Fix: A lot of fix on sendings features

This commit is contained in:
Laurent Destailleur 2008-05-17 01:52:24 +00:00
parent d89644a579
commit ef0ced5b2c
9 changed files with 274 additions and 271 deletions

View File

@ -50,7 +50,7 @@ if ($_GET["action"] == 'specimen')
$exp = new Expedition($db); $exp = new Expedition($db);
$exp->initAsSpecimen(); $exp->initAsSpecimen();
$exp->fetch_commande(); //$exp->fetch_commande();
// Charge le modele // Charge le modele
$dir = DOL_DOCUMENT_ROOT . "/expedition/mods/pdf/"; $dir = DOL_DOCUMENT_ROOT . "/expedition/mods/pdf/";

View File

@ -57,7 +57,7 @@ if ($_GET["action"] == 'specimen')
$exp = new Expedition($db); $exp = new Expedition($db);
$exp->initAsSpecimen(); $exp->initAsSpecimen();
$exp->fetch_commande(); //$exp->fetch_commande();
// Charge le modele // Charge le modele
$dir = DOL_DOCUMENT_ROOT . "/livraison/mods/pdf/"; $dir = DOL_DOCUMENT_ROOT . "/livraison/mods/pdf/";

View File

@ -16,10 +16,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Id$
* $Source$
*/ */
// Code identique a /expedition/fiche.php // Code identique a /expedition/fiche.php
@ -27,7 +23,7 @@
/** /**
\file htdocs/expedition/commande.php \file htdocs/expedition/commande.php
\ingroup expedition \ingroup expedition
\version $Revision$ \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
@ -396,6 +392,7 @@ if ($_GET["id"] > 0)
/* /*
* Boutons Actions * Boutons Actions
*/ */
if ($user->societe_id == 0) if ($user->societe_id == 0)
{ {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
@ -403,11 +400,12 @@ if ($_GET["id"] > 0)
// Bouton expedier sans gestion des stocks // Bouton expedier sans gestion des stocks
if (! $conf->stock->enabled && $reste_a_livrer_total > 0 && ! $commande->brouillon && $user->rights->expedition->creer) if (! $conf->stock->enabled && $reste_a_livrer_total > 0 && ! $commande->brouillon && $user->rights->expedition->creer)
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/fiche.php?action=create&amp;object_id='.$_GET["id"].'">'.$langs->trans("NewSending").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/fiche.php?action=create&amp;origin=commande&amp;object_id='.$_GET["id"].'">'.$langs->trans("NewSending").'</a>';
} }
print "</div>"; print "</div>";
} }
print '<table width="100%"><tr><td width="50%" valign="top">'; print '<table width="100%"><tr><td width="50%" valign="top">';
/* /*
@ -435,7 +433,7 @@ if ($_GET["id"] > 0)
print '<input type="hidden" name="action" value="create">'; print '<input type="hidden" name="action" value="create">';
print '<input type="hidden" name="id" value="'.$commande->id.'">'; print '<input type="hidden" name="id" value="'.$commande->id.'">';
print '<input type="hidden" name="origin" value="commande">'; print '<input type="hidden" name="origin" value="commande">';
print '<input type="hidden" name="origin_id" value="'.$commande->id.'">'; print '<input type="hidden" name="object_id" value="'.$commande->id.'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
$entrepot = new Entrepot($db); $entrepot = new Entrepot($db);

View File

@ -87,10 +87,10 @@ class Expedition extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (date_creation, fk_user_author, date_expedition"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (ref, date_creation, fk_user_author, date_expedition";
$sql.= ", fk_soc"; $sql.= ", fk_soc";
$sql.= ")"; $sql.= ")";
$sql.= " VALUES (now(), $user->id, ".$this->db->idate($this->date_expedition); $sql.= " VALUES ('(PROV)', now(), $user->id, ".$this->db->idate($this->date_expedition);
$sql.= ", ".$this->socid; $sql.= ", ".$this->socid;
$sql.= ")"; $sql.= ")";
@ -105,13 +105,13 @@ class Expedition extends CommonObject
// Insertion des lignes // Insertion des lignes
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
{ {
if (! $this->create_line($this->lignes[$i]->entrepot_id, $this->lignes[$i]->origin_line_id, $this->lignes[$i]->qty)) if (! $this->create_line($this->lignes[$i]->entrepot_id, $this->lignes[$i]->origin_line_id, $this->lignes[$i]->qty) > 0)
{ {
$error++; $error++;
} }
} }
if ($this->id && $this->origin_id) if (! $error && $this->id && $this->origin_id)
{ {
if ($conf->commande->enabled) if ($conf->commande->enabled)
{ {
@ -144,7 +144,7 @@ class Expedition extends CommonObject
} }
} }
if ($error==0) if (! $error)
{ {
$this->db->commit(); $this->db->commit();
return $this->id; return $this->id;
@ -152,7 +152,7 @@ class Expedition extends CommonObject
else else
{ {
$error++; $error++;
$this->error=$this->db->error()." - sql=$sql"; $this->error=$this->db->lasterror()." - sql=$sql";
$this->db->rollback(); $this->db->rollback();
return -3; return -3;
} }
@ -160,7 +160,7 @@ class Expedition extends CommonObject
else else
{ {
$error++; $error++;
$this->error=$this->db->error()." - sql=$sql"; $this->error=$this->db->lasterror()." - sql=$sql";
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }
@ -183,17 +183,15 @@ class Expedition extends CommonObject
$error = 0; $error = 0;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet (fk_expedition, fk_entrepot, fk_origin_line, qty)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet (fk_expedition, fk_entrepot, fk_origin_line, qty)";
$sql .= " VALUES (".$this->id.", ".$entrepot_id.", ".$origin_line_id.", ".$qty.")"; $sql .= " VALUES (".$this->id.", ".($entrepot_id?$entrepot_id:'null').", ".$origin_line_id.", ".$qty.")";
//print 'x'.$sql;
if (! $this->db->query($sql) ) if (! $this->db->query($sql))
{ {
$error++; $error++;
} }
if ($error == 0 ) if (! $error) return 1;
{ else return -1;
return 1;
}
} }
/** /**
@ -640,6 +638,11 @@ class Expedition extends CommonObject
if ($statut==0) return img_picto($langs->trans('StatusSendingDraft'),'statut0').' '.$langs->trans('StatusSendingDraft'); if ($statut==0) return img_picto($langs->trans('StatusSendingDraft'),'statut0').' '.$langs->trans('StatusSendingDraft');
if ($statut==1) return img_picto($langs->trans('StatusSendingValidated'),'statut4').' '.$langs->trans('StatusSendingValidated'); if ($statut==1) return img_picto($langs->trans('StatusSendingValidated'),'statut4').' '.$langs->trans('StatusSendingValidated');
} }
if ($mode == 5)
{
if ($statut==0) return $langs->trans('StatusSendingDraftShort').' '.img_picto($langs->trans('StatusSendingDraft'),'statut0');
if ($statut==1) return $langs->trans('StatusSendingValidatedShort').' '.img_picto($langs->trans('StatusSendingValidated'),'statut4');
}
} }
/** /**
@ -683,13 +686,15 @@ class Expedition extends CommonObject
} }
} }
$order=new Commande($this->db);
$order->initAsSpecimen();
// Initialise paramètres // Initialise paramètres
$this->id=0; $this->id=0;
$this->ref = 'SPECIMEN'; $this->ref = 'SPECIMEN';
$this->specimen=1; $this->specimen=1;
$socid = rand(1, $num_socs); $socid = rand(1, $num_socs);
$this->statut = 1; $this->statut = 1;
$this->commande_id = 0;
if ($conf->livraison->enabled) if ($conf->livraison->enabled)
{ {
$this->livraison_id = 0; $this->livraison_id = 0;
@ -699,6 +704,9 @@ class Expedition extends CommonObject
$this->adresse_livraison_id = 0; $this->adresse_livraison_id = 0;
$this->socid = $socids[$socid]; $this->socid = $socids[$socid];
$this->commande_id = 0;
$this->commande = $order;
$nbp = 5; $nbp = 5;
$xnbp = 0; $xnbp = 0;
while ($xnbp < $nbp) while ($xnbp < $nbp)

View File

@ -17,8 +17,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
*/ */
// Code identique a /expedition/commande.php // Code identique a /expedition/commande.php
@ -27,7 +25,7 @@
\file htdocs/expedition/fiche.php \file htdocs/expedition/fiche.php
\ingroup expedition \ingroup expedition
\brief Fiche descriptive d'une expedition \brief Fiche descriptive d'une expedition
\version $Revision$ \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
@ -56,8 +54,8 @@ if ($user->societe_id > 0)
$socid = $user->societe_id; $socid = $user->societe_id;
} }
$origin = $_GET["origin"]?$_GET["origin"]:$_POST["origin"]; $origin = $_GET["origin"]?$_GET["origin"]:$_POST["origin"]; // Example: commande, propal
$origin_id = $_GET["origin_id"]?$_GET["origin_id"]:$_POST["origin_id"]; $origin_id = $_GET["object_id"]?$_GET["object_id"]:$_POST["object_id"]; // Id of order or propal
/* /*
* Actions * Actions
@ -82,6 +80,7 @@ if ($_POST["action"] == 'add')
$object->fetch($expedition->origin_id); $object->fetch($expedition->origin_id);
//$object->fetch_lines(); //$object->fetch_lines();
$expedition->socid = $object->socid; $expedition->socid = $object->socid;
for ($i = 0 ; $i < sizeof($object->lignes) ; $i++) for ($i = 0 ; $i < sizeof($object->lignes) ; $i++)
@ -188,12 +187,18 @@ if ($_GET["action"] == 'create')
{ {
print_titre($langs->trans("CreateASending")); print_titre($langs->trans("CreateASending"));
if (! $origin)
{
$mesg='<div class="error">'.$langs->trans("ErrorBadParameters").'</div>';
}
if ($mesg) if ($mesg)
{ {
print $mesg.'<br>'; print $mesg.'<br>';
} }
if ($origin)
{
$class = ucfirst($origin); $class = ucfirst($origin);
$object = new $class($db); $object = new $class($db);
@ -208,7 +213,7 @@ if ($_GET["action"] == 'create')
$author->id = $object->user_author_id; $author->id = $object->user_author_id;
$author->fetch(); $author->fetch();
$entrepot = new Entrepot($db); if ($conf->stock->enabled) $entrepot = new Entrepot($db);
/* /*
* Document source * Document source
@ -216,7 +221,7 @@ if ($_GET["action"] == 'create')
print '<form action="fiche.php" method="post">'; print '<form action="fiche.php" method="post">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="origin" value="'.$origin.'">'; print '<input type="hidden" name="origin" value="'.$origin.'">';
print '<input type="hidden" name="origin_id" value="'.$object->id.'">'; print '<input type="hidden" name="object_id" value="'.$object->id.'">';
if ($_GET["entrepot_id"]) if ($_GET["entrepot_id"])
{ {
print '<input type="hidden" name="entrepot_id" value="'.$_GET["entrepot_id"].'">'; print '<input type="hidden" name="entrepot_id" value="'.$_GET["entrepot_id"].'">';
@ -422,6 +427,7 @@ if ($_GET["action"] == 'create')
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
}
} }
else else
/* *************************************************************************** */ /* *************************************************************************** */

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -114,7 +114,7 @@ if ($resql)
print_liste_field_titre($langs->trans("Proposal"),"liste.php","ori.ref", "", "&amp;socid=$socid",'width="25%" align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Proposal"),"liste.php","ori.ref", "", "&amp;socid=$socid",'width="25%" align="left"',$sortfield,$sortorder);
} }
print_liste_field_titre($langs->trans("Date"),"liste.php","e.date_expedition","","&amp;socid=$socid", 'width="25%" align="right" colspan="2"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Date"),"liste.php","e.date_expedition","","&amp;socid=$socid", 'width="25%" align="right" colspan="2"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),"liste.php","e.fk_statut","","&amp;socid=$socid",'width="10%" align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),"liste.php","e.fk_statut","","&amp;socid=$socid",'width="10%" align="right"',$sortfield,$sortorder);
print "</tr>\n"; print "</tr>\n";
$var=True; $var=True;
@ -158,7 +158,7 @@ if ($resql)
print " <a href=\"propal.php?year=$y\">"; print " <a href=\"propal.php?year=$y\">";
print strftime("%Y",$objp->date_expedition)."</a></TD>\n"; print strftime("%Y",$objp->date_expedition)."</a></TD>\n";
print '<td align="center">'.$expedition->statuts[$objp->fk_statut].'</td>'; print '<td align="right">'.$expedition->LibStatut($objp->fk_statut,5).'</td>';
print "</tr>\n"; print "</tr>\n";
$i++; $i++;

View File

@ -17,16 +17,13 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see http://www.gnu.org/ * or see http://www.gnu.org/
*
* $Id$
* $Source$
*/ */
/** /**
\file htdocs/expedition/mods/pdf/pdf_expedition_dorade.modules.php \file htdocs/expedition/mods/pdf/pdf_expedition_dorade.modules.php
\ingroup expedition \ingroup expedition
\brief Fichier de la classe permettant de générer les bordereaux envoi au modèle Merou \brief Fichier de la classe permettant de générer les bordereaux envoi au modèle Merou
\version $Revision$ \version $Id$
*/ */
require_once DOL_DOCUMENT_ROOT."/expedition/mods/pdf/ModelePdfExpedition.class.php"; require_once DOL_DOCUMENT_ROOT."/expedition/mods/pdf/ModelePdfExpedition.class.php";

View File

@ -16,16 +16,13 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see http://www.gnu.org/ * or see http://www.gnu.org/
*
* $Id$
* $Source$
*/ */
/** /**
\file htdocs/expedition/mods/pdf/pdf_expedition_rouget.modules.php \file htdocs/expedition/mods/pdf/pdf_expedition_rouget.modules.php
\ingroup expedition \ingroup expedition
\brief Fichier de la classe permettant de générer les bordereaux envoi au modèle Rouget \brief Fichier de la classe permettant de générer les bordereaux envoi au modèle Rouget
\version $Revision$ \version $Id$
*/ */
require_once DOL_DOCUMENT_ROOT."/expedition/mods/pdf/ModelePdfExpedition.class.php"; require_once DOL_DOCUMENT_ROOT."/expedition/mods/pdf/ModelePdfExpedition.class.php";

View File

@ -18,16 +18,13 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/ */
/** /**
\file htdocs/livraison/fiche.php \file htdocs/livraison/fiche.php
\ingroup livraison \ingroup livraison
\brief Fiche descriptive d'un bon de livraison \brief Fiche descriptive d'un bon de livraison
\version $Revision$ \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");