<?php
session_start();
if(!isset ($_SESSION['user_id'])){
    header("Location:../index.php?msg=Log in first");
    exit();
}else{
	include('../Server/connection.php');
	include('includes/session.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>
	
  <!-- jquery ui -->  
  <link rel="stylesheet" href="assests/jquery-ui/jquery-ui.min.css">
  <script src="assests/jquery-ui/jquery-ui.min.js"></script>
	
  <!-- Must Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></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="dashboard.php">  <h2><span class="glyphicon glyphicon-step-backward"></span> Back</h2></a>
					
					<?php
					/*
				$order_Id = $_GET['i'];
				
				$sql81 = "SELECT * FROM details,orders	
					WHERE orders.order_id = {$order_Id} and details.id=orders.customer_id";

				$result81 = $conn->query($sql81);
				//$data81 = $result81->fetch_row();
				
				while($data81 = mysqli_fetch_array($result81))
							{
							$payment_mode = $data81['mode_id'];
							$vatAmount = number_format($data81['vat'],2);
							$vatAmount11 = $data81['vat'];
							$grandAmount = number_format($data81['grand_total_amount'],2);
							$grandAmount11 = $data81['grand_total_amount'];
							$totalAmount = number_format($data81['total_amount'],2);
							$totalAmount11 = $data81['total_amount'];
				            }
				
                $sql812 = "SELECT vat_settings.rate FROM vat_settings";
				$result812 = $conn->query($sql812);
				while($data812 = mysqli_fetch_array($result812))
							{
							$vat_rate = $data812['rate'];
							}				
						*/	
				//$m = $data8[6];
				
				//$invDate = date('m/d/Y', strtotime($inv_date));
				//$dueDate = date('m/d/Y', strtotime($due_date));
               //echo $total_amount;			
				?>
					
					
					
                    <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" method="POST" action="php_action/recordSalaries.php" id="createOrderForm" enctype="multipart/form-data">
			   
			    <input type="hidden" name="order_id" value="<?php echo $order_Id; ?>">
              
              <table class="table" id="productTable">
			  	<thead>
			  		<tr>			  			
			  			<th style="width:5px;">S/N:</th>
						<th style="width:2000px;">Service</th>
			  			<th style="width:1200px;">Price in Usd</th>
			  			<th style="width:1200px;">Duration in Hrs</th>			  			
			  			<th style="width:1200px;">Amount in Usd</th>		  			
			  			<th style="width:5px;"></th>
			  		</tr>
			  	</thead>
			  	<tbody>
			  		<?php
			  		//$arrayNumber = 0;
					//$no 	= 1;
			  		//for($x = 1; $x < 4; $x++) { 
					
					$invItemSql = "SELECT ordered_services.totalAmount,grand_child_services.gcservice_id,grand_child_services.pservice_id,grand_child_services.cservice_id,grand_child_services.gcService_name,grand_child_services.price,grand_child_services.duration FROM grand_child_services,ordered_services WHERE ordered_services.gcservice_id=grand_child_services.gcservice_id and ordered_services.order_id = {$order_Id}";
					$invItemResult = $conn->query($invItemSql);
						// $orderItemData = $orderItemResult->fetch_all();						
						
						// print_r($orderItemData);
			  		$arrayNumber = 0;
			  		// for($x = 1; $x <= count($orderItemData); $x++) {
			  		$x = 1;
			  		while($invItemData = $invItemResult->fetch_array()) { 
					$gcservice_id = $invItemData['gcservice_id'];
					//$pservice_id = $invItemData['pservice_id'];
					//$cservice_id = $invItemData['cservice_id'];
					          ?>
					
			  			<tr id="row<?php echo $x; ?>" class="<?php echo $arrayNumber; ?>">	
						
						   <td style="width:2px;">
			  					<div class="form-group">
								<?php
								print $x;
								?>
			  					</div>
			  				</td>
							
							
							
							 <td style="width:5000px;">
			  					<div class="form-group">
								
								  <select class="form-control" name="grandService[]" id="grandService<?php echo $x; ?>" onchange="getProductData(<?php echo $x; ?>)" required />
								
					   <?php
				$lev11 = 'level_3';	   
				$sqlRs2212 = "SELECT * FROM grand_child_services where gcservice_id='$gcservice_id'";
				$Rs2212 = $conn->query($sqlRs2212);
				while($row2212 = $Rs2212->fetch_array()){									 		
			  	echo "<option value='".$row2212['gcservice_id']."' class='".$lev11."'>".$row2212['gcService_name']."</option>";
				  } 	   
					   
					   
				$sqlRs = "SELECT parent_services.service_name,parent_services.pservice_id FROM parent_services order by service_name";
                $Rs = $conn->query($sqlRs);
				
               while($rowRs = mysqli_fetch_assoc($Rs))
                  {
				$pservice_id = $rowRs['pservice_id'];
				$service_name = $rowRs['service_name'];
				?>		
				 <option class="level_1"><?php echo $service_name;?></option>
				<?php
				$sqlRs22 = "SELECT child_services.cservice_id,child_services.childService_name FROM child_services where pservice_id='$pservice_id'";
				$Rs22 = $conn->query($sqlRs22);
				while($rowRs22 = mysqli_fetch_assoc($Rs22))
                  {
				$cservice_name = $rowRs22['childService_name'];
				$cservice_id = $rowRs22['cservice_id'];
				?>
				
                <option class="level_2"><?php echo $cservice_name;?></option>
				
				 <?php
				$lev = 'level_3';
				$sqlRs221 = "SELECT * FROM grand_child_services where pservice_id='$pservice_id' and cservice_id='$cservice_id'";
				$Rs221 = $conn->query($sqlRs221);
				while($row221 = $Rs221->fetch_array()){									 		
			  	echo "<option value='".$row221['gcservice_id']."' class='".$lev."'>".$row221['gcService_name']."</option>";
				  }
				  
				 
				  
				  }
				  }
				?>
						 
					
              </select>
								
								
                               
								
								
								
			  					</div>
			  				</td>

                            <td style="width:5000px;">			  					
			  					<input type="text" name="rate[]" id="rate<?php echo $x; ?>" onkeyup="getTotal(<?php echo $x ?>)" value="<?php echo $invItemData['price']; ?>" autocomplete="off"  disabled="true" class="form-control" />			  					
			  					<input type="hidden" name="rateValue[]" id="rateValue<?php echo $x; ?>" value="<?php echo $invItemData['price']; ?>" autocomplete="off" class="form-control" />			  					
			  				</td>
			  			
							
							
							<!--choosed -->
			  				<td style="width:4500px;">
			  					<div class="form-group">
			  					<input type="number" name="quantity[]" id="quantity<?php echo $x; ?>" onkeyup="getTotal(<?php echo $x ?>)" value="<?php echo $invItemData['duration']; ?>" autocomplete="off" disabled="true" class="form-control"/>
			  					</div>
			  				</td>
							<!--choosed -->
							
							
							
                            <td style="width:7500px;">								
			  					<input type="text" name="total[]" id="total<?php echo $x; ?>" value="<?php echo $invItemData['totalAmount']; ?>" autocomplete="off" class="form-control" disabled="true" />			  					
			  					<input type="hidden" name="totalValue[]" id="totalValue<?php echo $x; ?>" value="<?php echo $invItemData['totalAmount']; ?>" autocomplete="off" class="form-control" />			  					
			  				</td>
							
							
			  				<td>

			  					<button class="btn btn-default removeProductRowBtn" type="button" id="removeProductRowBtn" onclick="removeProductRow(<?php echo $x; ?>)"><i class="glyphicon glyphicon-trash"></i></button>
			  				</td>
			  			</tr>
		  			<?php
		  			//$arrayNumber++;
					//$no++;
			  		//} // /for
					$arrayNumber++;
		  			$x++;
			  		} // /for
			  		?>
			  	</tbody>			  	
			  </table>
			  
			  
			  <div class="controls">
			  <div class="row">

			  <div class="col-sm-4">
			  <div class="form-group">
			  <label for="form_name">Sub Amount </label>
			  <input type="text" class="form-control" id="subTotal"  name="subTotal" value="<?php echo $grandAmount; ?>" disabled="true" />
			  <input type="hidden" class="form-control" id="subTotalValue" name="subTotalValue" value="<?php echo $grandAmount11; ?>" />				      
              </div>
			  </div>
			  
			  <div class="col-sm-4">
			  <div class="form-group">
		      <label for="form_name">Vat <?php echo $vat_rate?> % </label>
			  <input type="text" class="form-control" id="vat"  name="vat" value="<?php echo $vatAmount; ?>" disabled="true" />
			  <input type="hidden" class="form-control" id="vatValue" name="vatValue" value="<?php echo $vatAmount11; ?>"/>
			  </div>
			  </div>
			  
			  
			  <div class="col-sm-4">
			  <div class="form-group">
			  <label for="form_name">Total Amount </label>
			  <input type="text" class="form-control" id="totalAmount" name="totalAmount" value="<?php echo $totalAmount; ?>" disabled="true"/>
			  <input type="hidden" class="form-control" id="totalAmountValue" name="totalAmountValue" value="<?php echo $totalAmount11; ?>"/>      
              </div>
			  </div>
			  
			  </div>	  
              </div>
			  
			  
			    <div class="controls">
			  <div class="row">

			  <div class="col-sm-6">
			  <div class="form-group">
			  <label for="form_name">Payment Mode </label>
			  
			  
			  <select class="form-control" name="payment_mode" id="payment_mode" style="width:100%;margin-left:0%;" autocomplete="off" required />
			  						<?php	
											
									$productSql32 = "SELECT id,name from payment_mode where id='$payment_mode'";
			  							$productData32 = $conn->query($productSql32);

			  							while($row32 = $productData32->fetch_array()) {									 		
			  								echo "<option value='".$row32['id']."'>".$row32['name']."</option>";
										 	} // /while 

                                       
									   $productSql33 = "SELECT id,name from payment_mode where id!='$payment_mode'";
			  							$productData33 = $conn->query($productSql33);

			  							while($row33 = $productData33->fetch_array()) {									 		
			  								echo "<option value='".$row33['id']."'>".$row33['name']."</option>";
										 	} // /while 

			  						?>
		  						</select>



			  
              </div>
			  </div>
			  
			
			  
			  <div class="col-sm-6">
			  <div class="form-group">
			  
			  <label for="form_name">Upload Document (s): </label>
				 </br>
				 <label class="radio-inline">
          <input type="radio" name="upl_status" value="Yes" id="upl_status"> Yes
         </label>&nbsp&nbsp&nbsp&nbsp
         <label class="radio-inline">
          <input type="radio" name="upl_status" value="No" id="upl_status" checked> No
         </label>&nbsp&nbsp&nbsp&nbsp
		 
		
		
		<div id="textboxes3" style="display: none">		
		     
			 <label for="form_name">Upload Document(s) </label>
			  <input  type="file" name="file[]"  id="file" class="form-control" style="width:100%;margin-left:0%;" multiple>
			  
			   <br/>
        <label for="file" class="error" generated="true"></label>
			 
			</div>
              
				  
                </div>
			   </div>
			  
			  </div>	  
              </div>
			  
		
			  </br></br>
			
			  <div class="form-group submitButtonFooter">
			    <div class="col-sm-12">
			    <!--<button type="button" class="btn btn-default" onclick="addRow()" id="addRowBtn" data-loading-text="Loading..."> <i class="glyphicon glyphicon-plus-sign"></i> Add Row </button>-->
			      <button type="submit" id="createOrderBtn" data-loading-text="Loading..." class="btn btn-success"><i class="glyphicon glyphicon-ok-sign"></i> Save Changes</button>
                  </br></br>
			      <!--<button type="reset" class="btn btn-default" onclick="resetOrderForm()"><i class="glyphicon glyphicon-erase"></i> Reset</button>-->
			    </div>
			  </div>
			  
			  
			</form>                  
					
				</div>  
               
				
				
				
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->
		
		
		<?php
		include 'includes/footer.php';
		?>
		
        
      </div>
    </div>
	
	
	<script>	
	$(document).ready(
function(){
   $('.level_2').each(
        function(){
            $(this).text('----'+$(this).text());
        }
   );

   $('.level_3').each(
        function(){
            $(this).text('---------'+$(this).text());
        }
   );

 }
);
</script>

<script>	
	$(document).ready(function(){
    $('input[name="upl_status"]').on('click', function(){
        if ($(this).val() == 'Yes'){
			 $('#textboxes3').show();
        }else {
			$('#textboxes3').hide();
		}
	
		
    });
});
</script>

   <!-- Must -->
    <script src="custom/js/recordSalaries.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
}
?>