<?php /* Smarty version Smarty-3.1.11, created on 2024-07-16 15:48:58
         compiled from "..\views\default\productCatview\edit.html" */ ?>
<?php /*%%SmartyHeaderCode:121966966c3a8add90-83142972%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'f3809dedd33de1c197e3bd006d879ed573c73e1c' => 
    array (
      0 => '..\\views\\default\\productCatview\\edit.html',
      1 => 1704826751,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '121966966c3a8add90-83142972',
  'function' => 
  array (
  ),
  'variables' => 
  array (
    'productCatparent' => 0,
    'productCatData' => 0,
    'parentid' => 0,
    'categories' => 0,
    'parent' => 0,
    'Programsettingdata' => 0,
    'currency' => 0,
    'catUnitsData' => 0,
    'j' => 0,
    'unitsData' => 0,
    'unit' => 0,
    'proUnit' => 0,
    'countcatUnits' => 0,
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty-3.1.11',
  'unifunc' => 'content_66966c3acdf176_67688004',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_66966c3acdf176_67688004')) {function content_66966c3acdf176_67688004($_smarty_tpl) {?><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="#"><?php echo @PRODUCTS;?>
</a></li>
            <li><a href="productCatController.php?do=show"><?php echo @PRODUCTS_CATEGORIES;?>
</a></li>
            <li class="active"><?php echo @EDIT_MAIN_CATEGORY;?>
</li>
        </ol>
        <div class="panel panel-default panel-m">
            <div class="panel-heading">
                <h3 class="panel-title"><?php echo @EDIT_MAIN_CATEGORY;?>
</h3>
            </div>
            <div class="panel-body"> 
                <form class="nameToBeChecked form-horizontal" role="form" action="productCatController.php?do=update"
                    method="post" enctype="multipart/form-data" id="spform">
                    
                    <div class="form-group">
                        <label for="parent" class="col-lg-2 control-label"><?php echo @MAIN_CATEGORY;?>
</label>
                        <div class="col-lg-4">
                            <input type="hidden" name="parent" id="parent">
                            <input type="hidden" id="oldid" value="<?php echo $_smarty_tpl->tpl_vars['productCatparent']->value->productCatId;?>
">
                            <input type="hidden" id="oldname" value="<?php echo $_smarty_tpl->tpl_vars['productCatparent']->value->productCatName;?>
">

                            <!--                            <select class="select2 wdt100" name="parent" id="parent">
                                                            <option <?php if ($_smarty_tpl->tpl_vars['productCatData']->value->productCatParent==0){?>selected<?php }?> value="0"><?php echo @NO_MAIN_CATEGORY;?>
</option>
                                                            <?php if ($_smarty_tpl->tpl_vars['parentid']->value){?>
                                                            <option value="<?php echo $_smarty_tpl->tpl_vars['productCatparent']->value->productCatId;?>
" selected><?php echo $_smarty_tpl->tpl_vars['productCatparent']->value->productCatName;?>
</option>
                                                            <?php }?>
                                                            <?php  $_smarty_tpl->tpl_vars['parent'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['parent']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['categories']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['parent']->key => $_smarty_tpl->tpl_vars['parent']->value){
$_smarty_tpl->tpl_vars['parent']->_loop = true;
?>
                                                            <option value="<?php echo $_smarty_tpl->tpl_vars['parent']->value->productCatId;?>
" ><?php echo $_smarty_tpl->tpl_vars['parent']->value->productCatName;?>
</option>
                                                              <option value="<?php echo $_smarty_tpl->tpl_vars['parent']->value->productCatId;?>
" <?php if ($_smarty_tpl->tpl_vars['productCatData']->value->productCatParent==$_smarty_tpl->tpl_vars['parent']->value->productCatId){?>selected<?php }?>><?php echo $_smarty_tpl->tpl_vars['parent']->value->productCatName;?>
</option>
                                                            <?php } ?>


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

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

                    <div class="form-group">
                        <label for="productCatName" class="col-lg-2 control-label"><?php echo @CATEGORY_NAME;?>
</label>
                        <div class="col-lg-4"> <span id="sprytextfield1">
                                <input type="text" name="productCatName" id="productCatName"
                                    placeholder="<?php echo @CATEGORY_NAME;?>
" class="form-control"
                                    value="<?php echo $_smarty_tpl->tpl_vars['productCatData']->value->productCatName;?>
"
                                    onblur="checkNameWithId(event, 'productcat', 'productCatName', 'productCatId')" />
                                <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><?php echo @WRONG_MESSAGE;?>
</h4>
                                <p><?php echo @NAME_ALREADY_TAKEN;?>
</p>
                                <div class="clearfix"></div>
                            </div>
                        </div>
                    </div>
                    <!-- =================================================   -->
                    <div class="form-group">
                        <label class="col-lg-2 control-label"><?php echo @IN_MENU;?>
</label>
                        <div class="col-lg-4">
                            <div class="radio-inline">
                                <label>
                                    <input value="0" class="radioR" <?php if ($_smarty_tpl->tpl_vars['productCatData']->value->inMenu==0){?>
                                    checked="checked"<?php }?> name="inMenu" type="radio">

                                    <?php echo @CATEGORY_YES;?>
 </label>
                            </div>
                            <div class="radio-inline">
                                <label>
                                    <input value="1" class="noradioR" <?php if ($_smarty_tpl->tpl_vars['productCatData']->value->inMenu==1){?>
                                    checked="checked"<?php }?> name="inMenu" type="radio">
                                    <?php echo @CATEGORY_NO;?>
 </label>
                            </div>

                        </div>
                    </div>

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

                    <div class="form-group">
                        <label for="discounttype" class="col-lg-2 control-label"><?php echo @DISCOUNT_TYPE;?>
</label>
                        <div class="col-lg-4">
                            <select class="select2 wdt100" name="discounttype" id="discounttype"
                                onchange="chechdata();">
                                <option <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['productCatData']->value->discounttype;?>
<?php $_tmp1=ob_get_clean();?><?php if ($_tmp1==-1){?> selected="selected" <?php }?>
                                    value="-1"><?php echo @CHOOSE_TYPE;?>
 </option>
                                <option <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['productCatData']->value->discounttype;?>
<?php $_tmp2=ob_get_clean();?><?php if ($_tmp2==0){?> selected="selected" <?php }?>
                                    value="0"><?php echo @CATEGORY_DIRECT;?>
 </option>
                                <option <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['productCatData']->value->discounttype;?>
<?php $_tmp3=ob_get_clean();?><?php if ($_tmp3==1){?> selected="selected" <?php }?>
                                    value="1"><?php echo @CATEGORY_RATE;?>
</option>
                            </select>
                        </div>
                    </div>

                    <!-- =================================================   -->
                    <div class="form-group" <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->isOpticProg==1){?>style="display:none;"<?php }?>>
                        <label for="discounttype"
                            class="col-lg-2 control-label"><?php echo @OPTICAL_SERVICES;?>
</label>
                        <div class="col-lg-4">
                            <select class="select2 wdt100" name="opticServices[]" id="opticServices" multiple>
                                <option value="Single vision" <?php if (strpos($_smarty_tpl->tpl_vars['productCatData']->value->opticServices,'Single
                                    vision')!=false){?> selected<?php }?> >Single vision</option>
                                <option value="polycarbonate" <?php if (strpos($_smarty_tpl->tpl_vars['productCatData']->value->opticServices,'polycarbonate')!=false){?> selected<?php }?>>polycarbonate</option>
                                <option value="Hi index" <?php if (strpos($_smarty_tpl->tpl_vars['productCatData']->value->opticServices,'Hi index')!=false){?> selected<?php }?>>Hi index</option>
                                <option value="Contact lenses Plano" <?php if (strpos($_smarty_tpl->tpl_vars['productCatData']->value->opticServices,'Contact
                                    lenses Plano')!=false){?> selected<?php }?>>Contact lenses Plano</option>
                                <option value="Contact lenses power" <?php if (strpos($_smarty_tpl->tpl_vars['productCatData']->value->opticServices,'Contact
                                    lenses power')!=false){?> selected<?php }?>>Contact lenses power</option>
                                <option value="Sunglasses" <?php if (strpos($_smarty_tpl->tpl_vars['productCatData']->value->opticServices,'Sunglasses')!=false){?> selected<?php }?>>Sunglasses</option>
                                <option value="Medical frame" <?php if (strpos($_smarty_tpl->tpl_vars['productCatData']->value->opticServices,'Medical
                                    frame')!=false){?> selected<?php }?>>Medical frame</option>
                                <option value="Reading" <?php if (strpos($_smarty_tpl->tpl_vars['productCatData']->value->opticServices,'Reading')!=false){?>
                                    selected<?php }?>>Reading</option>
                                <option value="Accessories" <?php if (strpos($_smarty_tpl->tpl_vars['productCatData']->value->opticServices,'Accessories')!=false){?> selected<?php }?>>Accessories</option>
                                <option value="Bifocal" <?php if (strpos($_smarty_tpl->tpl_vars['productCatData']->value->opticServices,'Bifocal')!=false){?>
                                    selected<?php }?>>Bifocal</option>
                                <option value="Multifocal/Progressive" <?php if (strpos($_smarty_tpl->tpl_vars['productCatData']->value->opticServices,'Multifocal/Progressive')!=false){?> selected<?php }?>>Multifocal/Progressive</option>
                            </select>
                        </div>
                    </div>
                    <!--==============================-->

                    <div class="form-group">
                        <label for="email" class="col-lg-2 control-label"><?php echo @CATEGORY_IMAGE;?>
</label>
                        <div class="col-lg-4"> <img src="../views/default/images/cat_image/<?php echo $_smarty_tpl->tpl_vars['productCatData']->value->logo;?>
"
                                alt="" width="122" height="75" />
                            <input type="file" name="logo" id="logo" class="form-control"
                                placeholder="<?php echo @CATEGORY_IMAGE;?>
" accept="image/*" />
                            <input type="hidden" name="oldlogo" id="oldlogo" value="<?php echo $_smarty_tpl->tpl_vars['productCatData']->value->logo;?>
" />
                        </div>
                    </div>

                    <input type="hidden" id="thecurrency" value="<?php echo $_smarty_tpl->tpl_vars['currency']->value;?>
" />
                    <!-- =================================================   -->
                    <div class="form-group">
                        <label for="selldiscount" class="col-lg-2 control-label"><?php echo @SALE_DISCOUNT;?>
</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="text" name="selldiscount" id="selldiscount"
                                    value="<?php echo $_smarty_tpl->tpl_vars['productCatData']->value->selldiscount;?>
" onKeyUp="chechdata();"
                                    class="form-control numberinput" placeholder="<?php echo @DISCOUNT_VALUE;?>
" />
                                <span class="input-group-addon"> <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['productCatData']->value->discounttype;?>
<?php $_tmp4=ob_get_clean();?><?php if ($_tmp4==-1){?>
                                    <?php echo $_smarty_tpl->tpl_vars['currency']->value;?>

                                    <?php }else{?><?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['productCatData']->value->discounttype;?>
<?php $_tmp5=ob_get_clean();?><?php if ($_tmp5==0){?>
                                    <?php echo $_smarty_tpl->tpl_vars['currency']->value;?>

                                    <?php }else{?><?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['productCatData']->value->discounttype;?>
<?php $_tmp6=ob_get_clean();?><?php if ($_tmp6==1){?>
                                    %
                                    <?php }}}?> </span>
                            </div>
                        </div>
                    </div>

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

                    <div class="form-group">
                        <label for="buydiscount" class="col-lg-2 control-label"><?php echo @BUY_DISCOUNT;?>
</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="text" name="buydiscount" id="buydiscount"
                                    value="<?php echo $_smarty_tpl->tpl_vars['productCatData']->value->buydiscount;?>
" onKeyUp="chechdata();"
                                    class="form-control numberinput" placeholder="<?php echo @DISCOUNT_VALUE;?>
" />
                                <span class="input-group-addon"> <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['productCatData']->value->discounttype;?>
<?php $_tmp7=ob_get_clean();?><?php if ($_tmp7==-1){?>
                                    <?php echo $_smarty_tpl->tpl_vars['currency']->value;?>

                                    <?php }else{?><?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['productCatData']->value->discounttype;?>
<?php $_tmp8=ob_get_clean();?><?php if ($_tmp8==0){?>
                                    <?php echo $_smarty_tpl->tpl_vars['currency']->value;?>

                                    <?php }else{?><?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['productCatData']->value->discounttype;?>
<?php $_tmp9=ob_get_clean();?><?php if ($_tmp9==1){?>
                                    %
                                    <?php }}}?> </span>
                            </div>
                        </div>
                    </div>

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

                    <div class="form-group">
                        <label for="buytotal" class="col-lg-2 control-label"><?php echo @ACTUAL_BUY_PRICE;?>
</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="buypricereal" id="buypricereal"
                                    value="<?php echo $_smarty_tpl->tpl_vars['productCatData']->value->buypricereal;?>
" value="0" style="width: 303px;"
                                    class="form-control numberinput" placeholder="<?php echo @ACTUAL_BUY_PRICE;?>
" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    <!-- =================================================   -->
                    <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showpriceall==1){?>
                    <div class="form-group">
                        <label for="buytotal" class="col-lg-2 control-label"><?php echo @WHOLESALE_PRICE;?>
</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="buytotal" id="buytotal" value="<?php echo $_smarty_tpl->tpl_vars['productCatData']->value->buytotal;?>
"
                                    value="0" style="width: 303px;" class="form-control numberinput"
                                    placeholder="<?php echo @WHOLESALE_PRICE;?>
 " />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    <?php }?>
                    <!-- =================================================   -->
                    <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showpricehalf==1){?>
                    <div class="form-group">
                        <label for="buyhalf" class="col-lg-2 control-label"><?php echo @HALF_WHOLESALE_PRICE;?>
</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="buyhalf" id="buyhalf" value="<?php echo $_smarty_tpl->tpl_vars['productCatData']->value->buyhalf;?>
"
                                    value="0" style="width: 303px;" class="form-control numberinput"
                                    placeholder="<?php echo @HALF_WHOLESALE_PRICE;?>
" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    <?php }?>
                    <!-- =================================================   -->
                    <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showpriceunit==1){?>
                    <div class="form-group">
                        <label for="buypart" class="col-lg-2 control-label"><?php echo @RETAIL_PRICE;?>
</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="buypart" id="buypart" value="<?php echo $_smarty_tpl->tpl_vars['productCatData']->value->buypart;?>
"
                                    value="0" style="width: 303px;" class="form-control numberinput"
                                    placeholder="<?php echo @RETAIL_PRICE;?>
" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    <?php }?>
                    <!-- =================================================   -->
                    <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showprice4==1){?>
                    <div class="form-group">
                        <label for="price4" class="col-lg-2 control-label"><?php echo @PRICE4;?>
</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="price4" id="price4" style="width: 303px;"
                                    class="form-control main_input numberinput" placeholder="<?php echo @PRICE4;?>
"
                                    value="<?php echo $_smarty_tpl->tpl_vars['productCatData']->value->price4;?>
" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    <?php }?>
                    <!-- =================================================   -->
                    <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showprice5==1){?>
                    <div class="form-group">
                        <label for="price5" class="col-lg-2 control-label"><?php echo @PRICE5;?>
</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="price5" id="price5" style="width: 303px;"
                                    class="form-control main_input numberinput" placeholder="<?php echo @PRICE5;?>
"
                                    value="<?php echo $_smarty_tpl->tpl_vars['productCatData']->value->price5;?>
" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    <?php }?>
                    <!-- =================================================   -->
                    <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showprice6==1){?>
                    <div class="form-group">
                        <label for="price6" class="col-lg-2 control-label"><?php echo @PRICE6;?>
</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="price6" id="price6" style="width: 303px;"
                                    class="form-control main_input numberinput" placeholder="<?php echo @PRICE6;?>
"
                                    value="<?php echo $_smarty_tpl->tpl_vars['productCatData']->value->price6;?>
" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    <?php }?>
                    <!-- =================================================   -->
                    <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showprice7==1){?>
                    <div class="form-group">
                        <label for="price7" class="col-lg-2 control-label"><?php echo @PRICE7;?>
</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="price7" id="price7" style="width: 303px;"
                                    class="form-control main_input numberinput" placeholder="<?php echo @PRICE7;?>
"
                                    value="<?php echo $_smarty_tpl->tpl_vars['productCatData']->value->price7;?>
" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    <?php }?>
                    <!-- =================================================   -->
                    <?php if ($_smarty_tpl->tpl_vars['Programsettingdata']->value->showprice8==1){?>
                    <div class="form-group">
                        <label for="price8" class="col-lg-2 control-label"><?php echo @PRICE8;?>
</label>
                        <div class="col-lg-4">
                            <div class="input-group">
                                <input type="number" name="price8" id="price8" style="width: 303px;"
                                    class="form-control main_input numberinput" placeholder="<?php echo @PRICE8;?>
"
                                    value="<?php echo $_smarty_tpl->tpl_vars['productCatData']->value->price8;?>
" />
                                <span class="new_prices">%</span>
                            </div>
                        </div>
                    </div>
                    <?php }?>
                    <!-- =================================================   -->
                    <div class="form-group">
                        <label class="col-lg-2 control-label"><?php echo @NEGATIVE_SALES_STOP;?>
</label>
                        <div class="col-lg-4">
                            <div class="radio-inline">
                                <label>
                                    <input value="0" class="radioR" <?php if ($_smarty_tpl->tpl_vars['productCatData']->value->stopNegativeSale==0){?>
                                    checked="checked"<?php }?> name="stopNegativeSale" type="radio">

                                    <?php echo @CATEGORY_NO;?>
 </label>
                            </div>
                            <div class="radio-inline">
                                <label>
                                    <input value="1" class="noradioR" <?php if ($_smarty_tpl->tpl_vars['productCatData']->value->stopNegativeSale==1){?>
                                    checked="checked"<?php }?> name="stopNegativeSale" type="radio">
                                    <?php echo @CATEGORY_YES;?>
 </label>
                            </div>

                        </div>
                    </div>

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

                    <div class="form-group">
                        <label for="productCatDescription"
                            class="col-lg-2 control-label"><?php echo @CATEGORY_COMMIT;?>
</label>
                        <div class="col-lg-4">
                            <textarea class="form-control" rows="3"
                                name="productCatDescription"><?php echo $_smarty_tpl->tpl_vars['productCatData']->value->productCatDescription;?>
</textarea>
                        </div>
                    </div>

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

                    <input name="productCatId" id="productCatId" type="hidden"
                        value="<?php echo $_smarty_tpl->tpl_vars['productCatData']->value->productCatId;?>
" />
                    <input name="conditions" id="conditions" type="hidden" value="<?php echo $_smarty_tpl->tpl_vars['productCatData']->value->conditions;?>
" />

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

                    <div id="cat_addUnitsDiv">
                        <div class="table-responsive">
                            <table id="cat_unitsTable" class="table table-black">
                                <?php $_smarty_tpl->tpl_vars['j'] = new Smarty_variable(1, null, 0);?>
                                <?php  $_smarty_tpl->tpl_vars['proUnit'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['proUnit']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['catUnitsData']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['proUnit']->key => $_smarty_tpl->tpl_vars['proUnit']->value){
$_smarty_tpl->tpl_vars['proUnit']->_loop = true;
?>
                                <tr>
                                    <td>
                                        <div class="form-group">
                                            <label class="col-lg-4 control-label"><?php echo @UNIT_NAME;?>
</label>
                                            <div class="col-lg-8">
                                                <select name="productcatunit_disabled<?php echo $_smarty_tpl->tpl_vars['j']->value;?>
"
                                                    id="productcatunit_disabled<?php echo $_smarty_tpl->tpl_vars['j']->value;?>
" disabled="disabled"
                                                    data-placeholder="<?php echo @CHOOSE;?>
"
                                                    class="select2 wdt100 aw_m1 chosenproduct" tabindex="12">
                                                    <option value="-1"><?php echo @CHOOSE_UNIT_NAME;?>
</option>

                                                    <?php  $_smarty_tpl->tpl_vars['unit'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['unit']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['unitsData']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['unit']->key => $_smarty_tpl->tpl_vars['unit']->value){
$_smarty_tpl->tpl_vars['unit']->_loop = true;
?>

                                                    <option value="<?php echo $_smarty_tpl->tpl_vars['unit']->value->unitId;?>
" <?php if ($_smarty_tpl->tpl_vars['proUnit']->value->unitid==$_smarty_tpl->tpl_vars['unit']->value->unitId){?>selected<?php }?>><?php echo $_smarty_tpl->tpl_vars['unit']->value->unitName;?>
</option>

                                                    <?php } ?>

                                                </select>
                                                <input name="productcatunit<?php echo $_smarty_tpl->tpl_vars['j']->value;?>
" id="productcatunit<?php echo $_smarty_tpl->tpl_vars['j']->value;?>
" type="hidden"
                                                    value="<?php echo $_smarty_tpl->tpl_vars['proUnit']->value->unitid;?>
" />

                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="form-group">
                                            <label class="col-lg-4 control-label"><?php echo @NUMBER_UNITS;?>
</label>
                                            <div class="col-lg-8">
                                                <input name="cat_productnumber<?php echo $_smarty_tpl->tpl_vars['j']->value;?>
" id="cat_productnumber<?php echo $_smarty_tpl->tpl_vars['j']->value;?>
"
                                                    type="text" class="form-control numberinput"
                                                    value="<?php echo $_smarty_tpl->tpl_vars['proUnit']->value->productnumber;?>
" />
                                            </div>
                                        </div>
                                    </td>
                                    <td><a id="cat_remove<?php echo $_smarty_tpl->tpl_vars['j']->value;?>
" onClick="cat_removeUnits(<?php echo $_smarty_tpl->tpl_vars['j']->value;?>
);"
                                            class="cat_removeUnits">X</a></td>
                                </tr>
                                <?php $_smarty_tpl->_capture_stack[0][] = array('default', 'j', null); ob_start(); ?><?php echo $_smarty_tpl->tpl_vars['j']->value+1;?>
<?php list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
if (!empty($_capture_buffer)) {
 if (isset($_capture_assign)) $_smarty_tpl->assign($_capture_assign, ob_get_contents());
 if (isset( $_capture_append)) $_smarty_tpl->append( $_capture_append, ob_get_contents());
 Smarty::$_smarty_vars['capture'][$_capture_buffer]=ob_get_clean();
} else $_smarty_tpl->capture_error();?>
                                <?php } ?>
                            </table>
                        </div>
                        <!--end cat_unitsTable-->
                    </div>
                    <input class="cat_addUnits btn btn-warning" onClick="cat_addUnits();" type="button"
                        value="<?php echo @ADD_UNITS_MEASURE;?>
" />
                    <input name="cat_unitsItr" id="cat_unitsItr" type="hidden" value="<?php echo $_smarty_tpl->tpl_vars['countcatUnits']->value;?>
" />

                    <!-------------------------------- 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"><?php echo @SAVE_IT;?>
</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<div id="productUnitsDiv" style="display:none;">
    <option value="-1"><?php echo @CHOOSE_UNIT_NAME;?>
</option>
    <?php  $_smarty_tpl->tpl_vars['unit'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['unit']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['unitsData']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['unit']->key => $_smarty_tpl->tpl_vars['unit']->value){
$_smarty_tpl->tpl_vars['unit']->_loop = true;
?>
    <option value="<?php echo $_smarty_tpl->tpl_vars['unit']->value->unitId;?>
"><?php echo $_smarty_tpl->tpl_vars['unit']->value->unitName;?>
</option>
    <?php } ?>
</div>

<script type="text/javascript">
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
    $('#spbutton').live('click', function (e) {
        if (!$('#spbutton').hasClass("processing")) {
            $('#spbutton').addClass("processing");
            $('#productCatName').trigger('blur');
            setTimeout(function () {
                var myForm = document.getElementById("spform");
                var SS = Spry.Widget.Form.validate(myForm);
                if (SS == true) {
                    myForm.submit();
                }
                else {
                    $('#spbutton').removeClass("processing");
                }
            }, 500);
        }
    });

    $(function () {
        $('#parent').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
                        withoutId:$('#productCatId').val(),
                    };
                },
                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);
            }
        });
        $('#parent').select2('data', { id: $('#oldid').val(), text: $('#oldname').val() })
    });
</script>
<?php }} ?>