dolibarr 21.0.0-alpha
card.php
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) ---Put here your own copyright and developer email---
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
36// General defined Options
37//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
38//if (! defined('MAIN_AUTHENTICATION_MODE')) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
39//if (! defined('MAIN_LANG_DEFAULT')) define('MAIN_LANG_DEFAULT', 'auto'); // Force LANG (language) to a particular value
40//if (! defined('MAIN_SECURITY_FORCECSP')) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies
41//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
42//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
43//if (! defined('NOLOGIN')) define('NOLOGIN', '1'); // Do not use login - if this page is public (can be called outside logged session). This includes the NOIPCHECK too.
44//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
45//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
46//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // Do not load html.form.class.php
47//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // Do not load and show top and left menu
48//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
49//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
50//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
51//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
52//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
53//if (! defined('NOSESSION')) define('NOSESSION', '1'); // On CLI mode, no need to use web sessions
54//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
55//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
56
57
58// Load Dolibarr environment
59require "../main.inc.php";
60require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
61require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
62require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
63require_once DOL_DOCUMENT_ROOT.'/intracommreport/class/intracommreport.class.php';
64require_once DOL_DOCUMENT_ROOT.'/intracommreport/lib/intracommreport.lib.php';
65
66// Load translation files required by the page
67$langs->loadLangs(array("intracommreport", "other"));
68
69// Get parameters
70$id = GETPOSTINT('id');
71$ref = GETPOST('ref', 'alpha');
72$lineid = GETPOSTINT('lineid');
73
74$action = GETPOST('action', 'aZ09');
75$confirm = GETPOST('confirm', 'alpha');
76$cancel = GETPOST('cancel', 'aZ09');
77$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
78$backtopage = GETPOST('backtopage', 'alpha'); // if not set, a default page will be used
79$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); // if not set, $backtopage will be used
80$backtopagejsfields = GETPOST('backtopagejsfields', 'alpha');
81$dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09');
82
83if (!empty($backtopagejsfields)) {
84 $tmpbacktopagejsfields = explode(':', $backtopagejsfields);
85 $dol_openinpopup = $tmpbacktopagejsfields[0];
86}
87
88// Initialize a technical objects
89$object = new IntracommReport($db);
90$extrafields = new ExtraFields($db);
91$diroutputmassaction = $conf->intracommreport->dir_output.'/temp/massgeneration/'.$user->id;
92$hookmanager->initHooks(array($object->element.'card', 'globalcard')); // Note that conf->hooks_modules contains array
93
94// Fetch optionals attributes and labels
95$extrafields->fetch_name_optionals_label($object->table_element);
96
97$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
98
99// Initialize array of search criteria
100$search_all = trim(GETPOST("search_all", 'alpha'));
101$search = array();
102foreach ($object->fields as $key => $val) {
103 if (GETPOST('search_'.$key, 'alpha')) {
104 $search[$key] = GETPOST('search_'.$key, 'alpha');
105 }
106}
107
108if (empty($action) && empty($id) && empty($ref)) {
109 $action = 'view';
110}
111
112// Load object
113include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
114
115// There is several ways to check permission.
116// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
117$enablepermissioncheck = 1;
118if ($enablepermissioncheck) {
119 $permissiontoread = $user->hasRight('intracommreport', 'read');
120 $permissiontoadd = $user->hasRight('intracommreport', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
121 $permissiontodelete = $user->hasRight('intracommreport', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
122 $permissionnote = $user->hasRight('intracommreport', 'write'); // Used by the include of actions_setnotes.inc.php
123 $permissiondellink = $user->hasRight('intracommreport', 'write'); // Used by the include of actions_dellink.inc.php
124} else {
125 $permissiontoread = 1;
126 $permissiontoadd = 1; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
127 $permissiontodelete = 1;
128 $permissionnote = 1;
129 $permissiondellink = 1;
130}
131
132$upload_dir = $conf->intracommreport->multidir_output[isset($object->entity) ? $object->entity : 1].'/intracommreport';
133
134// Security check (enable the most restrictive one)
135//if ($user->socid > 0) accessforbidden();
136//if ($user->socid > 0) $socid = $user->socid;
137//$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0);
138//restrictedArea($user, $object->module, $object, $object->table_element, $object->element, 'fk_soc', 'rowid', $isdraft);
139if (!isModEnabled("intracommreport")) {
140 accessforbidden("Module intracommreport not enabled");
141}
142if (!$permissiontoread) {
144}
145
146$error = 0;
147
148
149/*
150 * Actions
151 */
152
153$parameters = array();
154$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
155if ($reshook < 0) {
156 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
157}
158
159if (empty($reshook)) {
160 $backurlforlist = dol_buildpath('/intracommreport/list.php', 1);
161
162 if (empty($backtopage) || ($cancel && empty($id))) {
163 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
164 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
165 $backtopage = $backurlforlist;
166 } else {
167 $backtopage = dol_buildpath('/intracommreport/card.php', 1).'?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
168 }
169 }
170 }
171
172 $triggermodname = 'INTRACOMMREPORT_MODIFY'; // Name of trigger action code to execute when we modify record
173
174 // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
175 include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
176
177 // Actions when linking object each other
178 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
179
180 // Actions when printing a doc from card
181 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
182
183 // Action to move up and down lines of object
184 //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
185
186 // Action to build doc
187 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
188
189 if ($action == 'set_thirdparty' && $permissiontoadd) {
190 $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', null, 'date', '', $user, $triggermodname);
191 }
192 if ($action == 'classin' && $permissiontoadd) {
193 $object->setProject(GETPOSTINT('projectid'));
194 }
195
196 // Actions to send emails
197 $triggersendname = 'INTRACOMMREPORT_SENTBYMAIL';
198 $autocopy = 'MAIN_MAIL_AUTOCOPY_INTRACOMMREPORT_TO';
199 $trackid = 'intracommreport'.$object->id;
200 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
201}
202
203
204
205
206/*
207 * View
208 */
209
210$form = new Form($db);
211$formfile = new FormFile($db);
212$formproject = new FormProjets($db);
213
214$title = $langs->trans("IntraCommReport")." - ".$langs->trans('Card');
215//$title = $object->ref." - ".$langs->trans('Card');
216if ($action == 'create') {
217 $title = $langs->trans("NewObject", $langs->transnoentitiesnoconv("IntraCommReport"));
218}
219$help_url = '';
220
221llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-mymodule page-card');
222
223// Example : Adding jquery code
224// print '<script type="text/javascript">
225// jQuery(document).ready(function() {
226// function init_myfunc()
227// {
228// jQuery("#myid").removeAttr(\'disabled\');
229// jQuery("#myid").attr(\'disabled\',\'disabled\');
230// }
231// init_myfunc();
232// jQuery("#mybutton").click(function() {
233// init_myfunc();
234// });
235// });
236// </script>';
237
238
239// Part to create
240if ($action == 'create') {
241 if (empty($permissiontoadd)) {
242 accessforbidden('NotEnoughPermissions', 0, 1);
243 }
244
245 print load_fiche_titre($title, '', 'object_'.$object->picto);
246
247 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
248 print '<input type="hidden" name="token" value="'.newToken().'">';
249 print '<input type="hidden" name="action" value="add">';
250 if ($backtopage) {
251 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
252 }
253 if ($backtopageforcancel) {
254 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
255 }
256 if ($backtopagejsfields) {
257 print '<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.'">';
258 }
259 if ($dol_openinpopup) {
260 print '<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.'">';
261 }
262
263 print dol_get_fiche_head(array(), '');
264
265
266 print '<table class="border centpercent tableforfieldcreate">'."\n";
267
268 // Common attributes
269 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
270
271 // Other attributes
272 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
273
274 print '</table>'."\n";
275
276 print dol_get_fiche_end();
277
278 print $form->buttonsSaveCancel("Create");
279
280 print '</form>';
281
282 //dol_set_focus('input[name="ref"]');
283}
284
285// Part to edit record
286if (($id || $ref) && $action == 'edit') {
287 print load_fiche_titre($langs->trans("IntraCommReport"), '', 'object_'.$object->picto);
288
289 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
290 print '<input type="hidden" name="token" value="'.newToken().'">';
291 print '<input type="hidden" name="action" value="update">';
292 print '<input type="hidden" name="id" value="'.$object->id.'">';
293 if ($backtopage) {
294 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
295 }
296 if ($backtopageforcancel) {
297 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
298 }
299
300 print dol_get_fiche_head();
301
302 print '<table class="border centpercent tableforfieldedit">'."\n";
303
304 // Common attributes
305 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
306
307 // Other attributes
308 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
309
310 print '</table>';
311
312 print dol_get_fiche_end();
313
314 print $form->buttonsSaveCancel();
315
316 print '</form>';
317}
318
319// Part to show record
320if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
322
323 print dol_get_fiche_head($head, 'card', $langs->trans("IntraCommReport"), -1, $object->picto, 0, '', '', 0, '', 1);
324
325 $formconfirm = '';
326
327 // Confirmation to delete (using preloaded confirm popup)
328 if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
329 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteIntraCommReport'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 'action-delete');
330 }
331 // Confirmation to delete line
332 if ($action == 'deleteline') {
333 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
334 }
335
336 // Clone confirmation
337 if ($action == 'clone') {
338 // Create an array for form
339 $formquestion = array();
340 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
341 }
342
343 // Call Hook formConfirm
344 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
345 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
346 if (empty($reshook)) {
347 $formconfirm .= $hookmanager->resPrint;
348 } elseif ($reshook > 0) {
349 $formconfirm = $hookmanager->resPrint;
350 }
351
352 // Print form confirm
353 print $formconfirm;
354
355
356 // Object card
357 // ------------------------------------------------------------
358 $linkback = '<a href="'.dol_buildpath('/intracommreport/list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
359
360 $morehtmlref = '<div class="refidno">';
361 /*
362 // Ref customer
363 $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1);
364 $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string'.(getDolGlobalInt('THIRDPARTY_REF_INPUT_SIZE') ? ':'.getDolGlobalInt('THIRDPARTY_REF_INPUT_SIZE') : ''), '', null, null, '', 1);
365 // Thirdparty
366 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer');
367 if (!getDolGlobalInt('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) {
368 $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)';
369 }
370 // Project
371 if (isModEnabled('project')) {
372 $langs->load("projects");
373 $morehtmlref .= '<br>';
374 if ($permissiontoadd) {
375 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
376 if ($action != 'classify') {
377 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
378 }
379 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
380 } else {
381 if (!empty($object->fk_project)) {
382 $proj = new Project($db);
383 $proj->fetch($object->fk_project);
384 $morehtmlref .= $proj->getNomUrl(1);
385 if ($proj->title) {
386 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
387 }
388 }
389 }
390 }
391 */
392 $morehtmlref .= '</div>';
393
394
395 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
396
397
398 print '<div class="fichecenter">';
399 print '<div class="fichehalfleft">';
400 print '<div class="underbanner clearboth"></div>';
401 print '<table class="border centpercent tableforfield">'."\n";
402
403 // Common attributes
404 //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
405 //unset($object->fields['fk_project']); // Hide field already shown in banner
406 //unset($object->fields['fk_soc']); // Hide field already shown in banner
407 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
408
409 // Other attributes. Fields from hook formObjectOptions and Extrafields.
410 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
411
412 print '</table>';
413 print '</div>';
414 print '</div>';
415
416 print '<div class="clearboth"></div>';
417
418 print dol_get_fiche_end();
419
420
421 /*
422 * Lines
423 */
424
425 if (!empty($object->table_element_line)) {
426 // Show object lines
427 $result = $object->getLinesArray();
428
429 print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
430 <input type="hidden" name="token" value="' . newToken().'">
431 <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
432 <input type="hidden" name="mode" value="">
433 <input type="hidden" name="page_y" value="">
434 <input type="hidden" name="id" value="' . $object->id.'">
435 ';
436
437 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
438 include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
439 }
440
441 print '<div class="div-table-responsive-no-min">';
442 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
443 print '<table id="tablelines" class="noborder noshadow" width="100%">';
444 }
445
446 /*
447 if (!empty($object->lines)) {
448 $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
449 }
450 */
451
452 // Form to add new line
453 if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
454 if ($action != 'editline') {
455 // Add products/services form
456
457 $parameters = array();
458 $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
459 if ($reshook < 0) {
460 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
461 }
462 if (empty($reshook)) {
463 $object->formAddObjectLine(1, $mysoc, $soc);
464 }
465 }
466 }
467
468 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
469 print '</table>';
470 }
471 print '</div>';
472
473 print "</form>\n";
474 }
475
476
477 // Buttons for actions
478
479 if ($action != 'presend' && $action != 'editline') {
480 print '<div class="tabsAction">'."\n";
481 $parameters = array();
482 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
483 if ($reshook < 0) {
484 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
485 }
486
487 if (empty($reshook)) {
488 // Send
489 if (empty($user->socid)) {
490 print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle');
491 }
492
493 // Back to draft
494 if ($object->status == $object::STATUS_VALIDATED) {
495 print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd);
496 }
497
498 // Modify
499 print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
500
501 // Validate
502 if ($object->status == $object::STATUS_DRAFT) {
503 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
504 print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes&token='.newToken(), '', $permissiontoadd);
505 } else {
506 $langs->load("errors");
507 print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0);
508 }
509 }
510
511 // Clone
512 if ($permissiontoadd) {
513 print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=clone&token='.newToken(), '', $permissiontoadd);
514 }
515
516 /*
517 // Disable / Enable
518 if ($permissiontoadd) {
519 if ($object->status == $object::STATUS_ENABLED) {
520 print dolGetButtonAction('', $langs->trans('Disable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', $permissiontoadd);
521 } else {
522 print dolGetButtonAction('', $langs->trans('Enable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', $permissiontoadd);
523 }
524 }
525 if ($permissiontoadd) {
526 if ($object->status == $object::STATUS_VALIDATED) {
527 print dolGetButtonAction('', $langs->trans('Cancel'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd);
528 } else {
529 print dolGetButtonAction('', $langs->trans('Re-Open'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen&token='.newToken(), '', $permissiontoadd);
530 }
531 }
532 */
533
534 // Delete (with preloaded confirm popup)
535 $deleteUrl = $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken();
536 $buttonId = 'action-delete-no-ajax';
537 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) { // We can use preloaded confirm if not jmobile
538 $deleteUrl = '';
539 $buttonId = 'action-delete';
540 }
541 $params = array();
542 print dolGetButtonAction('', $langs->trans("Delete"), 'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
543 }
544 print '</div>'."\n";
545 }
546
547
548 // Select mail models is same action as presend
549 if (GETPOST('modelselected')) {
550 $action = 'presend';
551 }
552
553 if ($action != 'presend') {
554 print '<div class="fichecenter"><div class="fichehalfleft">';
555 print '<a name="builddoc"></a>'; // ancre
556
557 $includedocgeneration = 0;
558
559 // Documents
560 if ($includedocgeneration) {
561 $objref = dol_sanitizeFileName($object->ref);
562 $relativepath = $objref.'/'.$objref.'.pdf';
563 $filedir = $conf->intracommreport->dir_output.'/'.$object->element.'/'.$objref;
564 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
565 $genallowed = $permissiontoread; // If you can read, you can build the PDF to read content
566 $delallowed = $permissiontoadd; // If you can create/edit, you can remove a file on card
567 print $formfile->showdocuments('intracommreport:IntraCommReport', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
568 }
569
570 // Show links to link elements
571 $linktoelem = $form->showLinkToObjectBlock($object, array(), array('intracommreport'));
572 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
573
574
575 print '</div><div class="fichehalfright">';
576
577 $MAXEVENT = 10;
578
579 $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/intracommreport/intracommreport_agenda.php', 1).'?id='.$object->id);
580
581 $includeeventlist = 0;
582
583 // List of actions on element
584 if ($includeeventlist) {
585 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
586 $formactions = new FormActions($db);
587 $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
588 }
589
590 print '</div></div>';
591 }
592
593 //Select mail models is same action as presend
594 if (GETPOST('modelselected')) {
595 $action = 'presend';
596 }
597
598 // Presend form
599 $modelmail = 'intracommreport';
600 $defaulttopic = 'InformationMessage';
601 $diroutput = $conf->intracommreport->dir_output;
602 $trackid = 'intracommreport'.$object->id;
603
604 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
605}
606
607// End of page
608llxFooter();
609$db->close();
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage standard extra fields.
Class to manage building of HTML components.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage building of HTML components.
Class to manage intracomm report.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
intracommreportPrepareHead($object)
Prepare array of tabs for IntraCommReport.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.