diff --git a/.env.dist b/.env.dist index b0392b88..30f9a925 100644 --- a/.env.dist +++ b/.env.dist @@ -15,7 +15,7 @@ APP_SECRET=b344cd6cd151ae1d61403ed55806c5ce # Configure your db driver and server_version in config/packages/doctrine.yaml DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name ###< doctrine/doctrine-bundle ### -GMAPS_API_KEY=insertgmapsapikeyhere +GMAPS_API_KEY=insert_gmapsapikey_here # rising tide sms gateway RT_USER=rt_user @@ -28,7 +28,7 @@ RT_SHORTCODE=1234 MQTT_IP_ADDRESS=localhost MQTT_PORT=8883 MQTT_CERT=/location/of/cert/file.crt -MQTT_WS_HOST=insertiphere +MQTT_WS_HOST=insert_ip_here MQTT_WS_PORT=8083 # redis client @@ -38,20 +38,22 @@ REDIS_CLIENT_PORT=6379 REDIS_CLIENT_PASSWORD=foobared # privacy policy ids -POLICY_PROMO=insertpromopolicyidhere -POLICY_THIRD_PARTY=insertthirdpartypolicyidhere -POLICY_MOBILE=insertmobilepolicyidhere +POLICY_PROMO=insert_promopolicyid_here +POLICY_THIRD_PARTY=insert_thirdpartypolicyid_here +POLICY_MOBILE=insert_mobilepolicyid_here # OTP -OTP_MODE=settotestorrandom +OTP_MODE=set_to_test_or_random # geofence -GEOFENCE_ENABLE=settotrueorfalse +GEOFENCE_ENABLE=set_to_true_or_false # unknown manufacturer and vehicle ids -CVU_MFG_ID=insertmfgidforunknownvehicles -CVU_BRAND_ID=insertbrandidforunknownvehicles +CVU_MFG_ID=insert_mfgid_for_unknown_vehicles +CVU_BRAND_ID=insert_brandid_for_unknown_vehicles # country code prefix -COUNTRY_CODE=+insertcountrycodehere +COUNTRY_CODE=+insert_country_code_here +# dashboard +DASHBOARD_ENABLE=set_to_true_or_false diff --git a/config/acl.yaml b/config/acl.yaml index 21f09775..c6ccc243 100644 --- a/config/acl.yaml +++ b/config/acl.yaml @@ -215,6 +215,20 @@ access_keys: - id: rider.delete label: Delete + - id: servicecharge + label: Service Charge + acls: + - id: service_charge.menu + label: Menu + - id: service_charge.list + label: List + - id: service_charge.add + label: Add + - id: service_charge.update + label: Update + - id: service_charge.delete + label: Delete + - id: joborder label: Job Order acls: diff --git a/config/cmb.menu.yaml b/config/cmb.menu.yaml new file mode 100644 index 00000000..7c6b4d82 --- /dev/null +++ b/config/cmb.menu.yaml @@ -0,0 +1,183 @@ +main_menu: + - id: home + acl: dashboard.menu + label: Dashboard + icon: flaticon-line-graph + - id: user + acl: user.menu + label: User + icon: flaticon-users + - id: user_list + acl: user.list + label: Users + parent: user + - id: role_list + acl: role.list + label: Roles + parent: user + + - id: apiuser + acl: apiuser.menu + label: API User + icon: flaticon-users + - id: api_user_list + acl: apiuser.list + label: API Users + parent: apiuser + - id: api_role_list + acl: apirole.list + label: API Roles + parent: apiuser + + - id: logistics + acl: logistics.menu + label: Logistics + icon: fa fa-truck + - id: rider_list + acl: rider.list + label: Riders + parent: logistics + - id: service_charge_list + acl: service_charge.list + label: Service Charges + parent: logistics + + - id: battery + acl: battery.menu + label: Battery + icon: fa fa-battery-3 + - id: battery_list + acl: battery.list + label: Batteries + parent: battery + - id: bmfg_list + acl: bmfg.list + label: Manufacturers + parent: battery + - id: bmodel_list + acl: bmodel.list + label: Models + parent: battery + - id: bsize_list + acl: bsize.list + label: Sizes + parent: battery + - id: promo_list + acl: promo.list + label: Promos + parent: battery + + - id: vehicle + acl: vehicle.menu + label: Vehicle + icon: fa fa-car + - id: vehicle_list + acl: vehicle.list + label: Vehicles + parent: vehicle + - id: vmfg_list + acl: vmfg.list + label: Manufacturers + parent: vehicle + + - id: location + acl: location.menu + label: Location + icon: fa fa-home + - id: outlet_list + acl: outlet.menu + label: Outlet + parent: location + - id: hub_list + acl: hub.menu + label: Hub + parent: location + - id: geofence_list + acl: geofence.menu + label: Geofence + parent: location + + + - id: joborder + acl: joborder.menu + label: Job Order + icon: flaticon-calendar-3 + - id: jo_onestep_form + acl: jo_onestep.form + label: One-step Process + parent: joborder + - id: jo_walkin_form + acl: jo_walkin.form + label: Walk-in + parent: joborder + - id: jo_fulfill + acl: jo_fulfill.list + label: Fulfillment + parent: joborder + - id: jo_open + acl: jo_open.list + label: Open + parent: joborder + - id: jo_all + acl: jo_all.list + label: View All + parent: joborder + + - id: support + acl: support.menu + label: Customer Support + icon: flaticon-support + - id: customer_list + acl: customer.list + label: Customers + parent: support + - id: ticket_list + acl: ticket.list + label: Tickets + parent: support + - id: general_search + acl: general.search + label: Search + parent: support + - id: warranty_search + acl: warranty.search + label: Customer Battery Search + parent: support + - id: privacy_policy_list + acl: privacy_policy.list + label: Privacy Policy + parent: support + - id: warranty_list + acl: warranty.list + label: Warranty + parent: support + - id: warranty_upload + acl: warranty.upload + label: Warranty Upload + parent: support + - id: static_content_list + acl: static_content.list + label: Static Content + parent: support + + - id: service + acl: service.menu + label: Other Services + icon: flaticon-squares + - id: service_list + acl: service.list + label: Services + parent: service + + - id: partner + acl: partner.menu + label: Partners + icon: flaticon-network + - id: partner_list + acl: partner.list + label: Partners + parent: partner + - id: review_list + acl: review.list + label: Reviews + parent: partner diff --git a/config/menu.yaml b/config/menu.yaml index 1f90e314..7c6b4d82 100644 --- a/config/menu.yaml +++ b/config/menu.yaml @@ -37,6 +37,10 @@ main_menu: acl: rider.list label: Riders parent: logistics + - id: service_charge_list + acl: service_charge.list + label: Service Charges + parent: logistics - id: battery acl: battery.menu @@ -106,18 +110,6 @@ main_menu: acl: jo_walkin.form label: Walk-in parent: joborder - - id: jo_in - acl: jo_in.list - label: Incoming - parent: joborder - - id: jo_proc - acl: jo_proc.list - label: Dispatch - parent: joborder - - id: jo_assign - acl: jo_assign.list - label: Rider Assignment - parent: joborder - id: jo_fulfill acl: jo_fulfill.list label: Fulfillment diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index d912927a..cb90797b 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -6,3 +6,4 @@ twig: gmaps_api_key: "%env(GMAPS_API_KEY)%" mqtt_host: "%env(MQTT_WS_HOST)%" mqtt_port: "%env(MQTT_WS_PORT)%" + dashboard_enable: "%env(DASHBOARD_ENABLE)%" diff --git a/config/resq.menu.yaml b/config/resq.menu.yaml new file mode 100644 index 00000000..b0096cf5 --- /dev/null +++ b/config/resq.menu.yaml @@ -0,0 +1,183 @@ +main_menu: + - id: home + acl: dashboard.menu + label: Dashboard + icon: flaticon-line-graph + - id: user + acl: user.menu + label: User + icon: flaticon-users + - id: user_list + acl: user.list + label: Users + parent: user + - id: role_list + acl: role.list + label: Roles + parent: user + + - id: apiuser + acl: apiuser.menu + label: API User + icon: flaticon-users + - id: api_user_list + acl: apiuser.list + label: API Users + parent: apiuser + - id: api_role_list + acl: apirole.list + label: API Roles + parent: apiuser + + - id: logistics + acl: logistics.menu + label: Logistics + icon: fa fa-truck + - id: rider_list + acl: rider.list + label: Riders + parent: logistics + + - id: battery + acl: battery.menu + label: Battery + icon: fa fa-battery-3 + - id: battery_list + acl: battery.list + label: Batteries + parent: battery + - id: bmfg_list + acl: bmfg.list + label: Manufacturers + parent: battery + - id: bmodel_list + acl: bmodel.list + label: Models + parent: battery + - id: bsize_list + acl: bsize.list + label: Sizes + parent: battery + - id: promo_list + acl: promo.list + label: Promos + parent: battery + + - id: vehicle + acl: vehicle.menu + label: Vehicle + icon: fa fa-car + - id: vehicle_list + acl: vehicle.list + label: Vehicles + parent: vehicle + - id: vmfg_list + acl: vmfg.list + label: Manufacturers + parent: vehicle + + - id: location + acl: location.menu + label: Location + icon: fa fa-home + - id: outlet_list + acl: outlet.menu + label: Outlet + parent: location + - id: hub_list + acl: hub.menu + label: Hub + parent: location + - id: geofence_list + acl: geofence.menu + label: Geofence + parent: location + + + - id: joborder + acl: joborder.menu + label: Job Order + icon: flaticon-calendar-3 + - id: jo_in + acl: jo_in.list + label: Incoming + parent: joborder + - id: jo_proc + acl: jo_proc.list + label: Dispatch + parent: joborder + - id: jo_assign + acl: jo_assign.list + label: Rider Assignment + parent: joborder + - id: jo_fulfill + acl: jo_fulfill.list + label: Fulfillment + parent: joborder + - id: jo_open + acl: jo_open.list + label: Open + parent: joborder + - id: jo_all + acl: jo_all.list + label: View All + parent: joborder + + - id: support + acl: support.menu + label: Customer Support + icon: flaticon-support + - id: customer_list + acl: customer.list + label: Customers + parent: support + - id: ticket_list + acl: ticket.list + label: Tickets + parent: support + - id: general_search + acl: general.search + label: Search + parent: support + - id: warranty_search + acl: warranty.search + label: Customer Battery Search + parent: support + - id: privacy_policy_list + acl: privacy_policy.list + label: Privacy Policy + parent: support + - id: warranty_list + acl: warranty.list + label: Warranty + parent: support + - id: warranty_upload + acl: warranty.upload + label: Warranty Upload + parent: support + - id: static_content_list + acl: static_content.list + label: Static Content + parent: support + + - id: service + acl: service.menu + label: Other Services + icon: flaticon-squares + - id: service_list + acl: service.list + label: Services + parent: service + + - id: partner + acl: partner.menu + label: Partners + icon: flaticon-network + - id: partner_list + acl: partner.list + label: Partners + parent: partner + - id: review_list + acl: review.list + label: Reviews + parent: partner diff --git a/config/routes/service_charge.yaml b/config/routes/service_charge.yaml new file mode 100644 index 00000000..c6206371 --- /dev/null +++ b/config/routes/service_charge.yaml @@ -0,0 +1,34 @@ +service_charge_list: + path: /service_charges + controller: App\Controller\ServiceChargeController::index + +service_charge_rows: + path: /service_charges/rows + controller: App\Controller\ServiceChargeController::rows + methods: [POST] + +service_charge_create: + path: /service_charges/create + controller: App\Controller\ServiceChargeController::addForm + methods: [GET] + +service_charge_create_submit: + path: /service_charges/create + controller: App\Controller\ServiceChargeController::addSubmit + methods: [POST] + +service_charge_update: + path: /service_charges/{id} + controller: App\Controller\ServiceChargeController::updateForm + methods: [GET] + +service_charge_update_submit: + path: /service_charges/{id} + controller: App\Controller\ServiceChargeController::updateSubmit + methods: [POST] + +service_charge_delete: + path: /service_charges/{id} + controller: App\Controller\ServiceChargeController::destroy + methods: [DELETE] + diff --git a/src/Controller/JobOrderController.php b/src/Controller/JobOrderController.php index f04ba047..edddc3f1 100644 --- a/src/Controller/JobOrderController.php +++ b/src/Controller/JobOrderController.php @@ -432,7 +432,7 @@ class JobOrderController extends Controller * @Menu(selected="jo_fulfill") */ public function fulfillmentForm(JobOrderHandlerInterface $jo_handler, $id, - GISManagerInterface $gis) + GISManagerInterface $gis, EntityManagerInterface $em) { $this->denyAccessUnlessGranted('jo_fulfill.list', null, 'No access.'); @@ -445,6 +445,8 @@ class JobOrderController extends Controller throw $this->createNotFoundException($e->getMessage()); } + $params['vmfgs'] = $em->getRepository(VehicleManufacturer::class)->findAll(); + $params['vmakes'] = $em->getRepository(Vehicle::class)->findAll(); $params['submit_url'] = $this->generateUrl('jo_fulfill_submit', ['id' => $id]); $params['return_url'] = $this->generateUrl('jo_fulfill'); $params['map_js_file'] = $gis->getJSJOFile(); diff --git a/src/Controller/ServiceChargeController.php b/src/Controller/ServiceChargeController.php new file mode 100644 index 00000000..7208e306 --- /dev/null +++ b/src/Controller/ServiceChargeController.php @@ -0,0 +1,268 @@ +denyAccessUnlessGranted('service_charge.list', null, 'No access.'); + + return $this->render('service-charge/list.html.twig'); + } + + public function rows(Request $req) + { + $this->denyAccessUnlessGranted('service_charge.list', null, 'No access.'); + + // build query + $qb = $this->getDoctrine() + ->getRepository(ServiceCharge::class) + ->createQueryBuilder('q'); + + // get datatable params + $datatable = $req->request->get('datatable'); + + // count total records + $tquery = $qb->select('COUNT(q)'); + + // add fitlers to count query + $this->setQueryFilters($datatable, $tquery); + + $total = $tquery->getQuery() + ->getSingleScalarResult(); + + // get current page number + $page = $datatable['pagination']['page'] ?? 1; + + $perpage = $datatable['pagination']['perpage']; + $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'); + + // add filters to query + $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(); + + // process rows + $rows = []; + foreach ($obj_rows as $orow) { + // add row data + $row['id'] = $orow->getID(); + $row['name'] = $orow->getName(); + + // add row metadata + $row['meta'] = [ + 'update_url' => '', + 'delete_url' => '' + ]; + + // add crud urls + if ($this->isGranted('service_charge.update')) + $row['meta']['update_url'] = $this->generateUrl('service_charge_update', ['id' => $row['id']]); + if ($this->isGranted('service.delete')) + $row['meta']['delete_url'] = $this->generateUrl('service_charge_delete', ['id' => $row['id']]); + + $rows[] = $row; + } + + // response + return $this->json([ + 'meta' => $meta, + 'data' => $rows + ]); + } + + /** + * @Menu(selected="service_charge_list") + */ + public function addForm() + { + $this->denyAccessUnlessGranted('service_charge.add', null, 'No access.'); + + $params = []; + $params['obj'] = new ServiceCharge(); + $params['mode'] = 'create'; + + // response + return $this->render('service-charge/form.html.twig', $params); + } + + public function addSubmit(Request $req, ValidatorInterface $validator, EntityManagerInterface $em) + { + $this->denyAccessUnlessGranted('service_charge.add', null, 'No access.'); + + // create new object + $row = new ServiceCharge(); + + // set and save values + $row->setName($req->request->get('name')); + $row->setAmount($req->request->get('amount')); + + // validate + $errors = $validator->validate($row); + + // 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); + } else { + // validated! save the entity + $em->persist($row); + $em->flush(); + + // return successful response + return $this->json([ + 'success' => 'Changes have been saved!' + ]); + } + } + + /** + * @Menu(selected="service_charge_list") + * @ParamConverter("sc", class="App\Entity\ServiceCharge") + */ + public function updateForm(ServiceCharge $sc) + { + $this->denyAccessUnlessGranted('service_charge.update', null, 'No access.'); + + $params = []; + $params['mode'] = 'update'; + + if ($sc == null) + throw $this->createNotFoundException('The item does not exist'); + + $params['obj'] = $sc; + + // response + return $this->render('service-charge/form.html.twig', $params); + } + + /** + * @ParamConverter("sc", class="App\Entity\ServiceCharge") + */ + public function updateSubmit(Request $req, ValidatorInterface $validator, + ServiceCharge $sc, EntityManagerInterface $em) + { + $this->denyAccessUnlessGranted('service_charge.update', null, 'No access.'); + + // make sure this row exists + if ($sc == null) + throw $this->createNotFoundException('The item does not exist'); + + // set and save values + $sc->setName($req->request->get('name')); + $sc->setAmount($req->request->get('amount')); + + // validate + $errors = $validator->validate($sc); + + // 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); + } else { + // validated! save the entity + $em->flush(); + + // return successful response + return $this->json([ + 'success' => 'Changes have been saved!' + ]); + } + } + + /** + * @Menu(selected="service_list") + * @ParamConverter("sc", class="App\Entity\ServiceCharge") + */ + public function destroy(ServiceCharge $sc, EntityManagerInterface $em) + { + $this->denyAccessUnlessGranted('service_charge.delete', null, 'No access.'); + + $params = []; + + if ($sc == null) + throw $this->createNotFoundException('The item does not exist'); + + // delete this row + $em->remove($sc); + $em->flush(); + + // response + $response = new Response(); + $response->setStatusCode(Response::HTTP_OK); + $response->send(); + } + + protected function setQueryFilters($datatable, &$query) + { + if (isset($datatable['query']['data-rows-search']) && !empty($datatable['query']['data-rows-search'])) { + $query->where('q.name LIKE :filter') + ->setParameter('filter', '%' . $datatable['query']['data-rows-search'] . '%'); + } + } + +} diff --git a/src/Entity/ServiceCharge.php b/src/Entity/ServiceCharge.php index 8ba224cf..98f96c77 100644 --- a/src/Entity/ServiceCharge.php +++ b/src/Entity/ServiceCharge.php @@ -3,6 +3,7 @@ namespace App\Entity; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity @@ -21,6 +22,7 @@ class ServiceCharge // name /** * @ORM\Column(type="string", length=80) + * @Assert\NotBlank() */ protected $name; diff --git a/src/Service/JobOrderHandler/CMBJobOrderHandler.php b/src/Service/JobOrderHandler/CMBJobOrderHandler.php index 7e4c9bb6..d109d4c3 100644 --- a/src/Service/JobOrderHandler/CMBJobOrderHandler.php +++ b/src/Service/JobOrderHandler/CMBJobOrderHandler.php @@ -1387,12 +1387,13 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface { $params['obj'] = new JobOrder(); $params['mode'] = 'onestep'; + $params['jo_service_charges'] = []; $this->fillDropdownParameters($params); $this->fillFormTags($params); // get template to display - $params['template'] = $this->getTwigTemplate('jo_onestep'); + $params['template'] = $this->getTwigTemplate('jo_onestep_form'); // return params return $params; @@ -1407,7 +1408,22 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface $params['mode'] = 'onestep-edit'; $params['cvid'] = $obj->getCustomerVehicle()->getID(); $params['vid'] = $obj->getCustomerVehicle()->getVehicle()->getID(); - $params['jo_service_charges'] = $obj->getMeta('service_charges'); + + // get service charges + $sc_array = []; + $jo_service_charges = $obj->getMeta('service_charges'); + if (!(empty($jo_service_charges))) + { + foreach ($jo_service_charges as $jo_sc_id) + { + // find service charge + $sc_obj = $em->getRepository(ServiceCharge::class)->find($jo_sc_id); + + $sc_array[] = $sc_obj; + } + } + + $params['jo_service_charges'] = $sc_array; $this->fillDropdownParameters($params); $this->fillFormTags($params); @@ -1517,7 +1533,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface { $em = $this->em; - $params['mode'] = 'update-all'; + $params['mode'] = 'view-all'; // get row data $obj = $em->getRepository(JobOrder::class)->find($id); @@ -1529,8 +1545,12 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface $this->fillDropdownParameters($params); $this->fillFormTags($params); - // get template to display - $params['template'] = $this->getTwigTemplate('jo_all_form'); + // get template to display + // check transaction origin if walkin + if ($obj->getSource() == TransactionOrigin::WALK_IN) + $params['template'] = $this->getTwigTemplate('jo_walkin_form'); + else + $params['template'] = $this->getTwigTemplate('jo_onestep_form'); $params['obj'] = $obj; $params['status_cancelled'] = JOStatus::CANCELLED; @@ -2381,7 +2401,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface $this->fillFormTags($params); // get template to display - $params['template'] = $this->getTwigTemplate('jo_walkin'); + $params['template'] = $this->getTwigTemplate('jo_walkin_form'); // return params return $params; @@ -2667,7 +2687,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface $this->fillFormTags($params); // get template to display - $params['template'] = $this->getTwigTemplate('jo_walkin_edit'); + $params['template'] = $this->getTwigTemplate('jo_walkin_edit_form'); // return params return $params; @@ -2775,24 +2795,16 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface // $this->template_hash = [ // 'blah' => 'blah', // ]; - $this->template_hash['jo_incoming_form'] = 'job-order/cmb.form.html.twig'; - $this->template_hash['jo_open_edit_form'] = 'job-order/cmb.form.html.twig'; $this->template_hash['jo_incoming_vehicle_form'] = 'job-order/cmb.form.html.twig'; - $this->template_hash['jo_processing_form'] = 'job-order/cmb.form.html.twig'; - $this->template_hash['jo_assigning_form'] = 'job-order/cmb.form.html.twig'; - $this->template_hash['jo_fulfillment_form'] = 'job-order/cmb.form.html.twig'; - $this->template_hash['jo_open_hub_form'] = 'job-order/cmb.form.html.twig'; - $this->template_hash['jo_open_rider_form'] = 'job-order/cmb.form.html.twig'; - $this->template_hash['jo_all_form'] = 'job-order/cmb.form.html.twig'; - $this->template_hash['jo_list_processing'] = 'job-order/list.processing.html.twig'; - $this->template_hash['jo_list_assigning'] = 'job-order/list.assigning.html.twig'; - $this->template_hash['jo_list_fulfillment'] = 'job-order/list.fulfillment.html.twig'; - $this->template_hash['jo_list_open'] = 'job-order/list.open.html.twig'; + $this->template_hash['jo_fulfillment_form'] = 'job-order/cmb.form.onestep.html.twig'; + $this->template_hash['jo_all_form'] = 'job-order/cmb.form.onestep.html.twig'; + $this->template_hash['jo_list_fulfillment'] = 'job-order/cmb.list.fulfillment.html.twig'; + $this->template_hash['jo_list_open'] = 'job-order/cmb.list.open.html.twig'; $this->template_hash['jo_list_all'] = 'job-order/list.all.html.twig'; - $this->template_hash['jo_onestep'] = 'job-order/cmb.form.onestep.html.twig'; + $this->template_hash['jo_onestep_form'] = 'job-order/cmb.form.onestep.html.twig'; $this->template_hash['jo_onestep_edit_form'] = 'job-order/cmb.form.onestep.html.twig'; - $this->template_hash['jo_walkin'] = 'job-order/cmb.form.walkin.html.twig'; - $this->template_hash['jo_walkin_edit'] = 'job-order/cmb.form.walkin.html.twig'; + $this->template_hash['jo_walkin_form'] = 'job-order/cmb.form.walkin.html.twig'; + $this->template_hash['jo_walkin_edit_form'] = 'job-order/cmb.form.walkin.html.twig'; } protected function checkTier($tier) diff --git a/templates/home.html.twig b/templates/home.html.twig index 975b0ea5..b7ac2c24 100644 --- a/templates/home.html.twig +++ b/templates/home.html.twig @@ -15,7 +15,9 @@ -{{ include('map/' ~ map_js_file) }} +{% if dashboard_enable == 'true' %} + {{ include('map/' ~ map_js_file) }} +{% endif %} {% endblock %} diff --git a/templates/job-order/cmb.form.onestep.html.twig b/templates/job-order/cmb.form.onestep.html.twig index d59172dd..c5246ddb 100644 --- a/templates/job-order/cmb.form.onestep.html.twig +++ b/templates/job-order/cmb.form.onestep.html.twig @@ -389,14 +389,20 @@

- Nearest Hubs + {% if mode in ['view-all', 'update-fulfillment'] %} + Assigned Hub + {% else %} + Nearest Hubs + {% endif %}

- + {% if mode != 'view-all' %} + + {% endif %}
@@ -430,14 +436,20 @@

- Rider Assignment + {% if mode in ['view-all', 'update-fulfillment'] %} + Assigned Rider + {% else %} + Rider Assignment + {% endif %}

- + {% if mode != 'view-all' %} + + {% endif %}
@@ -452,7 +464,7 @@ - {% if mode in ['onestep-edit'] %} + {% if mode in ['onestep-edit', 'view-all', 'update-fulfillment'] %} {% set avail_riders = obj.getHub.getAvailableRiders|default([]) %} @@ -462,7 +474,11 @@ {% if obj.getHub %} {% for rider in avail_riders %} - + {% if mode in ['view-all', 'update-fulfillment'] %} + + {% else %} + + {% endif %} {{ rider.getFirstName }} {{ rider.getLastName }} {{ rider.getContactNumber }} @@ -485,24 +501,26 @@
-
- -
+ {% if mode != 'view-all' %} +
+ +
+ {% endif %}
- - {% for jo_sc_key, jo_sc in obj.getMeta('service_charges')|default([]) %} + + {% for jo_sc in jo_service_charges %}
- {% for key, sc in service_charges %} - + {% endfor %}
- +
@@ -634,9 +652,11 @@
- - {% if ftags.set_map_coordinate and is_granted('joborder.cancel') and not obj.isCancelled %} - Cancel Job Order + {% if mode != 'view-all' %} + + {% if ftags.set_map_coordinate and is_granted('joborder.cancel') and not obj.isCancelled %} + Cancel Job Order + {% endif %} {% endif %} Back
@@ -781,6 +801,32 @@ $(function() { }); {% endif %} + {% if mode in ['view-all', 'update-fulfillment'] %} + var hub_table = ''; + $.getJSON("{{ url('hub_nearest') }}?lat=" + lat + "&long=" + lng, function(data) { + var hubs = data['hubs']; + var hub_marker; + for (i in hubs) { + var hub = hubs[i]; + + if(selected_hub == hub['id']) { + hub_table += ''; + hub_marker = L.marker([hub['lat'], hub['long']], { icon: icon_hub }); + hubLayerGroup.addLayer(hub_marker); + + hub_table += '' + hub['name'] + ''; + hub_table += '' + hub['branch'] + ''; + hub_table += '' + hub['cnum'] + ''; + hub_table += '' + hub['distance'] + ''; + hub_table += ''; + hub_table += ''; + } + } + + $('#nearest_hubs').html(hub_table); + }); + {% endif %} + // add marker to layer group markerLayerGroup.addLayer(marker); @@ -844,76 +890,80 @@ $(function() { }); $(function() { - $('#hubs-table').on('click', 'tr', function() { - var id = $(this).data('id'); + {% if mode != 'view-all' %} + $('#hubs-table').on('click', 'tr', function() { + var id = $(this).data('id'); - riderLayerGroup.clearLayers(); + riderLayerGroup.clearLayers(); - if (id != selected_hub) { + if (id != selected_hub) { - // highlight this row - $('#hubs-table').find('.m-table__row--primary').removeClass('m-table__row--primary'); + // highlight this row + $('#hubs-table').find('.m-table__row--primary').removeClass('m-table__row--primary'); - $(this).addClass('m-table__row--primary'); + $(this).addClass('m-table__row--primary'); - // set hub - selected_hub = id; - $('#hub-field').val(selected_hub); + // set hub + selected_hub = id; + $('#hub-field').val(selected_hub); - // clear rider field - $('#rider-field').val(''); - selected_rider = ''; + // clear rider field + $('#rider-field').val(''); + selected_rider = ''; - // get riders of hub - // get hub riders ajax - // TODO: add latitude and longitude of delivery location to ajax request - var rider_table = ''; - $.getJSON("{{ url('hub_riders') }}?id=" + selected_hub, function(data) { - var riders = data['riders']; - for (i in riders) { - var rider = riders[i]; - var rider_lat = rider['location'][0]; - var rider_lng = rider['location'][1]; - var rider_marker = L.marker([rider_lat, rider_lng], { icon: icon_rider_available }); - riderLayerGroup.addLayer(rider_marker); + // get riders of hub + // get hub riders ajax + // TODO: add latitude and longitude of delivery location to ajax request + var rider_table = ''; + $.getJSON("{{ url('hub_riders') }}?id=" + selected_hub, function(data) { + var riders = data['riders']; + for (i in riders) { + var rider = riders[i]; + var rider_lat = rider['location'][0]; + var rider_lng = rider['location'][1]; + var rider_marker = L.marker([rider_lat, rider_lng], { icon: icon_rider_available }); + riderLayerGroup.addLayer(rider_marker); - rider_table += ''; - rider_table += '' + rider['first_name'] + ''; - rider_table += '' + rider['last_name'] + ''; - rider_table += '' + rider['contact_num'] + ''; - rider_table += '' + rider['plate_num'] + ''; - rider_table += ''; - rider_table += ''; - } + rider_table += ''; + rider_table += '' + rider['first_name'] + ''; + rider_table += '' + rider['last_name'] + ''; + rider_table += '' + rider['contact_num'] + ''; + rider_table += '' + rider['plate_num'] + ''; + rider_table += ''; + rider_table += ''; + } - $('#riders').html(rider_table); - }); - } else { - // unhighlight this row - $(this).removeClass('m-table__row--primary'); - - // remove id value - selected_hub = ''; - } - }); + $('#riders').html(rider_table); + }); + } else { + // unhighlight this row + $(this).removeClass('m-table__row--primary'); + + // remove id value + selected_hub = ''; + } + }); + {% endif %} }); $(function() { - $('#rider-table').on('click', 'tr', function() { - var id = $(this).data('id'); + {% if mode != 'view-all' %} + $('#rider-table').on('click', 'tr', function() { + var id = $(this).data('id'); - // highlight this row - $('#rider-table').find('.m-table__row--primary').removeClass('m-table__row--primary'); + // highlight this row + $('#rider-table').find('.m-table__row--primary').removeClass('m-table__row--primary'); - $(this).addClass('m-table__row--primary'); + $(this).addClass('m-table__row--primary'); - // set rider - selected_rider = id; - $('#rider-field').val(selected_rider); - }); + // set rider + selected_rider = id; + $('#rider-field').val(selected_rider); + }); + {% endif %} }); - {% if mode in ['onestep-edit'] %} + {% if mode in ['onestep-edit', 'view-all', 'update-fulfillment'] %} var lat = {{ obj.getCoordinates.getLatitude }}; var lng = {{ obj.getCoordinates.getLongitude }}; @@ -1307,7 +1357,7 @@ $(function() { var sc_array = []; // populate invoiceItems if editing so that we don't lose the battery - {% if mode in ['open-edit', 'onestep-edit', 'walk-in-edit'] %} + {% if mode in ['view-all', 'open-edit', 'onestep-edit', 'walk-in-edit', 'update-fulfillment'] %} {% if (obj.getInvoice and obj.getInvoice.getItems|length > 0) %} {% for item in obj.getInvoice.getItems %} {% if item.getBattery() %} @@ -1369,14 +1419,13 @@ $(function() { generateInvoice(); }); - // reset the invoice table - $("#btn-reset-invoice").click(function() { - $("#invoice-discount").prop('selectedIndex', 0); + // reset the invoice table + $("#btn-reset-invoice").click(function() { + $("#invoice-discount").val(0); $('.sc-select').closest('.row').remove(); - invoiceItems = []; - sc_array = []; - generateInvoice(); - }); + invoiceItems = []; + generateInvoice(); + }); // recompute $("#btn-recompute-invoice").click(function() { @@ -1389,8 +1438,14 @@ $(function() { var stype = $("#service_type").val(); var cvid = $("#customer-vehicle").val(); - $.each(sc_array, function(index){ - console.log('generateInvoice ' + this.id); + sc_array = []; + + // get the service charges + $('.sc-select').each(function() { + var id = $(this).children('option:selected').val(); + sc_array.push({ + id: id, + }); }); // generate invoice values @@ -1409,39 +1464,39 @@ $(function() { $("#invoice-change").val(1); var invoice = response.invoice; - // populate totals - $("#invoice-discount").val(invoice.discount); - $("#invoice-price").val(invoice.price); - $("#invoice-trade-in").val(invoice.trade_in); - $("#invoice-vat").val(invoice.vat); - $("#invoice-total-amount").val(invoice.total_price); + // populate totals + $("#invoice-discount").val(invoice.discount); + $("#invoice-price").val(invoice.price); + $("#invoice-trade-in").val(invoice.trade_in); + $("#invoice-vat").val(invoice.vat); + $("#invoice-total-amount").val(invoice.total_price); - // populate rows - var html = ''; + // populate rows + var html = ''; - if (invoice.items.length > 0) { - $.each(invoice.items, function(key, item) { - html += '' + - '' + item.title + '' + - '' + item.quantity + '' + - '' + item.unit_price + '' + - '' + item.amount + '' + - /* - '' + - */ - ''; - }); - } else { - html = '' + - '' + - 'No items to display.' + - '' + - ''; - } - - table.html(html); - }); - } + if (invoice.items.length > 0) { + $.each(invoice.items, function(key, item) { + html += '' + + '' + item.title + '' + + '' + item.quantity + '' + + '' + item.unit_price + '' + + '' + item.amount + '' + + /* + '' + + */ + ''; + }); + } else { + html = '' + + '' + + 'No items to display.' + + '' + + ''; + } + + table.html(html); + }); + } // remove from invoice table // TODO: figure out a way to delete rows, and should deleting trade ins be allowed since they count as items on the table? @@ -1677,9 +1732,6 @@ $(function() { $('#sc-section').append(html); - // clear the sc_array - sc_array.length = 0; - // trigger change in select $('#sc-section').find('.sc-select').last().change(); return false; @@ -1691,16 +1743,6 @@ $(function() { $(this).closest('.row').remove(); - sc_array.length = 0; - - // get the service charges - $('.sc-select').each(function() { - var id = $(this).children('option:selected').val(); - sc_array.push({ - id: id, - }); - }); - generateInvoice(); return false; @@ -1710,17 +1752,6 @@ $(function() { var amount = $(this).children('option:selected').data('amount'); $(this).closest('.row').find('.sc-amount').val(amount); - // clear the sc_array - sc_array.length = 0; - - // get the service charges - $('.sc-select').each(function() { - var id = $(this).children('option:selected').val(); - sc_array.push({ - id: id, - }); - }); - generateInvoice(); }); diff --git a/templates/job-order/cmb.form.walkin.html.twig b/templates/job-order/cmb.form.walkin.html.twig index 1a833e63..f2e02e44 100644 --- a/templates/job-order/cmb.form.walkin.html.twig +++ b/templates/job-order/cmb.form.walkin.html.twig @@ -341,9 +341,11 @@
- + {% if mode != 'view-all' %} + + {% endif %}
@@ -358,14 +360,23 @@ - {% for hub in hubs %} - - {{ hub.getName }} - {{ hub.getBranch }} - {{ hub.getContactNumbers }} + {% if mode == 'view-all' %} + + {{ obj.getHub.getName }} + {{ obj.getHub.getBranch }} + {{ obj.getHub.getContactNumbers }} - {% endfor %} + {% else %} + {% for hub in hubs %} + + {{ hub.getName }} + {{ hub.getBranch }} + {{ hub.getContactNumbers }} + + + {% endfor %} + {% endif %}
@@ -495,9 +506,11 @@
- - {% if ftags.set_map_coordinate and is_granted('joborder.cancel') and not obj.isCancelled %} - Cancel Job Order + {% if mode != 'view-all' %} + + {% if ftags.set_map_coordinate and is_granted('joborder.cancel') and not obj.isCancelled %} + Cancel Job Order + {% endif %} {% endif %} Back
@@ -946,12 +959,12 @@ var vdata = false; generateInvoice(); }); - // reset the invoice table - $("#btn-reset-invoice").click(function() { - $("#invoice-discount").prop('selectedIndex', 0); - invoiceItems = []; - generateInvoice(); - }); + // reset the invoice table + $("#btn-reset-invoice").click(function() { + $("#invoice-discount").val(0); + invoiceItems = []; + generateInvoice(); + }); // recompute $("#btn-recompute-invoice").click(function() { diff --git a/templates/job-order/cmb.list.fulfillment.html.twig b/templates/job-order/cmb.list.fulfillment.html.twig new file mode 100644 index 00000000..7cd98ad3 --- /dev/null +++ b/templates/job-order/cmb.list.fulfillment.html.twig @@ -0,0 +1,183 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

+ Job Orders (Fulfillment) +

+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ + + + +
+
+
+
+
+ +
+
+
+
+
+
+ +
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} diff --git a/templates/job-order/cmb.list.open.html.twig b/templates/job-order/cmb.list.open.html.twig new file mode 100644 index 00000000..bffdfd6c --- /dev/null +++ b/templates/job-order/cmb.list.open.html.twig @@ -0,0 +1,190 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

+ Job Orders (Open) +

+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ + + + +
+
+
+
+
+ +
+
+
+
+
+
+ +
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} diff --git a/templates/service-charge/form.html.twig b/templates/service-charge/form.html.twig new file mode 100644 index 00000000..73b5750a --- /dev/null +++ b/templates/service-charge/form.html.twig @@ -0,0 +1,143 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

Service Charges

+
+
+
+ +
+ +
+
+
+
+
+
+ + + +

+ {% if mode == 'update' %} + Edit Service Charge + {{ obj.getID() }} + {% else %} + New Service Charge + {% endif %} +

+
+
+
+
+
+
+
+ + + +
+
+
+
+ + + +
+
+ +
+
+
+
+
+ + Back +
+
+
+
+
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} diff --git a/templates/service-charge/list.html.twig b/templates/service-charge/list.html.twig new file mode 100644 index 00000000..6f92e838 --- /dev/null +++ b/templates/service-charge/list.html.twig @@ -0,0 +1,142 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

+ Service Charges +

+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ + + + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %}