function resetAction() { $userID = AF::get($this->params, 'idUser'); $activKey = AF::get($this->params, 'activkey'); $reset = AF::get($this->params, 'reset'); if (!$userID || !$activKey || !$reset) { throw new AFHttpException(0, 'bad_request', 404); } $userModel = User::model()->findByPk($userID); if (!$userModel || $userModel->activkey != $activKey || $reset != 'true') { throw new AFHttpException(0, 'bad_request', 404); } if (isset($_POST['reset_password']) && isset($_POST['ajax'])) { $password = trim(AF::get($_POST, 'password')); if (strlen($password) < 4) { Message::echoJsonError(__('small_password')); } $userModel->password = $password; $userModel->activkey = ''; if ($userModel->save()) { Message::echoJsonSuccess(__('your_password_changed')); } else { Message::echoJsonError(__('your_password_not_changed')); } } $this->addToPageTitle(__('reset_your_password')); Assets::cleanJs(); Assets::js('jquery.min'); Assets::js('jquery.form'); $this->render('reset', array()); }
function deleteAction() { /* This is from profilegateways $id = AF::get($_POST, 'id', 0); $ids = explode('_', $id); $errors = FALSE; $model = new ProfileGateway(); $model->profile_id = $ids[0]; $model->method_id = $ids[1]; $model->gateway_id = $ids[2]; $model->delete(); unset($model); Message::echoJsonSuccess(__('gateway_removed')); $this->redirect(); */ $id = AF::get($_POST, 'id', 0); $errors = FALSE; $model = new GatewayLimit(); $model->model_uset_id = $this->user->user_id; if ($model->findByPk($id)) { $model->delete(); } else { $errors = TRUE; } if ($model->getErrors()) { $errors = TRUE; } unset($model); Message::echoJsonSuccess(__('limit_removed')); $this->redirect(); }
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()); }
function removeAction() { $id = AF::get($_POST, 'id', 0); $modelsID = explode(',', $id); $errors = FALSE; foreach ($modelsID as $id) { $model = new Event(); $t = explode('-', $id); if (isset($t[0]) && isset($t[1])) { $model->removeEventProduct($t[0], $t[1]); } else { $errors = TRUE; } unset($model); } if (isset($_POST['ajax'])) { AF::setJsonHeaders('json'); if ($errors) { Message::echoJsonError(__('events_not_deleted')); } else { Message::echoJsonSuccess(__('events_deleted')); } } $this->redirect(); }
function removeemailAction() { $id = AF::get($_POST, 'id', 0); $modelsID = explode(',', $id); $errors = false; foreach ($modelsID as $id) { $idsArray = explode('-', $id); if (count($idsArray) != 3) { $errors = true; } $model = new CampaignEmail(); if ($model->findByPk(array('campaign_id' => $idsArray[0], 'day' => $idsArray[1], 'template_id' => $idsArray[2]))) { $model->model_uset_id = $this->user->user_id; $model->delete(); } else { $errors = true; } if ($model->getErrors()) { $errors = true; } unset($model); } if (isset($_POST['ajax'])) { AF::setJsonHeaders('json'); if ($errors) { Message::echoJsonError(__('campaign_email_no_deleted')); } else { Message::echoJsonSuccess(__('campaign_email_deleted')); } } $this->redirect(); }
function cloneAction() { if (isset($_POST['clone'])) { $campaigns = Campaign::model()->cache()->findAllInArray(); 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); $campprod_ids = AF::get($_POST, 'campship_id', 0); if (!$campprod_ids && !$campaign_id) { Message::echoJsonError(__('campship_id_not_found')); } $campprods = explode(',', $campprod_ids); $message = array(); $newIDs = array(); $isMany = count($campprods) > 1 ? true : false; $isThisCampaign = true; foreach ($campprods as $id) { $model = new CampaignShipping(); if (!$model->findByPk($id)) { if ($isMany) { continue; } Message::echoJsonError(__('campship_not_found')); } if ($model->campaign_id != $campaign_id) { $model->campaign_id = $campaign_id; $isThisCampaign = false; } if (!$model->cloneModel()) { if ($isMany) { continue; } Message::echoJsonError($model->errors2string); } $newID = $newIDs[] = $model->getPkValue(); $message[] = __('campship_cloned') . ' <a href="' . $this->controller . '/view/campaign_id=' . $campaign_id . '">' . __('view_campaign') . ' (ID: ' . $newID . ')</a><br>'; unset($model); } if (!$message) { Message::echoJsonError(__('campship_not_cloned')); } $message = implode($message); $newIDs = implode(',', $newIDs); $v = array('message' => $message); if ($isThisCampaign) { $v['newid'] = $newIDs; } Message::echoJsonSuccess($v); } }
function addeventAction() { if (isset($_POST['ajax'])) { AF::setJsonHeaders('json'); $eventType = (int) AF::get($_POST, 'event_type', 0); $eventID = (int) AF::get($_POST, 'event_id', 0); $productID = (int) AF::get($_POST, 'product_id', 0); if (isset($_POST['model']) && $_POST['model'] == 'Product') { $errors = array(); if (!$eventID) { $errors['event_id'] = 'Required'; } if (!$eventType) { $errors['event_type'] = 'Required'; } if (!$productID) { $errors['product_id'] = 'Required'; } if ($errors) { $answer['errors'] = $errors; Message::echoJson('error', $answer); } $eventModel = new Event(); $eventModel->addProductByID($eventID, $productID); $link = AF::link(array('products' => 'update'), array('id' => $productID)); Message::echoJson('success', array('redirect' => $link)); } if ($eventType) { //Events type list $eventModel = new Event(); $eventsTypes = $eventModel->getEventsByTypeID($eventType); if ($eventsTypes) { Message::echoJsonSuccess(array('message' => $eventsTypes)); } else { Message::echoJsonError(__('unknown_error')); } die; } } $this->redirect(); }
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); } }
function deleteAction() { $id = AF::get($_POST, 'id', 0); $modelsID = explode(',', $id); $errors = FALSE; foreach ($modelsID as $id) { $model = new User(); $model->model_uset_id = $this->user->user_id; if ($model->fillFromDbPk($id)) { $model->delete($id); } else { $errors = TRUE; } if ($model->getErrors()) { $errors = TRUE; } unset($model); } if (isset($_POST['ajax'])) { AF::setJsonHeaders('json'); if ($errors) { Message::echoJsonError(__('campaign_no_deleted')); } else { Message::echoJsonSuccess(__('campaign_deleted')); } } $this->redirect(); }
protected function cloneModel($modelName) { $modelNameS = strtolower($modelName); if (isset($_POST['ajax'])) { AF::setJsonHeaders('json'); $idTemp = AF::get($_POST, 'id', 0); // added handling of possible addlData array passed over via the clone model function in all.js $addlData = AF::get($_POST, 'addlData', 0); if (!$idTemp) { Message::echoJsonError(__($modelNameS . '_id_not_found')); } $ids = explode(',', $idTemp); $message = array(); $newIDs = array(); $isMany = count($ids) > 1 ? true : false; foreach ($ids as $id) { $model = new $modelName(); if (!$model->fillFromDbPk($id)) { if ($isMany) { continue; } Message::echoJsonError(__($modelNameS . '_not_found')); } // added pass of addl to model function if (!$model->cloneModel($id, $addlData)) { if ($isMany) { continue; } Message::echoJsonError(__($modelNameS . '_not_cone')); } $newID = $newIDs[] = $model->getPkValue(); $message[] = __($modelNameS . '_cloned') . ' <a href="' . $this->controller . '/update/id=' . $newID . '">' . __('edit') . ' (ID: ' . $newID . ')</a><br>'; unset($model); } if (!$message) { Message::echoJsonError(__($modelNameS . '_not_cloned')); } $message = implode($message); $newIDs = implode(',', $newIDs); $v = array('message' => $message, 'newid' => $newIDs); Message::echoJsonSuccess($v); } }
function upsellAction() { $model = new Upsell(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['model']) && $_POST['model'] == 'upsells' && isset($_POST['ajax'])) { $upsellID = AF::get($_POST, 'upsell_id'); $parent_upsell_id = AF::get($_POST, 'parent_upsell_id'); $answer = AF::get($_POST, 'answer'); $productID = AF::get($_POST, 'product_id'); $shippingID = AF::get($_POST, 'shipping_id'); $campaign_id = AF::get($_POST, "campaign_id"); $main_parent_product_id = AF::get($_POST, "main_parent_product_id"); $product_replace = AF::get($_POST, "product_replace") ? AF::get($_POST, "product_replace") : 0; $url = AF::get($_POST, 'url'); if (!$answer) { Message::echoJsonError(__('upsell_not_upsell_answer')); } //if(!$shippingID) //Message::echoJsonError(__('upsell_select_shipping')); if (!$parent_upsell_id) { if ($upsellID) { $model->findByPk($upsellID); if ($productID) { $model->product_id = $productID; $model->shipping_id = $shippingID; $model->product_replace = $product_replace; $model->url = $url; if ($model->save()) { Message::echoJsonSuccess(array('reload' => '1', 'message' => __('upsell_updated'))); } else { Message::echoJsonError(__('upsell_not_updated')); } } else { $campProdModel = new CampaignProduct(); $campProdModel->findByPk($answer); $campProdModel->upsell_id = null; if ($campProdModel->save()) { $model->delete(); Message::echoJsonSuccess(array('reload' => '1', 'message' => __('upsell_updated'))); } else { Message::echoJsonError(__('upsell_not_updated')); } } } else { if (!$productID) { Message::echoJsonError(__('upsell_select_product')); } $model->product_id = $productID; $model->shipping_id = $shippingID; $model->product_replace = $product_replace; $model->url = $url; if ($model->save()) { $campProdModel = new CampaignProduct(); $campProdModel->findByPk($answer); $campProdModel->upsell_id = $model->upsell_id; if ($campProdModel->save()) { Message::echoJsonSuccess(array('reload' => '1', 'message' => __('upsell_created'))); } else { Message::echoJsonError(__('upsell_not_updated')); } } else { Message::echoJsonError(__('upsell_not_updated')); } } } elseif ($upsellID) { $model->findByPk($upsellID); if (!$productID) { if ($model->delete()) { $parentUpsellModel = new Upsell(); $parentUpsellModel->findByPk($parent_upsell_id); $parentUpsellModel->setAnswer($answer, null); $parentUpsellModel->save(); Message::echoJsonSuccess(__('upsell_not_deleted')); } else { Message::echoJsonError(__('upsell_not_updated')); } } else { $model->product_id = $productID; $model->shipping_id = $shippingID; $model->product_replace = $product_replace; $model->url = $url; if ($model->save()) { Message::echoJsonSuccess(array('reload' => '1', 'message' => __('upsell_updated'))); } else { Message::echoJsonError(__('upsell_not_updated')); } } } else { // parent_upsell_id = 119, upsell_id = 0 if (!$productID) { Message::echoJsonError(__('upsell_select_product')); } $model->fillFromArray($_POST); if ($model->save()) { $upsellModel = new Upsell(); $upsellModel->findByPk($parent_upsell_id); $upsellModel->setAnswer($answer, $model->upsell_id); if ($upsellModel->save()) { Message::echoJsonSuccess(array('reload' => '1', 'message' => __('upsell_created'))); } else { Message::echoJsonError(__('upsell_not_updated')); } } else { Message::echoJsonError(__('upsell_not_updated')); } } die; } }
public function process() { // States list request from sales site if ($this->wsType == 'st') { // set headers AF::setJsonHeaders('json'); // country_id has already been verified as set $states = State::model()->getStatesByCID($this->post['country_id']); // return json state list if present Message::echoJsonSuccess(array('message' => $states)); exit; } // CRM Order if ($this->wsType == 'x1') { // EXISTING CUSTOMER CHECK if (!$this->newCustomer) { $this->customer = Customer::model()->fillFromDbPk($this->post['customer_id']); $this->shippingAddress = Address::model()->fillFromDbPk($this->post['address_id']); $this->billingAddress = Address::model()->fillFromDbPk($this->post['billing_address_id']); } // if customer already built then check for blacklist $this->buildCustomer(); // EXISTING ORDER Check - DON'T NEED THIS I THINK $this->order = new Order(); /*if (!$this->newCustomer && $this->order->fillFromDbPk($this->customer->getCustomerOkOrder($this->campaign->campaign_id))) $this->apiError('An "OK" order already exists for this customer. Order ID ' . $this->order->order_id);*/ // addresses if (!isset($this->shippingAddress) || !$this->shippingAddress->getPkvalue()) { $this->buildAddress(); if ($this->post['billingSameAsShipping']) { $this->billingAddress = $this->shippingAddress; } else { $this->buildAddress('billing'); } } // payment before order. if no payment specified allow order to still be built if ($this->isPayment && isset($this->post['payment_id']) && $this->post['payment_id']) { $this->payment = Payment::model()->fillFromDbPk($this->post['payment_id']); } if ($this->isPayment) { $this->buildPayment(); } // order $this->buildOrder(); // pay or return if ($this->isPayment) { $this->webPayment(); } else { $this->order->status = 'ok'; $this->order->addFlags('paid'); // this needs to be set in order to have the order get sent to fulfillment $this->order->amount_product = '0.00'; $this->order->amount_shipping = '0.00'; $this->order->save(); } $this->apiSuccess('Order ' . $this->order->order_id . ' created'); } // Build prospect, click and customer info if (in_array($this->wsType, array('p', 'l'))) { $this->customer = new Customer(); $this->order = new Order(); $this->prospect = new Prospect(); // EXISTING ORDER/CUSTOMER CHECK - make sure there isn't already an order for this campaign and email if ($this->customer->getCustomerByEmail($this->post['email']) && $this->customer->getCustomerOkOrder($this->campaign->campaign_id) && $this->order->fillFromDbPk($this->customer->getCustomerOkOrder($this->campaign->campaign_id))) { $this->thankYou(true); } // BlueSnap Pending Order Check // Has an order already been submitted to the gateway and is pending final approval? If so, redirect to the thankyou page if (isset($this->customer->customer_id) && $this->order->orderPendingAttemptExists($this->campaign->campaign_id, $this->customer->customer_id)) { $this->thankYou(true); } // Existing Prospect check if customer already exists. If no prospect, build click if ($this->customer->getPkValue()) { if (!$this->prospect->prospectExists($this->customer->customer_id, $this->campaign->campaign_id)) { $this->buildClick(); } else { //prospect already exists. let's update the updated column $this->prospect->created = 'NOW():sql'; //date("Y-m-d H:i:s"); $this->prospect->save(); // check the click info. if its new then we need to double check it all $this->buildClick($this->prospect->click_id); } } else { $this->buildClick(); } $this->buildCustomer(); $this->buildAddress(); $this->buildProspect(); // if this is not a lastchance request, then redirect the user to the order page if ($this->wsType != 'l') { // build return object. SET TO HTTPS WHEN TESTING IS COMPLETE $url = $this->campaign->order_url . '?tempOrderId=' . $this->prospect->getPkValue(); $this->apiSuccess($url); } } // Build Order if (in_array($this->wsType, array('o', 'l'))) { if ($this->wsType == 'o') { // load objects $this->prospect = new Prospect(); if (!$this->prospect->fillFromDbPk($this->post['tempOrderId'])) { $this->apiError('Error:12 - This temporary transaction is invalid'); } $this->shippingAddress = new Address(); if (!$this->shippingAddress->fillFromDbPk($this->prospect->address_id)) { $this->apiError('Error:12 - This temporary transaction is invalid'); } $this->customer = new Customer(); if (!$this->customer->fillFromDbPk($this->prospect->customer_id)) { $this->apiError('Error:12 - This temporary transaction is invalid'); } } $this->buildOrder(); } // Upsell if (in_array($this->wsType, array('u'))) { // load objects $this->order = new Order(); if (!$this->order->fillFromDbPk($this->post['tempOrderId'])) { $this->apiError('Error:12 - This transaction is invalid'); } // already processed? if so send to TY page, unless there's been a decline/error if (!in_array($this->order->status, array('new', 'error'))) { $this->thankYou(true); } // check for test order if ($this->order->isFlag('test')) { $this->setTest(); } $this->upsellProcess(); } // 1Click if (in_array($this->wsType, array('c'))) { // add some time to the request to give the payment gateway rest time sleep(2); $this->customer = new Customer(); $existingOrder = new Order(); // EXISTING ORDER/CUSTOMER CHECK - make sure there isn't already an order for this campaign and email if ($this->customer->getCustomerByEmail($this->order->customer->email) && $this->customer->getCustomerOkOrder($this->campaign->campaign_id) && $existingOrder->fillFromDbPk($this->order->customer->getCustomerOkOrder($this->campaign->campaign_id))) { $this->thankYou(); } // BlueSnap Pending Order Check // Has an order already been submitted to the gateway and is pending final approval? If so, redirect to the thankyou page if ($this->order->orderPendingAttemptExists($this->campaign->campaign_id, $this->order->customer->customer_id)) { $this->thankYou(true); } // load/build objects $this->buildClick(); // order already built in isValid() $this->customer = Customer::model()->fillFromDbPk($this->order->customer_id); $this->payment = Payment::model()->fillFromDbPk($this->order->payment_id); $this->shippingAddress = Address::model()->fillFromDbPk($this->order->address_id); $this->billingAddress = Address::model()->fillFromDbPk($this->order->billing_address_id); $this->post['ps'] = $this->order->gateway->system_code; $this->buildOrder(); } }
function getCustomersAction() { $this->checkLogin(); $searchText = AF::get($_POST, 'search_text', false); $customerID = AF::get($_POST, 'customer_id', false); if ($searchText) { $customers = $searchText ? Customers::searchByEmail($searchText) : array(); Message::echoJsonSuccess(array('data' => $customers)); } elseif ($customerID) { $customerModel = Customer::model()->findByPk($customerID); $addressModel = Address::model()->findByCustomerId($customerModel); } die; }
function deleteAction() { $id = AF::get($_POST, 'id', 0); $modelsID = explode(',', $id); $errors = FALSE; foreach ($modelsID as $id) { $model = new Order(); if ($model->fillFromDbPk($id)) { $orderDeleteModel = new OrderDelete(); $orderDeleteModel->fillFromArray($model->getAttributes()); if ($orderDeleteModel->save()) { if (!$model->delete()) { $errors = true; } } else { $errors = true; } OrderLog::createLog($this->user->user_id, $id, 25); } else { $errors = TRUE; } if ($model->getErrors()) { $errors = TRUE; } unset($model); } if (isset($_POST['ajax'])) { AF::setJsonHeaders('json'); if ($errors) { Message::echoJsonError(__('order_no_deleted')); } else { Message::echoJsonSuccess(__('order_deleted')); } } }
function deleteAction() { $id = AF::get($_POST, 'id', 0); $modelsID = explode(',', $id); $errors = FALSE; foreach ($modelsID as $id) { $model = new Domain(); //$model->model_uset_id = $this->user->user_id; if ($model->findByPk($id)) { // if beforeDelete() returns an error, indicate this to the user if (!$model->delete($id)) { $errors = TRUE; } } else { $errors = TRUE; } if ($model->getErrors()) { $errors = TRUE; } unset($model); } if (isset($_POST['ajax'])) { AF::setJsonHeaders('json'); if ($errors) { Message::echoJsonError(__('domain_not_deleted')); } else { Message::echoJsonSuccess(__('domain_deleted')); } } $this->redirect(); }
function connectionAction() { $smtpModel = new Smtp(); if (isset($_POST['ajax'])) { $_POST['smtp_password'] = str_replace(' ', '+', $_POST['smtp_password']); $smtpModel->fillFromArray($_POST); if ($smtpModel->testConnection()) { Message::echoJsonSuccess(__('smtp_test_connection_ok')); } else { Message::echoJsonError(__('smtp_test_connection_error')); } } }
function deleteAction() { $id = AF::get($_POST, 'id', 0); $modelsID = explode(',', $id); $errors = FALSE; foreach ($modelsID as $id) { $model = new Profile(); $model->model_uset_id = $this->user->user_id; if ($model->findByPk($id)) { $model->delete($id); } else { $errors = TRUE; } if ($model->getErrors()) { $errors = TRUE; } unset($model); } if (isset($_POST['ajax'])) { AF::setJsonHeaders('json'); if ($errors) { Message::echoJsonError(__('profile_not_deleted')); } else { $countE = AF::get($_POST, 'countE', 100000); if (count($modelsID) >= $countE) { $link = AF::link(array('profiles' => 'view')); Message::echoJsonRedirect($link); } else { Message::echoJsonSuccess(__('profile_deleted')); } } } $this->redirect(); }
function deleteAction() { if (isset($this->params['all_method']) && $this->params['all_method']) { $campaignID = $this->params['campaign_id']; $methodID = $this->params['method_id']; if ($campaignID && $methodID) { Pixelrate::removeAllByCM($campaignID, $methodID); $this->redirect(); } } $id = AF::get($_POST, 'id', 0); $modelsID = explode(',', $id); $errors = FALSE; $link = FALSE; foreach ($modelsID as $id) { $model = new Pixelrate(); $model->model_uset_id = $this->user->user_id; if ($model->fillFromDbPk($id)) { $model->delete($id); } else { $errors = TRUE; } if ($model->getErrors()) { $errors = TRUE; } if (!$model->aff_id) { $link = AF::link(array('pixelrates' => 'campaign'), array('campaign_id' => $model->campaign_id)); } unset($model); } if (isset($_POST['ajax'])) { AF::setJsonHeaders('json'); if ($errors) { Message::echoJsonError(__('pixelrate_not_deleted')); } else { if (!$link) { Message::echoJsonSuccess(__('pixelrate_deleted')); } else { Message::echoJsonRedirect($link); } } } $this->redirect(); }
function deleteAction() { $id = AF::get($_POST, 'id', 0); $modelsID = explode(',', $id); $errors = FALSE; foreach ($modelsID as $id) { $model = new Tax(); $model->model_uset_id = $this->user->user_id; if ($model->fillFromDbPk($id)) { $model->delete($id); } else { $errors = TRUE; } if ($model->getErrors()) { $errors = TRUE; } unset($model); } if (isset($_POST['ajax'])) { AF::setJsonHeaders('json'); if ($errors) { Message::echoJsonError(__('tax_not_deleted')); } else { $countE = AF::get($_POST, 'countE', 100000); // if the delete request came from an update page, we need to redirect if (count($modelsID) >= $countE || stripos($_SERVER['HTTP_REFERER'], 'taxes/update') !== false) { $link = AF::link(array('taxes' => 'view')); Message::echoJsonRedirect($link); } else { Message::echoJsonSuccess(__('tax_deleted')); } } } $this->redirect('view'); //$this->redirect(); }
/** * Update customer */ function updateAction() { $model = new Customer(); $id = AF::get($this->params, 'id', FALSE); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['ajax'])) { $customer_id = AF::get($_POST, 'customer_id', false); $flags = AF::get($_POST, 'flags', false); unset($_POST['flags']); if (!$flags) { $flags = array(); } $model->fillFromArray($_POST, FALSE); $model->removeFlags($model->_flagFields['flags']); $model->addFlags($flags); $model->user_id_updated = $this->user->user_id; $model->updated = 'NOW():sql'; if ($model->save()) { Message::echoJsonSuccess(__('customer_updated')); } else { Message::echoJsonError(__('customer_no_updated')); } die; } if (!$id) { throw new AFHttpException(0, 'no_id'); } if (!$model->findByPk($id)) { throw new AFHttpException(0, 'incorrect_id'); } Assets::js('jquery.form'); /* I don't think I need this now $shippingAddress=new Address(); $shippingAddress->fillFromDbPk($model->address_id); $billingAddress=new Address(); $billingAddress->fillFromDbPk($model->billing_address_id); $countryModel = new Country(); $countries = $countryModel->getCountries(); $shippingStates=($shippingAddress->country_id)?$countryModel->getStatesByCID($shippingAddress->country_id):array(); $billingStates=($billingAddress->country_id)?$countryModel->getStatesByCID($billingAddress->country_id):array(); */ $this->addToPageTitle('Update customer'); $this->render('update', array('model' => $model)); }