Main.php 2.53 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
     * Home page
     * Presents campaign information and a random Contact
     */
    function home($f3,$args) {
9
        // Select a random contact
10
        //TODO: use weight for random
11
        $rand_id = rand(0, count($f3->get('contacts'))-1);
12 13
        $contacts = $f3->get('contacts');
        $f3->set('contact', $contacts[$rand_id]);
14
        $f3->set('random', rand(0, 2));
Mindiell's avatar
Mindiell committed
15 16 17
        $f3->set('block_content','home.html');
    }

nepski's avatar
nepski committed
18 19 20 21 22 23
    /*
     * 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
     */
24
    function feedbackform($f3, $args) {
nepski's avatar
nepski committed
25
        //GET
nepski's avatar
nepski committed
26
        if ($f3->get('VERB') == 'GET'){
27 28
            $categories = Api::get_feedback_categories();
            $f3->set('feedback_categories', $categories['categories']);
nepski's avatar
nepski committed
29

nepski's avatar
nepski committed
30 31
            $contact_id = $f3->get('POST.contact_id');
            $f3->set("contact_id", $contact_id);
nepski's avatar
use API  
nepski committed
32

nepski's avatar
nepski committed
33 34
            //TODO: create call
            //TODO: start call
nepski's avatar
use API  
nepski committed
35

nepski's avatar
nepski committed
36 37
            $f3->set('block_content', 'feedbackform.html');
        }
nepski's avatar
nepski committed
38
        //POST
nepski's avatar
nepski committed
39
        elseif ($f3->get('VERB') == 'POST'){
nepski's avatar
use API  
nepski committed
40 41
            $contact_id = $f3->get('POST.contact_id');
            $feedback = $f3->get('POST.feedback');
nepski's avatar
nepski committed
42
            $category = $f3->get('POST.feedback_category');
nepski's avatar
use API  
nepski committed
43

nepski's avatar
nepski committed
44
            //send feedback to campaign
nepski's avatar
nepski committed
45
            $f3->set('post_feedback_result', Api::post_feedback($contact_id, $feedback, $category));
nepski's avatar
nepski committed
46 47
            $f3->set('block_content', 'thankyou.html');
        }
48
    }
nepski's avatar
nepski committed
49

nepski's avatar
nepski committed
50 51 52
    /*
     * Feedback SIP function
     */
nepski's avatar
nepski committed
53
    function feedbacksip($f3, $args) {
nepski's avatar
nepski committed
54

nepski's avatar
nepski committed
55
    }
nepski's avatar
nepski committed
56 57 58 59 60 61 62 63 64 65

    /*
     * call Page
     * Form to call
     * GET: show the form
     * POST: send the form and GET feedbackform
     */
    function call($f3, $args) {
        //GET
        if ($f3->get('VERB') == 'GET') {
nepski's avatar
nepski committed
66
            $f3->set('contact', Api::get_contact()); //$args['id']
nepski's avatar
nepski committed
67 68 69 70 71 72 73 74 75 76 77

            $f3->set('block_content', 'call.html');
        }
        //POST
        elseif ($f3->get('VERB') == 'POST'){
            //GET feedbackform
            $f3->set('VERB', 'GET');
            $this->feedbackform($f3, $args);
        }
    }

nepski's avatar
nepski committed
78
    function contactslist($f3, $args) {
79 80
        $contacts = Api::get_contacts();
        $f3->set('contacts', $contacts);
81
        $f3->set('random', 2);
nepski's avatar
nepski committed
82 83 84

        $f3->set('block_content', 'contactslist.html');
    }
85

86 87 88 89 90
    function argumentation($f3, $args) {
        $arguments = Api::get_arguments();
        $f3->set('arguments', $arguments);

        $f3->set('block_content', 'argumentation.html');
91 92
    }

Mindiell's avatar
Mindiell committed
93
};