<style>
    .quantityStyle ,.costStyle{
        display: none;
    }
    @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">
                <form action="productionOutManyController.php?do=show" method="post" 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>
                                    <p>{$productionOutMany->title}</p>
                                </div>
                            </div>
                            <div class="col-lg-4">
                                <div class="form-group">
                                    <label>مخزن المدخلات</label>
                                    <p>
                                        {foreach $allStore as $store}
                                        {if $productionOutMany->inStore == $store->storeId}{$store->storeName}{/if}
                                        {/foreach}
                                    </p>
                                </div>
                            </div>
                            <div class="col-lg-4">
                                <div class="form-group">
                                    <label>مخزن المخرجات</label>
                                    <p>
                                        {foreach $allStore as $store}
                                        {if $productionOutMany->outStore == $store->storeId}{$store->storeName}{/if}
                                        {/foreach}
                                    </p>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="col-lg-4">
                                <div class="form-group">
                                    <label>المورد</label>
                                    <p>{$productionOutMany->suppliername}</p>
                                </div>
                            </div>

                            <!--                            <div class="col-lg-4">
                                                            <div class="form-group">
                                                                <label> المنتج النهائى</label>
                                                                <input type="hidden" class="getFinalProductsWithOutProductionEquation" name="finalProductId" id="finalProductId" data-placeholder=" اختر منتج"  />
                                                            </div>
                                                        </div>

                                                        <div class="col-lg-2">
                                                            <div class="form-group">
                                                                <label>الكمية</label>
                                                                <input type="text" name="outQuantity" class="form-control positivefloat outCalc" id="outQuantity" placeholder="">
                                                            </div>
                                                        </div>-->
                            <div class="col-lg-2">
                                <div class="form-group">
                                    <label>رقم التصنيع الخارجى</label>
                                    <p>{$productionOutMany->productionoutmanynum}</p>
                                </div>
                            </div>
                            <!--<br/>
                                    <div class="col-lg-4">
                                        <div class="form-group">
                                            <label>التعليق</label>
                                            <textarea name="comment" class="form-control" rows="2"></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 quantityStyle"> الكمية المتوقعة</th>
                                        <th  class="wdt120">الكمية </th><!--الفعلية-->
                                        <th  class="wdt120"> سعر الوحدة</th>
                                        <th  class="wdt120 costStyle" > التكلفة المتوقعة</th>
                                        <th class="wdt120">التكلفة </th><!-- الفعلية -->
                                    </tr>
                                </thead>
                                <tbody>
                                    {assign var=totalQuantity value=0}
                                    {assign var=totalCost value=0}
                                    {assign var=i value=1}
                                    {foreach $outProducts as $data}
                                    <tr>
                                        <td>
                                            {$data->productName}
                                        </td>
                                        <td>
                                            {$data->unitName}
                                        </td>
                                        <td class="quantityStyle">
                                            {$data->quantity}
                                        </td>
                                        <td>
                                            {$data->quantity}
                                        </td>
                                        <td><span id="unitPrice{$i}">{$data->unitprice}</span></td>
                                        <td class="costStyle">
                                            {$data->cost}
                                        </td>
                                        <td>
                                            {$data->cost}
                                        </td>
                                    </tr>
                                    {assign var=totalQuantity value=$totalQuantity+$data->quantity}
                                    {assign var=totalCost value=$totalCost+$data->cost}
                                    {assign var=i value=$i+1}
                                    {/foreach}
                                    <tr id="totalRowOut">
                                        <th colspan="2" style="color: #eeecda; background-color: #0081a8;">
                                            <span style="font: bold;">الإجمالي</span>
                                        </th>
                                        <th class="quantityStyle">
                                            <span id="totalQuantitySpan">{$totalQuantity}</span>
                                        </th>
                                        <th>
                                            <span id="totalActualQuantity">{$totalQuantity}</span>
                                        </th>
                                        <th></th>
                                        <th id="totCost" class="costStyle">{$totalCost}</th>
                                        <th>
                                            <span id="actualTotalCost">{$totalCost}</span>
                                            <input type="hidden" id="actlTotalCost" name="actlTotalCost" value="{$totalCost}">
                                        </th>
                                    </tr>
                                </tbody>
                            </table>
                        </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 ">
                                <thead>
                                    <tr>
                                        <th style="width:40%">المنتج </th>
                                        <th style="width:10%">وحدة القياس</th>
                                        <th style="width:10%">الكمية</th>
                                        <th style="width:10%">تكلفة المواد الخام للوحده</th>
                                        <th style="width:10%">تكلفة تصنيع الوحدة</th>
                                        <th style="width:10%">التكلفة الاجمالية للوحدة</th>
                                        <th style="width:10%">التكلفة الاجمالية</th>
                                    </tr>
                                </thead>
                                <tbody id="inTabletb">
                                    {assign var=inTotalCostTotal value=0}
                                    {assign var=allUnitManufPrice value=0}
                                    {assign var=i value=1}
                                    {foreach $inProducts as $data}
                                    <tr>
                                        <td>
                                            {$data->productName}
                                        </td>
                                        <td>
                                            {$data->unitName}
                                        </td>
                                        <td>{$data->quantity}</td>
                                        <td>{$data->unitpriceraw}</td>
                                        <td>{$data->unitManufPrice}</td>
                                        <td><span class="inTotalCostUnit" id="inTotalCostUnit{$i}">{$data->inTotalCostUnit}</span>{$data->inTotalCostUnit}</td>
                                        <td><span class="inTotalCost" id="inTotalCost{$i}">{$data->inTotalCost}</span></td>
                                    </tr>
                                    {assign var=inTotalCostTotal value=$inTotalCostTotal+$data->inTotalCost}
                                    {assign var=allUnitManufPrice value=$allUnitManufPrice+($data->quantity * $data->unitManufPrice)}
                                    {assign var=i value=$i+1}
                                    {/foreach}
                                </tbody>
                            </table>
                        </div>
                        <button type="button" class="btn btn-dark pull-left ft-nor">
                            الاجمالى <span class="badge wht-clo">
                                <div id='allCost'>{$inTotalCostTotal}</div>
                            </span>
                        </button>

                        <button type="button" class="btn btn-dark pull-left ft-nor" style="margin-left: 3px;">
                            اجمالى تكلفة تصنيع الوحدة	 <span class="badge wht-clo">
                                <div id='allUnitManufPrice'>{$allUnitManufPrice}</div>
                            </span>
                        </button>
                        <div class="clearfix"></div>
                    </div>
                    <div class="clearfix"></div>

                    <input type="hidden" name="id" id="id" value="{$productionOutMany->id}">
                    <div class="row  hidden-print m10" >
                        <div class="col-lg-12">
                            <button type="submit"  class="btn btn-primary">
                                <i class="glyphicon glyphicon-ok "></i>  رجوع</button>
                        </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-->

