Maxi debuggage et amélioration du module expédition

This commit is contained in:
Laurent Destailleur 2006-06-24 17:10:32 +00:00
parent c830e432e4
commit 9f6e356684
22 changed files with 546 additions and 408 deletions

View File

@ -23,18 +23,18 @@
/** /**
\file htdocs/comm/adresse_livraison.class.php \file htdocs/comm/adresse_livraison.class.php
\ingroup societe \ingroup societe, expedition
\brief Fichier de la classe des adresses de livraison \brief Fichier de la classe des adresses de livraison
\version $Revision$ \version $Revision$
*/ */
/** /**
\class Societe \class AdresseLivraison
\brief Classe permettant la gestion des adresses de livraison \brief Classe permettant la gestion des adresses de livraison
*/ */
class Livraison class AdresseLivraison
{ {
var $db; var $db;
@ -55,7 +55,7 @@ class Livraison
* \param DB handler accès base de données * \param DB handler accès base de données
* \param id id societe (0 par defaut) * \param id id societe (0 par defaut)
*/ */
function Livraison($DB, $id=0) function AdresseLivraison($DB, $id=0)
{ {
global $conf; global $conf;

View File

@ -73,7 +73,6 @@ if (!$user->rights->commercial->client->voir && $socid && !$user->societe_id > 0
} }
} }
$livraison = new Livraison($db);
@ -83,6 +82,7 @@ $livraison = new Livraison($db);
if ($_POST["action"] == 'add' || $_POST["action"] == 'update') if ($_POST["action"] == 'add' || $_POST["action"] == 'update')
{ {
$livraison = new AdresseLivraison($db);
$livraison->socid = $_POST["socid"]; $livraison->socid = $_POST["socid"];
$livraison->label = $_POST["label"]; $livraison->label = $_POST["label"];
$livraison->nom = $_POST["nom"]; $livraison->nom = $_POST["nom"];
@ -161,7 +161,7 @@ if ($_POST["action"] == 'add' || $_POST["action"] == 'update')
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user->rights->societe->supprimer) if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user->rights->societe->supprimer)
{ {
$livraison = new Livraison($db); $livraison = new AdresseLivraison($db);
$result = $livraison->delete($_GET["idl"], $socid); $result = $livraison->delete($_GET["idl"], $socid);
if ($result == 0) if ($result == 0)
@ -195,6 +195,8 @@ if ($_GET["action"] == 'create' || $_POST["action"] == 'create')
* Fiche adresse de livraison en mode création * Fiche adresse de livraison en mode création
*/ */
$livraison = new AdresseLivraison($db);
if ($_POST["label"] && $_POST["nom"]) if ($_POST["label"] && $_POST["nom"])
{ {
$livraison->socid=$_POST["socid"]; $livraison->socid=$_POST["socid"];
@ -277,6 +279,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
/* /*
* Fiche societe en mode edition * Fiche societe en mode edition
*/ */
$livraison = new AdresseLivraison($db);
print_titre($langs->trans("EditDeliveyAdress")); print_titre($langs->trans("EditDeliveyAdress"));
@ -284,7 +287,6 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
{ {
if ($reload || ! $_POST["nom"]) if ($reload || ! $_POST["nom"])
{ {
$livraison = new Livraison($db);
$livraison->socid = $socid; $livraison->socid = $socid;
$livraison->fetch_adresse($idl); $livraison->fetch_adresse($idl);
} }
@ -365,92 +367,105 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
} }
else else
{ {
/* /*
* Fiche société en mode visu * Fiche société en mode visu
*/ */
$livraison = new Livraison($db); $livraison = new AdresseLivraison($db);
$result=$livraison->fetch($socid); $result=$livraison->fetch($socid);
$nblignes = sizeof($livraison->lignes); if ($result < 0)
if ($result < 0) {
{ dolibarr_print_error($db,$livraison->error);
dolibarr_print_error($db,$livraison->error); exit;
//exit; }
}
$societe=new Societe($db);
$societe->fetch($livraison->socid);
$head = societe_prepare_head($societe);
dolibarr_fiche_head($head, 'customer', $societe->nom);
$head = societe_prepare_head($livraison); // Confirmation de la suppression de la facture
if ($_GET["action"] == 'delete')
dolibarr_fiche_head($head, 'company', $livraison->nom_societe); {
$html = new Form($db);
$html->form_confirm("adresse_livraison.php?socid=".$livraison->socid."&amp;idl=".$_GET["idl"],$langs->trans("DeleteDeliveryAddress"),$langs->trans("ConfirmDeleteDeliveryAdress"),"confirm_delete");
print "<br />\n";
}
if ($livraison->error)
{
print '<div class="error">';
print $livraison->error;
print '</div>';
}
$nblignes = sizeof($livraison->lignes);
if ($nblignes)
{
for ($i = 0 ; $i < $nblignes ; $i++)
{
print '<table class="border" width="100%">';
print '<tr><td width="20%">'.$langs->trans('DeliveryAddressLabel').'</td><td colspan="3">'.$livraison->lignes[$i]->label.'</td>';
print '<td valign="top" colspan="2" width="50%" rowspan="6">'.$langs->trans('Note').' :<br>'.nl2br($livraison->lignes[$i]->note).'</td></tr>';
print '<tr><td width="20%">'.$langs->trans('Name').'</td><td colspan="3">'.$livraison->lignes[$i]->nom.'</td></tr>';
print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">".nl2br($livraison->lignes[$i]->adresse)."</td></tr>";
print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$livraison->lignes[$i]->cp."</td></tr>";
print '<tr><td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$livraison->lignes[$i]->ville."</td></tr>";
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'.$livraison->lignes[$i]->pays.'</td>';
print '</td></tr>';
print '</table>';
/*
*
*/
print '<div class="tabsAction">';
if ($user->rights->societe->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/adresse_livraison.php?socid='.$livraison->socid.'&amp;idl='.$livraison->lignes[$i]->idl.'&amp;action=edit">'.$langs->trans("Edit").'</a>';
}
if ($user->rights->societe->supprimer)
{
print '<a class="butActionDelete" href="'.DOL_URL_ROOT.'/comm/adresse_livraison.php?socid='.$livraison->socid.'&amp;idl='.$livraison->lignes[$i]->idl.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
}
print '</div>';
print '<br>';
}
}
else
{
print $langs->trans("None");
}
print '</div>';
// Confirmation de la suppression de la facture /*
if ($_GET["action"] == 'delete') * Bouton actions
{ */
$html = new Form($db);
$html->form_confirm("adresse_livraison.php?socid=".$livraison->socid."&amp;idl=".$_GET["idl"],$langs->trans("DeleteDeliveryAddress"),$langs->trans("ConfirmDeleteDeliveryAdress"),"confirm_delete"); if ($_GET["action"] == '')
print "<br />\n"; {
} print '<div class="tabsAction">';
if ($user->rights->societe->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/adresse_livraison.php?socid='.$livraison->socid.'&amp;action=create">'.$langs->trans("Add").'</a>';
}
print '</div>';
}
if ($livraison->error)
{
print '<div class="error">';
print $livraison->error;
print '</div>';
}
for ($i = 0 ; $i < $nblignes ; $i++)
{
print '<table class="border" width="100%">';
print '<tr><td width="20%">'.$langs->trans('DeliveryAddressLabel').'</td><td colspan="3">'.$livraison->lignes[$i]->label.'</td>';
print '<td valign="top" colspan="2" width="50%" rowspan="6">'.$langs->trans('Note').' :<br>'.nl2br($livraison->lignes[$i]->note).'</td></tr>';
print '<tr><td width="20%">'.$langs->trans('Name').'</td><td colspan="3">'.$livraison->lignes[$i]->nom.'</td></tr>';
print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">".nl2br($livraison->lignes[$i]->adresse)."</td></tr>";
print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$livraison->lignes[$i]->cp."</td></tr>";
print '<tr><td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$livraison->lignes[$i]->ville."</td></tr>";
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'.$livraison->lignes[$i]->pays.'</td>';
print '</td></tr>';
print '</table>';
/*
*
*/
print '<div class="tabsAction">';
if ($user->rights->societe->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/adresse_livraison.php?socid='.$livraison->socid.'&amp;idl='.$livraison->lignes[$i]->idl.'&amp;action=edit">'.$langs->trans("Edit").'</a>';
}
if ($user->rights->societe->supprimer)
{
print '<a class="butActionDelete" href="'.DOL_URL_ROOT.'/comm/adresse_livraison.php?socid='.$livraison->socid.'&amp;idl='.$livraison->lignes[$i]->idl.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
}
print '</div>';
print '<br>';
}
print '</div>';
if ($_GET["action"] == '')
{
print '<div class="tabsAction">';
if ($user->rights->societe->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/adresse_livraison.php?socid='.$livraison->socid.'&amp;action=create">'.$langs->trans("Add").'</a>';
}
print '</div>';
}
} }
$db->close(); $db->close();

View File

@ -1500,7 +1500,7 @@ else
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&amp;action=builddoc">'.$langs->trans("BuildPDF").'</a>'; print '<a class="butAction" href="fiche.php?id='.$commande->id.'&amp;action=builddoc">'.$langs->trans("BuildPDF").'</a>';
} }
// reBuild PDF // ReBuild PDF
if ($user->rights->commande->creer && $commande->statut >= 3) if ($user->rights->commande->creer && $commande->statut >= 3)
{ {
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&amp;action=builddoc">'.$langs->trans("RebuildPDF").'</a>'; print '<a class="butAction" href="fiche.php?id='.$commande->id.'&amp;action=builddoc">'.$langs->trans("RebuildPDF").'</a>';
@ -1521,7 +1521,7 @@ else
} }
// Ship // Ship
if ($conf->expedition->enabled && $commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer) if ($commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer)
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$_GET['id'].'">'.$langs->trans('ShipProduct').'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$_GET['id'].'">'.$langs->trans('ShipProduct').'</a>';
} }

View File

@ -212,20 +212,18 @@ $html = new Form($db);
/* Mode vue et edition */ /* Mode vue et edition */
/* */ /* */
/* *************************************************************************** */ /* *************************************************************************** */
if ( isset($mesg)) if (isset($mesg)) print $mesg;
print $mesg;
$id = $_GET["facid"]; $id = $_GET["facid"];
if ($id > 0) if ($id > 0)
{ {
$facture = New Facture($db); $facture = New Facture($db);
if ( $facture->fetch($_GET['facid'], $user->societe_id) > 0) if ( $facture->fetch($_GET['facid'], $user->societe_id) > 0)
{ {
$soc = new Societe($db, $facture->socidp); $facture->fetch_client();
$soc->fetch($facture->socidp);
$head = facture_prepare_head($facture);
$head = facture_prepare_head($facture); dolibarr_fiche_head($head, 'contact', $langs->trans('InvoiceCustomer'));
dolibarr_fiche_head($head, 'contact', $langs->trans('InvoiceCustomer'));
/* /*
* Facture synthese pour rappel * Facture synthese pour rappel
@ -238,9 +236,6 @@ if ($id > 0)
print "</td></tr>"; print "</td></tr>";
// Customer // Customer
if ( is_null($facture->client) )
$facture->fetch_client();
print "<tr><td>".$langs->trans("Company")."</td>"; print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$facture->client->getNomUrl(1,'compta').'</td></tr>'; print '<td colspan="3">'.$facture->client->getNomUrl(1,'compta').'</td></tr>';
print "</table>"; print "</table>";
@ -281,7 +276,7 @@ if ($id > 0)
print '</td>'; print '</td>';
print '<td colspan="1">'; print '<td colspan="1">';
print $conf->global->MAIN_INFO_SOCIETE_NOM; print $mysoc->nom;
print '</td>'; print '</td>';
print '<td colspan="1">'; print '<td colspan="1">';
@ -338,12 +333,12 @@ if ($id > 0)
print "</tr>\n"; print "</tr>\n";
$societe = new Societe($db); $societe = new Societe($db);
$var = true; $var = true;
foreach(array('internal','external') as $source) foreach(array('internal','external') as $source)
{ {
$tab = $facture->liste_contact(-1,$source); $tab = $facture->liste_contact(-1,$source);
$num=sizeof($tab); $num=sizeof($tab);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
@ -368,7 +363,7 @@ if ($id > 0)
} }
if ($tab[$i]['socid'] < 0) if ($tab[$i]['socid'] < 0)
{ {
print $conf->global->MAIN_INFO_SOCIETE_NOM; print $mysoc->nom;
} }
if (! $tab[$i]['socid']) if (! $tab[$i]['socid'])
{ {

View File

@ -157,17 +157,16 @@ class Conf
$this->commande->dir_output=DOL_DATA_ROOT."/commande"; $this->commande->dir_output=DOL_DATA_ROOT."/commande";
$this->commande->dir_images=DOL_DATA_ROOT."/commande/images"; $this->commande->dir_images=DOL_DATA_ROOT."/commande/images";
if (defined('MAIN_MODULE_EXPEDITION') && MAIN_MODULE_EXPEDITION) // Module expeditions
{ $this->expedition->enabled=defined("MAIN_MODULE_EXPEDITION")?MAIN_MODULE_EXPEDITION:0;
// Module expeditions // Sous module bons d'expedition
$this->expedition->enabled=defined("MAIN_SUBMODULE_EXPEDITION")?MAIN_SUBMODULE_EXPEDITION:0; $this->expedition_bon->enabled=defined("MAIN_SUBMODULE_EXPEDITION")?MAIN_SUBMODULE_EXPEDITION:0;
$this->expedition->dir_output=DOL_DATA_ROOT."/expedition"; $this->expedition->dir_output=DOL_DATA_ROOT."/expedition";
$this->expedition->dir_images=DOL_DATA_ROOT."/expedition/images"; $this->expedition->dir_images=DOL_DATA_ROOT."/expedition/images";
// Module bon de livraison // Sous module bons de livraison
$this->livraison->enabled=defined("MAIN_SUBMODULE_LIVRAISON")?MAIN_SUBMODULE_LIVRAISON:0; $this->livraison->enabled=defined("MAIN_SUBMODULE_LIVRAISON")?MAIN_SUBMODULE_LIVRAISON:0;
$this->livraison->dir_output=DOL_DATA_ROOT."/livraison"; $this->livraison->dir_output=DOL_DATA_ROOT."/livraison";
$this->livraison->dir_images=DOL_DATA_ROOT."/livraison/images"; $this->livraison->dir_images=DOL_DATA_ROOT."/livraison/images";
}
// Module societe // Module societe
$this->societe->enabled=defined("MAIN_MODULE_SOCIETE")?MAIN_MODULE_SOCIETE:0; $this->societe->enabled=defined("MAIN_MODULE_SOCIETE")?MAIN_MODULE_SOCIETE:0;

View File

@ -424,9 +424,8 @@ if ($_GET["id"] > 0)
} }
// Bouton expedier avec gestion des stocks // Bouton expedier avec 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->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer)
{ {
print '<form method="GET" action="'.DOL_URL_ROOT.'/expedition/fiche.php">'; print '<form method="GET" action="'.DOL_URL_ROOT.'/expedition/fiche.php">';
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.'">';
@ -587,7 +586,8 @@ if ($_GET["id"] > 0)
} }
$db->free($resql); $db->free($resql);
} }
else { else
{
dolibarr_print_error($db); dolibarr_print_error($db);
} }
} }

View File

@ -223,18 +223,20 @@ class Expedition extends CommonObject
if ($this->statut == 0) $this->brouillon = 1; if ($this->statut == 0) $this->brouillon = 1;
// ligne de produit associée à une expédition
$this->lignes = array(); $this->lignes = array();
$sql = "SELECT c.description, c.qty as qtycom, e.qty as qtyexp, e.fk_commande_ligne"; // TODO Supprimer cette partie. L'appelant qui fetch doit
$sql .= ", c.fk_product, c.label, p.ref"; // en fait appeler fetch_lignes pour charges ceci.
$sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as e"; $sql = "SELECT c.description, c.qty as qtycom, c.fk_product, c.label, ";
$sql .= " , ".MAIN_DB_PREFIX."commandedet as c"; $sql.= " e.qty as qtyexp, e.fk_commande_ligne,";
$sql .= " , ".MAIN_DB_PREFIX."product as p"; $sql.= " p.ref";
$sql .= " WHERE e.fk_expedition = ".$this->id; $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as e";
$sql .= " AND e.fk_commande_ligne = c.rowid"; $sql.= " , ".MAIN_DB_PREFIX."commandedet as c";
$sql .= " AND c.fk_product = p.rowid"; $sql.= " , ".MAIN_DB_PREFIX."product as p";
$sql.= " WHERE e.fk_expedition = ".$this->id;
$sql.= " AND e.fk_commande_ligne = c.rowid";
$sql.= " AND c.fk_product = p.rowid";
$resultp = $this->db->query($sql); $resultp = $this->db->query($sql);
if ($resultp) if ($resultp)
{ {
@ -245,10 +247,11 @@ class Expedition extends CommonObject
{ {
$objp = $this->db->fetch_object($resultp); $objp = $this->db->fetch_object($resultp);
$ligne = new ExpeditionLigne(); $ligne = new ExpeditionLigne($this->db);
$ligne->commande_ligne_id = $objp->fk_commande_ligne; $ligne->commande_ligne_id = $objp->fk_commande_ligne;
$ligne->product_desc = $objp->description; // Description ligne $ligne->product_desc = $objp->description; // Description ligne
$ligne->qty_expedition = $objp->qtyexp;
$ligne->qty_commande = $objp->qtycom; $ligne->qty_commande = $objp->qtycom;
$ligne->fk_product = $objp->fk_product; $ligne->fk_product = $objp->fk_product;
@ -432,7 +435,7 @@ class Expedition extends CommonObject
function addline( $id, $qty ) function addline( $id, $qty )
{ {
$num = sizeof($this->lignes); $num = sizeof($this->lignes);
$ligne = new ExpeditionLigne(); $ligne = new ExpeditionLigne($this->db);
$ligne->commande_ligne_id = $id; $ligne->commande_ligne_id = $id;
$ligne->qty = $qty; $ligne->qty = $qty;
@ -568,13 +571,13 @@ class Expedition extends CommonObject
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$ligne = new ExpeditionLigne(); $ligne = new ExpeditionLigne($this->db);
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$ligne->fk_product = $obj->fk_product; $ligne->fk_product = $obj->fk_product;
$ligne->qty_commande = $obj->qtycom; $ligne->qty_commande = $obj->qtycom;
$ligne->qty_expedition = $obj->qtyexp; $ligne->qty_expedition = $obj->qtyexp;
$ligne->description = stripslashes($obj->description); $ligne->description = $obj->description;
$this->lignes[$i] = $ligne; $this->lignes[$i] = $ligne;
$i++; $i++;

View File

@ -36,8 +36,10 @@ require_once(DOL_DOCUMENT_ROOT."/product.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");
$langs->load("companies");
$langs->load("bills"); $langs->load("bills");
$langs->load('deliveries'); $langs->load('deliveries');
$langs->load('orders');
$user->getrights('expedition'); $user->getrights('expedition');
if (!$user->rights->expedition->lire) if (!$user->rights->expedition->lire)
@ -183,6 +185,7 @@ if ($_GET["action"] == 'create')
$author->fetch(); $author->fetch();
$entrepot = new Entrepot($db); $entrepot = new Entrepot($db);
/* /*
* Commande * Commande
*/ */
@ -190,32 +193,62 @@ if ($_GET["action"] == 'create')
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="'.$_GET["entrepot_id"].'">'; print '<input type="hidden" name="entrepot_id" value="'.$_GET["entrepot_id"].'">';
print '<table class="border" width="100%">';
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="50%" colspan="2">';
print "</td></tr>"; print '<table class="border" width="100%">';
// Ref commande
print '<tr><td>'.$langs->trans("RefOrder").'</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref.'</a></td>';
print "</tr>\n";
// Ref commande client
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
print $langs->trans('RefCustomerOrderShort').'</td><td align="left">';
print '</td>';
if ($_GET['action'] != 'refcdeclient' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refcdeclient&amp;id='.$commande->id.'">'.img_edit($langs->trans('Edit')).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($user->rights->commande->creer && $_GET['action'] == 'refcdeclient')
{
print '<form action="fiche.php?id='.$id.'" method="post">';
print '<input type="hidden" name="action" value="set_ref_client">';
print '<input type="text" class="flat" size="20" name="ref_client" value="'.$commande->ref_client.'">';
print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
}
else
{
print $commande->ref_client;
}
print '</td>';
print '</tr>';
// Société
print '<tr><td>'.$langs->trans('Company').'</td>';
print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
print '</tr>';
// Date
print "<tr><td>".$langs->trans("Date")."</td>";
print '<td colspan="3">'.dolibarr_print_date($commande->date,"%A %d %B %Y")."</td></tr>\n";
print "<tr><td>".$langs->trans("Date")."</td>";
print "<td>".strftime("%A %d %B %Y",$commande->date)."</td>\n";
print '<td>'.$langs->trans("Order").'</td><td><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref.'</a>';
print "</td></tr>\n"; if ($conf->stock->enabled)
{
print '<tr><td>'.$langs->trans("Warehouse").'</td>'; print '<tr><td>'.$langs->trans("Warehouse").'</td>';
print '<td>'; print '<td colspan="3">';
$ents = $entrepot->list_array(); $ents = $entrepot->list_array();
print '<a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?id='.$_GET["entrepot_id"].'">'.img_object($langs->trans("ShowWarehouse"),'stock').' '.$ents[$_GET["entrepot_id"]].'</a>'; print '<a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?id='.$_GET["entrepot_id"].'">'.img_object($langs->trans("ShowWarehouse"),'stock').' '.$ents[$_GET["entrepot_id"]].'</a>';
print '</td>'; print '</td></tr>';
print "<td>".$langs->trans("Author")."</td><td>$author->fullname</td>\n"; }
if ($commande->note) if ($commande->note)
{ {
print '<tr><td colspan="3">Note : '.nl2br($commande->note)."</td></tr>"; print '<tr><td colspan="3">Note : '.nl2br($commande->note)."</td></tr>";
} }
print "</table>";
print "</table>";
/* /*
* Lignes de commandes * Lignes de commandes
@ -411,27 +444,34 @@ else
// Client // Client
print '<tr><td width="20%">'.$langs->trans("Customer").'</td>'; print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
print '<td width="30%">'.$soc->getNomUrl(1).'</td>'; print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
// Auteur
print '<td width="20%">'.$langs->trans("Author").'</td><td width="30%">'.$author->fullname.'</td>';
print "</tr>"; print "</tr>";
// Commande liée // Commande liée
print '<tr><td>'.$langs->trans("Order").'</td>'; print '<tr><td>'.$langs->trans("RefOrder").'</td>';
print '<td><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref."</a></td>\n"; print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref."</a></td>\n";
print '<td>&nbsp;</td><td>&nbsp;</td></tr>'; print '</tr>';
// Commande liée
print '<tr><td>'.$langs->trans("RefCustomerOrderShort").'</td>';
print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id.'">'.$commande->ref_client."</a></td>\n";
print '</tr>';
// Date // Date
print '<tr><td>'.$langs->trans("Date").'</td>'; print '<tr><td>'.$langs->trans("Date").'</td>';
print "<td>".strftime("%A %d %B %Y",$expedition->date)."</td>\n"; print '<td colspan="3">'.dolibarr_print_date($expedition->date,"%A %d %B %Y")."</td>\n";
print '</tr>';
// Entrepot
$entrepot = new Entrepot($db); if (!$conf->expedition->enabled && $conf->stock->enabled)
$entrepot->fetch($expedition->entrepot_id); {
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>'; // Entrepot
$entrepot = new Entrepot($db);
$entrepot->fetch($expedition->entrepot_id);
print '<tr><td width="20%">'.$langs->trans("Warehouse").'</td>';
print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id.'">'.$entrepot->libelle.'</a></td>';
print '</tr>';
}
print "</table>\n"; print "</table>\n";
/* /*
@ -439,10 +479,10 @@ else
*/ */
echo '<br><table class="noborder" width="100%">'; echo '<br><table class="noborder" width="100%">';
$sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande"; $sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande,";
$sql .= " , ed.qty as qty_livre"; $sql .= " ed.qty as qty_livre";
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."expeditiondet as ed"; $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."expeditiondet as ed";
$sql .= " WHERE ed.fk_expedition = $expedition->id AND cd.rowid = ed.fk_commande_ligne "; $sql .= " WHERE ed.fk_expedition = ".$expedition->id." AND cd.rowid = ed.fk_commande_ligne ";
$resql = $db->query($sql); $resql = $db->query($sql);
@ -573,7 +613,7 @@ else
print_titre($langs->trans("OtherSendingsForSameOrder")); print_titre($langs->trans("OtherSendingsForSameOrder"));
print '<table class="liste" width="100%">'; print '<table class="liste" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td align="left">'.$langs->trans("Sending").'</td>'; print '<td align="left">'.$langs->trans("Ref").'</td>';
print '<td>'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Description").'</td>';
print '<td align="center">'.$langs->trans("QtyShipped").'</td>'; print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
print '<td align="center">'.$langs->trans("Date").'</td>'; print '<td align="center">'.$langs->trans("Date").'</td>';
@ -585,7 +625,7 @@ else
$var=!$var; $var=!$var;
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td align="left"><a href="'.DOL_URL_ROOT.'/expedition/fiche.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.'<a></td>'; print '<td align="left" nowrap="nowrap"><a href="'.DOL_URL_ROOT.'/expedition/fiche.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->ref.'<a></td>';
if ($objp->fk_product > 0) if ($objp->fk_product > 0)
{ {
$product = new Product($db); $product = new Product($db);
@ -601,7 +641,7 @@ else
print "<td>".stripslashes(nl2br($objp->description))."</td>\n"; print "<td>".stripslashes(nl2br($objp->description))."</td>\n";
} }
print '<td align="center">'.$objp->qty_livre.'</td>'; print '<td align="center">'.$objp->qty_livre.'</td>';
print '<td align="center">'.dolibarr_print_date($objp->date_expedition).'</td>'; print '<td align="center" nowrap="nowrap">'.dolibarr_print_date($objp->date_expedition).'</td>';
print '</tr>'; print '</tr>';
$i++; $i++;
} }
@ -629,7 +669,7 @@ else
print_titre("Orders"); print_titre("Orders");
print '<table width="100%" class="border">'; print '<table width="100%" class="border">';
print "<tr $bc[$true]><td>".$langs->trans("Order")." PDF</td>"; print "<tr $bc[$true]><td>PDF</td>";
print '<td><a href="'.DOL_URL_ROOT.'/document.php?modulepart=commande&file='.urlencode($relativepath).'">'.$commande->ref.'.pdf</a></td>'; print '<td><a href="'.DOL_URL_ROOT.'/document.php?modulepart=commande&file='.urlencode($relativepath).'">'.$commande->ref.'.pdf</a></td>';
print '<td align="right">'.filesize($file). ' bytes</td>'; print '<td align="right">'.filesize($file). ' bytes</td>';
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>'; print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>';

View File

@ -88,28 +88,28 @@ function expedition_pdf_create($db, $id, $modele='', $outputlangs='')
$dir = DOL_DOCUMENT_ROOT."/expedition/mods/pdf/"; $dir = DOL_DOCUMENT_ROOT."/expedition/mods/pdf/";
$modelisok=0; $modelisok=0;
$liste=array();
// Positionne modele sur le nom du modele de commande à utiliser // Positionne modele sur le nom du modele de commande à utiliser
$file = "pdf_expedition_".$modele.".modules.php"; $file = "pdf_expedition_".$modele.".modules.php";
if ($modele && file_exists($dir.$file)) $modelisok=1; if ($modele && file_exists($dir.$file)) $modelisok=1;
// Si model pas encore bon // Si model pas encore bon
if (! $modelisok) if (! $modelisok)
{ {
if ($conf->global->EXPEDITION_ADDON_PDF) $modele = $conf->global->EXPEDITION_ADDON_PDF; if ($conf->global->EXPEDITION_ADDON_PDF) $modele = $conf->global->EXPEDITION_ADDON_PDF;
$file = "pdf_expedition_".$modele.".modules.php"; $file = "pdf_expedition_".$modele.".modules.php";
if (file_exists($dir.$file)) $modelisok=1; if (file_exists($dir.$file)) $modelisok=1;
} }
// Si model pas encore bon // Si model pas encore bon
if (! $modelisok) if (! $modelisok)
{ {
$liste=array();
$model=new ModelePDFExpedition(); $model=new ModelePDFExpedition();
$liste=$model->liste_modeles($db); $liste=$model->liste_modeles($db);
$modele=key($liste); // Renvoie premiere valeur de clé trouvé dans le tableau $modele=key($liste); // Renvoie premiere valeur de clé trouvé dans le tableau
$file = "pdf_expedition_".$modele.".modules.php"; $file = "pdf_expedition_".$modele.".modules.php";
if (file_exists($dir.$file)) $modelisok=1; if (file_exists($dir.$file)) $modelisok=1;
} }
// Charge le modele // Charge le modele
@ -126,11 +126,12 @@ function expedition_pdf_create($db, $id, $modele='', $outputlangs='')
$expeditionref = sanitize_string($expedition->ref); $expeditionref = sanitize_string($expedition->ref);
$dir = $conf->expedition->dir_output . "/" . $expeditionref; $dir = $conf->expedition->dir_output . "/" . $expeditionref;
$file = $dir . "/" . $expeditionref . ".pdf"; $file = $dir . "/" . $expeditionref . ".pdf";
if ($obj->generate($expedition, $file))
if ($obj->generate($expedition, $file) > 0)
// if ( $obj->write_pdf_file($id, $outputlangs) > 0) // if ( $obj->write_pdf_file($id, $outputlangs) > 0)
{ {
// on supprime l'image correspondant au preview // on supprime l'image correspondant au preview
// commande_delete_preview($db, $id); // expedition_delete_preview($db, $id);
return 1; return 1;
} }
else else
@ -144,7 +145,7 @@ function expedition_pdf_create($db, $id, $modele='', $outputlangs='')
{ {
if (! $conf->global->EXPEDITION_ADDON_PDF) if (! $conf->global->EXPEDITION_ADDON_PDF)
{ {
print $langs->trans("Error")." ".$langs->trans("Error_EPXEDITION_ADDON_PDF_NotDefined"); print $langs->trans("Error")." ".$langs->trans("Error_EXPEDITION_ADDON_PDF_NotDefined");
} }
else else
{ {

View File

@ -85,12 +85,47 @@ Class pdf_expedition_dorade extends ModelePdfExpedition
} }
function generate(&$objExpe, $filename) function generate(&$objExpe, $filename, $outputlangs='')
{ {
global $user,$conf,$langs,$mysoc;
if (! is_object($outputlangs)) $outputlangs=$langs;
$outputlangs->load("main");
$outputlangs->load("companies");
$outputlangs->load("bills");
$outputlangs->load("propal");
$outputlangs->load("products");
$outputlangs->setPhpLang();
$this->expe = $objExpe; $this->expe = $objExpe;
$this->expe->fetch_commande(); $this->expe->fetch_commande();
// Définition de $dir et $file
if ($this->expe->specimen)
{
$dir = $conf->propal->dir_output;
$file = $dir . "/SPECIMEN.pdf";
}
else
{
$expref = sanitize_string($this->expe->ref);
$dir = $conf->expedition->dir_output . "/" . $expref;
$file = $dir . "/" . $expref . ".pdf";
}
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
{
$this->error=$outputlangs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
$filename=$file;
$this->pdf = new ModelePdfExpedition(); $this->pdf = new ModelePdfExpedition();
$this->pdf->expe = &$this->expe; $this->pdf->expe = &$this->expe;

View File

@ -52,10 +52,19 @@ Class pdf_expedition_merou extends ModelePdfExpedition
//Creation du Document //Creation du Document
//Initialisation des données //Initialisation des données
//***************************** //*****************************
function generate(&$objExpe, $file) function generate(&$objExpe, $file, $outputlangs='')
{ {
global $user,$langs,$conf; global $user,$conf,$langs,$mysoc;
if (! is_object($outputlangs)) $outputlangs=$langs;
$outputlangs->load("main");
$outputlangs->load("companies");
$outputlangs->load("bills");
$outputlangs->load("propal");
$outputlangs->load("products");
$outputlangs->setPhpLang();
//Initialisation des langues //Initialisation des langues
$langs->load("main"); $langs->load("main");
$langs->load("bills"); $langs->load("bills");
@ -63,9 +72,11 @@ Class pdf_expedition_merou extends ModelePdfExpedition
//Generation de la fiche //Generation de la fiche
$this->expe = $objExpe; $this->expe = $objExpe;
$this->expe->fetch_commande(); $this->expe->fetch_commande();
//Creation du Client //Creation du Client
$soc = new Societe($this->db); $soc = new Societe($this->db);
$soc->fetch($this->expe->commande->socidp); $soc->fetch($this->expe->commande->socidp);
//Creation de l expediteur //Creation de l expediteur
$this->expediteur = $soc; $this->expediteur = $soc;
//Creation du destinataire //Creation du destinataire
@ -74,6 +85,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
//print_r($pdf->expe); //print_r($pdf->expe);
$idcontact = $this->expe->commande->getIdContact('external','DESTINATAIRE'); $idcontact = $this->expe->commande->getIdContact('external','DESTINATAIRE');
$this->destinataire->fetch($idcontact[0]); $this->destinataire->fetch($idcontact[0]);
//Creation du livreur //Creation du livreur
$idcontact = $this->expe->commande->getIdContact('internal','LIVREUR'); $idcontact = $this->expe->commande->getIdContact('internal','LIVREUR');
$this->livreur = new User($this->db,$idcontact[0]); $this->livreur = new User($this->db,$idcontact[0]);
@ -85,7 +97,8 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$expeditionref = sanitize_string($this->expe->ref); $expeditionref = sanitize_string($this->expe->ref);
$dir = $conf->expedition->dir_output . "/" . $expeditionref; $dir = $conf->expedition->dir_output . "/" . $expeditionref;
$file = $dir . "/" . $expeditionref . ".pdf"; $file = $dir . "/" . $expeditionref . ".pdf";
//Si le dossier n existe pas
//Si le dossier n existe pas
if (! file_exists($dir)) if (! file_exists($dir))
{ {
umask(0); umask(0);
@ -101,7 +114,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
if (file_exists($dir)) if (file_exists($dir))
{ {
// Initialisation Bon vierge // Initialisation Bon vierge
$pdf = new FPDF('l','mm','A5'); $pdf = new FPDF('l','mm',$this->format);
$pdf->Open(); $pdf->Open();
$pdf->AddPage(); $pdf->AddPage();
//Generation de l entete du fichier //Generation de l entete du fichier
@ -111,9 +124,13 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$pdf->SetAuthor($user->fullname); $pdf->SetAuthor($user->fullname);
$pdf->SetMargins(10, 10, 10); $pdf->SetMargins(10, 10, 10);
$pdf->SetAutoPageBreak(1,0); $pdf->SetAutoPageBreak(1,0);
$pdf->SetFont('Arial','', 7);
//Insertion de l entete //Insertion de l entete
$this->_pagehead($pdf, $this->expe); $this->_pagehead($pdf, $this->expe);
//Initiailisation des coordonnées
//Initialisation des coordonnées
$tab_top = 53; $tab_top = 53;
$tab_height = 70; $tab_height = 70;
$pdf->SetFillColor(240,240,240); $pdf->SetFillColor(240,240,240);
@ -264,7 +281,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$pdf->SetXY($Xoff,$Yoff); $pdf->SetXY($Xoff,$Yoff);
$pdf->SetFont('Arial','',8); $pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->MultiCell(0, 8, "Num Bon de Livraison : ".$exp->ref, '' , 'L'); $pdf->MultiCell(0, 8, $langs->trans("Ref: ").$exp->ref, '' , 'L');
//$this->Code39($Xoff+43, $Yoff+1, $this->expe->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true); //$this->Code39($Xoff+43, $Yoff+1, $this->expe->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
//Num Commande //Num Commande
$Yoff = $Yoff+10; $Yoff = $Yoff+10;
@ -272,7 +289,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$pdf->SetXY($Xoff,$Yoff); $pdf->SetXY($Xoff,$Yoff);
$pdf->SetFont('Arial','',8); $pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->MultiCell(0, 8, "Num Commande : ".$exp->commande->ref, '' , 'L'); $pdf->MultiCell(0, 8, $langs->trans("RefOrder").': '.$exp->commande->ref, '' , 'L');
//$this->Code39($Xoff+43, $Yoff+1, $exp->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true); //$this->Code39($Xoff+43, $Yoff+1, $exp->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
//Definition Emplacement du bloc Societe //Definition Emplacement du bloc Societe
$blSocX=11; $blSocX=11;
@ -345,12 +362,13 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$pdf->SetFont('Arial','B',8); $pdf->SetFont('Arial','B',8);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->MultiCell(50, 8, "Livreur(s) : ".$livreur->fullname, '' , 'L'); $pdf->MultiCell(50, 8, "Livreur(s) : ".$livreur->fullname, '' , 'L');
/**********************************/ /**********************************/
//Emplacement Informations Expediteur (Client) //Emplacement Informations Expediteur (Client)
/**********************************/ /**********************************/
$Ydef = $Yoff; $Ydef = $Yoff;
$blExpX=$Xoff-20; $blExpX=$Xoff-20;
$blW=50; $blW=52;
$Yoff = $Yoff+5; $Yoff = $Yoff+5;
$Ydef = $Yoff; $Ydef = $Yoff;
$blSocY = 1; $blSocY = 1;

View File

@ -66,10 +66,19 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
} }
function generate(&$objExpe, $filename) function generate(&$objExpe, $filename, $outputlangs='')
{ {
global $langs; global $user,$conf,$langs,$mysoc;
if (! is_object($outputlangs)) $outputlangs=$langs;
$outputlangs->load("main");
$outputlangs->load("companies");
$outputlangs->load("bills");
$outputlangs->load("propal");
$outputlangs->load("products");
$outputlangs->setPhpLang();
$this->expe = $objExpe; $this->expe = $objExpe;
$this->pdf = new FPDF(); $this->pdf = new FPDF();

View File

@ -146,31 +146,41 @@ function propale_pdf_create($db, $id, $modele='', $outputlangs='')
$langs->load("propale"); $langs->load("propale");
$dir = DOL_DOCUMENT_ROOT."/includes/modules/propale/"; $dir = DOL_DOCUMENT_ROOT."/includes/modules/propale/";
$modelisok=0;
// Positionne modele sur le nom du modele de facture à utiliser // Positionne modele sur le nom du modele de propale à utiliser
if (! strlen($modele)) $file = "pdf_propale_".$modele.".modules.php";
if ($modele && file_exists($dir.$file)) $modelisok=1;
// Si model pas encore bon
if (! $modelisok)
{ {
if ($conf->global->PROPALE_ADDON_PDF) if ($conf->global->PROPALE_ADDON_PDF) $modele = $conf->global->PROPALE_ADDON_PDF;
{ $file = "pdf_propale_".$modele.".modules.php";
$modele = $conf->global->PROPALE_ADDON_PDF; if (file_exists($dir.$file)) $modelisok=1;
}
else
{
print $langs->trans("Error")." ".$langs->trans("Error_PROPALE_ADDON_PDF_NotDefined");
return 0;
}
} }
// Charge le modele // Si model pas encore bon
$file = "pdf_propale_".$modele.".modules.php"; if (! $modelisok)
if (file_exists($dir.$file))
{ {
$classname = "pdf_propale_".$modele; $liste=array();
$model=new ModelePDFPropales();
$liste=$model->liste_modeles($db);
$modele=key($liste); // Renvoie premiere valeur de clé trouvé dans le tableau
$file = "pdf_propale_".$modele.".modules.php";
if (file_exists($dir.$file)) $modelisok=1;
}
// Charge le modele
if ($modelisok)
{
$classname = "pdf_expedition_".$modele;
require_once($dir.$file); require_once($dir.$file);
$obj = new $classname($db); $obj = new $classname($db);
if ( $obj->write_pdf_file($id, $outputlangs) > 0) if ($obj->write_pdf_file($id, $outputlangs) > 0)
{ {
// on supprime l'image correspondant au preview // on supprime l'image correspondant au preview
propale_delete_preview($db, $id); propale_delete_preview($db, $id);
@ -185,7 +195,14 @@ function propale_pdf_create($db, $id, $modele='', $outputlangs='')
} }
else else
{ {
print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file); if (! $conf->global->PROPALE_ADDON_PDF)
{
print $langs->trans("Error")." ".$langs->trans("Error_PROPALE_ADDON_PDF_NotDefined");
}
else
{
print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file);
}
return 0; return 0;
} }
} }

View File

@ -466,10 +466,6 @@ LDAPSetupForVersion2=LDAP server configured for version 2
ProductSetup=Products module setup ProductSetup=Products module setup
NumberOfProductShowInSelect=Max number of products in combos select lists (0=no limit) NumberOfProductShowInSelect=Max number of products in combos select lists (0=no limit)
ConfirmDeleteProductLineAbility=Confirmation of removal of a line produces in the forms ConfirmDeleteProductLineAbility=Confirmation of removal of a line produces in the forms
##### Sendings #####
SendingsSetup=Sending module setup
SendingsReceiptModel=Sending receipt model
SendingsAbility=Support sendings sheets
##### Syslog ##### ##### Syslog #####
SyslogSetup=Syslog module setup SyslogSetup=Syslog module setup
SyslogOutput=Log output SyslogOutput=Log output
@ -492,7 +488,11 @@ NewRSS=New RSS
##### Mailing ##### ##### Mailing #####
MailingSetup=Mailing module setup MailingSetup=Mailing module setup
MailingEMailFrom=Sender EMail (From) for emails sent by emailing module MailingEMailFrom=Sender EMail (From) for emails sent by emailing module
##### Sendings #####
SendingsSetup=Sending module setup
SendingsReceiptModel=Sending receipt model
SendingsAbility=Support sendings sheets for customer deliveries
##### Deliveries ##### ##### Deliveries #####
DeliveryOrderNumberingModules=Delivery order numbering module DeliveryOrderNumberingModules=Products deliveries receipt numbering module
DeliveryOrderModel=Delivery order model DeliveryOrderModel=Products deliveries receipt model
DeliveriesOrderAbility=Deliveries order ability DeliveriesOrderAbility=Products deliveries receipt ability

View File

@ -66,6 +66,7 @@ ComptaCard=Accountancy card
DraftOrders=Draft orders DraftOrders=Draft orders
RelatedOrders=Related orders RelatedOrders=Related orders
OnProcessOrders=On process orders OnProcessOrders=On process orders
RefOrder=Ref. order
RefCustomer=Ref. customer RefCustomer=Ref. customer
RefCustomerOrder=Ref. customer order RefCustomerOrder=Ref. customer order
CustomerOrder=Customer order CustomerOrder=Customer order

View File

@ -15,6 +15,7 @@ CreateASending=Create a sending
CreateSending=Create sending CreateSending=Create sending
QtyOrdered=Qty ordered QtyOrdered=Qty ordered
QtyShipped=Qty shipped QtyShipped=Qty shipped
QtyReceived=Qty received
KeepToShip=Keep to ship KeepToShip=Keep to ship
OtherSendingsForSameOrder=Other sendings already shipped OtherSendingsForSameOrder=Other sendings already shipped
SendingsToValidate=Sending to validate SendingsToValidate=Sending to validate

View File

@ -116,7 +116,7 @@ Module70Desc=Gestion des interventions
Module75Name=Déplacements Module75Name=Déplacements
Module75Desc=Gestion des déplacements Module75Desc=Gestion des déplacements
Module80Name=Expéditions Module80Name=Expéditions
Module80Desc=Gestion des expéditions et bons de livraison Module80Desc=Gestion des expéditions et réceptions client
Module85Name=Banques et caisses Module85Name=Banques et caisses
Module85Desc=Gestion des comptes financiers de type Comptes bancaires, postaux ou Caisses liquides Module85Desc=Gestion des comptes financiers de type Comptes bancaires, postaux ou Caisses liquides
Module86Name=OSCommerce Module86Name=OSCommerce
@ -466,10 +466,6 @@ LDAPSetupForVersion2=Serveur LDAP configur
ProductSetup=Configuration du module Produits ProductSetup=Configuration du module Produits
NumberOfProductShowInSelect=Nombre de produits max dans les listes déroulantes (0=aucune limite) NumberOfProductShowInSelect=Nombre de produits max dans les listes déroulantes (0=aucune limite)
ConfirmDeleteProductLineAbility=Confirmation de suppression d'une ligne produit dans les formulaires ConfirmDeleteProductLineAbility=Confirmation de suppression d'une ligne produit dans les formulaires
##### Sendings #####
SendingsSetup=Configuration du module Expéditions/Livraisons
SendingsReceiptModel=Modèle du bordereau d'expédition
SendingsAbility=Prise en charge des bons d'expéditions
##### Syslog ##### ##### Syslog #####
SyslogSetup=Configuration du module Syslog SyslogSetup=Configuration du module Syslog
SyslogOutput=Sortie des log SyslogOutput=Sortie des log
@ -492,7 +488,11 @@ NewRSS=Syndication d'un nouveau flux RSS
##### Mailing ##### ##### Mailing #####
MailingSetup=Configuration du module EMailing MailingSetup=Configuration du module EMailing
MailingEMailFrom=Email emetteur (From) des mails envoyés par EMailing MailingEMailFrom=Email emetteur (From) des mails envoyés par EMailing
##### Sendings #####
SendingsSetup=Configuration du module Expéditions/Livraisons
SendingsReceiptModel=Modèle du bordereau d'expédition
SendingsAbility=Prise en charge des bons d'expéditions vers le client
##### Deliveries ##### ##### Deliveries #####
DeliveryOrderNumberingModules=Module de numérotation des bons de livraison DeliveryOrderNumberingModules=Module de numérotation des bons de réception client
DeliveryOrderModel=Modèle de bon de livraison DeliveryOrderModel=Modèle de bon de réception client
DeliveriesOrderAbility=Prise en charge des bons de livraison DeliveriesOrderAbility=Prise en charge des bons de réception client

View File

@ -66,6 +66,7 @@ ComptaCard=Fiche compta
DraftOrders=Commandes brouillons DraftOrders=Commandes brouillons
RelatedOrders=Commandes rattachées RelatedOrders=Commandes rattachées
OnProcessOrders=Commandes en cours de traitement OnProcessOrders=Commandes en cours de traitement
RefOrder=Réf. commande
RefCustomer=Réf. client RefCustomer=Réf. client
RefCustomerOrder=Réf. commande client RefCustomerOrder=Réf. commande client
CustomerOrder=Commande client CustomerOrder=Commande client

View File

@ -15,6 +15,7 @@ CreateASending=Cr
CreateSending=Créer expedition CreateSending=Créer expedition
QtyOrdered=Qté commandée QtyOrdered=Qté commandée
QtyShipped=Qté expédiée QtyShipped=Qté expédiée
QtyReceived=Qté reçue
KeepToShip=Reste à expédier KeepToShip=Reste à expédier
OtherSendingsForSameOrder=Autres expéditions déjà envoyés OtherSendingsForSameOrder=Autres expéditions déjà envoyés
SendingsToValidate=Expéditions à valider SendingsToValidate=Expéditions à valider

View File

@ -46,7 +46,7 @@ function commande_prepare_head($commande)
$h++; $h++;
} }
if ($conf->expedition->enabled && $user->rights->expedition->lire) if (($conf->expedition->enabled || $conf->livraison->enabled) && $user->rights->expedition->lire)
{ {
$head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id; $head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id;
$head[$h][1] = $langs->trans("SendingCard"); $head[$h][1] = $langs->trans("SendingCard");
@ -60,7 +60,6 @@ function commande_prepare_head($commande)
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id; $head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
$head[$h][1] = $langs->trans("ComptaCard"); $head[$h][1] = $langs->trans("ComptaCard");
$head[$h][2] = 'accountancy'; $head[$h][2] = 'accountancy';
$hselected = $h;
$h++; $h++;
} }

View File

@ -21,8 +21,6 @@
* $Source$ * $Source$
*/ */
/** /**
\file htdocs/livraison/fiche.php \file htdocs/livraison/fiche.php
\ingroup livraison \ingroup livraison
@ -34,13 +32,9 @@ require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/livraison/mods/modules_livraison.php"); require_once(DOL_DOCUMENT_ROOT."/livraison/mods/modules_livraison.php");
require_once(DOL_DOCUMENT_ROOT."/expedition/expedition.class.php"); require_once(DOL_DOCUMENT_ROOT."/expedition/expedition.class.php");
if ($conf->stock->enabled) require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php");
if (!$conf->expedition->enabled && $conf->stock->enabled) $langs->load("sendings");
{
require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php");
}
$langs->load("bills"); $langs->load("bills");
$langs->load('deliveries'); $langs->load('deliveries');
@ -423,33 +417,34 @@ else
// Client // Client
print '<tr><td width="20%">'.$langs->trans("Customer").'</td>'; print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
print '<td width="30%">'; print '<td align="3">'.$soc->getNomUrl(1).'</td>';
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
// Auteur
print '<td width="20%">'.$langs->trans("Author").'</td><td width="30%">'.$author->fullname.'</td>';
print "</tr>"; print "</tr>";
// Commande liée // Commande liée
print '<tr><td>'.$langs->trans("Order").'</td>'; print '<tr><td>'.$langs->trans("RefOrder").'</td>';
print '<td><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id.'">'.$commande->ref."</a></td>\n"; print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref."</a></td>\n";
print '<td>&nbsp;</td><td>&nbsp;</td></tr>'; print '</tr>';
// Commande liée
print '<tr><td>'.$langs->trans("RefCustomerOrderShort").'</td>';
print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id.'">'.$commande->ref_client."</a></td>\n";
print '</tr>';
// Date // Date
print '<tr><td>'.$langs->trans("Date").'</td>'; print '<tr><td>'.$langs->trans("Date").'</td>';
print "<td>".dolibarr_print_date($livraison->date_creation,'%A %d %B %Y')."</td>\n"; print '<td colspan="3">'.dolibarr_print_date($livraison->date_creation,'%A %d %B %Y')."</td>\n";
print '</tr>';
if (!$conf->expedition->enabled && $conf->stock->enabled) if (!$conf->expedition->enabled && $conf->stock->enabled)
{ {
// Entrepot // Entrepot
$entrepot = new Entrepot($db); $entrepot = new Entrepot($db);
$entrepot->fetch($expedition->entrepot_id); $entrepot->fetch($livraison->entrepot_id);
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>'; print '<tr><td width="20%">'.$langs->trans("Warehouse").'</td>';
print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id.'">'.$entrepot->libelle.'</a></td>';
print '</tr>';
} }
print '</tr>';
print "</table>\n"; print "</table>\n";
/* /*
@ -457,10 +452,10 @@ else
*/ */
echo '<br><table class="noborder" width="100%">'; echo '<br><table class="noborder" width="100%">';
$sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande"; $sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande,";
$sql .= " , ld.qty as qty_livre"; $sql .= " ld.qty as qty_livre";
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."livraisondet as ld"; $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."livraisondet as ld";
$sql .= " WHERE ld.fk_livraison = $livraison->id AND cd.rowid = ld.fk_commande_ligne "; $sql .= " WHERE ld.fk_livraison = ".$livraison->id." AND cd.rowid = ld.fk_commande_ligne ";
$resql = $db->query($sql); $resql = $db->query($sql);
@ -472,7 +467,7 @@ else
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Products").'</td>'; print '<td>'.$langs->trans("Products").'</td>';
print '<td align="center">'.$langs->trans("QtyOrdered").'</td>'; print '<td align="center">'.$langs->trans("QtyOrdered").'</td>';
print '<td align="center">'.$langs->trans("QtyShipped").'</td>'; print '<td align="center">'.$langs->trans("QtyReceived").'</td>';
print "</tr>\n"; print "</tr>\n";
$var=true; $var=true;

View File

@ -32,7 +32,7 @@ require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
require_once(DOL_DOCUMENT_ROOT."/expedition/expedition.class.php"); require_once(DOL_DOCUMENT_ROOT."/expedition/expedition.class.php");
/** /**
\class Livraison \class Livraison
\brief Classe de gestion des bons de livraison \brief Classe de gestion des bons de livraison
*/ */
@ -40,7 +40,7 @@ class Livraison extends CommonObject
{ {
var $db; var $db;
var $id; var $id;
var $brouillon; var $brouillon;
var $commande_id; var $commande_id;
@ -69,16 +69,19 @@ class Livraison extends CommonObject
function create($user) function create($user)
{ {
global $conf; global $conf;
dolibarr_syslog("Livraison::create ");
require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php"; require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php";
$error = 0; $error = 0;
/* On positionne en mode brouillon le bon de livraison */ /* On positionne en mode brouillon le bon de livraison */
$this->brouillon = 1; $this->brouillon = 1;
$this->user = $user; $this->user = $user;
$this->db->begin(); $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 (date_creation, fk_user_author, fk_adresse_livraison";
if ($this->commande_id) $sql.= ", fk_commande"; if ($this->commande_id) $sql.= ", fk_commande";
if ($this->expedition_id) $sql.= ", fk_expedition"; if ($this->expedition_id) $sql.= ", fk_expedition";
@ -87,48 +90,49 @@ class Livraison extends CommonObject
if ($this->commande_id) $sql.= ", $this->commande_id"; if ($this->commande_id) $sql.= ", $this->commande_id";
if ($this->expedition_id) $sql.= ", $this->expedition_id"; if ($this->expedition_id) $sql.= ", $this->expedition_id";
$sql.= ")"; $sql.= ")";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."livraison"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."livraison");
$sql = "UPDATE ".MAIN_DB_PREFIX."livraison SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id; $numref="(PROV".$this->id.")";
if ($this->db->query($sql)) $sql = "UPDATE ".MAIN_DB_PREFIX."livraison ";
$sql.= "SET ref='".addslashes($numref)."' WHERE rowid=".$this->id;
$resql=$this->db->query($sql);
if ($resql)
{ {
if (! $conf->expedition->enabled)
{
$commande = new Commande($this->db);
$commande->id = $this->commande_id;
$this->lignes = $commande->fetch_lignes();
}
if (!$conf->expedition->enabled)
{
$commande = new Commande($this->db);
$commande->id = $this->commande_id;
$lignes = $commande->fetch_lignes();
}
/* /*
* Insertion des produits dans la base * Insertion des produits dans la base
*/ */
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
{ {
//TODO if (! $this->create_line(0, $this->lignes[$i]->commande_ligne_id, $this->lignes[$i]->qty))
if (! $this->create_line(0, $this->lignes[$i]->commande_ligne_id, $this->lignes[$i]->qty)) {
{ $error++;
$error++; }
}
} }
/* if (! $conf->expedition->enabled)
*
*/
if (!$conf->expedition->enabled)
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->commande_id; $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
if (! $this->db->query($sql)) $sql.= " SET fk_statut = 2";
$sql.= " WHERE rowid=".$this->commande_id;
$resql=$this->db->query($sql);
if (! $resql)
{ {
$error++; $error++;
} }
} }
if ($error==0) if ($error==0)
{ {
$this->db->commit(); $this->db->commit();
@ -137,7 +141,8 @@ class Livraison extends CommonObject
else else
{ {
$error++; $error++;
$this->error=$this->db->error()." - sql=$sql"; $this->error=$this->db->error()." - sql=".$this->db->lastqueryerror;
dolibarr_syslog("Livraison::create Error -3 ".$this->error);
$this->db->rollback(); $this->db->rollback();
return -3; return -3;
} }
@ -145,7 +150,8 @@ class Livraison extends CommonObject
else else
{ {
$error++; $error++;
$this->error=$this->db->error()." - sql=$sql"; $this->error=$this->db->error()." - sql=".$this->db->lastqueryerror;
dolibarr_syslog("Livraison::create Error -2 ".$this->error);
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }
@ -153,7 +159,8 @@ class Livraison extends CommonObject
else else
{ {
$error++; $error++;
$this->error=$this->db->error()." - sql=$sql"; $this->error=$this->db->error()." - sql=".$this->db->lastqueryerror;
dolibarr_syslog("Livraison::create Error -1 ".$this->error);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@ -168,7 +175,7 @@ class Livraison extends CommonObject
$error = 0; $error = 0;
$idprod = 0; $idprod = 0;
$j = 0; $j = 0;
while (($j < sizeof($this->commande->lignes)) && idprod == 0) while (($j < sizeof($this->commande->lignes)) && idprod == 0)
{ {
if ($this->commande->lignes[$j]->id == $commande_ligne_id) if ($this->commande->lignes[$j]->id == $commande_ligne_id)
@ -177,22 +184,22 @@ class Livraison extends CommonObject
} }
$j++; $j++;
} }
$sql = "INSERT INTO ".MAIN_DB_PREFIX."livraisondet (fk_livraison, fk_commande_ligne, qty)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."livraisondet (fk_livraison, fk_commande_ligne, qty)";
$sql .= " VALUES ($this->id,".$commande_ligne_id.",".$qty.")"; $sql .= " VALUES ($this->id,".$commande_ligne_id.",".$qty.")";
if (! $this->db->query($sql) ) if (! $this->db->query($sql) )
{ {
$error++; $error++;
} }
if ($error == 0 ) if ($error == 0 )
{ {
return 1; return 1;
} }
} }
/** /**
* *
* Lit un bon de livraison * Lit un bon de livraison
* *
@ -200,20 +207,20 @@ class Livraison extends CommonObject
function fetch ($id) function fetch ($id)
{ {
global $conf; global $conf;
$sql = "SELECT l.rowid, l.date_creation, l.date_valid, l.ref, l.fk_user_author,"; $sql = "SELECT l.rowid, l.date_creation, l.date_valid, l.ref, l.fk_user_author,";
$sql .=" l.fk_statut, l.fk_commande, l.fk_expedition, l.fk_user_valid, l.note, l.note_public"; $sql .=" l.fk_statut, l.fk_commande, l.fk_expedition, l.fk_user_valid, l.note, l.note_public";
$sql .= ", ".$this->db->pdate("l.date_livraison")." as date_livraison, l.fk_adresse_livraison, l.model_pdf"; $sql .= ", ".$this->db->pdate("l.date_livraison")." as date_livraison, l.fk_adresse_livraison, l.model_pdf";
$sql .= ", c.fk_soc"; $sql .= ", c.fk_soc";
$sql .= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c"; $sql .= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c";
$sql .= " WHERE l.rowid = ".$id." AND c.rowid = l.fk_commande"; $sql .= " WHERE l.rowid = ".$id." AND c.rowid = l.fk_commande";
$result = $this->db->query($sql) ; $result = $this->db->query($sql) ;
if ( $result ) if ( $result )
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->date_creation = $obj->date_creation; $this->date_creation = $obj->date_creation;
$this->date_valid = $obj->date_valid; $this->date_valid = $obj->date_valid;
@ -230,15 +237,15 @@ class Livraison extends CommonObject
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->db->free(); $this->db->free();
if ($this->user_author_id) if ($this->user_author_id)
{ {
$sql = "SELECT name, firstname"; $sql = "SELECT name, firstname";
$sql.= " FROM ".MAIN_DB_PREFIX."user"; $sql.= " FROM ".MAIN_DB_PREFIX."user";
$sql.= " WHERE rowid = ".$this->user_author_id; $sql.= " WHERE rowid = ".$this->user_author_id;
$resqluser = $this->db->query($sql); $resqluser = $this->db->query($sql);
if ($resqluser) if ($resqluser)
{ {
$obju = $this->db->fetch_object($resqluser); $obju = $this->db->fetch_object($resqluser);
@ -246,12 +253,12 @@ class Livraison extends CommonObject
$this->user_author_firstname = $obju->firstname; $this->user_author_firstname = $obju->firstname;
} }
} }
if ($this->statut == 0) $this->brouillon = 1; if ($this->statut == 0) $this->brouillon = 1;
$file = $conf->livraison->dir_output . "/" .get_exdir($livraison->id) . "/" . $this->id.".pdf"; $file = $conf->livraison->dir_output . "/" .get_exdir($livraison->id) . "/" . $this->id.".pdf";
$this->pdf_filename = $file; $this->pdf_filename = $file;
return 1; return 1;
} }
else else
@ -269,15 +276,15 @@ class Livraison extends CommonObject
function valid($user) function valid($user)
{ {
global $conf; global $conf;
require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php"; require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php";
dolibarr_syslog("livraison.class.php::valid begin"); dolibarr_syslog("livraison.class.php::valid begin");
$this->db->begin(); $this->db->begin();
$error = 0; $error = 0;
if ($user->rights->expedition->livraison->valider) if ($user->rights->expedition->livraison->valider)
{ {
if (defined('LIVRAISON_ADDON')) if (defined('LIVRAISON_ADDON'))
@ -285,7 +292,7 @@ class Livraison extends CommonObject
if (is_readable(DOL_DOCUMENT_ROOT .'/livraison/mods/'.LIVRAISON_ADDON.'.php')) if (is_readable(DOL_DOCUMENT_ROOT .'/livraison/mods/'.LIVRAISON_ADDON.'.php'))
{ {
require_once DOL_DOCUMENT_ROOT .'/livraison/mods/'.LIVRAISON_ADDON.'.php'; require_once DOL_DOCUMENT_ROOT .'/livraison/mods/'.LIVRAISON_ADDON.'.php';
// Definition du nom de module de numerotation de commande // Definition du nom de module de numerotation de commande
$modName=LIVRAISON_ADDON; $modName=LIVRAISON_ADDON;
@ -293,7 +300,7 @@ class Livraison extends CommonObject
$objMod = new $modName($this->db); $objMod = new $modName($this->db);
$soc = new Societe($this->db); $soc = new Societe($this->db);
$soc->fetch($this->socidp); $soc->fetch($this->socidp);
// on vérifie si le bon de livraison est en numérotation provisoire // on vérifie si le bon de livraison est en numérotation provisoire
$livref = substr($this->ref, 1, 4); $livref = substr($this->ref, 1, 4);
if ($livref == PROV) if ($livref == PROV)
@ -304,89 +311,89 @@ class Livraison extends CommonObject
{ {
$num = $this->ref; $num = $this->ref;
} }
// \todo Tester si non dejà au statut validé. Si oui, on arrete afin d'éviter // \todo Tester si non dejà au statut validé. Si oui, on arrete afin d'éviter
// de décrémenter 2 fois le stock. // de décrémenter 2 fois le stock.
$sql = "UPDATE ".MAIN_DB_PREFIX."livraison SET ref='$num', fk_statut = 1, date_valid=now(), fk_user_valid=$user->id"; $sql = "UPDATE ".MAIN_DB_PREFIX."livraison ";
$sql .= " WHERE rowid = $this->id AND fk_statut = 0"; $sql.= " SET ref='".addslashes($num)."', fk_statut = 1, date_valid=now(), fk_user_valid=".$user->id;
$sql.= " WHERE rowid = $this->id AND fk_statut = 0";
if ($this->db->query($sql) ) $resql=$this->db->query($sql);
{ if ($resql)
{
// Si module stock géré et que expedition faite depuis un entrepot
if (!$conf->expedition->enabled && $conf->stock->enabled && $this->entrepot_id)
{
// Si module stock géré et que expedition faite depuis un entrepot //Enregistrement d'un mouvement de stock pour chaque produit de l'expedition
if (!$conf->expedition->enabled && $conf->stock->enabled && $this->entrepot_id)
{
//Enregistrement d'un mouvement de stock pour chaque produit de l'expedition
dolibarr_syslog("livraison.class.php::valid enregistrement des mouvements");
$sql = "SELECT cd.fk_product, ld.qty "; dolibarr_syslog("livraison.class.php::valid enregistrement des mouvements");
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld";
$sql.= " WHERE ld.fk_livraison = $this->id AND cd.rowid = ld.fk_commande_ligne";
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i=0;
while($i < $num)
{
dolibarr_syslog("livraison.class.php::valid movment $i");
$obj = $this->db->fetch_object($resql); $sql = "SELECT cd.fk_product, ld.qty ";
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld";
$sql.= " WHERE ld.fk_livraison = $this->id AND cd.rowid = ld.fk_commande_ligne";
$mouvS = new MouvementStock($this->db); $resql=$this->db->query($sql);
$result=$mouvS->livraison($user, $obj->fk_product, $this->entrepot_id, $obj->qty); if ($resql)
if ($result < 0) {
{ $num = $this->db->num_rows($resql);
$this->db->rollback(); $i=0;
$this->error=$this->db->error()." - sql=$sql"; while($i < $num)
dolibarr_syslog("livraison.class.php::valid ".$this->error); {
return -3; dolibarr_syslog("livraison.class.php::valid movment $i");
}
$i++;
}
}
else
{
$this->db->rollback();
$this->error=$this->db->error()." - sql=$sql";
dolibarr_syslog("livraison.class.php::valid ".$this->error);
return -2;
}
}
// On efface le répertoire de pdf provisoire $obj = $this->db->fetch_object($resql);
$livraisonref = sanitize_string($this->ref);
if ($conf->expedition->dir_output) $mouvS = new MouvementStock($this->db);
$result=$mouvS->livraison($user, $obj->fk_product, $this->entrepot_id, $obj->qty);
if ($result < 0)
{ {
$dir = $conf->livraison->dir_output . "/" . $livraisonref ; $this->db->rollback();
$file = $dir . "/" . $livraisonref . ".pdf"; $this->error=$this->db->error()." - sql=$sql";
if (file_exists($file)) dolibarr_syslog("livraison.class.php::valid ".$this->error);
{ return -3;
if (!dol_delete_file($file)) }
{ $i++;
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file); }
return 0;
} }
} else
if (file_exists($dir)) {
{ $this->db->rollback();
if (!dol_delete_dir($dir)) $this->error=$this->db->error()." - sql=$sql";
{ dolibarr_syslog("livraison.class.php::valid ".$this->error);
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); return -2;
return 0;
} }
} }
}
// On efface le répertoire de pdf provisoire
dolibarr_syslog("livraison.class.php::valid ok"); $livraisonref = sanitize_string($this->ref);
} if ($conf->expedition->dir_output)
{
$dir = $conf->livraison->dir_output . "/" . $livraisonref ;
$file = $dir . "/" . $livraisonref . ".pdf";
if (file_exists($file))
{
if (!dol_delete_file($file))
{
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
return 0;
}
}
if (file_exists($dir))
{
if (!dol_delete_dir($dir))
{
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
return 0;
}
}
}
dolibarr_syslog("livraison.class.php::valid ok");
}
else else
{ {
$this->db->rollback(); $this->db->rollback();
@ -411,22 +418,23 @@ class Livraison extends CommonObject
/** \brief Créé le bon de livraison depuis une expédition existante /** \brief Créé le bon de livraison depuis une expédition existante
\param user Utilisateur qui crée \param user Utilisateur qui crée
\param sending_id id de l'expédition qui sert de modèle \param sending_id Id de l'expédition qui sert de modèle
*/ */
function create_from_sending($user, $sending_id) function create_from_sending($user, $sending_id)
{ {
$expedition = new Expedition($this->db); $expedition = new Expedition($this->db);
$expedition->fetch($sending_id); $result=$expedition->fetch($sending_id);
$this->lines = array(); $this->lines = array();
$this->date_livraison = time(); $this->date_livraison = time();
$this->expedition_id = $sending_id; $this->expedition_id = $sending_id;
for ($i = 0 ; $i < sizeof($expedition->lignes) ; $i++) for ($i = 0 ; $i < sizeof($expedition->lignes) ; $i++)
{ {
$LivraisonLigne = new LivraisonLigne(); $LivraisonLigne = new LivraisonLigne($this->db);
$LivraisonLigne->commande_ligne_id = $expedition->lignes[$i]->commande_ligne_id; $LivraisonLigne->commande_ligne_id = $expedition->lignes[$i]->commande_ligne_id;
$LivraisonLigne->libelle = $expedition->lignes[$i]->libelle; $LivraisonLigne->libelle = $expedition->lignes[$i]->libelle;
$LivraisonLigne->description = $expedition->lignes[$i]->product_desc; $LivraisonLigne->description = $expedition->lignes[$i]->product_desc;
$LivraisonLigne->qty = $expedition->lignes[$i]->qty_commande; $LivraisonLigne->qty = $expedition->lignes[$i]->qty_expedition;
$LivraisonLigne->fk_product = $expedition->lignes[$i]->fk_product; $LivraisonLigne->fk_product = $expedition->lignes[$i]->fk_product;
$LivraisonLigne->ref = $expedition->lignes[$i]->ref; $LivraisonLigne->ref = $expedition->lignes[$i]->ref;
$this->lignes[$i] = $LivraisonLigne; $this->lignes[$i] = $LivraisonLigne;
@ -449,7 +457,7 @@ class Livraison extends CommonObject
function addline( $id, $qty ) function addline( $id, $qty )
{ {
$num = sizeof($this->lignes); $num = sizeof($this->lignes);
$ligne = new livraisonLigne(); $ligne = new livraisonLigne($this->db);
$ligne->commande_ligne_id = $id; $ligne->commande_ligne_id = $id;
$ligne->qty = $qty; $ligne->qty = $qty;
@ -457,7 +465,7 @@ class Livraison extends CommonObject
$this->lignes[$num] = $ligne; $this->lignes[$num] = $ligne;
} }
/** /**
* *
* *
*/ */
@ -466,11 +474,11 @@ class Livraison extends CommonObject
if ($this->statut == 0) if ($this->statut == 0)
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet WHERE rowid = $idligne"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet WHERE rowid = $idligne";
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
$this->update_price(); $this->update_price();
return 1; return 1;
} }
else else
@ -488,13 +496,13 @@ class Livraison extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."livraisondet WHERE fk_livraison = $this->id ;"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."livraisondet WHERE fk_livraison = $this->id ;";
if ( $this->db->query($sql) ) if ( $this->db->query($sql) )
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."livraison WHERE rowid = $this->id;"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."livraison WHERE rowid = $this->id;";
if ( $this->db->query($sql) ) if ( $this->db->query($sql) )
{ {
$this->db->commit(); $this->db->commit();
// On efface le répertoire de pdf provisoire // On efface le répertoire de pdf provisoire
$livref = sanitize_string($this->ref); $livref = sanitize_string($this->ref);
if ($conf->livraison->dir_output) if ($conf->livraison->dir_output)
@ -518,7 +526,7 @@ class Livraison extends CommonObject
} }
} }
} }
return 1; return 1;
} }
else else
@ -544,12 +552,12 @@ class Livraison extends CommonObject
$this->commande =& new Commande($this->db); $this->commande =& new Commande($this->db);
$this->commande->fetch($this->commande_id); $this->commande->fetch($this->commande_id);
} }
/** /**
* *
* *
*/ */
function fetch_adresse_livraison($id) function fetch_adresse_livraison($id)
{ {
$idadresse = $id; $idadresse = $id;
@ -563,7 +571,7 @@ class Livraison extends CommonObject
{ {
$this->lignes = array(); $this->lignes = array();
$sql = "SELECT c.label, c.description, c.qty as qtycom, l.qty as qtyliv"; $sql = "SELECT c.label, c.description, c.qty as qtycom, l.qty as qtyliv";
$sql .= ", c.fk_product, c.price, p.ref"; $sql .= ", c.fk_product, c.price, p.ref";
$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."commandedet as c";
@ -581,7 +589,7 @@ class Livraison extends CommonObject
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$ligne = new LivraisonLigne(); $ligne = new LivraisonLigne($this->db);
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
@ -593,9 +601,9 @@ class Livraison extends CommonObject
$ligne->description = stripslashes($obj->description); $ligne->description = stripslashes($obj->description);
$ligne->price = $obj->price; $ligne->price = $obj->price;
$this->lignes[$i] = $ligne; $this->lignes[$i] = $ligne;
$i++; $i++;
} }
$this->db->free($resql); $this->db->free($resql);
} }