Dbut modification expedition livraison

Phase1: modification des expeditions
- elles pourront dsormais etre li  une propale (pas encore effectif)
- l'id entrepot est stock dans la ligne produit
This commit is contained in:
Regis Houssin 2008-01-17 10:27:59 +00:00
parent 857e8c0726
commit c19f0c753f
20 changed files with 1167 additions and 902 deletions

View File

@ -73,9 +73,6 @@ $socid = restrictedArea($user, $module, $objectid, $dbtable);
// Nombre de ligne pour choix de produit/service predefinis // Nombre de ligne pour choix de produit/service predefinis
$NBLINES=4; $NBLINES=4;
$form=new Form($db);
/******************************************************************************/ /******************************************************************************/
/* Actions */ /* Actions */
@ -854,10 +851,10 @@ if ($_GET['propalid'] > 0)
print '</td>'; print '</td>';
if ($conf->projet->enabled) $rowspan++; if ($conf->projet->enabled) $rowspan++;
if ($conf->expedition->enabled) if ($conf->expedition->enabled || $conf->livraison->enabled)
{ {
if ($conf->global->PROPALE_ADD_SHIPPING_DATE) $rowspan++; if ($conf->global->PROPALE_ADD_SHIPPING_DATE || !$conf->commande->enabled) $rowspan++;
if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS) $rowspan++; if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS || !$conf->commande->enabled) $rowspan++;
} }
// Notes // Notes
@ -901,7 +898,7 @@ if ($_GET['propalid'] > 0)
// gerer par les commandes et non les propales // gerer par les commandes et non les propales
if ($conf->expedition->enabled || $conf->livraison->enabled) if ($conf->expedition->enabled || $conf->livraison->enabled)
{ {
if ($conf->global->PROPALE_ADD_SHIPPING_DATE) if ($conf->global->PROPALE_ADD_SHIPPING_DATE || !$conf->commande->enabled)
{ {
$langs->load('deliveries'); $langs->load('deliveries');
print '<tr><td>'; print '<tr><td>';
@ -928,7 +925,7 @@ if ($_GET['propalid'] > 0)
} }
// adresse de livraison // adresse de livraison
if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS) if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS || !$conf->commande->enabled)
{ {
print '<tr><td>'; print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
@ -1014,11 +1011,11 @@ if ($_GET['propalid'] > 0)
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($_GET['action'] == 'classer') if ($_GET['action'] == 'classer')
{ {
$form->form_project($_SERVER['PHP_SELF'].'?propalid='.$propal->id, $propal->socid, $propal->projetidp, 'projetidp'); $html->form_project($_SERVER['PHP_SELF'].'?propalid='.$propal->id, $propal->socid, $propal->projetidp, 'projetidp');
} }
else else
{ {
$form->form_project($_SERVER['PHP_SELF'].'?propalid='.$propal->id, $propal->socid, $propal->projetidp, 'none'); $html->form_project($_SERVER['PHP_SELF'].'?propalid='.$propal->id, $propal->socid, $propal->projetidp, 'none');
} }
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -1207,7 +1207,7 @@ class Commande extends CommonObject
$sql = 'SELECT fk_product, sum(ed.qty)'; $sql = 'SELECT fk_product, sum(ed.qty)';
$sql.=' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed, '.MAIN_DB_PREFIX.'expedition as e, '.MAIN_DB_PREFIX.'commande as c, '.MAIN_DB_PREFIX.'commandedet as cd'; $sql.=' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed, '.MAIN_DB_PREFIX.'expedition as e, '.MAIN_DB_PREFIX.'commande as c, '.MAIN_DB_PREFIX.'commandedet as cd';
$sql.=' WHERE ed.fk_expedition = e.rowid AND ed.fk_commande_ligne = cd .rowid AND cd.fk_commande = c.rowid'; $sql.=' WHERE ed.fk_expedition = e.rowid AND ed.fk_origin_line = cd.rowid AND cd.fk_commande = c.rowid';
$sql.=' AND cd.fk_commande =' .$this->id; $sql.=' AND cd.fk_commande =' .$this->id;
if ($filtre_statut >= 0) $sql.=' AND e.fk_statut = '.$filtre_statut; if ($filtre_statut >= 0) $sql.=' AND e.fk_statut = '.$filtre_statut;
$sql .= ' GROUP BY fk_product '; $sql .= ' GROUP BY fk_product ';
@ -2402,7 +2402,7 @@ class CommandeLigne
{ {
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$this->rowid = $objp->rowid; $this->rowid = $objp->rowid;
$this->fk_propal = $objp->fk_propal; $this->fk_commande = $objp->fk_commande;
$this->desc = $objp->description; $this->desc = $objp->description;
$this->qty = $objp->qty; $this->qty = $objp->qty;
$this->price = $objp->price; $this->price = $objp->price;

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2006 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -140,7 +140,6 @@ if ($_GET["id"] > 0)
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Société // Société
print '<tr><td>'.$langs->trans('Company').'</td>'; print '<tr><td>'.$langs->trans('Company').'</td>';
print '<td colspan="3">'.$soc->getNomUrl(1).'</td>'; print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
@ -187,7 +186,6 @@ if ($_GET["id"] > 0)
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Adresse de livraison // Adresse de livraison
print '<tr><td height="10">'; print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
@ -292,14 +290,14 @@ if ($_GET["id"] > 0)
* Lignes de commandes avec quantité livrées et reste à livrer * Lignes de commandes avec quantité livrées et reste à livrer
* Les quantités livrées sont stockées dans $commande->expeditions[fk_product] * Les quantités livrées sont stockées dans $commande->expeditions[fk_product]
*/ */
echo '<table class="liste" width="100%">'; print '<table class="liste" width="100%">';
$sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.subprice"; $sql = "SELECT cd.fk_product, cd.description, cd.price, cd.qty, cd.rowid, cd.tva_tx, cd.subprice";
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as l "; $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd ";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
$sql.= " WHERE l.fk_commande = ".$commande->id; $sql.= " WHERE cd.fk_commande = ".$commande->id;
$sql.= " AND p.fk_product_type <> 1"; $sql.= " AND p.fk_product_type <> 1";
$sql.= " ORDER BY l.rowid"; $sql.= " ORDER BY cd.rowid";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
@ -404,11 +402,9 @@ if ($_GET["id"] > 0)
// Bouton expedier sans gestion des stocks // Bouton expedier sans gestion des stocks
if (! $conf->stock->enabled && $reste_a_livrer_total > 0 && ! $commande->brouillon && $user->rights->expedition->creer) if (! $conf->stock->enabled && $reste_a_livrer_total > 0 && ! $commande->brouillon && $user->rights->expedition->creer)
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/fiche.php?action=create&amp;commande_id='.$_GET["id"].'">'.$langs->trans("NewSending").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/fiche.php?action=create&amp;object_id='.$_GET["id"].'">'.$langs->trans("NewSending").'</a>';
} }
print "</div>"; print "</div>";
} }
print '<table width="100%"><tr><td width="50%" valign="top">'; print '<table width="100%"><tr><td width="50%" valign="top">';
@ -427,10 +423,8 @@ if ($_GET["id"] > 0)
$somethingshown=$html->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf); $somethingshown=$html->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf);
print '</td><td valign="top" width="50%">'; print '</td><td valign="top" width="50%">';
// Bouton expedier avec gestion des stocks // Bouton expedier avec gestion des stocks
if ($conf->stock->enabled && $reste_a_livrer_total > 0 && $commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer) if ($conf->stock->enabled && $reste_a_livrer_total > 0 && $commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer)
{ {
@ -439,14 +433,13 @@ if ($_GET["id"] > 0)
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.'">';
print '<input type="hidden" name="commande_id" value="'.$commande->id.'">'; print '<input type="hidden" name="origin" value="commande">';
print '<input type="hidden" name="origin_id" value="'.$commande->id.'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
$entrepot = new Entrepot($db); $entrepot = new Entrepot($db);
$langs->load("stocks"); $langs->load("stocks");
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("Warehouse").'</td>'; print '<td>'.$langs->trans("Warehouse").'</td>';
print '<td>'; print '<td>';
@ -498,7 +491,7 @@ if ($_GET["id"] > 0)
$sql .= " , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e"; $sql .= " , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e";
if ($conf->livraison->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid"; if ($conf->livraison->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid";
$sql .= " WHERE cd.fk_commande = ".$commande->id; $sql .= " WHERE cd.fk_commande = ".$commande->id;
$sql .= " AND cd.rowid = ed.fk_commande_ligne"; $sql .= " AND cd.rowid = ed.fk_origin_line";
$sql .= " AND ed.fk_expedition = e.rowid"; $sql .= " AND ed.fk_expedition = e.rowid";
$sql .= " ORDER BY cd.fk_product"; $sql .= " ORDER BY cd.fk_product";

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be> * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2005-2008 Régis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -29,7 +30,8 @@
*/ */
require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php"); require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
/** /**
@ -40,9 +42,12 @@ class Expedition extends CommonObject
{ {
var $db; var $db;
var $id; var $id;
var $socid;
var $brouillon; var $brouillon;
var $entrepot_id; var $entrepot_id;
var $modelpdf; var $modelpdf;
var $origin;
var $origin_id;
/** /**
@ -70,20 +75,22 @@ class Expedition extends CommonObject
*/ */
function create($user) function create($user)
{ {
global $conf;
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 la commande */ /* On positionne en mode brouillon l'expedition */
$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"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (date_creation, fk_user_author, date_expedition";
if ($this->entrepot_id) $sql.= ", fk_entrepot"; $sql.= ", fk_soc";
$sql.= ")"; $sql.= ")";
$sql.= " VALUES (now(), $user->id, ".$this->db->idate($this->date_expedition).",$this->commande_id"; $sql.= " VALUES (now(), $user->id, ".$this->db->idate($this->date_expedition);
if ($this->entrepot_id) $sql.= ", $this->entrepot_id"; $sql.= ", ".$this->socid;
$sql.= ")"; $sql.= ")";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
@ -94,29 +101,48 @@ class Expedition extends CommonObject
$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))
{ {
$this->commande = new Commande($this->db);
$this->commande->id = $this->commande_id;
$this->commande->fetch_lines();
// Insertion des lignes // Insertion des lignes
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
{ {
if (! $this->create_line(0, $this->lignes[$i]->commande_ligne_id, $this->lignes[$i]->qty)) if (! $this->create_line($this->lignes[$i]->entrepot_id, $this->lignes[$i]->origin_line_id, $this->lignes[$i]->qty))
{ {
$error++; $error++;
} }
} }
/* if ($this->id && $this->origin_id)
* {
*/ if ($conf->commande->enabled)
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->commande_id; {
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'co_exp (fk_expedition, fk_commande) VALUES ('.$this->id.','.$this->origin_id.')';
if (!$this->db->query($sql)) if (!$this->db->query($sql))
{ {
$error++; $error++;
} }
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->origin_id;
if (! $this->db->query($sql))
{
$error++;
}
}
else
{
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'pr_exp (fk_expedition, fk_propal) VALUES ('.$this->id.','.$this->origin_id.')';
if (!$this->db->query($sql))
{
$error++;
}
//Todo: definir un statut
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 9 WHERE rowid=".$this->origin_id;
if (! $this->db->query($sql))
{
$error++;
}
}
}
if ($error==0) if ($error==0)
{ {
$this->db->commit(); $this->db->commit();
@ -151,23 +177,12 @@ class Expedition extends CommonObject
* *
* *
*/ */
function create_line($transaction, $commande_ligne_id, $qty) function create_line($entrepot_id, $origin_line_id, $qty)
{ {
$error = 0; $error = 0;
$idprod = 0; $sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet (fk_expedition, fk_entrepot, fk_origin_line, qty)";
$j = 0; $sql .= " VALUES (".$this->id.", ".$entrepot_id.", ".$origin_line_id.", ".$qty.")";
while (($j < sizeof($this->commande->lignes)) && idprod == 0)
{
if ($this->commande->lignes[$j]->id == $commande_ligne_id)
{
$idprod = $this->commande->lignes[$j]->fk_product;
}
$j++;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet (fk_expedition, fk_commande_ligne, qty)";
$sql .= " VALUES ($this->id,".$commande_ligne_id.",".$qty.")";
if (! $this->db->query($sql) ) if (! $this->db->query($sql) )
{ {
@ -188,15 +203,15 @@ class Expedition extends CommonObject
{ {
global $conf; global $conf;
$sql = "SELECT e.rowid, e.date_creation, e.ref, e.fk_user_author, e.fk_statut, e.fk_commande, e.fk_entrepot,"; $sql = "SELECT e.rowid, e.fk_soc as socid, e.date_creation, e.ref, e.fk_user_author, e.fk_statut";
$sql.= " ".$this->db->pdate("e.date_expedition")." as date_expedition, e.model_pdf,"; $sql.= ", ".$this->db->pdate("e.date_expedition")." as date_expedition, e.model_pdf, e.fk_adresse_livraison";
$sql.= " c.fk_adresse_livraison"; if ($conf->commande->enabled) $sql.=", ce.fk_commande as origin_id";
if ($conf->livraison->enabled) $sql.=", l.rowid as livraison_id"; if ($conf->livraison->enabled) $sql.=", l.rowid as livraison_id";
$sql.= " FROM ".MAIN_DB_PREFIX."commande as c,"; $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
$sql.= " ".MAIN_DB_PREFIX."expedition as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."co_exp as ce ON e.rowid = ce.fk_expedition";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON ce.fk_commande = c.rowid";
if ($conf->livraison->enabled) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON e.rowid = l.fk_expedition"; if ($conf->livraison->enabled) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON e.rowid = l.fk_expedition";
$sql.= " WHERE e.rowid = ".$id; $sql.= " WHERE e.rowid = ".$id;
$sql.= " AND e.fk_commande = c.rowid";
$result = $this->db->query($sql) ; $result = $this->db->query($sql) ;
@ -208,17 +223,17 @@ class Expedition extends CommonObject
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref = $obj->ref; $this->ref = $obj->ref;
$this->socid = $obj->socid;
$this->statut = $obj->fk_statut; $this->statut = $obj->fk_statut;
$this->commande_id = $obj->fk_commande; $this->origin_id = $obj->origin_id;
if ($conf->livraison->enabled)
{
$this->livraison_id = $obj->livraison_id; $this->livraison_id = $obj->livraison_id;
}
$this->user_author_id = $obj->fk_user_author; $this->user_author_id = $obj->fk_user_author;
$this->date = $obj->date_expedition; $this->date = $obj->date_expedition;
$this->entrepot_id = $obj->fk_entrepot;
$this->adresse_livraison_id = $obj->fk_adresse_livraison; $this->adresse_livraison_id = $obj->fk_adresse_livraison;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
if ($conf->commande->enabled) $this->origin = "commande";
$this->db->free($result); $this->db->free($result);
if ($this->statut == 0) $this->brouillon = 1; if ($this->statut == 0) $this->brouillon = 1;
@ -416,12 +431,13 @@ class Expedition extends CommonObject
* Ajoute une ligne * Ajoute une ligne
* *
*/ */
function addline( $id, $qty ) function addline( $entrepot_id, $id, $qty )
{ {
$num = sizeof($this->lignes); $num = sizeof($this->lignes);
$ligne = new ExpeditionLigne($this->db); $ligne = new ExpeditionLigne($this->db);
$ligne->commande_ligne_id = $id; $ligne->entrepot_id = $entrepot_id;
$ligne->origin_line_id = $id;
$ligne->qty = $qty; $ligne->qty = $qty;
$this->lignes[$num] = $ligne; $this->lignes[$num] = $ligne;
@ -440,7 +456,6 @@ class Expedition extends CommonObject
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
$this->update_price(); $this->update_price();
return 1; return 1;
} }
else else
@ -449,6 +464,7 @@ class Expedition extends CommonObject
} }
} }
} }
/** /**
* Supprime la fiche * Supprime la fiche
* *
@ -457,10 +473,10 @@ class Expedition extends CommonObject
{ {
$this->db->begin(); $this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition = $this->id ;"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition = ".$this->id;
if ( $this->db->query($sql) ) if ( $this->db->query($sql) )
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition WHERE rowid = $this->id;"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition WHERE rowid = ".$this->id;
if ( $this->db->query($sql) ) if ( $this->db->query($sql) )
{ {
$this->db->commit(); $this->db->commit();
@ -488,7 +504,6 @@ class Expedition extends CommonObject
} }
} }
} }
return 1; return 1;
} }
else else
@ -504,7 +519,6 @@ class Expedition extends CommonObject
} }
} }
/** /**
* Classe la commande * Classe la commande
* *
@ -553,27 +567,29 @@ class Expedition extends CommonObject
/* /*
* Lit la commande associée * Lit le document associé
* *
*/ */
function fetch_commande() function fetch_object($object)
{ {
$this->commande = & new Commande($this->db); $class = ucfirst($object);
$this->commande->fetch($this->commande_id); $this->$object = & new $class($this->db);
$this->$object->fetch($this->origin_id);
} }
function fetch_lines() function fetch_lines()
{ {
$sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.qty as qty_commande"; //Todo: récupérer les champs du document associé a part
$sql.= ", ed.qty as qty_expedie, ed.fk_commande_ligne";
$sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.qty as qty_asked";
$sql.= ", ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot";
$sql.= ", p.ref, p.label, p.weight, p.weight_units, p.volume, p.volume_units"; $sql.= ", p.ref, p.label, p.weight, p.weight_units, p.volume, p.volume_units";
$sql.= " FROM (".MAIN_DB_PREFIX."commandedet as cd"; $sql.= " FROM (".MAIN_DB_PREFIX."commandedet as cd";
$sql.= ", ".MAIN_DB_PREFIX."expeditiondet as ed)"; $sql.= ", ".MAIN_DB_PREFIX."expeditiondet as ed)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON (p.rowid = cd.fk_product)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON (p.rowid = cd.fk_product)";
$sql.= " WHERE ed.fk_expedition = ".$this->id; $sql.= " WHERE ed.fk_expedition = ".$this->id;
$sql.= " AND ed.fk_commande_ligne = cd.rowid"; $sql.= " AND ed.fk_origin_line = cd.rowid";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
@ -585,13 +601,14 @@ class Expedition extends CommonObject
$ligne = new ExpeditionLigne($this->db); $ligne = new ExpeditionLigne($this->db);
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$ligne->order_line_id = $obj->fk_commande_ligne; $ligne->origin_line_id = $obj->fk_origin_line;
$ligne->entrepot_id = $obj->fk_entrepot;
$ligne->fk_product = $obj->fk_product; $ligne->fk_product = $obj->fk_product;
$ligne->ref = $obj->ref; $ligne->ref = $obj->ref;
$ligne->libelle = $obj->label; $ligne->libelle = $obj->label;
$ligne->description = $obj->description; $ligne->description = $obj->description;
$ligne->qty_commande = $obj->qty_commande; $ligne->qty_asked = $obj->qty_asked;
$ligne->qty_expedie = $obj->qty_expedie; $ligne->qty_shipped = $obj->qty_shipped;
$ligne->weight = $obj->weight; $ligne->weight = $obj->weight;
$ligne->weight_units = $obj->weight_units; $ligne->weight_units = $obj->weight_units;
$ligne->volume = $obj->volume; $ligne->volume = $obj->volume;
@ -734,8 +751,8 @@ class ExpeditionLigne
var $qty_expedition; var $qty_expedition;
var $fk_product; var $fk_product;
// From llx_commandedet // From llx_commandedet or llx_propaldet
var $qty_commande; var $qty_asking;
var $libelle; // Label produit var $libelle; // Label produit
var $product_desc; // Description produit var $product_desc; // Description produit
var $ref; var $ref;

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com> * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2005-2007 Régis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2008 Régis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -34,6 +34,7 @@ require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT ."/expedition/mods/pdf/ModelePdfExpedition.class.php"); require_once(DOL_DOCUMENT_ROOT ."/expedition/mods/pdf/ModelePdfExpedition.class.php");
if ($conf->produit->enabled) require_once(DOL_DOCUMENT_ROOT."/product.class.php"); if ($conf->produit->enabled) require_once(DOL_DOCUMENT_ROOT."/product.class.php");
if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
if ($conf->stock->enabled) require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php"); if ($conf->stock->enabled) require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php");
$langs->load("companies"); $langs->load("companies");
@ -55,6 +56,8 @@ if ($user->societe_id > 0)
$socid = $user->societe_id; $socid = $user->societe_id;
} }
$origin = $_GET["origin"]?$_GET["origin"]:$_POST["origin"];
$origin_id = $_GET["origin_id"]?$_GET["origin_id"]:$_POST["origin_id"];
/* /*
* Actions * Actions
@ -62,8 +65,6 @@ if ($user->societe_id > 0)
if ($_POST["action"] == 'add') if ($_POST["action"] == 'add')
{ {
// \todo Mettre id entrepot sur ligne detail expedition et non sur fiche expedition
$db->begin(); $db->begin();
// Creation de l'objet expedition // Creation de l'objet expedition
@ -71,21 +72,27 @@ if ($_POST["action"] == 'add')
$expedition->date_expedition = time(); $expedition->date_expedition = time();
$expedition->note = $_POST["note"]; $expedition->note = $_POST["note"];
$expedition->commande_id = $_POST["commande_id"]; $expedition->origin = $origin;
$expedition->entrepot_id = $_POST["entrepot_id"]; $expedition->origin_id = $origin_id;
// On boucle sur chaque ligne de commande pour compléter objet expedition // On boucle sur chaque ligne du document d'origine pour compléter objet expedition
// avec qté à livrer // avec qté à livrer
$commande = new Commande($db); $class = ucfirst($expedition->origin);
$commande->fetch($expedition->commande_id); $object = new $class($db);
$commande->fetch_lines(); $object->fetch($expedition->origin_id);
for ($i = 0 ; $i < sizeof($commande->lignes) ; $i++) //$object->fetch_lines();
$expedition->socid = $object->socid;
for ($i = 0 ; $i < sizeof($object->lignes) ; $i++)
{ {
$qty = "qtyl".$i; $ent = "entl".$i;
$idl = "idl".$i; $idl = "idl".$i;
$qty = "qtyl".$i;
$entrepot_id = $_POST[$ent]?$_POST[$ent]:$_POST["entrepot_id"];
if ($_POST[$qty] > 0) if ($_POST[$qty] > 0)
{ {
$expedition->addline($_POST[$idl],$_POST[$qty]); $expedition->addline($entrepot_id,$_POST[$idl],$_POST[$qty]);
} }
} }
@ -186,26 +193,29 @@ if ($_GET["action"] == 'create')
print $mesg.'<br>'; print $mesg.'<br>';
} }
$commande = new Commande($db); $class = ucfirst($origin);
$commande->loadExpeditions();
if ( $commande->fetch($_GET["commande_id"])) $object = new $class($db);
$object->loadExpeditions();
if ( $object->fetch($origin_id))
{ {
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->socid); $soc->fetch($object->socid);
$author = new User($db); $author = new User($db);
$author->id = $commande->user_author_id; $author->id = $object->user_author_id;
$author->fetch(); $author->fetch();
$entrepot = new Entrepot($db); $entrepot = new Entrepot($db);
/* /*
* Commande * Document source
*/ */
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="origin" value="'.$origin.'">';
print '<input type="hidden" name="origin_id" value="'.$object->id.'">';
if ($_GET["entrepot_id"]) if ($_GET["entrepot_id"])
{ {
print '<input type="hidden" name="entrepot_id" value="'.$_GET["entrepot_id"].'">'; print '<input type="hidden" name="entrepot_id" value="'.$_GET["entrepot_id"].'">';
@ -213,41 +223,34 @@ if ($_GET["action"] == 'create')
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref commande // Ref
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 '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>'; if ($conf->commande->enabled)
print $langs->trans('RefCustomerOrderShort').'</td><td align="left">';
print '</td>';
if ($_GET['action'] != 'RefCustomerOrder' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=RefCustomerOrder&amp;id='.$commande->id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($user->rights->commande->creer && $_GET['action'] == 'RefCustomerOrder')
{ {
print '<form action="fiche.php?id='.$id.'" method="post">'; print $langs->trans("RefOrder").'</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$object->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$object->ref;
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 else
{ {
print $commande->ref_client; print $langs->trans("RefProposal").'</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/comm/fiche.php?propalid='.$object->id.'">'.img_object($langs->trans("ShowProposal"),'propal').' '.$object->ref;
} }
print '</a></td>';
print "</tr>\n";
// Ref client
print '<tr><td>';
print $langs->trans('RefCustomer').'</td><td colspan="3">';
print $object->ref_client;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Sociét // Tiers
print '<tr><td>'.$langs->trans('Company').'</td>'; print '<tr><td>'.$langs->trans('Company').'</td>';
print '<td colspan="3">'.$soc->getNomUrl(1).'</td>'; print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
print '</tr>'; print '</tr>';
// Date // Date
print "<tr><td>".$langs->trans("Date")."</td>"; print "<tr><td>".$langs->trans("Date")."</td>";
print '<td colspan="3">'.dolibarr_print_date($commande->date,"dayhour")."</td></tr>\n"; print '<td colspan="3">'.dolibarr_print_date($object->date,"day")."</td></tr>\n";
// Entrepot (si forcé) // Entrepot (si forcé)
if ($conf->stock->enabled && $_GET["entrepot_id"]) if ($conf->stock->enabled && $_GET["entrepot_id"])
@ -259,9 +262,9 @@ if ($_GET["action"] == 'create')
print '</td></tr>'; print '</td></tr>';
} }
if ($commande->note && ! $user->societe_id) if ($object->note && ! $user->societe_id)
{ {
print '<tr><td colspan="3">'.$langs->trans("NotePrivate").': '.nl2br($commande->note)."</td></tr>"; print '<tr><td colspan="3">'.$langs->trans("NotePrivate").': '.nl2br($object->note)."</td></tr>";
} }
print "</table>"; print "</table>";
@ -270,15 +273,15 @@ if ($_GET["action"] == 'create')
* Lignes de commandes * Lignes de commandes
* *
*/ */
echo '<br><table class="noborder" width="100%">'; print '<br><table class="noborder" width="100%">';
$lignes = $commande->fetch_lines(1); //$lignes = $object->fetch_lines(1);
$numcommandes = sizeof($commande->lignes); $numAsked = sizeof($object->lignes);
/* Lecture des expeditions déjà effectuées */ /* Lecture des expeditions déjà effectuées */
$commande->loadExpeditions(); $object->loadExpeditions();
if ($numcommandes) if ($numAsked)
{ {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Description").'</td>';
@ -300,10 +303,10 @@ if ($_GET["action"] == 'create')
} }
$var=true; $var=true;
$indicecommande = 0; $indiceAsked = 0;
while ($indicecommande < $numcommandes) while ($indiceAsked < $numAsked)
{ {
$ligne = $commande->lignes[$indicecommande]; $ligne = $object->lignes[$indiceAsked];
$var=!$var; $var=!$var;
print "<tr $bc[$var]>\n"; print "<tr $bc[$var]>\n";
if ($ligne->fk_product > 0) if ($ligne->fk_product > 0)
@ -324,12 +327,12 @@ if ($_GET["action"] == 'create')
print '<td align="center">'.$ligne->qty.'</td>'; print '<td align="center">'.$ligne->qty.'</td>';
print '<td align="center">'; print '<td align="center">';
$quantite_livree = $commande->expeditions[$ligne->fk_product]; $quantityDelivered = $object->expeditions[$ligne->fk_product];
print $quantite_livree;; print $quantityDelivered;
print '</td>'; print '</td>';
$quantite_commandee = $ligne->qty; $quantityAsked = $ligne->qty;
$quantite_a_livrer = $quantite_commandee - $quantite_livree; $quantityToBeDelivered = $quantityAsked - $quantityDelivered;
if ($conf->stock->enabled) if ($conf->stock->enabled)
{ {
@ -338,20 +341,20 @@ if ($_GET["action"] == 'create')
{ {
$stock = $product->stock_entrepot[$_GET["entrepot_id"]]; $stock = $product->stock_entrepot[$_GET["entrepot_id"]];
$stock+=0; // Convertit en numérique $stock+=0; // Convertit en numérique
$defaultqty=min($quantite_a_livrer, $stock); $defaultqty=min($quantityToBeDelivered, $stock);
} }
// Quantité à livrer // Quantité à livrer
print '<td align="center">'; print '<td align="center">';
print '<input name="idl'.$indicecommande.'" type="hidden" value="'.$ligne->id.'">'; print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$ligne->id.'">';
print '<input name="qtyl'.$indicecommande.'" type="text" size="4" value="'.$defaultqty.'">'; print '<input name="qtyl'.$indiceAsked.'" type="text" size="4" value="'.$defaultqty.'">';
print '</td>'; print '</td>';
// Stock // Stock
if ($_GET["entrepot_id"]) if ($_GET["entrepot_id"])
{ {
print '<td align="right">'.$stock; print '<td align="right">'.$stock;
if ($stock < $quantite_a_livrer) if ($stock < $quantityToBeDelivered)
{ {
print ' '.img_warning($langs->trans("StockTooLow")); print ' '.img_warning($langs->trans("StockTooLow"));
} }
@ -387,7 +390,7 @@ if ($_GET["action"] == 'create')
} }
print '<td align="left">'; print '<td align="left">';
$html->select_array('warehouse'.$i,$array,'',1,0,0); $html->select_array('entl'.$i,$array,'',1,0,0);
print '</td>'; print '</td>';
} }
} }
@ -395,14 +398,14 @@ if ($_GET["action"] == 'create')
{ {
// Quantité à livrer // Quantité à livrer
print '<td align="center">'; print '<td align="center">';
print '<input name="idl'.$indicecommande.'" type="hidden" value="'.$ligne->id.'">'; print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$ligne->id.'">';
print '<input name="qtyl'.$indicecommande.'" type="text" size="6" value="'.$quantite_a_livrer.'">'; print '<input name="qtyl'.$indiceAsked.'" type="text" size="6" value="'.$quantityToBeDelivered.'">';
print '</td>'; print '</td>';
} }
print "</tr>\n"; print "</tr>\n";
$indicecommande++; $indiceAsked++;
$var=!$var; $var=!$var;
} }
@ -435,12 +438,11 @@ else
if ($expedition->id > 0) if ($expedition->id > 0)
{ {
$object = New Commande($db);
$commande = New Commande($db); $object->fetch($expedition->origin_id);
$commande->fetch($expedition->commande_id);
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->socid); $soc->fetch($expedition->socid);
$h=0; $h=0;
$head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$expedition->id; $head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$expedition->id;
@ -492,9 +494,9 @@ else
$totalVolume = ''; $totalVolume = '';
for ($i = 0 ; $i < $num_prod ; $i++) for ($i = 0 ; $i < $num_prod ; $i++)
{ {
$totalWeight += $lignes[$i]->weight*$lignes[$i]->qty_expedie; $totalWeight += $lignes[$i]->weight*$lignes[$i]->qty_shipped;
$weightUnit = $lignes[$i]->weight_units; $weightUnit = $lignes[$i]->weight_units;
$totalVolume += $lignes[$i]->volume*$lignes[$i]->qty_expedie; $totalVolume += $lignes[$i]->volume*$lignes[$i]->qty_shipped;
$volumeUnit = $lignes[$i]->volume_units; $volumeUnit = $lignes[$i]->volume_units;
} }
@ -509,19 +511,29 @@ else
print '<td colspan="3">'.$soc->getNomUrl(1).'</td>'; print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
print "</tr>"; print "</tr>";
// Commande liée // Document liée
print '<tr><td>'.$langs->trans("RefOrder").'</td>'; print '<tr><td>';
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"; if ($conf->commande->enabled)
{
print $langs->trans("RefOrder").'</td>';
print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$object->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$object->ref;
}
else
{
print $langs->trans("RefProposal").'</td>';
print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/expedition/propal.php?propalid='.$object->id.'">'.img_object($langs->trans("ShowProposal"),'propal').' '.$object->ref;
}
print "</a></td>\n";
print '</tr>'; print '</tr>';
// Commande liée // Ref client
print '<tr><td>'.$langs->trans("RefCustomerOrderShort").'</td>'; print '<tr><td>'.$langs->trans("RefCustomer").'</td>';
print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id.'">'.$commande->ref_client."</a></td>\n"; print '<td colspan="3">'.$object->ref_client."</a></td>\n";
print '</tr>'; print '</tr>';
// Date // Date
print '<tr><td>'.$langs->trans("Date").'</td>'; print '<tr><td>'.$langs->trans("Date").'</td>';
print '<td colspan="3">'.dolibarr_print_date($expedition->date,"dayhour")."</td>\n"; print '<td colspan="3">'.dolibarr_print_date($expedition->date,"day")."</td>\n";
print '</tr>'; print '</tr>';
// Poids Total // Poids Total
@ -570,7 +582,6 @@ else
for ($i = 0 ; $i < $num_prod ; $i++) for ($i = 0 ; $i < $num_prod ; $i++)
{ {
$var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
if ($lignes[$i]->fk_product > 0) if ($lignes[$i]->fk_product > 0)
{ {
@ -585,22 +596,22 @@ else
} }
// Qte commandé // Qte commandé
print '<td align="center">'.$lignes[$i]->qty_commande.'</td>'; print '<td align="center">'.$lignes[$i]->qty_asked.'</td>';
// Qte a expedier ou expedier // Qte a expedier ou expedier
print '<td align="center">'.$lignes[$i]->qty_expedie.'</td>'; print '<td align="center">'.$lignes[$i]->qty_shipped.'</td>';
// Poids // Poids
print '<td align="center">'.$lignes[$i]->weight*$lignes[$i]->qty_expedie.' '.measuring_units_string($lignes[$i]->weight_units,"weight").'</td>'; print '<td align="center">'.$lignes[$i]->weight*$lignes[$i]->qty_shipped.' '.measuring_units_string($lignes[$i]->weight_units,"weight").'</td>';
// Volume // Volume
print '<td align="center">'.$lignes[$i]->volume*$lignes[$i]->qty_expedie.' '.measuring_units_string($lignes[$i]->volume_units,"volume").'</td>'; print '<td align="center">'.$lignes[$i]->volume*$lignes[$i]->qty_shipped.' '.measuring_units_string($lignes[$i]->volume_units,"volume").'</td>';
// Entrepot source // Entrepot source
if ($conf->stock->enabled) if ($conf->stock->enabled)
{ {
$entrepot = new Entrepot($db); $entrepot = new Entrepot($db);
$entrepot->fetch($expedition->entrepot_id); $entrepot->fetch($lignes[$i]->entrepot_id);
print '<td align="left">'.$entrepot->getNomUrl(1).'</td>'; print '<td align="left">'.$entrepot->getNomUrl(1).'</td>';
} }
@ -668,16 +679,16 @@ else
/* /*
* Autres expeditions * Autres expeditions
*/ */
$sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande"; $sql = "SELECT obj.fk_product, obj.description, obj.rowid, obj.qty as qty_asking";
$sql .= " , ed.qty as qty_livre, e.ref, ed.fk_expedition as expedition_id"; $sql.= ", ed.qty as qty_shipped, ed.fk_expedition as expedition_id";
$sql .= ",".$db->pdate("e.date_expedition")." as date_expedition"; $sql.= ", e.ref, ".$db->pdate("e.date_expedition")." as date_expedition";
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; $sql.= " FROM ".MAIN_DB_PREFIX.$expedition->origin."det as obj";
$sql.= " , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e"; $sql.= " , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e";
$sql .= " WHERE cd.fk_commande = ".$expedition->commande_id; $sql.= " WHERE obj.fk_".$expedition->origin." = ".$expedition->origin_id;
$sql.= " AND e.rowid <> ".$expedition->id; $sql.= " AND e.rowid <> ".$expedition->id;
$sql .= " AND cd.rowid = ed.fk_commande_ligne"; $sql.= " AND obj.rowid = ed.fk_origin_line";
$sql.= " AND ed.fk_expedition = e.rowid"; $sql.= " AND ed.fk_expedition = e.rowid";
$sql .= " ORDER BY cd.fk_product"; $sql.= " ORDER BY obj.fk_product";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
@ -719,7 +730,7 @@ else
{ {
print "<td>".nl2br(dolibarr_trunc($objp->description,24))."</td>\n"; print "<td>".nl2br(dolibarr_trunc($objp->description,24))."</td>\n";
} }
print '<td align="center">'.$objp->qty_livre.'</td>'; print '<td align="center">'.$objp->qty_shipped.'</td>';
print '<td align="center" nowrap="nowrap">'.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++;

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2006 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -50,19 +50,26 @@ print "</form></table><br />\n";
/* /*
* Expeditions à valider * Expeditions à valider
*/ */
$sql = "SELECT e.rowid, e.ref, s.nom, s.rowid as socid, c.ref as commande_ref, c.rowid as commande_id"; $clause = " WHERE ";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; $sql = "SELECT e.rowid, e.ref";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; $sql.= ", s.nom, s.rowid as socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ", c.ref as commande_ref, c.rowid as commande_id";
$sql.= " WHERE e.fk_commande = c.rowid AND c.fk_soc = s.rowid AND e.fk_statut = 0"; $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."co_exp as ce ON e.rowid = ce.fk_expedition";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON ce.fk_commande = c.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
if (!$user->rights->commercial->client->voir && !$socid)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
$sql.= $clause." sc.fk_user = " .$user->id;
$clause = " AND ";
}
$sql.= $clause." e.fk_statut = 0";
if ($socid) if ($socid)
{ {
$sql .= " AND c.fk_soc = ".$socid; $sql .= " AND c.fk_soc = ".$socid;
} }
if (!$user->rights->commercial->client->voir && !$socid) //restriction
{
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
}
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@ -173,13 +180,22 @@ if ( $resql )
/* /*
* Expeditions à valider * Expeditions à valider
*/ */
$sql = "SELECT e.rowid, e.ref, s.nom, s.rowid as socid, c.ref as commande_ref, c.rowid as commande_id"; $clause = " WHERE ";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; $sql = "SELECT e.rowid, e.ref";
$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; $sql.= ", s.nom, s.rowid as socid";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ", c.ref as commande_ref, c.rowid as commande_id";
$sql .= " WHERE e.fk_commande = c.rowid AND c.fk_soc = s.rowid AND e.fk_statut = 1"; $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."co_exp as ce ON e.rowid = ce.fk_expedition";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON ce.fk_commande = c.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
if (!$user->rights->commercial->client->voir && !$socid)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
$sql.= $clause." sc.fk_user = " .$user->id;
$clause = " AND ";
}
$sql.= $clause." e.fk_statut = 1";
if ($socid) $sql .= " AND c.fk_soc = ".$socid; if ($socid) $sql .= " AND c.fk_soc = ".$socid;
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " ORDER BY e.date_expedition DESC"; $sql.= " ORDER BY e.date_expedition DESC";
$sql.= $db->plimit(5, 0); $sql.= $db->plimit(5, 0);
@ -192,7 +208,7 @@ if ($resql)
$i = 0; $i = 0;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("LastSendings",$max).'</td></tr>'; print '<td colspan="3">'.$langs->trans("LastSendings",$num).'</td></tr>';
$var = True; $var = True;
while ($i < $num) while ($i < $num)
{ {

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2006 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -31,6 +31,8 @@ require("./pre.inc.php");
if (!$user->rights->expedition->lire) accessforbidden(); if (!$user->rights->expedition->lire) accessforbidden();
$langs->load('companies');
// Sécurité accés client // Sécurité accés client
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
@ -55,33 +57,40 @@ $offset = $limit * $_GET["page"] ;
/******************************************************************************/ /******************************************************************************/
llxHeader('',$langs->trans('ListOfSendings'),'ch-expedition.html'); llxHeader('',$langs->trans('ListOfSendings'));
$sql = "SELECT e.rowid, e.ref,".$db->pdate("e.date_expedition")." as date_expedition, e.fk_statut, s.nom as socname, s.rowid as socid, c.ref as comref, c.rowid as comid"; $clause = " WHERE ";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; $sql = "SELECT e.rowid, e.ref,".$db->pdate("e.date_expedition")." as date_expedition, e.fk_statut";
$sql.= ", s.nom as socname, s.rowid as socid";
$sql.= ", ori.ref as oriref, ori.rowid as oriid";
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."commande as c"; if ($conf->commande->enabled)
if ($socid) $sql.=", ".MAIN_DB_PREFIX."commande as c"; {
if ($user->rights->commercial->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON c.rowid = e.fk_commande"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."co_exp as ce ON e.rowid = ce.fk_expedition";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as ori ON ce.fk_commande = ori.rowid";
}
$sql_add = " WHERE "; else
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."pr_exp as pe ON e.rowid = pe.fk_expedition";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."propal as ori ON pe.fk_commande = ori.rowid";
}
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
if (!$user->rights->commercial->client->voir && !$socid)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
$sql.= $clause." sc.fk_user = " .$user->id;
$clause = " AND ";
}
if ($socid) if ($socid)
{ {
$sql.= $sql_add . " e.fk_commande = c.rowid AND c.fk_soc = ".$socid; $sql.= $clause." e.fk_soc = ".$socid;
$sql_add = " AND "; $clause = " AND ";
} }
if ($_POST["sf_ref"]) if ($_POST["sf_ref"])
{ {
$sql.= $sql_add . " e.ref like '%".addslashes($_POST["sf_ref"])."%'"; $sql.= $clause." e.ref like '%".addslashes($_POST["sf_ref"])."%'";
$sql_add = " AND "; $clause = " AND ";
} }
if (!$user->rights->commercial->client->voir && !$socid) //restriction
{
$sql .= $sql_add . " e.fk_commande = c.rowid AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
}
$expedition = new Expedition($db);
$sql.= " ORDER BY $sortfield $sortorder"; $sql.= " ORDER BY $sortfield $sortorder";
$sql.= $db->plimit($limit + 1,$offset); $sql.= $db->plimit($limit + 1,$offset);
@ -91,6 +100,8 @@ if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$expedition = new Expedition($db);
print_barre_liste($langs->trans('ListOfSendings'), $_GET["page"], "liste.php","&amp;socid=$socid",$sortfield,$sortorder,'',$num); print_barre_liste($langs->trans('ListOfSendings'), $_GET["page"], "liste.php","&amp;socid=$socid",$sortfield,$sortorder,'',$num);
$i = 0; $i = 0;
@ -99,7 +110,14 @@ if ($resql)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Ref"),"liste.php","e.ref","","&amp;socid=$socid",'width="15%"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Ref"),"liste.php","e.ref","","&amp;socid=$socid",'width="15%"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Company"),"liste.php","s.nom", "", "&amp;socid=$socid",'width="25%" align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),"liste.php","s.nom", "", "&amp;socid=$socid",'width="25%" align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Order"),"liste.php","c.ref", "", "&amp;socid=$socid",'width="25%" align="left"',$sortfield,$sortorder); if ($conf->commande->enabled)
{
print_liste_field_titre($langs->trans("Order"),"liste.php","ori.ref", "", "&amp;socid=$socid",'width="25%" align="left"',$sortfield,$sortorder);
}
else
{
print_liste_field_titre($langs->trans("Proposal"),"liste.php","ori.ref", "", "&amp;socid=$socid",'width="25%" align="left"',$sortfield,$sortorder);
}
print_liste_field_titre($langs->trans("Date"),"liste.php","e.date_expedition","","&amp;socid=$socid", 'width="25%" align="right" colspan="2"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Date"),"liste.php","e.date_expedition","","&amp;socid=$socid", 'width="25%" align="right" colspan="2"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),"liste.php","e.fk_statut","","&amp;socid=$socid",'width="10%" align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),"liste.php","e.fk_statut","","&amp;socid=$socid",'width="10%" align="center"',$sortfield,$sortorder);
print "</tr>\n"; print "</tr>\n";
@ -114,7 +132,14 @@ if ($resql)
print "<td><a href=\"fiche.php?id=".$objp->rowid."\">".img_object($langs->trans("ShowSending"),"sending").'</a>&nbsp;'; print "<td><a href=\"fiche.php?id=".$objp->rowid."\">".img_object($langs->trans("ShowSending"),"sending").'</a>&nbsp;';
print "<a href=\"fiche.php?id=".$objp->rowid."\">".$objp->ref."</a></td>\n"; print "<a href=\"fiche.php?id=".$objp->rowid."\">".$objp->ref."</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->socid.'">'.$objp->socname.'</a></td>'; print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->socid.'">'.$objp->socname.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$objp->comid.'">'.$objp->comref.'</a></td>'; if ($conf->commande->enabled)
{
print '<td><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$objp->oriid.'">'.$objp->oriref.'</a></td>';
}
else
{
print '<td><a href="'.DOL_URL_ROOT.'/expedition/propal.php?propalid='.$objp->oriid.'">'.$objp->oriref.'</a></td>';
}
$now = time(); $now = time();
$lim = 3600 * 24 * 15 ; $lim = 3600 * 24 * 15 ;

View File

@ -21,7 +21,7 @@
/** /**
\defgroup expedition Module expedition \defgroup expedition Module expedition
\brief Module pour g<EFBFBD>rer les expeditions de produits \brief Module pour gerer les expeditions de produits
*/ */
/** /**
@ -42,7 +42,7 @@ class modExpedition extends DolibarrModules
/** /**
* \brief Constructeur. Definit les noms, constantes et boites * \brief Constructeur. Definit les noms, constantes et boites
* \param DB handler d'acc<EFBFBD>s base * \param DB handler d'acces base
*/ */
function modExpedition($DB) function modExpedition($DB)
{ {
@ -51,7 +51,7 @@ class modExpedition extends DolibarrModules
$this->family = "crm"; $this->family = "crm";
$this->name = "Expedition"; $this->name = "Expedition";
$this->description = "Gestion des exp<EFBFBD>ditions"; $this->description = "Gestion des expeditions";
$this->revision = explode(' ','$Revision$'); $this->revision = explode(' ','$Revision$');
$this->version = $this->revision[1]; $this->version = $this->revision[1];
$this->const_name = 'MAIN_MODULE_EXPEDITION'; $this->const_name = 'MAIN_MODULE_EXPEDITION';
@ -64,8 +64,8 @@ class modExpedition extends DolibarrModules
// Config pages // Config pages
$this->config_page_url = array("confexped.php"); $this->config_page_url = array("confexped.php");
// D<EFBFBD>pendances // Dependances
$this->depends = array(); $this->depends = array("modPropale");
$this->requiredby = array(); $this->requiredby = array();
// Constantes // Constantes
@ -73,13 +73,13 @@ class modExpedition extends DolibarrModules
$this->const[0][0] = "LIVRAISON_ADDON_PDF"; $this->const[0][0] = "LIVRAISON_ADDON_PDF";
$this->const[0][1] = "chaine"; $this->const[0][1] = "chaine";
$this->const[0][2] = "typhon"; $this->const[0][2] = "typhon";
$this->const[0][3] = 'Nom du gestionnaire de g<EFBFBD>n<EFBFBD>ration des commandes en PDF'; $this->const[0][3] = 'Nom du gestionnaire de generation des commandes en PDF';
$this->const[0][4] = 0; $this->const[0][4] = 0;
$this->const[1][0] = "LIVRAISON_ADDON"; $this->const[1][0] = "LIVRAISON_ADDON";
$this->const[1][1] = "chaine"; $this->const[1][1] = "chaine";
$this->const[1][2] = "mod_livraison_jade"; $this->const[1][2] = "mod_livraison_jade";
$this->const[1][3] = 'Nom du gestionnaire de num<EFBFBD>rotation des bons de livraison'; $this->const[1][3] = 'Nom du gestionnaire de numerotation des bons de livraison';
$this->const[1][4] = 0; $this->const[1][4] = 0;
// Boxes // Boxes
@ -99,7 +99,7 @@ class modExpedition extends DolibarrModules
$r++; $r++;
$this->rights[$r][0] = 102; $this->rights[$r][0] = 102;
$this->rights[$r][1] = 'Cr<EFBFBD>er modifier les expeditions'; $this->rights[$r][1] = 'Creer modifier les expeditions';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'creer'; $this->rights[$r][4] = 'creer';
@ -128,7 +128,7 @@ class modExpedition extends DolibarrModules
$r++; $r++;
$this->rights[$r][0] = 1102; $this->rights[$r][0] = 1102;
$this->rights[$r][1] = 'Cr<EFBFBD>er modifier les bons de livraison'; $this->rights[$r][1] = 'Creer modifier les bons de livraison';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'livraison'; $this->rights[$r][4] = 'livraison';
@ -154,8 +154,8 @@ class modExpedition extends DolibarrModules
/** /**
* \brief Fonction appel<EFBFBD>e lors de l'activation du module. Ins<EFBFBD>re en base les constantes, boites, permissions du module. * \brief Fonction appelee lors de l'activation du module. Insere en base les constantes, boites, permissions du module.
* D<EFBFBD>finit <EFBFBD>galement les r<EFBFBD>pertoires de donn<EFBFBD>es <EFBFBD> cr<EFBFBD>er pour ce module. * Definit egalement les repertoires de donnees a creer pour ce module.
*/ */
function init() function init()
{ {
@ -171,7 +171,7 @@ class modExpedition extends DolibarrModules
} }
/** /**
* \brief Fonction appel<EFBFBD>e lors de la d<EFBFBD>sactivation d'un module. * \brief Fonction appelee lors de la desactivation d'un module.
* Supprime de la base les constantes, boites et permissions du module. * Supprime de la base les constantes, boites et permissions du module.
*/ */
function remove() function remove()

View File

@ -22,7 +22,7 @@
*/ */
/** \defgroup propale Module propale /** \defgroup propale Module propale
\brief Module pour g<EFBFBD>rer la tenue de propositions commerciales \brief Module pour gerer la tenue de propositions commerciales
*/ */
/** /**
@ -43,7 +43,7 @@ class modPropale extends DolibarrModules
/** /**
* \brief Constructeur. Definit les noms, constantes et boites * \brief Constructeur. Definit les noms, constantes et boites
* \param DB handler d'acc<EFBFBD>s base * \param DB handler d'acces base
*/ */
function modPropale($DB) function modPropale($DB)
{ {
@ -64,7 +64,7 @@ class modPropale extends DolibarrModules
// Dir // Dir
$this->dirs = array(); $this->dirs = array();
// D<EFBFBD>pendances // Dependances
$this->depends = array("modSociete","modCommercial"); $this->depends = array("modSociete","modCommercial");
$this->config_page_url = array("propale.php"); $this->config_page_url = array("propale.php");
@ -74,13 +74,13 @@ class modPropale extends DolibarrModules
$this->const[0][0] = "PROPALE_ADDON_PDF"; $this->const[0][0] = "PROPALE_ADDON_PDF";
$this->const[0][1] = "chaine"; $this->const[0][1] = "chaine";
$this->const[0][2] = "azur"; $this->const[0][2] = "azur";
$this->const[0][3] = 'Nom du gestionnaire de g<EFBFBD>n<EFBFBD>ration des propales en PDF'; $this->const[0][3] = 'Nom du gestionnaire de generation des propales en PDF';
$this->const[0][4] = 0; $this->const[0][4] = 0;
$this->const[1][0] = "PROPALE_ADDON"; $this->const[1][0] = "PROPALE_ADDON";
$this->const[1][1] = "chaine"; $this->const[1][1] = "chaine";
$this->const[1][2] = "mod_propale_marbre"; $this->const[1][2] = "mod_propale_marbre";
$this->const[1][3] = 'Nom du gestionnaire de num<EFBFBD>rotation des propales'; $this->const[1][3] = 'Nom du gestionnaire de numerotation des propales';
$this->const[1][4] = 0; $this->const[1][4] = 0;
// Boxes // Boxes
@ -93,54 +93,54 @@ class modPropale extends DolibarrModules
$this->rights[1][0] = 21; // id de la permission $this->rights[1][0] = 21; // id de la permission
$this->rights[1][1] = 'Lire les propositions commerciales'; // libelle de la permission $this->rights[1][1] = 'Lire les propositions commerciales'; // libelle de la permission
$this->rights[1][2] = 'r'; // type de la permission (d<EFBFBD>pr<EFBFBD>ci<EFBFBD> <20> ce jour) $this->rights[1][2] = 'r'; // type de la permission (deprecie a ce jour)
$this->rights[1][3] = 1; // La permission est-elle une permission par d<EFBFBD>faut $this->rights[1][3] = 1; // La permission est-elle une permission par defaut
$this->rights[1][4] = 'lire'; $this->rights[1][4] = 'lire';
$this->rights[2][0] = 22; // id de la permission $this->rights[2][0] = 22; // id de la permission
$this->rights[2][1] = 'Cr<EFBFBD>er/modifier les propositions commerciales'; // libelle de la permission $this->rights[2][1] = 'Creer/modifier les propositions commerciales'; // libelle de la permission
$this->rights[2][2] = 'w'; // type de la permission (d<EFBFBD>pr<EFBFBD>ci<EFBFBD> <20> ce jour) $this->rights[2][2] = 'w'; // type de la permission (deprecie a ce jour)
$this->rights[2][3] = 0; // La permission est-elle une permission par d<EFBFBD>faut $this->rights[2][3] = 0; // La permission est-elle une permission par defaut
$this->rights[2][4] = 'creer'; $this->rights[2][4] = 'creer';
$this->rights[3][0] = 24; // id de la permission $this->rights[3][0] = 24; // id de la permission
$this->rights[3][1] = 'Valider les propositions commerciales'; // libelle de la permission $this->rights[3][1] = 'Valider les propositions commerciales'; // libelle de la permission
$this->rights[3][2] = 'd'; // type de la permission (d<EFBFBD>pr<EFBFBD>ci<EFBFBD> <20> ce jour) $this->rights[3][2] = 'd'; // type de la permission (deprecie a ce jour)
$this->rights[3][3] = 0; // La permission est-elle une permission par d<EFBFBD>faut $this->rights[3][3] = 0; // La permission est-elle une permission par defaut
$this->rights[3][4] = 'valider'; $this->rights[3][4] = 'valider';
$this->rights[4][0] = 25; // id de la permission $this->rights[4][0] = 25; // id de la permission
$this->rights[4][1] = 'Envoyer les propositions commerciales aux clients'; // libelle de la permission $this->rights[4][1] = 'Envoyer les propositions commerciales aux clients'; // libelle de la permission
$this->rights[4][2] = 'd'; // type de la permission (d<EFBFBD>pr<EFBFBD>ci<EFBFBD> <20> ce jour) $this->rights[4][2] = 'd'; // type de la permission (deprecie a ce jour)
$this->rights[4][3] = 0; // La permission est-elle une permission par d<EFBFBD>faut $this->rights[4][3] = 0; // La permission est-elle une permission par defaut
$this->rights[4][4] = 'envoyer'; $this->rights[4][4] = 'envoyer';
$this->rights[5][0] = 26; // id de la permission $this->rights[5][0] = 26; // id de la permission
$this->rights[5][1] = 'Cl<EFBFBD>turer les propositions commerciales'; // libelle de la permission $this->rights[5][1] = 'Cloturer les propositions commerciales'; // libelle de la permission
$this->rights[5][2] = 'd'; // type de la permission (d<EFBFBD>pr<EFBFBD>ci<EFBFBD> <20> ce jour) $this->rights[5][2] = 'd'; // type de la permission (deprecie a ce jour)
$this->rights[5][3] = 0; // La permission est-elle une permission par d<EFBFBD>faut $this->rights[5][3] = 0; // La permission est-elle une permission par defaut
$this->rights[5][4] = 'cloturer'; $this->rights[5][4] = 'cloturer';
$this->rights[6][0] = 27; // id de la permission $this->rights[6][0] = 27; // id de la permission
$this->rights[6][1] = 'Supprimer les propositions commerciales'; // libelle de la permission $this->rights[6][1] = 'Supprimer les propositions commerciales'; // libelle de la permission
$this->rights[6][2] = 'd'; // type de la permission (d<EFBFBD>pr<EFBFBD>ci<EFBFBD> <20> ce jour) $this->rights[6][2] = 'd'; // type de la permission (deprecie a ce jour)
$this->rights[6][3] = 0; // La permission est-elle une permission par d<EFBFBD>faut $this->rights[6][3] = 0; // La permission est-elle une permission par defaut
$this->rights[6][4] = 'supprimer'; $this->rights[6][4] = 'supprimer';
} }
/** /**
* \brief Fonction appel<EFBFBD>e lors de l'activation du module. Ins<EFBFBD>re en base les constantes, boites, permissions du module. * \brief Fonction appelee lors de l'activation du module. Insere en base les constantes, boites, permissions du module.
* D<EFBFBD>finit <EFBFBD>galement les r<EFBFBD>pertoires de donn<EFBFBD>es <EFBFBD> cr<EFBFBD>er pour ce module. * Definit egalement les repertoires de donnees a creer pour ce module.
*/ */
function init() function init()
{ {
global $conf; global $conf;
// Permissions et valeurs par d<EFBFBD>faut // Permissions et valeurs par defaut
$this->remove(); $this->remove();
// R<EFBFBD>pertoires // Repertoires
$this->dirs[0] = $conf->propal->dir_output; $this->dirs[0] = $conf->propal->dir_output;
$this->dirs[1] = $conf->propal->dir_temp; $this->dirs[1] = $conf->propal->dir_temp;
@ -154,7 +154,7 @@ class modPropale extends DolibarrModules
} }
/** /**
* \brief Fonction appel<EFBFBD>e lors de la d<EFBFBD>sactivation d'un module. * \brief Fonction appelee lors de la desactivation d'un module.
* Supprime de la base les constantes, boites et permissions du module. * Supprime de la base les constantes, boites et permissions du module.
*/ */
function remove() function remove()

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> /* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -174,6 +175,9 @@ if (isset($_POST['action']) && $_POST['action'] == 'upgrade')
migrate_delete_old_files($db,$langs,$conf); migrate_delete_old_files($db,$langs,$conf);
// Script pour V2.2 -> V2.4
migrate_commande_expedition($db,$langs,$conf);
// On commit dans tous les cas. // On commit dans tous les cas.
// La procedure etant concue pour pouvoir passer plusieurs fois quelquesoit la situation. // La procedure etant concue pour pouvoir passer plusieurs fois quelquesoit la situation.
$db->commit(); $db->commit();
@ -1454,6 +1458,75 @@ function migrate_module_menus($db,$langs,$conf)
} }
} }
/*
* Correspondance des expeditions et des commandes clients dans la table llx_co_exp
*/
function migrate_commande_expedition($db,$langs,$conf)
{
if ($conf->expedition->enabled)
{
print '<tr><td colspan="4">';
print '<br>';
print '<b>'.$langs->trans('MigrationShipmentOrderMatching')."</b><br>\n";
$result = $db->DDLDescTable(MAIN_DB_PREFIX."expedition","fk_commande");
$obj = $db->fetch_object($result);
if ($obj)
{
$sql = "SELECT e.rowid, e.fk_commande FROM ".MAIN_DB_PREFIX."expedition as e";
$resql = $db->query($sql);
if ($resql)
{
$i = 0;
$error = 0;
$num = $db->num_rows($resql);
if ($num)
{
$db->begin();
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."co_exp (fk_expedition,fk_commande)";
$sql.= " VALUES (".$obj->rowid.",".$obj->fk_commande.")";
$resql2=$db->query($sql);
if (!$resql2)
{
$error++;
dolibarr_print_error($db);
}
print ". ";
$i++;
}
if ($error == 0)
{
$db->commit();
$sql = "ALTER TABLE ".MAIN_DB_PREFIX."expedition DROP COLUMN fk_commande";
$db->query($sql);
}
else
{
$db->rollback();
}
}
}
else
{
dolibarr_print_error($db);
}
}
else
{
print $langs->trans('AlreadyDone')."<br>\n";
}
print '</td></tr>';
}
}
/* A faire egalement: Modif statut paye et fk_facture des factures payés completement /* A faire egalement: Modif statut paye et fk_facture des factures payés completement
On recherche facture incorrecte: On recherche facture incorrecte:

View File

@ -43,11 +43,11 @@ function propal_prepare_head($propal)
$head[$h][2] = 'comm'; $head[$h][2] = 'comm';
$h++; $h++;
if (!$conf->commande->enabled && (($conf->expedition->enabled && $user->rights->expedition->lire) if ((!$conf->commande->enabled && (($conf->expedition->enabled && $user->rights->expedition->lire)
|| ($conf->livraison->enabled && $user->rights->expedition->livraison->lire))) || ($conf->livraison->enabled && $user->rights->expedition->livraison->lire))))
{ {
$langs->load("sendings"); $langs->load("sendings");
$head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$propal->id; $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?propalid='.$propal->id;
if ($conf->expedition->enabled) $text=$langs->trans("Sendings"); if ($conf->expedition->enabled) $text=$langs->trans("Sendings");
if ($conf->livraison->enabled) $text.='/'.$langs->trans("Receivings"); if ($conf->livraison->enabled) $text.='/'.$langs->trans("Receivings");
$head[$h][1] = $text; $head[$h][1] = $text;

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -266,7 +267,9 @@ class Entrepot
{ {
$liste = array(); $liste = array();
$sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."entrepot WHERE statut = 1"; $sql = "SELECT rowid, label";
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot";
$sql.= " WHERE statut = 1";
$result = $this->db->query($sql) ; $result = $this->db->query($sql) ;
$i = 0; $i = 0;
@ -320,7 +323,6 @@ class Entrepot
} }
} }
/** /**
* \brief Retourne le libellé du statut d'un entrepot (ouvert, ferme) * \brief Retourne le libellé du statut d'un entrepot (ouvert, ferme)
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long * \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long

View File

@ -41,3 +41,48 @@ alter table llx_menu add column tms timestamp;
update llx_menu set url='/comm/prospect/prospects.php?leftmenu=prospects' where rowid=702 and url='/contact/index.php?leftmenu=prospects&type=p'; update llx_menu set url='/comm/prospect/prospects.php?leftmenu=prospects' where rowid=702 and url='/contact/index.php?leftmenu=prospects&type=p';
ALTER TABLE llx_menu ADD UNIQUE INDEX idx_menu_uk_menu (menu_handler, fk_menu, url); ALTER TABLE llx_menu ADD UNIQUE INDEX idx_menu_uk_menu (menu_handler, fk_menu, url);
-- Drop unused table
drop table if exists llx_so_gr;
-- Modification expedition
create table llx_co_exp
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_commande integer NOT NULL,
fk_expedition integer NOT NULL,
key(fk_commande),
key(fk_expedition)
)type=innodb;
-- V4 ALTER TABLE llx_expedition DROP INDEX fk_expedition_methode;
-- V4 ALTER TABLE llx_expedition DROP INDEX fk_commande;
-- V4 ALTER TABLE llx_expedition DROP INDEX ref;
-- V4 ALTER TABLE llx_expeditiondet DROP INDEX fk_expedition;
-- V4 ALTER TABLE llx_expeditiondet DROP INDEX fk_commande_ligne;
alter table llx_expedition add column fk_soc integer NOT NULL after ref;
alter table llx_expedition add column fk_adresse_livraison integer after date_expedition;
-- V4.1 UPDATE llx_expedition as e SET e.fk_soc = (SELECT c.fk_soc FROM llx_commande AS c WHERE e.fk_commande = c.rowid);
-- V4.1 UPDATE llx_expedition as e SET e.fk_adresse_livraison = (SELECT c.fk_adresse_livraison FROM llx_commande AS c WHERE e.fk_commande = c.rowid);
ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_soc (fk_soc);
ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_user_author (fk_user_author);
ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_user_valid (fk_user_valid);
ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_expedition_methode (fk_expedition_methode);
-- V4 ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
-- V4 ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
-- V4 ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid);
-- V4 ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_expedition_methode FOREIGN KEY (fk_expedition_methode) REFERENCES llx_expedition_methode (rowid);
ALTER TABLE llx_expedition ADD UNIQUE INDEX idx_expedition_uk_ref (ref);
ALTER TABLE llx_expeditiondet CHANGE fk_commande_ligne fk_origin_line integer;
ALTER TABLE llx_expeditiondet ADD COLUMN fk_entrepot integer after fk_origin_line;
ALTER TABLE llx_expeditiondet ADD COLUMN rang integer DEFAULT 0 after qty;
-- V4.1 UPDATE llx_expeditiondet as ed SET ed.fk_entrepot = (SELECT e.fk_entrepot FROM llx_expedition AS e WHERE ed.fk_expedition = e.rowid);
ALTER TABLE llx_expedition DROP COLUMN fk_entrepot;
ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_expedition (fk_expedition);
ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_entrepot (fk_entrepot);
-- V4 ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_expedition FOREIGN KEY (fk_expedition) REFERENCES llx_expedition (rowid);
-- V4 ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_entrepot FOREIGN KEY (fk_entrepot) REFERENCES llx_entrepot (rowid);

View File

@ -0,0 +1,30 @@
-- ===================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
--
-- $Id$
-- ===================================================================
create table llx_co_exp
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_commande integer NOT NULL,
fk_expedition integer NOT NULL,
key(fk_commande),
key(fk_expedition)
)type=innodb;

View File

@ -0,0 +1,33 @@
-- ===================================================================
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
--
-- $Id$
-- ===================================================================
ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_soc (fk_soc);
ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_user_author (fk_user_author);
ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_user_valid (fk_user_valid);
ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_expedition_methode (fk_expedition_methode);
ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid);
ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_expedition_methode FOREIGN KEY (fk_expedition_methode) REFERENCES llx_expedition_methode (rowid);
ALTER TABLE llx_expedition ADD UNIQUE INDEX idx_expedition_uk_ref (ref);

View File

@ -1,5 +1,6 @@
-- =================================================================== -- ===================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> -- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
-- --
-- This program is free software; you can redistribute it and/or modify -- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by -- it under the terms of the GNU General Public License as published by
@ -23,19 +24,15 @@ create table llx_expedition
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp, tms timestamp,
ref varchar(30) NOT NULL, ref varchar(30) NOT NULL,
fk_commande integer, fk_soc integer NOT NULL,
date_creation datetime, -- date de creation date_creation datetime, -- date de creation
date_valid datetime, -- date de validation
date_expedition date, -- date de l'expedition
fk_user_author integer, -- createur fk_user_author integer, -- createur
date_valid datetime, -- date de validation
fk_user_valid integer, -- valideur fk_user_valid integer, -- valideur
fk_entrepot integer, date_expedition date, -- date de l'expedition
fk_adresse_livraison integer, -- adresse de livraison
fk_expedition_methode integer, fk_expedition_methode integer,
fk_statut smallint DEFAULT 0, fk_statut smallint DEFAULT 0,
note text, note text,
model_pdf varchar(50), model_pdf varchar(50)
UNIQUE INDEX (ref),
key(fk_expedition_methode),
key(fk_commande)
)type=innodb; )type=innodb;

View File

@ -0,0 +1,24 @@
-- ===================================================================
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
--
-- $Id$
-- ===================================================================
ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_expedition (fk_expedition);
ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_expedition FOREIGN KEY (fk_expedition) REFERENCES llx_expedition (rowid);

View File

@ -1,5 +1,6 @@
-- =================================================================== -- ===================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> -- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
-- --
-- This program is free software; you can redistribute it and/or modify -- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by -- it under the terms of the GNU General Public License as published by
@ -22,9 +23,8 @@ create table llx_expeditiondet
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_expedition integer NOT NULL, fk_expedition integer NOT NULL,
fk_commande_ligne integer NOT NULL, fk_origin_line integer, -- Correspondance de la ligne avec le document d'origine (propal, commande)
qty real, -- quantité fk_entrepot integer, -- Entrepot de depart du produit
qty real, -- Quantity
key(fk_expedition), rang integer DEFAULT 0
key(fk_commande_ligne)
)type=innodb; )type=innodb;

View File

@ -1,5 +1,6 @@
-- =================================================================== -- ===================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> -- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
-- --
-- This program is free software; you can redistribute it and/or modify -- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by -- it under the terms of the GNU General Public License as published by
@ -26,17 +27,17 @@ create table llx_livraison
fk_expedition integer, -- expedition auquel est rattache le bon de livraison fk_expedition integer, -- expedition auquel est rattache le bon de livraison
ref varchar(30) NOT NULL, -- delivery number ref varchar(30) NOT NULL, -- delivery number
date_creation datetime, -- date de creation date_creation datetime, -- date de creation
date_valid datetime, -- date de validation
fk_user_author integer, -- createur du bon de livraison fk_user_author integer, -- createur du bon de livraison
date_valid datetime, -- date de validation
fk_user_valid integer, -- valideur du bon de livraison fk_user_valid integer, -- valideur du bon de livraison
date_livraison date default NULL, -- date de livraison
fk_adresse_livraison integer, -- adresse de livraison
fk_statut smallint default 0, fk_statut smallint default 0,
total_ht real default 0, total_ht real default 0,
total_ttc real default 0, total_ttc real default 0,
note text, note text,
note_public text, note_public text,
model_pdf varchar(50), model_pdf varchar(50),
date_livraison date default NULL,
fk_adresse_livraison integer, -- adresse de livraison
UNIQUE INDEX (ref), UNIQUE INDEX (ref),
key(fk_commande) key(fk_commande)

View File

@ -1,5 +1,6 @@
-- =================================================================== -- ===================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> -- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
-- --
-- This program is free software; you can redistribute it and/or modify -- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by -- it under the terms of the GNU General Public License as published by