From 023f07f89a76ef3eb7235d8e9b3d31be70f45424 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 27 Jun 2017 19:46:23 +0200 Subject: [PATCH 01/22] Manage_SQL : improve cosmetic + add error function --- html/js/infobulle.js | 7 ++ html/js/managetable.js | 15 ++- include/database/class_noalyss_sql.php | 3 +- include/lib/class_html_input.php | 11 +- include/lib/class_manage_table_sql.php | 165 ++++++++++++++++++------- 5 files changed, 149 insertions(+), 52 deletions(-) diff --git a/html/js/infobulle.js b/html/js/infobulle.js index 525585ff7..e87b19b1f 100644 --- a/html/js/infobulle.js +++ b/html/js/infobulle.js @@ -52,3 +52,10 @@ function hideBulle(p_ctl) var d=document.getElementById('bulle'); d.style.visibility="hidden"; } +function displayBulle(p_comment) { + var d=document.getElementById('bulle'); + d.innerHTML=p_comment; + d.style.top=posY+offsetY+"px"; + d.style.left=posX+offsetX+"px"; + d.style.visibility="visible"; +} \ No newline at end of file diff --git a/html/js/managetable.js b/html/js/managetable.js index 1e84a54c7..29e2f070c 100644 --- a/html/js/managetable.js +++ b/html/js/managetable.js @@ -172,16 +172,19 @@ var ManageTable = function (p_table_name) new_row.innerHTML = answer['html']; $("tb"+answer['ctl']).appendChild(new_row); } - new Effect.Highlight(answer['ctl_row'] ,{ startcolor: '#ABCBF7',endcolor: '#ffffff' }); + new Effect.Highlight(answer['ctl_row'] ,{startcolor: '#FAD4D4',endcolor: '#F78082' }); + alternate_row_color("tb"+answer['ctl']); + remove_waiting_box(); + $("dtr").hide(); } else { + remove_waiting_box(); smoke.alert("Changement impossible"); - throw "error in save"; + $("dtr").update(answer['html']); + } - alternate_row_color("tb"+answer['ctl']); - remove_waiting_box(); - $("dtr").hide(); - } catch (e) { + } + catch (e) { alert(e.message); return false; } diff --git a/include/database/class_noalyss_sql.php b/include/database/class_noalyss_sql.php index 34eb68948..35b5677cd 100644 --- a/include/database/class_noalyss_sql.php +++ b/include/database/class_noalyss_sql.php @@ -95,8 +95,7 @@ abstract class Noalyss_SQL */ public function save() { - $pk=$this->primary_key; - $count=$this->cn->get_value('select count(*) from '.$this->table.' where '.$this->primary_key.'=$1',array($this->$pk)); + $count = $this->exist(); if ($count == 0) $this->insert(); diff --git a/include/lib/class_html_input.php b/include/lib/class_html_input.php index 5fad2b752..fb6e63745 100755 --- a/include/lib/class_html_input.php +++ b/include/lib/class_html_input.php @@ -228,6 +228,15 @@ class HtmlInput $r='Δ'; return $r; } + static function errorbulle($p_comment) + { + global $g_failed; + $r=sprintf(' %s ', + $p_comment, + $p_comment, + $g_failed); + return $r; + } /** * return a string containing the html code for calling the modifyOperation */ @@ -476,7 +485,7 @@ class HtmlInput */ static function image_click($p_image,$p_js,$p_message) { - $ret=sprintf('', + $ret=sprintf('', $p_message,$p_image,$p_js); return $ret; diff --git a/include/lib/class_manage_table_sql.php b/include/lib/class_manage_table_sql.php index 1964e158c..b52259765 100644 --- a/include/lib/class_manage_table_sql.php +++ b/include/lib/class_manage_table_sql.php @@ -67,7 +67,7 @@ class Manage_Table_SQL private $row_update; //!< Flag to indicate if rows can be updated private $row_append; //!< Flag to indicate if rows can be added private $json_parameter; //!< Default parameter to add (gDossier...) - + private $aerror; //!< Array containing the error of the input data const UPDATABLE=1; const VISIBLE=2; @@ -97,8 +97,42 @@ class Manage_Table_SQL $this->callback="ajax.php"; $this->json=json_encode(array("gDossier"=>Dossier::id(), "op"=>"managetable")); + $this->aerror=[]; + } + function get_table() { + return $this->table; + } + /** + * @brief set the error message for a wrong input + * @param $p_col the column name + * @param $p_message the error message + * @see check + */ + function set_error($p_col,$p_message) + { + $this->aerror[$p_col]=$p_message; + } + /** + * @brief retrieve the error message + * @param $p_col column name + * @return string with message or empty if no error + * @see input + */ + function get_error($p_col) + { + if ( isset ($this->aerror[$p_col])) return $this->aerror[$p_col]; + return ""; + } + /** + * This function can be overrided to check the data before + * inserting , updating or removing, + * @see set_error get_error + * @return boolean + */ + function check() + { + return true; } - /** * @brief set the type of a column , it will change in the input db box , the * select must supply an array of possible values [val=> , label=>] with @@ -453,7 +487,7 @@ class Manage_Table_SQL } /** - * @brief set the id value of a data row + * @brief set the id value of a data row and load from the db */ function set_pk($p_id) { @@ -462,7 +496,9 @@ class Manage_Table_SQL } /** - * @brief get the data from http request + * @brief get the data from http request strip the not update or not visible data to their + * initial value. Before saving , it is important to set the pk and load from db + * @see set_pk */ function from_request() { @@ -471,7 +507,11 @@ class Manage_Table_SQL { $v=HtmlInput::default_value_request($this->a_order[$i], ""); $key=$this->a_order[$i]; - $this->table->$key=strip_tags($v); + if ( $this->get_property_visible($key) == TRUE + && $this->get_property_updatable($key) == TRUE ) + { + $this->table->$key=strip_tags($v); + } } } @@ -509,7 +549,7 @@ class Manage_Table_SQL $js=sprintf("%s.delete('%s','%s');", $this->object_name, $p_row[$this->table->primary_key], $this->object_name ); - echo HtmlInput::image_click("delete.gif", $js,_("effacer")); + echo HtmlInput::image_click("delete.gif", $js,_("Effacer")); } echo ""; echo ''; @@ -529,11 +569,12 @@ class Manage_Table_SQL $key=$this->a_order[$i]; $label=$this->a_label_displaid[$key]; $value=$this->table->get($key); - + $error=$this->get_error($key); + $error=($error=="")?"":HtmlInput::errorbulle($error); if ($this->get_property_visible($key)===TRUE) { // Label - echo " {$label} "; + echo " {$label} {$error}"; if ($this->get_property_updatable($key)==TRUE) { @@ -545,16 +586,29 @@ class Manage_Table_SQL $select->selected=$value; echo $select->input(); } - else + elseif ($this->a_type[$key]=="text") { $text=new IText($key); $text->value=$value; $min_size=(strlen($value)<30)?30:strlen($value)+5; $text->size=$min_size; echo $text->input(); - /* printf('', - $label, $value, $key, $key - );*/ + } + elseif ($this->a_type[$key]=="numeric") + { + $text=new INum($key); + $text->value=$value; + $min_size=(strlen($value)<10)?10:strlen($value)+1; + $text->size=$min_size; + echo $text->input(); + } + elseif ($this->a_type[$key]=="date") + { + $text=new IDate($key); + $text->value=$value; + $min_size=10; + $text->size=$min_size; + echo $text->input(); } echo ""; } @@ -584,30 +638,38 @@ class Manage_Table_SQL { // fill up object with $_REQUEST $this->from_request(); - // save the object - $this->save(); - // compose the answer - $status="OK"; - $s1=$xml->createElement("status", $status); - $ctl=$this->object_name."_".$this->table->get_pk_value(); - $s2=$xml->createElement("ctl_row", $ctl); - $s4=$xml->createElement("ctl", $this->object_name); - ob_start(); - $this->table->load(); - $array=$this->table->to_array(); - $this->display_row($array); - $html=ob_get_contents(); - ob_end_clean(); - $s3=$xml->createElement("html" ); - $t1=$xml->createTextNode($html); - $s3->appendChild($t1); - + // Check if the data are valid , if not then display the + // input values with the error message + // + if ( $this->check() == false ) { + $xml=$this->ajax_input("NOK"); + return $xml; + } else { + // Data are valid so we can save them + $this->save(); + // compose the answer + $status="OK"; + $s1=$xml->createElement("status", $status); + $ctl=$this->object_name."_".$this->table->get_pk_value(); + $s2=$xml->createElement("ctl_row", $ctl); + $s4=$xml->createElement("ctl", $this->object_name); + ob_start(); + $this->table->load(); + $array=$this->table->to_array(); + $this->display_row($array); + $html=ob_get_contents(); + ob_end_clean(); + $s3=$xml->createElement("html" ); + $t1=$xml->createTextNode($html); + $s3->appendChild($t1); + } $root=$xml->createElement("data"); $root->appendChild($s1); $root->appendChild($s2); $root->appendChild($s3); $root->appendChild($s4); + $xml->appendChild($root); } catch (Exception $ex) { @@ -621,8 +683,8 @@ class Manage_Table_SQL $root->appendChild($s2); $root->appendChild($s3); $root->appendChild($s4); + $xml->appendChild($root); } - $xml->appendChild($root); return $xml; } @@ -634,13 +696,13 @@ class Manage_Table_SQL * - content : Html answer * @return DomDocument */ - function ajax_input() + function ajax_input($p_status="OK") { $xml=new DOMDocument("1.0", "UTF-8"); - $xml->createElement("status", "OK"); + $xml->createElement("status", $p_status); try { - $status="OK"; + $status=$p_status; ob_start(); echo HtmlInput::title_box("Donnée", "dtr"); @@ -654,6 +716,8 @@ class Manage_Table_SQL echo HtmlInput::hidden("p_id", $this->table->get_pk_value()); // button Submit and cancel $close=sprintf("\$('%s').remove()", "dtr"); + // display error if any + $this->display_error(); echo ''; echo ""; - + + $html=ob_get_contents(); ob_end_clean(); @@ -756,14 +821,7 @@ class Manage_Table_SQL */ function save() { - if ($this->table->exist()==0) - { - $this->table->insert(); - } - else - { - $this->table->update(); - } + $this->table->save(); } /** @@ -795,5 +853,26 @@ class Manage_Table_SQL { $this->table->set($p_key, $p_value); } + /** + * Display a list of the error collected + * @see get_error set_error + * + */ + function display_error() + { + $nb_order=count($this->a_order); + if ( count($this->aerror) == 0)return; + echo "Liste erreurs :"; + for ($i=0; $i<$nb_order; $i++) + { + $key=$this->a_order[$i]; + $label=$this->a_label_displaid[$key]; + $error=$this->get_error($key); + $error=($error=="")?"":"".h($label)." : ".h($this->get_error($key)).""; + + echo $error; + } + echo ""; + } } From 5ca7658031af60867fd43aa90e9399a34b49ce8b Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 4 Jul 2017 00:07:31 +0200 Subject: [PATCH 02/22] Improve debug --- html/do.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/html/do.php b/html/do.php index df7396bd7..cae78fb8a 100644 --- a/html/do.php +++ b/html/do.php @@ -101,6 +101,20 @@ if ( DEBUG ) { +

$_REQUEST

+ +

$_SESSION

+ + +

$GLOBALS

+ + ', $this->object_name); } @@ -478,10 +480,10 @@ class Manage_Table_SQL echo th($this->a_label_displaid[$key]); } if ($this->can_update_row()) { - echo td(_('Modifier')); + echo th(" ",'style="width:40px"'); } if ($this->can_delete_row()) { - echo td(_('Effacer')); + echo th(" ",'style="width:40px"'); } echo ""; } From cc03a7a6d11da1386a50435fc3f5b110881a86c8 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 4 Jul 2017 00:08:40 +0200 Subject: [PATCH 04/22] HtmlInput::button_action: add icon , htmlInput : add documentation --- include/lib/class_html_input.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/lib/class_html_input.php b/include/lib/class_html_input.php index fb6e63745..c8b0d773b 100755 --- a/include/lib/class_html_input.php +++ b/include/lib/class_html_input.php @@ -463,17 +463,20 @@ class HtmlInput return $r; } /** - * button Html + * button Html with javascript *@param $action action action to perform (message) without onclick *@param $javascript javascript to execute + *@param $id is the DOM element id + *@param $p_class CSS class of the button + *@param $p_symbole raw symbole to add to the action message */ - static function button_action($action,$javascript,$id="xx",$p_class="button") + static function button_action($action,$javascript,$id="xx",$p_class="button",$p_symbole="") { if ($id=="xx"){ $id=HtmlInput::generate_id("xx"); } $r=""; - $r.=''; + $r.=''; return $r; } From 85566da94c911ac9cb16fb61d91a88e734816e75 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 5 Jul 2017 10:33:39 +0200 Subject: [PATCH 05/22] New function manage_table::set_table, and manage_table::delete --- include/lib/class_manage_table_sql.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/lib/class_manage_table_sql.php b/include/lib/class_manage_table_sql.php index 2a9bb39ab..bc8c4537f 100644 --- a/include/lib/class_manage_table_sql.php +++ b/include/lib/class_manage_table_sql.php @@ -102,6 +102,9 @@ class Manage_Table_SQL function get_table() { return $this->table; } + function set_table(Noalyss_SQL $p_noalyss_sql) { + $this->table=$p_noalyss_sql; + } /** * @brief set the error message for a wrong input * @param $p_col the column name @@ -784,7 +787,7 @@ class Manage_Table_SQL $xml=new DOMDocument('1.0', "UTF-8"); try { - $this->table->delete(); + $this->delete(); $status="OK"; $s1=$xml->createElement("status", $status); $ctl=$this->object_name."_".$this->table->get_pk_value(); From 29d9ffe4fbd6cbec746614b6147f6d6935f8b197 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 12 Jul 2017 19:29:59 +0200 Subject: [PATCH 06/22] Bug : cannot print action in profil Cannot add a export / printing in profile --- include/ajax/ajax_get_profile.php | 1 + include/class/class_profile_menu.php | 1 + include/profile.inc.php | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/ajax/ajax_get_profile.php b/include/ajax/ajax_get_profile.php index 952852b86..2ef1618df 100644 --- a/include/ajax/ajax_get_profile.php +++ b/include/ajax/ajax_get_profile.php @@ -55,6 +55,7 @@ $a_tab[$call_tab]='tabs_selected';
  •   +
  • + cn->exec_sql(" diff --git a/include/profile.inc.php b/include/profile.inc.php index 63715e893..6a1b15ffe 100644 --- a/include/profile.inc.php +++ b/include/profile.inc.php @@ -350,7 +350,7 @@ if (isset($_POST['add_menu'])||isset($_POST['add_impress'])) * Do not insert twice the same menu */ $duplicate = $cn->get_value(" select count(*) from profile_menu where " - . " pm_id_dep = $1 and me_code = $2",array($p_dep,$me_code)); + . " pm_id_dep = $1 and me_code = $2",array($pm_id_dep,$me_code)); if ( $duplicate > 0 ) { throw new Exception(_('Doublon')); } From 67ea72a02b904da4a0ffcb633e00d6e89a3743a7 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 28 Aug 2017 18:59:37 +0200 Subject: [PATCH 07/22] index.php version --- html/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/index.php b/html/index.php index 7c614fe2d..559eace39 100644 --- a/html/index.php +++ b/html/index.php @@ -261,7 +261,7 @@ if (isset ($_REQUEST['reconnect']) && isset ($_REQUEST['backurl'])) { } echo ' -version NOALYSS_VERSION - '.$my_domain.' +version 6919+3 - '.$my_domain.'

    From fa72daa9efec01a5770b70072b20001eb64c52ba Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 28 Aug 2017 19:00:11 +0200 Subject: [PATCH 08/22] noalyss_sql.class fix bug in function set --- include/database/class_noalyss_sql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/database/class_noalyss_sql.php b/include/database/class_noalyss_sql.php index 35b5677cd..9dab28e67 100644 --- a/include/database/class_noalyss_sql.php +++ b/include/database/class_noalyss_sql.php @@ -122,7 +122,7 @@ abstract class Noalyss_SQL public function set($p_string, $p_value) { if (array_key_exists($p_string, $this->type)) { - $this->$idx=$p_value; + $this->$p_string=$p_value; } else throw new Exception(__FILE__.":".__LINE__.$p_string.'Erreur attribut inexistant '.$p_string); } From ceb5427110826e49f9bf1748574fa3f3d0b3cc32 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 28 Aug 2017 19:05:17 +0200 Subject: [PATCH 09/22] Version --- html/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/index.php b/html/index.php index 559eace39..8ea2b40ca 100644 --- a/html/index.php +++ b/html/index.php @@ -261,7 +261,7 @@ if (isset ($_REQUEST['reconnect']) && isset ($_REQUEST['backurl'])) { } echo ' -version 6919+3 - '.$my_domain.' +version 6919+5 - '.$my_domain.'

    From b6b7bf6381d3c9789447475fbac085cab6daea62 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 28 Aug 2017 19:06:04 +0200 Subject: [PATCH 10/22] Version --- include/constant.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/constant.php b/include/constant.php index a2bb1317c..3396b698f 100644 --- a/include/constant.php +++ b/include/constant.php @@ -88,7 +88,7 @@ define ('SMALLX','ⵝ'); define ('BUTTONADD',"✚"); -define ('SVNINFO',NOALYSS_VERSION); +define ('SVNINFO',6919+5); if ( ! defined ('DEBUG')) { define ("DEBUG",false); } From 1879d10288d449f4bfa0cb5b272cd05518347b6d Mon Sep 17 00:00:00 2001 From: Dany DE BONTRIDDER Date: Fri, 8 Dec 2017 13:30:11 +0100 Subject: [PATCH 11/22] Fix problem with invalid unicode sequence --- html/fid_card.php | 10 +++++----- html/js/ajax_fiche.js | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/html/fid_card.php b/html/fid_card.php index fab07b321..3bc6e9112 100644 --- a/html/fid_card.php +++ b/html/fid_card.php @@ -146,13 +146,13 @@ if (sizeof($sql) != 0 ) $sql_name=$cn->execute('get_name',array($sql[$i]['f_id'],23)); if (Database::num_row($sql_name) == 1) $quick_code=Database::fetch_result($sql_name,0,0); - + $fid=htmlentities($_REQUEST['FID']); /* Highlight the found pattern with bold format */ - $name=str_ireplace($_REQUEST['FID'],''.$_REQUEST['FID'].'',h($name)); - $qcode=str_ireplace($_REQUEST['FID'],''.$_REQUEST['FID'].'',h($quick_code)); - $desc=str_ireplace($_REQUEST['FID'],''.$_REQUEST['FID'].'',h($desc)); - printf('
  • %s %s %s
  • ', + $name=str_ireplace($_REQUEST['FID'],''.$fid.'',h($name)); + $qcode=str_ireplace($_REQUEST['FID'],''.$fid.'',h($quick_code)); + $desc=str_ireplace($_REQUEST['FID'],''.$fid.'',h($desc)); + printf('
  • %s %s %s
  • ', $quick_code, $quick_code, $name, diff --git a/html/js/ajax_fiche.js b/html/js/ajax_fiche.js index 88503ed4b..28e7afb0b 100644 --- a/html/js/ajax_fiche.js +++ b/html/js/ajax_fiche.js @@ -116,6 +116,7 @@ function ajaxFid(p_ctl) } queryString=queryString+"&j="+jrn+'&gDossier='+gDossier; queryString=queryString+'&ctl='+p_ctl.id; + queryString=encodeURI(queryString); var action=new Ajax.Request ( "fid.php", From ac996a79b46d3f956095e54b898ecfe02668ae95 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 8 Dec 2017 20:11:22 +0100 Subject: [PATCH 12/22] Protect queryString with encodeURI --- html/js/acc_ledger.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 4cbc79070..656c4b555 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -162,7 +162,7 @@ function update_row(ctl) { var jrn = g('p_jrn').value; var dossier = g('gDossier').value; - var qs = 'gDossier=' + dossier + '&op=minrow&j=' + jrn + '&ctl=' + ctl; + var qs = encodeURI('gDossier=' + dossier + '&op=minrow&j=' + jrn + '&ctl=' + ctl); var action = new Ajax.Request( "ajax_misc.php", { @@ -915,7 +915,7 @@ function filter_card(obj, queryString) { queryString = queryString + '&j=' + jrn; } - return queryString; + return encodeURI(queryString); } /** *@brief to display the lettering for the operation, call @@ -1056,7 +1056,7 @@ function op_save(obj) var action = new Ajax.Request('ajax_misc.php', { method: 'post', - parameters: queryString, + parameters: encodeURI(queryString), onFailure: null, onSuccess: infodiv } From fc2760f9fce0df361150aef229da3a04b0dcc16f Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 8 Dec 2017 20:25:53 +0100 Subject: [PATCH 13/22] fix bug with filter_card : encodeURI not needed --- html/js/acc_ledger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 656c4b555..5c62bddea 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -915,7 +915,7 @@ function filter_card(obj, queryString) { queryString = queryString + '&j=' + jrn; } - return encodeURI(queryString); + return queryString; } /** *@brief to display the lettering for the operation, call From 22e589833bb07bdc9602d7271a23083e3510c45f Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 8 Dec 2017 20:27:25 +0100 Subject: [PATCH 14/22] Set version 6919.6 --- html/index.php | 2 +- include/constant.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/html/index.php b/html/index.php index 8ea2b40ca..7edff3f47 100644 --- a/html/index.php +++ b/html/index.php @@ -261,7 +261,7 @@ if (isset ($_REQUEST['reconnect']) && isset ($_REQUEST['backurl'])) { } echo ' -version 6919+5 - '.$my_domain.' +version 6919+6 - '.$my_domain.'

    diff --git a/include/constant.php b/include/constant.php index 3396b698f..155194b52 100644 --- a/include/constant.php +++ b/include/constant.php @@ -88,7 +88,7 @@ define ('SMALLX','ⵝ'); define ('BUTTONADD',"✚"); -define ('SVNINFO',6919+5); +define ('SVNINFO',6919+6); if ( ! defined ('DEBUG')) { define ("DEBUG",false); } From 163d9ce0585aa199bf7d7347920e0d4835d4eb30 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 14 Dec 2017 21:28:45 +0100 Subject: [PATCH 15/22] Accounting : error message if accounting is too large --- html/js/card.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/html/js/card.js b/html/js/card.js index 8b4fa9383..552f9c69e 100644 --- a/html/js/card.js +++ b/html/js/card.js @@ -692,9 +692,13 @@ function form_blank_card(obj) */ function save_card(obj) { - var content=$(obj).ipopup; + var accounting= $(obj)['av_text25']; + if ( accounting.value.length > 40 ) { + smoke.alert('Poste comptable trop grand'); + return false; + } // Data must be taken here - data=$('save_card').serialize(false); + var data=$('save_card').serialize(false); var content=$(obj).ipopup; $(content).innerHTML=loading(); var dossier=$('gDossier').value; From b6aaaeeb9319afa2af5623d8ff3670424fa771f4 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 14 Dec 2017 21:34:20 +0100 Subject: [PATCH 16/22] Accounting : error message if accounting is too large --- html/js/card.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/html/js/card.js b/html/js/card.js index 552f9c69e..547bd20cb 100644 --- a/html/js/card.js +++ b/html/js/card.js @@ -692,10 +692,12 @@ function form_blank_card(obj) */ function save_card(obj) { - var accounting= $(obj)['av_text25']; - if ( accounting.value.length > 40 ) { - smoke.alert('Poste comptable trop grand'); - return false; + if ($(obj)['av_text5']) { + var accounting= $(obj)['av_text5']; + if ( accounting.value.length > 40 ) { + smoke.alert('Poste comptable trop grand'); + return false; + } } // Data must be taken here var data=$('save_card').serialize(false); var content=$(obj).ipopup; From 72179995be93940274cb44e3ce39c765cc47cb51 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 14 Dec 2017 21:53:49 +0100 Subject: [PATCH 17/22] set version 6919.7 --- include/constant.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/constant.php b/include/constant.php index 155194b52..de991bcbf 100644 --- a/include/constant.php +++ b/include/constant.php @@ -88,7 +88,7 @@ define ('SMALLX','ⵝ'); define ('BUTTONADD',"✚"); -define ('SVNINFO',6919+6); +define ('SVNINFO',6919+7); if ( ! defined ('DEBUG')) { define ("DEBUG",false); } From be75a27d2e14cfdf14a7f4355879af0eb5cad355 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 12 Dec 2017 19:55:57 +0100 Subject: [PATCH 18/22] =?UTF-8?q?Task=20#0001507:=20Click=20sur=20d=C3=A9t?= =?UTF-8?q?ail=20op=C3=A9rations=20appara=C3=AEt=20trop=20haut=20Use=20the?= =?UTF-8?q?=20function=20window.pageYOffset=20instead=20of=20window.scroll?= =?UTF-8?q?Y?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/js/scripts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/js/scripts.js b/html/js/scripts.js index 83054b9bb..87e9b90fa 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -1436,9 +1436,9 @@ function fixed_position(p_sx, p_sy) function calcy(p_sy) { var sy = p_sy; - if (window.scrollY) + if (window.pageYOffset) { - sy = window.scrollY + p_sy; + sy = window.pageYOffset + p_sy; } else { From 518119e9c837160d48a0919a2be4c31471a7113b Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 28 Nov 2017 19:17:40 +0100 Subject: [PATCH 19/22] Improve calc --- html/js/calc.js | 11 ++++++++--- html/js/scripts.js | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/html/js/calc.js b/html/js/calc.js index 37477c5cb..4789efcee 100644 --- a/html/js/calc.js +++ b/html/js/calc.js @@ -38,6 +38,12 @@ function cal() try { Compute(); + p_variable=p_variable.replace(/[a-z]/,''); + p_variable=p_variable.replace(/[A-Z]/,''); + p_variable=p_variable.replace(//,''); p_variable=p_variable.replace(/ /g,""); p_variable=p_variable.replace(/\+/g,"+ "); p_variable=p_variable.replace(/-/g,"- "); @@ -52,9 +58,8 @@ function cal() alert_box("Mauvaise formule\n"+p_variable); return false; } - p_history=p_history+'
    '+p_variable; - p_history+="="+result.toString(); - var str_sub="

    Total :"+p_variable+" = "+result.toString()+"

    "; + p_history=p_variable+"="+result.toString()+'
    '+p_history; + var str_sub="Total :"+p_variable+" = "+result.toString(); this.document.getElementById("sub_total").innerHTML=str_sub; this.document.getElementById("listing").innerHTML=p_history; this.document.getElementById('inp').value=""; diff --git a/html/js/scripts.js b/html/js/scripts.js index 87e9b90fa..5a4299537 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -1062,7 +1062,7 @@ function show_calc() shtml += ''; shtml += '

    Calculatrice

    '; shtml += '
    Calculatrice simplifiée: écrivez simplement les opérations que vous voulez puis la touche retour. exemple : 1+2+3*(1/5) '; - shtml += '

    Taper une formule (ex 20*5.1) puis enter
    '; + shtml += ' Taper une formule (ex 20*5.1) puis enter '; var obj = {id: sid, html: shtml, drag: true, style: '' From 5c595c6ac952424d82dc51b173e17244b05c9fed Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 14 Dec 2017 22:05:59 +0100 Subject: [PATCH 20/22] Calc : set 4 decimals --- html/js/calc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/js/calc.js b/html/js/calc.js index 4789efcee..5460a7bfb 100644 --- a/html/js/calc.js +++ b/html/js/calc.js @@ -51,7 +51,7 @@ function cal() sub=eval(p_variable); var result=parseFloat(sub); - result=Math.round(result*100)/100; + result=Math.round(result*10000)/10000; } catch(exception) { From 38b0e7f61d6addcbd01a83993bb495d9c7869763 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 16 Sep 2017 11:48:42 +0200 Subject: [PATCH 21/22] NEW : ICard , you can hide or show the accounting in the search box with the functions ICard->hide_accounting and ICard->show_accounting --- html/js/card.js | 16 +++++++++++++++- include/ajax/ajax_card.php | 3 ++- include/lib/class_icard.php | 15 ++++++++++++++- include/template/card_result.php | 9 ++++++++- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/html/js/card.js b/html/js/card.js index 547bd20cb..c8e7083bf 100644 --- a/html/js/card.js +++ b/html/js/card.js @@ -64,6 +64,7 @@ function boxsearch_card(p_dossier) * - inp input text to update with the quickcode * - label field to update with the name * - ctl the id to fill with the HTML answer (ending with _content) + * - acc 1 if accounting are visible */ function search_card(obj) { @@ -86,10 +87,17 @@ function search_card(obj) jrn=-1; } } + var accvis=obj.accvis; + if ( accvis == undefined ) { + accvis=0; + } else { + accvis=obj.accvis; + } var query=encodeJSON({'gDossier':gDossier, 'inp':inp,'label':label,'price':price,'tvaid':tvaid, 'ctl':'search_card','op2':'fs','jrn':jrn, - 'typecard':typecard,'query':string_to_search,'op':'card' + 'typecard':typecard,'query':string_to_search,'op':'card', + 'accvis':accvis }); if ( $('search_card') ) { removeDiv('search_card'); @@ -259,6 +267,12 @@ function search_get_card(obj) { queryString+="&ctl="+obj.ctl; } + if ( obj.elements['accvis'] ) + { + queryString+="&accvis="+$F(accvis); + } else { + queryString+="&accvis=0"; + } $('asearch').innerHTML=loading(); var action=new Ajax.Request ( 'ajax_misc.php', { diff --git a/include/ajax/ajax_card.php b/include/ajax/ajax_card.php index 22b9a7bd0..ca6c88787 100644 --- a/include/ajax/ajax_card.php +++ b/include/ajax/ajax_card.php @@ -51,6 +51,7 @@ * - ctl (to return) * - popup * - ref if we want to refresh the window + * - acc is accounting is visible or not *\see fiche fiche::Save constant.php */ if ( ! defined('ALLOWED')) die (_('Accès non autorisé')); @@ -350,7 +351,7 @@ case 'fs': $r.=''; $r.=dossier::hidden().HtmlInput::hidden('op','fs'); $array=array(); - foreach (array('query','inp','jrn','label','typecard','price','tvaid') as $i) + foreach (array('accvis','query','inp','jrn','label','typecard','price','tvaid') as $i) { if (isset(${$i}) ) { diff --git a/include/lib/class_icard.php b/include/lib/class_icard.php index 437f150c6..42a99c02a 100644 --- a/include/lib/class_icard.php +++ b/include/lib/class_icard.php @@ -132,6 +132,19 @@ class ICard extends HtmlInput $this->choice_create=1; $this->autocomplete=1; $this->style=' style="vertical-align:50%"'; + $this->accvis=1; //!< account_visible =1 otherwise 0 + } + /** + * @brief in the search box, the accounting will be hidden + */ + function hide_accounting() { + $this->accvis=0; + } + /** + * @brief in the search box, the accounting will be shown it is the default + */ + function show_accounting() { + $this->accvis=1; } /*!\brief set the javascript callback function * by default it is update_value called BEFORE the querystring is send @@ -297,7 +310,7 @@ class ICard extends HtmlInput if ( $this->readOnly==true) return ''; if ( ! isset($this->id )) $this->id=$this->name; $a=""; - foreach (array('typecard','jrn','label','price','tvaid') as $att) + foreach (array('typecard','jrn','label','price','tvaid','accvis') as $att) { if (isset($this->$att) ) $a.="this.".$att."='".$this->$att."';"; diff --git a/include/template/card_result.php b/include/template/card_result.php index 3bf77d4a5..6c38fad65 100644 --- a/include/template/card_result.php +++ b/include/template/card_result.php @@ -9,14 +9,21 @@ - + + + From 0a6a6399b8da535dd3742899be98edf9ee970f5f Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 18 Dec 2017 17:22:39 +0100 Subject: [PATCH 22/22] set version --- html/index.php | 2 +- include/constant.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/html/index.php b/html/index.php index 7edff3f47..37a705202 100644 --- a/html/index.php +++ b/html/index.php @@ -261,7 +261,7 @@ if (isset ($_REQUEST['reconnect']) && isset ($_REQUEST['backurl'])) { } echo ' -version 6919+6 - '.$my_domain.' +version 6919+8 - '.$my_domain.'

    diff --git a/include/constant.php b/include/constant.php index de991bcbf..06ae9944a 100644 --- a/include/constant.php +++ b/include/constant.php @@ -88,7 +88,7 @@ define ('SMALLX','ⵝ'); define ('BUTTONADD',"✚"); -define ('SVNINFO',6919+7); +define ('SVNINFO',6919+8); if ( ! defined ('DEBUG')) { define ("DEBUG",false); }