<link rel="stylesheet" type="text/css" href="<?= base_url() ?>assets/css/style.css">
<script type="text/javascript" src="<?= base_url() ?>assets/js/product.js"></script>
<script type="text/javascript" src="<?= base_url() ?>assets/js/common_validation.js"></script>
<style type="text/css">
    .ui-menu {
        z-index: 10000 !important;
    }
</style>

<!-- Page Content -->
<div class="page-content">
    <!-- Page Header -->
    <div class="page-header position-relative">
        <div class="header-title"><h1><?php echo $this->lang->line("PRODUCTS"); ?></h1></div>
        <!--Header Buttons-->
        <div class="header-buttons">
            <a class="sidebar-toggler" href="#"><i class="fa fa-arrows-h"></i></a>
            <a class="refresh" id="refresh-toggler" href=""><i class="glyphicon glyphicon-refresh"></i></a>
            <a class="fullscreen" id="fullscreen-toggler" href="#"><i class="glyphicon glyphicon-fullscreen"></i></a>
        </div>
        <!--Header Buttons End-->
    </div>
    <!-- /Page Header -->
    <!-- Page Body -->
    <div class="page-body">
        <div class="row">
            <div class="col-xs-12 col-md-12">
                <div class="widget">
                    <?php if ($this->session->flashdata('success_msg')) { ?>
                        <div class="alert alert-success">
                            <a href="#" class="close" data-dismiss="alert">&times;</a>
                            <?php echo $this->session->flashdata('success_msg'); $this->session->unset_userdata('success_msg');?>
                        </div>
                    <?php } ?>
                    <div id="modal-success" class="modal modal-message modal-success" style="display: none;">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <i class="glyphicon glyphicon-check"></i>
                                </div>
                                <div class="modal-title"><?php echo $this->lang->line("DELETEDSUCCESSFULLY"); ?></div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-success"  data-dismiss="modal-success"><?php echo $this->lang->line("OK"); ?></button>
                                </div>
                            </div> <!-- / .modal-content -->
                        </div> <!-- / .modal-dialog -->
                    </div>
                    <div class="widget-body">
                        <div class="table-toolbar">
                            <div class="form-group" style="margin-bottom: 0px;"> 
                                <a type="button" class="btn btn-success shiny icon-only new" data-toggle="modal"
                                   data-target="#myModal" href="javascript:void(0);" id="add_btn">
                                    <i class="fa fa-plus"></i></a>
                                <input type="text" class="dt-column_div"
                                       placeholder="<?php echo $this->lang->line("SEARCHBYBARCODE"); ?>"
                                       id="searchbarcode" name="searchbarcode" />
                                <select class="dt-column_div" id="searchbyitemtype" name="searchbyitemtype" >
                                    <option value=""><?php echo $this->lang->line("SEARCHBYTYPE"); ?></option>
                                    <option value="P"><?php echo $this->lang->line("PRODUCTS"); ?></option>
                                    <option value="M"><?php echo $this->lang->line("MATERIAL"); ?></option>
                                </select>
                                <select class="dt-column_div" id="searchbycategory" name="searchbycategory" >
                                    <option value="">Search by Category</option>
                                    <?php
                                    if($categories) {
                                        foreach($categories as $catrec) {
                                    ?>
                                        <option value="<?php echo $catrec->ID; ?>"><?php echo $catrec->NAME; ?></option>
                                    <?php
                                        }
                                    }
                                    ?>
                                </select>
                            </div>
                            
                            <div id="exportModal" class="modal modal-message modal-success">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <?php echo $this->lang->line("DOWNLOADING"); ?>
                                        </div>
                                        <div class="modal-title">
                                            <div class="col-sm-6"> <i class="fa fa-file-text-o fa-2x pdtexport" aria-hidden="true" id="pdf_export"></i>
                                                <br><span style="font-size: 13px;cursor: pointer;"><?php echo $this->lang->line("PDF"); ?></span></div>
                                            <div class="col-sm-6"><i class="fa fa-file-excel-o fa-2x pdtexport" aria-hidden="true" id="excel_export"></i>
                                                <br><span style="font-size: 13px;"><?php echo $this->lang->line("EXCEL"); ?></span></div>
                                        </div>
                                        <div class="modal-footer">

                                        </div>
                                    </div> <!-- / .modal-content -->
                                </div> <!-- / .modal-dialog -->
                            </div>
                            <div id="myModal" class="modal fade" data-backdrop="static" role="dialog">
                                <div class="modal-dialog">
                                    <!-- Modal content-->
                                    <div class="modal-content">
                                        <form action="" method="post" id="form1" name="form1" enctype="multipart/form-data">
                                            <div class="modal-header">
                                                <button type="button" class="close" id="modal_close" data-dismiss="modal">&times;</button>
                                                <h4 class="modal-title"><?php echo $this->lang->line("PRODUCTDETAILS"); ?></h4>
                                            </div>
                                            <div class="modal-body">
                                                <div class="row">
                                                    <div class="col-lg-12 col-sm-12 col-xs-12">
                                                        <div id="simplewizard" class="wizard" data-target="#simplewizard-steps">
                                                            <ul class="steps">
                                                                <li data-target="#simplewizardstep1" class="active general_tabs" id="general_tabs1">
                                                                    <?php echo $this->lang->line("GENERAL"); ?>
                                                                    <span class="chevron"></span>
                                                                </li>
                                                                <li data-target="#productimage_div" class="general_tabs" id="productimage">
                                                                    <?php echo $this->lang->line("IMAGE"); ?>
                                                                    <span class="chevron"></span>
                                                                </li>
                                                                <li data-target="#simplewizardstep2" class="general_tabs" id="general_tabs2">
                                                                    <?php echo $this->lang->line("STOCK"); ?>
                                                                    <span class="chevron"></span>
                                                                </li>
                                                                <li data-target="#simplewizardstep3" class="general_tabs" id="general_tabs3">
                                                                    <?php echo $this->lang->line("PROPORTIES"); ?>
                                                                    <span class="chevron"></span>
                                                                </li>
                                                                <li data-target="#simplewizardstep4" class="general_tabs" id="general_tabs4" style="display: none;">
                                                                    <?php echo $this->lang->line("BREAKDOWN"); ?>
                                                                    <span class="chevron"></span>
                                                                </li>
                                                            </ul>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-12 addmargin display_error" style="margin-top: 10px;"></div>                 
                                                    <div class="col-md-12 addmargin success_msg" style="margin-top: 10px;">
                                                        <?php echo $this->lang->line("RECORDADDEDSUCCESSFULLY"); ?>
                                                    </div> 
                                                    <div class="col-lg-12 col-sm-12 col-xs-12 general_tabs_div" id="general_tabs1_div" >            
                                                        <div id="horizontal-form">   
                                                            <div class="form-group">
                                                                <label for="inputEmail3" class="col-sm-3 control-label no-padding-right">
                                                                    <?php echo $this->lang->line("REFERENCENO"); ?> <span class="mandatory">*</span></label>
                                                                <div class="col-sm-8 addmargin">
                                                                    <input type="text" class="form-control" id="reference" name="reference"
                                                                           placeholder="<?php echo $this->lang->line("REFERENCENO"); ?>">
                                                                </div>
                                                                <div class="col-sm-1">
                                                                    <i class="fa fa-plus btn" aria-hidden="true" id="reference_id"></i>
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label for="inputEmail3" class="col-sm-3 control-label no-padding-right">
                                                                    <?php echo $this->lang->line("BARCODE"); ?> <span class="mandatory">*</span></label>
                                                                <div class="col-sm-8 addmargin">
                                                                    <input type="text" class="form-control" id="code" name="code"
                                                                           placeholder="<?php echo $this->lang->line("BARCODE"); ?>">
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label for="inputEmail3" class="col-sm-3 control-label no-padding-right"><?php echo $this->lang->line("NAME"); ?> <span class="mandatory">*</span></label>
                                                                <div class="col-sm-8 addmargin">
                                                                    <input type="text" class="form-control" id="name" name="name" placeholder="<?php echo $this->lang->line("NAME"); ?>">
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label for="inputEmail3" class="col-sm-3 control-label no-padding-right">
                                                                    <?php echo $this->lang->line("PRODUCTCATEGORY"); ?>
                                                                    <span class="mandatory">*</span></label>
                                                                <div class="col-sm-8 addmargin">
                                                                    <select name="category" id="category" class="form-control">
                                                                        <option value="">--- <?php echo $this->lang->line("SELECT"); ?> ---</option>
                                                                        <?php foreach ($categories as $categories_list) { ?>
                                                                            <option value="<?php echo $categories_list->ID; ?>"><?php echo $categories_list->NAME; ?></option>
                                                                        <?php } ?>
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label for="inputEmail3" class="col-sm-3 control-label no-padding-right"><?php echo $this->lang->line("TAXCATEGORY"); ?> <span class="mandatory">*</span></label>
                                                                <div class="col-sm-8 addmargin">
                                                                    <select name="taxcat" id="taxcat" class="form-control">
                                                                        <option value="">--- <?php echo $this->lang->line("SELECT"); ?> ---</option> 
                                                                        <?php foreach ($tax_categories as $tax_categories_list) { ?>
                                                                            <option value="<?php echo $tax_categories_list->ID; ?>"><?php echo $tax_categories_list->NAME; ?></option>
                                                                        <?php } ?>                             
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label for="inputEmail3" class="col-sm-3 control-label no-padding-right">
                                                                    <?php echo $this->lang->line("PRICEBUY"); ?>
                                                                    </label>
                                                                <div class="col-sm-8 addmargin">
                                                                    <input type="text" class="form-control" id="pricebuy" name="pricebuy"
                                                                           placeholder="<?php echo $this->lang->line("PRICEBUY"); ?>" onkeypress="javascript:return isNumber(event)">

                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label for="inputEmail3" class="col-sm-3 control-label no-padding-right"><?php echo $this->lang->line("PRICESELL"); ?> <span class="mandatory">*</span></label>
                                                                <div class="col-sm-4 addmargin">
                                                                    <input type="text" class="form-control" id="sellpricehd" name="sellpricehd" placeholder="<?php echo $this->lang->line("PRICESELL"); ?> " onkeypress="javascript:return isNumber(event)">
                                                                    <input type="hidden" class="form-control" id="pricesell" name="pricesell" />
                                                                </div>
                                                                <div class="col-sm-4 addmargin">
                                                                    <input type="text" class="form-control" id="profit" name="profit" placeholder="<?php echo $this->lang->line("PROFITINPERCENTAGE"); ?>" onkeypress="javascript:return isNumber(event)">  
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label for="inputEmail3" class="col-sm-3 control-label no-padding-right">
                                                                <?php echo $this->lang->line("SELLPRICEPLUSTAX"); ?>
                                                                </label>
                                                                <div class="col-sm-8 addmargin">
                                                                    <input type="text" class="form-control" id="sellpricewithtax" name="sellpricewithtax"
                                                                           placeholder="<?php echo $this->lang->line("SELLPRICEPLUSTAX"); ?>" onkeypress="javascript:return isNumber(event)">
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label for="inputEmail3" class="col-sm-3 control-label no-padding-right">
                                                                    <?php echo $this->lang->line("ATTRIBUTES"); ?>
                                                                </label>
                                                                <div class="col-sm-8 addmargin">
                                                                    <select name="attributeset_id" id="attributeset_id" class="form-control">
                                                                        <option value="">--- <?php echo $this->lang->line("SELECT"); ?> ---</option>  
                                                                        <?php if($attributeset) { foreach ($attributeset as $attributeset_list) { ?>
                                                                            <option value="<?php echo $attributeset_list->ID; ?>"><?php echo $attributeset_list->NAME; ?></option>
                                                                        <?php } } ?>                            
                                                                    </select>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    
                                                    <div class="col-lg-12 col-sm-12 col-xs-12 general_tabs_div" id="productimage_div">
                                                        <div class="row">
                                                            <div class="col-xs-12 col-sm-8 col-md-8 form-group" style="margin-top: 20px;">
                                                                <span class="file-input btn btn-azure btn-file">
                                                                    Browse <input type="file" name="productimage" id="productimage" class="inp-form form-control" />
                                                                </span>
                                                            </div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-xs-12 col-sm-8 col-md-10">
                                                                <img src="" id="productimageview" width="150" />
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-12 col-sm-12 col-xs-12 general_tabs_div" id="general_tabs2_div" style="display: none;">
                                                        <div id="horizontal-form">                    
                                                            <div class="form-group">
                                                                <label for="inputEmail3" class="col-sm-3 control-label no-padding-right">
                                                                <?php echo $this->lang->line("STOCKCOSTBYYEAR"); ?>
                                                                </label>
                                                                <div class="col-sm-8 addmargin">
                                                                    <input type="text" class="form-control" id="stock_cost_by_year" name="stock_cost_by_year"
                                                                           placeholder="<?php echo $this->lang->line("STOCKCOSTBYYEAR"); ?>">
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label for="inputEmail3" class="col-sm-3 control-label no-padding-right">
                                                                <?php echo $this->lang->line("STOCKVOLUME"); ?>
                                                                </label>
                                                                <div class="col-sm-8 addmargin">
                                                                    <input type="text" class="form-control" id="stock_volume"
                                                                        name="stock_volume" placeholder="<?php echo $this->lang->line("STOCKVOLUME"); ?>" />
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label for="inputEmail3" class="col-sm-3 control-label no-padding-right"><?php echo $this->lang->line("INCATALOG"); ?></label>
                                                                <div class="col-sm-1">
                                                                    <div class="checkbox">
                                                                        <label>
                                                                            <input type="checkbox" class="inverted" id="incatalog" name="incat" checked />
                                                                            <span class="text"></span>
                                                                        </label>
                                                                    </div>
                                                                </div>
                                                                <div class="col-sm-7 addmargin">
                                                                    <input type="text" class="form-control" id="order" name="catorder" placeholder="<?php echo $this->lang->line("ORDER"); ?>" disabled="disabled" onkeypress="javascript:return isNumber(event)">
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label for="inputEmail3" class="col-sm-3 control-label no-padding-right"><?php echo $this->lang->line("AUXILARY"); ?></label>
                                                                <div class="col-sm-8">
                                                                    <div class="checkbox">
                                                                        <label>
                                                                            <input type="checkbox" class="inverted" id="auxilary" name="iscom">
                                                                            <span class="text"></span>
                                                                        </label>
                                                                    </div>
                                                                </div>
                                                            </div>       
                                                            <div class="form-group">
                                                                <label for="inputEmail3" class="col-sm-3 control-label no-padding-right"><?php echo $this->lang->line("SCALE"); ?></label>
                                                                <div class="col-sm-8">
                                                                    <div class="checkbox">
                                                                        <label>
                                                                            <input type="checkbox" class="inverted" id="scale" name="isscale">
                                                                            <span class="text"></span>
                                                                        </label>
                                                                    </div>
                                                                </div>
                                                            </div> 
                                                            <div class="form-group">
                                                                <label for="inputEmail3" class="col-sm-3 control-label no-padding-right"><?php echo $this->lang->line("BREAKDOWN"); ?></label>
                                                                <div class="col-sm-8">
                                                                    <div class="checkbox">
                                                                        <label>
                                                                            <input type="checkbox" class="inverted" id="breakdown">
                                                                            <span class="text"></span>
                                                                        </label>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label for="inputEmail3" class="col-sm-3 control-label no-padding-right"><?php echo $this->lang->line("MATERIAL"); ?></label>
                                                                <div class="col-sm-8">
                                                                    <div class="checkbox">
                                                                        <label>
                                                                            <input type="checkbox" class="inverted" id="ITEMTYPE" name="ITEMTYPE" />
                                                                            <span class="text"></span>
                                                                        </label>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            
                                                        </div>
                                                    </div>
                                                    <div class="col-lg-12 col-sm-12 col-xs-12 general_tabs_div" id="general_tabs3_div" style="display: none;">            
                                                        <div id="horizontal-form">
                                                            <div class="form-group" style="margin-top: 10px;"> 
                                                                <textarea class="form-control propoties_textarea" name="proporties"><?php if (isset($resources[0]->CONTENT)) { echo ($resources[0]->CONTENT); } ?></textarea>
                                                            </div>  
                                                        </div>  
                                                    </div>
                                                    <div class="col-lg-12 col-sm-12 col-xs-12 general_tabs_div" id="general_tabs4_div" style="display: none;">            
                                                        <div id="horizontal-form">
                                                            <div class="form-group" style="margin-top: 10px;">
    <table id="example7" class="table table-bordered table-striped">
        <thead>
            <tr>
                <th class="addwidth" style="width:25%;padding: 0px;margin: 0px;">
                    <input type="text" name="txtbarcode" id="txtbarcode" class="inp-form form-control" placeholder="Enter barcode" style="height: 33px;width: 100%;" />
                </th>
                <th style="padding: 0px;margin: 0px;width:50%;">
<!--                    <select role="select" name="txtitemname" id="txtitemname" style="height: 33px;width: 100%;" 
                            onchange="selectitemname(this.options[this.selectedIndex].getAttribute('pricebuy'),this.value,
                            this.options[this.selectedIndex].getAttribute('barcode'))">
                        <option value=""><?php // echo $this->lang->line("SELECTPRODUCT"); ?></option>
                    </select>-->
                    <div class="input-group" style="width: 100%;">
                        <a href="#" data-toggle="modal" data-target="#MYMODALPRODUCT">
                            <div class="form-control" id="txtitemname"></div>
                        </a>
                        <span class="input-group-btn">
                            <a href="#" class="btn btn-sky shiny" data-toggle="modal" data-target="#MYMODALPRODUCT">
                                <i class="fa fa-search"></i>
                                <?php echo $this->lang->line("BROWSE"); ?></a>
                        </span>
                    </div>
                    <input type="hidden" name="txtproductid" id="txtproductid" />
                    <input type="hidden" name="txtproductbuyprice" id="txtproductbuyprice" />
                </th>
                <th class="addwidth" style="padding: 0px;margin: 0px;width:19%;">
                    <input type="number" name="txtqty" id="txtqty" placeholder="Enter Quantity" style="height: 33px;width: 100%;" />
                </th>
                <th style="width: 6%;padding: 0px;margin: 0px;vertical-align: middle;text-align: center;">
                    <button onclick="save_brk_dwn();" type="button" id="brk_add" class="btn btn-success btn-xs shiny">
                        <i class="fa fa-plus" aria-hidden="true"></i></button>
                </th>
            </tr>
            <tr>
                <th class="addwidth"><?php echo $this->lang->line("BARCODE"); ?></th>
                <th><?php echo $this->lang->line("MATERIAL"); ?></th>
                <th class="addwidth"><?php echo $this->lang->line("UNIT"); ?></th>
                <th style="width: 10px;"></th>
            </tr>
        </thead>
        <tbody id="tr_brk_dwn">
        </tbody>
    </table>
                                                                <input type="hidden" name="hdcounter" id="hdcounter" value="0" class="hiddenfiled">
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>    
                                            </div>
                                    </div>
                                    <div class="modal-footer">
                                        <input type="hidden" name="id" id="id">
                                        <button type="submit" class="btn btn-success shiny save_btns" id="btn_save" name="save"><?php echo $this->lang->line("SAVE"); ?></button>
                                        <button type="submit" class="btn btn-success shiny save_btns" id="save_new" name="save_new"><?php echo $this->lang->line("SAVEANDNEW"); ?></button>
                                        <button type="button" class="btn btn-danger" id="modal_close" data-dismiss="modal"><?php echo $this->lang->line("CLOSE"); ?></button>
                                    </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <div id="confirmmodal" class="modal fade" role="dialog">
                            <div class="modal-dialog">
                                <!-- Modal content-->
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                                        <h4 class="modal-title"><?php echo $this->lang->line("AREYOUSURETODELETE"); ?></h4>
                                        <p class="display_error"><?php echo $this->lang->line("CANTDELETEPRODUCTUSED"); ?></p>
                                    </div>
                                    <div class="modal-footer">
                                        <input type="hidden" id="okid" value="">
                                        <button type="button" class="btn btn-success shiny" onclick="return deleteFunction()"><?php echo $this->lang->line("OK"); ?></button>
                                        <button type="button" class="btn btn-danger shiny" data-dismiss="modal"><?php echo $this->lang->line("CLOSE"); ?></button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <input type="hidden" name="currencyDecimel" id="currencyDecimel" value="<?php echo $currencyDecimel; ?>">
                        <div class="table-responsive">  
                            <div id="myTable_processing" class="dataTables_processing" style="display: none;">Processing...</div>
                            <table class="table table-striped table-hover table-bordered editable" id="productsdatatable">
                                <thead>
                                    <tr role="row">
                                        <th><?php echo $this->lang->line("SL"); ?></th>
                                        <th><?php echo $this->lang->line("CATEGORY"); ?></th>
                                        <th><?php echo $this->lang->line("REFERENCE"); ?></th>
                                        <th><?php echo $this->lang->line("CODE"); ?></th>
                                        <th><?php echo $this->lang->line("NAME"); ?></th>
                                        <th><?php echo $this->lang->line("PRICEBUY"); ?></th>
                                        <th><?php echo $this->lang->line("PRICESELL"); ?></th>
                                        <th><?php echo $this->lang->line("TAX"); ?></th>
                                        <th><?php echo $this->lang->line("SELLPRICEPLUSTAX"); ?></th>
                                        <th style="width: 120px;"><?php echo $this->lang->line("ACTION"); ?></th>
                                    </tr>
                                </thead>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- /Page Body -->
</div>
<!-- /Page Content -->
</div>
<div id="MYMODALPRODUCT" class="modal fade" role="dialog">
    <div class="modal-dialog">
        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-body">
                <div class="widget-body no-padding" id="productlistselect" style="box-shadow: none;">
                    <table class="table table-bordered table-hover table-striped" id="productsdatatablelist" style="padding: 6px !important;">
                        <thead class="bordered-darkorange">
                            <tr role="row">
                                <th><?php echo $this->lang->line("CATEGORY"); ?></th>
                                <th><?php echo $this->lang->line("REFERENCE"); ?></th>
                                <th><?php echo $this->lang->line("CODE"); ?></th>
                                <th><?php echo $this->lang->line("NAME"); ?></th>
                                <th><?php echo $this->lang->line("PRICEBUY"); ?></th>
                                <th><?php echo $this->lang->line("PRICESELL"); ?></th>
                                <th><?php echo $this->lang->line("STOCKVALUE"); ?></th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- /Page Container -->
<!-- Main Container -->
<script src="<?php echo base_url();?>assets/js/dropzone/dropzone.min.js"></script>
<script src="<?php echo base_url();?>assets/js/select2/select2.js"></script>
<style type="text/css">
    #productsdatatable td:nth-child(1){
        text-align: center;
    }

    #productsdatatable td:nth-child(6),td:nth-child(7),td:nth-child(9){
        text-align: right;
    }
</style>
<script type="text/javascript">
    $(document).ajaxStop(function () {
        $('.dataTables_processing').hide();
    });

    $(document).ajaxStart(function () {
        $('.dataTables_processing').show();
    }); 
    
    function selectitemname(pricebuy='',id='',barcode='',prname='',pricesell='') {
        $('#txtproductid').val(id);
        $('#txtproductbuyprice').val(pricebuy);
        $('#txtbarcode').val(barcode);
        $('#txtqty').focus();
        $('#txtitemname').html(prname);
        $('#MYMODALPRODUCT').modal('hide');
    }
    
    
    function save_brk_dwn() {
        var txtproductid = $('#txtproductid').val();
        var txtproductbuyprice = $('#txtproductbuyprice').val();
        var txtbarcode = $('#txtbarcode').val();
        var txtqty = $('#txtqty').val();
        var txtitemname = $('#txtitemname').text();
        var tabledata =  "<tr>";
        if(txtproductid!='' && txtqty!='') {
            tabledata =  tabledata+"<td><input type='hidden' class='' name='brk_material[]' value='"+txtproductid+"' />\n\
                <input type='hidden' class='brk_price' value='"+(txtproductbuyprice*txtqty)+"' />\n\
                <input type='hidden' class='brk_units' name='brk_units[]' value='"+txtqty+"' />\n\
                "+txtbarcode+"</td><td>"+txtitemname+"</td><td>"+txtqty+"</td><td><button onclick='removerow(this);' type='button' \n\
                 class='btn btn-danger btn-xs shiny'><i class='fa fa-trash' aria-hidden='true'></i></button></td></tr>";
            $("#tr_brk_dwn").append(tabledata);
            $('#txtproductid').val('');
            $('#txtproductbuyprice').val('');
            $('#txtbarcode').val('');
            $('#txtqty').val('');
            $('#txtitemname').html('');
            calculatetotalprice();
        }
    }
    function calculatetotalprice() {
        var inputs = $(".brk_price");
        var totalamt=0;
        for(var i = 0; i < inputs.length; i++){
            totalamt = parseFloat(totalamt)+parseFloat($(inputs[i]).val());
        }
        $("#pricebuy").val(totalamt);
    }
    function removerow(Obj='') {
        Obj.closest('tr').remove();
        calculatetotalprice();
    }
   
    
</script>