remove be

This commit is contained in:
Imam Syahid Hudzaifah 2025-08-12 08:48:46 +07:00
commit 891b57a5c6
27 changed files with 20272 additions and 0 deletions

16
.dockerignore Normal file
View File

@ -0,0 +1,16 @@
# Git-related files and directories
.git
.gitignore
.gitattributes
# Specific paths
/app/src/api/vendor
/app/src/api/log
# Common files to ignore
README.md
LICENSE
# OS generated files
.DS_Store
Thumbs.db

56
Dockerfile.backend Normal file
View File

@ -0,0 +1,56 @@
# Use the official PHP 7.3 Apache base image
FROM php:7.3-apache
# Install system dependencies
RUN apt-get update && apt-get install -y \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
libzip-dev \
unzip \
git \
curl \
rsyslog
# Install PHP extensions
RUN docker-php-ext-install pdo pdo_mysql mysqli zip
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install -j$(nproc) gd
# Install Composer version 1
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --version=1.10.22
WORKDIR /app
# Copying Config Files
COPY ./be/src/api/composer.json ./src/api/composer.json
COPY ./be/src/api/Aiko/ ./src/api/Aiko/
COPY ./be/src/api/Helper/ ./src/api/Helper/
RUN cd /app/src/api && composer install
# Copying controllers
COPY ./be .
RUN cd /app/src/api && composer dump-autoload -o
RUN chmod -R 777 /app/src/api/log && chmod -R 777 /app/src/api/vendor
# Configure Apache
COPY apache-config.conf /etc/apache2/sites-available/000-default.conf
COPY custom-logging.conf /etc/apache2/conf-available/custom-logging.conf
RUN a2enmod proxy && \
a2enmod proxy_http && \
a2enmod proxy_balancer && \
a2enmod lbmethod_byrequests && \
a2enmod rewrite && \
a2enconf custom-logging
# Copy rsyslog configuration
COPY rsyslog.conf /etc/rsyslog.conf
# Create and set permissions for the start script
COPY entrypoint-backend.sh /usr/local/bin/start-services.sh
RUN chmod +x /usr/local/bin/start-services.sh
# Use the script as the entry point
CMD ["/usr/local/bin/start-services.sh"]

19
Dockerfile.frontend Normal file
View File

@ -0,0 +1,19 @@
FROM mcr.microsoft.com/devcontainers/typescript-node:20
MAINTAINER Imam Syahid Hudzaifa <me@imamsyahid.dev>
WORKDIR /app
COPY ./fe/package*.json ./
RUN npm install
COPY ./fe .
# Default app name is hcportal, but can be overridden at runtime
ENV APP_NAME=hcportal
EXPOSE 4200
# Copy the entrypoint script
COPY entrypoint-frontend.sh /entrypoint.sh
# Make the entrypoint script executable
RUN chmod +x /entrypoint.sh
# Set the entrypoint
ENTRYPOINT ["/entrypoint.sh"]

File diff suppressed because it is too large Load Diff

10
admin/controller/index.html Executable file
View File

@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

10
admin/index.html Executable file
View File

@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

6073
admin/model/Admin.php Executable file

File diff suppressed because it is too large Load Diff

3939
admin/model/Adminquerytrait.php Executable file

File diff suppressed because it is too large Load Diff

432
admin/model/DbBuilderHelper.php Executable file
View File

@ -0,0 +1,432 @@
<?php
namespace modules\gemba\admin\model;
use ErrorException;
use Exception;
use PDO;
use PDOException;
/**
*
*/
trait DbBuilderHelper
{
public $enabledDebugMode = false;
public function dbBuilderUpdate($table, $column = [], $where = [])
{
try {
$sql = "UPDATE $table SET ";
$ctr = count($column);
for ($i = 0; $i < $ctr; $i++) {
$cKey = $column[$i]['key'];
$sql .= "`$cKey` = :$cKey";
$next = $i + 1;
if ($next < $ctr) {
$sql .= ', ';
}
}
$ctrWhere = count($where);
for ($i = 0; $i < $ctrWhere; $i++) {
$exp = isset($where[$i]['exp']) ? $where[$i]['exp'] : ' AND ';
$opr = isset($where[$i]['opr']) ? $where[$i]['opr'] : ' = ';
$wKey = $where[$i]['key'];
if ($i == 0) {
$sql .= " WHERE `$wKey` $opr :$wKey";
continue;
}
$sql .= "$exp `$wKey` $opr :$wKey";
}
$sql = str_replace(' ', ' ', $sql);
$stmt = $this->registry->db->prepare($sql);
for ($i = 0; $i < $ctr; $i++) {
$bind = isset($column[$i]['bind']) ? $column[$i]['bind'] : PDO::PARAM_STR;
$cKey = $column[$i]['key'];
$stmt->bindValue(":$cKey", $column[$i]['val'], $bind);
}
for ($i = 0; $i < $ctrWhere; $i++) {
$bind = isset($where[$i]['bind']) ? $where[$i]['bind'] : PDO::PARAM_STR;
$wKey = $where[$i]['key'];
$stmt->bindValue(":$wKey", $where[$i]['val'], $bind);
}
$this->checkDebugMode($stmt);
$stmt->execute();
return true;
} catch (PDOException $e) {
$this->registry
->log
->error('CompleteRegisterHelper / action : dbBuilderUpdate : '
. $e->getMessage() . ', Line: '
. $e->getLine());
return false;
} catch (ErrorException $e) {
$this->registry
->log
->error('CompleteRegisterHelper / action : dbBuilderUpdate : '
. $e->getMessage() . ', Line: '
. $e->getLine());
return false;
}
}
public function dbBuilderInsert($table, $column = [], $insertId = false)
{
try {
$sql = "INSERT INTO $table ";
$ctr = count($column);
$columnKey = '';
$binderKey = '';
for ($i = 0; $i < $ctr; $i++) {
$cKey = $column[$i]['key'];
$next = $i + 1;
if ($i === 0) {
$columnKey .= '(';
$binderKey .= '(';
}
$columnKey .= "`$cKey`";
$binderKey .= ":$cKey";
if ($next < $ctr) {
$columnKey .= ', ';
$binderKey .= ', ';
}
if ($next === $ctr) {
$columnKey .= ')';
$binderKey .= ')';
}
}
$sql .= "$columnKey VALUES $binderKey";
$stmt = $this->registry->db->prepare($sql);
for ($i = 0; $i < $ctr; $i++) {
$bind = isset($column[$i]['bind']) ? $column[$i]['bind'] : PDO::PARAM_STR;
$cKey = $column[$i]['key'];
$stmt->bindValue(":$cKey", $column[$i]['val'], $bind);
}
$this->checkDebugMode($stmt);
$stmt->execute();
if ($insertId) {
return $this->registry->db->lastInsertId();
}
return true;
} catch (PDOException $e) {
$this->registry
->log
->error('CompleteRegisterHelper / action : dbBuilderInsert : '
. $e->getMessage() . ', Line: '
. $e->getLine());
return false;
} catch (ErrorException $e) {
$this->registry
->log
->error('CompleteRegisterHelper / action : dbBuilderInsert : '
. $e->getMessage() . ', Line: '
. $e->getLine());
return false;
}
}
public function dbBuilderDelete($table, $columnWhere, $id, $bind = PDO::PARAM_INT)
{
try {
$sql = "DELETE FROM $table WHERE $columnWhere = :id";
$stmt = $this->registry->db->prepare($sql);
$stmt->bindValue(':id', $id, $bind);
$this->checkDebugMode($stmt);
$stmt->execute();
return true;
} catch (PDOException $e) {
$this->registry
->log
->error('CompleteRegisterHelper / action : dbBuilderDelete : '
. $e->getMessage() . ', Line: '
. $e->getLine());
return false;
} catch (ErrorException $e) {
$this->registry
->log
->error('CompleteRegisterHelper / action : dbBuilderDelete : '
. $e->getMessage() . ', Line: '
. $e->getLine());
return false;
}
}
public function dbBuilderDeleteMultiWhere($table, $where = [])
{
try {
$sql = "DELETE FROM $table WHERE [[rw]] ";
$stmt = $this->registry->db->prepare($sql);
$ctrWhere = count($where);
$whereColumn = '';
for ($i = 0; $i < $ctrWhere; $i++) {
$exp = isset($where[$i]['exp']) ? $where[$i]['exp'] : ' AND ';
$opr = isset($where[$i]['opr']) ? $where[$i]['opr'] : ' = ';
$wKey = $where[$i]['key'];
if ($i == 0) {
$whereColumn .= "`$wKey` $opr :$wKey";
continue;
}
$whereColumn .= "$exp `$wKey` $opr :$wKey";
}
$sql = str_replace('[[rw]]', $whereColumn, $sql);
$stmt = $this->registry->db->prepare($sql);
for ($i = 0; $i < $ctrWhere; $i++) {
$bind = isset($where[$i]['bind']) ? $where[$i]['bind'] : PDO::PARAM_INT;
$wKey = $where[$i]['key'];
$stmt->bindValue(":$wKey", $where[$i]['val'], $bind);
}
$this->checkDebugMode($stmt);
$stmt->execute();
return true;
} catch (PDOException $e) {
$this->registry
->log
->error('CompleteRegisterHelper / action : dbBuilderDeleteMultiWhere : '
. $e->getMessage() . ', Line: '
. $e->getLine());
return false;
} catch (ErrorException $e) {
$this->registry
->log
->error('CompleteRegisterHelper / action : dbBuilderDeleteMultiWhere : '
. $e->getMessage() . ', Line: '
. $e->getLine());
return false;
}
}
public function dbBuilderSelect($table, $column = ['*'], $where = [])
{
try {
$sql = "SELECT [[rc]] FROM $table WHERE [[rw]]";
$ctrColumn = count($column);
$keyColumn = '';
for ($i = 0; $i < $ctrColumn; $i++) {
$cKey = $column[$i];
$next = $i + 1;
$keyColumn .= $cKey === '*' ? $cKey : "`$cKey`";
if ($next < $ctrColumn) {
$keyColumn .= ', ';
}
}
$sql = str_replace('[[rc]]', $keyColumn, $sql);
$ctrWhere = count($where);
$whereColumn = '';
for ($i = 0; $i < $ctrWhere; $i++) {
$exp = isset($where[$i]['exp']) ? $where[$i]['exp'] : ' AND ';
$opr = isset($where[$i]['opr']) ? $where[$i]['opr'] : ' = ';
$wKey = $where[$i]['key'];
if ($i == 0) {
$whereColumn .= "`$wKey` $opr :$wKey";
continue;
}
$whereColumn .= "$exp `$wKey` $opr :$wKey";
}
if (count($where) === 0) {
$sql = str_replace('WHERE', '', $sql);
}
$sql = str_replace('[[rw]]', $whereColumn, $sql);
$stmt = $this->registry->db->prepare($sql);
for ($i = 0; $i < $ctrWhere; $i++) {
$bind = isset($where[$i]['bind']) ? $where[$i]['bind'] : PDO::PARAM_STR;
$wKey = $where[$i]['key'];
$stmt->bindValue(":$wKey", $where[$i]['val'], $bind);
}
$this->checkDebugMode($stmt);
$stmt->execute();
return $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOexception $e) {
$this->registry
->log
->error('CompleteRegisterHelper / action : dbBuilderSelect : '
. $e->getMessage() . ', Line: '
. $e->getLine());
return array();
} catch (ErrorException $e) {
$this->registry
->log
->error('CompleteRegisterHelper / action : dbBuilderSelect : '
. $e->getMessage() . ', Line: '
. $e->getLine());
return array();
}
}
private function checkDebugMode($stmt)
{
if ($this->enabledDebugMode) {
$stmt->debugDumpParams();
die();
}
}
public function dbBuilderSelectJoin($table, $column = ['*'], $where = [],$order="")
{
try {
$sql = "SELECT [[rc]] FROM $table WHERE [[rw]] $order";
$ctrColumn = count($column);
$keyColumn = '';
for ($i = 0; $i < $ctrColumn; $i++) {
$cKey = $column[$i];
$next = $i + 1;
$keyColumn .= $cKey === '*' ? $cKey : "$cKey";
if ($next < $ctrColumn) {
$keyColumn .= ', ';
}
}
$sql = str_replace('[[rc]]', $keyColumn, $sql);
$ctrWhere = count($where);
$whereColumn = '';
for ($i = 0; $i < $ctrWhere; $i++) {
$startSymbol = isset($where[$i]['start_symbol']) ? $where[$i]['start_symbol'] : '';
$endSymbol = isset($where[$i]['end_symbol']) ? $where[$i]['end_symbol'] : '';
$exp = isset($where[$i]['exp']) ? $where[$i]['exp'] : ' AND ';
$opr = isset($where[$i]['opr']) ? $where[$i]['opr'] : ' = ';
$wField = isset($where[$i]['field'])?$where[$i]['field']:$where[$i]['key'];
$wVal = isset($where[$i]['val'])?$where[$i]['val']:'';
$wKey = isset($where[$i]['key'])?$where[$i]['key']:'';
if ($i == 0) {
if($wKey == ''){
$whereColumn .= "$startSymbol :$wField $opr '$wVal' $endSymbol";
}else{
if($opr == 'in'){
$whereColumn .= "$startSymbol $wKey $opr ('". implode("','", $wVal) . "') $endSymbol";
}else if($opr == 'IS NULL'){
$whereColumn .= "$wKey $opr";
}else if($opr == 'between'){
$start = isset($where[$i]['start'])?$where[$i]['start']:'';
$end = isset($where[$i]['end'])?$where[$i]['end']:'';
$whereColumn .= "$wKey $opr '".$start."' AND '".$end."'";
}else{
$whereColumn .= "$startSymbol $wKey $opr :$wField $endSymbol";
}
}
continue;
}
if($wKey == ''){
$whereColumn .= " $exp $startSymbol :$wField $opr '$wVal' $endSymbol";
}else{
if($opr == 'in'){
$whereColumn .= " $exp $startSymbol $wKey $opr ('". implode("','", $wVal) . "') $endSymbol";
}else if($opr == 'IS NULL'){
$whereColumn .= "$exp $wKey $opr";
}else if($opr == 'between'){
$start = isset($where[$i]['start'])?$where[$i]['start']:'';
$end = isset($where[$i]['end'])?$where[$i]['end']:'';
$whereColumn .= "$exp $wKey $opr '".$start."' AND '".$end."'";
}else{
$whereColumn .= " $exp $startSymbol $wKey $opr :$wField $endSymbol";
}
}
}
if (count($where) === 0) {
$sql = str_replace('WHERE', '', $sql);
}
$sql = str_replace('[[rw]]', $whereColumn, $sql);
$stmt = $this->registry->db->prepare($sql);
for ($i = 0; $i < $ctrWhere; $i++) {
$bind = isset($where[$i]['bind']) ? $where[$i]['bind'] : PDO::PARAM_STR;
$wField = isset($where[$i]['field'])?$where[$i]['field']:$where[$i]['key'];
$opr = isset($where[$i]['opr']) ? $where[$i]['opr'] : ' = ';
$wKey = isset($where[$i]['key'])?$where[$i]['key']:'';
if($wKey != ''){
if($opr == 'LIKE'){
$stmt->bindValue(":$wField", '%'.$where[$i]['val'].'%', $bind);
}else if($opr == 'in'){
}else if($opr == 'IS NULL'){
}else if($opr == 'between'){
}else{
$stmt->bindValue(":$wField", $where[$i]['val'], $bind);
}
}
}
// var_dump($stmt);
// die();
$this->checkDebugMode($stmt);
$stmt->execute();
return $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOexception $e) {
$this->registry
->log
->error('CompleteRegisterHelper / action : dbBuilderSelect : '
. $e->getMessage() . ', Line: '
. $e->getLine().' , table : '
.$table );
return array();
} catch (ErrorException $e) {
$this->registry
->log
->error('CompleteRegisterHelper / action : dbBuilderSelect : '
. $e->getMessage() . ', Line: '
. $e->getLine().' , table : '
.$table);
return array();
}
}
}

751
admin/model/Upload.php Executable file
View File

@ -0,0 +1,751 @@
<?php
namespace modules\gemba\admin\model;
use Aiko\Model;
use PDOException;
use PDO;
use ErrorException;
use Exception;
use PHPExcel;
use DateTime;
if (!defined('__SITE_PATH')) {
exit('No direct script access allowed');
}
class Upload extends Model
{
use \modules\gemba\admin\model\DbBuilderHelper, Adminquerytrait;
public function __construct($registry)
{
parent::__construct($registry);
}
public function importDataQuestion($file)
{
$filename = $this->saveFile($file);
$objWorkSheet = $this->getWorkSheet($filename['newfilename'], 0);
$data = $this->getDataQuestionUpload($objWorkSheet);
return $this->saveDataQuestionList($data);
}
private function getWorkSheet($fileName, $sheetIndex)
{
$objPHPExcel = new PHPExcel();
$inputFileType = \PHPExcel_IOFactory::identify($fileName);
$objReader = \PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load($fileName);
$total_sheets = $objPHPExcel->getSheetCount();
$objWorkSheet = $objPHPExcel->setActiveSheetIndex($sheetIndex);
return $objWorkSheet;
}
private function saveFile($file)
{
$filename = $file->getClientOriginalName();
$mimeType = $file->getClientMimeType();
$fileExtension = $file->guessExtension();
$mimeClientAlowed = array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-excel');
if (!in_array($mimeType, $mimeClientAlowed)) {
throw new Exception('error file type');
}
$targetPath = $this->registry->config->base_storage. '/uploadfile/gemba_question/';
$targetFile = str_replace('//', '/', $targetPath);
$obj11 = $file->move($targetFile, $filename);
$newfilename = $targetFile . $filename;
return array('filename' => $filename, 'newfilename' => $newfilename);
}
public function getDataQuestionUpload($objWorkSheet)
{
$startRow = 3;
$endRow = $objWorkSheet->getHighestRow();
$kodeSoalCol = $this->getColomIndex('A');
$areaCol = $this->getColomIndex('B');
$soalCol = $this->getColomIndex('C');
$detailSoalCol = $this->getColomIndex('D');
$kodeTypeSoalCol = $this->getColomIndex('E');
$idCategoryCol = $this->getColomIndex('F');
$sectionIdCol = $this->getColomIndex('G');
$jumlahJawabanCol = $this->getColomIndex('H');
$itemJawabanCol = $this->getColomIndex('I');
$scoreJawabanCol = $this->getColomIndex('J');
$groupQuestionCol = $this->getColomIndex('K');
$data = array();
for ($i = $startRow; $i <= $endRow; $i++) {
$item = array();
$kodeSoal = $objWorkSheet->getCellByColumnAndRow($kodeSoalCol, $i)->getFormattedValue();
$area = $objWorkSheet->getCellByColumnAndRow($areaCol, $i)->getFormattedValue();
$soal = $objWorkSheet->getCellByColumnAndRow($soalCol, $i)->getFormattedValue();
$detailSoal = $objWorkSheet->getCellByColumnAndRow($detailSoalCol, $i)->getFormattedValue();
$kodeTypeSoal = $objWorkSheet->getCellByColumnAndRow($kodeTypeSoalCol, $i)->getFormattedValue();
$idCategory = $objWorkSheet->getCellByColumnAndRow($idCategoryCol, $i)->getFormattedValue();
$sectionId = $objWorkSheet->getCellByColumnAndRow($sectionIdCol, $i)->getFormattedValue();
$jumlahJawaban = $objWorkSheet->getCellByColumnAndRow($jumlahJawabanCol, $i)->getFormattedValue();
$itemJawaban = $objWorkSheet->getCellByColumnAndRow($itemJawabanCol, $i)->getFormattedValue();
$scoreJawaban = $objWorkSheet->getCellByColumnAndRow($scoreJawabanCol, $i)->getFormattedValue();
if ($kodeSoal) {
$item['kode_soal'] = $kodeSoal;
$item['area'] = $area;
$item['soal'] = $soal;
$item['detail_soal'] = $detailSoal;
$item['kode_type_soal'] = $kodeTypeSoal;
$item['id_category'] = $idCategory;
$item['section_id'] = $sectionId;
$item['jumlah_jawaban'] = $jumlahJawaban;
$item['item_jawaban'] = $itemJawaban;
$item['score_jawaban'] = $scoreJawaban;
array_push($data, $item);
}
}
$data_soal = $this->unique_att_rev($data, false, 'kode_soal');
foreach ($data_soal as $key => $value) {
$data_soal[$key]['detail'] = array_filter($data, function ($var) use ($value) {
return ($var['kode_soal'] == $value['kode_soal']);
});
}
return $data_soal;
}
private function getColomIndex($col)
{
$idx = \PHPExcel_Cell::columnIndexFromString($col);
return $idx - 1;
}
public function unique_att_rev($array, $keep_key_assoc = false, $keys)
{
$duplicate_keys = array();
$tmp = array();
foreach ($array as $key => $val) {
if (!in_array($val[$keys], $tmp))
$tmp[] = $val[$keys];
else
$duplicate_keys[] = $key;
}
foreach ($duplicate_keys as $key)
unset($array[$key]);
return $keep_key_assoc ? $array : array_values($array);
}
public function saveDataQuestionList($data,$upload=false)
{
try {
if(!$upload){
$this->registry->db->beginTransaction();
}
// var_dump($data);die();
// $item['kode_soal'] = $kodeSoal;
// $item['area'] = $area;
// $item['soal'] = $soal;
// $item['detail_soal'] = $detailSoal;
// $item['kode_type_soal'] = $kodeTypeSoal;
// $item['id_category'] = $idCategory;
// $item['section_id'] = $sectionId;
// $item['jumlah_jawaban'] = $jumlahJawaban;
// $item['item_jawaban'] = $itemJawaban;
// $item['score_jawaban'] = $scoreJawaban;
foreach ($data as $i => $q) {
$type=$this->dbBuilderSelectJoin('gmb_question_types t1',
[
't1.*'
],
[
['field' => 'code_type','key' => 't1.code_type', 'val' => $q['kode_type_soal'], 'bind' => PDO::PARAM_STR],
]
);
$this->registry->log->error($q['kode_type_soal'].' '.$i.' '.$q['kode_soal']);
$question = $this->dbBuilderInsert('gmb_questions', [
['key' => 'question_code', 'val' => $q['kode_soal'], 'bind' => PDO::PARAM_STR],
['key' => 'question', 'val' => $q['soal'], 'bind' => PDO::PARAM_STR],
['key' => 'question_description', 'val' => $q['soal'], 'bind' => PDO::PARAM_STR],
['key' => 'jum_answer', 'val' => $q['jumlah_jawaban'], 'bind' => PDO::PARAM_STR],
['key' => 'gmb_question_types_id', 'val' => $type[0]['id'], 'bind' => PDO::PARAM_STR],
['key' => 'gmb_question_section_id', 'val' => $q['section_id'], 'bind' => PDO::PARAM_STR],
['key' => 'gmb_question_category_id', 'val' => $q['id_category'], 'bind' => PDO::PARAM_STR],
['key' => 'gmb_question_group_id', 'val' => '1', 'bind' => PDO::PARAM_STR],
],
true);
if (!$question) {
return false;
}
foreach ($q['detail'] as $j => $item) {
if($item['detail_soal'] != '' && $item['detail_soal']){
$question_item = $this->dbBuilderInsert('gmb_qustion_items', [
['key' => 'item_name', 'val' => $item['detail_soal'], 'bind' => PDO::PARAM_STR],
['key' => 'gmb_questions_id', 'val' => $question, 'bind' => PDO::PARAM_STR],
],
true);
if (!$question_item) {
return false;
}
}
}
$order=1;
foreach ($q['detail'] as $j => $answer) {
if($answer['item_jawaban'] != '' && $answer['item_jawaban']){
$gmb_answer_detail = $this->dbBuilderInsert('gmb_answer_detail', [
['key' => 'answer_score', 'val' => $answer['score_jawaban'], 'bind' => PDO::PARAM_STR],
['key' => 'answer_label', 'val' => $answer['item_jawaban'], 'bind' => PDO::PARAM_STR],
['key' => 'order', 'val' => $order, 'bind' => PDO::PARAM_STR],
['key' => 'gmb_questions_id', 'val' => $question, 'bind' => PDO::PARAM_STR],
],
true);
if (!$gmb_answer_detail) {
return false;
}
$order++;
}
}
}
// return false;
if(!$upload){
$this->registry->db->commit();
$message = "PAYROLL.MESSAGE.SUCCMESINS";
$status = "PAYROLL.MESSAGE.SUCCESS";
return $this->sendResponse([], $message, $status);
}else{
return true;
}
} catch (PDOException $e) {
$this->registry->db->rollBack();
$this->registry->log->error('Gemba-saveEventGemba: ' . $e->getMessage() . ', Line: ' . $e->getLine() . ', File: ' . $e->getFile() . ', User: ' . \Helper::getSessionVar('username'));
$message = "PAYROLL.MESSAGE.FAILMESQUERY";
$status = "PAYROLL.MESSAGE.FAILED";
return $this->sendResponse([], $message, $status);
} catch (ErrorException $e) {
$this->registry->db->rollBack();
$this->registry->log->error('Gemba-saveEventGemba: ' . $e->getMessage() . ', Line: ' . $e->getLine() . ', File: ' . $e->getFile() . ', User: ' . \Helper::getSessionVar('username'));
$message = "PAYROLL.MESSAGE.FAILMESUNKNOWN";
$status = "PAYROLL.MESSAGE.FAILED";
return $this->sendResponse([], $message, $status);
}
}
public function importDataActivities($file)
{
$filename = $this->saveFile($file);
$objWorkSheet = $this->getWorkSheet($filename['newfilename'], 0);
$data = $this->getDataActivitiesUpload($objWorkSheet);
// var_dump($data);
// die();
return $this->saveDataActivitiesList($data);
}
public function getDataActivitiesUpload($objWorkSheet)
{
$startRow = 2;
$endRow = $objWorkSheet->getHighestRow();
$endColumn = $objWorkSheet->getHighestColumn();
if ($endColumn == 'N') {
$idCol = $this->getColomIndex('A');
$businessUnitIdCol = $this->getColomIndex('B');
$refWorkScopeIdCol = $this->getColomIndex('C');
$sectionIdCol = $this->getColomIndex('D');
$departmentIdCol = $this->getColomIndex('E');
$activitiesCol = $this->getColomIndex('F');
$yesScoreCol = $this->getColomIndex('G');
$noScoreCol = $this->getColomIndex('H');
$yesNoteCol = $this->getColomIndex('I');
$noNoteCol = $this->getColomIndex('J');
$orderNoCol = $this->getColomIndex('K');
$categoryIdCol = $this->getColomIndex('L');
$riskLevelIdCol = $this->getColomIndex('M');
$linkReveranceCol = $this->getColomIndex('N');
$data = array();
for ($i = $startRow; $i <= $endRow; $i++) {
$item = array();
$id = $objWorkSheet->getCellByColumnAndRow($idCol, $i)->getFormattedValue();
$businessUnitId = $objWorkSheet->getCellByColumnAndRow($businessUnitIdCol, $i)->getFormattedValue();
$refWorkScopeId = $objWorkSheet->getCellByColumnAndRow($refWorkScopeIdCol, $i)->getFormattedValue();
$sectionId = $objWorkSheet->getCellByColumnAndRow($sectionIdCol, $i)->getFormattedValue();
$departmentId = $objWorkSheet->getCellByColumnAndRow($departmentIdCol, $i)->getFormattedValue();
$activities = $objWorkSheet->getCellByColumnAndRow($activitiesCol, $i)->getFormattedValue();
$yesScore = $objWorkSheet->getCellByColumnAndRow($yesScoreCol, $i)->getFormattedValue();
$noScore = $objWorkSheet->getCellByColumnAndRow($noScoreCol, $i)->getFormattedValue();
$categoryId = $objWorkSheet->getCellByColumnAndRow($categoryIdCol, $i)->getFormattedValue();
$riskLevelId = $objWorkSheet->getCellByColumnAndRow($riskLevelIdCol, $i)->getFormattedValue();
$orderNo = $objWorkSheet->getCellByColumnAndRow($orderNoCol, $i)->getFormattedValue();
$yesRequired = $objWorkSheet->getCellByColumnAndRow($yesNoteCol, $i)->getFormattedValue();
$noRequired = $objWorkSheet->getCellByColumnAndRow($noNoteCol, $i)->getFormattedValue();
$linkReverance = $objWorkSheet->getCellByColumnAndRow($linkReveranceCol, $i)->getFormattedValue();
if ($businessUnitId) {
$item['id'] = $id;
$item['description'] = $activities;
$item['gmbs_question_category_id'] = $categoryId;
$item['gmbs_question_section_id'] = $sectionId;
$item['gmbs_ref_risk_level_id'] = $riskLevelId;
$item['gmbs_ref_work_scopes_id'] = $refWorkScopeId;
$item['score_yes'] = $yesScore;
$item['score_no'] = $noScore;
$item['order_no'] = $orderNo;
$item['yes_required_note'] = $yesRequired;
$item['no_required_note'] = $noRequired;
$item['reference_link'] = $linkReverance;
array_push($data, $item);
}
}
} else {
$businessUnitIdCol = $this->getColomIndex('A');
$refWorkScopeIdCol = $this->getColomIndex('B');
$sectionIdCol = $this->getColomIndex('C');
$departmentIdCol = $this->getColomIndex('D');
$activitiesCol = $this->getColomIndex('E');
$yesScoreCol = $this->getColomIndex('F');
$noScoreCol = $this->getColomIndex('G');
$yesNoteCol = $this->getColomIndex('H');
$noNoteCol = $this->getColomIndex('I');
$orderNoCol = $this->getColomIndex('J');
$categoryIdCol = $this->getColomIndex('K');
$riskLevelIdCol = $this->getColomIndex('L');
$linkReveranceCol = $this->getColomIndex('M');
$data = array();
for ($i = $startRow; $i <= $endRow; $i++) {
$item = array();
$businessUnitId = $objWorkSheet->getCellByColumnAndRow($businessUnitIdCol, $i)->getFormattedValue();
$refWorkScopeId = $objWorkSheet->getCellByColumnAndRow($refWorkScopeIdCol, $i)->getFormattedValue();
$sectionId = $objWorkSheet->getCellByColumnAndRow($sectionIdCol, $i)->getFormattedValue();
$departmentId = $objWorkSheet->getCellByColumnAndRow($departmentIdCol, $i)->getFormattedValue();
$activities = $objWorkSheet->getCellByColumnAndRow($activitiesCol, $i)->getFormattedValue();
$yesScore = $objWorkSheet->getCellByColumnAndRow($yesScoreCol, $i)->getFormattedValue();
$noScore = $objWorkSheet->getCellByColumnAndRow($noScoreCol, $i)->getFormattedValue();
$categoryId = $objWorkSheet->getCellByColumnAndRow($categoryIdCol, $i)->getFormattedValue();
$riskLevelId = $objWorkSheet->getCellByColumnAndRow($riskLevelIdCol, $i)->getFormattedValue();
$orderNo = $objWorkSheet->getCellByColumnAndRow($orderNoCol, $i)->getFormattedValue();
$yesRequired = $objWorkSheet->getCellByColumnAndRow($yesNoteCol, $i)->getFormattedValue();
$noRequired = $objWorkSheet->getCellByColumnAndRow($noNoteCol, $i)->getFormattedValue();
$linkReverance = $objWorkSheet->getCellByColumnAndRow($linkReveranceCol, $i)->getFormattedValue();
if ($businessUnitId) {
$item['description'] = $activities;
$item['gmbs_question_category_id'] = $categoryId;
$item['gmbs_question_section_id'] = $sectionId;
$item['gmbs_ref_risk_level_id'] = $riskLevelId;
$item['gmbs_ref_work_scopes_id'] = $refWorkScopeId;
$item['score_yes'] = $yesScore;
$item['score_no'] = $noScore;
$item['order_no'] = $orderNo;
$item['yes_required_note'] = $yesRequired;
$item['no_required_note'] = $noRequired;
$item['reference_link'] = $linkReverance;
array_push($data, $item);
}
}
}
return $data;
}
public function saveDataActivitiesList($data,$upload=false)
{
try {
if(!$upload){
$this->registry->db->beginTransaction();
}
$error=0;
$error_message=[];
// $result = array();
// foreach ($data as $key => $value){
// $filterArr = array_filter($result, function ($var) use ($value) {
// return $var['gmbs_question_category_id'] == $value['gmbs_question_category_id'] && $var['gmbs_question_section_id'] == $value['gmbs_question_section_id'] && $var['description'] == $value['description'];
// });
// if (!$filterArr) {
// $result[] = $value;
// }
// }
foreach ($data as $i => $q) {
if (isset($q['id']) && $q['id']) {
$master_update = $this->dbBuilderUpdate('gmbs_activities',
[
['key' => 'order_no', 'val' => $q['order_no'], 'bind' => PDO::PARAM_STR],
['key' => 'description', 'val' => $q['description'], 'bind' => PDO::PARAM_STR],
['key' => 'gmbs_question_category_id', 'val' => $q['gmbs_question_category_id'], 'bind' => PDO::PARAM_STR],
['key' => 'gmbs_question_section_id', 'val' => $q['gmbs_question_section_id'], 'bind' => PDO::PARAM_STR],
['key' => 'gmbs_ref_risk_level_id', 'val' => $q['gmbs_ref_risk_level_id'], 'bind' => PDO::PARAM_STR],
['key' => 'gmbs_ref_work_scopes_id', 'val' => $q['gmbs_ref_work_scopes_id'], 'bind' => PDO::PARAM_STR],
['key' => 'reference_link', 'val' => $q['reference_link'], 'bind' => PDO::PARAM_STR],
], [
['key' => 'id', 'val' => $q['id'], 'bind' => PDO::PARAM_INT],
]);
if (!$master_update) {
return false;
}
$this->dbBuilderDelete('gmbs_answer_detail', 'gmbs_activities_id', $q['id']);
$question_item = $this->dbBuilderInsert('gmbs_answer_detail', [
['key' => 'answer_score', 'val' => $q['score_yes'], 'bind' => PDO::PARAM_STR],
['key' => 'answer_label', 'val' => 'YES', 'bind' => PDO::PARAM_STR],
['key' => 'order', 'val' => 1, 'bind' => PDO::PARAM_STR],
['key' => 'qualitative_answer', 'val' => 'Standar', 'bind' => PDO::PARAM_STR],
['key' => 'is_require_note', 'val' => $q['yes_required_note'], 'bind' => PDO::PARAM_STR],
['key' => 'gmbs_activities_id', 'val' => $q['id'], 'bind' => PDO::PARAM_STR],
],
true);
if (!$question_item) {
return false;
}
$question_item = $this->dbBuilderInsert('gmbs_answer_detail', [
['key' => 'answer_score', 'val' => $q['score_no'], 'bind' => PDO::PARAM_STR],
['key' => 'answer_label', 'val' => 'NO', 'bind' => PDO::PARAM_STR],
['key' => 'order', 'val' => 2, 'bind' => PDO::PARAM_STR],
['key' => 'qualitative_answer', 'val' => 'Tidak Standar', 'bind' => PDO::PARAM_STR],
['key' => 'is_require_note', 'val' => $q['no_required_note'], 'bind' => PDO::PARAM_STR],
['key' => 'gmbs_activities_id', 'val' => $q['id'], 'bind' => PDO::PARAM_STR],
],
true);
if (!$question_item) {
return false;
}
} else {
$question = $this->dbBuilderInsert('gmbs_activities', [
['key' => 'order_no', 'val' => $q['order_no'], 'bind' => PDO::PARAM_STR],
['key' => 'description', 'val' => $q['description'], 'bind' => PDO::PARAM_STR],
['key' => 'gmbs_question_category_id', 'val' => $q['gmbs_question_category_id'], 'bind' => PDO::PARAM_STR],
['key' => 'gmbs_question_section_id', 'val' => $q['gmbs_question_section_id'], 'bind' => PDO::PARAM_STR],
['key' => 'gmbs_ref_risk_level_id', 'val' => $q['gmbs_ref_risk_level_id'], 'bind' => PDO::PARAM_STR],
['key' => 'gmbs_ref_work_scopes_id', 'val' => $q['gmbs_ref_work_scopes_id'], 'bind' => PDO::PARAM_STR],
['key' => 'is_publish', 'val' => '1', 'bind' => PDO::PARAM_STR],
['key' => 'reference_link', 'val' => $q['reference_link'], 'bind' => PDO::PARAM_STR],
],
true);
if (!$question) {
$gmbs_question_category=$this->dbBuilderSelectJoin('gmbs_question_category t1',
[
't1.*'
],
[
['field' => 'id','key' => 't1.id', 'val' => $q['gmbs_question_category_id'], 'bind' => PDO::PARAM_STR],
]
);
if(count($gmbs_question_category) == 0){
array_push($error_message,array(
"note"=>"gmbs_question_category id ".$q['gmbs_question_category_id']." not found"
));
$error++;
}
$gmbs_question_section=$this->dbBuilderSelectJoin('gmbs_question_section t1',
[
't1.*'
],
[
['field' => 'id','key' => 't1.id', 'val' => $q['gmbs_question_section_id'], 'bind' => PDO::PARAM_STR],
]
);
if(count($gmbs_question_section) == 0){
array_push($error_message,array(
"note"=>"gmbs_question_section id ".$q['gmbs_question_section_id']." not found"
));
$error++;
}
$gmbs_ref_risk_level=$this->dbBuilderSelectJoin('gmbs_ref_risk_level t1',
[
't1.*'
],
[
['field' => 'id','key' => 't1.id', 'val' => $q['gmbs_ref_risk_level_id'], 'bind' => PDO::PARAM_STR],
]
);
if(count($gmbs_ref_risk_level) == 0){
array_push($error_message,array(
"note"=>"gmbs_ref_risk_level id ".$q['gmbs_ref_risk_level_id']." not found"
));
$error++;
}
$gmbs_ref_work_scopes=$this->dbBuilderSelectJoin('gmbs_ref_work_scopes t1',
[
't1.*'
],
[
['field' => 'id','key' => 't1.id', 'val' => $q['gmbs_ref_work_scopes_id'], 'bind' => PDO::PARAM_STR],
]
);
if(count($gmbs_ref_work_scopes) == 0){
array_push($error_message,array(
"note"=>"gmbs_ref_work_scopes id ".$q['gmbs_ref_work_scopes_id']." not found"
));
$error++;
}
continue;
}
$question_item = $this->dbBuilderInsert('gmbs_answer_detail', [
['key' => 'answer_score', 'val' => $q['score_yes'], 'bind' => PDO::PARAM_STR],
['key' => 'answer_label', 'val' => 'YES', 'bind' => PDO::PARAM_STR],
['key' => 'order', 'val' => 1, 'bind' => PDO::PARAM_STR],
['key' => 'qualitative_answer', 'val' => 'Standar', 'bind' => PDO::PARAM_STR],
['key' => 'is_require_note', 'val' => $q['yes_required_note'], 'bind' => PDO::PARAM_STR],
['key' => 'gmbs_activities_id', 'val' => $question, 'bind' => PDO::PARAM_STR],
],
true);
if (!$question_item) {
return false;
}
$question_item = $this->dbBuilderInsert('gmbs_answer_detail', [
['key' => 'answer_score', 'val' => $q['score_no'], 'bind' => PDO::PARAM_STR],
['key' => 'answer_label', 'val' => 'NO', 'bind' => PDO::PARAM_STR],
['key' => 'order', 'val' => 2, 'bind' => PDO::PARAM_STR],
['key' => 'qualitative_answer', 'val' => 'Tidak Standar', 'bind' => PDO::PARAM_STR],
['key' => 'is_require_note', 'val' => $q['no_required_note'], 'bind' => PDO::PARAM_STR],
['key' => 'gmbs_activities_id', 'val' => $question, 'bind' => PDO::PARAM_STR],
],
true);
if (!$question_item) {
return false;
}
}
}
// return false;
if($error == 0){
$this->registry->db->commit();
return array(
'pesan' => 'Berhasil Upload Data',
'status' => 1,
'moreInfo'=>$error_message);
}else{
return array(
'pesan' => 'Gagal Upload Data',
'status' => 0,
'moreInfo'=>[]);
}
// if(!$upload){
// $this->registry->db->commit();
// $message = "PAYROLL.MESSAGE.SUCCMESINS";
// $status = "PAYROLL.MESSAGE.SUCCESS";
// return $this->sendResponse([], $message, $status);
// }else{
// return true;
// }
} catch (PDOException $e) {
$this->registry->db->rollBack();
$this->registry->log->error('Gemba-saveEventGemba: ' . $e->getMessage() . ', Line: ' . $e->getLine() . ', File: ' . $e->getFile() . ', User: ' . \Helper::getSessionVar('username'));
$message = "PAYROLL.MESSAGE.FAILMESQUERY";
$status = "PAYROLL.MESSAGE.FAILED";
return $this->sendResponse([], $message, $status);
} catch (ErrorException $e) {
$this->registry->db->rollBack();
$this->registry->log->error('Gemba-saveEventGemba: ' . $e->getMessage() . ', Line: ' . $e->getLine() . ', File: ' . $e->getFile() . ', User: ' . \Helper::getSessionVar('username'));
$message = "PAYROLL.MESSAGE.FAILMESUNKNOWN";
$status = "PAYROLL.MESSAGE.FAILED";
return $this->sendResponse([], $message, $status);
}
}
public function importDataLineRunning($file)
{
$filename = $this->saveFile($file);
$objWorkSheet = $this->getWorkSheet($filename['newfilename'], 0);
$data = $this->getDataLineRunningUpload($objWorkSheet);
// var_dump($data);
// die();
return $this->saveDataLineRunningList($data);
}
public function getDataLineRunningUpload($objWorkSheet)
{
$startRow = 2;
$endRow = $objWorkSheet->getHighestRow();
$runningDateCol = $this->getColomIndex('A');
$lineIdCol = $this->getColomIndex('B');
$shiftGroupIdCol = $this->getColomIndex('C');
$data = array();
for ($i = $startRow; $i <= $endRow; $i++) {
$item = array();
$runningDate = \PHPExcel_Style_NumberFormat::toFormattedString($objWorkSheet->getCellByColumnAndRow($runningDateCol, $i)->getValue(), 'YYYY-MM-DD');
$lineId = $objWorkSheet->getCellByColumnAndRow($lineIdCol, $i)->getFormattedValue();
$shiftGroupId = $objWorkSheet->getCellByColumnAndRow($shiftGroupIdCol, $i)->getFormattedValue();
if ($runningDate) {
$item['running_date'] = $runningDate;
$item['ref_shift_group_id'] = $shiftGroupId;
$item['gedung_sector_line_id'] = $lineId;
array_push($data, $item);
}
}
return $data;
}
public function saveDataLineRunningList($data,$upload=false)
{
try {
if(!$upload){
$this->registry->db->beginTransaction();
}
$error=0;
$error_message=[];
foreach ($data as $i => $q) {
$question = $this->dbBuilderInsert('gmbs_line_running', [
['key' => 'running_date', 'val' => $q['running_date'], 'bind' => PDO::PARAM_STR],
['key' => 'ref_shift_group_id', 'val' => $q['ref_shift_group_id'], 'bind' => PDO::PARAM_STR],
['key' => 'gedung_sector_line_id', 'val' => $q['gedung_sector_line_id'], 'bind' => PDO::PARAM_STR],
],
true);
if (!$question) {
$gedung_sector_line=$this->dbBuilderSelectJoin('gedung_sector_line t1',
[
't1.*'
],
[
['field' => 'id','key' => 't1.id', 'val' => $q['gedung_sector_line_id'], 'bind' => PDO::PARAM_STR],
]
);
if(count($gedung_sector_line) == 0){
array_push($error_message,array(
"note"=>"gedung_sector_line id ".$q['gedung_sector_line_id']." not found"
));
$error++;
}
$ref_shift_group=$this->dbBuilderSelectJoin('ref_shift_group t1',
[
't1.*'
],
[
['field' => 'id','key' => 't1.id', 'val' => $q['ref_shift_group_id'], 'bind' => PDO::PARAM_STR],
]
);
if(count($ref_shift_group) == 0){
array_push($error_message,array(
"note"=>"ref_shift_group id ".$q['ref_shift_group_id']." not found"
));
$error++;
}
continue;
}
}
// return false;
if($error == 0){
$this->registry->db->commit();
return array(
'pesan' => 'Berhasil Upload Data',
'status' => 1,
'moreInfo'=>$error_message);
}else{
return array(
'pesan' => 'Gagal Upload Data',
'status' => 0,
'moreInfo'=>[]);
}
// if(!$upload){
// $this->registry->db->commit();
// $message = "PAYROLL.MESSAGE.SUCCMESINS";
// $status = "PAYROLL.MESSAGE.SUCCESS";
// return $this->sendResponse([], $message, $status);
// }else{
// return true;
// }
} catch (PDOException $e) {
$this->registry->db->rollBack();
$this->registry->log->error('Gemba-saveEventGemba: ' . $e->getMessage() . ', Line: ' . $e->getLine() . ', File: ' . $e->getFile() . ', User: ' . \Helper::getSessionVar('username'));
$message = "PAYROLL.MESSAGE.FAILMESQUERY";
$status = "PAYROLL.MESSAGE.FAILED";
return $this->sendResponse([], $message, $status);
} catch (ErrorException $e) {
$this->registry->db->rollBack();
$this->registry->log->error('Gemba-saveEventGemba: ' . $e->getMessage() . ', Line: ' . $e->getLine() . ', File: ' . $e->getFile() . ', User: ' . \Helper::getSessionVar('username'));
$message = "PAYROLL.MESSAGE.FAILMESUNKNOWN";
$status = "PAYROLL.MESSAGE.FAILED";
return $this->sendResponse([], $message, $status);
}
}
}

10
admin/model/index.html Executable file
View File

@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

View File

@ -0,0 +1,67 @@
<?php
$objPHPExcel = new \PHPExcel();
// Set document properties
$objPHPExcel->getProperties()->setCreator("Nabati")
->setLastModifiedBy("Nabati")
->setTitle("Office 2007 XLSX TEMPLATE UPLOAD ")
->setSubject("TEMPLATE UPLOAD ")
->setDescription("TEMPLATE UPLOAD ")
->setKeywords("office 2007 openxml php")
->setCategory("TEMPLATE UPLOAD ");
$cel = 1;
$condition = "new, second, scrap";
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'No')
->setCellValue('B1', 'Department')
->setCellValue('C1', 'Business Unit')
->setCellValue('D1', 'Line')
->setCellValue('E1', 'Section')
->setCellValue('F1', 'Activities')
->setCellValue('G1', 'PIC')
->setCellValue('H1', 'Note')
->setCellValue('I1', 'Date Time')
->setCellValue('J1', 'Photo');
$row=2;
foreach ($list as $key => $value) {
$photoStr = "";
if (isset($value['photo']) && count($value['photo']) !== 0) {
foreach ($value['photo'] as $val) {
$photoStr .= $val['img'] .", ";
}
}
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A'.($row+$key), ($key+1))
->setCellValue('B'.($row+$key), $value['department_name'])
->setCellValue('C'.($row+$key), $value['bu_name'])
->setCellValue('D'.($row+$key), $value['line_name'])
->setCellValue('E'.($row+$key), $value['section_name'])
->setCellValue('F'.($row+$key), $value['activities'])
->setCellValue('G'.($row+$key), $value['pic_name'])
->setCellValue('H'.($row+$key), $value['note'])
->setCellValue('I'.($row+$key), $value['date_time'])
->setCellValue('J'.($row+$key), $photoStr);
}
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
// Redirect output to a clients web browser (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="export-data-monitoring.xlsx"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header('Pragma: public'); // HTTP/1.0
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
$objPHPExcel->disconnectWorksheets();
unset($objPHPExcel);
exit;

203
admin/views/report.php Executable file
View File

@ -0,0 +1,203 @@
<?php
// print_r($list);
// exit();
$objPHPExcel = new \PHPExcel();
// Set document properties
$objPHPExcel->getProperties()->setCreator("Syamsudin")
->setLastModifiedBy("Syamsudin")
->setTitle("Office 2007 XLSX Test Document")
->setSubject("Export Data")
->setDescription("Export Data")
->setKeywords("office 2007 openxml php")
->setCategory("Export Data");
// $myJSON = json_encode($list);
// echo $myJSON;
// // var_dump($list);
// die();
$event=$list['event'];
$assesor='';
$manufacture_name='';
$products_name='';
if($event){
$assesor=isset($event[0]['fullname'])?$event[0]['fullname']:'';
$manufacture_name=$event[0]['ref_manunfactures_name'];
$products_name=$event[0]['ref_manunfacture_products_name'];
}
$cel = 2;
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A' . $cel, 'Nama Pabrik')
->setCellValue('B' . ($cel), $manufacture_name)
->setCellValue('A' . ($cel+1), 'Nama Produk')
->setCellValue('B' . ($cel+1), $products_name)
->setCellValue('A' . ($cel+2), 'Assesor')
->setCellValue('B' . ($cel+2), $assesor);
$cel = 5;
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('E' . $cel, 'SCORE')
->setCellValue('E' . ($cel+1), 'Result (Actual) Grouping :');
$cel = 5;
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('E' . $cel, 'SCORE')
->setCellValue('E' . ($cel+1), 'Result (Actual) Grouping :');
$column='J';
$header=$list['header'];
for ($i=0; $i < count($header); $i++) {
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue($column.'' . ($cel), $header[$i]['name']);
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue($column.'' . ($cel+1), ($header[$i]['total_score']/$list['total_all_max_score'])*100);
$column++;
$column++;
$column++;
$column++;
}
$cel = 7;
$event_section=$list['gmb_event_sections'];
for ($i=0; $i < count($event_section); $i++) {
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A' . ($cel+1), $event_section[$i]['first_question'])
->setCellValue('B' . ($cel+1), '-')
->setCellValue('C' . ($cel+1), $event_section[$i]['last_question'])
->setCellValue('D' . ($cel+1), $event_section[$i]['section_name'])
->setCellValue('E' . ($cel+1), $event_section[$i]['ach_result_section'])
->setCellValue('F' . ($cel+1), $event_section[$i]['score'])
->setCellValue('G' . ($cel+1), '/')
->setCellValue('H' . ($cel+1), $event_section[$i]['weight']);
$column='J';
$header=$event_section[$i]['category_type'];
foreach ($header as $key => $value) {
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue($column.'' . ($cel+1), $value['total_score']);
$column++;
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue($column.'' . ($cel+1), '/');
$column++;
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue($column.'' . ($cel+1), $value['total_max_score']);
$column++;
$column++;
}
$cel++;
}
$column='J';
$header=$list['header'];
// var_dump($header);die();
for ($i=0; $i < count($header); $i++) {
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue($column.'' . ($cel+1), ($header[$i]['total_score']/$header[$i]['total_max_score'])*100);
$column++;
$column++;
$column++;
$column++;
}
$cel++;
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A' . ($cel+1), 'PLANT SECTION ACHIEVEMENT');
$cel++;
for ($i=0; $i < count($event_section); $i++) {
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A' . ($cel+1), 'SECTION SCORE')
->setCellValue('A' . ($cel+2), $event_section[$i]['ach_result_section'])
->setCellValue('C' . ($cel+1), 'VALUES')
->setCellValue('D' . ($cel+1), $event_section[$i]['section_name'])
->setCellValue('E' . ($cel+1), 'Grand Total');
$cel++;
$header=$event_section[$i]['category_type'];
foreach ($header as $key => $value) {
// var_dump($value);die();
if($value['type'] == 'types'){
$score=ROUND(($value['total_score']/$value['total_max_score'])*100,2);
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('C' . ($cel+1), $value['name'])
->setCellValue('D' . ($cel+1), $score)
->setCellValue('E' . ($cel+1), $score);
$cel++;
}
}
$cel++;
$cel++;
}
foreach(range('A',$column) as $columnID) {
$objPHPExcel->getActiveSheet()
->getColumnDimension($columnID)
->setAutoSize(true);
}
// $style = array(
// 'alignment' => array(
// 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
// )
// );
$objPHPExcel->getDefaultStyle()->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);;
// Rename worksheet
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
if($generate){
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="gemba-report-'.strtotime(date('Y-m-d')).'.xls"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace(__FILE__,'/hcportal_docs/gembareport/'.$filename,__FILE__));
$objPHPExcel->disconnectWorksheets();
unset($objPHPExcel);
// $obj->sendMailAttAwnReport($filename,$mail);
}else{
// Redirect output to a clients web browser (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="gemba-report.xls"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
$objPHPExcel->disconnectWorksheets();
unset($objPHPExcel);
}
exit;
// var_dump($objPHPExcel);

94
admin/views/reportpdf.php Executable file
View File

@ -0,0 +1,94 @@
<?php
use Dompdf\Dompdf;
$dompdf = new DOMPDF();
// $is_date_mcu=getdate(date("U",$list['date_mcu']));
// var_Dump($list);
// die();
$header=$list['header'];
$header_length=count($list['header']);
$html_header="";
$html_section="";
foreach ($header as $key => $value) {
$html_header.="<td style='text-align:center'>{$value['name']}</td>";
}
$event_section=$list['gmb_event_sections'];
$html_section="";
foreach ($event_section as $key => $value) {
$no=$key+1;
$html_section.="<tr>";
$html_section.="<td style='text-align:center'>{$no}</td>";
$html_section.="<td style='text-align:left'>{$value['section_name']}</td>";
$html_section.="<td style='text-align:center'>{$value['ach_result_section']}</td>";
foreach ($value['category_type'] as $j => $vj) {
$score=ROUND(($vj['total_score']/$vj['total_max_score'])*100,2);
$html_section.="<td style='text-align:center'>{$score}</td>";
}
$html_section.="</tr>";
}
$html = "<table class='table-style' style='border-collapse: collapse;font-size: 12px'>
<tr>
<td style='width: 20%;text-align:left;' colspan='3'>
<b style='display:block; margin:auto;text-align:left;padding-top:10px;'>
<img src='https://talentpool.hcnabati.com/assets/images/logos/new_logo.png' style='width: 70px;' />
</b>
</td>
</tr>
</table>
<br>
<br>
<br>
<table class='table-style' style='border-collapse: collapse;font-size: 12px'>
<tr>
<td>Subject</td>
<td width='1%'>:</td>
<td>Genba Result Report</td>
</tr>
<tr>
<td>Periode</td>
<td width='1%'>:</td>
<td></td>
</tr>
</table>
<p style='font-size: 12px'>Dear All Leaders,</p>
<p style='font-size: 12px'>Dengan berlangsungnya kegiatan GENBA pada periode diatas, berikut kami lampirkan laporan GENBA serta performance per Plant dan per area diantaranya : </p>
<table class='table-style' border='1' style='border-collapse: collapse;font-size: 12px;margin: auto;width:90%'>
<thead>
<tr>
<td rowspan='2' style='text-align:center'>NO</td>
<td rowspan='2' style='text-align:center'>Area/Proces</td>
<td rowspan='2' style='text-align:center'>Total Score</td>
<td colspan='{$header_length}' style='text-align:center'>Score Category</td>
</tr>
<tr>
$html_header
</tr>
$html_section
</thead>
<tbody>
</tbody>
</table>
<p style='font-size: 12px'>Demikian laporan performance GENBA ini kami sampaikan, mohon kerjasamanya untuk dapat melakukan improvement terkait dengan temuan guna meningkatkan score performance untuk menjadikan kondisi yang lebih baik.</p>
<br>
<br>
<p style='font-size: 12px'>SALAM IMPROVEMENT</p>
";
$dompdf->set_paper('A4', 'portrait');
$dompdf->load_html($html);
$dompdf->set_option('isRemoteEnabled', TRUE);
// $dompdf->setPaper('A4', 'landscape');
$dompdf->render();
$dompdf->stream($filename);
$output = $dompdf->output();
file_put_contents('hcportal_docs/gembareport/'.$filename, $output);
?>

View File

@ -0,0 +1,186 @@
<?php
$objPHPExcel = new \PHPExcel();
// Set document properties
$objPHPExcel->getProperties()->setCreator("Nabati")
->setLastModifiedBy("Nabati")
->setTitle("Office 2007 XLSX TEMPLATE UPLOAD ")
->setSubject("TEMPLATE UPLOAD ")
->setDescription("TEMPLATE UPLOAD ")
->setKeywords("office 2007 openxml php")
->setCategory("TEMPLATE UPLOAD ");
$cel = 1;
$condition = "new, second, scrap";
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'Activities ID')
->setCellValue('B1', 'Business Unit')
->setCellValue('C1', 'Scope ID')
->setCellValue('D1', 'Section ID')
->setCellValue('E1', 'Department ID')
->setCellValue('F1', 'Questionnaire')
->setCellValue('G1', 'YES')
->setCellValue('H1', 'NO')
->setCellValue('I1', 'YES REQUIRED NOTE')
->setCellValue('J1', 'NO REQUIRED NOTE')
->setCellValue('K1', 'ORDER NO')
->setCellValue('L1', 'Category ID')
->setCellValue('M1', 'Risk Level ID')
->setCellValue('N1', 'Link Reverance');
$row=2;
foreach ($list_activities as $key => $value) {
if ($value && isset($value)) {
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A'.($row+$key), $value['id'])
->setCellValue('B'.($row+$key), $value['gmbs_business_unit_id'])
->setCellValue('C'.($row+$key), $value['gmbs_ref_work_scopes_id'])
->setCellValue('D'.($row+$key), $value['gmbs_question_section_id'])
->setCellValue('E'.($row+$key), $value['department_id'])
->setCellValue('F'.($row+$key), $value['description'])
->setCellValue('G'.($row+$key), isset($value['answer_score_yes']) ? $value['answer_score_yes'] : 0)
->setCellValue('H'.($row+$key), isset($value['answer_score_no']) ? $value['answer_score_no'] : 0)
->setCellValue('I'.($row+$key), isset($value['is_require_note_yes']) ? $value['is_require_note_yes'] : 0)
->setCellValue('J'.($row+$key), isset($value['is_require_note_no']) ? $value['is_require_note_no'] : 1)
->setCellValue('K'.($row+$key), $value['order_no'])
->setCellValue('L'.($row+$key), $value['gmbs_question_category_id'])
->setCellValue('M'.($row+$key), $value['gmbs_ref_risk_level_id'])
->setCellValue('N'.($row+$key), $value['reference_link']);
}
}
$objWorkSheet = $objPHPExcel->createSheet(1);
$objPHPExcel->setActiveSheetIndex(1)
->setCellValue('A1', 'ID')
->setCellValue('B1', 'BU NAME')
->setCellValue('C1', 'DESCRIPTION')
->setCellValue('D1', 'PLAN')
->setCellValue('E1', 'GEDUNG')
->setCellValue('F1', 'SECTOR')
->setCellValue('G1', 'LINE');
$objPHPExcel->getActiveSheet()->setTitle('BUSINESS UNIT');
$row=2;
foreach ($list_bu as $key => $value) {
$objPHPExcel->setActiveSheetIndex(1)
->setCellValue('A'.($row+$key), $value['id'])
->setCellValue('B'.($row+$key), $value['bu_name'])
->setCellValue('C'.($row+$key), $value['description'])
->setCellValue('D'.($row+$key), $value['description'])
->setCellValue('E'.($row+$key), $value['gedung_name'])
->setCellValue('F'.($row+$key), $value['sector_name'])
->setCellValue('G'.($row+$key), $value['line_number']);
}
$objWorkSheet = $objPHPExcel->createSheet(2);
$objPHPExcel->setActiveSheetIndex(2)
->setCellValue('A1', 'ID')
->setCellValue('B1', 'SCOPE NAME')
->setCellValue('C1', 'DESCRIPTION');
$objPHPExcel->getActiveSheet()->setTitle('WORK SCOPE');
$row=2;
foreach ($list_scope as $key => $value) {
$objPHPExcel->setActiveSheetIndex(2)
->setCellValue('A'.($row+$key), $value['id'])
->setCellValue('B'.($row+$key), $value['scope_name'])
->setCellValue('C'.($row+$key), $value['description']);
}
$objWorkSheet = $objPHPExcel->createSheet(3);
$objPHPExcel->setActiveSheetIndex(3)
->setCellValue('A1', 'ID')
->setCellValue('B1', 'SECTION NAME')
->setCellValue('C1', 'COMPANY')
->setCellValue('D1', 'SUB AREA')
->setCellValue('E1', 'GEDUNG')
->setCellValue('F1', 'SECTOR')
->setCellValue('G1', 'LINE')
->setCellValue('H1', 'BUSINESS UNIT')
->setCellValue('I1', 'DEPARTMENT');
$objPHPExcel->getActiveSheet()->setTitle('SECTION');
$row=2;
foreach ($list_section as $key => $value) {
$objPHPExcel->setActiveSheetIndex(3)
->setCellValue('A'.($row+$key), $value['id'])
->setCellValue('B'.($row+$key), $value['section_name'])
->setCellValue('C'.($row+$key), $value['company_name'])
->setCellValue('D'.($row+$key), $value['sub_area_name'])
->setCellValue('E'.($row+$key), $value['gedung_name'])
->setCellValue('F'.($row+$key), $value['sector_name'])
->setCellValue('G'.($row+$key), $value['line_name'])
->setCellValue('H'.($row+$key), $value['bu_name'])
->setCellValue('I'.($row+$key), $value['department_name']);
}
$objWorkSheet = $objPHPExcel->createSheet(4);
$objPHPExcel->setActiveSheetIndex(4)
->setCellValue('A1', 'ID')
->setCellValue('B1', 'DIVISION')
->setCellValue('C1', 'DEPARTMENT');
$objPHPExcel->getActiveSheet()->setTitle('DEPARTMENT');
$row=2;
foreach ($list_department as $key => $value) {
$objPHPExcel->setActiveSheetIndex(4)
->setCellValue('A'.($row+$key), $value['department_id'])
->setCellValue('B'.($row+$key), $value['division'])
->setCellValue('C'.($row+$key), $value['department']);
}
$objWorkSheet = $objPHPExcel->createSheet(5);
$objPHPExcel->setActiveSheetIndex(5)
->setCellValue('A1', 'ID')
->setCellValue('B1', 'CATEGORY');
$objPHPExcel->getActiveSheet()->setTitle('SECTION');
$row=2;
foreach ($list_category as $key => $value) {
$objPHPExcel->setActiveSheetIndex(5)
->setCellValue('A'.($row+$key), $value['id'])
->setCellValue('B'.($row+$key), $value['category_name']);
}
$objWorkSheet = $objPHPExcel->createSheet(6);
$objPHPExcel->setActiveSheetIndex(6)
->setCellValue('A1', 'ID')
->setCellValue('B1', 'RISK LEVEL');
$objPHPExcel->getActiveSheet()->setTitle('RISK LEVEL');
$row=2;
foreach ($list_risk as $key => $value) {
$objPHPExcel->setActiveSheetIndex(6)
->setCellValue('A'.($row+$key), $value['id'])
->setCellValue('B'.($row+$key), $value['risk_level_name']);
}
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
$datePeriode = date('Y-m-d');
// Redirect output to a clients web browser (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="template-edit-activities-'. $datePeriode .'.xlsx"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header('Pragma: public'); // HTTP/1.0
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
$objPHPExcel->disconnectWorksheets();
unset($objPHPExcel);
exit;

View File

@ -0,0 +1,157 @@
<?php
$objPHPExcel = new \PHPExcel();
// Set document properties
$objPHPExcel->getProperties()->setCreator("Nabati")
->setLastModifiedBy("Nabati")
->setTitle("Office 2007 XLSX TEMPLATE UPLOAD ")
->setSubject("TEMPLATE UPLOAD ")
->setDescription("TEMPLATE UPLOAD ")
->setKeywords("office 2007 openxml php")
->setCategory("TEMPLATE UPLOAD ");
$cel = 1;
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'RUNNING DATE')
->setCellValue('B1', 'LINE ID')
->setCellValue('C1', 'SHIFT GROUP ID')
->setCellValue('A2', '2024-01-01')
->setCellValue('B2', '1')
->setCellValue('C2', '2');
$objWorkSheet = $objPHPExcel->createSheet(1);
$objPHPExcel->setActiveSheetIndex(1)
->setCellValue('A1', 'ID LINE')
->setCellValue('B1', 'COMPANY')
->setCellValue('C1', 'SUB AREA')
->setCellValue('D1', 'GEDUNG')
->setCellValue('E1', 'SECTOR')
->setCellValue('F1', 'LINE');
$objPHPExcel->getActiveSheet()->setTitle('Gedung Sector Line');
$row=2;
foreach ($list_sector_line as $key => $value) {
$objPHPExcel->setActiveSheetIndex(1)
->setCellValue('A'.($row+$key), $value['gedung_sector_line_id'])
->setCellValue('B'.($row+$key), $value['company'])
->setCellValue('C'.($row+$key), $value['sub_area'])
->setCellValue('D'.($row+$key), $value['gedung_name'])
->setCellValue('E'.($row+$key), $value['sector_name'])
->setCellValue('F'.($row+$key), $value['line_number']);
}
$objWorkSheet = $objPHPExcel->createSheet(2);
$objPHPExcel->setActiveSheetIndex(2)
->setCellValue('A1', 'ID SHIFT GROUP')
->setCellValue('B1', 'COMPANY')
->setCellValue('C1', 'SUB AREA')
->setCellValue('D1', 'SHIFT GROUP');
$objPHPExcel->getActiveSheet()->setTitle('Shift Group');
$row=2;
foreach ($ref_shift_group as $key => $value) {
$objPHPExcel->setActiveSheetIndex(2)
->setCellValue('A'.($row+$key), $value['ref_shift_group_id'])
->setCellValue('B'.($row+$key), $value['company'])
->setCellValue('C'.($row+$key), $value['sub_area'])
->setCellValue('D'.($row+$key), $value['shift_group_name']);
}
// $objWorkSheet = $objPHPExcel->createSheet(3);
// $objPHPExcel->setActiveSheetIndex(3)
// ->setCellValue('A1', 'ID')
// ->setCellValue('B1', 'SECTION NAME')
// ->setCellValue('C1', 'COMPANY')
// ->setCellValue('D1', 'SUB AREA')
// ->setCellValue('E1', 'GEDUNG')
// ->setCellValue('F1', 'SECTOR')
// ->setCellValue('G1', 'LINE')
// ->setCellValue('H1', 'BUSINESS UNIT')
// ->setCellValue('I1', 'DEPARTMENT');
// $objPHPExcel->getActiveSheet()->setTitle('SECTION');
// $row=2;
// foreach ($list_section as $key => $value) {
// $objPHPExcel->setActiveSheetIndex(3)
// ->setCellValue('A'.($row+$key), $value['id'])
// ->setCellValue('B'.($row+$key), $value['section_name'])
// ->setCellValue('C'.($row+$key), $value['company_name'])
// ->setCellValue('D'.($row+$key), $value['sub_area_name'])
// ->setCellValue('E'.($row+$key), $value['gedung_name'])
// ->setCellValue('F'.($row+$key), $value['sector_name'])
// ->setCellValue('G'.($row+$key), $value['line_name'])
// ->setCellValue('H'.($row+$key), $value['bu_name'])
// ->setCellValue('I'.($row+$key), $value['department_name']);
// }
// $objWorkSheet = $objPHPExcel->createSheet(4);
// $objPHPExcel->setActiveSheetIndex(4)
// ->setCellValue('A1', 'ID')
// ->setCellValue('B1', 'DIVISION')
// ->setCellValue('C1', 'DEPARTMENT');
// $objPHPExcel->getActiveSheet()->setTitle('DEPARTMENT');
// $row=2;
// foreach ($list_department as $key => $value) {
// $objPHPExcel->setActiveSheetIndex(4)
// ->setCellValue('A'.($row+$key), $value['department_id'])
// ->setCellValue('B'.($row+$key), $value['division'])
// ->setCellValue('C'.($row+$key), $value['department']);
// }
// $objWorkSheet = $objPHPExcel->createSheet(5);
// $objPHPExcel->setActiveSheetIndex(5)
// ->setCellValue('A1', 'ID')
// ->setCellValue('B1', 'CATEGORY');
// $objPHPExcel->getActiveSheet()->setTitle('SECTION');
// $row=2;
// foreach ($list_category as $key => $value) {
// $objPHPExcel->setActiveSheetIndex(5)
// ->setCellValue('A'.($row+$key), $value['id'])
// ->setCellValue('B'.($row+$key), $value['category_name']);
// }
// $objWorkSheet = $objPHPExcel->createSheet(6);
// $objPHPExcel->setActiveSheetIndex(6)
// ->setCellValue('A1', 'ID')
// ->setCellValue('B1', 'RISK LEVEL');
// $objPHPExcel->getActiveSheet()->setTitle('RISK LEVEL');
// $row=2;
// foreach ($list_risk as $key => $value) {
// $objPHPExcel->setActiveSheetIndex(6)
// ->setCellValue('A'.($row+$key), $value['id'])
// ->setCellValue('B'.($row+$key), $value['risk_level_name']);
// }
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
// Redirect output to a clients web browser (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="template-upload-activities.xlsx"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header('Pragma: public'); // HTTP/1.0
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
$objPHPExcel->disconnectWorksheets();
unset($objPHPExcel);
unset($objWriter);
exit;

View File

@ -0,0 +1,172 @@
<?php
$objPHPExcel = new \PHPExcel();
// Set document properties
$objPHPExcel->getProperties()->setCreator("Nabati")
->setLastModifiedBy("Nabati")
->setTitle("Office 2007 XLSX TEMPLATE UPLOAD ")
->setSubject("TEMPLATE UPLOAD ")
->setDescription("TEMPLATE UPLOAD ")
->setKeywords("office 2007 openxml php")
->setCategory("TEMPLATE UPLOAD ");
$cel = 1;
$condition = "new, second, scrap";
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'Business Unit ID')
->setCellValue('B1', 'Scope ID')
->setCellValue('C1', 'Section ID')
->setCellValue('D1', 'Department ID')
->setCellValue('E1', 'Questionnaire')
->setCellValue('F1', 'YES')
->setCellValue('G1', 'NO')
->setCellValue('H1', 'YES REQUIRED NOTE')
->setCellValue('I1', 'NO REQUIRED NOTE')
->setCellValue('J1', 'ORDER NO')
->setCellValue('K1', 'Category ID')
->setCellValue('L1', 'Risk Level ID')
->setCellValue('M1', 'Link Reverance');
// $objPHPExcel->setActiveSheetIndex(0)
// ->setCellValue('A2', '16000390')
// ->setCellValue('B2', '2022-11-01')
// ->setCellValue('C2', '89')
// ->setCellValue('D2', '2')
// ->setCellValue('E2', 'new')
// ->setCellValue('F2', 'Baru');
$objWorkSheet = $objPHPExcel->createSheet(1);
$objPHPExcel->setActiveSheetIndex(1)
->setCellValue('A1', 'ID')
->setCellValue('B1', 'BU NAME')
->setCellValue('C1', 'DESCRIPTION')
->setCellValue('D1', 'PLAN')
->setCellValue('E1', 'GEDUNG')
->setCellValue('F1', 'SECTOR')
->setCellValue('G1', 'LINE');
$objPHPExcel->getActiveSheet()->setTitle('BUSINESS UNIT');
$row=2;
foreach ($list_bu as $key => $value) {
$objPHPExcel->setActiveSheetIndex(1)
->setCellValue('A'.($row+$key), $value['id'])
->setCellValue('B'.($row+$key), $value['bu_name'])
->setCellValue('C'.($row+$key), $value['description'])
->setCellValue('D'.($row+$key), $value['description'])
->setCellValue('E'.($row+$key), $value['gedung_name'])
->setCellValue('F'.($row+$key), $value['sector_name'])
->setCellValue('G'.($row+$key), $value['line_number']);
}
$objWorkSheet = $objPHPExcel->createSheet(2);
$objPHPExcel->setActiveSheetIndex(2)
->setCellValue('A1', 'ID')
->setCellValue('B1', 'SCOPE NAME')
->setCellValue('C1', 'DESCRIPTION');
$objPHPExcel->getActiveSheet()->setTitle('WORK SCOPE');
$row=2;
foreach ($list_scope as $key => $value) {
$objPHPExcel->setActiveSheetIndex(2)
->setCellValue('A'.($row+$key), $value['id'])
->setCellValue('B'.($row+$key), $value['scope_name'])
->setCellValue('C'.($row+$key), $value['description']);
}
$objWorkSheet = $objPHPExcel->createSheet(3);
$objPHPExcel->setActiveSheetIndex(3)
->setCellValue('A1', 'ID')
->setCellValue('B1', 'SECTION NAME')
->setCellValue('C1', 'COMPANY')
->setCellValue('D1', 'SUB AREA')
->setCellValue('E1', 'GEDUNG')
->setCellValue('F1', 'SECTOR')
->setCellValue('G1', 'LINE')
->setCellValue('H1', 'BUSINESS UNIT')
->setCellValue('I1', 'DEPARTMENT');
$objPHPExcel->getActiveSheet()->setTitle('SECTION');
$row=2;
foreach ($list_section as $key => $value) {
$objPHPExcel->setActiveSheetIndex(3)
->setCellValue('A'.($row+$key), $value['id'])
->setCellValue('B'.($row+$key), $value['section_name'])
->setCellValue('C'.($row+$key), $value['company_name'])
->setCellValue('D'.($row+$key), $value['sub_area_name'])
->setCellValue('E'.($row+$key), $value['gedung_name'])
->setCellValue('F'.($row+$key), $value['sector_name'])
->setCellValue('G'.($row+$key), $value['line_name'])
->setCellValue('H'.($row+$key), $value['bu_name'])
->setCellValue('I'.($row+$key), $value['department_name']);
}
$objWorkSheet = $objPHPExcel->createSheet(4);
$objPHPExcel->setActiveSheetIndex(4)
->setCellValue('A1', 'ID')
->setCellValue('B1', 'DIVISION')
->setCellValue('C1', 'DEPARTMENT');
$objPHPExcel->getActiveSheet()->setTitle('DEPARTMENT');
$row=2;
foreach ($list_department as $key => $value) {
$objPHPExcel->setActiveSheetIndex(4)
->setCellValue('A'.($row+$key), $value['department_id'])
->setCellValue('B'.($row+$key), $value['division'])
->setCellValue('C'.($row+$key), $value['department']);
}
$objWorkSheet = $objPHPExcel->createSheet(5);
$objPHPExcel->setActiveSheetIndex(5)
->setCellValue('A1', 'ID')
->setCellValue('B1', 'CATEGORY');
$objPHPExcel->getActiveSheet()->setTitle('SECTION');
$row=2;
foreach ($list_category as $key => $value) {
$objPHPExcel->setActiveSheetIndex(5)
->setCellValue('A'.($row+$key), $value['id'])
->setCellValue('B'.($row+$key), $value['category_name']);
}
$objWorkSheet = $objPHPExcel->createSheet(6);
$objPHPExcel->setActiveSheetIndex(6)
->setCellValue('A1', 'ID')
->setCellValue('B1', 'RISK LEVEL');
$objPHPExcel->getActiveSheet()->setTitle('RISK LEVEL');
$row=2;
foreach ($list_risk as $key => $value) {
$objPHPExcel->setActiveSheetIndex(6)
->setCellValue('A'.($row+$key), $value['id'])
->setCellValue('B'.($row+$key), $value['risk_level_name']);
}
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
// Redirect output to a clients web browser (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="template-upload-activities.xlsx"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header('Pragma: public'); // HTTP/1.0
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
$objPHPExcel->disconnectWorksheets();
unset($objPHPExcel);
exit;

3
admin/views/ttd-1-pma.php Executable file

File diff suppressed because one or more lines are too long

35
apache-config.conf Normal file
View File

@ -0,0 +1,35 @@
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and por
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header
# match this virtual host. For the default virtual host (this file)
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /
ProxyPass /hcportal http://127.0.0.1:80/app retry=1 acquire=3000 timeout=600 Keepalive=On
<Directory /app>
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

12
custom-logging.conf Normal file
View File

@ -0,0 +1,12 @@
# Disable access log
CustomLog /dev/null common
# Send error log to stderr
ErrorLog /proc/self/fd/2
# Set log level to warn to capture important issues
LogLevel warn
# Redirect PHP errors to stderr
php_flag log_errors on
php_value error_log /proc/self/fd/2

37
docker-compose.yml Normal file
View File

@ -0,0 +1,37 @@
services:
fe:
container_name: frontend
build:
context: .
dockerfile: Dockerfile.frontend
networks:
- hcportalnetwork
volumes:
- ./fe:/app
ports:
- 4200:4200
be:
container_name: backend
build:
context: .
dockerfile: dockerfile.backend
networks:
- hcportalnetwork
volumes:
- ./be:/app
owasp:
container_name: owasp-hcportal
image: owasp/modsecurity-crs:3.3.5-nginx-202401080101
environment:
- backend=http://be:80
networks:
- hcportalnetwork
ports:
- 8888:80
links:
- be
depends_on:
- be
networks:
hcportalnetwork:
driver: bridge

26
entrypoint-backend.sh Normal file
View File

@ -0,0 +1,26 @@
#!/bin/bash
# ANSI color codes
RED='\033[0;31m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to color the log output
color_log() {
while IFS= read -r line; do
if [[ $line == *"PHP Fatal error:"* ]] || [[ $line == *"ERROR:"* ]] || [[ $line == *"Error:"* ]]; then
echo -e "${RED}$line${NC}"
elif [[ $line == *"PHP Warning:"* ]]; then
echo -e "${YELLOW}$line${NC}"
elif [[ $line == *"PHP Notice:"* ]]; then
echo -e "${GREEN}$line${NC}"
else
echo -e "${BLUE}$line${NC}"
fi
done
}
# Start Apache in foreground and pipe through color_log
apache2-foreground 2>&1 | color_log

20
entrypoint-frontend.sh Normal file
View File

@ -0,0 +1,20 @@
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
# Navigate to the app directory
cd /app
# Install dependencies if node_modules doesn't exist
if [ ! -d "node_modules" ]; then
echo "Installing dependencies..."
npm install
fi
# Get the app name from environment variable or use default
APP_NAME=${APP_NAME:-hcportal}
# Serve the application
echo "Starting ${APP_NAME}..."
npx nx serve ${APP_NAME} --host 0.0.0.0 --port 4200

1
fe Submodule

@ -0,0 +1 @@
Subproject commit cbe98dcb438770c2921573f2e21cf6bbf7b002ef

222
mpp.php Normal file
View File

@ -0,0 +1,222 @@
<?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');
}
}
}

6073
mppdb.php Normal file

File diff suppressed because it is too large Load Diff

29
rsyslog.conf Normal file
View File

@ -0,0 +1,29 @@
# Load modules
module(load="imfile")
# Monitor specific error log file
input(type="imfile"
File="/app/src/api/log/Error-*.log"
Tag="api_error_logs"
Severity="error"
Facility="local0")
# Template to include severity
template(name="ErrorFormat" type="string" string="%syslogseverity-text%: %msg%\n")
# Filter out GET and POST logs
:msg, contains, "GET " stop
:msg, contains, "POST " stop
# Send error messages to stderr with severity
if $syslogtag contains 'api_error_logs' then {
action(type="omfile" file="/dev/stderr" template="ErrorFormat")
}
# Optionally, you can add more specific filters here
if $msg contains "PHP Fatal error:" or $msg contains "PHP Warning:" then {
action(type="omfile" file="/dev/stderr" template="ErrorFormat")
}
# Discard other logs
*.* stop