Compare commits
24 Commits
b15a823c9c
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 0dcb155acb | |||
|
|
47a0cf31d2 | ||
| 0903c60316 | |||
|
|
e5f23303d9 | ||
| 724cdb9c3f | |||
|
|
b9e164725e | ||
| f9d870073f | |||
|
|
4699de9a77 | ||
| 81ee36f956 | |||
|
|
196117f07f | ||
| 1a31fb6f4e | |||
|
|
84b617f8fb | ||
| ed52e1b62c | |||
|
|
9f6959784f | ||
| 99e9dd6699 | |||
|
|
bbdd9fb75c | ||
| 6dc7a10865 | |||
|
|
cc788ea6d4 | ||
| 36082e27f9 | |||
|
|
8c0af96b94 | ||
| 122d39d912 | |||
|
|
b02954d0a2 | ||
|
|
9b098864bc | ||
|
|
50f542c3d1 |
@@ -102,7 +102,6 @@ class ProductCharacteristicsMasterImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?ProductCharacteristicsMaster
|
||||
{
|
||||
|
||||
$warnMsg = [];
|
||||
$plantCod = trim($this->data['plant']) ?? null;
|
||||
$itemCod = trim($this->data['item']) ?? null;
|
||||
|
||||
@@ -459,6 +459,13 @@ class ImportTransitResource extends Resource
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
$formattedDate = null;
|
||||
$formattedShipperDate = null;
|
||||
$etaDate = null;
|
||||
$etdDate = null;
|
||||
$formattedBlRcvdDate = null;
|
||||
|
||||
$criRfqNo = trim($row[1] ?? '');
|
||||
$mailRcvdDate = trim($row[2] ?? '');
|
||||
$pricolRefNo = trim($row[3] ?? '');
|
||||
|
||||
@@ -37,6 +37,9 @@ class VehicleEntryResource extends Resource
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('uuid')
|
||||
->label('Uuid')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('vehicle_number')
|
||||
->label('Vehicle Number')
|
||||
->required(),
|
||||
@@ -102,6 +105,11 @@ class VehicleEntryResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('uuid')
|
||||
->label('UUID')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('vehicle_number')
|
||||
->label('Vehicle Number')
|
||||
->alignCenter()
|
||||
|
||||
@@ -3780,7 +3780,7 @@ class CharacteristicsController extends Controller
|
||||
if (! $cField) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Master characteristic field value '{$charField}'' not found in approver master!",
|
||||
'status_description' => "Master characteristic field value '{$charField}' not found in approver master!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
@@ -3856,6 +3856,21 @@ class CharacteristicsController extends Controller
|
||||
$query->where('approver_type', 'Characteristic');
|
||||
})->where('machine_id', $machineId)->where('plant_id', $plantId)->get();
|
||||
|
||||
$requestQual = RequestCharacteristic::where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
|
||||
->whereHas('approver', function ($query) {
|
||||
$query->where('approver_type', 'Quality');
|
||||
})->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get();
|
||||
|
||||
foreach ($requestQual as $row) {
|
||||
$workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1';
|
||||
|
||||
TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId)
|
||||
->update([
|
||||
'has_work_flow_id' => $workFlowStatus,
|
||||
'updated_by' => $userName,
|
||||
]);
|
||||
}
|
||||
|
||||
$tempClassChars = TempClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->get();
|
||||
|
||||
if (! $requestChars->isEmpty()) {
|
||||
@@ -3966,6 +3981,21 @@ class CharacteristicsController extends Controller
|
||||
$query->where('approver_type', 'Characteristic');
|
||||
})->where('machine_id', $machineId)->where('plant_id', $plantId)->get();
|
||||
|
||||
$requestQual = RequestCharacteristic::where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
|
||||
->whereHas('approver', function ($query) {
|
||||
$query->where('approver_type', 'Quality');
|
||||
})->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get();
|
||||
|
||||
foreach ($requestQual as $row) {
|
||||
$workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1';
|
||||
|
||||
TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId)
|
||||
->update([
|
||||
'has_work_flow_id' => $workFlowStatus,
|
||||
'updated_by' => $userName,
|
||||
]);
|
||||
}
|
||||
|
||||
if (! $requestChars->isEmpty()) {
|
||||
$hasCharPending = false;
|
||||
|
||||
@@ -4980,6 +5010,21 @@ class CharacteristicsController extends Controller
|
||||
$query->where('approver_type', 'Characteristic');
|
||||
})->where('machine_id', $machineId)->where('plant_id', $plantId)->get();
|
||||
|
||||
$requestQual = RequestCharacteristic::where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
|
||||
->whereHas('approver', function ($query) {
|
||||
$query->where('approver_type', 'Quality');
|
||||
})->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get();
|
||||
|
||||
foreach ($requestQual as $row) {
|
||||
$workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1';
|
||||
|
||||
TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId)
|
||||
->update([
|
||||
'has_work_flow_id' => $workFlowStatus,
|
||||
'updated_by' => $userName,
|
||||
]);
|
||||
}
|
||||
|
||||
$tempClassChars = TempClassCharacteristic::where('aufnr', $jobNo)->where('machine_id', $machineId)->where('plant_id', $plantId)->get();
|
||||
|
||||
if (! $requestChars->isEmpty()) {
|
||||
@@ -5084,6 +5129,21 @@ class CharacteristicsController extends Controller
|
||||
$query->where('approver_type', 'Characteristic');
|
||||
})->where('machine_id', $machineId)->where('plant_id', $plantId)->get();
|
||||
|
||||
$requestQual = RequestCharacteristic::where('aufnr', $jobNo)->where('item_id', $itemId)->where('model_type', $modelType)
|
||||
->whereHas('approver', function ($query) {
|
||||
$query->where('approver_type', 'Quality');
|
||||
})->where('machine_id', $machineId)->where('plant_id', $plantId)->orderBy('id')->get();
|
||||
|
||||
foreach ($requestQual as $row) {
|
||||
$workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1';
|
||||
|
||||
TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId)
|
||||
->update([
|
||||
'has_work_flow_id' => $workFlowStatus,
|
||||
'updated_by' => $userName,
|
||||
]);
|
||||
}
|
||||
|
||||
if (! $requestChars->isEmpty()) {
|
||||
$hasCharPending = false;
|
||||
|
||||
@@ -5160,12 +5220,20 @@ class CharacteristicsController extends Controller
|
||||
'approver_status_3' => $row->approver_status3 ?? '',
|
||||
'approver_remark_3' => $row->approver_remark3 ?? '',
|
||||
'approved_at_3' => $row->approved3_at ?? '', // ? $row->approved3_at->format('d-m-Y H:i:s') : '',
|
||||
'mail_status' => ($row->mail_status == 'Sent') ? 'Sent-M1' : (($row->mail_status == 'Sent-Mail2') ? 'Sent-M2' : (($row->mail_status == 'Sent-Mail3') ? 'Sent-M3' : '-')),
|
||||
'triggered_at' => $row->trigger_at ?? '',
|
||||
'requested_by' => ($row->created_by == 'Admin') ? 'jothi' : $row->created_by ?? '',
|
||||
'requested_at' => $row->created_at ? $row->created_at->format('Y-m-d H:i:s') : '',
|
||||
];
|
||||
} else {
|
||||
$workFlowStatus = ($row->approver_status1 == 'Approved' || $row->approver_status2 == 'Approved' || $row->approver_status3 == 'Approved') ? '0' : '1';
|
||||
|
||||
// / TempClassCharacteristic::where('aufnr', $jobNo)->where('model_type', $modelType)->where('machine_id', $machineId)->where('plant_id', $plantId)
|
||||
// / ->update([
|
||||
// / 'has_work_flow_id' => $workFlowStatus,
|
||||
// / 'updated_by' => $userName,
|
||||
// / ]);
|
||||
|
||||
if ($workFlowStatus == '1') {
|
||||
$workFlowStatus = ($row->approver_status1 == 'Rejected' || $row->approver_status2 == 'Rejected' || $row->approver_status3 == 'Rejected') ? '2' : '1';
|
||||
}
|
||||
@@ -5191,6 +5259,8 @@ class CharacteristicsController extends Controller
|
||||
'approver_status_3' => $row->approver_status3 ?? '',
|
||||
'approver_remark_3' => $row->approver_remark3 ?? '',
|
||||
'approved_at_3' => $row->approved3_at ?? '', // ? $row->approved3_at->format('d-m-Y H:i:s') : '',
|
||||
'mail_status' => ($row->mail_status == 'Sent') ? 'Sent-M1' : (($row->mail_status == 'Sent-Mail2') ? 'Sent-M2' : (($row->mail_status == 'Sent-Mail3') ? 'Sent-M3' : '-')),
|
||||
'triggered_at' => $row->trigger_at ?? '',
|
||||
'requested_by' => ($row->created_by == 'Admin') ? 'jothi' : $row->created_by ?? '',
|
||||
'requested_at' => $row->created_at ? $row->created_at->format('Y-m-d H:i:s') : '',
|
||||
];
|
||||
|
||||
@@ -57,101 +57,154 @@ class VehicleController extends Controller
|
||||
|
||||
$plantId = $plantCod->id;
|
||||
|
||||
$data = $request->all();
|
||||
// $data = $request->all();
|
||||
|
||||
$vehicleNo = $data['vehicle_number'] ?? '';
|
||||
$entryTimeRaw = $data['entry_time'] ?? '';
|
||||
$exitTimeRaw = $data['exit_time'] ?? '';
|
||||
$duration = $data['duration'] ?? '';
|
||||
$type = $data['type'] ?? '';
|
||||
$data = $request->json()->all();
|
||||
|
||||
if(!$vehicleNo)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Vehicle number cant't be empty!",
|
||||
], 404);
|
||||
}
|
||||
else if (strlen($vehicleNo) < 8) {
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "vehicle number '$vehicleNo' must be at least 8 characters long",
|
||||
], 404);
|
||||
}
|
||||
else if(!$entryTimeRaw)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Entry time cant't be empty!",
|
||||
], 404);
|
||||
}
|
||||
// else if(!$exitTimeRaw)
|
||||
// {
|
||||
// return response()->json([
|
||||
// 'status' => 'ERROR',
|
||||
// 'status_description' => "Exit time cant't be empty!",
|
||||
// ], 404);
|
||||
// }
|
||||
// else if(!$duration)
|
||||
// {
|
||||
// return response()->json([
|
||||
// 'status' => 'ERROR',
|
||||
// 'status_description' => "Duration cant't be empty!",
|
||||
// ], 404);
|
||||
// }
|
||||
else if(!$type)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "type cant't be empty!",
|
||||
], 404);
|
||||
$results = [];
|
||||
|
||||
foreach ($data as $item) {
|
||||
|
||||
$uuid = $item['uuid'] ?? '';
|
||||
$vehicleNo = trim($item['vehicle_number'] ?? '');
|
||||
$entryTimeRaw = $item['entry_time'] ?? '';
|
||||
$exitTimeRaw = $item['exit_time'] ?? '';
|
||||
$duration = $item['duration'] ?? '';
|
||||
$type = $item['type'] ?? '';
|
||||
|
||||
if (!$vehicleNo) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Vehicle number can't be empty!"
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
elseif (strlen($vehicleNo) < 8) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Vehicle number '$vehicleNo' must be at least 8 characters long"
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
elseif (!$entryTimeRaw) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Entry time can't be empty!"
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
elseif (!$type) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Type can't be empty!"
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
elseif ($entryTimeRaw && !Carbon::hasFormat($entryTimeRaw, 'd/m/Y h:i:s A')) {
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid Entry time format $entryTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM"
|
||||
];
|
||||
continue;
|
||||
}
|
||||
else if ($exitTimeRaw && !Carbon::hasFormat($exitTimeRaw, 'd/m/Y h:i:s A')) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid Exit time format $exitTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM"
|
||||
];
|
||||
continue;
|
||||
}
|
||||
elseif ($duration && !preg_match('/^\d{2}:\d{2}:\d{2}$/', $duration)) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid duration format $duration"
|
||||
];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($entryTimeRaw && !Carbon::hasFormat($entryTimeRaw, 'd/m/Y h:i:s A')) {
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Invalid Entry time format $entryTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM",
|
||||
], 404);
|
||||
}
|
||||
else if ($exitTimeRaw && !Carbon::hasFormat($exitTimeRaw, 'd/m/Y h:i:s A')) {
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Invalid Exit time format $exitTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM",
|
||||
], 404);
|
||||
}
|
||||
else if ($duration && !preg_match('/^\d{2}:\d{2}:\d{2}$/', $duration)) {
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Invalid duration format $duration. Expected HH:MM:SS",
|
||||
], 404);
|
||||
if(!empty($results)){
|
||||
return response()->json($results, 404);
|
||||
}
|
||||
|
||||
if(!empty($entryTimeRaw)){
|
||||
$entryTime = $entryTimeRaw
|
||||
? Carbon::createFromFormat('d/m/Y h:i:s A', $entryTimeRaw)
|
||||
: null;
|
||||
foreach ($data as $item) {
|
||||
|
||||
$uuid = $item['uuid'] ?? '';
|
||||
$vehicleNo = trim($item['vehicle_number'] ?? '');
|
||||
$entryTimeRaw = $item['entry_time'] ?? '';
|
||||
$exitTimeRaw = $item['exit_time'] ?? '';
|
||||
$duration = $item['duration'] ?? '';
|
||||
$type = $item['type'] ?? '';
|
||||
|
||||
if(!empty($entryTimeRaw)){
|
||||
$entryTime = $entryTimeRaw
|
||||
? Carbon::createFromFormat('d/m/Y h:i:s A', $entryTimeRaw)
|
||||
: null;
|
||||
}
|
||||
|
||||
$exitTime = null;
|
||||
|
||||
if(!empty($exitTimeRaw)){
|
||||
|
||||
$exitTime = $exitTimeRaw
|
||||
? Carbon::createFromFormat('d/m/Y h:i:s A', $exitTimeRaw)
|
||||
: null;
|
||||
}
|
||||
|
||||
if (
|
||||
empty($duration) &&
|
||||
!empty($entryTime) &&
|
||||
!empty($exitTime)
|
||||
) {
|
||||
|
||||
$totalSeconds = $entryTime->diffInSeconds($exitTime);
|
||||
|
||||
$hours = floor($totalSeconds / 3600);
|
||||
$minutes = floor(($totalSeconds % 3600) / 60);
|
||||
$seconds = $totalSeconds % 60;
|
||||
|
||||
$duration = sprintf(
|
||||
'%02d:%02d:%02d',
|
||||
$hours,
|
||||
$minutes,
|
||||
$seconds
|
||||
);
|
||||
}
|
||||
|
||||
$record = VehicleEntry::updateOrInsert(
|
||||
[
|
||||
'plant_id' => $plantId,
|
||||
'uuid' => $uuid
|
||||
],
|
||||
[
|
||||
'vehicle_number' => $vehicleNo,
|
||||
'entry_time' => $entryTime,
|
||||
'exit_time' => $exitTime ?? null,
|
||||
'duration' => $duration ?: null,
|
||||
'type' => $type,
|
||||
'updated_at' => now(),
|
||||
'created_at' => now(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$exitTime = null;
|
||||
|
||||
if(!empty($exitTimeRaw)){
|
||||
|
||||
$exitTime = $exitTimeRaw
|
||||
? Carbon::createFromFormat('d/m/Y h:i:s A', $exitTimeRaw)
|
||||
: null;
|
||||
}
|
||||
|
||||
$record = VehicleEntry::insert([
|
||||
'plant_id' => $plantId,
|
||||
'vehicle_number' => $vehicleNo,
|
||||
'entry_time' => $entryTime,
|
||||
'exit_time' => $exitTime ?? null,
|
||||
'duration' => $duration ?: null,
|
||||
'type' => $type,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
if($record){
|
||||
return response()->json([
|
||||
'status' => 'SUCCESS',
|
||||
|
||||
@@ -34,7 +34,7 @@ class RequestCharacteristic extends Model
|
||||
'mail_status',
|
||||
'trigger_at',
|
||||
'work_flow_id',
|
||||
|
||||
'model_type',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
|
||||
@@ -17,6 +17,7 @@ class VehicleEntry extends Model
|
||||
'exit_time',
|
||||
'duration',
|
||||
'type',
|
||||
'uuid',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_at',
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE request_characteristics
|
||||
ADD COLUMN model_type TEXT DEFAULT NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('request_characteristics', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE vehicle_entries
|
||||
ADD COLUMN uuid TEXT DEFAULT NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('vehicle_entries', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user