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