2013-01-24 12:47:06 +01:00
|
|
|
<?php
|
|
|
|
|
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
|
|
|
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
|
|
|
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
2018-10-27 14:43:12 +02:00
|
|
|
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
|
2013-01-24 12:47:06 +01:00
|
|
|
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
|
|
|
|
|
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
|
2013-07-25 18:35:48 +02:00
|
|
|
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
2013-01-24 12:47:06 +01:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2019-09-23 21:55:30 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2013-01-24 12:47:06 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \file htdocs/compta/deplacement/document.php
|
|
|
|
|
* \ingroup deplacement
|
|
|
|
|
* \brief Page of linked files onto trip and expenses
|
|
|
|
|
*/
|
|
|
|
|
|
2022-09-07 20:08:59 +02:00
|
|
|
// Load Dolibarr environment
|
2013-01-24 12:47:06 +01:00
|
|
|
require '../../main.inc.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/trip.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
|
|
|
|
|
2018-05-27 09:27:09 +02:00
|
|
|
// Load translation files required by the page
|
|
|
|
|
$langs->loadLangs(array('other', 'trips', 'companies', 'interventions'));
|
2013-01-24 12:47:06 +01:00
|
|
|
|
2019-01-27 11:55:16 +01:00
|
|
|
$id = GETPOST('id', 'int');
|
2013-01-24 12:47:06 +01:00
|
|
|
$ref = GETPOST('ref', 'alpha');
|
2020-09-16 19:39:50 +02:00
|
|
|
$action = GETPOST('action', 'aZ09');
|
2019-01-27 11:55:16 +01:00
|
|
|
$confirm = GETPOST('confirm', 'alpha');
|
2013-01-24 12:47:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get parameters
|
2020-04-20 15:06:27 +02:00
|
|
|
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
2020-09-18 17:13:01 +02:00
|
|
|
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
2020-09-17 14:31:25 +02:00
|
|
|
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
2020-03-13 13:07:11 +01:00
|
|
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
2021-02-23 21:09:01 +01:00
|
|
|
if (empty($page) || $page == -1) {
|
|
|
|
|
$page = 0;
|
|
|
|
|
} // If $page is not defined, or '' or -1
|
2020-04-20 15:06:27 +02:00
|
|
|
$offset = $limit * $page;
|
2013-01-24 12:47:06 +01:00
|
|
|
$pageprev = $page - 1;
|
|
|
|
|
$pagenext = $page + 1;
|
2021-02-23 21:09:01 +01:00
|
|
|
if (!$sortorder) {
|
|
|
|
|
$sortorder = "ASC";
|
|
|
|
|
}
|
|
|
|
|
if (!$sortfield) {
|
|
|
|
|
$sortfield = "name";
|
|
|
|
|
}
|
2013-01-24 12:47:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
$object = new Deplacement($db);
|
|
|
|
|
$object->fetch($id, $ref);
|
|
|
|
|
|
|
|
|
|
$upload_dir = $conf->deplacement->dir_output.'/'.dol_sanitizeFileName($object->ref);
|
2019-11-13 19:37:08 +01:00
|
|
|
$modulepart = 'trip';
|
2013-01-24 12:47:06 +01:00
|
|
|
|
2021-10-25 15:32:10 +02:00
|
|
|
// Security check
|
|
|
|
|
if ($user->socid) {
|
|
|
|
|
$socid = $user->socid;
|
|
|
|
|
}
|
|
|
|
|
$result = restrictedArea($user, 'deplacement', $id, '');
|
|
|
|
|
|
|
|
|
|
$permissiontoadd = $user->rights->deplacement->creer; // Used by the include of actions_dellink.inc.php
|
|
|
|
|
|
2013-01-24 12:47:06 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Actions
|
|
|
|
|
*/
|
|
|
|
|
|
2021-02-19 16:10:19 +01:00
|
|
|
include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
|
2013-01-24 12:47:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* View
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$form = new Form($db);
|
|
|
|
|
|
2019-01-27 11:55:16 +01:00
|
|
|
llxHeader("", "", $langs->trans("TripCard"));
|
2013-01-24 12:47:06 +01:00
|
|
|
|
|
|
|
|
|
2021-02-23 21:09:01 +01:00
|
|
|
if ($object->id) {
|
2013-01-24 12:47:06 +01:00
|
|
|
$object->fetch_thirdparty();
|
|
|
|
|
|
2019-11-13 19:37:08 +01:00
|
|
|
$head = trip_prepare_head($object);
|
2013-01-24 12:47:06 +01:00
|
|
|
|
2020-10-22 22:50:03 +02:00
|
|
|
print dol_get_fiche_head($head, 'documents', $langs->trans("TripCard"), 0, 'trip');
|
2013-01-24 12:47:06 +01:00
|
|
|
|
|
|
|
|
|
2018-08-04 14:17:51 +02:00
|
|
|
// Build file list
|
2019-11-13 19:37:08 +01:00
|
|
|
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
|
|
|
|
|
$totalsize = 0;
|
2021-02-23 21:09:01 +01:00
|
|
|
foreach ($filearray as $key => $file) {
|
2019-11-13 19:37:08 +01:00
|
|
|
$totalsize += $file['size'];
|
2013-01-24 12:47:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
print '<table class="border tableforfield centpercent">';
|
2013-01-24 12:47:06 +01:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/deplacement/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
|
2013-01-24 12:47:06 +01:00
|
|
|
|
|
|
|
|
// Ref
|
|
|
|
|
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
|
2016-03-25 15:53:44 +01:00
|
|
|
print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', '');
|
2013-01-24 12:47:06 +01:00
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
|
|
|
// Societe
|
|
|
|
|
//print "<tr><td>".$langs->trans("Company")."</td><td>".$object->client->getNomUrl(1)."</td></tr>";
|
|
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
|
|
|
|
|
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
|
|
|
|
|
print '</table>';
|
2013-01-24 12:47:06 +01:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
print '</div>';
|
2013-01-24 12:47:06 +01:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
$modulepart = 'deplacement';
|
2021-06-08 16:19:21 +02:00
|
|
|
$permissiontoadd = $user->rights->deplacement->creer;
|
2020-10-31 14:32:18 +01:00
|
|
|
$param = '&id='.$object->id;
|
2021-04-12 21:25:58 +02:00
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
|
2020-05-21 15:05:19 +02:00
|
|
|
} else {
|
2014-03-10 19:36:32 +01:00
|
|
|
print $langs->trans("ErrorUnknown");
|
2013-01-24 12:47:06 +01:00
|
|
|
}
|
|
|
|
|
|
2018-07-30 17:28:44 +02:00
|
|
|
// End of page
|
2013-01-24 12:47:06 +01:00
|
|
|
llxFooter();
|
|
|
|
|
$db->close();
|