<?php
	require_once('source/session.php');
	require_once('source/error.php');
	require_once('source/dbconfig.php');
	require_once('source/function.php');
	
		
	
	if($_SESSION['msg'] == "email" || $_SESSION['msg'] == "phone" || $_SESSION['msg'] == "bitcoin wallet" || $_SESSION['msg'] == "account number")
	{
		$msg = "<h5 class='alert alert-warning text-center'>".($_SESSION['msg'])." already exists, please try another</h5>";
		
	}            
	else if($_SESSION['msg'] == "signup")
	{
		$msg = "<h5 class='alert alert-success text-center'>Order Placement Succesful. Customer will receive tract number in his or her email.<a 
		class='btn-sm' href='new_order.php'>Refresh</a></h5>";
	}            
	else if($_SESSION['msg'] == "captcha")
	{
		$msg = "<h5 class='alert alert-warning text-center'>Something went wrong, please check captcha</h5>";
	}            
	else if($_SESSION['msg'] == "samp")
	{
		$msg = "<h5 class='alert alert-warning text-center'>Samp request found, please try again</h5>";
	}            
	else if($_SESSION['msg'] == "forget")
	{
		$msg = "<h5 class='alert alert-success text-center'>New password has been sent to your verified email</h5>";
	} else if($_SESSION['msg'] == "no_ref")
	{
		$msg = "<h5 class='alert alert-danger text-center'>Invalid Referrence Email</h5>";
	} else if($_SESSION['msg'] == "no_pro")
	{
		$msg = "<h5 class='alert alert-danger text-center'>Invalid Promoter/Consultant Email</h5>";
	} 

		unset($_SESSION['msg']);
?>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">
  <title>AJC-American Jet Cargo</title>
  <!-- Bootstrap core CSS-->
  <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <!-- Custom fonts for this template-->
  <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
  <!-- Page level plugin CSS-->
  <link href="vendor/datatables/dataTables.bootstrap4.css" rel="stylesheet">
  <!-- Custom styles for this template-->
  <link href="css/sb-admin.css" rel="stylesheet">
  <link href="css/user_profile.css" rel="stylesheet">
  
  <!-- select-->
  <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
  
</head>

<body class="fixed-nav sticky-footer bg-dark" id="page-top">
  <!-- Navigation-->
  <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top" id="mainNav">
  
<?php
            	
            	$rows = sql($DBH, "SELECT * FROM tbl_admin where status = ?", 
            	array("Active"), "rows");							
            	foreach($rows as $row)
            	{
            		$admin_name 		= $row['username'];
            	}
		
      if (isset($_SESSION['SESS_HASH_ADMIN'])) {
		$user_true 			 = "<img class='user one' src='profile_pic/$profile_pic' width='200px'><a class='navbar-brand' href='index.php' style='font-weight: bold; color: gold'> $fullname</a>";
		
}
		echo "$user_true ";
?>
    <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarResponsive">
      <ul class="navbar-nav navbar-sidenav" id="exampleAccordion">
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Dashboard">
          <a class="nav-link" href="main.php">
            <i class="fa fa-fw fa-dashboard fa-spin" style="color: #3498db"></i>
            <span class="nav-link-text" style="color: yellow">Dashboard</span>
          </a>
        </li>
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Charts">
          <a class="nav-link" href="sales_rep.php">
            <i class="fa fa-fw fa-user-o fa-spin" style="color: #3498db"></i>
            <span class="nav-link-text" style="color: yellow">Sale's Rep</span>
          </a>
        </li>
        <li class="nav-item" data-toggle="tooltip" data-placement="right" title="Tables">
          <a class="nav-link" href="notice.php">
            <i class="fa fa-fw fa-money fa-spin" style="color: #3498db"></i>
            <span class="nav-link-text" style="color: yellow">Post Message (PM)</span>
          </a>
        </li>
      </ul>
      <ul class="navbar-nav ml-auto">
        <li class="nav-item">
          <a class="nav-link" data-toggle="modal" href="logout.php" style="color: yellow">
            <i class="fa fa-fw fa-sign-out"></i>Logout</a>
        </li>
      </ul>
    </div>
  </nav>
  
  <div class="content-wrapper">
    <div class="container-fluid">
      <!-- Breadcrumbs-->
      <ol class="breadcrumb" style="background: gold">
        <li class="breadcrumb-item">
          <a href="index.php" style="color: black; font-weight: bold">Dashboard</a>
        </li>
        <li class="breadcrumb-item active" style="color: black">New Order</li>
      </ol>
      <div class="row">
        <div class="col-lg-12">
          <!-- Example Bar Chart Card-->
      <ol class="breadcrumb"style="background: #3498db">
                                    <h6 align="center"><strong>PLACE NEW ORDER</strong></h6>
        
                                    </ol>                                   
<?php
	echo $msg;
?>   
		
            
                <hr>
                <marquee><h4 style='color:red'>Carefully Add New Order</h4></marquee>
                <hr>
          <form method="post" action="exe_update_order.php" class="form-horizontal" enctype="multipart/form-data">
          <?php
					
			$rows1 = sql($DBH, "SELECT * FROM tbl_details where order_number = ?", array($_GET['order_number']), "rows");							
			foreach($rows1 as $row1)
			{	
				$order_id			= $row1['id'];
				$order_number	   		= $row1['order_number'];
				$c_name 		   	= $row1['name'];
				$c_phone 			= $row1['phone'];
				$c_email 		   	= $row1['email'];
				$c_item 		   	= $row1['item'];
				$c_destination 		   	= $row1['destination'];
				$c_locationi 		   	= $row1['locationi'];
				$c_locationii 		   	= $row1['locationii'];
				$c_locationiii 		   	= $row1['locationiii'];
				$c_address 		   	= $row1['address'];
				$c_postalcode 		   	= $row1['postalcode'];
				$sales_rep 		   	= $row1['sales_rep'];
				$sc_status 		   	= $row1['success_status'];
				$status 		   	= $row1['status'];
				$sales_repphone 		   	= $row1['sales_repphone'];
				$sales_repemail 		   	= $row1['sales_repemail'];
				$date_time 		   	= $row1['date_time'];
				$date_stamp_end 		   	= $row1['dt_stamp_end'];
				
				
				if($status == "RECEIVED"){
				$c_status = "
			<select name='status' class='form-control'>
				<option value='RECEIVED' selected='selected'>RECEIVED</option>
				<option value='PROCESSED'>PROCESSED</option>
				<option value='SHIPPED'>SHIPPED</option>
				<option value='ON HOLD'>ON HOLD</option>
				<option value='DELIVERED'>DELEVERED</option>
				<option value='COMPLETED'>COMPLETED</option>
			</select>";
				}
				else if($status == "PROCESSED"){
				$c_status = "
			<select name='status' class='form-control'>
				<option value='RECEIVED'>RECEIVED</option>
				<option value='PROCESSED' selected='selected'>PROCESSED</option>
				<option value='SHIPPED'>SHIPPED</option>
				<option value='ON HOLD'>ON HOLD</option>
				<option value='DELIVERED'>DELEVERED</option>
				<option value='COMPLETED'>COMPLETED</option>
			</select>";
				}
				else if($status == "SHIPPED"){
				$c_status = "
			<select name='status' class='form-control'>
				<option value='RECEIVED'>RECEIVED</option>
				<option value='PROCESSED'>PROCESSED</option>
				<option value='SHIPPED' selected='selected'>SHIPPED</option>
				<option value='ON HOLD'>ON HOLD</option>
				<option value='DELIVERED'>DELEVERED</option>
				<option value='COMPLETED'>COMPLETED</option>
			</select>";
				}
				else if($status == "ON HOLD"){
				$c_status = "
			<select name='status' class='form-control'>
				<option value='RECEIVED'>RECEIVED</option>
				<option value='PROCESSED'>PROCESSED</option>
				<option value='SHIPPED'>SHIPPED</option>
				<option value='ON HOLD' selected='selected'>ON HOLD</option>
				<option value='DELIVERED'>DELEVERED</option>
				<option value='COMPLETED'>COMPLETED</option>
			</select>";
				}
				else if($status == "DELEVERED"){
				$c_status = "
			<select name='status' class='form-control'>
				<option value='RECEIVED'>RECEIVED</option>
				<option value='PROCESSED'>PROCESSED</option>
				<option value='SHIPPED'>SHIPPED</option>
				<option value='ON HOLD'>ON HOLD</option>
				<option value='DELIVERED' selected='selected'>DELEVERED</option>
				<option value='COMPLETED'>COMPLETED</option>
			</select>";
				}
				else if($status == "COMPLETED"){
				$c_status = "
			<select name='status' class='form-control'>
				<option value='RECEIVED'>RECEIVED</option>
				<option value='PROCESSED'>PROCESSED</option>
				<option value='SHIPPED'>SHIPPED</option>
				<option value='ON HOLD'>ON HOLD</option>
				<option value='DELIVERED'>DELEVERED</option>
				<option value='COMPLETED' selected='selected'>COMPLETED</option>
			</select>";
				}
				
		echo "
			Order Number: <input name='order_number' class='hidden' value='$order_number' readonly/>
			Last Update: <input name='dt_stamp_end' class='hidden' value='$date_stamp_end' readonly/>
			Present Update: <input name='date_time' class='hidden' value='$date_time' readonly/>
			<input name='location' type='hidden' value='$c_locationii'/>
			<div class='row'>
			<div class='col-sm-6'>
			<label>Customer's Name</label>
			<input type='text' name='fullname' class='form-control' value='$c_name' required/>
		</div>
			<div class='col-sm-6'>
			<label>Customer's Email</label>
			<input type='email' name='c_email' class='form-control' value='$c_email' required/>
		</div>
		</div>
			<div class='row'>
			<div class='col-sm-6'>
			<label>Customer's Phone</label>
			<input type='phone' name='phone' class='form-control' value='$c_phone' required/>
		</div>
			<div class='col-sm-6'>
			<label>Select Sale's Rep</label>
			<input type='text' class='form-control' value='$sales_rep, $sales_repphone' readonly/>
		</div>
		</div>
			<div class='row'>
			<div class='col-sm-6'>
			<label>Item Ordered</label>
			<input type='text' name='item' class='form-control' value='$c_item' required/>
		</div>
			<div class='col-sm-6'>
			<label>Destination</label>
			<input type='text' name='destination' class='form-control' value='$c_destination' required/>
		</div>
		</div>
			<div class='row'>
			<div class='col-sm-6'>
			<label>From: </label>
			<input type='text' name='locationi' class='form-control' value='$c_locationi' required/>
		</div>
			<div class='col-sm-6'>
			<label>Present Location</label>
			<input type='text' name='locationii' class='form-control' value='$c_locationii' required/>
		</div>
		</div>
			<div class='row'>
			<div class='col-sm-6'>
			<label>Previous Location</label>
			<input type='text' name='locationiii' class='form-control' value='$c_locationiii' readonly/>
		</div>
			<div class='col-sm-6'>
			<label>Address</label>
			<input type='text' name='address' class='form-control' value='$c_address' required/>
		</div>
		</div>
			<div class='row'>
			<div class='col-sm-6'>
			<label>Postalcode</label>
			<input type='text' name='postalcode' class='form-control' value='$c_postalcode' required/>
		</div>
			<div class='col-sm-6'>
			<label>Status</label>
			$c_status
		</div>
		</div><br/>
			<div class='row'>
			<div class='col-sm-6'>
			<label>Message</label>
			<textarea rows='5' class='form-control' name='success_status' placeholder='$sc_status' ></textarea>
		</div>
			<div class='col-sm-6'>
			<input class='btn-sm' type='submit' name='submit' value='UPDATE' required/>
			</div>
			</div><br/><br/>";
			}
		?>
	</form>
                  
                              </div>
          </div>
    <!-- /.container-fluid-->
    <!-- /.content-wrapper-->
    <footer class="sticky-footer" style="background: gold">
      <div class="container">
        <div class="text-center">
          <small><strong>Copyright © Reserved! AMERICAN JET CARGO Developement Theme.</strong></small>
        </div>
      </div>
    </footer>
    <!-- Scroll to Top Button-->
    <a class="scroll-to-top rounded" href="#page-top">
      <i class="fa fa-angle-up"></i>
    </a>
    <!-- Logout Modal-->
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">×</span>
            </button>
          </div>
          <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
          <div class="modal-footer">
            <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
            <a class="btn btn-primary" href="Sign_in.php">Logout</a>
          </div>
        </div>
      </div>
    </div>
    <!-- Bootstrap core JavaScript-->
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
    <!-- Core plugin JavaScript-->
    <script src="vendor/jquery-easing/jquery.easing.min.js"></script>
    <!-- Page level plugin JavaScript-->
    <script src="vendor/chart.js/Chart.min.js"></script>
    <script src="vendor/datatables/jquery.dataTables.js"></script>
    <script src="vendor/datatables/dataTables.bootstrap4.js"></script>
    <!-- Custom scripts for all pages-->
    <script src="js/sb-admin.min.js"></script>
    <!-- Custom scripts for this page-->
    <script src="js/sb-admin-datatables.min.js"></script>
    <script src="js/sb-admin-charts.min.js"></script>
     
        <script>
			$(document).ready(function(e){
				$(".pass_mismatch").hide();
				$("#signup").submit(function(e){
					var p1 = $("input[name='password']").val();
					var p2 = $("input[name='password2']").val();
					
					$("input[name='password']").css("border","1px solid #cccccc");
					$("input[name='password2']").css("border","1px solid #cccccc");
					$(".pass_mismatch").hide();
						
					if(p1 != p2){
						$("input[name='password']").css("border","1px solid #f00");
						$("input[name='password2']").css("border","1px solid #f00");
						window.location.hash = '#signup';
						$(".pass_mismatch").slideDown();
						e.preventDefault();
					}
				});
				
			});
			
		</script>
  </div>
</body>

</html>
