Merge branch 'master' of gitlab.com:jankstudio/resq into 194-catalyst-api-bundle-acl

This commit is contained in:
Korina Cordero 2019-05-08 07:16:09 +00:00
commit 3c236d0ab4
23 changed files with 961 additions and 40 deletions

View file

@ -75,6 +75,17 @@ class TestCommand extends Command
];
$api->post('/capi/warranties/' . $id . '/claim', $params);
// add battery
$sku = 'WZMB31QT-CPP00-S';
$brand_id = '4';
$size_id = '1';
$params = [
'sku' => $sku,
'brand_id' => $brand_id,
'size_id' => $size_id,
];
$api->post('/capi/batteries', $params);
/*
// plate warranty

View file

@ -248,3 +248,5 @@ access_keys:
label: Menu
- id: report.reject
label: Rejection Report
- id: report.battery.conflict
label: Battery Conflict Report

View file

@ -30,6 +30,12 @@ capi_battery_sizes:
controller: App\Controller\CAPI\BatteryController::getSizes
methods: [GET]
# add battery
capi_battery_add:
path: /capi/batteries
controller: App\Controller\CAPI\BatteryController::addBattery
methods: [POST]
# vehicle api

View file

@ -17,3 +17,13 @@ rep_reject_detail_submit:
path: /report/rejection_detail
controller: App\Controller\ReportController::rejectDetailSubmit
methods: [POST]
rep_battery_conflict_form:
path: /report/battery_conflict
controller: App\Controller\ReportController::batteryConflictForm
methods: [GET]
rep_battery_conflict_submit:
path: /report/battery_conflict
controller: App\Controller\ReportController::batteryConflictSubmit
methods: [POST]

View file

@ -6,3 +6,7 @@ search_history:
path: /search/history
controller: App\Controller\SearchController::search
methods: [GET]
search_legacyjo_details:
path: /search/legacyjo/{id}/details
controller: App\Controller\SearchController::legacyJODetails

73
kml/supported_areas.kml Normal file
View file

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>ResQ Supported Area</name>
<description/>
<Style id="poly-000000-1200-77-nodesc-normal">
<LineStyle>
<color>ff000000</color>
<width>1.2</width>
</LineStyle>
<PolyStyle>
<color>4d000000</color>
<fill>1</fill>
<outline>1</outline>
</PolyStyle>
<BalloonStyle>
<text><![CDATA[<h3>$[name]</h3>]]></text>
</BalloonStyle>
</Style>
<Style id="poly-000000-1200-77-nodesc-highlight">
<LineStyle>
<color>ff000000</color>
<width>1.8</width>
</LineStyle>
<PolyStyle>
<color>4d000000</color>
<fill>1</fill>
<outline>1</outline>
</PolyStyle>
<BalloonStyle>
<text><![CDATA[<h3>$[name]</h3>]]></text>
</BalloonStyle>
</Style>
<StyleMap id="poly-000000-1200-77-nodesc">
<Pair>
<key>normal</key>
<styleUrl>#poly-000000-1200-77-nodesc-normal</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#poly-000000-1200-77-nodesc-highlight</styleUrl>
</Pair>
</StyleMap>
<Folder>
<name>ResQ Supported Area</name>
<Placemark>
<name>Supported Area</name>
<styleUrl>#poly-000000-1200-77-nodesc</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<tessellate>1</tessellate>
<coordinates>
121.0717128,14.7868868,0
121.0222743,14.7895424,0
120.9302638,14.6793076,0
120.9494899,14.4427135,0
121.0250209,14.3735484,0
121.0744593,14.5171749,0
121.1513636,14.5357864,0
121.1884425,14.5809791,0
121.2021754,14.6248337,0
121.1321376,14.6540653,0
121.129391,14.7616569,0
121.0717128,14.7868868,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Folder>
</Document>
</kml>

View file

@ -10,6 +10,7 @@ use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use App\Entity\Warranty;
use App\Entity\Battery;
use App\Entity\BatterySize;
use App\Entity\BatteryModel;
use App\Entity\VehicleManufacturer;
@ -31,6 +32,7 @@ use DateTime;
class ImportLegacyJobOrderCommand extends Command
{
protected $em;
protected $batt_hash;
protected $bmodel_hash;
protected $bsize_hash;
protected $vmfg_hash;
@ -50,6 +52,7 @@ class ImportLegacyJobOrderCommand extends Command
$this->loadBatterySizes();
$this->loadVehicleManufacturers();
$this->loadVehicles();
$this->loadBatteries();
$this->jo_hash = [];
@ -312,7 +315,7 @@ class ImportLegacyJobOrderCommand extends Command
continue;
// check if battery is found
$found_battery = $this->findBattery($fields[92], $batt_model, $batt_size);
$found_battery = $this->findBattery($fields[92], $batt_model, $batt_size, $sap_code);
if (!$found_battery)
{
// $output->writeln('battery not found - ' . $fields[92]);
@ -399,7 +402,33 @@ class ImportLegacyJobOrderCommand extends Command
$line .= '\N,';
// date claim
$line .= '\N';
$line .= '\N,';
// claim id
$line .= '\N,';
// sap battery id
if (isset($sap_code))
$line .= $sap_code . ',';
else
$line .= '\N,';
// first name
if (isset($fields[20]) && strlen(trim($fields[20])) > 0)
$line .= $fields[20] . ',';
else
$line .= '\N,';
// last name
if (isset($fields[22]) && strlen(trim($fields[22])) > 0)
$line .= $fields[22] . ',';
else
$line .= '\N,';
// mobile number
if (isset($fields[24]) && strlen(trim($fields[24])) > 0)
$line .= $fields[24] . ',';
else
$line .= '\N';
fwrite($warr_outfile, $line . "\n");
}
@ -769,6 +798,25 @@ class ImportLegacyJobOrderCommand extends Command
}
}
protected function loadBatteries()
{
$this->batt_hash = [];
$batts = $this->em->getRepository(Battery::class)->findAll();
foreach ($batts as $batt)
{
if (($batt->getModel() == null) or ($batt->getSize() == null) or ($batt->getSAPCode() == null))
{
continue;
}
$model_id = $batt->getModel()->getID();
$size_id = $batt->getSize()->getID();
$this->batt_hash[$model_id][$size_id] = $batt->getSAPCode();
}
}
protected function loadVehicleManufacturers()
{
$this->vmfg_hash = [];
@ -817,16 +865,16 @@ class ImportLegacyJobOrderCommand extends Command
return $clean_text;
}
protected function findBattery($batt_field, &$batt_model, &$batt_size)
{
// split battery into model and size
// echo "trying match - " . $fields[92] . "\n";
$res = preg_match("/^(.+)(GOLD|EXCEL|ENDURO|\(Trade-In\))/", $batt_field, $matches);
if (!$res)
{
// echo "no match - " . $fields[92] . "\n";
protected function findBattery($batt_field, &$batt_model, &$batt_size, &$sap_code)
{
// split battery into model and size
// echo "trying match - " . $batt_field . "\n";
$res = preg_match("/^(.+)(GOLD|EXCEL|ENDURO|\(Trade-In\))/", $batt_field, $matches);
if (!$res)
{
//echo "no match - " . $fields[92] . "\n";
return false;
}
}
if ($matches[2] == '(Trade-In)')
return false;
@ -836,29 +884,35 @@ class ImportLegacyJobOrderCommand extends Command
// TODO: what to do about (Trade-In)
// check if we have the size
$found_size = $this->simplifyName($matches[1]);
if (!isset($this->bsize_hash[$found_size]))
{
// try legacy battery lookup
$legacy_size = LegacyBattery::translate($found_size);
if ($legacy_size == null)
{
// echo "no size - $found_size\n";
if (isset($no_sizes[$found_size]))
$no_sizes[$found_size]++;
else
$no_sizes[$found_size] = 1;
return false;
}
// check if we have the size
$found_size = $this->simplifyName($matches[1]);
if (!isset($this->bsize_hash[$found_size]))
{
// try legacy battery lookup
$legacy_size = LegacyBattery::translate($found_size);
if ($legacy_size == null)
{
// echo "no size - $found_size\n";
if (isset($no_sizes[$found_size]))
$no_sizes[$found_size]++;
else
$no_sizes[$found_size] = 1;
return false;
}
$found_size = $legacy_size;
}
$found_size = $legacy_size;
}
$batt_size = $this->bsize_hash[$found_size];
// $batt_size = $found_size;
//get battery using ids of batt_model and batt_size
if (!isset($this->batt_hash[$batt_model][$batt_size]))
return false;
$sap_code = $this->batt_hash[$batt_model][$batt_size];
return true;
}
}
protected function findVehicle($vmfg_field, $vmake_field, $vmodel_field, &$vehicle)
{

View file

@ -802,8 +802,9 @@ class APIController extends Controller
$is_covered = $geo->isCovered($long, $lat);
if (!$is_covered)
{
// TODO: put geofence error message in config file somewhere
$res->setError(true)
->setErrorMessage('Location is not covered by our service.');
->setErrorMessage('Oops! Our service is limited to Metro Manila only. We will update you as soon as we are able to cover your area');
return $res->getReturnResponse();
}

View file

@ -119,6 +119,7 @@ class BatteryController extends BaseController
$row['sell_price'] = $orow[0]->getSellingPrice();
$row['warr_private'] = $orow[0]->getWarrantyPrivate();
$row['warr_commercial'] = $orow[0]->getWarrantyCommercial();
$row['warr_tnv'] = $orow[0]->getWarrantyTnv();
$row['res_capacity'] = $orow[0]->getReserveCapacity();
$row['length'] = $orow[0]->getLength();
$row['width'] = $orow[0]->getWidth();
@ -181,6 +182,7 @@ class BatteryController extends BaseController
->setSAPCode($req->request->get('sap_code'))
->setWarrantyPrivate($req->request->get('warr_private'))
->setWarrantyCommercial($req->request->get('warr_commercial'))
->setWarrantyTnv($req->request->get('warr_tnv'))
->setReserveCapacity($req->request->get('res_capacity'))
->setLength($req->request->get('length'))
->setWidth($req->request->get('width'))
@ -303,6 +305,7 @@ class BatteryController extends BaseController
->setSAPCode($req->request->get('sap_code'))
->setWarrantyPrivate($req->request->get('warr_private'))
->setWarrantyCommercial($req->request->get('warr_commercial'))
->setWarrantyTnv($req->request->get('warr_tnv'))
->setReserveCapacity($req->request->get('res_capacity'))
->setLength($req->request->get('length'))
->setWidth($req->request->get('width'))

View file

@ -89,4 +89,72 @@ class BatteryController extends APIController
return new APIResponse(true, 'Battery sizes loaded.', $data);
}
public function addBattery(Request $req, EntityManagerInterface $em)
{
// required parameters
$params = [
'sku',
'brand_id',
'size_id',
];
$msg = $this->checkRequiredParameters($req, $params);
error_log('msg - ' . $msg);
if ($msg)
return new APIResponse(false, $msg);
$sku = $req->request->get('sku');
$brand_id = $req->request->get('brand_id');
$size_id = $req->request->get('size_id');
// check if sku already exists
$batt = $em->getRepository(SAPBattery::class)->find($sku);
if ($batt != null)
return new APIResponse(false, 'Battery SKU already exists.');
// check if brand exists
$batt_brand = $em->getRepository(SAPBatteryBrand::class)->find($brand_id);
if ($batt_brand == null)
return new APIResponse(false, 'Invalid brand.');
// check if size exists
$batt_size = $em->getRepository(SAPBatterySize::class)->find($size_id);
if ($batt_size == null)
return new APIResponse(false, 'Invalid size.');
$new_batt = new SAPBattery();
$new_batt->setID($sku)
->setBrand($batt_brand)
->setSize($batt_size);
try
{
$em->persist($new_batt);
$em->flush();
}
catch (UniqueConstraintViolationException $e)
{
return new APIResponse(false, 'Battery SKU already exists.');
}
// return the new battery data
$data = [
'battery' => $this->generateBatteryData($new_batt),
];
return new APIResponse(true, 'Battery added.', $data);
}
protected function generateBatteryData(SAPBattery $batt)
{
$data = [
'sku' => $batt->getID(),
'brand' => $batt->getBrand()->getID(),
'size' => $batt->getSize()->getID(),
];
return $data;
}
}

View file

@ -110,7 +110,7 @@ class WarrantyController extends APIController
$query = $qb->select('w')
->from('App\\Entity\\Warranty', 'w')
->orderBy('w.serial', $order)
->orderBy('w.date_create', $order)
->setFirstResult($start)
->setMaxResults($max)
->getQuery();

View file

@ -5,8 +5,11 @@ namespace App\Controller;
use App\Ramcar\BaseController;
use App\Ramcar\JORejectionReason;
use App\Ramcar\ServiceType;
use App\Ramcar\JOStatus;
use App\Entity\JORejection;
use App\Entity\Battery;
use App\Entity\JobOrder;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
@ -260,4 +263,139 @@ class ReportController extends BaseController
]);
*/
}
public function batteryConflictForm()
{
$this->denyAccessUnlessGranted('report.battery.conflict', null, 'No access.');
$params = $this->initParameters('outlet_list');
return $this->render('report/battery/batt_conflict_form.html.twig', $params);
}
public function batteryConflictSubmit(Request $req)
{
$this->denyAccessUnlessGranted('report.battery.conflict', null, 'No access.');
// get job order query builder
$job_qb = $this->getDoctrine()
->getRepository(JobOrder::class)
->createQueryBuilder('jo');
$em = $this->getDoctrine()->getManager();
// get dates
$raw_date_start = $req->request->get('date_start');
$raw_date_end = $req->request->get('date_end');
$date_start = DateTime::createFromFormat('m/d/Y', $raw_date_start);
$date_end = DateTime::createFromFormat('m/d/Y', $raw_date_end);
// build query for job order
$jo_query = $job_qb->where('jo.date_create >= :start')
->andWhere('jo.date_create <= :end')
->andWhere('jo.status != :status')
->setParameter('start', $date_start->format('Y-m-d') . ' 00:00:00')
->setParameter('end', $date_end->format('Y-m-d') . ' 23:59:59')
->setParameter('status', JOStatus::CANCELLED)
->getQuery();
// run queries
$jos = $jo_query->getResult();
$batteries = $em->getRepository(Battery::class)->findAll();
// create compatibility matrix for battery and vehicle
$comp_matrix = [];
foreach ($batteries as $batt)
{
$vehicles = $batt->getVehicles();
foreach ($vehicles as $vehicle)
{
$comp_matrix[$batt->getID()][$vehicle->getID()] = true;
}
}
// go through the job orders to find the conflicts
$results = [];
foreach ($jos as $jo)
{
$invoice_items = $jo->getInvoice()->getItems();
foreach ($invoice_items as $item)
{
// check if the item is a battery
if ($item->getBattery() != null)
{
$batt_id = $item->getBattery()->getID();
$vehicle_id = $jo->getCustomerVehicle()->getVehicle()->getID();
if (isset($comp_matrix[$batt_id][$vehicle_id]) && $comp_matrix[$batt_id][$vehicle_id])
{
continue;
}
else
{
// get the compatible batteries for the customer vehicle
$batteries = [];
foreach($jo->getCustomerVehicle()->getVehicle()->getBatteries() as $comp_batt)
{
//$batteries[] = [
// 'mfg_name' => $comp_batt->getManufacturer()->getName(),
// 'model_name' => $comp_batt->getModel()->getName(),
// 'size_name' => $comp_batt->getSize()->getName(),
//];
$batteries[] = $comp_batt->getManufacturer()->getName() . ' ' .
$comp_batt->getModel()->getName() . ' ' .
$comp_batt->getSize()->getName();
}
$results[] = [
'jo_id' => $jo->getID(),
'jo_date_create' => $jo->getDateCreate()->format('m/d/Y H:i'),
'cus_vehicle_manufacturer' => $jo->getCustomerVehicle()->getVehicle()->getManufacturer()->getName(),
'cus_vehicle_make' => $jo->getCustomerVehicle()->getVehicle()->getMake(),
'cus_vehicle_model' => $jo->getCustomerVehicle()->getModelYear(),
'battery_model_ordered' => $item->getBattery()->getModel()->getName(),
'battery_size_ordered' => $item->getBattery()->getSize()->getName(),
'compatible_batt' => implode(', ', $batteries),
];
}
}
}
}
$resp = new StreamedResponse();
$resp->setCallback(function() use ($results) {
// csv output
$csv_handle = fopen('php://output', 'w+');
fputcsv($csv_handle, [
'Order #',
'Order Date and Time',
'Manufacturer',
'Make',
'Year',
'Battery Model',
'Battery Size',
'Compatible Batteries'
]);
foreach ($results as $row)
{
fputcsv($csv_handle, $row);
}
fclose($csv_handle);
});
$filename = 'battery_conflict_' . $date_start->format('Ymd') . '_' . $date_end->format('Ymd') . '.csv';
$resp->setStatusCode(200);
$resp->headers->set('Content-Type', 'text/csv; charset=utf-8');
$resp->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"');
return $resp;
//return $this->json([
// 'result' => $results,
//]);
}
}

View file

@ -3,8 +3,12 @@
namespace App\Controller;
use App\Ramcar\BaseController;
use App\Service\GeneralSearch;
use App\Entity\LegacyJobOrder;
use App\Entity\LegacyJobOrderRow;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@ -46,4 +50,20 @@ class SearchController extends BaseController
// response
return $this->render('search/form.html.twig', $params);
}
public function legacyJODetails($id)
{
$this->denyAccessUnlessGranted('general.search', null, 'No access.');
// get legacy job order
$em = $this->getDoctrine()->getManager();
$legacy_jo = $em->getRepository(LegacyJobOrder::class)->find($id);
$params = $this->initParameters('general.search');
$params['data'] = $legacy_jo;
$params['mode'] = "details";
// response
return $this->render('search/legacyjo_details.html.twig', $params);
}
}

View file

@ -85,6 +85,13 @@ class Battery
*/
protected $warr_commercial;
// warranty tnv
/**
* @ORM\Column(type="smallint")
* @Assert\NotBlank()
*/
protected $warr_tnv;
// reserve capacity
/**
* @ORM\Column(type="smallint")
@ -248,6 +255,17 @@ class Battery
return $this->warr_commercial;
}
public function setWarrantyTnv($warr_tnv)
{
$this->warr_tnv = $warr_tnv;
return $this;
}
public function getWarrantyTnv()
{
return $this->warr_tnv;
}
public function setReserveCapacity($res_capacity)
{
$this->res_capacity = $res_capacity;

View file

@ -343,6 +343,10 @@ class LegacyJobOrder
*/
protected $plate_number;
/**
* @ORM\OneToMany(targetEntity="LegacyJobOrderRow", mappedBy="job_order")
*/
protected $rows;
public function setID($id)
@ -642,15 +646,15 @@ class LegacyJobOrder
return $this->dispatch_date;
}
public function setDispatchBy($dispatch_by)
public function setDispatchedBy($dispatched_by)
{
$this->dispatch_by = $dispatch_by;
$this->dispatched_by = $dispatched_by;
return $this;
}
public function getDispatchBy()
public function getDispatchedBy()
{
return $this->dispatch_by;
return $this->dispatched_by;
}
public function setAddress($address)
@ -696,4 +700,9 @@ class LegacyJobOrder
{
return $this->plate_number;
}
public function getRows()
{
return $this->rows;
}
}

View file

@ -19,11 +19,6 @@ class LegacyJobOrderRow
*/
protected $id;
/**
* @ORM\Column(type="integer")
*/
protected $job_order_id;
/**
* @ORM\Column(type="string", length=40)
*/
@ -59,6 +54,12 @@ class LegacyJobOrderRow
*/
protected $enrollee;
/**
* @ORM\ManyToOne(targetEntity="LegacyJobOrder", inversedBy="rows")
* @ORM\JoinColumn(name="job_order_id", referencedColumnName="id", nullable=true)
*/
protected $job_order;
public function setID($id)
{
$this->id = $id;
@ -69,4 +70,93 @@ class LegacyJobOrderRow
{
return $this->id;
}
public function setItem($item)
{
$this->item = $item;
return $this;
}
public function getItem()
{
return $this->item;
}
public function setQuantity($qty)
{
$this->qty = $qty;
return $this;
}
public function getQuantity()
{
return $this->qty;
}
public function setPrice($price)
{
$this->price = $price;
return $this;
}
public function getPrice()
{
return $this->price;
}
public function setPriceLevel($price_level)
{
$this->price_level = $price_level;
return $this;
}
public function getPriceLevel()
{
return $this->price_level;
}
public function setStatus($status)
{
$this->status = $status;
return $this;
}
public function getStatus()
{
return $this->status;
}
public function setAccount($account)
{
$this->account = $account;
return $this;
}
public function getAccount()
{
return $this->account;
}
public function setEnrollee($enrollee)
{
$this->enrollee = $enrollee;
return $this;
}
public function getEnrollee()
{
return $this->enrollee;
}
public function setJobOrder(LegacyJobOrder $job_order)
{
$this->job_order = $job_order;
return $this;
}
public function getJobOrder()
{
return $this->job_order;
}
}

View file

@ -128,6 +128,16 @@
</span>
</a>
</li>
<li class="m-menu__item " data-redirect="true" aria-haspopup="true">
<a href= "{{ url('rep_battery_conflict_form') }}" class="m-menu__link">
<i class="m-menu__link-bullet m-menu__link-bullet--dot">
<span></span>
</i>
<span class="m-menu__link-text">
Battery Conflict Report
</span>
</a>
</li>
</ul>
</li>
<!--

View file

@ -157,6 +157,14 @@
<div class="form-control-feedback hide" data-field="warr_commercial"></div>
<span class="m-form__help">In months</span>
</div>
<div class="col-lg-4">
<label data-field="warr_tnv">
TNV
</label>
<input type="number" name="warr_tnv" class="form-control m-input" value="{{ obj.getWarrantyTnv }}">
<div class="form-control-feedback hide" data-field="warr_tnv"></div>
<span class="m-form__help">In months</span>
</div>
</div>
</div>
<div class="m-form__seperator m-form__seperator--dashed"></div>

View file

@ -0,0 +1,82 @@
{% 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">Battery Conflict Report</h3>
</div>
</div>
</div>
<!-- END: Subheader -->
<div class="m-content">
<!--Begin::Section-->
<div class="row">
<div class="col-xl-6">
<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-calendar"></i>
</span>
<h3 class="m-portlet__head-text">
Select a date range
</h3>
</div>
</div>
</div>
<form id="row-form" autocomplete="off" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed" method="post" action="{{ url('rep_battery_conflict_submit') }}">
<div class="m-portlet__body">
<div class="form-group m-form__group row">
<div class="input-daterange input-group" id="date-range">
<input role="presentation" type="text" class="form-control m-input" name="date_start" placeholder="Start date" />
<div class="input-group-append">
<span class="input-group-text"><i class="la la-ellipsis-h"></i></span>
</div>
<input role="presentation" type="text" class="form-control" name="date_end" placeholder="End date" />
</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>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
$(function() {
$("#date-range").datepicker({
orientation: "bottom"
});
$("#row-form").submit(function(e) {
var form = $(this);
if (!$("[name='date_start']").val() || !$("[name='date_end']").val()) {
e.preventDefault();
swal({
title: 'Whoops!',
text: 'Please fill in both date fields.',
type: 'warning'
});
return false;
}
});
});
</script>
{% endblock %}

View file

@ -86,6 +86,7 @@
<th>Last Name</th>
<th>First Name</th>
<th>Plate Number</th>
<th> </th>
</tr>
</thead>
<tbody>
@ -95,6 +96,7 @@
<td>{{ result.getCustLastName|default('') }}</td>
<td>{{ result.getCustFirstName|default('') }}</td>
<td>{{ result.getPlateNumber|default('') }}</td>
<td> <a href="{{ url('search_legacyjo_details', {'id': result.getID }) }}" >Details</a> </td>
</tr>
{% endfor %}
</tbody>
@ -191,6 +193,10 @@
<th>Last Name</th>
<th>First Name</th>
<th>Plate Number</th>
<th>Warranty Class</th>
<th>Expiry Date</th>
<th>Serial</th>
<th>Battery</th>
</tr>
</thead>
<tbody>
@ -200,6 +206,10 @@
<td>{{ result.getLastName|default("") }}</td>
<td>{{ result.getFirstName|default("") }}</td>
<td>{{ result.getPlateNumber|default("") }}</td>
<td>{{ result.getWarrantyClass|default("") }}</td>
<td>{{ result.getDateExpire|default("")|date('d M Y') }}</td>
<td>{{ result.getSerial|default("") }}</td>
<td>{{ result.getSAPBattery.getID|default("") }}</td>
</tr>
{% endfor %}
</tbody>

View file

@ -0,0 +1,298 @@
{% 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">
Legacy Job Order
</h3>
</div>
</div>
</div>
<!--Begin::Section-->
<form id="row-form" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed">
<div class="m-portlet__body">
<br>
<div class="m-form__section{{ mode == 'details' }}">
<div class="m-form__heading">
<h3 class="m-form__heading-title">
Customer Details
</h3>
</div>
<div class="form-group m-form__group row" no-border>
<div class="col-lg-6">
<label data-field="customer_first_name">First Name</label>
<input type="text" name="customer_first_name" id="customer-first-name" class="form-control m-input" value="{{ data.getCustFirstName|default('') }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="customer_first_name"></div>
</div>
<div class="col-lg-6">
<label data-field="customer_last_name">Last Name</label>
<input type="text" name="customer_last_name" id="customer-last-name" class="form-control m-input" value="{{ data.getCustLastName|default('') }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="customer_last_name"></div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-6">
<label data-field="customer_phone_mobile">Mobile Phone</label>
<div class="input-group m-input-group">
<span class="input-group-addon">+63</span>
<input type="text" name="customer_phone_mobile" id="customer-phone-mobile" class="form-control m-input" value="{{ data.getCustMobile|default('') }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="customer_phone_mobile"></div>
</div>
</div>
<div class="col-lg-6">
<label data-field="customer_phone_landline">Landline</label>
<div class="input-group m-input-group">
<span class="input-group-addon">+63</span>
<input type="text" name="customer_phone_landline" id="customer-phone-landline" class="form-control m-input" value="{{ data.getCustLandline|default('') }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="customer_phone_landline"></div>
</div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-6">
<label data-field="customer_contact">Contact</label>
<div class="input-group m-input-group">
<span class="input-group-addon">+63</span>
<input type="text" name="customer_contact" id="customer-contact" class="form-control m-input" value="{{ data.getCustContact|default('') }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="customer_contact"></div>
</div>
</div>
</div>
</div>
<div class="m-form__section">
<div class="m-form__heading">
<h3 class="m-form__heading-title">
Vehicle Details
</h3>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-3">
<label data-field="vmfg">Manufacturer</label>
<input type="text" name="vmfg" id="vmfg" class="form-control m-input" value="{{ data.getCarBrand|default('') }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="vmfg"></div>
</div>
<div class="col-lg-3">
<label data-field="vehicle_make">Make</label>
<input type="text" name="vehicle_make" id="vehicle-make" class="form-control m-input" value="{{ data.getCarMake|default('') }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="vehicle_make"></div>
</div>
<div class="col-lg-3">
<label data-field="vehicle_year">Model Year</label>
<input type="text" name="vehicle_year" id="vehicle-year" class="form-control m-input" value="{{ data.getCarModel|default('') }}" 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 data-field="vehicle_plate">Plate #</label>
<input type="text" name="vehicle_plate" id="vehicle-plate" class="form-control m-input" value="{{ data.getPlateNumber|default('') }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="vehicle_color"></div>
</div>
<div class="col-lg-3">
<label data-field="vehicle_color">Color</label>
<input type="text" name="vehicle_color" id="vehicle-color" class="form-control m-input" value="{{ data.getCarColor|default('') }}" data-vehicle-field="1" disabled>
<div class="form-control-feedback hide" data-field="vehicle_color"></div>
</div>
</div>
</div>
<div class="m-form__section">
<div class="m-form__heading">
<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"{{ data.getAdvanceOrder == "Yes" ? ' checked' }} disabled>
<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-6">
<label data-field="transaction_type">Transaction Type</label>
<input type="text" name="transaction_type" id="trasaction-type" class="form-control m-input" value="{{ data.getTransType|default('') }}" disabled>
<div class="form-control-feedback hide" data-field="service_type"></div>
</div>
<div class="col-lg-3">
<label data-field="mode_of_payment">Mode of Payment</label>
<input type="text" name="mode_of_payment" id="mode-of-payment" class="form-control m-input" value="{{ data.getPaymentMethod|default('') }}" disabled>
<div class="form-control-feedback hide" data-field="mode_of_payment"></div>
</div>
<div class="col-lg-3">
<label data-field="purchase_date">Purchase Date</label>
<input type="text" name="date_purchase" class="form-control m-input" value="{{ data.getDatePurchase|default('') }}" disabled>
<div class="form-control-feedback hide" data-field="date_purchase"></div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-6">
<label>Transaction Date</label>
<input type="text" name="date_transaction" class="form-control m-input" value="{{ data.getTransDate|default("now")|date('d M Y - g:i A') }}" disabled>
<div class="form-control-feedback hide" data-field="date_transaction"></div>
</div>
<div class="col-lg-3">
<label data-field="date_schedule">Delivery Date</label>
<div class="input-group date dp">
<input type="text" name="date_delivery_date" class="form-control m-input" value="{{ data.getDeliveryDate|default('') }}" 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_delivery_date"></div>
</div>
<div class="col-lg-3">
<label data-field="date_schedule">Delivery Time</label>
<div class="input-group">
<input type="text" name="date_delivery_time" class="form-control m-input tp" value="{{ data.getDeliveryTime|default('') }}" 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_delivery_time"></div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-6">
<label data-field="agent_notes">Agent Notes</label>
<textarea name="agent_notes" class="form-control m-input" rows="15" disabled>{{ data.getAgentNotes1 }}</textarea>
<div class="form-control-feedback hide" data-field="agent_notes"></div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-6">
<div class="col-lg-12 form-group-inner">
<label data-field="source">Transaction Origin</label>
<input type="text" name="transaction_origin" id="trasaction-origin" class="form-control m-input" value="{{ data.getOrigin|default('') }}" disabled>
<div class="form-control-feedback hide" data-field="mode_of_payment"></div>
</div>
<br>
<div class="col-lg-12 form-group-inner">
<label data-field="delivery_instructions">Delivery Instructions</label>
<textarea name="delivery_instructions" class="form-control m-input" rows="4" disabled>{{ data.getDeliveryInstructions }}</textarea>
</div>
</div>
<div class="col-lg-6">
<div class="col-lg-12 form-group-inner">
<label>Prepared By</label>
<input type="text" name="prepared_by" class="form-control m-input" value="{{ data.getPreparedBy|default('') }}" disabled>
<div class="form-control-feedback hide" data-field="date_transaction"></div>
</div>
<br>
<div class="col-lg-12 form-group-inner">
<label>Dispatched By</label>
<input type="text" name="dispatched_by" class="form-control m-input" value="{{ data.getDispatchedBy|default('') }}" disabled>
<div class="form-control-feedback hide" data-field="date_transaction"></div>
</div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-6">
<label data-field="stage">Status</label>
<input type="text" name="stage" class="form-control m-input" value="{{ data.getStage|default('') }}" disabled>
<div class="form-control-feedback hide" data-field="stage"></div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-6">
<label data-field="cancel_reason">Reason for Cancellation</label>
<textarea name="cancel_reason" class="form-control m-input" rows="4" disabled>{{ data.getCancelReason|default('') }}</textarea>
<div class="form-control-feedback hide" data-field="cancel_reason"></div>
</div>
<div class="col-lg-6">
<label data-field="cancel_reason_specify">Details for Cancellation</label>
<textarea name="cancel_reason_specify" class="form-control m-input" rows="4" disabled>{{ data.getCancelReasonSpecify|default('') }}</textarea>
<div class="form-control-feedback hide" data-field="cancel_reason_specify"></div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-12">
{% if data.getRows is empty %}
<div class="m-alert m-alert--icon m-alert--icon-solid m-alert--outline alert alert-brand" role="alert">
<div class="m-alert__icon">
<i class="flaticon-exclamation-2"></i>
<span></span>
</div>
<div class="m-alert__text">
No transactions for this legacy job order.
</div>
</div>
{% else %}
<table class="table table-striped m-table">
<thead>
<tr class="m-table__row--brand">
<th>ID</th>
<th>Item</th>
<th>Quantity</th>
<th>Price</th>
<th>Price Level</th>
<th>Status</th>
<th>Account</th>
<th>Enrollee</th>
</tr>
</thead>
<tbody>
{% for row in data.getRows %}
<tr>
<td>{{ row.getID|default("") }}</td>
<td>{{ row.getItem|default('') }}</td>
<td>{{ row.getQuantity|default('') }}</td>
<td>{{ row.getPrice|default('') }}</td>
<td>{{ row.getPriceLevel|default('') }}</td>
<td>{{ row.getStatus|default('') }}</td>
<td>{{ row.getAccount|default('') }}</td>
<td>{{ row.getEnrollee|default('') }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</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">
Location
</h3>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-6">
<label data-field="delivery_address">Delivery Address</label>
<textarea name="delivery_address" class="form-control m-input" rows="4" disabled>{{ data.getAddress|default('') }}</textarea>
<div class="form-control-feedback hide" data-field="delivery_address"></div>
</div>
<div class="col-lg-6">
<label data-field="landmark">Landmark</label>
<textarea name="landmark" class="form-control m-input" rows="4" disabled>{{ data.getLandmark|default('') }}</textarea>
<div class="form-control-feedback hide" data-field="landmark"></div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,2 @@
update battery as batt inner join battery_model as bmodel on batt.model_id = bmodel.id set batt.warr_tnv=12 where bmodel.name='GOLD';

View file

@ -0,0 +1,4 @@
load data local infile '/tmp/plate_numbers.csv' into table plate_number fields terminated by ',';
load data infile '/tmp/legacy_jo_row.csv' into table legacy_job_order_row fields terminated by ',' enclosed by '"' lines terminated by '\n' (job_order_id, item, qty, price, price_level, status, account, enrollee) set id = null;
load data local infile '/tmp/warranty.csv' into table warranty fields terminated by ',' (bty_model_id, bty_size_id, serial, warranty_class, plate_number, status, date_create, date_purchase, date_expire, date_claim, claim_id, sap_bty_id, first_name, last_name, mobile_number) set id = null;
load data infile '/tmp/legacy_jo.csv' into table legacy_job_order fields terminated by '|' (id, trans_date, trans_type, origin, car_brand, car_make, car_model, car_color, cust_name, cust_first_name, cust_middle_name, cust_last_name, cust_contact, cust_mobile, cust_landline, delivery_instructions, agent_notes_1, delivery_date, delivery_time, advance_order, stage, cancel_reason, cancel_reason_specify, payment_method, prepared_by, dispatch_time, dispatch_date, dispatched_by, address, landmark, date_purchase, plate_number);