/**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $leadsAndStatusDataProvider = new LeadsStatusDataProvider();
     // $leadsAndStatusDataProvider = new LeadsStatusUrlDataProvider();
     $chartDataObj = new ChartDataProvider($leadsAndStatusDataProvider->data);
     $chartDataProvider = $chartDataObj->getData();
     /* client data */
     $clientVb = Yii::app()->askteriskDb->createCommand("select * from client_panel")->queryAll();
     $clientj6 = Yii::app()->askteriskDb->createCommand("select * from clientj6_sec_today")->queryAll();
     $clientj6 = $clientj6[0];
     $_5CXFER = Yii::app()->askteriskDb->createCommand("select * from `5cxfer_today`")->queryRow();
     $criteria = new CDbCriteria();
     $criteria->order = "date_created DESC";
     $currentBalance = BalanceLog::model()->find($criteria);
     $updatedInitBalance = 300;
     foreach ($clientVb as $key => $value) {
         if ($currentBalance) {
             $updatedInitBalance = $currentBalance->current_balance;
         } else {
             $currentBalance->current_balance = 300;
             $currentBalance->save();
         }
         $tempContainer = $clientVb[$key];
         $tempContainer['raw_seconds'] = doubleval($value['seconds']) + doubleval($clientj6['seconds']);
         $tempContainer['id'] = uniqid();
         $tempContainer['total'] = doubleval($tempContainer['raw_seconds']) / 60 * doubleval($value['ppminc']);
         $tempContainer['balance'] = doubleval($updatedInitBalance);
         $tempContainer['balance'] -= doubleval($tempContainer['total']);
         $tempContainer['total'] = '£ ' . sprintf("%.2f", $tempContainer['total']);
         $tempContainer['balance'] = '£ ' . sprintf("%.2f", $tempContainer['balance']);
         $tempContainer['raw_seconds'] = doubleval($value['seconds']) + doubleval($clientj6['seconds']);
         $tempContainer['hours'] = intval($tempContainer['raw_seconds'] / (60 * 60));
         $tempContainer['minutes'] = intval($tempContainer['raw_seconds'] / 60);
         $tempContainer['seconds'] = intval($tempContainer['raw_seconds'] % 60);
         // $tempContainer['cxfer']  = $_5CXFER['generated'];
         $tempContainer['cxfer'] = BarryOptLog::getCountToday();
         $clientVb[$key] = $tempContainer;
     }
     /*compute the total*/
     /*file uploaded*/
     $fileUploadedObj = new ClientUploadedData();
     $fileUploadedArr = $fileUploadedObj->getListUploaded();
     /*export range form*/
     $exportModel = new ExportRangeForm();
     $exportModel->unsetAttributes();
     if (isset($_POST['ExportRangeForm'])) {
         $exportModel->attributes = $_POST['ExportRangeForm'];
         if ($exportModel->validate()) {
             $this->redirect(array("/export/range", "dateFrom" => $exportModel->date_from, "dateTo" => $exportModel->date_to));
         } else {
             Yii::app()->user->setFlash("error", CHtml::errorSummary($exportModel));
             $this->redirect(array('/site/index'));
         }
     }
     $this->render('index', compact('clientVb', 'fileUploadedArr', 'exportModel', 'leadsAndStatusDataProvider', 'chartDataProvider'));
 }
<?php

/* @var $this SiteController */
$this->pageTitle = Yii::app()->name;
$baseUrl = Yii::app()->theme->baseUrl;
$dataRetobj = new ClientUploadedData();
$tempArrContainer = $dataRetobj->getListUploaded();
$gridDataProvider = new CArrayDataProvider($tempArrContainer);
$gridDataProvider->sort = array();
$gridDataProvider->sort->defaultOrder = 'last_modified DESC';
?>

<div class="row-fluid">
    <div class="span6">
        <?php 
$this->beginWidget('zii.widgets.CPortlet', array('title' => '<span class="icon-picture"></span>Upload Files', 'titleCssClass' => ''));
?>
        <?php 
$this->widget('ext.EAjaxUpload.EAjaxUpload', array('id' => 'uploadFile', 'config' => array('template' => '<div class="qq-uploader"><div class="qq-upload-drop-area"><span>Drop files here to upload</span></div><div class="qq-upload-button">Upload a file</div><ul class="qq-upload-list"></ul></div>', 'action' => Yii::app()->createUrl('site/upload'), 'allowedExtensions' => array("csv", "jpg", 'txt', 'xlsx', 'xls'), 'sizeLimit' => 10 * 1024 * 1024, 'onComplete' => "js:function(id, fileName, responseJSON){ \$.fn.yiiGridView.update('gridview1') }", 'messages' => array('typeError' => "{file} has invalid extension. Only {extensions} are allowed.", 'sizeError' => "{file} is too large, maximum file size is {sizeLimit}.", 'minSizeError' => "{file} is too small, minimum file size is {minSizeLimit}.", 'emptyError' => "{file} is empty, please select files again without it.", 'onLeave' => "The files are being uploaded, if you leave now the upload will be cancelled."), 'showMessage' => "js:function(message){ alert(message); }")));
?>


        <?php 
$this->endWidget();
?>

    </div>
    <div class="span6">
        <?php 
$this->widget('bootstrap.widgets.TbAlert', array('fade' => true, 'closeText' => '×', 'alerts' => array('success' => array('block' => true, 'fade' => true, 'closeText' => '×'), 'error' => array('error' => true, 'fade' => true, 'closeText' => '×'))));
?>
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $dialableLeads = 0;
     $leadsAndStatusDataProvider1 = new LeadsStatusDataProvider('1501');
     $leadsAndStatusDataProvider2 = new LeadsStatusDataProvider('1502');
     if (isset($_GET['listid']) && $_GET['listid'] == '1503,1504') {
         $leadsAndStatusDataProvider1 = new LeadsStatusDataProvider('1503');
         $leadsAndStatusDataProvider2 = new LeadsStatusDataProvider('1504');
     }
     //@TODO - combine leads status
     $data1Arr = $leadsAndStatusDataProvider1->data;
     $data2Arr = $leadsAndStatusDataProvider2->data;
     $tempClone = array();
     if (!empty($data1Arr)) {
         $tempClone = $data1Arr;
     } else {
         if (!empty($data2Arr)) {
             $tempClone = $data2Arr;
         }
     }
     $combinedArr = array();
     foreach ($tempClone as $key => $value) {
         $first = $data1Arr[$key]['lead'];
         $second = $data2Arr[$key]['lead'];
         $combinedArr[] = array('id' => $key, 'status' => $tempClone[$key]['status'], 'lead' => intval($first) + intval($second));
         if ($tempClone[$key]['status'] == 'New Lead') {
             $dialableLeads = intval($first) + intval($second);
         }
     }
     $leadsAndStatusDataProvider = new CArrayDataProvider($combinedArr, array('id' => 'id', 'keyField' => 'id'));
     $leadsAndStatusDataProvider->pagination = false;
     //Pass the combined data for chart
     $chartDataObj = new ChartDataProvider($leadsAndStatusDataProvider->data);
     $chartDataProvider = $chartDataObj->getData();
     /* client data */
     $clientVb = Yii::app()->askteriskDb->createCommand("select * from client_panel")->queryAll();
     // $clientj6 = Yii::app()->askteriskDb->createCommand("select * from clientj6_sec_today")->queryAll();
     // $clientj6 = $clientj6[0];
     // $_5CXFER = Yii::app()->askteriskDb->createCommand("select * from `5cxfer_today`")->queryRow();
     $criteria = new CDbCriteria();
     $criteria->order = "date_created DESC";
     $currentBalance = BalanceLog::model()->find($criteria);
     $updatedInitBalance = 300;
     foreach ($clientVb as $key => $value) {
         if ($currentBalance) {
             $updatedInitBalance = $currentBalance->current_balance;
         } else {
             $currentBalance->current_balance = 300;
             $currentBalance->save();
         }
         $tempContainer = $clientVb[$key];
         if (!is_null(@$clientj6) && isset($clientj6['seconds'])) {
             $tempContainer['raw_seconds'] = doubleval($value['seconds']) + doubleval($clientj6['seconds']);
         }
         $tempContainer['raw_seconds'] = doubleval($value['seconds']);
         $tempContainer['id'] = uniqid();
         $tempContainer['total'] = doubleval($tempContainer['raw_seconds']) / 60 * doubleval($value['ppminc']);
         $tempContainer['balance'] = doubleval($updatedInitBalance);
         $tempContainer['balance'] -= doubleval($tempContainer['total']);
         $tempContainer['total'] = '£ ' . sprintf("%.2f", $tempContainer['total']);
         $tempContainer['balance'] = '£ ' . sprintf("%.2f", $tempContainer['balance']);
         $tempContainer['raw_seconds'] = doubleval($value['seconds']) + doubleval($clientj6['seconds']);
         $tempContainer['hours'] = intval($tempContainer['raw_seconds'] / (60 * 60));
         $tempContainer['minutes'] = intval($tempContainer['raw_seconds'] / 60);
         $tempContainer['seconds'] = intval($tempContainer['raw_seconds'] % 60);
         $tempContainer['leads'] = intval($dialableLeads);
         // $tempContainer['cxfer']  = $_5CXFER['generated'];
         $tempContainer['cxfer'] = BarryOptLog::getCountToday();
         $clientVb[$key] = $tempContainer;
     }
     /*compute the total*/
     /*file uploaded*/
     $fileUploadedObj = new ClientUploadedData();
     $fileUploadedArr = $fileUploadedObj->getListUploaded();
     /*export range form*/
     $exportModel = new ExportRangeForm();
     $exportModel->unsetAttributes();
     if (isset($_POST['ExportRangeForm'])) {
         $exportModel->attributes = $_POST['ExportRangeForm'];
         if ($exportModel->validate()) {
             $this->redirect(array("/export/range", "dateFrom" => $exportModel->date_from, "dateTo" => $exportModel->date_to));
         } else {
             Yii::app()->user->setFlash("error", CHtml::errorSummary($exportModel));
             $this->redirect(array('/site/index'));
         }
     }
     $this->render('index', compact('clientVb', 'fileUploadedArr', 'exportModel', 'leadsAndStatusDataProvider', 'chartDataProvider'));
 }