From 1d2116101ab03ab0a8687d87d072e3730ea53457 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 5 May 2020 23:30:33 +0200 Subject: [PATCH 01/39] =?UTF-8?q?Pierre-Fran=C3=A7ois=20P.=20Ajout=20des?= =?UTF-8?q?=20parenth=C3=A8ses=20dans=20le=20calcul=20des=20champs=20num?= =?UTF-8?q?=C3=A9riques?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/js/scripts.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/html/js/scripts.js b/html/js/scripts.js index c3133e7e0..280942930 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -254,7 +254,8 @@ function set_value(p_ctl, p_value, p_add) function compute_number(value) { var retval = 0; - var exp = new RegExp("^[0-9/*+-.]+$", "g"); + + var exp = new RegExp("^[0-9/*+-.()]+$", "g"); /*pour éviter un eval() mal intentionné*/ var res = exp.test(value); if (res) @@ -3667,4 +3668,4 @@ function toggle_row_warning_enable(p_enable, p_row) } else { $(p_row).hide(); } -} \ No newline at end of file +} From 3f5759dfccd2f7f97d4c2a8e97eea86caa3d6730 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 6 May 2020 23:47:04 +0200 Subject: [PATCH 02/39] Bug Database:lo_unlink unknown variable --- include/class/database.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/class/database.class.php b/include/class/database.class.php index 101cc5e61..30da3f448 100644 --- a/include/class/database.class.php +++ b/include/class/database.class.php @@ -89,7 +89,7 @@ class Database extends DatabaseCore $r = pg_fetch_array($ret, 0); $old_oid = $r['jr_pj']; if (strlen($old_oid) != 0) - pg_lo_unlink($cn, $old_oid); + $this->lo_unlink( $old_oid); } // Load new document $this->exec_sql("update jrn set jr_pj=$1 , jr_pj_name=$2, @@ -115,7 +115,7 @@ class Database extends DatabaseCore /** * \brief loop to apply all the path to a folder or a template * Upgrade check if the folder $p_name needs to be upgrade thanks the variable DBVERSION - * and run all the SQL script named upgradeX.sql from the folder noalyss/include/sql/patch + * and run all the SQL script named upgradeX.sql from the folder noalyss/include/sql/patch * until X equal DBVERSION-1 * * \param $p_name database name @@ -226,7 +226,7 @@ class Database extends DatabaseCore if (!DEBUG) ob_end_clean(); - + } } echo ''; @@ -253,4 +253,4 @@ class Database extends DatabaseCore } return $sys_name; } -} \ No newline at end of file +} From 39617e77e419a627c71e6a81819d0543949e8d97 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 10 May 2020 11:59:58 +0200 Subject: [PATCH 03/39] Fix problem with redirect --- html/user_login.php | 2 +- include/constant.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/html/user_login.php b/html/user_login.php index 94e4a9099..0780af731 100644 --- a/html/user_login.php +++ b/html/user_login.php @@ -129,7 +129,7 @@ if ( $User->admin == 0 || (defined("MULTI")&& MULTI == 0 ) ) $folder=$User->get_available_folder(); if ( $folder != null && count($folder) == 1 ) { - + echo _("Si la redirection ne fonctionne pas, vous devez changer la valeur de NOALYSS_URL "); redirect(NOALYSS_URL.'/do.php?gDossier='.$folder[0]['dos_id']); exit(); } diff --git a/include/constant.php b/include/constant.php index a10f5bb39..b27c1a35c 100644 --- a/include/constant.php +++ b/include/constant.php @@ -322,7 +322,7 @@ if ( ! defined ("NOALYSS_URL")) { $protocol=$_SERVER['REQUEST_SCHEME']; } $base=$protocol.'://'. - $_SERVER['HTTP_HOST']. + $_SERVER['SERVER_NAME']. ":".$_SERVER['SERVER_PORT']. dirname($_SERVER['PHP_SELF']); define ("NOALYSS_URL",$base); From 92bd3eb5063805e97d236f61f58208a82bac26a5 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 11 May 2020 00:03:41 +0200 Subject: [PATCH 04/39] Fix bug in recover password Include sendmail.class.php fix bug sending email with file (compatibility PHP7) --- include/lib/sendmail_core.class.php | 37 ++++++++++++++++------------- include/recover.php | 23 +++++++++++++----- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/include/lib/sendmail_core.class.php b/include/lib/sendmail_core.class.php index 11a5180af..b62061d0c 100644 --- a/include/lib/sendmail_core.class.php +++ b/include/lib/sendmail_core.class.php @@ -78,7 +78,8 @@ class Sendmail_Core */ function set_message($p_message) { - $this->message = $p_message; + // $this->message =wordwrap($p_message,70,"\r\n"); + $this->message =$p_message; } /** @@ -134,24 +135,26 @@ class Sendmail_Core $this->content .= "Content-Type: text/plain; charset=\"utf-8\"" . $eol; $this->content .= "Content-Transfer-Encoding: 7bit" . $eol.$eol ; $this->content .= $this->message . $eol ; - - // attachment - for ($i = 0; $i < count($this->afile); $i++) + if ( ! empty($this->afile ) ) { - $file = $this->afile[$i]; - $file_size = filesize($file->full_name); - $handle = fopen($file->full_name, "r"); - $content = fread($handle, $file_size); - fclose($handle); - $content = chunk_split(base64_encode($content)); - $this->content .= "--" . $separator . $eol; - $this->content .= "Content-Type: " . $file->type . "; name=\"" . $file->filename . "\"" . $eol; - $this->content .= "Content-Disposition: attachment; filename=\"" . $file->filename . "\"" . $eol; - $this->content .= "Content-Transfer-Encoding: base64" . $eol; - $this->content.=$eol; - $this->content .= $content . $eol ; + // attachment + for ($i = 0; $i < count($this->afile); $i++) + { + $file = $this->afile[$i]; + $file_size = filesize($file->full_name); + $handle = fopen($file->full_name, "r"); + $content = fread($handle, $file_size); + fclose($handle); + $content = chunk_split(base64_encode($content)); + $this->content .= "--" . $separator . $eol; + $this->content .= "Content-Type: " . $file->type . "; name=\"" . $file->filename . "\"" . $eol; + $this->content .= "Content-Disposition: attachment; filename=\"" . $file->filename . "\"" . $eol; + $this->content .= "Content-Transfer-Encoding: base64" . $eol; + $this->content.=$eol; + $this->content .= $content . $eol ; + } } - if ( count ($this->afile) == 0 ) $this->content.=$eol; + if ( empty ($this->afile) ) $this->content.=$eol; $this->content .= "--" . $separator . "--"; } diff --git a/include/recover.php b/include/recover.php index ec082d1fc..cf9dac818 100644 --- a/include/recover.php +++ b/include/recover.php @@ -25,6 +25,7 @@ define('SIZE_REQUEST', 70); require_once NOALYSS_INCLUDE.'/lib/html_input.class.php'; require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; +require_once NOALYSS_INCLUDE.'/class/sendmail.class.php'; /** * @brief generate a random string of char * @param $car int length of the string @@ -95,12 +96,22 @@ elseif ($action=="send_email") : if ($valid==true): $request_id=generate_random(SIZE_REQUEST); $user_password=generate_random(10); - /* - * save the request into - */ - $cn->exec_sql("insert into recover_pass(use_id,request,password,created_on,created_host) " - ." values ($1,$2,$3,now(),$4)", array($user_id, $request_id, $user_password, $_SERVER['REMOTE_ADDR'])); - + // exist a valid request for this user ? + $exist_request= $cn->get_array("select request , password from recover_pass + where use_id=$1 and created_on > now() - interval '12 hours'",[$user_id]); + if ( empty($exist_request ) ) { + /* save the request into */ + $cn->exec_sql("insert into recover_pass(use_id,request,password,created_on,created_host) " + ." values ($1,$2,$3,now(),$4)", array($user_id, $request_id, $user_password, $_SERVER['REMOTE_ADDR'])); + } else { + $request_id=$exist_request[0]["request"]; + $user_password=$exist_request[0]['password']; + /* if too many request , there is a bug somewhere , so record an warning */ + if ( count($exist_request)> 1 ){ + error_log("WRE109 Trop de request pour ".var_export($exist_request,true)); + } + + } /* * send an email */ From 741a1c1417b4ba5443af24e300d09b0b3173651f Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 11 May 2020 00:10:23 +0200 Subject: [PATCH 05/39] Code : add connection by DSN --- include/lib/database_core.class.php | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/include/lib/database_core.class.php b/include/lib/database_core.class.php index 098b7d6ca..4e4bac2dc 100644 --- a/include/lib/database_core.class.php +++ b/include/lib/database_core.class.php @@ -77,6 +77,42 @@ class DatabaseCore $this->is_open = TRUE; } + /** + * Connect by DSN : description of database connection like + * return a Database_Core object + * @code + * port=6002 host=x.x.x.x dbname=dbname user=admin password=www + * @endcode + * + * @param string $p_dsn describing the connection + * + */ + function connect_dsn($p_dsn) + { + $this->db =pg_connect($p_dsn); + + if ( $this->db == false ) + { + if (DEBUG) { + echo '

Impossible de se connecter à postgreSql !

'; + echo '

'; + echo "Vos paramètres sont incorrectes :
"; + echo "
"; + echo "base de donnée : $p_dsn
"; + echo '

'; + + exit ("Connection impossible : vérifiez vos paramètres de base + de données"); + } else { + echo '

' . _('Erreur de connexion !') . '

'; + $this->is_open = false; + throw new Exception(_('Erreur Connexion')); + } + + } + $this->is_open=TRUE; + return $this; + } public function verify() { From 5655d438b13a962a13d6bbd4fed61bce19f97a1e Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 23 May 2020 10:48:28 +0200 Subject: [PATCH 06/39] Compatibility postgresql 12 --- include/sql/patch/upgrade36.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/sql/patch/upgrade36.sql b/include/sql/patch/upgrade36.sql index 82e2f3a5d..3b74bb2d3 100644 --- a/include/sql/patch/upgrade36.sql +++ b/include/sql/patch/upgrade36.sql @@ -177,8 +177,7 @@ CREATE TABLE bud_hypothese CONSTRAINT fk_bud_hypo_pa_id FOREIGN KEY (pa_id) REFERENCES plan_analytique (pa_id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE -) -WITHOUT OIDS; +); create sequence seq_bud_hypothese_bh_id; From 6593181f5580758c56d097bb12de3738d4e5c279 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 24 May 2020 21:49:08 +0200 Subject: [PATCH 07/39] Remove DB connect with DSN --- include/lib/database_core.class.php | 36 +---------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/include/lib/database_core.class.php b/include/lib/database_core.class.php index 4e4bac2dc..2bcba2307 100644 --- a/include/lib/database_core.class.php +++ b/include/lib/database_core.class.php @@ -75,44 +75,10 @@ class DatabaseCore } $this->is_open = TRUE; + } - /** - * Connect by DSN : description of database connection like - * return a Database_Core object - * @code - * port=6002 host=x.x.x.x dbname=dbname user=admin password=www - * @endcode - * - * @param string $p_dsn describing the connection - * - */ - function connect_dsn($p_dsn) - { - $this->db =pg_connect($p_dsn); - if ( $this->db == false ) - { - if (DEBUG) { - echo '

Impossible de se connecter à postgreSql !

'; - echo '

'; - echo "Vos paramètres sont incorrectes :
"; - echo "
"; - echo "base de donnée : $p_dsn
"; - echo '

'; - - exit ("Connection impossible : vérifiez vos paramètres de base - de données"); - } else { - echo '

' . _('Erreur de connexion !') . '

'; - $this->is_open = false; - throw new Exception(_('Erreur Connexion')); - } - - } - $this->is_open=TRUE; - return $this; - } public function verify() { From dcede7bfbcb1583795ac7d1059514c23298e3224 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 24 May 2020 21:54:06 +0200 Subject: [PATCH 08/39] #1798 French calendar --- html/js/lang/calendar-fr.js | 18 +++++++++--------- include/lib/ac_common.php | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/html/js/lang/calendar-fr.js b/html/js/lang/calendar-fr.js index 2a9e0b20b..1bfdc94a8 100644 --- a/html/js/lang/calendar-fr.js +++ b/html/js/lang/calendar-fr.js @@ -48,17 +48,17 @@ Calendar._SDN = new Array // full month names Calendar._MN = new Array ("Janvier", - "Février", + "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", - "Août", + "Août", "Septembre", "Octobre", "Novembre", - "Décembre"); + "Décembre"); // short month names Calendar._SMN = new Array @@ -83,7 +83,7 @@ Calendar._TT["ABOUT"] = "DHTML Date/Heure Selecteur\n" + "(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-) "Pour la derniere version visitez : http://www.dynarch.com/projects/calendar/\n" + -"Distribué par GNU LGPL. Voir http://gnu.org/licenses/lgpl.html pour les details." + +"Distribué par GNU LGPL. Voir http://gnu.org/licenses/lgpl.html pour les details." + "\n\n" + "Selection de la date :\n" + "- Utiliser les bouttons \xab, \xbb pour selectionner l\'annee\n" + @@ -95,13 +95,13 @@ Calendar._TT["ABOUT_TIME"] = "\n\n" + "- ou Maj-clic pour decrementer\n" + "- ou clic et glisser-deplacer pour une selection plus rapide"; -Calendar._TT["PREV_YEAR"] = "Année préc. (maintenir pour menu)"; -Calendar._TT["PREV_MONTH"] = "Mois préc. (maintenir pour menu)"; +Calendar._TT["PREV_YEAR"] = "Année préc. (maintenir pour menu)"; +Calendar._TT["PREV_MONTH"] = "Mois préc. (maintenir pour menu)"; Calendar._TT["GO_TODAY"] = "Atteindre la date du jour"; Calendar._TT["NEXT_MONTH"] = "Mois suiv. (maintenir pour menu)"; -Calendar._TT["NEXT_YEAR"] = "Année suiv. (maintenir pour menu)"; -Calendar._TT["SEL_DATE"] = "Sélectionner une date"; -Calendar._TT["DRAG_TO_MOVE"] = "Déplacer"; +Calendar._TT["NEXT_YEAR"] = "Année suiv. (maintenir pour menu)"; +Calendar._TT["SEL_DATE"] = "Sélectionner une date"; +Calendar._TT["DRAG_TO_MOVE"] = "Déplacer"; Calendar._TT["PART_TODAY"] = " (Aujourd'hui)"; // the following is to inform that "%s" is to be the first day of week diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index df4ae72e8..39c65de90 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -342,7 +342,17 @@ function html_page_start($p_theme="", $p_script="", $p_script2="") $p_script2 . " "; echo ' - + '; + + if (isset($_SESSION['g_lang']) && $_SESSION['g_lang']=='fr_FR.utf8' ) + { + echo ''; + } + if (isset($_SESSION['g_lang']) && $_SESSION['g_lang']=='nl_NL.utf8' ) + { + echo ''; + } + echo ' '; @@ -1365,4 +1375,4 @@ function convert_to_rtf($p_string) } } return $result; -} \ No newline at end of file +} From e7f4184ef8b71f6bf51050181f0e064d1d81cb30 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 24 May 2020 19:07:41 +0200 Subject: [PATCH 09/39] Compatility PHP7.4 --- include/class/acc_ledger.class.php | 36 +++++++------------ .../acc_ledger_history_generic.class.php | 2 +- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index b2f05da3d..d43dcd933 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -2416,22 +2416,17 @@ class Acc_Ledger extends jrn_def_sql switch ($this->jrn_def_type) { case 'ACH': - $this->jrn_def_fiche_cred=(isset($ACH_FICHECRED))?join($ACH_FICHECRED, - ','):''; - $this->jrn_def_fiche_deb=(isset($ACH_FICHEDEB))?join($ACH_FICHEDEB, - ','):""; + $this->jrn_def_fiche_cred=(isset($ACH_FICHECRED))?join(',',$ACH_FICHECRED):''; + $this->jrn_def_fiche_deb=(isset($ACH_FICHEDEB))?join(',',$ACH_FICHEDEB):""; break; case 'VEN': - $this->jrn_def_fiche_cred=(isset($VEN_FICHECRED))?join($VEN_FICHECRED, - ','):''; - $this->jrn_def_fiche_deb=(isset($VEN_FICHEDEB))?join($VEN_FICHEDEB, - ','):""; + $this->jrn_def_fiche_cred=(isset($VEN_FICHECRED))?join(',',$VEN_FICHECRED):''; + $this->jrn_def_fiche_deb=(isset($VEN_FICHEDEB))?join(',',$VEN_FICHEDEB):""; break; case 'ODS': $this->jrn_def_class_deb=$p_jrn_class_deb; - $this->jrn_def_fiche_deb=(isset($ODS_FICHEDEB))?join($ODS_FICHEDEB, - ','):''; ; + $this->jrn_def_fiche_deb=(isset($ODS_FICHEDEB))?join(',',$ODS_FICHEDEB):''; ; $this->jrn_def_fiche_cred=null; break; @@ -2440,8 +2435,7 @@ class Acc_Ledger extends jrn_def_sql $result=$a->get_by_qcode(trim(strtoupper($_POST['bank'])), false); $bank=$a->id; $this->jrn_def_bank=$bank; - $this->jrn_def_fiche_deb=(isset($FIN_FICHEDEB))?join($FIN_FICHEDEB, - ','):""; + $this->jrn_def_fiche_deb=(isset($FIN_FICHEDEB))?join(',',$FIN_FICHEDEB):""; if ($result==-1) throw new Exception(_("Aucun compte en banque n'est donné")); $this->jrn_def_num_op=(isset($numb_operation))?1:0; @@ -2605,22 +2599,17 @@ class Acc_Ledger extends jrn_def_sql switch ($this->jrn_def_type) { case 'ACH': - $this->jrn_def_fiche_cred=(isset($ACH_FICHECRED))?join($ACH_FICHECRED, - ','):''; - $this->jrn_def_fiche_deb=(isset($ACH_FICHEDEB))?join($ACH_FICHEDEB, - ','):""; + $this->jrn_def_fiche_cred=(isset($ACH_FICHECRED))?join(',',$ACH_FICHECRED):''; + $this->jrn_def_fiche_deb=(isset($ACH_FICHEDEB))?join(',',$ACH_FICHEDEB):""; break; case 'VEN': - $this->jrn_def_fiche_cred=(isset($VEN_FICHECRED))?join($VEN_FICHECRED, - ','):''; - $this->jrn_def_fiche_deb=(isset($VEN_FICHEDEB))?join($VEN_FICHEDEB, - ','):""; + $this->jrn_def_fiche_cred=(isset($VEN_FICHECRED))?join(',',$VEN_FICHECRED):''; + $this->jrn_def_fiche_deb=(isset($VEN_FICHEDEB))?join(',',$VEN_FICHEDEB):""; break; case 'ODS': $this->jrn_def_class_deb=$p_jrn_class_deb; - $this->jrn_def_fiche_deb=(isset($ODS_FICHEDEB))?join($ODS_FICHEDEB, - ','):''; ; + $this->jrn_def_fiche_deb=(isset($ODS_FICHEDEB))?join(',',$ODS_FICHEDEB):''; ; $this->jrn_def_fiche_cred=null; break; case 'FIN': @@ -2628,8 +2617,7 @@ class Acc_Ledger extends jrn_def_sql $result=$a->get_by_qcode(trim(strtoupper($_POST['bank'])), false); $bank=$a->id; $this->jrn_def_bank=$bank; - $this->jrn_def_fiche_deb=(isset($FIN_FICHEDEB))?join($FIN_FICHEDEB, - ','):""; + $this->jrn_def_fiche_deb=(isset($FIN_FICHEDEB))?join(',',$FIN_FICHEDEB):""; if ($result==-1) throw new Exception(_("Aucun compte en banque n'est donné")); $this->jrn_def_num_op=(isset($numb_operation))?1:0; diff --git a/include/class/acc_ledger_history_generic.class.php b/include/class/acc_ledger_history_generic.class.php index 97207cf0c..54ee8312b 100644 --- a/include/class/acc_ledger_history_generic.class.php +++ b/include/class/acc_ledger_history_generic.class.php @@ -417,7 +417,7 @@ class Acc_Ledger_History_Generic extends Acc_Ledger_History function get_rowSimple($trunc=0, $p_limit=-1, $p_offset=-1) { global $g_user; - $jrn=" jrn_def_id in (".join($this->ma_ledger, ",").")"; + $jrn=" jrn_def_id in (".join(',',$this->ma_ledger).")"; $periode=sql_filter_per($this->db, $this->m_from, $this->m_to, 'p_id', 'jr_tech_per'); From 577229bde99af14860cd294d865c1da795362570 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 24 May 2020 21:46:34 +0200 Subject: [PATCH 10/39] Task #1532 : detail payment --- include/class/acc_ledger_purchase.class.php | 22 +++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index 5b6fe187e..4365cfdc3 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -48,10 +48,12 @@ require_once NOALYSS_INCLUDE.'/class/stock_goods.class.php'; */ class Acc_Ledger_Purchase extends Acc_Ledger { + private $payment_operation; /*ledger_type='ACH'; parent::__construct($p_cn,$p_init); + $this->payment_operation=-1; } /*!\brief verify that the data are correct before inserting or confirming *\param an array (usually $_POST) @@ -878,7 +880,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger $acc_pay->grpt=$acseq; $acc_pay->jrn=$mp->get_parameter('ledger_target'); $acc_pay->periode=$tperiode; - $acc_pay->type=($famount>=0)?'c':'d'; + $acc_pay->type=($famount>=0)?'c':'d'; $acc_pay->insert_jrnx(); /* Insert supplier */ @@ -899,6 +901,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger $acc_pay->desc=(!isset($e_comm_paiement) || strlen(trim($e_comm_paiement)) == 0) ?$e_comm:$e_comm_paiement; $mp_jr_id=$acc_pay->insert_jrn(); + $this->payment_operation=$mp_jr_id; $acjrn->grpt_id=$acseq; $acjrn->update_internal_code($acinternal); // add an automatic PJ if ODS @@ -1700,19 +1703,30 @@ EOF; */ if ( $e_mp!=0 && strlen (trim (${'e_mp_qcode_'.$e_mp})) != 0 ) { + $r.="

"; $r.=HtmlInput::hidden('e_mp_qcode_'.$e_mp,${'e_mp_qcode_'.$e_mp}); $r.=HtmlInput::hidden('acompte',$acompte); - $r.=HtmlInput::hidden('e_comm_paiement',$e_comm_paiement); - $r.=HtmlInput::hidden('mp_date',$mp_date); + $r.=HtmlInput::hidden('e_comm_paiement',$e_comm_paiement); + $r.=HtmlInput::hidden('mp_date',$mp_date); /* needed for generating a invoice */ $r.=HtmlInput::hidden('qcode_benef', ${'e_mp_qcode_' . $e_mp}); $fname = new Fiche($this->db); $fname->get_by_qcode(${'e_mp_qcode_' . $e_mp}); + $detail_payment=""; + // payment operation + if ($this->payment_operation != 1) { + $pay_internal=$this->db->get_value("select jr_internal from jrn where jr_id=$1", + [$this->payment_operation]); + $detail_payment=HtmlInput::detail_op($this->payment_operation,$pay_internal); + } $r.='

' . _("Payé par")." " . ${'e_mp_qcode_' . $e_mp} . - " " . $fname->getName() . '

' . '

' . _('Déduction acompte ') . h($acompte) . '

' . + " " . $fname->getName() .$detail_payment. ' ' ; + $r.='

' . _('Déduction acompte ') . h($acompte) . '

' . _('Libellé :') . h($e_comm_paiement) ; $r.='
'; $r.='
'; + + $r.="

"; } // check for upload piece /* From d4b298b2aeb72ffb766364af464563d849c925ef Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 24 May 2020 21:53:43 +0200 Subject: [PATCH 11/39] =?UTF-8?q?#1583:=20[Cosm=C3=A9tique]=20Liste=20de?= =?UTF-8?q?=20cat=C3=A9gories=20de=20fiches,=20espace=20avant=20les=20()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/fiche.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fiche.inc.php b/include/fiche.inc.php index 31e8f5dca..8b05b53b0 100644 --- a/include/fiche.inc.php +++ b/include/fiche.inc.php @@ -37,7 +37,7 @@ global $g_user, $g_failed; */ /* category */ $categorie = new ISelect('cat'); -$categorie->value = $cn->make_array("select fd_id,fd_label||'('||(select count(*) from fiche where fiche.fd_id=fiche_def.fd_id)::text||')' from fiche_def order by fd_label"); +$categorie->value = $cn->make_array("select fd_id,fd_label||' ('||(select count(*) from fiche where fiche.fd_id=fiche_def.fd_id)::text||')' from fiche_def order by fd_label"); $categorie->selected = $http->get('cat','number',0); $str_categorie = $categorie->input(); $ac = $http->request('ac'); From a491c4c95602a061df994978eea47d8d74a195a5 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 2 Jun 2020 13:52:20 +0200 Subject: [PATCH 12/39] CSS : new background-selected for a row in table --- html/style-classic.css | 7 +++++++ html/style-classic7.css | 6 ++++++ html/style-light.css | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/html/style-classic.css b/html/style-classic.css index e830a15b2..0dd8480a1 100644 --- a/html/style-classic.css +++ b/html/style-classic.css @@ -2426,4 +2426,11 @@ span.tab_row { } span.title_tab_row { +} + +/* Selected row in a table */ +.background-selected { + background-color: #000066 !important; + color : white !important; + } \ No newline at end of file diff --git a/html/style-classic7.css b/html/style-classic7.css index 5b3233330..3ffb83c97 100644 --- a/html/style-classic7.css +++ b/html/style-classic7.css @@ -2461,4 +2461,10 @@ span.title_tab_row { background-color: darkblue; color:white; padding : 3px; +} +/* Selected row in a table */ +.background-selected { + background-color: #000066 !important; + color : white !important; + } \ No newline at end of file diff --git a/html/style-light.css b/html/style-light.css index 95b758593..c2b7c88da 100644 --- a/html/style-light.css +++ b/html/style-light.css @@ -2359,4 +2359,10 @@ span.title_tab_row { color:white; padding : 3px; +} +/* Selected row in a table */ +.background-selected { + background-color: #000066 !important; + color : white !important; + } \ No newline at end of file From 7a30cbe0c762852b5a7697298d1d473a951321b9 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 2 Jun 2020 13:54:01 +0200 Subject: [PATCH 13/39] JS : improve code alternate_row_color --- html/js/scripts.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/html/js/scripts.js b/html/js/scripts.js index 280942930..631f6a818 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -3045,28 +3045,21 @@ function alert_box(p_message) */ function alternate_row_color(p_table) { - var len = $(p_table).tBodies[0].rows.length; + var table_colored=$(p_table); + var len = table_colored.tBodies[0].rows.length; var i = 0; var localClass = ""; for (i = 1; i < len; i++) { localClass = (i % 2 == 0) ? "even" : "odd"; - if (localClass == "even" && $(p_table).tBodies[0].rows[i].hasClassName("odd")) + if ( table_colored.tBodies[0].rows[i].hasClassName("odd")) { - $(p_table).tBodies[0].rows[i].removeClassName("odd"); + table_colored.tBodies[0].rows[i].removeClassName("odd"); } - if (localClass == "even" && !$(p_table).tBodies[0].rows[i].hasClassName("even")) + if (table_colored.tBodies[0].rows[i].hasClassName("even")) { - $(p_table).tBodies[0].rows[i].addClassName("even"); - } - - if (localClass == "odd" && $(p_table).tBodies[0].rows[i].hasClassName("even")) - { - $(p_table).tBodies[0].rows[i].removeClassName("even"); - } - if (localClass == "odd" && !$(p_table).tBodies[0].rows[i].hasClassName("odd")) - { - $(p_table).tBodies[0].rows[i].addClassName("odd"); + table_colored.tBodies[0].rows[i].removeClassName("even"); } + table_colored.tBodies[0].rows[i].addClassName(localClass); } } From 1f7610b8948185b78882344d436a3751a35bfd04 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 2 Jun 2020 14:32:04 +0200 Subject: [PATCH 14/39] =?UTF-8?q?task=20#0001801:=20CARD=20:=20mise=20?= =?UTF-8?q?=C3=A0=20jour=20fiche=20,=20effacement=20et=20modification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/js/card.js | 201 ++++++++++++++++++- include/ajax/ajax_card.php | 133 ++++++++++-- include/class/extension.class.php | 2 +- include/class/fiche.class.php | 39 ++++ include/fiche.inc.php | 23 ++- include/template/result_cat_card_summary.php | 38 +--- 6 files changed, 375 insertions(+), 61 deletions(-) diff --git a/html/js/card.js b/html/js/card.js index 70ede3254..1ad8e4e60 100644 --- a/html/js/card.js +++ b/html/js/card.js @@ -663,13 +663,16 @@ function dis_blank_card(obj) } else { var dossier=obj.gDossier; } - var queryString='gDossier='+dossier; queryString+='&ctl='+content; queryString+='&fd_id='+fd_id; queryString+=ref; queryString+='&op2=bc'; // bc for blank card queryString+='&op=card'; // bc for blank card + if (obj.after_save) { + queryString+='&after_save='+obj.after_save; + } + if ( obj.elementId) queryString+="&eltid="+obj.elementId; var action=new Ajax.Request ( 'ajax_misc.php', { @@ -748,16 +751,42 @@ function save_card(obj) parameters:queryString, onFailure:errorFid, onSuccess:function (req,json) { - var elt=req.responseXML.getElementsByTagName("eltid"); var status=req.responseXML.getElementsByTagName("status"); var status_value='OK'; + var after_savetag=req.responseXML.getElementsByTagName("after_save"); + var after_save=0; if ( status.length !=0) { status_value=getNodeText(status[0]); } - if ( status_value == 'OK') { + if ( after_savetag.length !=0 ) { + after_save=getNodeText(after_savetag[0]); + } + // if status == OK and after_save == 0 + // then update the box + if ( status_value == 'OK' && after_save == 0) { fill_box(req,json); } + + // if status == OK and after_save == 1 + // then add a row to the table + if ( status_value == 'OK' && after_save == 1) { + var table_card=$('fiche_tb_id'); + f_id=getNodeText(req.responseXML.getElementsByTagName("f_id")[0]); + var row=new Element('tr'); + row.id="row_card"+f_id; + row.innerHTML=getNodeText(req.responseXML.getElementsByTagName("code")[0]); + table_card.tBodies[0].appendChild(row); + new Effect.Highlight(row.id ,{startcolor: '#FAD4D4',endcolor: '#F78082' }); + // + if ( table_card.tBodies[0].rows.length % 2 == 0 ) { + row.addClassName("odd"); + } else { + row.addClassName("even"); + + } + } + remove_waiting_box(); if ( elt.length != 0) { var eltid=getNodeText(elt[0]); @@ -1024,3 +1053,169 @@ function delete_card(obj) { } }); } +/** + * Display a card , modify it , redraw the row + * before calling this function , it it neeed to have in the web page a hidden card_gdossier with the dossier id + * @param {type} p_fiche_id + * @returns {undefined} + */ +function modify_card(p_fiche_id) +{ + /* window with result */ + card_layer++; + + var content = 'card_' + card_layer; + var nTop = 170 + card_layer; + if (nTop > 300) { + nTop = 170; + } + var str_top = fixed_position(250, nTop) + var str_style = str_top + ";width:45em;height:auto;position:absolute"; + + var popup = {'id': content, 'cssclass': 'inner_box', 'style': str_style, 'html': loading(), 'drag': false}; + + add_div(popup); + + /* dossier id */ + if ( ! document.getElementById("card_gdossier")) { + + console.error("card_gdossier error"); + throw ("card_gdossier not set"); + } + var dossier = $('card_gdossier').value; + + + var action = new Ajax.Request('ajax_misc.php', + { + method: 'get', + parameters: {'gDossier':dossier,"op":'card',"op2":"dc","f_id":p_fiche_id,'ctl':content,after_save:2} , + onFailure: errorFid, + onSuccess: function (respTxt) { + fill_box(respTxt); + } + } + ); +} +/** + * Delete a card and remove the row + * before calling this function , it it neeed to have in the web page a hidden card_gdossier with the dossier id + * @param {type} p_fiche_id + * @returns {undefined} + */ +function delete_card_id(p_fiche_id) +{ + var row="row_card"+p_fiche_id; + if ( ! document.getElementById("card_gdossier")) { + + console.error("card_gdossier error"); + throw ("card_gdossier not set"); + } + $(row).addClassName("background-selected"); + var dossier = $('card_gdossier').value; + smoke.confirm(content[47], function (e) { + if (e) { + waiting_box(); + new Ajax.Request("ajax_misc.php", { + "method": "get", + parameters: {'gDossier':dossier,"op":'card',"op2":"rm_card","f_id":p_fiche_id,'ctl':row} , + onSuccess: function (req) { + remove_waiting_box(); + var table_card=$('fiche_tb_id'); + var answer = req.responseXML; + var a = answer.getElementsByTagName('ctl'); + if (a.length == 0) + { + var rec = req.responseText; + alert_box('erreur :' + rec); + } + var html = answer.getElementsByTagName('code'); + var namectl = a[0].firstChild.nodeValue; + var nodeXml = html[0]; + var code_html = getNodeText(nodeXml); + code_html = unescape_xml(code_html); + + if ((code_html) == "OK") { + Effect.Fade(row, {duration: 0.1}); + table_card.tBodies[0].removeChild($(row)); + alternate_row_color("fiche_tb_id"); + } else { + smoke.alert(code_html); + + } + } + + }); + } else{ + $(row).removeClassName("background-selected"); + + } + }); + +} + +/** +* update a card in ajax , and update a row +* +*/ +function update_row(obj) +{ + try { + var name = obj.id; + + var qs = Form.serialize(name) + '&op2=upr&op=card'; + var action = new Ajax.Request('ajax_misc.php', + { + method: 'get', + parameters: qs, + onFailure: errorFid, + onSuccess: function (req) { + try { + + remove_waiting_box(); + + var answer = req.responseXML; + var a = answer.getElementsByTagName('ctl'); + var html = answer.getElementsByTagName('code'); + if (a.length === 0) { + var rec = req.responseText; + alert_box('erreur :' + rec); + } + var name_ctl = "row_card" + obj.f_id.value; + var code_html = getNodeText(html[0]); // Firefox ne prend que les 4096 car. + code_html = unescape_xml(code_html); + + if ( document.getElementById(name_ctl)) { + // update the row + $(name_ctl).innerHTML = code_html; + new Effect.Highlight(name_ctl ,{startcolor: '#FAD4D4',endcolor: '#F78082' }); + + } + $(a[0].firstChild.nodeValue).remove(); + + + } catch (e) { + alert_box(e.message); + if (console) { + console.error(e); + console.error("log answer = " + req.responseText); + } + } + try { + code_html.evalScripts(); + } catch (e) { + if (console) { + console.error(e); + console.error("log answer = " + req.responseText); + } + alert_box(content[53] + "\n" + e.message); + } + + + } + } + ); + } catch (e) { + alert_box(e.message); + return false; + } +} \ No newline at end of file diff --git a/include/ajax/ajax_card.php b/include/ajax/ajax_card.php index 980215825..2053f1a83 100644 --- a/include/ajax/ajax_card.php +++ b/include/ajax/ajax_card.php @@ -77,7 +77,7 @@ foreach ($var as $v) $cont=1; } } -extract($_REQUEST, EXTR_SKIP ); +extract($_REQUEST, EXTR_SKIP ); if ( $cont != 0 ) exit(); @@ -132,6 +132,29 @@ case 'dc': $f=new Fiche($cn); /* add title + close */ $html=HtmlInput::title_box(_("Détail fiche"), $ctl,"close","","y"); + + // if there is no qcode then try to find it thanks the card id + if ( ! isset ($qcode) ){ + $f->id=$http->get("f_id","number"); + $qcode=$f->get_quick_code(); + } + + // after save , we can either show a card in readonly or update a row + $safter_save=$http->request("after_save","string","1"); + switch ($safter_save) + { + case "1": + // show a card it readonly and fade it + $after_save="update_card(this)"; + break; + case "2": + // update a row in the table X + $after_save="update_row(this)"; + break; + default: + break; + } + if ( $qcode != '') { $f->get_by_qcode($qcode); @@ -153,7 +176,7 @@ case 'dc': if ($can_modify==1) { - $html.='
'; + $html.=''; $html.=dossier::hidden(); $html.=HtmlInput::hidden('f_id',$f->id); $html.=HtmlInput::hidden('ctl',$ctl); @@ -207,6 +230,9 @@ case 'bc': if ( isset ($eltid)) { $r.=HtmlInput::hidden("eltid", $eltid); } + // Action after save = 0, the card is display one second and fade out + $after_save=$http->get("after_save","number",0); + $r.=HtmlInput::hidden("after_save",$after_save); $r.='
'; $html=$r; } @@ -336,7 +362,7 @@ return; * ----------------------------------------------------------------------*/ case 'sc': - $html=HtmlInput::title_box(_("Choix de la catégorie"), $ctl); + if ( $g_user->check_action(FICADD)==1 ) { $f=new Fiche($cn); @@ -344,19 +370,46 @@ case 'sc': try { $f->insert($fd_id,$_POST); $f->Get(); - $html.='

'._('Fiche sauvée').'

'; - $html.=$f->Display(true); - $js=""; - if ( isset( $_POST['ref'])) $js=create_script(' window.location.reload()'); - $html.=$js; - if ( isset ($eltid)) { - // after adding a new card, we update some field - $extra="$eltid". - "{$f->get_quick_code ()}"; + $after_save=$http->post("after_save","number",0); + // Action after save = 0, the card is display one second and fade out + // + if ( $after_save == 0 ) { + $html=HtmlInput::title_box(_("Choix de la catégorie"), $ctl); + $html.='

'._('Fiche sauvée').'

'; + $html.=$f->Display(true); + $js=""; + if ( isset( $_POST['ref'])) $js=create_script(' window.location.reload()'); + $html.=$js; + if ( isset ($eltid)) { + // after adding a new card, we update some field + $extra="$eltid". + "{$f->get_quick_code ()}"; + + + } + $extra.=$status; + $extra.="0"; + + } + // Action after save = 1 ; after adding a card the table must be updated + // see fiche.inc.php + // + if ( $after_save == 1 ){ + $f_id=$f->id; + ob_start(); + $detail=Icon_Action::modify("mod".$f_id, sprintf("modify_card('%s')",$f_id)). + " ". + Icon_Action::trash("del".$f_id, sprintf("delete_card_id('%s')",$f_id)); + $html = td($detail); + $html .= $f->display_row(); + $html.=ob_get_contents(); + ob_clean(); + $extra="".$f_id.""; + $ctl="row_card".$f_id; + $extra.="1"; + } - $extra.=$status; - $html.=HtmlInput::button_close($ctl); } catch (Exception $exc) { $html="

"._("Erreur sauvegarde")."

"; $html.=$exc->getMessage(); @@ -592,6 +645,9 @@ case 'scc': $ctl="info_div"; } break; + +// Update a card and then display the result +// in a readonly box case 'upc': $html=HtmlInput::title_box("Détail fiche", $ctl); @@ -619,17 +675,52 @@ case 'upc': } } break; - //------------------------------------------------------------------ - // Unlink a card - //------------------------------------------------------------------ - case 'rm_card': - $html=HtmlInput::title_box("Détail fiche", $ctl); +// Update a card and then display the result +// in the table +case 'upr': + $f_id=$http->get("f_id","number"); + $html=""; + if ( $g_user->check_action(FICADD)==0 ) + { + $html.=alert(_('Action interdite'),true); + } + else + { + if ($cn->get_value('select count(*) from fiche where f_id=$1',array($f_id)) == '0' ) + { + $html.=alert(_('Fiche non valide'),true); + } - if ( $g_user->check_action(FIC)==0 ) + else + { + + $f=new Fiche($cn,$f_id ); + ob_start(); + $f->update($_GET); + $detail=Icon_Action::modify("mod".$f_id, sprintf("modify_card('%s')",$f_id)). + " ". + Icon_Action::trash("del".$f_id, sprintf("delete_card_id('%s')",$f_id)); + $html.=td($detail); + $html.=$f->display_row(); + $html.=ob_get_contents(); + ob_end_clean(); + } + } + break; + + + +//------------------------------------------------------------------ +// Unlink a card +//------------------------------------------------------------------ + case 'rm_card': + $html=HtmlInput::title_box("Détail fiche", $ctl); + + if ( $g_user->check_action(FIC)==0 ) { $html.=alert(_('Action interdite'),true); } - else + else { if ($cn->get_value('select count(*) from fiche where f_id=$1',array($_GET['f_id'])) == '0' ) { diff --git a/include/class/extension.class.php b/include/class/extension.class.php index 64e4d33e5..5fad200ec 100644 --- a/include/class/extension.class.php +++ b/include/class/extension.class.php @@ -353,7 +353,7 @@ class Extension extends Menu_Ref_sql $extension->me_type='PL'; $extension->me_menu=trim($xml->plugin[$i]->name); $extension->me_parameter='plugin_code='.trim($xml->plugin[$i]->code); - $extension->depend=(isset($xml->plugin[$i]->depend))?trim($xml->plugin[$i]->depend):""; + $extension->depend=(isset($xml->plugin[$i]->depend))?trim($xml->plugin[$i]->depend):"EXT"; $extension->order=(isset($xml->plugin[$i]->order))?trim($xml->plugin[$i]->order):9000; $a_extension[]=clone $extension; } diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php index 9a300b447..73d5bec34 100644 --- a/include/class/fiche.class.php +++ b/include/class/fiche.class.php @@ -2257,6 +2257,45 @@ class Fiche function filter_history($p_table_id) { return _('Cherche').' '.HtmlInput::filter_table($p_table_id, '0,1,2,3,4,5,6,7,8,9,10', 1); } + /** + * @brief display card as a table row , the tag TR must be added + * + * @return HTMLT string starting + * + */ + function display_row() + { + $this->getAttribut(); + foreach($this->attribut as $attr) { + $sort=""; + + if ($attr->ad_type!='select') + { + + if ($attr->ad_type=="date") { + // format YYYYMMDD + $sort='sorttable_customkey="'.format_date($attr->av_text, "DD.MM.YYYY", "YYYYMMDD").'"'; + } + elseif ($attr->ad_type=="poste"){ + $sort='sorttable_customkey="TEXT'.$attr->av_text.'"'; + } + echo td($attr->av_text, 'style="padding: 0 10 1 10;white-space:nowrap;" '.$sort); + } + else { + $value=$cn->make_array($attr->ad_extra); + $row_content=""; + for ($e=0; $eav_text) { + $row_content=h($value[$e]['label']); + break; + } + } + echo td($row_content, 'style="padding: 0 10 1 10;white-space:nowrap;"'); + + } + } + + } } ?> diff --git a/include/fiche.inc.php b/include/fiche.inc.php index 8b05b53b0..50eaf6f71 100644 --- a/include/fiche.inc.php +++ b/include/fiche.inc.php @@ -234,16 +234,25 @@ if ($histo->selected == 3) $cat_card = new Fiche_Def($cn); $cat_card->id =$http->get('cat','number'); $aHeading = $cat_card->getAttribut(); - if ( $allcard == 0) echo $str_add_card; + $str_add_card=""; + if ( $allcard == 0 ) { + $h_add_card_b = new IButton('add_card'); + $h_add_card_b->label = _('Créer une nouvelle fiche'); + $h_add_card_b->javascript = "dis_blank_card({gDossier:$gDossier,fd_id:$fd_id,after_save:1,ref:2})"; + $str_add_card=$h_add_card_b->input(); + } + echo $str_add_card; require_once NOALYSS_TEMPLATE.'/result_cat_card_summary.php'; $hid = new IHidden(); - echo '
' . dossier::hidden() . - HtmlInput::submit('bt_csv', _("Export CSV")) . - HtmlInput::hidden('act', "CSV:fiche") . - $hid->input("type", "fiche") . - $hid->input("ac", $http->request('ac')) . - $hid->input("fd_id", $http->request('cat',"number")); + echo '' . dossier::hidden() ; + echo $str_add_card; + echo + HtmlInput::submit('bt_csv', _("Export CSV")) . + HtmlInput::hidden('act', "CSV:fiche") . + $hid->input("type", "fiche") . + $hid->input("ac", $http->request('ac')) . + $hid->input("fd_id", $http->request('cat',"number")); echo "
"; return; diff --git a/include/template/result_cat_card_summary.php b/include/template/result_cat_card_summary.php index 3b1c4060a..86aea8e8f 100644 --- a/include/template/result_cat_card_summary.php +++ b/include/template/result_cat_card_summary.php @@ -24,42 +24,22 @@ for ($i=0;$i ',$row['f_id']); + printf('',$row['f_id']); else - printf('',$row['f_id']); + printf('',$row['f_id']); - $fiche=new Fiche($cn); - $fiche->id=$row['f_id']; - $fiche->getAttribut(); -$detail=HtmlInput::card_detail($fiche->strAttribut(ATTR_DEF_QUICKCODE)); + $fiche->id=$row['f_id']; + $detail=Icon_Action::modify("mod".$fiche->id, sprintf("modify_card('%s')",$fiche->id)). + " ". + Icon_Action::trash("del".$fiche->id, sprintf("delete_card_id('%s')",$fiche->id)); echo td($detail); - foreach($fiche->attribut as $attr) : - $sort=""; +$fiche->display_row(); - if ( $attr->ad_type != 'select'): - if ($attr->ad_type=="date") : - // format YYYYMMDD - $sort='sorttable_customkey="'.format_date($attr->av_text, "DD.MM.YYYY", "YYYYMMDD").'"'; - elseif ($attr->ad_type=="poste"): - $sort='sorttable_customkey="TEXT'.$attr->av_text.'"'; - endif; - echo td($attr->av_text,'style="padding: 0 10 1 10;white-space:nowrap;" '.$sort); - else: - $value=$cn->make_array($attr->ad_extra); - $row_content=""; - for ($e=0;$eav_text): - $row_content=h($value[$e]['label']); - break; - endif; - endfor; - echo td($row_content,'style="padding: 0 10 1 10;white-space:nowrap;"'); - - endif; - endforeach; echo ''; endforeach; From 09398054ce087dfab174729fa2ff71ec13c2c0bd Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 3 Jun 2020 11:45:48 +0200 Subject: [PATCH 15/39] Select Box : improve position in floating element --- html/js/scripts.js | 3 + include/lib/select_box.class.php | 123 ++++++++++++++++++++++++------- 2 files changed, 101 insertions(+), 25 deletions(-) diff --git a/html/js/scripts.js b/html/js/scripts.js index 631f6a818..404e99eff 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -2969,6 +2969,8 @@ function init_scroll() up.innerHTML = ' '; document.body.appendChild(up); window.onscroll = function () { + if ( document.getElementById("select_box_content") ) + { document.getElementById("select_box_content").setStyle({display:"none"})}; if (document.viewport.getScrollOffsets().top > 0) { if ($('go_up').visible() == false) { $('go_up').setOpacity(0.65); @@ -2979,6 +2981,7 @@ function init_scroll() $('go_up').hide(); } } + } /** * Confirm a form thanks a modal dialog Box, it returns true if we agree otherwise diff --git a/include/lib/select_box.class.php b/include/lib/select_box.class.php index 82c5547c4..28e6bc740 100644 --- a/include/lib/select_box.class.php +++ b/include/lib/select_box.class.php @@ -36,7 +36,8 @@ class Select_Box private $cnt; private $filter; //!< allow a dynamic not case sensitive search var $default_value; - + private $position ; //!< change depending if we are in an absolute block or not + /** * Default constructor * @param type $p_id javascript DOMid @@ -52,6 +53,98 @@ class Select_Box $this->default_value=-1; $this->style_box=""; $this->filter=""; + $this->position="normal"; + } + public function get_position() + { + return $this->position; + } + + public function set_position($position) + { + if ( ! in_array($position,array("normal","in-absolute") ) ) { + throw new Exception("SB0005",EXC_PARAM_VALUE); + } + $this->position=$position; + return $this; + } + + private function compute_position() + { + $list_id=sprintf('%s_list', $this->id); + switch ($this->position) + { + case "normal": + + // Show when click + $javascript=sprintf('$("%s_bt").onclick=function() { + try { + var newDiv=$("select_box%s"); + var pos=$("%s_bt").cumulativeOffset(); + newDiv.setStyle({display:"block",position:"fixed",top:pos.top+25+"px",left:pos.left+5+"px"}); + + if ( $("search_%s") ) { $("search_%s").focus();} + + } catch(e) { + alert(e.message); + } + } + ', $this->id, $this->id, $this->id, $list_id, $list_id); + // Hide when out of the zone + $javascript.=sprintf('$("select_box%s").onmouseleave=function() { + try { + var newDiv=$("select_box%s"); + newDiv.setStyle({display:"none"}); + } catch(e) { + alert(e.message); + } + }',$this->id,$this->id); + break; + case "in-absolute": + // Show when click + $javascript=sprintf(' + $("%s_bt").onclick=function() { + try { + + + if (! document.getElementById("select_box_content") ) { + + var newDiv=new Element("div"); + newDiv.id="select_box_content"; + document.body.appendChild(newDiv); + newDiv.addClassName("select_box"); + $("select_box_content").onmouseleave=function() { + try { + var newDiv=$("select_box_content"); + newDiv.setStyle({display:"none"}); + } catch(e) { + alert(e.message); + } + } + } else { + var newDiv=document.getElementById("select_box_content"); + } + newDiv.innerHTML=$("select_box%s").innerHTML; + var pos=$("%s_bt").cumulativeOffset(); + var nTop=pos.top; + var viewport = document.viewport.getDimensions(); + if ( nTop> viewport.height-newDiv.getHeight()-20) { nTop-=newDiv.getHeight()-5} + + newDiv.setStyle({display:"block",position:"absolute",top:nTop+"px",left:pos.left+5+"px","z-index":999}); + + if ( $("search_%s") ) { $("search_%s").focus();} + } catch(e) { + alert(e.message); + } + } + ', $this->id, $this->id, $this->id, $list_id, $list_id); + + break; + + default: + break; + } + return $javascript; } function input() @@ -59,36 +152,16 @@ class Select_Box $list_id=sprintf('%s_list',$this->id); // Show when click - $javascript=sprintf('$("%s_bt").onclick=function() { - try { - var newDiv=$("select_box%s"); - var pos=$("%s_bt").cumulativeOffset(); - newDiv.setStyle({display:"block",position:"fixed",top:pos.top+25+"px",left:pos.left+5+"px"}); - - if ( $("search_%s") ) { $("search_%s").focus();} - - } catch(e) { - alert(e.message); - } - } - ', $this->id, $this->id, $this->id, $list_id,$list_id); + $javascript=$this->compute_position(); + - // Hide when out of the zone - $javascript.=sprintf('$("select_box%s").onmouseleave=function() { - try { - var newDiv=$("select_box%s"); - newDiv.setStyle({display:"none"}); - } catch(e) { - alert(e.message); - } - }',$this->id,$this->id); // display the button - printf('', + printf('', $this->id, $this->value); printf('', $this->id, $this->id, $this->default_value); - printf('
', + printf('
', $this->id, $this->style_box); // Show the filter if there is one, From 9d001a7ed02cb2811ae2337e438c71137ced0832 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 3 Jun 2020 16:09:31 +0200 Subject: [PATCH 16/39] =?UTF-8?q?task=20#0001413:=20Duplication=20d'op?= =?UTF-8?q?=C3=A9ration=202=20-=20le=20retour?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/js/acc_ledger.js | 40 +++++ include/ajax/ajax_ledger.php | 16 ++ include/class/acc_operation.class.php | 174 ++++++++++++++++++++++ include/lib/html_input.class.php | 19 ++- include/template/ledger_detail_bottom.php | 32 ++-- 5 files changed, 266 insertions(+), 15 deletions(-) diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index f236bf34b..200a30651 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -1469,4 +1469,44 @@ function reset_filter(p_div) { // By default , unpaid is uncked $(p_div+"operation_filter").value="all"; +} + +/** + * propose to duplicate an operation + */ +function duplicate_operation(p_dossier,p_jr_id) { + waiting_box(); + var duplicate_div=create_div({id:"duplicate_operation_div",cssclass:"inner_box"}); + + new Ajax.Request("ajax_misc.php", { + parameters : { + "op":"ledger", + "gDossier":p_dossier, + "jr_id":p_jr_id, + "act":"duplicateop", + "div":"duplicate_operation_div" + }, + onSuccess:function(req) { + remove_waiting_box(); + console.debug("success"); + var xml=req.responseXML; + console.debug ("received"+xml); + if ( xml.getElementsByTagName("ctl").length==0) { + console.log("erreur"+req.responseText); + } + console.debug("ok we display"); + add_div(duplicate_div); + console.debug (getNodeText(xml.getElementsByTagName("code")[0])); + + console.debug("fill div"); + duplicate_div.setStyle({"position":"fixed","top":"15%","z-index":"999", + "min-width":"30rem", + "left":"30%", + "width":"40%"}); + duplicate_div.innerHTML=getNodeText(xml.getElementsByTagName("code")[0]); + duplicate_div.setStyle({display:"block"}); + } + } + + ); } \ No newline at end of file diff --git a/include/ajax/ajax_ledger.php b/include/ajax/ajax_ledger.php index 8b90b6e98..7f93ea81f 100644 --- a/include/ajax/ajax_ledger.php +++ b/include/ajax/ajax_ledger.php @@ -577,6 +577,22 @@ case 'reverseop': } $html=ob_get_contents(); ob_end_clean(); + break; + +case 'duplicateop': + /////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Duplicate operation + /////////////////////////////////////////////////////////////////////////////////////////////////////////// + $operation=new Acc_Operation($cn); + $operation->jr_id=$jr_id; + ob_start(); + echo HtmlInput::title_box(_("Dupliquer une opération"), $div); + echo $operation->form_clone_operation("cloneit"); + + $html=ob_get_contents(); + ob_end_clean(); + + break; } $html=escape_xml($html); diff --git a/include/class/acc_operation.class.php b/include/class/acc_operation.class.php index 3a71a3fe2..8586607fd 100644 --- a/include/class/acc_operation.class.php +++ b/include/class/acc_operation.class.php @@ -732,6 +732,60 @@ class Acc_Operation $type_operation->selected=$p_status; return $type_operation; } + /** + * create a form to recreate the operation and returns it, just like a correct + * + */ + function form_clone_operation($p_id) { + // retrieve all info about operation + $operation = $this->get_quant(); + $array=$operation->compute_array(); + global $g_user; + // Prepare the form + $r='
'; + $r.=Dossier::hidden(); + $a_code=$this->db->get_array("select code from v_menu_dependency vmd where me_code=$1 and p_id=$2", + array( $operation->signature,$g_user->get_profile())); + + // select the menu where the operation will be duplicated + if ( empty ($a_code)) { + $r.=_("Menu invalide"); + return $r; + } + $r.="

"; + $r.="

    "; + $r.=sprintf("
  • %s
  • ",$operation->det->jr_pj_number); + $r.=sprintf("
  • %s
  • ",$operation->det->jr_comment); + $r.=sprintf("
  • %s
  • ",$operation->det->jr_montant); + $r.="
"; + $r.="

"; + if (count($a_code) == 1 ) { + $r.=HtmlInput::hidden("ac",$a_code[0]['code']); + $r.=sprintf(_("Voulez-vous aller à %s pour dupliquer cette opération ?"),$a_code[0]['code']); + + } else { + $select=new ISelect("ac"); + $select->value=array(); + $nb_code=count($a_code); + + for ($i=0;$i<$nb_code;$i++) { + $select->value[]=array("label"=>$a_code[$i]['code'],"value"=>$a_code[$i]['code']); + } + $r.=sprintf(_("Voulez-vous aller à %s pour dupliquer cette opération ?"),$select->input()); + + } + + $r.="

"; + $r.=HtmlInput::simple_array_to_hidden($array); + + // + $r.=HtmlInput::submit(uniqid(), _("Dupliquer")); + $r.='
'; + + + // return the form as a string + return $r; + } } ///////////////////////////////////////////////////////////////////////////// @@ -764,6 +818,19 @@ class Acc_Detail extends Acc_Operation $this->det->note=$this->db->get_value($sql,array($this->jr_id)); $this->det->note=strip_tags($this->det->note); } + /** + * + */ + function compute_array() + { + $array=array(); + $array['desc']=$this->det->jr_comment; + $array['e_date']=""; + $array['e_ech']=""; + $array['p_jrn']=$this->det->jr_def_id; + return $array; + + } } ///////////////////////////////////////////////////////////////////////////// /** @@ -790,6 +857,30 @@ class Acc_Misc extends Acc_Detail FROM jrnx where j_grpt = $1 order by j_debit desc,j_poste"; $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id)); } + /*** + * Compute an array for using with Acc_Ledger::insert + * + */ + function compute_array() + { + $this->get(); + $array=parent::compute_array(); + $nb_array=count($this->det->array); + $array['nb_item']=$nb_array; + + for ($i=0;$i<$nb_array;$i++) { + $array["qc_".$i]=$this->det->array[$i]['j_qcode']; + $array["poste".$i]=$this->det->array[$i]['j_poste']; + $array["amount".$i]=$this->det->array[$i]['j_montant']; + if ( $this->det->array[$i]['j_debit'] == 't') { + $array["ck".$i]=1; + } + $array["ld".$i]=$this->det->array[$i]['j_text']; + } + + return $array; + + } } ///////////////////////////////////////////////////////////////////////////// /** @@ -813,6 +904,35 @@ class Acc_Sold extends Acc_Detail FROM quant_sold join jrnx using(j_id) where j_grpt=$1"; $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id)); } + /*** + * Compute an array for using with Acc_Ledger::insert + * + */ + function compute_array() + { + $this->get(); + $array=parent::compute_array(); + $nb_array=count($this->det->array); + $array['nb_item']=$nb_array; + + + $array["e_client"]=$this->db->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=23", + array($this->det->array[0]['qs_client'])); + + for ($i=0;$i<$nb_array;$i++) { + $array["e_march".$i]=$this->db->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=23", + array($this->det->array[$i]['qs_fiche'])); + + $array["e_march".$i."_price"]=$this->det->array[$i]['qs_unit']; + $array["e_march".$i."_label"]=$this->det->array[$i]['j_text']; + $array["e_march".$i."_tva_id"]=$this->det->array[$i]['qs_vat_code']; + $array["e_march".$i."_tva_amount"]=$this->det->array[$i]['qs_vat']; + $array["e_quant".$i]=$this->det->array[$i]['qs_quantite']; + } + $array['correct']=1; + return $array; + + } } ///////////////////////////////////////////////////////////////////////////// @@ -839,6 +959,37 @@ class Acc_Purchase extends Acc_Detail FROM quant_purchase join jrnx using(j_id) where j_grpt=$1"; $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id)); } + /*** + * Compute an array for using with Acc_Ledger::insert + * + */ + function compute_array() + { + $this->get(); + $array=parent::compute_array(); + $nb_array=count($this->det->array); + $array['nb_item']=$nb_array; + + + $array["e_client"]=$this->db->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=23", + array($this->det->array[0]['qp_supplier'])); + + for ($i=0;$i<$nb_array;$i++) { + $array["e_march".$i]=$this->db->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=23", + array($this->det->array[$i]['qp_fiche'])); + + $array["e_march".$i."_price"]=$this->det->array[$i]['qp_unit']; + $array["e_march".$i."_label"]=$this->det->array[$i]['j_text']; + $array["e_march".$i."_tva_id"]=$this->det->array[$i]['qp_vat_code']; + $array["e_march".$i."_tva_amount"]=$this->det->array[$i]['qp_vat']; + $array["e_quant".$i]=$this->det->array[$i]['qp_quantite']; + } + $array['correct']=1; + return $array; + + } + + } ///////////////////////////////////////////////////////////////////////////// /** @@ -861,4 +1012,27 @@ class Acc_Fin extends Acc_Detail FROM quant_fin where jr_id = $1"; $this->det->array=$this->db->get_array($sql,array($this->jr_id)); } + /*** + * Compute an array for using with Acc_Ledger::insert + * + */ + function compute_array() + { + $this->get(); + $array=parent::compute_array(); + $nb_array=count($this->det->array); + $array['nb_item']=$nb_array; + + + for ($i=0;$i<$nb_array;$i++) { + $array["e_other".$i]=$this->db->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=23", + array($this->det->array[$i]['qf_other'])); + + $array["e_other".$i."_amount"]=$this->det->array[$i]['qf_amount']; + $array["e_other".$i."_comment"]=$this->det->jr_comment; + } + $array['correct']=1; + return $array; + + } } diff --git a/include/lib/html_input.class.php b/include/lib/html_input.class.php index f79048b58..7dd1ccdf3 100755 --- a/include/lib/html_input.class.php +++ b/include/lib/html_input.class.php @@ -604,11 +604,24 @@ class HtmlInput } } } - } - + } + + return $r; + } + /** + * Transform a double array as a HTML string with hidden html value + * array has the formarray ["name"]="x",array['value']="y") the key name will be the hidden input name; + * @param double $array + */ + static function simple_array_to_hidden($array) + { + if (empty ($array)) return ""; + $r=""; + foreach ( $array as $key=>$value) { + $r.=HtmlInput::hidden($key, $value); + } return $r; } - /** * @brief transform a json to hidden * @param json $p_json diff --git a/include/template/ledger_detail_bottom.php b/include/template/ledger_detail_bottom.php index 6f89b1d91..c2d635420 100644 --- a/include/template/ledger_detail_bottom.php +++ b/include/template/ledger_detail_bottom.php @@ -1,5 +1,6 @@
set_position("in-absolute"); $cn=Dossier::connect(); // Contains all the linked actions $a_followup = Follow_Up::get_all_operation($jr_id); @@ -199,7 +204,6 @@ if ($aRap != null ) { $e ); $remove=Icon_Action::trash(uniqid(), $js); -// $remove=$rmReconciliation->input(); } else $remove=''; @@ -315,25 +319,29 @@ if ( $div != 'popup' ) { echo HtmlInput::submit('save',_('Sauver'),'onClick="return verify_ca(\'popup\');"'); $owner=new Noalyss_Parameter_Folder($cn); if ($owner->MY_ANALYTIC != 'nu' /*&& $div=='popup' */){ - echo ''; + + $select_box->add_javascript(_("Vérification CA"), sprintf("verify_ca('%s')",$div)); } $per=new Periode($cn,$obj->det->jr_tech_per); if ( $per->is_closed() == 0 && $owner->MY_STRICT=='N' && $g_user->check_action(RMOPER)==1) { - $remove=new IButton('Effacer'); - $remove->label=_('Effacer'); - $remove->javascript="return confirm_box(null,content[50],function () {removeOperation('".$obj->det->jr_id."',".dossier::id().",'".$div."')})"; - echo $remove->input(); + $javascript="return confirm_box(null,content[50],function () {removeOperation('".$obj->det->jr_id."',".dossier::id().",'".$div."')})"; + $select_box->add_javascript(_("Effacer"), $javascript); } //---------------------------------------------------- // Extourne //---------------------------------------------------- - $reverse=new IButton('bext'.$div); - $reverse->label=_('Extourner'); - $reverse->javascript="g('ext".$div."').style.display='block'"; - echo $reverse->input(); - echo '

'; + $select_box->add_javascript(_("Extourne"), sprintf("g('ext%s').style.display='block'",$div)); + + //------------------------------------------------------------------- + // Duplicate + //------------------------------------------------------------------- + $select_box->add_javascript(_("Duplicate"),sprintf("duplicate_operation('%s','%s')",Dossier::id(),$obj->jr_id)); + + +echo $select_box->input(); +echo '

'; echo ''; echo '