diff --git a/application/controllers/SaisieController.php b/application/controllers/SaisieController.php index 8df565f6e..ba90bc7a3 100644 --- a/application/controllers/SaisieController.php +++ b/application/controllers/SaisieController.php @@ -1653,11 +1653,13 @@ class SaisieController extends Zend_Controller_Action $this->view->assign('id1', $lienRef); } else { //Création de la première référence lien + $result = $ws->getIdentiteLight($siren); + //Compute informations $infos = array( - 'siren' => $siren, + 'siren' => $result->Siren, 'actif' => 1, 'PpPm' => 'PM', - 'RS' => $rs, + 'RS' => $result->Nom, 'civilite' => '', 'nom' => '', 'prenom' => '', @@ -1666,17 +1668,17 @@ class SaisieController extends Zend_Controller_Action 'naissance_dept_pays' => '', 'naissance_lieu' => '', 'nat' => '', - 'adresse_num' => '', - 'adresse_btq' => '', - 'adresse_codvoie' => '', - 'adresse_libvoie' => '', + 'adresse_num' => $result->AdresseNum, + 'adresse_btq' => $result->AdresseBtq, + 'adresse_codvoie' => $result->AdresseVoie, + 'adresse_libvoie' => $result->AdresseRue, 'adresse_comp' => '', - 'adresse_cp' => '', - 'adresse_ville' => '', - 'adresse_pays' => '', + 'adresse_cp' => $result->CP, + 'adresse_ville' => $result->Ville, + 'adresse_pays' => 'FRA', 'dateSaisie' => date('YmdHis'), - 'capital' => '', - 'deviseCapital' => 'EUR', + 'capital' => $result->CapitalDev, + 'deviseCapital' => $result->CapitalDev, 'nbActions' => '', 'idLoc1Type' => '', 'idLoc1Num' => '', @@ -1687,7 +1689,7 @@ class SaisieController extends Zend_Controller_Action ); $idNewLien = $ws->setLienRef(json_encode($infos)); Zend_Registry::get('firebug')->info('idNewLien:'.$idNewLien); - if (is_int($idNewLien)) { + if ( is_int($idNewLien) ) { $this->view->assign('id1', $idNewLien); } } @@ -2242,7 +2244,7 @@ class SaisieController extends Zend_Controller_Action $ws = new WsScores(); - if ($id===null) { + if ( $id===null ) { $siren = $request->getParam('siren'); $result = $ws->searchLienRef($siren, 'siren'); if (count($result->item)>0) { @@ -2253,44 +2255,57 @@ class SaisieController extends Zend_Controller_Action } } - $this->view->assign('edit', $id); + if ( $id!==null ) { - $this->view->assign('currencies', $this->currencies); - $this->view->assign('countries', $this->countries); + $this->view->assign('edit', $id); - $result = $ws->getSaisieLienRef($id); - $items = json_decode($result, true); + $this->view->assign('currencies', $this->currencies); + $this->view->assign('countries', $this->countries); - //Get country code - if ($items->adresse_pays!='FRA') { - $result = $ws->getCountryId($items['adresse_pays']); - $this->view->assign('identifiant', $result->item); - } + $result = $ws->getSaisieLienRef($id); - Zend_Registry::get('firebug')->info($items); + if ( $result!==false ) { - if (count($items)>0) { - foreach( $items as $key => $val ) { - switch ($key) { - case 'dateCapital': - case 'dateNbActions': - case 'naissance_date': - if (!empty($val) && $val!='0000-00-00') { - $date = new Zend_Date($val, 'yyyy-MM-dd'); - $this->view->assign($key, $date->toString('dd/MM/yyyy')); - } - break; - default: - $this->view->assign($key, $val); - break; - } - } - } + $items = json_decode($result, true); + if ( $items!==null ) { + Zend_Registry::get('firebug')->info('getSaisieLienRef id='.$id); + Zend_Registry::get('firebug')->info($items); + + //Get country code + if ($items->adresse_pays!='FRA') { + $result = $ws->getCountryId($items['adresse_pays']); + $this->view->assign('identifiant', $result->item); + } + + Zend_Registry::get('firebug')->info($items); + + if (count($items)>0) { + foreach( $items as $key => $val ) { + switch ($key) { + case 'dateCapital': + case 'dateNbActions': + case 'naissance_date': + if (!empty($val) && $val!='0000-00-00') { + $date = new Zend_Date($val, 'yyyy-MM-dd'); + $this->view->assign($key, $date->toString('dd/MM/yyyy')); + } + break; + default: + $this->view->assign($key, $val); + break; + } + } + } + + if ($items['PpPm']=='PM') { + $this->view->assign('nom', $items['RS']); + } else { + $this->view->assign('nom', $items['nom']); + } + } + + } - if ($items['PpPm']=='PM') { - $this->view->assign('nom', $items['RS']); - } else { - $this->view->assign('nom', $items['nom']); } } @@ -2635,18 +2650,18 @@ class SaisieController extends Zend_Controller_Action $message = $this->view->translate('Edition'); } else if ($params['mode'] == 'del') { $message = $this->view->translate('Suppression'); - } + } $result = $ws->setDirigeantsOp(json_encode($infos), $params['mode'], $params['id']); if ($result>0) { - $message = $message.' '.$this->view->translate('a été réussi!'); + $message = $message.' '.$this->view->translate('a été réussi!'); } else if ($result===0) { - $message = $message.' '.$this->view->translate('n\'a pas été réussi!'); + $message = $message.' '.$this->view->translate('n\'a pas été réussi!'); } else { $message = $result; } - + $this->view->assign('message', $message); }