diff --git a/html/js/managetable.js b/html/js/managetable.js index 84c2d88a8..fe125da20 100644 --- a/html/js/managetable.js +++ b/html/js/managetable.js @@ -97,8 +97,10 @@ var ManageTable = function (p_table_name) // use the table //compute the length of row //if rows == 0 or the sort is not defined then append - if ( sort_column=-1 || p_table.rows.length < 2 || p_table.rows[1].cells[sort_column] == undefined || p_table.rows[1].cells[sort_column].getAttribute('sort_value') == undefined ) { - p_table.appendChild(p_element_row); + if ( this.sort_column==-1 || p_table.rows.length < 2 || p_table.rows[1].cells[sort_column] == undefined || p_table.rows[1].cells[sort_column].getAttribute('sort_value') == undefined ) { + var row=p_table.insertRow(p_table.rows.length); + row.innerHTML=p_element_row.innerHTML; + row.id=p_element_row.id; return; } // loop for each row , compare the innerHTML of the column with the @@ -262,7 +264,7 @@ var ManageTable = function (p_table_name) var answer = here.parseXML(req); if (answer['status'] == 'OK') { var x=answer['ctl_row']; - $(x).hide(); + $(x).remove(); alternate_row_color("tb"+answer['ctl']); }else { smoke.alert("Effacement impossible"); diff --git a/include/lib/manage_table_sql.class.php b/include/lib/manage_table_sql.class.php index 4678b9eba..087828e76 100644 --- a/include/lib/manage_table_sql.class.php +++ b/include/lib/manage_table_sql.class.php @@ -113,6 +113,13 @@ class Manage_Table_SQL $this->icon_del="right"; $this->col_sort=0; } + /** + * send the XML headers for the ajax call + */ + function send_header() + { + header('Content-type:text/xml;charset="UTF-8"'); + } /** * When adding an element , it is column we checked to insert before, * @return none @@ -177,9 +184,34 @@ class Manage_Table_SQL /** * This function can be overrided to check the data before - * inserting , updating or removing, + * inserting , updating or removing, above an example of an overidden check * @see set_error get_error * @return boolean + * @code +function check() + { + global $cn; + $table=$this->get_table(); + $is_error=0; + $insert=false; + // sect_codename must be unique + if ( $table->exist() > 0) { + $insert=1; + } + $count=$cn->get_value(" select count(*) from syndicat.treasurer where tr_login=$1 and sect_id=$2 and tr_id<>$3", + array( + $table->tr_login, + $table->section_full_name, + $table->tr_id + )); + if ($count > 0 ) { + $this->set_error("section_full_name",_("Ce trésorier a déjà accès à cette section")); + $is_error++; + } + if ( $is_error > 0 ) return false; + return true; + } + * @endcode */ function check() {