<!--to call from js-->
<!--    <div id="RawMaterials" style="display:none">
        {foreach $rows as $material}
                <option value="{$material->productId}">{$material->productName}</option>
        {/foreach}
    </div> -->
<!--    end   -->



<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="productionRateController.php?do=update" method="post" id="form1">
                    <input type="hidden" name="searchvalue" id="searchvalue" value="{$Programsettingdata->searchvalue}"/>
                    <span class="form-group">
                        <input type="hidden" name="productionrateid" id="productionrateid" value="{$productionrate->productionRateId}" />
                    </span>
                    <div class="row">
                        <div class="col-lg-8">
                            <div class="form-group">
                                <label class="col-lg-4 control-label">اسم معادلة الانتاج</label>
                                <div class="col-lg-4">
                                    <input name="name" id="name" value="{$productionrate->name}" type="text"   class="form-control"/>
                                </div>
                            </div>




                            <div class="form-group" style="margin-top:30px">
                                </br>
                                <label class="col-lg-4 control-label">اختر اسم المنتج النهائى</label>
                                <div class="col-lg-4">
                                    <input type="hidden"  class="getFinalProductsWithOutProductionRate wdt300" name="finalProductId" id="finalProductId" data-placeholder=" اختر منتج"  />
                                    <!-- <select class="select2 wdt300" name="finanlproduct" id="finanlproduct">
                                                 <option value="-1">اختر المنتج النهائى</option>
                                           {foreach $finanlproduct as $f}
                                             <option
                                             {if {$f->productId}=={$choosenfinanlproduct}}selected="selected"{/if}

                                              value="{$f->productId}">{$f->productName}</option>
                                           {/foreach}
                                           </select>-->

                                    <input id="oldfinalproduct" name="oldfinalproduct" type="hidden" value="{$oldfinalproduct}" />
                                    <input id="oldfinalproductname" name="oldfinalproductname" type="hidden" value="{$oldfinalproductname}" />

                                </div>

                            </div>




                        </div>
                    </div>


                    <div class="row">
                        <div class="row">
                            <hr/>
                            <div class="col-lg-6">
                                <h4 class="col-lg-4">المكونات
                                    <input type="hidden" name="rowitr" id="rowitr" value="{$noOfRows}" />
                                </h4>
                            </div>
                            <div class="col-lg-6">
                                <button type="button" name="addrow" id="addrow" class="btn btn-primary pull-left ft-nor"> اضافة جديد</button>
                                <button type="button" style="display:none;" name="addrow" id="addrow" class="btn btn-primary pull-left ft-nor" onclick="addrow();"> اضافة جديد</button>
                            </div>

                        </div>
                        <p><!-- end of title row--></p>
                        <table class="table billtable table-bordered table-black" id="table">
                            <thead>
                                <tr>
                                    <th class="wdt400">المنتجات الخام</th>
                                    <th  class="wdt200"><span class="sr-only">وحدة القياس</span></th>
                                    <!--<th  class="wdt200">نسبة المشاركة </th>-->
                                    <th  class="wdt200" >عدد الوحدات</th>
                                    <th class="wdt200">حذف</th>
                                </tr>
                            </thead>
                            <tbody>
                                {assign var=i value=1}
                                {assign var=y value=1}
                                {foreach $Productionrateproduct as $x}
                                <tr>
                                    <td ><input type="hidden" name="productionRateProductId{$i}" id="productionRateProductId{$i}"  value="{$x->productionRateProductId}"/>

                                        <!--  <input type="hidden"  class="select2RawMaterials wdt300" name="product{$i}" id="product{$i}" data-placeholder=" اختر منتج خام"  />-->

                                        <!--               <input type="hidden"   name="oldproduct{$i}" id="oldproduct{$i}" value="{$x->productId}"  />
                                                       <input type="hidden"   name="oldproductname{$i}" id="oldproductname{$i}" value="{$x->productName}"  />-->

                                        <select class="select2 wdt300" name="product{$i}" id="product{$i}" >


                                            {foreach $rows as $material}
                                            <option value="{$material->productId}"

                                                    {if {$material->productId}=={$x->productId}}selected="selected"{/if} >{$material->productName}</option>
                                            {/foreach}


                                        </select>
                                    </td>
                                    <td>
                                        <div id="unitDiv{$i}">
                                            <select name="unitId{$i}" id="unitId{$i}" class="select2 wdt300">
                                                {foreach $productUnitData{$y} as $myUnit}
                                                <option value="{$myUnit->productunitid}"
                                                        {if {$myUnit->productunitid}=={$x->unitId}}selected="selected"{/if}

                                                    >{$myUnit->unitName}</option>

                                                {/foreach}
                                            </select>
                                        </div>

                                        <!--<input type="hidden"   name="oldUnit{$i}" id="oldUnit{$i}" value="{$x->unitId}"  />
                                         <input type="hidden"   name="oldUnitName{$i}" id="oldUnitName{$i}" value="{$x->unitName}"  /> -->
                                    </td>
                                    <!--                                    <td><div id="table">
                                                                                <input type="text" name="input{$i}" id="input{$i}"  class="form-control check" value="{$x->rate}" tabindex=""  />
                                                                            </div></td>-->
                                    <td><div id="table">
                                            <input  name="inputt{$i}" id="inputt{$i}"  class="form-control positive" value="{$x->quantity}" tabindex="" />
                                        </div></td>
                                    <td id="{$i}">
                                        <button id="remove{$i}" name="remove{$i}" type="button" class="close flt-none removeicon removeproduct"  aria-hidden="true" onclick="removerow();">&times;</button>
                                    </td>
                                </tr>
                                {capture assign=i}{$i+1}{/capture}
                                {capture assign=y}{$y+1}{/capture}
                                {/foreach}
                            </tbody>
                        </table>
                        <p>&nbsp; </p>
                        <!--                        <button type="button" class="btn btn-primary pull-left ft-nor"> اجمالى النسبة <span class="badge wht-clo">
                                                        <div id="percentage">100</div>

                                                    </span></button>-->
                    </div>
                    <div class="row" align="center">
                        <button type="submit" id="save" class="btn btn-primary">حفظ</button>

                        <span style="color:#F00;font-weight:bold;font-size:120%;" > {$msg}</span>
                        <!--<button type="submit" id="saveAndNew" class="btn btn-success" onclick="return changeFormAction({$billnameid});">حفظ وجديد</button>-->
                    </div>
                </form>


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

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

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

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