public function execute()
 {
     $order_id = waRequest::request('order_id', 0, 'int');
     $id = waRequest::request('id', 0, 'int');
     $to = waRequest::request('to');
     $nm = new shopNotificationModel();
     $n = $nm->getById($id);
     if (!$n) {
         $this->errors = sprintf_wp('%s entry not found', _w('Notification'));
         return;
     }
     $om = new shopOrderModel();
     $o = $om->getById($order_id);
     if (!$o) {
         $this->errors = _w('Order not found');
         return;
     }
     shopHelper::workupOrders($o, true);
     $opm = new shopOrderParamsModel();
     $o['params'] = $opm->get($order_id);
     try {
         $contact = $o['contact_id'] ? new shopCustomer($o['contact_id']) : wa()->getUser();
         $contact->getName();
     } catch (Exception $e) {
         $contact = new shopCustomer(wa()->getUser()->getId());
     }
     $cm = new shopCustomerModel();
     $customer = $cm->getById($contact->getId());
     if (!$customer) {
         $customer = $cm->getEmptyRow();
     }
     $workflow = new shopWorkflow();
     // send notifications
     shopNotifications::sendOne($id, array('order' => $o, 'customer' => $contact, 'status' => $workflow->getStateById($o['state_id'])->getName()), $to);
 }
 public function execute()
 {
     $id = waRequest::get('id');
     $model = new shopNotificationModel();
     $n = $model->getById($id);
     $params_model = new shopNotificationParamsModel();
     $params = $params_model->getParams($id);
     // Orders used as sample data for testing
     $om = new shopOrderModel();
     $test_orders = $om->where("paid_date IS NOT NULL AND state_id <> 'deleted'")->order('id DESC')->limit(10)->fetchAll('id');
     shopHelper::workupOrders($test_orders);
     $im = new shopOrderItemsModel();
     foreach ($im->getByField('order_id', array_keys($test_orders), true) as $i) {
         $test_orders[$i['order_id']]['items'][] = $i;
     }
     foreach ($test_orders as &$o) {
         $o['items'] = ifset($o['items'], array());
         $o['total_formatted'] = waCurrency::format('%{s}', $o['total'], $o['currency']);
     }
     $this->view->assign('n', $n);
     $this->view->assign('params', $params);
     $this->view->assign('transports', self::getTransports());
     $this->view->assign('events', $this->getEvents());
     $this->view->assign('test_orders', $test_orders);
     $this->view->assign('default_email_from', $this->getConfig()->getGeneralSettings('email'));
     $this->view->assign('sms_from', $this->getSmsFrom());
     $this->view->assign('routes', wa()->getRouting()->getByApp('shop'));
 }
 public function execute()
 {
     $model = new shopNotificationModel();
     $notifications = $model->getAll();
     $this->view->assign('notifications', $notifications);
     $this->view->assign('transports', self::getTransports());
 }
 public function execute()
 {
     $data = waRequest::post('data', array());
     $data['source'] = $data['source'] ? $data['source'] : null;
     if (!isset($data['status'])) {
         $data['status'] = 0;
     }
     $id = waRequest::get('id');
     $model = new shopNotificationModel();
     if (!$id) {
         $id = $model->insert($data);
     } else {
         $model->updateById($id, $data);
     }
     $params = waRequest::post('params');
     if (isset($params['to']) && !$params['to']) {
         $params['to'] = waRequest::post('to');
     }
     if (isset($params['from'])) {
         if (!$params['from']) {
             unset($params['from']);
         } else {
             if ($params['from'] == 'other') {
                 $params['from'] = waRequest::post('from');
             }
         }
     }
     $params_model = new shopNotificationParamsModel();
     $params_model->save($id, $params);
     $this->response = $model->getById($id);
     $transports = shopSettingsNotificationsAction::getTransports();
     $this->response['icon'] = $transports[$this->response['transport']]['icon'];
 }
 public function execute()
 {
     $id = waRequest::post('id');
     $model = new shopNotificationModel();
     if (!$model->delete($id)) {
         $this->errors = 'Error, try again';
     }
 }
 /**
  * @param array $params array('old' => string, 'new' => string)
  * @see waEventHandler::execute()
  * @return void
  */
 public function execute(&$params)
 {
     $model = new shopCategoryRoutesModel();
     $model->updateByField(array('route' => $params['old']), array('route' => $params['new']));
     $notification_model = new shopNotificationModel();
     $notification_model->updateByField(array('source' => $params['old']), array('source' => $params['new']));
     $followup_model = new shopFollowupModel();
     $followup_model->updateByField(array('source' => $params['old']), array('source' => $params['new']));
     wa('shop')->event(array('shop', 'update.route'), $params);
 }
Example #7
0
    include($file);
} else {
    header("HTTP/1.0 404 Not Found");
}
');
waFiles::copy(wa()->getAppPath('lib/config/data/.htaccess', 'shop'), $path . '/.htaccess');
$currency_model = new shopCurrencyModel();
$model = new waAppSettingsModel();
$model->set('shop', 'welcome', 1);
if ($currency_model->countAll() == 0) {
    $currency_model->insert(array('code' => 'USD', 'rate' => 1.0, 'sort' => 1), 2);
    $model->set('shop', 'currency', 'USD');
    $model->set('shop', 'use_product_currency', 'true');
}
// notifications
$notifications_model = new shopNotificationModel();
if ($notifications_model->countAll() == 0) {
    $notifications_action = new shopSettingsNotificationsAddAction();
    $notifications = $notifications_action->getTemplates();
    $params_model = new shopNotificationParamsModel();
    $events = $notifications_action->getEvents();
    foreach ($notifications as $event => $n) {
        if ($event == 'order') {
            continue;
        }
        $data = array('name' => $events[$event]['name'] . ' (' . _w('Customer') . ')', 'event' => $event, 'transport' => 'email', 'status' => 1);
        $id = $notifications_model->insert($data);
        $params = $n;
        $params['to'] = 'customer';
        $params_model->save($id, $params);
        if ($event == 'order.create') {
 private function setup()
 {
     if ($country = waRequest::post('country')) {
         if (!empty($this->countries[$country])) {
             $path = $this->getConfig()->getConfigPath('data/welcome/', false);
             $country_data = (include $path . "country_{$country}.php");
             # Main country setting
             $model = new waAppSettingsModel();
             $model->set('shop', 'country', $country);
             #currency
             if (!empty($country_data['currency'])) {
                 $currency_model = new shopCurrencyModel();
                 $sort = 0;
                 foreach ($country_data['currency'] as $code => $rate) {
                     // delete old currency info is exists
                     $currency_model->deleteById($code);
                     $currency_model->insert(array('code' => $code, 'rate' => $rate, 'sort' => $sort++), 2);
                     if ($sort == 1) {
                         $model->set('shop', 'currency', $code);
                     }
                 }
             }
             #taxes
             if (!empty($country_data['taxes'])) {
                 foreach ($country_data['taxes'] as $tax_data) {
                     shopTaxes::save($tax_data);
                 }
             }
             #custom code
             $function = 'shopWelcome' . ucfirst($country);
             if (function_exists($function)) {
                 try {
                     call_user_func_array($function, array());
                 } catch (Exception $ex) {
                     //TODO
                 }
             }
         }
     }
     if (!empty($this->types)) {
         $type_model = new shopTypeModel();
         $type_features_model = new shopTypeFeaturesModel();
         $types = waRequest::post('types');
         if (empty($types)) {
             if (!$type_features_model->countAll()) {
                 $types[] = 'default';
             }
         }
         if ($types) {
             foreach ($types as $type) {
                 $type_model->insertTemplate($type);
             }
         }
     }
     $set_model = new shopSetModel();
     $set_model->add(array('id' => 'promo', 'name' => _w('Featured on homepage'), 'type' => shopSetModel::TYPE_STATIC));
     $set_model->add(array('id' => 'bestsellers', 'name' => _w('Bestsellers'), 'type' => shopSetModel::TYPE_DYNAMIC, 'count' => 8, 'rule' => 'rating DESC'));
     // notifications
     $notifications_model = new shopNotificationModel();
     if ($notifications_model->countAll() == 0) {
         $notifications_action = new shopSettingsNotificationsAddAction();
         $notifications = $notifications_action->getTemplates();
         $params_model = new shopNotificationParamsModel();
         $events = $notifications_action->getEvents();
         foreach ($notifications as $event => $n) {
             if ($event == 'order') {
                 continue;
             }
             $data = array('name' => $events[$event]['name'] . ' (' . _w('Customer') . ')', 'event' => $event, 'transport' => 'email', 'status' => 1);
             $id = $notifications_model->insert($data);
             $params = $n;
             $params['to'] = 'customer';
             $params_model->save($id, $params);
             if ($event == 'order.create') {
                 $data['name'] = $events[$event]['name'] . ' (' . _w('Store admin') . ')';
                 $id = $notifications_model->insert($data);
                 $params['to'] = 'admin';
                 $params_model->save($id, $params);
             }
         }
     }
     /* !!! import commented out on welcome screen
        switch (waRequest::post('import')) {
        case 'demo':
        //TODO create demoproducts
        $this->redirect('?action=products');
        break;
        case 'migrate':
        $plugins = $this->getConfig()->getPlugins();
        if (empty($plugins['migrate'])) {
        $url = $this->getConfig()->getBackendUrl(true).'installer/?module=update&action=manager&install=1&app_id[shop/plugins/migrate]=webasyst';
        } else {
        $url = '?action=importexport#/migrate/';
        }
        $this->redirect($url);
        break;
        case 'scratch':
        default: */
     $this->redirect('?action=products#/welcome/');
     //        break;
     //}
 }