/var/www/(Del)pathways.org.hk/MIS20140127/old20140314/student_invoice/ajax_invoice.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
<?php
include_once '../include/DBConnect.php';
$type=$_POST['type'];
$stu_id=$_POST['linking_id'];
if(
$type==1){
    
$query1 "Select ss.stu_subsidy_id,s.percent as sum_p from student_subsidy as ss, subsidy as s where ss.subsidy_id = s.subsidy_id and ss.deleted=0 and s.deleted=0
                            and s.actived=1 and ss.actived=1 and ss.stu_subsidy_id='
$stu_id'";
    
$result $dbh->query($query1);
    if(
$result->rowcount()==0){
        
$percent=0;
    }
    else{
        
$result->setFetchMode(PDO::FETCH_OBJ);
        
$row $result->fetch();
        
$percent $row->sum_p;
        
//$percent=  doubleval($percent);
    
}
    echo 
$percent;
}
else{
    if(
$type==2){
        
$query "Select la.package_discount from event as e, lesson_attendance as la,student_grade as sg,grade as g,
                        student as stu,lesson as l,event_lesson as el where e.event_id=el.event_id and
                        el.lesson_id=l.lesson_id and l.lesson_id=la.lesson_id and sg.student_grade_id=stu.linking_id and sg.grade_id=g.grade_id and stu.root_id=la.stu_linking_id and sg.student_grade_id=stu.linking_id and sg.grade_id=g.grade_id
                        and e.deleted=0 and e.actived=1 and sg.deleted=0 and sg.actived=1 and g.deleted=0 and g.actived=1 and la.deleted=0 and la.actived=1 and stu.deleted=0 and stu.actived=1
                        and l.deleted=0 and l.actived=1 and el.deleted=0 and el.actived=1 and stu.linking_id='
$stu_id'";
        
$result $dbh->query($query); //get invoice data
        
$result->setFetchMode(PDO::FETCH_OBJ);
        
$row $result->fetch();
        
$package_discount=$row->package_discount;
        echo 
$package_discount;
    }
    else{
        if(
$type==3){
            echo 
'0';
        }
        else{
            echo 
'<script>alert("Error.")</script>';
        }
    }
}