<file_sep><?php
	include('connection/phpconnect.php');
	session_start();
    error_reporting(E_ERROR | E_WARNING | E_PARSE);
    $search = (isset($_GET['search'])) ? $_GET['search'] : '';
	$sql = "SELECT *
    FROM `employee`
    WHERE (`code` LIKE '%$search%')
    OR (`name` LIKE '%$search%')
    OR (`area` LIKE '%$search%')
    OR (`position` LIKE '%$search%')
    ORDER BY `id_employee` ASC;";
    $result = mysqli_query($db, $sql);
    $i = 1;
    if (isset($_POST["export"])) {
        $filename = "Export_excel.xls";
        header("Content-Type: application/vnd.ms-excel");
        header("Content-Disposition: attachment; filename=\"$filename\"");
        $isPrintHeader = false;
        if (! empty($result)) {
            foreach ($result as $row) {
                if (! $isPrintHeader) {
                    echo "Number","\t";
                    echo implode("\t",array_keys($row)) . "\n";
                    $isPrintHeader = true;
                }
                echo $i,"\t"; $i++;
                echo implode("\t", array_values($row)) . "\n";
            }
        }
        exit();    
    }
    if($_SESSION['username'] == ""){
		echo "<script type='text/javascript'>";
		echo "window.location = 'index.php'; ";
		echo "</script>";
	}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Required meta tags-->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="au theme template">
    <meta name="author" content="<NAME>">
    <meta name="keywords" content="au theme template">

    <!-- Title Page-->
    <title>Show Employee</title>

    <!-- Fontfaces CSS-->
    <link href="css/font-face.css" rel="stylesheet" media="all">
    <link href="vendor/font-awesome-4.7/css/font-awesome.min.css" rel="stylesheet" media="all">
    <link href="vendor/font-awesome-5/css/fontawesome-all.min.css" rel="stylesheet" media="all">
    <link href="vendor/mdi-font/css/material-design-iconic-font.min.css" rel="stylesheet" media="all">

    <!-- Bootstrap CSS-->
    <link href="vendor/bootstrap-4.1/bootstrap.min.css" rel="stylesheet" media="all">

    <!-- Vendor CSS-->
    <link href="vendor/animsition/animsition.min.css" rel="stylesheet" media="all">
    <link href="vendor/bootstrap-progressbar/bootstrap-progressbar-3.3.4.min.css" rel="stylesheet" media="all">
    <link href="vendor/wow/animate.css" rel="stylesheet" media="all">
    <link href="vendor/css-hamburgers/hamburgers.min.css" rel="stylesheet" media="all">
    <link href="vendor/slick/slick.css" rel="stylesheet" media="all">
    <link href="vendor/select2/select2.min.css" rel="stylesheet" media="all">
    <link href="vendor/perfect-scrollbar/perfect-scrollbar.css" rel="stylesheet" media="all">

    <!-- Main CSS-->
    <link href="css/theme.css" rel="stylesheet" media="all">
</head>

<body class="animsition">
    <div class="page-wrapper">
        <!-- HEADER DESKTOP-->
        <header class="header-desktop3 d-none d-lg-block">
            <div class="section__content section__content--p35">
                <div class="header3-wrap">
                    <div class="header__logo">
                        <a href="#">
                            <img src="images/icon/true2.png" alt="CoolAdmin" />
                        </a>
                    </div>
                    <div class="header__navbar">
                        <ul class="list-unstyled">
                            <li>
                                <a href="index.php">
                                    <i class="fas fa-chart-bar"></i>
                                    <span class="bot-line"></span>Home</a>
                            </li>
                            <li>
                                <a href="form_wr.php">
                                    <i class="fas fa-shopping-basket"></i>
                                    <span class="bot-line"></span>Withdraw Return</a>
                            </li>
                            <?php
                                if($_SESSION['username'] == !""){
                            ?>
                            <li class="has-sub">
                                <a href="#">
                                    <i class="fas fa-copy"></i>
                                    <span class="bot-line"></span>Pages</a>
                                <ul class="header3-sub-list list-unstyled">
                                    <li>
                                        <a href="form_mat.php">
                                            <i class="fas fa-barcode"></i>Add new MAT</a>
                                    </li>
                                    <li>
                                        <a href="form_store.php">
                                            <i class="fas fa-warehouse"></i>Update location</a>
                                    </li>
                                </ul>
                            </li>
                            <?php
                                }
                            ?>
                            </li>
                        </ul>
                    </div>
                    <div class="header__tool">
                        <div class="account-wrap">
                            <div class="account-item account-item--style2 clearfix js-item-menu">
                                <div class="content">
                                    <?php
                                        if($_SESSION['username'] == ""){
                                    ?>
                                        <a class="js-acc-btn" href="#">User</a>  
                                    <?php
                                        }
                                    ?>
                                    <?php
                                        if($_SESSION['username'] == !""){
                                    ?>
                                        <a class="js-acc-btn" href="#"><?php echo $_SESSION['username'] ?></a>  
                                    <?php
                                        }
                                    ?>
                                </div>
                                <div class="account-dropdown js-dropdown">
                                    <div class="account-dropdown__body">
                                        <?php
                                            if($_SESSION['username'] == !""){
                                        ?>
                                        <div class="account-dropdown__item">
                                            <a href="account.php">
                                                <i class="zmdi zmdi-account"></i>Account</a>
                                        </div>
                                        <div class="account-dropdown__item">
                                            <a href="#">
                                                <i class="zmdi zmdi-settings"></i>Setting</a>
                                        </div>
                                        <?php
                                            }
                                        ?>
                                    </div>
                                    <div class="account-dropdown__footer">
                                        <?php
                                        if($_SESSION['username'] == ""){
                                        ?>
                                            <a href='login.php'>
                                                <i class="zmdi zmdi-power"></i>Login</a>    
                                        <?php
                                            }
                                        ?>    
                                        <?php
                                            if($_SESSION['username'] == !""){
                                        ?>
                                            <a href='action/logout.php'>
                                                <i class="zmdi zmdi-power"></i>Logout</a>
                                        <?php
                                            }
                                        ?>
                                        <a href="forget-pass.html">
                                            <i class="zmdi zmdi-key"></i>Forget Password</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </header>
        <!-- END HEADER DESKTOP-->

        <!-- HEADER MOBILE-->
        <header class="header-mobile header-mobile-2 d-block d-lg-none">
            <div class="header-mobile__bar">
                <div class="container-fluid">
                    <div class="header-mobile-inner">
                        <a class="logo" href="#">
                            <img src="images/icon/true2.png" alt="CoolAdmin" />
                        </a>
                        <button class="hamburger hamburger--slider" type="button">
                            <span class="hamburger-box">
                                <span class="hamburger-inner"></span>
                            </span>
                        </button>
                    </div>
                </div>
            </div>
            <nav class="navbar-mobile">
                <div class="container-fluid">
                    <ul class="navbar-mobile__list list-unstyled">
                        <li>
                            <a href="index.php">
                                <i class="fas fa-chart-bar"></i>Home</a>
                        </li>
                        <li>
                            <a href="form_wr.php">
                                <i class="fas fa-shopping-basket"></i>Withdraw Return</a>
                        </li>
                        <?php
                                    if($_SESSION['username'] == !""){
                                ?>
                        <li class="has-sub">
                            <a class="js-arrow" href="#">
                                <i class="fas fa-copy"></i>Pages</a>
                            <ul class="navbar-mobile-sub__list list-unstyled js-sub-list">
                                
                                    <li>
                                        <a href="form_mat.php">
                                            <i class="fas fa-barcode"></i>Add new MAT</a>
                                    </li>
                                    <li>
                                        <a href="form_store.php">
                                            <i class="fas fa-warehouse"></i>Update location</a>
                                    </li>
                                
                            </ul>
                        </li>
                        <?php
                            }
                        ?>
                    </ul>
                </div>
            </nav>
        </header>
        <div class="sub-header-mobile-2 d-block d-lg-none">
            <div class="header__tool">
                <div class="account-wrap">
                    <div class="account-item account-item--style2 clearfix js-item-menu">
                        <div class="content">
                        <?php
                            if($_SESSION['username'] == ""){
                        ?>
                            <a class="js-acc-btn" href="#">User</a>  
                        <?php
                            }
                        ?>
                        <?php
                            if($_SESSION['username'] == !""){
                        ?>
                            <a class="js-acc-btn" href="#"><?php echo $_SESSION['username'] ?></a>  
                        <?php
                            }
                        ?>
                        </div>
                        <div class="account-dropdown js-dropdown">
                            <div class="account-dropdown__body">
                                <?php
                                    if($_SESSION['username'] == !""){
                                ?>
                                <div class="account-dropdown__item">
                                    <a href="account.php">
                                        <i class="zmdi zmdi-account"></i>Account</a>
                                </div>
                                <?php
                                    }
                                ?>
                                <div class="account-dropdown__item">
                                    <a href="#">
                                        <i class="zmdi zmdi-settings"></i>Setting</a>
                                </div>
                            </div>
                            <div class="account-dropdown__footer">
                                <?php
                                    if($_SESSION['username'] == ""){
                                ?>
                                    <a href='login.php'>
                                        <i class="zmdi zmdi-power"></i>Login</a>
                                <?php
                                    }
                                ?>
                                <?php
                                    if($_SESSION['username'] == !""){
                                ?>
                                    <a href='action/logout.php'>
                                        <i class="zmdi zmdi-power"></i>Logout</a>
                                <?php
                                    }
                                ?>
                                <a href="forget-pass.html">
                                    <i class="zmdi zmdi-key"></i>Forget Password</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- END HEADER MOBILE -->

        <!-- PAGE CONTENT-->
        <div class="page-content--bgf7">
            <!-- BREADCRUMB-->
            <section class="au-breadcrumb2">
                <div class="container">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="au-breadcrumb-content">
                                <div class="au-breadcrumb-left">
                                    <span class="au-breadcrumb-span">You are here:</span>
                                    <ul class="list-unstyled list-inline au-breadcrumb__list">
                                        <li class="list-inline-item active">
                                            <a href="#">Show Employee</a>
                                        </li>
                                        <li class="list-inline-item seprate">
                                            <span>/</span>
                                        </li>
                                        <li class="list-inline-item">
                                        <?php
                                        if(isset($_GET['search']))
                                        {
                                        ?>
                                            <b><?php echo ($search); ?></b>
                                        <?php
                                        }
                                        ?>
                                        </li>
                                    </ul>
                                </div>
                                <form  method="request" class="form-header" action="search.php">
                                    <input id="search" class="au-input au-input--xl" type="text" name="search" placeholder="กดปุ่มเพื่อแสดงข้อมูลอุปกรณ์ หรือกรอกคำค้นหา" size="control"/>
                                    <button class="au-btn--submit" type="submit" name="submit">
                                        <i class="zmdi zmdi-search"></i>
                                    </button>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
            <!-- END BREADCRUMB-->

            <!-- WELCOME-->
            <section class="welcome p-t-10">
                <div class="container">
                    <form method="POST">
                        <div class="row">
                            <div class="col-md-12">
                            <div class="overview-wrap">
                                <h2 class="title-1">ข้อมูลพนักงาน</h2>
                                </div>
                                <hr class="line-seprate">
                            </div>
                        </div>
                    </form>
                </div>
            </section>
            <!-- END WELCOME-->

            <!--แสดงข้อมูล-->
            <section class="p-t-20 p-b-20">
                <div class="container">
                    
                    <div class="row">
                        <div class="col-md-12">
                            <div class="row">
                                <div class="col-lg-8 offset-md-2">
                                    <div class="overview-wrap">
                                    <div class="overview-wrap">
                                    <?php
                                            if(isset($_GET['search']))
                                            {
                                            ?>
                                                <font color="blue"><?php echo ($search); ?></font>
                                            <?php
                                            }
                                            ?>
                                            &nbsp;                          
                                            พบผลลัพธ์&nbsp;<b>
                                            <?php
                                            $count="SELECT COUNT(`employee`.`id_employee`) AS `id_employee` FROM `employee`
                                            WHERE (`id_employee` LIKE '%$search%') 
                                            OR (`code` LIKE '%$search%')
                                            OR (`name` LIKE '%$search%') 
                                            OR (`area` LIKE '%$search%')
                                            OR (`position` LIKE '%$search%')";
                                            $resultcount=$db->query($count);
                                            while($row=$resultcount->fetch_object())
                                            {
                                            ?>
                                            <option value="<?php echo $row->id_employee;?>">
                                            <?php echo $row->id_employee;?>
                                            </option>
                                            <?php
                                            }
                                            ?>
                                            </b>&nbsp;รายการ
                                        </div>
                                        <form  method="request" class="form-header" action="show_emp.php">
                                            <input id="search" class="au-input au-input--xl" type="text" name="search" placeholder="กดปุ่มเพื่อแสดงข้อมูลอุปกรณ์ หรือกรอกคำค้นหา" size="control"/>
                                            <button class="au-btn--submit" type="submit" name="submit">
                                                <i class="zmdi zmdi-search"></i>
                                            </button>
                                        </form>
                                        <div class="btn">
                                            <form action="" method="POST">
                                                <button type="submit" name="export" id="btnExport" value="Export" class="au-btn au-btn-icon au-btn--blue">
                                                    <i class="fa fa-file-excel-o"></i>Export</button>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-12">
                                    <div class="table-responsive table--no-card">
                                    <?php
                                    echo "<table id='tap' class='table table-borderless table-striped table-earning'>";
                                    
                                    echo "<tr>
                                    <thead align='center'>
                                    <th>code</th>
                                    <th>name</th>
                                    <th>area</th>
                                    <th>position</th>";
                                    if($_SESSION['username'] == !""){
                                    echo"<th>แก้ไข</th>
                                    <th>ลบ</th>";
                                    }
                                    echo"</thead>
                                    </tr>";
                                    while($row = mysqli_fetch_array($result)) { 
                                    echo "<tr><tbody align='center'>";
                                    echo "<td>" .$row["code"] .  "</td> ";  
                                    echo "<td>" .$row["name"] .  "</td> "; 
                                    echo "<td>" .$row["area"] .  "</td> ";  
                                    echo "<td>" .$row["position"] .  "</td> ";
                                    //แก้ไขข้อมูลส่่ง member_id ที่จะแก้ไขไปที่ฟอร์ม
                                    if($_SESSION['username'] == !""){
                                    echo "<td><a href='form_update_emp.php?id_employee=$row[0]'><button class='btn btn-warning'>edit</button></a></td> ";
                                    //ลบข้อมูล
                                    echo "<td><a href='action/delete_emp.php?id_employee=$row[0]' onclick=\"return confirm('Do you want to delete this record? !!!')\"><button class='btn btn-danger'>del</button></a></td> ";
                                    }
                                    echo "</tbody></tr>";
                                    }
                                    echo "</table>";
                                    //5. close connection
                                    mysqli_close($db);
                                    ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>

            <!-- COPYRIGHT-->
            <section class="p-t-60 p-b-20">
                <div class="container">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="copyright">
                            <p>Copyright © 2020</a>.</p>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
            <!-- END COPYRIGHT-->
        </div>

    </div>

    <!-- Jquery JS-->
    <script src="vendor/jquery-3.2.1.min.js"></script>
    <!-- Bootstrap JS-->
    <script src="vendor/bootstrap-4.1/popper.min.js"></script>
    <script src="vendor/bootstrap-4.1/bootstrap.min.js"></script>
    <!-- Vendor JS       -->
    <script src="vendor/slick/slick.min.js">
    </script>
    <script src="vendor/wow/wow.min.js"></script>
    <script src="vendor/animsition/animsition.min.js"></script>
    <script src="vendor/bootstrap-progressbar/bootstrap-progressbar.min.js">
    </script>
    <script src="vendor/counter-up/jquery.waypoints.min.js"></script>
    <script src="vendor/counter-up/jquery.counterup.min.js">
    </script>
    <script src="vendor/circle-progress/circle-progress.min.js"></script>
    <script src="vendor/perfect-scrollbar/perfect-scrollbar.js"></script>
    <script src="vendor/chartjs/Chart.bundle.min.js"></script>
    <script src="vendor/select2/select2.min.js">
    </script>

    <!-- Main JS-->
    <script src="js/main.js"></script>

</body>

</html>
<!-- end document-->
<file_sep><?php
date_default_timezone_set("Asia/Bangkok");
include("../connection/phpconnect.php");
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$num_lo = $_REQUEST['num_lo'];
$id_shelf = $_REQUEST['id_shelf'];
$id_store = $_REQUEST['id_store'];
$time = date("ymdHis");
$no = "$id_store$time";
$id_mat = $_REQUEST['id_mat'];
$id_emp = $_REQUEST['id_emp'];
$action = $_REQUEST['action'];
$amount = $_REQUEST['amount'];
$date = date("Y-m-d");

$call="SELECT * FROM `process_log` WHERE `no` = $no;";
$result = mysqli_query($db, $call);
if($result->num_rows==0)
{
	if($action=='withdraw'){
		$amlo = "SELECT * FROM `location` WHERE `id_mat` = '$id_mat' AND `id_store` = '$id_store' AND `id_shelf` = '$id_shelf'";
		$reamlo = mysqli_query($db, $amlo);
		if($reamlo->num_rows==1){
			while($row=$reamlo->fetch_object()){
				$echo = $row->amount;
				$del = $echo - $amount;
				if($echo < $amount){
					echo "<script type='text/javascript'>";
					echo "alert('อุปกรณ์มีไม่เพียงพอ');";
					echo "window.history.back()";
					echo "</script>";
				}
				else{
					if($del == 0){
						$sqldel = "DELETE FROM `location` WHERE `num_lo` = '$num_lo'";
						$delete = mysqli_query($db, $sqldel);
					}
					else{
						$sqlup = "UPDATE
						`location`
						SET
						`amount` = `amount` - '$amount'
						WHERE
						`id_mat` = '$id_mat' AND `id_store` = '$id_store' AND `id_shelf` = '$id_shelf'";
						$ubdate = mysqli_query($db, $sqlup);
					}
					$sql="INSERT INTO `process_log` (`no`, `id_mat`, `id_emp`, `action`, `amount`, `date`)
					VALUES ('$no','$id_mat','$id_emp','$action','$amount','$date')";
					$insert = mysqli_query($db, $sql);
					echo "<script type='text/javascript'>";
					echo "alert('ทำรายการสำเร็จ');";
					echo "window.location = '../form_show_location.php'; ";
					echo "</script>";
					echo $amount,"<br>";
					echo $echo,"<br>";
					echo $del,"<br>";
					echo $zero;
				}
			}
		}
		if($reamlo->num_rows==0){
			echo "<script type='text/javascript'>";
			echo "alert('ไม่พบข้อมูล กรุณาทำรายการอีกครั้ง');";
			echo "window.history.back()";
			echo "</script>";
		}
	}
	if($action=='return'){
		$amlof = "SELECT * FROM `location_fail` WHERE `id_mat` = '$id_mat' AND `id_store` = '$id_store'";
		$reamlof = mysqli_query($db, $amlof);
		if($reamlof->num_rows==1){
			$sqlup = "UPDATE
			`location_fail`
			SET
			`amount` = `amount` + '$amount'
			WHERE
			`id_mat` = '$id_mat' AND `id_store` = '$id_store' AND `id_shelf` = '$id_shelf'";
			$update = mysqli_query($db, $sqlup);
		}
		if($reamlof->num_rows==0){
			$sqllof="INSERT INTO `location_fail` (`id_mat`, `id_store`, `id_shelf`, `amount`)
			VALUES ('$id_mat','$id_store','$id_shelf','$amount')";
			$insert1 = mysqli_query($db, $sqllof);
		}
		$sql="INSERT INTO `process_log` (`no`, `id_mat`, `id_emp`, `action`, `amount`, `date`)
		VALUES ('$no','$id_mat','$id_emp','$action','$amount','$date')";
		$insert = mysqli_query($db, $sql);
		//echo $sql;
		echo "<script type='text/javascript'>";
		echo "alert('ทำรายการสำเร็จ');";
		echo "window.location = '../form_show_location_fail.php'; ";
		echo "</script>";
	}

	if($action=='deposited'){
		$amlo = "SELECT * FROM `location` WHERE `id_mat` = '$id_mat' AND `id_store` = '$id_store' AND `id_shelf` = '$id_shelf'";
		$reamlo = mysqli_query($db, $amlo);
		if($reamlo->num_rows==1){
			$sqlup = "UPDATE
			`location`
			SET
			`amount` = `amount` + '$amount'
			WHERE
			`id_mat` = '$id_mat' AND `id_store` = '$id_store' AND `id_shelf` = '$id_shelf'";
			$update = mysqli_query($db, $sqlup);
		}
		if($reamlo->num_rows==0){
			$sqllo="INSERT INTO `location` (`id_mat`, `id_store`, `id_shelf`, `amount`)
			VALUES ('$id_mat','$id_store','$id_shelf','$amount')";
			$insert1 = mysqli_query($db, $sqllo);
		}
		$sql="INSERT INTO `process_log` (`no`, `id_mat`, `id_emp`, `action`, `amount`, `date`)
		VALUES ('$no','$id_mat','$id_emp','$action','$amount','$date')";
		$insert = mysqli_query($db, $sql);
		//echo $sql;
		echo "<script type='text/javascript'>";
		echo "alert('ทำรายการสำเร็จ');";
		echo "window.location = '../form_show_location.php'; ";
		echo "</script>";
	}
}else
{
	echo "<script type='text/javascript'>";
	echo "alert('ไม่สามารถทำรายการได้');";
	echo "window.history.back()";
	echo "</script>";
}
?><file_sep><?php
    include('connection/phpconnect.php');
    session_start();
    error_reporting(E_ERROR | E_WARNING | E_PARSE);
    //$action = $_REQUEST['action'];
    if (isset($_REQUEST['action'])) {
        $action = $_REQUEST['action'];
    } else {
    $action = 'all';
    }
    $day = date("Y-m-d");
    $month = date("Y-m");
    $search = (isset($_GET['search'])) ? $_GET['search'] : '';
    $perpage = 10;
    if (isset($_GET['page'])) {
    $page = $_GET['page'];
    } else {
    $page = 1;
    }
    $start = ($page - 1) * $perpage;
    if($action=='today'){
        $sqls = "SELECT *
        FROM process_log
        WHERE  ((`date` LIKE '%$day%') and (`no` LIKE '%$search%'))
        OR ((`date` LIKE '%$day%') and (`id_emp` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`id_mat` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`amount` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`action` LIKE '%$search%')) ORDER BY date asc limit {$start} , {$perpage};";
        $results = mysqli_query($db, $sqls);
        $sqle = "SELECT *
        FROM process_log
        WHERE ((`date` LIKE '%$day%') and (`no` LIKE '%$search%'))
        OR ((`date` LIKE '%$day%') and (`id_emp` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`id_mat` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`amount` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`action` LIKE '%$search%')) ORDER BY date asc;";
        $resulte = mysqli_query($db, $sqle); 
    }
    else if($action=='todayd'){
        $sqls = "SELECT *
        FROM process_log
        WHERE ((`date` LIKE '%$day%') and (`action` LIKE 'deposited') and (`no` LIKE '%$search%'))
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'deposited') and (`id_emp` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'deposited') and (`id_mat` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'deposited') and (`amount` LIKE '%$search%')) ORDER BY date asc limit {$start} , {$perpage};";
        $results = mysqli_query($db, $sqls);
        $sqle = "SELECT *
        FROM process_log
        WHERE ((`date` LIKE '%$day%') and (`action` LIKE 'deposited') and (`no` LIKE '%$search%'))
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'deposited') and (`id_emp` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'deposited') and (`id_mat` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'deposited') and (`amount` LIKE '%$search%')) ORDER BY date asc;";
        $resulte = mysqli_query($db, $sqle); 
    }
    else if($action=='todayw'){
        $sqls = "SELECT *
        FROM process_log
        WHERE ((`date` LIKE '%$day%') and (`action` LIKE 'withdraw') and (`no` LIKE '%$search%'))
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'withdraw') and (`id_emp` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'withdraw') and (`id_mat` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'withdraw') and (`amount` LIKE '%$search%')) ORDER BY date asc limit {$start} , {$perpage};";
        $results = mysqli_query($db, $sqls);
        $sqle = "SELECT *
        FROM process_log
        WHERE ((`date` LIKE '%$day%') and (`action` LIKE 'withdraw') and (`no` LIKE '%$search%'))
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'withdraw') and (`id_emp` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'withdraw') and (`id_mat` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'withdraw') and (`amount` LIKE '%$search%')) ORDER BY date asc;";
        $resulte = mysqli_query($db, $sqle); 
    }
    else if($action=='todayr'){
        $sqls = "SELECT *
        FROM process_log
        WHERE ((`date` LIKE '%$day%') and (`action` LIKE 'return') and (`no` LIKE '%$search%'))
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'return') and (`id_emp` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'return') and (`id_mat` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'return') and (`amount` LIKE '%$search%')) ORDER BY date asc limit {$start} , {$perpage};";
        $results = mysqli_query($db, $sqls);
        $sqle = "SELECT *
        FROM process_log
        WHERE ((`date` LIKE '%$day%') and (`action` LIKE 'return') and (`no` LIKE '%$search%'))
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'return') and (`id_emp` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'return') and (`id_mat` LIKE '%$search%')) 
        OR ((`date` LIKE '%$day%') and (`action` LIKE 'return') and (`amount` LIKE '%$search%')) ORDER BY date asc;";
        $resulte = mysqli_query($db, $sqle); 
    }
    else if($action=='thismonth'){
        $sqls = "SELECT *
        FROM process_log
        WHERE ((`date` LIKE '%$month%') and (`no` LIKE '%$search%'))
        OR ((`date` LIKE '%$month%') and (`id_emp` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`id_mat` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`amount` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`action` LIKE '%$search%')) ORDER BY date asc limit {$start} , {$perpage};";
        $results = mysqli_query($db, $sqls);
        $sqle = "SELECT *
        FROM process_log
        WHERE  ((`date` LIKE '%$month%') and (`no` LIKE '%$search%'))
        OR ((`date` LIKE '%$month%') and (`id_emp` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`id_mat` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`amount` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`action` LIKE '%$search%')) ORDER BY date asc;";
        $resulte = mysqli_query($db, $sqle); 
    }
    else if($action=='thismonthd'){
        $sqls = "SELECT *
        FROM process_log
        WHERE ((`date` LIKE '%$month%') and (`action` LIKE 'deposited') and (`no` LIKE '%$search%'))
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'deposited') and (`id_emp` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'deposited') and (`id_mat` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'deposited') and (`amount` LIKE '%$search%')) ORDER BY date asc limit {$start} , {$perpage};";
        $results = mysqli_query($db, $sqls);
        $sqle = "SELECT *
        FROM process_log
        WHERE ((`date` LIKE '%$month%') and (`action` LIKE 'deposited') and (`no` LIKE '%$search%'))
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'deposited') and (`id_emp` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'deposited') and (`id_mat` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'deposited') and (`amount` LIKE '%$search%')) ORDER BY date;";
        $resulte = mysqli_query($db, $sqle); 
    }
    else if($action=='thismonthw'){
        $sqls = "SELECT *
        FROM process_log
        WHERE ((`date` LIKE '%$month%') and (`action` LIKE 'withdraw') and (`no` LIKE '%$search%'))
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'withdraw') and (`id_emp` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'withdraw') and (`id_mat` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'withdraw') and (`amount` LIKE '%$search%')) ORDER BY date asc limit {$start} , {$perpage};";
        $results = mysqli_query($db, $sqls);
        $sqle = "SELECT *
        FROM process_log
        WHERE ((`date` LIKE '%$month%') and (`action` LIKE 'withdraw') and (`no` LIKE '%$search%'))
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'withdraw') and (`id_emp` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'withdraw') and (`id_mat` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'withdraw') and (`amount` LIKE '%$search%')) ORDER BY date asc;";
        $resulte = mysqli_query($db, $sqle); 
    }
    else if($action=='thismonthr'){
        $sqls = "SELECT *
        FROM process_log
        WHERE ((`date` LIKE '%$month%') and (`action` LIKE 'return') and (`no` LIKE '%$search%'))
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'return') and (`id_emp` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'return') and (`id_mat` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'return') and (`amount` LIKE '%$search%'))ORDER BY date asc limit {$start} , {$perpage};";
        $results = mysqli_query($db, $sqls);
        $sqle = "SELECT *
        FROM process_log
        WHERE ((`date` LIKE '%$month%') and (`action` LIKE 'return') and (`no` LIKE '%$search%'))
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'return') and (`id_emp` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'return') and (`id_mat` LIKE '%$search%')) 
        OR ((`date` LIKE '%$month%') and (`action` LIKE 'return') and (`amount` LIKE '%$search%'))ORDER BY date asc;";
        $resulte = mysqli_query($db, $sqle); 
    }
    else if($action=='all'){
        $sqls = "SELECT *
        FROM process_log
        WHERE (`date` LIKE '%$search%')
        OR (`id_mat` LIKE '%$search%') 
        OR (`no` LIKE '%$search%')
        OR (`id_emp` LIKE '%$search%') 
        OR (`action` LIKE '%$search%') 
        OR (`amount` LIKE '%$search%') ORDER BY date asc limit {$start} , {$perpage};";
        $results = mysqli_query($db, $sqls);
        $sqle = "SELECT *
        FROM process_log
        WHERE (`date` LIKE '%$search%')
        OR (`id_mat` LIKE '%$search%') 
        OR (`no` LIKE '%$search%')
        OR (`id_emp` LIKE '%$search%') 
        OR (`action` LIKE '%$search%') 
        OR (`amount` LIKE '%$search%') ORDER BY date asc;";
        $resulte = mysqli_query($db, $sqle);
    }
	
    $e = 1;
    if (isset($_POST["export"])) {
        $filename = "process_$action.xls";
        header("Content-Type: application/vnd.ms-excel");
        header("Content-Disposition: attachment; filename=\"$filename\"");
        $isPrintHeader = false;
        if (! empty($resulte)) {
            foreach ($resulte as $rows) {
                if (! $isPrintHeader) {
                    echo "Number","\t";
                    echo implode("\t",array_keys($rows)) . "\n";
                    $isPrintHeader = true;
                }
                echo $e,"\t"; $e++;
                echo implode("\t", array_values($rows)) . "\n";
            }
        }
        exit();    
    }
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Required meta tags-->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="Co-Op Project">
    <meta name="author" content="<NAME>">
    <meta name="keywords" content="Co-Op Project">

    <!-- Title Page-->
    <title>Dashboard</title>
    <link rel="icon" href="images/icon/true2.png" type="image/icon type">

    <!-- Fontfaces CSS-->
    <link href="css/font-face.css" rel="stylesheet" media="all">
    <link href="vendor/font-awesome-4.7/css/font-awesome.min.css" rel="stylesheet" media="all">
    <link href="vendor/font-awesome-5/css/fontawesome-all.min.css" rel="stylesheet" media="all">
    <link href="vendor/mdi-font/css/material-design-iconic-font.min.css" rel="stylesheet" media="all">

    <!-- Bootstrap CSS-->
    <link href="vendor/bootstrap-4.1/bootstrap.min.css" rel="stylesheet" media="all">

    <!-- Vendor CSS-->
    <link href="vendor/animsition/animsition.min.css" rel="stylesheet" media="all">
    <link href="vendor/bootstrap-progressbar/bootstrap-progressbar-3.3.4.min.css" rel="stylesheet" media="all">
    <link href="vendor/wow/animate.css" rel="stylesheet" media="all">
    <link href="vendor/css-hamburgers/hamburgers.min.css" rel="stylesheet" media="all">
    <link href="vendor/slick/slick.css" rel="stylesheet" media="all">
    <link href="vendor/select2/select2.min.css" rel="stylesheet" media="all">
    <link href="vendor/perfect-scrollbar/perfect-scrollbar.css" rel="stylesheet" media="all">

    <!-- Main CSS-->
    <link href="css/theme.css" rel="stylesheet" media="all">
    <link href="css/paginator.css" rel="stylesheet" media="all">

</head>

<body class="animsition">
    <div class="page-wrapper">
        <!-- HEADER DESKTOP-->
        <header class="header-desktop3 d-none d-lg-block">
            <div class="section__content section__content--p35">
                <div class="header3-wrap">
                    <div class="header__logo">
                        <a href="#">
                            <img src="images/icon/true2.png" alt="CoolAdmin" />
                        </a>
                    </div>
                    <div class="header__navbar">
                        <ul class="list-unstyled">
                            <li>
                                <a href="#">
                                    <i class="fas fa-chart-pie"></i>
                                    </span>Home</a>
                            </li>
                            <li>
                                <a href="form_show_location.php">
                                    <i class="fas fa-warehouse"></i>
                                    <span class="bot-line"></span>Location Good</a>
                            </li>
                            <li>
                                <a href="form_show_location_fail.php">
                                    <i class="fas fa-wrench"></i>
                                    <span class="bot-line"></span>Location Fail</a>
                            </li>
                            <?php
                                if($_SESSION['username'] == !""){
                            ?>
                            <li class="has-sub">
                                <a href="#">
                                    <i class="fas fa-copy"></i>
                                    <span class="bot-line"></span>Manage</a>
                                <ul class="header3-sub-list list-unstyled">
                                    <li>
                                        <a href="form_show_mat.php">
                                            <i class="fas fa-barcode"></i>Material</a>
                                    </li>
                                    <li>
                                        <a href="form_show_mattype.php">
                                            <i class="fas fa-barcode"></i>Material Type</a>
                                    </li>
                                    <li>
                                        <a href="form_show_emp.php">
                                            <i class="fas fa-user"></i>Employee</a>
                                    </li>
                                    <li>
                                        <a href="form_show_position.php">
                                            <i class="fas fa-user"></i>Position</a>
                                    </li>
                                    <li>
                                        <a href="form_show_department.php">
                                            <i class="fas fa-user"></i>Departmet</a>
                                    </li>
                                    <li>
                                        <a href="form_show_plant.php">
                                            <i class="fas fa-warehouse"></i>Plant</a>
                                    </li>
                                    <li>
                                        <a href="form_show_store.php">
                                            <i class="fas fa-warehouse"></i>Store</a>
                                    </li>
                                    <li>
                                        <a href="form_show_shelf.php">
                                            <i class="fas fa-warehouse"></i>Shelf</a>
                                    </li>
                                    <li>
                                        <a href="form_show_users.php">
                                            <i class="fas fa-user"></i>Users</a>
                                    </li>
                                </ul>
                            </li>
                            <?php
                                }
                            ?>
                            </li>
                        </ul>
                    </div>
                    <div class="header__tool">
                        <div class="account-wrap">
                            <div class="account-item account-item--style2 clearfix js-item-menu">
                                <div class="content">
                                    <?php
                                    if($_SESSION['username'] == ""){
                                    ?>
                                        <a href='login.php'>
                                            <i class="js-acc-btn"></i>Login</a>    
                                    <?php
                                        }
                                    ?>
                                    <?php
                                    if($_SESSION['username'] == !""){
                                    ?>
                                        <a class="js-acc-btn" href="#"><?php echo $_SESSION['username'] ?></a>        
                                    <?php
                                        }
                                    ?>
                                    
                                </div>
                                <div class="account-dropdown js-dropdown">
                                    <?php
                                        if($_SESSION['username'] == !""){
                                    ?>
                                    <div class="account-dropdown__body">
                                        <div class="account-dropdown__item">
                                            <a href="account.php">
                                                <i class="zmdi zmdi-account"></i>Account</a>
                                        </div>
                                    </div>
                                    <?php
                                        }
                                    ?>
                                    <div class="account-dropdown__footer">
                                        <?php
                                            if($_SESSION['username'] == ""){
                                        ?>
                                            <a href='login.php'>
                                                <i class="zmdi zmdi-power"></i>Login</a>
                                        <?php
                                            }
                                        ?>
                                        <?php
                                            if($_SESSION['username'] == !""){
                                        ?>
                                            <a href='action/logout.php'>
                                                <i class="zmdi zmdi-power"></i>Logout</a>
                                        <?php
                                            }
                                        ?>
                                        <a href="forget-pass.html">
                                            <i class="zmdi zmdi-key"></i>Forget Password</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </header>
        <!-- END HEADER DESKTOP-->

        <!-- HEADER MOBILE-->
        <header class="header-mobile header-mobile-2 d-block d-lg-none">
            <div class="header-mobile__bar">
                <div class="container-fluid">
                    <div class="header-mobile-inner">
                        <a class="logo" href="#">
                            <img src="images/icon/true2.png" alt="CoolAdmin" />
                        </a>
                        <button class="hamburger hamburger--slider" type="button">
                            <span class="hamburger-box">
                                <span class="hamburger-inner"></span>
                            </span>
                        </button>
                    </div>
                </div>
            </div>
            <nav class="navbar-mobile">
                <div class="container-fluid">
                    <ul class="navbar-mobile__list list-unstyled">
                        <li>
                            <a href="#">
                                <i class="fas fa-chart-pie"></i>Home</a>
                        </li>
                        <li>
                            <a href="form_show_location.php">
                                <i class="fas fa-warehouse"></i>
                                <span class="bot-line"></span>Location Good</a>
                        </li>
                        <li>
                            <a href="form_show_location_fail.php">
                                <i class="fas fa-wrench"></i>
                                <span class="bot-line"></span>Location Fail</a>
                        </li>
                        <?php
                                    if($_SESSION['username'] == !""){
                                ?>
                        <li class="has-sub">
                            <a class="js-arrow" href="#">
                                <i class="fas fa-copy"></i>Manage</a>
                            <ul class="navbar-mobile-sub__list list-unstyled js-sub-list">
                                <li>
                                    <a href="form_show_mat.php">
                                        <i class="fas fa-barcode"></i>Material</a>
                                </li>
                                <li>
                                    <a href="form_show_mattype.php">
                                        <i class="fas fa-barcode"></i>Material Type</a>
                                </li>
                                <li>
                                    <a href="form_show_emp.php">
                                        <i class="fas fa-user"></i>Employee</a>
                                </li>
                                <li>
                                    <a href="form_show_position.php">
                                        <i class="fas fa-user"></i>Position</a>
                                </li>
                                <li>
                                    <a href="form_show_department.php">
                                        <i class="fas fa-user"></i>Department</a>
                                </li>
                                <li>
                                    <a href="form_show_plant.php">
                                        <i class="fas fa-warehouse"></i>Plant</a>
                                </li>
                                <li>
                                    <a href="form_show_store.php">
                                        <i class="fas fa-warehouse"></i>Store</a>
                                </li>
                                <li>
                                    <a href="form_show_shelf.php">
                                        <i class="fas fa-warehouse"></i>Shelf</a>
                                </li>
                                <li>
                                    <a href="form_show_users.php">
                                        <i class="fas fa-user"></i>Users</a>
                                </li>
                            </ul>
                        </li>
                        <?php
                            }
                        ?>
                    </ul>
                </div>
            </nav>
        </header>
        <div class="sub-header-mobile-2 d-block d-lg-none">
            <div class="header__tool">
                <div class="account-wrap">
                    <div class="account-item account-item--style2 clearfix js-item-menu">
                        <div class="content">
                            <?php
                            if($_SESSION['username'] == ""){
                            ?>
                                <a href='login.php'>
                                    <i class="js-acc-btn"></i>Login</a>    
                            <?php
                                }
                            ?>
                            <?php
                            if($_SESSION['username'] == !""){
                            ?>
                                <a class="js-acc-btn" href="#"><?php echo $_SESSION['username'] ?></a>        
                            <?php
                                }
                            ?>
                            
                        </div>
                        <div class="account-dropdown js-dropdown">
                            <?php
                                if($_SESSION['username'] == !""){
                            ?>
                            <div class="account-dropdown__body">
                                <div class="account-dropdown__item">
                                    <a href="account.php">
                                        <i class="zmdi zmdi-account"></i>Account</a>
                                </div>
                            </div>
                            <?php
                                }
                            ?>
                            <div class="account-dropdown__footer">
                                <?php
                                    if($_SESSION['username'] == ""){
                                ?>
                                    <a href='login.php'>
                                        <i class="zmdi zmdi-power"></i>Login</a>
                                <?php
                                    }
                                ?>
                                <?php
                                    if($_SESSION['username'] == !""){
                                ?>
                                    <a href='action/logout.php'>
                                        <i class="zmdi zmdi-power"></i>Logout</a>
                                <?php
                                    }
                                ?>
                                <a href="forget-pass.html">
                                    <i class="zmdi zmdi-key"></i>Forget Password</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- END HEADER MOBILE -->

        <!-- PAGE CONTENT-->
        <div class="page-content--bgf7">
            <!-- BREADCRUMB-->
            <section class="au-breadcrumb2">
                <div class="container">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="au-breadcrumb-content">
                                <div class="au-breadcrumb-left">
                                    <span class="au-breadcrumb-span">You are here:</span>
                                    <ul class="list-unstyled list-inline au-breadcrumb__list">
                                        <li class="list-inline-item active">
                                            <a href="#">Home</a>
                                        </li>
                                        <li class="list-inline-item seprate">
                                            <span>/</span>
                                        </li>
                                        <li class="list-inline-item"><?php echo $action; ?></li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
            <!-- END BREADCRUMB-->
                                    
            <!-- WELCOME-->
            <section class="welcome p-t-10">
                <div class="container">
                    <div class="row">
                        <div class="col-md-12">
                        <div class="overview-wrap">
                            <h1 class="title-4">Inventory Movement</h1>
                            <form action="index.php" method="request">
                                <button type="submit" name="action" id="allsearch" value="all" class="au-btn au-btn-icon au-btn--blue">
                                    <i class="zmdi zmdi-search"></i>ALl Process</button>
                            </form>
                        </div>
                            <hr class="line-seprate">
                        </div>
                    </div>
                </div>
            </section>
            <!-- END WELCOME-->

            <!-- STATISTIC-->
            <section class="statistic statistic2">
                <div class="container">
                    <div class="row">
                        
                        <div class="col-sm-6 col-lg-3">
                            <div class="overview-item overview-item--c1">
                            <form  method="request" class="form-header" action="index.php">
                            <button type="submit"><input type="hidden" name="action" value="today" />
                                <div class="overview__inner">
                                    <div class="overview-box clearfix">
                                        <div class="icon">
                                            <i class="fa fa-exchange-alt"></i>
                                        </div>
                                        <div class="text">
                                            <h2>
                                                <?php
                                                $sql="SELECT SUM(`process_log`.`amount`) AS `amount` FROM `process_log` WHERE date(`date`) = date(now())";
                                                $result=$db->query($sql);
                                                while($row=$result->fetch_object())
                                                {
                                                ?>
                                                <option value="<?php echo $row->amount;?>">
                                                <?php echo $row->amount;?>
                                                </option>
                                                <?php
                                                }
                                                ?>
                                            </h2>
                                            <span>Action today</span>
                                        </div>
                                    </div>
                                </div>
                            </button>
                            </form>
                            </div>
                        </div>
                        
                        <div class="col-sm-6 col-lg-3">
                            <div class="overview-item overview-item--c2">
                            <form  method="request" class="form-header" action="index.php">
                            <button type="submit"><input type="hidden" name="action" value="todayd" />
                                <div class="overview__inner">
                                    <div class="overview-box clearfix">
                                        <div class="icon">
                                            <i class="fa fa-box"></i>
                                        </div>
                                        <div class="text">
                                            <h2>
                                                <?php
                                                $sql="SELECT SUM(`process_log`.`amount`) AS `amount` FROM `process_log` WHERE `action` = 'deposited' AND date(`date`) = date(now())";
                                                $result=$db->query($sql);
                                                while($row=$result->fetch_object())
                                                {
                                                ?>
                                                <option value="<?php echo $row->amount;?>">
                                                <?php echo $row->amount;?>
                                                </option>
                                                <?php
                                                }
                                                ?>
                                            </h2>
                                            <span>Deposited today</span>
                                        </div>
                                    </div>
                                </div>
                            </button>
                            </form>
                            </div>
                        </div>
                        <div class="col-sm-6 col-lg-3">
                            <div class="overview-item overview-item--c3">
                            <form  method="request" class="form-header" action="index.php">
                            <button type="submit"><input type="hidden" name="action" value="todayw" />
                                <div class="overview__inner">
                                    <div class="overview-box clearfix">
                                        <div class="icon">
                                            <i class="fa fa-box"></i>
                                        </div>
                                        <div class="text">
                                            <h2>
                                                <?php
                                                $sql="SELECT SUM(`process_log`.`amount`) AS `amount` FROM `process_log` WHERE `action` = 'withdraw' AND date(`date`) = date(now())";
                                                $result=$db->query($sql);
                                                while($row=$result->fetch_object())
                                                {
                                                ?>
                                                <option value="<?php echo $row->amount;?>">
                                                <?php echo $row->amount;?>
                                                </option>
                                                <?php
                                                }
                                                ?>
                                            </h2>
                                            <span>Withdraw today</span>
                                        </div>
                                    </div>
                                </div>
                            </button>
                            </form>
                            </div>
                        </div>
                        <div class="col-sm-6 col-lg-3">
                            <div class="overview-item overview-item--c4">
                            <form  method="request" class="form-header" action="index.php">
                            <button type="submit"><input type="hidden" name="action" value="todayr" />
                                <div class="overview__inner">
                                    <div class="overview-box clearfix">
                                        <div class="icon">
                                            <i class="fa fa-pallet"></i>
                                        </div>
                                        <div class="text">
                                            <h2>
                                                <?php
                                                $sql="SELECT SUM(`process_log`.`amount`) AS `amount` FROM `process_log` WHERE `action` = 'return' AND date(`date`) = date(now())";
                                                $result=$db->query($sql);
                                                while($row=$result->fetch_object())
                                                {
                                                ?>
                                                <option value="<?php echo $row->amount;?>">
                                                <?php echo $row->amount;?>
                                                </option>
                                                <?php
                                                }
                                                ?>
                                            </h2>
                                            <span>Return today</span>
                                        </div>
                                    </div>
                                </div>
                            </button>
                            </form>
                            </div>
                        </div>
                        <div class="col-sm-6 col-lg-3">
                            <div class="overview-item overview-item--c1">
                            <form  method="request" class="form-header" action="index.php">
                            <button type="submit"><input type="hidden" name="action" value="thismonth" />
                                <div class="overview__inner">
                                    <div class="overview-box clearfix">
                                        <div class="icon">
                                            <i class="fa fa-exchange-alt"></i>
                                        </div>
                                        <div class="text">
                                            <h2>
                                                <?php
                                                $sql="SELECT SUM(`process_log`.`amount`) AS `amount` FROM `process_log` WHERE month(`date`) = month(now())";
                                                $result=$db->query($sql);
                                                while($row=$result->fetch_object())
                                                {
                                                ?>
                                                <option value="<?php echo $row->amount;?>">
                                                <?php echo $row->amount;?>
                                                </option>
                                                <?php
                                                }
                                                ?>
                                            </h2>
                                            <span>Action this month</span>
                                        </div>
                                    </div>
                                </div>
                            </button>
                            </form>
                            </div>
                        </div>
                        <div class="col-sm-6 col-lg-3">
                            <div class="overview-item overview-item--c2">
                            <form  method="request" class="form-header" action="index.php">
                            <button type="submit"><input type="hidden" name="action" value="thismonthd" />
                                <div class="overview__inner">
                                    <div class="overview-box clearfix">
                                        <div class="icon">
                                            <i class="fa fa-box"></i>
                                        </div>
                                        <div class="text">
                                            <h2>
                                                <?php
                                                $sql="SELECT sum(`process_log`.`amount`) AS `amount` FROM `process_log` WHERE `action` = 'deposited' AND month(`date`) = month(now())";
                                                $result=$db->query($sql);
                                                while($row=$result->fetch_object())
                                                {
                                                ?>
                                                <option value="<?php echo $row->amount;?>">
                                                <?php echo $row->amount;?>
                                                </option>
                                                <?php
                                                }
                                                ?>
                                            </h2>
                                            <span>Deposited thismonth</span>
                                        </div>
                                    </div>
                                </div>
                            </button>
                            </form>
                            </div>
                        </div>
                        <div class="col-sm-6 col-lg-3">
                            <div class="overview-item overview-item--c3">
                            <form  method="request" class="form-header" action="index.php">
                            <button type="submit"><input type="hidden" name="action" value="thismonthw" />
                                <div class="overview__inner">
                                    <div class="overview-box clearfix">
                                        <div class="icon">
                                            <i class="fa fa-box"></i>
                                        </div>
                                        <div class="text">
                                            <h2>
                                                <?php
                                                $sql="SELECT SUM(`process_log`.`amount`) AS `amount` FROM `process_log` WHERE `action` = 'withdraw' AND month(`date`) = month(now())";
                                                $result=$db->query($sql);
                                                while($row=$result->fetch_object())
                                                {
                                                ?>
                                                <option value="<?php echo $row->amount;?>">
                                                <?php echo $row->amount;?>
                                                </option>
                                                <?php
                                                }
                                                ?>
                                            </h2>
                                            <span>Withdraw this month</span>
                                        </div>
                                    </div>
                                </div>
                            </button>
                            </form>
                            </div>
                        </div>
                        <div class="col-sm-6 col-lg-3">
                            <div class="overview-item overview-item--c4">
                            <form  method="request" class="form-header" action="index.php">
                            <button type="submit"><input type="hidden" name="action" value="thismonthr" />
                                <div class="overview__inner">
                                    <div class="overview-box clearfix">
                                        <div class="icon">
                                            <i class="fa fa-pallet"></i>
                                        </div>
                                        <div class="text">
                                            <h2>
                                                <?php
                                                $sql="SELECT SUM(`process_log`.`amount`) AS `amount` FROM `process_log` WHERE `action` = 'return' AND month(`date`) = month(now())";
                                                $result=$db->query($sql);
                                                while($row=$result->fetch_object())
                                                {
                                                ?>
                                                <option value="<?php echo $row->amount;?>">
                                                <?php echo $row->amount;?>
                                                </option>
                                                <?php
                                                }
                                                ?>
                                            </h2>
                                            <span>Return this month</span>
                                        </div>
                                    </div>
                                </div>
                            </button>
                            </form>
                            </div>
                        </div>
                    </div>
                    <hr class="line-seprate">
                </div>
            </section>
            <!-- END STATISTIC-->
            <!--แสดงข้อมูล-->
            <section class="p-t-20 p-b-20">
                <div class="container">
                    <?php
                    {
                    ?>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="row">
                                <div class="col">
                                    <div class="overview-wrap">
                                        <div class="overview-wrap">
                                            <?php
                                            if(isset($_GET['search']))
                                            {
                                            ?>
                                                <font color="blue"><?php echo ($search); ?></font>
                                            <?php
                                            }
                                            ?>
                                            &nbsp;
                                            พบผลลัพธ์
                                            &nbsp;
                                            <b>
                                            <?php
                                            if($action=='today'){
                                                $count="SELECT COUNT(`no`) as `no` FROM `process_log`
                                                WHERE ((`date` LIKE '%$day%') AND (`action` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$day%') AND (`id_mat` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$day%') AND (`no` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$day%') AND (`id_emp` LIKE '%$search%')) 
                                                OR ((`date` LIKE '%$day%') AND (`amount` LIKE '%$search%'));";
                                            }
                                            else if($action=='todayd'){
                                                $count="SELECT COUNT(`no`) as `no` FROM `process_log`
                                                WHERE ((`date` LIKE '%$day%') AND (`action` LIKE 'deposited') AND (`id_mat` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$day%') AND (`action` LIKE 'deposited') AND (`no` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$day%') AND (`action` LIKE 'deposited') AND (`id_emp` LIKE '%$search%')) 
                                                OR ((`date` LIKE '%$day%') AND (`action` LIKE 'deposited') AND (`amount` LIKE '%$search%'));";
                                            }
                                            else if($action=='todayw'){
                                                $count="SELECT COUNT(`no`) as `no` FROM `process_log`
                                                WHERE ((`date` LIKE '%$day%') AND (`action` LIKE 'withdraw') AND (`id_mat` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$day%') AND (`action` LIKE 'withdraw') AND (`no` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$day%') AND (`action` LIKE 'withdraw') AND (`id_emp` LIKE '%$search%')) 
                                                OR ((`date` LIKE '%$day%') AND (`action` LIKE 'withdraw') AND (`amount` LIKE '%$search%'));";
                                            }
                                            else if($action=='todayr'){
                                                $count="SELECT COUNT(`no`) as `no` FROM `process_log`
                                                WHERE ((`date` LIKE '%$day%') AND (`action` LIKE 'return') AND (`id_mat` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$day%') AND (`action` LIKE 'return') AND (`no` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$day%') AND (`action` LIKE 'return') AND (`id_emp` LIKE '%$search%')) 
                                                OR ((`date` LIKE '%$day%') AND (`action` LIKE 'return') AND (`amount` LIKE '%$search%'));";
                                            }
                                            else if($action=='thismonth'){
                                                $count="SELECT COUNT(`no`) as `no` FROM `process_log`
                                                WHERE ((`date` LIKE '%$month%') AND (`action` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$month%') AND (`id_mat` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$month%') AND (`no` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$month%') AND (`id_emp` LIKE '%$search%')) 
                                                OR ((`date` LIKE '%$month%') AND (`amount` LIKE '%$search%'));";
                                            }
                                            else if($action=='thismonthd'){
                                                $count="SELECT COUNT(`no`) as `no` FROM `process_log`
                                                WHERE ((`date` LIKE '%$month%') AND (`action` LIKE 'deposited') AND (`id_mat` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$month%') AND (`action` LIKE 'deposited') AND (`no` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$month%') AND (`action` LIKE 'deposited') AND (`id_emp` LIKE '%$search%')) 
                                                OR ((`date` LIKE '%$month%') AND (`action` LIKE 'deposited') AND (`amount` LIKE '%$search%'));";;
                                            }
                                            else if($action=='thismonthw'){
                                                $count="SELECT COUNT(`no`) as `no` FROM `process_log`
                                                WHERE ((`date` LIKE '%$month%') AND (`action` LIKE 'withdraw') AND (`id_mat` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$month%') AND (`action` LIKE 'withdraw') AND (`no` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$month%') AND (`action` LIKE 'withdraw') AND (`id_emp` LIKE '%$search%')) 
                                                OR ((`date` LIKE '%$month%') AND (`action` LIKE 'withdraw') AND (`amount` LIKE '%$search%'));";
                                            }
                                            else if($action=='thismonthr'){
                                                $count="SELECT COUNT(`no`) as `no` FROM `process_log`
                                                WHERE ((`date` LIKE '%$month%') AND (`action` LIKE 'return') AND (`id_mat` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$month%') AND (`action` LIKE 'return') AND (`no` LIKE '%$search%'))
                                                OR ((`date` LIKE '%$month%') AND (`action` LIKE 'return') AND (`id_emp` LIKE '%$search%')) 
                                                OR ((`date` LIKE '%$month%') AND (`action` LIKE 'return') AND (`amount` LIKE '%$search%'));";
                                            }
                                            else{
                                                $count="SELECT COUNT(`no`) as `no` FROM `process_log`
                                                WHERE (`id_mat` LIKE '%$search%') 
                                                OR (`no` LIKE '%$search%')
                                                OR (`id_emp` LIKE '%$search%') 
                                                OR (`action` LIKE '%$search%') 
                                                OR (`amount` LIKE '%$search%') 
                                                OR (`date` LIKE '%$search%');";
                                            }
                                            

                                            $resultcount=$db->query($count);
                                            while($row=$resultcount->fetch_object())
                                            {
                                            ?>
                                            <option value="<?php echo $row->no;?>">
                                            <?php echo $row->no;?>
                                            </option>
                                            <?php
                                            }
                                            ?>
                                            </b>&nbsp;รายการ
                                        </div>
                                        <form  method="request" class="form-header" action="index.php">
                                            <input id="search" class="au-input au-input--xl" type="text" name="search" value=""  placeholder="กดปุ่มเพื่อแสดงข้อมูลการเบิก-คืน หรือกรอกคำค้นหา" size="control"/>
                                            <button class="au-btn--submit" type="submit">
                                                <input type="hidden" name="action" value="<?php echo ($action); ?>" />
                                                <i class="zmdi zmdi-search"></i>
                                            </button>
                                        </form>
                                        <div class="btn">
                                            <form action="" method="POST">
                                                <button type="submit" name="export" id="btnExport" value="Export" class="au-btn au-btn-icon au-btn--blue">
                                                    <i class="fa fa-file-excel-o"></i>Export</button>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="table-responsive m-b-40">
                                        <table id="tap" class="table table-borderless table-data3">
                                            <thead>
                                                <tr>
                                                    <!--th><div align="center">Number</div></th-->
                                                    <th><div align="center">Action Number</div></th>
                                                    <th><div align="center">Material Number</div></th>
                                                    <th><div align="center">Employee</div></th>
                                                    <th><div align="center">Action</div></th>
                                                    <th><div align="center">Amount</div></th>
                                                    <th><div align="center">Date</div></th>  
                                                </tr>
                                            </thead>  
                                            <?php
                                            //$i = 1;
                                            while($rows=$results->fetch_object()) { 
                                            ?>  
                                            <tbody>
                                                <tr>
                                                    <!--td align="center"><--?php echo $i; $i++; ?></td-->
                                                    <td align="center"><?php echo $rows->no;	?></td>
                                                    <td align="center"><?php echo $rows->id_mat;	?></td>
                                                    <td align="center"><?php echo $rows->id_emp; ?></td>
                                                    <td align="center"><?php echo $rows->action;	?></td>
                                                    <td align="center"><?php echo $rows->amount;	?></td>
                                                    <td align="center"><?php echo $rows->date;	?></td>
                                                </tr>
                                            </tbody>
                                            <?php	   
                                            }
                                            ?>
                                        </table>
                                    
                                    <?php
                                    if($action=='today'){
                                        $sql2 = "SELECT *
                                        FROM process_log
                                        WHERE (`date` LIKE '%$day%') and (`id_mat` LIKE '%$search%') 
                                        OR (`date` LIKE '%$day%') and (`no` LIKE '%$search%')
                                        OR (`date` LIKE '%$day%') and (`id_emp` LIKE '%$search%') 
                                        OR (`date` LIKE '%$day%') and (`action` LIKE '%$search%') 
                                        OR (`date` LIKE '%$day%') and (`amount` LIKE '%$search%')  ORDER BY date";
                                        $query2 = mysqli_query($db, $sql2);
                                        $total_record = mysqli_num_rows($query2);
                                        $total_page = ceil($total_record / $perpage);
                                    }
                                    else if($action=='todayd'){
                                        $sql2 = "SELECT *
                                        FROM process_log
                                        WHERE (`date` LIKE '%$day%') AND (`action` LIKE 'deposited') and (`id_mat` LIKE '%$search%') 
                                        OR (`date` LIKE '%$day%') AND (`action` LIKE 'deposited') and (`no` LIKE '%$search%')
                                        OR (`date` LIKE '%$day%') AND (`action` LIKE 'deposited') and (`id_emp` LIKE '%$search%') 
                                        OR (`date` LIKE '%$day%') AND (`action` LIKE 'deposited') and (`amount` LIKE '%$search%')  ORDER BY date";
                                        $query2 = mysqli_query($db, $sql2);
                                        $total_record = mysqli_num_rows($query2);
                                        $total_page = ceil($total_record / $perpage);
                                    }
                                    else if($action=='todayw'){
                                        $sql2 = "SELECT *
                                        FROM process_log
                                        WHERE ((`date` LIKE '%$day%') AND (`action` LIKE 'withdraw') AND (`id_mat` LIKE '%$search%')) 
                                        OR ((`date` LIKE '%$day%') AND (`action` LIKE 'withdraw') AND (`no` LIKE '%$search%'))
                                        OR ((`date` LIKE '%$day%') AND (`action` LIKE 'withdraw') AND (`id_emp` LIKE '%$search%')) 
                                        OR ((`date` LIKE '%$day%') AND (`action` LIKE 'withdraw') AND (`amount` LIKE '%$search%')) ORDER BY date";
                                        $query2 = mysqli_query($db, $sql2);
                                        $total_record = mysqli_num_rows($query2);
                                        $total_page = ceil($total_record / $perpage);
                                    }
                                    else if($action=='todayr'){
                                        $sql2 = "SELECT *
                                        FROM process_log
                                        WHERE (`date` LIKE '%$day%')
                                        AND (`action` LIKE 'return') ORDER BY date";
                                        $query2 = mysqli_query($db, $sql2);
                                        $total_record = mysqli_num_rows($query2);
                                        $total_page = ceil($total_record / $perpage);
                                    }
                                    else if($action=='thismonth'){
                                        $sql2 = "SELECT *
                                        FROM process_log
                                        WHERE (`date` LIKE '%$month%') and (`id_mat` LIKE '%$search%') 
                                        OR (`date` LIKE '%$month%') and (`no` LIKE '%$search%')
                                        OR (`date` LIKE '%$month%') and (`id_emp` LIKE '%$search%') 
                                        OR (`date` LIKE '%$month%') and (`action` LIKE '%$search%') 
                                        OR (`date` LIKE '%$month%') and (`amount` LIKE '%$search%') ORDER BY date";
                                        $query2 = mysqli_query($db, $sql2);
                                        $total_record = mysqli_num_rows($query2);
                                        $total_page = ceil($total_record / $perpage);
                                    }
                                    else if($action=='thismonthd'){
                                        $sql2 = "SELECT *
                                        FROM process_log
                                        WHERE (`date` LIKE '%$month%')
                                        AND (`action` LIKE 'deposited') ORDER BY date";
                                        $query2 = mysqli_query($db, $sql2);
                                        $total_record = mysqli_num_rows($query2);
                                        $total_page = ceil($total_record / $perpage);
                                    }
                                    else if($action=='thismonthw'){
                                        $sql2 = "SELECT *
                                        FROM process_log
                                        WHERE (`date` LIKE '%$month%')
                                        AND (`action` LIKE 'withdraw') ORDER BY date";
                                        $query2 = mysqli_query($db, $sql2);
                                        $total_record = mysqli_num_rows($query2);
                                        $total_page = ceil($total_record / $perpage);
                                    }
                                    else if($action=='thismonthr'){
                                        $sql2 = "SELECT *
                                        FROM process_log
                                        WHERE (`date` LIKE '%$month%')
                                        AND (`action` LIKE 'return') ORDER BY date";
                                        $query2 = mysqli_query($db, $sql2);
                                        $total_record = mysqli_num_rows($query2);
                                        $total_page = ceil($total_record / $perpage);
                                    }
                                    else {
                                        $sql2 = "SELECT *
                                        FROM process_log
                                        WHERE (`id_mat` LIKE '%$search%') 
                                        OR (`no` LIKE '%$search%')
                                        OR (`id_emp` LIKE '%$search%') 
                                        OR (`action` LIKE '%$search%') 
                                        OR (`amount` LIKE '%$search%') 
                                        OR (`date` LIKE '%$search%') ORDER BY date";
                                        $query2 = mysqli_query($db, $sql2);
                                        $total_record = mysqli_num_rows($query2);
                                        $total_page = ceil($total_record / $perpage);
                                    }
                                    ?>
                                    <?php if ($total_page > 0): ?>
                                    <div align="center">
                                        <ul class="pagination">
                                            <?php if ($page > 1): ?>
                                            <li class="prev">
                                                <a href="index.php?action=<?php echo $action; ?>&search=<?php echo $search; ?>&page=<?php echo $page-1; ?>" aria-label="Previous">
                                                <span aria-hidden="true">&laquo;</span>&nbsp;Prev
                                                </a>
                                            </li>
                                            <?php endif; ?>


                                            <?php if ($page > 3): ?>
                                            <li class="start"><a href="index.php?action=<?php echo $action; ?>&search=<?php echo $search; ?>&page=1">1</a></li>
                                            <li class="dots">...</li>
                                            <?php endif; ?>

                                            <?php if ($page-2 > 0): ?><li class="page"><a href="index.php?action=<?php echo $action; ?>&search=<?php echo $search; ?>&page=<?php echo $page-2 ?>"><?php echo $page-2 ?></a></li><?php endif; ?>
											<?php if ($page-1 > 0): ?><li class="page"><a href="index.php?action=<?php echo $action; ?>&search=<?php echo $search; ?>&page=<?php echo $page-1 ?>"><?php echo $page-1 ?></a></li><?php endif; ?>
                                            
                                            <li class="currentpage">
                                                <a href="index.php?action=<?php echo $action; ?>&search=<?php echo $search; ?>&page=<?php echo $page; ?>">
                                                    <?php echo $page; ?>
                                                </a>
                                            </li>

											<?php if ($page+1 < $total_page+1): ?><li class="page"><a href="index.php?action=<?php echo $action; ?>&search=<?php echo $search; ?>&page=<?php echo $page+1 ?>"><?php echo $page+1 ?></a></li><?php endif; ?>
											<?php if ($page+2 < $total_page+1): ?><li class="page"><a href="index.php?action=<?php echo $action; ?>&search=<?php echo $search; ?>&page=<?php echo $page+2 ?>"><?php echo $page+2 ?></a></li><?php endif; ?>

											<?php if ($page < $total_page-2): ?>
											<li class="dots">...</li>
											<li class="end"><a href="index.php?action=<?php echo $action; ?>&search=<?php echo $search; ?>&page=<?php echo $total_page ?>"><?php echo $total_page ?></a></li>
											<?php endif; ?>
                                            

                                            <?php if ($page < $total_page): ?>
                                            <li class="next">
                                                <a href="index.php?action=<?php echo $action; ?>&search=<?php echo $search; ?>&page=<?php echo $page+1;?>" aria-label="Next">
                                                    Next&nbsp;<span aria-hidden="true">&raquo;</span>
                                                </a>
                                            </li>
                                            <?php endif; ?>
                                        </ul>
                                    </div>
                                    <?php endif; ?>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php       
					}
					?>
                </div>
            </section>
            <!-- COPYRIGHT-->
            <section class="p-t-60 p-b-20">
                <div class="container">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="copyright">
                            <p>Copyright © 2020</a>.</p>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
            <!-- END COPYRIGHT-->
        </div>

    </div>

    <!-- Jquery JS-->
    <script src="vendor/jquery-3.2.1.min.js"></script>
    <!-- Bootstrap JS-->
    <script src="vendor/bootstrap-4.1/popper.min.js"></script>
    <script src="vendor/bootstrap-4.1/bootstrap.min.js"></script>
    <!-- Vendor JS       -->
    <script src="vendor/slick/slick.min.js">
    </script>
    <script src="vendor/wow/wow.min.js"></script>
    <script src="vendor/animsition/animsition.min.js"></script>
    <script src="vendor/bootstrap-progressbar/bootstrap-progressbar.min.js">
    </script>
    <script src="vendor/counter-up/jquery.waypoints.min.js"></script>
    <script src="vendor/counter-up/jquery.counterup.min.js">
    </script>
    <script src="vendor/circle-progress/circle-progress.min.js"></script>
    <script src="vendor/perfect-scrollbar/perfect-scrollbar.js"></script>
    <script src="vendor/chartjs/Chart.bundle.min.js"></script>
    <script src="vendor/select2/select2.min.js">
    </script>

    <!-- Main JS-->
    <script src="js/main.js"></script>

</body>

</html>
<!-- end document-->
<file_sep><?php
date_default_timezone_set("Asia/Bangkok");
include("../connection/phpconnect.php");

$time = date("ymdHis");
$id_mat = $_REQUEST['id_mat'];
$id_store = $_REQUEST['id_store'];
$no = "$id_store$time";
$id_shelf = $_REQUEST['id_shelf'];
$id_employee = $_REQUEST['id_employee'];
$amount = $_REQUEST['amount'];
$date = date("Y-m-d H:i:s");

$call="SELECT * FROM `withdraw_return` WHERE `no` = $no;";
$result = mysqli_query($db, $call);

if($result->num_rows==0)
{
	$amlo = "SELECT * FROM `location` WHERE `id_mat` = '$id_mat' AND `id_store` = '$id_store' AND `id_shelf` = '$id_shelf'";
	$reamlo = mysqli_query($db, $amlo);
	if($reamlo->num_rows==1){
		$cc = "SELECT `amount` FROM `location` WHERE `id_mat` = '$id_mat' AND `id_store` = '$id_store' AND `id_shelf` = '$id_shelf'";
		$recc = mysqli_query($db, $cc);
		$ch = $recc - $amount;
		
			$sqlup = "UPDATE
			`location`
			SET
			`amount` = `amount` - '$amount'
			WHERE
			`id_mat` = '$id_mat' AND `id_store` = '$id_store' AND `id_shelf` = '$id_shelf'";
			$ubdate = mysqli_query($db, $sqlup);

			$sql="INSERT INTO `withdraw_return` (`no`, `id_mat`, `id_employee`, `action`, `amount`, `date`)
			VALUES ('$no','$id_mat','$id_employee','withdraw','$amount','$date')";
			$insert = mysqli_query($db, $sql);
			echo $ch;
			echo "<script type='text/javascript'>";
			echo "alert('ทำรายการสำเร็จ');";
			//echo "window.location = '../search.php?search=&submit='; ";
			echo "</script>";
		
	}
	if($reamlo->num_rows==0){
		echo "<script type='text/javascript'>";
		echo "alert('ไม่พบข้อมูล กรุณาทำรายการอีกครั้ง');";
		echo "window.history.back()";
		echo "</script>";
	}
}else
{
	echo "<script type='text/javascript'>";
	echo "alert('ไม่สามารถทำรายการได้');";
	echo "window.history.back()";
	echo "</script>";
}
?><file_sep><!DOCTYPE html>
<html lang="en">
<?php
	include('connection/phpconnect.php');
	$search = (isset($_GET['search'])) ? $_GET['search'] : '';
	$sql = "SELECT * FROM `withdraw_return` WHERE (`id_mat` LIKE '%$search%') OR (`id_employee` LIKE '%$search%') OR (`action` LIKE '%$search%') OR (`volume` LIKE '%$search%') OR (`date` LIKE '%$search%') ORDER BY date;";
	$result = mysqli_query($db, $sql);
?>
<head>
    <!-- Required meta tags-->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="au theme template">
    <meta name="author" content="<NAME>">
    <meta name="keywords" content="au theme template">

    <!-- Title Page-->
    <title>Dashboard</title>

    <!-- Fontfaces CSS-->
    <link href="css/font-face.css" rel="stylesheet" media="all">
    <link href="vendor/font-awesome-4.7/css/font-awesome.min.css" rel="stylesheet" media="all">
    <link href="vendor/font-awesome-5/css/fontawesome-all.min.css" rel="stylesheet" media="all">
    <link href="vendor/mdi-font/css/material-design-iconic-font.min.css" rel="stylesheet" media="all">

    <!-- Bootstrap CSS-->
    <link href="vendor/bootstrap-4.1/bootstrap.min.css" rel="stylesheet" media="all">

    <!-- Vendor CSS-->
    <link href="vendor/animsition/animsition.min.css" rel="stylesheet" media="all">
    <link href="vendor/bootstrap-progressbar/bootstrap-progressbar-3.3.4.min.css" rel="stylesheet" media="all">
    <link href="vendor/wow/animate.css" rel="stylesheet" media="all">
    <link href="vendor/css-hamburgers/hamburgers.min.css" rel="stylesheet" media="all">
    <link href="vendor/slick/slick.css" rel="stylesheet" media="all">
    <link href="vendor/select2/select2.min.css" rel="stylesheet" media="all">
    <link href="vendor/perfect-scrollbar/perfect-scrollbar.css" rel="stylesheet" media="all">

    <!-- Main CSS-->
    <link href="css/theme.css" rel="stylesheet" media="all">

	
	
	
</head>

<body class="animsition">
    <div class="page">
        <!-- HEADER MOBILE-->
        <header class="header-mobile d-block d-lg-none">
            <div class="header-mobile__bar">
                <div class="container-fluid">
                    <div class="header-mobile-inner">
                        <a class="logo" href="index.html">
                            <img src="images/icon/true2.png" alt="CoolAdmin" />
                        </a>
                        <button class="hamburger hamburger--slider" type="button">
                            <span class="hamburger-box">
                                <span class="hamburger-inner"></span>
                            </span>
                        </button>
                    </div>
                </div>
            </div>
            <nav class="navbar-mobile">
                <div class="container-fluid">
                    <ul class="navbar-mobile__list list-unstyled">
                        <li class="has-sub">
                            <a class="js-arrow" href="#">
                                <i class="fas fa-tachometer-alt"></i>Dashboard</a>
                        </li>
                        <li>
                            <a href="#">
                                <i class="fas fa-chart-bar"></i>Charts</a>
                        </li>
                        <li>
                            <a href="#">
                                <i class="fas fa-table"></i>Tables</a>
                        </li>
                        <li>
                            <a href="#">
                                <i class="far fa-check-square"></i>Forms</a>
                        </li>
						<li class="has-sub">
                            <a class="js-arrow" href="#">
                                <i class="fas fa-copy"></i>Pages</a>
                            <ul class="navbar-mobile-sub__list list-unstyled js-sub-list">
                                <li>
                                    <a href="login.html">Login</a>
                                </li>
                                <li>
                                    <a href="register.html">Register</a>
                                </li>
                                <li>
                                    <a href="forget-pass.php">Forget Password</a>
                                </li>
                            </ul>
                        </li>
                        <li>
                            <a href="form_wr.html">
                                <i class="fas fa-calendar-alt"></i>Withdrw-Return</a>
                        </li>
                    </ul>
                </div>
            </nav>
        </header>
        <!-- END HEADER MOBILE-->

        <!-- MENU SIDEBAR-->
        <aside class="menu-sidebar d-none d-lg-block">
            <div class="logo">
                <a href="#">
                    <img src="images/icon/true2.png" alt="Cool Admin" />
                </a>
            </div>
            <div class="menu-sidebar__content js-scrollbar1">
                <nav class="navbar-sidebar">
                    <ul class="list-unstyled navbar__list">
                        <li class="active has-sub">
                            <a class="js-arrow" href="#">
                                <i class="fas fa-tachometer-alt"></i>Dashboard</a>
                        </li>
                        <li>
                            <a href="#">
                                <i class="fas fa-chart-bar"></i>Charts</a>
                        </li>
                        <li>
                            <a href="#">
                                <i class="fas fa-table"></i>Tables</a>
                        </li>
                        <li>
                            <a href="#">
                                <i class="far fa-check-square"></i>Forms</a>
                        </li>
						<li class="has-sub">
                            <a class="js-arrow" href="#">
                                <i class="fas fa-copy"></i>Pages</a>
                            <ul class="list-unstyled navbar__sub-list js-sub-list">
                                <li>
                                    <a href="login.html">Login</a>
                                </li>
                                <li>
                                    <a href="register.html">Register</a>
                                </li>
                                <li>
                                    <a href="forget-pass.html">Forget Password</a>
                                </li>
                            </ul>
                        </li>
                        <li>
                            <a href="form_wr.php">
                                <i class="fas fa-calendar-alt"></i>Withdrw-Return</a>
                        </li>
                    </ul>
                </nav>
            </div>
        </aside>
        <!-- END MENU SIDEBAR-->

        <!-- PAGE CONTAINER-->
        <div class="page-container">
            <!-- HEADER DESKTOP-->
            <header class="header-desktop">
                <div class="section__content section__content--p30">
                    <div class="container-fluid">
                        <div class="header-wrap">
                            <form  method="request" class="form-header" action="search.php">
                                <input id="search" class="au-input au-input--xl" type="text" name="search" placeholder="กดปุ่มเพื่อแสดงข้อมูลการเบิก-คืนทั้งหมด หรือกรอกเพื่อค้นหา" size="control" />
                                <button class="au-btn--submit" type="submit" name="submit">
                                    <i class="zmdi zmdi-search"></i>
                                </button>
                            </form>
                            <div class="header-button">
                                <div class="account-wrap">
                                    <div class="account-item clearfix js-item-menu">
                                        <div class="image">
                                            <img src="images/icon/avatar-01.jpg" alt="<NAME>" />
                                        </div>
                                        <div class="content">
                                            <a class="js-acc-btn" href="#"><NAME></a>
                                        </div>
                                        <div class="account-dropdown js-dropdown">
                                            <div class="info clearfix">
                                                <div class="image">
                                                    <a href="#">
                                                        <img src="images/icon/avatar-01.jpg" alt="<NAME>" />
                                                    </a>
                                                </div>
                                                <div class="content">
                                                    <h5 class="name">
                                                        <a href="#"><NAME></a>
                                                    </h5>
                                                    <span class="email"><EMAIL></span>
                                                </div>
                                            </div>
                                            <div class="account-dropdown__body">
                                                <div class="account-dropdown__item">
                                                    <a href="#">
                                                        <i class="zmdi zmdi-account"></i>Account</a>
                                                </div>
                                                <div class="account-dropdown__item">
                                                    <a href="#">
                                                        <i class="zmdi zmdi-settings"></i>Setting</a>
                                                </div>
                                                <div class="account-dropdown__item">
                                                    <a href="form_mat.php">
                                                        <i class="zmdi zmdi-plus"></i>Add new MAT</a>
                                                </div>
                                            </div>
                                            <div class="account-dropdown__footer">
                                                <a href="#">
                                                    <i class="zmdi zmdi-power"></i>Logout</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </header>
            <!-- HEADER DESKTOP-->

            <!-- MAIN CONTENT-->
            <div class="main-content">
                <div class="section__content section__content--p30">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="overview-wrap">
                                    <h2 class="title-1">overview</h2>
                                    <button class="au-btn au-btn-icon au-btn--blue">
                                        <i class="zmdi zmdi-plus"></i>add item</button>
                                </div>
                            </div>
                        </div>
                        <div class="row m-t-25">
							<div class="col-sm-6 col-lg-3">
                                <div class="overview-item overview-item--c2">
                                    <div class="overview__inner">
                                        <div class="overview-box clearfix">
                                            <div class="icon">
                                                <i class="zmdi zmdi-shopping-cart"></i>
                                            </div>
                                            <div class="text">
                                                <h2>388,688</h2>
                                                <span>เบิก</span>
                                            </div>
                                        </div>
                                        <div class="overview-chart">
                                            <canvas id="widgetChart2"></canvas>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-6 col-lg-3">
                                <div class="overview-item overview-item--c2">
                                    <div class="overview__inner">
                                        <div class="overview-box clearfix">
                                            <div class="icon">
                                                <i class="zmdi zmdi-shopping-cart"></i>
                                            </div>
                                            <div class="text">
                                                <h2>388,688</h2>
                                                <span>คืน</span>
                                            </div>
                                        </div>
                                        <div class="overview-chart">
                                            <canvas id="widgetChart2"></canvas>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-6 col-lg-3">
                                <div class="overview-item overview-item--c1">
                                    <div class="overview__inner">
                                        <div class="overview-box clearfix">
                                            <div class="icon">
                                                <i class="zmdi zmdi-account-o"></i>
                                            </div>
                                            <div class="text">
                                                <h2>10368</h2>
                                                <span>members online</span>
                                            </div>
                                        </div>
                                        <div class="overview-chart">
                                            <canvas id="widgetChart1"></canvas>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            
                            <div class="col-sm-6 col-lg-3">
                                <div class="overview-item overview-item--c3">
                                    <div class="overview__inner">
                                        <div class="overview-box clearfix">
                                            <div class="icon">
                                                <i class="zmdi zmdi-calendar-note"></i>
                                            </div>
                                            <div class="text">
                                                <h2>1,086</h2>
                                                <span>this week</span>
                                            </div>
                                        </div>
                                        <div class="overview-chart">
                                            <canvas id="widgetChart3"></canvas>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-6 col-lg-3">
                                <div class="overview-item overview-item--c4">
                                    <div class="overview__inner">
                                        <div class="overview-box clearfix">
                                            <div class="icon">
                                                <i class="zmdi zmdi-money"></i>
                                            </div>
                                            <div class="text">
                                                <h2>$1,060,386</h2>
                                                <span>total earnings</span>
                                            </div>
                                        </div>
                                        <div class="overview-chart">
                                            <canvas id="widgetChart4"></canvas>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-6">
                                <div class="au-card recent-report">
                                    <div class="au-card-inner">
                                        <h3 class="title-2">recent reports</h3>
                                        <div class="chart-info">
                                            <div class="chart-info__left">
                                                <div class="chart-note">
                                                    <span class="dot dot--blue"></span>
                                                    <span>products</span>
                                                </div>
                                                <div class="chart-note mr-0">
                                                    <span class="dot dot--green"></span>
                                                    <span>services</span>
                                                </div>
                                            </div>
                                            <div class="chart-info__right">
                                                <div class="chart-statis">
                                                    <span class="index incre">
                                                        <i class="zmdi zmdi-long-arrow-up"></i>25%</span>
                                                    <span class="label">products</span>
                                                </div>
                                                <div class="chart-statis mr-0">
                                                    <span class="index decre">
                                                        <i class="zmdi zmdi-long-arrow-down"></i>10%</span>
                                                    <span class="label">services</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="recent-report__chart">
                                            <canvas id="recent-rep-chart"></canvas>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-6">
                                <div class="au-card chart-percent-card">
                                    <div class="au-card-inner">
                                        <h3 class="title-2 tm-b-5">char by %</h3>
                                        <div class="row no-gutters">
                                            <div class="col-xl-6">
                                                <div class="chart-note-wrap">
                                                    <div class="chart-note mr-0 d-block">
                                                        <span class="dot dot--blue"></span>
                                                        <span>products</span>
                                                    </div>
                                                    <div class="chart-note mr-0 d-block">
                                                        <span class="dot dot--red"></span>
                                                        <span>services</span>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-xl-6">
                                                <div class="percent-chart">
                                                    <canvas id="percent-chart"></canvas>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
						
						
						
                        <div class="row">
                            <div class="col-lg">
                                <h2 class="title-1 m-b-25">Earnings By Items</h2>
                                <div class="table-responsive table--no-card m-b-40">
                                    <table class="table table-borderless table-striped table-earning">
                                        <thead>
                                            <tr>
                                                <th>date</th>
                                                <th>order ID</th>
                                                <th>name</th>
                                                <th class="text-right">price</th>
                                                <th class="text-right">quantity</th>
                                                <th class="text-right">total</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr>
                                                <td>2018-09-29 05:57</td>
                                                <td>100398</td>
                                                <td>iPhone X 64Gb Grey</td>
                                                <td class="text-right">$999.00</td>
                                                <td class="text-right">1</td>
                                                <td class="text-right">$999.00</td>
                                            </tr>
                                            <tr>
                                                <td>2018-09-28 01:22</td>
                                                <td>100397</td>
                                                <td>Samsung S8 Black</td>
                                                <td class="text-right">$756.00</td>
                                                <td class="text-right">1</td>
                                                <td class="text-right">$756.00</td>
                                            </tr>
                                            <tr>
                                                <td>2018-09-27 02:12</td>
                                                <td>100396</td>
                                                <td>Game Console Controller</td>
                                                <td class="text-right">$22.00</td>
                                                <td class="text-right">2</td>
                                                <td class="text-right">$44.00</td>
                                            </tr>
                                            <tr>
                                                <td>2018-09-26 23:06</td>
                                                <td>100395</td>
                                                <td>iPhone X 256Gb Black</td>
                                                <td class="text-right">$1199.00</td>
                                                <td class="text-right">1</td>
                                                <td class="text-right">$1199.00</td>
                                            </tr>
                                            <tr>
                                                <td>2018-09-25 19:03</td>
                                                <td>100393</td>
                                                <td>USB 3.0 Cable</td>
                                                <td class="text-right">$10.00</td>
                                                <td class="text-right">3</td>
                                                <td class="text-right">$30.00</td>
                                            </tr>
                                            <tr>
                                                <td>2018-09-29 05:57</td>
                                                <td>100392</td>
                                                <td>Smartwatch 4.0 LTE Wifi</td>
                                                <td class="text-right">$199.00</td>
                                                <td class="text-right">6</td>
                                                <td class="text-right">$1494.00</td>
                                            </tr>
                                            <tr>
                                                <td>2018-09-24 19:10</td>
                                                <td>100391</td>
                                                <td>Camera C430W 4k</td>
                                                <td class="text-right">$699.00</td>
                                                <td class="text-right">1</td>
                                                <td class="text-right">$699.00</td>
                                            </tr>
                                            <tr>
                                                <td>2018-09-22 00:43</td>
                                                <td>100393</td>
                                                <td>USB 3.0 Cable</td>
                                                <td class="text-right">$10.00</td>
                                                <td class="text-right">3</td>
                                                <td class="text-right">$30.00</td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="copyright">
                                    <p>Copyright © 2018 Colorlib. All rights reserved. Template by <a href="https://colorlib.com">Colorlib</a>.</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- END MAIN CONTENT-->
            <!-- END PAGE CONTAINER-->
        </div>

    </div>

    <!-- Jquery JS-->
    <script src="vendor/jquery-3.2.1.min.js"></script>
    <!-- Bootstrap JS-->
    <script src="vendor/bootstrap-4.1/popper.min.js"></script>
    <script src="vendor/bootstrap-4.1/bootstrap.min.js"></script>
    <!-- Vendor JS       -->
    <script src="vendor/slick/slick.min.js">
    </script>
    <script src="vendor/wow/wow.min.js"></script>
    <script src="vendor/animsition/animsition.min.js"></script>
    <script src="vendor/bootstrap-progressbar/bootstrap-progressbar.min.js">
    </script>
    <script src="vendor/counter-up/jquery.waypoints.min.js"></script>
    <script src="vendor/counter-up/jquery.counterup.min.js">
    </script>
    <script src="vendor/circle-progress/circle-progress.min.js"></script>
    <script src="vendor/perfect-scrollbar/perfect-scrollbar.js"></script>
    <script src="vendor/chartjs/Chart.bundle.min.js"></script>
    <script src="vendor/select2/select2.min.js">
    </script>

    <!-- Main JS-->
    <script src="js/main.js"></script>
	
	
	

</body>

</html>
<!-- end document-->
<file_sep><?php
include('../connection/phpconnect.php');
$del = $_REQUEST['id_shelf'];
$strSQL = "DELETE
FROM
    `shelf`
WHERE
    `id_shelf` = $del";

$objQuery = mysqli_query($db, $strSQL);
if($objQuery)
{
	echo "<script type='text/javascript'>";
	echo "alert('Record Deleted!');";
	echo "window.location = '../form_show_shelf.php'; ";
	echo "</script>";
}
else
{
	echo "<script type='text/javascript'>";
	echo "alert('Error Delete [".$strSQL."]');";
	echo "window.location = '../form_show_shelf.php'; ";
	echo "</script>";
	
}
mysqli_close($db);
?><file_sep><?php
include("../connection/phpconnect.php");
$id_shelf = $_REQUEST['id_shelf'];
$name = $_REQUEST['name'];
$id_store = $_REQUEST['id_store'];
$call = "SELECT * FROM `shelf` WHERE `id_shelf` = $id_shelf;";
$result = mysqli_query($db, $call);
if($result->num_rows==0)
{
	$sql="INSERT INTO `shelf` 
	VALUES ('$id_shelf' ,'$name' ,'$id_store');";
	$insert = mysqli_query($db, $sql);
	//echo $sql;
	echo "<script type='text/javascript'>";
	echo "alert('เพิ่มข้อมูลสำเร็จ');";
	echo "window.location = '../form_show_shelf.php'; ";
	echo "</script>";
}else if($result->num_rows==1)
{
	echo "<script type='text/javascript'>";
	echo "alert('ไม่สามารถเพิ่มข้อมูลได้');";
	echo "window.location = '../form_show_shelf.php'; ";
	echo "</script>";
}
?><file_sep><?php
include("../connection/phpconnect.php");
$id_emp = $_REQUEST['id_emp'];
$name = $_REQUEST['name'];
$department = $_REQUEST['department'];
$position = $_REQUEST['position'];

    $sqlup = "UPDATE
        `employee`
        SET
        `id_emp` = '$id_emp',
		`name` = '$name',
		`department` = '$department',
		`position` = '$position'
        WHERE
        `id_emp` = '$id_emp'";
	$update = mysqli_query($db, $sqlup);
	
	if($update){
		echo "<script type='text/javascript'>";
		echo "alert('Update Succesfuly');";
		echo "window.location = '../form_show_emp.php'; ";
		echo "</script>";
		}
		else{
		echo "<script type='text/javascript'>";
		echo "alert('Error');";
		echo "window.history.back()";
		echo "</script>";
	}
	mysqli_close($db);
?><file_sep><?php
include("../connection/phpconnect.php");
$id_store = $_REQUEST['id_store'];
$storename = $_REQUEST['storename'];
$id_plant = $_REQUEST['id_plant'];
$call = "SELECT * FROM `store` WHERE `id_store` = $id_store;";
$result = mysqli_query($db, $call);
if($result->num_rows==0)
{
	$sql="INSERT INTO `store` 
	VALUES ('$id_store' ,'$storename' ,'$id_plant');";
	$insert = mysqli_query($db, $sql);
	//echo $sql;
	echo "<script type='text/javascript'>";
	echo "alert('เพิ่มข้อมูลสำเร็จ');";
	echo "window.location = '../form_show_store.php'; ";
	echo "</script>";
}else if($result->num_rows==1)
{
	echo "<script type='text/javascript'>";
	echo "alert('ไม่สามารถเพิ่มข้อมูลได้');";
	echo "window.location = '../form_show_store.php'; ";
	echo "</script>";
}
?><file_sep><?php
include("../connection/phpconnect.php");
$id = $_REQUEST['id'];
$plant = $_REQUEST['plant'];
$call = "SELECT * FROM `plant` WHERE `id` = $id;";
$result = mysqli_query($db, $call);
if($result->num_rows==0)
{
	$sql="INSERT INTO `plant` 
	VALUES ('$id','$plant');";
	$insert = mysqli_query($db, $sql);
	//echo $sql;
	echo "<script type='text/javascript'>";
	echo "alert('เพิ่มข้อมูลสำเร็จ');";
	echo "window.location = '../form_show_plant.php'; ";
	echo "</script>";
}else if($result->num_rows==1)
{
	echo "<script type='text/javascript'>";
	echo "alert('ไม่สามารถเพิ่มข้อมูลได้');";
	echo "window.location = '../form_show_plant.php'; ";
	echo "</script>";
}
?><file_sep><?php
include("../connection/phpconnect.php");
$id_mat = $_REQUEST['id_mat'];
$id_store = $_REQUEST['id_store'];
$id_shelf = $_REQUEST['id_shelf'];
$amount = $_REQUEST['amount'];

$sqlup = "UPDATE
`location_fail`
SET
`amount` = '$amount'
WHERE
`id_mat` = '$id_mat' AND `id_store` = '$id_store' AND `id_shelf` = '$id_shelf'";
$update = mysqli_query($db, $sqlup);
	
	if($update){
		echo "<script type='text/javascript'>";
		echo "alert('Update Succesfuly');";
		echo "window.location = '../form_show_location_fail.php'; ";
		echo "</script>";
		}
		else{
		echo "<script type='text/javascript'>";
		echo "alert('Error');";
		echo "window.history.back()";
		echo "</script>";
	}
	mysqli_close($db);
?><file_sep><?php
date_default_timezone_set("Asia/Bangkok");
include("../connection/phpconnect.php");
$id_shelf = $_REQUEST['id_shelf'];
$id_store = $_REQUEST['id_store'];
$time = date("ymdHis");

$no = "$id_store$time";
$id_mat = $_REQUEST['id_mat'];
$id_employee = $_REQUEST['id_employee'];
$action = $_REQUEST['action'];
$amount = $_REQUEST['amount'];
$date = date("Y-m-d H:i:s");

$call="SELECT * FROM `withdraw_return` WHERE `no` = $no;";
$result = mysqli_query($db, $call);
if($result->num_rows==0)
{
	$amlo = "SELECT * FROM `location` WHERE `id_mat` = '$id_mat' AND `id_store` = '$id_store' AND `id_shelf` = '$id_shelf'";
	$reamlo = mysqli_query($db, $amlo);
	if($action=='withdraw'){
		if($reamlo->num_rows==1){
			$check = `amount` - $amount;
			if($check > 0){
				$sqlup = "UPDATE
				`location`
				SET
				`amount` = `amount` - '$amount'
				WHERE
				`id_mat` = '$id_mat' AND `id_store` = '$id_store' AND `id_shelf` = '$id_shelf'";
				$ubdate = mysqli_query($db, $sqlup);

				$sql="INSERT INTO `withdraw_return` (`no`, `id_mat`, `id_employee`, `action`, `amount`, `date`)
				VALUES ('$no','$id_mat','$id_employee','$action','$amount','$date')";
				$insert = mysqli_query($db, $sql);
				//echo $sql;
				echo "<script type='text/javascript'>";
				echo "alert('ทำรายการสำเร็จ');";
				echo "window.location = '../form_wr.php'; ";
				echo "</script>";
			}
			else
			{
				echo "<script type='text/javascript'>";
				echo "alert('อุปกรณ์มีไม่เพียงพอ กรุณาระบุจำนวนอีกครั้ง');";
				echo "window.history.back()";
				echo "</script>";
			}
		}
		if($reamlo->num_rows==0){
			echo "<script type='text/javascript'>";
			echo "alert('ไม่พบข้อมูล กรุณาทำรายการอีกครั้ง');";
			echo "window.history.back()";
			echo "</script>";
		}
	}
	if($action=='return'){
		$sql="INSERT INTO `withdraw_return` (`no`, `id_mat`, `id_employee`, `action`, `amount`, `date`)
		VALUES ('$no','$id_mat','$id_employee','$action','$amount','$date')";
		$insert = mysqli_query($db, $sql);
		//echo $sql;
		echo "<script type='text/javascript'>";
		echo "alert('ทำรายการสำเร็จ');";
		echo "window.location = '../form_wr.php'; ";
		echo "</script>";
	}
	if($action=='deposited'){
		if($reamlo->num_rows==1){
			$sqlup = "UPDATE
			`location`
			SET
			`amount` = `amount` + '$amount'
			WHERE
			`id_mat` = '$id_mat' AND `id_store` = '$id_store' AND `id_shelf` = '$id_shelf'";
			$ubdate = mysqli_query($db, $sqlup);

			$sql="INSERT INTO `withdraw_return` (`no`, `id_mat`, `id_employee`, `action`, `amount`, `date`)
			VALUES ('$no','$id_mat','$id_employee','$action','$amount','$date')";
			$insert = mysqli_query($db, $sql);
			//echo $sql;
			echo "<script type='text/javascript'>";
			echo "alert('ทำรายการสำเร็จ');";
			echo "window.location = '../form_wr.php'; ";
			echo "</script>";
		}
		if($reamlo->num_rows==0){
			$sqllo="INSERT INTO `location` (`num_lo`, `id_mat`, `id_store`, `id_shelf`, `amount`)
			VALUES ('$num_lo','$id_mat','$id_store','$id_shelf','$amount')";
			$insert1 = mysqli_query($db, $sqllo);

			$sql="INSERT INTO `withdraw_return` (`no`, `id_mat`, `id_employee`, `action`, `amount`, `date`)
			VALUES ('$no','$id_mat','$id_employee','$action','$amount','$date')";
			$insert = mysqli_query($db, $sql);
			//echo $sql;
			echo "<script type='text/javascript'>";
			echo "alert('ทำรายการสำเร็จ');";
			echo "window.location = '../form_wr.php'; ";
			echo "</script>";
		}
	}
}else
{
	echo "<script type='text/javascript'>";
	echo "alert('ไม่สามารถทำรายการได้');";
	echo "window.history.back()";
	echo "</script>";
}
?><file_sep><?php
include("../connection/phpconnect.php");
$department = $_REQUEST['department'];
$call = "SELECT * FROM `department` WHERE `department` = $department;";
$result = mysqli_query($db, $call);
if($result->num_rows==0)
{
	$sql="INSERT INTO `department` 
	VALUES ('$department');";
	$insert = mysqli_query($db, $sql);
	//echo $sql;
	echo "<script type='text/javascript'>";
	echo "alert('เพิ่มข้อมูลสำเร็จ');";
	echo "window.location = '../form_show_department.php'; ";
	echo "</script>";
}else if($result->num_rows==1)
{
	echo "<script type='text/javascript'>";
	echo "alert('ไม่สามารถเพิ่มข้อมูลได้');";
	echo "window.location = '../form_show_department.php'; ";
	echo "</script>";
}
?><file_sep><?php
$db_server = "db";
$db_user = "root";
$db_pass = "<PASSWORD>";
$db_src ="inventory";
$db = new mysqli($db_server,$db_user,$db_pass,$db_src);
$db->query("set names utf8");
if ($db->connect_error) {
echo "Connection failed: " . $db->connect_error;
} 
?><file_sep><?php
include("../connection/phpconnect.php");
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$to = $_REQUEST['email'];
$sql = "SELECT * FROM `users` WHERE `email` = $to;";
$result = mysqli_query($db, $sql);
if($result->num_rows==1){
    while($rows=$result->fetch_object()){
        $username = $rows->username;
        $password = $rows->password;
        $subject = "Forget-Pass";
        $txt = "$username<br>$password";
        $headers = "From: <EMAIL>" . "\r\n" .
        "CC: $to";
        mail($to,$subject,$txt,$headers);
        echo "<script type='text/javascript'>";
		echo "alert('ทำรายการสำเร็จ');";
		//echo "window.location = '../forget-pass.html';";
		echo "</script>";
    }
}
else{
    echo $to,"<br>";
    echo $username,"<br>";
    echo $password;
    echo "<script type='text/javascript'>";
    echo "alert('ไม่สามารถทำรายการได้');";
    //echo "window.history.back()";
    echo "</script>";
}
?><file_sep><?php
include("../connection/phpconnect.php");
$id_shelf = $_REQUEST['id_shelf'];
$name = $_REQUEST['name'];
$id_store = $_REQUEST['id_store'];

    $sqlup = "UPDATE
        `shelf`
        SET
        `id_shelf` = '$id_shelf',
		`name` = '$name',
		`id_store` = '$id_store'
        WHERE
        `id_shelf` = '$id_shelf'";
	$update = mysqli_query($db, $sqlup);
	
	if($update){
		echo "<script type='text/javascript'>";
        echo "alert('Update Succesfuly, ";
        echo "Store ID : $id_shelf, ";
        echo "Store Name : $name, ";
        echo "Plant ID : $id_store');";
		echo "window.location = '../form_show_shelf.php'; ";
		echo "</script>";
		}
		else{
		echo "<script type='text/javascript'>";
		echo "alert('Error');";
		echo "window.history.back()";
		echo "</script>";
	}
	mysqli_close($db);
?><file_sep><?php
include("../connection/phpconnect.php");
$id_emp = $_REQUEST['id_emp'];
$name = $_REQUEST['name'];
$department = $_REQUEST['department'];
$position = $_REQUEST['position'];
$call = "SELECT * FROM `employee` WHERE `id_emp` = $id_emp;";
$result = mysqli_query($db, $call);
if($result->num_rows==0)
{
	$sql="INSERT INTO `employee`
	VALUES ('$id_emp' ,'$name' ,'$department' ,'$position');";
	$insert = mysqli_query($db, $sql);
	//echo $sql;
	echo "<script type='text/javascript'>";
	echo "alert('เพิ่มข้อมูลสำเร็จ');";
	echo "window.location = '../form_show_emp.php'; ";
	echo "</script>";
}else if($result->num_rows==1)
{
	echo "<script type='text/javascript'>";
	echo "alert('ไม่สามารถเพิ่มข้อมูลได้');";
	echo "window.location = '../form_show_emp.php'; ";
	echo "</script>";
}
?><file_sep><?php
include("../connection/phpconnect.php");
$Username = $_REQUEST['Username'];
$Email = $_REQUEST['Email'];
$Password = $_REQUEST['<PASSWORD>'];
$call1="SELECT * FROM `users` WHERE `username` = '$Username';";
$call2="SELECT * FROM `users` WHERE `email` = '$Email';";
$call3="SELECT * FROM `users` WHERE `username` = '$Username' OR `email` = '$Email';";
$result1 = mysqli_query($db, $call1);
$result2 = mysqli_query($db, $call2);
$result3 = mysqli_query($db, $call3);
if($result3->num_rows==0)
{
	$sql="INSERT INTO 
	users VALUES ('$Username', 
	'$Email', 
	'$Password');";
	
	$insert = mysqli_query($db, $sql);
	echo $sql;
	echo "<script type='text/javascript'>";
	echo "alert('เพิ่มข้อมูลสำเร็จ');";
	echo "window.history.back()";
	echo "</script>";
}else if ($result1->num_rows==1)
{
	echo "<script type='text/javascript'>";
	echo "alert('Usersname ถูกใช้แล้ว');";
	echo "window.history.back()";
	echo "</script>";
}else if ($result2->num_rows==1)
{
	echo "<script type='text/javascript'>";
	echo "alert('Email ถูกใช้แล้ว');";
	echo "window.history.back()";
	echo "</script>";
}
?><file_sep><?php
include("../connection/phpconnect.php");
$username = $_REQUEST['username'];
$email = $_REQUEST['email'];
$password = $_REQUEST['<PASSWORD>'];

    $sqlup = "UPDATE
        `users`
        SET
		`email` = '$email',password = <PASSWORD>'
        WHERE
        `username` = '$username'";
	$update = mysqli_query($db, $sqlup);
	
	if($update){
		echo "<script type='text/javascript'>";
		echo "alert('Update Succesfuly');";
		echo "window.location = '../form_show_users.php'; ";
		echo "</script>";
		}
		else{
		echo "<script type='text/javascript'>";
		echo "alert('Error');";
		echo "window.history.back()";
		echo "</script>";
	}
	mysqli_close($db);
?><file_sep><!DOCTYPE html>
<html lang="en">
<?php
	session_start();
	error_reporting(E_ERROR | E_WARNING | E_PARSE);
	include('connection/phpconnect.php');	
	$strSQL = "SELECT * FROM shelf WHERE id_shelf = '".$_REQUEST['id_shelf']."' ";
	$objQuery = mysqli_query($db, $strSQL);
    $objResult = mysqli_fetch_array($objQuery);	
    if($_SESSION['username'] == ""){
		echo "<script type='text/javascript'>";
		echo "window.location = 'index.php'; ";
		echo "</script>";
    }
?>
<head>
    <!-- Required meta tags-->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="Co-Op Project">
    <meta name="author" content="<NAME>">
    <meta name="keywords" content="Co-Op Project">

    <!-- Title Page-->
    <title>Shelf Update</title>
    <link rel="icon" href="images/icon/true2.png" type="image/icon type">

    <!-- Fontfaces CSS-->
    <link href="css/font-face.css" rel="stylesheet" media="all">
    <link href="vendor/font-awesome-4.7/css/font-awesome.min.css" rel="stylesheet" media="all">
    <link href="vendor/font-awesome-5/css/fontawesome-all.min.css" rel="stylesheet" media="all">
    <link href="vendor/mdi-font/css/material-design-iconic-font.min.css" rel="stylesheet" media="all">

    <!-- Bootstrap CSS-->
    <link href="vendor/bootstrap-4.1/bootstrap.min.css" rel="stylesheet" media="all">

    <!-- Vendor CSS-->
    <link href="vendor/animsition/animsition.min.css" rel="stylesheet" media="all">
    <link href="vendor/bootstrap-progressbar/bootstrap-progressbar-3.3.4.min.css" rel="stylesheet" media="all">
    <link href="vendor/wow/animate.css" rel="stylesheet" media="all">
    <link href="vendor/css-hamburgers/hamburgers.min.css" rel="stylesheet" media="all">
    <link href="vendor/slick/slick.css" rel="stylesheet" media="all">
    <link href="vendor/select2/select2.min.css" rel="stylesheet" media="all">
    <link href="vendor/perfect-scrollbar/perfect-scrollbar.css" rel="stylesheet" media="all">

    <!-- Main CSS-->
    <link href="css/theme.css" rel="stylesheet" media="all">

</head>

<body class="animsition">
    <div class="page-wrapper">
        <!-- HEADER DESKTOP-->
        <header class="header-desktop3 d-none d-lg-block">
            <div class="section__content section__content--p35">
                <div class="header3-wrap">
                    <div class="header__logo">
                        <a href="#">
                            <img src="images/icon/true2.png" alt="CoolAdmin" />
                        </a>
                    </div>
                    <div class="header__navbar">
                        <ul class="list-unstyled">
                            <li>
                                <a href="index.php">
                                    <i class="fas fa-chart-pie"></i>
                                    <span class="bot-line"></span>Home</a>
                            </li>
                            <li>
                                <a href="form_show_location.php">
                                    <i class="fas fa-warehouse"></i>
                                    <span class="bot-line"></span>Location Good</a>
                            </li>
                            <li>
                                <a href="form_show_location_fail.php">
                                    <i class="fas fa-wrench"></i>
                                    <span class="bot-line"></span>Location Fail</a>
                            </li>
                            <?php
                                if($_SESSION['username'] == !""){
                            ?>
                            <li class="has-sub">
                                <a href="#">
                                    <i class="fas fa-copy"></i>
                                    <span class="bot-line"></span>Manage</a>
                                <ul class="header3-sub-list list-unstyled">
                                    <li>
                                        <a href="form_show_mat.php">
                                            <i class="fas fa-barcode"></i>Material</a>
                                    </li>
                                    <li>
                                        <a href="form_show_mattype.php">
                                            <i class="fas fa-barcode"></i>Material Type</a>
                                    </li>
                                    <li>
                                        <a href="form_show_emp.php">
                                            <i class="fas fa-user"></i>Employee</a>
                                    </li>
                                    <li>
                                        <a href="form_show_position.php">
                                            <i class="fas fa-user"></i>Position</a>
                                    </li>
                                    <li>
                                        <a href="form_show_department.php">
                                            <i class="fas fa-user"></i>Departmet</a>
                                    </li>
                                    <li>
                                        <a href="form_show_plant.php">
                                            <i class="fas fa-warehouse"></i>Plant</a>
                                    </li>
                                    <li>
                                        <a href="form_show_store.php">
                                            <i class="fas fa-warehouse"></i>Store</a>
                                    </li>
                                    <li>
                                        <a href="form_show_shelf.php">
                                            <i class="fas fa-warehouse"></i>Shelf</a>
                                    </li>
                                    <li>
                                        <a href="form_show_users.php">
                                            <i class="fas fa-user"></i>Users</a>
                                    </li>
                                </ul>
                            </li>
                            <?php
                                }
                            ?>
                            </li>
                        </ul>
                    </div>
                    <div class="header__tool">
                        <div class="account-wrap">
                            <div class="account-item account-item--style2 clearfix js-item-menu">
                                <div class="content">
                                    <?php
                                    if($_SESSION['username'] == ""){
                                    ?>
                                        <a href='login.php'>
                                            <i class="js-acc-btn"></i>Login</a>    
                                    <?php
                                        }
                                    ?>
                                    <?php
                                    if($_SESSION['username'] == !""){
                                    ?>
                                        <a class="js-acc-btn" href="#"><?php echo $_SESSION['username'] ?></a>        
                                    <?php
                                        }
                                    ?>
                                    
                                </div>
                                <div class="account-dropdown js-dropdown">
                                    <?php
                                        if($_SESSION['username'] == !""){
                                    ?>
                                    <div class="account-dropdown__body">
                                        <div class="account-dropdown__item">
                                            <a href="account.php">
                                                <i class="zmdi zmdi-account"></i>Account</a>
                                        </div>
                                    </div>
                                    <?php
                                        }
                                    ?>
                                    <div class="account-dropdown__footer">
                                        <?php
                                            if($_SESSION['username'] == ""){
                                        ?>
                                            <a href='login.php'>
                                                <i class="zmdi zmdi-power"></i>Login</a>
                                        <?php
                                            }
                                        ?>
                                        <?php
                                            if($_SESSION['username'] == !""){
                                        ?>
                                            <a href='action/logout.php'>
                                                <i class="zmdi zmdi-power"></i>Logout</a>
                                        <?php
                                            }
                                        ?>
                                        <a href="forget-pass.html">
                                            <i class="zmdi zmdi-key"></i>Forget Password</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </header>
        <!-- END HEADER DESKTOP-->

        <!-- HEADER MOBILE-->
        <header class="header-mobile header-mobile-2 d-block d-lg-none">
            <div class="header-mobile__bar">
                <div class="container-fluid">
                    <div class="header-mobile-inner">
                        <a class="logo" href="#">
                            <img src="images/icon/true2.png" alt="CoolAdmin" />
                        </a>
                        <button class="hamburger hamburger--slider" type="button">
                            <span class="hamburger-box">
                                <span class="hamburger-inner"></span>
                            </span>
                        </button>
                    </div>
                </div>
            </div>
            <nav class="navbar-mobile">
                <div class="container-fluid">
                    <ul class="navbar-mobile__list list-unstyled">
                        <li>
                            <a href="index.php">
                                <i class="fas fa-chart-pie"></i>Home</a>
                        </li>
                        <li>
                            <a href="form_show_location.php">
                                <i class="fas fa-warehouse"></i>
                                <span class="bot-line"></span>Location Good</a>
                        </li>
                        <li>
                            <a href="form_show_location_fail.php">
                                <i class="fas fa-wrench"></i>
                                <span class="bot-line"></span>Location Fail</a>
                        </li>
                        <?php
                                    if($_SESSION['username'] == !""){
                                ?>
                        <li class="has-sub">
                            <a class="js-arrow" href="#">
                                <i class="fas fa-copy"></i>Manage</a>
                            <ul class="navbar-mobile-sub__list list-unstyled js-sub-list">
                                <li>
                                    <a href="form_show_mat.php">
                                        <i class="fas fa-barcode"></i>Material</a>
                                </li>
                                <li>
                                    <a href="form_show_mattype.php">
                                        <i class="fas fa-barcode"></i>Material Type</a>
                                </li>
                                <li>
                                    <a href="form_show_emp.php">
                                        <i class="fas fa-user"></i>Employee</a>
                                </li>
                                <li>
                                    <a href="form_show_position.php">
                                        <i class="fas fa-user"></i>Position</a>
                                </li>
                                <li>
                                    <a href="form_show_department.php">
                                        <i class="fas fa-user"></i>Department</a>
                                </li>
                                <li>
                                    <a href="form_show_plant.php">
                                        <i class="fas fa-warehouse"></i>Plant</a>
                                </li>
                                <li>
                                    <a href="form_show_store.php">
                                        <i class="fas fa-warehouse"></i>Store</a>
                                </li>
                                <li>
                                    <a href="form_show_shelf.php">
                                        <i class="fas fa-warehouse"></i>Shelf</a>
                                </li>
                                <li>
                                    <a href="form_show_users.php">
                                        <i class="fas fa-user"></i>Users</a>
                                </li>
                            </ul>
                        </li>
                        <?php
                            }
                        ?>
                    </ul>
                </div>
            </nav>
        </header>
        <div class="sub-header-mobile-2 d-block d-lg-none">
            <div class="header__tool">
                <div class="account-wrap">
                    <div class="account-item account-item--style2 clearfix js-item-menu">
                        <div class="content">
                            <?php
                            if($_SESSION['username'] == ""){
                            ?>
                                <a href='login.php'>
                                    <i class="js-acc-btn"></i>Login</a>    
                            <?php
                                }
                            ?>
                            <?php
                            if($_SESSION['username'] == !""){
                            ?>
                                <a class="js-acc-btn" href="#"><?php echo $_SESSION['username'] ?></a>        
                            <?php
                                }
                            ?>
                            
                        </div>
                        <div class="account-dropdown js-dropdown">
                            <?php
                                if($_SESSION['username'] == !""){
                            ?>
                            <div class="account-dropdown__body">
                                <div class="account-dropdown__item">
                                    <a href="account.php">
                                        <i class="zmdi zmdi-account"></i>Account</a>
                                </div>
                            </div>
                            <?php
                                }
                            ?>
                            <div class="account-dropdown__footer">
                                <?php
                                    if($_SESSION['username'] == ""){
                                ?>
                                    <a href='login.php'>
                                        <i class="zmdi zmdi-power"></i>Login</a>
                                <?php
                                    }
                                ?>
                                <?php
                                    if($_SESSION['username'] == !""){
                                ?>
                                    <a href='action/logout.php'>
                                        <i class="zmdi zmdi-power"></i>Logout</a>
                                <?php
                                    }
                                ?>
                                <a href="forget-pass.html">
                                    <i class="zmdi zmdi-key"></i>Forget Password</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- END HEADER MOBILE -->

        <!-- PAGE CONTENT-->
        <div class="page-content--bgf7">
            <!-- BREADCRUMB-->
            <section class="au-breadcrumb2">
                <div class="container">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="au-breadcrumb-content">
                                <div class="au-breadcrumb-left">
                                    <span class="au-breadcrumb-span">You are here:</span>
                                    <ul class="list-unstyled list-inline au-breadcrumb__list">
                                        <li class="list-inline-item active">
                                            <a href="#">Update</a>
                                        </li>
                                        <li class="list-inline-item seprate">
                                            <span>/</span>
                                        </li>
                                        <li class="list-inline-item">Shelf</li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
            <!-- END BREADCRUMB-->

            <form action="action/update_shelf.php" method="post">
            <!-- WELCOME-->
            <section class="welcome p-t-10">
                <div class="container">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="overview-wrap">
                                <h1 class="title-4">Update Shelf</h1>
                                <button type="submit" name="submit"  class="au-btn au-btn-icon au-btn--blue">
                                    <i class="zmdi zmdi-save"></i>Submit</button>
                            </div>
                            <hr class="line-seprate">
                        </div>
                    </div>
                </div>
            </section>
            <!-- END WELCOME-->

            <!-- STATISTIC-->
            <section class="section__content section__content--p30">
                <div class="container">
                    <div class="row">
                        <div class="col-md-12">
                            <div  class="col">
								<div class="card">
									
									<div class="card-body card-block">
                                        <div class="form-group">
											<label for="id_shelf">Shelf ID</label>
											<input name="id_shelf" type="text" id="id_shelf" value="<?php echo $objResult["id_shelf"];?>" disabled='disabled' class="form-control" />
                                            <input name="id_shelf" type="hidden" id="id_shelf" value="<?php echo $objResult["id_shelf"];?>" /></div>    
                                        <div class="form-group">
											<label for="name">Shelf Name</label>
											<input name="name" type="text" id="name" value="<?php echo $objResult["name"];?>" required="required" class="form-control" />
					                    </div>
                                        <div class="form-group">
											<label for="id_store">Store ID</label>
											<select class="form-control" id="id_store" name="id_store" required>
												<option><?php echo $objResult["id_store"];?></option>
												<?php
													$sql="SELECT `store`.`id_store` AS `id_store` FROM `store`";
													$result=$db->query($sql);
													while($row=$result->fetch_object())
													{
												?>
												<option value="<?php echo $row->id_store;?>">
													<?php echo $row->id_store;?>
												</option>
												<?php
												}
												?>   
											</select>
                                        </div>
                                        <button class="au-btn--block btn btn-danger m-b-20" type="button" value="Go back!" onclick="history.back()">Back</button>
									</div>
								</div>
							</div>
                        </div>
                    </div>
                </div>
            </section>
            <!-- END STATISTIC-->
            </form>

            <!-- COPYRIGHT-->
            <section class="p-t-60 p-b-20">
                <div class="container">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="copyright">
                                <p>Copyright © 2020</a>.</p>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
            <!-- END COPYRIGHT-->
        </div>

    </div>

    <!-- Jquery JS-->
    <script src="vendor/jquery-3.2.1.min.js"></script>
    <!-- Bootstrap JS-->
    <script src="vendor/bootstrap-4.1/popper.min.js"></script>
    <script src="vendor/bootstrap-4.1/bootstrap.min.js"></script>
    <!-- Vendor JS       -->
    <script src="vendor/slick/slick.min.js">
    </script>
    <script src="vendor/wow/wow.min.js"></script>
    <script src="vendor/animsition/animsition.min.js"></script>
    <script src="vendor/bootstrap-progressbar/bootstrap-progressbar.min.js">
    </script>
    <script src="vendor/counter-up/jquery.waypoints.min.js"></script>
    <script src="vendor/counter-up/jquery.counterup.min.js">
    </script>
    <script src="vendor/circle-progress/circle-progress.min.js"></script>
    <script src="vendor/perfect-scrollbar/perfect-scrollbar.js"></script>
    <script src="vendor/chartjs/Chart.bundle.min.js"></script>
    <script src="vendor/select2/select2.min.js">
    </script>

    <!-- Main JS-->
    <script src="js/main.js"></script>

</body>

</html>
<!-- end document-->
<file_sep><?php
	session_start();
	include('../connection/phpconnect.php');
	$Username = $_POST['username'];
	$Password = $_POST['<PASSWORD>'];
	$query = "SELECT * FROM `users` WHERE `username` = '$Username' AND `password` = '$<PASSWORD>'";
	$query2 = "SELECT * FROM `users` WHERE `username` = '$Username'";
	$query3 = "SELECT `password` FROM `users` WHERE `username` = '$Username'";
	$result = mysqli_query($db, $query);
	$result2 = mysqli_query($db, $query2);
	$result3 = mysqli_query($db, $query3);
	
	if(mysqli_num_rows($result)==1){
		$row = mysqli_fetch_array($result);

		$_SESSION["username"] = $row["username"];

		session_write_close();
		echo "<script type='text/javascript'>";
		echo "window.history.back()";
		echo "</script>";
	}
	else if(mysqli_num_rows($result2)==0)
	{
		echo "<script type='text/javascript'>";
		echo "alert('Do not have this Username');";
		echo "window.history.back()";
		echo "</script>";
	}
	else if($Password!==$result3)
	{
		echo "<script type='text/javascript'>";
		echo "alert('Password Incorrect!');";
		echo "window.history.back()";
		echo "</script>";
	}
?><file_sep><meta charset="UTF-8">
<?php
include('../connection/phpconnect.php');
    $num_lo = $_REQUEST["num_lo"];
    $id_mat = $_REQUEST["id_mat"];
	$id_store = $_REQUEST["id_store"];
	$id_shelf = $_REQUEST["id_shelf"];
	$amount = $_REQUEST["amount"];

	$sql = "UPDATE `location` SET  
			num_lo='$num_lo' ,
			id_mat='$id_mat' ,
			id_store='$id_store' ,
			id_shelf='$id_shelf' ,
            amount='$amount'
			WHERE num_lo='$num_lo' ";

$result = mysqli_query($db, $sql) or die ("Error in query: $sql " . mysqli_error());
mysqli_close($db);

	if($result){
	echo "<script type='text/javascript'>";
	echo "alert('Update Succesfuly');";
	echo "window.location = '../search.php?search=&submit='; ";
	echo "</script>";
	}
	else{
	echo "<script type='text/javascript'>";
	echo "alert('Error back to Update again');";
	echo "window.location = '../search.php?search=&submit='; ";
	echo "</script>";
}
?><file_sep><?php
include('../connection/phpconnect.php');
$strSQL = "DELETE FROM `department` ";
$strSQL .="WHERE `department` = '".$_GET["department"]."' ";
$objQuery = mysqli_query($db, $strSQL);
if($objQuery)
{
	echo "<script type='text/javascript'>";
	echo "alert('Record Deleted!');";
	echo "window.location = '../form_show_department.php'; ";
	echo "</script>";
}
else
{
	echo "<script type='text/javascript'>";
	echo "alert('Error Delete [".$strSQL."]');";
	echo "window.location = '../form_show_department.php'; ";
	echo "</script>";
	
}
mysqli_close($db);
?>