diff --git a/html/js/scripts.js b/html/js/scripts.js index a2d95bf94..ee099d888 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -1306,7 +1306,7 @@ function search_reconcile(dossier, ctl_concern, amount_id, ledger, p_id_target,p var str_style = fixed_position(77, 99); str_style += ";width:92%;overflow:auto;"; waiting_box(); - + var hide_operation=$(ctl_concern).getAttribute("hide_operation"); var param_send = {gDossier: dossier, ctlc: ctl_concern, @@ -1315,7 +1315,8 @@ function search_reconcile(dossier, ctl_concern, amount_id, ledger, p_id_target,p amount_id: amount_id, ledger: ledger, target: target, - tiers:tiers + tiers:tiers, + hide_operation:hide_operation }; var qs = encodeJSON(param_send); diff --git a/include/ajax/ajax_search_operation.php b/include/ajax/ajax_search_operation.php index a279e5585..446c9beb4 100644 --- a/include/ajax/ajax_search_operation.php +++ b/include/ajax/ajax_search_operation.php @@ -50,6 +50,8 @@ if (isset($_GET['amount_id'])) )); } $target=$http->get("target", "string", ""); +$hide_operation=$http->get("hide_operation","string",""); + $ledger=new Acc_Ledger_Search('ALL', 1, $target); if ($base=='recherche.php'||$base=='do.php') @@ -103,7 +105,7 @@ if (isset($_GET['viewsearch'])) // get first date of current exercice list($array['date_start'], $array['date_end'])=$g_user->get_limit_current_exercice(); } - + $array['hide_operation']=$hide_operation; list($sql, $where)=$ledger->build_search_sql($array); // Count nb of line $max_line=$cn->count_sql($sql); diff --git a/include/class/acc_balance.class.php b/include/class/acc_balance.class.php index 485cf0bed..446b2ef8d 100644 --- a/include/class/acc_balance.class.php +++ b/include/class/acc_balance.class.php @@ -36,10 +36,10 @@ class Acc_Balance function __construct($p_cn) { $this->db=$p_cn; - $this->jrn=null; + $this->jrn=array(); $from_poste=""; $to_poste=""; - $unsold=false; + $unsold=false; } @@ -311,7 +311,7 @@ class Acc_Balance /* get the list of jrn of the cat. */ $array=Acc_Ledger::array_cat(); - $jrn=array(); + $this->jrn=array(); for ($e=0;$etype, $this->div."ledger_type"); $r.=HtmlInput::hidden('ac', $_REQUEST['ac']); + if (isset($_REQUEST['hide_operation'])) + $r.=HtmlInput::hidden("hide_operation", $_REQUEST['hide_operation']); ob_start(); $search_filter=$this->build_search_filter(); require_once NOALYSS_TEMPLATE.'/ledger_search.php'; @@ -383,6 +385,7 @@ class Acc_Ledger_Search $fil_account=''; $fil_paid=''; $fil_date_paid=''; + $fil_hide_operation=''; $and=''; $g_user=new User($this->cn); @@ -519,6 +522,11 @@ class Acc_Ledger_Search $fil_paid=$and.SQL_LIST_UNPAID_INVOICE; $and=" and "; } + if ( isset ($hide_operation) && trim($hide_operation) !="") + { + $fil_hide_operation=$and.sprintf( ' jr_id not in (%s)',sql_string($hide_operation)); + $and=" and "; + } global $g_user; if ($g_user->admin==0&&$g_user->is_local_admin()==0 && $g_user->get_status_security_ledger()==1 ) { @@ -528,7 +536,8 @@ class Acc_Ledger_Search " uj_login='".sql_string($_SESSION['g_user'])."'". " and uj_priv in ('R','W'))"; } - $where=$fil_ledger.$fil_amount.$fil_date.$fil_desc.$fil_sec.$fil_amount.$fil_qcode.$fil_paid.$fil_account.$fil_date_paid; + $where=$fil_ledger.$fil_amount.$fil_date.$fil_desc.$fil_sec.$fil_amount. + $fil_qcode.$fil_paid.$fil_account.$fil_date_paid.$fil_hide_operation; $sql.=" where ".$where; return array($sql, $where); } @@ -558,6 +567,7 @@ class Acc_Ledger_Search $r.=HtmlInput::hidden('ac', $_REQUEST['ac']); + /* when called from commercial.php some hidden values are needed */ if (isset($_REQUEST['sa'])) $r.=HtmlInput::hidden("sa", $_REQUEST['sa']); @@ -568,6 +578,9 @@ class Acc_Ledger_Search if (isset($_REQUEST['f_id'])) $r.=HtmlInput::hidden("f_id", $_REQUEST['f_id']); + + + $r.=''; $r.=''; diff --git a/include/export/export_balance_pdf.php b/include/export/export_balance_pdf.php index bc0d4eac7..e4d69df07 100644 --- a/include/export/export_balance_pdf.php +++ b/include/export/export_balance_pdf.php @@ -29,307 +29,302 @@ * \param e_comment invoice number */ // Copyright Author Dany De Bontridder danydb@aevalys.eu -if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis'); +if (!defined('ALLOWED')) die('Appel direct ne sont pas permis'); include_once("lib/ac_common.php"); -require_once NOALYSS_INCLUDE.'/lib/database.class.php'; +require_once NOALYSS_INCLUDE . '/lib/database.class.php'; include_once("class/acc_balance.class.php"); -require_once NOALYSS_INCLUDE.'/header_print.php'; -require_once NOALYSS_INCLUDE.'/class/dossier.class.php'; -require_once NOALYSS_INCLUDE.'/lib/pdf.class.php'; -require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; -$http=new HttpInput(); +require_once NOALYSS_INCLUDE . '/header_print.php'; +require_once NOALYSS_INCLUDE . '/class/dossier.class.php'; +require_once NOALYSS_INCLUDE . '/lib/pdf.class.php'; +require_once NOALYSS_INCLUDE . '/lib/http_input.class.php'; +$http = new HttpInput(); -$gDossier=dossier::id(); +$gDossier = dossier::id(); bcscale(4); -$cn=Dossier::connect(); -$rep=new Database(); -require_once NOALYSS_INCLUDE.'/class/user.class.php'; +$cn = Dossier::connect(); +$rep = new Database(); +require_once NOALYSS_INCLUDE . '/class/user.class.php'; $g_user->Check(); -$bal=new Acc_Balance($cn); -try -{ - $from_periode=$http->request("from_periode"); - $to_periode=$http->request("to_periode"); - $from_poste=$http->request("from_poste"); - $to_poste=$http->request("to_poste"); - $p_filter=$http->request("p_filter","string"); -} -catch (Exception $exc) -{ +$bal = new Acc_Balance($cn); +try { + $from_periode = $http->request("from_periode"); + $to_periode = $http->request("to_periode"); + $from_poste = $http->request("from_poste"); + $to_poste = $http->request("to_poste"); + $p_filter = $http->request("p_filter", "string"); +} catch (Exception $exc) { + error_log("Missing parameters"); error_log($exc->getTraceAsString()); return; } // Compute for the summary -$summary_tab=$bal->summary_init(); -$summary_prev_tab=$bal->summary_init(); -$is_summary=$http->get("summary","string", 0); - -$bal->jrn=null; -switch( $p_filter) -{ -case 0: - $bal->jrn=null; - break; -case 1: - if ( isset($_GET['r_jrn'])) - { - $selected=$_GET['r_jrn']; - $array_ledger=$g_user->get_ledger('ALL',3); - $array=get_array_column($array_ledger,'jrn_def_id'); - for ($e=0;$ejrn[]=$selected[$e]; +$summary_tab = $bal->summary_init(); +$summary_prev_tab = $bal->summary_init(); +$is_summary = $http->get("summary", "string", 0); + +$bal->jrn = null; +switch ($p_filter) { + case 0: + $bal->jrn = null; + break; + case 1: + if (isset($_GET['r_jrn'])) { + $selected = $http->get("r_jrn"); + $array_ledger = $g_user->get_ledger('ALL', 3); + $array = get_array_column($array_ledger, 'jrn_def_id'); + for ($e = 0; $e < count($selected); $e++) { + if (isset ($selected[$e]) + && isNumber($selected[$e]) == 1 + && in_array($selected[$e], $array)) { + $bal->jrn[] = $selected[$e]; + } + } } - } - break; -case 2: - if ( isset($_GET['r_cat'])) $bal->filter_cat($_GET['r_cat']); - break; + break; + case 2: + if (isset($_GET['r_cat'])) $bal->filter_cat($http->get("r_cat")); + break; } -$bal->from_poste=$from_poste; -$bal->to_poste=$to_poste; -if (isset($_GET['unsold'])) $bal->unsold=true; -$previous=(isset($_GET['previous_exc']))?1:0; - -$array=$bal->get_row($from_periode,$to_periode,$previous); +$bal->from_poste = $from_poste; +$bal->to_poste = $to_poste; +if (isset($_GET['unsold'])) $bal->unsold = true; +$previous = (isset($_GET['previous_exc'])) ? 1 : 0; -$previous= (isset ($array[0]['sum_cred_previous']))?1:0; +$array = $bal->get_row($from_periode, $to_periode, $previous); + +$previous = (isset ($array[0]['sum_cred_previous'])) ? 1 : 0; -if ( sizeof($array) == 0 ) -{ +if (sizeof($array) == 0) { exit(); } -$pPeriode=new Periode($cn); -$a=$pPeriode->get_date_limit($from_periode); -$b=$pPeriode->get_date_limit($to_periode); -$per_text=" du ".$a['p_start']." au ".$b['p_end']; +$pPeriode = new Periode($cn); +$a = $pPeriode->get_date_limit($from_periode); +$b = $pPeriode->get_date_limit($to_periode); +$per_text = sprintf(_("Du %s au %s" ), $a['p_start'] ,$b['p_end']); // If compare with previous exercice , // we use the landscape mode -if ($previous == 1 ) { - $pdf=new PDFLand($cn); +if ($previous == 1) { + $pdf = new PDFLand($cn); } else { - $pdf= new PDF($cn); + $pdf = new PDF($cn); } -$pdf->setDossierInfo(" Balance ".$per_text); +$pdf->setDossierInfo(" Balance " . $per_text); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetAuthor('NOALYSS'); -$pdf->SetFont('DejaVuCond','',7); -$pdf->setTitle(_("Balance comptable"),true); -$pdf->write_cell(30,6,_('poste')); -$pdf->LongLine(60,6,_('Libellé')); -if ($previous == 1 ){ - $pdf->write_cell(20,6,'Débit N-1',0,0,'R'); - $pdf->write_cell(20,6,'Crédit N-1',0,0,'R'); - $pdf->write_cell(20,6,'Solde N-1',0,0,'R'); +$pdf->SetFont('DejaVuCond', '', 7); +$pdf->setTitle(_("Balance comptable"), true); +$pdf->write_cell(30, 6, _('poste')); +$pdf->LongLine(60, 6, _('Libellé')); +if ($previous == 1) { + $pdf->write_cell(20, 6, 'Débit N-1', 0, 0, 'R'); + $pdf->write_cell(20, 6, 'Crédit N-1', 0, 0, 'R'); + $pdf->write_cell(20, 6, 'Solde N-1', 0, 0, 'R'); } -$pdf->write_cell(25,6,_('Ouverture'),0,0,'R'); -$pdf->write_cell(25,6,_('Total Débit'),0,0,'R'); -$pdf->write_cell(25,6,_('Total Crédit'),0,0,'R'); -$pdf->write_cell(25,6,_('Solde Débiteur'),0,0,'R'); +$pdf->write_cell(25, 6, _('Ouverture'), 0, 0, 'R'); +$pdf->write_cell(25, 6, _('Total Débit'), 0, 0, 'R'); +$pdf->write_cell(25, 6, _('Total Crédit'), 0, 0, 'R'); +$pdf->write_cell(25, 6, _('Solde'), 0, 0, 'R'); $pdf->line_new(); -$pdf->SetFont('DejaVuCond','',8); -$tp_deb=0; -$tp_cred=0; -$tp_sold=0; -$tp_solc=0; -$tp_deb_previous=0; -$tp_cred_previous=0; -$tp_sold_previous=0; -$tp_solc_previous=0; -if ( $previous == 1) { - $a_sum=array('sum_cred','sum_deb','solde_deb','solde_cred','sum_cred_previous','sum_deb_previous','solde_deb_previous','solde_cred_previous','sum_cred_ope','sum_deb_ope'); +$pdf->SetFont('DejaVuCond', '', 8); +$tp_deb = 0; +$tp_cred = 0; +$tp_sold = 0; +$tp_solc = 0; +$tot_opening = 0; +$tp_deb_previous = 0; +$tp_cred_previous = 0; +$tp_sold_previous = 0; +$tp_solc_previous = 0; +if ($previous == 1) { + $a_sum = array('sum_cred', 'sum_deb', 'solde_deb', 'solde_cred', 'sum_cred_previous', 'sum_deb_previous', 'solde_deb_previous', 'solde_cred_previous', 'sum_cred_ope', 'sum_deb_ope'); +} else { + $a_sum = array('sum_cred', 'sum_deb', 'solde_deb', 'solde_cred', 'sum_cred_ope', 'sum_deb_ope'); } -else { - $a_sum=array('sum_cred','sum_deb','solde_deb','solde_cred','sum_cred_ope','sum_deb_ope') ; +foreach ($a_sum as $a) { + $nlvl1[$a] = 0; + $nlvl2[$a] = 0; + $nlvl3[$a] = 0; } -foreach($a_sum as $a) - { - $nlvl1[$a]=0; - $nlvl2[$a]=0; - $nlvl3[$a]=0; - } -$lvl1_old=''; -$lvl2_old=''; -$lvl3_old=''; +$lvl1_old = ''; +$lvl2_old = ''; +$lvl3_old = ''; bcscale(2); -if (! empty($array)) - { - $i=0; - foreach ($array as $key=>$value) - { - $i++; - /* - * level x - */ - if ( $value['poste']=='') continue; - foreach (array(3,2,1) as $ind) - { - $r=$value; - if ( ! isset($_GET['lvl'.$ind]))continue; +if (!empty($array)) { + $i = 0; + foreach ($array as $key => $value) { + $i++; + /* + * level x + */ + if ($value['poste'] == '') continue; + foreach (array(3, 2, 1) as $ind) { + $r = $value; + 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)) { + $pdf->SetFont('DejaVu', 'B', 7); + $pdf->LongLine(30, 6, ${'lvl' . $ind . '_old'}); + $delta = bcsub(${'nlvl' . $ind}['solde_cred'], ${'nlvl' . $ind}['solde_deb']); + $side = ($delta < 0) ? "D" : "C"; + if ($previous == 1) { + $delta_previous = bcsub(${'nlvl' . $ind}['solde_cred_previous'], ${'nlvl' . $ind}['solde_deb_previous']); + $side_previous = ($delta_previous < 0) ? "D" : "C"; + $pdf->write_cell(60, 6, " ", 0, 0, 'R'); + $pdf->write_cell(22, 6, nbm(${'nlvl' . $ind}['sum_deb_previous']), 0, 0, 'R'); + $pdf->write_cell(22, 6, nbm(${'nlvl' . $ind}['sum_cred_previous']), 0, 0, 'R'); + $pdf->write_cell(22, 6, nbm(abs($delta_previous)) . " $side_previous", 0, 0, 'R'); - if (${'lvl'.$ind.'_old'} == '') ${'lvl'.$ind.'_old'}=substr($r['poste'],0,$ind); - if ( ${'lvl'.$ind.'_old'} != substr($r['poste'],0,$ind)) - { - $pdf->SetFont('DejaVu','B',7); - $pdf->LongLine(30,6,${'lvl'.$ind.'_old'}); - $delta=bcsub(${'nlvl'.$ind}['solde_cred'],${'nlvl'.$ind}['solde_deb']); - $side=($delta< 0) ? "D":"C"; - if ($previous == 1 ) { - $delta_previous=bcsub(${'nlvl'.$ind}['solde_cred_previous'],${'nlvl'.$ind}['solde_deb_previous']); - $side_previous=($delta_previous < 0) ? "D":"C"; - $pdf->write_cell(60,6," ",0,0,'R'); - $pdf->write_cell(22,6,nbm(${'nlvl'.$ind}['sum_deb_previous']),0,0,'R'); - $pdf->write_cell(22,6,nbm(${'nlvl'.$ind}['sum_cred_previous']),0,0,'R'); - $pdf->write_cell(22,6,nbm(abs($delta_previous))." $side_previous",0,0,'R'); - } else { - $pdf->write_cell(60,6," ",0,0,'R'); - + $pdf->write_cell(60, 6, " ", 0, 0, 'R'); + } - $solde_lv=bcsub(${'nlvl'.$ind}['sum_deb_ope'],${'nlvl'.$ind}['sum_cred_ope']); - $side_lv=($solde_lv<0)?" C":" D"; - $side_lv=($solde_lv==0)?" ":$side_lv; - $pdf->write_cell(25,6,nbm(abs($solde_lv)).$side_lv,0,0,'R'); - $pdf->write_cell(25,6,nbm(bcsub(${'nlvl'.$ind}['sum_deb'],${'nlvl'.$ind}['sum_deb_ope'])),0,0,'R'); - $pdf->write_cell(25,6,nbm(bcsub(${'nlvl'.$ind}['sum_cred'],${'nlvl'.$ind}['sum_cred_ope'])),0,0,'R'); - $solde_lv=bcsub(${'nlvl'.$ind}['solde_deb'],${'nlvl'.$ind}['solde_cred']); - $side_lv=($solde_lv>0)?"D":"C"; - $side_lv=($solde_lv==0)?"":$side_lv; - $pdf->write_cell(25,6,nbm(abs($solde_lv))." $side_lv",0,0,'R'); - $pdf->line_new(); - $pdf->SetFont('DejaVuCond','',7); - ${'lvl'.$ind.'_old'}=substr($r['poste'],0,$ind); - foreach($a_sum as $a) - { - ${'nlvl'.$ind}[$a]=0; - } - } - } - foreach($a_sum as $a) - { - $nlvl1[$a]=bcadd($nlvl1[$a],$r[$a]); - $nlvl2[$a]=bcadd($nlvl2[$a],$r[$a]); - $nlvl3[$a]=bcadd($nlvl3[$a],$r[$a]); - } + $solde_lv = bcsub(${'nlvl' . $ind}['sum_deb_ope'], ${'nlvl' . $ind}['sum_cred_ope']); + $side_lv = ($solde_lv < 0) ? " C" : " D"; + $side_lv = ($solde_lv == 0) ? " " : $side_lv; + $pdf->write_cell(25, 6, nbm(abs($solde_lv)) . $side_lv, 0, 0, 'R'); + $pdf->write_cell(25, 6, nbm(bcsub(${'nlvl' . $ind}['sum_deb'], ${'nlvl' . $ind}['sum_deb_ope'])), 0, 0, 'R'); + $pdf->write_cell(25, 6, nbm(bcsub(${'nlvl' . $ind}['sum_cred'], ${'nlvl' . $ind}['sum_cred_ope'])), 0, 0, 'R'); + $solde_lv = bcsub(${'nlvl' . $ind}['solde_deb'], ${'nlvl' . $ind}['solde_cred']); + $side_lv = ($solde_lv > 0) ? "D" : "C"; + $side_lv = ($solde_lv == 0) ? "" : $side_lv; + $pdf->write_cell(25, 6, nbm(abs($solde_lv)) . " $side_lv", 0, 0, 'R'); + $pdf->line_new(); + $pdf->SetFont('DejaVuCond', '', 7); + ${'lvl' . $ind . '_old'} = substr($r['poste'], 0, $ind); + foreach ($a_sum as $a) { + ${'nlvl' . $ind}[$a] = 0; + } + } + } + foreach ($a_sum 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); - $fill=1; - } - else - { - $pdf->SetFillColor(0,0,0); - $fill=0; - } + if ($i % 2 == 0) { + $pdf->SetFillColor(220, 221, 255); + $fill = 1; + } else { + $pdf->SetFillColor(0, 0, 0); + $fill = 0; + } + + $pdf->LongLine(30, 6, $value['poste'], 0, 'L', $fill); + $pdf->LongLine(60, 6, $value['label'], 0, 'L', $fill); + $summary_tab = $bal->summary_add($summary_tab, $value['poste'], + $value['sum_deb'], + $value['sum_cred']); + if ($previous == 1) { + $pdf->write_cell(22, 6, nbm($value['sum_deb_previous']), 0, 0, 'R', $fill); + $pdf->write_cell(22, 6, nbm($value['sum_cred_previous']), 0, 0, 'R', $fill); - $pdf->LongLine(30,6,$value['poste'],0,'L',$fill); - $pdf->LongLine(60,6,$value['label'],0,'L',$fill); - $summary_tab=$bal->summary_add($summary_tab,$value['poste'], - $value['sum_deb'], - $value['sum_cred']); - if ($previous == 1 ) { - $pdf->write_cell(22,6,nbm($value['sum_deb_previous']),0,0,'R',$fill); - $pdf->write_cell(22,6,nbm($value['sum_cred_previous']),0,0,'R',$fill); - // $pdf->write_cell(22,6,nbm($value['solde_deb_previous']),0,0,'R',$fill); // $pdf->write_cell(22,6,nbm($value['solde_cred_previous']),0,0,'R',$fill); - $solde_previous=bcsub($value['solde_cred_previous'],$value['solde_deb_previous']); - $side_previous=($solde_previous<0)?" D":" C"; - $side_previous=($solde_previous==0)?"":$side_previous; - - $pdf->write_cell(22,6,nbm(abs($solde_previous)).$side_previous,0,0,'R',$fill); - - $tp_deb_previous=bcadd($tp_deb_previous,$value['sum_deb_previous']); - $tp_cred_previous=bcadd($tp_cred_previous,$value['sum_cred_previous']); - $tp_sold_previous=bcadd($tp_sold_previous,$value['solde_deb_previous']); - $tp_solc_previous=bcadd($tp_solc_previous,$value['solde_cred_previous']); - $summary_prev_tab=$bal->summary_add($summary_prev_tab, - $value['poste'], - $value['sum_deb_previous'], - $value['sum_cred_previous']); + $solde_previous = bcsub($value['solde_cred_previous'], $value['solde_deb_previous']); + $side_previous = ($solde_previous < 0) ? " D" : " C"; + $side_previous = ($solde_previous == 0) ? "" : $side_previous; + + $pdf->write_cell(22, 6, nbm(abs($solde_previous)) . $side_previous, 0, 0, 'R', $fill); + + $tp_deb_previous = bcadd($tp_deb_previous, $value['sum_deb_previous']); + $tp_cred_previous = bcadd($tp_cred_previous, $value['sum_cred_previous']); + $tp_sold_previous = bcadd($tp_sold_previous, $value['solde_deb_previous']); + $tp_solc_previous = bcadd($tp_solc_previous, $value['solde_cred_previous']); + $summary_prev_tab = $bal->summary_add($summary_prev_tab, + $value['poste'], + $value['sum_deb_previous'], + $value['sum_cred_previous']); } - $solde_ope=bcsub($value['sum_deb_ope'],$value['sum_cred_ope']); - $side_ope=($solde_ope>0)?" D":"C"; - $side_ope=($solde_ope==0)?" ":$side_ope; - - $pdf->write_cell(25,6,nbm(abs($solde_ope)).$side_ope,0,0,'R',$fill); - $pdf->write_cell(25,6,nbm(bcsub($value['sum_deb'],$value['sum_deb_ope'])),0,0,'R',$fill); - $pdf->write_cell(25,6,nbm(bcsub($value['sum_cred'],$value['sum_cred_ope'])),0,0,'R',$fill); - $solde=bcsub($value['sum_deb'],$value['sum_cred']); - $side=($solde>0)?"D":"C"; - $side=($solde==0)?"":$side; - $pdf->write_cell(25,6,nbm(abs($solde)).$side,0,0,'R',$fill); - $pdf->line_new(); - $tp_deb=bcadd($tp_deb,$value['sum_deb']); - $tp_cred=bcadd($tp_cred,$value['sum_cred']); - $tp_sold=bcadd($tp_sold,$value['solde_deb']); - $tp_solc=bcadd($tp_solc,$value['solde_cred']); + $solde_ope = bcsub($value['sum_deb_ope'], $value['sum_cred_ope']); + $tot_opening=bcadd($tot_opening,$solde_ope); - } - foreach (array(3,2,1) as $ind) - { - $r=$value; - if ( ! isset($_GET['lvl'.$ind]))continue; + $side_ope = ($solde_ope > 0) ? " D" : "C"; + $side_ope = ($solde_ope == 0) ? " " : $side_ope; + // compute column value + $deb = bcsub($value['sum_deb'], $value['sum_deb_ope']); + $cred = bcsub($value['sum_cred'], $value['sum_cred_ope']); + $pdf->write_cell(25, 6, nbm(abs($solde_ope)) . $side_ope, 0, 0, 'R', $fill); + $pdf->write_cell(25, 6, nbm($deb), 0, 0, 'R', $fill); + $pdf->write_cell(25, 6, nbm($cred), 0, 0, 'R', $fill); + $solde = bcsub($value['sum_deb'], $value['sum_cred']); + $side = ($solde > 0) ? "D" : "C"; + $side = ($solde == 0) ? "" : $side; + $pdf->write_cell(25, 6, nbm(abs($solde)) . $side, 0, 0, 'R', $fill); + $pdf->line_new(); + $tp_deb = bcadd($tp_deb, $deb); + $tp_cred = bcadd($tp_cred, $cred); + $tp_sold = bcadd($tp_sold, $value['solde_deb']); + $tp_solc = bcadd($tp_solc, $value['solde_cred']); - if (${'lvl'.$ind.'_old'} == '') ${'lvl'.$ind.'_old'}=substr($r['poste'],0,$ind); - if ( ${'lvl'.$ind.'_old'} != substr($r['poste'],0,$ind)) - { - $pdf->SetFont('DejaVu','B',7); - $pdf->write_cell(30,6,"Totaux ".$ind); - $pdf->write_cell(60,6,${'lvl'.$ind.'_old'}); - if ($previous == 1 ) { - $pdf->write_cell(22,6,nbm(${'nlvl'.$ind}['sum_deb_previous']),0,0,'R'); - $pdf->write_cell(22,6,nbm(${'nlvl'.$ind}['sum_cred_previous']),0,0,'R'); - $pdf->write_cell(22,6,nbm(${'nlvl'.$ind}['solde_deb_previous']),0,0,'R'); - $pdf->write_cell(22,6,nbm(${'nlvl'.$ind}['solde_cred_previous']),0,0,'R'); - } - $pdf->write_cell(25,6,nbm(${'nlvl'.$ind}['sum_deb']),0,0,'R'); - $pdf->write_cell(25,6,nbm(${'nlvl'.$ind}['sum_cred']),0,0,'R'); - $solde_lv=bcsub(${'nlvl'.$ind}['solde_deb'],${'nlvl'.$ind}['solde_cred']); - $side_lv=($solde_lv>0)?"D":"C"; - $side_lv=($solde_lv==0)?"":$side_lv; - $pdf->write_cell(25,6,nbm(abs($solde_lv))." $side_lv",0,0,'R'); - $pdf->line_new(); - $pdf->SetFont('DejaVuCond','',7); - ${'lvl'.$ind.'_old'}=substr($r['poste'],0,$ind); - foreach($a_sum as $a) - { - ${'nlvl'.$ind}[$a]=0; - } - } - } + } + foreach (array(3, 2, 1) as $ind) { + $r = $value; + 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)) { + $pdf->SetFont('DejaVu', 'B', 7); + $pdf->write_cell(30, 6, "Totaux " . $ind); + $pdf->write_cell(60, 6, ${'lvl' . $ind . '_old'}); + if ($previous == 1) { + $pdf->write_cell(22, 6, nbm(${'nlvl' . $ind}['sum_deb_previous']), 0, 0, 'R'); + $pdf->write_cell(22, 6, nbm(${'nlvl' . $ind}['sum_cred_previous']), 0, 0, 'R'); + $pdf->write_cell(22, 6, nbm(${'nlvl' . $ind}['solde_deb_previous']), 0, 0, 'R'); + $pdf->write_cell(22, 6, nbm(${'nlvl' . $ind}['solde_cred_previous']), 0, 0, 'R'); + } + $pdf->write_cell(25, 6, nbm(${'nlvl' . $ind}['sum_deb']), 0, 0, 'R'); + $pdf->write_cell(25, 6, nbm(${'nlvl' . $ind}['sum_cred']), 0, 0, 'R'); + $solde_lv = bcsub(${'nlvl' . $ind}['solde_deb'], ${'nlvl' . $ind}['solde_cred']); + $side_lv = findSide($solde_lv ); + $pdf->write_cell(25, 6, nbm(abs($solde_lv)) . " $side_lv", 0, 0, 'R'); + $pdf->line_new(); + $pdf->SetFont('DejaVuCond', '', 7); + ${'lvl' . $ind . '_old'} = substr($r['poste'], 0, $ind); + foreach ($a_sum as $a) { + ${'nlvl' . $ind}[$a] = 0; + } + } + } // Totaux - $pdf->SetFont('DejaVuCond','B',8); - $pdf->write_cell(90,6,$r['label']); - if ($previous == 1 ) { - $pdf->write_cell(22,6,nbm($tp_deb_previous),'T',0,'R',0); - $pdf->write_cell(22,6,nbm($tp_cred_previous),'T',0,'R',0); - $pdf->write_cell(22,6,nbm($tp_sold_previous),'T',0,'R',0); - $pdf->write_cell(22,6,nbm($tp_solc_previous),'T',0,'R',0); + $pdf->SetFont('DejaVuCond', 'B', 8); + $pdf->write_cell(90, 6, $r['label']); + if ($previous == 1) { + $pdf->write_cell(22, 6, nbm($tp_deb_previous), 'T', 0, 'R', 0); + $pdf->write_cell(22, 6, nbm($tp_cred_previous), 'T', 0, 'R', 0); + $pdf->write_cell(22, 6, nbm($tp_sold_previous), 'T', 0, 'R', 0); + $pdf->write_cell(22, 6, nbm($tp_solc_previous), 'T', 0, 'R', 0); } - $pdf->write_cell(25,6,nbm($tp_deb),'T',0,'R',0); - $pdf->write_cell(25,6,nbm($tp_cred),'T',0,'R',0); - $pdf->write_cell(25,6,nbm($tp_sold),'T',0,'R',0); - $pdf->write_cell(25,6,nbm($tp_solc),'T',0,'R',0); + $solde = bcsub($tp_sold,$tp_solc); + + $solde_side = findSide($solde); + $tot_opening_side = findSide($tot_opening); + // --------------- + // Footer column + // --------------- + $pdf->write_cell(25, 6, nbm(abs($tot_opening))." ".$tot_opening_side, 'T', 0, 'R', 0); + $pdf->write_cell(25, 6, nbm($tp_deb), 'T', 0, 'R', 0); + $pdf->write_cell(25, 6, nbm($tp_cred), 'T', 0, 'R', 0); + $pdf->write_cell(25, 6, nbm(abs($solde)).$solde_side, 'T', 0, 'R', 0); $pdf->line_new(); - } /** empty */ - // display the summary - if ($is_summary==1) { - if ($previous==1) { +} +/** empty */ +// display the summary +if ($is_summary == 1) { + if ($previous == 1) { $pdf->SetFont('DejaVuCond', 'B', 8); $pdf->write_cell(50, 8, _("Résumé Exercice précédent")); $pdf->line_new(); @@ -344,9 +339,8 @@ if (! empty($array)) $bal->summary_display_pdf($summary_tab, $pdf); } -$fDate=date('dmy-Hi'); -$pdf->Output('balance-'.$fDate.'.pdf','D'); - +$fDate = date('dmy-Hi'); +$pdf->Output('balance-' . $fDate . '.pdf', 'D'); ?> diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index c57d20a8d..ca7d65492 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -113,6 +113,22 @@ function nb($p_number) return $r; } +/** + * return D if the number is smaller than 0 , C if bigger and an empty string if + * equal to 0. Used for displaying saldo D / C (debit / credit ) + * @param float $p_number + */ +function findSide($p_number) +{ + $return =''; + if ( $p_number > 0 ) { + $return ='D'; + }else { + $return =($p_number== 0)?"":"C"; + } + return $return; +} + /** * format the number with a sep. for the thousand * @param $p_number number diff --git a/include/lib/iconcerned.class.php b/include/lib/iconcerned.class.php index c296804d2..d43fa3e4c 100644 --- a/include/lib/iconcerned.class.php +++ b/include/lib/iconcerned.class.php @@ -28,6 +28,7 @@ require_once NOALYSS_INCLUDE.'/lib/html_input.class.php'; class IConcerned extends HtmlInput { + private $hideOperation; //!< string of j_id to hide, separated by comma to avoid to reconcile an operation with itself public function __construct($p_name='',$p_value='',$p_id="") { @@ -36,8 +37,9 @@ class IConcerned extends HtmlInput $this->amount_id=null; $this->paid=''; $this->id=$p_id; - $this->tiers=""; // id of the field for the tiers to be updated - $this->div=""; // Dom Element to show the search result + $this->tiers=""; // id of the field for the tiers to be updated + $this->div=""; // Dom Element to show the search result + $this->hideOperation=""; // string of j_id to hide, separated by comma to avoid to reconcile an operation with itself } /*!\brief show the html input of the widget*/ public function input($p_name=null,$p_value=null) @@ -55,17 +57,27 @@ class IConcerned extends HtmlInput $this->tiers ); $r=Icon_Action::icon_magnifier(uniqid(), $javascript); $r.=sprintf(" - + ", $this->name, $this->id, $this->value, + $this->hideOperation, $this->id ); return $r; } + + /** + * setter + * @param $p_string + */ + function set_hideOperation($p_string) + { + $this->hideOperation=strip_tags($p_string); + } /*!\brief print in html the readonly value of the widget*/ public function display() { diff --git a/include/template/ledger_detail_bottom.php b/include/template/ledger_detail_bottom.php index 15e95afc8..5484eaf4c 100644 --- a/include/template/ledger_detail_bottom.php +++ b/include/template/ledger_detail_bottom.php @@ -26,9 +26,9 @@ $aRap=$oRap->get(); // find out exercice $periode_id=new Periode($cn,$detail->det->jr_tech_per); $exercice=$periode_id->get_exercice(); - - - $nb_document=($detail->det->jr_pj_name != "")?1:0; + + +$nb_document=($detail->det->jr_pj_name != "")?1:0; $nb_aRap=(is_array($aRap))?count($aRap):0; // Array of tab @@ -225,6 +225,7 @@ if ( $access=='W') { $wConcerned=new IConcerned("rapt".$div); $wConcerned->amount_id=$obj->det->jr_montant; $wConcerned->div="search_reconcile"; + $wConcerned->set_hideOperation( $obj->jr_id); echo $wConcerned->input(); } diff --git a/include/template/stock_inv.php b/include/template/stock_inv.php index 2c1bdea34..556dcc66c 100644 --- a/include/template/stock_inv.php +++ b/include/template/stock_inv.php @@ -27,6 +27,8 @@ * */ ?> + +
" class="content">
')"> @@ -104,7 +106,6 @@ -