PageRenderTime 55ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

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

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