本文整理汇总了PHP中invoice::generate_email方法的典型用法代码示例。如果您正苦于以下问题:PHP invoice::generate_email方法的具体用法?PHP invoice::generate_email怎么用?PHP invoice::generate_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类invoice
的用法示例。
在下文中一共展示了invoice::generate_email方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
function execute()
{
log_debug("invoice_form_export", "Executing execute()");
/*
Fetch basic invoice details
*/
$obj_sql_invoice = new sql_query();
if ($this->type == "ar") {
$obj_sql_invoice->string = "SELECT code_invoice, customerid FROM account_" . $this->type . " WHERE id='" . $this->invoiceid . "' LIMIT 1";
} else {
$obj_sql_invoice->string = "SELECT code_quote, customerid FROM account_" . $this->type . " WHERE id='" . $this->invoiceid . "' LIMIT 1";
}
$obj_sql_invoice->execute();
$obj_sql_invoice->fetch_array();
/*
Generate Email
This function call provides us with all the email fields we can use to complete the form with.
*/
$obj_invoice = new invoice();
$obj_invoice->type = $this->type;
$obj_invoice->id = $this->invoiceid;
$email = $obj_invoice->generate_email();
/*
Define email form
*/
$this->obj_form_email = new form_input();
$this->obj_form_email->formname = "invoice_export_email";
$this->obj_form_email->language = $_SESSION["user"]["lang"];
$this->obj_form_email->action = $this->processpage;
$this->obj_form_email->method = "post";
// general
$structure = NULL;
$structure["fieldname"] = "sender";
$structure["type"] = "radio";
$structure["defaultvalue"] = $email["sender"];
$structure["values"] = array("system", "user");
$structure["translations"]["system"] = sql_get_singlevalue("SELECT value FROM config WHERE name='COMPANY_NAME'") . " <" . sql_get_singlevalue("SELECT value FROM config WHERE name='COMPANY_CONTACT_EMAIL'") . ">";
$structure["translations"]["user"] = user_information("realname") . " <" . user_information("contact_email") . ">";
$this->obj_form_email->add_input($structure);
$structure = NULL;
$structure["fieldname"] = "subject";
$structure["type"] = "input";
$structure["defaultvalue"] = $email["subject"];
$structure["options"]["width"] = "600";
$this->obj_form_email->add_input($structure);
$structure = NULL;
$structure["fieldname"] = "email_to";
$structure["type"] = "input";
$structure["defaultvalue"] = $email["to"];
$structure["options"]["width"] = "600";
$this->obj_form_email->add_input($structure);
$structure = NULL;
$structure["fieldname"] = "email_cc";
$structure["type"] = "input";
$structure["defaultvalue"] = $email["cc"];
$structure["options"]["width"] = "600";
$this->obj_form_email->add_input($structure);
$structure = NULL;
$structure["fieldname"] = "email_bcc";
$structure["type"] = "input";
$structure["defaultvalue"] = $email["bcc"];
$structure["options"]["width"] = "600";
$this->obj_form_email->add_input($structure);
$structure = NULL;
$structure["fieldname"] = "email_message";
$structure["type"] = "textarea";
$structure["defaultvalue"] = $email["message"];
$structure["options"]["width"] = "600";
$structure["options"]["height"] = "100";
$this->obj_form_email->add_input($structure);
// hidden
$structure = NULL;
$structure["fieldname"] = "formname";
$structure["type"] = "hidden";
$structure["defaultvalue"] = $this->obj_form_email->formname;
$this->obj_form_email->add_input($structure);
$structure = NULL;
$structure["fieldname"] = "id_invoice";
$structure["type"] = "hidden";
$structure["defaultvalue"] = $this->invoiceid;
$this->obj_form_email->add_input($structure);
// submit button
$structure = NULL;
$structure["fieldname"] = "submit";
$structure["type"] = "submit";
$structure["defaultvalue"] = "Send via Email";
$this->obj_form_email->add_input($structure);
// load any data returned due to errors
$this->obj_form_email->load_data_error();
/*
Define download form
*/
$this->obj_form_download = new form_input();
$this->obj_form_download->formname = "invoice_export_download";
$this->obj_form_download->language = $_SESSION["user"]["lang"];
$this->obj_form_download->action = $this->processpage;
$this->obj_form_download->method = "post";
// general
$structure = NULL;
//.........这里部分代码省略.........
示例2: page_execute
function page_execute()
{
/*
Check Configuration
*/
if (!empty($GLOBALS["config"]["ORDERS_BILL_ENDOFMONTH"])) {
/*
Check that today is the last day of the month
*/
//if (time_calculate_monthdate_last( date("Y-m-d") ) == date("Y-m-d"))
if (true) {
log_write("notification", "cron_orders", "Today is the end of the month, time to process customer orders and convert into invoices.");
/*
Fetch all the customer ID for customers who currently have order items - no point going through
*all* customers, only need to do those with items.
*/
$sql_customer_obj = new sql_query();
$sql_customer_obj->string = "SELECT id_customer FROM customers_orders GROUP BY id_customer";
$sql_customer_obj->execute();
if ($sql_customer_obj->num_rows()) {
$sql_customer_obj->fetch_array();
foreach ($sql_customer_obj->data as $data_customer) {
/*
Execute order processing for customer
*/
// generate the invoice
$obj_customer = new customer_orders();
$obj_customer->id = $data_customer["id_customer"];
$obj_customer->load_data();
$invoiceid = $obj_customer->invoice_generate();
// send the PDF (if desired)
if ($GLOBALS["config"]["ACCOUNTS_INVOICE_AUTOEMAIL"] == 1 || $GLOBALS["config"]["ACCOUNTS_INVOICE_AUTOEMAIL"] == "enabled") {
$invoice = new invoice();
$invoice->id = $invoiceid;
$invoice->type = "ar";
$invoice->load_data();
$invoice->load_data_export();
if ($invoice->data["amount_total"] > 0) {
// generate an email
$email = $invoice->generate_email();
// send email
$invoice->email_invoice("system", $email["to"], $email["cc"], $email["bcc"], $email["subject"], $email["message"]);
// complete
log_write("notification", "cron_orders", "Invoice " . $invoice->data["code_invoice"] . " has been emailed to customer (" . $email["to"] . ")");
} else {
// complete - invoice is for $0, so don't want to email out
log_write("notification", "cron_orders", "Invoice " . $invoice->data["code_invoice"] . " has not been emailed to the customer due to invoice being for \$0.");
}
unset($invoice);
} else {
log_write("notification", "cron_orders", "Not emailing invoice " . $invoice->data["code_invoice"] . " to customer due to ACCOUNTS_INVOICE_AUTOEMAIL being disabled");
}
}
}
log_write("notification", "cron_orders", "Completed processing of orders, total of " . $sql_customer_obj->num_rows() . " affected");
} else {
log_write("notification", "cron_orders", "Not processing orders, waiting until the end of the month");
}
} else {
log_write("notification", "cron_orders", "Not processing monthly orders, ORDERS_BILL_ENDOFMONTH option is disabled");
}
}
示例3: service_invoices_generate
//.........这里部分代码省略.........
}
/*
Commit
Conduct final error check, before commiting the new invoice and sending the customer an email
if appropiate.
(we obviously don't want to email them if the invoice is getting rolled back!)
*/
$sql_obj = new sql_query();
if (error_check()) {
$sql_obj->trans_rollback();
log_write("error", "inc_services_invoicegen", "An error occured whilst creating service invoice. No changes have been made.");
} else {
$sql_obj->trans_commit();
// invoice creation complete - remove any notifications made by the invoice functions and return
// our own notification
$_SESSION["notification"]["message"] = array();
log_write("notification", "inc_services_invoicegen", "New invoice {$invoicecode} for customer " . $customer_data["code_customer"] . " created");
/*
Send the invoice to the customer as a PDF via email
*/
$emailed = "unsent";
if (sql_get_singlevalue("SELECT value FROM config WHERE name='EMAIL_ENABLE'") == "enabled") {
if (sql_get_singlevalue("SELECT value FROM config WHERE name='ACCOUNTS_INVOICE_AUTOEMAIL'") == "enabled") {
// load completed invoice data
$invoice = new invoice();
$invoice->id = $invoiceid;
$invoice->type = "ar";
$invoice->load_data();
$invoice->load_data_export();
if ($invoice->data["amount_total"] > 0) {
// generate an email
$email = $invoice->generate_email();
// send email
$invoice->email_invoice("system", $email["to"], $email["cc"], $email["bcc"], $email["subject"], $email["message"]);
// complete
log_write("notification", "inc_services_invoicegen", "Invoice {$invoicecode} has been emailed to customer (" . $email["to"] . ")");
} else {
// complete - invoice is for $0, so don't want to email out
log_write("notification", "inc_services_invoicegen", "Invoice {$invoicecode} has not been emailed to the customer due to invoice being for \$0.");
}
$emailed = "emailed - " . $email["to"];
unset($invoice);
}
}
// end if email enabled
}
// end if commit successful
/*
Review Status
Here we need to check whether invoicing succeded/failed for the selected customer and process accordingly - we
also want to re-set the error flag if running a batch mode, to enable other customers to still be invoiced.
*/
if (error_check()) {
// an error occured
$invoice_stats["total_failed"]++;
$invoice_stats["failed"][] = array("code_customer" => $customer_data["code_customer"], "name_customer" => $customer_data["name_customer"], "code_invoice" => $invoicecode);
// clear the error strings if we are processing from CLI this will allow us to continue on
// with additional invoices.
if (!empty($_SESSION["mode"])) {
if ($_SESSION["mode"] == "cli") {
log_write("debug", "inc_services_invoicegen", "Processing from CLI, clearing error flag and continuing with additional invoices");
error_clear();
}
示例4: page_execute
function page_execute($argv)
{
/*
Input Options
*/
$option_date = NULL;
if (empty($argv[2])) {
die("You must provide a date option in form of YYYY-MM-DD\n");
}
if (preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $argv[2])) {
$option_date = $argv[2];
} else {
die("You must provide a date option in form of YYYY-MM-DD - wrong format supplied\n");
}
/*
Respect Configuration
*/
if ($GLOBALS["config"]["EMAIL_ENABLE"] != "enabled") {
die("The configuration option EMAIL_ENABLE is disabled - you need to enable emailing before proceeding with this script");
}
/*
Fetch all invoices for the period
*/
$obj_invoice_sql = new sql_query();
$obj_invoice_sql->string = "SELECT id, code_invoice, date_sent, sentmethod FROM account_ar WHERE date_trans='{$option_date}'";
$obj_invoice_sql->execute();
if ($obj_invoice_sql->num_rows()) {
$obj_invoice_sql->fetch_array();
foreach ($obj_invoice_sql->data as $data_invoice) {
log_write("debug", "script", "Processing invoice " . $data_invoice["code_invoice"] . "");
if ($data_invoice["sentmethod"]) {
// already sent
log_write("debug", "script", "Invoice has already been sent on " . $data_invoice["data_sent"] . ", not re-sending");
} else {
// never has been sent
log_write("debug", "script", "Invoice has never been sent, preparing to send via email.");
// load completed invoice data
$invoice = new invoice();
$invoice->id = $data_invoice["id"];
$invoice->type = "ar";
$invoice->load_data();
$invoice->load_data_export();
if ($invoice->data["amount_total"] > 0) {
// generate an email
$email = $invoice->generate_email();
// send email
if ($invoice->email_invoice("system", $email["to"], $email["cc"], $email["bcc"], $email["subject"], $email["message"])) {
// complete
log_write("notification", "script", "Invoice " . $data_invoice["code_invoice"] . " has been emailed to customer (" . $email["to"] . ")");
} else {
// failure
log_write("error", "script", "An error occured whilst attempting to send invoice " . $data_invoice["code_invoice"] . " to " . $email["to"] . "");
}
} else {
// complete - invoice is for $0, so don't want to email out
log_write("notification", "script", "Invoice " . $data_invoice["code_invoice"] . " has not been emailed to the customer due to invoice being for \$0.");
}
unset($invoice);
}
// end of invoice needs sending
}
// end of invoice loop
} else {
log_write("notification", "script", "There are no invoices for the supplied date period");
}
}