Example #1
0
 public function userformsteponeajaxAction()
 {
     try {
         $this->_helper->layout->disableLayout();
         $this->_helper->viewRenderer->setNoRender();
         $request = $this->getRequest();
         if ($this->getRequest()->isPost()) {
             $id = null;
             $mapper = new Gyuser_Model_UserDataMapper();
             $pdlObj = new Gyuser_Model_User();
             if ($request->id) {
                 $pdlObj->setId($request->id);
             }
             $CUIL = $request->CUIL;
             $CUIL = str_replace('-', '', $CUIL);
             $pdlObj->setClient_type($request->client_type);
             $pdlObj->setFirst_name($request->first_name);
             $pdlObj->setLast_name($request->last_name);
             $pdlObj->setDNI($request->DNI);
             $pdlObj->setCUIL($CUIL);
             $pdlObj->setTel_cell($request->tel_cell);
             $pdlObj->setTel_lab($request->tel_lab);
             $pdlObj->setTel_otro($request->tel_otro);
             $pdlObj->setTel_part($request->tel_part);
             //$pdlObj->setTel_cell_code($request->tel_cell_code);
             $pdlObj->setTel_lab_code($request->tel_lab_code);
             $pdlObj->setTel_otro_code($request->tel_otro_code);
             $pdlObj->setTel_part_code($request->tel_part_code);
             $pdlObj->setEmail($request->email);
             $pdlObj->setActivity($request->activity);
             $pdlObj->setBusiness($request->business);
             $pdlObj->setBusiness_CUIT($request->business_CUIT);
             $pdlObj->setMulti_address_json($request->multi_address_json);
             $pdlObj->setMulti_prior_json($request->multi_prior_json);
             list($Day, $Month, $Year) = explode('/', $request->date_added);
             $stampeddate = mktime(12, 0, 0, $Month, $Day, $Year);
             $realDate = date("Y-m-d", $stampeddate);
             $pdlObj->setDate_added($realDate);
             $pdlObj->setOperator($request->operator);
             $pdlObj->setContact_point($request->contact_point);
             $pdlObj->setExtra_info($request->extra_info);
             //NOTE! if the type was changed or it is a new
             //user then set type_change equal to today
             if ($request->client_type != $request->original_type) {
                 $pdlObj->setType_change(date("Y-m-d"));
             }
             $ValidateDNI = $mapper->ValidateDNI($pdlObj);
             $ValidateEmail = $mapper->ValidateEmail($pdlObj);
             $ValidateCUIL = $mapper->ValidateCUIL($pdlObj);
             $ValidateCUIT = $mapper->ValidateCUIT($pdlObj);
             $error = array('DNI' => $ValidateDNI, 'email' => $ValidateEmail, 'CUIL' => $ValidateCUIL, 'business_CUIT' => $ValidateCUIT);
             if ($ValidateDNI === true && $ValidateEmail === true && $ValidateCUIL === true && $ValidateCUIT === true) {
                 $id = $mapper->save($pdlObj);
                 $error['valid'] = true;
                 $error['client_id'] = $id;
             } else {
                 $error['valid'] = false;
             }
             echo json_encode($error);
         }
     } catch (Exception $e) {
         echo $e;
     }
 }