Example #1
0
 function cancelReceiptList($receiptIDArray = "")
 {
     if (is_array($receiptIDArray)) {
         $collectionRecords = new CollectionRecords();
         $collection = new Collection();
         $receipt = new Receipt();
         $payment = new Payment();
         foreach ($receiptIDArray as $receiptID) {
             // find other receipts associated to payment
             $collectionRecords->selectRecords("WHERE receiptID='" . $receiptID . "'");
             $paymentID = $collectionRecords->arrayList[0]->getPaymentID();
             $collectionRecords->selectRecords("WHERE paymentID='" . $paymentID . "'");
             if (is_array($collectionRecords->getArrayList())) {
                 foreach ($collectionRecords->getArrayList() as $collection) {
                     $cancelReceiptIDArray[] = $collection->getReceiptID();
                     $cancelPaymentIDArray[] = $collection->getPaymentID();
                     $cancelCollectionIDArray[] = $collection->getCollectionID();
                 }
             }
         }
         $cancelCollectionIDArray = array_unique($cancelCollectionIDArray);
         $cancelReceiptIDArray = array_unique($cancelReceiptIDArray);
         $cancelPaymentIDArray = array_unique($cancelPaymentIDArray);
         foreach ($cancelCollectionIDArray as $collectionID) {
             $collection->selectRecord($collectionID);
             $collection->setStatus("cancelled");
             $collection->updateRecord();
         }
         $condition = " WHERE ";
         foreach ($cancelReceiptIDArray as $receiptID) {
             if ($condition != " WHERE ") {
                 $condition .= " OR ";
             }
             $condition .= " receiptID = '" . $receiptID . "' ";
             $receipt->selectRecord($receiptID);
             $receipt->setStatus("cancelled");
             $receipt->updateRecord();
         }
         foreach ($cancelPaymentIDArray as $paymentID) {
             $payment->selectRecord($paymentID);
             $payment->setStatus("cancelled");
             $payment->updateRecord();
         }
         // cancel associated mergedReceipts
         $receiptRecords = new ReceiptRecords();
         if ($receiptRecords->selectRecords($condition)) {
             if (!($domDoc = $receiptRecords->getDomDocument())) {
                 return false;
             } else {
                 $xmlStr = $domDoc->dump_mem(true);
                 return $xmlStr;
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }