
<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">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title">إضافة منتج</h3>
                <a href="{$youtubes[51]->url}" target="_blank" class="hidden-print"><img src="../views/default/assets/img/youtube.png" class="pull-left" alt="Youtube" style="width: 2%;"></a>
            </div>
            <div class="panel-body">
                <form class="nameToBeChecked form-horizontal" role="form" action="productController.php?do=addopticdata" 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">
                                <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}">{$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" />
                                        </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="0"/>
                                        </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"></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" value="0" class="form-control positivefloat proprice"/>
                                                <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" value="0" class="form-control positivefloat proprice"/>
                                                <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" value="0" class="form-control positivefloat proprice"/>
                                                <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" value="0" class="form-control positivefloat proprice"/>
                                                <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" id="opticUnitsTable">
                                <thead>
                                    <tr>
                                        <th width="50%">اسم الوحدة</th>
                                        <th width="40%">عدد القطع</th>
                                        <th>حذف</th>
                                    </tr>
                                </thead>
                                <tbody>

                                </tbody>
                            </table>
                            <input type="hidden" id="unitsitr" name="unitsitr" value="0"/>
                        </div>
                    </div>
                    <input type="hidden" id="currentType" name="currentType" value="0"/>
                    <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 panel-m" id="productDiv" style="display: none;">
                                <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" {if {$Programsettingdata->parcode} eq 0}  {else} style="display:none !important" {/if}>
                                    <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 panel-m" id="sizecolorDiv">
                                <div class="panel-heading">
                                    <h3 class="panel-title">المقاسات أوالألوان</h3>
                                </div>
                                <div class="panel-body">
                                    <input type="hidden" name="type_parcode" id="type_parcode" value="{$Programsettingdata->parcode}"/>
                                    <a id="addOpticSizeColor" class="btn btn-primary" style="float: left"> إضافة</a>
                                    <table class="table table-black" id="opticSizeColorTable">
                                        <thead>
                                            <tr>
                                                <th>الاسم</th>
                                                <th class=" check_tr {if {$Programsettingdata->parcode} eq 1} hidden {/if}">الباركود</th>
                                                <th>الكمية</th>
                                                <th>تعليق</th>
                                                <th>حذف</th>
                                            </tr>
                                        </thead>
                                        <tbody>

                                        </tbody>
                                    </table>
                                    <input type="hidden" id="sizecoloritr" name="sizecoloritr" value="0"/>
                                </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 class="clearfix"></div>
                <br/>



            </div>
            <div class="clearfix"></div>
        </div>
    </div>


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

    {literal}
    <script>
        $('body').on('keyup change', '#productBuyPrice', function () {
            var val = $(this).val();
            $('#productSellAllPrice').val(val);
            $('#productSellHalfPrice').val(val);
            $('#productSellUnitPrice').val(val);
        });
        $('body').on('keyup change', '#productSellAllPrice', function () {
            var val = $(this).val();
            $('#productSellHalfPrice').val(val);
            $('#productSellUnitPrice').val(val);
        });
    </script>
    {/literal}