extranet/application/controllers/DashboardController.php

583 lines
19 KiB
PHP
Raw Normal View History

2011-02-21 08:45:13 +00:00
<?php
class DashboardController extends Zend_Controller_Action
{
2011-12-07 09:13:40 +00:00
protected $typeActes= array(
'a00' => 'MODIFICATION',
'a01' => 'MODIFICATION',
'a02' => 'DISSOLUTION',
'a03' => 'CONSTITUTION',
'a04' => 'STATUTS CONSTITUTIFS',
'a06' => 'STATUTS A JOUR',
'a07' => 'STATUTS A JOUR',
'a08' => 'STATUTS A JOUR ET DECLARATION DE CONFORMITE',
'a09' => 'STATUTS APRES TRANSFERT DE SIEGE',
'a1D' => 'AUGMENTATION ET REDUCTION CAPITAL',
'a25' => 'AUGMENTATION DE CAPITAL',
'a26' => 'REDUCTION DE CAPITAL',
'a31' => 'TRANSFERT SIEGE SOCIAL HORS RESSORT O',
'a33' => 'CHANGEMENT DE GERANT',
'a39' => 'CHANGEMENT DE COMMISSAIRE AUX COMPTES',
'a77' => 'CONTINUATION MALGRE LA PERTE DE LA MOITIE DU CAPITAL',
'aA1' => 'STATUTS',
'aAA' => 'ACTE',
'aAB' => 'ACTE MODIFICATIF',
'aAC' => 'ACTE RECTIFICATIF',
'aAD' => 'ACTE SOUS SEING PRIVE',
'aAE' => 'AMPLIATION',
'aAG' => 'AVENANT',
'aAH' => 'AVENANT AUX STATUTS',
'aAI' => 'ATTESTATION',
'aAJ' => 'ANNEXES',
'aAK' => 'ATTESTATION BANCAIRE',
'aAP' => 'PROJET APPORT PARTIEL D&quot,ACTIF',
'aAT' => 'DELIVRANCE DE L&quot,INFORMATION FAITE AU CONJOINT SUR LES CONSEQUENCES DES DETTES',
'aCA' => 'CERTIFICAT',
'aCB' => 'COMPTES DE CLOTURE DE LIQUIDATION',
'aCD' => 'CONTRAT',
'aCE' => 'CONVENTION',
'aCF' => 'CERTIFICAT DE SOUSCRIPTION D&quot,ACTIONS',
'aDA' => 'DECISION DE GERANCE',
'aDB' => 'DECISION DE L&quot,ASSOCIE UNIQUE',
'aDC' => 'DECISION DES ASSOCIES',
'aDE' => 'DECLARATION DE CONFORMITE',
'aDF' => 'DECLARATION DE SOUSCRIPTION ET DE VERSEMENT',
'aDH' => 'DECLARATION DE CONFORMITE (ART.374 L24/07/1966)',
'aDI' => 'DECISION DE L&quot,ACTIONNAIRE UNIQUE',
'aDP' => 'DECISION DU PRESIDENT',
'aEA' => 'EXPEDITION',
'aEB' => 'EXPEDITION NOTARIEE',
'aEC' => 'EXTRAIT DU PROCES-VERBAL',
'aFU' => 'PROJET DE FUSION',
'aIF' => 'PROJET APPORT PARTIEL D&quot,ACTIF',
'aJA' => 'JUGEMENT',
'aLA' => 'LETTRE',
'aLB' => 'LISTE DES SIEGES SOCIAUX ANTERIEURS',
'aLC' => 'LETTRE DE DEMISSION',
'aLD' => 'LETTRE DE NOMINATION',
'aLF' => 'LISTE DES SOUSCRIPTEURS',
'aLS' => 'CERTIFICAT DE DEPOT DES FONDS AVEC LISTE DES SOUSCRIPTEURS',
'aNA' => 'NOMINATION DE REPRESENTANT',
'aO9' => 'NOMINATION DE GERANT(S)',
'aOA' => 'ORDONNANCE',
'aOB' => 'ORDONNANCE DE REFERE',
'aOC' => 'ORDONNANCE DU PRESIDENT',
'aOD' => 'ORDONNANCE SUR REQUETE',
'aOE' => 'ORDONNANCE',
'aPA' => 'PROCES VERBAL',
'aPC' => 'PROCES VERBAL D&quot,ASSEMBLEE CONSTITUTIVE',
'aPD' => 'PROCES VERBAL D&quot,ASSEMBLEE DU DIRECTOIRE',
'aPE' => 'PROCES VERBAL D&quot,ASSEMBLEE GENERALE',
'aPF' => 'PROCES VERBAL D&quot,ASSEMBLEE GENERALE EXTRAORDINAIRE',
'aPG' => 'PROCES VERBAL D&quot,ASSEMBLEE GENERALE ORDINAIRE',
'aPH' => 'PROCES VERBAL D&quot,ASSEMBLEE MIXTE',
'aPI' => 'PROCES VERBAL D&quot,ASSEMBLEES ORDINAIRE ET EXTRAORDINAIRE',
'aPL' => 'PROCES VERBAL DIRIGEANT SOCIAL',
'aPM' => 'PROCES VERBAL DU CONSEIL D&quot,ADMINISTRATION',
'aPN' => 'PROCES VERBAL DU CONSEIL DE SURVEILLANCE',
'aPO' => 'PROCES VERBAL DE LA GERANCE',
'aPT' => 'PROJET DE TRAITE D&quot,APPORT',
'aPU' => 'PROJET DE FUSION',
'aPV' => 'PV D&quot,ASSEMBLEE',
'aQ2' => 'CONSTITUTION DE LA SOCIETE',
'aR1' => 'CESSION DE PARTS (OU DONATION)',
'aR4' => 'TRAITE DE FUSION',
'aRA' => 'RAPPORT',
'aRB' => 'RAPPORT COMMISSAIRE AUX COMPTES',
'aRC' => 'RAPPORT COMMISSAIRE FUSION',
'aRE' => 'RAPPORT CR/CPTES TRANSFORM. STE',
'aRG' => 'RAPPORT DU COMMISSAIRE A LA FUSION',
'aRH' => 'RAPPORT DU COMMISSAIRE A LA SCISSION',
'aRI' => 'RAPPORT DU COMMISSAIRE A LA TRANSFORMATION',
'aRK' => 'RAPPORT DU COMMISSAIRE AUX APPORTS',
'aRL' => 'RAPPORT DU COMMISSAIRE AUX APPORTS ET A LA FUSION',
'aRQ' => 'RAPPORT GERANCE',
'aRS' => 'RAPPORT SPECIAL DU CONSEIL D&quot,ADMINISTRATION',
'aRU' => 'PROJET',
'aTA' => 'TRAITE',
'aTB' => 'TRAITE D&quot,APPORT-FUSION',
'aTC' => 'TRAITE DE FUSION',
'aUA' => 'ATTESTATION DU CONJOINT COMMUN EN BIENS',
);
public function init()
{
require_once 'Scores/WsScores.php';
require_once 'Scores/Utilisateur.php';
2011-12-07 09:13:40 +00:00
require_once 'common/dates.php';
}
public function preDispatch()
{
$user = new Utilisateur();
if (!$user->checkModeEdition() && $user->getIdClient()!=1 ){
$this->_forward('perms', 'error');
}
}
/**
* Affichage des différents liens d'administration
*/
2011-05-18 06:36:14 +00:00
public function indexAction()
{
$liens = array(
0 => array(
'libelle' => 'Gestion des clients',
'url' => $this->view->url(array('action'=>'clients')),
),
2011-07-11 09:46:40 +00:00
1 => array(
'libelle' => 'Créer un client',
'url' => $this->view->url(array('action'=>'client')),
2011-08-05 10:31:11 +00:00
),
2 => array(
2011-07-11 09:46:40 +00:00
'libelle' => 'Gestion des commandes',
'url' => $this->view->url(array('action'=>'commandes')),
),
2011-05-18 06:36:14 +00:00
);
$this->view->assign('Liens', $liens);
}
/**
* Gestion des commandes de l'extranet
* Type : greffes | kbis | graydon | giant
*/
public function commandesAction()
{
$this->view->headScript()->appendFile('/themes/default/scripts/dashboard.js', 'text/javascript');
$request = $this->getRequest();
$type = $request->getParam('type', '');
$user = new Utilisateur();
$typesCommande = array('kbis', 'greffes');
if (in_array($type, $typesCommande)){
require_once 'Scores/GestionCommandes.php';
switch($type){
case 'kbis':
$num = $request->getParam('num');
$num = str_replace(' ', '', $num);
$etat = $request->getParam('etat');
2011-08-04 16:00:20 +00:00
$mode = $request->getParam('mode', '-');
$date = $request->getParam('date');
$modeSelect = array(
'-' => array('value'=>'-', 'select'=>'', 'affichage'=>''),
'G' => array('value'=>'G', 'select'=> '', 'affichage'=>'courrier infogreffe'),
'C' => array('value'=>'C', 'select'=> '', 'affichage'=>'courrier S&amp;D'),
'E' => array('value'=>'E', 'select'=> '', 'affichage'=>'e-mail'),
);
$modeSelect[$mode]['select'] = ' selected';
$gestionCommande = new GestionCommande();
2011-12-07 10:46:20 +00:00
$status = $gestionCommande->listAllStatus();
$etatSelect = array();
$etatSelect[] = array('value'=>0, 'select'=>'', 'affichage'=>'');
foreach($status as $item){
$select = '';
if ($item['id']==$etat){
$select = ' selected';
}
$etatSelect[] = array('value'=>$item['id'], 'select'=>$select, 'affichage'=>$item['libStatut']);
}
2011-12-07 14:15:41 +00:00
if ($mode!='-'){
${'status'.$mode} = $gestionCommande->listStatus($mode);
} else {
foreach ($modeSelect as $item){
if($item['value']!='-'){
${'status'.$item['value']} = $gestionCommande->listStatus($item['value']);
}
}
}
//Valeur pour la sélection des dates
$dateSelect = array();
$dateToday = date('m');
$dateIntervalle = 12;
if ($user->checkModeEdition()){
$dateIntervalle = 24;
}
for($i=$dateToday-$dateIntervalle; $i<=$dateToday; $i++) {
$dateTime = mktime(0, 0, 0, $i+1, 0, date('Y'));
$selected = '';
if ($date=='' && $i==$dateToday ){
$selected = 'selected';
}
if ($date!='' && $dateTime==$date){
$selected = 'selected';
}
$dateSelect[] = array(
'value' => $dateTime,
'select' => $selected,
'affichage' => date('m/Y', $dateTime)
);
}
$this->view->assign('dateSelect', $dateSelect);
$this->view->assign('etatSelect', $etatSelect);
$this->view->assign('modeSelect', $modeSelect);
$this->view->assign('num', $num);
if (!empty($num)){
if (preg_match('/[0-9]{9}/', $num)){
$listCommandes = $gestionCommande->listCommandesKbisBySiren($num);
} elseif(substr($num,0,1)=='K'){
$listCommandes = $gestionCommande->listCommandesKbisByNum($num);
}
} elseif (!empty($date)) {
$listCommandes = $gestionCommande->listCommandesKbis($date, $etat, $mode);
}
2011-12-07 12:34:01 +00:00
//Parcours de la liste des commandes et vérification document existe
if (count($listCommandes)>0) {
for($i=0;$i<count($listCommandes);$i++)
{
//Etat de la commande
$cmdEtatSelect = array();
$cmdEtatSelect[] = array('value'=>0, 'select'=>'', 'affichage'=>'');
$typeCommande = $listCommandes[$i]->type;
if (isset(${'status'.$typeCommande})){
foreach(${'status'.$typeCommande} as $item){
$select = '';
if ($item['id']==$listCommandes[$i]->statutCommande){
$select = ' selected';
}
$cmdEtatSelect[] = array(
'value' => $item['id'],
'affichage' => $item['libStatut'],
'select' => $select,
);
}
}
$listCommandes[$i]->cmdEtatSelect = $cmdEtatSelect;
}
}
break; //Fin Gestion Kbis
case 'greffes':
$num = $request->getParam('num');
$num = str_replace(' ', '', $num);
$etat = $request->getParam('etat');
2011-08-04 16:00:20 +00:00
$mode = $request->getParam('mode', '-');
$date = $request->getParam('date');
$login = $request->getParam('login');
if (empty($mode) && !empty($num)) $mode = substr($num,0,1);
$modeSelect = array(
'-' => array('value'=>'-', 'select'=>'', 'affichage'=>''),
'G' => array('value'=>'G', 'select'=> '', 'affichage'=>'courrier infogreffe'),
'C' => array('value'=>'C', 'select'=> '', 'affichage'=>'courrier S&amp;D'),
'E' => array('value'=>'E', 'select'=> '', 'affichage'=>'e-mail'),
);
$modeSelect[$mode]['select'] = ' selected';
$gestionCommande = new GestionCommande();
//Liste des états possible pour les commandes
$status = $gestionCommande->listAllStatus();
$etatSelect = array();
$etatSelect[] = array('value'=>0, 'select'=>'', 'affichage'=>'');
foreach($status as $item){
$select = '';
if ($item['id']==$etat){
$select = ' selected';
}
$etatSelect[] = array(
2011-12-07 09:44:35 +00:00
'value' => $item['id'],
'select' => $select,
'affichage' => $item['libStatut']
);
}
//Valeur pour la sélection des dates
$dateSelect = array();
$dateToday = date('m');
$dateIntervalle = 12;
if ($user->checkModeEdition()){
$dateIntervalle = 24;
}
for($i=$dateToday-$dateIntervalle; $i<=$dateToday; $i++) {
$dateTime = mktime(0, 0, 0, $i+1, 0, date('Y'));
$selected = '';
if ($date=='' && $i==$dateToday ){
$selected = 'selected';
}
if ($date!='' && $dateTime==$date){
$selected = 'selected';
}
$dateSelect[] = array(
'value' => $dateTime,
'select' => $selected,
'affichage' => date('m/Y', $dateTime)
);
}
$this->view->assign('dateSelect', $dateSelect);
$this->view->assign('etatSelect', $etatSelect);
$this->view->assign('modeSelect', $modeSelect);
$this->view->assign('num', $num);
$this->view->assign('login', $login);
if (!empty($num)){
if (preg_match('/[0-9]{9}/', $num)){
$listCommandes = $gestionCommande->listCommandesGreffeBySiren($num);
} elseif(substr($num,0,1)=='G' || substr($num,0,1)=='C'){
$listCommandes = $gestionCommande->listCommandesGreffeByNum($num);
}
} elseif (!empty($login)) {
$listCommandes = $gestionCommande->listCommandesGreffeByLogin($login, $date);
} elseif (!empty($date)) {
$listCommandes = $gestionCommande->listCommandesGreffe($date, $etat, $mode);
}
2011-12-07 09:13:40 +00:00
//Liste des différents états pour les commandes
2011-08-04 16:00:20 +00:00
if ($mode!='-'){
${'status'.$mode} = $gestionCommande->listStatus($mode);
} else {
foreach ($modeSelect as $item){
if($item['value']!='-'){
${'status'.$item['value']} = $gestionCommande->listStatus($item['value']);
}
}
}
//Parcours de la liste des commandes et vérification document existe
if (count($listCommandes)>0) {
2011-08-04 16:00:20 +00:00
for($i=0;$i<count($listCommandes);$i++)
{
//Etat de la commande
$cmdEtatSelect = array();
$cmdEtatSelect[] = array('value'=>0, 'select'=>'', 'affichage'=>'');
2011-12-07 08:26:18 +00:00
$typeCommande = $listCommandes[$i]->typeCommande;
2011-08-04 16:00:20 +00:00
if (isset(${'status'.$typeCommande})){
foreach(${'status'.$typeCommande} as $item){
$select = '';
2011-12-07 08:26:18 +00:00
if ($item['id']==$listCommandes[$i]->statutCommande){
2011-08-04 16:00:20 +00:00
$select = ' selected';
}
$cmdEtatSelect[] = array(
'value' => $item['id'],
'affichage' => $item['libStatut'],
'select' => $select,
);
}
}
2011-12-07 08:26:18 +00:00
$listCommandes[$i]->cmdEtatSelect = $cmdEtatSelect;
2011-08-04 16:00:20 +00:00
//Lien vers le fichier
$documentLien = '';
2011-12-07 09:13:40 +00:00
$document = '';
2011-12-07 09:44:35 +00:00
$sirenLien = '';
2011-08-04 16:00:20 +00:00
switch($type)
{
2011-12-07 09:13:40 +00:00
case 'greffes':
2011-12-07 08:26:18 +00:00
if (preg_match('/^([0-9a-zA-Z]{2}-).*?$/', $listCommandes[$i]->refDocument, $matches)){
2011-12-07 09:44:35 +00:00
2011-12-07 09:13:40 +00:00
if (substr($listCommandes[$i]->refDocument,0,3)=='ST-'){
$document = 'DERNIER STATUS &Agrave; JOUR';
} else {
$explodedRef = explode('-', $listCommandes[$i]->refDocument);
$dateref = WDate::dateT('Ymd','d/m/Y',$explodedRef[1]);
$depot = ', Dépôt n°'.$explodedRef[6].' au '.$dateref;
$document = $this->typeActes['a'.substr($listCommandes[$i]->refDocument,0,2)].$depot;
}
2011-12-07 09:44:35 +00:00
$configuration = Zend_Registry::get('configuration');
$refFile = realpath($configuration->path->data).'/'.
$configuration->path->pdf.'/acte-'.
$listCommandes[$i]->siren.'-'.
trim($listCommandes[$i]->refDocument).'.pdf';
if (file_exists($refFile)) {
$document = '<a href="./fichier/pdf/acte-'.
$listCommandes[$i]->siren.'-'.
trim($listCommandes[$i]->refDocument).'.pdf'.
'" target="_blank">'.$document.'</a>';
}
$sirenLien = $this->view->url(array(
'controller' => 'pieces',
'action' => 'actes',
2011-12-07 09:13:40 +00:00
'siret' => $listCommandes[$i]->siren,
2011-12-07 09:44:35 +00:00
), null, true);
2011-12-07 08:26:18 +00:00
} elseif (preg_match('/^([0-9]{4}).*?$/', $listCommandes[$i]->refDocument, $matches)){
2011-12-07 09:44:35 +00:00
2011-12-07 09:13:40 +00:00
$document = 'Bilan de '.$matches[1];
2011-12-07 09:44:35 +00:00
$configuration = Zend_Registry::get('configuration');
$refFile = realpath($configuration->path->data).'/'.
$configuration->path->pdf.'/bilan-'.
$listCommandes[$i]->siren.'-'.
trim($listCommandes[$i]->refDocument).'.pdf';
if(file_exists($pathData.'/pdf/bilan-'.$siren.'-'.$ref.'.pdf')){
$suffixe = 'bilan';
$document = '<a href="./fichier/pdf/bilan-'.
$listCommandes[$i]->siren.'-'.
trim($listCommandes[$i]->refDocument).'.pdf'.
'" target="_blank">'.$document.'</a>';
}
$sirenLien = $this->view->url(array(
'controller' => 'pieces',
'action' => 'bilans',
2011-12-07 09:13:40 +00:00
'siret' => $listCommandes[$i]->siren,
2011-12-07 09:44:35 +00:00
), null, true);
}
break;
}
2011-12-07 09:13:40 +00:00
$listCommandes[$i]->document = $document;
2011-12-07 08:26:18 +00:00
$listCommandes[$i]->documentLien = $documentLien;
2011-12-07 09:44:35 +00:00
$listCommandes[$i]->sirenLien = $sirenLien;
}
}
break; //Fin Gestion Greffes
}
$this->view->assign('commandes', $listCommandes);
$this->renderScript('dashboard/commandes-'.$type.'.phtml');
}
//Affichage des liens vers les différents types de commande
$this->view->assign('typesCommande', $typesCommande);
}
2011-08-19 15:32:48 +00:00
/**
* Modification de l'état d'une commande infogreffe
*/
2011-08-04 16:00:20 +00:00
public function commandesetatchangeAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest();
$etat = $request->getParam('etat');
$idCommande = $request->getParam('idCommande');
require_once 'Scores/GestionCommandes.php';
$commande = new GestionCommande();
echo $commande->changeEtat($idCommande, $etat);
}
2011-08-19 15:32:48 +00:00
/**
* Affichage de la raison sociale à partir du siren
*/
public function rsAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest();
$siren = $request->getParam('siren');
$ws = new WsScores();
$infos = $ws->getIdentite($siren);
if ($infos==false) {
echo 'Erreur';
} else {
echo $infos->Nom;
}
}
/**
* Génération automatique du courrier PDF / ODT
*/
public function courrierAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
2011-08-22 13:30:32 +00:00
$request = $this->getRequest();
$numCommande = $request->getParam('commande');
2011-08-22 13:30:32 +00:00
require_once 'GenCourrier/GenCourrier.php';
$courrier = new GenCourrier($numCommande);
2011-08-22 13:30:32 +00:00
$courrier->computeOdt();
}
/**
* Liste les clients
*/
public function clientsAction()
{
$user = new Utilisateur();
if ( !$user->isSuperAdmin() ){
$this->_forward('perms', 'error');
}
$this->view->headScript()->appendFile('/themes/default/scripts/dashboard.js', 'text/javascript');
$ws = new WsScores();
$reponse = $ws->getListeClients();
$listeClients = $reponse->result->item;
$reponse = $ws->getListeDroits();
$wsdroits = $reponse->item;
$this->view->assign('ListeClients', $listeClients);
$this->view->assign('wsdroits', $wsdroits);
}
/**
* Edition ou création d'un nouveau client
*/
public function clientAction()
{
$user = new Utilisateur();
if ( !$user->isSuperAdmin() ){
$this->_forward('perms', 'error');
}
$this->view->headScript()->appendFile('/themes/default/scripts/jquery.checkbox.js', 'text/javascript');
$this->view->headLink()->appendStylesheet('/themes/default/styles/jquery.checkbox.css', 'all');
$request = $this->getRequest();
$idClient = $request->getParam('idClient', false);
$titre = 'CREATION NOUVEAU CLIENT';
$submitValue = 'Créer le client';
if ($idClient!==false){
$ws = new WsScores();
$reponse = $ws->getListeClients($idClient);
$InfosClient = $reponse->result->item[0];
$titre = 'EDITION CLIENT';
$submitValue = 'Modifier le client';
}
$ws = new WsScores();
$reponse = $ws->getListeDroits();
$wsdroits = $reponse->item;
$this->view->assign('idClient', $idClient);
$this->view->assign('InfosClient', $InfosClient);
$this->view->assign('titre', $titre);
$this->view->assign('submitValue', $submitValue);
$this->view->assign('wsdroits', $wsdroits);
}
/**
* Enregistre les informations sur le client
*/
public function clientsaveAction()
{
2011-06-29 08:18:24 +00:00
$request = $this->getRequest();
$infos = $request->getParams();
2011-06-29 08:18:24 +00:00
$ws = new WsScores();
$reponse = $ws->setClient($infos);
2011-06-29 08:18:24 +00:00
if ($reponse->error->errnum==1) {
$this->_forward('client', 'dashboard', null, array('idClient' => $infos['idClient']));
}
2011-06-29 08:18:24 +00:00
$this->view->assign('infos', $request->getParams());
}
2011-02-21 08:45:13 +00:00
}