<?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="Contra Voucher Edit";
$page="24_voucher_edit.php?active_id=".$active_id."&menu_id=".$menu_id."";
$table='journal_master';	
$unique='jv_no';

$request_no=$_REQUEST['request_no'];

$ms_data=mysqli_fetch_object(mysqli_query($conn,'select * from '.$table.' where jv_no="'.$request_no.'"'));

// End Common Information

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

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

		$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.'"')+1;
  		$cy_id = sprintf("%06d", $inv_cy_id);
   		$invoice_no=''.$year.''.$month.''.$cy_id;
		$view_invoice_no='CN-'.$year.''.$month.''.$cy_id;

$master_ledger_id=0;
$remarks = $_POST['remarks'];
$jv_type=4;
$tr_from='Contra';
//$grp_sql="SELECT * FROM ledger_group  WHERE group_id='".$ledger_group_id."'";
//$grp_data = find_all_field_sql($conn,$grp_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) VALUES

("'.$invoice_no.'", "'.$YR.'", "'.$cy_id.'", "'.$view_invoice_no.'", "'.$jv_type.'", "'.$jv_date.'", "'.$group_for.'", "'.$master_ledger_id.'", "'.$tr_from.'", "'.$remarks.'", "'.$status.'", "'.$entry_at.'", "'.$entry_by.'")';
	
mysqli_query($conn,$ins_sql);


		//if($_FILES['attached_file']['tmp_name']!=''){ 
//		$file_temp = $_FILES['attached_file']['tmp_name'];
//		$folder = "jv_attached_file";
//		move_uploaded_file($conn,$file_temp, $folder.$invoice_no.'.jpg');}



?>

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

<?php

}



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

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

$warehouse_id=$_POST['warehouse_id'];
$remarks = $_POST['remarks'];

 $up_jm='update journal_master set  master_ledger_id="'.$master_ledger_id.'",  jv_date="'.$jv_date.'", remarks="'.$remarks.'", edit_by="'.$entry_by.'", edit_at="'.$entry_at.'" where jv_no="'.$jv_no.'"';
mysqli_query($conn,$up_jm);




header("location:".$page.'&request_no='.$jv_no."");

?>

<!--<script language="javascript">
window.location.href = "<?php echo $page;?>&request_no=<?=$jv_no?>";
</script>-->

<?php

}




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

{
//$_POST['entry_by'] = $_SESSION['user']['id'];

$ms_sql="SELECT * FROM journal_master  WHERE jv_no='".$request_no."'";
$ms_data = find_all_field_sql($conn,$ms_sql);

$status='MANUAL';
$entry_by = $_SESSION['user']['id'];
$entry_at = $now=date('Y-m-d H:i:s');

$jv_no=$ms_data->jv_no;
$jv_date=$ms_data->jv_date;
$relevant_ledger=$ms_data->master_ledger_id;
$tr_from=$ms_data->tr_from;
$tr_no=0;
$cc_code=0;
$tr_id=0;
$ref_no=0;
$group_for=$ms_data->group_for;

$gl_account=$_POST['gl_account'];

  $ledger=explode(' ::',$gl_account);
  $ledger_id=$ledger[0];

$narration=$_POST['narration'];
$dr_amt=$_POST['dr_amt'];
$cr_amt=$_POST['cr_amt'];


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

header("location:".$page.'&request_no='.$jv_no."");

?>

<!--<script language="javascript">
window.location.href = "<?php echo $page;?>&request_no=<?=$jv_no?>";
</script>-->

<?php

}



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

{
//$_POST['entry_by'] = $_SESSION['user']['id'];

$ms_sql="SELECT * FROM journal_master  WHERE jv_no='".$request_no."'";
$ms_data = find_all_field_sql($conn,$ms_sql);

$status='MANUAL';
$entry_by = $_SESSION['user']['id'];
$entry_at = $now=date('Y-m-d H:i:s');

$sql_deljv = 'delete from journal where  jv_no="'.$request_no.'"';
mysqli_query($conn,$sql_deljv);

$jv_no=$ms_data->jv_no;
$jv_date=$ms_data->jv_date;
$ledger_id=$ms_data->master_ledger_id;
$relevant_ledger=0;
$tr_from=$ms_data->tr_from;
$tr_no=0;
$cc_code=0;
$tr_id=0;
$ref_no=0;
$group_for=$ms_data->group_for;

$narration=$ms_data->remarks;



$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);
}


?>

<script language="javascript">
window.location.href = "26_voucher.php?active_id=306&menu_id=3";
</script>

<?php

}




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

{
//$_POST['entry_by'] = $_SESSION['user']['id'];

$ms_sql="SELECT * FROM journal_master  WHERE jv_no='".$request_no."'";
$ms_data = find_all_field_sql($conn,$ms_sql);

$status='MANUAL';
$entry_by =  $_SESSION['user']['id'];
$entry_at = $now=date('Y-m-d H:i:s');

$sql_deljv = 'delete from journal where  jv_no="'.$request_no.'"';
mysqli_query($conn,$sql_deljv);


$jv_no=$ms_data->jv_no;
$jv_date=$ms_data->jv_date;
$tr_from=$ms_data->tr_from;

$up_jm='update journal_master set status="'.$status.'" where jv_no="'.$jv_no.'"';
mysqli_query($conn,$up_jm);



?>

<script language="javascript">
window.location.href = "26_voucher.php?active_id=306&menu_id=3";
</script>

<?php

}





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

{
//$_POST['entry_by'] = $_SESSION['user']['id'];

$ms_sql="SELECT * FROM journal_master  WHERE jv_no='".$request_no."'";
$ms_data = find_all_field_sql($conn,$ms_sql);

$status='MANUAL';
$entry_by = $_SESSION['user']['id'];
$entry_at = $now=date('Y-m-d H:i:s');

$jv_no=$ms_data->jv_no;
$tr_from=$ms_data->tr_from;

$del_id=$_POST['del_id'];

 $sql_delp = 'delete from secondary_journal where  id="'.$del_id.'"';
mysqli_query($conn,$sql_delp);


?>

<?php /*?><script language="javascript">
window.location.href = "24_voucher.php?request_no=<?=$jv_no?>";
</script><?php */?>

<?php

}







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

{
//$_POST['entry_by'] = $_SESSION['user']['id'];

$ms_sql="SELECT * FROM journal_master  WHERE jv_no='".$request_no."'";
$ms_data = find_all_field_sql($conn,$ms_sql);

$status='MANUAL';
$entry_by = $_SESSION['user']['id'];
$entry_at = $now=date('Y-m-d H:i:s');

$jv_no=$ms_data->jv_no;
$tr_from=$ms_data->tr_from;

$sql_del1 = 'delete from journal_master where tr_from="'.$tr_from.'" and jv_no="'.$jv_no.'"';
mysqli_query($conn,$sql_del1);

$sql_del2 = 'delete from secondary_journal where tr_from="'.$tr_from.'" and jv_no="'.$jv_no.'"';
mysqli_query($conn,$sql_del2);

$sql_del3 = 'delete from journal where tr_from="'.$tr_from.'" and jv_no="'.$jv_no.'"';
mysqli_query($conn,$sql_del3);


?>

<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> ======= -->

  <script language="javascript">

function SUMcalculation(id){
var tot_dr_amt_edit = 0;
var tot_cr_amt_edit = 0;

<?php

$sql = 'select j.*, a.ledger_name from secondary_journal j, accounts_ledger a
where j.ledger_id=a.ledger_id and j.jv_no="'.$request_no.'"  order by id desc';
$query = mysqli_query($conn,$sql);
while($data=mysqli_fetch_object($query)){
?>
tot_dr_amt_edit = tot_dr_amt_edit + document.getElementById('dr_amt_edit_<?php echo $data->id?>').value*1;
tot_cr_amt_edit = tot_cr_amt_edit + document.getElementById('cr_amt_edit_<?php echo $data->id?>').value*1;;
<?php
}

?>
document.getElementById('tot_dr_amt_edit').value = tot_dr_amt_edit;
document.getElementById('tot_cr_amt_edit').value = tot_cr_amt_edit;


}


</script>



<script>



function getXMLHTTP() { //fuction to return the xml http object



		var xmlhttp=false;	



		try{



			xmlhttp=new XMLHttpRequest();



		}



		catch(e)	{		



			try{			



				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");

			}

			catch(e){



				try{



				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");



				}



				catch(e1){



					xmlhttp=false;



				}



			}



		}



		 	



		return xmlhttp;



    }



	function update_value(id)
	{

var id=id; // Rent
//var mon=(document.getElementById('mon').value); 
//var year=(document.getElementById('year').value)*1; 
var ledger_id_edit=(document.getElementById('ledger_id_edit_'+id).value)*1;
//var ref_no_edit=(document.getElementById('ref_no_edit_'+id).value)*1;
var narration_edit=(document.getElementById('narration_edit_'+id).value);
var dr_amt_edit=(document.getElementById('dr_amt_edit_'+id).value)*1;
var cr_amt_edit=(document.getElementById('cr_amt_edit_'+id).value)*1;

var strURL="24_voucher_edit_ajax.php?id="+id+"&ledger_id_edit="+ledger_id_edit+"&narration_edit="+narration_edit+"&dr_amt_edit="+dr_amt_edit+"&cr_amt_edit="+cr_amt_edit;



		var req = getXMLHTTP();



		if (req) {



			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {						

						document.getElementById('divi_'+id).style.display='inline';

						document.getElementById('divi_'+id).innerHTML=req.responseText;						

					} else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}				

			}

			req.open("GET", strURL, true);

			req.send(null);

		}	



}




</script>

  
  <?php
  do_calander('#invoice_date');
  do_calander('#jv_date');
  ?>
 
 
 
 
<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="index.html">Home</a></li>
          <li class="breadcrumb-item">General Voucher</li>
          <li class="breadcrumb-item active"><?php echo $page_title;?> </li>
        </ol>
      </nav>
    </div><!-- End Page Title -->

    <section class="section">
      <div class="row">
        

        <div class="col-lg-7">

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

              <!-- General Form Elements -->
              <form action="" method="post" name="form1" id="form1" onSubmit="return check()" style="font-size:14px;">
                <div class="row mb-3">
                  <label for="inputText" class="col-sm-3 col-form-label"><span style="color:#FF0000;">Date</span></label>
                  <div class="col-sm-9">
			   <?php if($request_no>0){?> 
			    <input type="text" class="form-control" id="jv_date" name="jv_date" value="<?php echo $ms_data->jv_date; ?>" required >
			   <?php } else {?>
			   <input type="text" class="form-control" id="invoice_date" name="invoice_date" value="" required>
			   <?php }?>
			   

                  </div>
				  
				  
				  
                </div>
                <div class="row mb-3">
                  <label for="inputEmail" class="col-sm-3 col-form-label">Voucher No</label>
                  <div class="col-sm-9">
                    <input type="text" class="form-control" id="jv_no" name="jv_no" value="<?php if($request_no>0){ echo $ms_data->jv_no; } ?>" readonly="" >
                  </div>
                </div>
				
				<div class="row mb-3">
                  <label for="inputPassword" class="col-sm-3 col-form-label">Note</label>
                  <div class="col-sm-9">
                    <textarea class="form-control" style="height: 80px" id="remarks" name="remarks" ><?php if($request_no>0){ echo $ms_data->remarks; } ?></textarea>
                  </div>
                </div>
                        
                <?php /*?><div class="row mb-3">
                  <label for="inputNumber" class="col-sm-3 col-form-label">Attach File(s)</label>
                  <div class="col-sm-9">
                    <input class="form-control" type="file" id="attached_file" name="attached_file" >
                  </div>
                </div><?php */?>
                   

                <div class="text-center">
				<?php if($request_no>0) {?>
                  <button type="submit" class="btn btn-success btn-sm" name="up_master_data" id="up_master_data" >Update Data</button>
				 <?php }else {?>
				  <button type="submit" class="btn btn-primary btn-sm" name="ins_master_data" id="ins_master_data" >Initiate Entry</button>
				 <?php }?>
                 <!-- <button type="reset" class="btn btn-secondary" onClick="parent.location='<?php echo $page?>'" >Reset</button>-->
                </div>

              </form><!-- End General Form Elements -->

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


<div class="col-lg-5">

          <div class="card">
            <div class="card-body">
		    <br/>
			<table width="100%" class="table table-sm" style="font-size:12px;">
                <thead>
                  <tr style="text-transform:uppercase; color:#012970; background:#f6f9ff;  border-top: 1px solid #CCCCCC;">
                    <th width="22%" scope="col"><span class="card-title" style="font-size:10px; text-transform:uppercase;">JV No </span></th>
                    <th width="20%" scope="col"><span class="card-title" style="font-size:10px;  text-transform:uppercase;"><div style="text-align:center">JV Date</div> </span></th>
                    <th width="20%" scope="col"><span class="card-title" style="font-size:10px; text-transform:uppercase;">
                    <div style="text-align:right">Amount</div> </span></th>
                    <th width="38%" scope="col"><span class="card-title" style="font-size:10px; text-transform:uppercase;">
                    <div style="text-align:right">Entry By </div>
                    </span></th>
                  </tr>
                </thead>
                <tbody>
		<?php
			
					
		 $sql = "select user_id, fname from user_management where 1 group by user_id";
		 $query = mysqli_query($conn,$sql);
		 while($info=mysqli_fetch_object($query)){
  		 $fname[$info->user_id]=$info->fname;
		}
					
					    $sql = 'select a.jv_no, a.view_jv_no, a.jv_date, sum(j.dr_amt) as jv_amt, a.entry_by from '.$table.' a, journal j 
						 where a.jv_no=j.jv_no and a.tr_from="Contra" and a.status="CHECKED" and a.jv_no="'.$request_no.'" group by j.jv_no order by a.jv_no DESC LIMIT 8';
						$query = mysqli_query($conn,$sql);
						while ($data = mysqli_fetch_object($query)) {

					?>
			
      <tr>
      <td><a href="view_file/journal_print_view.php?jv_no=<?php echo $data->jv_no;?>" target="_blank"><?php echo $data->view_jv_no;?></a></td>
      <td align="center"><?php echo date('d-M-y',strtotime($data->jv_date));?></td>
      <td align="right"><?php echo number_format($data->jv_amt,2); ?></td>
      <td align="right"><?php echo $fname[$data->entry_by];?></td>
      </tr>
				  <?php }?>
				  
     
                </tbody>
              </table>
			</div>
		</div>
</div>


<div class="col-lg-12">

          <div class="card">
            <div class="card-body">
              <br/>
 <form  action="" method="post" name="form1" id="form1" onSubmit="return check()" style="font-size:12px;">
             <table class="table table-bordered ">
                <thead>
                  <tr style="text-transform:uppercase; color:#012970; background:#f6f9ff;  border-top: 1px solid #CCCCCC;">
                    <th width="38%" scope="col">GL ACCOUNT </th>
                    <th width="28%" scope="col">DESCRIPTION</th>
                    <th width="12%" scope="col">DEBITS</th>
                    <th width="12%" scope="col">CREDITS</th>
                    <th width="10%" scope="col">ACTION</th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                    <th scope="row">
					
					<?php
					if($request_no>0) {
					//auto_complete_from_db($conn,'accounts_ledger','ledger_name','concat(ledger_id,"->",ledger_name)','1','ledger_id');
					
					auto_complete_from_db_sql($conn,'SELECT concat(a.ledger_id," :: ",a.ledger_name," >>> [GL Group: ",g.group_name,"]"), concat(a.ledger_id," :: ",a.ledger_name," >>> [GL Group: ",g.group_name,"]") FROM accounts_ledger a, ledger_group g 
					 WHERE a.ledger_group_id=g.group_id and a.ledger_type!="General"','gl_account');
					}
					?>
					
					
					<input type="text" class="form-control" name="gl_account" id="gl_account" autocomplete="off" required></th>
                    <td><input type="text" class="form-control" name="narration" id="narration"></td>
                    <td><input type="text" class="form-control" name="dr_amt" id="dr_amt" ></td>
                    <td><input type="text" class="form-control" name="cr_amt" id="cr_amt" ></td>
                    <td>
	<button type="submit" class="btn btn-primary btn-sm" name="ins_primary_data" id="ins_primary_data" ><i class="bi bi-plus"></i>ADD&nbsp;&nbsp;</button>				
					</td>
                  </tr>
                </tbody>
              </table>
                

              </form><!-- End General Form Elements -->

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



 
 
 
          
<div class="col-lg-12">

          <div class="card">
            <div class="card-body">
              
              <br/>
              <!-- Bordered Table -->
			
              <table class="table table-bordered " style="font-size:12px;">
                <thead>
                  <tr style="text-transform:uppercase; color:#012970; background:#f6f9ff;  border-top: 1px solid #CCCCCC;">
                    <th width="3%" scope="col">SL</th>
                    <th width="27%" scope="col">GL ACCOUNT </th>
                    <th width="26%" scope="col">DESCRIPTION</th>
                    <th width="12%" scope="col"><center>DEBITS</center></th>
                    <th width="12%" scope="col"><center>CREDITS</center></th>
                    <th width="10%" scope="col">ACTION</th>
                  </tr>
                </thead>
                <tbody>
					<?php
					
					$sl=1;
					
						 $sql = 'select j.*, a.ledger_name from secondary_journal j, accounts_ledger a
						where j.ledger_id=a.ledger_id and j.jv_no="'.$request_no.'"  order by id desc';
						$query = mysqli_query($conn,$sql);
						while ($data = mysqli_fetch_object($query)) {

					?>
				
                  <tr>
                    <th scope="row"><?php echo $sl++;?></th>
                    <td>
					<select id="ledger_id_edit_<?php echo $data->id?>" name="ledger_id_edit_<?php echo $data->id?>"  class="form-select"  style="width: 95%;">
                      <option></option>
 <?php foreign_relation($conn,'accounts_ledger','ledger_id','ledger_name',$data->ledger_id, 'ledger_type!="General" group by ledger_id');?>
                    </select>					</td>
                    <td>
					<input type="text" class="form-control" name="narration_edit_<?php echo $data->id?>" id="narration_edit_<?php echo $data->id?>" value="<?php echo $data->narration;?>">					</td>
                    <td align="right">
					<input type="text" class="form-control" name="dr_amt_edit_<?php echo $data->id?>" id="dr_amt_edit_<?php echo $data->id?>" value="<?php echo $data->dr_amt; $tot_dr_amt+=$data->dr_amt;?>" onKeyUp="SUMcalculation(<?php echo $data->id?>)" >					</td>
                    <td align="right">
					<input type="text" class="form-control" name="cr_amt_edit_<?php echo $data->id?>" id="cr_amt_edit_<?php echo $data->id?>" value="<?php echo $data->cr_amt; $tot_cr_amt+=$data->cr_amt;?>" onKeyUp="SUMcalculation(<?php echo $data->id?>)" >					</td>
                    <td align="center">  <span id="divi_<?php echo $data->id?>">
					   <input class="form-control" type="button" name="Button" value="Edit"  onclick="update_value(<?php echo $data->id?>)" style="width:80%; height:30px; background-color:#FF3366; font-weight:700; font-size:12px;"/>
					 </span></td>
                  </tr>
				   <?php }?>
                  <tr  style="font-size:16px;">
                    <th scope="row">&nbsp;</th>
                    <td>&nbsp;</td>
                    <td><strong>Total</strong></td>
                    <td align="right"><input name="tot_dr_amt_edit" id="tot_dr_amt_edit" type="text" class="form-control" readonly=""  value="<?php echo $tot_dr_amt?>"  /></td>
                    <td align="right"><input name="tot_cr_amt_edit" id="tot_cr_amt_edit" type="text" class="form-control" readonly=""  value="<?php echo $tot_cr_amt?>"  /></td>
                    <td align="center">&nbsp;</td>
                  </tr>
				  
				 
                </tbody>
              </table>
			  
              <!-- End Bordered Table -->
			  <br>
			  <br>
			  <br>
			  
			  <br>
			  <br>
			  
			  <hr>

           <form action="" method="post" name="form1" id="form1" onSubmit="return check()">   
<div class="text-left">


				<?php if($difference_amt==0){?>
                  <button type="submit" class="btn btn-success btn-sm" name="confirm_data" id="confirm_data" >Save &amp; Publish</button> &nbsp;&nbsp;
				<?php }?> 
				 <!-- <button type="reset" class="btn btn-primary btn-sm" onClick="parent.location='<?php echo $page?>'" >Save as Draft</button> &nbsp;&nbsp;
                  <button type="submit" class="btn btn-danger btn-sm" name="cancel_data" id="cancel_data" >Cancel</button>-->
				  
				    <button type="submit" class="btn btn-primary btn-sm" name="draft_data" id="draft_data" >Send To Draft</button>
              </div>
        </form>

            </div>
          </div>

          

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

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

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

</body>

</html>