<?php

use \App\Model\setup\PackerModel;

?>
<style>
    .detail_table td{
        padding: 3px!important;
    }
</style>
<table class=" table-hover table-bordered detail_table" width="100%">
    <thead>
    <tr>
        <th>#</th>
        <th>{{__('administrator.date')}}</th>
        <th>{{__('administrator.production')}}</th>
        <th>{{__('administrator.packing')}}</th>
        <th>{{__('administrator.user')}}</th>
        <th>{{__('administrator.packer')}}</th>
        <th>{{__('administrator.total_item')}}</th>
        <th>{{__('administrator.import_qty')}}</th>
        <th>{{__('administrator.return_qty')}}</th>
        <th>{{__('administrator.remain')}}</th>
        <th>{{__('administrator.action')}}</th>
    </tr>
    </thead>
    <tbody>
    @php
        $total_done = 0;
    @endphp
    @foreach($master as $key => $row)
        @php
            $btn = ' <button title="' . __('administrator.show') . '" class="button_info btn_show" data-href = "' . route("production-packing.show", $row->id) . '">' . __('administrator.show') . '</button> ';
            $btn .= ' <button title="' . __('administrator.import_stock') . '" class="button_primary btn_show" data-add="' . (!$row->done ? (route('production-packing-import-stock', $row->id)) : '') . '" data-href = "' . route("production-packing-import-stock-list", $row->id) . '" >' . __('administrator.import_stock') . '</button> ';
            $btn .= ' <button title="' . __('administrator.return') . '" class="button_danger btn_show" data-add="' . (!$row->done ? route('production-packing-return-to-production', $row->id) : '') . '" data-href = "' . route("production-packing-return-to-production-list", $row->id) . '" >' . __('administrator.return') . '</button> ';

            if (!$row->done) {
                $btn .= ' <button title="' . __('administrator.done') . '" class="button_success btn_done" data-href = "' . route("production-packing-done", $row->id) . '">' . __('administrator.done') . '</button> ';
            }
        @endphp
        <tr>
            <td>{{$key+1}}</td>
            <td>{{myDate($row->date)}}</td>
            <td>{{($row->production_invoice)}}</td>
            <td>{{($row->invoice_number)}}</td>
            <td>{{findUser($row->user_id)->name}}</td>
            <td>{{PackerModel::find($row->packer_id)->name??''}}</td>
            <td>{{$row->total_qty}}</td>
            <td>{{$row->import_qty??0}}</td>
            <td>{{$row->return_qty??0}}</td>
            <td>{{$row->total_qty-$row->import_qty-$row->return_qty}}</td>
            <td>{!! $btn !!}</td>
        </tr>
    @endforeach
    </tbody>

</table>
