<?php
include_once 'includes/processes.php';
$Process = new Login_Process;
$pageLink = basename($_SERVER['REQUEST_URI']);
$Process->check_status($pageLink);
$itemData = $Process->getItemInfo($_GET['tid']);
$addItemStock = $Process->addItemStock($_POST,$_POST['add-stock']);
?>
<!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><?php echo $itemData->item_name; ?>::.Add Stock - 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/icheck/skins/minimal/blue.css">
  <link rel="stylesheet" href="./js/plugins/select2/select2.css">
  <link rel="stylesheet" href="./js/plugins/datepicker/datepicker.css">
  <link rel="stylesheet" href="./js/plugins/simplecolorpicker/jquery.simplecolorpicker.css">
  <link rel="stylesheet" href="./js/plugins/timepicker/bootstrap-timepicker.css">
  <link rel="stylesheet" href="./js/plugins/fileupload/bootstrap-fileupload.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"><?php echo $itemData->item_name; ?>::::Add Stock</h2>
        <ol class="breadcrumb">
          <li><a href="./">Home</a></li>
          <li><a href="it-store.php">IT Store</a></li>
          <li class="active"><?php echo $itemData->item_name; ?>::::Add Stock</li>
        </ol>
      </div> <!-- /.content-header -->

      

      <div class="row">
	  
		 <div class="col-md-12">
			<?php echo $addItemStock; ?>
		 </div>
		 
		 <div class="col-md-4">
   
			<div class="portlet">

            <div class="portlet-header">

              <h3>
                <i class="fa fa-compass"></i>
                Add New Stock
              </h3>

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

            <div class="portlet-content">
				<form action="<?php echo $_SERVER['PHP_SELF']; ?>?tid=<?php echo $_GET['tid']; ?>" method="post">
				<input type="hidden" name="item_id"  value="<?php echo $itemData->item_id; ?>">
					<div class="row">
						<div class="col-sm-12">
							<div class="form-group">
								<label for="reason">Received Quantity</label>
								<input type="number" id="quantity" name="quantity" placeholder="Received Quantity" class="form-control" required />
							</div>
						</div> <!-- /.col -->
						<div class="col-sm-12">
							<div class="form-group">
								<label for="reason">Received From</label>
								<input type="text" id="received-from" name="received-from" placeholder="Received From" class="form-control" required />
							</div>
						</div> <!-- /.col -->
						
						
						<div class="col-sm-12">
					<div class="form-group col-sm-12" class="input-group date" >
						<label for="date_requested">Date Received</label>
						<input autocomplete="off" id="dp-ex-3"  data-date-end-date="0d" id="date-received" name="date_received" id="date_received" name="date_received" placeholder="Date Received" class="form-control" required>
					</div>				
				</div>
						<!--
						<div class="col-sm-12">
							<strong>Date Received</strong>
							<div id="dp-ex-3" class="input-group date" data-date-end-date="0d" id="date-received" name="date_received" placeholder="Date Received" data-auto-close="true" data-date="<?php echo date("Y-m-d"); ?>" data-date-format="yyyy-mm-dd" data-date-autoclose="true"  required />
								<input class="form-control" name="date_receved" type="text">
								<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
							</div>
							<span class="help-block">yyyy-mm-dd</span>
						</div>
						-->
						<!-- /.col -->
						<div class="col-sm-12">
							<div class="form-group">
								<label for="reason">Remark</label>
								<textarea rows="5" name="remark" class="form-control"></textarea>
							</div>
						</div> <!-- /.col -->
						
						<div class="col-sm-12">
							<div style="padding:5px;margin:5px;" class="alert alert-warning"><i class="fa fa-warning"></i> Warning: stock added cannot be deleted</div>
						</div> <!-- /.col -->
							
						<div class="col-sm-12">
							<button type="submit" name="add-stock" class="btn btn-primary">Add Stock</button>
						</div> <!-- /.col -->					
					</div>
				</form>
            </div> <!-- /.portlet-content -->

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

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

		 
        <div class="col-md-8">
		
		 <div class="portlet">

            <div class="portlet-header">

              <h3>
                <i class="fa fa-ticket"></i>
                Stock List
              </h3>

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

            <div class="portlet-content">           

				<div class="table-responsive">

					<?php $Process->getItemStockHistory($itemData->item_id); ?>

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

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

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

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



      




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

</div> <!-- /.container -->
	<?php include"includes/footer.php"; ?>
	
	

   <div id="basicModal" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3 class="modal-title"><i class="fa fa-ticket"></i> New Requisition</h3>
      </div>
	  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
		<div class="modal-body">
			<div class="row">
				<div class="col-sm-12">
					<div class="form-group col-sm-12">
						<label for="reason">Reason For Request</label>
						<input type="text" id="reason" class="form-control">
					</div>
					</div> <!-- /.col -->
			</div>
			<div class="row">
				<div class="col-sm-4">
					<div class="form-group col-sm-12">
						<label for="item_desc">Item Description</label>
						<input type="text" id="item_desc" name="item_desc[]" class="form-control">
					</div>
				</div>
				<div class="col-sm-4">
					<div class="form-group col-sm-12">
						<label for="item_qty">Item quantity</label>
						<input type="number" id="item_qty" name="item_qty[]" class="form-control">
					</div>				
				</div>
				<div class="col-sm-4">
					<div class="form-group col-sm-12">
						<label for="item_remark">Remarks</label>
						<input type="text" id="item_remark" name="item_remark[]" class="form-control">
					</div>				
				</div>
				
				<div id="dynamicInputs"></div>
			
				<div class="col-md-12">
				<a href="javascript:;" class="btn btn-info btn-lg btn-xs pull-right" type="button" onclick="addItem('dynamicInputs');">Add Item <i class="fa fa-plus"></i></a>
				</div>
			</div>
		<div class="modal-footer">
			<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
			<button type="submit" name="request" class="btn btn-primary">Make Request</button>
		</div>
	  </form>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

 <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/datatables/jquery.dataTables.min.js"></script>
  <script src="./js/plugins/datatables/DT_bootstrap.js"></script>
  <script src="./js/plugins/tableCheckable/jquery.tableCheckable.js"></script>
  <script src="./js/plugins/icheck/jquery.icheck.min.js"></script>
  
    <!-- Plugin JS -->
  <script src="./js/plugins/select2/select2.js"></script>
  <script src="./js/plugins/datepicker/bootstrap-datepicker.js"></script>
  <script src="./js/plugins/timepicker/bootstrap-timepicker.js"></script>
  <script src="./js/plugins/simplecolorpicker/jquery.simplecolorpicker.js"></script>
  <script src="./js/plugins/autosize/jquery.autosize.min.js"></script>
  <script src="./js/plugins/textarea-counter/jquery.textarea-counter.js"></script>
  <script src="./js/plugins/fileupload/bootstrap-fileupload.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-4'>"+
					"<div class='form-group col-sm-12'>"+
						"<label for='item_desc'>Item Description</label>"+
						"<input type='text' id='item_desc' name='item_desc[]' class='form-control'>"+
					"</div>"+
				"</div>"+
				"<div class='col-sm-4'>"+
					"<div class='form-group col-sm-12'>"+
						"<label for='item_qty'>Item quantity</label>"+
						"<input type='number' id='item_qty' name='item_qty[]' class='form-control'>"+
					"</div>"+				
				"</div>"+
				"<div class='col-sm-4'>"+
					"<div class='form-group col-sm-12'>"+
						"<label for='item_remark'>Remarks</label>"+
						"<input type='text' id='item_remark' name='item_remark[]' class='form-control'>"+
					"</div>"+				
				"</div>";
     document.getElementById(divName).appendChild(newdiv);

}

function removeDesignation(sourceid) {
	var elementid = document.getElementById(sourceid);
	//counter--;
	elementid.remove();
}
</script>
  
</body>
</html>
