finished igr file upload issue

This commit is contained in:
vadivel J 2024-10-28 11:26:24 +05:30
parent cbe976d73a
commit 0d1d94ecf5
3 changed files with 37 additions and 22 deletions

View File

@ -708,6 +708,7 @@ function viewIGRDetails()
function UpdateIGR() function UpdateIGR()
{ {
$IGRNo = $this->request->getPost('igr'); $IGRNo = $this->request->getPost('igr');
$PONo = $this->request->getPost('po'); $PONo = $this->request->getPost('po');
@ -754,12 +755,13 @@ function viewIGRDetails()
$fileupdated_count = 0; $fileupdated_count = 0;
$fileupdated_name = []; $fileupdated_name = [];
$fileNames = $this->request->getPost('file_name'); $fileNames = $this->request->getPost('file_name');
$files = $this->request->getFiles(); $files = $this->request->getFileMultiple('emp_file');
if(isset($files['emp_file']))
if(isset($files))
{ {
foreach ($files['emp_file'] as $index => $file) { foreach ($files as $index => $file) {
if ($file->isValid() && !$file->hasMoved()) { if ($file->isValid() && !$file->hasMoved()) {
@ -768,10 +770,10 @@ function viewIGRDetails()
$newName = $file->getRandomName(); $newName = $file->getRandomName();
$file->move($path, $newName); $file->move($path, $newName);
// Store the file information in the database // Store the file information in the database
$additionalFiles = array( $additionalFiles = array(
'Remarks' => $finallyfilename, 'Remarks' => $finallyfilename,
'FilePath' => $newName, 'FilePath' => $newName,
'IGRNO' => $IGRNo, 'IGRNO' => $IGRNo,
'PONO' => $PONo 'PONO' => $PONo
); );
$lastInsertFileId = $this->inwardgateregister_model->uploadAdditionalFile($additionalFiles); $lastInsertFileId = $this->inwardgateregister_model->uploadAdditionalFile($additionalFiles);
@ -779,7 +781,7 @@ function viewIGRDetails()
$fileupdated_count++; $fileupdated_count++;
$fileupdated_name[] = $finallyfilename; $fileupdated_name[] = $finallyfilename;
} }
} }
} }
} }

View File

@ -241,9 +241,17 @@
</table> </table>
</div> <!-- end table-responsive--> </div> <!-- end table-responsive-->
</div> </div>
<div class="form-row text-right"> <div class="form-row text-left">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<input type="file" name="MasterFile" id="MasterFile" onchange="filenames(this.name); "><br> <br>
<div class="form-group col-md-12">
<label> Master IGR file</label>
<br>
<input type="file" name="MasterFile" id="MasterFile" onchange="filenames(this.name); ">
<label id="MasterFileLabel" style="display:none;">
<a><span></span><small></small></a>
</label>
</div>
</div> </div>
</div> </div>
@ -840,16 +848,16 @@
<script> <script>
function appendFilesFileds(data) { function appendFilesFileds(data) {
var newRowHtml = ` var newRowHtml = `
<div class="form-row pad"> <div class="form-row pad mt-2">
<div class="form-group col-md-4"> <div class=" col-md-4">
<label class="col-form-label">File name</label> <label class="col-form-label">File name</label>
<input type="text" id="file_name" name="file_name[]" maxlength="255" class="form-control" value="${data != null && data != '' ? data.file_name : ''}"> <input type="text" id="file_name" name="file_name[]" maxlength="255" class="form-control" value="${data != null && data != '' ? data.file_name : ''}">
</div> </div>
<div class="form-group col-md-4"> <div class=" col-md-4">
<label class="col-form-label">File</label> <label class="col-form-label">File</label>
<input type="file" name="emp_file[]" class="form-control"> <input type="file" name="emp_file[]" class="form-control">
</div> </div>
<div class="form-group col-md-4 p-4"> <div class=" col-md-4" style="margin-top: 40px;">
<button type="button" class="btn btn-danger waves-effect btn-sm" onclick="removeContact(this)">Remove</button> <button type="button" class="btn btn-danger waves-effect btn-sm" onclick="removeContact(this)">Remove</button>
<button type="button" class="btn btn-primary waves-effect btn-sm a1" onclick="appendFilesFileds()">Add</button> <button type="button" class="btn btn-primary waves-effect btn-sm a1" onclick="appendFilesFileds()">Add</button>
</div> </div>

View File

@ -1029,16 +1029,21 @@
formData.append('tableData', JSON.stringify(tableData)); formData.append('tableData', JSON.stringify(tableData));
formData.append('isOpenOrder', $("#hiddenIsOpenOrder").val()); formData.append('isOpenOrder', $("#hiddenIsOpenOrder").val());
formData.append('MasterFile', $('#MasterFile')[0].files[0]); formData.append('MasterFile', $('#MasterFile')[0].files[0]);
formData.append('file_name[]', $('#file_name').val());
var empFiles = $('#emp_file')[0] ? $('#emp_file')[0].files : null; $('input[name="file_name[]"]').each(function() {
if (empFiles) { formData.append('file_name[]', $(this).val());
});
$('input[name="emp_file[]"]').each(function() {
var empFiles = this.files;
for (var i = 0; i < empFiles.length; i++) { for (var i = 0; i < empFiles.length; i++) {
formData.append('emp_file[]', empFiles[i]); formData.append('emp_file[]', empFiles[i]);
console.log(empFiles[i]); console.log(empFiles[i]);
} }
} else { });
console.log("ajax call");
}
//return false;
$('#loader').show(); $('#loader').show();
$.ajax({ $.ajax({
data: formData, data: formData,
@ -1626,7 +1631,7 @@
</div> </div>
<div class=" col-md-4"> <div class=" col-md-4">
<label class="col-form-label" for="emp_file">File</label> <label class="col-form-label" for="emp_file">File</label>
<input type="file" id="emp_file" name="emp_file[]" class="form-control"> <input type="file" id="emp_file" name="emp_file[]" multiple class="form-control">
</div> </div>
<div class=" col-md-4" style="margin-top: 40px;"> <div class=" col-md-4" style="margin-top: 40px;">
<button type="button" class="btn btn-danger btn-sm" onclick="removeContact(this)">Remove</button> <button type="button" class="btn btn-danger btn-sm" onclick="removeContact(this)">Remove</button>