Ajout du montant avant commande

This commit is contained in:
Michael RICOIS 2014-02-11 10:01:06 +00:00
parent 04b23a60d8
commit 5302700ab3

View File

@ -16,7 +16,7 @@ class ReportController extends Zend_Controller_Action
} }
/** /**
* * Page d'entrée
*/ */
public function indexAction() public function indexAction()
{ {
@ -99,7 +99,7 @@ class ReportController extends Zend_Controller_Action
} }
/** /**
* * Page de commande
*/ */
public function cmdAction() public function cmdAction()
{ {
@ -179,14 +179,16 @@ class ReportController extends Zend_Controller_Action
$html = $report->getContent(); $html = $report->getContent();
if ( $html !== false ) { if ( $html !== false ) {
$pathCmd = $c->profil->path->data; //Replace some HTML contents
$html = preg_replace('@<link href="/@si','<link href="./', $html);
$html = preg_replace('@src="/@si','src="./', $html);
$path = $c->profil->path->pages;
$id = uniqid(); $id = uniqid();
//Write the file (name with commande id) //Write the file (name with commande id)
if ( file_put_contents($pathCmd . DIRECTORY_SEPARATOR . $id.'.html', $html) ) { if ( file_put_contents($path . DIRECTORY_SEPARATOR . $id.'.html', $html) ) {
$session->CmdID = $this->view->CmdID = $id; $session->CmdID = $this->view->CmdID = $id;
} }
} }
} }
@ -254,6 +256,12 @@ class ReportController extends Zend_Controller_Action
$this->view->montant = $this->montantht." &euro; HT" . " (".$this->montant." &euro; TTC)"; $this->view->montant = $this->montantht." &euro; HT" . " (".$this->montant." &euro; TTC)";
$data = array(
'mt' => $this->montantht,
'tax' => $this->tva,
);
$commandM->update($data, 'id='.$row->id);
//Paybox //Paybox
$paybox = new Paybox_System(false); $paybox = new Paybox_System(false);
$paybox->setUrlPaiement(); $paybox->setUrlPaiement();
@ -272,7 +280,7 @@ class ReportController extends Zend_Controller_Action
} }
/** /**
* * Retour après paiement Paybox
*/ */
public function retourAction() public function retourAction()
{ {
@ -345,7 +353,9 @@ class ReportController extends Zend_Controller_Action
} }
/**
* Command delivery
*/
public function deliverAction() public function deliverAction()
{ {
$this->_helper->layout()->disableLayout(); $this->_helper->layout()->disableLayout();
@ -451,17 +461,15 @@ class ReportController extends Zend_Controller_Action
$row = $commandM->fetchRow($where); $row = $commandM->fetchRow($where);
if ( $row !== null ) { if ( $row !== null ) {
//Copy html from command directory to temporary storage
$c = Zend_Registry::get('config'); $c = Zend_Registry::get('config');
$source = $c->profil->path->data . DIRECTORY_SEPARATOR . $row->cmdId . '.html'; $html = $c->profil->path->pages . DIRECTORY_SEPARATOR . $row->cmdId . '.html';
$dest = $c->profil->path->pages . DIRECTORY_SEPARATOR . $row->cmdId . '.html';
$content = file_get_contents($source); //Save the HTML file
$content = preg_replace('@<link href="/@si','<link href="./',$content); copy($html, $c->profil->path->data . DIRECTORY_SEPARATOR . 'html' . DIRECTORY_SEPARATOR . $id.'.html');
$content = preg_replace('@src="/@si','src="./',$content);
file_put_contents($dest, $content); //Generate the PDF
$pdf = new Scores_Wkhtml_Pdf(); $pdf = new Scores_Wkhtml_Pdf();
$file = $pdf->exec($dest); $file = $pdf->exec($html);
} }
@ -495,9 +503,7 @@ class ReportController extends Zend_Controller_Action
$request = $this->getRequest(); $request = $this->getRequest();
$cmdId = $request->getParam('id'); $cmdId = $request->getParam('id');
$regen = $request->getParam('regen');
$c = Zend_Registry::get('config');
$path = $c->profil->path->pages;
$auth = Zend_Auth::getInstance(); $auth = Zend_Auth::getInstance();
@ -506,6 +512,23 @@ class ReportController extends Zend_Controller_Action
//If REF and EMAIL and eta = 0, OK => file et commande moins d'un mois //If REF and EMAIL and eta = 0, OK => file et commande moins d'un mois
) { ) {
$c = Zend_Registry::get('config');
//Regen command
if ($regen !== null) {
$source = $c->profil->path->data . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . $cmdId . 'html';
$dest = $c->profil->path->pages . DIRECTORY_SEPARATOR . $cmdId . '.html';
copy($source, $dest);
//Generate the PDF
$pdf = new Scores_Wkhtml_Pdf();
$file = $pdf->exec($dest);
}
//Serve the file
$path = $c->profil->path->pages;
$file = $path . DIRECTORY_SEPARATOR . $cmdId . '.pdf'; $file = $path . DIRECTORY_SEPARATOR . $cmdId . '.pdf';
if( file_exists($file) && filesize($file)>0 ) { if( file_exists($file) && filesize($file)>0 ) {
header('Content-Transfer-Encoding: none'); header('Content-Transfer-Encoding: none');