From e47cc77db77dbcf2e0e945949c39c438b30cff7c Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 26 Aug 2019 16:36:45 +0200 Subject: [PATCH 01/26] Cosmetic --- include/compta_fin.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/compta_fin.inc.php b/include/compta_fin.inc.php index 397b30098..7627696a1 100644 --- a/include/compta_fin.inc.php +++ b/include/compta_fin.inc.php @@ -133,7 +133,7 @@ if ( isset($_POST['correct'])) //---------------------------------------- // Blank form //---------------------------------------- -echo ''.$p_msg.''; +if ( $p_msg !="" ) echo ''.$p_msg.''; echo '
'; echo HtmlInput::hidden('ledger_type','fin'); From 654edc4f0d7607a71edafa72c5debc305ad9293d Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 27 Aug 2019 12:04:48 +0200 Subject: [PATCH 02/26] Task #0001736: PHP7 comptability : count() works only with array --- include/class/anc_plan.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/include/class/anc_plan.class.php b/include/class/anc_plan.class.php index 93bb90608..fb5b69f21 100644 --- a/include/class/anc_plan.class.php +++ b/include/class/anc_plan.class.php @@ -59,6 +59,7 @@ class Anc_Plan "pa_description as description from plan_analytique $p_order"; $ret=$this->db->exec_sql($sql); $array=Database::fetch_all($ret); + if ($array == FALSE ) return array(); return $array; } From 610498c9d2973ca09273fb0d4ae2e900a3bd89bb Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 27 Aug 2019 12:11:40 +0200 Subject: [PATCH 03/26] changement de texte --- include/anc_pa.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/anc_pa.inc.php b/include/anc_pa.inc.php index a795c35fd..f3fc67433 100644 --- a/include/anc_pa.inc.php +++ b/include/anc_pa.inc.php @@ -171,7 +171,7 @@ if ($sa=='anc_menu') echo '
'; echo ''; echo ''; echo '
'; - echo ''._("Ajout d'un plan comptable").''; + echo ''._("Ajout d'un plan analytique").''; echo '
'; @@ -191,7 +191,7 @@ if ($sa=='anc_menu') if ($obj->isAppend()==true) { echo ''; - echo ''._("Ajout d'un plan comptable").''; + echo ''._("Ajout d'un plan analytique").''; echo ''; } foreach ($list as $line) From 0579253637cc26456fb9e5e9caab94c97f964d70 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 27 Aug 2019 17:45:51 +0200 Subject: [PATCH 04/26] Translation & text --- include/compta_ach.inc.php | 3 +-- include/template/ledger_detail_bottom.php | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/compta_ach.inc.php b/include/compta_ach.inc.php index 578451b3c..65f3d3fa5 100644 --- a/include/compta_ach.inc.php +++ b/include/compta_ach.inc.php @@ -68,7 +68,6 @@ if (isset($_POST['view_invoice'])) echo '
'; echo '
'; echo h1(_("Confirmation")); - echo h1(_("Confirmation")); echo span(_("Vous devez encore confirmer"),' class="notice"'); echo '
'; @@ -312,4 +311,4 @@ echo '
'; return; // end record invoice -?> \ No newline at end of file +?> diff --git a/include/template/ledger_detail_bottom.php b/include/template/ledger_detail_bottom.php index 4fc312941..6f89b1d91 100644 --- a/include/template/ledger_detail_bottom.php +++ b/include/template/ledger_detail_bottom.php @@ -323,7 +323,7 @@ if ( $div != 'popup' ) { { $remove=new IButton('Effacer'); $remove->label=_('Effacer'); - $remove->javascript="return confirm_box(null,'Vous confirmez effacement ?',function () {removeOperation('".$obj->det->jr_id."',".dossier::id().",'".$div."')})"; + $remove->javascript="return confirm_box(null,content[50],function () {removeOperation('".$obj->det->jr_id."',".dossier::id().",'".$div."')})"; echo $remove->input(); } //---------------------------------------------------- @@ -359,7 +359,7 @@ echo ''; $r.='

'; $r.=HtmlInput::submit('x','accepter', - 'onclick="confirm_box($(\'form_'.$div.'\'),\'Vous confirmez ? \',function () {$(\'form_'.$div.'\').divname=\''.$div.'\';reverseOperation($(\'form_'.$div.'\'))}); return false"'); + 'onclick="confirm_box($(\'form_'.$div.'\'),content[50],function () {$(\'form_'.$div.'\').divname=\''.$div.'\';reverseOperation($(\'form_'.$div.'\'))}); return false"'); $r.="

"; $r.=''; echo $r; From 4a637a0e87c9d9b847aaea285695d1ba102771fa Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 27 Aug 2019 18:53:31 +0200 Subject: [PATCH 05/26] Security : avoid direct call to Http Variable --- include/history_operation.inc.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/include/history_operation.inc.php b/include/history_operation.inc.php index 3a0ceb77d..420a32458 100644 --- a/include/history_operation.inc.php +++ b/include/history_operation.inc.php @@ -142,13 +142,16 @@ $r = HtmlInput::get_to_hidden(array('search_opnb_jrn', 'search_opr_jrn')); if (isset($_GET['r_jrn'])) { - foreach ($_GET['r_jrn'] as $k => $v) - $r.=HtmlInput::hidden('r_jrn[' . $k . ']', $v); + $a_rjn=$http->get('r_jrn','array'); + foreach ($a_rjn as $k => $v) { + if (isNumber($v)) $r.=HtmlInput::hidden('r_jrn[' . $k . ']', $v); + } } if (isset($_GET['search_opr_jrn'])) { - foreach ($_GET['search_opr_jrn'] as $k => $v) - $r.=HtmlInput::hidden('r_jrn[' . $k . ']', $v); + $a_search_opr_jrn=$http->get('search_opr_jrn','array'); + foreach ($a_search_opr_jrn as $k => $v) + if (isNumber($v)) $r.=HtmlInput::hidden('r_jrn[' . $k . ']', $v); } echo $r; @@ -164,13 +167,13 @@ $r = HtmlInput::get_to_hidden(array('l', 'date_paid_start','date_paid_end', 'accounting', 'unpaid', 'gDossier', 'ledger_type', 'p_action')); if (isset($_GET['search_opr_jrn'])) { - foreach ($_GET['search_opr_jrn'] as $k => $v) - $r.=HtmlInput::hidden('r_jrn[' . $k . ']', $v); + foreach ($a_search_opr_jrn as $k => $v) + if (isNumber($v)) $r.=HtmlInput::hidden('r_jrn[' . $k . ']', $v); } if (isset($_GET['r_jrn'])) { - foreach ($_GET['r_jrn'] as $k => $v) - $r.=HtmlInput::hidden('r_jrn[' . $k . ']', $v); + foreach ($a_rjn as $k => $v) + if (isNumber($v)) $r.=HtmlInput::hidden('r_jrn[' . $k . ']', $v); } echo '
'; echo $r; From 57153bea0e813c1fee72870824c5f8578341797b Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 27 Aug 2019 18:58:04 +0200 Subject: [PATCH 06/26] Security : avoid direct call to Http Variable --- include/history_operation.inc.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/history_operation.inc.php b/include/history_operation.inc.php index 420a32458..50f0e1104 100644 --- a/include/history_operation.inc.php +++ b/include/history_operation.inc.php @@ -110,6 +110,11 @@ $max_line = $cn->count_sql($sql); $step = $_SESSION['g_pagesize']; $page = (isset($_GET['offset'])) ? $_GET['page'] : 1; $offset = (isset($_GET['offset'])) ? $_GET['offset'] : 0; + +// check if number +$page=(isNumber($page)==0)?1:$page; +$offset=(isNumber($offset)==0)?0:$offset; + $bar = navigation_bar($offset, $max_line, $step, $page); echo $msg; From 7de5af784c5eaf5dced617951fcd376e0a78f655 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 27 Aug 2019 19:27:16 +0200 Subject: [PATCH 07/26] =?UTF-8?q?#0001584:=20En=20mode=20=C2=ABoptionnelle?= =?UTF-8?q?=C2=BB,=20afficher=20si=20CA=20ventil=C3=A9e=20ou=20non.=20Ajou?= =?UTF-8?q?t=20symbole=20"contient"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/class/acc_ledger_search.class.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/include/class/acc_ledger_search.class.php b/include/class/acc_ledger_search.class.php index 40e0ca6a3..9506dddeb 100644 --- a/include/class/acc_ledger_search.class.php +++ b/include/class/acc_ledger_search.class.php @@ -282,7 +282,13 @@ class Acc_Ledger_Search */ public function build_search_sql($p_array, $p_order="", $p_where="") { - $sql="select jr_id , + $sql="with cas as ( + select distinct jr_id + from jrn + join jrnx on (jr_grpt_id=j_grpt) + where + exists(select 1 from operation_analytique where j_id=jrnx.j_id) ) + select jr_id , jr_montant, substr(jr_comment,1,60) as jr_comment, to_char(jr_ech,'DD.MM.YY') as str_jr_ech, @@ -336,11 +342,15 @@ class Acc_Ledger_Search else null end as total_invoice, jr_date_paid, - to_char(jr_date_paid,'DD.MM.YY') as str_jr_date_paid + to_char(jr_date_paid,'DD.MM.YY') as str_jr_date_paid, + cas.jr_id as analytic_op from - jrn as X left join jrn_note using(jr_id) + jrn as X + left join jrn_note using(jr_id) + left join cas using( jr_id) join jrn_def on jrn_def_id=jr_def_id - join parm_periode on p_id=jr_tech_per"; + join parm_periode on p_id=jr_tech_per + "; if (!empty($p_array)) extract($p_array, EXTR_SKIP); @@ -771,6 +781,8 @@ class Acc_Ledger_Search $r.=""; $tmp_jr_comment=h($row['jr_comment']); $r.=$tmp_jr_comment; + if ( $row['analytic_op'] != "") + $r.=sprintf(''); $r.=""; $r.=td(h($row['n_text']), ' style="font-size:0.87em%"'); // Amount From 5e291fc48fb98b114dd05e211cee5406a555225f Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 27 Aug 2019 19:28:38 +0200 Subject: [PATCH 08/26] New : icon_action:slider icon_action:comment and fix single quote issue in icon_action:tips --- include/lib/icon_action.class.php | 37 ++++++++++++++++++++++++++++++- scenario/icon_actionTest.php | 6 +++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/include/lib/icon_action.class.php b/include/lib/icon_action.class.php index 485e4802f..cc24a325a 100644 --- a/include/lib/icon_action.class.php +++ b/include/lib/icon_action.class.php @@ -96,13 +96,31 @@ class Icon_Action */ static function tips($p_comment) { - $p_comment=htmlentities($p_comment); + $p_comment=str_replace("'",' ',$p_comment); $r=''; $r.=""; $r.=''; return $r; } + /** + * Display a info in a bubble, text is given as parameter + * @param string $p_comment + * + * @return html string + */ + static function comment($p_comment) + { + $p_comment=str_replace("'",' ',$p_comment); + $js=sprintf("displayBulle('%s')",$p_comment); + + $r=sprintf('', + $js,$js); + $r.=""; + $r.=''; + + return $r; + } /** * Display a icon ON * @param string $p_div id of element @@ -307,4 +325,21 @@ class Icon_Action $lock_cur); return $r; } + /** + * Display the icon of a slider + * @param string $p_id DOMid + * @param string $p_javascript + * @return htmlString + */ + static function slider($p_id,$p_javascript) + { + + $lock_cur=""; + + $r=sprintf( '%s', + $p_id, + $p_javascript, + $lock_cur); + return $r; + } } diff --git a/scenario/icon_actionTest.php b/scenario/icon_actionTest.php index 4682d7e69..35c33a98c 100644 --- a/scenario/icon_actionTest.php +++ b/scenario/icon_actionTest.php @@ -77,4 +77,10 @@ include_once NOALYSS_INCLUDE."/lib/icon_action.class.php";

Tips +

+

+ Slider +

+

+ Comment

\ No newline at end of file From 98c3a84b161b539ba0aba004c731caf5533eb92b Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 29 Aug 2019 00:04:42 +0200 Subject: [PATCH 09/26] =?UTF-8?q?fixup!=20fixup!=20New=20Task=201728:=20Ai?= =?UTF-8?q?de=20=C3=A0=20l'encodage=20-=20Journaux=20n=C3=A9gatifs=20(note?= =?UTF-8?q?=20de=20cr=C3=A9dit)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/class/acc_ledger.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index 165f79279..bf72b5790 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -2357,10 +2357,12 @@ class Acc_Ledger extends jrn_def_sql { throw new Exception(_('Choix du type de journal est obligatoire')); } - if ($negative_amount == 1 && trim($negative_warning)=="") { + if (isset( $negative_warning) && $negative_amount == 1 && trim($negative_warning)=="") { + throw new Exception(_("Avertissement ne peut être vide")); } - if ( $negative_amount <> 0 && $negative_amount <> 1 ){ + if ( isset( $negative_amount) && $negative_amount <> 0 && $negative_amount <> 1 ){ + throw new Exception(_("Valeur invalide")); } } @@ -2391,8 +2393,8 @@ class Acc_Ledger extends jrn_def_sql $this->jrn_deb_max_line=($min_row<1)?1:$min_row; $this->jrn_def_description=$p_description; $this->jrn_enable=$jrn_enable; - $this->jrn_def_negative_amount=$negative_amount; - $this->jrn_def_negative_warning=$negative_warning; + $this->jrn_def_negative_amount=(isset($negative_amount))?$negative_amount:'0'; + $this->jrn_def_negative_warning=(isset ($negative_warning))?$negative_warning:_("Attention, ce journal doit utiliser des montants négatifs"); switch ($this->jrn_def_type) { From 62bc40eb17c4453857f255336bb7f751fb07abaf Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 29 Aug 2019 01:19:54 +0200 Subject: [PATCH 10/26] =?UTF-8?q?#0001711:=20Gros=20souci=20comptanal=20Mo?= =?UTF-8?q?ntant=20compt=C3=A9=20en=20absolu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/class/anc_key.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/include/class/anc_key.class.php b/include/class/anc_key.class.php index f553a53f2..ed06eb074 100644 --- a/include/class/anc_key.class.php +++ b/include/class/anc_key.class.php @@ -324,6 +324,7 @@ class Anc_Key { $val[$number][$i]=bcmul($p_amount,$a_amount[$i]['ke_percent']); $val[$number][$i]=bcdiv($val[$number][$i],100); + $val[$number][$i]=abs($val[$number][$i]); } $array['val']=$val; From 0c013f33c68aeb4e70470cae344faf68e68e076e Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 29 Aug 2019 09:41:48 +0200 Subject: [PATCH 11/26] layout --- include/class/acc_ledger.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index bf72b5790..ad72cfcb3 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -714,7 +714,7 @@ class Acc_Ledger extends jrn_def_sql // CA if ($g_parameter->MY_ANALYTIC!='nu') // use of AA { - if (preg_match("/^[6,7]+/", $strPoste)==1) + if ($g_parameter->match_analytic( $strPoste)==TRUE) { // show form $op=new Anc_Operation($this->db); @@ -1293,7 +1293,7 @@ class Acc_Ledger extends jrn_def_sql $tot_cred+=($acc_op->type=='c')?$acc_op->amount:0; if ($g_parameter->MY_ANALYTIC!="nu") { - if (preg_match("/^[6,7]+/", $poste)==1) + if ($g_parameter->match_analytic( $poste)==TRUE) { // for each item, insert into operation_analytique */ @@ -2357,12 +2357,12 @@ class Acc_Ledger extends jrn_def_sql { throw new Exception(_('Choix du type de journal est obligatoire')); } - if (isset( $negative_warning) && $negative_amount == 1 && trim($negative_warning)=="") { + + if (isset( $negative_warning) && $negative_amount == 1 && trim($negative_warning)=="") { throw new Exception(_("Avertissement ne peut être vide")); } - if ( isset( $negative_amount) && $negative_amount <> 0 && $negative_amount <> 1 ){ - + if ( isset( $negative_amount) && $negative_amount <> 0 && $negative_amount <> 1 ){ throw new Exception(_("Valeur invalide")); } } From e57aa7d86392ce89ab2267822f9fed1a633b24bb Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 29 Aug 2019 09:43:22 +0200 Subject: [PATCH 12/26] =?UTF-8?q?#1369:=20=C3=89tendre=20la=20comptabilit?= =?UTF-8?q?=C3=A9=20analytique=20=C3=A0=20tous=20les=20postes=3F=20#1716:?= =?UTF-8?q?=20GROS=20SOUCI=20CA=20-=20ventilation=204=20et=205.=205=20phan?= =?UTF-8?q?t=C3=B4me!=20#1479:=20PROPOSITION=20CA=20-=20param=C3=A9trage?= =?UTF-8?q?=20comptes=20actifs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/ajax/ajax_anc_key_compute.php | 2 +- include/class/acc_ledger_fin.class.php | 2 +- include/class/acc_ledger_purchase.class.php | 2 +- include/class/acc_ledger_sold.class.php | 5 +- .../class/noalyss_parameter_folder.class.php | 91 +++++++++++++++---- include/company.inc.php | 18 +++- include/template/ledger_detail_ach.php | 2 +- include/template/ledger_detail_fin.php | 2 +- include/template/ledger_detail_misc.php | 2 +- include/template/ledger_detail_ven.php | 2 +- 10 files changed, 98 insertions(+), 30 deletions(-) diff --git a/include/ajax/ajax_anc_key_compute.php b/include/ajax/ajax_anc_key_compute.php index c04d643f5..63c48c76d 100644 --- a/include/ajax/ajax_anc_key_compute.php +++ b/include/ajax/ajax_anc_key_compute.php @@ -48,7 +48,7 @@ catch (Exception $exc) error_log($exc->getTraceAsString()); return; } - +ob_start(); $compute_key=new Anc_Key($key); $pos=strrpos($target,"t"); $row=substr($target,$pos+1); diff --git a/include/class/acc_ledger_fin.class.php b/include/class/acc_ledger_fin.class.php index b9023ac70..c27c16c75 100644 --- a/include/class/acc_ledger_fin.class.php +++ b/include/class/acc_ledger_fin.class.php @@ -612,7 +612,7 @@ class Acc_Ledger_Fin extends Acc_Ledger } $r.=''; // encode the pa - if ($g_parameter->MY_ANALYTIC != 'nu' && preg_match("/^[6,7]/", $fTiers->strAttribut(ATTR_DEF_ACCOUNT)) == 1) // use of AA + if ($g_parameter->MY_ANALYTIC != 'nu' && $g_parameter->match_analytic($fTiers->strAttribut(ATTR_DEF_ACCOUNT)) == 1) // use of AA { // show form $anc_op = new Anc_Operation($this->db); diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index f47974928..2ac7becc3 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -656,7 +656,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger Stock_Goods::insert_goods($this->db,array('j_id'=>$j_id,'goods'=>${'e_march'.$i},'quant'=>$nNeg*${'e_quant'.$i},'dir'=>$dir,'repo'=>$repo)) ; } - if ( $g_parameter->MY_ANALYTIC != "nu" ) + if ( $g_parameter->MY_ANALYTIC != "nu" && $g_parameter->match_analytic($poste_val)) { // for each item, insert into operation_analytique */ $op=new Anc_Operation($this->db); diff --git a/include/class/acc_ledger_sold.class.php b/include/class/acc_ledger_sold.class.php index ae4535a38..8a6ff3e7b 100644 --- a/include/class/acc_ledger_sold.class.php +++ b/include/class/acc_ledger_sold.class.php @@ -364,7 +364,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { } - if ($g_parameter->MY_ANALYTIC != "nu") { + if ($g_parameter->MY_ANALYTIC != "nu" && $g_parameter->match_analytic($poste_val)) { // for each item, insert into operation_analytique */ $op = new Anc_Operation($this->db); $op->oa_group = $group; @@ -819,7 +819,8 @@ class Acc_Ledger_Sold extends Acc_Ledger { $r.=''; } // encode the pa - if ($g_parameter->MY_ANALYTIC != 'nu') { // use of AA + if ($g_parameter->MY_ANALYTIC != 'nu' + && $g_parameter->match_analytic($fiche->strAttribut(ATTR_DEF_ACCOUNT))==TRUE) { // use of AA // show form $anc_op = new Anc_Operation($this->db); $null = ($g_parameter->MY_ANALYTIC == 'op') ? 1 : 0; diff --git a/include/class/noalyss_parameter_folder.class.php b/include/class/noalyss_parameter_folder.class.php index 8f784429e..a9db097bb 100644 --- a/include/class/noalyss_parameter_folder.class.php +++ b/include/class/noalyss_parameter_folder.class.php @@ -45,6 +45,7 @@ class Noalyss_Parameter_Folder var $MY_ALPHANUM; var $MY_UPDLAB; var $MY_STOCK; + var $MY_ANC_FILTER; // constructor function __construct($p_cn) @@ -61,14 +62,51 @@ class Noalyss_Parameter_Folder } } - function check(&$p_value) + function check_anc_filter($p_value) { - if ($p_value == 'MY_STRICT' - && $this->MY_STRICT != 'Y' - && $this->MY_STRICT != 'N') - $p_value='N'; - $p_value=htmlspecialchars($p_value); + $tmp_value=$p_value; + $tmp_value=preg_replace("/[0-9]|,/", '', $p_value); + if ( $tmp_value != "") { + throw new Exception (sprintf(_("Valeur invalide %s"),$tmp_value),1000); + } + if (trim($p_value) == "") { + throw new Exception (sprintf(_("Erreur Filtre analytique %s"),$tmp_value),1001); + + } + } + function check($p_attr, $p_value) + { + $ret_value=$p_value; + switch ($p_attr) + { + case 'MY_STRICT': + + if (empty(trim($p_value)) ||($p_value!='Y'&&$p_value!='N')) + { + $ret_value='N'; + } + + break; + case 'MY_ANC_FILTER': + try + { + $p_value=str_replace(" ", "", $p_value); + $this->check_anc_filter($p_value); + $ret_value=$p_value; + } + catch (Exception $exc) + { + throw $exc; + } + + break; + default : + $ret_value=htmlspecialchars($p_value); + } + return $ret_value; + } + /*! ************************************************** * \brief save the parameter into the database by inserting or updating @@ -79,20 +117,24 @@ class Noalyss_Parameter_Folder */ function save($p_attr) { - $this->check($p_attr); - $value=$this->$p_attr; - // check if the parameter does exist - if ( $this->db->get_value('select count(*) from parameter where pr_id=$1',array($p_attr)) != 0 ) - { - $Res=$this->db->exec_sql("update parameter set pr_value=$1 where pr_id=$2", - array($value,$p_attr)); - } - else - { + try { + $value=$this->check($p_attr,$this->$p_attr); - $Res=$this->db->exec_sql("insert into parameter (pr_id,pr_value) values( $1,$2)", - array($p_attr,$value)); + // check if the parameter does exist + if ( $this->db->get_value('select count(*) from parameter where pr_id=$1',array($p_attr)) != 0 ) + { + $Res=$this->db->exec_sql("update parameter set pr_value=$1 where pr_id=$2", + array($value,$p_attr)); + } + else + { + $Res=$this->db->exec_sql("insert into parameter (pr_id,pr_value) values( $1,$2)", + array($p_attr,$value)); + + } + } catch (Exception $e) { + throw $e; } } @@ -124,8 +166,19 @@ class Noalyss_Parameter_Folder $this->save('MY_ALPHANUM'); $this->save('MY_UPDLAB'); $this->save('MY_STOCK'); + $this->save("MY_ANC_FILTER"); - + } + /** + * Check if an accounting match the anc_filter + * @param string $p_accounting + * @return boolean FALSE does not match , TRUE matches + */ + function match_analytic($p_accounting) + { + $string="/^[".$this->MY_ANC_FILTER."]+/"; + if ( preg_match($string,$p_accounting) == 0 ) return FALSE; + return TRUE; } } diff --git a/include/company.inc.php b/include/company.inc.php index c7dcc540e..2bd6ae279 100644 --- a/include/company.inc.php +++ b/include/company.inc.php @@ -48,8 +48,12 @@ if (isset($_POST['record_company'])) $m->MY_ALPHANUM = $http->post("p_alphanum"); $m->MY_UPDLAB = $http->post("p_updlab"); $m->MY_STOCK =$http->post("p_stock"); - - $m->Update(); + $m->MY_ANC_FILTER=$http->post("p_anc_filter"); + try { + $m->Update(); + } catch (Exception $e) { + alert($e->getMessage()); + } } $my = new Noalyss_Parameter_Folder($cn); @@ -111,6 +115,10 @@ $stock->value = array( $stock->selected = $my->MY_STOCK; $stock->table = 1; +$anc_filter=new IText("p_anc_filter", $my->MY_ANC_FILTER); +$anc_filter->placeholder='6,7'; +$anc_filter->title=_("Uniquement des chiffres séparés par des virgules"); + // other parameters $all = new IText(); $all->table = 1; @@ -135,6 +143,12 @@ echo "" . td(_("Pays"), 'style="text-align:right"') . $all->input("p_pays", $all->value = ''; echo "" . td(_("Numéro de Tva"), 'style="text-align:right"') . $all->input("p_tva", $my->MY_TVA) . ""; echo "" . td(_("Utilisation de la compta. analytique"), 'style="text-align:right"') . $compta->input("p_compta", $array) . ""; +echo ''. td(_("Opération analytique uniquement pour les postes comptables commençant par")). + ''. + $anc_filter->input(). + Icon_Action::tips($anc_filter->title); + ''. + ''; echo "" . td(_("Utilisation des stocks"), 'style="text-align:right"') . $stock->input() . ""; echo "" . td(_("Utilisation du mode strict "), 'style="text-align:right"') . $strict->input("p_strict", $strict_array) . ""; diff --git a/include/template/ledger_detail_ach.php b/include/template/ledger_detail_ach.php index 97981af2d..7513aa0ad 100644 --- a/include/template/ledger_detail_ach.php +++ b/include/template/ledger_detail_ach.php @@ -225,7 +225,7 @@ $str_anc=""; if ($owner->MY_ANALYTIC != "nu" /*&& $div == 'popup'*/ ) { $poste = $fiche->strAttribut(ATTR_DEF_ACCOUNT); - if (preg_match('/^(6|7)/', $poste)) + if ( $g_parameter->match_analytic($poste)) { $anc_op = new Anc_Operation($cn); $anc_op->j_id = $q['j_id']; diff --git a/include/template/ledger_detail_fin.php b/include/template/ledger_detail_fin.php index a34f4b680..291a125d7 100644 --- a/include/template/ledger_detail_fin.php +++ b/include/template/ledger_detail_fin.php @@ -118,7 +118,7 @@ echo td(_('Pièce')).td($itext->input()); if ( $owner->MY_ANALYTIC != "nu" /*&& $div == 'popup'*/) { $poste=$fiche->strAttribut(ATTR_DEF_ACCOUNT); - if ( preg_match('/^(6|7)/',$q[$e]['j_poste'])) + if ( $g_parameter->match_analytic($q[$e]['j_poste'])) { $qcode=$fiche->strAttribut(ATTR_DEF_QUICKCODE); $anc_op=new Anc_Operation($cn); diff --git a/include/template/ledger_detail_misc.php b/include/template/ledger_detail_misc.php index 27ce89814..eb00e1118 100644 --- a/include/template/ledger_detail_misc.php +++ b/include/template/ledger_detail_misc.php @@ -161,7 +161,7 @@ $amount_idx=0; $row.=($q[$e]['j_debit']=='f')?$montant:td(''); /* Analytic accountancy */ if ( $owner->MY_ANALYTIC != "nu" /*&& $div=='popup'*/){ - if ( preg_match('/^(6|7)/',$q[$e]['j_poste'])) { + if ( $g_parameter->match_analytic($q[$e]['j_poste'])) { echo HtmlInput::hidden("amount_t".$amount_idx,$q[$e]['j_montant']); $anc_op=new Anc_Operation($cn); diff --git a/include/template/ledger_detail_ven.php b/include/template/ledger_detail_ven.php index fa7c3acaf..f68b51e75 100644 --- a/include/template/ledger_detail_ven.php +++ b/include/template/ledger_detail_ven.php @@ -223,7 +223,7 @@ echo $ipaid->input(); if ($owner->MY_ANALYTIC != "nu" /*&& $div == 'popup' */ ) { $poste = $fiche->strAttribut(ATTR_DEF_ACCOUNT); - if (preg_match('/^(6|7)/', $poste)) + if ( $g_parameter->match_analytic($poste)) { $anc_op = new Anc_Operation($cn); $anc_op->in_div=$div; From 8cb9ea878423be844453c577851ecfc62a3f17a9 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 29 Aug 2019 09:55:25 +0200 Subject: [PATCH 13/26] =?UTF-8?q?Missing=20files=20for=20#1369:=20=C3=89te?= =?UTF-8?q?ndre=20la=20comptabilit=C3=A9=20analytique=20=C3=A0=20tous=20le?= =?UTF-8?q?s=20postes=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/constant.php | 2 +- include/sql/patch/upgrade137.sql | 6 + .../noalyss_parameter_folderTest.class.php | 183 ++++++++++++++++++ 3 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 include/sql/patch/upgrade137.sql create mode 100644 unit-test/include/class/noalyss_parameter_folderTest.class.php diff --git a/include/constant.php b/include/constant.php index d157706d8..cb856c36b 100644 --- a/include/constant.php +++ b/include/constant.php @@ -108,7 +108,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) { if ( ! defined ("SYSINFO_DISPLAY")) { define ("SYSINFO_DISPLAY",TRUE); } -define ("DBVERSION",137); +define ("DBVERSION",138); define ("MONO_DATABASE",25); define ("DBVERSIONREPO",18); define ('NOTFOUND','--not found--'); diff --git a/include/sql/patch/upgrade137.sql b/include/sql/patch/upgrade137.sql new file mode 100644 index 000000000..2d83eb303 --- /dev/null +++ b/include/sql/patch/upgrade137.sql @@ -0,0 +1,6 @@ +begin; +insert into "parameter" (pr_id,pr_value) values ('MY_ANC_FILTER','6,7'); + + +insert into version (val,v_description) values (138,'Analytic improve'); +commit ; \ No newline at end of file diff --git a/unit-test/include/class/noalyss_parameter_folderTest.class.php b/unit-test/include/class/noalyss_parameter_folderTest.class.php new file mode 100644 index 000000000..091830c19 --- /dev/null +++ b/unit-test/include/class/noalyss_parameter_folderTest.class.php @@ -0,0 +1,183 @@ + + +use PHPUnit\Framework\TestCase; +function trim_parameter($p_value){ + return; +} +/** + * Generated by PHPUnit_SkeletonGenerator on 2017-11-26 at 11:24:04. + */ +class Noalyss_Parameter_FolderTest extends TestCase +{ + + protected $object; + private $a_param; + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + * + */ + protected function setUp() + { + global $g_connection, $g_user; + $_REQUEST['gDossier']=DOSSIER; + $g_connection=new Database(DOSSIER); + $g_user=new User($g_connection); + $this->object=new Noalyss_Parameter_Folder($g_connection); + $this->a_param=explode(",","MY_COUNTRY,". + "MY_DEFAULT_ROUND_ERROR_DEB,". + "MY_DEFAULT_ROUND_ERROR_CRED,". + "MY_ANC_FILTER,". + "MY_NAME,". + "MY_TVA,". + "MY_STREET,". + "MY_NUMBER,". + "MY_CP,". + "MY_TEL,". + "MY_PAYS,". + "MY_COMMUNE,". + "MY_FAX,". + "MY_ANALYTIC,". + "MY_STRICT,". + "MY_TVA_USE,". + "MY_PJ_SUGGEST,". + "MY_CHECK_PERIODE,". + "MY_DATE_SUGGEST,". + "MY_ALPHANUM,". + "MY_UPDLAB,". + "MY_STOCK"); + + } + public function testNew() + { + global $g_connection ; + $nb_param=count($this->a_param); + $cnt=$g_connection->get_value("select count(*) from parameter where pr_id like 'MY_%'"); + $this->assertEquals($nb_param,$cnt,"Number of parameters"); + + } + /* + * @covers Noalyss_Parameter_Folder::checkTest + * + */ + public function testcheck() + { + + $a=$this->object->check('MY_STRICT', 0); + $this->assertEquals($a,"N"); + + } + /* + * @covers Noalyss_Parameter_Folder::checkTest + * + */ + public function testcheck_anc_filter() + { + + try { + $this->object->check_anc_filter('6,7'); + $this->assertTrue(TRUE); + } catch (Exception $ex) { + $this->assertTrue(FALSE,'6,7 is valid'); + } + try { + $this->object->check_anc_filter('6,7,8,2'); + $this->assertTrue(TRUE); + } catch (Exception $ex) { + $this->assertTrue(FALSE,'6,7,8,2 is valid'); + } + try { + $this->object->check_anc_filter('6,7,8,2,AA'); + $this->assertTrue(FALSE); + } catch (Exception $ex) { + $this->assertTrue(TRUE,'6,7,8,2 is not valid'); + } + + } + /* + * @covers Noalyss_Parameter_Folder::checkTest + * + */ + public function testupdate() + { + $ok=0; + try { + $this->testsave(); + } catch (Exception $e) + { + $ok=1; + } + $this->assertEquals($ok,0); + } + /* + * @covers Noalyss_Parameter_Folder::checkTest + * + */ + public function testsave() + { + global $g_connection; + for ($e =0;$e < count($this->a_param);$e++) + { + + $attr=$this->a_param[$e]; + + $old=$this->object->$attr; + switch ($attr) + { + case "MY_STRICT": + $this->object->$attr='Y'; + break; + case "MY_COUNTRY": + $this->object->MY_COUNTRY='XBE'; + break; + case "MY_ANC_FILTER": + $this->object->MY_ANC_FILTER='5,4'; + break; + default: + $this->object->$attr='000'; + break; + } + $this->object->save($this->a_param[$e]); + $cur_value=$g_connection->get_value('select pr_value from "parameter" where pr_id=$1',[$attr]); + $this->assertTrue(($cur_value==$this->object->$attr),sprintf("failed : %s cur_value %s expected %s",$attr,$cur_value,$this->object->$attr)); + $this->assertTrue($cur_value != $old,sprintf( "failed : %s cur_value %s old %s",$attr,$cur_value,$old)); + + $this->object->$attr=$old; + $this->object->save($this->a_param[$e]); + $cur_value=$g_connection->get_value('select pr_value from "parameter" where pr_id=$1',[$attr]); + $this->assertTrue($cur_value == $old,sprintf( "failed : %s cur_value %s old %s",$attr,$cur_value,$old)); + } + + } + function testMatch_accounting() + { + $this->assertTrue($this->object->match_analytic("612")); + $this->assertTrue($this->object->match_analytic("6")); + $this->assertTrue($this->object->match_analytic("66")); + $this->assertTrue($this->object->match_analytic("71")); + $this->assertTrue($this->object->match_analytic("7")); + $this->assertFalse($this->object->match_analytic("5")); + } +} + +?> From 9b945bd430c90d0d692bf8b9809678282e5e3d82 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 29 Aug 2019 12:21:09 +0200 Subject: [PATCH 14/26] #0001643: ajout icon "cache" pour bouton "remonter" --- html/js/scripts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/js/scripts.js b/html/js/scripts.js index 81b05633c..daa1397d7 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -2946,7 +2946,7 @@ function init_scroll() "style":"padding:5px;left:auto;width:auto;height: auto;display:none;position:fixed;bottom:30%;right:50px;text-align:center;font-size:20px", id:"go_up" }); - up.innerHTML=' '; + up.innerHTML=' '; document.body.appendChild(up); window.onscroll=function () { if ( document.viewport.getScrollOffsets().top> 0) { From 76bd0fd6166a49920073d130322d09e04859a03f Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 29 Aug 2019 19:10:06 +0200 Subject: [PATCH 15/26] =?UTF-8?q?@0001735:=20icone=20poubelle=20cat=C3=A9g?= =?UTF-8?q?orie=20de=20fiche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/class/template_card_category.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/class/template_card_category.class.php b/include/class/template_card_category.class.php index b5b7e439b..e74f8f31f 100644 --- a/include/class/template_card_category.class.php +++ b/include/class/template_card_category.class.php @@ -134,10 +134,9 @@ class Template_Card_Category extends Manage_Table_SQL if (!in_array($a_attribut[$i]['ad_id'], [ATTR_DEF_NAME, ATTR_DEF_QUICKCODE])&&$used==0) { // allow to remove attribute - $js=sprintf("onclick=\"category_card.remove_attribut('%s','%s','%s',%d)\"", + $js=sprintf("category_card.remove_attribut('%s','%s','%s',%d)", Dossier::id(), $this->table->frd_id, $objname, $a_attribut[$i]['ad_id']); - echo HtmlInput::anchor(SMALLX, "", $js, - ' class="smallbutton" style="padding:0px;display:inline" '); + echo Icon_Action::trash(uniqid(), $js); } echo ''; } From e187a515bcdcb7a33065d1e37cf3049cb646a007 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 29 Aug 2019 19:14:47 +0200 Subject: [PATCH 16/26] #0001736: PHP7 comptability + translation --- include/template/fiche_def_input.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/template/fiche_def_input.php b/include/template/fiche_def_input.php index b7291e778..ceefb0c98 100644 --- a/include/template/fiche_def_input.php +++ b/include/template/fiche_def_input.php @@ -23,15 +23,15 @@ -

Modèles de catégorie

+

    $v) { ?>
  • input("FICHE_REF",$v['frd_id']); echo $v['frd_text']; - if ( sizeof ($v['frd_class_base']) != 0 ) + if ( !empty ($v['frd_class_base']) != 0 ) echo "  Class base = ".$v['frd_class_base'].""; }?> From e344c1dded0d786cd2896c000017a2f174f01c15 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 29 Aug 2019 19:21:14 +0200 Subject: [PATCH 17/26] =?UTF-8?q?#0001735:=20icone=20poubelle=20cat=C3=A9g?= =?UTF-8?q?orie=20de=20fiche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/ajax/ajax_template_cat_category.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/ajax/ajax_template_cat_category.php b/include/ajax/ajax_template_cat_category.php index 241b98954..529dcbda2 100644 --- a/include/ajax/ajax_template_cat_category.php +++ b/include/ajax/ajax_template_cat_category.php @@ -70,8 +70,7 @@ switch ($action) Dossier::id(), $frd_id, $objname, $ad_id); $answer['content']=$cn->get_value("select ad_text from attr_def where ad_id=$1", [$ad_id]). - HtmlInput::anchor(SMALLX, "javascript:void(0)", $js, - ' class="smallbutton" style="padding:0px;display:inline" '); + Icon_Action::trash(uniqid(), $js); } catch (Exception $exc) { From 23b0091fe17dfd6f38c1b84b37bba6101e0a6b40 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 29 Aug 2019 19:21:36 +0200 Subject: [PATCH 18/26] =?UTF-8?q?#0001735:=20icone=20add=20cat=C3=A9gorie?= =?UTF-8?q?=20de=20fiche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/class/template_card_category.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/class/template_card_category.class.php b/include/class/template_card_category.class.php index e74f8f31f..ee2e743c8 100644 --- a/include/class/template_card_category.class.php +++ b/include/class/template_card_category.class.php @@ -158,9 +158,7 @@ class Template_Card_Category extends Manage_Table_SQL echo $sel_attribut->input(); $js_script=sprintf("category_card.add_attribut('%s','%s','%s')", $dossier_id, $this->table->frd_id, $objname); - echo HtmlInput::button_image($js_script, uniqid(), - 'class="smallbutton image_search"', - "image/bouton-plus.png"); + echo Icon_Action::icon_add(uniqid(), $js_script); } } } From 7156fcb1cd8d7f0f6320fcec1beb76a24c213200 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 29 Aug 2019 19:26:04 +0200 Subject: [PATCH 19/26] #0001735: icone warning --- include/lib/icon_action.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/lib/icon_action.class.php b/include/lib/icon_action.class.php index cc24a325a..90cca74b5 100644 --- a/include/lib/icon_action.class.php +++ b/include/lib/icon_action.class.php @@ -195,7 +195,7 @@ class Icon_Action */ static function warnbulle($p_comment) { - $r=sprintf('', + $r=sprintf('', $p_comment, $p_comment); return $r; From 9c74020bb50500f070551f463630093a5b1d6cb2 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 30 Aug 2019 02:08:04 +0200 Subject: [PATCH 20/26] Task #0001731: Moyen de paiement , bug in ajax , if ledger==ODS a category of card is mandatory --- include/class/payment_method_mtable.class.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/class/payment_method_mtable.class.php b/include/class/payment_method_mtable.class.php index f67b60218..ab655a7d7 100644 --- a/include/class/payment_method_mtable.class.php +++ b/include/class/payment_method_mtable.class.php @@ -26,6 +26,7 @@ * @see ajax_payment_method.php */ require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php"; +require_once NOALYSS_INCLUDE."/database/jrn_def_sql.class.php"; class Payment_Method_MTable extends Manage_Table_SQL { @@ -92,11 +93,15 @@ class Payment_Method_MTable extends Manage_Table_SQL $this->set_error("mp_lib", _("Un libellé est obligatoire")); $has_error++; } - if (trim ($table->mp_qcode) != "" && $a_row['jrn_def_type'] != 'FIN') { - $fiche=new Fiche($cn); - if ( $fiche->get_by_qcode($table->mp_qcode,FALSE) == 1) { - $this->set_error("mp_qcode",_("Fiche inexistante")); - $has_error++; + + if (trim ($table->mp_qcode) != "") { + $ledger=new Jrn_def_SQL($cn , $table->jrn_def_id); + if ( $ledger->get('jrn_def_type') == 'FIN'){ + $fiche=new Fiche($cn); + if ( $fiche->get_by_qcode($table->mp_qcode,FALSE) == 1) { + $this->set_error("mp_qcode",_("Fiche inexistante")); + $has_error++; + } } } // get the type of the ledger From 3b5cb8e9dd794a6b5123835dab4611daf8a15465 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 1 Sep 2019 00:23:06 +0200 Subject: [PATCH 21/26] Data_SQL Add database indication --- include/lib/data_sql.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/lib/data_sql.class.php b/include/lib/data_sql.class.php index 5b45aa482..57827c0ca 100644 --- a/include/lib/data_sql.class.php +++ b/include/lib/data_sql.class.php @@ -46,8 +46,9 @@ */ abstract class Data_SQL { - - function __construct($p_cn, $p_id=-1) + private $cn; //! Database connection + + function __construct(DatabaseCore $p_cn, $p_id=-1) { $this->cn=$p_cn; $pk=$this->primary_key; From e4ddfd19f0cc470c911429d297b2d64cb581abae Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 4 Sep 2019 14:47:45 +0200 Subject: [PATCH 22/26] translate --- include/template/letter_all.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/template/letter_all.php b/include/template/letter_all.php index 5af29165e..0239ead61 100644 --- a/include/template/letter_all.php +++ b/include/template/letter_all.php @@ -50,7 +50,7 @@ $class= ( ($i % 2) == 0 ) ? "odd":"even"; > content[$i]['letter']==-1)?" aucun lettrage ":strtoupper(base_convert($this->content[$i]['letter'],10,36)); +$letter=($this->content[$i]['letter']==-1)?_("aucun lettrage"):strtoupper(base_convert($this->content[$i]['letter'],10,36)); $js="this.gDossier=".dossier::id(). ";this.j_id=".$this->content[$i]['j_id']. ";this.obj_type='".$this->object_type."'". From 72342dbec2b4a66ca193052f0b4e5432c4f6f92a Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 4 Sep 2019 21:11:10 +0200 Subject: [PATCH 23/26] Data_SQL add the member --- include/lib/data_sql.class.php | 88 +++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/include/lib/data_sql.class.php b/include/lib/data_sql.class.php index 57827c0ca..e3bdb1656 100644 --- a/include/lib/data_sql.class.php +++ b/include/lib/data_sql.class.php @@ -42,11 +42,39 @@ * After you call the parent constructor * @note the view or the table must include an unique key, otherwise the load * doesn't work. + * + * @pnote + * Name is an array the key is the logical name and the value is the name of the column + @code + $this->name=array( + "id"=>"o_id", + "program"=>"o_prog", + "date"=>"o_date", + "qcode"=>"o_qcode", + "fiche"=>"f_id", + ); +@endcode * + the type is an array , key = column name , value = type + + * @code + $this->type = array( + "o_id"=>"numeric", + "o_prog"=>"numeric", + "o_date"=>"date", + "o_qcode"=>"text", + "f_id"=>"numeric", + ); +@endcode + * */ abstract class Data_SQL { - private $cn; //! Database connection + private $cn; //! Database connection + var $name; //! Array of logical and real name + var $primary_key; //! Column name of the primary key + var $type; //! Type of the data + var $date_format; //! defaullt date format function __construct(DatabaseCore $p_cn, $p_id=-1) { @@ -65,6 +93,7 @@ abstract class Data_SQL $this->$pk=$p_id; /* load it */ if ($p_id != -1 )$this->load(); + if ( empty($this->date_format) ) $this->date_format="DD.MM.YYYY"; } /** * Insert or update : if the row already exists, update otherwise insert @@ -264,6 +293,63 @@ abstract class Data_SQL * @return integer 0 doesn't exist , 1 exists */ abstract function exist() ; + public function get_cn() + { + return $this->cn; + } + + public function get_name() + { + return $this->name; + } + + public function get_primary_key() + { + return $this->primary_key; + } + + public function get_type() + { + return $this->type; + } + + public function set_cn($cn) + { + $this->cn=$cn; + return $this; + } + /** + * + * @param string $name + * @return $this + */ + public function set_name($name) + { + $this->name=$name; + return $this; + } + /** + * + * @param string $primary_key + * @return $this + */ + public function set_primary_key($primary_key) + { + $this->primary_key=$primary_key; + return $this; + } + /** + * + * @param array $type + * @return $this + */ + public function set_type($type) + { + $this->type=$type; + return $this; + } + + } ?> From d0b254366972beb94d738697f469ec700d3c1b8c Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 4 Sep 2019 21:11:37 +0200 Subject: [PATCH 24/26] Noalyss_SQL Create a function build query --- include/lib/noalyss_sql.class.php | 46 ++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/include/lib/noalyss_sql.class.php b/include/lib/noalyss_sql.class.php index 0e23ca832..aa40129f1 100644 --- a/include/lib/noalyss_sql.class.php +++ b/include/lib/noalyss_sql.class.php @@ -87,6 +87,7 @@ require NOALYSS_INCLUDE."/lib/data_sql.class.php"; abstract class Noalyss_SQL extends Data_SQL { + var $default; function __construct(&$p_cn, $p_id=-1) { $this->cn=$p_cn; @@ -104,6 +105,7 @@ abstract class Noalyss_SQL extends Data_SQL $this->$pk=$p_id; /* load it */ if ($p_id != -1 )$this->load(); + } /** * Insert or update : if the row already exists, update otherwise insert @@ -255,23 +257,8 @@ abstract class Noalyss_SQL extends Data_SQL public function load() { - $sql=" select "; - $sep=""; - foreach ($this->name as $key) { - switch ($this->type[$key]) - { - case "date": - $sql .= $sep.'to_char('.$key.",'".$this->date_format."') as ".$key; - break; - default: - $sql.=$sep.$key; - } - $sep=","; - } + $sql=$this->build_query(); $pk=$this->primary_key; - $sql.=" from ".$this->table; - - $sql.=" where ".$this->primary_key." = $1"; $result=$this->cn->get_array($sql,array ($this->$pk)); if ($this->cn->count()==0) @@ -412,6 +399,33 @@ abstract class Noalyss_SQL extends Data_SQL $count=$this->cn->get_value("select count(*) from ".$this->table." where ".$this->primary_key."=$1",array($this->$pk)); return $count; } + + /** + * Build the SQL select statement for querying the object and returns it + * @return string Query of the object + */ + public function build_query() + { + $sql=" select "; + $sep=""; + foreach ($this->name as $key) { + switch ($this->type[$key]) + { + case "date": + $sql .= $sep.'to_char('.$key.",'".$this->date_format."') as ".$key; + break; + default: + $sql.=$sep.$key; + } + $sep=","; + } + $pk=$this->primary_key; + $sql.=" from ".$this->table; + + $sql.=" where ".$this->primary_key." = $1"; + + return $sql; + } } ?> From cd34856cfeb60709347eb2658a901440e62f9a4d Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 4 Sep 2019 21:11:53 +0200 Subject: [PATCH 25/26] PDF_Core : add function get --- include/lib/pdf_core.class.php | 35 ++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/include/lib/pdf_core.class.php b/include/lib/pdf_core.class.php index 91c76723b..abfbb9290 100644 --- a/include/lib/pdf_core.class.php +++ b/include/lib/pdf_core.class.php @@ -58,7 +58,7 @@ class PDF_Core extends TFPDF public function __construct ( $orientation = 'P', $unit = 'mm', $format = 'A4') { - $this->bigger=0; + $this->bigger=0; parent::__construct($orientation, $unit, $format); $this->AddFont('DejaVu','','DejaVuSans.ttf',true); @@ -68,12 +68,39 @@ class PDF_Core extends TFPDF $this->AddFont('DejaVuCond','B','DejaVuSansCondensed-Bold.ttf',true); $this->AddFont('DejaVuCond','I','DejaVuSansCondensed-Oblique.ttf',true); - + $this->cells=array(); } - - + function get_margin_left() + { + return $this->lMargin; + } + function get_margin_bottom() + { + return $this->bMargin; + + } + function get_margin_top() + { + return $this->tMargin; + } + function get_margin_right() + { + return $this->rMargin; + } + function get_orientation() + { + return $this->DefOrientation; + } + function get_unit() + { + return $this->k; + } + function get_page_size() + { + return $this->DefPageSize; + } /** * Count the number of rows a p_text will take for a multicell * @param $p_text String From 61db6699e035f9c1cb400a80d340163f8408d8c2 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 4 Sep 2019 21:12:19 +0200 Subject: [PATCH 26/26] Database_Core add function with the number of cols --- include/lib/database_core.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/lib/database_core.class.php b/include/lib/database_core.class.php index c4fb518ac..8a8d3d24c 100644 --- a/include/lib/database_core.class.php +++ b/include/lib/database_core.class.php @@ -946,6 +946,14 @@ class DatabaseCore $csv->write(); } } + /** + * Returns the number of columns in a ret + * @param handler $p_ret handler to a query + */ + static function nb_column($p_ret) { + return pg_num_fields($p_ret); + } + } /* test::test_me(); */