PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/adminps/themes/default/template/controllers/groups/helpers/form/form.tpl

https://bitbucket.org/enurkov/prestashop
Smarty Template | 273 lines | 232 code | 17 blank | 24 comment | 15 complexity | a4e3df1ca2950238cdb99a2b6991c2e2 MD5 | raw file
  1. {*
  2. * 2007-2012 PrestaShop
  3. *
  4. * NOTICE OF LICENSE
  5. *
  6. * This source file is subject to the Academic Free License (AFL 3.0)
  7. * that is bundled with this package in the file LICENSE.txt.
  8. * It is also available through the world-wide-web at this URL:
  9. * http://opensource.org/licenses/afl-3.0.php
  10. * If you did not receive a copy of the license and are unable to
  11. * obtain it through the world-wide-web, please send an email
  12. * to license@prestashop.com so we can send you a copy immediately.
  13. *
  14. * DISCLAIMER
  15. *
  16. * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
  17. * versions in the future. If you wish to customize PrestaShop for your
  18. * needs please refer to http://www.prestashop.com for more information.
  19. *
  20. * @author PrestaShop SA <contact@prestashop.com>
  21. * @copyright 2007-2012 PrestaShop SA
  22. * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
  23. * International Registered Trademark & Property of PrestaShop SA
  24. *}
  25. {extends file="helpers/form/form.tpl"}
  26. {block name="label"}
  27. {if $input['type'] == 'modules'}
  28. <div style="{if !$form_id}display:none{/if}">
  29. <div class="separation"></div>
  30. <label>{l s='Module restrictions:'}</label>
  31. </div>
  32. {elseif $input['type'] == 'group_discount_category'}
  33. <div style="{if !$form_id}display:none{/if}">
  34. <div class="separation"></div>
  35. <label>{$input.label} </label>
  36. </div>
  37. {else}
  38. <label>{$input.label} </label>
  39. {/if}
  40. {/block}
  41. {block name="field"}
  42. {if $input['type'] == 'group_discount_category'}
  43. <div style="{if !$form_id}display:none{/if}">
  44. <script type="text/javascript">
  45. $(document).ready(function() {
  46. $("#group_discount_category").fancybox({
  47. onStart: function () {
  48. $('#group_discount_category_fancybox').show();
  49. initFancyBox();
  50. },
  51. onClosed: function () {
  52. $('#group_discount_category_fancybox').hide();
  53. }
  54. });
  55. });
  56. function deleteCategoryReduction(id_category)
  57. {
  58. $('#group_discount_category_table tr#'+id_category).fadeOut('slow', function () {
  59. $(this).remove();
  60. });
  61. }
  62. function toogleCheck(elt)
  63. {
  64. if ($(elt).hasClass('select_all'))
  65. {
  66. $(elt).addClass('unselect_all').removeClass('select_all');
  67. $('ul#sortable_module_'+$(elt).attr('id')).find('input[type="checkbox"]').removeAttr('checked');
  68. $(elt).html('{l s='Select all'}');
  69. }
  70. else
  71. {
  72. $(elt).addClass('select_all').removeClass('unselect_all');
  73. $('ul#sortable_module_'+$(elt).attr('id')).find('input[type="checkbox"]').attr('checked', true);
  74. $(elt).html('{l s='Unselect all'}');
  75. }
  76. }
  77. function unauthorizeChecked()
  78. {
  79. $('ul#sortable_module_unauthorize_list').find('input[type="checkbox"]:checked').each( function () {
  80. $('ul#sortable_module_authorize_list').prepend($(this).parent());
  81. $(this).removeAttr('checked');
  82. $(this).parent().children('input["type=hidden"]').attr('name', 'modulesBoxAuth[]');
  83. });
  84. }
  85. function authorizeChecked()
  86. {
  87. $('ul#sortable_module_authorize_list').find('input[type="checkbox"]:checked').each( function () {
  88. $('ul#sortable_module_unauthorize_list').prepend($(this).parent());
  89. $(this).removeAttr('checked');
  90. $(this).parent().children('input["type=hidden"]').attr('name', 'modulesBoxUnauth[]');
  91. });
  92. }
  93. function addCategoryReduction()
  94. {
  95. exist = false;
  96. $('.category_reduction').each( function () {
  97. if ($(this).attr('name') == 'category_reduction['+$('[name="id_category"]:checked').val()+']')
  98. {
  99. exist = true;
  100. jAlert('{l s='This category already exist for this group'}');
  101. return false;
  102. }
  103. });
  104. if (exist)
  105. return;
  106. $.ajax({
  107. type:"POST",
  108. url: "ajax-tab.php",
  109. async: true,
  110. dataType: "json",
  111. data : {
  112. ajax: "1",
  113. token: "{getAdminToken tab='AdminGroups'}",
  114. controller: "AdminGroups",
  115. action: "addCategoryReduction",
  116. category_reduction: $('#category_reduction_fancybox').val() ,
  117. id_category: $('[name="id_category"]:checked').val()
  118. },
  119. success : function(jsonData)
  120. {
  121. if (jsonData.hasError)
  122. {
  123. var errors = '';
  124. for(error in jsonData.errors)
  125. //IE6 bug fix
  126. if(error != 'indexOf')
  127. errors += jsonData.errors[error] + "\n";
  128. jAlert(errors);
  129. }
  130. else
  131. {
  132. $('#group_discount_category_table').append('<tr class="alt_row" id="'+jsonData.id_category+'"><td>'+jsonData.catPath+'</td><td>{l s='Discount:'}'+jsonData.discount+'{l s='%'}</td><td><a href="#" onclick="deleteCategoryReduction('+jsonData.id_category+');"><img src="../img/admin/delete.gif"></a></td></tr>');
  133. var input_hidden = document.createElement("input");
  134. input_hidden.setAttribute('type', 'hidden');
  135. input_hidden.setAttribute('value', jsonData.discount);
  136. input_hidden.setAttribute('name', 'category_reduction['+jsonData.id_category+']');
  137. input_hidden.setAttribute('class', 'category_reduction');
  138. $('#group_discount_category_table tr#'+jsonData.id_category+' > td:last').append(input_hidden);
  139. $.fancybox.close();
  140. }
  141. }
  142. });
  143. return false;
  144. }
  145. function initFancyBox()
  146. {
  147. $('[name="id_category"]:checked').removeAttr('checked');
  148. collapseAllCategories();
  149. $('#category_reduction_fancybox').val('0.00');
  150. }
  151. </script>
  152. <div class="margin-form">
  153. <a class="button" href="#group_discount_category_fancybox" id="group_discount_category">{l s='Add a category discount'}</a>
  154. <table cellspacing="0" cellpadding="0" class="table" style="margin-top:10px" id="group_discount_category_table">
  155. {foreach $input['values'] key=key item=category }
  156. <tr class="alt_row" id="{$category.id_category}">
  157. <td>{$category.path}</td>
  158. <td>{l s='Discount: %d%%' sprintf=$category.reduction}</td>
  159. <td>
  160. <a href="#" onclick="deleteCategoryReduction({$category.id_category});"><img src="../img/admin/delete.gif"></a>
  161. <input type="hidden" class="category_reduction" name="category_reduction[{$category.id_category}]" value="{$category.reduction}">
  162. </td>
  163. </tr>
  164. {/foreach}
  165. </table>
  166. <div style="display:none" id="group_discount_category_fancybox">
  167. <fieldset style="text-align:left"><legend><img src="../img/admin/tab-groups.gif" />{l s='New group category discount'}</legend>
  168. <div class="hintGroup" style="font-size: 13px;">
  169. {l s='Caution: the discount applied to a category does not stack with the overall reduction but instead replaces it.'}
  170. </div>
  171. {$categoryTreeView}
  172. <div class="warn">{l s='Only products that have this category as the default category will be affected'}</div>
  173. <div class="clear">&nbsp;</div>
  174. <label>{l s='Discount (%):'}</label>
  175. <input type="text" name="category_reduction_fancybox" id="category_reduction_fancybox" value="0.00" size="33">
  176. <div class="clear">&nbsp;</div>
  177. <button onclick="addCategoryReduction();" class="button">{l s='add'}</button>
  178. </fieldset>
  179. </div>
  180. </div>
  181. {elseif $input['type'] == 'modules'}
  182. <div style="{if !$form_id}display:none{/if}">
  183. <div class="margin-form">
  184. <script type="text/javascript">
  185. $(document).ready(function() {
  186. $( "#sortable_module_authorize_list, #sortable_module_unauthorize_list" ).sortable({
  187. connectWith: ".connectedSortable",
  188. stop: function(event, ui)
  189. {
  190. if ($(event.toElement).parent('ul').attr('id') == 'sortable_module_authorize_list')
  191. $(event.toElement).children('input["type=hidden"]').attr('name', 'modulesBoxAuth[]');
  192. else
  193. $(event.toElement).children('input["type=hidden"]').attr('name', 'modulesBoxUnauth[]');
  194. }
  195. }).disableSelection();
  196. });
  197. </script>
  198. <table cellspacing="0" cellpadding="0" class="table" style="width:600px">
  199. <thead>
  200. <tr>
  201. <th style="padding-left:10px;">
  202. {$input['label']['auth_modules']}
  203. </th>
  204. <th style="padding-left:10px;">
  205. {$input['label']['unauth_modules']}
  206. </th>
  207. </tr>
  208. </thead>
  209. <tbody>
  210. <tr>
  211. <td style="width:300px">
  212. <ul id="sortable_module_authorize_list" class="connectedSortable" style="height:300px;overflow:auto">
  213. <li></li>
  214. {foreach $input['values']['auth_modules'] key=key item=module }
  215. <li class="module_list" id="module_{$module->id}">
  216. <input type="checkbox" style="margin-right:5px">
  217. <img src="../modules/{$module->name}/logo.gif">
  218. {$module->displayName}
  219. <input type="hidden" name="modulesBoxAuth[]" value="{$module->id}">
  220. </li>
  221. {/foreach}
  222. </ul>
  223. </td>
  224. <td style="width:300px">
  225. <ul id="sortable_module_unauthorize_list" class="connectedSortable" style="height:300px;overflow:auto">
  226. <li></li>
  227. {foreach $input['values']['unauth_modules'] key=key item=module }
  228. <li class="module_list" id="module_{$module->id}">
  229. <input type="checkbox" style="margin-right:5px">
  230. <img src="../modules/{$module->name}/logo.gif">
  231. {$module->displayName}
  232. <input type="hidden" name="modulesBoxUnauth[]" value="{$module->id}">
  233. </li>
  234. {/foreach}
  235. </ul>
  236. </td>
  237. </tr>
  238. </tbody>
  239. <tfoot>
  240. <tr>
  241. <td style="text-align:center">
  242. <button style="width:100%;margin-top:5px" id="authorize_list" onclick="toogleCheck(this);return false;" class="button">{l s='Select all'}</button>
  243. <button style="width:100%;margin-top:5px;margin-bottom:5px" onclick="authorizeChecked();return false;" class="button">{l s='Unauthorize >>'}</button>
  244. </td>
  245. <td style="text-align:center">
  246. <button style="width:100%;margin-top:5px"id="unauthorize_list" onclick="toogleCheck(this);return false;" class="button">{l s='Select all'}</button>
  247. <button style="width:100%;margin-top:5px;margin-bottom:5px" onclick="unauthorizeChecked();return false;" class="button">{l s='<< Authorize'}</button>
  248. </td>
  249. </tr>
  250. </tfoot>
  251. </table>
  252. </div>
  253. {else}
  254. {$smarty.block.parent}
  255. {/if}
  256. {/block}