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


PHP invoice::voidInvoice方法代码示例

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


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

示例1: task

 function task($VAR)
 {
     require_once PATH_MODULES . 'email_template/email_template.inc.php';
     require_once PATH_MODULES . 'invoice/invoice.inc.php';
     $invoice = new invoice();
     # get active net terms
     $db =& DB();
     $rs =& $db->Execute($sql = sqlSelect($db, "net_term", "*", "status=1"));
     if ($rs && $rs->RecordCount() > 0) {
         // loop through net terms
         while (!$rs->EOF) {
             $id = $rs->fields['id'];
             $last_interval = mktime(0, 0, 0, date('m'), date('d') - $rs->fields['terms'], date('Y'));
             $i =& $db->Execute($sql = sqlSelect($db, "invoice", "id,account_id,total_amt,billed_amt,due_date,net_term_date_last,net_term_intervals", "net_term_id = {$id} AND\n\t\t\t\t\t (suspend_billing = 0 OR suspend_billing IS NULL) AND\n\t\t\t\t\t (billing_status = 0 OR billing_status IS NULL) AND \n\t\t\t\t\t due_date <= {$last_interval} AND\n\t\t\t\t\t net_term_date_last <= {$last_interval}"));
             if ($i && $i->RecordCount() > 0) {
                 // loop through invoices
                 while (!$i->EOF) {
                     $terms = $rs->fields['terms'];
                     echo "<BR>" . ($start_interval = $i->fields['net_term_date_last']);
                     echo "<BR>" . ($stop_interval = $start_interval + 86400 * $terms);
                     echo "<BR>" . date(UNIX_DATE_FORMAT, $start_interval);
                     // charge or suspend?
                     if (!empty($i->fields['net_term_intervals']) && $rs->fields['suspend_intervals'] < $i->fields['net_term_intervals']) {
                         // suspend invoice
                         $arr['id'] = $i->fields['id'];
                         $na =& $invoice->voidInvoice($arr, $invoice);
                         // suspend billing status
                         $fields = array('suspend_billing' => 1);
                         $db->Execute($sql = sqlUpdate($db, "invoice", $fields, "id = {$i->fields['id']}"));
                         // send suspend e-mail
                         if ($rs->fields['enable_emails']) {
                             $email = new email_template();
                             $email->send('net_term_suspend', $i->fields['account_id'], $i->fields['id'], $rs->fields['suspend_intervals'], $i->fields['net_term_intervals']);
                         }
                     } else {
                         // calc late fee
                         if ($rs->fields['fee_type'] == 1) {
                             $fee = $rs->fields['fee'];
                         } else {
                             $fee = ($i->fields['total_amt'] - $i->fields['billed_amt']) * $rs->fields['fee'];
                         }
                         // create late charge
                         if ($fee > 0) {
                             $fields = array('date_orig' => time(), 'status' => 0, 'account_id' => $i->fields['account_id'], 'amount' => $fee, 'sweep_type' => $rs->fields['sweep_type'], 'taxable' => $this->taxable, 'quantity' => 1, 'attributes' => "Name=={$rs->fields['name']}\r\nInterval==" . date(UNIX_DATE_FORMAT, $start_interval) . " - " . date(UNIX_DATE_FORMAT, $stop_interval), 'description' => $rs->fields['sku']);
                             $db->Execute($sql = sqlInsert($db, "charge", $fields));
                             // update invoice
                             $_fields['net_term_intervals'] = $i->fields['net_term_intervals'] + 1;
                             $_fields['net_term_date_last'] = $stop_interval;
                             $db->Execute($sql = sqlUpdate($db, "invoice", $_fields, "id={$i->fields['id']}"));
                             echo "<BR><BR>{$sql}";
                         }
                         // send late fee/payment reminder e-mail:
                         if ($rs->fields['enable_emails']) {
                             $email = new email_template();
                             $email->send('net_term_late_notice', $i->fields['account_id'], $i->fields['id'], number_format($fee, 2), number_format($rs->fields['suspend_intervals'] - $i->fields['net_term_intervals']));
                         }
                     }
                     $i->MoveNext();
                 }
             }
             $rs->MoveNext();
         }
     }
 }
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:64,代码来源:net_term.inc.php

示例2: postback


//.........这里部分代码省略.........
         if ($result === false) {
             $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
         }
         $actual_billed_currency_id = $result->fields['id'];
         if (is_string($result->fields["convert_array"])) {
             $convert = unserialize($result->fields["convert_array"]);
         } else {
             $convert = false;
         }
         $this->format_currency[$actual_billed_currency_id] = array('symbol' => $result->fields["symbol"], 'convert' => $convert, 'iso' => $result->fields["three_digit"]);
         if ($result->RecordCount() == 0 || $actual_billed_currency_id == $billed_currency_id) {
             # same as billed_currency_id
             $this->billed_amt = $arr['amount'] + $billed_amt;
             $this->actual_billed_amt = $arr['amount'] + $billed_amt;
             $this->actual_billed_currency_id = $actual_billed_currency_id;
         } else {
             # Get the billed currency id currency info:
             $q = "SELECT * FROM " . AGILE_DB_PREFIX . "currency WHERE\n\t\t        \t\t\tid   \t= " . $db->qstr($billed_currency_id) . " AND\n\t\t        \t\t\tsite_id = " . $db->qstr(DEFAULT_SITE);
             $result = $db->Execute($q);
             if ($result === false) {
                 $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
             }
             $this->format_currency[$billed_currency_id] = array('symbol' => $result->fields["symbol"], 'convert' => unserialize($result->fields["convert_array"]), 'iso' => $result->fields["three_digit"]);
             # Convert the invoice amount to the actual billed currency amount
             $due_amount = $invoice->fields['total_amt'] - $invoice->fields['billed_amt'];
             $conversion = $this->format_currency[$billed_currency_id]["convert"][$actual_billed_currency_id]["rate"];
             $this->billed_amt = $billed_amt + ($arr['amount'] /= $conversion);
             $this->actual_billed_amt = $actual_billed_amt + $arr['amount'];
             $this->actual_billed_currency_id = $actual_billed_currency_id;
         }
     }
     # Check for any subscription_id
     if (!empty($arr['subscription_id'])) {
         $this->subscription_id = trim($arr['subscription_id']);
     } else {
         $this->subscription_id = trim($invoice->fields['checkout_plugin_data']);
     }
     # Check for the checkout_id
     if (!empty($arr['checkout_id'])) {
         $this->checkout_id = $arr['checkout_id'];
     } else {
         $this->checkout_id = $invoice->fields['checkout_plugin_id'];
     }
     # Check for the billing status:
     if ($this->billed_amt >= $invoice->fields['total_amt']) {
         $this->billing_status = '1';
     } else {
         $this->billing_status = '0';
     }
     # Check if this transaction_id has already been processed:
     $q = "SELECT id FROM " . AGILE_DB_PREFIX . "invoice_memo WHERE\n        \t\t\tinvoice_id \t= " . $db->qstr($invoice_id) . " AND\n        \t\t\ttype\t\t= " . $db->qstr('postback') . " AND\n        \t\t\tmemo\t\t= " . $db->qstr($arr['transaction_id']) . " AND\n        \t\t\tsite_id \t= " . $db->qstr(DEFAULT_SITE);
     $memo = $db->Execute($q);
     if ($memo === false) {
         $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
     }
     if ($memo->RecordCount() > 0) {
         # duplicate post:
         $C_debug->error('Duplicate Postback', 'checkout.inc.php :: postback()', "Duplicate postback for invoice {$arr['invoice_id']} & transaction id {$arr['transaction_id']}");
     } else {
         # Create the invoice memo:
         $memo_id = $db->GenID(AGILE_DB_PREFIX . 'invoice_memo_id');
         $q = "INSERT INTO\n\t        \t\t\t" . AGILE_DB_PREFIX . "invoice_memo \n\t        \t      SET\n\t        \t\t\tid \t\t\t\t\t= " . $db->qstr($memo_id) . ",\n\t        \t\t\tsite_id \t\t\t= " . $db->qstr(DEFAULT_SITE) . ",\n\t        \t\t\tdate_orig \t\t\t= " . $db->qstr(time()) . ", \n\t        \t\t\tinvoice_id\t \t\t= " . $db->qstr($invoice_id) . ", \n\t        \t\t\taccount_id\t\t\t= " . $db->qstr(0) . ", \n\t        \t\t\ttype\t\t\t\t= " . $db->qstr('postback') . ", \n\t        \t\t\tmemo\t\t\t\t= " . $db->qstr($arr['transaction_id']);
         $memosql = $db->Execute($q);
         if ($memosql === false) {
             $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
         }
         # Update the invoice billing info:
         $q = "UPDATE\n\t        \t\t\t" . AGILE_DB_PREFIX . "invoice \n\t        \t      SET\n\t        \t\t\tdate_last \t\t\t= " . $db->qstr(time()) . ", \n\t        \t\t\tbilling_status \t\t= " . $db->qstr($this->billing_status) . ", \n\t        \t\t\tcheckout_plugin_id\t= " . $db->qstr($this->checkout_id) . ", \n\t        \t\t\tcheckout_plugin_data = " . $db->qstr($this->subscription_id) . ", \n\t        \t\t\tbilled_amt\t\t\t= " . $db->qstr($this->billed_amt) . ", \n\t        \t\t\tactual_billed_amt\t= " . $db->qstr($this->actual_billed_amt) . ", \n\t        \t\t\tactual_billed_currency_id = " . $db->qstr($this->actual_billed_currency_id) . "\n\t        \t\t   WHERE\n\t        \t\t\tid \t\t\t= " . $db->qstr($invoice_id) . " AND\n\t        \t\t\tsite_id \t= " . $db->qstr(DEFAULT_SITE);
         $memosql = $db->Execute($q);
         if ($memosql === false) {
             $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
         }
         # Update the invoice approval status
         $VAR['id'] = $invoice_id;
         include_once PATH_MODULES . 'invoice/invoice.inc.php';
         $inv = new invoice();
         if (!$arr['status']) {
             # void
             $inv->voidInvoice($VAR);
             # create a record of the viod in an invoice memo:
             $memo_id = $db->GenID(AGILE_DB_PREFIX . 'invoice_memo_id');
             $q = "INSERT INTO\n\t\t        \t\t\t" . AGILE_DB_PREFIX . "invoice_memo \n\t\t        \t      SET\n\t\t        \t\t\tid \t\t\t\t\t= " . $db->qstr($memo_id) . ",\n\t\t        \t\t\tsite_id \t\t\t= " . $db->qstr(DEFAULT_SITE) . ",\n\t\t        \t\t\tdate_orig \t\t\t= " . $db->qstr(time()) . ", \n\t\t        \t\t\tinvoice_id\t \t\t= " . $db->qstr($invoice_id) . ", \n\t\t        \t\t\taccount_id\t\t\t= " . $db->qstr(0) . ", \n\t\t        \t\t\ttype\t\t\t\t= " . $db->qstr('void') . ", \n\t\t        \t\t\tmemo\t\t\t\t= " . $db->qstr("Voided due to postback: " . $arr['transaction_id']);
             $rsql = $db->Execute($q);
             if ($rsql === false) {
                 $C_debug->error('checkout.inc.php', 'postback', $q . " | " . @$db->ErrorMsg());
             }
         } else {
             # approve
             $inv->autoApproveInvoice($invoice_id);
             # User invoice payment confirmation
             include_once PATH_MODULES . 'email_template/email_template.inc.php';
             $email = new email_template();
             $email->send('invoice_paid_user', $invoice->fields['account_id'], $invoice_id, DEFAULT_CURRENCY, '');
             # Admin alert of payment processed
             $email = new email_template();
             $email->send('admin->invoice_paid_admin', $invoice->fields['account_id'], $invoice_id, DEFAULT_CURRENCY, '');
         }
     }
     return true;
 }
开发者ID:hbustun,项目名称:agilebill,代码行数:101,代码来源:checkout.inc.php


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