Revert code + change order to add other email after

This commit is contained in:
Michael RICOIS 2014-05-24 09:15:12 +00:00
parent cba2a42376
commit 10b829487e
7 changed files with 187 additions and 20 deletions

View File

@ -448,7 +448,9 @@ class PiecesController extends Zend_Controller_Action
if ($response===false) {
$this->view->assign('msg', "Erreur lors du passage de la commande.");
} else {
$this->view->assign('msg', "Enregistrement de votre commande sous la référence".$response.".");
$this->view->assign('formEmail', true);
$this->view->assign('refCommande', $response);
$this->view->assign('msg',"Enregistrement de votre commande sous la référence ".strtoupper($response).".");
}
}
//Affichage du formulaire
@ -469,6 +471,28 @@ class PiecesController extends Zend_Controller_Action
}
}
break;
//Saisir email
case 'EMAIL':
if ( $request->isXmlHttpRequest() ) {
if ( $request->isPost() ) {
$id = $request->getParam('refCommande');
$email = trim($request->getParam('email'));
if ( !empty($email) ) {
$response = $ws->setPiecesBilanCmdEmail($id, $email);
if ( $response === false ) {
$this->view->assign('msg', "Impossible d'enregistrer un email pour la commande ".strtoupper($id).".");
} else {
$this->view->assign('msg', "Email ".$email." enregistré pour la commande ".strtoupper($id).".");
}
} else {
$this->view->assign('msg', "Email incorrect.");
}
}
}
break;
}
}
@ -553,9 +577,11 @@ class PiecesController extends Zend_Controller_Action
//Enregistrement de la commande
if ( $request->isPost() ) {
$response = $ws->getPiecesActe($siren, $mode, $depotNum, $depotDate, $acteType, $acteNum, $acteDate, $ref);
if ($response===false) {
if ( $response === false ) {
$this->view->assign('msg', "Erreur lors du passage de la commande.");
} else {
$this->view->assign('formEmail', true);
$this->view->assign('refCommande', $response);
$this->view->assign('msg',"Enregistrement de votre commande sous la référence ".strtoupper($response).".");
}
}
@ -584,6 +610,28 @@ class PiecesController extends Zend_Controller_Action
}
}
break;
//Saisir email
case 'EMAIL':
if ( $request->isXmlHttpRequest() ) {
if ( $request->isPost() ) {
$id = $request->getParam('refCommande');
$email = trim($request->getParam('email'));
if ( !empty($email) ) {
$response = $ws->setPiecesActeCmdEmail($id, $email);
if ( $response === false ) {
$this->view->assign('msg', "Impossible d'enregistrer un email pour la commande ".strtoupper($id).".");
} else {
$this->view->assign('msg', "Email ".$email." enregistré pour la commande ".strtoupper($id).".");
}
} else {
$this->view->assign('msg', "Email incorrect.");
}
}
}
break;
}
}

View File

@ -57,13 +57,9 @@ class SurveillanceController extends Zend_Controller_Action
$encours = $request->getParam('encours', 0);
$user = new Scores_Utilisateur();
// Main email
$email = $user->getEmail();
$emails = explode(';', $email);
//Secondary email
//$ws = new WsScores();
//secondEmails = $ws->getEmail();
if( empty($source) ) {
$source = array();
@ -83,8 +79,7 @@ class SurveillanceController extends Zend_Controller_Action
}
$this->view->assign('source', $source);
$this->view->assign('siret', $siret);
$this->view->assign('emails', $emails);
$this->view->assign('email', join(';',$emails));
$this->view->assign('email', $email);
$this->view->assign('ref', $ref);
$this->view->assign('encours', $encours);
}

View File

@ -4,7 +4,7 @@
<p>Vous recevrez un email (sous 3/5 jours ouvrés) lorsque le document sera disponible.</p>
<p>Votre email : <b><?=$this->email?></b> </p>
<p>Email du compte : <b><?=$this->email?></b> </p>
<?php if ($this->emailValide===false) {?>
@ -14,6 +14,9 @@
<?php } else {?>
<div id="output">
<p><i>(Il est possible de modifier l'email après le passage de la commande)</i></p>
<form name="commande" action="<?=$this->url(array('controller'=>'pieces','action'=>'acte'),null,true)?>" method="post">
<input type="hidden" name="mode" value="<?=$this->mode?>"/>
<input type="hidden" name="siren" value="<?=$this->siren?>"/>
@ -32,10 +35,49 @@
<?php } else {?>
<?php if($this->msg) {?>
<?php if ($this->formEmail) {?>
<div id="output">
<b><?=$this->msg?></b>
<form name="commande" action="<?=$this->url(array('controller'=>'pieces','action'=>'acte'),null,true)?>" method="post">
<input type="hidden" name="mode" value="EMAIL"/>
<input type="hidden" name="refCommande" value="<?=$this->refCommande?>"/>
<div class="fieldgrp">
<label class="StyleInfoLib">Modifier l'adresse email</label>
<div class="field">
<input class="longfield" name="email" type="text" value="<?=$this->email?>" size="100"/>
</div>
</div>
</label>
</form>
</div>
<script>
$('#dialogcmd').dialog({ buttons: [
{ text: "Modifier email", click: function() {
var url = $('form[name=commande]').attr('action');
var formdata = $('form[name=commande]').serialize();
$('#dialogcmd > #output').html("Enregistrement en cours...");
$.post(url, formdata, function(data){
$('#dialogcmd > #output').html(data);
});
}
},
{ text: "Fermer", click: function() { $(this).dialog("close"); } }
] });
</script>
<?php } elseif($this->msg) {?>
<b><?=$this->msg?></b>
<?php } else {?>
<a href="<?=$this->url?>" target="_blank">Télécharger le fichier</a>
<?php }?>
<?php }?>

View File

@ -4,7 +4,7 @@
<p>Vous recevrez un email (sous 3/5 jours ouvrés) lorsque le document sera disponible.</p>
<p>Votre email : <b><?=$this->email?></b> </p>
<p>Email du compte : <b><?=$this->email?></b> </p>
<?php if ($this->emailValide===false) {?>
@ -14,6 +14,9 @@
<?php } else {?>
<div id="output">
<p><i>(Il est possible de modifier l'email après le passage de la commande)</i></p>
<form name="commande" action="<?=$this->url(array('controller'=>'pieces','action'=>'bilan'),null,true)?>" method="post">
<input type="hidden" name="mode" value="<?=$this->mode?>"/>
<input type="hidden" name="siren" value="<?=$this->siren?>"/>
@ -29,10 +32,33 @@
<?php } else {?>
<?php if($this->msg) {?>
<?=$this->msg?>
<?php if ( $this->formEmail ) {?>
<div id="output">
<b><?=$this->msg?></b>
<form name="commande" action="<?=$this->url(array('controller'=>'pieces','action'=>'bilan'),null,true)?>" method="post">
<input type="hidden" name="mode" value="EMAIL"/>
<input type="hidden" name="refCommande" value="<?=$this->refCommande?>"/>
<div class="fieldgrp">
<label class="StyleInfoLib">Modifier l'adresse email</label>
<div class="field">
<input class="longfield" name="email" type="text" value="<?=$this->email?>" size="100"/>
</div>
</div>
</label>
</form>
</div>
<?php } elseif ( $this->msg ) {?>
<b><?=$this->msg?></b>
<?php } else {?>
<a href="<?=$this->url?>" target="_blank">Télécharger le fichier</a>
<?php }?>
<?php }?>

View File

@ -72,10 +72,7 @@ $('#dialogsurv').dialog({ buttons: [ {
<div class="fieldgrp">
<label class="StyleInfoLib">Adresse email du destinataire</label>
<div class="field">
<?php foreach($this->emails as $email) {?>
<?=$email?><br/>
<?php }?>
<input class="longfield" name="email" type="hidden" value="<?=$this->email?>"/>
<input class="longfield" name="email" type="text" value="<?=$this->email?>" size="100"/>
</div>
</div>

View File

@ -1038,6 +1038,65 @@ class WsScores
}
}
public function setPiecesActeCmdEmail($id, $email)
{
$params = new stdClass();
$params->id = $id;
$params->email = $email;
$client = $this->loadClient('pieces');
try {
$reponse = $client->setActeCmdEmail($params);
return $reponse->getActesResult;
} catch (SoapFault $fault) {
if ( in_array($fault->faultcode, array('ERR', 'MSG')) ){
return $fault->faultstring;
} else {
Zend_Registry::get('firebug')->info($fault->faultcode.':'.$fault->faultstring);
$this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse());
return false;
}
}
}
public function setPiecesBilanCmdEmail($id, $email)
{
$params = new stdClass();
$params->id = $id;
$params->email = $email;
$client = $this->loadClient('pieces');
try {
$reponse = $client->setBilanCmdEmail($params);
return $reponse->getActesResult;
} catch (SoapFault $fault) {
if ( in_array($fault->faultcode, array('ERR', 'MSG')) ){
return $fault->faultstring;
} else {
Zend_Registry::get('firebug')->info($fault->faultcode.':'.$fault->faultstring);
$this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse());
return false;
}
}
}
public function setPiecesKbisCmdEmail($id, $email)
{
$params = new stdClass();
$params->id = $id;
$params->email = $email;
$client = $this->loadClient('pieces');
try {
$reponse = $client->setKbisCmdEmail($params);
return $reponse->getActesResult;
} catch (SoapFault $fault) {
if ( in_array($fault->faultcode, array('ERR', 'MSG')) ){
return $fault->faultstring;
} else {
Zend_Registry::get('firebug')->info($fault->faultcode.':'.$fault->faultstring);
$this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse());
return false;
}
}
}
public function setCGU()
{

View File

@ -65,7 +65,7 @@ $(document).ready(function(){
bgiframe: true,
title: title,
width: 550,
height: 300,
height: 400,
modal: true,
open: function(event, ui) {
$(this).html('Chargement...');
@ -77,7 +77,7 @@ $(document).ready(function(){
$('#dialogcmd').dialog({ buttons: [ { text: "Fermer", click: function() { $(this).dialog("close"); } } ] });
var url = $('form[name=commande]').attr('action');
var formdata = $('form[name=commande]').serialize();
$('#dialogcmd > #output').html("Commande en cours...");
$('#dialogcmd > #output').html("Enregistrement en cours...");
$.post(url, formdata, function(data){
$('#dialogcmd > #output').html(data);
});