52if (!$res && !empty($_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) {
53 $res = @include str_replace(
"..",
"", $_SERVER[
"CONTEXT_DOCUMENT_ROOT"]).
"/main.inc.php";
56$tmp = empty($_SERVER[
'SCRIPT_FILENAME']) ?
'' : $_SERVER[
'SCRIPT_FILENAME'];
57$tmp2 = realpath(__FILE__);
59$j = strlen($tmp2) - 1;
60while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
64if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)).
"/main.inc.php")) {
65 $res = @include substr($tmp, 0, ($i + 1)).
"/main.inc.php";
67if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php")) {
68 $res = @include dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php";
71if (!$res && file_exists(
"../main.inc.php")) {
72 $res = @include
"../main.inc.php";
74if (!$res && file_exists(
"../../main.inc.php")) {
75 $res = @include
"../../main.inc.php";
77if (!$res && file_exists(
"../../../main.inc.php")) {
78 $res = @include
"../../../main.inc.php";
81 die(
"Include of main fails");
92include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
93include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
94include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
99$langs->loadLangs(array(
"mymodule@mymodule",
"other"));
107$action =
GETPOST(
'action',
'aZ09');
108$confirm =
GETPOST(
'confirm',
'alpha');
111$backtopage =
GETPOST(
'backtopage',
'alpha');
112$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
113$optioncss =
GETPOST(
'optioncss',
'aZ');
114$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
119$diroutputmassaction = $conf->mymodule->dir_output.
'/temp/massgeneration/'.$user->id;
120$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
124$extrafields->fetch_name_optionals_label(
$object->table_element);
127$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
130$search_all = trim(
GETPOST(
"search_all",
'alpha'));
132foreach (
$object->fields as $key => $val) {
133 if (
GETPOST(
'search_'.$key,
'alpha')) {
134 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
138if (empty($action) && empty($id) && empty($ref)) {
143include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
147$enablepermissioncheck =
getDolGlobalInt(
'MYMODULE_ENABLE_PERMISSION_CHECK');
148if ($enablepermissioncheck) {
149 $permissiontoread = $user->hasRight(
'mymodule',
'myobject',
'read');
150 $permissiontoadd = $user->hasRight(
'mymodule',
'myobject',
'write');
151 $permissiontodelete = $user->hasRight(
'mymodule',
'myobject',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
152 $permissionnote = $user->hasRight(
'mymodule',
'myobject',
'write');
153 $permissiondellink = $user->hasRight(
'mymodule',
'myobject',
'write');
155 $permissiontoread = 1;
156 $permissiontoadd = 1;
157 $permissiontodelete = 1;
159 $permissiondellink = 1;
162$upload_dir = $conf->mymodule->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/myobject';
172if (!$permissiontoread) {
183$parameters = array();
184$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
189if (empty($reshook)) {
190 $backurlforlist =
dol_buildpath(
'/mymodule/myobject_list.php', 1);
192 if (empty($backtopage) || ($cancel && empty($id))) {
193 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
194 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
195 $backtopage = $backurlforlist;
197 $backtopage =
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
202 $triggermodname =
$object->TRIGGER_PREFIX.
'_MODIFY';
205 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
208 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
211 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
217 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
230 $triggersendname =
'MYMODULE_MYOBJECT_SENTBYMAIL';
231 $autocopy =
'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
232 $trackid =
'myobject'.$object->id;
233 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
242$form =
new Form($db);
245$title = $langs->trans(
"MyObject").
" - ".$langs->trans(
'Card');
247if ($action ==
'create') {
248 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"MyObject"));
252llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-mymodule page-card');
271if ($action ==
'create') {
272 if (empty($permissiontoadd)) {
278 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
279 print
'<input type="hidden" name="token" value="'.newToken().
'">';
280 print
'<input type="hidden" name="action" value="add">';
282 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
284 if ($backtopageforcancel) {
285 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
287 if ($dol_openinpopup) {
288 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
294 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
297 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
300 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
302 print
'</table>'.
"\n";
306 print $form->buttonsSaveCancel(
"Create");
314if (($id || $ref) && $action ==
'edit') {
317 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
318 print
'<input type="hidden" name="token" value="'.newToken().
'">';
319 print
'<input type="hidden" name="action" value="update">';
320 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
322 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
324 if ($backtopageforcancel) {
325 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
330 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
333 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
336 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
342 print $form->buttonsSaveCancel();
348if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
351 print
dol_get_fiche_head($head,
'card', $langs->trans(
"MyObject"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
356 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
357 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMyObject'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
360 if ($action ==
'deleteline') {
361 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
365 if ($action ==
'clone') {
367 $formquestion = array();
368 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
395 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
396 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
397 if (empty($reshook)) {
398 $formconfirm .= $hookmanager->resPrint;
399 } elseif ($reshook > 0) {
400 $formconfirm = $hookmanager->resPrint;
409 $linkback =
'<a href="'.dol_buildpath(
'/mymodule/myobject_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
411 $morehtmlref =
'<div class="refidno">';
443 $morehtmlref .=
'</div>';
446 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
449 print
'<div class="fichecenter">';
450 print
'<div class="fichehalfleft">';
451 print
'<div class="underbanner clearboth"></div>';
452 print
'<table class="border centpercent tableforfield">'.
"\n";
458 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
461 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
467 print
'<div class="clearboth"></div>';
476 if (!empty(
$object->table_element_line)) {
478 $result =
$object->getLinesArray();
480 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
481 <input type="hidden" name="token" value="' .
newToken().
'">
482 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
483 <input type="hidden" name="mode" value="">
484 <input type="hidden" name="page_y" value="">
485 <input type="hidden" name="id" value="' .
$object->id.
'">
488 if (!empty($conf->use_javascript_ajax) &&
$object->status == 0) {
489 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
492 print
'<div class="div-table-responsive-no-min">';
493 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
494 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
502 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
503 if ($action !=
'editline') {
506 $parameters = array();
507 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
511 if (empty($reshook)) {
517 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
528 if ($action !=
'presend' && $action !=
'editline') {
529 print
'<div class="tabsAction">'.
"\n";
530 $parameters = array();
531 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
536 if (empty($reshook)) {
538 if (empty($user->socid)) {
539 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle');
543 if (
$object->status == $object::STATUS_VALIDATED) {
544 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
548 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
551 if (
$object->status == $object::STATUS_DRAFT) {
553 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
555 $langs->load(
"errors");
556 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
561 if ($permissiontoadd) {
562 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
584 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken();
585 $buttonId =
'action-delete-no-ajax';
586 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
588 $buttonId =
'action-delete';
591 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
598 if (
GETPOST(
'modelselected')) {
602 if ($action !=
'presend') {
603 print
'<div class="fichecenter"><div class="fichehalfleft">';
604 print
'<a name="builddoc"></a>';
606 $includedocgeneration = 0;
609 if ($includedocgeneration) {
611 $relativepath = $objref.
'/'.$objref.
'.pdf';
612 $filedir = $conf->mymodule->dir_output.
'/'.
$object->element.
'/'.$objref;
613 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
614 $genallowed = $permissiontoread;
615 $delallowed = $permissiontoadd;
616 print $formfile->showdocuments(
'mymodule:MyObject',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
620 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'myobject'), 1);
621 if (is_array($tmparray)) {
622 $linktoelem = $tmparray[
'linktoelem'];
623 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
624 print $htmltoenteralink;
625 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
628 $somethingshown = $form->showLinkedObjectBlock($object, $tmparray);
631 print
'</div><div class="fichehalfright">';
637 $includeeventlist = 0;
640 if ($includeeventlist) {
641 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
643 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
646 print
'</div></div>';
650 if (
GETPOST(
'modelselected')) {
655 $modelmail =
'myobject';
656 $defaulttopic =
'InformationMessage';
657 $diroutput = $conf->mymodule->dir_output;
658 $trackid =
'myobject'.$object->id;
660 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
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, $morecssdiv='')
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
getDolDefaultContextPage($s)
Return the default context page string.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
isModEnabled($module)
Is Dolibarr module enabled.
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.