<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
    }
    .eqName{
        color: #eeecda;background-color: #0081a8;padding: 5px; vertical-align: middle; text-align: center;font-weight: bold;width:60%;
    }
</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">
                <input type="hidden" name="lowOutPriceAlert" id="lowOutPriceAlert" value="{$ManufacuresettingData->lowOutPriceAlert}"/>
                <form action="productionExecutionController.php?do=add" 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" required 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 class="form-control" placeholder="" data-val="{$orderId}" value="{$orderId}">
                                </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" data-date-format="yyyy-mm-dd" name="orderdate" required value="{$today}">
                                </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" >
                                        <option value="-1">اختر {if $ManufacuresettingData->taskOrderName == 1}طلبية{else}أمر شغل{/if}</option>
                                        {foreach $allTaskOrders as $order}
                                        {if $order->conditions neq 1}
                                        <option value="{$order->id}" data-proId="{$order->productId}" data-proName="{$order->productName}/{$order->proCatName}" data-num="{$order->num}">{$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=" اختر منتج"  />
                                </div>
                            </div>

                            <div class="col-lg-1">
                                <div class="form-group">
                                    <label>العدد</label>
                                    <input type="text" name="proNum" class="form-control positivefloat" 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" class="form-control" placeholder="Enter text here..."></textarea>
                                </div>
                            </div>

                        </div>
                    </div>
                    <div id="SCProEqDiv">

                    </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>

                                </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="text" min="0" name="rentCost" id="rentCost" class="form-control countCost positivefloat" placeholder="" value="0">
                                </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="text" name="otherCost" id="otherCost" class="form-control countCost positivefloat" placeholder="" value="0">
                                </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">
                                        <option value="-1">اختر المخزن</option>
                                        {foreach $allStore as $store}
                                        <option value="{$store->storeId}" {if $ManufacuresettingData->storeid && $ManufacuresettingData->storeid eq $store->storeId}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="1"/>
                        <input type="hidden" id="countItr" name="countItr" value="1"/>
                        <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="wdt300" >  المخزن</th>
                                        <th class="wdt50"></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>
                                            <input type="hidden" id="product1" name="product1"  class="select2product wdt100"  data-placeholder="اختر منتج"  tabindex="7" />
                                        </td>
                                        <td >
                                            <input type="text" style="width:60px;margin:3px;float:right" name="allPrice1" id="allPrice1"  class="form-control checkPrice" value="" />
                                            <input type="text" style="width:60px;margin:3px;float:right" name="halfPrice1" id="halfPrice1"  class="form-control checkPrice" value="" />
                                            <input type="text" style="width:60px;margin:3px;float:right" name="unitPrice1" id="unitPrice1"  class="form-control checkPrice" value="" />
                                        </td>
                                        <td >
                                            <input type="text" name="amount1" id="amount1" min="0" class="form-control outAmount positivefloat" value="" />
                                        </td>

                                        <td><span id="outCost1"></span></td>
                                        <td><span id="outTotalCost1"></span></td>
                                        <td>
                                            <select class="select2 outStore" id="outStore1" name="outStore1">
                                                <option value="-1">اختر المخزن</option>
                                                {foreach $allStore as $store}
                                                <option value="{$store->storeId}" {if $ManufacuresettingData->storeid && $ManufacuresettingData->storeid eq $store->storeId}selected{/if}>{$store->storeName}</option>
                                                {/foreach}
                                            </select>
                                        </td>
                                        <td class="noprint"><a href="javascript:;" type="button" class="btn add addOutPro" id="addOutPro1"><i class="glyphicon glyphicon-plus-sign"></i></a></td>
                                    </tr>
                                </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">
                                        <option value="-1">اختر المخزن</option>
                                        {foreach $allStore as $store}
                                        <option value="{$store->storeId}"{if $ManufacuresettingData->storeid && $ManufacuresettingData->storeid eq $store->storeId}selected{/if}>{$store->storeName}</option>
                                        {/foreach}
                                    </select>
                                </div>

                            </div>
                        </div>
                        <!--                        <div class="col-lg-3">
                                                    <button type="button" name="addWastePro" id="addWastePro" class="btn btn-primary pull-left ft-nor mt-10 addWastePro"> <i class="glyphicon glyphicon-plus"></i>
                                                        اضافة جديد</button>
                                                </div>-->
                        <input type="hidden" name="wasteItr" id="wasteItr" value="1"/>

                        <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>
                                        <th class="wdt50"></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td >
                                            <input type="hidden" id="wasteproduct1" name="wasteproduct1"  class="select2product wdt100 wasteproduct"  data-placeholder="اختر منتج"  tabindex="7" />
                                        </td>
                                        <td >
                                            <input type="text" style="width:60px;margin:3px;float:right" name="wasteAllPrice1" id="wasteAllPrice1"  class="form-control " value="" />
                                            <input type="text" style="width:60px;margin:3px;float:right" name="wasteHalfPrice1" id="wasteHalfPrice1"  class="form-control " value="" />
                                            <input type="text" style="width:60px;margin:3px;float:right" name="wasteUnitPrice1" id="wasteUnitPrice1"  class="form-control " value="" />

                                        </td>

                                        <td>
                                            <input type="text" name="wasteAmount1" id="wasteAmount1" min="0" class="form-control positivefloat" value="" />
                                        </td>
                                        <td >
                                            <select class="wasteStore select2" id="wasteStore1" name="wasteStore1">
                                                <option value="-1">اختر المخزن</option>
                                                {foreach $allStore as $store}
                                                <option value="{$store->storeId}" {if $ManufacuresettingData->storeid && $ManufacuresettingData->storeid eq $store->storeId}selected{/if}>{$store->storeName}</option>
                                                {/foreach}
                                            </select>
                                        </td>
                                        <td class="noprint"><a href="javascript:;" type="button" class="btn add addWastePro" id="addWastePro1"><i class="glyphicon glyphicon-plus-sign"></i></a></td>
                                    </tr>
                                </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'>0</div>
                                </span>
                            </button>
                        </div>
                    </div>



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

                    <div class="row  hidden-print m10" >
                        <div class="col-lg-12">
                            <button type="submit"  id="saveBtn" class="btn btn-primary">
                                <i class="glyphicon glyphicon-ok "></i>  حفظ</button>
                            {if $ManufacuresettingData->reducestoreamount && $ManufacuresettingData->reducestoreamount eq 1} <button type="submit"  id="executeSave" class="btn btn-success"><i class="glyphicon glyphicon-send "></i>  حفظ وتنفيذ </button>{/if}
                        </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-->

<script>
    /*$(function(){
     $("#saveBtn").on('click',function() {
     $(this).hide();
     $("#executeSave").hide();
     });

     $("#executeSave").on('click',function() {
     $(this).hide();
     $("#saveBtn").hide();
     });
     });*/
</script>


