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/21] =?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/21] 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/21] 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/21] 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/21] 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/21] 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/21] 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/21] #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/21] 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/21] 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/21] =?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/21] 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/21] 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/21] =?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=$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 '";
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/21] 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('