• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP waModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中waModel的典型用法代码示例。如果您正苦于以下问题:PHP waModel类的具体用法?PHP waModel怎么用?PHP waModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了waModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: postPublishAction

 public function postPublishAction($params)
 {
     $post_id = (int) $params['id'];
     $blog_id = (int) $params['blog_id'];
     // check rights for this blog at first and unsubscribe user if he hasn't
     $sql = "SELECT c.id FROM blog_emailsubscription s\n        JOIN wa_contact c ON s.contact_id = c.id\n        WHERE s.blog_id = " . $blog_id;
     $model = new waModel();
     $unsubscribe_contact_ids = array();
     foreach ($model->query($sql) as $row) {
         $rights = 1;
         try {
             $rights = blogHelper::checkRights($blog_id, $row['id'], blogRightConfig::RIGHT_READ);
         } catch (Exception $e) {
             $rights = 0;
         }
         if (!$rights) {
             $unsubscribe_contact_ids[] = $row['id'];
         }
     }
     if ($unsubscribe_contact_ids) {
         $em = new blogEmailsubscriptionModel();
         $em->deleteByField(array('contact_id' => $unsubscribe_contact_ids, 'blog_id' => $blog_id));
     }
     // add subscribers to queue
     $sql = "REPLACE INTO blog_emailsubscription_log (post_id, contact_id, name, email, datetime)\n                SELECT " . $post_id . ", c.id, c.name, e.email, '" . date('Y-m-d H:i:s') . "' FROM blog_emailsubscription s\n                JOIN wa_contact c ON s.contact_id = c.id\n                JOIN wa_contact_emails e ON c.id = e.contact_id AND e.sort = 0\n                WHERE s.blog_id = " . $blog_id;
     $model->exec($sql);
     // save backend url for cron
     $app_settings_model = new waAppSettingsModel();
     $app_settings_model->set(array($this->app_id, $this->id), 'backend_url', wa()->getRootUrl(true) . wa()->getConfig()->getBackendUrl());
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:30,代码来源:blogEmailsubscriptionPlugin.class.php


示例2: execute

 public function execute()
 {
     $model_settings = new waAppSettingsModel();
     $settings = $model_settings->get($key = array('shop', 'deliveryshop'));
     $model = new waModel();
     $domains = $model->query("SELECT * FROM site_domain")->fetchAll();
     $prices = $model->query("SELECT * FROM shop_deliveryshop_delivery")->fetchAll('domain');
     foreach ($domains as $d) {
         $tab = explode('.', $d['name']);
         $info[$d['name']]['tab_name'] = $tab[0];
         $template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $d['id'] . '.html', false, 'shop', true);
         $change_tpl[$d['name']] = true;
         if (!file_exists($template_path)) {
             $template_path = wa()->getAppPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka.html', 'shop');
             $change_tpl[$d['name']] = false;
         }
         $template_content[$d['name']] = file_get_contents($template_path);
         unset($template_path);
     }
     $this->view->assign('info', $info);
     $this->view->assign('prices', $prices);
     $this->view->assign('change_tpl', $change_tpl);
     $this->view->assign('template', $template_content);
     $this->view->assign('settings', $settings);
 }
开发者ID:quadrodesign,项目名称:deliveryshop,代码行数:25,代码来源:shopDeliveryshopPluginSettings.action.php


示例3: execute

 public function execute()
 {
     $model = new waModel();
     $payment_model = new wacabPaymentModel();
     $payments = $payment_model->getAll();
     $apps_model = new wacabAppsModel();
     $apps = $apps_model->getByField('stat', 1, true);
     $total = $model->query('SELECT SUM(pay) FROM wacab_payment WHERE `apps_id` is not null')->fetchAll();
     $plugins_stat = array();
     foreach ($apps as $app) {
         $app_total = $model->query('SELECT SUM(pay) FROM wacab_payment WHERE `apps_id` = ' . $app['id'])->fetch();
         $app_count = $model->query('SELECT COUNT(*) FROM wacab_payment WHERE `pay` >= 0 AND `apps_id` = ' . $app['id'])->fetch();
         $app_return = $model->query('SELECT COUNT(*) FROM wacab_payment WHERE `pay` < 0 AND `apps_id` = ' . $app['id'])->fetch();
         $names = json_decode($app['name'], true);
         if ($app['parent'] == 'no_parent' || $app['parent'] == '') {
             $pname = $names[0];
         } else {
             $pname = $names[0] . " (" . $app['parent'] . ")";
         }
         $plugins_stat[] = array('id' => $app['app_id'], 'total' => $app_total[0], 'name' => $pname, 'count' => $app_count[0], 'return' => $app_return[0]);
     }
     $this->view->assign('total', $total);
     $this->view->assign('apps', $plugins_stat);
     $this->setTemplate(wacabHelper::getAppPath() . '/templates/actions/statistic/stat_page.html');
 }
开发者ID:itfrogs,项目名称:wa-wacab,代码行数:25,代码来源:wacabStatistic.action.php


示例4: getSql

 protected function getSql()
 {
     $model = new waModel();
     $where = array();
     if ($discountcard = waRequest::get('discountcard')) {
         $where[] = "discountcard LIKE '" . $model->escape($discountcard) . "'";
     }
     $sql = "FROM `shop_discountcards`" . ($where ? " WHERE " . implode(" AND ", $where) : "") . " ORDER BY `id` DESC";
     return $sql;
 }
开发者ID:klxqz,项目名称:discountcards,代码行数:10,代码来源:shopDiscountcardsPluginBackendList.action.php


示例5: execute

 public function execute(&$params)
 {
     $master_id = $params['id'];
     $merge_ids = $params['contacts'];
     $m = new waModel();
     foreach (array(array('blog_comment', 'contact_id')) as $pair) {
         list($table, $field) = $pair;
         $sql = "UPDATE {$table} SET {$field} = :master WHERE {$field} in (:ids)";
         $m->exec($sql, array('master' => $master_id, 'ids' => $merge_ids));
     }
     return null;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:12,代码来源:contacts.merge.handler.php


示例6: postPublishAction

 public function postPublishAction($params)
 {
     $post_id = (int) $params['id'];
     $blog_id = (int) $params['blog_id'];
     // add subscribers to queue
     $sql = "REPLACE INTO blog_emailsubscription_log (post_id, contact_id, name, email, datetime)\n                SELECT " . $post_id . ", c.id, c.name, e.email, '" . date('Y-m-d H:i:s') . "' FROM blog_emailsubscription s\n                JOIN wa_contact c ON s.contact_id = c.id\n                JOIN wa_contact_emails e ON c.id = e.contact_id AND e.sort = 0\n                WHERE s.blog_id = " . $blog_id;
     $model = new waModel();
     $model->exec($sql);
     // save backend url for cron
     $app_settings_model = new waAppSettingsModel();
     $app_settings_model->set(array($this->app_id, $this->id), 'backend_url', wa()->getRootUrl(true) . wa()->getConfig()->getBackendUrl());
 }
开发者ID:nowaym,项目名称:webasyst-framework,代码行数:12,代码来源:blogEmailsubscriptionPlugin.class.php


示例7: execute

 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']);
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:52,代码来源:contactsBackendAutocomplete.controller.php


示例8: execute

 public function execute()
 {
     switch (waRequest::get('event')) {
         case 'del_trans':
             $model = new waModel();
             $model->query('TRUNCATE TABLE  `wacab_payment`');
             break;
         case 'del_reviews':
             $model = new waModel();
             $model->query('TRUNCATE TABLE  `wacab_review`');
             break;
     }
 }
开发者ID:Alexkurd,项目名称:wacab,代码行数:13,代码来源:wacabBackendSmall.controller.php


示例9: execute

 public function execute()
 {
     try {
         $data = waRequest::post();
         $model = new waModel();
         foreach ($data['data'] as $k => $v) {
             if ($v['id'] != 'new') {
                 $is = $model->query("SELECT * FROM shop_deliveryshop_pvz WHERE code = '" . $v['id'] . "' AND domain = '" . $k . "'")->fetchAssoc();
                 if (!$is) {
                     $d = $model->query("SELECT * FROM shop_deliveryshop_pvz WHERE code = '" . $v['id'] . "'")->fetchAssoc();
                     if ($d && $d['domain'] == '') {
                         $model->query("UPDATE shop_deliveryshop_pvz SET \n                                           address = '" . $v['address'] . "',\n                                           workTime = '" . $v['workTime'] . "',\n                                           email = '" . $v['email'] . "',\n                                           TK = '" . $v['TK'] . "',\n                                           note = '" . $v['note'] . "',\n                                           phone = '" . $v['phone'] . "',\n                                           domain = '" . $k . "'\n                                           WHERE id = '" . $d['id'] . "'");
                     } else {
                         $model->query("INSERT INTO shop_deliveryshop_pvz \n                                           (code, name, city, cityCode, workTime, address, phone, note, coordX, coordY, \n                                           weightMin, weightMax, TK, domain, status, email)\n                                           VALUES ('" . $v['id'] . "', '" . $d['name'] . "', '" . $d['city'] . "',\n                                           '" . $d['cityCode'] . "', '" . $v['workTime'] . "',\n                                           '" . $v['address'] . "', '" . $v['phone'] . "', '" . $v['note'] . "',\n                                           '" . $d['coordX'] . "', '" . $d['coordY'] . "', '" . $d['weightMin'] . "',\n                                           '" . $d['weightMax'] . "', '" . $v['TK'] . "', '" . $k . "', '" . $d['status'] . "', '" . $v['email'] . "')");
                     }
                 } else {
                     $model->query("UPDATE shop_deliveryshop_pvz SET \n                                       address = '" . $v['address'] . "',\n                                       workTime = '" . $v['workTime'] . "',\n                                       email = '" . $v['email'] . "',\n                                       TK = '" . $v['TK'] . "',\n                                       note = '" . $v['note'] . "',\n                                       phone = '" . $v['phone'] . "'\n                                       WHERE id = '" . $is['id'] . "' AND domain = '" . $k . "'");
                 }
             } else {
                 if ($v['city']) {
                     $city = $model->query("SELECT city FROM shop_deliveryshop_city WHERE cityCode = '" . $v['city'] . "'")->fetchField();
                     $model->query("INSERT INTO shop_deliveryshop_pvz \n                                       (code, name, city, cityCode, workTime, address, phone, note, coordX, coordY, \n                                       weightMin, weightMax, TK, domain, status, email)\n                                       VALUES ('" . $v['code'] . "', '" . $v['name'] . "', '" . $city . "',\n                                       '" . $v['city'] . "', '" . $v['workTime'] . "',\n                                       '" . $v['address'] . "', '" . $v['phone'] . "', '" . $v['note'] . "',\n                                       '" . $v['coordX'] . "', '" . $v['coordY'] . "', '" . $v['weightMin'] . "',\n                                       '" . $v['weightMax'] . "', '" . $v['TK'] . "', '" . $k . "', 'new', '" . $v['email'] . "')");
                 } else {
                     $this->response['stat'] = 'error';
                 }
             }
         }
         $this->response['message'] = 'ok';
     } catch (Exception $e) {
         $this->setError($e->getMessage());
     }
 }
开发者ID:quadrodesign,项目名称:deliveryshop,代码行数:32,代码来源:shopDeliveryshopPluginBackendSavepvz.controller.php


示例10: execute

 public function execute()
 {
     $url = waRequest::param('url');
     $domain = waRequest::server('HTTP_HOST');
     $model = new waModel();
     //    $main_domain = $model->query("SELECT value FROM wa_app_settings WHERE app_id = 'webasyst' AND name = 'url'")->fetchField();
     $app_settings_model = new waAppSettingsModel();
     $main_domain = trim(str_replace(array('https', 'http', '://'), '', $app_settings_model->get('webasyst', 'url')), "/");
     $data = $model->query("\nSELECT\n  shop_deliveryshop_city_description.*\n, shop_deliveryshop_city.city\n, shop_deliveryshop_city.region\nFROM\n  shop_deliveryshop_city_description\nLEFT JOIN\n  shop_deliveryshop_city ON shop_deliveryshop_city_description.cityCode = shop_deliveryshop_city.cityCode\nLEFT JOIN\n  wa_region ON wa_region.code = shop_deliveryshop_city.region AND wa_region.country_iso3='rus'\nWHERE\n  (url = '{$url}' OR city = '{$url}')\nAND\n  domain IN ('{$domain}', '{$main_domain}')\nLIMIT 1\n  ")->fetchAssoc();
     // Уменьшаем стоимость доставки на сумму указанную в настройках плагина
     $delivery_compensation = $model->query("SELECT price FROM shop_deliveryshop_delivery WHERE domain = '" . $domain . "'")->fetchField();
     $delivery_compensation = intval($delivery_compensation);
     $delivery_price = intval($data['delivery_price']);
     $courier_price = intval($data['courier_price']);
     if ($delivery_price > $delivery_compensation) {
         $data['delivery_price'] = (int) (($delivery_price - $delivery_compensation) / 50) * 50;
         //Уменьшаем до ближайшего полтинника
     } else {
         $data['delivery_price'] = 0;
     }
     if ($courier_price > $delivery_compensation) {
         $data['courier_price'] = (int) (($courier_price - $delivery_compensation) / 50) * 50;
         //Уменьшаем до ближайшего полтинника
     } else {
         $data['courier_price'] = 0;
     }
     foreach (array('meta_title' => $main_domain, 'meta_description' => '', 'meta_keywords' => '', 'delivery_time' => '', 'courier_time' => '') as $key => $value) {
         $data[$key] = isset($data[$key]) ? $data[$key] : $value;
     }
     wa()->getResponse()->setTitle($data['meta_title']);
     wa()->getResponse()->setMeta('description', $data['meta_description']);
     wa()->getResponse()->setMeta('keywords', $data['meta_keywords']);
     $city_code = isset($data['cityCode']) ? $data['cityCode'] : 0;
     $pvz = $model->query("\nSELECT\n  shop_deliveryshop_pvz.*\nFROM\n  shop_deliveryshop_pvz\nWHERE\n  cityCode = {$city_code}\nAND\n  status = 'completed'\nAND\n  (domain IN ('{$domain}', '{$main_domain}') OR domain IS NULL)\n")->fetchAll();
     //$site_model = new siteDomainModel();
     //$domain_id = $site_model->getByName($domain);
     $domain_id = $model->query("SELECT id FROM site_domain WHERE name = '" . $domain . "'")->fetchField();
     $template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $domain_id . '.html', false, 'shop', true);
     if (!file_exists($template_path)) {
         $template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka.html', false, 'shop', true);
     }
     if (!file_exists($template_path)) {
         $template_path = wa()->getAppPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka.html', 'shop');
     }
     $this->view->assign('data', $data);
     $this->view->assign('pvz', $pvz);
     $this->view->assign('page', array('id' => null, 'name' => '', 'content' => $this->view->fetch($template_path)));
     $this->setThemeTemplate('page.html');
     waSystem::popActivePlugin();
 }
开发者ID:quadrodesign,项目名称:deliveryshop,代码行数:50,代码来源:shopDeliveryshopPluginFrontendDostavka.action.php


示例11: getSql

 protected function getSql()
 {
     $model = new waModel();
     $where = array();
     if ($discountcard = waRequest::get('discountcard')) {
         $where[] = "`discountcard` LIKE '" . $model->escape($discountcard) . "'";
     }
     if ($order_id = waRequest::get('order_id')) {
         $order_id = $this->decodeOrderId($order_id);
         $where[] = "`order_id` = '" . $order_id . "'";
     }
     $sql = "FROM `shop_discountcards_order`" . ($where ? " WHERE " . implode(" AND ", $where) : "") . " ORDER BY `order_id` DESC";
     return $sql;
 }
开发者ID:klxqz,项目名称:discountcards,代码行数:14,代码来源:shopDiscountcardsPluginBackendOrders.action.php


示例12: execute

 public function execute()
 {
     $plugin_id = array('shop', 'deliveryshop');
     try {
         $app_settings_model = new waAppSettingsModel();
         $settings = waRequest::post('settings');
         $app_settings_model->set($plugin_id, 'status', (int) $settings['status']);
         $model = new waModel();
         $domains = $model->query("SELECT * FROM site_domain")->fetchAll();
         $reset_tpls = waRequest::post('reset_tpls');
         $template = waRequest::post('template');
         $prices = waRequest::post('prices');
         $this->response['pri'] = $prices;
         foreach ($domains as $d) {
             $id_price = $model->query("SELECT id FROM shop_deliveryshop_delivery WHERE domain = '" . $d['name'] . "'")->fetchField();
             if ($id_price) {
                 $model->query("UPDATE shop_deliveryshop_delivery SET price = '" . $prices[$d['name']]['price'] . "' WHERE domain = '" . $d['name'] . "'");
             } else {
                 $model->query("INSERT INTO shop_deliveryshop_delivery (domain, price)\n                                   VALUES ('" . $d['name'] . "', '" . $prices[$d['name']]['price'] . "')");
             }
             if (isset($reset_tpls[$d['name']])) {
                 $template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $d['id'] . '.html', false, 'shop', true);
                 @unlink($template_path);
             } else {
                 if (!isset($template[$d['name']])) {
                     throw new waException('Не определён шаблон');
                 }
                 $template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $d['id'] . '.html', false, 'shop', true);
                 if (!file_exists($template_path)) {
                     $template_path = wa()->getAppPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka.html', 'shop');
                 }
                 $template_content = file_get_contents($template_path);
                 if ($template_content != $template[$d['name']]) {
                     $template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $d['id'] . '.html', false, 'shop', true);
                     $f = fopen($template_path, 'w');
                     if (!$f) {
                         throw new waException('Не удаётся сохранить шаблон. Проверьте права на запись ' . $template_path);
                     }
                     fwrite($f, $template[$d['name']]);
                     fclose($f);
                 }
             }
             $this->response['template'] = $template;
         }
         $this->response['message'] = "Сохранено";
     } catch (Exception $e) {
         $this->setError($e->getMessage());
     }
 }
开发者ID:quadrodesign,项目名称:deliveryshop,代码行数:49,代码来源:shopDeliveryshopPluginSettingsSave.controller.php


示例13: getUserCategoryId

 public static function getUserCategoryId($contact_id = null)
 {
     if ($contact_id === null) {
         $contact_id = wa()->getUser()->getId();
     }
     $model = new waModel();
     $sql = "SELECT * FROM `wa_contact_categories` WHERE `contact_id` = '" . $model->escape($contact_id) . "'";
     $categories = $model->query($sql)->fetchAll();
     $category_ids = array();
     $category_ids[] = 0;
     foreach ($categories as $category) {
         $category_ids[] = $category['category_id'];
     }
     return $category_ids;
 }
开发者ID:klxqz,项目名称:price,代码行数:15,代码来源:shopPrice.plugin.php


示例14: execute

 public function execute()
 {
     try {
         $id = waRequest::post('id');
         $status = waRequest::post('status');
         $g = waRequest::post('g');
         $model = new waModel();
         if ($g == 'shop') {
             $model->query("UPDATE shop_deliveryshop_city SET status='" . $status . "' WHERE cityCode='" . $id . "'");
         } else {
             if ($g == 'delivery') {
                 $model->query("UPDATE shop_deliveryshop_pvz SET status='" . $status . "' WHERE code='" . $id . "'");
             }
         }
         $this->response['message'] = 'ok';
     } catch (Exception $e) {
         $this->setError($e->getMessage());
     }
 }
开发者ID:quadrodesign,项目名称:deliveryshop,代码行数:19,代码来源:shopDeliveryshopPluginBackendChangestatus.controller.php


示例15: execute

 public function execute()
 {
     $id = waRequest::post('id');
     $name = waRequest::post('name');
     $content = waRequest::post('content');
     $model = new waModel();
     if (is_numeric($id)) {
         $model->query("UPDATE shop_notifier_template SET name = '" . $name . "' WHERE id = '" . $id . "'");
     } else {
         $result = $model->query("INSERT INTO shop_notifier_template (name) VALUES ('" . $name . "')");
         $id = $result->lastInsertId();
     }
     $template_path = shopNotifierPlugin::path($id);
     $f = fopen($template_path, 'w');
     if (!$f) {
         throw new waException('Не удаётся сохранить шаблон. Проверьте права на запись ' . $template_path);
     }
     fwrite($f, $content);
     fclose($f);
     $this->response['result'] = array('id' => $id, 'name' => $name);
 }
开发者ID:quadrodesign,项目名称:notifier,代码行数:21,代码来源:shopNotifierPluginSettingsSaveTemplate.controller.php


示例16: execute

 public function execute()
 {
     switch (waRequest::get('event')) {
         case 'del_trans':
             $model = new waModel();
             $model->query('TRUNCATE TABLE  `wacab_payment`');
             break;
         case 'del_reviews':
             $model = new waModel();
             $model->query('TRUNCATE TABLE  `wacab_review`');
             break;
         case 'del_areports':
             $model = new waModel();
             $model->query('TRUNCATE TABLE  `wacab_areport`');
             break;
         case 'print_report':
             $model = new wacabAgentModel();
             $report = $model->getByField('rid', waRequest::get('rid'));
             echo $report['html'];
             break;
     }
 }
开发者ID:itfrogs,项目名称:wa-wacab,代码行数:22,代码来源:wacabBackendSmall.controller.php


示例17: execute

 public function execute()
 {
     try {
         $PvzList = simplexml_load_file('http://gw.edostavka.ru:11443/pvzlist.php');
         $model = new waModel();
         $update = 0;
         $insert = 0;
         if ($PvzList) {
             foreach ($PvzList->Pvz as $pvz) {
                 if (!($weight = $pvz->WeightLimit)) {
                     $weight['WeightMin'] = '';
                     $weight['WeightMax'] = '';
                 }
                 $id = $model->query("SELECT id FROM shop_deliveryshop_pvz WHERE code='" . (string) $pvz['Code'] . "'")->fetchField();
                 $id_city = $model->query("SELECT cityCode FROM shop_deliveryshop_city WHERE cityCode='" . (string) $pvz['CityCode'] . "'")->fetchField();
                 $youcity = new shopDeliveryshopPluginHelper();
                 $data = $youcity->getCitySearch($pvz[0]['City']);
                 if ($data[2] != 0 && is_numeric($data[2])) {
                     $region = $data[2];
                 } else {
                     if ($data[4] == 'ukr') {
                         $region = 'Украина';
                     } else {
                         if ($data[4] == 'kaz') {
                             $region = 'Казахстан';
                         }
                     }
                 }
                 if ($id_city) {
                     $model->query("UPDATE shop_deliveryshop_city SET \n                                       cityCode='" . mysql_escape_string((string) $pvz[0]['CityCode']) . "',\n                                       city='" . mysql_escape_string((string) $pvz[0]['City']) . "',\n                                       region='" . $region . "'\n                                       WHERE cityCode='" . $id_city . "'");
                 } else {
                     $model->query("INSERT INTO shop_deliveryshop_city\n                                       (cityCode, city, region, status)\n                                        VALUES ('" . mysql_escape_string((string) $pvz[0]['CityCode']) . "',\n                                        '" . mysql_escape_string((string) $pvz[0]['City']) . "', '" . $region . "', 'new')");
                 }
                 if ($id) {
                     $model->query("UPDATE shop_deliveryshop_pvz SET\n                                       code='" . mysql_escape_string((string) $pvz['Code']) . "',\n                                       name='" . mysql_escape_string((string) $pvz[0]['Name']) . "',\n                                       cityCode='" . mysql_escape_string((string) $pvz[0]['CityCode']) . "',\n                                       city='" . mysql_escape_string((string) $pvz[0]['City']) . "',\n                                       workTime='" . mysql_escape_string((string) $pvz[0]['WorkTime']) . "',\n                                       address='" . mysql_escape_string((string) $pvz[0]['Address']) . "',\n                                       phone='" . mysql_escape_string((string) $pvz[0]['Phone']) . "',\n                                       note='" . mysql_escape_string((string) $pvz[0]['Note']) . "',\n                                       coordX='" . mysql_escape_string((string) $pvz[0]['coordX']) . "',\n                                       coordY='" . mysql_escape_string((string) $pvz[0]['coordY']) . "',\n                                       weightMin='" . mysql_escape_string((string) $weight['WeightMin']) . "',\n                                       weightMax='" . mysql_escape_string((string) $weight['WeightMax']) . "'\n                                       WHERE id='" . $id . "'");
                     $update++;
                 } else {
                     $model->query("INSERT INTO shop_deliveryshop_pvz\n                                       (code, name, cityCode, city, workTime, address, phone, note, coordX, coordY, weightMin, weightMax, status)\n                                        VALUES ('" . mysql_escape_string((string) $pvz['Code']) . "',\n                                        '" . mysql_escape_string((string) $pvz[0]['Name']) . "',\n                                        '" . mysql_escape_string((string) $pvz[0]['CityCode']) . "',\n                                        '" . mysql_escape_string((string) $pvz[0]['City']) . "',\n                                        '" . mysql_escape_string((string) $pvz[0]['WorkTime']) . "',\n                                        '" . mysql_escape_string((string) $pvz[0]['Address']) . "',\n                                        '" . mysql_escape_string((string) $pvz[0]['Phone']) . "',\n                                        '" . mysql_escape_string((string) $pvz[0]['Note']) . "',\n                                        '" . mysql_escape_string((string) $pvz[0]['coordX']) . "',\n                                        '" . mysql_escape_string((string) $pvz[0]['coordY']) . "',\n                                        '" . mysql_escape_string((string) $weight['WeightMin']) . "',\n                                        '" . mysql_escape_string((string) $weight['WeightMax']) . "',\n                                        'new')");
                 }
             }
         }
         $this->response['message'] = 'Импортировано';
         $this->response['update'] = $update;
         $this->response['ins'] = $insert;
     } catch (Exception $e) {
         $this->setError($e->getMessage());
     }
 }
开发者ID:quadrodesign,项目名称:deliveryshop,代码行数:48,代码来源:shopDeliveryshopPluginSettingsImport.controller.php


示例18: getSourceModel

 /**
  * @return waModel
  * @throws waException
  */
 private function getSourceModel()
 {
     if (!$this->source) {
         $this->source_path = $this->option('path');
         if (substr($this->source_path, -1) != '/') {
             $this->source_path .= '/';
         }
         if (!file_exists($this->source_path)) {
             throw new waException(sprintf(_wp('Invalid PATH %s; %s'), $this->source_path, _wp('directory not exists')));
         }
         if (!file_exists($this->source_path . 'kernel/wbs.xml')) {
             throw new waException(sprintf(_wp('Invalid PATH %s; %s'), $this->source_path, _wp('file kernel/wbs.xml not found')));
         }
         /**
          *
          * @var SimpleXMLElement $wbs
          */
         $wbs = simplexml_load_file($this->source_path . 'kernel/wbs.xml');
         $this->dbkey = (string) $wbs->FRONTEND['dbkey'];
         $dkey_path = $this->source_path . 'dblist/' . $this->dbkey . '.xml';
         if (empty($this->dbkey) || !file_exists($dkey_path)) {
             throw new waException(sprintf(_wp('Invalid PATH %s; %s'), $this->source_path, sprintf(_wp('invalid file %s'), 'dblist/' . $this->dbkey . '.xml')));
         }
         /**
          *
          * @var SimpleXMLElement $dblist
          */
         $dblist = simplexml_load_file($dkey_path);
         $host_name = (string) $dblist->DBSETTINGS['SQLSERVER'];
         $host = $wbs->xPath('/WBS/SQLSERVERS/SQLSERVER[@NAME="' . htmlentities($host_name, ENT_QUOTES, 'utf-8') . '"]');
         if (!count($host)) {
             throw new waException(_wp('Invalid SQL server name'));
         }
         $host = $host[0];
         $port = (string) $host['PORT'];
         $this->sql_options = array('host' => (string) $host['HOST'] . ($port ? ':' . $port : ''), 'user' => (string) $dblist->DBSETTINGS['DB_USER'], 'password' => (string) $dblist->DBSETTINGS['DB_PASSWORD'], 'database' => (string) $dblist->DBSETTINGS['DB_NAME'], 'type' => function_exists('mysqli_connect') ? 'mysqli' : 'mysql');
         $this->source = new waModel($this->sql_options);
     } else {
         $this->source->ping();
     }
     return $this->source;
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:46,代码来源:blogImportPluginWebasystSameTransport.class.php


示例19: execute

 public function execute(&$params)
 {
     $master_id = $params['id'];
     $merge_ids = $params['contacts'];
     $all_ids = array_merge($merge_ids, array($master_id));
     $m = new waModel();
     //
     // All the simple cases: update contact_id in tables
     //
     foreach (array(array('shop_cart_items', 'contact_id'), array('shop_checkout_flow', 'contact_id'), array('shop_order', 'contact_id'), array('shop_order_log', 'contact_id'), array('shop_product', 'contact_id'), array('shop_product_reviews', 'contact_id'), array('shop_affiliate_transaction', 'contact_id')) as $pair) {
         list($table, $field) = $pair;
         $sql = "UPDATE {$table} SET {$field} = :master WHERE {$field} in (:ids)";
         $m->exec($sql, array('master' => $master_id, 'ids' => $merge_ids));
     }
     //
     // shop_affiliate_transaction
     //
     $balance = 0.0;
     $sql = "SELECT * FROM shop_affiliate_transaction WHERE contact_id=? ORDER BY id";
     foreach ($m->query($sql, $master_id) as $row) {
         $balance += $row['amount'];
         if ($row['balance'] != $balance) {
             $m->exec("UPDATE shop_affiliate_transaction SET balance=? WHERE id=?", $balance, $row['id']);
         }
     }
     $affiliate_bonus = $balance;
     //
     // shop_customer
     //
     // Make sure it exists
     $cm = new shopCustomerModel();
     $cm->createFromContact($master_id);
     $sql = "SELECT SUM(number_of_orders) FROM shop_customer WHERE contact_id IN (:ids)";
     $number_of_orders = $m->query($sql, array('ids' => $all_ids))->fetchField();
     $sql = "SELECT MAX(last_order_id) FROM shop_customer WHERE contact_id IN (:ids)";
     $last_order_id = $m->query($sql, array('ids' => $all_ids))->fetchField();
     $sql = "UPDATE shop_customer SET number_of_orders=?, last_order_id=?, affiliate_bonus=? WHERE contact_id=?";
     $m->exec($sql, ifempty($number_of_orders, 0), ifempty($last_order_id, null), ifempty($affiliate_bonus, 0), $master_id);
     if ($number_of_orders) {
         shopCustomers::recalculateTotalSpent($master_id);
     }
     wa('shop')->event('customers_merge', $params);
     return null;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:44,代码来源:contacts.merge.handler.php


示例20: execute

 public function execute()
 {
     try {
         $data = waRequest::post();
         $model = new waModel();
         foreach ($data['data'] as $k => $v) {
             $delivery_time = '{$delivery_time}';
             $delivery_price = '{$delivery_price}';
             $courier_time = '{$courier_time}';
             $courier_price = '{$courier_price}';
             if ($v['description'] == '<p><br></p>' || $v['description'] == '') {
                 $v['description'] = '';
             }
             if ($v['anons_shop'] == '<p><br></p>' || $v['anons_shop'] == '') {
                 $v['anons_shop'] = '';
             }
             if ($v['anons_delivery'] == '<p><br></p>' || $v['anons_delivery'] == '') {
                 $v['anons_delivery'] = '';
             }
             if ($v['id'] != 'new') {
                 $id = $model->query("SELECT id FROM shop_deliveryshop_city_description \n                                         WHERE cityCode='" . $v['id'] . "' AND domain='" . $k . "'")->fetchField();
                 $model->query("UPDATE shop_deliveryshop_city SET region = '" . $v['region'] . "' WHERE cityCode = '" . $v['id'] . "'");
                 if ($id) {
                     $model->query("UPDATE shop_deliveryshop_city_description SET\n                                       ID_TK = '" . $v['ID_TK'] . "',\n                                       delivery_time = '" . $v['delivery_time'] . "',\n                                       delivery_price = '" . $v['delivery_price'] . "',\n                                       courier_time = '"  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP waRequest类代码示例发布时间:2022-05-23
下一篇:
PHP waLog类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap