/**
  * 编辑 资源分类
  */
 function actionCategoryEdit()
 {
     $this->_pathway->addStep('编辑资源库分类');
     $id = $this->_context->id;
     $category = Category::find()->getById($id);
     if ($category->isNewRecord()) {
         return "{msg:'该记录不存在'}";
     }
     $form = new Form_Category(url('admin::dictmanager/categoryEdit'));
     $form->add(QForm::ELEMENT, 'id', array('_ui' => 'hidden'));
     if ($this->_context->isPOST() && $form->validate($_POST)) {
         try {
             //修改并保存数据
             $category->changeProps($form->values());
             $category->save();
             return "{id:'{$id}', msg:'编辑成功'}";
         } catch (QDB_ActiveRecord_ValidateFailedException $ex) {
             $form->invalidate($ex);
         }
     } else {
         if (!$this->_context->isPOST()) {
             $form->import($category);
         }
     }
     $this->_view['form'] = $form;
 }
 public function updatecategoryAction()
 {
     global $mySession;
     $db = new Db();
     $categoryId = $this->getRequest()->getParam('categoryId');
     $this->view->categoryId = $categoryId;
     $catData = $db->runQuery("select * from " . SERVICE_CATEGORIES . " where cat_id='" . $categoryId . "'");
     $this->view->catImage = $catData[0]['cat_img_path'];
     $this->view->pageHeading = "Edit Category";
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest();
         $myform = new Form_Category($categoryId);
         if ($myform->isValid($request->getPost())) {
             $dataForm = $myform->getValues();
             $myObj = new Services();
             $Result = $myObj->UpdateCategory($dataForm, $categoryId);
             if ($Result == 1) {
                 $mySession->errorMsg = "Coupon Category Updated updated successfully.";
                 $this->_redirect('services/categories');
             } else {
                 $mySession->errorMsg = "Category name you entered is already exists.";
                 $this->view->myform = $myform;
                 $this->render('editcategory');
             }
         } else {
             $this->view->myform = $myform;
             $this->render('editcategory');
         }
     } else {
         $this->_redirect('services/editcategory/categoryId/' . $categoryId);
     }
 }
 public function savecategoryAction()
 {
     global $mySession;
     $db = new Db();
     $this->view->pageHeading = "Add New Category";
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest();
         $myform = new Form_Category();
         if ($myform->isValid($request->getPost())) {
             $dataForm = $myform->getValues();
             $myObj = new classified();
             $Result = $myObj->SaveCategory($dataForm);
             if ($Result == 1) {
                 $mySession->errorMsg = "Classified Category added successfully.";
                 $this->_redirect('classified/index');
             } else {
                 $mySession->errorMsg = "Category name you entered is already exists.";
                 $this->view->myform = $myform;
                 $this->render('addcategory');
             }
         } else {
             $this->view->myform = $myform;
             $this->render('addcategory');
         }
     } else {
         $this->_redirect('classified/addcategory');
     }
 }
Example #4
0
 public function updatecategoryAction()
 {
     global $mySession;
     $db = new Db();
     $catId = $this->getRequest()->getParam('catId');
     $this->view->catId = $catId;
     $this->view->pageHeading = "Edit Category";
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest();
         $myform = new Form_Category($catId);
         if ($myform->isValid($request->getPost())) {
             $dataForm = $myform->getValues();
             $myObj = new Pages();
             $Result = $myObj->UpdateCategory($dataForm, $catId);
             if ($Result == 1) {
                 $mySession->errorMsg = "Category updated successfully.";
                 $this->_redirect('pages/managecategory');
             } else {
                 $mySession->errorMsg = "Category name you entered already exists.";
                 $this->view->myform = $myform;
                 $this->render('editcategory');
             }
         } else {
             $this->view->myform = $myform;
             $this->render('editcategory');
         }
     } else {
         $this->_redirect('pages/editcategory/catId/' . $catId);
     }
 }