Rhapsody Posted April 26, 2012 Share Posted April 26, 2012 I use the BO stats section, product detail links to run quick summary views for products that have been purchased. Thanks to some help from others, I have mods that substitute the name (first initial followed by last name) rather than the customer number. I also have a field that displays quantity sold in addition to the stock level. I would like to modify the code for this module so that I can: 1. have selectable arrows to click in the top row so that I can order the display according to that column (ascending or descending - similar to the orders and customers BO displays) 2. The fields I want to be able to sort on are: Date Order Member (this is a custom field I have in the ps_customer table) Name (want to sort by the last name even though the display is F. Lastname) A screenshot of the BO display of my existing statsproduct module is shown. I have also pasted the area where the existing code I am using that needs to be changed, and the entire modified statsproduct.php module I am using. Can anyone help me with the mods I need to make it do what I want? if ($totalBought) { $sales = $this->getSales($id_product, $cookie->id_lang); $this->_html .= '<br class="clear" /> <h3>'.$this->l('Sales').'</h3> <div style="overflow-y: scroll; height: '.min(400, (count($sales)+1)*32).'px;"> <table class="table" border="0" cellspacing="0" cellspacing="0"> <thead> <tr> <th>'.$this->l('Date').'</th> <th>'.$this->l('Order').'</th> <th>'.$this->l('Member').'</th> <th>'.$this->l('Customer').'</th> '.($hasAttribute ? '<th>'.$this->l('Attribute').'</th>' : '').' <th>'.$this->l('Qty').'</th> <th>'.$this->l('Price').'</th> </tr> </thead><tbody>'; $tokenOrder = Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee)); $tokenCustomer = Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($cookie->id_employee)); foreach ($sales as $sale) /* Rhapsody changed so customer name is displayed instead of customer id in table */ { $customer = new Customer($sale['id_customer']); // Kneler added $this->_html .= ' <tr> <td>'.Tools::displayDate($sale['date_add'], (int)($cookie->id_lang), false).'</td> <td align="center"><a href="?tab=AdminOrders&id_order='.$sale['id_order'].'&vieworder&token='.$tokenOrder.'">'.(int)($sale['id_order']).'</a></td> <td align="center"><a href="?tab=AdminCustomers&id_customer='.$sale['id_customer'].'&viewcustomer&token='.$tokenCustomer.'">'.$customer->member.'</a></td> <td align="center"><a href="?tab=AdminCustomers&id_customer='.$sale['id_customer'].'&viewcustomer&token='.$tokenCustomer.'">'.substr($customer->firstname, 0, 1).'. '.$customer->lastname.'</a></td> '.($hasAttribute ? '<td>'.$sale['product_name'].'</td>' : '').' <td>'.(int)($sale['product_quantity']).'</td> <td>'.Tools::displayprice($sale['total'], $currency).'</td> </tr>'; } /* End Rhapsody changed so customer name is displayed instead of customer id in table */ $this->_html .= '</tbody></table></div>'; statsproduct.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now