<?php
ini_set('display_errors', 0);
//error_reporting(E_ALL);
//ini_set('display_errors', 1);

session_start();
ob_start();

require_once('configuration/server_connect.php');
require_once('configuration/all_function.php');

$active_id=$_REQUEST['active_id'];
$menu_id=$_REQUEST['menu_id'];

//do_calander('#jv_date');
// Common Information

$page_title="Receive Payment";
$page="44_customer_receive_group.php?active_id=".$active_id."&menu_id=".$menu_id."";
$table='journal_master';	
$unique='jv_no';

  $acc_reference = $_POST['acc_reference'];

  $reference=explode(' :: ',$acc_reference);
   $customer_group=$reference[0];
  
 
 
// End Common Information

if(isset($_POST['confirm_data']))

{
//$_POST['entry_by'] = $_SESSION['user']['id'];
$status='CHECKED';
$entry_by =  $_SESSION['user']['id'];
$entry_at = $now=date('Y-m-d H:i:s');
$group_for = $_SESSION['user']['group'];
$ref_no=$_POST['ref_no'];
$customer_group=$_POST['customer_group'];
$jv_date=$_POST['jv_date'];

$jv_type=1;
$jv_special=1;

$jv_title=find_a_field($conn,'journal_type','jv_title','id="'.$jv_type.'"');

		$YR = date('Y',strtotime($jv_date));
 		$year = date('y',strtotime($jv_date));
  		$month = date('m',strtotime($jv_date));
 		$inv_cy_id = find_a_field($conn,'journal_master','max(jv_id)','year="'.$YR.'" and jv_type="'.$jv_type.'"')+1;
  		$cy_id = sprintf("%06d", $inv_cy_id);
   		$jv_no=''.$year.''.$month.''.$jv_type.''.$cy_id;
		$view_jv_no=$jv_title.''.$year.''.$month.''.$jv_type.''.$cy_id;
		
$master_ledger_id=$_POST['master_ledger_id'];
$remarks = $_POST['remarks'];
$tr_from='Receipt';
 	
$config_sql="SELECT * FROM config_ledger  WHERE group_for='".$group_for."'";
$config_data = find_all_field_sql($conn,$config_sql);

  $ins_sql = 'INSERT INTO  journal_master (jv_no, year, jv_id, view_jv_no, jv_type, jv_date, group_for, master_ledger_id, tr_from, remarks, status, entry_at, entry_by, ref_no, jv_special) VALUES

("'.$jv_no.'", "'.$YR.'", "'.$cy_id.'", "'.$view_jv_no.'", "'.$jv_type.'", "'.$jv_date.'", "'.$group_for.'", "'.$master_ledger_id.'", "'.$tr_from.'", "'.$remarks.'", "'.$status.'", "'.$entry_at.'", "'.$entry_by.'", "'.$customer_group.'", "'.$jv_special.'")';
	
mysqli_query($conn,$ins_sql);


$sql = 'select m.jv_no, m.view_jv_no, m.jv_date, r.ref_no, r.ledger_id  from journal_master m, accounts_reference r
where  m.ref_no=r.ref_no and r.customer_group="'.$customer_group.'" and m.tr_from in ("Sales", "Opening", "Journal") and m.jv_special=1  group by m.jv_no order by m.jv_date, m.jv_no';
$query = mysqli_query($conn,$sql);
while ($data = mysqli_fetch_object($query)) {

if($_POST['all_tot_amt_'.$data->jv_no]>0)
{
$inv_note= $_POST['inv_note_'.$data->jv_no];
$ledger_id= $_POST['ledger_id_'.$data->jv_no];
$tds_amt= $_POST['tds_amt_'.$data->jv_no];
$vds_amt= $_POST['vds_amt_'.$data->jv_no];
$commission_amt= $_POST['commission_amt_'.$data->jv_no];
$discount_amt= $_POST['discount_amt_'.$data->jv_no];
$receipt_amt= $_POST['receipt_amt_'.$data->jv_no];
$advance_amt= $_POST['advance_amt_'.$data->jv_no];
$other_income= $_POST['other_income_'.$data->jv_no];
$total_rec_amt= $tds_amt+$vds_amt+$commission_amt+$discount_amt+$receipt_amt;
$cash_receive_amt= $receipt_amt+$advance_amt+$other_income;
$net_receipt_amt +=$cash_receive_amt;


$ins_sqljv = 'INSERT INTO  journal_receive_payment (jv_no, jv_date, ledger_id, ref_no, discount_amt, receive_amt, dr_amt, cr_amt, tr_from, tr_no, tr_date, tr_id, group_for, status, entry_by, entry_at, tds_amt, vds_amt, commission_amt, advance_amt, other_income, inv_note) VALUES

("'.$jv_no.'", "'.$jv_date.'", "'.$ledger_id.'", "'.$data->ref_no.'",  "'.$discount_amt.'",  "'.$receipt_amt.'",  "'.$dr_amt.'", "'.$total_rec_amt.'", "'.$tr_from.'", "'.$data->jv_no.'", "'.$data->jv_date.'", "'.$tr_id.'", "'.$group_for.'", "'.$status.'", "'.$entry_by.'", "'.$entry_at.'", "'.$tds_amt.'", "'.$vds_amt.'", "'.$commission_amt.'", "'.$advance_amt.'", "'.$other_income.'", "'.$inv_note.'")';
	
mysqli_query($conn,$ins_sqljv);

$ins_id=mysqli_insert_id($conn);

$rec_note=$data->view_jv_no.' '.$inv_note;

add_to_sec_journal($conn, $jv_no, $jv_date, $ledger_id, $data->ref_no, $rec_note, $dr_amt, $total_rec_amt, $tr_from, $data->jv_no, $master_ledger_id, $cc_code, $ins_id, $group_for, $status, $entry_by, $entry_at);

if($tds_amt>0) {
add_to_sec_journal($conn, $jv_no, $jv_date, $config_data->tds_ledger, $data->ref_no, $data->view_jv_no, $tds_amt, $cr_amt,  $tr_from, $data->jv_no, '0', $cc_code, $ins_id, $group_for, $status, $entry_by, $entry_at);
}

if($vds_amt>0) {
add_to_sec_journal($conn, $jv_no, $jv_date, $config_data->vds_ledger, $data->ref_no, $data->view_jv_no, $vds_amt, $cr_amt,  $tr_from, $data->jv_no, '0', $cc_code, $ins_id, $group_for, $status, $entry_by, $entry_at);
}

if($commission_amt>0) {
add_to_sec_journal($conn, $jv_no, $jv_date, $config_data->commission_ledger, $data->ref_no, $data->view_jv_no, $commission_amt, $cr_amt,  $tr_from, $data->jv_no, '0', $cc_code, $ins_id, $group_for, $status, $entry_by, $entry_at);
}

if($discount_amt>0) {
add_to_sec_journal($conn, $jv_no, $jv_date, $config_data->discount_ledger, $data->ref_no, $data->view_jv_no, $discount_amt, $cr_amt,  $tr_from, $data->jv_no, '0', $cc_code, $ins_id, $group_for, $status, $entry_by, $entry_at);
}

if($advance_amt>0) {
add_to_sec_journal($conn, $jv_no, $jv_date, $config_data->sales_advance, $data->ref_no, 'Advance Received', $dr_amt, $advance_amt,  $tr_from, $data->jv_no, '0', $cc_code, $ins_id, $group_for, $status, $entry_by, $entry_at);
}

if($other_income>0) {
add_to_sec_journal($conn, $jv_no, $jv_date, $config_data->other_income, $data->ref_no, $data->view_jv_no, $dr_amt, $other_income,  $tr_from, $data->jv_no, '0', $cc_code, $ins_id, $group_for, $status, $entry_by, $entry_at);
}

}	
}

$narration='Receive Payment';

$total_amt=$net_receipt_amt;

if($total_amt>0){
add_to_sec_journal($conn, $jv_no, $jv_date, $master_ledger_id, $ref_no, $narration,  $total_amt,  $cr_amt,  $tr_from,  $jv_no, $ledger_id, $cc_code,  $tr_id,  $group_for,  $status,  $entry_by,  $entry_at);
}



$jv_approval = find_a_field($conn,'journal_type','jv_approval','journal_type="'.$tr_from.'"');

if($jv_approval=="Yes"){

sec_journal_journal($conn,$jv_no,$jv_no,$tr_from);

$time_now = date('Y-m-d H:i:s');

$up_sj='update secondary_journal set status="CHECKED", checked_at="'.$time_now.'", checked_by="'.$_SESSION['user']['id'].'" 
where jv_no="'.$jv_no.'" and tr_from="'.$tr_from.'"';
mysqli_query($conn,$up_sj);

$up_jv='update journal set status="CHECKED", checked_by="'.$_SESSION['user']['id'].'", checked_at="'.$time_now.'"
 where jv_no="'.$jv_no.'" and tr_from="'.$tr_from.'"';
mysqli_query($conn,$up_jv);

$up_jm='update journal_master set status="CHECKED", checked_by="'.$_SESSION['user']['id'].'", checked_at="'.$time_now.'"
 where jv_no="'.$jv_no.'" and tr_from="'.$tr_from.'"';
mysqli_query($conn,$up_jm);

}elseif($jv_approval=="No") {
$up_jm='update journal_master set status="UNCHECKED" where jv_no="'.$jv_no.'" and tr_from="'.$tr_from.'"';
mysqli_query($conn,$up_jm);

$up_sj='update secondary_journal set status="UNCHECKED" where jv_no="'.$jv_no.'" and tr_from="'.$tr_from.'"';
mysqli_query($conn,$up_sj);
}


//$dis_amt = find_a_field($conn,'journal_receive_payment','sum(discount_amt)','jv_no="'.$jv_no.'"');

//$dis_data=mysqli_fetch_object(mysqli_query($conn,'select sum(discount_amt) as dis_amt from journal_receive_payment where jv_no="'.$jv_no.'"'));

//if($dis_amt>0) {
//auto_insert_invoice_discount_secoundary_journal($conn,$jv_no);
//}





?>

<script language="javascript">
window.location.href = "<?php echo $page;?>";
</script>

<?php } ?>




<!DOCTYPE html>
<html lang="en">

<!-- ======= <head> ======= -->
 <?php require_once('inc_files/inc_head.php'); ?>
<!-- ======= </head> ======= -->


  <?php
  do_calander('#jv_date');
  create_combobox('master_ledger');
  ?>
  
  
  
<script language="javascript">

function SUMcalculation(jv_no){
var total_amt = 0;

<?php

$sql = "select m.jv_no, m.view_jv_no, m.jv_date, sum(j.dr_amt) as inv_amt from journal_master m, journal j
where m.jv_no=j.jv_no and m.tr_from='Sales' and m.ref_no='".$ref_no."' and j.dr_amt>0 and j.item_id=0 group by j.jv_no order by m.jv_date, m.jv_no";
$query = mysqli_query($conn,$sql);
while($data=mysqli_fetch_object($query)){
?>
total_amt = total_amt + document.getElementById('receipt_amt_<?php echo $data->jv_no?>').value*1;;
<?php
}

?>
document.getElementById('total_amt').value = total_amt;



}


</script>


<script language="javascript">

function TRcalculation(jv_no){

var tds_amt = document.getElementById('tds_amt_'+jv_no).value*1;
var vds_amt = document.getElementById('vds_amt_'+jv_no).value*1;
var commission_amt = document.getElementById('commission_amt_'+jv_no).value*1;
var discount_amt = document.getElementById('discount_amt_'+jv_no).value*1;
var receipt_amt = document.getElementById('receipt_amt_'+jv_no).value*1;
var advance_amt = document.getElementById('advance_amt_'+jv_no).value*1;
var other_income = document.getElementById('other_income_'+jv_no).value*1;

var all_tot_amt = document.getElementById('all_tot_amt_'+jv_no).value= (tds_amt+vds_amt+commission_amt+discount_amt+receipt_amt+advance_amt+other_income);
}


</script>


 
 
 <script language="javascript">

function count(){



var total_unit=(document.getElementById('total_unit').value)*1; 

var unit_price=(document.getElementById('unit_price').value)*1;

document.getElementById('total_amt').value=(total_unit*unit_price);



}


function final_count(){



//var unit_price=(document.getElementById('unit_price').value)*1; 
//
//var bag_size=(document.getElementById('bag_size').value)*1;
//
//var init_bag_unit=(document.getElementById('init_bag_unit').value)*1;  
//
//var init_dist_unit=(document.getElementById('init_dist_unit').value)=(bag_size*init_bag_unit);
//
//document.getElementById('init_total_unit').value=(init_dist_unit*1);
//
//document.getElementById('init_total_amt').value=(unit_price*init_dist_unit);

var dist_unit=(document.getElementById('dist_unit').value)*1; 

document.getElementById('total_unit').value=(dist_unit*1);

var total_amt=(document.getElementById('total_amt').value)*1; 

document.getElementById('unit_price').value=(total_amt/dist_unit);



}




//window.onload = function() {
//  document.getElementById("itemin").focus();
//};






</script>

<body>

  <!-- ======= Header ======= -->
  <?php 
  require_once('inc_files/inc_header.php');
  ?><!-- End Header -->

  <!-- ======= Sidebar ======= -->
   <?php  require_once('inc_files/inc_menu.php'); ?>
   <!-- End Sidebar-->

  <main id="main" class="main">
    <div class="pagetitle">
      <h1><?php echo $page_title?></h1>
      <nav>
        <ol class="breadcrumb">
          <li class="breadcrumb-item"><a href="home.php">Home</a></li>
          <li class="breadcrumb-item">Sales Management</li>
          <li class="breadcrumb-item active"><?php echo $page_title?></li>
        </ol>
      </nav>
    </div><!-- End Page Title -->

    <section class="section">
      <div class="row">
	  
	  <?php if ($customer_group=="") { ?>
	  <div class="col-lg-12">

          <div class="card">
            <div class="card-body">
              
			  <h5 class="card-title"><strong>&nbsp;</strong></h5>

              <!-- General Form Elements -->
                <form class="row g-3" action="" method="post" name="form1" id="form1" onSubmit="return check()" style="font-size:14px;">
                <div class="row mb-3" >
                  <label for="email" class="col-sm-2 col-form-label"><strong><center>Customer Group</center></strong></label>
                  <div class="col-sm-6">
				  
				  <?php 
				 auto_complete_from_db_sql($conn,'SELECT concat(a.id," :: ",a.customer_group), concat(a.id," :: ",a.customer_group) FROM customer_group a
					 WHERE 1','acc_reference'); 
				 ?>
                  <input type="text" class="form-control" id="acc_reference" name="acc_reference" value="" required>
                  </div>
				  
				     <div class="col-sm-4">
					 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type="submit" class="btn btn-primary btn-sm" name="submit" id="submit" >&nbsp;<i class="bi bi-arrow-down-circle me-1"></i> View Invoice&nbsp;&nbsp;&nbsp;</button>
					 </div>
				  
                </div>
				
		
  
              </form><!-- End General Form Elements -->

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


	  <?php }?>
	  
        <?php if(isset($_POST['submit'])){ ?>
<form action="" method="post" name="form1" id="form1" onSubmit="return check()"  style="font-size:14px;">
        <div class="col-lg-12">

          <div class="card">
            <div class="card-body">
              <p>&nbsp;</p>

              <!-- General Form Elements -->
              
			  
			  <div class="row mb-3">
                  <label for="inputText" class="col-sm-2 col-form-label"><span style="color:#FF0000;">Customer Group</span></label>
                  <div class="col-sm-6">
			  
		  <select id="customer_group" name="customer_group"  class="form-select"  required  >
			
			<?php foreign_relation($conn,'customer_group','id','concat(id," :: ",customer_group)',$_POST['customer_group'],'id="'.$customer_group.'"');?>
		
         </select>

                  </div>
			  
                </div>
			  
                <div class="row mb-3">
                  <label for="inputText" class="col-sm-2 col-form-label"><span style="color:#FF0000;">Receive Date</span></label>
                  <div class="col-sm-6">
			  
			    <input type="text" class="form-control" id="jv_date" name="jv_date" value="<?php echo $ms_data->jv_date; ?>" required readonly="">

                  </div>
			  
                </div>
				
				
                
				<div class="row mb-3">
                  <label for="inputEmail" class="col-sm-2 col-form-label"><span style="color:#FF0000;">Deposit To</span></label>
                  <div class="col-sm-6">
			
      <select id="master_ledger_id" name="master_ledger_id" required class="form-select" >
	  
	  <option></option>

	<?php foreign_relation($conn,'accounts_ledger','ledger_id','concat(ledger_id," :: ",ledger_name)',$_POST['master_ledger_id'],'ledger_type!="General"');?>
		
      </select>
			
			
			
                  </div>
                </div>
				<div class="row mb-3">
                  <label for="inputPassword" class="col-sm-2 col-form-label">Note</label>
                  <div class="col-sm-6">
                    <textarea class="form-control" style="height: 80px" id="remarks" name="remarks" ></textarea>
                  </div>
                </div>
                        
          
              <!-- End General Form Elements -->

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

<?php }?>


  <?php if(isset($_POST['submit'])){ ?>
<div class="col-lg-12">

          <div class="card">
            <div class="card-body">
              
              <h5 class="card-title"><strong>Outstanding Transactions</strong></h5>
              <!-- Bordered Table -->
			
              <table width="35%" class="table table-bordered " style="font-size:12px;">
                <thead>
                  <tr>
                    <th width="2%" scope="col">SL</th>
                    <th width="2%" scope="col">CUSTOMER</th>
                    <th width="7%" scope="col"> DATE</th>
                    <th width="8%" scope="col">INVOICE NO </th>
                    <th width="8%" scope="col">INV Note </th>
                    <th width="4%" scope="col"> DAYS </th>
                    <th width="8%" scope="col" align="right">INV AMT</th>
                    <th width="7%" scope="col" align="right">DUE AMT</th>
                    <th width="7%" scope="col" align="right">TDS</th>
                    <th width="7%" scope="col" align="right">VDS</th>
                    <th width="8%" scope="col" align="right">COMM.</th>
                    <th width="8%" scope="col" align="right">DISC.</th>
                    <th width="10%" scope="col" align="right">RECEIVE</th>
                    <th width="8%" scope="col" align="right">ADV</th>
                    <th width="8%" scope="col" align="right">INCM</th>
                  </tr>
                </thead>
                <tbody>
					<?php
					
					$sl=1;
					
					
					$sql = "select sum(cr_amt) as received_amt, tr_no  from journal_receive_payment where tr_from in ('Receipt', 'Journal')  group by tr_no ";
					$query = mysqli_query($conn,$sql);
					while($data=mysqli_fetch_object($query)){
					$received_amt[$data->tr_no]=$data->received_amt;
					
					}
					
	$sql = 'select  ref_no, ledger_id, jv_no, sum(dr_amt) as sales_amt, sum(cr_amt) as adv_amt from journal 
	where tr_from in ("Sales", "Opening", "Journal") group by ref_no, ledger_id, jv_no';
					$query = mysqli_query($conn,$sql);
					while($data=mysqli_fetch_object($query)){
					$sales_amt[$data->ref_no][$data->ledger_id][$data->jv_no]=$data->sales_amt;
					$adv_amt[$data->ref_no][$data->ledger_id][$data->jv_no]=$data->adv_amt;
					}
					
					
					
					
					   $sql = 'select m.jv_no, m.view_jv_no, m.jv_date, r.ref_no, r.display_name, r.ledger_id  from journal_master m, accounts_reference r
						where  m.ref_no=r.ref_no and r.customer_group="'.$customer_group.'" and m.tr_from in ("Sales", "Opening", "Journal")  and m.jv_special=1  
						 group by m.jv_no order by r.ref_no, m.jv_date, m.jv_no';
						$query = mysqli_query($conn,$sql);
						while ($data = mysqli_fetch_object($query)) {

					?>
					
<?php
$t_date=date('Y-m-d');
$f_dt = $data->jv_date;		   
$t_dt =  date('Y-m-d', strtotime('+1 day', strtotime($t_date)));

$from_date = strtotime($f_dt);
$to_date = strtotime($t_dt);
$datediff = $to_date - $from_date;
$count_days = round($datediff / (60 * 60 * 24));

?>
				
				<?php if ($due_amt=($sales_amt[$data->ref_no][$data->ledger_id][$data->jv_no]-($adv_amt[$data->ref_no][$data->ledger_id][$data->jv_no]+$received_amt[$data->jv_no]))>0) {?>
                  <tr>
                    <td scope="row"><?php echo $sl++;?></td>
                    <td scope="row"><?php echo $data->display_name;?></td>
                    <td style="white-space: nowrap;"><?php echo date('d-M-y',strtotime($data->jv_date));?></td>
                    <td><a href="view_file/sales_invoice_print_view.php?jv_no=<?php echo $data->jv_no;?>" target="_blank"><?php echo $data->view_jv_no;?></a></td>
                    <td>
					<textarea class="form-control" style="height: 33px" id="inv_note_<?php echo $data->jv_no?>" name="inv_note_<?php echo $data->jv_no?>" ></textarea>					</td>
                    <td><?php echo $count_days;?></td>
                    <td align="right">
<?php echo number_format($invoice_amt=$sales_amt[$data->ref_no][$data->ledger_id][$data->jv_no]-$adv_amt[$data->ref_no][$data->ledger_id][$data->jv_no],2);?></td>
                    <td align="right"><?php echo number_format($due_amt=$invoice_amt-$received_amt[$data->jv_no],2);?></td>
                    <td align="right">
					<input class="form-control"  onKeyUp="TRcalculation(<?php echo $data->jv_no?>)" name="tds_amt_<?php echo $data->jv_no?>" id="tds_amt_<?php echo $data->jv_no?>" type="text"  value="0"  style="height:33px" />					</td>
                    <td align="right">
					<input class="form-control"  onKeyUp="TRcalculation(<?php echo $data->jv_no?>)" name="vds_amt_<?php echo $data->jv_no?>" id="vds_amt_<?php echo $data->jv_no?>" type="text"  value="0"  style="height:33px" />					</td>
                    <td align="right">
					<input class="form-control"  onKeyUp="TRcalculation(<?php echo $data->jv_no?>)" name="commission_amt_<?php echo $data->jv_no?>" id="commission_amt_<?php echo $data->jv_no?>" type="text"  value="0"  style="height:33px" />					</td>
                    <td align="right">
					<input class="form-control" name="ledger_id_<?php echo $data->jv_no?>" id="ledger_id_<?php echo $data->jv_no?>" type="hidden"  value="<?php echo $data->ledger_id?>"  style="height:33px" />
					<input class="form-control"  onKeyUp="TRcalculation(<?php echo $data->jv_no?>)" name="discount_amt_<?php echo $data->jv_no?>" id="discount_amt_<?php echo $data->jv_no?>" type="text"  value="0"  style="height:33px" /></td>
                    <td align="right"> <input class="form-control"  onKeyUp="TRcalculation(<?php echo $data->jv_no?>)" name="receipt_amt_<?php echo $data->jv_no?>" id="receipt_amt_<?php echo $data->jv_no?>" value="0" type="text"  style="height:33px" />	</td>
                    <td align="right">
					<input class="form-control"  onKeyUp="TRcalculation(<?php echo $data->jv_no?>)" name="advance_amt_<?php echo $data->jv_no?>" id="advance_amt_<?php echo $data->jv_no?>" type="text"  value="0"  style="height:33px" />					</td>
                    <td align="right">
					<input class="form-control"  onKeyUp="TRcalculation(<?php echo $data->jv_no?>)" name="other_income_<?php echo $data->jv_no?>" id="other_income_<?php echo $data->jv_no?>" type="text"  value="0"  style="height:33px" />	
					
					<input class="form-control"  name="all_tot_amt_<?php echo $data->jv_no?>" id="all_tot_amt_<?php echo $data->jv_no?>" type="hidden"  value="0"  style="height:33px" />					</td>
                  </tr>
				  <?php } }?>
                </tbody>
              </table>
			  
              <!-- End Bordered Table -->
			  
			  <br>
			  <br>
			  
			  <!--<table class="table">
                
                <tbody>
					
				  
			    <th width="6%" scope="col">&nbsp;</th>
                    <th width="24%" scope="col">&nbsp;</th>
                    <th width="19%" scope="col">&nbsp;</th>
                    <th width="14%" scope="col">&nbsp;</th>
                    <th width="12%" scope="col" align="right">&nbsp;</th>
                    <th width="11%" scope="col" align="right">TOTAL</th>
                    <th width="14%" scope="col" align="right"><input name="total_amt" id="total_amt" type="text" class="form-control" readonly=""  value="<?php echo $total_amt?>"  /></th>
				</tbody>
                  
              </table>-->
			  <br>
			 
			  
			  
          
<div class="text-left" align="right">
 
				 
				  <button type="reset" class="btn btn-primary btn-sm" onClick="parent.location='<?php echo $page?>'" >&nbsp;&nbsp;Clear&nbsp;&nbsp;</button>&nbsp;&nbsp;&nbsp;&nbsp
				  <button type="submit" class="btn btn-success btn-sm" name="confirm_data" id="confirm_data" >&nbsp;&nbsp;Save &amp; Close&nbsp;&nbsp;</button>
                  
              </div>
       
		
		 <br>

            </div>
          </div>

        </div>
	<?php }?>	
	 </form>	
		
      </div>
    </section>

  </main><!-- End #main -->

 <!-- ======= Footer ======= -->
 <?php require_once('inc_files/inc_footer.php'); ?>
<!-- ======= Footer ======= -->

</body>

</html>