function Main() { switch ($this->formArray["formAction"]) { case "delete": //print_r($this->formArray); if (count($this->formArray["companyID"]) > 0) { $CompanyList = new SoapObject(NCCBIZ . "CompanyList.php", "urn:Object"); if (!($deletedRows = $CompanyList->deleteCompany($this->formArray["companyID"]))) { $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: CompanyList.php"); exit; break; default: $this->tpl->set_var("msg", ""); } $CompanyList = new SoapObject(NCCBIZ . "CompanyList.php", "urn:Object"); if (!($xmlStr = $CompanyList->getCompanyList())) { $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 { $companyRecords = new CompanyRecords(); $companyRecords->parseDomCompanyRecords($domDoc); $list = $companyRecords->getCompanyList(); $this->tpl->set_block("rptsTemplate", "CompanyList", "CompanyListBlock"); foreach ($list as $key => $value) { $this->tpl->set_var("companyID", $value->getCompanyID()); if (!($cname = $value->getCompanyName())) { $cname = "none"; } $this->tpl->set_var("companyName", $cname); $this->tpl->set_var("tin", $value->getTin()); $this->tpl->set_var("telephone", $value->getTelephone()); $this->tpl->set_var("fax", $value->getFax()); $this->tpl->parse("CompanyListBlock", "CompanyList", true); } } } $this->tpl->parse("templatePage", "rptsTemplate"); $this->tpl->finish("templatePage"); $this->tpl->p("templatePage"); }
function searchCompany($searchKey, $page = 0) { if ($page > 0) { $page = ($page - 1) * PAGE_BY; $limit = "LIMIT {$page}," . PAGE_BY; } $fields = array("companyName"); $companyRecords = new CompanyRecords(); if ($companyRecords->searchRecords($searchKey, $fields, $limit)) { if (!($domDoc = $companyRecords->getDomDocument())) { return false; } else { $xmlStr = $domDoc->dump_mem(true); return $xmlStr; } } else { return false; } }
function Main() { switch ($this->formArray["formAction"]) { case "search": $CompanyList = new SoapObject(NCCBIZ . "CompanyList.php", "urn:Object"); $this->tpl->set_block("rptsTemplate", "Pages", "PagesBlock"); if (!($count = $CompanyList->getSearchCount($this->formArray["searchKey"]))) { $this->tpl->set_var("PagesBlock", ""); } else { $numOfPages = ceil($count / PAGE_BY); for ($i = 1; $i <= $numOfPages; $i++) { if ($i == $this->formArray["page"]) { $this->tpl->set_var("pages", ""); $this->tpl->set_var("paged", $i); } 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 = $CompanyList->searchCompany($this->formArray["searchKey"], $this->formArray["page"]))) { $this->tpl->set_block("rptsTemplate", "Found", "FoundBlock"); $this->tpl->set_var("FoundBlock", ""); } else { //echo $xmlStr; if (!($domDoc = domxml_open_mem($xmlStr))) { $this->tpl->set_block("rptsTemplate", "Table", "TableBlock"); $this->tpl->set_var("TableBlock", "error xmlDoc"); } else { $companyRecords = new CompanyRecords(); $companyRecords->parseDomDocument($domDoc); $list = $companyRecords->getArrayList(); if (count($list)) { $this->tpl->set_block("rptsTemplate", "CompanyList", "CompanyListBlock"); foreach ($list as $key => $value) { $this->tpl->set_var("companyID", $value->getCompanyID()); if (!($cname = $value->getCompanyName())) { $cname = "none"; } $this->tpl->set_var("companyName", $cname); $this->tpl->set_var("telephone", $value->getTelephone()); $this->tpl->parse("CompanyListBlock", "CompanyList", 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": $OwnerList = new SoapObject(NCCBIZ . "OwnerList.php", "urn:Object"); $OwnerList->addOwnerCompany($this->formArray["ownerID"], $this->formArray["companyID"]); header("location: ChangeOfOwnershipCompanySearchClose.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"], "searchKey" => $this->formArray["searchKey"], "formAction" => "search"))); $this->tpl->parse("templatePage", "rptsTemplate"); $this->tpl->finish("templatePage"); $this->tpl->p("templatePage"); }