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>
|
2011-07-05 19:21:19 +02:00
|
|
|
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
2010-06-30 17:39:47 +02:00
|
|
|
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
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 2 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
|
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
|
|
|
*/
|
2004-09-14 19:28:37 +02:00
|
|
|
|
2005-04-11 19:40:57 +02:00
|
|
|
/**
|
2008-05-04 17:26:01 +02:00
|
|
|
* \file htdocs/societe/document.php
|
2008-05-04 17:19:02 +02:00
|
|
|
* \brief Tab for documents linked to third party
|
|
|
|
|
* \ingroup societe
|
2009-05-06 15:39:43 +02:00
|
|
|
*/
|
2004-09-14 19:28:37 +02:00
|
|
|
|
2010-03-01 09:28:29 +01:00
|
|
|
require("../main.inc.php");
|
2006-04-09 00:47:51 +02:00
|
|
|
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
|
2008-05-04 17:19:02 +02:00
|
|
|
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
2011-02-07 15:23:57 +01:00
|
|
|
require_once(DOL_DOCUMENT_ROOT."/lib/images.lib.php");
|
2010-05-03 10:43:32 +02:00
|
|
|
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
|
2004-02-08 12:50:05 +01:00
|
|
|
|
2004-11-12 01:50:14 +01:00
|
|
|
$langs->load("companies");
|
2006-01-21 20:47:43 +01:00
|
|
|
$langs->load('other');
|
2004-11-12 01:50:14 +01:00
|
|
|
|
2011-07-05 18:10:56 +02:00
|
|
|
$mesg='';
|
|
|
|
|
|
|
|
|
|
$action = GETPOST('action');
|
|
|
|
|
$confirm = GETPOST('confirm');
|
|
|
|
|
$socid = (GETPOST('socid') ? GETPOST('socid') : GETPOST('id'));
|
2006-03-10 18:32:47 +01:00
|
|
|
|
2008-05-04 17:19:02 +02:00
|
|
|
// Security check
|
2009-03-03 01:12:56 +01:00
|
|
|
if ($user->societe_id > 0)
|
2008-05-04 17:19:02 +02:00
|
|
|
{
|
|
|
|
|
unset($_GET["action"]);
|
2009-03-03 01:12:56 +01:00
|
|
|
$action='';
|
2008-05-04 17:19:02 +02:00
|
|
|
$socid = $user->societe_id;
|
|
|
|
|
}
|
|
|
|
|
$result = restrictedArea($user, 'societe', $socid);
|
|
|
|
|
|
|
|
|
|
// 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;
|
2008-05-04 17:19:02 +02:00
|
|
|
$pageprev = $page - 1;
|
|
|
|
|
$pagenext = $page + 1;
|
2007-11-11 16:55:45 +01:00
|
|
|
if (! $sortorder) $sortorder="ASC";
|
|
|
|
|
if (! $sortfield) $sortfield="name";
|
2004-02-08 12:50:05 +01:00
|
|
|
|
2008-07-10 19:11:04 +02:00
|
|
|
$upload_dir = $conf->societe->dir_output . "/" . $socid ;
|
|
|
|
|
$courrier_dir = $conf->societe->dir_output . "/courrier/" . get_exdir($socid) ;
|
|
|
|
|
|
2011-07-03 10:55:46 +02:00
|
|
|
$object = new Societe($db);
|
2004-12-05 00:24:25 +01:00
|
|
|
|
2004-12-25 21:23:24 +01:00
|
|
|
/*
|
2006-01-21 20:47:43 +01:00
|
|
|
* Actions
|
2004-12-25 21:23:24 +01:00
|
|
|
*/
|
2006-03-23 18:41:17 +01:00
|
|
|
|
2011-07-06 20:20:49 +02:00
|
|
|
// Post file
|
2008-11-28 00:02:49 +01:00
|
|
|
if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
2004-02-08 12:50:05 +01:00
|
|
|
{
|
2011-07-05 18:10:56 +02:00
|
|
|
if ($object->fetch($socid))
|
2009-05-06 15:39:43 +02:00
|
|
|
{
|
2011-07-05 18:10:56 +02:00
|
|
|
if (create_exdir($upload_dir) >= 0)
|
2009-05-06 15:39:43 +02:00
|
|
|
{
|
2011-07-05 18:10:56 +02:00
|
|
|
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
|
|
|
|
|
if (is_numeric($resupload) && $resupload > 0)
|
2010-05-01 16:28:48 +02:00
|
|
|
{
|
2011-07-05 18:10:56 +02:00
|
|
|
if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1)
|
|
|
|
|
{
|
|
|
|
|
// Create small thumbs for company (Ratio is near 16/9)
|
|
|
|
|
// Used on logon for example
|
|
|
|
|
$imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs");
|
2011-07-06 00:40:35 +02:00
|
|
|
|
2011-07-05 18:10:56 +02:00
|
|
|
// Create mini thumbs for company (Ratio is near 16/9)
|
|
|
|
|
// Used on menu or for setup page for example
|
|
|
|
|
$imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs");
|
|
|
|
|
}
|
|
|
|
|
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
|
2010-05-01 16:28:48 +02:00
|
|
|
}
|
2011-07-05 18:10:56 +02:00
|
|
|
else
|
2010-05-01 16:28:48 +02:00
|
|
|
{
|
2011-07-05 18:10:56 +02:00
|
|
|
$langs->load("errors");
|
|
|
|
|
if (is_numeric($resupload) && $resupload < 0) // Unknown error
|
|
|
|
|
{
|
|
|
|
|
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
|
|
|
|
|
}
|
|
|
|
|
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
|
|
|
|
|
{
|
|
|
|
|
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
|
|
|
|
|
}
|
|
|
|
|
else // Known error
|
|
|
|
|
{
|
|
|
|
|
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
|
|
|
|
|
}
|
2010-05-01 16:28:48 +02:00
|
|
|
}
|
2009-05-06 15:39:43 +02:00
|
|
|
}
|
|
|
|
|
}
|
2004-02-08 12:50:05 +01:00
|
|
|
}
|
|
|
|
|
|
2011-07-06 20:20:49 +02:00
|
|
|
// Delete file
|
2011-07-05 18:10:56 +02:00
|
|
|
if ($action == 'confirm_deletefile' && $confirm == 'yes')
|
2004-02-08 12:50:05 +01:00
|
|
|
{
|
2011-07-05 18:10:56 +02:00
|
|
|
if ($object->fetch($socid))
|
|
|
|
|
{
|
|
|
|
|
$file = $upload_dir . "/" . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
2011-07-14 07:21:52 +02:00
|
|
|
dol_delete_file($file,0,0,0,'FILE_DELETE',$object);
|
2011-07-05 18:10:56 +02:00
|
|
|
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
|
|
|
|
|
}
|
2004-02-08 12:50:05 +01:00
|
|
|
}
|
|
|
|
|
|
2008-02-24 15:41:07 +01:00
|
|
|
|
2004-02-08 12:50:05 +01:00
|
|
|
/*
|
2009-05-06 15:39:43 +02: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);
|
2006-01-21 20:47:43 +01:00
|
|
|
|
2004-02-08 12:50:05 +01:00
|
|
|
if ($socid > 0)
|
|
|
|
|
{
|
2011-07-03 10:55:46 +02:00
|
|
|
if ($object->fetch($socid))
|
2007-02-22 22:16:31 +01:00
|
|
|
{
|
|
|
|
|
/*
|
2009-05-06 15:39:43 +02:00
|
|
|
* Affichage onglets
|
|
|
|
|
*/
|
2010-06-30 17:39:47 +02:00
|
|
|
if ($conf->notification->enabled) $langs->load("mails");
|
2011-07-03 10:55:46 +02:00
|
|
|
$head = societe_prepare_head($object);
|
2009-03-03 01:12:56 +01:00
|
|
|
|
2007-03-07 13:55:56 +01:00
|
|
|
$html=new Form($db);
|
2009-03-03 01:12:56 +01:00
|
|
|
|
2009-08-05 19:19:55 +02:00
|
|
|
dol_fiche_head($head, 'document', $langs->trans("ThirdParty"),0,'company');
|
2009-03-03 01:12:56 +01:00
|
|
|
|
2008-05-04 17:19:02 +02:00
|
|
|
|
2007-02-22 22:16:31 +01:00
|
|
|
// Construit liste des fichiers
|
2011-07-06 22:56:48 +02:00
|
|
|
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
|
2007-02-22 22:16:31 +01:00
|
|
|
$totalsize=0;
|
2008-05-04 17:19:02 +02:00
|
|
|
foreach($filearray as $key => $file)
|
2007-02-22 22:16:31 +01:00
|
|
|
{
|
2008-05-04 17:19:02 +02:00
|
|
|
$totalsize+=$file['size'];
|
2007-02-22 22:16:31 +01:00
|
|
|
}
|
2009-03-03 01:12:56 +01:00
|
|
|
|
|
|
|
|
|
2007-02-22 22:16:31 +01:00
|
|
|
print '<table class="border"width="100%">';
|
2009-03-03 01:12:56 +01:00
|
|
|
|
2007-02-22 22:16:31 +01:00
|
|
|
// Ref
|
2011-04-22 00:27:02 +02:00
|
|
|
print '<tr><td width="30%">'.$langs->trans("ThirdPartyName").'</td>';
|
2009-06-30 02:01:47 +02:00
|
|
|
print '<td colspan="3">';
|
2011-07-03 10:55:46 +02:00
|
|
|
print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom');
|
2009-06-30 02:01:47 +02:00
|
|
|
print '</td></tr>';
|
2007-02-22 22:16:31 +01:00
|
|
|
|
|
|
|
|
// Prefix
|
2011-01-29 17:25:01 +01:00
|
|
|
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
|
|
|
|
|
{
|
2011-07-03 10:55:46 +02:00
|
|
|
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
|
2011-01-29 17:25:01 +01:00
|
|
|
}
|
2009-03-03 01:12:56 +01:00
|
|
|
|
2011-07-03 10:55:46 +02:00
|
|
|
if ($object->client)
|
2009-06-30 02:01:47 +02:00
|
|
|
{
|
|
|
|
|
print '<tr><td>';
|
|
|
|
|
print $langs->trans('CustomerCode').'</td><td colspan="3">';
|
2011-07-03 10:55:46 +02:00
|
|
|
print $object->code_client;
|
|
|
|
|
if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
|
2009-06-30 02:01:47 +02:00
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-03 10:55:46 +02:00
|
|
|
if ($object->fournisseur)
|
2009-06-30 02:01:47 +02:00
|
|
|
{
|
|
|
|
|
print '<tr><td>';
|
|
|
|
|
print $langs->trans('SupplierCode').'</td><td colspan="3">';
|
2011-07-03 10:55:46 +02:00
|
|
|
print $object->code_fournisseur;
|
|
|
|
|
if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
|
2009-06-30 02:01:47 +02:00
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Nbre fichiers
|
2007-02-22 22:16:31 +01:00
|
|
|
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.sizeof($filearray).'</td></tr>';
|
2009-03-03 01:12:56 +01:00
|
|
|
|
2007-02-22 22:16:31 +01:00
|
|
|
//Total taille
|
|
|
|
|
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
|
2009-03-03 01:12:56 +01:00
|
|
|
|
2007-02-22 22:16:31 +01:00
|
|
|
print '</table>';
|
2009-03-03 01:12:56 +01:00
|
|
|
|
2007-02-22 22:16:31 +01:00
|
|
|
print '</div>';
|
2009-03-03 01:12:56 +01:00
|
|
|
|
2011-07-03 10:55:46 +02:00
|
|
|
dol_htmloutput_mesg($mesg,$mesgs);
|
2009-03-03 01:12:56 +01:00
|
|
|
|
2009-05-06 15:39:43 +02:00
|
|
|
/*
|
2009-05-06 18:27:45 +02:00
|
|
|
* Confirmation suppression fichier
|
2009-05-06 15:39:43 +02:00
|
|
|
*/
|
2011-07-05 18:10:56 +02:00
|
|
|
if ($action == 'delete')
|
2009-05-06 15:39:43 +02:00
|
|
|
{
|
2011-07-05 18:10:56 +02:00
|
|
|
$ret=$html->form_confirm($_SERVER["PHP_SELF"].'?socid='.$socid.'&urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
|
2009-05-06 15:39:43 +02:00
|
|
|
if ($ret == 'html') print '<br>';
|
|
|
|
|
}
|
2011-07-06 00:40:35 +02:00
|
|
|
|
2009-05-06 15:39:43 +02:00
|
|
|
$formfile=new FormFile($db);
|
2011-07-06 00:40:35 +02:00
|
|
|
|
|
|
|
|
// Show upload form
|
2011-07-05 19:21:19 +02:00
|
|
|
if ($conf->global->MAIN_USE_JQUERY_FILEUPLOAD)
|
2011-07-03 15:16:46 +02:00
|
|
|
{
|
|
|
|
|
$formfile->form_ajaxfileupload($object);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?socid='.$socid,'',0,0,$user->rights->societe->creer);
|
2011-07-06 00:40:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// List of document
|
|
|
|
|
$param='&socid='.$object->id;
|
|
|
|
|
$formfile->list_of_documents($filearray,$object,'societe',$param);
|
2009-03-03 01:12:56 +01:00
|
|
|
|
2007-11-11 16:55:45 +01:00
|
|
|
print "<br><br>";
|
2007-02-22 22:16:31 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-02-20 23:53:15 +01:00
|
|
|
dol_print_error($db);
|
2007-02-22 22:16:31 +01:00
|
|
|
}
|
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
|
|
|
|
2004-02-08 12:50:05 +01:00
|
|
|
$db->close();
|
|
|
|
|
|
2005-06-11 14:11:28 +02:00
|
|
|
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
2005-06-11 14:11:28 +02:00
|
|
|
|
2004-02-08 12:50:05 +01:00
|
|
|
?>
|