dolibarr  7.0.0-beta
facturation.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
3  * Copyright (C) 2008-2011 Laurent Destailleur <eldy@uers.sourceforge.net>
4  * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
5  * Copyright (C) 2013 Marcos GarcĂ­a <marcosgdf@gmail.com>
6  * Copyright (C) 2013 Adolfo Segura <adolfo.segura@gmail.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
31 /*
32  * View
33  */
34 
35 $form=new Form($db);
36 
37 // Get list of articles (in warehouse '$conf_fkentrepot' if defined and stock module enabled)
38 if ( GETPOST('filtre','alpha') ) {
39 
40  // Avec filtre
41  $ret=array(); $i=0;
42 
43  $sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx, p.fk_product_type";
44  if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
45  $sql.= " FROM ".MAIN_DB_PREFIX."product as p";
46  if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$conf_fkentrepot."'";
47  $sql.= " WHERE p.entity IN (".getEntity('product').")";
48  $sql.= " AND p.tosell = 1";
49  if(!$conf->global->CASHDESK_SERVICES) $sql.= " AND p.fk_product_type = 0";
50  $sql.= " AND (";
51  $sql.= "p.ref LIKE '%".$db->escape(GETPOST('filtre'))."%' OR p.label LIKE '%".$db->escape(GETPOST('filtre'))."%'";
52  if (! empty($conf->barcode->enabled))
53  {
54  $filtre = GETPOST('filtre','alpha');
55 
56  //If the barcode looks like an EAN13 format and the last digit is included in it,
57  //then whe look for the 12-digit too
58  //As the twelve-digit string will also hit the 13-digit code, we only look for this one
59  if (strlen($filtre) == 13) {
60  $crit_12digit = substr($filtre, 0, 12);
61  $sql .= " OR p.barcode LIKE '%".$db->escape($crit_12digit)."%'";
62  } else {
63  $sql.= " OR p.barcode LIKE '%".$db->escape($filtre)."%'";
64  }
65  }
66  $sql.= ")";
67  $sql.= " ORDER BY label";
68 
69  dol_syslog("facturation.php", LOG_DEBUG);
70  $resql=$db->query($sql);
71  if ($resql)
72  {
73  $nbr_enreg = $db->num_rows($resql);
74 
75  while ($i < $conf_taille_listes && $tab = $db->fetch_array($resql) )
76  {
77  foreach ( $tab as $cle => $valeur )
78  {
79  $ret[$i][$cle] = $valeur;
80  }
81  $i++;
82  }
83  $db->free($resql);
84  }
85  else
86  {
87  dol_print_error($db);
88  }
89  $tab_designations=$ret;
90 } else {
91 
92  // Sans filtre
93  $ret=array();
94  $i=0;
95 
96  $sql = "SELECT p.rowid, ref, label, tva_tx, p.fk_product_type";
97  if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
98  $sql.= " FROM ".MAIN_DB_PREFIX."product as p";
99  if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$conf_fkentrepot."'";
100  $sql.= " WHERE p.entity IN (".getEntity('product').")";
101  $sql.= " AND p.tosell = 1";
102  if(!$conf->global->CASHDESK_SERVICES) $sql.= " AND p.fk_product_type = 0";
103  $sql.= " ORDER BY p.label";
104 
105  dol_syslog($sql);
106  $resql=$db->query($sql);
107  if ($resql)
108  {
109  $nbr_enreg = $db->num_rows($resql);
110 
111  while ($i < $conf_taille_listes && $tab = $db->fetch_array($resql))
112  {
113  foreach ( $tab as $cle => $valeur )
114  {
115  $ret[$i][$cle] = $valeur;
116  }
117  $i++;
118  }
119  $db->free($resql);
120  }
121  else
122  {
123  dol_print_error($db);
124  }
125  $tab_designations=$ret;
126 }
127 
128 //$nbr_enreg = count($tab_designations);
129 
130 if ( $nbr_enreg > 1 )
131 {
132  if ( $nbr_enreg > $conf_taille_listes )
133  {
134  $top_liste_produits = '----- '.$conf_taille_listes.' '.$langs->transnoentitiesnoconv("CashDeskProducts").' '.$langs->trans("CashDeskOn").' '.$nbr_enreg.' -----';
135  }
136  else
137  {
138  $top_liste_produits = '----- '.$nbr_enreg.' '.$langs->transnoentitiesnoconv("CashDeskProducts").' '.$langs->trans("CashDeskOn").' '.$nbr_enreg.' -----';
139  }
140 
141 }
142 else if ( $nbr_enreg == 1 )
143 {
144  $top_liste_produits = '----- 1 '.$langs->transnoentitiesnoconv("ProductFound"). ' -----';
145 }
146 else
147 {
148  $top_liste_produits = '----- '.$langs->transnoentitiesnoconv("NoProductFound"). ' -----';
149 }
150 
151 
152 // Recuperation des taux de tva
153 global $mysoc;
154 
155 $ret=array();
156 $i=0;
157 
158 // Reinitialisation du mode de paiement, en cas de retour aux achats apres validation
159 $obj_facturation->getSetPaymentMode('RESET');
160 $obj_facturation->montantEncaisse('RESET');
161 $obj_facturation->montantRendu('RESET');
162 $obj_facturation->paiementLe('RESET');
163 
164 
165 // Affichage des templates
166 require ('tpl/facturation1.tpl.php');
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage generation of HTML components Only common components must be here.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013