Qual: Mise en facteur du code de gestion des onglets commande

This commit is contained in:
Laurent Destailleur 2006-05-06 19:06:40 +00:00
parent 1aef3cbf9d
commit 41a5d50b5b
10 changed files with 200 additions and 330 deletions

View File

@ -30,6 +30,7 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/order.lib.php");
$user->getrights('commande'); $user->getrights('commande');
$user->getrights('expedition'); $user->getrights('expedition');
@ -80,46 +81,9 @@ if ($_GET["id"] > 0) {
$soc = new Societe($db, $commande->socidp); $soc = new Societe($db, $commande->socidp);
$soc->fetch($commande->socidp); $soc->fetch($commande->socidp);
$h=0;
if ($conf->commande->enabled && $user->rights->commande->lire) $head = commande_prepare_head($commande);
{ dolibarr_fiche_head($head, 'preview', $langs->trans("CustomerOrder"));
$head[$h][0] = DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans('OrderCard');
$h++;
}
if ($conf->expedition->enabled && $user->rights->expedition->lire)
{
$head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id;
$head[$h][1] = $langs->trans('SendingCard');
$h++;
}
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans('ComptaCard');
$h++;
}
if ($conf->use_preview_tabs)
{
$head[$h][0] = DOL_URL_ROOT.'/commande/apercu.php?id='.$commande->id;
$head[$h][1] = $langs->trans("Preview");
$hselected=$h;
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id;
$head[$h][1] = $langs->trans('Info');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$commande->id;
$head[$h][1] = $langs->trans('OrderContact');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans('Order').': '.$commande->ref);
/* /*
@ -147,7 +111,7 @@ if ($_GET["id"] > 0) {
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Reference // Ref
print '<tr><td width="18%">'.$langs->trans("Ref")."</td>"; print '<tr><td width="18%">'.$langs->trans("Ref")."</td>";
print '<td colspan="2">'.$commande->ref.'</td>'; print '<td colspan="2">'.$commande->ref.'</td>';
print '<td width="50%">'.$langs->trans("Source").' : ' . $commande->sources[$commande->source] ; print '<td width="50%">'.$langs->trans("Source").' : ' . $commande->sources[$commande->source] ;

View File

@ -30,7 +30,7 @@
require ("./pre.inc.php"); require ("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php'); require_once(DOL_DOCUMENT_ROOT."/lib/order.lib.php");
$langs->load("facture"); $langs->load("facture");
$langs->load("orders"); $langs->load("orders");
@ -220,67 +220,37 @@ if ($id > 0)
$commande = New Commande($db); $commande = New Commande($db);
if ( $commande->fetch($_GET['id'], $user->societe_id) > 0) if ( $commande->fetch($_GET['id'], $user->societe_id) > 0)
{ {
$soc = new Societe($db, $commande->socidp); $soc = new Societe($db, $commande->soc_id);
$soc->fetch($commande->socidp); $soc->fetch($commande->soc_id);
$h=0;
if ($conf->commande->enabled && $user->rights->commande->lire) $head = commande_prepare_head($commande);
{ dolibarr_fiche_head($head, 'contact', $langs->trans("CustomerOrder"));
$head[$h][0] = DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans("OrderCard");
$h++;
}
if ($conf->expedition->enabled && $user->rights->expedition->lire)
{
$head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id;
$head[$h][1] = $langs->trans("SendingCard");
$h++;
}
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans("ComptaCard");
$h++;
}
if ($conf->use_preview_tabs)
{
$head[$h][0] = DOL_URL_ROOT.'/commande/apercu.php?id='.$commande->id;
$head[$h][1] = $langs->trans("Preview");
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id;
$head[$h][1] = $langs->trans("Info");
$h++;
//Ajout de longlet contacts
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$commande->id;
$head[$h][1] = $langs->trans('OrderContact');
$hselected = $h;
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("Order").": $commande->ref");
/* /*
* Facture synthese pour rappel * Facture synthese pour rappel
*/ */
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Reference de la commande // Ref
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">'; print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $commande->ref; print $commande->ref;
print "</td></tr>"; print "</td></tr>";
// Customer // Ref commande client
if ( is_null($commande->ref_client) ) print '<tr><td>';
$soc = new Societe($db); print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
$soc->fetch($commande->soc_id); print $langs->trans('RefCustomer').'</td><td align="left">';
print '</td>';
print '</tr></table>';
print '</td><td colspan="3">';
print $commande->ref_client;
print '</td>';
print '</tr>';
print "<tr><td>".$langs->trans("Customer")."</td>"; // Customer
print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'; print '<td colspan="3">';
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td></tr>'; print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td></tr>';
print "</table>"; print "</table>";
@ -465,7 +435,7 @@ if ($id > 0)
} }
else else
{ {
// Contrat non trouvé // Contrat non trouv
print "Contrat inexistant ou accés refusé"; print "Contrat inexistant ou accés refusé";
} }
} }

View File

@ -37,6 +37,7 @@ require_once(DOL_DOCUMENT_ROOT.'/propal.class.php');
require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php'); require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php');
require_once(DOL_DOCUMENT_ROOT.'/actioncomm.class.php'); require_once(DOL_DOCUMENT_ROOT.'/actioncomm.class.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php');
require_once(DOL_DOCUMENT_ROOT."/lib/order.lib.php");
$langs->load('orders'); $langs->load('orders');
$langs->load('sendings'); $langs->load('sendings');
@ -732,47 +733,8 @@ else
$author->id = $commande->user_author_id; $author->id = $commande->user_author_id;
$author->fetch(); $author->fetch();
$h=0; $head = commande_prepare_head($commande);
dolibarr_fiche_head($head, 'order', $langs->trans("CustomerOrder"));
if ($conf->commande->enabled && $user->rights->commande->lire)
{
$head[$h][0] = DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans('OrderCard');
$hselected = $h;
$h++;
}
if ($conf->expedition->enabled && $user->rights->expedition->lire)
{
$head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id;
$head[$h][1] = $langs->trans('SendingCard');
$h++;
}
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans('ComptaCard');
$h++;
}
if ($conf->use_preview_tabs)
{
$head[$h][0] = DOL_URL_ROOT.'/commande/apercu.php?id='.$commande->id;
$head[$h][1] = $langs->trans("Preview");
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id;
$head[$h][1] = $langs->trans('Info');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$commande->id;
$head[$h][1] = $langs->trans('OrderContact');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans('Order').': '.$commande->ref);
/* /*
* Confirmation de la suppression de la commande * Confirmation de la suppression de la commande

View File

@ -30,6 +30,7 @@
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/order.lib.php");
$langs->load("orders"); $langs->load("orders");
$langs->load("sendings"); $langs->load("sendings");
@ -45,49 +46,11 @@ llxHeader();
$commande = new Commande($db); $commande = new Commande($db);
$commande->fetch($_GET["id"]); $commande->fetch($_GET["id"]);
$commande->info($_GET["id"]); $commande->info($_GET["id"]);
$soc = new Societe($db, $commande->socidp); $soc = new Societe($db, $commande->soc_id);
$soc->fetch($commande->socidp); $soc->fetch($commande->soc_id);
$h = 0; $head = commande_prepare_head($commande);
dolibarr_fiche_head($head, 'info', $langs->trans("CustomerOrder"));
if ($conf->commande->enabled && $user->rights->commande->lire)
{
$head[$h][0] = DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans("OrderCard");
$h++;
}
if ($conf->expedition->enabled && $user->rights->expedition->lire)
{
$head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id;
$head[$h][1] = $langs->trans("SendingCard");
$h++;
}
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans("ComptaCard");
$h++;
}
if ($conf->use_preview_tabs)
{
$head[$h][0] = DOL_URL_ROOT.'/commande/apercu.php?id='.$commande->id;
$head[$h][1] = $langs->trans("Preview");
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id;
$head[$h][1] = $langs->trans("Info");
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$commande->id;
$head[$h][1] = $langs->trans('OrderContact');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("Order").": $commande->ref");
print '<table width="100%"><tr><td>'; print '<table width="100%"><tr><td>';

View File

@ -29,31 +29,28 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/order.lib.php");
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/project.class.php");
$langs->load("orders"); $langs->load("orders");
$langs->load("sendings");
$langs->load("companies"); $langs->load("companies");
$langs->load("bills"); $langs->load("bills");
$langs->load("propal");
$user->getrights('facture'); $user->getrights('commande');
if (! $user->rights->commande->lire) accessforbidden(); if (! $user->rights->commande->lire) accessforbidden();
require_once(DOL_DOCUMENT_ROOT."/project.class.php"); // Sécurité accés client
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
/*
* Sécurité accés client
*/
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
$action = ''; $action = '';
$socidp = $user->societe_id; $socidp = $user->societe_id;
} }
/* /*
* * Actions
*/ */
if ($_GET["action"] == 'facturee') if ($_GET["action"] == 'facturee')
@ -87,46 +84,8 @@ if ($_GET["id"] > 0)
$author->id = $commande->user_author_id; $author->id = $commande->user_author_id;
$author->fetch(); $author->fetch();
$h=0; $head = commande_prepare_head($commande);
dolibarr_fiche_head($head, 'accountancy', $langs->trans("CustomerOrder"));
if ($conf->commande->enabled && $user->rights->commande->lire)
{
$head[$h][0] = DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans("OrderCard");
$h++;
}
if ($conf->expedition->enabled && $user->rights->expedition->lire)
{
$head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id;
$head[$h][1] = $langs->trans("SendingCard");
$h++;
}
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans("ComptaCard");
$hselected = $h;
$h++;
}
if ($conf->use_preview_tabs)
{
$head[$h][0] = DOL_URL_ROOT.'/commande/apercu.php?id='.$commande->id;
$head[$h][1] = $langs->trans("Preview");
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id;
$head[$h][1] = $langs->trans("Info");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$commande->id;
$head[$h][1] = $langs->trans('OrderContact');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("Order").": $commande->ref");
/* /*
* Commande * Commande

View File

@ -34,6 +34,7 @@ require_once(DOL_DOCUMENT_ROOT."/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/project.class.php"); require_once(DOL_DOCUMENT_ROOT."/project.class.php");
require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/order.lib.php");
$langs->load("bills"); $langs->load("bills");
@ -87,46 +88,8 @@ if ($_GET["id"] > 0)
$author->id = $commande->user_author_id; $author->id = $commande->user_author_id;
$author->fetch(); $author->fetch();
$h=0; $head = commande_prepare_head($commande);
dolibarr_fiche_head($head, 'shipping', $langs->trans("CustomerOrder"));
if ($conf->commande->enabled && $user->rights->commande->lire)
{
$head[$h][0] = DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans("OrderCard");
$h++;
}
if ($conf->expedition->enabled && $user->rights->expedition->lire)
{
$head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id;
$head[$h][1] = $langs->trans("SendingCard");
$hselected = $h;
$h++;
}
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans("ComptaCard");
$h++;
}
if ($conf->use_preview_tabs)
{
$head[$h][0] = DOL_URL_ROOT.'/commande/apercu.php?id='.$commande->id;
$head[$h][1] = $langs->trans("Preview");
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id;
$head[$h][1] = $langs->trans("Info");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$commande->id;
$head[$h][1] = $langs->trans('OrderContact');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("Order").": $commande->ref");
/* /*
* Confirmation de la validation * Confirmation de la validation

View File

@ -8,6 +8,8 @@ OrderDate=Date commande
NewOrder=New order NewOrder=New order
SupplierOrder=Supplier order SupplierOrder=Supplier order
SuppliersOrders=Suppliers' orders SuppliersOrders=Suppliers' orders
CustomerOrder=Customer order
CustomersOrders=Customers' orders
OrdersToValid=Orders to valid OrdersToValid=Orders to valid
OrdersToBill=Orders to bill OrdersToBill=Orders to bill
OrdersInProcess=Orders in process OrdersInProcess=Orders in process

View File

@ -8,6 +8,8 @@ OrderDate=Date commande
NewOrder=Nouvelle commande NewOrder=Nouvelle commande
SupplierOrder=Commande fournisseur SupplierOrder=Commande fournisseur
SuppliersOrders=Commandes fournisseurs SuppliersOrders=Commandes fournisseurs
CustomerOrder=Commande client
CustomersOrders=Commandes client
OrdersToValid=Commandes à valider OrdersToValid=Commandes à valider
OrdersToBill=Commandes à facturer OrdersToBill=Commandes à facturer
OrdersInProcess=Commandes en traitement OrdersInProcess=Commandes en traitement

View File

@ -23,6 +23,7 @@
/** /**
\file htdocs/lib/company.lib.php \file htdocs/lib/company.lib.php
\brief Ensemble de fonctions de base pour le module societe \brief Ensemble de fonctions de base pour le module societe
\ingroup societe
\version $Revision$ \version $Revision$
Ensemble de fonctions de base de dolibarr sous forme d'include Ensemble de fonctions de base de dolibarr sous forme d'include
@ -34,8 +35,6 @@ function societe_prepare_head($objsoc)
$h = 0; $h = 0;
$head = array(); $head = array();
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$objsoc->id; $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$objsoc->id;
$head[$h][1] = $langs->trans("Company"); $head[$h][1] = $langs->trans("Company");
$head[$h][2] = 'company'; $head[$h][2] = 'company';

86
htdocs/lib/order.lib.php Normal file
View File

@ -0,0 +1,86 @@
<?php
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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.
* or see http://www.gnu.org/
*
* $Id$
* $Source$
*/
/**
\file htdocs/lib/order.lib.php
\brief Ensemble de fonctions de base pour le module commande
\ingroup commande
\version $Revision$
Ensemble de fonctions de base de dolibarr sous forme d'include
*/
function commande_prepare_head($commande)
{
global $langs, $conf, $user;
if ($conf->expedition->enabled) $langs->load("sendings");
$h = 0;
$head = array();
if ($conf->commande->enabled && $user->rights->commande->lire)
{
$head[$h][0] = DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans("OrderCard");
$head[$h][2] = 'order';
$h++;
}
if ($conf->expedition->enabled && $user->rights->expedition->lire)
{
$head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id;
$head[$h][1] = $langs->trans("SendingCard");
$head[$h][2] = 'shipping';
$h++;
}
if ($conf->compta->enabled || $conf->comptaexpert->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans("ComptaCard");
$head[$h][2] = 'accountancy';
$hselected = $h;
$h++;
}
if ($conf->use_preview_tabs)
{
$head[$h][0] = DOL_URL_ROOT.'/commande/apercu.php?id='.$commande->id;
$head[$h][1] = $langs->trans("Preview");
$head[$h][2] = 'preview';
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$commande->id;
$head[$h][1] = $langs->trans('OrderContact');
$head[$h][2] = 'contact';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id;
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
$h++;
return $head;
}
?>