private function addEvent($type, $id, $email, $datetime)
 {
     echo 'Adding ' . strtoupper($type) . ' to campaign ' . $id . ' with date of ' . $datetime . ' and email of ' . $email . "\r\n";
     $StoreModel = new Store();
     $encryptedEmail = $StoreModel->encryptEmail($email);
     // Look for this email address in store table
     $StoreRows = Store::model()->with('store2contact')->findAll(array('condition' => 'email = :email', 'params' => array(':email' => $encryptedEmail)));
     // collect our warehouse_ids up to match in campaign_contact table.
     $warehouseIDs = [];
     if (sizeof($StoreRows)) {
         // Save 1 suppression row for every instance of the email address in the store table - use store_id
         foreach ($StoreRows as $Store) {
             if ($Store->store2contact != null) {
                 $warehouseIDs[] = $Store->store2contact->contact_warehouse_id;
             }
         }
         $Contacts = null;
         // check for contact
         if (sizeof($warehouseIDs) && is_numeric($id)) {
             //Bounces
             if ($type === 'bounce') {
                 $Contacts = CampaignContact::model()->updateAll(array('bounced' => $datetime), "campaign_id = :campaign_id AND warehouse_id IN (" . implode(',', $warehouseIDs) . ") AND bounced IS NULL", array(':campaign_id' => $id));
             } else {
                 $Contacts = CampaignContact::model()->updateAll(array('opened' => $datetime), "campaign_id = :campaign_id AND warehouse_id IN (" . implode(',', $warehouseIDs) . ") AND opened IS NULL", array(':campaign_id' => $id));
             }
         }
         echo 'Updated ' . sizeof($Contacts) . ' contact';
     } else {
         echo 'Campaign contact not found' . "\r\n";
     }
     echo "\r\n";
 }
Exemple #2
0
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $result = Managers::model()->find('name=? and is_quit=?', array($this->username, "0"));
     if ($result) {
         if ($result->password == md5($this->username . md5($this->password))) {
             $this->_id = $result->id;
             $this->errorCode = self::ERROR_NONE;
             $token = md5($result->id . $this->password);
             //Yii::app()->cache_redis->set($result->id.'.UserToken',$token);
             $store = Store::model()->findAll('manager=:id', array(':id' => $result->id));
             $store_ids = array();
             if ($store) {
                 foreach ($store as $key => $val) {
                     $store_ids[] = $val->id;
                 }
             }
             Yii::app()->user->setState('token', $token);
             Yii::app()->user->setState('info', $result);
             Yii::app()->user->setState('store', $store);
             Yii::app()->user->setState('store_ids', $store_ids);
         } else {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         }
     } else {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     }
     return !$this->errorCode;
 }
Exemple #3
0
 public function run($args)
 {
     exit('Disabled');
     $Stores = Store::model()->with('organisation')->findAll();
     foreach ($Stores as $Store) {
         if (strlen($Store->email)) {
             print $Store->first_name . ',' . $Store->last_name . ',' . $Store->email . ',' . $Store->organisation->title . ',' . $this->getEmailPrefs($Store->contact_email) . "\r\n";
             //print $Store->last_name . "\n";
             //print $Store->address_line_1 . "\n\n\n";
             //print $Store->phone . "\n\n\n";
             //print $Store->mobile . "\n\n\n";
         }
     }
     exit;
     /*
     $StoreModel = new Store;
     $email = $StoreModel->encryptEmail($email);
     
     $Store = Store::model()->findAll(array(
     	
     	'condition' => 'email = :email',
     	'params' => array(
     		':email' => $email,
     	),
     	
     ));
     
     print_r($Store);
     */
 }
 public function actionAutocomplete($query)
 {
     $json = array(array('id' => 0, 'value' => Yii::t('store', 'Default')));
     $stores = Store::model()->findAll("name LIKE '%{$query}%' ");
     foreach ($stores as $store) {
         $json[] = array('id' => $store->category_id, 'value' => $store->name);
     }
     echo CJSON::encode($json);
 }
Exemple #5
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $this->pageTitle = "POSnail";
     $data = array();
     if (Yii::app()->user->parts == 2) {
         $service = new Service('search');
         $customer = new Customer('search');
         $employee = new User('search');
         $model = Store::model()->find('pk_s_id = :pk_s_id', array(':pk_s_id' => Yii::app()->user->storeID));
         $data = array('model' => $model, 'customer' => $customer, 'employee' => $employee, 'service' => $service);
     }
     $this->render($this->view . 'index', $data);
 }
 public function actionIndex()
 {
     $model = new ConsumerLog('search');
     $model->unsetAttributes();
     $amount = ConsumerLog::model()->getAmount();
     if ($_GET['ConsumerLog']) {
         $model->attributes = $_GET['ConsumerLog'];
         /* var_dump($_GET);
            exit;*/
         $amount = ConsumerLog::model()->getAmount($_GET['ConsumerLog']);
     }
     $names = Store::model()->getName();
     $this->render('index', ['model' => $model, 'names' => $names, 'amount' => $amount]);
 }
 public function run($args)
 {
     exit('Disabled');
     $StoreRows = Store::model()->findAll(array('condition' => "salutation IN ('0','1','2','3','4','5')"));
     $salutations = array(0 => 'Mr', 1 => 'Mrs', 2 => 'Ms', 3 => 'Miss', 4 => 'Dr', 5 => 'Prof');
     $fixed = 0;
     foreach ($StoreRows as $Store) {
         $wrongSalutation = $Store->salutation;
         $Store->salutation = $salutations[$wrongSalutation];
         if ($Store->save(true, array('salutation'))) {
             $fixed++;
         }
         print 'Fixed salutation from ' . $wrongSalutation . ' to ' . $Store->salutation . "\n";
     }
     print "\n\n" . 'fixed ' . $fixed . ' of ' . count($StoreRows) . " store rows \n\n";
 }
 public function actionUpdate($id)
 {
     $model = new CategoryForm();
     if (isset($_POST['CategoryForm'])) {
         $model->attributes = $_POST['CategoryForm'];
         if ($model->validate()) {
             $model->save();
             $this->redirect(array('index'));
         }
     } else {
         $model->loadDataFromCategory($id);
     }
     $statuses = array(0 => Yii::t('common', 'Disabled'), 1 => Yii::t('common', 'Enabled'));
     $stores = CHtml::listData(Store::model()->findAll(), 'store_id', 'name');
     $stores[0] = Yii::t('store', 'Default');
     $this->render('update', array('model' => $model, 'stores' => $stores, 'statuses' => $statuses));
 }
Exemple #9
0
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     if (strpos($this->username, "@")) {
         $user = User::model()->notsafe()->findByAttributes(array('email' => $this->username));
     } else {
         $user = User::model()->notsafe()->findByAttributes(array('username' => $this->username));
     }
     if ($_SESSION['store']['store_id']) {
         $store = Store::model()->findByPk($_SESSION['store']['store_id']);
     }
     if ($user === null) {
         if (strpos($this->username, "@")) {
             $this->errorCode = self::ERROR_EMAIL_INVALID;
         } else {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
         }
     } else {
         if (Yii::app()->getModule('user')->encrypting($this->password) !== $user->password) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             if ($user->status == 0 && Yii::app()->getModule('user')->loginNotActiv == false) {
                 $this->errorCode = self::ERROR_STATUS_NOTACTIV;
             } else {
                 if ($user->status == -1) {
                     $this->errorCode = self::ERROR_STATUS_BAN;
                 } else {
                     if ($user->superuser == 0) {
                         $this->errorCode = self::ERROR_STATUS_NOTADMIN;
                     } else {
                         if ($store->user_id !== $user->id) {
                             $this->errorCode = self::ERROR_STATUS_NOTOWNER;
                         } else {
                             $this->_id = $user->id;
                             $this->username = $user->username;
                             $this->errorCode = self::ERROR_NONE;
                         }
                     }
                 }
             }
         }
     }
     return !$this->errorCode;
 }
Exemple #10
0
 public function init()
 {
     parent::init();
     $host = Yii::app()->request->hostInfo;
     $domain = str_replace('http://', '', $host);
     if ($host == 'http://' . F::sg('site', 'shopDomain')) {
         Yii::app()->theme = 'store';
     } else {
         $store = Store::model()->findByAttributes(array('domain' => $domain));
         $session = new CHttpSession();
         $session->open();
         //	    $session->destroy();
         $session['store'] = array('store_id' => $store->store_id, 'name' => $store->name, 'email' => $store->email, 'theme' => $store->theme);
         //	    $store_name = $session['store'];  // get session variable 'name1'
         //	    foreach ($session as $name => $value) // traverse all session variables
         //		$session['name3'] = $value3;  // set session variable 'name3'
         //	    echo $store->domain;
         //	    exit;
         Yii::app()->theme = $store->theme;
         //	    print_r($_SESSION);
     }
     //	    exit;
 }
Exemple #11
0
 public function authenticate()
 {
     // Try to get user from User table - this will be an administrator
     $User = User::model()->findByAttributes(array('email' => strtolower($this->username), 'verified' => 1, 'mothballed' => 0));
     if (!is_null($User)) {
         // We have an admin user
         if (isset($User->password)) {
             if ($User->password === hash('sha256', $this->password . SHASALT)) {
                 $this->errorCode = self::ERROR_NONE;
                 $this->_id = $User->id;
                 $this->userType = 'admin';
             } else {
                 $this->errorCode = self::ERROR_PASSWORD_INVALID;
             }
         }
     } else {
         // For encryption
         $Store = new Store();
         $Criteria = new CDbCriteria();
         $Criteria->condition = "\n\t\t\t\temail = :email AND \n\t\t\t\torigin_organisation_id = :origin_organisation_id AND \n\t\t\t\tpassword IS NOT NULL \n\t\t\t";
         $Criteria->params = array(':email' => $Store->encryptEmail($this->username), ':origin_organisation_id' => 10);
         $Store = Store::model()->with('store2contact', 'store2contact.accession')->find($Criteria);
         if (!is_null($Store)) {
             // We have a user from THE LIST
             // Does the password match?
             if ($Store->store2contact->accession->password === hash('sha256', $this->password . SHASALT)) {
                 $this->errorCode = self::ERROR_NONE;
                 $this->_id = $Store->id;
                 $this->userType = 'contact';
             } else {
                 $this->errorCode = self::ERROR_PASSWORD_INVALID;
             }
         }
     }
     return !$this->errorCode;
 }
 public function actionIndex()
 {
     $stores = Store::model()->findAll();
     $this->render('index', array('stores' => $stores));
 }
Exemple #13
0
<?php 
$this->breadcrumbs[] = Yii::t('crud', 'Inventories');
Yii::app()->clientScript->registerScript('search', "\n    \$('.search-button').click(function(){\n        \$('.search-form').toggle();\n        return false;\n    });\n    \$('.search-form form').submit(function(){\n        \$.fn.yiiGridView.update(\n            'inventory-grid',\n            {data: \$(this).serialize()}\n        );\n        return false;\n    });\n    ");
?>

<?php 
$this->widget("TbBreadcrumbs", array("links" => $this->breadcrumbs));
?>
<h1>
    
    <?php 
echo Yii::t('crud', 'Inventories');
?>
    <small><?php 
echo Yii::t('crud', 'Manage');
?>
</small>
    
</h1>

<?php 
$this->renderPartial("_toolbar", array("model" => $model));
?>



<?php 
$this->widget('TbGridView', array('id' => 'inventory-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'template' => '{pager}{items}{pager}{summary}', 'pager' => array('class' => 'TbPager', 'displayFirstAndLast' => true), 'columns' => array(array('class' => 'CLinkColumn', 'header' => '', 'labelExpression' => '$data->itemLabel', 'urlExpression' => 'Yii::app()->controller->createUrl("view", array("inventory_id" => $data["inventory_id"]))'), array('class' => 'editable.EditableColumn', 'name' => 'inventory_id', 'editable' => array('url' => $this->createUrl('/sakila/slim/inventory/editableSaver'))), array('name' => 'film_id', 'value' => 'CHtml::value($data,\'film.itemLabel\')', 'filter' => CHtml::listData(Film::model()->findAll(array('limit' => 1000)), 'film_id', 'itemLabel')), array('name' => 'store_id', 'value' => 'CHtml::value($data,\'store.itemLabel\')', 'filter' => CHtml::listData(Store::model()->findAll(array('limit' => 1000)), 'store_id', 'itemLabel')), array('class' => 'editable.EditableColumn', 'name' => 'last_update', 'editable' => array('url' => $this->createUrl('/sakila/slim/inventory/editableSaver'))), array('class' => 'TbButtonColumn', 'viewButtonUrl' => 'Yii::app()->controller->createUrl("view", array("inventory_id" => $data->inventory_id))', 'updateButtonUrl' => 'Yii::app()->controller->createUrl("update", array("inventory_id" => $data->inventory_id))', 'deleteButtonUrl' => 'Yii::app()->controller->createUrl("delete", array("inventory_id" => $data->inventory_id))'))));
Exemple #14
0
 public function actionOpen()
 {
     // See http://documentation.mailgun.com/user_manual.html#webhooks
     // Mail so we know we have received the opened webhook
     // Set up authorisation
     $authString = $_POST['timestamp'] . $_POST['token'];
     $authHash = hash_hmac('sha256', $authString, Yii::app()->params['mailgun']['key']);
     // Check Auth
     if ($authHash === $_POST['signature']) {
         // Huzzah! Authorized HTTP POST from Mailgun
         $uniques = array();
         $StoreModel = new Store();
         // Encrypt the email so we can find a match
         $openedEmailAddress = $StoreModel->encryptEmail($_POST['recipient']);
         // Look for this email address in store table
         $StoreRows = Store::model()->with('store2contact')->findAll(array('condition' => 'email = :email', 'params' => array(':email' => $openedEmailAddress)));
         // collect our warehouse_ids up to match in campaign_contact table.
         $warehouseIDs = [];
         if (sizeof($StoreRows)) {
             // Save 1 suppression row for every instance of the email address in the store table - use store_id
             foreach ($StoreRows as $Store) {
                 // expired? No store to contact. Skip
                 if (!is_null($Store->store2contact)) {
                     $warehouseIDs[] = $Store->store2contact->contact_warehouse_id;
                 }
             }
             // check for campaign_contacts.
             if (sizeof($warehouseIDs) && is_numeric($_POST['campaign_id']) && is_numeric($_POST['group_id'])) {
                 // it's a bounce of a campaign email. Mark against the row.
                 CampaignContact::model()->updateAll(array('opened' => date('Y-m-d H:i:s', $_POST['timestamp'])), "campaign_id = :campaign_id AND group_id = :group_id AND warehouse_id IN (" . implode(',', array_filter($warehouseIDs)) . ") AND opened IS NULL", array(':campaign_id' => $_POST['campaign_id'], ':group_id' => $_POST['group_id']));
             }
             header("HTTP/1.0 200 Ok");
             exit;
         } else {
             header("HTTP/1.0 404 Not Found");
             exit('Not Found');
         }
     } else {
         // Go away
         sleep(5);
         header("HTTP/1.0 401 Unauthorized");
         exit('Unauthorized');
     }
 }
Exemple #15
0
 private function import()
 {
     $db = new PDO(Yii::app()->params['db']['connectionString'], Yii::app()->params['db']['username'], Yii::app()->params['db']['password'], array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));
     $resultRows = $db->query('SELECT * FROM raw_import WHERE id > ' . $this->lastRowProcessed . ' LIMIT ' . $this->rowsToProcess);
     $suppressionCount = 0;
     echo "\n\n" . 'Pointer is at ' . $this->lastRowProcessed . "\n\n";
     while ($data = $resultRows->fetch(PDO::FETCH_ASSOC)) {
         $StoreView = null;
         $DupeMatch = null;
         $CodeMatch = null;
         $Store2Contact = null;
         //20532
         // 1 yes 0 no 2 unknown
         $contact_email = 2;
         //unkown
         $contact_post = 2;
         $contact_sms = 2;
         $organisation_id = null;
         // create base Store instance.
         $StoreView = new Store();
         $data['CCR_Client_URN'] = $this->emptyToNull($data['CCR_Client_URN']);
         if (is_null($data['CCR_Client_URN'])) {
             // no URN no insert
             continue;
         }
         $StoreView['origin_unique_id'] = trim($data['CCR_Client_URN']);
         $StoreView['csv_file_uuid'] = $data['Cleaning_UUID'];
         $StoreView['date_imported'] = date('Y-m-d H:i:s');
         //Get organisation id
         switch ($data['CCR_Organisation']) {
             case 'Example 1':
                 $organisation_id = 1;
                 switch ($data['CCR_Email_Allow']) {
                     case 'Allow':
                         $contact_email = 1;
                         break;
                     case 'Do Not Allow':
                         $contact_email = 0;
                         break;
                 }
                 break;
             default:
                 break;
         }
         $StoreView['contact_email'] = $contact_email;
         $StoreView['contact_sms'] = $contact_sms;
         $StoreView['contact_post'] = $contact_post;
         $StoreView['origin_organisation_id'] = $organisation_id;
         $StoreView['salutation'] = $this->emptyToNull($data['CCR_Title']);
         $StoreView['first_name'] = $this->emptyToNull($data['CCR_Forename']);
         $StoreView['last_name'] = $this->emptyToNull($data['CCR_Surname']);
         if (!is_null($StoreView['last_name'])) {
             $StoreView['last_name'] = rtrim(mcrypt_decrypt($this->cipher, $this->key3, base64_decode($StoreView['last_name']), $this->mode, $this->iv));
         }
         $StoreView['address_line_1'] = $this->emptyToNull($data['CCR_Address1']);
         if (!is_null($StoreView['address_line_1'])) {
             $StoreView['address_line_1'] = rtrim(mcrypt_decrypt($this->cipher, $this->key2, base64_decode($StoreView['address_line_1']), $this->mode, $this->iv));
         }
         $StoreView['address_line_2'] = $this->emptyToNull($data['CCR_Address2']);
         $StoreView['address_line_3'] = $this->emptyToNull($data['CCR_Address3']);
         $StoreView['address_line_4'] = $this->emptyToNull($data['CCR_Address4']);
         $StoreView['address_town'] = $this->emptyToNull($data['CCR_Town']);
         $data['CCR_Postcode'] = trim($data['CCR_Postcode']);
         if ($this->isPostcode($data['CCR_Postcode'])) {
             $StoreView['address_postcode'] = $data['CCR_Postcode'];
         } else {
             $StoreView['address_postcode'] = null;
         }
         $StoreView['address_county'] = $this->emptyToNull($data['CCR_County']);
         // phone and mobile
         //regex to to see if provided phone number is mobile
         $phone1 = intval(rtrim(mcrypt_decrypt($this->cipher, $this->key4, base64_decode($data['CCR_Phone1']), $this->mode, $this->iv)));
         $phone2 = intval(rtrim(mcrypt_decrypt($this->cipher, $this->key5, base64_decode($data['CCR_Phone2']), $this->mode, $this->iv)));
         if ($phone1 && $phone2) {
             if ($this->isMobile($phone1)) {
                 $StoreView['mobile'] = $phone1;
                 $StoreView['phone'] = $phone2;
             }
             if ($this->isMobile($phone2)) {
                 $StoreView['mobile'] = $phone2;
                 $StoreView['phone'] = $phone1;
             }
         } else {
             if ($phone1) {
                 if ($this->isMobile($phone1)) {
                     $StoreView['mobile'] = $phone1;
                 } else {
                     $StoreView['phone'] = $phone1;
                 }
             } else {
                 if ($phone2) {
                     if ($this->isMobile($phone2)) {
                         $StoreView['mobile'] = $phone2;
                     } else {
                         $StoreView['phone'] = $phone2;
                     }
                 }
             }
         }
         // end phone and mobile
         // email
         $StoreView->email = $data['CCR_Email'];
         if (!is_null($StoreView->email)) {
             $StoreView->email = rtrim(mcrypt_decrypt($this->cipher, $this->key1, base64_decode($StoreView['email']), $this->mode, $this->iv));
         }
         if (!is_null($StoreView['email']) && !filter_var($StoreView->email, FILTER_VALIDATE_EMAIL)) {
             $StoreView->email = null;
         }
         // end email
         // Save the contact in the store
         if (!$StoreView->validate()) {
             print '$StoreView->errors:' . "\n";
             print_r($StoreView->errors);
         } else {
             $this->totalImported++;
             //in dupe set
             $data['CCR_Ind_Set'] = (int) trim($data['CCR_Ind_Set']);
             /*
             if(this row has (int)CCR_Ind_Set > 0){
             	
             	select existing 1+ duplicates
             
             	if(this row (int)CCR_Ind_Set matches a ccr_duplicate_id with the same organisation_id){
             	
             		// mega dupe
             		if( existing record has 'Yes' for CCR_Ind_Dupe1 ){
             	
             			insert and expire this row
             		}
             		else
             		{
             			expire existing
             			insert this row
             		}
             	}
             	else
             	{
             		// no other rows in same org
             		insert this row
             	}
             }
             else
             {
             	// not a duplicate
             }
             */
             // is this the ccr dupe favoured row?
             $StoreView['ccr_ind_dupe1'] = trim($data['CCR_Ind_Dupe1']) === 'Yes' ? 1 : 0;
             // If CCR has detected a duplicate...
             if ($data['CCR_Ind_Set'] > 0) {
                 $this->totalDupes++;
                 $StoreView->ccr_duplicate_id = $data['CCR_Ind_Set'];
                 //print "CCR_Ind_Set > 0\n";
                 //first of all, let see if the dupe has the same origin id as a previous in the database
                 $DupeMatches = Store::model()->with(array('store2contact'))->findAllByAttributes(array('ccr_duplicate_id' => $data['CCR_Ind_Set'], 'date_expired' => null), array('index' => 'origin_organisation_id'));
                 // print ('starting new loop with dupes');
                 if (sizeof($DupeMatches)) {
                     // print "size DupeMatches > 0\n";
                     $Store2Contact = null;
                     // print_r(array_keys($DupeMatches));
                     // print "\nDupeMatch orgs: " . $organisation_id . "\n";
                     if (array_key_exists((int) $organisation_id, $DupeMatches)) {
                         // we have a match from the same organisation
                         // print "org exists in dupes data\n";
                         //not do in the correct order, needs to be done with CCR_Ind_Set
                         //we need to expire the match and update the warehouse record
                         //we the new one
                         //echo 'DupeMatch';
                         if ($DupeMatches[$organisation_id]->ccr_ind_dupe1) {
                             // print "Alread have trusted row, expire row\n";
                             // already have a trusted row. Expire and insert this one.
                             $StoreView->date_expired = date('Y-m-d H:i:s');
                             $StoreView->ccr_ind_dupe1 = 0;
                             // just in case.
                         } else {
                             // print "Update store row\n";
                             // update store row
                             $DupeMatches[$organisation_id]->date_expired = date('Y-m-d H:i:s');
                             $DupeMatches[$organisation_id]->save();
                             // update any suppression list rows to not have warehouse or store_id. They're old and expired.
                             SuppressionList::model()->deleteAll('store2contact_id = ' . (int) $DupeMatches[$organisation_id]->store2contact->id);
                             // clone the contact_warehouse_id and ind set. Gets saved below.
                             $Store2Contact = $DupeMatches[$organisation_id]->store2contact;
                             // print 'Store2Contact=';
                             // print_r ($Store2Contact->attributes);
                             $Store2Contact->contact_warehouse_id = $DupeMatches[$organisation_id]->store2contact->contact_warehouse_id;
                         }
                     } else {
                         // print "org does not exist in dupes data\n";
                         //is it not a dupe match but someone else has the same dupe id?
                         //if so, lets find their Warehouse ID and then add as a new row
                         $LastDuplicate = end($DupeMatches);
                         $Store2Contact = new Store2Contact();
                         $Store2Contact->contact_warehouse_id = $LastDuplicate->store2contact->contact_warehouse_id;
                     }
                     // the save for dupes is here
                     if (!$StoreView->save()) {
                         print_r($StoreView->errors);
                     }
                     // if we have a store2contact save it here
                     if (!is_null($Store2Contact)) {
                         //update store_id to new one
                         $Store2Contact->store_id = $StoreView->id;
                         $Store2Contact->origin_unique_id = $data['CCR_Client_URN'];
                         $Store2Contact->origin_id = $organisation_id;
                         // print 'saving a (dupe style) store2contact ' . $Store2Contact->id . "\n";
                         if (!$Store2Contact->save()) {
                             print_r($Store2Contact->errors);
                         }
                     }
                     // currently required below.
                     //unset($Store2Contact);
                 }
             }
             // when not a duplicate or there is no other dupe stored yet
             if ($data['CCR_Ind_Set'] == 0 || !sizeof($DupeMatches)) {
                 // save for when no duplicates
                 if (!$StoreView->save()) {
                     print_r($StoreView->errors);
                 }
                 $Warehouse = new Warehouse();
                 if (!$Warehouse->save()) {
                     print_r($Warehouse->errors);
                 }
                 // Create a new Store2Contact row
                 $Store2Contact = new Store2Contact();
                 $Store2Contact->store_id = $StoreView->id;
                 $Store2Contact->contact_warehouse_id = $Warehouse->id;
                 $Store2Contact->origin_unique_id = $data['CCR_Client_URN'];
                 $Store2Contact->origin_id = $organisation_id;
                 if (!$Store2Contact->save()) {
                     print_r($Store2Contact->errors);
                 }
             }
             // Check for non-contactable by email, and add to the supression list
             if ($StoreView->contact_email == 0) {
                 if (!is_null($Store2Contact) && (int) $Store2Contact->id) {
                     $Suppression = new SuppressionList();
                     $Suppression->type = SuppressionList::TYPE_UNSUBSCRIBE;
                     // always save the store id against this row
                     $Suppression->store_id = $StoreView->id;
                     // we have a store2contact row for this person. Add to suppression data.
                     $Suppression->store2contact_id = $Store2Contact->id;
                     //We don't need the warehouse id
                     //$Suppression->warehouse_id = $Store2Contact->contact_warehouse_id;
                     $Suppression->date = date('Y-m-d H:i:s');
                     if ($Suppression->save()) {
                         $suppressionCount++;
                     }
                 }
             }
         }
         unset($data);
         unset($StoreView);
         unset($Store2Contact);
         unset($DupeMatch);
         unset($CodeMatch);
         $this->lastRowProcessed++;
         if (!($this->lastRowProcessed % 100)) {
             $this->completedToNow = $this->lastRowProcessed;
             $timeTotal = microtime(true) - $this->time_start;
             $timeForThis100 = $timeTotal - $this->timeTakenSoFar;
             $this->timeTakenSoFar = $timeTotal;
             $speed = round(1 / $timeForThis100 * 100, 3);
             $currentExecutionTime = round($timeTotal / 60, 2);
             echo $this->lastRowProcessed / 1000 . 'k done in ' . $currentExecutionTime . ' mins. ' . $speed . '  rows/s                    ' . "\r";
         }
     }
     print "\n\n" . $suppressionCount . ' contacts were added to suppression list - not contactable by email' . "\n\n";
 }
Exemple #16
0
 public function focusDynamic($params = array())
 {
     extract($params);
     if (isset($user_id) && $user_id) {
         // $obj = Dynamic::model()->with('focus')->findAll('user_id=:user_id and is_focus=:focus', array(':user_id' => $user_id, ':focus' => '1'));
         $obj = Dynamic::model()->getFocusDynamic($user_id);
         if ($obj) {
             //获取用户信息
             $focus_users = $this->getFocus($user_id);
             $dynamic = array();
             foreach ($obj as $key => $val) {
                 $user_info = $focus_users[$val->focus->focus_id];
                 if ($user_info) {
                     $image = explode(',', $val->dy_images);
                     $images = array();
                     if ($image) {
                         foreach ($image as $k => $v) {
                             $images[] = Yii::app()->params['qiniu']['host'] . $v;
                         }
                     }
                     $dynamic[$key] = array('id' => $val->dy_id, 'content' => $val->dy_content, 'images' => $images, 'num' => $val->dy_agree, 'time' => $val->gmt_created);
                     $dynamic[$key]['logo'] = Yii::app()->params['qiniu']['host'] . $user_info['image'];
                     $dynamic[$key]['nickname'] = $user_info['user_name'];
                     $dynamic[$key]['url'] = 'www.baidu.com';
                 }
             }
             if ($dynamic) {
                 $ret = $this->notice('OK', 0, '成功', $dynamic);
             } else {
                 $ret = $this->notice('OK', 0, '暂无数据', []);
             }
         } else {
             $ret = $this->notice('OK', 0, '暂无数据', []);
         }
     } else {
         //$ret = $this->notice('ERR', 301, '缺少参数', []);
         $obj = Dynamic::model()->findAll(array('order' => 'gmt_created desc', 'limit' => '100'));
         $dynamic = array();
         if ($obj) {
             //user
             $users = User::model()->loadUsers();
             $alliances = Alliance::model()->loadAlliances();
             $stores = Store::model()->loadStores();
             foreach ($obj as $key => $val) {
                 if (!$val->dy_type) {
                     $user = $users[$val->dy_user];
                     if ($user) {
                         $dynamic[$key]['logo'] = Yii::app()->params['qiniu']['host'] . $user['image'];
                         $dynamic[$key]['nickname'] = $user['name'];
                     } else {
                         continue;
                     }
                 } else {
                     if ($val->dy_type == 1) {
                         $alliance = $alliances[$val->dy_user];
                         if ($alliance) {
                             $dynamic[$key]['logo'] = Yii::app()->params['qiniu']['host'] . $alliance['image'];
                             $dynamic[$key]['nickname'] = $alliance['name'];
                         } else {
                             continue;
                         }
                     } else {
                         if ($val->dy_type == 2) {
                             $store = $stores[$val->dy_user];
                             if ($store) {
                                 $dynamic[$key]['logo'] = Yii::app()->params['qiniu']['host'] . $store['image'];
                                 $dynamic[$key]['nickname'] = $store['name'];
                             } else {
                                 continue;
                             }
                         }
                     }
                 }
                 $image = explode(',', $val->dy_images);
                 $images = array();
                 if ($image) {
                     foreach ($image as $k => $v) {
                         $images[] = Yii::app()->params['qiniu']['host'] . $v;
                     }
                 }
                 $dynamic[$key] = array('id' => $val->dy_id, 'content' => $val->dy_content, 'images' => $images, 'num' => $val->dy_agree, 'time' => $val->gmt_created);
                 $dynamic[$key]['url'] = 'www.baidu.com';
             }
             if ($dynamic) {
                 $ret = $this->notice('OK', 0, '成功', $dynamic);
             } else {
                 $ret = $this->notice('OK', 0, '暂无数据', []);
             }
         } else {
             $ret = $this->notice('OK', 0, '暂无数据', []);
         }
     }
     return $ret;
 }
Exemple #17
0
		<?php 
echo $form->labelEx($description, 'meta_keyword');
?>
		<?php 
echo TbHtml::activeTextArea($description, 'meta_keyword');
?>
		<?php 
echo $form->error($description, 'meta_keyword');
?>
		</div><!-- row -->
		<div class="row">
		<?php 
echo $form->labelEx($model, 'store_id');
?>
		<?php 
echo $form->dropDownList($model, 'store_id', TbHtml::listData(Store::model()->findAll(array('order' => 'name')), 'id', 'name'));
?>
		<?php 
echo $form->error($model, 'store_id');
?>
		</div><!-- row -->
		<div class="row">
		<label for="Image_file"><?php 
echo Yii::t('label', 'Image');
?>
</label>
			<span class="btn btn-success fileinput-button">
				<i class="icon-plus icon-white"></i>
				<span>Select files...</span>
				<?php 
$this->widget('yiiwheels.widgets.fileupload.WhBasicFileUpload', array('attribute' => 'file', 'model' => $image, 'uploadAction' => $this->createUrl('upload'), 'pluginOptions' => array('dataType' => 'json', 'acceptFileTypes' => "js:/(\\.|\\/)(gif|jpe?g|png)\$/i", 'maxFileSize' => 4000000, 'maxNumberOfFiles' => 2, 'getNumberOfFiles' => "js:function(){return jQuery('#bfiles .row').length;}", 'done' => 'js:function(e, data){
Exemple #18
0
<p>This script will create 100 rows of randomly-generated content for the database</p>

<div class="alert alert-warning">
	<p>You are on the server <em><?php 
print $_SERVER['HTTP_HOST'];
?>
</em>, which is the <?php 
print ENVIRONMENT;
?>
 environment.</p>
</div>

<p>Your current data is as follows:</p>

<?php 
$Store = Store::model()->count();
$Store2Contact = Store2Contact::model()->count();
$Accession = Accession::model()->count();
$CleanWarehouse = Yii::app()->db->createCommand("SELECT COUNT(*) as tot FROM clean_warehouse")->queryRow();
?>

<table class="table table-bordered">
	<tr>
		<th>Table</th>
		<th>Rows</th>
	</tr>
	<tr>
		<td>store</td>
		<td><?php 
print $Store;
?>
Exemple #19
0
<?php

$this->breadcrumbs[] = Yii::t('crud', 'Inventories');
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\$('.search-form').toggle();\nreturn false;\n});\n\$('.search-form form').submit(function(){\n\$.fn.yiiGridView.update('inventory-grid', {\ndata: \$(this).serialize()\n});\nreturn false;\n});\n");
?>

<?php 
$this->widget("TbBreadcrumbs", array("links" => $this->breadcrumbs));
?>
<h1>
    <?php 
echo Yii::t('crud', 'Inventories');
?>
 <small><?php 
echo Yii::t('crud', 'Manage');
?>
</small>
</h1>

<?php 
$this->renderPartial("_toolbar", array("model" => $model));
$this->widget('TbGridView', array('id' => 'inventory-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'pager' => array('class' => 'TbPager', 'displayFirstAndLast' => true), 'columns' => array(array('class' => 'editable.EditableColumn', 'name' => 'inventory_id', 'editable' => array('url' => $this->createUrl('/sakila/hybrid/inventory/editableSaver'))), array('name' => 'film_id', 'value' => 'CHtml::value($data,\'film.itemLabel\')', 'filter' => CHtml::listData(Film::model()->findAll(array('limit' => 1000)), 'film_id', 'itemLabel')), array('name' => 'store_id', 'value' => 'CHtml::value($data,\'store.itemLabel\')', 'filter' => CHtml::listData(Store::model()->findAll(array('limit' => 1000)), 'store_id', 'itemLabel')), array('class' => 'editable.EditableColumn', 'name' => 'last_update', 'editable' => array('url' => $this->createUrl('/sakila/hybrid/inventory/editableSaver'))), array('class' => 'TbButtonColumn', 'viewButtonUrl' => "Yii::app()->controller->createUrl('view', array('inventory_id' => \$data->inventory_id))", 'updateButtonUrl' => "Yii::app()->controller->createUrl('update', array('inventory_id' => \$data->inventory_id))", 'deleteButtonUrl' => "Yii::app()->controller->createUrl('delete', array('inventory_id' => \$data->inventory_id))"))));
 public function actionPayment($id)
 {
     $cart = $this->getCart();
     $add = CheckoutAddress::model()->findByPk($id);
     $link;
     $onlinePaymentMethodName;
     $extrapObj = array();
     $orderArray = array();
     $classArray = array();
     if (!empty($add) && !empty($cart['items'])) {
         if (isset($_POST['Payment']['payment_method'])) {
             $pay_method = $_POST['Payment']['payment_method'];
             $cart['payment'] = $pay_method == 4 ? 2 : $pay_method;
             $paymentType = is_numeric($pay_method) ? 'others' : 'online';
             $order = new Order();
             $order->order_status_id = 1;
             $order->total = $this->getCartTotal();
             $order->ip = Yii::app()->request->userHostAddress;
             $order->user_agent = Yii::app()->request->userAgent;
             $order->firstname = $add->firstname;
             $order->lastname = $add->lastname;
             $order->email = $add->email;
             $order->telephone = $add->telephone;
             $order->payment_firstname = $add->firstname;
             $order->payment_lastname = $add->lastname;
             $order->payment_company = '';
             $order->payment_tax_id = 0;
             $order->payment_address_1 = $add->address_1;
             $order->payment_address_2 = $add->address_2;
             $order->payment_city = $add->city;
             $order->payment_postcode = $add->postal_code;
             $order->payment_country_id = $add->country_id;
             $order->payment_zone_id = $add->zone_id;
             $order->payment_method = $cart['payment'];
             $order->payment_code = uniqid() . rand(1, 9);
             $order->shipping_firstname = $add->firstname;
             $order->shipping_lastname = $add->lastname;
             $order->shipping_company = '';
             $order->shipping_address_1 = $add->address_1;
             $order->shipping_address_2 = $add->address_2;
             $order->shipping_city = $add->city;
             $order->shipping_postcode = $add->postal_code;
             $order->shipping_country_id = $add->country_id;
             $order->shipping_zone_id = $add->zone_id;
             $order->shipping_method = 2;
             if ($add->zone_id == 2412) {
                 $order->shipping_method = 1;
             }
             $storeid = UtilityHelper::yiiparam('storeID');
             $store = Store::model()->findByPk($storeid);
             $order->store_id = $storeid;
             $order->store_name = $store->name;
             $order->store_url = $store->url;
             $order->payment_country = Country::model()->findByPk($order->payment_country_id)->name;
             $order->payment_zone = Zone::model()->findByPk($order->payment_zone_id)->name;
             $order->shipping_country = $order->payment_country;
             $order->shipping_zone = $order->payment_zone;
             if ($order->save()) {
                 foreach ($cart['items'] as $product) {
                     $orderproduct = new OrderProduct();
                     $orderproduct->order_id = $order->id;
                     $orderproduct->product_id = $product['product_id'];
                     $orderproduct->name = $product['name'];
                     $orderproduct->model = $product['model'];
                     $orderproduct->quantity = $product['quantity'];
                     $orderproduct->price = $product['price'];
                     $orderproduct->total = $product['total'];
                     $orderproduct->tax = 0;
                     if ($orderproduct->save()) {
                         if (!empty($product['option'])) {
                             foreach ($product['option'] as $orderoption) {
                                 $orderoption->order_id = $order->id;
                                 $orderoption->order_product_id = $orderproduct->id;
                                 $orderoption->save();
                             }
                         }
                     } else {
                         Yii::log("CartPaymentOrderProductErrors: " . CVarDumper::dumpAsString($orderproduct->getErrors()), CLogger::LEVEL_ERROR, "cart.actions.payment");
                     }
                 }
                 //Yii::app()->user->setState('user_cart', NULL);
                 $extrap = array();
                 //
                 switch ($paymentType) {
                     case 'others':
                         // Will need to loop through the ids for non online payment to do this properly
                         if ($pay_method == 1) {
                             $link = '_cash';
                             $extrap = array('orderID' => $order->id, 'total' => $order->total);
                             UtilityHelper::changeOrderStatus($order->id);
                         } else {
                             if ($pay_method == 3) {
                                 $link = '_bank';
                                 $extrap = array('orderID' => $order->id, 'total' => $order->total);
                             }
                         }
                         break;
                     case 'online':
                         $subClasses = new PaymentGatewayHelper();
                         $subClassesArray = $subClasses->getSubClasses();
                         foreach ($subClassesArray as $class => $payOption) {
                             ${$class} = new $class();
                             $onlinePaymentMethodName = ${$class}->getPaymentName();
                             if ($pay_method == $onlinePaymentMethodName) {
                                 $link = ${$class}->getViewLink();
                                 ${$class}->setOrderObj($order);
                                 $extrapObj = ${$class}->getOrderObj();
                                 foreach ($extrapObj as $field => $value) {
                                     $orderArray[$field] = $value;
                                 }
                                 $link = ${$class}->getViewLink();
                                 $extrap = array('orderID' => $orderArray['id'], 'total' => $orderArray['total']);
                                 ${$class}->regPaymentTransaction($order);
                                 $classArray['pay_method'] = $pay_method;
                             } else {
                                 continue;
                             }
                         }
                         break;
                     default:
                         break;
                 }
                 if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                     $this->renderPartial($link, array_merge(array('ref' => $order->payment_code), $extrap, $classArray), false, true);
                     Yii::app()->end();
                 }
                 $this->render($link, array_merge(array('ref' => $order->payment_code), $extrap, $classArray));
                 Yii::app()->end();
             } else {
                 Yii::log("CartPaymentErrors: " . CVarDumper::dumpAsString($order->getErrors()), CLogger::LEVEL_ERROR, "cart.actions.payment");
             }
         }
         if (Yii::app()->getRequest()->getIsAjaxRequest()) {
             $this->renderPartial('_payment', array('app' => $add), false, true);
             Yii::app()->end();
         }
         $this->render('payment', array('app' => $add));
         Yii::app()->end();
     }
     $this->redirect(array('cart'));
 }
Exemple #21
0
 public function actionEdit($id)
 {
     $typeAccount = Yii::app()->user->hasState('typeAccountCurrent') ? Yii::app()->user->getState('typeAccountCurrent') : null;
     $this->pageTitle = $typeAccount != null ? 'Edit Account Of ' . $typeAccount : 'Edit Account';
     $model = $this->loadModel($id);
     $passwordOld = $model->s_password;
     $storeOld = $model->s_store_id;
     $store = Store::model()->findAll('i_account_manager = 0');
     $model->s_password = '******';
     if (isset($_POST['User'])) {
         $flagSave = false;
         $flagChangeImage = false;
         $model->attributes = $_POST['User'];
         $levelAccount = Yii::app()->user->level;
         $role = Roles::model()->findByPk($model->i_user_role);
         if ($model->s_store_id != $storeOld) {
             $checkStore = Store::model()->find('pk_s_id = :pk_s_id', array(':pk_s_id' => $model->s_store_id));
             if ($checkStore == null) {
                 $model->s_store_id = $storeOld;
                 $model->addError('s_store_id', 'Store invalid');
             }
             $storeManager = $checkStore->userManager();
             if ($storeManager != null) {
                 $model->addError('i_user_role', 'The store has managed. Please select user type other or stores other');
             }
         }
         $model->i_manager = 0;
         $model->i_device_max = intval($model->i_device_max);
         $model->i_flag_sync = 1;
         if ($model->i_user_role == 3) {
             $model->i_manager = 1;
         }
         if ($role == null) {
             $model->addError('i_user_role', 'Type not exist');
         } elseif ($levelAccount < $role->level) {
             $model->addError('i_user_role', 'Your are not authorized to make this type of account');
         }
         if ($model->s_password != '' && $model->s_password != 'posNail@2015' && $model->s_password != $passwordOld) {
             $password = sha1($model->s_secret_code . sha1($model->s_password . $model->s_secret_code));
             $model->s_password = $password;
         } else {
             $model->s_password = $passwordOld;
         }
         $image = CUploadedFile::getInstance($model, 's_image_server');
         if ($image != null) {
             if ($image->saveAs(Yii::app()->basePath . '/../data/users/' . $model->s_image_server)) {
                 $imgthumb = Yii::app()->phpThumb->create(Yii::app()->basePath . '/../data/users/' . $model->s_image_server);
                 $imgthumb->resize(240, 240);
                 $imgthumb->save(Yii::app()->basePath . '/../data/users/240x240_' . $model->s_image_server);
                 $imgthumb->resize(120, 120);
                 $imgthumb->save(Yii::app()->basePath . '/../data/users/120x120_' . $model->s_image_server);
                 $flagChangeImage = true;
             } else {
                 $model->addError('s_image_server', 'Upload image fail');
             }
         }
         if (count($model->errors) == 0) {
             if ($model->save()) {
                 $flagSave = true;
             } elseif ($flagChangeImage == true) {
                 $flagSave = false;
                 @unlink(Yii::app()->basePath . '/../data/users/' . $model->s_image_server);
                 @unlink(Yii::app()->basePath . '/../data/users/240x240_' . $model->s_image_server);
                 @unlink(Yii::app()->basePath . '/../data/users/120x120_' . $model->s_image_server);
             }
             if ($flagSave == true) {
                 $this->redirect(array('index'));
             }
         }
     }
     $this->render('create', array('model' => $model, 'store' => $store, 'typeAccount' => $typeAccount));
 }
Exemple #22
0
 public function actionChange()
 {
     $id = $this->_get("id");
     if ($id) {
         $model = Course::model()->findByPk($id);
         if ($_POST['Course']) {
             $time_area = '';
             if ($_POST['Course']['time_area']) {
                 $time_area = serialize($_POST['Course']['time_area']);
             }
             $_POST['Course']['time_area'] = $time_area;
             $model->attributes = $_POST['Course'];
             if ($model->validate() && $model->save()) {
                 Yii::app()->user->setFlash('course', '更新成功');
                 $this->redirect(array('course/index'));
             }
         }
         if ($model->time_area) {
             $time_area = unserialize($model->time_area);
         }
         $stores = Store::model()->getName();
         $this->render('change', array('model' => $model, 'time_area' => $time_area, 'stores' => $stores));
     } else {
         $this->redirect(array('/site/index'));
     }
 }
 public function loadModel($id)
 {
     $model = Store::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('crud', 'The requested page does not exist.'));
     }
     return $model;
 }
 /**
  * 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 Store the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Store::model()->findByPk($id, "company_id=:company_id", array(':company_id' => Yii::app()->session['user']->company_id));
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemple #25
0
 public function getStore($id = 0)
 {
     if (!$id) {
         $id = $this->dy_user;
     }
     if ($id && $this->dy_type == 2) {
         $obj = Store::model()->findByPk($id);
         if ($obj) {
             return $obj->name;
         }
     }
 }
Exemple #26
0
		<?php 
echo $form->labelEx($model, 'relatedA');
?>
		
        <?php 
echo CHtml::activeListBox($model, 'relatedA', CHtml::listData(Product::model()->findAll(), 'id', function ($data) {
    return $data->getName();
}), array('multiple' => 'multiple'));
?>
        <?php 
echo $form->error($model, 'relatedA');
?>
    </div>
	
	<div class="row">
		<?php 
echo $form->labelEx($model, 'stores');
?>
		
        <?php 
echo CHtml::activeListBox($model, 'stores', CHtml::listData(Store::model()->findAll(), 'id', 'name'), array('multiple' => 'multiple'));
?>
        <?php 
echo $form->error($model, 'stores');
?>
    </div>

<?php 
$this->endWidget();
?>
</div>
Exemple #27
0
 public function actionUnsubscribes()
 {
     if (Yii::app()->user->organisation_id < 1) {
         // not from a specific organisation.
         throw new CHttpException('404', 'Page Not Found');
     }
     $Organisation = Organisation::model()->findByPk(Yii::app()->user->organisation_id);
     if (isset($_POST['download'])) {
         // offer the unsubscribes for their organisation
         $Store = new Store();
         $Unsubscribers = Store::model()->findAllBySql("\n\n\t\t\t\tSELECT DISTINCT s.email\n\n\t\t\t\tFROM suppression_list sl, store s\n\n\t\t\t\tWHERE sl.store_id IS NOT NULL\n\t\t\t\t\tAND s.id = sl.store_id\n\t\t\t\t\tAND s.origin_organisation_id = " . (int) $Organisation->id . "\n\t\t\t\t\tAND s.email IS NOT NULL\n\t\t\t\t\t-- INVITES DO HAVE CAMPAIGN_IDs IN THE SUPPRESSION TABLE >> AND sl.campaign_id IS NULL\n\t\t\t\t\tAND sl.type = 1\n\t\t\t\t\t-- AND sl.`date` > '2015-02-13 16:34:00'\n\n\t\t\t\tGROUP BY s.email\n\t\t\t\tORDER BY `date` DESC\n\n\t\t\t");
         // get our columns headings
         if (sizeof($Unsubscribers)) {
             $output = fopen("php://output", 'w');
             header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
             header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate");
             header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
             header('Content-Encoding: UTF-8');
             header('Content-type: text/csv; charset=UTF-8');
             // disposition / encoding on response body
             header("Content-Disposition:attachment;filename=unsubscribes.csv");
             header("Content-Transfer-Encoding: binary");
             // build a csv
             $csv = array();
             $columnNames = array();
             foreach ($Unsubscribers as $key => $Unsubscriber) {
                 fputcsv($output, [$Unsubscriber['email']]);
             }
             // disabled all logging so it's not appended to csv
             foreach (Yii::app()->log->routes as $route) {
                 if ($route instanceof CWebLogRoute) {
                     $route->enabled = false;
                 }
             }
             fclose($output);
             exit;
         }
         Yii::app()->end();
     }
     // get a count of recent unsubscribes
     $recentUnsubscribeResults = Yii::app()->db->createCommand("\n\n\t\t\tSELECT COUNT(DISTINCT s.email) as total\n\n\t\t\tFROM suppression_list sl, store s, organisation o\n\n\t\t\tWHERE sl.store_id IS NOT NULL\n\t\t\t\tAND s.id = sl.store_id\n\t\t\t\tAND o.id = s.origin_organisation_id\n\t\t\t\tAND s.origin_organisation_id = " . (int) $Organisation->id . "\n\n\t\t\t\tAND date > '" . date("Y-m-d H:i:s", time() - 7 * 24 * 60 * 60) . "'\n\t\t\t\tAND s.email IS NOT NULL\n\t\t\t\t-- INVITES DO HAVE CAMPAIGN_IDs IN THE SUPPRESSION TABLE >> AND sl.campaign_id IS NULL\n\t\t\t\tAND sl.type = 1\n\n\t\t\tGROUP BY s.origin_organisation_id\n\n\t\t")->queryAll();
     // get a count of all unsubscribes
     $totalUnsubscribeResults = Yii::app()->db->createCommand("\n\n\t\t\tSELECT COUNT(DISTINCT s.email) as total\n\n\t\t\tFROM suppression_list sl, store s, organisation o\n\n\t\t\tWHERE sl.store_id IS NOT NULL\n\t\t\t\tAND s.id = sl.store_id\n\t\t\t\tAND s.origin_organisation_id = " . (int) $Organisation->id . "\n\t\t\t\tAND o.id = s.origin_organisation_id\n\t\t\t\tAND s.email IS NOT NULL\n\t\t\t\t-- INVITES DO HAVE CAMPAIGN_IDs IN THE SUPPRESSION TABLE >> AND sl.campaign_id IS NULL\n\t\t\t\tAND sl.type = 1\n\t\t\t\t-- AND sl.`date` > '2015-02-13 16:34:00'\n\n\t\t\tGROUP BY s.origin_organisation_id\n\n\t\t")->queryAll();
     $this->pageTitle = 'unsubscribes | ' . Yii::app()->name;
     $this->breadcrumbs = array('unsubscribes');
     $this->render('unsubscribes', array('recent' => $recentUnsubscribeResults[0]['total'], 'total' => $totalUnsubscribeResults[0]['total']));
 }
Exemple #28
0
		<?php 
echo $form->labelEx($model, 'film_id');
?>
		<?php 
echo $form->dropDownList($model, 'film_id', GxHtml::listDataEx(Film::model()->findAllAttributes(null, true)));
?>
		<?php 
echo $form->error($model, 'film_id');
?>
		</div><!-- row -->
		<div class="row">
		<?php 
echo $form->labelEx($model, 'store_id');
?>
		<?php 
echo $form->dropDownList($model, 'store_id', GxHtml::listDataEx(Store::model()->findAllAttributes(null, true)));
?>
		<?php 
echo $form->error($model, 'store_id');
?>
		</div><!-- row -->
		<div class="row">
		<?php 
echo $form->labelEx($model, 'last_update');
?>
		<?php 
echo $form->textField($model, 'last_update');
?>
		<?php 
echo $form->error($model, 'last_update');
?>
Exemple #29
0
<?php

$this->breadcrumbs = array($model->label(2) => array('index'), 'Manage');
$this->menu = array(array('label' => 'List' . ' ' . $model->label(2), 'url' => array('index')), array('label' => 'Create' . ' ' . $model->label(), 'url' => array('create')));
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('inventory-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
?>

<h1><?php 
echo 'Manage' . ' ' . GxHtml::encode($model->label(2));
?>
</h1>

<p>
You may optionally enter a comparison operator (&lt;, &lt;=, &gt;, &gt;=, &lt;&gt; or =) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php 
echo GxHtml::link('Advanced Search', '#', array('class' => 'search-button'));
?>
<div class="search-form">
<?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'inventory-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('inventory_id', array('name' => 'film_id', 'value' => 'GxHtml::valueEx($data->film)', 'filter' => GxHtml::listDataEx(Film::model()->findAllAttributes(null, true))), array('name' => 'store_id', 'value' => 'GxHtml::valueEx($data->store)', 'filter' => GxHtml::listDataEx(Store::model()->findAllAttributes(null, true))), 'last_update', array('class' => 'CButtonColumn'))));
Exemple #30
0
echo $form->error($model, 'last_update');
?>
		</div><!-- row -->

		<label><?php 
echo GxHtml::encode($model->getRelationLabel('customers'));
?>
</label>
		<?php 
echo $form->checkBoxList($model, 'customers', GxHtml::encodeEx(GxHtml::listDataEx(Customer::model()->findAllAttributes(null, true)), false, true));
?>
		<label><?php 
echo GxHtml::encode($model->getRelationLabel('staffs'));
?>
</label>
		<?php 
echo $form->checkBoxList($model, 'staffs', GxHtml::encodeEx(GxHtml::listDataEx(Staff::model()->findAllAttributes(null, true)), false, true));
?>
		<label><?php 
echo GxHtml::encode($model->getRelationLabel('stores'));
?>
</label>
		<?php 
echo $form->checkBoxList($model, 'stores', GxHtml::encodeEx(GxHtml::listDataEx(Store::model()->findAllAttributes(null, true)), false, true));
?>

<?php 
echo GxHtml::submitButton('Save');
$this->endWidget();
?>
</div><!-- form -->