SD-35 SD-28

This commit is contained in:
Claire DELBOS 2017-04-11 16:37:57 +02:00
parent b63addf2a4
commit 65831d3194
12 changed files with 338 additions and 48 deletions

View File

@ -1070,7 +1070,7 @@ class FinanceController extends Zend_Controller_Action
$entreprise = new Scores_Session_Entreprise($this->siret, $this->id);
$this->view->assign('banques', $infos->result->item);
$this->view->assign('banques', isset($infos->result->item)?$infos->result->item:array());
$this->view->assign('raisonSociale', $entreprise->getRaisonSociale());
$this->view->assign('siren', substr($this->siret, 0, 9));
$this->view->assign('exportObjet', $infos);

View File

@ -381,7 +381,7 @@ class JuridiqueController extends Zend_Controller_Action
$this->view->msg = "Erreur";
} else {
$this->view->List = $response->List->item;
$this->view->List = isset($response->List->item)?$response->List->item:null;
// --- Pagination
$nbReponsesTotal = $response->Nb;
$pageTotal = $pageCurrent = 1;

View File

@ -806,6 +806,8 @@ class RechercheController extends Zend_Controller_Action
//Calcul pagination
$nbReponses = $reponse->nbReponses;
$nbReponsesTotal = $reponse->nbReponsesTotal;
$pagePrev=1;
$pageNext=1;
if ($nbReponses < $nbReponsesTotal) {
$pageTotal = ceil( $nbReponsesTotal / $nbAffichage );
$pageCurrent = $page;

View File

@ -2918,7 +2918,7 @@ class SaisieController extends Zend_Controller_Action
$this->view->assign('actif',$result->Actif);
$this->view->assign('siren', $siren);
$this->view->assign('mode', $mode);
$this->view->assign('banques', $infos->result->item);
$this->view->assign('banques', isset($infos->result->item)?$infos->result->item:array());
$this->view->assign('guichetMod', $guichetMod);
$this->view->assign('banqueMod', $banqueMod);
@ -2937,7 +2937,7 @@ class SaisieController extends Zend_Controller_Action
$mode = $request->getParam('mode');
$this->view->assign('code_banque', $guichetMod);
$this->view->assign('code_banque', $codeBanque);
$this->view->assign('code_guichet', $codeGuichet);
$this->view->assign('num_compte', $numCompte);
$this->view->assign('bic_swift', $bicSwift);

View File

@ -383,7 +383,7 @@ class SurveillanceController extends Zend_Controller_Action
$ws = new WsScores();
$infos = $ws->getSurveillances($filtre, $position, $nbAffichage);
$surveillances = $infos->result->item;
$surveillances = isset($infos->result->item)?$infos->result->item:null;
$listTrier = array();
if ( count($surveillances)>0 ) {
@ -1155,4 +1155,56 @@ class SurveillanceController extends Zend_Controller_Action
$html2pdf->WriteHTML(utf8_decode($output));
$html2pdf->Output(str_replace('.csv', '.pdf', $nomFic), 'D');
}
/**
* Import surveillance en fichier csv
*/
public function surveillanceserieAction(){
//echo 'coucou';die;
$request = $this->getRequest();
if($request->getParam('ref')>""){
$cs=new Scores_Import_FileCsv();
$verif=$cs->verifandupload($_FILES,$request);
if($verif['success']){
$this->view->assign('msg', 'Nous avons enregistré votre fichier de '.$verif['message'].' lignes.<br><br>Les surveillances seront enregistrées durant la nuit.');
$this->view->assign('step', 2);
}else{
$this->view->assign('msg', $verif['message']);
$this->view->assign('step', 2);
}
return;
}
//Affichage formulaire demande ref et email
$this->_helper->layout->disableLayout();
$source = $request->getParam('source', '');
$encours = $request->getParam('encours', 0);
$this->view->pathScript=$this->theme->pathScript;
$this->view->pathStyle=$this->theme->pathStyle;
$user = new Scores_Utilisateur();
$request = $this->getRequest();
$source = $request->getParam('source');
$tabSource = array();
$user = new Scores_Utilisateur();
// Main email
$email = $user->getEmail();
$ref=$user->identity->id . 'www'.Date('YmdHis');
foreach ($this->sourceDroit as $s => $perm) {
if ($user->checkPerm($perm)) {
$tabSource[] = array(
'value' => $s,
'name' => $this->sourceTxt[$s],
'select' => (!empty($source) && $source==$s) ? ' selected' : '',
);
}
}
$this->view->assign('tabSource', $tabSource);
$this->view->assign('email', $email);
$this->view->assign('ref', $ref);
$this->view->assign('encours', $encours);
$this->view->msg="Sélectionnez votre fichier";
}
}

View File

@ -8,7 +8,7 @@ div#dialog fieldset legend {padding:5px; font-weight:bold; }
<form name="saveRiban" action="<?=$this->url(array('controller'=>'saisie', 'action'=>'ribansave'),null, true)?>" method="post">
<?php if($this->mode == add || $this->mode == edit){?>
<?php if($this->mode == 'add' || $this->mode == 'edit'){?>
<input type="hidden" name="mode" value="<?=$this->mode?>" />
<input type="hidden" name="siren" value="<?=$this->siren?>" />
<div class="fieldgrp">
@ -25,8 +25,10 @@ div#dialog fieldset legend {padding:5px; font-weight:bold; }
<?php
if ($this->actif==1){
$checkActive = 'checked';
$checkInactive = '';
} else {
$checkInactive = 'checked';
$checkActive = '';
}
?>
<div style="float:left;">Active<input type="radio" name="actif" value="1" <?=$checkActive;?>/></div>
@ -35,7 +37,7 @@ if ($this->actif==1){
</div>
<div class="fieldgrp">
<fieldset>
<legend>Saisie RIB</legend>
<div class="fieldgrp">
@ -49,7 +51,7 @@ if ($this->actif==1){
</select>
</div>
</div>
<div class="fieldgrp">
<label>Guichet</label>
<div class="field" >
@ -71,19 +73,19 @@ if ($this->actif==1){
</div>
</div>
</fieldset>
</div>
<div class="fieldgrp">
<fieldset>
<legend>Saisie BIC/IBAN</legend>
<div class="fieldgrp">
<label>BIC/SWIFT</label>
<div class="field">
<input type="text" name="bic_swift" value="" size="20"/>
<input type="text" name="bic_swift" value="" size="20"/>
</div>
</div>
<div class="fieldgrp">
<label>IBAN</label>
<div class="field">
@ -100,7 +102,7 @@ if ($this->actif==1){
</form>
<script>
$('#dialog').dialog({ buttons: [

View File

@ -28,9 +28,14 @@ if ( empty($this->source) ){
?>
</div>
<h2>Extraction des surveillances</h2>
<h2>Traitements de masse</h2>
<div class="paragraph">
<?=$this->action('surveillancecsv', 'surveillance')?>
<p class="options">Demande de surveillance en série :
<a class="dialogsurv" href="/surveillance/surveillanceserie" title="Demande de surveillance en série ">
OK</a></p>
</div>
<h2>Options de recherche</h2>
<div class="paragraph">
@ -296,4 +301,3 @@ $(function() {
?>
});
</script>

View File

@ -0,0 +1,70 @@
<div id="survForm">
<link href="<?=$this->pathStyle?>/bsmain.css" media="all" rel="stylesheet" type="text/css">
<?php if(intval($this->step==0)):?>
<?php
$cs=new Scores_Import_FileCsv();
$msg=$cs->standardhelptext;
?>
<div id="msgintro" class="alert-sm alert-success"><?=$msg?>
<br><br><center>
<button id="btnstart" class="btn btn-sm btn-info">Le fichier est pret</button>
</center><br><br>
</div>
<?php endif;?>
<?php if(intval($this->step==2)):?>
<div id="center">
<h1 class="titre">SURVEILLANCE</h1>
<div class="paragraph">
<div id="msgintro" class="alert-sm alert-warning"><?=$this->msg?>
<br><br>
<br><br><center>
<a href="<?=$this->url(array('controller' => 'surveillance', 'action' => 'liste'))?>" class="submit">Retour</a>
</center><br><br>
</div>
<?php endif;?>
<div id="msg" class="alert-sm alert-danger"></div>
<form enctype="multipart/form-data" id="fileform" action="<?=$this->url(array('controller' => 'surveillance', 'action' => 'surveillanceserie'))?>" method="POST">
<input class="required" type="file" name="fichier" size="50000" >
<div class="form-group">
<?php foreach($this->tabSource as $s) : ?>
<input type="checkbox" name="source[]" value="<?=$s['value']?>"<?=$s['select']?>/>&nbsp;<?=$s['name']?><br/>
<?php endforeach; ?>
</div>
<div class="form-group">
<label for="email">Adresse email du destinataire</label>
<input class="required" name="email" type="text" value="<?=$this->email?>"/>
</div>
<input class="btn btn-sm btn-info" name="loadfile" value="Charger le fichier" type="submit">
<input name="ref" type="hidden" value="<?=$this->ref?>"/></div>
</form>
</div>
<script>
$( "#fileform" ).hide();
$('#btnstart').click(function( event ) {
$( "#fileform" ).show();
$( "#msgintro" ).hide();
});
$( "#fileform" ).submit(function( event ) {
var ok=false;
if($('input[name="source[]"]:checked').length > 0){
ok=true;
}
if ( $( ".required" ).val().length === 0 ) {
ok=false;
}
if(!ok){
$('#msg').html('Merci de remplir tous les champs');
}
if ( $( "input[name=fichier]" ).val().substr(-4,4) != '.csv' ) {
$('#msg').html('Format de fichier incorrect');
ok=false;
}
if(!ok){
event.preventDefault();
}
});</script>

73
composer.lock generated
View File

@ -92,21 +92,21 @@
},
{
"name": "guzzlehttp/guzzle",
"version": "6.2.2",
"version": "6.2.3",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "ebf29dee597f02f09f4d5bbecc68230ea9b08f60"
"reference": "8d6c6cc55186db87b7dc5009827429ba4e9dc006"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/ebf29dee597f02f09f4d5bbecc68230ea9b08f60",
"reference": "ebf29dee597f02f09f4d5bbecc68230ea9b08f60",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/8d6c6cc55186db87b7dc5009827429ba4e9dc006",
"reference": "8d6c6cc55186db87b7dc5009827429ba4e9dc006",
"shasum": ""
},
"require": {
"guzzlehttp/promises": "^1.0",
"guzzlehttp/psr7": "^1.3.1",
"guzzlehttp/psr7": "^1.4",
"php": ">=5.5"
},
"require-dev": {
@ -150,7 +150,7 @@
"rest",
"web service"
],
"time": "2016-10-08T15:01:37+00:00"
"time": "2017-02-28T22:50:30+00:00"
},
{
"name": "guzzlehttp/promises",
@ -205,16 +205,16 @@
},
{
"name": "guzzlehttp/psr7",
"version": "1.3.1",
"version": "1.4.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b"
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b",
"reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
"shasum": ""
},
"require": {
@ -250,29 +250,36 @@
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Tobias Schultze",
"homepage": "https://github.com/Tobion"
}
],
"description": "PSR-7 message implementation",
"description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
"http",
"message",
"request",
"response",
"stream",
"uri"
"uri",
"url"
],
"time": "2016-06-24T23:00:38+00:00"
"time": "2017-03-20T17:10:46+00:00"
},
{
"name": "monolog/monolog",
"version": "1.22.0",
"version": "1.22.1",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "bad29cb8d18ab0315e6c477751418a82c850d558"
"reference": "1e044bc4b34e91743943479f1be7a1d5eb93add0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/bad29cb8d18ab0315e6c477751418a82c850d558",
"reference": "bad29cb8d18ab0315e6c477751418a82c850d558",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/1e044bc4b34e91743943479f1be7a1d5eb93add0",
"reference": "1e044bc4b34e91743943479f1be7a1d5eb93add0",
"shasum": ""
},
"require": {
@ -337,7 +344,7 @@
"logging",
"psr-3"
],
"time": "2016-11-26T00:15:39+00:00"
"time": "2017-03-13T07:08:03+00:00"
},
{
"name": "phpoffice/phpexcel",
@ -597,16 +604,16 @@
},
{
"name": "symfony/browser-kit",
"version": "v3.2.2",
"version": "v3.2.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/browser-kit.git",
"reference": "548f8230bad9f77463b20b15993a008f03e96db5"
"reference": "2fe0caa60c1a1dfeefd0425741182687a9b382b8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/browser-kit/zipball/548f8230bad9f77463b20b15993a008f03e96db5",
"reference": "548f8230bad9f77463b20b15993a008f03e96db5",
"url": "https://api.github.com/repos/symfony/browser-kit/zipball/2fe0caa60c1a1dfeefd0425741182687a9b382b8",
"reference": "2fe0caa60c1a1dfeefd0425741182687a9b382b8",
"shasum": ""
},
"require": {
@ -650,20 +657,20 @@
],
"description": "Symfony BrowserKit Component",
"homepage": "https://symfony.com",
"time": "2017-01-02T20:32:22+00:00"
"time": "2017-02-21T09:12:04+00:00"
},
{
"name": "symfony/css-selector",
"version": "v3.2.2",
"version": "v3.2.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
"reference": "f0e628f04fc055c934b3211cfabdb1c59eefbfaa"
"reference": "a48f13dc83c168f1253a5d2a5a4fb46c36244c4c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/f0e628f04fc055c934b3211cfabdb1c59eefbfaa",
"reference": "f0e628f04fc055c934b3211cfabdb1c59eefbfaa",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/a48f13dc83c168f1253a5d2a5a4fb46c36244c4c",
"reference": "a48f13dc83c168f1253a5d2a5a4fb46c36244c4c",
"shasum": ""
},
"require": {
@ -703,20 +710,20 @@
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
"time": "2017-01-02T20:32:22+00:00"
"time": "2017-02-21T09:12:04+00:00"
},
{
"name": "symfony/dom-crawler",
"version": "v3.2.2",
"version": "v3.2.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
"reference": "27d9790840a4efd3b7bb8f5f4f9efc27b36b7024"
"reference": "403944e294cf4ceb3b8447f54cbad88ea7b99cee"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/27d9790840a4efd3b7bb8f5f4f9efc27b36b7024",
"reference": "27d9790840a4efd3b7bb8f5f4f9efc27b36b7024",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/403944e294cf4ceb3b8447f54cbad88ea7b99cee",
"reference": "403944e294cf4ceb3b8447f54cbad88ea7b99cee",
"shasum": ""
},
"require": {
@ -759,7 +766,7 @@
],
"description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com",
"time": "2017-01-02T20:32:22+00:00"
"time": "2017-02-21T09:12:04+00:00"
},
{
"name": "symfony/polyfill-mbstring",

View File

@ -0,0 +1,8 @@
<?php
class Application_Model_CommandesSurveillance extends Zend_Db_Table_Abstract
{
protected $_name = 'commandes_surveillance';
}

View File

@ -0,0 +1,144 @@
<?php
class Scores_Import_FileCsv
{
private $filepath='';
private $standardcolumns=array(
'siren','nic','ref'
);
private $standarddelimiter=',';
private $standardencoding='utf-8';
public $standardhelptext='Le fichier attendu est un csv standard : fichier texte extension .csv contenant 3 colonnes (siren nic ref) séparées par des virgules';
public function __construct()
{
$c = new Zend_Config_Ini(realpath(APPLICATION_PATH) . '/configs/application.ini');
$ct = $c->toArray();
$config=$ct[APPLICATION_ENV];
//home/vhosts/data/extranet
$this->filepath=$config['profil']['path']['shared'].'/persist/surveillance/';
if(!is_dir($this->filepath)){
mkdir($this->filepath);
}
}
public function verifandupload($file,$request){
$ref=$request->getParam('ref');
$user = new Scores_Utilisateur();
$login = $user->identity->username;
//var_dump($user->identity);die;
$email=$request->getParam('email');
$sources=$request->getParam('source');
$fileinname=$file["fichier"]["name"];
$fileType = pathinfo($fileinname,PATHINFO_EXTENSION);
if($fileType!='csv'){
return array('success' => false, 'message' => 'Extension incorrecte');
}
$fileoutname=$ref.'.csv';
$target=$this->filepath.$fileoutname;
if (!move_uploaded_file($file["fichier"]["tmp_name"], $target)) {
return array('success' => false, 'message' => 'Le fichier '
. basename( $file["fichier"]["name"]). ' ne peut pas être chargé.');
}
$result=$this->verifyformat($fileoutname);
if($result['success']){
$row=$result['message'];
}else{
return $result;
}
$result=$this->sendtoftp($fileoutname);
if(!$result['success']){
return $result;
}
$user = new Scores_Utilisateur();
$cmd=new Application_Model_CommandesSurveillance();
foreach($sources as $source){
$data= array(
'ref' => $ref,
'login' =>$login,
'email' => $email,
'filename' => $fileinname,
'surv_source' => $source,
'date_created' => Date('Y-m-d')
);
$cmd->insert($data);
}
return array('success' => true, 'message' => $row);
}
private function verifyformat($filename){
$handle=fopen($this->filepath.$filename,'r');
if(!$handle){
return array('success' => false, 'message' => 'Fichier illisible.');
}
ini_set("auto_detect_line_endings", true);
$row=1;
while (($data = fgetcsv($handle)) !== FALSE) {
$num = count($data);
if($num!=3){
return array('success' => false, 'message' => 'Nombre de colonnes erronné à la ligne '.$row.'.');
}
if($data[0]=='siren' & $row==1){
continue;
}
$data[0]=trim($data[0]);
if(strlen($data[0])>9){
return array('success' => false, 'message' => 'Siren mal formaté à la ligne '.$row.'.');
}
if(!is_numeric($data[0])){
return array('success' => false, 'message' => 'Siren non numérique '.$data[0].' à la ligne '.$row.'.');
}
$siren=substr('000000000'.$data[0],-9,9);
if(!$this->estValide($siren)){
return array('success' => false, 'message' => 'Siren invalide '.$data[0].' à la ligne '.$row.'.');
}
$row++;
}
fclose($handle);
return array('success' => true, 'message' => $row);
}
private function sendtoftp($filename){
$connection = ftp_connect('ftp.scores-decisions.com',21);
$login = ftp_login($connection, 'internesd', 'internesd2017');
$dest='/send/'.$filename;
$source=$this->filepath.$filename;
if (!$connection || !$login) {
return array('success' => false, 'message' => 'Un problement technique est survenu merci de nous contacter avec le code erreur '.__LINE__);
}
if(!ftp_pasv($connection, true)){
return array('success' => false, 'message' => 'Un problement technique est survenu merci de nous contacter avec le code erreur '.__LINE__);
}
$upload = ftp_put($connection, $dest, $source, FTP_BINARY);
if (!$upload) {
return array('success' => false, 'message' => 'Un problement technique est survenu merci de nous contacter avec le code erreur '.__LINE__);
}
ftp_close($connection);
return array('success' => true, 'message' => '');
}
private function estValide($siren){
// Donc le SIREN est un numérique à 9 chiffres
$somme = 0;
for ($cpt = 0; $cpt<strlen($siren); $cpt++) {
if (($cpt % 2) == 1) { // Les positions paires : 2ème, 4ème, 6ème et 8ème chiffre
$tmp = substr($siren,$cpt,1) * 2; // On le multiplie par 2
if ($tmp > 9)
$tmp -= 9; // Si le résultat est supérieur à 9, on lui soustrait 9
}
else
$tmp = substr($siren,$cpt,1);
$somme += (int)$tmp;
}
if (($somme % 10) == 0)
return true; // Si la somme est un multiple de 10 alors le SIREN est valide
else
return false;
}
}

View File

@ -0,0 +1 @@
@import url("./../../../libs/bootstrap-3.3.7/css/bootstrap.min.css");