Si le montant de TVA est égal à 0, il sera automatiquement calculé';
if ( ! isset ($_REQUEST['action'])){
exit;
}
$action=$_REQUEST['action'];
//--------------------------------------------------------------------------------
// use a predefined operation
//--------------------------------------------------------------------------------
if ( $action=="use_opd" ) {
$op=new Pre_op_ach($cn);
$op->set_od_id($_REQUEST['pre_def']);
$p_post=$op->compute_array();
echo_debug(__FILE__.':'.__LINE__.'- ','p_post = ',$p_post);
$submit='
';
$form=FormAchInput($cn,$_GET['p_jrn'],$User->GetPeriode(),$p_post,$submit,false,$p_post['nb_item']);
echo '
';
echo $form;
echo '
';
exit();
}
// action = new
if ( $action == 'new' ) {
// We request a new form
// Check privilege
if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) != 2 ) {
NoAccess();
exit -1;
}
if ( isset($_GET['blank'] )) {
// Submit button in the form
$submit='
';
$jrn=new Acc_Ledger($cn, $_GET['p_jrn']);
$r=FormAchInput($cn,$_GET['p_jrn'],$User->GetPeriode(),$_POST,$submit,false,$jrn->getDefLine());
//--------------------
// predef op.
$op=new Pre_operation($cn);
$op->p_jrn=$_GET['p_jrn'];
$op->od_direct='f';
echo '
";
}
// Add an item
if ( isset ($_POST['add_item'])) {
// Add a line
$nb_number=$_POST["nb_item"];
$nb_number++;
// submit button in the form
$submit='
';
$r=FormAchInput($cn,$_GET['p_jrn'],$User->GetPeriode(),$_POST,$submit,false,
$nb_number);
echo '
';
echo $r;
echo $msg_tva;
echo "
".JS_CALC_LINE."
";
echo "
";
}
// Correct it
if ( isset ($_POST['correct'])) {
// Get number of lines
$nb_number=$_POST["nb_item"];
// submit button in the form
$submit='
';
$r=FormAchInput($cn,$_GET['p_jrn'],$User->GetPeriode(),$_POST,$submit,false, $nb_number);
echo '
';
echo $r;
echo $msg_tva;
echo "
".JS_CALC_LINE."
";
echo "
";
return;
}
// View the charge and show a submit button to save it
if ( isset ($_POST['view_invoice']) and
! isset ($_POST['save'])) {
$nb_number=$_POST["nb_item"];
$submit='';
if ( $own->MY_ANALYTIC != "nu" )
$submit.='';
$submit.='';
if ( form_verify_input ($cn,$_GET['p_jrn'],$User->GetPeriode(),$_POST,$nb_number) == true ) {
// Should use a read only view instead of FormAch
// where we can check
$r=FormAchView($cn,$_GET['p_jrn'],$User->GetPeriode(),$_POST,$submit,$nb_number);
} else {
// if something goes wrong, correct it
$submit='
';
$r=FormAchInput($cn,$_GET['p_jrn'],$User->GetPeriode(),$_POST,$submit, false, $nb_number);
}
echo '
';
echo $r;
echo $msg_tva;
echo "
".JS_CALC_LINE."
";
echo "
";
}
// Save the charge into database
if ( isset($_POST['save'] )) {
// Get number of lines
$nb_number=$_POST["nb_item"];
if (form_verify_input ($cn,$_GET['p_jrn'],$User->GetPeriode(),$_POST,$nb_number)
== true ) {
list($internal,$comment)=RecordSell($cn,$_POST,$User,$_GET['p_jrn']);
// submit button in the form
$submit='
$paid)
{
list($ad) = sscanf($name,"set_jr_id%d");
if ( $ad == null ) continue;
$sql="update jrn set jr_rapt='' where jr_id=$ad";
$Res=ExecSql($cn,$sql);
}
// set a paid flag for the checked box
foreach ($_POST as $name=>$paid)
{
list ($id) = sscanf ($name,"rd_paid%d");
if ( $id == null ) continue;
$paid=($paid=='on')?'paid':'';
$sql="update jrn set jr_rapt='$paid' where jr_id=$id";
$Res=ExecSql($cn,$sql);
}
}
// Show list of sell
echo_debug ("user_action_ach.php");
// Date - date of payment - Customer - amount
if ( $current == -1) {
$cond=" and jr_tech_per in (select p_id from parm_periode where p_exercice='".$User->getExercice()."')";
} else {
$cond=" and jr_tech_per=".$current;
}
$sql=SQL_LIST_ALL_INVOICE.$cond." and jr_def_id=".$_GET['p_jrn'];
$step=$_SESSION['g_pagesize'];
$page=(isset($_GET['offset']))?$_GET['page']:1;
$offset=(isset($_GET['offset']))?$_GET['offset']:0;
list ($max_ligne,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
$bar=jrn_navigation_bar($offset,$max_ligne,$step,$page);
echo '';
echo '
';
}
if ( $action == 'voir_jrn_non_paye' ) {
// Check privilege
if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) < 1 ) {
NoAccess();
exit -1;
}
// Ask to update payment
if ( isset ( $_POST['paid']))
{
// reset all the paid flag because the checkbox is post only
// when checked
foreach ($_POST as $name=>$paid)
{
list($ad) = sscanf($name,"set_jr_id%d");
if ( $ad == null ) continue;
$sql="update jrn set jr_rapt='' where jr_id=$ad";
$Res=ExecSql($cn,$sql);
}
// set a paid flag for the checked box
foreach ($_POST as $name=>$paid)
{
list ($id) = sscanf ($name,"rd_paid%d");
if ( $id == null ) continue;
$paid=($paid=='on')?'paid':'';
$sql="update jrn set jr_rapt='$paid' where jr_id=$id";
$Res=ExecSql($cn,$sql);
}
}
// Show list of unpaid sell
// Date - date of payment - Customer - amount
$sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and jr_def_id=".$_GET['p_jrn'] ;
$offset=(isset($_GET['offset']))?$_GET['offset']:0;
$step=$_SESSION['g_pagesize'];
$page=(isset($_GET['offset']))?$_GET['page']:1;
list ($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
// $bar=jrn_navigation_bar($offset,$max_ligne,$step,$page);
$sql=SQL_LIST_UNPAID_INVOICE." and jr_def_id=".$_GET['p_jrn'] ;
list ($max_line2,$list2)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
// Get the max line
$m=($max_line2>$max_line)?$max_line2:$max_line;
$bar2=jrn_navigation_bar($offset,$m,$step,$page);
echo '
';
echo $search_box;
// if nofirst is set then show result
if ( isset ($_GET['nofirst'] ) ) {
list ($max_line,$a)=ListJrn($cn,$_GET['p_jrn'],"",$_POST);
echo $a;
}
echo '