本文整理汇总了PHP中invoice::action_create方法的典型用法代码示例。如果您正苦于以下问题:PHP invoice::action_create方法的具体用法?PHP invoice::action_create怎么用?PHP invoice::action_create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类invoice
的用法示例。
在下文中一共展示了invoice::action_create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: invoice_form_details_process
function invoice_form_details_process($type, $mode, $returnpage_error, $returnpage_success)
{
log_debug("inc_invoices_forms", "Executing invoice_form_details_process({$type}, {$mode}, {$returnpage_error}, {$returnpage_success})");
// TODO: it seems this function requests the $mode, but then works it out itself anyway.
// check out what is going on here.
/*
Start the invoice
*/
$invoice = new invoice();
$invoice->type = $type;
/*
Fetch all form data
*/
// get the ID for an edit
if ($mode == "edit") {
$invoice->id = @security_form_input_predefined("int", "id_invoice", 1, "");
}
// general details
if ($type == "ap") {
$invoice->data["vendorid"] = @security_form_input_predefined("int", "vendorid", 1, "");
} else {
$invoice->data["customerid"] = @security_form_input_predefined("int", "customerid", 1, "");
}
$invoice->data["employeeid"] = @security_form_input_predefined("int", "employeeid", 1, "");
$invoice->data["notes"] = @security_form_input_predefined("any", "notes", 0, "");
$invoice->data["code_ordernumber"] = @security_form_input_predefined("any", "code_ordernumber", 0, "");
$invoice->data["code_ponumber"] = @security_form_input_predefined("any", "code_ponumber", 0, "");
$invoice->data["date_trans"] = @security_form_input_predefined("date", "date_trans", 1, "");
$invoice->data["date_due"] = @security_form_input_predefined("date", "date_due", 1, "");
// other
$invoice->data["dest_account"] = @security_form_input_predefined("int", "dest_account", 1, "");
// are we editing an existing invoice or adding a new one?
if ($invoice->id) {
$mode = "edit";
// make sure the invoice actually exists
if (!$invoice->verify_invoice()) {
log_write("error", "process", "The invoice you have attempted to edit - " . $invoice->id . " - does not exist in this system.");
}
// check if invoice is locked or not
if ($invoice->check_lock()) {
log_write("error", "process", "The invoice can not be edited because it is locked.");
}
} else {
$mode = "add";
}
// invoice must be provided by edit page, but not by add invoice, since we can just generate a new one
if ($mode == "add") {
$invoice->data["code_invoice"] = @security_form_input_predefined("any", "code_invoice", 0, "");
} else {
$invoice->data["code_invoice"] = @security_form_input_predefined("any", "code_invoice", 1, "");
}
//// ERROR CHECKING ///////////////////////
// make sure we don't choose a invoice invoice number that is already in use
if ($invoice->data["code_invoice"]) {
$invoice->prepare_code_invoice($invoice->data["code_invoice"]);
}
/// if there was an error, go back to the entry page
if ($_SESSION["error"]["message"]) {
$_SESSION["error"]["form"][$type . "_invoice_" . $mode] = "failed";
header("Location: ../../index.php?page={$returnpage_error}&id=" . $invoice->id . "");
exit(0);
} else {
// GENERATE INVOICE ID
// if no invoice ID has been supplied, we now need to generate a unique invoice id
if (!$invoice->data["code_invoice"]) {
$invoice->prepare_code_invoice();
}
// APPLY GENERAL OPTIONS
if ($mode == "add") {
// create a new invoice
if ($invoice->action_create()) {
$_SESSION["notification"]["message"][] = "Invoice successfully created.";
journal_quickadd_event("account_" . $invoice->type . "", $invoice->id, "Invoice successfully created");
} else {
$_SESSION["error"]["message"] = "An error occured whilst attempting to create the invoice";
}
// display items page
$returnpage_success = str_replace("view", "items", $returnpage_success);
header("Location: ../../index.php?page={$returnpage_success}&id=" . $invoice->id . "");
} else {
// update an existing invoice
if ($invoice->action_update()) {
$_SESSION["notification"]["message"][] = "Invoice successfully updated.";
journal_quickadd_event("account_" . $invoice->type . "", $invoice->id, "Invoice successfully updated");
} else {
$_SESSION["error"]["message"] = "An error occured whilst attempting to update the invoice";
}
// display updated details
header("Location: ../../index.php?page={$returnpage_success}&id=" . $invoice->id . "");
}
exit(0);
}
// end if passed tests
}
示例2: SoapFault
function set_invoice_details($id, $invoicetype, $locked, $orgid, $employeeid, $dest_account, $code_invoice, $code_ordernumber, $code_ponumber, $date_due, $date_trans, $date_sent, $sendmethod, $notes)
{
log_debug("accounts_invoices_manage", "Executing set_invoice_details({$id}, {$invoicetype}, values...)");
// check the invoicetype
if ($invoicetype != "ar" && $invoicetype != "ap") {
throw new SoapFault("Sender", "INVALID_INVOICE_TYPE");
}
if (user_permissions_get("accounts_" . $invoicetype . "_write")) {
$obj_invoice = new invoice();
$obj_invoice->type = $invoicetype;
/*
Load SOAP Data
TODO: a number of these options might just be ignored by the action_update command - look
into this possiblity
*/
$obj_invoice->id = @security_script_input_predefined("int", $id);
$obj_invoice->data["locked"] = @security_script_input_predefined("int", $locked);
if ($invoicetype == "ap") {
$obj_invoice->data["vendorid"] = @security_script_input_predefined("int", $orgid);
} else {
$obj_invoice->data["customerid"] = @security_script_input_predefined("int", $orgid);
}
$obj_invoice->data["employeeid"] = @security_script_input_predefined("int", $employeeid);
$obj_invoice->data["dest_account"] = @security_script_input_predefined("int", $dest_account);
$obj_invoice->data["code_invoice"] = @security_script_input_predefined("any", $code_invoice);
$obj_invoice->data["code_ordernumber"] = @security_script_input_predefined("any", $code_ordernumber);
$obj_invoice->data["code_ponumber"] = @security_script_input_predefined("any", $code_ponumber);
$obj_invoice->data["date_due"] = @security_script_input_predefined("date", $date_due);
$obj_invoice->data["date_trans"] = @security_script_input_predefined("date", $date_trans);
$obj_invoice->data["date_sent"] = @security_script_input_predefined("date", $date_sent);
$obj_invoice->data["sentmethod"] = @security_script_input_predefined("any", $sentmethod);
$obj_invoice->data["notes"] = @security_script_input_predefined("any", $notes);
foreach (array_keys($obj_invoice->data) as $key) {
// TODO: what the fuck is wrong with php here???
//
// weird bug work around - without the != 0 statement, $obj_invoice->data["locked"] will
// match "error", despite equaling 0.
if ($obj_invoice->data[$key] == "error" && $obj_invoice->data[$key] != 0) {
throw new SoapFault("Sender", "INVALID_INPUT");
}
}
/*
Error Handling
*/
// verify invoice exisitance (if editing an existing one)
if ($obj_invoice->id) {
if (!$obj_invoice->verify_invoice()) {
throw new SoapFault("Sender", "INVALID_INVOICE");
}
// make sure invoice is not locked
if ($obj_invoice->check_lock()) {
throw new SoapFault("Sender", "LOCKED");
}
}
// make sure we don't choose a invoice code that has already been taken
if (!$obj_invoice->prepare_code_invoice($obj_invoice->data["code_invoice"])) {
throw new SoapFault("Sender", "DUPLICATE_CODE_INVOICE");
}
/*
Perform Changes
*/
if ($obj_invoice->id) {
// update existing invoice
if ($obj_invoice->action_update()) {
return $obj_invoice->id;
} else {
throw new SoapFault("Sender", "UNEXPECTED_ACTION_ERROR");
}
} else {
// create new invoice
if ($obj_invoice->action_create()) {
return $obj_invoice->id;
} else {
throw new SoapFault("Sender", "UNEXPECTED_ACTION_ERROR");
}
}
} else {
throw new SoapFault("Sender", "ACCESS DENIED");
}
}
示例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: invoice
function invoice_generate($invoiceid = NULL)
{
log_write("debug", "inc_customers", "Executing invoice_generate()");
// we don't need to worry about checking if this is the appropiate date, that logic is handled by
// other functions before calling this one.
// initatiate SQL
$sql_obj = new sql_query();
$sql_obj->trans_begin();
// do we need to create an invoice?
if (!$invoiceid) {
$obj_invoice = new invoice();
$obj_invoice->type = "ar";
$obj_invoice->data["customerid"] = $this->id;
$obj_invoice->data["employeeid"] = 1;
$obj_invoice->data["notes"] = "Invoice generated from customer orders page.";
$obj_invoice->prepare_date_shift();
$obj_invoice->action_create();
$invoiceid = $obj_invoice->id;
log_write("debug", "inc_customers", "Creating a new invoice with ID of {$invoiceid}");
} else {
// reuse existing
log_write("debug", "inc_customers", "Using specified invoice {$invoiceid} for orders invoicing");
}
// run through the items and add to the invoice
$obj_orders_sql = new sql_query();
$obj_orders_sql->string = "SELECT * FROM customers_orders WHERE id_customer='" . $this->id . "'";
$obj_orders_sql->execute();
if ($obj_orders_sql->num_rows()) {
$obj_orders_sql->fetch_array();
foreach ($obj_orders_sql->data as $data_order) {
log_write("debug", "inc_customers", "Adding order item " . $data_order["id"] . " to invoice " . $invoiceid . " for customer " . $this->id . "");
// select values desired, certain safety checks
$data_order_tmp = array();
$data_order_tmp["customid"] = $data_order["customid"];
$data_order_tmp["quantity"] = $data_order["quantity"];
$data_order_tmp["units"] = addslashes($data_order["units"]);
$data_order_tmp["amount"] = $data_order["amount"];
$data_order_tmp["price"] = $data_order["price"];
$data_order_tmp["discount"] = $data_order["discount"];
$data_order_tmp["description"] = addslashes($data_order["description"]);
// Add each order as an item on the invoice.
$obj_item = new invoice_items();
$obj_item->id_invoice = $invoiceid;
$obj_item->type_invoice = "ar";
$obj_item->type_item = $data_order["type"];
$obj_item->prepare_data($data_order_tmp);
$obj_item->action_create();
$obj_item->action_update();
// delete the item now that it's been added
$obj_delete_sql = new sql_query();
$obj_delete_sql->string = "DELETE FROM customers_orders WHERE id='" . $data_order["id"] . "' LIMIT 1";
$obj_delete_sql->execute();
unset($obj_delete_sql);
}
// update invoice summary information
$obj_item->action_update_tax();
$obj_item->action_update_total();
$obj_item->action_update_ledger();
unset($obj_item);
}
// end if order items.
// make automated payments - such as customer credit pool or auto-pay credit card functionality
if ($GLOBALS["config"]["ACCOUNTS_AUTOPAY"]) {
log_write("debug", "inc_services_invoicegen", "Autopay Functionality Enabled, running appropiate functions for invoice ID {$invoiceid}");
$obj_autopay = new invoice_autopay();
$obj_autopay->id_invoice = $invoiceid;
$obj_autopay->type_invoice = "ar";
$obj_autopay->autopay();
unset($obj_autopay);
}
// save changes
if (error_check()) {
$sql_obj->trans_rollback();
log_write("error", "inc_customers", "An error occurred whilst attempting to generate an invoice.");
return 0;
} else {
$sql_obj->trans_commit();
log_write("notification", "inc_customers", "Successfully generate invoice " . $obj_invoice->data["code_invoice"] . " for customer " . $this->data["name_customer"] . "");
return $invoiceid;
}
}