public function actionToday() { $fileName = sprintf("%s-%s", "barry-export-data", date("Y-m-d")); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"{$fileName}.csv\";"); header("Content-Transfer-Encoding: binary"); $barryOptOutLogs = new BarryOptLog(); $allDataColl = $barryOptOutLogs->getAllToday(); $exporter = new ExportLeadData(); $filePath = $exporter->exportContents($allDataColl); /*stream the contents*/ echo file_get_contents($filePath); }
/** * 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 $this->beginWidget('zii.widgets.CPortlet', array('title' => '<span class=" icon-wrench"></span>Admin Action', 'titleCssClass' => '', 'htmlOptions' => array('style' => 'text-align: left;padding-left: 20px;'))); ?> <h5> <span class="icon-download"></span> <?php echo CHtml::link("Export Data <span class='label label-info'>" . BarryOptLog::getCountAll() . "</span>", array('/export')); ?> </h5> <hr> <h5> <span class="icon-calendar"></span> <?php echo CHtml::link("Export Today <span class='label label-info'>" . BarryOptLog::getCountToday() . "</span>", array('/export/today')); ?> </h5> <hr> <h5> <span class="icon-calendar"></span> <?php echo CHtml::link("Export Range", "#", array("onclick" => '$("#exportModal").dialog("open"); return false;')); ?> </h5> <?php if (Yii::app()->user->checkAccess('administrator')) { ?> <hr>
public static function getCountAll() { $obj = new BarryOptLog(); $resColl = $obj->getAllData(); return count($resColl); }
/** * 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')); }