<?php
                                $message = $this->session->userdata('message');
                                if (!empty($message)) {
                                    ?>
                                    <div class="alert alert-block alert-success">
                                        <h6 class="lighter arial green" style="text-align:center;"><b>
                                                <?php echo $message;
                                                $this->session->unset_userdata('message');
                                                ?>
                                            </b></h6>
                                    </div>  
                                    <?php
                                }
                                $errormessage = $this->session->userdata('errormessage');
                                if (!empty($errormessage)) {
                                    ?>
                                    <div class="alert alert-block alert-danger">
                                        <h6 class="lighter arial red" style="text-align:center;"><b>
                                                <?php echo $errormessage;
                                                $this->session->unset_userdata('errormessage');
                                                ?>
                                            </b></h6>
                                    </div> 
                                    <?php
                                }
                                ?>  
<div class="page-content" >  
<div class="row">
    <!--<div class="col-sm-5"> 
        <div class="widget-box">
            <div class="widget-header" style="height:40px;">
                <h5  style="text-align:center; color:red;"><b> Search By date or category</b> </h5>
            </div>

            <div class="widget-body">
                <div class="widget-main no-padding">
                    <form action="<?php //echo admin_url()?>/expensesetup/searchSingleBydate " method="post">

                        <fieldset class="col-xs-12 col-sm-12">
                                <div class="col-xs-3 col-sm-3"><label>Date</label></div>
                                <?php //echo form_error('data[date]', '<div style="color: rgb(255, 0, 0);">', '</div>'); ?>
                                <div class="input-group col-xs-6 col-sm-6">
                                    <input class="form-control date-picker" id="id-date-picker-1" type="text" name="data[date]" value="<?php //echo set_value('data[date]',false); ?>" data-date-format="dd-mm-yyyy" />
                                    <span class="input-group-addon">
                                        <i class="fa fa-calendar bigger-110"></i>
                                    </span>
                                </div>
                        </fieldset>
                        <?php //if(!empty(getAllExpenseCategory())){?>
                        <fieldset class="col-xs-12 col-sm-12">
                            <label class="col-xs-3 col-sm-3">Category</label>
                            <?php //echo form_error('data[expenseCategory]', '<div style="color: rgb(255, 0, 0);">', '</div>'); ?>
                            <select name="data[expenseCategory]" class="col-xs-6 col-sm-6">
                                    <option value=""> Select Expense Category.....</option>
                                <?php //foreach(getAllExpenseCategory() as $value){?>
                                    <option value="<?php //if(!empty($value['category_id'])){echo $value['category_id'];}?>" <?php //echo set_select('data[expenseCategory]',$value['category_id'],FALSE);?>>
                                    <?php //if(!empty($value['category_name'])){echo $value['category_name'];}?>
                                    </option>
                                <?php //}?>
                            </select>
                           
                        </fieldset>
                        <?php //}?>

                        <fieldset class="col-xs-12 col-sm-12">
                            <label class="col-xs-3 col-sm-3">Salary Type</label>
                            <?php //echo form_error('data[salary_type]', '<div style="color: rgb(255, 0, 0);">', '</div>'); ?>
                            <select name="data[salary_type]" class="col-xs-6 col-sm-6">
                                    <option value=""> Select Salary Type.....</option>
                                    <option value="1">Salary Commission</option>
                                    <option value="2">Insentive</option>
                                    <option value="3">Hounariom</option>
                            </select>
                           
                        </fieldset>

                        <div class="clearfix"></div>

                        <div class="form-actions center">
                            <button type="submit" name="btnSdate" class="btn btn-sm btn-success">
                                 <i class="ace-icon fa fa-undo bigger-110"></i>
                                Search 
                                
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>-->
    <div class="col-sm-12">
        <div class="widget-box">
            <div class="widget-header" style="height:40px;">
                <h5  style="text-align:center; color:red;"><b> Search By DateRange And Anyone Selector ( Category Or Salary Type )</b> </h5>
            </div>

            <div class="widget-body">
                <div class="widget-main no-padding">
                    <form action="<?php echo admin_url()?>/expensesetup/searchBydaterange " method="post">

                        <fieldset class="col-xs-6 col-sm-6">
                                <div class="col-xs-4 col-sm-4"><label>Date From</label></div>
                                <?php echo form_error('data[fromdate]', '<div style="color: rgb(255, 0, 0);">', '</div>'); ?>
                                <div class="input-group col-xs-8 col-sm-8">
                                    <input class="form-control date-picker" id="id-date-picker-1" type="text" name="data[fromdate]" value="<?php echo set_value('data[fromdate]',false); ?>" data-date-format="dd-mm-yyyy" />
                                    <span class="input-group-addon">
                                        <i class="fa fa-calendar bigger-110"></i>
                                    </span>
                                </div>
                        </fieldset>

                        <fieldset class="col-xs-6 col-sm-6">
                                <div class="col-xs-4 col-sm-4"><label>Date To</label></div>
                                <?php echo form_error('data[todate]', '<div style="color: rgb(255, 0, 0);">', '</div>'); ?>
                                <div class="input-group col-xs-8 col-sm-8">
                                    <input class="form-control date-picker" id="id-date-picker-1" type="text" name="data[todate]" value="<?php echo set_value('data[todate]',false); ?>" data-date-format="dd-mm-yyyy" />
                                    <span class="input-group-addon">
                                        <i class="fa fa-calendar bigger-110"></i>
                                    </span>
                                </div>
                        </fieldset>
                        <?php //if(!empty(getAllExpenseCategory())){?>
                        <fieldset class="col-xs-6 col-sm-6">
                            <label class="col-xs-4 col-sm-4">Category</label>
                            <?php echo form_error('data[expenseCategory]', '<div style="color: rgb(255, 0, 0);">', '</div>'); ?>
                            <select name="data[expenseCategory]" class="col-xs-8 col-sm-8">
                                    <option value=""> Select Expense Category.....</option>
                                <?php foreach(getAllExpenseCategory() as $value){?>
                                    <option value="<?php if(!empty($value['category_id'])){echo $value['category_id'];}?>" <?php echo set_select('data[expenseCategory]',$value['category_id'],FALSE);?>>
                                    <?php if(!empty($value['category_name'])){echo $value['category_name'];}?>
                                    </option>
                                <?php }?>
                            </select>
                           
                        </fieldset>
                        <?php //}?>

                        <fieldset class="col-xs-6 col-sm-6">
                            <label class="col-xs-4 col-sm-4">Salary Type</label>
                            <?php echo form_error('data[salary_type]', '<div style="color: rgb(255, 0, 0);">', '</div>'); ?>
                            <select name="data[salary_type]" class="col-xs-8 col-sm-8">
                                    <option value=""> Select Salary.....</option>
                                    <?php foreach (getsalaryType() as $key => $value) { ?>
                                        <option value="<?php echo $key ?>" <?php echo set_select('data[salary_type]', $key, FALSE); ?>>
                                            <?php echo $value; ?>
                                        </option>
                                    <?php } ?>
                            </select>
                           
                        </fieldset>

                        <div class="clearfix"></div>

                        <div class="form-actions center">
                            <button type="submit" name="btnSdateRange" class="btn btn-sm btn-success">
                                 <i class="ace-icon fa fa-undo bigger-110"></i>
                                Search By DateRange
                                
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    </div>
<!--Calculation Amount  -->
     <?php //if(!empty($expense)){
    //         $count=count($expense);
    //         //echo $expense[0]['expenseAmount'];
    //         $count1=0;
    //         for ($i=0;$i<$count;$i++) {
    //             $count1=$count1 + $expense[0]['expenseAmount'];
    //         }
    //         echo $count1;
    //}?>

    <?php if(!empty($expense) || !empty($salaryexpense)){?>
    <div class="row">
    <div class="col-sm-12">
        <div class="widget-box">
            <div class="widget-header" style="height:40px;">
                <h4  style="text-align:center; color:green;"><b> Total Expense</b> </h4>
            </div>

            <div class="widget-body">
                <div class="widget-main no-padding">
                    <form >
                    <fieldset class="col-xs-4 col-sm-4"></fieldset>
                        <fieldset class="col-xs-6 col-sm-6">
                                <div class="col-xs-4 col-sm-4"><label style="color:green;"><b>Expense By Category</b></label></div>
                                
                                <div class="input-group col-xs-8 col-sm-8">
                                    <span style="color:red;">
                                        <?php if(!empty($expense))
                                            {
                                                $count=0;
                                                foreach ($expense as $total) 
                                                {
                                                    $count=$count + $total['expenseAmount'];
                                                }
                                                echo $count;
                                            }else{echo $count=0;}
                                        ?>
                                    </span>
                                </div>
                        </fieldset>
                        <fieldset class="col-xs-4 col-sm-4"></fieldset>
                        <fieldset class="col-xs-6 col-sm-6">
                                <div class="col-xs-4 col-sm-4"><label style="color:green;"><b>By Employee/Officers</b></label></div>

                                
                                <div class="input-group col-xs-8 col-sm-8">
                                    
                                    <span style="color:red;">
                                        <?php if(!empty($salaryexpense))
                                            {
                                                $countsalary=0;
                                                foreach ($salaryexpense as $total) 
                                                {
                                                    $countsalary=$countsalary + $total['salaryAmount'];
                                                }
                                                echo $countsalary;
                                            }else{echo $countsalary=0;}
                                        ?>
                                    </span>
                                </div>
                        </fieldset>
                        <fieldset class="col-xs-4 col-sm-4"></fieldset>
                        <fieldset class="col-xs-6 col-sm-6">
                                <div class="col-xs-4 col-sm-4"><label style="color:green;"><b>Total Expense</b></label></div>

                                
                                <div class="input-group col-xs-8 col-sm-8">
                                   
                                    <span style="color:red;">
                                    <?php if(!empty($count) || !empty($countsalary)) {echo $count + $countsalary ; }else{echo 0;}?>
                                    </span>
                                </div>
                        </fieldset>
                        <div class="clearfix"></div>
                        <div class="form-actions center">
                           
                        </div>
                        
                    </form>
                </div>
            </div>
        </div>
    </div>
    </div>
<?php }?>

<!-- End Calculation Amount  -->


 <!--    Start table   -->

 <div class="clearfix"></div>
 
  <?php if(!empty($expense)){?>
  <!--   -----------------------company info----------------------------------- -->
<div class="col-sm-2"></div>
    <div class="col-sm-10 hidden" id="cinfo">
                                                            <div class="row">
                                                                <div class="col-xs-11 label label-lg label-info arrowed-in arrowed-right">
                                                                    <b>Company Info</b>
                                                                </div>
                                                            </div>

                                                            <div>
                                                                <ul class="list-unstyled spaced">

                                                                    <li>
                                                                    <i class="ace-icon fa fa-caret-right blue"></i>
                                                                    <span >Company Name:</span>
                                                                        
                                                                        Hasan Homes and Developers Limited
                                                                    </li>

                                                                    <li>
                                                                    <i class="ace-icon fa fa-caret-right blue"></i>
                                                                        <span >Address:</span>
                                                                        <?php echo "A.R Khan,Treade Center(4th Flore),40/1 , Nyapolton ,Motijil ,Dhaka-1000"?>
                                                                    </li>

                                                                    <li>

                                                                        <i class="ace-icon fa fa-caret-right blue"></i><span >Branch :</span>
                                                                        Dorigaw Stand ,Dokkkhin keranigong , Dhaka-1310
                                                                    </li>

                                                                    <li>
                                                                        <i class="ace-icon fa fa-caret-right blue"></i>
                                                                        Phone:
                                                                        02-9355530,
                                                                        Mobile:
                                                                        01977-672672, 01711-437255, 01726-235544</b>
                                                                    </li>

                                                                    <li>
                                                                        <i class="ace-icon fa fa-caret-right blue"></i>
                                                                        Email: info@hasanhomesltd.com
                                                                    </li>
                                                                    <li >
                                                                        <i class="ace-icon fa fa-caret-right blue"></i>
                                                                        Web: www.hasanhomesltd.com
                                                                    </li>

                                                                    <li>
                                                                        <i class="ace-icon fa fa-caret-right blue"></i>
                                                                        Paymant Info
                                                                    </li>
                                                                </ul>
                                                            </div>
                                                        </div><!-- /.col -->




    <!--   ---------------------------End company info---------------------------------- --> 
 <div id="printDIV1" > 
<div class="row col-xs-12 col-sm-12">
<div class="col-xs-12 col-sm-12 widget-container-col">
                                        <div class="widget-box widget-color-blue">
                                            <div class="widget-header">
                                                <h5 class="widget-title bigger lighter">
                                                   
                                                    Expense By Category
                                                    
                                                    
                                                </h5>
                                    <!--  <button style='margin:0px 0px 0px 300px;' onclick="javascript:printDiv('printDIV1')" type="button" class="btn"> PRINT </button> -->           
                                              <!--  <i class="red ace-icon glyphicon glyphicon-print  bigger-130" style='margin:0px 0px 0px 1000px;' onclick="javascript:printDiv('printDIV1')"></i>  -->
                                                <i class="red ace-icon glyphicon glyphicon-print  bigger-130" style='margin:0px 0px 0px 1000px;' onclick="javascript:printDivmulti('cinfo','printDIV1')"></i> 
                                            </div>

                                            <div class="widget-body">
                                                <div class="widget-main no-padding">
                                                    <table class="table table-striped table-bordered table-hover">
                                                        <thead class="thin-border-bottom">
                                                            <tr>
                                                                <th>
                                                                    <i ></i>
                                                                    Serial
                                                                </th>

                                                                <th>
                                                                  
                                                                    Category
                                                                </th>
                                                                <th class="hidden-480"> Expense Amount</th>
                                                                <th class="hidden-480">Date</th>
                                                            </tr>
                                                        </thead>

                                                        <tbody>
                                                            
                                                <?php $i=0;foreach($expense as $value){ ?>
                                                            <tr>
                                                                <td ><?php echo ++$i ?></td>

                                                                <td>
                                                                    <a href="#"><?php $cat_nam=getexpenseCategoryById($value['expenseCategory']); echo $cat_nam['category_name'];?></a>
                                                                </td>

                                                                <td class="hidden-480">
                                                                    <span class="label label-warning"><?php echo $value['expenseAmount'];?></span>
                                                                </td>
                                                                <td class="hidden-480">
                                                                    <span ><?php echo $value['date'];?></span>
                                                                </td>
                                                            </tr>
                                                <?php }?>

                                                            <tr>
                                                                <td></td>
                                                                <td></td>
                                                                <td style="color:red;">
                                                                    <?php if(!empty($expense))
                                                                    {
                                                                        $count=0;
                                                                        foreach ($expense as $total) 
                                                                        {
                                                                            $count=$count + $total['expenseAmount'];
                                                                        }
                                                                        echo "Total Amount  =<b><i>".$count."</i></b> Taka";
                                                                    }else{echo $count=0;}
                                                                ?>
                                                                </td>
                                                                <td></td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                </div><!-- /.span -->
    </div><!-- /.row -->
   </div> 
    <?php } ?>

<?php if(!empty($salaryexpense)){?>

  <div id="printDIV" > 
<div class="row col-xs-12 col-sm-12">
<div class="col-xs-12 col-sm-12 widget-container-col">
                                        <div class="widget-box widget-color-blue">
                                            <div class="widget-header">
                                            
                                                <h5 class="widget-title bigger lighter" >
                                                   
                                                     Expense By Emmployee/Officers
                                                  
                                                    
                                                </h5>
                                                <!-- <button style='margin:0px 0px 0px 400px;' onclick="javascript:printDiv('printDIV')" type="button" class="btn"> PRINT </button> -->
                                                <!-- <a class="red" href="<?php //echo admin_url()?>/expenseSetup/searchBydaterange" onclick="javascript:printDiv('printDIV')"></a> -->
                                                          <!-- <i class="red ace-icon glyphicon glyphicon-print  bigger-130" style='margin:0px 0px 0px 900px;' onclick="javascript:printDiv('printDIV')"></i> -->
                                                          <i class="red ace-icon glyphicon glyphicon-print  bigger-130" style='margin:0px 0px 0px 900px;' onclick="javascript:printDivmulti('cinfo','printDIV')"></i>
                                                
                                            </div>

                                            <div class="widget-body">
                                                <div class="widget-main no-padding">
                                                    <table class="table table-striped table-bordered table-hover">
                                                        <thead class="thin-border-bottom">
                                                            <tr>
                                                                <th>
                                                                    <i class="ace-icon fa fa-user"></i>
                                                                   Serial
                                                                </th>

                                                                <th>
                                                                   EmployeeId & Name 
                                                                </th>
                                                                <th>
                                                                   Salary Type 
                                                                </th>
                                                                <th class="hidden-480">SalaryAmount</th>
                                                                <th class="hidden-480"> date</th>
                                                            </tr>
                                                        </thead>

                                                        <tbody>
                                                            
                                                <?php $i=0;foreach($salaryexpense as $value){ ?>
                                                            <tr>
                                                                <td ><?php echo ++$i ?></td>

                                                                <td>
                                                                    <a href="#">
                                                                        <?php $usrnam=getEmployeeById($value['employee_id']); echo "Id : ". $value['employee_id'].'</br> Name : '.$usrnam['userName'];?>
                                                                    </a>
                                                                </td>

                                                                <td class="hidden-480">
                                                                    <a href="#"><?php if(!empty($value['salary_type'])){echo element($value['salary_type'],getsalaryType(),null);}?></a>
                                                                </td>
                                                                <td class="hidden-480">
                                                                    <span class="label label-warning"><?php echo $value['salaryAmount']?></span>
                                                                </td>
                                                                <td class="hidden-480">
                                                                    <span ><?php echo $value['date'];?></span>
                                                                </td>
                                                            </tr>
                                                <?php }?>

                                                        <tr>
                                                            <td></td>
                                                            <td></td>
                                                            <td></td>
                                                            <td style="color:red;">
                                                                <?php if(!empty($salaryexpense))
                                                                {
                                                                    $countsalary=0;
                                                                    foreach ($salaryexpense as $total) 
                                                                    {
                                                                        $countsalary=$countsalary + $total['salaryAmount'];
                                                                    }
                                                                    echo "Total Amount  =<b><i>".$countsalary."</i></b> Taka";
                                                                }else{echo $countsalary=0;}
                                                            ?>
                                                            </td>
                                                            <td></td>
                                                        </tr>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                </div><!-- /.span -->
    </div><!-- /.row -->
   </div>
   

<?php }?>

<!--   end table   -->
    </div> 
