25 require
"../main.inc.php";
26 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/contract.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
30 if (!empty($conf->project->enabled)) {
31 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
36 $langs->loadLangs(array(
"companies",
"contracts"));
38 if (
GETPOST(
'actioncode',
'array')) {
39 $actioncode =
GETPOST(
'actioncode',
'array', 3);
40 if (!count($actioncode)) {
44 $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));
46 $search_agenda_label =
GETPOST(
'search_agenda_label');
48 $action =
GETPOST(
'action',
'alpha');
49 $confirm =
GETPOST(
'confirm',
'alpha');
55 $socid = $user->socid;
59 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
60 $fieldtype = (!empty($id) ?
'rowid' :
'ref');
61 $result =
restrictedArea($user,
'contrat', $fieldvalue,
'',
'',
'', $fieldtype);
63 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
64 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
65 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
67 if (empty($page) || $page == -1) {
70 $offset = $limit * $page;
71 $pageprev = $page - 1;
72 $pagenext = $page + 1;
74 $sortfield =
'a.datep,a.id';
77 $sortorder =
'DESC,DESC';
83 if ($id > 0 || !empty($ref)) {
84 $result = $object->fetch($id, $ref);
88 $hookmanager->initHooks(array(
'agendacontract',
'globalcard'));
95 $parameters = array(
'id' => $id,
'ref' => $ref);
96 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
101 if (empty($reshook)) {
103 if (
GETPOST(
'cancel',
'alpha') && !empty($backtopage)) {
104 header(
"Location: ".$backtopage);
109 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
111 $search_agenda_label =
'';
122 if (!empty($conf->project->enabled)) {
126 if ($object->id > 0) {
128 $module = (!empty($conf->global->CONTRACT_ADDON) ? $conf->global->CONTRACT_ADDON :
'mod_contract_serpis');
129 if (substr($module, 0, 13) ==
'mod_contract_' && substr($module, -3) ==
'php') {
130 $module = substr($module, 0,
dol_strlen($module) - 4);
134 $modCodeContract =
new $module();
137 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
138 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
140 $object->fetch_thirdparty();
142 $title = $langs->trans(
"Agenda");
143 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/contractrefonly/', $conf->global->MAIN_HTML_TITLE) && $object->ref) {
144 $title = $object->ref.
" - ".$title;
148 if (!empty($conf->notification->enabled)) {
149 $langs->load(
"mails");
155 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
158 if (!empty($modCodeContract->code_auto)) {
159 $morehtmlref .= $object->ref;
161 $morehtmlref .=
$form->editfieldkey(
"",
'ref', $object->ref, $object, $user->rights->contrat->creer,
'string',
'', 0, 3);
162 $morehtmlref .=
$form->editfieldval(
"",
'ref', $object->ref, $object, $user->rights->contrat->creer,
'string',
'', 0, 2);
167 $morehtmlref .=
'<div class="refidno">';
169 $morehtmlref .=
$form->editfieldkey(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, $permtoedit,
'string',
'', 0, 1);
170 $morehtmlref .=
$form->editfieldval(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, $permtoedit,
'string',
'',
null,
null,
'', 1,
'getFormatedCustomerRef');
172 $morehtmlref .=
'<br>';
173 $morehtmlref .=
$form->editfieldkey(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, $permtoedit,
'string',
'', 0, 1);
174 $morehtmlref .=
$form->editfieldval(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, $permtoedit,
'string',
'',
null,
null,
'', 1,
'getFormatedSupplierRef');
176 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1);
177 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
178 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/contrat/list.php?socid='.$object->thirdparty->id.
'&search_name='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherContracts").
'</a>)';
181 if (!empty($conf->project->enabled)) {
182 $langs->load(
"projects");
183 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
184 if ($user->rights->contrat->creer) {
185 if ($action !=
'classify') {
187 $morehtmlref .=
' : ';
189 if ($action ==
'classify') {
191 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
192 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
193 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
194 $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
195 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
196 $morehtmlref .=
'</form>';
198 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->thirdparty->id, $object->fk_project,
'none', 0, 0, 0, 1);
201 if (!empty($object->fk_project)) {
203 $proj->fetch($object->fk_project);
204 $morehtmlref .=
' : '.$proj->getNomUrl(1);
206 $morehtmlref .=
' - '.$proj->title;
213 $morehtmlref .=
'</div>';
215 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'none', $morehtmlref);
217 print
'<div class="fichecenter">';
219 print
'<div class="underbanner clearboth"></div>';
221 $object->info($object->id);
254 if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) {
255 $backtopage = $_SERVER[
'PHP_SELF'].
'?id='.$object->id;
256 $out =
'&origin='.$object->element.
'&originid='.$object->id.
'&backtopage='.urlencode($backtopage);
257 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'AddAction'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/comm/action/card.php?action=create'.$out);
261 if (
isModEnabled(
'agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
264 $param =
'&id='.$object->id;
265 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
266 $param .=
'&contextpage='.$contextpage;
268 if ($limit > 0 && $limit != $conf->liste_limit) {
269 $param .=
'&limit='.$limit;
272 print
load_fiche_titre($langs->trans(
"ActionsOnContract"), $newcardbutton,
'');
277 $filters[
'search_agenda_label'] = $search_agenda_label;
280 show_actions_done($conf, $langs, $db, $object,
null, 0, $actioncode,
'', $filters, $sortfield, $sortorder);