/var/www/(Del)pathways.org.hk/MIS20140127/old20140414/student/ajax_edit_stu.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
<script>
    $(document).ready(function() {
        var val = [];
        $('.subsidy_get:checked').each(function(i) {
            val[i] = $(this).val();
            //alert(val[i]);
        });
        $.ajax({
            type: "POST",
            url: "ajax_subsidy_get.php",
            data: {
                subsidy: val
            },
            cache: false,
            success: function(html) {
                $("#subsidy_percent").val(html);
            }
        });
    });
    $(document).on('click', '.subsidy_get', function() {
        var val = [];
        $('.subsidy_get:checked').each(function(i) {
            val[i] = $(this).val();
            //alert(val[i]);
        });
        $.ajax({
            type: "POST",
            url: "ajax_subsidy_get.php",
            data: {
                subsidy: val
            },
            cache: false,
            success: function(html) {
                $("#subsidy_percent").val(html);
            }
        });
    });
</script>
<?php
include_once '../include/DBConnect.php';
$subsidy $_POST['subsidy'];
$linking_id $_POST['linking_id'];
$check FALSE;
$action=$_POST['action'];
if (
$action=="View") {
    if (
$subsidy != 1) {
        
$query "Select Subsidy_ID as s,title,percent from subsidy where actived='1' and deleted='0' and subsidy_type='$subsidy'";
        
$result $dbh->query($query);
        
$result->setFetchMode(PDO::FETCH_OBJ);
        while (
$row $result->fetch()) {
            
$query1 "Select subsidy_id from student_subsidy where actived='1' and deleted='0' and stu_subsidy_id='$linking_id'";
            
$result1 $dbh->query($query1);
            
$result1->setFetchMode(PDO::FETCH_OBJ);
            while (
$row1 $result1->fetch()) {
                if (
$row1->subsidy_id == $row->s)
                    
$check TRUE;
            }
            if (
$check == TRUE) {
                echo 
'
        <input type="radio" name="subsidy_get[]" class="subsidy_get" value="' 
$row->'"checked disabled="true">
        ' 
$row->title '
        <br>'
;
            } else {
                echo 
'
        <input type="radio" name="subsidy_get[]" class="subsidy_get" value="' 
$row->'" disabled="true">
        ' 
$row->title '
        <br>'
;
            }
            
$check FALSE;
        }
    }
} else {
    if (
$subsidy != 1) {
        
$query "Select Subsidy_ID as s,title,percent from subsidy where actived='1' and deleted='0' and subsidy_type='$subsidy'";
        
$result $dbh->query($query);
        
$result->setFetchMode(PDO::FETCH_OBJ);
        while (
$row $result->fetch()) {
            
$query1 "Select subsidy_id from student_subsidy where actived='1' and deleted='0' and stu_subsidy_id='$linking_id'";
            
$result1 $dbh->query($query1);
            
$result1->setFetchMode(PDO::FETCH_OBJ);
            while (
$row1 $result1->fetch()) {
                if (
$row1->subsidy_id == $row->s)
                    
$check TRUE;
            }
            if (
$check == TRUE) {
                echo 
'
        <input type="radio" name="subsidy_get[]" class="subsidy_get" value="' 
$row->'"checked/>
        ' 
$row->title '
        <br>'
;
            } else {
                echo 
'
        <input type="radio" name="subsidy_get[]" class="subsidy_get" value="' 
$row->'"/>
        ' 
$row->title '
        <br>'
;
            }
            
$check FALSE;
        }
    }
}