当前位置: 首页>>代码示例>>PHP>>正文


PHP invoice::prepare_code_invoice方法代码示例

本文整理汇总了PHP中invoice::prepare_code_invoice方法的典型用法代码示例。如果您正苦于以下问题:PHP invoice::prepare_code_invoice方法的具体用法?PHP invoice::prepare_code_invoice怎么用?PHP invoice::prepare_code_invoice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在invoice的用法示例。


在下文中一共展示了invoice::prepare_code_invoice方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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
                        
//.........这里部分代码省略.........
开发者ID:carriercomm,项目名称:amberdms-bs,代码行数:101,代码来源:inc_services_invoicegen.php

示例2: 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
}
开发者ID:carriercomm,项目名称:amberdms-bs,代码行数:94,代码来源:inc_invoices_process.php

示例3: 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");
     }
 }
开发者ID:carriercomm,项目名称:amberdms-bs,代码行数:81,代码来源:invoices_manage.php


注:本文中的invoice::prepare_code_invoice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。