<style>
.submit_pdf {
    background-image: url(./assets/images/file-icons/pdf.png);
    border: 0px;
    background-color: #FFFFFF;
    color: transparent;
    margin: 5px 0 10px 0;
    height: 25px;
    width: 25px;
	float:none !important;
}
.submit_excel {
    background-image: url(./assets/images/file-icons/xlsx.png);
    border: 0px;
    background-color: #FFFFFF;
    color: transparent;
    margin: 5px 0 10px 20px;
    height: 25px;
    width: 25px;
}
</style>
<aside class="right-side">
    <section class="content-header">
        <div class="title_bar">
            <h1 class="major_txt_color"><?php echo $title;?></h1>
            <div class="breadcrumb_container"><?php echo breadcrumb_links();?></div>
        </div>
    </section>
    <?php $general = get_general_setting();?>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <!-- /.box -->
                <div class="box box-primary">
                    <div class="box-body table-responsive">
                        <form name="get_data_search" action="<?php echo $form_action;?>" method="post" class="search_form validate_form">
                            <div class="col-xs-12">
                                <div class="col-md-6">
                                	<div class="form-group">
                                        <label>Category</label>
                                        <select name="category_id" id="category_id" class="form-control select2 category_id" data-placeholder="Select Category">
                                            <option value="">Select Category</option>
                                            <?php foreach ($category as $key => $value) {?>
                                                <option value="<?php echo $value->id; ?>" <?php if($value->id == $category_id){ ?>selected<?php } ?>><?php echo $value->category_name; ?></option>
                                            <?php } ?>
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        <label >Start Date</label>
                                        <div class="input-group">
                                            <div class="input-group-addon">
                                                <i class="fa fa-calendar"></i>
                                            </div>
                                            <input type="text" class="start_date" placeholder="DD-MM-YYYY" style="padding: 6px 12px;margin-right:5%;width:100%;" id="start_date" name="start_date" value="<?php echo (!empty($start_date)) ? $start_date : date('d-m-Y');?>" autocomplete="off" >
                                            
                                        </div>
                                    </div>                                    
                                </div>
                                <div class="col-md-6">
                                	<div class="form-group">
                                        <label>Sub Category</label>
                                        <select name="item_id" id="item_id" class="form-control select2 item_id" data-placeholder="Select Sub Category">
                                            <option value="">Select Sub Category</option> 
										    <?php if(!empty($category_id) && isset($category_items)){ ?>
												<?php foreach($category_items as $item){ ?>
													<option value="<?php echo $item['id']; ?>" <?php if($item['id'] == $item_id){ ?>selected<?php } ?>><?php echo $item['name']; ?></option>
												<?php } ?>
											<?php } ?>											
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        <label >End Date</label>
                                        <div class="input-group">
                                            <div class="input-group-addon">
                                                <i class="fa fa-calendar"></i>
                                            </div>                                          
                                            <input type="text" class="end_date" placeholder="DD-MM-YYYY" style="padding: 6px 12px;margin-right:5%;width:100%;"  id="end_date" name="end_date" value="<?php echo (!empty($end_date)) ? $end_date : date('d-m-Y');?>" autocomplete="off" >
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-xs-12">
                                <div class="col-md-3">&nbsp;</div>
                                <div class="col-md-6" style="text-align: center;">
                                    <input type="submit" value="Submit" name="submit" class="btn btn-danger btn-sm" style="background-color: #e33739; border-color: #e33739;margin-right: 10px;" />
                                    <input type="submit" value="Print Data" name="submit" class="btn btn-primary btn-sm" style="margin-right: 10px;" />
                                  <!--  <input type="submit" name="submit" value="<?php echo (!empty($pdftype)) ? $pdftype : 'Pdf Data';?>" class="submit_pdf" title="Export PDF" />-->
                                    <input type="submit" name="submit" value="<?php echo (!empty($exceltype)) ? $exceltype : 'Excel Data';?>" class="submit_excel" title="Export Excel" />
                                </div>                                
                                <div class="col-md-3">&nbsp;</div>
                            </div>
                        </form>
                    </div>
                    <div class="box-body table-responsive" style="clear:both;">                       
                        <div style="max-height: 410px; overflow-y: auto;">
                            <table class="table table-bordered table-striped filterTable" id="filterTable">
                                <thead>
                                    <tr>
                                        <th width="5%" class="align-center">S.No</th>
                                        <th class="align-center">Name</th>
                                        <th class="align-center">Star</th>
                                        <th class="align-center">Name1</th>
                                        <th class="align-center">Star1</th>
                                        <th class="align-center">Name2</th>
                                        <th class="align-center">Star2</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php 
                                    $start_date = (!empty($start_date)) ? $start_date : date('d-m-Y');                                  
                                    $end_date 	= (!empty($end_date)) ? $end_date : date('d-m-Y');
                                    
									if(count($results) > 0) { 
                                        $i = 0;
                                        foreach( $results as $key => $row) :
                                            if(!empty($row['bar_name_1']) || !empty($row['bar_name_2']) || !empty($row['bar_name_3'])) {
                                    ?>
                                            <tr>
                                                <td class="align-center"><?php echo ++$i;?></td>
                                                <td><?php echo (!empty($row['bar_name_1'])) ? '<span class="lang-tamil">' . $row['bar_name_1'] . '</span>' : 'N/A';?></td>
												<td><?php echo $row['star_name1']; ?></td>
                                                <td><?php echo (!empty($row['bar_name_2'])) ? '<span class="lang-tamil">' . $row['bar_name_2'] . '</span>' : 'N/A';?></td>
												<td><?php echo $row['star_name2']; ?></td>
                                                <td><?php echo (!empty($row['bar_name_3'])) ? '<span class="lang-tamil">' . $row['bar_name_3'] . '</span>' : 'N/A';?></td>				
												<td><?php echo $row['star_name3']; ?></td>
                                                
                                            </tr>
                                    <?php } endforeach; ?>                                       
                                    <?php } else {?>
                                        <tr>
                                            <td colspan="7" style="color: #0B6CCB;"><center>No Records Found!</center></td>
                                        </tr>
                                    <?php } ?>
                                </tbody>        
                            </table>
                        </div>
                    </div><!-- /.box-body -->
                    
                </div><!-- /.box -->
            </div>
        </div>
    </section><!-- /.content -->
</aside><!-- /.right-side -->
<!-- ./wrapper -->
<div class="modal fade" id="pdfModal" role="dialog">
    <div class="modal-dialog modal-lg">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Archanai Name List Report</h4>
        </div>
        <div class="modal-body">
         <iframe src="" class="pdf_iframe" width="850" height="600"></iframe>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
      
    </div>
</div>
<script type="text/javascript">
$(document).ready(function() {
	<?php if(isset($_SESSION['pdf_devotee'])): ?>
	var srcval='<?php echo base_url().'uploads/devotee_report_pdf/'.$_SESSION['pdf_devotee_file']; ?>';
	$('.pdf_iframe').attr("src",srcval);
	$('#pdfModal').modal({"show":true}); 
	<?php 
	unset($_SESSION['pdf_devotee']);
	endif; 
	?>
  
	//change_todate();
	$('.start_date').bootstrapMaterialDatePicker({ 
		time: false, 
		format: 'DD-MM-YYYY'
	}).on('change', function(){
		if($('.end_date').val() != '') {
			$('.end_date').val('');
		}
	});
	
	$('.end_date').bootstrapMaterialDatePicker({ 
		time: false, 
		format: 'DD-MM-YYYY'
	});
	
	$('#category_id').on('change', function(){	
		$('#item_id').empty();	
		$.ajax({
            async: false,
            url: base_url + 'archanai_namelist_report/get_item_list',
            type: 'POST',
            data: {catId: $(this).val()},
            dataType: "html"
        }).done(function (data) {
            $('#item_id').append(data);
        }).fail(function (XHR, status_code, error_thrown) {
            console.log(error_thrown);
        });
	});
});
</script>