/** * Manages all models. */ public function actionAdmin() { $model = new OutboundItemsHistory('search'); $model->unsetAttributes(); // clear any default values //for excel. if (isset($_GET['export'])) { header("Content-Type: application/vnd.ms-excel; charset=utf-8"); header("Content-Disposition: inline; filename=\"Outbound Items History " . date("F j, Y") . ".xls\""); $dataProvider = $model->search(); $dataProvider->pagination = False; //$itemModel=Items::model()->findByPk($item_id); ?> <table border="1"> <tr> <th>History_id_item</th> <th>Part number</th> <th>Item name</th> <th>Quantity_moved</th> <th>Current_quantity_in_stock</th> <th>User Name</th> <th>created</th> </tr> <?php //echo "history_id_item \t main_item_id \t quantity_moved \t current_quantity_in_stock \t created \n"; foreach ($dataProvider->data as $data) { echo "<tr>"; echo "<td>" . $data->history_id_item . "</td>"; echo "<td>" . $data->mainItem->part_number; echo "<td>" . $data->mainItem->name . "</td>"; echo "<td>" . $data->quantity_moved . "</td>"; echo "<td>" . $data->current_quantity_in_stock . "</td>"; echo "<td>" . $data->user->username . "</td>"; echo "<td>" . $data->created . "</td>"; echo "</tr>"; //echo $data->history_id_item , "\t", $data->mainItem->name, "\t", $data->quantity_moved, "\t", $data->current_quantity_in_stock, "\t", $data->created, "\n"; } //end of foreach(). ?> </table> <?php Yii::app()->end(); } //end of if(isset()) if (isset($_GET['OutboundItemsHistory'])) { $model->attributes = $_GET['OutboundItemsHistory']; } $this->render('admin', array('model' => $model)); /*original. $model=new OutboundItemsHistory('search'); $model->unsetAttributes(); // clear any default values if(isset($_GET['OutboundItemsHistory'])) $model->attributes=$_GET['OutboundItemsHistory']; $this->render('admin',array( 'model'=>$model, ));*/ }