public function selectedclientAction()
 {
     $cdclient = $_POST["cdclient"];
     $addressTypeModel = new AddresstypeModel();
     $clientModel = new ClientModel();
     $client = $clientModel->fetchRow($clientModel->getClientByCdClient($cdclient));
     $dtbirth = new Zend_Date($client['dtbirth'], 'dd-MM-YYYY');
     $year = $dtbirth->toString('YYYY');
     $month = $dtbirth->toString('MM');
     $day = $dtbirth->toString('dd');
     $today = new Zend_Date();
     $tdYear = $today->toString('YYYY');
     $tdMonth = $today->toString('MM');
     $tdDay = $today->toString('dd');
     $nrage = 0;
     $nrage = GslabUtils::calcAgeDifferenceShort($client['dtbirth']);
     if ($tdMonth < $month || $tdMonth == $month && $tdDay < $day) {
         $nrage--;
     }
     $selectedClient = array();
     $selectedClient['nmmail'] = $client['nmmail'];
     $selectedClient['fgactive'] = $client['fgactive'];
     $selectedClient['fgclienttype'] = $client['fgclienttype'];
     $selectedClient['fgsex'] = $client['fgsex'];
     $selectedClient['idrg'] = $client['idrg'];
     $selectedClient['idcpf'] = $client['idcpf'];
     $selectedClient['dtbirth'] = $dtbirth->toString('dd-MM-YYYY');
     $selectedClient['nrage'] = $nrage;
     $selectedClient['nrweight'] = $client['nrweight'];
     $selectedClient['nrheight'] = $client['nrheight'];
     $selectedClient['nmimage'] = $client['nmimage'];
     $selectedClient['fgvip'] = $client['fgvip'];
     $selectedClient['idaddresstype'] = $addressTypeModel->getAddressTypeById($client['idaddresstype']);
     $selectedClient['idcep'] = $client['idcep'];
     $selectedClient['nmmail'] = $client['nmmail'];
     $selectedClient['nmstreet'] = $client['nmstreet'];
     $selectedClient['nrnumber'] = $client['nrnumber'];
     $selectedClient['nmneighborhood'] = $client['nmneighborhood'];
     $selectedClient['idcity'] = $client['idcity'];
     $selectedClient['idstate'] = $client['idstate'];
     $selectedClient['idcomplement'] = $client['idcomplement'];
     $selectedClient['nrphonenumber'] = "(" . $client['nrdddphone'] . ") " . substr($client['nrphonenumber'], 0, 4) . "-" . substr($client['nrphonenumber'], 4, 4);
     // Busca apenas convênios Ativos(fgactive = 1)
     $clientCovenantModel = new ClientcovenantModel();
     $covenantData = $clientCovenantModel->fetchAll($clientCovenantModel->getClientCovenantsByCdClient($cdclient));
     $covenantArray = array();
     foreach ($covenantData as $covenant) {
         $covenantRow['cdcovenant'] = $covenant['cdcovenant'];
         $covenantRow['idcovenantcard'] = $covenant['idcovenantcard'];
         $covenantRow['nmcardholder'] = $covenant['nmcardholder'];
         $covenantRow['nmcovenant'] = $covenant['nmcovenant'];
         $covenantArray[] = $covenantRow;
     }
     $selectedClient['covenantData'] = $covenantArray;
     $this->view->selectedClient = $selectedClient;
 }
Exemplo n.º 2
0
 public function editAction()
 {
     $cdclient = $this->_request->getParam("cdclient");
     $addressTypeModel = new AddresstypeModel();
     $this->view->addressTypeData = $addressTypeModel->getAllAddressType();
     $clientModel = new ClientModel();
     $clientadressModel = new ClientaddressModel();
     $clientphoneModel = new ClientphonenumberModel();
     $clientaddressData = $clientadressModel->fetchRow();
     $client = $clientModel->fetchRow('cdclient = ' . $cdclient);
     $this->view->client = $client;
     $age = $this->view->client->dtbirth;
     $data = new Zend_Date($this->view->client->dtbirth, "YYYY-MM-dd HH:mm:ss");
     $this->view->client->dtbirth = $data->toString('dd-MM-YYYY');
     $this->view->nrage = GslabUtils::calcAgeDifferenceShort($age);
     $this->view->address = $clientadressModel->fetchRow($clientadressModel->getStateById($clientaddressData['idstate'], $cdclient));
     $clientphoneData = $clientphoneModel->fetchRow('cdclient = ' . $cdclient);
     $this->view->phone = $clientphoneData;
     if ($client['dtdum'] != '') {
         $client['dtdum'] = new Zend_Date($this->view->client->dtdum, "YYYY-MM-dd HH:mm:ss");
         $this->view->dtdum = $client['dtdum']->toString('dd-MM-YYYY');
     } else {
         $this->view->dtdum = '';
     }
     if ($clientphoneData['cdclientphonenumber'] != '') {
         $cdclientphonenumber = $clientphoneData['cdclientphonenumber'];
         if ($clientphoneData['nrphonenumber'] != '') {
             $phonenumber = $clientphoneData['nrphonenumber'];
             $dddphonenumber = $clientphoneData['nrdddphone'];
         } else {
             $phonenumber = '';
             $dddphonenumber = '';
         }
         if ($clientphoneData['nrcellphonenumber'] != '') {
             $cellphonenumber = $clientphoneData['nrcellphonenumber'];
             $dddcellphonenumber = $clientphoneData['nrdddcellphone'];
         } else {
             $cellphonenumber = '';
             $dddcellphonenumber = '';
         }
     } else {
         $phonenumber = '';
         $dddphonenumber = '';
         $cdclientphonenumber = '';
         $cellphonenumber = '';
         $dddcellphonenumber = '';
     }
     $this->view->nrphonenumber = $phonenumber;
     $this->view->nrcellphonenumber = $cellphonenumber;
     $this->view->nrdddphone = $dddphonenumber;
     $this->view->nrdddcellphone = $dddcellphonenumber;
     $this->view->cdclientphonenumber = $cdclientphonenumber;
 }