public function displayMain() { global $smarty, $link, $cookie; $errors = false; if (!$cookie->logged || !User::checkPassword($cookie->id_user, $cookie->passwd)) { Tools::redirect($link->getPage('userView')); } $referer = Tools::Q('referer') ? $link->getPage(Tools::Q('referer')) : $link->getPage('MyAddressesView'); if ($id_address = Tools::Q('id')) { $address = new Address((int) $id_address); if (Tools::isSubmit('saveAddress')) { $address->copyFromPost(); if ($address->update()) { Tools::redirect($referer); } else { $errors = $address->_errors; } } $smarty->assign('address', $address); } elseif (Tools::isSubmit('saveAddress')) { $address = new Address(); $address->copyFromPost(); $address->id_user = $cookie->id_user; if ($address->add()) { Tools::redirect($referer); } else { $errors = $address->_errors; } } $countrys = Country::loadData(1, 1000, 'position', 'asc', array('active' => true)); $smarty->assign(array('referer' => Tools::Q('referer'), 'countrys' => $countrys, 'errors' => $errors)); return $smarty->fetch('address.tpl'); }
public function displayMain() { global $smarty, $link; $errors = array(); if (Tools::isSubmit('CreateUser')) { if (!Validate::isEmail(Tools::getRequest('email')) || User::userExists(Tools::getRequest('email'))) { $errors[] = 'The email is invalid or an account is already registered with this e-mail!'; } elseif (empty($_POST['passwd'])) { $errors[] = 'The password is empty!'; } else { $user = new User(); $user->copyFromPost(); $user->active = 1; if ($user->add()) { $address = new Address(); $address->copyFromPost(); $address->id_user = $user->id; $address->is_default = 1; if ($address->add()) { $user->logined(array('id_address' => $address->id)); if (Tools::getRequest("step") == 2) { Tools::redirect($link->getPage('CheckoutView')); } else { Tools::redirect($link->getPage('MyaccountView')); } return; } else { $errors = $address->_errors; } } else { $errors = $user->_errors; } } } $countrys = Country::loadData(1, 500, null, null, array('active' => 1)); $smarty->assign(array('id_default_country' => Configuration::get('TM_DEFAULT_COUNTRY_ID'), 'countrys' => $countrys, 'step' => Tools::getRequest("step"), 'errors' => $errors)); return $smarty->fetch('join.tpl'); }
if ($id_country = Tools::P('TM_DEFAULT_COUNTRY_ID')) { Configuration::updateValue('TM_DEFAULT_COUNTRY_ID', $id_country); } UIAdminAlerts::conf('配置已更新'); } 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' => 'button', 'title' => '保存', 'id' => 'save-base-form', 'class' => 'btn-success', 'icon' => 'save')); echo UIViewBlock::area(array('bread' => $bread, 'btn_groups' => $btn_group), 'breadcrumb'); ?> <script language="javascript"> $("#save-base-form").click(function(){ $("#base-form").submit(); }) </script> <?php $form = new UIAdminEditForm('post', 'index.php?rule=base', 'form-horizontal', 'base-form'); $result = Country::loadData(1, 500); $countrys = array(); foreach ($result['items'] as $country) { $countrys[$country['id_country']] = $country['name']; } $form->items = array('TM_SHOP_NAME' => array('title' => '网站名称', 'type' => 'text', 'value' => Configuration::get('TM_SHOP_NAME')), 'TM_SHOP_DOMAIN' => array('title' => '网站域名', 'type' => 'text', 'value' => Configuration::get('TM_SHOP_DOMAIN')), 'TM_DEFAULT_COUNTRY_ID' => array('title' => '默认国家', 'type' => 'select', 'value' => Configuration::get('TM_DEFAULT_COUNTRY_ID'), 'option' => $countrys), 'TM_SHOP_EMAIL' => array('title' => '邮箱地址', 'type' => 'text', 'value' => Configuration::get('TM_SHOP_EMAIL')), 'TM_PRODUCTS_PER_PAGE' => array('title' => '每页显示数量', 'type' => 'text', 'value' => Configuration::get('TM_PRODUCTS_PER_PAGE')), 'TM_PRODUCTS_PER_PAGE_LIST' => array('title' => '允许每页显示', 'type' => 'text', 'value' => Configuration::get('TM_PRODUCTS_PER_PAGE_LIST'), 'info' => '以逗号分隔,最好为每页显示的数量的公倍数.如:8,24,40'), 'saveBase' => array('type' => 'hidden', 'value' => 'update')); echo UIViewBlock::area(array('col' => 'col-md-12', 'title' => '编辑', 'body' => $form->draw()), 'panel');
} elseif (Tools::isSubmit('subActiveON') or Tools::isSubmit('subActiveOFF')) { $select_cat = Tools::getRequest('categoryBox'); $action = Tools::isSubmit('subActiveON') ? 1 : 0; $object = new Country(); if (is_array($select_cat)) { if ($object->statusSelection($select_cat, $action)) { UIAdminAlerts::conf('国家已更新'); } } } echo UIAdminDndTable::loadHead(); $table = new UIAdminDndTable('country', 'Country', 'id_country'); $table->addAttribte('id', 'country'); $table->header = array(array('sort' => false, 'isCheckAll' => 'itemsBox[]', 'name' => 'id_country'), array('name' => 'id_country', 'title' => 'ID', 'filter' => 'string'), array('name' => 'name', 'title' => '国家', 'filter' => 'string'), array('name' => 'need_state', 'title' => '省/州', 'filter' => 'bool'), array('name' => 'active', 'title' => '状态', 'filter' => 'bool'), array('name' => 'position', 'title' => '排序'), array('sort' => false, 'title' => '操作', 'class' => 'text-right', 'isAction' => array('edit', 'delete'))); $filter = $table->initFilter(); $orderBy = isset($_GET['orderby']) ? Tools::G('orderby') : 'position'; $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 = Country::loadData($p, $limit, $orderBy, $orderWay, $filter); 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=country_edit', 'class' => 'btn-success', 'icon' => 'plus')); echo UIViewBlock::area(array('bread' => $bread, 'btn_groups' => $btn_group), 'breadcrumb'); $btn_group = array(array('type' => 'button', 'title' => '批量删除', 'confirm' => '你确定要删除选中项?', 'name' => 'deleteItems', 'class' => 'btn-danger', 'icon' => 'remove')); echo UIViewBlock::area(array('title' => '国家列表', 'table' => $table, 'result' => $result, 'limit' => $limit, 'btn_groups' => $btn_group), 'table');