Plugin Suivi
This commit is contained in:
parent
eef2069000
commit
3074968746
62
library/Application/Controller/Plugin/Suivi.php
Normal file
62
library/Application/Controller/Plugin/Suivi.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
class Application_Controller_Plugin_Suivi extends Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
public function preDispatch(Zend_Controller_Request_Abstract $request)
|
||||
{
|
||||
$module = $request->getModuleName();
|
||||
$controller = $request->getControllerName();
|
||||
$action = $request->getActionName();
|
||||
|
||||
if ($module != 'legal') {
|
||||
return;
|
||||
}
|
||||
|
||||
Zend_Registry::get('firebug')->info('PLUGIN SUIVI - START');
|
||||
|
||||
/**
|
||||
* Afficher les surveilllances
|
||||
* - uniquement pour le module "legal"
|
||||
* - lorsque le layout est activé
|
||||
*/
|
||||
|
||||
$layout = Zend_Layout::getMVCInstance();
|
||||
if ( $layout->isEnabled() ) {
|
||||
$view = $layout->getView();
|
||||
$view->MenuSuivi = null;
|
||||
$view->Suivi = array();
|
||||
|
||||
$siret = $request->getParam('siret');
|
||||
$siren = substr($siret, 0, 9);
|
||||
|
||||
$ws = new Scores_Ws_Client('entreprise', '0.8');
|
||||
$params = new stdClass();
|
||||
$params->filtre->item = $siren;
|
||||
$params->filtre->itemMode = 'siren';
|
||||
$params->filtre->source = $source;
|
||||
$params->filtre->tri = 'siren';
|
||||
$params->filtre->triMode = 'asc';
|
||||
$params->filtre->detail = false;
|
||||
try {
|
||||
$view->MenuSuivi = true;
|
||||
$response = $ws->getSurveillances($params);
|
||||
if ($response !== false) {
|
||||
if (count($response->result->item[0]->sources->item) > 0) {
|
||||
$item = $response->result->item[0]->sources->item;
|
||||
foreach ($item as $i) {
|
||||
$struct = new stdClass();
|
||||
$struct->label = $i->ref . " <small>(".$i->source.")</small>";
|
||||
$view->Suivi[] = $struct;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$view->SuiviMsg = "Chargement impossible !";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$view->MenuSuivi = null;
|
||||
Zend_Registry::get('firebug')->info($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Zend_Registry::get('firebug')->info('PLUGIN SUIVI - END');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user