2005-08-24 22:29:41 +02:00
|
|
|
<?php
|
2007-01-02 16:23:19 +01:00
|
|
|
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2010-03-13 23:27:37 +01:00
|
|
|
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
2005-08-24 22:29:41 +02:00
|
|
|
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
2009-04-27 22:37:50 +02:00
|
|
|
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
|
|
|
|
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
|
2005-08-24 22:29:41 +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
|
|
|
|
|
* 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
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*/
|
2009-03-03 01:12:56 +01:00
|
|
|
|
2005-08-25 01:58:47 +02:00
|
|
|
/**
|
2010-01-13 18:06:20 +01:00
|
|
|
* \file htdocs/product/document.php
|
|
|
|
|
* \ingroup product
|
|
|
|
|
* \brief Page des documents joints sur les produits
|
|
|
|
|
* \version $Id$
|
|
|
|
|
*/
|
2005-08-25 01:58:47 +02:00
|
|
|
|
2010-03-16 19:26:38 +01:00
|
|
|
require('../main.inc.php');
|
2006-08-02 00:42:38 +02:00
|
|
|
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
|
2010-04-28 23:29:12 +02:00
|
|
|
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
2008-05-04 15:33:49 +02:00
|
|
|
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
2010-05-03 10:43:32 +02:00
|
|
|
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
|
2005-08-24 22:29:41 +02:00
|
|
|
|
2005-12-03 12:48:44 +01:00
|
|
|
$langs->load("other");
|
2010-05-02 19:05:07 +02:00
|
|
|
$langs->load("products");
|
2005-12-03 12:47:09 +01:00
|
|
|
|
2005-08-24 22:29:41 +02:00
|
|
|
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
|
2005-12-03 04:49:00 +01:00
|
|
|
|
2009-05-04 10:31:42 +02:00
|
|
|
// Security check
|
2009-05-04 10:42:29 +02:00
|
|
|
if (isset($_GET["id"]) || isset($_GET["ref"]))
|
2009-05-04 10:31:42 +02:00
|
|
|
{
|
2009-05-04 10:42:29 +02:00
|
|
|
$id = isset($_GET["id"])?$_GET["id"]:(isset($_GET["ref"])?$_GET["ref"]:'');
|
2009-05-04 10:31:42 +02:00
|
|
|
}
|
2009-05-04 12:46:53 +02:00
|
|
|
$fieldid = isset($_GET["ref"])?'ref':'rowid';
|
2009-05-04 10:31:42 +02:00
|
|
|
if ($user->societe_id) $socid=$user->societe_id;
|
2009-06-08 20:14:37 +02:00
|
|
|
$result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid);
|
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
|
|
|
|
|
|
|
|
|
2005-12-03 04:49:00 +01:00
|
|
|
$product = new Product($db);
|
|
|
|
|
if ($_GET['id'] || $_GET["ref"])
|
2005-08-25 01:58:47 +02:00
|
|
|
{
|
2005-12-03 04:49:00 +01:00
|
|
|
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
|
|
|
|
|
if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
|
|
|
|
|
|
2010-06-02 10:34:44 +02:00
|
|
|
if ($conf->product->enabled) $upload_dir = $conf->product->dir_output.'/'.dol_sanitizeFileName($product->ref);
|
2010-01-13 18:06:20 +01:00
|
|
|
elseif ($conf->service->enabled) $upload_dir = $conf->service->dir_output.'/'.dol_sanitizeFileName($product->ref);
|
2005-08-25 01:58:47 +02:00
|
|
|
}
|
2008-02-25 00:29:30 +01:00
|
|
|
$modulepart='produit';
|
2005-08-24 22:29:41 +02:00
|
|
|
|
2005-08-25 01:58:47 +02:00
|
|
|
/*
|
|
|
|
|
* Action envoie fichier
|
|
|
|
|
*/
|
2010-01-06 00:01:25 +01:00
|
|
|
|
2008-11-28 00:02:49 +01:00
|
|
|
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
2005-08-24 22:29:41 +02:00
|
|
|
{
|
2010-05-01 16:28:48 +02:00
|
|
|
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
|
|
|
|
|
|
|
|
|
if (create_exdir($upload_dir) >= 0)
|
|
|
|
|
{
|
|
|
|
|
$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)
|
|
|
|
|
{
|
|
|
|
|
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
|
|
|
|
|
}
|
|
|
|
|
else
|
2010-01-08 11:02:53 +01:00
|
|
|
{
|
2010-05-01 16:28:48 +02:00
|
|
|
$langs->load("errors");
|
|
|
|
|
if ($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-01-08 11:02:53 +01:00
|
|
|
}
|
2010-05-01 16:28:48 +02:00
|
|
|
}
|
2005-08-25 01:58:47 +02:00
|
|
|
}
|
2005-08-24 22:29:41 +02:00
|
|
|
|
|
|
|
|
|
2007-07-30 22:43:57 +02:00
|
|
|
/*
|
2010-03-13 23:27:37 +01:00
|
|
|
* View
|
2007-07-30 22:43:57 +02:00
|
|
|
*/
|
2009-03-03 01:12:56 +01:00
|
|
|
|
2007-07-30 22:43:57 +02:00
|
|
|
$html = new Form($db);
|
2005-08-24 22:29:41 +02:00
|
|
|
|
2006-06-10 11:27:34 +02:00
|
|
|
llxHeader("","",$langs->trans("CardProduct".$product->type));
|
2005-08-25 01:58:47 +02:00
|
|
|
|
2005-08-24 22:29:41 +02:00
|
|
|
|
2005-12-03 04:49:00 +01:00
|
|
|
if ($product->id)
|
2005-08-24 22:29:41 +02:00
|
|
|
{
|
2005-08-25 01:58:47 +02:00
|
|
|
if ( $error_msg )
|
2009-03-03 01:12:56 +01:00
|
|
|
{
|
2005-08-25 01:58:47 +02:00
|
|
|
echo '<div class="error">'.$error_msg.'</div><br>';
|
|
|
|
|
}
|
2005-08-24 22:29:41 +02:00
|
|
|
|
2005-08-25 01:58:47 +02:00
|
|
|
if ($action=='delete')
|
|
|
|
|
{
|
2009-07-16 02:43:59 +02:00
|
|
|
$file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
2008-02-25 00:29:30 +01:00
|
|
|
$result=dol_delete_file($file);
|
|
|
|
|
//if ($result >= 0) $mesg=$langs->trans("FileWasRemoced");
|
2005-08-25 01:58:47 +02:00
|
|
|
}
|
2005-08-24 22:29:41 +02:00
|
|
|
|
2007-01-02 16:23:19 +01:00
|
|
|
$head=product_prepare_head($product, $user);
|
2006-08-02 00:42:38 +02:00
|
|
|
$titre=$langs->trans("CardProduct".$product->type);
|
2009-08-06 15:21:23 +02:00
|
|
|
$picto=($product->type==1?'service':'product');
|
|
|
|
|
dol_fiche_head($head, 'documents', $titre, 0, $picto);
|
2005-08-24 22:29:41 +02:00
|
|
|
|
2005-08-25 01:58:47 +02:00
|
|
|
|
2008-05-04 15:33:49 +02:00
|
|
|
// Construit liste des fichiers
|
2010-12-02 00:42:39 +01:00
|
|
|
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
|
2008-05-04 15:33:49 +02:00
|
|
|
$totalsize=0;
|
|
|
|
|
foreach($filearray as $key => $file)
|
|
|
|
|
{
|
|
|
|
|
$totalsize+=$file['size'];
|
|
|
|
|
}
|
2009-03-03 01:12:56 +01:00
|
|
|
|
|
|
|
|
|
2005-12-03 04:49:00 +01:00
|
|
|
print '<table class="border" width="100%">';
|
|
|
|
|
|
2010-12-18 18:51:15 +01:00
|
|
|
// Ref
|
2005-12-03 04:49:00 +01:00
|
|
|
print '<tr>';
|
2010-02-17 19:27:20 +01:00
|
|
|
print '<td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
2007-11-10 15:30:54 +01:00
|
|
|
print $html->showrefnav($product,'ref','',1,'ref');
|
2005-12-03 04:49:00 +01:00
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
2010-12-18 18:51:15 +01:00
|
|
|
// Label
|
2005-12-03 04:49:00 +01:00
|
|
|
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$product->libelle.'</td></tr>';
|
|
|
|
|
|
2010-12-18 18:51:15 +01:00
|
|
|
// Status (to sell)
|
|
|
|
|
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')'.'</td><td>';
|
|
|
|
|
print $product->getLibStatut(2,0);
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
|
|
|
// Status (to buy)
|
|
|
|
|
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')'.'</td><td>';
|
|
|
|
|
print $product->getLibStatut(2,1);
|
|
|
|
|
print '</td></tr>';
|
2006-03-17 00:54:29 +01:00
|
|
|
|
2005-08-25 01:58:47 +02:00
|
|
|
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.sizeof($filearray).'</td></tr>';
|
|
|
|
|
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
|
|
|
|
|
print '</table>';
|
2005-08-24 22:29:41 +02:00
|
|
|
|
2005-08-25 01:58:47 +02:00
|
|
|
print '</div>';
|
2005-08-24 22:29:41 +02:00
|
|
|
|
|
|
|
|
|
2006-11-13 23:01:35 +01:00
|
|
|
// Affiche formulaire upload
|
2008-01-10 18:12:07 +01:00
|
|
|
$formfile=new FormFile($db);
|
2009-06-08 20:14:37 +02:00
|
|
|
$formfile->form_attach_new_file(DOL_URL_ROOT.'/product/document.php?id='.$product->id,'',0,0,($user->rights->produit->creer||$user->rights->service->creer));
|
2009-03-03 01:12:56 +01:00
|
|
|
|
2005-08-24 22:29:41 +02:00
|
|
|
|
2008-05-04 15:33:49 +02:00
|
|
|
// List of document
|
2008-05-04 16:24:29 +02:00
|
|
|
$param='&id='.$product->id;
|
|
|
|
|
$formfile->list_of_documents($filearray,$product,'produit',$param);
|
2009-03-03 01:12:56 +01:00
|
|
|
|
2005-08-24 22:29:41 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
print $langs->trans("UnkownError");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$db->close();
|
|
|
|
|
|
|
|
|
|
llxFooter('$Date$ - $Revision$');
|
|
|
|
|
?>
|