<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>

    
	<form data-parsley-validate="" novalidate="" enctype="multipart/form-data"
			action="<?php echo base_url() ?>admin/user/update_documents/<?php if (!empty($profile_info->account_details_id)) echo $profile_info->account_details_id; ?>"
			method="post">

		<input type="hidden" name="document_id" value="<?php if (!empty($document_info->document_id)) echo $document_info->document_id; ?>">

		<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
			<div class="space-y-2">
				<?= form_file('resume', lang('resume')); ?>
				<input type="hidden" name="resume_path" value="<?php if (!empty($document_info->resume_path)) echo $document_info->resume_path; ?>">
				<?php if (!empty($document_info->resume)) : ?>
					<p class="text-xs text-muted-foreground">
						<?= lang('existing') ?>: <?= html_escape($document_info->resume_filename ?? $document_info->resume); ?>
					</p>
					<input type="hidden" name="resume" value="<?php echo $document_info->resume; ?>">
				<?php endif; ?>
			</div>

			<div class="space-y-2">
				<?= form_file('offer_letter', lang('offer_latter')); ?>
				<input type="hidden" name="offer_letter_path" value="<?php if (!empty($document_info->offer_letter_path)) echo $document_info->offer_letter_path; ?>">
				<?php if (!empty($document_info->offer_letter)) : ?>
					<p class="text-xs text-muted-foreground">
						<?= lang('existing') ?>: <?= html_escape($document_info->offer_letter_filename ?? $document_info->offer_letter); ?>
					</p>
					<input type="hidden" name="offer_letter" value="<?php echo $document_info->offer_letter; ?>">
				<?php endif; ?>
			</div>

			<div class="space-y-2">
				<?= form_file('joining_letter', lang('joining_latter')); ?>
				<input type="hidden" name="joining_letter_path" value="<?php if (!empty($document_info->joining_letter_path)) echo $document_info->joining_letter_path; ?>">
				<?php if (!empty($document_info->joining_letter)) : ?>
					<p class="text-xs text-muted-foreground">
						<?= lang('existing') ?>: <?= html_escape($document_info->joining_letter_filename ?? $document_info->joining_letter); ?>
					</p>
					<input type="hidden" name="joining_letter" value="<?php echo $document_info->joining_letter; ?>">
				<?php endif; ?>
			</div>

			<div class="space-y-2">
				<?= form_file('contract_paper', lang('contract_paper')); ?>
				<input type="hidden" name="contract_paper_path" value="<?php if (!empty($document_info->contract_paper_path)) echo $document_info->contract_paper_path; ?>">
				<?php if (!empty($document_info->contract_paper)) : ?>
					<p class="text-xs text-muted-foreground">
						<?= lang('existing') ?>: <?= html_escape($document_info->contract_paper_filename ?? $document_info->contract_paper); ?>
					</p>
					<input type="hidden" name="contract_paper" value="<?php echo $document_info->contract_paper; ?>">
				<?php endif; ?>
			</div>

			<div class="space-y-2">
				<?= form_file('id_proff', lang('id_prof')); ?>
				<input type="hidden" name="id_proff_path" value="<?php if (!empty($document_info->id_proff_path)) echo $document_info->id_proff_path; ?>">
				<?php if (!empty($document_info->id_proff)) : ?>
					<p class="text-xs text-muted-foreground">
						<?= lang('existing') ?>: <?= html_escape($document_info->id_proff_filename ?? $document_info->id_proff); ?>
					</p>
					<input type="hidden" name="id_proff" value="<?php echo $document_info->id_proff; ?>">
				<?php endif; ?>
			</div>
		</div>

		<div class="rounded-xl border border-border bg-card p-4 space-y-3 mt-3">
			<div class="flex items-center justify-between">
				<h5 class="text-sm font-semibold text-foreground"><?= lang('other_document') ?></h5>
				<button type="button" id="add_more" class="inline-flex items-center gap-1 rounded-lg border border-border px-3 py-1.5 text-xs font-semibold text-foreground hover:bg-muted">
					<i data-lucide="plus" class="h-3 w-3"></i><?= lang('add_more') ?>
				</button>
			</div>
			<div id="add_new" class="space-y-3">
				<?php
				$uploaded_file = array();
				if (!empty($document_info->other_document)) {
					$uploaded_file = json_decode($document_info->other_document);
				}
				if (!empty($uploaded_file)) :
					foreach ($uploaded_file as $v_files_image) : ?>
						<div class="flex items-center justify-between rounded-lg border border-border bg-muted/40 px-3 py-2">
							<div class="text-sm text-foreground"><?= html_escape($v_files_image->fileName); ?></div>
							<div class="flex items-center gap-2">
								<button type="button" class="text-rose-600 hover:text-rose-700 text-xs font-semibold RCF">&times; <?= lang('remove') ?></button>
							</div>
							<input type="hidden" name="path[]" value="<?php echo $v_files_image->path; ?>">
							<input type="hidden" name="fileName[]" value="<?php echo $v_files_image->fileName; ?>">
							<input type="hidden" name="fullPath[]" value="<?php echo $v_files_image->fullPath; ?>">
							<input type="hidden" name="size[]" value="<?php echo $v_files_image->size; ?>">
							<input type="hidden" name="is_image[]" value="<?php echo $v_files_image->is_image; ?>">
						</div>
					<?php endforeach; ?>
				<?php endif; ?>

				<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
					<?= form_file('other_document[]', lang('other_document')); ?>
				</div>
			</div>
		</div>

		<div class="flex items-center justify-end gap-2 pt-2">
			<button type="button" class="rounded-lg border border-border px-4 py-2 text-xs font-semibold text-foreground hover:bg-muted" data-dismiss="modal"><?= lang('close') ?></button>
			<button type="submit" class="rounded-lg bg-indigo-600 px-4 py-2 text-xs font-semibold text-white shadow-sm hover:bg-indigo-500"><?= lang('update') ?></button>
		</div>
	</form>

