Main.php 2.28 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
10
11
        // Select a random contact
        $rand_id = rand(0, count($f3->get('contacts'))-1);
        $f3->set('contact', $f3->get('contacts')[$rand_id]);
Mindiell's avatar
Mindiell committed
12
13
14
        $f3->set('block_content','home.html');
    }

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

nepski's avatar
nepski committed
27
28
            $contact_id = $f3->get('POST.contact_id');
            $f3->set("contact_id", $contact_id);
nepski's avatar
use API    
nepski committed
29

nepski's avatar
nepski committed
30
31
            //TODO: create call
            //TODO: start call
nepski's avatar
use API    
nepski committed
32

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

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

nepski's avatar
nepski committed
47
48
49
    /*
     * Feedback SIP function
     */
nepski's avatar
nepski committed
50
    function feedbacksip($f3, $args) {
nepski's avatar
nepski committed
51

nepski's avatar
nepski committed
52
    }
nepski's avatar
nepski committed
53
54
55
56
57
58
59
60
61
62

    /*
     * 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
63
            $f3->set('contact', Api::get_contact()); //$args['id']
nepski's avatar
nepski committed
64
65
66
67
68
69
70
71
72
73
74

            $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
75
76
77
78
79
    function contactslist($f3, $args) {
        $f3->set('contacts', Api::get_contacts()['contacts']);

        $f3->set('block_content', 'contactslist.html');
    }
80
81
82
83
84

    function salespitch($f3, $args) {
        $f3->set('block_content', 'salespitch.html');
    }

Mindiell's avatar
Mindiell committed
85
};