2
0
forked from Wavyzz/dolibarr

Fix: No error when no product has been selected on point of sale module.

This commit is contained in:
Laurent Destailleur
2010-07-14 11:19:25 +00:00
parent d4ab29b71f
commit e5e80de504
5 changed files with 81 additions and 56 deletions

View File

@@ -32,10 +32,10 @@
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
//if (! defined("NOLOGIN")) define("NOLOGIN",'1');
//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
// Change this following line to use the correct relative path (../, ../../, etc)
require("../main.inc.php");

View File

@@ -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-2010 Laurent Destailleur <eldy@uers.sourceforge.net>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
@@ -28,18 +28,18 @@ include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
class Facturation {
/**
* Attributs "volatiles" : r<EFBFBD>initialis<EFBFBD>s apr<EFBFBD>s chaque traitement d'un article
* <p>Attributs "volatiles" : r<EFBFBD>initialis<EFBFBD>s apr<EFBFBD>s chaque traitement d'un article</p>
* Attributs "volatiles" : reinitialises apres chaque traitement d'un article
* <p>Attributs "volatiles" : reinitialises apres chaque traitement d'un article</p>
* @var int $id => 'rowid' du produit dans llx_product
* @var string $ref => 'ref' du produit dans llx_product
* @var int $qte => Quantit<EFBFBD> pour le produit en cours de traitement
* @var int $stock => Stock th<EFBFBD>orique pour le produit en cours de traitement
* @var int $qte => Quantite pour le produit en cours de traitement
* @var int $stock => Stock theorique pour le produit en cours de traitement
* @var int $remise_percent => Remise en pourcent sur le produit en cours
* @var int $montant_remise => Remise en pourcent sur le produit en cours
* @var int $prix => Prix HT du produit en cours
* @var int $tva => 'rowid' du taux de tva dans llx_c_tva
*/
protected $id;
var $id;
protected $ref;
protected $qte;
protected $stock;
@@ -86,11 +86,11 @@ class Facturation {
public function ajoutArticle()
{
global $db;
$sql = "SELECT taux";
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva";
$sql.= " WHERE rowid = ".$this->tva();
dol_syslog("ajoutArticle sql=".$sql);
$resql = $db->query($sql);
@@ -104,7 +104,7 @@ class Facturation {
{
dol_print_error($db);
}
// Define part of HT, VAT, TTC
$resultarray=calcul_price_total($this->qte,$this->prix(),$this->remise_percent(),$vat_rate,0,0,0,'HT',0);
@@ -113,7 +113,7 @@ class Facturation {
$total_ht = $resultarray[0];
$total_vat = $resultarray[1];
$total_ttc = $resultarray[2];
// Calcul du montant de la remise
if ($this->remise_percent())
{
@@ -141,10 +141,10 @@ class Facturation {
$sql.= ", ".price2num($total_ht,'MT');
$sql.= ", ".price2num($total_ttc,'MT');
$sql.= ")";
dol_syslog("ajoutArticle sql=".$sql);
$result = $db->query($sql);
if (!$result)
{
dol_print_error($db);
@@ -160,11 +160,11 @@ class Facturation {
public function supprArticle($aArticle)
{
global $db;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."tmp_caisse";
$sql.= " WHERE id = ".$aArticle;
$sql.= " LIMIT 1";
$db->query($sql);
}
@@ -175,7 +175,7 @@ class Facturation {
public function calculTotaux()
{
global $db;
$res = $db->query ('SELECT remise, total_ht, total_ttc, taux FROM '.MAIN_DB_PREFIX.'tmp_caisse as c
LEFT JOIN '.MAIN_DB_PREFIX.'c_tva as t ON c.fk_tva = t.rowid
ORDER BY id');

View File

@@ -19,15 +19,30 @@
/**
* This page is called each time we press a key in the code or description
* search form to show product combo list
* search form to show product combo list.
*/
include('../master.inc.php');
require ('include/environnement.php');
$langs->load("@cashdesk");
// Verification
if ( strlen ($_GET["code"]) >= 0 ) // If at least one key
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
//if (! defined("NOLOGIN")) define("NOLOGIN",'1');
// Change this following line to use the correct relative path (../, ../../, etc)
require("../main.inc.php");
require(DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php');
//header("Content-type: text/html; charset=UTF-8");
header("Content-type: text/html; charset=".$conf->file->character_set_client);
// Search from criteria
if ( strlen ($_GET["code"]) >= 0 ) // If search criteria is on char length at least
{
$sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx";
if ($conf->stock->enabled && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
@@ -37,7 +52,7 @@ if ( strlen ($_GET["code"]) >= 0 ) // If at least one key
$sql.= " AND p.fk_product_type = 0";
$sql.= " AND (p.ref LIKE '%".$_GET['code']."%' OR p.label LIKE '%".$_GET['code']."%')";
$sql.= " ORDER BY label";
dol_syslog("facturation_dhtml.php sql=".$sql);
$result = $db->query($sql);
@@ -46,7 +61,7 @@ if ( strlen ($_GET["code"]) >= 0 ) // If at least one key
if ( $nbr = $db->num_rows($result) )
{
$resultat = '<ul class="dhtml_bloc">';
$ret=array(); $i=0;
while ( $tab = $db->fetch_array($result) )
{
@@ -57,23 +72,25 @@ if ( strlen ($_GET["code"]) >= 0 ) // If at least one key
$i++;
}
$tab=$ret;
for ( $i = 0; $i < count ($tab); $i++ )
{
$resultat .= '
<li class="dhtml_defaut" title="'.$tab[$i]['ref'].'"
onMouseOver="javascript: this.className = \'dhtml_selection\';"
onMouseOut="javascript: this.className = \'dhtml_defaut\';"
">'.htmlentities($tab[$i]['ref'].' - '.$tab[$i]['label']).'</li>
>'.$tab[$i]['ref'].' - '.$tab[$i]['label'].'</li>
';
}
$resultat .= '</ul>';
print $resultat;
}
else
{
$langs->load("cashdesk@cashdesk");
print '<ul class="dhtml_bloc">';
print '<li class="dhtml_defaut">'.$langs->trans("NoResults").'</li>';
print '</ul>';

View File

@@ -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) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2008-2010 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
@@ -18,8 +18,8 @@
*/
require ('../master.inc.php');
require ('include/environnement.php');
require ('class/Facturation.class.php');
require (DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php');
require (DOL_DOCUMENT_ROOT.'/cashdesk/class/Facturation.class.php');
$obj_facturation = unserialize ($_SESSION['serObjFacturation']);
unset ($_SESSION['serObjFacturation']);
@@ -34,7 +34,7 @@ switch ( $_GET['action'] )
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 AND ps.fk_entrepot = ".$conf_fkentrepot;
// Recuperation des donnees en fonction de la source (liste deroulante ou champ texte) ...
if ( $_POST['hdnSource'] == 'LISTE' )
{
@@ -44,9 +44,9 @@ switch ( $_GET['action'] )
{
$sql.= " WHERE p.ref = '".$_POST['txtRef']."'";
}
$result = $db->query($sql);
if ($result)
{
// ... et enregistrement dans l'objet
@@ -58,13 +58,13 @@ switch ( $_GET['action'] )
{
$ret[$key] = $value;
}
$obj_facturation->id( $ret['rowid'] );
$obj_facturation->ref( $ret['ref'] );
$obj_facturation->stock( $ret['reel'] );
$obj_facturation->prix( $ret['price'] );
$obj_facturation->tva( $ret['tva_tx'] );
// Definition du filtre pour n'afficher que le produit concerne
if ( $_POST['hdnSource'] == 'LISTE' )
{
@@ -74,13 +74,13 @@ switch ( $_GET['action'] )
{
$filtre = $_POST['txtRef'];
}
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation&filtre='.$filtre;
}
else
{
$obj_facturation->raz();
if ( $_POST['hdnSource'] == 'REF' )
{
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation&filtre='.$_POST['txtRef'];
@@ -101,22 +101,30 @@ switch ( $_GET['action'] )
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation';
}
break;
break;
case 'ajout_article':
$obj_facturation->qte($_POST['txtQte']);
$obj_facturation->tva($_POST['selTva']);
$obj_facturation->remise_percent($_POST['txtRemise']);
$obj_facturation->ajoutArticle();
case 'ajout_article': // We have clicked on button "Add product"
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation';
break;
//var_dump($obj_facturation);
//exit;
if (! empty($obj_facturation->id)) // A product has been selected and stored in session
{
$obj_facturation->qte($_POST['txtQte']);
$obj_facturation->tva($_POST['selTva']);
$obj_facturation->remise_percent($_POST['txtRemise']);
$obj_facturation->ajoutArticle();
}
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation';
break;
case 'suppr_article':
$obj_facturation->supprArticle($_GET['suppr_id']);
$obj_facturation->supprArticle($_GET['suppr_id']);
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation';
break;
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation';
break;
}

View File

@@ -1,5 +1,5 @@
/* Copyright (C) 2007-2008 J<EFBFBD>r<EFBFBD>mie 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
@@ -51,7 +51,7 @@ function file (fichier) {
}
// Affichage des donn<EFBFBD>es aTexte dans le bloc identifi<EFBFBD> par aId
// Affichage des donnees aTexte dans le bloc identifie par aId
function afficheDonnees (aId, aTexte) {
document.getElementById(aId).innerHTML = aTexte;
@@ -59,7 +59,7 @@ function afficheDonnees (aId, aTexte) {
}
// aCible : id du bloc de destination; aCode : argument <EFBFBD> passer <EFBFBD> la page php charg<EFBFBD>e du traitement et de l'affichage
// aCible : id du bloc de destination; aCode : argument a passer a la page php chargee du traitement et de l'affichage
function verifResultat (aCible, aCode) {
if (aCode != '') {
@@ -76,7 +76,7 @@ function verifResultat (aCible, aCode) {
}
// Change dynamiquement la classe de l'<EFBFBD>l<EFBFBD>ment ayant l'id aIdElement pour aClasse
// Change dynamiquement la classe de l'element ayant l'id aIdElement pour aClasse
function setStyle (aIdElement, aClasse) {
aIdElement.className = aClasse;