* @copyright PrestaShop
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
* @version 1.3
*
*/
include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');
class AdminSearch extends AdminTab
{
/**
* Search a specific string in the products and categories
*
* @params string $query String to find in the catalog
*/
public function searchCatalog($query)
{
global $cookie;
$this->_list['products'] = Product::searchByName(intval($cookie->id_lang), $query);
if (!empty($this->_list['products']))
for ($i = 0; $i < count($this->_list['products']); $i++)
$this->_list['products'][$i]['nameh'] = str_ireplace($query, ''.$query.'', $this->_list['products'][$i]['name']);
$this->_list['categories'] = Category::searchByName(intval($cookie->id_lang), $query);
}
/**
* Search a specific name in the customers
*
* @params string $query String to find in the catalog
*/
public function searchCustomer($query)
{
$this->_list['customers'] = Customer::searchByName($query);
}
function postProcess()
{
global $cookie;
/* Handle empty search field */
if (!isset($_POST['bo_query']) OR empty($_POST['bo_query']) OR !isset($_POST['bo_search_type']))
{
echo '
| '.$this->l('Reference').' |
Product |
'.$this->l('Quantity').' |
'.$this->l('Unit price').' |
'.$this->l('Total price').' |
';
if ($products)
foreach ($products as $product)
echo '
| '.$product['reference'].' |
'.$product['name'].' |
'.$product['quantity'].' |
'.Tools::displayPrice($product['price'], $currency).' |
'.Tools::displayPrice($product['total_wt'], $currency).' |
';
if ($discounts)
foreach ($discounts as $discount)
echo '
| '.$discount['name'].' |
'.$discount['description'].' |
1 |
-'.Tools::displayPrice($discount['value'], $currency).' |
-'.Tools::displayPrice($discount['value'], $currency).' |
';
echo '
| '.$this->l('Products:').' |
'.Tools::displayPrice($total_products, $currency).' |
| '.$this->l('Vouchers').' |
'.Tools::displayPrice($total_discounts, $currency).' |
| '.$this->l('Gift-wrapping:').' |
'.Tools::displayPrice($total_wrapping, $currency).' |
| '.$this->l('Shipping:').' |
'.Tools::displayPrice($total_shipping, $currency).' |
| '.$this->l('Total:').' |
'.Tools::displayPrice($total_price, $currency).' |