function updateAction() { $model = new Event(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['model']) && $_POST['model'] == 'Event') { 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(__('events_updated')); } else { Message::echoJsonError(__('events_not_updated') . ' ' . $model->errors2string); } die; } $model->save(); $this->redirect(); 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'); } $templates = Template::model()->cache()->findAllInArray(); $smtps = Smtp::model()->cache()->findAllInArray(); Assets::js('jquery.form'); $this->addToPageTitle('Update event'); $this->render('update', array('model' => $model, 'smtps' => $smtps, 'templates' => $templates)); }
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('Smtp', $this->params, $pagination, '`smtp_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', 'smtp'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields)); die; } $smtps = Smtp::model()->cache()->findAllInArray(); Assets::js('ajax_table'); Assets::js('af_input_field'); $this->addToPageTitle(__('smtp')); $this->render('view', array('dataProvider' => $dataProvider, 'smtps' => $smtps, 'pagination' => $pagination, 'models' => $models, '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)); }