本文整理汇总了PHP中invoice::load_data方法的典型用法代码示例。如果您正苦于以下问题:PHP invoice::load_data方法的具体用法?PHP invoice::load_data怎么用?PHP invoice::load_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类invoice
的用法示例。
在下文中一共展示了invoice::load_data方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: invoice
//fetch basic customer details
$obj_sql_contact = new sql_query();
$obj_sql_contact->string = "SELECT id, contact FROM customer_contacts WHERE customer_id = '" . $obj_sql_invoice->data[0]["customerid"] . "' AND role = 'accounts'";
$obj_sql_contact->execute();
$obj_sql_contact->fetch_array();
//fetch email to address, set error if no address is set
$to = sql_get_singlevalue("SELECT detail AS value FROM customer_contact_records WHERE contact_id = '" . $obj_sql_contact->data[0]["id"] . "' AND type = 'email' LIMIT 1");
if (!$to) {
$error_array[] = $obj_sql_invoice->data[0]["code_invoice"];
continue;
}
//create invoice
$obj_invoice = new invoice();
$obj_invoice->type = "ar";
$obj_invoice->id = $invoice_id;
$obj_invoice->load_data();
$obj_invoice->load_data_export();
//get templating keys and values
$invoice_data = $obj_invoice->invoice_fields;
$invoice_data_parts['keys'] = array_keys($invoice_data);
$invoice_data_parts['values'] = array_values($invoice_data);
foreach ($invoice_data_parts['keys'] as $index => $key) {
$invoice_data_parts['keys'][$index] = "(" . $key . ")";
}
foreach ($invoice_data_parts['values'] as $index => $value) {
$invoice_data_parts['values'][$index] = trim($value);
}
$invoice_data_parts['keys'][] = "(days_overdue)";
$invoice_data_parts['values'][] = trim($days_overdue);
//create email message
$email_message = @security_form_input_predefined("any", "email_message", 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: service_invoices_generate
function service_invoices_generate($customerid = NULL)
{
log_debug("inc_services_invoicegen", "Executing service_invoices_generate({$customerid})");
/*
Invoice Report Statistics
*/
$invoice_stats = array();
$invoice_stats["time_start"] = time();
$invoice_stats["total"] = 0;
$invoice_stats["total_failed"] = 0;
/*
Run through all the customers
*/
$sql_customers_obj = new sql_query();
$sql_customers_obj->string = "SELECT id, code_customer, name_customer FROM customers";
if ($customerid) {
$sql_customers_obj->string .= " WHERE id='{$customerid}' LIMIT 1";
}
$sql_customers_obj->execute();
if ($sql_customers_obj->num_rows()) {
$sql_customers_obj->fetch_array();
foreach ($sql_customers_obj->data as $customer_data) {
/*
Fetch all periods belonging to this customer which need to be billed.
*/
$sql_periods_obj = new sql_query();
$sql_periods_obj->string = "SELECT " . "services_customers_periods.id, " . "services_customers_periods.rebill, " . "services_customers_periods.invoiceid, " . "services_customers_periods.invoiceid_usage, " . "services_customers_periods.date_start, " . "services_customers_periods.date_end, " . "services_customers.date_period_first, " . "services_customers.date_period_next, " . "services_customers.date_period_last, " . "services_customers.id as id_service_customer, " . "services_customers.serviceid " . "FROM services_customers_periods " . "LEFT JOIN services_customers ON services_customers.id = services_customers_periods.id_service_customer " . "WHERE " . "services_customers.customerid='" . $customer_data["id"] . "' " . "AND (invoiceid = '0' OR rebill = '1')" . "AND date_billed <= '" . date("Y-m-d") . "'";
$sql_periods_obj->execute();
if ($sql_periods_obj->num_rows()) {
$sql_periods_obj->fetch_array();
/*
BILL CUSTOMER
This customer has at least one service that needs to be billed. We need to create
a new invoice, and then process each service, adding the services to the invoice as
items.
*/
/*
Start Transaction
(one transaction per invoice)
*/
$sql_obj = new sql_query();
$sql_obj->trans_begin();
/*
Create new invoice
*/
$invoice = new invoice();
$invoice->type = "ar";
$invoice->prepare_code_invoice();
$invoice->data["customerid"] = $customer_data["id"];
$invoice->data["employeeid"] = 1;
// set employee to the default internal user
$invoice->prepare_date_shift();
if (!$invoice->action_create()) {
log_write("error", "services_invoicegen", "Unexpected problem occured whilst attempting to create invoice.");
$sql_obj->trans_rollback();
return 0;
}
$invoiceid = $invoice->id;
$invoicecode = $invoice->data["code_invoice"];
unset($invoice);
/*
Create Service Items
We need to create an item for basic service plan - IE: the regular fixed fee, and another item for any
excess usage.
*/
foreach ($sql_periods_obj->data as $period_data) {
/*
TODO:
We should be able to re-bill usage here when needed with a clever cheat - if we load the periods to be billed,
we can then ignore the plan item, and rebill the usage item.
*/
$period_data["mode"] = "standard";
if ($period_data["rebill"]) {
if (!$period_data["invoiceid_usage"] && $period_data["invoiceid"]) {
// the selected period has been billed, but the usage has been flagged for rebilling - we need to *ignore* the base plan
// item and only bill for the usage range.
$period_data["mode"] = "rebill_usage";
}
}
// fetch service details
$obj_service = new service_bundle();
$obj_service->option_type = "customer";
$obj_service->option_type_id = $period_data["id_service_customer"];
if (!$obj_service->verify_id_options()) {
log_write("error", "customers_services", "Unable to verify service ID of " . $period_data["id_service_customer"] . " as being valid.");
return 0;
}
$obj_service->load_data();
$obj_service->load_data_options();
// ratio is used to adjust prices for partial periods
$ratio = 1;
if ($obj_service->data["billing_mode_string"] == "monthend" || $obj_service->data["billing_mode_string"] == "monthadvance" || $obj_service->data["billing_mode_string"] == "monthtelco") {
log_debug("services_invoicegen", "Invoice bills by month date");
/*
Handle monthly billing
//.........这里部分代码省略.........
示例4: 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");
}
}
示例5: SoapFault
function get_invoice_pdf($id, $invoicetype)
{
log_debug("invoices_manage_soap", "Executing get_invoice_pdf({$id}, {$invoicetype})");
// check the invoice type
if ($invoicetype != "ar" && $invoicetype != "ap") {
throw new SoapFault("Sender", "INVALID_INVOICE_TYPE");
}
if (user_permissions_get("accounts_" . $invoicetype . "_view")) {
$obj_invoice = new invoice();
$obj_invoice->type = $invoicetype;
// sanitise input
$obj_invoice->id = @security_script_input_predefined("int", $id);
if (!$obj_invoice->id || $obj_invoice->id == "error") {
throw new SoapFault("Sender", "INVALID_INPUT");
}
// verify that the invoice is valid
if (!$obj_invoice->verify_invoice()) {
throw new SoapFault("Sender", "INVALID_INVOICE");
}
// load data from DB for this invoice
if (!$obj_invoice->load_data()) {
throw new SoapFault("Sender", "UNEXPECTED_ACTION_ERROR");
}
// generate PDF
$obj_invoice->generate_pdf();
// return data
return base64_encode($obj_invoice->obj_pdf->output);
} else {
throw new SoapFault("Sender", "ACCESS_DENIED");
}
}
示例6: 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");
}
}