texte * @var array */ protected $sourceTxt = array( 'annonces' => 'Annonces', 'insee' => 'Insee', 'bilans' => 'Bilans', 'score' => 'IndiScore', 'actes' => 'Actes', 'dirigeants' => 'Dirigeants', 'privileges' => 'Privilèges', 'paiements' => 'Paiements', 'liens' => 'Liens', ); /** * Association source => droits * @var array */ protected $sourceDroit = array( 'annonces' => 'survannonce', 'insee' => 'survinsee', 'bilans' => 'survbilan', 'score' => 'survscore', 'actes' => 'survactes', 'dirigeants' => 'survdirigeants', 'privileges' => 'survpriv', 'paiements' => 'survpaiements', 'liens' => 'survliens', ); public function init() { require_once 'Scores/Utilisateur.php'; require_once 'Scores/WsScores.php'; require_once 'common/dates.php'; } public function indexAction() { //What we want to do here } /** * Ajouter une surveillance */ public function ajouterAction() { //Affichage formulaire demande ref et email $this->_helper->layout->disableLayout(); $request = $this->getRequest(); $siret = $request->getParam('siret', ''); $email = $request->getParam('email', ''); $ref = $request->getParam('ref', ''); $source = $request->getParam('source', ''); $encours = $request->getParam('encours', 0); $user = new Utilisateur(); $email = $user->getEmail(); if( empty($source) ) { $source = array(); foreach($this->sourceTxt as $Source => $Txt) { if( $user->checkPerm($this->sourceDroit[$Source]) ) { $checked = 'checked'; if ($Source=='privileges') { $checked = ''; } $source[] = array( 'id' => $Source, 'txt' => $Txt, 'checked' => $checked, ); } } } $this->view->assign('source', $source); $this->view->assign('siret', $siret); $this->view->assign('email', $email); $this->view->assign('ref', $ref); $this->view->assign('encours', $encours); } public function demanderefAction() { $this->_helper->layout->disableLayout(); $user = new Utilisateur(); $email = $user->getEmail(); $this->view->assign('email', $email); } /** * Supprimer une surveillances */ public function supprimerAction() { $this->_helper->layout->disableLayout(); $request = $this->getRequest(); $page = $request->getParam('page'); $from = $request->getParam('from'); $siret = $request->getParam('siret', ''); $email = $request->getParam('email', ''); $ref = $request->getParam('ref', ''); $source = $request->getParam('source', 'annonces'); $ws = new WsScores(); $set = $ws->setSurveillance($siret, $email, urldecode($ref), $source, true); if (isset($from)) { $this->_helper->viewRenderer->setNoRender(true); if ( $set->result ) { echo "Surveillance supprimé"; } else { echo "Erreur lors de la suppression"; } } elseif (isset($page)) { $this->_redirect('surveillance/liste/page/'.$page); } else { $this->_redirect('surveillance/liste'); } } /** * Ajoute, Supprime, Edite la surveillance (Ajax) */ public function setAction() { $this->_helper->layout->disableLayout(); $request = $this->getRequest(); $siret = $request->getParam('siret', ''); $email = $request->getParam('email', ''); $ref = $request->getParam('ref', ''); $source = $request->getParam('source', 'annonces'); $delete = $request->getParam('delete', false); $encours = $request->getParam('encours', 0); //Vérification siret / email / ref if (empty($siret) || empty($email) | empty($ref)){ $msg = 'Erreur email ou reférence non définie !'; //Vérification de l'encours (chiffres) } elseif (!preg_match('/([0-9]+)/', $encours)){ $msg = 'Encours incorrect'; } else { if (!empty($delete)){ $delete = true; } $ws = new WsScores(); if (is_array($source)) { foreach($source as $s) { $msg = ''; $set = $ws->setSurveillance($siret, $email, $ref, $s, $delete, $encours); if ($set) { $msg.= "Mise sous surveillance $s"; } else { $msg.= "Erreur lors de la mise sous surveillance $s"; } $msg.= "
"; } } else { $set = $ws->setSurveillance($siret, $email, $ref, $source, $delete, $encours); if ($set) { if ($delete) { $msg = "Suppression surveillance $source"; } else { $msg = "Mise sous surveillance $source"; } } else { if ($delete) { $msg = "Erreur lors de la suppression de la surveillance $source"; } else { $msg = "Erreur lors de la mise sous surveillance $source"; } } } } $this->view->assign('msg', $msg); } /** * Ajoute un encours client */ public function encoursAction() { $this->_helper->layout->disableLayout(); $this->_forward('ajouter', 'surveillance', null, array( 'source' => 'score' )); } /** * Affiche les infos d'une surveillance */ public function infosAction() { $this->view->headScript()->appendFile('/themes/default/scripts/surveillance.js', 'text/javascript'); $request = $this->getRequest(); $source = $request->getParam('source', ''); $siret = $request->getParam('siret', 0); $user = new Utilisateur(); //if ($user->checkPerm()) $listSurv = array(); if (intval($siret)!=0) { $ws = new WsScores(); $filtre = new stdClass(); $filtre->item = $siret; $filtre->itemMode = 'siren'; $filtre->source = $source; $filtre->tri = 'siren'; $filtre->triMode = 'asc'; $filtre->detail = false; $infos = $ws->getSurveillances($filtre); $surveillances = $infos->result->item; if (count($surveillances)>0) { $titre = 'Ajouter une surveillance'; $texte = "L'entité est sous surveillance"; $item = $surveillances[0]; foreach($item->sources->item as $surv){ $tooltipTexte = ''; $ref = $surv->ref; $tooltipTexte.= "Ref : ".$ref; $tooltipTexte.= "
Date d'ajout :".WDate::dateT('Y-m-d', 'd/m/Y', $surv->dateAjout); if ($surv->dateDerEnvoi!='0000-00-00 00:00:00') { $tooltipTexte.= "
Date de dernier envoi : ". WDate::dateT('Y-m-d', 'd/m/Y', substr($surv->dateDerEnvoi,0,10)); } $listSurv[] = array( 'tooltipTexte' => $tooltipTexte, 'sourceTexte' => $this->sourceTxt[$surv->source] ); } } else { $titre = 'Ajouter une surveillance'; $texte = 'Mettre sous surveillance'; if (!empty($source)){ $texte.= ' '.$this->sourceTxt[$source]; } } } if (!empty($ref)) { $this->view->assign('ref', $ref); } else { $this->view->assign('ref', $ref); } $this->view->assign('surveillances', $listSurv); $this->view->assign('dialogTitre', $titre); $this->view->assign('dialogTexte', $texte); $this->view->assign('dialogSource', $source); } /** * Liste les surveillances */ public function listeAction() { $user = new Utilisateur(); if (!$user->checkPerm('survliste')){ $this->_forward('perms', 'error'); } $this->view->headLink() ->appendStylesheet('/themes/default/styles/surveillance.css', 'all'); $this->view->headScript() ->appendFile('/themes/default/scripts/jquery.tablesorter.js', 'text/javascript') ->appendFile('/themes/default/scripts/surveillance.js', 'text/javascript'); $request = $this->getRequest(); $page = $request->getParam('page', 0); $source = $request->getParam('source', ''); $tri = $request->getParam('tri', 'siren'); $this->view->assign('tri', $tri); $triMode = $request->getParam('triMode', 'asc'); $this->view->assign('triMode', $triMode); $q = $request->getParam('q', null); if ( $q == 'Siren, Référence, Raison Sociale' ) { $q = null; } $this->view->assign('q', $q); $detail = true; $nbAffichage = 50; $position = $page*$nbAffichage; switch ( $tri ) { default: case 'siren': $triws = 'siren'; break; case 'rs': $triws = 'rs'; break; case 'reference': $triws = 'ref'; break; case 'dateajout': $triws = 'dateAjout'; break; case 'datederenvoi': $triws = 'dateDerEnvoi'; break; } // Source => Permission $tabSource = array( 'annonces' => 'annonce', 'insee' => 'insee', 'bilans' => 'bilan', 'score' => 'score', 'actes' => 'actes', 'dirigeants' => 'dirigeants', 'privileges' => 'priv', ); $user = new Utilisateur(); //Select Tri + Liste des sources autorisées $selectTri = ''; $permSource = array(); foreach ($tabSource as $s => $perm) { if ($user->checkPerm('surv'.$perm)) { $permSource[] = $s; $selectTri.= '