Iwant to insert this code
if($transaction_user_define_fields->udf_type == 'Selectbox'){
echo '<i class="fa fa-list fa-lg text-primary pull-left" data-toggle="tooltip" data-placement="right" title="View option" onclick="viewUDFOPT('.$transaction_user_define_fields->tran_udf_col_id.')"></i>';
}
inside
$this->table->add_row()
but im getting an error .please help
if($transaction_user_define_fields->udf_type == 'Selectbox'){
$this->table->add_row('<i class="fa fa-list fa-lg text-primary pull-left" data-toggle="tooltip" data-placement="right" title="View option" onclick="viewUDFOPT('.$transaction_user_define_fields->tran_udf_col_id.')"></i>');
}
This would make the tag clickable, if you want to make the entire cell clickable you will have to set it as a param in add row
as per codeigniter documentation
$cell = array('data' => 'Blue', 'class' => 'highlight', 'colspan' => 2);
$this->table->add_row($cell, 'Red', 'Green');
// generates
// <td class='highlight' colspan='2'>Blue</td><td>Red</td><td>Green</td>
Related
So in my code, I have 2 functions. One that will return all rows in a table and one that will return 1 row based on its code.
When I run the function to get all of them - no issues - works and displays on the html fine using a foreach loop.
When i run the function however to get one, i get the error in the title for each line the array is referenced e.g $location['address_line2'].
I understand this is an error with a newer version of php but cannot find a work around.
The query works fine btw, I use print_r to display it before the foreach loop and i can see it in the inspect element.
$premises = getPremisesByCode($connection, $premisesCode);
//$premises = getAllPremises($connection);
if($premises != NULL){
foreach ($premises as $location) {
$visible = ($location['active'] != 'deactivated' ? '<span class="fa-stack"><i style="color: #008d1b;" class="fa fa-check fa-stack-1x"></i></span>' : '<span class="fa-stack"><i style="color: #8d0000;" class="fa fa-times fa-stack-1x"></i></span>' );
$editBtn = '<a class="btn btn-xs btn-info px-2 py-1 shadow" href="/'.$productfolder.'/edit-product-type/'.$location['code'].'/" title="Edit this product"><i style="font-size: 1rem;" class="mdi mdi-lead-pencil"></i></a> ';
$toggleIcon = ($location['active'] != 'deactivated') ? '<i class="mdi mdi-close"></i>' : '<i class="mdi mdi-check"></i>';
$toggleColour = ($location['active'] != 'deactivated') ? 'warning' : 'success';
$toggleBtn = '<a class="btn btn-xs btn-'.$toggleColour.' px-2 py-1 shadow" href="/'.$productfolder.'/toggle-premises/'.$location['code'].'/">'.$toggleIcon.'</a> ';
$ptImage = (isset($location['logo'])) ? '<img class="img-thumbnail shadow mx-auto d-block p-2" style="max-width: 200px; background-color: '.$location['primary_colour'].' " src="/assets/images/'.$location['logo'].'">' : '<strong>No Image Uploaded!</strong>';
$locationAddress = $location['address_line1'].'<br>';
$locationAddress .= ($location['address_line2'] != '') ? $location['address_line2'].'<br>' : NULL;
$locationAddress .= ($location['address_city'] != '') ? $location['address_city'].'<br>': NULL;
$locationAddress .= $location['address_county'].'<br>';
$locationAddress .= $location['address_postal_code'].'<br>';
$outputTr .= '
<tr id="'.$location['id'].'">
<td width="100px">'.$editBtn.$toggleBtn.'</td>
<td>'.$ptImage.'</td>
<td>'.$location['name'].'</td>
<td>'.$locationAddress.$premisesCode.'</td>
<td>'.$visible.'</td>
</tr>';
}
I already get all the data from the database and displayed it on my vue component. But, how can I display specific data on the table?
Like if the results from the database contains a user type of 'SuperAdmin'
I wanted to filter it like don't display if you find data related 'SuperAdmin'
https://imgur.com/kwTziOG - Here is my output.
I have searched this kind of problem and nothings pops-up.
Say for example.
['Paul','paul#new.com',['Admin']
['Paul', 'paul#new.com', ['SuperAdmin']
I just want to display the first array. Since it doesn't have a user type of SuperAdmin.
<tr v-for="user in users.data" :key="user.id">
<td>{{user.id}}</td>
<td>{{user.name}}</td>
<td>{{user.email}}</td>
<td>{{user.type}}</td>
<td>{{user.created_at |myDate}}</td>
<td>
<a href="#" #click="editModal(user)">
<i class="fa fa-edit"></i>
</a>
/
<a href="#" #click="deleteUser(user.id)">
<i class="fa fa-trash red"></i>
</a>
</td>
</tr>
I just displayed all the data being fetch in the database. Just wanted it to filter it somehow.
I have not used Vue in alittle while but if I remember correctly you can just use 'v-if' and it will conditionally render the data. Below is an example of how this could be done.
Possible Solution
<tr v-for="user in users.data" :key="user.id">
<div v-if="user.type == 'SuperAdmin'">
<td>{{user.id}}</td>
<td>{{user.name}}</td>
<td>{{user.email}}</td>
<td>{{user.type}}</td>
<td>{{user.created_at |myDate}}</td>
<td>
<a href="#" #click="editModal(user)">
<i class="fa fa-edit"></i>
</a>
<a href="#" #click="deleteUser(user.id)">
<i class="fa fa-trash red"></i>
</a>
</td>
</div>
</tr>
Hope this answered your question, good luck!
I have the following <td> tag with <a> tag in it that contains a php variable in href. I only can browse upto uploads folder. Does anyone know why? It supposed to browse until uploads\$_POST['searchInput'] . But it is not doing that.
<td class="viewEditTd"><button class = "btn btn-info viewEditButton"><a href="file://///172.xx.xx.xxx\TEMP\xxx\uploads\"<?php echo $_POST['searchInput']; ?>"\" target="_blank"><span class="
glyphicon glyphicon-folder-open" aria-hidden="true"></span> View File</a></button></td>
I am able to solve the issue with the help of Stack overflow forum member. This is how it solved. My issue was as below
<td class="viewEditTd"><button class = "btn btn-info viewEditButton"><a href="file://///172.xx.xx.xxx\TEMP\xxx\uploads\"<?php echo $_POST['searchInput']; ?>"\" target="_blank"><span class="
glyphicon glyphicon-folder-open" aria-hidden="true"></span> View File</a></button></td>
It was solved by removing the two double quotes around the php tags. Working answer is
<td class="viewEditTd"><button class = "btn btn-info viewEditButton"><a href="file://///172.xx.xx.xxx\TEMP\xxx\uploads\<?php echo $_POST['searchInput']; ?>" target="_blank"><span class="
glyphicon glyphicon-folder-open" aria-hidden="true"></span> View File</a></button></td>
It shows 500 internal server error when retrieving data through ajax. But the whole code works well in my localhost. And i am facing this error for the first time, so i am not sure whether this error is caused due to fetching data through AJAX. If it is not the correct reason please get me the correct reason.
this is my coding
$.ajax({
type:"POST",
url:"api_fle/get_post",
data:{u_id:u_id,type:'all13'},
success:function(response){
if(response!=0){
var parsed = $.parseJSON(response);
date = new Array();
events = new Array();
$.each(parsed,function(i,parsed){
if(parsed.shred.length>15){var shred=jQuery.trim(parsed.shred).substring(0, 14) + '...';} else{var shred=parsed.shred;}
if(parsed.cmpny_name == parsed.shred){var sharedd=parsed.cmpny_name; var sha=""; var pic=parsed.pro_pic;}else{var sharedd=shred; var sha=' shared <input type="hidden" id="who_hid_id" value="'+parsed.id+'">'+parsed.cmpny_name+"'s Event"; var pic=parsed.pic;}
date[i]=parsed.SharedDate;
events[i]='<div class="col-md-10 post" style="background:#FFF"><span class="company-logo-small"><img src="'+pic+'" style=" width: 60px; height: 60px;"></span>'
+'<span class="fullhead"><span class="posted-name"><a id="who_shred" style="color:#fff;cursor:pointer;"><input type="hidden" id="who_hid_id" value="'+parsed.id+'"><span itemprop="hiringOrganization">'+sharedd+'</span></a>'+sha+'</span></span>'
+'<span class="post-status" style="color:#fff;">'+prettyDate(parsed.SharedDate)+'</span><div class="post-inner"><div class="col-md-12"><div class="panel panel-default event">'
+'<div class="panel-heading title">'+parsed.name+'</div><ul class="list-group"><li class="list-group-item"><i class="fa fa-globe"></i>'+parsed.location+'</li>'
+'<li class="list-group-item"><i class="fa fa-calendar-o"></i>'+parsed.date+'</li><li class="list-group-item"><i class="fa fa-clock-o"></i>'+parsed.time+'</li>'
+'<li class="list-group-item"><i class="fa fa-users"></i>Attendees '+parsed.attendies+'</li></ul><ul class="list-group"><div class="panel-body"><p>'+parsed.decs+'</p>'
+'<a class="btn btn-xs btn-info pull-left" target="_blank" href="eventview?evnt_id='+parsed.evnt_id+'">View</a>  '
+'<i class="fa fa-fw fa-facebook-square" style="font-size:20px;"></i>'
+'<a class="twitter popup" href="pagelink?evnt_id='+parsed.evnt_id+'" target="_blank"><i class="fa fa-fw fa-twitter-square " style="font-size:20px;"></i></a>'
+'<a class="twitter popup" href="pagelink?evnt_id='+parsed.evnt_id+'" target="_blank">'
+'<i class="fa fa-fw fa-linkedin-square" style="font-size:20px;"></i></a><a class="twitter popup" href="pagelink?evnt_id='+parsed.evnt_id+'" target="_blank">'
+'<i class="fa fa-fw fa-google-plus" style="font-size:20px;"></i></a></div></ul><div id="img"></div><div class="clearfix"></div></div></div></div></div>';
});
}
});
-------------------------
page : get_post
--------------------
if($_POST['type']=='all13'){
$update_time=mysql_query("UPDATE `share_post` SET `sharedDate`='".$_POST['time']."' WHERE `frm_id` = 'U005114608238'");
$sql=select_query("SELECT s.id,e.u_id,e.cmpny_name,n.pro_pic as pic,l.pro_pic,l.level as lv,m.evnt_id,m.name,m.location,m.decs,m.time,
m.date,m.attendies,s.frm_id,s.is_important,s.shred,s.SharedDate,s.lvl FROM employer_info e,login l,login n,`event` m, share_post s WHERE n.u_id=s.frm_id and e.u_id=l.u_id and m.u_id=l.u_id and m.evnt_id=s.post_id and s.to_id='".$_POST['u_id']."' order by s.id desc");
$count=count($sql);
$response=array();
for($i=0;$i<$count;$i++){
array_push($response,$sql[$i]);
}
echo json_encode($response);
}
when i have inspected the error , i got something like in this screenshot
i am trying to pass an id in the checkbox while generating datatables,My codes are as follows
Controller
public function list_view() {
$this->datatables->select('c.id,,c.image,c.first_name,c.email_primary,c.contact_mobile,c.contact_home,cn.country_name,c.unique_id,c.title')
->from('contact c')
->join('country cn','cn.id=c.country_id','left');
$this->datatables->add_column('action', '<input id="list-chk_" class="top-label" type="checkbox" value=c.id />', 'id');
$this->datatables->add_column('sync', '<span class="list-sync" ></span>', 'c.id');
$this->datatables->add_column('email', '<span class="list-mail" ></span>', 'c.id');
echo $this->datatables->generate('json');
}
I just want to pass c.id along with the checkbox,as I need to have further manipulation using that id in datatables,
Thank You .
You can just pass the variable as {{ c.id }}
Example:
$result = DB::table('users')
->select('users.id as id','users.first_name', 'users.last_name', 'users.email', 'users.username', 'users.activated');
return Datatables::of($result)
->add_column('actions', '<a aid="{{ $id }}" style="cursor: pointer;" class="edit_admin" data-toggle="modal" data-target="#edit_admin_modal" title="Edit Admin" ><i class="fa fa-pencil"></i></a> <a style="cursor: pointer;" aid="{{ $id }}" class="delete_admin" data-toggle="modal" data-target="#delete_admin_modal" title="Remove Admin" ><i class="fa fa-times-circle"></i></a> <a aid="{{ $id }}" style="cursor: pointer;" class="enable_disable_admin" title="Enable/Disable Admin" ><i class="fa fa-check-circle-o"></i></a>')
->remove_column('id')
->make();