예제 #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
 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));
     }
 }
예제 #3
0
 public function actionIndex()
 {
     $model = new User();
     $model->superuser = 0;
     //not super user
     $model->status = User::STATUS_ACTIVE;
     $profile = new Profile();
     $this->performAjaxValidation(array($model, $profile));
     $assignedListId = "";
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         $model->activkey = Yii::app()->getModule("user")->encrypting(microtime() . $model->password);
         $profile->attributes = $_POST['Profile'];
         $profile->user_id = 0;
         if ($model->validate() && $profile->validate()) {
             $model->password = Yii::app()->getModule("user")->encrypting($model->password);
             if ($model->save()) {
                 $profile->user_id = $model->id;
                 $profile->save();
                 // To prevent having empty id for object model
                 // Save the  assigned listid*/
                 $listOfListId = explode(",", $_POST['assignedListId']);
                 foreach ($listOfListId as $key => $value) {
                     $listidModel = ListId::model()->findByAttributes(array('list_id_value' => $value));
                     if ($listidModel) {
                         $newAssignment = new AssignedAllowedListId();
                         $newAssignment->list_id = $listidModel->id;
                         $newAssignment->user_id = $model->id;
                         $newAssignment->save();
                     }
                 }
             }
             $assignedListId = $_POST['assignedListId'];
             Yii::app()->user->setFlash("success", "Success! New user created ");
             $this->redirect(array('/ManageUser'));
         } else {
             $profile->validate();
         }
     }
     $this->render('create', array('model' => $model, 'profile' => $profile, 'selectedAllowedId' => $assignedListId));
 }
예제 #4
0
 /**
  * Returns list of unassigned listid
  * @param  integer $user_id The ID of user
  * @return array          The unassigned listid
  */
 public static function getUnassignedListId($user_id)
 {
     /*get all list id of current user */
     $assignedListId = AssignedAllowedListId::getAllAssignedList($user_id);
     $excludedCollection = [];
     foreach ($assignedListId as $key => $value) {
         /*compose list id to be exluded*/
         $excludedCollection[] = $value->list->list_id_value;
     }
     $criteria = new CDbCriteria();
     /*get all records not in excluded collection */
     $criteria->addNotInCondition("list_id_value", $excludedCollection);
     $unassignedListId = ListId::model()->findAll($criteria);
     return $unassignedListId;
     /*return collection*/
 }
예제 #5
0
        }
        ?>
			<?php 
        echo $form->error($profile, $field->varname);
        ?>
		</div>
				<?php 
    }
}
?>
		
	</div>
	<div class="row">
		<legend>Allowed List</legend>
		<?php 
$data = CHtml::listData(ListId::model()->findAll(), 'list_id_label', 'list_id_value');
$this->widget('yiiwheels.widgets.select2.WhSelect2', array('data' => $data, 'asDropDownList' => false, 'name' => 'assignedListId', 'pluginOptions' => array('tags' => array_values($data), 'placeholder' => 'List of listid', 'width' => '40%', 'tokenSeparators' => array(',', ' '))));
?>
	</div>
	<div class="row">
		<hr>
		<?php 
echo CHtml::submitButton('Save', array('class' => 'btn btn-primary'));
?>
	</div>
	<br>
	<br>
	<br>

<?php 
$this->endWidget();
예제 #6
0
 public function actionNewListId($listId)
 {
     $newListId = new ListId();
     $newListId->list_id_label = $listId;
     $newListId->list_id_value = $listId;
     if ($newListId->save()) {
         Yii::app()->user->setFlash("success", "Success : List {$listId} is now available. ");
     } else {
         Yii::app()->user->setFlash("error", CHtml::errorSummary($newListId));
     }
     $this->redirect(Yii::app()->request->getUrlReferrer());
 }