
<form class="nameToBeChecked form-horizontal" role="form" action="productControllerAjax.php?do=editopticdata" method="post" id="opticproduct-form">
    <input type="hidden" id="opticproduct" name="opticproduct" value="1"/>
    <div class="panel panel-default panel-m">
        <div class="panel-heading">
            <h3 class="panel-title">بيانات أساسية</h3>
        </div>
        <div class="panel-body">
            <div class="row">
                <input type="hidden" id="catid_hide" name="catid_hide" value="{$catData->productCatId}"/>
                <input type="hidden" id="gotoshow" name="gotoshow" value="{$gotoshow}"/>
                <div class="col-lg-6" id="rightpart" style="display: inline">
                    <div class="form-group">
                        <label for="parent" class="col-lg-4 control-label">التصنيف</label>
                        <div class="col-lg-8">
                            <select class="select2 wdt100" name="opticproductcatid" id="opticproductcatid">
                                <option value=""></option>
                                {foreach $allParents as $parent}
                                <option value="{$parent->productCatId}" {if $catData->productCatParent == $parent->productCatId}selected="selected"{/if}>{$parent->productCatName}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">الاسم</label>
                        <div class="col-lg-8">
                            <input type="text" name="name" id="name"  class="form-control" value="{$catData->productCatName}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">الحد الأدنى</label>
                        <div class="col-lg-8">
                            <input type="text" name="limitamount" id="limitamount"  class="form-control positiveNo limit" value="{$productData[0]->limitamount}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">التعليق</label>
                        <div class="col-lg-8">
                            <textarea  class="form-control" rows="2" name="description">{$catData->productCatDescription}</textarea>
                        </div>
                    </div>
                </div>

                <div class="col-lg-6" id="leftpart" style="display: inline">
                    <div class="form-group">
                        <label class="col-lg-4 control-label">سعر الشراء</label>
                        <div class="col-lg-8">
                            <div class="input-group">
                                <input type="text" name="productBuyPrice" id="productBuyPrice" class="form-control positivefloat proprice" value="{$productData[0]->productBuyPrice}"/>
                                <span class="input-group-addon">{$currency}</span> </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">سعر البيع جملة</label>
                        <div class="col-lg-8">
                            <div class="input-group">
                                <input type="text" name="productSellAllPrice" id="productSellAllPrice" class="form-control positivefloat proprice" value="{$productData[0]->productSellAllPrice}"/>
                                <span class="input-group-addon">{$currency}</span> </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">سعر البيع نصف جملة</label>
                        <div class="col-lg-8">
                            <div class="input-group">
                                <input type="text" name="productSellHalfPrice" id="productSellHalfPrice" class="form-control positivefloat proprice" value="{$productData[0]->productSellHalfPrice}"/>
                                <span class="input-group-addon">{$currency}</span> </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">سعر البيع تجزئة</label>
                        <div class="col-lg-8">
                            <div class="input-group">
                                <input type="text" name="productSellUnitPrice" id="productSellUnitPrice" class="form-control positivefloat proprice" value="{$productData[0]->productSellUnitPrice}"/>
                                <span class="input-group-addon">{$currency}</span> </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="panel panel-default panel-m">
        <div class="panel-heading">
            <h3 class="panel-title">الوحدات</h3>
        </div>
        <div class="panel-body">
            <a id="addOpticUnit" class="btn btn-primary" style="float: left"> إضافة</a>
            <table class="table table-black" id="opticUnitsTable">
                <thead>
                    <tr>
                        <th width="50%">اسم الوحدة</th>
                        <th width="40%">عدد القطع</th>
                        <th>حذف</th>
                    </tr>
                </thead>
                <tbody>
                    {assign var=i value=0}
                    {foreach $productUnitsData as $data}
                    <tr>
                        <td>
                            <input type="hidden" id="productUnit_hideid{$i}" name="productUnit_hideid{$i}" value="{$data->productunitid}"/>
                            <select name="unitid{$i}" id="unitid{$i}" class="select2 unitClass wdt100">
                                <option></option>
                                {foreach $unitsData as $unit}
                                <option value="{$unit->unitId}" {if $data->unitid == $unit->unitId}selected="selected"{/if}>{$unit->unitName}</option>
                                {/foreach}
                            </select>
                        </td>

                        <td>
                            <input type="text" name="unitno{$i}" id="unitno{$i}" class="form-control unitnoClass positiveNo" value="{$data->productnumber}">
                        </td>
                        <td>
                            <a class="btn btn-default btn-lg removeicon removethis"></a>
                        </td>
                    </tr>
                    {assign var=i value=$i+1}
                    {/foreach}
                </tbody>
            </table>
            <input type="hidden" id="unitsitr" name="unitsitr" value="{$productUnitsDataCount}"/>
        </div>
    </div>
    <input type="hidden" id="currentType" name="currentType" value="{if $catData->isOptic == 2}0{else}{$catData->isOptic}{/if}"/>
    <div class="panel panel-default panel-m">
        <div class="panel-heading">
            <h3 class="panel-title">التفاصيل</h3>
        </div>
        <!--a id="changeType" class="btn btn-success" style="float: left">منتج بدون مقاسات والوان </a-->
        <div class="panel-body">
            <div class="clearfix"></div>
            <br/>
            <!--div class="panel panel-default" id="productDiv" {if $catData->isOptic == 2}style="display: none"{/if}>
                <div class="panel-heading">
                    <h3 class="panel-title">البيانات المنتج</h3>
                </div>
                <div class="form-group">
                    <label class="col-lg-2 control-label">العدد</label>
                    <div class="col-lg-4">
                        <input type="text" name="productQuantity" id="productQuantity"  class="form-control positiveNo" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-2 control-label">الباركود</label>
                    <div class="col-lg-4">
                        <input type="text" name="productparcode" id="productparcode"  class="form-control" value="{$generatedParcode}"/>
                    </div>
                </div>
            </div-->
            <div class="panel panel-default" id="sizecolorDiv" {if $catData->isOptic != 2}style="display: none"{/if}>
                <div class="panel-heading">
                    <h3 class="panel-title">المقاسات أوالألوان</h3>
                </div>
                <div class="panel-body">
                    <a id="addOpticSizeColor" class="btn btn-primary" style="float: left"> إضافة</a>
                    <table class="table table-black" id="opticSizeColorTable">
                        <thead>
                            <tr>
                                <th>الاسم</th>
                                <th>الباركود</th>
                                <th>الكمية</th>
                                <th>تعليق</th>
                                <th>حذف</th>
                            </tr>
                        </thead>
                        <tbody>
                            {assign var=i value=0}
                            {foreach $productData as $data}
                            <tr>
                                <td>
                                    <!--input type="hidden" id="productunit_hideids{$i}" name="productunit_hideids{$i}" value="{$data->productUnitIds}"/-->
                                    <input type="hidden" id="product_hideid{$i}" name="product_hideid{$i}" value="{$data->productId}"/>
                                    <input type="text" name="sizecolorname{$i}" id="sizecolorname{$i}" class="form-control sizecolorname" value="{$data->productName}">
                                </td>
                                <td>
                                    <input type="text" name="parcode{$i}" id="parcode{$i}" class="form-control parcodec" value="{$data->parcode}">
                                </td>
                                <td>
                                    <input type="text" name="quantity{$i}" id="quantity{$i}" class="form-control positiveNo quantity" disabled="disabled" value="{$data->sumProductQuantity}">
                                </td>
                                <td>
                                    <textarea name="comment{$i}" id="comment{$i}" rows="2" class="form-control">{$data->productDescription}</textarea>
                                </td>
                                <td>
                                    <a class="btn btn-default btn-lg removeicon removethis"></a>
                                </td>
                            </tr>
                            {assign var=i value=$i+1}
                            {/foreach}
                        </tbody>
                    </table>
                    <input type="hidden" id="sizecoloritr" name="sizecoloritr" value="{$productDataCount}"/>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-lg-offset-2 col-lg-4">
                <button type="button"  class="btn btn-primary pull-left" id="saveOpticProduct">حفظ </button>
            </div>
        </div>
</form>


<div id="unitsDiv" style="display: none">
    <option></option>
    {foreach $unitsData as $data}
    <option value="{$data->unitId}">{$data->unitName}</option>
    {/foreach}
</div>

{literal}
<script>
    $('#opticproductcatid').select2();
    $('.unitClass').select2();
</script>
{/literal}