-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsousitemprixaff.php
More file actions
153 lines (139 loc) · 3.45 KB
/
sousitemprixaff.php
File metadata and controls
153 lines (139 loc) · 3.45 KB
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
<?php
require_once("./stpiadmin/includes/includes.php");
require_once("./stpiadmin/includes/classes/item/clsitem.php");
require_once("./stpiadmin/includes/classes/user/clsuser.php");
require_once("./stpiadmin/includes/classes/registre/clsregistre.php");
$objBdd = clsbdd::singleton();
$objTexte = new clstexte("./texte/sousitemprixaff");
$objUser = new clsuser();
$objItem = new clsitem();
$objRegistre = new clsregistre();
$objClient =& $objRegistre->stpi_getObjClient();
$objSousItem = $objItem->stpi_getObjSousItem();
$objAttribut = $objItem->stpi_getObjSousItem()->stpi_getObjAttribut();
if (!$objItem->stpi_chkNbID($_POST["nbItemID"]))
{
exit;
}
$i = 0;
$arrAttributID = array();
while(true)
{
if (!isset($_POST["nbAttributID" . $i]))
{
break;
}
if (!$objAttribut->stpi_chkNbID($_POST["nbAttributID" . $i]))
{
exit;
}
$arrAttributID[] = $_POST["nbAttributID" . $i];
$i++;
}
if (empty($arrAttributID))
{
exit;
}
$boolRegistre = 0;
if ($objUser = $objUser->stpi_getObjUserFromSession())
{
if ($objUser->stpi_getNbTypeUserID() == 2)
{
if ($objClient->stpi_setNbID($objUser->stpi_getNbID()))
{
if ($nbRegistreID = $objClient->stpi_selNbRegistreIDPublic())
{
if ($objRegistre->stpi_setNbID($nbRegistreID))
{
if ($objUser->stpi_getNbID() == $objRegistre->stpi_getNbClientID())
{
$boolRegistre = 1;
}
}
}
}
}
}
$SQL = "SELECT stpi_item_SousItem.nbSousItemID, COUNT(*) AS nbMatch";
$SQL .= " FROM stpi_item_SousItem, stpi_item_SousItem_Attribut";
$SQL .= " WHERE stpi_item_SousItem.nbItemID = '" . $objBdd->stpi_trsInputToBdd($_POST["nbItemID"]) . "'";
$SQL .= " AND stpi_item_SousItem.nbSousItemID = stpi_item_SousItem_Attribut.nbSousItemID";
/*
$SQL .= " AND stpi_item_SousItem.nbItemID=stpi_item_Item_DispItem.nbItemID";
if ($boolRegistre)
{
$SQL .= " AND ((stpi_item_Item_DispItem.nbDispItemID=1 AND stpi_item_SousItem.nbQte > 0) OR stpi_item_Item_DispItem.nbDispItemID=2)";
}
else
{
$SQL .= " AND stpi_item_Item_DispItem.nbDispItemID=1 AND stpi_item_SousItem.nbQte > 0";
}
*/
$SQL .= " AND (";
foreach ($arrAttributID as $k => $nbAttributID)
{
if ($k != 0)
{
$SQL .= " OR stpi_item_SousItem_Attribut.nbAttributID = '" . $objBdd->stpi_trsInputToBdd($nbAttributID) . "'";
}
else
{
$SQL .= " stpi_item_SousItem_Attribut.nbAttributID = '" . $objBdd->stpi_trsInputToBdd($nbAttributID) . "'";
}
}
$SQL .= " )";
$SQL .= " GROUP BY stpi_item_SousItem.nbSousItemID";
$SQL .= " HAVING nbMatch = " . $objBdd->stpi_trsInputToBdd(count($arrAttributID));
$ok = true;
if ($result = $objBdd->stpi_select($SQL))
{
if ($row = mysql_fetch_assoc($result))
{
if ($objSousItem->stpi_setNbID($row["nbSousItemID"]))
{
$boolAddToCart = 0;
if ($objItem->stpi_setNbID($objSousItem->stpi_getNbItemID()))
{
if ($objItem->stpi_chkDisponibilite(1))
{
if ($objSousItem->stpi_getNbQte() > 0)
{
$boolAddToCart = 1;
}
}
if ($boolRegistre)
{
if (!$objItem->stpi_chkDisponibilite(2))
{
$boolRegistre = 0;
}
}
}
if ($boolAddToCart OR $boolRegistre)
{
$objSousItem->stpi_affPrixPublic(1, $boolAddToCart, $boolRegistre);
}
else
{
$ok = false;
}
}
else
{
$ok = false;
}
}
else
{
$ok = false;
}
}
else
{
$ok = false;
}
if ($ok == false)
{
print($objTexte->stpi_getArrTxt("noavailable"));
}
?>