* @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 AdminCarts extends AdminTab
{
public function __construct()
{
$this->table = 'cart';
$this->className = 'Cart';
$this->lang = false;
$this->edit = false;
$this->view = true;
$this->delete = false;
$this->_select = 'CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`, a.id_cart as total, ca.name as carrier';
$this->_join = 'LEFT JOIN '._DB_PREFIX_.'customer c on (c.id_customer = a.id_customer)
LEFT JOIN '._DB_PREFIX_.'currency cu on (cu.id_currency = a.id_currency)
LEFT JOIN '._DB_PREFIX_.'carrier ca on (ca.id_carrier = a.id_carrier)
';
$this->fieldsDisplay = array(
'id_cart' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'customer' => array('title' => $this->l('Customer'), 'width' => 80, 'filter_key' => 'c!lastname'),
'total' => array('title' => $this->l('Total'), 'callback' => 'getTotalCart', 'orderby' => false, 'search' => false, 'width' => 50, 'align' => 'right', 'prefix' => '', 'suffix' => '', 'currency' => true),
'carrier' => array('title' => $this->l('Carrier'), 'width' => 25, 'align' => 'center', 'callback' => 'replaceZeroByShopName'),
'date_add' => array('title' => $this->l('Date'), 'width' => 90, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add'));
parent::__construct();
}
public function viewDetails()
{
global $currentIndex, $cookie;
$cart = $this->loadObject();
$customer = new Customer($cart->id_customer);
$customerStats = $customer->getStats();
$products = $cart->getProducts();
$customizedDatas = Product::getAllCustomizedDatas(intval($cart->id));
Product::addCustomizationPrice($products, $customizedDatas);
$summary = $cart->getSummaryDetails();
$discounts = $cart->getDiscounts();
$currency = new Currency($cart->id_currency);
$currentLanguage = new Language(intval($cookie->id_lang));
// display cart header
echo '
'.(($customer->id) ? $customer->firstname.' '.$customer->lastname : $this->l('Guest')).' - '.$this->l('Cart #').sprintf('%06d', $cart->id).' '.$this->l('from').' '.$cart->date_upd.'
';
/* Display customer information */
echo '
';
echo '
';
/* Display order information */
$id_order = intval(Order::getOrderByCartId($cart->id));
$order = new Order($id_order);
echo '
';
echo '
';
// List of products
echo '
';
}
private function displayCustomizedDatas(&$customizedDatas, &$product, &$currency, &$image, $tokenCatalog, &$stock)
{
$order = $this->loadObject();
if (is_array($customizedDatas) AND isset($customizedDatas[intval($product['id_product'])][intval($product['id_product_attribute'])]))
{
echo '
| '.(isset($image['id_image']) ? cacheImage(_PS_IMG_DIR_.'p/'.intval($product['id_product']).'-'.intval($image['id_image']).'.jpg',
'product_mini_'.intval($product['id_product']).(isset($product['id_product_attribute']) ? '_'.intval($product['id_product_attribute']) : '').'.jpg', 45, 'jpg') : '--').' |
'.$product['name'].'
'.($product['reference'] ? $this->l('Ref:').' '.$product['reference'] : '')
.(($product['reference'] AND $product['supplier_reference']) ? ' / '.$product['supplier_reference'] : '')
.' |
'.Tools::displayPrice($product['price_wt'], $currency, false, false).' |
'.$product['customizationQuantityTotal'].' |
'.intval($stock['quantity']).' |
'.Tools::displayPrice($product['total_customization_wt'], $currency, false, false).' |
';
foreach ($customizedDatas[intval($product['id_product'])][intval($product['id_product_attribute'])] AS $customization)
{
echo '
';
foreach ($customization['datas'] AS $type => $datas)
if ($type == _CUSTOMIZE_FILE_)
{
$i = 0;
echo '';
foreach ($datas AS $data)
echo '-
';
echo ' ';
}
elseif ($type == _CUSTOMIZE_TEXTFIELD_)
{
$i = 0;
echo '';
foreach ($datas AS $data)
echo '- '.($data['name']).$this->l(':').' '.$data['value'].'
';
echo ' ';
}
echo ' |
|
'.$customization['quantity'].' |
|
|
';
}
}
}
public function display()
{
global $cookie;
if (isset($_GET['view'.$this->table]))
$this->viewDetails();
else
{
$this->getList(intval($cookie->id_lang), !Tools::getValue($this->table.'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL);
$this->displayList();
}
}
}
?>