<?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-12">
        <div class="widget-box">
            <div class="widget-header" style="height:40px;">
                <h5  style="text-align:center; color:red;"><b> Search By date range</b> </h5>
            </div>

            <div class="widget-body">
                <div class="widget-main no-padding">
                    <form action="<?php echo admin_url()?>/balancesetup/balanceBydaterange " 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>

                        <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>

    <?php if(!empty($landIncome) || !empty($extraIncome)){?>
    <div class="col-sm-6" id="balanceView">
        <div class="widget-box">
            <div class="widget-header" style="height:40px;">
                <h4  style="text-align:center; color:green;"><b> Total Income</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-6 col-sm-6"><label style="color:green;"><b>By Customer</b></label></div>
                                
                                <div class="input-group col-xs-6 col-sm-6">
                                    <span style="color:red;">
                                        <?php if(!empty($landIncome['amount']))
                                            {
                                                echo $landIncome['amount'];
                                            }else{echo $landIncome['amount']=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-6 col-sm-6"><label style="color:green;"><b>By Category</b></label></div>

                                
                                <div class="input-group col-xs-6 col-sm-6">
                                    
                                    <span style="color:red;">
                                        <?php if(!empty($extraIncome['amount']))
                                            {
                                                echo $extraIncome['amount'];
                                            }else{echo $extraIncome['amount']=0;}
                                        ?>
                                    </span>
                                    
                                </div>
                        </fieldset>
                        <?php if(!empty($landIncome['amount']) || !empty($extraIncome['amount'])) { $INCOME=$landIncome['amount'] + $extraIncome['amount'] ; }else{ $INCOME=0;}?>
                        <div class="clearfix"></div>
                        <div class="form-actions center">
                           
                        </div>
                        
                    </form>
                </div>
            </div>
        </div>
    </div>
    <?php }?>

    <?php if(!empty($expense) || !empty($salaryExpense)){?>
    <div class="col-sm-6">
        <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-6 col-sm-6"><label style="color:green;"><b>By Category</b></label></div>
                                
                                <div class="input-group col-xs-6 col-sm-6">
                                    <span style="color:red;">
                                        <?php if(!empty($expense['expenseAmount']))
                                            {
                                                echo $expense['expenseAmount'];
                                            }else{echo $expense['expenseAmount']=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-6 col-sm-6"><label style="color:green;"><b>By Employee/Officers</b></label></div>

                                
                                <div class="input-group col-xs-6 col-sm-6">
                                    
                                    <span style="color:red;">
                                        <?php if(!empty($salaryExpense['salaryAmount']))
                                            {
                                                echo $salaryExpense['salaryAmount'];
                                            }else{echo $salaryExpense['salaryAmount']=0;}
                                        ?>
                                    </span>
                                    
                                </div>
                        </fieldset>
                        <?php if(!empty($expense['expenseAmount']) || !empty($salaryExpense['salaryAmount'])) { $EXPENSE=$expense['expenseAmount'] + $salaryExpense['salaryAmount'] ; }else{ $EXPENSE=0;}?>
                        <div class="clearfix"></div>
                        <div class="form-actions center">
                           
                        </div>
                        
                    </form>
                </div>
            </div>
        </div>
    </div>
    <?php } if(!empty($EXPENSE) || !empty($INCOME)){?>

    <div class="col-sm-12">
        <div class="widget-box">
            <div class="widget-header" style="height:40px;">
                <h4  style="text-align:center; color:green;"><b> </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;"><h4><b>Total Income</b></h4></label></div>
                                
                                <div class="input-group col-xs-4 col-sm-4">
                                    <span style="color:red;"><h4>
                                       <?php
                                        echo $INCOME;
                                       ?>
                                    </h4></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;"><h4><b>Total Expense</b></h4></label></div>
                                
                                <div class="input-group col-xs-4 col-sm-4">
                                    <span style="color:red;"><h4>
                                       <?php
                                        echo $EXPENSE;
                                       ?>
                                    </h4></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;"><h1><b>Balance</b></h1></label></div>
                                
                                <div class="input-group col-xs-4 col-sm-4">
                                    <span style="color:red;"><h1>
                                       <?php
                                       // if($INCOME > $EXPENSE){echo $INCOME - $EXPENSE.'&nbsp;&nbsp;&nbsp;(Profit)';}
                                       // elseif($INCOME < $EXPENSE){echo $EXPENSE - $INCOME.'&nbsp;&nbsp;&nbsp;(Loss)';}
                                       // else{echo 'You Have Equal Balance';}

                                       if($INCOME > $EXPENSE){echo $INCOME - $EXPENSE;}
                                       elseif($INCOME < $EXPENSE){echo $EXPENSE - $INCOME;}
                                       else{echo 'You Have Equal Balance';}
                                       ?>
                                    </h1></span>
                                </div>
                        </fieldset>

                        
                        <div class="clearfix"></div>
                        <div class="form-actions center">
                           
                        </div>
                        
                    </form>
                </div>
            </div>
        </div>
    </div>
    <?php }?>
    </div>

    </div>

