2004-10-19 22:19:58 +02:00
|
|
|
<?php
|
2005-06-27 23:47:44 +02:00
|
|
|
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2009-03-03 01:12:56 +01:00
|
|
|
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
2005-06-27 23:47:44 +02:00
|
|
|
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
2012-12-30 15:13:49 +01:00
|
|
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
2003-08-28 17:29:13 +02: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
|
2003-08-28 17:29:13 +02: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-03 02:45:22 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-08-28 17:29:13 +02:00
|
|
|
*/
|
2004-08-14 14:54:50 +02:00
|
|
|
|
2009-03-03 01:12:56 +01:00
|
|
|
/**
|
2009-10-04 14:16:45 +02:00
|
|
|
* \file htdocs/comm/propal/document.php
|
|
|
|
|
* \ingroup propale
|
2010-03-27 03:35:08 +01:00
|
|
|
* \brief Page de gestion des documents attaches a une proposition commerciale
|
2009-10-04 14:16:45 +02:00
|
|
|
*/
|
2004-08-14 14:54:50 +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.'/comm/propal/class/propal.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.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';
|
2003-08-28 17:33:50 +02:00
|
|
|
|
2005-09-11 13:49:43 +02:00
|
|
|
$langs->load('compta');
|
2006-01-21 20:47:43 +01:00
|
|
|
$langs->load('other');
|
2003-08-28 17:29:13 +02:00
|
|
|
|
2012-06-09 18:37:54 +02:00
|
|
|
$action = GETPOST('action','alpha');
|
|
|
|
|
$confirm = GETPOST('confirm','alpha');
|
2012-02-27 22:26:22 +01:00
|
|
|
$id = GETPOST('id','int');
|
2012-06-09 18:37:54 +02:00
|
|
|
$ref = GETPOST('ref','alpha');
|
2007-06-21 20:10:45 +02:00
|
|
|
|
2008-02-24 14:18:40 +01:00
|
|
|
// Security check
|
2012-07-23 20:52:55 +02:00
|
|
|
$socid='';
|
|
|
|
|
if (! empty($user->societe_id))
|
2008-05-04 16:24:29 +02:00
|
|
|
{
|
2009-03-03 01:12:56 +01:00
|
|
|
$action='';
|
2008-05-04 16:24:29 +02:00
|
|
|
$socid = $user->societe_id;
|
|
|
|
|
}
|
2012-07-23 20:52:55 +02:00
|
|
|
$result = restrictedArea($user, 'propal', $id);
|
2005-06-29 03:35:00 +02:00
|
|
|
|
2008-05-04 16:24:29 +02:00
|
|
|
// 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 16:24:29 +02:00
|
|
|
$pageprev = $page - 1;
|
|
|
|
|
$pagenext = $page + 1;
|
2010-11-20 14:08:44 +01:00
|
|
|
if (! $sortorder) $sortorder="ASC";
|
|
|
|
|
if (! $sortfield) $sortfield="name";
|
2008-05-04 16:24:29 +02:00
|
|
|
|
2011-07-05 18:10:56 +02:00
|
|
|
$object = new Propal($db);
|
2012-06-09 18:37:54 +02:00
|
|
|
$object->fetch($id,$ref);
|
2012-07-02 19:30:37 +02:00
|
|
|
if ($object->id > 0)
|
|
|
|
|
{
|
|
|
|
|
$object->fetch_thirdparty();
|
2012-06-09 18:37:54 +02:00
|
|
|
}
|
2006-01-21 20:47:43 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Actions
|
|
|
|
|
*/
|
2009-03-03 01:12:56 +01:00
|
|
|
|
2006-01-21 20:47:43 +01:00
|
|
|
// Envoi fichier
|
2012-07-23 20:52:55 +02:00
|
|
|
if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
2003-08-28 17:29:13 +02:00
|
|
|
{
|
2012-06-09 18:37:54 +02:00
|
|
|
if ($object->id > 0)
|
2006-01-21 20:47:43 +01:00
|
|
|
{
|
2012-03-22 08:33:44 +01:00
|
|
|
$upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
2012-07-29 16:44:19 +02:00
|
|
|
dol_add_file_process($upload_dir,0,1,'userfile');
|
2006-01-21 20:47:43 +01:00
|
|
|
}
|
|
|
|
|
}
|
2003-08-28 17:29:13 +02:00
|
|
|
|
2006-01-21 20:47:43 +01:00
|
|
|
// Delete
|
2011-07-05 18:10:56 +02:00
|
|
|
if ($action == 'confirm_deletefile' && $confirm == 'yes')
|
2006-01-21 20:47:43 +01:00
|
|
|
{
|
2012-06-09 18:37:54 +02:00
|
|
|
if ($object->id > 0)
|
2006-01-21 20:47:43 +01:00
|
|
|
{
|
2012-05-29 23:50:13 +02:00
|
|
|
$langs->load("other");
|
2011-07-06 22:56:48 +02:00
|
|
|
|
2012-03-22 08:33:44 +01:00
|
|
|
$upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
2012-05-29 23:50:13 +02:00
|
|
|
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
2012-07-29 15:47:24 +02:00
|
|
|
$ret=dol_delete_file($file,0,0,0,$object);
|
|
|
|
|
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
|
|
|
|
|
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
|
2012-08-31 05:58:38 +02:00
|
|
|
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
|
2012-05-31 17:48:03 +02:00
|
|
|
exit;
|
2006-01-21 20:47:43 +01:00
|
|
|
}
|
2003-08-28 17:29:13 +02:00
|
|
|
}
|
|
|
|
|
|
2006-01-21 20:47:43 +01:00
|
|
|
|
|
|
|
|
/*
|
2009-10-04 14:16:45 +02:00
|
|
|
* View
|
2006-01-21 20:47:43 +01:00
|
|
|
*/
|
2009-03-03 01:12:56 +01:00
|
|
|
|
2012-07-28 17:34:21 +02:00
|
|
|
llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos');
|
2005-01-16 20:05:40 +01:00
|
|
|
|
2011-11-08 10:18:45 +01:00
|
|
|
$form = new Form($db);
|
2009-10-04 14:16:45 +02:00
|
|
|
|
2012-06-09 18:37:54 +02:00
|
|
|
if ($object->id > 0)
|
2003-08-28 17:29:13 +02:00
|
|
|
{
|
2012-07-02 19:30:37 +02:00
|
|
|
$upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref);
|
2012-07-23 20:52:55 +02:00
|
|
|
|
2012-07-02 19:30:37 +02:00
|
|
|
$head = propal_prepare_head($object);
|
|
|
|
|
dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal');
|
2012-07-23 20:52:55 +02:00
|
|
|
|
2012-07-02 19:30:37 +02:00
|
|
|
// 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'];
|
|
|
|
|
}
|
2012-07-23 20:52:55 +02:00
|
|
|
|
|
|
|
|
|
2012-07-02 19:30:37 +02:00
|
|
|
print '<table class="border"width="100%">';
|
2012-07-23 20:52:55 +02:00
|
|
|
|
2012-07-28 09:54:47 +02:00
|
|
|
$linkback='<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
|
2012-07-23 20:52:55 +02:00
|
|
|
|
2012-07-02 19:30:37 +02:00
|
|
|
// Ref
|
|
|
|
|
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
|
|
|
|
|
print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
|
|
|
|
|
print '</td></tr>';
|
2012-07-23 20:52:55 +02:00
|
|
|
|
2012-07-02 19:30:37 +02:00
|
|
|
// Ref client
|
|
|
|
|
print '<tr><td>';
|
2013-07-19 14:23:42 +02:00
|
|
|
print '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">';
|
2012-07-02 19:30:37 +02:00
|
|
|
print $langs->trans('RefCustomer').'</td><td align="left">';
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '</tr></table>';
|
|
|
|
|
print '</td><td colspan="3">';
|
|
|
|
|
print $object->ref_client;
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
2012-07-23 20:52:55 +02:00
|
|
|
|
2012-07-02 19:30:37 +02:00
|
|
|
// Customer
|
|
|
|
|
print "<tr><td>".$langs->trans("Company")."</td>";
|
|
|
|
|
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
|
2012-07-23 20:52:55 +02:00
|
|
|
|
2012-07-02 19:30:37 +02: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">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
|
2012-07-23 20:52:55 +02:00
|
|
|
|
2012-07-02 19:30:37 +02:00
|
|
|
print '</table>';
|
2012-07-23 20:52:55 +02:00
|
|
|
|
2012-07-02 19:30:37 +02:00
|
|
|
print '</div>';
|
2012-07-23 20:52:55 +02:00
|
|
|
|
2012-07-02 19:30:37 +02:00
|
|
|
/*
|
|
|
|
|
* Confirmation suppression fichier
|
2012-07-29 15:47:24 +02:00
|
|
|
*/
|
2012-07-02 19:30:37 +02:00
|
|
|
if ($action == 'delete')
|
|
|
|
|
{
|
2013-09-06 11:51:24 +02:00
|
|
|
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
|
2012-07-02 19:30:37 +02:00
|
|
|
}
|
2012-07-23 20:52:55 +02:00
|
|
|
|
2012-07-02 19:30:37 +02:00
|
|
|
// Affiche formulaire upload
|
|
|
|
|
$formfile=new FormFile($db);
|
2012-09-13 16:11:08 +02:00
|
|
|
$formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id,'',0,0,$user->rights->propal->creer,50,$object);
|
2012-07-23 20:52:55 +02:00
|
|
|
|
|
|
|
|
|
2012-07-02 19:30:37 +02:00
|
|
|
// List of document
|
2012-09-13 16:11:08 +02:00
|
|
|
$formfile->list_of_documents($filearray,$object,'propal');
|
2003-08-28 17:29:13 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-07-01 21:40:06 +02:00
|
|
|
print $langs->trans("UnkownError");
|
2003-08-28 17:29:13 +02:00
|
|
|
}
|
2004-11-07 16:14:09 +01:00
|
|
|
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
2012-07-23 20:52:55 +02:00
|
|
|
$db->close();
|
2003-08-28 17:29:13 +02:00
|
|
|
?>
|