48 if (!$res && !empty($_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) {
49 $res = @include $_SERVER[
"CONTEXT_DOCUMENT_ROOT"].
"/main.inc.php";
52 $tmp = empty($_SERVER[
'SCRIPT_FILENAME']) ?
'' : $_SERVER[
'SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
53 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
56 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)).
"/main.inc.php")) {
57 $res = @include substr($tmp, 0, ($i + 1)).
"/main.inc.php";
59 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php")) {
60 $res = @include dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php";
63 if (!$res && file_exists(
"../main.inc.php")) {
64 $res = @include
"../main.inc.php";
66 if (!$res && file_exists(
"../../main.inc.php")) {
67 $res = @include
"../../main.inc.php";
69 if (!$res && file_exists(
"../../../main.inc.php")) {
70 $res = @include
"../../../main.inc.php";
73 die(
"Include of main fails");
76 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
77 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
78 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
83 $langs->loadLangs(array(
"mymodule@mymodule",
"other"));
88 $lineid =
GETPOST(
'lineid',
'int');
90 $action =
GETPOST(
'action',
'aZ09');
91 $confirm =
GETPOST(
'confirm',
'alpha');
92 $cancel =
GETPOST(
'cancel',
'aZ09');
93 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
94 $backtopage =
GETPOST(
'backtopage',
'alpha');
95 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
96 $dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
101 $diroutputmassaction = $conf->mymodule->dir_output.
'/temp/massgeneration/'.$user->id;
102 $hookmanager->initHooks(array(
'myobjectcard',
'globalcard'));
105 $extrafields->fetch_name_optionals_label($object->table_element);
107 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
110 $search_all =
GETPOST(
"search_all",
'alpha');
112 foreach ($object->fields as $key => $val) {
113 if (
GETPOST(
'search_'.$key,
'alpha')) {
114 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
118 if (empty($action) && empty($id) && empty($ref)) {
123 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
127 $enablepermissioncheck = 0;
128 if ($enablepermissioncheck) {
129 $permissiontoread = $user->hasRight(
'mymodule',
'myobject',
'read');
130 $permissiontoadd = $user->hasRight(
'mymodule',
'myobject',
'write');
131 $permissiontodelete = $user->hasRight(
'mymodule',
'myobject',
'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
132 $permissionnote = $user->hasRight(
'mymodule',
'myobject',
'write');
133 $permissiondellink = $user->hasRight(
'mymodule',
'myobject',
'write');
135 $permissiontoread = 1;
136 $permissiontoadd = 1;
137 $permissiontodelete = 1;
139 $permissiondellink = 1;
142 $upload_dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object->entity : 1].
'/myobject';
152 if (!$permissiontoread) {
161 $parameters = array();
162 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
167 if (empty($reshook)) {
170 $backurlforlist =
dol_buildpath(
'/mymodule/myobject_list.php', 1);
172 if (empty($backtopage) || ($cancel && empty($id))) {
173 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
174 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
175 $backtopage = $backurlforlist;
177 $backtopage =
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
182 $triggermodname =
'MYMODULE_MYOBJECT_MODIFY';
185 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
188 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
191 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
197 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
199 if ($action ==
'set_thirdparty' && $permissiontoadd) {
200 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
202 if ($action ==
'classin' && $permissiontoadd) {
203 $object->setProject(
GETPOST(
'projectid',
'int'));
207 $triggersendname =
'MYMODULE_MYOBJECT_SENTBYMAIL';
208 $autocopy =
'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
209 $trackid =
'myobject'.$object->id;
210 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
226 $title = $langs->trans(
"MyObject");
247 if ($action ==
'create') {
248 if (empty($permissiontoadd)) {
252 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"MyObject")),
'',
'object_'.$object->picto);
254 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
255 print
'<input type="hidden" name="token" value="'.newToken().
'">';
256 print
'<input type="hidden" name="action" value="add">';
258 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
260 if ($backtopageforcancel) {
261 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
269 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
272 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
275 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
277 print
'</table>'.
"\n";
281 print
$form->buttonsSaveCancel(
"Create");
289 if (($id || $ref) && $action ==
'edit') {
290 print
load_fiche_titre($langs->trans(
"MyObject"),
'',
'object_'.$object->picto);
292 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
293 print
'<input type="hidden" name="token" value="'.newToken().
'">';
294 print
'<input type="hidden" name="action" value="update">';
295 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
297 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
299 if ($backtopageforcancel) {
300 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
305 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
308 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
311 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
317 print
$form->buttonsSaveCancel();
323 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
326 print
dol_get_fiche_head($head,
'card', $langs->trans(
"MyObject"), -1, $object->picto);
331 if ($action ==
'delete') {
332 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteMyObject'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
335 if ($action ==
'deleteline') {
336 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
340 if ($action ==
'clone') {
342 $formquestion = array();
343 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
347 if ($action ==
'xxx') {
348 $text = $langs->trans(
'ConfirmActionMyObject', $object->ref);
357 $formquestion = array();
369 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
373 $parameters = array(
'formConfirm' =>
$formconfirm,
'lineid' => $lineid);
374 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
375 if (empty($reshook)) {
377 } elseif ($reshook > 0) {
387 $linkback =
'<a href="'.dol_buildpath(
'/mymodule/myobject_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
389 $morehtmlref =
'<div class="refidno">';
421 $morehtmlref .=
'</div>';
424 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
427 print
'<div class="fichecenter">';
428 print
'<div class="fichehalfleft">';
429 print
'<div class="underbanner clearboth"></div>';
430 print
'<table class="border centpercent tableforfield">'.
"\n";
436 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
439 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
445 print
'<div class="clearboth"></div>';
454 if (!empty($object->table_element_line)) {
456 $result = $object->getLinesArray();
458 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
459 <input type="hidden" name="token" value="' .
newToken().
'">
460 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
461 <input type="hidden" name="mode" value="">
462 <input type="hidden" name="page_y" value="">
463 <input type="hidden" name="id" value="' . $object->id.
'">
466 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
467 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
470 print
'<div class="div-table-responsive-no-min">';
471 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
472 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
475 if (!empty($object->lines)) {
476 $object->printObjectLines($action, $mysoc,
null,
GETPOST(
'lineid',
'int'), 1);
480 if ($object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
481 if ($action !=
'editline') {
484 $parameters = array();
485 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
486 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
488 $object->formAddObjectLine(1, $mysoc, $soc);
492 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
503 if ($action !=
'presend' && $action !=
'editline') {
504 print
'<div class="tabsAction">'.
"\n";
505 $parameters = array();
506 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
511 if (empty($reshook)) {
513 if (empty($user->socid)) {
514 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle');
518 if ($object->status == $object::STATUS_VALIDATED) {
519 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
522 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
525 if ($object->status == $object::STATUS_DRAFT) {
526 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
527 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
529 $langs->load(
"errors");
530 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
535 if ($permissiontoadd) {
536 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.(!empty($object->socid)?
'&socid='.$object->socid:
'').
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
558 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete, $params);
565 if (
GETPOST(
'modelselected')) {
569 if ($action !=
'presend') {
570 print
'<div class="fichecenter"><div class="fichehalfleft">';
571 print
'<a name="builddoc"></a>';
573 $includedocgeneration = 0;
576 if ($includedocgeneration) {
578 $relativepath = $objref.
'/'.$objref.
'.pdf';
579 $filedir = $conf->mymodule->dir_output.
'/'.$object->element.
'/'.$objref;
580 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
581 $genallowed = $permissiontoread;
582 $delallowed = $permissiontoadd;
583 print $formfile->showdocuments(
'mymodule:MyObject', $object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
587 $linktoelem =
$form->showLinkToObjectBlock($object,
null, array(
'myobject'));
588 $somethingshown =
$form->showLinkedObjectBlock($object, $linktoelem);
591 print
'</div><div class="fichehalfright">';
595 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dol_buildpath(
'/mymodule/myobject_agenda.php', 1).
'?id='.$object->id);
598 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
600 $somethingshown =
$formactions->showactions($object, $object->element.
'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
602 print
'</div></div>';
606 if (
GETPOST(
'modelselected')) {
611 $modelmail =
'myobject';
612 $defaulttopic =
'InformationMessage';
613 $diroutput = $conf->mymodule->dir_output;
614 $trackid =
'myobject'.$object->id;
616 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
isModEnabled($module)
Is Dolibarr module enabled.
$formconfirm
if ($action == 'delbookkeepingyear') {
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.