function viewAction() { $clearArray = array('campaign_id', 'aff_id'); $this->filter($clearArray); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true)); $models = AFActiveDataProvider::models('Prospect', $this->params, $pagination); $dataProvider = $models->getAll(); $filterFields = $models->getoutFilterFields($clearArray); // set ajax table if (AF::isAjaxRequestModels()) { $this->view->includeFile('_table', array('application', 'views', 'prospects'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields, 'ajax' => true)); die; } /* $prospects = $models->getAll(); $countries = $models->getCountries(); $campaignsFilter = $models->getCampaignsCountProspects(); $afids = $models->getAfids(); */ $affiliates = Affiliate::model()->cache()->findAllInArray(); $countries = Country::model()->cache()->findAllInArray(); $campaigns = Campaign::model()->cache()->findAllInArray(); Assets::js('ajax_table'); Assets::js('af_input_field'); $this->addToPageTitle('Prospects'); $this->render('view', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'filterFields' => $filterFields, 'affiliates' => $affiliates, 'countries' => $countries, 'campaigns' => $campaigns)); }
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)); }
public function actionIndex() { $affiliates = Affiliate::model()->findAll(); $this->render('index', array('affiliates' => $affiliates)); }
function updateAction() { $id = (int) AF::get($this->params, 'id', FALSE); if (!$id) { throw new AFHttpException(0, 'no_id'); } if (!($model = Pixel::model()->restrictions('campaign_id')->findByPk($id))) { throw new AFHttpException(0, 'incorrect_id'); } // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['ajax']) && $_POST['ajax'] == 'categorys-form') { if (isset($_POST['aff_id_ALL']) || isset($_POST['aff_id']) && !$_POST['aff_id']) { $_POST['aff_id'] = null; } $model->fillFromArray($_POST, FALSE); if (!$_POST['aff_id']) { $model->aff_id = null; } // Check aff_id by restrictions $t = $this->access->getUserRestrictions(array('aff_id')); if (isset($t['aff_id']['a']) && $t['aff_id']['a'] == 1) { if (!in_array($model->aff_id, $t['aff_id']['b'])) { Message::echoJsonError(__('pixel_not_updated')); } } $model->user_id_updated = $this->user->user_id; $model->updated = 'NOW():sql'; $model->model_uset_id = $this->user->user_id; if ($model->save()) { Message::echoJsonSuccess(__('pixel_updated')); } else { Message::echoJsonError(__('pixel_not_updated')); } } $affiliates = AF::userAccess()->array2RestrictionArray('aff_id', Affiliate::model()->cache()->findAllInArray()); $this->addToPageTitle('Update pixel'); Assets::js('jquery.form'); $this->render('update', array('model' => $model, 'affiliates' => $affiliates)); }
<th><?php echo Yii::t('dashboard', 'No. of Affiliates'); ?> :</th> <td><?php echo Affiliate::model()->count(); ?> </td> </tr> <tr> <th><?php echo Yii::t('dashboard', 'Affiliates Awaiting Approval'); ?> :</th> <td><?php echo Affiliate::model()->countByAttributes(array('approved' => Affiliate::PENDING)); ?> </td> </tr> </tbody> </table> </div> <div class="span7"> <h2>Statistics</h2> <ul class="nav nav-tabs" id="myTab"> <li class="active"><a data-toggle="tab" href="#today"><?php echo Yii::t('dashboard', 'Today'); ?> </a></li> </ul> <div class="tab-content" id="myTabContent">
public function getAfids() { /*$where = $this->unsetWhereKey('aff_id', 'stext', 'order_id', 'fname', 'lname', 'email', 'customer_id', 'product_id'); $join = $this->getJoinString(array('affiliates')); if($this->searchFields['method_id']) $join .= " JOIN `payments` as p USING(`payment_id`)"; 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`)"; $sql = "SELECT a.`aff_id`, a.`aff_ref`, COUNT(a.`aff_ref`) as count FROM `orders` o JOIN `affiliates` as a ON o.`aff_id`=a.`aff_id` LEFT JOIN `addresses` as ad USING (`address_id`) ?p WHERE ?p AND a.`aff_ref` IS NOT NULL GROUP BY a.`aff_ref`"; $result = self::$_msql->getall($sql, $join, $where); //if(!$result) return $result; if( !empty($this->searchFields['aff_id']) ) { $afids = explode(',', $this->searchFields['aff_id']); //$afids = array_unique($afids); if($result) { foreach($result as $value) { $key = array_search($value['aff_id'], $afids); if( $key !== false && isset($afids[$key]) ) unset($afids[$key]); } if($afids) { foreach($afids as $value) { if(!$value) continue; $result[] = array('aff_id' => $value, 'count' => '0'); } } } else { foreach($afids as $value) { if(!$value) continue; $result[] = array('aff_id' => $value, 'count' => '0',); } } } return $result;*/ return Affiliate::model()->cache()->findAllInArray(); }
function indexAction() { //change orders recurring dates or gateway if (isset($_POST['change_recurring_data']) && $_POST['change_recurring_data'] && $this->access->actionAccess('change_recurring_data')) { $models = AFActiveDataProvider::models('Order', $this->params); $models->updateRecurringData(); $this->redirect(); } $clearArray = array('status', 'campaign_id', 'product_id', 'aff_id'); if (!isset($this->params['dates'])) { $dataFrom = mktime(0, 0, 0, date("m"), date("d"), date("Y") - 2); $fromDate = date("d.m.Y", $dataFrom); $today = date("d.m.Y"); $this->params['dates'] = $fromDate . '-' . $today; } if (isset($_POST['ajax'])) { if (isset($_POST['get_models']) && $_POST['get_models']) { //echo 1; //die; $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true, 'ajax_div' => 'orders_table')); $modelOrders = AFActiveDataProvider::models('Order', $this->params); $filterFields = $modelOrders->getoutFilterFields($clearArray, array('dates')); $dataProvider = Orders::getModels($filterFields, $pagination); $view = new View(); $view->includeFile('_order_table', array('application', 'views', 'orders'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields)); die; } if (isset($_POST['download_csv']) && $_POST['download_csv']) { $modelOrders = AFActiveDataProvider::models('Order', $this->params); if (isset($_POST['csvfields']) && $_POST['csvfields']) { foreach ($_POST['csvfields'] as $k => $v) { $selectedFields[$v] = $modelOrders->all_fields[$v]; } } else { $selectedFields = $modelOrders->default_selected_fields; } $pagination = null; if ($_POST['order_id']) { $this->params['order_id'] = $_POST['order_id']; } $modelOrders = AFActiveDataProvider::models('Order', $this->params); $filterFields = $modelOrders->getoutFilterFields($clearArray, array('dates')); $dataProvider = Orders::getModels($filterFields, $pagination, $selectedFields); Csv::printArray($dataProvider); die; } die; } $modelOrders = AFActiveDataProvider::models('Order', $this->params); // csv /* if(isset($this->params['csvfields'])) { $selectedFields = explode(',',$this->params['csvfields']); foreach($selectedFields as $k=>$v) $selectedFields[$k]=$modelOrders->all_fields[$v]; } else */ $selectedFields = $modelOrders->default_selected_fields; $filterFields = $modelOrders->getoutFilterFields($clearArray, array('dates')); $statuses = Order::$statuses; $campaigns = Campaign::model()->cache()->findAllInArray(); $afids = Affiliate::model()->cache()->findAllInArray(); $products = Product::model()->cache()->findAllInArray(); $countries = Country::model()->cache()->findAllInArray(); $paymentMethods = Method::model()->cache()->findAllInArray(); $states = $filterFields['country'] !== null ? State::model()->getStatesByCID($filterFields['country']) : array(); $customerFields = Order::$address_search_fields; unset($customerFields[0]); $cssAllFields = $modelOrders->all_fields; Assets::css('jquery-ui'); Assets::js('jquery.form'); Assets::js('jquery-ui'); Assets::js('dateRange/jquery.daterange'); Assets::js('af_input_field'); Assets::js('orders_index'); $this->addToPageTitle('Orders'); $this->render('index', array('filterFields' => $filterFields, 'statuses' => $statuses, 'campaigns' => $campaigns, 'products' => $products, 'countries' => $countries, 'paymentMethods' => $paymentMethods, 'customerFields' => $customerFields, 'states' => $states, 'cssAllFields' => $cssAllFields, 'selectedFields' => $selectedFields, 'afids' => $afids)); }