30 require
"../main.inc.php";
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/contract.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
36 if (!empty($conf->project->enabled)) {
37 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
41 $langs->loadLangs(array(
'other',
'products',
'contracts'));
43 $action =
GETPOST(
'action',
'alpha');
44 $confirm =
GETPOST(
'confirm',
'alpha');
49 if ($user->socid > 0) {
50 unset($_GET[
"action"]);
52 $socid = $user->socid;
57 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
58 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
59 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
61 if (empty($page) || $page == -1) {
64 $offset = $limit * $page;
65 $pageprev = $page - 1;
66 $pagenext = $page + 1;
76 $object->fetch($id, $ref);
77 if ($object->id > 0) {
78 $object->fetch_thirdparty();
81 $upload_dir = $conf->contrat->multidir_output[$object->entity].
'/'.
dol_sanitizeFileName($object->ref);
82 $modulepart =
'contract';
85 $hookmanager->initHooks(array(
'contractcard',
'globalcard'));
87 $permissiontoadd = $user->rights->contrat->creer;
94 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
103 llxHeader(
'', $langs->trans(
"Contract"),
"");
109 print
dol_get_fiche_head($head,
'documents', $langs->trans(
"Contract"), -1,
'contract');
113 $filearray =
dol_dir_list($upload_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) ==
'desc' ?SORT_DESC:SORT_ASC), 1);
115 foreach ($filearray as $key => $file) {
116 $totalsize += $file[
'size'];
122 $linkback =
'<a href="'.DOL_URL_ROOT.
'/contrat/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
127 $morehtmlref .= $object->ref;
133 $morehtmlref .=
'<div class="refidno">';
135 $morehtmlref .=
$form->editfieldkey(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, 0,
'string',
'', 0, 1);
136 $morehtmlref .=
$form->editfieldval(
"RefCustomer",
'ref_customer', $object->ref_customer, $object, 0,
'string',
'',
null,
null,
'', 1,
'getFormatedCustomerRef');
138 $morehtmlref .=
'<br>';
139 $morehtmlref .=
$form->editfieldkey(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'', 0, 1);
140 $morehtmlref .=
$form->editfieldval(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'',
null,
null,
'', 1,
'getFormatedSupplierRef');
142 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1);
143 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
144 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/contrat/list.php?socid='.$object->thirdparty->id.
'&search_name='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherContracts").
'</a>)';
147 if (!empty($conf->project->enabled)) {
148 $langs->load(
"projects");
149 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
150 if ($user->rights->contrat->creer) {
151 if ($action !=
'classify') {
153 $morehtmlref .=
' : ';
155 if ($action ==
'classify') {
157 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
158 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
159 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
160 $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
161 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
162 $morehtmlref .=
'</form>';
164 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->thirdparty->id, $object->fk_project,
'none', 0, 0, 0, 1);
167 if (!empty($object->fk_project)) {
169 $proj->fetch($object->fk_project);
170 $morehtmlref .=
' : '.$proj->getNomUrl(1);
172 $morehtmlref .=
' - '.$proj->title;
179 $morehtmlref .=
'</div>';
182 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'none', $morehtmlref);
185 print
'<div class="fichecenter">';
186 print
'<div class="underbanner clearboth"></div>';
188 print
'<table class="border tableforfield centpercent">';
189 print
'<tr><td class="titlefield">'.$langs->trans(
"NbOfAttachedFiles").
'</td><td colspan="3">'.count($filearray).
'</td></tr>';
190 print
'<tr><td>'.$langs->trans(
"TotalSizeOfAttachedFiles").
'</td><td colspan="3">'.
dol_print_size($totalsize, 1, 1).
'</td></tr>';
197 $modulepart =
'contract';
198 $permissiontoadd = $user->rights->contrat->creer;
199 $permtoedit = $user->rights->contrat->creer;
200 $param =
'&id='.$object->id;
201 include DOL_DOCUMENT_ROOT.
'/core/tpl/document_actions_post_headers.tpl.php';
203 print $langs->trans(
"ErrorUnknown");