nhance/app/Views/rfq/multi_files.php

50 lines
2.2 KiB
PHP

<?php
$fileIndex = 1; // Initialize index
$increment = 1; // Example increment value
?>
<?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); // First file must be Demography
$placeholder = $isFirstField ? 'First file must be Demography.' : '';
$accept = $isFirstField ? '.xls,.xlsx' : '';
$index = $index + 1;
?>
<div class="form-row d-flex align-items-end" id="fileField_<?= $index ?>">
<input type="hidden" name="leads_file_id[]"
value="<?= htmlspecialchars($value['id']) ?>" id="file_id_<?= $index ?>">
<!-- Document Name Input -->
<div class="form-group col-md-5">
<label>Document Name<span class="text-danger"></span></label>
<input type="text" class="form-control" name="docs_name_<?= $increment ?>[]"
placeholder="<?= $placeholder ?>"
value="<?= htmlspecialchars($value['docs_name']) ?>" id="docs_name_<?= $index ?>">
</div>
<!-- File Upload Input -->
<div class="form-group col-md-5">
<label>
File Upload
<span class="text-danger"></span><br>
<small id="file_name_display_<?= $index ?>" 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_<?= $index ?>"
name="file_name_<?= $increment ?>[]" accept="<?= $accept ?>"
onchange="showFileName(this, <?= $index ?>)">
</div>
<!-- Add/Remove Buttons -->
<div class="col-md-2" style="position: relative; bottom: 16px;">
<button type="button" class="btn btn-danger" onclick="removeFileField(<?= $index ?>, <?= htmlspecialchars($value['id']) ?>)">x</button>
<button type="button" class="btn btn-primary" onclick="addFileField(<?= $increment ?>)">+</button>
</div>
</div>
<?php } } ?>