Esempio n. 1
0
 public function AddContact($data)
 {
     try {
         $form = $this->getContactUsForm();
         $result = array();
         /*if($data['contactType'] == 'email'){
         			$form->emailAddress->setRequired(true);
         			$form->phone->setRequired(false);
         		}else if($data['contactType'] == 'phone'){
         			$form->phone->setRequired(true);
         			$form->contactType->setValue('phone');
         			$form->emailAddress->setRequired(false);
         		}*/
         if ($form->isValid($data)) {
             $formData = $form->getValues();
             $mapper = new Administrator_Model_ContactUsDataMapper();
             $contactObj = new Administrator_Model_ContactUs();
             $domain = $_SERVER["SERVER_NAME"];
             if ($domain == "www.dinedesk.com" || $domain == "dinedesk.com") {
                 $contactObj->setCompanyId(1);
             } else {
                 if ($domain == "www.dinedesk.co.za" || $domain == "dinedesk.co.za") {
                     $contactObj->setCompanyId(2);
                 } else {
                     $contactObj->setCompanyId(1);
                 }
             }
             $contactObj->setcontactname($formData['contactName']);
             $contactObj->setaddress($formData['address']);
             $contactObj->setcity($formData['city']);
             $contactObj->setstate($formData['state']);
             $contactObj->setcountry($formData['country']);
             $contactObj->setzip($formData['postalCode']);
             $contactObj->setphone($formData['phone']);
             $contactObj->setemail($formData['emailAddress']);
             $contactObj->setfax($formData['fax']);
             $contactObj->setwebsite($formData['website']);
             $contactObj->setmoreinformation($formData['moreinfo']);
             $contactObj->setcomments($formData['comments']);
             $contactObj->setpostedon(date('Y-m-d'));
             $contactObj->setcontacttype($formData['type']);
             $status = $mapper->CreateContact($contactObj);
             if ($status) {
                 $result['status'] = $status;
                 $result['form'] = $form;
             }
             //return $result;
             $mailmapper = new Application_Service_Administrator();
             //if($formData['notificationType'] == 'email'){
             if ($result['status']) {
                 /*$mailObj = new Communication_Model_Mail();
                 		$mailObj->setMsgCode('EnquiryNot');
                 			$name = $formData['contactName'];
                 			$data = array('Name' => $name,
                 			  'City'    => $formData['city'],
                 			  'State' => $formData['state'],
                 			  'Country'  => $formData['country'],
                 			  'Phone'     => $formData['phone'],
                 			  'Email'     => $formData['emailAddress'],
                 			  'Comments'     => $formData['comments']);
                 			  //'Status'	 => $formData['bookingStatus']);
                 			$mailObj->setData($data);
                 			$mailStatus = $mailmapper->SendMail($mailObj);*/
             }
             return $result;
         } else {
             $formData = $form->getValues();
             $form->populate($formData);
             $result['status'] = false;
             $result['form'] = $form;
             return $result;
         }
     } catch (Exception $ex) {
         Rdine_Logger_FileLogger::info($ex->getMessage());
         throw new Exception($ex->getMessage());
     }
 }