Add job order ticket form blocks #21
This commit is contained in:
parent
7b39419710
commit
50347027a3
4 changed files with 161 additions and 10 deletions
|
|
@ -10,18 +10,20 @@ ticket_rows:
|
|||
methods: [POST]
|
||||
|
||||
ticket_create:
|
||||
path: /tickets/create/{customer_id}
|
||||
path: /tickets/create/{customer_id}/{job_order_id}
|
||||
controller: App\Controller\TicketController::addForm
|
||||
methods: [GET]
|
||||
defaults:
|
||||
customer_id: false
|
||||
job_order_id: false
|
||||
|
||||
ticket_create_submit:
|
||||
path: /tickets/create/{customer_id}
|
||||
path: /tickets/create/{customer_id}/{job_order_id}
|
||||
controller: App\Controller\TicketController::addSubmit
|
||||
methods: [POST]
|
||||
defaults:
|
||||
customer_id: false
|
||||
job_order_id: false
|
||||
|
||||
ticket_update:
|
||||
path: /tickets/{id}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use App\Ramcar\TicketType;
|
|||
use App\Ramcar\TicketStatus;
|
||||
use App\Entity\Ticket;
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\JobOrder;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
|
@ -123,7 +124,7 @@ class TicketController extends BaseController
|
|||
]);
|
||||
}
|
||||
|
||||
public function addForm(Request $req, $customer_id)
|
||||
public function addForm(Request $req, $customer_id, $job_order_id)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('ticket.add', null, 'No access.');
|
||||
|
||||
|
|
@ -131,6 +132,7 @@ class TicketController extends BaseController
|
|||
$params['obj'] = new Ticket();
|
||||
$params['mode'] = 'create';
|
||||
$params['customer'] = false;
|
||||
$params['job_order'] = false;
|
||||
$customer = false;
|
||||
|
||||
// get customer data
|
||||
|
|
@ -144,6 +146,18 @@ class TicketController extends BaseController
|
|||
|
||||
// add to view
|
||||
$params['customer'] = $customer;
|
||||
|
||||
// get job order data
|
||||
if ($job_order_id) {
|
||||
$job_order = $em->getRepository(JobOrder::class)->find($job_order_id);
|
||||
|
||||
// make sure this row exists
|
||||
if (empty($job_order))
|
||||
throw $this->createNotFoundException('This job order does not exist');
|
||||
|
||||
// add to view
|
||||
$params['job_order'] = $job_order;
|
||||
}
|
||||
}
|
||||
|
||||
// get parent associations
|
||||
|
|
@ -160,13 +174,21 @@ class TicketController extends BaseController
|
|||
|
||||
if ($referer == $cust_update_url)
|
||||
$params['redirect_url'] = $cust_update_url;
|
||||
|
||||
if ($job_order)
|
||||
{
|
||||
$job_order_url = $this->generateUrl('jo_proc_form', ['id' => $job_order->getID()], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
|
||||
if ($referer == $job_order_url)
|
||||
$params['redirect_url'] = $job_order_url;
|
||||
}
|
||||
}
|
||||
|
||||
// response
|
||||
return $this->render('ticket/form.html.twig', $params);
|
||||
}
|
||||
|
||||
public function addSubmit(Request $req, ValidatorInterface $validator, $customer_id)
|
||||
public function addSubmit(Request $req, ValidatorInterface $validator, $customer_id, $job_order_id)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('ticket.add', null, 'No access.');
|
||||
|
||||
|
|
@ -190,6 +212,15 @@ class TicketController extends BaseController
|
|||
if (count($mobile_numbers) > 0) {
|
||||
$contact_num = $mobile_numbers[0]->getID();
|
||||
}
|
||||
|
||||
// get job order data
|
||||
if ($job_order_id) {
|
||||
$job_order = $em->getRepository(JobOrder::class)->find($job_order_id);
|
||||
|
||||
// make sure this row exists
|
||||
if (empty($job_order))
|
||||
throw $this->createNotFoundException('This job order does not exist');
|
||||
}
|
||||
} else {
|
||||
// get values directly from form
|
||||
$first_name = $req->request->get('first_name');
|
||||
|
|
@ -226,6 +257,11 @@ class TicketController extends BaseController
|
|||
$obj->setCustomer($customer);
|
||||
}
|
||||
|
||||
// if linked to job order, set association
|
||||
if ($job_order_id) {
|
||||
$obj->setJobOrder($job_order);
|
||||
}
|
||||
|
||||
// initialize error list
|
||||
$error_array = [];
|
||||
|
||||
|
|
@ -279,9 +315,11 @@ class TicketController extends BaseController
|
|||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$customer = $obj->getCustomer();
|
||||
$job_order = $obj->getJobOrder();
|
||||
|
||||
// get parent associations
|
||||
$params['customer'] = $customer;
|
||||
$params['job_order'] = $job_order;
|
||||
$params['ticket_types'] = TicketType::getCollection();
|
||||
$params['statuses'] = TicketStatus::getCollection();
|
||||
$params['other_ticket_type'] = TicketType::OTHER;
|
||||
|
|
|
|||
|
|
@ -376,7 +376,7 @@
|
|||
|
||||
{% if mode == 'update-processing' %}
|
||||
<div class="m-form__seperator m-form__seperator--dashed"></div>
|
||||
<div class="m-form__section m-form__section--last">
|
||||
<div class="m-form__section">
|
||||
<div class="m-form__heading">
|
||||
<h3 class="m-form__heading-title">
|
||||
Nearest Hubs
|
||||
|
|
@ -421,8 +421,12 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-12">
|
||||
<div id="hub_map" style="height:600px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if mode in ['update-assigning', 'update-fulfillment'] %}
|
||||
|
|
@ -473,7 +477,7 @@
|
|||
<div class="m-form__seperator m-form__seperator--dashed"></div>
|
||||
|
||||
{% if mode == 'update-assigning' %}
|
||||
<div class="m-form__section m-form__section--last">
|
||||
<div class="m-form__section">
|
||||
<div class="m-form__heading">
|
||||
<h3 class="m-form__heading-title">
|
||||
Rider Assignment
|
||||
|
|
@ -525,7 +529,7 @@
|
|||
{% endif %}
|
||||
|
||||
{% if mode == 'update-fulfillment' %}
|
||||
<div class="m-form__section m-form__section--last">
|
||||
<div class="m-form__section">
|
||||
<div class="m-form__heading">
|
||||
<h3 class="m-form__heading-title">
|
||||
Rider Details
|
||||
|
|
@ -565,6 +569,28 @@
|
|||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if mode != 'create' %}
|
||||
<div class="m-form__seperator m-form__seperator--dashed"></div>
|
||||
|
||||
<div class="m-form__section m-form__section--last">
|
||||
<div class="m-form__heading">
|
||||
<h3 class="m-form__heading-title">
|
||||
Tickets
|
||||
</h3>
|
||||
</div>
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-12">
|
||||
<div class="m_datatable" id="data-tickets"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group m-form__group row">
|
||||
<div class="col-lg-12">
|
||||
<a href="{{ url('ticket_create', {'customer_id': obj.getCustomer.getID, 'job_order_id': obj.getID}) }}" class="btn btn-primary">Create Ticket</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
<div class="m-portlet__foot m-portlet__foot--fit">
|
||||
<div class="m-form__actions m-form__actions--solid m-form__actions--right">
|
||||
|
|
@ -1070,7 +1096,7 @@ $(function() {
|
|||
selectedHub = id;
|
||||
|
||||
// center the map
|
||||
omap.setCenter(lat, lng);
|
||||
hmap.setCenter(lat, lng);
|
||||
} else {
|
||||
// unhighlight this row
|
||||
$(this).removeClass('m-table__row--primary');
|
||||
|
|
@ -1104,6 +1130,76 @@ $(function() {
|
|||
}
|
||||
});
|
||||
{% endif %}
|
||||
|
||||
{% if mode != 'create' %}
|
||||
var ticketRows = [];
|
||||
|
||||
{% for ticket in obj.getTickets %}
|
||||
trow = {
|
||||
id: "{{ ticket.getID }}",
|
||||
date_create: "{{ ticket.getDateCreate|date('d M Y - h:i A') }}",
|
||||
subject: "{{ ticket.getSubject }}",
|
||||
ticket_type: "{{ ticket.getTicketTypeText }}",
|
||||
status: "{{ ticket.getStatusText }}",
|
||||
edit_url: "{{ url('ticket_update', {'id': ticket.getID}) }}"
|
||||
};
|
||||
|
||||
ticketRows.push(trow);
|
||||
{% endfor %}
|
||||
|
||||
// tickets data table
|
||||
var ticketOptions = {
|
||||
data: {
|
||||
type: 'local',
|
||||
source: ticketRows,
|
||||
saveState: {
|
||||
cookie: false,
|
||||
webstorage: false
|
||||
}
|
||||
},
|
||||
layout: {
|
||||
scroll: true
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
field: 'id',
|
||||
title: 'ID',
|
||||
width: 30
|
||||
},
|
||||
{
|
||||
field: 'date_create',
|
||||
title: 'Date Created',
|
||||
width: 200
|
||||
},
|
||||
{
|
||||
field: 'subject',
|
||||
title: 'Subject',
|
||||
width: 300
|
||||
},
|
||||
{
|
||||
field: 'ticket_type',
|
||||
title: 'Ticket Type'
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: 'Status'
|
||||
},
|
||||
{
|
||||
field: 'Actions',
|
||||
width: 70,
|
||||
title: 'Actions',
|
||||
sortable: false,
|
||||
overflow: 'visible',
|
||||
template: function (row, index, datatable) {
|
||||
return '<a href="' + row.edit_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit-ticket" title="Edit"><i class="la la-edit"></i></a>';
|
||||
},
|
||||
}
|
||||
],
|
||||
pagination: false
|
||||
};
|
||||
|
||||
var ticketTable = $("#data-tickets").mDatatable(ticketOptions);
|
||||
{% endif %}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<form id="row-form" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed" method="post" action="{{ mode == 'update' ? url('ticket_update_submit', {'id': obj.getId}) : url('ticket_create_submit', {'customer_id': customer ? customer.getID : false}) }}">
|
||||
<form id="row-form" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed" method="post" action="{{ mode == 'update' ? url('ticket_update_submit', {'id': obj.getId}) : url('ticket_create_submit', {'customer_id': customer ? customer.getID : false, 'job_order_id': job_order ? job_order.getID : false}) }}">
|
||||
<div class="m-portlet__body">
|
||||
<div class="form-group m-form__group row no-border">
|
||||
<div class="col-lg-4">
|
||||
|
|
@ -107,6 +107,21 @@
|
|||
<div class="form-control-feedback hide" data-field="details"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group m-form__group row no-border">
|
||||
<div class="col-lg-4">
|
||||
<label data-field="job_order_id">Linked Job Order</label>
|
||||
<input type="text" name="job_order_id" class="form-control m-input" value="{{ job_order.getID|default('None') }}" disabled>
|
||||
<div class="form-control-feedback hide" data-field="job_order_id"></div>
|
||||
</div>
|
||||
{% if job_order %}
|
||||
<div class="col-lg-4">
|
||||
<label> </label>
|
||||
<div>
|
||||
<a href="{{ url('jo_proc_form', {'id': job_order.getID }) }}" class="btn btn-info">View Job Order</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__foot m-portlet__foot--fit">
|
||||
<div class="m-form__actions m-form__actions--solid m-form__actions--right">
|
||||
|
|
|
|||
Loading…
Reference in a new issue