* Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2010 Regis Houssin * * 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. */ /** * \file htdocs/product/photos.php * \ingroup product * \brief Onglet photos de la fiche produit * \version $Id$ */ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); $langs->load("products"); $langs->load("bills"); // Security check if (isset($_GET["id"]) || isset($_GET["ref"])) { $id = isset($_GET["id"])?$_GET["id"]:(isset($_GET["ref"])?$_GET["ref"]:''); } $fieldid = isset($_GET["ref"])?'ref':'rowid'; if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid); $mesg = ''; $dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output); /* * Actions */ if ($_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { if ($_GET["id"]) { $product = new Product($db); $result = $product->fetch($_GET["id"]); $result = $product->add_photo($dir, $_FILES['userfile']); } } if ($_REQUEST["action"] == 'confirm_delete' && $_GET["file"] && $_REQUEST['confirm'] == 'yes' && ($user->rights->produit->creer || $user->rights->service->creer)) { $product = new Product($db); $product->delete_photo($dir."/".$_GET["file"]); } if ($_GET["action"] == 'addthumb' && $_GET["file"]) { $product = new Product($db); $product->add_thumb($dir."/".$_GET["file"]); } /* * View */ $html = new Form($db); if ($_GET["id"] || $_GET["ref"]) { $product = new Product($db); if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); if ($_GET["id"]) $result = $product->fetch($_GET["id"]); llxHeader("","",$langs->trans("CardProduct".$product->type)); if ($result) { /* * En mode visu */ $head=product_prepare_head($product, $user); $titre=$langs->trans("CardProduct".$product->type); $picto=($product->type==1?'service':'product'); dol_fiche_head($head, 'photos', $titre, 0, $picto); /* * Confirmation de la suppression de photo */ if ($_GET['action'] == 'delete') { $ret=$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$product->id.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1); if ($ret == 'html') print '
'; } print($mesg); print ''; // Reference print ''; print ''; print ''; // Libelle print ''; print ''; // Status (to sell) print ''; // Status (to buy) print ''; print "
'.$langs->trans("Ref").''; print $html->showrefnav($product,'ref','',1,'ref'); print '
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'.''; print $product->getLibStatut(2,0); print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'.''; print $product->getLibStatut(2,1); print '
\n"; print "\n"; /* ************************************************************************** */ /* */ /* Barre d'action */ /* */ /* ************************************************************************** */ print "\n
\n"; if ($_GET["action"] != 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer)) { if (! empty($conf->global->MAIN_UPLOAD_DOC)) { print ''; print $langs->trans("AddPhoto").''; } else { print 'e'; print $langs->trans("AddPhoto").''; } } print "\n
\n"; /* * Add a photo */ if ($_GET["action"] == 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer) && ! empty($conf->global->MAIN_UPLOAD_DOC)) { // Affiche formulaire upload $formfile=new FormFile($db); $formfile->form_attach_new_file(DOL_URL_ROOT.'/product/photos.php?id='.$product->id,$langs->trans("AddPhoto"),1); } // Affiche photos if ($_GET["action"] != 'ajout_photo') { $nbphoto=0; $nbbyrow=5; $maxWidth = 160; $maxHeight = 120; print $product->show_photos($dir,1,1000,$nbbyrow,1,1); if ($product->nbphoto < 1) { print '
'; print ''; print ''; print '
'; print "
".$langs->trans("NoPhotoYet")."

"; print '
'; } } } } else { print $langs->trans("ErrorUnknown"); } $db->close(); llxFooter('$Date$ - $Revision$'); ?>