public function merchandiseManagEditAction()
 {
     $schoolId = $this->getCurrentSchoolId();
     $this->getWebStatus($schoolId);
     $userId = $this->loginUser->uid;
     $this->getNoCommentSum($schoolId, $userId);
     $this->isSchoolManage($schoolId, $userId);
     $mid = $this->getInput('id');
     $shopId = $this->getInput('shopid');
     if ($this->getInput('type', 'post') === 'do') {
         $merchandiseId = $this->getInput('id', 'request');
         list($foodName, $price, $currentprice, $unit, $remainder, $description, $merchandisedescription, $descriptionurl, $tag, $needPackingPrice, $willRecommend, $isActive, $isStar, $sysTags) = $this->getInput(array('foodname', 'price', 'currentprice', 'unit', 'remainder', 'description', 'merchandisedescription', 'descriptionurl', 'choosenTagid', 'needPackingPrice', 'willRecommend', 'isActive', 'isStar', 'systags'), 'post');
         $sysTagList = explode('||', $sysTags);
         $r = $this->_getMerchandiseDs()->deleteMerchandiseTag($merchandiseId);
         if (!empty($sysTagList[0])) {
             foreach ($sysTagList as $key => $value) {
                 if (!empty($value)) {
                     $dm = new App_Merchandise_Tag_Dm();
                     $dm->setMid($merchandiseId)->setTid($value);
                     $this->_getMerchandiseDs()->addMerchandiseTag($dm);
                 }
             }
         }
         $dm = new App_Merchandise_Dm();
         $dm->setMerchandiseName($foodName)->setPrice($price)->setCurrentPrice($currentprice)->setNeedPackingPrice($needPackingPrice)->setUnit($unit)->setRemainder($remainder)->setActive($isActive)->setIsStar($isStar)->setRecommend($willRecommend)->setDescription($description)->setMerchandiseDescription($merchandisedescription)->setDescriptionUrl($descriptionurl)->setTagId($tag)->setLastUpdateTime(Pw::getTime());
         $result = $this->_getMerchandiseDs()->update($merchandiseId, $dm);
         if ($result == 1) {
             $this->showMessage("更新成功");
         } else {
             $this->showError("更新失败,请联系管理员");
         }
         return;
     }
     $myMenus = $this->_getMyOrderDS()->getMyMenus($schoolId, $this->loginUser->uid);
     $merchandiseId = $this->getInput('id', 'request');
     $merchandise = $this->_getMerchandiseDs()->getMerchandiseById($merchandiseId);
     $this->setOutput($merchandise, 'merchandise');
     $tagList = $this->_getTagDs()->getTagsByShopId($shopId, true);
     $this->setOutput($tagList, 'tagList');
     //set seleted system tag for merchandise
     $selectedSysTagList = $this->_getMerchandiseDs()->getMerchandiseTagsByMid($merchandiseId);
     $sysTagList = $this->_getTagDs()->getSysTags();
     $sysTagList = array_values($sysTagList);
     foreach ($sysTagList as $key => $sysTag) {
         $sysTagList[$key]['selected'] = "";
         foreach ($selectedSysTagList as $selectedTag) {
             if ($sysTag['id'] == $selectedTag['tid']) {
                 $sysTagList[$key]['selected'] = "selected";
             }
         }
     }
     $this->setOutput($sysTagList, 'sysTagList');
     $this->setOutput($myMenus, 'myMenus');
     $this->setOutput($schoolId, 'schoolId');
 }
Esempio n. 2
0
 /**
  * add record
  *
  * @param App_Merchandise_Tag_Dm $dm
  * @return multitype:|Ambigous <boolean, number, string, rowCount>
  */
 public function addMerchandiseTag(App_Merchandise_Tag_Dm $dm)
 {
     if (true !== ($r = $dm->beforeAdd())) {
         return $r;
     }
     return $this->loadMerchandiseTagDao()->add($dm->getData());
 }