<?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');

$jv_no = $_REQUEST['jv_no'];
 
 $flag = $_REQUEST['flag'];
 
$sql_del_sjv = 'delete from secondary_journal where jv_no="'.$jv_no.'" and tr_from="Sales"';
mysqli_query($conn,$sql_del_sjv);

$sql_del_jv = 'delete from journal where jv_no="'.$jv_no.'" and tr_from="Sales"';
mysqli_query($conn,$sql_del_jv);
 
 
if($jv_no>0){
auto_insert_invoice_secoundary_journal($conn,$jv_no);
}

//if($total_unit==0){
//$sql_del = 'delete from sales_invoice where id="'.$order_no.'" ';
//mysqli_query($conn,$sql_del);
//}
//
//
//$entry_by=$_SESSION['user']['id'];
//$entry_at=date('Y-m-d H:i:s');
//
// $up_sql = 'update sales_invoice  set unit_price="'.$unit_price.'", total_unit="'.$total_unit.'", total_amt="'.$total_amt.'", discount="'.$discount.'", 
//  discount_amt="'.$discount_amt.'",  amt_after_discount="'.$amt_after_discount.'", remarks="'.$remarks.'",
// edit_by="'.$entry_by.'", edit_at="'.$entry_at.'"  where id='.$order_no;
//mysqli_query($conn,$up_sql);





echo 'Success!';
?>