28 if (!$res && !empty(
$_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) $res = @include
$_SERVER[
"CONTEXT_DOCUMENT_ROOT"].
"/main.inc.php";
30 $tmp = empty(
$_SERVER[
'SCRIPT_FILENAME']) ?
'' :
$_SERVER[
'SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
31 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
32 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)).
"/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1)).
"/main.inc.php";
33 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";
35 if (!$res && file_exists(
"../main.inc.php")) $res = @include
"../main.inc.php";
36 if (!$res && file_exists(
"../../main.inc.php")) $res = @include
"../../main.inc.php";
37 if (!$res && file_exists(
"../../../main.inc.php")) $res = @include
"../../../main.inc.php";
38 if (!$res) die(
"Include of main fails");
40 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
46 $langs->loadLangs(array(
"mymodule@mymodule",
"companies",
"other",
"mails"));
50 $lineid =
GETPOST(
'lineid',
'int');
51 $socid =
GETPOST(
'socid',
'int');
52 $action =
GETPOST(
'action',
'aZ09');
57 $diroutputmassaction = $conf->mymodule->dir_output.
'/temp/massgeneration/'.$user->id;
58 $hookmanager->initHooks(array(
'myobjectcontact',
'globalcard'));
60 $extrafields->fetch_name_optionals_label($object->table_element);
63 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
70 $permission = $user->rights->mymodule->myobject->write;
76 if ($action ==
'addcontact' && $permission)
80 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
84 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
87 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS')
89 $langs->load(
"errors");
90 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"), null,
'errors');
96 elseif ($action ==
'swapstatut' && $permission)
98 $result = $object->swapContactStatus(
GETPOST(
'ligne'));
100 elseif ($action ==
'deletecontact' && $permission)
102 $result = $object->delete_contact($lineid);
106 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
118 $title = $langs->trans(
'MyObject').
" - ".$langs->trans(
'ContactsAddresses');
123 $form =
new Form($db);
125 $contactstatic =
new Contact($db);
126 $userstatic =
new User($db);
144 $linkback =
'<a href="'.dol_buildpath(
'/mymodule/myobject_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
146 $morehtmlref =
'<div class="refidno">';
184 $morehtmlref .=
'</div>';
186 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0,
'',
'', 1);
193 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array(
'/core/tpl'));
194 foreach ($dirtpls as $reldir)
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.
Class to manage Dolibarr users.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
myobjectPrepareHead($object)
Prepare array of tabs for MyObject.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
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.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.