
<style type="text/css">
    #InventoryPurchaseTable thead tr th {
        color: #555;
        border-bottom: 1px solid rgba(0,0,0,0.1);
    }
    #InventoryPurchaseTable tbody tr td input {
        width: 100%;
        margin: 0;
        border: 1px solid rgba(0,0,0,0.02);
        background-color: #f0f0f0;
    }
    #InventoryPurchaseTable tbody tr td {
        border: 0;
        padding: 3px 1px;
        position: relative;
    }
    #InventoryPurchaseTable tbody tr:first-child td {
        padding-top: 10px;
    }
    #InventoryPurchaseTable .Hint {
        position: absolute;
        font-size: 10px;
        font-weight: bold;
        height: 20px;
        line-height: 20px;
        bottom: 2px;
        right: 4px;
        color: rgb(153, 153, 153);
    }
    #InventoryPurchaseTable .TotalTD {
        width: auto;
        display: inline-block;
        text-align: center;
        font-size: 20px;
        text-indent: 10px;
        font-weight: bold;
    }
    #InventoryPurchaseTable .Disc {
        width: 50px;
    }
    #InventoryPurchaseTable input.wrong {
        border: 1px solid rgba(255, 0, 0, 0.2);
        background: rgba(255, 0, 0, 0.05);
    }
    .DropDownForForms > .dropdown-menu {
        width: 100%;
        height: auto;
        max-height: 200px;
        cursor: pointer;
        overflow-y: auto;
        z-index: 999999;
    }
    .DropDownForForms > .dropdown-menu > li:hover {
        background: #eee;
    }
    .DropDownForForms > button {
        position: relative;
        z-index: 999;
    }
    .DropDownForForms > button > input {
        position: absolute;
        left: 5;
        top: 0;
        width: 90%;
        cursor: pointer;
        -webkit-user-select: none;
        -moz-user-select: none;
        user-select: none;
        padding: 0;
        border: 0;
        background: transparent;
    }
    .Disabled {
        cursor: default;
        opacity: 0.5;
    }
    #AdvanceValue {
        width: 102px;
        display: inline-block;
    }
    .ImageTD {
        text-align: center;
    }
    .ImageTD > .Remove {
        display: none;
    }
    .ImageTD > .Add > input {
        position: absolute;
        left: 0;
        top: 0;
        opacity: 0.001;
        cursor: pointer;
    }
    .ImageTD.Added > .Add {
        display: none;
    }
    .ImageTD.Added > .Remove {
        display: inline-block;
    }
    #AccountsTree {
        display: none;
        position: absolute;
        left: 0px;
        top: 0px;
        width: 300px;
        height: 200px;
        overflow: auto;
        background: #fafafa;
        border: 1px solid #ddd;
        z-index: 9999;
        -webkit-box-shadow: 0px 0px 5px rgba(98, 98, 98, 0.2);
        -moz-box-shadow: 0px 0px 5px rgba(98, 98, 98, 0.2);
        box-shadow: 0px 0px 5px rgba(98, 98, 98, 0.2);
    }
    .TreeItem {
        display: inline-block;
        cursor: default;
        font-size: 11px;
    }
    .TreeItem.NoChild {
        cursor: pointer;
        padding: 3px;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
    }
    .TreeItem.NoChild:hover {
        background: rgb(238, 238, 238);
    }
    .dynatree-exp-cd span.dynatree-expander {
        top: 5px;
    }
    .dynatree-node > .dynatree-icon {
        display: none;
    }
    ul.dynatree-container {
        overflow: visible !important;
    }
    .DropDownForForms > button strong {
        width: 288px;
        text-overflow: ellipsis;
        overflow: hidden;
        display: block;
    }
    #SetPaidForm{
        display:none;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        background-color:rgba(0,0,0,0.3);
        z-index: 99999;
        -webkit-transition:opacity 0.3s linear;
        -moz-transition:opacity 0.3s linear;
        transition:opacity 0.3s linear;
    }
    #SetPaidForm.Closed{
        opacity:0;
    }
    #SetPaidForm > .Body{
        width: 50%;
        padding:13px;
        margin: 130px auto;
        background-color: #fff;
        -webkit-box-shadow: 0 0 40px #888;
        -moz-box-shadow: 0 0 40px #888;
        box-shadow: 0 0 40px #888;
        -webkit-transition:-webkit-transform 0.2s linear;
        -moz-transition:-moz-transform 0.2s linear;
        transition:transform 0.2s linear;
    }
    #SetPaidForm.Closed > .Body{
        -webkit-transform:scale(0);
    }
    #SetPaidForm .nav.nav-tabs a {
        padding: 7px 14px;
        font-size: 11px;
    }
    .InputSpinner{
        width: 60px;
    }
    .InputSpinner > .form-control{
        border-color: rgb(221, 221, 221);
        height:36px;
        margin:0;
        padding:0;
        text-align: center;
        /*
        -webkit-border-radius: 3px 0px 0px 3px !important;
        -moz-border-radius: 3px 0px 0px 3px !important;
        border-radius: 3px 0px 0px 3px !important;
        */
    }
    .InputSpinner > .input-group-btn-vertical {
        position: relative;
        white-space: nowrap;
        width: 25px;
        vertical-align: middle;
        display: table-cell;
    }
    .InputSpinner > .input-group-btn-vertical > .btn {
        height:19px;
        display: block;
        float: none;
        width: 100%;
        max-width: 100%;
        padding: 8px;
        margin-left: -1px;
        position: relative;
        border-radius: 0;
    }
    .InputSpinner > .input-group-btn-vertical > .btn:first-child {
        border-top-right-radius: 4px;
    }
    .InputSpinner > .input-group-btn-vertical > .btn:last-child {
        margin-top: -2px;
        border-bottom-right-radius: 4px;
    }
    .InputSpinner > .input-group-btn-vertical i{
        position: absolute;
        top: 50%;
        left: 6px;
        margin-top:-9px;
        font-size: 18px;
    }
</style>
<link href="<?php echo THEME_PATH; ?>/plugins/jquery-dynatree/skin/ui.dynatree.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="<?php echo THEME_PATH; ?>/plugins/summernote/css/summernote.css" rel="stylesheet" type="text/css" media="screen">
<script src=" <?php echo THEME_PATH; ?>/plugins/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
<script src="<?php echo THEME_PATH; ?>/plugins/jquery-dynatree/jquery.dynatree.min.js" type="text/javascript"></script>
<script src="<?php echo THEME_PATH; ?>/plugins/summernote/js/summernote.min.js" type="text/javascript"></script>
<script src="<?php echo THEME_PATH; ?>plugins/jquery-validation/js/jquery.validate.min.js"></script>
<div class="modal fade" data-backdrop="static"  id="add_expenses" tabindex="-1" role="dialog" aria-hidden="true" style="overflow:auto">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" data- aria-hidden="true"><i class="pg-close fs-14"></i></button>
                <h5><?php print CommonLanguage::getMessage('add_expenditures'); ?></h5>
            </div>
            <div class="modal-body">
                <div id="ModalValidationAlert"></div>
                <form method="POST" action="" onsubmit="return false" id="InvoiceForm">
                    <div class="invoice">
                        <div class="container-sm-height">
                            <div class="row-sm-height">
                                <div class="col-md-9 col-sm-height sm-no-padding">
                                    <div>
                                        <div class="input-group  col-md-4 center-margin pull-left" >
                                            <h2 class="font-montserrat all-caps hint-text"><?php print CommonLanguage::getMessage('expenditures'); ?></h2>
                                        </div>
                                        <div class="clearfix"></div>
                                    </div>
                                    <div>
                                        <span class="fa fa-plus-circle m-l-5 openFrame" data-src="Inventory/ViewVendorList?is_pop=1" style="color:#4c0870;cursor:pointer"></span>
                                        <div class="input-group  col-md-4 center-margin pull-left" >
                                            <span class="input-group-addon  complete">
                                                <i class="fa fa-search"></i>
                                            </span>
                                            <input type="text" id="AddExpensessearch_supplier" class="form-control ui-autocomplete-input" placeholder="<?php print CommonLanguage::getMessage('enter_supplier_company'); ?>" aria-invalid="false">
                                        </div>
                                        <div class="clearfix"></div>
                                    </div>
                                    <br>
                                    <div id="AddExpensesSupplierInfo">
                                        <input type="hidden" name="Supplier_ID" required id="AddExpensesSupplier_ID" />
                                        <div id="AddExpensesSupplierInfoContent">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-4 col-sm-height col-bottom sm-no-padding sm-p-b-20" style="vertical-align: top;">
                                    <div  class="form-group form-group-default input-group">
                                        <label><?php print CommonLanguage::getMessage('Date'); ?></label>
                                        <input id="PurchaseInvoiceDate" name="PurchaseInvoiceDate" class="form-control" value="<?php echo ($today); ?>" />
                                        <span class="input-group-addon complete"><i class="fa fa-calendar"></i></span>
                                    </div>
                                    <?php echo Forms::CurrencyDropDown(1, "complete") ?>
                                    <br>
                                </div>
                            </div>
                        </div>
                        <div>
                            <div class="clearfix"></div>
                        </div>
                        <div class="table-responsive">
                            <table class="table m-t-50" id='InventoryPurchaseTable'>
                                <thead>
                                    <tr>
                                        <th class="text-center" style="width:30%"><?php print CommonLanguage::getMessage('Description'); ?></th>
                                        <th class="text-center" style="width:10%"><?php print CommonLanguage::getMessage('Quantity'); ?></th>
                                        <th class="text-center" style="width:10%"><?php print CommonLanguage::getMessage('unit_price'); ?></th>
                                        <th class="text-center" style="width:30%"><?php print CommonLanguage::getMessage('account'); ?><span class="fa fa-plus-circle m-l-5 openFrame" data-src="ACC/viewlibrary/1?is_pop=1" style="color:#4c0870;cursor:pointer"></span></th>
                                        <th class="text-center"><?php print CommonLanguage::getMessage('Upload'); ?></th>
                                        <th class="text-center" style="width:10%"><?php print CommonLanguage::getMessage('total'); ?></th>
                                        <th class="text-center" style="width:10%"><?php print CommonLanguage::getMessage('paid'); ?></th>
                                        <th class="text-center" style="width:5%"><?php print CommonLanguage::getMessage('Taxable'); ?></th>
                                        <th class="text-center" style="width:5%"><?php print CommonLanguage::getMessage('depreciation'); ?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr class="TableItem">
                                        <td><input type="text" class="form-control Description"></td>
                                        <td><input type="text" class="form-control Quantity"></td>
                                        <td><input type="text" class="form-control UnitPrice isnumber"></td>
                                        <td>                                                            
                                            <input class="AccountCode full-width"  name="AccountCode" type="hidden"  />
                                            <!--                                            <div class="form-group BootstrapDropDown">
<select class="full-width AccountCode" data-init-plugin="select2">
                                            <?php foreach ($expenses_accounts as $account): ?>
    <option value="<?php echo $account['Account_Code']; ?>"><?php echo $account['Account_Name'] . " - " . $account['Account_Code']; ?></option>
                                            <?php endforeach; ?>
</select>
</div>-->
                                        </td>
                                        <td class="ImageTD"><button class="Remove btn btn-danger" onclick="RemoveCurrentTdFile(this);return false"><?php print CommonLanguage::getMessage('remove'); ?></button><button class="Add btn btn-complete"><input type="file"  accept="image/*" class="form-control image_file" onchange="$(this).parents('td').addClass('Added')" /><?php print CommonLanguage::getMessage('Add'); ?></button></td>
                                        <td class="TotalTD"><span class="CurrencyIndicator"><?php echo $currency_symbol ?></span>&nbsp;<span class="Total">0</span></td>
                                        <td class="text-center Paid"><button class="SetPaid btn btn-complete"><?php print CommonLanguage::getMessage('set'); ?></button></td>
                                        <td style="text-center"><input type="checkbox" id="Expense_VAT" name="Expense_VAT" class="taxtable"/></td>
                                        <td class="text-center Depreciation"><button class="SetDep btn btn-complete"><?php print CommonLanguage::getMessage('Add'); ?></button></td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                        <br>
                        <div class="container-sm-height" >
                            <div class="row row-sm-height b-a b-grey">
                                <!--
<div class="form-group  text-center">
<label>File input</label>
<input id="NewExpenseUploadPhoto" type="file" name="image_file" accept="image/*" data-target="#NewExpenseUploadImagePreview" class="form-control " onchange="window.NewExpenseCurrentFileUploadaddExpenses = event.target.files;ValidateForNewExpensePhoto(this,'Picture')">
<p>Note:please use PNG/JPG images only.</p>
</div>
                                -->
                                <div class="col-sm-8 col-sm-height col-middle clearfix sm-p-b-15">
                                    <textarea id="Expense_Note" name="Expense_Note" class="form-control NoteTextArea" placeholder="<?php print CommonLanguage::getMessage('enter_note'); ?>"></textarea>
                                    <!--
<div class="text-center">
<img id="NewExpenseUploadImagePreview" style="max-width: 200px;max-height: 200px;;display:none" />
<i  id="NewExpenseNoPreviewFileUploadIcon" class="fa fa-file-image-o fa-5x"></i>
</div>
                                    -->                                     </div>
                                <div class="col-sm-4 text-right bg-menu col-sm-height padding-15">
                                    <h5 class="font-montserrat all-caps small no-margin hint-text text-white bold"><?php print CommonLanguage::getMessage('total'); ?></h5>
                                    <h1 class="no-margin text-white Total"><span class="CurrencyIndicator"><?php echo $currency_symbol ?></span>&nbsp;<span id="PurchaseInvoiceTotalDetails">0</span></h1>
                                </div>
                            </div>
                        </div>
                        <div class="container-sm-height" >
                            <button class=" btn btn-complete btn-cons m-b-10 pull-right  "  id="InvoiceSubmitButton" style="padding-top: 10px;top: 20px;min-width:253px;" type="button"><i class="pg-form"></i> <span class="bold"><?php print CommonLanguage::getMessage('Save'); ?></span></button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<div id="SetPaidForm">
    <div class="Body">
        <div class="">
            <ul class="nav nav-tabs">
                <li class="active"><a data-toggle="tab" href="#AddExpenseSetPaidFormTab_1"><i class="fa fa-money"></i>&nbsp;&nbsp;<?php print CommonLanguage::getMessage('cash'); ?></a></li>
                <li><a data-toggle="tab" href="#AddExpenseSetPaidFormTab_2"><i class="fa fa-file-text-o"></i>&nbsp;&nbsp;<?php print CommonLanguage::getMessage('check'); ?></a></li>
                <li><a data-toggle="tab" href="#AddExpenseSetPaidFormTab_3"><i class="fa fa-cc-visa"></i>&nbsp;&nbsp;<?php print CommonLanguage::getMessage('credit_card'); ?></a></li>
            </ul>
            <div class="tab-content" style="padding:0;overflow:visible">
                <div id="AddExpenseSetPaidFormTab_1" class="tab-pane fade in active">
                    <table class="table" cellpadding="0" cellspacing="0">
                        <tbody>
                            <tr>
                                <td style="width: 65%;"><span class="SpanInTableInPayment"><?php print CommonLanguage::getMessage('amount'); ?></span></td>
                                <td>
                                    <div class="input-group InputSpinner" style="width:120px">
                                        <input type="text" class="form-control" value="0" onblur="InputMustBeAtleastN(this, 0);" />
                                        <div class="input-group-btn-vertical">
                                            <button class="btn btn-default more"><i class="fa fa-caret-up"></i></button>
                                            <button class="btn btn-default"><i class="fa fa-caret-down"></i></button>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td><span class="SpanInTableInPayment"><?php print CommonLanguage::getMessage('Type'); ?></span></td>
                                <td style="text-align:center">
                                    <div class="input-group-btn DropDownForForms Closable">
                                        <button type="button" class="btn btn-default btn-block dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                            <span><?php print CommonLanguage::getMessage('select'); ?></span>
                                            <input type="hidden" value="" class="form-control" onkeyup="return false" onkeydown="return false"/>
                                        </button>
                                        <ul class="dropdown-menu">
                                            <?php for ($x = 0; $x < count($Cashes); $x++) { ?>
                                                <li value="<?php echo $Cashes[$x]["Account_ID"]; ?>"><a><?php echo $Cashes[$x]["Account_Name"]; ?></a></li>
                                            <?php } ?>
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div id="AddExpenseSetPaidFormTab_2" class="tab-pane fade in">
                    <table class="table" cellpadding="0" cellspacing="0">
                        <tbody>
                            <tr>
                                <td style="width: 65%;"><span class="SpanInTableInPayment"><?php print CommonLanguage::getMessage('amount'); ?></span></td>
                                <td>
                                    <div class="input-group InputSpinner" style="width:120px">
                                        <input type="text" class="form-control" value="0" onblur="InputMustBeAtleastN(this, 0);" />
                                        <div class="input-group-btn-vertical">
                                            <button class="btn btn-default more"><i class="fa fa-caret-up"></i></button>
                                            <button class="btn btn-default"><i class="fa fa-caret-down"></i></button>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td><span class="SpanInTableInPayment"><?php print CommonLanguage::getMessage('Type'); ?></span></td>
                                <td style="text-align:center">
                                    <div class="input-group-btn DropDownForForms Closable">
                                        <button type="button" class="btn btn-default btn-block dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                            <span><?php print CommonLanguage::getMessage('select'); ?></span>
                                            <input type="hidden" value="" class="form-control" onkeyup="return false" onkeydown="return false"/>
                                        </button>
                                        <ul class="dropdown-menu">
                                            <?php for ($x = 0; $x < count($Checks); $x++) { ?>
                                                <li value="<?php echo $Checks[$x]["Account_ID"]; ?>"><a><?php echo $Checks[$x]["Account_Name"]; ?></a></li>
                                            <?php } ?>
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                            <!--                            <tr>
<td><span class="SpanInTableInPayment"><?php print CommonLanguage::getMessage('check'); ?> #</span></td>
<td style="text-align:center"><input type="text" class="form-control CheckNumValue" /></td>
</tr>-->
                        </tbody>
                    </table>
                </div>
                <div id="AddExpenseSetPaidFormTab_3" class="tab-pane fade in">
                    <table class="table" cellpadding="0" cellspacing="0">
                        <tbody>
                            <tr>
                                <td style="width: 65%;"><span class="SpanInTableInPayment"><?php print CommonLanguage::getMessage('amount'); ?></span></td>
                                <td>
                                    <div class="input-group InputSpinner" style="width:120px">
                                        <input type="text" class="form-control" value="0" onblur="InputMustBeAtleastN(this, 0);" />
                                        <div class="input-group-btn-vertical">
                                            <button class="btn btn-default more"><i class="fa fa-caret-up"></i></button>
                                            <button class="btn btn-default"><i class="fa fa-caret-down"></i></button>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td><span class="SpanInTableInPayment"><?php print CommonLanguage::getMessage('Type'); ?></span></td>
                                <td style="text-align:center">
                                    <div class="input-group-btn DropDownForForms Closable">
                                        <button type="button" class="btn btn-default btn-block dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                            <span><?php print CommonLanguage::getMessage('select'); ?></span>
                                            <input type="hidden" value="" class="form-control" onkeyup="return false" onkeydown="return false"/>
                                        </button>
                                        <ul class="dropdown-menu">
                                            <?php for ($x = 0; $x < count($CreditCards); $x++) { ?>
                                                <li value="<?php echo $CreditCards[$x]["Account_ID"]; ?>"><a><?php echo $CreditCards[$x]["Account_Name"]; ?></a></li>
                                            <?php } ?>
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                            <!--                            <tr>
<td><span class="SpanInTableInPayment"><?php print CommonLanguage::getMessage('approval_code'); ?></span></td>
<td style="text-align:center"><input type="text" class="form-control CardApproval" /></td>
</tr>-->
                        </tbody>
                    </table>
                </div>
            </div>
            <div style="text-align:right">
                <button class="CloseMeButton btn btn-default"><?php print CommonLanguage::getMessage('Close'); ?></button>
                <button class="SaveMeButton btn btn-complete"><?php print CommonLanguage::getMessage('Save'); ?></button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade stick-up " data-backdrop="static" id="addDepreciation" tabindex="-1" role="dialog" aria-hidden="true"style="width:60%;margin:0 auto">
    <div class="modal-dialog ">
        <div class="modal-content">
            <div class="modal-header clearfix text-left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="pg-close fs-14"></i></button>
                <h5><span class="semi-bold"><?php print CommonLanguage::getMessage('add_depreciation'); ?></span></h5>
            </div>
            <div class="modal-body">
                <form id="DepreciationPostForm" method="POST" onsubmit="return false">
                    <div class="row">
                        <div class="col-md-12" style="margin:15px;">
                            <div class="col-md-6">
                                <div><label><?php print CommonLanguage::getMessage('depreciation_rate'); ?></label></div>
                                <div class="input-group m-b"><span class="input-group-btn">
                                        <button type="button" class="btn btn-complete"><i class="fa fa-certificate"></i> </button> </span>
                                    <input type="text" placeholder="<?php print CommonLanguage::getMessage('depreciation_rate'); ?>" id="DepRate" name="DepRate" class="form-control DepRate " required>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div><label><?php print CommonLanguage::getMessage('depreciation_period'); ?></label></div>
                                <div class="input-group m-b"><span class="input-group-btn ">
                                        <button type="button" class="btn btn-complete"><i class="fa fa-certificate"></i> </button> </span>
                                    <select required id="Dep_Period" name="Dep_Period" class="full-width " data-init-plugin="select2">
                                        <?php foreach ($all_periods as $periods): ?>
                                            <option value="<?php echo $periods['Period_ID']; ?>"><?php echo $periods['Period_Name']; ?></option>
                                        <?php endforeach; ?>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12" style="margin:10px;">
                            <div class="col-md-6">
                                <div><label><?php print CommonLanguage::getMessage('Description'); ?></label></div>
                                <div class="input-group required">
                                    <span class="input-group-addon bg-complete">
                                        <i class="fa fa-pencil inputIcon"></i>
                                    </span>
                                    <input type="text" placeholder="<?php print CommonLanguage::getMessage('Description'); ?>" id="DepDescription" name="DepDescription" class="form-control DepDescription " required>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div><label><?php print CommonLanguage::getMessage('supplier_invoice_nb'); ?></label></div>
                                <div class="input-group required">
                                    <span class="input-group-addon bg-complete">
                                        <i class="fa fa-sort-numeric-asc inputIcon"></i>
                                    </span>
                                    <input type="text" placeholder="<?php print CommonLanguage::getMessage('supplier_invoice_nb'); ?>" id="Supplier_Nb" name="Supplier_Nb" class="form-control Supplier_Nb " required>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <div class="pull-right">
                            <button class="btn btn-default" id="CloseDepreciation"   > <?php print CommonLanguage::getMessage('Close'); ?> </button>
                            <button class="btn btn-complete " id="SubmitDepreciation"  >  <?php print CommonLanguage::getMessage('Save'); ?>  </button>
                        </div>
                    </div>
            </div>
            </form>
        </div>
    </div>
</div>
<script>
    var Required_Fields = <?php echo json_encode(CommonLanguage::getMessage('Required_Fields')); ?>,
            DepRequired = <?php echo json_encode(CommonLanguage::getMessage('DepRequired')); ?>,
            CompanyLang = <?php echo json_encode(CommonLanguage::getMessage('company')); ?>,
            EmailLang = <?php echo json_encode(CommonLanguage::getMessage('Email')); ?>,
            PhoneLang = <?php echo json_encode(CommonLanguage::getMessage('Phone')); ?>,
            AddressLang = <?php echo json_encode(CommonLanguage::getMessage('address')); ?>,
            CountryLang = <?php echo json_encode(CommonLanguage::getMessage('country')); ?>,
            FinancialNbLang = <?php echo json_encode(CommonLanguage::getMessage('financial_nb')); ?>,
            Failed_Submit = <?php echo json_encode(CommonLanguage::getMessage('Failed_Submit')); ?>,
            Submitted_Successfully = <?php echo json_encode(CommonLanguage::getMessage('Submitted_Successfully')); ?>,
            Is_Actual = <?php echo $is_actual ? 'true' : 'false' ?>;
    var TotalInvoice = 0,
            TotalDiscount = 0,
            TotalInvoiceWithoutDiscount = 0,
            today = <?php echo json_encode($today) ?>;
    $(document).on("change", "select", function () {
        var val = $(this).val(); //get new value
        //find selected option
        $("option", this).removeAttr("selected").filter(function () {
            return $(this).attr("value") == val;
        }).first().attr("selected", "selected"); //add selected attribute to selected option
    });
    $(function () {
        build_select2($("input[name=AccountCode]"), "xhr/accIDSearch?type=Expense")
        //new Switchery($("#Expense_VAT").get(0),{color: $.Pages.getColor("complete")})
        $("#SetPaidForm").addClass("Closed").appendTo($("#add_expenses > .modal-dialog > .modal-content"))
                .find(".CloseMeButton").on("click", function (e) {
            $("#SetPaidForm").clearQueue().addClass("Closed").delay(300).queue(function () {
                $(this).css("display", "none")
            })
        }).end().find(".SaveMeButton").on("click", function (e) {
            $(".CloseMeButton", $(this).parent()).trigger("click")
            CurrentTR.attr({
                Cash_Amount: $("#AddExpenseSetPaidFormTab_1 .InputSpinner > input").eq(0).val(),
                Cash_Type: $("#AddExpenseSetPaidFormTab_1 .DropDownForForms > button > input").eq(0).val(),
                Check_Amount: $("#AddExpenseSetPaidFormTab_2 .InputSpinner > input").eq(0).val(),
                Check_Type: $("#AddExpenseSetPaidFormTab_2 .DropDownForForms > button > input").eq(0).val(),
                Check_Num: $("#AddExpenseSetPaidFormTab_2 .CheckNumValue").eq(0).val(),
                Card_Amount: $("#AddExpenseSetPaidFormTab_3 .InputSpinner > input").eq(0).val(),
                Card_Type: $("#AddExpenseSetPaidFormTab_3 .DropDownForForms > button > input").eq(0).val(),
                Card_Code: $("#AddExpenseSetPaidFormTab_3 .CardApproval").eq(0).val()
            })
        })
        $("#SetPaidForm .InputSpinner .btn").on('click', function () {
            var Input = $("input", $(this).parent().parent()), V = parseInt(Input.val())
            Input.val($(this).hasClass("more") ? V + 1 : V == 0 ? 0 : V - 1)
        })
        $("#InventoryPurchaseTable").on("click", ".TableItem .SetPaid", function (e) {
            e.preventDefault();
            window.CurrentTR = $(this).parents("tr");
            $("#AddExpenseSetPaidFormTab_1 .InputSpinner > input").eq(0).val(CurrentTR.attr("Cash_Amount") || 0)
            $("#AddExpenseSetPaidFormTab_1 .DropDownForForms > button > input").eq(0).val(CurrentTR.attr("Cash_Type") || $("#AddExpenseSetPaidFormTab_1 .DropDownForForms > .dropdown-menu > li:eq(0)").attr("value"))
            $("#AddExpenseSetPaidFormTab_1 .DropDownForForms > button > span").text($("#AddExpenseSetPaidFormTab_1 .DropDownForForms > .dropdown-menu > li[value='" + $("#AddExpenseSetPaidFormTab_1 .DropDownForForms > button > input").eq(0).val() + "']").text());
            $("#AddExpenseSetPaidFormTab_2 .InputSpinner > input").eq(0).val(CurrentTR.attr("Check_Amount") || 0)
            $("#AddExpenseSetPaidFormTab_2 .DropDownForForms > button > input").eq(0).val(CurrentTR.attr("Check_Type") || $("#AddExpenseSetPaidFormTab_2 .DropDownForForms > .dropdown-menu > li:eq(0)").attr("value"))
            $("#AddExpenseSetPaidFormTab_2 .DropDownForForms > button > span").text($("#AddExpenseSetPaidFormTab_2 .DropDownForForms > .dropdown-menu > li[value='" + $("#AddExpenseSetPaidFormTab_2 .DropDownForForms > button > input").eq(0).val() + "']").text());
            $("#AddExpenseSetPaidFormTab_2 .CheckNumValue").eq(0).val(CurrentTR.attr("Check_Num") || "")
            $("#AddExpenseSetPaidFormTab_3 .InputSpinner > input").eq(0).val(CurrentTR.attr("Card_Amount") || 0)
            $("#AddExpenseSetPaidFormTab_3 .DropDownForForms > button > input").eq(0).val(CurrentTR.attr("Card_Type") || $("#AddExpenseSetPaidFormTab_3 .DropDownForForms > .dropdown-menu > li:eq(0)").attr("value"))
            $("#AddExpenseSetPaidFormTab_3 .DropDownForForms > button > span").text($("#AddExpenseSetPaidFormTab_3 .DropDownForForms > .dropdown-menu > li[value='" + $("#AddExpenseSetPaidFormTab_3 .DropDownForForms > button > input").eq(0).val() + "']").text());
            $("#AddExpenseSetPaidFormTab_3 .CardApproval").eq(0).val(CurrentTR.attr("Card_Code") || "")
            $("#SetPaidForm").css({"display": "block"}).clearQueue().delay(10).queue(function () {
                $(this).removeClass("Closed")
            })
        })
        $("#add_expenses").on("shown.bs.modal", function () {
            //            $("#ModalValidationAlert").remove();
            $("#PurchaseInvoiceTotalDetails").html("0");
            $("#InventoryPurchaseTable input:not(.image_file)").val("")
            $("#InventoryPurchaseTable .ImageTD.Added button.Remove").each(function () {
                RemoveCurrentTdFile(this);
            })
        });
        $("body").addClass("NoSearch")
        $("#PurchaseInvoiceDate").datepicker({
            autoclose: true
        }).on("changeDate", function (e) {
            $(this).keyup();
        })
        $("#InventoryPurchaseTable").delegate(".Quantity,.UnitPrice,.Disc", "blur keyup", function (e) {
            var me = $(this), TR = me.parents("tr");
            setTimeout("UpdateTable()", 100);
            if (e.which == 13) {
                if (me.hasClass("Quantity")) {
                    TR.find(".UnitPrice").focus();
                } else if (me.hasClass("UnitPrice")) {
                    TR.find(".Disc").focus();
                } else {
                    TR.next().find(".CODE").focus();
                }
            }
            if (TR.index() < $("#InventoryPurchaseTable tbody").children().length - 1) {
                if ($.trim(me.val()).match(/^\s*?([\d]+(\.\d+)?|\.\d{1,2})\s*$/) == null) {
                    me.addClass("wrong");
                } else {
                    me.removeClass("wrong");
                }
            }
        });
        $("#InventoryPurchaseTable tbody").delegate("> tr input", "keydown", function (e) {
            var me = $(this)
            if (e.which == 8) {
                if (me.val() == "" && !me.hasClass("CODE")) {
                    me.parents("td").prev().find("input").focus();
                } else if (me.val() == "" && me.hasClass("CODE")) {
                    if (me.parents("tr").prev()) {
                        me.parents("tr").prev().find(".Disc").focus();
                    }
                }
            }
        })
        $("#InventoryPurchaseTable tbody").delegate("> tr input", "keyup", function (e) {
            var me = $(this), Parent = me.parents("tbody"), IsLastOneEmpty = true;
            $("tr", Parent).each(function (e) {
                if ($("tr", Parent).length > 1) {
                    var IsEmpty = true;
                    $(this).find("input").each(function () {
                        if ($(this).val() != "")
                            IsEmpty = false;
                    })
                    if (IsEmpty == true) {
                        if ($(this).index() <= $("#InventoryPurchaseTable tbody tr").length - 2) {
                            me.parents("tr").prev().find(".Disc").focus()
                            $(this).remove();
                        }
                    }
                }
            })
            $("tr:last-child input.UnitPrice", Parent).each(function (e) {
                if ($(this).val() != "")
                    IsLastOneEmpty = false;
            })
            if (IsLastOneEmpty == false) {
                var ClonedRow = $("tr:first-child", Parent).clone()
                ClonedRow.find("input").val("")
                ClonedRow.find("input[name=AccountCode]").val('').attr('data-select-name', '')
                Parent.append(ClonedRow);
                $(".Hint,.Total", ClonedRow).html("")
                $("input", ClonedRow).removeClass("wrong")
                $(".select2-container", ClonedRow).remove()
                build_select2($("input[name=AccountCode]", ClonedRow), "xhr/accIDSearch?type=Expense")
                $(".select2-container", ClonedRow).show()
                ClonedRow.find(".ImageTD").removeClass("Added")
                ClonedRow.removeAttr("Cash_Amount Check_Amount Check_Type Check_Num Card_Amount Card_Type Card_Code depRate depPeriod depPeriodName DepDesc DepInvNb")
                UpdateTable();
            }
        })
        $("#CurrencyDropDown li").click(function () {
            $(".CurrencyIndicator").html($(this).attr("mysymbol"))
            setTimeout("ExpenseUpdateSubmitButtonStatus()", 100);
        })
        var Def = $("#CurrencyDropDown li").filter(function () {
            return $(this).attr("value") == $("#CurrencyDropDown input").val();
        })
        if (Def.length > 0) {
            $(".CurrencyIndicator").html(Def.attr("mysymbol"))
            $("> button > span", $("#CurrencyDropDown")).html(Def.text());
        }
        $("#InvoiceForm").validate({
            ignore: ".ignore",
            rules: {
                PurchaseInvoiceDate: {required: true, date: true},
            }
        })
        $("#InvoiceSubmitButton").on("click", ApplyPostMethod);
        $("#AddExpensessearch_supplier").autocomplete({
            source: 'xhr/ajaxVendor',
            minLength: 2,
            select: function (event, ui) {
                var Content = "";
                Content += "<strong><span class='Name'>" + ui.item.Supplier_Name + "</span></strong>";
                Content += "<div><strong>" + CompanyLang + ": </strong><span class='Company'>" + ui.item.Supplier_Company + "</span></div>";
                Content += "<div><strong>" + EmailLang + ": </strong><span class='Address'>" + ui.item.Supplier_Email + "</span></div>";
                Content += "<div><strong>" + PhoneLang + ": </strong><span class='Phone'>" + ui.item.Supplier_Phone + "</span></div>";
                Content += "<div><strong>" + AddressLang + ": </strong><span class='Discount'>" + ui.item.Name + " - " + ui.item.Supplier_Address + "</span></div>";
                Content += "<div><strong>" + CountryLang + ": </strong>" + ui.item.Country_Name + "</div>";
                Content += "<div><strong>" + FinancialNbLang + ": </strong>" + ui.item.Account_Code + "</div>";
                $("#AddExpensesSupplierInfoContent").html(Content)
                $("#AddExpensesSupplier_ID-error").remove()
                $("#AddExpensessearch_supplier").val(ui.item.Supplier_Company)
                $("#AddExpensesSupplier_ID").removeClass("error").val(ui.item.Supplier_ID);
                ExpenseUpdateSubmitButtonStatus()
                return false
            }
        }).autocomplete("instance")._renderItem = function (ul, item) {
            return $("<li>").html("<table cellspacing='0' cellpadding='0'><tr><td class='Column1'><i class='fa fa-file-o'></i></td><td><strong>" + item.Supplier_Name + "</strong></td></tr></table>").appendTo(ul)
        }
        $("#AddExpensessearch_supplier").autocomplete("instance")._resizeMenu = function (ul, items) {
            this.menu.element.outerWidth(this.element.width() + parseFloat(this.element.css("padding-left")) + parseFloat(this.element.css("padding-right")) + 2);
        }
        ExpenseUpdateSubmitButtonStatus();
        $("#InventoryPurchaseTable tbody").delegate("> tr .taxtable", "click", function (e) {
            UpdateTotalForRow($(this).parents('tr'));
            UpdateTable()
        })
        $('#InventoryPurchaseTable').on('click', '.SetDep', function () {
            window.depTR = $(this).parents('tr')
            $('#DepRate').val(depTR.attr('depRate') || '')
            $('#Dep_Period').val(depTR.attr('depPeriod') || 1)
            $('#DepDescription').val(depTR.attr('DepDesc') || '')
            $('#Supplier_Nb').val(depTR.attr('DepInvNb') || '')
            $('#select2-chosen-3').html(depTR.attr('depPeriodName') || '')
            $('#addDepreciation').modal('show')
        })
        $('#SubmitDepreciation').on('click', function () {
            depTR.attr({
                depRate: $('#DepRate').val(),
                depPeriod: $('#Dep_Period').val(),
                depPeriodName: $('#select2-chosen-3').html(),
                DepDesc: $('#DepDescription').val(),
                DepInvNb: $('#Supplier_Nb').val()
            })
            setTimeout(function () {
                $("#addDepreciation").modal('hide')
            }, 1500)
            $("#InvoiceSubmitButton").removeClass('disabled')
        })
        $('#CloseDepreciation').on('click', function () {
            $("#addDepreciation").modal('hide')
        })
        $("#InventoryPurchaseTable tbody").on("change", "input[name=AccountCode]", function () {
            var account = $(this).val();
            CheckAccountCode(account)
        })
    })
    function UpdateTable() {
        TotalInvoice = TotalDiscount = TotalInvoiceWithoutDiscount = 0
        $("#InventoryPurchaseTable tr").each(function () {
            UpdateTotalForRow($(this));
        })
        var InvoiceDiscountInput = parseFloat($("#InvoiceDiscountInput").val()) || 0;
        var TotalInvoiceDisounted = TotalInvoice - (TotalInvoice * (InvoiceDiscountInput / 100))
        $("#PurchaseInvoiceTotalDetails").attr({
            "MyValueNotDiscounted": TotalInvoice, "MyValueDiscounted": TotalInvoiceDisounted
        }).text(AddCommas(public_round_number(TotalInvoiceDisounted)))
        var SubTotalVal = TotalInvoiceWithoutDiscount * (1 - TotalDiscount / 100);
        $("#DiscountVal").html(AddCommas( public_round_number(TotalInvoiceWithoutDiscount - TotalInvoice)))
        $("#InvoiceTotalAfterDiscount").text(AddCommas(public_round_number(TotalInvoiceWithoutDiscount * (InvoiceDiscountInput / 100))))
        setTimeout("ExpenseUpdateSubmitButtonStatus()", 100);
    }
    function ApplyPostMethod() {
        if ($('#search_supplier').val() && $('#search_supplier').select2('data').job_required == 1 && !$('#job_id').val()) {
            toastr.error('<?php echo CommonLanguage::getMessage('job_is_required'); ?>');
            return;
        }
        var IsValidated = true;
        //        $("#ModalValidationAlert").remove();
        //        var AlertBox = $('<div id="ModalValidationAlert" class="WizardValidationAlert alert"></div>'), IsValidated = true, Data = {Expenses: []};
        //        AlertBox.insertAfter($("#add_expenses").find(".modal-dialog .modal-header").find("h5"))
        //if($("#InvoiceForm").valid()) {
        var Data2 = new FormData();
        Data2.append("PurchaseInvoiceDate", $("#PurchaseInvoiceDate").val());
        Data2.append("Supplier_ID", $("#Supplier_ID").val());
        Data2.append("Expense_Date", $("#PurchaseInvoiceDate").val());
        Data2.append("Is_Actual", Is_Actual ? 1 : 0);
        var Data = {Expenses: []};
        $("#InventoryPurchaseTable tbody tr").each(function (e) {
            var me = $(this);
            if (e < $(this).parent().children().length - 1) {

                Data.Expenses.push({
                    Expense_Date: $("#PurchaseInvoiceDate").val(),
                    Expense_Description: me.find(".Description").val(),
                    Expense_Item_Quantity: me.find(".Quantity").val(),
                    Expense_Unit_Price: me.find(".UnitPrice").val(),
                    Account_Code: me.find("[name=AccountCode]").val(),
                    Expense_Total_Price: me.find("td.TotalTD > .Total").attr("myval"),
                    Currency_ID: $("#CurrencyDropDown  input").val(),
                    Expense_Note: $("#Expense_Note ").val(),
                    Expense_VAT: me.find(".taxtable").is(":checked") ? me.find("td.TotalTD > .Total").attr("MyTaxVal") : 0,
                    Supplier_ID: $("#AddExpensesSupplier_ID").val(),
                    Cash_Amount: me.attr("cash_amount") || 0,
                    Check_Amount: me.attr("check_amount") || 0,
                    Card_Amount: me.attr("card_amount") || 0,
                    Cash_Account: me.attr("cash_type") || "",
                    Check_Account: me.attr("check_type") || "",
                    Card_Account: me.attr("card_type") || "",
                    Check_Num: me.attr("check_num") || "",
                    Card_Code: me.attr("card_code") || "",
                    Depreciation_Rate_Percent: me.attr("DepRate") || "",
                    Depreciation_Period_ID: me.attr("DepPeriod") || "",
                    Depreciation_Rate_Description: me.attr("DepDesc") || "",
                    Supplier_Invoice_Number: me.attr("DepInvNb") || ""
                });

                if (me.find(".image_file")[0].files.length > 0) {
                    Data2.append("Image" + (Data.Expenses.length - 1), me.find(".image_file")[0].files[0]);
                } else {
                    Data2.append("Image" + (Data.Expenses.length - 1), "");
                }
                me.find(".Quantity,.UnitPrice").each(function () {
                    if ($.trim($(this).val()) == "" || ($(this).hasClass("isnumber") && $.trim($(this).val()).match(/^\s*?([\d]+(\.\d+)?|\.\d{1,2})\s*$/) == null)) {
                        $(this).addClass("wrong")
                        IsValidated = false;
                    } else {
                        $(this).removeClass("wrong");
                    }
                })
                if ($.trim(me.find(".Description").val()) == "") {
                    me.find(".Description").addClass("wrong")
                    IsValidated = false;
                } else {
                    me.find(".Description").removeClass("wrong");
                }
            }
        })
        Data2.append("Expenses", JSON.stringify(Data.Expenses))
        if (!IsValidated)
            return;
        //        $("#ModalIsBusy").remove()
        //        $("#add_expenses").append('<div id="ModalIsBusy" style="position:absolute;left:0;right:0;top:0px;height:100%;background:rgba(255,255,255,0.9);z-index:9999;opacity:0"><img class="image-responsive-height demo-mw-50" src="img/demo/progress.svg" alt="Progress" style="position: absolute;left: 50%;top: 50%;margin: -25px 0 0 -25px;" /></div>');
        //        $("#ModalIsBusy").animate({
        //            opacity: 1
        //        });
        $.ajax({
            url: "ACCAjax/addExpense",
            method: "POST",
            data: Data2,
            contentType: false,
            processData: false,
            complete: function (v1, v2) {
                if (v2 == 'success') {
                    if (v1.responseText === "success") {
                        $("#ModalIsBusy").remove()
                        $("#ModalValidationAlert").attr("class", "alert alert-success").empty().html(Submitted_Successfully);
                        ChangeTable()
                        setTimeout(function () {
                            $("#add_expenses").modal('toggle');
                            $("#ModalValidationAlert").addClass('hidden')
                        }, 1500);
                    } else {
                        $("#ModalValidationAlert").attr("class", "alert alert-danger").empty().html(v1.responseText);
                    }
                } else {
                    $("#ModalValidationAlert").attr("class", "alert alert-danger").empty().html(Failed_Submit);
                }
                $("#ModalIsBusy").remove();
                //			setTimeout(function(){location.reload();}, 1500)
            }
        })
    }
    function UpdateTotalForRow(who) {
        var Single_Price = parseFloat(who.find(".UnitPrice").val()) || 0,
                Qty = parseFloat(who.find(".Quantity").val()) || 0,
                Total = who.find(".taxtable").is(':checked') ? parseFloat((Single_Price * Qty) * 0.1) + parseFloat(Single_Price * Qty) : Single_Price * Qty,
                Discount = parseFloat(who.find(".Disc").val()) || 0,
                Net_Total = (Total * (1 - Discount / 100)) || 0;
        TotalInvoiceWithoutDiscount += Total;
        TotalDiscount += Discount
        TotalInvoice += Net_Total
        who.find(".Total").attr("MyVal",public_round_number(Net_Total)).text(AddCommas(public_round_number(Net_Total)));
        who.find(".Total").attr("MyTaxVal", who.find(".taxtable").is(':checked') ? (Single_Price * Qty * 0.1) : 0).text(AddCommas( public_round_number(Net_Total)));
    }
    function ExpenseUpdateSubmitButtonStatus() {
        var Rows = $("#InventoryPurchaseTable tbody tr"), DoDisable = false
        if (Rows.length > 0) {
            if (Rows.length == 1) {
                if ($.trim($("input.Description", Rows).val()) != "" && $.trim($("input.Quantity", Rows).val()) != "" && $.trim($("input.UnitPrice", Rows).val()) != "") {
                    DoDisable = false;
                } else {
                    DoDisable = true;
                }
            } else {
                DoDisable = false;
            }
        } else {
            DoDisable = true;
        }
        if ($.trim($("#CurrencyDropDown > button > input").val()) == "")
            DoDisable = true;
        if (DoDisable) {
            $("#InvoiceSubmitButton").addClass("disabled");
        } else {
            $("#InvoiceSubmitButton").removeClass("disabled");
        }
    }
    function ValidateForNewExpensePhoto(input) {
        var IsFileOK = false;
        if (input.files && input.files[0]) {
            var FileName = $.trim(input.files[0].name)
            var FileType = FileName.substring(FileName.lastIndexOf("."));
            if (FileType) {
                FileType = FileType.toLowerCase();
                if (FileType == ".png" || FileType == ".jpg" || FileType == ".jpeg" || FileType == ".pdf") {
                    IsFileOK = true;
                }
            }
            $("#NewExpenseUploadImagePreview,#NewExpenseNoPreviewFileUploadIcon").hide()
            $("#NewExpenseFilewarning2").remove()
            if (IsFileOK == false) {
                $("#NewExpenseNoPreviewFileUploadIcon").show()
                $("<span id='NewExpenseFilewarning2' style='color:#f00;display: block;text-align: center;'> [File not Supported]</span>").insertAfter($(input))
                return false;
            } else {
                var reader = new FileReader();
                reader.onload = function (e) {
                    $("#NewExpenseUploadImagePreview").attr('src', e.target.result).show();
                }
                reader.readAsDataURL(input.files[0]);
                return true;
            }
        }
        return false;
    }
    function RemoveCurrentTdFile(who) {
        var Parent = $(who).parents("td")
        Parent.find(".Add").empty().html('<input type="file" accept="image/*"  class="form-control image_file" onchange="$(this).parents(\'td\').addClass(\'Added\')" />Add')
        Parent.removeClass('Added');
    }
    function InputMustBeAtleastN(who, N) {
        if (parseInt(who.value) < N || !parseInt(who.value))
            who.value = N;
    }
    $("#add_expenses").on('hidden.bs.modal', function () {
        $('#InventoryPurchaseTable input[name!=Currency_ID]').val('');
        $('#AddExpensesSupplierInfoContent').empty();
        setTimeout("ExpenseUpdateSubmitButtonStatus()", 100);
        $('#AddExpensesSupplier_ID-error,#PurchaseInvoiceDate-error').hide()
    })
    $("#add_expenses").on('shown.bs.modal', function () {
        $('#PurchaseInvoiceDate').val(today);
        setTimeout("ExpenseUpdateSubmitButtonStatus()", 100);
    })
    function CheckAccountCode(who) {
        var DoDisable = false;
        if (who.match(/^22[0-9].*$/) || who == 22)
            DoDisable = true;
        if (DoDisable) {
            var alertwar = $("<div id='modalwarning' class='WizardValidationAlert alert alert-danger'><span>" + DepRequired + "</span></div>");
            alertwar.insertAfter($("#add_expenses").find(".modal-dialog .modal-header").find("h5"))
            $(document.body).animate({scrollTop: 0}, 800)
            $("#InvoiceSubmitButton").addClass("disabled");
            $("#modalwarning").fadeOut(10000)
        } else {
            $("#InvoiceSubmitButton").removeClass("disabled");
        }
    }
</script>
