diff --git a/dev/skeletons/skeleton_page.php b/dev/skeletons/skeleton_page.php index d093bda318d..785f5d967da 100644 --- a/dev/skeletons/skeleton_page.php +++ b/dev/skeletons/skeleton_page.php @@ -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"); diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index 4f68821a94f..d5988c19a42 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2008 Laurent Destailleur + * Copyright (C) 2008-2010 Laurent Destailleur * Copyright (C) 2010 Juanjo Menent * * 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�initialis�s apr�s chaque traitement d'un article - *

Attributs "volatiles" : r�initialis�s apr�s chaque traitement d'un article

+ * Attributs "volatiles" : reinitialises apres chaque traitement d'un article + *

Attributs "volatiles" : reinitialises apres chaque traitement d'un article

* @var int $id => 'rowid' du produit dans llx_product * @var string $ref => 'ref' du produit dans llx_product - * @var int $qte => Quantit� pour le produit en cours de traitement - * @var int $stock => Stock th�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'); diff --git a/htdocs/cashdesk/facturation_dhtml.php b/htdocs/cashdesk/facturation_dhtml.php index b0883006cae..4c48ff4a08c 100644 --- a/htdocs/cashdesk/facturation_dhtml.php +++ b/htdocs/cashdesk/facturation_dhtml.php @@ -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 = '
    '; - + $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 .= '
  • '.htmlentities($tab[$i]['ref'].' - '.$tab[$i]['label']).'
  • + >'.$tab[$i]['ref'].' - '.$tab[$i]['label'].' '; } - + $resultat .= '
'; - + print $resultat; } else { + $langs->load("cashdesk@cashdesk"); + print '
    '; print '
  • '.$langs->trans("NoResults").'
  • '; print '
'; diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index 488accdfaa6..52d7bb254a7 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -1,6 +1,6 @@ - * Copyright (C) 2008 Laurent Destailleur +/* Copyright (C) 2007-2008 Jeremie Ollivier + * Copyright (C) 2008-2010 Laurent Destailleur * * 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; } diff --git a/htdocs/cashdesk/javascript/dhtml.js b/htdocs/cashdesk/javascript/dhtml.js index b40f84f8e40..f91946e11c0 100644 --- a/htdocs/cashdesk/javascript/dhtml.js +++ b/htdocs/cashdesk/javascript/dhtml.js @@ -1,5 +1,5 @@ -/* Copyright (C) 2007-2008 Jérémie Ollivier +/* Copyright (C) 2007-2008 Jeremie Ollivier * * 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ées aTexte dans le bloc identifié 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 à passer à la page php chargé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'élé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;