Add the new ticket fields into the ticket form. #676
This commit is contained in:
parent
96ce1f81fa
commit
d89f67bc76
3 changed files with 480 additions and 325 deletions
|
|
@ -9,8 +9,11 @@ use App\Ramcar\SourceOfAwareness;
|
||||||
use App\Entity\Ticket;
|
use App\Entity\Ticket;
|
||||||
use App\Entity\Customer;
|
use App\Entity\Customer;
|
||||||
use App\Entity\JobOrder;
|
use App\Entity\JobOrder;
|
||||||
|
use App\Entity\TicketType as NewTicketType;
|
||||||
|
use App\Entity\SubTicketType;
|
||||||
|
|
||||||
use Doctrine\ORM\Query;
|
use Doctrine\ORM\Query;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
|
|
@ -128,7 +131,7 @@ class TicketController extends Controller
|
||||||
/**
|
/**
|
||||||
* @Menu(selected="ticket_list")
|
* @Menu(selected="ticket_list")
|
||||||
*/
|
*/
|
||||||
public function addForm(Request $req, $customer_id, $job_order_id)
|
public function addForm(Request $req, EntityManagerInterface $em, $customer_id, $job_order_id)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('ticket.add', null, 'No access.');
|
$this->denyAccessUnlessGranted('ticket.add', null, 'No access.');
|
||||||
|
|
||||||
|
|
@ -140,7 +143,6 @@ class TicketController extends Controller
|
||||||
|
|
||||||
// get customer data
|
// get customer data
|
||||||
if ($customer_id) {
|
if ($customer_id) {
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
$customer = $em->getRepository(Customer::class)->find($customer_id);
|
$customer = $em->getRepository(Customer::class)->find($customer_id);
|
||||||
|
|
||||||
// make sure this row exists
|
// make sure this row exists
|
||||||
|
|
@ -176,6 +178,8 @@ class TicketController extends Controller
|
||||||
$params['redirect_url'] = $this->generateUrl('ticket_list');
|
$params['redirect_url'] = $this->generateUrl('ticket_list');
|
||||||
$params['soa_types'] = SourceOfAwareness::getCollection();
|
$params['soa_types'] = SourceOfAwareness::getCollection();
|
||||||
|
|
||||||
|
$params['sets'] = $this->generateFormSets($em);
|
||||||
|
|
||||||
// set redirect url
|
// set redirect url
|
||||||
if ($customer)
|
if ($customer)
|
||||||
{
|
{
|
||||||
|
|
@ -236,12 +240,16 @@ class TicketController extends Controller
|
||||||
$obj = new Ticket();
|
$obj = new Ticket();
|
||||||
|
|
||||||
// get ticket type
|
// get ticket type
|
||||||
$ticket_type = $req->request->get('ticket_type');
|
//$ticket_type = $req->request->get('ticket_type');
|
||||||
$other_ticket_type = '';
|
//$other_ticket_type = '';
|
||||||
|
|
||||||
if ($ticket_type == TicketType::OTHER) {
|
//if ($ticket_type == TicketType::OTHER) {
|
||||||
$other_ticket_type = $req->request->get('other_ticket_type');
|
// $other_ticket_type = $req->request->get('other_ticket_type');
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
// get the "new" ticket type
|
||||||
|
$ttype_id = $req->request->get('new_ticket_type');
|
||||||
|
$sub_ttype_id = $req->request->get('sub_ticket_type');
|
||||||
|
|
||||||
// get source of awareness if any
|
// get source of awareness if any
|
||||||
$soa_type = $req->request->get('source_of_awareness');
|
$soa_type = $req->request->get('source_of_awareness');
|
||||||
|
|
@ -254,8 +262,8 @@ class TicketController extends Controller
|
||||||
->setLastName($last_name)
|
->setLastName($last_name)
|
||||||
->setContactNumber($contact_num)
|
->setContactNumber($contact_num)
|
||||||
->setStatus($req->request->get('status'))
|
->setStatus($req->request->get('status'))
|
||||||
->setTicketType($ticket_type)
|
//->setTicketType($ticket_type)
|
||||||
->setOtherTicketType($other_ticket_type)
|
//->setOtherTicketType($other_ticket_type)
|
||||||
->setDetails($req->request->get('details'))
|
->setDetails($req->request->get('details'))
|
||||||
->setPlateNumber($req->request->get('plate_number'))
|
->setPlateNumber($req->request->get('plate_number'))
|
||||||
->setDateCreate(new DateTime())
|
->setDateCreate(new DateTime())
|
||||||
|
|
@ -280,9 +288,21 @@ class TicketController extends Controller
|
||||||
$errors = $validator->validate($obj);
|
$errors = $validator->validate($obj);
|
||||||
|
|
||||||
// custom validation for other ticket type
|
// custom validation for other ticket type
|
||||||
if ($ticket_type == TicketType::OTHER && empty($other_ticket_type)) {
|
//if ($ticket_type == TicketType::OTHER && empty($other_ticket_type)) {
|
||||||
$error_array['other_ticket_type'] = 'Ticket type not specified.';
|
// $error_array['other_ticket_type'] = 'Ticket type not specified.';
|
||||||
}
|
//}
|
||||||
|
// get ticket and sub ticket type objects
|
||||||
|
$ttype = $em->getRepository(NewTicketType::class)->find($ttype_id);
|
||||||
|
if (empty($ttype))
|
||||||
|
$error_array['new_ticket_type'] = 'Ticket type not specified.';
|
||||||
|
|
||||||
|
$sub_ttype = $em->getRepository(SubTicketType::class)->find($sub_ttype_id);
|
||||||
|
if (empty($sub_ttype))
|
||||||
|
$error_array['sub_ticket_type'] = 'Sub ticket type not specified.';
|
||||||
|
|
||||||
|
// set the ticket type and sub ticket type for ticket
|
||||||
|
$obj->setNewTicketType($ttype)
|
||||||
|
->setSubTicketType($sub_ttype);
|
||||||
|
|
||||||
// add errors to list
|
// add errors to list
|
||||||
foreach ($errors as $error) {
|
foreach ($errors as $error) {
|
||||||
|
|
@ -311,22 +331,19 @@ class TicketController extends Controller
|
||||||
/**
|
/**
|
||||||
* @Menu(selected="ticket_list")
|
* @Menu(selected="ticket_list")
|
||||||
*/
|
*/
|
||||||
public function updateForm(Request $req, $id)
|
public function updateForm(Request $req, $id, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('ticket.update', null, 'No access.');
|
$this->denyAccessUnlessGranted('ticket.update', null, 'No access.');
|
||||||
|
|
||||||
$params['mode'] = 'update';
|
$params['mode'] = 'update';
|
||||||
|
|
||||||
// get row data
|
// get row data
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
$obj = $em->getRepository(Ticket::class)->find($id);
|
$obj = $em->getRepository(Ticket::class)->find($id);
|
||||||
|
|
||||||
// make sure this row exists
|
// make sure this row exists
|
||||||
if (empty($obj))
|
if (empty($obj))
|
||||||
throw $this->createNotFoundException('The item does not exist');
|
throw $this->createNotFoundException('The item does not exist');
|
||||||
|
|
||||||
// $em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
$customer = $obj->getCustomer();
|
$customer = $obj->getCustomer();
|
||||||
$job_order = $obj->getJobOrder();
|
$job_order = $obj->getJobOrder();
|
||||||
|
|
||||||
|
|
@ -339,6 +356,8 @@ class TicketController extends Controller
|
||||||
$params['redirect_url'] = $this->generateUrl('ticket_list');
|
$params['redirect_url'] = $this->generateUrl('ticket_list');
|
||||||
$params['soa_types'] = SourceOfAwareness::getCollection();
|
$params['soa_types'] = SourceOfAwareness::getCollection();
|
||||||
|
|
||||||
|
$params['sets'] = $this->generateFormSets($em);
|
||||||
|
|
||||||
// set redirect url
|
// set redirect url
|
||||||
if ($customer)
|
if ($customer)
|
||||||
{
|
{
|
||||||
|
|
@ -428,12 +447,16 @@ class TicketController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// get ticket type
|
// get ticket type
|
||||||
$ticket_type = $req->request->get('ticket_type');
|
//$ticket_type = $req->request->get('ticket_type');
|
||||||
$other_ticket_type = '';
|
//$other_ticket_type = '';
|
||||||
|
|
||||||
if ($ticket_type == TicketType::OTHER) {
|
//if ($ticket_type == TicketType::OTHER) {
|
||||||
$other_ticket_type = $req->request->get('other_ticket_type');
|
// $other_ticket_type = $req->request->get('other_ticket_type');
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
// get the "new" ticket type
|
||||||
|
$ttype_id = $req->request->get('new_ticket_type');
|
||||||
|
$sub_ttype_id = $req->request->get('sub_ticket_type');
|
||||||
|
|
||||||
// get source of awareness if any
|
// get source of awareness if any
|
||||||
$soa_type = $req->request->get('source_of_awareness');
|
$soa_type = $req->request->get('source_of_awareness');
|
||||||
|
|
@ -446,8 +469,8 @@ class TicketController extends Controller
|
||||||
->setLastName($last_name)
|
->setLastName($last_name)
|
||||||
->setContactNumber($contact_num)
|
->setContactNumber($contact_num)
|
||||||
->setStatus($req->request->get('status'))
|
->setStatus($req->request->get('status'))
|
||||||
->setTicketType($ticket_type)
|
//->setTicketType($ticket_type)
|
||||||
->setOtherTicketType($other_ticket_type)
|
//->setOtherTicketType($other_ticket_type)
|
||||||
->setDetails($req->request->get('details'))
|
->setDetails($req->request->get('details'))
|
||||||
->setPlateNumber($req->request->get('plate_number'))
|
->setPlateNumber($req->request->get('plate_number'))
|
||||||
->setSourceOfAwareness($soa_type)
|
->setSourceOfAwareness($soa_type)
|
||||||
|
|
@ -460,9 +483,21 @@ class TicketController extends Controller
|
||||||
$errors = $validator->validate($obj);
|
$errors = $validator->validate($obj);
|
||||||
|
|
||||||
// custom validation for other ticket type
|
// custom validation for other ticket type
|
||||||
if ($ticket_type == TicketType::OTHER && empty($other_ticket_type)) {
|
//if ($ticket_type == TicketType::OTHER && empty($other_ticket_type)) {
|
||||||
$error_array['other_ticket_type'] = 'Ticket type not specified.';
|
// $error_array['other_ticket_type'] = 'Ticket type not specified.';
|
||||||
}
|
//}
|
||||||
|
// get ticket and sub ticket type objects
|
||||||
|
$ttype = $em->getRepository(NewTicketType::class)->find($ttype_id);
|
||||||
|
if (empty($ttype))
|
||||||
|
$error_array['new_ticket_type'] = 'Ticket type not specified.';
|
||||||
|
|
||||||
|
$sub_ttype = $em->getRepository(SubTicketType::class)->find($sub_ttype_id);
|
||||||
|
if (empty($sub_ttype))
|
||||||
|
$error_array['sub_ticket_type'] = 'Sub ticket type not specified.';
|
||||||
|
|
||||||
|
// set the ticket type and sub ticket type for ticket
|
||||||
|
$obj->setNewTicketType($ttype)
|
||||||
|
->setSubTicketType($sub_ttype);
|
||||||
|
|
||||||
// add errors to list
|
// add errors to list
|
||||||
foreach ($errors as $error) {
|
foreach ($errors as $error) {
|
||||||
|
|
@ -508,6 +543,35 @@ class TicketController extends Controller
|
||||||
$response->send();
|
$response->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function generateFormSets(EntityManagerInterface $em)
|
||||||
|
{
|
||||||
|
// get ticket types
|
||||||
|
$ttypes = $em->getRepository(NewTicketType::class)->findBy([], ['name' => 'asc']);
|
||||||
|
$ttypes_set = [];
|
||||||
|
foreach ($ttypes as $ttype)
|
||||||
|
{
|
||||||
|
$ttypes_set[$ttype->getID()] = $ttype->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
// get sub ticket types
|
||||||
|
$sub_ttypes = $em->getRepository(SubTicketType::class)->findBy([], ['name' => 'asc']);
|
||||||
|
$sub_ttypes_set = [];
|
||||||
|
foreach ($sub_ttypes as $sub_ttype)
|
||||||
|
{
|
||||||
|
$sub_ttypes_set[] = [
|
||||||
|
'id' => $sub_ttype->getID(),
|
||||||
|
'name' => $sub_ttype->getName(),
|
||||||
|
'ticket_type_id' => $sub_ttype->getTicketType()->getID(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'new_ticket_types' => $ttypes_set,
|
||||||
|
'sub_ticket_types' => $sub_ttypes_set,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// check if datatable filter is present and append to query
|
// check if datatable filter is present and append to query
|
||||||
protected function setQueryFilters($datatable, &$query, $qb) {
|
protected function setQueryFilters($datatable, &$query, $qb) {
|
||||||
if (isset($datatable['query']['data-rows-search']) && !empty($datatable['query']['data-rows-search'])) {
|
if (isset($datatable['query']['data-rows-search']) && !empty($datatable['query']['data-rows-search'])) {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use App\Ramcar\TicketType;
|
use App\Ramcar\TicketType as LegacyTicketType;
|
||||||
use App\Ramcar\TicketStatus;
|
use App\Ramcar\TicketStatus;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
@ -44,8 +44,7 @@ class Ticket
|
||||||
|
|
||||||
// ticket type
|
// ticket type
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=15)
|
* @ORM\Column(type="string", length=15, nullable=true)
|
||||||
* @Assert\NotBlank()
|
|
||||||
*/
|
*/
|
||||||
protected $ticket_type;
|
protected $ticket_type;
|
||||||
|
|
||||||
|
|
@ -120,6 +119,20 @@ class Ticket
|
||||||
*/
|
*/
|
||||||
protected $remarks;
|
protected $remarks;
|
||||||
|
|
||||||
|
// new ticket type
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity="TicketType", inversedBy="tickets")
|
||||||
|
* @ORM\JoinColumn(name="ticket_type_id", referencedColumnName="id", nullable=true)
|
||||||
|
*/
|
||||||
|
protected $new_ticket_type;
|
||||||
|
|
||||||
|
// sub ticket type
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity="SubTicketType", inversedBy="subtickets")
|
||||||
|
* @ORM\JoinColumn(name="subticket_type_id", referencedColumnName="id", nullable=true)
|
||||||
|
*/
|
||||||
|
protected $subticket_type;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->date_create = new DateTime();
|
$this->date_create = new DateTime();
|
||||||
|
|
@ -182,10 +195,10 @@ class Ticket
|
||||||
|
|
||||||
public function getTicketTypeText()
|
public function getTicketTypeText()
|
||||||
{
|
{
|
||||||
if ($this->ticket_type == TicketType::OTHER) {
|
if ($this->ticket_type == LegacyTicketType::OTHER) {
|
||||||
return $this->other_ticket_type;
|
return $this->other_ticket_type;
|
||||||
} else {
|
} else {
|
||||||
$types = TicketType::getCollection();
|
$types = LegacyTicketType::getCollection();
|
||||||
return $types[$this->ticket_type] ?? "";
|
return $types[$this->ticket_type] ?? "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -300,4 +313,25 @@ class Ticket
|
||||||
return $this->remarks;
|
return $this->remarks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setNewTicketType(TicketType $new_ticket_type = null)
|
||||||
|
{
|
||||||
|
$this->new_ticket_type = $new_ticket_type;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNewTicketType()
|
||||||
|
{
|
||||||
|
return $this->new_ticket_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSubTicketType(SubTicketType $subticket_type = null)
|
||||||
|
{
|
||||||
|
$this->subticket_type = $subticket_type;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSubTicketType()
|
||||||
|
{
|
||||||
|
return $this->subticket_type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,321 +1,378 @@
|
||||||
{% extends 'base.html.twig' %}
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<!-- BEGIN: Subheader -->
|
<!-- BEGIN: Subheader -->
|
||||||
<div class="m-subheader">
|
<div class="m-subheader">
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
<div class="mr-auto">
|
<div class="mr-auto">
|
||||||
<h3 class="m-subheader__title">Tickets</h3>
|
<h3 class="m-subheader__title">Tickets</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- END: Subheader -->
|
||||||
|
<div class="m-content">
|
||||||
|
<!--Begin::Section-->
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xl-10">
|
||||||
|
<div class="m-portlet m-portlet--mobile">
|
||||||
|
<div class="m-portlet__head">
|
||||||
|
<div class="m-portlet__head-caption">
|
||||||
|
<div class="m-portlet__head-title">
|
||||||
|
<span class="m-portlet__head-icon">
|
||||||
|
<i class="fa fa-ticket"></i>
|
||||||
|
</span>
|
||||||
|
<h3 class="m-portlet__head-text">
|
||||||
|
{% if mode == 'update' %}
|
||||||
|
Edit Ticket
|
||||||
|
<small>{{ obj.getID }}</small>
|
||||||
|
{% else %}
|
||||||
|
New Ticket
|
||||||
|
{% if customer %}
|
||||||
|
<small>for {{ customer.getFirstName ~ " " ~ customer.getLastName }}</small>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<form id="row-form" class="m-form m-form--fit m-form--label-align-right" 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="m-form__section m-form__section--first{{ mode == 'create' ? ' m-form__section--last' }}">
|
||||||
|
{% if (mode == 'update') and (obj.getTicketType != null) %}
|
||||||
|
<div class="form-group m-form__group row no-border">
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<label data-field="status">Legacy Ticket Type</label>
|
||||||
|
<select class="form-control m-input" id="ticket-type" name="ticket_type" disabled>
|
||||||
|
<option value=""></option>
|
||||||
|
{% for key, ticket_type in ticket_types %}
|
||||||
|
<option value="{{ key }}"{{ key == obj.getTicketType ? ' selected' }}>{{ ticket_type }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<div class="form-control-feedback hide" data-field="ticket_type"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<label data-field="other_ticket_type">Legacy Other Ticket Type <small>(please specify)</small></label>
|
||||||
|
<input type="text" name="other_ticket_type" id="other-ticket-type" class="form-control m-input" value="{{ obj.getOtherTicketType }}" disabled>
|
||||||
|
<div class="form-control-feedback hide" data-field="other_ticket_type"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="form-group m-form__group row no-border">
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<label data-field="status">Ticket Type</label>
|
||||||
|
<select class="form-control m-input" id="new-ticket-type" name="new_ticket_type">
|
||||||
|
<option value="">Select a ticket type</option>
|
||||||
|
{% for id, label in sets.new_ticket_types %}
|
||||||
|
{% if obj.getNewTicketType %}
|
||||||
|
<option value="{{ id }}"{{ id == obj.getNewTicketType.getID ? ' selected' }}>{{ label }}</option>
|
||||||
|
{% else %}
|
||||||
|
<option value="{{ id }}">{{ label }}</option>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<div class="form-control-feedback hide" data-field="new_ticket_type"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<label data-field="sub_ticket_type">Sub Ticket Type</label>
|
||||||
|
<select class="form-control m-input" id="sub-ticket-type" name="sub_ticket_type">
|
||||||
|
{% if obj.getSubTicketType == null %}
|
||||||
|
<option value="0">Select a ticket type first</option>
|
||||||
|
{% else %}
|
||||||
|
<option value="0">Select a sub-ticket type</option>
|
||||||
|
{% for sub_ttype in sets.sub_ticket_types %}
|
||||||
|
{% if sub_ttype.ticket_type_id == obj.getNewTicketType.getID %}
|
||||||
|
{% if sub_ttype.id == obj.getSubTicketType.getID|default(0) %}
|
||||||
|
<option value="{{ sub_ttype.id }}" selected>{{ sub_ttype.name }}</option>
|
||||||
|
{% else %}
|
||||||
|
<option value="{{ sub_ttype.id }}">{{ sub_ttype.name }}</option>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</select>
|
||||||
|
<div class="form-control-feedback hide" data-field="sub_ticket_type"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group m-form__group row no-border">
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<label data-field="first_name">First Name</label>
|
||||||
|
<input type="text" name="first_name" class="form-control m-input" value="{{ customer and mode == 'create' ? customer.getFirstName : obj.getFirstName }}"{{ customer ? ' disabled' }}>
|
||||||
|
<div class="form-control-feedback hide" data-field="first_name"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<label data-field="last_name">Last Name</label>
|
||||||
|
<input type="text" name="last_name" class="form-control m-input" value="{{ customer and mode == 'create' ? customer.getLastName : obj.getLastName }}"{{ customer ? ' disabled' }}>
|
||||||
|
<div class="form-control-feedback hide" data-field="last_name"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group m-form__group row no-border">
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<label data-field="contact_num">Contact Number</label>
|
||||||
|
<div class="input-group m-input-group">
|
||||||
|
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
|
||||||
|
<input type="text" name="contact_num" class="form-control m-input" value="{{ customer and mode == 'create' and customer.getPhoneMobile is not empty ? customer.getPhoneMobile : obj.getContactNumber }}"{{ customer ? ' disabled' }}>
|
||||||
|
<div class="form-control-feedback hide" data-field="contact_num"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group m-form__group row no-border">
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<label data-field="plate_number">Vehicle Plate Number</label>
|
||||||
|
<input type="text" name="plate_number" class="form-control m-input" value="{{ obj.getPlateNumber }}">
|
||||||
|
<div class="form-control-feedback hide" data-field="plate_number"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group m-form__group row no-border">
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<label data-field="status">Source of Awareness</label>
|
||||||
|
<select class="form-control m-input" id="source-of-awareness" name="source_of_awareness">
|
||||||
|
<option value=""></option>
|
||||||
|
{% for key, soa in soa_types %}
|
||||||
|
<option value="{{ key }}"{{ key == obj.getSourceOfAwareness ? ' selected' }}>{{ soa }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<div class="form-control-feedback hide" data-field="source_of_awareness"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group m-form__group row no-border">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<label for="remarks" data-field="remarks"> Remarks </label>
|
||||||
|
<textarea class="form-control m-input" id="remarks" rows="6" name="remarks">{{ obj.getRemarks }}</textarea>
|
||||||
|
<div class="form-control-feedback hide" data-field="remarks"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group m-form__group row no-border">
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<label data-field="status">Status</label>
|
||||||
|
<select class="form-control m-input" id="status" name="status">
|
||||||
|
{% for key, status in statuses %}
|
||||||
|
<option value="{{ key }}"{{ key == obj.getStatus ? ' selected' }}>{{ status }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<div class="form-control-feedback hide" data-field="status"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group m-form__group row no-border">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<label for="details" data-field="details">
|
||||||
|
Details
|
||||||
|
</label>
|
||||||
|
<textarea class="form-control m-input" id="details" rows="6" name="details">{{ obj.getDetails }}</textarea>
|
||||||
|
<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_all_form', {'id': job_order.getID }) }}" class="btn btn-info">View Job Order</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if mode == 'update' %}
|
||||||
|
<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">
|
||||||
|
Related Tickets
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div class="form-group m-form__group row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="m_datatable" id="data-related-tickets"></div>
|
||||||
|
</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">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<button type="submit" class="btn btn-success">Submit</button>
|
||||||
|
<a href="{{ redirect_url }}" class="btn btn-secondary">Back</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- END: Subheader -->
|
</div>
|
||||||
<div class="m-content">
|
|
||||||
<!--Begin::Section-->
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-xl-10">
|
|
||||||
<div class="m-portlet m-portlet--mobile">
|
|
||||||
<div class="m-portlet__head">
|
|
||||||
<div class="m-portlet__head-caption">
|
|
||||||
<div class="m-portlet__head-title">
|
|
||||||
<span class="m-portlet__head-icon">
|
|
||||||
<i class="fa fa-ticket"></i>
|
|
||||||
</span>
|
|
||||||
<h3 class="m-portlet__head-text">
|
|
||||||
{% if mode == 'update' %}
|
|
||||||
Edit Ticket
|
|
||||||
<small>{{ obj.getID }}</small>
|
|
||||||
{% else %}
|
|
||||||
New Ticket
|
|
||||||
{% if customer %}
|
|
||||||
<small>for {{ customer.getFirstName ~ " " ~ customer.getLastName }}</small>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<form id="row-form" class="m-form m-form--fit m-form--label-align-right" 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="m-form__section m-form__section--first{{ mode == 'create' ? ' m-form__section--last' }}">
|
|
||||||
<div class="form-group m-form__group row no-border">
|
|
||||||
<div class="col-lg-4">
|
|
||||||
<label data-field="status">Ticket Type</label>
|
|
||||||
<select class="form-control m-input" id="ticket-type" name="ticket_type">
|
|
||||||
<option value=""></option>
|
|
||||||
{% for key, ticket_type in ticket_types %}
|
|
||||||
<option value="{{ key }}"{{ key == obj.getTicketType ? ' selected' }}>{{ ticket_type }}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
<div class="form-control-feedback hide" data-field="ticket_type"></div>
|
|
||||||
</div>
|
|
||||||
<div class="col-lg-4">
|
|
||||||
<label data-field="other_ticket_type">Other Ticket Type <small>(please specify)</small></label>
|
|
||||||
<input type="text" name="other_ticket_type" id="other-ticket-type" class="form-control m-input" value="{{ obj.getOtherTicketType }}" disabled>
|
|
||||||
<div class="form-control-feedback hide" data-field="other_ticket_type"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group m-form__group row no-border">
|
|
||||||
<div class="col-lg-4">
|
|
||||||
<label data-field="first_name">First Name</label>
|
|
||||||
<input type="text" name="first_name" class="form-control m-input" value="{{ customer and mode == 'create' ? customer.getFirstName : obj.getFirstName }}"{{ customer ? ' disabled' }}>
|
|
||||||
<div class="form-control-feedback hide" data-field="first_name"></div>
|
|
||||||
</div>
|
|
||||||
<div class="col-lg-4">
|
|
||||||
<label data-field="last_name">Last Name</label>
|
|
||||||
<input type="text" name="last_name" class="form-control m-input" value="{{ customer and mode == 'create' ? customer.getLastName : obj.getLastName }}"{{ customer ? ' disabled' }}>
|
|
||||||
<div class="form-control-feedback hide" data-field="last_name"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group m-form__group row no-border">
|
|
||||||
<div class="col-lg-4">
|
|
||||||
<label data-field="contact_num">Contact Number</label>
|
|
||||||
<div class="input-group m-input-group">
|
|
||||||
<span class="input-group-addon">{% trans %}country_code_prefix{% endtrans %}</span>
|
|
||||||
<input type="text" name="contact_num" class="form-control m-input" value="{{ customer and mode == 'create' and customer.getPhoneMobile is not empty ? customer.getPhoneMobile : obj.getContactNumber }}"{{ customer ? ' disabled' }}>
|
|
||||||
<div class="form-control-feedback hide" data-field="contact_num"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group m-form__group row no-border">
|
|
||||||
<div class="col-lg-4">
|
|
||||||
<label data-field="plate_number">Vehicle Plate Number</label>
|
|
||||||
<input type="text" name="plate_number" class="form-control m-input" value="{{ obj.getPlateNumber }}">
|
|
||||||
<div class="form-control-feedback hide" data-field="plate_number"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group m-form__group row no-border">
|
|
||||||
<div class="col-lg-4">
|
|
||||||
<label data-field="status">Source of Awareness</label>
|
|
||||||
<select class="form-control m-input" id="source-of-awareness" name="source_of_awareness">
|
|
||||||
<option value=""></option>
|
|
||||||
{% for key, soa in soa_types %}
|
|
||||||
<option value="{{ key }}"{{ key == obj.getSourceOfAwareness ? ' selected' }}>{{ soa }}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
<div class="form-control-feedback hide" data-field="source_of_awareness"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group m-form__group row no-border">
|
|
||||||
<div class="col-lg-12">
|
|
||||||
<label for="remarks" data-field="remarks"> Remarks </label>
|
|
||||||
<textarea class="form-control m-input" id="remarks" rows="6" name="remarks">{{ obj.getRemarks }}</textarea>
|
|
||||||
<div class="form-control-feedback hide" data-field="remarks"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group m-form__group row no-border">
|
|
||||||
<div class="col-lg-4">
|
|
||||||
<label data-field="status">Status</label>
|
|
||||||
<select class="form-control m-input" id="status" name="status">
|
|
||||||
{% for key, status in statuses %}
|
|
||||||
<option value="{{ key }}"{{ key == obj.getStatus ? ' selected' }}>{{ status }}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
<div class="form-control-feedback hide" data-field="status"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group m-form__group row no-border">
|
|
||||||
<div class="col-lg-12">
|
|
||||||
<label for="details" data-field="details">
|
|
||||||
Details
|
|
||||||
</label>
|
|
||||||
<textarea class="form-control m-input" id="details" rows="6" name="details">{{ obj.getDetails }}</textarea>
|
|
||||||
<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_all_form', {'id': job_order.getID }) }}" class="btn btn-info">View Job Order</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if mode == 'update' %}
|
|
||||||
<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">
|
|
||||||
Related Tickets
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
<div class="form-group m-form__group row">
|
|
||||||
<div class="col-lg-12">
|
|
||||||
<div class="m_datatable" id="data-related-tickets"></div>
|
|
||||||
</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">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-12">
|
|
||||||
<button type="submit" class="btn btn-success">Submit</button>
|
|
||||||
<a href="{{ redirect_url }}" class="btn btn-secondary">Back</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
$("#row-form").submit(function(e) {
|
$("#row-form").submit(function(e) {
|
||||||
var form = $(this);
|
var form = $(this);
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: form.prop('action'),
|
url: form.prop('action'),
|
||||||
data: form.serialize()
|
data: form.serialize()
|
||||||
}).done(function(response) {
|
}).done(function(response) {
|
||||||
// remove all error classes
|
// remove all error classes
|
||||||
removeErrors();
|
removeErrors();
|
||||||
swal({
|
swal({
|
||||||
title: 'Done!',
|
title: 'Done!',
|
||||||
text: 'Your changes have been saved!',
|
text: 'Your changes have been saved!',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
onClose: function() {
|
onClose: function() {
|
||||||
window.location.href = "{{ redirect_url }}";
|
window.location.href = "{{ redirect_url }}";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).fail(function(response) {
|
}).fail(function(response) {
|
||||||
if (response.status == 422) {
|
if (response.status == 422) {
|
||||||
var errors = response.responseJSON.errors;
|
var errors = response.responseJSON.errors;
|
||||||
var firstfield = false;
|
var firstfield = false;
|
||||||
|
|
||||||
// remove all error classes first
|
// remove all error classes first
|
||||||
removeErrors();
|
removeErrors();
|
||||||
|
|
||||||
// display errors contextually
|
// display errors contextually
|
||||||
$.each(errors, function(field, msg) {
|
$.each(errors, function(field, msg) {
|
||||||
var formfield = $("[name='" + field + "']");
|
var formfield = $("[name='" + field + "']");
|
||||||
var label = $("label[data-field='" + field + "']");
|
var label = $("label[data-field='" + field + "']");
|
||||||
var msgbox = $(".form-control-feedback[data-field='" + field + "']");
|
var msgbox = $(".form-control-feedback[data-field='" + field + "']");
|
||||||
|
|
||||||
// add error classes to bad fields
|
// add error classes to bad fields
|
||||||
formfield.addClass('form-control-danger');
|
formfield.addClass('form-control-danger');
|
||||||
label.addClass('has-danger');
|
label.addClass('has-danger');
|
||||||
msgbox.html(msg).addClass('has-danger').removeClass('hide');
|
msgbox.html(msg).addClass('has-danger').removeClass('hide');
|
||||||
|
|
||||||
// check if this field comes first in DOM
|
// check if this field comes first in DOM
|
||||||
var domfield = formfield.get(0);
|
var domfield = formfield.get(0);
|
||||||
|
|
||||||
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
|
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
|
||||||
firstfield = domfield;
|
firstfield = domfield;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// focus on first bad field
|
// focus on first bad field
|
||||||
firstfield.focus();
|
firstfield.focus();
|
||||||
|
|
||||||
// scroll to above that field to make it visible
|
// scroll to above that field to make it visible
|
||||||
$('html, body').animate({
|
$('html, body').animate({
|
||||||
scrollTop: $(firstfield).offset().top - 200
|
scrollTop: $(firstfield).offset().top - 200
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// remove all error classes
|
// remove all error classes
|
||||||
function removeErrors() {
|
function removeErrors() {
|
||||||
$(".form-control-danger").removeClass('form-control-danger');
|
$(".form-control-danger").removeClass('form-control-danger');
|
||||||
$("[data-field]").removeClass('has-danger');
|
$("[data-field]").removeClass('has-danger');
|
||||||
$(".form-control-feedback[data-field]").addClass('hide');
|
$(".form-control-feedback[data-field]").addClass('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
// toggle other ticket type field
|
// toggle other ticket type field
|
||||||
$("#ticket-type").change(function() {
|
$("#ticket-type").change(function() {
|
||||||
var field = $("#other-ticket-type");
|
var field = $("#other-ticket-type");
|
||||||
|
|
||||||
if ($(this).val() == '{{ other_ticket_type }}') {
|
if ($(this).val() == '{{ other_ticket_type }}') {
|
||||||
field.prop('disabled', false);
|
field.prop('disabled', false);
|
||||||
} else {
|
} else {
|
||||||
field.prop('disabled', true).val("");
|
field.prop('disabled', true).val("");
|
||||||
}
|
}
|
||||||
}).change();
|
}).change();
|
||||||
|
|
||||||
{% if mode == 'update' %}
|
{% if mode == 'update' %}
|
||||||
// related tickets
|
// related tickets
|
||||||
var ticketRows = [];
|
var ticketRows = [];
|
||||||
|
|
||||||
{% for ticket in related_tickets %}
|
{% for ticket in related_tickets %}
|
||||||
trow = {
|
trow = {
|
||||||
id: "{{ ticket.getID }}",
|
id: "{{ ticket.getID }}",
|
||||||
date_create: "{{ ticket.getDateCreate|date('d M Y - h:i A') }}",
|
date_create: "{{ ticket.getDateCreate|date('d M Y - h:i A') }}",
|
||||||
ticket_type: "{{ ticket.getTicketTypeText }}",
|
ticket_type: "{{ ticket.getTicketTypeText }}",
|
||||||
status: "{{ ticket.getStatusText }}",
|
status: "{{ ticket.getStatusText }}",
|
||||||
edit_url: "{{ url('ticket_update', {'id': ticket.getID}) }}"
|
edit_url: "{{ url('ticket_update', {'id': ticket.getID}) }}"
|
||||||
};
|
};
|
||||||
|
|
||||||
ticketRows.push(trow);
|
ticketRows.push(trow);
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
// tickets data table
|
// tickets data table
|
||||||
var ticketOptions = {
|
var ticketOptions = {
|
||||||
data: {
|
data: {
|
||||||
type: 'local',
|
type: 'local',
|
||||||
source: ticketRows,
|
source: ticketRows,
|
||||||
saveState: {
|
saveState: {
|
||||||
cookie: false,
|
cookie: false,
|
||||||
webstorage: false
|
webstorage: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
layout: {
|
layout: {
|
||||||
scroll: true
|
scroll: true
|
||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
field: 'id',
|
field: 'id',
|
||||||
title: 'ID',
|
title: 'ID',
|
||||||
width: 30
|
width: 30
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'date_create',
|
field: 'date_create',
|
||||||
title: 'Date Created',
|
title: 'Date Created',
|
||||||
width: 200
|
width: 200
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'ticket_type',
|
field: 'ticket_type',
|
||||||
title: 'Ticket Type'
|
title: 'Ticket Type'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'status',
|
field: 'status',
|
||||||
title: 'Status'
|
title: 'Status'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'Actions',
|
field: 'Actions',
|
||||||
width: 70,
|
width: 70,
|
||||||
title: 'Actions',
|
title: 'Actions',
|
||||||
sortable: false,
|
sortable: false,
|
||||||
overflow: 'visible',
|
overflow: 'visible',
|
||||||
template: function (row, index, datatable) {
|
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>';
|
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
|
pagination: false
|
||||||
};
|
};
|
||||||
|
|
||||||
var ticketTable = $("#data-related-tickets").mDatatable(ticketOptions);
|
var ticketTable = $("#data-related-tickets").mDatatable(ticketOptions);
|
||||||
{% endif %}
|
{% endif %}
|
||||||
});
|
});
|
||||||
</script>
|
|
||||||
|
var subticket_type_list = {{ sets.sub_ticket_types|json_encode|raw }};
|
||||||
|
|
||||||
|
// populate sub ticket type field
|
||||||
|
$('form').on('change', '#new-ticket-type', function() {
|
||||||
|
console.log('ticket type change');
|
||||||
|
var ticket_type_id = $(this).val();
|
||||||
|
|
||||||
|
// build options for sub ticket type based on selected ticket type
|
||||||
|
var options = '<option value="0">Select sub ticket type</option>';
|
||||||
|
for (var i in subticket_type_list) {
|
||||||
|
if (subticket_type_list[i].ticket_type_id == ticket_type_id) {
|
||||||
|
options += '<option value="' + subticket_type_list[i].id + '">' + subticket_type_list[i].name + '</option>'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#sub-ticket-type').html(options);
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue