private function processAffiliateLink() { if (!isset($_GET['pc']) || $_GET['pc'] == '') { return; } $promocode = $_GET['pc']; $mediaBroker = Mediabroker::model()->findByPromocode($promocode); if ($mediaBroker == null) { return; } $url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $wlAccount = WhiteLabel::model()->findByPk($mediaBroker->wlabel_id); if ($wlAccount == null) { return; } // save cookie $correctDomain = '.' . $wlAccount->domain; //$correctDomain = '127.0.0.1'; $success = setcookie("p_ref", $mediaBroker->mbroker_id, time() + 60 * 60 * 24 * 30, "/", $correctDomain); // 30 days expiration $click = new MediabrokerClick(); $click->mbroker_id = $mediaBroker->mbroker_id; $click->date_created = date("Y-m-d h:i:s"); $click->url = $url; $click->referer = $referer; $click->save(); }
/** * Lists all models. */ public function actionIndex() { $model = new PurchasedPlan(); $form = new PurchasePlanForm(); if (isset($_POST['PurchasedPlan'])) { $form->attributes = $_POST['PurchasedPlan']; if ($form->validate()) { if ($_POST['PurchasedPlan']['realPayment'] == 0) { //$form->purchasePlan($this->getPlanType()); $this->redirect(array('index')); } else { $wl = WhiteLabel::model()->findByPk(Yii::app()->user->getWhiteLabelId()); if ($wl == null) { throw new Exception("Account doesn't exist"); } $plan = Plan::model()->findByAttributes(array('plan_id' => $form->plan_id, 'wlabel_id' => Yii::app()->user->getWhiteLabelId(), 'type' => $this->getPlanType())); if ($plan == null) { throw new Exception("Plan doesn't exist"); } if ($wl->payment_type == PaymentType::TYPE_PAYPAL) { $this->processPayPalPayment($wl, $plan); } else { if ($wl->payment_type == PaymentType::TYPE_AUTHORIZENET) { $this->processAuthnetPayment($wl, $plan); } } exit; } } } if (isset($_GET['PurchasedPlan'])) { $model->attributes = $_GET['PurchasedPlan']; } $this->render('index', array('model' => $model, 'planType' => $this->getPlanType())); }
/** * 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 the ID of the model to be loaded */ public function loadModel() { $model = WhiteLabel::model()->findByPk(Yii::app()->user->getWhiteLabelId()); if ($model === null) { throw new CHttpException(404, '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 the ID of the model to be loaded */ public function loadModel($id) { $model = WhiteLabel::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionIndex() { $this->layout = 'login'; $wlabelId = isset($_REQUEST['wid']) ? $_REQUEST['wid'] : ''; if ($wlabelId == '') { throw new CHttpException(404, 'Bad parameter wid'); } $planId = isset($_REQUEST['pid']) ? $_REQUEST['pid'] : ''; if ($planId == '') { throw new CHttpException(404, 'Bad parameter pid'); } $advertiserId = isset($_REQUEST['aid']) ? $_REQUEST['aid'] : ''; if ($advertiserId == '') { throw new CHttpException(404, 'Bad parameter aid'); } $returnUrl = isset($_REQUEST['return']) ? $_REQUEST['return'] : ''; if ($returnUrl == '') { throw new CHttpException(404, 'Bad parameter return'); } $wl = WhiteLabel::model()->findByPk(Yii::app()->user->getWhiteLabelId()); if ($wl == null) { throw new Exception("Account doesn't exist"); } $plan = Plan::model()->findByAttributes(array('plan_id' => $planId, 'wlabel_id' => $wlabelId)); if ($plan == null) { throw new CHttpException(404, 'Cannot find plan!'); } $advertiser = Advertiser::model()->findByAttributes(array('advertiser_id' => $planId, 'wlabel_id' => $advertiserId)); if ($plan == null) { throw new CHttpException(404, 'Cannot find advertiser!'); } $form = new AuthorizenetPaymentForm(); if (isset($_POST['AuthorizenetPaymentForm'])) { $form->attributes = $_POST['AuthorizenetPaymentForm']; $form->advertiser_id = $advertiserId; $form->wlabel_id = $wlabelId; $form->plan_id = $plan->plan_id; $form->refId = $plan->plan_id; $form->name = "Plan Subscription"; $form->unit = "days"; $form->totalOccurrences = 999; $form->trialOccurrences = 0; $form->trialAmount = 0; $form->startDate = date('Y-m-d'); $form->length = $plan->duration; $form->amount = $plan->price; if ($form->validate()) { if ($form->sendCreateSubscription($wl, $plan)) { $this->redirect($returnUrl); } } } if (isset($_GET['AuthorizenetPaymentForm'])) { $form->attributes = $_GET['AuthorizenetPaymentForm']; } $this->render('form_authnet_payment', array('model' => $form)); }
private function getStatusAccordingToWLModeration() { $wlAccount = WhiteLabel::model()->findByPk(Yii::app()->user->getWhiteLabelId()); if (!$wlAccount) { throw new CHttpException(1234, "Account cannot be found!"); } if ($wlAccount->moderate_members == 1) { return UserStatus::STATUS_PENDING; } else { return UserStatus::STATUS_APPROVED; } }
private function recognizeWLFromHost($host) { $accounts = WhiteLabel::model()->findRealAccountsAsRecords(); foreach ($accounts as $account) { if (strripos($host, $account->domain) !== false) { //echo "BY DOMAIN"; Yii::app()->cache->set("WL_" . $host, $account->wlabel_id); //Yii::app()->cache->set("WL_DOMAIN_".$host, $account->domain); $this->setState('location', null); return $account->wlabel_id; } } // WhiteLabel account not found by the domain!?! foreach ($accounts as $account) { //echo "FIRST"; $this->setState('location', null); return $account->wlabel_id; } return null; }
public function actionIndex() { if (Yii::app()->user->isMediabroker()) { $mediaBroker = Mediabroker::model()->findByPk(Yii::app()->user->getMediabrokerId()); $wlAccount = WhiteLabel::model()->findByPk(Yii::app()->user->getWhitelabelId()); $model = new MediabrokerClick(); $data = Mediabroker::model()->getStatsData(Yii::app()->user->getMediabrokerId()); $this->render('mediabroker_index', array('wlAccount' => $wlAccount, 'model' => $model, 'data' => $data, 'mbrokerId' => Yii::app()->user->getMediabrokerId(), 'mediaBroker' => $mediaBroker)); } else { $qsForm = new QuickStatsForm(); $quickStats = $this->getQuickStats($qsForm); $cForm = new SiteadminContactForm(); if (isset($_POST['SiteadminContactForm'])) { $cForm->attributes = $_POST['SiteadminContactForm']; $valid = $cForm->validate(); if ($valid) { $cForm->sendMessage(); } } $this->render('index', array('quickStats' => $quickStats, 'cForm' => $cForm, 'qsForm' => $qsForm)); } }
function afterSave() { if ($this->isNewRecord) { $purchasedPlan = PurchasedPlan::model()->findByPk($this->pplan_id); if ($purchasedPlan == null) { throw new CHttpException(1234, "No plan found!"); } if ($purchasedPlan->type == PlanType::ADVERTISER_PLAN && $purchasedPlan->advertiser_id != '') { $advertiser = Advertiser::model()->findByPk($purchasedPlan->advertiser_id); if ($advertiser == null) { throw new CHttpException(1234, "No advertiser found!"); } if ($advertiser->mbroker_id != '') { // insert commission for this media broker $wlAccount = WhiteLabel::model()->findByPk($purchasedPlan->wlabel_id); if ($wlAccount == null) { throw new CHttpException(1234, "No account found!"); } if ($wlAccount->mb_commission != '' && $wlAccount->mb_commission != 0 && $wlAccount->mb_commission_type != '' && $wlAccount->mb_commission_type != 0) { if ($wlAccount->mb_commission_type == CommissionType::TYPE_FIXED) { $commissionAmount = $wlAccount->mb_commission; } else { // percentage $commissionAmount = $purchasedPlan->price / 100 * $wlAccount->mb_commission; } $mbCommissions = new MediabrokerCommission(); $mbCommissions->mbroker_id = $advertiser->mbroker_id; $mbCommissions->pppayment_id = $this->pppayment_id; $mbCommissions->date_created = date("Y-m-d h:i:s"); $mbCommissions->amount = $commissionAmount; $mbCommissions->save(); } } } } return parent::afterSave(); }
<?php if (count($locations) > 0) { ?> <h2>Other Locations</h2> <ul class="content-menu"> <?php foreach ($locations as $id => $record) { ?> <li> <a href="http://<?php echo $record->domain . '.' . WhiteLabel::model()->getDomain(); ?> "><?php echo $record->name; ?> </a> </li> <?php } ?> </ul> <?php }
<?php $model = new Coupon(); $columns = array(); if (Yii::app()->user->isSuperadmin()) { $columns[] = array('name' => 'wlabel_id', 'header' => 'White Label', 'filter' => CHtml::listData(WhiteLabel::model()->findAll(), 'wlabel_id', 'name'), 'value' => '$data->p_whitelabel->name'); } $columns[] = array('name' => 'coupon_id', 'header' => 'ID'); $columns[] = array('name' => 'headline', 'header' => 'Headline'); $columns[] = array('name' => 'redeemed', 'header' => 'Redeemed'); $columns[] = array('name' => 'redemption_rate', 'header' => 'Redemption Rate'); ?> <div id="tabs-2" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide"> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'user-grid', 'dataProvider' => $model->search($qsForm->dateFrom, $qsForm->dateTo), 'filter' => null, 'columns' => $columns)); ?> <img src="http://chart.apis.google.com/chart?chs=460x240&cht=p3&chco=BBCCED|76A4FB|3399CC|3366CC|224499|008000&chd=s:fUPPb8&chdl=Akif+Quddus|Trey+Brister|Sally+Carson|Joe+Garcia|Phuong+Nguyen|All+Others&chl=50|32|25|24|45|98&chma=|5&chtt=Redemption+Rate+By+Employee&chts=FF0000,18" width="460" height="240" alt="Redemption Rate By Employee" /> <img src="http://chart.apis.google.com/chart?chxs=0,008000,11.5&chxt=x&chs=480x240&cht=p3&chco=BBCCED,76A4FB,3399CC,3072F3,3366CC,008000&chd=s:bNVil4&chdl=Akif+Quddus|Benny+Elder|Vincent+Trisapta|Jon+Hall|Mike+Summer|All+Others&chl=45|21|35|56|61|92&chma=0,0,5&chtt=Promotions+Redeemed+By+Employee&chts=FF0000,18" width="480" height="240" alt="Promotions Redeemed By Employee" /> <div class="clearfix"></div> <!-- Each Tab Ends --> </div>
<?php echo $form->error($model, 'parent_category_id'); ?> </div> <?php if (Yii::app()->user->isSuperadmin()) { ?> <div class="row"> <?php echo $form->labelEx($model, 'wlabel_id'); ?> <?php echo $form->dropDownList($model, 'wlabel_id', WhiteLabel::model()->findRealAccounts(), array('' => '')); ?> <?php echo $form->error($model, 'wlabel_id'); ?> </div> <?php } ?> <div class="row"> <?php if ($model->icon != '') { ?> <img src="<?php
/** * @return array validation rules for model attributes. */ public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array(array('wlabel_id, username, password, type, status, date_created', 'required'), array('wlabel_id', 'in', 'range' => array_keys(CHtml::listData(WhiteLabel::model()->findAll(), 'wlabel_id', 'name')), 'allowEmpty' => false), array('username, password, confirm_password, first_name, last_name, city', 'length', 'max' => 50), array('address', 'length', 'max' => 100), array('username', 'checkUsernameIsUniqueAndCorrect'), array('state, zipcode, country, phone, alt_phone, fax, email', 'length', 'max' => 40), array('date_lastlogin', 'safe'), array('user_id, wlabel_id, username, password, type, status, date_created, date_lastlogin, first_name, last_name, address, city, state, zipcode, country, phone, alt_phone, fax, email', 'safe', 'on' => 'search')); }
/** * @return array validation rules for model attributes. */ public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array(array('name, header_html, footer_html, status, domain', 'required'), array('parent_location_id, wlabel_id, status', 'numerical', 'integerOnly' => true), array('parent_location_id', 'belongsToSameWhitelabelAccount'), array('domain', 'checkDomainIsUniqueAndCorrect'), array('wlabel_id', 'in', 'range' => array_keys(CHtml::listData(WhiteLabel::model()->findAll(), 'wlabel_id', 'name')), 'allowEmpty' => false), array('name', 'length', 'max' => 255), array('logo', 'length', 'max' => 200), array('logo', 'file', 'types' => 'jpg, gif, png', 'allowEmpty' => true), array('location_id, parent_location_id, wlabel_id, domain, name, logo, header_html, footer_html, status', 'safe', 'on' => 'search')); }
/** * @return array validation rules for model attributes. */ public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array(array('type, name, duration, price', 'required'), array('wlabel_id, type, duration', 'numerical', 'integerOnly' => true), array('price', 'numerical'), array('wlabel_id', 'in', 'range' => array_keys(CHtml::listData(WhiteLabel::model()->findAll(), 'wlabel_id', 'name')), 'allowEmpty' => false), array('name', 'length', 'max' => 100), array('price', 'length', 'max' => 10), array('plan_id, wlabel_id, type, name, duration, price', 'safe', 'on' => 'search')); }
public function getDomain() { $wl = WhiteLabel::model()->findByPk(Yii::app()->user->getWhiteLabelId()); if ($wl != null) { return $wl->domain; } return ''; }
<?php $wlabels = WhiteLabel::model()->findRealAccounts(); if (count($wlabels) > 0) { ?> <div class="form"> <?php $form = $this->beginWidget('CActiveForm', array('id' => 'purchased-plan-form', 'enableAjaxValidation' => false)); ?> <?php echo $form->errorSummary($model); ?> <div class="row"> <?php echo $form->labelEx($model, 'wlabel_id'); ?> <?php echo $form->dropDownList($model, 'wlabel_id', $wlabels, array('' => '')); ?> <?php echo $form->error($model, 'wlabel_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'plan_id');
public static function checkSubscriptionStatus($subscriptionId) { if (Yii::app()->params['paymentsTestMode']) { $host = "apitest.authorize.net"; } else { $host = "api.authorize.net"; } $path = "/xml/v1/request.api"; $wlAccount = WhiteLabel::model()->findByPk(Yii::app()->user->getWhiteLabelId()); if ($wlAccount == null) { throw new Exception("Account doesn't exist"); } $content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" . "<ARBGetSubscriptionStatusRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" . "<merchantAuthentication>" . "<name>" . $wlAccount->auth_api_id . "</name>" . "<transactionKey>" . $wlAccount->auth_trans_key . "</transactionKey>" . "</merchantAuthentication>" . "<subscriptionId>" . $subscriptionId . "</subscriptionId>" . "</ARBGetSubscriptionStatusRequest>"; $response = Utils::send_request_via_fsockopen($host, $path, $content); if ($response) { Utils::logToPaymentFile('authnet', $response); $responseValues = Utils::parse_return($response); return $responseValues['status']; } return 'error'; }
<div class="form2" style="display: block; color: white; margin-right: 20px; margin-left: 20px;"> <?php $form = $this->beginWidget('CActiveForm', array('id' => 'location-form', 'enableAjaxValidation' => false, 'action' => Yii::app()->createUrl("siteadmin/defaultwlid"))); ?> <div> Default Whitelabel Account: <?php echo CHtml::dropDownList('wlabel_id', $default_wlabel_id, WhiteLabel::model()->findRealAccounts()); ?> <?php echo CHtml::submitButton('Ok'); ?> </div> <?php $this->endWidget(); ?> </div><!-- form -->
</div> </div> <?php } else { ?> <?php echo $this->renderPartial('/restriction/restriction', array('model' => $model, 'resourceType' => $checkFor, 'resTypeName' => 'locations')); ?> <?php } ?> <div class="title title-spacing"> <h3>Existing Locations</h3> </div> <?php if (Yii::app()->user->isSuperadmin()) { $columns = array(array('name' => 'wlabel_id', 'filter' => CHtml::listData(WhiteLabel::model()->findAll(), 'wlabel_id', 'name'), 'value' => '$data->p_whitelabel->name'), 'name', array('class' => 'CButtonColumn', 'template' => '{update}{delete}', 'afterDelete' => 'function(link,success,data){ if(success) alert("Delete completed successfuly"); }')); } else { $columns = array('name', array('class' => 'CButtonColumn', 'template' => '{update}{delete}', 'afterDelete' => 'function(link,success,data){ if(success) alert("Delete completed successfuly"); }')); } $this->widget('zii.widgets.grid.CGridView', array('id' => 'location-grid', 'dataProvider' => $model->with('p_whitelabel')->search(), 'filter' => null, 'columns' => $columns)); ?>
<?php $form = $this->beginWidget('CActiveForm', array('id' => 'user-form', 'enableAjaxValidation' => false)); ?> <?php echo $form->errorSummary($model); ?> <div class="row"> <?php echo $form->labelEx($model, 'wlabel_id'); ?> <?php echo $form->dropDownList($model, 'wlabel_id', CHtml::listData(WhiteLabel::model()->findAll(), 'wlabel_id', 'name'), array('' => '')); ?> <?php echo $form->error($model, 'wlabel_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'username'); ?> <?php echo $form->textField($model, 'username', array('size' => 50, 'maxlength' => 50)); ?> <?php
public static function getCookieDomain() { $wlId = Yii::app()->user->getWhitelabelId(); $domain = Yii::app()->cache->get("WL_DOMAIN_" . $wlId); if ($domain != false) { return $domain; } $wlAccount = WhiteLabel::model()->findByPk($wlId); if ($wlAccount == null) { return null; } // save cookie $correctDomain = '.' . $wlAccount->domain; Yii::app()->cache->set("WL_DOMAIN_" . $wlId, $correctDomain); }
public function getDefaultWhiteLabelId() { $defId = $this->getState('wlabel_id', ''); if ($defId == '') { // get first available whitelabel account id $accounts = WhiteLabel::model()->findRealAccounts(); $defaultAccountId = null; foreach ($accounts as $id => $name) { $defaultAccountId = $id; break; } if ($defaultAccountId == null) { return ''; } // save it to session $this->setDefaultWhiteLabelId($defaultAccountId); $defId = $defaultAccountId; } return $defId; }
/** * @return array validation rules for model attributes. */ public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array(array('advertiser_id, url, name, street_address, city, state, zip, phone, date_created', 'required'), array('wlabel_id, advertiser_id, type', 'numerical', 'integerOnly' => true), array('wlabel_id', 'in', 'range' => array_keys(CHtml::listData(WhiteLabel::model()->findAll(), 'wlabel_id', 'name')), 'allowEmpty' => false), array('advertiser_id', 'in', 'range' => array_keys(CHtml::listData(Advertiser::model()->findAll(), 'advertiser_id', 'user_id')), 'allowEmpty' => false), array('url, name, street_address', 'length', 'max' => 100), array('city, state, zip, phone, logo, mon_open, mon_close, tue_open, tue_close, wed_open, wed_close, thu_open, thu_close, fri_open, fri_close, sat_open, sat_close, sun_open, sun_close', 'length', 'max' => 40), array('description', 'safe'), array('url', 'url'), array('logo', 'file', 'types' => 'jpg, gif, png', 'allowEmpty' => true), array('p_categories', 'verifyNumberOfCategories'), array('p_locations', 'verifyNumberOfLocations'), array('p_coupons', 'verifyNumberOfCoupons'), array('type', 'verifyNumberOfFeaturedListings'), array('listing_id, wlabel_id, advertiser_id, url, name, street_address, city, state, zip, phone, description, logo, type, date_created, mon_open, mon_close, tue_open, tue_close, wed_open, wed_close, thu_open, thu_close, fri_open, fri_close, sat_open, sat_close, sun_open, sun_close', 'safe', 'on' => 'search')); }
<div class="portlet"> <div class="portlet-header">Create Admin</div> <div class="portlet-content"> <?php echo $this->renderPartial('_form', array('model' => $model)); ?> </div> </div> <div class="title title-spacing"> <h3>Manage SuperAdmins and White Label Admins</h3> </div> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'user-grid', 'dataProvider' => $model->with('p_whitelabel')->searchAdmins(), 'filter' => null, 'columns' => array('user_id', array('name' => 'wlabel_id', 'filter' => CHtml::listData(WhiteLabel::model()->findAll(), 'wlabel_id', 'name'), 'value' => '$data->p_whitelabel->name'), 'username', array('name' => 'type', 'filter' => CHtml::listData(UserType::findAll(), 'id', 'name'), 'value' => '$data->getType($data->type)'), array('name' => 'status', 'filter' => CHtml::listData(UserStatus::findAll(), 'id', 'name'), 'value' => '$data->getStatus($data->status)'), array('class' => 'CButtonColumn', 'template' => '{update}{delete}', 'afterDelete' => 'function(link,success,data){ if(success) alert("Delete completed successfuly"); }')))); ?>
/** * @return array validation rules for model attributes. */ public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array(array('wlabel_id, name', 'required'), array('wlabel_id', 'in', 'range' => array_keys(CHtml::listData(WhiteLabel::model()->findAll(), 'wlabel_id', 'name')), 'allowEmpty' => false), array('parent_category_id, wlabel_id, sort_order', 'numerical', 'integerOnly' => true), array('parent_category_id', 'belongsToSameWhitelabelAccount'), array('name, domain', 'length', 'max' => 100), array('icon', 'file', 'types' => 'jpg, gif, png', 'allowEmpty' => true), array('category_id, parent_category_id, wlabel_id, name, domain, sort_order', 'safe', 'on' => 'search')); }