extranet/application/controllers/SaisieController.php

2980 lines
112 KiB
PHP
Raw Normal View History

2011-02-21 08:45:13 +00:00
<?php
class SaisieController extends Zend_Controller_Action
{
2013-09-23 08:47:30 +00:00
protected $countries;
protected $currencies;
/**
2011-08-20 15:32:48 +00:00
* Enter description here ...
* @var unknown_type
*/
/**
* Cours d'appel codée en dur
* @todo vérifier si table à jour
*/
protected $coursAppel = array(
array( "triId"=>"1756", "triCode"=>"AIXPRL", "triNom"=>"Cour d'Appel d'Aix-en-Provence", "triCP"=>"13616" ),
array( "triId"=>"1757", "triCode"=>"AMIENL", "triNom"=>"Cour d'Appel d'Amiens", "triCP"=>"80027" ),
array( "triId"=>"1758", "triCode"=>"ANGERL", "triNom"=>"Cour d'Appel d'Angers", "triCP"=>"49043" ),
array( "triId"=>"1759", "triCode"=>"BASSEL", "triNom"=>"Cour d'Appel de Basse-Terre", "triCP"=>"97109" ),
array( "triId"=>"1760", "triCode"=>"BASTIL", "triNom"=>"Cour d'Appel de Bastia", "triCP"=>"20407" ),
array( "triId"=>"1761", "triCode"=>"BESANL", "triNom"=>"Cour d'Appel de Besançon", "triCP"=>"25017" ),
array( "triId"=>"1762", "triCode"=>"BORDEL", "triNom"=>"Cour d'Appel de Bordeaux", "triCP"=>"33077" ),
array( "triId"=>"1763", "triCode"=>"BOURGL", "triNom"=>"Cour d'Appel de Bourges", "triCP"=>"18023" ),
array( "triId"=>"1764", "triCode"=>"CAENL", "triNom"=>"Cour d'Appel de Caen", "triCP"=>"14050" ),
array( "triId"=>"1765", "triCode"=>"CHAMBL", "triNom"=>"Cour d'Appel de Chambéry", "triCP"=>"73018" ),
array( "triId"=>"1766", "triCode"=>"COLMAL", "triNom"=>"Cour d'Appel de Colmar", "triCP"=>"68027" ),
array( "triId"=>"1767", "triCode"=>"DIJONL", "triNom"=>"Cour d'Appel de Dijon", "triCP"=>"21034" ),
array( "triId"=>"1768", "triCode"=>"DOUAIL", "triNom"=>"Cour d'Appel de Douai", "triCP"=>"59507" ),
array( "triId"=>"1769", "triCode"=>"FORTFL", "triNom"=>"Cour d'Appel de Fort-de-France", "triCP"=>"97200" ),
array( "triId"=>"1770", "triCode"=>"GRENOL", "triNom"=>"Cour d'Appel de Grenoble", "triCP"=>"38019" ),
array( "triId"=>"1771", "triCode"=>"LIMOGL", "triNom"=>"Cour d'Appel de Limoges", "triCP"=>"87031" ),
array( "triId"=>"1772", "triCode"=>"LYONL", "triNom"=>"Cour d'Appel de Lyon", "triCP"=>"69321" ),
array( "triId"=>"1773", "triCode"=>"METZL", "triNom"=>"Cour d'Appel de Metz", "triCP"=>"57036" ),
array( "triId"=>"1774", "triCode"=>"MONTPL", "triNom"=>"Cour d'Appel de Montpellier", "triCP"=>"34023" ),
array( "triId"=>"1775", "triCode"=>"NANCYL", "triNom"=>"Cour d'Appel de Nancy", "triCP"=>"54035" ),
array( "triId"=>"1776", "triCode"=>"NIMESL", "triNom"=>"Cour d'Appel de Nîmes", "triCP"=>"30031" ),
array( "triId"=>"1777", "triCode"=>"NOUMEL", "triNom"=>"Cour d'Appel de Nouméa", "triCP"=>"98848" ),
array( "triId"=>"1778", "triCode"=>"PAPEEL", "triNom"=>"Cour d'Appel de Papeete", "triCP"=>"98714" ),
array( "triId"=>"1779", "triCode"=>"PARISL", "triNom"=>"Cour d'Appel de Paris", "triCP"=>"75055" ),
array( "triId"=>"1780", "triCode"=>"PAUL", "triNom"=>"Cour d'Appel de Pau", "triCP"=>"64034" ),
array( "triId"=>"1781", "triCode"=>"POITIL", "triNom"=>"Cour d'Appel de Poitiers", "triCP"=>"86020" ),
array( "triId"=>"1782", "triCode"=>"REIMSL", "triNom"=>"Cour d'Appel de Reims", "triCP"=>"51096" ),
array( "triId"=>"1783", "triCode"=>"RENNEL", "triNom"=>"Cour d'Appel de Rennes", "triCP"=>"35064" ),
array( "triId"=>"1784", "triCode"=>"RIOML", "triNom"=>"Cour d'Appel de Riom", "triCP"=>"63201" ),
array( "triId"=>"1785", "triCode"=>"ROUENL", "triNom"=>"Cour d'Appel de Rouen", "triCP"=>"76037" ),
array( "triId"=>"1786", "triCode"=>"STDENL", "triNom"=>"Cour d'Appel de Saint-Denis-de-La Réunion", "triCP"=>"97488" ),
array( "triId"=>"1787", "triCode"=>"TOULOL", "triNom"=>"Cour d'Appel de Toulouse", "triCP"=>"31068" ),
array( "triId"=>"1788", "triCode"=>"VERSAL", "triNom"=>"Cour d'Appel de Versailles", "triCP"=>"78011" ),
array( "triId"=>"1789", "triCode"=>"ORLEAL", "triNom"=>"Cour d'Appel d'Orléans", "triCP"=>"45044" ),
array( "triId"=>"1790", "triCode"=>"CAYENL", "triNom"=>"Chambre Détachée de la Cour d'Appel de Fort de France à Cayenne", "triCP"=>"97300" ),
array( "triId"=>"1798", "triCode"=>"AGENL", "triNom"=>"Cour d'Appel d'Agen", "triCP"=>"47916" ),
);
/**
* test de type de voie
* @todo vérifier si type de voie à jour
*/
2014-03-14 10:42:09 +00:00
protected $codVoie = array(
'ABE' => "Abbaye",
'AGL' => "Agglomération",
'AIRE' => "Aire",
'ALL' => "Allée",
'ALL' => "Allee",
'ACH' => "Ancien chemin",
'ART' => "Ancienne route",
'ANSE' => "Anse",
'ARC' => "Arcade",
'AUT' => "Autoroute",
'AV' => "Avenue",
'BRE' => "Barrière",
'BCH' => "Bas chemin",
'BSTD' => "Bastide",
'BAST' => "Baston",
'BEGI' => "Beguinage",
'BER' => "Berge",
'BOIS' => "Bois",
'BCLE' => "Boucle",
'BD' => "Boulevard",
'BRG' => "Bourg",
'BUT' => "Butte",
'CALE' => "Cale",
'CAMP' => "Camp",
'CGNE' => "Campagne",
'CPG' => "Camping",
'CARR' => "Carré",
'CAU' => "Carreau",
'CAR' => "Carrefour",
'CARE' => "Carrière",
'CST' => "Castel",
'CAV' => "Cavée",
'CTRE' => "Central",
'CTRE' => "Centre",
'CHL' => "Chalet",
'CHP' => "Chapelle",
'CHI' => "Charmille",
'CHT' => "Château",
'CHS' => "Chaussée",
'CHE' => "Chemin",
'CHV' => "Chemin vicinaux",
'CHV' => "Chemin vicinal",
'CHEM' => "Cheminement",
'CITE' => "Cîte",
'CLOI' => "Cloître",
'CLOS' => "Clos",
'COL' => "Col",
'COLI' => "Colline",
'CTR' => "Contour",
'COR' => "Corniche",
'COTE' => "Côte",
'COTT' => "Cottage",
'COUR' => "Cour",
'CRS' => "Cours",
'DARS' => "Darse",
'DEG' => "Degré",
'DSG' => "Descente",
'DSC' => "Descente",
'DIG' => "Digue",
'DOM' => "Domaine",
'ECA' => "Ecart",
'ECL' => "Ecluse",
'EGL' => "Eglise",
'EN' => "Enceinte",
'ENV' => "Enclave",
'ENC' => "Enclos",
'ESC' => "Escalier",
'ESPA' => "Espace",
'ESP' => "Esplanade",
'ETING' => "Etang",
'FG' => "Faubourg",
'FRM' => "Ferme",
'FON' => "Fontaine",
'FORT' => "Fort",
'FORM' => "Forum",
'FOS' => "Fosse",
'FOYR' => "Foyer",
'GAL' => "Galerie",
'GARE' => "Gare",
'GARN' => "Garenne",
'GBD' => "Grand boulevard",
'GDEN' => "Grande ensemble",
'GR' => "Grande rue",
'GRI' => "Grille",
'GRIM' => "Grimpette",
'GPE' => "Groupe",
'GPT' => "Groupement",
'HLE' => "Halle",
'HAM' => "Hameau",
'HCH' => "Haut chemin",
'HIP' => "Hippodrome",
'HLM' => "HLM",
'ILE' => "Ile",
'IMM' => "Immeuble",
'IMP' => "Impasse",
'JARD' => "Jardin",
'JTE' => "Jetée",
'LEVE' => "Levée",
'LD' => "Lieu dit",
'LD' => "Lieudit",
'LOT' => "Lotissement",
'MAIL' => "Mail",
'MF' => "Maison forestière",
'MAN' => "Manoir",
'MAR' => "Marche",
'MAS' => "Mas",
'MET' => "Métro",
'MTE' => "Montée",
'MLN' => "Moulin",
'MUS' => "Musée",
'NTE' => "Nouvelle route",
'PAL' => "Palais",
'PARC' => "Parc",
'PKG' => "Parking",
'PRV' => "Parvis",
'PAS' => "Passage",
'PN' => "Passage à niveau",
'PASS' => "Passe",
'PLE' => "Passerelle",
'PAT' => "Patio",
'PAV' => "Pavillon",
'PERI' => "Périphérique",
'PSTY' => "Péristyle",
'PTA' => "Petites allée",
'PCH' => "Petit chemin",
'PAE' => "Petite avenue",
'PIM' => "Petite impasse",
'PRT' => "Petite route",
'PTR' => "Petite rue",
'PL' => "Place",
'PLCI' => "Placis",
'PLAG' => "Plage",
'PLN' => "Plaine",
'PLAN' => "Plan",
'PLT' => "Plateau",
'PNT' => "Pointe",
'PONT' => "Pont",
'PCH' => "Porche",
'PORT' => "Port",
'PTE' => "Porte",
'PORQ' => "Portique",
'POT' => "Poterne",
'POUR' => "Pourtour",
'PRE' => "Pré",
'PRQ' => "Presqu'île",
'PROM' => "Promenade",
'QU' => "Quai",
'QUAI' => "Quai",
'QUA' => "Quartier",
'RAC' => "Raccourci",
'RAID' => "Raidillon",
'RPE' => "Rampe",
'REM' => "Rempart",
'RES' => "Résidence",
'ROC' => "Roc",
'ROC' => "Rocade",
'RPT' => "Rond point",
'ROQT' => "Roquet",
'RTD' => "Rotonde",
'RTE' => "Route",
'R' => "Rue",
'RUE' => "Rue",
'RLE' => "Ruelle",
'SEN' => "Sente",
'SEN' => "Sentier",
'SQ' => "Square",
'STDE' => "Stade",
'STA' => "Station",
'TPL' => "Terre plein",
'TRN' => "Terrain",
'TSSE' => "Terrasse",
'TRT' => "Tertre",
'TOUR' => "Tour",
'TRA' => "Traverse",
'VAL' => "Vallon",
'VAL' => "Vallée",
'VEN' => "Venelle",
'VIA' => "Via",
'VTE' => "Vieille route",
'VCHE' => "Vieux chemin",
'VLA' => "Villa",
'VGE' => "Village",
'VLGE' => "Village",
'VOI' => "Voie",
'VOIE' => "Voie",
'ZONE' => "Zone",
'ZAC' => "Zone d'aménagement concerté",
'Z A C' => "Zone d'aménagement concerté",
'ZAD' => "Zone d'aménagement différé",
'Z A D' => "Zone d'aménagement différé",
'ZA' => "Zone artisanale",
'Z A' => "Zone artisanale",
'ZI' => "Zone industrielle",
'Z I' => "Zone industrielle",
'ZUP' => "Zone à urbaniser en priorité",
'Z U P' => "Zone à urbaniser en priorité",
);
2012-05-20 16:31:28 +00:00
2011-08-20 15:32:48 +00:00
/**
* Retourne Fonctions de direction
2011-08-20 15:32:48 +00:00
*/
protected function fctDir()
{
$fctdir = new Application_Model_FctDir();
$sql = $fctdir->select('codeFct, libelle');
$selectDir['0000'] = '-';
$rows = $fctdir->fetchAll($sql);
if ( count($rows)>0 ) {
foreach ($rows as $item) {
$index = str_pad($item->codeFct, 4, "0", STR_PAD_LEFT);
$selectDir[$index] = $item->libelle;
}
}
return $selectDir;
}
2012-05-20 16:31:28 +00:00
2011-08-20 15:32:48 +00:00
/**
2012-05-20 16:31:28 +00:00
* Genre
2011-08-21 13:12:01 +00:00
* @var array
2011-08-20 15:32:48 +00:00
*/
/**
* civilité en dur
* @todo verifier si liste à jour civilité
*/
2011-08-21 13:04:38 +00:00
protected $selectGenre = array(
'' => '-',
'M.' => 'M',
'Mme' => 'Mme',
'Mlle' => 'Mlle',
'Societe' => 'STE'
);
2011-08-21 13:43:07 +00:00
public function init()
{
require_once 'Scores/WsScores.php';
require_once 'Scores/IdentiteEntreprise.php';
2012-05-20 16:31:28 +00:00
$ws = new WsScores();
2013-09-23 08:47:30 +00:00
//codPays3 (index), libPays, devise
$countries = json_decode($ws->getCatalogCountry(),true);
if ($countries!==false) {
2012-12-12 21:19:42 +00:00
$lib = array();
foreach ($countries as $key => $row) {
$lib[$key] = $row['libPays'];
}
array_multisort($lib, SORT_ASC, SORT_STRING, $countries);
$this->countries = $countries;
}
2013-09-23 08:47:30 +00:00
//devIso (index), devNom
2012-12-12 21:19:42 +00:00
$currencies = json_decode($ws->getCatalogCurrency(),true);
if ($currencies!==false) {
$lib = array();
foreach ($currencies as $key => $row) {
$lib[$key] = $row['devNom'];
}
array_multisort($lib, SORT_ASC, SORT_STRING, $currencies);
$this->currencies = $currencies;
}
$this->view->headLink()->appendStylesheet('/themes/default/styles/saisie.css', 'all');
}
2012-05-20 16:31:28 +00:00
2011-08-20 15:32:48 +00:00
/**
* Index
*/
2013-09-23 08:47:30 +00:00
public function indexAction()
{
//Do nothing
}
2012-05-20 16:31:28 +00:00
2011-06-07 09:59:39 +00:00
/**
* Affichage du formulaire de saisie
* @todo : Enregistrement des informations en session pour récupération
2011-06-07 09:59:39 +00:00
*/
2011-05-06 14:17:44 +00:00
public function ficheAction()
{
2012-01-24 17:10:14 +00:00
$this->view->headScript()
->appendFile('/themes/default/scripts/saisie.js', 'text/javascript')
->appendFile('/libs/form/jquery.form.min.js', 'text/javascript');
2012-05-20 16:31:28 +00:00
$request = $this->getRequest();
$siret = $request->getParam('siret');
$id = $request->getParam('id', 0);
2012-05-20 16:31:28 +00:00
2011-12-28 10:18:08 +00:00
$this->view->headTitle()->append('Saisie - '.$siret);
2012-05-20 16:31:28 +00:00
$ws = new WsScores();
$infos = $ws->getIdentite($siret, $id);
$devisesReponse = $ws->getDevises();
$devises = $devisesReponse->result->item;
2012-05-20 16:31:28 +00:00
//Mise en session
2013-11-21 16:31:49 +00:00
$session = new Scores_Session_Entreprise($siret, $id, true);
$session->setInfoEntrep($infos);
2012-05-20 16:31:28 +00:00
2011-12-12 14:13:09 +00:00
$sessionSaisie = new Zend_Session_Namespace('saisie');
$sessionSaisie->tabSaisie['tribunal'] = $infos->TribunalCode;
2012-05-20 16:31:28 +00:00
2013-09-23 08:47:30 +00:00
//@todo : Change
$this->view->assign('selectPays', $this->countries);
$this->view->assign('siret', $siret);
$this->view->assign('id', $id);
$this->view->assign('devises', $devises);
$this->view->assign('etab', $infos);
}
2011-06-23 07:20:15 +00:00
2011-07-06 15:31:24 +00:00
/**
* Sauvegarde des informations de saisie
2012-05-20 16:31:28 +00:00
* @todo : Sauvegarder en mémoire la saisie
2011-07-06 15:31:24 +00:00
*/
public function saveAction()
{
//$this->_helper->layout()->disableLayout();
//$this->_helper->viewRenderer->setNoRender(true);
2012-05-20 16:31:28 +00:00
2011-07-06 15:31:24 +00:00
$request = $this->getRequest();
2012-05-20 16:31:28 +00:00
$siret = $request->getParam('siret');
$id = $request->getParam('id', 0);
2012-05-20 16:31:28 +00:00
2011-07-06 15:31:24 +00:00
$tabSaisie = $request->getParam('frmSaisie');
$tabJugement = $request->getParam('jugement');
$tabActionna = $request->getParam('actionnaire');
$tabParticip = $request->getParam('particip');
$tabScore = $request->getParam('score');
$perimetreVente = $request->getParam('perimetreVente');
$etablissement5500 = $request->getParam('etablissement5500');
$etabnic = $request->getParam('etabnic');
2012-05-20 16:31:28 +00:00
2011-07-06 15:31:24 +00:00
//Vente et Cession evénement 5500
if ($perimetreVente!=null){
foreach($perimetreVente as $k => $p){
if ( $p=='-' ){
array_splice($perimetreVente, $k, 1);
}
}
if ( isset($perimetreVente) && count($perimetreVente)>0 ){
$tabJugement['even'] = array_merge(
$tabJugement['even'],
$perimetreVente);
}
}
//Liste établissements concernées
if ( $etablissement5500!=null && count($etablissement5500)>0 ) {
$countEtab = 0;
$txtEtab = '';
foreach($etablissement5500 as $etab){
$txtEtab.= $etab;
$countEtab++;
if($countEtab>10) break;
if( count($etablissement5500) > $countEtab )
{ $txtEtab.=', '; }
}
2012-05-20 16:31:28 +00:00
2011-07-06 15:31:24 +00:00
if ( count($etablissement5500)>1 ){
$txt = 'Etablissement(s) concerné(s) : ';
} else {
$txt = 'Etablissement concerné : ';
}
2012-05-20 16:31:28 +00:00
2011-07-06 15:31:24 +00:00
if ( $tabJugement['comp']!='' ) {
$tabJugement['comp'].= ' '.$txt.$txtEtab;
} else {
$tabJugement['comp'] = ' '.$txt.$txtEtab;
}
}
2012-05-20 16:31:28 +00:00
2011-07-06 15:31:24 +00:00
//Sélection nic pour établissement concerné
if ( $etabnic!=null && $etabnic != '' ) {
if ( isset($txtEtab) && $txtEtab!='' ) {
$tabJugement['comp'].= ', '.$etabnic;
} else {
$tabJugement['comp'].= 'Etablissement concerné : '.$etabnic;
}
}
2012-05-20 16:31:28 +00:00
2011-07-06 15:31:24 +00:00
//Opposition à l'adresse
if ( $tabJugement['oppo'] == 'adresse' ) {
if ( $tabJugement['comp']!='' ) {
$tabJugement['comp'].= ' Opposition : A l\'adresse du bien vendu';
} else {
$tabJugement['comp'] = 'Opposition : A l\'adresse du bien vendu';
}
}
2012-05-20 16:31:28 +00:00
$tabInfos = array();
$tabInfos['identite'] = $tabSaisie;
$tabInfos['jugement'] = $tabJugement;
$tabInfos['actionnaire'] = $tabActionna;
$tabInfos['participation'] = $tabParticip;
$tabInfos['scores'] = $tabScore;
2012-05-20 16:31:28 +00:00
2011-07-06 15:31:24 +00:00
$ws = new WsScores();
$O = $ws->setInfosEntrep($siret, $id, $tabInfos);
//Enregistrement en session pour saisie supplémentaire ou lors d'erreur
2011-07-06 15:31:24 +00:00
$tabSaisie = array(
'source' => $tabJugement['source'],
'dateParution' => $tabJugement['dateParution'],
'numParution' => $tabJugement['numParution']
);
2012-05-20 16:31:28 +00:00
$session = new Zend_Session_Namespace('saisie');
$session->tabSaisie = $tabSaisie;
2012-05-20 16:31:28 +00:00
if ($O->error->errnum!=0){
2014-10-16 18:46:23 +00:00
$message = "Erreur lors de l'enregistrement !";
$this->_helper->getHelper('Redirector')->setGotoSimple('fiche', 'saisie', null, array(
2011-10-25 07:45:44 +00:00
'siret' => $siret,
'id' => $id,
'message' => $message
2012-05-20 16:31:28 +00:00
));
} else {
$message = 'Saisie enregistrée !';
$this->view->assign('params', $request->getParams());
$this->view->assign('tabInfos', $tabInfos);
$this->view->assign('O', $O);
2011-10-25 07:45:44 +00:00
$this->view->assign('siret', $siret);
$this->view->assign('id', $id);
$this->view->assign('message', $message);
2012-05-20 16:31:28 +00:00
}
2011-07-06 15:31:24 +00:00
}
2012-05-20 16:31:28 +00:00
2011-06-07 09:59:39 +00:00
/**
* Retourne le formulaire bodacc
*/
public function formAction()
{
$request = $this->getRequest();
$siret = $request->getParam('siret');
$id = $request->getParam('id', 0);
2012-05-20 16:31:28 +00:00
2013-11-21 16:31:49 +00:00
$session = new Scores_Session_Entreprise($siret, $id);
2012-05-20 16:31:28 +00:00
$ws = new WsScores();
2012-05-20 16:31:28 +00:00
$reponse = $ws->getListeJalCollecte();
$listeJalCollecte = $reponse->result->item;
$this->view->assign('ListeJalCollecte', $listeJalCollecte);
2012-05-20 16:31:28 +00:00
2011-12-06 10:23:00 +00:00
if (Zend_Session::sessionExists()){
if(Zend_Session::namespaceIsset('saisie')){
$sessionSaisie = new Zend_Session_Namespace('saisie');
$saisie = $sessionSaisie->tabSaisie;
$this->view->assign('saisie', $saisie);
}
2011-10-25 09:03:21 +00:00
}
2012-05-20 16:31:28 +00:00
2011-12-12 14:13:09 +00:00
$eventNum = isset($saisie['eventNum']) ? $saisie['eventNum'] : '0000' ;
$this->view->assign('eventNum', $eventNum);
2012-05-20 16:31:28 +00:00
//Si le code tribunal n'est pas défini dans la fiche identité
//alors en sélectionner un par défault suivant le code INSEE
2011-12-12 14:13:09 +00:00
$tribunal = isset($saisie['tribunal']) ? $saisie['tribunal'] : '' ;
$this->view->assign('codeTribunalCmp', $tribunal);
2012-05-20 16:31:28 +00:00
$listeCompetences = array();
if ($tribunal=='') {
$siret = $session->getSiret();
$codeCommune = $session->getCodeCommune();
$reponse = $ws->getListeCompetences($siret, 'tri', $codeCommune);
$listeCompetences = $reponse->result->item;
}
$this->view->assign('ListeCompetences', $listeCompetences);
2012-05-20 16:31:28 +00:00
$reponse = $ws->getTribunaux( array('C','I','G','M','P') );
$listeTribunaux = array();
if (count($reponse->result->item)>0) {
foreach($reponse->result->item as $item) {
$listeTribunaux[$item->code] = $item->nom;
}
asort($listeTribunaux);
}
$this->view->assign('ListeTribunaux', $listeTribunaux);
/**
* table des événements en dur
* @todo verifier si liste à jour
*/
$selectEvent = array(
'1100', '1101' , '1200', '1201', '1300', '1301', '1302', '1303', '1304', '1305', '1306',
2013-09-23 08:47:30 +00:00
'1307', '1308', '1309', '1310', '1311', '1312', '1408', '1411', '1412', '1413', '1414',
'1415', '1511', '1502', '1506', '1503', '1512', '1600', '1601', '1999', '2102', '2100',
'2202', '2206', '2319', '2315', '2313', '2305', '2307', '2303', '2306', '2901', '4500',
'5500', '6700', '1010', '1050', '1055', '2203', '2204', '2210', '2212',
);
$eventM = new Application_Model_TabEvenements();
$sql = $eventM->select()
->where('codEven IN ('.join(',',$selectEvent).')')
->order('libEven ASC');
$rows = $eventM->fetchAll($sql);
$tabEvent = array();
if ($rows->count()>0) {
foreach($rows as $row){
2013-01-24 08:56:39 +00:00
$tabEvent[$row->codEven] = $row->libEven;
}
2012-05-20 16:31:28 +00:00
}
$this->view->assign('tabEvent', $tabEvent);
$this->view->assign('siret', $siret);
}
2012-05-20 16:31:28 +00:00
2011-06-07 09:59:39 +00:00
/**
* Retourne le formulaire correspondant à l'évenement
*/
public function evenAction()
{
$request = $this->getRequest();
if ( $request->isPost() ){
$this->_helper->layout->disableLayout();
}
$num = $request->getParam('num', '0000');
$siren = $request->getParam('siren', '');
$nic = $request->getParam('nic', '');
$tribunal = $request->getParam('tribunal', '');
$selectDir = $this->fctDir();
2012-05-20 16:31:28 +00:00
2011-12-06 10:23:00 +00:00
if (Zend_Session::sessionExists()){
2011-12-06 10:31:54 +00:00
/*if(Zend_Session::namespaceIsset('saisie')){
2011-12-06 10:23:00 +00:00
$sessionSaisie = new Zend_Session_Namespace('saisie');
$this->view->assign('saisie', $sessionSaisie->tabSaisie);
$num = $sessionSaisie->tabSaisie['eventNum'];
$tribunal = $sessionSaisie->tabSaisie['tribunal'];
$siren = substr($siren, 0, 9);
2012-05-20 16:31:28 +00:00
$nic = substr($siren, 9, 5);
2011-12-06 10:31:54 +00:00
}*/
2011-12-06 10:23:00 +00:00
}
2012-05-20 16:31:28 +00:00
switch($num) {
case '5500':
//Liste des établissements
$ws = new WsScores();
$reponse = $ws->getListeEtablissements($siren, -1, 0, 200);
$listeEtablissements = $reponse->result->item;
$this->view->assign('ListeEtablissements', $listeEtablissements);
break;
case '6700':
//Liste des établissements
$ws = new WsScores();
$reponse = $ws->getListeEtablissements($siren, -1, 0, 200);
$listeEtablissements = $reponse->result->item;
//Zend_Registry::get('firebug')->info(count($listeEtablissements));
$this->view->assign('ListeEtablissements', $listeEtablissements);
//Assign constantes
$this->view->assign('selectDir', $selectDir);
2015-03-02 13:43:42 +00:00
$this->view->assign('selectGenre', $this->selectGenre);
break;
case '2202':
case '2203':
case '2204':
case '2210':
case '2212':
case '2315':
//Assign constantes
$this->view->assign('selectDir', $selectDir);
2015-03-02 13:43:42 +00:00
$this->view->assign('selectGenre', $this->selectGenre);
break;
}
$this->view->assign('siren', $siren);
$this->view->assign('nic', $nic);
$this->view->assign('tribunal', $tribunal);
$this->renderScript('saisie/even/'.$num.'.phtml');
}
2012-05-20 16:31:28 +00:00
2011-06-07 09:59:39 +00:00
/**
* Affiche un champ de formulaire
*/
public function champsAction()
{
$request = $this->getRequest();
$champ = $request->getParam('champ', '');
$this->renderScript('saisie/champs/'.$champ.'.phtml');
}
2012-05-20 16:31:28 +00:00
2011-06-07 09:59:39 +00:00
/**
* Retourne les informations de l'établissements
*/
2011-05-06 15:47:21 +00:00
public function etabnicAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
2012-05-20 16:31:28 +00:00
2011-05-06 15:47:21 +00:00
$request = $this->getRequest();
$siret = $request->getParam('siret', '');
if($siret!='') {
$ws = new WsScores();
$etab = $ws->getIdentite($siret);
if($etab->Siret==$siret){
echo $etab->Adresse.' '.$etab->CP.' '.$etab->Ville.' ('. $etab->Nic.')';
}
}
}
2012-05-20 16:31:28 +00:00
public function listetabAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$request = $this->getRequest();
$siren = $this->getParam('siren');
$p = $request->getParam('p', 0);
if (!empty($p)) {
$ws = new WsScores();
$reponse = $ws->getListeEtablissements($siren, -1, $p);
$liste = array();
if (count($reponse->result->item)>0) {
foreach ($reponse->result->item as $item) {
$liste[] = array(
'value' => $item->Nic,
'label' => $siren.$item->Nic.' - '.$item->Adresse.' '.$item->CP.' '.$item->Ville,
);
}
}
if ($p < $reponse->nbReponses) {
$p = $p+200;
}
$output = array( 'p' => $p, 'list' => $liste );
}
echo json_encode($output);
}
2011-06-07 09:59:39 +00:00
/**
* Retourne le formulaire d'opposition insee
*/
public function oppositioninseeAction()
{
2011-11-18 15:43:53 +00:00
$this->_helper->layout->disableLayout();
2011-06-07 09:59:39 +00:00
}
2011-12-06 16:48:03 +00:00
/**
* Retourne le formulaire de refus rncs
*/
public function refusrncsAction()
{
$this->_helper->layout->disableLayout();
}
2012-05-20 16:31:28 +00:00
2011-06-23 07:20:15 +00:00
/**
2011-08-20 15:32:48 +00:00
* Suppression / Copie et Edition des annonces
* @todo : Faire l'edition des annonces
2011-06-23 07:20:15 +00:00
*/
2011-07-01 12:44:12 +00:00
public function annonceAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
2012-05-20 16:31:28 +00:00
$request = $this->getRequest();
$source = $request->getParam('source');
$op = $request->getParam('op');
2012-05-20 16:31:28 +00:00
switch($op)
{
2011-07-01 12:44:12 +00:00
case 'delete':
2012-05-20 16:31:28 +00:00
2011-12-16 09:00:08 +00:00
$siret = str_replace(' ', '', $request->getParam('siret'));
2011-07-01 12:44:12 +00:00
$idan = $request->getParam('idan');
2012-05-20 16:31:28 +00:00
2011-07-01 12:44:12 +00:00
$sourceNum = false;
$source = strtoupper($source);
if (in_array($source, array('BODA', 'BODB', 'BODC'))){
$sourceNum = 1;
} elseif ($source == 'BALO') {
$sourceNum = 2;
} elseif ($source == 'ASSO') {
$sourceNum = 3;
} elseif (in_array($source, array('BOMP A', 'BOMP B', 'BOMP C', 'MAPA'))) {
$sourceNum = 4;
} elseif (!empty($source)){
$sourceNum = 0;
}
2012-05-20 16:31:28 +00:00
2011-07-01 12:44:12 +00:00
if ($sourceNum === false) {
echo "Source inconnu"; exit;
}
2012-05-20 16:31:28 +00:00
2011-07-01 12:44:12 +00:00
$ws = new WsScores();
$reponse = $ws->supprAnnonce($sourceNum, $idan, $siret);
$error = $reponse->error;
if ( isset($error) && $error->errnum == 0 ){
2011-07-01 12:44:12 +00:00
$output = 'Annonce '.$idan.' supprimé !';
} elseif ( isset($error) && $error->errnum != 0 ) {
2011-07-01 12:44:12 +00:00
$output = 'Erreur lors de la suppression.';
} else {
$output = "Une erreur est survenue...";
}
echo $output;
2012-05-20 16:31:28 +00:00
2011-07-01 12:44:12 +00:00
break;
2012-05-20 16:31:28 +00:00
2011-07-01 12:44:12 +00:00
case 'copy':
2012-05-20 16:31:28 +00:00
2011-12-16 09:01:21 +00:00
$siretIn = str_replace(' ', '', $request->getParam('siretIn'));
$siretOut = str_replace(' ', '', $request->getParam('siretOut'));
2011-07-01 12:44:12 +00:00
$idan = $request->getParam('idan');
2012-05-20 16:31:28 +00:00
$sourceNum = false;
$source = strtoupper($source);
if (in_array($source, array('BODA', 'BODB', 'BODC'))){
$sourceNum = 1;
} elseif ($source == 'BALO') {
$sourceNum = 2;
} elseif ($source == 'ASSO') {
$sourceNum = 3;
} elseif (in_array($source, array('BOMP A', 'BOMP B', 'BOMP C', 'MAPA'))) {
$sourceNum = 4;
} elseif (!empty($source)){
$sourceNum = 0;
}
if ($sourceNum === false) {
echo "Source inconnu"; exit;
}
$ws = new WsScores();
$reponse = $ws->dupliqueAnnonce($sourceNum, $idan, $siretIn, $siretOut);
$error = $reponse->error;
if ( isset($error) && $error->errnum == 0 ){
$output = 'Annonce '.$idan.' dupliqué sur '.$siretOut.'!';
} elseif ( isset($error) && $error->errnum != 0 ) {
$output = 'Erreur lors de la duplication.';
2011-07-01 12:44:12 +00:00
} else {
$output = "Une erreur est survenue...";
2011-07-01 12:44:12 +00:00
}
echo $output;
2012-05-20 16:31:28 +00:00
2011-07-01 12:44:12 +00:00
break;
2012-05-20 16:31:28 +00:00
2011-07-01 12:44:12 +00:00
case 'edit':
2012-05-20 16:31:28 +00:00
//@todo : sauvegarder
2012-05-20 16:31:28 +00:00
2011-07-01 12:44:12 +00:00
$siret = $request->getParam('siret');
$idan = $request->getParam('idan');
2012-05-20 16:31:28 +00:00
print_r($request->getParams());
2012-05-20 16:31:28 +00:00
/*
echo saisie_save($siret, '', $tabInfo);
echo '<br/>';
2012-05-20 16:31:28 +00:00
*/
2012-05-20 16:31:28 +00:00
2011-07-01 12:44:12 +00:00
break;
2012-05-20 16:31:28 +00:00
case 'even':
2012-05-20 16:31:28 +00:00
2011-12-16 09:01:21 +00:00
$siret = str_replace(' ', '', $request->getParam('siret'));
$idan = $request->getParam('idan');
2012-05-20 16:31:28 +00:00
$codeEven = $request->getParam('even');
$siren = substr($siret,0,9);
$ws = new WsScores();
$result = $ws->setAnnonceEven($siren, $idan, $codeEven);
if ($result===true) {
echo "Modification effectué";
} else {
echo "Erreur !";
}
2012-05-20 16:31:28 +00:00
break;
2012-05-20 16:31:28 +00:00
2011-07-01 12:44:12 +00:00
default:
echo 'Error !';
break;
}
}
2012-05-20 16:31:28 +00:00
2011-06-23 07:20:15 +00:00
/**
* Affiche le fomulaire d'edition/suppression/copie d'annonce
*/
2011-07-01 12:44:12 +00:00
public function annoncedialogAction()
{
$this->_helper->layout->disableLayout();
2012-05-20 16:31:28 +00:00
2011-07-01 12:44:12 +00:00
$request = $this->getRequest();
$siret = $request->getParam('siret');
2011-07-01 12:44:12 +00:00
$op = $request->getParam('op');
$idan = $request->getParam('idAnn');
$source = $request->getParam('code');
2012-05-20 16:31:28 +00:00
if ($op == 'edit')
{
$siret = $request->getParam('siret');
2012-05-20 16:31:28 +00:00
$siren = substr($siret,0,9);
$nic = substr($siret,10,5);
2012-05-20 16:31:28 +00:00
if ( !empty($idan) )
{
$ws = new WsScores();
$reponse = $ws->getAnnonceCollecte($idan, $siret);
if ($reponse->error->errnum>0)
{
$message = $reponse->error->errmsg;
$this->view->assign('message', $message);
2012-05-20 16:31:28 +00:00
}
else
{
$idanResult = $reponse->result;
//Limitation des événements
$eventLimits = array('5500');
foreach ( $eventLimits as $eventLimit )
{
$isEditable = false;
if (count($idanResult->even->item)>0){
foreach($idanResult->even->item as $even){
if ($eventLimit == $even->CodeEven){
$isEditable = true;
break;
2012-05-20 16:31:28 +00:00
}
}
}
if ( $isEditable && in_array($idanResult->source, array('JT', 'ANTE')))
{
2013-11-05 14:45:25 +00:00
$dateParution = new Zend_Date(substr($idanResult->dateSource,0,10), 'yyyy-MM-dd');
$dateJugement = new Zend_Date($idanResult->dateEffetFinP, 'yyyy-MM-dd');
$dateFinPeriode = new Zend_Date($idanResult->dateJugement, 'yyyy-MM-dd');
//Mapper idanResult dans le tableau de saisie
$saisie = array(
'source' => isset($_SESSION['source']) ? $_SESSION['source'] : $idanResult->source,
'dateParution' => isset($_SESSION['dateParution']) ? $_SESSION['dateParution'] :
2013-11-05 14:45:25 +00:00
$dateParution->toString('dd/MM/yyyy'),
'numParution' => isset($_SESSION['numParution']) ? $_SESSION['numParution'] : '',
2013-11-05 14:45:25 +00:00
'dateJugement' => $dateJugement->toString('dd/MM/yyyy'),
'tribunal' => $idanResult->tribunal,
'even' => $idanResult->even->item,
'eventNum' => $eventLimit,
'comp' => $idanResult->complement,
'montant' => $idanResult->montant,
2013-11-05 14:45:25 +00:00
'dateFinPeriode' => $dateFinPeriode->toString('dd/MM/yyyy'),
);
2012-05-20 16:31:28 +00:00
$intervenants = array();
for ( $i=0 ; $i<3 ; $i++ ) {
$intervenants[$i] = array(
'type' => $idanResult->{'inter'.($i+1).'type'},
'id' => $idanResult->{'inter'.($i+1).'id'},
'nom' => $idanResult->{'inter'.($i+1).'nom'},
);
}
2012-05-20 16:31:28 +00:00
$sessionSaisie = new Zend_Session_Namespace('saisie');
$sessionSaisie->tabSaisie = $saisie;
2012-05-20 16:31:28 +00:00
//require_once realpath(dirname(__FILE__)).'/constantes.php';
//require_once realpath(dirname(__FILE__)).'/saisie_form_event.php';
break;
} else {
$message = "Source : ".$idanResult->source."<br/>";
$message.= "Evénement(s) non éditable : <br/>";
foreach($idanResult->even->item as $even){
$message.= $even->CodeEven." - ";
$eventM = new Application_Model_TabEvenements();
$row = $eventM->find($even->CodeEven);
if (null !== row) {
$message.= $row->current()->libEven;
}
$message.= "<br/>";
}
$this->view->assign('message', $message);
}
}
}
}
2012-05-20 16:31:28 +00:00
}
elseif ($op == 'even')
{
$eventM = new Application_Model_TabEvenements();
$sql = $eventM->select()->order('libEven ASC');
$rows = $eventM->fetchAll($sql);
$tabEvent = array();
if ($rows->count()>0) {
foreach($rows as $row){
$tabEvent[$row->codEven] = $row->libEven;
}
}
$this->view->assign('evens', $tabEvent);
}
2011-07-01 12:44:12 +00:00
$this->view->assign('op', $op);
$this->view->assign('idan', $idan);
$this->view->assign('source', $source);
$this->view->assign('siret', $siret);
2011-07-01 12:44:12 +00:00
}
2012-05-20 16:31:28 +00:00
2012-08-23 08:03:50 +00:00
public function associationAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
$type = $request->getParam('type');
$siren = $request->getParam('siren');
$waldec = $request->getParam('waldec');
2012-08-23 08:03:50 +00:00
//Téléchargement du fichier
if ( isset($_FILES) && count($_FILES)==1 ) {
$this->_helper->viewRenderer->setNoRender(true);
if ( empty($siren) ) {
echo "Pas d'identifiant!";
2012-08-23 08:03:50 +00:00
} else {
$c = Zend_Registry::get('config');
$path = $c->profil->path->data.'/association';
if ( $type=='bilan' ){
$dateCloture = $request->getParam('dateCloture');
if (strlen($dateCloture)!=8) {
echo "Erreur format date cloture";
}
$path.= '/bilans';
$name = $siren.'_'.$dateCloture;
} elseif ( $type=='acte' ) {
$date = $request->getParam('date');
if (strlen($date)!=8) {
echo "Erreur format date";
}
$name = 'ST-'.$siren.'-'.$date;
$path.= '/actes';
}
$n = $_FILES['fichier']['name'];
$s = $_FILES['fichier']['size'];
$tmp_name = $_FILES['fichier']['tmp_name'];
$extValide = array('pdf');
$extension = strrchr($n,'.');
$extension = strtolower(substr($extension,1));
//Vérifier l'extension du fichier
if( !in_array($extension, $extValide) ){
echo "Extension de fichier incorrect !";
} elseif ( move_uploaded_file($tmp_name, $path.'/'.$name.'.'.$extension) ){
$result = true;
//Send info to webservice
if ( $type='acte' ) {
$ws = new WsScores();
$info = $ws->setActeAsso($siren, $waldec, 'ST', 'Statut', $date);
if (is_string($info)) {
$result = false;
}
}
//Display message
if ($result) {
echo "Fichier envoyé, <a target=\"_blank\" href=\"".$this->view->url(array(
'controller' => 'fichier',
'action' => 'pdfassociation',
'file' => $name.'.'.$extension,
), 'default', true)."\">Cliquez pour voir le fichier</a>";
}
} else {
echo "Erreur lors du déplacement du fichier !";
}
}
2012-08-23 08:03:50 +00:00
//Affichage formulaire
} else {
$this->view->inlineScript()->appendFile('/libs/form/jquery.form.min.js');
2012-08-23 08:03:50 +00:00
if ( intval($siren)==0 ) {
2013-11-21 16:31:49 +00:00
$session = new Scores_Session_Entreprise();
2012-08-23 08:03:50 +00:00
$siren = '';
if ( substr($session->AutreId,0,1)=='W' ) {
$siren = $session->AutreId;
}
}
$this->view->assign('siren', $siren);
$this->view->assign('type', $type);
}
}
2012-05-20 16:31:28 +00:00
public function liasseAction()
2013-02-11 08:25:59 +00:00
{
$request = $this->getRequest();
2012-05-20 16:31:28 +00:00
$siret = $request->getParam('siret');
$id = $request->getParam('id');
2012-09-03 06:39:21 +00:00
$siren = substr($siret,0,9);
$this->view->assign('siren', $siren);
2013-11-21 16:31:49 +00:00
$session = new Scores_Session_Entreprise($siret, $id);
2012-05-20 16:31:28 +00:00
$this->view->assign('siret', $siret);
$this->view->assign('raisonSociale', $session->getRaisonSociale());
2012-09-03 06:39:21 +00:00
require_once 'Scores/WsScores.php';
$ws = new WsScores();
2012-09-03 06:39:21 +00:00
$selection = $request->getParam('selection', '');
2013-05-15 18:22:21 +00:00
2012-09-14 09:50:24 +00:00
if ( !empty($selection) ) {
list($date, $type) = explode(':', $selection);
2012-09-03 06:39:21 +00:00
if ($date!='NEW') {
2013-05-15 18:22:21 +00:00
$milDate = $milDatePre = null;
$listBilans = $ws->getListeBilans($siren);
if ( count($listBilans->result->item) > 0 ) {
foreach ($listBilans->result->item as $item) {
2013-05-15 18:22:21 +00:00
if ($type == $item->typeBilan) {
if ($item->dateExercice == $date) {
$milDate = $item->dateExercice;
}
if (substr($item->dateExercice,0,4) == intval(substr($date,0,4))-1) {
$milDatePre = $item->dateExercice;
}
}
}
}
if ( null !== $milDate ) {
Zend_Registry::get('firebug')->info('milDate');
2013-05-15 18:22:21 +00:00
$response = $ws->getBilan($siren, $milDate, $type, true);
$infos = new stdClass();
$infos->siren = $response->siren;
$infos->dateCloture = $response->DATE_CLOTURE;
$infos->dateCloturePre = $response->DATE_CLOTURE_PRE;
$infos->dureeMois = $response->DUREE_MOIS;
$infos->dureeMoisPre = $response->DUREE_MOIS_PRE;
$infos->unite = empty($response->MONNAIE_LIV_UNITE) ? 'U' : $response->MONNAIE_LIV_UNITE;
$postes = array();
foreach ($response->POSTES->item as $item) {
$postes[$item->id] = $item->val;
}
} elseif ( null === $milDate && null !== $milDatePre ) {
Zend_Registry::get('firebug')->info('milDatePre');
2013-05-15 18:22:21 +00:00
$response = $ws->getBilan($siren, $milDatePre, $type, true);
Zend_Registry::get('firebug')->info($response);
$infos = new stdClass();
$infos->siren = $response->siren;
$infos->dateCloturePre = $response->DATE_CLOTURE;
$infos->dureeMoisPre = $response->DUREE_MOIS;
2013-05-15 18:22:21 +00:00
$infos->unite = empty($response->MONNAIE_LIV_UNITE) ? 'U' : $response->MONNAIE_LIV_UNITE;
$postesN1 = array();
foreach ($response->POSTES->item as $item) {
$postesN1[$item->id] = $item->val;
}
$postes = array();
/** Reprises des valeures N-1 si l'information est absente en base **/
if ($type=='N' || $type=='C') {
// Actif
if (!isset($postes['AA3']) && isset($postesN1['AA2'])) $postes['AA3']=$postesN1['AA2'];
if (!isset($postes['AC2']) && isset($postesN1['AC1'])) $postes['AC2']=$postesN1['AC1'];
if (!isset($postes['AE2']) && isset($postesN1['AE1'])) $postes['AE2']=$postesN1['AE1'];
if (!isset($postes['AG2']) && isset($postesN1['AG1'])) $postes['AG2']=$postesN1['AG1'];
if (!isset($postes['AI2']) && isset($postesN1['AI1'])) $postes['AI2']=$postesN1['AI1'];
if (!isset($postes['AK2']) && isset($postesN1['AK1'])) $postes['AK2']=$postesN1['AK1'];
if (!isset($postes['AM2']) && isset($postesN1['AM1'])) $postes['AM2']=$postesN1['AM1'];
if (!isset($postes['AO2']) && isset($postesN1['AO1'])) $postes['AO2']=$postesN1['AO1'];
if (!isset($postes['AQ2']) && isset($postesN1['AQ1'])) $postes['AQ2']=$postesN1['AQ1'];
if (!isset($postes['AS2']) && isset($postesN1['AS1'])) $postes['AS2']=$postesN1['AS1'];
if (!isset($postes['AU2']) && isset($postesN1['AU1'])) $postes['AU2']=$postesN1['AU1'];
if (!isset($postes['AW2']) && isset($postesN1['AW1'])) $postes['AW2']=$postesN1['AW1'];
if (!isset($postes['AY2']) && isset($postesN1['AY1'])) $postes['AY2']=$postesN1['AY1'];
if (!isset($postes['CT2']) && isset($postesN1['CT1'])) $postes['CT2']=$postesN1['CT1'];
if (!isset($postes['CV2']) && isset($postesN1['CV1'])) $postes['CV2']=$postesN1['CV1'];
if (!isset($postes['BC2']) && isset($postesN1['BC1'])) $postes['BC2']=$postesN1['BC1'];
if (!isset($postes['BE2']) && isset($postesN1['BE1'])) $postes['BE2']=$postesN1['BE1'];
if (!isset($postes['BG2']) && isset($postesN1['BG1'])) $postes['BG2']=$postesN1['BG1'];
if (!isset($postes['BI2']) && isset($postesN1['BI1'])) $postes['BI2']=$postesN1['BI1'];
if (!isset($postes['BK2']) && isset($postesN1['BK1'])) $postes['BK2']=$postesN1['BK1'];
if (!isset($postes['BM2']) && isset($postesN1['BM1'])) $postes['BM2']=$postesN1['BM1'];
if (!isset($postes['BO2']) && isset($postesN1['BO1'])) $postes['BO2']=$postesN1['BO1'];
if (!isset($postes['BQ2']) && isset($postesN1['BQ1'])) $postes['BQ2']=$postesN1['BQ1'];
if (!isset($postes['BS2']) && isset($postesN1['BS1'])) $postes['BS2']=$postesN1['BS1'];
if (!isset($postes['BU2']) && isset($postesN1['BU1'])) $postes['BU2']=$postesN1['BU1'];
if (!isset($postes['BW2']) && isset($postesN1['BW1'])) $postes['BW2']=$postesN1['BW1'];
if (!isset($postes['BY2']) && isset($postesN1['BY1'])) $postes['BY2']=$postesN1['BY1'];
if (!isset($postes['CA2']) && isset($postesN1['CA1'])) $postes['CA2']=$postesN1['CA1'];
if (!isset($postes['CC2']) && isset($postesN1['CC1'])) $postes['CC2']=$postesN1['CC1'];
if (!isset($postes['CE2']) && isset($postesN1['CE1'])) $postes['CE2']=$postesN1['CE1'];
if (!isset($postes['CG2']) && isset($postesN1['CG1'])) $postes['CG2']=$postesN1['CG1'];
if (!isset($postes['CI2']) && isset($postesN1['CI1'])) $postes['CI2']=$postesN1['CI1'];
if (!isset($postes['CK2']) && isset($postesN1['CK1'])) $postes['CK2']=$postesN1['CK1'];
if (!isset($postes['CL3']) && isset($postesN1['CL2'])) $postes['CL3']=$postesN1['CL2'];
if (!isset($postes['CM3']) && isset($postesN1['CM2'])) $postes['CM3']=$postesN1['CM2'];
if (!isset($postes['CN3']) && isset($postesN1['CN2'])) $postes['CN3']=$postesN1['CN2'];
if (!isset($postes['1A2']) && isset($postesN1['1A1'])) $postes['1A2']=$postesN1['1A1'];
// Passif
if (!isset($postes['DA1']) && isset($postesN1['DA'])) $postes['DA1']=$postesN1['DA'];
if (!isset($postes['DB1']) && isset($postesN1['DB'])) $postes['DB1']=$postesN1['DB'];
if (!isset($postes['DC1']) && isset($postesN1['DC'])) $postes['DC1']=$postesN1['DC'];
if (!isset($postes['DD1']) && isset($postesN1['DD'])) $postes['DD1']=$postesN1['DD'];
if (!isset($postes['DE1']) && isset($postesN1['DE'])) $postes['DE1']=$postesN1['DE'];
if (!isset($postes['DF1']) && isset($postesN1['DF'])) $postes['DF1']=$postesN1['DF'];
if (!isset($postes['DG1']) && isset($postesN1['DG'])) $postes['DG1']=$postesN1['DG'];
if (!isset($postes['DH1']) && isset($postesN1['DH'])) $postes['DH1']=$postesN1['DH'];
if (!isset($postes['DI1']) && isset($postesN1['DI'])) $postes['DI1']=$postesN1['DI'];
if (!isset($postes['DJ1']) && isset($postesN1['DJ'])) $postes['DJ1']=$postesN1['DJ'];
if (!isset($postes['DK1']) && isset($postesN1['DK'])) $postes['DK1']=$postesN1['DK'];
if (!isset($postes['DL1']) && isset($postesN1['DL'])) $postes['DL1']=$postesN1['DL'];
if (!isset($postes['DM1']) && isset($postesN1['DM'])) $postes['DM1']=$postesN1['DM'];
if (!isset($postes['DN1']) && isset($postesN1['DN'])) $postes['DN1']=$postesN1['DN'];
if (!isset($postes['DO1']) && isset($postesN1['DO'])) $postes['DO1']=$postesN1['DO'];
if (!isset($postes['DP1']) && isset($postesN1['DP'])) $postes['DP1']=$postesN1['DP'];
if (!isset($postes['DQ1']) && isset($postesN1['DQ'])) $postes['DQ1']=$postesN1['DQ'];
if (!isset($postes['DR1']) && isset($postesN1['DR'])) $postes['DR1']=$postesN1['DR'];
if (!isset($postes['DS1']) && isset($postesN1['DS'])) $postes['DS1']=$postesN1['DS'];
if (!isset($postes['DT1']) && isset($postesN1['DT'])) $postes['DT1']=$postesN1['DT'];
if (!isset($postes['DU1']) && isset($postesN1['DU'])) $postes['DU1']=$postesN1['DU'];
if (!isset($postes['DV1']) && isset($postesN1['DV'])) $postes['DV1']=$postesN1['DV'];
if (!isset($postes['DW1']) && isset($postesN1['DW'])) $postes['DW1']=$postesN1['DW'];
if (!isset($postes['DX1']) && isset($postesN1['DX'])) $postes['DX1']=$postesN1['DX'];
if (!isset($postes['DY1']) && isset($postesN1['DY'])) $postes['DY1']=$postesN1['DY'];
if (!isset($postes['DZ1']) && isset($postesN1['DZ'])) $postes['DZ1']=$postesN1['DZ'];
if (!isset($postes['EA1']) && isset($postesN1['EA'])) $postes['EA1']=$postesN1['EA'];
if (!isset($postes['EB1']) && isset($postesN1['EB'])) $postes['EB1']=$postesN1['EB'];
if (!isset($postes['EC1']) && isset($postesN1['EC'])) $postes['EC1']=$postesN1['EC'];
if (!isset($postes['ED1']) && isset($postesN1['ED'])) $postes['ED1']=$postesN1['ED'];
if (!isset($postes['EE1']) && isset($postesN1['EE'])) $postes['EE1']=$postesN1['EE'];
if (!isset($postes['1B1']) && isset($postesN1['1B'])) $postes['1B1']=$postesN1['1B'];
if (!isset($postes['1C1']) && isset($postesN1['1C'])) $postes['1C1']=$postesN1['1C'];
if (!isset($postes['1D1']) && isset($postesN1['1D'])) $postes['1D1']=$postesN1['1D'];
if (!isset($postes['1E1']) && isset($postesN1['1E'])) $postes['1E1']=$postesN1['1E'];
if (!isset($postes['EF1']) && isset($postesN1['EF'])) $postes['EF1']=$postesN1['EF'];
if (!isset($postes['EG1']) && isset($postesN1['EG'])) $postes['EG1']=$postesN1['EG'];
if (!isset($postes['EH1']) && isset($postesN1['EH'])) $postes['EH1']=$postesN1['EH'];
// Compte de Résultats
if (!isset($postes['FC1']) && isset($postesN1['FC'])) $postes['FC1']=$postesN1['FC'];
if (!isset($postes['FF1']) && isset($postesN1['FF'])) $postes['FF1']=$postesN1['FF'];
if (!isset($postes['FI1']) && isset($postesN1['FI'])) $postes['FI1']=$postesN1['FI'];
if (!isset($postes['FL1']) && isset($postesN1['FL'])) $postes['FL1']=$postesN1['FL'];
if (!isset($postes['FM1']) && isset($postesN1['FM'])) $postes['FM1']=$postesN1['FM'];
if (!isset($postes['FN1']) && isset($postesN1['FN'])) $postes['FN1']=$postesN1['FN'];
if (!isset($postes['FO1']) && isset($postesN1['FO'])) $postes['FO1']=$postesN1['FO'];
if (!isset($postes['FP1']) && isset($postesN1['FP'])) $postes['FP1']=$postesN1['FP'];
if (!isset($postes['FQ1']) && isset($postesN1['FQ'])) $postes['FQ1']=$postesN1['FQ'];
if (!isset($postes['FR1']) && isset($postesN1['FR'])) $postes['FR1']=$postesN1['FR'];
if (!isset($postes['FS1']) && isset($postesN1['FS'])) $postes['FS1']=$postesN1['FS'];
if (!isset($postes['FT1']) && isset($postesN1['FT'])) $postes['FT1']=$postesN1['FT'];
if (!isset($postes['FU1']) && isset($postesN1['FU'])) $postes['FU1']=$postesN1['FU'];
if (!isset($postes['FV1']) && isset($postesN1['FV'])) $postes['FV1']=$postesN1['FV'];
if (!isset($postes['FW1']) && isset($postesN1['FW'])) $postes['FW1']=$postesN1['FW'];
if (!isset($postes['FX1']) && isset($postesN1['FX'])) $postes['FX1']=$postesN1['FX'];
if (!isset($postes['FY1']) && isset($postesN1['FY'])) $postes['FY1']=$postesN1['FY'];
if (!isset($postes['FZ1']) && isset($postesN1['FZ'])) $postes['FZ1']=$postesN1['FZ'];
if (!isset($postes['GA1']) && isset($postesN1['GA'])) $postes['GA1']=$postesN1['GA'];
if (!isset($postes['GB1']) && isset($postesN1['GB'])) $postes['GB1']=$postesN1['GB'];
if (!isset($postes['GC1']) && isset($postesN1['GC'])) $postes['GC1']=$postesN1['GC'];
if (!isset($postes['GD1']) && isset($postesN1['GD'])) $postes['GD1']=$postesN1['GD'];
if (!isset($postes['GE1']) && isset($postesN1['GE'])) $postes['GE1']=$postesN1['GE'];
if (!isset($postes['GF1']) && isset($postesN1['GF'])) $postes['GF1']=$postesN1['GF'];
if (!isset($postes['GG1']) && isset($postesN1['GG'])) $postes['GG1']=$postesN1['GG'];
if (!isset($postes['GH1']) && isset($postesN1['GH'])) $postes['GH1']=$postesN1['GH'];
if (!isset($postes['GI1']) && isset($postesN1['GI'])) $postes['GI1']=$postesN1['GI'];
if (!isset($postes['GJ1']) && isset($postesN1['GJ'])) $postes['GJ1']=$postesN1['GJ'];
if (!isset($postes['GK1']) && isset($postesN1['GK'])) $postes['GK1']=$postesN1['GK'];
if (!isset($postes['GL1']) && isset($postesN1['GL'])) $postes['GL1']=$postesN1['GL'];
if (!isset($postes['GM1']) && isset($postesN1['GM'])) $postes['GM1']=$postesN1['GM'];
if (!isset($postes['GN1']) && isset($postesN1['GN'])) $postes['GN1']=$postesN1['GN'];
if (!isset($postes['GO1']) && isset($postesN1['GO'])) $postes['GO1']=$postesN1['GO'];
if (!isset($postes['GP1']) && isset($postesN1['GP'])) $postes['GP1']=$postesN1['GP'];
if (!isset($postes['GQ1']) && isset($postesN1['GQ'])) $postes['GQ1']=$postesN1['GQ'];
if (!isset($postes['GR1']) && isset($postesN1['GR'])) $postes['GR1']=$postesN1['GR'];
if (!isset($postes['GS1']) && isset($postesN1['GS'])) $postes['GS1']=$postesN1['GS'];
if (!isset($postes['GT1']) && isset($postesN1['GT'])) $postes['GT1']=$postesN1['GT'];
if (!isset($postes['GU1']) && isset($postesN1['GU'])) $postes['GU1']=$postesN1['GU'];
if (!isset($postes['GV1']) && isset($postesN1['GV'])) $postes['GV1']=$postesN1['GV'];
if (!isset($postes['GW1']) && isset($postesN1['GW'])) $postes['GW1']=$postesN1['GW'];
if (!isset($postes['HA1']) && isset($postesN1['HA'])) $postes['HA1']=$postesN1['HA'];
if (!isset($postes['HB1']) && isset($postesN1['HB'])) $postes['HB1']=$postesN1['HB'];
if (!isset($postes['HC1']) && isset($postesN1['HC'])) $postes['HC1']=$postesN1['HC'];
if (!isset($postes['HD1']) && isset($postesN1['HD'])) $postes['HD1']=$postesN1['HD'];
if (!isset($postes['HE1']) && isset($postesN1['HE'])) $postes['HE1']=$postesN1['HE'];
if (!isset($postes['HF1']) && isset($postesN1['HF'])) $postes['HF1']=$postesN1['HF'];
if (!isset($postes['HG1']) && isset($postesN1['HG'])) $postes['HG1']=$postesN1['HG'];
if (!isset($postes['HH1']) && isset($postesN1['HH'])) $postes['HH1']=$postesN1['HH'];
if (!isset($postes['HI1']) && isset($postesN1['HI'])) $postes['HI1']=$postesN1['HI'];
if (!isset($postes['HJ1']) && isset($postesN1['HJ'])) $postes['HJ1']=$postesN1['HJ'];
if (!isset($postes['HK1']) && isset($postesN1['HK'])) $postes['HK1']=$postesN1['HK'];
if (!isset($postes['HL1']) && isset($postesN1['HL'])) $postes['HL1']=$postesN1['HL'];
if (!isset($postes['HM1']) && isset($postesN1['HM'])) $postes['HM1']=$postesN1['HM'];
if (!isset($postes['HN1']) && isset($postesN1['HN'])) $postes['HN1']=$postesN1['HN'];
if (!isset($postes['HO1']) && isset($postesN1['HO'])) $postes['HO1']=$postesN1['HO'];
if (!isset($postes['HY1']) && isset($postesN1['HY'])) $postes['HY1']=$postesN1['HY'];
if (!isset($postes['1G1']) && isset($postesN1['1G'])) $postes['1G1']=$postesN1['1G'];
if (!isset($postes['HP1']) && isset($postesN1['HP'])) $postes['HP1']=$postesN1['HP'];
if (!isset($postes['HQ1']) && isset($postesN1['HQ'])) $postes['HQ1']=$postesN1['HQ'];
if (!isset($postes['1H1']) && isset($postesN1['1H'])) $postes['1H1']=$postesN1['1H'];
if (!isset($postes['1J1']) && isset($postesN1['1J'])) $postes['1J1']=$postesN1['1J'];
if (!isset($postes['1K1']) && isset($postesN1['1K'])) $postes['1K1']=$postesN1['1K'];
if (!isset($postes['HX1']) && isset($postesN1['HX'])) $postes['HX1']=$postesN1['HX'];
if (!isset($postes['A11']) && isset($postesN1['A1'])) $postes['A11']=$postesN1['A1'];
if (!isset($postes['A21']) && isset($postesN1['A2'])) $postes['A21']=$postesN1['A2'];
if (!isset($postes['A31']) && isset($postesN1['A3'])) $postes['A31']=$postesN1['A3'];
if (!isset($postes['A41']) && isset($postesN1['A4'])) $postes['A41']=$postesN1['A4'];
} elseif ($type=='S') {
// Calcul des chiffres net N-1 si absent 2033
if (!isset($postesN1['013']) && (isset($postesN1['010'])||isset($postesN1['012'])))$postesN1['013']=$postesN1['010']-$postesN1['012'];
if (!isset($postesN1['017']) && (isset($postesN1['014'])||isset($postesN1['016'])))$postesN1['017']=$postesN1['014']-$postesN1['016'];
if (!isset($postesN1['031']) && (isset($postesN1['028'])||isset($postesN1['030'])))$postesN1['031']=$postesN1['028']-$postesN1['030'];
if (!isset($postesN1['043']) && (isset($postesN1['040'])||isset($postesN1['042'])))$postesN1['043']=$postesN1['040']-$postesN1['042'];
if (!isset($postesN1['049']) && (isset($postesN1['044'])||isset($postesN1['048'])))$postesN1['049']=$postesN1['044']-$postesN1['048'];
if (!isset($postesN1['053']) && (isset($postesN1['050'])||isset($postesN1['052'])))$postesN1['053']=$postesN1['050']-$postesN1['052'];
if (!isset($postesN1['063']) && (isset($postesN1['060'])||isset($postesN1['062'])))$postesN1['063']=$postesN1['060']-$postesN1['062'];
if (!isset($postesN1['067']) && (isset($postesN1['064'])||isset($postesN1['066'])))$postesN1['067']=$postesN1['064']-$postesN1['066'];
if (!isset($postesN1['071']) && (isset($postesN1['068'])||isset($postesN1['070'])))$postesN1['071']=$postesN1['068']-$postesN1['070'];
if (!isset($postesN1['075']) && (isset($postesN1['072'])||isset($postesN1['074'])))$postesN1['075']=$postesN1['072']-$postesN1['074'];
if (!isset($postesN1['083']) && (isset($postesN1['080'])||isset($postesN1['082'])))$postesN1['083']=$postesN1['080']-$postesN1['082'];
if (!isset($postesN1['087']) && (isset($postesN1['084'])||isset($postesN1['086'])))$postesN1['087']=$postesN1['084']-$postesN1['086'];
if (!isset($postesN1['091']) && (isset($postesN1['088'])||isset($postesN1['090'])))$postesN1['091']=$postesN1['088']-$postesN1['090'];
if (!isset($postesN1['095']) && (isset($postesN1['092'])||isset($postesN1['094'])))$postesN1['095']=$postesN1['092']-$postesN1['094'];
if (!isset($postesN1['099']) && (isset($postesN1['096'])||isset($postesN1['098'])))$postesN1['099']=$postesN1['096']-$postesN1['098'];
if (!isset($postesN1['113']) && (isset($postesN1['110'])||isset($postesN1['112'])))$postesN1['113']=$postesN1['110']-$postesN1['112'];
// Récupération des chiffres N-1 si absent du bilan N
// ACTIF 2033
if (!isset($postes['N00']) && isset($postesN1['013'])) $postes['N00']=$postesN1['013'];
if (!isset($postes['N01']) && isset($postesN1['017'])) $postes['N01']=$postesN1['017'];
if (!isset($postes['N02']) && isset($postesN1['031'])) $postes['N02']=$postesN1['031'];
if (!isset($postes['N03']) && isset($postesN1['043'])) $postes['N03']=$postesN1['043'];
if (!isset($postes['N04']) && isset($postesN1['049'])) $postes['N04']=$postesN1['049'];
if (!isset($postes['N05']) && isset($postesN1['053'])) $postes['N05']=$postesN1['053'];
if (!isset($postes['N06']) && isset($postesN1['063'])) $postes['N06']=$postesN1['063'];
if (!isset($postes['N07']) && isset($postesN1['067'])) $postes['N07']=$postesN1['067'];
if (!isset($postes['N08']) && isset($postesN1['071'])) $postes['N08']=$postesN1['071'];
if (!isset($postes['N09']) && isset($postesN1['075'])) $postes['N09']=$postesN1['075'];
if (!isset($postes['N10']) && isset($postesN1['083'])) $postes['N10']=$postesN1['083'];
if (!isset($postes['N11']) && isset($postesN1['087'])) $postes['N11']=$postesN1['087'];
if (!isset($postes['N12']) && isset($postesN1['091'])) $postes['N12']=$postesN1['091'];
if (!isset($postes['N13']) && isset($postesN1['095'])) $postes['N13']=$postesN1['095'];
if (!isset($postes['N14']) && isset($postesN1['099'])) $postes['N14']=$postesN1['099'];
if (!isset($postes['N15']) && isset($postesN1['113'])) $postes['N15']=$postesN1['113'];
// PASSIF 2033
if (!isset($postes['N16']) && isset($postesN1['120'])) $postes['N16']=$postesN1['120'];
if (!isset($postes['N17']) && isset($postesN1['124'])) $postes['N17']=$postesN1['124'];
if (!isset($postes['N18']) && isset($postesN1['126'])) $postes['N18']=$postesN1['126'];
if (!isset($postes['N19']) && isset($postesN1['130'])) $postes['N19']=$postesN1['130'];
if (!isset($postes['N20']) && isset($postesN1['132'])) $postes['N20']=$postesN1['132'];
if (!isset($postes['N21']) && isset($postesN1['134'])) $postes['N21']=$postesN1['134'];
if (!isset($postes['N22']) && isset($postesN1['136'])) $postes['N22']=$postesN1['136'];
if (!isset($postes['N23']) && isset($postesN1['140'])) $postes['N23']=$postesN1['140'];
if (!isset($postes['N24']) && isset($postesN1['142'])) $postes['N24']=$postesN1['142'];
if (!isset($postes['N25']) && isset($postesN1['154'])) $postes['N25']=$postesN1['154'];
if (!isset($postes['N26']) && isset($postesN1['156'])) $postes['N26']=$postesN1['156'];
if (!isset($postes['N27']) && isset($postesN1['164'])) $postes['N27']=$postesN1['164'];
if (!isset($postes['N28']) && isset($postesN1['166'])) $postes['N28']=$postesN1['166'];
if (!isset($postes['N29']) && isset($postesN1['172'])) $postes['N29']=$postesN1['172'];
if (!isset($postes['N30']) && isset($postesN1['174'])) $postes['N30']=$postesN1['174'];
if (!isset($postes['N31']) && isset($postesN1['176'])) $postes['N31']=$postesN1['176'];
if (!isset($postes['N32']) && isset($postesN1['180'])) $postes['N32']=$postesN1['180'];
// COMPTE DE RESULTAT 2033
if (!isset($postes['N33']) && isset($postesN1['210'])) $postes['N33']=$postesN1['210'];
if (!isset($postes['N34']) && isset($postesN1['214'])) $postes['N34']=$postesN1['214'];
if (!isset($postes['N35']) && isset($postesN1['218'])) $postes['N35']=$postesN1['218'];
if (!isset($postes['N36']) && isset($postesN1['222'])) $postes['N36']=$postesN1['222'];
if (!isset($postes['N37']) && isset($postesN1['224'])) $postes['N37']=$postesN1['224'];
if (!isset($postes['N38']) && isset($postesN1['226'])) $postes['N38']=$postesN1['226'];
if (!isset($postes['N39']) && isset($postesN1['230'])) $postes['N39']=$postesN1['230'];
if (!isset($postes['N40']) && isset($postesN1['232'])) $postes['N40']=$postesN1['232'];
if (!isset($postes['N41']) && isset($postesN1['234'])) $postes['N41']=$postesN1['234'];
if (!isset($postes['N42']) && isset($postesN1['236'])) $postes['N42']=$postesN1['236'];
if (!isset($postes['N43']) && isset($postesN1['238'])) $postes['N43']=$postesN1['238'];
if (!isset($postes['N44']) && isset($postesN1['240'])) $postes['N44']=$postesN1['240'];
if (!isset($postes['N45']) && isset($postesN1['242'])) $postes['N45']=$postesN1['242'];
if (!isset($postes['N46']) && isset($postesN1['244'])) $postes['N46']=$postesN1['244'];
if (!isset($postes['N47']) && isset($postesN1['250'])) $postes['N47']=$postesN1['250'];
if (!isset($postes['N48']) && isset($postesN1['252'])) $postes['N48']=$postesN1['252'];
if (!isset($postes['N49']) && isset($postesN1['254'])) $postes['N49']=$postesN1['254'];
if (!isset($postes['N50']) && isset($postesN1['256'])) $postes['N50']=$postesN1['256'];
if (!isset($postes['N51']) && isset($postesN1['262'])) $postes['N51']=$postesN1['262'];
if (!isset($postes['N52']) && isset($postesN1['264'])) $postes['N52']=$postesN1['264'];
if (!isset($postes['N53']) && isset($postesN1['270'])) $postes['N53']=$postesN1['270'];
if (!isset($postes['N54']) && isset($postesN1['280'])) $postes['N54']=$postesN1['280'];
if (!isset($postes['N55']) && isset($postesN1['290'])) $postes['N55']=$postesN1['290'];
if (!isset($postes['N56']) && isset($postesN1['294'])) $postes['N56']=$postesN1['294'];
if (!isset($postes['N57']) && isset($postesN1['300'])) $postes['N57']=$postesN1['300'];
if (!isset($postes['N58']) && isset($postesN1['306'])) $postes['N58']=$postesN1['306'];
if (!isset($postes['N59']) && isset($postesN1['310'])) $postes['N59']=$postesN1['310'];
} elseif ($type=='A' || $type=='B') {
// BANQUES
if (!isset($postes['NA1']) && isset($postesN1['AA1'])) $postes['NA1']=$postesN1['AA1'];
if (!isset($postes['NA2']) && isset($postesN1['AA2'])) $postes['NA2']=$postesN1['AA2'];
if (!isset($postes['NA3']) && isset($postesN1['AA3'])) $postes['NA3']=$postesN1['AA3'];
if (!isset($postes['NP1']) && isset($postesN1['AP1'])) $postes['NP1']=$postesN1['AP1'];
if (!isset($postes['NP2']) && isset($postesN1['AP2'])) $postes['NP2']=$postesN1['AP2'];
if (!isset($postes['NP3']) && isset($postesN1['AP3'])) $postes['NP3']=$postesN1['AP3'];
if (!isset($postes['NP4']) && isset($postesN1['AP4'])) $postes['NP4']=$postesN1['AP4'];
if (!isset($postes['NP5']) && isset($postesN1['AP5'])) $postes['NP5']=$postesN1['AP5'];
if (!isset($postes['NP6']) && isset($postesN1['AP6'])) $postes['NP6']=$postesN1['AP6'];
if (!isset($postes['NP7']) && isset($postesN1['AP7'])) $postes['NP7']=$postesN1['AP7'];
if (!isset($postes['NP8']) && isset($postesN1['AP8'])) $postes['NP8']=$postesN1['AP8'];
if (!isset($postes['NP9']) && isset($postesN1['AP9'])) $postes['NP9']=$postesN1['AP9'];
if (!isset($postes['NR1']) && isset($postesN1['AR1'])) $postes['NR1']=$postesN1['AR1'];
if (!isset($postes['NR2']) && isset($postesN1['AR2'])) $postes['NR2']=$postesN1['AR2'];
if (!isset($postes['NR3']) && isset($postesN1['AR3'])) $postes['NR3']=$postesN1['AR3'];
// ASSURANCE
if (!isset($postes['NR4']) && isset($postesN1['AR4'])) $postes['AR4']=$postesN1['AR4'];
}
} else {
$infos = 'NEW';
2012-09-03 06:39:21 +00:00
}
2013-05-15 18:22:21 +00:00
2012-09-03 06:39:21 +00:00
} else {
$infos = 'NEW';
}
}
$ancres = array(
'C' => array(
'actif' => 'Actif',
'passif' => 'Passif',
2012-09-03 06:39:21 +00:00
'compteDeResultat' => 'Compte de résultat',
//+ Poste YP pour l'effectif du groupe
),
'N' => array(
'actif' => 'Actif',
'passif' => 'Passif',
'compteDeResultat' => 'Compte de résultat',
'immobilisations' => 'Immobilisations',
'amortissements' => 'Amortissements',
'provisions' => 'Provisions',
2012-09-24 08:43:28 +00:00
'creancesDettes' => 'Créances, Dettes',
'resultatfiscal' => 'Détermination du résultat fiscal',
'deficit' => 'DÉFICITS, INDEMNITÉS POUR CONGÉS À PAYER ET PROVISIONS NON DÉDUCTIBLES',
'affectation' => 'Affectation',
'annexe16' => 'DÉTERMINATION DE LA VALEUR AJOUTÉE PRODUITE AU COURS DE L\'EXERCICE',
),
'S' => array(
'actif' => 'Actif',
'passif' => 'Passif',
'compteDeResultat' => 'Compte de résultat',
'immobilisations' => 'Immobilisations',
'amortissements' => 'Amortissements',
'provisions' => 'Provisions',
'creancesDettes' => 'Créances, Dettes',
'affectation' => 'Affectation'
),
'A' => array(
'actif' => 'Actif',
'passif' => 'Passif',
'compteDeResultat' => 'Compte de résultat',
),
'B' => array(
'actif' => 'Actif',
'passif' => 'Passif',
'compteDeResultat' => 'Compte de résultat',
),
2012-05-20 16:31:28 +00:00
);
if (!empty($infos)) {
2012-09-03 06:39:21 +00:00
//Default value
if ( is_string($infos) && $infos == 'NEW' ) {
$dateCloture = (date('Y')-1).'1231';
2012-09-03 06:39:21 +00:00
$dureeMois = '12';
$dateCloturePre = 'AAAAMMJJ';
$dureeMoisPre = '0';
2012-09-03 06:39:21 +00:00
$unite = 'U';
} else {
2013-05-15 18:22:21 +00:00
$dateCloture = ($infos->dateCloture!='') ? $infos->dateCloture : $date;
$dureeMois = ($infos->dureeMois!='') ? $infos->dureeMois : '12';
$dateCloturePre = empty($infos->dateCloturePre) ? 'AAAAMMJJ' : $infos->dateCloturePre ;
$dureeMoisPre = empty($infos->dureeMoisPre) ? '0' : $infos->dureeMoisPre;
2012-09-03 06:39:21 +00:00
$unite = $infos->unite;
$this->view->assign('liasse', $postes);
}
//Formattage date
$dateCloture = substr($dateCloture,6,2).'/'.substr($dateCloture,4,2).'/'.substr($dateCloture,0,4);
$dateCloturePre = substr($dateCloturePre,6,2).'/'.substr($dateCloturePre,4,2).'/'.substr($dateCloturePre,0,4);
2012-09-03 06:39:21 +00:00
$this->view->assign('dateCloture', $dateCloture);
$this->view->assign('dateCloturePre', $dateCloturePre);
$this->view->assign('dureeMois', $dureeMois);
$this->view->assign('dureeMoisPre', $dureeMoisPre);
$this->view->assign('unite', $unite);
$this->view->assign('typeBilan', $type);
2012-09-03 06:39:21 +00:00
$this->view->assign('ancres', $ancres[$type]);
$this->view->inlineScript()->appendFile('/libs/editable/jquery.jeditable.js');
$this->view->assign('infos', $infos);
2013-05-15 18:22:21 +00:00
}
2011-06-23 07:20:15 +00:00
}
/**
* Sauvegarde de la liasse saisie
*/
2012-09-03 06:39:21 +00:00
public function liassesaveAction()
{
$this->_helper->layout()->disableLayout();
2012-09-03 06:39:21 +00:00
//Renvoyer flux json STATUS : OK ou ERR, MESSAGE : TEXTE, POSTE : ARRAY ou vide
$request = $this->getRequest();
$params = $request->getParams();
$dateCloture = substr($params['dateCloture'],6,4).
substr($params['dateCloture'],3,2).
substr($params['dateCloture'],0,2);
$dateCloturePre = substr($params['dateCloturePre'],6,4).
substr($params['dateCloturePre'],3,2).
substr($params['dateCloturePre'],0,2);
$originalDateCloture = substr($params['originalDateCloture'],6,4).
substr($params['originalDateCloture'],3,2).
substr($params['originalDateCloture'],0,2);
$originalTypeBilan = $params['originalTypeBilan'];
$ws = new WsScores();
$response = $ws->setBilan(
$params['siren'],
$originalDateCloture,
$originalTypeBilan,
$params['unite'],
$dateCloture,
$params['dureeMois'],
$dateCloturePre,
$params['dureeMoisPre'],
$params['typeBilan'],
2012-09-21 19:40:45 +00:00
$params['postes'],
$params['step']
);
Zend_Registry::get('firebug')->info($response);
if (is_int($response)) {
$this->view->assign('result', array('status'=>'OK'));
} else {
if ( preg_match_all('/([A-Z0-9]{2,});?/', $response, $postes) ) {
Zend_Registry::get('firebug')->info($postes[1]);
$this->view->assign('result', array(
'status'=>'ERR',
'message'=>'Erreur valeur',
'postes' => $postes[1],
));
} else {
$this->view->assign('result', array(
'status'=>'ERR',
'message'=>$response,
'postes'=>array(),
));
}
}
2012-09-03 06:39:21 +00:00
}
/**
* Affichage du formulaire pour les liens
*/
public function lienAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
2012-12-05 12:59:13 +00:00
$siren = $request->getParam('siren', null);
$mode = $request->getParam('mode');
$type = $request->getParam('type');
$idLien = $request->getParam('idLien', null);
$lienRef = $request->getParam('lienref', null);
$createFiche = $request->getParam('createfiche', null);
$ws = new WsScores();
Zend_Registry::get('firebug')->info('createfiche:'.$createFiche);
$id2 = null;
if ($createFiche) {
//Get identite
$result = $ws->getIdentiteLight($createFiche);
//Compute informations
$infos = array(
'siren' => $result->Siren,
'actif' => 1,
'PpPm' => 'PM',
'RS' => $result->Nom,
'civilite' => '',
'nom' => '',
'prenom' => '',
'nom_usage' => '',
'naissance_date' => '',
'naissance_dept_pays' => '',
'naissance_lieu' => '',
'nat' => '',
'adresse_num' => $result->AdresseNum,
'adresse_btq' => $result->AdresseBtq,
'adresse_codvoie' => $result->AdresseVoie,
'adresse_libvoie' => $result->AdresseRue,
'adresse_comp' => '',
'adresse_cp' => $result->CP,
'adresse_ville' => $result->Ville,
'adresse_pays' => 'FRA',
'dateSaisie' => date('YmdHis'),
'capital' => $result->CapitalDev,
'deviseCapital' => $result->CapitalDev,
'nbActions' => '',
'idLoc1Type' => '',
'idLoc1Num' => '',
'idLoc2Type' => '',
'idLoc2Num' => '',
'idLoc3Type' => '',
'idLoc3Num' => '',
);
$id2 = $ws->setLienRef(json_encode($infos));
if (is_int($id2)) {
Zend_Registry::get('firebug')->info('id2:'.$id2);
$this->view->assign('id2', $id2);
$this->view->assign('id2Nom', $result->Nom);
}
}
if ( $lienRef !== null ) {
Zend_Registry::get('firebug')->info('lienRef:'.$lienRef);
$result = $ws->getLienRef($lienRef);
Zend_Registry::get('firebug')->info($result);
$rs = $result->raisonSociale;
//Override session session
if ( intval($result->siren) != 0 ) {
2012-12-05 12:59:13 +00:00
$siren = $result->siren;
2013-11-21 16:31:49 +00:00
$session = new Scores_Session_Entreprise($siren);
2012-12-05 12:59:13 +00:00
}
} elseif ($siren !== null) {
2013-11-21 16:31:49 +00:00
$session = new Scores_Session_Entreprise($siren);
$rs = $session->getRaisonSociale();
}
$detention = array(
'+' => 'Major.',
'-' => 'Minor.',
'C' => 'Contrôle',
'S' => 'Scission',
'F' => 'Fusion',
'P' => 'Projet de fusion',
'T' => 'TUP',
'L' => 'Tutelle',
'E' => 'Franchise',
2013-12-26 14:42:44 +00:00
'M' => 'Membre',
2012-10-15 09:12:59 +00:00
);
$this->view->assign('detention', $detention);
//Mode = delete
/*
id du lien pour récupérer les informations
- rs1, siren1, rs2, siren2
*/
if ($mode == 'delete') {
2012-10-24 07:57:39 +00:00
$result = $ws->getSaisieLien($idLien);
$infos = json_decode($result, true);
2012-10-24 07:57:39 +00:00
Zend_Registry::get('firebug')->info($infos);
2012-10-24 07:57:39 +00:00
if ($type=='actionnaire') {
$this->view->assign('id1', $infos['idPar']);
$this->view->assign('id2', $infos['idAct']);
2012-10-24 16:10:48 +00:00
$idFiche = $infos['idAct'];
} elseif ($type=='participation') {
2012-10-24 07:57:39 +00:00
$this->view->assign('id2', $infos['idPar']);
$this->view->assign('id1', $infos['idAct']);
2012-10-24 16:10:48 +00:00
$idFiche = $infos['idPar'];
2012-10-24 07:57:39 +00:00
}
2012-10-24 16:10:48 +00:00
if ($idFiche) {
$result = $ws->getLienRef($idFiche);
if ($result->raisonSociale!='') {
$this->view->assign('rs2', $result->raisonSociale);
} else {
$this->view->assign('rs2', $result->nom);
}
$this->view->assign('siren2', $result->siren);
}
2012-10-24 07:57:39 +00:00
$this->view->assign('PDetention', $infos['PDetention']);
$this->view->assign('Pvote', $infos['Pvote']);
$this->view->assign('MajMin', $infos['MajMin']);
$dateEffetLien = new Zend_Date($infos['dateEffetLien'], 'yyyy-MM-dd');
$this->view->assign('dateEffetLien', $dateEffetLien->toString('dd/MM/yyyy'));
}
//Mode = edit / add
/*
id du lien pour récupérer les informations
- siren, rs actuel
- Liste des documents de référence
- Liste des types d'identifiant par pays sdv1.tabIdLocal
*/
elseif ($mode == 'edit') {
$result = $ws->getSaisieLien($idLien);
$infos = json_decode($result, true);
Zend_Registry::get('firebug')->info($infos);
if ($type=='actionnaire') {
$this->view->assign('id1', $infos['idPar']);
$this->view->assign('id2', $infos['idAct']);
2012-10-24 16:10:48 +00:00
} elseif ($type=='participation') {
$this->view->assign('id2', $infos['idPar']);
$this->view->assign('id1', $infos['idAct']);
}
$dateEffetLien = new Zend_Date($infos['dateEffetLien'], 'yyyy-MM-dd');
2013-09-16 15:41:31 +00:00
$doc = ($siren) ? $ws->getLienDoc($siren, 'Siren') : $ws->getLienDoc($lienRef, 'Entreprise');
if ( $doc->item[0]->date ) {
$date = new Zend_Date($doc->item[0]->date, 'yyyy-MM-dd');
$dateEffetLienDoc = $date->toString('dd/MM/yyyy');
} else {
$dateEffetLienDoc = $dateEffetLien->toString('dd/MM/yyyy');
}
$this->view->assign('PDetention', $infos['PDetention']);
$this->view->assign('Pvote', $infos['Pvote']);
$this->view->assign('MajMin', $infos['MajMin']);
$this->view->assign('dateEffetLien', $dateEffetLien->toString('dd/MM/yyyy'));
2013-09-16 15:41:31 +00:00
$this->view->assign('dateEffetLienDoc', $dateEffetLienDoc);
} else {
$date = $request->getParam('date');
if ($date) {
$this->view->assign('dateEffetLien', substr($date,8,2).'/'.substr($date,5,2).'/'.substr($date,0,4));
}
if ( $lienRef ) {
$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' => $result->Siren,
'actif' => 1,
'PpPm' => 'PM',
'RS' => $result->Nom,
'civilite' => '',
'nom' => '',
'prenom' => '',
2012-11-21 09:06:46 +00:00
'nom_usage' => '',
'naissance_date' => '',
'naissance_dept_pays' => '',
'naissance_lieu' => '',
'nat' => '',
'adresse_num' => $result->AdresseNum,
'adresse_btq' => $result->AdresseBtq,
'adresse_codvoie' => $result->AdresseVoie,
'adresse_libvoie' => $result->AdresseRue,
'adresse_comp' => '',
'adresse_cp' => $result->CP,
'adresse_ville' => $result->Ville,
'adresse_pays' => 'FRA',
'dateSaisie' => date('YmdHis'),
'capital' => $result->CapitalDev,
'deviseCapital' => $result->CapitalDev,
'nbActions' => '',
'idLoc1Type' => '',
'idLoc1Num' => '',
'idLoc2Type' => '',
'idLoc2Num' => '',
'idLoc3Type' => '',
'idLoc3Num' => '',
);
$idNewLien = $ws->setLienRef(json_encode($infos));
Zend_Registry::get('firebug')->info('idNewLien:'.$idNewLien);
if ( is_int($idNewLien) ) {
$this->view->assign('id1', $idNewLien);
}
}
$this->view->assign('countries', $this->countries);
}
//Affichage
$this->view->assign('rs', $rs);
$this->view->assign('siren', $siren);
$this->view->assign('mode', $mode);
$this->view->assign('type', $type);
$this->view->assign('idLien', $idLien);
2012-10-15 09:12:59 +00:00
}
2012-10-15 09:12:59 +00:00
public function liensearchAction()
{
$this->_helper->layout()->disableLayout();
$query = $this->getRequest()->getParam('q');
2012-11-22 07:44:55 +00:00
$type = $this->getRequest()->getParam('type', null);
//Some transformation
if ( $type == 'siren' || $type == 'id' ) {
$query = str_replace(array(' ','.','-',','), array('','','',''), $query);
}
2012-10-15 09:12:59 +00:00
$ws = new WsScores();
2012-11-22 07:44:55 +00:00
$result = $ws->searchLienRef($query, $type);
2012-10-15 09:12:59 +00:00
Zend_Registry::get('firebug')->info($result);
$output = array();
if (count($result->item)>0) {
foreach ($result->item as $item) {
$output[] = array(
'value' => $item->id,
'label' => $item->lib,
);
}
}
$this->view->assign('output', $output);
}
/**
* Gestion des liens étrangers
*/
public function lienetrangerAction()
{
2012-11-14 17:21:32 +00:00
$request = $this->getRequest();
$mode = $request->getParam('mode', null);
$this->view->assign('mode', $mode);
2012-11-15 10:15:44 +00:00
Zend_Registry::get('firebug')->info($mode);
2012-11-14 17:21:32 +00:00
if ($mode === null) {
$this->_helper->layout()->disableLayout();
}
2012-12-12 21:19:42 +00:00
$this->view->assign('currencies', $this->currencies);
$this->view->assign('countries', $this->countries);
2012-11-09 11:33:00 +00:00
$this->view->assign('type', $this->getRequest()->getParam('type'));
}
2012-10-15 09:12:59 +00:00
/**
* Gestion des liens personnes physiques
2012-10-15 09:12:59 +00:00
*/
public function lienppAction()
{
$this->_helper->layout()->disableLayout();
$dep = new Application_Model_TabDepartements();
$sql = $dep->select();
$rows = $dep->fetchAll($sql);
if ( count($rows)>0 ) {
foreach ($rows as $item) {
$depListe[] = array(
'num' => $item->numdep,
'lib' => $item->libdep,
);
}
}
$this->view->assign('depListe', $depListe);
$this->view->assign('countries', $this->countries);
2012-10-15 09:12:59 +00:00
}
2012-10-15 09:12:59 +00:00
public function lienrefsaveAction()
{
$this->_helper->layout()->disableLayout();
$params = $this->getRequest()->getParams();
2012-10-15 09:12:59 +00:00
//Construct reference informations
$params['PpPm'] = 'PM';
2012-12-13 16:23:53 +00:00
//Check params
2013-02-20 13:17:09 +00:00
if ( empty($params['nom'])
2012-12-14 07:11:46 +00:00
|| $params['pp']==1 && empty($params['prenom'])
2012-12-13 16:23:53 +00:00
|| empty($params['adresse_pays'])
|| empty($params['adresse_ville']) ) {
2013-02-20 13:17:09 +00:00
$this->view->assign('error', 'Champs non saisi !');
2012-12-13 16:23:53 +00:00
} else {
2012-12-13 16:23:53 +00:00
//Personne Physique
if ($params['pp']==1) {
//Fill data
$params['PpPm'] = 'PP';
2013-01-17 17:07:03 +00:00
$params['RS'] = $params['civilite'].' '.$params['nom'].' '.$params['prenom'].' '.$params['nom_usage'];
2012-12-13 16:23:53 +00:00
//Personne Morale
} elseif (!empty($params['siren'])) {
//Fill data
$params['RS'] = $params['nom'];
$params['civilite'] = '';
$params['nom'] = '';
$params['prenom'] = '';
$params['nom_usage'] = '';
$params['naissance_date'] = '';
$params['naissance_dept_pays'] = '';
$params['naissance_lieu'] = '';
$params['nat'] = '';
} else {
//Fill data
$params['siren'] = '000000000';
$params['RS'] = $params['nom'];
$params['civilite'] = '';
$params['nom'] = '';
$params['prenom'] = '';
$params['nom_usage'] = '';
$params['naissance_date'] = '';
$params['naissance_dept_pays'] = '';
$params['naissance_lieu'] = '';
$params['nat'] = '';
}
2013-11-05 14:45:25 +00:00
if (empty($params['dateCapital'])) {
$dateCapital = '';
} else {
$date = new Zend_Date($params['dateCapital'], 'dd/MM/yyyy');
$dateCapital = $date->toString('yyyyMMdd');
}
if (empty($params['naissance_date'])) {
$dateNaissance = '';
} else {
$date = new Zend_Date($params['naissance_date'], 'dd/MM/yyyy');
$dateNaissance = $date->toString('yyyyMMdd');
}
if (empty($params['dateNbActions'])) {
$dateNbActions = '';
} else {
$date = new Zend_Date($params['dateNbActions'], 'dd/MM/yyyy');
2013-11-29 13:54:52 +00:00
$dateNbActions = $date->toString('yyyyMMdd');
2013-11-05 14:45:25 +00:00
}
if ($params['naissance_dept_pays']=='FRA' && $params['naissance_dept']!='') {
$params['naissance_dept_pays'] = $params['naissance_dept'];
}
2013-11-05 14:45:25 +00:00
2012-12-13 16:23:53 +00:00
$infos = array(
'siren' => preg_replace('/\s+/', '', $params['siren']),
2013-12-26 14:42:44 +00:00
'actif' => (array_key_exists('actif', $params) && $params['actif']==0 ) ? 0 : 1,
2012-12-13 16:23:53 +00:00
'PpPm' => $params['PpPm'],
'RS' => strtoupper(trim($params['RS'])),
2013-12-26 14:42:44 +00:00
'sigle' => empty($params['sigle']) ? '' : trim($params['sigle']),
2012-12-13 16:23:53 +00:00
'civilite' => $params['civilite'],
'nom' => strtoupper(trim($params['nom'])),
'prenom' => ucfirst(trim($params['prenom'])),
'nom_usage' => strtoupper(trim($params['nom_usage'])),
2013-11-05 14:45:25 +00:00
'naissance_date' => $dateNaissance,
2012-12-13 16:23:53 +00:00
'naissance_dept_pays' => $params['naissance_dept_pays'],
'naissance_lieu' => $params['naissance_lieu'],
'nat' => $params['nat'],
'adresse_num' => empty($params['adresse_num']) ? '' : trim($params['adresse_num']),
'adresse_btq' => empty($params['adresse_btq']) ? '' : trim($params['adresse_btq']),
'adresse_codvoie' => empty($params['adresse_codvoie']) ? '' : strtoupper(trim($params['adresse_codvoie'])),
'adresse_libvoie' => empty($params['adresse_libvoie']) ? '' : strtoupper(trim($params['adresse_libvoie'])),
'adresse_comp' => empty($params['adresse_comp']) ? '' : strtoupper(trim($params['adresse_comp'])),
'adresse_cp' => empty($params['adresse_cp']) ? '' : trim($params['adresse_cp']),
'adresse_ville' => empty($params['adresse_ville']) ? '' : trim($params['adresse_ville']),
'adresse_pays' => empty($params['adresse_pays']) ? '' : trim($params['adresse_pays']),
'tel' => empty($params['tel']) ? '' : trim($params['tel']),
'fax' => empty($params['fax']) ? '' : trim($params['fax']),
'web' => empty($params['web']) ? '' : trim($params['web']),
'email' => empty($params['email']) ? '' : trim($params['email']),
'dateSaisie' => date('YmdHis'),
'capital' => empty($params['capital']) ? '' : trim($params['capital']),
'deviseCapital' => empty($params['deviseCapital']) ? 'EUR' : $params['deviseCapital'],
2013-11-05 14:45:25 +00:00
'dateCapital' => $dateCapital,
2012-12-13 16:23:53 +00:00
'nbActions' => empty($params['nbActions']) ? '' : $params['nbActions'],
2013-11-05 14:45:25 +00:00
'dateNbActions' => $dateNbActions,
'isin' => empty($params['isin']) ? '' : trim($params['isin']),
2012-12-13 16:23:53 +00:00
'idLoc1Type' => $params['idLoc1Type'],
'idLoc1Num' => trim($params['idLoc1Num']),
'idLoc2Type' => $params['idLoc2Type'],
'idLoc2Num' => trim($params['idLoc2Num']),
'idLoc3Type' => $params['idLoc3Type'],
'idLoc3Num' => trim($params['idLoc3Num']),
'bilMillesime' => $params['bilMillesime'],
'bilDev' => empty($params['bilDev']) ? 'EUR' : $params['bilDev'],
'bilFL' => $params['bilFL'],
'bilHN' => $params['bilHN'],
'bilFPr' => $params['bilFPr'],
'bilEE' => $params['bilEE'],
);
2012-12-13 16:23:53 +00:00
Zend_Registry::get('firebug')->info($params);
2012-12-13 16:23:53 +00:00
$ws = new WsScores();
$idNewLien = $ws->setLienRef(json_encode($infos), $params['idLien']);
2013-02-20 13:17:09 +00:00
$this->view->assign('idNewLien', $idNewLien);
$rs = empty($infos['RS']) ? $infos['nom'] : $infos['RS'];
$this->view->assign('RS', $rs);
2013-02-20 15:39:35 +00:00
$this->view->assign('error', '');
if (!is_int($idNewLien) || $idNewLien==0){
2013-02-20 13:17:09 +00:00
$this->view->assign('error', $idNewLien);
2012-12-13 16:23:53 +00:00
}
2012-10-15 09:12:59 +00:00
}
}
/**
* Sauvegarde
*/
public function liensaveAction()
{
$this->_helper->layout()->disableLayout();
2012-10-15 09:12:59 +00:00
$params = $this->getRequest()->getParams();
$ws = new WsScores();
2012-10-24 16:10:48 +00:00
if ($params['mode']=='delete') {
2013-11-05 14:45:25 +00:00
if (empty($params['dateEffetLien'])) {
$dateEffetLien = '';
} else {
$date = new Zend_Date($params['dateEffetLien'], 'dd/MM/yyyy');
$dateEffetLien = $date->toString('yyyyMMdd');
}
2012-10-24 16:10:48 +00:00
$infos = array(
'actif' => 0,
2013-11-05 14:45:25 +00:00
'dateEffetLien' => $dateEffetLien,
2012-10-24 16:10:48 +00:00
'motifUpdate' => empty($params['motifUpdate']) ? '' : $params['motifUpdate'],
);
} else {
if ($params['type']=='actionnaire') {
$idAct = $params['id2'];
$idPar = $params['id1'];
} elseif ($params['type']=='participation') {
$idPar = $params['id2'];
$idAct = $params['id1'];
}
2013-11-05 14:45:25 +00:00
if (empty($params['dateEffetLien'])) {
$date = new Zend_Date();
} else {
$date = new Zend_Date($params['dateEffetLien'], 'dd/MM/yyyy');
}
2012-10-24 16:10:48 +00:00
$infos = array(
'idAct' => $idAct,
'actif' => 1,
'PDetention' => $params['PDetention'],
2012-11-13 16:49:58 +00:00
'Pvote' => ($params['Pvote']=='') ? null : $params['Pvote'],
2012-10-24 16:10:48 +00:00
'MajMin' => $params['MajMin'],
'idPar' => $idPar,
2013-11-05 14:45:25 +00:00
'dateEffetLien' => $date->toString('yyyyMMdd'),
2012-10-24 16:10:48 +00:00
'motifUpdate' => empty($params['motifUpdate']) ? '' : $params['motifUpdate'],
);
if($params['transfer'] && ($params['MajMin'] == 'T' || $params['MajMin'] == 'F'))
{
$liens = $ws->getLiensById($idPar);
$participations = $liens->participations->item;
if (count($participations)>0) {
$ws->setLienChange('tupfusion', $idPar, $idAct);
}
}
2012-10-24 16:10:48 +00:00
}
Zend_Registry::get('firebug')->info($infos);
$idNewLien = $ws->setLien(json_encode($infos), $params['idLien']);
if (!is_int($idNewLien)){
$this->view->assign('error', $idNewLien);
2012-10-15 09:12:59 +00:00
} else {
$this->view->assign('id', $idNewLien);
$this->view->assign('mode', $params['mode']);
2012-10-15 09:12:59 +00:00
}
}
public function liendocAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
2012-11-21 09:06:46 +00:00
$mode = $request->getParam('mode');
if ($mode == 'delete') {
$this->view->assign('mode', $mode);
$id = $request->getParam('id');
$this->view->assign('idNum', $id);
2012-11-21 09:06:46 +00:00
//Get Infos
2012-11-09 11:33:00 +00:00
$ws = new WsScores();
2012-11-21 09:06:46 +00:00
$docs = $ws->getLienDoc($id);
if (count($docs->item)==1) {
$this->view->assign('doc', $docs->item[0]);
}
2012-11-21 09:06:46 +00:00
} else {
$siren = $request->getParam('siren', null);
$idLien = $request->getParam('idLien', null);
$type = $request->getParam('type', null);
$this->view->assign('idType', $type);
2012-11-21 09:06:46 +00:00
if ($siren===null) {
$this->view->assign('idNum', $idLien);
} else {
$ws = new WsScores();
$identite = $ws->getIdentite($siren);
2013-11-05 14:45:25 +00:00
if (empty($identite->Bilan->Cloture)) {
$dateCapital = '';
} else {
$date = new Zend_Date($identite->Bilan->Cloture, 'yyyyMMdd');
$dateCapital = $date->toString('dd/MM/yyyy');
}
2012-11-21 09:06:46 +00:00
$infos = array(
'siren' => $siren,
'actif' => 1,
'PpPm' => 'PP',
'RS' => $identite->Nom,
'civilite' => '',
'nom' => '',
'prenom' => '',
'nom_usage' => '',
'naissance_date' => '',
'naissance_dept_pays' => '',
'naissance_lieu' => '',
'nat' => '',
'adresse_num' => $identite->AdresseNum,
'adresse_btq' => $identite->AdresseBtq,
'adresse_codvoie' => $identite->AdresseVoie,
2013-11-29 13:54:52 +00:00
'adresse_libvoie' => $identite->AdresseRue,
2012-11-21 09:06:46 +00:00
'adresse_comp' => $identite->Adresse2,
'adresse_cp' => $identite->CP,
'adresse_ville' => $identite->Ville,
'adresse_pays' => 'FRA',
'dateSaisie' => date('YmdHis'),
'capital' => $identite->Bilan->Capital,
'deviseCapital' => 'EUR',
2013-11-05 14:45:25 +00:00
'dateCapital' => $dateCapital,
2012-11-21 09:06:46 +00:00
'nbActions' => '',
'idLoc1Type' => '',
'idLoc1Num' => '',
'idLoc2Type' => '',
'idLoc2Num' => '',
'idLoc3Type' => '',
'idLoc3Num' => '',
'bilMillesime' => $identite->Bilan->Millesime,
'bilDev' => 'EUR',
'bilFL' => $identite->Bilan->CA,
'bilHN' => $identite->Bilan->Resultat,
'bilFPr' => '',
'bilEE' => '',
);
$idNum = $ws->setLienRef(json_encode($infos));
$this->view->assign('idNum', $idNum);
}
}
}
public function liendocsaveAction()
{
$this->_helper->layout()->disableLayout();
2012-11-07 17:21:39 +00:00
$this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest();
$params = $request->getParams();
2012-11-07 17:21:39 +00:00
if (empty($params['idNum'])) {
echo "Erreur";
}
2012-11-21 09:06:46 +00:00
//
elseif ($params['mode']=='delete') {
$ws = new WsScores();
$result = $ws->setLienDoc(json_encode(array()), $params['idNum']);
if ($result) {
echo "Fichier supprimé";
} else {
echo "Erreur lors de la suppression";
}
}
//Téléchargement du fichier
2012-11-07 17:21:39 +00:00
elseif ( isset($_FILES) && count($_FILES)==1 )
{
2012-11-16 08:48:05 +00:00
$c = Zend_Registry::get('config');
$path = realpath($c->profil->path->data).'/groupes';
2012-11-07 17:21:39 +00:00
if (!file_exists($path)) { mkdir($path); }
$date = new Zend_Date($params['fileDate'],'dd/MM/yyyy');
$name = 'INTERNE-'.$params['idNum'].'-'.$params['fileType'].'-'.$date->toString('yyyyMMdd');
$n = $_FILES['fichier']['name'];
$s = $_FILES['fichier']['size'];
$tmp_name = $_FILES['fichier']['tmp_name'];
$extValide = array('pdf');
$extension = strrchr($n,'.');
$extension = substr($extension,1);
//Vérifier l'extension du fichier
if( !in_array($extension, $extValide) ){
echo "Extension de fichier incorrect !";
} elseif ( move_uploaded_file($tmp_name, $path.'/'.$name.'.'.$extension) ){
$result = false;
//Send info to webservice
$infos = array(
'idType' => $params['idType'],
'idNum' => $params['idNum'],
2012-11-09 11:33:00 +00:00
'periDoc' => $params['periDoc'],
'docRef' => $name,
'dateDocRef' => $date->toString('yyyyMMdd'),
);
$ws = new WsScores();
2012-11-09 11:33:00 +00:00
$result = $ws->setLienDoc(json_encode($infos));
//Display message
if ($result) {
echo "Fichier envoyé";
} else {
//Delete file
2012-11-07 17:21:39 +00:00
unlink($path.'/'.$name.'.'.$extension);
echo "Erreur lors de l'enregistrement des informations !";
}
} else {
echo "Erreur lors du déplacement du fichier !";
}
}
2012-11-07 17:21:39 +00:00
//Greffe
else {
echo "Greffe";
}
}
public function countryidAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
$code = $request->getParam('code');
$ws = new WsScores();
$result = $ws->getCountryId($code);
$this->view->assign('identifiant', $result->item);
}
2012-10-24 16:10:48 +00:00
public function bourseAction()
{
$request = $this->getRequest();
$siret = $request->getParam('siret');
$id = $request->getParam('id', 0);
2012-10-24 16:10:48 +00:00
$this->view->headTitle()->append('Saisie - '.$siret);
2013-11-21 16:31:49 +00:00
$session = new Scores_Session_Entreprise($siret, $id);
$isin = $session->getIsin();
2012-10-24 16:10:48 +00:00
$ws = new WsScores();
$result = $ws->getSaisieBourse($isin);
$infos = json_decode($result, true);
$dateFields = array(
'dateIntroduction',
'dateIntroYmd',
'dateRadiation',
'dateNbTitres',
'dateDerAG');
if ( $infos === null ) {
$this->view->assign('error', $result);
} else {
foreach ( $infos as $key => $val ) {
if(in_array($key, $dateFields))
{
if ($val=="0000-00-00") {
$val = "";
} else {
$date = new Zend_Date($val, 'yyyy-MM-dd');
$val = $date->toString('dd/MM/yyyy');
}
}
$this->view->assign($key, $val);
}
}
$this->view->assign('raisonSociale', $session->getRaisonSociale());
$this->view->assign('siren', $session->getSiren());
2012-10-24 16:10:48 +00:00
}
2012-10-24 16:10:48 +00:00
public function boursesaveAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
if ( $request->isPost() ){
$infos = $request->getParams();
$dateFields = array(
'dateIntroduction',
'dateIntroYmd',
'dateRadiation',
'dateNbTitres',
'dateDerAG');
foreach($dateFields as $dateField)
{
if ($infos[$dateField] != '') {
$date = new Zend_Date($infos[$dateField], 'dd/MM/yyyy');
$infos[$dateField] = $date->toString('yyyy-MM-dd');
}
}
$filtre = array('controller'=>'', 'action'=>'', 'module'=>'', 'id'=>'', 'submit'=>'', 'dateIntroYmd'=>'');
$infos = array_diff_key($infos, $filtre);
$ws = new WsScores();
$result = $ws->setBourse($infos['code_isin'], json_encode($infos));
$this->view->assign('message', $result);
}
2012-10-24 16:10:48 +00:00
}
public function lienidentiteAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
2012-11-09 11:33:00 +00:00
$this->view->assign('type', $request->getParam('type'));
$siren = $request->getParam('siren');
$ws = new WsScores();
2012-11-09 11:33:00 +00:00
$result = $ws->getIdentite($siren);
2012-11-14 20:44:24 +00:00
Zend_Registry::get('firebug')->info($result);
$this->view->assign('nom',$result->Nom);
2013-12-26 14:42:44 +00:00
$this->view->assign('sigle',$result->sigle);
$this->view->assign('adresse_num',$result->AdresseNum);
$this->view->assign('adresse_btq',$result->AdresseBtq);
$this->view->assign('adresse_codvoie',$result->AdresseVoie);
$this->view->assign('adresse_libvoie',$result->AdresseRue);
$this->view->assign('adresse_comp',$result->Adresse2);
$this->view->assign('adresse_cp',$result->CP);
$this->view->assign('adresse_ville',$result->Ville);
2014-02-25 16:58:40 +00:00
$this->view->assign('adresse_pays',$result->Pays);
2013-11-29 13:54:52 +00:00
$this->view->assign('actif',$result->Actif);
2012-11-09 11:33:00 +00:00
$this->view->assign('tel',$result->Tel);
$this->view->assign('fax',$result->Fax);
$this->view->assign('web',$result->Web);
$this->view->assign('mail',$result->Mail);
$this->view->assign('cj',$result->FJ);
$this->view->assign('ape',$result->NafEnt);
$this->view->assign('capital',$result->Bilan->Capital);
$this->view->assign('deviseCapital', 'EUR');
2013-11-05 14:45:25 +00:00
$date = new Zend_Date($result->Bilan->Cloture, 'yyyyMMdd');
$this->view->assign('dateCapital', $date->toString('dd/MM/yyyy'));
$this->view->assign('bilDev', 'EUR');
2012-11-09 11:33:00 +00:00
$this->view->assign('bilMillesime', $result->Bilan->Millesime);
$this->view->assign('bilFL', $result->Bilan->CA);
$this->view->assign('bilHN', $result->Bilan->Resultat);
2012-12-14 14:50:27 +00:00
$this->view->assign('currencies', $this->currencies);
//Special legal form, go to other display
if ( ($result->FJ>=1000 && $result->FJ<=1999) || ($result->FJ>=10 && $result->FJ<=19) ) {
$this->view->assign('countries', $this->countries);
$this->renderScript('saisie/lienpp.phtml');
}
}
public function lienficheAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
2013-01-09 08:27:44 +00:00
$id = $request->getParam('idFiche', null);
$ws = new WsScores();
if ( $id===null ) {
2013-01-09 08:27:44 +00:00
$siren = $request->getParam('siren');
$result = $ws->searchLienRef($siren, 'siren');
if (count($result->item)>0) {
foreach ($result->item as $item) {
$id = $item->id;
break;
}
}
}
if ( $id!==null ) {
$this->view->assign('edit', $id);
$this->view->assign('currencies', $this->currencies);
$this->view->assign('countries', $this->countries);
$result = $ws->getSaisieLienRef($id);
if ( $result!==false ) {
$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 {
$dep = new Application_Model_TabDepartements();
$sql = $dep->select();
$rows = $dep->fetchAll($sql);
if ( count($rows)>0 ) {
foreach ($rows as $item) {
$depListe[] = array(
'num' => $item->numdep,
'lib' => $item->libdep,
);
if ($item->numdep == $items['naissance_dept_pays']) {
$this->view->assign('naissance_dept_pays', 'FRA');
$this->view->assign('naissance_dept', $item->numdep);
}
}
}
$this->view->assign('depListe', $depListe);
$this->view->assign('nom', $items['nom']);
}
}
}
}
}
2012-12-13 16:23:53 +00:00
public function lienchangeAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
$mode = $request->getParam('mode');
$this->view->assign('mode', $mode);
2012-12-13 16:23:53 +00:00
$lienref = $request->getParam('lienref');
$this->view->assign('lienref', $lienref);
$idLien = $request->getParam('idLien');
$this->view->assign('idLien', $idLien);
$ws = new WsScores();
2013-01-17 17:07:03 +00:00
//Save data
if ( $request->isPost() ){
$id = $request->getParam('id');
if ($id) $result = $ws->setLienChange($mode, $idLien, $id);
if (true === $result) {
$this->view->assign('message', 'Déplacement effectué.');
} else {
$this->view->assign('message', 'Erreur : '.$result);
}
2012-12-13 16:23:53 +00:00
} else {
2013-01-17 17:07:03 +00:00
$this->view->assign('countries', $this->countries);
//Obtain LienRef
$result = $ws->getSaisieLienRef($lienref);
$infos = json_decode($result,true);
if ($infos['PpPm']=='PM') {
$this->view->assign('nom', $infos['RS']);
} else {
$this->view->assign('nom', $infos['nom'].' '.$infos['prenom']);
}
2012-12-13 16:23:53 +00:00
}
2012-12-13 16:23:53 +00:00
}
2013-12-26 14:42:44 +00:00
public function liendeleteAction()
{
$this->_helper->layout()->disableLayout();
2013-12-26 14:42:44 +00:00
$request = $this->getRequest();
$id = $request->getParam('idFiche', null);
$infos = array ('delete' => '1');
2013-12-26 14:42:44 +00:00
$ws = new WsScores();
2013-12-26 14:42:44 +00:00
if ($id===null) {
$siren = $request->getParam('siren');
2013-12-26 14:42:44 +00:00
$result = $ws->searchLienRef($siren, 'siren');
if (count($result->item)>0) {
foreach ($result->item as $item) {
$id = $item->id;
break;
}
}
}
2013-12-26 14:42:44 +00:00
if ( $request->isPost() ) {
if ($id == null) {
$message = 'Fiche n\'est pas trouvée';
} else {
$checkLiens = $ws->getLiensById($id);
if ($checkLiens->actionnaires->item || $checkLiens->participations->item || $checkLiens->directions->item) {
$message = 'Presence des liens';
} else {
$result = $ws->setLienRef(json_encode($infos), $id);
$message = ($result == 1)?'Fiche supprimée':'Erreur de suppression';
}
Zend_Registry::get('firebug')->info($checkLiens->participations->item);
$this->view->assign('message', $message);
}
} else {
$this->view->assign('id', $id);
}
}
public function scorecutoffAction()
{
2013-06-06 12:01:45 +00:00
$ws = new WsScores();
$user = new Scores_Utilisateur();
$request = $this->getRequest();
$siren = $request->getParam('siren');
2013-08-12 12:08:03 +00:00
$message = '';
$getcutoff = null;
if ( $request->isXmlHttpRequest() ) {
$this->_helper->layout()->disableLayout();
$params = $request->getParams();
$mode = $request->getParam('mode');
//Confirm delete
if ( $mode == 'todelete' ) {
$this->view->assign('mode', 'todelete');
$this->view->assign('siren', $params['siren']);
$this->view->assign('encours', $params['encours']);
$this->view->assign('scoreSolv', $params['scoreSolv']);
$this->view->assign('scoreDir', $params['scoreDir']);
$this->view->assign('scoreConf', $params['scoreConf']);
$this->view->assign('remarque', $params['remarque']);
$this->view->assign('paiement', $params['paiement']);
}
//Delete
elseif ($mode == 'delete') {
$this->view->assign('mode', 'delete');
$message = $ws->setScoreCutoff(
$params['siren'],
$params['encours']*1000,
$params['scoreSolv'],
$params['scoreDir'],
$params['scoreConf'],
$params['remarque'],
$params['paiement'],
1
);
if (is_int($message)){
$message = "Cut-off est supprimé.";
} else {
$message = "Erreur lors de la suppression du cut-off (".$message.").";
}
}
//Add or Edit cutoff
else {
if ( $request->isPost() ) {
// check values one more time
$paramlist = array(
'siren' => 'Siren',
'encours' => 'Encours',
'scoreSolv' => 'Indiscore',
'scoreDir' => 'Score dirigeance',
'scoreConf' => 'Score de conformité',
'remarque' => 'Remarque',
'paiement' => 'Information de paiement',
);
foreach ($paramlist as $item => $val) {
if ( !isset($params[$item]) ) {
$message .= "Valeur $val vide !<br/>";
}
if ( $params['encours']<0 || $params['encours']>500 ) {
$message = "Encours : Erreur borne";
}
}
// end checking values
if ( $message == '' ) {
$message = $ws->setScoreCutoff(
$params['siren'],
$params['encours']*1000,
$params['scoreSolv'],
$params['scoreDir'],
$params['scoreConf'],
$params['remarque'],
$params['paiement'],
$params['delete']
);
if (is_int($message)){
$message = "Cut-off mis à jour.";
$this->view->assign('mode', 'added');
} else {
$message = "Erreur lors de la mise à jour (".$message.").";
}
}
}
2013-09-23 08:47:30 +00:00
$getcutoff = json_decode($ws->getScoreCutoff($siren), true);
if( !$getcutoff ) {
if ( $message == '' ) {
$message = "Aucun Cut-off, merci de remplir toutes les valeurs";
}
$getcutoff = array(
'siren' => '',
'encours' => '',
'scoreSolv' => '',
'scoreDir' => '',
'scoreConf' => '',
'remarque' => '',
'paiement' => '',
'dateInsert' => '',
'dateUpdate' => ''
);
2013-08-12 12:08:03 +00:00
}
}
}
//Display link
else {
$this->view->assign('name', "Définir un Cut-off");
$this->view->assign('href', $this->view->url(array(
'controller'=>'saisie','action'=>'scorecutoff','siren'=>$siren
) , 'default', true));
2013-06-07 16:07:50 +00:00
}
2013-06-07 16:07:50 +00:00
$this->view->assign('getcutoff', $getcutoff);
$this->view->assign('siren', $siren);
$this->view->assign('typescore', $user->getTypeScore());
$this->view->assign('message', $message);
2013-07-30 08:58:23 +00:00
}
2013-11-21 16:31:49 +00:00
public function citysearchAction()
{
$this->_helper->layout()->disableLayout();
2013-11-29 13:54:52 +00:00
$cpVille = $this->getRequest()->getParam('cpville', null);
2013-11-21 16:31:49 +00:00
$output = array();
2013-11-29 13:54:52 +00:00
if ( null !== $cpVille) {
$city = new Application_Model_City();
$sql = $city->select('code, libelle');
if (is_numeric($cpVille) && strlen($cpVille)<6) {
$sql->where("code LIKE '".$cpVille."%'");
} else {
$sql->where('libelle LIKE ?', "%$cpVille%");
2013-12-26 14:42:44 +00:00
}
$sql->limit(20);
2013-11-21 16:31:49 +00:00
$rows = $city->fetchAll($sql);
if ( count($rows)>0 ) {
foreach ($rows as $item) {
$output[] = array(
2013-11-29 13:54:52 +00:00
'label' => str_pad($item->code, 5, 0, STR_PAD_LEFT).": ".$item->libelle,
'value' => str_pad($item->code, 5, 0, STR_PAD_LEFT),
2013-11-21 16:31:49 +00:00
);
}
}
2013-12-26 14:42:44 +00:00
}
2013-11-21 16:31:49 +00:00
$this->view->assign('output', $output);
}
2014-03-14 10:42:09 +00:00
public function codvoieAction()
{
$this->_helper->layout()->disableLayout();
2014-03-14 10:42:09 +00:00
$codvoie = $this->getRequest()->getParam('codvoie', null);
$output = array();
if ( null !== $codvoie) {
foreach($this->codVoie as $key=>$val){
if (stripos($key, $codvoie)!==false || stripos($val, $codvoie)!==false){
$output[] = array(
'label' => $key.": ".$val,
'value' => $key
);
}
}
}
$this->view->assign('output', $output);
}
2013-12-26 14:42:44 +00:00
/**
* Ajouter, modifier ou supprimer des dirigeants oppérationnels
*/
public function diropcontrolAction()
{
$this->_helper->layout()->disableLayout();
$request = $this->getRequest();
$mode = $request->getParam('mode');
$id = $request->getParam('id', null);
$siret = $request->getParam('siret');
$siren = substr($siret, 0, 9);
$nic = substr($siret, 9, 5);
$ws = new WsScores();
switch ($mode) {
case 'add':
$fonction = $this->fctDir();
$this->view->assign('fonction', $fonction);
break;
case 'edit':
$fonction = $this->fctDir();
$infos = $ws->getDirigeantsOp($siren, $id);
$this->view->assign('fonction', $fonction);
$this->view->assign('infos', $infos->item[0]);
break;
}
$this->view->assign('mode', $mode);
$this->view->assign('id', $id);
$this->view->assign('siren', $siren);
$this->view->assign('nic', $nic);
}
/**
* Sauvegarder les modifications des dirigeants oppérationnels
*/
public function diropsaveAction()
{
$this->_helper->layout()->disableLayout();
$params = $this->getRequest()->getParams();
$message = '';
$newDate = '0000-00-00';
if (trim($params['naiss_date']) != '') {
$date = new Zend_Date($params['naiss_date'], 'dd/MM/yyyy');
$newDate = $date->toString('yyyy-MM-dd');
}
$infos = array(
2014-11-26 16:45:13 +00:00
'siren' => $params['siren'],
'nic' => $params['nic'],
'civilite' => $params['civilite'],
'nom' => $params['nom'],
'prenom' => $params['prenom'],
'nom_usage' => $params['nom_usage'],
'dateNais' => $newDate,
'lieuNais' => $params['naiss_lieu'],
'codFct' => str_pad($params['codFct'], 4, 0, STR_PAD_LEFT),
'tel' => $params['tel'],
'fax' => $params['fax'],
'email' => $params['email']
);
$ws = new WsScores();
if($params['mode'] == 'add'){
$message = $this->view->translate('Ajout');
} else if ($params['mode'] == 'edit') {
$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!');
} else if ($result===0) {
$message = $message.' '.$this->view->translate('n\'a pas été réussi!');
} else {
$message = $result;
}
$this->view->assign('message', $message);
}
2014-11-26 16:45:13 +00:00
/**
2013-12-26 14:42:44 +00:00
* Edit contact information
*/
public function contactAction()
{
$request = $this->getRequest();
if ( $request->isXmlHttpRequest() ) {
$this->_helper->layout()->disableLayout();
$id = $request->getParam('id');
$this->view->assign('id', $id);
2013-12-26 14:42:44 +00:00
if ( $request->isPost() ) {
$this->view->assign('post', true);
$params = $request->getParams();
2013-12-26 14:42:44 +00:00
$message = '';
$mode = $request->getParam('mode');
if( $mode == 'delete' ) {
$ws = new WsScores();
$result = $ws->setSaisieContactEt($params['siret'], '', '', '', $id, true);
if ( is_string($result) ) {
$this->view->assign('msg', $result);
}
} else {
2014-05-03 15:36:25 +00:00
// Check values
2013-12-26 14:42:44 +00:00
$paramlist = array(
'siret' => 'SIRET',
'type' => 'Type',
'value' => 'Valeur',
2013-12-26 14:42:44 +00:00
);
foreach ($paramlist as $item => $val) {
if (!isset($params[$item])) {
$message .= "Valeur $val vide !<br/>";
}
}
2014-05-03 15:36:25 +00:00
// End checking values
$id = null;
if ( array_key_exists('id', $params) && !empty($params['id'])) {
$id = $params['id'];
}
2013-12-26 14:42:44 +00:00
if ($message == '') {
//setContactEt
$ws = new WsScores();
2014-05-03 15:36:25 +00:00
$result = $ws->setSaisieContactEt($params['siret'], $params['type'], $params['value'], $params['info'], $id);
2013-12-26 14:42:44 +00:00
if ( is_string($result) ) {
$this->view->assign('msg', $result);
}
} else {
$this->view->assign('msg', $message);
}
}
} else {
$mode = $request->getParam('mode');
$this->view->assign('mode', $mode);
2013-12-26 14:42:44 +00:00
$siret = $request->getParam('siret');
$this->view->assign('siret', $siret);
if ( $mode=='delete' ) {
2013-12-26 14:42:44 +00:00
$this->view->assign('mode', 'delete');
} else {
if ( $id !== null ) {
$ws = new WsScores();
$result = $ws->getSaisieContactEt($id);
$data = json_decode($result, true);
2013-12-26 14:42:44 +00:00
Zend_Registry::get('firebug')->info($data);
$this->view->assign('id', $data['id']);
$this->view->assign('siret', str_pad($data['siren'],9,'0',STR_PAD_LEFT).str_pad($data['nic'],5,'0',STR_PAD_LEFT));
$this->view->assign('type', $data['typeTel']);
if ($data['typeTel']=='tel' || $data['typeTel']=='fax' ) {
$this->view->assign('value', str_pad($data['telephone'],10,'0',STR_PAD_LEFT));
$this->view->assign('info', $data['infoTel']);
2013-12-26 14:42:44 +00:00
} else {
$this->view->assign('value', $data->infoTel);
}
$tabChange = array();
if ( $data->idUtilisateur != 0 ) {
$change = new stdClass();
$change->UserId = $data['idUtilisateur'];
$change->UserName = $data['idUtilisateurName'];
$change->Date = $data['dateInsert'];
$change->Type = 'add';
$tabChange[] = $change;
}
if ( $data->idUpdate != 0 ) {
$change = new stdClass();
$change->UserId = $data['idUpdate'];
$change->UserName = $data['idUpdateName'];
$change->Date = $data['dateUpdate'];
$change->Type = 'edit';
$tabChange[] = $change;
}
if ( $data->idSuppr != 0 ) {
$change = new stdClass();
$change->UserId = $data['idSuppr'];
$change->UserName = $data['idSupprName'];
$change->Date = $data['dateSuppr'];
$change->Type = 'del';
$tabChange[] = $change;
}
$this->view->Modif = $tabChange;
2013-12-26 14:42:44 +00:00
}
$this->view->telinfo = array(
"accueil",
"achats",
"administratif",
"affrètement",
"agence",
"agence commerciale",
"agence industries",
"atelier(s)",
"bureau",
"bureau d'étude",
"centrale à béton",
"centre de formation",
"chef d'établissement",
"comité détablissement",
"comité d'entreprise",
"conseil",
"conseil financier",
"conseil immobilier",
"construction",
"coordination",
"cuisine",
"cuisine centrale",
"déchetterie",
"délégation départementale",
"délégation régionale",
"dépôt",
"direction",
"direction commerciale",
"direction de l'environnement",
"direction des ressources humaines",
"direction financière",
"direction générale",
"direction logistique",
"direction régionale",
"direction technique",
"direction usine",
"distribution",
"division surveillance",
"douane",
"entrepôt(s)",
"facturation",
"fournitures industrielles",
"gardien",
"gestion",
"industrie",
"inspection technique",
"laboratoire",
"local entretien",
"local syndical",
"magasin",
"matériaux",
"menuiserie",
"négoce",
"parking",
"pièces détachées",
"publicité",
"rédaction",
"répondeur",
"renseignements",
"salle d'exposition",
"secrétariat",
"secrétariat de direction",
"service après vente/SAV",
"service clients",
"service commandes",
"service commercial",
"service commercial export",
"service comptabilité",
"service comptabilité fournisseurs",
"service courrier",
"service dépannage",
"service entreprises",
"service entretien",
"service expéditions",
"service exploitation",
"service export",
"service financier",
"service formation",
"service fournisseurs",
"service import",
"service informatique",
"service international",
"service locations",
"service logistique",
"service maintenance",
"service maritime",
"service production",
"service qualité",
"service technique",
"service terrestre",
"services généraux",
"siège",
"standard",
"standard général",
"standard usine",
"syndicat",
"transitaire",
"transports",
"travaux",
"unité de production",
"usine",
);
}
}
}
}
2011-02-21 08:45:13 +00:00
}