<div id="opername" style="display:none">
    {foreach $alloperation as $operation}
    <option value="{$operation->settingOperationID}">{$operation->settingOperationName}</option>
    {/foreach}
</div>
<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>
            </div>
            <div class="panel-body">

                {literal}
                <form class="form-horizontal " role="form" action="stageController.php?do=update"  method="post" id="addform" >
                    {/literal}

                    <div class="form-group">
                        <label for="stagename" class="col-lg-2 control-label">اسم المرحله</label>
                        <div class="col-lg-4"><span id="sprytextfield1">
                                <input type="text" name="setoperation" id="setoperation"   placeholder="اسم  المرحله" class="form-control" value="{$loadstage->stagename}" />
                                <span class="textfieldRequiredMsg">***.</span></span>
                            <input type="hidden" name="stageid" id="stageid" value="{$loadstage->stageId}"/>
                        </div>
                    </div>

                    <!-- =================================================   -->

                    <div class="form-group">
                        <label for="productName" class="col-lg-2 control-label">اسم المنتج</label>
                        <div class="col-lg-4"><span id="productspry1">
                                <select class="select2 wdt300 " name="productname" id="productname">
                                    <option value="-1"> اختر منتج</option>
                                    {foreach $allproduct as $product}
                                    <option value="{$product->productId}" {if {$product->productId} eq {$loadstage->productId} }selected{/if}>{$product->productName}</option>
                                    {/foreach}

                                </select>
                                <span class="selectInvalidMsg">***.</span><span class="selectRequiredMsg">***.</span></span></div>
                    </div>

                    <!-- =================================================   -->

                    <div class="form-group">
                        <div class="form-group">
                            <hr/>
                            <div class="col-lg-6">
                                <h4> العمليات</h4>
                            </div>
                            <div class="col-lg-6">
                                <button type="button" name="addoperation" id="addoperation" class="btn btn-primary pull-left ft-nor"> اضافة جديد</button>
                            </div>
                        </div>
                        <div class="table-responsive">
                            <table class="table billtable table-bordered table-black" id="containerpros">
                                <thead>
                                    <tr>
                                        <th class="wdt200"> رقم العمليه</th>
                                        <th  class="wdt400"> اسم العمليه </th>
                                        <th  class="wdt200" >عدد الساعات</th>
                                        <th>حذف</th>

                                    </tr>
                                </thead>
                                <tbody>
                                    {assign var=x value=1}
                                    {foreach $stagerow as $newrow}
                                    <tr>
                                        <td>
                                            <div id="number">{$x}</div>
                                            <input type="hidden" name="no{$x}" id="no{$x}" value="{$x}"/>
                                        </td>
                                        <td>
                                            <div id="operat{$x}"><span id="operatspry{$x}">
                                                    <select class="select2 wdt300" name="oprationname{$x}" id="oprationname{$x}"  onchange="operationhour(this.value, {$x});">
                                                        <option value="-1">اختر عمليه</option>
                                                        {foreach $alloperation as $operation}
                                                        <option value="{$operation->settingOperationID}" {if {$operation->settingOperationID} eq {$newrow->operationId} }selected {/if}>{$operation->settingOperationName}</option>
                                                        {/foreach}
                                                    </select>
                                                    <span class="selectInvalidMsg">***.</span><span class="selectRequiredMsg">***.</span></span></div>
                                        </td>
                                        <td>
                                            <div id="operhours{$x}">
                                                <input type="text" name="hours{$x}" id="hours{$x}" value="{$newrow->newstage}" class="form-control getprototal  numberinput txt-nonraduis settinghour"  readonly />
                                            </div>
                                        </td>
                                        <td id="{$x}">
                                            <button id="remove{$x}" type="button" class="close flt-none removeicon removeoperation" aria-hidden="true">&times;</button>
                                            <input type="hidden" name="stagestep{$x}"  id="stagestep{$x}" value="{$newrow->stagestepId}"/>
                                        </td>
                                    </tr>

                                    {capture assign=x}{$x+1}{/capture}
                                    {/foreach}
                                </tbody>
                            </table>

                            <input type="hidden" name="operationitr" id="operationitr" value="{$newrow->counter}"/>
                            <button type="button" class="btn btn-primary pull-left ft-nor"> إجمالي عدد الساعات للعمليات <span class="badge wht-clo"><div id="totaloperationhourx">{$loadstage->totalhour}</div></span></button>
                            <input type="hidden" name="totaloperationhour1" id="totaloperationhour1" value="{$loadstage->totalhour}"/>
                        </div>
                    </div>

                    <!-- =================================================   -->
                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button type="submit"  class="btn btn-primary pull-left">حفظ الامر</button>
                        </div>
                    </div>


                </form>
            </div>
        </div>




    </div>
</div>



{literal}
<script>
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn: ["blur", "change"]});

    var productspry1 = new Spry.Widget.ValidationSelect("productspry1", {invalidValue: "-1"});
</script>
{/literal}