diff --git a/include/ajax/ajax_cfgaction.php b/include/ajax/ajax_cfgaction.php index 656253194..8d2312e91 100644 --- a/include/ajax/ajax_cfgaction.php +++ b/include/ajax/ajax_cfgaction.php @@ -63,13 +63,15 @@ $action_document_type->set_object_name($ctl_id); if ($action=="input") { - + $action_document_type->set_order(["dt_id", "dt_value","dt_prefix"]); + header('Content-type: text/xml; charset=UTF-8'); echo $action_document_type->ajax_input()->saveXML(); return; } elseif ($action=="save") { + $action_document_type->set_order(["dt_id", "dt_value","dt_prefix"]); $xml=$action_document_type->ajax_save(); header('Content-type: text/xml; charset=UTF-8'); echo $xml->saveXML(); diff --git a/include/class/action_document_type_mtable.class.php b/include/class/action_document_type_mtable.class.php index f02f56d7b..a48b98a70 100644 --- a/include/class/action_document_type_mtable.class.php +++ b/include/class/action_document_type_mtable.class.php @@ -162,35 +162,55 @@ class Action_Document_Type_MTable extends Manage_Table_SQL function input() { parent::input(); - - - + + + // Detail option contact $table=$this->get_table(); $cn=$table->cn; - // insert new contact options - $cn->exec_sql("insert into jnt_document_option_contact (jdoc_enable,document_type_id, - contact_option_ref_id) - select 0 , $1, cor_id - from contact_option_ref - where - cor_id not in (select cor_id from - jnt_document_option_contact a - where a.document_type_id=$1)",[$table->dt_id]); + try + { + $cn->start(); + if ( $table->dt_id == -1 ){ + $aOption=$cn->get_array("select cor_id,cor_label,cor_type,-1 document_type_id,0 jdoc_enable + from + contact_option_ref cor + order by cor_label"); + + } else { + // insert new contact options + $cn->exec_sql("insert into jnt_document_option_contact (jdoc_enable,document_type_id, + contact_option_ref_id) + select 0 , $1, cor_id + from contact_option_ref + where + cor_id not in (select cor_id from + jnt_document_option_contact a + where a.document_type_id=$1)", [$table->dt_id]); + + // Select all + $aOption=$cn->get_array("select cor_id,cor_label,cor_type,document_type_id ,coalesce(jdoc_enable,0) jdoc_enable + from + contact_option_ref cor + left join jnt_document_option_contact jdoc on (cor_id=contact_option_ref_id) + where + document_type_id is null + or document_type_id = $1 + order by cor_label", [$this->table->dt_id]); + } + + // Detail option + require NOALYSS_TEMPLATE."/action_document_type_mtable_input.php"; + $cn->commit(); + } + catch (Exception $exc) + { + $cn->rollback(); + + echo $exc->getMessage(); + error_log($exc->getTraceAsString()); + } - // Select all - - $aOption=$cn->get_array("select cor_id,cor_label,cor_type,document_type_id ,coalesce(jdoc_enable,0) jdoc_enable - from - contact_option_ref cor - left join jnt_document_option_contact jdoc on (cor_id=contact_option_ref_id) - where - document_type_id is null - or document_type_id = $1 - order by cor_label",[$this->table->dt_id]); - - // Detail option - require NOALYSS_TEMPLATE."/action_document_type_mtable_input.php"; } /** diff --git a/sql/upgrade.sql b/sql/upgrade.sql index e69de29bb..847dce72a 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -0,0 +1,2 @@ +ALTER TABLE public.action_person drop CONSTRAINT action_gestion_ag_id_fk2 ; +ALTER TABLE public.action_person ADD CONSTRAINT action_gestion_ag_id_fk2 FOREIGN KEY (ag_id) REFERENCES action_gestion(ag_id) on delete cascade on update cascade;