示例#1
0
 public function getflowlistAction()
 {
     $flow = new Admin_Model_Flow();
     $data = array();
     $dataFlow = $flow->fetchAll("state = 1", array('CONVERT( flow_name USING gbk )'))->toArray();
     for ($i = 0; $i < count($dataFlow); $i++) {
         $data[$i]['id'] = $dataFlow[$i]['id'];
         $data[$i]['name'] = $dataFlow[$i]['flow_name'];
     }
     echo Zend_Json::encode($data);
     exit;
 }
示例#2
0
 /**
  * @abstract    保存
  * @return      null
  */
 public function saveAction()
 {
     // 返回值数组
     $result = array('success' => true, 'result' => true, 'info' => '保存成功');
     $request = $this->getRequest()->getParams();
     $val = (object) $request;
     $id = $val->id;
     $flow = new Admin_Model_Flow();
     if ($id) {
         // 检查是否存在
         if ($flow->fetchAll("id != " . $id . " and flow_name = '" . $val->flow_name . "'")->count() > 0) {
             $result['result'] = false;
             $result['info'] = "流程“" . $val->flow_name . "”已经存在";
             echo Zend_Json::encode($result);
             exit;
         }
         $data = array('flow_name' => $val->flow_name, 'description' => $val->description, 'remark' => $val->remark, 'step_ids' => $val->json);
         $where = "id=" . $id;
         try {
             $flow->update($data, $where);
         } catch (Exception $e) {
             $result['result'] = false;
             $result['info'] = $e->getMessage();
             echo Zend_Json::encode($result);
             exit;
         }
     } else {
         // 检查是否存在
         if ($flow->fetchAll("flow_name = '" . $val->flow_name . "'")->count() > 0) {
             $result['result'] = false;
             $result['info'] = "流程“" . $val->flow_name . "”已经存在";
             echo Zend_Json::encode($result);
             exit;
         }
         $data = array('flow_name' => $val->flow_name, 'description' => $val->description, 'remark' => $val->remark, 'step_ids' => $val->json);
         try {
             $flow->insert($data);
         } catch (Exception $e) {
             $result['result'] = false;
             $result['info'] = $e->getMessage();
             echo Zend_Json::encode($result);
             exit;
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }