diff --git a/htdocs/cashdesk/classes/Auth.class.php b/htdocs/cashdesk/classes/Auth.class.php index c08e8ac27da..d9285fc436c 100644 --- a/htdocs/cashdesk/classes/Auth.class.php +++ b/htdocs/cashdesk/classes/Auth.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2008 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 * the Free Software Foundation; either version 2 of the License, or @@ -96,62 +96,69 @@ protected function verif_utilisateurs () { global $conf, $db; - + //var_dump($conf->db); //$sql = new Sql ($conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name); $sql = $db; - + // Verification des informations dans la base - $res = $sql->query ($this->sql); - $num = $sql->num_rows ($res); + $resql = $sql->query ($this->sql); + if ($resql) + { + $num = $sql->num_rows ($resql); - if ( $num ) { + if ( $num ) { - // fetchFirst - $ret=array(); - $tab = mysql_fetch_array($res); - foreach ( $tab as $cle => $valeur ) - { - $ret[$cle] = $valeur; - } - $tab=$ret; + // fetchFirst + $ret=array(); + $tab = $sql->fetch_array($resql); + foreach ( $tab as $cle => $valeur ) + { + $ret[$cle] = $valeur; + } + $tab=$ret; - if ( ($tab['pass_crypted'] == md5 ($this->passwd)) || (($tab['pass'] == $this->passwd) && ($tab['pass'] != ''))) { + if ( ($tab['pass_crypted'] == md5 ($this->passwd)) || (($tab['pass'] == $this->passwd) && ($tab['pass'] != ''))) { - // On verifie que le compte soit bien actif - if ( $tab['statut'] ) { + // On verifie que le compte soit bien actif + if ( $tab['statut'] ) { - $this->reponse(0); + $this->reponse(0); + + } else { + + $this->reponse(-2); + + } } else { - $this->reponse(-2); + $this->reponse(-1); } } else { - $this->reponse(-1); + $this->reponse(-10); } - - } else { - - $this->reponse(-10); + } + else + { } - } public function verif ($aLogin, $aPasswd) { + global $conf; $this->login ($aLogin); $this->passwd ($aPasswd); $this->sql = "SELECT rowid, pass_crypted, statut FROM ".MAIN_DB_PREFIX."user - WHERE login = '".$this->login."'"; + WHERE login = '".$this->login."' and entity IN (0,".$conf->entity.")"; $this->verif_utilisateurs(); diff --git a/htdocs/cashdesk/classes/Facturation.class.php b/htdocs/cashdesk/classes/Facturation.class.php index bca191ecd77..0b002d47867 100644 --- a/htdocs/cashdesk/classes/Facturation.class.php +++ b/htdocs/cashdesk/classes/Facturation.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2008 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 * the Free Software Foundation; either version 2 of the License, or @@ -79,10 +79,10 @@ class Facturation { // global $conf_db_host, $conf_db_user, $conf_db_pass, $conf_db_base; // $sql = new Sql ($conf_db_host, $conf_db_user, $conf_db_pass, $conf_db_base); - global $sql; + global $sql; $resql=$sql->query ('SELECT taux FROM '.MAIN_DB_PREFIX.'c_tva WHERE rowid = '.$this->tva()); - - $tab_tva = mysql_fetch_array($resql); + + $tab_tva = $sql->fetch_array($resql); $ret=array(); foreach ( $tab_tva as $cle => $valeur ) { @@ -90,7 +90,7 @@ class Facturation { } $tab_tva=$ret; // var_dump($tab_tva);exit; - + // TODO Mettre methode de calcul arrondi TVA de Dolibarr // Calcul du total ht sans remise @@ -110,7 +110,7 @@ class Facturation { // Calcul du total ttc $total_ttc = ($total_ht - $montant_remise) * (($tab_tva['taux'] / 100) + 1); - + $sql->query('INSERT INTO '.MAIN_DB_PREFIX.'tmp_caisse ( fk_article, qte, @@ -151,18 +151,18 @@ class Facturation { // global $conf_db_host, $conf_db_user, $conf_db_pass, $conf_db_base; // $sql = new Sql ($conf_db_host, $conf_db_user, $conf_db_pass, $conf_db_base); - global $sql; + global $sql; $res = $sql->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'); $total_ht=0; $total_ttc=0; - + if ( $sql->num_rows($res) ) { $ret=array(); $i=0; - while ( $tab = mysql_fetch_array($res) ) + while ( $tab = $sql->fetch_array($res) ) { foreach ( $tab as $cle => $valeur ) { @@ -171,7 +171,7 @@ class Facturation { $i++; } $tab=$ret; - + for ( $i = 0; $i < count($tab); $i++ ) { // Total HT diff --git a/htdocs/cashdesk/facturation.php b/htdocs/cashdesk/facturation.php index 9dd14462b52..266ae5671e8 100644 --- a/htdocs/cashdesk/facturation.php +++ b/htdocs/cashdesk/facturation.php @@ -1,7 +1,7 @@ * Copyright (C) 2008 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 * the Free Software Foundation; either version 2 of the License, or @@ -32,7 +32,7 @@ if ( $_GET['filtre'] ) { AND ref LIKE \'%'.$_GET['filtre'].'%\' OR label LIKE \'%'.$_GET['filtre'].'%\' ORDER BY label'); - while ( $tab = mysql_fetch_array($resql) ) + while ( $tab = $sql->fetch_array($resql) ) { foreach ( $tab as $cle => $valeur ) { @@ -52,7 +52,7 @@ if ( $_GET['filtre'] ) { AND fk_product_type = 0 AND fk_entrepot = '.$conf_fkentrepot.' ORDER BY label'); - while ( $tab = mysql_fetch_array($resql) ) + while ( $tab = $sql->fetch_array($resql) ) { foreach ( $tab as $cle => $valeur ) { @@ -92,7 +92,7 @@ if ( $nbr_enreg > 1 ) { global $mysoc; $request="SELECT t.rowid, t.taux FROM ".MAIN_DB_PREFIX."c_tva as t, llx_c_pays as p - WHERE t.fk_pays = p.rowid AND t.active = 1 AND p.code = '".$mysoc->pays_code."'"; + WHERE t.fk_pays = p.rowid AND t.active = 1 AND p.code = '".$mysoc->pays_code."'"; //print $request; $ret=array(); $i=0; diff --git a/htdocs/cashdesk/facturation_dhtml.php b/htdocs/cashdesk/facturation_dhtml.php index 2ac6b7813a9..23cc57ad12f 100644 --- a/htdocs/cashdesk/facturation_dhtml.php +++ b/htdocs/cashdesk/facturation_dhtml.php @@ -1,7 +1,7 @@ * Copyright (C) 2008 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 * the Free Software Foundation; either version 2 of the License, or @@ -38,7 +38,7 @@ $resultat = '
    '; $ret=array(); $i=0; - while ( $tab = mysql_fetch_array($res) ) + while ( $tab = $sql->fetch_array($res) ) { foreach ( $tab as $cle => $valeur ) { @@ -47,7 +47,7 @@ $i++; } $tab=$ret; - + for ( $i = 0; $i < count ($tab); $i++ ) { $resultat .= ' diff --git a/htdocs/cashdesk/facturation_verif.php b/htdocs/cashdesk/facturation_verif.php index 54a3e1351f0..b9ae226dd99 100644 --- a/htdocs/cashdesk/facturation_verif.php +++ b/htdocs/cashdesk/facturation_verif.php @@ -55,7 +55,7 @@ switch ( $_GET['action'] ) { if ( $sql->num_rows ($res) ) { $ret=array(); - $tab = mysql_fetch_array($res); + $tab = $sql->fetch_array($res); foreach ( $tab as $cle => $valeur ) { $ret[$cle] = $valeur; diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php index 481e74c9702..d49a9db2842 100644 --- a/htdocs/cashdesk/index.php +++ b/htdocs/cashdesk/index.php @@ -1,5 +1,5 @@ +/* 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 @@ -16,6 +16,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/** + * \file htdocs/cashdesk/index.php + * \ingroup cashdesk + * \brief File to login to point of sales + * \version $Id$ + */ + // Init session. Name of session is specific to Dolibarr instance. $sessionname='DOLSESSID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]); $sessiontimeout='DOLSESSTIMEOUT_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]); @@ -41,7 +48,7 @@ if ( $_SESSION['uid'] > 0 ) - + diff --git a/htdocs/cashdesk/index_verif.php b/htdocs/cashdesk/index_verif.php index 306dc360722..ce2dbadc36c 100644 --- a/htdocs/cashdesk/index_verif.php +++ b/htdocs/cashdesk/index_verif.php @@ -24,7 +24,6 @@ require ('classes/Auth.class.php'); $username = $_POST['txtUsername']; $password = $_POST['pwdPassword']; - $auth = new Auth ($conf_db_host,$conf_db_user, $conf_db_pass, $conf_db_base ); $retour = $auth->verif ($username, $password); @@ -37,10 +36,10 @@ if ( $retour >= 0 ) { $res=$sql->query ( "SELECT rowid, name, firstname FROM ".MAIN_DB_PREFIX."user - WHERE login = '".$username."'"); + WHERE login = '".$username."' and entity IN (0,".$conf->entity.")"); $ret=array(); - $tab = mysql_fetch_array($res); + $tab = $sql->fetch_array($res); foreach ( $tab as $cle => $valeur ) { $ret[$cle] = $valeur; diff --git a/htdocs/cashdesk/templates/liste_articles.tpl.php b/htdocs/cashdesk/templates/liste_articles.tpl.php index 45704bbe8c9..7514446d4f3 100644 --- a/htdocs/cashdesk/templates/liste_articles.tpl.php +++ b/htdocs/cashdesk/templates/liste_articles.tpl.php @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. if ( $sql->num_rows($res) ) { $ret=array(); $i=0; - while ( $tab = mysql_fetch_array($res) ) + while ( $tab = $sql->fetch_array($res) ) { foreach ( $tab as $cle => $valeur ) { diff --git a/htdocs/cashdesk/templates/ticket.tpl.php b/htdocs/cashdesk/templates/ticket.tpl.php index 95e823d7c14..092bc3280e7 100644 --- a/htdocs/cashdesk/templates/ticket.tpl.php +++ b/htdocs/cashdesk/templates/ticket.tpl.php @@ -125,7 +125,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. if ( $sql->num_rows($res) ) { $ret=array(); $i=0; - while ( $tab = mysql_fetch_array($res) ) + while ( $tab = $sql->fetch_array($res) ) { foreach ( $tab as $cle => $valeur ) { diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index a5b7def9661..5af99444c8c 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -1,7 +1,7 @@ * Copyright (C) 2008 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 * the Free Software Foundation; either version 2 of the License, or @@ -43,12 +43,12 @@ switch ( $_GET['action'] ) { if ( $sql->num_rows ($res) ) { $ret=array(); - $tab = mysql_fetch_array($res); + $tab = $sql->fetch_array($res); foreach ( $tab as $cle => $valeur ) { $ret[$cle] = $valeur; } - + $tab_num_facture = $ret; $tab = explode ('-', $tab_num_facture['facnumber']); @@ -212,9 +212,9 @@ switch ( $_GET['action'] ) { FROM ".MAIN_DB_PREFIX."facture WHERE 1 ORDER BY rowid DESC"); - + $ret=array(); - $tab = mysql_fetch_array($resql); + $tab = $sql->fetch_array($resql); foreach ( $tab as $cle => $valeur ) { $ret[$cle] = $valeur; @@ -296,9 +296,9 @@ switch ( $_GET['action'] ) { FROM ".MAIN_DB_PREFIX."facture WHERE 1 ORDER BY rowid DESC"); - + $ret=array(); - $tab = mysql_fetch_array($resql); + $tab = $sql->fetch_array($resql); foreach ( $tab as $cle => $valeur ) { $ret[$cle] = $valeur; @@ -351,7 +351,7 @@ switch ( $_GET['action'] ) { ORDER BY rowid DESC"); $ret=array(); - $tab = mysql_fetch_array($resql); + $tab = $sql->fetch_array($resql); foreach ( $tab as $cle => $valeur ) { $ret[$cle] = $valeur; @@ -401,9 +401,9 @@ switch ( $_GET['action'] ) { FROM ".MAIN_DB_PREFIX."paiement WHERE 1 ORDER BY rowid DESC"); - + $ret=array(); - $tab = mysql_fetch_array($resql); + $tab = $sql->fetch_array($resql); foreach ( $tab as $cle => $valeur ) { $ret[$cle] = $valeur; @@ -453,7 +453,7 @@ switch ( $_GET['action'] ) { LEFT JOIN '.MAIN_DB_PREFIX.'product_stock ON '.MAIN_DB_PREFIX.'tmp_caisse.fk_article = '.MAIN_DB_PREFIX.'product_stock.fk_product WHERE 1'); $ret=array(); $i=0; - while ( $tab = mysql_fetch_array($res) ) + while ( $tab = $sql->fetch_array($res) ) { foreach ( $tab as $cle => $valeur ) { @@ -472,7 +472,7 @@ switch ( $_GET['action'] ) { FROM '.MAIN_DB_PREFIX.'product WHERE rowid = '.$tab_liste[$i]['fk_article']); $ret=array(); - $tab = mysql_fetch_array($res); + $tab = $sql->fetch_array($res); foreach ( $tab as $cle => $valeur ) { $ret[$cle] = $valeur; @@ -484,14 +484,14 @@ switch ( $_GET['action'] ) { FROM '.MAIN_DB_PREFIX.'c_tva WHERE rowid = '.$tab_liste[$i]['fk_tva']); $ret=array(); - $tab = mysql_fetch_array($res); + $tab = $sql->fetch_array($res); foreach ( $tab as $cle => $valeur ) { $ret[$cle] = $valeur; } $tab_tva = $ret; - - + + // Calcul du montant de la TVA $montant_tva = $tab_liste[$i]['total_ttc'] - $tab_liste[$i]['total_ht'];