
<!DOCTYPE html>
<html>

<head>
   
<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>
    <script type="text/javascript">
function FormatCurrency(ctrl) {
              //Check if arrow keys are pressed - we want to allow navigation around textbox using arrow keys
              if (event.keyCode == 37 || event.keyCode == 38 || event.keyCode == 39 || event.keyCode == 40) {
                  return;
              }

              var val = ctrl.value;

              val = val.replace(/,/g, "")
              ctrl.value = "";
              val += '';
              x = val.split('.');
              x1 = x[0];
              x2 = x.length > 1 ? '.' + x[1] : '';

              var rgx = /(\d+)(\d{3})/;

              while (rgx.test(x1)) {
                  x1 = x1.replace(rgx, '$1' + ',' + '$2');
              }

              ctrl.value = x1 + x2;
          }

          function CheckNumeric() {
              return event.keyCode >= 48 && event.keyCode <= 57 || event.keyCode == 46;
          }
</script>
   <?php
     include '../includes/header.php'; 
     

      
    include '../includes/connection.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 ($business!=0) {
if($permissions['business_id'] != 0){
      ?>
      <script>window.location="../main/dashboard.php"</script>
      <?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">Businesses</div>
                        </div>
                        <div class="block-content collapse in">
                            <div class="span12">
                               
                               
                                        <div class="btn-group" >
                                     <a href="#myModal" data-toggle="modal" class="btn btn-primary"><i class="icon-plus icon-white"></i>&nbsp;Add a new Business</a>
                                  </div>
                                
                                  

                                  <!--Model begins here -->
                                  <div id="myModal" class="modal hide">
                                        <div class="modal-header" style="background: #08c; color: white; text-align: center;">
                                            <button data-dismiss="modal" class="close" type="button">&times;</button>
                                            <h3>Add A New Businness</h3>
                                        </div>
                                        <div class="modal-body">
                                            <form action="" method="POST">
                                            <label style=" font-size: 20px; "> Business Type</label>
                                  <select name="businesstype" id="select02" class="chzn-select"  style="width: 95%; height: 30px; font-size: 20px;" required="required">
                                  <option value="" selected disabled>select Business Type</option>
                                  <option value="0">Retail Or Wholesale</option>
                                  <option value="1">Both Retail And Wholesale</option>
                                  </select>

                                            <label style=" font-size: 20px; ">Business Name</label>
                                            <input type="text" name="business" class="input-xlarge focusedform-control" placeholder="Business Name" required style="width: 95%; height: 30px; font-size: 20px;">
                                            <label style=" font-size: 20px; "> Contact</label>
                                            <input type="number" name="contact" class="form-control" placeholder="phone no" required="required" style="width:  95%; height: 30px; font-size: 20px;"  >
                                            <label style=" font-size: 20px; "> Email</label>
                                      <input type="email" name="email" class="form-control" placeholder="info@info.com" style="width: 95%; height: 30px; font-size: 20px;">
                      
                                   <label style=" font-size: 20px; "> Address</label>
                                  <input type="text" name="address" class="form-control" placeholder="Address"  style="width: 95%; height: 30px; font-size: 20px;">
                    
                                  <label style=" font-size: 20px; "> Location</label>
                                  <select name="country" id="select01" class="chzn-select"  style="width: 95%; height: 30px; font-size: 20px;" required="required">
                                  <option value="" selected disabled>select country</option>
                                  <?php
                                  $sql3 = mysqli_query($con,"select * from countries");
                                  while($row3=mysqli_fetch_array($sql3)){
                                    ?>
                                    <option value="<?php echo$row3['id'];?>"><?php echo$row3['State_or_territory'];?>(<?php echo$row3['CurrencyName'];?>)</option>
                                    <?php
                                  }
                                  ?>
                                  </select>
                    
                                            <div class="span12" >
                                        <div class="span8">
                                      <button type="submit" name="addbusinness" class="btn btn-primary">Save</button>
                                    </div>
                                    <div  class="span4">
                                      <a href="" class="btn btn-danger" data-dismiss="modal">Cancel</a>
                                    </div>  
                                  </div>
                                            </form>
                                        </div>
                                    </div>
                                    <!--Model Ends here -->
                              
                               <?php
include '../includes/connection.php';
                               // Create connection
$sql = mysqli_query($con,"SELECT * FROM business");
//$result = mysqli_query($con, $sql);

if (mysqli_num_rows($sql) > 0) {
// output data of each row



                               ?>
                                
                                <div id="toolbar">
                                    <select class="form-control">
                                            <option value="">Export Basic</option>
                                            <option value="all">Export All</option>
                                            <option value="selected">Export Selected</option>
                                        </select>
                                </div>
                                <table  id="table" data-toggle="table" data-pagination="true" data-search="true" data-show-columns="true" data-show-pagination-switch="true" data-show-refresh="false" data-key-events="true" data-show-toggle="false" data-resizable="false" data-cookie="true"
                                    data-cookie-id-table="saveId" data-show-export="true" data-click-to-select="true" data-toolbar="#toolbar" data-export-options='{"fileName": "Testing_filename"}'>
                                    <thead>
                                        <tr>
                                            <th>No</th>
                                            <th> Name</th>
                                            <th>Contact</th>
                                            <th>Address</th>
                                            <th>Email</th>
                                           
                                            <th>Added By</th>
                                            <th>AddedOn</th>
                                            
                                            <th>Edit</th>
                                            <th>Activate</th>
                                            <th>store</th>
                                      
                                            

                                        </tr>
                                    </thead>
                                    <tbody>
                                    
                                    <?php
                                    $no = 0;
                                    while($row = mysqli_fetch_assoc($sql)) {
                                        $no++;
                                            ?>
                                    <tr class="gradeU">
                                            <td><?php echo $no; ?></td>
                                            <td><?php echo $row['business_name']; ?></td>
                                            <td><?php echo $row['contact']; ?></td>
                                            <td><?php echo $row['location']; ?></td>
                                            <td><?php echo $row['email']; ?></td>
                                            
                                            
                                            
                                            <?php
                                            $uid = $row['recorded_by'];
                                            $sql2 = mysqli_query($con,"select name from users where id='$uid'");
                                            $row2 = mysqli_fetch_array($sql2);
                                            ?>
                                            <td><?php echo $row2['name']; ?></td>
                                            <td><?php echo $row['recorded_on']; ?></td>
                                           
                                            <td class="center">
                                            
                                            <a href="#edit<?php echo $row['business_id']; ?>" data-toggle="modal" ><button class="btn btn-primary"><i class="icon-edit icon-white"></i></button></a>
                                                
                                                
                                                
                                <div id="edit<?php echo $row['business_id']; ?>" class="modal hide">
                                        <div class="modal-header" style="text-align: center; background-color: #08c; color: white;">
                                            <button data-dismiss="modal" class="close" type="button">&times;</button>
                                            <h3>Edit Business Details</h3>
                                        </div>
                                        <div class="modal-body">
                    <?php  
                    $sid=$row['business_id'];
                    $values=mysqli_fetch_array(mysqli_query($con,"SELECT * from business where business_id='$sid'"));
                    $eid=$values['business_id'];
                    
                    $ename=$values['business_name'];
                    $econtact=$values['contact'];
                    $eemail=$values['email'];
                    $eaddress=$values['location'];
                    $ctry=$values['Country'];
                    $btype=$values['type'];

                    
                    ?>
                                            <form action="" method="POST">
                      <input type="hidden" name="editid" value="<?php echo $eid;?>">
                      <label style=" font-size: 20px; "> Business Type</label>
                                  <select name="businesstypee" id="seff" class="chzn-select"  style="width: 95%; height: 30px; font-size: 20px;" required="required">
                                  <?php
                                  if ($btype==1) {
                                                   ?>
                                                   <option value="<?php echo $btype ?>">Both Retail And Wholesale</option>
                                                    <option value="0">Retail Or Wholesale</option>
                                                   <?php 
                                                }else{
                                                    ?>
                                                  <option value="0">Retail Or Wholesale</option>
                                                    <option value="1">Both Retail And Wholesale</option>
                                                    <?php  
                                                }
                                                ?>
                                  ?>
                                  
                                  </select>
                    <label style=" font-size: 20px; ">Business Name</label>
                    <input type="text" name="ename" value="<?php echo $ename;?>" class="input-xlarge focusedform-control"  required style="width: 
                    95%; height: 30px; font-size: 20px;">
                    <label style=" font-size: 20px; "> Contact</label>
                    <input type="number" name="econtact" value="0<?php echo $econtact;?>"  required="required" style="width: 
                    95%; height: 30px; font-size: 20px;" minlength="9" maxlength="10">
                    
                    <label style=" font-size: 20px; " > Email</label>
                    <input type="email" name="eemail" value="<?php echo $eemail;?>" style="width: 
                    95%; height: 30px; font-size: 20px;">
                    <label style=" font-size: 20px; "> Address</label>
                    <input type="text" value="<?php echo $eaddress;?>" name="eaddress" class="form-control"  style="width: 
                    95%; height: 30px; font-size: 20px;">
                    <label style=" font-size: 20px; "> Location</label>
                                  <select name="ecountry" id="select01" class="chzn-select"  style="width: 95%; height: 30px; font-size: 20px;">
                                  <?php
                                   $sql33 = mysqli_fetch_array(mysqli_query($con,"select * from countries where id='$ctry'"));
                                   ?>
                                  <option value="<?php echo $ctry;?>" selected ><?php echo$sql33['State_or_territory'];?>(<?php echo$sql33['CurrencyName'];?>)</option>
                                  <?php
                                  $sql54 = mysqli_query($con,"select * from countries");
                                  while($row3=mysqli_fetch_array($sql54)){
                                    ?>
                                    <option value="<?php echo$row3['id'];?>"><?php echo$row3['State_or_territory'];?>(<?php echo$row3['CurrencyName'];?>)</option>
                                    <?php
                                  }
                                  ?>
                                  </select>
                    <div class="span12" >
                      <div class="span8">
                                      <button type="submit" name="save" class="btn btn-primary">Save </button>
                                    </div>
                                     
                                  </div>
                    </form>

                                        </div>
                                        <div class="modal-footer">
                                            
                                            <a data-dismiss="modal" class="btn btn-warning" href="#">cancel</a>
                                        </div>
                                    </div>
                                        
                                            </td>
                                            <?php 
    $sus=$row['status'];
if ($sus==0) {
   ?>
   <td><a onclick = "confirmationReturn(this); return false;" href="activate_business.php?business_id=<?php echo $row['business_id']; ?>"><button class="btn btn-warning"><i class="icon-ok icon-white"></i>Activate</button></a>
</td>
   <?php
}else{
  ?>
  <td><a onclick = "confirmationSuspend(this); return false;" href="deactivate_business.php?business_id=<?php echo $row['business_id']; ?>"><button class="btn btn-info"><i class="icon-plane icon-white"></i>Deactivate</button></a>
</td>
  <?php
}
?> 
<?php 
    $stos=$row['store'];
if ($stos==0) {
   ?>
   <td><a onclick = "confirmationReturnstore(this); return false;" href="activate_store.php?business_id=<?php echo $row['business_id']; ?>"><button class="btn btn-warning"><i class="icon-ok icon-white"></i>Activate Store</button></a>
</td>
   <?php
}else{
  ?>
  <td><a onclick = "confirmationSuspendstore(this); return false;" href="deactivate_store.php?business_id=<?php echo $row['business_id']; ?>"><button class="btn btn-info"><i class="icon-plane icon-white"></i>Deactivate Store</button></a>
</td>
  <?php
}
?> 
<?php 
    $sempts=$row['empties'];
if ($sempts==0) {
   ?>
   <td><a onclick = "confirmationReturnempties(this); return false;" href="activate_empties.php?business_id=<?php echo $row['business_id']; ?>"><button class="btn btn-warning"><i class="icon-ok icon-white"></i>Activate Empties</button></a>
</td>
   <?php
}else{
  ?>
  <td><a onclick = "confirmationSuspendempties(this); return false;" href="deactivate_empties.php?business_id=<?php echo $row['business_id']; ?>"><button class="btn btn-info"><i class="icon-plane icon-white"></i>Deactivate Empties</button></a>
</td>
  
                                           

                                            <?php } ?>
                                        </tr>
                                        
                                        <?php


}
} else {
echo "<h4 style='color:red;'>0 results</h4>";
}

mysqli_close($con);


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

    <!--==========Footer js======-->
    <?php require_once("../includes/footerjs.php");?>
    <!--==========Footer js======-->
<script type = "text/javascript">
function confirmationDelete(anchor){
    var conf = confirm("Are you sure you want to delete this Businness?");
    if(conf){
        window.location = anchor.attr("href");
    }
} 
function confirmationSuspend(anchor){
    var conf1 = confirm("Are you sure you want to Deactivate this Business?");
    if(conf1){
        window.location = anchor.attr("href");
    }
}  
function confirmationReturn(anchor){
    var conf2 = confirm("Are you sure you want to Activate this Business?");
    if(conf2){
        window.location = anchor.attr("href");
    }
}  
function confirmationReturnstore(anchor){
    var conf1s = confirm("Are you sure you want to Activate this business's Store?");
    if(conf1s){
        window.location = anchor.attr("href");
    }
}
function confirmationSuspendstore(anchor){
    var conf2s = confirm("Are you sure you want to Deactivate this Business's Store?");
    if(conf2s){
        window.location = anchor.attr("href");
    }
}  

function confirmationReturnempties(anchor){
    var conf1s = confirm("Are you sure you want to Activate this business's Empties Management?");
    if(conf1s){
        window.location = anchor.attr("href");
    }
}
function confirmationSuspendempties(anchor){
    var conf2s = confirm("Are you sure you want to Deactivate this Business's Empties Management?");
    if(conf2s){
        window.location = anchor.attr("href");
    }
}  
</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>

<link href="../vendors/uniform.default.css" rel="stylesheet" media="screen">
<link href="../vendors/chosen.min.css" rel="stylesheet" media="screen">
<script src="../vendors/chosen.jquery.min.js"></script>
<script>

$(function() {
            $(".datepicker").datepicker();
            $(".uniform_on").uniform();
            $(".chzn-select").chosen();
            $(".chzn-select1").chosen();
            $('.textarea').wysihtml5();

            $('#rootwizard').bootstrapWizard({onTabShow: function(tab, navigation, index) {
                var $total = navigation.find('li').length;
                var $current = index+1;
                var $percent = ($current/$total) * 100;
                $('#rootwizard').find('.bar').css({width:$percent+'%'});
                // If it's the last tab then hide the last button and show the finish instead
                if($current >= $total) {
                    $('#rootwizard').find('.pager .next').hide();
                    $('#rootwizard').find('.pager .finish').show();
                    $('#rootwizard').find('.pager .finish').removeClass('disabled');
                } else {
                    $('#rootwizard').find('.pager .next').show();
                    $('#rootwizard').find('.pager .finish').hide();
                }
            }});
            $('#rootwizard .finish').click(function() {
                alert('Finished!, Starting over!');
                $('#rootwizard').find("a[href*='tab1']").trigger('click');
            });
        });
        </script>
</body>

<?php


if(isset($_POST['addbusinness'])){
include '../includes/connection.php';
$businnessname=mysqli_real_escape_string($con,ucwords($_POST['business']));
$contact=mysqli_real_escape_string($con,$_POST['contact']);
// $contact=substr($contact1, -9);
$address=mysqli_real_escape_string($con,ucwords($_POST['address']));
$email=mysqli_real_escape_string($con,$_POST['email']);
$country=mysqli_real_escape_string($con,$_POST['country']);
$type=$_POST['businesstype'];

$id_user=$_SESSION['id'];

$sql0 = mysqli_query($con,"SELECT * from business where business_name='$businnessname' && location='$address'") or die(mysqli_error($con));
$num0 = mysqli_num_rows($sql0);
if($num0>0){
echo"<script>alert('Failed. Businnes with name $businnessname and location $address already exists. Correct your inputs'),history.go(-1)</script>";
}
else{
$sql = mysqli_query($con,"INSERT INTO business (business_name, contact,location,country,email, recorded_by,type)
VALUES ('$businnessname', '$contact','$address','$country','$email','$id_user','$type')");

if ($sql) {
  $last_id = mysqli_insert_id($con);
  $sqlb=mysqli_query($con, "INSERT INTO permissions(role,branch_id,business_id,added_by,view_stock,view_products,add_stock, spoilt_stock,new_product,view_reconcile_stock,edit_stock,add_product,product_stock,view_product_categories,edit_product,delete_product,add_product_category,edit_product_category,delete_product_category,view_purchase,view_sales,view_customer_balance, view_untaken_orders,view_pending_payments,add_order,edit_order,delete_order,process_order,view_sales_report,filter_sales_report,sales_report_branch,export_excel,view_sales_report_total_sales,print_sales_reciept,sales_return_button,view_individual_product_sales, filter_individual_product_sales,view_debtors_report,view_expenses,add_expense, view_expense_categories,view_expense_Report,view_expense_branch,add_expense_categories,edit_expense_catgeories, delete_expense_catgeories,view_purchases_report,filter_purchases_report,purchases_return_button,new_purchases,purchase_report_branch,view_individaul_product_purchases,  filter_individual_product_purchases,new_individual_product_purchases,view_creditors_report,export_creditors_report,creditors_pay_button,  view_payment_report,filter_payment_report,view_voucher,export_payment_reports,view_paymentlogs_branch,view_transactions_report, filter_transactions_reports,export_transaction_reports,transactions_branch,view_profit_analysis,profit_analysis_by_graph, profit_analysis_by_table,profit_analysis_details,filter_profit_analysis,view_sales_analysis,view_sales_analysis_by_Graph,sales_by_table,  filter_sales_analysis,sales_analysis_details,view_cash_analysis,cash_out,filter_cash_out,edit_cash_out,cashout_export,add_cash_out,cashout_branch,cashout_action,cash_at_hand_amount,cash_at_hand,export_cash_at_hand,view_short_expiries,mark_as_expired,  edit_short_expires,export_short_expires,view_logs,view_business,view_users,view_dashboard,view_dashboard_business_summary,view_dashboard_creditors,dashboard_new_orders,dashboard_managment_stock,dash_mahange_expense,most_demanded_prod_graph,sales_summary_graph,view_notification,view_settings,nav_settings_business,nav_settings_branch,view_add_new_branch,view_export_branches, view_branch_action,view_branch_activate,view_advanced,view_accounts,nav_users,add_user,edit_user,suspend_user,delete_user,Return_user,  view_users_branch,nav_suppliers,add_supllier,edit_supplier,suspend_supplier,delete_supplier,supplier_branch,nav_products,products_admin_branch,nav_units,add_unit,edit_unit,delete_unit,units_branch,view_staff,staff_branch,set_staff_role,add_staff,edit_staff,delete_staff,suspend_staff,nav_reciepts,update_reciepts,nav_advanced,view_product_arrangment,nav_settings_store,nav_add_to_store,edit_store_quantity,store_logs,nav_settings_empties,empties_customer,empties_categories,export_crates,add_taken_crates,nav_settings_exchange_rate,other_settings,update_prod_arrangment,save_other_settings,view_daily_summary,total_sales,total_sales_details,credit_sales,credit_sales_details,credits_paid,credits_paid_details,expenses,dash_expense_details,dash_cash_at_hand,dash_cash_at_hand_details,view_general_summary,view_stock_value,view_stock_value_details,stock_value_details,dash_creditors,creditors_details,dash_instock,dash_instock_details,dash_out_of_stock,dash_out_of_stock_details,view_permissions) VALUES('Super admin',0,'$last_id','$id_user',1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)");
//  if(!$sqlb){
// mysqli_error($con)
//  }


$id_user=$_SESSION['id'];
$activity="Added a new Businnes ".$businnessname." with a contact: ".$contact." and email: ".$email;
$log_sql=mysqli_query($con,"INSERT INTO logs(user_id, activity) VALUES 
('$id_user','$activity')");

echo "<script>
alert('Businnes $businnessname with contact $contact and email $email has been recorded successfully');
window.location='business.php'
</script>";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($con);
}
}
mysqli_close($con);
}

?>

<?php

if(isset($_POST['save'])){
include '../includes/connection.php';
$editid=$_POST['editid'];
$ename=mysqli_real_escape_string($con,ucwords($_POST['ename']));
$econtact=mysqli_real_escape_string($con,$_POST['econtact']);
// $econtact=substr($econtact1, -9);
$eaddress=mysqli_real_escape_string($con,ucwords($_POST['eaddress']));
$eemail=mysqli_real_escape_string($con,$_POST['eemail']);
$ecountry=mysqli_real_escape_string($con,$_POST['ecountry']);
$etype=$_POST['businesstypee'];

$id_user=$_SESSION['id'];
//$time = date("Y-m-d: H:i:s");
$esql0 = mysqli_query($con,"SELECT * from business where business_name='$ename' && location='$eaddress' && business_id !='$editid'");
$enum0 = mysqli_num_rows($esql0);
if($enum0>0){
echo"<script>alert('Failed. Business with Name $ename and location $eaddress  already exists')</script>";
}
else{
$esql = mysqli_query($con,"UPDATE  business set business_name='$ename', contact='$econtact',location='$eaddress',email='$eemail',Country='$ecountry',type='$etype' where business_id='$editid'");
if ($esql) {


$id_user=$_SESSION['id'];
$eactivity="Updated Details of Business ".$ename." with a contact: ".$econtact." and email: ".$eemail;
$elog_sql=mysqli_query($con,"INSERT INTO logs(user_id, activity) VALUES 
('$id_user','$eactivity')");

echo "<script>
alert('Business $ename with contact $econtact and email $eemail has been updated successfully');
window.location='business.php'
</script>";
} else {
echo "Error: " . $esql . "<br>" . mysqli_error($con);
}
}
mysqli_close($con);
}

?>

</html>

