From ab4cc9bd10c5acf0f3c3981915ed941a4b6ea41a Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 7 Mar 2011 14:30:26 +0000 Subject: [PATCH] Merged revisions 4035,4037-4048 via svnmerge from file:///home/developper/svn/phpcompta/branches/rel550 ........ r4037 | danydb | 2011-03-05 14:03:18 +0100 (Sat, 05 Mar 2011) | 2 lines Add request_to_hidden, post_to_hidden functions ........ r4038 | danydb | 2011-03-05 14:04:31 +0100 (Sat, 05 Mar 2011) | 2 lines add doc. function get_to_hidden post_to_hidden ........ r4039 | danydb | 2011-03-05 14:37:20 +0100 (Sat, 05 Mar 2011) | 1 line Fix javascript problem with date ........ r4040 | danydb | 2011-03-05 16:29:52 +0100 (Sat, 05 Mar 2011) | 2 lines Bug cannot get the last date ........ r4041 | danydb | 2011-03-05 16:52:57 +0100 (Sat, 05 Mar 2011) | 1 line Add default_value, request_to_hidden function ........ r4042 | danydb | 2011-03-05 16:53:15 +0100 (Sat, 05 Mar 2011) | 1 line Add sublevel to balance ........ r4043 | danydb | 2011-03-05 16:53:32 +0100 (Sat, 05 Mar 2011) | 1 line Add bank saldo ........ r4044 | danydb | 2011-03-05 17:06:37 +0100 (Sat, 05 Mar 2011) | 2 lines 234 limite dans les dossier afficher en administration ........ r4045 | danydb | 2011-03-05 17:12:33 +0100 (Sat, 05 Mar 2011) | 2 lines bug 234 ........ r4046 | danydb | 2011-03-07 13:05:48 +0100 (Mon, 07 Mar 2011) | 1 line add_todo_list was removed ........ r4047 | danydb | 2011-03-07 13:13:48 +0100 (Mon, 07 Mar 2011) | 1 line Bug IDate ........ --- html/get_saldo.php | 10 ++-- html/js/acc_ledger.js | 2 +- html/print_balance.php | 66 +++++++++++++++++++++---- include/balance.inc.php | 71 +++++++++++++++++++++++++++ include/class_acc_ledger_fin.php | 6 ++- include/class_html_input.php | 82 ++++++++++++++++++++++++++++---- include/class_idate.php | 9 ++-- include/compta_fin.inc.php | 2 +- include/dossier.inc.php | 4 +- include/template/dashboard.php | 3 +- 10 files changed, 220 insertions(+), 35 deletions(-) diff --git a/html/get_saldo.php b/html/get_saldo.php index 552c47158..10ffea552 100644 --- a/html/get_saldo.php +++ b/html/get_saldo.php @@ -49,12 +49,11 @@ if ( $user->check_jrn($_GET['j'])=='X' ) return '{"saldo":"0"}'; $filter_year=" j_tech_per in (select p_id from parm_periode ". "where p_exercice='".$user->get_exercice()."')"; -$acc=new Fiche($cn); -$acc->get_by_qcode($_GET['ctl'],false); -if ( $acc->belong_ledger($_GET['j']) == -1 ) - return '{"saldo":"0"}'; -$res=$acc->get_solde_detail($filter_year); +$id=$cn->get_value('select jrn_def_bank from jrn_def where jrn_def_id=$1',array($_GET['j'])); +$acc=new Fiche($cn,$id); + +$res=$acc->get_bk_balance($filter_year." and ( trim(jr_pj_number) != '' and jr_pj_number is not null)" ); if ( empty($res) ) return '{"saldo":"0"}'; @@ -62,7 +61,6 @@ $solde=$res['solde']; if ( $res['debit'] < $res['credit'] ) $solde=$solde*(-1); //header("Content-type: text/html; charset: utf8",true); - echo '{"saldo":"'.$solde.'"}'; diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 365c86f03..44c48e1aa 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -170,7 +170,7 @@ function success_get_last_date(req) var name_ctl=a[0].firstChild.nodeValue; var code_html=getNodeText(html[0]); code_html=unescape_xml(code_html); - $(name_ctl).value=code_html; + document.getElementsByName(name_ctl)[0].value=code_html; } catch (e) { diff --git a/html/print_balance.php b/html/print_balance.php index 2ae29234a..9b497f129 100644 --- a/html/print_balance.php +++ b/html/print_balance.php @@ -105,8 +105,56 @@ $tp_deb=0; $tp_cred=0; $tp_sold=0; $tp_solc=0; +foreach(array('sum_cred','sum_deb','solde_deb','solde_cred') as $a) + { + $nlvl1[$a]=0; + $nlvl2[$a]=0; + $nlvl3[$a]=0; + } +$lvl1_old=''; +$lvl2_old=''; +$lvl3_old=''; + +bcscale(2); + for ($i=0;$iSetFont('DejaVu','B',7); + $pdf->Cell(30,6,"Totaux ".$ind); + $pdf->Cell(80,6,${'lvl'.$ind.'_old'}); + $pdf->Cell(20,6,nbm(${'nlvl'.$ind}['sum_deb']),0,0,'R'); + $pdf->Cell(20,6,nbm(${'nlvl'.$ind}['sum_cred']),0,0,'R'); + $pdf->Cell(20,6,nbm(${'nlvl'.$ind}['solde_deb']),0,0,'R'); + $pdf->Cell(20,6,nbm(${'nlvl'.$ind}['solde_cred']),0,0,'R'); + $pdf->Ln(); + $pdf->SetFont('DejaVuCond','',7); + ${'lvl'.$ind.'_old'}=substr($r['poste'],0,$ind); + foreach(array('sum_cred','sum_deb','solde_deb','solde_cred') as $a) + { + ${'nlvl'.$ind}[$a]=0; + } + // xdebug_print_function_stack();exit(); + } + } + foreach(array('sum_cred','sum_deb','solde_deb','solde_cred') as $a) + { + $nlvl1[$a]=bcadd($nlvl1[$a],$r[$a]); + $nlvl2[$a]=bcadd($nlvl2[$a],$r[$a]); + $nlvl3[$a]=bcadd($nlvl3[$a],$r[$a]); + } + if ( $i % 2 == 0 ) { $pdf->SetFillColor(220,221,255); @@ -117,7 +165,7 @@ for ($i=0;$iSetFillColor(0,0,0); $fill=0; } - if ( ! isset($array[$i]))continue; + $pdf->Cell(30,6,$array[$i]['poste'],0,0,'L',$fill); $pdf->Cell(80,6,$array[$i]['label'],0,0,'L',$fill); $pdf->Cell(20,6,nbm($array[$i]['sum_deb']),0,0,'R',$fill); @@ -125,19 +173,19 @@ for ($i=0;$iCell(20,6,nbm($array[$i]['solde_deb']),0,0,'R',$fill); $pdf->Cell(20,6,nbm($array[$i]['solde_cred']),0,0,'R',$fill); $pdf->Ln(); - $tp_deb+=$array[$i]['sum_deb']; - $tp_cred+=$array[$i]['sum_cred']; - $tp_sold+=$array[$i]['solde_deb']; - $tp_solc+=$array[$i]['solde_cred']; + $tp_deb=bcadd($tp_deb,$array[$i]['sum_deb']); + $tp_cred=bcadd($tp_cred,$array[$i]['sum_cred']); + $tp_sold=bcadd($tp_sold,$array[$i]['solde_deb']); + $tp_solc=bcadd($tp_solc,$array[$i]['solde_cred']); } // Totaux $pdf->SetFont('DejaVuCond','B',8); $pdf->Cell(110,6,'Totaux'); -$pdf->Cell(20,6,$tp_deb,'T',0,'R',0); -$pdf->Cell(20,6,$tp_cred,'T',0,'R',0); -$pdf->Cell(20,6,$tp_sold,'T',0,'R',0); -$pdf->Cell(20,6,$tp_solc,'T',0,'R',0); +$pdf->Cell(20,6,nbm($tp_deb),'T',0,'R',0); +$pdf->Cell(20,6,nbm($tp_cred),'T',0,'R',0); +$pdf->Cell(20,6,nbm($tp_sold),'T',0,'R',0); +$pdf->Cell(20,6,nbm($tp_solc),'T',0,'R',0); $pdf->Ln(); diff --git a/include/balance.inc.php b/include/balance.inc.php index f6561c980..31d418095 100644 --- a/include/balance.inc.php +++ b/include/balance.inc.php @@ -106,6 +106,31 @@ if ( isset($_GET['p_filter']) && $_GET['p_filter']==2) $rad->selected='t'; else $rad->selected=false; echo '
  • '.$rad->input('p_filter',2).'Filtré par catégorie'.HtmlInput::select_cat($array_cat).'
  • '; echo ''; +echo 'Totaux par sous-niveaux'; +$ck_lev1=new ICheckBox('lvl1'); +$ck_lev2=new ICheckBox('lvl2'); +$ck_lev3=new ICheckBox('lvl3'); +$ck_lev1->value=1; +$ck_lev2->value=1; +$ck_lev3->value=1; + + +echo '
      '; + +if (HtmlInput::default_value('lvl1',false,$_GET) !== false) + $ck_lev1->selected=true; +if (HtmlInput::default_value('lvl2',false,$_GET) !== false) + $ck_lev2->selected=true; +if (HtmlInput::default_value('lvl3',false,$_GET) !== false) + $ck_lev3->selected=true; +echo '
    • '.$ck_lev1->input().'Niveau 1
    • '; +echo '
    • '.$ck_lev2->input().'Niveau 2
    • '; +echo '
    • '.$ck_lev3->input().'Niveau 3
    • '; + + + +echo '
    '; + $from_poste=new IPoste(); $from_poste->name="from_poste"; @@ -162,6 +187,8 @@ if ( isset ($_GET['view'] ) ) echo HtmlInput::hidden("from_poste",$_GET['from_poste']). HtmlInput::hidden("to_poste",$_GET['to_poste']); + echo HtmlInput::get_to_hidden(array('lvl1','lvl2','lvl3')); + echo ""; echo '
    '. @@ -228,6 +255,17 @@ if ( isset($_GET['view'] ) ) echo 'Solde Créditeur'; $i=0; + foreach(array('sum_cred','sum_deb','solde_deb','solde_cred') as $a) + { + $lvl1[$a]=0; + $lvl2[$a]=0; + $lvl3[$a]=0; + } + $lvl1_old=''; + $lvl2_old=''; + $lvl3_old=''; + + bcscale(2); foreach ($row as $r) { $i++; @@ -238,6 +276,38 @@ if ( isset($_GET['view'] ) ) $view_history= sprintf('%s', $r['poste'], $gDossier, $r['poste']); + /* + * level x + */ + foreach (array(3,2,1) as $ind) + { + if ( ! isset($_GET['lvl'.$ind]))continue; + if (${'lvl'.$ind.'_old'} == '') ${'lvl'.$ind.'_old'}=substr($r['poste'],0,$ind); + if ( ${'lvl'.$ind.'_old'} != substr($r['poste'],0,$ind)) + { + + echo ''; + echo td("Total niveau ".$ind); + echo td(${'lvl'.$ind.'_old'}); + echo td(nbm(${'lvl'.$ind}['sum_deb']),'style="text-align:right"'); + echo td(nbm(${'lvl'.$ind}['sum_cred']),'style="text-align:right"'); + echo td(nbm(${'lvl'.$ind}['solde_deb']),'style="text-align:right"'); + echo td(nbm(${'lvl'.$ind}['solde_cred']),'style="text-align:right"'); + + echo ''; + ${'lvl'.$ind.'_old'}=substr($r['poste'],0,$ind); + foreach(array('sum_cred','sum_deb','solde_deb','solde_cred') as $a) + { + ${'lvl'.$ind}[$a]=0; + } + } + } + foreach(array('sum_cred','sum_deb','solde_deb','solde_cred') as $a) + { + $lvl1[$a]=bcadd($lvl1[$a],$r[$a]); + $lvl2[$a]=bcadd($lvl2[$a],$r[$a]); + $lvl3[$a]=bcadd($lvl3[$a],$r[$a]); + } echo ''; echo td($view_history); echo td(h($r['label'])); @@ -246,6 +316,7 @@ if ( isset($_GET['view'] ) ) echo td(nbm($r['solde_deb']),'style="text-align:right"'); echo td(nbm($r['solde_cred']),'style="text-align:right"'); echo ''; + } echo ''; diff --git a/include/class_acc_ledger_fin.php b/include/class_acc_ledger_fin.php index 6899c3307..d45f42a98 100644 --- a/include/class_acc_ledger_fin.php +++ b/include/class_acc_ledger_fin.php @@ -247,9 +247,11 @@ class Acc_Ledger_Fin extends Acc_Ledger // Ledger (p_jrn) //-- - $add_js=""; + + $add_js='onchange="update_pj();update_bank();get_last_date();ajax_saldo(\'first_sold\')";'; - if ( $owner->MY_PJ_SUGGEST == 'Y') $add_js="onchange='update_pj();update_bank();get_last_date();'"; + if ( $owner->MY_DATE_SUGGEST == 'Y') + $add_js='onchange="update_pj();update_bank();get_last_date();ajax_saldo(\'first_sold\')";'; $wLedger=$this->select_ledger('FIN',2); if ($wLedger == null ) exit ('Pas de journal disponible'); diff --git a/include/class_html_input.php b/include/class_html_input.php index 41a05f6af..d40e58a4e 100755 --- a/include/class_html_input.php +++ b/include/class_html_input.php @@ -467,19 +467,83 @@ class HtmlInput return $r; } /** - *transform get to hidden + *transform request data to hidden + *@param $array is an of indices + *@param $request name of the superglobal $_POST $_GET $_REQUEST(default) + *@return html string with the hidden data + */ + static function array_to_hidden($array,$global_array ) + { + + $r=""; + + if ( count($global_array )==0) return ''; + foreach ($array as $a) + { + if (isset($global_array [$a])) $r.=HtmlInput::hidden($a,$global_array [$a]); + } + + return $r; + } + /** + *transform $_GET data to hidden + *@param $array is an of indices + *@see HtmlInput::request_to_hidden *@return html string with the hidden data */ static function get_to_hidden($array) { - if ( count($_GET) == 0) return ""; - $r=""; - foreach ( $array as $a) - { - if (isset($_GET[$a])) $r.=HtmlInput::hidden($a,$_GET[$a]); - } + $r=self::array_to_hidden($array,$_GET ); + return $r; + } + /** + *transform $_POST data to hidden + *@param $array is an of indices + *@see HtmlInput::request_to_hidden + *@return html string with the hidden data + */ + + static function post_to_hidden($array) + { + $r=self::array_to_hidden($array,$_POST ); + return $r; + } + /** + *transform $_REQUEST data to hidden + *@param $array is an of indices + *@see HtmlInput::request_to_hidden + *@return html string with the hidden data + */ + + static function request_to_hidden($array) + { + $r=self::array_to_hidden($array,$_REQUEST ); return $r; } -} - + /** + * generate an unique id for a widget, + *@param $p_prefix prefix + *@see HtmlInput::IDate + *@return string with a unique id + */ + static function generate_id($p_prefix) + { + $r=sprintf('%s_%d',$p_prefix,mt_rand(0,999999)); + return $r; + } + /** + * return default if the value if the array doesn't exist + *@param $ind the index to check + *@param $default the value to return + *@param $array the array + */ + static function default_value($ind,$default,$array) + { + if ( ! isset($array[$ind])) + { + return $default; + } + return $array[$ind]; + } +} \ No newline at end of file diff --git a/include/class_idate.php b/include/class_idate.php index 90e899eac..3cf5d2217 100644 --- a/include/class_idate.php +++ b/include/class_idate.php @@ -32,20 +32,21 @@ class IDate extends HtmlInput $this->name=($p_name==null)?$this->name:$p_name; $this->value=($p_value==null)?$this->value:$p_value; if ( $this->readOnly==true) return $this->display(); - $r='id=self::generate_id($this->name); + $r=''. - ''; $r.='