Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Template Name: Inschrijven */
- $context = Timber::get_context();
- $post = new TimberPost();
- $context['post'] = $post;
- if(isset($_GET['cursus_name'])){
- $context['cursus_name'] = $_GET['cursus_name'];
- // dd($context['cursus_name']);
- }
- if(isset($_GET['workshop_name']) && isset($_GET['date'])){
- $context['workshop_name'] = 'Naam: '. $_GET['workshop_name']. ' ,Datum: '.$_GET['date'];
- }
- $args = [
- 'post_type' => 'course',
- 'posts_per_page' => -1,
- ];
- //Get courses for form
- $context['courses'] = Timber::get_posts($args);
- //Sets error array for form
- $context['errors'] = [];
- //Validation for form
- if(isset($_POST['submit'])){
- if(empty($_POST['titulature'])){
- $context['errors']['titulature'] = 'Vul uw titelatuur in';
- } else {
- $context['form']['titulature'] = $_POST['titulature'];
- }
- if(empty($_POST['initials'])){
- $context['errors']['initials'] = 'Vul uw voorletters in';
- } else {
- $context['form']['initials'] = $_POST['initials'];
- }
- if(empty($_POST['firstName'])){
- $context['errors']['firstName'] = 'Vul uw voornaam in';
- } else {
- $context['form']['firstName'] = $_POST['firstName'];
- }
- if(empty($_POST['lastName'])){
- $context['errors']['lastName'] = 'Vul uw achternaam in';
- } else {
- $context['form']['lastName'] = $_POST['lastName'];
- }
- if(empty($_POST['birthDate'])){
- $context['errors']['birthDate'] = 'Vul uw geboortedatum in';
- } else {
- $context['form']['birthDate'] = $_POST['birthDate'];
- }
- if(empty($_POST['birthPlace'])){
- $context['errors']['birthPlace'] = 'Vul uw geboorteplaats in';
- } else {
- $context['form']['birthPlace'] = $_POST['birthPlace'];
- }
- if(empty($_POST['street'])){
- $context['errors']['street'] = 'Vul uw straat in';
- } else {
- $context['form']['street'] = $_POST['street'];
- }
- if(empty($_POST['houseNumber'])){
- $context['errors']['houseNumber'] = 'Vul uw huisnummer in';
- } else {
- $context['form']['houseNumber'] = $_POST['houseNumber'];
- }
- if(empty($_POST['addition'])){
- $context['form']['addition'] = '';
- } else {
- $context['form']['addition'] = $_POST['addition'];
- }
- if(empty($_POST['zipcode'])){
- $context['errors']['zipcode'] = 'Vul uw postcode in';
- } else {
- $context['form']['zipcode'] = $_POST['zipcode'];
- }
- if(empty($_POST['place'])){
- $context['errors']['place'] = 'Vul uw plaats in';
- } else {
- $context['form']['place'] = $_POST['place'];
- }
- if(empty($_POST['phoneNumber'])){
- $context['errors']['phoneNumber'] = 'Vul uw telefoonnnummer in';
- } else {
- $context['form']['phoneNumber'] = $_POST['phoneNumber'];
- }
- if(empty($_POST['email'])){
- $context['errors']['email'] = 'Vul uw email in';
- } else {
- $context['form']['email'] = $_POST['email'];
- }
- //1
- // if (empty($_POST['course']) && empty($_POST['cursus']) && empty($_POST['workshop'])) {
- // $context['errors']['schooling'] = 'Je moet minimaal 1 opleiding, cursus of workshop selecteren';
- // }
- // if (!empty($_POST['course']) && empty($_POST['payment'])) {
- // $context['errors']['payment'] = 'Voor een opleiding dient u een betalingskeuze te maken.';
- // }
- // $context['form']['payment'] = $_POST['payment'] ?: '';
- // $context['form']['course'] = $_POST['course'] ?: '';
- // $context['form']['cursus'] = $_POST['cursus'] ?: '';
- // $context['form']['workshop'] = $_POST['workshop'] ?: '';
- //2
- // if (empty($_POST['course']) && empty($_POST['cursus']) && empty($_POST['workshop'])) {
- // $context['errors']['schooling'] = 'Je moet minimaal 1 opleiding, cursus of workshop selecteren';
- // }
- // if (!empty($_POST['course']) && empty($_POST['payment'])) {
- // $context['errors']['payment'] = 'Voor een opleiding dient u een betalingskeuze te maken.';
- // }
- // else if (!empty($_POST['course']) && !empty($_POST['payment'])) {
- // $context['form']['payment'] = $_POST['payment'];
- // $context['form']['course'] = $_POST['course'];
- // }
- // if (!empty($_POST['cursus'])) {
- // $context['form']['cursus'] = $_POST['cursus'];
- // }
- // if (!empty($_POST['workshop'])) {
- // $context['form']['workshop'] = $_POST['workshop'];
- // }
- $context['form']['payment'] = $_POST['payment'] ?: '';
- $context['form']['course'] = $_POST['course'] ?: '';
- $context['form']['cursus'] = $_POST['cursus'] ?: '';
- $context['form']['workshop'] = $_POST['workshops'] ?: '';
- if(!empty($_POST['course'])){
- if(empty($_POST['payment'])){
- $context['errors']['payment'] = 'Voor een opleiding dient u een betalingswijze te kiezen.';
- }
- }
- elseif(empty($_POST['cursus']) && empty($_POST['workshops'])){
- $context['errors']['schooling'] = 'Je moet minimaal 1 opleiding, cursus of workshop selecteren';
- }
- if(empty($_POST['comment'])){
- $context['form']['comment'] = '-';
- } else {
- $context['form']['comment'] = $_POST['comment'];
- }
- if(empty($_POST['terms'])){
- $context['errors']['terms'] = 'Om u te kunnen inschrijven moet u akkoord gaan met de algemene voorwaardem.';
- } else {
- $context['form']['terms'] = implode(',',$_POST['terms']);
- }
- if(count($context['errors']) == 0){
- sendTemplateMail('mail/signup.twig', $context['form'], 'Uw inschrijving', 'info@school4us.nl', $context['form']['email']);
- sendTemplateMail('mail/signup_client.twig', $context['form'], 'Inschrijving van '.$context['form']['firstName'].' '.$context['form']['lastName'], $context['form']['email'], 'info@school4us.nl');
- $context['success'] = 'Uw mail is verstuurd.';
- }
- }
- Timber::render('pages/page-signup.twig', $context );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement