示例#1
0
 function Main()
 {
     switch ($this->formArray["formAction"]) {
         case "search":
             $this->tpl->set_var("msg", "");
             $mergedReceiptRecords = new MergedReceiptRecords();
             $this->tpl->set_block("rptsTemplate", "Pages", "PagesBlock");
             $this->tpl->set_block("rptsTemplate", "PagesList", "PagesListBlock");
             $condition = $this->filterCancelled();
             $fields = array("basicReceiptNumber", "sefReceiptNumber", "idleReceiptNumber", "receivedFromName", "checkNumber", "draweeBank");
             $count = $mergedReceiptRecords->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 (!$mergedReceiptRecords->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 = $mergedReceiptRecords->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("mergedReceiptID", $value->getMergedReceiptID());
                         $this->tpl->set_var("receivedFromName", $value->getReceivedFromName());
                         $this->tpl->set_var("basicReceiptNumber", $value->getBasicReceiptNumber());
                         $this->tpl->set_var("sefReceiptNumber", $value->getSefReceiptNumber());
                         $this->tpl->set_var("idleReceiptNumber", $value->getIdleReceiptNumber());
                         $this->tpl->set_var("receiptDate", date("m/d/Y", strtotime($value->getReceiptDate())));
                         $printURL = $this->getPrintURL($value);
                         $this->tpl->set_var("printURL", $printURL);
                         $this->tpl->parse("ReceiptListBlock", "ReceiptList", true);
                     }
                 }
             }
             break;
         default:
             $this->tpl->set_var("msg", "");
             $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();
             $mergedReceiptRecords = new MergedReceiptRecords();
             $count = $mergedReceiptRecords->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 (!$mergedReceiptRecords->selectRecords($condition)) {
                 $this->tpl->set_block("rptsTemplate", "ReceiptTable", "ReceiptTableBlock");
                 $this->tpl->set_var("ReceiptTableBlock", "");
             } else {
                 $list = $mergedReceiptRecords->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("mergedReceiptID", $value->getMergedReceiptID());
                         $this->tpl->set_var("receivedFromName", $value->getReceivedFromName());
                         $this->tpl->set_var("basicReceiptNumber", $value->getBasicReceiptNumber());
                         $this->tpl->set_var("sefReceiptNumber", $value->getSefReceiptNumber());
                         $this->tpl->set_var("idleReceiptNumber", $value->getIdleReceiptNumber());
                         $this->tpl->set_var("receiptDate", date("m/d/Y", strtotime($value->getReceiptDate())));
                         $printURL = $this->getPrintURL($value);
                         $this->tpl->set_var("printURL", $printURL);
                         $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");
 }
 function insertRecord()
 {
     $mergedReceiptRecords = new MergedReceiptRecords();
     $condition = "WHERE ";
     // look for existing basicReceiptIDs
     $condition .= "(";
     $i = 0;
     foreach ($this->formArray["basicReceiptIDArray"] as $basicReceiptID) {
         if ($i > 0) {
             $condition .= " OR ";
         }
         $condition .= "basicReceiptIDCSV LIKE '" . $basicReceiptID . "'";
         $condition .= " OR basicReceiptIDCSV LIKE '" . $basicReceiptID . ",%'";
         $condition .= " OR basicReceiptIDCSV LIKE '%," . $basicReceiptID . ",%'";
         $condition .= " OR basicReceiptIDCSV LIKE '%," . $basicReceiptID . "'";
         $i++;
     }
     $condition .= ")";
     // look for existing sefReceiptIDs
     $condition .= " AND ";
     $condition .= "(";
     $i = 0;
     foreach ($this->formArray["sefReceiptIDArray"] as $sefReceiptID) {
         if ($i > 0) {
             $condition .= " OR ";
         }
         $condition .= "sefReceiptIDCSV LIKE '" . $sefReceiptID . "'";
         $condition .= " OR sefReceiptIDCSV LIKE '" . $sefReceiptID . ",%'";
         $condition .= " OR sefReceiptIDCSV LIKE '%," . $sefReceiptID . ",%'";
         $condition .= " OR sefReceiptIDCSV LIKE '%," . $sefReceiptID . "'";
         $i++;
     }
     $condition .= ")";
     // look for existing idleReceiptIDs
     $condition .= " AND ";
     $condition .= "(";
     $i = 0;
     foreach ($this->formArray["idleReceiptIDArray"] as $idleReceiptID) {
         if ($i > 0) {
             $condition .= " OR ";
         }
         $condition .= "idleReceiptIDCSV LIKE '" . $idleReceiptID . "'";
         $condition .= " OR idleReceiptIDCSV LIKE '" . $idleReceiptID . ",%'";
         $condition .= " OR idleReceiptIDCSV LIKE '%," . $idleReceiptID . ",%'";
         $condition .= " OR idleReceiptIDCSV LIKE '%," . $idleReceiptID . "'";
         $i++;
     }
     $condition .= ")";
     $condition .= " AND status!='cancelled'";
     if (!$mergedReceiptRecords->selectRecords($condition)) {
         $mergedReceipt = new MergedReceipt();
         $mergedReceipt->setBasicReceiptAmount($this->formArray["basicReceiptAmount"]);
         $mergedReceipt->setBasicReceiptNumber($this->formArray["basicReceiptNumber"]);
         $mergedReceipt->setBasicPreviousReceiptNumber($this->formArray["basicPreviousReceiptNumber"]);
         $mergedReceipt->setBasicPreviousReceiptDate($this->formArray["basicPreviousReceiptDate"]);
         $basicReceiptIDCSV = "";
         if (is_array($this->formArray["basicReceiptIDArray"])) {
             $basicReceiptIDCSV = implode(",", $this->formArray["basicReceiptIDArray"]);
         }
         $mergedReceipt->setBasicReceiptIDCSV($basicReceiptIDCSV);
         $mergedReceipt->setSefReceiptAmount($this->formArray["sefReceiptAmount"]);
         $mergedReceipt->setSefReceiptNumber($this->formArray["sefReceiptNumber"]);
         $mergedReceipt->setSefPreviousReceiptNumber($this->formArray["sefPreviousReceiptNumber"]);
         $mergedReceipt->setSefPreviousReceiptDate($this->formArray["sefPreviousReceiptDate"]);
         $sefReceiptIDCSV = "";
         if (is_array($this->formArray["sefReceiptIDArray"])) {
             $sefReceiptIDCSV = implode(",", $this->formArray["sefReceiptIDArray"]);
         }
         $mergedReceipt->setSefReceiptIDCSV($sefReceiptIDCSV);
         $mergedReceipt->setIdleReceiptAmount($this->formArray["idleReceiptAmount"]);
         $mergedReceipt->setIdleReceiptNumber($this->formArray["idleReceiptNumber"]);
         $mergedReceipt->setIdlePreviousReceiptNumber($this->formArray["idlePreviousReceiptNumber"]);
         $mergedReceipt->setIdlePreviousReceiptDate($this->formArray["idlePreviousReceiptDate"]);
         $idleReceiptIDCSV = "";
         if (is_array($this->formArray["idleReceiptIDArray"])) {
             $idleReceiptIDCSV = implode(",", $this->formArray["idleReceiptIDArray"]);
         }
         $mergedReceipt->setIdleReceiptIDCSV($idleReceiptIDCSV);
         $mergedReceipt->setPaymentMode($this->formArray["paymentMode"]);
         $mergedReceipt->setCheckNumber($this->formArray["checkNumber"]);
         $mergedReceipt->setDateOfCheck($this->formArray["dateOfCheck"]);
         $mergedReceipt->setDraweeBank($this->formArray["draweeBank"]);
         $mergedReceipt->setCityTreasurer($this->formArray["cityTreasurer"]);
         $mergedReceipt->setDeputyTreasurer($this->formArray["deputyTreasurer"]);
         $mergedReceipt->setReceiptDate($this->formArray["receiptDate"]);
         $mergedReceipt->setReceivedFrom($this->formArray["receivedFrom"]);
         $mergedReceipt->setReceivedFromName($this->getReceivedFromName($this->formArray["receivedFrom"]));
         $mergedReceipt->setStatus("");
         $mergedReceipt->setCreatedBy($this->userID);
         $mergedReceipt->setModifiedBy($this->userID);
         $mergedReceipt->insertRecord();
     } else {
         // update first record
         $mergedReceipt = $mergedReceiptRecords->arrayList[0];
         $mergedReceipt->setBasicReceiptAmount($this->formArray["basicReceiptAmount"]);
         $mergedReceipt->setBasicReceiptNumber($this->formArray["basicReceiptNumber"]);
         $mergedReceipt->setBasicPreviousReceiptNumber($this->formArray["basicPreviousReceiptNumber"]);
         $mergedReceipt->setBasicPreviousReceiptDate($this->formArray["basicPreviousReceiptDate"]);
         $basicReceiptIDCSV = "";
         if (is_array($this->formArray["basicReceiptIDArray"])) {
             $basicReceiptIDCSV = implode(",", $this->formArray["basicReceiptIDArray"]);
         }
         $mergedReceipt->setBasicReceiptIDCSV($basicReceiptIDCSV);
         $mergedReceipt->setSefReceiptAmount($this->formArray["sefReceiptAmount"]);
         $mergedReceipt->setSefReceiptNumber($this->formArray["sefReceiptNumber"]);
         $mergedReceipt->setSefPreviousReceiptNumber($this->formArray["sefPreviousReceiptNumber"]);
         $mergedReceipt->setSefPreviousReceiptDate($this->formArray["sefPreviousReceiptDate"]);
         $sefReceiptIDCSV = "";
         if (is_array($this->formArray["sefReceiptIDArray"])) {
             $sefReceiptIDCSV = implode(",", $this->formArray["sefReceiptIDArray"]);
         }
         $mergedReceipt->setSefReceiptIDCSV($sefReceiptIDCSV);
         $mergedReceipt->setIdleReceiptAmount($this->formArray["idleReceiptAmount"]);
         $mergedReceipt->setIdleReceiptNumber($this->formArray["idleReceiptNumber"]);
         $mergedReceipt->setIdlePreviousReceiptNumber($this->formArray["idlePreviousReceiptNumber"]);
         $mergedReceipt->setIdlePreviousReceiptDate($this->formArray["idlePreviousReceiptDate"]);
         $idleReceiptIDCSV = "";
         if (is_array($this->formArray["idleReceiptIDArray"])) {
             $idleReceiptIDCSV = implode(",", $this->formArray["idleReceiptIDArray"]);
         }
         $mergedReceipt->setIdleReceiptIDCSV($idleReceiptIDCSV);
         $mergedReceipt->setPaymentMode($this->formArray["paymentMode"]);
         $mergedReceipt->setCheckNumber($this->formArray["checkNumber"]);
         $mergedReceipt->setDateOfCheck($this->formArray["dateOfCheck"]);
         $mergedReceipt->setDraweeBank($this->formArray["draweeBank"]);
         $mergedReceipt->setCityTreasurer($this->formArray["cityTreasurer"]);
         $mergedReceipt->setDeputyTreasurer($this->formArray["deputyTreasurer"]);
         $mergedReceipt->setReceiptDate($this->formArray["receiptDate"]);
         $mergedReceipt->setReceivedFrom($this->formArray["receivedFrom"]);
         $mergedReceipt->setReceivedFromName($this->getReceivedFromName($this->formArray["receivedFrom"]));
         $mergedReceipt->setStatus("");
         $mergedReceipt->setCreatedBy($this->userID);
         $mergedReceipt->setModifiedBy($this->userID);
         $mergedReceipt->updateRecord();
     }
 }