/var/www/hkosl.com/imusiccircle/webadmin/public_holiday_process.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
<?php
    $page_settings 
= array(
        
'formid'     => 'Approval'// for permission
        
'section'    => 'Master'// parent/page title
        
'subsection' => 'Public Holiday'// page title
        
'domain'     => 'public_holiday'// table/model name
        
'access'     => 'GNr'// for permission
    
);
    require_once 
"check_login.php";

    if (
$_REQUEST["action"] == "ADD" || $_REQUEST["action"] == "MODIFY") {

        
$message "";

        if (empty(
$_POST["date"])) {
            
$message .= _lang("Please enter Date.") . "\\n\\n";
        } else {
            if (!
validateDate($_POST["date"], "Y-m-d")) {
                
$message .= _lang("Please enter correct Date.") . "\\n\\n";
            }
        }

        if (empty(
$_POST["remark"])) {
            
$message .= _lang("Please enter Remark.") . "\\n\\n";
        }

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

    if (
$_REQUEST["action"] == "ADD") {
        
$sql        "insert into public_holiday (`date`, remark, createby, createdate, lastupby, lastupdate) value (?, ?, ?, ?, ?, ?)";
        
$parameters = array($_POST["date"], $_POST["remark"], $_SESSION["cmsloginid"], date("Y-m-d H:i:s"), $_SESSION["cmsloginid"], date("Y-m-d H:i:s"));

        
bind_pdo($sql$parameters);

        
header("Location: " $page_settings["domain"] . "_index.php?msg=1");
    } else if (
$_REQUEST["action"] == "MODIFY") {

        
$sql        "update public_holiday set `date`=?, remark=?, lastupby=?, lastupdate=?";
        
$parameters = array($_POST["date"], $_POST["remark"], $_SESSION['cmsloginid'], $nowdate);
        
$sql .= " where id = ?";
        
$parameters[] = (int)$_POST["id"];

        
bind_pdo($sql$parameters);

        
header("Location: " $page_settings["domain"] . "_index.php?msg=2");
    } else if (
$_REQUEST["action"] == "DELETE") {
        
$id = (int)$_GET["id"];

        
$sql        "update public_holiday set deleted = ?, lastupdate=?, lastupby=? where id = ?";
        
$parameters = array(1date("Y-m-d H:i:s"), $_SESSION['cmsloginid'], $id);
        
bind_pdo($sql$parameters);

        
header("Location: " $page_settings["domain"] . "_index.php?msg=2");
    }