diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php index 00535921c2b..86e20267274 100644 --- a/htdocs/cashdesk/affContenu.php +++ b/htdocs/cashdesk/affContenu.php @@ -28,14 +28,14 @@ require_once('class/Facturation.class.php'); if ( $_GET['id'] == 'NOUV' ) { 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 ... -if ( isset ($_SESSION['serObjFacturation']) ) +if (isset($_SESSION['serObjFacturation'])) { $obj_facturation = unserialize($_SESSION['serObjFacturation']); - unset ($_SESSION['serObjFacturation']); + unset($_SESSION['serObjFacturation']); } else { diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index 248198d26af..87a46c7eee2 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -25,571 +25,615 @@ include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php'); */ class Facturation { - /** - * Attributs "volatiles" : reinitialises apres chaque traitement d'un article - *
Attributs "volatiles" : reinitialises apres chaque traitement d'un article
- * int $id => 'rowid' du produit dans llx_product - * string $ref => 'ref' du produit dans llx_product - * int $qte => Quantite pour le produit en cours de traitement - * int $stock => Stock theorique pour le produit en cours de traitement - * int $remise_percent => Remise en pourcent sur le produit en cours - * int $montant_remise => Remise en pourcent sur le produit en cours - * int $prix => Prix HT du produit en cours - * int $tva => 'rowid' du taux de tva dans llx_c_tva - */ - var $id; - protected $ref; - protected $qte; - protected $stock; - protected $remise_percent; - protected $montant_remise; - protected $prix; - protected $tva; - - /** - * Attributs persistants : utilises pour toute la duree de la vente (jusqu'a validation ou annulation) - * string $num_facture => Numero de la facture (de la forme FAYYMM-XXXX) - * string $mode_reglement => Mode de reglement (ESP, CB ou CHQ) - * int $montant_encaisse => Montant encaisse en cas de reglement en especes - * int $montant_rendu => Monnaie rendue en cas de reglement en especes - * int $paiement_le => Date de paiement en cas de paiement differe - * - * int $prix_total_ht => Prix total hors taxes - * int $montant_tva => Montant total de la TVA, tous taux confondus - * int $prix_total_ttc => Prix total TTC - */ - protected $num_facture; - protected $mode_reglement; - protected $montant_encaisse; - protected $montant_rendu; - protected $paiement_le; - - protected $prix_total_ht; - protected $montant_tva; - protected $prix_total_ttc; - - - /** - * Constructor - */ - public function Facturation() - { - $this->raz(); - $this->raz_pers(); - } - - - // Methodes de traitement des donnees - - /** - * Ajout d'un article au panier - */ - public function ajoutArticle() - { - global $db; - - $sql = "SELECT taux"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_tva"; - $sql.= " WHERE rowid = ".$this->tva(); - - dol_syslog("ajoutArticle sql=".$sql); - $resql = $db->query($sql); - - if ($resql) - { - $obj = $db->fetch_object($resql); - $vat_rate=$obj->taux; - //var_dump($vat_rate);exit; - } - else - { - dol_print_error($db); - } - - - // Define part of HT, VAT, TTC - $resultarray=calcul_price_total($this->qte,$this->prix(),$this->remise_percent(),$vat_rate,0,0,0,'HT',0); - - // Calcul du total ht sans remise - $total_ht = $resultarray[0]; - $total_vat = $resultarray[1]; - $total_ttc = $resultarray[2]; - - // Calcul du montant de la remise - if ($this->remise_percent()) - { - $remise_percent = $this->remise_percent(); - } else { - $remise_percent = 0; - } - $montant_remise_ht = ($resultarray[6] - $resultarray[0]); - $this->montant_remise($montant_remise_ht); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."pos_tmp ("; - $sql.= "fk_article"; - $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); - $result = $db->query($sql); - - if (!$result) - { - dol_print_error($db); - } - - $this->raz(); - - } - - /** - * Suppression du panier d'un article identifie par son id dans la table llx_pos_tmp - * @param aArticle - */ - public function supprArticle($aArticle) - { - global $db; - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."pos_tmp"; - $sql.= " WHERE id = ".$aArticle; - $sql.= " LIMIT 1"; - - $db->query($sql); - - } - - /** - * \brief Calcul du total HT, total TTC et montants TVA - */ - public function calculTotaux() - { - 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_ttc=0; - - 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); - for($i=0;$i < $tab_size;$i++) { - - // Total HT - $remise = $tab[$i]['remise']; - $total_ht += ($tab[$i]['total_ht']); - $total_ttc += ($tab[$i]['total_ttc']); - } + /** + * Attributs "volatiles" : reinitialises apres chaque traitement d'un article + *Attributs "volatiles" : reinitialises apres chaque traitement d'un article
+ * int $id => 'rowid' du produit dans llx_product + * string $ref => 'ref' du produit dans llx_product + * int $qte => Quantite pour le produit en cours de traitement + * int $stock => Stock theorique pour le produit en cours de traitement + * int $remise_percent => Remise en pourcent sur le produit en cours + * int $montant_remise => Remise en pourcent sur le produit en cours + * int $prix => Prix HT du produit en cours + * int $tva => 'rowid' du taux de tva dans llx_c_tva + */ + var $id; + protected $ref; + protected $qte; + protected $stock; + protected $remise_percent; + protected $montant_remise; + protected $prix; + protected $tva; + + /** + * Attributs persistants : utilises pour toute la duree de la vente (jusqu'a validation ou annulation) + * string $num_facture => Numero de la facture (de la forme FAYYMM-XXXX) + * string $mode_reglement => Mode de reglement (ESP, CB ou CHQ) + * int $montant_encaisse => Montant encaisse en cas de reglement en especes + * int $montant_rendu => Monnaie rendue en cas de reglement en especes + * int $paiement_le => Date de paiement en cas de paiement differe + * + * int $prix_total_ht => Prix total hors taxes + * int $montant_tva => Montant total de la TVA, tous taux confondus + * int $prix_total_ttc => Prix total TTC + */ + protected $num_facture; + protected $mode_reglement; + protected $montant_encaisse; + protected $montant_rendu; + protected $paiement_le; + + protected $prix_total_ht; + protected $montant_tva; + protected $prix_total_ttc; + + + /** + * Constructor + */ + public function Facturation() + { + $this->raz(); + $this->raz_pers(); + } + + + // Methodes de traitement des donnees + + + /** + * Add a product into cart + * + * @return void + */ + public function ajoutArticle() + { + global $conf,$db; + + $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; + $societe = new Societe($db); + $societe->fetch($thirdpartyid); + + $sql = "SELECT taux"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_tva"; + $sql.= " WHERE rowid = ".$this->tva(); + + dol_syslog("ajoutArticle sql=".$sql); + $resql = $db->query($sql); + + if ($resql) + { + $obj = $db->fetch_object($resql); + $vat_rate=$obj->taux; + //var_dump($vat_rate);exit; + } + else + { + dol_print_error($db); + } + + + // Define part of HT, VAT, TTC + $resultarray=calcul_price_total($this->qte,$this->prix(),$this->remise_percent(),$vat_rate,0,0,0,'HT',0); + + // Calcul du total ht sans remise + $total_ht = $resultarray[0]; + $total_vat = $resultarray[1]; + $total_ttc = $resultarray[2]; + + // Calcul du montant de la remise + if ($this->remise_percent()) + { + $remise_percent = $this->remise_percent(); + } else { + $remise_percent = 0; + } + $montant_remise_ht = ($resultarray[6] - $resultarray[0]); + $this->montant_remise($montant_remise_ht); + + $product = new Product($db); + $product->fetch($this->id); + + $newcartarray=$_SESSION['poscart']; + $i=count($newcartarray); + + $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) + { + 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(); + + } + + /** + * Remove a product from panel + * + * @param aArticle Id of line into cart to remove + */ + public function supprArticle($aArticle) + { + $poscart=$_SESSION['poscart']; + + $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; + } + + /** + * Calcul du total HT, total TTC et montants TVA + * + * @return int Total + */ + public function calculTotaux() + { + global $db; + + $total_ht=0; + $total_ttc=0; + + $tab=array(); + $tab = $_SESSION['poscart']; + + $tab_size=count($tab); + for($i=0;$i < $tab_size;$i++) + { + // Total HT + $remise = $tab[$i]['remise']; + $total_ht += ($tab[$i]['total_ht']); + $total_ttc += ($tab[$i]['total_ttc']); + } + + $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; + } + + /** + * Reinitialisation des attributs + * + * @return void + */ + public function raz() + { + $this->id('RESET'); + $this->ref('RESET'); + $this->qte('RESET'); + $this->stock('RESET'); + $this->remise_percent('RESET'); + $this->montant_remise('RESET'); + $this->prix('RESET'); + $this->tva('RESET'); + } + + /** + * Reinitialisation des attributs persistants + */ + public function raz_pers() + { + $this->num_facture('RESET'); + $this->mode_reglement('RESET'); + $this->montant_encaisse('RESET'); + $this->montant_rendu('RESET'); + $this->paiement_le('RESET'); + + $this->prix_total_ht('RESET'); + $this->montant_tva('RESET'); + $this->prix_total_ttc('RESET'); + + } + + + // Methodes de modification des attributs proteges + + /** + * Getter for id + * @param aId + * @return id + */ + public function id($aId=null) + { + + if ( !$aId ) + { + + return $this->id; + + } else if ( $aId == 'RESET' ) + { + + $this->id = NULL; + + } else + { + + $this->id = $aId; + + } + + } + + /** + * Getter for ref + * @param $aRef + */ + public function ref($aRef=null) + { + + if ( !$aRef ) + { + return $this->ref; + } + else if ( $aRef == 'RESET' ) + { + $this->ref = NULL; + } + else + { + $this->ref = $aRef; + } + + } + + /** + * Getter for qte + * @param $aQte + * @return + */ + public function qte ( $aQte=null ) + { + if ( !$aQte ) + { + return $this->qte; + } + else if ( $aQte == 'RESET' ) + { + + $this->qte = NULL; + } + else + { + $this->qte = $aQte; + } + + } + + /** + * Getter for stock + * + * @param aStock + * @return + */ + public function stock($aStock=null) + { + + if ( !$aStock ) + { + return $this->stock; + } + else if ( $aStock == 'RESET' ) + { + $this->stock = NULL; + } + else + { + $this->stock = $aStock; + } - $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; - } + /** + * Getter for remise_percent + * + * @param aRemisePercent + * @return + */ + 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; + } - /** - * Reinitialisation des attributs - */ - public function raz () - { - $this->id('RESET'); - $this->ref('RESET'); - $this->qte('RESET'); - $this->stock('RESET'); - $this->remise_percent('RESET'); - $this->montant_remise('RESET'); - $this->prix('RESET'); - $this->tva('RESET'); + } - } + /** + * Getter for montant_remise + * + * @param aMontantRemise + * @return + */ + public function montant_remise($aMontantRemise=null) + { - /** - * Reinitialisation des attributs persistants - */ - public function raz_pers () - { - $this->num_facture('RESET'); - $this->mode_reglement('RESET'); - $this->montant_encaisse('RESET'); - $this->montant_rendu('RESET'); - $this->paiement_le('RESET'); + if ( !$aMontantRemise ) { - $this->prix_total_ht('RESET'); - $this->montant_tva('RESET'); - $this->prix_total_ttc('RESET'); + return $this->montant_remise; - } + } else if ( $aMontantRemise == 'RESET' ) { + $this->montant_remise = NULL; - // Methodes de modification des attributs proteges + } else { - /** - * Getter for id - * @param aId - * @return id - */ - public function id ( $aId=null ) - { + $this->montant_remise = $aMontantRemise; - if ( !$aId ) { + } - return $this->id; + } - } else if ( $aId == 'RESET' ) { + /** + * Getter for prix + * + * @param aPrix + * @return + */ + public function prix ( $aPrix=null ) + { - $this->id = NULL; + if ( !$aPrix ) { - } else { + return $this->prix; - $this->id = $aId; + } else if ( $aPrix == 'RESET' ) { - } + $this->prix = NULL; - } + } else { - /** - * Getter for ref - * @param $aRef - */ - public function ref ( $aRef=null ) { + $this->prix = $aPrix; - if ( !$aRef ) { + } - return $this->ref; + } - } else if ( $aRef == 'RESET' ) { + /** + * Getter for tva + * + * @param aTva + * @return + */ + public function tva ( $aTva=null ) + { - $this->ref = NULL; + if ( !$aTva ) { - } else { + return $this->tva; - $this->ref = $aRef; + } else if ( $aTva == 'RESET' ) { - } + $this->tva = NULL; - } + } else { - /** - * Getter for qte - * @param $aQte - * @return - */ - public function qte ( $aQte=null ) { + $this->tva = $aTva; - if ( !$aQte ) { + } - return $this->qte; + } - } else if ( $aQte == 'RESET' ) { + /** + * + * @param $aNumFacture + */ + public function num_facture ( $aNumFacture=null ) + { - $this->qte = NULL; + if ( !$aNumFacture ) { - } else { + return $this->num_facture; - $this->qte = $aQte; + } else if ( $aNumFacture == 'RESET' ) { - } + $this->num_facture = NULL; - } + } else { - /** - * Getter for stock - * @param aStock - * @return - */ - public function stock ( $aStock=null ) - { + $this->num_facture = $aNumFacture; - if ( !$aStock ) { + } + } - return $this->stock; + /** + * + * @param unknown_type $aModeReglement + */ + public function mode_reglement ( $aModeReglement=null ) + { - } else if ( $aStock == 'RESET' ) { + if ( !$aModeReglement ) { - $this->stock = NULL; + return $this->mode_reglement; - } else { + } else if ( $aModeReglement == 'RESET' ) { - $this->stock = $aStock; + $this->mode_reglement = NULL; - } + } else { - } + $this->mode_reglement = $aModeReglement; - /** - * Getter for remise_percent - * @param aRemisePercent - * @return - */ - public function remise_percent ( $aRemisePercent=null ) - { + } - if ( !$aRemisePercent ) { + } - return $this->remise_percent; + /** + * + * @param $aMontantEncaisse + */ + public function montant_encaisse ( $aMontantEncaisse=null ) + { - } else if ( $aRemisePercent == 'RESET' ) { + if ( !$aMontantEncaisse ) { - $this->remise_percent = NULL; + return $this->montant_encaisse; - } else { + } else if ( $aMontantEncaisse == 'RESET' ) { - $this->remise_percent = $aRemisePercent; + $this->montant_encaisse = NULL; - } + } else { - } + $this->montant_encaisse = $aMontantEncaisse; - /** - * Getter for montant_remise - * @param aMontantRemise - * @return - */ - public function montant_remise ( $aMontantRemise=null ) { + } - if ( !$aMontantRemise ) { + } - return $this->montant_remise; + /** + * + * @param $aMontantRendu + */ + public function montant_rendu ( $aMontantRendu=null ) + { - } else if ( $aMontantRemise == 'RESET' ) { + if ( !$aMontantRendu ) { - $this->montant_remise = NULL; + return $this->montant_rendu; + } else if ( $aMontantRendu == 'RESET' ) { - } else { + $this->montant_rendu = NULL; - $this->montant_remise = $aMontantRemise; + } else { - } + $this->montant_rendu = $aMontantRendu; - } + } - /** - * Getter for prix - * @param aPrix - * @return - */ - public function prix ( $aPrix=null ) - { + } - if ( !$aPrix ) { + /** + * + * @param $aPaiementLe + */ + public function paiement_le ( $aPaiementLe=null ) + { - return $this->prix; + if ( !$aPaiementLe ) { - } else if ( $aPrix == 'RESET' ) { + return $this->paiement_le; - $this->prix = NULL; + } else if ( $aPaiementLe == 'RESET' ) { - } else { + $this->paiement_le = NULL; - $this->prix = $aPrix; + } else { - } + $this->paiement_le = $aPaiementLe; - } + } - /** - * Getter for tva - * @param aTva - * @return - */ - public function tva ( $aTva=null ) - { + } - if ( !$aTva ) { + /** + * + * @param $aTotalHt + */ + public function prix_total_ht ( $aTotalHt=null ) + { - return $this->tva; + if ( !$aTotalHt ) { - } else if ( $aTva == 'RESET' ) { + return $this->prix_total_ht; - $this->tva = NULL; + } else if ( $aTotalHt == 'RESET' ) { - } else { + $this->prix_total_ht = NULL; - $this->tva = $aTva; + } else { - } + $this->prix_total_ht = $aTotalHt; - } + } - public function num_facture ( $aNumFacture=null ) - { + } - if ( !$aNumFacture ) { + /** + * + * @param $aMontantTva + */ + public function montant_tva ( $aMontantTva=null ) + { - return $this->num_facture; + if ( !$aMontantTva ) { - } else if ( $aNumFacture == 'RESET' ) { + return $this->montant_tva; - $this->num_facture = NULL; + } else if ( $aMontantTva == 'RESET' ) { - } else { + $this->montant_tva = NULL; - $this->num_facture = $aNumFacture; + } else { - } + $this->montant_tva = $aMontantTva; - } + } - public function mode_reglement ( $aModeReglement=null ) - { + } - if ( !$aModeReglement ) { + /** + * + * @param $aTotalTtc + */ + public function prix_total_ttc ( $aTotalTtc=null ) + { - 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; - - } - - } + if ( !$aTotalTtc ) + { + return $this->prix_total_ttc; + } + else if ( $aTotalTtc == 'RESET' ) + { + $this->prix_total_ttc = NULL; + } + else + { + $this->prix_total_ttc = $aTotalTtc; + } + } } diff --git a/htdocs/cashdesk/tpl/liste_articles.tpl.php b/htdocs/cashdesk/tpl/liste_articles.tpl.php index edb8ed0c751..4be93a96363 100644 --- a/htdocs/cashdesk/tpl/liste_articles.tpl.php +++ b/htdocs/cashdesk/tpl/liste_articles.tpl.php @@ -31,87 +31,44 @@ along with this program. If not, seetrans("ShoppingCart"); ?>
query($request); - if (! $res) - { - dol_print_error($db); - exit; - } +/** add Ditto for MultiPrix*/ +$thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; +$societe = new Societe($db); +$societe->fetch($thirdpartyid); +/** end add Ditto */ - if ( $db->num_rows($res) ) - { +$tab=array(); +$tab = $_SESSION['poscart']; - $ret=array(); $i=0; +$tab_size=count($tab); +if ($tab_size <= 0) print ''.$tab[$i]['ref'].' - '.$tab[$i]['label'].'
'."\n"); - /** add Ditto for MultiPrix*/ - $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; - $societe = new Societe($db); - $societe->fetch($thirdpartyid); - /** end add Ditto */ + if ( $tab[$i]['remise_percent'] > 0 ) { - while ( $tab = $db->fetch_array($res) ) - { - foreach ( $tab as $cle => $valeur ) - { - $ret[$i][$cle] = $valeur; - } + $remise_percent = ' -'.$tab[$i]['remise_percent'].'%'; - /** add Ditto for MultiPrix*/ - if($conf->global->PRODUIT_MULTIPRICES) - { - $product = new Product($db); - $product->fetch($ret[$i]['id']); + } else { - if(isset($product->multiprices[$societe->price_level])) - { - $ret[$i]['price'] = $product->multiprices_ttc[$societe->price_level]; - } - } - /** end add Ditto */ + $remise_percent = ''; + } - $i++; - } - $tab = $ret; + $remise = $tab[$i]['remise']; - $tab_size=count($tab); - for($i=0;$i < $tab_size;$i++) { + echo (''.$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").')
'."\n"); + echo (''.$tab[$i]['ref'].' - '.$tab[$i]['label'].'
'."\n"); +$obj_facturation->calculTotaux(); +$total_ttc = $obj_facturation->prix_total_ttc(); +echo (''.$langs->trans("Total").' : '.price2num($total_ttc, 'MT').' '.$conf->monnaie.'
'.$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").')
'."\n"); - echo (''.$langs->trans("Total").' : '.price2num($total_ttc, 'MT').' '.$conf->monnaie.'
'.$langs->trans("NoArticle").'
'."\n"); - - } - -?> +?> - \ No newline at end of file diff --git a/htdocs/cashdesk/tpl/ticket.tpl.php b/htdocs/cashdesk/tpl/ticket.tpl.php index 834ab76619d..14f6537181f 100644 --- a/htdocs/cashdesk/tpl/ticket.tpl.php +++ b/htdocs/cashdesk/tpl/ticket.tpl.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2007-2008 Jeremie Olliviername; ?>
-
-
name; ?>
+
+
- '; - print $object->ref; - ?> -
-'; +print $object->ref; +?>
+| trans("Code"); ?> | trans("Label"); ?> | trans("Qty"); ?> | trans("Discount").' (%)'; ?> | trans("TotalHT"); ?> |
|---|---|---|---|---|
| trans("Code"); ?> | +trans("Label"); ?> | +trans("Qty"); ?> | +trans("Discount").' (%)'; ?> | +trans("TotalHT"); ?> | +
| '.$tab[$i]['ref'].' | '.$tab[$i]['label'].' | '.$tab[$i]['qte'].' | '.$tab[$i]['remise_percent'].' | '.price2num($tab[$i]['total_ht'],'MT').' '.$conf->monnaie.' |
| '.$tab[$i]['ref'].' | '.$tab[$i]['label'].' | '.$tab[$i]['qte'].' | '.$tab[$i]['remise_percent'].' | '.price2num($tab[$i]['total_ht'],'MT').' '.$conf->monnaie.' |
| '.$langs->trans("TotalHT").' | '.price2num($obj_facturation->prix_total_ht(),'MT')." ".$conf->monnaie." | \n"; - echo '
|---|---|
| '.$langs->trans("TotalVAT").' | '.price2num($obj_facturation->montant_tva(),'MT')." ".$conf->monnaie." |
| '.$langs->trans("TotalTTC").' | '.price2num($obj_facturation->prix_total_ttc(),'MT')." ".$conf->monnaie." | '.$langs->trans("TotalHT").' | '.price2num($obj_facturation->prix_total_ht(),'MT')." ".$conf->monnaie." | \n"; +echo '
| '.$langs->trans("TotalVAT").' | '.price2num($obj_facturation->montant_tva(),'MT')." ".$conf->monnaie." |
| '.$langs->trans("TotalTTC").' | '.price2num($obj_facturation->prix_total_ttc(),'MT')." ".$conf->monnaie." |