コード例 #1
0
 public function editAction()
 {
     $webformurlid = $this->request->getParam('id');
     $userid = $this->user->getId();
     $user = new Application_Model_User((int) $userid);
     if ($webformurlid) {
         $formObj = new Application_Model_Form();
         $webformadetails = $formObj->getWebformDeatils($webformurlid);
         if (count($webformadetails) == 0) {
             $this->_redirector->gotoUrl('/form/create/');
         }
         $attbArray = array();
         $userid = $webformadetails['0']['entityid'];
         foreach ($webformadetails as $key => $webArray) {
             $attbArray[$key] = $webArray['attribute'];
             $attbWeightage[$webArray['attribute']] = $webArray['weightage'];
             $attbtoArray[$key]['attbtype'] = $webArray['attbtype'];
             $attbtoArray[$key]['attboption'] = $webArray['attboption'];
         }
         $this->view->webformadetails = $webformadetails;
         $this->view->attbarray = $attbArray;
         $this->view->attbWeightage = $attbWeightage;
         $this->view->attbtoArray = $attbtoArray;
         $this->view->folders = $this->user->getFolders();
         $this->view->business = $user->businessname;
         if ($this->request->isPost()) {
             if ($this->request->getParam('formurl') == "") {
                 $message['type'] = "error";
                 $message['body'] = "Atleast Unique URL is required";
             } else {
                 $folderidArray = $this->request->getParam('folderid');
                 if (!empty($folderidArray)) {
                     $folderids = implode($folderidArray, ',');
                     $webformAttbArrayToinsert = array();
                     $webformUrlArray = array("entityid" => $userid, "urlname" => addslashes(trim($this->request->getParam('formurl'))), "thankumsg" => addslashes($this->request->getParam('thanku_message')), "descmsg" => addslashes($this->request->getParam('formdesc')), "folderid" => $folderids, "alertmessage" => addslashes(trim($this->request->getParam('alertmessage'))), "notifybysms" => $this->request->getParam('notifybysms'), "notifybyemail" => addslashes(trim($this->request->getParam('notifybyemail'))));
                     //                        echo "<pre>"; print_r($webformUrlArray); exit;
                     $webformAttbArray = $this->request->getParam('chkname');
                     //echo "<pre>"; print_r($webformAttbArray);
                     $webformAttbTypeArray = $this->request->getParam('chktype');
                     //echo "<pre>"; print_r($webformAttbTypeArray);
                     //$webformAttbOptionArray = $this->request->getParam('chkvalue');  //echo "<pre>"; print_r($webformAttbOptionArray);
                     $webformAttbWeightage = $this->request->getParam('weightage');
                     //echo "<pre>"; print_r($webformAttbTypeArray);
                     //echo "<pre>"; print_r($this->request->getParam('chk')); exit;
                     foreach ($this->request->getParam('chk') as $key => $checked) {
                         $webformAttbArrayToinsert[$key]['weightage'] = addslashes($webformAttbWeightage[$checked]);
                         $webformAttbArrayToinsert[$key]['attb'] = addslashes($webformAttbArray[$checked]);
                         $webformAttbArrayToinsert[$key]['attbtype'] = addslashes($webformAttbTypeArray[$checked]);
                         //$webformAttbArrayToinsert[$key]['attboption'] = addslashes($webformAttbOptionArray[$checked]);
                         $webformAttbOptionArray = $this->request->getParam('chkvalue' . $checked);
                         //echo "<pre>"; print_r($webformAttbOptionArray);
                         if (!empty($webformAttbOptionArray)) {
                             $webformAttbOptionString = implode(",", $webformAttbOptionArray);
                         } else {
                             $webformAttbOptionString = "";
                         }
                         $webformAttbArrayToinsert[$key]['attboption'] = addslashes($webformAttbOptionString);
                     }
                     //echo "<pre>"; print_r($webformAttbArrayToinsert); exit;
                     if (empty($webformAttbArrayToinsert)) {
                         $message['type'] = "error";
                         $message['body'] = "Please check atleast one information field";
                     } elseif (empty($folderidArray)) {
                         $message['type'] = "error";
                         $message['body'] = "Please choose atleast one folder";
                     } else {
                         $updateformURL = $formObj->updateFormURL($webformurlid, $webformUrlArray['thankumsg'], $webformUrlArray['descmsg'], $webformUrlArray['folderid'], $webformUrlArray['alertmessage'], $webformUrlArray['notifybysms'], $webformUrlArray['notifybyemail']);
                         $removeExistingAttb = $formObj->removeFormAttribute($webformurlid);
                         if ($removeExistingAttb) {
                             $addformURLAttribute = $formObj->addFormAttribute($webformurlid, $webformAttbArrayToinsert);
                         }
                         $this->_redirector->gotoUrl('/form/create/');
                     }
                 } else {
                     $message['type'] = "error";
                     $message['body'] = "Please select atleast one folder from dropdown.";
                 }
             }
         }
     } else {
         $this->_redirector->gotoUrl('/form/create/');
     }
 }