Change destination marker image, add backend functionality for job order processing stage
This commit is contained in:
parent
2b4c289ba9
commit
29a838b1a8
4 changed files with 70 additions and 20 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
|
@ -47,7 +47,7 @@ class JobOrderController extends BaseController
|
||||||
return $this->render('job-order/form.html.twig', $params);
|
return $this->render('job-order/form.html.twig', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function incomingSubmit(Request $req)
|
public function incomingSubmit(Request $req, ValidatorInterface $validator)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('jo_in.list', null, 'No access.');
|
$this->denyAccessUnlessGranted('jo_in.list', null, 'No access.');
|
||||||
|
|
||||||
|
|
@ -93,20 +93,16 @@ class JobOrderController extends BaseController
|
||||||
->setDeliveryInstructions($req->request->get('delivery_instructions'))
|
->setDeliveryInstructions($req->request->get('delivery_instructions'))
|
||||||
->setAgentNotes($req->request->get('agent_notes'))
|
->setAgentNotes($req->request->get('agent_notes'))
|
||||||
->setDeliveryAddress($req->request->get('delivery_address'));
|
->setDeliveryAddress($req->request->get('delivery_address'));
|
||||||
|
|
||||||
|
// validate
|
||||||
|
$errors = $validator->validate($obj);
|
||||||
|
|
||||||
|
// add errors to list
|
||||||
|
foreach ($errors as $error) {
|
||||||
|
$error_array[$error->getPropertyPath()] = $error->getMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Validation
|
|
||||||
|
|
||||||
/*
|
|
||||||
// validate
|
|
||||||
$errors = $validator->validate($obj);
|
|
||||||
|
|
||||||
// add errors to list
|
|
||||||
foreach ($errors as $error) {
|
|
||||||
$error_array[$error->getPropertyPath()] = $error->getMessage();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// check if any errors were found
|
// check if any errors were found
|
||||||
if (!empty($error_array)) {
|
if (!empty($error_array)) {
|
||||||
// return validation failure response
|
// return validation failure response
|
||||||
|
|
@ -314,7 +310,59 @@ class JobOrderController extends BaseController
|
||||||
|
|
||||||
error_log(print_r($req->request->all(), true));
|
error_log(print_r($req->request->all(), true));
|
||||||
|
|
||||||
// TODO: validation and saving of updated job order
|
// check if lat and lng are provided
|
||||||
|
if (empty($req->request->get('coord_lng')) || empty($req->request->get('coord_lat'))) {
|
||||||
|
$error_array['coordinates'] = 'No map coordinates provided. Please click on a location on the map.';
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if outlet is set
|
||||||
|
if (empty($req->request->get('outlet'))) {
|
||||||
|
$error_array['outlet'] = 'No outlet selected.';
|
||||||
|
} else {
|
||||||
|
// get outlet
|
||||||
|
$outlet = $em->getRepository(Outlet::class)->find($req->request->get('outlet'));
|
||||||
|
|
||||||
|
if (empty($outlet)) {
|
||||||
|
$error_array['outlet'] = 'Invalid outlet specified.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($error_array)) {
|
||||||
|
// coordinates
|
||||||
|
$point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat'));
|
||||||
|
|
||||||
|
// set and save values
|
||||||
|
$obj->setDateSchedule(DateTime::createFromFormat("d M Y h:i A", $req->request->get('date_schedule_date') . " " . $req->request->get('date_schedule_time')))
|
||||||
|
->setCoordinates($point)
|
||||||
|
->setAdvanceOrder($req->request->get('flag_advance') ?? false)
|
||||||
|
->setServiceType($req->request->get('service_type'))
|
||||||
|
->setSource('web')
|
||||||
|
->setStatus($req->request->get('status'))
|
||||||
|
->setDeliveryInstructions($req->request->get('delivery_instructions'))
|
||||||
|
->setAgentNotes($req->request->get('agent_notes'))
|
||||||
|
->setDeliveryAddress($req->request->get('delivery_address'))
|
||||||
|
->setOutlet($outlet);
|
||||||
|
|
||||||
|
// validate
|
||||||
|
$errors = $validator->validate($obj);
|
||||||
|
|
||||||
|
// add errors to list
|
||||||
|
foreach ($errors as $error) {
|
||||||
|
$error_array[$error->getPropertyPath()] = $error->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if any errors were found
|
||||||
|
if (!empty($error_array)) {
|
||||||
|
// return validation failure response
|
||||||
|
return $this->json([
|
||||||
|
'success' => false,
|
||||||
|
'errors' => $error_array
|
||||||
|
], 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
// validated! save the entity
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
// return successful response
|
// return successful response
|
||||||
return $this->json([
|
return $this->json([
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ class JobOrder
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Customer", inversedBy="job_orders")
|
* @ORM\ManyToOne(targetEntity="Customer", inversedBy="job_orders")
|
||||||
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
|
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
|
||||||
|
* Assert\NotBlank()
|
||||||
*/
|
*/
|
||||||
protected $customer;
|
protected $customer;
|
||||||
|
|
||||||
|
|
@ -84,6 +85,7 @@ class JobOrder
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="CustomerVehicle", inversedBy="job_orders")
|
* @ORM\ManyToOne(targetEntity="CustomerVehicle", inversedBy="job_orders")
|
||||||
* @ORM\JoinColumn(name="cvehicle_id", referencedColumnName="id")
|
* @ORM\JoinColumn(name="cvehicle_id", referencedColumnName="id")
|
||||||
|
* Assert\NotBlank()
|
||||||
*/
|
*/
|
||||||
protected $cus_vehicle;
|
protected $cus_vehicle;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,13 +160,13 @@
|
||||||
<div class="form-group m-form__group row">
|
<div class="form-group m-form__group row">
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<label>Transaction Date:</label>
|
<label>Transaction Date:</label>
|
||||||
<input type="text" name="date_transaction" class="form-control m-input" value="{{ "now"|date('d M Y') }}" disabled>
|
<input type="text" name="date_transaction" class="form-control m-input" value="{{ obj.getDateCreate|default("now")|date('d M Y') }}" disabled>
|
||||||
<div class="form-control-feedback hide" data-field="date_transaction"></div>
|
<div class="form-control-feedback hide" data-field="date_transaction"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-3">
|
<div class="col-lg-3">
|
||||||
<label data-field="date_schedule">Scheduled Date:</label>
|
<label data-field="date_schedule">Scheduled Date:</label>
|
||||||
<div class="input-group date dp">
|
<div class="input-group date dp">
|
||||||
<input type="text" name="date_schedule_date" class="form-control m-input" data-default-value="{{ obj.getDateSchedule ? obj.getDateSchedule|date('Y-m-d') : "now"|date('Y-m-d') }}" value="{{ obj.getDateSchedule ? obj.getDateSchedule|date('d M Y') : "now"|date('d M Y') }}" readonly placeholder="Select a date" disabled>
|
<input type="text" name="date_schedule_date" class="form-control m-input" data-default-value="{{ obj.getDateSchedule|default("now")|date('Y-m-d') }}" value="{{ obj.getDateSchedule|default("now")|date('d M Y') }}" readonly placeholder="Select a date" disabled>
|
||||||
<span class="input-group-addon">
|
<span class="input-group-addon">
|
||||||
<i class="la la-calendar glyphicon-th"></i>
|
<i class="la la-calendar glyphicon-th"></i>
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -176,7 +176,7 @@
|
||||||
<div class="col-lg-3">
|
<div class="col-lg-3">
|
||||||
<label data-field="date_schedule">Scheduled Time:</label>
|
<label data-field="date_schedule">Scheduled Time:</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" name="date_schedule_time" class="form-control m-input tp" data-default-value="{{ obj.getDateSchedule ? obj.getDateSchedule|date('g:i A') : "now"|date('g:i A') }}" value="{{ obj.getDateSchedule ? obj.getDateSchedule|date('g:i A') : "now"|date('g:i A') }}" readonly placeholder="Select a time" disabled>
|
<input type="text" name="date_schedule_time" class="form-control m-input tp" data-default-value="{{ obj.getDateSchedule|default("now")|date('g:i A') }}" value="{{ obj.getDateSchedule|default("now")|date('g:i A') }}" readonly placeholder="Select a time" disabled>
|
||||||
<span class="input-group-addon">
|
<span class="input-group-addon">
|
||||||
<i class="la la-clock-o glyphicon-th"></i>
|
<i class="la la-clock-o glyphicon-th"></i>
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -353,7 +353,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{% for outlet in outlets %}
|
{% for outlet in outlets %}
|
||||||
<tr data-id="{{ outlet.outlet.getID }}">
|
<tr data-id="{{ outlet.outlet.getID }}"{{ obj.getOutlet and obj.getOutlet.getID == outlet.outlet.getID ? ' class="m-table__row--primary"' }}>
|
||||||
<td>{{ outlet.outlet.getName }}</td>
|
<td>{{ outlet.outlet.getName }}</td>
|
||||||
<td>{{ outlet.outlet.getAddress }}</td>
|
<td>{{ outlet.outlet.getAddress }}</td>
|
||||||
<td>{{ outlet.outlet.getContactNumbers }}</td>
|
<td>{{ outlet.outlet.getContactNumbers }}</td>
|
||||||
|
|
@ -823,7 +823,7 @@ $(function() {
|
||||||
|
|
||||||
{% if mode == 'update' %}
|
{% if mode == 'update' %}
|
||||||
|
|
||||||
var selectedOutlet = false;
|
var selectedOutlet = '{{ obj.getOutlet ? obj.getOutlet.getID : "" }}';
|
||||||
|
|
||||||
$("#outlets-table tbody tr").click(function() {
|
$("#outlets-table tbody tr").click(function() {
|
||||||
var id = $(this).data('id');
|
var id = $(this).data('id');
|
||||||
|
|
@ -841,7 +841,7 @@ $(function() {
|
||||||
$(this).removeClass('m-table__row--primary');
|
$(this).removeClass('m-table__row--primary');
|
||||||
|
|
||||||
// remove id value
|
// remove id value
|
||||||
selectedOutlet = false;
|
selectedOutlet = '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue