public function createAction() { $model = new Field(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['model']) && $_POST['model'] == 'Field') { if (isset($_POST['ajax'])) { $model->fillFromArray($_POST); if ($model->save()) { $link = AF::link(array('fields' => 'update'), array('id' => $model->PkValue)); Message::echoJson('success', array('redirect' => $link)); } else { Message::echoJsonError(__('field_not_created')); } die; } $model->save(); $this->redirect(); die; } $fieldCode = AF::get($this->params, 'field_code', false); /* if(!$fieldCode) throw new AFHttpException(0, 'no_field_code'); */ $model->field_code = $fieldCode; Assets::js('jquery.form'); $this->addToPageTitle('Create field'); $this->render('create', array('model' => $model, 'fieldCode' => $fieldCode)); }
public function createAction() { if (isset($_POST['ajax']) && isset($_POST['getshipping'])) { $shippings = Shipping::model()->cache()->findAllInArray(); AF::setJsonHeaders('json'); Message::echoJsonSuccess(array('message' => $shippings)); } $model = new CampaignShipping(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['model']) && $_POST['model'] == 'Campship') { $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 (isset($_POST['ajax'])) { if ($model->save()) { $link = AF::link(array('campship' => 'view'), array('campaign_id' => $model->campaign_id)); Message::echoJson('success', array('redirect' => $link)); } else { Message::echoJsonError(__('campship_not_created') . ' ' . $model->errors2string); } die; } $model->save(); $this->redirect(); } $this->addToPageTitle('Create Campaign Shipping'); $this->render('create', array('model' => $model)); }
public function createAction() { if (isset($_POST['ajax']) && isset($_POST['getattached'])) { $campaign_id = AF::get($_POST, 'campaign_id', 0); $attached = Campaigns::getAvailableCampaignAttachByCamp($campaign_id); AF::setJsonHeaders('json'); Message::echoJsonSuccess(array('message' => $attached)); } $model = new CampaignAttach(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['model']) && $_POST['model'] == 'Campattach') { $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 (isset($_POST['ajax'])) { if ($model->save()) { $link = AF::link(array('campattach' => 'view'), array('campaign_id' => $model->campaign_id)); Message::echoJson('success', array('redirect' => $link)); } else { Message::echoJsonError(__('campattach_not_created') . ' ' . $model->errors2string); } die; } $model->save(); $this->redirect(); } $this->addToPageTitle('Create Campaign Attachment'); $this->render('create', array('model' => $model)); }
public function createAction() { $model = new Gateway(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['model']) && $_POST['model'] == 'Gateway') { if (isset($_POST['ajax'])) { $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()) { $link = AF::link(array('gateways' => 'update'), array('id' => $model->PkValue)); Message::echoJson('success', array('redirect' => $link)); } else { Message::echoJsonError(__('gateway_not_created')); } die; } $model->save(); $this->redirect(); die; } $currencies = Currency::model()->cache()->findAllInArray(); $systems = PSystem::model()->cache()->findAllInArray(); $gateways = Gateway::model()->cache()->findAllInArray(); Assets::js('jquery.form'); $this->addToPageTitle('Create Gateway'); $this->render('create', array('model' => $model, 'currencies' => $currencies, 'systems' => $systems, 'gateways' => $gateways)); }
public function createAction() { if (isset($_POST['ajax']) && isset($_POST['getgateways'])) { $gatewayModel = new Gateway(); $gateways = $gatewayModel->getGateways(); AF::setJsonHeaders('json'); Message::echoJsonSuccess(array('message' => $gateways)); } $model = new CampaignGateway(); $this->performAjaxValidation($model); if (isset($_POST['model']) && $_POST['model'] == 'Campgate') { $model->fillFromArray($_POST); if (isset($_POST['ajax'])) { if ($model->addGatewayById()) { $link = AF::link(array('campgate' => 'view'), array('campaign_id' => $model->campaign_id)); Message::echoJson('success', array('redirect' => $link)); } else { Message::echoJsonError(__('campgate_not_created') . ' ' . $model->errors2string); } die; } $model->addGatewayById(); $this->redirect(); } $this->addToPageTitle('Create Campaign Gateway'); $this->render('create', array('model' => $model)); }
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)); }
public function createAction() { $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); $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()) { $link = AF::link(array('shipcats' => 'update'), array('id' => $model->PkValue)); Message::echoJson('success', array('redirect' => $link)); } else { Message::echoJsonError(__('shipcat_not_created')); } die; } $model->save(); $this->redirect(); die; } Assets::js('jquery.form'); $this->addToPageTitle('Create shipcat'); $this->render('create', array('model' => $model)); }
public function createAction() { $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); $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()) { $link = AF::link(array('events' => 'update'), array('id' => $model->PkValue)); Message::echoJson('success', array('redirect' => $link)); } else { Message::echoJsonError(__('events_not_created') . ' ' . $model->errors2string); } die; } $model->save(); $this->redirect(); die; } $templates = Template::model()->cache()->findAllInArray(); $smtps = Smtp::model()->cache()->findAllInArray(); Assets::js('jquery.form'); $this->addToPageTitle('Create event'); $this->render('create', array('model' => $model, 'smtps' => $smtps, 'templates' => $templates)); }
public function createAction() { $model = new Tax(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['model']) && $_POST['model'] == 'Tax') { $model->fillFromArray($_POST); if (isset($_POST['defaultCountryCheck']) && $_POST['defaultCountryCheck']) { $model->state_code = null; } $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 (isset($_POST['ajax'])) { if ($model->save()) { $link = AF::link(array('taxes' => 'view'), array('country_id' => $_POST['country_id'])); Message::echoJson('success', array('redirect' => $link)); } else { Message::echoJsonError(__('taxes_not_created') . '. ' . __('tax_record_exists')); } die; } else { if (!$model->save()) { } else { $this->redirect('view/country_id=' . $_POST['country_id']); } } die; } $stateCode = AF::get($this->params, 'state_code', null); $countryID = AF::get($this->params, 'country_id', null); $stateModel = new State(); if ($stateCode && !$countryID) { $stateModel->fillFromStateCode($stateCode); $countryID = $stateModel->country_id; $this->params['country_id'] = $countryID; } $countries = Country::model()->cache()->findAllInArray(); $states = State::model()->getStates($countryID); //$countryDefault = Taxs::getCountryDefault($countryID); Assets::js('jquery.form'); $this->addToPageTitle('Create Tax record'); $this->render('create', array('model' => $model, 'states' => $states, 'countries' => $countries)); }
public function createAction() { $model = new Campaign(); if (isset($_POST['country_id'])) { $_POST['country_id'] = implode(',', $_POST['country_id']); } // check if this is an attachment campaign. if so, we don't want to validate the urls or fulfillment_id if it isnot presesnt $attach = false; if (isset($_POST['attach']) && $_POST['attach']) { $attach = true; $_POST['url'] = $_POST['order_url'] = $_POST['return_url'] = 'attach'; if (!strlen($_POST['fulfillment_id'])) { $_POST['fulfillment_id'] = 0; } } // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['model']) && $_POST['model'] == 'campaigns') { $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()) { $link = AF::link(array('campaigns' => 'update'), array('id' => $model->PkValue)); Message::echoJson('success', array('redirect' => $link)); } else { Message::echoJsonError('Campaign wasn\'t created.'); } die; } $countries = Country::model()->cache()->findAllInArray(); $profiles = Profile::model()->cache()->findAllInArray(); // prepend dry run gateway array_unshift($profiles, array('profile_id' => 0, 'profile_name' => 'DRY RUN GATEWAY')); $fulfillments = Fulfillment::model()->cache()->findAllInArray(); $currencies = Currency::model()->cache()->findAllInArray(); Assets::js('jquery.form'); $this->addToPageTitle('Create campaign'); $this->render('create', array('model' => $model, 'countries' => $countries, 'currencies' => $currencies, 'profiles' => $profiles, 'fulfillments' => $fulfillments)); }
public function createAction() { $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); //$model->model_uset_id = $this->user->user_id; if ($model->save()) { $link = AF::link(array('domains' => 'view')); Message::echoJson('success', array('redirect' => $link)); } else { Message::echoJsonError(__('domain_not_created')); } die; } Assets::js('jquery.form'); $this->addToPageTitle(__('create_domain')); $this->render('create', array('model' => $model)); }
public function createAction() { $model = new GatewayLimit(); if (isset($_POST['model'])) { // Add gatewaylimit to gateway if ($_POST['model'] == 'gateway_limit') { $this->performAjaxValidation($model); // Uncomment the line if AJAX validation is needed if (!empty($_POST['limit_id'])) { $model->setIsNewRecord(FALSE); } $model->fillFromArray($_POST, TRUE); if ($model->save()) { $link = AF::link(array('gateways' => 'update'), array('id' => $model->gateway_id)); Message::echoJson('success', array('redirect' => $link)); } else { Message::echoJsonError(__('gateway_limit_not_created') . ' ' . $model->errors2string); } } } }
public function createAction() { if (isset($_POST['ajax']) && isset($_POST['getcampaigns'])) { $campaignID = AF::get($_POST, 'campaign_id'); $campaignModel = new Campaign(); $campaigns = $campaignModel->getComboCampaigns($campaignID); AF::setJsonHeaders('json'); Message::echoJsonSuccess(array('message' => $campaigns)); } $model = new CCombo(); // Uncomment the following line if AJAX validation is needed //$this->performAjaxValidation($model); if (isset($_POST['model']) && $_POST['model'] == 'CCombo') { $comboCampaignID = AF::get($_POST, 'combo_campaign_id'); $campaignID = AF::get($_POST, 'campaign_id'); if (!$comboCampaignID or !$campaignID) { Message::echoJsonError(__('combo_empty_campaign_id')); } $model->campaign1_id = min($comboCampaignID, $campaignID); $model->campaign2_id = max($comboCampaignID, $campaignID); //$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 (isset($_POST['ajax'])) { if ($model->save()) { $link = AF::link(array('ccombo' => 'view'), array('campaign_id' => $campaignID)); Message::echoJson('success', array('redirect' => $link)); } else { Message::echoJsonError(__('ccombo_not_created') . ' ' . $model->errors2string); } die; } $model->save(); $this->redirect(); } $this->addToPageTitle('Create Campaign Shipping'); $this->render('create', array('model' => $model)); }
public function createAction() { $model = new Pixelrate(); if (isset($_POST['get_peyment_method'])) { AF::setJsonHeaders('json'); $paymentType = AF::get($_POST, 'payment_type', 0); $paymentMethods = Payments::methods($paymentType); if ($paymentMethods) { Message::echoJsonSuccess(array('message' => $paymentMethods)); } else { Message::echoJsonError(__('incorrect_payment_type')); } } $this->performAjaxValidation($model); // Uncomment the following line if AJAX validation is needed if (isset($_POST['model']) && $_POST['model'] == 'pixelrates') { if (!isset($_POST['default'])) { if (!isset($_POST['aff_id']) || empty($_POST['aff_id'])) { Message::echoJson('error', array('errors' => array('aff_id' => 'No empty'))); } } $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(__('pixelrate_not_created') . ' ' . $model->errors2string); } die; } $this->addToPageTitle('Create pixel rates'); $this->render('create', array('model' => $model)); }
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 createAction() { $model = new User(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['model']) && $_POST['model'] == 'users') { $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()) { $link = AF::link(array('users' => 'update'), array('id' => $model->PkValue)); Message::echoJson('success', array('redirect' => $link)); } else { Message::echoJsonError('User wasn\'t created.'); } die; } $roles = Role::model()->cache()->findAllInArray(); Assets::js('jquery.form'); $this->addToPageTitle('Create user'); $this->render('create', array('model' => $model, 'roles' => $roles)); }
function ajaxAction() { if (!isset($_POST['ajax'])) { throw new AFHttpException(404, 'page_not_found'); } if ($this->access->actionAccess('update')) { /* DEPRECATED BECAUSE ITS UPDATED ON SPECIFIC PAGES if(isset($_POST['update_customer_information'])) { if(isset($_POST['CustomerModel'])) { $customerModel=new Customer(); $customerModel->fillFromArray($_POST['CustomerModel'], false); $customerModel->model_uset_id = $this->user->user_id; $customerModel->save(false); } if(isset($_POST['ShippingAddress'])) { $sAddressModel=new Address(); $sAddressModel->fillFromArray($_POST['ShippingAddress'], false); $sAddressModel->model_uset_id = $this->user->user_id; $sAddressModel->save(false); } if(isset($_POST['BillingAddress']) && $_POST['ShippingAddress']['address_id']!=$_POST['BillingAddress']['address_id']) { $bAddressModel=new Address(); $bAddressModel->fillFromArray($_POST['BillingAddress'], false); $bAddressModel->model_uset_id = $this->user->user_id; $bAddressModel->save(false); } OrderLog::createLog($this->user->user_id, $_POST['order_id'], 2); Message::echoJsonSuccess(__('customer_information_updated')); } */ if (isset($_POST['order_set_chargeback_amount'])) { $orderID = (int) AF::get($_POST, 'order_id', 0); $amount = AF::get($_POST, 'amount', 0); $type = (int) AF::get($_POST, 'type', 0); $modelOrder = Order::model()->findByPk($orderID); $new_amount = $modelOrder->chargeBackSet($amount, $type, $this->user->user_id); if ($new_amount) { Message::echoJsonSuccess(array('answer' => __('order_chargeback_amount_updated'), 'new_amount' => $new_amount)); } else { $msg = $amount > $modelOrder->maxAmountChargeback ? __('order_chargeback_amount_exceeded') : __('order_chargeback_amount_no_updated'); Message::echoJsonError($msg); } die; /*// we need to make sure the chargeback flag is set. if not, set flag and log it if(!$modelOrder->isFlag('chargeback')) { $modelOrder->addFlags('chargeback'); $modelOrder->save(false); $orderProducts=OrderProducts::getProductsByOrderID($orderID); foreach($orderProducts as $orderProduct) { $orderProduct->removeFlags('recurring'); $orderProduct->save(); } OrderLog::createLog($this->user->user_id, $orderID, 11, 'chargeback'); } if( $modelOrder && in_array($type, array(29, 30)) && $amount <= $modelOrder->maxAmountChargeback && $orderID) { $notes = ($amount) ? $amount : null; OrderLog::createLog($this->user->user_id, $orderID, $type, $notes, $amount); Message::echoJsonSuccess(array('answer'=>__('order_chargeback_amount_updated'), 'new_amount'=>$modelOrder->maxAmountChargeback)); } else { $msg = ($amount > $modelOrder->maxAmountChargeback) ? __('order_chargeback_amount_exceeded') :__('order_chargeback_amount_no_updated') ; Message::echoJsonError($msg); } die;*/ } if (isset($_POST['rma_code'])) { $orderModel = new Order(); $orderModel->order_id = (int) AF::get($_POST, 'order_id', 0); $orderModel->rma_code = (int) AF::get($_POST, 'rma_code', 0); $orderModel->setRMA($this->user->user_id); Message::echoJsonSuccess($orderModel->rma_number); die; } if (isset($_POST['order_refund']) && $this->access->actionAccess('order_refund')) { $orderID = AF::get($_POST, 'order_id'); $amountRefunded = AF::get($_POST, 'amount_refunded', 0); $model = Order::model()->findByPk($orderID); $model->refunded($amountRefunded); if (!$model->errors) { $paymentAPI = new PaymentAPI(); $response = $paymentAPI->refundOrder($model, $amountRefunded); if ($response->status == 'success') { if ($amountRefunded == $model->max_refund) { $op = OrderProduct::model(); //new OrderProducts('OrderProduct'); $op->cancelRecurring($model->order_id); unset($op); $model->status = 'void'; } $model->amount_refunded = number_format($amountRefunded + $model->amount_refunded, 2); $model->payment_total = number_format($model->payment_total - $amountRefunded, 2); if (!$model->save()) { fb($model->getErrors()); } OrderLog::createLog($this->user->user_id, $model->order_id, 13, $amountRefunded); Event::setEvents($model->order_id, 7); Message::echoJsonSuccess(__('order_is_refunded')); } else { Message::echoJsonError(__('order_not_refunded') . ' ' . $response->alerts2string . ' ' . $response->errors2string); } } else { Message::echoJson('error', array('errors' => $model->errors, 'message' => $model->errors2string)); } } if (isset($_POST['order_void']) && $this->access->actionAccess('order_refund')) { $orderLogsModel = new OrderLog(); $orderLogsModel->user_id = $this->user->user_id; $orderLogsModel->action = 3; if (!$orderLogsModel->canVoid()) { Message::echoJsonSuccess(__('you_cant_do_void')); } $orderID = AF::get($_POST, 'order_id'); $model = Order::model()->findByPk($orderID); if ($model->status == 'void') { Message::echoJsonSuccess(__('order_is_voided')); } $paymentAPI = new PaymentAPI(); $response = $paymentAPI->voidOrder($model); if ($response->status == 'success') { // unset recurring products $orderProducts = new OrderProducts('OrderProduct'); $orderProducts->cancelRecurring($model->order_id); unset($orderProducts); $model->status = 'void'; $model->amount_refunded = $model->payment_total; $model->payment_total = '0'; $model->save(); OrderLog::createLog($this->user->user_id, $model->order_id, 3, __('success') . ' ' . $model->amount_refunded); Event::setEvents($this->order->order_id, 6); Message::echoJsonSuccess(__('order_is_voided')); } else { OrderLog::createLog($this->user->user_id, $model->order_id, 3, __('failed') . ' ' . $model->max_refund); Message::echoJsonError(__('order_not_void') . ' ' . $response->alerts2string . ' ' . $response->errors2string); } } if (isset($_POST['rebill_now']) && $this->access->actionAccess('order_rebill_now')) { $orderID = AF::get($_POST, 'order_id'); $productID = AF::get($_POST, 'product_id'); if (!$orderID || !$productID) { Message::echoJsonSuccess(__('invalid_request')); } $newOrderID = Order::rebillNow($orderID, $productID); if ($newOrderID) { $orderModel = Order::model()->findByPk($newOrderID); $paymentAPI = new PaymentAPI(); $response = $paymentAPI->payOrder($orderModel, $orderModel->amount); if ($response->status == 'success') { $orderModel->status = 'ok'; $orderModel->removeFlags('pay'); $orderModel->addFlags('paid'); $orderModel->payment_total = $response->attemptModel->amount; $orderModel->save(); //update recurring_next $msql = SafeMySQL::getInstance(); $sql = "UPDATE `orders_products`\n JOIN `products` USING(`product_id`)\n SET `orders_products`.`recurring_next` = DATE_ADD(NOW(), INTERVAL `products`.`subscription_days` DAY)\n WHERE FIND_IN_SET('recurring', `orders_products`.`flags`)>0\n AND `orders_products`.`order_id`=?i"; $msql->query($sql, $orderModel->order_id); // log action on parent order for visibility OrderLog::createLog($this->user->user_id, $orderID, 27, __('success') . ' ' . $orderModel->payment_total . ' - Child Order ' . $orderID); OrderLog::createLog($this->user->user_id, $orderModel->order_id, 27, __('success') . ' ' . $orderModel->payment_total); Event::setEvents($orderModel->order_id, 6); Message::echoJsonSuccess(__('order_is_rebill')); } else { $orderModel->status = 'error'; //delete the pay flag $orderModel->removeFlags('pay'); if ($orderModel->billing_cycle > 0) { $orderModel->addFlags('retry'); } $orderModel->save(); // log failed attempt on parent order OrderLog::createLog($this->user->user_id, $orderID, 27, __('failed') . ' ' . $orderModel->amount . ' - Child Order ' . $orderID); OrderLog::createLog($this->user->user_id, $orderModel->order_id, 27, __('failed') . ' ' . $orderModel->amount); Message::echoJsonError(__('order_not_rebill') . ' ' . $response->alerts2string . ' ' . $response->errors2string); } } else { Message::echoJsonSuccess(__('order_rebill_now_error')); } //$orderLogsModel=new OrderLog(); //$orderLogsModel->user_id=$this->user->user_id; //$orderLogsModel->action=27; /* $orderLogsModel=new OrderLog(); $orderLogsModel->user_id=$this->user->user_id; $orderLogsModel->action=3; if(!$orderLogsModel->canVoid()) Message::echoJsonSuccess(__('you_cant_do_void')); $orderID = AF::get($_POST, 'order_id'); $model=Order::model()->findByPk($orderID); if($model->status=='void') Message::echoJsonSuccess(__('order_is_voided')); $paymentAPI=new PaymentAPI(); $response=$paymentAPI->voidOrder($model); if($response->status=='success') { // unset recurring products $orderProducts = new OrderProducts('OrderProduct'); $orderProducts->cancelRecurring($model->order_id); unset($orderProducts); $model->status = 'void'; $model->amount_refunded = $response->attemptModel->amount; $model->save(); OrderLog::createLog($this->user->user_id, $model->order_id, 3, __('success').' '.$model->amount_refunded); Event::setEvents($this->order->order_id, 6); Message::echoJsonSuccess(__('order_is_voided')); } else { OrderLog::createLog($this->user->user_id, $model->order_id, 3, __('failed').' '.$model->max_refund); Message::echoJsonError(__('order_not_void').' '.$response->alerts2string.' '.$response->errors2string); } */ } } die; }
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(); }