本文整理汇总了PHP中Campaign::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Campaign::model方法的具体用法?PHP Campaign::model怎么用?PHP Campaign::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Campaign
的用法示例。
在下文中一共展示了Campaign::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: viewAction
function viewAction()
{
$id = AF::get($this->params, 'campaign_id', FALSE);
if (!($modelCampaign = Campaign::model()->restrictions()->findByPk($id))) {
throw new AFHttpException(0, 'incorrect_id');
}
$clearArray = array();
$this->filter($clearArray);
$pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true));
$models = AFActiveDataProvider::models('Pixel', $this->params, $pagination);
$dataProvider = $models->getAll();
$filterFields = $models->getoutFilterFields($clearArray);
// set ajax table
if (AF::isAjaxRequestModels()) {
$this->view->includeFile('_table', array('application', 'views', 'pixels'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields));
die;
}
$affiliates = Affiliate::model()->restrictions()->findAllInArray();
Assets::js('jquery.form');
Assets::css('jquery-ui');
Assets::js('jquery-ui');
Assets::js('ajax_table');
Assets::js('af_input_field');
$this->addToPageTitle(__('pixels'));
$this->render('view', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'campaign_id' => AF::get($this->params, 'campaign_id'), 'affiliates' => $affiliates, 'modelCampaign' => $modelCampaign));
}
示例2: newretentionAction
function newretentionAction()
{
$clearArray = array('campaign_id', 'aff_id');
$this->filter($clearArray);
if (!isset($this->params['dates_r'])) {
$dataFrom = mktime(0, 0, 0, date("m") - 1, date("d"), date("Y"));
$fromDate = date("d.m.Y", $dataFrom);
$today = date("d.m.Y");
$this->params['dates_r'] = $fromDate . '-' . $today;
}
if (!isset($this->params['initial_dates'])) {
$fromDate = date("d.m.Y", time() - 777600);
$today = date("d.m.Y");
$this->params['initial_dates'] = $fromDate . '-' . $today;
}
if (!isset($this->params['billing_cycle'])) {
$this->params['billing_cycle'] = 1;
}
$pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params));
$models = AFActiveDataProvider::models('Retention', $this->params, $pagination);
$report = $models->getForGraph();
$filterFields = $models->getoutFilterFields($clearArray, array('dates_r', 'initial_dates'));
$campaigns = Campaign::model()->cache()->findAllInArray();
$affiliates = Affiliate::model()->cache()->findAllInArray();
Assets::css('jquery-ui');
Assets::js('//code.jquery.com/ui/1.10.3/jquery-ui.js');
Assets::js('dateRange/jquery.daterange');
Assets::js('//www.google.com/jsapi');
//<script type="text/javascript" src="https://www.google.com/jsapi"></script>
$this->addToPageTitle(__('sales_by_retention_chart'));
$this->render('newretention', array('report' => $report, 'campaigns' => $campaigns, 'affiliates' => $affiliates, 'filterFields' => $filterFields));
}
示例3: getCampaignNumber
public function getCampaignNumber()
{
$name = Yii::app()->user->guestName;
if (strpos($name, 'uest') == 0) {
return false;
}
// только для гостя
if (isset($_REQUEST['campaignId'])) {
$campaignId = (int) $_REQUEST['campaignId'];
$campaign = Campaign::model()->findByPk($campaignId);
$orderId = 0;
if (isset($_REQUEST['orderId'])) {
$orderId = (int) $_REQUEST['orderId'];
}
if (!$orderId) {
return $campaign_id;
}
$order = Zakaz::model()->find('id=:id', array(':id' => $orderId));
if ($campaign) {
$domains = explode(',', $campaign->domains);
$domain = $domains[0];
$_SERVER['SERVER_NAME'] = $domain;
return true;
}
}
$campaigns = Campaign::model()->findAll();
foreach ($campaigns as $campaign) {
$domains = explode(',', $campaign->domains);
$domain = $domains[0];
$_SERVER['SERVER_NAME'] = $domain;
if ($this->getCampaignNumber()) {
return true;
}
}
}
示例4: search_by_domain
public static function search_by_domain($domain)
{
$orgz = Campaign::model()->findAll("domains like '%{$domain}%'");
if (count($orgz) == 1) {
return $orgz[0];
} else {
return false;
}
}
示例5: actionExport
public function actionExport($id)
{
$Campaign = Campaign::model()->findByPk($_GET['campaign_id']);
if (!$Campaign->hasBeenRun) {
throw new CHttpException('404', 'Not found');
}
// check campaign has been run
if (!$Campaign->hasBeenRun) {
throw new CHttpException('403', 'Forbidden');
// not possible. Forbidden.
}
$CampaignGroup = CampaignGroup::model()->findByAttributes(array('id' => $id, 'campaign_id' => $Campaign->id));
if (is_null($CampaignGroup)) {
throw new CHttpException('404', 'Not found');
}
$Criteria = new CDbCriteria();
$Criteria->compare('`t`.`campaign_id`', $Campaign->id);
$Criteria->compare('`t`.`group_id`', $id);
$Criteria->with = array('contact');
$Criteria->order = '`t`.`group_id` ASC';
$CampaignContacts = CampaignContact::model()->findAll($Criteria);
// build the csv
$rows = array();
$outcomeColumns = array();
foreach ($CampaignGroup->outcomes as $Outcome) {
// will be a url or NULL so fine
$outcomeColumns[$Outcome->name] = $Outcome->url;
}
$headings = array('contact_warehouse_id' => 'insider_id', 'salutation' => 'Prefix', 'first_name' => 'Forename', 'last_name' => 'Surname', 'email' => 'Email', 'phone' => 'Telephone', 'mobile' => 'Mobile', 'dob' => 'Date of Birth', 'address_line_1' => 'Address Line 1', 'address_line_2' => 'Address Line 2', 'address_line_3' => 'Address Line 3', 'address_line_4' => 'Address Line 4', 'address_town' => 'Town', 'address_postcode' => 'Postcode', 'address_county' => 'County', 'culture_segment' => 'Culture Segment', 'level_of_engagement' => 'Level of Engagement');
// build each row
foreach ($CampaignContacts as $CampaignContact) {
$row = array();
// use headings to get data
foreach ($headings as $key => $value) {
$row[$value] = $CampaignContact->contact->{$key};
}
$rows[] = array_merge($row, array_values($outcomeColumns));
}
// stick headers on the start after adding outcome names to it
array_unshift($rows, array_values(array_merge($headings, array_keys($outcomeColumns))));
$cleanGroupName = preg_replace(array("@[^a-z0-9\\-\\s]@i", "@\\s+@", "@\\-{2,}@"), array("", "-", "-"), $CampaignGroup->name) . '-' . date("Y-m-d");
$csv = 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=" . $cleanGroupName . ".csv");
header("Content-Transfer-Encoding: binary");
foreach ($rows as $column) {
fputcsv($csv, $column);
}
fclose($csv);
//echo $csv;
exit;
}
示例6: getAttachedGatewayByPrn
public static function getAttachedGatewayByPrn($parent_order_id, $attach_campaign_id, $ps = null)
{
if (!$parent_order_id || !$attach_campaign_id) {
return 0;
}
// get gateway of parent order
$order = Order::model()->fillFromDbPk($parent_order_id);
if (!$order) {
return 0;
}
// load attached campaign info
$campaign = Campaign::model()->fillFromDbPk($attach_campaign_id);
if (!$campaign) {
return 0;
}
$db = self::$_msql = SafeMySQL::getInstance();
for ($c = 0; $c < 3; $c++) {
// in case there are gateways but none are set to current alter the query
// IF THERE ARE NO CURRENT OR ACTIVE GATEWAYS THEN DEFAULT TO THE FIRST GATEWAY IN THE LIST SO AT LEAST THE ORDER CAN BE BILLED
if ($c == 0) {
$and = "AND pg.flags = 'cur'";
} else {
if ($c == 1) {
$and = "AND pg.flags != 'off'";
} else {
$and = '';
}
}
if (strlen($ps)) {
$and .= " AND g.system_code = ?s";
}
$sql = "SELECT \n\t\t\t\t\t pg.gateway_id\n\t\t\t\tFROM \n\t\t\t\t\tprofiles_gateways as pg\n\t\t\t\t\tLEFT JOIN gateways as g USING(gateway_id)\n\t\t\t\t\tleft JOIN gateway_limits as l on (pg.method_id = l.method_id) and (pg.gateway_id = l.gateway_id)\n\t\t\t\tWHERE \n\t\t\t\t\tg.routing_number = ?s\n\t\t\t\t\tand pg.profile_id = ?i\n\t\t\t\t\tAND pg.method_id = ?i\n\t\t\t\t\t" . $and . "\n\t\t\t\tORDER BY `gateway_rank` ASC\n\t\t\t\tLIMIT 1";
if (strlen($ps)) {
$result = $db->getOne($sql, $order->gateway->routing_number, $campaign->profile_id, $order->payment->method_id, $ps);
} else {
$result = $db->getOne($sql, $order->gateway->routing_number, $campaign->profile_id, $order->payment->method_id);
}
if (!empty($result)) {
return $result;
}
}
return false;
}
示例7: updateSites
public static function updateSites($campaignID)
{
$modelCampaign = Campaign::model()->with('domain')->cache()->findByPk($campaignID);
if (!$modelCampaign) {
return false;
}
$db = SafeMySQL::getInstance();
$sql = "SELECT c.`url`,\n c.`campaign_id`,\n c.`country_id`,\n c.`currency_id`\n FROM `campaigns` as c\n WHERE c.`domain_id` = ?i";
$campaigns = $db->getAll($sql, $modelCampaign->domain_id);
$rArray = array();
$cIDs = array();
foreach ($campaigns as $campaign) {
$cIDs[] = $campaign['campaign_id'];
$rArray[$campaign['campaign_id']] = array('main' => array('path' => $campaign['url'], 'campaign_id' => $campaign['campaign_id'], 'country_id' => $campaign['country_id'], 'currency_id' => $campaign['currency_id']), 'products' => array(), 'custom_fields' => array());
$sql = "SELECT `name`, `value`\n FROM `site_variables`\n WHERE (`domain_id`=?i AND`campaign_id`=?i)\n OR (`domain_id`=?i AND `campaign_id` IS NULL)\n OR (`domain_id` IS NULL AND `campaign_id` IS NULL)";
$customFields = $db->getAll($sql, $modelCampaign->domain_id, $campaign['campaign_id'], $modelCampaign->domain_id);
if ($customFields) {
foreach ($customFields as $field) {
$rArray[$campaign['campaign_id']]['custom_fields'][$field['name']] = $field['value'];
}
}
}
$sql = "SELECT p.`product_id`,\n p.`prodcat_id`,\n p.`product_name`,\n p.`product_price`,\n p.`product_weight`,\n p.`product_next_id`,\n p.`subscription_days`,\n cp.`campaign_id`\n FROM `products` as p\n JOIN `campaigns_products` as cp USING (`product_id`)\n WHERE cp.`campaign_id` IN (?a)\n AND cp.`enabled` = 1\n AND cp.`upsell_id` IS NULL";
$products = $db->getAll($sql, $cIDs);
if ($products) {
foreach ($products as $product) {
$campaignID = $product['campaign_id'];
unset($product['campaign_id']);
array_push($rArray[$campaignID]['products'], $product);
}
}
$siteApi = new SiteApi();
if (!$siteApi->createFile(json_encode($rArray))) {
//save an error to the log file
//..
return false;
}
$siteApi->domain = $modelCampaign->domain->url;
$siteApi->update();
}
示例8: run
public function run($args)
{
exit;
date_default_timezone_set("Europe/London");
print "Getting campaigns to process \n";
$CampaignCollection = Campaign::model()->with('query')->findAll(array("condition" => "processing = 0 AND status = :status AND invite = 1", "params" => array(":status" => Campaign::STATUS_QUEUED)));
print count($CampaignCollection) . ' campaigns to process' . "\n";
$campaignIDs = [];
foreach ($CampaignCollection as $Campaign) {
$campaignIDs[] = $Campaign->id;
print "Will process " . $Campaign->id . " \n";
}
$command = Yii::app()->db->createCommand();
$command->update('campaign', array("processing" => 1), array('in', 'id', $campaignIDs));
foreach ($CampaignCollection as $Campaign) {
$InviteEmail = new InviteEmail();
$InviteEmail->send($Campaign);
$Campaign->processing = 0;
$Campaign->save(true, array("processing"));
print "Completed processing " . $Campaign->id . " \n";
$Campaign->refresh();
print "Status of campaign was " . $Campaign->getStatusText() . "\n\n";
}
}
示例9: run
public function run($args)
{
exit('Use no.2 command');
ini_set('memory_limit', '4G');
$start = microtime(true);
print "\n\n";
print 'Running email de-duperer' . "\n\n";
sleep(1);
$QueuedCampaigns = Campaign::model()->findAll(array("condition" => "processing = 0 AND status = :status", "params" => array(":status" => Campaign::STATUS_QUEUED)));
$totalInvitesDeleted = 0;
$invitesDeleted = [];
print sizeof($QueuedCampaigns) . ' campaigns to process' . "\n\n";
foreach ($QueuedCampaigns as $QueuedCampaign) {
print 'Looking up Campaign ' . $QueuedCampaign->id . "...\n";
$Invites = Invite::model()->with('store')->findAll(array('condition' => 'query_id != :qid', 'params' => array(':qid' => $QueuedCampaign->query_id)));
$previouslyInvited = array();
print 'Building invite array...' . "\n";
foreach ($Invites as $k => $Invite) {
$previouslyInvited[] = $Invite->store->email;
if ($k % 1000 == 0) {
print '.';
}
}
unset($Invites);
sleep(1);
print " DONE!\n\n";
sleep(1);
print sizeof($previouslyInvited) . ' previously invited contacts' . "\n";
// Dupecheck this campaign
$results = Invite::model()->with("store")->findAll(array('condition' => 'campaign_id = :campaign_id', 'params' => array(':campaign_id' => $QueuedCampaign->id)));
print sizeof($results) . ' contacts in this invite campaign' . "\n";
$emails = [];
if (sizeof($results)) {
foreach ($results as $Invite) {
$emails[$Invite->id] = $Invite->store->email;
}
}
unset($results);
// LOCAL DUPES
/*
print 'Finding duplicates within this campaign' . "\n";
sleep(1);
$arrayCountValues = array_count_values($emails);
$localDuplicates = 0;
foreach($arrayCountValues as $arrayCount)
{
if($arrayCount > 1)
{
$localDuplicates++;
}
}
print 'Duplicates local to this campaign: ' . $localDuplicates . "\n\n";
*/
// Global dupes
print 'Finding duplicates in entire invite set' . "\n";
$arrayIntersect = array_intersect($emails, $previouslyInvited);
unset($previouslyInvited);
print 'Dupes found: ' . sizeof($arrayIntersect) . "\n";
foreach ($arrayIntersect as $inviteID => $dupeEmail) {
//print 'Deleting duplicate Invite ID: ' . $inviteID . ' for ' . $dupeEmail . "\n";
// $InviteToDelete = Invite::model()->findByPk($inviteID);
// $InviteToDelete->delete();
if (!in_array($inviteID, $invitesDeleted)) {
$totalInvitesDeleted++;
$invitesDeleted[] = $inviteID;
}
}
print "\n\n\n";
print 'COMPLETE' . "\n";
print "\n\n\n";
unset($emails);
unset($arrayIntersect);
}
print 'Total invites deleted: ' . $totalInvitesDeleted . "\n\n";
$RemainingInvites = Invite::model()->count(array('condition' => "date > '2015-01-01' AND status = 0"));
print 'Invites remaining to be sent: ' . $RemainingInvites . "\n\n";
print 'Peak memory usage: ' . memory_get_peak_usage(true) / 1024 / 1024 . "MB\n\n\n";
$end = microtime(true);
print 'Script ran in ' . round($end - $start, 4) . ' seconds' . "\n\n";
// Alternate with SQL
$Invites = Yii::app()->db->createCommand("\n\t\t\n\t\tSELECT i.id, s.email, count(s.email) AS c FROM invite i\n\n\t\tLEFT JOIN store s ON i.store_id = s.id\n\t\t\n\t\tWHERE i.date > '2015-01-01'\n\t\t\n\t\tGROUP BY s.email HAVING c > 1\n\t\t\n\t\t")->queryAll();
print 'Invites to remove using SQL query: ' . sizeof($Invites) . "\n\n";
}
示例10: cloneAction
function cloneAction()
{
if (isset($_POST['clone'])) {
$campaigns = Campaign::model()->cache()->findAllInArray();
AF::setJsonHeaders('json');
echo json_encode(array('campaigns' => $campaigns));
die;
}
if (isset($_POST['ajax'])) {
AF::setJsonHeaders('json');
$campaign_id = AF::get($_POST, 'campaign_id', 0);
$campprod_ids = AF::get($_POST, 'campship_id', 0);
if (!$campprod_ids && !$campaign_id) {
Message::echoJsonError(__('campship_id_not_found'));
}
$campprods = explode(',', $campprod_ids);
$message = array();
$newIDs = array();
$isMany = count($campprods) > 1 ? true : false;
$isThisCampaign = true;
foreach ($campprods as $id) {
$model = new CampaignShipping();
if (!$model->findByPk($id)) {
if ($isMany) {
continue;
}
Message::echoJsonError(__('campship_not_found'));
}
if ($model->campaign_id != $campaign_id) {
$model->campaign_id = $campaign_id;
$isThisCampaign = false;
}
if (!$model->cloneModel()) {
if ($isMany) {
continue;
}
Message::echoJsonError($model->errors2string);
}
$newID = $newIDs[] = $model->getPkValue();
$message[] = __('campship_cloned') . ' <a href="' . $this->controller . '/view/campaign_id=' . $campaign_id . '">' . __('view_campaign') . ' (ID: ' . $newID . ')</a><br>';
unset($model);
}
if (!$message) {
Message::echoJsonError(__('campship_not_cloned'));
}
$message = implode($message);
$newIDs = implode(',', $newIDs);
$v = array('message' => $message);
if ($isThisCampaign) {
$v['newid'] = $newIDs;
}
Message::echoJsonSuccess($v);
}
}
示例11: run
public function run($args)
{
$campaignSuccess = false;
$configs = Yii::app()->db->createCommand("SELECT * FROM `config` WHERE `key` IN ('host', 'https')")->queryAll();
if (sizeof($configs) < 2) {
throw new CException("\n\n\n===\nDomain or HTTPS config not yet set. View any admin area page in a browser to remedy this.\n===\n\n");
}
foreach ($configs as $config) {
$configParams[$config['key']] = $config['value'];
}
date_default_timezone_set("Europe/London");
print "Getting campaigns to process \n";
$CampaignCollection = Campaign::model()->findAll(array('with' => array('query', 'groups' => array('with' => array('email_template'))), "condition" => "processing = 0 AND status = :status AND invite = 0", "params" => array(":status" => Campaign::STATUS_QUEUED)));
print count($CampaignCollection) . ' campaigns to process' . "\n";
$campaignIDs = [];
foreach ($CampaignCollection as $Campaign) {
$campaignIDs[] = $Campaign->id;
print "Will process Campaign ID: " . $Campaign->id . " \n";
}
$command = Yii::app()->db->createCommand();
$command->update('campaign', array("processing" => 1), array('in', 'id', $campaignIDs));
foreach ($CampaignCollection as $Campaign) {
/* sending logic */
/* create mailgun campaign id */
$mailgunApi = new MailgunCampaign(Yii::app()->params['insiderEmailDomain'], Yii::app()->params['mailgun']['key']);
// Check if the campaign ID exists
try {
$checkCampaignResponse = $mailgunApi->getCampaign(Yii::app()->params['insiderEmailDomain'], $Campaign->id);
} catch (Exception $e) {
$checkCampaignResponse = false;
}
if (!$checkCampaignResponse) {
$mailgunCampaignResponse = $mailgunApi->createCampaign(Yii::app()->params['insiderEmailDomain'], array("name" => $Campaign->name, "id" => $Campaign->id));
} else {
$mailgunCampaignResponse['campaign'] = $checkCampaignResponse;
}
/* Example Response
Array
(
[message] => Campaign created
[campaign] => Array
(
[clicked_count] => 0
[opened_count] => 0
[submitted_count] => 0
[unsubscribed_count] => 0
[bounced_count] => 0
[id] => 691
[name] => Hicks 2
[created_at] => Tue, 24 Feb 2015 13:34:25 GMT
[delivered_count] => 0
[complained_count] => 0
[dropped_count] => 0
)
)
*/
$Store = new Store();
/* loop groups */
/* load & render template (campaign_group) */
foreach ($Campaign->groups as $CampaignGroup) {
$mailgunApi = new MailgunApi(Yii::app()->params['insiderEmailDomain'], Yii::app()->params['mailgun']['key']);
$mailgunApi->enableTracking();
$mailgunApi->enableOpensTracking();
$mailgunApi->enableClicksTracking();
$message = $mailgunApi->newMessage();
$message->setFrom(Yii::app()->params['fromEmail'], Yii::app()->name);
$message->setSubject($CampaignGroup->subject);
$message->setCampaignId($mailgunCampaignResponse['campaign']['id']);
$message->setHtml($CampaignGroup->email_template->parsedHtml($configParams));
// send variables to mailgun so that bounces and opens are easier to deal with.
$message->addVar('campaign_id', $Campaign->id);
$message->addVar('group_id', $CampaignGroup->id);
//get contacts
$CampaignContactCollection = CampaignContact::model()->findAll(array('with' => array('contact2outcomes' => array('index' => 'campaign_outcome_id')), "condition" => "\n\t\t\t\t\t\tgroup_id = :groupid\n\t\t\t\t\t\tAND `t`.`status` = 0\n\t\t\t\t\t", "params" => array(":groupid" => $CampaignGroup->id), 'index' => 'warehouse_id'));
echo sizeof($CampaignContactCollection);
// get the contact rows for the above campaigncontact rows
$Criteria = new CDbCriteria();
$Criteria->index = 'contact_warehouse_id';
$Contacts = CleanWarehouse::model()->findAllByPk(array_keys($CampaignContactCollection), $Criteria);
$chunkedCampaignContacts = array_chunk($CampaignContactCollection, 1000, true);
foreach ($chunkedCampaignContacts as $campaign1000) {
//echo 'C';
$transaction = $Campaign->dbConnection->beginTransaction();
$campaign1000IDs = array();
$sentCount = 0;
$message->resetTo();
foreach ($campaign1000 as $warehouse_id => $CampaignContact) {
//echo '.';
$campaign1000IDs[] = $CampaignContact->id;
$thisContact = $Contacts[$warehouse_id];
$standardTags = array('first_name' => $thisContact->first_name, 'last_name' => $Store->decryptLastName($thisContact->last_name), 'email' => $Store->decryptEmail($thisContact->email), 'insider_unsubscribe' => 'http' . ($configParams['https'] ? 's' : '') . '://' . $configParams['host'] . Yii::app()->urlManager->createUrl('data/campaignUnsubscribe', array('campaign_id' => $Campaign->id, 'campaign_hash' => $Campaign->hash, 'campaign_contact_id' => $CampaignContact->id, 'campaign_contact_hash' => $CampaignContact->hash)), 'warehouse_id' => $warehouse_id);
$campaignTags = $CampaignGroup->email_template->returnOutcomeTagsToUrls($configParams, $Campaign, $CampaignContact->contact2outcomes);
$parsedTagsArray = array_merge($standardTags, $campaignTags);
if (ENVIRONMENT === 'PRODUCTION') {
$message->addTo($Store->decryptEmail($thisContact->email), $thisContact->first_name . ' ' . $Store->decryptLastName($thisContact->last_name), $parsedTagsArray);
} else {
$message->addTo("email@example.com", $thisContact->first_name . ' ' . $Store->decryptLastName($thisContact->last_name), $parsedTagsArray);
}
$sentCount++;
//.........这里部分代码省略.........
示例12: actionMailIndividual
/**
* Sends an individual email to an item in a campaign/newsletter list.
*
* @param type $campaignId
* @param type $itemId
*/
public function actionMailIndividual($campaignId, $itemId)
{
$this->itemId = $itemId;
$this->campaign = Campaign::model()->findByPk($campaignId);
$email = $this->recipient->email;
if ($this->campaign instanceof Campaign && $this->listItem instanceof X2ListItem) {
$this->sendIndividualMail();
$this->response['fullStop'] = $this->fullStop;
$status = $this->status;
// Actual SMTP (or elsewise) delivery error that should stop the batch:
$error = $status['code'] != 200 && $this->undeliverable || $this->fullStop;
$this->response['status'] = $this->status;
$this->respond($status['message'], $error);
} else {
$this->respond(Yii::t('marketing', 'Specified campaign does not exist.'), 1);
}
}
示例13: getCampaigns
public function getCampaigns()
{
/*$where = $this->unsetWhereKey('campaign_id', 'stext', 'LL_order_id', 'order_id', 'fname', 'lname', 'customer_id', 'email', 'product_id');
$unionSelect = '';
if( !empty($this->searchFields['campaign_id']) )
{
$tempArray = explode(',', $this->searchFields['campaign_id']);
foreach($tempArray as $value)
{
$unionSelect .= " UNION SELECT {$value},0";
}
}
$join = $this->join;
if($this->searchFields['recurring_orders'])
$join .= " JOIN `orders_products` as op USING (`order_id`)";
if($this->searchFields['country_id'])
$join .= " JOIN `campaigns` as c USING (`campaign_id`)";
if($this->searchFields['method_id'])
$join .= " LEFT JOIN `payments` as p USING (`payment_id`)";
$sql = "SELECT c.`url`, c.`campaign_name`, o.* FROM `campaigns` c JOIN
(SELECT * FROM (
SELECT `campaign_id`, COUNT(*) AS `count`
FROM `orders` o
LEFT JOIN `addresses` as ad USING (`address_id`)
?p
WHERE ?p
GROUP BY `campaign_id`
{$unionSelect}) `o2` GROUP BY `campaign_id`
) o
USING (`campaign_id`)
ORDER BY `campaign_id` DESC";
// This used to be order by 'url' but I changed it to campaign_id DESC for /orders/view
//fb(self::$_msql->parse($sql, $this->join, $where));
$result=self::$_msql->getAll($sql, $join, $where);
return AF::userAccess()->array2RestrictionArray('campaign_id', $result);*/
return Campaign::model()->cache()->findAllInArray();
}
示例14: attachedOrder
public function attachedOrder($order, $campaign_id, $isPayment = false)
{
$this->wsType = 'a1';
$this->intervalCheck = false;
$this->isPayment = $isPayment;
$this->newCustomer = false;
$this->order = $order;
$this->campaign = Campaign::model()->fillFromDbPk($campaign_id);
if (!$this->campaign) {
return false;
}
// creating child / parent link in the DB
$parent_id = $this->order->order_id;
// clear the model and update
$this->order->getCopyModel();
$this->order->parent_id = $parent_id;
$this->order->status = 'new';
$this->order->created = $this->order->updated = 'NOW():sql';
//date("Y-m-d H:i:s");
$this->order->campaign_id = $this->campaign->campaign_id;
$this->order->click_id = NULL;
// check for parent test order
if ($this->order->isFlag('test')) {
$this->test = true;
}
$this->order->removeFlags();
if ($this->isPayment) {
$this->order->addFlags('pay');
} else {
$this->order->flags = '';
}
// set test
if ($this->test) {
$this->order->addFlags('test');
}
$this->order->ship_with = NULL;
// set default values. will be updated further down the script
$this->order->amount_product = '0';
$this->order->amount_shipping = '0';
$this->order->payment_total = '0';
$this->order->amount_refunded = '0';
$this->order->pixel_fired = '0';
$this->order->shipping_id = 19;
// Free Shipping
$this->order->billing_cycle = 0;
// check for test cc
//if (stripos($this->order->payment->method->method_ref,'cc_') !== false && $this->order->payment->cc_number == Config::get()->payments->pacnet['testCC']) {
if (isset($this->order->payment) && stripos($this->order->payment->method->method_ref, 'cc_') !== false && ($this->order->payment->num4 == strlen(Config::get()->payments->pacnet['testCC']) && $this->order->payment->num2 == substr(Config::get()->payments->pacnet['testCC'], 0, 6) && $this->order->payment->num3 == substr(Config::get()->payments->pacnet['testCC'], strlen(Config::get()->payments->pacnet['testCC']) - 4, 4))) {
$this->order->addFlags('test');
$this->test = true;
}
// Check to see if a gateway assigned to the attached campaign has the same PRN info as the gateway used in the main order. if so, use it
$gid = @ProfileGateways::getAttachedGatewayByPrn($parent_id, $campaign_id);
// if not, Grab Current gateway. will be checked again before payment is submitted.
if (!$gid) {
// ignore payment system type for this
// RENABLE THIS FOR ATTACH ORDERS? QUESTION.
$gid = @ProfileGateways::getCurrentGatewayByIds($this->campaign->profile_id, $this->order->payment->method_id);
if (!$gid) {
$gid = 0;
}
// set to 0. the batch job that bills the orders can deal with this
}
// if we have a new gateway, use it. if not keep the old one from the parent order
if ($gid) {
$this->order->gateway_id = $gid;
}
unset($gid);
// save order
if (!$this->order->save(true, null, false)) {
fb($this->order->getErrors());
//$this->apiError('attached order error - ' . $this->order->geterrors2string());
return false;
}
//Save order logs
$orderLogModel = new OrderLog();
$orderLogModel->order_id = $parent_id;
$orderLogModel->user_id = 0;
$orderLogModel->action = 26;
$orderLogModel->notes = $this->order->order_id;
$orderLogModel->save();
// load products for the attach campaign
$campProducts = new CampaignProducts('CampaignProduct');
$campProducts->load($this->campaign->campaign_id);
$pArray = array();
foreach ($campProducts->products as $p) {
$pArray[] = $p->product_id;
}
$this->post = array();
$this->post['product_id'] = implode(',', $pArray);
unset($campProducts);
$this->buildProducts();
$amount = $this->amount_product;
// set shipping info
// I'm assuming that since this is an attach campaign there's only one shipping option
$campShip = new CampaignShippings('CampaignShipping');
$campShip->load($this->campaign->campaign_id);
$this->order->shipping_id = $campShip->shipping[0]->shipping_id;
$this->order->amount_shipping = $campShip->selectedShipping($this->order->shipping_id)->amount_initial;
// catch for missing shipping id
//.........这里部分代码省略.........
示例15:
break;
case QueryQuestion::OPTION_ARTFORM:
if (is_null($Artforms)) {
$Artforms = Artform::model()->findAll(array('index' => 'id', 'order' => 'title ASC'));
}
print ' ' . $CultureSegments[$row->query_option]->title;
break;
case QueryQuestion::OPTION_LOE:
if (is_null($LevelsOfEngagement)) {
$LevelsOfEngagement = QueryQuestion::model()->levelsOfEngagement();
}
print ' ' . $LevelsOfEngagement[$row->query_option];
break;
case QueryQuestion::OPTION_CAMPAIGN:
if (is_null($Campaigns)) {
$Campaigns = Campaign::model()->with('query')->findAll(array('condition' => 'invite = 0', 'index' => 'id'));
}
print ' ' . $Campaigns[$row->query_option];
break;
default:
print ' ' . $row->query_number;
break;
}
?>
</td>
</tr>
<?php
}
?>
</table>
</div>