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>
|
2018-10-27 14:43:12 +02:00
|
|
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
2010-06-30 17:39:47 +02:00
|
|
|
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
2013-07-25 18:35:48 +02:00
|
|
|
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
2015-02-27 15:08:08 +01:00
|
|
|
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
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
|
2013-01-16 15:36:08 +01:00
|
|
|
* 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
|
2019-09-23 21:55:30 +02:00
|
|
|
* along with this program. If not, see <https://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
|
|
|
|
2012-08-22 23:24:21 +02:00
|
|
|
require '../main.inc.php';
|
2012-08-22 23:11:24 +02:00
|
|
|
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
|
|
|
|
2018-10-01 08:22:23 +02:00
|
|
|
$langs->loadLangs(array("companies", "other"));
|
2011-07-05 18:10:56 +02:00
|
|
|
|
2019-11-13 19:37:08 +01:00
|
|
|
$action = GETPOST('action', 'aZ09');
|
|
|
|
|
$confirm = GETPOST('confirm');
|
|
|
|
|
$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
|
2012-04-07 09:14:33 +02:00
|
|
|
$ref = GETPOST('ref', 'alpha');
|
2006-03-10 18:32:47 +01:00
|
|
|
|
2008-05-04 17:19:02 +02:00
|
|
|
// Get parameters
|
2020-04-20 15:06:27 +02:00
|
|
|
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
2019-01-27 11:55:16 +01:00
|
|
|
$sortfield = GETPOST("sortfield", 'alpha');
|
|
|
|
|
$sortorder = GETPOST("sortorder", 'alpha');
|
2020-03-13 13:07:11 +01:00
|
|
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
2021-02-26 21:17:52 +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;
|
2008-05-04 17:19:02 +02:00
|
|
|
$pageprev = $page - 1;
|
|
|
|
|
$pagenext = $page + 1;
|
2019-10-14 15:13:07 +02:00
|
|
|
|
2021-02-26 21:17:52 +01:00
|
|
|
if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) {
|
|
|
|
|
$sortfield = $conf->global->MAIN_DOC_SORT_FIELD;
|
|
|
|
|
}
|
|
|
|
|
if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) {
|
|
|
|
|
$sortorder = $conf->global->MAIN_DOC_SORT_ORDER;
|
|
|
|
|
}
|
2019-10-14 15:13:07 +02:00
|
|
|
|
2021-02-26 21:17:52 +01:00
|
|
|
if (!$sortorder) {
|
|
|
|
|
$sortorder = "ASC";
|
|
|
|
|
}
|
|
|
|
|
if (!$sortfield) {
|
|
|
|
|
$sortfield = "position_name";
|
|
|
|
|
}
|
2004-02-08 12:50:05 +01:00
|
|
|
|
2011-07-03 10:55:46 +02:00
|
|
|
$object = new Societe($db);
|
2021-02-26 21:17:52 +01:00
|
|
|
if ($id > 0 || !empty($ref)) {
|
2012-04-07 09:14:33 +02:00
|
|
|
$result = $object->fetch($id, $ref);
|
2012-05-29 23:50:13 +02:00
|
|
|
|
2020-04-10 10:59:32 +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, 0, 0, 0, $object, 'thirdparty');
|
2012-04-07 09:14:33 +02:00
|
|
|
}
|
|
|
|
|
|
2018-03-30 16:44:58 +02:00
|
|
|
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
2020-04-10 10:59:32 +02:00
|
|
|
$hookmanager->initHooks(array('thirdpartydocument', 'globalcard'));
|
2018-03-30 16:44:58 +02:00
|
|
|
|
2021-05-18 01:58:54 +02:00
|
|
|
$permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
2018-03-30 16:44:58 +02:00
|
|
|
|
2021-04-01 11:18:35 +02:00
|
|
|
// Security check
|
|
|
|
|
if ($user->socid > 0) {
|
|
|
|
|
unset($action);
|
|
|
|
|
$socid = $user->socid;
|
|
|
|
|
}
|
|
|
|
|
$result = restrictedArea($user, 'societe', $object->id, '&societe');
|
|
|
|
|
|
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
|
|
|
|
2021-02-19 16:10:19 +01:00
|
|
|
include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.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
|
|
|
/*
|
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);
|
|
|
|
|
|
2019-11-13 19:37:08 +01:00
|
|
|
$title = $langs->trans("ThirdParty").' - '.$langs->trans("Files");
|
2021-02-26 21:17:52 +01:00
|
|
|
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
|
|
|
|
|
$title = $object->name.' - '.$langs->trans("Files");
|
|
|
|
|
}
|
2019-11-13 19:37:08 +01:00
|
|
|
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
2019-01-27 11:55:16 +01:00
|
|
|
llxHeader('', $title, $help_url);
|
2006-01-21 20:47:43 +01:00
|
|
|
|
2021-02-26 21:17:52 +01:00
|
|
|
if ($object->id) {
|
2012-07-02 19:30:37 +02:00
|
|
|
/*
|
2016-02-27 06:38:48 +01:00
|
|
|
* Show tabs
|
2012-07-02 19:30:37 +02:00
|
|
|
*/
|
2021-02-26 21:17:52 +01:00
|
|
|
if (!empty($conf->notification->enabled)) {
|
|
|
|
|
$langs->load("mails");
|
|
|
|
|
}
|
2012-07-02 19:30:37 +02:00
|
|
|
$head = societe_prepare_head($object);
|
|
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
$form = new Form($db);
|
2012-07-02 19:30:37 +02:00
|
|
|
|
2020-10-22 22:50:03 +02:00
|
|
|
print dol_get_fiche_head($head, 'document', $langs->trans("ThirdParty"), -1, 'company');
|
2012-07-02 19:30:37 +02:00
|
|
|
|
|
|
|
|
|
2018-08-04 14:17:51 +02:00
|
|
|
// Build file list
|
2020-04-10 10:59:32 +02: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-26 21:17:52 +01:00
|
|
|
foreach ($filearray as $key => $file) {
|
2020-04-10 10:59:32 +02:00
|
|
|
$totalsize += $file['size'];
|
2012-07-02 19:30:37 +02:00
|
|
|
}
|
|
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
2017-07-01 14:18:09 +02:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
|
2017-07-01 14:18:09 +02:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
print '<div class="fichecenter">';
|
2017-07-01 14:18:09 +02:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
print '<div class="underbanner clearboth"></div>';
|
2019-03-29 13:26:26 +01:00
|
|
|
print '<table class="border tableforfield centpercent">';
|
2012-07-02 19:30:37 +02:00
|
|
|
|
2021-06-23 19:02:14 +02:00
|
|
|
// Type Prospect/Customer/Supplier
|
|
|
|
|
print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
|
|
|
|
|
print $object->getTypeUrl(1);
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
2012-07-02 19:30:37 +02:00
|
|
|
// Prefix
|
2021-02-26 21:17:52 +01:00
|
|
|
if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
|
2016-05-17 02:16:28 +02:00
|
|
|
print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
|
2012-07-02 19:30:37 +02:00
|
|
|
}
|
|
|
|
|
|
2021-02-26 21:17:52 +01:00
|
|
|
if ($object->client) {
|
2016-05-17 02:16:28 +02:00
|
|
|
print '<tr><td class="titlefield">';
|
2012-07-02 19:30:37 +02:00
|
|
|
print $langs->trans('CustomerCode').'</td><td colspan="3">';
|
2021-02-27 02:44:52 +01:00
|
|
|
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
|
2020-12-20 13:54:02 +01:00
|
|
|
$tmpcheck = $object->check_codeclient();
|
|
|
|
|
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
|
|
|
|
print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
|
|
|
|
|
}
|
2012-07-02 19:30:37 +02:00
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-26 21:17:52 +01:00
|
|
|
if ($object->fournisseur) {
|
2016-05-17 02:16:28 +02:00
|
|
|
print '<tr><td class="titlefield">';
|
2012-07-02 19:30:37 +02:00
|
|
|
print $langs->trans('SupplierCode').'</td><td colspan="3">';
|
2021-02-27 02:44:52 +01:00
|
|
|
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
|
2020-12-20 13:54:02 +01:00
|
|
|
$tmpcheck = $object->check_codefournisseur();
|
|
|
|
|
if ($tmpcheck != 0 && $tmpcheck != -5) {
|
|
|
|
|
print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
|
|
|
|
|
}
|
2012-07-02 19:30:37 +02:00
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-27 06:38:48 +01:00
|
|
|
// Number of files
|
2016-05-17 02:16:28 +02:00
|
|
|
print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
|
2012-07-02 19:30:37 +02:00
|
|
|
|
2016-02-27 06:38:48 +01:00
|
|
|
// Total size
|
2019-01-27 11:55:16 +01:00
|
|
|
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
|
2012-07-02 19:30:37 +02:00
|
|
|
|
|
|
|
|
print '</table>';
|
|
|
|
|
|
2015-10-13 13:06:32 +02:00
|
|
|
print '</div>';
|
2017-07-01 14:18:09 +02:00
|
|
|
|
2020-10-27 18:19:31 +01:00
|
|
|
print dol_get_fiche_end();
|
2012-07-02 19:30:37 +02:00
|
|
|
|
2013-09-18 12:02:47 +02:00
|
|
|
$modulepart = 'societe';
|
2021-06-08 16:19:21 +02:00
|
|
|
$permissiontoadd = $user->rights->societe->creer;
|
2016-10-14 18:09:24 +02:00
|
|
|
$permtoedit = $user->rights->societe->creer;
|
2019-11-13 19:37:08 +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 {
|
2019-01-27 11:55:16 +01:00
|
|
|
accessforbidden('', 0, 0);
|
2004-02-08 12:50:05 +01:00
|
|
|
}
|
2004-09-14 19:22:36 +02:00
|
|
|
|
2018-08-05 17:21:59 +02:00
|
|
|
// End of page
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
2012-04-07 09:14:33 +02:00
|
|
|
$db->close();
|