Пример #1
0
 function Main()
 {
     switch ($this->formArray["formAction"]) {
         case "search":
             $this->tpl->set_var("msg", "");
             $receiptRecords = new ReceiptRecords();
             $this->tpl->set_block("rptsTemplate", "Pages", "PagesBlock");
             $this->tpl->set_block("rptsTemplate", "PagesList", "PagesListBlock");
             $condition = $this->filterCancelled();
             $fields = array("receiptNumber", "checkNumber", "draweeBank");
             $count = $receiptRecords->countSearchRecords($this->formArray["searchKey"], $fields);
             if ($count == 0 || $count == false) {
                 $this->tpl->set_var("PagesBlock", "");
                 $this->tpl->set_var("PagesListBlock", "");
                 $numOfPages = 1;
                 $this->tpl->set_block("rptsTemplate", "PageNavigator", "PagesBlock");
                 $this->tpl->set_var("PageNavigatorBlock", "");
             } else {
                 $numOfPages = ceil($count / PAGE_BY);
                 // page list nav
                 $this->formArray["pageLinksInLine"] = 7;
                 if ($this->formArray["page"] < round($this->formArray["pageLinksInLine"] / 2)) {
                     $startPageLinks = 1;
                 } else {
                     $startPageLinks = $this->formArray["page"] - round($this->formArray["pageLinksInLine"] / 2);
                     if ($startPageLinks < 1) {
                         $startPageLinks = 1;
                     }
                 }
                 $endPageLinks = $startPageLinks + ($this->formArray["pageLinksInLine"] - 1);
                 if ($endPageLinks > $numOfPages) {
                     $endPageLinks = $numOfPages;
                 }
                 for ($i = $startPageLinks; $i <= $endPageLinks; $i++) {
                     if ($i == $this->formArray["page"]) {
                         $this->tpl->set_var("pageListPages", "");
                         $this->tpl->set_var("pageListPagesUrl", "");
                         $this->tpl->set_var("pageListPaged", $i);
                     } else {
                         $this->tpl->set_var("pageListPages", $i);
                         $this->tpl->set_var("pageListPagesUrl", $i . "&formAction=search&searchKey=" . urlencode($this->formArray["searchKey"]));
                         $this->tpl->set_var("pageListPaged", "");
                     }
                     $this->tpl->parse("PagesListBlock", "PagesList", true);
                 }
                 // drop down nav
                 for ($i = 1; $i <= $numOfPages; $i++) {
                     if ($i == $this->formArray["page"]) {
                         $this->tpl->set_var("pages", $i);
                         $this->tpl->set_var("pagesUrl", $i . "&formAction=search&searchKey=" . urlencode($this->formArray["searchKey"]));
                         $this->tpl->set_var("paged", "selected");
                     } else {
                         $this->tpl->set_var("pages", $i);
                         $this->tpl->set_var("pagesUrl", $i . "&formAction=search&searchKey=" . urlencode($this->formArray["searchKey"]));
                         $this->tpl->set_var("paged", "");
                     }
                     $this->tpl->parse("PagesBlock", "Pages", true);
                 }
             }
             if ($numOfPages == $this->formArray["page"]) {
                 $this->tpl->set_var("nextTxt", "");
             } else {
                 $this->tpl->set_var("next", $this->formArray["page"] + 1 . "&formAction=search&searchKey=" . urlencode($this->formArray["searchKey"]));
                 $this->tpl->set_var("nextTxt", "next");
             }
             if ($this->formArray["page"] == 1) {
                 $this->tpl->set_var("previousTxt", "");
             } else {
                 $this->tpl->set_var("previous", $this->formArray["page"] - 1 . "&formAction=search&searchKey=" . urlencode($this->formArray["searchKey"]));
                 $this->tpl->set_var("previousTxt", "previous");
             }
             $this->tpl->set_var("pageOf", $this->formArray["page"] . " of " . $numOfPages);
             $condition = $this->filterCancelled();
             $condition .= $this->sortBlocks();
             $condition .= " LIMIT " . ($this->formArray["page"] - 1) * PAGE_BY . "," . PAGE_BY;
             if (!$receiptRecords->searchRecords($this->formArray["searchKey"], $fields, $condition)) {
                 $this->tpl->set_var("pageOf", "");
                 $this->tpl->set_block("rptsTemplate", "ReceiptTable", "ReceiptTableBlock");
                 $this->tpl->set_var("ReceiptTableBlock", "");
                 $this->tpl->set_block("rptsTemplate", "ReceiptDBEmpty", "ReceiptDBEmptyBlock");
                 $this->tpl->set_var("ReceiptDBEmptyBlock", "");
                 $this->tpl->set_block("rptsTemplate", "Pages", "PagesBlock");
                 $this->tpl->set_var("PagesBlock", "");
                 $this->tpl->set_var("PagesListBlock", "");
                 $this->tpl->set_var("previousTxt", "");
                 $this->tpl->set_var("nextTxt", "");
             } else {
                 $this->tpl->set_block("rptsTemplate", "NotFound", "NotFoundBlock");
                 $this->tpl->set_var("NotFoundBlock", "");
                 $list = $receiptRecords->getArrayList();
                 if (count($list)) {
                     $this->tpl->set_block("rptsTemplate", "ReceiptDBEmpty", "ReceiptDBEmptyBlock");
                     $this->tpl->set_var("ReceiptDBEmptyBlock", "");
                     $this->tpl->set_block("rptsTemplate", "ReceiptList", "ReceiptListBlock");
                     foreach ($list as $key => $value) {
                         $this->tpl->set_var("receiptID", $value->getReceiptID());
                         $this->tpl->set_var("receiptNumber", $value->getReceiptNumber());
                         $this->tpl->set_var("receiptDate", date("m/d/Y", strtotime($value->getReceiptDate())));
                         $this->tpl->set_var("taxType", $this->getTaxType($value->getReceiptID()));
                         $receivedFromName = $this->getOwnerNames($value->getReceivedFrom());
                         $this->tpl->set_var("receivedFromName", $receivedFromName);
                         $this->tpl->parse("ReceiptListBlock", "ReceiptList", true);
                     }
                 }
             }
             break;
         default:
             $this->tpl->set_var("msg", "");
             $ReceiptList = new SoapObject(NCCBIZ . "ReceiptList.php", "urn:Object");
             $this->tpl->set_block("rptsTemplate", "Pages", "PagesBlock");
             $this->tpl->set_block("rptsTemplate", "PagesList", "PagesListBlock");
             $this->tpl->set_block("rptsTemplate", "NotFound", "NotFoundBlock");
             $this->tpl->set_var("NotFoundBlock", "");
             $condition = $this->filterCancelled();
             $receiptRecords = new ReceiptRecords();
             $count = $receiptRecords->countRecords($condition);
             if ($count == 0 || $count == false) {
                 $this->tpl->set_var("PagesBlock", "");
                 $this->tpl->set_var("PagesListBlock", "");
                 $this->tpl->set_block("rptsTemplate", "PageNavigator", "PagesBlock");
                 $this->tpl->set_var("PageNavigatorBlock", "");
             } else {
                 $numOfPages = ceil($count / PAGE_BY);
                 // page list nav
                 $this->formArray["pageLinksInLine"] = 7;
                 if ($this->formArray["page"] < round($this->formArray["pageLinksInLine"] / 2)) {
                     $startPageLinks = 1;
                 } else {
                     $startPageLinks = $this->formArray["page"] - round($this->formArray["pageLinksInLine"] / 2);
                     if ($startPageLinks < 1) {
                         $startPageLinks = 1;
                     }
                 }
                 $endPageLinks = $startPageLinks + ($this->formArray["pageLinksInLine"] - 1);
                 if ($endPageLinks > $numOfPages) {
                     $endPageLinks = $numOfPages;
                 }
                 for ($i = $startPageLinks; $i <= $endPageLinks; $i++) {
                     if ($i == $this->formArray["page"]) {
                         $this->tpl->set_var("pageListPages", "");
                         $this->tpl->set_var("pageListPagesUrl", "");
                         $this->tpl->set_var("pageListPaged", $i);
                     } else {
                         $this->tpl->set_var("pageListPages", $i);
                         $this->tpl->set_var("pageListPagesUrl", $i);
                         $this->tpl->set_var("pageListPaged", "");
                     }
                     $this->tpl->parse("PagesListBlock", "PagesList", true);
                 }
                 // drop down nav
                 for ($i = 1; $i <= $numOfPages; $i++) {
                     if ($i == $this->formArray["page"]) {
                         $this->tpl->set_var("pages", $i);
                         $this->tpl->set_var("pagesUrl", $i);
                         $this->tpl->set_var("paged", "selected");
                     } else {
                         $this->tpl->set_var("pages", $i);
                         $this->tpl->set_var("pagesUrl", $i);
                         $this->tpl->set_var("paged", "");
                     }
                     $this->tpl->parse("PagesBlock", "Pages", true);
                 }
             }
             if ($numOfPages == $this->formArray["page"]) {
                 $this->tpl->set_var("nextTxt", "");
             } else {
                 $this->tpl->set_var("next", $this->formArray["page"] + 1);
                 $this->tpl->set_var("nextTxt", "next");
             }
             if ($this->formArray["page"] == 1) {
                 $this->tpl->set_var("previousTxt", "");
             } else {
                 $this->tpl->set_var("previous", $this->formArray["page"] - 1);
                 $this->tpl->set_var("previousTxt", "previous");
             }
             if ($numOfPages == "") {
                 $this->tpl->set_var("pageOf", "");
             } else {
                 $this->tpl->set_var("pageOf", $this->formArray["page"] . " of " . $numOfPages);
             }
             $condition = $this->filterCancelled();
             $condition .= $this->sortBlocks();
             $condition .= " LIMIT " . ($this->formArray["page"] - 1) * PAGE_BY . "," . PAGE_BY;
             if (!$receiptRecords->selectRecords($condition)) {
                 $this->tpl->set_block("rptsTemplate", "ReceiptTable", "ReceiptTableBlock");
                 $this->tpl->set_var("ReceiptTableBlock", "");
             } else {
                 $list = $receiptRecords->getArrayList();
                 if (count($list)) {
                     $this->tpl->set_block("rptsTemplate", "ReceiptDBEmpty", "ReceiptDBEmptyBlock");
                     $this->tpl->set_var("ReceiptDBEmptyBlock", "");
                     $this->tpl->set_block("rptsTemplate", "ReceiptList", "ReceiptListBlock");
                     foreach ($list as $key => $value) {
                         $this->tpl->set_var("receiptID", $value->getReceiptID());
                         $this->tpl->set_var("receiptNumber", $value->getReceiptNumber());
                         $this->tpl->set_var("receiptDate", date("m/d/Y", strtotime($value->getReceiptDate())));
                         $this->tpl->set_var("taxType", $this->getTaxType($value->getReceiptID()));
                         $receivedFromName = $this->getOwnerNames($value->getReceivedFrom());
                         $this->tpl->set_var("receivedFromName", $receivedFromName);
                         $this->tpl->parse("ReceiptListBlock", "ReceiptList", true);
                     }
                 }
             }
             break;
     }
     $this->setForm();
     $this->setPageDetailPerms();
     $this->tpl->set_var("uname", $this->user["uname"]);
     $this->tpl->set_var("today", date("F j, Y"));
     $this->tpl->set_var("Session", $this->sess->url(""));
     $this->tpl->parse("templatePage", "rptsTemplate");
     $this->tpl->finish("templatePage");
     $this->tpl->p("templatePage");
 }
Пример #2
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;
     }
 }