
<?php
session_start();
error_reporting(0);
@ini_set('display_errors', 0);
$id_user=$_SESSION['id'];
$branch=$_SESSION['branch_id'];
$business=$_SESSION['business_id'];
?>
<!DOCTYPE html>
<html>
    
     <head>
         <?php
    include("../includes/header-links.php");
$permissions = mysqli_fetch_array(mysqli_query($con,"SELECT * FROM  
  permissions,users WHERE  permissions.role_id = users.role 
  AND users.id='$id_user' AND users.business_id ='$business' AND users.branch_id ='$branch'"));

if($permissions['nav_reciepts'] != 1){
?>
<script>window.location="../main/dashboard.php"</script>
<?php
}
?>
    ?>
       
        <!-- Bootstrap -->
        <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
        <link href="../bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
        <link href="../assets/styles.css" rel="stylesheet" media="screen">
        <link href="../assets/DT_bootstrap.css" rel="stylesheet" media="screen">
        <link rel="stylesheet" href="../data-table-css/bootstrap-table.css">
    <link rel="stylesheet" href="../data-table-css/bootstrap-editable.css">
        <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="vendors/flot/excanvas.min.js"></script><![endif]-->
        <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
            <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
        <script src="../vendors/modernizr-2.6.2-respond-1.1.0.min.js"></script>
    </head>
    
    <body>
        <?php include '../includes/header.php'; ?>
        <div class="container-fluid">
            <div class="row-fluid">
                <?php include '../includes/sidebar.php'; ?>
                <!--/span-->
                <div class="span10" id="content">

                     <div class="row-fluid">
                        <!-- block -->
                        <div class="block">
                            <div class="navbar navbar-inner block-header">
                                <div class="muted pull-left">Receipt Options</div>
                            </div>
                            <div class="block-content collapse in">
                                <div class="span12" >
                                   

                                      
												<form action="" method="POST">
                                               
                                                <div class="span10" style="margin: 20px;">
                                                <div class="span5">
												<label style="margin-left: 10px; font-size: 20px;">Print Receipt After Purchase</label>
                                                </div>
                                                  <div class="span5">
												<select name="purchase" class="form-control" style="height: 40px; font-size: 20px;">
                                                <?php
                                                $check1=mysqli_fetch_array(mysqli_query($conn,"SELECT print_after_purchase from receipt_settings where branch_id='$branch'"));
                                                $pvalue=$check1['print_after_purchase'];
                                                if ($pvalue==1) {
                                                   ?>
                                                   <option value="<?php echo $pvalue ?>">Yes</option>
                                                    <option value="0">No</option>
                                                   <?php 
                                                }else{
                                                    ?>
                                                  <option value="0">No</option>
                                                    <option value="1">Yes</option>
                                                    <?php  
                                                }
                                                ?>
                                                    
                                                </select>
                                                  </div>
                                                </div>
                                               
                                               
                                                <div class="span10" style="margin: 20px;">
                                                 <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">Print Receipt After Sale</label>
                                                </div>
                                                 <div class="span5">
                                                <select name="sale" class="form-control" style="height: 40px; font-size: 20px;">
                                                    
                                                    <?php
                                                $check2=mysqli_fetch_array(mysqli_query($conn,"SELECT print_after_sale from receipt_settings where branch_id='$branch'"));
                                                $svalue=$check2['print_after_sale'];
                                                if ($svalue==1) {
                                                   ?>
                                                   <option value="<?php echo $svalue ?>">Yes</option>
                                                    <option value="0">No</option>
                                                   <?php 
                                                }else{
                                                    ?>
                                                  <option value="0">No</option>
                                                    <option value="1">Yes</option>
                                                    <?php  
                                                }
                                                ?>
                                                </select>
                                                </div>
                                                </div>
                                                
                                                <div class="span10" style="margin: 20px;">
                                                <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">Indicate Branch Name on receipt</label>
                                                </div>
                                                 <div class="span5">
                                                <select name="pbranch" class="form-control" style="height: 40px; font-size: 20px;">
                                                    
                                                    <?php
                                                $check3=mysqli_fetch_array(mysqli_query($conn,"SELECT indicate_branch from receipt_settings where branch_id='$branch'"));
                                                $bvalue=$check3['indicate_branch'];
                                                if ($bvalue==1) {
                                                   ?>
                                                   <option value="<?php echo $bvalue ?>">Yes</option>
                                                    <option value="0">No</option>
                                                   <?php 
                                                }else{
                                                    ?>
                                                  <option value="0">No</option>
                                                    <option value="1">Yes</option>
                                                    <?php  
                                                }
                                                ?>
                                                </select>
                                                </div>
												
                                                </div>
                                                <div class="span10" style="margin: 20px;">
                                                <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">Indicate prices inclusive of Vat where Applicable on receipt</label>
                                                </div>
                                                 <div class="span5">
                                                <select name="pvat" class="form-control" style="height: 40px; font-size: 20px;">
                                                    
                                                    <?php
                                            $check4=mysqli_fetch_array(mysqli_query($conn,"SELECT indictate_prices_vat from receipt_settings where branch_id='$branch'"));
                                                $pvvalue=$check4['indictate_prices_vat'];
                                                if ($pvvalue==1) {
                                                   ?>
                                                   <option value="<?php echo $pvvalue ?>">Yes</option>
                                                    <option value="0">No</option>
                                                   <?php 
                                                }else{
                                                    ?>
                                                  <option value="0">No</option>
                                                    <option value="1">Yes</option>
                                                    <?php  
                                                }
                                                ?>
                                                </select>
                                                </div>
                                                
                                                </div>
                                                <div class="span10" style="margin: 20px;">
                                                <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">Indicate goods once Sold Are not returnable on receipt</label>
                                                </div>
                                                 <div class="span5">
                                                <select name="pgood" class="form-control" style="height: 40px; font-size: 20px;">
                                                    
                                                    <?php
                                            $check4=mysqli_fetch_array(mysqli_query($conn,"SELECT indicate_goods_once_sold from receipt_settings where branch_id='$branch'"));
                                                $pgvalue=$check4['indicate_goods_once_sold'];
                                                if ($pgvalue==1) {
                                                   ?>
                                                   <option value="<?php echo $pgvalue ?>">Yes</option>
                                                    <option value="0">No</option>
                                                   <?php 
                                                }else{
                                                    ?>
                                                  <option value="0">No</option>
                                                    <option value="1">Yes</option>
                                                    <?php  
                                                }
                                                ?>
                                                </select>
                                                </div>
                                                
                                                </div>
                                                <?php 
                        if( $permissions['update_reciepts'] == 1){
                            ?>
												<div class="form-actions">
                                          <button type="submit" name="add" class="btn btn-primary" style="height: 60px; font-size: 20px;">Update</button>
                                          
                                        </div>
                                        <?php
                         }
                             ?>	
												</form>
											
										<!--Model Ends here -->
                                  
                                    
                                  
                                    
                                </div>
                            </div>
                        </div>
                        <!-- /block -->
                    </div>
                </div>
            </div>
            <?php


if(isset($_POST['add'])){
    include '../includes/connection.php';
$sale=$_POST['sale'];
$purchase=$_POST['purchase'];
$pbranch=$_POST['pbranch'];
$pvat=$_POST['pvat'];
$pgood=$_POST['pgood'];



    $sql = mysqli_query($conn,"UPDATE receipt_settings SET  print_after_sale='$sale',print_after_purchase='$purchase',indicate_branch='$pbranch', indictate_prices_vat='$pvat',indicate_goods_once_sold='$pgood' where branch_id='$branch'");


if ( $sql) {
    ?>

    <meta http-equiv="refresh" content="0;URL='receipt_settings.php'" />  
    <?php
} else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}

mysqli_close($conn);
}

?>
            <hr>
            <?php include '../includes/footer.php'; ?>
        </div>
        <!--/.fluid-container-->

        <script src="../vendors/jquery-1.9.1.js"></script>
        <script src="../bootstrap/js/bootstrap.min.js"></script>
        <script src="../vendors/datatables/js/jquery.dataTables.min.js"></script>
<script src="../data-table-js/bootstrap-table.js"></script>
    <script src="../data-table-js/tableExport.js"></script>
    <script src="../data-table-js/data-table-active.js"></script>
    <script src="../data-table-js/bootstrap-table-editable.js"></script>
    <script src="../data-table-js/bootstrap-editable.js"></script>
    <script src="../data-table-js/bootstrap-table-resizable.js"></script>
    <script src="../data-table-js/colResizable-1.5.source.js"></script>
    <script src="../data-table-js/bootstrap-table-export.js"></script>

        <script src="../assets/scripts.js"></script>
        <script src="../assets/DT_bootstrap.js"></script>
        <script>
        $(function() {
            
        });
        </script>
    </body>


 
</html>
