<?php
if($action == 'view_country_detail'){
?>

<div class="col-lg-12">
        <?php
            $model_emirates = MasEmiratesList::model()->findByPk($country_id);                
        ?>
        <p>
            <label>Emirates : </label>
            <b><?php echo $model_emirates['emirates_name'];  ?></b>
        </p>
        <table class="table table-hover table-bordered personal-task">
            <thead>
                <tr>
                    <th>S.No</th>
                    <th>Month</th>
                    <th>Quotes Count</th>                    
                    <th>Amount</th>
                </tr>
            </thead>
            <tbody>
            
            <?php
            
            
            if(!empty($graph_detail)){
                $i  =1;
                $month_array = array("January","February","March","April","May","June","July","August","September","October","November","December");
                $total  = 0.00;
                foreach ($graph_detail as $value) {
                        $month   = $value['m']-1;
                    ?>
                        <tr onclick="getQuoteMonthDetails(<?php echo $value['m']; ?>,<?php echo $value['y']; ?>,<?php echo $country_id; ?>)">
                            <td><?php echo $i; ?></td>
                            <td><?php echo $month_array[$month]." - ".$value['y']; ?></td>                            
                            <td><?php echo $value['TOTAL_COUNT']; ?></td>
                            <td class="text-right"><?php echo Yii::app()->numberFormatter->formatCurrency($value['TOTAL_AMT'],""); ?></td>
                        </tr>
                    <?php
                    $total+=$value['TOTAL_AMT'];
                    $i++;   
                }
                ?>
                    <tr>
                        <td class="text-right" colspan="3"><b>Total Amount</b></td>
                        <td class="text-right"><b><?php echo Yii::app()->numberFormatter->formatCurrency($total,""); ?></b></td>
                    </tr>
                <?php
            }
            else{
                ?>
                    <tr>
                        <td colspan="4">No data found</td>
                    </tr>
                <?php
            }
            
            ?>
            </tbody>
        </table>
    </div>
    
<?php
}
else if($action == 'view_country_month_detail'){
    
    $month_arr = array("January","February","March","April","May","June","July","August","September","October","November","December");
    $month  =$month-1;
    ?>
    <div class="col-lg-12">
        <p>
            
            <b><?php echo $month_arr[$month]." - ".$year;  ?></b>
        </p>
        <table class="table table-hover table-bordered personal-task">
            <thead>
                <tr>
                    <th>S.No</th>
                    <th>Customer Name</th>
                    <th>Start Date</th>
                    <th>End Date</th>
                    <th>Amount</th>
                </tr>
            </thead>
            <tbody>
            
            <?php
           
          
            if(!empty($graph_detail)){
                $i  =1;
                $total_amt  = 0.00;
                //$month_array = array("January","February","March","April","May","June","July","August","September","October","November","December");
                foreach ($graph_detail as $value) {
                        
                        if($value['qtn_close_date'] == '0000-00-00'){
                            $close_date   = "";
                        }else{
                            $close_date   = date('d/m/Y',strtotime($value['qtn_close_date']));
                        }
                    ?>
                        <tr onclick="getQuotesOwnerMonthDetails(<?php echo $value['quotes_id']; ?>)">
                            <td><?php echo $i; ?></td>
                            <td><?php echo $value['customer_name']; ?></td>
                            <td><?php echo date('d/m/Y',strtotime($value['qtn_start_date']));//echo $value['enq_date']; ?></td>
                            <td><?php echo $close_date;//echo $value['closing_date']; ?></td>
                            <td class="text-right"><?php echo Yii::app()->numberFormatter->formatCurrency($value['grand_total'],""); ?></td>
                        </tr>
                    <?php
                    $total_amt+=$value['grand_total'];
                    $i++;   
                }
                ?>
                    <tr>
                        <td class="text-right" colspan="4"><b>Total Amount</b></td>
                        <td class="text-right"><b><?php echo Yii::app()->numberFormatter->formatCurrency($total_amt,""); ?></b></td>
                    </tr>
                <?php
            }
            else{
                ?>
                    <tr>
                        <td colspan="4">No data found</td>
                    </tr>
                <?php
            }
            
            ?>
            </tbody>
        </table>
    </div>
    <?php
    
}
?>
