getJSInitFile(); return $this->render('home.html.twig', $params); } public function getMapLocations(JobOrderCache $jo_cache) { $active_jos = $jo_cache->getAllActiveJobOrders(); // get active JOs from cache } public function getRiderLocations(JobOrderCache $jo_cache, RiderCache $rider_cache, EntityManagerInterface $em, RiderTracker $rider_tracker) { // get active JOs from cache $active_jos = $jo_cache->getAllActiveJobOrders(); $riders = $rider_cache->getAllActiveRiders(); // TODO: optimize this // get all riders and figure out if they have active jos foreach ($riders as $rider_id => $rider_data) { $rider = $em->getRepository(Rider::class)->find($rider_id); if ($rider == null) { unset($riders[$rider_id]); continue; } $jo = $rider->getActiveJobOrder(); if ($jo == null) $riders[$rider_id]['has_jo'] = false; else $riders[$rider_id]['has_jo'] = true; } // get active JOs and check transaction origin for TransactionOrigin::MOBILE_APP foreach ($active_jos as $jo_id => $jo_data) { $jo = $em->getRepository(JobOrder::class)->find($jo_id); if ($jo == null) { unset($active_jos[$jo_id]); continue; } if ($jo->getSource() == TransactionOrigin::MOBILE_APP) { $active_jos[$jo_id]['is_mobile'] = true; } else { $active_jos[$jo_id]['is_mobile'] = false; } } // get active riders from cache // get all riders /* $riders = $em->getRepository(Rider::class)->findAll(); $locations = []; foreach ($riders as $rider) { // get location for each rider $rider_id = $rider->getID(); $coordinates = $rider_tracker->getRiderLocation($rider_id); $lat = $coordinates->getLatitude(); $long = $coordinates->getLongitude(); $jo = $rider->getActiveJobOrder(); if ($jo == null) { $has_jo = false; $clat = 0; $clong = 0; $jo_data = []; } else { $has_jo = true; $cust_loc = $jo->getCoordinates(); $clat = $cust_loc->getLatitude(); $clong = $cust_loc->getLongitude(); $jo_id = $jo->getID(); $jo_data = [ 'id' => $jo_id, 'status' => $jo->getStatusText(), 'stype' => $jo->getServiceTypeName(), 'url' => $this->generateUrl('jo_all_form', ['id' => $jo_id]), 'plate' => $jo->getCustomerVehicle()->getPlateNumber(), 'cname' => $jo->getCustomer()->getNameDisplay(), ]; } // use rider map label as key $rider_map_label = $rider->getMapLabel(); $locations[$rider_id] = [ 'label' => $rider->getMapLabel(), 'loc' => [$lat, $long], 'has_jo' => $has_jo, 'cust_loc' => [$clat, $clong], 'jo' => $jo_data, ]; } */ return $this->json([ 'jos' => $active_jos, 'riders' => $riders, ]); } }