26require_once NOALYSS_INCLUDE.
"/database/document_type_sql.class.php";
42 $this->
set_order([
"dt_id",
"dt_prefix",
"dt_value",]);
76 $this->
table->dt_value=
$http->request(
'dt_value');
77 $this->
table->dt_prefix=
$http->request(
'dt_prefix');
78 $this->other[
'detail_operation']=
$http->request(
"detail_operation",
"string", 0);
79 $this->other[
'contact_multiple']=
$http->request(
"det_contact_mul",
"string", 0);
80 $this->other[
'make_invoice']=
$http->request(
"make_invoice",
"string", 0);
81 $this->other[
'make_feenote']=
$http->request(
"make_feenote",
"string", 0);
82 $this->other[
'followup_comment']=
$http->request(
"followup_comment",
"string", 0);
83 $this->other[
'editable_description']=
$http->request(
"editable_description",
"string", 0);
84 $this->other[
'enable_followup']=
$http->request(
"enable_followup",
"string", 0);
85 $this->other[
'seq']=
$http->request(
"seq",
"string", 0);
86 $this->other[
'select_option_operation']=
$http->request(
"select_option_operation",
"string",
null);
87 $this->other[
'select_comment']=
$http->request(
"select_comment",
"string",
null);
88 $this->other[
'videoconf_server']=
$http->request(
'videoconf_server',
"string",0);
89 $this->other[
'videoconf_server_url']=
$http->request(
'videoconf_server_url',
"string",DEFAULT_SERVER_VIDEO_CONF);
90 $this->other[
"cor_id"]=
$http->request(
"cor_id",
"array",[]);
91 $nb_corid=count($this->other[
"cor_id"]);
93 for (
$i=0;
$i<$nb_corid;
$i++) {
94 $this->other[
"contact_option$i"]=
$http->request(
"contact_option".
$i,
"number",0);
106 if (empty(trim(
$table->dt_value)))
108 $this->
set_error(
"dt_value", _(
"Nom ne peut être vide"));
111 if (empty(trim(
$table->dt_prefix)))
113 $this->
set_error(
"dt_prefix", _(
"Préfixe ne peut être vide"));
117 if (
$table->cn->get_value(
'select count(*) from document_type where upper(dt_value)=upper($1) and dt_id <> $2',
120 $this->
set_error(
"dt_value", _(
"Doublon, ce nom existe déjà "));
124 if (
$table->cn->get_value(
'select count(*) from document_type where upper(dt_prefix)=upper($1) and dt_id <> $2',
127 $this->
set_error(
"dt_value", _(
"Doublon, ce préfixe existe déjà "));
147 $count_md=
$table->cn->get_value(
'select count(*) from document_modele where md_type=$1',
149 $count_a=
$table->cn->get_value(
'select count(*) from action_gestion where ag_type=$1', array(
$table->dt_id));
151 if ($count_md!=0||$count_a!=0)
153 throw new Exception(_(
'Des actions dépendent de cette catégorie'), 1300);
157 catch (Exception $exc)
159 if ($exc->getCode()!=1300)
163 throw new Exception($exc->getMessage());
182 if (
$table->dt_id == -1 ){
183 $aOption=
$cn->get_array(
"select cor_id,cor_label,cor_type,-1 document_type_id,0 jdoc_enable
185 contact_option_ref cor
186 order by cor_label");
190 $cn->exec_sql(
"insert into jnt_document_option_contact (jdoc_enable,document_type_id,
191 contact_option_ref_id)
192 select 0 , $1, cor_id
193 from contact_option_ref
195 cor_id not in (select cor_id from
196 jnt_document_option_contact a
197 where a.document_type_id=$1)", [
$table->dt_id]);
200 $aOption=
$cn->get_array(
"select cor_id,cor_label,cor_type,document_type_id ,coalesce(jdoc_enable,0) jdoc_enable
202 contact_option_ref cor
203 left join jnt_document_option_contact jdoc on (cor_id=contact_option_ref_id)
205 document_type_id is null
206 or document_type_id = $1
207 order by cor_label", [$this->
table->dt_id]);
210 $cn->exec_sql(
"delete from action_person_option where ap_id in (select apo.ap_id
212 left join action_person_option apo ON (a.ap_id=apo.action_person_id)
213 left join contact_option_ref cor on (apo.contact_option_ref_id=cor.cor_id)
214 join action_gestion ag on (a.ag_id=ag.ag_id)
216 cor.cor_id not in (select jdoc2.contact_option_ref_id
217 from jnt_document_option_contact jdoc2
218 where jdoc2.document_type_id =$1
219 and jdoc2.jdoc_enable =1));
224 require NOALYSS_TEMPLATE.
"/action_document_type_mtable_input.php";
227 catch (Exception $exc)
231 echo $exc->getMessage();
232 error_log($exc->getTraceAsString());
246 if ($this->other[
'seq']!=0)
249 $doc_type->set_number($this->other[
'seq']);
252 $cn->exec_sql(
"insert into document_option (do_code,document_type_id,do_enable,do_option) values ($1,$2,$3,$4)
253 on conflict on constraint document_option_un
254 do update set do_enable=$3,do_option=$4",
255 [
"detail_operation",
257 $this->other[
'detail_operation'],
258 $this->other[
'select_option_operation']
262 $cn->exec_sql(
"insert into document_option (do_code,document_type_id,do_enable) values ($1,$2,$3)
263 on conflict on constraint document_option_un
264 do update set do_enable=$3 ", [
"contact_multiple", $object_sql->dt_id, $this->other[
'contact_multiple']]);
267 $cn->exec_sql(
"insert into document_option (do_code,document_type_id,do_enable) values ($1,$2,$3)
268 on conflict on constraint document_option_un
269 do update set do_enable=$3 ", [
"editable_description", $object_sql->dt_id
270 , $this->other[
'editable_description']]);
273 $cn->exec_sql(
"insert into document_option (do_code,document_type_id,do_enable) values ($1,$2,$3)
274 on conflict on constraint document_option_un
275 do update set do_enable=$3 ", [
"make_invoice", $object_sql->dt_id, $this->other[
'make_invoice']]);
278 $cn->exec_sql(
"insert into document_option (do_code,document_type_id,do_enable) values ($1,$2,$3)
279 on conflict on constraint document_option_un
280 do update set do_enable=$3 ", [
"make_feenote", $object_sql->dt_id, $this->other[
'make_feenote']]);
283 $cn->exec_sql(
"insert into document_option (do_code,document_type_id,do_enable,do_option) values ($1,$2,$3,$4)
284 on conflict on constraint document_option_un
285 do update set do_enable=$3,do_option=$4 ",
286 [
"followup_comment",
288 $this->other[
'followup_comment'],
289 $this->other[
'select_comment']
293 if ( $this->other[
'videoconf_server'] == 1 && trim($this->other[
'videoconf_server_url'])==
"") {
294 $this->other[
'videoconf_server_url']=DEFAULT_SERVER_VIDEO_CONF;
296 $cn->exec_sql(
"insert into document_option (do_code,document_type_id,do_enable,do_option) values ($1,$2,$3,$4)
297 on conflict on constraint document_option_un
298 do update set do_enable=$3,do_option=$4 ",
299 [
"videoconf_server",
301 $this->other[
'videoconf_server'],
302 $this->other[
'videoconf_server_url']
306 $cn->exec_sql(
"delete from jnt_document_option_contact where document_type_id=$1",[$object_sql->dt_id]);
307 $nb_contact_option=count($this->other[
"cor_id"]);
309 for (
$e=0;
$e<$nb_contact_option;
$e++) {
311 if ( isset($this->other[
"contact_option".
$e]) ) {
312 $cn->exec_sql(
"insert into jnt_document_option_contact
313 (jdoc_enable,document_type_id,contact_option_ref_id)
314 values ($1,$2,$3)",[$this->other[
"contact_option".
$e],$object_sql->dt_id,$option_id]);
record_log($p_message)
Record an error message into the log file of the server.
catch(Exception $ex) $doc_type
display , modify and add document_type for follow up
__construct(Document_type_SQL $doc_type)
input()
display the box for adding, the name for p_id , are in the form
abstract of the table public.document_type
Purpose is to propose a librairy to display a table content and allow to update and delete row ,...
set_property_updatable($p_key, $p_value)
set a column of the data row updatable or not
set_property_visible($p_key, $p_value)
set a column of the data row visible or not
set_error($p_col, $p_message)
set the error message for a wrong input
set_col_label($p_key, $p_display)
set the name to display for a column