152 lines
5.1 KiB
PHP
152 lines
5.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Models\AuditTrailModel;
|
|
use Response;
|
|
use Yajra\DataTables\DataTables;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Request as Req;
|
|
use App\Models\Audit\TemplateKKAModel;
|
|
use App\Models\Audit\AuditFindingModel;
|
|
use App\Models\Audit\HistoryPemilikModel;
|
|
use DB;
|
|
use Auth;
|
|
use Str;
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
use App\Exports\IcsExport;
|
|
use App\Models\HomeModel;
|
|
|
|
|
|
date_default_timezone_set('Asia/Jakarta');
|
|
|
|
class ManagementContentController extends Controller
|
|
{
|
|
|
|
public function list(Request $request, $type)
|
|
{
|
|
$checkRole = $this->checkRoleAccess($type);
|
|
if ($checkRole == false) {
|
|
return view('errors.404');
|
|
}
|
|
|
|
switch ($type) {
|
|
case 'audit_trail':
|
|
$view = 'content.management_content.audit_trail.index';
|
|
$dataPage['title'] = 'List Audit Trail';
|
|
$dataPage['tableHead'] =
|
|
array(
|
|
["Role User","all","role_name"],
|
|
["Username","all","name"],
|
|
["Event","all","event"],
|
|
["Data","all","auditable_type"],
|
|
["Tanggal","all","created_at"]
|
|
);
|
|
break;
|
|
|
|
case 'home':
|
|
$view = 'content.management_content.home.index';
|
|
$dataPage['title'] = 'Master Home';
|
|
// $dataPage['mst_home'] = \DB::select("SELECT * from mst_home");
|
|
// $dataPage['ref_katalog'] = \DB::select("SELECT * FROM ref_catalog WHERE is_active = 't'");
|
|
|
|
break;
|
|
}
|
|
|
|
if ($type != 'home') {
|
|
foreach($dataPage['tableHead'] as $v){
|
|
$arrHead[] = $v[2];
|
|
}
|
|
$dataPage['head'] = implode(",",$arrHead);
|
|
}
|
|
|
|
|
|
$dataPage['type'] = $type;
|
|
// $dataPage['tahun'] = \DB::select("SELECT distinct on (periode_year) periode_year from master_audit_plan order by periode_year desc");
|
|
$dataPage['ref_user'] = \DB::select("SELECT * from users_admin where status_user = 't' and role = 2 order by id desc");
|
|
|
|
|
|
|
|
$dataPage['table'] = route('management_content.data_table',$type);
|
|
|
|
return $this->bsGetView($view,$dataPage);
|
|
}
|
|
public function data_table(Request $request, $type)
|
|
{
|
|
|
|
$checkRole = $this->checkRoleAccess($type);
|
|
if ($checkRole == false) {
|
|
return view('errors.404');
|
|
}
|
|
|
|
switch ($type) {
|
|
case 'audit_trail':
|
|
$data = \DB::select("SELECT audits.id,rru.description as role_name, bu.username as name,bu.email,audits.event,audits.auditable_type,audits.created_at
|
|
FROM audits
|
|
left join users_admin bu on bu.id = audits.user_id
|
|
left join groups_admin rru on rru.id = bu.role
|
|
order by audits.created_at desc");
|
|
break;
|
|
|
|
}
|
|
|
|
return DataTables::of($data)
|
|
->editColumn('created_at',function($data) use ($type) {
|
|
if($type == 'audit_trail'){
|
|
return date('d-m-Y H:i:s',strtotime($data->created_at));
|
|
}
|
|
|
|
})
|
|
|
|
|
|
->addColumn('action', function ($data) use ($type) {
|
|
$btn = '';
|
|
|
|
return '
|
|
<div class="dropdown dropdown-inline">
|
|
<a href="javascript:;" class="btn btn-sm btn-clean btn-icon mr-2" data-toggle="dropdown">
|
|
<span class="svg-icon svg-icon-md">
|
|
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1">
|
|
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
<rect x="0" y="0" width="24" height="24"/>
|
|
<path d="M5,8.6862915 L5,5 L8.6862915,5 L11.5857864,2.10050506 L14.4852814,5 L19,5 L19,9.51471863 L21.4852814,12 L19,14.4852814 L19,19 L14.4852814,19 L11.5857864,21.8994949 L8.6862915,19 L5,19 L5,15.3137085 L1.6862915,12 L5,8.6862915 Z M12,15 C13.6568542,15 15,13.6568542 15,12 C15,10.3431458 13.6568542,9 12,9 C10.3431458,9 9,10.3431458 9,12 C9,13.6568542 10.3431458,15 12,15 Z" fill="#000000"/>
|
|
</g>
|
|
</svg>
|
|
</span>
|
|
</a>
|
|
<div class="dropdown-menu dropdown-menu-sm dropdown-menu-right">
|
|
<ul class="navi flex-column navi-hover py-2">
|
|
<li class="navi-header font-weight-bolder text-uppercase font-size-xs text-primary pb-2">
|
|
Choose an action:
|
|
</li>
|
|
'.$btn.'
|
|
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
';
|
|
})
|
|
->rawColumns(['group_kka','status', 'action'])
|
|
->make(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
public function act_any(Request $request, $type)
|
|
{
|
|
$checkRole = $this->checkRoleAccess($type);
|
|
if ($checkRole == false) {
|
|
return view('errors.404');
|
|
}
|
|
|
|
switch ($type) {
|
|
// HOME
|
|
|
|
|
|
}
|
|
}
|
|
|
|
}
|