This commit is contained in:
Claire DELBOS 2017-04-14 09:11:10 +02:00
parent 9a8a008d03
commit 220aa8e27c
7 changed files with 26578 additions and 55 deletions

View File

@ -2910,15 +2910,21 @@ class SaisieController extends Zend_Controller_Action
$mode = $request->getParam('mode'); $mode = $request->getParam('mode');
$guichetMod = $request->getParam('guichetMod'); $guichetMod = $request->getParam('guichetMod');
$banqueMod = $request->getParam('banqueMod'); $banqueMod = $request->getParam('banqueMod');
$result='';
$ws = new WsScores(); if($mode!='add'){
$result = $ws->getIdentite($siren); $params= new stdClass();
$infos = $ws->getBanques($siren); $values=array(
'siren' => str_replace(' ', '',$request->getParam('siren')),
$this->view->assign('actif',$result->Actif); 'codeBanque' => $banqueMod,
'codeGuichet' => $guichetMod,
);
$params->infos=json_encode($values);
$ws = new Scores_Ws_Client('saisie', '0.2');
$result = $ws->getRib($params);
}
$this->view->assign('siren', $siren); $this->view->assign('siren', $siren);
$this->view->assign('mode', $mode); $this->view->assign('mode', $mode);
$this->view->assign('banques', isset($infos->result->item)?$infos->result->item:array()); $this->view->assign('banques', $result);
$this->view->assign('guichetMod', $guichetMod); $this->view->assign('guichetMod', $guichetMod);
$this->view->assign('banqueMod', $banqueMod); $this->view->assign('banqueMod', $banqueMod);
@ -2929,20 +2935,56 @@ class SaisieController extends Zend_Controller_Action
public function ribansaveAction(){ public function ribansaveAction(){
$this->_helper->layout()->disableLayout(); $this->_helper->layout()->disableLayout();
$request = $this->getRequest(); $request = $this->getRequest();
$codeBanque = str_replace(' ', '',$request->getParam('code_banque')); $params= new stdClass();
$codeGuichet = str_replace(' ', '',$request->getParam('code_guichet')); $values=array(
$numCompte = str_replace(' ', '',$request->getParam('num_compte')); 'siren' => str_replace(' ', '',$request->getParam('siren')),
$bicSwift = str_replace(' ', '',$request->getParam('bic_swift')); 'codeBanque' => str_replace(' ', '',$request->getParam('code_banque')),
$iban = str_replace(' ', '',$request->getParam('iban')); 'codeGuichet' => str_replace(' ', '',$request->getParam('code_guichet')),
$mode = $request->getParam('mode'); 'numCompte' => str_replace(' ', '',$request->getParam('num_compte')),
'bic' => str_replace(' ', '',$request->getParam('bic_swift')),
'iban' => str_replace(' ', '',$request->getParam('iban')),
'mode' => $request->getParam('mode'),
);
$params->infos=json_encode($values);
$ws = new Scores_Ws_Client('saisie', '0.2');
$result = $ws->setRib($params);
if($result){
echo 'Opération enregistrée';
}else {
echo 'Opération échouée ';
}
die;
}
$this->view->assign('code_banque', $codeBanque); public function testwsAction(){
$this->view->assign('code_guichet', $codeGuichet); $c = Zend_Registry::get('config');
$this->view->assign('num_compte', $numCompte); $wsdl = 'http://webservice.sd.dev/saisie/v0.2?wsdl-auto';
$this->view->assign('bic_swift', $bicSwift); $options = array( '0.2' => array(
$this->view->assign('iban', $iban); 'setRib' => array(
'debug' => true,
'log' => 'mail',
),
),
);
$options['features'] = SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS;
$options['compression'] = SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE;
$options['login'] = 'cdelbos';
$options['password'] = 'coucou';
if (APPLICATION_ENV == 'development'){
$options['cache_wsdl'] = WSDL_CACHE_NONE;
}
$options['trace'] = true;
$options['encoding'] = 'utf-8';
$client = false;
$client = new SoapClient($wsdl, $options);
$params = new stdClass();
$params->infos=json_encode(array('siren' => '809613144','mode' => 'add', 'codeBanque' => '20041'));
$reponse = $client->setRib($params);
var_dump($reponse);die;
} }
} }

View File

@ -1190,7 +1190,7 @@ class SurveillanceController extends Zend_Controller_Action
// Main email // Main email
$email = $user->getEmail(); $email = $user->getEmail();
$ref=$user->identity->id . 'www'.Date('YmdHis'); $ref=$user->identity->id . 'surv'.Date('YmdHis');
foreach ($this->sourceDroit as $s => $perm) { foreach ($this->sourceDroit as $s => $perm) {
if ($user->checkPerm($perm)) { if ($user->checkPerm($perm)) {
$tabSource[] = array( $tabSource[] = array(

View File

@ -42,7 +42,7 @@
<td valign="top" ><p style="text-decoration:underline;"><?=$relation->libBanque?></p> <td valign="top" ><p style="text-decoration:underline;"><?=$relation->libBanque?></p>
<?php if (empty($this->AutrePage) && $this->edition) {?> <?php if (empty($this->AutrePage) && $this->edition) {?>
<a class="dialog" title="Edition RIB/IBAN" href="<?=$this->url(array('controller'=>'saisie','action'=>'ribiban','mode'=>'edit','siren'=>$this->siren, 'guichetMod'=>$relation->codeGuichet, 'banqueMod'=>$relation->codeBanque), null, true)?>"><img src="/themes/default/images/interfaces/editer.png" /></a> <a class="dialog" title="Edition RIB/IBAN" href="<?=$this->url(array('controller'=>'saisie','action'=>'ribiban','mode'=>'edit','siren'=>$this->siren, 'guichetMod'=>$relation->codeGuichet, 'banqueMod'=>$relation->codeBanque), null, true)?>"><img src="/themes/default/images/interfaces/editer.png" /></a>
<a class="dialog" title="Supprimer RIB/IBAN" href="<?=$this->url(array('controller'=>'saisie','action'=>'ribiban','mode'=>'delete','siren'=>$this->siren,'siret'=>$this->siret), null, true)?>"><img src="/themes/default/images/interfaces/supprimer.png" /></a> <a class="dialog" title="Supprimer RIB/IBAN" href="<?=$this->url(array('controller'=>'saisie','action'=>'ribiban','mode'=>'delete','siren'=>$this->siren, 'guichetMod'=>$relation->codeGuichet, 'banqueMod'=>$relation->codeBanque), null, true)?>"><img src="/themes/default/images/interfaces/supprimer.png" /></a>
<?php }?> <?php }?>
</td> </td>
<td> <td>

View File

@ -4,13 +4,19 @@ div#dialog fieldset {border:1px solid; padding:1px; }
div#dialog fieldset legend {padding:5px; font-weight:bold; } div#dialog fieldset legend {padding:5px; font-weight:bold; }
</style> </style>
<?php
$bq=new Scores_Finance_Banques();
$banques=$bq->getBDF_Etabs('php');
$list_bq=json_encode($banques);
$list_guichets=$bq->getBDF_Guichets();
$lbanque = (array)json_decode($this->banques);
//var_dump($lbanque);
?>
<form name="saveRiban" action="<?=$this->url(array('controller'=>'saisie', 'action'=>'ribansave'),null, true)?>" method="post"> <form name="saveRiban" action="<?=$this->url(array('controller'=>'saisie', 'action'=>'ribansave'),null, true)?>" method="post">
<?php if($this->mode == 'add' || $this->mode == 'edit'){?>
<input type="hidden" name="mode" value="<?=$this->mode?>" /> <input type="hidden" name="mode" value="<?=$this->mode?>" />
<input type="hidden" name="siren" value="<?=$this->siren?>" /> <input type="hidden" name="siren" value="<?=$this->siren?>" />
<?php if($this->mode == 'add' || $this->mode == 'edit'){?>
<div class="fieldgrp"> <div class="fieldgrp">
<label>Siren</label> <label>Siren</label>
<div class="field"> <div class="field">
@ -23,7 +29,7 @@ div#dialog fieldset legend {padding:5px; font-weight:bold; }
<label>Situation RIB</label> <label>Situation RIB</label>
<div class="field"> <div class="field">
<?php <?php
if ($this->actif==1){ if ($this->actif==1 || (isset($lbanque['dateSuppr']) && $lbanque['dateSuppr']=='0000-00-00 00:00:00') ){
$checkActive = 'checked'; $checkActive = 'checked';
$checkInactive = ''; $checkInactive = '';
} else { } else {
@ -43,33 +49,35 @@ if ($this->actif==1){
<div class="fieldgrp"> <div class="fieldgrp">
<label>Banque</label> <label>Banque</label>
<div class="field" > <div class="field" >
<select name="Banque" style="width:160px;" > <select name="Banque" type="text" value="<?=$this->banqueMod?>" >
<option value=""><?=$this->banqueMod?></option> <option value="<?=$this->banqueMod?>"><?=isset($banques[$this->banqueMod])?$banques[$this->banqueMod]:$this->banqueMod?></option>
<?php foreach( $this->banques as $val ) {?> <?php foreach($banques as $num => $name):?>
<option value="<?=$val->codeBanque?>"><?=$val->codeBanque?></option> <option value="<?=$num?>"><?=substr($name,0,40)?></option>
<?php }?> <?php endforeach;?>
</select> </select>
<span id="denombque"></span>
</div> </div>
</div> </div>
<div class="fieldgrp"> <div class="fieldgrp">
<label>Guichet</label> <label>Guichet</label>
<div class="field" > <div class="field" >
<select name="Guichet" style="width:160px;" > <select name="Guichet" style="width:160px;" >
<option value=""><?=$this->guichetMod?></option> <option value=""><?=$this->banqueMod?></option>
<?php foreach( $this->banques as $val ) {?> <?php foreach( $this->banques as $val ) {?>
<option value="<?=$val->codeGuichet?>"><?=$val->codeGuichet?></option> <option value="<?=$val->codeBanque?>"><?=$val->codeBanque?></option>
<?php }?> <?php }?>
</select> </select>
<span id="denomgcht"></span>
</div> </div>
</div> </div>
<div class="fieldgrp"> <div class="fieldgrp">
<label>RIB</label> <label>RIB</label>
<div class="field"> <div class="field">
<input type="text" name="code_banque" size="4" value=""/> <input type="text" name="code_banque" size="4" value="<?=(isset($lbanque['codeBanque'])?$lbanque['codeBanque']:'') ?>"/>
<input type="text" name="code_guichet" size="4" value=""/> <input type="text" name="code_guichet" size="4" value="<?=(isset($lbanque['codeGuichet'])?$lbanque['codeGuichet']:'') ?>"/>
<input type="text" name="num_compte" size="32" value=""/> <input type="text" name="num_compte" size="32" value="<?=(isset($lbanque['numCompte'])?$lbanque['numCompte']:'') ?>"/>
</div> </div>
</div> </div>
</fieldset> </fieldset>
@ -82,20 +90,25 @@ if ($this->actif==1){
<div class="fieldgrp"> <div class="fieldgrp">
<label>BIC/SWIFT</label> <label>BIC/SWIFT</label>
<div class="field"> <div class="field">
<input type="text" name="bic_swift" value="" size="20"/> <input type="text" name="bic_swift" value="<?=(isset($lbanque['bic'])?$lbanque['bic']:'') ?>" size="20"/>
</div> </div>
</div> </div>
<div class="fieldgrp"> <div class="fieldgrp">
<label>IBAN</label> <label>IBAN</label>
<div class="field"> <div class="field">
<input type="text" name="iban" value="" size="47"/> <input type="text" name="iban" value="<?=(isset($lbanque['iban'])?$lbanque['iban']:'') ?>" size="47"/>
</div> </div>
</div> </div>
</fieldset> </fieldset>
<?php }else {?> <?php }else {?>
<input type="hidden" name="code_banque" value="<?=(isset($lbanque['codeBanque'])?$lbanque['codeBanque']:'') ?>" />
<input type="hidden" name="code_guichet" value="<?=(isset($lbanque['codeGuichet'])?$lbanque['codeGuichet']:'') ?>" />
<input type="hidden" name="num_compte" value="<?=(isset($lbanque['numCompte'])?$lbanque['numCompte']:'') ?>" />
<input type="hidden" name="bic_swift" value="<?=(isset($lbanque['bic'])?$lbanque['bic']:'') ?>" />
<input type="hidden" name="iban" value="<?=(isset($lbanque['iban'])?$lbanque['iban']:'') ?>" />
<p>Voulez vous supprimer ce RIB ?</p> <p>Voulez vous supprimer ce RIB ?</p>
<?php }?> <?php }?>
@ -105,11 +118,52 @@ if ($this->actif==1){
<script> <script>
var tab_bqu=<?=$list_bq?>;
var tab_guichet=<?=$list_guichets?>;
var selecthtml1='<option value="<?=$this->banqueMod?>"><?=$this->banqueMod?></option>';
$('select[name=Banque]').change(function(e){
var num=$('select[name=Banque]').val();
$('select[name=code_banque]').val(num);
var selecthtml2=selecthtml1;
for(var numg in tab_guichet[num]){
selecthtml2+='<option value="'+numg+'">'+numg+'</option>';
}
$('select[name=Guichet]').html(selecthtml2);
if($('input[name=code_banque]').val()==""){
$('input[name=code_banque]').val(num);
}
});
$('select[name=Guichet]').change(function(){
var num=$('select[name=Banque]').val();
var numg=$('select[name=Guichet]').val();
$('#denomgcht').html(tab_guichet[num][numg]);
if($('input[name=code_guichet]').val()==""){
$('input[name=code_guichet]').val(numg);
}
});
$('input[name=code_banque]').change(function(e){
var num=$('input[name=code_banque]').val();
$('select[name=Banque]').val(num);
$('select[name=Banque]').change();
});
$('input[name=iban]').change(function(e){
var regex = new RegExp(' ', "igm");
var iban=$('input[name=iban]').val().replace(regex,"");
$('input[name=iban]').val(iban);
var num=iban.substr(4,5);
$('select[name=Banque]').val(num);
$('select[name=Banque]').change();
var numg=iban.substr(9,5);
$('select[name=Guichet]').val(num);
$('select[name=Guichet]').change();
});
$('#dialog').dialog({ buttons: [ $('#dialog').dialog({ buttons: [
{ text: "Valider", click: function() { { text: "Valider", click: function() {
var form = $('form[name=saveRiban]'); var form = $('form[name=saveRiban]');
$.post(form.attr('action'), form.serialize(), function(data){ $.post(form.attr('action'), form.serialize(), function(data){
form.replaceWith(data); form.replaceWith(data);
}).done(function(data){ alert(data);
}).fail(function(){ alert('Unknow error'); }); }).fail(function(){ alert('Unknow error'); });
} }, } },
{ text: "Annuler", click: function() { $(this).dialog("close"); } } { text: "Annuler", click: function() { $(this).dialog("close"); } }

File diff suppressed because one or more lines are too long

View File

@ -12,9 +12,9 @@ class Scores_Import_FileCsv
{ {
$c = new Zend_Config_Ini(realpath(APPLICATION_PATH) . '/configs/application.ini'); $c = new Zend_Config_Ini(realpath(APPLICATION_PATH) . '/configs/application.ini');
$ct = $c->toArray(); $ct = $c->toArray();
$config=$ct[APPLICATION_ENV]; $this->config=$ct[APPLICATION_ENV];
//home/vhosts/data/extranet //home/vhosts/data/extranet
$this->filepath=$config['profil']['path']['shared'].'/persist/surveillance/'; $this->filepath=$this->config['profil']['path']['shared'].'/persist/surveillance/';
if(!is_dir($this->filepath)){ if(!is_dir($this->filepath)){
mkdir($this->filepath); mkdir($this->filepath);
} }
@ -22,10 +22,10 @@ class Scores_Import_FileCsv
public function verifandupload($file,$request){ public function verifandupload($file,$request){
$ref=$request->getParam('ref'); $ref=$request->getParam('ref');
$user = new Scores_Utilisateur(); $user = new Scores_Utilisateur();
$login = $user->identity->username; $this->login = $user->identity->username;
//var_dump($user->identity);die; //var_dump($user->identity);die;
$email=$request->getParam('email'); $this->email=$request->getParam('email');
$sources=$request->getParam('source'); $this->sources=$request->getParam('source');
$fileinname=$file["fichier"]["name"]; $fileinname=$file["fichier"]["name"];
$fileType = pathinfo($fileinname,PATHINFO_EXTENSION); $fileType = pathinfo($fileinname,PATHINFO_EXTENSION);
@ -33,12 +33,12 @@ class Scores_Import_FileCsv
return array('success' => false, 'message' => 'Extension incorrecte'); return array('success' => false, 'message' => 'Extension incorrecte');
} }
$fileoutname=$ref.'.csv'; $fileoutname=$ref.'.csv';
$target=$this->filepath.$fileoutname; $target=$this->filepath.$fileinname;
if (!move_uploaded_file($file["fichier"]["tmp_name"], $target)) { if (!move_uploaded_file($file["fichier"]["tmp_name"], $target)) {
return array('success' => false, 'message' => 'Le fichier ' return array('success' => false, 'message' => 'Le fichier '
. basename( $file["fichier"]["name"]). ' ne peut pas être chargé.'); . basename( $file["fichier"]["name"]). ' ne peut pas être chargé.');
} }
$result=$this->verifyformat($fileoutname); $result=$this->verifyformat($fileinname,$fileoutname);
if($result['success']){ if($result['success']){
$row=$result['message']; $row=$result['message'];
}else{ }else{
@ -48,27 +48,61 @@ class Scores_Import_FileCsv
if(!$result['success']){ if(!$result['success']){
return $result; return $result;
} }
$user = new Scores_Utilisateur();
$cmd=new Application_Model_CommandesSurveillance(); $cmd=new Application_Model_CommandesSurveillance();
foreach($sources as $source){ foreach($sources as $source){
$data= array( $data= array(
'ref' => $ref, 'ref' => $ref,
'login' =>$login, 'login' =>$this->login,
'email' => $email, 'email' => $this->email,
'filename' => $fileinname, 'filename' => $fileinname,
'surv_source' => $source, 'surv_source' => $source,
'date_created' => Date('Y-m-d') 'date_created' => Date('Y-m-d')
); );
$cmd->insert($data); $cmd->insert($data);
} }
$mail = new Zend_Mail('UTF-8');
// --- Configuration du transport SMTP
if ( $this->config['profil']['mail']['method'] == 'smtp' ) {
$config = array();
if ( isset($this->config['profil']['mail']['username']) ) {
$config['username'] = $this->config['profil']['mail']['username'];
}
if ( isset($this->config['profil']['mail']['password']) ) {
$config['password'] = $this->config['profil']['mail']['password'];
}
if ( isset($this->config['profil']['mail']['port']) ) {
$config['port'] = $c->profil->mail->port;
}
$tr = new Zend_Mail_Transport_Smtp($this->config['profil']['mail']['host'], $config);
}
// --- Configuration transport Sendmail
if ( $this->config['profil']['mail']['method']== 'sendmail' ) {
$tr = new Zend_Mail_Transport_Sendmail();
}
$mail->setDefaultTransport($tr);
$mail->setBodyText(implode('###',$data));
$mail->setFrom('support@scores-decisions.com', 'Extranet');
$mail->addTo('supportdev@scores-decisions.com', 'Support');
$mail->setSubject('Commande de surveillance '.$ref);
try{
$mail->send(); // Ne fonctionne pas en dev....
}catch(Exception $e){
// Ne fonctionne pas en dev.... voir en prod
}
return array('success' => true, 'message' => $row); return array('success' => true, 'message' => $row);
} }
private function verifyformat($filename){ private function verifyformat($fileinname,$fileoutname){
$handle=fopen($this->filepath.$filename,'r'); $handle=fopen($this->filepath.$fileinname,'r');
$h2=fopen($this->filepath.$fileoutname,'w');
if(!$handle){ if(!$handle){
return array('success' => false, 'message' => 'Fichier illisible.'); return array('success' => false, 'message' => 'Fichier illisible.');
} }
if(!$h2){
return array('success' => false, 'message' => 'Un probleme technique est survenu merci de nous contacter avec le code erreur '.__LINE__);
}
ini_set("auto_detect_line_endings", true); ini_set("auto_detect_line_endings", true);
$row=1; $row=1;
while (($data = fgetcsv($handle)) !== FALSE) { while (($data = fgetcsv($handle)) !== FALSE) {
@ -91,8 +125,16 @@ class Scores_Import_FileCsv
return array('success' => false, 'message' => 'Siren invalide '.$data[0].' à la ligne '.$row.'.'); return array('success' => false, 'message' => 'Siren invalide '.$data[0].' à la ligne '.$row.'.');
} }
$row++; $row++;
$data[3]='';
$data[4]=$this->login;
$data[5]=$this->email;
foreach($this->sources as $source){
$data[3]=$source;
fputcsv($h2,$data);
}
} }
fclose($handle); fclose($handle);
fclose($h2);
return array('success' => true, 'message' => $row); return array('success' => true, 'message' => $row);
@ -107,16 +149,16 @@ class Scores_Import_FileCsv
$source=$this->filepath.$filename; $source=$this->filepath.$filename;
if (!$connection || !$login) { if (!$connection || !$login) {
return array('success' => false, 'message' => 'Un problement technique est survenu merci de nous contacter avec le code erreur '.__LINE__); return array('success' => false, 'message' => 'Un probleme technique est survenu merci de nous contacter avec le code erreur '.__LINE__);
} }
if(!ftp_pasv($connection, true)){ if(!ftp_pasv($connection, true)){
return array('success' => false, 'message' => 'Un problement technique est survenu merci de nous contacter avec le code erreur '.__LINE__); return array('success' => false, 'message' => 'Un probleme technique est survenu merci de nous contacter avec le code erreur '.__LINE__);
} }
$upload = ftp_put($connection, $dest, $source, FTP_BINARY); $upload = ftp_put($connection, $dest, $source, FTP_BINARY);
if (!$upload) { if (!$upload) {
return array('success' => false, 'message' => 'Un problement technique est survenu merci de nous contacter avec le code erreur '.__LINE__); return array('success' => false, 'message' => 'Un probleme technique est survenu merci de nous contacter avec le code erreur '.__LINE__);
} }
ftp_close($connection); ftp_close($connection);

View File

@ -10,5 +10,15 @@ return array(
'errorMsg' => array('MSG'), 'errorMsg' => array('MSG'),
'log' => 'mail', 'log' => 'mail',
), ),
'setRib' => array(
'debug' => true,
'errorMsg' => array('MSG'),
'log' => 'mail',
),
'getRib' => array(
'debug' => true,
'errorMsg' => array('MSG'),
'log' => 'mail',
),
) )
); );