dolibarr/htdocs/societe/document.php

166 lines
4.7 KiB
PHP
Raw Normal View History

2004-10-20 23:06:45 +02:00
<?php
2007-01-22 16:41:57 +01:00
/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
2010-03-28 23:49:43 +02:00
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
2012-12-30 15:13:49 +01:00
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
2010-06-30 17:39:47 +02:00
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
2004-02-08 12:50:05 +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
2004-02-08 12:50:05 +01:00
* (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
2011-08-01 01:19:04 +02:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2004-02-08 12:50:05 +01:00
*/
2005-04-11 19:40:57 +02:00
/**
2008-05-04 17:26:01 +02:00
* \file htdocs/societe/document.php
* \brief Tab for documents linked to third party
* \ingroup societe
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.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/class/html.formfile.class.php';
2004-02-08 12:50:05 +01:00
$langs->load("companies");
$langs->load('other');
$action=GETPOST('action');
$confirm=GETPOST('confirm');
2012-07-02 19:30:37 +02:00
$id=(GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int'));
$ref = GETPOST('ref', 'alpha');
2006-03-10 18:32:47 +01:00
// Security check
if ($user->societe_id > 0)
{
2012-09-12 16:02:01 +02:00
unset($action);
$socid = $user->societe_id;
}
$result = restrictedArea($user, 'societe', $id, '&societe');
// Get parameters
2010-11-20 14:08:44 +01:00
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
2004-02-08 12:50:05 +01:00
2011-07-03 10:55:46 +02:00
$object = new Societe($db);
2012-07-02 19:30:37 +02:00
if ($id > 0 || ! empty($ref))
{
$result = $object->fetch($id, $ref);
2012-07-02 19:30:37 +02:00
$upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id ;
$courrier_dir = $conf->societe->multidir_output[$object->entity] . "/courrier/" . get_exdir($object->id);
}
/*
* Actions
*/
2013-09-18 16:11:36 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
2004-02-08 12:50:05 +01:00
2008-02-24 15:41:07 +01:00
2004-02-08 12:50:05 +01:00
/*
* View
*/
2004-09-14 19:22:36 +02:00
2009-06-30 02:01:47 +02:00
$form = new Form($db);
2011-05-01 20:56:41 +02:00
$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('',$langs->trans("ThirdParty").' - '.$langs->trans("Files"),$help_url);
if ($object->id)
2004-02-08 12:50:05 +01:00
{
2012-07-02 19:30:37 +02:00
/*
* Affichage onglets
2012-07-02 19:30:37 +02:00
*/
2012-09-15 10:01:35 +02:00
if (! empty($conf->notification->enabled)) $langs->load("mails");
2012-07-02 19:30:37 +02:00
$head = societe_prepare_head($object);
$form=new Form($db);
dol_fiche_head($head, 'document', $langs->trans("ThirdParty"),0,'company');
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
{
$totalsize+=$file['size'];
}
print '<table class="border"width="100%">';
// Ref
print '<tr><td width="25%">'.$langs->trans("ThirdPartyName").'</td>';
2012-07-02 19:30:37 +02:00
print '<td colspan="3">';
print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom');
print '</td></tr>';
// Prefix
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{
2012-07-02 19:30:37 +02:00
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
}
if ($object->client)
{
print '<tr><td>';
print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $object->code_client;
if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
print '</td></tr>';
}
if ($object->fournisseur)
{
print '<tr><td>';
print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $object->code_fournisseur;
if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
print '</td></tr>';
}
// Nbre fichiers
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
//Total taille
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
print '</div>';
2013-09-18 12:02:47 +02:00
$modulepart = 'societe';
$permission = $user->rights->societe->creer;
$param = '&id=' . $object->id;
2013-09-18 16:11:36 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
2004-02-08 12:50:05 +01:00
}
else
{
2011-07-03 10:55:46 +02:00
accessforbidden('',0,0);
2004-02-08 12:50:05 +01:00
}
2004-09-14 19:22:36 +02:00
llxFooter();
$db->close();
2004-02-08 12:50:05 +01:00
?>