dolibarr  13.0.2
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 <https://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  // Avec filtre
40  $ret = array(); $i = 0;
41 
42  $sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx, p.fk_product_type";
43  if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql .= ", ps.reel";
44  $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
45  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 = '".$db->escape($conf_fkentrepot)."'";
46  $sql .= " WHERE p.entity IN (".getEntity('product').")";
47  $sql .= " AND p.tosell = 1";
48  if (!$conf->global->CASHDESK_SERVICES) $sql .= " AND p.fk_product_type = 0";
49  $sql .= " AND (";
50  $sql .= "p.ref LIKE '%".$db->escape(GETPOST('filtre'))."%' OR p.label LIKE '%".$db->escape(GETPOST('filtre'))."%'";
51  if (!empty($conf->barcode->enabled))
52  {
53  $filtre = GETPOST('filtre', 'alpha');
54 
55  //If the barcode looks like an EAN13 format and the last digit is included in it,
56  //then whe look for the 12-digit too
57  //As the twelve-digit string will also hit the 13-digit code, we only look for this one
58  if (strlen($filtre) == 13) {
59  $crit_12digit = substr($filtre, 0, 12);
60  $sql .= " OR p.barcode LIKE '%".$db->escape($crit_12digit)."%'";
61  } else {
62  $sql .= " OR p.barcode LIKE '%".$db->escape($filtre)."%'";
63  }
64  }
65  $sql .= ")";
66  $sql .= " ORDER BY label";
67 
68  dol_syslog("facturation.php", LOG_DEBUG);
69  $resql = $db->query($sql);
70  if ($resql)
71  {
72  $nbr_enreg = $db->num_rows($resql);
73 
74  while ($i < $conf_taille_listes && $tab = $db->fetch_array($resql))
75  {
76  foreach ($tab as $cle => $valeur)
77  {
78  $ret[$i][$cle] = $valeur;
79  }
80  $i++;
81  }
82  $db->free($resql);
83  } else {
84  dol_print_error($db);
85  }
86  $tab_designations = $ret;
87 } else {
88  // Sans filtre
89  $ret = array();
90  $i = 0;
91 
92  $sql = "SELECT p.rowid, ref, label, tva_tx, p.fk_product_type";
93  if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql .= ", ps.reel";
94  $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
95  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 = '".$db->escape($conf_fkentrepot)."'";
96  $sql .= " WHERE p.entity IN (".getEntity('product').")";
97  $sql .= " AND p.tosell = 1";
98  if (!$conf->global->CASHDESK_SERVICES) $sql .= " AND p.fk_product_type = 0";
99  $sql .= " ORDER BY p.label";
100 
101  dol_syslog($sql);
102  $resql = $db->query($sql);
103  if ($resql)
104  {
105  $nbr_enreg = $db->num_rows($resql);
106 
107  while ($i < $conf_taille_listes && $tab = $db->fetch_array($resql))
108  {
109  foreach ($tab as $cle => $valeur)
110  {
111  $ret[$i][$cle] = $valeur;
112  }
113  $i++;
114  }
115  $db->free($resql);
116  } else {
117  dol_print_error($db);
118  }
119  $tab_designations = $ret;
120 }
121 
122 //$nbr_enreg = count($tab_designations);
123 
124 if ($nbr_enreg > 1)
125 {
126  if ($nbr_enreg > $conf_taille_listes)
127  {
128  $top_liste_produits = '----- '.$conf_taille_listes.' '.$langs->transnoentitiesnoconv("CashDeskProducts").' '.$langs->trans("CashDeskOn").' '.$nbr_enreg.' -----';
129  } else {
130  $top_liste_produits = '----- '.$nbr_enreg.' '.$langs->transnoentitiesnoconv("CashDeskProducts").' '.$langs->trans("CashDeskOn").' '.$nbr_enreg.' -----';
131  }
132 } elseif ($nbr_enreg == 1)
133 {
134  $top_liste_produits = '----- 1 '.$langs->transnoentitiesnoconv("ProductFound").' -----';
135 } else {
136  $top_liste_produits = '----- '.$langs->transnoentitiesnoconv("NoProductFound").' -----';
137 }
138 
139 
140 // Recuperation des taux de tva
141 global $mysoc;
142 
143 $ret = array();
144 $i = 0;
145 
146 // Reinitialisation du mode de paiement, en cas de retour aux achats apres validation
147 $obj_facturation->getSetPaymentMode('RESET');
148 $obj_facturation->amountCollected('RESET');
149 $obj_facturation->amountReturned('RESET');
150 $obj_facturation->paiementLe('RESET');
151 
152 
153 // Affichage des templates
154 require 'tpl/facturation1.tpl.php';
GETPOST($paramname, $check= 'alphanohtml', $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= '', $logcontext=null)
Write log message into outputs.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...