Exemplo n.º 1
0
 function updateAction()
 {
     $model = new Address();
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['ajax']) && $_POST['ajax'] == 'categorys-form') {
         if (isset($_POST['AFID_ALL']) || isset($_POST['AFID']) && !$_POST['AFID']) {
             $_POST['AFID'] = 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(__('address_updated'));
         } else {
             Message::echoJsonError(__('address_not_updated'));
         }
         die;
     }
     $id = AF::get($this->params, 'id', FALSE);
     if (!$id) {
         throw new AFHttpException(0, 'no_id');
     }
     if (!$model->findByPk($id)) {
         throw new AFHttpException(0, 'incorrect_id');
     }
     $countries = Country::model()->cache()->findAllInArray();
     $states = $model->country_id ? State::model()->getStatesByCID($model->country_id) : array();
     $this->addToPageTitle('Update address');
     Assets::js('jquery.form');
     $this->render('update', array('model' => $model, 'countries' => $countries, 'states' => $states));
 }
Exemplo n.º 2
0
 function updateAction()
 {
     $model = new Affiliate();
     $this->performAjaxValidation($model);
     // Uncomment the following line if AJAX validation is needed
     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(__('affiliate_updated'));
         } else {
             Message::echoJsonError(__('affiliate_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));
     Assets::js('jquery.form');
     $this->addToPageTitle('Update affiliate');
     $this->render('update', array('model' => $model, 'pagination' => $pagination));
 }
Exemplo n.º 3
0
 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));
 }
Exemplo n.º 4
0
 function updateAction()
 {
     $model = new IpAccess();
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['ajax'])) {
         $id = AF::get($_POST, 'id');
         $model->findByPk($id);
         $model->ip = $_POST['ip'];
         $model->note = $_POST['note'];
         if ($model->save()) {
             $link = $_SERVER['HTTP_REFERER'];
             Message::echoJson('success', array('redirect' => $link));
             Message::echoJsonSuccess(__('access_updated'));
         } else {
             Message::echoJsonError(__('access_not_updated') . ' ' . $model->errors2string);
         }
         die;
     }
     $id = AF::get($this->params, 'id', FALSE);
     if (!$id) {
         throw new AFHttpException(0, 'no_id');
     }
     if (!$model->findByPk($id)) {
         throw new AFHttpException(0, 'incorrect_id');
     }
     $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params));
     Assets::js('jquery.form');
     $this->addToPageTitle('Update affiliate');
     $this->render('update', array('model' => $model, 'pagination' => $pagination));
 }
Exemplo n.º 5
0
 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));
 }
Exemplo n.º 6
0
 function updateAction()
 {
     $model = new Domain();
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (AF::isAjaxRequest() && isset($_POST['model']) && $_POST['model'] == 'Domain') {
         $model->fillFromArray($_POST, false);
         if ($model->save()) {
             Message::echoJsonSuccess(__('domain_updated'));
         } else {
             Message::echoJsonError(__('domain_not_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');
     }
     Assets::js('jquery.form');
     $this->addToPageTitle(__('update_domain'));
     $this->render('update', array('model' => $model));
 }
Exemplo n.º 7
0
 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));
 }
Exemplo n.º 8
0
 function updateAction()
 {
     $model = new Shipcat();
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['model']) && $_POST['model'] == 'Shipcat') {
         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(__('shipcat_updated'));
             } else {
                 Message::echoJsonError(__('shipcat_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->fillFromDbPk($id)) {
         throw new AFHttpException(0, 'incorrect_id');
     }
     Assets::js('jquery.form');
     $this->addToPageTitle('Update shipcat');
     $this->render('update', array('model' => $model));
 }
Exemplo n.º 9
0
 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));
 }
Exemplo n.º 10
0
 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')));
 }
Exemplo n.º 11
0
 public function before()
 {
     parent::before();
     if ($this->auto_render === TRUE) {
         Assets::js('jquery', ADMIN_RESOURCES . 'libs/jquery.min.js');
         Assets::package(array('jquery-ui', 'backbone', 'notify', 'underscore', 'select2', 'core', 'bootstrap'));
     }
 }
Exemplo n.º 12
0
 public function action_index()
 {
     Assets::package('jquery-ui');
     Assets::css('fullcalendar', ADMIN_RESOURCES . 'libs/fullcalendar-2.1.0/fullcalendar.min.css', 'global');
     Assets::js('fullcalendar', ADMIN_RESOURCES . 'libs/fullcalendar-2.1.0/fullcalendar.min.js', 'jquery');
     Assets::js('fullcalendar.lang', ADMIN_RESOURCES . 'libs/fullcalendar-2.1.0/lang/' . I18n::lang_short() . '.js', 'fullcalendar');
     $this->set_title(__('Calendar'), FALSE);
     $this->template->content = View::factory('calendar/index', array('colors' => array('default', 'darken', 'danger', 'info', 'primary', 'success', 'warning'), 'icons' => array('info', 'warning', 'check', 'user', 'lock', 'clock-o')));
 }
Exemplo n.º 13
0
 /**
  * Tests whether JS files can be combined, minified,
  * and cached successfully. Verfies returned HTML 
  * tag and checks to see whether cached file exists.
  * @return void
  */
 public function testRenderJs()
 {
     Assets::js(array('plugins.js', 'functions.js'));
     Assets::coffee('test.coffee');
     // Does returned tag match expected output?
     $this->assertTrue(Assets::renderJs() == "<script type=\"text/javascript\" src=\"/assets/cache/" . Assets::getCompiledName('js') . "\"></script>");
     // Does file exist?
     $this->filename = __DIR__ . '/assets/cache/' . Assets::getCompiledName('js');
     $this->assertTrue(file_exists($this->filename));
 }
Exemplo n.º 14
0
 public function before()
 {
     parent::before();
     if (file_exists(CMSPATH . FileSystem::normalize_path('media/js/i18n/' . I18n::lang() . '-message.js'))) {
         Assets::js('i18n', ADMIN_RESOURCES . 'js/i18n/' . I18n::lang() . '-message.js', 'global');
     }
     if ($this->request->action() != 'logout' and Auth::is_logged_in()) {
         $this->go_home();
     }
 }
Exemplo n.º 15
0
 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));
 }
Exemplo n.º 16
0
 public function action_index()
 {
     \Assets::css('page2', base_UI . 'css/rangeslider.css');
     \Assets::js('page1', base_UI . 'js/plugins/range/rangeslider.min.js');
     \Assets::js('page2', base_UI . 'js/plugins/range/range_script.js');
     \Assets::js('attr', base_UI . 'js/pages/attr.js');
     \Assets::js('jumper', base_UI . 'js/index/recovery_pass_jumper.js');
     $user_id = \Registry::getCurrentUser()->iduser;
     $data_formula = $this->dataFormula();
     $this->template->assign(['data_formula' => $data_formula]);
     $this->response->body($this->template->fetch('main.tpl'));
 }
Exemplo n.º 17
0
 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')));
 }
Exemplo n.º 18
0
 public function action_message()
 {
     \Assets::js('page', base_UI . 'js/pages/chat.js');
     $user_id = \Registry::getCurrentUser()->id;
     $receiver_id = $this->request->param('id');
     $receiver = \Model\User::model()->findByPk($receiver_id);
     $criteria = new \DBCriteria();
     $criteria->condition = ' ( session = "' . $receiver_id . "#" . $user_id . '" ) OR
     ( session = "' . $user_id . "#" . $receiver_id . '" ) ';
     $session = \Model\Chat::model()->find($criteria);
     $short_history = $this->userCustomHistory($user_id, $receiver_id, $session->session, $this->user_messages);
     $this->template->assign(['short_history' => $short_history, 'session' => $session->session, 'receiver' => $receiver]);
     $this->response->body($this->template->fetch('chat/message.tpl'));
 }
Exemplo n.º 19
0
 function languageAction()
 {
     if (isset($_POST['UserSettings'])) {
         $this->user->settings->attributes = $_POST['UserSettings'];
         if ($this->user->save()) {
             Message::echoJsonSuccess(__('user_settings_updated'));
         } else {
             Message::echoJsonError(__('user_settings_not_updated'));
         }
     }
     $this->addToPageTitle(__('language') . ' ' . __('settings'));
     Assets::js('jquery.form');
     $this->render('language', array());
 }
Exemplo n.º 20
0
 /**
  * Add hook for shortcode tag
  *
  * There can only be one hook for each shortcode.
  * Which means that if another plugin has a similar shortcode, it will
  * override yours or yours will override theirs depending on which order
  * the plugins are included and/or ran.
  *
  * @param   string          $tag       Shortcode tag to be searched in post content.
  * @param   callable        $callback  Hook to run when shortcode is found.
  * @param   string|boolean  $asset     CSS or JS or both to be added. css|js|both [Optional]
  *
  * @return  array
  *
  * @throws  Gleez_Exception
  *
  * @uses    Assets::css
  * @uses    Assets::js
  */
 public static function set($tag, $callback, $asset = FALSE)
 {
     if (!is_callable($callback)) {
         throw new Gleez_Exception('Invalid Shortcode::callback specified');
     }
     self::$_tags[$tag] = $callback;
     if ($asset and $asset == 'css') {
         Assets::css($tag, "media/css/shortcodes/{$tag}.css");
     }
     if ($asset and $asset == 'js') {
         Assets::js($tag, "media/js/shortcodes/{$tag}.js");
     }
     return self::$_tags;
 }
Exemplo n.º 21
0
 /**
  * Listing Widgets
  */
 public function action_index()
 {
     $this->title = __('Widgets');
     $view = View::factory('admin/widget/list')->bind('widget_regions', $widget_regions)->bind('weight_delta', $weight_delta)->bind('widgets', $widget_listing);
     $widget_regions = array();
     $adminTheme = Theme::getTheme();
     $frontTheme = Theme::getTheme(Config::get('site.theme', $adminTheme->name));
     if (isset($adminTheme->regions) and !empty($adminTheme->regions)) {
         $widget_regions = Arr::merge($widget_regions, $adminTheme->regions);
     }
     if (isset($frontTheme->regions) and !empty($frontTheme->regions)) {
         $widget_regions = Arr::merge($widget_regions, $frontTheme->regions);
     }
     // Add a last region for disabled blocks.
     $widget_regions = Arr::merge($widget_regions, array(self::$WIDGET_REGION_NONE => self::$WIDGET_REGION_NONE));
     $widgets = ORM::factory('widget')->order_by('region')->order_by('weight')->find_all();
     // Weights range from -delta to +delta, so delta should be at least half
     // of the amount of blocks present. This makes sure all blocks in the same
     // region get an unique weight.
     $weight_delta = round(count($widgets) / 2);
     if (isset($widget_regions[self::$WIDGET_REGION_NONE])) {
         $widget_regions[self::$WIDGET_REGION_NONE] = __('Disabled');
     }
     foreach ($widget_regions as $key => $value) {
         // Initialize an empty array for the region.
         $widget_listing[$key] = array();
     }
     // Initialize disabled widgets array.
     $widget_listing[self::$WIDGET_REGION_NONE] = array();
     // Add each block in the form to the appropriate place in the widget listing.
     foreach ($widgets as $widget) {
         // Fetch the region for the current widget.
         $region = isset($widget->region) ? $widget->region : self::$WIDGET_REGION_NONE;
         $widget_listing[$region][] = $widget;
     }
     if ($this->valid_post('widget-list')) {
         foreach ($_POST['widgets'] as $widget) {
             $widget['status'] = (int) ($widget['region'] != self::$WIDGET_REGION_NONE);
             $widget['region'] = $widget['status'] ? $widget['region'] : self::$WIDGET_REGION_NONE;
             DB::update('widgets')->set(array('status' => $widget['status'], 'weight' => $widget['weight'], 'region' => $widget['region']))->where('id', '=', $widget['id'])->execute();
         }
         Message::success(__('The Widget settings have been updated.'));
         Cache::instance('widgets')->delete_all();
         $this->request->redirect(Route::get('admin/widget')->uri());
     }
     $this->response->body($view);
     Assets::tabledrag();
     Assets::js('widgets', 'media/js/widgets.js', array('jquery'), FALSE, array('weight' => 5));
 }
Exemplo n.º 22
0
 public function action_Edit()
 {
     if ($item_id = \Utils\Protect::Validate($this->request->param('id'), 'int')) {
         \Assets::js('sight', base_UI . 'js/admin/pages/Edit.js');
         $this->addCKEditor();
         $this->addBootstrapModal();
         $this->addSelect2();
         //Alerts BootBox
         \Assets::js('BootBox', base_UI . 'libs/BootBox/bootbox.js');
         //Item Data
         $data_item = \Model\Pages::model()->findByPk($item_id);
         $PageTypes = \Model\PageType::model()->findAll();
         $this->template->assign(['data' => $data_item, 'PageTypes' => $PageTypes]);
         $this->response->body($this->template->fetch('admin/pages/edit.tpl'));
     }
 }
Exemplo n.º 23
0
 public function action_revision()
 {
     Assets::js('diff_text_tool', ADMIN_RESOURCES . 'libs/diff_match_patch.js', 'global');
     Assets::js('part_revision', ADMIN_RESOURCES . 'js/controller/part_revision.js', 'global');
     $part_id = (int) $this->request->param('id');
     $part = ORM::factory('page_part', $part_id);
     $parts = DB::select()->from('part_revision')->order_by('created_on', 'desc')->as_object();
     if (!empty($part->id)) {
         $page = ORM::factory('page', $part->page_id);
         $this->breadcrumbs->add($page->title, Route::get('backend')->uri(array('controller' => 'page', 'action' => 'edit', 'id' => $page->id)));
         $this->set_title(__('Revision for part :name', array(':name' => $part->name)));
         $parts->where('part_id', '=', $part_id);
     } else {
         $this->set_title(__('Parts revision'));
     }
     $this->template->content = View::factory('part/revision', array('part' => $part, 'parts' => $parts->execute()));
 }
Exemplo n.º 24
0
 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')));
 }
Exemplo n.º 25
0
 public function action_Edit()
 {
     if ($item_id = \Utils\Protect::Validate($this->request->param('id'), 'int')) {
         \Assets::js('sight', base_UI . 'js/admin/Payments/Edit.js');
         $this->addCKEditor();
         $this->addBootstrapModal();
         $this->addSelect2();
         //Alerts BootBox
         \Assets::js('BootBox', base_UI . 'libs/BootBox/bootbox.js');
         //Item Data
         $data = \Model\UserPayment::model()->with('iduser0', 'iduserCredit')->findByPk($item_id);
         $userCredit = \Model\UserCredit::model()->findAll();
         $users = \Model\User::model()->findAll();
         $this->template->assign(['data' => $data, 'userCredit' => $userCredit, 'users' => $users]);
         $this->response->body($this->template->fetch('admin/payments/edit.tpl'));
     }
 }
Exemplo n.º 26
0
 public function action_display()
 {
     $user_id = \Registry::getCurrentUser()->iduser;
     if ($item_id = \Utils\Protect::Validate($this->request->param('id'), 'int')) {
         \Assets::js('page1', base_UI . 'js/pages/page.js');
         $page = \Model\Pages::model()->findByPk($item_id);
         $this->template->assign(['page' => $page]);
         $this->response->body($this->template->fetch('pages.tpl'));
     } else {
         if ($alias = \Utils\Protect::Validate($this->request->param('alias'), 'string')) {
             /**@var \Model\Item $data*/
             \Assets::js('page1', base_UI . 'js/pages/page.js');
             $page = \Model\Pages::model()->findByAttributes(['alias' => $alias]);
             $this->template->assign(['page' => $page]);
             $this->response->body($this->template->fetch('pages.tpl'));
         }
     }
 }
Exemplo n.º 27
0
 /**
  * Sending mails
  *
  * @since 1.0.0  First time this method was introduced
  * @since 1.1.0  Added jQuery Textarea Characters Counter Plugin
  *
  * @link  http://roy-jin.appspot.com/jsp/textareaCounter.jsp
  *
  * @uses  Request::query
  * @uses  Route::get
  * @uses  Route::uri
  * @uses  URL::query
  * @uses  URL::site
  * @uses  Validation::rule
  * @uses  Config::get
  * @uses  Config::load
  * @uses  Assets::js
  */
 public function action_mail()
 {
     $this->title = __('Contact us');
     $config = Config::load('contact');
     Assets::js('textareaCounter', 'media/js/jquery.textareaCounter.plugin.js', array('jquery'), FALSE, array('weight' => 10));
     Assets::js('greet/form', 'media/js/greet.form.js', array('textareaCounter'), FALSE, array('weight' => 15));
     //Add schema.org support
     $this->schemaType = 'ContactPage';
     // Set form destination
     $destination = !is_null($this->request->query('destination')) ? array('destination' => $this->request->query('destination')) : array();
     // Set form action
     $action = Route::get('contact')->uri(array('action' => $this->request->action())) . URL::query($destination);
     // Get user
     $user = User::active_user();
     // Set mail types
     $types = $config->get('types', array());
     $view = View::factory('contact/form')->set('destination', $destination)->set('action', $action)->set('config', $config)->set('types', $types)->set('user', $user)->bind('post', $post)->bind('errors', $this->_errors);
     // Initiate Captcha
     if ($config->get('use_captcha', FALSE) and !$this->_auth->logged_in()) {
         $captcha = Captcha::instance();
         $view->set('captcha', $captcha);
     }
     if ($this->valid_post('contact')) {
         $post = Validation_Contact::factory($this->request->post());
         if ($post->check()) {
             // Create the email subject
             $subject = __('[:category] :subject', array(':category' => $types[$post['category']], ':subject' => Text::plain($post['subject'])));
             // Create the email body
             $body = View::factory('email/contact')->set('name', $post['name'])->set('body', $post['body'])->set('config', Config::load('site'))->render();
             // Create an email message
             $email = Email::factory()->to(Text::plain($this->_config->get('site_email', '*****@*****.**')), __('Webmaster :site', array(':site' => Template::getSiteName())))->subject($subject)->from($post['email'], Text::plain($post['name']))->message($body, 'text/html');
             // @todo message type should be configurable
             // Send the message
             $email->send();
             Log::info(':name sent an e-mail regarding :cat', array(':name' => Text::plain($post['name']), ':cat' => $types[$post['category']]));
             Message::success(__('Your message has been sent.'));
             // Always redirect after a successful POST to prevent refresh warnings
             $this->request->redirect(Route::get('contact')->uri(), 200);
         } else {
             $this->_errors = $post->errors('contact', TRUE);
         }
     }
     $this->response->body($view);
 }
Exemplo n.º 28
0
 /**
  * Javascript (optimized) helper.
  * All scripts are optimized for download size and formed into a single file.
  * Optimization is done by JShrink\Minimizer.
  *
  * This file is updated automatically if the files change.
  *
  * @param $files - array of files to include
  * @param $outputdir - where to place the generated files, default is typically adequate.
  */
 public static function combine_js($files, $outputdir = 'static/generated/')
 {
     if (\HMC\Config::SITE_ENVIRONMENT() == 'development') {
         Assets::js($files);
         return;
     }
     $ofiles = is_array($files) ? $files : array($files);
     $hashFileName = md5(join($ofiles));
     $dirty = false;
     if (file_exists($outputdir . $hashFileName . '.js')) {
         $hfntime = filemtime($outputdir . $hashFileName . '.js');
         foreach ($ofiles as $vfile) {
             $file = str_replace(\HMC\Config::SITE_URL(), \HMC\Config::SITE_PATH(), $vfile);
             if (!$dirty) {
                 $fmtime = filemtime($file);
                 if ($fmtime > $hfntime) {
                     $dirty = true;
                 }
             }
         }
     } else {
         $dirty = true;
     }
     if ($dirty) {
         $buffer = "";
         foreach ($ofiles as $vfile) {
             $jsFile = str_replace(\HMC\Config::SITE_URL(), \HMC\Config::SITE_PATH(), $vfile);
             $buffer .= "\n" . file_get_contents($jsFile);
         }
         ob_start();
         // Write everything out
         echo $buffer;
         $fc = ob_get_clean();
         $minifiedCode = \JShrink\Minifier::minify($fc, array('flaggedComments' => false));
         file_put_contents(SITEROOT . $outputdir . $hashFileName . '.js', $minifiedCode);
     }
     static::resource(str_replace(':||', '://', str_replace('//', '/', str_replace('://', ':||', \HMC\Config::SITE_URL() . $outputdir . $hashFileName . '.js'))), 'js');
 }
Exemplo n.º 29
0
 public function init_media()
 {
     parent::init_media();
     $this->template_js_params['ACE_THEME'] = Config::get('ace', 'theme', 'textmate');
     $this->template_js_params['DEFAULT_FILTER'] = Config::get('site', 'default_filter_id', '');
     Assets::package(array('jquery', 'bootstrap', 'notify', 'select2', 'dropzone', 'fancybox', 'datepicker', 'underscore', 'core'));
     foreach (array('.js', '-message.js') as $file_name) {
         $filename = Kohana::$cache_dir . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, array('i18n', NULL)) . I18n::lang() . $file_name;
         if (file_exists($filename)) {
             Assets::js('i18n', BASE_URL . 'cms/cache/i18n/' . I18n::lang() . $file_name, 'global', FALSE, 0);
         }
     }
     $file = $this->request->controller();
     $directory = $this->request->directory();
     if (!empty($directory)) {
         $file = $directory . '/' . $file;
     }
     $file = strtolower($file);
     if (Kohana::find_file('media', FileSystem::normalize_path('js/controller/' . $file), 'js')) {
         Assets::js('controller.' . $file, ADMIN_RESOURCES . 'js/controller/' . $file . '.js', 'global', FALSE, 999);
     }
     Assets::group('global', 'events', '<script type="text/javascript">' . Assets::merge_files('js/events', 'js') . '</script>', 'global');
 }
Exemplo n.º 30
0
 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')));
 }