<?php
include_once 'includes/processes.php';
$Process = new Login_Process;
$pageLink = basename($_SERVER['REQUEST_URI']);
$Process->check_status($pageLink);
$makeRequest = $Process->makeRequest($_POST,$_POST['request']);
$updateRequest = $Process->updateRequest($_POST,$_POST['update_request']);
$acknowledgeRequest = $Process->acknowledgeRequest($_POST,$_POST['acknowledge']);
?>
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
  <title>Requisition - APL Portal</title>

  <meta charset="utf-8">
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width">

  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,700italic,400,600,700">
  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Oswald:400,300,700">
  <link rel="stylesheet" href="./css/font-awesome.min.css">
  <link rel="stylesheet" href="./js/libs/css/ui-lightness/jquery-ui-1.9.2.custom.min.css">
  <link rel="stylesheet" href="./css/bootstrap.min.css">

  <!-- Plugin CSS -->
  <link rel="stylesheet" href="./js/plugins/magnific/magnific-popup.css">
  <link rel="stylesheet" href="./js/plugins/select2/select2.css">

  <!-- App CSS -->
  <link rel="stylesheet" href="./css/target-admin.css">
  <link rel="stylesheet" href="./css/custom.css">


  <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
  <![endif]-->
</head>

<body>

<?php include'includes/header.php'; ?>

<div class="container">

  <div class="content">

    <div class="content-container">

      

      <div class="content-header">
        <h2 class="content-header-title">Requisitions</h2>
        <ol class="breadcrumb">
          <li><a href="./">Home</a></li>
          <li class="active">Requisitions</li>
        </ol>
      </div> <!-- /.content-header -->

      

      <div class="row">
	
		<?php 
		
			if(in_array("request_admin",$_SESSION['privileges'])) { 
				$Process->getStoreItemStock(); 
			}
		
		?>
		 
		 
        <div class="col-md-12">
		
		<?php echo $makeRequest; ?>
    <?php echo $updateRequest; ?>
    <?php echo $acknowledgeRequest; ?>
		
		 <div class="portlet">

            <div class="portlet-header">

              <h3>
                <i class="fa fa-ticket"></i>
				Your Requests
              </h3>
              <?php if(in_array("request_user",$_SESSION['privileges'])): ?>
                  <ul class="portlet-tools pull-right">
                    <li>
                      <a data-toggle="modal" href="new-request.php" data-target="#addRequets" class="btn btn-sm btn-secondary">
                        Make Requisition
                      </a>
                    </li>
                  </ul>
              <?php endif; ?>
            </div> <!-- /.portlet-header -->

            <div class="portlet-content">           

              <div class="table-responsive">

					<?php $Process->getStationRequest($_SESSION['station_id']); ?>
			  
              </div> <!-- /.table-responsive -->
              

            </div> <!-- /.portlet-content -->

          </div> <!-- /.portlet -->

		  
        </div> <!-- /.col -->
		

      </div> <!-- /.row -->



      




    </div> <!-- /.content-container -->
      
  </div> <!-- /.content -->

</div> <!-- /.container -->
	<?php include"includes/footer.php"; ?>
	
	
  <div id="addRequets" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>

   <div id="item_Modal" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>

<div id="ackModal" class="modal fade">
<div class="modal-dialog">
 <div class="modal-content">
   
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>



 <script src="./js/libs/jquery-1.10.1.min.js"></script>
  <script src="./js/libs/jquery-ui-1.9.2.custom.min.js"></script>
  <script src="./js/libs/bootstrap.min.js"></script>

  <!--[if lt IE 9]>
  <script src="./js/libs/excanvas.compiled.js"></script>
  <![endif]-->
  
  <!-- Plugin JS -->
  <script src="./js/plugins/magnific/jquery.magnific-popup.min.js"></script>
  <script src="./js/plugins/howl/howl.js"></script>

  <!-- App JS -->
  <script src="./js/target-admin.js"></script>
  
  <!-- Plugin JS -->
  <script src="./js/demos/form-extended.js"></script>


  
  <script>
function addItem(divName){
     var newdiv = document.createElement('div');
	
     newdiv.innerHTML ="<div class='col-sm-6'>"+
					"<div class='form-group col-sm-12'>"+
						"<label for='item_desc'>Item</label>"+
						"<select name='item_id[]' class='form-control' data-required='true'>"+
						"<option value=''>Please Select</option>"+
						<?php $Process->listRequestItemJS(); ?>
						"</option>"+
						"</select>"+
					"</div>"+
				"</div>"+
				"<div class='col-sm-6'>"+
					"<div class='form-group col-sm-12'>"+
						"<label for='item_qty'>Item quantity</label>"+
						"<input type='number' id='item_qty' name='item_qty[]' min='1' class='form-control'>"+
					"</div>"+				
				"</div>";
     document.getElementById(divName).appendChild(newdiv);

}

function removeDesignation(sourceid) {
	var elementid = document.getElementById(sourceid);
	//counter--;
	elementid.remove();
}

$(document).on("hidden.bs.modal", function (e) {
    $(e.target).removeData("bs.modal").find(".modal-content").empty();
	});
</script>
  
</body>
</html>
