<!--to call from js-->
<div id="RawMaterials" style="display:none">
    {foreach $rows as $material}
    <option value="{$material->productId}">{$material->productName}</option>
    {/foreach}
</div>
<div id="productUnitsDiv" style="display:none;">
    <option value="-1">اختر وحدة القياس</option>
    {foreach $unitsData as $unit}
    <option value="{$unit->unitId}">{$unit->unitName}</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>
                <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 action="productController.php?do=add" method="post" class="nameToBeChecked" id="myProductForm" name="myProductForm" enctype="multipart/form-data">
                    <input type="hidden" name="searchvalue" id="searchvalue" value="{$Programsettingdata->searchvalue}"/>
                    <div class="row">
                        <div class="col-lg-8">
                            <div>
                                <label class="control-label">تصنيف المنتج</label>
                                <select class="select2 wdt300 productCatt" data-level="0"  name="productCatId0" id="productCatId0" >
                                    <option value="-1">اختر تصنيف</option>
                                    {foreach $catDataReport as $data}
                                    <option value="{$data->productCatId}">{$data->productCatName}</option>
                                    {/foreach}
                                </select>
                                <input type="hidden" id="level" name="level" value="0">
                            </div>
                            <div id="manyParents"></div>
                            <input type="hidden" id="dontLoadProducts" name="dontLoadProducts" value="1"/>
                            <input type="hidden" name="productAddMultiCatLevel" id="productAddMultiCatLevel" value="1"/>
                            <input type="hidden" name="productAddMultiCatLevel" id="productAddMultiCatLevel" value="1"/>
                            <input type="hidden" name="productquantity1" id="productquantity1" value="0"/>
                            <input type="hidden" name="expireDate1" id="expireDate1" value="0"/>
                            <input type="hidden" name="limitamount1" id="limitamount1" value="0"/>
                            <input type="hidden" name="type1" id="type1" value="0"/>
                            <input type="hidden" name="isCollective" id="isCollective" value="1"/>
                            <input name="productItr" id="productItr" type="hidden" value="1" />
                            <br/>
                            <div class="form-group">
                                <label class="col-lg-3 control-label">اسم المنتج النهائى</label>
                                <div class="col-lg-4">
                                    <input name="productName1" id="productName1"  type="text" class="form-control add_required_attr" onchange="checkProductName(this.value, 1);" data-itra="1"/>
                                    <span id="nameError" style="display: none;color: darkred;">هذا الاسم موجود مسبقاً من فضلك اختر اسماً آخر.</span>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="form-group">
                                <label class="col-lg-3 control-label">سعر الجملة</label>
                                <div class="col-lg-4">
                                    <input name="productSellAllPrice1" id="productSellAllPrice1" data-type="buytotal"  type="text" class="form-control prices aw_m aw_mt aw_pp numberclic positivefloat buy_total1 enteraction numberinput" data-itra="1"/>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="form-group">
                                <label class="col-lg-3 control-label">سعر نصف الجملة</label>
                                <div class="col-lg-4">
                                    <input name="productSellHalfPrice1" type="text" data-type="buyhalf" id="productSellHalfPrice1" class="form-control  aw_m aw_mt aw_pp numberclic prices enteraction numberinput positivefloat buy_hafe1" required="required">
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="form-group">
                                <label class="col-lg-3 control-label">سعر التجزئه</label>
                                <div class="col-lg-4">
                                    <input name="productSellUnitPrice1" type="text" data-type="buypart" id="productSellUnitPrice1" class="form-control  aw_m aw_mt aw_pp numberclic prices enteraction numberinput positivefloat buy_part1" data-id="1" required="required">
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="form-group">
                                <label class="col-lg-3 control-label">صورة</label>
                                <div class="col-lg-4">
                                    <input type="file" name="logo1" id="logo1" placeholder="الشعار" accept="image/*"/>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="form-group {if $Programsettingdata->parcode eq 1} hidden {/if}">
                                <label class="col-lg-3 control-label">الباركود</label>
                                <div class="col-lg-4">
                                    <input name="parcode1" onblur="checkbarcode(this.value, 1);" type="text"   id="parcode1" size="9" class="form-control" value="" size="50" ><!-- {$generatedParcode} -->
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="form-group {if $Programsettingdata->date eq 1} hidden {/if}">
                                <label class="col-lg-3 control-label">التاريخ</label>
                                <div class="col-lg-4">
                                    <input name="productDate1" type="text" id="productDate1" size="9"  class="form-control awdatepicker" autocomplete="off"  data-date-format="yyyy-mm-dd" value="{$today}"  width="27"/>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="form-group {if $Programsettingdata->isCaf != 1 && $Programsettingdata->isRestaurent != 1} hidden {/if}">
                                <label class="col-lg-3 control-label">فى المنيو</label>
                                <div class="col-lg-4">
                                    <label class='color-black'>
                                        <input value="0"  class="radioR" name="inMenu1" checked="checked"  type="radio"  />
                                        نعم </label>

                                    <label class='color-black'>
                                        <input value="1"  class="noradioR" name="inMenu1" type="radio" />
                                        لا </label>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="form-group">
                                <label class="col-lg-3 control-label">خدمة</label>
                                <div class="col-lg-4">
                                    <label class='color-black'>
                                        <input value="1"  class="radioR isservice" name="isservice1"   type="radio" />
                                        نعم </label>

                                    <label class='color-black'>
                                        <input value="0"  class="noradioR isservice" name="isservice1"   checked="checked"  type="radio" />
                                        لا </label>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="form-group">
                                <label class="col-lg-3 control-label">الوصف</label>
                                <div class="col-lg-4">
                                    <textarea  name="productDescription1" id="productDescription1" class="form-control"></textarea>
                                </div>
                            </div>


                        </div>
                    </div>
                    <div class="panel panel-default panel-m {if {$Programsettingdata->measuringunit} eq 1} hidden {/if}">
                        <div class="panel-heading">
                            <h3 class="panel-title">الوحدات</h3>
                        </div>
                        <div class="panel-body">
                            <input class="addUnits btn btn-warning pull-left" onclick="addUnits(1);" type="button" value="إضافة وحدة قياس">
                            <!------------------------ وحدة قياس---------------------->
                            <input name="unitsItr1" id="unitsItr1" type="hidden" value="0" />
                            <div id="addUnitsDiv1 " class="check_tr_mesurunit" style=" ">
                                <table id="unitsTable1" class="table" style="
                                       width: 98%;
                                       box-shadow: 0px 3px 5px #a59f9f, -3px 0px 5px #fff;
                                       background-color: #999;">
                                    <tr style="display: none">
                                        <td>
                                            <div class="form-group">
                                                <label class="col-lg-4 control-label">اسم وحدة القياس</label>
                                                <div class="col-lg-8">
                                                    <select name="productunit11" id="productunit11" data-placeholder="اختر"  class="select2 wdt100 chosenproduct" >
                                                        <option value="-1">اختر وحدة القياس</option>

                                                        {foreach $unitsData as $unit}

                                                        <option value="{$unit->unitId}">{$unit->unitName}</option>

                                                        {/foreach}

                                                    </select>
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="form-group">
                                                <label class="col-lg-4 control-label">عدد الوحدات</label>
                                                <div class="col-lg-8">
                                                    <input name="productnumber11" id="productnumber11" type="text" class="form-control numberinput" />
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <a id="remove11" onClick="removeUnits(1, 1);" class="removeUnits">X</a>
                                        </td>
                                    </tr>
                                </table>
                                <!--end unitsTable-->
                            </div>
                            <!--end productsTable -->
                        </div>
                    </div>
                    <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" name="rowitr" id="rowitr" value="0" />
                                <input type="hidden" name="notRawMaterialsOnly" id="notRawMaterialsOnly" value="1"/>
                                <div class="col-lg-12">
                                    <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>
                            <table class="table billtable table-bordered table-black col-lg-4" 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>
                                </tbody>
                            </table>
                            <p>&nbsp; </p>
                            <div>
                                <!--h4><u>(customProductionRate.js , function calcCollectiveProductCost()) azmy  حساب تكلفة المنتج من المكونات</u></h4-->
                                <button type="button" class="btn btn-primary ft-nor"> التكلفة بسعر الشراء
                                    <span class="badge wht-clo"><div id="productBuyPrice">0</div></span></button>
                                &nbsp;
                                <button type="button" class="btn btn-primary ft-nor"> التكلفة باخر سعر شراء
                                    <span class="badge wht-clo"><div id="lastbuyprice">0</div></span></button>
                                &nbsp;
                                <button type="button" class="btn btn-primary ft-nor"> التكلفة باخر سعر شراء مع الخصم
                                    <span class="badge wht-clo"><div id="lastbuyprice_withDiscount">0</div></span></button>
                                &nbsp;
                                <button type="button" class="btn btn-primary ft-nor"> التكلفة بمتوسط سعر الشراء
                                    <span class="badge wht-clo"><div id="meanbuyprice">0</div></span></button>
                                &nbsp;
                                <button type="button" class="btn btn-primary ft-nor"> التكلفة بمتوسط سعر الشراء مع الخصم
                                    <span class="badge wht-clo"><div id="meanbuyprice_withDiscount">0</div></span></button>

                                <button type="button" class="btn btn-primary ft-nor">المتوسط العام
                                    <span class="badge wht-clo"><div id="overAllAveragePrice">0</div></span></button>

                                <input type="hidden" name="productBuyPrice_h" id="productBuyPrice_h" value=""/>
                                <input type="hidden" name="lastbuyprice_h" id="lastbuyprice_h" value=""/>
                                <input type="hidden" name="lastbuyprice_withDiscount_h" id="lastbuyprice_withDiscount_h" value=""/>
                                <input type="hidden" name="meanbuyprice_h" id="meanbuyprice_h" value=""/>
                                <input type="hidden" name="meanbuyprice_withDiscount_h" id="meanbuyprice_withDiscount_h" value=""/>
                                <input type="hidden" name="overAllAveragePrice_h" id="overAllAveragePrice_h" value=""/>
                            </div>
                            <br/>
                            <div class="clearfix"></div>
                        </div>
                    </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-->


{literal}
<script>
    $('body').on('keyup change', '#productSellAllPrice1', function () {
        var val = $(this).val();
        $('#productSellHalfPrice1').val(val);
        $('#productSellUnitPrice1').val(val);
    });
</script>
{/literal}
