12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- include APPPATH.'/models/Model_flow_status.php';
- class Model_Flow extends Lin_Model
- {
- public $allStatus;
- // const STATUS_PROCESSING = 0;//待处理
- // const STATUS_COMPLETED = 1;//已完成
- // const STATUS_CANCEL = -1;//取消
- // const STATUSCLOSE = -2;//关闭
- function __construct(){
- parent::__construct();
- $this->load->database();
- $this->table = 'flow';
- $this->load_table('flow');
- $this->allStatus=new Model_Flow_status();
- }
-
- public function allStatus()
- {
- return [
-
- ];
- }
- /**
- * 此状态的下一个状态
- * @param Status $status
- * @return mixed
- */
- public function getNextStatus($status)
- {
- $flowStatus = $this->allStatus->find('`code`="'.$status.'"');
- return $this->allStatus->find(" `flow_id` =".$flowStatus['flow_id']." and `order` >" . $flowStatus['order'],"*",'order');
- }
- public function getCloseStatus($status)
- {
- return $this->allStatus->find('`flow_id`='.$status['flow_id'].' and `order` = '.Model_Flow_status::STATUSCLOSE.'','*','`order`');
- }
- public function getCancelStatus($status)
- {
- return $this->allStatus->find('`flow_id`='.$status['flow_id'].' and `order` = '.Model_Flow_status::STATUS_CANCEL.'','*','`order`');
- }
- /**
- * 获取初始状态
- * @return mixed
- */
- public function getFirstStatus($flow)
- {
- return $this->allStatus->find('`flow_id`='.$flow['id'].' and `order` >= 0','*','`order`');
- }
- /**
- * 获取最终状态
- * @return mixed
- */
- public function getFinalStatus($status)
- {
- return $this->allStatus->find('`flow_id`='.$status['flow_id'].' and `order` >= 0','*','`order` desc');
- }
- // public function process()
- // {
- // return $this->hasMany(Process::class, 'flow_id');
- // }
- }
|