Browse Source

Merge pull request 'Dev-Farhan' (#216) from Dev-Farhan into general

Reviewed-on: ordo/adw-backend#216
pull/3/head
farhantock 1 year ago
parent
commit
258ba21844
  1. 11
      app/Http/Controllers/ActivityController.php
  2. 85
      app/Http/Controllers/CompanyController.php
  3. 235
      app/Http/Controllers/Controller.php
  4. 2
      app/Http/Controllers/DashboardBoDController.php
  5. 5
      app/Http/Controllers/ProjectController.php
  6. 10
      app/Http/Controllers/UserToActivityController.php
  7. 37
      app/Models/Company.php
  8. 36
      app/Models/Divisi.php
  9. 3
      app/Models/HumanResource.php
  10. 2
      app/Models/Menu.php
  11. 2
      app/Models/ProjectPhase.php
  12. 2
      app/Models/ProjectRole.php
  13. 2
      app/Models/ProjectType.php
  14. 2
      app/Models/Role.php
  15. 2
      app/Models/RoleMenu.php
  16. 2
      app/Models/Satuan.php
  17. 4
      routes/web.php

11
app/Http/Controllers/ActivityController.php

@ -527,6 +527,17 @@ class ActivityController extends Controller
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
} }
public function searchAnalysis(Request $request)
{
$dataBuilder = $this->setUpPayload($request->all(), 'm_activity');
$builder = $dataBuilder['builder'];
$dataGet = $builder->select('selfTable.*','m_version_gantt.name_version', 'm_users.name as user_name')
->join('m_version_gantt', 'm_version_gantt.id', '=', 'selfTable.version_gantt_id')
->join('assign_hr_to_activity', 'assign_hr_to_activity.activity_id', '=', 'selfTable.id')
->join('m_users', 'assign_hr_to_activity.user_id', '=', 'm_users.id')
->get();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet ], 200);
}
// before upload file // before upload file
public function importOld(Request $request) public function importOld(Request $request)
{ {

85
app/Http/Controllers/CompanyController.php

@ -0,0 +1,85 @@
<?php
namespace App\Http\Controllers;
use App\Models\Company;
use Illuminate\Http\Request;
class CompanyController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param \App\Company $company
* @return \Illuminate\Http\Response
*/
public function show(Company $company)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Company $company
* @return \Illuminate\Http\Response
*/
public function edit(Company $company)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Company $company
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Company $company)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Company $company
* @return \Illuminate\Http\Response
*/
public function destroy(Company $company)
{
//
}
}

235
app/Http/Controllers/Controller.php

@ -1,6 +1,7 @@
<?php <?php
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Models\UserToActivity; use App\Models\UserToActivity;
@ -16,18 +17,21 @@ class Controller extends BaseController
protected $pathDocument = "assets/file/project/"; protected $pathDocument = "assets/file/project/";
protected $pathTmpImport = "assets/file/tmpimport/"; protected $pathTmpImport = "assets/file/tmpimport/";
protected $pathActivityDocument = "assets/file/activity/"; protected $pathActivityDocument = "assets/file/activity/";
protected $listJoinAll = ['first', 'second', 'third', 'fourth', 'fifth', protected $listJoinAll = [
'sixth', 'seventh', 'eighth', 'ninth', 'tenth']; 'first', 'second', 'third', 'fourth', 'fifth',
'sixth', 'seventh', 'eighth', 'ninth', 'tenth'
];
protected $currentDate; protected $currentDate;
protected $currentName; protected $currentName;
protected $currentId; protected $currentId;
protected $companyId;
public function __construct() public function __construct()
{ {
$this->currentDate = date("Y-m-d H:i:s"); $this->currentDate = date("Y-m-d H:i:s");
$this->currentName = auth()->user() ? auth()->user()->name : "system"; $this->currentName = auth()->user() ? auth()->user()->name : "system";
$this->currentId = auth()->user() ? auth()->user()->id : 0; $this->currentId = auth()->user() ? auth()->user()->id : 0;
$this->companyId = auth()->user() ? auth()->user()->company_id : 0;
$this->pathImage = config('assets.image'); $this->pathImage = config('assets.image');
$this->pathDocument = config('assets.project'); $this->pathDocument = config('assets.project');
$this->pathActivityDocument = config('assets.activity'); $this->pathActivityDocument = config('assets.activity');
@ -36,41 +40,41 @@ class Controller extends BaseController
protected function setUpPayload($condition, $tableSelf) protected function setUpPayload($condition, $tableSelf)
{ {
$alias = "selfTable"; $alias = "selfTable";
$builder = DB::table($tableSelf." AS ".$alias); $builder = DB::table($tableSelf . " AS " . $alias);
// $builder = $builder->select($alias.".*"); // $builder = $builder->select($alias.".*");
if($condition){ if ($condition) {
if(isset($condition['select'])){ if (isset($condition['select'])) {
foreach($condition['select'] as $select){ foreach ($condition['select'] as $select) {
$builder = $builder->addSelect($alias.".".$select); $builder = $builder->addSelect($alias . "." . $select);
} }
}else{ } else {
$builder = $builder->addSelect($alias.".*"); $builder = $builder->addSelect($alias . ".*");
} }
if(isset($condition['joins'])){ if (isset($condition['joins'])) {
$selectColumn = []; $selectColumn = [];
$no = 0; $no = 0;
foreach($condition['joins'] as $join){ foreach ($condition['joins'] as $join) {
$tableJoin = isset($join['name1']) ? $join['name1'] : $alias; $tableJoin = isset($join['name1']) ? $join['name1'] : $alias;
$tableName = $join['name']; $tableName = $join['name'];
$columnJoin = $join['column_join']; // foreign key table sini $columnJoin = $join['column_join']; // foreign key table sini
$columnSelf = isset($join['column_self']) ? $join['column_self'] : "id"; // primary key table lawan $columnSelf = isset($join['column_self']) ? $join['column_self'] : "id"; // primary key table lawan
$columnResult = $join['column_results']; $columnResult = $join['column_results'];
foreach($columnResult as $sColumn){ foreach ($columnResult as $sColumn) {
$builder = $builder->addSelect($tableName.".".$sColumn." as join_".$this->listJoinAll[$no]."_".$sColumn); $builder = $builder->addSelect($tableName . "." . $sColumn . " as join_" . $this->listJoinAll[$no] . "_" . $sColumn);
} }
$builder = $builder->leftJoin($tableName, $tableJoin.".".$columnJoin, '=', $tableName.'.'.$columnSelf); $builder = $builder->leftJoin($tableName, $tableJoin . "." . $columnJoin, '=', $tableName . '.' . $columnSelf);
$no++; $no++;
} }
} }
if(isset($condition['columns'])){ if (isset($condition['columns'])) {
$listWhere = $condition['columns']; $listWhere = $condition['columns'];
$builder = $builder->where(function ($query) use($listWhere, $alias){ $builder = $builder->where(function ($query) use ($listWhere, $alias) {
foreach($listWhere as $where){ foreach ($listWhere as $where) {
$value = $where['value']; $value = $where['value'];
if($value && $value!="" && $value!=" "){ if ($value && $value != "" && $value != " ") {
$column = $where['name']; $column = $where['name'];
$operator = strtolower($where['logic_operator']); // like, =, <>, range $operator = strtolower($where['logic_operator']); // like, =, <>, range
$value2 = isset($where['value1']) ? $where['value1'] : ""; $value2 = isset($where['value1']) ? $where['value1'] : "";
@ -81,22 +85,22 @@ class Controller extends BaseController
}); });
} }
if(isset($condition['group_column'])){ if (isset($condition['group_column'])) {
$builder = $this->groupWhere($builder, $condition['group_column'], $alias); $builder = $this->groupWhere($builder, $condition['group_column'], $alias);
} }
$data['count'] = clone $builder; $data['count'] = clone $builder;
if(isset($condition['paging'])){ if (isset($condition['paging'])) {
$builder = $builder->offset($condition['paging']['start'])->limit($condition['paging']['length']); $builder = $builder->offset($condition['paging']['start'])->limit($condition['paging']['length']);
} }
if(isset($condition['orders'])){ if (isset($condition['orders'])) {
$orders = $condition['orders']; $orders = $condition['orders'];
$sortBy = $orders['ascending'] ? "ASC" : "DESC"; $sortBy = $orders['ascending'] ? "ASC" : "DESC";
$columnOrder = $orders['columns']; $columnOrder = $orders['columns'];
foreach($columnOrder as $column){ foreach ($columnOrder as $column) {
$builder = $builder->orderBy($alias.".".$column, $sortBy); $builder = $builder->orderBy($alias . "." . $column, $sortBy);
} }
} }
} }
@ -111,8 +115,8 @@ class Controller extends BaseController
$operator = $listGroupWhere['operator']; $operator = $listGroupWhere['operator'];
$operatorGroup = $listGroupWhere['group_operator']; $operatorGroup = $listGroupWhere['group_operator'];
$listWhere = $listGroupWhere['where']; $listWhere = $listGroupWhere['where'];
if(strtolower($operator)=="and"){ if (strtolower($operator) == "and") {
$builder = $builder->where(function($query) use($operatorGroup, $listWhere, $alias){ $builder = $builder->where(function ($query) use ($operatorGroup, $listWhere, $alias) {
$no = 1; $no = 1;
foreach ($listWhere as $where) { foreach ($listWhere as $where) {
$value = $where['value']; $value = $where['value'];
@ -120,22 +124,22 @@ class Controller extends BaseController
$operator = strtolower($where['logic_operator']); $operator = strtolower($where['logic_operator']);
$value2 = isset($where['value1']) ? $where['value1'] : ""; $value2 = isset($where['value1']) ? $where['value1'] : "";
$tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; $tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias;
if($value && $value!="" && $value!=" "){ if ($value && $value != "" && $value != " ") {
if($operatorGroup=="and"){ if ($operatorGroup == "and") {
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2);
}else{ } else {
if($no==1){ if ($no == 1) {
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2);
}else{ } else {
$query = $this->orWhereCondition($query, $operator, $tableColumn, $column, $value, $value2); $query = $this->orWhereCondition($query, $operator, $tableColumn, $column, $value, $value2);
} }
} }
} }
$no = $no+1; $no = $no + 1;
} }
}); });
}else if(strtolower($operator)=="or"){ } else if (strtolower($operator) == "or") {
$builder = $builder->orWhere(function($query) use($operatorGroup, $listWhere, $alias){ $builder = $builder->orWhere(function ($query) use ($operatorGroup, $listWhere, $alias) {
$no = 1; $no = 1;
foreach ($listWhere as $where) { foreach ($listWhere as $where) {
$value = $where['value']; $value = $where['value'];
@ -143,13 +147,13 @@ class Controller extends BaseController
$operator = strtolower($where['logic_operator']); $operator = strtolower($where['logic_operator']);
$value2 = isset($where['value1']) ? $where['value1'] : ""; $value2 = isset($where['value1']) ? $where['value1'] : "";
$tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; $tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias;
if($value && $value!="" && $value!=" "){ if ($value && $value != "" && $value != " ") {
if($operatorGroup=="and"){ if ($operatorGroup == "and") {
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2);
}else{ } else {
if($no==1){ if ($no == 1) {
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2);
}else{ } else {
$query = $this->orWhereCondition($query, $operator, $tableColumn, $column, $value, $value2); $query = $this->orWhereCondition($query, $operator, $tableColumn, $column, $value, $value2);
} }
} }
@ -164,39 +168,40 @@ class Controller extends BaseController
private function whereCondition($oldQuery, $operator, $tableColumn, $column, $value, $value2) private function whereCondition($oldQuery, $operator, $tableColumn, $column, $value, $value2)
{ {
$query = $oldQuery; $query = $oldQuery;
if($operator=="range"){ if ($operator == "range") {
$query = $query->whereBetween($tableColumn.".".$column, [$value, $value2]); $query = $query->whereBetween($tableColumn . "." . $column, [$value, $value2]);
}else if($operator=="like"){ } else if ($operator == "like") {
$query = $query->where($tableColumn.".".$column, 'like', '%'.$value.'%'); $query = $query->where($tableColumn . "." . $column, 'like', '%' . $value . '%');
}else if($operator=="ilike"){ } else if ($operator == "ilike") {
$query = $query->where($tableColumn.".".$column, '~*', $value); $query = $query->where($tableColumn . "." . $column, '~*', $value);
}else if($operator=="="){ } else if ($operator == "=") {
$query = $query->where($tableColumn.".".$column, $value); $query = $query->where($tableColumn . "." . $column, $value);
}else if($operator=="in"){ } else if ($operator == "in") {
$query = $query->whereIn($tableColumn.".".$column, $value); $query = $query->whereIn($tableColumn . "." . $column, $value);
}else if($operator=="notin"){ } else if ($operator == "notin") {
$query = $query->whereNotIn($tableColumn.".".$column, $value); $query = $query->whereNotIn($tableColumn . "." . $column, $value);
}else{ } else {
$query = $query->where($tableColumn.".".$column, $operator, $value); $query = $query->where($tableColumn . "." . $column, $operator, $value);
} }
return $query; return $query;
} }
private function whereConditionSingleTable($oldQuery, $operator, $column, $value, $value2){ private function whereConditionSingleTable($oldQuery, $operator, $column, $value, $value2)
{
$query = $oldQuery; $query = $oldQuery;
if($operator=="range"){ if ($operator == "range") {
$query = $query->whereBetween($column, [$value, $value2]); $query = $query->whereBetween($column, [$value, $value2]);
}else if($operator=="like"){ } else if ($operator == "like") {
$query = $query->where($column, 'like', '%'.$value.'%'); $query = $query->where($column, 'like', '%' . $value . '%');
}else if($operator=="ilike"){ } else if ($operator == "ilike") {
$query = $query->where($column, '~*', $value); $query = $query->where($column, '~*', $value);
}else if($operator=="="){ } else if ($operator == "=") {
$query = $query->where($column, $value); $query = $query->where($column, $value);
}else if($operator=="in"){ } else if ($operator == "in") {
$query = $query->whereIn($column, $value); $query = $query->whereIn($column, $value);
}else if($operator=="notin"){ } else if ($operator == "notin") {
$query = $query->whereNotIn($column, $value); $query = $query->whereNotIn($column, $value);
}else{ } else {
$query = $query->where($column, $operator, $value); $query = $query->where($column, $operator, $value);
} }
return $query; return $query;
@ -205,25 +210,26 @@ class Controller extends BaseController
private function orWhereCondition($oldQuery, $operator, $tableColumn, $column, $value, $value2) private function orWhereCondition($oldQuery, $operator, $tableColumn, $column, $value, $value2)
{ {
$query = $oldQuery; $query = $oldQuery;
if($operator=="range"){ if ($operator == "range") {
$query = $query->orWhereBetween($tableColumn.".".$column, [$value, $value2]); $query = $query->orWhereBetween($tableColumn . "." . $column, [$value, $value2]);
}else if($operator=="like"){ } else if ($operator == "like") {
$query = $query->orWhere($tableColumn.".".$column, 'like', '%'.$value.'%'); $query = $query->orWhere($tableColumn . "." . $column, 'like', '%' . $value . '%');
}else if($operator=="ilike"){ } else if ($operator == "ilike") {
$query = $query->where($tableColumn.".".$column, '~*', $value); $query = $query->where($tableColumn . "." . $column, '~*', $value);
}else if($operator=="="){ } else if ($operator == "=") {
$query = $query->orWhere($tableColumn.".".$column, $value); $query = $query->orWhere($tableColumn . "." . $column, $value);
}else if($operator=="in"){ } else if ($operator == "in") {
$query = $query->orWhereIn($tableColumn.".".$column, $value); $query = $query->orWhereIn($tableColumn . "." . $column, $value);
}else if($operator=="notin"){ } else if ($operator == "notin") {
$query = $query->orWhereNotIn($tableColumn.".".$column, $value); $query = $query->orWhereNotIn($tableColumn . "." . $column, $value);
}else{ } else {
$query = $query->orWhere($tableColumn.".".$column, $operator, $value); $query = $query->orWhere($tableColumn . "." . $column, $operator, $value);
} }
return $query; return $query;
} }
protected function calculateAllCost($activity_id, $proyek_id){ protected function calculateAllCost($activity_id, $proyek_id)
{
$humanCostPlanning = $this->calculateAllHumanCost($activity_id, $proyek_id); $humanCostPlanning = $this->calculateAllHumanCost($activity_id, $proyek_id);
$materialCostPlanning = $this->calculateMaterialCost($activity_id, $proyek_id); $materialCostPlanning = $this->calculateMaterialCost($activity_id, $proyek_id);
$toolsCostPlanning = 0; $toolsCostPlanning = 0;
@ -234,11 +240,11 @@ class Controller extends BaseController
private function calculateAllHumanCost($activity_id, $proyek_id) private function calculateAllHumanCost($activity_id, $proyek_id)
{ {
$dataHuman = UserToActivity::select("ahp.standart_rate as standart_rate","ahp.max_used as max_used", "ahp.cost_per_used as cost_per_used", "ahp.uom_standart_rate as uom_standart_rate") $dataHuman = UserToActivity::select("ahp.standart_rate as standart_rate", "ahp.max_used as max_used", "ahp.cost_per_used as cost_per_used", "ahp.uom_standart_rate as uom_standart_rate")
->leftJoin("assign_hr_to_proyek as ahp", "assign_hr_to_activity.user_id", "=", "ahp.user_id") ->leftJoin("assign_hr_to_proyek as ahp", "assign_hr_to_activity.user_id", "=", "ahp.user_id")
->where("assign_hr_to_activity.activity_id", $activity_id)->where("assign_hr_to_activity.proyek_id", $proyek_id) ->where("assign_hr_to_activity.activity_id", $activity_id)->where("assign_hr_to_activity.proyek_id", $proyek_id)
->where("ahp.proyek_id", $proyek_id) ->where("ahp.proyek_id", $proyek_id)
->get(); ->get();
$totalCost = 0; $totalCost = 0;
foreach ($dataHuman as $human) { foreach ($dataHuman as $human) {
@ -253,58 +259,61 @@ class Controller extends BaseController
$activity = Activity::find($activity_id); $activity = Activity::find($activity_id);
$duration = $activity->duration; $duration = $activity->duration;
$standarRate = $human->standart_rate; $standarRate = $human->standart_rate;
$maxUsed = $human->max_used/100; $maxUsed = $human->max_used / 100;
if ($human->uom_standart_rate == "Hour") { if ($human->uom_standart_rate == "Hour") {
$totalCost = ($standarRate*8*$duration)*$maxUsed; $totalCost = ($standarRate * 8 * $duration) * $maxUsed;
return $totalCost; return $totalCost;
} }
$totalCost = ($standarRate*$duration)*$maxUsed; $totalCost = ($standarRate * $duration) * $maxUsed;
return $totalCost; return $totalCost;
} }
private function calculateMaterialCost($activity_id, $proyek_id) private function calculateMaterialCost($activity_id, $proyek_id)
{ {
$totalCost = AssignMaterial::selectRaw("COALESCE(qty_planning,0)*COALESCE(budget,0) as totalCost") $totalCost = AssignMaterial::selectRaw("COALESCE(qty_planning,0)*COALESCE(budget,0) as totalCost")
->where("proyek_id", $proyek_id) ->where("proyek_id", $proyek_id)
->where("activity_id", $activity_id) ->where("activity_id", $activity_id)
->sum(AssignMaterial::raw("COALESCE(qty_planning, 0) * COALESCE(budget, 0)")); ->sum(AssignMaterial::raw("COALESCE(qty_planning, 0) * COALESCE(budget, 0)"));
return $totalCost; return $totalCost;
} }
protected function getLoc($lat, $lng){ protected function getLoc($lat, $lng)
{
// $response = Http::get(config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json"); // $response = Http::get(config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json");
// return $response->json; // return $response->json;
$url = config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json"; $url = config('api.nominatim') . "/reverse?lat=" . $lat . "&lon=" . $lng . "&format=json";
// $token = config('api.adw_token'); // $token = config('api.adw_token');
$response = $this->curlRequest($url); $response = $this->curlRequest($url);
return $response; return $response;
} }
private function curlRequest($url){ private function curlRequest($url)
$ch = curl_init(); {
// $headers = [ $ch = curl_init();
// 'Authorization: '.$token // $headers = [
// ]; // 'Authorization: '.$token
curl_setopt($ch, CURLOPT_URL, $url); // ];
// curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch); $response = curl_exec($ch);
if ($response === false) if ($response === false)
$response = curl_error($ch); $response = curl_error($ch);
curl_close($ch); curl_close($ch);
return json_decode($response); return json_decode($response);
} }
protected function addDetailK3($dataDetail, $report_id){ protected function addDetailK3($dataDetail, $report_id)
{
foreach ($dataDetail as $value) { foreach ($dataDetail as $value) {
$dataNew = array( $dataNew = array(
"report_k3_id"=>$report_id, "report_k3_id" => $report_id,
"checklist_k3_id"=>$value['checklist_id'], "checklist_k3_id" => $value['checklist_id'],
"name_checklist_k3"=>$value['checklist_name'], "name_checklist_k3" => $value['checklist_name'],
"created_by"=>$this->currentName "created_by" => $this->currentName
); );
ReportK3Detail::create($dataNew); ReportK3Detail::create($dataNew);

2
app/Http/Controllers/DashboardBoDController.php

@ -304,7 +304,7 @@ class DashboardBoDController extends Controller
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name') $divisions = Divisi::select('id', 'name', 'color')
->with('children') ->with('children')
->whereNull('parent') ->whereNull('parent')
->get(); ->get();

5
app/Http/Controllers/ProjectController.php

@ -229,6 +229,7 @@ class ProjectController extends Controller
$dataBuilder = $this->setUpPayload($payload, 'm_proyek'); $dataBuilder = $this->setUpPayload($payload, 'm_proyek');
$builder = $dataBuilder['builder']; $builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count']; $countBuilder = $dataBuilder['count'];
// $builder->where("selfTable.created_by",$this->currentName);
$dataGet = $builder->get(); $dataGet = $builder->get();
$totalRecord = $countBuilder->count(); $totalRecord = $countBuilder->count();
@ -274,7 +275,9 @@ class ProjectController extends Controller
'created_by', 'created_by',
'updated_at', 'updated_at',
'updated_by' 'updated_by'
)->orderBy('id', 'desc')->get(); )->orderBy('id', 'desc')
// ->where("created_by",$this->currentName)
->get();
$countData = $data->count(); $countData = $data->count();
if(!$data) if(!$data)

10
app/Http/Controllers/UserToActivityController.php

@ -129,6 +129,16 @@ class UserToActivityController extends Controller
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
} }
public function searchAnalysis(Request $request)
{
$dataBuilder = $this->setUpPayload($request->all(), 'assign_hr_to_activity');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
}
public function search(Request $request) public function search(Request $request)
{ {
$payload = $request->all(); $payload = $request->all();

37
app/Models/Company.php

@ -0,0 +1,37 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Company extends Model
{
protected $table = 'm_divisi';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
"registration_no",
"company_name",
"address",
"phone_no",
"email",
"description",
"logo_login",
"logo_header",
"favicon_image",
"login_instruction",
"about",
"html_title",
"app_name",
"base_url",
"is_active",
"template_id",
'created_at',
'created_by',
'updated_at',
'updated_by',
'company_id'
];
}

36
app/Models/Divisi.php

@ -6,37 +6,39 @@ use Illuminate\Database\Eloquent\Model;
class Divisi extends Model class Divisi extends Model
{ {
protected $table = 'm_divisi'; protected $table = 'm_divisi';
const CREATED_AT = 'created_at'; const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'name',
'parent', 'parent',
'description', 'description',
'color', 'color',
'created_at', 'created_at',
'created_by', 'created_by',
'updated_at', 'updated_at',
'updated_by' 'updated_by',
]; 'company_id'
];
public static function boot() {
public static function boot()
{
parent::boot(); parent::boot();
static::deleting(function($data) { static::deleting(function ($data) {
$data->children()->delete(); $data->children()->delete();
}); });
} }
public function parent() public function parent()
{ {
return $this->belongsTo('App\Models\Divisi','parent')->where('parent', null)->with('parent'); return $this->belongsTo('App\Models\Divisi', 'parent')->where('parent', null)->with('parent');
} }
public function children() public function children()
{ {
return $this->hasMany('App\Models\Divisi','parent')->with('children'); return $this->hasMany('App\Models\Divisi', 'parent')->with('children');
} }
} }

3
app/Models/HumanResource.php

@ -33,6 +33,7 @@ class HumanResource extends Model
'updated_at', 'updated_at',
'updated_by', 'updated_by',
'divisi_id', 'divisi_id',
'status_boundary' 'status_boundary',
'company_id'
]; ];
} }

2
app/Models/Menu.php

@ -13,6 +13,6 @@ class Menu extends Model
protected $fillable = [ protected $fillable = [
'parent_id', 'icon', 'name', 'alias_name', 'url', 'sequence', 'parent_id', 'icon', 'name', 'alias_name', 'url', 'sequence',
'created_at', 'created_by', 'updated_at', 'updated_by' 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
]; ];
} }

2
app/Models/ProjectPhase.php

@ -12,6 +12,6 @@ class ProjectPhase extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'color', 'order', 'created_at', 'created_by', 'updated_at', 'updated_by' 'name', 'color', 'order', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
]; ];
} }

2
app/Models/ProjectRole.php

@ -12,6 +12,6 @@ class ProjectRole extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
]; ];
} }

2
app/Models/ProjectType.php

@ -12,6 +12,6 @@ class ProjectType extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
]; ];
} }

2
app/Models/Role.php

@ -12,6 +12,6 @@ class Role extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'description', 'default_page', 'created_at', 'created_by', 'updated_at', 'updated_by' 'name', 'description', 'default_page', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
]; ];
} }

2
app/Models/RoleMenu.php

@ -12,6 +12,6 @@ class RoleMenu extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'role_id', 'menu_id', 'created_at', 'created_by', 'updated_at', 'updated_by' 'role_id', 'menu_id', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id', "create", "read", "update", "delete"
]; ];
} }

2
app/Models/Satuan.php

@ -12,6 +12,6 @@ class Satuan extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
]; ];
} }

4
routes/web.php

@ -197,6 +197,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->get('/user-to-activity/edit/{id}', 'UserToActivityController@edit'); $router->get('/user-to-activity/edit/{id}', 'UserToActivityController@edit');
$router->put('/user-to-activity/update/{id}', 'UserToActivityController@update'); $router->put('/user-to-activity/update/{id}', 'UserToActivityController@update');
$router->post('/user-to-activity/search', 'UserToActivityController@search'); $router->post('/user-to-activity/search', 'UserToActivityController@search');
$router->post('/user-to-activity/search-analysis', 'UserToActivityController@searchAnalysis');
$router->post('/user-to-activity/list-filtered', 'UserToActivityController@listFiltered'); $router->post('/user-to-activity/list-filtered', 'UserToActivityController@listFiltered');
$router->delete('/user-to-activity/delete/{id}', 'UserToActivityController@delete'); $router->delete('/user-to-activity/delete/{id}', 'UserToActivityController@delete');
$router->get('/user-to-activity/list', 'UserToActivityController@list'); $router->get('/user-to-activity/list', 'UserToActivityController@list');
@ -204,7 +205,8 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->get('/sumVolActualM/{id}', 'ActivityController@sumVolumeActualMaterial'); $router->get('/sumVolActualM/{id}', 'ActivityController@sumVolumeActualMaterial');
$router->get('/activity/{id}/{proyek_id}/get', 'ActivityController@getByGanttId'); $router->get('/activity/{id}/{proyek_id}/get', 'ActivityController@getByGanttId');
$router->get('/activity/search', 'ActivityController@search'); $router->post('/activity/search', 'ActivityController@search');
$router->post('/activity/search-analysis', 'ActivityController@searchAnalysis');
$router->post('/activity/import', 'ActivityController@import'); $router->post('/activity/import', 'ActivityController@import');
$router->post('/activity/import-update', 'ActivityController@importUpdate'); $router->post('/activity/import-update', 'ActivityController@importUpdate');
$router->post('/activity/import-old', 'ActivityController@importOld'); $router->post('/activity/import-old', 'ActivityController@importOld');

Loading…
Cancel
Save