/**
  *
  * 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 = Materialtype::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     parent::actionIndex();
     $parentmatgroup = new Materialgroup('searchwstatus');
     $parentmatgroup->unsetAttributes();
     // clear any default values
     if (isset($_GET['Parentmatgroup'])) {
         $parentmatgroup->attributes = $_GET['Parentmatgroup'];
     }
     $materialtype = new Materialtype('searchwstatus');
     $materialtype->unsetAttributes();
     // clear any default values
     if (isset($_GET['Materialtype'])) {
         $materialtype->attributes = $_GET['Materialtype'];
     }
     $model = new Materialgroup('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Materialgroup'])) {
         $model->attributes = $_GET['Materialgroup'];
     }
     if (isset($_GET['pageSize'])) {
         Yii::app()->user->setState('pageSize', (int) $_GET['pageSize']);
         unset($_GET['pageSize']);
         // would interfere with pager and repetitive page size change
     }
     $this->render('index', array('model' => $model, 'parentmatgroup' => $parentmatgroup, 'materialtype' => $materialtype));
 }
?>
	<?php 
echo $form->errorSummary($model);
?>

    <div class="row">
		<?php 
echo $form->labelEx($model, 'materialtypeid');
?>
		<?php 
echo $form->hiddenField($model, 'materialtypeid');
?>
	  <input type="text" name="materialtypedescription" id="materialtypedescription" readonly >
    <?php 
$this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'materialtype_dialog', 'options' => array('title' => Yii::t('app', 'Material Type'), 'width' => 'auto', 'autoOpen' => false, 'modal' => true)));
$materialtype = new Materialtype('searchwstatus');
$materialtype->unsetAttributes();
// clear any default values
if (isset($_GET['Materialtype'])) {
    $materialtype->attributes = $_GET['Materialtype'];
}
$this->widget('zii.widgets.grid.CGridView', array('id' => 'materialtype-grid', 'dataProvider' => $materialtype->Searchwstatus(), 'filter' => $materialtype, 'template' => '{summary}{pager}<br>{items}{pager}{summary}', 'columns' => array(array('header' => '', 'type' => 'raw', 'value' => 'CHtml::Button("+",
          array("name" => "send_absschedule",
          "id" => "send_absschedule",
          "onClick" => "$(\\"#materialtype_dialog\\").dialog(\\"close\\"); $(\\"#materialtypedescription\\").val(\\"$data->description\\"); $(\\"#Materialgroup_materialtypeid\\").val(\\"$data->materialtypeid\\");
		  "))'), array('name' => 'materialtypeid', 'visible' => false, 'value' => '$data->materialtypeid', 'htmlOptions' => array('width' => '1%')), 'description')));
$this->endWidget('zii.widgets.jui.CJuiDialog');
echo CHtml::Button('...', array('onclick' => '$.fn.yiiGridView.update("materialtype-grid");$("#materialtype_dialog").dialog("open"); return false;'));
?>
		<?php 
echo $form->error($model, 'materialtypeid');