From 0a32a7cd5f099b7eab5c70cd672a5e507f02b13a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Nov 2008 20:09:23 +0000 Subject: [PATCH] Can attach files on supplier orders --- htdocs/document.php | 10 +- htdocs/fourn/commande/dispatch.php | 23 +--- htdocs/fourn/commande/document.php | 181 +++++++++++++++++++++++++++++ htdocs/fourn/commande/fiche.php | 23 +--- htdocs/fourn/commande/history.php | 27 +---- htdocs/fourn/commande/note.php | 28 +---- htdocs/lib/fourn.lib.php | 36 ++++++ 7 files changed, 239 insertions(+), 89 deletions(-) create mode 100644 htdocs/fourn/commande/document.php diff --git a/htdocs/document.php b/htdocs/document.php index 5eea18de65e..b4a0bea7d11 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -20,11 +20,11 @@ */ /** - \file htdocs/document.php - \brief Wrapper to allow download of data files - \version $Id$ - \remarks L'appel est document.php?file=pathrelatifdufichier&modulepart=repfichierconcerne -*/ + * \file htdocs/document.php + * \brief Wrapper to download data files + * \version $Id$ + * \remarks L'appel est document.php?file=pathrelatifdufichier&modulepart=repfichierconcerne + */ $original_file = urldecode($_GET["file"]); $modulepart = urldecode($_GET["modulepart"]); diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 3145a2b722c..8261c8cb69b 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -29,6 +29,7 @@ require('./pre.inc.php'); require_once(DOL_DOCUMENT_ROOT.'/includes/modules/supplier_order/modules_commandefournisseur.php'); require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/fourn.lib.php"); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/project.class.php'); $langs->load('orders'); @@ -108,26 +109,10 @@ if ($id > 0) $author->id = $commande->user_author_id; $author->fetch(); - $h = 0; - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id; - $head[$h][1] = $langs->trans("OrderCard"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$commande->id; - $head[$h][1] = $langs->trans("OrderDispatch"); - $a = $h; - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$commande->id; - $head[$h][1] = $langs->trans("Note"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$commande->id; - $head[$h][1] = $langs->trans("OrderFollow"); - $h++; - + $head = ordersupplier_prepare_head($commande); + $title=$langs->trans("SupplierOrder"); - dolibarr_fiche_head($head, $a, $title); + dolibarr_fiche_head($head, 'dispatch', $title); /* * Commande diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php new file mode 100644 index 00000000000..569d2f7554e --- /dev/null +++ b/htdocs/fourn/commande/document.php @@ -0,0 +1,181 @@ + + * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005 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/fourn/commande/document.php + \ingroup supplier + \brief Page de gestion des documents attachees a une commande fournisseur + \version $Id$ + */ + +require('./pre.inc.php'); +require_once(DOL_DOCUMENT_ROOT.'/lib/order.lib.php'); +require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/fourn.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); +require_once DOL_DOCUMENT_ROOT."/fourn/fournisseur.commande.class.php"; + +if (!$user->rights->commande->lire) +accessforbidden(); + +$langs->load('orders'); +$langs->load('sendings'); +$langs->load('companies'); +$langs->load('bills'); +$langs->load('deliveries'); +$langs->load('products'); +$langs->load('stocks'); + + +$id=empty($_GET['id']) ? 0 : intVal($_GET['id']); +$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action']; + +// Security check +if (!$user->rights->fournisseur->commande->lire) accessforbidden(); +if ($user->societe_id > 0) +{ + unset($_GET["action"]); + $action=''; + $socid = $user->societe_id; +} + +// Get parameters +$page=$_GET["page"]; +$sortorder=$_GET["sortorder"]; +$sortfield=$_GET["sortfield"]; + +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="name"; +if ($page == -1) { $page = 0 ; } +$offset = $conf->liste_limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; + + +$commande = new CommandeFournisseur($db); +if ($commande->fetch($id) < 0) +{ + dolibarr_print_error($db); + exit; +} + +/* + * Actions + */ + +// Envoi fichier +if ($_POST["sendit"] && $conf->upload) +{ + $upload_dir = $conf->fournisseur->commande->dir_output . "/" . sanitizeFileName($commande->ref); + if (! is_dir($upload_dir)) create_exdir($upload_dir); + + if (is_dir($upload_dir)) + { + if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0) > 0) + { + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + //print_r($_FILES); + } + else + { + // Echec transfert (fichier dépassant la limite ?) + $mesg = '
'.$langs->trans("ErrorFileNotUploaded").'
'; + // print_r($_FILES); + } + } +} + +// Delete +if ($action=='delete') +{ + $upload_dir = $conf->fournisseur->commande->dir_output . "/" . sanitizeFileName($commande->ref); + $file = $upload_dir . '/' . urldecode($_GET['urlfile']); + dol_delete_file($file); + $mesg = '
'.$langs->trans("FileWasRemoved").'
'; +} + + +/* + * Affichage + */ +if ($id > 0) +{ + llxHeader(); + + $upload_dir = $conf->fournisseur->commande->dir_output.'/'.sanitizeFileName($commande->ref); + + $societe = new Societe($db); + $societe->fetch($commande->socid); + + $head = ordersupplier_prepare_head($commande); + + dolibarr_fiche_head($head, 'documents', $langs->trans('SupplierOrder')); + + + // Construit liste des fichiers + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + + print ''; + + // Ref + print ''; + + print ''; + + // Statut + print ''; + print ''; + print '"; + + print ''; + print ''; + print "
'.$langs->trans('Ref').''.$commande->ref.'
'.$langs->trans('Supplier').''.$societe->getNomUrl(1).'
'.$langs->trans("Status").''; + print $commande->getLibStatut(4); + print "
'.$langs->trans("NbOfAttachedFiles").''.sizeof($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
\n"; + print "\n"; + + if ($mesg) { print $mesg."
"; } + + + // Affiche formulaire upload + $formfile=new FormFile($db); + $formfile->form_attach_new_file(DOL_URL_ROOT.'/fourn/commande/document.php?id='.$commande->id); + + + // List of document + $param='&id='.$commande->id; + $formfile->list_of_documents($filearray,$commande,'commande_fournisseur',$param); +} +else +{ + Header('Location: index.php'); +} + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 8002c21c1f0..40826157903 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -30,7 +30,9 @@ require('./pre.inc.php'); require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/html.formorder.class.php"); require_once(DOL_DOCUMENT_ROOT.'/includes/modules/supplier_order/modules_commandefournisseur.php'); +require_once DOL_DOCUMENT_ROOT."/fourn/fournisseur.commande.class.php"; require_once DOL_DOCUMENT_ROOT."/fourn/fournisseur.product.class.php"; +require_once DOL_DOCUMENT_ROOT."/lib/fourn.lib.php"; if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/project.class.php'); $langs->load('orders'); @@ -487,27 +489,10 @@ if ($id > 0) $author->id = $commande->user_author_id; $author->fetch(); - $h = 0; - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id; - $head[$h][1] = $langs->trans("OrderCard"); - $a = $h; - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$commande->id; - $head[$h][1] = $langs->trans("OrderDispatch"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$commande->id; - $head[$h][1] = $langs->trans("Note"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$commande->id; - $head[$h][1] = $langs->trans("OrderFollow"); - $h++; - + $head = ordersupplier_prepare_head($commande); $title=$langs->trans("SupplierOrder"); - dolibarr_fiche_head($head, $a, $title); + dolibarr_fiche_head($head, 'card', $title); /* * Confirmation de la suppression de la commande diff --git a/htdocs/fourn/commande/history.php b/htdocs/fourn/commande/history.php index 4335723c2b1..39d57ce6a50 100644 --- a/htdocs/fourn/commande/history.php +++ b/htdocs/fourn/commande/history.php @@ -15,19 +15,17 @@ * 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. - * - * $Id$ - * $Source$ */ /** \file htdocs/fourn/commande/history.php \ingroup commande \brief Fiche commande - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/fourn.lib.php"); $langs->load("orders"); $langs->load("suppliers"); @@ -62,27 +60,10 @@ if ($_GET["id"] > 0) llxHeader('',$langs->trans("History"),"CommandeFournisseur",$addons); - $h = 0; - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id; - $head[$h][1] = $langs->trans("OrderCard"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$commande->id; - $head[$h][1] = $langs->trans("OrderDispatch"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$commande->id; - $head[$h][1] = $langs->trans("Note"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$commande->id; - $head[$h][1] = $langs->trans("OrderFollow"); - $a = $h; - - $h++; + $head = ordersupplier_prepare_head($commande); $title=$langs->trans("SupplierOrder"); - dolibarr_fiche_head($head, $a, $title); + dolibarr_fiche_head($head, 'info', $title); /* diff --git a/htdocs/fourn/commande/note.php b/htdocs/fourn/commande/note.php index 7adc2a6b37c..26c1549f865 100644 --- a/htdocs/fourn/commande/note.php +++ b/htdocs/fourn/commande/note.php @@ -15,19 +15,17 @@ * 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. - * - * $Id$ - * $Source$ */ /** \file htdocs/fourn/commande/note.php \ingroup commande - \brief Fiche commande - \version $Revision$ + \brief Fiche note commande + \version $Id$ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/fourn.lib.php"); $langs->load("orders"); $langs->load("suppliers"); @@ -78,26 +76,10 @@ if ($_GET["id"] > 0) $author->id = $commande->user_author_id; $author->fetch(); - $h = 0; - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id; - $head[$h][1] = $langs->trans("OrderCard"); - $h++; + $head = ordersupplier_prepare_head($commande); - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$commande->id; - $head[$h][1] = $langs->trans("OrderDispatch"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$commande->id; - $head[$h][1] = $langs->trans("Note"); - $a = $h; - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$commande->id; - $head[$h][1] = $langs->trans("OrderFollow"); - $h++; - $title=$langs->trans("SupplierOrder"); - dolibarr_fiche_head($head, $a, $title); + dolibarr_fiche_head($head, 'note', $title); /* diff --git a/htdocs/lib/fourn.lib.php b/htdocs/lib/fourn.lib.php index 40cb4f1aa00..de2f492a796 100644 --- a/htdocs/lib/fourn.lib.php +++ b/htdocs/lib/fourn.lib.php @@ -53,4 +53,40 @@ function facturefourn_prepare_head($fac) return $head; } + +function ordersupplier_prepare_head($commande) +{ + global $langs, $conf; + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id; + $head[$h][1] = $langs->trans("OrderCard"); + $head[$h][2] = 'card'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$commande->id; + $head[$h][1] = $langs->trans("OrderDispatch"); + $head[$h][2] = 'dispatch'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$commande->id; + $head[$h][1] = $langs->trans("Note"); + $head[$h][2] = 'note'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/document.php?id='.$commande->id; + $head[$h][1] = $langs->trans("Documents"); + $head[$h][2] = 'documents'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$commande->id; + $head[$h][1] = $langs->trans("OrderFollow"); + $head[$h][2] = 'info'; + $h++; + + return $head; +} + + ?> \ No newline at end of file