29 if (!$res && !empty($_SERVER[
"CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER[
"CONTEXT_DOCUMENT_ROOT"].
"/main.inc.php";
31 $tmp = empty($_SERVER[
'SCRIPT_FILENAME']) ?
'' : $_SERVER[
'SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
32 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
33 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)).
"/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1)).
"/main.inc.php";
34 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";
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 && file_exists(
"../../../main.inc.php")) $res = @include
"../../../main.inc.php";
39 if (!$res) die(
"Include of main fails");
41 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
44 require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransfer.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/lib/stocktransfer_stocktransfer.lib.php';
49 $langs->loadLangs(array(
"stocks",
"other"));
54 $action =
GETPOST(
'action',
'alpha');
55 $cancel =
GETPOST(
'cancel',
'aZ09');
56 $backtopage =
GETPOST(
'backtopage',
'alpha');
58 if (
GETPOST(
'actioncode',
'array')) {
59 $actioncode =
GETPOST(
'actioncode',
'array', 3);
60 if (!count($actioncode)) $actioncode =
'0';
62 $actioncode =
GETPOST(
"actioncode",
"alpha", 3) ?
GETPOST(
"actioncode",
"alpha", 3) : (
GETPOST(
"actioncode") ==
'0' ?
'0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
64 $search_agenda_label =
GETPOST(
'search_agenda_label');
66 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
67 $sortfield =
GETPOST(
"sortfield",
'alpha');
68 $sortorder =
GETPOST(
"sortorder",
'alpha');
70 if (empty($page) || $page == -1) { $page = 0; }
71 $offset = $limit * $page;
72 $pageprev = $page - 1;
73 $pagenext = $page + 1;
74 if (!$sortfield) $sortfield =
'a.datep,a.id';
75 if (!$sortorder) $sortorder =
'DESC,DESC';
80 $diroutputmassaction = $conf->stocktransfer->dir_output.
'/temp/massgeneration/'.$user->id;
81 $hookmanager->initHooks(array(
'stocktransferagenda',
'globalcard'));
83 $extrafields->fetch_name_optionals_label($object->table_element);
86 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
87 if ($id > 0 || !empty($ref)) $upload_dir = $conf->stocktransfer->multidir_output[$object->entity].
"/".$object->id;
92 $result =
restrictedArea($user,
'stocktransfer', $object->id,
'',
'stocktransfer');
94 $permissiontoadd = $user->rights->stocktransfer->stocktransfer->write;
101 $parameters = array(
'id'=>$id);
102 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
103 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
105 if (empty($reshook)) {
107 if (
GETPOST(
'cancel',
'alpha') && !empty($backtopage)) {
108 header(
"Location: ".$backtopage);
113 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
115 $search_agenda_label =
'';
127 if ($object->id > 0) {
128 $title = $langs->trans(
"Agenda");
133 if (!empty($conf->notification->enabled)) $langs->load(
"mails");
137 print
dol_get_fiche_head($head,
'agenda', $langs->trans(
"StockTransfer"), -1, $object->picto);
141 $linkback =
'<a href="'.dol_buildpath(
'/stocktransfer/stocktransfer_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
143 $morehtmlref =
'<div class="refidno">';
181 $morehtmlref .=
'</div>';
184 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
186 print
'<div class="fichecenter">';
187 print
'<div class="underbanner clearboth"></div>';
189 $object->info($object->id);
200 $objthirdparty = $object;
201 $objcon =
new stdClass();
203 $out =
'&origin='.$object->element.
'&originid='.$object->id;
204 $permok = $user->rights->agenda->myactions->create;
205 if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
207 if (get_class($objthirdparty) ==
'Societe') $out .=
'&socid='.$objthirdparty->id;
208 $out .= (!empty($objcon->id) ?
'&contactid='.$objcon->id :
'').
'&backtopage=1&percentage=-1';
215 print
'<div class="tabsAction">';
218 if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) {
219 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create'.$out.
'">'.$langs->trans(
"AddAction").
'</a>';
221 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"AddAction").
'</a>';
227 if (
isModEnabled(
'agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
228 $param =
'&id='.$object->id.
'&socid='.$socid;
229 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
230 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
237 $filters[
'search_agenda_label'] = $search_agenda_label;
241 show_actions_done($conf, $langs, $db, $object,
null, 0, $actioncode,
'', $filters, $sortfield, $sortorder,
'');