Compare commits

..

3 commits

17 changed files with 132 additions and 803 deletions

View file

@ -2,20 +2,6 @@ catalyst_auth:
main: main:
user_entity: "App\\Entity\\User" user_entity: "App\\Entity\\User"
acl_data: acl_data:
- id: competitor
label: Competitor Access
acls:
- id: competitor.menu
label: Menu
- id: competitor.list
label: List
- id: competitor.add
label: Add
- id: competitor.update
label: Update
- id: competitor.delete
label: Delete
- id: dashboard - id: dashboard
label: Dashboard Access label: Dashboard Access
acls: acls:
@ -686,7 +672,6 @@ catalyst_auth:
acls: acls:
- id: item_pricing.update - id: item_pricing.update
label: Update label: Update
api: api:
user_entity: "App\\Entity\\ApiUser" user_entity: "App\\Entity\\ApiUser"

View file

@ -7,13 +7,6 @@ catalyst_menu:
order: 1 order: 1
- id: competitor
acl: competitor.menu
label: Competitors
icon: fa fa-battery-0 #hehe
order: 1
- id: user - id: user
acl: user.menu acl: user.menu
label: '[menu.user]' label: '[menu.user]'
@ -312,4 +305,4 @@ catalyst_menu:
- id: item_pricing - id: item_pricing
acl: item_pricing.update acl: item_pricing.update
label: Item Pricing label: Item Pricing
parent: item parent: item

View file

@ -1,33 +0,0 @@
competitor:
path: /competitors
controller: App\Controller\CompetitorController::index
competitor_rows:
path: /competitors/rows
controller: App\Controller\CompetitorController::rows
methods: [POST]
competitor_create:
path: /competitors/create
controller: App\Controller\CompetitorController::addForm
methods: [GET]
competitor_create_submit:
path: /competitors/create
controller: App\Controller\CompetitorController::addSubmit
methods: [POST]
competitor_update:
path: /competitors/{id}
controller: App\Controller\CompetitorController::updateForm
methods: [GET]
competitor_update_submit:
path: /competitors/{id}
controller: App\Controller\CompetitorController::updateSubmit
methods: [POST]
competitor_delete:
path: /competitors/{id}
controller: App\Controller\CompetitorController::destroy
methods: [DELETE]

View file

@ -386,6 +386,7 @@ class RiderAppController extends ApiController
'flag_coolant' => $jo->hasCoolant(), 'flag_coolant' => $jo->hasCoolant(),
'has_motolite' => $cv->hasMotoliteBattery(), 'has_motolite' => $cv->hasMotoliteBattery(),
'delivery_status' => $jo->getDeliveryStatus(), 'delivery_status' => $jo->getDeliveryStatus(),
'flag_sealant' => $jo->hasSealant(),
] ]
]; ];
} }
@ -1324,7 +1325,7 @@ class RiderAppController extends ApiController
return new APIResponse(false, 'Invalid promo id - ' . $promo_id); return new APIResponse(false, 'Invalid promo id - ' . $promo_id);
} }
// get other parameters, if any: has motolite battery, has warranty doc, with coolant, payment method // get other parameters, if any: has motolite battery, has warranty doc, with coolant, payment method, with sealant
if (isset($items['flag_motolite_battery'])) if (isset($items['flag_motolite_battery']))
{ {
// get customer vehicle from jo // get customer vehicle from jo
@ -1359,6 +1360,15 @@ class RiderAppController extends ApiController
$jo->setModeOfPayment($payment_method); $jo->setModeOfPayment($payment_method);
} }
if (isset($items['flag_sealant']))
{
$has_sealant = $items['flag_sealant'];
if ($has_sealant == 'true')
$jo->setHasSealant(true);
else
$jo->setHasSealant(false);
}
// get capi user // get capi user
$capi_user = $this->getUser(); $capi_user = $this->getUser();
if ($capi_user == null) if ($capi_user == null)
@ -1443,6 +1453,13 @@ class RiderAppController extends ApiController
else else
$jo->setHasCoolant(false); $jo->setHasCoolant(false);
// sealant
$flag_sealant = $req->request->get('flag_sealant', 'false');
if ($flag_sealant == 'true')
$jo->setHasSealant(true);
else
$jo->setHasSealant(false);
// has motolite battery // has motolite battery
$cv = $jo->getCustomerVehicle(); $cv = $jo->getCustomerVehicle();
$has_motolite = $req->request->get('has_motolite', 'false'); $has_motolite = $req->request->get('has_motolite', 'false');
@ -1543,6 +1560,9 @@ class RiderAppController extends ApiController
// get coolant if any // get coolant if any
$flag_coolant = $jo->hasCoolant(); $flag_coolant = $jo->hasCoolant();
// get sealant if any
$flag_sealant = $jo->hasSealant();
// check if new promo is null // check if new promo is null
if ($promo == null) if ($promo == null)
{ {
@ -1561,6 +1581,7 @@ class RiderAppController extends ApiController
->setCustomerVehicle($cv) ->setCustomerVehicle($cv)
->setSource($source) ->setSource($source)
->setHasCoolant($flag_coolant) ->setHasCoolant($flag_coolant)
->setHasSealant($flag_sealant)
->setIsTaxable(); ->setIsTaxable();
// set price tier // set price tier

View file

@ -1,297 +0,0 @@
<?php
namespace App\Controller;
use App\Entity\Competitor;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Doctrine\ORM\EntityManager;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Catalyst\MenuBundle\Annotation\Menu;
class CompetitorController extends Controller
{
/**
* @Menu(selected="competitor")
*/
public function index()
{
$this->denyAccessUnlessGranted('competitor.list', null, 'No access.');
return $this->render('competitor/list.html.twig');
}
public function rows(Request $req)
{
$this->denyAccessUnlessGranted('competitor.list', null, 'No access.');
// get query builder
$qb = $this->getDoctrine()
->getRepository(Competitor::class)
->createQueryBuilder('q');
// get datatable params
$datatable = $req->request->get('datatable');
// count total records
$tquery = $qb->select('COUNT(q)');
$this->setQueryFilters($datatable, $tquery);
$total = $tquery->getQuery()
->getSingleScalarResult();
// get current page number
$page = $datatable['pagination']['page'] ?? 1;
$perpage = $datatable['pagination']['perpage'];
// ELMO TODO: FOR NOW:
// $perpage = 5;
$offset = ($page - 1) * $perpage;
// add metadata
$meta = [
'page' => $page,
'perpage' => $perpage,
'pages' => ceil($total / $perpage),
'total' => $total,
'sort' => 'asc',
'field' => 'id'
];
// build query
$query = $qb->select('q');
$this->setQueryFilters($datatable, $query);
// check if sorting is present, otherwise use default
if (isset($datatable['sort']['field']) && !empty($datatable['sort']['field'])) {
$order = $datatable['sort']['sort'] ?? 'asc';
$query->orderBy('q.' . $datatable['sort']['field'], $order);
} else {
$query->orderBy('q.id', 'asc');
}
// get rows for this page
$obj_rows = $query->setFirstResult($offset)
->setMaxResults($perpage)
->getQuery()
->getResult();
// dd($obj_rows);
// process rows
$rows = [];
foreach ($obj_rows as $orow) {
// add row data
$row['id'] = $orow->getID();
$row['branch_name'] = $orow->getBranchName();
$row['brand'] = $orow->getBrand();
$row['address'] = $orow->getAddress();
if ($orow->getIsNearPartner()){
$row['is_near_partner'] = "Yes";
}
else{
$row['is_near_partner'] = "No";
}
// add row metadata
$row['meta'] = [
'update_url' => '',
'delete_url' => ''
];
// add crud urls
if ($this->isGranted('competitor.update'))
$row['meta']['update_url'] = $this->generateUrl('competitor_update', ['id' => $row['id']]);
if ($this->isGranted('competitor.delete'))
$row['meta']['delete_url'] = $this->generateUrl('competitor_delete', ['id' => $row['id']]);
$rows[] = $row;
}
// response
return $this->json([
'meta' => $meta,
'data' => $rows
]);
}
/**
* @Menu(selected="competitor")
*/
public function addForm()
{
$this->denyAccessUnlessGranted('competitor.add', null, 'No access.');
$params = [];
$params['obj'] = new Competitor();
$params['mode'] = 'create';
$em = $this->getDoctrine()->getManager();
// response
return $this->render('competitor/form.html.twig', $params);
}
public function addSubmit(Request $req, EncoderFactoryInterface $ef, ValidatorInterface $validator)
{
$this->denyAccessUnlessGranted('competitor.add', null, 'No access.');
// create new object
$em = $this->getDoctrine()->getManager();
$obj = new Competitor();
$this->setObject($obj, $em, $req);
// validate
$errors = $validator->validate($obj);
// initialize error list
$error_array = [];
// add errors to list
foreach ($errors as $error) {
$error_array[$error->getPropertyPath()] = $error->getMessage();
}
// check if any errors were found
if (!empty($error_array)) {
// return validation failure response
return $this->json([
'success' => false,
'errors' => $error_array
], 422);
}
// validated! save the entity
$em->persist($obj);
$em->flush();
// return successful response
return $this->json([
'success' => 'Changes have been saved!'
]);
}
/**
* @Menu(selected="competitor")
*/
public function updateForm($id)
{
// $id = 14;
$this->denyAccessUnlessGranted('competitor.update', null, 'No access.');
$params['mode'] = 'update';
// get row data
$em = $this->getDoctrine()->getManager();
$row = $em->getRepository(Competitor::class)->find($id);
// make sure this row exists
if (empty($row))
throw $this->createNotFoundException('The item does not exist');
$params['obj'] = $row;
// response
return $this->render('competitor/form.html.twig', $params);
}
public function updateSubmit(Request $req, ValidatorInterface $validator, $id)
{
$this->denyAccessUnlessGranted('competitor.update', null, 'No access.');
// get object data
$em = $this->getDoctrine()->getManager();
$obj = $em->getRepository(Competitor::class)->find($id);
// make sure this object exists
if (empty($obj))
throw $this->createNotFoundException('The item does not exist');
$this->setObject($obj, $em, $req);
// validate
$errors = $validator->validate($obj);
// initialize error list
$error_array = [];
// add errors to list
foreach ($errors as $error) {
$error_array[$error->getPropertyPath()] = $error->getMessage();
}
// check if any errors were found
if (!empty($error_array)) {
// return validation failure response
return $this->json([
'success' => false,
'errors' => $error_array
], 422);
}
// validated! save the entity
$em->flush();
// return successful response
return $this->json([
'success' => 'Changes have been saved!'
]);
}
public function destroy($id)
{
$this->denyAccessUnlessGranted('competitor.delete', null, 'No access.');
// get object data
$em = $this->getDoctrine()->getManager();
$obj = $em->getRepository(Competitor::class)->find($id);
if (empty($obj))
throw $this->createNotFoundException('The item does not exist');
// delete this object
$em->remove($obj);
$em->flush();
// response
$response = new Response();
$response->setStatusCode(Response::HTTP_OK);
$response->send();
}
protected function setQueryFilters($datatable, QueryBuilder $query)
{
if (isset($datatable['query']['data-rows-search']) && !empty($datatable['query']['data-rows-search'])) {
$query->where('q.branch_name LIKE :filter')
->orWhere('q.address LIKE :filter')
->orWhere('q.brand LIKE :filter')
->orWhere('q.is_near_partner LIKE :filter')
->setParameter('filter', '%' . $datatable['query']['data-rows-search'] . '%');
}
}
protected function setObject(Competitor $obj, EntityManager $em, Request $req)
{
// dd($req);
// set and save values
$obj->setBranchName($req->request->get('branch_name'))
->setBrand($req->request->get('brand'))
->setAddress($req->request->get('address'))
->setIsNearPartner($req->request->get('is_near_partner') ? 1 : 0);
}
}

View file

@ -754,6 +754,8 @@ class JobOrderController extends Controller
$promo_id = $req->request->get('promo'); $promo_id = $req->request->get('promo');
$cvid = $req->request->get('cvid'); $cvid = $req->request->get('cvid');
$service_charges = $req->request->get('service_charges', []); $service_charges = $req->request->get('service_charges', []);
$flag_coolant = $req->request->get('flag_coolant', false);
$flag_sealant = $req->request->get('flag_sealant', false);
// coordinates // coordinates
// need to check if lng and lat are set // need to check if lng and lat are set
@ -784,7 +786,9 @@ class JobOrderController extends Controller
->setCustomerVehicle($cv) ->setCustomerVehicle($cv)
->setIsTaxable() ->setIsTaxable()
->setSource(TransactionOrigin::CALL) ->setSource(TransactionOrigin::CALL)
->setPriceTier($price_tier); ->setPriceTier($price_tier)
->setHasCoolant($flag_coolant)
->setHasSealant($flag_sealant);
/* /*
// if it's a jumpstart or troubleshoot only, we know what to charge already // if it's a jumpstart or troubleshoot only, we know what to charge already

View file

@ -1,91 +0,0 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class Competitor
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $branch_name;
/**
* @ORM\Column(type="string", length=255)
*/
private $brand;
/**
* @ORM\Column(type="boolean")
*/
private $is_near_partner;
/**
* @ORM\Column(type="string", length=255)
*/
private $address;
public function getId(): ?int
{
return $this->id;
}
public function getBranchName(): ?string
{
return $this->branch_name;
}
public function setBranchName(string $branch_name): self
{
$this->branch_name = $branch_name;
return $this;
}
public function getBrand(): ?string
{
return $this->brand;
}
public function setBrand(string $brand): self
{
$this->brand = $brand;
return $this;
}
public function getIsNearPartner(): ?bool
{
return $this->is_near_partner;
}
public function setIsNearPartner(bool $is_near_partner): self
{
$this->is_near_partner = $is_near_partner;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(string $address): self
{
$this->address = $address;
return $this;
}
}

View file

@ -441,6 +441,12 @@ class JobOrder
*/ */
protected $flag_cust_new; protected $flag_cust_new;
// only for tire service, if it requires sealant or not
/**
* @ORM\Column(type="boolean")
*/
protected $flag_sealant;
public function __construct() public function __construct()
{ {
$this->date_create = new DateTime(); $this->date_create = new DateTime();
@ -458,6 +464,7 @@ class JobOrder
$this->trade_in_type = null; $this->trade_in_type = null;
$this->flag_rider_rating = false; $this->flag_rider_rating = false;
$this->flag_coolant = false; $this->flag_coolant = false;
$this->flag_sealant = false;
$this->priority = 0; $this->priority = 0;
$this->meta = []; $this->meta = [];
@ -1256,4 +1263,15 @@ class JobOrder
return $this->flag_cust_new; return $this->flag_cust_new;
} }
public function setHasSealant($flag = true)
{
$this->flag_sealant = $flag;
return $this;
}
public function hasSealant()
{
return $this->flag_sealant;
}
} }

View file

@ -31,6 +31,7 @@ class TireRepair implements InvoiceRuleInterface
public function compute($criteria, &$total) public function compute($criteria, &$total)
{ {
$stype = $criteria->getServiceType(); $stype = $criteria->getServiceType();
$has_sealant = $criteria->hasSealant();
$pt_id = $criteria->getPriceTier(); $pt_id = $criteria->getPriceTier();
$items = []; $items = [];
@ -56,8 +57,28 @@ class TireRepair implements InvoiceRuleInterface
'price' => $price, 'price' => $price,
]; ];
$qty_price = bcmul($price, $qty, 2); $qty_fee = bcmul($qty, $price, 2);
$total['total_price'] = bcadd($total['total_price'], $qty_price, 2); $total_price = $qty_fee;
if ($has_sealant)
{
$sealant_fee_data = $this->getSealantFeeData();
$sealant_fee = $sealant_fee_data['fee'];
$sealant_title = $sealant_fee_data['title'];
$items[] = [
'service_type' => $this->getID(),
'qty' => $qty,
'title' => $sealant_title,
'price' => $sealant_fee,
];
$qty_price = bcmul($sealant_fee, $qty, 2);
$total_price = bcadd($total_price, $qty_price, 2);
}
$total['total_price'] = bcadd($total['total_price'], $total_price, 2);
} }
return $items; return $items;
@ -131,4 +152,28 @@ class TireRepair implements InvoiceRuleInterface
return $title; return $title;
} }
public function getSealantFeeData()
{
$data = [
'fee' => 0.00,
'title' => '',
];
$code = 'tire_sealant_fee';
// find the service fee using the code
// if we can't find the fee, return 0
$fee = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]);
if ($fee != null)
{
$data = [
'fee' => $fee->getFee(),
'title' => $fee->getName(),
];
}
return $data;
}
} }

View file

@ -18,6 +18,7 @@ class InvoiceCriteria
protected $flag_taxable; protected $flag_taxable;
protected $source; // use Ramcar's TransactionOrigin protected $source; // use Ramcar's TransactionOrigin
protected $price_tier; protected $price_tier;
protected $flag_sealant;
// entries are battery and trade-in combos // entries are battery and trade-in combos
protected $entries; protected $entries;
@ -34,6 +35,7 @@ class InvoiceCriteria
$this->flag_taxable = false; $this->flag_taxable = false;
$this->source = ''; $this->source = '';
$this->price_tier = 0; // set to default $this->price_tier = 0; // set to default
$this->flag_sealant = false;
} }
public function setServiceType($stype) public function setServiceType($stype)
@ -202,4 +204,15 @@ class InvoiceCriteria
{ {
return $this->price_tier; return $this->price_tier;
} }
public function setHasSealant($flag = true)
{
$this->flag_sealant = $flag;
return $this;
}
public function hasSealant()
{
return $this->flag_sealant;
}
} }

View file

@ -69,6 +69,14 @@ class InvoiceManager implements InvoiceGeneratorInterface
->setCustomerVehicle($jo->getCustomerVehicle()) ->setCustomerVehicle($jo->getCustomerVehicle())
->setPriceTier($price_tier); ->setPriceTier($price_tier);
if (($jo->getServiceType() == ServiceType::OVERHEAT_ASSISTANCE) &&
($jo->hasCoolant()))
$criteria->setHasCoolant(true);
if (($jo->getServiceType() == ServiceType::TIRE_REPAIR) &&
($jo->hasSealant()))
$criteria->setHasSealant(true);
// set if taxable // set if taxable
// NOTE: ideally, this should be a parameter when calling generateInvoiceCriteria. But that // NOTE: ideally, this should be a parameter when calling generateInvoiceCriteria. But that
// would mean adding it as a parameter to the call, impacting all calls // would mean adding it as a parameter to the call, impacting all calls

View file

@ -1,191 +0,0 @@
{% 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">Competitors</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="fa fa-building"></i>
</span>
<h3 class="m-portlet__head-text">
{% if mode == 'update' %}
Edit Competitor
<small>{{ obj.getBranchName() }}</small>
{% else %}
New Competitor
{% endif %}
</h3>
</div>
</div>
</div>
<form id="row-form" class="m-form m-form--label-align-right" method="post" action="{{ mode == 'update' ? url('competitor_update_submit', {'id': obj.getId()}) : url('competitor_create_submit') }}">
<div class="m-portlet__body">
<div class="form-group m-form__group row no-border">
<div class="col-lg-6">
<label for="name" data-field="name">
Branch Name
</label>
<input type="text" name="branch_name" class="form-control m-input" value="{{ obj.getBranchName()|default('') }}">
<div class="form-control-feedback hide" data-field="name"></div>
</div>
<div class="col-lg-6">
<label for="branch" data-field="branch">
Brand Being Sold
</label>
<input type="text" name="brand" class="form-control m-input" value="{{ obj.getBrand()|default('') }}">
<div class="form-control-feedback hide" data-field="branch"></div>
</div>
</div>
<div class="form-group m-form__group row no-border">
<div class="col-lg-6">
<label for="name" data-field="name">
Address / Location
</label>
<input type="text" name="address" class="form-control m-input" value="{{ obj.getAddress()|default('') }}">
<div class="form-control-feedback hide" data-field="name"></div>
</div>
</div>
<div class="form-group m-form__group row no-border">
<div class="col-lg-12">
<span class="m-switch m-switch--icon block-switch">
<label>
<input type="checkbox" name="is_near_partner" id="flag_near_partner" value="1"{{ obj.getIsNearPartner() ? ' checked'}}>
<label class="switch-label">Near A Partner</label>
<span></span>
</label>
</span>
<div class="form-control-feedback hide" data-field="enabled"></div>
</div>
</div>
</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('competitor_list') }}" class="btn btn-secondary">Back</a>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
$(function() {
$("#row-form").submit(function(e) {
console.log("no");
var form = $(this);
e.preventDefault();
$.ajax({
method: "POST",
url: form.prop('action'),
data: form.serialize()
}).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('competitor_list') }}";
}
});
}).fail(function(response) {
if (response.status == 422) {
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');
}
});
</script>
{% endblock %}

View file

@ -1,161 +0,0 @@
{% 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">
Competitors
</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__body">
<div class="m-form m-form--label-align-right m--margin-top-20 m--margin-bottom-30">
<div class="row align-items-center">
<div class="col-xl-8 order-2 order-xl-1">
<div class="form-group m-form__group row align-items-center">
<div class="col-md-4">
<div class="m-input-icon m-input-icon--left">
<input type="text" class="form-control m-input m-input--solid" placeholder="Search..." id="data-rows-search">
<span class="m-input-icon__icon m-input-icon__icon--left">
<span><i class="la la-search"></i></span>
</span>
</div>
</div>
</div>
</div>
<div class="col-xl-4 order-1 order-xl-2 m--align-right">
<a href="{{ url('competitor_create') }}" class="btn btn-focus m-btn m-btn--custom m-btn--icon m-btn--air m-btn--pill">
<span>
<i class="fa fa-building"></i>
<span>New Competitor</span>
</span>
</a>
<div class="m-separator m-separator--dashed d-xl-none"></div>
</div>
</div>
</div>
<!--begin: Datatable -->
<div id="data-rows"></div>
<!--end: Datatable -->
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
$(function() {
var options = {
data: {
type: 'remote',
source: {
read: {
url: '{{ url("competitor_rows") }}',
method: 'POST',
}
},
saveState: {
cookie: false,
webstorage: false
},
pageSize: 10,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
columns: [
{
field: 'id',
title: 'ID',
width: 30
},
{
field: 'branch_name',
title: 'Branch Name'
},
{
field: 'brand',
title: 'Brand Being Sold'
},
{
field: 'address',
title: 'Address'
},
{
field: 'is_near_partner',
title: 'Near a Partner?',
},
{
field: 'Actions',
width: 110,
title: 'Actions',
sortable: false,
overflow: 'visible',
template: function (row, index, datatable) {
var actions = '';
if (row.meta.update_url != '') {
console.log(row.branch_name,"hi");
console.log(row);
actions += '<a href="' + row.meta.update_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" data-id="' + row.branch_name + '" title="Edit"><i class="la la-edit"></i></a>';
}
if (row.meta.delete_url != '') {
actions += '<a href="' + row.meta.delete_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-danger m-btn--icon m-btn--icon-only m-btn--pill btn-delete" data-id="' + row.branch_name + '" title="Delete"><i class="la la-trash"></i></a>';
}
return actions;
},
}
],
search: {
onEnter: false,
input: $('#data-rows-search'),
delay: 400
}
};
var table = $("#data-rows").mDatatable(options);
$(document).on('click', '.btn-delete', function(e) {
var url = $(this).prop('href');
var id = $(this).data('id');
var btn = $(this);
console.log($(this).data(),"whee");
e.preventDefault();
swal({
title: 'Confirmation',
html: 'Are you sure you want to delete <strong>' + id + '</strong>?',
type: 'warning',
showCancelButton: true
}).then((result) => {
if (result.value) {
$.ajax({
method: "DELETE",
url: url
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
});
}
});
});
});
</script>
{% endblock %}

View file

@ -1207,6 +1207,8 @@
<script> <script>
var invoiceItems = []; var invoiceItems = [];
var hasCoolant = 0;
var hasSealant = 0;
// location search autocomplete // location search autocomplete
var input = document.getElementById('m_gmap_address'); var input = document.getElementById('m_gmap_address');
@ -1270,6 +1272,19 @@ $(function() {
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
// need to check if jo has coolant or sealant
{% if obj.getServiceType == 'overheat' %}
{% if obj.hasCoolant == 1 %}
hasCoolant = 1;
{% endif %}
{% endif %}
{% if obj.getServiceType == 'tire' %}
{% if obj.hasSealant == 1 %}
hasSealant = 1;
{% endif %}
{% endif %}
{% endif %} {% endif %}
} }
@ -1830,6 +1845,8 @@ $(function() {
'cvid': cvid, 'cvid': cvid,
'coord_lng': lng, 'coord_lng': lng,
'coord_lat': lat, 'coord_lat': lat,
'flag_coolant': hasCoolant,
'flag_sealant': hasSealant,
} }
}).done(function(response) { }).done(function(response) {
// mark as invoice changed // mark as invoice changed

View file

@ -63,4 +63,3 @@
</ul> </ul>
</div> </div>
{% endmacro %} {% endmacro %}

View file

@ -129,8 +129,6 @@
} }
}; };
console.log(options);
var table = $("#data-rows").mDatatable(options); var table = $("#data-rows").mDatatable(options);
$(document).on('click', '.btn-delete', function(e) { $(document).on('click', '.btn-delete', function(e) {

View file

@ -0,0 +1 @@
INSERT INTO service_offering (name, code, fee) VALUES ('Tire Sealant Fee', 'tire_sealant_fee', '200.00');