コード例 #1
0
 function deleteAction()
 {
     $id = AF::get($_POST, 'id', 0);
     $modelsID = explode(',', $id);
     $errors = FALSE;
     foreach ($modelsID as $id) {
         $model = new Address();
         $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(__('address_not_deleted'));
         } else {
             Message::echoJsonSuccess(__('address_deleted'));
         }
     }
     $this->redirect();
 }
コード例 #2
0
 public function ordersAction()
 {
     $from = AF::get($this->params, 'from', false);
     $clearArray = array();
     $this->filter($clearArray);
     if (!isset($this->params['r_dates'])) {
         $today = date("d.m.Y");
         $this->params['r_dates'] = $today . '-' . $today;
     }
     $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true));
     $models = AFActiveDataProvider::models('Attempt', $this->params, $pagination);
     $dataProvider = $models->getDeclineOrdersReport();
     $filterFields = Attempt::$FilterFields = $models->getoutFilterFields($clearArray, array('r_dates'));
     $fields = array('order_formatted', 'type_formatted', 'status_note', 'created_formatted');
     $gateways = $models->getDSearchGateways();
     $reasons = $models->getDSearchReasons();
     // set ajax table
     if (AF::isAjaxRequestModels()) {
         $this->view->includeFile('_orders_table', array('application', 'views', 'declinedreports'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields, 'fields' => $fields, 'gateways' => $gateways, 'reasons' => $reasons));
         die;
     }
     Assets::css('jquery-ui');
     Assets::js('//code.jquery.com/ui/1.10.3/jquery-ui.js');
     Assets::js('dateRange/jquery.daterange');
     Assets::js('ajax_table');
     $this->render('orders', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields, 'fields' => $fields, 'gateways' => $gateways, 'reasons' => $reasons, 'from' => $from));
 }
コード例 #3
0
 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());
 }
コード例 #4
0
 function __construct()
 {
     $this->params = func_get_args();
     $this->createUrl();
     $this->pageCount = ceil($this->params[1] / $this->itemsPerPage);
     $this->currentPage = AF::get($this->params[0], 'page', 1);
 }
コード例 #5
0
 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();
 }
コード例 #6
0
 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();
 }
コード例 #7
0
 function generalAction()
 {
     if (isset($_POST['model']) && ($_POST['model'] = 'User')) {
         $this->user->name = AF::get($_POST, 'name');
         $this->user->password = AF::get($_POST, 'password');
         $this->user->settings;
         if ($this->user->save(false)) {
             Message::echoJsonSuccess(__('user_settings_updated'));
         } else {
             Message::echoJsonError(__('user_settings_not_updated'));
         }
     }
     $this->addToPageTitle(__('general') . ' ' . __('settings'));
     Assets::js('jquery.form');
     $this->render('general', array());
 }
コード例 #8
0
 /**
  * Show the customers orders with address for each order in case they use different addresses.
  */
 function openAction()
 {
     $customer_id = AF::get($this->params, 'customer_id', false);
     // Get the $_GET['customer_id']
     if (!$customer_id) {
         throw new AFHttpException(0, 'no_customer_id');
     }
     // uses en.php to get string
     $this->filter();
     $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params));
     $models = AFActiveDataProvider::models('Customer', $this->params, $pagination);
     $dataProvider = $models->getOrdersByCustomerId($customer_id);
     $orderModel = new Order();
     $labels = $orderModel->attributeLabels();
     $this->addToPageTitle('View Client');
     $this->render('open', array('lables' => $labels, 'pagination' => $pagination, 'dataProvider' => $dataProvider, 'countOrders' => count($dataProvider), 'email' => $dataProvider[0]->email));
 }
コード例 #9
0
 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;
 }
コード例 #10
0
 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'));
         }
     }
 }
コード例 #11
0
 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();
 }
コード例 #12
0
 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;
     }
 }
コード例 #13
0
 public function updateRecurringData()
 {
     $db = self::$_msql;
     $this->whereAndLimit();
     $whichOrders = AF::get($_POST, 'which_orders');
     $whichDate = AF::get($_POST, 'which_date');
     $gatewayID = AF::get($_POST, 'gateway_id');
     $ordersID = AF::get($_POST, 'orders_id');
     $set = '';
     $andWhere = '';
     if ($gatewayID) {
         $set = $db->parse('o.`gateway_id`=?i', (int) $gatewayID);
     } elseif ($whichDate) {
         if ($whichDate == Order::RECURRING_ORDERS_DATE) {
             $newRecurringDate = AF::get($_POST, 'new_r_date');
             $nRDA = array_reverse(explode('.', $newRecurringDate));
             $set = $db->parse('op.`recurring_next`=?s', implode('-', $nRDA));
         } elseif ($whichDate == Order::RECURRING_ORDERS_DAY) {
             $day = AF::get($_POST, 'different_days');
             $dateMinTemp = AF::get($_POST, 'new_r_date_from');
             $dateMaxTemp = AF::get($_POST, 'new_r_date_to');
             if ($dateMinTemp) {
                 $dateMinA = array_reverse(explode('.', $dateMinTemp));
                 $dateMin = implode('-', $dateMinA);
             } else {
                 $dateMin = '2000-01-01';
             }
             if ($dateMaxTemp) {
                 $dateMaxA = array_reverse(explode('.', $dateMaxTemp));
                 $dateMax = implode('-', $dateMaxA);
             } else {
                 $dateMax = '2100-01-01';
             }
             $set = $db->parse('op.`recurring_next`= if(DATE_ADD(op.`recurring_next`, INTERVAL ?i DAY)>?s,?s,   if(DATE_ADD(op.`recurring_next`, INTERVAL ?i DAY)<?s, ?s, DATE_ADD(op.`recurring_next`, INTERVAL ?i DAY)))', $day, $dateMax, $dateMax, $day, $dateMin, $dateMin, $day);
         }
     }
     if ($whichOrders == Order::RECURRING_ORDERS_SELECTED) {
         $changeOrdersArray = explode(',', $ordersID);
         $andWhere = $db->parse(' AND o.`order_id` IN(?a)', $changeOrdersArray);
     }
     $sql = "UPDATE `orders` as o\n\t\tJOIN `campaigns` as c USING (`campaign_id`)\n\t\tJOIN `customers` as cu USING (`customer_id`)\n\t\tJOIN `orders_products` as op USING (`order_id`)\n\t\tJOIN `products` as pr USING(`product_id`)\n\t\tLEFT JOIN `products` AS p2 on p2.`product_id` = pr.`product_next_id`\n\t\tLEFT JOIN `shipping` as sh ON sh.shipping_id = o.shipping_id\n\t\tLEFT JOIN `gateways` as g USING (`gateway_id`)\n\t\tLEFT JOIN `addresses` as ad USING (`address_id`)\n\t\tLEFT JOIN `systems` as s USING (`system_code`)\n\t\tLEFT JOIN `payments` as p USING (`payment_id`)\n\t\tLEFT JOIN `methods` as m USING (`method_id`)\n\t\t?p\n\t\tSET {$set}\n        WHERE ?p {$andWhere}";
     $db->query($sql, $this->join, $this->where);
 }
コード例 #14
0
 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();
 }
コード例 #15
0
<?php

include_once '../settings/autoload.php';
$msql = SafeMySQL::getInstance();
$orderID = AF::get($_GET, 'order_id');
$status = AF::get($_GET, 'status', 'inprogress');
// inprogress, submitted, unknown, new
if ($orderID) {
    Order::finalizeOrder($orderID);
    die;
}
while ($orderID = getOrderID()) {
    Order::finalizeOrder($orderID);
}
function getOrderID()
{
    global $msql, $status;
    try {
        // Open transaction
        $msql->query("START TRANSACTION");
        // Select attempt
        $sql = "SELECT `attempt_id`, `order_id`, `status`\n        FROM `attempts`\n        WHERE `status`=?s\n        AND `attempt_type` = 'debit'\n        AND `updated` < DATE_SUB(NOW(), INTERVAL 10 MINUTE)\n        LIMIT 1";
        $result = $msql->getRow($sql, $status);
        $attemptID = isset($result['attempt_id']) && $result['attempt_id'] ? $result['attempt_id'] : null;
        $orderID = isset($result['order_id']) && $result['order_id'] ? $result['order_id'] : null;
        // Update selected attempt
        if ($attemptID) {
            $sql = "UPDATE `attempts` SET `updated`=NOW() WHERE `attempt_id`=?i";
            $msql->query($sql, $attemptID);
        }
        // Close transaction
コード例 #16
0
<?php

@(include_once '../settings/autoload.php');
$campaignID = AF::get($_GET, 'campaign_id');
if (!$campaignID) {
    exit('Incorrect Campaign ID');
}
SiteApi::updateSites($campaignID);
echo 'done...';
コード例 #17
0
 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);
     }
 }
コード例 #18
0
 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();
 }
コード例 #19
0
 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();
 }
コード例 #20
0
 public function fulfillmentAction()
 {
     $clearArray = array('fulfillment_id', 'o_status');
     $this->filter($clearArray);
     if (!isset($this->params['r_dates'])) {
         $today = date("d.m.Y");
         $this->params['r_dates'] = $today . '-' . $today;
     }
     if (!isset($this->params['show_orders'])) {
         $this->params['show_orders'] = 0;
     }
     $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true));
     $showOrders = AF::get($this->params, 'show_orders') ? true : false;
     if ($showOrders && isset($this->params['from']) && in_array($this->params['from'], Fulfillment::orderSType())) {
         switch ($this->params['from']) {
             case 'shippable_orders':
                 $this->params['o_status'] = implode(',', array(Order::STATUS_OK, Order::STATUS_SENT));
                 $this->params['o_flag'] = Order::FlAG_PAID;
                 $this->params['o_not_flag'] = Order::FlAG_TEST;
                 break;
             case 'shippable_products':
                 $this->params['o_status'] = implode(',', array(Order::STATUS_OK, Order::STATUS_SENT));
                 $this->params['o_flag'] = Order::FlAG_PAID;
                 $this->params['o_not_flag'] = Order::FlAG_TEST;
                 break;
             case 'orders_pending_post':
                 $this->params['o_status'] = implode(',', array(Order::STATUS_OK));
                 $this->params['o_flag'] = Order::FlAG_PAID;
                 $this->params['o_not_flag'] = Order::FlAG_TEST;
                 break;
             case 'orders_sent_to_fulfillment':
                 $this->params['o_status'] = implode(',', array(Order::STATUS_SENT));
                 $this->params['o_flag'] = Order::FlAG_PAID;
                 $this->params['o_not_flag'] = Order::FlAG_TEST;
                 break;
             case 'orders_pending_tracking':
                 $this->params['o_status'] = implode(',', array(Order::STATUS_SENT, Order::STATUS_SHIPPED));
                 $this->params['o_flag'] = Order::FlAG_PAID;
                 $this->params['p_tracking_number'] = '';
                 $this->params['o_not_flag'] = Order::FlAG_TEST;
                 break;
             case 'shipped_orders':
                 $this->params['o_status'] = implode(',', array(Order::STATUS_SHIPPED));
                 $this->params['o_flag'] = Order::FlAG_PAID;
                 $this->params['o_not_flag'] = Order::FlAG_TEST;
                 break;
             case 'returned_orders':
                 $this->params['o_status'] = implode(',', array(Order::STATUS_RETURNED));
                 $this->params['o_not_flag'] = Order::FlAG_TEST;
                 break;
         }
     }
     $models = AFActiveDataProvider::models('Fulfillment', $this->params, $pagination);
     if ($showOrders) {
         $dataProvider = $models->getStatusReportByOrder();
         $total = null;
         $fields = array('order_id_link', 'created_formatted', 'shippable_products', 'return_reason_formatted', 'status');
     } else {
         $dataProvider = $models->getStatusReport();
         $total = $models->getTotalReport();
         $fields = array('fulfillment_formatted', 'shippable_orders_link', 'shippable_products_link', 'orders_pending_post_link', 'orders_sent_to_fulfillment_link', 'orders_pending_tracking_link', 'shipped_orders_link', 'returned_orders_link');
     }
     $filterFields = OrderLog::$FilterFields = $models->getoutFilterFields($clearArray, array('r_dates'));
     $fulfillments = $models->getReportFulfillments();
     // set ajax table
     if (AF::isAjaxRequestModels()) {
         $this->view->includeFile('_fulfillment_table', array('application', 'views', 'reports'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields, 'total' => $total[0], 'fields' => $fields, 'ajax' => true, 'fulfillments' => $fulfillments));
         die;
     }
     if (isset($this->params['download_csv'])) {
         $csvField = $fields;
         $changeArray = array('shippable_orders_link' => 'shippable_orders', 'shippable_products_link' => 'shippable_products', 'orders_pending_post_link' => 'orders_pending_post', 'orders_sent_to_fulfillment_link' => 'orders_sent_to_fulfillment', 'orders_pending_tracking_link' => 'orders_pending_tracking', 'shipped_orders_link' => 'shipped_orders', 'returned_orders_link' => 'returned_orders', 'order_id_link' => 'order_id', 'return_reason_formatted' => 'return_reason');
         foreach ($changeArray as $k => $v) {
             $key = array_search($k, $csvField);
             if ($key || $key === 0) {
                 $csvField[$key] = $v;
             }
         }
         Csv::printDataProviderCsv($dataProvider, $csvField, 'fulfillment_report');
     }
     Assets::css('jquery-ui');
     Assets::js('//code.jquery.com/ui/1.10.3/jquery-ui.js');
     Assets::js('dateRange/jquery.daterange');
     Assets::js('ajax_table');
     $this->render('fulfillment', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields, 'fields' => $fields, 'fulfillments' => $fulfillments, 'total' => $total[0]));
 }
コード例 #21
0
 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();
 }
コード例 #22
0
 protected function customValid()
 {
     $countErrors = 0;
     if (isset($_POST['isbilling']) && $_POST['isbilling']) {
         if (!$this->billing_fname) {
             $this->setError('billing_fname', 'required');
             $countErrors++;
         }
         if (!$this->billing_lname) {
             $this->setError('billing_lname', 'required');
             $countErrors++;
         }
         if (!$this->billing_address1) {
             $this->setError('billing_address1', 'required');
             $countErrors++;
         }
         if (!$this->billing_address2) {
             $this->setError('billing_address2', 'required');
             $countErrors++;
         }
         if (!$this->billing_city) {
             $this->setError('billing_city', 'required');
             $countErrors++;
         }
         if (!$this->billing_state_id) {
             $this->setError('billing_state_id', 'required');
             $countErrors++;
         }
         if (!$this->billing_country_id) {
             $this->setError('billing_country_id', 'required');
             $countErrors++;
         }
         if (!$this->billing_zip) {
             $this->setError('billing_zip', 'required');
             $countErrors++;
         }
     }
     if ($this->payment_type && $this->getIsNewRecord()) {
         $payment_method = AF::get($_POST, 'payment_method');
         if (!$payment_method) {
             $this->setError('payment_method', 'Incorrect formatted');
             $countErrors++;
         }
     }
     return $countErrors ? false : true;
 }
コード例 #23
0
 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);
     }
 }
コード例 #24
0
 function change_rankAction()
 {
     $profile_id = AF::get($_POST, 'profile_id', 0);
     $change = AF::get($_POST, 'change', 0);
     if ($change == "up") {
         $change = -1;
     } else {
         $change = +1;
     }
     $model = new ProfileGateway();
     $model->fillFromArray($_POST);
     $model->changeRank($change);
     unset($model);
     Message::echoJsonRedirect("/lj3/profiles/update/id=" . $profile_id);
 }
コード例 #25
0
 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);
     }
 }
コード例 #26
0
 protected function customValid()
 {
     $countErrors = 0;
     $subscription_days = AF::get($_POST, 'subscription_days');
     $is_subscription = AF::get($_POST, 'is_subscription');
     if ($is_subscription && $subscription_days <= 0) {
         $this->setError('subscription_days', 'Incorrect formatted');
         $countErrors++;
     }
     return $countErrors ? false : true;
 }
コード例 #27
0
 function deleteAction()
 {
     $id = AF::get($_POST, 'id', 0);
     $ids = explode('_', $id);
     $errors = FALSE;
     $model = new ProfileMethod();
     $model->profile_id = $ids[0];
     $model->method_id = $ids[1];
     $model->load_balance = $ids[2];
     $model->delete();
     unset($model);
     Message::echoJsonRedirect("/lj3/profiles/update/id=" . $ids[0]);
     $this->redirect();
 }
コード例 #28
0
 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();
 }
コード例 #29
0
 /**
  * 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));
 }