{{-- --}}

NTG TNA Dashboard

@php // Retrieve the user's role and assigned buyers $user = auth()->user(); $buyerIds = DB::table('buyer_assigns') ->where('user_id', $user->id) ->pluck('buyer_id'); // Query TNAs based on the user's role and assigned buyers $query = DB::table('t_n_a_s')->where('order_close', '0'); if ($user->role_id == 3 || ($user->role_id == 2 && $buyerIds->isNotEmpty())) { $query->whereIn('buyer_id', $buyerIds); } $buyerList = $query->select('buyer')->distinct()->get(); @endphp
Back @foreach ($buyerList as $buyer) @endforeach
{{--
{{ $tnas->links() }}
--}} {{-- --}} {{-- --}} @php $sl = 1; @endphp @forelse ($tnas as $tna) {{-- @dd($tna) --}} @if (auth()->user()->role_id == 4 || auth()->user()->role_id == 1) @elseif (auth()->user()->role_id == 3) @php $privileges = DB::table('buyer_assigns') ->where('buyer_id', $tna->buyer_id) ->where('user_id', auth()->user()->id) ->count(); // dd($privileges) @endphp @if ($privileges > 0) {{-- @dd($tna->buyer) --}} @else @endif @else @endif {{-- --}} {{-- @foreach (['lab_dip_submission', 'fabric_booking', 'fit_sample_submission', 'print_strike_off_submission', 'bulk_accessories_booking', 'fit_comments', 'bulk_yarn_inhouse', 'bulk_accessories_inhouse', 'pp_sample_submission', 'bulk_fabric_knitting', 'pp_comments_receive', 'bulk_fabric_dyeing', 'bulk_fabric_delivery', 'pp_meeting', 'cutting', 'etd'] as $task) @foreach (['plan', 'actual'] as $type) @php $date = $tna->{$task . '_' . $type}; $cellClass = ''; $explanation = ''; // Default explanation to empty // Check if $date is a valid date and not 'N/A' if ($date && $date !== 'N/A' && strtotime($date) !== false) { try { $cellDate = \Carbon\Carbon::parse($date); $today = \Carbon\Carbon::now(); $diffDays = $today->diffInDays($cellDate, false); if ($type === 'plan' && empty($tna->{$task . '_actual'})) { if ($cellDate->isToday() || $cellDate->lt($today)) { $cellClass = 'bg-red'; } elseif ($diffDays <= 2) { $cellClass = 'bg-yellow'; } else { $cellClass = 'bg-light'; } } if ($type === 'actual' && $tna->{$task . '_plan'}) { $planDate = \Carbon\Carbon::parse($tna->{$task . '_plan'}); if ($cellDate->gt($planDate)) { $cellClass = 'text-danger font-weight-bold'; } } } catch (\Exception $e) { // Log the error or handle it appropriately $date = ''; // Reset the date if parsing fails } } elseif ($date === 'N/A') { $cellClass = 'text-muted'; // Optional: add a class for 'N/A' } @endphp @if ($type === 'actual' && empty($date)) @if (auth()->user()->role_id == 3) @php $buyer_privilage = DB::table('buyer_assigns') ->where('buyer_id', $tna->buyer_id) ->where('user_id', auth()->user()->id) ->count(); @endphp @if ($buyer_privilage > 0) @endif @else @endif @else @php $explanation = DB::table('tna_explanations') ->where('perticulars', $task . '_' . $type) ->where('tna_id', $tna->id) ->first()->explanation ?? ''; @endphp @endif @endforeach @endforeach --}} @foreach (['lab_dip_submission', 'fabric_booking', 'fit_sample_submission', 'print_strike_off_submission', 'bulk_accessories_booking', 'fit_comments', 'bulk_yarn_inhouse', 'bulk_accessories_inhouse', 'pp_sample_submission', 'bulk_fabric_knitting', 'pp_comments_receive', 'bulk_fabric_dyeing', 'bulk_fabric_delivery', 'pp_meeting', 'etd', 'fabrics_and_accessories_inspection', 'size_set_making', 'pattern_correction', 'machines_layout', 'cutting', 'print_start', 'bulk_sewing_input', 'bulk_wash_start', 'bulk_finishing_start', 'bulk_cutting_close', 'print_close', 'bulk_sewing_close', 'bulk_wash_close', 'bulk_finishing_close', 'pre_final_inspection', 'final_inspection', 'ex_factory'] as $task) @foreach (['plan', 'actual'] as $type) @php $date = $tna->{$task . '_' . $type}; $cellClass = ''; if ($date && $date != 'N/A') { $today = \Carbon\Carbon::now(); $cellDate = \Carbon\Carbon::parse($date); $diffDays = $today->diffInDays($cellDate, false); if ($type === 'plan' && empty($tna->{$task . '_actual'})) { if ($cellDate->isToday() || $cellDate->lt($today)) { $cellClass = 'bg-red'; } elseif ($diffDays <= 2) { $cellClass = 'bg-yellow'; } else { $cellClass = 'bg-light'; } } if ($type === 'actual' && $tna->{$task . '_plan'}) { $planDate = \Carbon\Carbon::parse($tna->{$task . '_plan'}); $actualDate = \Carbon\Carbon::parse($date); if ($cellDate->gt($planDate)) { $cellClass = 'text-danger font-weight-bold'; } if ($cellDate->gt($actualDate)) { $cellClass = 'bg-light'; } } } elseif ($date == 'N/A') { $date = 'N/A'; } @endphp @if ($type === 'actual' && empty($date)) @if ( $task == 'lab_dip_submission' || $task == 'fabric_booking' || $task == 'fit_sample_submission' || $task == 'print_strike_off_submission' || $task == 'bulk_accessories_booking' || $task == 'fit_comments' || $task == 'bulk_yarn_inhouse' || $task == 'bulk_accessories_inhouse' || $task == 'pp_sample_submission' || $task == 'bulk_fabric_knitting' || $task == 'pp_comments_receive' || $task == 'bulk_fabric_dyeing' || $task == 'bulk_fabric_delivery') @if (auth()->user()->role_id == 1 || auth()->user()->role_id == 3 || auth()->user()->role_id == 4) @else @endif @elseif ($task == 'fabrics_and_accessories_inspection') @if (auth()->user()->role_id == 1 || auth()->user()->role_id == 10008 || auth()->user()->role_id == 10009 || auth()->user()->role_id == 4) @else @endif @elseif ($task == 'size_set_making') @if (auth()->user()->role_id == 1 || auth()->user()->role_id == 10005 || auth()->user()->role_id == 4) @else @endif @elseif ($task == 'pattern_correction') @if (auth()->user()->role_id == 1 || auth()->user()->role_id == 10007 || auth()->user()->role_id == 10008 || auth()->user()->role_id == 4) @else @endif @elseif ($task == 'machines_layout') @if (auth()->user()->role_id == 1 || auth()->user()->role_id == 10006 || auth()->user()->role_id == 4) @else @endif @elseif ( $task == 'cutting' || $task == 'print_start' || $task == 'bulk_sewing_input' || $task == 'bulk_wash_start' || $task == 'bulk_finishing_start' || $task == 'bulk_cutting_close' || $task == 'print_close' || $task == 'bulk_sewing_close' || $task == 'bulk_wash_close' || $task == 'bulk_finishing_close') @if (auth()->user()->role_id == 1 || auth()->user()->role_id == 4 || auth()->user()->role_id == 5) @else @endif @elseif ($task == 'pre_final_inspection' || $task == 'final_inspection' || $task == 'ex_factory') @if (auth()->user()->role_id == 1 || auth()->user()->role_id == 10008 || auth()->user()->role_id == 4) @else @endif @elseif ($task == 'final_inspection' || $task == 'ex_factory') @if (auth()->user()->role_id == 1 || auth()->user()->role_id == 10005 || auth()->user()->role_id == 4) @else @endif @else @endif @else @endif @endforeach @endforeach @empty @endforelse {{-- {{ $tnas->links() }} --}}
Action Buyer Style PO Number Item Qty (pcs) PO Receive Date Shipment/ETD Total Lead Time Order Free Time Lab Dip Submission Fabric Booking Fit Sample Submission Print Strike Off Submission Bulk Accessories Booking Fit Comments Bulk Yarn Inhouse Bulk Accessories Inhouse PP Sample Submission Bulk Fabric Knitting PP Comments Receive Bulk Fabric Dyeing Bulk Fabric Delivery PP MeetingCuttingETD Fabrics and Accessories Inspection Size Set Making Pattern Correction Machines, Layout, and Folder Preparation Bulk Cutting Start Print/Emb. Start Bulk Sewing Input Bulk Wash Start Bulk Finishing Start Bulk Cutting Close Print/Emb. Close Bulk Sewing Close Bulk Wash Close/ Finishing Received Bulk Finishing Close Pre-final Inspection Final Inspection ex-factory
Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan Actual Plan ActualPlan Actual
{{ $sl++ }} {{ $sl++ }} {{ $sl++ }}{{ $sl++ }}{{ $tna->buyer }}{{ $tna->style }} {{ $tna->po }} {{ str_replace(',', ' ', $tna->style) }} {{ str_replace(',', ' ', $tna->po) }} {{ $tna->item }} {{ $tna->qty_pcs }} {{ \Carbon\Carbon::parse($tna->po_receive_date)->format('d-M-y') ?? '' }} {{ \Carbon\Carbon::parse($tna->shipment_etd)->format('d-M-y') ?? '' }} {{ $tna->total_lead_time }} @if ($tna->pp_meeting_actual == null) @php $today = \Carbon\Carbon::parse($tna->pp_meeting_plan); $shipment_etd = \Carbon\Carbon::parse($tna->shipment_etd); $diffDays = $today->diffInDays($shipment_etd, false); if ($diffDays > 0) { echo $diffDays; } else { echo '0'; } @endphp @else @php $today = \Carbon\Carbon::parse($tna->pp_meeting_plan); $shipment_etd = \Carbon\Carbon::parse($tna->pp_meeting_actual); $diffDays = $today->diffInDays($shipment_etd, false); if ($diffDays > 0) { echo $diffDays; } else { echo '0'; } @endphp @endif {{ $date == 'N/A' ? 'N/A' : ($date ? \Carbon\Carbon::parse($date)->format('d-M-y') : '') }} {{ $date == 'N/A' ? 'N/A' : ($date ? \Carbon\Carbon::parse($date)->format('d-M-y') : '') }}
No TNA Found
Cancel Refresh Page