1 | {combine_script id='jquery.dataTables' load='footer' path='themes/default/js/plugins/jquery.dataTables.js'} |
---|
2 | {combine_css path="themes/default/js/plugins/datatables/css/jquery.dataTables.css"} |
---|
3 | {combine_css path=$MPS_PATH|@cat:"admin/template/style.css"} |
---|
4 | {combine_script id='jquery.ui.sortable' load='footer' path='themes/default/js/ui/minified/jquery.ui.sortable.min.js'} |
---|
5 | {combine_script id='jquery.chosen' load='footer' path='themes/default/js/plugins/chosen.jquery.min.js'} |
---|
6 | {combine_css path="themes/default/js/plugins/chosen.css"} |
---|
7 | |
---|
8 | |
---|
9 | {footer_script}{literal} |
---|
10 | (function($) { |
---|
11 | $(document).ready(function(){ |
---|
12 | |
---|
13 | |
---|
14 | var $oTable, |
---|
15 | $nEditing = null, |
---|
16 | $val = $('.val').html(), |
---|
17 | $add_opt = $('#add_option_prod').html(); |
---|
18 | |
---|
19 | $('#product_list input[type=checkbox]').each(function(){ |
---|
20 | $(this).prop('checked', false) |
---|
21 | }); |
---|
22 | |
---|
23 | $('#AddProd').click(function() { |
---|
24 | $('.add_content').css('top','100px') |
---|
25 | $('.Tadd').show(); |
---|
26 | $('#Add_product').fadeIn(); |
---|
27 | $('#showAddProd .infos').hide(); |
---|
28 | $('input[name=product]').focus(); |
---|
29 | return false; |
---|
30 | }); |
---|
31 | |
---|
32 | $('#close_Add_product').click(function() { |
---|
33 | $('#Add_product').fadeOut(function(){ |
---|
34 | $('#add_option_prod').hide(); |
---|
35 | $('.tit').hide(); |
---|
36 | $('#AddProdForm input[type=text]').attr('value',''); |
---|
37 | $('#AddProdForm textarea#noteAdmin').val(''); |
---|
38 | $('li.search-choice').remove(); |
---|
39 | $('select.chzn-select option').each(function(){ |
---|
40 | $(this).removeAttr('selected'); |
---|
41 | }) |
---|
42 | }); |
---|
43 | return false; |
---|
44 | }); |
---|
45 | |
---|
46 | $('#AddProdForm').submit(function(){ |
---|
47 | var $return = true; |
---|
48 | if($.trim($('input#product',this).val()).length==0 || $.trim($('input#price',this).val()).length==0){ |
---|
49 | $return = false; |
---|
50 | $('.errors').show(); |
---|
51 | setTimeout(function(){ |
---|
52 | $('.errors').hide() |
---|
53 | },3000); |
---|
54 | } |
---|
55 | return $return |
---|
56 | }) |
---|
57 | |
---|
58 | $('#permitAction input[type="submit"]').click(function() { |
---|
59 | if (!confirm("{/literal}{'Are you sure?'|translate|escape:javascript}{literal}")) { |
---|
60 | $('#product_list input[type=checkbox]').each(function(){ |
---|
61 | $(this).prop('checked', false); |
---|
62 | delet_button() |
---|
63 | }); |
---|
64 | } else { |
---|
65 | $('#formTab_prod').submit(); |
---|
66 | } |
---|
67 | return false; |
---|
68 | } ); |
---|
69 | |
---|
70 | $oTable = $('#product_list').dataTable({ |
---|
71 | "bAutoWidth": false, |
---|
72 | "bStateSave": true, |
---|
73 | "aoColumns" : [ |
---|
74 | { sWidth: '2%','sClass': 'center', 'bSortable': false}, |
---|
75 | { sWidth: '38%','sClass': 'product_row' }, |
---|
76 | { sWidth: '38%'}, |
---|
77 | { sWidth: '12%', 'bSortable': false, }, |
---|
78 | { sWidth: '8%', }, |
---|
79 | ], |
---|
80 | "oLanguage": { |
---|
81 | "sProcessing": "{/literal}{'Loading...'|translate|escape:'javascript'}{literal}", |
---|
82 | "sSearch": '<span class="icon-search"></span>'+"{/literal}{'Search'|translate|escape:'javascript'}{literal}", |
---|
83 | "sLengthMenu": "{/literal}{'Display _MENU_ records per page'|translate|escape:'javascript'}{literal}", |
---|
84 | "sInfo": "{/literal}{'Showing _START_ to _END_ of _TOTAL_ records'|translate|escape:'javascript'}{literal}", |
---|
85 | "sInfoEmpty": "{/literal}{'Showing 0 to 0 of 0 records'|translate|escape:'javascript'}{literal}", |
---|
86 | "sInfoFiltered": "{/literal}{'(filtered from _MAX_ total records)'|translate|escape:'javascript'}{literal}", |
---|
87 | "sInfoPostFix": "", |
---|
88 | "sLoadingRecords": "{/literal}{'Loading...'|translate|escape:'javascript'}{literal}", |
---|
89 | "sZeroRecords": "{/literal}{'No matching option found'|translate|escape:'javascript'}{literal}", |
---|
90 | "oPaginate": { |
---|
91 | "sFirst": "{/literal}{'First'|translate|escape:'javascript'}{literal}", |
---|
92 | "sPrevious": '← '+"{/literal}{'Previous'|translate|escape:'javascript'}{literal}", |
---|
93 | "sNext": "{/literal}{'Next'|translate|escape:'javascript'}{literal}"+' →', |
---|
94 | "sLast": "{/literal}{'Last'|translate|escape:'javascript'}{literal}", |
---|
95 | }, |
---|
96 | }, |
---|
97 | }); |
---|
98 | |
---|
99 | function _rempform($this){ |
---|
100 | var $nRow = $this.parents('tr')[0], |
---|
101 | $jqInputs = $('input', $nRow), |
---|
102 | $id = $jqInputs[0].value, |
---|
103 | $prod = $('#prodvar').data('product'), |
---|
104 | $product = $prod[$id].product, |
---|
105 | $Nadmin = $prod[$id].noteAdmin, |
---|
106 | $price = $prod[$id].price, |
---|
107 | $option = $prod[$id].option; |
---|
108 | for(key in $option) { |
---|
109 | $('.chzn-select option').each(function(){ |
---|
110 | if($(this).text()==$option[key]){ |
---|
111 | $(this).attr('selected','selected'); |
---|
112 | } |
---|
113 | }); |
---|
114 | } |
---|
115 | $('.chzn-select').trigger("chosen:updated"); |
---|
116 | |
---|
117 | $('input#product_id').attr('value',$id); |
---|
118 | $('input#product').attr('value',$product); |
---|
119 | $('textarea#noteAdmin').val($Nadmin); |
---|
120 | $('input#price').attr('value',$price); |
---|
121 | } |
---|
122 | |
---|
123 | $(document).on('click','#formTab_prod .prodEdit', function () { |
---|
124 | var $this = $(this), |
---|
125 | $pos = $(document).scrollTop(), |
---|
126 | $pos = $pos + 100; |
---|
127 | |
---|
128 | $('.add_content').css('top',$pos) |
---|
129 | $('.Tedit').show(); |
---|
130 | _rempform($this); |
---|
131 | $('#Add_product').fadeIn(); |
---|
132 | |
---|
133 | return false; |
---|
134 | }); |
---|
135 | |
---|
136 | $(document).on('click','#formTab_prod .prodDupli', function () { |
---|
137 | var $this = $(this); |
---|
138 | $pos = $(document).scrollTop(), |
---|
139 | $pos = $pos + 100; |
---|
140 | |
---|
141 | $('.add_content').css('top',$pos) |
---|
142 | $('.Tdupli').show(); |
---|
143 | _rempform($this); |
---|
144 | $('input#product_id').attr('value',''); |
---|
145 | $('#Add_product').fadeIn(); |
---|
146 | |
---|
147 | return false |
---|
148 | }); |
---|
149 | |
---|
150 | $(document).on('click', '#selectAll', function () { |
---|
151 | $('#product_list input[type=checkbox]').prop('checked', true); |
---|
152 | delet_button() |
---|
153 | return false; |
---|
154 | }); |
---|
155 | |
---|
156 | $(document).on('click', '#selectNone', function () { |
---|
157 | $('#product_list input[type=checkbox]').prop('checked', false); |
---|
158 | delet_button() |
---|
159 | return false; |
---|
160 | }); |
---|
161 | |
---|
162 | $(document).on('click', '#selectInvert', function () { |
---|
163 | $('#product_list input[type=checkbox]').each(function(){ |
---|
164 | if($(this).is (':checked')){ |
---|
165 | $(this).prop('checked', false); |
---|
166 | }else{ |
---|
167 | $(this).prop('checked', true); |
---|
168 | } |
---|
169 | delet_button() |
---|
170 | }); |
---|
171 | return false; |
---|
172 | }); |
---|
173 | |
---|
174 | $(document).on('change','#product_list input[type=checkbox]', function () { |
---|
175 | delet_button() |
---|
176 | }); |
---|
177 | |
---|
178 | function delet_button(){ |
---|
179 | if($('#product_list input[type=checkbox]:checked').length > 0){ |
---|
180 | $('#forbidAction').css('display','none'); |
---|
181 | $('#permitAction').css('display','block'); |
---|
182 | }else{ |
---|
183 | $('#forbidAction').css('display','block'); |
---|
184 | $('#permitAction').css('display','none'); |
---|
185 | } |
---|
186 | }; |
---|
187 | |
---|
188 | $("#listOrder").sortable({ |
---|
189 | placeholder: 'highlight', |
---|
190 | update: function() { |
---|
191 | var $order = $("#listOrder").sortable("toArray"); |
---|
192 | $('#newOrder').val($order.join(",")); |
---|
193 | } |
---|
194 | }); |
---|
195 | |
---|
196 | $("#listOrder").disableSelection(); |
---|
197 | |
---|
198 | $('#ChangeOrder').click(function() { |
---|
199 | $("#change_Order").fadeIn( |
---|
200 | ); |
---|
201 | return false; |
---|
202 | }); |
---|
203 | |
---|
204 | $('#close_changeOrder').click(function() { |
---|
205 | $("#change_Order").fadeOut(); |
---|
206 | |
---|
207 | return false; |
---|
208 | }); |
---|
209 | |
---|
210 | $('.chzn-select').chosen({width:"400px"}) |
---|
211 | |
---|
212 | $('.addopt').click(function(){ |
---|
213 | $('#add_option_prod').show(); |
---|
214 | $('#sub_add_product').hide(); |
---|
215 | }); |
---|
216 | |
---|
217 | $(document).on('change','#optType',function(){ |
---|
218 | var $valSel = $('.addopt_table select#optType option:selected').attr('value'); |
---|
219 | if($valSel=="text" || $valSel=="textarea"){ |
---|
220 | $('.valeur').fadeOut('fast'); |
---|
221 | } else { |
---|
222 | $('.valeur').fadeIn('fast') |
---|
223 | } |
---|
224 | }); |
---|
225 | |
---|
226 | $('.addVal').click(function() { |
---|
227 | $('.valeur').append($('<div/>').addClass('val').append($val)); |
---|
228 | ;return false; |
---|
229 | }) |
---|
230 | |
---|
231 | $(document).on('click','.delVal',function(){ |
---|
232 | if (confirm("{/literal}{'Are you sure?'|translate|escape:javascript}{literal}")) { |
---|
233 | var $Nval = $('.addopt_table .valeur input').length; |
---|
234 | if($Nval>1){ |
---|
235 | $(this).parents('div.val').remove(); |
---|
236 | }else{ |
---|
237 | var $val = $(this).parents('div.val'); |
---|
238 | $('input', $val).val('').attr('value',''); |
---|
239 | } |
---|
240 | } |
---|
241 | return false |
---|
242 | }); |
---|
243 | |
---|
244 | $(document).on('submit','#addopt_form',function(){ |
---|
245 | if($.trim($('input#optName',this).val()).length==0){ |
---|
246 | $('.erroropt').show(); |
---|
247 | setTimeout(function(){ |
---|
248 | $('.erroropt').hide() |
---|
249 | },3000); |
---|
250 | }else{ |
---|
251 | var $optecour = $('input#optName').val(); |
---|
252 | if($('.valeur').is(':hidden')){ |
---|
253 | $('.valeur').remove(); |
---|
254 | } |
---|
255 | $('.optadded').show(); |
---|
256 | setTimeout(function(){ |
---|
257 | $('.optadded').hide() |
---|
258 | },3000); |
---|
259 | $.ajax({ |
---|
260 | type:"POST", |
---|
261 | data: $(this).serialize(), |
---|
262 | success: function(html){ |
---|
263 | var $idlo = $(html).find('#idlastopt').text(); |
---|
264 | console.debug($idlo); |
---|
265 | $('#opt select').append($('<option />').attr({'value':$idlo,'selected':'selected'}).text($optecour)); |
---|
266 | $('.chzn-select').trigger("chosen:updated"); |
---|
267 | } |
---|
268 | }); |
---|
269 | $('#sub_add_product').show(); |
---|
270 | $('#add_option_prod input[type=text]').attr('value',''); |
---|
271 | $('.val').remove(); |
---|
272 | $('.valeur').append($('<div/>').addClass('val').append($val)); |
---|
273 | $('select#optType option').each(function(){ |
---|
274 | $(this).removeAttr('selected'); |
---|
275 | }); |
---|
276 | |
---|
277 | $('#add_option_prod').hide().html($add_opt); |
---|
278 | } |
---|
279 | return false |
---|
280 | }) |
---|
281 | |
---|
282 | }); |
---|
283 | })(jQuery); |
---|
284 | {/literal}{/footer_script} |
---|
285 | |
---|
286 | <div id="prodvar" class="titrePage" data-product='{$mps_product|@json_encode}'> |
---|
287 | <h2>{'Products'|@translate}</h2> |
---|
288 | </div> |
---|
289 | <p class="showCreateAlbum" id="showAddProd"> |
---|
290 | <a href="#" id="AddProd" class="icon-plus-circled">{'Add a product'|translate}</a> |
---|
291 | <span class="infos" style="display:none"></span> |
---|
292 | </p> |
---|
293 | |
---|
294 | <div id="Add_product" class="add_wrap" style="display:none"> |
---|
295 | <div class="add_content"> |
---|
296 | <span id="close_Add_product" class="close_box_add"></span> |
---|
297 | <div class="boxtitre"><h1> |
---|
298 | <span class="tit Tadd">{'Add '|translate}</span> |
---|
299 | <span class="tit Tdupli">{'Duplicate '|translate}</span> |
---|
300 | <span class="tit Tedit">{'Edit '|translate}</span> |
---|
301 | <span class="tit Tedit Tdupli">{'the product'|translate}</span> |
---|
302 | <span class="tit Tadd">{'a product'|translate}</span> |
---|
303 | </h1></div> |
---|
304 | <form id="AddProdForm" method="post" name="add_prod" action=""> |
---|
305 | <div style="margin: 0 0 10px 5px"> |
---|
306 | <div class="addprod_table"> |
---|
307 | <div> |
---|
308 | <span>{'Product'|translate}</span> |
---|
309 | <span><input id="product" type="text" name="product" size="100"></span> |
---|
310 | <span><input id="product_id" type="hidden" name="id"></span> |
---|
311 | </div> |
---|
312 | |
---|
313 | <div> |
---|
314 | <span valign="top">{'Note administrator'|translate}</span> |
---|
315 | <span><textarea id="noteAdmin" rows="8" cols="50" name="noteAdmin" maxlength="50"></textarea></span> |
---|
316 | </div> |
---|
317 | <div> |
---|
318 | <span>{'Price'|@translate}</span> |
---|
319 | <span><input id="price" type="text" name="price"> {$mps_conf.currency}</span> |
---|
320 | </div> |
---|
321 | <div id="opt"> |
---|
322 | <span>{'Options'|@translate}</span> |
---|
323 | <span> |
---|
324 | <select data-placeholder="{'select a option'|@translate}" class="chzn-select" multiple style="width:700px;" name="opt[]"> |
---|
325 | {html_options options=$mps_option } |
---|
326 | </select> |
---|
327 | </span> |
---|
328 | <p class="showCreateAlbum" id="showAddProd"> |
---|
329 | <a href="#" class="addopt icon-plus-circled">{'Add a option'|translate}</a><span class="infos optadded" style="display:none">{'option registered'|translate}</span> |
---|
330 | |
---|
331 | </p> |
---|
332 | </div> |
---|
333 | |
---|
334 | </div> |
---|
335 | </div> |
---|
336 | <span class="actionButtons"> |
---|
337 | |
---|
338 | <input type="hidden" name="product_add"> |
---|
339 | <input id="sub_add_product" class="submit" name="product_add" type="submit" value="{'Submit'|@translate}"> |
---|
340 | </span> |
---|
341 | <span class="errors" style="display:none">{'you must enter the product and not the price'|@translate}</span> |
---|
342 | </form> |
---|
343 | |
---|
344 | |
---|
345 | <div id="add_option_prod" style="display:none"> |
---|
346 | <div> |
---|
347 | |
---|
348 | <form id="addopt_form" method="post" name="add_opt" action=""> |
---|
349 | <div style="margin: 0 0 10px 5px" > |
---|
350 | <div class="addopt_table"> |
---|
351 | <div> |
---|
352 | <span>{'Name'|translate}</span> |
---|
353 | <span><input id="optId" type="hidden" name="id"></span> |
---|
354 | <span><input id="optName" type="text" name="name" size="40"></span> |
---|
355 | </div> |
---|
356 | |
---|
357 | <div id="typeOpt"> |
---|
358 | <span valign="top">{'Type of option'|translate}</span> |
---|
359 | <span id="select">{html_options name=type options=$mps_type_opt selected="select" id="optType"}</span> |
---|
360 | </div> |
---|
361 | |
---|
362 | <div> |
---|
363 | <span><label>{'The field is required'|@translate} |
---|
364 | <input id="optRequi" type="checkbox" name="requi" value="1"> |
---|
365 | </label><span> |
---|
366 | </div> |
---|
367 | <div> |
---|
368 | <span>{'Note administrator'|@translate}</span> |
---|
369 | <span><input id="optTitle" type="text" name="title" size="40"></span> |
---|
370 | </div> |
---|
371 | |
---|
372 | <div class="valeur"> |
---|
373 | <div> |
---|
374 | <span>{'Option value'|@translate}</span> |
---|
375 | <span><a class="icon-plus-circled addVal" href="#">{'add value'|@translate}</a></span> |
---|
376 | </div> |
---|
377 | |
---|
378 | <div class="val"> |
---|
379 | <span>{'Value'|@translate}</span> |
---|
380 | <span><input type="text" name="val[]" size="20"></span> |
---|
381 | <span><a class="icon-cancel-circled delVal" href="#">{'delete'|@translate}</a></span> |
---|
382 | </div> |
---|
383 | </div> |
---|
384 | |
---|
385 | </div> |
---|
386 | </div> |
---|
387 | |
---|
388 | <span class="actionButtons"> |
---|
389 | <input name="option_add" type="hidden" value="{'Submit'|@translate}"> |
---|
390 | |
---|
391 | <input id="option_add" class="submit" type="submit" value="{'Submit'|@translate}"> |
---|
392 | </span> |
---|
393 | <span class="errors erroropt" style="display:none">{'you must enter the name of the option'|@translate}</span> |
---|
394 | |
---|
395 | </form> |
---|
396 | </div> |
---|
397 | </div> |
---|
398 | |
---|
399 | </div> |
---|
400 | </div> |
---|
401 | |
---|
402 | <div id=prod_table> |
---|
403 | <form id="formTab_prod" method="post" name="add_prod" action=""> |
---|
404 | <table id="product_list"> |
---|
405 | <thead> |
---|
406 | <tr> |
---|
407 | <th></th> |
---|
408 | <th>{'Product'|@translate}</th> |
---|
409 | <th>{'Note administrator'|@translate}</th> |
---|
410 | <th>{'Options'|@translate}</th> |
---|
411 | <th>{'Price'|@translate}</th> |
---|
412 | |
---|
413 | </tr> |
---|
414 | </thead> |
---|
415 | <tbody> |
---|
416 | {foreach from=$mps_product item=product name=product} |
---|
417 | <tr class="{if $smarty.foreach.product.index is odd}row1{else}row2{/if}"> |
---|
418 | <td><input type="checkbox" name="check[]" value={$product.id}></td> |
---|
419 | <td><span>{$product.product}</span> <a title="{'edit'|translate|escape:'javascript'}" class="prodEdit icon-pencil tabact">{'edit'|translate}</a> <a title="{'duplicate'|translate|escape:'javascript'}" class="prodDupli icon-pencil tabact">{'duplicate'|translate}</a></td> |
---|
420 | <td>{$product.noteAdmin} </td> |
---|
421 | <td>{foreach from=$product.option item=option name=option}{$option}/{/foreach}</td> |
---|
422 | <td>{$product.price} {$mps_conf.currency}</td> |
---|
423 | </tr> |
---|
424 | |
---|
425 | |
---|
426 | {/foreach} |
---|
427 | </tbody> |
---|
428 | </table> |
---|
429 | |
---|
430 | |
---|
431 | <div style="clear:right"></div> |
---|
432 | |
---|
433 | <p class="checkActions"> |
---|
434 | {'Select:'|@translate} |
---|
435 | <a href="#" id="selectAll">{'All'|@translate}</a>, |
---|
436 | <a href="#" id="selectNone">{'None'|@translate}</a>, |
---|
437 | <a href="#" id="selectInvert">{'Invert'|@translate}</a> |
---|
438 | </p> |
---|
439 | |
---|
440 | </div> |
---|
441 | |
---|
442 | <div id="forbidAction">{'No product selected'|@translate}</div> |
---|
443 | <div id="permitAction" style="display:none"> |
---|
444 | <input type="submit" name="delete" value="{'Delete'|@translate}"> |
---|
445 | <br></br> |
---|
446 | </div> |
---|
447 | </form> |
---|
448 | |
---|
449 | <p class="showCreateAlbum" id="showChangeOrder"> |
---|
450 | <a href="#" id="ChangeOrder" class="icon-plus-circled">{'Change the display order of products in the form'|translate}</a> |
---|
451 | </p> |
---|
452 | |
---|
453 | |
---|
454 | <div id="change_Order" class="add_wrap" style="display:none"> |
---|
455 | <div class="add_content"> |
---|
456 | <span id="close_changeOrder" class="close_box_add"></span> |
---|
457 | <div class="boxtitre"><h1>{'Change the display order of products in the form'|translate}</h1> |
---|
458 | <p> {'drag / drop to change the order'|translate}</p></div> |
---|
459 | <div id="form_order"> |
---|
460 | <form id="changeOrder" method="post" name="add_prod" action=""> |
---|
461 | <fieldset> |
---|
462 | |
---|
463 | <ul id="listOrder"> |
---|
464 | {foreach from=$mps_product item=product name=product} |
---|
465 | <li id="{$product.id}">{$product.product} -> {$product.noteAdmin} -> {$product.price} {$mps_conf.currency}</li> |
---|
466 | {/foreach} |
---|
467 | <br /> |
---|
468 | </fieldset> |
---|
469 | <input id="newOrder" type="hidden" value="" name="newOrder"> |
---|
470 | <input id="sortable" type="submit" name="submit" value="{'Submit'|@translate}"> |
---|
471 | |
---|
472 | </form> |
---|
473 | </div> |
---|
474 | </div> |
---|
475 | </div> |
---|
476 | |
---|
477 | |
---|
478 | |
---|
479 | |
---|
480 | |
---|
481 | |
---|
482 | |
---|
483 | |
---|
484 | |
---|