<?php echo message_box('success'); ?>
<?php echo message_box('error'); ?>
<?php
$error_message = $this->session->userdata('error_message');
$error_type = $this->session->userdata('error_type');
if (!empty($error_message)) {
	foreach ($error_message as $key => $v_message) {
		?>
		<div class="alert-<?php echo $error_type[$key] ?>"
		     style="padding: 8px;margin-bottom: 21px;border: 1px solid transparent;}">
			<?php echo $v_message; ?>
		</div>
		<?php
	}
}
$this->session->unset_userdata('error_message');

$email_fields = array(
	array('name' => 'send_clock_email', 'label' => lang('send') . ' ' . lang('clock_email')),
	array('name' => 'leave_email', 'label' => lang('leave') . ' ' . lang('email')),
	array('name' => 'overtime_email', 'label' => lang('overtime') . ' ' . lang('email')),
	array('name' => 'payslip_email', 'label' => lang('payslip') . ' ' . lang('email')),
	array('name' => 'advance_salary_email', 'label' => lang('advance_salary') . ' ' . lang('email')),
	array('name' => 'award_email', 'label' => lang('award') . ' ' . lang('email')),
	array('name' => 'job_circular_email', 'label' => lang('job_circular') . ' ' . lang('email')),
	array('name' => 'announcements_email', 'label' => lang('announcements') . ' ' . lang('email')),
	array('name' => 'training_email', 'label' => lang('training') . ' ' . lang('email')),
	array('name' => 'expense_email', 'label' => lang('expense') . ' ' . lang('email')),
	array('name' => 'deposit_email', 'label' => lang('deposit') . ' ' . lang('email')),
	array('name' => 'projects_email', 'label' => lang('projects') . ' ' . lang('email')),
	array('name' => 'tasks_email', 'label' => lang('tasks') . ' ' . lang('email')),
);
?>

<div class="rounded-2xl">
	<?php echo form_open(base_url('admin/settings/save_email_notification'), array('id' => 'form', 'class' => 'p-6 space-y-6', 'role' => 'form')); ?>

	<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
		<?php foreach ($email_fields as $field) {
			$checked = config_item($field['name']);
			echo '<div class="rounded-lg border border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-900/40 p-4">'
				. form_checkbox($field['name'], $field['label'], !empty($checked) && $checked == 1, false, array('value' => 1))
				. '</div>';
		} ?>
	</div>

	<div class="flex items-center justify-end gap-2">
		<button type="submit" id="sbtn" class="btn btn-sm btn-primary"><?= lang('update') ?></button>
	</div>
	<?php echo form_close(); ?>
</div>
