88 lines
2.4 KiB
PHP
88 lines
2.4 KiB
PHP
<?php
|
|
|
|
include_once(realpath(dirname(__FILE__)) . "/../../../classes/PluginsClassiques.class.php");
|
|
include_once(realpath(dirname(__FILE__)) . "/classes/Codepromo_codepromo.class.php");
|
|
include_once(realpath(dirname(__FILE__)) . "/classes/Codepromo_codepromo_regle.class.php");
|
|
include_once(realpath(dirname(__FILE__)) . "/classes/Codepromo_util.class.php");
|
|
|
|
class Codepromo extends PluginsClassiques{
|
|
|
|
|
|
function __construct(){
|
|
parent::__construct("codepromo");
|
|
}
|
|
|
|
function init(){
|
|
$code = new Codepromo_codepromo();
|
|
$code->init();
|
|
|
|
$code = new Codepromo_codepromo_regle();
|
|
$code->init();
|
|
|
|
$code = new Codepromo_util();
|
|
$code->init();
|
|
}
|
|
|
|
function demarrage(){
|
|
global $action;
|
|
|
|
if($action == "codepromo"){
|
|
$code = new Codepromo_codepromo();
|
|
if(! $code->charger_statut($_REQUEST['code'], array(1)))
|
|
return 0;
|
|
|
|
//print_r($code);
|
|
$regle = new Codepromo_codepromo_regle();
|
|
$query = "select * from $regle->table where codepromo=" . $code->id;
|
|
$resul = mysql_query($query, $regle->link);
|
|
|
|
include_once(realpath(dirname(__FILE__)) . "/actions/" . $code->action . ".class.php");
|
|
$action = $code->action;
|
|
|
|
while($row = mysql_fetch_object($resul)){
|
|
|
|
include_once(realpath(dirname(__FILE__)) . "/controleurs/" . $row->controleur . ".class.php");
|
|
include_once(realpath(dirname(__FILE__)) . "/operations/" . $row->operation . ".class.php");
|
|
$controleur = $row->controleur;
|
|
$operation = $row->operation;
|
|
|
|
if(! $operation::calcule($controleur::calcule(), $row->valeur))
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
$action::appliquer($code->valeur, $code->id);
|
|
|
|
$action ="";
|
|
$_REQUEST['action'] = ""; $_GET['action'] = ""; $_POST['action'] = "";
|
|
|
|
}
|
|
}
|
|
|
|
function port(&$port){
|
|
if(isset($_SESSION['codepromo']['port']))
|
|
$port = $_SESSION['codepromo']['port'];
|
|
}
|
|
|
|
function aprescommande($commande){
|
|
if($_SESSION['navig']->promotemp->id)
|
|
{
|
|
$code_promo_util = new Codepromo_util();
|
|
$code_promo_util->promo = $_SESSION['navig']->promotemp->code;
|
|
$code_promo_util->commande = $commande->id;
|
|
$code_promo_util->add();
|
|
unset($_SESSION['navig']->promotemp);
|
|
}
|
|
unset($_SESSION['codepromo']['port']);
|
|
}
|
|
|
|
function avantcommande(){
|
|
if($_SESSION['navig']->promo)
|
|
{
|
|
$_SESSION['navig']->promotemp = $_SESSION['navig']->promo;
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|