public function selectedclientAction()
 {
     $cdclient = $_POST["cdclient"];
     //$cdrequest = $_POST[""];
     //print_r($_POST);
     $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['fgsex'] = $client['fgsex'];
     $selectedClient['dtbirth'] = $dtbirth->toString('dd-MM-YYYY');
     $selectedClient['nrage'] = $nrage;
     //   $selectedClient['cdrequest'] = $cdrequest;
     // 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;
 }
 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;
 }