<?php
$general->createLog('customer_transaction_remove',$_POST);
$voucher_id=intval($_POST['voucher_id']);
$voucher=$db->get_rowData('a_voucher_entry','id',$voucher_id);
$remove_types=[
    V_T_RECEIVE_FROM_CUSTOMER,
    V_T_CUSTOMER_COLLECTION_DISCOUNT,
    V_T_CUSTOMER_YEARLY_DISCOUNT,
    V_T_CUSTOMER_BAD_DEBT,
    V_T_RECOVERABLE_ENTRY
];
if(
    !empty($voucher)&&
    in_array($voucher['type'],$remove_types)
){
    $db->transactionStart();
    $delete=$db->delete('a_head_entry',['voucher_id'=>$voucher_id]);
    if($delete==false){$error=fl();setMessage(66);}
    $delete=$db->delete('a_voucher_entry',['id'=>$voucher_id]);
    if($delete==false){$error=fl();setMessage(66);}
    if(!isset($error)){
        $ac=true;
        $jArray['status']=1;
    }
    else{
        $ac=false;
    }
    $db->transactionStop($ac);
}
$general->createLog('customer_transaction_remove',$jArray);