Conversie codeigniter 4
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
<?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]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user