/**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(VehicleRepositoryEloquent $vehicleRepo, EntryRepositoryEloquent $entryRepo, TripRepositoryEloquent $tripRepo)
 {
     $vehiclesStatistics = $vehicleRepo->getVehiclesStatistics();
     $vehiclesLastPlace = $vehicleRepo->getVehiclesLastPlace();
     $lastsServiceCost = $entryRepo->getLastsServiceCostStatistics();
     $servicesStatistics = $entryRepo->getServicesStatistics();
     $tripsStatistics = $tripRepo->getTripsStatistics();
     $lastsFuelCost = $tripRepo->getLastsFuelCostStatistics();
     return View::make('welcome', ['vehiclesStatistics' => $vehiclesStatistics, 'vehiclesLastPlace' => $vehiclesLastPlace, 'lastsServiceCostStatistics' => $lastsServiceCost, 'servicesStatistics' => $servicesStatistics, 'tripsStatistics' => $tripsStatistics, 'lastsFuelCostStatistics' => $lastsFuelCost]);
 }
 public function edit($idPart)
 {
     $part = $this->partRepo->find($idPart);
     $part = $this->partRepo->getInputs($part);
     $this->helper->validateRecord($part);
     $vehicle_id = VehicleRepositoryEloquent::getVehicles(true);
     $vendor_id = ContactRepositoryEloquent::getContacts('vendor', true);
     $part_type_id = TypeRepositoryEloquent::getTypes('part');
     $part_model_id = ModelRepositoryEloquent::getModels('part', array_keys($part_type_id->toArray())[0]);
     $part_id = self::getParts($idPart, true);
     $typedialog = TypeRepositoryEloquent::getDialogStoreOptions('part');
     $modeldialog = ModelRepositoryEloquent::getDialogStoreOptions('part');
     $modeldialog['model_type_id'] = $part->part_type_id;
     $attributes = [];
     if (config('app.attributes_api_url') != null) {
         $attributes = AttributeRepositoryEloquent::getAttributesWithValues('part.' . $part->partType->name, $idPart);
     }
     $sensor_data = $filters = null;
     if ($part->partType->name == Lang::get('setup.sensor')) {
         $filters = $this->helper->getFilters($this->request->all(), $this->tireSensorRepo->getFields(), $this->request);
         $filters['id'] = $part->id;
         $filters['sort'] = 'created_at';
         $filters['order'] = 'desc';
         $sensor_data = $this->tireSensorRepo->results($filters);
     }
     return view("part.edit", compact('part', 'vehicle_id', 'vendor_id', 'part_type_id', 'part_model_id', 'part_id', 'sensor_data', 'filters', 'attributes', 'modeldialog', 'typedialog'));
 }
 public function edit($idTrip)
 {
     $trip = $this->tripRepo->find($idTrip);
     $trip = $this->tripRepo->getInputs($trip);
     $this->helper->validateRecord($trip);
     $company_id = CompanyRepositoryEloquent::getCompanies();
     $vehicle_id = VehicleRepositoryEloquent::getVehicles();
     $driver_id = ContactRepositoryEloquent::getContacts('driver');
     $vendor_id = ContactRepositoryEloquent::getContacts('vendor', true);
     $trip_type_id = TypeRepositoryEloquent::getTypes('trip');
     $fuel_type = TypeRepositoryEloquent::getTypes('fuel');
     $typedialog = TypeRepositoryEloquent::getDialogStoreOptions('trip');
     $attributes = [];
     if (config('app.attributes_api_url') != null) {
         $attributes = AttributeRepositoryEloquent::getAttributesWithValues('trip.' . $trip->type->name, $idTrip);
     }
     return view("trip.edit", compact('trip', 'driver_id', 'vendor_id', 'company_id', 'vehicle_id', 'trip_type_id', 'fuel_type', 'attributes', 'typedialog'));
 }
 public function testVehiclesStatistics()
 {
     $vehicles = [];
     for ($i = 0; $i < 9; $i++) {
         $vehicles[] = factory(\App\Entities\Vehicle::class)->create(['company_id' => $this->company_id]);
     }
     // In use tests
     $trips[0] = factory(\App\Entities\Trip::class)->create(['company_id' => $this->company_id, 'vehicle_id' => $vehicles[0]->id, 'pickup_date' => Carbon::now()->subDays(2)]);
     $trips[1] = factory(\App\Entities\Trip::class)->create(['company_id' => $this->company_id, 'vehicle_id' => $vehicles[1]->id, 'pickup_date' => Carbon::now()->subDays(5), 'deliver_date' => Carbon::now()->addDays(5)]);
     $trips[2] = factory(\App\Entities\Trip::class)->create(['company_id' => $this->company_id, 'vehicle_id' => $vehicles[2]->id, 'pickup_date' => Carbon::now()->subDays(5), 'deliver_date' => Carbon::now()->addDays(5)]);
     // Maintenance tests
     $type = factory(\App\Entities\Type::class)->create(['company_id' => $this->company_id, 'entity_key' => 'vehicle', 'name' => 'repair']);
     $entries[0] = factory(\App\Entities\Entry::class)->create(['company_id' => $this->company_id, 'entry_type_id' => $type->id, 'datetime_ini' => Carbon::now()->subDays(2), 'vehicle_id' => $vehicles[3]->id]);
     $entries[1] = factory(\App\Entities\Entry::class)->create(['company_id' => $this->company_id, 'entry_type_id' => $type->id, 'datetime_ini' => Carbon::now()->subDays(2), 'datetime_end' => Carbon::now()->addDays(5), 'vehicle_id' => $vehicles[4]->id]);
     $statistics = VehicleRepositoryEloquent::getVehiclesStatistics();
     $this->assertEquals($statistics['in_use']['result'], 3);
     $this->assertEquals($statistics['maintenance']['result'], 2);
     $this->assertEquals($statistics['available']['result'], 4);
 }
 public function edit($idEntry)
 {
     $entry = $this->entryRepo->find($idEntry);
     $entry = $this->entryRepo->getInputs($entry);
     $this->helper->validateRecord($entry);
     $company_id = CompanyRepositoryEloquent::getCompanies();
     $entry_type_id = TypeRepositoryEloquent::getTypes('entry');
     $vendor_id = ContactRepositoryEloquent::getContacts('vendor', true);
     $vehicle_id = VehicleRepositoryEloquent::getVehicles();
     $parts = PartRepositoryEloquent::getPartsByVehicle($entry->vehicle_id);
     $entry_parts = [];
     $typedialog = TypeRepositoryEloquent::getDialogStoreOptions('entry');
     foreach ($entry->partsEntries->toArray() as $entryPart) {
         $entry_parts[] = $entryPart['part_id'];
     }
     $attributes = [];
     if (config('app.attributes_api_url') != null) {
         $attributes = AttributeRepositoryEloquent::getAttributesWithValues('entry.' . $entry->type->name, $idEntry);
     }
     return view("entry.edit", compact('entry', 'entry_type_id', 'company_id', 'vehicle_id', 'vendor_id', 'parts', 'entry_parts', 'attributes', 'typedialog'));
 }