Good day,
I have a table as shown in the diagram below:
7079
I want it to be auto_number, and want to group the <td> by Equipment Category(First), Equipment Sub Category(Second)
CONTROLLER
public function actionUpdate($building_id, $bip_id, $inspector_id)
{
$model = new InspectionBooking();
$rating = new InspectionRatingScale();
$scoredequipment = new ScoredEquipment();
$scoredequipments=$scoredequipment->getBuildingScoredequipment($building_id);
$scoredequipmentscore = new ScoredEquipmentScore();
$scoredequipmentscore1=$scoredequipmentscore->getScore($building_id,$bip_id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->bookinspection_id]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
return $this->render('update', [
'model' => $model,
'rating' => $rating,
'scoredequipment' => $scoredequipment,
'scoredequipments' => $scoredequipments,
'scoredequipmentscore'=>$scoredequipmentscore1,
]);
}
VIEW
<div class="box">
<div class="box-header">
<h3 class="box-title">Equipments</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Equipment Category</th>
<th>Equipment Sub Category</th>
<th>Activity</th>
<th></th>
<th>Comment</th>
</tr>
</thead>
<tbody>
<?php
if(count($scoredequipmentscore)>=1){
foreach ($scoredequipmentscore as $cvalue)
{
?>
<tr>
<td><?php echo $cvalue['equipment_category'] ?></td>
<td><?php echo $cvalue['equipment_sub_category'] ?></td>
<td><?php echo $cvalue['item_name'] ?></td>
<td>
<?php
$name="InspectionRatingScale[scoredequipment][$cvalue[equipment_id]][rating_text]";
$yn=array("$cvalue[rating]"=>array('selected'=>true));
//echo $form->dropDownList($rating, 'rating_text', ArrayHelper::map($rating->findAll(),'rating_value','rating_text'),array('class'=>'form-control','name'=>$name,'options'=>$yn))->label(false);
echo $form->Field($rating, 'rating_text')->dropDownList(ArrayHelper::map(\app\modules\inspection\models\InspectionRatingScale::find()->all(),'rating_value','rating_text'), ['name'=>$name,'options'=>$yn])->hiddenInput()->label(false);
?>
</td>
<td>
<?php
// die(var_dump($scoreditem));
$sc1=new ScoredEquipmentScore();
echo $form->field($sc1, 'scored_comment')->textInput()->label(false);
?>
</td>
</tr>
<?php
}
}
else{
foreach ($scoredequipments as $cvalue)
{
?>
<tr>
<td><?php echo $cvalue['equipment_category'] ?></td>
<td><?php echo $cvalue['equipment_sub_category'] ?></td>
<td><?php echo $cvalue['item_name'] ?></td>
<td>
<?php
$name="InspectionRatingScale[scoredequipment][$cvalue[equipment_id]][rating_text]";
// echo $form->dropDownList($rating, 'rating_text', ArrayHelper::map($rating->findAll(''),'rating_value','rating_text'),array('class'=>'form-control','name'=>$name));
echo $form->Field($rating, 'rating_text')->dropDownList(ArrayHelper::map(\app\modules\inspection\models\InspectionRatingScale::find()->all(),'rating_value','rating_text'), ['name'=>$name])->hiddenInput()->label(false);
?>
</td>
<td>
<?php
// die(var_dump($scoreditem));
$sc1=new ScoredEquipmentScore();
echo $form->field($sc1, 'scored_comment')->textInput()->label(false);
?>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div>
</div>