Initial commit for job order tier 1 / incoming form
This commit is contained in:
parent
794be3bccf
commit
36627d713d
7 changed files with 759 additions and 1 deletions
|
|
@ -7,6 +7,16 @@ customer_rows:
|
||||||
controller: App\Controller\CustomerController::rows
|
controller: App\Controller\CustomerController::rows
|
||||||
methods: [POST]
|
methods: [POST]
|
||||||
|
|
||||||
|
customer_vehicle_search:
|
||||||
|
path: /customers/vehicles
|
||||||
|
controller: App\Controller\CustomerController::getCustomerVehicles
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
customer_vehicle_info:
|
||||||
|
path: /customers/vehicle-info
|
||||||
|
controller: App\Controller\CustomerController::getCustomerVehicleInfo
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
customer_create:
|
customer_create:
|
||||||
path: /customers/create
|
path: /customers/create
|
||||||
controller: App\Controller\CustomerController::addForm
|
controller: App\Controller\CustomerController::addForm
|
||||||
|
|
@ -31,4 +41,3 @@ customer_delete:
|
||||||
path: /customers/{id}
|
path: /customers/{id}
|
||||||
controller: App\Controller\CustomerController::destroy
|
controller: App\Controller\CustomerController::destroy
|
||||||
methods: [DELETE]
|
methods: [DELETE]
|
||||||
|
|
||||||
|
|
|
||||||
19
config/routes/job_order.yaml
Normal file
19
config/routes/job_order.yaml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
jo_in:
|
||||||
|
path: /job-order/incoming
|
||||||
|
controller: App\Controller\JobOrderController::incomingForm
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
jo_proc:
|
||||||
|
path: /job-order/processing
|
||||||
|
controller: App\Controller\JobOrderController::processingForm
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
jo_in_submit:
|
||||||
|
path: /job-order/incoming
|
||||||
|
controller: App\Controller\JobOrderController::incomingSubmit
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
jo_proc_submit:
|
||||||
|
path: /job-order/processing
|
||||||
|
controller: App\Controller\JobOrderController::processingSubmit
|
||||||
|
methods: [POST]
|
||||||
|
|
@ -30,6 +30,21 @@ span.has-danger,
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.flex-row.m-form__heading {
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-row.m-form__heading label {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-row.m-form__heading > * + * {
|
||||||
|
border-left: 1px solid #EBEDF2;
|
||||||
|
margin-left: 16px;
|
||||||
|
padding-left: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
.form-group-inner {
|
.form-group-inner {
|
||||||
padding-left: 0 !important;
|
padding-left: 0 !important;
|
||||||
padding-right: 0 !important;
|
padding-right: 0 !important;
|
||||||
|
|
@ -66,6 +81,11 @@ span.has-danger,
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.select2-selection {
|
||||||
|
font-size: 1rem !important;
|
||||||
|
font-weight: 300 !important;
|
||||||
|
}
|
||||||
|
|
||||||
@media (min-width: 995px) {
|
@media (min-width: 995px) {
|
||||||
.modal-lg {
|
.modal-lg {
|
||||||
max-width: 1024px;
|
max-width: 1024px;
|
||||||
|
|
|
||||||
|
|
@ -537,6 +537,156 @@ class CustomerController extends BaseController
|
||||||
return range($start_year, date("Y") + 1);
|
return range($start_year, date("Y") + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCustomerVehicles(Request $req)
|
||||||
|
{
|
||||||
|
if (!$this->isGranted('jo_in.list')) {
|
||||||
|
$exception = $this->createAccessDeniedException('No access.');
|
||||||
|
throw $exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get search term
|
||||||
|
$term = $req->query->get('search');
|
||||||
|
|
||||||
|
// get querybuilder
|
||||||
|
$qb = $this->getDoctrine()
|
||||||
|
->getRepository(CustomerVehicle::class)
|
||||||
|
->createQueryBuilder('q');
|
||||||
|
|
||||||
|
// build expression now since we're reusing it
|
||||||
|
$vehicle_label = $qb->expr()->concat('q.plate_number', $qb->expr()->literal(' - '), 'c.first_name', $qb->expr()->literal(' '), 'c.last_name');
|
||||||
|
|
||||||
|
// count total records
|
||||||
|
$tquery = $qb->select('COUNT(q)')
|
||||||
|
->join('q.customer', 'c');
|
||||||
|
|
||||||
|
// add filters to count query
|
||||||
|
if (!empty($term)) {
|
||||||
|
$tquery->where($vehicle_label . ' LIKE :filter')
|
||||||
|
->setParameter('filter', '%' . $term . '%');
|
||||||
|
}
|
||||||
|
|
||||||
|
$total = $tquery->getQuery()
|
||||||
|
->getSingleScalarResult();
|
||||||
|
|
||||||
|
// pagination vars
|
||||||
|
$page = $req->query->get('page') ?? 1;
|
||||||
|
$perpage = 20;
|
||||||
|
$offset = ($page - 1) * $perpage;
|
||||||
|
$pages = ceil($total / $perpage);
|
||||||
|
$has_more_pages = $page < $pages ? true : false;
|
||||||
|
|
||||||
|
// build main query
|
||||||
|
$query = $qb->select('q')
|
||||||
|
->addSelect($vehicle_label . ' as vehicle_label')
|
||||||
|
->addSelect('c.first_name as cust_first_name')
|
||||||
|
->addSelect('c.last_name as cust_last_name');
|
||||||
|
|
||||||
|
// add filters if needed
|
||||||
|
if (!empty($term)) {
|
||||||
|
$query->where($vehicle_label . ' LIKE :filter')
|
||||||
|
->setParameter('filter', '%' . $term . '%');
|
||||||
|
}
|
||||||
|
|
||||||
|
// get rows
|
||||||
|
$obj_rows = $query->orderBy('q.plate_number', 'asc')
|
||||||
|
->setFirstResult($offset)
|
||||||
|
->setMaxResults($perpage)
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
// build vehicles array
|
||||||
|
$vehicles = [];
|
||||||
|
|
||||||
|
foreach ($obj_rows as $vehicle) {
|
||||||
|
$vehicles[] = [
|
||||||
|
'id' => $vehicle[0]->getID(),
|
||||||
|
'text' => $vehicle['vehicle_label']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $this->json([
|
||||||
|
'success' => true,
|
||||||
|
'results' => $vehicles,
|
||||||
|
'pagination' => [
|
||||||
|
'more' => $has_more_pages
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCustomerVehicleInfo(Request $req)
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('jo_in.list', null, 'No access.');
|
||||||
|
|
||||||
|
// get id
|
||||||
|
$id = $req->query->get('id');
|
||||||
|
|
||||||
|
// get row data
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$obj = $em->getRepository(CustomerVehicle::class)->find($id);
|
||||||
|
|
||||||
|
// make sure this row exists
|
||||||
|
if (empty($obj)) {
|
||||||
|
return $this->json([
|
||||||
|
'success' => false,
|
||||||
|
'error' => 'The item does not exist'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$customer = $obj->getCustomer();
|
||||||
|
$vehicle = $obj->getVehicle();
|
||||||
|
$battery = $obj->getCurrentBattery();
|
||||||
|
|
||||||
|
// get all mobile numbers
|
||||||
|
$mobile_numbers = [];
|
||||||
|
|
||||||
|
foreach ($customer->getMobileNumbers() as $number) {
|
||||||
|
$mobile_numbers[] = $number->getID();
|
||||||
|
}
|
||||||
|
|
||||||
|
// build response
|
||||||
|
$row = [
|
||||||
|
'customer' => [
|
||||||
|
'id' => $customer->getID(),
|
||||||
|
'first_name' => $customer->getFirstName(),
|
||||||
|
'last_name' => $customer->getLastName(),
|
||||||
|
'mobile_numbers' => $mobile_numbers
|
||||||
|
],
|
||||||
|
'vehicle' => [
|
||||||
|
'id' => $vehicle->getID(),
|
||||||
|
'mfg_name' => $vehicle->getManufacturer()->getName(),
|
||||||
|
'make' => $vehicle->getMake(),
|
||||||
|
'model_year_from' => $vehicle->getModelYearFrom(),
|
||||||
|
'model_year_to' => $vehicle->getModelYearTo(),
|
||||||
|
'model_year' => $obj->getModelYear(),
|
||||||
|
'color' => $obj->getColor(),
|
||||||
|
//'plate_number' => $obj->getPlateNumber(),
|
||||||
|
//'fuel_type' => $obj->getFuelType(),
|
||||||
|
//'status_condition' => $obj->getStatusCondition(),
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!empty($battery)) {
|
||||||
|
$row['battery'] = [
|
||||||
|
'id' => $battery->getID(),
|
||||||
|
'mfg_name' => $battery->getManufacturer()->getName(),
|
||||||
|
'model_name' => $battery->getModel()->getName(),
|
||||||
|
'size_name' => $battery->getSize()->getName(),
|
||||||
|
'prod_code' => $battery->getProductCode(),
|
||||||
|
'warranty_code' => $obj->getWarrantyCode(),
|
||||||
|
'warranty_expiration' => $obj->getWarrantyExpiration() ? $obj->getWarrantyExpiration()->format("d M Y") : "",
|
||||||
|
'has_motolite_battery' => $obj->hasMotoliteBattery(),
|
||||||
|
'is_active' => $obj->isActive()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $this->json([
|
||||||
|
'success' => true,
|
||||||
|
'data' => $row
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// 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) {
|
protected function setQueryFilters($datatable, &$query) {
|
||||||
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'])) {
|
||||||
|
|
|
||||||
75
src/Controller/JobOrderController.php
Normal file
75
src/Controller/JobOrderController.php
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Ramcar\BaseController;
|
||||||
|
use App\Ramcar\ServiceType;
|
||||||
|
use App\Ramcar\JOStatus;
|
||||||
|
use App\Entity\JobOrder;
|
||||||
|
use App\Entity\Customer;
|
||||||
|
use App\Entity\CustomerVehicle;
|
||||||
|
use App\Entity\Outlet;
|
||||||
|
use App\Entity\Rider;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Query;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
|
|
||||||
|
use App\Menu\Generator as MenuGenerator;
|
||||||
|
use App\Access\Generator as ACLGenerator;
|
||||||
|
|
||||||
|
class JobOrderController extends BaseController
|
||||||
|
{
|
||||||
|
protected $acl_gen;
|
||||||
|
|
||||||
|
public function __construct(MenuGenerator $menu_gen, ACLGenerator $acl_gen)
|
||||||
|
{
|
||||||
|
$this->acl_gen = $acl_gen;
|
||||||
|
parent::__construct($menu_gen);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function incomingForm()
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('jo_in.list', null, 'No access.');
|
||||||
|
|
||||||
|
$params = $this->initParameters('jo_in');
|
||||||
|
$params['obj'] = new JobOrder();
|
||||||
|
$params['mode'] = 'create';
|
||||||
|
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
// get parent associations
|
||||||
|
$params['customers'] = $em->getRepository(Customer::class)->findAll();
|
||||||
|
$params['outlet'] = $em->getRepository(Outlet::class)->findAll();
|
||||||
|
$params['rider'] = $em->getRepository(Rider::class)->findAll();
|
||||||
|
$params['service_types'] = ServiceType::getCollection();
|
||||||
|
$params['statuses'] = JOStatus::getCollection();
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $this->render('job-order/incoming.html.twig', $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function incomingSubmit(Request $req)
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('jo_in.list', null, 'No access.');
|
||||||
|
|
||||||
|
// create new row
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$row = new JobOrder();
|
||||||
|
|
||||||
|
// TODO: Validation, handling of job order
|
||||||
|
|
||||||
|
// DEBUG: Get all variables
|
||||||
|
error_log(print_r($req->request->all(), true));
|
||||||
|
|
||||||
|
// DEBUG: Fake error array
|
||||||
|
$error_array = [];
|
||||||
|
|
||||||
|
// DEBUG: Error response for now
|
||||||
|
return $this->json([
|
||||||
|
'success' => false,
|
||||||
|
'errors' => $error_array
|
||||||
|
], 422);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -113,6 +113,18 @@ class JobOrder
|
||||||
*/
|
*/
|
||||||
protected $status;
|
protected $status;
|
||||||
|
|
||||||
|
// delivery instructions
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="text", nullable=true)
|
||||||
|
*/
|
||||||
|
protected $delivery_instructions;
|
||||||
|
|
||||||
|
// agent notes
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="text", nullable=true)
|
||||||
|
*/
|
||||||
|
protected $agent_notes;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->date_create = new DateTime();
|
$this->date_create = new DateTime();
|
||||||
|
|
@ -258,4 +270,37 @@ class JobOrder
|
||||||
{
|
{
|
||||||
return $this->source;
|
return $this->source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setStatus($status)
|
||||||
|
{
|
||||||
|
$this->status = $status;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStatus()
|
||||||
|
{
|
||||||
|
return $this->status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDeliveryInstructions($delivery_instructions)
|
||||||
|
{
|
||||||
|
$this->delivery_instructions = $delivery_instructions;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDeliveryInstructions()
|
||||||
|
{
|
||||||
|
return $this->delivery_instructions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAgentNotes($agent_notes)
|
||||||
|
{
|
||||||
|
$this->agent_notes = $agent_notes;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAgentNotes()
|
||||||
|
{
|
||||||
|
return $this->agent_notes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
440
templates/job-order/incoming.html.twig
Normal file
440
templates/job-order/incoming.html.twig
Normal file
|
|
@ -0,0 +1,440 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<!-- BEGIN: Subheader -->
|
||||||
|
<div class="m-subheader">
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<div class="mr-auto">
|
||||||
|
<h3 class="m-subheader__title">Job Order</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- END: Subheader -->
|
||||||
|
<div class="m-content">
|
||||||
|
<!--Begin::Section-->
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xl-12">
|
||||||
|
<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="flaticon-transport"></i>
|
||||||
|
</span>
|
||||||
|
<h3 class="m-portlet__head-text">
|
||||||
|
Incoming
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<form id="row-form" class="m-form m-form--fit m-form--label-align-right" method="post" action="{{ url('jo_in_submit') }}">
|
||||||
|
<div class="m-portlet__body">
|
||||||
|
<div class="m-form__section m-form__section--first">
|
||||||
|
<div class="m-form__heading">
|
||||||
|
<h3 class="m-form__heading-title">
|
||||||
|
Customer & Vehicle Details
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div class="form-group m-form__group row">
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<label>Select a vehicle:</label>
|
||||||
|
<select class="form-control m-select2" id="customer-vehicle" name="customer_vehicle"></select>
|
||||||
|
<div class="form-control-feedback hide" data-field="customer_vehicle"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<label>Vehicle Manufacturer:</label>
|
||||||
|
<input type="text" name="vmfg" id="vmfg" class="form-control m-input" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||||
|
<div class="form-control-feedback hide" data-field="vmfg"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<label>Vehicle Model:</label>
|
||||||
|
<input type="text" name="vehicle_model" id="vehicle-model" class="form-control m-input" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||||
|
<div class="form-control-feedback hide" data-field="vehicle_model"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<label>Vehicle Model Year:</label>
|
||||||
|
<input type="text" name="vehicle_year" id="vehicle-year" class="form-control m-input" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||||
|
<div class="form-control-feedback hide" data-field="vehicle_year"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group m-form__group row">
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<label>Vehicle Color:</label>
|
||||||
|
<input type="text" name="vehicle_color" id="vehicle-color" class="form-control m-input" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||||
|
<div class="form-control-feedback hide" data-field="vehicle_color"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<label>Current Battery:</label>
|
||||||
|
<input type="text" name="current_battery" id="current-battery" class="form-control m-input" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||||
|
<div class="form-control-feedback hide" data-field="current_battery"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<label>Warranty Code:</label>
|
||||||
|
<input type="text" name="warranty_code" id="warranty-code" class="form-control m-input" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||||
|
<div class="form-control-feedback hide" data-field="warranty_code"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<label>Warranty Expiration Date:</label>
|
||||||
|
<input type="text" name="warranty_expiration" id="warranty-expiration" class="form-control m-input" placeholder="Select a vehicle first" data-vehicle-field="1" disabled>
|
||||||
|
<div class="form-control-feedback hide" data-field="warranty_expiration"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="m-form__seperator m-form__seperator--dashed"></div>
|
||||||
|
<div class="m-form__section m-form__section">
|
||||||
|
<div class="m-form__heading flex-row">
|
||||||
|
<h3 class="m-form__heading-title">
|
||||||
|
Transaction Details
|
||||||
|
</h3>
|
||||||
|
<span class="m-switch m-switch--icon block-switch">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" name="flag_advance" id="flag-advance" value="1">
|
||||||
|
<label class="switch-label">This is an advance order</label>
|
||||||
|
<span></span>
|
||||||
|
</label>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="form-group m-form__group row">
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<label>Transaction Date:</label>
|
||||||
|
<input type="text" name="date_transaction" class="form-control m-input" value="{{ "now"|date('d M Y') }}" readonly>
|
||||||
|
<div class="form-control-feedback hide" data-field="date_transaction"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<label>Service Type:</label>
|
||||||
|
<select class="form-control m-input" name="service_type">
|
||||||
|
<!--<option value=""></option>-->
|
||||||
|
{% for key, service in service_types %}
|
||||||
|
<option value="{{ key }}"{{ obj.getServiceType() == service ? ' selected' }}>{{ service }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<div class="form-control-feedback hide" data-field="service_type"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<label>Scheduled Date:</label>
|
||||||
|
<div class="input-group date dp">
|
||||||
|
<input type="text" name="date_schedule_date" class="form-control m-input" data-default-value="{{ obj.getDateSchedule()|date('Y-m-d') }}" value="{{ obj.getDateSchedule()|date('d M Y') }}" readonly placeholder="Select a date" disabled>
|
||||||
|
<span class="input-group-addon">
|
||||||
|
<i class="la la-calendar glyphicon-th"></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="form-control-feedback hide" data-field="date_schedule_date"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<label>Scheduled Time:</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="text" name="date_schedule_time" class="form-control m-input tp" data-default-value="{{ obj.getDateSchedule()|date('g:i A') }}" value="{{ obj.getDateSchedule()|date('g:i A') }}" readonly placeholder="Select a time" disabled>
|
||||||
|
<span class="input-group-addon">
|
||||||
|
<i class="la la-clock-o glyphicon-th"></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="form-control-feedback hide" data-field="date_schedule_time"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group m-form__group row">
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<label>Status:</label>
|
||||||
|
<select class="form-control m-input" name="status">
|
||||||
|
<!--<option value=""></option>-->
|
||||||
|
{% for key, status in statuses %}
|
||||||
|
<option value="{{ key }}"{{ obj.getStatus() == status ? ' selected' }}>{{ status }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<div class="form-control-feedback hide" data-field="status"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<label>Delivery Instructions:</label>
|
||||||
|
<textarea name="delivery_instructions" class="form-control m-input" rows="4"></textarea>
|
||||||
|
<div class="form-control-feedback hide" data-field="delivery_instructions"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<label>Agent Notes:</label>
|
||||||
|
<textarea name="agent_notes" class="form-control m-input" rows="4"></textarea>
|
||||||
|
<div class="form-control-feedback hide" data-field="agent_notes"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="m-form__seperator m-form__seperator--dashed"></div>
|
||||||
|
<div class="m-form__section">
|
||||||
|
<div class="m-form__heading">
|
||||||
|
<h3 class="m-form__heading-title">
|
||||||
|
Coordinates
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div class="form-group m-form__group row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<input type="hidden" id="map_lat" name="coord_lat" value="">
|
||||||
|
<input type="hidden" id="map_lng" name="coord_lng" value="">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="text" class="form-control" id="m_gmap_address" placeholder="Search">
|
||||||
|
<span class="input-group-btn">
|
||||||
|
<button class="btn btn-primary" id="m_gmap_btn">
|
||||||
|
<i class="fa fa-search"></i>
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div id="m_gmap" style="height:600px;"></div>
|
||||||
|
<div class="form-control-feedback hide" data-field="coordinates"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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">
|
||||||
|
Invoice
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</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="{{ url('jo_in') }}" class="btn btn-secondary">Cancel</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
<script src="//maps.google.com/maps/api/js?key={{ gmaps_api_key }}" type="text/javascript"></script>
|
||||||
|
<script src="/assets/vendors/custom/gmaps/gmaps.js" type="text/javascript"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(function() {
|
||||||
|
// BEGIN google maps stuff
|
||||||
|
function selectPoint(map, latlng) {
|
||||||
|
var lat = latlng.lat();
|
||||||
|
var lng = latlng.lng();
|
||||||
|
|
||||||
|
// show it in map
|
||||||
|
map.removeMarkers();
|
||||||
|
map.setCenter(lat, lng);
|
||||||
|
map.addMarker({
|
||||||
|
lat: lat,
|
||||||
|
lng: lng
|
||||||
|
});
|
||||||
|
|
||||||
|
// set value in hidden input
|
||||||
|
$('#map_lat').val(lat);
|
||||||
|
$('#map_lng').val(lng);
|
||||||
|
}
|
||||||
|
|
||||||
|
var map = new GMaps({
|
||||||
|
div: '#m_gmap',
|
||||||
|
lat: 14.6091,
|
||||||
|
lng: 121.0223,
|
||||||
|
click: function(e) {
|
||||||
|
// handle click in map
|
||||||
|
selectPoint(map, e.latLng);
|
||||||
|
e.stop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var handleAction = function() {
|
||||||
|
var text = $.trim($('#m_gmap_address').val());
|
||||||
|
GMaps.geocode({
|
||||||
|
address: text,
|
||||||
|
callback: function(results, status) {
|
||||||
|
map.removeMarkers();
|
||||||
|
if (status == 'OK') {
|
||||||
|
selectPoint(map, results[0].geometry.location);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
region: 'ph'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#m_gmap_btn').click(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
handleAction();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#m_gmap_address").keypress(function(e) {
|
||||||
|
var keycode = (e.keyCode ? e.keyCode : e.which);
|
||||||
|
if (keycode == '13') {
|
||||||
|
e.preventDefault();
|
||||||
|
handleAction();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// check if we need to set map
|
||||||
|
{% if mode == 'update' %}
|
||||||
|
var latlng = new google.maps.LatLng({{ obj.getCoordinates.getLatitude }}, {{ obj.getCoordinates.getLongitude }});
|
||||||
|
selectPoint(map, latlng);
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
// END google maps stuff
|
||||||
|
|
||||||
|
$("#row-form").submit(function(e) {
|
||||||
|
var form = $(this);
|
||||||
|
|
||||||
|
// get all fields, including disabled ones
|
||||||
|
var disabled = form.find(":input:disabled").prop('disabled', false);
|
||||||
|
var fields = form.serializeArray().map(function(x){this[x.name] = x.value; return this;}.bind({}))[0];
|
||||||
|
disabled.prop('disabled', true);
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
method: "POST",
|
||||||
|
url: form.prop('action'),
|
||||||
|
data: fields
|
||||||
|
}).done(function(response) {
|
||||||
|
// remove all error classes
|
||||||
|
removeErrors();
|
||||||
|
swal({
|
||||||
|
title: 'Done!',
|
||||||
|
text: 'Your changes have been saved!',
|
||||||
|
type: 'success',
|
||||||
|
onClose: function() {
|
||||||
|
window.location.href = "{{ url('jo_in') }}";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).fail(function(response) {
|
||||||
|
var errors = response.responseJSON.errors;
|
||||||
|
var firstfield = false;
|
||||||
|
|
||||||
|
// remove all error classes first
|
||||||
|
removeErrors();
|
||||||
|
|
||||||
|
// display errors contextually
|
||||||
|
$.each(errors, function(field, msg) {
|
||||||
|
var formfield = $("[name='" + field + "']");
|
||||||
|
var label = $("label[data-field='" + field + "']");
|
||||||
|
var msgbox = $(".form-control-feedback[data-field='" + field + "']");
|
||||||
|
|
||||||
|
// add error classes to bad fields
|
||||||
|
formfield.addClass('form-control-danger');
|
||||||
|
label.addClass('has-danger');
|
||||||
|
msgbox.html(msg).addClass('has-danger').removeClass('hide');
|
||||||
|
|
||||||
|
// check if this field comes first in DOM
|
||||||
|
var domfield = formfield.get(0);
|
||||||
|
|
||||||
|
if (!firstfield || (firstfield && firstfield.compareDocumentPosition(domfield) === 2)) {
|
||||||
|
firstfield = domfield;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// focus on first bad field
|
||||||
|
firstfield.focus();
|
||||||
|
|
||||||
|
// scroll to above that field to make it visible
|
||||||
|
$('html, body').animate({
|
||||||
|
scrollTop: $(firstfield).offset().top - 200
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// remove all error classes
|
||||||
|
function removeErrors() {
|
||||||
|
$(".form-control-danger").removeClass('form-control-danger');
|
||||||
|
$("[data-field]").removeClass('has-danger');
|
||||||
|
$(".form-control-feedback[data-field]").addClass('hide');
|
||||||
|
}
|
||||||
|
|
||||||
|
// store selected vehicle data
|
||||||
|
var vdata;
|
||||||
|
|
||||||
|
// vehicle selector
|
||||||
|
$('#customer-vehicle').select2({
|
||||||
|
ajax: {
|
||||||
|
url: "{{ url('customer_vehicle_search') }}",
|
||||||
|
dataType: 'json',
|
||||||
|
delay: 200,
|
||||||
|
data: function (params) {
|
||||||
|
var query = {
|
||||||
|
search: params.term,
|
||||||
|
page: params.page || 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
placeholder: "Select a vehicle"
|
||||||
|
}).on('select2:select', function(e) {
|
||||||
|
var data = e.params.data;
|
||||||
|
|
||||||
|
// get info for this customer vehicle
|
||||||
|
$.ajax({
|
||||||
|
method: "GET",
|
||||||
|
url: "{{ url('customer_vehicle_info') }}",
|
||||||
|
data: { id: data.id }
|
||||||
|
}).done(function(response) {
|
||||||
|
vdata = response.data;
|
||||||
|
|
||||||
|
// reset vehicle fields
|
||||||
|
resetVehicleFields();
|
||||||
|
|
||||||
|
// set form fields
|
||||||
|
$("#vmfg").val(vdata.vehicle.mfg_name);
|
||||||
|
$("#vehicle-model").val(vdata.vehicle.make);
|
||||||
|
$("#vehicle-year").val(vdata.vehicle.model_year);
|
||||||
|
$("#vehicle-color").val(vdata.vehicle.color);
|
||||||
|
|
||||||
|
if (typeof vdata.battery !== 'undefined') {
|
||||||
|
$("#current-battery").val(vdata.battery.mfg_name + " " + vdata.battery.model_name + " " + vdata.battery.size_name + " (" + vdata.battery.prod_code + ")");
|
||||||
|
$("#warranty-code").val(vdata.battery.warranty_code);
|
||||||
|
$("#warranty-expiration").val(vdata.battery.warranty_expiration);
|
||||||
|
} else {
|
||||||
|
$("#current-battery, #warranty-code, #warranty-expiration").val("No current battery").css('color', '#f4516c');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}).focus();
|
||||||
|
|
||||||
|
// reset all vehicle info form fields
|
||||||
|
function resetVehicleFields() {
|
||||||
|
$("[data-vehicle-field='1']").val("").css('color', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
// datepicker
|
||||||
|
$(".dp").datepicker({
|
||||||
|
format: "dd M yyyy",
|
||||||
|
todayHighlight: true,
|
||||||
|
autoclose: true,
|
||||||
|
pickerPosition: 'bottom-left',
|
||||||
|
bootcssVer: 3,
|
||||||
|
clearBtn: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// timepicker
|
||||||
|
$('.tp').timepicker({
|
||||||
|
format: "dd M yyyy - HH:ii P",
|
||||||
|
minuteStep: 1,
|
||||||
|
showMeridian: true,
|
||||||
|
snapToStep: true,
|
||||||
|
bootcssVer: 3,
|
||||||
|
clearBtn: true,
|
||||||
|
todayHighlight: true,
|
||||||
|
autoclose: true,
|
||||||
|
pickerPosition: 'bottom-left'
|
||||||
|
});
|
||||||
|
|
||||||
|
// toggle advance order fields
|
||||||
|
$("#flag-advance").change(function() {
|
||||||
|
var dp = $("[name='date_schedule_date']");
|
||||||
|
var tp = $("[name='date_schedule_time']");
|
||||||
|
var checked = $(this).prop('checked');
|
||||||
|
|
||||||
|
if (checked) {
|
||||||
|
dp.prop('disabled', false);
|
||||||
|
tp.prop('disabled', false);
|
||||||
|
} else {
|
||||||
|
// reset to default values if disabled
|
||||||
|
var dateObj = moment(dp.data('default-value'), "YYYY-MM-DD");
|
||||||
|
dp.prop('disabled', true).parent().datepicker('setDate', dateObj.toDate());
|
||||||
|
tp.prop('disabled', true).timepicker('setTime', tp.data('default-value'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
Loading…
Reference in a new issue