52if (!$res && !empty($_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) {
53 $res = @include $_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");
84require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
85require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
86require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
100$langs->loadLangs(array(
"mymodule@mymodule",
"other"));
107$action =
GETPOST(
'action',
'aZ09');
108$confirm =
GETPOST(
'confirm',
'alpha');
109$cancel =
GETPOST(
'cancel',
'aZ09');
110$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
111$backtopage =
GETPOST(
'backtopage',
'alpha');
112$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
113$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
114$optioncss =
GETPOST(
'optioncss',
'aZ');
115$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
117if (!empty($backtopagejsfields)) {
118 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
119 $dol_openinpopup = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpbacktopagejsfields[0]);
125$diroutputmassaction =
$conf->mymodule->dir_output.
'/temp/massgeneration/'.$user->id;
126$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
130$extrafields->fetch_name_optionals_label(
$object->table_element);
133$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
136$search_all = trim(
GETPOST(
"search_all",
'alpha'));
138foreach (
$object->fields as $key => $val) {
139 if (
GETPOST(
'search_'.$key,
'alpha')) {
140 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
144if (empty($action) && empty($id) && empty($ref)) {
149include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
153$enablepermissioncheck =
getDolGlobalInt(
'MYMODULE_ENABLE_PERMISSION_CHECK');
154if ($enablepermissioncheck) {
155 $permissiontoread = $user->hasRight(
'mymodule',
'myobject',
'read');
156 $permissiontoadd = $user->hasRight(
'mymodule',
'myobject',
'write');
157 $permissiontodelete = $user->hasRight(
'mymodule',
'myobject',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
158 $permissionnote = $user->hasRight(
'mymodule',
'myobject',
'write');
159 $permissiondellink = $user->hasRight(
'mymodule',
'myobject',
'write');
161 $permissiontoread = 1;
162 $permissiontoadd = 1;
163 $permissiontodelete = 1;
165 $permissiondellink = 1;
168$upload_dir =
$conf->mymodule->multidir_output[isset(
$object->entity) ?
$object->entity : 1].
'/myobject';
175if (!isModEnabled(
$object->module)) {
178if (!$permissiontoread) {
189$parameters = array();
190$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
195if (empty($reshook)) {
196 $backurlforlist =
dol_buildpath(
'/mymodule/myobject_list.php', 1);
198 if (empty($backtopage) || ($cancel && empty($id))) {
199 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
200 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
201 $backtopage = $backurlforlist;
203 $backtopage =
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
208 $triggermodname =
'MYMODULE_MYOBJECT_MODIFY';
211 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
214 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
217 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
223 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
225 if ($action ==
'set_thirdparty' && $permissiontoadd) {
226 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
228 if ($action ==
'classin' && $permissiontoadd) {
233 $triggersendname =
'MYMODULE_MYOBJECT_SENTBYMAIL';
234 $autocopy =
'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
235 $trackid =
'myobject'.$object->id;
236 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
246$form =
new Form($db);
250$title = $langs->trans(
"MyObject").
" - ".$langs->trans(
'Card');
252if ($action ==
'create') {
253 $title = $langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"MyObject"));
257llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-mymodule page-card');
276if ($action ==
'create') {
277 if (empty($permissiontoadd)) {
283 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
284 print
'<input type="hidden" name="token" value="'.newToken().
'">';
285 print
'<input type="hidden" name="action" value="add">';
287 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
289 if ($backtopageforcancel) {
290 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
292 if ($backtopagejsfields) {
293 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
295 if ($dol_openinpopup) {
296 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
302 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
305 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
308 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
310 print
'</table>'.
"\n";
314 print $form->buttonsSaveCancel(
"Create");
322if (($id || $ref) && $action ==
'edit') {
325 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
326 print
'<input type="hidden" name="token" value="'.newToken().
'">';
327 print
'<input type="hidden" name="action" value="update">';
328 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
330 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
332 if ($backtopageforcancel) {
333 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
338 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
341 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
344 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
350 print $form->buttonsSaveCancel();
356if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
359 print
dol_get_fiche_head($head,
'card', $langs->trans(
"MyObject"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
364 if ($action ==
'delete' || (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile))) {
365 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMyObject'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
368 if ($action ==
'deleteline') {
369 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
373 if ($action ==
'clone') {
375 $formquestion = array();
376 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
380 if ($action ==
'xxx') {
381 $text = $langs->trans(
'ConfirmActionXxx',
$object->ref);
390 $formquestion = array();
402 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
406 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
407 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
408 if (empty($reshook)) {
409 $formconfirm .= $hookmanager->resPrint;
410 } elseif ($reshook > 0) {
411 $formconfirm = $hookmanager->resPrint;
420 $linkback =
'<a href="'.dol_buildpath(
'/mymodule/myobject_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
422 $morehtmlref =
'<div class="refidno">';
454 $morehtmlref .=
'</div>';
457 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
460 print
'<div class="fichecenter">';
461 print
'<div class="fichehalfleft">';
462 print
'<div class="underbanner clearboth"></div>';
463 print
'<table class="border centpercent tableforfield">'.
"\n";
469 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
472 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
478 print
'<div class="clearboth"></div>';
487 if (!empty(
$object->table_element_line)) {
489 $result =
$object->getLinesArray();
491 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
492 <input type="hidden" name="token" value="' .
newToken().
'">
493 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
494 <input type="hidden" name="mode" value="">
495 <input type="hidden" name="page_y" value="">
496 <input type="hidden" name="id" value="' .
$object->id.
'">
499 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == 0) {
500 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
503 print
'<div class="div-table-responsive-no-min">';
504 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
505 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
513 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
514 if ($action !=
'editline') {
517 $parameters = array();
518 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
522 if (empty($reshook)) {
523 $object->formAddObjectLine(1, $mysoc, $soc);
528 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
539 if ($action !=
'presend' && $action !=
'editline') {
540 print
'<div class="tabsAction">'.
"\n";
541 $parameters = array();
542 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
547 if (empty($reshook)) {
549 if (empty($user->socid)) {
550 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle');
554 if (
$object->status == $object::STATUS_VALIDATED) {
555 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
559 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
562 if (
$object->status == $object::STATUS_DRAFT) {
564 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
566 $langs->load(
"errors");
567 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
572 if ($permissiontoadd) {
573 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
595 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken();
596 $buttonId =
'action-delete-no-ajax';
597 if (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile)) {
599 $buttonId =
'action-delete';
602 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
609 if (
GETPOST(
'modelselected')) {
613 if ($action !=
'presend') {
614 print
'<div class="fichecenter"><div class="fichehalfleft">';
615 print
'<a name="builddoc"></a>';
617 $includedocgeneration = 0;
620 if ($includedocgeneration) {
622 $relativepath = $objref.
'/'.$objref.
'.pdf';
623 $filedir =
$conf->mymodule->dir_output.
'/'.
$object->element.
'/'.$objref;
624 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
625 $genallowed = $permissiontoread;
626 $delallowed = $permissiontoadd;
627 print $formfile->showdocuments(
'mymodule:MyObject',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
631 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'myobject'), 1);
632 $linktoelem = $tmparray[
'linktoelem'];
633 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
634 print $htmltoenteralink;
636 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
639 print
'</div><div class="fichehalfright">';
645 $includeeventlist = 0;
648 if ($includeeventlist) {
649 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
651 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
654 print
'</div></div>';
658 if (
GETPOST(
'modelselected')) {
663 $modelmail =
'myobject';
664 $defaulttopic =
'InformationMessage';
665 $diroutput =
$conf->mymodule->dir_output;
666 $trackid =
'myobject'.$object->id;
668 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
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.
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.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.