51if (!$res && !empty($_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) {
52 $res = @include $_SERVER[
"CONTEXT_DOCUMENT_ROOT"].
"/main.inc.php";
55$tmp = empty($_SERVER[
'SCRIPT_FILENAME']) ?
'' : $_SERVER[
'SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
56while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
60if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)).
"/main.inc.php")) {
61 $res = @include substr($tmp, 0, ($i + 1)).
"/main.inc.php";
63if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php")) {
64 $res = @include dirname(substr($tmp, 0, ($i + 1))).
"/main.inc.php";
67if (!$res && file_exists(
"../main.inc.php")) {
68 $res = @include
"../main.inc.php";
70if (!$res && file_exists(
"../../main.inc.php")) {
71 $res = @include
"../../main.inc.php";
73if (!$res && file_exists(
"../../../main.inc.php")) {
74 $res = @include
"../../../main.inc.php";
77 die(
"Include of main fails");
80require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
81require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
82require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
87$langs->loadLangs(array(
"mymodule@mymodule",
"other"));
92$lineid =
GETPOST(
'lineid',
'int');
94$action =
GETPOST(
'action',
'aZ09');
95$confirm =
GETPOST(
'confirm',
'alpha');
96$cancel =
GETPOST(
'cancel',
'aZ09');
97$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
98$backtopage =
GETPOST(
'backtopage',
'alpha');
99$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
100$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
101$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
103if (!empty($backtopagejsfields)) {
104 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
105 $dol_openinpopup = $tmpbacktopagejsfields[0];
111$diroutputmassaction = $conf->mymodule->dir_output.
'/temp/massgeneration/'.$user->id;
112$hookmanager->initHooks(array($object->element.
'card',
'globalcard'));
115$extrafields->fetch_name_optionals_label($object->table_element);
117$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
120$search_all = trim(
GETPOST(
"search_all",
'alpha'));
122foreach ($object->fields as $key => $val) {
123 if (
GETPOST(
'search_'.$key,
'alpha')) {
124 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
128if (empty($action) && empty($id) && empty($ref)) {
133include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
137$enablepermissioncheck = 0;
138if ($enablepermissioncheck) {
139 $permissiontoread = $user->hasRight(
'mymodule',
'myobject',
'read');
140 $permissiontoadd = $user->hasRight(
'mymodule',
'myobject',
'write');
141 $permissiontodelete = $user->hasRight(
'mymodule',
'myobject',
'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
142 $permissionnote = $user->hasRight(
'mymodule',
'myobject',
'write');
143 $permissiondellink = $user->hasRight(
'mymodule',
'myobject',
'write');
145 $permissiontoread = 1;
146 $permissiontoadd = 1;
147 $permissiontodelete = 1;
149 $permissiondellink = 1;
152$upload_dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object->entity : 1].
'/myobject';
159if (!isModEnabled(
"mymodule")) {
162if (!$permissiontoread) {
171$parameters = array();
172$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
177if (empty($reshook)) {
180 $backurlforlist =
dol_buildpath(
'/mymodule/myobject_list.php', 1);
182 if (empty($backtopage) || ($cancel && empty($id))) {
183 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
184 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
185 $backtopage = $backurlforlist;
187 $backtopage =
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
192 $triggermodname =
'MYMODULE_MYOBJECT_MODIFY';
195 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
198 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
201 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
207 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
209 if ($action ==
'set_thirdparty' && $permissiontoadd) {
210 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
212 if ($action ==
'classin' && $permissiontoadd) {
213 $object->setProject(
GETPOST(
'projectid',
'int'));
217 $triggersendname =
'MYMODULE_MYOBJECT_SENTBYMAIL';
218 $autocopy =
'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
219 $trackid =
'myobject'.$object->id;
220 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
230$form =
new Form($db);
234$title = $langs->trans(
"MyObject").
" - ".$langs->trans(
'Card');
236if ($action ==
'create') {
237 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"MyObject"));
241llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-mymodule page-card');
260if ($action ==
'create') {
261 if (empty($permissiontoadd)) {
267 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
268 print
'<input type="hidden" name="token" value="'.newToken().
'">';
269 print
'<input type="hidden" name="action" value="add">';
271 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
273 if ($backtopageforcancel) {
274 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
276 if ($backtopagejsfields) {
277 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
279 if ($dol_openinpopup) {
280 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
288 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
291 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
294 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
296 print
'</table>'.
"\n";
300 print $form->buttonsSaveCancel(
"Create");
308if (($id || $ref) && $action ==
'edit') {
309 print
load_fiche_titre($langs->trans(
"MyObject"),
'',
'object_'.$object->picto);
311 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
312 print
'<input type="hidden" name="token" value="'.newToken().
'">';
313 print
'<input type="hidden" name="action" value="update">';
314 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
316 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
318 if ($backtopageforcancel) {
319 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
324 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
327 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
330 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
336 print $form->buttonsSaveCancel();
342if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
345 print
dol_get_fiche_head($head,
'card', $langs->trans(
"MyObject"), -1, $object->picto, 0,
'',
'', 0,
'', 1);
350 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
351 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteMyObject'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
354 if ($action ==
'deleteline') {
355 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
359 if ($action ==
'clone') {
361 $formquestion = array();
362 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
366 if ($action ==
'xxx') {
367 $text = $langs->trans(
'ConfirmActionMyObject', $object->ref);
376 $formquestion = array();
388 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
392 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
393 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
394 if (empty($reshook)) {
395 $formconfirm .= $hookmanager->resPrint;
396 } elseif ($reshook > 0) {
397 $formconfirm = $hookmanager->resPrint;
406 $linkback =
'<a href="'.dol_buildpath(
'/mymodule/myobject_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
408 $morehtmlref =
'<div class="refidno">';
440 $morehtmlref .=
'</div>';
443 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
446 print
'<div class="fichecenter">';
447 print
'<div class="fichehalfleft">';
448 print
'<div class="underbanner clearboth"></div>';
449 print
'<table class="border centpercent tableforfield">'.
"\n";
455 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
458 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
464 print
'<div class="clearboth"></div>';
473 if (!empty($object->table_element_line)) {
475 $result = $object->getLinesArray();
477 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
478 <input type="hidden" name="token" value="' . newToken().
'">
479 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
480 <input type="hidden" name="mode" value="">
481 <input type="hidden" name="page_y" value="">
482 <input type="hidden" name="id" value="' . $object->id.
'">
485 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
486 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
489 print
'<div class="div-table-responsive-no-min">';
490 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
491 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
494 if (!empty($object->lines)) {
495 $object->printObjectLines($action, $mysoc,
null,
GETPOST(
'lineid',
'int'), 1);
499 if ($object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
500 if ($action !=
'editline') {
503 $parameters = array();
504 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
508 if (empty($reshook)) {
509 $object->formAddObjectLine(1, $mysoc, $soc);
514 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
525 if ($action !=
'presend' && $action !=
'editline') {
526 print
'<div class="tabsAction">'.
"\n";
527 $parameters = array();
528 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
533 if (empty($reshook)) {
535 if (empty($user->socid)) {
536 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=presend&token='.newToken().
'&mode=init#formmailbeforetitle');
540 if ($object->status == $object::STATUS_VALIDATED) {
541 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_setdraft&confirm=yes&token='.newToken(),
'', $permissiontoadd);
545 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.newToken(),
'', $permissiontoadd);
548 if ($object->status == $object::STATUS_DRAFT) {
549 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
550 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_validate&confirm=yes&token='.newToken(),
'', $permissiontoadd);
552 $langs->load(
"errors");
553 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
558 if ($permissiontoadd) {
559 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.(!empty($object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.newToken(),
'', $permissiontoadd);
581 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken();
582 $buttonId =
'action-delete-no-ajax';
583 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
585 $buttonId =
'action-delete';
588 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
595 if (
GETPOST(
'modelselected')) {
599 if ($action !=
'presend') {
600 print
'<div class="fichecenter"><div class="fichehalfleft">';
601 print
'<a name="builddoc"></a>';
603 $includedocgeneration = 0;
606 if ($includedocgeneration) {
608 $relativepath = $objref.
'/'.$objref.
'.pdf';
609 $filedir = $conf->mymodule->dir_output.
'/'.$object->element.
'/'.$objref;
610 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
611 $genallowed = $permissiontoread;
612 $delallowed = $permissiontoadd;
613 print $formfile->showdocuments(
'mymodule:MyObject', $object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
617 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'myobject'));
618 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
621 print
'</div><div class="fichehalfright">';
625 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dol_buildpath(
'/mymodule/myobject_agenda.php', 1).
'?id='.$object->id);
628 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
630 $somethingshown =
$formactions->showactions($object, $object->element.
'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
632 print
'</div></div>';
636 if (
GETPOST(
'modelselected')) {
641 $modelmail =
'myobject';
642 $defaulttopic =
'InformationMessage';
643 $diroutput = $conf->mymodule->dir_output;
644 $trackid =
'myobject'.$object->id;
646 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
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.
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='', $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.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
myobjectPrepareHead($object)
Prepare array of tabs for MyObject.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.