hcportal-dev/mpp.php
2025-08-12 08:48:46 +07:00

223 lines
6.2 KiB
PHP

<?php
namespace modules\endpoint\genba\admin\controller;
use Aiko\Controller;
use Aiko\Http;
use Helper;
use modules\gemba\admin\model\Admin;
if (!defined('__SITE_PATH')) {
exit('No direct script access allowed');
}
class AdminController extends Controller
{
protected $obj;
public function __construct($registry)
{
parent::__construct($registry);
$this->ActionAjaxOff = array('index');
$this->apiModule = 'genbaadmin';
$this->obj = new Admin($this->registry);
$this->generalActions = '*';
}
public function index()
{
$this->isAuthorized();
}
protected function getLineList()
{
$rs = $this->obj->getLineListData();
if (is_array($rs)) {
Http::ResponseJson($rs);
} else {
Http::ErrorQueryResponse('Query Error', 'json');
}
}
protected function getManufactureList()
{
$rs = $this->obj->getRefManufactures();
if (is_array($rs)) {
Http::ResponseJson($rs);
} else {
Http::ErrorQueryResponse('Query Error', 'json');
}
}
protected function getSubAreaFromManufacture()
{
$id = $this->apiParams->manId;
$rs = $this->obj->getSubAreaFromManufacture($id);
if (is_array($rs)) {
Http::ResponseJson($rs);
} else {
Http::ErrorQueryResponse('Query Error', 'json');
}
}
protected function getDivisionFromSubArea()
{
$id = $this->apiParams->subAreaId;
$rs = $this->obj->getDivisionFromSubArea($id);
if (is_array($rs)) {
Http::ResponseJson($rs);
} else {
Http::ErrorQueryResponse('Query Error', 'json');
}
}
protected function getDepartmentName()
{
$departmentId = $this->apiParams->departmentId;
$rs = $this->obj->getDepartmentDivisionName($departmentId);
if (is_array($rs)) {
Http::ResponseJson($rs[0]);
} else {
Http::ErrorQueryResponse('Query Error', 'json');
}
}
protected function getDataEmployee()
{
$empId = $this->apiParams->empId;
$rs = $this->obj->getDataEmployee($empId);
if (is_array($rs)) {
Http::ResponseJson($rs);
} else {
Http::ErrorQueryResponse('User Not Found', 'json');
}
}
protected function getDepartmentFromDivision()
{
$id = $this->apiParams->divisionId;
$subAreaId = $this->apiParams->subAreaId;
$rs = $this->obj->getDepartmentFromDivision($id, $subAreaId);
if (is_array($rs)) {
Http::ResponseJson($rs);
} else {
Http::ErrorQueryResponse('Query Error', 'json');
}
}
protected function searchEmp()
{
$search = $this->apiParams->search;
$rs = $this->obj->searchEmployee($search);
if (is_array($rs)) {
Http::ResponseJson($rs);
} else {
Http::ErrorQueryResponse('Query Error', 'json');
}
}
protected function getManufactureArea()
{
$manufacture_id = $this->apiParams->manId;
$rs = $this->obj->getManufactureArea($manufacture_id);
if (is_array($rs)) {
Http::ResponseJson($rs);
} else {
Http::ResponseJson([], 'json');
}
}
protected function getForemanList() {}
protected function getBu()
{
$search = $this->apiParams->search ?? null;
$rs = $this->obj->GetBusinessUnits($search);
if (is_array($rs)) {
Http::ResponseJson($rs);
} else {
Http::ErrorQueryResponse('Query Error', 'json');
}
}
protected function getTeamMember()
{
$nik = $this->apiParams->nik ?? null;
if (empty($nik)) {
Http::ErrorQueryResponse('NIK is required', 'json');
return;
}
$rs = $this->obj->getTeamMember($nik);
if (is_array($rs)) {
Http::responseJson($rs);
} else {
Http::ErrorQueryResponse('Query Error', 'json');
}
}
protected function getGedung()
{
$buId = $this->apiParams->buId ?? null;
$search = $this->apiParams->search ?? null;
$sectorId = $this->apiParams->id ?? null;
$rs = $this->obj->getSector($buId, $search, $sectorId);
if (is_array($rs)) {
Http::responseJson($rs);
} else {
Http::ErrorQueryResponse('Query Error', 'json');
}
}
protected function getLineByGedung()
{
$buId = $this->apiParams->buId ?? null;
$sectorId = $this->apiParams->sectorId ?? null;
$search = $this->apiParams->search ?? null;
$rs = $this->obj->getGedungSectorLines($buId, $sectorId, $search);
if (is_array($rs)) {
Http::responseJson($rs);
} else {
Http::ErrorQueryResponse('Query Error', 'json');
}
}
protected function getBusinessTitle()
{
$id = $this->apiParams->divisionId;
$subAreaId = $this->apiParams->subAreaId;
$departmentId = $this->apiParams->departmentId;
$rs = $this->obj->getBusinessTitle($id, $departmentId, $subAreaId);
if (is_array($rs)) {
Http::ResponseJson($rs);
} else {
Http::ErrorQueryResponse('Query Error', 'json');
}
}
protected function getOrgLayer()
{
$id = $this->apiParams->divisionId;
$subAreaId = $this->apiParams->subAreaId;
$departmentId = $this->apiParams->departmentId;
$rs = $this->obj->getOrgLayer($id, $departmentId, $subAreaId);
if (is_array($rs)) {
Http::ResponseJson($rs);
} else {
Http::ErrorQueryResponse('Query Error', 'json');
}
}
protected function getMpp()
{
$id = $this->apiParams->divisionId;
$subAreaId = $this->apiParams->subAreaId;
$departmentId = $this->apiParams->departmentId;
$olId = $this->apiParams->olId;
$rs = $this->obj->getMpp($id, $departmentId, $subAreaId, $olId);
if (is_array($rs)) {
Http::ResponseJson($rs);
} else {
Http::ErrorQueryResponse('Query Error', 'json');
}
}
}