Example #1
0
 /**
  * Manage postback for multiple invoices 
  */
 function postback_multiple($arr)
 {
     $db =& DB();
     include_once PATH_MODULES . 'invoice/invoice.inc.php';
     $invoice = new invoice();
     // get multi-invoice details
     $total = $invoice->multiple_invoice_total($arr['invoice_id']);
     if (!$total) {
         return false;
     }
     $amt = $arr['amount'];
     foreach ($invoice->invoice_id as $id) {
         if ($amt > 0) {
             // get total due for this invoice:
             $rs = sqlSelect($db, "invoice", "SUM(total_amt-billed_amt) as total", "id={$id}");
             if ($rs && $rs->RecordCount()) {
                 $thisamt = $rs->fields["total"];
                 if ($thisamt > $amt) {
                     $arr['amount'] = $amt;
                 } else {
                     $arr['amount'] = $thisamt;
                 }
                 $arr["invoice_id"] = $id;
                 $this->postback($arr);
                 $amt -= $thisamt;
             }
         }
     }
 }