<div id="newemp" style="display:none">
    {foreach $allemp as $new}
    <option value="{$new->employeeId}">{$new->employeeName}</option>
    {/foreach}
</div>
<div id="newasset" style="display:none">
    {foreach $allassets as $newasst}
    <option value="{$newasst->assetId}">{$newasst->assetsName}</option>
    {/foreach}
</div>
<div class="row">
    <div class="container">

        <ol class="breadcrumb">
            <li><a href="#">المخازن</a></li>
            <li><a href="../workstation/storeController.php?do=show">المخازن</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 class="nameToBeChecked form-horizontal" role="form" action="workstationController.php?do=update" method="post">

                    <div class="form-group">
                        <label for="storeName" class="col-lg-2 control-label">اسم المركز</label>
                        <div class="col-lg-4"><span id="sprytextfield1">
                                <input type="text" name="stationname" id="stationname"   placeholder="اسم المركز" class="form-control" value="{$loadwork->workname}" />
                                <span class="textfieldRequiredMsg">***.</span></span>
                            <input type="hidden" name="stationid" id="stationid" value="{$loadwork->workstationid}"/>
                        </div>
                    </div>
                    <div class="row">
                        <div class="row">
                            <hr/>
                            <div class="col-lg-6">
                                <h4>العمال</h4>
                            </div>
                            <div class="col-lg-6">
                                <button type="button" name="addwork" id="addwork" 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="wdt400">اسم العمال</th>
                                        <th  class="wdt200">عدد الساعات </th>
                                        <th  class="wdt200" >الكفاءه %</th>
                                        <th>حذف</th>

                                    </tr>
                                </thead>
                                <tbody>
                                    {assign var=x value=1}
                                    {foreach $allworker as $worker}
                                    <tr>
                                        <td>
                                            <div id="choose{$x}"><span id="employeespry{$x}">
                                                    <select class="select2 wdt300 " name="workname{$x}" id="workname{$x}" >
                                                        <option value="-1">اختر عامل</option>
                                                        {foreach $allemp as $new}
                                                        <option value="{$new->employeeId}" {if {$new->employeeId} eq {$worker->employeeid} }selected{/if}>{$new->employeeName}</option>
                                                        {/foreach}
                                                    </select>
                                                    <span class="selectInvalidMsg">***.</span><span class="selectRequiredMsg">***.</span></span></div>
                                        </td>
                                        <td>
                                            <div id="workhours{$x}">
                                                <input type="text" name="hours{$x}" id="hours{$x}" value="{$worker->workhours}"  class="form-control getprototal  numberinput txt-nonraduis workerhour" required onkeypress="return isNumberKey(event)" />
                                            </div>
                                        </td>
                                        <td>
                                            <div id="workefficency{$x}">
                                                <input type="text" name="efficency{$x}" id="efficency{$x}"  value="{$worker->efficiency}"  class="form-control getprototal  numberinput txt-nonraduis workerhour effx" required onKeyPress="return isNumberKey(event)"/>
                                            </div>
                                        </td>
                                        <td id="{$x}">
                                            <button id="remove{$x}" name="remove{$x}" type="button" class="close flt-none removeicon removework" aria-hidden="true">&times;</button>
                                            <input type="hidden" name="workid{$x}" id="workid{$x}" value="{$worker->workstationworkerId}"/>
                                        </td>
                                    </tr>
                                    {capture assign=x}{$x+1}{/capture}
                                    {/foreach}
                                </tbody>
                            </table>

                            <input type="hidden" name="stationitr" id="stationitr" value="{$workitr}"/>
                            <button type="button" class="btn btn-primary pull-left ft-nor"> إجمالي عدد الساعات للعمال <span class="badge wht-clo"><div id="totalworkerhour">{$loadwork->workerhours}</div></span></button>
                            <input type="hidden" name="totalworkerhourx" id="totalworkerhour1" value="{$loadwork->workerhours}"/>
                        </div>
                    </div>
                    <!-- =================================================   -->


                    <div class="row">
                        <div class="row">
                            <hr/>
                            <div class="col-lg-6">
                                <h4> الاصول</h4>
                            </div>
                            <div class="col-lg-6">
                                <button type="button" name="addasset" id="addasset" class="btn btn-primary pull-left ft-nor"> اضافة جديد</button>
                            </div>
                        </div>
                        <div class="table-responsive">
                            <table class="table billtable table-bordered table-black" id="containerassets">
                                <thead>
                                    <tr>
                                        <th class="wdt400"> اسم الاله</th>
                                        <th  class="wdt200">عدد الساعات </th>
                                        <th  class="wdt200" >الكفاءه %</th>
                                        <th>حذف</th>

                                    </tr>
                                </thead>
                                <tbody>
                                    {assign var=j value=1}
                                    {foreach $allasset as $asst}
                                    <tr>
                                        <td>
                                            <div id="chooseasset{$j}"><span id="assetspry{$j}">
                                                    <select class="select2 wdt300" name="asset{$j}" id="asset{$j}" >
                                                        <option value="-1">اختر اله</option>
                                                        {foreach $allassets as $newasst}
                                                        <option value="{$newasst->assetId}" {if {$newasst->assetId} eq {$asst->assetsId} }selected{/if}>{$newasst->assetsName}</option>
                                                        {/foreach}
                                                    </select>
                                                    <span class="selectInvalidMsg">***.</span><span class="selectRequiredMsg">***.</span></span>
                                            </div>
                                        </td>
                                        <td>
                                            <div id="assethours">
                                                <input type="text" name="whour{$j}" id="whour{$j}" value="{$asst->workhours}" class="form-control getprototal  numberinput txt-nonraduis assethour" required onkeypress="return isNumberKey(event)" />
                                            </div>
                                        </td>
                                        <td>
                                            <div id="assetefficency">
                                                <input type="text" name="wefficency{$j}" id="wefficency{$j}" value="{$asst->efficiency}" class="form-control getprototal  numberinput txt-nonraduis assethour effasset" required onkeypress="return isNumberKey(event)" />
                                            </div>
                                        </td>
                                        <td id="x{$j}">
                                            <button id="wremove{$j}" type="button" class="close flt-none removeicon removeasset" aria-hidden="true">&times;</button>
                                            <input type="hidden" name="assetid{$j}" id="assetid{$j}" value="{$asst->workstationassetsId}"/>
                                        </td>

                                    </tr>
                                    {capture assign=j}{$j+1}{/capture}
                                    {/foreach}
                                </tbody>
                            </table>
                            <input type="hidden" name="assetsitr" id="assetsitr" value="{$assititr}"/>
                            <button type="button" class="btn btn-primary pull-left ft-nor"> إجمالي عدد الساعات لاله <span class="badge wht-clo"><div id="totalassethour">{$loadwork->assetshours}</div></span></button>
                            <input type="hidden" name="totalassethourx" id="totalassethour1" value="{$loadwork->assetshours}"/>
                        </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>
    function isNumberKey(evt)
    {
        var charCode = (evt.which) ? evt.which : event.keyCode
        if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

        return true;
    }


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

</script>

{/literal}

