-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclothes.php
More file actions
252 lines (212 loc) · 7.3 KB
/
Copy pathclothes.php
File metadata and controls
252 lines (212 loc) · 7.3 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?php
require_once("models/config.php");
if (!securePage($_SERVER['PHP_SELF'])){die();}
require_once("models/header.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<body>
<!-- header -->
<div id="header">
<?require_once("models/headerMenu.php");?>
</div>
<!-- end header -->
<!-- shell -->
<div class="shell">
<script type="text/javascript">
var sizes = [[ 0,3,'longSlot', 'bigSlot','smallSlot', 'smallSlot','bigSlot'],
[ 1,3,'bigSlot', 'longSlot','smallSlot', 'smallSlot','bigSlot'],
[ 2,3,'bigSlot', 'longSlot','longSlot', 'bigSlot'] ];
var index = 0;
var collection = new Array();;
var allItemsCompleted = 0;
$(init);
function navigate(nav){
index = index + nav;
if(index == sizes.length)
index = 0;
if(index <0)
index = sizes.length -1 ;
reset();
displayChoices();
displayCanevasCompositions();
}
function reset(){
allItemsCompleted = 0;
$('#clothesPile').html( '' );
$('#clothesSlotsColum1').html( '' );
$('#clothesSlotsColum2').html( '' );
collection = new Array();;
$( init );
}
function displayChoices(id_brand,id_cat,id_color){
$('#clothesPile').html( '' );
$.get( "http://randonnazbike.ch/social/getter.php?tbl=clothe&color="+id_color+"&categorie="+id_cat+"&seller="+id_brand, function( data ) {
for ( var i=0; i<data.length; i++ ) {
$('<div>' + '<img width="40px" src="clothes_images/'+data[i].id +'.jpg"/>' + '</div>').data('clothesId',data[i].id).attr('class', 'smallSlot').appendTo( '#clothesPile' ).draggable( {
stack: '#clothesPile div',
cursor: 'move',
container: 'body',
helper: 'clone',
revert: true
} );
}
$('#clothesPile').append('<div style="clear:both;"></div>');
});
}
function displayCanevasCompositions(){
// Create the card slots
for ( var i=2; i<=sizes[index].length; i++ ) {
if(i<=sizes[index][1]){
$('<div>' + "" + '</div>').attr('class', sizes[index][i]).appendTo( '#clothesSlotsColum1' ).droppable( {
accept: '#clothesPile div',
hoverClass: 'hovered',
drop: handleClothesDrop
} );
}else
{
$('<div>' + "" + '</div>').attr('class', sizes[index][i]).appendTo( '#clothesSlotsColum2' ).droppable( {
accept: '#clothesPile div',
hoverClass: 'hovered',
drop: handleClothesDrop
} );
}
}
}
function init() {
displayCanevasCompositions();
}
function handleClothesDrop( event, ui ) {
collection[allItemsCompleted] = ui.draggable.data("clothesId");
$(this).css("border","2px solid white");
ui.draggable.draggable( 'disable' );
$(this).append('<img data="'+ui.draggable.data("clothesId")+' " src="clothes_images/'+ui.draggable.data("clothesId")+'.jpg" />');
$(this).droppable( 'disable' );
ui.draggable.hide();
ui.draggable.draggable( 'option', 'revert', false );
allItemsCompleted++;
}
function search(){
var category = $("#select_category").val();
var brand = $("#select_brand").val();
var color = $("#select_color").val();
displayChoices(brand, category, color);
}
function create(){
if(allItemsCompleted == (sizes[index].length-2)){
$.ajax({
type: "GET",
url: "getter.php?tbl=addcompo",
data: "compositionArray="+JSON.stringify(collection)+"&compoCanevas="+index+"&compoName="+$('#compositionName').val()+"&catStyle="+$('#select_style').val(),
success: function(result) {
$('<div></div>').load('pageConfirm.php?id='+result).modal();
reset();
},
error: function() {
alert("Error, you do not complete all items");
}
});
}else{
alert("you havn't completed all items");
}
}
</script>
</head>
<body>
<!-- main -->
<div id="main">
<div id="content" >
<div id="container" class="clothesContainer" >
<div id="clothesComposition" style="float:left; width:480px;">
<div style="padding-top:15px; padding-bottom:15px;"><h2>1. Choose your canevas...</h2></div>
<div id="left" style="float:left; padding-top:120px; width:70px;">
<span onclick="navigate(-1)" id="button-previous"></span>
</div>
<div id="clothesSlots" style="float:left; background-color:white" class="shadow">
<div id="clothesSlotsColum1" class="clothesSlotsColum">
</div>
<div id="clothesSlotsColum2" class="clothesSlotsColum">
</div>
</div>
<div id="right" style="padding-top:120px; float:left; width:100px;">
<span onclick="navigate(1)" id="button-next"></span>
</div>
</div>
<div id="nameContainer" style="float:left; width:320px;">
<div style="padding-top:15px; padding-bottom:15px;"><h2>2. Give a description...</h2></div>
<input type="text" id="compositionName" placeholder="Composition title">
</br>
<select id="select_style">
<option value="" disabled="disabled" selected="selected">Choose a category</option>
<?php
$mysql = new mysqli("localhost", "socialuser2", "salutsalut", "mydb") or die('There was a problem connecting to the database');
$stmt = $mysql->prepare('Select id_style,style_name from tbl_style');
$stmt->execute();
$stmt->bind_result($id,$nom);
while($row = $stmt->fetch()){
echo '<option value="'.$id.'">'.$nom.'</option>';
}
?>
</select></br></br>
</div>
<div id="searchClothesContainer" style="float:left; width:300px;">
<div style="padding-top:15px; padding-bottom:15px;"><h2>3. Search your clothes...</h2></div>
<select id="select_category">
<option value="n" selected="selected">Choose a category</option>
<?php
$mysql = new mysqli("localhost", "socialuser2", "salutsalut", "mydb") or die('There was a problem connecting to the database');
$stmt = $mysql->prepare('Select id_categorie,categorie_name from tbl_categorie');
$stmt->execute();
$stmt->bind_result($id,$nom);
while($row = $stmt->fetch()){
echo '<option value="'.$id.'">'.$nom.'</option>';
}
?>
</select>
<select id="select_brand">
<option value="n" selected="selected">Choose a brand</option>
<?php
$mysql = new mysqli("localhost", "socialuser2", "salutsalut", "mydb") or die('There was a problem connecting to the database');
$stmt = $mysql->prepare('Select id_seller,seller_name from tbl_seller');
$stmt->execute();
$stmt->bind_result($id,$nom);
while($row = $stmt->fetch()){
echo '<option value="'.$id.'">'.$nom.'</option>';
}
?>
</select></br>
<select id="select_color">
<option value="n" selected="selected">Choose a color</option>
<?php
$mysql = new mysqli("localhost", "socialuser2", "salutsalut", "mydb") or die('There was a problem connecting to the database');
$stmt = $mysql->prepare('Select id_color,color_name from tbl_color');
$stmt->execute();
$stmt->bind_result($id,$nom);
while($row = $stmt->fetch()){
echo '<option value="'.$id.'">'.$nom.'</option>';
}
?>
</select></br>
<button onclick="search()">Search</button>
</div>
<div style="clear:both;"/>
<div id="clothesSelector" >
<div style="padding-top:15px; padding-bottom:15px;"><h2>4. Drag your favorites clothes and make your composition</h2></div>
<div id="clothesPile" style="overflow: auto; height:300px;" class="shadow">
</div>
<button onclick="reset()">Reset</button>
<button onclick="create()">Create</button>
</div>
</div>
</div>
</div>
<!-- end main -->
<!-- footer -->
<div id="footer">
<?require_once("models/footer.php");?>
</div>
<!-- end footer -->
</div>
<!-- end shell -->
</body>
</html>