function Main() { switch ($this->formArray["formAction"]) { case "delete": if (count($this->formArray["personID"]) > 0) { $PersonList = new SoapObject(NCCBIZ . "PersonList.php", "urn:Object"); if (!($deletedRows = $PersonList->deletePerson($this->formArray["personID"]))) { $this->tpl->set_var("msg", "SOAP failed"); } else { $this->tpl->set_var("msg", $deletedRows . " records deleted"); } } else { $this->tpl->set_var("msg", "0 records deleted"); } break; case "cancel": header("location: PersonList.php"); exit; break; default: $this->tpl->set_var("msg", ""); } $PersonList = new SoapObject(NCCBIZ . "PersonList.php", "urn:Object"); if (!($xmlStr = $PersonList->getPersonList())) { $this->tpl->set_block("rptsTemplate", "Table", "TableBlock"); $this->tpl->set_var("TableBlock", "database empty"); } else { if (!($domDoc = domxml_open_mem($xmlStr))) { $this->tpl->set_block("rptsTemplate", "Table", "TableBlock"); $this->tpl->set_var("TableBlock", "error xmlDoc"); } else { $personRecords = new PersonRecords(); $personRecords->parseDomDocument($domDoc); $list = $personRecords->getArrayList(); $this->tpl->set_block("rptsTemplate", "PersonList", "PersonListBlock"); foreach ($list as $key => $value) { $this->tpl->set_var("personID", $value->getPersonID()); if (!($pname = $value->getFullName())) { $pname = "none"; } $this->tpl->set_var("fullName", $pname); $this->tpl->set_var("tin", $value->getTin()); $this->tpl->set_var("telephone", $value->getTelephone()); $this->tpl->set_var("mobileNumber", $value->getMobileNumber()); $this->tpl->parse("PersonListBlock", "PersonList", true); } } } $this->tpl->parse("templatePage", "rptsTemplate"); $this->tpl->finish("templatePage"); $this->tpl->p("templatePage"); }
function Main() { switch ($this->formArray["formAction"]) { case "search": $PersonList = new SoapObject(NCCBIZ . "PersonList.php", "urn:Object"); $this->tpl->set_block("rptsTemplate", "Pages", "PagesBlock"); $this->tpl->set_block("rptsTemplate", "PagesList", "PagesListBlock"); if (!($count = $PersonList->getSearchCount($this->formArray["searchKey"]))) { $this->tpl->set_var("PagesBlock", ""); $this->tpl->set_var("PagesListBlock", ""); } 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("pageListPaged", $i); } else { $this->tpl->set_var("pageListPages", $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("paged", "selected"); } else { $this->tpl->set_var("pages", $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"); } $this->tpl->set_var("pageOf", $this->formArray["page"] . " of " . $numOfPages); if (!($xmlStr = $PersonList->searchPerson($this->formArray["searchKey"], $this->formArray["page"]))) { $this->tpl->set_block("rptsTemplate", "Found", "FoundBlock"); $this->tpl->set_var("FoundBlock", ""); } else { if (!($domDoc = domxml_open_mem($xmlStr))) { $this->tpl->set_block("rptsTemplate", "Table", "TableBlock"); $this->tpl->set_var("TableBlock", "error xmlDoc"); } else { $personRecords = new PersonRecords(); $personRecords->parseDomDocument($domDoc); $list = $personRecords->getArrayList(); if (count($list)) { $this->tpl->set_block("rptsTemplate", "PersonList", "PersonListBlock"); foreach ($list as $key => $value) { $this->tpl->set_var("personID", $value->getPersonID()); if (!($pname = $value->getFullName())) { $pname = "none"; } $this->tpl->set_var("fullName", $pname); $this->tpl->set_var("tin", $value->getTin()); $this->tpl->set_var("telephone", $value->getTelephone()); $this->tpl->set_var("mobileNumber", $value->getMobileNumber()); $this->tpl->parse("PersonListBlock", "PersonList", true); } $this->tpl->set_block("rptsTemplate", "NotFound", "NotFoundBlock"); $this->tpl->set_var("NotFoundBlock", ""); } else { $this->tpl->set_block("rptsTemplate", "Found", "FoundBlock"); $this->tpl->set_var("FoundBlock", ""); } } } break; case "add": //$owner = new Owner; //foreach($this->formArray["personID"] as $key => $value){ // $owner->deleteOwnerPerson($value); // $owner->insertOwnerPerson($this->formArray["ownerID"],$value); //} //print_r($this->formArray["personID"]); $OwnerList = new SoapObject(NCCBIZ . "OwnerList.php", "urn:Object"); $OwnerList->addOwnerPerson($this->formArray["ownerID"], $this->formArray["personID"]); header("location: PersonSearchClose.php" . $this->sess->url("") . $this->sess->add_query(array("odID" => $this->formArray["odID"]))); break; default: $this->tpl->set_block("rptsTemplate", "Table", "TableBlock"); $this->tpl->set_var("TableBlock", ""); $this->tpl->set_block("rptsTemplate", "NotFound", "NotFoundBlock"); $this->tpl->set_var("NotFoundBlock", ""); } $this->setForm(); $this->tpl->set_var("Session", $this->sess->url("") . $this->sess->add_query(array("odID" => $this->formArray["odID"], "ownerID" => $this->formArray["ownerID"], "afsID" => $this->formArray["afsID"], "searchKey" => $this->formArray["searchKey"], "formAction" => "search"))); $this->tpl->parse("templatePage", "rptsTemplate"); $this->tpl->finish("templatePage"); $this->tpl->p("templatePage"); }