From 44fb7045ac9e0c0a31b79a8950f65ffed7f55922 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Wed, 18 Nov 2009 00:26:50 +0000 Subject: [PATCH] Fix: Restore broken feature of stock management on point of sale module. --- htdocs/admin/cashdesk.php | 12 +++++------ htdocs/cashdesk/affContenu.php | 8 ++++++- htdocs/cashdesk/affIndex.php | 13 +++++++++++- htdocs/cashdesk/facturation.php | 21 ++++++++++++------- htdocs/cashdesk/facturation_dhtml.php | 6 +++--- htdocs/cashdesk/facturation_verif.php | 3 +-- htdocs/cashdesk/include/environnement.php | 9 ++++---- .../cashdesk/templates/facturation1.tpl.php | 13 +++++++++--- htdocs/product/stock/fiche.php | 1 + 9 files changed, 59 insertions(+), 27 deletions(-) diff --git a/htdocs/admin/cashdesk.php b/htdocs/admin/cashdesk.php index fdc4337d9f8..8947059ce57 100644 --- a/htdocs/admin/cashdesk.php +++ b/htdocs/admin/cashdesk.php @@ -50,13 +50,13 @@ if ($_POST["action"] == 'set') { if ($_POST["CASHDESK_ID_THIRDPARTY"] < 0) $_POST["CASHDESK_ID_THIRDPARTY"]=''; if ($_POST["CASHDESK_ID_BANKACCOUNT"] < 0) $_POST["CASHDESK_ID_BANKACCOUNT"]=''; -// if ($_POST["CASHDESK_ID_WAREHOUSE"] < 0) $_POST["CASHDESK_ID_WAREHOUSE"]=''; + if ($_POST["CASHDESK_ID_WAREHOUSE"] < 0) $_POST["CASHDESK_ID_WAREHOUSE"]=''; dolibarr_set_const($db,"CASHDESK_ID_THIRDPARTY",$_POST["CASHDESK_ID_THIRDPARTY"],'chaine',0,'',$conf->entity); dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CASH",$_POST["CASHDESK_ID_BANKACCOUNT_CASH"],'chaine',0,'',$conf->entity); dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CHEQUE",$_POST["CASHDESK_ID_BANKACCOUNT_CHEQUE"],'chaine',0,'',$conf->entity); dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CB",$_POST["CASHDESK_ID_BANKACCOUNT_CB"],'chaine',0,'',$conf->entity); -// dolibarr_set_const($db,"CASHDESK_ID_WAREHOUSE",$_POST["CASHDESK_ID_WAREHOUSE"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db,"CASHDESK_ID_WAREHOUSE",$_POST["CASHDESK_ID_WAREHOUSE"],'chaine',0,'',$conf->entity); dol_syslog("admin/cashdesk: level ".$_POST["level"]); } @@ -93,7 +93,7 @@ print '<tr '.$bc[$var].'><td width=\"50%\">'.$langs->trans("CashDeskThirdPartyFo print '<td colspan="2">'; print $form->select_societes($conf->global->CASHDESK_ID_THIRDPARTY,'CASHDESK_ID_THIRDPARTY','',1,1); print '</td></tr>'; -if ($conf->global->MAIN_MODULE_BANQUE) +if ($conf->banque->enabled) { $var=!$var; print '<tr '.$bc[$var].'><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>'; @@ -113,8 +113,8 @@ if ($conf->global->MAIN_MODULE_BANQUE) $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CB,'CASHDESK_ID_BANKACCOUNT_CB',0,"courant=1",1); print '</td></tr>'; } -/* -if ($conf->global->MAIN_MODULE_STOCK) + +if ($conf->stock->enabled) { $var=!$var; print '<tr '.$bc[$var].'><td>'.$langs->trans("CashDeskIdWareHouse").'</td>'; @@ -122,7 +122,7 @@ if ($conf->global->MAIN_MODULE_STOCK) $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE,'CASHDESK_ID_WAREHOUSE','',1); print '</td></tr>'; } -*/ + print '</table>'; diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php index 4d073c2f2a3..888cbb7cf8d 100644 --- a/htdocs/cashdesk/affContenu.php +++ b/htdocs/cashdesk/affContenu.php @@ -1,6 +1,6 @@ <?php /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net> - * Copyright (C) 2008 Laurent Destailleur <eldy@uers.sourceforge.net> + * Copyright (C) 2008-2009 Laurent Destailleur <eldy@uers.sourceforge.net> * Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr> * * This program is free software; you can redistribute it and/or modify @@ -18,6 +18,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/** + * \file htdocs/cashdesk/affContenu.php + * \ingroup cashdesk + * \brief Include to show main page for cashdesk module + * \version $Id$ + */ require ('classes/Facturation.class.php'); // Si nouvelle vente, reinitialisation des donnees (destruction de l'objet et vidage de la table contenant la liste des articles) diff --git a/htdocs/cashdesk/affIndex.php b/htdocs/cashdesk/affIndex.php index 8c2f16e6400..64664a540db 100644 --- a/htdocs/cashdesk/affIndex.php +++ b/htdocs/cashdesk/affIndex.php @@ -18,6 +18,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/** + * \file htdocs/cashdesk/affIndex.php + * \ingroup cashdesk + * \brief First page of point of sale module + * \version $Id$ + */ include_once('../master.inc.php'); require_once('include/environnement.php'); if ( $_SESSION['uid'] <= 0 ) { @@ -52,7 +58,12 @@ print '</head>'."\n"; print '<body>'."\n"; -if (!empty($error)) print $error; +if (!empty($error)) +{ + print $error; + print '</body></html>'; + exit; +} print '<div class="conteneur">'."\n"; print '<div class="conteneur_img_gauche">'."\n"; diff --git a/htdocs/cashdesk/facturation.php b/htdocs/cashdesk/facturation.php index f85a0817487..43a63ff2614 100644 --- a/htdocs/cashdesk/facturation.php +++ b/htdocs/cashdesk/facturation.php @@ -1,6 +1,6 @@ <?php /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net> - * Copyright (C) 2008 Laurent Destailleur <eldy@uers.sourceforge.net> + * Copyright (C) 2008-2009 Laurent Destailleur <eldy@uers.sourceforge.net> * * 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 @@ -17,22 +17,29 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// Get list of articles (in warehouse '$conf_fkentrepot' if stock module enabled) +/** + * \file htdocs/cashdesk/facturation.php + * \ingroup cashdesk + * \brief Include to show main page for cashdesk module + * \version $Id$ + */ + +// Get list of articles (in warehouse '$conf_fkentrepot' if defined and stock module enabled) if ( $_GET['filtre'] ) { // Avec filtre $ret=array(); $i=0; $sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx"; + if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= ", ps.reel"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product"; + if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$conf_fkentrepot."'"; $sql.= " WHERE p.envente = 1"; $sql.= " AND p.fk_product_type = 0"; - if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.=" AND ps.fk_entrepot = '".$conf_fkentrepot."'"; $sql.= " AND (p.ref LIKE '%".$_GET['filtre']."%' OR p.label LIKE '%".$_GET['filtre']."%')"; $sql.= " ORDER BY label"; - dol_syslog($sql); + dol_syslog("facturation.php sql=".$sql); $resql=$db->query ($sql); if ($resql) { @@ -57,11 +64,11 @@ if ( $_GET['filtre'] ) { $i=0; $sql = "SELECT p.rowid, ref, label, tva_tx"; + if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= ", ps.reel"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product"; + if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".$conf_fkentrepot; $sql.= " WHERE p.envente = 1"; $sql.= " AND p.fk_product_type = 0"; - if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " AND ps.fk_entrepot = ".$conf_fkentrepot; $sql.= " ORDER BY p.label"; dol_syslog($sql); diff --git a/htdocs/cashdesk/facturation_dhtml.php b/htdocs/cashdesk/facturation_dhtml.php index cf5b262774c..b0883006cae 100644 --- a/htdocs/cashdesk/facturation_dhtml.php +++ b/htdocs/cashdesk/facturation_dhtml.php @@ -30,15 +30,15 @@ $langs->load("@cashdesk"); if ( strlen ($_GET["code"]) >= 0 ) // If at least one key { $sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx"; + if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= ", ps.reel"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product"; + if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$conf_fkentrepot."'"; $sql.= " WHERE p.envente = 1"; $sql.= " AND p.fk_product_type = 0"; - if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.=" AND ps.fk_entrepot = '".$conf_fkentrepot."'"; $sql.= " AND (p.ref LIKE '%".$_GET['code']."%' OR p.label LIKE '%".$_GET['code']."%')"; $sql.= " ORDER BY label"; - dol_syslog($sql); + dol_syslog("facturation_dhtml.php sql=".$sql); $result = $db->query($sql); if ($result) diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index 2c5bda9cb13..21cdae0aa20 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -33,7 +33,7 @@ switch ( $_GET['action'] ) $sql = "SELECT p.rowid, p.ref, p.price, p.tva_tx"; if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= ", ps.reel"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product"; + if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".$conf_fkentrepot; // Recuperation des donnees en fonction de la source (liste deroulante ou champ texte) ... if ( $_POST['hdnSource'] == 'LISTE' ) @@ -44,7 +44,6 @@ switch ( $_GET['action'] ) { $sql.= " WHERE p.ref = '".$_POST['txtRef']."'"; } - if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= " AND ps.fk_entrepot = ".$conf_fkentrepot; $result = $db->query($sql); diff --git a/htdocs/cashdesk/include/environnement.php b/htdocs/cashdesk/include/environnement.php index 873c283a38b..441adb88193 100644 --- a/htdocs/cashdesk/include/environnement.php +++ b/htdocs/cashdesk/include/environnement.php @@ -1,6 +1,7 @@ <?php /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net> - * + * Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net> + * * 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 @@ -44,8 +45,8 @@ $conf_fkaccount_cash = $conf->global->CASHDESK_ID_BANKACCOUNT_CASH > 0?$conf->gl $conf_fkaccount_cheque = $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE > 0?$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE:$_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"]; // Identifiant unique correspondant au compte cb $conf_fkaccount_cb = $conf->global->CASHDESK_ID_BANKACCOUNT_CB > 0?$conf->global->CASHDESK_ID_BANKACCOUNT_CB:$_SESSION["CASHDESK_ID_BANKACCOUNT_CB"]; -// Identifiant unique correspondant a l'entrepot associe a la caisse -//$conf_fkentrepot = $conf->global->CASHDESK_ID_WAREHOUSE > 0?$conf->global->CASHDESK_ID_WAREHOUSE:$_SESSION["CASHDESK_ID_WAREHOUSE"]; +// Identifiant unique correspondant a l'entrepot a utiliser +$conf_fkentrepot = $conf->global->CASHDESK_ID_WAREHOUSE > 0?$conf->global->CASHDESK_ID_WAREHOUSE:$_SESSION["CASHDESK_ID_WAREHOUSE"]; // Check if setup ok $error = ''; @@ -60,7 +61,7 @@ if ($conf->banque->enabled && (empty($conf_fkaccount_cash) || empty($conf_fkacco // If we setup stock module to ask movement on invoices, with must not work if required setup not finished. if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_BILL && empty($conf_fkentrepot)) { - $error.= '<div class="error">Setup of CashDesk module not complete. Warehouse (for stock decrease on invoice) is not defined</div>'; + $error.= '<div class="error">Setup of CashDesk module not complete. You ask to decrease stock on invoice creation but warehouse for this is not defined (Change stock module setup, or complete point of sale module setup).</div>'; } // Parametres d'affichage diff --git a/htdocs/cashdesk/templates/facturation1.tpl.php b/htdocs/cashdesk/templates/facturation1.tpl.php index 314f97a0312..d2c1b2f1f91 100644 --- a/htdocs/cashdesk/templates/facturation1.tpl.php +++ b/htdocs/cashdesk/templates/facturation1.tpl.php @@ -3,7 +3,8 @@ $langs->load("main"); $langs->load("bills"); $langs->load("@cashdesk"); ?> -<!--Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net> +<!-- +Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net> 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 @@ -18,6 +19,8 @@ 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$ --> <script type="text/javascript" src="javascript/facturation1.js"></script> <script type="text/javascript" src="javascript/dhtml.js"></script> @@ -68,7 +71,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. } - echo ('<option '.$selected.' value="'.$tab_designations[$i]['rowid'].'">'.$tab_designations[$i]['ref'].' - '.$label.'</option>'."\n "); + print '<option '.$selected.' value="'.$tab_designations[$i]['rowid'].'">'.$tab_designations[$i]['ref'].' - '.$label; + if ($conf->stock->enabled && !empty($conf_fkentrepot)) print ' ('.$langs->trans("Warehouse").': '.$tab_designations[$i]['reel'].')'; + print '</option>'."\n "; } @@ -94,7 +99,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. } - echo ('<option '.$selected.' value="'.$tab_designations[$i]['rowid'].'">'.$tab_designations[$i]['ref'].' - '.$label.'</option>'."\n "); + print '<option '.$selected.' value="'.$tab_designations[$i]['rowid'].'">'.$tab_designations[$i]['ref'].' - '.$label; + if ($conf->stock->enabled && !empty($conf_fkentrepot)) print ' ('.$langs->trans("Warehouse").': '.(empty($tab_designations[$i]['reel'])?0:$tab_designations[$i]['reel']).')'; + print '</option>'."\n "; } diff --git a/htdocs/product/stock/fiche.php b/htdocs/product/stock/fiche.php index b2d2ec8f644..0eab8d19f58 100644 --- a/htdocs/product/stock/fiche.php +++ b/htdocs/product/stock/fiche.php @@ -335,6 +335,7 @@ else $sql.= " ORDER BY " . $sortfield . " " . $sortorder; //$sql .= $db->plimit($limit + 1 ,$offset); + dol_syslog('List products sql='.$sql); $resql = $db->query($sql) ; if ($resql) { -- GitLab