From 4a75de6f8ccd67505cd4f7cae274900c2ec96ec0 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 13 Jul 2010 19:04:10 +0000 Subject: [PATCH] FS#104 Add the ability to select several ledgers for the search --- doc/developper/create_doc.sh | 4 +-- include/class_acc_ledger.php | 50 ++++++++++++++++-------------- include/class_html_input.php | 2 +- include/template/ledger_search.php | 2 +- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/doc/developper/create_doc.sh b/doc/developper/create_doc.sh index 8db50412c..23418cb8a 100755 --- a/doc/developper/create_doc.sh +++ b/doc/developper/create_doc.sh @@ -3,7 +3,7 @@ cd html; sed -i "s/utf-8/utf-8/g" * cd .. if [ ! -z "$PGUSER" ] ; then echo "DOMAINE = $DOMAIN" - postgresql_autodoc -u $PGUSER --password $PGPASSWORD -h localhost -d ${DOMAIN}mod1 - postgresql_autodoc -u $PGUSER --password $PGPASSWORD -h localhost -d ${DOMAIN}account_repository + postgresql_autodoc -u $PGUSER --password=$PGPASSWORD -h localhost -d ${DOMAIN}mod1 + postgresql_autodoc -u $PGUSER --password=$PGPASSWORD -h localhost -d ${DOMAIN}account_repository fi cd ../../ && bash dev/compose_list.sh diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php index 8cafa3cb3..30290dd67 100644 --- a/include/class_acc_ledger.php +++ b/include/class_acc_ledger.php @@ -2027,24 +2027,12 @@ function get_last_date() $user=new User($this->db); $r=''; /* security : filter ledger on user */ - $filter_ledger=$user->get_ledger_sql($p_type,3); + $filter_ledger=$user->get_ledger($p_type,3); - $f_ledger=new ISelect('p_jrn'); - $aLedger=$this->db->make_array('select jrn_def_id,jrn_def_name from jrn_def where '.$filter_ledger); - if ( $all_type_ledger==1) - $aLedger[]=array('value'=>-1,'label'=>'Tous les journaux'); - - /* if not p_jrn then all */ - if( ! isset($_REQUEST['p_jrn'])) { - /* By default all ledger of this type */ - $this->id=-1; - } else { - $this->id=$_REQUEST['p_jrn']; - } - $f_ledger->selected=$this->id; - $f_ledger->value=$aLedger; - - /* widget for date_start */ + $selected=(isset($_REQUEST['r_jrn']))?$_REQUEST['r_jrn']:null; + $f_ledger=HtmlInput::select_ledger($filter_ledger,$selected); + + /* widget for date_start */ $f_date_start=new IDate('date_start'); /* all periode or only the selected one */ if ( isset($_REQUEST['date_start'])) { @@ -2160,6 +2148,7 @@ function get_last_date() if ( $p_array != null ) extract($p_array); + $r_jrn=(isset($r_jrn))?$r_jrn:-1; /* if no variable are set then give them a default * value */ @@ -2174,7 +2163,6 @@ function get_last_date() list($date_start,$date_end)=$per->get_date_limit(); } $desc=''; - $p_jrn=(isset($p_jrn))?$p_jrn:-1; $qcode=(isset($qcode))?$qcode:""; $accounting=(isset($accounting))?$accounting:""; @@ -2192,8 +2180,9 @@ function get_last_date() $fil_paid=''; $and=''; - if ( $p_jrn == -1 ) { - $user=new User($this->db); + $user=new User($this->db); + + if ( $r_jrn == -1 ) { /* Specific action allow to see all the ledgers in once */ if ( $p_action == 'gl') $p_action='ALL'; /* actions from commercial.php */ @@ -2205,11 +2194,24 @@ function get_last_date() $fil_ledger=$user->get_ledger_sql($p_action,3); $and=' and '; - } else if ( $p_jrn != 0 ){ - $fil_ledger = ' jrn_def_id = '.$p_jrn; - $and=' and '; - } + } else { + if ( $p_action == 'gl') $p_action='ALL'; + $aLedger=$user->get_ledger($p_action,3); + $fil_ledger='';$sp=''; + + for ($i=0;$i < count($aLedger) ;$i ++) { + if ( isset($r_jrn[$i])) {$fil_ledger.=$sp.$aLedger[$i]['jrn_def_id'];$sp=',';} + } + $fil_ledger=' jrn_def_id in ('.$fil_ledger.')'; + $and=' and '; + + /* no ledger selected */ + if ( $sp == '' ) { + $fil_ledger='';$and=''; + } + } + /* format the number */ $amount_min=toNumber($amount_min); $amount_max=toNumber($amount_max); diff --git a/include/class_html_input.php b/include/class_html_input.php index ab3f0b725..600753383 100755 --- a/include/class_html_input.php +++ b/include/class_html_input.php @@ -240,7 +240,7 @@ echo $string => {'prop':'1','prop2':'2','prop3':'3'}; static function select_ledger($p_array,$p_selected) { ob_start(); $ledger=new IButton('l'); - $ledger->label="Journaux"; + $ledger->label="choix des journaux"; $ledger->javascript=" show_ledger_choice()"; echo $ledger->input(); diff --git a/include/template/ledger_search.php b/include/template/ledger_search.php index 2ec8612b1..2f16c772e 100644 --- a/include/template/ledger_search.php +++ b/include/template/ledger_search.php @@ -5,7 +5,7 @@ -input() ?> +