/**
  * @param int $id
  * @param string $name
  * @param string $contactname
  * @param string $email
  * @param string $phonenumber
  * @param string $region
  * @param string $website
  * @param int $status
  * @return Company
  */
 public static function createCompany($id, $name, $contactname, $email, $phonenumber, $region, $website, $status)
 {
     $newCompany = new Company();
     $newCompany->setId($id);
     $newCompany->setName($name);
     $newCompany->setContactName($contactname);
     $newCompany->setEmail($email);
     $newCompany->setPhoneNumber($phonenumber);
     $newCompany->setRegion($region);
     $newCompany->setWebsite($website);
     $newCompany->setStatus($status);
     return $newCompany;
 }
 public function mapDtoToCompany(CompanyDto $companyDto)
 {
     $company = new Company();
     $company->setId($companyDto->getId());
     $company->setName($companyDto->getName());
     $company->setContactName($companyDto->getContactName());
     $company->setEmail($companyDto->getEmail());
     $company->setPhoneNumber($companyDto->getPhoneNumber());
     $company->setRegion($companyDto->getRegion());
     $company->setWebsite($companyDto->getWebsite());
     $company->setStatus($companyDto->getStatus());
     return $company;
 }
Beispiel #3
0
 function Main()
 {
     switch ($this->formArray["formAction"]) {
         case "edit":
             $CompanyDetails = new SoapObject(NCCBIZ . "CompanyDetails.php", "urn:Object");
             if (!($xmlStr = $CompanyDetails->getCompanyDetails($this->formArray["companyID"]))) {
                 $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 {
                     $company = new Company();
                     $company->parseDomDocument($domDoc);
                     $this->formArray["companyID"] = $company->getCompanyID();
                     $this->formArray["companyName"] = $company->getCompanyName();
                     $this->formArray["tin"] = $company->getTin();
                     $this->formArray["telephone"] = $company->getTelephone();
                     $this->formArray["fax"] = $company->getFax();
                     $address = $company->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["email"] = $company->getEmail();
                     $this->formArray["website"] = $company->getWebsite();
                 }
             }
             break;
         case "save":
             $CompanyEncode = new SoapObject(NCCBIZ . "CompanyEncode.php", "urn:Object");
             if ($this->formArray["companyID"] != "") {
                 $CompanyDetails = new SoapObject(NCCBIZ . "CompanyDetails.php", "urn:Object");
                 if (!($xmlStr = $CompanyDetails->getCompanyDetails($this->formArray["companyID"]))) {
                     $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 {
                         $company = new Company();
                         $company->parseDomDocument($domDoc);
                         $address = $company->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();
                         }
                         //$company->selectRecord($this->formArray["companyID"]);
                         $company->setCompanyID($this->formArray["companyID"]);
                         $company->setCompanyName($this->formArray["companyName"]);
                         $company->setTin($this->formArray["tin"]);
                         $company->setTelephone($this->formArray["telephone"]);
                         $company->setFax($this->formArray["fax"]);
                         $company->setAddressArray($address);
                         $company->setEmail($this->formArray["email"]);
                         $company->setWebsite($this->formArray["website"]);
                         $company->setDomDocument();
                         $doc = $company->getDomDocument();
                         $xmlStr = $doc->dump_mem(true);
                         if (!($ret = $CompanyEncode->updateCompany($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();
                 $company = new Company();
                 $company->setCompanyID($this->formArray["companyID"]);
                 $company->setCompanyName($this->formArray["companyName"]);
                 $company->setTelephone($this->formArray["telephone"]);
                 $company->setFax($this->formArray["fax"]);
                 $company->setTin($this->formArray["tin"]);
                 $company->setAddressArray($address);
                 $company->setEmail($this->formArray["email"]);
                 $company->setWebsite($this->formArray["website"]);
                 $company->setDomDocument();
                 $doc = $company->getDomDocument();
                 $xmlStr = $doc->dump_mem(true);
                 if (!($ret = $CompanyEncode->saveCompany($xmlStr, $this->formArray["ownerID"]))) {
                     exit("error save");
                 }
             }
             $this->formArray["companyID"] = $ret;
             //echo $ret;
             //}
             header("location: CompanyClose.php?parentURL=" . urlencode($this->formArray["parentURL"]));
             exit;
             //*/
             //else echo "tumpak!";
             break;
         case "cancel":
             header("location: CompanyList.php");
             exit;
             break;
         default:
             if ($this->formArray["locID"]) {
                 $ODDetails = new SoapObject(NCCBIZ . "ODDetails.php", "urn:Object");
                 if (!($xmlStr = $ODDetails->getLocation($this->formArray["locID"]))) {
                     exit("xml failed");
                 } else {
                     if (!($domDoc = domxml_open_mem($xmlStr))) {
                     } else {
                         $loc = new LocationAddress();
                         $loc->parseDomDocument($domDoc);
                         foreach ($loc as $key => $value) {
                             $this->formArray[$key] = $value;
                         }
                     }
                 }
             }
             $this->tpl->set_block("rptsTemplate", "companyID", "companyIDBlock");
             $this->tpl->set_var("companyIDBlock", "");
             $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");
 }
 private function _createContactFromEmail($emails)
 {
     $c = array();
     if ($emails === null) {
         return $c;
     }
     foreach ($emails as $email) {
         $temp = new Company();
         $temp->setEmail($email);
         $c[] = $temp;
     }
     return $c;
 }