Document Type : CFGACTION cannot add new document, fix order in dialog box,Fix= cannot delete action cause cascade on action_person

This commit is contained in:
Dany De Bontridder 2020-10-12 12:59:22 +02:00
parent 2427b756a9
commit ed50fc802d
3 changed files with 50 additions and 26 deletions

View file

@ -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();

View file

@ -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";
}
/**

View file

@ -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;