From 1f037f640ed4167cd40d69d80abfcd9d15d56016 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Wed, 14 Oct 2020 16:39:45 +0200 Subject: [PATCH] Follow-Up : comment optional --- include/action.common.inc.php | 6 ++-- .../action_document_type_mtable.class.php | 6 ++++ include/class/document_option.class.php | 31 +++++++++++++++++++ include/class/follow_up.class.php | 3 +- include/constant.php | 2 +- include/sql/patch/upgrade148.sql | 6 ++++ .../action_document_type_mtable_input.php | 8 +++++ include/template/detail-action.php | 6 ++-- 8 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 include/sql/patch/upgrade148.sql diff --git a/include/action.common.inc.php b/include/action.common.inc.php index cd754240a..ad648082c 100644 --- a/include/action.common.inc.php +++ b/include/action.common.inc.php @@ -193,10 +193,9 @@ if ($sub_action == "update") } $act->f_id_dest=$act->qcode_dest; $act->save(); - echo '
'; // Add hidden tag - echo '
'; + echo ''; @@ -207,7 +206,6 @@ if ($sub_action == "update") echo ''; echo $supl_hidden; echo '
'; - echo '
'; return; } } @@ -228,7 +226,7 @@ if ($sub_action == 'detail') if ($g_user->can_write_action($ag_id) == true) { - echo '
'; + echo ''; echo $supl_hidden; echo HtmlInput::hidden('ac', $http->request('ac')); echo dossier::hidden(); diff --git a/include/class/action_document_type_mtable.class.php b/include/class/action_document_type_mtable.class.php index 64c8c5748..d0d364031 100644 --- a/include/class/action_document_type_mtable.class.php +++ b/include/class/action_document_type_mtable.class.php @@ -79,6 +79,7 @@ class Action_Document_Type_MTable extends Manage_Table_SQL $this->other['detail_operation']=$http->request("detail_operation", "string", 0); $this->other['contact_multiple']=$http->request("det_contact_mul", "string", 0); $this->other['make_invoice']=$http->request("make_invoice", "string", 0); + $this->other['followup_comment']=$http->request("followup_comment", "string", 0); $this->other['seq']=$http->request("seq", "string", 0); $this->other['select_option_operation']=$http->request("select_option_operation", "string", null); $this->other["cor_id"]=$http->request("cor_id","array",[]); @@ -258,6 +259,10 @@ class Action_Document_Type_MTable extends Manage_Table_SQL $cn->exec_sql("insert into document_option (do_code,document_type_id,do_enable) values ($1,$2,$3) on conflict on constraint document_option_un do update set do_enable=$3 ", ["make_invoice", $object_sql->dt_id, $this->other['make_invoice']]); + // Option for comments + $cn->exec_sql("insert into document_option (do_code,document_type_id,do_enable) values ($1,$2,$3) + on conflict on constraint document_option_un + do update set do_enable=$3 ", ["followup_comment", $object_sql->dt_id, $this->other['followup_comment']]); // Option contact to save $cn->exec_sql("delete from jnt_document_option_contact where document_type_id=$1",[$object_sql->dt_id]); @@ -272,6 +277,7 @@ class Action_Document_Type_MTable extends Manage_Table_SQL } } + } } diff --git a/include/class/document_option.class.php b/include/class/document_option.class.php index cc5553356..4fd974c2c 100644 --- a/include/class/document_option.class.php +++ b/include/class/document_option.class.php @@ -48,6 +48,23 @@ class Document_Option } return $display_operation; } + /** + * returns true if comment are available otherwise false + * + * @param int $p_document_type Document_Type.dt_id + * @return boolean + */ + static function is_enable_comment($p_document_type) + { + $display_operation=false; + $cn=Dossier::connect(); + if ($cn->get_value("select do_enable from document_option where document_type_id=$1 and do_code = $2", + [$p_document_type, 'followup_comment'])=='1') + { + $display_operation=true; + } + return $display_operation; + } /** * returns option from the operation_detail * @@ -98,5 +115,19 @@ class Document_Option } return $return; } + /** + * Returns true if we can add a comment , or false if it is not possible + * @param integer $p_id is the action_gestion.ag_id + */ + static function can_add_comment($p_id) { + $cn=Dossier::connect(); + $document_type=$cn->get_value("select ag_type from action_gestion where ag_id=$1",[$p_id]); + if (Document_Option::is_enable_comment($document_type)) return true; + // If comment are disable, only the first one is authorized as event description + $cnt=$cn->get_value("select count(*) from action_gestion_comment where ag_id=$1",[$p_id]); + if ($cnt == 0 ) return true; + return false; + + } } diff --git a/include/class/follow_up.class.php b/include/class/follow_up.class.php index dfc1ec802..52aeecbef 100644 --- a/include/class/follow_up.class.php +++ b/include/class/follow_up.class.php @@ -38,6 +38,7 @@ require_once NOALYSS_INCLUDE.'/lib/inum.class.php'; require_once NOALYSS_INCLUDE.'/lib/sort_table.class.php'; require_once NOALYSS_INCLUDE.'/lib/irelated_action.class.php'; require_once NOALYSS_INCLUDE.'/class/tag.class.php'; +require_once NOALYSS_INCLUDE.'/class/document_option.class.php'; require_once NOALYSS_INCLUDE.'/class/default_menu.class.php'; require_once NOALYSS_INCLUDE.'/lib/inplace_edit.class.php'; require_once NOALYSS_INCLUDE.'/lib/noalyss_csv.class.php'; @@ -592,7 +593,7 @@ class Follow_Up /* Upload the documents */ $doc=new Document($this->db); $doc->Upload($this->ag_id); - if (trim($this->ag_comment)!='') + if (trim($this->ag_comment)!='' && Document_Option::can_add_comment($this->ag_id)) { $this->db->exec_sql("insert into action_gestion_comment (ag_id,tech_user,agc_comment) values ($1,$2,$3)" , array($this->ag_id, $_SESSION['g_user'], $this->ag_comment)); diff --git a/include/constant.php b/include/constant.php index 07b2dce1c..fe77c4d64 100644 --- a/include/constant.php +++ b/include/constant.php @@ -107,7 +107,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) { if ( ! defined ("SYSINFO_DISPLAY")) { define ("SYSINFO_DISPLAY",TRUE); } -define ("DBVERSION",148); +define ("DBVERSION",149); define ("MONO_DATABASE",25); define ("DBVERSIONREPO",18); define ('NOTFOUND','--not found--'); diff --git a/include/sql/patch/upgrade148.sql b/include/sql/patch/upgrade148.sql new file mode 100644 index 000000000..76477c192 --- /dev/null +++ b/include/sql/patch/upgrade148.sql @@ -0,0 +1,6 @@ +begin; +INSERT INTO public.document_option (do_code, document_type_id, do_enable, do_option) select 'followup_comment', dt_id, 1, NULL +from document_type ; + +insert into version (val,v_description) values (149,'Default values for document_option,comment on followup'); +commit; diff --git a/include/template/action_document_type_mtable_input.php b/include/template/action_document_type_mtable_input.php index 784a4f069..a02401f30 100644 --- a/include/template/action_document_type_mtable_input.php +++ b/include/template/action_document_type_mtable_input.php @@ -92,6 +92,14 @@ $i=new ICheckBox("make_invoice",1); if ( Document_Option::is_enable_make_invoice($table->dt_id)) $i->set_check(1); else $i->set_check(0); echo $i->input(); echo _("Création de facture"); +?> + +
  • +dt_id)) $i->set_check(1); else $i->set_check(0); +echo $i->input(); +echo _("Commentaire"); ?>
  • diff --git a/include/template/detail-action.php b/include/template/detail-action.php index 0516e5f49..f43d3211e 100644 --- a/include/template/detail-action.php +++ b/include/template/detail-action.php @@ -276,10 +276,12 @@ for( $c=0;$c'; -echo $desc->input(); +if ( Document_Option::can_add_comment($ag_id) ) { + echo $desc->input(); +} echo ''; ?> - +

    value="+" onclick="enlarge('ag_comment');return false;"> value="-" style="display:none" onclick="small('ag_comment');return false;">