public static function get() { if (!isset($_GET['browser'])) { //No browser id given so redirect to the manageuser //page to search a user header('Location: managebrowser', true, 303); } else { $page = new Page(); $page->data['title'] = 'Browser bewerken'; try { //Load requested browser in session $_SESSION['Stippers']['EditBrowser']['browser'] = BrowserDB::getBrowserById($_GET['browser']); EditBrowserController::buildAddEditBrowserTopView($page, false); } catch (BrowserDBException $ex) { if ($ex->getCode() == BrowserDBException::NOBROWSERFORID) { $page->data['ErrorMessageNoDescriptionWithLinkView']['errorTitle'] = 'Er is geen browser met deze id'; } else { $page->data['ErrorMessageNoDescriptionWithLinkView']['errorTitle'] = 'Kan browser niet ophalen'; } $page->data['ErrorMessageNoDescriptionWithLinkView']['tryAgainUrl'] = 'managebrowser'; $page->addView('error/ErrorMessageNoDescriptionWithLinkView'); } catch (Exception $ex) { $page->data['ErrorMessageNoDescriptionWithLinkView']['errorTitle'] = 'Kan browser niet ophalen'; $page->data['ErrorMessageNoDescriptionWithLinkView']['tryAgainUrl'] = 'managebrowser'; $page->addView('error/ErrorMessageNoDescriptionWithLinkView'); } $page->showWithMenu(); } }
public static function post() { $page = new Page(); $page->data['title'] = 'Kassa'; if (isset($_POST['to_enter_transaction_view'])) { $errMsgs = CashRegisterEnterCardViewValidator::validate($_POST); if (empty($errMsgs)) { try { $_SESSION['Stippers']['CashRegister']['user'] = UserDB::getFullUserByCardNumber($_POST['card_number']); if (!$_SESSION['Stippers']['CashRegister']['user']) { CashRegisterController::buildEnterCardView($page, true); $page->data['CashRegisterEnterCardView']['errMsgs']['global'] = '<h2 class="error_message" id="enter_card_form_error_message">Dit kaartnummer is niet gekoppeld aan een gebruiker.</h2>'; } else { CashRegisterController::buildEnterTransactionView($page, false); } } catch (Exception $ex) { CashRegisterController::buildEnterCardView($page, true); $page->data['CashRegisterEnterCardView']['errMsgs']['global'] = '<h2 class="error_message" id="enter_card_form_error_message">Kan gebruiker niet ophalen, probeer opnieuw.</h2>'; } } else { CashRegisterController::buildEnterCardView($page, true); $page->data['CashRegisterEnterCardView']['errMsgs'] = array_merge($page->data['CashRegisterEnterCardView']['errMsgs'], $errMsgs); } } elseif (isset($_POST['register_transaction'])) { $errMsgs = CashRegisterEnterTransactionViewValidator::validate($_POST); if (empty($errMsgs)) { try { $decrMoney = $_POST['decrease_money'] == '' ? 0 : SafeMath::getCentsFromString($_POST['decrease_money']); $executingBrowserName = BrowserDB::getBrowserById($_SESSION['Stippers']['browser']->browserId)->name; $trans = new MoneyTransaction(null, $_SESSION['Stippers']['CashRegister']['user']->userId, $_SESSION['Stippers']['CashRegister']['user']->balance, 0, $decrMoney, MoneyTransactionConfig::DEFAULT_DISCOUNT_PERC, false, null, $executingBrowserName, null); if ($trans->getBalAfter() < 0) { $page->data['ErrorMessageWithDescriptionWithLinkView']['tryAgainUrl'] = $_SERVER['REQUEST_URI']; $page->data['ErrorMessageWithDescriptionWithLinkView']['errorTitle'] = 'Saldo te laag'; $page->data['ErrorMessageWithDescriptionWithLinkView']['errorDescription'] = 'Het saldo de kaart is te laag.<br>Je komt onder nul uit.'; $page->addView('error/ErrorMessageWithDescriptionWithLinkView'); } else { MoneyTransactionDB::addTransaction($_SESSION['Stippers']['CashRegister']['user'], $trans); $page->data['CashRegisterTransactionResultView']['balBefore'] = $trans->getBalBefore() / 100; $page->data['CashRegisterTransactionResultView']['balAfter'] = $trans->getBalAfter() / 100; $page->data['CashRegisterTransactionResultView']['discount'] = $trans->getDiscount() / 100; $page->data['CashRegisterTransactionResultView']['decrMoney'] = $trans->getDecrMoney() / 100; $page->addView('cashRegister/CashRegisterTransactionResultView'); } } catch (Exception $ex) { CashRegisterController::buildEnterTransactionView($page, true); $page->data['CashRegisterEnterTransactionView']['errMsgs']['global'] = '<h2 class="error_message" id="enter_transaction_form_error_message">Kan transactie niet registreren, probeer opnieuw.</h2>'; } } else { CashRegisterController::buildEnterTransactionView($page, true); $page->data['CashRegisterEnterTransactionView']['errMsgs'] = array_merge($page->data['CashRegisterEnterTransactionView']['errMsgs'], $errMsgs); } } $page->showWithMenu(); }
public static function post() { $page = new Page(); $page->data['title'] = 'Geld beheren'; $errMsgs = ManageUserMoneyEnterTransactionViewValidator::validate($_POST); if (empty($errMsgs)) { try { $incrMoney = $_POST['increase_money'] == '' ? 0 : SafeMath::getCentsFromString($_POST['increase_money']); $decrMoney = $_POST['decrease_money'] == '' ? 0 : SafeMath::getCentsFromString($_POST['decrease_money']); $fromPrize = isset($_POST['from_prize']); if (isset($_SESSION['Stippers']['browser'])) { $executingBrowserName = BrowserDB::getBrowserById($_SESSION['Stippers']['browser']->browserId)->name; } else { $executingBrowserName = null; } if (isset($_SESSION['Stippers']['user'])) { $executingUser = $_SESSION['Stippers']['user']->userId; } else { $executingUser = null; } $trans = new MoneyTransaction(null, $_SESSION['Stippers']['ManageUserMoney']['user']->userId, $_SESSION['Stippers']['ManageUserMoney']['user']->balance, $incrMoney, $decrMoney, MoneyTransactionConfig::DEFAULT_DISCOUNT_PERC, $fromPrize, null, $executingBrowserName, $executingUser); if ($trans->getBalAfter() < 0) { $page->data['ErrorMessageWithDescriptionWithLinkView']['tryAgainUrl'] = $_SERVER['REQUEST_URI']; $page->data['ErrorMessageWithDescriptionWithLinkView']['errorTitle'] = 'Saldo te laag'; $page->data['ErrorMessageWithDescriptionWithLinkView']['errorDescription'] = 'Het saldo de kaart is te laag.<br>Je komt onder nul uit.'; $page->addView('error/ErrorMessageWithDescriptionWithLinkView'); } else { MoneyTransactionDB::addTransaction($_SESSION['Stippers']['ManageUserMoney']['user'], $trans); $page->data['ManageUserMoneyTransactionResultView']['balBefore'] = $trans->getBalBefore() / 100; $page->data['ManageUserMoneyTransactionResultView']['balAfter'] = $trans->getBalAfter() / 100; $page->data['ManageUserMoneyTransactionResultView']['discount'] = $trans->getDiscount() / 100; $page->data['ManageUserMoneyTransactionResultView']['incrMoney'] = $trans->getIncrMoney() / 100; $page->data['ManageUserMoneyTransactionResultView']['decrMoney'] = $trans->getDecrMoney() / 100; $page->addView('manageUserMoney/ManageUserMoneyTransactionResultView'); } } catch (Exception $ex) { ManageUserMoneyController::buildEnterTransactionView($page, true); $page->data['ManageUserMoneyEnterTransactionView']['errMsgs']['global'] = '<h2 class="error_message" id="enter_transaction_form_error_message">Kan transactie niet registreren, probeer opnieuw.</h2>'; } } else { ManageUserMoneyController::buildEnterTransactionView($page, true); $page->data['ManageUserMoneyEnterTransactionView']['errMsgs'] = array_merge($page->data['ManageUserMoneyEnterTransactionView']['errMsgs'], $errMsgs); } $page->showWithMenu(); }
public static function post() { $page = new Page(); $page->data['title'] = 'Gebruiker toevoegen'; //Validate input $formTopViewErrMsgs = UserDataFormTopViewValidator::validate($_POST); $formPasswordViewErrMsgs = UserDataFormPasswordViewValidator::validate($_POST); $formMiddleViewErrMsgs = UserDataFormMiddleViewValidator::validate($_POST); //No error means we create a user and password salt if (empty($formTopViewErrMsgs) && empty($formPasswordViewErrMsgs) && empty($formMiddleViewErrMsgs)) { $passwordSalt = Random::getGuid(); $user = new User(); $user->email = $_POST['email']; $user->firstName = ucwords($_POST['first_name']); $user->lastName = ucwords($_POST['last_name']); $user->passwordHash = hash_pbkdf2("sha256", $_POST['password'], $passwordSalt, SecurityConfig::N_PASSWORD_HASH_ITERATIONS); $user->street = ucwords($_POST['street']); $user->houseNumber = $_POST['house_number']; $user->city = ucwords($_POST['city']); $user->postalCode = $_POST['postal_code']; $user->country = ucwords($_POST['country']); $user->phone = $_POST['phone']; $user->dateOfBirth = $_POST['date_of_birth']; //Add the user try { $userId = UserDB::addUser($user, $passwordSalt, $_POST['card_number']); $page->addView('addRenewUser/addUser/SuccessfullyAddedView'); //Send welcome mail try { $failedEmails = Email::sendEmails('WelcomeNewMember.html', 'JH DE Stip - Welkom', EmailConfig::FROM_ADDRESS, [$user], null); //If failedEmails is not empty the mail was not sent if (!empty($failedEmails)) { $page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] = 'Kan welkomstmail niet verzenden.'; $page->addView('error/ErrorMessageNoDescriptionNoLinkView'); } } catch (Exception $ex) { $page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] = 'Kan welkomstmail niet verzenden.'; $page->addView('error/ErrorMessageNoDescriptionNoLinkView'); } //Add money to user's card try { $addedUser = UserDB::getFullUserById($userId); $executingBrowserName = BrowserDB::getBrowserById($_SESSION['Stippers']['browser']->browserId)->name; $trans = new MoneyTransaction(null, $addedUser->userId, 0, AddOrRenewUserConfig::NEW_OR_RENEWED_USER_BONUS, 0, 0, true, null, $executingBrowserName, null); MoneyTransactionDB::addTransaction($addedUser, $trans); } catch (Exception $ex) { if (isset($page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'])) { $page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] .= ' Kan het saldo van het account niet verhogen, probeer dit handmatig te doen.'; } else { $page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] = 'Kan het saldo van het account niet verhogen, probeer dit handmatig te doen.'; } $page->addView('error/ErrorMessageNoDescriptionNoLinkView'); } } catch (UserDBException $ex) { AddUserController::buildAddUserPage($page, true); if ($ex->getCode() == UserDBException::EMAILALREADYEXISTS) { $page->data['UserDataFormTopView']['errMsgs']['global'] = '<h2 class="error_message" id="user_data_form_error_message">Dit e-mailadres is al in gebruik.</h2>'; } elseif ($ex->getCode() == UserDBException::CARDALREADYUSED) { $page->data['UserDataFormTopView']['errMsgs']['global'] = '<h2 class="error_message" id="user_data_form_error_message">Dit kaartnummer is al in gebruik.</h2>'; } else { $page->data['UserDataFormTopView']['errMsgs']['global'] = '<h2 class="error_message" id="user_data_form_error_message">Kan gebruiker niet toevoegen, probeer het opnieuw.</h2>'; } } catch (Exception $ex) { AddUserController::buildAddUserPage($page, true); $page->data['UserDataFormTopView']['errMsgs']['global'] = '<h2 class="error_message" id="user_data_form_error_message">Kan gebruiker niet toevoegen, probeer het opnieuw.</h2>'; } } else { AddUserController::buildAddUserPage($page, true); $page->data['UserDataFormTopView']['errMsgs'] = array_merge($page->data['UserDataFormTopView']['errMsgs'], $formTopViewErrMsgs); $page->data['UserDataFormPasswordView']['errMsgs'] = array_merge($page->data['UserDataFormPasswordView']['errMsgs'], $formPasswordViewErrMsgs); $page->data['UserDataFormMiddleView']['errMsgs'] = array_merge($page->data['UserDataFormMiddleView']['errMsgs'], $formMiddleViewErrMsgs); } $page->showWithMenu(); }
public static function post() { if (isset($_POST['save'])) { $page = new Page(); $page->data['title'] = 'Gebruiker hernieuwen'; //Validate input $formTopViewErrMsgs = UserDataFormTopViewValidator::validate($_POST); $formMiddleViewErrMsgs = UserDataFormMiddleViewValidator::validate($_POST); //No error means we create a user and password salt if (empty($formTopViewErrMsgs) && empty($formMiddleViewErrMsgs)) { $newUser = new User(); $newUser->userId = $_SESSION['Stippers']['RenewUser']['user']->userId; $newUser->email = $_POST['email']; $newUser->passwordHash = $_SESSION['Stippers']['RenewUser']['user']->passwordHash; $newUser->firstName = ucwords($_POST['first_name']); $newUser->lastName = ucwords($_POST['last_name']); $newUser->street = ucwords($_POST['street']); $newUser->houseNumber = $_POST['house_number']; $newUser->city = ucwords($_POST['city']); $newUser->postalCode = $_POST['postal_code']; $newUser->country = ucwords($_POST['country']); $newUser->phone = $_POST['phone']; $newUser->dateOfBirth = $_POST['date_of_birth']; $newUser->balance = $_SESSION['Stippers']['RenewUser']['user']->balance; $newUser->isAdmin = $_SESSION['Stippers']['RenewUser']['user']->isAdmin; $newUser->isHintManager = $_SESSION['Stippers']['RenewUser']['user']->isHintManager; $newUser->isUserManager = $_SESSION['Stippers']['RenewUser']['user']->isUserManager; $newUser->isBrowserManager = $_SESSION['Stippers']['RenewUser']['user']->isBrowserManager; $newUser->isMoneyManager = $_SESSION['Stippers']['RenewUser']['user']->isMoneyManager; $newUser->creationTime = $_SESSION['Stippers']['RenewUser']['user']->creationTime; //Renew the user try { UserDB::renewMembership($_SESSION['Stippers']['RenewUser']['user'], $newUser, $_POST['card_number']); $page->addView('addRenewUser/renewUser/SuccessfullyRenewedView'); //Send welcome mail try { $failedEmails = Email::sendEmails('WelcomeOldMember.html', 'JH DE Stip - Welkom', EmailConfig::FROM_ADDRESS, [$newUser], null); //If failedEmails is not empty the mail was not sent if (!empty($failedEmails)) { $page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] = 'Kan welkomstmail niet verzenden.'; $page->addView('error/ErrorMessageNoDescriptionNoLinkView'); } } catch (Exception $ex) { $page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] = 'Kan welkomstmail niet verzenden.'; $page->addView('error/ErrorMessageNoDescriptionNoLinkView'); } //Add money to user's card try { $executingBrowserName = BrowserDB::getBrowserById($_SESSION['Stippers']['browser']->browserId)->name; $trans = new MoneyTransaction(null, $newUser->userId, $newUser->balance, AddOrRenewUserConfig::NEW_OR_RENEWED_USER_BONUS, 0, 0, true, null, $executingBrowserName, null); MoneyTransactionDB::addTransaction($newUser, $trans); } catch (Exception $ex) { if (isset($page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'])) { $page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] .= ' Kan het saldo van het account niet verhogen, probeer dit handmatig te doen.'; } else { $page->data['ErrorMessageNoDescriptionNoLinkView']['errorTitle'] = 'Kan het saldo van het account niet verhogen, probeer dit handmatig te doen.'; } $page->addView('error/ErrorMessageNoDescriptionNoLinkView'); } } catch (UserDBException $ex) { if ($ex->getCode() == UserDBException::USERALREADYMEMBER) { $page->addView('addRenewUser/renewUser/UserAlreadyMemberView'); } elseif ($ex->getCode() == UserDBException::USEROUTOFDATE) { $page->data['ErrorMessageWithDescriptionWithLinkView']['errorTitle'] = 'Gebruiker niet hernieuwd'; $page->data['ErrorMessageWithDescriptionWithLinkView']['errorDescription'] = 'Iemand anders heeft de gebruiker in tussentijd al gewijzigd.'; $page->data['ErrorMessageWithDescriptionWithLinkView']['tryAgainUrl'] = $_SERVER['REQUEST_URI']; $page->addView('error/ErrorMessageWithDescriptionWithLinkView'); } else { RenewUserController::buildRenewUserPage($page, true); if ($ex->getCode() == UserDBException::EMAILALREADYEXISTS) { $page->data['UserDataFormTopView']['errMsgs']['global'] = '<h2 class="error_message" id="user_data_form_error_message">Dit e-mailadres is al in gebruik.</h2>'; } elseif ($ex->getCode() == UserDBException::CARDALREADYUSED) { $page->data['UserDataFormTopView']['errMsgs']['global'] = '<h2 class="error_message" id="user_data_form_error_message">Dit kaartnummer is al in gebruik.</h2>'; } else { $page->data['UserDataFormTopView']['errMsgs']['global'] = '<h2 class="error_message" id="user_data_form_error_message">Kan gebruiker niet hernieuwen, probeer het opnieuw.</h2>'; } } } catch (Exception $ex) { RenewUserController::buildRenewUserPage($page, true); $page->data['UserDataFormTopView']['errMsgs']['global'] = '<h2 class="error_message" id="user_data_form_error_message">Kan gebruiker niet hernieuwen, probeer het opnieuw.</h2>'; } } else { RenewUserController::buildRenewUserPage($page, true); $page->data['UserDataFormTopView']['errMsgs'] = array_merge($page->data['UserDataFormTopView']['errMsgs'], $formTopViewErrMsgs); $page->data['UserDataFormMiddleView']['errMsgs'] = array_merge($page->data['UserDataFormMiddleView']['errMsgs'], $formMiddleViewErrMsgs); } $page->showWithMenu(); } else { header('Location: renewusersearch', true, 303); } }