<?php include 'inc_classes.php'; 
include "admin_authentication.php";
?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Apply Leave</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.7 -->
  <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
  <!-- daterange picker -->
  <link rel="stylesheet" href="bower_components/bootstrap-daterangepicker/daterangepicker.css">
  <!-- bootstrap datepicker -->
  <link rel="stylesheet" href="bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
  <!-- iCheck for checkboxes and radio inputs -->
  <link rel="stylesheet" href="plugins/iCheck/all.css">
  <!-- Bootstrap Color Picker -->
  <link rel="stylesheet" href="bower_components/bootstrap-colorpicker/dist/css/bootstrap-colorpicker.min.css">
  <!-- Bootstrap time Picker -->
  <link rel="stylesheet" href="plugins/timepicker/bootstrap-timepicker.min.css">
  <!-- Select2 -->
  <link rel="stylesheet" href="bower_components/select2/dist/css/select2.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
  <!-- Google Font -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
<script>
 var pageName='order_list';
</script>

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
  <?php include "include/header-main.php"; ?>
  <!-- Left side column. contains the logo and sidebar -->
  <?php include "include/menu_left.php"; ?>
  <!-- Content Wrapper. Contains page content -->
    <!-- Left side column. contains the logo and sidebar -->
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Order List
        <!--<small>Version 2.0</small>-->
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">Dashboard</li>
      </ol>
    </section>
	<?php
	$errors=array(); 
	$i=0;
	$success=0;
	if($_POST['submit'])
	{
		$added_date=date('Y-m-d');
		$branch_name=$_POST['branch_name'];
		$employee_id=$_POST['employee_id'];
		$admin_id=$_POST['admin_id'];
		if($_SESSION['type']=='S' || $_SESSION['type']=='Z' || $_SESSION['type']=='LD')
		{
			$sel_branch="select cm_id from site_setting where branch_name='".$branch_name."' and type='A'";
			$ptr_branch=mysql_query($sel_branch);
			$data_branch=mysql_fetch_array($ptr_branch);
			$cm_id=$data_branch['cm_id'];
			$data_record['cm_id']=$cm_id;
			$data_record_check_prod['cm_id']=$cm_id;
		}	
		else
		{
			$branch_name1=$_SESSION['branch_name'];
			$cm_id=$_SESSION['cm_id'];
			$data_record['cm_id']=$cm_id;
			$data_record_check_prod['cm_id']=$cm_id;
		}
		if(count($errors))
		{
		?>
			<tr>
				<td> <br></br>
				<table align="left" style="text-align:left;" class="alert">
				<tr><td ><strong>Please correct the following errors</strong><ul>
					<?php
						for($k=0;$k<count($errors);$k++)
						echo '<li style="text-align:left;padding-top:5px;" class="green_head_font">'.$errors[$k].'</li>';?>
						</ul>
				</td></tr>
				</table>
				</td>
			</tr><br></br>  
			<?php
		}
		else
		{
			$success=1;
			$data_record['added_date']=$added_date;
			$data_record['employee_id']=$employee_id;

			$total_floor=$_POST['floor'];
			if($record_id)
			{
				//$where_record=" checkout_id='".$record_id."'";
				//$db->query_update("checkout", $data_record,$where_record);
				//echo '<br></br><div id="msgbox" style="width:40%;">Record updated successfully</center></div><br></br>';
			}
			else
			{
				$data_record['total_qty']=$total_floor;
				$data_record['category_id'] =$_POST['cat_id'];
				$data_record['order_no'] =$_POST['order_no'];
				$data_record['status'] ='Ordered';
				$record_id=$db->query_insert("order_list", $data_record);
				for($i=1;$i<=$total_floor;$i++)
				{
					if($_POST['product_id'.$i]!='')
					{
						$quantity=$_POST['quantity'.$i];
						$data_record_check_prod['order_list_id'] =$record_id;
						$data_record_check_prod['product_id'] =$_POST['product_id'.$i];
						$data_record_check_prod['category_id'] =$_POST['cat_id'];
						$data_record_check_prod['vendor_id'] =$_POST['vendor_id'.$i];
						$data_record_check_prod['brand_id'] =$_POST['brand_id'.$i];
						$data_record_check_prod['size'] =$_POST['unit'.$i];
						$data_record_check_prod['unit'] =$_POST['measure_unit'.$i];
						$data_record_check_prod['mrp_price'] =$_POST['mrp_price'.$i];
						$data_record_check_prod['consumed'] =$_POST['qty_consumed'.$i];
						$data_record_check_prod['no_of_live_student'] =$_POST['no_of_live_student'.$i];
						$data_record_check_prod['last_order_date']=$_POST['last_order_date'.$i];
						$data_record_check_prod['last_order_qty'] =$_POST['last_order_qty'.$i];
						$data_record_check_prod['qty_from_faculty'] =$_POST['qty_from_faculty'.$i];
						$data_record_check_prod['qty_in_hand'] =$_POST['qty_in_hand'.$i];
						$data_record_check_prod['qty_in_stock'] =$_POST['qty_in_stock'.$i];
						$data_record_check_prod['qty_from_qa'] =$_POST['qty_from_qa'.$i];
						$data_record_check_prod['qty_from_qm'] =$_POST['qty_from_qm'.$i];
						$data_record_check_prod['order_value'] =$_POST['order_value'.$i];
						$data_record_check_prod['added_date']=date('Y-m-d');
						//$data_record_check_prod['employee_id'] =$_POST['employee_id'];
						$data_record_check_prod['cm_id']=$cm_id;
						$data_record_check_prod['admin_id']=$admin_id;
						$data_record_check_prod['employee_id']=$employee_id;

						$checkout_prod_map_id=$db->query_insert("order_list_map", $data_record_check_prod);
					}
				}
				//---------------------------SYSTEMS AUTOMATED TASK-----------------------------------
				//--===========================-Order List Action-===================================-
				$sel_name="select name from site_setting where admin_id='".$employee_id."'";
				$ptr_name=mysql_query($sel_name);
				$data_name=mysql_fetch_array($ptr_name);
				
				$name=$data_name['name'];
				//$cm_id=$cm_id1;
				$where_cms=" and cm_id='".$cm_id."'";
				$record_cm_id=$cm_id;
				if($_SESSION['type']=='S' || $_SESSION['type']=='Z' || $_SESSION['type']=='LD' )
				{
					$where_cms='';
				}
				$task_access='';
				$staff_id='';
				$sel_acc="select * from task_previleges where 1 and privilege_id='413' ".$where_cms." order by access_id desc limit 0,1";
				$ptr_access=mysql_query($sel_acc);
				//if(mysql_num_rows($ptr_access))
				//{
					$data_staff=mysql_fetch_array($ptr_access);
					
					if($data_staff['admin_id']!='')
					{
						$staff_id=$data_staff['admin_id'];
					}
					else
					{
						$staff_id='69';
					}
					if($data_staff['minutes']!='')
					{
						$minutes=$data_staff['minutes'];
					}
					else
					{
						$minutes=5;
					}
					if($data_staff['points']!='')
					{
						$points=$data_staff['points'];
					}
					else
					{
						$points=floatval($minutes * 0.21,3);
					}
					if($data_staff['priority']!='')
					{
						$priority=$data_staff['priority'];
					}
					else
					{
						$priority='high';
					}
					if($data_staff['due_date_period']!='')
					{
						$due_date_period=$data_staff['due_date_period'];
						$due_date=date('Y-m-d H:i:s',strtotime('+'.$due_date_period.' days'));
					}
					else
					{
						$due_date=date('Y-m-d H:i:s',strtotime('+3 days'));
					}
					
				//}
				$task_data=array();
				$task_data['on_action']="update_order_list_qty";
				$task_data['task_name']="Update Product Qty in Staff Order List";
				$task_data['description']="Please update the product quantity under the order list of <b>".$name."</b>. Order no. is <b>".$_POST['order_no']."</b>.";
				$task_data['hours']=$minutes;
				$task_data['points']=$points;
				$task_data['rating_point']="100";
				$task_data['due_date']=$due_date;
				$task_data['priority']=$priority;
				$task_data['Validation']="valid";
				$task_data['status']="in_progress";
				$task_data['staff_id']=$staff_id;
				$task_data['admin_id']=$_SESSION['admin_id'];
				$task_data['added_date']=date('Y-m-d H:i:s');
				$task_data['cm_id']=$cm_id;
				$task_data['action_name']="Update Product Qty in Staff Order List";
				$task_data['action_description']="Please update the product quantity under the order list of <b>".$name."</b>. Order no. is <b>".$_POST['order_no']."</b>.";
				$task_data['action_id']=$record_id;
				$task_data['url']="proctuct.php?record_id=".$record_id."";
				//print_r($task_data);
				$task_assign=taskScheduler($task_data);
				//=========================================================================
				
				$insert="INSERT INTO `log_history`(`category`, `action`, `name`, `id`, `date`, `cm_id`, `admin_id`) VALUES ('add_order_list','Add','staff order list','".$record_id."','".date('Y-m-d H:i:s')."','".$_SESSION['cm_id']."','".$_SESSION['admin_id']."')";
				$query=mysql_query($insert);
				?>
				<script>
				//send(<?php ///echo $record_id; ?>);
				</script>
				<script type="text/javascript">
					//setTimeout('document.location.href="lv_order_list.php";',500);
				</script>
				<?php			
			}
		}
	}
	?>
    <!-- Main content -->
    <section class="content">
      <!-- SELECT2 EXAMPLE -->
      <div class="box box-default">
        <!--<div class="box-header with-border">
          <h3 class="box-title">Select2</h3>

          <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
            <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-remove"></i></button>
          </div>
        </div>-->
        <!-- /.box-header -->
        <form name="loan_form" method="post" >
            <div class="box-body">
              <div class="row">
                <div class="col-md-12">
					<input type="hidden" name="res1" id="res1" />
					<input type="hidden" name="res2" id="res2" />
					<input type="hidden" name="res_tax" id="res_tax" />
                  <div class="form-group">
					<input type="hidden" name="branch_name" id="branch_name" value="<?php echo $_SESSION['branch_name']; ?>">
					<input type="hidden" name="employee_id" id="employee_id" value="<?php echo $_SESSION['admin_id']; ?>">
                    <label>Select Product Category</label>
                      	<?php 
						$sel_domain="SELECT * FROM product_category where 1 and status='Active' order by pcategory_id asc";	 
						$query_domain=mysql_query($sel_domain);
						$total_d=mysql_num_rows($query_domain);
						echo '<table width="100%"><tr><td>'; 
						echo '<select class="form-control select2" id="cat_id" name="cat_id" onChange="get_product_by_cat(this.value)" style="width: 100%;">';
						echo '<option value="">Select Product Category</option>';
						while($data_domain=mysql_fetch_array($query_domain))
						{
							echo '<option value="'.$data_domain['pcategory_id'].'">'.$data_domain['pcategory_name'].'</option>';
						}
						echo '</select>';
						echo "</td></tr></table>";
						?>
                    </select>
                  </div>
                  <div class="form-group">
                  	<label>Order No. </label>
					<?php
					$sel_order="SELECT MAX(`order_list_id`) as last_id from order_list";
					$ptr_order=mysql_query($sel_order);
					if(mysql_num_rows($ptr_order))
					{
						$data_order=mysql_fetch_array($ptr_order);
					}
					else
					{
						$data_order['last_id']=0;
					}
					$order_no='E'.date('m').date('y').$_SESSION['admin_id'].$data_order['last_id'];
					//order_no= month-year-empid-
					?>
					<div><input type="text" readonly name="order_no" id="order_no" class="input_text" <?php if($_SESSION['type']!='S') echo 'readonly="readonly"'; ?> value="<?php if($record_id !='') { echo $row_record['order_no']; } else echo $order_no; ?>" style="width: 200px"></div>
                  </div>
				<div class="form-group">
					
					<label>Select Products</label>
					<!--*********************************Multiple*******************************************--->
					<div class="box-body">
					  <div class="table-responsive">
						<table width="100%" border="0" bgcolor="#CCCCCC" align="center">
						<tr>
						<!--<td width="10%">Select Product from stock<span class="orange_font">*</span></td>-->
						<td colspan="3">
						  <table  width="101%" class="table no-margin" style="border:1px solid gray; ">
							<tr>
							   <td colspan="2">
								<table cellpadding="5" width="100%" >
								 <tr>
								   <input type="hidden" name="no_of_floor" id="no_of_floor" class="inputText" size="1" onKeyUp="create_floor();" value="0" />
									 <script language="javascript">                              
										<?php 
										if($_SESSION['where'] !='')
										{
											$cm_ds= ' and p.cm_id='.$_SESSION['cm_id'].'';
										}
										else
										{
											$cm_ds='';
										}
										$readFaculty='readonly="readonly"';
										$bgFaculty='background-color:#bfbfbf';
										if($_SESSION['type']=='S' || $_SESSION['type']=='F' || $_SESSION['type']=='A' )
										{
											$readFaculty='';
											$bgFaculty='';
										}
										$readQa='readonly="readonly"';
										$bgQa='background-color:#bfbfbf';
										if($_SESSION['type']=='S' || $_SESSION['type']=='LD' || $_SESSION['type']=='B' || $_SESSION['type']=='QA' )
										{
											$readQa='';
											$bgQa='';
										}
										$readQm='readonly="readonly"';
										$bgQm='background-color:#bfbfbf';
										if($_SESSION['type']=='S' || $_SESSION['type']=='LD' || $_SESSION['type']=='ZM')
										{
											$readQm='';
											$bgQm='';
										}
										$readS='readonly="readonly"';
										$bgS='background-color:#bfbfbf';
										if($_SESSION['type']=='S' )
										{
											$readS='';
											$bgS='';
										}
										?>
										function floors(idss)
										{
											res= document.getElementById("res1").value;
											res11= document.getElementById("res2").value;

											var shows_data='<div id="floor_id'+idss+'"><table class="table no-margin" cellspacing="3" id="tbl'+idss+'" width="100%" style="margin:5px 0px 5px 0px !important"><tr><td width="17%" align="center"><input type="hidden" name="exclusive_id'+idss+'" id="exclusive_id'+idss+'" value="'+idss+'" /><select class="form-control select2" name="product_id'+idss+'" style="width:120px" id="product_id'+idss+'" onChange="show_product('+idss+');" required><option value="">Select Product</option>'+res+'</select><input type="hidden" class="input_txt datepicker" name="last_order_date'+idss+'" id="last_order_date'+idss+'" style="width:80px;<?php echo $bgS; ?>"><input type="hidden" name="last_order_qty'+idss+'" id="last_order_qty'+idss+'" style="width:80px;<?php echo $bgS; ?>"></td><td width="5%" align="center"><input type="text" name="qty_in_hand'+idss+'" id="qty_in_hand'+idss+'" style="width:80px;<?php echo $bgS; ?>"><input type="hidden" name="qty_in_stock'+idss+'" id="qty_in_stock'+idss+'"><input type="hidden" name="qty_consumed'+idss+'" id="qty_consumed'+idss+'" style="width:80px;<?php echo $bgS; ?>"></td><td width="5%" align="center"><input type="text" name="no_of_live_student'+idss+'" id="no_of_live_student'+idss+'" style="width:80px;<?php echo $bgS; ?>"></td><td width="5%" align="center"><input type="text" onBlur="check_quantity('+idss+')" name="qty_from_faculty'+idss+'" id="qty_from_faculty'+idss+'" style="width:80px;<?php echo $bgFaculty; ?>" <?php echo $readFaculty;?>><input type="hidden" name="qty_from_qa'+idss+'" id="qty_from_qa'+idss+'" style="width:80px;<?php echo $bgQa;?>" <?php echo $readQa;?>><input type="hidden" name="qty_from_qm'+idss+'" id="qty_from_qm'+idss+'" style="width:80px;<?php echo $bgQm;?>" <?php echo $readQm;?>><input type="hidden" name="tot_price'+idss+'" id="tot_price'+idss+'" style="width:80px;<?php echo $bgS; ?>"><input type="hidden" name="row_deleted'+idss+'" id="row_deleted'+idss+'"><input type="hidden" name="total_product[]" id="total_product'+idss+'"></td></tr><tr><td colspan="7"><div style="display:none" id="product_details'+idss+'"><table class="table no-margin" style="width:100%;margin:5px 0px 5px 0px !important" align="center" ><tr><td width="7%">MRP Price : <span id="price'+idss+'"></span><input type="hidden" name="mrp_price'+idss+'" id="mrp_price'+idss+'" ></td><td width="7%">Brand : <span id="brand'+idss+'"></span><input type="hidden" name="brand_id'+idss+'" id="brand_id'+idss+'" ></td><td width="10%" align="center">Unit : <span id="unit_val'+idss+'"></span><input type="hidden" name="unit'+idss+'" id="unit'+idss+'" style="width:60px"><span id="measure'+idss+'"></span><input type="hidden" name="measure_unit'+idss+'" id="measure_unit'+idss+'"><input type="hidden" name="vendor_id'+idss+'" id="vendor_id'+idss+'" ></td>';
											document.getElementById('floor').value=idss;
											return shows_data;
										}
									</script>
								   <td align="left">
									   <div class="btn-group">
										  <button type="button" name="Add" class="btn btn-success addBtn" onClick="javascript:create_floor('add');" alt="Add(+)">Add <i class="fa fa-plus"></i></button>
										  <button type="button" class="btn btn-danger delBtn" onClick="javascript:create_floor('delete');" alt="Delete(-)">Delete <i class="fa fa-minus"></i></button>
									   </div>
								   <!--<input type="button" name="Add" class="btn btn-sm addBtn" onClick="javascript:create_floor('add');" alt="Add(+)" > 
								   <input type="button" name="Add"  class="btn btn-sm delBtn"  onClick="javascript:create_floor('delete');" alt="Delete(-)" >-->
								  </td>
								</tr>
							</table>
								<table class="table no-margin" width="100%" border="0" class="tbl" bgcolor="#CCCCCC" align="center">
								<tr>
									<td colspan="6">
									  <table class="table no-margin" cellspacing="3" id="tbl" width="100%">
										<tr>
											<td valign="top" align="center" width="17%">Product Name</td>

											<!--<td valign="top" width="5%" align="center">Lat order date</td>-->
											<!--<td valign="top" width="5%" align="center">Last order Quantity</td>-->
											<td valign="top" width="5%" align="center">Qty in hand</td>
											<!--<td valign="top" width="5%" align="center">Qty Consumed</td>-->
											<td valign="top" width="5%" align="center">No.of.live student</td>
											<td valign="top" width="5%" align="center">Qty from Faculty/CM</td>
											<!--<td valign="top" width="5%" align="center">Qty from QA</td>
											<td valign="top" width="5%" align="center">Qty from QM</td>
											<td valign="top" width="5%" align="center">Total</td>-->
										</tr>
									  </table>
										<input type="hidden" name="floor" id="floor"  value="0" />
										<div id="create_floor"></div>
									</td>
								  </tr>
								</table>
								</td>
								</tr>
							</table> 
						 </td>
					   </tr>
				   		
							</table>
						</div>
					</div>
					<!--***************************************************************************--->
				</div>
                </div>
                <!-- /.col -->
                <div class="col-md-12">
                	<input type="submit" name="submit" value="Submit" class="btn btn-block btn-success">
                </div>
            	<!-- /.row -->
            </div>
            </form>
        	<!-- /.box-body -->
        	<!--<div class="box-footer">
          Visit <a href="https://select2.github.io/">Select2 documentation</a> for more examples and information about
          the plugin.
        </div>-->
      </div>
      <div class="row">
        <!-- Left col -->
        <div class="col-md-12">
          <!-- TABLE: LATEST ORDERS -->
          <div class="box box-info">
            <div class="box-header with-border">
              <h3 class="box-title">Order List</h3>
              <div class="box-tools pull-right">
                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
                </button>
                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
              </div>
            </div>
            <!-- /.box-header -->
			<div class="box-body">
              <div class="table-responsive">
                <table class="table no-margin">
                	<thead>
						<tr>
							<th style="text-align:center !important">Sr. No.</th>
							<th style="text-align:center !important">Order No.</th>
							<th style="text-align:center !important">Category</th>
							<th style="text-align:center !important">Total Product</th>
							<th style="text-align:center !important">Added Date</th>
							<th style="text-align:center !important">Status</th>
							<th style="text-align:center !important">View</th>
						</tr>
                  	</thead> 
					<tbody>
					<?php
					$t=1;
					$sel_app="select * from order_list where 1 and  cm_id='".$_SESSION['cm_id']."' and employee_id='".$_SESSION['admin_id']."' order by order_list_id desc";
					$ptr_app=mysql_query($sel_app);
					while($data_app=mysql_fetch_array($ptr_app))
					{
						$sel_staff="select name from site_setting where 1 and admin_id='".$data_app['status_updated_by']."'";
						$ptr_staff=mysql_query($sel_staff);
						$data_staff=mysql_fetch_array($ptr_staff);
						?>
						<tr>
							<td align="center"><?php echo $t; ?></td>
							<td align="center"><?php echo $data_app['order_no']; ?></td>
							<?php
							$sel_domain="SELECT * FROM product_category where pcategory_id='".$data_app['category_id']."' order by pcategory_id asc ";	 
							$query_domain=mysql_query($sel_domain);
							$data_c=mysql_fetch_array($query_domain);
							echo '<td align="center">'.$data_c['pcategory_name'].'</td>';
							?>
							<td align="center"><?php echo $data_app['total_qty']; ?></td>
							<td align="center"><?php echo $data_app['added_date']; ?></td>
							<td align="center"><?php echo $data_app['status']; ?></td>
							<?php 
							echo '<td align="center"><a href="lv_manage_order_list.php?record_id='.$data_app['order_list_id'].'" ><i class="fa fa-fw fa-file-text-o"></i></a>&nbsp;&nbsp;</td>';
							//echo '<td align="center"><a onclick="return validationToDelete(\''.$_SERVER['PHP_SELF'].'\');" href="'.$_SERVER['PHP_SELF'].'?deleteRecord=1&record_id='.$listed_record_id.'&page='.$_REQUEST['page'].$query_string1.'"><img src="images/delete_icon.png" title="Delete Record" class="example-fade" /></a>&nbsp;&nbsp;</td>';
							?>					
						</tr> 
						<?php
						$t++;
					}
					?>
					</tbody>
				</table>
           	</div>
            <!-- /.table-responsive -->
            </div>
            <!-- /.box-body -->
			<div class="box-footer clearfix">
			<!--<a href="javascript:void(0)" class="btn btn-sm btn-info btn-flat pull-left">Place New Order</a>
			<a href="javascript:void(0)" class="btn btn-sm btn-default btn-flat pull-right">View All Orders</a>-->
			</div>
            <!-- /.box-footer -->
            </div>
          <!-- /.box -->
        </div>
        <!-- /.col -->
	  </div>
      <!-- /.box -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
  <?php include "include/footer-main.php"; ?>
</div>
<!-- jQuery 3 -->
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Select2 -->
<script src="bower_components/select2/dist/js/select2.full.min.js"></script>
<!-- InputMask -->
<script src="plugins/input-mask/jquery.inputmask.js"></script>
<script src="plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
<script src="plugins/input-mask/jquery.inputmask.extensions.js"></script>
<!-- date-range-picker -->
<script src="bower_components/moment/min/moment.min.js"></script>
<script src="bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
<!-- bootstrap datepicker -->
<script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
<!-- bootstrap color picker -->
<script src="bower_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.min.js"></script>
<!-- bootstrap time picker -->
<script src="plugins/timepicker/bootstrap-timepicker.min.js"></script>
<!-- SlimScroll -->
<script src="bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- iCheck 1.0.1 -->
<script src="plugins/iCheck/icheck.min.js"></script>
<!-- FastClick -->
<script src="bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
	
<script language="javascript" src="dist/js/script.js"></script>
<script language="javascript" src="dist/js/conditions-script.js"></script>
<!-- Page script -->
<script>
  $(function () {
    //Initialize Select2 Elements
    $('.select2').select2();
    //Datemask dd/mm/yyyy
    /*$('#datemask').inputmask('dd/mm/yyyy', { 'placeholder': 'dd/mm/yyyy' })
    //Datemask2 mm/dd/yyyy
    $('#datemask2').inputmask('mm/dd/yyyy', { 'placeholder': 'mm/dd/yyyy' })
    //Money Euro
    $('[data-mask]').inputmask()

    //Date range picker
    $('#reservation').daterangepicker()
    //Date range picker with time picker
    $('#reservationtime').daterangepicker({ timePicker: true, timePickerIncrement: 30, format: 'MM/DD/YYYY h:mm A' })
    //Date range as a button
    $('#daterange-btn').daterangepicker(
      {
        ranges   : {
          'Today'       : [moment(), moment()],
          'Yesterday'   : [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
          'Last 7 Days' : [moment().subtract(6, 'days'), moment()],
          'Last 30 Days': [moment().subtract(29, 'days'), moment()],
          'This Month'  : [moment().startOf('month'), moment().endOf('month')],
          'Last Month'  : [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
        },
        startDate: moment().subtract(29, 'days'),
        endDate  : moment()
      },
      function (start, end) {
        $('#daterange-btn span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'))
      }
    )*/
    //Date picker
    $('#datepicker').datepicker({
      autoclose: true,
	  format: 'dd/mm/yyyy',
	  startDate: '-0d',
	  Default: true,
	  todayHighlight: true
    })
	$('#datepicker1').datepicker({
      autoclose: true,
	  format: 'dd/mm/yyyy',
	  Default: true,
	  todayHighlight: true
    })
    //iCheck for checkbox and radio inputs
    $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
      checkboxClass: 'icheckbox_minimal-blue',
      radioClass   : 'iradio_minimal-blue'
    })
    //Red color scheme for iCheck
    $('input[type="checkbox"].minimal-red, input[type="radio"].minimal-red').iCheck({
      checkboxClass: 'icheckbox_minimal-red',
      radioClass   : 'iradio_minimal-red'
    })
    //Flat red color scheme for iCheck
    $('input[type="checkbox"].flat-red, input[type="radio"].flat-red').iCheck({
      checkboxClass: 'icheckbox_flat-green',
      radioClass   : 'iradio_flat-green'
    })
    //Colorpicker
    $('.my-colorpicker1').colorpicker()
    //color picker with addon
    $('.my-colorpicker2').colorpicker()

    //Timepicker
    $('.timepicker').timepicker({
      showInputs: false
    })
})

function get_product_by_cat(cat_id)
{
	var branch_name=document.getElementById('branch_name').value;
	var data1="action=get_category_wise_product&branch_name="+branch_name+"&cat_id="+cat_id;
	//alert(data1);
	$.ajax({
		url: "get_product_list.php", type: "post", data: data1, cache: false,
		success: function (html)
		{
			document.getElementById("create_floor").innerHTML='';
			//document.getElementById("create_type1").innerHTML='';
			document.getElementById("res1").value=html;
		}
	});
}
function count_days(to_date)
{
	var frm_date=document.getElementById("datepicker").value;
	frm_date_split=frm_date.split('/');
	new_frm_date=frm_date_split[1]+'/'+frm_date_split[0]+'/'+frm_date_split[2];

	to_date_split=to_date.split('/');
	new_to_date=to_date_split[1]+'/'+to_date_split[0]+'/'+to_date_split[2];

	const dt_date1 = new Date(new_frm_date);
	const dt_date2 = new Date(new_to_date);


	var difference_time = dt_date2.getTime() - dt_date1.getTime();
	var diff = parseInt(difference_time / (1000 * 3600 * 24));
	document.getElementById("leave_days").value=diff+1;
	//var daydiff = diff / (1000 * 60 * 60 * 24);   
	//alert("differance days "+diff);
}
</script>
<script type="text/javascript">
function show_product(ids)
{
	product_id=document.getElementById("product_id"+ids).value;
	//alert(product_id)
	var data1="product_id="+product_id;
	$.ajax({
		url: "get-product_qty.php", type: "post", data: data1, cache: false,
		success: function (html)
		{
			var new_values= document.getElementById('unit'+ids).value=html;
			
			var fields = new_values.split(/-/);
			var unit11 = fields[0];
			var sep_field= unit11.split(" ");
			var unit1=sep_field[0];
			var measure=sep_field[1];
			
			var quantity = fields[1];
			var quantity_new = quantity /*- quantity_minus*/;
			
			//alert(quantity_new);
			$("#unit"+ids).val(unit1);
			$("#unit_val"+ids).html(unit1);
			$("#measure"+ids).html(measure);
			$("#measure_unit"+ids).val(measure);
			$("#qty_in_stock"+ids).val(quantity);
			
			var prod_desc=fields[2];
			//alert(prod_desc);
			var details = prod_desc.split(/#/);
			var price= details[0];
			var brand= details[1];
			var description= details[2];
			
			document.getElementById("product_details"+ids).style.display="block";
			$("#price"+ids).html(price);
			$("#mrp_price"+ids).val(price);
			$("#brand"+ids).html(details[3]);
			$("#brand_id"+ids).val(brand);
			//$("#description"+ids).html(description);
			/*if(document.getElementById("select_from"))
			{
				values=document.getElementById("select_from").value;
				show_product_qty(values)
			}*/
			setTimeout(show_last_order_details(ids),500)
		}
	});
}
function show_last_order_details(ids)
{
	product_id=document.getElementById("product_id"+ids).value;
	employee_id=document.getElementById("employee_id").value;
	//alert(product_id)
	var data1="product_id="+product_id+"&employee_id="+employee_id;
	$.ajax({
		url: "get_last_order_details.php", type: "post", data: data1, cache: false,
		success: function (html)
		{
			//alert(html);
			var fields = html.split(/#/);
			var last_order_date = fields[0];
			var last_quantity = fields[1];

			$("#last_order_date"+ids).val(last_order_date);
			$("#last_order_qty"+ids).val(last_quantity);
			$("#qty_in_hand"+ids).val(fields[2]);
			$("#qty_consumed"+ids).val(fields[3]);
			$("#no_of_live_student"+ids).val(fields[4]);
			$("#vendor_id"+ids).val(fields[5]);
		}
	});
}
function show_product_qty(id)
{
	var type=document.getElementById("select_from"+id).value;
	//alert(type)
	if(type=="stock")
	{
		var product_id= document.getElementById("product_id"+id).value;	
		var data="product_id="+product_id+"&type="+type+"&id="+id;
		//alert(data)	
		$.ajax({
            url: "get_product_from_stock.php", type: "post", data: data, cache: false,
            success: function (html)
			{
				//alert(html)
				sep=html.split("###");
				
				$("#quantity"+id).val(sep[0]);
				document.getElementById("select_to_div"+id).innerHTML=sep[1];
			}
		});
	}
	else
	{
		var product_id= document.getElementById("product_id"+id).value;	
		var data="product_id="+product_id+"&type="+type+"&id="+id;	
		$.ajax({
			
            url: "get_product_from_shelf_cons.php", type: "post", data: data, cache: false,
            success: function (html)
			{
				sep=html.split("###");
				$("#quantity"+id).val(sep[0]);
				document.getElementById("select_to_div"+id).innerHTML=sep[1];
			}
		});
	}
}
function check_quantity(qty_id)
{
	qty=document.getElementById("qty_from_faculty"+qty_id).value;
	price=document.getElementById("mrp_price"+qty_id).value;
	if(price > 0)
	{
		var tot_price = Number(qty * price);
		document.getElementById("tot_price"+qty_id).value=tot_price;
	}
}
</script>
</body>
</html>