/var/www/hkosl.com/imusiccircle/webadmin/evaluation_form.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<?php
    $page_settings 
= array(
        
'formid'     => 'student'// for permission
        
'section'    => 'Master'// parent/page title
        
'subsection' => 'Evaluation Form'// page title
        
'domain'     => 'evaluation_form'// table/model name
        
'access'     => 'GNr'// for permission
    
);

    require_once 
"check_login.php";

    if (empty(
$_REQUEST["order_id"])) {
        
header("Location: order_index.php");
        exit;
    }

    
$order      get_order((int)$_GET["order_id"]);
    
$sql        "select count(*) as tutored_num from order_detail where order_id = ? and tutor_status = ?";
    
$parameters = array($order["id"], 1);
    
$result     bind_pdo($sql$parameters"selectone");

    
/*var_dump($result["tutored_num"],$order["course_count"]);
    exit;*/
    /*if ($result["tutored_num"] != $order["course_count"]) {
        header("Location: order_index.php");
        exit;
    }*/

    
$sql                    "select * from evaluation_form_answer where cmsloginid = ? and order_id = ? and status = ? and deleted = ?";
    
$parameters             = array($_SESSION["cmsloginid"], (int)$_GET["order_id"], 10);
    
$evaluation_form_answer bind_pdo($sql$parameters"selectone");

    
//no need this
    /*if ($_SESSION["is_student"] == 1) {
        if (!empty($evaluation_form_answer) || $order["studentmain_id"] != $_SESSION["student_login"]) {
            header("Location: order_index.php");
            exit;
        }
    }*/

    
if ($_POST) {
        if (
$_POST["action"] == "ADD") {
            
$message "";

            
$sql        "select * from evaluation_form_question where form_id = ? and status = ? and deleted = ?";
            
$parameters = array(110);
            
$result     bind_pdo($sql$parameters"selectall");
            foreach (
$result as $row) {
                if (empty(
$_POST["ans"][$row["id"]]) && $row["required"] == 1) {
                    
$message "請填寫所有含有 * 的問題。";
                }
            }

            if (!empty(
$message)) {
                echo 
"<script>alert('" $message "');history.back();</script>";
                exit;
            }

            foreach (
$_POST["ans"] as $question_id => $ans) {
                
$sql        "insert into evaluation_form_answer (createby, createdate, lastupby, lastupdate, question_id, answer, studentmain_id, cmsloginid, order_id) value (?,?,?,?,?,?,?,?,?)";
                
$parameters = array($_SESSION["cmsloginid"], date("Y-m-d H:i:s"), $_SESSION["cmsloginid"], date("Y-m-d H:i:s"), $question_id$ans$_SESSION["student_login"], $_SESSION["cmsloginid"], $_POST["order_id"]);
                
bind_pdo($sql$parameters);
            }

            
header("Location: order_index.php");
            exit;
        }
    }

    
$sql                      "select * from evaluation_form_question where deleted = ? and status = ? and form_id = ? order by sort ASC";
    
$parameters               = array(011);
    
$evaluation_form_question bind_pdo($sql$parameters"selectall");


?>
<!DOCTYPE html>
<html>
<head>
    <?php require_once "_html_head.php"?>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <?php require_once "_header.php"?>
    <?php require_once "_menu.php"?>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                <?= _lang($page_settings['subsection']) ?>
                <small>
                    <?= _lang("Update"?>
                </small>
            </h1>
            <ol class="breadcrumb">
                <li>
                    <?= _lang("Home"?>
                </li>
                <li><a href="<?= $page_settings['domain'?>_index.php"><i class="fa"></i>
                        <?= _lang($page_settings['subsection']) ?>
                    </a></li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">

            <!-- Your Page Content Here -->

            <!-- main form -->
            <form action="<?= $page_settings['domain'?>.php" id="myform" class="myform" method="POST" enctype="multipart/form-data">

                <input type="hidden" name="order_id" value="<?= (int)$_GET["order_id"?>"/>
                <input type="hidden" name="action" value="ADD"/>

                <div class="row">
                    <div class="col-xs-12">
                        <div class="box">
                            <div class="box-header">
                                <div class="col-md-8">
                                    <div class="btn-group">

                                        <a href="order_index.php?msg=4" class="btn btn-default"><i class="fa fa-chevron-left" aria-hidden="true"></i>
                                            <?= _lang('Back'?>
                                        </a>
                                        <?php if($_SESSION["is_student"] == && $order["studentmain_id"] == $_SESSION["student_login"]){  if(empty($evaluation_form_answer)){ ?>
                                            <button type="submit" class="btn btn-primary" id="LiSaveBtn">
                                                <i class="fa fa-floppy-o" aria-hidden="true"></i> <?= _lang('Save'?>
                                            </button>
                                        <?php } else { ?>
                                            <button type="button" class="btn btn-success" id="LiSaveBtn">
                                                <i class="fa fa-floppy-o" aria-hidden="true"></i> <?= _lang('Completed'?>
                                            </button>
                                        <?php } } ?>

                                    </div>
                                </div>

                            </div>

                            <!-- /.box-header -->
                            <div class="box-body">

                                <div class="scroll_left_right_container">
                                    <div class="scroll_left_right"><img src="../img/scroll_left_right.png"></div>
                                </div>

                                <div class="table-responsive">

                                    <table class="table">
                                        <tr>
                                            <th></th>
                                            <th><?= _lang("Evaluation Form"?></th>
                                            <th class="tc">1</th>
                                            <th class="tc">2</th>
                                            <th class="tc">3</th>
                                            <th class="tc">4</th>
                                            <th class="tc">5</th>
                                        </tr>

                                        <tr>
                                            <th></th>
                                            <th></th>
                                            <th class="tc">非常反對</th>
                                            <th class="tc">反對</th>
                                            <th class="tc">一般</th>
                                            <th class="tc">贊同</th>
                                            <th class="tc">非常贊同</th>
                                        </tr>

                                        <?php $score 0; foreach ($evaluation_form_question as $row) {
                                            
$sql                    "select answer from evaluation_form_answer where question_id = ? and order_id = ? and status = ? and deleted = ?";
                                            
$parameters             = array($row["id"], (int)$_GET["order_id"], 10);
                                            
$evaluation_form_answer bind_pdo($sql$parameters"selectone");

                                            
?>
                                            <tr>
                                                <td><?= $row["sort"?></td>
                                                <td>
                                                    <span class="<?= $row["required"] == "required_field" "" ?>"><?= $row["question"?></span>
                                                </td>
                                                <?php if ($row["type"] == "RADIO_BUTTON") {
                                                    
$score += $evaluation_form_answer["answer"];

                                                    for(
$i 1$i <= 5$i++){
                                                    
?>
                                                    <td class="tc">
                                                        <input type="radio" name="ans[<?= $row["id"?>]" value="<?=$i?><?=(!empty($evaluation_form_answer["answer"]) && $evaluation_form_answer["answer"] == $i)?"checked":""?>>
                                                    </td>

                                                <?php } } else if ($row["type"] == "TEXT") { ?>
                                                    <td class="tc" colspan="5">
                                                        <input type="text" name="ans[<?= $row["id"?>]" style="width: 79%;" value="<?=!empty($evaluation_form_answer["answer"])?$evaluation_form_answer["answer"]:""?>" >
                                                    </td>
                                                <?php ?>
                                            </tr>

                                            <?php if( ($row["id"] == 12 || $row["id"] == 22 )&& (!empty($evaluation_form_answer) && ($_SESSION["cmsrole"] == "super_admin") || $_SESSION["cmsrole"] == "admin")){ ?>
                                                <tr>
                                                    <td colspan="2" class="tr"></td>
                                                    <td colspan="5" class="tc">總評分: <?=round($score/5)?></td>
                                                </tr>
                                            <?php $score 0; } ?>

                                            <?php if ($row["type"] == "TEXT" && $row["id"] == 12) { ?>
                                                <tr>
                                                    <td colspan="8"></td>
                                                </tr>
                                                <tr>
                                                    <td></td>
                                                    <td colspan="7" class="tl">如在音樂室上課,請加以填寫以下欄目,謝謝</td>
                                                </tr>
                                            <?php ?>
                                        <?php ?>

                                    </table>

                                    <label style="color: red;"><?= lang("* Required Field"?></label>
                                </div>
                            </div>
                            <!-- /.box-body -->
                        </div>
                        <!-- /.box -->
                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </form>

            <!-- End of Your Page Content Here -->

        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->

    <?php require_once "_footer.php"?>
    <?php require_once "_aside.php"?>
</div>
<!-- ./wrapper -->

<!-- REQUIRED JS SCRIPTS -->
<?php require_once "_html_script.php"?>

<script type="text/javascript">
    $(function () {
        <?php if(!empty($evaluation_form_answer)){ ?>
            $("input").attr("disabled", true);
        <?php ?>
    });
</script>
</body>

</html>