nhance/app/Views/rfq/multi_files.php
2025-05-16 17:50:57 +05:30

68 lines
3.0 KiB
PHP

<?php
$fileIndex = 1;
$increment = 1;
?>
<?php if (isset($lead_edit_data) && isset($lead_edit_data["multi_file_data"]) && !empty($lead_edit_data["multi_file_data"])) {
foreach ($lead_edit_data["multi_file_data"] as $index => $value) {
$isFirstField = ($index === 0);
$placeholder = $isFirstField ? 'First file must be Demography.' : '';
$accept = $isFirstField ? '.xls,.xlsx' : '';
$displayIndex = $index + 1;
?>
<div class="form-row d-flex align-items-end" id="fileField_<?= $displayIndex ?>">
<input type="hidden" name="leads_file_id[]" value="<?= htmlspecialchars($value['id']) ?>" id="file_id_<?= $displayIndex ?>">
<div class="form-group col-md-5">
<label>Document Name</label>
<input type="text" class="form-control" name="docs_name_<?= $increment ?>[]"
placeholder="<?= $placeholder ?>"
value="<?= htmlspecialchars($value['docs_name']) ?>" id="docs_name_<?= $displayIndex ?>">
</div>
<div class="form-group col-md-5">
<label>
File Upload<br>
<small id="file_name_display_<?= $displayIndex ?>" class="text-muted">
<?= !empty($value['file_name']) ? htmlspecialchars($value['file_name']) : 'No file chosen' ?>
</small>
</label>
<input type="file" class="form-control" id="file_name_<?= $displayIndex ?>"
name="file_name_<?= $increment ?>[]" accept="<?= $accept ?>"
onchange="showFileName(this, <?= $displayIndex ?>)">
</div>
<div class="col-md-2" style="position: relative; bottom: 16px;">
<button type="button" class="btn btn-danger" onclick="removeFileField(<?= $displayIndex ?>, <?= htmlspecialchars($value['id']) ?>)">x</button>
<button type="button" class="btn btn-primary" onclick="addFileField(<?= $increment ?>)">+</button>
</div>
</div>
<?php } } else { ?>
<!-- Default field if no file data exists -->
<div class="form-row d-flex align-items-end" id="fileField_1">
<input type="hidden" name="leads_file_id[]" value="">
<div class="form-group col-md-5">
<label>Document Name</label>
<input type="text" class="form-control" name="docs_name_1[]"
placeholder="First file must be Demography." id="docs_name_1">
</div>
<div class="form-group col-md-5">
<label>
File Upload<br>
<small id="file_name_display_1" class="text-muted">No file chosen</small>
</label>
<input type="file" class="form-control" id="file_name_1"
name="file_name_1[]" accept=".xls,.xlsx" onchange="showFileName(this, 1)">
</div>
<div class="col-md-2" style="position: relative; bottom: 16px;">
<button type="button" class="btn btn-danger" onclick="removeFileField(1, '')">x</button>
<button type="button" class="btn btn-primary" onclick="addFileField(1)">+</button>
</div>
</div>
<?php } ?>