Fix preversion for cash desk module

This commit is contained in:
Laurent Destailleur
2008-11-18 22:44:53 +00:00
parent c2cb3e3c7a
commit 3ad5d6b566
16 changed files with 958 additions and 783 deletions

View File

@@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2007-2008 J<EFBFBD>r<EFBFBD>mie Ollivier <jeremie.o@laposte.net> /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* * Copyright (C) 2008 Laurent Destailleur <eldy@uers.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@@ -18,7 +19,7 @@
require ('classes/Facturation.class.php'); require ('classes/Facturation.class.php');
// Si nouvelle vente, r<EFBFBD>initialisation des donn<EFBFBD>es (destruction de l'objet et vidage de la table contenant la liste des articles) // Si nouvelle vente, reinitialisation des donnees (destruction de l'objet et vidage de la table contenant la liste des articles)
if ( $_GET['id'] == 'NOUV' ) { if ( $_GET['id'] == 'NOUV' ) {
unset ($_SESSION['serObjFacturation']); unset ($_SESSION['serObjFacturation']);
@@ -27,7 +28,7 @@ if ( $_GET['id'] == 'NOUV' ) {
} }
// R<EFBFBD>cup<EFBFBD>ration, s'il existe, de l'objet contenant les infos de la vente en cours ... // Recuperation, s'il existe, de l'objet contenant les infos de la vente en cours ...
if ( isset ($_SESSION['serObjFacturation']) ) { if ( isset ($_SESSION['serObjFacturation']) ) {
$obj_facturation = unserialize ($_SESSION['serObjFacturation']); $obj_facturation = unserialize ($_SESSION['serObjFacturation']);
@@ -45,6 +46,7 @@ if ( isset ($_SESSION['serObjFacturation']) ) {
<div class="liste_articles"><?php include ('liste_articles.php'); ?></div> <div class="liste_articles"><?php include ('liste_articles.php'); ?></div>
<div class="principal"><?php <div class="principal"><?php
if ( $_GET['menu'] ) { if ( $_GET['menu'] ) {
include ($_GET['menu'].'.php'); include ($_GET['menu'].'.php');

View File

@@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2007-2008 J<EFBFBD>r<EFBFBD>mie Ollivier <jeremie.o@laposte.net> /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* * Copyright (C) 2008 Laurent Destailleur <eldy@uers.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@@ -32,7 +33,7 @@ if ( $_SESSION['uid'] <= 0 ) {
<meta name="robots" content="none" /> <meta name="robots" content="none" />
<meta name="author" content="J<EFBFBD>r<EFBFBD>mie Ollivier - jeremie.o@laposte.net" /> <meta name="author" content="Jeremie Ollivier - jeremie.o@laposte.net" />
<meta name="Generator" content="Kwrite, Gimp, Inkscape" /> <meta name="Generator" content="Kwrite, Gimp, Inkscape" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
@@ -41,7 +42,7 @@ if ( $_SESSION['uid'] <= 0 ) {
<meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Style-Type" content="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" media="screen" /> <link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<!-- Import des fichiers n<EFBFBD>cessaires <EFBFBD> JsCalendar --> <!-- Import des fichiers necessaires a JsCalendar -->
<style type="text/css"> <style type="text/css">
@import url(include/jscalendar/calendar-blue.css); @import url(include/jscalendar/calendar-blue.css);
</style> </style>

View File

@@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2007-2008 J<EFBFBD>r<EFBFBD>mie Ollivier <jeremie.o@laposte.net> /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* * Copyright (C) 2008 Laurent Destailleur <eldy@uers.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@@ -90,22 +91,34 @@
/** /**
* Authentification d'un demandeur * Authentification d'un demandeur
* @return (int) 0 = Ok; -1 = login incorrect; -2 = login ok, mais compte d<>sactiv<69>; -10 = aucune entr<74>e trouv<75>e dans la base * @return (int) 0 = Ok; -1 = login incorrect; -2 = login ok, mais compte d<>sactiv<69>; -10 = aucune entr<74>e trouv<75>e dans la base
*/ */
protected function verif_utilisateurs () { protected function verif_utilisateurs () {
$sql = new Sql ($this->host, $this->user, $this->pass, $this->base); global $conf, $db;
// V<>rification des informations dans la base //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); $res = $sql->query ($this->sql);
$num = $sql->num_rows ($res);
if ( $sql->numRows ($res) ) { if ( $num ) {
$tab = $sql->fetchFirst ($res); // fetchFirst
$ret=array();
$tab = mysql_fetch_array($res);
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 v<EFBFBD>rifie que le compte soit bien actif // On verifie que le compte soit bien actif
if ( $tab['statut'] ) { if ( $tab['statut'] ) {
$this->reponse(0); $this->reponse(0);

View File

@@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2007-2008 J<EFBFBD>r<EFBFBD>mie Ollivier <jeremie.o@laposte.net> /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* * Copyright (C) 2008 Laurent Destailleur <eldy@uers.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@@ -16,94 +17,101 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
class Facturation { class Facturation {
/** /**
* Attributs "volatiles" : r<>initialis<69>s apr<70>s chaque traitement d'un article * Attributs "volatiles" : r<>initialis<69>s apr<70>s chaque traitement d'un article
* <p>Attributs "volatiles" : r<>initialis<69>s apr<70>s chaque traitement d'un article</p> * <p>Attributs "volatiles" : r<>initialis<69>s apr<70>s chaque traitement d'un article</p>
* @var int $id => 'rowid' du produit dans llx_product * @var int $id => 'rowid' du produit dans llx_product
* @var string $ref => 'ref' du produit dans llx_product * @var string $ref => 'ref' du produit dans llx_product
* @var int $qte => Quantit<69> pour le produit en cours de traitement * @var int $qte => Quantit<69> pour le produit en cours de traitement
* @var int $stock => Stock th<74>orique pour le produit en cours de traitement * @var int $stock => Stock th<74>orique pour le produit en cours de traitement
* @var int $remise_percent => Remise en pourcent sur le produit en cours * @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 $montant_remise => Remise en pourcent sur le produit en cours
* @var int $prix => Prix HT du produit en cours * @var int $prix => Prix HT du produit en cours
* @var int $tva => 'rowid' du taux de tva dans llx_c_tva * @var int $tva => 'rowid' du taux de tva dans llx_c_tva
*/ */
protected $id; protected $id;
protected $ref; protected $ref;
protected $qte; protected $qte;
protected $stock; protected $stock;
protected $remise_percent; protected $remise_percent;
protected $montant_remise; protected $montant_remise;
protected $prix; protected $prix;
protected $tva; protected $tva;
/** /**
* Attributs persistants : utilis<69>s pour toute la dur<75>e de la vente (jusqu'<27> validation ou annulation) * Attributs persistants : utilis<69>s pour toute la dur<75>e de la vente (jusqu'<27> validation ou annulation)
* @var string $num_facture => Num<75>ro de la facture (de la forme FAYYMM-XXXX) * @var string $num_facture => Num<75>ro de la facture (de la forme FAYYMM-XXXX)
* @var string $mode_reglement => Mode de r<>glement (ESP, CB ou CHQ) * @var string $mode_reglement => Mode de r<>glement (ESP, CB ou CHQ)
* @var int $montant_encaisse => Montant encaiss<73> en cas de r<>glement en esp<73>ces * @var int $montant_encaisse => Montant encaiss<73> en cas de r<>glement en esp<73>ces
* @var int $montant_rendu => Monnaie rendue en cas de r<>glement en esp<73>ces * @var int $montant_rendu => Monnaie rendue en cas de r<>glement en esp<73>ces
* @var int $paiement_le => Date de paiement en cas de paiement diff<66>r<EFBFBD> * @var int $paiement_le => Date de paiement en cas de paiement diff<66>r<EFBFBD>
* *
* @var int $prix_total_ht => Prix total hors taxes * @var int $prix_total_ht => Prix total hors taxes
* @var int $montant_tva => Montant total de la TVA, tous taux confondus * @var int $montant_tva => Montant total de la TVA, tous taux confondus
* @var int $prix_total_ttc => Prix total TTC * @var int $prix_total_ttc => Prix total TTC
*/ */
protected $num_facture; protected $num_facture;
protected $mode_reglement; protected $mode_reglement;
protected $montant_encaisse; protected $montant_encaisse;
protected $montant_rendu; protected $montant_rendu;
protected $paiement_le; protected $paiement_le;
protected $prix_total_ht; protected $prix_total_ht;
protected $montant_tva; protected $montant_tva;
protected $prix_total_ttc; protected $prix_total_ttc;
public function __construct () { public function __construct () {
$this->raz(); $this->raz();
$this->raz_pers(); $this->raz_pers();
} }
// M<EFBFBD>thodes de traitement des donn<EFBFBD>es // Methodes de traitement des donnees
/** /**
* Ajout d'un article au panier * Ajout d'un article au panier
*/ */
public function ajoutArticle () { public function ajoutArticle () {
global $conf_db_host, $conf_db_user, $conf_db_pass, $conf_db_base; // 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);
$sql = new Sql ($conf_db_host, $conf_db_user, $conf_db_pass, $conf_db_base);
$tab_tva = $sql->fetchFirst ( $sql->query ('SELECT taux FROM '.MAIN_DB_PREFIX.'c_tva WHERE rowid = '.$this->tva().';') ); global $sql;
$resql=$sql->query ('SELECT taux FROM '.MAIN_DB_PREFIX.'c_tva WHERE rowid = '.$this->tva());
$tab_tva = mysql_fetch_array($resql);
$ret=array();
foreach ( $tab_tva as $cle => $valeur )
{
$ret[$cle] = $valeur;
}
$tab_tva=$ret;
// var_dump($tab_tva);exit;
// TODO Mettre methode de calcul arrondi TVA de Dolibarr
// Calcul du total ht sans remise
$total_ht = ( $this->qte * $this->prix() );
// Calcul du montant de la remise
if ( $this->remise_percent() ) {
$remise_percent = $this->remise_percent();
} else {
$remise_percent = 0;
}
$montant_remise = $total_ht * $remise_percent / 100;
$this->montant_remise ($montant_remise);
// Calcul du total ttc
$total_ttc = ($total_ht - $montant_remise) * (($tab_tva['taux'] / 100) + 1);
// TODO Mettre methode de calcul arrondi TVA de Dolibarr $sql->query('INSERT INTO '.MAIN_DB_PREFIX.'tmp_caisse (
// Calcul du total ht sans remise
$total_ht = ( $this->qte * $this->prix() );
// Calcul du montant de la remise
if ( $this->remise_percent() ) {
$remise_percent = $this->remise_percent();
} else {
$remise_percent = 0;
}
$montant_remise = $total_ht * $remise_percent / 100;
$this->montant_remise ($montant_remise);
// 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, fk_article,
qte, qte,
fk_tva, fk_tva,
@@ -120,381 +128,389 @@
'.price2num($total_ht).', '.price2num($total_ht).',
'.price2num($total_ttc).')'); '.price2num($total_ttc).')');
$this->raz(); $this->raz();
} }
/** /**
* Suppression du panier d'un article identifi<66> par son id dans la table llx_tmp_caisse * Suppression du panier d'un article identifi<66> par son id dans la table llx_tmp_caisse
*/ */
public function supprArticle ($aArticle) { public function supprArticle ($aArticle) {
global $conf_db_host, $conf_db_user, $conf_db_pass, $conf_db_base; // 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);
$sql = new Sql ($conf_db_host, $conf_db_user, $conf_db_pass, $conf_db_base); global $sql;
$sql->query('DELETE FROM '.MAIN_DB_PREFIX.'tmp_caisse WHERE id = '.$aArticle.' LIMIT 1');
$sql->query('DELETE FROM '.MAIN_DB_PREFIX.'tmp_caisse WHERE id = '.$aArticle.' LIMIT 1'); }
} /**
/**
* Calcul du total HT, total TTC et montants TVA * Calcul du total HT, total TTC et montants TVA
*/ */
public function calculTotaux () { public function calculTotaux () {
global $conf_db_host, $conf_db_user, $conf_db_pass, $conf_db_base; // 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);
$sql = new Sql ($conf_db_host, $conf_db_user, $conf_db_pass, $conf_db_base); global $sql;
$res = $sql->query ('SELECT remise, total_ht, total_ttc, taux FROM '.MAIN_DB_PREFIX.'tmp_caisse as c
// Incr<63>mentation des compteurs
$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 LEFT JOIN '.MAIN_DB_PREFIX.'c_tva as t ON c.fk_tva = t.rowid
ORDER BY id'); ORDER BY id');
$total_ht=0; $total_ht=0;
$total_ttc=0; $total_ttc=0;
if ( $sql->numRows($res) ) { if ( $sql->num_rows($res) ) {
$tab = $sql->fetchAll($res); $ret=array(); $i=0;
while ( $tab = mysql_fetch_array($res) )
for ( $i = 0; $i < count($tab); $i++ ) { {
foreach ( $tab as $cle => $valeur )
// Total HT {
$remise = $tab[$i]['remise']; $ret[$i][$cle] = $valeur;
$total_ht += ($tab[$i]['total_ht']);
$total_ttc += ($tab[$i]['total_ttc']);
} }
$i++;
}
$tab=$ret;
for ( $i = 0; $i < count($tab); $i++ ) {
$this->prix_total_ttc = $total_ttc; // Total HT
$this->prix_total_ht = $total_ht; $remise = $tab[$i]['remise'];
$total_ht += ($tab[$i]['total_ht']);
$this->montant_tva = $total_ttc - $total_ht; $total_ttc += ($tab[$i]['total_ttc']);
//print $this->prix_total_ttc.'eeee'; exit;
} }
$this->prix_total_ttc = $total_ttc;
$this->prix_total_ht = $total_ht;
$this->montant_tva = $total_ttc - $total_ht;
//print $this->prix_total_ttc.'eeee'; exit;
} }
/** }
* R<>initialisation des attributs
/**
* R<>initialisation des attributs
*/ */
public function raz () { public function raz () {
$this->id ('RESET'); $this->id ('RESET');
$this->ref ('RESET'); $this->ref ('RESET');
$this->qte ('RESET'); $this->qte ('RESET');
$this->stock ('RESET'); $this->stock ('RESET');
$this->remise_percent ('RESET'); $this->remise_percent ('RESET');
$this->montant_remise ('RESET'); $this->montant_remise ('RESET');
$this->prix ('RESET'); $this->prix ('RESET');
$this->tva ('RESET'); $this->tva ('RESET');
} }
/** /**
* R<>initialisation des attributs persistants * R<>initialisation des attributs persistants
*/ */
public function raz_pers () { public function raz_pers () {
$this->num_facture ('RESET'); $this->num_facture ('RESET');
$this->mode_reglement ('RESET'); $this->mode_reglement ('RESET');
$this->montant_encaisse ('RESET'); $this->montant_encaisse ('RESET');
$this->montant_rendu ('RESET'); $this->montant_rendu ('RESET');
$this->paiement_le ('RESET'); $this->paiement_le ('RESET');
$this->prix_total_ht ('RESET'); $this->prix_total_ht ('RESET');
$this->montant_tva ('RESET'); $this->montant_tva ('RESET');
$this->prix_total_ttc ('RESET'); $this->prix_total_ttc ('RESET');
} }
// M<EFBFBD>thodes de modification des attributs prot<EFBFBD>g<EFBFBD>s // Methodes de modification des attributs proteges
public function id ( $aId=null ) { public function id ( $aId=null ) {
if ( !$aId ) { if ( !$aId ) {
return $this->id; return $this->id;
} else if ( $aId == 'RESET' ) { } else if ( $aId == 'RESET' ) {
$this->id = NULL; $this->id = NULL;
} else { } else {
$this->id = $aId; $this->id = $aId;
}
}
public function ref ( $aRef=null ) {
if ( !$aRef ) {
return $this->ref;
} else if ( $aRef == 'RESET' ) {
$this->ref = NULL;
} else {
$this->ref = $aRef;
}
}
public function qte ( $aQte=null ) {
if ( !$aQte ) {
return $this->qte;
} else if ( $aQte == 'RESET' ) {
$this->qte = NULL;
} else {
$this->qte = $aQte;
}
}
public function stock ( $aStock=null ) {
if ( !$aStock ) {
return $this->stock;
} else if ( $aStock == 'RESET' ) {
$this->stock = NULL;
} else {
$this->stock = $aStock;
}
}
public function remise_percent ( $aRemisePercent=null ) {
if ( !$aRemisePercent ) {
return $this->remise_percent;
} else if ( $aRemisePercent == 'RESET' ) {
$this->remise_percent = NULL;
} else {
$this->remise_percent = $aRemisePercent;
}
}
public function montant_remise ( $aMontantRemise=null ) {
if ( !$aMontantRemise ) {
return $this->montant_remise;
} else if ( $aMontantRemise == 'RESET' ) {
$this->montant_remise = NULL;
} else {
$this->montant_remise = $aMontantRemise;
}
}
public function prix ( $aPrix=null ) {
if ( !$aPrix ) {
return $this->prix;
} else if ( $aPrix == 'RESET' ) {
$this->prix = NULL;
} else {
$this->prix = $aPrix;
}
}
public function tva ( $aTva=null ) {
if ( !$aTva ) {
return $this->tva;
} else if ( $aTva == 'RESET' ) {
$this->tva = NULL;
} else {
$this->tva = $aTva;
}
}
public function num_facture ( $aNumFacture=null ) {
if ( !$aNumFacture ) {
return $this->num_facture;
} else if ( $aNumFacture == 'RESET' ) {
$this->num_facture = NULL;
} else {
$this->num_facture = $aNumFacture;
}
}
public function mode_reglement ( $aModeReglement=null ) {
if ( !$aModeReglement ) {
return $this->mode_reglement;
} else if ( $aModeReglement == 'RESET' ) {
$this->mode_reglement = NULL;
} else {
$this->mode_reglement = $aModeReglement;
}
}
public function montant_encaisse ( $aMontantEncaisse=null ) {
if ( !$aMontantEncaisse ) {
return $this->montant_encaisse;
} else if ( $aMontantEncaisse == 'RESET' ) {
$this->montant_encaisse = NULL;
} else {
$this->montant_encaisse = $aMontantEncaisse;
}
}
public function montant_rendu ( $aMontantRendu=null ) {
if ( !$aMontantRendu ) {
return $this->montant_rendu;
} else if ( $aMontantRendu == 'RESET' ) {
$this->montant_rendu = NULL;
} else {
$this->montant_rendu = $aMontantRendu;
}
}
public function paiement_le ( $aPaiementLe=null ) {
if ( !$aPaiementLe ) {
return $this->paiement_le;
} else if ( $aPaiementLe == 'RESET' ) {
$this->paiement_le = NULL;
} else {
$this->paiement_le = $aPaiementLe;
}
}
public function prix_total_ht ( $aTotalHt=null ) {
if ( !$aTotalHt ) {
return $this->prix_total_ht;
} else if ( $aTotalHt == 'RESET' ) {
$this->prix_total_ht = NULL;
} else {
$this->prix_total_ht = $aTotalHt;
}
}
public function montant_tva ( $aMontantTva=null ) {
if ( !$aMontantTva ) {
return $this->montant_tva;
} else if ( $aMontantTva == 'RESET' ) {
$this->montant_tva = NULL;
} else {
$this->montant_tva = $aMontantTva;
}
}
public function prix_total_ttc ( $aTotalTtc=null ) {
if ( !$aTotalTtc ) {
return $this->prix_total_ttc;
} else if ( $aTotalTtc == 'RESET' ) {
$this->prix_total_ttc = NULL;
} else {
$this->prix_total_ttc = $aTotalTtc;
}
} }
} }
public function ref ( $aRef=null ) {
if ( !$aRef ) {
return $this->ref;
} else if ( $aRef == 'RESET' ) {
$this->ref = NULL;
} else {
$this->ref = $aRef;
}
}
public function qte ( $aQte=null ) {
if ( !$aQte ) {
return $this->qte;
} else if ( $aQte == 'RESET' ) {
$this->qte = NULL;
} else {
$this->qte = $aQte;
}
}
public function stock ( $aStock=null ) {
if ( !$aStock ) {
return $this->stock;
} else if ( $aStock == 'RESET' ) {
$this->stock = NULL;
} else {
$this->stock = $aStock;
}
}
public function remise_percent ( $aRemisePercent=null ) {
if ( !$aRemisePercent ) {
return $this->remise_percent;
} else if ( $aRemisePercent == 'RESET' ) {
$this->remise_percent = NULL;
} else {
$this->remise_percent = $aRemisePercent;
}
}
public function montant_remise ( $aMontantRemise=null ) {
if ( !$aMontantRemise ) {
return $this->montant_remise;
} else if ( $aMontantRemise == 'RESET' ) {
$this->montant_remise = NULL;
} else {
$this->montant_remise = $aMontantRemise;
}
}
public function prix ( $aPrix=null ) {
if ( !$aPrix ) {
return $this->prix;
} else if ( $aPrix == 'RESET' ) {
$this->prix = NULL;
} else {
$this->prix = $aPrix;
}
}
public function tva ( $aTva=null ) {
if ( !$aTva ) {
return $this->tva;
} else if ( $aTva == 'RESET' ) {
$this->tva = NULL;
} else {
$this->tva = $aTva;
}
}
public function num_facture ( $aNumFacture=null ) {
if ( !$aNumFacture ) {
return $this->num_facture;
} else if ( $aNumFacture == 'RESET' ) {
$this->num_facture = NULL;
} else {
$this->num_facture = $aNumFacture;
}
}
public function mode_reglement ( $aModeReglement=null ) {
if ( !$aModeReglement ) {
return $this->mode_reglement;
} else if ( $aModeReglement == 'RESET' ) {
$this->mode_reglement = NULL;
} else {
$this->mode_reglement = $aModeReglement;
}
}
public function montant_encaisse ( $aMontantEncaisse=null ) {
if ( !$aMontantEncaisse ) {
return $this->montant_encaisse;
} else if ( $aMontantEncaisse == 'RESET' ) {
$this->montant_encaisse = NULL;
} else {
$this->montant_encaisse = $aMontantEncaisse;
}
}
public function montant_rendu ( $aMontantRendu=null ) {
if ( !$aMontantRendu ) {
return $this->montant_rendu;
} else if ( $aMontantRendu == 'RESET' ) {
$this->montant_rendu = NULL;
} else {
$this->montant_rendu = $aMontantRendu;
}
}
public function paiement_le ( $aPaiementLe=null ) {
if ( !$aPaiementLe ) {
return $this->paiement_le;
} else if ( $aPaiementLe == 'RESET' ) {
$this->paiement_le = NULL;
} else {
$this->paiement_le = $aPaiementLe;
}
}
public function prix_total_ht ( $aTotalHt=null ) {
if ( !$aTotalHt ) {
return $this->prix_total_ht;
} else if ( $aTotalHt == 'RESET' ) {
$this->prix_total_ht = NULL;
} else {
$this->prix_total_ht = $aTotalHt;
}
}
public function montant_tva ( $aMontantTva=null ) {
if ( !$aMontantTva ) {
return $this->montant_tva;
} else if ( $aMontantTva == 'RESET' ) {
$this->montant_tva = NULL;
} else {
$this->montant_tva = $aMontantTva;
}
}
public function prix_total_ttc ( $aTotalTtc=null ) {
if ( !$aTotalTtc ) {
return $this->prix_total_ttc;
} else if ( $aTotalTtc == 'RESET' ) {
$this->prix_total_ttc = NULL;
} else {
$this->prix_total_ttc = $aTotalTtc;
}
}
}
?> ?>

View File

@@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2007-2008 J<EFBFBD>r<EFBFBD>mie Ollivier <jeremie.o@laposte.net> /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* * Copyright (C) 2008 Laurent Destailleur <eldy@uers.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@@ -22,23 +23,23 @@ require_once ('Sql.interface.php');
class Sql implements intSql { class Sql implements intSql {
/** /**
* Constructeur : initialise la connection <20> la base de donn<6E>es * Constructeur : initialise la connection <20> la base de donn<6E>es
* @param $aHost Domaine ou adresse IP du serveur de base de donn<6E>es (ex : localhost ou db.monsite.fr) * @param $aHost Domaine ou adresse IP du serveur de base de donn<6E>es (ex : localhost ou db.monsite.fr)
* @param $aUser Utilisateur de la base de donn<6E>es * @param $aUser Utilisateur de la base de donn<6E>es
* @param $aPass Mot de passe de l'utilisateur de la base de donn<6E>es * @param $aPass Mot de passe de l'utilisateur de la base de donn<6E>es
* @param $aBase Nom de la base de donn<6E>es <20> utiliser * @param $aBase Nom de la base de donn<6E>es <20> utiliser
*/ */
public function __construct ($aHost, $aUser, $aPass, $aBase) { public function __construct ($aHost, $aUser, $aPass, $aBase) {
$db = mysql_connect ($aHost, $aUser, $aPass); $db = mysql_connect ($aHost, $aUser, $aPass);
mysql_select_db ($aBase, $db); mysql_select_db ($aBase, $db);
} }
/** /**
* Destructeur : ferme la connection <20> la base de donn<6E>es * Destructeur : ferme la connection <20> la base de donn<6E>es
*/ */
// D<>sactivation pour cause bug avec 1and1 // D<>sactivation pour cause bug avec 1and1
// public function __destruct () { // public function __destruct () {
// //
// mysql_close (); // mysql_close ();
@@ -46,9 +47,9 @@ class Sql implements intSql {
// } // }
/** /**
* Effectue une requ<71>te sur la base de donn<6E>es, et renvoi la ressource correspondante * Effectue une requ<71>te sur la base de donn<6E>es, et renvoi la ressource correspondante
* @param $aRequete Requ<71>te SQL (ex : SELECT nom, prenom FROM table1 WHERE id = 127) * @param $aRequete Requ<71>te SQL (ex : SELECT nom, prenom FROM table1 WHERE id = 127)
* @return Ressource vers la requ<71>te venant d'<27>tre effectu<74>e * @return Ressource vers la requ<71>te venant d'<27>tre effectu<74>e
*/ */
public function query ($aRequete) { public function query ($aRequete) {
dolibarr_syslog("cashdesk query sql=".$aRequete, LOG_DEBUG); dolibarr_syslog("cashdesk query sql=".$aRequete, LOG_DEBUG);
@@ -57,33 +58,31 @@ class Sql implements intSql {
} }
/** /**
* Renvoi le nombre de r<>sultats d'une requ<71>te * Renvoi le nombre de r<>sultats d'une requ<71>te
* @param $aRes Ressource d'une requ<71>te effectu<74>e pr<70>c<EFBFBD>demment * @param $aRes Ressource d'une requ<71>te effectu<74>e pr<70>c<EFBFBD>demment
* @return Entier : nombre de r<>sultats de la requ<71>te * @return Entier : nombre de r<>sultats de la requ<71>te
*/ */
public function numRows ($aRes) { public function num_rows ($aRes) {
return mysql_num_rows($aRes); return mysql_num_rows($aRes);
} }
/** /**
* Enregistre tous les r<>sultats d'une requ<71>te dans un tableau <20> deux dimensions * Enregistre tous les r<>sultats d'une requ<71>te dans un tableau <20> deux dimensions
* @param $aRes Ressource d'une requ<71>te effectu<74>e pr<70>c<EFBFBD>demment * @param $aRes Ressource d'une requ<71>te effectu<74>e pr<70>c<EFBFBD>demment
* @return Tableau <20> deux dimensions : $tab[indice_resultat(integer)][indice_champ(integer) / nom_champ(string)] * @return Tableau <20> deux dimensions : $tab[indice_resultat(integer)][indice_champ(integer) / nom_champ(string)]
*/ */
public function fetchAll ($aRes) { public function fetch_array ($aRes) {
$i = 0;
while ( $tab = mysql_fetch_array($aRes) ) {
foreach ( $tab as $cle => $valeur ) {
$ret=array(); $i=0;
while ( $tab = mysql_fetch_array($aRes) )
{
foreach ( $tab as $cle => $valeur )
{
$ret[$i][$cle] = $valeur; $ret[$i][$cle] = $valeur;
} }
$i++; $i++;
} }
return $ret; return $ret;
@@ -91,22 +90,21 @@ class Sql implements intSql {
} }
/** /**
* Enregistre seulement le premier r<>sultat d'une requ<71>te dans un tableau <20> une dimension * Enregistre seulement le premier r<>sultat d'une requ<71>te dans un tableau <20> une dimension
* @param $aRes Ressource d'une requ<71>te effectu<74>e pr<70>c<EFBFBD>demment * @param $aRes Ressource d'une requ<71>te effectu<74>e pr<70>c<EFBFBD>demment
* @return Tableau <20> une dimension : $tab[indice_champ(integer) / nom_champ(string)] * @return Tableau <20> une dimension : $tab[indice_champ(integer) / nom_champ(string)]
*/ */
public function fetchFirst ($aRes) { public function fetchFirst ($aRes)
{
$ret=array();
$tab = mysql_fetch_array($aRes); $tab = mysql_fetch_array($aRes);
foreach ( $tab as $cle => $valeur )
foreach ( $tab as $cle => $valeur ) { {
$ret[$cle] = $valeur; $ret[$cle] = $valeur;
} }
return $ret; return $ret;
} }
} }

View File

@@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2007-2008 J<EFBFBD>r<EFBFBD>mie Ollivier <jeremie.o@laposte.net> /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* * Copyright (C) 2008 Laurent Destailleur <eldy@uers.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@@ -18,16 +19,16 @@
interface intSql { interface intSql {
// Envoie une requ<71>te et retourne le pointeur vers le r<>sultat // Envoie une requ<71>te et retourne le pointeur vers le r<>sultat
public function query ($aRequete); public function query ($aRequete);
// Renvoie le nombre de r<>sultats contenus dans la ressource // Renvoie le nombre de r<>sultats contenus dans la ressource
public function numRows ($aRes); public function num_rows ($aRes);
// Parcours tous les r<>sultats de la ressource et les enregistre dans un tableau <20> 2 dimensions : $tab[ligne][nom_champ/indice] // Parcours tous les r<>sultats de la ressource et les enregistre dans un tableau <20> 2 dimensions : $tab[ligne][nom_champ/indice]
public function fetchAll ($aRes); public function fetch_array ($aRes);
// Enregistre seulement le premier r<>sultat de la ressource dans un tableau <20> 1 dimension : $tab[nom_champ/indice] // Enregistre seulement le premier r<>sultat de la ressource dans un tableau <20> 1 dimension : $tab[nom_champ/indice]
public function fetchFirst ($aRes); public function fetchFirst ($aRes);
} }

View File

@@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2007-2008 J<EFBFBD>r<EFBFBD>mie Ollivier <jeremie.o@laposte.net> /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* * Copyright (C) 2008 Laurent Destailleur <eldy@uers.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@@ -16,11 +17,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// R<EFBFBD>cup<EFBFBD>ration de la liste des articles // Recuperation de la liste des articles
if ( $_GET['filtre'] ) { if ( $_GET['filtre'] ) {
// Avec filtre // Avec filtre
$tab_designations = $sql->fetchAll ( $sql->query ( $ret=array(); $i=0;
$resql=$sql->query (
'SELECT '.MAIN_DB_PREFIX.'product.rowid, ref, label, tva_tx 'SELECT '.MAIN_DB_PREFIX.'product.rowid, ref, label, tva_tx
FROM '.MAIN_DB_PREFIX.'product FROM '.MAIN_DB_PREFIX.'product
LEFT JOIN '.MAIN_DB_PREFIX.'product_stock ON '.MAIN_DB_PREFIX.'product.rowid = '.MAIN_DB_PREFIX.'product_stock.fk_product LEFT JOIN '.MAIN_DB_PREFIX.'product_stock ON '.MAIN_DB_PREFIX.'product.rowid = '.MAIN_DB_PREFIX.'product_stock.fk_product
@@ -29,22 +31,36 @@ if ( $_GET['filtre'] ) {
AND fk_entrepot = '.$conf_fkentrepot.' AND fk_entrepot = '.$conf_fkentrepot.'
AND ref LIKE \'%'.$_GET['filtre'].'%\' AND ref LIKE \'%'.$_GET['filtre'].'%\'
OR label LIKE \'%'.$_GET['filtre'].'%\' OR label LIKE \'%'.$_GET['filtre'].'%\'
ORDER BY label ORDER BY label');
;')); while ( $tab = mysql_fetch_array($resql) )
{
foreach ( $tab as $cle => $valeur )
{
$ret[$i][$cle] = $valeur;
}
$i++;
}
$tab_designations=$ret;
} else { } else {
// Sans filtre // Sans filtre
$tab_designations = $sql->fetchAll ( $sql->query (' $ret=array(); $i=0;
SELECT '.MAIN_DB_PREFIX.'product.rowid, ref, label, tva_tx $resql=$sql->query ('SELECT '.MAIN_DB_PREFIX.'product.rowid, ref, label, tva_tx
FROM '.MAIN_DB_PREFIX.'product FROM '.MAIN_DB_PREFIX.'product
LEFT JOIN '.MAIN_DB_PREFIX.'product_stock ON '.MAIN_DB_PREFIX.'product.rowid = '.MAIN_DB_PREFIX.'product_stock.fk_product LEFT JOIN '.MAIN_DB_PREFIX.'product_stock ON '.MAIN_DB_PREFIX.'product.rowid = '.MAIN_DB_PREFIX.'product_stock.fk_product
WHERE envente = 1 WHERE envente = 1
AND fk_product_type = 0 AND fk_product_type = 0
AND fk_entrepot = '.$conf_fkentrepot.' AND fk_entrepot = '.$conf_fkentrepot.'
ORDER BY label ORDER BY label');
;')); while ( $tab = mysql_fetch_array($resql) )
{
foreach ( $tab as $cle => $valeur )
{
$ret[$i][$cle] = $valeur;
}
$i++;
}
$tab_designations=$ret;
} }
$nbr_enreg = count ($tab_designations); $nbr_enreg = count ($tab_designations);
@@ -53,35 +69,46 @@ if ( $nbr_enreg > 1 ) {
if ( $nbr_enreg > $conf_taille_listes ) { if ( $nbr_enreg > $conf_taille_listes ) {
$top_liste_produits = '----- '.$conf_taille_listes.' produits affich<EFBFBD>s sur un total de '.$nbr_enreg.' -----'; $top_liste_produits = '----- '.$conf_taille_listes.' produits affiches sur un total de '.$nbr_enreg.' -----';
} else { } else {
$top_liste_produits = '----- '.$nbr_enreg.' produits affich<EFBFBD>s sur un total de '.$nbr_enreg.' -----'; $top_liste_produits = '----- '.$nbr_enreg.' produits affiches sur un total de '.$nbr_enreg.' -----';
} }
} else if ( $nbr_enreg == 1 ) { } else if ( $nbr_enreg == 1 ) {
$top_liste_produits = '----- 1 article trouv<EFBFBD> -----'; $top_liste_produits = '----- 1 article trouve -----';
} else { } else {
$top_liste_produits = '----- Aucun article trouv<EFBFBD> -----'; $top_liste_produits = '----- Aucun article trouve -----';
} }
// R<EFBFBD>cup<EFBFBD>ration des taux de tva // Recuperation des taux de tva
global $mysoc; global $mysoc;
$request="SELECT t.rowid, t.taux $request="SELECT t.rowid, t.taux
FROM ".MAIN_DB_PREFIX."c_tva as t, llx_c_pays as p 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; //print $request;
$tab_tva = $sql->fetchAll ($sql->query ($request));
$ret=array(); $i=0;
$res=$sql->query ($request);
while ( $tab = $sql->fetch_array($res) )
{
foreach ( $tab as $cle => $valeur )
{
$ret[$i][$cle] = $valeur;
}
$i++;
}
$tab_tva = $ret;
// R<EFBFBD>initialisation du mode de paiement, en cas de retour aux achats apr<EFBFBD>s validation // Reinitialisation du mode de paiement, en cas de retour aux achats apres validation
$obj_facturation->mode_reglement ('RESET'); $obj_facturation->mode_reglement ('RESET');
$obj_facturation->montant_encaisse ('RESET'); $obj_facturation->montant_encaisse ('RESET');
$obj_facturation->montant_rendu ('RESET'); $obj_facturation->montant_rendu ('RESET');

View File

@@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2007-2008 J<EFBFBD>r<EFBFBD>mie Ollivier <jeremie.o@laposte.net> /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* * Copyright (C) 2008 Laurent Destailleur <eldy@uers.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@@ -32,11 +33,21 @@
OR label LIKE '%".$_GET['code']."%' OR label LIKE '%".$_GET['code']."%'
ORDER BY label"); ORDER BY label");
if ( $nbr = $sql->numRows($res) ) { if ( $nbr = $sql->num_rows($res) ) {
$resultat = '<ul class="dhtml_bloc">'; $resultat = '<ul class="dhtml_bloc">';
$tab = $sql->fetchAll($res); $ret=array(); $i=0;
while ( $tab = mysql_fetch_array($res) )
{
foreach ( $tab as $cle => $valeur )
{
$ret[$i][$cle] = $valeur;
}
$i++;
}
$tab=$ret;
for ( $i = 0; $i < count ($tab); $i++ ) { for ( $i = 0; $i < count ($tab); $i++ ) {
$resultat .= ' $resultat .= '
@@ -56,7 +67,7 @@
echo (' echo ('
<ul class="dhtml_bloc"> <ul class="dhtml_bloc">
<li class="dhtml_defaut">'.htmlentities ('Aucun r<>sultat').'</li> <li class="dhtml_defaut">'.htmlentities ('Aucun r<>sultat').'</li>
</ul> </ul>
'); ');

View File

@@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2007-2008 J<EFBFBD>r<EFBFBD>mie Ollivier <jeremie.o@laposte.net> /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2008 Laurent Destailleur <eldy@uers.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -15,107 +16,115 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
require ('../master.inc.php');
require ('include/environnement.php');
require ('classes/Facturation.class.php');
$obj_facturation = unserialize ($_SESSION['serObjFacturation']); require ('../master.inc.php');
unset ($_SESSION['serObjFacturation']); require ('include/environnement.php');
require ('classes/Facturation.class.php');
switch ( $_GET['action'] ) { $obj_facturation = unserialize ($_SESSION['serObjFacturation']);
unset ($_SESSION['serObjFacturation']);
default:
if ( $_POST['hdnSource'] != 'NULL' ) {
// R<>cup<75>ration des donn<6E>es en fonction de la source (liste d<>roulante ou champ texte) ... switch ( $_GET['action'] ) {
if ( $_POST['hdnSource'] == 'LISTE' ) {
$res = $sql->query('SELECT fk_product, ref, stock_propale, stock_commande, price, reel, tva_tx default:
if ( $_POST['hdnSource'] != 'NULL' ) {
// Recuperation des donnees en fonction de la source (liste d<>roulante ou champ texte) ...
if ( $_POST['hdnSource'] == 'LISTE' ) {
$res = $sql->query('SELECT fk_product, ref, stock_propale, stock_commande, price, reel, tva_tx
FROM '.MAIN_DB_PREFIX.'product FROM '.MAIN_DB_PREFIX.'product
LEFT JOIN '.MAIN_DB_PREFIX.'product_stock ON '.MAIN_DB_PREFIX.'product.rowid = '.MAIN_DB_PREFIX.'product_stock.fk_product LEFT JOIN '.MAIN_DB_PREFIX.'product_stock ON '.MAIN_DB_PREFIX.'product.rowid = '.MAIN_DB_PREFIX.'product_stock.fk_product
WHERE fk_product = '.$_POST['selProduit'].' WHERE fk_product = '.$_POST['selProduit'].'
;'); ;');
} else if ( $_POST['hdnSource'] == 'REF' ) { } else if ( $_POST['hdnSource'] == 'REF' ) {
$res = $sql->query('SELECT fk_product, ref, stock_propale, stock_commande, price, reel, tva_tx $res = $sql->query('SELECT fk_product, ref, stock_propale, stock_commande, price, reel, tva_tx
FROM '.MAIN_DB_PREFIX.'product FROM '.MAIN_DB_PREFIX.'product
LEFT JOIN '.MAIN_DB_PREFIX.'product_stock ON '.MAIN_DB_PREFIX.'product.rowid = '.MAIN_DB_PREFIX.'product_stock.fk_product LEFT JOIN '.MAIN_DB_PREFIX.'product_stock ON '.MAIN_DB_PREFIX.'product.rowid = '.MAIN_DB_PREFIX.'product_stock.fk_product
WHERE ref = \''.$_POST['txtRef'].'\' WHERE ref = \''.$_POST['txtRef'].'\'
;'); ;');
}
// ... et enregistrement dans l'objet
if ( $sql->num_rows ($res) ) {
$ret=array();
$tab = mysql_fetch_array($res);
foreach ( $tab as $cle => $valeur )
{
$ret[$cle] = $valeur;
}
$tab = $ret;
$obj_facturation->id( $tab['fk_product'] );
$obj_facturation->ref( $tab['ref'] );
$obj_facturation->stock( $tab['reel'] - $tab['stock_propale'] - $tab['stock_commande'] );
$obj_facturation->prix( $tab['price'] );
$obj_facturation->tva( $tab['tva_tx'] );
// Definition du filtre pour n'afficher que le produit concern<72>
if ( $_POST['hdnSource'] == 'LISTE' ) {
$filtre = $tab['ref'];
} else if ( $_POST['hdnSource'] == 'REF' ) {
$filtre = $_POST['txtRef'];;
} }
$redirection = 'affIndex.php?menu=facturation&filtre='.$filtre;
// ... et enregistrement dans l'objet
if ( $sql->numRows ($res) ) {
$tab = $sql->fetchFirst($res);
$obj_facturation->id( $tab['fk_product'] );
$obj_facturation->ref( $tab['ref'] );
$obj_facturation->stock( $tab['reel'] - $tab['stock_propale'] - $tab['stock_commande'] );
$obj_facturation->prix( $tab['price'] );
$obj_facturation->tva( $tab['tva_tx'] );
// D<>finition du filtre pour n'afficher que le produit concern<72>
if ( $_POST['hdnSource'] == 'LISTE' ) {
$filtre = $tab['ref'];
} else if ( $_POST['hdnSource'] == 'REF' ) {
$filtre = $_POST['txtRef'];;
}
$redirection = 'affIndex.php?menu=facturation&filtre='.$filtre;
} else {
$obj_facturation->raz();
if ( $_POST['hdnSource'] == 'REF' ) {
$redirection = 'affIndex.php?menu=facturation&filtre='.$_POST['txtRef'];
} else {
$redirection = 'affIndex.php?menu=facturation';
}
}
} else { } else {
$redirection = 'affIndex.php?menu=facturation'; $obj_facturation->raz();
if ( $_POST['hdnSource'] == 'REF' ) {
$redirection = 'affIndex.php?menu=facturation&filtre='.$_POST['txtRef'];
} else {
$redirection = 'affIndex.php?menu=facturation';
}
} }
break; } else {
case 'ajout_article';
$obj_facturation->qte($_POST['txtQte']);
$obj_facturation->tva($_POST['selTva']);
$obj_facturation->remise_percent($_POST['txtRemise']);
$obj_facturation->ajoutArticle();
$redirection = 'affIndex.php?menu=facturation'; $redirection = 'affIndex.php?menu=facturation';
break;
case 'suppr_article': }
$obj_facturation->supprArticle($_GET['suppr_id']);
$redirection = '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();
$redirection = 'affIndex.php?menu=facturation';
break;
case 'suppr_article':
$obj_facturation->supprArticle($_GET['suppr_id']);
$redirection = 'affIndex.php?menu=facturation';
break;
}
$_SESSION['serObjFacturation'] = serialize ($obj_facturation); $_SESSION['serObjFacturation'] = serialize ($obj_facturation);
header ('Location: '.$redirection); header ('Location: '.$redirection);
?> ?>

View File

@@ -1,5 +1,5 @@
<?php <?php
/* 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -26,20 +26,20 @@ dolibarr_syslog("Start session name=".$sessionname." Session id()=".session_id()
$conf_db_type = $dolibarr_main_db_type; $conf_db_type = $dolibarr_main_db_type;
// Param<EFBFBD>tres de connexion <EFBFBD> la base // Parametres de connexion a la base
$conf_db_host = $dolibarr_main_db_host; $conf_db_host = $dolibarr_main_db_host;
$conf_db_user = $dolibarr_main_db_user; $conf_db_user = $dolibarr_main_db_user;
$conf_db_pass = $dolibarr_main_db_pass; $conf_db_pass = $dolibarr_main_db_pass;
$conf_db_base = $dolibarr_main_db_name; $conf_db_base = $dolibarr_main_db_name;
// Param<EFBFBD>tres g<EFBFBD>n<EFBFBD>raux // Parametres generaux
$conf_url_racine = $dolibarr_main_url_root.'/cashdesk'; $conf_url_racine = $dolibarr_main_url_root.'/cashdesk';
// Identifiant unique correspondant au tiers generique pour la vente // Identifiant unique correspondant au tiers generique pour la vente
$conf_fksoc = $conf->global->CASHDESK_ID_THIRDPARTY; $conf_fksoc = $conf->global->CASHDESK_ID_THIRDPARTY;
// Identifiant unique correspondant au compte caisse / liquide // Identifiant unique correspondant au compte caisse / liquide
$conf_fkaccount = $conf->global->CASHDESK_ID_BANKACCOUNT > 0?$conf->global->CASHDESK_ID_BANKACCOUNT:$_SESSION["CASHDESK_ID_BANKACCOUNT"]; $conf_fkaccount = $conf->global->CASHDESK_ID_BANKACCOUNT > 0?$conf->global->CASHDESK_ID_BANKACCOUNT:$_SESSION["CASHDESK_ID_BANKACCOUNT"];
// Identifiant unique correspondant <EFBFBD> l'entrep<EFBFBD>t associ<EFBFBD> <20> la caisse // 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"]; $conf_fkentrepot = $conf->global->CASHDESK_ID_WAREHOUSE > 0?$conf->global->CASHDESK_ID_WAREHOUSE:$_SESSION["CASHDESK_ID_WAREHOUSE"];
// Check if setup ok // Check if setup ok
@@ -47,13 +47,14 @@ if (empty($conf_fksoc)) dolibarr_print_error("Setup of CashDesk module not
if ($conf->bank->enabled && empty($conf_fkaccount)) dolibarr_print_error("Setup of CashDesk module not complete. Bank account not defined."); if ($conf->bank->enabled && empty($conf_fkaccount)) dolibarr_print_error("Setup of CashDesk module not complete. Bank account not defined.");
if ($conf->stock->enabled && empty($conf_fkentrepot)) dolibarr_print_error("Setup of CashDesk module not complete. Warehous not defined."); if ($conf->stock->enabled && empty($conf_fkentrepot)) dolibarr_print_error("Setup of CashDesk module not complete. Warehous not defined.");
// Param<EFBFBD>tres d'affichage // Parametres d'affichage
$conf_taille_listes = 200; // Nombre max de lignes <EFBFBD> afficher dans les listes $conf_taille_listes = 200; // Nombre max de lignes a afficher dans les listes
$conf_nbr_car_listes = 60; // Nombre max de caract<EFBFBD>res par ligne dans les listes $conf_nbr_car_listes = 60; // Nombre max de caracteres par ligne dans les listes
$new_conf_db_type=$conf_db_type; $new_conf_db_type=$conf_db_type;
if (eregi('mysql',$new_conf_db_type)) $new_conf_db_type='Mysql'; if (eregi('mysql',$new_conf_db_type)) $new_conf_db_type='Mysql';
require ('classes/'.$new_conf_db_type.'.class.php'); require ('classes/'.$new_conf_db_type.'.class.php');
$sql = new Sql ($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);
$sql=$db;
?> ?>

View File

@@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2007-2008 J<EFBFBD>r<EFBFBD>mie Ollivier <jeremie.o@laposte.net> /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2008 Laurent Destailleur <eldy@uers.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -15,39 +16,49 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
include('../master.inc.php');
require ('include/environnement.php');
require ('classes/Auth.class.php');
$username = $_POST['txtUsername']; include('../master.inc.php');
$password = $_POST['pwdPassword']; require ('include/environnement.php');
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 ); $auth = new Auth ($conf_db_host,$conf_db_user, $conf_db_pass, $conf_db_base );
$retour = $auth->verif ($username, $password); $retour = $auth->verif ($username, $password);
if ( $retour >= 0 ) { if ( $retour >= 0 ) {
$db = mysql_connect ($conf_db_host,$conf_db_user, $conf_db_pass); // $db = mysql_connect ($conf_db_host,$conf_db_user, $conf_db_pass);
mysql_select_db ($conf_db_base, $db); // mysql_select_db ($conf_db_base, $db);
$tab = $sql->fetchFirst ($sql->query ( $res=$sql->query (
"SELECT rowid, name, firstname "SELECT rowid, name, firstname
FROM ".MAIN_DB_PREFIX."user FROM ".MAIN_DB_PREFIX."user
WHERE login = '".$username."'")); WHERE login = '".$username."'");
$_SESSION['uid'] = $tab['rowid'];
$_SESSION['uname'] = $username;
$_SESSION['nom'] = $tab['name'];
$_SESSION['prenom'] = $tab['firstname'];
header ('Location: affIndex.php?menu=facturation&id=NOUV');
} else {
header ('Location: index.php?err='.$retour.'&user='.$username);
$ret=array();
$tab = mysql_fetch_array($res);
foreach ( $tab as $cle => $valeur )
{
$ret[$cle] = $valeur;
} }
$tab = $ret;
$_SESSION['uid'] = $tab['rowid'];
$_SESSION['uname'] = $username;
$_SESSION['nom'] = $tab['name'];
$_SESSION['prenom'] = $tab['firstname'];
header ('Location: affIndex.php?menu=facturation&id=NOUV');
} else {
header ('Location: index.php?err='.$retour.'&user='.$username);
}
?> ?>

View File

@@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2007-2008 J<EFBFBD>r<EFBFBD>mie Ollivier <jeremie.o@laposte.net> /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* * Copyright (C) 2008 Laurent Destailleur <eldy@uers.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@@ -16,9 +17,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
require ('templates/liste_articles.tpl.php'); require ('templates/liste_articles.tpl.php');
$obj_facturation->prix_total_ht ($lst_total_ht); $obj_facturation->prix_total_ht ($lst_total_ht);
$obj_facturation->prix_total_ttc ($lst_total_ttc); $obj_facturation->prix_total_ttc ($lst_total_ttc);
?> ?>

View File

@@ -1,4 +1,4 @@
<!--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 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 it under the terms of the GNU General Public License as published by
@@ -20,15 +20,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<p class="titre">Panier</p> <p class="titre">Panier</p>
<?php <?php
// R<EFBFBD>cup<EFBFBD>ration du contenu de la vente // Recuperation du contenu de la vente
$res = $sql->query ( $res = $sql->query ('SELECT id, ref, label, qte, price, remise_percent, remise, total_ht, total_ttc FROM '.MAIN_DB_PREFIX.'tmp_caisse as c
'SELECT id, ref, label, qte, price, remise_percent, remise, total_ht, total_ttc FROM '.MAIN_DB_PREFIX.'tmp_caisse as c
LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON c.fk_article = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON c.fk_article = p.rowid
ORDER BY id'); ORDER BY id');
if ( $sql->numRows($res) ) { if ( $sql->num_rows($res) ) {
$tab = $sql->fetchAll($res); $ret=array(); $i=0;
while ( $tab = mysql_fetch_array($res) )
{
foreach ( $tab as $cle => $valeur )
{
$ret[$i][$cle] = $valeur;
}
$i++;
}
$tab = $ret;
for ( $i = 0; $i < count($tab); $i++ ) { for ( $i = 0; $i < count($tab); $i++ ) {

View File

@@ -1,4 +1,4 @@
<!--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 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 it under the terms of the GNU General Public License as published by
@@ -103,16 +103,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
66750 SAINT CYPRIEN</p> 66750 SAINT CYPRIEN</p>
<?php <?php
// R<>cup<75>ration et affichage de la date et de l'heure // R<>cup<75>ration et affichage de la date et de l'heure
$date = date ('d/m/Y'); $date = date ('d/m/Y');
$heure = date ('H:i'); $heure = date ('H:i');
echo ('<p class="date_heure">Le '.$date.' <20> '.$heure.'</p>'); echo ('<p class="date_heure">Le '.$date.' <20> '.$heure.'</p>');
?> ?>
</div> </div>
</div> </div>
<table class="liste_articles"> <table class="liste_articles">
<tr class="titres"><th>Code</th><th>Label</th><th>Qt<51></th><th>Remise (%)</th><th>Tot HT</th></tr> <tr class="titres"><th>Code</th><th>Label</th><th>Qt<51></th><th>Remise (%)</th><th>Tot HT</th></tr>
<?php <?php
@@ -122,9 +122,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON c.fk_article = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON c.fk_article = p.rowid
ORDER BY id'); ORDER BY id');
if ( $sql->numRows($res) ) { if ( $sql->num_rows($res) ) {
$tab = $sql->fetchAll($res); $ret=array(); $i=0;
while ( $tab = mysql_fetch_array($res) )
{
foreach ( $tab as $cle => $valeur )
{
$ret[$i][$cle] = $valeur;
}
$i++;
}
$tab = $ret;
for ( $i = 0; $i < count($tab); $i++ ) { for ( $i = 0; $i < count($tab); $i++ ) {
@@ -167,6 +176,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
</script> </script>
<a class="lien" href="#" onclick="javascript: window.close(); return(false);">Fermer cette fen<65>tre</a> <a class="lien" href="#" onclick="javascript: window.close(); return(false);">Fermer cette fen<65>tre</a>
</body> </body>

View File

@@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2007-2008 J<EFBFBD>r<EFBFBD>mie Ollivier <jeremie.o@laposte.net> /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* * Copyright (C) 2008 Laurent Destailleur <eldy@uers.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@@ -15,129 +16,137 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
require ('../master.inc.php');
require ('include/environnement.php');
require ('classes/Facturation.class.php');
$obj_facturation = unserialize ($_SESSION['serObjFacturation']); require ('../master.inc.php');
unset ($_SESSION['serObjFacturation']); require ('include/environnement.php');
require ('classes/Facturation.class.php');
switch ( $_GET['action'] ) { $obj_facturation = unserialize ($_SESSION['serObjFacturation']);
unset ($_SESSION['serObjFacturation']);
default: switch ( $_GET['action'] ) {
$redirection = 'affIndex.php?menu=validation'; default:
break;
case 'valide_achat': $redirection = 'affIndex.php?menu=validation';
break;
// R<>cup<75>ration du dernier num<75>ro de facture case 'valide_achat':
$res = $sql->query (
"SELECT facnumber // R<>cup<75>ration du dernier num<75>ro de facture
$res = $sql->query (
"SELECT facnumber
FROM ".MAIN_DB_PREFIX."facture FROM ".MAIN_DB_PREFIX."facture
WHERE facnumber LIKE 'FA%' WHERE facnumber LIKE 'FA%'
ORDER BY rowid DESC"); ORDER BY rowid DESC");
if ( $sql->numRows ($res) ) { if ( $sql->num_rows ($res) ) {
$tab_num_facture = $sql->fetchFirst ( $res );
$tab = explode ('-', $tab_num_facture['facnumber']);
$num_txt = $tab[1];
$num = $num_txt + 1;
// Formatage du num<75>ro sur quatre caract<63>res
if ( $num < 1000 ) { $num = '0'.$num; }
if ( $num < 100 ) { $num = '0'.$num; }
if ( $num < 10 ) { $num = '0'.$num; }
$obj_facturation->num_facture ('FA'.date('ym').'-'.$num);
} else {
$obj_facturation->num_facture ( 'FA'.date('ym').'-0001' );
}
$obj_facturation->mode_reglement ($_POST['hdnChoix']);
// Si paiement autre qu'en esp<73>ces, montant encaiss<73> = prix total
$mode_reglement = $obj_facturation->mode_reglement();
if ( $mode_reglement != 'ESP' ) {
$montant = $obj_facturation->prix_total_ttc();
} else {
$montant = $_POST['txtEncaisse'];
}
if ( $mode_reglement != 'DIF') {
$obj_facturation->montant_encaisse ($montant);
//D<>termination de la somme rendue
$total = $obj_facturation->prix_total_ttc ();
$encaisse = $obj_facturation->montant_encaisse();
$obj_facturation->montant_rendu ( $encaisse - $total );
} else {
$obj_facturation->paiement_le ($_POST['txtDatePaiement']);
$ret=array();
$tab = mysql_fetch_array($res);
foreach ( $tab as $cle => $valeur )
{
$ret[$cle] = $valeur;
} }
$tab_num_facture = $ret;
$redirection = 'affIndex.php?menu=validation'; $tab = explode ('-', $tab_num_facture['facnumber']);
break; $num_txt = $tab[1];
$num = $num_txt + 1;
case 'retour': // Formatage du num<75>ro sur quatre caract<63>res
if ( $num < 1000 ) { $num = '0'.$num; }
if ( $num < 100 ) { $num = '0'.$num; }
if ( $num < 10 ) { $num = '0'.$num; }
$redirection = 'affIndex.php?menu=facturation'; $obj_facturation->num_facture ('FA'.date('ym').'-'.$num);
break;
case 'valide_facture': } else {
// R<>cup<75>ration de la date et de l'heure $obj_facturation->num_facture ( 'FA'.date('ym').'-0001' );
$date = date ('Y-m-d');
$heure = date ('H:i:s');
// R<>cup<75>ration du mode de r<>glement et cr<63>ation de la note priv<69>e ... }
$note = '';
switch ( $obj_facturation->mode_reglement() ) {
case 'ESP': $obj_facturation->mode_reglement ($_POST['hdnChoix']);
$mode_reglement = 4;
$note .= 'R<>glement en esp<73>ces'."\n"; // Si paiement autre qu'en esp<73>ces, montant encaiss<73> = prix total
$note .= 'Somme encaiss<73>e : '.$obj_facturation->montant_encaisse()." euro\n"; $mode_reglement = $obj_facturation->mode_reglement();
$note .= 'Somme rendue : '.$obj_facturation->montant_rendu()." euro\n"; if ( $mode_reglement != 'ESP' ) {
$note .= "\n";
$note .= '--------------------------------------'."\n\n";
break;
case 'CB': $montant = $obj_facturation->prix_total_ttc();
$mode_reglement = 6;
break;
case 'CHQ': } else {
$mode_reglement = 7;
break;
} $montant = $_POST['txtEncaisse'];
// ... on termine la note }
$note .= addslashes ($_POST['txtaNotes']);
// Si paiement diff<66>r<EFBFBD> ... if ( $mode_reglement != 'DIF') {
if ( $obj_facturation->mode_reglement() == 'DIF' ) {
// ... ajout d'une facture sans mode de r<>glement, avec la date d'<27>ch<63>ance $obj_facturation->montant_encaisse ($montant);
$sql->query (
"INSERT INTO ".MAIN_DB_PREFIX."facture ( //D<>termination de la somme rendue
$total = $obj_facturation->prix_total_ttc ();
$encaisse = $obj_facturation->montant_encaisse();
$obj_facturation->montant_rendu ( $encaisse - $total );
} else {
$obj_facturation->paiement_le ($_POST['txtDatePaiement']);
}
$redirection = 'affIndex.php?menu=validation';
break;
case 'retour':
$redirection = 'affIndex.php?menu=facturation';
break;
case 'valide_facture':
// R<>cup<75>ration de la date et de l'heure
$date = date ('Y-m-d');
$heure = date ('H:i:s');
// R<>cup<75>ration du mode de r<>glement et cr<63>ation de la note priv<69>e ...
$note = '';
switch ( $obj_facturation->mode_reglement() ) {
case 'ESP':
$mode_reglement = 4;
$note .= 'Reglement en especes'."\n";
$note .= 'Somme encaissee : '.$obj_facturation->montant_encaisse()." euro\n";
$note .= 'Somme rendue : '.$obj_facturation->montant_rendu()." euro\n";
$note .= "\n";
$note .= '--------------------------------------'."\n\n";
break;
case 'CB':
$mode_reglement = 6;
break;
case 'CHQ':
$mode_reglement = 7;
break;
}
// ... on termine la note
$note .= addslashes ($_POST['txtaNotes']);
// Si paiement differe ...
if ( $obj_facturation->mode_reglement() == 'DIF' ) {
// ... ajout d'une facture sans mode de r<>glement, avec la date d'<27>ch<63>ance
$sql->query (
"INSERT INTO ".MAIN_DB_PREFIX."facture (
facnumber, facnumber,
type, type,
ref_client, ref_client,
@@ -198,21 +207,28 @@
);"); );");
// R<EFBFBD>cup<EFBFBD>ration de l'id de la facture nouvellement cr<EFBFBD><EFBFBD>e // Recuperation de l'id de la facture nouvellement creee
$tab_id_facture = $sql->fetchFirst ( $sql->query ( $resql=$sql->query ("SELECT rowid
"SELECT rowid
FROM ".MAIN_DB_PREFIX."facture FROM ".MAIN_DB_PREFIX."facture
WHERE 1 WHERE 1
ORDER BY rowid DESC") ); ORDER BY rowid DESC");
$ret=array();
$tab = mysql_fetch_array($resql);
foreach ( $tab as $cle => $valeur )
{
$ret[$cle] = $valeur;
}
$tab_id_facture=$ret;
$id = $tab_id_facture['rowid']; $id = $tab_id_facture['rowid'];
// Sinon ... // Sinon ...
} else { } else {
// ... ajout d'une facture et d'un paiement // ... ajout d'une facture et d'un paiement
$sql->query ("INSERT INTO ".MAIN_DB_PREFIX."facture ( $sql->query ("INSERT INTO ".MAIN_DB_PREFIX."facture (
facnumber, facnumber,
type, type,
ref_client, ref_client,
@@ -274,22 +290,31 @@
;"); ;");
// R<EFBFBD>cup<EFBFBD>ration de l'id de la facture nouvellement cr<EFBFBD><EFBFBD>e // Recuperation de l'id de la facture nouvellement creee
$tab_id_facture = $sql->fetchFirst ( $sql->query ( $resql=$sql->query (
"SELECT rowid "SELECT rowid
FROM ".MAIN_DB_PREFIX."facture FROM ".MAIN_DB_PREFIX."facture
WHERE 1 WHERE 1
ORDER BY rowid DESC") ); ORDER BY rowid DESC");
$ret=array();
$tab = mysql_fetch_array($resql);
foreach ( $tab as $cle => $valeur )
{
$ret[$cle] = $valeur;
}
$id = $tab_id_facture['rowid']; $tab_id_facture = $tab;
$id = $tab_id_facture['rowid'];
// Ajout d'une op<6F>ration sur le compte de caisse, uniquement si le paiement est en esp<73>ces // Ajout d'une op<6F>ration sur le compte de caisse, uniquement si le paiement est en esp<73>ces
if ( $obj_facturation->mode_reglement() == 'ESP' ) { if ( $obj_facturation->mode_reglement() == 'ESP' ) {
$sql->query ( $sql->query (
"INSERT INTO ".MAIN_DB_PREFIX."bank ( "INSERT INTO ".MAIN_DB_PREFIX."bank (
datec, datec,
datev, datev,
dateo, dateo,
@@ -316,21 +341,30 @@
) )
;"); ;");
} }
// R<EFBFBD>cup<EFBFBD>ration de l'id de l'op<EFBFBD>ration nouvellement cr<EFBFBD><EFBFBD>e // Recuperation de l'id de l'operation nouvellement creee
$tab_id_operation = $sql->fetchFirst ( $sql->query ( $resql=$sql->query (
"SELECT rowid "SELECT rowid
FROM ".MAIN_DB_PREFIX."bank FROM ".MAIN_DB_PREFIX."bank
WHERE 1 WHERE 1
ORDER BY rowid DESC") ); ORDER BY rowid DESC");
$id_op = $tab_id_operation['rowid']; $ret=array();
$tab = mysql_fetch_array($resql);
foreach ( $tab as $cle => $valeur )
{
$ret[$cle] = $valeur;
}
$tab_id_operation = $tab;
$id_op = $tab_id_operation['rowid'];
// Ajout d'un nouveau paiement // Ajout d'un nouveau paiement
$sql->query ( $sql->query (
"INSERT INTO ".MAIN_DB_PREFIX."paiement ( "INSERT INTO ".MAIN_DB_PREFIX."paiement (
fk_facture, fk_facture,
datec, datec,
datep, datep,
@@ -361,18 +395,27 @@
)"); )");
// R<>cup<75>ration de l'id du paiement nouvellement cr<63><EFBFBD> // R<>cup<75>ration de l'id du paiement nouvellement cr<63>
$tab_id_paiement = $sql->fetchFirst ( $sql->query ( $resql=$sql->query (
"SELECT rowid "SELECT rowid
FROM ".MAIN_DB_PREFIX."paiement FROM ".MAIN_DB_PREFIX."paiement
WHERE 1 WHERE 1
ORDER BY rowid DESC") ); ORDER BY rowid DESC");
$ret=array();
$tab = mysql_fetch_array($resql);
foreach ( $tab as $cle => $valeur )
{
$ret[$cle] = $valeur;
}
$id_paiement = $tab_id_paiement['rowid']; $tab_id_paiement = $tab;
$id_paiement = $tab_id_paiement['rowid'];
$sql->query ( $sql->query (
"INSERT INTO ".MAIN_DB_PREFIX."paiement_facture ( "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (
fk_paiement, fk_paiement,
fk_facture, fk_facture,
amount amount
@@ -385,11 +428,11 @@
) )
;"); ;");
} }
// Ajout d'un r<>glement tva // Ajout d'un r<>glement tva
$sql->query ( $sql->query (
"INSERT INTO llx_facture_tva_sum ( "INSERT INTO llx_facture_tva_sum (
fk_facture, fk_facture,
amount, amount,
tva_tx tva_tx
@@ -403,48 +446,74 @@
;"); ;");
// R<EFBFBD>cup<EFBFBD>ration de la liste des articles du panier // Recuperation de la liste des articles du panier
$tab_liste = $sql->fetchAll ( $sql->query (' $res=$sql->query ('
SELECT fk_article, qte, fk_tva, remise_percent, remise, total_ht, total_ttc, reel SELECT fk_article, qte, fk_tva, remise_percent, remise, total_ht, total_ttc, reel
FROM '.MAIN_DB_PREFIX.'tmp_caisse FROM '.MAIN_DB_PREFIX.'tmp_caisse
LEFT JOIN '.MAIN_DB_PREFIX.'product_stock ON '.MAIN_DB_PREFIX.'tmp_caisse.fk_article = '.MAIN_DB_PREFIX.'product_stock.fk_product LEFT JOIN '.MAIN_DB_PREFIX.'product_stock ON '.MAIN_DB_PREFIX.'tmp_caisse.fk_article = '.MAIN_DB_PREFIX.'product_stock.fk_product
WHERE 1') ); WHERE 1');
$ret=array(); $i=0;
while ( $tab = mysql_fetch_array($res) )
{
foreach ( $tab as $cle => $valeur )
{
$ret[$i][$cle] = $valeur;
}
$i++;
}
for ($i = 0; $i < count ($tab_liste); $i++) { $tab_liste = $ret;
// R<>cup<75>ration de l'article for ($i = 0; $i < count ($tab_liste); $i++) {
$tab_article = $sql->fetchFirst ( $sql->query (
'SELECT label, tva_tx, price // Recuperation de l'article
$res = $sql->query (
'SELECT label, tva_tx, price
FROM '.MAIN_DB_PREFIX.'product FROM '.MAIN_DB_PREFIX.'product
WHERE rowid = '.$tab_liste[$i]['fk_article']) ); WHERE rowid = '.$tab_liste[$i]['fk_article']);
$ret=array();
$tab = mysql_fetch_array($res);
foreach ( $tab as $cle => $valeur )
{
$ret[$cle] = $valeur;
}
$tab_article = $ret;
$tab_tva = $sql->fetchFirst ( $sql->query ( $res = $sql->query (
'SELECT taux 'SELECT taux
FROM '.MAIN_DB_PREFIX.'c_tva FROM '.MAIN_DB_PREFIX.'c_tva
WHERE rowid = '.$tab_liste[$i]['fk_tva']) ); WHERE rowid = '.$tab_liste[$i]['fk_tva']);
$ret=array();
$tab = mysql_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'];
// Calcul du montant de la TVA // Calcul de la position de l'article dans la liste
$montant_tva = $tab_liste[$i]['total_ttc'] - $tab_liste[$i]['total_ht']; $position = $i + 1;
// Calcul de la position de l'article dans la liste
$position = $i + 1;
$reel = $tab_liste[$i]['reel']; $reel = $tab_liste[$i]['reel'];
$qte = $tab_liste[$i]['qte']; $qte = $tab_liste[$i]['qte'];
$stock = $reel - $qte; $stock = $reel - $qte;
// Mise <20> jour du stock // Mise <20> jour du stock
$sql->query ( $sql->query (
'UPDATE '.MAIN_DB_PREFIX.'product_stock 'UPDATE '.MAIN_DB_PREFIX.'product_stock
SET reel = '.$stock." SET reel = '.$stock."
WHERE fk_product = ".$tab_liste[$i]['fk_article']." WHERE fk_product = ".$tab_liste[$i]['fk_article']."
LIMIT 1"); LIMIT 1");
// Ajout d'une entr<74>e dans le d<>tail de la facture // Ajout d'une entr<74>e dans le d<>tail de la facture
$sql->query ( $sql->query (
'INSERT INTO '.MAIN_DB_PREFIX.'facturedet ( 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet (
fk_facture, fk_facture,
fk_product, fk_product,
description, description,
@@ -487,14 +556,14 @@
0, 0,
".$position.")"); ".$position.")");
} }
$redirection = 'affIndex.php?menu=validation_ok&facid='.$id; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr $redirection = 'affIndex.php?menu=validation_ok&facid='.$id; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr
break; break;
} }
$_SESSION['serObjFacturation'] = serialize ($obj_facturation); $_SESSION['serObjFacturation'] = serialize ($obj_facturation);
header ('Location: '.$redirection); header ('Location: '.$redirection);
?> ?>

View File

@@ -397,11 +397,10 @@ class DoliDb
/** /**
\brief Renvoie les donn<EFBFBD>es dans un tableau. * \brief Renvoie les donnees dans un tableau.
\param resultset Curseur de la requete voulue * \param resultset Curseur de la requete voulue
\return array * \return array
*/ */
function fetch_array($resultset=0) function fetch_array($resultset=0)
{ {
// Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion
@@ -410,11 +409,10 @@ class DoliDb
} }
/** /**
\brief Renvoie les donn<EFBFBD>es comme un tableau. * \brief Renvoie les donnees comme un tableau.
\param resultset Curseur de la requete voulue * \param resultset Curseur de la requete voulue
\return array * \return array
*/ */
function fetch_row($resultset=0) function fetch_row($resultset=0)
{ {
// Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion