Browse Source

Merge pull request 'dev-wahyun' (#68) from dev-wahyun into staging

Reviewed-on: ibnu/generic-ospro-backend#68
pull/1/head
farhantock 6 months ago
parent
commit
7ff7bdc969
  1. 40
      app/Http/Controllers/Controller.php
  2. 14
      app/Http/Controllers/ProjectController.php
  3. 1
      app/Models/HumanResource.php
  4. 2
      app/Models/User.php
  5. 1
      routes/web.php

40
app/Http/Controllers/Controller.php

@ -10,6 +10,7 @@ use App\Models\Company;
use App\Models\ReportK3Detail;
use App\Models\UserToActivity;
use App\Models\ProductTransaction;
use App\Models\Project;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
use Illuminate\Support\Facades\Http;
@ -45,13 +46,10 @@ class Controller extends BaseController
protected function setCustomeDirectoryUpload($company_name)
{
$current_date = date('Y-m-d');
[$year, $month, $day] = explode('-', $current_date);
$pathImage = 'assets/' . $company_name . ' ' . $year . '-' . $month . '-' . $day . '/image/';
$pathDocument = 'assets/' . $company_name . ' ' . $year . '-' . $month . '-' . $day . '/file/project/';
$pathTmpImport = 'assets/' . $company_name . ' ' . $year . '-' . $month . '-' . $day . '/file/tmpimport/';
$pathActivityDocument = 'assets/' . $company_name . ' ' . $year . '-' . $month . '-' . $day . '/file/activity/';
$pathImage = 'assets/' . $company_name . '/image/';
$pathDocument = 'assets/' . $company_name . '/file/project/';
$pathTmpImport = 'assets/' . $company_name . '/file/tmpimport/';
$pathActivityDocument = 'assets/' . $company_name . '/file/activity/';
return [
'pathImage' => $pathImage,
@ -64,14 +62,10 @@ class Controller extends BaseController
public function storage($company_name)
{
$directory = 'assets/' . urldecode($company_name);
if (!is_dir($directory)) {
return "Directory not found";
}
$size = 0;
try {
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) {
$size += $file->getSize();
@ -79,10 +73,32 @@ class Controller extends BaseController
} catch (Exception $e) {
return "Error while calculating size: " . $e->getMessage();
}
return round($size / 1048576, 2);
}
public function storageAllCompany()
{
$companies = Company::get();
$formData = [];
foreach($companies as $data) {
$size = 0;
$directory = 'assets/' . urldecode($data['company_name']);
if (is_dir($directory)) {
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) {
$size += $file->getSize();
}
}
$formData[] = [
'company_name' => $data['company_name'],
'size' => round($size / 1048576, 2),
'exp_ospro' => ProductTransaction::query()->where('company_id', $data['id'])->value('exp_ospro'),
'project_total' => Project::query()->where('company_id',$data['id'])->count()
];
}
return $formData;
}
public function setExpiredTimeOspro($company_id)
{
$currentDate = Carbon::now();

14
app/Http/Controllers/ProjectController.php

@ -84,17 +84,8 @@ class ProjectController extends Controller
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
}
// $result = Project::query()
// ->from('m_proyek AS mp')
// ->where('mp.id', $id)
// ->selectRaw('value_proyek,scoupe_of_work,kode_sortname,jumlah_stakeholder,nama,mulai_proyek,akhir_proyek,
// area_kerja,rencana_biaya,biaya_actual,company,pm_id,type_proyek_id,divisi_id,persentase_progress,keterangan,durasi_proyek,progress_by_worklog,currency_symbol,late_consequence,assumtion,currency_code,currency_name,project_objectives,considered_success_when,potential_risk,testing_environment,budget_health,phase_id,calculation_status');
// if (!is_null($result->first()['divisi_id'])) {
// $result->leftJoin('m_divisi', 'mp.divisi_id', '=', 'm_divisi.id')
// ->addSelect(DB::raw('m_divisi.name AS nama_divisi'));
// }
$result = Project::select(
$result = Project::
select(
'value_proyek',
'scoupe_of_work',
'kode_sortname',
@ -126,6 +117,7 @@ class ProjectController extends Controller
'phase_id',
'calculation_status',
'md.name as divisi_name',
'm_proyek.company_id'
)
->join('m_divisi as md', 'md.id', '=', 'm_proyek.divisi_id')
->where('m_proyek.id', $id)

1
app/Models/HumanResource.php

@ -36,5 +36,6 @@ class HumanResource extends Model
'updated_by',
'divisi_id',
'status_boundary',
'is_customer'
];
}

2
app/Models/User.php

@ -24,7 +24,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
protected $fillable = [
'name', 'email', 'role_id', 'username', 'session_login', 'phone_number', 'email', 'address',
'fcm_token', 'gender', 'birth_place', 'birth_date', 'blood_type', 'ktp_number', 'working_hours',
'created_at', 'created_by', 'updated_at', 'updated_by', 'status_resource', 'discount_id','company_id'
'created_at', 'created_by', 'updated_at', 'updated_by', 'status_resource', 'discount_id','company_id','is_customer'
];
const CREATED_AT = 'created_at';

1
routes/web.php

@ -591,6 +591,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->get('/demo-management/list', 'DemoController@list');
$router->get('/information-storage/{company_name}', 'Controller@storage');
$router->get('/information-storage-all-company','Controller@storageAllCompany');
$router->post('/refferal-code/search', 'RefferalCodeController@search');
$router->post('/refferal-code/add', 'RefferalCodeController@add');

Loading…
Cancel
Save