[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 50/73: Improve Manage_Table_SQL
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 50/73: Improve Manage_Table_SQL |
Date: |
Fri, 28 May 2021 05:26:40 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 14d867334f6a0e4e65126439ed6797e1a94f8cf8
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Fri May 7 14:34:13 2021 +0200
Improve Manage_Table_SQL
---
include/lib/manage_table_sql.class.php | 59 +++++++++++++++++++++++++++-------
1 file changed, 47 insertions(+), 12 deletions(-)
diff --git a/include/lib/manage_table_sql.class.php
b/include/lib/manage_table_sql.class.php
index 5d3a5b8..f5bd9ee 100644
--- a/include/lib/manage_table_sql.class.php
+++ b/include/lib/manage_table_sql.class.php
@@ -92,7 +92,7 @@ class Manage_Table_SQL
private $button_add_top; //!< place of the button add on the top, by
default true
protected $title; //! < give the title of the diabox , default is Data
private $cssclass; //! CSS class for the dialog box
-
+ private $current_row; //! in display_row and display_custom_row, it is the
current row which is used
/**
* @brief Constructor : set the label to the column name,
* the order of the column , set the properties and the
@@ -701,8 +701,23 @@ function check()
$this->button_add_top=$button_add_top;
return $this;
}
-
- /**
+ /**
+ * @brief execute the query (Data_SQL.seek), called by display_table
+ * @param string (default empty) $p_order SQL string added to
DatabaseCore::seek
+ * @param array (default null) $p_array Array for the SQL string
+ * @see Data_SQL.seek
+ * @return pgsql resource
+ */
+ function execute_query($p_order,$p_array=NULL)
+ {
+ if ($p_order=="")
+ {
+ $p_order="order by {$this->table->primary_key}";
+ }
+ $ret=$this->table->seek($p_order, $p_array);
+ return $ret;
+ }
+ /**
* @brief display the data of the table
* @param $p_order is the cond or order of the rows,
* if empty the primary key will be used
@@ -711,11 +726,7 @@ function check()
*/
function display_table($p_order="", $p_array=NULL)
{
- if ($p_order=="")
- {
- $p_order="order by {$this->table->primary_key}";
- }
- $ret=$this->table->seek($p_order, $p_array);
+ $ret=$this->execute_query();
$nb=Database::num_row($ret);
if ($this->can_append_row()==TRUE && $this->button_add_top == true)
{
@@ -912,6 +923,7 @@ function check()
$nb_order=count($this->a_order);
for ($i=0; $i<$nb_order; $i++)
{
+ $this->current_row=$p_row;
$v=$this->a_order[$i];
if ($i==0&&$this->icon_mod=="first"&&$this->can_update_row())
@@ -989,12 +1001,32 @@ function check()
echo '</tr>';
}
/**
+ * Return the current row printed in display_row
+ * @return array
+ */
+ public function get_current_row()
+ {
+ return $this->current_row;
+ }
+ /**
+ * set the current row printed in display_row
+ * @param type $current_row
+ * @return this;
+ */
+ public function set_current_row($current_row)
+ {
+ $this->current_row=$current_row;
+ return $this;
+ }
+
+ /**
* @brief When displaying a row, if a column has the type "custom" , we
can call this function to display properly the value
* including the tag "<td>".
+ * You can get the full array from display_row via get_current_row() or
reload from db thanks $p_id
*
* @param $p_key string key name
* @param $p_value string value
- * @param int $p_id id of the row (optional default 0)
+ * @param int $p_id id of the row , usually the pk of Data_SQL (optional
default 0)
* @see input_custom
* @see set_type
* @note must return a string which will be in surrounded by td in the
function display_row
@@ -1012,6 +1044,8 @@ function check()
*
* It returns true , if it is not readyonly and the form will have a
"save" button, if it returns nothing or false
* then there is no save button, nor form, the content is then readonly
+ *
+ *@see get_error , set_error
*
*/
function input()
@@ -1118,8 +1152,8 @@ function check()
* }
* }
* @endcode
- * @parameter string $p_key name of the column
- * @parameter string $p_value current value
+ * @param string $p_key name of the column
+ * @param string $p_value current value
* @return nothing
*/
function input_custom($p_key,$p_value) {
@@ -1198,7 +1232,8 @@ function check()
* display the input , but if that function returns false, the "save"
button will disappear but the form can be
* submitted with enter.
*
- * XML Tag
+ * @see input
+ * XML tag
* - status : OK , NOK
* - ctl : Dom id to update
* - content : Html answer
- [Noalyss-commit] [noalyss] 08/73: Warning if PHPVERSION < 7.2, (continued)
- [Noalyss-commit] [noalyss] 08/73: Warning if PHPVERSION < 7.2, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 10/73: Cosmetic : update fontello, button inplace_edit, doc, logo and dashboad, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 16/73: Currency : add a check , upgrade version of DB, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 24/73: Bug Select_Box = problem with DIV id, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 29/73: Cosmetic : display properly currency in detail operation, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 34/73: javascript : test and improve cosmetic, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 36/73: improve captcha, replace the global variable by a "DEFINE" constant, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 41/73: Cosmetic : Card History, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 47/73: Fix block problem with font, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 49/73: Improve function display_row_custom for the custom sort key see Sorttable.js, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 50/73: Improve Manage_Table_SQL,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 55/73: Manage_Table_SQL : typo, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 56/73: Output_HTML adapt to bootstrap navbar, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 57/73: Task #1807: Boutons indistincts – thème 7 classic, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 44/73: Cosmetic : width to large if recover passwd enable and icon trash not available for document (in operation detail), Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 28/73: Task #0001961: Devise : faciliter les calculs d'écarts de conversion, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 38/73: Task #1961 : Currency remove default currency, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 40/73: Cosmetic : add button_magnifier for searching, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 52/73: Code Rewriting : rename Noalyss_SQL class by Table_Data_SQL, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 53/73: Code Rewriting : rename Noalyss_SQL class by Table_Data_SQL, Dany De Bontridder, 2021/05/28
- [Noalyss-commit] [noalyss] 45/73: Cosmetic : button with HREF, Dany De Bontridder, 2021/05/28