/var/www/onesupportdemo.onesolution.hk/others/holiday_add.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
<?php
    
require_once('../inc/configure.php');
    
session_start();
    if(!empty(
$_SESSION['webadmin'])){
        
$nowdate date("Y-m-d H:i:s");
        if(isset(
$_GET["addholiday"]) && $_GET["addholiday"] ==1){
            
$remarks$_POST["remarks"];

            
//$sql = "insert into sup_public_holiday (year, holiday_date, createby, createdate, lastupby, lastupdate) values ('".date("Y")."','".date("Y-m-d")."', '".$_SESSION['webadmin']['id']."', '$nowdate', '".$_SESSION['webadmin']['id']."', '$nowdate') ";
            
$sql "insert into sup_public_holiday (year, holiday_date, createby, createdate, lastupby, lastupdate) values (?, ?, ?, ?, ?, ?) ";

            
$parameters = array(date("Y"),date("Y-m-d"),$_SESSION['webadmin']['id'],$nowdate,$_SESSION['webadmin']['id'],$nowdate);
            if (!(
$sth $dbh->prepare($sql))) {
                throw new 
Exception("sql prepare statement failure: $sql");
            }
            
$sth->setFetchMode(PDO::FETCH_ASSOC);
            if (!
$sth->execute($parameters)) {
                throw new 
Exception("sql execute statement failure: $sql");
            }

            
$lastinsertid $dbh->lastInsertId();

        }
        
header("Location: holiday_index.php?message=New empty holiday created." );
    }
?>