Main.php 1.34 KB
Newer Older
Mindiell's avatar
Mindiell committed
1 2 3 4
<?php

class Main extends Controller {
    /*
Mindiell's avatar
Mindiell committed
5 6 7 8 9
     * Home page
     * Presents campaign information and a random Contact
     */
    function home($f3,$args) {
        $f3->set('campaign', Api::get_campaign());
10
        $f3->set('contact', Api::get_contact());
Mindiell's avatar
Mindiell committed
11 12 13
        $f3->set('block_content','home.html');
    }

nepski's avatar
nepski committed
14 15 16 17 18 19
    /*
     * Feedback page
     * Form for a feedback after a call
     * GET: show the form
     * POST: send the form to the campaign API and show thank you
     */
20
    function feedbackform($f3, $args) {
nepski's avatar
nepski committed
21
        //GET
nepski's avatar
nepski committed
22
        if ($f3->get('VERB') == 'GET'){
nepski's avatar
nepski committed
23 24 25
            $categories = Api::get_feedback_categories()['categories'];
            $f3->set('feedback_categories', $categories);

nepski's avatar
use API  
nepski committed
26 27
            $f3->set("contact_id", 42);

nepski's avatar
nepski committed
28 29
            //TODO: create call
            //TODO: start call
nepski's avatar
use API  
nepski committed
30

nepski's avatar
nepski committed
31 32
            $f3->set('block_content', 'feedbackform.html');
        }
nepski's avatar
nepski committed
33
        //POST
nepski's avatar
nepski committed
34
        elseif ($f3->get('VERB') == 'POST'){
nepski's avatar
use API  
nepski committed
35 36
            $contact_id = $f3->get('POST.contact_id');
            $feedback = $f3->get('POST.feedback');
nepski's avatar
nepski committed
37
            $category = $f3->get('POST.feedback_category');
nepski's avatar
use API  
nepski committed
38

nepski's avatar
nepski committed
39
            //send feedback to campaign
nepski's avatar
nepski committed
40
            $f3->set('post_feedback_result', Api::post_feedback($contact_id, $feedback, $category));
nepski's avatar
nepski committed
41 42
            $f3->set('block_content', 'thankyou.html');
        }
43
    }
nepski's avatar
nepski committed
44

nepski's avatar
nepski committed
45
    function feedbacksip($f3, $args) {
nepski's avatar
nepski committed
46

nepski's avatar
nepski committed
47
    }
Mindiell's avatar
Mindiell committed
48 49
};