-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
facturation_verif.php
168 lines (139 loc) · 4.97 KB
/
facturation_verif.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2008-2010 Laurent Destailleur <eldy@uers.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 3 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/>.
*/
/**
* \file htdocs/cashdesk/facturation_verif.php
* \ingroup cashdesk
* \brief facturation_verif.php
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php';
require_once DOL_DOCUMENT_ROOT.'/cashdesk/class/Facturation.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$obj_facturation = unserialize($_SESSION['serObjFacturation']);
unset ($_SESSION['serObjFacturation']);
switch ( $_GET['action'] )
{
default:
if ( $_POST['hdnSource'] != 'NULL' )
{
$sql = "SELECT p.rowid, p.ref, p.price, p.tva_tx";
if (! empty($conf->stock->enabled) && !empty($conf_fkentrepot)) $sql.= ", ps.reel";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
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;
$sql.= " WHERE p.entity IN (".getEntity('product', 1).")";
// Recuperation des donnees en fonction de la source (liste deroulante ou champ texte) ...
if ( $_POST['hdnSource'] == 'LISTE' )
{
$sql.= " AND p.rowid = ".$_POST['selProduit'];
}
else if ( $_POST['hdnSource'] == 'REF' )
{
$sql.= " AND p.ref = '".$_POST['txtRef']."'";
}
$result = $db->query($sql);
if ($result)
{
// ... et enregistrement dans l'objet
if ( $db->num_rows($result) )
{
$ret=array();
$tab = $db->fetch_array($result);
foreach ( $tab as $key => $value )
{
$ret[$key] = $value;
}
/** add Ditto for MultiPrix*/
if (! empty($conf->global->PRODUIT_MULTIPRICES))
{
$thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY'];
$productid = $ret['rowid'];
$societe = new Societe($db);
$societe->fetch($thirdpartyid);
$product = new Product($db);
$product->fetch($productid);
if(isset($product->multiprices[$societe->price_level]))
{
$ret['price'] = $product->multiprices[$societe->price_level];
$ret['price_ttc'] = $product->multiprices_ttc[$societe->price_level];
// $product->multiprices_min[$societe->price_level];
// $product->multiprices_min_ttc[$societe->price_level];
// $product->multiprices_base_type[$societe->price_level];
$ret['tva_tx'] = $product->multiprices_tva_tx[$societe->price_level];
}
}
/** end add Ditto */
$obj_facturation->id($ret['rowid']);
$obj_facturation->ref($ret['ref']);
$obj_facturation->stock($ret['reel']);
$obj_facturation->prix($ret['price']);
$obj_facturation->tva($ret['tva_tx']);
// Definition du filtre pour n'afficher que le produit concerne
if ( $_POST['hdnSource'] == 'LISTE' )
{
$filtre = $ret['ref'];
}
else if ( $_POST['hdnSource'] == 'REF' )
{
$filtre = $_POST['txtRef'];
}
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation&filtre='.$filtre;
}
else
{
$obj_facturation->raz();
if ( $_POST['hdnSource'] == 'REF' )
{
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation&filtre='.$_POST['txtRef'];
}
else
{
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation';
}
}
}
else
{
dol_print_error($db);
}
}
else
{
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation';
}
break;
case 'ajout_article': // We have clicked on button "Add product"
//var_dump($obj_facturation);
//exit;
if (! empty($obj_facturation->id)) // A product has been selected and stored in session
{
$obj_facturation->qte($_POST['txtQte']);
$obj_facturation->tva($_POST['selTva']);
$obj_facturation->remisePercent($_POST['txtRemise']);
$obj_facturation->ajoutArticle();
}
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation';
break;
case 'suppr_article':
$obj_facturation->supprArticle($_GET['suppr_id']);
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menu=facturation';
break;
}
$_SESSION['serObjFacturation'] = serialize($obj_facturation);
header('Location: '.$redirection);
exit;