diff --git a/html/js/infobulle.js b/html/js/infobulle.js
index 525585ff7..e87b19b1f 100644
--- a/html/js/infobulle.js
+++ b/html/js/infobulle.js
@@ -52,3 +52,10 @@ function hideBulle(p_ctl)
var d=document.getElementById('bulle');
d.style.visibility="hidden";
}
+function displayBulle(p_comment) {
+ var d=document.getElementById('bulle');
+ d.innerHTML=p_comment;
+ d.style.top=posY+offsetY+"px";
+ d.style.left=posX+offsetX+"px";
+ d.style.visibility="visible";
+}
\ No newline at end of file
diff --git a/html/js/managetable.js b/html/js/managetable.js
index 1e84a54c7..29e2f070c 100644
--- a/html/js/managetable.js
+++ b/html/js/managetable.js
@@ -172,16 +172,19 @@ var ManageTable = function (p_table_name)
new_row.innerHTML = answer['html'];
$("tb"+answer['ctl']).appendChild(new_row);
}
- new Effect.Highlight(answer['ctl_row'] ,{ startcolor: '#ABCBF7',endcolor: '#ffffff' });
+ new Effect.Highlight(answer['ctl_row'] ,{startcolor: '#FAD4D4',endcolor: '#F78082' });
+ alternate_row_color("tb"+answer['ctl']);
+ remove_waiting_box();
+ $("dtr").hide();
} else {
+ remove_waiting_box();
smoke.alert("Changement impossible");
- throw "error in save";
+ $("dtr").update(answer['html']);
+
}
- alternate_row_color("tb"+answer['ctl']);
- remove_waiting_box();
- $("dtr").hide();
- } catch (e) {
+ }
+ catch (e) {
alert(e.message);
return false;
}
diff --git a/include/database/class_noalyss_sql.php b/include/database/class_noalyss_sql.php
index 34eb68948..35b5677cd 100644
--- a/include/database/class_noalyss_sql.php
+++ b/include/database/class_noalyss_sql.php
@@ -95,8 +95,7 @@ abstract class Noalyss_SQL
*/
public function save()
{
- $pk=$this->primary_key;
- $count=$this->cn->get_value('select count(*) from '.$this->table.' where '.$this->primary_key.'=$1',array($this->$pk));
+ $count = $this->exist();
if ($count == 0)
$this->insert();
diff --git a/include/lib/class_html_input.php b/include/lib/class_html_input.php
index a367f7aa2..6d5a06358 100755
--- a/include/lib/class_html_input.php
+++ b/include/lib/class_html_input.php
@@ -228,6 +228,15 @@ class HtmlInput
$r='Δ';
return $r;
}
+ static function errorbulle($p_comment)
+ {
+ global $g_failed;
+ $r=sprintf(' %s ',
+ $p_comment,
+ $p_comment,
+ $g_failed);
+ return $r;
+ }
/**
* return a string containing the html code for calling the modifyOperation
*/
@@ -476,7 +485,7 @@ class HtmlInput
*/
static function image_click($p_image,$p_js,$p_message)
{
- $ret=sprintf('',
+ $ret=sprintf('
',
$p_message,$p_image,$p_js);
return $ret;
diff --git a/include/lib/class_manage_table_sql.php b/include/lib/class_manage_table_sql.php
index f670f4129..32506ec9b 100644
--- a/include/lib/class_manage_table_sql.php
+++ b/include/lib/class_manage_table_sql.php
@@ -68,7 +68,7 @@ class Manage_Table_SQL
private $row_update; //!< Flag to indicate if rows can be updated
private $row_append; //!< Flag to indicate if rows can be added
private $json_parameter; //!< Default parameter to add (gDossier...)
-
+ private $aerror; //!< Array containing the error of the input data
const UPDATABLE=1;
const VISIBLE=2;
@@ -98,8 +98,42 @@ class Manage_Table_SQL
$this->callback="ajax.php";
$this->json=json_encode(array("gDossier"=>Dossier::id(),
"op"=>"managetable"));
+ $this->aerror=[];
+ }
+ function get_table() {
+ return $this->table;
+ }
+ /**
+ * @brief set the error message for a wrong input
+ * @param $p_col the column name
+ * @param $p_message the error message
+ * @see check
+ */
+ function set_error($p_col,$p_message)
+ {
+ $this->aerror[$p_col]=$p_message;
+ }
+ /**
+ * @brief retrieve the error message
+ * @param $p_col column name
+ * @return string with message or empty if no error
+ * @see input
+ */
+ function get_error($p_col)
+ {
+ if ( isset ($this->aerror[$p_col])) return $this->aerror[$p_col];
+ return "";
+ }
+ /**
+ * This function can be overrided to check the data before
+ * inserting , updating or removing,
+ * @see set_error get_error
+ * @return boolean
+ */
+ function check()
+ {
+ return true;
}
-
/**
* @brief set the type of a column , it will change in the input db box , the
* select must supply an array of possible values [val=> , label=>] with
@@ -454,7 +488,7 @@ class Manage_Table_SQL
}
/**
- * @brief set the id value of a data row
+ * @brief set the id value of a data row and load from the db
*/
function set_pk($p_id)
{
@@ -463,7 +497,9 @@ class Manage_Table_SQL
}
/**
- * @brief get the data from http request
+ * @brief get the data from http request strip the not update or not visible data to their
+ * initial value. Before saving , it is important to set the pk and load from db
+ * @see set_pk
*/
function from_request()
{
@@ -472,7 +508,11 @@ class Manage_Table_SQL
{
$v=HtmlInput::default_value_request($this->a_order[$i], "");
$key=$this->a_order[$i];
- $this->table->$key=strip_tags($v);
+ if ( $this->get_property_visible($key) == TRUE
+ && $this->get_property_updatable($key) == TRUE )
+ {
+ $this->table->$key=strip_tags($v);
+ }
}
}
@@ -510,7 +550,7 @@ class Manage_Table_SQL
$js=sprintf("%s.delete('%s','%s');", $this->object_name,
$p_row[$this->table->primary_key], $this->object_name
);
- echo HtmlInput::image_click("delete.gif", $js,_("effacer"));
+ echo HtmlInput::image_click("delete.gif", $js,_("Effacer"));
}
echo "";
echo '';
@@ -530,11 +570,12 @@ class Manage_Table_SQL
$key=$this->a_order[$i];
$label=$this->a_label_displaid[$key];
$value=$this->table->get($key);
-
+ $error=$this->get_error($key);
+ $error=($error=="")?"":HtmlInput::errorbulle($error);
if ($this->get_property_visible($key)===TRUE)
{
// Label
- echo "