Esempio n. 1
0
 public function editAction()
 {
     $choosenSchoolid = $this->getInput('choosenSchoolid', 'request');
     $choosenProvinceid = $this->getInput('choosenProvinceid', 'request');
     $id = $this->getInput('id', 'request');
     if ($this->getInput('type', 'post') === 'do') {
         //user click submit
         //1. get choosen schoolid
         $areaName = $this->getInput('areaname', 'post');
         if ($id <= 0) {
             $this->showError('无效的id, 请核实' . $id . $areaName . $choosenSchoolid);
             return;
         }
         if (empty($areaName)) {
             $this->showError('请填写学校的区域的名字');
             return;
         }
         //check if has duplicate name in database
         $hasDuplicate = $this->_getSchoolAreaDs()->checkDuplicateName($id, $choosenSchoolid, $areaName);
         if ($hasDuplicate) {
             $this->showError('此区域的名字在该学校下已经被使用了');
             return;
         }
         $dm = new App_SchoolArea_Dm();
         $dm->setArea($areaName)->setSchool($choosenSchoolid);
         $this->_getSchoolAreaDs()->updateArea($id, $dm);
         $this->showMessage('更新成功');
     } else {
         $id = $this->getInput('id', 'request');
         $this->setOutput($id, 'id');
         $areaInfo = $this->_getSchoolAreaDs()->getByid($id);
         if (count($areaInfo) > 0) {
             $this->setOutput($areaInfo[0], 'areainfo');
         }
         $allSchool = $this->_getSchoolDs()->getSchoolByAreaidAndTypeid($choosenProvinceid, 3);
         $this->setOutput($allSchool, 'allSchool');
     }
     $this->setOutput($choosenProvinceid, 'choosenProvinceid');
     $this->setOutput($choosenSchoolid, 'choosenSchoolid');
 }
Esempio n. 2
0
 public function updateArea($id, App_SchoolArea_Dm $dm)
 {
     return $this->_loadDao()->update($id, $dm->getData());
 }