示例#1
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Reports::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('phrase', 'The requested page does not exist.'));
     }
     return $model;
 }
            <th>
                From Date
            </th>
            <th>
                To Date
            </th>
            <th colspan="2">
                Description
            </th>
        <?php 
}
?>

    </tr>
    <?php 
foreach (Reports::model()->findAll(array('condition' => 'type=:type', 'params' => array(':type' => $type))) as $report) {
    ?>
            <tr>
                <td>
                    <?php 
    echo CHtml::link('<button class="btn btn-default">
                        <span class="btn-label-style">Edit</span>
                        </button>', array('update', 'id' => $report->id));
    ?>
                </td>
                <td>
                    <?php 
    echo CHtml::link('<button class="btn btn-default">
                        <span class="btn-label-style">View</span>
                        </button>', array('view', 'id' => $report->id));
    ?>
示例#3
0
 public function reportPost($attr)
 {
     $check = Reports::model()->findByAttributes(array('post_id' => $attr['post_id']));
     if ($check) {
         return 1;
     } else {
         $model = new Reports();
         $model->setAttributes($attr);
         $model->created_at = time();
         $model->status = 0;
         $model->updated_at = time();
         // $model->type = Yii::app()->params['USER_REPORT'];
         $rel = new UserPostRelationship();
         $rel->user_id = $attr['from'];
         $rel->post_id = $attr['post_id'];
         $rel->created_at = time();
         $rel->updated_at = time();
         $rel->type = Yii::app()->params['USER_REPORT'];
         if ($model->save(FALSE) && $rel->save(FALSE)) {
             return 2;
         }
     }
     return 3;
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Reports::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Phrase::trans(193, 0));
     }
     return $model;
 }