',urldecode($_REQUEST['url'])); $h_url=sprintf('',urldecode($_REQUEST['url'])); } $sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:""; //---------------------------------------------------------------------- // ask the saldo of the bank if ( $sub_action == "solde" ) { // Check privilege if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) < 1 ) { NoAccess(); exit -1; } echo '
'; echo ShowMenuJrnUser($gDossier,'FIN',0,'Liste'. 'Solde'); echo '
'; require_once("poste.php"); // find the bank account // NOTE : those values are in a table because // they are _national_ parameters $banque=new parm_code($cn,'BANQUE'); $caisse=new parm_code($cn,'CAISSE'); $vir_interne=new parm_code($cn,'VIREMENT_INTERNE'); $accountSql="select distinct pcm_val::text,pcm_lib from tmp_pcmn where pcm_val like '".$banque->p_value."%' or pcm_val like '".$vir_interne->p_value."%' or pcm_val like '".$caisse->p_value."%' order by pcm_val::text"; $ResAccount=ExecSql($cn,$accountSql); echo '
'; echo ""; // Filter the saldo // on the current year $filter_year=" and j_tech_per in (select p_id from parm_periode where p_exercice='".$User->getExercice()."')"; // for each account for ( $i = 0; $i < pg_NumRows($ResAccount);$i++) { // get the saldo $l=pg_fetch_array($ResAccount,$i); $m=GetSolde($cn,$l['pcm_val'],$filter_year); // print the result if the saldo is not equal to 0 if ( $m != 0.0 ) { echo ""; echo "". ""."".""; } }// for echo "
". $l['pcm_val']. "". $l['pcm_lib']. "". $m. "
"; echo "
"; exit(); } //----------------------------------------------------- // If a list of depense 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 '
'; echo ShowMenuJrnUser($gDossier,'FIN',0,'Liste'. 'Solde'); echo '
'; echo '
'; echo '
'; echo dossier::hidden(); $hid=new widget("hidden"); $hid->name="p_action"; $hid->value="bank"; echo $hid->IOValue(); $hid->name="sa"; $hid->value="list"; echo $hid->IOValue(); $w=new widget("select"); // filter on the current year $filter_year=" where p_exercice='".$User->getExercice()."'"; $periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end",1); // User is already set User=new cl_user($cn); $current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->GetPeriode(); $w->selected=$current; echo 'Période '.$w->IOValue("p_periode",$periode_start); $qcode=(isset($_GET['qcode']))?$_GET['qcode']:""; echo JS_SEARCH_CARD; $w=new widget('js_search_only'); $w->name='qcode'; $w->value=$qcode; $w->label=''; $w->extra='4'; $sp= new widget("span"); echo $sp->IOValue("qcode_label",$qcode).""; echo $w->IOValue(); echo $w->Submit('gl_submit','Rechercher'); echo '
'; echo $retour; // Show list of sell // Date - date of payment - Customer - amount if ( $current != -1 ) { $filter_per=" and jr_tech_per=".$current; } else { $filter_per=" and jr_tech_per in (select p_id from parm_periode where p_exercice=". $User->getExercice().")"; } // Show list of sell // Date - date of payment - Customer - amount $sql=SQL_LIST_ALL_INVOICE.$filter_per." and jr_def_type='FIN'" ; $step=$_SESSION['g_pagesize']; $page=(isset($_GET['offset']))?$_GET['page']:1; $offset=(isset($_GET['offset']))?$_GET['offset']:0; $l=""; // check if qcode contains something if ( $qcode != "" ) { // add a condition to filter on the quick code $l=" and jr_grpt_id in (select j_grpt from jrnx where j_qcode='$qcode') "; } list($max_line,$list)=ListJrn($cn,0,"where jrn_def_type='FIN' $filter_per $l " ,null,$offset,0); $bar=jrn_navigation_bar($offset,$max_line,$step,$page); echo "
$bar"; echo $list; echo "$bar
"; echo $retour; echo '
'; exit(); } //----------------------------------------------------- echo '
'; echo ShowMenuJrnUser($gDossier,'FIN',$p_jrn, 'Liste'. 'Solde'); echo '
'; //-------------------------------------------------------------------------------- // use a predefined operation //-------------------------------------------------------------------------------- if ( $sub_action=="use_opd" ) { $op=new Pre_op_fin($cn); $op->set_od_id($_REQUEST['pre_def']); $p_post=$op->compute_array(); echo_debug(__FILE__.':'.__LINE__.'- ','p_post = ',$p_post); // submit button in the form $submit=''. ''; $form=FormFin($cn,$_GET['p_jrn'],$User->GetPeriode(),$submit,$p_post,false,$p_post['nb_item']); echo '
'; echo $form; 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']) ) { 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=FormFin($cn,$p_jrn,$User->GetPeriode(),$submit,$_POST,false, $nb_item); //$form=FormFin($cn,$p_jrn,$User->GetPeriode(),$submit,$_POST,false, $nb_number); echo '
'; echo $form; echo JS_CALC_LINE; echo '
'; exit(); } //----------------------------------------------------- // Save : record // if ( isset($_POST['save'])) { if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) { NoAccess(); exit -1; } // we save the expense $r=RecordFin($cn,$_POST,$User,$p_jrn); $nb_number=$_POST['nb_item']; $submit='

Opération '.$r.' enregistré

'; $form=FormFin($cn,$p_jrn,$User->GetPeriode(),$submit,$_POST,true,$nb_number,true); echo '
'; echo $form; echo '
'; echo ''; echo ' '; exit(); } //----------------------------------------------------- // we show the confirmation screen // if ( isset ($_POST['view_invoice']) ) { if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) { NoAccess(); exit -1; } $nb_number=$_POST["nb_item"]; $submit=''; $submit.=''; if ( form_verify_input ($cn,$p_jrn,$User->GetPeriode(),$_POST,$nb_number) != null ) { // Should use a read only view instead of FormFin // where we can check $form=FormFin($cn,$p_jrn,$User->GetPeriode(),$submit,$_POST,true, $nb_number,false); } else { // if something goes wrong, correct it $submit=' '; $form=FormFin($cn,$p_jrn,$User->GetPeriode(),$submit,$_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('depense.inc.php',__LINE__,"Blank form"); // Submit button in the form $submit=' '; // Show an empty form of invoice $form=FormFin($cn,$p_jrn,$User->GetPeriode(),$submit,null,false,$jrn->GetDefLine('deb')); echo '
'; echo $form; echo '
'; $op=new Pre_operation($cn); $op->p_jrn=$p_jrn; $op->od_direct='f'; $hid=new widget("hidden"); echo $hid->IOValue("p_action","bank"); echo $hid->IOValue("sa","use_opd"); echo dossier::hidden(); echo $hid->IOValue("p_jrn",$p_jrn); echo $hid->IOValue("jrn_type","FIN"); if ($op->count() != 0 ) echo widget::submit_button('use_opd','Utilisez une op.prédéfinie'); echo $op->show_button(); echo '
'; echo JS_CALC_LINE; echo '
'; }