Hello,
I get the following error when running the code below:
Here is my code (from my model file)
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('id', 'required'),
array('id, user_id, client_id, aircraft_type_id, aircraft_reg_id, aircraft_sn_id, project_priority_id, project_status_id, department_id, doa_role_id, project_type_id, hoa_approval_id, hoa_approval_status_id, hoa_approval_level2_id, hoa_approval_level2_status_id, hoa_approval_level3_id, hoa_approval_level3_status_id, cve_approval_id, cve_approval_status_id, hodo_approval_id, hodo_approval_status_id, caam_approval_id, caam_approval_level2_id, caam_approval_status_id, caam_approval_level2_status_id, updated_user_id', 'numerical', 'integerOnly'=>true),
array('project_no, mod_number, latest_rev, soc_num, caam_officer1_name, caam_officer2_name', 'length', 'max'=>50),
array('mod_tittle, pic', 'length', 'max'=>100),
array('remark, hoa_approval_remark, hoa_approval_level2_remark, hoa_approval_level3_remark, hoa_approval_level4_remark, cve_approval_remark, hodo_approval_remark, caam_approval_remark, caam_approval_level2_remark', 'length', 'max'=>500),
array('project_date, hoa_approval_date, hoa_approval_level2_date, hoa_approval_level3_date, hoa_approval_level4_date, cve_approval_date, hodo_approval_date, caam_approval_date, caam_approval_level2_date, created_time, updated_time', 'safe'),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('id, user_id, project_no, mod_number, project_date, client_id, aircraft_type_id, aircraft_reg_id, aircraft_sn_id, project_priority_id, mod_tittle, latest_rev, pic, soc_num, remark, project_status_id, department_id, doa_role_id, project_type_id, hoa_approval_id, hoa_approval_level2_id, hoa_approval_level3_id, hoa_approval_level4_id, cve_approval_id, hodo_approval_id, caam_approval_id, caam_approval_level2_id, hoa_approval_date, hoa_approval_level2_date, hoa_approval_level3_date, hoa_approval_level4_date, cve_approval_date, hodo_approval_date, caam_approval_date, caam_approval_level2_date, created_time, updated_user_id, updated_time', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'user' => array(self::BELONGS_TO, 'Account', 'user_id'),
'client' => array(self::BELONGS_TO, 'Client', 'client_id'),
'clientStatus' => array(self::BELONGS_TO, 'ClientStatus', 'client_status_id'),
'aircraftRegistration' => array(self::BELONGS_TO, 'AircraftRegistration', 'aircraft_reg_id'),
'aircraftType' => array(self::BELONGS_TO, 'AircraftType', 'aircraft_type_id'),
'aircraftSerielNumber' => array(self::BELONGS_TO, 'AircraftSerielNumber', 'aircraft_sn_id'),
'projectPriority' => array(self::BELONGS_TO, 'ProjectPriority', 'project_priority_id'),
'projectStatus' => array(self::BELONGS_TO, 'ProjectStatus', 'project_status_id'),
'projectApproval' => array(self::BELONGS_TO, 'ProjectApproval', 'project_approval_id'),
'hoaApproval' => array(self::BELONGS_TO, 'Account', 'hoa_approval_id'),
'hoaApproval2' => array(self::BELONGS_TO, 'Account', 'hoa_approval_level2_id'),
'hoaApproval3' => array(self::BELONGS_TO, 'Account', 'hoa_approval_level3_id'),
'hoaApproval4' => array(self::BELONGS_TO, 'Account', 'hoa_approval_level4_id'),
'cveApproval' => array(self::BELONGS_TO, 'Account', 'cve_approval_id'),
'hodoApproval' => array(self::BELONGS_TO, 'Account', 'hodo_approval_id'),
'caamApproval' => array(self::BELONGS_TO, 'Account', 'caam_approval_id'),
'caamApproval2' => array(self::BELONGS_TO, 'Account', 'caam_approval_level2_id'),
'hoaApprovalStatus' => array(self::BELONGS_TO, 'ProjectStatus', 'hoa_approval_status_id'),
'hoaApproval2Status' => array(self::BELONGS_TO, 'ProjectStatus', 'hoa_approval_level2_status_id'),
'hoaApproval3Status' => array(self::BELONGS_TO, 'ProjectStatus', 'hoa_approval_level3_status_id'),
'hoaApproval4Status' => array(self::BELONGS_TO, 'ProjectStatus', 'hoa_approval_level4_status_id'),
'cveApprovalStatus' => array(self::BELONGS_TO, 'ProjectStatus', 'cve_approval_status_id'),
'hodoApprovalStatus' => array(self::BELONGS_TO, 'ProjectStatus', 'hodo_approval_status_id'),
'caamApprovalStatus' => array(self::BELONGS_TO, 'ProjectStatus', 'caam_approval_status_id'),
'caamApproval2Status' => array(self::BELONGS_TO, 'ProjectStatus', 'caam_approval_level2_status_id'),
'projectType' => array(self::BELONGS_TO, 'ProjectType', 'project_type_id'),
'department' => array(self::BELONGS_TO, 'Department', 'department_id'),
'doaRole' => array(self::BELONGS_TO, 'DoaRole', 'doa_role_id'),
'updated_user' => array(self::BELONGS_TO, 'User', 'updated_user_id'), // updated user log
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'user_id' => 'User',
'project_date' => 'Project Date',
'project_no' => 'Project No',
'mod_number' => 'Modification Number',
'client_id' => 'Client Name',
'aircraft_type_id' => 'Aircraft Type',
'aircraft_reg_id' => 'Aircraft Registration',
'aircraft_sn_id' => 'Aircraft Serial Number',
'project_priority_id' => 'Project Priority',
'mod_tittle' => 'Modification Tittle',
'latest_rev' => 'Latest Review',
'pic' => 'Person in Charge',
'soc_num' => 'SoC No',
'remark' => 'Remark',
'project_status_id' => 'Project Status',
'department_id' => 'Department',
'doa_role_id' => 'Doa Role',
'hoa_approval_id' => 'Approval Name',
'hoa_approval_date' => 'Approval Date',
'hoa_approval_status_id' => 'Approval Status',
'hoa_approval_remark' => 'Remarks',
'project_type_id' => 'Project Type',
'caam_approval_id' => 'Approval Name',
'caam_approval_date' => 'Approval Date',
'caam_officer1_name' => 'CAAM Officer Name',
'caam_approval_status_id' => 'Approval Status',
'caam_approval_remark' => 'Remarks',
'hoa_approval_level2_id' => 'Approval Name',
'hoa_approval_level2_date' => 'Approval Date',
'hoa_approval_level2_status_id' => 'Approval Status',
'hoa_approval_level2_remark' => 'Remarks',
'cve_approval_id' => 'Approval Name',
'cve_approval_date' => 'Approval Date',
'cve_approval_status_id' => 'Approval Status',
'cve_approval_remark' => 'Remarks',
'hoa_approval_level3_id' => 'Approval Name',
'hoa_approval_level3_date' => 'Approval Date',
'hoa_approval_level3_status_id' => 'Approval Status',
'hoa_approval_level3_remark' => 'Remarks',
'hoa_approval_level4_id' => 'Approval Name',
'hoa_approval_level4_date' => 'Approval Date',
'hoa_approval_level4_status_id' => 'Approval Status',
'hoa_approval_level4_remark' => 'Remarks',
'hodo_approval_id' => 'Approval Name',
'hodo_approval_date' => 'Approval Date',
'hodo_approval_status_id' => 'Approval Status',
'hodo_approval_remark' => 'Remarks',
'caam_approval_level2_id' => 'Approval Name',
'caam_approval_level2_date' => 'Approval Date',
'caam_officer2_name' => 'CAAM Officer Name',
'caam_approval_level2_status_id' => 'Approval Status',
'caam_approval_level2_remark' => 'Remarks',
'created_time' => 'Date',
'updated_user_id' => 'Updated User',
'updated_time' => 'Updated Time',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('user_id',$this->user_id);
$criteria->compare('project_no',$this->project_no,true);
$criteria->compare('mod_number',$this->mod_number,true);
$criteria->compare('client_id',$this->client_id,true);
$criteria->compare('aircraft_type_id',$this->aircraft_type_id,true);
$criteria->compare('aircraft_reg_id',$this->aircraft_reg_id,true);
$criteria->compare('aircraft_sn_id',$this->aircraft_sn_id,true);
$criteria->compare('project_priority_id',$this->priority_id,true);
$criteria->compare('project_approval_id',$this->approval_id,true);
$criteria->compare('mod_tittle',$this->mod_tittle,true);
$criteria->compare('latest_rev',$this->latest_rev,true);
$criteria->compare('pic',$this->pic,true);
$criteria->compare('soc_num',$this->soc_num,true);
$criteria->compare('remark',$this->remark,true);
$criteria->compare('project_status_id',$this->project_status_id,true);
$criteria->compare('department_id',$this->department_id,true);
$criteria->compare('doa_role_id',$this->doa_role_id,true);
$criteria->compare('hoa_approval_id',$this->hoa_approval_id);
$criteria->compare('hoa_approval_date',$this->hoa_approval_date,true);
$criteria->compare('hoa_approval_status_id',$this->hoa_approval_status_id);
$criteria->compare('hoa_approval_remark',$this->hoa_approval_remark,true);
$criteria->compare('project_type_id',$this->project_type_id,true);
$criteria->compare('hoa_approval_level2_id',$this->hoa_approval_level2_id);
$criteria->compare('hoa_approval_level2_date',$this->hoa_approval_level2_date,true);
$criteria->compare('hoa_approval_level2_status_id',$this->hoa_approval_level2_status_id);
$criteria->compare('hoa_approval_level2_remark',$this->hoa_approval_level2_remark,true);
$criteria->compare('cve_approval_id',$this->cve_approval_id);
$criteria->compare('cve_approval_date',$this->cve_approval_date,true);
$criteria->compare('cve_approval_status_id',$this->cve_approval_status_id);
$criteria->compare('cve_approval_remark',$this->cve_approval_remark,true);
$criteria->compare('hoa_approval_level3_id',$this->hoa_approval_level3_id);
$criteria->compare('hoa_approval_level3_date',$this->hoa_approval_level3_date,true);
$criteria->compare('hoa_approval_level3_status_id',$this->hoa_approval_level3_status_id);
$criteria->compare('hoa_approval_level3_remark',$this->hoa_approval_level3_remark,true);
$criteria->compare('hoa_approval_level4_id',$this->hoa_approval_level4_id);
$criteria->compare('hoa_approval_level4_date',$this->hoa_approval_level4_date,true);
$criteria->compare('hoa_approval_level4_status_id',$this->hoa_approval_level4_status_id);
$criteria->compare('hoa_approval_level4_remark',$this->hoa_approval_level4_remark,true);
$criteria->compare('hodo_approval_id',$this->hodo_approval_id);
$criteria->compare('hodo_approval_date',$this->hodo_approval_date,true);
$criteria->compare('hodo_approval_status_id',$this->hodo_approval_status_id);
$criteria->compare('hodo_approval_remark',$this->hodo_approval_remark,true);
$criteria->compare('caam_approval_id',$this->caam_approval_id);
$criteria->compare('caam_approval_date',$this->caam_approval_date,true);
$criteria->compare('caam_officer1_name',$this->caam_officer1_name,true);
$criteria->compare('caam_approval_status_id',$this->caam_approval_status_id);
$criteria->compare('caam_approval_remark',$this->caam_approval_remark,true);
$criteria->compare('caam_approval_level2_id',$this->caam_approval_level2_id);
$criteria->compare('caam_approval_level2_date',$this->caam_approval_level2_date,true);
$criteria->compare('caam_officer2_name',$this->caam_officer2_name,true);
$criteria->compare('caam_approval_level2_status_id',$this->caam_approval_level2_status_id);
$criteria->compare('caam_approval_level2_remark',$this->caam_approval_level2_remark,true);
$criteria->compare('created_time',$this->created_time,true);
$criteria->compare('updated_user_id',$this->updated_user_id);
$criteria->compare('updated_time',$this->updated_time,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord descendants!
* @param string $className active record class name.
* @return Moc the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
public $maxId = 0;
public function getMax($filter = null)
{
/* Get max in column1 WHERE column2 = $filter */
$criteria = new CDbCriteria;
$criteria->select = 'MAX(t.id) AS maxId';
$tempmodel = $this->find($criteria);
if (is_null($tempmodel['maxId'])) {
//echo 'Null:'.$tempmodel['maxDepartmentId']; die();
return 0;
}
else {
//echo $tempmodel['maxDepartmentId']; die();
return $tempmodel['maxId'];
}
}
public function getLabel($id)
{
switch ($id) {
case 1: // New MOC
case 2: // Updated MOC
$label = 'success';
break;
case 3: // Approved by 1st Level
$label = 'primary';
break;
case 4: // Review MOC by 1st Level
$label = 'warning';
break;
case 5: // Rejected by 1st Level
$label = 'danger';
break;
case 6: // Approved by 2nd Level
$label = 'pink';
break;
case 7: // Deferred by 2nd Level
$label = 'warning';
break;
case 8: // Withdrawn by 2nd Level
$label = 'danger';
break;
case 9: // Updated Safety Section
$label = 'mint';
break;
case 10: // Updated MOC Compliance
$label = 'info';
break;
case 11: // Updated Implementation Review
$label = 'purple';
break;
case 12: // Completed / Accomplished
$label = 'dark';
break;
case 13: // Stop Proceeding
$label = 'dark';
break;
case 14: // Deleted
$label = 'danger';
break;
case 15: // Reviewed by QAS
$label = 'warning';
break;
}
return $label;
}
public function getIcon($id)
{
switch ($id) {
case 1: // New MOC
case 2: // Updated MOC
$icon = 'fa-pencil-square-o';
break;
case 3: // Approved by 1st Level
$icon = 'fa-check-square-o';
break;
case 4: // Review MOC by 1st Level
$icon = 'fa-search';
break;
case 5: // Rejected by 1st Level
$icon = 'fa-minus-square';
break;
case 6: // Approved by 2nd Level
$icon = 'fa-check-square-o';
break;
case 7: // Deffered by 2nd Level
$icon = 'fa-ban-circle';
break;
case 8: // Withdrawn by 2nd Level
$icon = 'fa-ban-circle';
break;
case 9: // Updated Safety Section
$icon = 'fa-pencil-square-o';
break;
case 10: // Updated MOC Compliance
$icon = 'fa-pencil-square-o';
break;
case 11: // Updated Implementation Review
$icon = 'fa-thumbs-o-up';
break;
case 12: // Completed / Accomplished
$icon = 'fa-send';
break;
case 13: // Stop Proceeding
$icon = 'fa-book';
break;
case 14: // Deleted
$icon = 'fa-remove';
break;
case 15: // Review
$icon = 'fa-eye-slash';
break;
}
return $icon;
}
}
Here is my code (from my index file)
<div class="row">
<div class="col-lg-12">
<div class="panel">
<div class="panel-heading">
<a class="btn btn-success pull-right" title="" href="<?php echo Yii::app()->createUrl('project/create'); ?>" data-original-title="" style="margin-top:10px; margin-right:20px">
<i class="fa fa-pencil-square-o"></i>
<span class="menu-title">New Project</span>
</a>
<h3 class="panel-title">Project Tracking</h3>
</div>
<div class="panel-body">
<style>
.red { background-color: #fcfd8c; }
</style>
<table id="table-project-report" class="table table-bordered table-hover toggle-circle" data-page-size="10" data-limit-navigation="5">
<thead>
<tr>
<th data-sort-ignore="true" width="20px" class="text-center">No.</th>
<th data-toggle="true" width="40px">Project No.</th>
<th data-toggle="true" width="40px">Modification No.</th>
<th data-sort-ignore="true" width="80px" class="text-center">Client</th>
<th data-sort-ignore="true" width="70px" class="text-center">Aircraft Type</th>
<th data-sort-ignore="true" width="70px" class="text-center">Aircraft SN</th>
<th data-sort-ignore="true" width="70px" class="text-center">Aircraft Reg.</th>
<th data-toggle="true" width="170px">Modification Title</th>
<th data-hide="all">Latest Rev</th>
<th data-hide="all">PIC</th>
<th data-hide="all">SoC Number</th>
<th data-hide="all">Remark</th>
<th data-sort-ignore="true" width="100px" class="text-center">Project Status</th>
</tr>
</thead>
<div class="pad-btm form-inline">
<div class="row">
<div class="col-sm-6 text-xs-center">
<div class="form-group">
<label class="control-label"></label>
<?php
$list = CHtml::listData($modelProjectStatus, 'name', 'name');
echo CHtml::dropDownList('','id', $list,
array(
'empty' => 'All Status',
'class'=>'form-control',
'id'=>'table-project-filter-type'
//'onchange'=>'js:displayCatatan($(this).val());'
)
); ?>
</div>
</div>
<div class="col-sm-6 text-xs-center text-right">
<div class="form-group">
<input id="table-project-report-search" type="text" placeholder="Search" class="form-control" autocomplete="off">
</div>
</div>
</div>
</div>
<tbody>
<?php $i=1;
foreach ($model as $project):?>
<tr>
<td class="text-center">
<?php echo $i++; ?>
</td>
<td>
<?php if (Yii::app()->user->user_role_id != 10 OR Yii::app()->user->user_role_id != 4) { // All staff except HOD / Mgmt have accessable detail moc link?>
<a class="btn-link" href="<?php echo Yii::app()->createUrl('project/view', array('id'=>$project->id));?>">
<?php echo $project->project_no;?>
</a>
<?php } else echo $project->project_no; ?>
</td>
<td>
<?php echo $project->mod_number;?>
</td>
<td>
<?php echo $project->client->name;?>
</td>
<td class="text-center">
<?php echo $project->aircraftType->name;?>
</td>
<td class="text-center">
<?php echo $project->aircraftSerielNumber->sn;?>
</td>
<td class="text-center">
<?php echo $project->aircraftRegistration->name;?>
</td>
<td>
<?php echo $project->mod_tittle;?>
</td>
<td>
<?php echo $project->latest_rev;?>
</td>
<td>
<?php echo $project->pic;?>
</td>
<td>
<?php echo $project->soc_num;?>
</td>
<td>
<?php echo $project->remark;?>
</td>
<td class="text-center">
<?php echo '<span class="label label-table label-'.Project::model()->getLabel($project->project_status_id).'" title="'.$project->projectStatus->name.'">'.$project->projectStatus->name.'</span>';?>
</td>
</tr>
<?php
endforeach;?>
</tbody>
<tfoot>
<tr>
<td colspan="10">
<div class="text-right">
<ul class="pagination"></ul>
</div>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>