Fix: Can use POS module with several concurrent users. This also remove

temporary table.
This commit is contained in:
Laurent Destailleur 2011-10-13 20:14:29 +02:00
parent f5a593a291
commit f671df6634
7 changed files with 636 additions and 718 deletions

View File

@ -28,14 +28,14 @@ require_once('class/Facturation.class.php');
if ( $_GET['id'] == 'NOUV' ) if ( $_GET['id'] == 'NOUV' )
{ {
unset($_SESSION['serObjFacturation']); unset($_SESSION['serObjFacturation']);
$db->query('DELETE FROM '.MAIN_DB_PREFIX.'pos_tmp'); unset($_SESSION['poscart']);
} }
// Recuperation, 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']);
unset ($_SESSION['serObjFacturation']); unset($_SESSION['serObjFacturation']);
} }
else else
{ {

View File

@ -81,12 +81,19 @@ class Facturation {
// Methodes de traitement des donnees // Methodes de traitement des donnees
/** /**
* Ajout d'un article au panier * Add a product into cart
*
* @return void
*/ */
public function ajoutArticle() public function ajoutArticle()
{ {
global $db; global $conf,$db;
$thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY'];
$societe = new Societe($db);
$societe->fetch($thirdpartyid);
$sql = "SELECT taux"; $sql = "SELECT taux";
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva";
@ -125,82 +132,84 @@ class Facturation {
$montant_remise_ht = ($resultarray[6] - $resultarray[0]); $montant_remise_ht = ($resultarray[6] - $resultarray[0]);
$this->montant_remise($montant_remise_ht); $this->montant_remise($montant_remise_ht);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."pos_tmp ("; $product = new Product($db);
$sql.= "fk_article"; $product->fetch($this->id);
$sql.= ", qte";
$sql.= ", fk_tva";
$sql.= ", remise_percent";
$sql.= ", remise";
$sql.= ", total_ht";
$sql.= ", total_ttc";
$sql.= ") VALUES (";
$sql.= $this->id();
$sql.= ", ".$this->qte();
$sql.= ", ".$this->tva();
$sql.= ", ".$remise_percent;
$sql.= ", ".price2num($montant_remise_ht);
$sql.= ", ".price2num($total_ht,'MT');
$sql.= ", ".price2num($total_ttc,'MT');
$sql.= ")";
dol_syslog("ajoutArticle sql=".$sql); $newcartarray=$_SESSION['poscart'];
$result = $db->query($sql); $i=count($newcartarray);
if (!$result) $newcartarray[$i]['id']=$i;
$newcartarray[$i]['ref']=$product->ref;
$newcartarray[$i]['label']=$product->label;
$newcartarray[$i]['price']=$product->price;
$newcartarray[$i]['price_ttc']=$product->price_ttc;
/** add Ditto for MultiPrix*/
if ($conf->global->PRODUIT_MULTIPRICES)
{ {
dol_print_error($db); if(isset($product->multiprices[$societe->price_level]))
{
$newcartarray[$i]['price'] = $product->multiprices_ttc[$societe->price_level];
} }
}
/** end add Ditto */
$newcartarray[$i]['fk_article']=$this->id;
$newcartarray[$i]['qte']=$this->qte();
$newcartarray[$i]['fk_tva']=$this->tva();
$newcartarray[$i]['remise_percent']=$remise_percent;
$newcartarray[$i]['remise']=price2num($montant_remise_ht);
$newcartarray[$i]['total_ht']=price2num($total_ht,'MT');
$newcartarray[$i]['total_ttc']=price2num($total_ttc,'MT');
$_SESSION['poscart']=$newcartarray;
$this->raz(); $this->raz();
} }
/** /**
* Suppression du panier d'un article identifie par son id dans la table llx_pos_tmp * Remove a product from panel
* @param aArticle *
* @param aArticle Id of line into cart to remove
*/ */
public function supprArticle($aArticle) public function supprArticle($aArticle)
{ {
global $db; $poscart=$_SESSION['poscart'];
$sql = "DELETE FROM ".MAIN_DB_PREFIX."pos_tmp";
$sql.= " WHERE id = ".$aArticle;
$sql.= " LIMIT 1";
$db->query($sql);
$j=0;
$newposcart=array();
foreach($poscart as $key => $val)
{
if ($poscart[$key]['id'] != $aArticle)
{
$newposcart[$j]=$poscart[$key];
$newposcart[$j]['id']=$j;
$j++;
}
}
unset($poscart);
//var_dump($poscart);exit;
$_SESSION['poscart']=$newposcart;
} }
/** /**
* \brief Calcul du total HT, total TTC et montants TVA * Calcul du total HT, total TTC et montants TVA
*
* @return int Total
*/ */
public function calculTotaux() public function calculTotaux()
{ {
global $db; global $db;
$res = $db->query('SELECT remise, total_ht, total_ttc, taux FROM '.MAIN_DB_PREFIX.'pos_tmp as c
LEFT JOIN '.MAIN_DB_PREFIX.'c_tva as t ON c.fk_tva = t.rowid
ORDER BY id');
$total_ht=0; $total_ht=0;
$total_ttc=0; $total_ttc=0;
if ( $db->num_rows($res) ) { $tab=array();
$tab = $_SESSION['poscart'];
$ret=array(); $i=0;
while ( $tab = $db->fetch_array($res) )
{
foreach ( $tab as $cle => $valeur )
{
$ret[$i][$cle] = $valeur;
}
$i++;
}
$tab=$ret;
$tab_size=count($tab); $tab_size=count($tab);
for($i=0;$i < $tab_size;$i++) { for($i=0;$i < $tab_size;$i++)
{
// Total HT // Total HT
$remise = $tab[$i]['remise']; $remise = $tab[$i]['remise'];
$total_ht += ($tab[$i]['total_ht']); $total_ht += ($tab[$i]['total_ht']);
@ -214,12 +223,12 @@ class Facturation {
//print $this->prix_total_ttc.'eeee'; exit; //print $this->prix_total_ttc.'eeee'; exit;
} }
}
/** /**
* Reinitialisation des attributs * Reinitialisation des attributs
*
* @return void
*/ */
public function raz () public function raz()
{ {
$this->id('RESET'); $this->id('RESET');
$this->ref('RESET'); $this->ref('RESET');
@ -229,13 +238,12 @@ class Facturation {
$this->montant_remise('RESET'); $this->montant_remise('RESET');
$this->prix('RESET'); $this->prix('RESET');
$this->tva('RESET'); $this->tva('RESET');
} }
/** /**
* Reinitialisation des attributs persistants * Reinitialisation 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');
@ -257,18 +265,21 @@ class Facturation {
* @param aId * @param aId
* @return id * @return id
*/ */
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;
@ -280,20 +291,20 @@ class Facturation {
* Getter for ref * Getter for ref
* @param $aRef * @param $aRef
*/ */
public function ref ( $aRef=null ) { public function ref($aRef=null)
{
if ( !$aRef ) {
if ( !$aRef )
{
return $this->ref; return $this->ref;
}
} else if ( $aRef == 'RESET' ) { else if ( $aRef == 'RESET' )
{
$this->ref = NULL; $this->ref = NULL;
}
} else { else
{
$this->ref = $aRef; $this->ref = $aRef;
} }
} }
@ -303,78 +314,80 @@ class Facturation {
* @param $aQte * @param $aQte
* @return * @return
*/ */
public function qte ( $aQte=null ) { public function qte ( $aQte=null )
{
if ( !$aQte ) { if ( !$aQte )
{
return $this->qte; return $this->qte;
}
} else if ( $aQte == 'RESET' ) { else if ( $aQte == 'RESET' )
{
$this->qte = NULL; $this->qte = NULL;
}
} else { else
{
$this->qte = $aQte; $this->qte = $aQte;
} }
} }
/** /**
* Getter for stock * Getter for stock
*
* @param aStock * @param aStock
* @return * @return
*/ */
public function stock ( $aStock=null ) public function stock($aStock=null)
{ {
if ( !$aStock ) { if ( !$aStock )
{
return $this->stock; return $this->stock;
}
} else if ( $aStock == 'RESET' ) { else if ( $aStock == 'RESET' )
{
$this->stock = NULL; $this->stock = NULL;
}
} else { else
{
$this->stock = $aStock; $this->stock = $aStock;
} }
} }
/** /**
* Getter for remise_percent * Getter for remise_percent
*
* @param aRemisePercent * @param aRemisePercent
* @return * @return
*/ */
public function remise_percent ( $aRemisePercent=null ) public function remise_percent($aRemisePercent=null)
{ {
if ( !$aRemisePercent ) { if ( !$aRemisePercent )
{
return $this->remise_percent; return $this->remise_percent;
}
} else if ( $aRemisePercent == 'RESET' ) { else if ($aRemisePercent == 'RESET')
{
$this->remise_percent = NULL; $this->remise_percent = NULL;
}
} else { else
{
$this->remise_percent = $aRemisePercent; $this->remise_percent = $aRemisePercent;
} }
} }
/** /**
* Getter for montant_remise * Getter for montant_remise
*
* @param aMontantRemise * @param aMontantRemise
* @return * @return
*/ */
public function montant_remise ( $aMontantRemise=null ) { public function montant_remise($aMontantRemise=null)
{
if ( !$aMontantRemise ) { if ( !$aMontantRemise ) {
@ -394,6 +407,7 @@ class Facturation {
/** /**
* Getter for prix * Getter for prix
*
* @param aPrix * @param aPrix
* @return * @return
*/ */
@ -418,6 +432,7 @@ class Facturation {
/** /**
* Getter for tva * Getter for tva
*
* @param aTva * @param aTva
* @return * @return
*/ */
@ -440,6 +455,10 @@ class Facturation {
} }
/**
*
* @param $aNumFacture
*/
public function num_facture ( $aNumFacture=null ) public function num_facture ( $aNumFacture=null )
{ {
@ -456,9 +475,12 @@ class Facturation {
$this->num_facture = $aNumFacture; $this->num_facture = $aNumFacture;
} }
} }
/**
*
* @param unknown_type $aModeReglement
*/
public function mode_reglement ( $aModeReglement=null ) public function mode_reglement ( $aModeReglement=null )
{ {
@ -478,6 +500,10 @@ class Facturation {
} }
/**
*
* @param $aMontantEncaisse
*/
public function montant_encaisse ( $aMontantEncaisse=null ) public function montant_encaisse ( $aMontantEncaisse=null )
{ {
@ -497,6 +523,10 @@ class Facturation {
} }
/**
*
* @param $aMontantRendu
*/
public function montant_rendu ( $aMontantRendu=null ) public function montant_rendu ( $aMontantRendu=null )
{ {
@ -515,6 +545,10 @@ class Facturation {
} }
/**
*
* @param $aPaiementLe
*/
public function paiement_le ( $aPaiementLe=null ) public function paiement_le ( $aPaiementLe=null )
{ {
@ -534,6 +568,10 @@ class Facturation {
} }
/**
*
* @param $aTotalHt
*/
public function prix_total_ht ( $aTotalHt=null ) public function prix_total_ht ( $aTotalHt=null )
{ {
@ -553,6 +591,10 @@ class Facturation {
} }
/**
*
* @param $aMontantTva
*/
public function montant_tva ( $aMontantTva=null ) public function montant_tva ( $aMontantTva=null )
{ {
@ -572,23 +614,25 @@ class Facturation {
} }
/**
*
* @param $aTotalTtc
*/
public function prix_total_ttc ( $aTotalTtc=null ) public function prix_total_ttc ( $aTotalTtc=null )
{ {
if ( !$aTotalTtc ) { if ( !$aTotalTtc )
{
return $this->prix_total_ttc; return $this->prix_total_ttc;
} else if ( $aTotalTtc == 'RESET' ) {
$this->prix_total_ttc = NULL;
} else {
$this->prix_total_ttc = $aTotalTtc;
} }
else if ( $aTotalTtc == 'RESET' )
{
$this->prix_total_ttc = NULL;
}
else
{
$this->prix_total_ttc = $aTotalTtc;
}
} }
} }

View File

@ -31,57 +31,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<p class="titre"><?php echo $langs->trans("ShoppingCart"); ?></p> <p class="titre"><?php echo $langs->trans("ShoppingCart"); ?></p>
<?php <?php
// Recuperation du contenu de la vente /** add Ditto for MultiPrix*/
$request='SELECT id, ref, label, qte, price, remise_percent, remise, total_ht, total_ttc FROM '.MAIN_DB_PREFIX.'pos_tmp as c $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY'];
LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON c.fk_article = p.rowid $societe = new Societe($db);
ORDER BY id'; $societe->fetch($thirdpartyid);
dol_syslog($request); /** end add Ditto */
$res = $db->query($request);
if (! $res) $tab=array();
$tab = $_SESSION['poscart'];
$tab_size=count($tab);
if ($tab_size <= 0) print '<center>'.$langs->trans("NoArticle").'<center><br>';
else
{
for ($i=0;$i < $tab_size;$i++)
{ {
dol_print_error($db);
exit;
}
if ( $db->num_rows($res) )
{
$ret=array(); $i=0;
/** add Ditto for MultiPrix*/
$thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY'];
$societe = new Societe($db);
$societe->fetch($thirdpartyid);
/** end add Ditto */
while ( $tab = $db->fetch_array($res) )
{
foreach ( $tab as $cle => $valeur )
{
$ret[$i][$cle] = $valeur;
}
/** add Ditto for MultiPrix*/
if($conf->global->PRODUIT_MULTIPRICES)
{
$product = new Product($db);
$product->fetch($ret[$i]['id']);
if(isset($product->multiprices[$societe->price_level]))
{
$ret[$i]['price'] = $product->multiprices_ttc[$societe->price_level];
}
}
/** end add Ditto */
$i++;
}
$tab = $ret;
$tab_size=count($tab);
for($i=0;$i < $tab_size;$i++) {
echo ('<div class="cadre_article">'."\n"); echo ('<div class="cadre_article">'."\n");
echo ('<p><a href="facturation_verif.php?action=suppr_article&suppr_id='.$tab[$i]['id'].'" title="'.$langs->trans("DeleteArticle").'">'.$tab[$i]['ref'].' - '.$tab[$i]['label'].'</a></p>'."\n"); echo ('<p><a href="facturation_verif.php?action=suppr_article&suppr_id='.$tab[$i]['id'].'" title="'.$langs->trans("DeleteArticle").'">'.$tab[$i]['ref'].' - '.$tab[$i]['label'].'</a></p>'."\n");
@ -99,19 +63,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
echo ('<p>'.$tab[$i]['qte'].' x '.price2num($tab[$i]['price'], 'MT').$remise_percent.' = '.price2num($tab[$i]['total_ht'], 'MT').' '.$conf->monnaie.' '.$langs->trans("HT").' ('.price2num($tab[$i]['total_ttc'], 'MT').' '.$conf->monnaie.' '.$langs->trans("TTC").')</p>'."\n"); echo ('<p>'.$tab[$i]['qte'].' x '.price2num($tab[$i]['price'], 'MT').$remise_percent.' = '.price2num($tab[$i]['total_ht'], 'MT').' '.$conf->monnaie.' '.$langs->trans("HT").' ('.price2num($tab[$i]['total_ttc'], 'MT').' '.$conf->monnaie.' '.$langs->trans("TTC").')</p>'."\n");
echo ('</div>'."\n"); echo ('</div>'."\n");
} }
}
$obj_facturation->calculTotaux(); $obj_facturation->calculTotaux();
$total_ttc = $obj_facturation->prix_total_ttc(); $total_ttc = $obj_facturation->prix_total_ttc();
echo ('<p class="cadre_prix_total">'.$langs->trans("Total").' : '.price2num($total_ttc, 'MT').' '.$conf->monnaie.'<br></p>'."\n"); echo ('<p class="cadre_prix_total">'.$langs->trans("Total").' : '.price2num($total_ttc, 'MT').' '.$conf->monnaie.'<br></p>'."\n");
} else { ?></div>
echo ('<p class="cadre_aucun_article">'.$langs->trans("NoArticle").'</p>'."\n");
}
?>
</div>
</div> </div>

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net> /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2011 Laurent Destailleur <eldy@users.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
@ -29,69 +30,63 @@ $object->fetch($facid);
<title>Print ticket</title> <title>Print ticket</title>
<style type="text/css"> <style type="text/css">
body {
body {
font-size: 1.5em; font-size: 1.5em;
position: relative; position: relative;
} }
.entete { .entete { /* position: relative; */
/* position: relative; */
}
.address { }
/* float: left; */
.address { /* float: left; */
font-size: 12px; font-size: 12px;
} }
.date_heure { .date_heure {
position: absolute; position: absolute;
top: 0; top: 0;
right: 0; right: 0;
font-size: 16px; font-size: 16px;
} }
.infos { .infos {
position: relative; position: relative;
} }
.liste_articles {
.liste_articles {
width: 100%; width: 100%;
border-bottom: 1px solid #000; border-bottom: 1px solid #000;
text-align: center; text-align: center;
} }
.liste_articles tr.titres th { .liste_articles tr.titres th {
border-bottom: 1px solid #000; border-bottom: 1px solid #000;
} }
.liste_articles td.total { .liste_articles td.total {
text-align: right; text-align: right;
} }
.totaux { .totaux {
margin-top: 20px; margin-top: 20px;
width: 30%; width: 30%;
float: right; float: right;
text-align: right; text-align: right;
} }
.lien { .lien {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
display: none; display: none;
} }
@media print {
@media print {
.lien { .lien {
display: none; display: none;
} }
}
}
</style> </style>
</head> </head>
@ -99,50 +94,37 @@ $object->fetch($facid);
<body> <body>
<div class="entete"> <div class="entete">
<div class="logo"> <div class="logo"><?php print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&amp;file='.urlencode('/thumbs/'.$mysoc->logo_small).'">'; ?>
<?php print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&amp;file='.urlencode('/thumbs/'.$mysoc->logo_small).'">'; ?> </div>
</div> <div class="infos">
<div class="infos"> <p class="address"><?php echo $mysoc->name; ?><br>
<p class="address"><?php echo $mysoc->name; ?><br> <?php print dol_nl2br(dol_format_address($langs,$mysoc)); ?><br>
<?php print dol_nl2br(dol_format_address($langs,$mysoc)); ?><br> </p>
</p>
<p class="date_heure"> <p class="date_heure"><?php
<?php // Recuperation et affichage de la date et de l'heure
// Recuperation et affichage de la date et de l'heure $now = dol_now();
$now = dol_now(); print dol_print_date($now,'dayhourtext').'<br>';
print dol_print_date($now,'dayhourtext').'<br>'; print $object->ref;
print $object->ref; ?></p>
?> </div>
</p>
</div>
</div> </div>
<br> <br>
<table class="liste_articles"> <table class="liste_articles">
<tr class="titres"><th><?php print $langs->trans("Code"); ?></th><th><?php print $langs->trans("Label"); ?></th><th><?php print $langs->trans("Qty"); ?></th><th><?php print $langs->trans("Discount").' (%)'; ?></th><th><?php print $langs->trans("TotalHT"); ?></th></tr> <tr class="titres">
<th><?php print $langs->trans("Code"); ?></th>
<th><?php print $langs->trans("Label"); ?></th>
<th><?php print $langs->trans("Qty"); ?></th>
<th><?php print $langs->trans("Discount").' (%)'; ?></th>
<th><?php print $langs->trans("TotalHT"); ?></th>
</tr>
<?php <?php
// Variables $tab=array();
$res = $db->query( $tab = $_SESSION['poscart'];
'SELECT id, ref, label, qte, price, remise_percent, remise, total_ht, total_ttc, tva_tx FROM '.MAIN_DB_PREFIX.'pos_tmp as c
LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON c.fk_article = p.rowid
ORDER BY id');
if ($db->num_rows($res))
{
$ret=array(); $i=0;
while ($tab = $db->fetch_array($res))
{
foreach ($tab as $cle => $valeur)
{
$ret[$i][$cle] = $valeur;
}
$i++;
}
$tab = $ret;
$tab_size=count($tab); $tab_size=count($tab);
for($i=0;$i < $tab_size;$i++) for($i=0;$i < $tab_size;$i++)
@ -151,27 +133,22 @@ $object->fetch($facid);
echo ('<tr><td>'.$tab[$i]['ref'].'</td><td>'.$tab[$i]['label'].'</td><td>'.$tab[$i]['qte'].'</td><td>'.$tab[$i]['remise_percent'].'</td><td class="total">'.price2num($tab[$i]['total_ht'],'MT').' '.$conf->monnaie.'</td></tr>'."\n"); echo ('<tr><td>'.$tab[$i]['ref'].'</td><td>'.$tab[$i]['label'].'</td><td>'.$tab[$i]['qte'].'</td><td>'.$tab[$i]['remise_percent'].'</td><td class="total">'.price2num($tab[$i]['total_ht'],'MT').' '.$conf->monnaie.'</td></tr>'."\n");
} }
}
else
{
echo ('<p>Erreur : aucun article</p>'."\n");
}
?> ?>
</table> </table>
<table class="totaux"> <table class="totaux">
<?php <?php
echo '<tr><th nowrap="nowrap">'.$langs->trans("TotalHT").'</th><td nowrap="nowrap">'.price2num($obj_facturation->prix_total_ht(),'MT')." ".$conf->monnaie."</td></tr>\n"; echo '<tr><th nowrap="nowrap">'.$langs->trans("TotalHT").'</th><td nowrap="nowrap">'.price2num($obj_facturation->prix_total_ht(),'MT')." ".$conf->monnaie."</td></tr>\n";
echo '<tr><th nowrap="nowrap">'.$langs->trans("TotalVAT").'</th><td nowrap="nowrap">'.price2num($obj_facturation->montant_tva(),'MT')." ".$conf->monnaie."</td></tr>\n"; echo '<tr><th nowrap="nowrap">'.$langs->trans("TotalVAT").'</th><td nowrap="nowrap">'.price2num($obj_facturation->montant_tva(),'MT')." ".$conf->monnaie."</td></tr>\n";
echo '<tr><th nowrap="nowrap">'.$langs->trans("TotalTTC").'</th><td nowrap="nowrap">'.price2num($obj_facturation->prix_total_ttc(),'MT')." ".$conf->monnaie."</td></tr>\n"; echo '<tr><th nowrap="nowrap">'.$langs->trans("TotalTTC").'</th><td nowrap="nowrap">'.price2num($obj_facturation->prix_total_ttc(),'MT')." ".$conf->monnaie."</td></tr>\n";
?> ?>
</table> </table>
<script type="text/javascript"> <script type="text/javascript">
window.print(); window.print();
</script> </script>
<a class="lien" href="#" onclick="javascript: window.close(); return(false);"><?php echo $langs->trans("Close"); ?></a> <a class="lien" href="#"
onclick="javascript: window.close(); return(false);"><?php echo $langs->trans("Close"); ?></a>
</body> </body>

View File

@ -144,29 +144,15 @@ switch ($action)
$invoice=new Facture($db); $invoice=new Facture($db);
// Recuperation de la liste des articles du panier // Get content of cart
$res=$db->query('SELECT fk_article, qte, fk_tva, remise_percent, remise, total_ht, total_ttc $tab_liste = $_SESSION['poscart'];
FROM '.MAIN_DB_PREFIX.'pos_tmp
WHERE 1');
$ret=array(); $i=0;
while ($tab = $db->fetch_array($res))
{
foreach ($tab as $cle => $valeur)
{
$ret[$i][$cle] = $valeur;
}
$i++;
}
$tab_liste = $ret;
// Loop on each product // Loop on each product
$tab_liste_size=count($tab_liste); $tab_liste_size=count($tab_liste);
for($i=0;$i < $tab_liste_size;$i++) for ($i=0;$i < $tab_liste_size;$i++)
{ {
// Recuperation de l'article // Recuperation de l'article
$res = $db->query( $res = $db->query('SELECT label, tva_tx, price FROM '.MAIN_DB_PREFIX.'product WHERE rowid = '.$tab_liste[$i]['fk_article']);
'SELECT label, tva_tx, price
FROM '.MAIN_DB_PREFIX.'product
WHERE rowid = '.$tab_liste[$i]['fk_article']);
$ret=array(); $ret=array();
$tab = $db->fetch_array($res); $tab = $db->fetch_array($res);
foreach ( $tab as $cle => $valeur ) foreach ( $tab as $cle => $valeur )
@ -175,10 +161,7 @@ switch ($action)
} }
$tab_article = $ret; $tab_article = $ret;
$res = $db->query( $res = $db->query('SELECT taux FROM '.MAIN_DB_PREFIX.'c_tva WHERE rowid = '.$tab_liste[$i]['fk_tva']);
'SELECT taux
FROM '.MAIN_DB_PREFIX.'c_tva
WHERE rowid = '.$tab_liste[$i]['fk_tva']);
$ret=array(); $ret=array();
$tab = $db->fetch_array($res); $tab = $db->fetch_array($res);
foreach ( $tab as $cle => $valeur ) foreach ( $tab as $cle => $valeur )
@ -250,20 +233,6 @@ switch ($action)
$paiement_id = $payment->create($user); $paiement_id = $payment->create($user);
if ($paiement_id > 0) if ($paiement_id > 0)
{ {
/*if ( $obj_facturation->mode_reglement() == 'ESP' )
{
$bankaccountid=$conf_fkaccount_cash;
}
if ( $obj_facturation->mode_reglement() == 'CHQ' )
{
$bankaccountid=$conf_fkaccount_cheque;
}
if ( $obj_facturation->mode_reglement() == 'CB' )
{
$bankaccountid=$conf_fkaccount_cb;
}*/
if (! $error) if (! $error)
{ {
$result=$payment->addPaymentToBank($user,'payment','(CustomerInvoicePayment)',$bankaccountid,'',''); $result=$payment->addPaymentToBank($user,'payment','(CustomerInvoicePayment)',$bankaccountid,'','');

View File

@ -1,29 +0,0 @@
-- ===========================================================================
-- Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- ===========================================================================
CREATE TABLE llx_pos_tmp (
id integer AUTO_INCREMENT PRIMARY KEY,
fk_article integer NOT NULL,
qte real NOT NULL,
fk_tva integer NOT NULL,
remise_percent real NOT NULL,
remise real NOT NULL,
total_ht double(24,8) NOT NULL,
total_tva double(24,8) NOT NULL,
total_ttc double(24,8) NOT NULL
) ENGINE=innodb;

View File

@ -8,8 +8,8 @@
// in [-]HH:MM format... // in [-]HH:MM format...
// won't yet work with non-even tzs // won't yet work with non-even tzs
function fetchTimezone() { function fetchTimezone()
// FIXME: work around Safari bug {
var localclock = new Date(); var localclock = new Date();
// returns negative offset from GMT in minutes // returns negative offset from GMT in minutes
var tzRaw = localclock.getTimezoneOffset(); var tzRaw = localclock.getTimezoneOffset();