public static function generatePage(&$tpl, &$session, &$account, &$perso) { //Valider si le # du compte à été recu if (!isset($_POST['compte'])) { return fctErrorMSG('Ce compte est invalide (aucun compte).'); } //Passer le # de compte au template $tpl->set('COMPTE', $_POST['compte']); try { $compte = Member_BanqueCompte::getCompteFromNoCompte($_POST['compte']); } catch (Exception $e) { return fctErrorMSG($e->getMessage()); } //Vérifier si le compte appartiend bien au perso if ($compte->getIdPerso() != $perso->getId()) { return fctErrorMSG('Ce compte ne vous appartiend pas.'); } //Vérifier si le compte est autorisé à avoir des transactions automatiques if (!$compte->authAutoTransactions()) { return fctErrorMSG('Ce compte n\'est pas autorisé à faire des transactions automatiques.'); } //Charger les transactions du compte $transactions = $compte->getTransactionsAuto(); if (!empty($transactions)) { $tpl->set('TRANSACTIONS', $transactions); } return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/BanqueTransactionAuto.htm', __FILE__, __LINE__); }
public static function generatePage(&$tpl, &$session, &$account, &$perso) { //Valider si un # de compte à été recu if (!isset($_POST['compte'])) { return fctErrorMSG('Ce compte est invalide (aucun compte).'); } //Valider si un numéro de carte à été recu if (!isset($_POST['cid'])) { return fctErrorMSG('Cete carte est invalide (aucune carte).'); } //Passer le # du compte au template $tpl->set('COMPTE', $_POST['compte']); //Instancier le compte try { $compte = Member_BanqueCompte::getCompteFromNoCompte($_POST['compte']); } catch (GameException $e) { return fctErrorMSG($e->getMessage()); } //Vérifier si le compte appartiend bien au perso if ($compte->getIdPerso() != $perso->getId()) { return fctErrorMSG('Ce compte ne vous appartiend pas.'); } //supprimer la carte $compte->delAccesCard($_POST['cid']); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/Banque_carte_redirect.htm', __FILE__, __LINE__); }
public static function generatePage(&$tpl, &$session, &$account, &$mj) { //Valider si le # du compte à été recu if (!isset($_POST['compteId']) || !is_numeric($_POST['compteId'])) { return fctErrorMSG('Ce compte est invalide.'); } //Valider si le # de banque à été recu if (!isset($_POST['banqueId']) || !is_numeric($_POST['banqueId'])) { return fctErrorMSG('banque invalide.'); } //Valider si le # de transaction à été recu if (!isset($_POST['tid']) || !is_numeric($_POST['tid'])) { return fctErrorMSG('Transaction invalide.'); } //Instancier le compte try { $compte = Member_BanqueCompte::getCompteFromId($_POST['compteId']); } catch (GameException $e) { return fctErrorMSG($e->getMessage()); } //Rechercher la transaction $transactions = $compte->getTransactionsAuto(); foreach ($transactions as $transaction) { if ($transaction->getId() == $_POST['tid']) { $transactionFound = $transaction; } } //Vérifier si la transaction existe if (!isset($transactionFound)) { return fctErrorMSG('Cette transaction n\'existe pas. (' . $_POST['tid'] . ')'); } //Vérifier les données 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.'); } //Mettre à jour les informations try { $newCompteTo = Member_BanqueCompte::getCompteFromNoCompte($_POST['compteTo']); $transactionFound->changeCompteIdTo($newCompteTo->getId()); $transactionFound->changeDescription($_POST['description']); $transactionFound->changeValue($_POST['value']); $date = mktime(0, 0, 0, $_POST['date_month'], $_POST['date_day'], $_POST['date_year'] - GAMETIME_DECAL); $transactionFound->changeDate($date); $transactionFound->setData(); } catch (GameException $e) { return fctErrorMSG($e->getMessage()); } //rediriger la page die("<script type=\"text/javascript\">location.href='?mj=Lieu_BanqueTransactionAuto&id=" . $_POST['compteId'] . "&bid=" . $_POST['banqueId'] . "';</script>"); }
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__); }
public static function generatePage(&$tpl, &$session, &$account, &$perso) { //Valider si le # du compte à été recu if (!isset($_POST['compte'])) { return fctErrorMSG('Ce compte est invalide (aucun compte).'); } //Valider si le # de carte à été recu if (!isset($_POST['cid'])) { return fctErrorMSG('Cette carte est invalide (aucune carte).'); } //Passer le # de compte au template $tpl->set('COMPTE', $_POST['compte']); //Instancier le compte try { $compte = Member_BanqueCompte::getCompteFromNoCompte($_POST['compte']); } catch (GameException $e) { return fctErrorMSG($e->getMessage()); } //Vérifier si le compte appartiend bien au perso if ($compte->getIdPerso() != $perso->getId()) { return fctErrorMSG('Ce compte ne vous appartiend pas.'); } //Valider si le NIP est possible if (!is_numeric($_POST['nip'])) { return fctErrorMSG('Vous devez entrez un NIP composé uniquement de chiffres de 0 à 9.'); } //Valider si le nom a été entré if (empty($_POST['nom'])) { return fctErrorMSG('Vous devez entrez un nom pour la carte.'); } //Rechercher la carte $cartes = $compte->getCartes(); foreach ($cartes as $carte) { if ($carte->getNo() == $_POST['cid']) { $carteFound = $carte; } } //Vérifier si la carte existe if (!isset($carteFound)) { return fctErrorMSG('Cette carte n\'existe pas. (' . $_POST['cid'] . ')'); } //Mettre à jour les informations $carteFound->changeNom($_POST['nom']); $carteFound->changeNip($_POST['nip']); $carteFound->changeValid($_POST['valid'] == 1 ? true : false); $carteFound->saveData(); //rediriger la page //TODO: utiliser le module de redirection return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/Banque_carte_redirect.htm', __FILE__, __LINE__); }
public static function generatePage(&$tpl, &$session, &$account, &$perso) { $cout_carte = 10; //Vérifier les paramêtres requis if (!isset($_POST['compte'])) { return fctErrorMSG('Ce compte est invalide (aucun compte).'); } //Passer le # du compte au template $tpl->set('COMPTE', $_POST['compte']); //Instancier le compte try { $compte = Member_BanqueCompte::getCompteFromNoCompte($_POST['compte']); } catch (GameException $e) { return fctErrorMSG($e->getMessage()); } //Vérifier si le compte appartiend bien au perso if ($compte->getIdPerso() != $perso->getId()) { return fctErrorMSG('Ce compte ne vous appartiend pas.'); } //Valider si le nip a été entré if (!is_numeric($_POST['nip'])) { return fctErrorMSG('Vous devez entrez un NIP composé uniquement de chiffres de 0 à 9.'); } //Valider si le nom a été entré if (empty($_POST['nom'])) { return fctErrorMSG('Vous devez entrez un nom pour la carte.'); } //Valider si le compte possède assez d'argent pour acheter une carte if ($compte->getCash() < $cout_carte && $compte->getCash() != -1) { return fctErrorMSG('Vous n\'avez pas assez de fond dans votre compte pour créer une carte.'); } //Retirer le cout de la carte du compte $compte->changeCash('-', $cout_carte); $compte->setCash(); //Créer l'access $carteId = $compte->createAccesCard($_POST['nom'], $_POST['nip'], $_POST['valid']); //Créer la carte $compte->createCarteGuichet($_POST['nom'], $carteId, $perso->getId()); //Ajouter la transaction dans l'historique du compte et le HE $compte->add_bq_hist('', 'CGCH', $cout_carte, 0); Member_He::add(NULL, $perso->getId(), 'banque', 'Vous obtenez une carte pour le compte ' . $compte->getNoBanque() . '-' . $compte->getNoCompte() . '.'); return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/Banque_carte_redirect.htm', __FILE__, __LINE__); }
public static function generatePage(&$tpl, &$session, &$account, &$perso) { //Valider si le # de compte a été recu if (!isset($_POST['compte'])) { return fctErrorMSG('Ce compte est invalide (aucun compte).'); } //Passer le # de compte au template $tpl->set('COMPTE', $_POST['compte']); //Instancier le compte try { $compte = Member_BanqueCompte::getCompteFromNoCompte($_POST['compte']); } catch (Exception $e) { return fctErrorMSG($e->getMessage()); } //Vérifier si le compte appartiend bien au perso if ($compte->getIdPerso() != $perso->getId()) { return fctErrorMSG('Ce compte ne vous appartiend pas.'); } return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/BanqueTransactionAutoAdd.htm', __FILE__, __LINE__); }
public static function generatePage(&$tpl, &$session, &$account, &$perso) { //Vérifier le # du compte a été recu if (!isset($_POST['compte'])) { return fctErrorMSG('Ce compte est invalide (aucun compte).'); } //Valider si une carte à été sélectionnée if (!isset($_POST['tid'])) { return fctErrorMSG('Aucune transaction n\'a été sélectionnée.'); } //Passer le # du compte au template $tpl->set('COMPTE', $_POST['compte']); //Instancier le compte try { $compte = Member_BanqueCompte::getCompteFromNoCompte($_POST['compte']); } catch (GameException $e) { return fctErrorMSG($e->getMessage()); } //Vérifier si le compte appartiend bien au perso if ($compte->getIdPerso() != $perso->getId()) { return fctErrorMSG('Ce compte ne vous appartiend pas.'); } //Rechercher la transaction $transactions = $compte->getTransactionsAuto(); foreach ($transactions as $transaction) { if ($transaction->getId() == $_POST['tid']) { $transactionFound = $transaction; } } //Vérifier si la carte existe if (!isset($transactionFound)) { return fctErrorMSG('Cette transaction n\'existe pas.'); } //Passer les informations sur la carte au template $tpl->set('TRANSACTION', $transactionFound); //Afficher la page return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/BanqueTransactionAutoMod.htm', __FILE__, __LINE__); }
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>"); }
public static function generatePage(&$tpl, &$session, &$account, &$perso) { //Valider si le # du compte à été recu if (!isset($_POST['compte'])) { return fctErrorMSG('Ce compte est invalide (aucun compte).'); } //Valider si le # de carte à été recu if (!isset($_POST['tid'])) { return fctErrorMSG('Cette carte est invalide (aucune carte).'); } //Passer le # de compte au template $tpl->set('COMPTE', $_POST['compte']); //Instancier le compte try { $compte = Member_BanqueCompte::getCompteFromNoCompte($_POST['compte']); } catch (GameException $e) { return fctErrorMSG($e->getMessage()); } //Vérifier si le compte appartiend bien au perso if ($compte->getIdPerso() != $perso->getId()) { return fctErrorMSG('Ce compte ne vous appartiend pas.'); } //Rechercher la transaction $transactions = $compte->getTransactionsAuto(); foreach ($transactions as $transaction) { if ($transaction->getId() == $_POST['tid']) { $transactionFound = $transaction; } } //Vérifier si la transaction existe if (!isset($transactionFound)) { return fctErrorMSG('Cette transaction n\'existe pas. (' . $_POST['tid'] . ')'); } //Vérifier les données 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.'); } //Mettre à jour les informations try { $newCompteTo = Member_BanqueCompte::getCompteFromNoCompte($_POST['compteTo']); $transactionFound->changeCompteIdTo($newCompteTo->getId()); $transactionFound->changeDescription($_POST['description']); $transactionFound->changeValue($_POST['value']); $date = mktime(0, 0, 0, $_POST['date_month'], $_POST['date_day'], $_POST['date_year'] - GAMETIME_DECAL); $transactionFound->changeDate($date); $transactionFound->setData(); } catch (GameException $e) { return fctErrorMSG($e->getMessage()); } //rediriger la page //TODO: utiliser le module de redirection return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Member/Action/Lieu/BanqueTransactionAutoRedirect.htm', __FILE__, __LINE__); }