/** * 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')); }
public function actionRemoveAssignedList($user_id, $assigned_list_id) { $listIdMdl = ListId::model()->findByAttributes(array('list_id_value' => $assigned_list_id)); if (!$listIdMdl) { throw new CHttpException(404, "We can't find this {$assigned_list_id} in the database. "); } $assignedListIdMode = AssignedAllowedListId::model()->findByAttributes(array('user_id' => $user_id, "list_id" => $listIdMdl->id)); if (!$assignedListIdMode) { throw new CHttpException(404, "We can't find this record in the database. "); } else { $assignedListIdMode->delete(); $currentUserModel = User::model()->findByAttributes(array('id' => $user_id)); Yii::app()->user->setFlash("success", "Success : Assignment has been removed"); $this->redirect(array('/assigned/view', 'username' => $currentUserModel->username)); } }
public static function getAllAssignedList($userId) { $models = AssignedAllowedListId::model()->findAllByAttributes(array('user_id' => $userId)); return $models; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return AssignedAllowedListId the loaded model * @throws CHttpException */ public function loadModel($id) { $model = AssignedAllowedListId::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }