1 <?php
2
3 namespace Docoflow\Models;
4
5 use Yii;
6 use CDbCriteria;
7 use CActiveRecord;
8 use CActiveDataProvider;
9
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
25 class WorkflowStateActivity extends CActiveRecord
26 {
27 28 29 30 31
32 public function getDbConnection()
33 {
34 Yii::app()->container->bindIf('docoflow.connection', function ($container) {
35 return Yii::app()->db;
36 });
37
38 return Yii::app()->container->make('docoflow.connection');
39 }
40
41 42 43 44 45 46 47
48 public static function model($className = __CLASS__)
49 {
50 return parent::model($className);
51 }
52
53 54 55
56 public function tableName()
57 {
58 return '"workflow_state_activity"';
59 }
60
61 62 63
64 public function rules()
65 {
66
67
68 return array(
69 array('activity_id, state_id, assignor, assignee', 'required'),
70 array('activity_id, state_id, assignor, assignee', 'numerical', 'integerOnly' => true),
71 array('is_failed, is_notification', 'numerical'),
72 array('notification_subject, notification_body', 'length', 'max' => 512),
73
74
75 array('id, activity_id, state_id, assignor, assignee, is_failed, is_notification, notification_subject, notification_body', 'safe', 'on' => 'search'),
76 );
77 }
78
79 80 81
82 public function relations()
83 {
84
85
86 return array(
87 'activity' => [static::BELONGS_TO, WorkflowActivity::class, 'activity_id'],
88 );
89 }
90
91 92 93
94 public function attributeLabels()
95 {
96 return array(
97 'id' => 'ID',
98 'activity_id' => 'Activity',
99 'state_id' => 'State',
100 'assignor' => 'Assignor',
101 'assignee' => 'Assignee',
102 'is_failed' => 'Is Failed',
103 'is_notification' => 'Is Notification',
104 'notification_subject' => 'Notification Subject',
105 'notification_body' => 'Notification Body',
106 );
107 }
108
109 110 111 112 113
114 public function search()
115 {
116
117
118
119 $criteria = new CDbCriteria();
120
121 $criteria->compare('"id"', $this->id);
122 $criteria->compare('"activity_id"', $this->activity_id);
123 $criteria->compare('"state_id"', $this->state_id);
124 $criteria->compare('"assignor"', $this->assignor);
125 $criteria->compare('"assignee"', $this->assignee);
126 $criteria->compare('"is_failed"', $this->is_failed);
127 $criteria->compare('"is_notification"', $this->is_notification);
128 $criteria->compare('"notification_subject"', $this->notification_subject, true);
129 $criteria->compare('"notification_body"', $this->notification_body, true);
130
131 return new CActiveDataProvider($this, array(
132 'criteria' => $criteria,
133 ));
134 }
135 }
136