Fix: Debuggage et traduction module expedition.

This commit is contained in:
Laurent Destailleur 2005-07-09 01:16:31 +00:00
parent 27f3acedc4
commit b7dcd6409a
10 changed files with 799 additions and 729 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
@ -37,6 +37,9 @@ $langs->load("sendings");
if (!$user->admin) accessforbidden(); if (!$user->admin) accessforbidden();
// positionne la variable pour le test d'affichage de l'icone
$expedition_addon_var_pdf = EXPEDITION_ADDON_PDF;
$expedition_default = EXPEDITION_ADDON;
/* /*
* Actions * Actions
@ -62,55 +65,83 @@ if ($_GET["action"] == 'set')
if ($_GET["action"] == 'setpdf') if ($_GET["action"] == 'setpdf')
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'EXPEDITION_ADDON_PDF';"; $db->begin();
$db->query($sql);
$sql='';
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('EXPEDITION_ADDON_PDF','".$_GET["value"]."',0)";
if ($db->query($sql)) $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'EXPEDITION_ADDON_PDF';";
$resql=$db->query($sql);
if ($resql)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('EXPEDITION_ADDON_PDF','".$_GET["value"]."',0)";
$resql=$db->query($sql);
if ($resql)
{ {
// la constante qui a été lue en avant du nouveau set // la constante qui a été lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage cohérent // on passe donc par une variable pour avoir un affichage cohérent
$expedition_addon_var_pdf = $value; $expedition_addon_var_pdf = $value;
$db->commit();
Header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
$db->rollback();
dolibarr_print_error($db);
}
}
else
{
$db->rollback();
dolibarr_print_error($db);
} }
Header("Location: expedition.php");
} }
llxHeader();
// positionne la variable pour le test d'affichage de l'icone
$expedition_addon_var_pdf = EXPEDITION_ADDON_PDF;
$expedition_default = EXPEDITION_DEFAULT;
if ($_GET["action"] == 'setdef') if ($_GET["action"] == 'setdef')
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'EXPEDITION_ADDON';"; $db->begin();
$db->query($sql);
$sql='';
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('EXPEDITION_ADDON','".$value."',0)";
if ($db->query($sql)) $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'EXPEDITION_ADDON';";
$resql=$db->query($sql);
if ($resql)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('EXPEDITION_ADDON','".$_GET["value"]."',0)";
$resql=$db->query($sql);
if ($resql)
{ {
// la constante qui a été lue en avant du nouveau set // la constante qui a été lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage cohérent // on passe donc par une variable pour avoir un affichage cohérent
$expedition_default = $_GET["value"]; $expedition_default = $_GET["value"];
$db->commit();
Header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
$db->rollback();
dolibarr_print_error($db);
}
}
else
{
$db->rollback();
dolibarr_print_error($db);
} }
} }
/* /*
*
*
* *
*/ */
llxHeader();
$dir = DOL_DOCUMENT_ROOT."/expedition/mods/"; $dir = DOL_DOCUMENT_ROOT."/expedition/mods/";
/*
* Méthode de livraison // Méthode de livraison
*/
print_titre($langs->trans("SendingsSetup")); print_titre($langs->trans("SendingsSetup"));
@ -118,15 +149,16 @@ print "<br>";
print_titre($langs->trans("SendingMethod")); print_titre($langs->trans("SendingMethod"));
print '<table class="noborder">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td><td>'.$langs->trans("Description").'</td>'; print '<td width="140">'.$langs->trans("Name").'</td><td>'.$langs->trans("Description").'</td>';
print '<td align="center" colspan="2">'.$langs->trans("Active").'</td>'; print '<td align="center" colspan="2">'.$langs->trans("Active").'</td>';
print '<td align="center" colspan="2">'.$langs->trans("Default").'</td>'; print '<td align="center">'.$langs->trans("Default").'</td>';
print "</tr>\n"; print "</tr>\n";
if(is_dir($dir)) { if(is_dir($dir)) {
$handle=opendir($dir); $handle=opendir($dir);
$var=true;
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
@ -139,7 +171,8 @@ if(is_dir($dir)) {
$obj = new $classname(); $obj = new $classname();
print '<tr class="pair"><td>'; $var=!$var;
print "<tr $bc[$var]><td>";
echo $obj->name; echo $obj->name;
print "</td><td>\n"; print "</td><td>\n";
@ -153,22 +186,21 @@ if(is_dir($dir)) {
print '<a href="expedition.php?action=set&amp;statut=1&amp;value='.$name.'">'.$langs->trans("Activate").'</a>'; print '<a href="expedition.php?action=set&amp;statut=1&amp;value='.$name.'">'.$langs->trans("Activate").'</a>';
print '</td><td align="center">'; print '</td>';
// Default
print '<td align="center">';
if ($expedition_default == "$name") if ($expedition_default == "$name")
{ {
print img_tick(); print img_tick();
} }
else else
{ {
print "&nbsp;"; print '<a href="expedition.php?action=setdef&amp;value='.$name.'">'.$langs->trans("Default").'</a>';
} }
print '</td>';
print "</td><td>\n"; print '</tr>';
print '<a href="expedition.php?action=setdef&amp;value='.$name.'">'.$langs->trans("Activate").'</a>';
print '</td></tr>';
} }
} }
closedir($handle); closedir($handle);
@ -181,17 +213,13 @@ print '</table>';
print '<br>'; print '<br>';
/* // PDF
*
* PDF
*
*/
print_titre($langs->trans("SendingsReceiptModel")); print_titre($langs->trans("SendingsReceiptModel"));
print '<table class="noborder">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td><td>'.$langs->trans("Description").'</td>'; print '<td width="140">'.$langs->trans("Name").'</td><td>'.$langs->trans("Description").'</td>';
print '<td align="center" colspan="2">'.$langs->trans("Active").'</td>'; print '<td align="center" colspan="2">'.$langs->trans("Active").'</td>';
print "</tr>\n"; print "</tr>\n";
@ -202,6 +230,7 @@ $dir = DOL_DOCUMENT_ROOT."/expedition/mods/pdf/";
if(is_dir($dir)) if(is_dir($dir))
{ {
$handle=opendir($dir); $handle=opendir($dir);
$var=true;
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
@ -210,8 +239,9 @@ if(is_dir($dir))
$name = substr($file, 15, strlen($file) - 27); $name = substr($file, 15, strlen($file) - 27);
$classname = substr($file, 0, strlen($file) - 12); $classname = substr($file, 0, strlen($file) - 12);
print '<tr class="pair"><td>'; $var=!$var;
echo "$name"; print "<tr $bc[$var]><td>";
print $name;
print "</td><td>\n"; print "</td><td>\n";
require_once($dir.$file); require_once($dir.$file);
$obj = new $classname(); $obj = new $classname();

View File

@ -161,5 +161,5 @@ print '<br>';
$db->close(); $db->close();
llxFooter(); llxFooter('$Date$ - $Revision$');
?> ?>

View File

@ -165,7 +165,7 @@ if ($_GET["action"] == 'facturee')
$commande->classer_facturee(); $commande->classer_facturee();
} }
if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == yes && $user->rights->commande->valider) if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->rights->commande->valider)
{ {
$commande = new Commande($db); $commande = new Commande($db);
$commande->fetch($_GET["id"]); $commande->fetch($_GET["id"]);
@ -174,14 +174,14 @@ if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == yes && $user->ri
$result = $commande->valid($user); $result = $commande->valid($user);
} }
if ($_POST["action"] == 'confirm_cancel' && $_POST["confirm"] == yes && $user->rights->commande->valider) if ($_POST["action"] == 'confirm_cancel' && $_POST["confirm"] == 'yes' && $user->rights->commande->valider)
{ {
$commande = new Commande($db); $commande = new Commande($db);
$commande->fetch($_GET["id"]); $commande->fetch($_GET["id"]);
$result = $commande->cancel($user); $result = $commande->cancel($user);
} }
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == yes) if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
{ {
if ($user->rights->commande->supprimer ) if ($user->rights->commande->supprimer )
{ {
@ -744,6 +744,10 @@ else
print '</div>'; print '</div>';
/*
* Boutons actions
*/
if ($user->societe_id == 0 && $commande->statut < 3 && $_GET["action"] == '') if ($user->societe_id == 0 && $commande->statut < 3 && $_GET["action"] == '')
{ {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
@ -881,6 +885,7 @@ else
print "</table>\n"; print "</table>\n";
print '</td><td valign="top" width="50%">'; print '</td><td valign="top" width="50%">';
} }
/* /*
* Classe la commande dans un projet * Classe la commande dans un projet
* TODO finir le look & feel très moche * TODO finir le look & feel très moche
@ -899,10 +904,6 @@ else
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Save").'"></td></tr></table></form>'; print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Save").'"></td></tr></table></form>';
} }
/*
*
*
*/
} }
else else
{ {

View File

@ -18,7 +18,6 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
/** /**
@ -37,28 +36,25 @@ if (!$user->rights->commande->lire)
require("../project.class.php"); require("../project.class.php");
require("../propal.class.php"); require("../propal.class.php");
require("../product/stock/entrepot.class.php"); require("../product/stock/entrepot.class.php");
/*
* Sécurité accés client // 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;
} }
/*
*
*/
if ($_POST["action"] == 'confirm_cloture' && $_POST["confirm"] == yes)
/*
* Actions
*/
if ($_POST["action"] == 'confirm_cloture' && $_POST["confirm"] == 'yes')
{ {
$commande = new Commande($db); $commande = new Commande($db);
$commande->fetch($_GET["id"]); $commande->fetch($_GET["id"]);
$result = $commande->cloture($user); $result = $commande->cloture($user);
} }
llxHeader('','Fiche commande','');
$html = new Form($db);
/* *************************************************************************** */ /* *************************************************************************** */
/* */ /* */
@ -66,6 +62,11 @@ $html = new Form($db);
/* */ /* */
/* *************************************************************************** */ /* *************************************************************************** */
llxHeader('','Fiche commande','');
$html = new Form($db);
if ($_GET["id"] > 0) if ($_GET["id"] > 0)
{ {
$commande = New Commande($db); $commande = New Commande($db);
@ -113,9 +114,6 @@ if ($_GET["id"] > 0)
$html->form_confirm("commande.php?id=".$_GET["id"],"Clôturer la commande","Etes-vous sûr de vouloir clôturer cette commande ?","confirm_cloture"); $html->form_confirm("commande.php?id=".$_GET["id"],"Clôturer la commande","Etes-vous sûr de vouloir clôturer cette commande ?","confirm_cloture");
print "<br />"; print "<br />";
} }
/*
*
*/
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="20%">'.$langs->trans("Customer").'</td>'; print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
@ -141,8 +139,8 @@ if ($_GET["id"] > 0)
if ($commande->note) if ($commande->note)
{ {
print '<tr><td>Note</td></tr>'; print '<tr><td>'.$langs->trans("Note").'</td></tr>';
print '<tr><td colspan="3">Note : '.nl2br($commande->note)."</td></tr>"; print '<tr><td colspan="3">'.nl2br($commande->note)."</td></tr>";
} }
print '</table><br />'; print '</table><br />';
@ -151,38 +149,40 @@ if ($_GET["id"] > 0)
* Lignes de commandes * Lignes de commandes
* *
*/ */
echo '<table class="liste" width="100%" cellspacing="0" cellpadding="3">'; echo '<table class="liste" width="100%">';
$sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice"; $sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice";
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as l "; $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as l ";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON (p.rowid = l.fk_product)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid";
$sql .= " WHERE l.fk_commande = ".$commande->id." AND p.fk_product_type <> 1 ORDER BY l.rowid"; $sql.= " WHERE l.fk_commande = ".$commande->id;
$sql.= " AND p.fk_product_type <> 1";
$sql.= " ORDER BY l.rowid";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows(); $num = $db->num_rows($resql);
$i = 0; $total = 0; $i = 0; $total = 0;
if ($num)
{
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td width="54%">'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Products").'</td>';
print '<td align="center">Quan. Commandée</td>'; print '<td align="center">Quan. Commandée</td>';
print '<td align="center">Quan. livrée</td>'; print '<td align="center">Quan. livrée</td>';
print '<td align="center">Reste à livrer</td>'; print '<td align="center">Reste à livrer</td>';
if (defined("MAIN_MODULE_STOCK")) if ($conf->stock->enabled)
{ {
print '<td width="12%" align="center">Stock</td>'; print '<td align="center">Stock</td>';
} }
print "</tr>\n"; print "</tr>\n";
}
$var=True; $var=true;
$reste_a_livrer = array(); $reste_a_livrer = array();
while ($i < $num) while ($i < $num)
{ {
$objp = $db->fetch_object(); $objp = $db->fetch_object();
print "<TR $bc[$var]>";
$var=!$var;
print "<tr $bc[$var]>";
if ($objp->fk_product > 0) if ($objp->fk_product > 0)
{ {
@ -194,7 +194,7 @@ if ($_GET["id"] > 0)
} }
else else
{ {
print "<td>".stripslashes(nl2br($objp->description))."</TD>\n"; print "<td>".stripslashes(nl2br($objp->description))."</td>\n";
} }
print '<td align="center">'.$objp->qty.'</td>'; print '<td align="center">'.$objp->qty.'</td>';
@ -211,7 +211,7 @@ if ($_GET["id"] > 0)
print $reste_a_livrer[$objp->fk_product]; print $reste_a_livrer[$objp->fk_product];
print '</td>'; print '</td>';
if (defined("MAIN_MODULE_STOCK")) if ($conf->stock->enabled)
{ {
if ($product->stock_reel < $reste_a_livrer_x) if ($product->stock_reel < $reste_a_livrer_x)
{ {
@ -229,6 +229,13 @@ if ($_GET["id"] > 0)
} }
$db->free(); $db->free();
print "</table>"; print "</table>";
if (! $num)
{
print $langs->trans("None").'<br>';
print '<br>';
}
} }
else else
{ {
@ -255,6 +262,10 @@ if ($_GET["id"] > 0)
print '<tr><td width="20%">'.$langs->trans("Warehouse").'</td>'; print '<tr><td width="20%">'.$langs->trans("Warehouse").'</td>';
print '<td>'; print '<td>';
$html->select_array("entrepot_id",$entrepot->list_array()); $html->select_array("entrepot_id",$entrepot->list_array());
if (sizeof($entrepot->list_array()) <= 0)
{
print ' &nbsp; Aucun entrepôt définit, <a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?action=create">definissez en un</a>';
}
print '</td></tr>'; print '</td></tr>';
/* /*
print '<tr><td width="20%">Mode d\'expédition</td>'; print '<tr><td width="20%">Mode d\'expédition</td>';
@ -262,28 +273,16 @@ if ($_GET["id"] > 0)
$html->select_array("entrepot_id",$entrepot->list_array()); $html->select_array("entrepot_id",$entrepot->list_array());
print '</td></tr>'; print '</td></tr>';
*/ */
print '<tr><td colspan="2" align="center">';
if (sizeof($entrepot->list_array()))
{
print '<input type="submit" value="Créer">'; print "</table><br>";
}
else
{
print 'Aucun entrepôt définit, <a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?action=create">definissez en un</a>';
}
print '</td></tr>';
print "</table>";
print "</form>\n"; print "</form>\n";
} }
/* /*
* Alerte de seuil * Alerte de seuil
*
*/ */
if ($reste_a_livrer_total > 0 && defined("MAIN_MODULE_STOCK")) if ($reste_a_livrer_total > 0 && $conf->stock->enabled)
{ {
print '<br><table class="liste" width="100%"><tr>'; print '<br><table class="liste" width="100%"><tr>';
foreach ($reste_a_livrer as $key => $value) foreach ($reste_a_livrer as $key => $value)
@ -312,6 +311,10 @@ if ($_GET["id"] > 0)
} }
$db->free($resql); $db->free($resql);
} }
else {
dolibarr_print_date($db);
}
} }
} }
print "</table>"; print "</table>";
@ -320,13 +323,18 @@ if ($_GET["id"] > 0)
print '</div>'; print '</div>';
/* /*
* * Boutons Actions
*
*/ */
if ($user->societe_id == 0) if ($user->societe_id == 0)
{ {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($user->rights->expedition->valider && $reste_a_livrer_total == 0 && $commande->statut < 3)
if ($user->rights->expedition->creer && $reste_a_livrer_total > 0 && $commande->brouillon == 0)
{
print '<a class="tabAction" href="fiche.php?action=create&commande_id='.$commande->id.'">'.$langs->trans("CreateSending").'</a>';
}
if ($user->rights->commande->creer && $reste_a_livrer_total == 0 && $commande->statut < 3)
{ {
print '<a class="tabAction" href="commande.php?id='.$commande->id.'&amp;action=cloture">'.$langs->trans("Close").'</a>'; print '<a class="tabAction" href="commande.php?id='.$commande->id.'&amp;action=cloture">'.$langs->trans("Close").'</a>';
} }
@ -337,9 +345,7 @@ if ($_GET["id"] > 0)
/* /*
* Déjà livré * Déjà livr
*
*
*/ */
$sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande, ed.qty as qty_livre, e.ref, e.rowid as expedition_id"; $sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande, ed.qty as qty_livre, e.ref, e.rowid as expedition_id";
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e"; $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e";
@ -383,16 +389,19 @@ if ($_GET["id"] > 0)
print '</table>'; print '</table>';
} }
} }
else {
dolibarr_print_date($db);
}
} }
else else
{ {
/* Commande non trouvée */ /* Commande non trouvée */
print "Commande inexistante ou accés refusé"; print "Commande inexistante";
} }
} }
$db->close(); $db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>"); llxFooter('$Date$ - $Revision$');
?> ?>

View File

@ -20,7 +20,7 @@
* *
*/ */
/*! /**
\file htdocs/expedition/expedition.class.php \file htdocs/expedition/expedition.class.php
\ingroup expedition \ingroup expedition
\brief Fichier de la classe de gestion des expeditions \brief Fichier de la classe de gestion des expeditions
@ -28,7 +28,7 @@
*/ */
/*! \class Expedition /** \class Expedition
\brief Classe de gestion des expeditions \brief Classe de gestion des expeditions
*/ */
class Expedition class Expedition
@ -58,10 +58,11 @@ class Expedition
$this->products = array(); $this->products = array();
} }
/** /**
* Créé * \brief Créé expédition en base
* * \param user Objet du user qui cré
* * \return int <0 si erreur, id expédition créée si ok
*/ */
function create($user) function create($user)
{ {
@ -70,22 +71,22 @@ class Expedition
/* On positionne en mode brouillon la commande */ /* On positionne en mode brouillon la commande */
$this->brouillon = 1; $this->brouillon = 1;
$this->user = $user; $this->user = $user;
$this->db->begin(); $this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (date_creation, fk_user_author, date_expedition, fk_commande, fk_entrepot) "; $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (date_creation, fk_user_author, date_expedition, fk_commande";
$sql .= " VALUES (now(), $user->id, ".$this->db->idate($this->date_expedition).",$this->commande_id, $this->entrepot_id)"; if ($this->entrepot_id) $sql.= ", fk_entrepot";
$sql.= ")";
$sql.= " VALUES (now(), $user->id, ".$this->db->idate($this->date_expedition).",$this->commande_id";
if ($this->entrepot_id) $sql.= ", $this->entrepot_id";
$sql.= ")";
if ( $this->db->query($sql) ) $resql=$this->db->query($sql);
if ($resql)
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expedition"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expedition");
/*
*
*
*/
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id; $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
@ -105,8 +106,8 @@ class Expedition
$error++; $error++;
} }
} }
/* /*
*
* *
*/ */
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->commande_id; $sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->commande_id;
@ -115,31 +116,36 @@ class Expedition
$error++; $error++;
} }
if ($error==0) if ($error==0)
{ {
$this->db->commit(); $this->db->commit();
}
else
{
$this->db->rollback();
}
return $this->id; return $this->id;
} }
else else
{ {
$error++; $error++;
return -1; $this->error=$this->db->error()." - sql=$sql";
$this->db->rollback();
return -3;
} }
} }
else else
{ {
$error++; $error++;
print $this->db->error() . '<b><br>'.$sql; $this->error=$this->db->error()." - sql=$sql";
return 0; $this->db->rollback();
return -2;
} }
} }
else
{
$error++;
$this->error=$this->db->error()." - sql=$sql";
$this->db->rollback();
return -1;
}
}
/** /**
* *
* *
@ -215,9 +221,9 @@ class Expedition
} }
/** /**
* Valide l'expedition * \brief Valide l'expedition
* * \param user Objet de l'utilisateur qui valide
* * \return int
*/ */
function valid($user) function valid($user)
{ {
@ -235,9 +241,11 @@ class Expedition
{ {
$result = 1; $result = 1;
// Si module stock géré et que expedition faite depuis un entrepot
if ($conf->stock->enabled && $this->entrepot_id)
{
/* /*
* Enregistrement d'un mouvement de stock * Enregistrement d'un mouvement de stock pour chaque produit de l'expedition
* pour chaque ligne produit de l'expedition
*/ */
$sql = "SELECT cd.fk_product, ed.qty "; $sql = "SELECT cd.fk_product, ed.qty ";
@ -256,17 +264,18 @@ class Expedition
$i++; $i++;
} }
} }
}
} }
else else
{ {
$result = -1; $result = -1;
print $this->db->error() . ' in ' . $sql; $this->error=$this->db->error()." - sql=".$sql;
} }
} }
return $result ; return $result ;
} }
/** /**
* Ajoute un produit * Ajoute un produit
* *

View File

@ -21,7 +21,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
@ -37,16 +37,16 @@ if (!$user->rights->expedition->lire)
require("../propal.class.php"); require("../propal.class.php");
require("../product/stock/entrepot.class.php"); require("../product/stock/entrepot.class.php");
/* // Sécurité accés client
* 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 ($_POST["action"] == 'add') if ($_POST["action"] == 'add')
@ -62,6 +62,8 @@ if ($_POST["action"] == 'add')
$commande->fetch($expedition->commande_id); $commande->fetch($expedition->commande_id);
$commande->fetch_lignes(); $commande->fetch_lignes();
$db->begin();
for ($i = 0 ; $i < sizeof($commande->lignes) ; $i++) for ($i = 0 ; $i < sizeof($commande->lignes) ; $i++)
{ {
$qty = "qtyl".$i; $qty = "qtyl".$i;
@ -72,17 +74,21 @@ if ($_POST["action"] == 'add')
} }
} }
$expedition->create($user); $ret=$expedition->create($user);
if ($ret > 0)
$id = $expedition->id; {
$db->commit();
Header("Location:fiche.php?id=$id"); Header("Location: fiche.php?id=".$expedition->id);
exit;
}
else
{
$db->rollback();
$mesg='<div class="error">'.$expedition->error.'</div>';
$_GET["commande_id"]=$_POST["commande_id"];
$_GET["action"]='create';
}
} }
/*
*
*/
if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->rights->expedition->valider) if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->rights->expedition->valider)
{ {
@ -110,6 +116,7 @@ if ($_GET["action"] == 'pdf')
$expedition->PdfWrite(); $expedition->PdfWrite();
} }
/* /*
* *
*/ */
@ -120,18 +127,22 @@ $html = new Form($db);
* *
* Mode creation * Mode creation
* *
* *********************************************************************/
************************************************************************/ if ($_GET["action"] == 'create')
if ($_POST["action"] == 'create')
{ {
llxHeader('','Fiche expedition','ch-expedition.html',$form_search); llxHeader('','Fiche expedition','ch-expedition.html',$form_search);
print_titre("Créer une expédition"); print_titre($langs->trans("CreateASending"));
if ($mesg)
{
print $mesg.'<br>';
}
$commande = new Commande($db); $commande = new Commande($db);
$commande->livraison_array(); $commande->livraison_array();
if ( $commande->fetch($_POST["commande_id"])) if ( $commande->fetch($_GET["commande_id"]))
{ {
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->soc_id); $soc->fetch($commande->soc_id);
@ -146,25 +157,25 @@ if ($_POST["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="commande_id" value="'.$commande->id.'">'; print '<input type="hidden" name="commande_id" value="'.$commande->id.'">';
print '<input type="hidden" name="entrepot_id" value="'.$_POST["entrepot_id"].'">'; print '<input type="hidden" name="entrepot_id" value="'.$_GET["entrepot_id"].'">';
print '<table class="border" cellspacing="0" cellpadding="2" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="20%">Client</td>'; print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
print '<td width="30%"><b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>'; print '<td width="30%"><b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
print '<td width="50%" colspan="2">'; print '<td width="50%" colspan="2">';
print "</td></tr>"; print "</td></tr>";
print "<tr><td>Date</td>"; print "<tr><td>".$langs->trans("Date")."</td>";
print "<td>".strftime("%A %d %B %Y",$commande->date)."</td>\n"; print "<td>".strftime("%A %d %B %Y",$commande->date)."</td>\n";
print '<td colspan="2" width="50%">Commande : ' . $commande->ref ; print '<td colspan="2" width="50%">'.$langs->trans("Order").': ' . $commande->ref;
print "</td></tr>\n"; print "</td></tr>\n";
print '<tr><td>Entrepôt</td>'; print '<tr><td>'.$langs->trans("Warehouse").'</td>';
print '<td>'; print '<td>';
$ents = $entrepot->list_array(); $ents = $entrepot->list_array();
print $ents[$_POST["entrepot_id"]]; print $ents[$_GET["entrepot_id"]];
print '</td>'; print '</td>';
print "<td>".$langs->trans("Author")."</td><td>$author->fullname</td>\n"; print "<td>".$langs->trans("Author")."</td><td>$author->fullname</td>\n";
@ -178,7 +189,7 @@ if ($_POST["action"] == 'create')
* Lignes de commandes * Lignes de commandes
* *
*/ */
echo '<br><table border="0" width="100%" cellspacing="0" cellpadding="3">'; echo '<br><table class="noborder" width="100%">';
$lignes = $commande->fetch_lignes(1); $lignes = $commande->fetch_lignes(1);
@ -195,16 +206,17 @@ if ($_POST["action"] == 'create')
print '<td align="center">Quan. commandée</td>'; print '<td align="center">Quan. commandée</td>';
print '<td align="center">Quan. livrée</td>'; print '<td align="center">Quan. livrée</td>';
print '<td align="center">Quan. à livrer</td>'; print '<td align="center">Quan. à livrer</td>';
if (defined("MAIN_MODULE_STOCK")) if ($conf->stock->enabled)
{ {
print '<td width="12%" align="center">Stock</td>'; print '<td width="12%" align="center">'.$langs->trans("Stock").'</td>';
} }
print "</tr>\n"; print "</tr>\n";
} }
$var=True; $var=true;
while ($i < $num) while ($i < $num)
{ {
$ligne = $commande->lignes[$i]; $ligne = $commande->lignes[$i];
$var=!$var;
print "<tr $bc[$var]>\n"; print "<tr $bc[$var]>\n";
if ($ligne->product_id > 0) if ($ligne->product_id > 0)
{ {
@ -216,7 +228,7 @@ if ($_POST["action"] == 'create')
} }
else else
{ {
print "<td>".nl2br($ligne->description)."</TD>\n"; print "<td>".nl2br($ligne->description)."</td>\n";
} }
print '<td align="center">'.$ligne->qty.'</td>'; print '<td align="center">'.$ligne->qty.'</td>';
@ -236,7 +248,7 @@ if ($_POST["action"] == 'create')
$quantite_commandee = $ligne->qty; $quantite_commandee = $ligne->qty;
$quantite_a_livrer = $quantite_commandee - $quantite_livree; $quantite_a_livrer = $quantite_commandee - $quantite_livree;
if (defined("MAIN_MODULE_STOCK")) if ($conf->stock->enabled)
{ {
$stock = $product->stock_entrepot[$_POST["entrepot_id"]]; $stock = $product->stock_entrepot[$_POST["entrepot_id"]];
@ -267,13 +279,13 @@ if ($_POST["action"] == 'create')
* *
*/ */
print '<tr><td align="center" colspan="3"><input type="submit" value="Créer"></td></tr>'; print '<tr><td align="center" colspan="4"><br><input type="submit" value="'.$langs->trans("Create").'"></td></tr>';
print "</table>"; print "</table>";
print '</form>'; print '</form>';
} }
else else
{ {
print $db->error() . "<br>$sql";; dolibarr_print_error($db);
} }
} }
else else
@ -283,6 +295,7 @@ else
/* */ /* */
/* *************************************************************************** */ /* *************************************************************************** */
{ {
if ($_GET["id"] > 0) if ($_GET["id"] > 0)
{ {
$expedition = New Expedition($db); $expedition = New Expedition($db);
@ -345,8 +358,8 @@ else
print '<input type="hidden" name="action" value="setremise">'; print '<input type="hidden" name="action" value="setremise">';
} }
print '<br /><table class="border" cellspacing="0" cellpadding="2" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="20%">Client</td>'; print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
print '<td width="30%">'; print '<td width="30%">';
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>'; print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
@ -354,17 +367,17 @@ else
print "</tr>"; print "</tr>";
print "<tr><td>Commande</td>"; print '<tr><td>'.$langs->trans("Order").'</td>';
print '<td><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id.'">'.$commande->ref."</a></td>\n"; print '<td><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id.'">'.$commande->ref."</a></td>\n";
print '<td>&nbsp;</td><td>&nbsp;</td></tr>'; print '<td>&nbsp;</td><td>&nbsp;</td></tr>';
print "<tr><td>Date</td>"; print '<tr><td>'.$langs->trans("Date").'</td>';
print "<td>".strftime("%A %d %B %Y",$expedition->date)."</td>\n"; print "<td>".strftime("%A %d %B %Y",$expedition->date)."</td>\n";
$entrepot = new Entrepot($db); $entrepot = new Entrepot($db);
$entrepot->fetch($expedition->entrepot_id); $entrepot->fetch($expedition->entrepot_id);
print '<td width="20%">Entrepôt</td><td><a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id.'">'.$entrepot->libelle.'</a></td></tr>'; print '<td width="20%">'.$langs->trans("Warehouse").'</td><td><a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id.'">'.$entrepot->libelle.'</a></td></tr>';
print "</table>\n"; print "</table>\n";
@ -386,18 +399,19 @@ else
$num_prod = $db->num_rows($resql); $num_prod = $db->num_rows($resql);
$i = 0; $i = 0;
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td width="54%">'.$langs->trans("Description").'</td>'; print '<td width="54%">'.$langs->trans("Products").'</td>';
print '<td align="center">Quan. commandée</td>'; print '<td align="center">Quan. commandée</td>';
print '<td align="center">Quan. livrée</td>'; print '<td align="center">Quan. livrée</td>';
print "</tr>\n"; print "</tr>\n";
$var=True; $var=true;
while ($i < $num_prod) while ($i < $num_prod)
{ {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
print "<TR $bc[$var]>";
$var=!$var;
print "<tr $bc[$var]>";
if ($objp->fk_product > 0) if ($objp->fk_product > 0)
{ {
print '<td>'; print '<td>';
@ -422,25 +436,28 @@ else
dolibarr_print_error($db); dolibarr_print_error($db);
} }
print "</table>\n"; print "</table><br>\n";
print "\n</div>\n";
/* /*
* *
*/ */
$file = $expedition->pdf_filename; $file = $expedition->pdf_filename;
if (file_exists($file)) if (file_exists($file))
{ {
print '<br /><table class="border" width="50%">'; print_titre($langs->trans("Documents"));
print '<table class="border" width="50%">';
print "<tr $bc[$var]><td>".$langs->trans("Sending")." PDF</td>"; print "<tr $bc[$var]><td>".$langs->trans("Sending")." PDF</td>";
$b = ereg_replace($conf->expedition->dir_output."/","",$file); $b = ereg_replace($conf->expedition->dir_output."/","",$file);
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=expedition&file='.urlencode($b).'">'.basename($file).'</a></td>'; print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=expedition&file='.urlencode($b).'">'.basename($file).'</a></td>';
print '<td align="right">'.filesize($file). ' bytes</td>'; print '<td align="right">'.filesize($file). ' bytes</td>';
print '<td align="right">'.strftime("%e %B %Y %H:%M:%S",filemtime($file)).'</td></tr>'; print '<td align="right">'.dolibarr_print_date(filemtime($file),"%d %B %Y %H:%M:%S").'</td></tr>';
print "</table>"; print "</table>";
} }
print "\n</div>\n";
/* /*
* *
@ -639,5 +656,5 @@ else
$db->close(); $db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>"); llxFooter('$Date$ - $Revision$');
?> ?>

View File

@ -24,7 +24,7 @@
require_once DOL_DOCUMENT_ROOT.'/includes/fpdf/DolibarrPdfBarCode.class.php'; require_once DOL_DOCUMENT_ROOT.'/includes/fpdf/DolibarrPdfBarCode.class.php';
Class ModelePdfExpedition extends DolibarrPdfBarCode Class pdf_expedition extends DolibarrPdfBarCode
{ {

View File

@ -24,7 +24,7 @@
require_once DOL_DOCUMENT_ROOT."/expedition/mods/pdf/pdf_expedition.class.php"; require_once DOL_DOCUMENT_ROOT."/expedition/mods/pdf/pdf_expedition.class.php";
Class pdf_expedition_rouget extends ModelePdfExpedition Class pdf_expedition_rouget extends pdf_expedition
{ {
function pdf_expedition_rouget($db=0) function pdf_expedition_rouget($db=0)

View File

@ -10,3 +10,5 @@ StatisticsOfSendings=Statistics of sendings
NbOfSendings=Number of sendings NbOfSendings=Number of sendings
SendingCard=Sending Card SendingCard=Sending Card
NewSending=New sending NewSending=New sending
CreateASending=Create a sending
CreateSending=Create sending

View File

@ -10,3 +10,5 @@ StatisticsOfSendings=Statistiques des exp
NbOfSendings=Nombre d'expéditions NbOfSendings=Nombre d'expéditions
SendingCard=Fiche Expédition SendingCard=Fiche Expédition
NewSending=Nouvelle expédition NewSending=Nouvelle expédition
CreateASending=Créer une expedition
CreateSending=Créer expedition