<?php 
//check if current user role is allowed access to the pages
$can_add = ACL::is_allowed("salary_data/add");
$can_edit = ACL::is_allowed("salary_data/edit");
$can_view = ACL::is_allowed("salary_data/view");
$can_delete = ACL::is_allowed("salary_data/delete");
?>
<?php
$comp_model = new SharedController;
$page_element_id = "list-page-" . random_str();
$current_page = $this->set_current_page_link();
$csrf_token = Csrf::$token;
//Page Data From Controller
$view_data = $this->view_data;
$records = $view_data->records;
$record_count = $view_data->record_count;
$total_records = $view_data->total_records;
$field_name = $this->route->field_name;
$field_value = $this->route->field_value;
$view_title = $this->view_title;
$show_header = $this->show_header;
$show_footer = $this->show_footer;
$show_pagination = $this->show_pagination;
?>
<section class="page" id="<?php echo $page_element_id; ?>" data-page-type="list"  data-display-type="table" data-page-url="<?php print_link($current_page); ?>">
    <?php
    if( $show_header == true ){
    ?>
    <div  class="bg-light p-3 mb-3">
        <div class="container-fluid">
            <div class="row ">
                <div class="col ">
                    <h4 class="record-title">Salary Data</h4>
                </div>
                <div class="col-sm-3 ">
                    <?php if($can_add){ ?>
                    <a  class="btn btn btn-primary my-1" href="<?php print_link("salary_data/add") ?>">
                        <i class="fa fa-plus"></i>                              
                        Add New Salary Data 
                    </a>
                    <?php } ?>
                </div>
                <div class="col-sm-4 ">
                    <form  class="search" action="<?php print_link('salary_data/'); ?>" method="get">
                        <div class="input-group">
                            <input value="<?php echo get_value('search'); ?>" class="form-control" type="text" name="search"  placeholder="Search" />
                                <div class="input-group-append">
                                    <button class="btn btn-primary"><i class="fa fa-search"></i></button>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="col-md-12 comp-grid">
                        <div class="">
                            <!-- Page bread crumbs components-->
                            <?php
                            if(!empty($field_name) || !empty($_GET['search'])){
                            ?>
                            <hr class="sm d-block d-sm-none" />
                            <nav class="page-header-breadcrumbs mt-2" aria-label="breadcrumb">
                                <ul class="breadcrumb m-0 p-1">
                                    <?php
                                    if(!empty($field_name)){
                                    ?>
                                    <li class="breadcrumb-item">
                                        <a class="text-decoration-none" href="<?php print_link('salary_data'); ?>">
                                            <i class="fa fa-angle-left"></i>
                                        </a>
                                    </li>
                                    <li class="breadcrumb-item">
                                        <?php echo (get_value("tag") ? get_value("tag")  :  make_readable($field_name)); ?>
                                    </li>
                                    <li  class="breadcrumb-item active text-capitalize font-weight-bold">
                                        <?php echo (get_value("label") ? get_value("label")  :  make_readable(urldecode($field_value))); ?>
                                    </li>
                                    <?php 
                                    }   
                                    ?>
                                    <?php
                                    if(get_value("search")){
                                    ?>
                                    <li class="breadcrumb-item">
                                        <a class="text-decoration-none" href="<?php print_link('salary_data'); ?>">
                                            <i class="fa fa-angle-left"></i>
                                        </a>
                                    </li>
                                    <li class="breadcrumb-item text-capitalize">
                                        Search
                                    </li>
                                    <li  class="breadcrumb-item active text-capitalize font-weight-bold"><?php echo get_value("search"); ?></li>
                                    <?php
                                    }
                                    ?>
                                </ul>
                            </nav>
                            <!--End of Page bread crumbs components-->
                            <?php
                            }
                            ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php
        }
        ?>
        <div  class="">
            <div class="container-fluid">
                <div class="row ">
                    <div class="col-md-12 comp-grid">
                        <?php $this :: display_page_errors(); ?>
                        <div  class=" animated fadeIn page-content">
                            <script src="<?php echo SITE_ADDR; ?>/assets/js/moment.min.js"></script>
                            <script src="<?php echo SITE_ADDR; ?>/assets/plugins/xlsx.core.min.js"></script>
                            <script src="<?php echo SITE_ADDR; ?>/assets/plugins/Blob.js-1.1.1/Blob.min.js"></script>
                            <script src="<?php echo SITE_ADDR; ?>/assets/plugins/FileSaver.js-1.3.6/FileSaver.min.js"></script>
                            <link rel="stylesheet" type="text/css" href="<?php echo SITE_ADDR; ?>/assets/plugins/TableExport-5.2.0/css/tableexport.min.css" />
                                <script src="<?php echo SITE_ADDR; ?>/assets/plugins/TableExport-5.2.0/js/tableexport.min.js"></script>
                                <script src="<?php echo SITE_ADDR; ?>/assets/plugins/PrintPDF/print.min.js"></script>
                                <link rel="stylesheet" type="text/css" href="<?php echo SITE_ADDR; ?>/assets/plugins/PrintPDF/print.min.css">
                                    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.1/css/bootstrap-select.css" />
                                    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js"></script>
                                    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.1/js/bootstrap-select.min.js"></script>
                                    <div id="debit_ledger_name_vendor-trial_balance-records" class="container">
                                        <div  class="row">
                                            <div class="col">
                                                <div class="card mb-3">
                                                    <div class="card-header h4 h4">Salary Sheet Report</div>
                                                    <div class="p-2">
                                                        <div class="row g-2">
                                                            <div class="col">
                                                                <select required=""  id="monthSel" name="month"  placeholder="Select a Month ..."    class="custom-select" >
                                                                    <option value="">Select a Month ...</option>
                                                                    <option value="All">All</option>
                                                                    <option  value="1">January</option>
                                                                    <option  value="2">February</option>
                                                                    <option  value="3">March</option>
                                                                    <option  value="4">April</option>
                                                                    <option  value="5">May</option>
                                                                    <option  value="6">June</option>
                                                                    <option  value="7">July</option>
                                                                    <option  value="8">August</option>
                                                                    <option  value="9">September</option>
                                                                    <option  value="10">October</option>
                                                                    <option  value="11">November</option>
                                                                    <option  value="12">December</option>
                                                                </select>
                                                            </div>
                                                            <div class="col">
                                                                <select required=""  id="yearSel" name="year"  placeholder="Select a Year ..."    class="custom-select" >
                                                                    <option value="">Select a Year ...</option>
                                                                    <option value="All">All</option>
                                                                    <?php 
                                                                    $year_options = $comp_model -> month_locking_year_option_list();
                                                                    if(!empty($year_options)){
                                                                    foreach($year_options as $option){
                                                                    $value = (!empty($option['value']) ? $option['value'] : null);
                                                                    $label = (!empty($option['label']) ? $option['label'] : $value);
                                                                    $selected = $this->set_field_selected('year',$value, "");
                                                                    ?>
                                                                    <option <?php echo $selected; ?> value="<?php echo $value; ?>">
                                                                        <?php echo $label; ?>
                                                                    </option>
                                                                    <?php
                                                                    }
                                                                    }
                                                                    ?>
                                                                </select>
                                                            </div>
                                                            <div class="col">
                                                                <select required=""  id="profileSel" select required=""  id="ctrl-pid" data-load-select-options="prct_value_1,prct_value_2" name="pid"  placeholder="Select a value ..."    class="custom-select" name="portfolio_id"  placeholder="Select a Profile ..."    class="custom-select" >
                                                                    <option value="">Select a Profile ...</option>
                                                                    <option value="All">All</option>
                                                                    <?php 
                                                                    $portfolio_id_options = $comp_model -> employee_details_portfolio_id_option_list();
                                                                    if(!empty($portfolio_id_options)){
                                                                    foreach($portfolio_id_options as $option){
                                                                    $value = (!empty($option['value']) ? $option['value'] : null);
                                                                    $label = (!empty($option['label']) ? $option['label'] : $value);
                                                                    $selected = $this->set_field_selected('portfolio_id',$value, "");
                                                                    ?>
                                                                    <option <?php echo $selected; ?> value="<?php echo $value; ?>">
                                                                        <?php echo $label; ?>
                                                                    </option>
                                                                    <?php
                                                                    }
                                                                    }
                                                                    ?>
                                                                </select>
                                                            </div>
                                                            <div class="col ">
                                                                <div class="row">
                                                                    <div class="col">
                                                                        <div class="">
                                                                            <select  id="ctrl-prct_value_1" data-load-path="<?php print_link('api/json/portfolio_configurations_prct_value_1_option_list_2') ?>" name="prct_value_2"  placeholder="Select a value ..."    class=" form-control   custom-select"   multiple data-live-search="true">
                                                                                <!--<option value="">Select a Col Name</option>-->
                                                                            </select>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="col">
                                                                <select required=""  id="ctrl-dept" name="prct_value_operation"  placeholder="Select a value ..."    class="custom-select" >
                                                                    <option value="">Select a Department ...</option>
                                                                    <option value="All">All</option>
                                                                    <?php 
                                                                    $prct_value_operation_options = $comp_model -> portfolio_configurations_prct_value_operation_option_list();
                                                                    if(!empty($prct_value_operation_options)){
                                                                    foreach($prct_value_operation_options as $option){
                                                                    $value = (!empty($option['value']) ? $option['value'] : null);
                                                                    $label = (!empty($option['label']) ? $option['label'] : $value);
                                                                    $selected = $this->set_field_selected('prct_value_operation',$value, "");
                                                                    ?>
                                                                    <option <?php echo $selected; ?> value="<?php echo $value; ?>">
                                                                        <?php echo $label; ?>
                                                                    </option>
                                                                    <?php
                                                                    }
                                                                    }
                                                                    ?>
                                                                </select>
                                                            </div>
                                                            <div class="col-auto">
                                                                <button id="get_data_salary_sheet_COLWSIE" class="btn btn-primary">GET DATA</button>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div id="page-report-body" class="mb-5"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
