Example #1
0
 public static function generatePage(&$tpl, &$session, &$account)
 {
     $timeNow = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"));
     $timeNowAff = fctToGameTime($timeNow);
     $timeFutur = strtotime("+1 month", $timeNow);
     $timeFuturAff = fctToGameTime($timeFutur);
     $tpl->set('TIMENOW', $timeNow);
     $tpl->set('TIMENOWAFF', $timeNowAff);
     $tpl->set('TIMEFUTUR', $timeFutur);
     $tpl->set('TIMEFUTURAFF', $timeFuturAff);
     $transactionArr = array('transaction_id' => 10, 'transaction_compte_from' => '1111-1111', 'transaction_compte_to' => '2222-2222', 'transaction_valeur' => 250, 'transaction_description' => 'description test', 'transaction_date' => $timeNow);
     $transaction = new Member_BanqueTransactionAuto($transactionArr);
     $tpl->set('TRANSACTIONARRAY', $transactionArr);
     $tpl->set('TRANSACTION', $transaction);
     $transaction2 = new Member_BanqueTransactionAuto($transactionArr);
     $transaction2->changeCompteIdTo(94);
     $tpl->set('TRANSACTION2', $transaction2);
     $dbMgr = DbManager::getInstance();
     //Instancier le gestionnaire
     $db = $dbMgr->getConn('game');
     //Demander la connexion existante
     $query = 'SELECT *' . ' FROM ' . DB_PREFIX . 'perso_fouille';
     $prep = $db->prepare($query);
     $prep->execute($db, __FILE__, __LINE__);
     $arr = $prep->fetch();
     $prep->closeCursor();
     $prep = NULL;
     if (!empty($arr)) {
         $arr['expiration'] = fctToGameTime($arr['expiration']);
     }
     $tpl->set('FOUILLE', $arr);
     //Retourner le template complété/rempli
     return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Visitor/test.htm', __FILE__, __LINE__);
 }
 public static function generatePage(&$tpl, &$session, &$account, &$perso)
 {
     $coutTransaction = 0;
     //Vérifier les paramêtres requis
     if (!isset($_POST['compteNoTo']) || empty($_POST['compteNoTo'])) {
         return fctErrorMSG('Vous devez préciser le compte récepteur.');
     }
     if (!isset($_POST['description']) || empty($_POST['description'])) {
         return fctErrorMSG('Vous devez préciser une description pour la transaction.');
     }
     if (!isset($_POST['value']) || empty($_POST['value'])) {
         return fctErrorMSG('Vous devez entrer le montant de la transaction.');
     }
     if (!is_numeric($_POST['value'])) {
         return fctErrorMSG('Le montant doit être numérique.');
     }
     if (!isset($_POST['date_day']) || empty($_POST['date_day']) || !isset($_POST['date_month']) || empty($_POST['date_month']) || !isset($_POST['date_year']) || empty($_POST['date_year'])) {
         return fctErrorMSG('La date est incomplète.');
     }
     if (!is_numeric($_POST['date_day']) || !is_numeric($_POST['date_month']) || !is_numeric($_POST['date_year'])) {
         return fctErrorMSG('La date est erronée.');
     }
     if (!checkdate($_POST['date_month'], $_POST['date_day'], $_POST['date_year'] - GAMETIME_DECAL)) {
         return fctErrorMSG('La date est erronée.');
     }
     //Passer le # du compte au template
     $tpl->set('COMPTE', $_POST['compte']);
     //Instancier les comptes
     try {
         $compteEmetteur = Member_BanqueCompte::getCompteFromNoCompte($_POST['compte']);
         $compteRecepteur = Member_BanqueCompte::getCompteFromNoCompte($_POST['compteNoTo']);
     } catch (GameException $e) {
         return fctErrorMSG($e->getMessage());
     }
     //Vérifier si le compte appartiend bien au perso
     if ($compteEmetteur->getIdPerso() != $perso->getId()) {
         return fctErrorMSG('Ce compte ne vous appartiend pas.');
     }
     //Valider si le compte possède assez d'argent pour créer la transaction
     if ($compteEmetteur->getCash() < $coutTransaction && $compteEmetteur->getCash() != -1) {
         return fctErrorMSG('Vous n\'avez pas assez de fond dans votre compte pour créer une transaction.');
     }
     $date = mktime(0, 0, 0, $_POST['date_month'], $_POST['date_day'], $_POST['date_year'] - GAMETIME_DECAL);
     //Créer la transaction
     try {
         Member_BanqueTransactionAuto::createNewTransactionAuto($compteEmetteur->getId(), $compteRecepteur->getId(), $_POST['value'], $_POST['description'], $date);
     } catch (GameException $e) {
         return fctErrorMSG($e->getMessage());
     }
     //Retirer le cout de la transaction du compte
     $compteEmetteur->changeCash('-', $coutTransaction);
     $compteEmetteur->setCash();
     //Ajouter la transaction dans l'historique du compte et le HE
     $compteEmetteur->add_bq_hist('', 'CGCH', $coutTransaction, 0);
     Member_He::add(NULL, $perso->getId(), 'banque', 'Vous créez une transaction automatique pour le compte ' . $compteEmetteur->getNoBanque() . '-' . $compteEmetteur->getNoCompte() . '.');
     return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/BanqueTransactionAutoRedirect.htm', __FILE__, __LINE__);
 }
Example #3
0
 private static function doTransactions()
 {
     $limitTransaction = 5;
     //On récupère les transactions qui doivent être effectuées
     $transactions = Member_BanqueTransactionAuto::getTransactionsReady($limitTransaction);
     if (count($transactions) > 0) {
         foreach ($transactions as $transaction) {
             try {
                 $transaction->effectuerTransaction();
             } catch (Exception $e) {
                 //S'il y a un problème, on signal l'erreur mais on continue l'exécution de la remise
                 fctBugReport('Erreur lors d\'une transaction automatique de banque', array('error' => $e->getMessage()), __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, false, false, false);
             }
         }
     }
 }
 public static function save()
 {
     //Instancier le compte
     $compteFrom = Member_BanqueCompte::getCompteFromId($_POST['compteId']);
     $compteTo = Member_BanqueCompte::getCompteFromNoCompte($_POST['compteNoTo']);
     //Vérifier les valeurs
     if (!is_numeric($_POST['value'])) {
         throw new GameException('Le montant doit être numérique.');
     }
     if (!isset($_POST['date_day']) || empty($_POST['date_day']) || !isset($_POST['date_month']) || empty($_POST['date_month']) || !isset($_POST['date_year']) || empty($_POST['date_year'])) {
         throw new GameException('La date est incomplète.');
     }
     if (!is_numeric($_POST['date_day']) || !is_numeric($_POST['date_month']) || !is_numeric($_POST['date_year'])) {
         throw new GameException('La date est erronée.');
     }
     if (!checkdate($_POST['date_month'], $_POST['date_day'], $_POST['date_year'] - GAMETIME_DECAL)) {
         throw new GameException('La date est erronée.');
     }
     $date = mktime(0, 0, 0, $_POST['date_month'], $_POST['date_day'], $_POST['date_year'] - GAMETIME_DECAL);
     //Créer la nouvelle transaction
     Member_BanqueTransactionAuto::createNewTransactionAuto($compteFrom->getId(), $compteTo->getId(), $_POST['value'], $_POST['description'], $date);
     die("<script type=\"text/javascript\">location.href='?mj=Lieu_BanqueTransactionAuto&id=" . $_POST['compteId'] . "&bid=" . $_POST['banqueId'] . "';</script>");
 }