Exemple #1
0
 public function isValid($value, $context = null)
 {
     $value = intval($value);
     if ($value != 0) {
         $countryid = intval($context['country_id']);
         if ($countryid == 0) {
             $this->_error(self::COUNTRYIDEMPTY);
             return false;
         }
         $region_id = intval($context['region_id']);
         if ($countryid == 0) {
             $this->_error(self::REGIONIDEMPTY);
             return false;
         }
         $province = Provinces::find($value);
         if ($province->country_id != $countryid) {
             $this->_error(self::PROVINCEIDNOTVALID);
             return false;
         }
         if ($province->region_id != $region_id) {
             $this->_error(self::PROVINCEIDNOTVALID);
             return false;
         }
     }
     return true;
 }
 /**
  * Update the record previously selected
  */
 public function processAction()
 {
     $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $form = $this->getForm("/admin/domainsprofiles/process");
     $request = $this->getRequest();
     // Create the buttons in the edit form
     $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/domainsprofiles/list", "label" => $this->translator->translate('List'), "params" => array('css' => null)), array("url" => "/admin/domainsprofiles/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null)));
     try {
         // Check if we have a POST request
         if (!$request->isPost()) {
             return $this->_helper->redirector('list', 'domainsprofiles', 'admin');
         }
         if ($form->isValid($request->getPost())) {
             $params = $request->getPost();
             $area = intval($params['area']);
             if ($area != 0) {
                 $province = Provinces::find($area);
                 $area = $province->code;
                 $params['area'] = $area;
             }
             $id = DomainsProfiles::saveAll($params, $request->getParam('profile_id'));
             $this->_helper->redirector('edit', 'domainsprofiles', 'admin', array('id' => $id, 'mex' => $this->translator->translate('The task requested has been executed successfully.'), 'status' => 'success'));
         } else {
             $this->view->form = $form;
             $this->view->title = $this->translator->translate("Domain Profile details");
             $this->view->description = $this->translator->translate("Here you can edit the domains profile details.");
             return $this->render('applicantform');
         }
     } catch (Exception $e) {
         $this->_helper->redirector('edit', 'domainsprofiles', 'admin', array('id' => $id, 'mex' => $e->getMessage(), 'status' => 'danger'));
     }
 }
 public function showProvince($id_city)
 {
     $province = Cities::where('id', $id_city)->select('province_id')->first();
     $data = Provinces::find($province->province_id);
     return Response::json($data);
 }