Model_flow.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. include APPPATH.'/models/Model_flow_status.php';
  3. class Model_Flow extends Lin_Model
  4. {
  5. public $allStatus;
  6. // const STATUS_PROCESSING = 0;//待处理
  7. // const STATUS_COMPLETED = 1;//已完成
  8. // const STATUS_CANCEL = -1;//取消
  9. // const STATUSCLOSE = -2;//关闭
  10. function __construct(){
  11. parent::__construct();
  12. $this->load->database();
  13. $this->table = 'flow';
  14. $this->load_table('flow');
  15. $this->allStatus=new Model_Flow_status();
  16. }
  17. public function allStatus()
  18. {
  19. return [
  20. ];
  21. }
  22. /**
  23. * 此状态的下一个状态
  24. * @param Status $status
  25. * @return mixed
  26. */
  27. public function getNextStatus($status)
  28. {
  29. $flowStatus = $this->allStatus->find('`code`="'.$status.'"');
  30. return $this->allStatus->find(" `flow_id` =".$flowStatus['flow_id']." and `order` >" . $flowStatus['order'],"*",'order');
  31. }
  32. public function getCloseStatus($status)
  33. {
  34. return $this->allStatus->find('`flow_id`='.$status['flow_id'].' and `order` = '.Model_Flow_status::STATUSCLOSE.'','*','`order`');
  35. }
  36. public function getCancelStatus($status)
  37. {
  38. return $this->allStatus->find('`flow_id`='.$status['flow_id'].' and `order` = '.Model_Flow_status::STATUS_CANCEL.'','*','`order`');
  39. }
  40. /**
  41. * 获取初始状态
  42. * @return mixed
  43. */
  44. public function getFirstStatus($flow)
  45. {
  46. return $this->allStatus->find('`flow_id`='.$flow['id'].' and `order` >= 0','*','`order`');
  47. }
  48. /**
  49. * 获取最终状态
  50. * @return mixed
  51. */
  52. public function getFinalStatus($status)
  53. {
  54. return $this->allStatus->find('`flow_id`='.$status['flow_id'].' and `order` >= 0','*','`order` desc');
  55. }
  56. // public function process()
  57. // {
  58. // return $this->hasMany(Process::class, 'flow_id');
  59. // }
  60. }