From 79599aaf67f52a6e684156f5657e156f108ee9f6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 31 Jan 2008 13:40:45 +0000 Subject: [PATCH] =?UTF-8?q?D=E9but=20modification=20expedition=20livraison?= =?UTF-8?q?=20Phase2:=20modification=20des=20livraisons=20-=20elles=20pour?= =?UTF-8?q?ront=20d=E9sormais=20etre=20li=E9=20=E0=20une=20propale=20(pas?= =?UTF-8?q?=20encore=20effectif)=20-=20on=20pourra=20faire=20un=20bon=20de?= =?UTF-8?q?=20livraison=20sans=20document=20de=20base?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/livraison/fiche.php | 95 ++++++++++++---------------- htdocs/livraison/livraison.class.php | 62 ++++++++++++------ mysql/migration/2.2.0-2.4.0.sql | 20 ++++++ mysql/tables/llx_pr_exp.sql | 30 +++++++++ mysql/tables/llx_pr_liv.sql | 30 +++++++++ 5 files changed, 162 insertions(+), 75 deletions(-) create mode 100644 mysql/tables/llx_pr_exp.sql create mode 100644 mysql/tables/llx_pr_liv.sql diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php index cced73286bb..6c8b424c308 100644 --- a/htdocs/livraison/fiche.php +++ b/htdocs/livraison/fiche.php @@ -1,8 +1,9 @@ - * Copyright (C) 2005-2006 Laurent Destailleur - * Copyright (C) 2005 Simon TOSSER +/* Copyright (C) 2003-2005 Rodolphe Quiedeville + * Copyright (C) 2005-2006 Laurent Destailleur + * Copyright (C) 2005 Simon TOSSER * Copyright (C) 2007 Franky Van Liedekerke + * Copyright (C) 2005-2008 Regis Houssin * * 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 @@ -439,12 +440,12 @@ else // Date print ''.$langs->trans("Date").''; print ''.dolibarr_print_date($livraison->date_creation,'dayhourtext')."\n"; - print ''; + print ''; // Statut print ''.$langs->trans("Status").''; print ''.$livraison->getLibStatut(4)."\n"; - print ''; + print ''; if (!$conf->expedition_bon->enabled && $conf->stock->enabled) { @@ -461,60 +462,46 @@ else /* * Lignes produits */ - echo '
'; - - $sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande,"; - $sql .= " ld.qty as qty_livre"; - $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 "; - - $resql = $db->query($sql); - - if ($resql) + print '
'; + + $num_prod = sizeof($livraison->lignes); + + if ($num_prod) { - $num_prod = $db->num_rows($resql); - $i = 0; - - print ''; - print ''; + $i = 0; + + print ''; + print ''; print ''; print ''; - print "\n"; - - $var=true; - while ($i < $num_prod) + print "\n"; + + $var=true; + while ($i < $num_prod) + { + $var=!$var; + print ""; + if ($livraison->lignes[$i]->fk_product > 0) { - $objp = $db->fetch_object($resql); - - $var=!$var; - print ""; - if ($objp->fk_product > 0) - { - $product = new Product($db); - $product->fetch($objp->fk_product); - - print ''; - } - else - { - print "\n"; - } - print ''; - print ''; - - print ""; - - $i++; - $var=!$var; + $product = new Product($db); + $product->fetch($livraison->lignes[$i]->fk_product); + + print ''; } - $db->free($resql); - } - else - { - dolibarr_print_error($db); + else + { + print "\n"; + } + print ''; + print ''; + + print ""; + + $i++; + } } print "
'.$langs->trans("Products").'
'.$langs->trans("Products").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyReceived").'
'; - print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.$product->libelle; - if ($objp->description) print '
'.nl2br($objp->description); - print '
".stripslashes(nl2br($objp->description))."'.$objp->qty_commande.''.$objp->qty_livre.'
'; + print ''.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.' - '.$product->libelle; + if ($livraison->lignes[$i]->description) print '
'.$livraison->lignes[$i]->description; + print '
".$livraison->lignes[$i]->description."'.$livraison->lignes[$i]->qty_asked.''.$livraison->lignes[$i]->qty_delivered.'
\n"; diff --git a/htdocs/livraison/livraison.class.php b/htdocs/livraison/livraison.class.php index 6ddc836c892..a4328260140 100644 --- a/htdocs/livraison/livraison.class.php +++ b/htdocs/livraison/livraison.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2005-2006 Regis Houssin - * Copyright (C) 2006-2007 Laurent Destailleur +/* Copyright (C) 2003 Rodolphe Quiedeville + * Copyright (C) 2005-2008 Regis Houssin + * Copyright (C) 2006-2007 Laurent Destailleur * Copyright (C) 2007 Franky Van Liedekerke * * This program is free software; you can redistribute it and/or modify @@ -211,12 +211,27 @@ class Livraison extends CommonObject { global $conf; - $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 .= ", ".$this->db->pdate("l.date_livraison")." as date_livraison, l.fk_adresse_livraison, l.model_pdf"; - $sql .= ", c.fk_soc"; - $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 = "SELECT l.rowid, l.fk_soc, l.date_creation, l.date_valid, l.ref, l.ref_client, l.fk_user_author,"; + $sql.=" l.total_ht, l.fk_statut, 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"; + if ($conf->commande->enabled) + { + $sql.= ", cl.fk_commande as origin_id"; + } + else + { + $sql.= ", pl.fk_propal as origin_id"; + } + $sql.= " FROM ".MAIN_DB_PREFIX."livraison as l"; + if ($conf->commande->enabled) + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."co_liv as cl ON cl.fk_livraison = l.rowid"; + } + else + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."pr_liv as pl ON pl.fk_livraison = l.rowid"; + } + $sql.= " WHERE l.rowid = ".$id; $result = $this->db->query($sql) ; if ( $result ) @@ -227,9 +242,10 @@ class Livraison extends CommonObject $this->date_creation = $obj->date_creation; $this->date_valid = $obj->date_valid; $this->ref = $obj->ref; - $this->socid = $obj->fk_soc; + $this->ref_client = $obj->ref_client; + $this->socid = $obj->fk_soc; $this->statut = $obj->fk_statut; - $this->commande_id = $obj->fk_commande; + $this->origin_id = $obj->origin_id; $this->expedition_id = $obj->fk_expedition; $this->user_author_id = $obj->fk_user_author; $this->user_valid_id = $obj->fk_user_valid; @@ -561,19 +577,23 @@ class Livraison extends CommonObject $this->adresse = $adresse; } - + /** + * + * + */ function fetch_lignes() { $this->lignes = array(); - $sql = "SELECT p.label, c.description, c.qty as qtycom, l.qty as qtyliv"; - $sql .= ", c.fk_product, c.price, p.ref"; + $sql = "SELECT p.label, p.ref"; + $sql.= ", l.description, l.fk_product, l.subprice, l.total_ht, l.qty as qtyliv"; + //$sql.= ", c.qty as qtycom"; $sql .= " FROM ".MAIN_DB_PREFIX."livraisondet as l"; - $sql .= " , ".MAIN_DB_PREFIX."commandedet as c"; + //$sql .= " , ".MAIN_DB_PREFIX."commandedet as c"; $sql .= " , ".MAIN_DB_PREFIX."product as p"; $sql .= " WHERE l.fk_livraison = ".$this->id; - $sql .= " AND l.fk_commande_ligne = c.rowid"; - $sql .= " AND c.fk_product = p.rowid"; + //$sql .= " AND l.fk_commande_ligne = c.rowid"; + $sql .= " AND l.fk_product = p.rowid"; $resql = $this->db->query($sql); if ($resql) @@ -587,11 +607,11 @@ class Livraison extends CommonObject $obj = $this->db->fetch_object($resql); $ligne->fk_product = $obj->fk_product; - $ligne->qty_commande = $obj->qtycom; - $ligne->qty_livre = $obj->qtyliv; + $ligne->qty_asked = $obj->qtycom; + $ligne->qty_delivered = $obj->qtyliv; $ligne->ref = $obj->ref; - $ligne->label = stripslashes($obj->label); - $ligne->description = stripslashes($obj->description); + $ligne->label = stripslashes(nl2br($obj->label)); + $ligne->description = stripslashes(nl2br($obj->description)); $ligne->price = $obj->price; $this->lignes[$i] = $ligne; diff --git a/mysql/migration/2.2.0-2.4.0.sql b/mysql/migration/2.2.0-2.4.0.sql index e82917be9cf..658e47e62ed 100644 --- a/mysql/migration/2.2.0-2.4.0.sql +++ b/mysql/migration/2.2.0-2.4.0.sql @@ -133,4 +133,24 @@ alter table llx_livraisondet add column rang integer DEFAULT 0 after ALTER TABLE llx_livraisondet ADD INDEX idx_livraisondet_fk_expedition (fk_livraison); -- V4 ALTER TABLE llx_livraisondet ADD CONSTRAINT fk_livraisondet_fk_livraison FOREIGN KEY (fk_livraison) REFERENCES llx_livraison (rowid); +create table llx_pr_exp +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_propal integer NOT NULL, + fk_expedition integer NOT NULL, + + key(fk_propal), + key(fk_expedition) +)type=innodb; + +create table llx_pr_liv +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_propal integer NOT NULL, + fk_livraison integer NOT NULL, + + key(fk_propal), + key(fk_livraison) +)type=innodb; + ALTER TABLE llx_paiement modify fk_bank integer NOT NULL DEFAULT 0; diff --git a/mysql/tables/llx_pr_exp.sql b/mysql/tables/llx_pr_exp.sql new file mode 100644 index 00000000000..8a13d05f9e4 --- /dev/null +++ b/mysql/tables/llx_pr_exp.sql @@ -0,0 +1,30 @@ +-- =================================================================== +-- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2008 Regis Houssin +-- +-- 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_pr_exp +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_propal integer NOT NULL, + fk_expedition integer NOT NULL, + + key(fk_propal), + key(fk_expedition) +)type=innodb; diff --git a/mysql/tables/llx_pr_liv.sql b/mysql/tables/llx_pr_liv.sql new file mode 100644 index 00000000000..b63a96afa93 --- /dev/null +++ b/mysql/tables/llx_pr_liv.sql @@ -0,0 +1,30 @@ +-- =================================================================== +-- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2008 Regis Houssin +-- +-- 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_pr_liv +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_propal integer NOT NULL, + fk_livraison integer NOT NULL, + + key(fk_propal), + key(fk_livraison) +)type=innodb;