<?php
session_start();
if(!isset ($_SESSION['user_id'])){
	header("Location:../login.php?msg=Log in first");
    exit();
}else{
	include('includes/session.php');
    include('../Server/connection.php');
	echo "<div class='div-request div-hide'>editOrd</div>";
    	
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

	
	 <?php
  include 'title.php';
         ?>
	
	
	<link type = "image/png" rel="icon" href="images/brvision.png" />

    <!-- Bootstrap must-->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
	
    <!-- Font Awesome must-->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
	
	<!-- custom css -->
    <link rel="stylesheet" href="custom/css/custom.css">
	
    <!-- NProgress must-->
    <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
	
    <!-- Custom Theme Style must-->
    <link href="../build/css/custom.min.css" rel="stylesheet">
	
	<!-- must-->
	<script src="assests/jquery/jquery.min.js"></script>
	
	<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.min.js"></script>
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/additional-methods.min.js"></script>
	
  
	
  <!-- Must Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>
	
	<script type="text/javascript">
$(document).ready(function(){
    $('#client_id').on('change',function(){
        var regID = $(this).val();
        if(regID){
            $.ajax({
                type:'POST',
                url:'ajaxData11.php',
                data:'client_id='+regID,
                success:function(html){
                    $('#inv_id').html(html);
                }
            }); 
        }else{
            $('#inv_id').html('<option value="">Select Client First</option>');
        }
    });

});
</script>

	
  </head>

  <body class="nav-md">
  
    <div class="container body">
	
      <div class="main_container">
        <div class="col-md-3 left_col">
          <div class="left_col scroll-view">
		  
             <?php  
		include 'includes/role.php';
               ?>

            <div class="clearfix"></div>
            
			
			<?php
            include 'includes/profile.php';
			print '</br></br>';
			include 'includes/menu.php';
			?>


           

        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
		  
			
			
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
				  
                    <a href="viewAssets.php">  <h2><span class="glyphicon glyphicon-step-backward"></span> Back</h2></a>
					
					<?php
				$asset_id = $_GET['i'];
				$sql81 = "SELECT * FROM assets,itemtypes WHERE assets.asset_id = {$asset_id} and assets.itemType_id=itemtypes.itemType_id";
				$result81 = $conn->query($sql81);
				while($data81 = mysqli_fetch_array($result81))
							{
							$asset_name = $data81['asset_name'];
							$itemType_id = $data81['itemType_id'];
							$serial_no = $data81['serial_no'];
							$value  = $data81['value'];
							$remarks = $data81['remarks'];
							$itemTypeName = $data81['name'];
				            }
							
				      ?>
					
					
					
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      
                     
                    </ul>
                    <div class="clearfix"></div>
                  </div>
				  
				
				<div class="x_content" style="overflow: auto;">
				
				<?php if (isset($_SESSION['success_message']) && !empty($_SESSION['success_message'])) { ?>
                        <div class="success-message" style="margin-bottom: 20px;font-size: 20px;color: green;"><?php echo $_SESSION['success_message']; ?></div>
                        <?php
                        unset($_SESSION['success_message']);
                    }
                    ?>	
				 
				  <div class="success-messages"></div> <!--/success-messages-->

               <form class="form-horizontal" id="id_frm" method="POST" action="php_action/editAsset.php" enctype="multipart/form-data">
			   
			    <input type="hidden" name="asset_id" value="<?php echo $asset_id; ?>">
				
				
				<div class="item form-group">
                        <label for="password" class="control-label col-md-3">Item Type</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						  <select class="form-control" name="itemType_id" id="itemType_id" autocomplete="off">
			  						<?php
			  							$productSql = "SELECT * FROM itemtypes where itemType_id='$itemType_id'";
			  							$productData = $conn->query($productSql);
			  							while($row = $productData->fetch_array()){									 		
			  								echo "<option value='".$row['itemType_id']."'>".$row['name']."</option>";
										 	} // /while 
											
										$productSql7 = "SELECT * FROM itemtypes where itemType_id!='$itemType_id'";
			  							$productData7 = $conn->query($productSql7);
			  							while($row7 = $productData7->fetch_array()){									 		
			  								echo "<option value='".$row7['itemType_id']."'>".$row7['name']."</option>";
										 	} // /while 

			  						?>
		  						</select>
								<br/>
                         <label for="itemType_id" class="error" generated="true"></label>
                         
                        </div>
                      </div>
					  
					  
					   <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Asset Name</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						<input  type="text" style="width:100%;margin-left:0%;" placeholder="Asset Name" name="asset_name" id = "asset_name" value="<?php echo $asset_name; ?>"  class="form-control col-md-7 col-xs-12">
						  <br/>
                         <label for="asset_name" class="error" generated="true"></label>
						
						
						</div>
						</div>	

                  <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Serial No</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						<input  type="text" style="width:100%;margin-left:0%;" placeholder="Serial No" name="serial_no" id = "serial_no" value="<?php echo $serial_no; ?>"  class="form-control col-md-7 col-xs-12">
						  <br/>
                         <label for="serial_no" class="error" generated="true"></label>
						
						
						</div>
						</div>		

                     <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Value in Tsh.</label>
					  	
                        <div class="col-md-6 col-sm-6 col-xs-12">
						<input  type="number" style="width:100%;margin-left:0%;" placeholder="Value in Tsh" name="value" id = "value" min="1" value="<?php echo $value; ?>" class="form-control col-md-7 col-xs-12">
						  <br/>
                         <label for="value" class="error" generated="true"></label>
						
						
						</div>
						</div> 	

                    <div class="item form-group">
                        <label for="password" class="control-label col-md-3"> Remarks </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<textarea id="remarks" rows="10" cols="50" name="remarks" class="form-control" style="margin-left:0%;" autocomplete="off"> <?php echo htmlspecialchars($remarks);  ?> </textarea>
			            <br/>
                         <label for="remarks" class="error" generated="true"></label>
                          
                       
						  
						</div>
                      </div>						
					  
							
						
				
			 <div class="item form-group">
                        <label for="password" class="control-label col-md-3"></label>
					  	
                        <div class="form-group submitButtonFooter col-md-6 col-sm-6 col-xs-12">
						
						 <!--<input  type="number" style="width:100%;margin-left:0%;" placeholder="Cheque No" name="cheque_no" id = "cheque_no"  class="form-control col-md-7 col-xs-12">-->
						 <button type="submit" id="createOrderBtn" data-loading-text="Loading..." class="btn btn-success"><i class="glyphicon glyphicon-ok-sign"></i> Save Changes</button>
						
						</div>
						</div>
			
			  <!--<div class="form-group submitButtonFooter">
			    <div class="col-sm-12">
			      <button type="submit" id="createOrderBtn" data-loading-text="Loading..." class="btn btn-success"><i class="glyphicon glyphicon-ok-sign"></i> Save Changes</button>
			    </div>
			  </div>-->
			  
			  
			</form>                  
					
				</div>  
               
				
				
				
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->
		
		
		<?php
		include 'includes/footer.php';
		?>
		
        
      </div>
    </div>
	
<script>
	
 $("#id_frm").validate({
        rules: {
			
			"itemType_id": {
                required: true
            },
			
			"serial_no": {
                required: true
            },
			
			"quantity": {
                required: true
            },
			
			"value": {
                required: true
            },
			
			"remarks": {
                required: true
            }
		 
        },
        messages: {
			
			"itemType_id": {
                required: "Please Select Item Type."
            },
			
			"serial_no": {
                required: "Please Enter Serial No."
            },
			
			"quantity": {
                required: "Please Enter Quantity."
            },
			
			"value": {
                required: "Please Enter Value."
            },
			
			"remarks": {
                required: "Please Enter Amount Paid"
            }
			
			
        },
        // for demo
        //submitHandler: function(form) {
            //alert('valid form');
            //return false;
        //}
 });
</script>
	


   <!-- Must -->
    <script src="custom/js/editClientFiles.js"></script>
	
    <!-- Must Custom Theme Scripts -->
    <script src="../build/js/custom.min.js"></script>
	
	<!-- file input -->
	<script src="assests/plugins/fileinput/js/plugins/canvas-to-blob.min.js'); ?>" type="text/javascript"></script>	
	<script src="assests/plugins/fileinput/js/plugins/sortable.min.js" type="text/javascript"></script>	
	<script src="assests/plugins/fileinput/js/plugins/purify.min.js" type="text/javascript"></script>
	<script src="assests/plugins/fileinput/js/fileinput.min.js"></script>	


	<!-- DataTables -->
	<script src="assests/plugins/datatables/jquery.dataTables.min.js"></script>

  </body>
</html>



<?php
}
?>