
<?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['other_settings'] != 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">Products arrangement</div>
                            </div>
                            <div class="block-content collapse in">
                                <div class="span12" >
                                   
                                            <?php
                                                $sql_business_settings=mysqli_fetch_array(mysqli_query($conn,"SELECT * from business_settings where branch_id='$branch' && business_id='$business'"));
                                                   ?>
                                      
												<form action="" method="POST">
                                               
                                           <div class="span10" style="margin: 20px;">
                                                <div class="span5">
												<label style="margin-left: 10px; font-size: 20px;">Allow Back dating of Sales</label>
                                                </div>
                                                <div class="span5">
    												<select name="back_date_sales" class="form-control" style="height: 40px; font-size: 20px; width: 100%">
                                                        <?php
                                                        if ($sql_business_settings['back_date_sales']==0) {
                                                            ?>
                                                            <option value="0">No</option>
                                                            <option value="1">Yes</option>
                                                            <?php
                                                            
                                                        }else{
                                                            ?>
                                                            <option value="1">Yes</option>
                                                            <option value="0">No</option>
                                                            <?php
                                                        }
                                                        ?>
                                                      

                                                     </select>
                                                  </div>
                                                </div>
                                           
                                           <div class="span10" style="margin: 20px;">

                                                <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">Allow Back dating of Purchases</label>
                                                </div>

                                                <div class="span5">
                                                    <select name="back_date_purchases" class="form-control" style="height: 40px; font-size: 20px; width: 100%">
                                                        <?php
                                                        if ($sql_business_settings['back_date_purchases']==0) {
                                                            ?>
                                                            <option value="0">No</option>
                                                            <option value="1">Yes</option>
                                                            <?php
                                                            
                                                        }else{
                                                            ?>
                                                            <option value="1">Yes</option>
                                                            <option value="0">No</option>
                                                            <?php
                                                        }
                                                        ?>
                                                      

                                                    </select>
                                                  </div>
                                                </div>


                                            <div class="span10" style="margin: 20px;">
                                                <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">Allow Products Without stock</label>
                                                </div>
                                                <div class="span5">
                                                    <select name="include_services" class="form-control" style="height: 40px; font-size: 20px; width: 100%">
                                                        <?php
                                                        if ($sql_business_settings['include_services']==0) {
                                                            ?>
                                                            <option value="0">No</option>
                                                            <option value="1">Yes</option>
                                                            <?php
                                                            
                                                        }else{
                                                            ?>
                                                            <option value="1">Yes</option>
                                                            <option value="0">No</option>
                                                            <?php
                                                        }
                                                        ?>
                                                      

                                                     </select>
                                                  </div>
                                            </div>
                                            <div class="span10" style="margin: 20px;">
                                                <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">Allow Reserve Prices For Products</label>
                                                </div>
                                                <div class="span5">
                                                    <select name="inlude_reserve_prices" class="form-control" style="height: 40px; font-size: 20px; width: 100%">
                                                        <?php
                                                if ($sql_business_settings['inlude_reserve_prices']==0) {
                                                            ?>
                                                            <option value="0">No</option>
                                                            <option value="1">Yes</option>
                                                            <?php
                                                            
                                                        }else{
                                                            ?>
                                                            <option value="1">Yes</option>
                                                            <option value="0">No</option>
                                                            <?php
                                                        }
                                                        ?>
                                                      

                                                     </select>
                                                  </div>
                                            </div>
                                            <div class="span10" style="margin: 20px;">
                                                <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">Allow Sales Order Invoices</label>
                                                </div>
                                                <div class="span5">
                                                    <select name="allow_orders_withoutpay" class="form-control" style="height: 40px; font-size: 20px; width: 100%">
                                                        <?php
                                                if ($sql_business_settings['allow_orders_withoutpay']==0) {
                                                            ?>
                                                            <option value="0">No</option>
                                                            <option value="1">Yes</option>
                                                            <?php
                                                            
                                                        }else{
                                                            ?>
                                                            <option value="1">Yes</option>
                                                            <option value="0">No</option>
                                                            <?php
                                                        }
                                                        ?>
                                                      

                                                     </select>
                                                  </div>
                                            </div>
                                            <div class="span10" style="margin: 20px;">
                                                <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">Print Bills for Customers </label>
                                                </div>
                                                <div class="span5">
                                                    <select name="print_order_bills" class="form-control" style="height: 40px; font-size: 20px; width: 100%">
                                                        <?php
                                                        if ($sql_business_settings['print_order_bills']==0) {
                                                            ?>
                                                            <option value="0">No</option>
                                                            <option value="1">Yes</option>
                                                            <?php
                                                            
                                                        }else{
                                                            ?>
                                                            <option value="1">Yes</option>
                                                            <option value="0">No</option>
                                                            <?php
                                                        }
                                                        ?>
                                                      

                                                     </select>
                                                  </div>
                                            </div>
                                            <div class="span10" style="margin: 20px;">
                                                <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">Include VAT legibility On products </label>
                                                </div>
                                                <div class="span5">
                                                    <select name="vat_legibility" class="form-control" style="height: 40px; font-size: 20px; width: 100%">
                                                        <?php
                                                        if ($sql_business_settings['vat_legibility']==0) {
                                                            ?>
                                                            <option value="0">No</option>
                                                            <option value="1">Yes</option>
                                                            <?php
                                                            
                                                        }else{
                                                            ?>
                                                            <option value="1">Yes</option>
                                                            <option value="0">No</option>
                                                            <?php
                                                        }
                                                        ?>
                                                      

                                                     </select>
                                                  </div>
                                            </div>
                                            <div class="span10" style="margin: 20px;">
                                                <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">Select Staff When selling </label>
                                                </div>
                                                <div class="span5">
                                                    <select name="select_staff_onsale" class="form-control" style="height: 40px; font-size: 20px; width: 100%">
                                                        <?php
                                                        if ($sql_business_settings['select_staff_onsale']==0) {
                                                            ?>
                                                            <option value="0">No</option>
                                                            <option value="1">Yes</option>
                                                            <?php
                                                            
                                                        }else{
                                                            ?>
                                                            <option value="1">Yes</option>
                                                            <option value="0">No</option>
                                                            <?php
                                                        }
                                                        ?>
                                                      

                                                     </select>
                                                  </div>
                                            </div>
                                            
                                            <div class="span10" style="margin: 20px;">
                                                <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">Record Customers </label>
                                                </div>
                                                <div class="span5">
                                                    <select name="record_customers" class="form-control" style="height: 40px; font-size: 20px; width: 100%">
                                                        <?php
                                                        if ($sql_business_settings['record_customers']==0) {
                                                            ?>
                                                            <option value="0">No</option>
                                                            <option value="1">Yes</option>
                                                            <?php
                                                            
                                                        }else{
                                                            ?>
                                                            <option value="1">Yes</option>
                                                            <option value="0">No</option>
                                                            <?php
                                                        }
                                                        ?>
                                                      

                                                     </select>
                                                  </div>
                                            </div>
                                            <div class="span10" style="margin: 20px;">
                                                <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">Indicate Product Batch Numbers On Purchase </label>
                                                </div>
                                                <div class="span5">
                                                    <select name="add_batchnumber_onpurchase" class="form-control" style="height: 40px; font-size: 20px; width: 100%">
                                                        <?php
                                                       if ($sql_business_settings['add_batchnumber_onpurchase']==0) {
                                                            ?>
                                                            <option value="0">No</option>
                                                            <option value="1">Yes</option>
                                                            <?php
                                                            
                                                        }else{
                                                            ?>
                                                            <option value="1">Yes</option>
                                                            <option value="0">No</option>
                                                            <?php
                                                        }
                                                        ?>
                                                      

                                                     </select>
                                                  </div>
                                            </div>
                                            <div class="span10" style="margin: 20px;">
                                                <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">Indicate Product Expiry Date On Purchase </label>
                                                </div>
                                                <div class="span5">
                                                    <select name="add_expirydate_onpurchase" class="form-control" style="height: 40px; font-size: 20px; width: 100%">
                                                        <?php
                                                   if ($sql_business_settings['add_expirydate_onpurchase']==0) {
                                                            ?>
                                                            <option value="0">No</option>
                                                            <option value="1">Yes</option>
                                                            <?php
                                                            
                                                        }else{
                                                            ?>
                                                            <option value="1">Yes</option>
                                                            <option value="0">No</option>
                                                            <?php
                                                        }
                                                        ?>
                                                      

                                                     </select>
                                                  </div>
                                            </div>
                                            <div class="span10" style="margin: 20px;">
                                                <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">Indicate Supplier When Purchasing </label>
                                                </div>
                                                <div class="span5">
                                                    <select name="indicate_supplier_onpurchase" class="form-control" style="height: 40px; font-size: 20px; width: 100%">
                                                        <?php
                                                       if ($sql_business_settings['indicate_supplier_onpurchase']==0) {
                                                            ?>
                                                            <option value="0">No</option>
                                                            <option value="1">Yes</option>
                                                            <?php
                                                            
                                                        }else{
                                                            ?>
                                                            <option value="1">Yes</option>
                                                            <option value="0">No</option>
                                                            <?php
                                                        }
                                                        ?>
                                                      

                                                     </select>
                                                  </div>
                                            </div>
                                            <div class="span10" style="margin: 20px;">
                                                <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">Set default amount paid equal to total bill on sale </label>
                                                </div>
                                                <div class="span5">
                                                    <select name="sale_amount_paid" class="form-control" style="height: 40px; font-size: 20px; width: 100%">
                                                        <?php
                                                       if ($sql_business_settings['sale_amount_paid']==0) {
                                                            ?>
                                                            <option value="0">No</option>
                                                            <option value="1">Yes</option>
                                                            <?php
                                                            
                                                        }else{
                                                            ?>
                                                            <option value="1">Yes</option>
                                                            <option value="0">No</option>
                                                            <?php
                                                        }
                                                        ?>
                                                      

                                                     </select>
                                                  </div>
                                            </div>
                                            <div class="span10" style="margin: 20px;">
                                                <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">Record Invoice number When recording purchases </label>
                                                </div>
                                                <div class="span5">
                                                    <select name="record_invoice_number" class="form-control" style="height: 40px; font-size: 20px; width: 100%">
                                                        <?php
                                                       if ($sql_business_settings['record_invoice_number']==0) {
                                                            ?>
                                                            <option value="0">No</option>
                                                            <option value="1">Yes</option>
                                                            <?php
                                                            
                                                        }else{
                                                            ?>
                                                            <option value="1">Yes</option>
                                                            <option value="0">No</option>
                                                            <?php
                                                        }
                                                        ?>
                                                      

                                                     </select>
                                                  </div>
                                            </div>

                                            <div class="span10" style="margin: 20px;">
                                                <div class="span5">
                                                <label style="margin-left: 10px; font-size: 20px;">View Shifts Report</label>
                                                </div>
                                                <div class="span5">
                                                    <select name="view_shifts_report" class="form-control" style="height: 40px; font-size: 20px; width: 100%">
                                                        <?php
                                                       if ($sql_business_settings['view_shifts_report']==0) {
                                                            ?>
                                                            <option value="0">No</option>
                                                            <option value="1">Yes</option>
                                                            <?php
                                                            
                                                        }else{
                                                            ?>
                                                            <option value="1">Yes</option>
                                                            <option value="0">No</option>
                                                            <?php
                                                        }
                                                        ?>
                                                      

                                                     </select>
                                                  </div>
                                            </div>
                                               
                                                 <?php 
                        if( $permissions['save_other_settings'] == 1){
                            ?>
												<div class="form-actions">
                                                  <button type="submit" name="add" class="btn btn-primary" style="height: 60px; font-size: 20px;">Save Changes</button>
                                                  
                                                </div>
                                                 <?php
                         }
                             ?>	
												</form>
											
										<!--Model Ends here -->
                                  
                                    
                                  
                                    
                                </div>
                            </div>
                        </div>
                        <!-- /block -->
                    </div>
                </div>
            </div>
            <?php


if(isset($_POST['add'])){
    include '../includes/connection.php';

$back_date_sales=$_POST['back_date_sales'];
$back_date_purchases=$_POST['back_date_purchases'];
$include_services=$_POST['include_services'];
$inlude_reserve_prices=$_POST['inlude_reserve_prices'];
$print_order_bills=$_POST['print_order_bills'];
$allow_orders_withoutpay=$_POST['allow_orders_withoutpay'];
$vat_legibility=$_POST['vat_legibility'];
$select_staff_onsale=$_POST['select_staff_onsale'];
$record_customers=$_POST['record_customers'];
$add_batchnumber_onpurchase=$_POST['add_batchnumber_onpurchase'];
$add_expirydate_onpurchase=$_POST['add_expirydate_onpurchase'];
$indicate_supplier_onpurchase=$_POST['indicate_supplier_onpurchase'];
$sale_amount_paid=$_POST['sale_amount_paid'];
$record_invoice_number=$_POST['record_invoice_number'];
$view_shifts_report=$_POST['view_shifts_report'];




    $sql = mysqli_query($conn,"UPDATE business_settings SET back_date_sales='$back_date_sales',back_date_purchases='$back_date_purchases',include_services='$include_services',inlude_reserve_prices='$inlude_reserve_prices',print_order_bills='$print_order_bills',allow_orders_withoutpay='$allow_orders_withoutpay',vat_legibility='$vat_legibility',select_staff_onsale='$select_staff_onsale',record_customers='$record_customers',add_batchnumber_onpurchase='$add_batchnumber_onpurchase',add_expirydate_onpurchase='$add_expirydate_onpurchase',indicate_supplier_onpurchase='$indicate_supplier_onpurchase',sale_amount_paid='$sale_amount_paid',record_invoice_number='$record_invoice_number',view_shifts_report='$view_shifts_report' where branch_id='$branch'");


if ( $sql) {
    ?>

    <meta http-equiv="refresh" content="0;URL='general_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>
