Hi all i am trying to display all users who are attempted a test or not .all users are under one supervisor.need to display all users under supervisor those users who are attempted test or not .like below output
i need output like below
|test1|tes2
user1 | pass|fail
user2 | fail|pass
user3 | |
controller: this is my controller code
if ($supervisor) {
//this query is to get user under supervisor
$users_query="SELECT u.* FROM usr_data u, udf_text v WHERE u.usr_id != 6 AND u.usr_id = v.usr_id " . $supervisor_condition . " GROUP BY u.usr_id";
$user_records = $this->base_model->executeSelectQuery($users_query);
$final_dataa = [];
foreach ($user_records as $user) {
$user=(object)$user;
//this query is for to get users who attempted tests
$user_test=" SELECT u.*,o.title FROM usr_data u, object_data o,tst_tests tt,tst_active ta WHERE u.usr_id != 6 AND ta.user_fi=u.usr_id AND tt.obj_fi=o.obj_id AND ta.test_fi=tt.test_id AND ta.user_fi = $user->usr_id";
$tst_records=$this->base_model->executeSelectQuery($user_test);
if (count($tst_records)) {
foreach ($tst_records as $tst) {
$tst=(object)$tst;
$dta['usr_id'] = $user->usr_id;
$dta['firstname'] = $user->firstname;
$dta['matriculation'] = $user->matriculation;
$dta['approve_date'] = $this->udfTextData(1, $user->usr_id);
$dta['department'] = $user->department;
$dta['job_title'] = $this->udfTextData(6, $user->usr_id);
$dta['test_title'] = $tst->title;
$final_dataa[] = $dta;
}
}
else{
$dta['usr_id'] = $user->usr_id;
$dta['firstname'] = $user->firstname;
$dta['matriculation'] = $user->matriculation;
$dta['approve_date'] = $this->udfTextData(1, $user->usr_id);
$dta['department'] = $user->department;
$dta['job_title'] = $this->udfTextData(6, $user->usr_id);
// $dta['test_title'] = $tst->title;
$final_dataa[] = $dta;
}
}
}
$dataa['recordss'] = $final_dataa;
$this->load->view('supervisor', $dataa);
View: this is my view to display as table
<table class="table" id="myTable">
<thead>
<tr>
<?php
if(count($recordss)){
foreach ($recordss as $records) {
$records = (object)$records;
?>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><?phpechoucfirst($records->test_title);?></td>
<?php }}?>
<tr>
<th>Employe no</th>
<th>Employe Name</th>
<th>Date Joined</th>
<th> Division</th>
<th>Department</th>
<th>Job Title</th>
</tr>
</thead>
<tbody>
<?php
if(count($recordss))
{
foreach ($recordss as $records) {
$records = (object)$records;
$date_joined_y =substr($records->approve_date,0,4);
$date_joined_m =substr($records->approve_date,4,2);
$date_joined_d =substr($records->approve_date,6,2);
$date_joined = $date_joined_d."-".$date_joined_m."-".$date_joined_y;?>
<tr>
<td><?php echo ucfirst($records->matriculation); ?></td>
<td><a href="<?php echo base_url();?>welcome/employee/<?php echo $records->usr_id;?>"><?php echo ucfirst($records->firstname); ?></td>
<td><?php echo $date_joined; ?></td>
<td></td>
<td><?php echo ucfirst($records->department); ?></td>
<td><?php echo ucfirst($records->job_title); ?></td>
</tr>
<?php } } ?>
</tbody>
</table>
but am getting error like below:|Message: Undefined property:
|test1|tes2|Message: Undefined property:stdClass::$test_title
user1 | pass|fail|
user2 | fail|pass|
user3 | | |
i am trying to display all users who are attempted a test or not .all users are under one supervisor.need to display all users under supervisor those users who are attempted test or not .like below output i am trying to display all users who are attempted a test or not .all users are under one supervisor.need to display all users under supervisor those users who are attempted test or not .like below output
Aucun commentaire:
Enregistrer un commentaire