function getUserDetails($userID) { $user = new User(); $user->selectRecord($userID); if (!($domDoc = $user->getDomDocument())) { return false; } else { $xmlStr = $domDoc->dump_mem(true); return $xmlStr; } }
function Main() { switch ($this->formArray["formAction"]) { case "edit": $UserDetails = new SoapObject(NCCBIZ . "UserDetails.php", "urn:Object"); if (!($xmlStr = $UserDetails->getUserDetails($this->formArray["userID"]))) { $this->tpl->set_block("rptsTemplate", "Table", "TableBlock"); $this->tpl->set_var("TableBlock", "User record not found"); } else { if (!($domDoc = domxml_open_mem($xmlStr))) { $this->tpl->set_block("rptsTemplate", "Table", "TableBlock"); $this->tpl->set_var("TableBlock", "error xmlDoc"); } else { $user = new User(); $user->parseDomDocument($domDoc); $this->formArray["userID"] = $user->getUserID(); $this->formArray["userType"] = $user->getUserType(); $this->formArray["username"] = $user->getUsername(); $this->formArray["password"] = $user->getPassword(); $this->formArray["personID"] = $user->getPersonID(); $this->formArray["status"] = $user->getStatus(); } } $PersonDetails = new SoapObject(NCCBIZ . "PersonDetails.php", "urn:Object"); if (!($xmlStr = $PersonDetails->getPersonDetails($this->formArray["personID"]))) { $this->tpl->set_block("rptsTemplate", "Table", "TableBlock"); $this->tpl->set_var("TableBlock", "Person record not found"); } else { if (!($domDoc = domxml_open_mem($xmlStr))) { $this->tpl->set_block("rptsTemplate", "Table", "TableBlock"); $this->tpl->set_var("TableBlock", "error xmlDoc"); } else { $person = new Person(); $person->parseDomDocument($domDoc); list($dateArr["year"], $dateArr["month"], $dateArr["day"]) = explode("-", $person->getBirthday()); $this->formArray["personID"] = $person->getPersonID(); $this->formArray["lastName"] = $person->getLastName(); $this->formArray["firstName"] = $person->getFirstName(); $this->formArray["middleName"] = $person->getMiddleName(); $this->formArray["gender"] = $person->getGender(); $this->formArray["birth_year"] = removePreZero($dateArr["year"]); $this->formArray["birth_month"] = removePreZero($dateArr["month"]); $this->formArray["birth_day"] = removePreZero($dateArr["day"]); $this->formArray["maritalStatus"] = $person->getMaritalStatus(); $this->formArray["tin"] = $person->getTin(); $address = $person->addressArray[0]; if (is_a($address, Address)) { $this->formArray["addressID"] = $address->getAddressID(); $this->formArray["number"] = $address->getNumber(); $this->formArray["street"] = $address->getStreet(); $this->formArray["barangay"] = $address->getBarangay(); $this->formArray["district"] = $address->getDistrict(); $this->formArray["municipalityCity"] = $address->getMunicipalitycity(); $this->formArray["province"] = $address->getProvince(); } $this->formArray["telephone"] = $person->getTelephone(); $this->formArray["mobileNumber"] = $person->getMobileNumber(); $this->formArray["email"] = $person->getEmail(); } } $this->tpl->set_block("rptsTemplate", "NewUserPassword", "NewUserPasswordBlock"); $this->tpl->set_var("NewUserPasswordBlock", ""); $this->tpl->set_block("rptsTemplate", "OldUserPassword", "OldUserPasswordBlock"); $this->tpl->set_var("oldNewUserRowspan", 5); //$this->tpl->set_var("oldNewUserRowspan", 3); $this->tpl->parse("OldUserPasswordBlock", "OldUserPassword", true); break; case "save": /* if($this->isOldPasswordCorrect()==false){ $this->message = "Error. Cannot Save. Old password incorrect to create new password."; $this->tpl->set_var("message", $this->message); $this->tpl->parse("MessageBlock", "Message", true); $this->tpl->set_block("rptsTemplate", "NewUserPassword", "NewUserPasswordBlock"); $this->tpl->set_var("NewUserPasswordBlock", ""); $this->tpl->set_block("rptsTemplate", "OldUserPassword", "OldUserPasswordBlock"); $this->tpl->set_var("oldNewUserRowspan", 3); $this->tpl->parse("OldUserPasswordBlock", "OldUserPassword", true); break; } */ if ($this->formArray["newPassword"] != "" && $this->formArray["newPassword"] != "null") { $this->formArray["password"] = md5($this->formArray["newPassword"]); } if ($this->usernameAlreadyExists() == true) { $this->message = "Error. Cannot Save. Username already exists."; $this->tpl->set_var("message", $this->message); $this->tpl->parse("MessageBlock", "Message", true); $this->tpl->set_block("rptsTemplate", "NewUserPassword", "NewUserPasswordBlock"); $this->tpl->set_block("rptsTemplate", "OldUserPassword", "OldUserPasswordBlock"); if ($this->formArray["personID"] != "") { $this->tpl->set_var("NewUserPasswordBlock", ""); $this->tpl->set_var("oldNewUserRowspan", 3); $this->tpl->parse("OldUserPasswordBlock", "OldUserPassword", true); } else { $this->tpl->set_var("oldNewUserRowspan", 2); $this->tpl->parse("NewUserPasswordBlock", "NewUserPassword", true); $this->tpl->set_var("OldUserPasswordBlock", ""); } break; } $PersonEncode = new SoapObject(NCCBIZ . "PersonEncode.php", "urn:Object"); if ($this->formArray["personID"] != "") { $PersonDetails = new SoapObject(NCCBIZ . "PersonDetails.php", "urn:Object"); if (!($xmlStr = $PersonDetails->getPersonDetails($this->formArray["personID"]))) { $this->tpl->set_block("rptsTemplate", "Table", "TableBlock"); $this->tpl->set_var("TableBlock", "Person record not found"); } else { if (!($domDoc = domxml_open_mem($xmlStr))) { $this->tpl->set_block("rptsTemplate", "Table", "TableBlock"); $this->tpl->set_var("TableBlock", "error xmlDoc"); } else { $person = new Person(); $person->parseDomDocument($domDoc); $address = $person->addressArray[0]; if (is_a($address, Address)) { $address->setAddressID($this->formArray["addressID"]); $address->setNumber($this->formArray["number"]); $address->setStreet($this->formArray["street"]); $address->setBarangay($this->formArray["barangay"]); $address->setDistrict($this->formArray["district"]); $address->setMunicipalityCity($this->formArray["municipalityCity"]); $address->setProvince($this->formArray["province"]); $address->setDomDocument(); } $person->setPersonID($this->formArray["personID"]); $person->setPersonType("adminUser"); $person->setLastName($this->formArray["lastName"]); $person->setFirstName($this->formArray["firstName"]); $person->setMiddleName($this->formArray["middleName"]); $person->setGender($this->formArray["gender"]); $person->setBirthday($this->birthdate); $person->setMaritalStatus($this->formArray["maritalStatus"]); $person->setTin($this->formArray["tin"]); $person->setAddressArray($address); $person->setTelephone($this->formArray["telephone"]); $person->setMobileNumber($this->formArray["mobileNumber"]); $person->setEmail($this->formArray["email"]); $person->setDomDocument(); $doc = $person->getDomDocument(); //echo $doc->html_dump_mem(); $xmlStr = $doc->dump_mem(true); if (!($ret = $PersonEncode->updatePerson($xmlStr))) { exit("error update"); } } } } else { $address = new Address(); $address->setNumber($this->formArray["number"]); $address->setStreet($this->formArray["street"]); $address->setBarangay($this->formArray["barangay"]); $address->setDistrict($this->formArray["district"]); $address->setMunicipalityCity($this->formArray["municipalityCity"]); $address->setProvince($this->formArray["province"]); $address->setDomDocument(); $person = new Person(); $person->setPersonID($this->formArray["personID"]); $person->setPersonType("adminUser"); $person->setLastName($this->formArray["lastName"]); $person->setFirstName($this->formArray["firstName"]); $person->setMiddleName($this->formArray["middleName"]); $person->setGender($this->formArray["gender"]); $person->setBirthday($this->birthdate); $person->setMaritalStatus($this->formArray["maritalStatus"]); $person->setTin($this->formArray["tin"]); $person->setAddressArray($address); $person->setTelephone($this->formArray["telephone"]); $person->setMobileNumber($this->formArray["mobileNumber"]); $person->setEmail($this->formArray["email"]); $person->setDomDocument(); $doc = $person->getDomDocument(); $xmlStr = $doc->dump_mem(true); //echo $this->formArray["ownerID"].$xmlStr; if (!($ret = $PersonEncode->savePerson($xmlStr, $this->formArray["ownerID"]))) { exit("error save"); } } $this->formArray["personID"] = $ret; $UserEncode = new SoapObject(NCCBIZ . "UserEncode.php", "urn:Object"); if ($this->formArray["userID"] != "") { $UserDetails = new SoapObject(NCCBIZ . "UserDetails.php", "urn:Object"); if (!($xmlStr = $UserDetails->getUserDetails($this->formArray["userID"]))) { exit("User record not found"); } else { if (!($domDoc = domxml_open_mem($xmlStr))) { $this->tpl->set_block("rptsTemplate", "Table", "TableBlock"); $this->tpl->set_var("TableBlock", "error xmlDoc"); } else { $user = new User(); $user->parseDomDocument($domDoc); $user->setUserID($this->formArray["userID"]); $user->setUserType($this->formArray["userType"]); $user->setUsername($this->formArray["username"]); $user->setPassword($this->formArray["password"]); $user->setPersonID($this->formArray["personID"]); $user->setStatus($this->formArray["status"]); $user->setDomDocument(); $doc = $user->getDomDocument(); $xmlStr = $doc->dump_mem(true); if (!($ret = $UserEncode->updateUser($xmlStr))) { exit("error update"); } } } } else { $user = new User(); //$user->setUserID($this->formArray["userID"]); $user->setUserType($this->formArray["userType"]); $user->setUsername($this->formArray["username"]); $user->setPassword(md5($this->formArray["password"])); $user->setPersonID($this->formArray["personID"]); $user->setStatus($this->formArray["status"]); $user->setDomDocument(); $doc = $user->getDomDocument(); $xmlStr = $doc->dump_mem(true); if (!($ret = $UserEncode->saveUser($xmlStr))) { exit("error save"); } } header("location: UserClose.php" . $this->sess->url("")); exit; break; case "cancel": header("location: UserClose.php" . $this->sess->url("")); exit; break; default: $this->tpl->set_block("rptsTemplate", "UserID", "UserIDBlock"); $this->tpl->set_var("UserIDBlock", ""); $this->tpl->set_block("rptsTemplate", "ACK", "ACKBlock"); $this->tpl->set_var("ACKBlock", ""); $this->tpl->set_block("rptsTemplate", "NewUserPassword", "NewUserPasswordBlock"); $this->tpl->set_var("oldNewUserRowspan", 2); $this->tpl->parse("NewUserPasswordBlock", "NewUserPassword", true); $this->tpl->set_block("rptsTemplate", "OldUserPassword", "OldUserPasswordBlock"); $this->tpl->set_var("OldUserPasswordBlock", ""); } $this->setForm(); if ($this->message == "") { $this->tpl->set_var("MessageBlock", ""); } $this->tpl->parse("templatePage", "rptsTemplate"); $this->tpl->finish("templatePage"); $this->tpl->p("templatePage"); }
function Main() { switch ($this->formArray["formAction"]) { case "edit": $UserDetails = new SoapObject(NCCBIZ . "UserDetails.php", "urn:Object"); if (!($xmlStr = $UserDetails->getUserDetails($this->formArray["userID"]))) { $this->tpl->set_block("rptsTemplate", "Table", "TableBlock"); $this->tpl->set_var("TableBlock", "record not found"); } else { if (!($domDoc = domxml_open_mem($xmlStr))) { $this->tpl->set_block("rptsTemplate", "Table", "TableBlock"); $this->tpl->set_var("TableBlock", "error xmlDoc"); } else { $user = new User(); $user->parseDomDocument($domDoc); $this->formArray["userID"] = $user->getUserID(); $this->formArray["userType"] = $user->getUserType(); $this->formArray["username"] = $user->getUsername(); $this->formArray["password"] = $user->getPassword(); $this->formArray["personID"] = $user->getPersonID(); } } break; case "save": $UserEncode = new SoapObject(NCCBIZ . "UserEncode.php", "urn:Object"); if ($this->formArray["userID"] != "") { $UserDetails = new SoapObject(NCCBIZ . "UserDetails.php", "urn:Object"); if (!($xmlStr = $UserDetails->getUserDetails($this->formArray["userID"]))) { exit("record not found"); } else { if (!($domDoc = domxml_open_mem($xmlStr))) { $this->tpl->set_block("rptsTemplate", "Table", "TableBlock"); $this->tpl->set_var("TableBlock", "error xmlDoc"); } else { $user = new User(); $user->parseDomDocument($domDoc); $user->setUserID($this->formArray["userID"]); $user->setUserType($this->formArray["userType"]); $user->setUsername($this->formArray["username"]); $user->setPassword($this->formArray["password"]); $user->setPersonID($this->formArray["personID"]); $user->setDomDocument(); $doc = $user->getDomDocument(); $xmlStr = $doc->dump_mem(true); if (!($ret = $UserEncode->updateUser($xmlStr))) { exit("error update"); } } } } else { $user = new User(); //$user->setUserID($this->formArray["userID"]); $user->setUserType($this->formArray["userType"]); $user->setUsername($this->formArray["username"]); $user->setPassword($this->formArray["password"]); $user->setPersonID($this->formArray["personID"]); $user->setDomDocument(); $doc = $user->getDomDocument(); $xmlStr = $doc->dump_mem(true); if (!($ret = $UserEncode->saveUser($xmlStr))) { exit("error save"); } } $this->formArray["userID"] = $ret; header("location: UserEncode.php"); exit; break; case "cancel": header("location: UserList.php"); exit; break; default: $this->tpl->set_block("rptsTemplate", "UserID", "UserIDBlock"); $this->tpl->set_var("UserIDBlock", ""); $this->tpl->set_block("rptsTemplate", "ACK", "ACKBlock"); $this->tpl->set_var("ACKBlock", ""); } $this->setForm(); $this->tpl->parse("templatePage", "rptsTemplate"); $this->tpl->finish("templatePage"); $this->tpl->p("templatePage"); }