public function index() { $workTime = new WorkTimeUtil(); if (RequestUtil::isPost()) { $params = RequestUtil::postParams(); $params = array_map(function ($time) { if (!preg_match("~^\\d{2}:\\d{2}:\\d{2}\$~", $time)) { return "{$time}:00"; } else { return $time; } }, $params); $allDay = $workTime->build($params['allDayStart'], $params['allDayEnd']); $morningShift = $workTime->build($params['morningShiftStart'], $params['morningShiftEnd']); $middayShift = $workTime->build($params['middayShiftStart'], $params['middayShiftEnd']); $nightShift = $workTime->build($params['nightShiftStart'], $params['nightShiftEnd']); $workTime->saveWorkTime($allDay, $morningShift, $nightShift, $middayShift); $workTime->getTime(); } list($allDayStart, $allDayEnd) = $workTime->explode($workTime->getAllDay()); list($morningShiftStart, $morningShiftEnd) = $workTime->explode($workTime->getMorningShift()); list($middayShiftStart, $middayShiftEnd) = $workTime->explode($workTime->getMiddayShift()); list($nightShiftStart, $nightShiftEnd) = $workTime->explode($workTime->getNightShift()); $setting = array('allDayStart' => $allDayStart, 'allDayEnd' => $allDayEnd, 'morningShiftStart' => $morningShiftStart, 'morningShiftEnd' => $morningShiftEnd, 'nightShiftStart' => $nightShiftStart, 'nightShiftEnd' => $nightShiftEnd, 'middayShiftStart' => $middayShiftStart, 'middayShiftEnd' => $middayShiftEnd); $this->view('workTimeSetting', array('setting' => $setting)); }
public function updateSlider($sliderId) { if (!$sliderId) { $this->message('ID不能为空!'); } if (RequestUtil::isPost()) { $this->sliderModel->deleteSliderCache(); $params = RequestUtil::postParams(); // href if (!preg_match('~^http[s]?://~', $params['href'])) { $params['href'] = 'http://' . $params['href']; } if ($this->sliderModel->rules()->run()) { $upload = UploadUtil::commonUpload(array('upload/resize_200x200', 'upload/resize_100x100', 'upload/resize_600x600')); if ($upload) { $params['pic'] = $upload; } $returnUrl = 'slider/updateSlider/' . $sliderId; if ((new CurdUtil($this->sliderModel))->update(array('slider_id' => $sliderId), $params)) { $this->message('修改成功!', $returnUrl); } else { $this->message('修改失败!', $returnUrl); } } } $slider = (new CurdUtil($this->sliderModel))->readOne(array('slider_id' => $sliderId, 'disabled' => 0)); if (!$slider) { $this->message('记录不存在或者已被删除!', 'slider/index'); } $this->view('slider/updateSlider', array('slider' => $slider)); }
public function index() { $error = ''; if (RequestUtil::isPost()) { $validate = new ValidateUtil(); $validate->required('user_name'); $validate->required('password'); $validate->required('verify_code'); $params = RequestUtil::postParams(); if ($params['verify_code'] != UserUtil::getVerifyCode()) { $error = '验证码错误!'; } else { if ($validate->run()) { $userModel = new UserModel(); $params['password'] = $userModel->encodePassword($params['password']); $where = array('user_name' => $params['user_name'], 'password' => $params['password']); $user = (new CurdUtil($userModel))->readOne($where, 'user_id desc', '*, user_type+0 as type'); if (!$user) { $error = '登录失败,账号或者密码错误,请重试!'; } else { (new CurdUtil($userModel))->update($where, array('last_login_time' => DateUtil::now())); UserUtil::saveUser($user); if (UserUtil::isAdmin()) { ResponseUtil::redirect(UrlUtil::createBackendUrl('project/index')); } else { ResponseUtil::redirect(UrlUtil::createBackendUrl('beautician/index')); } } } } } $this->load->view('backend/login', array('error' => $error)); }
/** * 增加新用户专享 */ public function addForNewUserProject() { if (RequestUtil::isPost()) { $params = RequestUtil::postParams(); $insertId = (new CurdUtil($this->projectPropertyModel))->create($params); if ($insertId) { $this->message('新增成功!', 'ProjectProperty/projectForNewUserList'); } else { $this->message('新增失败!'); } } $categories = (new CategoryModel())->getAllCategories(); $this->view('projectProperty/forNewUser', array('categories' => $categories)); }
public function addArticle() { if (RequestUtil::isPost()) { if ($this->articleModel->rules()->run()) { $params = RequestUtil::postParams(); $insertId = (new CurdUtil($this->articleModel))->create(array_merge($params, array('create_time' => DateUtil::now()))); if ($insertId) { $this->message('新增文章成功!', 'article/index'); } else { $this->message('新增文章失败!', 'article/index'); } } } $this->view('article/addArticle'); }
/** * 添加店铺 */ public function addShop() { if (RequestUtil::isPost()) { if ($this->shopModel->rules()->run()) { $params = RequestUtil::postParams(); $params['shop_logo'] = UploadUtil::commonUpload(array('upload/resize_200x200', 'upload/resize_100x100')); $insertId = (new CurdUtil($this->shopModel))->create(array_merge($params, array('create_time' => DateUtil::now()))); if ($insertId) { $this->message('新增店铺成功!', 'shop/index'); } else { $this->message('新增店铺失败!', 'shop/index'); } } } $this->view('shop/addShop'); }
public function addUser() { if (RequestUtil::isPost()) { if ($this->userModel->rules()->run()) { $params = RequestUtil::postParams(); unset($params['re_password']); $params['password'] = $this->userModel->encodePassword($params['password']); $insertId = (new CurdUtil($this->userModel))->create(array_merge($params, array('create_time' => DateUtil::now()))); if ($insertId) { $this->message('新增账户成功!', 'user/index'); } else { $this->message('新增账户失败!', 'user/index'); } } } $this->view('user/addUser'); }
public function updateCouponCode($couponCodeId, $limit = '') { if (!$couponCodeId) { $this->message('优惠码不能为空!'); } if (RequestUtil::isPost()) { if ($this->couponCodeModel->rules()->run()) { $params = RequestUtil::postParams(); if ((new CurdUtil($this->couponCodeModel))->update(array('coupon_code_id' => $couponCodeId), $params)) { $this->message('修改优惠码成功!', 'couponCode/updateCouponCode/' . $couponCodeId . "/{$limit}"); } else { $this->message('修改优惠码失败!', 'couponCode/updateCouponCode/' . $couponCodeId . "/{$limit}"); } } } $coupon = $this->couponCodeModel->readOne($couponCodeId); $this->view('couponCode/updateCouponCode', array('coupon' => $coupon, 'limit' => $limit)); }
public function updateCategory($categoryId) { if (!$categoryId) { $this->message('分类ID错误!'); } if (RequestUtil::isPost()) { if ($this->categoryModel->rules()->run()) { $params = RequestUtil::postParams(); $affectedRows = (new CurdUtil($this->categoryModel))->update(array('category_id' => $categoryId), array('category_name' => $params['category_name'], 'order_sort' => $params['order_sort'])); if ($affectedRows > 0) { $this->message('修改分类信息成功!', 'category/index'); } else { $this->message('修改分类信息失败!', 'category/index'); } } } $category = (new CurdUtil($this->categoryModel))->readOne(array('category_id' => $categoryId)); if (!$category) { $this->message('分类不存在!', 'category/index'); } $this->view('category/updateCategory', $category); }
public function updateExchangeGoods($exchangeGoodsId, $limit = '') { if (RequestUtil::isPost()) { if ($this->exchangeGoodsModel->rules()->run()) { $params = RequestUtil::postParams(); $upload = UploadUtil::commonUpload(array('upload/resize_200x200', 'upload/resize_600x600', 'upload/resize_100x100')); if ($upload) { $params['exchange_goods_pic'] = $upload; } if ((new CurdUtil($this->exchangeGoodsModel))->update(array('exchange_goods_id' => $exchangeGoodsId), $params)) { $this->message('修改兑换商品成功!', 'exchangeGoods/updateExchangeGoods/' . $exchangeGoodsId . "/{$limit}"); } else { $this->message('修改兑换商品失败!', 'exchangeGoods/updateExchangeGoods/' . $exchangeGoodsId . "/{$limit}"); } } } $shops = (new ShopModel())->getAllShops(); $exchangeGoods = $this->exchangeGoodsModel->readOne($exchangeGoodsId); if (!$exchangeGoods) { $this->message('兑换商品不存在或者已被删除!', "exchangeGoods/index/{$limit}"); } $this->view('exchangeGoods/updateExchangeGoods', array('exchangeGoods' => $exchangeGoods, 'shops' => $shops, 'limit' => $limit)); }
public function addProject() { if (RequestUtil::isPost()) { if ($this->projectModel->rules()->run()) { $params = RequestUtil::postParams(); $mainProjectId = $params['main_project_id']; unset($params['main_project_id']); $params['project_cover'] = UploadUtil::commonUpload(array('upload/resize_200x200', 'upload/resize_600x600', 'upload/resize_100x100')); $insertId = (new CurdUtil($this->projectModel))->create(array_merge($params, array('create_time' => DateUtil::now()))); // 关联项目 if ($mainProjectId) { (new CurdUtil(new ProjectRelationModel()))->create(array('main_project_id' => $mainProjectId, 'relation_project_id' => $insertId)); } if ($insertId) { $this->message('新增项目成功!', 'project/index'); } else { $this->message('新增项目失败!', 'project/index'); } } } $categories = (new CategoryModel())->getAllCategories(); $shops = (new ShopModel())->getAllShops(); $this->view('project/addProject', array('categories' => $categories, 'shops' => $shops)); }
/** * 修改美容师工作时间 * @param $beauticianId */ public function updateBeauticianWorkTime($beauticianId) { $workTimeUtil = new WorkTimeUtil(); $workTime = $workTimeUtil->beauticianWorkTime; /** * array (size=7) * 'work_type_0' => string '5' (length=1) * 'work_type_1' => string '2' (length=1) * 'work_type_2' => string '5' (length=1) * 'work_type_3' => string '3' (length=1) * 'work_type_4' => string '3' (length=1) * 'work_type_5' => string '2' (length=1) * 'work_type_6' => string '2' (length=1) */ if (RequestUtil::isPost()) { $post = RequestUtil::postParams(); $data = array(); foreach ($post as $key => $value) { if (!preg_match('~^work_type_(\\d+)$~', $key, $matches)) { continue; } else { $w = $matches[1]; $data[$w] = $value; } } // 保持数据 $workTime[$beauticianId] = $data; $workTimeUtil->saveBeauticianWorkTime($workTime); } $workTime = $workTimeUtil->getBeauticianWorkTime(); $beauticianWorkTime = $workTime[$beauticianId]; $timeSetting = $this->timeSetting; $beautician = (new BeauticianModel())->readOne($beauticianId); $this->view('beautician/updateBeauticianWorkTime', array('beauticianWorkTime' => $beauticianWorkTime, 'timeSetting' => $timeSetting, 'beauticianId' => $beauticianId, 'beautician' => $beautician)); }