-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategories.html
896 lines (725 loc) · 43 KB
/
categories.html
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
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
{extends file="admin-layout.tpl"}
{block name="no-return-functions"}
{$admin_current_location = 'catalog'}
{/block}
{block name="page-title"}{intl l='Categories'}{/block}
{block name="check-resource"}admin.category{/block}
{block name="check-access"}view{/block}
{block name="main-content"}
<div class="categories">
<div id="wrapper" class="container">
{include file="includes/catalog-breadcrumb.html"}
{hook name="categories.top" location="categories_top" }
<div class="row">
<div class="col-md-12">
<div class="general-block-decorator">
<div class="table-responsive">
<table class="table table-striped table-condensed" id="category_list">
<caption>
{* display parent category name, and get current cat ID *}
{loop name="category_title" type="category" visible="*" id=$category_id}
{intl l="Categories in %cat" cat={$TITLE}}
{/loop}
{elseloop rel="category_title"}
{intl l="Top level categories"}
{/elseloop}
{hook name="categories.caption" location="category_list_caption" }
{loop type="auth" name="can_create" role="ADMIN" resource="admin.category" access="CREATE"}
<a class="btn btn-primary action-btn" title="{intl l='Add a new category'}" href="#category_creation_dialog" data-toggle="modal">
<span class="glyphicon glyphicon-plus-sign"></span>
</a>
{/loop}
</caption>
{ifloop rel="category_list"}
<thead>
<tr>
<th class="object-title">
{admin_sortable_header
current_order=$category_order
order='id'
reverse_order='id_reverse'
path={url path='/admin/catalog' category_id=$category_id}
request_parameter_name='category_order'
label="{intl l='ID'}"
}
</th>
<th class="object-image"> </th>
<th class="object-title">
{admin_sortable_header
current_order=$category_order
order='alpha'
reverse_order='alpha_reverse'
path={url path='/admin/catalog' category_id=$category_id}
request_parameter_name='category_order'
label="{intl l='Category title'}"
}
</th>
{hook name="categories.header" location="category_list_header" }
<th>
{admin_sortable_header
current_order=$category_order
order='visible'
reverse_order='visible_reverse'
path={url path='/admin/catalog' category_id=$category_id}
request_parameter_name='category_order'
label="{intl l='Online'}"
}
</th>
<th>
{admin_sortable_header
current_order=$category_order
order='manual'
reverse_order='manual_reverse'
path={url path='/admin/catalog' category_id=$category_id}
request_parameter_name='category_order'
label="{intl l='Position'}"
}
</th>
<th class="actions">{intl l='Actions'}</th>
</tr>
</thead>
<tbody>
{loop name="category_list" type="category" visible="*" parent=$category_id order=$category_order backend_context="1" lang=$lang_id return_url=false}
<tr>
<td>{$ID}</td>
<td>
{loop type="image" name="cat_image" source="category" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"}
<a href="{url path='admin/catalog' category_id=$OBJECT_ID}" title="{intl l='Browse this category'}"><img class="img-thumbnail" src="{$IMAGE_URL nofilter}" alt="{$TITLE}" /></a>
{/loop}
</td>
<td class="object-title">
<a href="{url path='admin/catalog' category_id=$ID}" title="{intl l='Browse this category'}">
{$TITLE}
</a>
</td>
{hook name="categories.row" location="category_list_row" category_id={$ID} }
<td>
{loop type="auth" name="can_change" role="ADMIN" resource="admin.category" access="UPDATE"}
<div class="make-switch switch-small categoryVisibleToggle" data-id="{$ID}" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input type="checkbox" class="categoryVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
</div>
{/loop}
{elseloop rel="can_change"}
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input type="checkbox" class="disabled" disabled="disabled" {if $VISIBLE == 1}checked="checked"{/if}>
</div>
{/elseloop}
</td>
<td>
{admin_position_block
resource="admin.category"
access="UPDATE"
path={url path='admin/categories/update-position' category_id=$ID}
url_parameter="category_id"
in_place_edit_class="categoryPositionChange"
position=$POSITION
id=$ID
}
</td>
<td class="actions">
<div class="btn-toolbar btn toolbar-primary">
<span class="glyphicon glyphicon-cog"></span>
</div>
<div class="toolbar-options hidden">
<a title="{intl l='Browse this category'}" href="{url path='admin/categories' category_id=$ID}"><span class="glyphicon glyphicon-folder-open"></span></a>
{loop type="auth" name="can_change" role="ADMIN" resource="admin.category" access="UPDATE"}
<a title="{intl l='Edit this category'}" href="{url path='/admin/categories/update' category_id=$ID}"><span class="glyphicon glyphicon-edit"></span></a>
{/loop}
{loop type="auth" name="can_delete" role="ADMIN" resource="admin.category" access="DELETE"}
<a class="category-delete" title="{intl l='Delete this category and all its contents'}" href="#category_delete_dialog" data-id="{$ID}" data-toggle="modal"><span class="glyphicon glyphicon-trash"></span></a>
{/loop}
</div>
</td>
</tr>
{/loop}
</tbody>
{/ifloop}
{elseloop rel="category_list"}
<thead>
<tr>
<td class="message">
<div class="alert alert-info">
{loop type="auth" name="can_create" role="ADMIN" resource="admin.category" access="CREATE"}
{intl l="This category has no sub-categories. To create a new one, click the + button above."}
{/loop}
{elseloop rel="can_create"}
{intl l="This category has no sub-categories."}
{/elseloop}
</div>
</td>
</tr>
</thead>
{/elseloop}
</table>
</div>
</div>
</div>
</div>
{* -- PRODUCT MANAGEMENT ---------------------------------------------------- *}
{* No product on toplevel category, e.g. id_category = 0 *}
{loop type="currency" name="product-currency" id=$edit_currency_id backend_context="1"}
{$currency_symbol = $SYMBOL}
{/loop}
{if $category_id > 0}
<div class="row">
<div class="col-md-12">
<div class="general-block-decorator">
<div class="table-responsive">
<table class="table table-striped table-condensed">
<caption>
{* display parent category name *}
{loop name="category_title" type="category" visible="*" id=$category_id}
{intl l="Products in %cat" cat={$TITLE}}
{/loop}
{elseloop rel="category_title"}
{intl l="Top level Products"}
{/elseloop}
{hook name="products.caption" location="product_list_caption" }
<a class="btn btn-primary action-btn" title="{intl l='Add a new product'}" href="#product_creation_dialog" data-toggle="modal">
<span class="glyphicon glyphicon-plus-sign"></span>
</a>
</caption>
{ifloop rel="product_list"}
<thead>
<tr>
<th class="object-title">
{admin_sortable_header
current_order=$product_order
order='id'
reverse_order='id_reverse'
path={url path='/admin/catalog' category_id=$category_id target='products'}
request_parameter_name='product_order'
label="{intl l='ID'}"
}
<th> </th>
<th class="object-title">
{admin_sortable_header
current_order=$product_order
order='ref'
reverse_order='ref_reverse'
path={url path='/admin/catalog' category_id=$category_id target='products'}
request_parameter_name='product_order'
label="{intl l='Reference'}"
}
</th>
<th class="object-title">
{admin_sortable_header
current_order=$product_order
order='alpha'
reverse_order='alpha_reverse'
path={url path='/admin/catalog' category_id=$category_id target='products'}
request_parameter_name='product_order'
label="{intl l='Product title'}"
}
{hook name="products.header" location="product_list_header" }
<th class="text-right">
{admin_sortable_header
current_order=$product_order
order='min_price'
reverse_order='max_price'
path={url path='/admin/catalog' category_id=$category_id target='products'}
request_parameter_name='product_order'
label="{intl l='Price'}"
}
</th>
<th class="text-center">
{admin_sortable_header
current_order=$product_order
order='visible'
reverse_order='visible_reverse'
path={url path='/admin/catalog' category_id=$category_id target='products'}
request_parameter_name='product_order'
label="{intl l='Online'}"
}
</th>
<th class="text-center">
{admin_sortable_header
current_order=$product_order
order='manual'
reverse_order='manual_reverse'
path={url path='/admin/catalog' category_id=$category_id target='products'}
request_parameter_name='product_order'
label="{intl l='Position'}"
}
</th>
<th class="actions">{intl l="Actions"}</th>
</tr>
</thead>
<tbody>
{loop name="product_list" type="product" visible="*" category=$category_id order=$product_order page=$page backend_context="on" limit={config key="number_default_results_per_page.category_list" default=20} return_url=false}
<tr>
<td>{$ID}</td>
<td>
{loop type="image" name="cat_image" source="product" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"}
<a href="{url path='/admin/products/update' product_id=$OBJECT_ID page=$page}" title="{intl l='Edit this product'}">
<img src="{$IMAGE_URL nofilter}" alt="{$TITLE}" />
</a>
{/loop}
</td>
<td class="object-title">
<a href="{url path='/admin/products/update' product_id=$ID page=$page}" title="{intl l='Edit this product'}">{$REF}</a>
{if $VIRTUAL}<span class="glyphicon glyphicon-download text-muted" title="{intl l='Virtual product'}"></span>{/if}
</td>
<td class="object-title"><a href="{url path='/admin/products/update' product_id=$ID page=$page}" title="{intl l='Edit this product'}">{$TITLE}</a></td>
{hook name="products.row" location="product_list_row" product_id={$ID} }
<td class="text-right"><a href="{url path='/admin/products/update' product_id=$ID page=$page current_tab='prices'}" title="{intl l='Edit Prices'}">{format_money number=$BEST_PRICE symbol=$currency_symbol}</a></td>
<td class="text-center">
{loop type="auth" name="can_change" role="ADMIN" resource="admin.product" access="UPDATE"}
<div class="make-switch switch-small productVisibleToggle" data-id="{$ID}" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input type="checkbox" class="productVisibleToggle" {if $VISIBLE == 1}checked="checked"{/if}>
</div>
{/loop}
{elseloop rel="can_change"}
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input type="checkbox" class="disabled" disabled="disabled" {if $VISIBLE == 1}checked="checked"{/if}>
</div>
{/elseloop}
</td>
<td class="text-center">
{admin_position_block
resource="admin.product"
access="UPDATE"
path={url path='/admin/products/update-position' product_id=$ID category_id=$category_id}
url_parameter="product_id"
in_place_edit_class="productPositionChange"
position=$POSITION
id=$ID
}
</td>
<td class="actions">
<div class="btn-toolbar btn toolbar-primary">
<span class="glyphicon glyphicon-cog"></span>
</div>
<div class="toolbar-options hidden">
{loop type="auth" name="can_change" role="ADMIN" resource="admin.product" access="UPDATE"}
<a title="{intl l='Edit this product'}" href="{url path='/admin/products/update' product_id=$ID page=$page}"><span class="glyphicon glyphicon-edit"></span></a>
{/loop}
{loop type="auth" name="can_delete" role="ADMIN" resource="admin.product" access="DELETE"}
<a class="product-delete" title="{intl l='Delete this product'}" href="#product_delete_dialog" data-id="{$ID}" data-toggle="modal"><span class="glyphicon glyphicon-trash"></span></a>
{/loop}
</div>
</td>
</tr>
{/loop}
</tbody>
<tfoot>
<tr>
<td colspan="100">
{include
file = "includes/pagination.html"
loop_ref = "product_list"
max_page_count = 10
page_url = {url path="/admin/catalog" category_id=$category_id product_order=$product_order}
}
</td>
</tr>
</tfoot>
{/ifloop}
{elseloop rel="product_list"}
<thead>
<tr>
<td class="message"><div class="alert alert-info">{intl l="This category doesn't contains any products. To add a new product, <strong>click the + button</strong> above."}</div></td>
</tr>
</thead>
{/elseloop}
</table>
</div>
</div>
</div>
</div>
{else}
<div class="alert alert-info">{intl l="To create a new product, select an existing category, or create a new one."}</div>
{/if}
{hook name="categories.bottom" location="categories_bottom" }
</div>
{hook name="categories.catalog-bottom" location="catalog_bottom" }
</div>
{* -- Adding a new category ------------------------------------------------- *}
{form name="thelia.admin.category.creation"}
{* Capture the dialog body, to pass it to the generic dialog *}
{capture "category_creation_dialog"}
{form_hidden_fields exclude="parent,locale"}
<input type="hidden" {form_field_attributes field='parent' value={$category_id}}>
{* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *}
{render_form_field field="success_url" value={url path='/admin/categories/update' category_id='_ID_'}}
{custom_render_form_field field="title"}
{loop type="lang" name="default-lang" default_only="1"}
<div class="input-group">
<input type="text" {form_field_attributes field="title"}>
<span class="input-group-addon"><img src="{image file="assets/img/flags/$CODE.png"}" alt="{$TITLE}" /></span>
</div>
{* Switch edition to the current locale *}
<input type="hidden" name="edit_language_id" value="{$ID}" />
{render_form_field field="locale" value=$LOCALE}
{/loop}
{/custom_render_form_field}
{form_field field="visible"}
<label class="checkbox">
<input type="checkbox" checked name="{$name}" value="1"> {$label}
</label>
{/form_field}
{hook name="category.create-form" location="category_create_form" }
{/capture}
{include
file = "includes/generic-create-dialog.html"
dialog_id = "category_creation_dialog"
dialog_title = {intl l="Create a new category"}
dialog_body = {$smarty.capture.category_creation_dialog nofilter}
dialog_ok_label = {intl l="Create this category"}
form_action = {url path='/admin/categories/create'}
form_enctype = {form_enctype}
form_error_message = $form_error_message
}
{/form}
{* -- Adding a new product -------------------------------------------------- *}
{form name="thelia.admin.product.creation"}
{* Capture the dialog body, to pass it to the generic dialog *}
{capture "product_creation_dialog"}
{form_hidden_fields}
{* Be sure to get the category_id, even if the form could not be validated *}
<input type="hidden" name="category_id" value="{$category_id}" />
{form_field field='success_url'}
{* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *}
<input type="hidden" name="{$name}" value="{url path='/admin/products/update' product_id='_ID_'}" />
{/form_field}
{form_field field='default_category'}
<input type="hidden" name="{$name}" value="{$category_id}" />
{/form_field}
{form_field field='ref'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
<div class="from-group">
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Reference'}">
</div>
<div class="help-block">{intl l='Enter here the product reference'}</div>
</div>
{/form_field}
{form_field field='title'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label}{if $required} <span class="required">*</span>{/if} : </label>
{loop type="lang" name="default-lang" default_only="1" backend_context="1"}
<div class="input-group">
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Title'}">
<span class="input-group-addon"><img src="{image file="assets/img/flags/$CODE.png"}" alt="{$TITLE}" /></span>
</div>
<div class="help-block">{intl l='Enter here the product name in the default language (%title)' title=$TITLE}</div>
{* Switch edition to the current locale *}
<input type="hidden" name="edit_language_id" value="{$ID}" />
{form_field field='locale'}
<input type="hidden" name="{$name}" value="{$LOCALE}" />
{/form_field}
{/loop}
</div>
{/form_field}
<div class="row">
<div class="col-sm-6">
{form_field field='tax_rule'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
<div class="form-group">
<select id="{$label_attr.for}" required="required" name="{$name}" class="form-control">
<option value="">{intl l="Select a tax tule"}</option>
{loop name="tax" type="tax-rule" backend_context="1"}
<option value="{$ID}" {if $IS_DEFAULT}selected="selected"{/if}>{$TITLE}</option>
{/loop}
</select>
</div>
<div class="help-block">{intl l='Select here the tax applicable to this product'}</div>
</div>
{/form_field}
</div>
<div class="col-sm-6">
{* If there are some templates, display select template field *}
{ifloop rel="product_template"}
{* Get category template *}
{loop type="category" name="new_product_category" visible="*" id=$category_id}
{assign var="product_template" value=$TEMPLATE}
{assign var="parent_category" value=$PARENT}
{/loop}
{* If current category has no template, get a parent's one *}
{if !$product_template}
{while $parent_category != 0 && !$product_template}
{loop type="category" name="parent_category" backend_context=1 visible="*" id=$parent_category}
{$parent_category = $PARENT}
{$product_template = $TEMPLATE}
{/loop}
{* Be sure to prevent infinite loops *}
{elseloop rel="parent_category"}
{$parent_category = 0}
{/elseloop}
{/while}
{/if}
{form_field field='template_id'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
<div class="form-group">
<select id="{$label_attr.for}" name="{$name}" class="form-control">
<option value="">{intl l="Select a template"}</option>
{loop name="product_template" type="product-template"}
<option value="{$ID}" {if $product_template == $ID}selected{/if}>{$NAME}</option>
{/loop}
</select>
</div>
<div class="help-block">{intl l='Select here a template for this product'}</div>
</div>
{/form_field}
{/ifloop}
</div>
</div>
<div class="row">
<div class="col-sm-6">
{form_field field='price'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
{loop type="currency" name="default-currency" default_only="1" backend_context="1"}
<div class="input-group">
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="col-lg-2 form-control automatic_price_field" value="{$value}" title="{$label}" placeholder="{intl l='Product price'}" data-price-type="price-without-tax" data-rel-price="price_with_tax">
<span class="input-group-addon">{$SYMBOL}</span>
</div>
<div class="help-block">{intl l='Enter here the product price in %title' title={$NAME}}</div>
{form_field field='currency'}
<input type="hidden" name="{$name}" value="{$ID}" />
{/form_field}
{/loop}
</div>
{/form_field}
</div>
<div class="col-sm-6">
{form_field field='tax_price'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
{loop type="currency" name="default-currency" default_only="1" backend_context="1"}
<div class="input-group">
<input type="text" id="{$label_attr.for}" name="{$name}" class="col-lg-2 form-control automatic_price_field" value="{$value}" title="{$label}" placeholder="{intl l='Product tax price'}" data-price-type="price-with-tax" data-rel-price="price_without_tax">
<span class="input-group-addon">{$SYMBOL}</span>
</div>
<div class="help-block">{intl l='Enter here the product tax price in %title' title={$NAME}}</div>
{/loop}
</div>
{/form_field}
</div>
</div>
<div class="row">
<div class="col-sm-6">
{form_field field='weight'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label}: </label>
<div class="input-group">
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Product weight'}">
<span class="input-group-addon">{intl l="Kg"}</span>
</div>
<div class="help-block">{intl l='Enter here the product weight, in Kilogrammes'}</div>
</div>
{/form_field}
</div>
<div class="col-sm-6">
{form_field field='quantity'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label}: </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Product stock'}">
<div class="help-block">{intl l='Enter here the product stock'}</div>
</div>
{/form_field}
</div>
</div>
{form_field field='virtual'}
<div class="form-group {if $error}has-error{/if}">
<div class="checkbox">
<label>
<input type="checkbox" id="{$label_attr.for}" name="{$name}" value="1">
{$label}
</label>
</div>
</div>
{/form_field}
{form_field field='visible'}
<div class="form-group {if $error}has-error{/if}">
<div class="checkbox">
<label>
<input type="checkbox" id="{$label_attr.for}" name="{$name}" value="1" checked="checked">
{$label}
</label>
</div>
</div>
{/form_field}
{hook name="product.create-form" location="product_create_form" }
{/capture}
{include
file = "includes/generic-create-dialog.html"
dialog_id = "product_creation_dialog"
dialog_title = {intl l="Create a new product"}
dialog_body = {$smarty.capture.product_creation_dialog nofilter}
dialog_ok_label = {intl l="Create this product"}
form_action = {url path='/admin/products/create'}
form_enctype = {form_enctype}
form_error_message = $form_error_message
}
{/form}
{* -- Delete category confirmation dialog ----------------------------------- *}
{capture "category_delete_dialog"}
<input type="hidden" name="category_id" id="category_delete_id" value="" />
{hook name="category.delete-form" location="category_delete_form" }
{/capture}
{include
file = "includes/generic-confirm-dialog.html"
dialog_id = "category_delete_dialog"
dialog_title = {intl l="Delete category"}
dialog_message = {intl l="Do you really want to delete this category and all its content ?"}
form_action = {token_url path='/admin/categories/delete'}
form_content = {$smarty.capture.category_delete_dialog nofilter}
}
{* -- Delete product confirmation dialog ------------------------------------ *}
{capture "product_delete_dialog"}
<input type="hidden" name="product_id" id="product_delete_id" value="" />
<input type="hidden" name="category_id" value="{$category_id}" />
<input type="hidden" name="page" value="{$page}">
{hook name="product.delete-form" location="product_delete_form" }
{/capture}
{include
file = "includes/generic-confirm-dialog.html"
dialog_id = "product_delete_dialog"
dialog_title = {intl l="Delete product"}
dialog_message = {intl l="Do you really want to delete this product and all it's components (images, documents)?<br>This can't be canceled."}
form_action = {token_url path='/admin/products/delete'}
form_content = {$smarty.capture.product_delete_dialog nofilter}
}
{/block}
{block name="javascript-initialization"}
{javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/jquery.typewatch.js'}
<script src="{$asset_url}"></script>
{/javascripts}
<script>
$(function() {
// Set proper category ID in delete from
$('a.category-delete').click(function(ev) {
$('#category_delete_id').val($(this).data('id'));
});
// Set proper product ID in delete from
$('a.product-delete').click(function(ev) {
$('#product_delete_id').val($(this).data('id'));
});
// JS stuff for creation form
{include
file = "includes/generic-js-dialog.html"
dialog_id = "category_creation_dialog"
form_name = "thelia.admin.category.creation"
}
{include
file = "includes/generic-js-dialog.html"
dialog_id = "product_creation_dialog"
form_name = "thelia.admin.product.creation"
}
{* Toggle object visibility *}
$(".categoryVisibleToggle").on('switch-change', function(event, data) {
$.ajax({
url : "{url path='admin/categories/toggle-online'}",
data : {
category_id : $(this).data('id'),
action : 'visibilityToggle'
}
});
});
$(".productVisibleToggle").on('switch-change', function(event, data) {
$.ajax({
url : "{url path='admin/products/toggle-online'}",
data : {
product_id : $(this).data('id'),
action : 'visibilityToggle'
}
});
});
{* Inline editing of object position using bootstrap-editable *}
$('.categoryPositionChange').editable({
type : 'text',
title : '{intl l="Enter new category position"}',
mode : 'popup',
inputclass : 'input-mini',
placement : 'left',
success : function(response, newValue) {
// The URL template
var url = "{url noamp='1' path='/admin/categories/update-position' category_id='__ID__' position='__POS__'}";
// Perform subtitutions
url = url.replace('__ID__', $(this).data('id'))
.replace('__POS__', newValue);
// Reload the page
location.href = url;
}
});
$('.productPositionChange').editable({
type : 'text',
title : '{intl l="Enter new product position"}',
mode : 'popup',
inputclass : 'input-mini',
placement : 'left',
success : function(response, newValue) {
// The URL template
var url = "{url noamp='1' path='/admin/products/update-position' product_id='__ID__' position='__POS__' category_id=$category_id}";
// Perform subtitutions
url = url.replace('__ID__', $(this).data('id'))
.replace('__POS__', newValue);
// Reload the page
location.href = url;
}
});
{* Change default status *}
$('.change-default').change(function(ev) {
var url = "{url path='/admin/categories/set-default' category_id='__ID__'}";
// Perform ID subtitutions
url = url.replace('__ID__', $(this).val());
// Reload the page
location.href = url;
});
function update_price(price, price_type, dest_field_id) {
var tax_rule_id = $('#tax_rule_field').val();
if (tax_rule_id != "") {
var operation;
if (price_type.indexOf('with-tax') != -1)
operation = 'from_tax';
else if (price_type.indexOf('without-tax') != -1)
operation = 'to_tax';
else
operation = '';
$.ajax({
url : '{url path="/admin/product/calculate-raw-price"}',
data : {
price : price,
action : operation,
tax_rule : tax_rule_id
},
type : 'get',
dataType : 'json',
success : function(json) {
$('#' + dest_field_id).val(json.result);
},
error : function(jqXHR, textStatus, errorThrown) {
alert("{intl l='Failed to get prices. Please try again.'} (" +errorThrown+ ")");
}
});
}
}
// Automatic update of price fields: any change in the taxed (resp. untaxed) price
// will update the untaxed (resp. taxed) one
$('.automatic_price_field').typeWatch({
captureLength: 1,
wait : 300,
callback : function () {
var price = $(this).val();
$(this).val(sanitizeFloat(price));
update_price($(this).val(), $(this).data('price-type'), $(this).data('rel-price'));
}
});
function sanitizeFloat(numVal) {
return numVal.replace(",", ".");
};
});
</script>
{/block}
{block name="javascript-last-call"}
{hook name="categories.js" location="categories-js" }
{/block}