</h1> <p class="lead"><?php echo $desc->desc; ?> </p> </div> <div class="row marketing"> <div class="col-lg-12"> <?php $has_place = false; if (!$username) { echo '<div class="alert alert-info">Avant toute chose tu dois te connecter ! <a class="btn btn-primary" href="login">Connexion</a></div>'; } else { $opt = Option::getUser($user->login, $desc->id); if (count($opt) > 0) { $has_place = true; $o = $opt[0]; if ($o->status == 'W') { $o->checkStatus($payutcClient, $desc->payutc_fun_id); } if ($o->status == 'V') { echo '<div class="alert alert-info">Félicitation ' . $user->prenom . ' ' . $user->nom . ', Tu as une place pour cet événement. Les organisateurs te contacteront par mail très prochainement.</div>'; } else { echo '<div class="alert alert-info">' . $user->prenom . ' ' . $user->nom . ', Une place est en cours de réservation avec tes identifiants. Tu peux <a class="btn btn-primary" href="' . $o->payutc_tra_url . '">retourner sur PayIcam</a> pour terminer le paiement ou <a class="btn btn-danger" href="cancel?id=' . $desc->id . '">annuler ta commande</a> (Dans tous les cas si tu ne paies pas dans les 15 minutes à venir ta commande sera automatiquement annulée).</div>'; } } } $debut = new DateTime($desc->debut);
return; } catch (\Exception $e) { $app->flash("info", $e->getMessage()); } $app->redirect("shotgun?id=" . $id); }); // Remove a choice $app->get('/cancel', function () use($app) { $gingerClient = new GingerClient(Config::get('ginger_key'), Config::get('ginger_server')); $payutcClient = getPayutcClient("WEBSALE"); if (!isset($_GET["id"])) { $app->redirect("index"); } else { $id = $_GET["id"]; } $options = Option::getUser($_SESSION["username"], $id); if (count($options) > 0) { $option = $options[0]; $option->status = 'A'; $option->update(); } $app->redirect("shotgun?id=" . $id); }); /* ADMIN ZONE */ $app->get('/shotgunform', function () use($app, $admin, $isAdminFondation) { $payutcClient = getPayutcClient("GESARTICLE"); if (!isset($_GET["fun_id"])) { $app->redirect("admin"); } else {
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; }