public function execute()
 {
     if (!$this->getUser()->getRights('shop', 'settings')) {
         throw new waRightsException(_w('Access denied'));
     }
     $cm = new waCountryModel();
     $rm = new waRegionModel();
     $country = waRequest::request('country');
     $this->saveFromPost($rm, $cm, $country);
     $countries = $cm->all();
     if (!$country || empty($countries[$country])) {
         $country = wa()->getSetting('country');
     }
     if (!$country || empty($countries[$country])) {
         // Show the first country with regions by default
         $region_countries = $rm->getCountries();
         $country = reset($region_countries);
         if (!$country || empty($countries[$country])) {
             $country = key($countries);
         }
     }
     $regions = $country ? $rm->getByCountry($country) : array();
     $this->view->assign('countries', $cm->allWithFav($countries));
     $this->view->assign('country', ifset($countries[$country], $cm->getEmptyRow()));
     $this->view->assign('regions', $regions);
 }
예제 #2
0
 public static function getTimeframeParams()
 {
     $timeframe = waRequest::request('timeframe');
     if ($timeframe === 'all') {
         $start_date = null;
         $end_date = null;
     } else {
         if ($timeframe == 'custom') {
             $from = waRequest::request('from', 0, 'int');
             $start_date = $from ? date('Y-m-d', $from) : null;
             $to = waRequest::request('to', 0, 'int');
             $end_date = $to ? date('Y-m-d', $to) : null;
         } else {
             if (!wa_is_int($timeframe)) {
                 $timeframe = 30;
             }
             $start_date = date('Y-m-d', time() - $timeframe * 24 * 3600);
             $end_date = null;
         }
     }
     $group_by = waRequest::request('groupby', 'days');
     if ($group_by !== 'months') {
         $group_by = 'days';
     }
     return array($start_date, $end_date, $group_by);
 }
 public function dispatch()
 {
     if ($this->system->getEnv() == 'frontend') {
         $module = 'frontend';
     } else {
         $module = waRequest::get($this->options['module'], $this->system->getEnv());
     }
     $module = waRequest::param('module', $module);
     $action = waRequest::param('action', waRequest::get($this->options['action']));
     $plugin = waRequest::param('plugin', waRequest::get('plugin', ''));
     // event init
     if (!waRequest::request('background_process')) {
         if (method_exists($this->system->getConfig(), 'onInit')) {
             $this->system->getConfig()->onInit();
         }
     }
     if ($widget = waRequest::param('widget')) {
         $this->executeWidget($widget, $action);
     } elseif ($this->system->getEnv() == 'backend') {
         $url = explode("/", $this->system->getConfig()->getRequestUrl(true));
         if (isset($url[2]) && isset($url[3]) && $url[2] == 'widgets') {
             $this->executeWidget($url[3], $action);
         } else {
             $this->execute($plugin, $module, $action);
         }
     } else {
         $this->execute($plugin, $module, $action);
     }
 }
 public function execute()
 {
     $ids = waRequest::request('id', array(), 'array_int');
     if (!$ids) {
         throw new waException('Contact id not specified.');
     }
     // only allowed to global admin
     if (!wa()->getUser()->getRights('webasyst', 'backend')) {
         throw new waRightsException(_w('Access denied'));
     }
     $groups = waRequest::post('groups', array(), 'array_int');
     $counters = array();
     $ugm = new waUserGroupsModel();
     if ($this->getRequest()->request('set')) {
         foreach ($ids as $id) {
             $ugm->delete($id, array());
         }
     }
     foreach ($ids as $id) {
         if ($groups) {
             $ugm->add(array_map(wa_lambda('$gid', 'return array(' . $id . ', $gid);'), $groups));
         }
     }
     $gm = new waGroupModel();
     foreach ($groups as $gid) {
         $cnt = $ugm->countByField(array('group_id' => $gid));
         $gm->updateCount($gid, $cnt);
         $counters[$gid] = $cnt;
     }
     $this->response['counters'] = $counters;
     $this->response['message'] = _w("%d user has been added", "%d users have been added", count($ids));
     $this->response['message'] .= ' ';
     $this->response['message'] .= _w("to %d group", "to %d groups", count($groups));
 }
 public function execute()
 {
     $blog_id = wa()->getRequest()->param('blog_url_type');
     if ($blog_id <= 0) {
         $blog_id = waRequest::request('blog_id', 0, 'int');
     }
     $this->setLayout(new blogFrontendLayout());
     // Get contact id and name as post author
     if (wa()->getUser()->get('is_user')) {
         $post_contact_id = wa()->getUser()->getId();
         $post_contact_name = wa()->getUser()->getName();
     } else {
         foreach (blogHelper::getAuthors($blog_id) as $post_contact_id => $post_contact_name) {
             break;
         }
     }
     // Prepare empty fake post data
     $post_model = new blogPostModel();
     $post = $post_model->prepareView(array(array('id' => 0, 'blog_id' => $blog_id, 'contact_id' => $post_contact_id, 'contact_name' => $post_contact_name, 'datetime' => date('Y-m-d H:i:s'), 'title' => '%replace-with-real-post-title%', 'status' => 'published', 'text' => '<div class="replace-with-real-post-text"></div>' . $this->getScripts(), 'comments_allowed' => 0) + $post_model->getEmptyRow()));
     $post = array_merge($post[0], array('comments' => array(), 'comment_link' => '', 'link' => ''));
     $this->getResponse()->setTitle(_w('Preview'));
     $this->getResponse()->setMeta('keywords', '');
     $this->getResponse()->setMeta('description', '');
     $current_auth = wa()->getStorage()->read('auth_user_data');
     $current_auth_source = $current_auth ? $current_auth['source'] : null;
     $this->view->assign(array('realtime_preview' => true, 'frontend_post' => array(), 'errors' => array(), 'form' => array(), 'show_comments' => false, 'request_captcha' => false, 'require_authorization' => false, 'theme' => waRequest::param('theme', 'default'), 'current_auth_source' => $current_auth_source, 'current_auth' => $current_auth, true, 'auth_adapters' => wa()->getAuthAdapters(), 'post' => $post));
 }
 public function execute()
 {
     $config = $this->getConfig();
     /**
      * @var shopConfig $config
      */
     $product = new shopProduct(waRequest::get('id', 0, waRequest::TYPE_INT));
     $type_id = waRequest::request('type_id', null, waRequest::TYPE_INT);
     if ($type_id != null) {
         $product->type_id = $type_id;
     }
     $sku_type = waRequest::request('sku_type', null, waRequest::TYPE_INT);
     if ($sku_type != null) {
         $product->sku_type = $sku_type;
     }
     // Selectable features
     $features_selectable = $product->features_selectable;
     $counts = array();
     foreach ($features_selectable as $f) {
         if ($f['selected']) {
             $counts[] = $f['selected'];
         }
     }
     $this->view->assign('product', $product);
     $this->view->assign('features', $features_selectable);
     $this->view->assign('features_counts', $counts);
     $this->view->assign(array('use_product_currency' => wa()->getSetting('use_product_currency'), 'currencies' => $this->getCurrencies(), 'primary_currency' => $config->getCurrency()));
 }
 public function dispatch()
 {
     $env = $this->system->getEnv();
     if ($env == 'frontend') {
         $module = 'frontend';
     } else {
         $module = waRequest::get($this->options['module'], $this->system->getEnv());
     }
     $module = waRequest::param('module', $module);
     $action = waRequest::param('action', waRequest::get($this->options['action']));
     $plugin = waRequest::param('plugin', $env == 'backend' ? waRequest::get('plugin', '') : '');
     // event init
     if (!waRequest::request('background_process')) {
         if (method_exists($this->system->getConfig(), 'onInit')) {
             $this->system->getConfig()->onInit();
         }
     }
     if ($this->system->getEnv() == 'backend') {
         if ($widget = waRequest::get('widget')) {
             $this->executeWidget($widget, $action);
         } else {
             $this->execute($plugin, $module, $action);
         }
     } else {
         $this->execute($plugin, $module, $action);
     }
 }
 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);
 }
예제 #9
0
 public function init()
 {
     parent::init();
     $this->storage = waSystem::getInstance()->getStorage();
     if (!isset(self::$options['session_timeout'])) {
         self::$options['session_timeout'] = 1800;
     }
     if (ini_get('session.gc_maxlifetime') < self::$options['session_timeout']) {
         ini_set('session.gc_maxlifetime', self::$options['session_timeout']);
     }
     $auth = waSystem::getInstance()->getAuth();
     $info = $auth->isAuth();
     if ($info && isset($info['id']) && $info['id']) {
         $this->auth = true;
         $this->id = $info['id'];
         // update last_datetime for contact
         if (!waRequest::request('background_process')) {
             $this->updateLastTime();
         }
         // check CSRF cookie
         if (!waRequest::cookie('_csrf')) {
             waSystem::getInstance()->getResponse()->setCookie('_csrf', uniqid('', true));
         }
     }
 }
 protected function getRates($shipping_id, $items, $address, $total)
 {
     $plugin = shopShipping::getPlugin(null, $shipping_id);
     $weight_unit = $plugin->allowedWeightUnit();
     $dimension = shopDimension::getInstance()->getDimension('weight');
     if ($weight_unit != $dimension['base_unit']) {
         foreach ($items as $item_id => $item) {
             if ($item['weight']) {
                 $items[$item_id]['weight'] = $item['weight'] / $dimension['units'][$weight_unit]['multiplier'];
             }
         }
     }
     $currency = $plugin->allowedCurrency();
     $currrent_currency = wa()->getConfig()->getCurrency(false);
     if ($currency != $currrent_currency) {
         $total = shop_currency($total, $currrent_currency, $currency, false);
     }
     $rates = $plugin->getRates($items, $address, array('total_price' => $total));
     if (is_array($rates)) {
         $is_html = waRequest::request('html');
         foreach ($rates as $r_id => &$r) {
             $r['id'] = $r_id;
             $r['rate_html'] = $is_html ? shop_currency_html($r['rate'], $r['currency']) : shop_currency($r['rate'], $r['currency']);
             $r['rate'] = shop_currency($r['rate'], $r['currency']);
         }
         unset($r);
         return array_values($rates);
     }
     return $rates;
 }
 public function setConfig($config = array(), $id = null)
 {
     $id = $this->getId($id);
     if ($id <= 0) {
         $name = wa()->getConfig()->getGeneralSettings('name');
         if (!$name) {
             $name = date('c');
         }
         $description = '';
         if (($raw = waRequest::request('profile')) && is_array($raw)) {
             if (!empty($raw['name'])) {
                 $name = $raw['name'];
             }
             if (!empty($raw['description'])) {
                 $description = $raw['description'];
             }
         }
         $id = $this->addConfig($name, $description);
     }
     $fields = array('id' => $id, 'plugin' => $this->plugin);
     $data = array('config' => json_encode($config));
     if (!empty($this->name)) {
         $data['name'] = $this->name;
     }
     $this->model->updateByField($fields, $data);
     return $id;
 }
 public function execute()
 {
     $type = waRequest::request('type');
     if (!$type) {
         return;
     }
     $asm = new waAppSettingsModel();
     $asm->set('shop', 'discount_' . $type, waRequest::request('enable') ? 1 : null);
 }
 public function execute()
 {
     $code = waRequest::param('code');
     $encoded_order_id = waRequest::param('id');
     $order_id = shopHelper::decodeOrderId($encoded_order_id);
     if (!$order_id) {
         // fall back to non-encoded id
         $order_id = $encoded_order_id;
         $encoded_order_id = shopHelper::encodeOrderId($order_id);
     }
     if (!$order_id || $order_id != substr($code, 16, -16)) {
         throw new waException(_w('Order not found'), 404);
     }
     // When user is authorized, check if order belongs to him.
     // When it does, redirect to plain order page.
     if (wa()->getUser()->isAuth()) {
         $om = new shopOrderModel();
         $order = $om->getOrder($order_id);
         if (!$order) {
             throw new waException(_w('Order not found'), 404);
         }
         if ($order['contact_id'] == wa()->getUser()->getId()) {
             $this->redirect(wa()->getRouteUrl('/frontend/myOrder', array('id' => $order_id)));
         }
     }
     // Check auth code
     $opm = new shopOrderParamsModel();
     $params = $opm->get($order_id);
     if (ifset($params['auth_code']) !== $code || empty($params['auth_pin'])) {
         throw new waException(_w('Order not found'), 404);
     }
     // Check auth pin and show order page if pin is correct
     $pin = waRequest::request('pin', wa()->getStorage()->get('shop/pin/' . $order_id));
     if ($pin && $pin == $params['auth_pin']) {
         wa()->getStorage()->set('shop/pin/' . $order_id, $pin);
         parent::execute();
         if (!waRequest::isXMLHttpRequest()) {
             $this->layout->assign('breadcrumbs', self::getBreadcrumbs());
         }
         return;
     }
     //
     // No pin or pin is incorrect: show form to enter pin
     //
     $this->view->assign('wrong_pin', !!$pin);
     $this->view->assign('pin_required', true);
     $this->view->assign('encoded_order_id', $encoded_order_id);
     $this->view->assign('my_nav_selected', 'orders');
     // Set up layout and template from theme
     $this->setThemeTemplate('my.order.html');
     if (!waRequest::isXMLHttpRequest()) {
         $this->setLayout(new shopFrontendLayout());
         $this->getResponse()->setTitle(_w('Order') . ' ' . $encoded_order_id);
         $this->view->assign('breadcrumbs', self::getBreadcrumbs());
         $this->layout->assign('nofollow', true);
     }
 }
 public function execute()
 {
     $action = waRequest::get('action_to_log', '', waRequest::TYPE_STRING_TRIM);
     $this->log($action, 1);
     if ($action == 'photos_upload') {
         $count = waRequest::request('count', 0, 'int');
         $this->response = _w('Uploaded %d photo', 'Uploaded %d photos', $count);
     }
 }
 public function execute()
 {
     if ($this->thread_id = waRequest::get('thread_id', false)) {
         $cache = new waSerializeCache($this->getApp() . '.' . $this->thread_id);
         $this->urls = $cache->get();
         $cache->delete();
     }
     if ($this->urls) {
         wa()->getStorage()->close();
         ob_start();
         try {
             $this->model = new waAppSettingsModel();
             $log_level = waSystemConfig::isDebug() ? waInstaller::LOG_DEBUG : waInstaller::LOG_WARNING;
             $updater = new waInstaller($log_level, $this->thread_id);
             $this->getStorage()->close();
             $updater->init();
             $this->model->ping();
             $storage = wa()->getStorage();
             $storage->close();
             $this->urls = $updater->update($this->urls);
             if (waRequest::request('install')) {
                 $this->install();
             }
             $this->response['sources'] = $this->getResult();
             $this->response['current_state'] = $updater->getState();
             $this->response['state'] = $updater->getFullState(waRequest::get('mode', 'apps'));
             //cleanup cache
             $this->cleanup();
             //update themes
             foreach ($this->urls as $url) {
                 if (preg_match('@(wa-apps/)?(.+)/themes/(.+)@', $url['slug'], $matches)) {
                     try {
                         $theme = new waTheme($matches[3], $matches[2]);
                         $theme->update();
                     } catch (Exception $ex) {
                         waLog::log(sprintf('Error during theme %s@%s update: %s', $matches[3], $matches[2], $ex->getMessage()));
                     }
                 }
             }
             //and again cleanup
             $this->cleanup();
             $this->getConfig()->setCount(false);
             $response = $this->getResponse();
             $response->addHeader('Content-Type', 'application/json; charset=utf-8');
             $response->sendHeaders();
         } catch (Exception $ex) {
             $this->setError($ex->getMessage());
         }
         if ($ob = ob_get_clean()) {
             $this->response['warning'] = $ob;
             waLog::log('Output at ' . __METHOD__ . ': ' . $ob);
         }
     } else {
         throw new Exception('nothing to update');
     }
 }
 public function execute()
 {
     $action = waRequest::get('action_to_log', '', waRequest::TYPE_STRING_TRIM);
     $params = null;
     if ($action == 'photos_upload') {
         $count = waRequest::request('count', 0, 'int');
         $this->response = _w('Uploaded %d photo', 'Uploaded %d photos', $count);
         $params = implode(',', waRequest::get('ids'));
     }
     $this->logAction($action, $params);
 }
예제 #17
0
 public static function getRouteHash()
 {
     if ($storefront = waRequest::request('storefront')) {
         return md5($storefront);
     } else {
         $routing = wa()->getRouting();
         $domain = $routing->getDomain(null, true);
         $route = $routing->getRoute();
         return md5($domain . '/' . $route['url']);
     }
 }
예제 #18
0
 public function execute()
 {
     $data['order'] = waRequest::request('order');
     $data['start'] = waRequest::request('start', 0, 'int');
     $data['draw'] = waRequest::request('draw', 1, 'int');
     $data['length'] = waRequest::request('length', 10, 'int');
     $data['search'] = waRequest::request('search');
     $payment_model = new wacabPaymentModel();
     $response = $payment_model->getDataTable($data);
     print json_encode($response);
 }
 public function execute()
 {
     $customer_id = waRequest::request('customer_id', 0, 'int');
     $category_id = waRequest::request('category_id', 0, 'int');
     if (!$customer_id || !$category_id) {
         return;
     }
     $ccm = new waContactCategoriesModel();
     $ccm->add($customer_id, $category_id);
     $cm = new shopCustomerModel();
     $this->response['count'] = $cm->getCategoryCounts($category_id);
 }
예제 #20
0
 public function execute()
 {
     $query = waRequest::request('q', '', waRequest::TYPE_STRING_TRIM);
     $tag_model = new photosTagModel();
     $tags = $tag_model->select('name')->where("name LIKE '" . $tag_model->escape($query, 'like') . "%'")->fetchAll('name', true);
     $tags = array_keys($tags);
     foreach ($tags as &$tag) {
         $tag = photosPhoto::escape($tag);
     }
     unset($tag);
     echo implode("\n", $tags);
 }
예제 #21
0
 public function execute()
 {
     $params = waRequest::request();
     $params['result'] = true;
     $module_id = waRequest::param('module_id');
     $result = waShipping::execCallback($params, $module_id);
     if (!empty($result['template'])) {
         $this->template = $result['template'];
     }
     $this->view->assign('params', $params);
     $this->view->assign('result', $result);
 }
 public function execute()
 {
     $term = waRequest::request('term');
     $limit = waRequest::request('limit', 30, 'int');
     if (mb_strlen($term) < 2) {
         return;
     }
     $type = waRequest::request('type', null, waRequest::TYPE_STRING_TRIM);
     $model = new waModel();
     if (strpos($term, '@') !== FALSE) {
         $contacts = new contactsCollection('/search/email*=' . $term);
     } else {
         $contacts = new contactsCollection();
         $t_a = preg_split("/\\s+/", $term);
         $cond = array();
         foreach ($t_a as $t) {
             $t = trim($t);
             if ($t) {
                 $t = $model->escape($t, 'like');
                 if ($type === 'person') {
                     $cond[] = "(c.firstname LIKE '{$t}%' OR c.middlename LIKE '{$t}%' OR c.lastname LIKE '{$t}%')";
                 } else {
                     if ($type === 'company') {
                         $cond[] = "c.name LIKE '{$t}%'";
                     } else {
                         $cond[] = "(c.firstname LIKE '{$t}%' OR c.middlename LIKE '{$t}%' OR c.lastname LIKE '{$t}%' OR c.name LIKE '{$t}%')";
                     }
                 }
             }
         }
         if ($cond) {
             $contacts->addWhere(implode(" AND ", $cond));
         }
     }
     if ($type) {
         if ($type === 'person') {
             $contacts->addWhere("is_company = 0");
         } else {
             if ($type === 'company') {
                 $contacts->addWhere("is_company = 1");
             }
         }
     }
     $this->response = array();
     $term_safe = htmlspecialchars($term);
     foreach ($contacts->getContacts('id,name,company,email', 0, $limit) as $c) {
         $name = $this->prepare($c['name'], $term_safe);
         $email = $this->prepare(ifset($c['email'][0], ''), $term_safe);
         $company = $this->prepare($c['company'], $term_safe);
         $this->response[] = array('label' => implode(', ', array_filter(array($name, $company, $email))), 'value' => $c['id'], 'name' => $c['name'], 'email' => ifset($c['email'][0], ''), 'company' => $c['company']);
     }
 }
 public function execute()
 {
     $limit = 30;
     $query = waRequest::request('q', '', waRequest::TYPE_STRING_TRIM);
     $tag_model = new blogTagPluginModel();
     $tags = $tag_model->search($query, $limit);
     $tags = array_keys($tags);
     foreach ($tags as &$tag) {
         $tag = htmlspecialchars($tag);
     }
     unset($tag);
     echo implode("\n", $tags);
 }
 public function execute()
 {
     $this->init();
     $this->reader->seek(max(0, waRequest::request('row', 0, waRequest::TYPE_INT)));
     $limit = max(1, waRequest::request('limit', 50, waRequest::TYPE_INT));
     $this->reader->columns(array(array('shopCsvProductviewController', 'tableRowHandler'), array(__CLASS__, 'columns')));
     $n = 0;
     $this->response['tbody'] = '';
     while (++$n <= $limit && $this->reader->next()) {
         $this->response['tbody'] .= $this->reader->getTableRow();
     }
     $this->response['rows_count'] = $this->reader->count();
     $this->response['current'] = $this->reader->key();
 }
예제 #25
0
 private function getInfoFromRequest()
 {
     $request = waRequest::request();
     if (!isset($request['shipping_id'])) {
         return false;
     } else {
         if (isset($request['shipping_' . $request['shipping_id']]['point_id'])) {
             $shipping = $request['shipping_' . $request['shipping_id']];
             if ($shipping['point_id']) {
                 return $shipping;
             }
         }
     }
     return false;
 }
 public function execute()
 {
     $id = waRequest::request('id');
     $class = 'photosImport' . ucfirst($id) . 'Transport';
     if ($id && class_exists($class)) {
         /**
          * @var photosImportTransport $transport
          */
         $transport = new $class();
     } else {
         throw new waException('Transport not found', 404);
     }
     $this->view->assign('controls', $transport->getControls());
     $this->view->assign('contacts', waUser::getUsers('photos'));
     $this->view->assign('user_id', $this->getUser()->getId());
 }
 public function execute()
 {
     $this->response = array('options' => array(), 'oOrder' => array());
     $country = waRequest::request('country');
     if (!$country) {
         return;
     }
     $rm = new waRegionModel();
     foreach ($rm->getByCountryWithFav($country) as $row) {
         if ($row['name'] === '') {
             $this->response['options'][''] = ' ';
             $this->response['oOrder'][] = '';
         } else {
             $this->response['options'][$row['code']] = $row['name'];
             $this->response['oOrder'][] = $row['code'];
         }
     }
 }
 public function execute()
 {
     $lm = new checklistsListModel();
     $lists = $lm->getAllowed();
     foreach ($lists as $id => &$list) {
         if (strtolower(substr($list['icon'], 0, 7)) == 'http://') {
             $list['icon'] = '<i class="icon16" style="background-image:url(' . htmlspecialchars($list['icon']) . ')"></i>';
         } else {
             $list['icon'] = '<i class="icon16 ' . $list['icon'] . '"></i>';
         }
     }
     $id = waRequest::request('id');
     if (($id = waRequest::request('id')) && isset($lists[$id])) {
         $lists[$id]['current'] = true;
     }
     $this->view->assign('lists', $lists);
     $this->view->assign('can_add_lists', $this->getRights('add_list'));
 }
 public function execute()
 {
     $id = waRequest::request('id', null, waRequest::TYPE_INT);
     $contact = new waContact($id);
     $contact->getName();
     // Customer orders
     $im = new shopOrderItemsModel();
     $orders_collection = new shopOrdersCollection('search/contact_id=' . $id);
     $orders = $orders_collection->getOrders('*,items,params', 0, 500);
     shopHelper::workupOrders($orders);
     foreach ($orders as &$o) {
         $o['total_formatted'] = waCurrency::format('%{s}', $o['total'], $o['currency']);
         $o['shipping_name'] = ifset($o['params']['shipping_name'], '');
         $o['payment_name'] = ifset($o['params']['payment_name'], '');
     }
     $this->view->assign('orders', $orders);
     $this->view->assign('contact', $contact);
     $this->view->assign('def_cur_tmpl', str_replace('0', '%s', waCurrency::format('%{s}', 0, wa()->getConfig()->getCurrency())));
 }
예제 #30
0
 public function execute()
 {
     //TODO use POST
     $app_ids = waRequest::request('app_id');
     try {
         if (installerHelper::isDeveloper()) {
             throw new waException(_w('Unable to delete application (developer version is on)'));
         }
         if (!$app_ids || !is_array($app_ids)) {
             throw new waException(_w('Application not found'));
         }
         foreach ($app_ids as &$info) {
             if (!is_array($info)) {
                 $info = array('vendor' => $info);
             }
         }
         unset($info);
         $this->apps = new waInstallerApps();
         $app_list = $this->apps->getApps(array('installed' => true));
         $deleted_apps = array();
         foreach ($app_list as $info) {
             $app_id = $info['slug'];
             if (isset($app_ids[$app_id]) && $app_ids[$app_id]['vendor'] == $info['vendor']) {
                 if (!empty($info['installed']['system'])) {
                     throw new waException(sprintf(_w('Can not delete system application "%s"'), $info['name']));
                 }
                 $deleted_apps[] = $this->deleteApp($app_id);
             }
         }
         wa()->setActive('installer');
         if (!$deleted_apps) {
             throw new waException(_w('Application not found'));
         }
         $message = _w('Application %s has been deleted', 'Applications %s have been deleted', min(2, count($deleted_apps)), false);
         $message = sprintf($message, implode(', ', $deleted_apps));
         $msg = installerMessage::getInstance()->raiseMessage($message);
     } catch (Exception $ex) {
         wa()->setActive('installer');
         $msg = installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL);
     }
     //'module' => installerHelper::getModule(),
     $this->redirect(array('msg' => $msg));
 }