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