Add warranty serial edit modal and ajax call for jo forms #525
This commit is contained in:
parent
1e3ac3e71c
commit
668f49f335
3 changed files with 70 additions and 0 deletions
|
|
@ -44,3 +44,8 @@ customer_delete:
|
|||
path: /customers/{id}
|
||||
controller: App\Controller\CustomerController::destroy
|
||||
methods: [DELETE]
|
||||
|
||||
customer_vehicle_warranty_edit_ajax:
|
||||
path: /ajax/customer_vehicle/{id}
|
||||
controller: App\Controller\CustomerController::editCustomerVehicleWarranty
|
||||
methods: [POST]
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use App\Ramcar\CrudException;
|
|||
|
||||
use App\Service\CustomerHandlerInterface;
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\CustomerVehicle;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
|
|
@ -226,4 +227,21 @@ class CustomerController extends Controller
|
|||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function editCustomerVehicleWarranty($id, Request $req, EntityManagerInterface $em)
|
||||
{
|
||||
$cv = $em->getRepository(CustomerVehicle::class)->find($id);
|
||||
|
||||
$serial = $req->request->get('warr_serial');
|
||||
$cv->setWarrantyCode($serial);
|
||||
|
||||
$em->flush();
|
||||
|
||||
return $this->json([
|
||||
'success' => true,
|
||||
'data' => [
|
||||
'warranty_code' => $serial,
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -219,6 +219,12 @@
|
|||
<input type="text" name="warranty_expiration" id="warranty-expiration" class="form-control m-input" value="{{ obj.getCustomerVehicle.getCurrentBattery|default(false) ? obj.getCustomerVehicle.getWarrantyExpiration|date("d M Y") : '' }}" data-vehicle-field="1" disabled>
|
||||
<div class="form-control-feedback hide" data-field="warranty_expiration"></div>
|
||||
</div>
|
||||
{% if obj.getCustomerVehicle %}
|
||||
<div class="col-lg-3">
|
||||
<div><label> </label></div>
|
||||
<a class="btn btn-primary" data-toggle="modal" href="#battery_edit"> Edit </a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-form__seperator m-form__seperator--dashed"></div>
|
||||
|
|
@ -913,6 +919,33 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="battery_edit" tabindex="-1" role="dialog" aria-hidden="true" style="display: none;">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Customer Battery Details</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="battery_edit_form" class="m-form m-form--fit m-form--label-align-right" method="POST" action="{{ url('customer_vehicle_warranty_edit_ajax', {'id' : obj.getCustomerVehicle ? obj.getCustomerVehicle.getID : 0}) }}">
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-12">
|
||||
<label>Warranty Serial Number</label>
|
||||
<input type="text" name="warr_serial" class="form-control m-input" maxlength="20">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn dark btn-outline" data-dismiss="modal">Close</button>
|
||||
<button type="button" id="battery_edit_submit" class="btn btn-primary">Save Changes</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal-dialog -->
|
||||
</div>
|
||||
|
||||
{% if mode in ['update-processing', 'update-reassign-hub'] %}
|
||||
<!-- rejection modal -->
|
||||
<div id="modal-rejection" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="modal-rejection-label" aria-hidden="true">
|
||||
|
|
@ -1890,5 +1923,19 @@ $(function() {
|
|||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
// battery warranty edit
|
||||
$('#battery_edit_submit').click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var url = $('#battery_edit_form').attr('action');
|
||||
var data = $('#battery_edit_form').serialize();
|
||||
$.post(url, data, function(data) {
|
||||
$('#warranty-code').val(data.data.warranty_code);
|
||||
$('#battery_edit').modal('hide');
|
||||
}, 'json');
|
||||
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue