|
|
@ -38,8 +38,10 @@ use App\Models\ProjectParticipants; |
|
|
|
use App\Models\FolderDocumentProyek; |
|
|
|
use App\Models\FolderDocumentProyek; |
|
|
|
use App\Models\ProjectToChecklistK3; |
|
|
|
use App\Models\ProjectToChecklistK3; |
|
|
|
use App\Helpers\MasterFunctionsHelper; |
|
|
|
use App\Helpers\MasterFunctionsHelper; |
|
|
|
|
|
|
|
use App\Models\ProductTransaction; |
|
|
|
use App\Models\ReportActivityMaterial; |
|
|
|
use App\Models\ReportActivityMaterial; |
|
|
|
use Illuminate\Support\Facades\Artisan; |
|
|
|
use Illuminate\Support\Facades\Artisan; |
|
|
|
|
|
|
|
use Illuminate\Database\Query\Builder; |
|
|
|
|
|
|
|
|
|
|
|
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"; |
|
|
|
|
|
|
|
|
|
|
@ -63,10 +65,36 @@ class ProjectController extends Controller |
|
|
|
$data['created_by'] = $this->currentName; |
|
|
|
$data['created_by'] = $this->currentName; |
|
|
|
$data['created_by_id'] = $this->currentId; |
|
|
|
$data['created_by_id'] = $this->currentId; |
|
|
|
|
|
|
|
|
|
|
|
if (empty($data['phase_id'])) |
|
|
|
if (empty($data['phase_id'])) { |
|
|
|
$data['phase_id'] = 1; |
|
|
|
$data['phase_id'] = 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$transaction = ProductTransaction::query() |
|
|
|
|
|
|
|
->where('company_id', $request->company_id); |
|
|
|
|
|
|
|
$cloneQueryTransaction = clone $transaction; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$countCreate = false; |
|
|
|
|
|
|
|
$projectResult = Project::query() |
|
|
|
|
|
|
|
->selectRaw('count(*) as total_project') |
|
|
|
|
|
|
|
->where('company_id', $request->company_id) |
|
|
|
|
|
|
|
->first(); |
|
|
|
|
|
|
|
if($transaction->where([['type_paket','Basic'],['amount','!=',null]])->exists()) { |
|
|
|
|
|
|
|
if($projectResult['total_project'] < 10) { |
|
|
|
|
|
|
|
$countCreate = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} elseif ($cloneQueryTransaction->where([['type_paket','Free'],['amount',0]])->exists()) { |
|
|
|
|
|
|
|
if($projectResult['total_project'] < 1) { |
|
|
|
|
|
|
|
$countCreate = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$countCreate = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($countCreate) { |
|
|
|
$result = Project::create($data); |
|
|
|
$result = Project::create($data); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Limited to create project!', 'code' => 500], 500); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!$result) |
|
|
|
if (!$result) |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Failed to add data!', 'code' => 500], 500); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Failed to add data!', 'code' => 500], 500); |
|
|
@ -531,6 +559,21 @@ class ProjectController extends Controller |
|
|
|
return response()->json(['status' => 'success', 'message' => 'Set baseline success!', 'code' => 200], 200); |
|
|
|
return response()->json(['status' => 'success', 'message' => 'Set baseline success!', 'code' => 200], 200); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function setBaselineActivity($activity_id, $gantt_id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$activity = Activity::where([ |
|
|
|
|
|
|
|
["version_gantt_id", $gantt_id], |
|
|
|
|
|
|
|
['id',$activity_id] |
|
|
|
|
|
|
|
])->first(); |
|
|
|
|
|
|
|
$activity->update([ |
|
|
|
|
|
|
|
"planned_start" => $activity->start_date, |
|
|
|
|
|
|
|
"planned_end" => $activity->end_date, |
|
|
|
|
|
|
|
"early_start" => $activity->start_date, |
|
|
|
|
|
|
|
"early_end" => $activity->end_date, |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'Set baseline activity success!', 'code' => 200], 200); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getInvoiceIntegration(Request $request) |
|
|
|
public function getInvoiceIntegration(Request $request) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$ganttCount = VersionGantt::where('proyek_id', $request->id)->count(); |
|
|
|
$ganttCount = VersionGantt::where('proyek_id', $request->id)->count(); |
|
|
|