";
if ($lignes[$i]->fk_product > 0)
{
print '';
@@ -649,7 +660,7 @@ else
print ''.$langs->trans("Validate").'';
}
- if ($conf->livraison->enabled && $expedition->statut == 1 && $user->rights->expedition->livraison->creer && !$expedition->livraison_id)
+ if ($conf->livraison_bon->enabled && $expedition->statut == 1 && $user->rights->expedition->livraison->creer && !$expedition->livraison_id)
{
print ''.$langs->trans("DeliveryOrder").'';
}
@@ -666,99 +677,35 @@ else
print "";
+
/*
* Documents générés
*/
-
- $expeditionref = sanitize_string($expedition->ref);
- $filedir = $conf->expedition->dir_output . "/" .$expeditionref;
-
- $urlsource = $_SERVER["PHP_SELF"]."?id=".$expedition->id;
-
- $genallowed=$user->rights->expedition->lire && ($expedition->statut > 0);
- $delallowed=$user->rights->expedition->supprimer;
- //$genallowed=1;
- //$delallowed=0;
-
- $somethingshown=$formfile->show_documents('expedition',$expeditionref,$filedir,$urlsource,$genallowed,$delallowed,$expedition->modelpdf);
- if ($genallowed && ! $somethingshown) $somethingshown=1;
+ if ($conf->expedition_bon->enabled)
+ {
+ $expeditionref = sanitize_string($expedition->ref);
+ $filedir = $conf->expedition->dir_output . "/" .$expeditionref;
+
+ $urlsource = $_SERVER["PHP_SELF"]."?id=".$expedition->id;
+
+ $genallowed=$user->rights->expedition->lire && ($expedition->statut > 0);
+ $delallowed=$user->rights->expedition->supprimer;
+ //$genallowed=1;
+ //$delallowed=0;
+
+ $somethingshown=$formfile->show_documents('expedition',$expeditionref,$filedir,$urlsource,$genallowed,$delallowed,$expedition->modelpdf);
+ if ($genallowed && ! $somethingshown) $somethingshown=1;
+ }
- /*
- * Autres expeditions
- */
- $sql = "SELECT obj.fk_product, obj.description, obj.rowid, obj.qty as qty_asking";
- $sql.= ", ed.qty as qty_shipped, ed.fk_expedition as expedition_id";
- $sql.= ", e.ref, ".$db->pdate("e.date_expedition")." as date_expedition";
- $sql.= " FROM ".MAIN_DB_PREFIX.$expedition->origin."det as obj";
- $sql.= " , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e";
- $sql.= " WHERE obj.fk_".$expedition->origin." = ".$expedition->origin_id;
- $sql.= " AND e.rowid <> ".$expedition->id;
- $sql.= " AND obj.rowid = ed.fk_origin_line";
- $sql.= " AND ed.fk_expedition = e.rowid";
- $sql.= " ORDER BY obj.fk_product";
-
- $resql = $db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- $i = 0;
-
- if ($num)
- {
- if ($somethingshown) print ' ';
-
- print_titre($langs->trans("OtherSendingsForSameOrder"));
- print '';
- print '';
- print '| '.$langs->trans("Ref").' | ';
- print ''.$langs->trans("Description").' | ';
- print ''.$langs->trans("Qty").' | ';
- print ''.$langs->trans("Date").' | ';
- print " \n";
-
- $var=True;
- while ($i < $num)
- {
- $var=!$var;
- $objp = $db->fetch_object($resql);
- print "";
- print '| '.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.' | ';
- if ($objp->fk_product > 0)
- {
- $product = new Product($db);
- $product->fetch($objp->fk_product);
-
- print '';
- print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.dolibarr_trunc($product->libelle,20);
- if ($objp->description) print nl2br(dolibarr_trunc($objp->description,24));
- print ' | ';
- }
- else
- {
- print "".nl2br(dolibarr_trunc($objp->description,24))." | \n";
- }
- print ''.$objp->qty_shipped.' | ';
- print ''.dolibarr_print_date($objp->date_expedition).' | ';
- print ' ';
- $i++;
- }
-
- print ' ';
- }
- $db->free($resql);
- }
- else
- {
- dolibarr_print_error($db);
- }
-
-
print ' | ';
// Rien a droite
print ' | ';
+ print ' ';
+ show_list_sending_receive($expedition->origin,$expedition->origin_id," AND e.rowid <> ".$expedition->id);
+
}
else
{
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index f04fc7d44bb..9424ee02d94 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -87,7 +87,7 @@ class Form
$htmltext=ereg_replace("\r","",$htmltext);
$htmltext=ereg_replace(" \n"," ",$htmltext);
$htmltext=ereg_replace("\n","",$htmltext);
-
+
if ($conf->use_javascript_ajax && $tooltipon == 4)
{
$s = ''."\n";
@@ -116,34 +116,34 @@ class Form
$paramfortooltippicto.=' onmouseover="showtip(\''.$htmltext.'\')"';
$paramfortooltippicto.=' onMouseout="hidetip()"';
}
- }
+ }
- $s="";
- $s.=' ';
- if ($direction > 0)
- {
- if ($text)
+ $s="";
+ $s.='';
+ if ($direction > 0)
{
- $s.='| '.$text;
- if ($direction) $s.=' ';
- $s.=' | ';
+ if ($text)
+ {
+ $s.=''.$text;
+ if ($direction) $s.=' ';
+ $s.=' | ';
+ }
+ if ($direction) $s.=''.$img.' | ';
}
- if ($direction) $s.=''.$img.' | ';
- }
- else
- {
- if ($direction) $s.=''.$img.' | ';
- if ($text)
+ else
{
- $s.='';
- if ($direction) $s.=' ';
- $s.=$text.' | ';
+ if ($direction) $s.=''.$img.' | ';
+ if ($text)
+ {
+ $s.='';
+ if ($direction) $s.=' ';
+ $s.=$text.' | ';
+ }
}
+ $s.=' ';
}
- $s.='
';
+ return $s;
}
- return $s;
- }
/**
\brief Affiche un texte avec picto help qui affiche un tooltip
diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php
index 88e0d561247..50cc3a316bc 100644
--- a/htdocs/install/upgrade2.php
+++ b/htdocs/install/upgrade2.php
@@ -1683,7 +1683,7 @@ function migrate_commande_expedition($db,$langs,$conf)
*/
function migrate_commande_livraison($db,$langs,$conf)
{
- if ($conf->livraison->enabled)
+ if ($conf->livraison_bon->enabled)
{
print ' ';
diff --git a/htdocs/lib/order.lib.php b/htdocs/lib/order.lib.php
index 44aa83f3f61..10a0636cb4f 100644
--- a/htdocs/lib/order.lib.php
+++ b/htdocs/lib/order.lib.php
@@ -47,12 +47,12 @@ function commande_prepare_head($commande)
$h++;
}
- if (($conf->expedition->enabled && $user->rights->expedition->lire)
- || ($conf->livraison->enabled && $user->rights->expedition->livraison->lire))
+ if (($conf->expedition_bon->enabled && $user->rights->expedition->lire)
+ || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire))
{
$head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id;
- if ($conf->expedition->enabled) $text=$langs->trans("Sendings");
- if ($conf->livraison->enabled) $text.='/'.$langs->trans("Receivings");
+ if ($conf->expedition_bon->enabled) $text=$langs->trans("Sendings");
+ if ($conf->livraison_bon->enabled) $text.='/'.$langs->trans("Receivings");
$head[$h][1] = $text;
$head[$h][2] = 'shipping';
$h++;
diff --git a/htdocs/lib/propal.lib.php b/htdocs/lib/propal.lib.php
index be586febf71..de5fc8c7362 100644
--- a/htdocs/lib/propal.lib.php
+++ b/htdocs/lib/propal.lib.php
@@ -43,13 +43,14 @@ function propal_prepare_head($propal)
$head[$h][2] = 'comm';
$h++;
- if ((!$conf->commande->enabled && (($conf->expedition->enabled && $user->rights->expedition->lire)
- || ($conf->livraison->enabled && $user->rights->expedition->livraison->lire))))
+ if ((!$conf->commande->enabled &&
+ (($conf->expedition_bon->enabled && $user->rights->expedition->lire)
+ || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire))))
{
$langs->load("sendings");
$head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?propalid='.$propal->id;
- if ($conf->expedition->enabled) $text=$langs->trans("Sendings");
- if ($conf->livraison->enabled) $text.='/'.$langs->trans("Receivings");
+ if ($conf->expedition_bon->enabled) $text=$langs->trans("Sendings");
+ if ($conf->livraison_bon->enabled) $text.='/'.$langs->trans("Receivings");
$head[$h][1] = $text;
$head[$h][2] = 'shipping';
$h++;
diff --git a/htdocs/lib/sendings.lib.php b/htdocs/lib/sendings.lib.php
new file mode 100644
index 00000000000..e7c435558e9
--- /dev/null
+++ b/htdocs/lib/sendings.lib.php
@@ -0,0 +1,134 @@
+
+ *
+ * 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/lib/sendings.lib.php
+ \ingroup expedition
+ \brief Library for expedition module
+ \version $Id$
+ */
+
+
+/**
+ * List sendings and receive receipts
+ *
+ * @param unknown_type $option
+ * @return unknown
+ */
+function show_list_sending_receive($origin='commande',$origin_id,$filter='')
+{
+ global $db, $conf, $langs, $bc;
+
+ $sql = "SELECT obj.rowid, obj.fk_product, obj.description, obj.qty as qty_asking";
+ $sql.= ", ed.qty as qty_shipped, ed.fk_expedition as expedition_id";
+ $sql.= ", e.ref, ".$db->pdate("e.date_expedition")." as date_expedition";
+ if ($conf->livraison_bon->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref";
+ $sql.= " FROM ".MAIN_DB_PREFIX.$origin."det as obj";
+ $sql.= " , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e";
+ if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid";
+ $sql.= " WHERE obj.fk_".$origin." = ".$origin_id;
+ if ($filter) $sql.=$filter;
+ $sql.= " AND obj.rowid = ed.fk_origin_line";
+ $sql.= " AND ed.fk_expedition = e.rowid";
+ $sql.= " ORDER BY obj.fk_product";
+
+ dolibarr_syslog("show_list_sending_receive sql=".$sql, LOG_DEBUG);
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+
+ if ($num)
+ {
+ if ($somethingshown) print ' ';
+
+ if ($filter) print_titre($langs->trans("OtherSendingsForSameOrder"));
+ else print_titre($langs->trans("SendingsAndReceivingForSameOrder"));
+
+ print '';
+ print '';
+ print '| '.$langs->trans("Ref").' | ';
+ print ''.$langs->trans("Description").' | ';
+ print ''.$langs->trans("Qty").' | ';
+ print ''.$langs->trans("DateSending").' | ';
+ if ($conf->expedition_bon->enabled)
+ {
+ print ''.$langs->trans("SendingSheet").' | ';
+ }
+ if ($conf->livraison_bon->enabled)
+ {
+ print ''.$langs->trans("DeliveryOrder").' | ';
+ }
+ print " \n";
+
+ $var=True;
+ while ($i < $num)
+ {
+ $var=!$var;
+ $objp = $db->fetch_object($resql);
+ print "";
+ print '| '.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.' | ';
+ if ($objp->fk_product > 0)
+ {
+ $product = new Product($db);
+ $product->fetch($objp->fk_product);
+
+ print '';
+ print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.dolibarr_trunc($product->libelle,20);
+ if ($objp->description) print dol_htmlentitiesbr(dolibarr_trunc($objp->description,24));
+ print ' | ';
+ }
+ else
+ {
+ print "".dol_htmlentitiesbr(dolibarr_trunc($objp->description,24))." | \n";
+ }
+ print ''.$objp->qty_shipped.' | ';
+ print ''.dolibarr_print_date($objp->date_expedition,'dayhour').' | ';
+ if ($conf->expedition_bon->enabled)
+ {
+ print ''.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.' | ';
+ }
+ if ($conf->livraison_bon->enabled)
+ {
+ if ($objp->livraison_id)
+ {
+ print ''.img_object($langs->trans("ShowSending"),'generic').' '.$objp->livraison_ref.' | ';
+ }
+ else
+ {
+ print ' | ';
+ }
+ }
+ print ' ';
+ $i++;
+ }
+
+ print ' ';
+ }
+ $db->free($resql);
+ }
+ else
+ {
+ dolibarr_print_error($db);
+ }
+
+ return 1;
+}
+
+?>
\ No newline at end of file
diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php
index 8d226b5ea57..54a31bc19f1 100644
--- a/htdocs/livraison/fiche.php
+++ b/htdocs/livraison/fiche.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2005-2006 Laurent Destailleur
+ * Copyright (C) 2005-2008 Laurent Destailleur
* Copyright (C) 2005 Simon TOSSER
* Copyright (C) 2007 Franky Van Liedekerke
* Copyright (C) 2005-2008 Regis Houssin
@@ -425,13 +425,13 @@ else
if ($conf->commande->enabled)
{
print '| '.$langs->trans("RefOrder").' | ';
- print ''.img_object($langs->trans("ShowOrder"),'order').' '.$livraison->$object->ref." | \n";
+ print ''.img_object($langs->trans("ShowOrder"),'order').' '.$livraison->commande->ref." | \n";
print ' ';
}
else
{
print '| '.$langs->trans("RefProposal").' | ';
- print ''.img_object($langs->trans("ShowProposal"),'propal').' '.$livraison->$object->ref." | \n";
+ print ''.img_object($langs->trans("ShowProposal"),'propal').' '.$livraison->propal->ref." | \n";
print ' ';
}
@@ -568,7 +568,7 @@ else
$sql.= ", cd.rowid, cd.qty as qty_commande";
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
$sql.= " , ".MAIN_DB_PREFIX."livraisondet as ld, ".MAIN_DB_PREFIX."livraison as l";
- $sql.= " WHERE cd.fk_commande = ".$livraison->commande_id;
+ $sql.= " WHERE cd.fk_commande = ".$livraison->origin_id;
$sql.= " AND l.rowid <> ".$livraison->id;
$sql.= " AND cd.rowid = ld.fk_origin_line";
$sql.= " AND ld.fk_livraison = l.rowid";
diff --git a/htdocs/livraison/livraison.class.php b/htdocs/livraison/livraison.class.php
index b81990e2eb3..acaa912ad34 100644
--- a/htdocs/livraison/livraison.class.php
+++ b/htdocs/livraison/livraison.class.php
@@ -17,21 +17,19 @@
* 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$
*/
/**
\file htdocs/livraison/livraison.class.php
\ingroup livraison
\brief Fichier de la classe de gestion des bons de livraison
- \version $Revision$
+ \version $Id$
*/
require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
require_once(DOL_DOCUMENT_ROOT."/expedition/expedition.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php");
-if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
+if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
@@ -47,7 +45,7 @@ class Livraison extends CommonObject
var $brouillon;
var $origin;
var $origin_id;
-
+ var $socid;
/**
* Initialisation
@@ -76,7 +74,7 @@ class Livraison extends CommonObject
{
global $conf;
- dolibarr_syslog("Livraison::create ");
+ dolibarr_syslog("Livraison::create");
$error = 0;
@@ -84,14 +82,16 @@ class Livraison extends CommonObject
$this->brouillon = 1;
$this->user = $user;
-
+
$this->db->begin();
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."livraison (date_creation, fk_user_author, fk_adresse_livraison";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."livraison (ref, fk_soc, date_creation, fk_user_author,";
+ $sql.= " fk_adresse_livraison";
if ($this->commande_id) $sql.= ", fk_commande";
if ($this->expedition_id) $sql.= ", fk_expedition";
$sql.= ")";
- $sql.= " VALUES (now(), $user->id, $this->adresse_livraison_id";
+ $sql.= " VALUES ('(PROV)', ".$this->socid.", now(), $user->id,";
+ $sql.= " ".($this->adresse_livraison_id > 0?$this->adresse_livraison_id:"null");
if ($this->commande_id) $sql.= ", $this->commande_id";
if ($this->expedition_id) $sql.= ", $this->expedition_id";
$sql.= ")";
@@ -120,7 +120,10 @@ class Livraison extends CommonObject
*/
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
{
- if (! $this->create_line(0, $this->lignes[$i]->commande_ligne_id, $this->lignes[$i]->qty))
+ $origin_id=$this->lignes[$i]->origin_ligne_id;
+ if (! $origin_id) $origin_id=$this->lignes[$i]->commande_ligne_id; // For backward compatibility
+
+ if (! $this->create_line(0, $origin_id, $this->lignes[$i]->qty))
{
$error++;
}
@@ -146,7 +149,7 @@ class Livraison extends CommonObject
else
{
$error++;
- $this->error=$this->db->error()." - sql=".$this->db->lastqueryerror;
+ $this->error=$this->db->lasterror()." - sql=".$this->db->lastqueryerror;
dolibarr_syslog("Livraison::create Error -3 ".$this->error);
$this->db->rollback();
return -3;
@@ -155,7 +158,7 @@ class Livraison extends CommonObject
else
{
$error++;
- $this->error=$this->db->error()." - sql=".$this->db->lastqueryerror;
+ $this->error=$this->db->lasterror()." - sql=".$this->db->lastqueryerror;
dolibarr_syslog("Livraison::create Error -2 ".$this->error);
$this->db->rollback();
return -2;
@@ -164,7 +167,7 @@ class Livraison extends CommonObject
else
{
$error++;
- $this->error=$this->db->error()." - sql=".$this->db->lastqueryerror;
+ $this->error=$this->db->lasterror()." - sql=".$this->db->lastqueryerror;
dolibarr_syslog("Livraison::create Error -1 ".$this->error);
$this->db->rollback();
return -1;
@@ -181,6 +184,7 @@ class Livraison extends CommonObject
$idprod = 0;
$j = 0;
+ // Search product id
while (($j < sizeof($this->commande->lignes)) && idprod == 0)
{
if ($this->commande->lignes[$j]->id == $commande_ligne_id)
@@ -190,8 +194,12 @@ class Livraison extends CommonObject
$j++;
}
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."livraisondet (fk_livraison, fk_commande_ligne, qty)";
- $sql .= " VALUES ($this->id,".$commande_ligne_id.",".$qty.")";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."livraisondet (fk_livraison, fk_origin_line,";
+ if ($idprod) $sql.=" fk_product";
+ $sql.= " qty)";
+ $sql.= " VALUES (".$this->id.",".$commande_ligne_id.",";
+ if ($idprod) $sql.=" ".$idprod.",";
+ $sql.= $qty.")";
if (! $this->db->query($sql) )
{
@@ -205,7 +213,6 @@ class Livraison extends CommonObject
}
/**
- *
* Lit un bon de livraison
*
*/
@@ -234,7 +241,8 @@ class Livraison extends CommonObject
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."pr_liv as pl ON pl.fk_livraison = l.rowid";
}
$sql.= " WHERE l.rowid = ".$id;
-
+
+ dolibarr_syslog("Livraison::fetch sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql) ;
if ($result)
{
@@ -475,7 +483,7 @@ class Livraison extends CommonObject
$LivraisonLigne->origin_ligne_id = $expedition->lignes[$i]->origin_line_id;
$LivraisonLigne->libelle = $expedition->lignes[$i]->libelle;
$LivraisonLigne->description = $expedition->lignes[$i]->product_desc;
- $LivraisonLigne->qty = $expedition->lignes[$i]->qty_expedie;
+ $LivraisonLigne->qty = $expedition->lignes[$i]->qty_shipped;
$LivraisonLigne->fk_product = $expedition->lignes[$i]->fk_product;
$LivraisonLigne->ref = $expedition->lignes[$i]->ref;
$this->lignes[$i] = $LivraisonLigne;
@@ -487,7 +495,8 @@ class Livraison extends CommonObject
$this->projetid = $expedition->projetidp;
$this->date_livraison = $expedition->date_livraison;
$this->adresse_livraison_id = $expedition->adresse_livraison_id;
-
+ $this->socid = $expedition->socid;
+
return $this->create($user);
}
@@ -619,16 +628,16 @@ class Livraison extends CommonObject
{
$this->lignes = array();
- $sql = "SELECT p.label, p.ref";
- $sql.= ", l.description, l.fk_product, l.subprice, l.total_ht, l.qty as qtyliv";
+ $sql = "SELECT p.label, p.ref,";
+ $sql.= " l.description, l.fk_product, l.subprice, l.total_ht, l.qty as qtyliv";
//$sql.= ", c.qty as qtycom";
- $sql .= " FROM ".MAIN_DB_PREFIX."livraisondet as l";
+ $sql.= " FROM ".MAIN_DB_PREFIX."livraisondet as l";
//$sql .= " , ".MAIN_DB_PREFIX."commandedet as c";
- $sql .= " , ".MAIN_DB_PREFIX."product as p";
- $sql .= " WHERE l.fk_livraison = ".$this->id;
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on p.rowid = l.fk_product";
+ $sql.= " WHERE l.fk_livraison = ".$this->id;
//$sql .= " AND l.fk_commande_ligne = c.rowid";
- $sql .= " AND l.fk_product = p.rowid";
+ dolibarr_syslog("Livraison::fetch_lignes sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
| |