2015-02-14 18:39:45 +01:00
< ? php
/* Copyright ( C ) 2003 - 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2015-02-21 12:57:17 +01:00
* Copyright ( C ) 2004 - 2015 Laurent Destailleur < eldy @ users . sourceforge . net >
2015-02-14 18:39:45 +01:00
* Copyright ( C ) 2005 Marc Barilley / Ocebo < marc @ ocebo . com >
* Copyright ( C ) 2005 - 2009 Regis Houssin < regis . houssin @ capnetworks . com >
* Copyright ( C ) 2005 Simon TOSSER < simon @ kornog - computing . com >
* Copyright ( C ) 2011 - 2012 Juanjo Menent < jmenent @ 2 byte . es >
* Copyright ( C ) 2013 Cédric Salvador < csalvador @ gpcsolutions . fr >
*
* 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
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2015-02-15 19:13:16 +01:00
* or see http :// www . gnu . org /
2015-02-14 18:39:45 +01:00
*/
/**
2015-02-15 22:49:23 +01:00
* \file htdocs / expensereport / document . php
2015-02-14 18:39:45 +01:00
* \ingroup expensereport
2015-02-21 12:57:17 +01:00
* \brief Page of linked files onto trip and expens reports
2015-02-14 18:39:45 +01:00
*/
require '../main.inc.php' ;
2015-02-21 12:57:17 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
2015-02-15 22:49:23 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/expensereport.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php' ;
2015-02-14 18:39:45 +01:00
2018-05-26 20:51:17 +02:00
// Load translation files required by the page
2018-04-16 19:25:27 +02:00
$langs -> loadLangs ( array ( " other " , " trips " , " companies " , " interventions " ));
2015-02-14 18:39:45 +01:00
$id = GETPOST ( 'id' , 'int' );
$ref = GETPOST ( 'ref' , 'alpha' );
$action = GETPOST ( 'action' , 'alpha' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
// Security check
if ( $user -> societe_id ) $socid = $user -> societe_id ;
2017-03-02 11:46:31 +01:00
$result = restrictedArea ( $user , 'expensereport' , $id , 'expensereport' );
2015-02-14 18:39:45 +01:00
// Get parameters
$sortfield = GETPOST ( 'sortfield' , 'alpha' );
$sortorder = GETPOST ( 'sortorder' , 'alpha' );
$page = GETPOST ( 'page' , 'int' );
2017-06-06 10:53:53 +02:00
if ( empty ( $page ) || $page == - 1 ) { $page = 0 ; } // If $page is not defined, or '' or -1
2015-02-14 18:39:45 +01:00
$offset = $conf -> liste_limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
if ( ! $sortorder ) $sortorder = " ASC " ;
2018-04-16 19:25:27 +02:00
if ( ! $sortfield ) $sortfield = " position_name " ;
2015-02-14 18:39:45 +01:00
$object = new ExpenseReport ( $db );
$object -> fetch ( $id , $ref );
$upload_dir = $conf -> expensereport -> dir_output . '/' . dol_sanitizeFileName ( $object -> ref );
$modulepart = 'trip' ;
2018-04-16 19:25:27 +02:00
// Load object
//include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
2015-02-14 18:39:45 +01:00
/*
* Actions
*/
2016-04-02 14:16:16 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php' ;
2015-02-14 18:39:45 +01:00
/*
* View
*/
$form = new Form ( $db );
2016-08-30 07:02:44 +02:00
$title = $langs -> trans ( " ExpenseReport " ) . " - " . $langs -> trans ( " Documents " );
$helpurl = " EN:Module_Expense_Reports " ;
llxHeader ( " " , $title , $helpurl );
2015-02-14 18:39:45 +01:00
if ( $object -> id )
{
$object -> fetch_thirdparty ();
2015-02-15 22:49:23 +01:00
$head = expensereport_prepare_head ( $object );
2015-02-14 18:39:45 +01:00
2017-03-21 17:56:11 +01:00
dol_fiche_head ( $head , 'documents' , $langs -> trans ( " ExpenseReport " ), - 1 , 'trip' );
2015-02-14 18:39:45 +01:00
2017-10-03 16:00:52 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/expensereport/list.php?restore_lastsearch_values=1' . ( ! empty ( $socid ) ? '&socid=' . $socid : '' ) . '">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2016-11-30 20:24:36 +01:00
$morehtmlref = '<div class="refidno">' ;
$morehtmlref .= '</div>' ;
2017-10-03 16:00:52 +02:00
2016-11-30 20:24:36 +01:00
dol_banner_tab ( $object , 'ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref );
2017-10-03 16:00:52 +02:00
2015-02-14 18:39:45 +01:00
// Construit liste des fichiers
2017-04-12 11:30:33 +02:00
$filearray = dol_dir_list ( $upload_dir , " files " , 0 , '' , '(\.meta|_preview.*\.png)$' , $sortfield ,( strtolower ( $sortorder ) == 'desc' ? SORT_DESC : SORT_ASC ), 1 );
2015-02-14 18:39:45 +01:00
$totalsize = 0 ;
foreach ( $filearray as $key => $file )
{
$totalsize += $file [ 'size' ];
}
2016-11-30 20:24:36 +01:00
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
2017-10-03 16:00:52 +02:00
2015-02-14 18:39:45 +01:00
print '<table class="border" width="100%">' ;
2015-02-21 12:57:17 +01:00
$linkback = '<a href="' . DOL_URL_ROOT . '/expensereport/list.php' . ( ! empty ( $socid ) ? '?socid=' . $socid : '' ) . '">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2015-02-14 18:39:45 +01:00
2016-11-30 20:24:36 +01:00
print '<tr><td class="titlefield">' . $langs -> trans ( " NbOfAttachedFiles " ) . '</td><td colspan="3">' . count ( $filearray ) . '</td></tr>' ;
2018-04-12 15:29:22 +02:00
print '<tr><td>' . $langs -> trans ( " TotalSizeOfAttachedFiles " ) . '</td><td colspan="3">' . dol_print_size ( $totalsize , 1 , 1 ) . '</td></tr>' ;
2015-02-14 18:39:45 +01:00
print '</table>' ;
print '</div>' ;
2016-11-30 20:24:36 +01:00
dol_fiche_end ();
2017-10-03 16:00:52 +02:00
2015-02-14 18:39:45 +01:00
$modulepart = 'expensereport' ;
$permission = $user -> rights -> expensereport -> creer ;
2016-09-07 01:54:16 +02:00
$permtoedit = $user -> rights -> expensereport -> creer ;
2015-02-14 18:39:45 +01:00
$param = '&id=' . $object -> id ;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php' ;
}
else
{
print $langs -> trans ( " ErrorUnknown " );
}
llxFooter ();
$db -> close ();