';
-
- } else {
- $Res=ExecSql($this->cn,"select p_id,to_char(p_start,'DD.MM.YYYY') as date_start,to_char(p_end,'DD.MM.YYYY') as date_end,status,p_exercice
- from parm_periode join jrn_periode using (p_id) where jrn_def_id=".$this->jrn_def_id."
- order by p_start,p_end");
- $Max=pg_NumRows($Res);
- $r=ExecSql($this->cn,'select jrn_Def_name from jrn_Def where jrn_Def_id='.
- $this->jrn_def_id);
- $jrn_name=pg_fetch_result($r,0,0);
- echo '
- Base de donnée ".domaine."mod".$_POST['ob_id']." est accèdée, déconnectez-vous d'abord
";
- print '';
- exit;
- }
- ob_flush();
- $sql="delete from priv_user where priv_id in (select jnt_id from jnt_use_dos where dos_id=".$_REQUEST['ob_id'].")";
- ExecSql($cn,$sql);
- $sql="delete from jnt_use_dos where dos_id=".$_REQUEST['ob_id'];
- ExecSql($cn,$sql);
- $sql="delete from ac_dossier where dos_id=".$_REQUEST['ob_id'];
- ExecSql($cn,$sql);
- print '
';
- print "Voilà le modèle $name est effacé";
- print "
";
- print '';
-
- }
- }
- else
- {
- print '
';
- print "$msg $name n'est pas effacé";
- print '
';
-
- return $r;
- }
-/*!
- **************************************************
- * \brief Display a form to enter info about
- * a parm_code object with the
';
-
-$msg_tva='Si le montant de TVA est égal à 0, il sera automatiquement calculé';
-
-// First we show the menu
-// If nothing is asked the propose a blank form
-// to enter a new invoice
-if ( ! isset ($_REQUEST['p_jrn'])) {
- // no journal are selected so we select the first one
- $p_jrn=GetFirstJrnIdForJrnType(dossier::id(),'ACH');
-
-} else
-{
- $p_jrn=$_REQUEST['p_jrn'];
-}
-// for the back button
-$retour="";
-$h_url="";
-
-if ( isset ($_REQUEST['url']))
-{
- $retour=widget::button_href('Retour',urldecode($_REQUEST['url']));
-
- $h_url=sprintf('',urldecode($_REQUEST['url']));
-}
-
-$sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
-//--------------------------------------------------------------------------------
-// use a predefined operation
-//--------------------------------------------------------------------------------
-if ( $sub_action=="use_opd" ) {
-echo '
';
- exit();
- }
-
-//-----------------------------------------------------
-// If a list of depense is asked
-//
-if ( $sub_action == "list")
-{
- // show the menu with the list item selected
- echo '
';
- // Ask to update payment
- if ( isset ( $_GET['paid']))
- {
- // reset all the paid flag because the checkbox is post only
- // when checked
- foreach ($_GET 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 ($_GET 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);
- }
-
- }
-
- echo '
';
-
- // 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);
- }
-
- }
- /* security put a filter on the ledger */
- $available_ledger=$User->get_ledger_sql();
-
-// Show list of unpaid sell
-// Date - date of payment - Customer - amount
- $sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and $available_ledger ".
- " and jrn_def_type='ACH'";
- $offset=(isset($_GET['offset']))?$_GET['offset']:0;
- $step=$_SESSION['g_pagesize'];
- $page=(isset($_GET['offset']))?$_GET['page']:1;
-
- list ($max_line,$list)=ListJrn($cn,0,$sql,null,$offset,1);
- // $bar=jrn_navigation_bar($offset,$max_ligne,$step,$page);
-
-
- $sql=SQL_LIST_UNPAID_INVOICE." and jrn_def_type='ACH' and $available_ledger";
- list ($max_line2,$list2)=ListJrn($cn,0,$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 '
';
-//-----------------------------------------------------
-// if we request to add an item
-// the $_POST['add_item'] is set
-// or if we ask to correct the invoice
-if ( isset ($_POST['add_item']) || isset ($_POST["correct"]) )
-{
- if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) {
- NoAccess();
- exit -1;
- }
-
- $nb_item=$_POST['nb_item'];
- if ( isset ($_POST['add_item']))
- $nb_item++;
- // Submit button in the form
- $submit='
- ';
-
- $form=FormAchInput($cn,$p_jrn,$User->get_periode(),$_POST,$submit,false,$nb_item);
- echo '
';
-
-/*!\file
- * \brief the purpose off this file is to create invoices, to record them and to generate
- * them, and of course to save them into the database
- *
- */
-
-
-// First we show the menu
-// If nothing is asked the propose a blank form
-// to enter a new invoice
-if ( ! isset ($_REQUEST['p_jrn'])) {
- // no journal are selected so we select the first one
- $p_jrn=GetFirstJrnIdForJrnType($gDossier,'VEN');
-} else
-{
- $p_jrn=$_REQUEST['p_jrn'];
-}
-// for the back button
-$retour="";
-$h_url="";
-
-if ( isset ($_REQUEST['url']))
-{
- $retour=widget::button_href('Retour',urldecode($_REQUEST['url']));
-
- $h_url=sprintf('',urldecode($_REQUEST['url']));
-}
-
-$sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
-//-----------------------------------------------------
-// If a list of invoice is asked
-//
-if ( $sub_action == "list")
-{
- // Check privilege
- /* if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) < 1 ) {
- NoAccess();
- exit -1;
- }
- */
- // show the menu with the list item selected
- echo '
';
- // Ask to update payment
- if ( isset ( $_GET['paid']))
- {
- // reset all the paid flag because the checkbox is post only
- // when checked
- foreach ($_GET 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 ($_GET 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);
- }
-
- }
-
- echo '
';
-
- // 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
- // Nav. bar
- $step=$_SESSION['g_pagesize'];
- $page=(isset($_GET['offset']))?$_GET['page']:1;
- $offset=(isset($_GET['offset']))?$_GET['offset']:0;
- /* security put a filter on the ledger */
- $available_ledger=$User->get_ledger_sql();
-
-
- $sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and jrn_def_type='VEN' and $available_ledger";
- list($max_line,$list)=ListJrn($cn,0,$sql,null,$offset,1);
- $sql=SQL_LIST_UNPAID_INVOICE." and ".$available_ledger.
- " and jrn_def_type='VEN'";
- list($max_line2,$list2)=ListJrn($cn,0,$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 '
';
- exit();
- }
-
-//-----------------------------------------------------
-// if we request to add an item
-// the $_POST['add_item'] is set
-// or if we ask to correct the invoice
-if ( isset ($_POST['add_item']) || isset ($_POST["correct_new_invoice"]) )
-{
- if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) {
- NoAccess();
- exit -1;
- }
-
- $nb_item=$_POST['nb_item'];
- if ( isset ($_POST['add_item']))
- $nb_item++;
- $form=FormVenInput($cn,$p_jrn,$User->get_periode(),$_POST,false,$nb_item);
- echo '
';
- echo $form;
- echo '
';
- exit();
-}
-//-----------------------------------------------------
-// we want to save the invoice and to generate a invoice
-//
-if ( isset($_POST['record_and_print_invoice']))
-{
- if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) {
- NoAccess();
- exit -1;
- }
- $nb_number=$_POST['nb_item'];
- // First we save the invoice, the internal code will be used to change the description
- // and upload the file
- if ( form_verify_input($cn,$p_jrn,$User->get_periode(),$_POST,$nb_number)== true) {
- list ($internal,$e)=RecordInvoice($cn,$_POST,$User,$p_jrn);
- $form=FormVenteView($cn,$p_jrn,$User->get_periode(),$_POST,$_POST['nb_item'],'noform','');
-
- echo '
';
- echo '
Opération '.$internal.' enregistré
';
- echo $form;
- echo '';
-
- // Show the details of the encoded invoice
- // and the url of the invoice
- if ( isset($_POST['gen_invoice']))
- {
- $doc=new Document($cn);
- $doc->f_id=$_POST['e_client'];
- $doc->md_id=$_POST['gen_doc'];
- $doc->ag_id=0;
- $str_file=$doc->Generate();
- // Move the document to the jrn
- $doc->MoveDocumentPj($internal);
- // Update the comment with invoice number
- $sql="update jrn set jr_comment='Facture ".$doc->d_number."' where jr_internal='$internal'";
- ExecSql($cn,$sql);
- /* Save the additional information into jrn_info */
- $obj=new Acc_Ledger_Info($cn);
- $jr_id=$obj->search_id_internal($internal);
- if (strlen(trim($_POST['bon_comm'] )) != 0 ) {
- $obj->set_type('BON_COMMANDE');
- $obj->set_value($_POST['bon_comm']);
- $obj->insert();
- }
- if (strlen(trim($_POST['other_info'] )) != 0 ) {
- $obj->set_type('OTHER');
- $obj->set_value($_POST['other_info']);
- $obj->insert();
- }
- echo $str_file;
- }
- } else {
-
- echo("A cause d'erreur la facture ne peut-ètre validé ");
- $form=FormVenteView($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$nb_number,"form");
-
- }
-
- echo '';
- // Button return
- printf ('',
- $p_jrn,dossier::get());
- exit();
-}
-//-----------------------------------------------------
-// we show the confirmation screen it is proposed here to generate the
-// invoice
-if ( isset ($_POST['view_invoice']) )
-{
- // Check privilege
- if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) < 1 ) {
- NoAccess();
- exit -1;
- }
- $nb_number=$_POST["nb_item"];
- if ( form_verify_input($cn,$p_jrn,$User->get_periode(),$_POST,$nb_number) == true)
- {
- $form=FormVenteView($cn,$p_jrn,$User->get_periode(),$_POST,$nb_number);
-
- } else {
- // Check failed : invalid date or quantity
- echo_error("Cannot validate ");
- $form=FormVenInput($cn,$p_jrn,$User->get_periode(),$_POST,false,$nb_number);
- }
-
- echo '
';
- echo $form;
- echo '
';
- exit();
-
-}
-
-
-
-//-----------------------------------------------------
-// By default we add a new invoice
-if ( $p_jrn != -1 )
-{
- if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) {
- exit -1;
- }
-
- $jrn=new Acc_Ledger($cn, $p_jrn);
- echo_debug('facture.inc.php.php',__LINE__,"Blank form");
- // Show an empty form of invoice
- $form=FormVenInput($cn,$p_jrn,$User->get_periode(),null,false,$jrn->GetDefLine());
- 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->get_periode(),$_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->get_periode(),$_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->get_periode(),$_POST,$nb_number) == true ) {
- // Should use a read only view instead of FormAch
- // where we can check
- $r=FormAchView($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$submit,$nb_number);
- } else {
- // if something goes wrong, correct it
- $submit='
- ';
- $r=FormAchInput($cn,$_GET['p_jrn'],$User->get_periode(),$_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->get_periode(),$_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->get_exercice()."')";
- } 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 '
";
-
-
- }
-
- // 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=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number);
- echo '
';
- echo $r;
- echo "
On-line calculator
".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=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number);
- echo '
';
- echo $r;
- echo "
On-line calculator
".JS_CALC_LINE."
";
-
- echo "
";
- }
-
-
- // View the charge and show a submit button to save it
- if ( isset ($_POST['view_invoice']) ) {
- $nb_number=$_POST["nb_item"];
- $r=form_verify_input($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$nb_number);
- // if something goes wrong correct it
- if ( $r == null )
- {
- // submit button in the form
- $submit='
- ';
-
- $r=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number);
- }
- else
- {
- $submit='';
- $submit.='';
-
- $r=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$_POST,true,$nb_number);
- }
-
- echo '
';
- echo $r;
- echo "
On-line calculator
".JS_CALC_LINE."
";
- echo "
";
- }
- // Save the charge into database
- if ( isset($_POST['save'] )) {
- $internal=RecordFin($cn,$_POST,$User,$_GET['p_jrn']);
- // Get number of lines
- $nb_number=$_POST["nb_item"];
-
- // submit button in the form
- //$submit='
-
-
-get_exercice()."')";
- } else {
- $cond=" and jr_tech_per=".$current;
- }
-
- // Date - date of payment - Customer - amount
- $sql=SQL_LIST_ALL_INVOICE.$cond." and jr_def_id=".$_GET['p_jrn'];
-
- // Nav. bar
- $step=$_SESSION['g_pagesize'];
- $page=(isset($_GET['offset']))?$_GET['page']:1;
- $offset=(isset($_GET['offset']))?$_GET['offset']:0;
- // SQL
- list($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset);
-
- $bar=jrn_navigation_bar($offset,$max_line,$step,$page);
-
- echo $bar;
- echo $list;
- echo $bar;
- echo '
';
-}
-//-----------------------------------------------------
-// balance
-//-----------------------------------------------------
-if ( $action == 'solde' ) {
- require_once("poste.php");
- // find the bank account
- // NOTE : those values are in a table because
- // they are _national_ parameters
- $banque=new Acc_Parm_Code($cn,'BANQUE');
- $caisse=new Acc_Parm_Code($cn,'CAISSE');
- $vir_interne=new Acc_Parm_Code($cn,'VIREMENT_INTERNE');
- $accountSql="select distinct pcm_val::text,pcm_lib from
- tmp_pcmn
- where pcm_val::text like '".$banque->p_value."%' or pcm_val::text like '".$vir_interne->p_value."%'
- or pcm_val::text like '".$caisse->p_value."%'
- order by pcm_val::text";
- $ResAccount=ExecSql($cn,$accountSql);
- echo '
';
- echo "
";
- // for each account
- for ( $i = 0; $i < pg_NumRows($ResAccount);$i++) {
- // get the saldo
- $l=pg_fetch_array($ResAccount,$i);
- $m=get_solde($cn,$l['pcm_val'],' and j_tech_per in (select '.
- 'p_id from parm_periode where p_exercice='.$User->get_exercice().') ');
- // print the result if the saldo is not equal to 0
- if ( $m != 0.0 ) {
- 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=FormODS($cn,$_POST['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number);
- echo '
';
- echo $r;
- echo "
On-line calculator
".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=FormODS($cn,$_POST['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number);
- echo '
';
- echo $r;
- echo "
On-line calculator
".JS_CALC_LINE."
";
- echo "
";
- }
-
-
- // View the charge and show a submit button to save it
- // TODO: the name 'view_invoice' should be changed to something more self-explaining, like
- // 'submit_od', no?
- if ( isset ($_POST['view_invoice']) ) {
- $nb_number=$_POST["nb_item"];
- $submit='';
- if ( $own->MY_ANALYTIC != "nu" )
- $submit.='';
- $submit.='';
-
- $r=FormODS($cn,$_POST['p_jrn'],$User->get_periode(),$submit,$_POST,true,$nb_number);
-
- // if something goes wrong, correct it
- if ( $r == null ) {
- // submit button in the form
- $submit='
- ';
-
- $r=FormODS($cn,$_POST['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number);
- }else {
- $submit='
- ';
-
-
- }
- echo '
';
- echo $r;
- echo "
On-line calculator
".JS_CALC_LINE."
";
- echo "
";
- }
- // Save the change into database
- if ( isset($_POST['save'] )) {
- $r=RecordODS($cn,$_POST,$User,$_POST['p_jrn']);
- // Get number of lines
- $nb_number=$_POST["nb_item"];
- if ( $r != null ) {
- // submit button in the form
- $submit='
';
- 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 '
';
- } else {
-
- echo("A cause d'erreur la facture ne peut-ètre validé ");
- $form=FormVenteView($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$nb_number,"form");
- }
-
- echo '
';
- echo $form;
- echo "
";
-}
-
-
- if ( $action == 'voir_jrn' ) {
- // Check privilege
- if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) < 1 ) {
- NoAccess();
- exit -1;
- }
- // Extract the page number we want
- $debut=(isset($_REQUEST['p_page']))?$_REQUEST['p_page']:0;
-
-
-?>
-
-
-
-$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
- // 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->get_exercice()."')";
- } 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_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
- $bar=jrn_navigation_bar($offset,$max_line,$step,$page);
-
- echo "$bar";
- echo '';
- echo "$bar ";
-
- 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
- // Nav. bar
- $step=$_SESSION['g_pagesize'];
- $page=(isset($_GET['offset']))?$_GET['page']:1;
- $offset=(isset($_GET['offset']))?$_GET['offset']:0;
-
- $sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and jr_def_id=".$_GET['p_jrn'] ;
- list($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
- $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 '