<?php

class GarageModel extends mainModel {

    public function __construct() {
        $registry = Registry::getInstance();
        $registry->vehicle = new Vehicle;
        $registry->employee = new Employee;
        $registry->expenses = new Expense;
        $registry->Currency = new Currency;
        $registry->payment = new Payment;
    }

    public static function getmsg($msg) {

        return CommonLanguage::getMessage($msg);
    }

    public static function getPieforGarage() {
        $vehicle = new Vehicle;
        $today = Date::getToday();
        $year = date("Y", strtotime($today)); // get the year from today
        $month = date("m", strtotime($today)); // get the month from today
        $per_days = array();
        for ($day = 01; $day < 32; $day++) {
            $fuelList = $vehicle->FuelGraph($year, $month, $day, true);
            if (!is_null($fuelList))
                array_push($per_days, $fuelList);
            else
                array_push($per_days, 0);
        }
        return $per_days;
    }

    public static function topSales() {
        $vehicle = new Vehicle;
        $today = Date::getToday();
        $year = date("Y", strtotime($today)); // get the year from today
        $month = date("m", strtotime($today)); // get the month from today
        $PieTopSold = $vehicle->getTopSalesTruck($year, $month);
        $arrName1 = array();
        for ($i = 0; $i < count($PieTopSold) / 2; $i++) {
            array_push($arrName1, $PieTopSold[$i]);
        }
        $arrValue1 = array();
        for ($i = count($PieTopSold) / 2; $i < count($PieTopSold); $i++) {
            array_push($arrValue1, $PieTopSold[$i]);
        }
        return [$arrName1, $arrValue1];
    }

}
