Example #1
0
 /**
  * This is the default 'view' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionDashboard()
 {
     if (Yii::app()->user->isGuest) {
         $this->redirect(array('default/login'));
     }
     $this->pageTitle = 'Admin | ' . Yii::app()->name;
     // Enable dashboard query?
     if (ENVIRONMENT != 'PRODUCTION') {
         // all contacts.
         $Query = new Query();
         $result = $Query->runCampaignQuery(array('contact_warehouse_id', 'terms_agreed', 'dob', 'origin_organisation_id', 'culture_segment'));
         $people = $result['rows'];
     } else {
         $result = [];
         $people = [];
     }
     // all contacts I have access to download
     if ((int) Yii::app()->user->role === User::ROLE_ORGANISATION) {
         $SQL = "\n\nSELECT COUNT(`store`.`id`) as total_contacts\n\nFROM `store2contact`\n\tLEFT JOIN `store` ON `store`.`id` = `store2contact`.`store_id`\nWHERE contact_warehouse_id IN (\n\n\tSELECT s2c2.contact_warehouse_id\n\tFROM store2contact s2c2\n\tWHERE s2c2.origin_id = " . Yii::app()->user->organisation_id . "\n\n)\nAND `store2contact`.`origin_id` = 10\n";
         $totalContacts = Store::model()->countBySQL($SQL);
     }
     Yii::app()->clientScript->registerScriptFile('https://www.google.com/jsapi');
     $this->render('dashboard', array('Query' => $Query, 'people' => $people, 'downloadResultSize' => $downloadResultSize, 'totalContacts' => $totalContacts));
 }