I am trying to filter results that will be displayed to user based on selection, but, its not displaying, properly, I do not know what I am doing wrong. I process using GET on the same page (users.php?rid=). This is how it displays when I select a value. Seems it loads the page twice into the div
The Select Button
<select name="role_id" id="role_id" style="width: 150px;"
onchange="">
<option value="">Select User</option>
<?php
$rid = 0;
if (isset($_GET['rid'])) {
$rid = clean($_GET['rid']);
}
$roles = get_user_roles();
foreach ($roles as $row):
?>
<option
value="<?php echo $row['role_id']; ?>"<?php if (isset($rid) && $rid == $row['role_id']) echo 'selected'; ?>>
<?php echo $row['name']; ?>
</option>
<?php endforeach; ?>
</select>
RESULT DIV
<div id="filter_result">
<table class="table table-striped" >
<thead>
<tr>
<th><div>#</div></th>
<th><div>Name</div></th>
<th><div>Email</div></th>
<th><div>User Type</div></th>
<th><div>Options</div></th>
</tr>
</thead>
<tbody>
<?php
if ($rid < 1) {
$users = get_users();
} else {
$users = get_role_users($rid);
}
if ($users->num_rows < 1) {
echo '<div class = "alert alert-warning text-center">There are no Students for this Class.... <a class="btn btn-primary btn-sm" href="add_user.php">Add User</a></div>';
}
$count = 1;
foreach ($users as $row):?>
<tr>
<td><?php echo $count++; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><?php echo get_role_name($row['role_id']); ?></td>
<!--Options-->
<td>
<!--Change Role-->
<div class="btn-group">
<button type="button" class="btn btn-primary btn-sm dropdown-toggle"
data-toggle="dropdown">
Change Role <span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-default pull-right" role="menu">
<?php $roles = get_user_roles();
foreach ($roles as $row2):
?>
<li>
<a href="change_roles.php?rid=<?php echo $row2['role_id'].'&uid='.$row['user_id'];?>">
<?php echo $row2['name']; ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
<!--Delete Student-->
<a href="delete_user.php?id=<?php echo $row['user_id']; ?>"
onclick="confirm('Are You sure?')" class="btn btn-danger"> Delete</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div
JAVASCRIPT
<script>
$(document).on('change', 'select#role_id', function () {
var role_id = $(this).val();
$('#filter_result').load('users.php?rid='+role_id, '#filter_result');
});
</script>
It should display like this
Since you are Checking selection on the same page, you can assign id to your body tag, for example
<body id="page_body">
then use #page_body.load(), it will work
$('#page_body').load('users.php?rid='+role_id, '#filter_result');
Related
So i have part where AJAX updates cart on click. Every AJAX call on my website is working fine except this one where call is processed but it just clears part of the page that should've been updated. So on both buttons click after <tbody id="korpin"> everything is cleared until next div.
Cart.php
<tbody id="korpin">
<?php
$conn = new mysqli("localhost", "root", "", "pc") or die("Unable to connect");
foreach($_SESSION['korpica'] as $id => $korpa):
$sql = $conn->prepare("SELECT a.sifra,a.slika,a.imeProizvoda,a.brend,b.cijena,b.cijena2 FROM proizvodi a inner join stanje b on a.sifra = b.sifra WHERE a.sifra = '".$korpa."'");
if($sql->execute()){
$sql->bind_result($sifra,$slika,$imeProizvoda,$brend,$cijena,$cijena2);
$sql->store_result();
while($sql->fetch()){
?>
<tr>
<td class="text-center"><img width="70px" src="image/proizvodi/<?php echo $slika; ?>.jpg" alt="<?php echo $imeProizvoda; ?>" title="<?php echo $imeProizvoda; ?>" class="img-thumbnail" /></td>
<td class="text-left"><?php echo $imeProizvoda; ?><br />
</td>
<td class="text-left"><?php echo $brend; ?></td>
<td class="text-left" width="200px"><div class="input-group btn-block quantity">
<span class="input-group-btn">
<button type="button" data-toggle="tooltip" title="+1" class="btn btn-primary" onclick="dodaj(`<?php echo $sifra; ?>`); cart.add(`<?php echo(str_replace('"', '\\`', $imeProizvoda)); ?>`); refresh(`<?php echo $sifra; ?>`);"><i class="fa fa-clone"></i></button>
<button type="button" data-toggle="tooltip" title="Ukloni" class="btn btn-danger" onclick="ukloni(`<?php echo $sifra; ?>`); sd.remove(`<?php echo(str_replace('"', '\\`', $imeProizvoda)); ?>`); refresh(`<?php echo $sifra; ?>`);"><i class="fa fa-times-circle"></i></button>
</span></div></td>
<?php if ($cijena2 > 0): ?>
<td class="text-right">€<?php echo bcdiv($cijena2,1,2); ?></td>
<td class="text-right">€<?php echo bcdiv($cijena2,1,2); ?></td>
<?php else :?>
<td class="text-right">€<?php echo bcdiv($cijena,1,2); ?></td>
<td class="text-right">€<?php echo bcdiv($cijena,1,2); ?></td>
<span class="price-old"></span>
<?php endif ?>
</tr>
<?php
}$sql->free_result();
} endforeach;
$conn->close();
?>
</tbody>
korpinUpd.js
function refresh(sifra) {
$.ajax({
url: 'cartUpdate.php',
success : function(data) {
$('#korpin').html(data);
}
});
}
and finally cartUpdate.php
<?php
session_start();
$output ='';
$cena; $conn = new mysqli("localhost", "root", "", "pc") or die("Unable to connect");
foreach($_SESSION['korpica'] as $id => $korpa){
$sql = $conn->prepare("SELECT a.sifra,a.slika,a.imeProizvoda,a.brend,b.cijena,b.cijena2 FROM proizvodi a inner join stanje b on a.sifra = b.sifra WHERE a.sifra = '".$korpa."'");
if($sql->execute()){
$sql->bind_result($sifra,$slika,$imeProizvoda,$brend,$cijena,$cijena2);
$sql->store_result();
while($sql->fetch()){
$output.= '<tr>';
$output.='<td class="text-center"><img width="70px" src="image/proizvodi/'.$slika.'.jpg" alt="'.$imeProizvoda.'" title="'.$imeProizvoda.'" class="img-thumbnail" /></td>
<td class="text-left">'.$imeProizvoda.'<br />
</td>
<td class="text-left">'.$brend.'</td>
<td class="text-left" width="200px"><div class="input-group btn-block quantity">
<span class="input-group-btn">
<button type="button" data-toggle="tooltip" title="+1" class="btn btn-primary" onclick="dodaj(`'.$sifra.'`); cart.add(`'.(str_replace('"', '\\`', $imeProizvoda)).'`); refresh(`'.$sifra.'`);"><i class="fa fa-clone"></i></button>
<button type="button" data-toggle="tooltip" title="Ukloni" class="btn btn-danger" onclick="ukloni(`'.$sifra.'`); sd.remove(`'.(str_replace('"', '\\`', $imeProizvoda)).'`); refresh(`'.$sifra.'`);"><i class="fa fa-times-circle"></i></button>
</span></div></td>';
if ($cijena2 > 0){
$cena = $cijena2;
}else{
$cena = $cijena;
}
$output .= '<td class="text-right">€'.$cena.'</td>
<td class="text-right">€'.$cena.'</td>';
$output .= '</tr>';
}
}}
$conn->close();
echo $output;
?>
Try echo json_decode($output); , your AJAX call might not recognize what you are sending.
I have this controller:
<?php
class Cart extends CI_Controller{
public $paypal_data = '';
public $tax;
public $shipping;
public $total = 0;
public $grand_total;
/*
*Cart Index
*/
public function index(){
//Load view
$data['main_content'] = 'cart';
$this->load->view('layouts/main', $data);
}
/*
*Add To Cart
*/
public function add(){
//Item data
$data = array(
'id'=> $this->input->post('item_number'),
'qty'=> $this->input->post('qty'),
'price'=> $this->input->post('price'),
'name'=> $this->input->post('title'),
);
//print_r($data);die();
//Insert Into cart-block
$this->cart->insert($data);
redirect('products');
}
}
And I have the view file which uses this controller:
<div class="cart-block">
<form action="cart/update" method="post">
<table cellpadding="6" cellspacing="1" style="width:100%" border="0">
<tr>
<th>QTY</th>
<th>Item Description</th>
<th style="text-align:right">Item Price</th>
</tr>
<?php $i = 1; ?>
<?php foreach ($this->cart->contents() as $items) : ?>
<input type="hidden" name="<?php echo $i. '[rowid]'; ?>" value="<?php echo $items['rowid']; ?>" />
<tr>
<td><input type="text" name="<?php echo $i.'[qty]'; ?>" value="<?php echo $items['qty']; ?>" maxlength="3" size= "5"</td>
<td><?php echo $items['name']; ?></td>
<td style="text-align:right"><?php echo $this->cart->format_number($items['price']); ?></td>
</tr>
<?php $i++; ?>
<?php endforeach; ?>
<tr>
<td></td>
<td class="right"><strong>Total</strong></td>
<td class="right" style="text-align:right">$<?php echo $this->cart->format_number($this->cart->total()); ?></td>
</tr>
</table>
<br>
<p><button class="btn btn-default" type="submit">Update Cart</button>
<a class="btn btn-default" href="cart">Go To Cart</a></p>
</form>
</div>
<div class="panel panel-default panel-list">
<div class="panel-heading panel-jeading-dark">
<h3 class="panel-title">
Categories
</h3>
</div>
<!--List group -->
<ul class="list-group">
<?php foreach(get_categories_h() as $category) : ?>
<li class="list-group-item"><?php echo $category->name; ?></li>
<?php endforeach; ?>
</ul>
I apologize that I can't show you the actual website because it's not online but based on the above snippets can any point out an error in the view file or controller that causes the shopping cart not to update?
I'm following a video tutorial but it seems I'm doing something wrong. Here is the video: https://youtu.be/ajt_DJMS5FM?t=13m45s
Your form action is cart/update your function in the controller is add?
Change the form action to cart/add. Or write an cart/update function.
Firstly change the Form Action action="cart/update" to
action="<?php echo base_url();?>cart/add" and apply die(); and test it
load the cart library in controller
$this->load->library('cart');
So I'm trying to do Ajax POST in my wordpress site which is used in checking if checkboxes are checked and getting their values to get updated on the database on click. Using the usual PHP form submit is the easiest but the fields that I'm trying to get is outside the form.
After button click, I created an alert if the data that I need is being picked up (and they are) so I can continue with the Ajax POST. However, the POST data is not showing when I inserted an alert on the second file.
Here's my code (content-orders.php):
<div class="container">
<div class="row">
<div class="col-sm-6 text-left">
<form class="form-inline" method="post">
<select id="bulk_action_stat" name="bulk_action_stat">
<option value="BA">Bulk Actions</option>
<option value="MTT">Move To Trash</option>
<option value="MP">Mark Processing</option>
<option value="MOH">Mark On-Hold</option>
<option value="MC">Mark Complete</option>
</select>
<button class="btn btn-success" type="submit" id="check-all">Filter</button>
</form>
</div>
<div class="col-sm-6 text-right">
<form class="form-inline" method="get">
<?php $statuses = wc_get_order_statuses(); ?>
<select name="orderstatus" class="custom-select mb-2 mr-sm-2 mb-sm-0">
<option value="any">-- Select Status --</option>
<?php foreach( $statuses as $skey => $status ) : ?>
<option <?php echo ( ( isset( $_GET['orderstatus'] ) && $_GET['orderstatus'] == $skey ) ? 'selected="selected"' : '' )?> value="<?php echo $skey;?>"><?php echo $status;?></option>
<?php endforeach; ?>
</select>
<input type="submit" value="Filter" />
</form>
</div>
</div>
<?php
$status_query = 'any';
if(isset( $_GET['orderstatus'] )) {
$status_query = $_GET['orderstatus'];
}
$filters = array(
'post_status' => $status_query,
'post_type' => 'shop_order',
'posts_per_page' => 200,
'paged' => 1,
'orderby' =>'modified',
'order' => 'DESC'
);
$loop = new WP_Query( $filters );
?>
<div class="row">
<div class="table-responsive">
<table class="table responstable table-striped">
<thead>
<tr>
<th><input id="checkAll" type="checkbox"></th>
<th>Order</th>
<th>Purchased</th>
<th>SKU</th>
<th>Ship To</th>
<th>Date</th>
<th>Total</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
if( !($loop->have_posts())) {
?>
<tr>
<td colspan="8" class="text-center">No data.</td>
</tr>
<?php
} else {
while ( $loop->have_posts() ) {
$loop->the_post();
$order = new WC_Order($loop->post->ID);
?>
<tr>
<td><input id="select-item" name="bulk_actions_check" type="checkbox" value="<?php echo $loop->post->ID; ?>"></td>
<td><?php echo $order->billing_first_name." ".$order->billing_last_name; ?></td>
<td>
<?php
foreach ($order->get_items() as $key => $lineItem) {
echo $lineItem['qty']." ".$lineItem['name']."<br />";
}
?>
</td>
<td><?php
foreach ($order->get_items() as $key => $SKUItem) {
$sku_handler = new WC_Product($SKUItem['product_id']);
echo $sku_handler->sku."<br />";
}
?></td>
<td><?php echo $order->get_shipping_address(); ?></td>
<td><?php explode(" ",$order->order_date); echo $order->order_date[0];?></td>
<td><?php echo "$".$order->get_total(); ?></td>
<td><?php echo $order->status; ?></td>
<td>
<form class="form-inline" method="get">
<input type="hidden" name="status_id" value="<?php echo $order->id; ?>" />
<?php if ($order->status != 'cancelled' && $order->status != 'completed') { ?>
<?php if ($order->status != 'processing') { ?>
<button class="btn btn-primary" id="processing-<?php echo $order->id; ?>" type="submit" name="update_status" value="processing"><i class="fa fa-ellipsis-h" aria-hidden="true"></i></button>
<?php }?>
<button class="btn btn-success" id="complete-<?php echo $order->id; ?>" type="submit" name="update_status" value="completed"><i class="fa fa-check" aria-hidden="true"></i></button>
<?php }?>
<button class="btn btn-info" id="view-<?php echo $order->id; ?>" type="submit" name="update_status" value="view"><i class="fa fa-eye" aria-hidden="true"></i></button>
</form>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#checkAll").click(function () {
jQuery('input:checkbox').not(this).prop('checked', this.checked);
});
jQuery('#check-all').click(function(){
var bulk_action_status = jQuery('#bulk_action_stat').val();
var checkValues = jQuery('input[name=bulk_actions_check]:checked').map(function()
{
return jQuery(this).val();
}).get();
alert(checkValues);
jQuery.ajax({
url: '<?php echo get_stylesheet_directory_uri(); ?>/test.php',
type: 'post',
data: { ids: checkValues },
success:function(data){
}
});
});
});
On test.php is just
print_r($_POST);
These 2 files are in my child theme.
I hope someone can help. Thanks!
-Eli
I'm a bellend.
The form should just have an ID and add the form ID to all the fields outside the form.
<form id="bulk_action_filter" class="form-inline" method="post">
<select id="bulk_action_stat" name="bulk_action_stat">
<option value="">Bulk Actions</option>
<option value="trash">Move To Trash</option>
<option value="processing">Mark Processing</option>
<option value="on-hold">Mark On-Hold</option>
<option value="completed">Mark Complete</option>
</select>
<input form="bulk_action_filter" type="submit" name="filter_bulk_actions" id="check-all" value="Apply"/>
</form>
<input form="bulk_action_filter" id="select-item" name="bulk_actions_check[]" type="checkbox" value="<?php echo $loop->post->ID; ?>">
I have a view code:
<?php
$i = 1;
//var_dump($this->productList);
foreach ($this->productList as $data) {
$desc=explode(",",$data['descriptions']);
?>
<tr>
<th colspan="3">
<input type="hidden" id="id_pack" name="id_pack" value="<?php echo $data['package_id']; ?>">
<input type="hidden" id="nama_pack" name="nama_pack" value="<?php echo $data['package_name']; ?>">
<h4 align="center" class="title-pack"><?php echo $data['package_name']; ?></h4>
</th>
</tr>
<tr id="dashe">
<td>
<ul class="myul">
<?php foreach($desc as $descriptions) { ?>
<li class="myli"> <?php echo $descriptions; ?></li>
<?php } ?>
</ul>
</td>
<td>
<h4 class="prize">
Rp. <?php echo number_format($data['price'],2);?>
/ month
</h4>
</td>
<td>
<p id="order" name="order" class="mybutton" data-toggle="modal" data-target=".mymodal">Order</p>
</td>
</tr>
<?php
$i++;
}
?>
And this the javascript:
document.getElementById("order").addEventListener("click", tampilkanHrm);
function tampilkanHrm() {
var pilihan=$("#nama_pack").val();
document.getElementById("choice").innerHTML = pilihan;
document.getElementById("pack").value = pilihan+" Package";
}
the problem is, in the order button it always show the same record. Just show the first data, even i clicked other order button. Hope somebody help.
You can't assign same id for multiple elements.
So, have different ids.
<?php
$i = 1;
//var_dump($this->productList);
foreach ($this->productList as $data) {
$desc=explode(",",$data['descriptions']);
?>
<tr>
<th colspan="3">
<input type="hidden" id="id_pack<?php echo $i ?>" name="id_pack" value="<?php echo $data['package_id']; ?>">
<input type="hidden" id="nama_pack<?php echo $i ?>" name="nama_pack" value="<?php echo $data['package_name']; ?>">
<h4 align="center" class="title-pack"><?php echo $data['package_name']; ?></h4>
</th>
</tr>
Similarly create buttons with different ids.
<td>
<p id="<?php echo $i ?>" name="order" class="mybutton" data-toggle="modal" data-target=".mymodal">Order</p>
</td>
Then change your javascript to jquery. Hope, you might also be using jquery [ understood from your code ]
$(".mybutton").on("click", function() {
var identifier = $(this).attr("id");
var pilihan=$("#nama_pack"+identifier).val();
$("#choice").html(pilihan);
});
Change your code like this and check.
we have a marketplace site. each seller/vendor have their own account.
we are displaying list of sellers products , qty, sku...etc in their account.
http://prntscr.com/8vgul0
we are using this code to display those information :
<?php
$isPartner= Mage::getModel('marketplace/userprofile')->isPartner();
$helper= Mage::helper('marketplace');
if($isPartner==1){
?>
<script type="text/javascript">
if (typeof jQuery == 'undefined'){
document.write(unescape("%3Cscript src='//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<div class="page-title">
<h1 style="float:left;"><?php echo $helper->__('My Product List') ?></h1>
</div>
<div class="wk_mp_design">
<div class="block block-account">
<div class="block-title">
<strong><span><h4><?php echo $helper->__('Product List') ?></h4></span></strong>
</div>
</div>
<div class="fieldset wk_mp_fieldset">
<div class="grid">
<div class="hor-scroll">
<form action="<?php echo Mage::helper('core/url')->getCurrentUrl();?>" method="post">
<table cellspacing="0" class="border wk_mp_list_table">
<thead>
<tr id="wk_mp_tr_heading">
<th><span><?php echo $helper->__('Product Name') ?></span></th>
<th><span><?php echo $helper->__('Date') ?></span></th>
<th><span><?php echo $helper->__('Product Status') ?></span></th>
<th><span> </span></th>
</tr>
</thead>
<tbody class="wk_mp_body">
<tr>
<td>
<input type="text" class="input-text" name="s" placeholder='<?php echo $helper->__('Search by product name') ?>' value="<?php echo $this->getRequest()->getParam('s')?>"/>
</td>
<td>
<span class="wk_mp_td_span">
<?php echo $helper->__('From: ') ?>
<input name="from_date" id="special_from_date" class="input-text" value="<?php echo $this->getRequest()->getParam('from_date')?>" />
</span>
<span class="wk_mp_td_span">
<?php echo $helper->__('To: ') ?>
<input name="to_date" id="special_to_date" class="input-text" value="<?php echo $this->getRequest()->getParam('to_date')?>" />
</span>
</td>
<td>
<select name="prostatus" class="input-text">
<option value=""><?php echo $helper->__('All') ?></option>
<option value="1" <?php if($this->getRequest()->getParam('prostatus') == 1) echo 'selected="selected"'?>>
<?php echo $helper->__('Approved') ?>
</option>
<option value="2" <?php if($this->getRequest()->getParam('prostatus') == 2) echo 'selected="selected"'?>>
<?php echo $helper->__('Unapproved') ?>
</option>
</select>
</td>
<td>
<button class="button" title="Save" type="submit">
<span><span><span><?php echo $helper->__('Submit') ?></span></span></span>
</button>
</td>
</tr>
</tbody>
</table>
</form>
<?php
if(count($this->getCollection())==0){ ?>
<div class="fieldset wk_mp_fieldset">
<div class="wk_emptymsg">
<?php echo $helper->__('No Product Available') ?>
</div>
</div>
<?php
} else{ ?>
<form action="<?php echo $this->getUrl('marketplace/marketplaceaccount/massdeletesellerpro') ?>" method="post" id="formmassdelete" name="formmassdelete">
<input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" />
<button class="button" title="<?php echo $helper->__('Delete Products') ?>" type="submit" style="float: left;padding: 5px 5px 5px 0;" id="mass_delete_butn">
<span><span><?php echo $helper->__('Delete Products') ?></span></span>
</button>
<table cellspacing="0" class="border wk_mp_list_table wk_mp_list_container_table">
<thead>
<tr class="wk_content">
<th class="wk_check_first_td">
<span>
<input type="checkbox" name="mpselecctall" value="all" id="mpselecctall"/>
</span>
</th>
<th class="wk_first_td">
<span class="label name">
<?php echo $helper->__('Product')?>
</span>
</th>
<th class="wk_first_td">
<span class="label name">
<?php echo $helper->__('sku')?>
</span>
</th>
<th>
<span class="label pro_status">
<?php echo $helper->__('Status')?>
</span>
</th>
<!--
<th>
<span class="label qty">
<?php echo $helper->__('Qty. Confirmed')?>
</span>
</th>
<th>
<span class="label qty">
<?php echo $helper->__('Qty. Pending')?>
</span>
</th>
<th>
<span class="label qty">
<?php echo $helper->__('Qty. Sold')?>
</span>
</th>
-->
<th>
<span class="label">
<?php echo $helper->__('Qty')?>
</span>
</th>
<th>
<span class="label">
<?php echo $helper->__('Earn Amount')?>
</span>
</th>
<th>
<span class="label">
<?php echo $helper->__('Action')?>
</span>
</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach($this->getCollection() as $products){
$i++;
$productMediaConfig = Mage::getModel('catalog/product_media_config');
$salesdetail=Mage::getModel('marketplace/saleslist')->getSalesdetail($products->getEntityId());
?>
<tr class="wk_row_view <?php echo $class = ($i == count($this->getCollection()))? 'wk_last_tr':''?>">
<td class="wk_check_first_td">
<span>
<input type="checkbox" name="product_mass_delete[]" class="mpcheckbox" value="<?php echo $products->getEntityId(); ?>"/>
</span>
</td>
<td class="wk_first_td">
<input type="hidden" class="hidden_id" value="<?php echo $products->getEntityId(); ?>" />
<div class="label name" title="<?php echo $products->getName(); ?>">
<div class="wk_pro_divide1">
<img src="<?php echo Mage::helper('catalog/image')->init($products,'thumbnail');?>" class="image" />
</div>
<div class="wk_pro_divide2">
<div style="width:100%;">
<a href="<?php echo $this->getUrl($products->getUrlPath())?>" target="blank">
<?php echo $products->getName();?>
</a>
</div>
<div style="width:100%;float:left;">
<?php echo Mage::helper('core')->currency($products->getPrice(), true, false);?>
</div>
</div>
</div>
</td>
<td>
<?php echo $sku = Mage::getModel('catalog/product')->load($products->getId())->getSku();?>
</td>
<?php
if($products->getStatus()==2) { ?>
<td>
<span class="label pro_status">
<?php echo $helper->__('Pending')?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $helper->__('Pending')?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $helper->__('Pending')?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $helper->__('Pending')?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $helper->__('Pending')?>
</span>
</td>
<?php }
else{
$id=$products->getId();
$productsolddetail=Mage::getModel('marketplace/saleslist')->getProductSalesDetailById($id);
$qtycom=0;
$com=0;
foreach($productsolddetail as $key){
$qtycom+=$key['magequantity'];
$com+=$key['actualparterprocost'];
} ?>
<td>
<span class="label pro_status">
<?php echo $helper->__('Approved')?>
</span>
</td>
<!-- edit qty -->
<td>
<?php echo (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($products)->getQty(); ?>
<span class="label wk_action">
<img src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>" data-type="<?php echo $products->getTypeId(); ?>" alt="<?php echo $helper->__('Edit')?>" title="<?php echo $helper->__('Edit')?>" class="mp_edit"/>
</span>
</td>
<!-- edit qty end -->
<!--
<td>
<span class="label qty">
<?php echo $salesdetail['quantitysoldconfirmed']; ?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $salesdetail['quantitysoldpending']; ?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $salesdetail['quantitysold']; ?>
</span>
</td>
-->
<td>
<span class="label price">
<?php echo Mage::helper('core')->currency($salesdetail['amountearned'], true, false); ?>
</span>
</td>
<?php
}?>
<td>
<span class="label wk_action">
<img src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>" data-type="<?php echo $products->getTypeId(); ?>" alt="<?php echo $helper->__('Edit')?>" title="<?php echo $helper->__('Edit')?>" class="mp_edit"/>
<img src="<?php echo $this->getSkinUrl('marketplace/images/icon-trash.png'); ?>" alt="<?php echo $helper->__('Delete')?>" title="<?php echo $helper->__('Delete')?>" class="mp_delete"/>
</span>
</td>
</tr>
<?php
}?>
</tbody>
</table>
</form>
<?php
}?>
</div>
</div>
<?php echo $this->getPagerHtml(); ?>
</div>
<div class="buttons-set">
<p class="back-link">
« <?php echo $helper->__('Back') ?>
</p>
</div>
</div>
<script>
var $wk_jq=jQuery.noConflict();
var newCustomerProductForm1 = new VarienForm('formmassdelete', true);
(function($wk_jq){
$wk_jq( "#special_from_date" ).datepicker({dateFormat: "yy-mm-dd"});
$wk_jq( "#special_to_date" ).datepicker({dateFormat: "yy-mm-dd"});
$wk_jq('body').delegate('.mp_edit','click',function(){
var id=$wk_jq(this).parents('.wk_row_view').find('.hidden_id').val();
var dicision=confirm('<?php echo $helper->__(" Are you sure you want to edit this product ? ")?>');
if(dicision==true){
var $type_id=$wk_jq(this).attr('data-type');
if($type_id=='simple')
window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/editapprovedsimple/') ?>".concat("id/",id);
if($type_id=='downloadable')
window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/editapproveddownloadable/') ?>".concat("id/",id);
if($type_id=='virtual')
window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/editapprovedvirtual/') ?>".concat("id/",id);
if($type_id=='configurable')
window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/editapprovedconfigurable/') ?>".concat("id/",id);
if($type_id=='grouped')
window.location = "<?php echo $this->getUrl('mpgroupproduct/index/editapprovedgrouped/') ?>".concat("id/",id);
<?php
//echo $this->getChildHtml('mpgrouped_productslist');
// echo $this->getChildHtml('mpbundle_productslist');
?>
if($type_id=='bundle')
window.location = "<?php echo $this->getUrl('mpbundleproduct/index/editbundle/') ?>".concat("id/",id);
}
});
$wk_jq('#mass_delete_butn').click(function(e){
var flag =0;
$wk_jq('.mpcheckbox').each(function(){
if (this.checked == true){
flag =1;
}
});
if (flag == 0){
alert("<?php echo $helper->__(' No Checkbox is checked ') ?>");
return false;
}
else{
var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete these product ? ")?>');
if(dicisionapp==true){
$wk_jq('#form-customer-product-new').submit();
}else{
return false;
}
}
});
$wk_jq('#mpselecctall').click(function(event) {
if(this.checked) {
$wk_jq('.mpcheckbox').each(function() {
this.checked = true;
});
}else{
$wk_jq('.mpcheckbox').each(function() {
this.checked = false;
});
}
});
$wk_jq('.mp_delete').click(function(){
var id=$wk_jq(this).parents('.wk_row_view').find('.hidden_id').val();
var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete this product ? ")?>');
if(dicisionapp==true)
window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/delete/') ?>".concat("id/",id);
});
})($wk_jq);
</script>
<?php
}else{
echo "<h2 class='wk_new_msg'>".$helper->__("To BECOME SELLER PLEASE CONTACT TO ADMIN.")."</h2>";
}?>
we have a edit button next to "Qty", if we click on that edit button, its redirecting to another page and than seller edit the information and save it.
we are using following code to edit :
<span class="label wk_action">
<img src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>" data-type="<?php echo $products->getTypeId(); ?>" alt="<?php echo $helper->__('Edit')?>" title="<?php echo $helper->__('Edit')?>" class="mp_edit"/>
</span>
what we need is if we click on "edit" button, then it should display text field as like in the image and update and cancel button below.
Please refer below URL for admin grid:
http://www.atwix.com/magento/inline-editing-in-magento-backend-grids/
I'm not sure but this may help you. Try below for front-end :
Step 1 : Make onclick event on your edit image and call javascript function
eg : onclick="updateField(this, '. $product_id .'); return false";
Step 2 : Create javascript function which you have define in onclick of image.
<?php $url='Mage::getUrl('module_name/index/updateField/');' ?>
<script type="text/javascript">
function updateField(image, product_id)
{
new Ajax.Request('<?php echo $url ?>', {
method: 'post',
parameters: { id: fieldId, field: $(button).previous('input').getValue() }
});
}
</script>
Step: 3 Make function in your controller that you have define in java script ajax url.
public function updateFieldAction()
{
$fieldId = (int) $this->getRequest()->getParam('id');
$field = $this->getRequest()->getParam('field');
if ($fieldId) {
$model = Mage::getModel('modulename/model')->load($fieldId);
$model->setField($field);
$model->save();
}
}