<style>
    @media (min-width: 768px){
        .form-horizontal .form-group {
            margin-right: -10px;
            margin-left:-10px;
        }
    }
    table i{
        font-size:18px;
        margin: 5px
    }
    .remove{
        color: #ec0000;
        font-size: 22px;

    }
    .edit{
        color:green

    }
    .detail{
        color:#0e7fd9
    }
    .billtable thead>tr>th {
        color: #eeecda;
        background-color: #0081a8;
    }

    .data-search{
        margin: 10px 15px 0;
    }
    .btn-dark {
        color: #fff;
        background-color: #636262;
        border-color: #646464;
    }
    .data-search .form-control{
        border-radius:3px
    }
    .card{
        box-shadow: 0 4px 16px rgba(0,0,0,.12);
        padding: 10px;
        margin: 40px 0;
        border-radius: 5px
    }
</style>


<div class="row">

    <div class="container">


        <ol class="breadcrumb">
            <li><a href="#">أمر انتاج</a></li>
            <li class="active">عرض</li>
        </ol>

        <div class="panel panel-default panel-m">
            <div class="panel-heading">
                <h3 class="panel-title"> عرض اوامر الانتاج</h3>
                <a href="{$youtubes[284]->url}" target="_blank" class="hidden-print"><img src="../views/default/assets/img/youtube.png" class="pull-left" alt="Youtube" style="width: 2%;"></a>

            </div>

            <div class="panel-body">
                <form class="form-inline hidden-print" action="productionExecutionController.php?do=show" method="post">
                    <div class="data-search">
                        <div class="row">
                            <div class="col-lg-3">
                                <div class="form-group">
                                    <label class="">من تاريخ </label>
                                    <input type="text" class="form-control awdatepicker" autocomplete="off" id="from" data-date-format="yyyy-mm-dd" name="from">
                                </div>
                            </div>
                            <div class="col-lg-3">
                                <div class="form-group">
                                    <label class="">الى تاريخ </label>
                                    <input type="text" class="form-control awdatepicker" autocomplete="off" id="from" data-date-format="yyyy-mm-dd" name="to">
                                </div>
                            </div>
                            <div class="col-lg-3">
                                <div class="form-group">
                                    <label>رقم أمر انتاج</label>
                                    <select class=" select2" name="orderId">
                                        <option value="-1">اختر رقم أمر الإنتاج</option>
                                        {foreach $allIds as $row}
                                        <option value="{$row->id}">{$row->orderId}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="col-lg-3">
                                <div class="form-group">
                                    <label>المنتج النهائي</label>
                                    <select class=" select2" name="productid">
                                        <option value="-1">المنتج النهائي</option>
                                        {foreach $allProductsExec as $row}
                                        <option value="{$row.productId}">{$row.productName}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-lg-4">
                                <div class="form-group">
                                    <label>التصنيف</label>
                                    <select class=" select2" name="catid">
                                        <option value="-1">التصنيف</option>
                                        {foreach $allProductCat as $row}
                                        <option value="{$row.productCatId}">{$row.productCatName}</option>
                                        {/foreach}
                                    </select>
                                </div>
                                <button type="submit" class="btn btn-primary">بحث</button>
                            </div>


                        </div>
                    </div>

                </form>
            </div>
            <!-- Table -->

            <div class="panel panel-default panel-m">
                <!-- Default panel contents -->
                <div class="panel-heading">{$message}</div>
                <div class="panel-body">
                    <!-- ================================================   -->
                    <!-- Nav tabs -->
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#new_orders" data-toggle="tab">كل أوامر الإنتاج</a></li>
                        <li><a href="#underDelivery_orders" data-toggle="tab">أوامر لم يتم تنفيذها</a></li>
                        <li><a href="#deliverd_orders" data-toggle="tab">أوامر تم تنفيذها</a></li>
                    </ul>
                    <!-- =================================================   -->
                    <div class="tab-content">
                        <hr/>
                        <!-- start the  new_orders -->
                        <div class="tab-pane active" id="new_orders">
                            <table class="table billtable table-bordered table-black card dataTableClass22">
                                <thead>
                                    <tr>
                                        <th > العنوان</th>
                                        <th> الرقم</th>
                                        <th> المنتج النهائي</th>
                                        <th> التاريخ</th>
                                        <th> عدد القطع</th>
                                        <th> التكلفة</th>
                                        <th> تكلفة الوحدة</th>
                                        <th class="noprint" >  تفاصيل</th>
                                        <th class="noprint">   تعديل</th>
                                        <th> الحالة</th>
                                        <th class="noprint">   حذف</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {foreach $allOrders as $order}
                                    <tr>
                                        <td>{$order->title}</td>
                                        <td>{$order->orderId}</td>
                                        <td>{$order->productName}</td>
                                        <td>{$order->orderdate}</td>
                                        <td>{$order->num}</td>
                                        <td>{$order->executioncost}</td>
                                        <td>{$order->executioncost/$order->num}</td>
                                        <td class="noprint"><a href="productionExecutionController.php?do=details&id={$order->id}" type="button" class="btn">
                                                <i class="glyphicon glyphicon-folder-open detail"></i>
                                            </a></td>
                                        <td class="noprint"><a href="productionExecutionController.php?do=edit&id={$order->id}" type="button" class="btn ">
                                                <i class="glyphicon glyphicon-pencil edit"></i>
                                            </a></td>
                                        <td>
                                            {if $order->executed eq 1}تم التنفيذ{else}
                                            {if $ManufacuresettingData->reducestoreamount && $ManufacuresettingData->reducestoreamount eq 1}
                                            <a href="productionExecutionController.php?do=execute&id={$order->id}" type="button" {if $usergroupData->storenegative == 1} class="btn executeBtn" data-id={$order->id} {else} class="btn" {/if}>
                                                تنفيذ <i class="glyphicon glyphicon-export"></i>
                                            </a>
                                            {else}
                                            لم يتم التنفيذ
                                            {/if}
                                            {/if}
                                        </td>
                                        <td class="noprint"><a href="javascript:;" type="button" class="btn">
                                                <i class="glyphicon glyphicon-remove-sign remove conformdel1" onclick="getValue({$order -> id});"></i>
                                            </a></td>
                                    </tr>
                                    {/foreach}
                                </tbody>

                            </table>
                            <div class="clearfix"></div>
                        </div>
                        <!-- start the  underDelivery_orders -->
                        <div class="tab-pane" id="underDelivery_orders">
                            <table class="table billtable table-bordered table-black card dataTableClass22">
                                <thead>
                                    <tr>
                                        <th > العنوان</th>
                                        <th> الرقم</th>
                                        <th> التاريخ</th>
                                        <th> عدد القطع</th>
                                        <th> التكلفة</th>
                                        <th class="noprint" >  تفاصيل</th>
                                        <th class="noprint">   تعديل</th>
                                        <!--<th> الحالة</th>-->
                                        <th class="noprint">   حذف</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {foreach $allOrders as $order}
                                    {if $order->executed eq 0}
                                    <tr>
                                        <td>{$order->title}</td>
                                        <td>{$order->orderId}</td>
                                        <td>{$order->orderdate}</td>
                                        <td>{$order->num}</td>
                                        <td>{$order->executioncost}</td>
                                        <td class="noprint"><a href="productionExecutionController.php?do=details&id={$order->id}" type="button" class="btn">
                                                <i class="glyphicon glyphicon-folder-open detail"></i>
                                            </a></td>
                                        <td class="noprint"><a href="productionExecutionController.php?do=edit&id={$order->id}" type="button" class="btn ">
                                                <i class="glyphicon glyphicon-pencil edit"></i>
                                            </a></td>
                                        <!--<td>{if $order->executed eq 1}تم التنفيذ{else}لم يتم التنفيذ{/if}</td>-->
                                        <td class="noprint"><a href="javascript:;" type="button" class="btn">
                                                <i class="glyphicon glyphicon-remove-sign remove conformdel1" onclick="getValue({$order -> id});"></i>
                                            </a></td>
                                    </tr>
                                    {/if}
                                    {/foreach}
                                </tbody>

                            </table>
                        </div>
                        <!-- start the  deliverd_orders -->
                        <div class="tab-pane" id="deliverd_orders">
                            <table class="table billtable table-bordered table-black card dataTableClass22">
                                <thead>
                                    <tr>
                                        <th > العنوان</th>
                                        <th> الرقم</th>
                                        <th> التاريخ</th>
                                        <th> عدد القطع</th>
                                        <th> التكلفة</th>
                                        <th class="noprint" >  تفاصيل</th>
                                        <th class="noprint">   تعديل</th>
                                        <!--<th> الحالة</th>-->
                                        <th class="noprint">   حذف</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {foreach $allOrders as $order}
                                    {if $order->executed eq 1}
                                    <tr>
                                        <td>{$order->title}</td>
                                        <td>{$order->orderId}</td>
                                        <td>{$order->orderdate}</td>
                                        <td>{$order->num}</td>
                                        <td>{$order->executioncost}</td>
                                        <td class="noprint"><a href="productionExecutionController.php?do=details&id={$order->id}" type="button" class="btn">
                                                <i class="glyphicon glyphicon-folder-open detail"></i>
                                            </a></td>
                                        <td class="noprint"><a href="productionExecutionController.php?do=edit&id={$order->id}" type="button" class="btn ">
                                                <i class="glyphicon glyphicon-pencil edit"></i>
                                            </a></td>
                                        <!--<td>{if $order->executed eq 1}تم التنفيذ{else}لم يتم التنفيذ{/if}</td>-->
                                        <td class="noprint"><a href="javascript:;" type="button" class="btn">
                                                <i class="glyphicon glyphicon-remove-sign remove conformdel1" onclick="getValue({$order -> id});"></i>
                                            </a></td>
                                    </tr>
                                    {/if}
                                    {/foreach}
                                </tbody>
                            </table>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                    <div  class="noprint">
                        <div class="col-lg-12">
                            <div class="form-group">
                                <div class="col-lg-4">
                                    <!--<button type="button" onclick="print_Custom('mycustomheader');" class="btn btn-success pull-right hidden-print">طباعة</button>-->
                                </div>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                    <div class="clearfix"></div>
                </div>
            </div>




        </div>  <!-- end of panel panel-default-->

    </div> <!-- end of container-->

</div>  <!-- end of row-->

{literal}
<script type="text/javascript">
            function getValue(idval)
            {
            var confirmDel = window.confirm("هل تريد حذف العنصر؟");
                    //alert(confirmDel);

                    if (confirmDel == true)
            {
            // x="You pressed OK!";
            window.location.href = "productionExecutionController.php?do=delete&id=" + idval;
            }
            else
            {
            // x="You pressed Cancel!";
            }

            }

    $(document).ready(function () {
        $('.dataTableClass22').dataTable({
            "order"
                : [
                        [4, "desc"]       // order by drug cat
                ]
        });

        $('.executeBtn').on('click',function(e){
            let id = $(this).data('id');
            $.ajax({
                type: "POST",
                url: 'productionExecutionAjaxController.php?do=checkStoreNegativeById',
                data: {id:id},
                async: false,
                success: function (data) {
                    if(data == -1){
                        e.preventDefault();
                        alert(" بعض الكميات غير موجودة بمخزن التصنيع ");
                    }
                }
            });
        });
    });

</script>
{/literal}