<?php
$new_employee_html = form_lookup_add_link(
	'client_id',
	base_url('admin/user/create'),
	lang('create') . ' ' . lang('employee'),
	'2xl'
);

$selected_employee_by = !empty($awardrule_info->client_id) ? $awardrule_info->client_id : (!empty($user_id) ? $user_id : '');
$selected_employee_by_label = null;
if (!empty($awardrule_info->client_id)) {
	$user = $this->db->where('client_id', $awardrule_info->client_id)->get('tbl_client')->row();
	if (!empty($user)) {
		$selected_employee_by_label = $user->name;
	}
}
?>
<div class="rounded-2xl ">


	<?php echo form_open(base_url('admin/settings/save_award_rule/' . (!empty($awardrule_info->award_rule_id) ? $awardrule_info->award_rule_id : '')), array('class' => 'p-6 space-y-6 ', 'enctype' => 'multipart/form-data', 'data-parsley-validate' => 'true', 'role' => 'form')); ?>



	<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
		<?= form_input_group('rule_name', lang('name'), (!empty($awardrule_info->rule_name) ? $awardrule_info->rule_name : ''), 'text', true); ?>


		<?= form_lookup_group('client_id', lang('employee'), $selected_employee_by, $selected_employee_by_label, true, array(), '', array('type' => 'client', 'append' => $new_employee_html)); ?>


		<?= form_input_group('card', lang('card'), (!empty($awardrule_info->card) ? $awardrule_info->card : ''), 'number', false); ?>

		<?= form_input_group('award_point_from', lang('Point from'), (!empty($awardrule_info->award_point_from) ? $awardrule_info->award_point_from : ''), 'text', false); ?>

		<?= form_input_group('award_point_to', lang('Point to'), (!empty($awardrule_info->award_point_to) ? $awardrule_info->award_point_to : ''), 'text', false); ?>
		<?= form_editor('description', lang('description'), (!empty($awardrule_info->description) ? $awardrule_info->description : ''), false); ?>

	</div>




	<div class="flex items-center justify-end gap-2">
		<button type="submit" class="btn btn-sm btn-primary"><?= lang('save_changes') ?></button>
		<button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal"><?= lang('cancel') ?></button>
	</div>
	<?php echo form_close(); ?>

</div>

<script type="text/javascript">
	$(document).ready(function() {
		$('body').find('select.selectpicker').not('.ajax-search').selectpicker({
			showSubtext: true,
		});
	});
</script>
