85 lines
3.3 KiB
PHP
85 lines
3.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
/**
|
|
* Calendar App
|
|
*
|
|
* @copyright 2021 Anna Larch <anna.larch@gmx.net>
|
|
*
|
|
* @author Anna Larch <anna.larch@gmx.net>
|
|
* @author Richard Steinmetz <richard@steinmetz.cloud>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
|
* License as published by the Free Software Foundation; either
|
|
* version 3 of the License, or any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
namespace OCA\Gestion\Service;
|
|
|
|
use OCA\Gestion\Constants\BddConstant;
|
|
use OCA\Gestion\Db\Bdd;
|
|
use OCA\Gestion\Db\OrderBdd;
|
|
use OCA\Gestion\Db\ProviderRepository;
|
|
use OCA\Gestion\Db\VehicleRepository;
|
|
use OCA\Gestion\Service\Order\OrderService;
|
|
use OCP\IURLGenerator;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class MenuStatisticService {
|
|
|
|
private $gestionBdd;
|
|
private $orderBdd;
|
|
private $providerRepository;
|
|
private $vehicleRepository;
|
|
|
|
public function __construct(
|
|
Bdd $gestionBdd,
|
|
OrderBdd $orderBdd,
|
|
ProviderRepository $providerRepository,
|
|
VehicleRepository $vehicleRepository
|
|
) {
|
|
$this->gestionBdd = $gestionBdd;
|
|
$this->orderBdd = $orderBdd;
|
|
$this->providerRepository = $providerRepository;
|
|
$this->vehicleRepository = $vehicleRepository;
|
|
}
|
|
|
|
/**
|
|
* @NoAdminRequired
|
|
* @NoCSRFRequired
|
|
*/
|
|
public function getStats($idNextCloud,$isUserThanatoOnly = false){
|
|
$res = array();
|
|
$res['client'] = json_decode($this->gestionBdd->numberClient($idNextCloud))[0]->c;
|
|
$res['defunt'] = $this->gestionBdd->numberDefunt($idNextCloud,$isUserThanatoOnly);
|
|
$res['thanato'] = json_decode($this->gestionBdd->numberThanato($idNextCloud))[0]->c;
|
|
$res['devis'] = json_decode($this->gestionBdd->numberDevis($idNextCloud))[0]->c;
|
|
$res['lieu'] = json_decode($this->gestionBdd->numberLieu($idNextCloud))[0]->c;
|
|
$res['trajet'] = json_decode($this->gestionBdd->numberTrajet($idNextCloud))[0]->c;
|
|
$res['facture'] = json_decode($this->gestionBdd->numberFacture($idNextCloud))[0]->c;
|
|
$res['produit'] = json_decode($this->gestionBdd->numberProduit($idNextCloud))[0]->c;
|
|
$res['article'] = json_decode($this->gestionBdd->numberArticle($idNextCloud))[0]->c;
|
|
$res['bibliotheque'] = json_decode($this->gestionBdd->numberBibliotheque($idNextCloud))[0]->c;
|
|
$res['order'] = $this->orderBdd->getOrderCount();
|
|
$res['provider'] = $this->providerRepository->getProviderCount();
|
|
$res['thanatoProductFee'] = $this->orderBdd->getThanatoProductFeeCount();
|
|
$res['clientGroup'] = json_decode($this->gestionBdd->getClientGroupCount())[0]->c;
|
|
$res['clientGroupDiscount'] = json_decode($this->gestionBdd->getClientGroupDiscountCount())[0]->c;
|
|
$res['clientGroupFacturation'] = json_decode($this->gestionBdd->getClientGroupFacturationCount())[0]->c;
|
|
$res['orderProduct'] = $this->orderBdd->getOrderProductCount();
|
|
$res['vehicle'] = $this->vehicleRepository->getVehicleCount();
|
|
return $res;
|
|
}
|
|
|
|
}
|