diff --git a/application/modules/achatclient/controllers/IndexController.php b/application/modules/achatclient/controllers/IndexController.php index 1f3a9335c..2167750fa 100644 --- a/application/modules/achatclient/controllers/IndexController.php +++ b/application/modules/achatclient/controllers/IndexController.php @@ -18,6 +18,8 @@ class Achatclient_IndexController extends Zend_Controller_Action protected $maxcredit=2000; + protected $libdroits = 'searchent'; + public function init() { if (Zend_Registry::isRegistered('logger')) { @@ -26,7 +28,7 @@ class Achatclient_IndexController extends Zend_Controller_Action $autoloader = Zend_Loader_Autoloader::getInstance(); // --- Theme $this->theme = Zend_Registry::get('theme'); - $request = $this->getRequest(); + $this->view->title='Votre compte crédits en ligne'; require_once 'Scores/WsScores.php'; } @@ -35,40 +37,97 @@ class Achatclient_IndexController extends Zend_Controller_Action */ public function indexAction() { + //Validation des droits $user = new Scores_Utilisateur(); - $ok=$user->checkperm('searchent'); + $ok=$user->checkperm($this->libdroits); if(!$ok){ $this->redirect('/'); } $ws = new WsScores(); $customer_credit = $ws->getCredit(); + $infos=array('user' => $user,'wscredit' => $customer_credit,'tranches' => $this->tranches); if(intval($customer_credit)>$this->maxcredit){ $this->view->msg='Vous détenez déjà le plafond de crédits autorisé.'; + return; } - $infos=array('user' => $user,'wscredit' => $customer_credit); - $this->view->infos=$infos; - var_dump($infos);die; - $this->logger->info(print_r($infos,1)); - if ($infos === false) { + $this->logger->info(print_r($user,1)); + if ($customer_credit === false and false) { $this->forward('soap', 'error'); } - //Paybox - Zend_Loader::loadClass('Paybox_System'); - $paybox = new \Paybox\System(false); - $paybox->setUrlPaiement(); - $paybox->setEmail($row->email); - $paybox->setReference($cmdId); - $paybox->setMontant($this->montant); - $paybox->setUrlRepondreA("http://".$request->getHttpHost()."/report/checkpmt"); - $paybox->setUrlParameters("http://".$request->getHttpHost()."/report/retour"); - $paybox->calculateHMAC(); + //Récupération des Parametres + $infos=array('user' => $user,'wscredit' => intval($customer_credit),'tranches' => $this->tranches); + //var_dump($infos);die; + $this->view->infos=$infos; + $this->view->submitValue='Commander'; + } + public function paiementAction() + { + //Validation + $request = $this->getRequest(''); + $nb_credit=$request->getParam('nb_credit'); + if(intval($nb_credit)==0){ + $this->error(__LINE__); + } + if(!isset($this->tranches[$nb_credit])){ + $this->error(__LINE__); + } + $user = new Scores_Utilisateur(); + $ok=$user->checkperm($this->libdroits); + if(!$ok){ + $this->error(__LINE__); + } + //Parametrage + + $pbparam=array(); + $pbparams['cmdId']=implode('#',array($user->identity->id,time())); + $pbparams['email']=$user->identity->email; + $pbparams['montant']=$this->tranches[$nb_credit]['montant']/100; + $pbparams['montantht']=$this->tranches[$nb_credit]['montantht']/100; + $pbparams['tva']=$this->tranches[$nb_credit]['tva']/100; + $ws = new WsScores(); + //$customer_credit = $ws->addCredit(); + + /* + $this->view->Siren = isset($session->CmdSiren)?$session->CmdSiren:'000000000'; + $this->view->RaisonSociale = isset($session->CmdRaisonSociale)?$session->CmdRaisonSociale:'testdev'; + $this->view->AdresseL1 = isset($session->CmdAdresseL1)?$session->CmdAdresseL1:''; + $this->view->AdresseL2 = isset($session->CmdAdresseL2)?$session->CmdAdresseL2:''; + $this->montantht=20; + $this->montant=20; + $this->tva=0; + //Lire la bdd + //$commandM = new Application_Model_Command(); + //$row = $commandM->fetchRow('cmdId="'.$cmdId.'"'); + + $this->view->montant = $this->montantht." € HT" . " (".$this->montant." € TTC)"; + + $data = array( + 'mt' => $this->montantht, + 'tax' => $this->tva, + ); + //$commandM->update($data, 'id='.$row->id);*/ + //Paybox + Zend_Loader::loadClass('Paybox_Config'); + Zend_Loader::loadClass('Paybox_System'); + $paybox = new Paybox_System(true); + $paybox->setUrlPaiement(); + $paybox->setEmail($pbparams['email']); + $paybox->setReference($pbparams['cmdId']); + $paybox->setMontant($pbparams['montant']); + //echo "http://".$request->getHttpHost()."/achatclient/pbanswer";die; + //$paybox->setUrlRepondreA("http://".$request->getHttpHost()."/achatclient/checkpmt"); + $paybox->setUrlParameters("http://".$request->getHttpHost()."/achatclient/pbanswer"); + $paybox->calculateHMAC(); + //$_POST=$paybox->getFormParameters(); + //$this->redirect($paybox->getFormUrl()); $this->view->PayboxUrl = $paybox->getFormUrl(); $this->view->PayboxValues = $paybox->getFormParameters(); - //$pb=new Paybox_System('test'); - //var_dump($pb); - } + } + public function pbanswer(){ + echo 'thanks';die; + } /** * Sélection du mode de paiement */ @@ -130,6 +189,9 @@ class Achatclient_IndexController extends Zend_Controller_Action } } + private function error($ligne=0,$message=""){ + echo $ligne;die; + } } ?> diff --git a/application/modules/achatclient/views/default/scripts/index/index.phtml b/application/modules/achatclient/views/default/scripts/index/index.phtml index 2b1035556..8a8ad30aa 100644 --- a/application/modules/achatclient/views/default/scripts/index/index.phtml +++ b/application/modules/achatclient/views/default/scripts/index/index.phtml @@ -1,30 +1,33 @@ +
-
- - - - - - - - - - - - + +

titre?>

+ +

Votre compte crédit

+
+

+Le compte infos['user']->identity->username)?$this->infos['user']->identity->username:""?> détient actuellement infos['wscredit'])?> crédits.
+msg?> +

+
+infos) && isset($this->infos['tranches'])):?> +

Vos choix de commande

+
+
+ infos['tranches'] as $credit => $item):?> +    Crédits ( Euros) + +
+
+

+ +

+
+ +
+
-
- - - - - - - - - - - - PBX_EFFECTUE - -
\ No newline at end of file diff --git a/application/modules/achatclient/views/default/scripts/index/paiement.phtml b/application/modules/achatclient/views/default/scripts/index/paiement.phtml index 7ddf35eaa..acd3e349b 100644 --- a/application/modules/achatclient/views/default/scripts/index/paiement.phtml +++ b/application/modules/achatclient/views/default/scripts/index/paiement.phtml @@ -4,7 +4,7 @@

ACHAT de CREDITS Mode de paiement

- CmdID ) {?> + CmdID ):?>
@@ -12,18 +12,6 @@

Informations de la commande

-
-
Siren :
-
Siren?>
-
Raison Sociale :
-
RaisonSociale?>
-
Adresse :
-
AdresseL1?>
-
-
AdresseL2?>
-
- -
Prix : montant?>
@@ -49,7 +37,7 @@ - + diff --git a/library/Paybox/Config.php b/library/Paybox/Config.php index dba030ffe..e7cdcde79 100644 --- a/library/Paybox/Config.php +++ b/library/Paybox/Config.php @@ -22,9 +22,11 @@ class Paybox_Config public function __construct($test = false) { if ($test === false) { + Zend_Loader::loadClass('Paybox_Config_Prod'); $config = new Paybox_Config_Prod(); } else { - $config = new Paybox_Config_Test(); + Zend_Loader::loadClass('Paybox_Config_Test'); + $config = new Paybox_Config_Test(); } foreach ( $config->variables as $var => $value ) { diff --git a/library/Scores/WsScores.php b/library/Scores/WsScores.php index 0d16a2ba7..dd4bd42b7 100644 --- a/library/Scores/WsScores.php +++ b/library/Scores/WsScores.php @@ -3399,7 +3399,7 @@ class WsScores $message.= "\n\n"; } - $message.= "Referer : ".$_SERVER['HTTP_REFERER']."\n\n"; + $message.= "Referer : ".isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:''."\n\n"; $message.= "Requete :\n ".$requete."\n"; $message.= "Reponse :\n ".$reponse."\n";