本文整理汇总了PHP中invoice::email_invoice方法的典型用法代码示例。如果您正苦于以下问题:PHP invoice::email_invoice方法的具体用法?PHP invoice::email_invoice怎么用?PHP invoice::email_invoice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类invoice
的用法示例。
在下文中一共展示了invoice::email_invoice方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: header
//create email message
$email_message = @security_form_input_predefined("any", "email_message", 0, "");
$email_message = str_replace($invoice_data_parts['keys'], $invoice_data_parts['values'], $email_message);
//create subject
$subject = @security_form_input_predefined("any", "subject", 0, "");
$subject = str_replace($invoice_data_parts['keys'], $invoice_data_parts['values'], $subject);
//sender
$from = @security_form_input_predefined("any", "sender", 0, "");
if ($from == "user") {
$from = user_information("contact_email");
} else {
$from = sql_get_singlevalue("SELECT value FROM config WHERE name='COMPANY_CONTACT_EMAIL'");
}
log_debug("EMAIL", "avout to send" . $i);
// send email
$obj_invoice->email_invoice($from, $to, "", "", $subject, $email_message);
$_SESSION["notification"]["message"][] = "Reminder email for Invoice " . $obj_sql_invoice->data[0]["code_invoice"] . " was sent successfully.";
}
}
//set error messages for emails that couldn't be sent
for ($i = 0; $i < count($error_array); $i++) {
$_SESSION["error"]["message"][] = "Reminder for Invoice " . $error_array[$i] . " was not sent as no email is set for the customer's default account.";
}
header("Location: ../../index.php?page=accounts/ar/account-statements.php");
exit(0);
} else {
// user does not have perms to view this page/isn't logged on
error_render_noperms();
header("Location: ../../index.php?page=message.php");
exit(0);
}
示例2: invoice_form_export_process
function invoice_form_export_process($type, $returnpage_error, $returnpage_success)
{
log_debug("inc_invoices_forms", "Executing invoice_form_export_process({$type}, {$returnpage_error}, {$returnpage_success})");
/*
Start the invoice
*/
$invoice = new invoice();
$invoice->type = $type;
/*
Fetch all form data
*/
// get the ID for an edit
$invoice->id = @security_form_input_predefined("int", "id_invoice", 1, "");
// general details
$data["formname"] = @security_form_input_predefined("any", "formname", 1, "");
if ($data["formname"] == "invoice_export_email") {
// send email
$data["sender"] = @security_form_input_predefined("any", "sender", 1, "");
$data["subject"] = @security_form_input_predefined("any", "subject", 1, "");
$data["email_to"] = @security_form_input_predefined("multiple_email", "email_to", 1, "");
$data["email_cc"] = @security_form_input_predefined("multiple_email", "email_cc", 0, "");
$data["email_bcc"] = @security_form_input_predefined("multiple_email", "email_bcc", 0, "");
$data["message"] = @security_form_input_predefined("any", "email_message", 1, "");
// check if email sending is permitted
if (sql_get_singlevalue("SELECT value FROM config WHERE name='EMAIL_ENABLE'") != "enabled") {
log_write("error", "inc_invoices_process", "Sorry, the ability to email invoices has been disabled. Please contact your system administrator if you require this feature to be enabled.");
}
} else {
// PDF download
$data["invoice_mark_as_sent"] = @security_form_input_predefined("any", "invoice_mark_as_sent", 0, "");
}
// make sure that the invoice exists
$sql_obj = new sql_query();
$sql_obj->string = "SELECT id FROM `account_" . $invoice->type . "` WHERE id='" . $invoice->id . "'";
$sql_obj->execute();
if (!$sql_obj->num_rows()) {
$_SESSION["error"]["message"][] = "The invoice you have attempted to edit - " . $invoice->id . " - does not exist in this system.";
}
//// ERROR CHECKING ///////////////////////
/// if there was an error, go back to the entry page
if (!empty($_SESSION["error"]["message"])) {
header("Location: ../../index.php?page={$returnpage_error}&id=" . $invoice->id . "");
exit(0);
} else {
if ($data["formname"] == "invoice_export_email") {
/*
Generate a PDF of the invoice and email it to the customer
*/
// stripslashes from the variables - by default all input variables are quoted for security reasons but
// we don't want this going through to the email.
$data["subject"] = stripslashes($data["subject"]);
$data["message"] = stripslashes($data["message"]);
// send email
$invoice->load_data();
$invoice->email_invoice($data["sender"], $data["email_to"], $data["email_cc"], $data["email_bcc"], $data["subject"], $data["message"]);
$_SESSION["notification"]["message"][] = "Email sent successfully.";
} else {
/*
Mark invoice as being sent if user requests it
*/
if ($data["invoice_mark_as_sent"]) {
$sql_obj = new sql_query();
$sql_obj->string = "UPDATE account_" . $invoice->type . " SET date_sent='" . date("Y-m-d") . "', sentmethod='manual' WHERE id='" . $invoice->id . "'";
$sql_obj->execute();
}
/*
Provide PDF to user's browser
*/
// generate PDF
$invoice->load_data();
$invoice->generate_pdf();
// PDF headers
if ($type == "quotes") {
$filename = "/tmp/quote_" . $invoice->data["code_quote"] . ".pdf";
} else {
$filename = "/tmp/invoice_" . $invoice->data["code_invoice"] . ".pdf";
}
// required for IE, otherwise Content-disposition is ignored
if (ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
header("Pragma: public");
// required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
// required for certain browsers
header("Content-Type: application/pdf");
header("Content-Disposition: attachment; filename=\"" . basename($filename) . "\";");
header("Content-Transfer-Encoding: binary");
// output the PDF
print $invoice->obj_pdf->output;
exit(0);
}
// display updated details
header("Location: ../../index.php?page={$returnpage_success}&id=" . $invoice->id . "");
exit(0);
}
// end if passed tests
}
示例3: 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");
}
}
示例4: 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();
}
}
} else {
示例5: 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");
}
}