示例#1
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $gridDataProvider = new CArrayDataProvider(array(), array('keyField' => 'id', 'id' => "id"));
     $gridDataProvider->pagination = false;
     $chartDataProvider = array();
     $totalRevenue = number_format(0, 2);
     $cc001 = LiveRevD::getValue("cc001");
     $cc002 = LiveRevD::getValue("cc002");
     if (isset($_GET['searchListId'])) {
         /*check if user is allow to check this listid */
         $_GET['searchListId'] = intval($_GET['searchListId']);
         $listId = ListId::model()->findByAttributes(array("list_id_value" => $_GET['searchListId']));
         if (!$listId) {
             throw new CHttpException(404, "This list doesn't exists");
         }
         $isAllowed = AssignedAllowedListId::model()->findByAttributes(array("list_id" => $listId->id, "user_id" => Yii::app()->user->id));
         //test 1242015
         if (!$isAllowed) {
             throw new CHttpException(403, "You are not allowed to search this list");
         }
         /*search and return leads and reports*/
         $fetcher = new LeadDataFetcher();
         $leadDataCollection = $fetcher->getDataFromDialer($_GET['searchListId']);
         $startingDate = null;
         /*get starting date log using user_id*/
         $criteria = new CDbCriteria();
         $criteria->compare("user_id", Yii::app()->user->id);
         $criteria->order = "id DESC";
         $startingDateMdl = StartingDateRevenueLog::model()->find($criteria);
         /* if cant find any use date starting from 10 years ago*/
         if (!$startingDateMdl) {
             $startingDate = "2000-01-01";
         } else {
             $startingDate = date("Y-m-d", strtotime($startingDateMdl->revert_date));
         }
         $totalRevenue = sprintf("%2.2f", $fetcher->getTotalRevenue($_GET['searchListId'], $startingDate));
         $leadRows = array();
         foreach ($leadDataCollection as $key => $value) {
             /* @var $value LeadData*/
             $leadRows[] = array('id' => $key, 'status' => $value->getLeadStatus(), 'lead' => $value->getLeadValue());
             $chartDataProvider[] = array("name" => $value->getLeadStatus(), "y" => $value->getLeadValue());
         }
         //re initialize value
         $gridDataProvider = new CArrayDataProvider($leadRows, array('keyField' => 'id', 'id' => "id"));
         $gridDataProvider->pagination = false;
     }
     $gridDataProvider->pagination = false;
     $this->render('index', compact('gridDataProvider', 'chartDataProvider', 'totalRevenue', 'cc001', 'cc002'));
 }
示例#2
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $data = LiveCallReport::getLiveReport();
     $leadInfoContainer = LeadInfoReport::getLiveReport();
     $data['convertedDeal'] = ConvertedDealReport::getLiveReport();
     $data['convertedDeal'] = ceil($data['convertedDeal']);
     $data['aveHoldTime'] = AverageHoldTimeReport::getAverage();
     $data['convertedDealCount'] = ConvertedDealCount::getAverage();
     $data['converRate'] = AverageContactRate::getAverage();
     $data['converRate'] = $data['converRate'] . '%';
     $data['orig_tbc'] = NumContactedReport::getNumberContact();
     // $data['liveD'] = LiveDRemoteData::getValue();
     $data['liveRevDvalue'] = LiveRevD::getValue();
     $data['liveRevPvalue'] = LiveRevP::getValue();
     $data['liveD'] = number_format($data['liveRevDvalue'] / 4, 2);
     if ($data['orig_tbc'] != '0') {
         $data['tbc'] = round($data['convertedDealCount'] / $data['orig_tbc'] * 100, 2);
         $data['tbc'] = $data['tbc'] . ' %';
     } else {
         $data['tbc'] = '0 %';
     }
     $data['leads'] = $leadInfoContainer['leads'];
     $data['contacted'] = $leadInfoContainer['contacted'];
     $tempAveHoldTimeArr = explode(":", $data['aveHoldTime']);
     unset($tempAveHoldTimeArr[2]);
     $tempAveHoldTime = implode(":", $tempAveHoldTimeArr);
     if (Yii::app()->request->isAjaxRequest) {
         $data['liveRevDvalue'] = $data['liveRevDvalue'];
         $data['liveRevPvalue'] = $data['liveRevPvalue'];
         $data['convertedDealRaw'] = $data['convertedDeal'];
         $data['convertedDeal'] = "£" . number_format(doubleval($data['convertedDeal']));
         $data["converRate"] = $data['converRate'];
         $data['aveHoldTime'] = $tempAveHoldTime;
         $data['convertedDealCount'] = empty($data['convertedDealCount']) ? 0 : $data['convertedDealCount'];
         $data['orig_averageHoldTime'] = $orig_tempAveHoldTime;
         echo json_encode($data);
         Yii::app()->end();
     }
     $this->render('newui', array('liveD' => $data['liveD'], 'revDVal' => $data['liveRevDvalue'], 'revPVal' => $data['liveRevPvalue'], 'waiting' => $data['waiting'], "called" => $data['called'], "convertedDeal" => doubleval($data['convertedDeal']), "convertedDealCount" => empty($data['convertedDealCount']) ? 0 : $data['convertedDealCount'], "converRate" => $data['converRate'], "averageHoldTime" => $tempAveHoldTime, 'orig_averageHoldTime' => $orig_tempAveHoldTime, "tbc" => $data['tbc'], "orig_tbc" => $data['orig_tbc'], "leads" => $data['leads'], "contacted" => $data['contacted']));
 }