88 lines
2.6 KiB
PHP
88 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Reports;
|
|
|
|
use App\Controllers\BaseController;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
|
|
class ReportsController extends BaseController
|
|
{
|
|
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
|
|
if (!defined('AUTHENTICATED') || AUTHENTICATED === false) {
|
|
die('NO ACCESS');
|
|
}
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
// Default action
|
|
}
|
|
|
|
public function recapProjects(string $archive): ResponseInterface
|
|
{
|
|
$field = $this->request->getPost('field');
|
|
$direction = $this->request->getPost('direction');
|
|
|
|
$recapprojects = new \Recapprojects($archive, $field, $direction);
|
|
|
|
$projects = $recapprojects->getProjects();
|
|
|
|
return $this->json($projects);
|
|
}
|
|
|
|
public function getMonthlyEmployeeHoursPerProject(int $employeeID, int $year): ResponseInterface
|
|
{
|
|
$monthlyhours = \Projecthour::getMonthlyEmployeeHoursPerProject($employeeID, $year);
|
|
|
|
return $this->json($monthlyhours);
|
|
}
|
|
|
|
public function getMonthlyEmployeehours(int $month, int $year): ResponseInterface
|
|
{
|
|
$sql = \QEmployeeHours::fire($month, $year);
|
|
|
|
$db = \Config\Database::connect();
|
|
$query = $db->query($sql);
|
|
|
|
$result = $query->getResult();
|
|
|
|
foreach ($result as $user) {
|
|
$user->targethours = \Employeetarget::getTargetHoursPerEmployee($user->user_id, $year, $month);
|
|
}
|
|
|
|
return $this->json($result);
|
|
}
|
|
|
|
public function getInvoiceOverview(int $year, string $orderType, string $orderDirection, string $archive): ResponseInterface
|
|
{
|
|
$invoices = new \Invoices($year, $orderType, $orderDirection, $archive);
|
|
|
|
$invoiceReport = $invoices->getInvoiceReport();
|
|
|
|
return $this->json($invoiceReport);
|
|
}
|
|
|
|
public function createInvoicesSpreadsheet(int $year, string $orderType, string $orderDirection, string $archive): ResponseInterface
|
|
{
|
|
$invoices = new \Invoices($year, $orderType, $orderDirection, $archive);
|
|
|
|
$invoiceReport = $invoices->getInvoiceReport();
|
|
|
|
new \InvoiceSpreadsheet($invoiceReport);
|
|
|
|
return $this->json(['success' => true]);
|
|
}
|
|
|
|
public function saveCurrentFinnacialYear(int $projectID): ResponseInterface
|
|
{
|
|
$amount = $this->request->getPost('amount');
|
|
|
|
\Project::whereId($projectID)->update(['current_financial_year' => $amount]);
|
|
|
|
return $this->json(['success' => true]);
|
|
}
|
|
}
|