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; } }
public function findClient(Gyuser_Model_User $obj) { /*$table = $this->getDbTable(); $row = $table->fetchRow( $table->select() ->join(array('client_types' => 'CT'),'clients.client_type = CT.id') ->where('id = ?', $obj->getId()) );*/ /* * TRY THIS * $select->from(array('opr' => 'operations'), array('*')); $select->joinLeft(array('ocvs' => 'other_caves'), 'opr.cave_id = ocvs.id', array('name as cave_name')); */ $db = Zend_Db_Table::getDefaultAdapter(); $stmt = $db->query("SELECT C.*, CT.name AS client_type_name FROM clients C JOIN client_types CT on C.client_type = CT.id WHERE C.id =" . $obj->getId()); $rows = $stmt->fetchAll(); if ($rows) { $row = $rows[0]; $CUIL = $row['CUIL']; if ($CUIL) { $CUIL1 = substr($CUIL, 0, 2); $CUIL2 = substr($CUIL, 2, 8); $CUIL3 = substr($CUIL, 10, 1); $CUIL = $CUIL1 . '-' . $CUIL2 . '-' . $CUIL3; } $tel_cell = $this->LandPhoneFormat($row['tel_cell']); $tel_otro = $this->LandPhoneFormat($row['tel_otro']); $tel_lab = $this->LandPhoneFormat($row['tel_lab']); $tel_part = $this->LandPhoneFormat($row['tel_part']); //$tel_cell_code = $this->CellPhoneAreaCodeFormat($row['tel_cell_code']; $tel_otro_code = $this->areaCodeOut($row['tel_otro_code, $tel_otro']); $tel_lab_code = $this->areaCodeOut($row['tel_lab_code, $tel_lab']); $tel_part_code = $this->areaCodeOut($row['tel_part_code, $tel_part']); $entry = new Gyuser_Model_User(); $entry->setId($row['id']); $entry->setClient_type($row['client_type']); //$entry->setClient_type_name($row['client_type_name']); $entry->setFirst_name($row['first_name']); $entry->setLast_name($row['last_name']); $entry->setDNI($row['DNI']); $entry->setCUIL($CUIL); $entry->setTel_cell($tel_cell); $entry->setTel_lab($tel_lab); $entry->setTel_otro($tel_otro); $entry->setTel_part($tel_part); //$entry->setTel_cell_code($tel_cell_code']); $entry->setTel_lab_code($tel_lab_code); $entry->setTel_otro_code($tel_otro_code); $entry->setTel_part_code($tel_part_code); $entry->setEmail($row['email']); $entry->setActivity($row['activity']); $entry->setDate_added(date("d/m/Y", strtotime($row['date_added']))); $entry->setOperator($row['operator']); $entry->setContact_point($row['contact_point']); $entry->setExtra_info($row['extra_info']); $entry->setBusiness($row['business']); $entry->setBusiness_CUIT($row['business_CUIT']); $entry->setType_change($row['type_change']); } return $entry; }