dolibarr  13.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 
25 //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
26 //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
27 //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
28 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
29 //if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
30 //if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
31 //if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on).
32 //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
33 //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
34 //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
35 //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
36 //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
37 //if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
38 //if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
39 //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
40 //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
41 //if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message
42 //if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies
43 //if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
44 //if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
45 
46 // Load Dolibarr environment
47 $res = 0;
48 // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
49 if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
50 // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
51 $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
52 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
53 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
54 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
55 // Try main.inc.php using relative path
56 if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
57 if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
58 if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
59 if (!$res) die("Include of main fails");
60 
61 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
62 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
63 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
64 dol_include_once('/mymodule/class/myobject.class.php');
65 dol_include_once('/mymodule/lib/mymodule_myobject.lib.php');
66 
67 // Load translation files required by the page
68 $langs->loadLangs(array("mymodule@mymodule", "other"));
69 
70 // Get parameters
71 $id = GETPOST('id', 'int');
72 $ref = GETPOST('ref', 'alpha');
73 $action = GETPOST('action', 'aZ09');
74 $confirm = GETPOST('confirm', 'alpha');
75 $cancel = GETPOST('cancel', 'aZ09');
76 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search
77 $backtopage = GETPOST('backtopage', 'alpha');
78 $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
79 //$lineid = GETPOST('lineid', 'int');
80 
81 // Initialize technical objects
82 $object = new MyObject($db);
83 $extrafields = new ExtraFields($db);
84 $diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id;
85 $hookmanager->initHooks(array('myobjectcard', 'globalcard')); // Note that conf->hooks_modules contains array
86 
87 // Fetch optionals attributes and labels
88 $extrafields->fetch_name_optionals_label($object->table_element);
89 
90 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
91 
92 // Initialize array of search criterias
93 $search_all = GETPOST("search_all", 'alpha');
94 $search = array();
95 foreach ($object->fields as $key => $val)
96 {
97  if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
98 }
99 
100 if (empty($action) && empty($id) && empty($ref)) $action = 'view';
101 
102 // Load object
103 include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
104 
105 
106 $permissiontoread = $user->rights->mymodule->myobject->read;
107 $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
108 $permissiontodelete = $user->rights->mymodule->myobject->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
109 $permissionnote = $user->rights->mymodule->myobject->write; // Used by the include of actions_setnotes.inc.php
110 $permissiondellink = $user->rights->mymodule->myobject->write; // Used by the include of actions_dellink.inc.php
111 $upload_dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object->entity : 1];
112 
113 // Security check - Protection if external user
114 //if ($user->socid > 0) accessforbidden();
115 //if ($user->socid > 0) $socid = $user->socid;
116 //$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0);
117 //$result = restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
118 
119 //if (empty($permissiontoread)) accessforbidden();
120 
121 
122 /*
123  * Actions
124  */
125 
126 $parameters = array();
127 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
128 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
129 
130 if (empty($reshook))
131 {
132  $error = 0;
133 
134  $backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1);
135 
136  if (empty($backtopage) || ($cancel && empty($id))) {
137  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
138  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
139  else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
140  }
141  }
142 
143  $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record
144 
145  // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
146  include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
147 
148  // Actions when linking object each other
149  include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
150 
151  // Actions when printing a doc from card
152  include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
153 
154  // Action to move up and down lines of object
155  //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
156 
157  // Action to build doc
158  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
159 
160  if ($action == 'set_thirdparty' && $permissiontoadd)
161  {
162  $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname);
163  }
164  if ($action == 'classin' && $permissiontoadd)
165  {
166  $object->setProject(GETPOST('projectid', 'int'));
167  }
168 
169  // Actions to send emails
170  $triggersendname = 'MYMODULE_MYOBJECT_SENTBYMAIL';
171  $autocopy = 'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
172  $trackid = 'myobject'.$object->id;
173  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
174 }
175 
176 
177 
178 
179 /*
180  * View
181  *
182  * Put here all code to build page
183  */
184 
185 $form = new Form($db);
186 $formfile = new FormFile($db);
187 $formproject = new FormProjets($db);
188 
189 $title = $langs->trans("MyObject");
190 $help_url = '';
191 llxHeader('', $title, $help_url);
192 
193 // Example : Adding jquery code
194 print '<script type="text/javascript" language="javascript">
195 jQuery(document).ready(function() {
196  function init_myfunc()
197  {
198  jQuery("#myid").removeAttr(\'disabled\');
199  jQuery("#myid").attr(\'disabled\',\'disabled\');
200  }
201  init_myfunc();
202  jQuery("#mybutton").click(function() {
203  init_myfunc();
204  });
205 });
206 </script>';
207 
208 
209 // Part to create
210 if ($action == 'create')
211 {
212  print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("MyObject")), '', 'object_'.$object->picto);
213 
214  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
215  print '<input type="hidden" name="token" value="'.newToken().'">';
216  print '<input type="hidden" name="action" value="add">';
217  if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
218  if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
219 
220  print dol_get_fiche_head(array(), '');
221 
222  // Set some default values
223  //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue';
224 
225  print '<table class="border centpercent tableforfieldcreate">'."\n";
226 
227  // Common attributes
228  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
229 
230  // Other attributes
231  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
232 
233  print '</table>'."\n";
234 
236 
237  print '<div class="center">';
238  print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">';
239  print '&nbsp; ';
240  print '<input type="'.($backtopage ? "submit" : "button").'" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"'.($backtopage ? '' : ' onclick="javascript:history.go(-1)"').'>'; // Cancel for create does not post form if we don't know the backtopage
241  print '</div>';
242 
243  print '</form>';
244 
245  //dol_set_focus('input[name="ref"]');
246 }
247 
248 // Part to edit record
249 if (($id || $ref) && $action == 'edit')
250 {
251  print load_fiche_titre($langs->trans("MyObject"), '', 'object_'.$object->picto);
252 
253  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
254  print '<input type="hidden" name="token" value="'.newToken().'">';
255  print '<input type="hidden" name="action" value="update">';
256  print '<input type="hidden" name="id" value="'.$object->id.'">';
257  if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
258  if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
259 
261 
262  print '<table class="border centpercent tableforfieldedit">'."\n";
263 
264  // Common attributes
265  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
266 
267  // Other attributes
268  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
269 
270  print '</table>';
271 
273 
274  print '<div class="center"><input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">';
275  print ' &nbsp; <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
276  print '</div>';
277 
278  print '</form>';
279 }
280 
281 // Part to show record
282 if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
283 {
284  $res = $object->fetch_optionals();
285 
286  $head = myobjectPrepareHead($object);
287  print dol_get_fiche_head($head, 'card', $langs->trans("MyObject"), -1, $object->picto);
288 
289  $formconfirm = '';
290 
291  // Confirmation to delete
292  if ($action == 'delete') {
293  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMyObject'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
294  }
295  // Confirmation to delete line
296  if ($action == 'deleteline') {
297  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
298  }
299  // Clone confirmation
300  if ($action == 'clone') {
301  // Create an array for form
302  $formquestion = array();
303  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
304  }
305 
306  // Confirmation of action xxxx
307  if ($action == 'xxx')
308  {
309  $formquestion = array();
310  /*
311  $forcecombo=0;
312  if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
313  $formquestion = array(
314  // 'text' => $langs->trans("ConfirmClone"),
315  // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
316  // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
317  // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
318  );
319  */
320  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
321  }
322 
323  // Call Hook formConfirm
324  $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
325  $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
326  if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
327  elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
328 
329  // Print form confirm
330  print $formconfirm;
331 
332 
333  // Object card
334  // ------------------------------------------------------------
335  $linkback = '<a href="'.dol_buildpath('/mymodule/myobject_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
336 
337  $morehtmlref = '<div class="refidno">';
338  /*
339  // Ref customer
340  $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
341  $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
342  // Thirdparty
343  $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
344  // Project
345  if (! empty($conf->projet->enabled))
346  {
347  $langs->load("projects");
348  $morehtmlref .= '<br>'.$langs->trans('Project') . ' ';
349  if ($permissiontoadd)
350  {
351  //if ($action != 'classify') $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> ';
352  $morehtmlref .= ' : ';
353  if ($action == 'classify') {
354  //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
355  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
356  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
357  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
358  $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
359  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
360  $morehtmlref .= '</form>';
361  } else {
362  $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
363  }
364  } else {
365  if (! empty($object->fk_project)) {
366  $proj = new Project($db);
367  $proj->fetch($object->fk_project);
368  $morehtmlref .= ': '.$proj->getNomUrl();
369  } else {
370  $morehtmlref .= '';
371  }
372  }
373  }*/
374  $morehtmlref .= '</div>';
375 
376 
377  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
378 
379 
380  print '<div class="fichecenter">';
381  print '<div class="fichehalfleft">';
382  print '<div class="underbanner clearboth"></div>';
383  print '<table class="border centpercent tableforfield">'."\n";
384 
385  // Common attributes
386  //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
387  //unset($object->fields['fk_project']); // Hide field already shown in banner
388  //unset($object->fields['fk_soc']); // Hide field already shown in banner
389  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
390 
391  // Other attributes. Fields from hook formObjectOptions and Extrafields.
392  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
393 
394  print '</table>';
395  print '</div>';
396  print '</div>';
397 
398  print '<div class="clearboth"></div>';
399 
401 
402 
403  /*
404  * Lines
405  */
406 
407  if (!empty($object->table_element_line))
408  {
409  // Show object lines
410  $result = $object->getLinesArray();
411 
412  print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
413  <input type="hidden" name="token" value="' . newToken().'">
414  <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
415  <input type="hidden" name="mode" value="">
416  <input type="hidden" name="id" value="' . $object->id.'">
417  ';
418 
419  if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
420  include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
421  }
422 
423  print '<div class="div-table-responsive-no-min">';
424  if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
425  {
426  print '<table id="tablelines" class="noborder noshadow" width="100%">';
427  }
428 
429  if (!empty($object->lines))
430  {
431  $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
432  }
433 
434  // Form to add new line
435  if ($object->status == 0 && $permissiontoadd && $action != 'selectlines')
436  {
437  if ($action != 'editline')
438  {
439  // Add products/services form
440  $object->formAddObjectLine(1, $mysoc, $soc);
441 
442  $parameters = array();
443  $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
444  }
445  }
446 
447  if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
448  {
449  print '</table>';
450  }
451  print '</div>';
452 
453  print "</form>\n";
454  }
455 
456 
457  // Buttons for actions
458 
459  if ($action != 'presend' && $action != 'editline') {
460  print '<div class="tabsAction">'."\n";
461  $parameters = array();
462  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
463  if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
464 
465  if (empty($reshook))
466  {
467  // Send
468  if (empty($user->socid)) {
469  print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle');
470  }
471 
472  // Back to draft
473  if ($object->status == $object::STATUS_VALIDATED) {
474  print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes', '', $permissiontoadd);
475  }
476 
477  print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit', '', $permissiontoadd);
478 
479  // Validate
480  if ($object->status == $object::STATUS_DRAFT) {
481  if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
482  print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', $permissiontoadd);
483  } else {
484  $langs->load("errors");
485  //print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', 0);
486  print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
487  }
488  }
489 
490  // Clone
491  print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=scrumsprint', '', $permissiontoadd);
492 
493  /*
494  if ($permissiontoadd)
495  {
496  if ($object->status == $object::STATUS_ENABLED) {
497  print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=disable">'.$langs->trans("Disable").'</a>'."\n";
498  } else {
499  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=enable">'.$langs->trans("Enable").'</a>'."\n";
500  }
501  }
502  if ($permissiontoadd)
503  {
504  if ($object->status == $object::STATUS_VALIDATED) {
505  print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close">'.$langs->trans("Cancel").'</a>'."\n";
506  } else {
507  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("Re-Open").'</a>'."\n";
508  }
509  }
510  */
511 
512  // Delete (need delete permission, or if draft, just need create/modify permission)
513  print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete', '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
514  }
515  print '</div>'."\n";
516  }
517 
518 
519  // Select mail models is same action as presend
520  if (GETPOST('modelselected')) {
521  $action = 'presend';
522  }
523 
524  if ($action != 'presend')
525  {
526  print '<div class="fichecenter"><div class="fichehalfleft">';
527  print '<a name="builddoc"></a>'; // ancre
528 
529  $includedocgeneration = 0;
530 
531  // Documents
532  if ($includedocgeneration) {
533  $objref = dol_sanitizeFileName($object->ref);
534  $relativepath = $objref.'/'.$objref.'.pdf';
535  $filedir = $conf->mymodule->dir_output.'/'.$object->element.'/'.$objref;
536  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
537  $genallowed = $user->rights->mymodule->myobject->read; // If you can read, you can build the PDF to read content
538  $delallowed = $user->rights->mymodule->myobject->write; // If you can create/edit, you can remove a file on card
539  print $formfile->showdocuments('mymodule:MyObject', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
540  }
541 
542  // Show links to link elements
543  $linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject'));
544  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
545 
546 
547  print '</div><div class="fichehalfright"><div class="ficheaddleft">';
548 
549  $MAXEVENT = 10;
550 
551  $morehtmlright = '<a href="'.dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id.'">';
552  $morehtmlright .= $langs->trans("SeeAll");
553  $morehtmlright .= '</a>';
554 
555  // List of actions on element
556  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
557  $formactions = new FormActions($db);
558  $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright);
559 
560  print '</div></div></div>';
561  }
562 
563  //Select mail models is same action as presend
564  if (GETPOST('modelselected')) $action = 'presend';
565 
566  // Presend form
567  $modelmail = 'myobject';
568  $defaulttopic = 'InformationMessage';
569  $diroutput = $conf->mymodule->dir_output;
570  $trackid = 'myobject'.$object->id;
571 
572  include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
573 }
574 
575 // End of page
576 llxFooter();
577 $db->close();
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action== 'set') elseif($action== 'specimen') elseif($action== 'setmodel') elseif($action== 'del') elseif($action== 'setdoc') $formactions
View.
Class to manage building of HTML components.
dolGetButtonAction($label, $html= '', $actionType= 'default', $url= '', $id= '', $userRight=1, $params=array())
Function dolGetButtonAction.
Class for MyObject.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
myobjectPrepareHead($object)
Prepare array of tabs for MyObject.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
Class to manage building of HTML components.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
Class to offer components to list and upload files.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
print $_SERVER["PHP_SELF"] n
Edit parameters.
Definition: categories.php:101
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...