<?php
	include("my_functions.php");
	$pagetitle = "Complete job";
	require('includes/applicationtop.php');
	require('includes/applicationmenu.php');
	
	$err= "";

    $actual_link = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
		$parts = explode('updatetopupmodeofpayment' , $actual_link);
		
    $fromdate = false;
    $selector = false;
	
	$startdatevalid = false;
	
	 
		 
        if(!empty($_POST["status"]) and !empty($_POST["focus"])   ){
            $status = $_POST["status"];  
            DB::startTransaction();
					DB::query("SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE");
					DB::update
					('topups', 
						array
						(
							 
                            'pmode' => $status,
                        ),"topid=%i", $_POST['focus']
					);
					
					DB::commit();
                    
                    ?>
						<script>
							window.location = "<?= $base_url?>todaysjobreport";
						</script>
                        <?php
			
			 
			
			 
			 
		 
	}else{

        $end = $parts[1];
		 $parts = explode('/' , $end);

        $command =  $parts[1];
        

        
								 
								  
 
    }
?>
			<!-- Content Wrapper. Contains page content -->
			<div class="content-wrapper">
				 

				<!-- Main content -->
				<section class="content">
					<!-- Default card -->
					<div class="card card-primary">
						<?php
							if($_SESSION["connectedusergroup"] == 1 || $_SESSION["connectedusergroup"] < 6)
							{
						?>
						<div class="card-body">
							<div id="servererrormessage">
							</div>
							
							<?php
								if($err!="")
								{
							?>
							<div class="alert alert-danger alert-dismissable">
								<i class="fa fa-ban"></i>
								<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button><br>
								<?php 
									echo $err; 
								?>
							</div>
							<?php
								}
							?>
							
							<div class="card card-info">
                                <div class="card-header">
                                    <h6 class="card-title"><?= $pagetitle ?></h6>
                                </div>
                                <div class="card-body">
                            
                               
							
							 
								<?php
									if($err=="" )
									{
								?>
								   

                                 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

                                 <div class="form-group  ">
                                 <label for="employee_role">New payment mode</label>
									<select  class="form-control" name="status" id="employee_role" data-placeholder="Choose One">
											 
												
                                    <?php
																		$paymentmodedata = DB::query("SELECT id, payment_name FROM payment_type");
																		
																		foreach ($paymentmodedata as $paymentmode)
																		{
																	?>
																	<option value="<?php echo $paymentmode['id']; ?>"><?php echo $paymentmode['payment_name']; ?></option>
																	<?php
																		}
																	?>
											</select>
										 </div>

                                        
                                                <input type="hidden" name="focus" id="name" maxlength="40" class="form-control" value="<?php echo $command; ?>" >
                                           
                                         
                                         
                                        

                                            <div class="btn-list">
								<div class="text-right">
									<a href="systemusers.php" class="btn btn-danger"><i class="glyphicon glyphicon-remove"></i> Cancel</a>
									
									<button type="submit" name="savedatabtn" id="savedatabtn" class="btn btn-success"><i class="glyphicon glyphicon-floppy-disk"></i> Save</button>
								</div>
							</div>

                                    </form>
								  
								   
                                     

                                </div>
                            </div>
              <!-- /.card-body -->
            </div>
									 
								
								   
								 
										 
								
								
								
								</div>
							</div>
						</div><!-- /.card-body -->
						<?php
							}
							}
							else
							{
						?>
						<div class="alert alert-danger alert-dismissable">
							<i class="fa fa-ban-circle"></i><br>
							Limited Access
						</div>
						<?php
							}
						?>
					</div><!-- /.card -->
				</section><!-- /.content -->
			</div><!-- /.content-wrapper -->
 
		</div><!-- ./wrapper -->
		
		<div class="modal" id="waitdialogmodal"  data-backdrop="static">
            <div class="modal-dialog modal-sm">
              <div class="modal-content">
                  <div class="modal-body">
					<div class="text-center">
						<img src="<?php echo $base_url . $ajax_loading_image; ?>" />
					</div>
				  </div>
              </div>
            </div>
        </div>

		 
	
	
	
	
 <?php include ('includes/general_footer.php')?> 
<script src="js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="tableExport.js"></script>
<script type="text/javascript" src="jquery.base64.js"></script>
<script type="text/javascript" src="html2canvas.js"></script>
<script type="text/javascript" src="jspdf/libs/sprintf.js"></script>
<script type="text/javascript" src="jspdf/jspdf.js"></script>
<script type="text/javascript" src="jspdf/libs/base64.js"></script> 
 <link href="css/datepicker.css" rel="stylesheet">
 
<script>
 
		$(function(){
			 
			$('#from').datepicker();
			$('#to').datepicker();
			 
			 
		});
	</script>

	 
		<script src="plugins/bert/storepos.js" type="text/javascript"></script>
		<script src="plugins/bert/store.js" type="text/javascript"></script>
	</body>
</html>