<?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="generalExpenses.php">  <h2><span class="glyphicon glyphicon-step-backward"></span> Back</h2></a>
					
					<?php
				$exp_id = $_GET['i'];
				$sql81 = "SELECT * FROM expenses WHERE expenses.exp_id = {$exp_id}";
				$result81 = $conn->query($sql81);
				while($data81 = mysqli_fetch_array($result81))
							{
							$amount_used = $data81['amount'];
							$exp_desc = $data81['exp_desc'];
							$expCate_id = $data81['expCate_id'];
							$currency_id = $data81['currency_id'];
				            }
							
				      ?>
					
					
					
                    <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/editExpenses.php" enctype="multipart/form-data">
			   
			    <input type="hidden" name="exp_id" value="<?php echo $exp_id; ?>">
				
				
				<div class="item form-group">
                        <label for="password" class="control-label col-md-3">Category</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						  <select class="form-control" name="expCate_id" id="expCate_id" autocomplete="off">
			  						<?php
			  							$productSql = "SELECT * FROM expcate where expCate_id='$exp_id'";
			  							$productData = $conn->query($productSql);
			  							while($row = $productData->fetch_array()){									 		
			  								echo "<option value='".$row['expCate_id']."'>".$row['name']."</option>";
										 	} // /while 
											
										$productSql7 = "SELECT * FROM expcate where expCate_id!='$exp_id'";
			  							$productData7 = $conn->query($productSql7);
			  							while($row7 = $productData7->fetch_array()){									 		
			  								echo "<option value='".$row7['expCate_id']."'>".$row7['name']."</option>";
										 	} // /while 

			  						?>
		  						</select>
								<br/>
                         <label for="expCate_id" class="error" generated="true"></label>
                         
                        </div>
                      </div>
					  
					  
			
					  
					  
					  
			   <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Currency</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						  <select class="form-control" name="currency_id" id="currency_id" autocomplete="off">
			  						<!--<option value="">~~SELECT~~</option>-->
			  						<?php
			  							$productSql4 = "SELECT * FROM currency where currency_id='$currency_id'";
			  							$productData4 = $conn->query($productSql4);
			  							while($row4 = $productData4->fetch_array()){									 		
			  								//echo "<option value='".$row4['currency_id']."'>".$row4['bank_name']."&nbsp&nbsp".$row4['bank_account']."</option>";
											echo "<option value='".$row4['currency_id']."'>".$row4['bank_name']."&nbsp&nbsp".$row4['bank_account']."&nbsp&nbsp".$row4['currencyName']."</option>";
										 	} // /while 
											
										$productSql4e = "SELECT * FROM currency where currency_id!='$currency_id'";
			  							$productData4e = $conn->query($productSql4e);
			  							while($row4e = $productData4e->fetch_array()){									 		
			  								//echo "<option value='".$row4['currency_id']."'>".$row4['bank_name']."&nbsp&nbsp".$row4['bank_account']."</option>";
											echo "<option value='".$row4e['currency_id']."'>".$row4e['bank_name']."&nbsp&nbsp".$row4e['bank_account']."&nbsp&nbsp".$row4e['currencyName']."</option>";
										 	} // /while 

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

                       <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Used For (Description) </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						<textarea id="exp_desc" rows="10" cols="50" name="exp_desc" class="form-control" style="margin-left:0%;" autocomplete="off"> <?php echo htmlspecialchars($exp_desc);  ?> </textarea>
			            <br/>
                         <label for="exp_desc" 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>
			
			  
			  
			</form>                  
					
				</div>  
               
				
				
				
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->
		
		
		<?php
		include 'includes/footer.php';
		?>
		
        
      </div>
    </div>
	
	<script>
 $("#id_frm").validate({
        rules: {
			
			"expCate_id": {
                required: true
            },
			
			"currency_id": {
                required: true
            },
			
			
			
			"amount": {
                required: true
            },
			
			"exp_desc": {
                required: true
            }
			
			
		 
        },
        messages: {
			
			"expCate_id": {
                required: "Please Select Category."
            },
			
			"currency_id": {
                required: "Please Select Currency."
            },
			
			
			
			"amount": {
                required: "Please Enter Amount Used"
            },
			
			
			
			
			"exp_desc": {
                required: "Please Enter Description"
            }
			
        },
        // for demo
        //submitHandler: function(form) {
            //alert('valid form');
            //return false;
        //}
 });
</script>
	
	<script>
	// order date picker
		$("#eta").datepicker();
		
		// delivery date picker
		//$("#dueDate").datepicker();
	
	</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
}
?>