function viewAction() { $clearArray = array(); $this->filter($clearArray); $stateCode = AF::get($this->params, 'state_code', null); $countryID = AF::get($this->params, 'country_id', null); $defaultCheck = $countryID ? null : AF::get($this->params, 'searchdefaultCountryCheck', null); $stateModel = new State(); if ($stateCode && !$countryID) { $stateModel->fillFromStateCode($stateCode); $countryID = $stateModel->country_id; $this->params['country_id'] = $countryID; } $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true)); // pass in blank model with possible location info to be used in pre-selecting fields during tax creation on the modal form $model = new Tax(); $model->state_code = $stateCode; $model->country_id = $countryID; $models = AFActiveDataProvider::models('Tax', $this->params, $pagination); $dataProvider = $defaultCheck ? $models->getDefaultCountries() : $models->getAll(); $filterFields = $models->getoutFilterFields($clearArray); // set ajax table if (AF::isAjaxRequestModels()) { $this->view->includeFile('_table', array('application', 'views', 'taxes'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields)); die; } $countries = Country::model()->cache()->findAllInArray(); $states = State::model()->cache()->findAllInArray(); $countryDefault = Taxs::getCountryDefault($countryID); Assets::js('jquery.form'); Assets::js('ajax_table'); Assets::js('af_input_field'); $this->addToPageTitle('Taxes'); $this->render('view', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'countries' => $countries, 'states' => $states, 'countryDefault' => $countryDefault, 'countryID' => $countryID, 'model' => $model, 'filterFields' => $filterFields)); }
function viewAction() { $clearArray = array(); $this->filter($clearArray); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true)); $models = AFActiveDataProvider::models('CCombo', $this->params, $pagination); $dataProvider = $models->getAll(); $filterFields = $models->getoutFilterFields($clearArray); // set ajax table if (AF::isAjaxRequestModels()) { $this->view->includeFile('_table', array('application', 'views', 'ccombo'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields)); die; } $connectCampaignIDs = array(); foreach ($dataProvider as $item) { if (!in_array($item->campaign1_id, $connectCampaignIDs)) { $connectCampaignIDs[] = $item->campaign1_id; } if (!in_array($item->campaign2_id, $connectCampaignIDs)) { $connectCampaignIDs[] = $item->campaign2_id; } } CCombos::getDoubleShippingSKUArray($connectCampaignIDs, AF::get($this->params, 'campaign_id')); $this->addToPageTitle('Campaigns Shipping'); Assets::js('jquery.form'); $this->render('view', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'filterFields' => $filterFields, 'campaign_id' => AF::get($this->params, 'campaign_id'))); }
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)); }
function welcomeAction() { $filterFields = array(); $dataProvider = array(); if ($this->access->actionAccess('dashboard')) { if (!isset($this->params['dates'])) { //$dataFrom=mktime(0, 0, 0, date("m"), date("d")-1, date("Y")); $fromDate = date("d.m.Y"); $this->params['dates'] = $fromDate . '-' . $fromDate; } $models = AFActiveDataProvider::models('Order', $this->params); $dataProvider = $models->dashboard(); $filterFields = $models->getoutFilterFields(array(), array('dates')); // set ajax table if (AF::isAjaxRequestModels()) { $this->view->includeFile('_dashboard', array('application', 'views', 'home'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'filterFields' => $filterFields)); die; } Assets::css('jquery-ui'); Assets::js('jquery-ui'); Assets::js('dateRange/jquery.daterange'); Assets::js('ajax_table'); Assets::js('//www.google.com/jsapi'); } $this->addToPageTitle(__('welcome')); $this->render('welcome', array('dataProvider' => $dataProvider, 'filterFields' => $filterFields)); }
public function ordersAction() { $from = AF::get($this->params, 'from', false); $clearArray = array(); $this->filter($clearArray); if (!isset($this->params['r_dates'])) { $today = date("d.m.Y"); $this->params['r_dates'] = $today . '-' . $today; } $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true)); $models = AFActiveDataProvider::models('Attempt', $this->params, $pagination); $dataProvider = $models->getDeclineOrdersReport(); $filterFields = Attempt::$FilterFields = $models->getoutFilterFields($clearArray, array('r_dates')); $fields = array('order_formatted', 'type_formatted', 'status_note', 'created_formatted'); $gateways = $models->getDSearchGateways(); $reasons = $models->getDSearchReasons(); // set ajax table if (AF::isAjaxRequestModels()) { $this->view->includeFile('_orders_table', array('application', 'views', 'declinedreports'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields, 'fields' => $fields, 'gateways' => $gateways, 'reasons' => $reasons)); die; } Assets::css('jquery-ui'); Assets::js('//code.jquery.com/ui/1.10.3/jquery-ui.js'); Assets::js('dateRange/jquery.daterange'); Assets::js('ajax_table'); $this->render('orders', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields, 'fields' => $fields, 'gateways' => $gateways, 'reasons' => $reasons, 'from' => $from)); }
function viewAction() { $clearArray = array('action', 'section'); $this->filter($clearArray); 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'] = $today . '-' . $today; } $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true)); $models = AFActiveDataProvider::models('Log', $this->params, $pagination); $dataProvider = $models->getAll(); $filterFields = $models->getoutFilterFields($clearArray, array('dates')); // set ajax table if (AF::isAjaxRequestModels()) { $this->view->includeFile('_table', array('application', 'views', 'logs'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields)); die; } $this->addToPageTitle('Logs'); Assets::css('jquery-ui'); Assets::js('jquery-ui'); Assets::js('dateRange/jquery.daterange'); Assets::js('ajax_table'); Assets::js('af_input_field'); $this->render('view', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'filterFields' => $filterFields)); }
function viewAction() { $clearArray = array('flags'); $this->filter($clearArray); if (empty($this->params)) { $today = date("d.m.Y"); $this->params['dates'] = $today . '-' . $today; } $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true)); $models = AFActiveDataProvider::models('ProspectEmail', $this->params, $pagination); $dataProvider = $models->getAll(); $filterFields = $models->getoutFilterFields($clearArray, array('dates')); // set ajax table if (AF::isAjaxRequestModels()) { $this->view->includeFile('_table', array('application', 'views', 'emails'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields)); die; } $campaigns = Campaign::model()->cache()->findAllInArray(); $templates = Template::model()->cache()->findAllInArray(); $flags = ProspectEmail::getEmailFlags(); /* $campaignsFilter = $models->getFilterCampaigns(); $templatesFilter = $models->getFilterTemplates(); $flagsFilter = $models->getFilterFlags(); */ Assets::css('jquery-ui'); Assets::js('jquery-ui'); Assets::js('dateRange/jquery.daterange'); Assets::js('ajax_table'); Assets::js('af_input_field'); $this->addToPageTitle(__('prospect_emails')); $this->render('view', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'filterFields' => $filterFields, 'campaigns' => $campaigns, 'templates' => $templates, 'flags' => $flags)); }
function viewAction() { $this->filter(); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params)); $models = AFActiveDataProvider::models('Shipcat', $this->params, $pagination); $dataProvider = $models->getAll(); $this->addToPageTitle('Shipcats'); $this->render('view', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models)); }
function viewAction() { $customer_id = AF::get($this->params, 'customer_id'); $this->filter(); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params)); $models = AFActiveDataProvider::models('Address', $this->params, $pagination); $addresses = $models->getAddressesByCustomerId($customer_id); $countries = Country::model()->cache()->findAllInArray(); Assets::js('jquery.form'); $this->addToPageTitle('Addresses'); $this->render('view', array('addresses' => $addresses, 'pagination' => $pagination, 'customer_id' => $customer_id, 'countries' => $countries)); }
function campaignAction() { $this->filter(); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params)); $models = AFActiveDataProvider::models('Pixelrate', $this->params, $pagination); $pixelrates = $models->getAllGroupByCampaign(); $id = AF::get($this->params, 'campaign_id'); $methods = Method::model()->cache()->findAllInArray(); Assets::js('jquery.form'); $this->addToPageTitle('Pixel rates'); $this->render('campaign', array('pixelrates' => $pixelrates, 'pagination' => $pagination, 'methods' => $methods, 'campaign_id' => $id)); }
function viewAction() { $this->filter(); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params)); $models = AFActiveDataProvider::models('CampaignGateway', $this->params, $pagination); $dataProvider = $models->getAll(); $gatewaysModel = new Gateway(); $gateways = $gatewaysModel->getGateways(); $this->addToPageTitle('Campaigns Gateways'); Assets::js('jquery.form'); $models->pk = "gateway_id"; $this->render('view', array('dataProvider' => $dataProvider, 'gateways' => $gateways, 'pagination' => $pagination, 'models' => $models, 'campaign_id' => AF::get($this->params, 'campaign_id'))); }
function openAction() { $fieldCode = AF::get($this->params, 'field_code', false); if (!$fieldCode) { throw new AFHttpException(0, 'no_field_code'); } $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params)); $_POST['field_code'] = $fieldCode; $this->filter(); $models = AFActiveDataProvider::models('Field', $this->params, $pagination); $dataProvider = $models->getAll(); $this->addToPageTitle('View Field'); $this->render('open', array('models' => $models, 'dataProvider' => $dataProvider, 'fieldCode' => $fieldCode)); }
function viewAction() { $clearArray = array(); $this->filter($clearArray); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true)); $models = AFActiveDataProvider::models('CampaignShipping', $this->params, $pagination); $dataProvider = $models->getAll(); $filterFields = $models->getoutFilterFields($clearArray); // set ajax table if (AF::isAjaxRequestModels()) { $this->view->includeFile('_table', array('application', 'views', 'campship'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields)); die; } $this->addToPageTitle('Campaigns Shipping'); Assets::js('jquery.form'); $this->render('view', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'filterFields' => $filterFields, 'campaign_id' => AF::get($this->params, 'campaign_id'))); }
/** * Show the customers orders with address for each order in case they use different addresses. */ function openAction() { $customer_id = AF::get($this->params, 'customer_id', false); // Get the $_GET['customer_id'] if (!$customer_id) { throw new AFHttpException(0, 'no_customer_id'); } // uses en.php to get string $this->filter(); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params)); $models = AFActiveDataProvider::models('Customer', $this->params, $pagination); $dataProvider = $models->getOrdersByCustomerId($customer_id); $orderModel = new Order(); $labels = $orderModel->attributeLabels(); $this->addToPageTitle('View Client'); $this->render('open', array('lables' => $labels, 'pagination' => $pagination, 'dataProvider' => $dataProvider, 'countOrders' => count($dataProvider), 'email' => $dataProvider[0]->email)); }
function viewAction() { $clearArray = array(); $this->filter($clearArray); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true)); $models = AFActiveDataProvider::models('Prodcat', $this->params, $pagination, '`prodcat_id` DESC'); //$dataProvider = $models->getAll(); $dataProvider = $models->cache()->getMethod('getAll'); $filterFields = $models->getoutFilterFields($clearArray); // set ajax table if (AF::isAjaxRequestModels()) { $this->view->includeFile('_table', array('application', 'views', 'prodcats'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields)); die; } Assets::js('ajax_table'); Assets::js('af_input_field'); $this->addToPageTitle(__('prodcats')); $this->render('view', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'filterFields' => $filterFields)); }
function viewAction() { $clearArray = array(); $this->filter($clearArray); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true)); $models = AFActiveDataProvider::models('Event', $this->params, $pagination); $dataProvider = $models->getAll(); $filterFields = $models->getoutFilterFields($clearArray); // set ajax table if (AF::isAjaxRequestModels()) { $this->view->includeFile('_table', array('application', 'views', 'events'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields)); die; } $templates = Template::model()->cache()->findAllInArray(); $smtps = Smtp::model()->cache()->findAllInArray(); $this->addToPageTitle('Events'); Assets::js('ajax_table'); Assets::js('af_input_field'); $this->render('view', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'templates' => $templates, 'smtps' => $smtps, 'filterFields' => $filterFields)); }
function viewAction() { $clearArray = array(); $this->filter($clearArray); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true)); $models = AFActiveDataProvider::models('Campaign', $this->params, $pagination); //$dataProvider = $models->getAll(); $dataProvider = $models->cache()->getMethod('getAll'); $filterFields = $models->getoutFilterFields($clearArray, array('dates')); // set ajax table if (AF::isAjaxRequestModels()) { $this->view->includeFile('_table', array('application', 'views', 'campaigns'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields)); die; } $campaignsFilter = Campaign::model()->cache()->restrictions()->findAllInArray(); // useful UI components for popup dialogs and things of that nature. added to use a dialog popup on the single campaign clone action Assets::js('jquery-ui'); Assets::js('ajax_table'); Assets::css('jquery-ui'); $this->addToPageTitle('Campaigns'); $this->render('view', array('dataProvider' => $dataProvider, 'campaignsFilter' => $campaignsFilter, 'pagination' => $pagination, 'models' => $models, 'filterFields' => $filterFields)); }
function updateAction() { $model = new Product(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['ajax'])) { if (isset($_POST['subscription_days']) && ((int) $_POST['subscription_days'] > 180 || (int) $_POST['subscription_days'] < 1)) { $_POST['subscription_days'] = null; } $model->fillFromArray($_POST, FALSE); $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(__('product_updated')); } else { Message::echoJsonError(__('product_no_updated')); } die; } $id = AF::get($this->params, 'id', FALSE); if (!$id) { throw new AFHttpException(0, 'no_id'); } if (!$model->cache()->findByPk($id)) { throw new AFHttpException(0, 'incorrect_id'); } $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params)); $models = AFActiveDataProvider::models('Event', $this->params, $pagination); $dataProvider = $models->getByProductID($id); $products = Product::model()->cache()->findAllInArray(); $prodcats = Prodcat::model()->cache()->findAllInArray(); //Events type list $eventModel = new Event(); $eventsTypes = $eventModel->getEventsType(); Assets::js('jquery.form'); $this->addToPageTitle('Update product'); $this->render('update', array('model' => $model, 'products' => $products, 'pagination' => $pagination, 'dataProvider' => $dataProvider, 'eventsTypes' => $eventsTypes, 'prodcats' => $prodcats)); }
function viewAction() { $clearArray = array(); $this->filter($clearArray); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true)); $models = AFActiveDataProvider::models('User', $this->params, $pagination); $dataProvider = $models->getAll(); $filterFields = $models->getoutFilterFields($clearArray); // set ajax table if (AF::isAjaxRequestModels()) { $this->view->includeFile('_table', array('application', 'views', 'users'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields)); die; } $roles = Role::model()->cache()->findAllInArray(); // Clear the super user role if (isset($roles[1])) { unset($roles[1]); } Assets::js('ajax_table'); Assets::js('af_input_field'); $this->addToPageTitle('Users'); $this->render('view', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'roles' => $roles, 'filterFields' => $filterFields)); }
function viewAction() { $this->filter(); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params)); $models = AFActiveDataProvider::models('CampaignProduct', $this->params, $pagination); $dataProvider = $models->getAll(); $camprodModel = new CampaignProduct(); $camprodModel->campaign_id = AF::get($this->params, 'campaign_id', 0); $productsUpsellsMain = $camprodModel->getUpsellProducts(); //eg: Array ( [321] => Array ( [product_id] => 321 [yes_upsell_id] => 0 ) ) //fb($productsUpsellsMain); $arr = array(); foreach ($productsUpsellsMain as $upsellArray) { $arr[] = $upsellArray['yes_upsell_id']; } // $arr[0] = 0 //$upsellModel = new Upsell(); $productsUpsells = array(); while (!empty($arr)) { $upsels = Upsells::getUpsellByArrayIDs($arr); $arr = array(); foreach ($upsels as $item) { $productsUpsells[$item['upsell_id']] = $item; if ($item['yes_upsell_id'] && !isset($productsUpsells[$item['yes_upsell_id']])) { $arr[] = $item['yes_upsell_id']; } if ($item['no_upsell_id'] && !isset($productsUpsells[$item['no_upsell_id']])) { $arr[] = $item['no_upsell_id']; } } } $products = Product::model()->cache()->findAllInArray(); $shippings = Shipping::model()->cache()->findAllInArray(); Assets::js('jquery.form'); $this->addToPageTitle('Campaigns Products'); $this->render('view', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'productsUpsells' => $productsUpsells, 'productsUpsellsMain' => $productsUpsellsMain, 'products' => $products, 'shippings' => $shippings, 'campaign_id' => AF::get($this->params, 'campaign_id'))); }
function approvalsAction() { $clearArray = array(); $this->filter($clearArray); if (!isset($this->params['dates'])) { $today = date("d.m.Y"); $this->params['dates'] = $today . '-' . $today; } if (!isset($this->params['sort_by'])) { $this->params['sort_by'] = 'bank_name'; } if (!isset($this->params['sort'])) { $this->params['sort'] = 'asc'; } $models = AFActiveDataProvider::models('Order', $this->params); $dataProvider = $models->getApprovalsReport(); $filterFields = $models->getoutFilterFields($clearArray, array('dates')); //=Order::$FilterFields // Download a csv file if (isset($this->params['download_csv'])) { Csv::printArray($dataProvider); } // set an ajax table if (AF::isAjaxRequestModels()) { $this->view->includeFile('_approvals_table', array('application', 'views', 'reports'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'filterFields' => $filterFields, 'ajax' => true)); die; } $campaigns = Campaign::model()->cache()->findAllInArray(); $countries = Country::model()->cache()->findAllInArray(); $this->addToPageTitle(__('section_name_approvals_report')); Assets::css('jquery-ui'); Assets::js('jquery-ui'); Assets::js('dateRange/jquery.daterange'); Assets::js('ajax_table'); Assets::js('af_input_field'); $this->render('approvals', array('dataProvider' => $dataProvider, 'filterFields' => $filterFields, 'campaigns' => $campaigns, 'countries' => $countries)); }
function cloneAction() { if (isset($_POST['clone'])) { $model = AFActiveDataProvider::models('Campaign'); $campaigns = $model->getCampaigns(); $campaigns = AF::userAccess()->array2RestrictionArray('campaign_id', $campaigns); 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); $pixel_ids = AF::get($_POST, 'pixel_id', 0); if (AF::userAccess()->hasRestrictions('campaign_id')) { $rf = AF::userAccess()->getRestrictionSearchFields('campaign_id', array()); if (!in_array($campaign_id, $rf)) { Message::echoJsonError(__('pixel_not_cloned')); } } if (!$pixel_ids && !$campaign_id) { Message::echoJsonError(__('campaign_id_not_found')); } $pixels = explode(',', $pixel_ids); $message = array(); $newIDs = array(); $isMany = count($pixels) > 1 ? true : false; $isThisCampaign = true; foreach ($pixels as $pixel_id) { $model = new Pixel(); if (!$model->fillFromDbPk($pixel_id)) { if ($isMany) { continue; } Message::echoJsonError(__('pixel_not_found')); } if ($model->campaign_id != $campaign_id) { $model->campaign_id = $campaign_id; $isThisCampaign = false; } if (!$model->cloneModel()) { if ($isMany) { continue; } Message::echoJsonError(__('pixel_not_found')); } $newID = $newIDs[] = $model->getPkValue(); $message[] = __('pixel_cloned') . ' <a href="' . $this->controller . '/update/id=' . $newID . '">' . __('edit') . ' (ID: ' . $newID . ')</a><br>'; unset($model); } if (!$message) { Message::echoJsonError(__('pixel_not_cloned')); } $message = implode($message); $newIDs = implode(',', $newIDs); $v = array('message' => $message); if ($isThisCampaign) { $v['newid'] = $newIDs; } Message::echoJsonSuccess($v); } }
private function upsellProcess() { // is this request still valid? set to one hour. there is a cron that salvages orphaned upsell orders after 1 hour if ($this->intervalCheck) { $this->checkInterval($this->order->updated); } // load previous order upsells, if any $orderUpsells = AFActiveDataProvider::models('OrderUpsell'); $orderUpsells->loadId($this->order->order_id); // is this a switch main product upsell? $replace = false; $upsell = new Upsell(); if (!$upsell->fillFromDbPk($this->post['uid'])) { apiError('order upsell invalid'); } if ($upsell->product_replace && $this->post['act_up'] == 'yes') { $replace = true; // overwrite main order_product record and reset upsell path $this->post['product_id'] = $upsell->product_id; $this->newOrder = false; // $this->upsell_id is built via the function below $this->buildProducts(); $this->order->amount_product = $this->amount_product; if ($upsell->shipping_id) { $shipping = new Shipping(); if ($shipping->fillFromDbPk($upsell->shipping_id)) { $this->order->shipping_id = $shipping->shipping_id; $this->order->amount_shipping = $shipping->amount_initial; } unset($shipping); } if (!$this->order->save()) { fb('order not saved'); continue; } // overwrite step so we can delete all previous steps below $this->post['step'] = 0; } // is this a replace product, or has this step already been recorded? if so, wipe out steps in DB if ($replace || (int) $this->post['step'] <= $orderUpsells->getUpsellStep()) { $orderUpsells->deleteSteps($this->post['step']); } if (!$replace) { $orderUpsells->add($this->order->order_id, $this->post['uid'], $this->post['act_up'], $this->post['step']); if (!$orderUpsells->save()) { apiError('order upsell invalid'); } // is there another upsell based on the asnwer given? $this->upsell_id = $orderUpsells->nextUpsell(); } if (!$this->upsell_id) { // We're all done with upsells, insert upsell products into order products // retrieve existing order_products $orderProducts = new OrderProducts('OrderProduct'); $orderProducts->loadByOrderId($this->order->order_id); foreach ($orderUpsells->orderUpsells as $oa) { if ($oa->answer == 'yes') { $orderProducts->add($oa->product_id, $oa->shipping_id, $this->order->order_id); } // remove from DB $oa->delete(); } if (!$orderProducts->save()) { continue; } // update amounts $this->order->amount_product = $orderProducts->getTotal(); if (!$this->order->save()) { fb('order not saved'); continue; } // process Payment $this->webPayment(); } else { // send user to next upsell page $this->upsellDirect((int) $this->post['step'] + 1); } }
function updateAction() { $model = new Profile(); if (isset($_POST['ajax'])) { // Add method to profile if (isset($_POST['model']) && $_POST['model'] == 'profiles_methods') { $profileMethod = new ProfileMethod(); @$this->performAjaxValidation($profileMethod); // Uncomment the line if AJAX validation is needed if ($_POST['action'] == 'create') { $profileMethod->fillFromArray($_POST, TRUE); } elseif ($_POST['action'] == 'update') { $methodID = (int) AF::get($_POST, 'method_id'); $profileID = (int) AF::get($_POST, 'profile_id'); $profileMethod = ProfileMethod::model()->findByPk(array('method_id' => $methodID, 'profile_id' => $profileID)); $profileMethod->fillFromArray($_POST); } if ($profileMethod->method_id == Method::METHOD_CC) { if (isset($_POST['flags']['filter']) && $_POST['flags']['filter']) { if (!$profileMethod->flags) { $profileMethod->flags = ''; } @$profileMethod->addFlags('filter'); } else { $profileMethod->removeFlags('filter'); } } if (!$profileMethod->flags) { $profileMethod->flags = ''; } if ($profileMethod->save()) { $link = AF::link(array('profiles' => 'update'), array('id' => $profileMethod->profile_id)); Message::echoJson('success', array('redirect' => $link)); } else { Message::echoJsonError(__('profile_method_not_' . $_POST['action'] . 'd') . '. ' . $profileMethod->errors2string); } } if (isset($_POST['getprofilemethodinfo'])) { $methodID = (int) AF::get($_POST, 'method_id'); $profileID = (int) AF::get($_POST, 'profile_id'); $methods = Method::model()->cache()->findAllInArray(); //$model = ProfileMethod::model()->find("profiles_methods_id=:profiles_methods_id", array(':profiles_methods_id'=>$id)); $model = ProfileMethod::model()->findByPk(array('method_id' => $methodID, 'profile_id' => $profileID)); echo $this->view->includeFile('_methods_form', array('application', 'views', 'profiles'), array('action' => 'update', 'ajax' => TRUE, 'popup' => TRUE, 'methodModel' => $model, 'methods' => $methods)); die; } } if (isset($_POST['model'])) { // Change profile_name if ($_POST['model'] == 'profile') { if (isset($_POST['ajax'])) { $this->performAjaxValidation($model); // Uncomment the line if AJAX validation is needed $model->fillFromArray($_POST, FALSE); $model->user_id_updated = $this->user->user_id; $model->updated = 'NOW():sql'; $model->model_uset_id = $this->user->user_id; if ($model->save()) { $link = AF::link(array('profiles' => 'update'), array('id' => $model->PkValue)); Message::echoJson('success', array('redirect' => $link)); } else { Message::echoJsonError(__('profile_no_updated')); } die; } $this->redirect(); die; } // Add gateway to profile if ($_POST['model'] == 'profiles_gateways') { $profileGateway = new ProfileGateway(); $this->performAjaxValidation($profileGateway); // Uncomment the line if AJAX validation is needed $profileGateway->fillFromArray($_POST, TRUE); $profileGateway->addGateway(); } } $id = AF::get($this->params, 'id', FALSE); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params)); $models = AFActiveDataProvider::models('ProfileGateway', $this->params, $pagination); $profile_methods = ProfileMethod::model()->getProfileMethodsByProfile($id); //$method_ids = '0'; if ($profile_methods) { foreach ($profile_methods as $key => $value) { $method_id_array[] = $value['method_id']; } $method_ids = implode(',', $method_id_array); } $methods = Method::model()->cache()->findAllInArray(); $gateways = Gateway::model()->getGateways(); if (!$id) { throw new AFHttpException(0, 'no_id'); } if (!$model->findByPk($id)) { throw new AFHttpException(0, 'incorrect_id'); } //for create profile method $modelProfileMethod = new ProfileMethod(); $modelProfileMethod->profile_id = $model->profile_id; Assets::js('jquery.form'); $this->addToPageTitle('Edit Profile'); $this->render('update', array('model' => $model, 'gateways' => $gateways, 'models' => $models, 'methods' => $methods, 'profile_methods' => $profile_methods, 'modelProfileMethod' => $modelProfileMethod)); }
public function updateAction() { $model = new Gateway(); $this->performAjaxValidation($model); // Uncomment the following line if AJAX validation is needed if (isset($_POST['model']) && $_POST['model'] == 'Gateway') { if (isset($_POST['ajax'])) { $model->fillFromArray($_POST, FALSE); $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(__('gateway_updated')); } else { Message::echoJsonError(__('gateway_no_updated')); } die; } $model->save(); $this->redirect(); die; } $id = AF::get($this->params, 'id', FALSE); if (!$id) { throw new AFHttpException(0, 'no_id'); } if (!$model->cache()->findByPk($id)) { throw new AFHttpException(0, 'incorrect_id'); } $currencies = Currency::model()->cache()->findAllInArray(); $methods = Method::model()->cache()->findAllInArray(); $systems = PSystem::model()->cache()->findAllInArray(); $gateways = Gateway::model()->cache()->findAllInArray(); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params)); $models = AFActiveDataProvider::models('GatewayLimit', $this->params, $pagination); $limits = $models->getLimitsByGatewayId($id); Assets::js('jquery.form'); $this->addToPageTitle('Update Gateway'); $this->render('update', array('model' => $model, 'currencies' => $currencies, 'limits' => $limits, 'methods' => $methods, 'systems' => $systems, 'gateways' => $gateways)); }
function logsAction() { if (isset($_POST['model']) && $_POST['model'] == 'orderlogs') { $orderID = AF::get($_POST, 'order_id'); if (!$orderID) { Message::echoJsonError(__('emply_order_id')); } $notes = AF::get($_POST, 'notes'); if (!$notes) { Message::echoJsonError(__('emply_notes')); } $modelOrderLog = new OrderLog(); $modelOrderLog->order_id = $orderID; $modelOrderLog->user_id = $this->user->user_id; $modelOrderLog->action = 15; $modelOrderLog->notes = $notes; if ($modelOrderLog->save()) { Message::echoJsonSuccess(); } else { Message::echoJsonError(__('orderlogs_not_created')); } die; } $orderID = AF::get($this->params, 'order_id'); $clearArray = array('action'); $this->filter($clearArray); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params)); $models = AFActiveDataProvider::models('OrderLog', $this->params, $pagination); $dataProvider = $models->getAll(); $FilterFields = $models->getoutFilterFields(array('action')); $this->addToPageTitle(__('order_logs')); Assets::css('jquery-ui'); Assets::js('//code.jquery.com/ui/1.10.3/jquery-ui.js'); Assets::js('dateRange/jquery.daterange'); Assets::js('jquery.form'); $this->render('logs', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'orderID' => $orderID, 'FilterFields' => $FilterFields)); }
function emailAction() { $model = new CampaignEmail(); if (isset($_POST['ajax'])) { if (isset($_POST['model']) && $_POST['model'] == 'prospects') { // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); $model->fillFromArray($_POST); /* $model->user_id_created = $this->user->user_id; $model->user_id_updated = $this->user->user_id; $model->updated = 'NOW():sql'; $model->created = 'NOW():sql'; $model->model_uset_id = $this->user->user_id; */ if ($model->save()) { Message::echoJsonSuccess(); } else { Message::echoJsonError(__('prospects_email_not_created') . ' ' . $model->errors2string); } die; } if (isset($_POST['model']) && $_POST['model'] == 'campaigns') { $campaignModel = new Campaign(); $campaignModel->setIsNewRecord(false); $campaignID = AF::get($_POST, 'campaign_id'); $campaignModel->fillFromDbPk($campaignID); $campaignModel->smtp_id = AF::get($_POST, 'smtp_id'); $campaignModel->user_id_updated = $this->user->user_id; $campaignModel->updated = 'NOW():sql'; if ($campaignModel->save(false)) { Message::echoJsonSuccess(__('campaign_updated')); } else { Message::echoJsonError(__('campaign_no_updated')); } die; } } $clearArray = array(); $this->filter($clearArray); $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true)); $models = AFActiveDataProvider::models('CampaignEmail', $this->params, $pagination); $dataProvider = $models->getAll(); $filterFields = $models->getoutFilterFields($clearArray); // set ajax table if (AF::isAjaxRequestModels()) { $this->view->includeFile('_email_table', array('application', 'views', 'prospects'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields)); die; } $templates = Template::model()->cache()->findAllInArray(); $smtps = Smtp::model()->cache()->findAllInArray(); $campaignID = AF::get($this->params, 'campaign_id'); $campaignModel = new Campaign(); $campaignModel->fillFromDbPk($campaignID); Assets::js('jquery.form'); $this->addToPageTitle(__('prospect_email')); $this->render('email', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'campaignModel' => $campaignModel, 'templates' => $templates, 'smtps' => $smtps, 'filterFields' => $filterFields)); }