Browse Source

Merge branch 'staging' of https://git.oslog.id/ordo/adw-backend into dev-ibnu

pull/3/head
ibnu 1 year ago
parent
commit
c6af2102d1
  1. 4
      app/Helpers/MasterFunctionsHelper.php
  2. 13
      app/Http/Controllers/BroadcastController.php
  3. 27
      app/Http/Controllers/ProjectController.php
  4. 36
      app/Jobs/ProcessSCurve.php
  5. 36
      database/migrations/2023_08_29_130624_create_jobs_table.php
  6. 1
      routes/web.php

4
app/Helpers/MasterFunctionsHelper.php

@ -428,7 +428,7 @@ class MasterFunctionsHelper
} }
$lastReal = $tempPercentageReal[count($tempPercentageReal) - 1]; $lastReal = $tempPercentageReal[count($tempPercentageReal) - 1];
$totalBCWP = $lastReal * $totalBCWP; $totalBCWP = $lastReal * $dataProject->rencana_biaya / 100;
$dataResponse = array( $dataResponse = array(
"date" => $tempDate, "date" => $tempDate,
"percentage" => $tempPercentage, "percentage" => $tempPercentage,
@ -723,7 +723,7 @@ class MasterFunctionsHelper
} }
$lastReal = $tempPercentageReal[count($tempPercentageReal) - 1]; $lastReal = $tempPercentageReal[count($tempPercentageReal) - 1];
$totalBCWP = $lastReal * $totalBCWP; $totalBCWP = $lastReal * $dataProject->rencana_biaya / 100;
$dataResponse = array( $dataResponse = array(
"date" => $tempDate, "date" => $tempDate,
"percentage" => $tempPercentage, "percentage" => $tempPercentage,

13
app/Http/Controllers/BroadcastController.php

@ -15,6 +15,12 @@ class BroadcastController extends Controller
$data = $request->all(); $data = $request->all();
$data['status_send'] = true; $data['status_send'] = true;
$data['created_by'] = $this->currentName; $data['created_by'] = $this->currentName;
if (isset($data['send_to_id'])) {
$idArray = $data['send_to_id'];
if (is_array($data['send_to_id'])) {
$data['send_to_id'] = implode(", ", $idArray);
}
}
// dd($data); // dd($data);
$result = Broadcast::create($data); $result = Broadcast::create($data);
if($result){ if($result){
@ -140,8 +146,10 @@ class BroadcastController extends Controller
} }
break; break;
case 'user': case 'users':
$user = User::where("id", $data['send_to_id'])->whereNotNull('fcm_token')->first(); $idArray = explode(", ", $data['send_to_id']);
foreach ($idArray as $key => $value) {
$user = User::where("id", $value)->whereNotNull('fcm_token')->first();
if (isset($user)) { if (isset($user)) {
FCMService::send( FCMService::send(
$user->fcm_token, $user->fcm_token,
@ -151,6 +159,7 @@ class BroadcastController extends Controller
] ]
); );
} }
}
break; break;
default: default:

27
app/Http/Controllers/ProjectController.php

@ -30,6 +30,7 @@ use Illuminate\Support\Facades\DB;
use App\Helpers\MasterFunctionsHelper; use App\Helpers\MasterFunctionsHelper;
use App\Models\ReportActivityMaterial; use App\Models\ReportActivityMaterial;
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use App\Jobs\ProcessSCurve;
const API_GEOLOCATION = "https://nominatim.oslogdev.com/search/ADDR?format=json&addressdetails=1&limit=1"; const API_GEOLOCATION = "https://nominatim.oslogdev.com/search/ADDR?format=json&addressdetails=1&limit=1";
@ -331,6 +332,15 @@ class ProjectController extends Controller
Artisan::call('calculate:scurve', [ Artisan::call('calculate:scurve', [
'project_id' => $request->project_id 'project_id' => $request->project_id
]); ]);
// $project = Project::find($request->project_id);
// if ($project) {
// dispatch(new ProcessSCurve($project));
// return response()->json(['message' => 'S Curve calculation queued']);
// }
// return response()->json(['message' => 'Project not found'], 404);
} }
public function getLinearSCurve(Request $request){ public function getLinearSCurve(Request $request){
@ -432,7 +442,24 @@ class ProjectController extends Controller
// return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200); // return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200);
return response()->json(['status'=>'success', 'data'=> '', 'code'=>200], 200); return response()->json(['status'=>'success', 'data'=> '', 'code'=>200], 200);
} }
public function getByUser($id)
{
$alias = "utp";
$userProyek = UserToProyek::query()
->from('assign_hr_to_proyek AS ' . $alias)
->where([
['is_customer', true],
['user_id', $id]
])
->leftJoin('m_users', $alias.'.user_id', '=', 'm_users.id')
->leftJoin('m_proyek', $alias.'.proyek_id', '=', 'm_proyek.id')
->leftJoin('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id')
->select('m_proyek.*', 'm_type_proyek.name AS join_second_name','m_users.name AS join_first_name')
->get();
$totalRecord = $userProyek->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200);
}
public function detail($id){ public function detail($id){
if(empty($id) || !is_int((int)$id)) if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);

36
app/Jobs/ProcessSCurve.php

@ -0,0 +1,36 @@
<?php
namespace App\Jobs;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Queue;
use App\Helpers\MasterFunctionsHelper;
use App\Models\Project;
class ProcessSCurve extends Job
{
protected $project;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(Project $project)
{
$this->project = $project;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$data = MasterFunctionsHelper::CalculateSCurve($this->project->id);
$this->project->scurve = json_encode($data);
$this->project->calculation_status = true;
$this->project->save();
}
}

36
database/migrations/2023_08_29_130624_create_jobs_table.php

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('jobs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('jobs');
}
}

1
routes/web.php

@ -53,6 +53,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->post('/document-activity/search', 'ActivityDokumenController@searchDocProject'); $router->post('/document-activity/search', 'ActivityDokumenController@searchDocProject');
$router->get('/document-activity/download/{id}', 'ActivityDokumenController@downloadDokumen'); $router->get('/document-activity/download/{id}', 'ActivityDokumenController@downloadDokumen');
$router->get('/project-by-customer/{id}','ProjectController@getByUser');
$router->post('/project/search', 'ProjectController@search'); $router->post('/project/search', 'ProjectController@search');
$router->post('/project/add', 'ProjectController@add'); $router->post('/project/add', 'ProjectController@add');
$router->put('/project/update/{id}', 'ProjectController@update'); $router->put('/project/update/{id}', 'ProjectController@update');

Loading…
Cancel
Save