Example #1
0
 public function displayMain()
 {
     global $smarty, $link, $cookie;
     if ($cookie->logged) {
         Tools::redirect($link->getPage('MyaccountView'));
     }
     if (Tools::isSubmit('loginSubmit')) {
         if (Tools::getRequest('email') && Tools::getRequest('passwd')) {
             $user = new User();
             if ($user->getByEmail(Tools::getRequest('email'), Tools::getRequest('passwd'))) {
                 $user->logined();
                 if (Tools::G("step") == 2) {
                     Tools::redirect($link->getPage('CheckoutView'));
                 } else {
                     Tools::redirect($link->getPage('MyaccountView'));
                 }
             } else {
                 $smarty->assign('errors', $user->_errors);
             }
         } else {
             $smarty->assign('errors', 'invalid email password combination');
         }
     }
     return $smarty->fetch('login.tpl');
 }
Example #2
0
 public function hookDisplay($view = false)
 {
     global $smarty;
     $noloadid = 0;
     if (Tools::G('route') == 'product-view' && Tools::G('id') > 0) {
         $this->addViewed(Tools::G('id'));
         $noloadid = intval(Tools::G('id'));
     }
     $smarty->assign('vieweds', $this->getViewed(10, $noloadid));
     $display = $this->display(__FILE__, 'viewed.tpl');
     return $display;
 }
Example #3
0
 public static function run()
 {
     if (isset($_GET['route']) && !empty(Tools::G('route'))) {
         $routes = explode('-', Tools::G('route'));
         $viewName = '';
         foreach ($routes as $route) {
             $viewName .= ucwords($route);
         }
     } else {
         $viewName = 'IndexView';
     }
     if (class_exists($viewName)) {
         $view = new $viewName();
     } else {
         $view = new NotFundView();
     }
     return $view;
 }
Example #4
0
<?php

if (Tools::Q('saveAttributeGroup') == 'add') {
    $attribute_group = new AttributeGroup();
    $attribute_group->copyFromPost();
    $attribute_group->add();
    if (is_array($attribute_group->_errors) and count($attribute_group->_errors) > 0) {
        $errors = $attribute_group->_errors;
    } else {
        $_GET['id'] = $attribute_group->id;
        UIAdminAlerts::conf('已添加属性组');
    }
}
if (isset($_GET['id'])) {
    $id = (int) Tools::G('id');
    $obj = new AttributeGroup($id);
}
if (Tools::Q('saveAttributeGroup') == 'edit') {
    if (Validate::isLoadedObject($obj)) {
        $obj->copyFromPost();
        $obj->update();
    }
    if (is_array($obj->_errors) and count($obj->_errors) > 0) {
        $errors = $obj->_errors;
    } else {
        UIAdminAlerts::conf('已更新属性组');
    }
}
if (isset($errors)) {
    UIAdminAlerts::MError($errors);
}
Example #5
0
    if (Validate::isLoadedObject($object)) {
        $object->delete();
    }
    if (is_array($object->_errors) and count($object->_errors) > 0) {
        $errors = $object->_errors;
    } else {
        UIAdminAlerts::conf('页面已删除');
    }
}
$table = new UIAdminTable('onepage', 'Onepage', 'id_onepage');
$table->header = array(array('sort' => false, 'isCheckAll' => 'itemsBox[]'), array('name' => 'id_onepage', 'title' => 'ID', 'filter' => 'string'), array('name' => 'view_name', 'title' => '示图名', 'filter' => 'string'), array('name' => 'meta_title', 'title' => 'Meta标题', 'filter' => 'string'), array('name' => 'rewrite', 'title' => 'URL', 'filter' => 'string'), array('name' => 'add_date', 'title' => '添加时间'), array('sort' => false, 'title' => '操作', 'class' => 'text-right', 'isAction' => array('edit', 'delete')));
$filter = $table->initFilter();
$orderBy = isset($_GET['orderby']) ? Tools::G('orderby') : 'id_onepage';
$orderWay = isset($_GET['orderway']) ? Tools::G('orderway') : 'asc';
$limit = $cookie->getPost('pagination') ? $cookie->getPost('pagination') : '50';
$p = Tools::G('p') ? Tools::G('p') == 0 ? 1 : Tools::G('p') : 1;
$result = Onepage::loadData($p, $limit, $orderBy, $orderWay, $filter);
/** 错误处理 */
if (isset($errors)) {
    UIAdminAlerts::MError($errors);
}
/** 导航 */
$breadcrumb = new UIAdminBreadcrumb();
$breadcrumb->home();
$breadcrumb->add(array('title' => '系统设置', 'active' => true));
$breadcrumb->add(array('title' => '单面管理', 'active' => true));
$bread = $breadcrumb->draw();
$btn_group = array(array('type' => 'a', 'title' => '新页面', 'href' => 'index.php?rule=onepage_edit', 'class' => 'btn-success', 'icon' => 'plus'));
echo UIViewBlock::area(array('bread' => $bread, 'btn_groups' => $btn_group), 'breadcrumb');
/** 列表输出 */
echo UIViewBlock::area(array('title' => '地址列表', 'table' => $table, 'result' => $result, 'limit' => $limit), 'table');
Example #6
0
 public function __construct()
 {
     if (Tools::G('id') > 0) {
         $this->entity = new Product(Tools::G('id'));
     }
 }
Example #7
0
    public function displayMain()
    {
        global $cookie;
        /*
        when user add or change address,from addressView or joinView
        */
        if (isset($_GET['ajaxStates']) and isset($_GET['id_country'])) {
            $states = Db::getInstance()->getAll('
			SELECT s.id_state, s.name
			FROM ' . DB_PREFIX . 'state s
			LEFT JOIN ' . DB_PREFIX . 'country c ON (s.`id_country` = c.`id_country`)
			WHERE s.id_country = ' . (int) Tools::G('id_country') . ' AND s.active = 1 AND c.`need_state` = 1
			ORDER BY s.`name` ASC');
            if (is_array($states) and !empty($states)) {
                $list = '';
                if (Tools::G('no_empty') != true) {
                    $list = '<option value="0">-----------</option>' . "\n";
                }
                foreach ($states as $state) {
                    $list .= '<option value="' . (int) $state['id_state'] . '"' . (Tools::G('id_state') == $state['id_state'] ? ' selected="selected"' : '') . '>' . $state['name'] . '</option>' . "\n";
                }
            } else {
                $list = 'false';
            }
            die($list);
        }
        //end get states
        /*
        from cartView get total
        */
        if (isset($_GET['getTotal']) and isset($_GET['id_cart']) and isset($_GET['id_carrier'])) {
            $carrier = new Carrier((int) $_GET['id_carrier']);
            $cart = new Cart((int) $_GET['id_cart']);
            $shipping = $carrier->shipping;
            $p_total = $cart->getProductTotal();
            $total = $shipping + $p_total - $cart->discount;
            $arr = array('name' => $carrier->name, 'shipping' => Tools::displayPrice($shipping), 'total' => Tools::displayPrice($total));
            echo json_encode($arr);
            exit;
        }
        //end use gettotal
        /*
        start use promo code,from CartView
        */
        if (isset($_GET['validatedPromocode']) && isset($_GET['code'])) {
            if (!isset($cookie->id_cart)) {
                $arr = array('status' => "NO", 'msg' => "cart is not init!");
                echo json_encode($arr);
                exit;
            }
            $row = Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'coupon WHERE code="' . pSQL($_GET['code']) . '" AND active=1');
            if ($row) {
                if ($row['id_user'] == 0 || $row['id_user'] == @$cookie->id_user) {
                    $cart = new Cart($cookie->id_cart);
                    $total = $cart->getProductTotal();
                    $quantity = $cart->getProductQantity();
                    $discount = 0;
                    if ($total > $row['total_over'] || $row['quantity_over'] > 0 && $quantity > $row['quantity_over']) {
                        if ($row['off'] > 0) {
                            $discount = (double) $total * $row['off'] / 100;
                        } else {
                            $discount = (double) $row['amount'];
                        }
                        $cart->discount = $discount;
                        if ($cart->update()) {
                            $arr = array('status' => "YES", 'discount' => "-" . Tools::displayPrice($discount), 'total' => Tools::displayPrice($cart->getOrderTotal()));
                            echo json_encode($arr);
                            exit;
                        }
                    }
                }
            }
            $arr = array('status' => "NO", 'msg' => "the code don't found!");
            echo json_encode($arr);
            exit;
        }
        //end use promo code
        /**
         * 购物车
         */
        if (Tools::G('c') == 'Cart') {
            global $cart;
            switch (Tools::G('m')) {
                case 'removeItem':
                    if ($cart->deleteProduct(Tools::G('id'))) {
                        $cart_info = $cart->getCartInfo();
                        $result = array('status' => 'yes', 'cart_total' => Tools::displayPrice($cart_info['cart_total']), 'cart_quantity' => $cart_info['cart_quantity']);
                        die(json_encode($result));
                    }
                    die(json_encode(array("status" => "no")));
                    break;
                case 'plusItem':
                    if ($row = $cart->plusProduct(Tools::G('id'))) {
                        $cart_info = $cart->getCartInfo();
                        $result = array('status' => 'yes', 'cart_total' => Tools::displayPrice($cart_info['cart_total']), 'cart_quantity' => $cart_info['cart_quantity'], 'item' => array('quantity' => $row['quantity'], 'total' => Tools::displayPrice($row['total'])));
                        die(json_encode($result));
                    }
                    die(json_encode(array("status" => "no")));
                    break;
                case 'minusItem':
                    if ($row = $cart->minusProduct(Tools::G('id'))) {
                        $cart_info = $cart->getCartInfo();
                        $result = array('status' => 'yes', 'cart_total' => Tools::displayPrice($cart_info['cart_total']), 'cart_quantity' => $cart_info['cart_quantity'], 'item' => array('quantity' => $row['quantity'], 'total' => Tools::displayPrice($row['total'])));
                        die(json_encode($result));
                    }
                    die(json_encode(array("status" => "no")));
                    break;
                case 'deleteMultiItem':
                    if ($cart->deleteMultiProduct(explode(',', Tools::G('id')))) {
                        $cart_info = $cart->getCartInfo();
                        $result = array('status' => 'yes', 'cart_total' => Tools::displayPrice($cart_info['cart_total']), 'cart_quantity' => $cart_info['cart_quantity']);
                        die(json_encode($result));
                    }
                    die(json_encode(array("status" => "no")));
                    break;
                default:
                    break;
            }
        }
        /**
         * 商品收藏
         */
        if (Tools::G('c') == 'Wish') {
            if (!isset($cookie->id_user)) {
                die(json_encode(array("status" => "no", "msg" => "d'not login!")));
            }
            $user = new User((int) $cookie->id_user);
            if (!Validate::isLoadedObject($user)) {
                die(json_encode(array("status" => "no", "msg" => "user load fail!")));
            }
            switch (Tools::G('m')) {
                case 'addItem':
                    if ($status = $user->addToWish(Tools::G('id'))) {
                        if ($status === 1) {
                            $result = array("m" => "add", 'status' => 'yes');
                        } else {
                            if ($status === -1) {
                                $result = array("m" => "delete", 'status' => 'yes');
                            }
                        }
                        die(json_encode($result));
                    }
                    die(json_encode(array("status" => "no")));
                    break;
                default:
                    break;
            }
        }
        /*
        start use add wish,from ProductView or CategoryView
        */
        if (isset($_GET['action']) && $_GET['action'] == 'add_wish' && isset($_GET['id_product'])) {
            if ($action = Wish::userAddWishProduct($_GET['id_product'])) {
                $wishs = Wish::getWishSumByUser();
                $count_html = "";
                if ($wishs['count'] > 0) {
                    $count_html = "<i>{$wishs['count']}</i>";
                }
                $arr = array('action' => $action, 'count' => $count_html, 'status' => "YES");
                echo json_encode($arr);
            } else {
                $arr = array('status' => "NO");
                echo json_encode($arr);
            }
            exit;
        }
        //end use add wish
        /**
         * 邮箱是否已被注册
         */
        if (Tools::P('existsEmail')) {
            $valid = true;
            if (User::userExists(Tools::P('existsEmail'))) {
                $valid = false;
            }
            echo json_encode(array('valid' => $valid));
        }
    }
Example #8
0
        $object->delete();
    }
    if (is_array($object->_errors) and count($object->_errors) > 0) {
        $errors = $object->_errors;
    } else {
        UIAdminAlerts::conf('颜色已删除');
    }
} elseif (Tools::isSubmit('subDelete')) {
    $select_cat = Tools::P('itemsBox');
    $color = new Color();
    if ($color->deleteSelection($select_cat)) {
        UIAdminAlerts::conf('颜色已删除');
    }
}
echo UIAdminDndTable::loadHead();
$table = new UIAdminDndTable('color', 'Color', 'id_color');
$table->addAttribte('id', 'color-table');
$table->header = array(array('sort' => false, 'isCheckAll' => 'itemsBox[]'), array('name' => 'id_color', 'title' => 'ID'), array('name' => 'name', 'title' => '名称'), array('name' => 'code', 'title' => '颜色', 'color' => true), array('name' => 'position', 'title' => '排序'), array('sort' => false, 'title' => '操作', 'class' => 'text-right', 'isAction' => array('edit', 'delete')));
$orderBy = isset($_GET['orderby']) ? Tools::G('orderby') : 'position';
$orderWay = isset($_GET['orderway']) ? Tools::G('orderway') : 'asc';
$result = Color::loadData($orderBy, $orderWay);
if (isset($errors)) {
    UIAdminAlerts::MError($errors);
}
$breadcrumb = new UIAdminBreadcrumb();
$breadcrumb->home();
$breadcrumb->add(array('title' => '颜色', 'active' => true));
$bread = $breadcrumb->draw();
$btn_group = array(array('type' => 'a', 'title' => '取消关联', 'href' => 'index.php?rule=color_cannel_product', 'class' => 'btn-primary', 'icon' => 'level-up'), array('type' => 'a', 'title' => '产品关联', 'href' => 'index.php?rule=color_product', 'class' => 'btn-primary', 'icon' => 'level-up'), array('type' => 'a', 'title' => '新颜色', 'href' => 'index.php?rule=color_edit', 'class' => 'btn-success', 'icon' => 'plus'));
echo UIViewBlock::area(array('bread' => $bread, 'btn_groups' => $btn_group), 'breadcrumb');
echo UIViewBlock::area(array('title' => '颜色', 'table' => $table, 'result' => $result), 'table');
Example #9
0
            }
        }
        if (count($filters_attribute_add_sql)) {
            Db::getInstance()->exec('INSERT INTO tm_filter (`key`, `value`) VALUES ' . implode(',', $filters_attribute_add_sql));
        }
        if (count($filters_attribute_del)) {
            $ret = Db::getInstance()->exec('DELETE FROM tm_filter_product WHERE `id_filter` IN (SELECT `id_filter` FROM tm_filter WHERE `value` IN (' . implode(',', $filters_attribute_del) . ') AND `key`="id_attribute")');
            if ($ret) {
                Db::getInstance()->exec('DELETE FROM tm_filter WHERE `value` IN (' . implode(',', $filters_attribute_del) . ') AND `key`="id_attribute")');
            }
        }
    }
    /** 2.对filter_product表操作 **/
    Db::getInstance()->exec('DELETE FROM tm_filter_product WHERE id_filter IN (SELECT `id_filter` FROM tm_filter WHERE `key`="id_attribute")');
    Db::getInstance()->exec("INSERT INTO tm_filter_product (`id_filter`, `id_product`) SELECT f.id_filter,pta.id_product FROM tm_product_to_attribute pta\n    LEFT JOIN tm_filter f ON (pta.id_attribute = f.value)\n    WHERE f.key = 'id_attribute'");
} elseif (Tools::G('index') == 'category') {
    /** 1.对filter表操作 **/
    $category = Db::getInstance()->getAllValue('SELECT id_category FROM ' . DB_PREFIX . 'category');
    if (is_array($category)) {
        $filters_category = Db::getInstance()->getAllValue('SELECT `value` FROM ' . DB_PREFIX . 'filter WHERE `key` = "id_category"');
        $filters_category_add_sql = array();
        if (is_array($filters_category)) {
            $filters_category_add = array_diff($category, $filters_category);
            $filters_category_del = array_diff($filters_category, $category);
            if (count($filters_category_add) > 0) {
                foreach ($filters_category_add as $id) {
                    $filters_category_add_sql[] = '("id_category", ' . (int) $id . ')';
                }
            }
        } else {
            foreach ($category as $id) {
Example #10
0
<?php

if (Tools::G('id_feature') > 0) {
    $id_feature = Tools::G('id_feature');
}
if (Tools::P('saveFeatureValue') == 'add' && Tools::P('id_feature') > 0) {
    $featureV = new FeatureValue();
    $featureV->copyFromPost();
    $featureV->add();
    if (is_array($featureV->_errors) and count($featureV->_errors) > 0) {
        $errors = $featureV->_errors;
    } else {
        $_GET['id'] = $featureV->id;
        UIAdminAlerts::conf('商品特征值已添加');
    }
    $id_feature = Tools::P('id_feature');
}
if (isset($_GET['id'])) {
    $id = (int) $_GET['id'];
    $obj = new FeatureValue($id);
    $id_feature = $obj->id_feature;
}
if (Tools::P('saveFeatureValue') == 'edit') {
    if (Validate::isLoadedObject($obj)) {
        $obj->copyFromPost();
        $obj->update();
    }
    if (is_array($obj->_errors) and count($obj->_errors) > 0) {
        $errors = $obj->_errors;
    } else {
        UIAdminAlerts::conf('商品特征值已更新');
Example #11
0
 protected function drawBody()
 {
     global $link;
     $body = '';
     if (count($this->data) == 0) {
         $body = '<tr><td align="center" colspan="' . count($this->header) . '">没有找到有效记录</td></tr>';
     } else {
         foreach ($this->data as $key => $row) {
             $path = !empty($this->parent) ? $row[$this->parent] . '_' : '';
             $path .= $row[$this->identifier];
             $body .= '<tr id="tr_' . $path . '_' . $row['position'] . '" >';
             foreach ($this->header as $head) {
                 $width = isset($head['width']) ? ' width="' . $head['width'] . '" ' : '';
                 $class = isset($head['class']) ? ' class="' . $head['class'] . '" ' : '';
                 if (isset($head['isCheckAll'])) {
                     $body .= '<td><input type="checkbox" name="' . $head['isCheckAll'] . '" value="' . $row[$this->identifier] . '" ></td>';
                 } elseif (isset($head['name'])) {
                     if (isset($head['isImage'])) {
                         $body .= '<td' . $width . $class . '><img src="' . $row[$head['name']] . '" class="img-thumbnail"></td>';
                     } elseif (isset($head['filter']) && $head['filter'] == 'bool') {
                         $body .= '<td' . $width . $class . '><span class="glyphicon glyphicon-' . ($row[$head['name']] == 0 ? 'remove' : 'ok') . ' active-toggle" onclick="setToggle($(this),\'' . $this->className . '\',\'' . $head['name'] . '\',' . $row[$this->identifier] . ')"></span></td>';
                     } elseif ($head['name'] == 'position') {
                         $body .= '<td' . $width . $class . ' id="td_' . $path . '" class="pointer dragHandle center" >';
                         $body .= '<div class="dragGroup"><span aria-hidden="true" class="glyphicon glyphicon-move"></span> <span class="positions">' . $row['position'] . '</span></div>';
                         $body .= '</td>';
                     } elseif (isset($head['edit']) && $head['edit'] == false) {
                         $title = isset($head['color']) ? '<span style="background-color:' . $row['color'] . ';color:white" class="color_field">' . $row[$head['name']] . '</span>' : $row[$head['name']];
                         $body .= '<td' . $width . $class . ' class="pointer">' . $title . '</td>';
                     } else {
                         $rule = isset($head['rule']) ? $head['rule'] : $this->rule . '_edit';
                         $title = isset($head['color']) ? '<span style="background-color:' . $row['color'] . ';color:white" class="color_field">' . $row[$head['name']] . '</span>' : $row[$head['name']];
                         $body .= '<td' . $width . $class . ' onclick="document.location = \'index.php?rule=' . $rule . '&id=' . $row[$this->identifier] . '\'" class="pointer">' . $title . '</td>';
                     }
                 } elseif (isset($head['isAction'])) {
                     //create filter and reset filter buttom group
                     $body .= '<td' . $width . $class . '><div class="btn-group">';
                     switch ($head['isAction'][0]) {
                         case 'view':
                             $body .= '<a class="btn btn-default" href="' . Tools::getLink($row['rewrite']) . '"><span class="glyphicon glyphicon-file" title="查看" aria-hidden="true"></span> 查看</a>';
                             break;
                         case 'edit':
                             $body .= '<a class="btn btn-default" href="index.php?rule=' . $this->rule . '_edit&id=' . $row[$this->identifier] . '"><span class="glyphicon glyphicon-edit" title="编辑" aria-hidden="true"></span> 编辑</a>';
                             break;
                         case 'delete':
                             $body .= '<a class="btn btn-default" href="index.php?rule=' . $this->rule . ($this->child ? '&id=' . Tools::G('id') : '') . '&delete=' . $row[$this->identifier] . '" onclick="return confirm(\'你确定要删除?\')"><span class="glyphicon glyphicon-trash" title="删除" aria-hidden="true"></span> 删除</a>';
                             break;
                     }
                     if (count($head['isAction']) == 1) {
                         $body .= '</div></td>';
                         continue;
                     }
                     $body .= '<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="caret"></span><span class="sr-only">操作</span></button>';
                     $body .= '<ul class="dropdown-menu table-action-dropdown-menu">';
                     foreach ($head['isAction'] as $key => $action) {
                         if ($key == 0) {
                             continue;
                         }
                         if ($action == 'view') {
                             $body .= '<li><a href="' . $link->getPage($this->className . 'View', $row[$this->identifier]) . '" target="_blank"><span class="glyphicon glyphicon-file" title="查看" aria-hidden="true"></span> 查看</a></li>';
                         }
                         if ($action == 'edit') {
                             $body .= '<li><a href="index.php?rule=' . $this->rule . '_edit&id=' . $row[$this->identifier] . '"><span class="glyphicon glyphicon-edit" title="编辑" aria-hidden="true"></span> 编辑</a></li>';
                         }
                         if ($action == 'delete') {
                             $body .= '<li><a href="index.php?rule=' . $this->rule . ($this->child ? '&id=' . Tools::G('id') : '') . '&delete=' . $row[$this->identifier] . '" onclick="return confirm(\'你确定要删除?\')"><span class="glyphicon glyphicon-trash" title="删除" aria-hidden="true"></span> 删除</a></li>';
                         }
                     }
                     $body .= '</ul></div></td>';
                 }
             }
             $body .= '</tr>';
         }
     }
     return '<tbody>' . $body . '</tbody>';
 }
Example #12
0
    <div class="<?php 
echo isset($data['class']) ? $data['class'] : 'col-md-12';
?>
">
        <div class="panel panel-default">
            <div class="panel-heading">
                <span class="badge"><?php 
echo $data['result']['total'];
?>
</span> <?php 
echo $data['title'];
?>
            </div>
            <div class="panel-body">
                <form class="form" method="post" action="index.php?rule=<?php 
echo isset($data['action']) ? $data['action'] : Tools::G('rule');
?>
">
                    <?php 
//config table options
$data['table']->data = $data['result']['items'];
echo $data['table']->draw();
?>
                    <div class="row">
                        <div class="col-md-4">
                            <input type="hidden" value="<?php 
echo $data['table']->token;
?>
" name="token">
                            <?php 
if (isset($data['btn_groups']) && count($data['btn_groups']) > 0) {
Example #13
0
<?php

if (Tools::G('id_attribute_group') > 0) {
    $id_attribute_group = Tools::G('id_attribute_group');
}
if (Tools::P('saveAttribute') == 'add' && Tools::P('id_attribute_group') > 0) {
    $attribute = new Attribute();
    $attribute->copyFromPost();
    $attribute->add();
    if (is_array($attribute->_errors) and count($attribute->_errors) > 0) {
        $errors = $attribute->_errors;
    } else {
        $_GET['id'] = $attribute->id;
        UIAdminAlerts::conf('属性值已添加');
    }
    $id_attribute_group = Tools::P('id_attribute_group');
}
if (isset($_GET['id'])) {
    $id = (int) $_GET['id'];
    $attribute = new Attribute($id);
    $id_attribute_group = $attribute->id_attribute_group;
}
if (Tools::P('saveAttribute') == 'edit') {
    if (Validate::isLoadedObject($attribute)) {
        $attribute->copyFromPost();
        $attribute->update();
    }
    if (is_array($attribute->_errors) and count($attribute->_errors) > 0) {
        $errors = $attribute->_errors;
    } else {
        UIAdminAlerts::conf('属性值已更新');
Example #14
0
<?php

include_once dirname(__FILE__) . "/../config/init.php";
/**
 * 处理各种taggle请求
 */
if (isset($_GET['toggle'])) {
    $fields = array('Product' => array('active', 'in_stock', 'is_new', 'is_sale', 'is_top'), 'Category' => array('active'), 'User' => array('active'), 'Brand' => array('active'), 'OrderStatus' => array('send_mail'), 'CMS' => array('active', 'is_top'), 'Country' => array('need_state', 'active'));
    $key = Tools::G('key');
    $object = Tools::G('toggle');
    $id = Tools::G('id');
    if (isset($fields[$object]) && in_array($key, $fields[$object])) {
        $entity = new $object($id);
        if ($entity->toggle($key)) {
            die(json_encode(array("status" => "YES")));
        }
    }
    die(json_encode(array("status" => "NO")));
}
/**
 * ajax动态状态国家下的省/州
 */
if (isset($_GET['ajaxStates']) and isset($_GET['id_country'])) {
    $states = Db::getInstance()->getAll('
	SELECT s.id_state, s.name
	FROM ' . DB_PREFIX . 'state s
	LEFT JOIN ' . DB_PREFIX . 'country c ON (s.`id_country` = c.`id_country`)
	WHERE s.id_country = ' . (int) Tools::getRequest('id_country') . ' AND s.active = 1 AND c.`need_state` = 1
	ORDER BY s.`name` ASC');
    if (is_array($states) and !empty($states)) {
        $list = '';