Example #1
0
// About page, list all current Shotguns
$app->get('/about', function () use($app, $isAdminFondation) {
    $app->render('header.php', array("active" => "about"));
    $app->render('about.php', array());
    $app->render('footer.php', array('isAdminFondation' => $isAdminFondation));
});
// Show a specific shotgun page
$app->get('/shotgun', function () use($app, $isAdminFondation) {
    $gingerClient = new GingerClient(Config::get('ginger_key'), Config::get('ginger_server'));
    $user = isset($_SESSION['username']) ? $gingerClient->getUser($_SESSION["username"]) : null;
    if (!isset($_GET["id"])) {
        $app->redirect("index");
    } else {
        $id = $_GET["id"];
    }
    $shotgun = new Desc();
    $shotgun->select($id);
    if (!in_array('all', $shotgun->public_cible) && (!empty($user) && !in_array($user->promo, $shotgun->public_cible))) {
        $app->flash("info", "Vous ne faites pas partie du public cible de ce shotgun.");
        $app->redirect("index");
    }
    $app->render('header.php', array());
    $app->render('shotgun.php', array("desc" => $shotgun, "username" => isset($_SESSION['username']) ? $_SESSION['username'] : null, "user" => $user, "payutcClient" => getPayutcClient("WEBSALE")));
    $app->render('footer.php', array('isAdminFondation' => $isAdminFondation));
});
// Show a specific shotgun page
$app->get('/makeshotgun', function () use($app) {
    $gingerClient = new GingerClient(Config::get('ginger_key'), Config::get('ginger_server'));
    $payutcClient = getPayutcClient("WEBSALE");
    if (!isset($_GET["id"]) || !isset($_GET["choice_id"])) {
        $app->redirect("index");
Example #2
0
 public static function getAll($fun_id = null, $max = 10)
 {
     $qb = self::getQbBase();
     if ($fun_id) {
         $qb->where('d.payutc_fun_id = :fun_id')->setParameter('fun_id', $fun_id);
     }
     $qb->orderBy('d.desc_debut', 'DESC');
     if ($max) {
         $qb->setMaxResults(10);
     }
     $ret = array();
     foreach ($qb->execute()->fetchAll() as $data) {
         $desc = new Desc();
         $desc->bind($data);
         $ret[] = $desc;
     }
     return $ret;
 }
Example #3
0
 public function shotgun($user, $payutcClient)
 {
     $desc = new Desc();
     $desc->select($this->descId);
     // Check not yet shotguned
     $opt = Option::getUser($user->login, $this->descId);
     if (count($opt) > 0) {
         $o = $opt[0];
         if ($o->status == 'W') {
             $o->checkStatus($payutcClient, $desc->payutc_fun_id);
         }
         if ($o->status == 'V') {
             throw new \Exception("Tu as déjà une place pour cet événement.");
         } else {
             return $o->payutc_tra_url;
         }
     }
     // Check available
     if (!$this->isAvailable()) {
         throw new \Exception("Tu as malheureusement cliqué trop lentement, ce choix n'est plus disponible !");
     }
     // Check always open
     $debut = new \DateTime($desc->debut);
     $fin = new \DateTime($desc->fin);
     $now = new \DateTime("NOW");
     $diff = $now->diff($debut);
     if ($diff->invert) {
         if ($now->diff($fin)->invert) {
             throw new \Exception("Désolé la vente est terminé...");
         }
     } else {
         throw new \Exception("La vente n'est pas encore ouvert ! Qu'est ce que tu fais la ?");
     }
     // Let's play !
     // cotisation
     // if($user->is_cotisant != 1) {
     //     $art_id = $this->payutc_art_idNC;
     // } else {
     $art_id = $this->payutc_art_idC;
     // }
     $vente = $payutcClient->createTransaction(array("items" => json_encode(array(array($art_id, 1))), "fun_id" => $desc->payutc_fun_id, "mail" => $user->mail, "return_url" => Config::get("self_url") . "shotgun?id=" . $desc->id, "callback_url" => Config::get("self_url") . "callback"));
     $opt = new Option();
     $opt->user_login = $user->login;
     $opt->user_prenom = $user->prenom;
     $opt->user_nom = $user->nom;
     $opt->user_mail = $user->mail;
     $opt->user_cotisant = $user->is_cotisant ? 1 : 0;
     $opt->fk_desc_id = $desc->id;
     $opt->fk_choice_id = $this->id;
     $opt->payutc_tra_id = $vente->tra_id;
     $opt->payutc_tra_url = $vente->url;
     $opt->date_creation = date("Y-m-d H:i:s");
     $opt->status = 'W';
     $opt->insert();
     return $vente->url;
 }