107 lines
5.6 KiB
PHP
107 lines
5.6 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' : '.xls,.xlsx,.pdf,.jpg,.jpeg,.png';
|
|
$accept_text = $isFirstField ? 'First file: Excel only (.xls, .xlsx)' : 'Files: PDF, Excel (.xlsx, .xls), Images (.png, .jpg, .jpeg)';
|
|
|
|
$displayIndex = $index + 1;
|
|
?>
|
|
|
|
<div class="form-row d-flex align-items-end" id="fileField_<?= $displayIndex ?>">
|
|
<div class="form-group row" style="width: 100%;">
|
|
<input type="hidden" name="leads_file_id[]" value="<?= htmlspecialchars($value['id']) ?>" id="file_id_<?= $displayIndex ?>">
|
|
|
|
<div class="col-auto" style="align-content: center;">
|
|
<label class="col-form-label">Document Name</label>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<input type="text" class="form-control" name="docs_name_<?= $increment ?>[]"
|
|
placeholder="<?= $placeholder ?>" style="background: #F5FFFF !important;"
|
|
value="<?= htmlspecialchars($value['docs_name']) ?>" id="docs_name_<?= $displayIndex ?>">
|
|
</div>
|
|
<div class="col-auto" style="align-content: center;">
|
|
<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>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="input-icon">
|
|
<input type="file" class="form-control" id="file_name_<?= $displayIndex ?>" name="file_name_<?= $increment ?>[]" accept="<?= $accept ?>" onchange="showFileName(this, <?= $displayIndex ?>)" style="background: #F5FFFF !important;">
|
|
<i class="mdi mdi-upload additional-icon"></i>
|
|
<small style="margin-left: 10px;font-size: 10px;"><span class="text-danger"><?= $accept_text ?></span></small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-auto">
|
|
<button type="button" class="btn btn-danger" onclick="removeFileField(<?= $displayIndex ?>, <?= htmlspecialchars($value['id']) ?>)"><span class="mdi mdi-trash-can"></span></button>
|
|
<button type="button" class="btn app-btn-secondary" onclick="addFileField(<?= $increment ?>)">+</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php } }else { ?>
|
|
<!-- Default field if no file data exists -->
|
|
<div class="form-row d-flex align-items-end" id="fileField_1">
|
|
<div class="form-group row" style="width: 100%;">
|
|
<input type="hidden" name="leads_file_id[]" value="">
|
|
|
|
<div class="col-auto" style="align-content: center;">
|
|
<label class="col-form-label">Document Name</label>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<input type="text" class="form-control" name="docs_name_1[]"
|
|
placeholder="First file must be Demography." id="docs_name_1" style="background: #F5FFFF !important;">
|
|
</div>
|
|
<div class="col-auto" style="align-content: center;">
|
|
<label>File Upload<br>
|
|
<small id="file_name_display_1" class="text-muted">No file chosen</small></label>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="input-icon">
|
|
<input type="file" class="form-control" id="file_name_1"
|
|
name="file_name_1[]" accept=".xls,.xlsx" onchange="showFileName(this, 1)" style="background: #F5FFFF !important;">
|
|
<i class="mdi mdi-upload additional-icon"></i>
|
|
<small style="margin-left: 10px;font-size: 10px;"><span class="text-danger">First file: Excel only (.xls, .xlsx)</span></small>
|
|
</div>
|
|
</div>
|
|
<div class="col-auto">
|
|
<button type="button" class="btn btn-danger" onclick="removeFileField(1, '')"><span class="mdi mdi-trash-can"></span></button>
|
|
<button type="button" class="btn app-btn-secondary" onclick="addFileField(1)">+</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- <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 } ?>
|