<?php
/* Smarty version 3.1.29, created on 2021-09-05 21:45:43
  from "/home/achahost/public_html/account/modules/addons/ProductDescriptionForInvoicesFree/resources/views/adminarea/settings/index.tpl" */

if ($_smarty_tpl->smarty->ext->_validateCompiled->decodeProperties($_smarty_tpl, array (
  'has_nocache_code' => false,
  'version' => '3.1.29',
  'unifunc' => 'content_61353a87420b85_58299491',
  'file_dependency' => 
  array (
    '1011b38a99bba8bcfaf803befa8a1dc14cda6e3c' => 
    array (
      0 => '/home/achahost/public_html/account/modules/addons/ProductDescriptionForInvoicesFree/resources/views/adminarea/settings/index.tpl',
      1 => 1589012884,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
),false)) {
function content_61353a87420b85_58299491 ($_smarty_tpl) {
?>

<div id='addon-content-preloader' class='preloader loading'>
    <span class='preloader'></span>
</div>

<div class='addon-content'>


    <div class="chooseProductPanel panel-body">
        <table class='table chooseProductPanel' id='productlimitdata'>
            <thead>
                <tr>
                    <th></th>
                    <th>Product Name</th>
                    <th>Description</th>
                </tr>
            </thead>
            <tbody>
                <?php
$_from = $_smarty_tpl->tpl_vars['productList']->value;
if (!is_array($_from) && !is_object($_from)) {
settype($_from, 'array');
}
$__foreach_category_0_saved_item = isset($_smarty_tpl->tpl_vars['category']) ? $_smarty_tpl->tpl_vars['category'] : false;
$_smarty_tpl->tpl_vars['category'] = new Smarty_Variable();
$_smarty_tpl->tpl_vars['category']->_loop = false;
foreach ($_from as $_smarty_tpl->tpl_vars['category']->value) {
$_smarty_tpl->tpl_vars['category']->_loop = true;
$__foreach_category_0_saved_local_item = $_smarty_tpl->tpl_vars['category'];
?>
                    <tr name='cat<?php echo $_smarty_tpl->tpl_vars['category']->value['category_id'];?>
'class="active group_name" style="border: 1px solid #b6b6b6; ">
                        <td ><input type="checkbox" class="test groupSelect" name="<?php echo $_smarty_tpl->tpl_vars['category']->value['id'];?>
"  value="cat<?php echo $_smarty_tpl->tpl_vars['category']->value['category_id'];?>
" ></td>
                        <td style="color:#0f8be6"><strong style="font-size: 15px;"><?php echo $_smarty_tpl->tpl_vars['category']->value['category_name'];?>
</strong></td>
                        <td  style="color:#0f8be6"> </td>
                    </tr>                          
                    <?php
$_from = $_smarty_tpl->tpl_vars['category']->value['products'];
if (!is_array($_from) && !is_object($_from)) {
settype($_from, 'array');
}
$__foreach_prodl_1_saved_item = isset($_smarty_tpl->tpl_vars['prodl']) ? $_smarty_tpl->tpl_vars['prodl'] : false;
$_smarty_tpl->tpl_vars['prodl'] = new Smarty_Variable();
$_smarty_tpl->tpl_vars['prodl']->_loop = false;
foreach ($_from as $_smarty_tpl->tpl_vars['prodl']->value) {
$_smarty_tpl->tpl_vars['prodl']->_loop = true;
$__foreach_prodl_1_saved_local_item = $_smarty_tpl->tpl_vars['prodl'];
?>
                        <tr name='<?php echo $_smarty_tpl->tpl_vars['prodl']->value['name'];?>
' style="border: 1px solid #ddd">
                            <td><input type="checkbox" name="td_productid" class="test cat<?php echo $_smarty_tpl->tpl_vars['category']->value['category_id'];?>
 generalSelect" value="<?php echo $_smarty_tpl->tpl_vars['prodl']->value['id'];?>
"
                                       <?php if ($_smarty_tpl->tpl_vars['prodl']->value['value'] == 1) {?> checked<?php }?>
                                       ></td>
                            <td><input type="hidden" name="td_productname" value="<?php echo $_smarty_tpl->tpl_vars['prodl']->value['name'];?>
"><?php echo $_smarty_tpl->tpl_vars['prodl']->value['name'];?>
</td>
                            <td><input type="hidden" name="td_productdesc" value="<?php echo $_smarty_tpl->tpl_vars['prodl']->value['name'];?>
"><?php echo $_smarty_tpl->tpl_vars['prodl']->value['description'];?>
</textarea>
                            </td>
                        </tr>               

                    <?php
$_smarty_tpl->tpl_vars['prodl'] = $__foreach_prodl_1_saved_local_item;
}
if ($__foreach_prodl_1_saved_item) {
$_smarty_tpl->tpl_vars['prodl'] = $__foreach_prodl_1_saved_item;
}
?>
                <?php
$_smarty_tpl->tpl_vars['category'] = $__foreach_category_0_saved_local_item;
}
if ($__foreach_category_0_saved_item) {
$_smarty_tpl->tpl_vars['category'] = $__foreach_category_0_saved_item;
}
?>
            </tbody>
        </table>
        <div class="pull-right">
            <button class="btn btn-success btn-inverse btnsave bmConfigAcceptSave">Save</button>        
            <input type="hidden" class="bmConfigAcceptSave" id="saveallData">
        </div>
    </div>
</div>


    <?php echo '<script'; ?>
>
        $(document).ready(function () {
            mainSelect();
        });

        if ($('.groupSelect').length) {
            $(".groupSelect").on('click', function () {
                groupName = $(this).val();
                value = $(this).is(':checked');
                $("input:checkbox." + groupName).prop('checked', this.checked);
            }
            );
        }
        function mainSelect() {
            $("input:checkbox.groupSelect").each(function (index) {
                val = $(this).val();
                if ($('.' + val + ':checked').length === $('.' + val).length) {
                    $(this).prop('checked', 'checked');
                } else {
                    $(this).prop('checked', '');

                }

            });
        }

        $(".generalSelect").on('click', function () {
            mainSelect();
        }
        );

        if ($('.bmConfigAcceptSave').length) {
            $(".bmConfigAcceptSave").on('click', function (e) {
                console.log('sss');
                $("#Loader").show();
                e.preventDefault();
                var arr = new Array();
                $('#productlimitdata > tbody > tr').each(function (k, v) {
                    if ($(v).hasClass('group_name') === false) {
                        arr.push({
                            'id': $($(v).find('input[name=td_productid]')).val(),
                            'value': $($(v).find('input[name=td_productid]')).is(':checked'),
                            'description': $($(v).find('textarea[name=td_description]')).val()
                        });
                    }
                });
                console.log(arr);
                $.post("addonmodules.php?module=ProductDescriptionForInvoicesFree&json=json",
                        {
                            "saveProdList": JSON.stringify(arr)
                        },
                        function (r) {
                            $("#Loader").hide();
                            result = JSON.parse(r.data);
                    console.log(result.result);
                            if (result.result == true)
                            {
                                $("#pl_failsafe").modal('hide');
                                $('#MDAlerts').find('[data-prototype=success]').show();
                                $('#MDAlerts').find('.note-success strong').html('Changes have been saved successfully.');
                            } else
                            {
                                $("#pl_failsafe").modal('hide');
                                $('#MDAlerts').find('[data-prototype=error]').show();
                                $('#MDAlerts').find('.note-danger strong').html('Something went wrong');
                                setTimeout(function () {
                                    $('#MDAlerts').find('[data-prototype=error]').fadeOut()
                                }, 2000);
                            }
                        },
                        "json");
            });
        }


    <?php echo '</script'; ?>
>
<?php }
}
