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