<style>
    @media (min-width: 768px){
        .form-horizontal .form-group {
            margin-right: -10px;
            margin-left:-10px;
        }

        .m10{
            margin: 10px
        }
        h4{
            font-size: 17px;
            font-weight: bold;
            color: #000000;
            margin: 10px 0 15px;
            font-family: sans-serif;
        }
        hr {
            margin: 20px ;
            border: 0;
            border-top: 2px solid #d7d7d7;

        }
        .card{
            box-shadow: 0 4px 16px rgba(0,0,0,.12);
            padding: 10px;
            margin: 40px 0;
            border-radius: 5px
        }

    }
    .wdt230{
        width:230px
    }
    .billtable thead>tr>th {
        color: #eeecda;
        background-color: #0081a8;
    }
    .add i{
        font-size: 20px;
        color: #607D8B;
    }
    .wdt50{
        width:50px
    }
    .mt-10{
        margin-top: 10px
    }
    .data-search{
        margin: 10px 15px 0;
    }
    .btn-dark {
        color: #fff;
        background-color: #636262;
        border-color: #646464;
    }
    .data-search .form-control{
        border-radius:3px
    }

</style>




<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">تصنيع </a></li>
            <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>
            </div>

            <div class="panel-body">

                <form action="" method="post" id="form1" class="form-horizontal nameToBeChecked">
                    <input type="hidden" name="searchvalue" id="searchvalue" value="{$Programsettingdata->searchvalue}"/>

                    <div class="data-search">
                        <div class="row">
                            <div class="col-lg-4">
                                <div class="form-group ">
                                    <label>العنوان</label>
                                    <input type="text" name="title" id="title" disabled value="{$productionExecutionData->title}" class="form-control" placeholder="">
                                </div>
                            </div>
                            <div class="col-lg-2">
                                <div class="form-group">
                                    <label>رقم أمر انتاج</label>
                                    <input type="text" name="proOrderId" id="proOrderId" required  disabled value="{$productionExecutionData->orderId}" class="form-control" placeholder="">
                                </div>
                            </div>
                            <div class="col-lg-3">
                                <div class="form-group">
                                    <label class="">تاريخ </label>
                                    <input type="text" class="form-control awdatepicker" autocomplete="off" id="orderdate"  disabled value="{$productionExecutionData->orderdate}" data-date-format="yyyy-mm-dd" name="orderdate" required>
                                </div>
                            </div>
                            <div class="col-lg-2">
                                <div class="form-group">
                                    <label>{if $ManufacuresettingData->taskOrderName == 1}طلبية{else}أمر شغل{/if}</label>
                                    <select class=" select2" id="orderId" name="orderId" disabled>
                                        <option value="-1">اختر {if $ManufacuresettingData->taskOrderName == 1}طلبية{else}أمر شغل{/if}</option>
                                        {foreach $allTaskOrders as $order}
                                        {if $order->conditions neq 1}
                                        <option value="{$order->id}" {if $order->id eq $productionExecutionData->taskid}selected{/if}>{$order->title}</option>
                                        {/if}
                                        {/foreach}
                                    </select>
                                </div>
                            </div>

                            <div class="col-lg-4">
                                <div class="form-group">
                                    <label> المنتج النهائى</label>
                                    <!--<input type="hidden" class="getFinalProductsWithOutProductionEquation wdt300" name="finalProductId" id="finalProductId" data-placeholder=" اختر منتج"  />-->
                                    <!--<input id="oldfinalproduct" name="oldfinalproduct" type="hidden" value="{$oldfinalproduct}" />-->
                                    <input id="oldfinalproductname" class="form-control" name="oldfinalproductname" type="text" disabled value="{$oldfinalproductname}" />
                                </div>
                            </div>

                            <div class="col-lg-1">
                                <div class="form-group">
                                    <label>العدد</label>
                                    <input type="number" name="proNum" disabled value="{$productionExecutionData->num}" class="form-control" id="proNum" placeholder="">
                                </div>
                            </div>

                            <div class="col-lg-2" style="margin-right: 96px;">
                                <div class="form-group">
                                    <label>التعليق</label>
                                    <textarea type="text" name="comment" disabled class="form-control" placeholder="Enter text here...">{$productionExecutionData->comment}</textarea>
                                </div>
                            </div>

                        </div>
                    </div>


                    <!-- المكونات -->
                    <div class="card">
                        <div class="col-lg-6">
                            <h4>المكونات</h4>
                        </div>

                        <div class="table-responsive">
                            <table class="table billtable table-bordered table-black " id="table">
                                <thead>
                                    <tr>
                                        <th class="wdt400">المنتجات الخام</th>
                                        <th class="wdt120 ">وحدة القياس</th>
                                        <th class="wdt120"> الكمية المتوقعة</th>
                                        <th  class="wdt120">الكمية الفعلية</th>
                                        <th  class="wdt120" > التكلفة المتوقعة</th>
                                        <th class="wdt120">التكلفة الفعلية</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {assign var="totalQuantity" value="0"}
                                    {assign var="totalCost" value="0"}
                                    {assign var="actualtotalQuantity" value="0"}
                                    {assign var="actualtotalCost" value="0"}

                                    {foreach $productionExecutionProductsData as $pro}

                                    <tr>
                                        <td>
                                            {$pro->productName}
                                        </td>
                                        <td>
                                            {$pro->unitName}
                                        </td>
                                        <td>
                                            {$pro->quantity}
                                        </td>
                                        <td>
                                            {$pro->actualquantity}
                                        </td>
                                        <td>
                                            {$pro->cost}
                                        </td>
                                        <td>
                                            {$pro->actualcost}
                                        </td>
                                    </tr>
                                    {assign var="totalQuantity" value=$totalQuantity+$pro->quantity}
                                    {assign var="totalCost" value=$totalCost+($pro->cost)}
                                    {assign var="actualtotalQuantity" value=$actualtotalQuantity+$pro->actualquantity}
                                    {assign var="actualtotalCost" value=$actualtotalCost+($pro->actualcost)}
                                    {/foreach}
                                    <tr>
                                        <th colspan="2" style="color: #eeecda; background-color: #0081a8;"><span style="font: bold;">الإجمالي</span></th>
                                        <th><span id="totalQuantitySpan">{$totalQuantity}</span></th>
                                        <th><span id="totalActualQuantity">{$actualtotalQuantity}</span></th>
                                        <th>{$totalCost}</th>
                                        <th>
                                            <span id="actualTotalCost">{$actualtotalCost}</span>
                                        </th>
                                    </tr>
                                <input type="hidden" name="rowitr" id="rowitr" value="{count($productionExecutionProductsData)}"/>
                                </tbody>
                            </table>
                        </div>

                    </div>
                    <!-- end of title row-->
                    <div class="row">
                        <div class="col-lg-4">
                            <div class="form-group">
                                <label class="col-lg-5">تكلفة أجور للقطعة</label>
                                <div class="col-lg-7">
                                    <input type="number" min="0" name="rentCost" id="rentCost" disabled value="{$productionExecutionData->rentcost}" class="form-control countCost" placeholder="">
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-4">
                            <div class="form-group">
                                <label class="col-lg-5 pull">تكاليف أخرى للقطعة</label>
                                <div class="col-lg-7">
                                    <input type="number" name="otherCost" id="otherCost" disabled value="{$productionExecutionData->othercost}" class="form-control countCost" placeholder="">
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- المخرجات -->
                    <div class="card">
                        <div class="col-lg-6">
                            <h4>المخرجات</h4>
                        </div>
                        <div class="col-lg-3 ">
                            <div class="form-group mt-10">
                                <label class="col-lg-3"> المخزن</label>
                                <div class="col-lg-9">
                                    <select class=" select2" id="storeMain" name="storeMain" disabled>
                                        <option value="-1">اختر المخزن</option>
                                        {foreach $allStore as $store}
                                        <option value="{$store->storeId}" {if $store->storeId eq $productionExecutionData->outstoreid}selected{/if}>{$store->storeName}</option>
                                        {/foreach}
                                    </select>
                                </div>

                            </div>
                        </div>
                        <!--                        <div class="col-lg-3">
                                                    <button type="button" name="addOutPro" id="addOutPro" class="btn btn-primary pull-left ft-nor mt-10 addOutPro"> <i class="glyphicon glyphicon-plus"></i>
                                                        اضافة جديد</button>
                                                </div>-->
                        <input type="hidden" name="outItr" id="outItr" value="{count($productionExecutionOutputData)}"/>
                        <input type="hidden" id="countItr" name="countItr" value="{count($productionExecutionOutputData)}"/>
                        <div class="table-responsive">
                            <table class="table billtable table-bordered table-black " id="outTable">
                                <thead>
                                    <tr>
                                        <th class="wdt400">المنتجات </th>
                                        <th class="wdt230 ">
                                            اسعار البيع
                                            <br/>
                                            الجملة -  نصف الجملة - تجزئة
                                        </th>
                                        <th class="wdt120">  العدد</th>
                                        <th class="wdt200"> تكلفةالمواد الخام للوحدة</th>
                                        <th class="wdt200"> التكلفة الكلية للوحدة</th>
                                        <th  class="wdt400" >  المخزن</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {foreach $productionExecutionOutputData as $output}
                                    <tr>
                                        <td >
                                            {$output->productName}
                                        </td>
                                        <td >
                                            <input type="text" style="width:60px;margin:3px;float:right" name="allPrice1" id="allPrice1"  class="form-control " disabled value="{$output->allprice}" />
                                            <input type="text" style="width:60px;margin:3px;float:right" name="halfPrice1" id="halfPrice1"  class="form-control " disabled value="{$output->halfprice}" />
                                            <input type="text" style="width:60px;margin:3px;float:right" name="unitPrice1" id="unitPrice1"  class="form-control " disabled value="{$output->unitprice}" />
                                        </td>
                                        <td >
                                            {$output->num}
                                        </td>

                                        <td>{$output->cost|round:"2"}</td>
                                        <td>{($output->cost + $productionExecutionData->rentcost + $productionExecutionData->othercost)|round:"2"}</td>

                                        <td >
                                            <select class="select2 outStore" id="outStore1" disabled name="outStore1">
                                                <option value="-1">اختر المخزن</option>
                                                {foreach $allStore as $store}
                                                <option value="{$store->storeId}" {if $store->storeId eq $output->storeid}selected{/if}>{$store->storeName}</option>
                                                {/foreach}
                                            </select>
                                        </td>
                                    </tr>
                                    {/foreach}
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <!-- end of title row-->


                    <!-- الهادر -->
                    <div class="card">
                        <div class="col-lg-6">
                            <h4>الهادر</h4>
                        </div>
                        <div class="col-lg-3 ">
                            <div class="form-group mt-10">
                                <label class="col-lg-3"> المخزن</label>
                                <div class="col-lg-9">
                                    <select class=" select2" id="storeWasteMain" name="storeWasteMain" disabled>
                                        <option value="-1">اختر المخزن</option>
                                        {foreach $allStore as $store}
                                        <option value="{$store->storeId}" {if $store->storeId eq $productionExecutionData->wastestoreid}selected{/if}>{$store->storeName}</option>
                                        {/foreach}
                                    </select>
                                </div>

                            </div>
                        </div>
                        <input type="hidden" name="wasteItr" id="wasteItr" value="{count($productionExecutionWasteData)}"/>

                        <div class="table-responsive">
                            <table class="table billtable table-bordered table-black " id="wasteTable">
                                <thead>
                                    <tr>
                                        <th class="wdt400">المنتجات </th>
                                        <th class="wdt230 ">
                                            اسعار البيع
                                            <br/>
                                            الجملة -  نصف الجملة - تجزئة
                                        </th>
                                        <th class="wdt120">  العدد</th>
                                        <th  class="wdt400" >  المخزن</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {foreach $productionExecutionWasteData as $waste}
                                    <tr>
                                        <td >
                                            {$waste->productName}
                                        </td>
                                        <td >
                                            <input type="text" style="width:60px;margin:3px;float:right" name="wasteAllPrice1" id="wasteAllPrice1" disabled class="form-control " value="{$waste->allprice}" />
                                            <input type="text" style="width:60px;margin:3px;float:right" name="wasteHalfPrice1" id="wasteHalfPrice1" disabled class="form-control " value="{$waste->halfprice}" />
                                            <input type="text" style="width:60px;margin:3px;float:right" name="wasteUnitPrice1" id="wasteUnitPrice1" disabled class="form-control " value="{$waste->unitprice}" />

                                        </td>

                                        <td>
                                            {$waste->num}
                                        </td>
                                        <td >
                                            <select class="wasteStore select2" id="wasteStore1" name="wasteStore1" disabled>
                                                <option value="-1">اختر المخزن</option>
                                                {foreach $allStore as $store}
                                                <option value="{$store->storeId}" {if $store->storeId eq $waste->storeid}selected{/if}>{$store->storeName}</option>
                                                {/foreach}
                                            </select>
                                        </td>
                                    </tr>
                                    {/foreach}
                                </tbody>
                            </table>
                        </div>

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

                    <div class="row">
                        <div class="col-lg-12">
                            <button type="button" class="btn btn-dark pull-left ft-nor">
                                تكلفة أمر الانتاج <span class="badge wht-clo">
                                    <div id='allCost'>{$productionExecutionData->executioncost}</div>
                                </span>
                            </button>
                        </div>
                    </div>



                    <div class="clearfix"></div>
                    <hr/>

                    <div class="row  hidden-print m10" >
                        <div class="col-lg-12">
                            <a href="productionExecutionController.php?do=show" class="btn btn-success">رجوع</a>
                        </div>

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

                </form>

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

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

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

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



