<?php
/* Smarty version 5.4.2, created on 2024-11-20 21:02:00
  from 'file:../default/transactions_expense.tpl' */

/* @var \Smarty\Template $_smarty_tpl */
if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array (
  'version' => '5.4.2',
  'unifunc' => 'content_673e9498154e32_13631927',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '2f0d12bee5bdf24450cf32d59956787d60a379ad' => 
    array (
      0 => '../default/transactions_expense.tpl',
      1 => 1730635718,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
))) {
function content_673e9498154e32_13631927 (\Smarty\Template $_smarty_tpl) {
$_smarty_current_dir = '/Users/razib/Herd/suite/ui/theme/default';
$_smarty_tpl->getInheritance()->init($_smarty_tpl, true);
?>



<?php 
$_smarty_tpl->getInheritance()->instanceBlock($_smarty_tpl, 'Block_1896799764673e94981265d2_67328296', "content");
?>



<?php 
$_smarty_tpl->getInheritance()->instanceBlock($_smarty_tpl, 'Block_1707527302673e949814fb45_63942794', "script");
?>

<?php $_smarty_tpl->getInheritance()->endChild($_smarty_tpl, ((string)$_smarty_tpl->getValue('layouts_admin')), $_smarty_current_dir);
}
/* {block "content"} */
class Block_1896799764673e94981265d2_67328296 extends \Smarty\Runtime\Block
{
public function callBlock(\Smarty\Template $_smarty_tpl) {
$_smarty_current_dir = '/Users/razib/Herd/suite/ui/theme/default';
?>

    <div class="row">
        <div class="col-md-4">
            <div class="panel">
                <div class="panel-hdr">
                    <h2><?php echo $_smarty_tpl->getValue('_L')['Add Expense'];?>
</h2>

                </div>

                <div class="panel-container">
                    <div class="panel-content" id="ibox_form">
                        <div class="alert alert-danger" id="emsg" style="display: none;">
                            <span id="emsgbody"></span>
                        </div>
                        <form class="form-horizontal" method="post" id="tform" role="form">
                            <div class="mb-3">
                                <label for="account"><span class="h6"><?php echo $_smarty_tpl->getValue('_L')['Account'];?>
</span></label>
                                <select id="account" name="account" class="form-control">
                                    <option value=""><?php echo $_smarty_tpl->getValue('_L')['Choose an Account'];?>
</option>
                                    <?php
$_from = $_smarty_tpl->getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('d'), 'ds');
$foreach0DoElse = true;
foreach ($_from ?? [] as $_smarty_tpl->getVariable('ds')->value) {
$foreach0DoElse = false;
?>
                                        <option value="<?php echo $_smarty_tpl->getValue('ds')['id'];?>
"><?php echo $_smarty_tpl->getValue('ds')['account'];?>
</option>
                                    <?php
}
$_smarty_tpl->getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?>


                                </select>
                            </div>

                            <div class="mb-3">
                                <label for="code"><span class="h6"><?php echo $_smarty_tpl->getValue('_L')['Code'];?>
</span></label>
                                <input type="text" class="form-control" id="code" name="code" value="<?php echo $_smarty_tpl->getSmarty()->getModifierCallback('predict_next_serial')($_smarty_tpl->getValue('config'),'expense');?>
">
                            </div>

                            <div class="mb-3">
                                <label for="date"><span class="h6"><?php echo $_smarty_tpl->getValue('_L')['Date'];?>
</span></label>
                                <input type="text" class="form-control"  value="<?php echo $_smarty_tpl->getValue('mdate');?>
" name="date" id="date" datepicker data-date-format="yyyy-mm-dd" data-auto-close="true">
                            </div>

                            <div class="mb-3">
                                <label for="description"><span class="h6 "><?php echo $_smarty_tpl->getValue('_L')['Description'];?>
</span></label>
                                <input type="text" class="form-control" id="description" name="description">
                                <div class="help-block"><a data-bs-toggle="modal" href="#modal_add_item"><i class="fal fa-paperclip"></i> <span class="h6"><?php echo $_smarty_tpl->getValue('_L')['Attach File'];?>
</span></a> </div>
                            </div>

                            <div class="mb-3">
                                <label for="currency"><span class="h6"><?php echo $_smarty_tpl->getValue('_L')['Currency'];?>
</span></label>
                                <select id="currency" name="currency" class="form-select">

                                    <?php
$_from = $_smarty_tpl->getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('currencies'), 'currency');
$foreach1DoElse = true;
foreach ($_from ?? [] as $_smarty_tpl->getVariable('currency')->value) {
$foreach1DoElse = false;
?>
                                        <option value="<?php echo $_smarty_tpl->getValue('currency')['iso_code'];?>
" <?php if ($_smarty_tpl->getValue('config')['home_currency'] == $_smarty_tpl->getValue('currency')['iso_code']) {?>selected<?php }?>
                                                <?php if ((null !== ($_smarty_tpl->getValue('currencies_all')[$_smarty_tpl->getValue('currency')['iso_code']] ?? null))) {?>
                                            data-a-sign="<?php echo $_smarty_tpl->getValue('currencies_all')[$_smarty_tpl->getValue('currency')['iso_code']]['symbol'];?>
" data-a-sep="<?php echo $_smarty_tpl->getValue('currencies_all')[$_smarty_tpl->getValue('currency')['iso_code']]['thousands_separator'];?>
" data-a-dec="<?php echo $_smarty_tpl->getValue('currencies_all')[$_smarty_tpl->getValue('currency')['iso_code']]['decimal_mark'];?>
" <?php if (($_smarty_tpl->getValue('currencies_all')[$_smarty_tpl->getValue('currency')['iso_code']]['symbol_first'] == true)) {?> data-p-sign="p" <?php } else { ?> data-p-sign="s" <?php }?>
                                                <?php }?>><?php echo $_smarty_tpl->getValue('currency')['iso_code'];?>
</option>
                                    <?php
}
$_smarty_tpl->getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?>


                                </select>
                            </div>


                            <div class="mb-3">
                                <label for="amount"><span class="h6"><?php echo $_smarty_tpl->getValue('_L')['Amount'];?>
</span></label>
                                <input type="text" class="form-control amount" id="amount" name="amount">
                            </div>

                            <div class="mb-3">
                                <label for="cats"><span class="h6"><?php echo $_smarty_tpl->getValue('_L')['Category'];?>
</span></label>
                                <select id="cats" name="cats" class="form-control">
                                    <option value="0"><?php echo $_smarty_tpl->getValue('_L')['Uncategorized'];?>
</option>
                                    <?php
$_from = $_smarty_tpl->getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('cats'), 'cat');
$foreach2DoElse = true;
foreach ($_from ?? [] as $_smarty_tpl->getVariable('cat')->value) {
$foreach2DoElse = false;
?>
                                        <option value="<?php echo $_smarty_tpl->getValue('cat')['id'];?>
"><?php echo $_smarty_tpl->getValue('cat')['name'];?>
</option>
                                    <?php
}
$_smarty_tpl->getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?>


                                </select>
                            </div>






                            <div class="mb-3">
                                <label for="tags"><span class="h6"><?php echo $_smarty_tpl->getValue('_L')['Tags'];?>
</span></label>
                                <select name="tags[]" id="tags" class="form-control" multiple="multiple">
                                    <?php
$_from = $_smarty_tpl->getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('tags'), 'tag');
$foreach3DoElse = true;
foreach ($_from ?? [] as $_smarty_tpl->getVariable('tag')->value) {
$foreach3DoElse = false;
?>
                                        <option value="<?php echo $_smarty_tpl->getValue('tag')['text'];?>
"><?php echo $_smarty_tpl->getValue('tag')['text'];?>
</option>
                                    <?php
}
$_smarty_tpl->getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?>

                                </select>
                            </div>

                            <div class="mb-3">
                                <label for="company"><span class="h6"><?php echo $_smarty_tpl->getValue('_L')['Company'];?>
</span></label>
                                <select id="company" name="company" class="form-control">
                                    <option value=""><?php echo $_smarty_tpl->getValue('_L')['None'];?>
</option>
                                    <?php
$_from = $_smarty_tpl->getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('companies'), 'company');
$foreach4DoElse = true;
foreach ($_from ?? [] as $_smarty_tpl->getVariable('company')->value) {
$foreach4DoElse = false;
?>
                                        <option value="<?php echo $_smarty_tpl->getValue('company')->id;?>
"><?php echo $_smarty_tpl->getValue('company')->company_name;?>
</option>
                                    <?php
}
$_smarty_tpl->getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?>


                                </select>
                            </div>

                            <div class="mb-3">
                                <label for="payee"><span class="h6"><?php echo $_smarty_tpl->getValue('_L')['Payee'];?>
</span></label>
                                <select id="payee" name="payee" class="form-control">
                                    <option value=""><?php echo $_smarty_tpl->getValue('_L')['Choose Contact'];?>
</option>
                                    <?php
$_from = $_smarty_tpl->getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('p'), 'ps');
$foreach5DoElse = true;
foreach ($_from ?? [] as $_smarty_tpl->getVariable('ps')->value) {
$foreach5DoElse = false;
?>
                                        <option value="<?php echo $_smarty_tpl->getValue('ps')['id'];?>
"><?php echo $_smarty_tpl->getValue('ps')['account'];?>
</option>
                                    <?php
}
$_smarty_tpl->getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?>


                                </select>
                            </div>


                            <div class="mb-3">
                                <label for="staff_id"><span class="h6"><?php echo $_smarty_tpl->getValue('_L')['Staff'];?>
</span></label>
                                <select id="staff_id" name="staff_id" class="form-control">
                                    <option value="0"><?php echo $_smarty_tpl->getValue('_L')['None'];?>
</option>
                                    <?php
$_from = $_smarty_tpl->getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('staffs'), 'staff');
$foreach6DoElse = true;
foreach ($_from ?? [] as $_smarty_tpl->getVariable('staff')->value) {
$foreach6DoElse = false;
?>
                                        <option value="<?php echo $_smarty_tpl->getValue('staff')->id;?>
"><?php echo $_smarty_tpl->getValue('staff')->fullname;?>
</option>
                                    <?php
}
$_smarty_tpl->getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?>


                                </select>
                            </div>


                            <div class="mb-3">
                                <label for="pmethod"><span class="h6"><?php echo $_smarty_tpl->getValue('_L')['Method'];?>
</span></label>
                                <select id="pmethod" name="pmethod" class="form-control">
                                    <option value=""><?php echo $_smarty_tpl->getValue('_L')['Select Payment Method'];?>
</option>
                                    <?php
$_from = $_smarty_tpl->getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('pms'), 'pm');
$foreach7DoElse = true;
foreach ($_from ?? [] as $_smarty_tpl->getVariable('pm')->value) {
$foreach7DoElse = false;
?>
                                        <option value="<?php echo $_smarty_tpl->getValue('pm')['name'];?>
"><?php echo $_smarty_tpl->getValue('pm')['name'];?>
</option>
                                    <?php
}
$_smarty_tpl->getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?>


                                </select>
                            </div>

                            <div class="mb-3">
                                <label for="item"><span class="h6"><?php echo $_smarty_tpl->getValue('_L')['Item'];?>
</span></label>
                                <select id="item" name="item_id" class="form-select">
                                    <option value="0"><?php echo $_smarty_tpl->getValue('_L')['None'];?>
</option>
                                    <?php
$_from = $_smarty_tpl->getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('items'), 'item');
$foreach8DoElse = true;
foreach ($_from ?? [] as $_smarty_tpl->getVariable('item')->value) {
$foreach8DoElse = false;
?>
                                        <option value="<?php echo $_smarty_tpl->getValue('item')->id;?>
"><?php echo $_smarty_tpl->getValue('item')->name;?>
</option>
                                    <?php
}
$_smarty_tpl->getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?>
                                </select>
                            </div>

                            <div class="mb-3">
                                <label for="status"><span class="h6"><?php echo $_smarty_tpl->getValue('_L')['Status'];?>
</span></label>
                                <select class="form-select" name="status" id="status">
                                    <option value="Cleared"><?php echo $_smarty_tpl->getValue('_L')['Cleared'];?>
</option>
                                    <option value="Uncleared"><?php echo $_smarty_tpl->getValue('_L')['Uncleared'];?>
</option>
                                </select>
                            </div>

                            <div class="mb-3">
                                <label for="ref"><span class="h6"><?php echo $_smarty_tpl->getValue('_L')['Ref'];?>
#</span></label>
                                <input type="text" class="form-control" id="ref" name="ref">
                            </div>




                            <div class="mb-3">
                                <input type="hidden" name="attachments" id="attachments" value="">
                                <button type="submit" id="submit" class="btn btn-primary"><?php echo $_smarty_tpl->getValue('_L')['Submit'];?>
</button>
                            </div>
                        </form>

                    </div>
                </div>

            </div>
        </div>

        <?php if ($_smarty_tpl->getSmarty()->getModifierCallback('has_access')($_smarty_tpl->getValue('user')->roleid,'transactions','view')) {?>

            <div class="col-md-8">
                <div class="panel">
                    <div class="panel-hdr">
                        <h2><?php echo $_smarty_tpl->getValue('_L')['Recent Expense'];?>
</h2>

                    </div>

                    <div class="panel-container">
                        <div class="panel-content">

                            <table class="table table-bordered table-striped sys_table">
                                <thead <?php if (empty($_smarty_tpl->getValue('config')['admin_dark_theme'])) {?>
                                    style="background:#f0f2ff"
                                        <?php }?>>
                                <tr>
                                    <th class="h6"><?php echo $_smarty_tpl->getValue('_L')['Account'];?>
</th>
                                    <th class="h6"><?php echo $_smarty_tpl->getValue('_L')['Description'];?>
</th>
                                    <th class="h6"><?php echo $_smarty_tpl->getValue('_L')['Amount'];?>
</th>

                                </tr>
                                </thead>
                                <tbody>

                                <?php
$_from = $_smarty_tpl->getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('tr'), 'trs');
$foreach9DoElse = true;
foreach ($_from ?? [] as $_smarty_tpl->getVariable('trs')->value) {
$foreach9DoElse = false;
?>
                                    <tr>
                                        <td class="h6"><?php echo $_smarty_tpl->getValue('trs')['account'];?>
</td>
                                        <td class="h6 text-info"><a href="<?php echo $_smarty_tpl->getValue('_url');?>
transactions/manage/<?php echo $_smarty_tpl->getValue('trs')['id'];?>
">
                                                <?php if ($_smarty_tpl->getValue('trs')['attachments'] != '') {?>
                                                    <i class="fal fa-paperclip"></i>
                                                <?php }?>
                                                <span class="h6 text-info"> <?php echo $_smarty_tpl->getValue('trs')['description'];?>
</span>

                                            </a>

                                            <?php if ($_smarty_tpl->getValue('trs')['code'] != '') {?>
                                                <br>
                                                <?php echo $_smarty_tpl->getValue('trs')['code'];?>

                                            <?php }?>

                                            <?php if ($_smarty_tpl->getValue('trs')['company_id'] != '0' && (null !== ($_smarty_tpl->getValue('companies_by_ids')[$_smarty_tpl->getValue('trs')['company_id']] ?? null))) {?>
                                                <br>
                                                <?php echo $_smarty_tpl->getValue('companies_by_ids')[$_smarty_tpl->getValue('trs')['company_id']]->company_name;?>

                                            <?php }?>

                                        </td>
                                        <td class="amount text-danger h6"
                                                <?php if ((null !== ($_smarty_tpl->getValue('currencies_all')[$_smarty_tpl->getValue('trs')['currency_iso_code']] ?? null))) {?>
                                                    data-a-sign="<?php echo $_smarty_tpl->getValue('currencies_all')[$_smarty_tpl->getValue('trs')['currency_iso_code']]['symbol'];?>
" data-a-sep="<?php echo $_smarty_tpl->getValue('currencies_all')[$_smarty_tpl->getValue('trs')['currency_iso_code']]['thousands_separator'];?>
" data-a-dec="<?php echo $_smarty_tpl->getValue('currencies_all')[$_smarty_tpl->getValue('trs')['currency_iso_code']]['decimal_mark'];?>
" <?php if (($_smarty_tpl->getValue('currencies_all')[$_smarty_tpl->getValue('trs')['currency_iso_code']]['symbol_first'] == true)) {?> data-p-sign="p" <?php } else { ?> data-p-sign="s" <?php }?>
                                                <?php }?>
                                        ><?php echo $_smarty_tpl->getValue('trs')['amount'];?>
</td>
                                    </tr>
                                <?php
}
$_smarty_tpl->getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?>

                                </tbody>
                            </table>

                        </div>
                    </div>

                </div>
            </div>

        <?php }?>



    </div>

    <input type="hidden" id="_lan_no_results_found" value="<?php echo $_smarty_tpl->getValue('_L')['No results found'];?>
">

    <div class="modal fade" id="modal_add_item" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">
                        <?php echo $_smarty_tpl->getValue('_L')['Attach File'];?>

                    </h4>
                    <button type="button" class="close btn btn-danger" data-bs-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true"><i class="fal fa-times"></i></span>
                    </button>
                </div>
                <div class="modal-body">
                    <form action="" class="dropzone" id="upload_container">

                        <div class="dz-message">
                            <h3> <i class="fal fa-cloud-upload"></i>  <?php echo $_smarty_tpl->getValue('_L')['Drop File Here'];?>
</h3>
                            <br />
                            <span class="note"><?php echo $_smarty_tpl->getValue('_L')['Click to Upload'];?>
</span>
                        </div>

                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?php echo $_smarty_tpl->getValue('_L')['Close'];?>
</button>
                </div>
            </div>
        </div>
    </div>

<?php
}
}
/* {/block "content"} */
/* {block "script"} */
class Block_1707527302673e949814fb45_63942794 extends \Smarty\Runtime\Block
{
public function callBlock(\Smarty\Template $_smarty_tpl) {
$_smarty_current_dir = '/Users/razib/Herd/suite/ui/theme/default';
?>




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

        Dropzone.autoDiscover = false;

        jQuery(document).ready(function() {


            var $currency = $('#currency');
            var $amount = $("#amount");


            function clxAmountSingleFieldAutoNumeric(amountId) {
                $(amountId).autoNumeric('destroy');
                $(amountId).autoNumeric('init', {
                    aSign: $currency.find(':selected').data('a-sign'),
                    dGroup: <?php echo $_smarty_tpl->getValue('config')['thousand_separator_placement'];?>
,
                    aPad: <?php echo $_smarty_tpl->getValue('config')['currency_decimal_digits'];?>
,
                    pSign: $currency.find(':selected').data('p-sign'),
                    aDec: $currency.find(':selected').data('a-dec'),
                    aSep: $currency.find(':selected').data('a-sep'),
                    vMax: '9999999999999999.00',
                    vMin: '-9999999999999999.00'

                });
            }

            $currency.on('change',function (event) {
                clxAmountSingleFieldAutoNumeric('#amount');
            });



            clxAmountSingleFieldAutoNumeric('#amount');

            function ib_autonumeric() {
                $('.amount').autoNumeric('init', {
                    vMax: '9999999999999999.00',
                    vMin: '-9999999999999999.00'

                });

            }


            ib_autonumeric();


            $("#account").select2({

                    language: {
                        noResults: function () {
                            return $("#_lan_no_results_found").val();
                        }
                    }
                }
            );
            $("#cats").select2({

                    language: {
                        noResults: function () {
                            return $("#_lan_no_results_found").val();
                        }
                    }
                }
            );
            $("#pmethod").select2({

                    language: {
                        noResults: function () {
                            return $("#_lan_no_results_found").val();
                        }
                    }
                }
            );
            $("#payee").select2({

                    language: {
                        noResults: function () {
                            return $("#_lan_no_results_found").val();
                        }
                    }
                }
            );

            $("#company").select2({

                    language: {
                        noResults: function () {
                            return $("#_lan_no_results_found").val();
                        }
                    }
                }
            );

            $("#item").select2({
                    language: {
                        noResults: function () {
                            return $("#_lan_no_results_found").val();
                        }
                    }
                }
            );

            $('#tags').select2({
                tags: true,
                tokenSeparators: [','],

                language: {
                    noResults: function () {
                        return $("#_lan_no_results_found").val();
                    }
                }
            });



            $("#emsg").hide();

            var _url = $("#_url").val();




            //  file attach

            var upload_resp;

            var $ib_form_submit = $("#submit");


            var ib_file = new Dropzone("#upload_container",
                {
                    url: _url + "transactions/handle_attachment/",
                    maxFiles: 1,
                    acceptedFiles: "image/*,application/pdf"
                }
            );


            ib_file.on("sending", function() {

                $ib_form_submit.prop('disabled', true);

            });

            ib_file.on("success", function(file,response) {

                $ib_form_submit.prop('disabled', false);

                upload_resp = response;

                if(upload_resp.success == 'Yes'){

                    toastr.success(upload_resp.msg);
                    // $file_link.val(upload_resp.file);
                    // files.push(upload_resp.file);
                    //
                    // console.log(files);

                    $('#attachments').val(function(i,val) {
                        return val + (!val ? '' : ',') + upload_resp.file;
                    });


                }
                else{
                    toastr.error(upload_resp.msg);
                }



            });


            $ib_form_submit.click(function (e) {
                e.preventDefault();
                $('#ibox_form').block({ message: null });
                var _url = $("#_url").val();
                $.post(_url + 'transactions/expense-post/', {


                    account: $('#account').val(),
                    date: $('#date').val(),

                    amount: $('#amount').val(),
                    sub_type: $('#sub_type').val(),
                    cats: $('#cats').val(),
                    description: $('#description').val(),
                    attachments: $('#attachments').val(),
                    tags: $('#tags').val(),
                    payee: $('#payee').val(),
                    pmethod: $('#pmethod').val(),
                    ref: $('#ref').val(),
                    currency: $currency.val(),
                    status: $('#status').val(),
                    code: $('#code').val(),
                    company: $('#company').val(),
                    staff_id: $('#staff_id').val(),
                    item_id: $('#item').val(),

                })
                    .done(function (data) {
                        var sbutton = $("#submit");
                        var _url = $("#_url").val();
                        if ($.isNumeric(data)) {

                            location.reload();
                        }
                        else {
                            $('#ibox_form').unblock();
                            var body = $("html, body");
                            body.animate({ scrollTop:0 }, '1000', 'swing');
                            $("#emsgbody").html(data);
                            $("#emsg").show("slow");
                        }
                    });
            });



        });



    <?php echo '</script'; ?>
>
<?php
}
}
/* {/block "script"} */
}
