PageRenderTime 36ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/admin228c4ef56/themes/default/template/controllers/access/helpers/form/form.tpl

https://gitlab.com/staging06/myproject
Smarty Template | 365 lines | 325 code | 16 blank | 24 comment | 46 complexity | e710e910c52ab3bb776445cfe2aa849c MD5 | raw file
  1. {*
  2. * 2007-2015 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-2015 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. <script type="text/javascript">
  26. $(document).ready(function() {
  27. var id_tab_parentmodule = {$id_tab_parentmodule|intval};
  28. var id_tab_module = {$id_tab_module|intval};
  29. $('tr.child-'+id_tab_parentmodule+' > td > input.view.'+id_tab_module).change( function () {
  30. if (!$(this).prop('checked'))
  31. {
  32. $('#table_module_2 thead th:eq(1) input').trigger('click');
  33. if ($('#table_module_2 thead th:eq(1) input').prop('checked'))
  34. $('#table_module_2 thead th:eq(1) input').trigger('click');
  35. }
  36. });
  37. $('tr.child-'+id_tab_parentmodule+' > td > input.edit.'+id_tab_module).change( function () {
  38. if (!$(this).prop('checked'))
  39. {
  40. $('#table_module_2 thead th:eq(2) input').trigger('click');
  41. if ($('#table_module_2 thead th:eq(2) input').prop('checked'))
  42. $('#table_module_2 thead th:eq(2) input').trigger('click');
  43. }
  44. });
  45. $('div.productTabs').find('a').each(function() {
  46. $(this).attr('href', '#');
  47. });
  48. $('div.productTabs a').click(function() {
  49. var id = $(this).attr('id');
  50. $('.nav-profile').removeClass('selected');
  51. $(this).addClass('selected active');
  52. $(this).siblings().removeClass('active');
  53. $('.tab-profile').hide()
  54. $('.'+id).show();
  55. });
  56. $('.ajaxPower').change(function(){
  57. var tout = $(this).data('rel').split('||');
  58. var id_tab = tout[0];
  59. var id_profile = tout[1];
  60. var perm = tout[2];
  61. var enabled = $(this).is(':checked')? 1 : 0;
  62. var tabsize = tout[3];
  63. var tabnumber = tout[4];
  64. var table = 'table#table_'+id_profile;
  65. if (perm == 'all' && $(this).parent().parent().hasClass('parent'))
  66. {
  67. if (enabled)
  68. $(this).parent().parent().parent().find('.child-'+id_tab+' input[type=checkbox]').attr('checked', 'checked');
  69. else
  70. $(this).parent().parent().parent().find('.child-'+id_tab+' input[type=checkbox]').removeAttr('checked');
  71. $.ajax({
  72. url: "{$link->getAdminLink('AdminAccess')|addslashes}",
  73. cache: false,
  74. data : {
  75. ajaxMode : '1',
  76. id_tab: id_tab,
  77. id_profile: id_profile,
  78. perm: perm,
  79. enabled: enabled,
  80. submitAddAccess: '1',
  81. addFromParent: '1',
  82. action: 'updateAccess',
  83. ajax: '1',
  84. token: '{getAdminToken tab='AdminAccess'}'
  85. },
  86. success : function(res,textStatus,jqXHR)
  87. {
  88. try {
  89. if (res == 'ok')
  90. showSuccessMessage("{l s='Update successful'}");
  91. else
  92. showErrorMessage("{l s='Update error'}");
  93. } catch(e) {
  94. jAlert('Technical error');
  95. }
  96. }
  97. });
  98. }
  99. perfect_access_js_gestion(this, perm, id_tab, tabsize, tabnumber, table);
  100. $.ajax({
  101. url: "{$link->getAdminLink('AdminAccess')|addslashes}",
  102. cache: false,
  103. data : {
  104. ajaxMode : '1',
  105. id_tab: id_tab,
  106. id_profile: id_profile,
  107. perm: perm,
  108. enabled: enabled,
  109. submitAddAccess: '1',
  110. action: 'updateAccess',
  111. ajax: '1',
  112. token: '{getAdminToken tab='AdminAccess'}'
  113. },
  114. success : function(res,textStatus,jqXHR)
  115. {
  116. try
  117. {
  118. if (res == 'ok')
  119. showSuccessMessage("{l s='Update successful'}");
  120. else
  121. showErrorMessage("{l s='Update error'}");
  122. }
  123. catch(e)
  124. {
  125. jAlert('Technical error');
  126. }
  127. }
  128. });
  129. });
  130. $(".changeModuleAccess").change(function(){
  131. var tout = $(this).data('rel').split('||');
  132. var id_module = tout[0];
  133. var perm = tout[1];
  134. var id_profile = tout[2];
  135. var enabled = $(this).is(':checked') ? 1 : 0;
  136. var enabled_attr = $(this).is(':checked') ? true : false;
  137. var table = 'table#table_module_'+id_profile;
  138. if (id_module == -1)
  139. $(table+' .ajax-ma-'+perm).each(function(key, value) {
  140. $(this).attr("checked", enabled_attr);
  141. });
  142. else if (!enabled)
  143. $(table+' #ajax-ma-'+perm+'-master').each(function(key, value) {
  144. $(this).attr("checked", enabled_attr);
  145. });
  146. $.ajax({
  147. url: "{$link->getAdminLink('AdminAccess')|addslashes}",
  148. cache: false,
  149. data : {
  150. ajaxMode: '1',
  151. id_module: id_module,
  152. perm: perm,
  153. enabled: enabled,
  154. id_profile: id_profile,
  155. changeModuleAccess: '1',
  156. action: 'updateModuleAccess',
  157. ajax: '1',
  158. token: '{getAdminToken tab='AdminAccess'}'
  159. },
  160. success : function(res,textStatus,jqXHR)
  161. {
  162. try
  163. {
  164. if (res == 'ok')
  165. showSuccessMessage("{l s='Update successful'}");
  166. else
  167. showErrorMessage("{l s='Update error'}");
  168. }
  169. catch(e)
  170. {
  171. jAlert('Technical error');
  172. }
  173. }
  174. });
  175. });
  176. });
  177. </script>
  178. {if $show_toolbar}
  179. {include file="toolbar.tpl" toolbar_btn=$toolbar_btn toolbar_scroll=$toolbar_scroll title=$title}
  180. <div class="leadin">{block name="leadin"}{/block}</div>
  181. {/if}
  182. <div class="row">
  183. <div class="productTabs col-lg-2">
  184. <div class="tab list-group">
  185. {foreach $profiles as $profile}
  186. <a class="list-group-item nav-profile {if $profile.id_profile == $current_profile}active{/if}" id="profile-{$profile.id_profile}" href="{$current|escape:'html':'UTF-8'}&amp;token={$token|escape:'html':'UTF-8'}&amp;id_profile={$profile.id_profile}">{$profile.name}</a>
  187. {/foreach}
  188. </div>
  189. </div>
  190. <form id="{$table}_form" class="defaultForm form-horizontal col-lg-10" action="{$current|escape:'html':'UTF-8'}&amp;{$submit_action}=1&amp;token={$token|escape:'html':'UTF-8'}" method="post" enctype="multipart/form-data">
  191. {if $form_id}
  192. <input type="hidden" name="{$identifier}" id="{$identifier}" value="{$form_id}" />
  193. {/if}
  194. {assign var=tabsize value=count($tabs)}
  195. {foreach $tabs AS $tab}
  196. {if $tab.id_tab > $tabsize}
  197. {assign var=tabsize value=$tab.id_tab}
  198. {/if}
  199. {/foreach}
  200. {foreach $profiles as $profile}
  201. <div class="profile-{$profile.id_profile} tab-profile" style="display:{if $profile.id_profile != $current_profile}none{/if}">
  202. <div class="row">
  203. {if $profile.id_profile != $admin_profile}
  204. <div class="col-lg-6">
  205. <div class="panel">
  206. <h3>{l s='Menu'}</h3>
  207. <table class="table" id="table_{$profile.id_profile}">
  208. <thead>
  209. <tr>
  210. <th></th>
  211. <th>
  212. <input type="checkbox" name="1" class="viewall ajaxPower"{if $access_edit == 1} data-rel="-1||{$profile.id_profile}||view||{$tabsize}||{count($tabs)}"{else} disabled="disabled"{/if}/>
  213. {l s='View'}
  214. </th>
  215. <th>
  216. <input type="checkbox" name="1" class="addall ajaxPower"{if $access_edit == 1} data-rel="-1||{$profile.id_profile}||add||{$tabsize}||{count($tabs)}"{else} disabled="disabled"{/if}/>
  217. {l s='Add'}
  218. </th>
  219. <th>
  220. <input type="checkbox" name="1" class="editall ajaxPower"{if $access_edit == 1} data-rel="-1||{$profile.id_profile}||edit||{$tabsize}||{count($tabs)}"{else} disabled="disabled"{/if}/>
  221. {l s='Edit'}
  222. </th>
  223. <th>
  224. <input type="checkbox" name="1" class="deleteall ajaxPower"{if $access_edit == 1} data-rel="-1||{$profile.id_profile}||delete||{$tabsize}||{count($tabs)}"{else} disabled="disabled"{/if}/>
  225. {l s='Delete'}
  226. </th>
  227. <th>
  228. <input type="checkbox" name="1" class="allall ajaxPower"{if $access_edit == 1} data-rel="-1||{$profile.id_profile}||all||{$tabsize}||{count($tabs)}"{else} disabled="disabled"{/if}/>
  229. {l s='All'}
  230. </th>
  231. </tr>
  232. </thead>
  233. <tbody>
  234. {if !count($tabs)}
  235. <tr>
  236. <td colspan="6">{l s='No menu'}</td>
  237. </tr>
  238. {else}
  239. {foreach $tabs AS $tab}
  240. {assign var=access value=$accesses[$profile.id_profile]}
  241. {if !$tab.id_parent OR $tab.id_parent == -1}
  242. {assign var=is_child value=false}
  243. {assign var=result_accesses value=0}
  244. <tr{if !$is_child} class="parent"{/if}>
  245. <td{if !$is_child} class="bold"{/if}>{if $is_child} &raquo; {/if}<strong>{$tab.name}</strong></td>
  246. {foreach $perms as $perm}
  247. {if $access_edit == 1}
  248. <td>
  249. <input type="checkbox" data-rel="{$access[$tab.id_tab]['id_tab']}||{$profile.id_profile}||{$perm}||{$tabsize}||{count($tabs)}" class="ajaxPower {$perm} {$access[$tab.id_tab]['id_tab']}"{if $access[$tab.id_tab][$perm] == 1} checked="checked"{/if}/>
  250. </td>
  251. {else}
  252. <td>
  253. <input type="checkbox" disabled="disabled"{if $access[$tab.id_tab][$perm] == 1} checked="checked"{/if}/>
  254. </td>
  255. {/if}
  256. {assign var=result_accesses value=$result_accesses + $access[$tab.id_tab][$perm]}
  257. {/foreach}
  258. <td>
  259. <input type="checkbox"{if $access_edit == 1} data-rel="{$access[$tab.id_tab]['id_tab']}||{$profile.id_profile}||all||{$tabsize}||{count($tabs)}" class="ajaxPower all {$access[$tab.id_tab]['id_tab']}"{else} class="all {$access[$tab.id_tab]['id_tab']}" disabled="disabled"{/if}{if $result_accesses == 4} checked="checked"{/if}/>
  260. </td>
  261. </tr>
  262. {foreach $tabs AS $child}
  263. {if $child.id_parent === $tab.id_tab}
  264. {if isset($access[$child.id_tab])}
  265. {assign var=is_child value=true}
  266. {assign var=result_accesses value=0}
  267. <tr class="child-{$child.id_parent}">
  268. <td{if !$is_child} class="bold"{/if}>{if $is_child} &raquo; {/if}{$child.name}</td>
  269. {foreach $perms as $perm}
  270. {if $access_edit == 1}
  271. <td>
  272. <input type="checkbox" data-rel="{$access[$child.id_tab]['id_tab']}||{$profile.id_profile}||{$perm}||{$tabsize}||{count($tabs)}" class="ajaxPower {$perm} {$access[$child.id_tab]['id_tab']}"{if $access[$child.id_tab][$perm] == 1} checked="checked"{/if}/>
  273. </td>
  274. {else}
  275. <td>
  276. <input type="checkbox" disabled="disabled"{if $access[$child.id_tab][$perm] == 1} checked="checked"{/if}/>
  277. </td>
  278. {/if}
  279. {assign var=result_accesses value=$result_accesses + $access[$child.id_tab][$perm]}
  280. {/foreach}
  281. <td>
  282. <input type="checkbox"{if $access_edit == 1} data-rel="{$access[$child.id_tab]['id_tab']}||{$profile.id_profile}||all||{$tabsize}||{count($tabs)}" class="ajaxPower all {$access[$child.id_tab]['id_tab']}"{else} class="all {$access[$child.id_tab]['id_tab']}" disabled="disabled"{/if}{if $result_accesses == 4} checked="checked"{/if}/>
  283. </td>
  284. </tr>
  285. {/if}
  286. {/if}
  287. {/foreach}
  288. {/if}
  289. {/foreach}
  290. {/if}
  291. </tbody>
  292. </table>
  293. </div>
  294. </div>
  295. <div class="col-lg-6">
  296. <div class="panel">
  297. <h3>{l s='Modules'}</h3>
  298. <table class="table" id="table_module_{$profile.id_profile}">
  299. <thead>
  300. <tr>
  301. <th></th>
  302. <th>
  303. <input type="checkbox"{if $access_edit == 1} class="changeModuleAccess" data-rel="-1||view||{$profile.id_profile}"{else} disabled="disabled"{/if}/> {l s='View'}
  304. </th>
  305. <th>
  306. <input type="checkbox"{if $access_edit == 1} class="changeModuleAccess" data-rel="-1||configure||{$profile.id_profile}"{else} disabled="disabled"{/if}/> {l s='Configure'}
  307. </th>
  308. <th>
  309. <input type="checkbox"{if $access_edit == 1} class="changeModuleAccess" data-rel="-1||uninstall||{$profile.id_profile}"{else} disabled="disabled"{/if}/> {l s='Uninstall'}
  310. </th>
  311. </tr>
  312. </thead>
  313. <tbody>
  314. {if !count($modules)}
  315. <tr>
  316. <td colspan="3">{l s='No modules are installed'}</td>
  317. </tr>
  318. {else}
  319. {foreach $modules[$profile.id_profile] AS $module}
  320. <tr>
  321. <td>&raquo; {$module.name}</td>
  322. <td>
  323. <input type="checkbox" value="1"{if $module.view == true} checked="checked"{/if}{if $access_edit == 1} class="ajax-ma-view changeModuleAccess" data-rel="{$module.id_module}||view||{$profile.id_profile}"{else} class="ajax-ma-view" disabled="disabled"{/if}/>
  324. </td>
  325. <td>
  326. <input type="checkbox" value="1"{if $module.configure == true} checked="checked"{/if}{if $access_edit == 1} class="ajax-ma-configure changeModuleAccess" data-rel="{$module.id_module}||configure||{$profile.id_profile}"{else} class="ajax-ma-configure" disabled="disabled"{/if}/>
  327. </td>
  328. <td>
  329. <input type="checkbox" value="1"{if $module.uninstall == true} checked="checked"{/if}{if $access_edit == 1} class="ajax-ma-uninstall changeModuleAccess" data-rel="{$module.id_module}||uninstall||{$profile.id_profile}"{else} class="ajax-ma-uninstall" disabled="disabled"{/if}/>
  330. </td>
  331. </tr>
  332. {/foreach}
  333. {/if}
  334. </tbody>
  335. </table>
  336. </div>
  337. </div>
  338. {else}
  339. <div class="col-lg-12">
  340. <div class="panel">
  341. {l s='Administrator permissions cannot be modified.'}
  342. </div>
  343. </div>
  344. {/if}
  345. </div>
  346. </div>
  347. {/foreach}
  348. </form>
  349. </div>