/var/www/(Del)pathways.org.hk/MIS20140127/old20140407/System/Prog_Subject_SQL.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
<?php

require_once '../include/DBConnect.php';

function 
SearchList() {
    global 
$dbh;
    
$sth $dbh->query("Select prog_subj_id,`program_code`,`sub_code`,`primary_individual_price`, `primary_group_price`, `primary_package_price`, `    secondary_individual_price`, `secondary_group_price`, `secondary_package_price` from prog_subject ps,program p, subject s 
where ps.actived = 1 and ps.deleted = 0 and p.actived = 1 and p.deleted = 0 and s.actived = 1 and s.deleted = 0 and ps.program_id = p.program_id and ps.subject_id = s.subject_id order by prog_subj_id"
);
    return 
$sth->fetchAll();
}

function 
isPackage($array) {
    return (
$array['primary_package_price'] != && $array['secondary_package_price'] != );
}

function 
PrintPrice($array$iP) {
    return 
$iP "Primary package price = " $array['primary_package_price'] . "<br/>Secondary package price = " $array['secondary_package_price'] :
            
"Primary individual price = " $array['primary_individual_price'] . "<br/>Primary group price = " $array['primary_group_price'] . "<br/>secondary individual price = " $array['    secondary_individual_price'] . "<br/>secondary group price = " $array['secondary_group_price'];
}

function 
ProgrammeList() {
    global 
$dbh;
    
$sth $dbh->query("SELECT `program_id`, `program_code` FROM `program` WHERE actived = 1 and deleted = 0 ");
    return 
$sth->fetchAll(PDO::FETCH_ASSOC);
}

function 
SubjectList() {
    global 
$dbh;
    
$sth $dbh->query("SELECT `subject_id`, `sub_code` FROM `subject` WHERE actived = 1 and deleted = 0");
    return 
$sth->fetchAll(PDO::FETCH_ASSOC);
}

function 
getDataFromID() {
    global 
$dbh$_GET;
    
$sth $dbh->query("SELECT `program_id`, `subject_id`, `primary_individual_price`, `primary_group_price`, `primary_package_price`, `    secondary_individual_price` sip, `secondary_group_price`, `secondary_package_price` FROM `prog_subject` WHERE actived = 1 and deleted = 0 and prog_subj_id = " $_GET['ps_id']);
    return 
$sth->fetch(PDO::FETCH_ASSOC);
}

function 
SaveRecord() {
    global 
$dbh$_POST;
    
$sth $dbh->prepare("INSERT INTO `prog_subject`(`program_id`, `subject_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`,"
            
" `primary_individual_price`, `primary_group_price`, `primary_package_price`, `    secondary_individual_price`,"
            
" `secondary_group_price`, `secondary_package_price`) VALUES (?,?,1,now(),1,now(),1,0,?,?,?,?,?,?)");
    
$sth->bindParam(1$_POST['programme']);
    
$sth->bindParam(2$_POST['code']);
    
$sth->bindParam(3$_POST['price3']);
    
$sth->bindParam(4$_POST['price4']);
    
$sth->bindParam(5$_POST['price1']);
    
$sth->bindParam(6$_POST['price5']);
    
$sth->bindParam(7$_POST['price6']);
    
$sth->bindParam(8$_POST['price2']);
    
$sth->execute();
}

function 
setSelected() {
    global 
$PS_Data;
    return 
isPackage($PS_Data) ? 0;
}

function 
UpdateRecord() {
    global 
$dbh$_POST$_GET;
    
$sth $dbh->prepare("UPDATE `prog_subject` SET `program_id`=?,`subject_id`=?,`lastupby`=1,`lastupdate`=now(),"
            
"`primary_individual_price`=?,`primary_group_price`=?,`primary_package_price`=?,`    secondary_individual_price`=?,"
            
"`secondary_group_price`=?,`secondary_package_price`=? WHERE actived = 1 and deleted = 0 and prog_subj_id = ?");
    
$sth->bindParam(1$_POST['programme']);
    
$sth->bindParam(2$_POST['code']);
    
$sth->bindParam(3$_POST['price3']);
    
$sth->bindParam(4$_POST['price4']);
    
$sth->bindParam(5$_POST['price1']);
    
$sth->bindParam(6$_POST['price5']);
    
$sth->bindParam(7$_POST['price6']);
    
$sth->bindParam(8$_POST['price2']);
    
$sth->bindParam(9$_GET['ps_id']);
}