127 lines
3.2 KiB
PHP
127 lines
3.2 KiB
PHP
<?php
|
|
class GestionController extends Zend_Controller_Action
|
|
{
|
|
public function preDispatch()
|
|
{
|
|
|
|
}
|
|
|
|
public function init()
|
|
{
|
|
$this->view->headLink()->appendStylesheet('/themes/default/styles/dashboard.css', 'all');
|
|
$this->view->headScript()->appendFile('/themes/default/scripts/dashboard.js', 'text/javascript');
|
|
}
|
|
|
|
public function indexAction()
|
|
{
|
|
|
|
|
|
}
|
|
|
|
public function profilsAction()
|
|
{
|
|
$profilsM = new Application_Model_EnrichissementProfils();
|
|
$sql = $profilsM->select()
|
|
->from($profilsM, array('id', 'idClient', 'login', 'reference', 'tarifLigne', 'dateAjout', 'dateSuppr', 'actif'));
|
|
$profils = $profilsM->fetchAll($sql);
|
|
|
|
$this->view->assign('profils', $profils);
|
|
}
|
|
|
|
public function profilAction(){}
|
|
|
|
public function profiladdAction()
|
|
{
|
|
$request = $this->getRequest();
|
|
|
|
//Sauvegarde du formulaire
|
|
if ( $request->isPost() && $request->getParam('submit')=='Enregistrer' ){
|
|
$params = $request->getParams();
|
|
|
|
//Vérifier le formulaire
|
|
$errForm = 0;
|
|
foreach ( $params as $key => $value ) {
|
|
if (empty($value)) {
|
|
$errForm++;
|
|
}
|
|
}
|
|
if (!$errForm) {
|
|
|
|
$dataInsee = 0;
|
|
// Est ce qu'il existe une donnée insee
|
|
require_once 'Scores/Enrichissement.php';
|
|
$fieldsM = new Enrichissement();
|
|
$fields = $fieldsM->getFields();
|
|
foreach ( $fields as $key => $val) {
|
|
if ( array_key_exists('insee', $val) && $val['insee']===true) {
|
|
$dateInsee = 1;
|
|
break;
|
|
}
|
|
}
|
|
|
|
$data = array(
|
|
'idClient' => $params['idClient'],
|
|
'login' => $params['login'],
|
|
'reference' => $params['reference'],
|
|
'criteres' => json_encode($params['criteres']),
|
|
'tarifLigne' => $params['tarifLigne'],
|
|
'dataInsee' => $dataInsee,
|
|
'dateAjout' => date('Y-m-d H:i:s'),
|
|
'actif' => 1,
|
|
);
|
|
$profilM = new Application_Model_EnrichissementProfils();
|
|
if ( $profilM->insert($data) ){
|
|
$this->view->assign('message', "Profil enregistré");
|
|
} else {
|
|
$this->view->assign('message', "Erreur lors de la sauvegarde");
|
|
}
|
|
} else {
|
|
$this->view->assign('message', "Erreur lors de la saisie");
|
|
}
|
|
|
|
}
|
|
|
|
//Affichage du formulaire
|
|
require_once 'Scores/Enrichissement.php';
|
|
$fieldsM = new Enrichissement();
|
|
$allFields = $fieldsM->getFields();
|
|
$this->view->assign('fields', $allFields);
|
|
}
|
|
|
|
public function profildelAction(){}
|
|
|
|
public function comptagesAction()
|
|
{
|
|
$table = new Application_Model_Comptages();
|
|
$sql = $table->select()
|
|
->order('dateAjout DESC');
|
|
$this->view->comptages = $table->fetchAll($sql)->toArray();
|
|
}
|
|
|
|
public function enrichissementsAction()
|
|
{
|
|
$table = new Application_Model_EnrichissementIdentifiants();
|
|
$sql = $table->select()
|
|
->order('dateAdded DESC');
|
|
$this->view->enrichissements = $table->fetchAll($sql)->toArray();
|
|
}
|
|
|
|
public function extractAction()
|
|
{
|
|
$id = $this->getRequest()->getParam('id');
|
|
$table = new Application_Model_EnrichissementIdentifiants();
|
|
$sql = $table->select()
|
|
->where('idComptage = ?', $id);
|
|
$result = $table->fetchRow($sql);
|
|
if(!empty($result)) {
|
|
$result = $result->toArray();
|
|
$sirets = json_decode($result['identifiants']);
|
|
foreach($sirets as $siret) {
|
|
echo $siret."\n";
|
|
}
|
|
}else {
|
|
echo 'Aucune commande d\'enrichissement sur ce comptage';
|
|
}
|
|
exit;
|
|
}
|
|
} |