Update tarif

This commit is contained in:
Michael RICOIS 2014-05-05 07:36:37 +00:00
parent 726e5299ee
commit 7d7b1073ce
6 changed files with 114 additions and 27 deletions

View File

@ -82,10 +82,10 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
//MetadataCache pour la base de données
$cache = Zend_Cache::factory(
'Core',
'Apc',
array('lifetime' => 28800,'automatic_serialization' => true),
array()
'Core',
'Apc',
array('lifetime' => 28800,'automatic_serialization' => true),
array()
);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
}
@ -97,10 +97,13 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$router = $front->getRouter();
//Route pour prestations
$route = new Zend_Controller_Router_Route('/id/:client/*', array(
'controller' => 'presta',
'action' => 'index',
));
$route = new Zend_Controller_Router_Route(
'/id/:client/*',
array(
'controller' => 'presta',
'action' => 'index',
)
);
$router->addRoute('presta', $route);
return $router;
}

View File

@ -6,14 +6,31 @@ class PrestaController extends Zend_Controller_Action
$request = $this->getRequest();
$id = $request->getParam('client');
$prestation = $request->getParam('p', 1);
switch($id) {
//Prestation KOMPASS, livraison rapport pdf
switch( $id ) {
// Prestation KOMPASS, livraison rapport pdf
case '144':
$siren = $request->getParam('siren');
$url = '/report/index/siren/'.$siren;
$url = '/report/index/siren/'.$siren.'/p/144-1';
$this->redirect($url);
break;
// Prestation CORPORAMA
case '186':
$siren = $request->getParam('siren');
switch ( $prestation ) {
case 1:
$url = '/report/index/siren/'.$siren.'/p/186-1';
break;
case 2:
break;
}
$this->redirect($url);
break;
default:
//Erreur
break;

View File

@ -1,18 +1,64 @@
<?php
class ReportController extends Zend_Controller_Action
{
protected $montant = 0;
protected $montant;
protected $montantht;
protected $tva;
protected $pLogin;
protected $pPassword;
public function init()
{
$this->view->headLink()
->appendStylesheet('/themes/default/css/justified-nav.css', 'all');
$this->view->headLink()->appendStylesheet('/themes/default/css/justified-nav.css', 'all');
$c = Zend_Registry::get('config');
$year = date('Y');
$this->tva = $c->profil->report->tva->{$year};
$this->montantht = $c->profil->report->montantht;
$this->montant = $this->montantht * (1 + $this->tva / 100);
//Create TVA tab
$tabTVA = array();
foreach ( $c->profil->tva as $date => $value) {
$tabTVA[$date] = $value;
}
krsort($tabTVA);
$prestation = null;
// Get partner parameters
if ( Zend_Session::isReadable() && Zend_Session::namespaceIsset('Cmd') ) {
$session = new Zend_Session_Namespace('Cmd');
$session->unlock();
$prestation = $session->p;
} else {
$request = $this->getRequest();
$p = $request->getParam('p');
if ( $p !== null ) {
$prestation = 'p'.$p;
}
}
// Set Prestation params
if ( $prestation !== null ) {
$today = date('Ymd');
foreach ( $tabTVA as $date => $value ) {
if ( $today < $date ) {
break;
}
$this->tva = $value;
}
$tarif = $c->prestation->toArray();
if ( array_key_exists($prestation, $tarif) ) {
$this->montantht = $tarif[$prestation]['montantht'];
$this->montant = $this->montantht * (1 + $this->tva / 100);
$this->pLogin = $tarif[$prestation]['username'];
$this->pPassword = $tarif[$prestation]['password'];
} else {
$prestation = null;
}
}
if ( $prestation === null ) {
$url = $this->view->url(array('controller' => 'report', 'action' => 'error'), null, true);
$this->redirect($url);
}
}
/**
@ -31,9 +77,12 @@ class ReportController extends Zend_Controller_Action
$request = $this->getRequest();
//Define title
$p = $request->getParam('p');
if ( $p !== null ) {
$session->p = 'p'.$p;
}
//Control the prestation with the database - inject additionnaly parameters
//Define title
//Get parameters
$siren = $request->getParam('siren');
@ -41,13 +90,9 @@ class ReportController extends Zend_Controller_Action
if (intval($siren)>100) {
//Vérifier que le SIREN existe en base
require_once 'Scores/WsScores.php';
$c = Zend_Registry::get('config');
$login = $c->profil->report->username;
$password = $c->profil->report->password;
$ws = new WsScores($login, $password);
$ws = new WsScores($this->pLogin, $this->pPassword);
$response = $ws->getIdentiteLight($siren);
if ($response !== false) {
//Identite
@ -771,4 +816,10 @@ class ReportController extends Zend_Controller_Action
}
}
public function errorAction()
{
$this->_helper->layout()->disableLayout();
}
}

View File

@ -0,0 +1,5 @@
<?php echo $this->render('report/header.phtml')?>
<div class="alert alert-danger"><strong>Erreur !</strong> Paramètres incorrects.</div>
<?php echo $this->render('report/footer.phtml')?>

View File

@ -1,6 +1,8 @@
CREATE TABLE IF NOT EXISTS `command` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`cmdId` varchar(15) NOT NULL COMMENT 'Identifiant unique de commande',
`mt` float NOT NULL COMMENT 'Montant Hors taxes',
`tax` float NOT NULL COMMENT 'Taux de taxe',
`siren` varchar(9) NOT NULL COMMENT 'Siren de l''entreprise',
`email` varchar(50) DEFAULT NULL COMMENT 'Email de la personne',
`rs` varchar(200) DEFAULT NULL COMMENT 'Raison sociale de la personne',
@ -18,4 +20,4 @@ CREATE TABLE IF NOT EXISTS `command` (
`idtrans` varchar(100) DEFAULT NULL COMMENT 'Numéro de transaction Paybox',
`dateInsert` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Date d''insertion de la commande',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Listing des commandes' AUTO_INCREMENT=1 ;
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Listing des commandes';

View File

@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS `report_bill` (
`id` int(11) NOT NULL,
`cmdId` varchar(255) NOT NULL,
`file` varchar(255) DEFAULT NULL,
`annee` int(4) NOT NULL,
`mois` int(2) NOT NULL,
`num` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;