public function actionIndex($accountId)
 {
     Yii::import("application.models.*");
     $criteria = new CDbCriteria();
     $criteria->compare('account_id', $account_id);
     $records = Records::model()->findAll();
     foreach ($records as $value) {
         $dataArr = json_decode($value->claimData, true);
         if (empty($dataArr['Title']) || empty($dataArr['Firstname'])) {
             echo "{$value->record_id} \n ";
         }
     }
 }
 private function retrieveDataRecords()
 {
     $records = null;
     /*using export type specified above*/
     if ($this->exportType === 'all') {
         $criteria = new CDbCriteria();
         $criteria->compare("account_id", $this->model->account_id);
         $criteria->order = "date_created DESC";
         $criteria->distinct = true;
         $records = Records::model()->findAll($criteria);
     } else {
         if ($this->exportType === 'this week') {
             $criteria = new CDbCriteria();
             $criteria->compare("account_id", $this->model->account_id);
             $startingDate = date("Y-m-d 12:00:00", strtotime('friday last week'));
             $endDate = date("Y-m-d 23:59:00", strtotime('friday this week'));
             $criteria->addBetweenCondition("t.date_created", $startingDate, $endDate);
             $criteria->order = "date_created DESC";
             $criteria->distinct = true;
             $records = Records::model()->findAll($criteria);
         } else {
             if ($this->exportType === 'today') {
                 $criteria = new CDbCriteria();
                 $criteria->compare("account_id", $_REQUEST['accountID']);
                 $criteria->addCondition("date(date_created) = date(now())");
                 $criteria->order = "date_created DESC";
                 //$criteria->group = "ip_address";
                 $criteria->distinct = true;
                 $records = Records::model()->findAll($criteria);
             } else {
                 if ($this->exportType === 'range') {
                     /*get claims between */
                     $criteria = new CDbCriteria();
                     $dateFrom = DateTime::createFromFormat("m/d/Y", $this->configurations['dateFrom']);
                     $dateTo = DateTime::createFromFormat("m/d/Y", $this->configurations['dateTo']);
                     $dateFromStr = $dateFrom->format('Y-m-d');
                     $dateToStr = $dateTo->format('Y-m-d');
                     $criteria->compare("account_id", $this->model->account_id);
                     $criteria->addBetweenCondition('date_created', $dateFromStr, $dateToStr);
                     $criteria->order = "date_created DESC";
                     $criteria->distinct = true;
                     $records = Records::model()->findAll($criteria);
                 }
             }
         }
     }
     return $records;
 }
예제 #3
0
 public function download()
 {
     $fileName = $this->model->claimAccountName . ' - ' . date("Y-m-d") . '-All-entries';
     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");
     $criteria = new CDbCriteria();
     $criteria->compare("account_id", $this->model->account_id);
     $criteria->order = "date_created DESC";
     $criteria->distinct = true;
     $records = Records::model()->findAll($criteria);
     $isFirst = true;
     foreach ($records as $curRecord) {
         $data = json_decode($curRecord->claimData, true);
         $rowData = "";
         $allowPrint = true;
         if ($isFirst) {
             //print heads
             $headers = "";
             $keys = array_keys($data);
             $headers = implode(",", $keys) . "\n";
             echo $headers;
             $isFirst = false;
         }
         /*check if mobile number exists at blacklist mobile nums*/
         $mobileNumMatch = preg_grep('/0?7\\d{9}/', $data);
         if (count($mobileNumMatch) > 0) {
             $mobileNumContainer = array_values($mobileNumMatch)[0];
             $criteria = new CDbCriteria();
             $criteria->compare('mobile_number', $mobileNumContainer);
             $allowPrint = !BlackListedMobile::model()->exists($criteria);
         }
         if ($allowPrint) {
             foreach ($data as $curRowData) {
                 $rowData = $rowData . "\"{$curRowData}\",";
             }
         }
         $rowData = str_replace(chr(194), " ", $rowData);
         //prepare data
         if ($allowPrint) {
             echo $rowData . "\n";
         }
     }
 }
예제 #4
0
 /**
  * Returns a json report on an acccount using hostname
  */
 public function actionGetClaimReport()
 {
     //get a record model using hostname
     header('Content-Type: application/json');
     $jsonMessage = array();
     if ($_POST['hostname']) {
         $hostname = parse_url($_POST['hostname'], PHP_URL_HOST);
         $criteria = new CDbCriteria();
         $criteria->join = 'right join claimaccount ON claimaccount.account_id = t.account_id';
         $criteria->compare("claimaccount.websiteURL", $hostname);
         $record = Records::model()->find($criteria);
         if ($record) {
             $jsonMessage['success'] = true;
             $jsonMessage['totalNumEntries'] = $record->getTotalNumberOfEntries();
             $jsonMessage['totalEntriesToday'] = $record->getTotalNumberOfEntriesToday();
             $jsonMessage['totalTheseWeek'] = $record->getThisWeekreport();
             $jsonMessage['message'] = $hostname;
         }
     } else {
         $jsonMessage['success'] = false;
     }
     echo json_encode($jsonMessage);
     //
 }
예제 #5
0
 public function actionMobile()
 {
     if (isset($_REQUEST['accountID'])) {
         $accountMdl = Accounts::model()->findByPk($_REQUEST['accountID']);
         $fileName = $accountMdl->claimAccountName . ' - ' . date("Y-m-d") . '-all-mobilenumbers';
         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");
         $criteria = new CDbCriteria();
         $criteria->compare("account_id", $_REQUEST['accountID']);
         $criteria->order = "date_created DESC";
         $records = Records::model()->findAll($criteria);
         $isFirst = true;
         foreach ($records as $curRecord) {
             $data = json_decode($curRecord->claimData, true);
             if ($isFirst) {
                 //print heads
                 echo "Mobile Number\n";
                 $isFirst = false;
             }
             //retrieve mobile number
             $arrayVals = array_values($data);
             $extractedMobile = MobileNumberExtractor::extractMobileNumbers($arrayVals);
             if ($extractedMobile != false) {
                 /* check if present at blacklist*/
                 $crt = new CDbCriteria();
                 $crt->compare('mobile_number', $extractedMobile);
                 if (!BlackListedMobile::model()->exists($crt)) {
                     echo $extractedMobile . PHP_EOL;
                 }
             }
         }
     } else {
         throw new CHttpException(404, "Yikes , You forgot to pass in the Account ID");
     }
 }
예제 #6
0
<?php

$model = Accounts::model();
/* @var $this AccountsController */
/* @var $data Accounts */
/* @var $model Accounts*/
/* @var $recordMdl Records*/
$recordMdl = Records::model();
$recordMdl->account_id = $data->account_id;
$newBaseUrl = Yii::app()->baseUrl;
/*Add style*/
$newStyle = <<<EOL
.site-availability-indicator{
    height: 36px;
    background-color: green;
    float: right;
    width: 36px;
    border-radius: 81px;
    position: relative;
    top: -16px;
    margin-bottom: -31px;
    padding: 6px;
    text-align: center;
    vertical-align: middle;
    height: 35px;
    width: 45px;
    padding: 6px;
    text-align: center;
    vertical-align: middle;
    height: 35px;
    padding-top: 15px;
예제 #7
0
 public function getThisWeekreport()
 {
     //using accountID
     $criteria = new CDbCriteria();
     $criteria->compare("account_id", $this->account_id);
     /* sunday 00.00 hrs - saturday 23:59 hrs*/
     // $startingDate = date("Y-m-d 24:00:00",strtotime('sunday last week')  );
     // $endDate = date("Y-m-d 23:59:59",strtotime('saturday this week')  );
     $startingDate = date("Y-m-d 12:00:00", strtotime('friday last week'));
     $endDate = date("Y-m-d 23:59:00", strtotime('friday this week'));
     $criteria->addBetweenCondition("date_created", $startingDate, $endDate);
     //$criteria->group = "ip_address";
     $criteria->distinct = true;
     return Records::model()->count($criteria);
 }