/** * Get one last Document's note * @param $docid * @return array */ public static function getLastNoteById($docid) { $note = new Notes(); $condition = new CDbCriteria(); $condition->condition = "Client_ID='" . Yii::app()->user->clientID . "'"; $condition->addCondition("Document_ID = '" . $docid . "'"); $condition->addCondition("Company_ID='0'"); $condition->order = "Created DESC"; $ap_note = $note->find($condition); if ($ap_note) { $comment = $ap_note->Comment; } else { $comment = ''; } return $comment; }
/** * Get last AP's notes * @param $apList * @return array */ public static function getAPsNotes($apList) { $notes = array(); foreach($apList as $ap) { $note = new Notes(); $condition = new CDbCriteria(); $condition->condition = "Client_ID='" . Yii::app()->user->clientID . "'"; $condition->addCondition("Document_ID = '" . $ap->Document_ID . "'"); $condition->addCondition("Company_ID='0'"); $condition->order = "Created DESC"; $ap_note = $note->find($condition); if ($ap_note) { $comment = $ap_note->Comment; $notes[$ap->AP_ID] = $comment; } else { $notes[$ap->AP_ID] = ''; } } return $notes; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // delete $notes = Notes::find($id); $notes->delete(); // redirect Session::flash('message', 'Successfully deleted the note!'); return Redirect::to('notes'); }