<?php foreach ($data as $key) { ?>
	<form id="form_<?= md5($key->id_cabang) ?>">
		<div class="card card-rounded card-abu">
			<div class="card-header">
				<h4 class="card-title" id="heading-labels">
					<i class="fa fa-building-o"></i> <?= $this->fungsi->get_nama_cab($key->id_cabang) ?>
				</h4>
				<?php
					if(in_array($this->session->userdata('level_user'), array("1"))) {
				?>
						<div class="row form-detail-karyawan">
							<div class="col-md-12 text-right">
								<label id="message_<?= md5($key->id_cabang) ?>" class="mr-2"></label>
								<button type="submit" id="btn_save_<?= md5($key->id_cabang) ?>" class="btn btn-primary round ladda-button" data-style="expand-left" style="display: none"><i class="fa fa-save"></i> SIMPAN</button>
								<button type="button" id="btn_batal_<?= md5($key->id_cabang) ?>" class="btn btn-danger round" style="display: none"><i class="fa fa-close"></i> BATAL</button>
								<button type="button" class="btn btn_edit btn-secondary round" id="<?= md5($key->id_cabang) ?>"> <i class="fa fa-edit (alias)"></i> EDIT DATA</button>
							</div>
						</div>
				<?php } ?>
			</div>
			<div class="card-body">
				<input type="hidden" id="id_cabang" name="id_cabang" class="form-control" value="<?= ((isset($key))? $key->id_cabang:'') ?>">

				<?php
					$data_cabang = $this->db->query("SELECT level_user, level_approval, id FROM p_approval_reimbursement WHERE id_cabang = '$key->id_cabang'");

					$jumlah_level = $data_cabang->num_rows();
					$i = 1;
					foreach ($data_cabang->result() as $val) {
						$level = explode(',', $val->level_approval);
				?>
						<div class="row mb-1">
							<div class="col-md-12">
								<label class="font-weight-bold"><?= $this->fungsi->get_nama_level($val->level_user) ?></label>
								<input type="hidden" id="level_user_<?= $key->id_cabang ?>_<?= $i ?>" name="level_user_<?= $key->id_cabang ?>_<?= $i ?>" class="form-control" value="<?= ((isset($val))? $val->level_user:'') ?>">
								<input type="hidden" id="id_<?= $key->id_cabang ?>_<?= $i ?>" name="id_<?= $key->id_cabang ?>_<?= $i ?>" class="form-control" value="<?= ((isset($val))? $val->id:'') ?>">
							</div>
						</div>
						<div class="row">
							<div class="col-md-2">
								<input type="checkbox" id="level1_<?= $i ?>" name="level_<?= $key->id_cabang ?>_<?= $i ?>-[]" value="7" disabled="true" data-i="<?= $i ?>" data-o="1"  <?=(isset($level) AND in_array('7', $level))? 'checked' : ''?> /> Supervisi
							</div>
							<div class="col-md-2">
								<input type="checkbox" id="level2_<?= $i ?>" name="level_<?= $key->id_cabang ?>_<?= $i ?>-[]" value="2" disabled="true" data-i="<?= $i ?>" data-o="2" <?=(isset($level) AND in_array('2', $level))? 'checked' : ''?>/> Kepala Departemen
							</div>
							<div class="col-md-2">
								<input type="checkbox" id="level3_<?= $i ?>" name="level_<?= $key->id_cabang ?>_<?= $i ?>-[]" value="5" disabled="true" data-i="<?= $i ?>" data-o="3" <?=(isset($level) AND in_array('5', $level))? 'checked' : ''?>/> Kepala Cabang
							</div>
							<div class="col-md-2">
								<input type="checkbox" id="level5_<?= $i ?>" name="level_<?= $key->id_cabang ?>_<?= $i ?>-[]" value="4" disabled="true" data-i="<?= $i ?>" data-o="5" <?=(isset($level) AND in_array('4', $level))? 'checked' : ''?>/> Direksi
							</div>
							<div class="col-md-2">
								<input type="checkbox" id="level4_<?= $i ?>" name="level_<?= $key->id_cabang ?>_<?= $i ?>-[]" value="6" disabled="true" data-i="<?= $i ?>" data-o="4" <?=(isset($level) AND in_array('6', $level))? 'checked' : ''?>/> Admin Reimbursement
							</div>
						</div>
						<hr>
						<br>
				<?php
						$i++;
					}
				?>
			</div>
			<div class="card-footer">
				<input type="hidden" name="jumlah_level" id="jumlah_level" value="<?= $jumlah_level ?>" class="form-control">
            </div>
		</div>
	</form>
<?php } ?>