Hi Everyone!
I am loving Yii and am getting more of an understanding of the best way to use it each day. Right now I am developing a learning application that manages customers, computers, and work orders. Figured it would be fun !
I am wondering if someone can point me towards a tutorial or code reference that pulls the data necessary onto one screen.
Here is a picture of what I want:
The problem is is that the database does not have the customer_id floating around everywhere (maybe is should?).
Here is the schema:
Here is my views\customers\view.php
<h1>Computers</h1>
<?php $this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$computerDataProvider,
)); ?>
<h1>Previous Work Orders</h1>
<?php $this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$workorderDataProvider,
)); ?>
<h1>Previous Phone Calls</h1>
<?php $this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$phonecallsDataProvider,
)); ?>
controllers\CustomersController.php
public function actionView($id)
{
$computerDataProvider = new CActiveDataProvider('Computers', array(
'criteria'=>array(
'condition'=>'customer_id=:customerId',
'params'=>array(':customerId'=>$this->loadModel($id)->id),
),
'pagination'=>array(
'pageSize'=>5,
),
));
$workorderDataProvider = new CActiveDataProvider('Workorder', array(
'criteria'=>array(
'condition'=>'computer_id=:computerid',
'params'=>array(':computerid'=>$this->loadModel($id)->id),
),
));
$phonecallsDataProvider = new CActiveDataProvider('Phonecalls', array(
'criteria'=>array(
'condition'=>'customer_id=:cid',
'params'=>array(':cid'=>$this->loadModel($id)->id),
),
));
$this->render('view',array(
'model'=>$this->loadModel($id),
'computerDataProvider'=>$computerDataProvider,
'workorderDataProvider'=>$workorderDataProvider,
'phonecallsDataProvider'=>$phonecallsDataProvider,
));
}