Hi mdomba,
View:
<div class="form">
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'sale-form',
'enableClientValidation' => true,
'enableAjaxValidation' => false,
'clientOptions' => array(
'validateOnSubmit' => true,
),
));
?>
<table border="1">
<tr>
<td>
<?php echo $form->labelEx($model, 'machine_tag'); ?>
</td>
<td>
<?php echo $form->dropDownList($model, 'machine_tag', $model->getMachineOptions(), array('empty' => '--Please Select--')); ?>
<?php echo $form->error($model, 'machine_tag'); ?>
</td>
</tr>
<td colspan="4">
<?php
$this->widget('zii.widgets.jui.CJuiButton', array(
'buttonType' => 'submit',
'name' => 'btnSubmit',
'value' => 'Submit',
'caption' => Yii::t('ui', 'View'),
));
?>
</td>
</tr>
</table>
<?php $this->endWidget(); ?>
</div><!-- form -->
<?php
if($model->getProductTarget()->totalItemCount > 0)
$this->widget('zii.widgets.grid.CGridView', array(
//'id' => 'detail-grid',
'dataProvider' => $model->getProductTarget(),
//'filter' => $model,
'columns' => array(
array(
'name' => 'description',
'header' => t("sales", "Product"),
),
array(
'name' => 'total',
'header' => t("sales", "Total Sales"),
),
),
));
}
?>
Controller:
public function actionProduct_target()
{
$model = new SaleForm('getProductTarget');
// collect user input data
if(isset($_POST['SaleForm']))
{
$model->attributes = $_POST['SaleForm'];
}
$this->render('product_target', array(
'model' => $model,
));
}
Model:
public function getProductTarget()
{
$sql = "";
$count = 0;
// collect user input data
if(isset($_POST['SaleForm']))
{
query..
}
return new CSqlDataProvider($sql, array(
'pagination' => array(
'pageSize' => 5,
),
));
}
Please helps me… Any problem inside?