<style>
    .new_prices {
        border-right: 0;
        border-bottom-right-radius: 0;
        border-top-right-radius: 0;
        font-weight: bold;
        padding: 4px 12px;
        font-size: 14px;
        font-weight: bold;
        line-height: 1;
        text-align: center;
        background-color: #eee;
        border: 1px solid #ccc;
        border-radius: 4px;
        width: 66px;
        white-space: nowrap;
        vertical-align: middle;
        display: table-cell;
        border-radius: 0px;
        border-bottom-left-radius: 4px;
        border-top-left-radius: 4px;
    }
</style>
<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">{$smarty.const.PRODUCTS}</a></li>
            <li><a href="productCatController.php?do=show">{$smarty.const.PRODUCTS_CATEGORIES}</a></li>
            <li class="active">{$smarty.const.ADD_MAIN_CATEGORY}</li>
        </ol>
        <div class="panel panel-default panel-m">
            <div class="panel-heading">
                <h3 class="panel-title">{$smarty.const.ADD_MAIN_CATEGORY}</h3>
            </div>
            <div class="panel-body"> {literal}
                <form class="nameToBeChecked form-horizontal" role="form" action="productCatController.php?do=add2"
                    method="post" enctype="multipart/form-data" id="spform">
                    {/literal}
                    <!--                    <div class="form-group">
                                            <label for="parent" class="col-lg-2 control-label">التصنيف الرئيسى</label>
                                            <div class="col-lg-4">
                                                <select class="select2 wdt100" name="parent" id="parent">
                                                    <option value="0">لا يوجد تصنيف رئيسي</option>


                                                    {foreach $allParents as $parent}


                                                    <option value="{$parent->productCatId}">{$parent->productCatName}</option>


                                                    {/foreach}


                                                </select>
                                            </div>
                                        </div>-->

                    <div class="form-group">
                        <label class="col-lg-2 control-label">{$smarty.const.PRODUCT_CATEGORY}</label>
                        <div class="col-lg-4">
                            <input type="hidden" data-level="0" name="parent" id="productCatId0">

                            <!-- <select class="select2 wdt300 productCat" data-level="0"  name="parent" id="productCatId0" >
                                                            <option value="-1">{$smarty.const.CHOOSE_CATEGORY}</option>
                                                            {foreach $categories as $data}
                                                            <option value="{$data->productCatId}">{$data->productCatName}</option>
                                                            {/foreach}
                                                        </select>-->
                        </div>
                        <input type="hidden" id="level" name="level" value="0">
                    </div>
                    <input type="hidden" id="thecurrency" value="{$currency}" />
                    <!-- =================================================   -->

                    <div class="form-group">
                        <label for="productCatName" class="col-lg-2 control-label">{$smarty.const.CATEGORY_NAME}</label>
                        <div class="col-lg-4"> <span id="sprytextfield1">
                                <input type="text" name="productCatName" id="productCatName"
                                    onkeyup="checkName(event, 'productcat', 'productCatName')"
                                    placeholder="{$smarty.const.CATEGORY_NAME}" class="form-control" />
                                <span class="textfieldRequiredMsg">*</span></span>
                            <div id="nameError" class="alert alert-block alert-danger fade in" style="display:none">
                                <button type="button" class="close pull-left" data-dismiss="alert"
                                    aria-hidden="true">&times;</button>
                                <h4>{$smarty.const.WRONG_MESSAGE}</h4>
                                <p>{$smarty.const.NAME_ALREADY_TAKEN}</p>
                                <div class="clearfix"></div>
                            </div>
                        </div>
                    </div>
                    <!-- =================================================   -->
                    <div class="form-group">
                        <label class="col-lg-2 control-label">{$smarty.const.IN_MENU}</label>
                        <div class="col-lg-4">
                            <div class="radio-inline">
                                <label>
                                    <input value="0" class="radioR" checked="checked" name="inMenu" type="radio">

                                    {$smarty.const.CATEGORY_YES} </label>
                            </div>
                            <div class="radio-inline">
                                <label>
                                    <input value="1" class="noradioR" name="inMenu" type="radio">
                                    {$smarty.const.CATEGORY_NO} </label>
                            </div>

                        </div>
                    </div>

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

                    <div class="form-group">
                        <label for="discounttype" class="col-lg-2 control-label">{$smarty.const.DISCOUNT_TYPE}</label>
                        <div class="col-lg-4">
                            <select class="select2 wdt100" name="discounttype" id="discounttype"
                                onchange="chechdata();">
                                <option value="-1"> {$smarty.const.CHOOSE_TYPE}</option>
                                <option value="0"> {$smarty.const.CATEGORY_DIRECT}</option>
                                <option value="1">{$smarty.const.CATEGORY_RATE}</option>
                            </select>
                        </div>
                    </div>

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

                    <div class="form-group" {if $Programsettingdata->isOpticProg == 1}style="display:none;"{/if}>
                        <label for="discounttype"
                            class="col-lg-2 control-label">{$smarty.const.OPTICAL_SERVICES}</label>
                        <div class="col-lg-4">
                            <select class="select2 wdt100" name="opticServices[]" id="opticServices" multiple>
                                <option value="Single vision">Single vision</option>
                                <option value="polycarbonate">polycarbonate</option>
                                <option value="Hi index">Hi index</option>
                                <option value="Contact lenses Plano">Contact lenses Plano</option>
                                <option value="Contact lenses power">Contact lenses power</option>
                                <option value="Sunglasses">Sunglasses</option>
                                <option value="Medical frame">Medical frame</option>
                                <option value="Reading">Reading</option>
                                <option value="Accessories">Accessories</option>
                                <option value="Bifocal">Bifocal</option>
                                <option value="Multifocal/Progressive">Multifocal/Progressive</option>
                            </select>
                        </div>
                    </div>
                    <!--==============================-->

                    <div class="form-group">
                        <label for="email" class="col-lg-2 control-label">{$smarty.const.CATEGORY_IMAGE}</label>
                        <div class="col-lg-4">
                            <input type="file" name="logo" id="logo" class="form-control"
                                placeholder="{$smarty.const.CATEGORY_LOGO}" accept="image/*" />
                        </div>
                    </div>

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

                    <div class="form-group">
                        <label for="selldiscount" class="col-lg-2 control-label">{$smarty.const.SALE_DISCOUNT}</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="selldiscount" id="selldiscount" value="0"
                                    onKeyUp="chechdata();" class="form-control numberinput"
                                    placeholder="{$smarty.const.DISCOUNT_VALUE}" />
                                <span class="input-group-addon">{$currency}</span>
                            </div>
                        </div>
                    </div>

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

                    <div class="form-group">
                        <label for="buydiscount" class="col-lg-2 control-label">{$smarty.const.BUY_DISCOUNT}</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="buydiscount" id="buydiscount" value="0"
                                    onKeyUp="chechdata();" class="form-control numberinput"
                                    placeholder="{$smarty.const.DISCOUNT_VALUE}" />
                                <span class="input-group-addon">{$currency}</span>
                            </div>
                        </div>
                    </div>



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

                    <div class="form-group">
                        <label for="buytotal" class="col-lg-2 control-label">{$smarty.const.ACTUAL_BUY_PRICE}</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="buypricereal" id="buypricereal" value="0"
                                    style="width: 303px;" class="form-control numberinput"
                                    placeholder="{$smarty.const.ACTUAL_BUY_PRICE}" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>

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

                    <!-- =================================================   -->
                    {if $Programsettingdata->showpriceall == 1}
                    <div class="form-group">
                        <label for="buytotal" class="col-lg-2 control-label">{$smarty.const.WHOLESALE_PRICE}</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="buytotal" id="buytotal" value="0" style="width: 303px;"
                                    class="form-control main_input numberinput"
                                    placeholder="{$smarty.const.WHOLESALE_PRICE}" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    {/if}
                    <!-- =================================================   -->
                    {if $Programsettingdata->showpricehalf == 1}
                    <div class="form-group">
                        <label for="buyhalf" class="col-lg-2 control-label">{$smarty.const.HALF_WHOLESALE_PRICE}</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="buyhalf" id="buyhalf" value="0" style="width: 303px;"
                                    class="form-control main_input numberinput"
                                    placeholder="{$smarty.const.HALF_WHOLESALE_PRICE}" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    {/if}
                    <!-- =================================================   -->
                    {if $Programsettingdata->showpriceunit == 1}
                    <div class="form-group">
                        <label for="buypart" class="col-lg-2 control-label">{$smarty.const.RETAIL_PRICE}</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="buypart" id="buypart" value="0" style="width: 303px;"
                                    class="form-control main_input numberinput"
                                    placeholder="{$smarty.const.RETAIL_PRICE}" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    {/if}
                    <!-- =================================================   -->
                    {if $Programsettingdata->showprice4 == 1}
                    <div class="form-group">
                        <label for="buypart" class="col-lg-2 control-label">{$smarty.const.PRICE4}</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="price4" id="price4" value="0" style="width: 303px;"
                                    class="form-control main_input numberinput" placeholder="{$smarty.const.PRICE4}" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    {/if}
                    <!-- =================================================   -->
                    {if $Programsettingdata->showprice5 == 1}
                    <div class="form-group">
                        <label for="buypart" class="col-lg-2 control-label">{$smarty.const.PRICE5}</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="price5" id="price5" value="0" style="width: 303px;"
                                    class="form-control main_input numberinput" placeholder="{$smarty.const.PRICE5}" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    {/if}
                    <!-- =================================================   -->
                    {if $Programsettingdata->showprice6 == 1}
                    <div class="form-group">
                        <label for="buypart" class="col-lg-2 control-label">{$smarty.const.PRICE6}</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="price6" id="price6" value="0" style="width: 303px;"
                                    class="form-control main_input numberinput" placeholder="{$smarty.const.PRICE6}" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    {/if}
                    <!-- =================================================   -->
                    {if $Programsettingdata->showprice7 == 1}
                    <div class="form-group">
                        <label for="buypart" class="col-lg-2 control-label">{$smarty.const.PRICE7}</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="price7" id="price7" value="0" style="width: 303px;"
                                    class="form-control main_input numberinput" placeholder="{$smarty.const.PRICE7}" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    {/if}
                    <!-- =================================================   -->
                    {if $Programsettingdata->showprice8 == 1}
                    <div class="form-group">
                        <label for="buypart" class="col-lg-2 control-label">{$smarty.const.PRICE8}</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="price8" id="price8" value="0" style="width: 303px;"
                                    class="form-control main_input numberinput" placeholder="{$smarty.const.PRICE8}" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    {/if}
                    <!-- =================================================   -->
                    {if $Programsettingdata->showprice9 == 1}
                    <div class="form-group">
                        <label for="buypart" class="col-lg-2 control-label">{$smarty.const.PRICE9}</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="price9" id="price9" value="0" style="width: 303px;"
                                    class="form-control main_input numberinput" placeholder="{$smarty.const.PRICE9}" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    {/if}
                    <!-- =================================================   -->
                    {if $Programsettingdata->showprice10 == 1}
                    <div class="form-group">
                        <label for="buypart" class="col-lg-2 control-label">{$smarty.const.PRICE10}</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="price10" id="price10" value="0" style="width: 303px;"
                                    class="form-control main_input numberinput" placeholder="{$smarty.const.PRICE10}" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    {/if}
                    <!-- =================================================   -->
                    {if $Programsettingdata->showprice11 == 1}
                    <div class="form-group">
                        <label for="buypart" class="col-lg-2 control-label">{$smarty.const.PRICE11}</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="price11" id="price11" value="0" style="width: 303px;"
                                    class="form-control main_input numberinput" placeholder="{$smarty.const.PRICE11}" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    {/if}
                    <!-- =================================================   -->
                    {if $Programsettingdata->showprice12 == 1}
                    <div class="form-group">
                        <label for="buypart" class="col-lg-2 control-label">{$smarty.const.PRICE12}</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="price12" id="price12" value="0" style="width: 303px;"
                                    class="form-control main_input numberinput" placeholder="{$smarty.const.PRICE12}" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    {/if}
                    <!-- =================================================   -->
                    {if $Programsettingdata->showprice13 == 1}
                    <div class="form-group">
                        <label for="buypart" class="col-lg-2 control-label">{$smarty.const.PRICE13}</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="price13" id="price13" value="0" style="width: 303px;"
                                    class="form-control main_input numberinput" placeholder="{$smarty.const.PRICE13}" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    {/if}
                    <!-- =================================================   -->
                    <div class="form-group">
                        <label class="col-lg-2 control-label">{$smarty.const.NEGATIVE_SALES_STOP}</label>
                        <div class="col-lg-4">
                            <div class="radio-inline">
                                <label>
                                    <input value="0" class="radioR" checked="checked" name="stopNegativeSale"
                                        type="radio">

                                    {$smarty.const.CATEGORY_NO} </label>
                            </div>
                            <div class="radio-inline">
                                <label>
                                    <input value="1" class="noradioR" name="stopNegativeSale" type="radio">
                                    {$smarty.const.CATEGORY_YES} </label>
                            </div>

                        </div>
                    </div>
                    <!-- =================================================   -->

                    <div class="form-group">
                        <label for="productCatDescription"
                            class="col-lg-2 control-label">{$smarty.const.CATEGORY_COMMIT}</label>
                        <div class="col-lg-4">
                            <textarea class="form-control" rows="3" name="productCatDescription"></textarea>
                        </div>
                    </div>

                    <!-- =================================================   -->
                    <!--------------------------------  adding units   ----------------------------->

                    <div id="cat_addUnitsDiv">
                        <div class="table-responsive">
                            <table id="cat_unitsTable" class="table table-black">
                                <tr>
                                    <td>
                                        <div class="form-group">
                                            <label class="col-lg-4 control-label">{$smarty.const.UNIT_NAME}</label>
                                            <div class="col-lg-8">
                                                <select name="productcatunit1" id="productcatunit1"
                                                    data-placeholder="{$smarty.const.CHOOSE}"
                                                    class="select2 wdt100 chosenproduct">
                                                    <option value="-1">{$smarty.const.CHOOSE_UNIT_NAME}</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">{$smarty.const.NUMBER_UNITS}</label>
                                            <div class="col-lg-8">
                                                <input name="cat_productnumber1" id="cat_productnumber1" type="text"
                                                    class="form-control numberinput" />
                                            </div>
                                        </div>
                                    </td>
                                    <td><a id="cat_remove1" onClick="cat_removeUnits(1);" class="cat_removeUnits">X</a>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <!--end cat_unitsTable-->
                    </div>
                    <input class="cat_addUnits btn btn-warning" onClick="cat_addUnits();" type="button"
                        value="{$smarty.const.ADD_UNITS_MEASURE}" />
                    <input name="cat_unitsItr" id="cat_unitsItr" type="hidden" value="1" />

                    <!-------------------------------- end adding units   -------------------------->

                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button type="button" class="btn btn-primary pull-left"
                                id="spbutton">{$smarty.const.SAVE_IT}</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<div id="productUnitsDiv" style="display:none;">
    <option value="-1">{$smarty.const.CHOOSE_UNIT_NAME}</option>
    {foreach $unitsData as $unit}
    <option value="{$unit->unitId}">{$unit->unitName}</option>
    {/foreach}
</div>
{literal}
<script type="text/javascript">
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
    $('#spbutton').live('click', function (e) {
        if (!$('#spbutton').hasClass("processing")) {
            $('#spbutton').addClass("processing");
            var myForm = document.getElementById("spform");
            var SS = Spry.Widget.Form.validate(myForm);
            if (SS == true) {
                myForm.submit();
            } else {
                $('#spbutton').removeClass("processing");
            }
        }
    });

    $(function () {
        $('#productCatId0').select2({
            placeholder: "اختر تصنيف ",
            minimumInputLength: 0,
            //  minimumInputLength: 3,
            multiple: false,
            quietMillis: 100,
            ajax: {
                url: "productControllerAjax.php?do=getallcats",
                dataType: 'json',
                data: function (term, page) {
                    //  alert(term);
                    return {
                        term: term, //search term
                        page_limit: 30, // page size
                    };
                },
                results: function (data) {
                    // alert(term);
                    return { results: data };
                }
            },
            formatResult: function (data) {
                return data.text;
            },
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                var data = { id: item[0], text: item[1] };
                callback(data);
            }
        });
    });
</script>
{/literal}