81 lines
4.0 KiB
Plaintext
81 lines
4.0 KiB
Plaintext
@model ImportMode
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">Import Data from CSV</h5>
|
|
<button type="button" class="btn-close" onclick="hideBulkImportModal()" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form>
|
|
<div class="form-group">
|
|
<div class="form-group">
|
|
<div class="col-12">
|
|
<div class="alert alert-warning" role="alert">
|
|
In order for this utility to function properly, your CSV file MUST be formatted exactly like the provided sample.
|
|
Dates must be supplied in a string.
|
|
Numbers must be supplied as numbers without currency formatting.
|
|
</div>
|
|
<div class="alert alert-danger" role="alert">
|
|
Failure to format the data correctly can cause data corruption. Please make sure you make a copy of the local database before proceeding.
|
|
</div>
|
|
@if (Model == ImportMode.GasRecord)
|
|
{
|
|
<a class="btn btn-link" href="/defaults/gassample.csv" target="_blank">Download Sample</a>
|
|
} else if (Model == ImportMode.ServiceRecord || Model == ImportMode.RepairRecord || Model == ImportMode.UpgradeRecord)
|
|
{
|
|
<a class="btn btn-link" href="/defaults/servicerecordsample.csv" target="_blank">Download Sample</a>
|
|
} else if (Model == ImportMode.TaxRecord)
|
|
{
|
|
<a class="btn btn-link" href="/defaults/taxrecordsample.csv" target="_blank">Download Sample</a>
|
|
} else if (Model == ImportMode.SupplyRecord)
|
|
{
|
|
<a class="btn btn-link" href="/defaults/supplysample.csv" target="_blank">Download Sample</a>
|
|
} else if (Model == ImportMode.PlanRecord)
|
|
{
|
|
<a class="btn btn-link" href="/defaults/plansample.csv" target="_blank">Download Sample</a>
|
|
}
|
|
</div>
|
|
</div>
|
|
<div class="row mt-2">
|
|
<div class="col-12">
|
|
<label for="csvFileUploader">Upload CSV File</label>
|
|
<input onChange="uploadFileAsync(this)" type="file" multiple accept=".csv" class="form-control-file" id="csvFileUploader">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" onclick="hideBulkImportModal()">Cancel</button>
|
|
<button type="button" onclick="importFromCsv()" class="btn btn-primary">Import</button>
|
|
</div>
|
|
<script>
|
|
var uploadedFile = "";
|
|
function importFromCsv() {
|
|
var vehicleId = GetVehicleId().vehicleId;
|
|
var mode = "@Model";
|
|
sloader.show();
|
|
$.post('/Vehicle/ImportToVehicleIdFromCsv', { vehicleId: vehicleId, mode: mode, fileName: uploadedFile }, function (data) {
|
|
sloader.hide();
|
|
if (data) {
|
|
successToast("Data Imported Successfully");
|
|
hideBulkImportModal();
|
|
if (mode == "GasRecord") {
|
|
getVehicleGasRecords(vehicleId);
|
|
} else if (mode == "ServiceRecord") {
|
|
getVehicleServiceRecords(vehicleId);
|
|
} else if (mode == "RepairRecord") {
|
|
getVehicleCollisionRecords(vehicleId);
|
|
} else if (mode == "TaxRecord") {
|
|
getVehicleTaxRecords(vehicleId);
|
|
} else if (mode == "UpgradeRecord") {
|
|
getVehicleUpgradeRecords(vehicleId);
|
|
} else if (mode == "SupplyRecord") {
|
|
getVehicleSupplyRecords(vehicleId);
|
|
} else if (mode == "PlanRecord"){
|
|
getVehiclePlanRecords(vehicleId);
|
|
}
|
|
} else {
|
|
errorToast("An error has occurred, please double check the data and try again.");
|
|
}
|
|
});
|
|
}
|
|
</script> |