<?php
defined('BASEPATH') OR exit('No direct script access allowed');
if(isset($_GET['jd']) && isset($_GET['role_id']) && $_GET['data']=='role'){
$role_resources_ids = explode(',',$role_resources);
?>

<div class="modal-header">
  <h5 class="modal-title f-w-600" id="exampleModalLabel"><strong>Edit User Role</strong></h5>
  <button class="btn-close" type="button" data-bs-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<form class="m-b-1" action="<?php echo site_url("roles/update").'/'.$role_id; ?>" method="post" name="edit_role" id="edit_role">
  <input type="hidden" name="_method" value="EDIT">
  <input type="hidden" name="_token" value="<?php echo $role_id;?>">
  <input type="hidden" name="ext_name" value="<?php echo $role_name;?>">
  <div class="modal-body">
    <div class="row">
      <div class="col-md-4">
        <div class="row">
          <div class="col-md-12">
            <div class="form-group">
              <label for="role_name">Role Name</label>
              <input class="form-control" placeholder="Role Name" name="role_name" type="text" value="<?php echo $role_name;?>">
            </div>
          </div>
        </div>
        <div class="row">
        	<input type="checkbox" name="role_resources[]" value="0" checked style="display:none;"/>
          <div class="col-md-12">
            <div class="form-group">
              <label for="role_access">Select Access</label>
              <select class="form-control custom-select" id="role_access_modal" name="role_access" data-plugin="select_hrm" data-placeholder="Select Access">
                <option value="">&nbsp;</option>
                <option value="1" <?php if($role_access==1):?> selected="selected" <?php endif;?>>All Menu Access</option>
                <option value="2" <?php if($role_access==2):?> selected="selected" <?php endif;?>>Custom Menu Access</option>
              </select>
            </div>
          </div>
        </div>
      </div>
      <div class="col-md-4">
        <div class="row">
          <div class="col-md-12">
            <div class="form-group">
              <label for="resources">Resources</label>
              <div id="all_resources">
                <div class="demo-section k-content">
                  <div>
                    <div id="treeview_m1"></div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="col-md-4">
        <div class="row">
          <div class="col-md-12">
            <div class="form-group">
              <div id="all_resources">
                <div class="demo-section k-content">
                  <div>
                    <div id="treeview_m2"></div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="modal-footer">
    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
    <button type="submit" class="btn btn-primary">Update</button>
  </div>
</form>
<link rel="stylesheet" href="<?php echo base_url();?>skin/vendor/select2/dist/css/select2.min.css">
<script type="text/javascript" src="<?php echo base_url();?>skin/vendor/select2/dist/js/select2.min.js"></script>
<script type="text/javascript">
 $(document).ready(function(){
					
		// On page load: datatable
		var xin_table = $('#xin_table').dataTable({
			"bDestroy": true,
			"ajax": {
				url : "<?php echo site_url("roles/role_list") ?>",
				type : 'GET'
			},
			"fnDrawCallback": function(settings){
			//$('[data-toggle="tooltip"]').tooltip();          
			}
    	});
		
		$('[data-plugin="select_hrm"]').select2($(this).attr('data-options'));
		$('[data-plugin="select_hrm"]').select2({ width:'100%' });	 

		/* Edit data */
		$("#edit_role").submit(function(e){
		e.preventDefault();
			var obj = $(this), action = obj.attr('name');
			$('.save').prop('disabled', true);
			
			$.ajax({
				type: "POST",
				url: e.target.action,
				data: obj.serialize()+"&is_ajax=1&edit_type=role&form="+action,
				cache: false,
				success: function (JSON) {
					if (JSON.error != '') {
						toastr.error(JSON.error);
						$('.save').prop('disabled', false);
					} else {
						xin_table.api().ajax.reload(function(){ 
							toastr.success(JSON.result);
						}, true);
						$('.edit-modal-data').modal('toggle');
						$('.save').prop('disabled', false);
					}
				}
			});
		});
	});	
  </script>
  <script>

jQuery("#treeview_m1").kendoTreeView({
checkboxes: {
checkChildren: true,
template: "<label class='custom-control custom-checkbox'><input type='checkbox' #= item.check# class='#= item.class #' name='role_resources[]' value='#= item.value #'  /><span class='custom-control-indicator'></span><span class='custom-control-description'>#= item.text #</span><span class='custom-control-info'>#= item.add_info #</span></label>"
},
check: onCheck,
dataSource: [
    
{ id: "", class: "role-checkbox custom-control-input", text: "Dashboard", add_info: "", value: "111", check: "<?php if(isset($_GET['role_id'])) { 
    if(in_array('111',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>", items: [
// sub 1
{ id: "", class: "role-checkbox custom-control-input", text: "All count",  add_info: "All count", value: "112", check: "<?php if(isset($_GET['role_id'])) { if(in_array('112',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Branch total count",  add_info: "Branch total count", value: "113", check: "<?php if(isset($_GET['role_id'])) { if(in_array('113',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Employee Add Count",  add_info: "Employee Add Count", value: "114", check: "<?php if(isset($_GET['role_id'])) { if(in_array('114',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

]},

{ id: "", class: "role-checkbox custom-control-input", text: "Shipments", add_info: "", value: "1", check: "<?php if(isset($_GET['role_id'])) { 
    if(in_array('1',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>", items: [
// sub 1
{ id: "", class: "role-checkbox custom-control-input", text: "Show All",  add_info: "show all", value: "212", check: "<?php if(isset($_GET['role_id'])) { if(in_array('212',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Edit",  add_info: "Deliver", value: "2", check: "<?php if(isset($_GET['role_id'])) { if(in_array('2',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "View",  add_info: "View", value: "211", check: "<?php if(isset($_GET['role_id'])) { if(in_array('211',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Add New",  add_info: "Edit", value: "3", check: "<?php if(isset($_GET['role_id'])) { if(in_array('3',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Delete",  add_info: "Delete", value: "4", check: "<?php if(isset($_GET['role_id'])) { if(in_array('4',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},
]}, // sub 1 end


{ id: "", class: "role-checkbox custom-control-input", text: "Customer", add_info: "", value: "5", check: "<?php if(isset($_GET['role_id'])) { 
if(in_array('5',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>", items: [
// sub 1
{ id: "", class: "role-checkbox custom-control-input", text: "Add",  add_info: "Add", value: "6", check: "<?php if(isset($_GET['role_id'])) { if(in_array('6',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Edit",  add_info: "Edit", value: "7", check: "<?php if(isset($_GET['role_id'])) { if(in_array('7',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "View",  add_info: "View", value: "8", check: "<?php if(isset($_GET['role_id'])) { if(in_array('8',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Delete",  add_info: "Delete", value: "9", check: "<?php if(isset($_GET['role_id'])) { if(in_array('9',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

]}, // sub 1 end


{ id: "", class: "role-checkbox custom-control-input", text: "Quotations", add_info: "", value: "10", check: "<?php if(isset($_GET['role_id'])) { 
if(in_array('10',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>", items: [
// sub 1
{ id: "", class: "role-checkbox custom-control-input", text: "Show All",  add_info: "show all", value: "411", check: "<?php if(isset($_GET['role_id'])) { if(in_array('411',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Add",  add_info: "Add", value: "11", check: "<?php if(isset($_GET['role_id'])) { if(in_array('11',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Edit",  add_info: "Edit", value: "12", check: "<?php if(isset($_GET['role_id'])) { if(in_array('12',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "View",  add_info: "View", value: "13", check: "<?php if(isset($_GET['role_id'])) { if(in_array('13',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Download",  add_info: "View", value: "14", check: "<?php if(isset($_GET['role_id'])) { if(in_array('14',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Delete",  add_info: "Delete", value: "15", check: "<?php if(isset($_GET['role_id'])) { if(in_array('15',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

]}, // sub 1 end


{ id: "", class: "role-checkbox custom-control-input", text: "Invoice", add_info: "", value: "30", check: "<?php if(isset($_GET['role_id'])) { 
if(in_array('10',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>", items: [
// sub 1
{ id: "", class: "role-checkbox custom-control-input", text: "Show All",  add_info: "show all", value: "31", check: "<?php if(isset($_GET['role_id'])) { if(in_array('31',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Add",  add_info: "Add", value: "32", check: "<?php if(isset($_GET['role_id'])) { if(in_array('32',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Edit",  add_info: "Edit", value: "33", check: "<?php if(isset($_GET['role_id'])) { if(in_array('33',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "View",  add_info: "View", value: "34", check: "<?php if(isset($_GET['role_id'])) { if(in_array('34',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Download",  add_info: "Download", value: "35", check: "<?php if(isset($_GET['role_id'])) { if(in_array('35',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Delete",  add_info: "Delete", value: "36", check: "<?php if(isset($_GET['role_id'])) { if(in_array('36',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

]}, // sub 1 end


{ id: "", class: "role-checkbox custom-control-input", text: "Profoma Invoice", add_info: "", value: "37", check: "<?php if(isset($_GET['role_id'])) { 
if(in_array('37',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>", items: [
// sub 1
{ id: "", class: "role-checkbox custom-control-input", text: "Show All",  add_info: "show all", value: "38", check: "<?php if(isset($_GET['role_id'])) { if(in_array('38',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Add",  add_info: "Add", value: "39", check: "<?php if(isset($_GET['role_id'])) { if(in_array('39',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Edit",  add_info: "Edit", value: "40", check: "<?php if(isset($_GET['role_id'])) { if(in_array('40',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "View",  add_info: "View", value: "41", check: "<?php if(isset($_GET['role_id'])) { if(in_array('41',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Download",  add_info: "Download", value: "42", check: "<?php if(isset($_GET['role_id'])) { if(in_array('42',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Delete",  add_info: "Delete", value: "43", check: "<?php if(isset($_GET['role_id'])) { if(in_array('43',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

]}, // sub 1 end


{ id: "", class: "role-checkbox custom-control-input", text: "Delivery Note", add_info: "", value: "44", check: "<?php if(isset($_GET['role_id'])) { 
if(in_array('44',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>", items: [
// sub 1
{ id: "", class: "role-checkbox custom-control-input", text: "Show All",  add_info: "show all", value: "45", check: "<?php if(isset($_GET['role_id'])) { if(in_array('45',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Add",  add_info: "Add", value: "46", check: "<?php if(isset($_GET['role_id'])) { if(in_array('46',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Edit",  add_info: "Edit", value: "47", check: "<?php if(isset($_GET['role_id'])) { if(in_array('47',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "View",  add_info: "View", value: "48", check: "<?php if(isset($_GET['role_id'])) { if(in_array('48',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Download",  add_info: "View", value: "49", check: "<?php if(isset($_GET['role_id'])) { if(in_array('49',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Delete",  add_info: "Delete", value: "50", check: "<?php if(isset($_GET['role_id'])) { if(in_array('50',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

]}, // sub 1 end


{ id: "", class: "role-checkbox custom-control-input", text: "Purchase order", add_info: "", value: "51", check: "<?php if(isset($_GET['role_id'])) { 
if(in_array('51',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>", items: [
// sub 1
{ id: "", class: "role-checkbox custom-control-input", text: "Show All",  add_info: "show all", value: "52", check: "<?php if(isset($_GET['role_id'])) { if(in_array('52',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Add",  add_info: "Add", value: "53", check: "<?php if(isset($_GET['role_id'])) { if(in_array('53',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Edit",  add_info: "Edit", value: "54", check: "<?php if(isset($_GET['role_id'])) { if(in_array('54',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "View",  add_info: "View", value: "55", check: "<?php if(isset($_GET['role_id'])) { if(in_array('55',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Download",  add_info: "View", value: "56", check: "<?php if(isset($_GET['role_id'])) { if(in_array('56',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Delete",  add_info: "Delete", value: "57", check: "<?php if(isset($_GET['role_id'])) { if(in_array('57',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

]}, // sub 1 end

]
});

jQuery("#treeview_m2").kendoTreeView({
checkboxes: {
checkChildren: true,
template: "<label class='custom-control custom-checkbox'><input type='checkbox' #= item.check# class='#= item.class #' name='role_resources[]' value='#= item.value #'  /><span class='custom-control-indicator'></span><span class='custom-control-description'>#= item.text #</span><span class='custom-control-info'>#= item.add_info #</span></label>"
},
check: onCheck,
dataSource: [
//

{ id: "", class: "role-checkbox custom-control-input", text: "Receipts", add_info: "", value: "58", check: "<?php if(isset($_GET['role_id'])) { 
if(in_array('58',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>", items: [
// sub 1
{ id: "", class: "role-checkbox custom-control-input", text: "Show All",  add_info: "show all", value: "59", check: "<?php if(isset($_GET['role_id'])) { if(in_array('59',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Add",  add_info: "Add", value: "60", check: "<?php if(isset($_GET['role_id'])) { if(in_array('60',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Edit",  add_info: "Edit", value: "61", check: "<?php if(isset($_GET['role_id'])) { if(in_array('61',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "View",  add_info: "View", value: "62", check: "<?php if(isset($_GET['role_id'])) { if(in_array('62',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Download",  add_info: "View", value: "63", check: "<?php if(isset($_GET['role_id'])) { if(in_array('63',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Delete",  add_info: "Delete", value: "64", check: "<?php if(isset($_GET['role_id'])) { if(in_array('64',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

]}, // sub 1 end



{ id: "", class: "role-checkbox custom-control-input", text: "Account Receivable", add_info: "", value: "65", check: "<?php if(isset($_GET['role_id'])) { 
if(in_array('65',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>", items: [
// sub 1
{ id: "", class: "role-checkbox custom-control-input", text: "Show All",  add_info: "show all", value: "66", check: "<?php if(isset($_GET['role_id'])) { if(in_array('66',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Add",  add_info: "Add", value: "67", check: "<?php if(isset($_GET['role_id'])) { if(in_array('67',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Edit",  add_info: "Edit", value: "68", check: "<?php if(isset($_GET['role_id'])) { if(in_array('68',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "View",  add_info: "View", value: "69", check: "<?php if(isset($_GET['role_id'])) { if(in_array('69',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Download",  add_info: "View", value: "70", check: "<?php if(isset($_GET['role_id'])) { if(in_array('70',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Delete",  add_info: "Delete", value: "71", check: "<?php if(isset($_GET['role_id'])) { if(in_array('71',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

]}, // sub 1 end



{ id: "", class: "role-checkbox custom-control-input", text: "Daily Expenses", add_info: "", value: "72", check: "<?php if(isset($_GET['role_id'])) { 
if(in_array('72',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>", items: [
// sub 1
{ id: "", class: "role-checkbox custom-control-input", text: "Show All",  add_info: "show all", value: "73", check: "<?php if(isset($_GET['role_id'])) { if(in_array('73',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Add",  add_info: "Add", value: "74", check: "<?php if(isset($_GET['role_id'])) { if(in_array('74',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Edit",  add_info: "Edit", value: "75", check: "<?php if(isset($_GET['role_id'])) { if(in_array('75',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "View",  add_info: "View", value: "76", check: "<?php if(isset($_GET['role_id'])) { if(in_array('76',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Download",  add_info: "View", value: "77", check: "<?php if(isset($_GET['role_id'])) { if(in_array('77',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Delete",  add_info: "Delete", value: "78", check: "<?php if(isset($_GET['role_id'])) { if(in_array('78',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

]}, // sub 1 end


{ id: "", class: "role-checkbox custom-control-input", text: "Rate Request", add_info: "", value: "16", check: "<?php if(isset($_GET['role_id'])) { 
if(in_array('16',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>", items: [
// sub 1
{ id: "", class: "role-checkbox custom-control-input", text: "Add",  add_info: "Add", value: "17", check: "<?php if(isset($_GET['role_id'])) { if(in_array('17',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Edit",  add_info: "Edit", value: "18", check: "<?php if(isset($_GET['role_id'])) { if(in_array('18',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "View",  add_info: "View", value: "19", check: "<?php if(isset($_GET['role_id'])) { if(in_array('19',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Delete",  add_info: "Delete", value: "20", check: "<?php if(isset($_GET['role_id'])) { if(in_array('20',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

]}, // sub 1 end


{ id: "", class: "role-checkbox custom-control-input", text: "Users", add_info: "", value: "21", check: "<?php if(isset($_GET['role_id'])) { 
if(in_array('21',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>", items: [
// sub 1
{ id: "", class: "role-checkbox custom-control-input", text: "Add",  add_info: "Add", value: "22", check: "<?php if(isset($_GET['role_id'])) { if(in_array('22',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Edit",  add_info: "Edit", value: "23", check: "<?php if(isset($_GET['role_id'])) { if(in_array('23',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "View",  add_info: "View", value: "24", check: "<?php if(isset($_GET['role_id'])) { if(in_array('24',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Delete",  add_info: "Delete", value: "25", check: "<?php if(isset($_GET['role_id'])) { if(in_array('25',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

]}, // sub 1 end


{ id: "", class: "role-checkbox custom-control-input", text: "Roles",  add_info: "View", value: "26", check: "<?php if(isset($_GET['role_id'])) { if(in_array('26',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Company",  add_info: "View", value: "27", check: "<?php if(isset($_GET['role_id'])) { if(in_array('27',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},

{ id: "", class: "role-checkbox custom-control-input", text: "Settings",  add_info: "", value: "28", check: "<?php if(isset($_GET['role_id'])) { 
if(in_array('28',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>", items: [
{ id: "", class: "role-checkbox custom-control-input", text: "Currency",  add_info: "Add", value: "29", check: "<?php if(isset($_GET['role_id'])) { if(in_array('29',$role_resources_ids)): echo 'checked'; else: echo ''; endif; }?>",},
]},

]
});
		
// show checked node IDs on datasource change
function onCheck() {
var checkedNodes = [],
treeView = jQuery("#treeview").data("kendoTreeView"),
message;
//checkedNodeIds(treeView.dataSource.view(), checkedNodes);
jQuery("#result").html(message);
}
$(document).ready(function(){
	$("#role_access_modal").change(function(){
		var sel_val = $(this).val();
		if(sel_val=='1') {
			$('.role-checkbox-modal').prop('checked', true);
		} else {
			$('.role-checkbox-modal').attr("checked", false);
		}
	});
});
</script>
<?php }
?>
