<?php
    $weighttext = $RequestInfo->weight['farmer'];
    list($oldweight, $oldunit) = explode(" ", $weighttext);
?>

<input type="hidden" id="oldweight" value="<?php echo e($oldweight); ?>">
<form action="<?php echo e(route('factory.reciever.post.accept')); ?>" method="post" class="mt-3 mb-5" id="EditForm">
    <?php echo e(csrf_field()); ?>

    <input type="hidden" name="requestId" value="<?php echo e($RequestInfo->id); ?>">
    <strong class="mb-2"> تخصیص به سرتیم (مبالغ برحسب تومان):</strong>
    <div class="zar-table mt-3">
        <table>
            <thead>
                <tr>
                    <th>#</th>
                    <th>سرتیم</th>
                    <th>وزن</th>
                    <th>دستمزد سرتیم</th>
                    <th>دستمزد کارگر</th>
                    <th>تاریخ اتمام</th>
                </tr>
            </thead>
            <tbody id="FormBodyTable">
                <tr>
                    <td data-label="#"><i class="fa-solid fa-circle-plus fa-lg addrow" style="color: #74C0FC; cursor: pointer;"></i></td>
                    <td data-label="سرتیم">
                        <select name="chiefWorker[]" id="chiefWorker_0" class="form-control" required>
                            <?php $__currentLoopData = $user_chief_worker; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user_chief): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($user_chief->id); ?>"><?php echo e($user_chief->first_name); ?> <?php echo e($user_chief->last_name); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </td>
                    <td data-label="وزن">
                        <div class="d-flex">
                            <input type="number" name="weight[]" id="weight[]" class="form-control" step=0.01 placeholder="وزن" required>
                            <select name="weightUnit[]" id="weighUnit[]" class="form-control ms-2">
                                <option value="کیلوگرم">کیلوگرم</option>
                                <option value="گرم">گرم</option>
                            </select>
                        </div>
                    </td>
                    <td data-label="دستمزد سرتیم">
                        <input type="text" name="chiefprice1[]" id="chiefprice1[]" class="form-control" placeholder="دستمزد سرتیم" disabled value="<?php echo e(number_format($chiefworker_salary)); ?>">
                        <input type="hidden" name="chiefprice[]" id="chiefprice[]" value="<?php echo e($chiefworker_salary); ?>">
                    </td>
                    <td data-label="دستمزد کارگر">
                        <input type="text" name="workerprice1[]" id="workerprice1[]" class="form-control" placeholder="دستمزد کارگر" disabled value="<?php echo e(number_format($worker_salary)); ?>" >
                        <input type="hidden" name="workerprice[]" id="workerprice[]" value="<?php echo e($worker_salary); ?>"> 
                    </td> 
                    <td data-label="تاریخ اتمام">
                        <input type="text" name="enddate[]" id="enddate[]" class="form-control" placeholder="تاریخ اتمام" dir="ltr" data-jdp required>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <div class="mt-3">
        <span>جمع وزن : <span id="sumWeight">0</span></span>
    </div>
    <div class="d-flex mt-3 justify-content-between">
        <span class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#disagreeModal">اعلام مغایرت</span>
        <button type="submit" class="btn btn-success" id="SubmitFormBtn">تایید و ادامه</button>
    </div>
</form>

<div class="modal fade" id="disagreeModal" tabindex="-1" aria-labelledby="disagreeModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="disagreeModalLabel">اعلام مغایرت</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <p class="text-danger text-center">آیا مطمئن هستید که مغایرت اعلام کنید؟</p>
                <form action="<?php echo e(route('factory.reciever.post.disagree')); ?>" method="post">
                    <?php echo e(csrf_field()); ?>

                    <input type="hidden" name="reqId" value="<?php echo e($RequestInfo->id); ?>">
                    <label for="reason" class="mb-2">علت مغایرت:</label>
                    <textarea name="reason" id="reason" cols="30" rows="5" class="form-control" required></textarea>
                    <div class="d-flex justify-content-center mt-3">
                        <button type="submit" class="btn btn-danger">ثبت مغایرت</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div><?php /**PATH /home1/zarborji/public_html/resources/views/factoryReceiver/list/form.blade.php ENDPATH**/ ?>