Advertisement
Guest User

Untitled

a guest
Mar 24th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.18 KB | None | 0 0
  1. <div class="modal-dialog modal-lg" id="myModal" tabindex="-1" role="dialog">
  2. <div class="modal-content">
  3. <div class="modal-header">
  4. <strong><?php echo $this->lang->line($controller_name . '_new'); ?></strong>
  5. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  6. </div>
  7. <div class="modal-body">
  8. <div class="row">
  9. <?php echo form_open('employees/save/'.$person_info->person_id,array('id'=>'employee_form','class' => 'form-horizontal')); ?>
  10. <div class="col-sm-6">
  11. <div id="required_fields_message"><?php echo $this->lang->line('common_fields_required_message'); ?></div>
  12. <ul id="error_message_box" class="error_message_box"></ul>
  13. <div class="well" id="employee_basic_info">
  14. <legend><?php echo $this->lang->line("employees_basic_information"); ?></legend>
  15. <?php $this->load->view("people/form_basic_info"); ?>
  16. </div>
  17. </div>
  18. <div class="col-sm-6">
  19. <div class="well" id="employee_login_info">
  20. <legend><?php echo $this->lang->line("employees_login_info"); ?></legend>
  21. <div class="form-group">
  22. <?php echo form_label($this->lang->line('employees_username').':', 'username',array('class'=>'required control-label col-xs-5')); ?>
  23. <div class="col-xs-6">
  24. <?php echo form_input(array(
  25. 'name'=>'username',
  26. 'id'=>'username',
  27. 'readonly'=>'readonly',
  28. 'class'=>'form-control',
  29. 'value'=>$person_info->username));?>
  30. </div>
  31. </div>
  32.  
  33. <?php
  34. $password_label_attributes = $person_info->person_id == "" ? array('class'=>'required control-label col-xs-5'):array('class'=>'control-label col-xs-5');
  35. ?>
  36.  
  37. <div class="form-group">
  38. <?php echo form_label($this->lang->line('employees_password').':', 'password',$password_label_attributes); ?>
  39. <div class="col-xs-6">
  40. <?php echo form_password(array(
  41. 'name'=>'password',
  42. 'id'=>'password',
  43. 'class'=>'form-control'
  44. ));?>
  45. </div>
  46. </div>
  47.  
  48. <div class="form-group">
  49. <?php echo form_label($this->lang->line('employees_repeat_password').':', 'repeat_password',$password_label_attributes); ?>
  50. <div class="col-xs-6">
  51. <?php echo form_password(array(
  52. 'name'=>'repeat_password',
  53. 'id'=>'repeat_password',
  54. 'class'=>'form-control'
  55. ));?>
  56. </div>
  57. </div>
  58. </div>
  59.  
  60. <div class="well" id="employee_permission_info">
  61. <legend><?php echo $this->lang->line("employees_permission_info"); ?></legend>
  62. <p><?php echo $this->lang->line("employees_permission_desc"); ?></p>
  63.  
  64. <ul id="permission_list">
  65. <?php
  66. foreach($all_modules->result() as $module)
  67. {
  68. ?>
  69. <li>
  70. <?php echo form_checkbox("grants[]",$module->module_id,$this->Employee->has_grant($module->module_id,$person_info->person_id),"class='module'"); ?>
  71. <span class="medium"><?php echo $this->lang->line('module_'.$module->module_id);?>:</span>
  72. <span class="small"><?php echo $this->lang->line('module_'.$module->module_id.'_desc');?></span>
  73. <?php
  74. foreach($all_subpermissions->result() as $permission)
  75. {
  76. $exploded_permission = explode('_', $permission->permission_id);
  77. if ($permission->module_id == $module->module_id)
  78. {
  79. $lang_key = $module->module_id.'_'.$exploded_permission[1];
  80. $lang_line = $this->lang->line($lang_key);
  81. $lang_line = ($this->lang->line_tbd($lang_key) == $lang_line) ? $exploded_permission[1] : $lang_line;
  82. if (empty($lang_line))
  83. {
  84. continue;
  85. }
  86. ?>
  87. <ul>
  88. <li>
  89. <?php echo form_checkbox("grants[]",$permission->permission_id,$this->Employee->has_grant($permission->permission_id,$person_info->person_id)); ?>
  90. <span class="medium"><?php echo $lang_line ?></span>
  91. </li>
  92. </ul>
  93. <?php
  94. }
  95. }
  96. }
  97. ?>
  98. </li>
  99. </ul>
  100. <?php
  101. echo form_submit(array(
  102. 'name'=>'submit',
  103. 'id'=>'submit',
  104. 'value'=>$this->lang->line('common_submit'),
  105. 'class'=>'btn btn-primary btn-sm pull-right')
  106. );
  107.  
  108. ?>
  109. </div>
  110. </div>
  111. <?php echo form_close(); ?>
  112. </div>
  113. <script type='text/javascript'>
  114. //validation and submit handling
  115. $(document).ready(function()
  116. {
  117.  
  118. $.validator.addMethod("module", function (value, element) {
  119. var result = true;
  120. $(".module").each(function(index, element)
  121. {
  122. var parent = $(element).parent();
  123. var checked = $(element).is(":checked");
  124. if ($("ul", parent).length > 0 && result)
  125. {
  126. result &= !checked || (checked && $("ul > li > input:checked", parent).length > 0);
  127. }
  128. });
  129. return result;
  130. }, '<?php echo $this->lang->line('employees_subpermission_required'); ?>');
  131.  
  132. $("ul#permission_list > li > input[name='grants[]']").each(function()
  133. {
  134. var $this = $(this);
  135. $("ul > li > input", $this.parent()).each(function()
  136. {
  137. var $that = $(this);
  138. var updateCheckboxes = function (checked)
  139. {
  140. $that.prop("disabled", !checked);
  141. !checked && $that.prop("checked", false);
  142. }
  143. $this.change(function() {
  144. updateCheckboxes($this.is(":checked"));
  145. });
  146. updateCheckboxes($this.is(":checked"));
  147. });
  148. });
  149.  
  150. $('#employee_form').validate({
  151. submitHandler:function(form)
  152. {
  153. $(form).ajaxSubmit({
  154. success:function(response)
  155. {
  156. //tb_remove();
  157. $('.modal').modal('hide');
  158. post_person_form_submit(response);
  159. },
  160. dataType:'json'
  161. });
  162.  
  163. },
  164. errorLabelContainer: "#error_message_box",
  165. wrapper: "li",
  166. rules:
  167. {
  168. first_name: "required",
  169. last_name: "required",
  170. username:
  171. {
  172. required:true,
  173. minlength: 5
  174. },
  175.  
  176. password:
  177. {
  178. <?php
  179. if($person_info->person_id == "")
  180. {
  181. ?>
  182. required:true,
  183. <?php
  184. }
  185. ?>
  186. minlength: 8
  187. },
  188. repeat_password:
  189. {
  190. equalTo: "#password"
  191. },
  192. email:
  193. {
  194. required: true,
  195. email: true
  196. }
  197. },
  198. messages:
  199. {
  200. first_name: "<?php echo $this->lang->line('common_first_name_required'); ?>",
  201. last_name: "<?php echo $this->lang->line('common_last_name_required'); ?>",
  202. email: "<?php echo $this->lang->line('common_email_invalid_format'); ?>",
  203. username:
  204. {
  205. required: "<?php echo $this->lang->line('employees_username_required'); ?>",
  206. minlength: "<?php echo $this->lang->line('employees_username_minlength'); ?>"
  207. },
  208.  
  209. password:
  210. {
  211. <?php
  212. if($person_info->person_id == "")
  213. {
  214. ?>
  215. required:"<?php echo $this->lang->line('employees_password_required'); ?>",
  216. <?php
  217. }
  218. ?>
  219. minlength: "<?php echo $this->lang->line('employees_password_minlength'); ?>"
  220. },
  221. repeat_password:
  222. {
  223. equalTo: "<?php echo $this->lang->line('employees_password_must_match'); ?>"
  224. },
  225. email: "<?php echo $this->lang->line('common_email_invalid_format'); ?>"
  226. }
  227. });
  228. $("#employee_form #email").on("keyup bind cut copy paste", function () {
  229. var email = $("#employee_form #email").val();
  230. $("#employee_form #username").val(email);
  231. });
  232. });
  233. </script>
  234. </div>
  235. </div>
  236. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement