-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·516 lines (489 loc) · 14.3 KB
/
index.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
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
<?php //Init
// Display options
$options = array(
'debug' => $_GET['debug']
);
$product_categories = array(
array(
'category_name' => 'Alpine ski',
'style' => 'alpineskis',
'attributes' => array(
array(
'attribute_name' => 'AlpineSkiLengthJunior',
'attribute_public_name' => 'Ski length',
'article_type' => 'AlpineSkiJunior',
'profile_attribute' => 'Length of person (cm)',
'get' => 'length',
'attribute_calc' => 'Length of person - 20cm',
'allow_less' => 2,
'allow_more' => 5,
'unit' => 'cm',
'products' => array(
array(
'product_name' => 'Knatte/Junior'
),
array(
'product_name' => 'Knatte/Junior Twintip'
)
),
'fetch' => 'AlpineSkiLengthJunior'
),
array(
'attribute_name' => 'AlpineSkiLengthSenior',
'attribute_public_name' => 'Ski length',
'article_type' => 'AlpineSkiSenior',
'profile_attribute' => 'Length of person (cm)',
'get' => 'length',
'attribute_calc' => 'Length of person - 14cm',
'allow_less' => 6,
'allow_more' => 2,
'unit' => 'cm',
'products' => array(
array(
'product_name' => 'Senior medel'
),
array(
'product_name' => 'Senior Advanced'
),
array(
'product_name' => 'Senior Extreme'
),
array(
'product_name' => 'Senior Extreme Pro'
),
array(
'product_name' => 'Senior Twintip'
)
),
'fetch' => 'AlpineSkiLengthSenior'
),
array(
'attribute_name' => 'AlpineSkiLengthFreeride',
'attribute_public_name' => 'Ski length',
'article_type' => 'AlpineSkiFreeride',
'profile_attribute' => 'Length of person (cm)',
'get' => 'length',
'attribute_calc' => 'Length of person - 7cm',
'allow_less' => 5,
'allow_more' => 2,
'unit' => 'cm',
'products' => array(
array(
'product_name' => 'Senior Freeride'
),
array(
'product_name' => 'Senior Topptur Medel'
),
array(
'product_name' => 'Senior Topptur Advanced'
)
),
'fetch' => 'AlpineSkiLengthFreeride'
)
)
),
array(
'category_name' => 'Alpine boot',
'style' => 'alpineboots',
'attributes' => array(
array(
'attribute_name' => 'AlpineBootSize',
'attribute_public_name' => 'Boot size',
'article_type' => 'AlpineBoot',
'profile_attribute' => 'Shoe size',
'get' => 'shoesize',
'attribute_calc' => 'Shoe size * 0.66',
'allow_less' => 0,
'allow_more' => 0,
'unit' => 'cm',
'products' => array(
array(
'product_name' => 'Knatte/Junior'
),
array(
'product_name' => 'Senior Medel'
),
array(
'product_name' => 'Senior Advanced'
),
array(
'product_name' => 'Senior Topptur Medel'
),
array(
'product_name' => 'Senior Topptur Avancerad'
)
),
'fetch' => 'AlpineBootSize',
)
)
),
array(
'category_name' => 'Cross country ski',
'style' => 'crosscountryskis',
'attributes' => array(
array(
'attribute_name' => 'CrossCountrySkiiLengthJunior',
'attribute_public_name' => 'Ski length',
'article_type' => 'CrossCountrySkiJunior',
'profile_attribute' => 'Length of person (cm)',
'get' => 'length',
'attribute_calc' => 'Length of person + 10cm',
'allow_less' => 15,
'allow_more' => 10,
'unit' => 'cm',
'products' => array(
array(
'product_name' => 'Junior Medel'
)
),
'fetch' => 'CrossCountrySkiLengthJunior',
),
array(
'attribute_name' => 'CrossCountrySkiiLengthSenior',
'attribute_public_name' => 'Ski length',
'article_type' => 'CrossCountrySkiSenior',
'profile_attribute' => 'Length of person (cm)',
'get' => 'length',
'attribute_calc' => 'Length of person + 20cm',
'allow_less' => 20,
'allow_more' => 15,
'unit' => 'cm',
'products' => array(
array(
'product_name' => 'Senior Medel'
),
array(
'product_name' => 'Senior Advanced'
)
),
'fetch' => 'CrossCountrySkiLengthSenior',
)
)
),
array(
'category_name' => 'Cross country boot',
'style' => 'crosscountryboots',
'attributes' => array(
array(
'attribute_name' => 'CrossCountryBootSize',
'attribute_public_name' => 'Boot size',
'article_type' => 'CrossCountryBoot',
'profile_attribute' => 'Shoe size',
'get' => 'shoesize',
'attribute_calc' => 'Shoe size + 1',
'allow_less' => 0,
'allow_more' => 0,
'unit' => '',
'products' => array(
array(
'product_name' => 'Knatte/Junior'
),
array(
'product_name' => 'Senior'
)
),
'fetch' => 'CrossCountryBootSize',
)
)
),
array(
'category_name' => 'Snowboard',
'style' => 'snowboards',
'attributes' => array(
array(
'attribute_name' => 'SnowboardLength',
'attribute_public_name' => 'Snowboard length',
'article_type' => 'Snowboard',
'profile_attribute' => 'Length of person (cm)',
'get' => 'length',
'attribute_calc' => 'Length of person - 20cm',
'allow_less' => 2,
'allow_more' => 8,
'unit' => 'cm',
'products' => array(
array(
'product_name' => 'Knatte/Junior Medel'
),
array(
'product_name' => 'Knatte/Junior Advanced'
),
array(
'product_name' => 'Senior Medel'
),
array(
'product_name' => 'Senior Advanced'
)
),
'fetch' => 'SnowboardLength',
)
)
),
array(
'category_name' => 'Snowboard boot',
'style' => 'snowboardboots',
'attributes' => array(
array(
'attribute_name' => 'SnowboardBootSize',
'attribute_public_name' => 'Boot size',
'article_type' => 'SnowboardBoot',
'profile_attribute' => 'Shoe size',
'get' => 'shoesize',
'attribute_calc' => 'Shoe size',
'allow_less' => 0,
'allow_more' => 0,
'unit' => '',
'products' => array(
array(
'product_name' => 'Knatte/Junior'
),
array(
'product_name' => 'Senior'
)
),
'fetch' => 'SnowboardBootSize',
)
)
),
array(
'category_name' => 'Skate',
'style' => 'skates',
'attributes' => array(
array(
'attribute_name' => 'SkateSize',
'attribute_public_name' => 'Skate size',
'article_type' => 'skates',
'profile_attribute' => 'Shoe size',
'get' => 'shoesize',
'attribute_calc' => 'Shoe size',
'allow_less' => 0,
'allow_more' => 0,
'unit' => '',
'products' => array(
array(
'product_name' => 'Knatte/Junior'
),
array(
'product_name' => 'Senior'
),
array(
'product_name' => 'Cross Country Senior'
)
),
'fetch' => 'SkateSize',
)
)
)
);
// Backwards compability for array_key_first
if (!function_exists('array_key_first')) {
function array_key_first($arr) {
foreach($arr as $key => $unused) {
return $key;
}
return NULL;
}
}
// return calculated recommended attribute
function CalcAttribute($attribute){
switch($attribute) {
case 'AlpineSkiLengthJunior' :
if( $_GET['length'] ){
return $_GET['length'] - 20;
break;
}
case 'AlpineSkiLengthSenior' :
if( $_GET['length'] ){
return $_GET['length'] - 14;
break;
}
case 'AlpineSkiLengthFreeride' :
if( $_GET['length'] ){
return $_GET['length'] - 7;
break;
}
case 'AlpineBootSize' :
if( $_GET['shoesize'] ){
return $_GET['shoesize'] * 0.66 ;
break;
}
case 'SnowboardLength' :
if( $_GET['length'] ){
return $_GET['length'] - 20;
break;
}
case 'SnowboardBootSize' :
if( $_GET['shoesize'] ){
return $_GET['shoesize'];
break;
}
case 'CrossCountrySkiLengthJunior' :
if( $_GET['length']){
return $_GET['length'] + 10;
break;
}
case 'CrossCountrySkiLengthSenior' :
if( $_GET['length']){
return $_GET['length'] + 20;
break;
}
case 'CrossCountryBootSize' :
if( $_GET['shoesize']){
return $_GET['shoesize'] + 1;
break;
}
case 'SkateSize' :
if( $_GET['shoesize']){
return $_GET['shoesize'];
break;
}
}
}
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Cairo&display=swap">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="style.css" >
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<form>
<div class="row main">
<?php
if($options['debug'] == true) { ?>
<div class="col-md-12">
<div class="content debug">
<h2>Debug</h2>
<div class="row">
<div class="col-md-6">
<h3>$_GET</h3>
<pre>
<?php var_export($_GET);?>
</pre>
</div>
<div class="col-md-6">
<h3>Result</h3>
<pre>
<?php var_export($product_categories) ?>;
</pre>
</div>
</div>
</div>
</div>
<?php } ?>
<div class="col-lg-6">
<div class="content meta">
<h1>Proof of concept: Recommended article attribute</h1>
<p>This tool aims to demonstrate the suggested method for calculating the recommended article attribut based on profile attributes given by the customer. The tool returns the recommended value for the for each article attribute type, regardless if that axact size exists or not, and the stock calculation would return the models which are close to this recommended value</p>
<p>With a product or package product the user would select an article variant for the article(s) added to that product.</p>
<div class="row">
<div class="col-md-9"><input name="debug" id="debug" type="checkbox" <?= ($_GET['debug']) ? 'checked' : null ; ?>/><label for="debug">Show debugging info</label></div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="content">
<h2>Profile attributes</h2>
<p>The attributes for customer.</p>
<div class="row">
<hr />
<div class="col-lg-9">
<label for="length">Length of person</label>
<p>Length of the customer in cm</p>
</div>
<div class="col-lg-3">
<input type='number' name='length' value='<?= $_GET['length'] ?>'>
</div>
<hr />
<div class="col-lg-9">
<label for="shoesize">Shoe size</label>
<p>European standard (Paris point) shoe size for customer.</p>
</div>
<div class="col-lg-3">
<input type='number' name='shoesize' value='<?= $_GET['shoesize'] ?>'>
</div>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="content slim">
<button type="submit">Submit</button>
</div>
</div>
</form>
<?php
if($_GET){
foreach($product_categories as $category){
echo '<div class="col-md-12"><div class="content ' . $category['style'] . '">';
echo '<span class="header">Product category</span><br />';
echo '<h2>' . $category['category_name'] . 's</h2>';
foreach($category['attributes'] as $attribute){
echo '<hr />';
echo '<div class="row">';
echo '<div class="col-md-4">';
echo '<span class="header">Articles - Subsets of article models</span><br />';
foreach($attribute['products'] as $product){
echo '<span class="label">' . $category['category_name'] . ' ' . $product['product_name'] . '</span><br />';
}
echo '</div>';
echo '<div class="col-md-3">';
echo '<div class="row">';
echo '<div class="col-md-12">';
echo '<span class="">' . 'Required profile attribute: '. '</span><br />';
echo '</div>';
echo '<div class="col-sm-7">';
echo '<span class="label">' . $attribute['profile_attribute']. '</span>';
echo '</div>';
echo '<div class="col-sm-3">';
echo '<span class="value">' .$_GET[$attribute['get']] . '</span>';
echo '</div>';
echo '<div class="col-md-2">' . '<span class="arrow">></span>' . '</div>';
echo '</div>';
echo '</div>';
echo '<div class="col-md-5">';
echo '<div class="row">';
echo '<div class="col-md-12">';
echo '<span class="">' . 'Article attribute: '. $attribute['attribute_name'] . '</span><br />';
echo '</div>';
echo '<div class="col-sm-9">';
echo '<span class="label">' . 'Optimal ' . $attribute['attribute_public_name'] . '</span>';
echo '</div>';
echo '<div class="col-sm-3">';
echo '<span class="value">' . CalcAttribute($attribute['fetch']) . $attribute['unit'] . '</span>';
echo '</div>';
echo '<div class="col-md-12">';
echo '<span class="calc">' . $attribute['attribute_name'] . ' = ' . $attribute['attribute_calc'] . '</span>';
echo '</div>';
if ($attribute['allow_less'] > 0 || $attribute['allow_more'] > 0 ){
echo '<div class="col-sm-9">';
echo '<span class="label">' . 'Minimum ' . $attribute['attribute_public_name'] . '</span>';
echo '</div>';
echo '<div class="col-sm-3">';
echo '<span class="value">' . (CalcAttribute($attribute['fetch']) - $attribute['allow_less']) . $attribute['unit'] . '</span>';
echo '</div>';
echo '<div class="col-md-12">';
echo '<span class="calc">-' . $attribute['allow_less'] . $attribute['unit'] . "</span>";
echo '</div>';
echo '<div class="col-sm-9">';
echo '<span class="label">' . 'Maximum ' . $attribute['attribute_public_name'] . '</span>';
echo '</div>';
echo '<div class="col-sm-3">';
echo '<span class="value">' . (CalcAttribute($attribute['fetch'])+$attribute['allow_more']) . $attribute['unit'] . '</span>';
echo '</div>';
echo '<div class="col-md-12">';
echo '<span class="calc">+' . $attribute['allow_more'] . $attribute['unit'] . "</span>";
echo '</div>';
}
echo '</div>';
echo '</div>';
echo '</div>';
}
echo '</div></div>';
}
}
?>
</body>
</html>