我有一张用于办公室部门之间发票跟踪的表格。一旦我注册发票,就会将交易插入到表中。我转发到后勤办公室并插入另一笔交易。在表中,我有 currentLocationId、nextlocationId、timein、timeout、action。当我转发发票时,我不会更新之前注册发票的记录,但是一旦我转发了发票,我就需要它退出队列。请记住,注册的初始事务是完整的,没有更新,我如何在 YII 模型中过滤以仅获取已注册但尚未转发的记录?
以下是我的模型搜索。
public function showPending($id)
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->with = array('invoices');
$criteria->together = true;
$criteria->compare('InvoiceTrackingID',$this->InvoiceTrackingID);
$criteria->compare('invoices.TrackingCode',$this->TrackingCode);
$criteria->compare('TimeInStamp',$this->TimeInStamp,true);
$criteria->compare('TimeOutStamp',$this->TimeOutStamp,true);
$criteria->compare('Comments',$this->Comments,true);
$criteria->compare('CurrentUnitLocationID',$this->CurrentUnitLocationID = $id); // see if the invoice is in your unit location
$criteria->compare('UserID',$this->UserID);
$criteria->compare('TrackingActionID',$this->TrackingActionID = 2); // fetch only invoices whose action was to forward to display
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}