|
|
@ -37,73 +37,6 @@ class Controller extends BaseController |
|
|
|
$this->pathActivityDocument = config('assets.activity'); |
|
|
|
$this->pathActivityDocument = config('assets.activity'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected function setUpPayloadByUser($condition) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$alias = "utp"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$userProyek = UserToProyek::from('assign_hr_to_proyek AS ' . $alias); |
|
|
|
|
|
|
|
$userProyek = $userProyek->where([ |
|
|
|
|
|
|
|
['is_customer', true], |
|
|
|
|
|
|
|
['user_id', $condition['user_id']['user_id']] |
|
|
|
|
|
|
|
])->select('m_proyek.*', 'm_type_proyek.name AS join_second_name'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($condition['joins'])) { |
|
|
|
|
|
|
|
$no = 0; |
|
|
|
|
|
|
|
foreach ($condition['joins'] as $join) { |
|
|
|
|
|
|
|
$tableJoin = isset($join['name1']) ? $join['name1'] : $alias; |
|
|
|
|
|
|
|
$tableName = $join['name']; |
|
|
|
|
|
|
|
$columnJoin = $join['column_join']; // foreign key table sini |
|
|
|
|
|
|
|
$columnSelf = isset($join['column_self']) ? $join['column_self'] : "id"; // primary key table lawan |
|
|
|
|
|
|
|
$columnResult = $join['column_results']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($columnResult as $sColumn) { |
|
|
|
|
|
|
|
$userProyek = $userProyek->addSelect($tableName . "." . $sColumn . " as join_" . $this->listJoinAll[$no] . "_" . $sColumn); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$userProyek = $userProyek->leftJoin($tableName, $tableJoin . "." . $columnJoin, '=', $tableName . '.' . $columnSelf); |
|
|
|
|
|
|
|
$no++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$userProyek->leftJoin('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($condition['columns'])) { |
|
|
|
|
|
|
|
$listWhere = $condition['columns']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$userProyek = $userProyek->where(function ($query) use ($listWhere, $alias) { |
|
|
|
|
|
|
|
foreach ($listWhere as $where) { |
|
|
|
|
|
|
|
$value = $where['value']; |
|
|
|
|
|
|
|
if ($value && $value != "" && $value != " ") { |
|
|
|
|
|
|
|
$column = $where['name']; |
|
|
|
|
|
|
|
$operator = strtolower($where['logic_operator']); // like, =, <>, range |
|
|
|
|
|
|
|
$value2 = isset($where['value1']) ? $where['value1'] : ""; |
|
|
|
|
|
|
|
$tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; |
|
|
|
|
|
|
|
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($condition['group_column'])) { |
|
|
|
|
|
|
|
$userProyek = $this->groupWhere($userProyek, $condition['group_column'], $alias); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data['count'] = clone $userProyek; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($condition['paging'])) { |
|
|
|
|
|
|
|
$userProyek = $userProyek->offset($condition['paging']['start'])->limit($condition['paging']['length']); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($condition['orders'])) { |
|
|
|
|
|
|
|
$orders = $condition['orders']; |
|
|
|
|
|
|
|
$sortBy = $orders['ascending'] ? "ASC" : "DESC"; |
|
|
|
|
|
|
|
$columnOrder = $orders['columns']; |
|
|
|
|
|
|
|
foreach ($columnOrder as $column) { |
|
|
|
|
|
|
|
$userProyek = $userProyek->orderBy($alias . "." . $column, $sortBy); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$data['userProyek'] = $userProyek; |
|
|
|
|
|
|
|
return $data; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function setUpPayload($condition, $tableSelf) |
|
|
|
protected function setUpPayload($condition, $tableSelf) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$alias = "selfTable"; |
|
|
|
$alias = "selfTable"; |
|
|
|