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

            
$holiday_ids $_POST["holiday_id"];
            
$remarks$_POST["remarks"];
            
$holiday_dates$_POST["holiday_date"];

            foreach(
$holiday_ids as $holiday_id){
                
$sql "update sup_public_holiday set holiday_date=?, remarks=?, lastupdate=?, lastupby=? where id=?";

                
$parameters = array($holiday_dates[$holiday_id],$remarks[$holiday_id],$nowdate,$_SESSION['webadmin']['id'],$holiday_id);
                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");
                }
            }


            
//delete this holiday
            
if(isset($_GET["delete_holiday"]) && $_GET["delete_holiday"] == 1){
                
$holiday_id = (int)$_GET["holiday_id"];
                
$sql "delete from sup_public_holiday where id = ?";

                
$parameters = array($holiday_id);
                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");
                }
                
header("Location: holiday_index.php" );

            }

        
header("Location: holiday_index.php" );



    }
?>