';
/* Display column names and arrows for ordering (ASC, DESC) */
if (array_key_exists($this->identifier,$this->identifiersDnd) AND $this->_orderBy == 'position')
{
echo '
';
}
echo 'identifier,$this->identifiersDnd) ? ' id="'.(((int)(Tools::getValue($this->identifiersDnd[$this->identifier], 1))) ? substr($this->identifier,3,strlen($this->identifier)) : '').'"' : '' ).' class="table'.((array_key_exists($this->identifier,$this->identifiersDnd) AND ($this->_orderBy != 'position 'AND $this->_orderWay != 'DESC')) ? ' tableDnD' : '' ).'" cellpadding="0" cellspacing="0">
';
if ($this->delete)
echo ' ';
echo ' | ';
foreach ($this->fieldsDisplay AS $key => $params)
{
echo ' '.$params['title'];
if (!isset($params['orderby']) OR $params['orderby'])
{
// Cleaning links
if (Tools::getValue($this->table.'Orderby') && Tools::getValue($this->table.'Orderway'))
$currentIndex = preg_replace('/&'.$this->table.'Orderby=([a-z _]*)&'.$this->table.'Orderway=([a-z]*)/i', '', $currentIndex);
echo '
';
}
echo ' | ';
}
/* Check if object can be modified, deleted or detailed */
if ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn'))
echo ' '.$this->l('Actions').' | ';
echo '
';
if ($this->delete)
echo ' --';
echo ' | ';
/* Javascript hack in order to catch ENTER keypress event */
$keyPress = 'onkeypress="formSubmit(event, \'submitFilterButton_'.$this->table.'\');"';
/* Filters (input, select, date or bool) */
foreach ($this->fieldsDisplay AS $key => $params)
{
$width = (isset($params['width']) ? ' style="width: '.(int)($params['width']).'px;"' : '');
echo '';
if (!isset($params['type']))
$params['type'] = 'text';
$value = Tools::getValue($this->table.'Filter_'.(array_key_exists('filter_key', $params) ? $params['filter_key'] : $key));
if (isset($params['search']) AND !$params['search'])
{
echo '-- | ';
continue;
}
switch ($params['type'])
{
case 'bool':
echo '
';
break;
case 'date':
case 'datetime':
if (is_string($value))
$value = unserialize($value);
if (!Validate::isCleanHtml($value[0]) OR !Validate::isCleanHtml($value[1]))
$value = '';
$name = $this->table.'Filter_'.(isset($params['filter_key']) ? $params['filter_key'] : $key);
$nameId = str_replace('!', '__', $name);
includeDatepicker(array($nameId.'_0', $nameId.'_1'));
echo $this->l('From').'
'.$this->l('To').' ';
break;
case 'select':
if (isset($params['filter_key']))
{
echo '';
break;
}
case 'text':
default:
if (!Validate::isCleanHtml($value))
$value = '';
echo '';
}
echo '';
}
if ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn'))
echo '-- | ';
echo '
';
}
public function displayListContent($token = NULL)
{
/* Display results in a table
*
* align : determine value alignment
* prefix : displayed before value
* suffix : displayed after value
* image : object image
* icon : icon determined by values
* active : allow to toggle status
*/
global $currentIndex, $cookie;
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$id_category = 1; // default categ
$irow = 0;
if ($this->_list AND isset($this->fieldsDisplay['position']))
{
$positions = array_map(create_function('$elem', 'return (int)($elem[\'position\']);'), $this->_list);
sort($positions);
}
if ($this->_list)
{
$isCms = false;
if (preg_match('/cms/Ui', $this->identifier))
$isCms = true;
$keyToGet = 'id_'.($isCms ? 'cms_' : '').'category'.(in_array($this->identifier, array('id_category', 'id_cms_category')) ? '_parent' : '');
foreach ($this->_list AS $tr)
{
$id = $tr[$this->identifier];
echo 'identifier,$this->identifiersDnd) ? ' id="tr_'.(($id_category = (int)(Tools::getValue('id_'.($isCms ? 'cms_' : '').'category', '1'))) ? $id_category : '').'_'.$id.'_'.$tr['position'].'"' : '').($irow++ % 2 ? ' class="alt_row"' : '').' '.((isset($tr['color']) AND $this->colorOnBackground) ? 'style="background-color: '.$tr['color'].'"' : '').'>
';
if ($this->delete AND (!isset($this->_listSkipDelete) OR !in_array($id, $this->_listSkipDelete)))
echo '';
echo ' | ';
foreach ($this->fieldsDisplay AS $key => $params)
{
$tmp = explode('!', $key);
$key = isset($tmp[1]) ? $tmp[1] : $tmp[0];
echo '
noLink) OR !$this->noLink))
echo ' onclick="document.location = \''.$currentIndex.'&'.$this->identifier.'='.$id.($this->view? '&view' : '&update').$this->table.'&token='.($token!=NULL ? $token : $this->token).'\'">'.(isset($params['prefix']) ? $params['prefix'] : '');
else
echo '>';
if ($key == 'id_product'
AND isset($tr[$key])
AND $tr[$key] !=0
AND isset($tr['id_order'])
) {
$order = new Order((int)$tr['id_order']);
$cart = new Cart((int)$order->id_cart);
$products = Db::getInstance()->executeS('
SELECT * FROM `'._DB_PREFIX_.'support_product_customerthread`
WHERE `id_customer_thread` = '.(int)$tr['id_customer_thread']
);
$supTo10 = 0;
$supTo100 = 0;
if(!empty($products)) {
foreach ($products as $product) {
$tax_rate = Tax::getProductTaxRate((int)$product['id_product'], (int)($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
$price = Product::getPriceStatic((int)$product['id_product'], false, (int)$product['id_product_attribute'], 6, NULL, false, true, 1, false, ((int)($tr['id_customer']) ? (int)($tr['id_customer']) : NULL), (int)($order->id_cart), ((int)($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) ? (int)($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) : NULL), $specificPriceOutput);
$price = Tools::ps_round($price * (1 + (float)($tax_rate) / 100), 2);
if($price>10){
$supTo10++;
}
if($price>100){
$supTo100++;
}
}
}
echo ($supTo10>0?' '.($supTo100>0?'':'').' ':'');
} elseif ($key == 'id_order' AND isset($tr[$key])) {
$order = new Order((int)$tr[$key]);
$cart = new Cart((int)$order->id_cart);
$nb_products = $cart->nbProducts();
echo ' '.($nb_products>0?$nb_products:'--').' ';
} elseif ($key == 'order' AND isset($tr['id_order']) AND (int)$tr['id_order']!=0) {
$currency = new Currency((int)(Configuration::get('PS_CURRENCY_DEFAULT')));
$order = new Order((int)$tr['id_order']);
$cart = new Cart((int)$order->id_cart);
echo ''.($order?Tools::displayPrice($cart->getOrderTotal(TRUE),$currency):'--').' ';
} elseif (isset($params['active']) AND isset($tr[$key])) {
$this->_displayEnableLink($token, $id, $tr[$key], $params['active'], Tools::getValue('id_category'), Tools::getValue('id_product'));
} elseif (isset($params['activeVisu']) AND isset($tr[$key])) {
echo '';
} elseif (isset($params['position'])) {
if ($this->_orderBy == 'position' AND $this->_orderWay != 'DESC')
{
echo '
';
echo '
'; }
else
echo (int)($tr[$key] + 1);
}
elseif (isset($params['image']))
{
// item_id is the product id in a product image context, else it is the image id.
$item_id = isset($params['image_id']) ? $tr[$params['image_id']] : $id;
// If it's a product image
if (isset($tr['id_image']))
{
$image = new Image((int)$tr['id_image']);
$path_to_image = _PS_IMG_DIR_.$params['image'].'/'.$image->getExistingImgPath().'.'.$this->imageType;
}else
$path_to_image = _PS_IMG_DIR_.$params['image'].'/'.$item_id.(isset($tr['id_image']) ? '-'.(int)($tr['id_image']) : '').'.'.$this->imageType;
echo cacheImage($path_to_image, $this->table.'_mini_'.$item_id.'.'.$this->imageType, 45, $this->imageType);
}
elseif (isset($params['icon']) AND (isset($params['icon'][$tr[$key]]) OR isset($params['icon']['default'])))
echo '';
elseif (isset($params['anticon']) AND (isset($params['anticon'][$tr[$key]]) OR isset($params['anticon']['default'])))
echo ' ';
elseif (isset($params['price']))
echo Tools::displayPrice($tr[$key], (isset($params['currency']) ? Currency::getCurrencyInstance((int)($tr['id_currency'])) : $currency), false);
elseif (isset($params['float']))
echo rtrim(rtrim($tr[$key], '0'), '.');
elseif (isset($params['type']) AND $params['type'] == 'date')
echo Tools::displayDate($tr[$key], (int)$cookie->id_lang);
elseif (isset($params['type']) AND $params['type'] == 'datetime')
echo Tools::displayDate($tr[$key], (int)$cookie->id_lang, true);
elseif (isset($params['type']) AND $params['type'] == 'datetimeLight')
echo date('d/m/Y H:i',strtotime($tr[$key]));
elseif (isset($tr[$key]))
{
$echo = ($key == 'price' ? round($tr[$key], 2) : isset($params['maxlength']) ? Tools::substr($tr[$key], 0, $params['maxlength']).'...' : $tr[$key]);
echo isset($params['callback']) ? call_user_func_array(array($this->className, $params['callback']), array($echo, $tr)) : $echo;
}
else
echo '--';
echo (isset($params['suffix']) ? $params['suffix'] : '').
' | ';
}
if ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn'))
{
echo '';
if ($this->view)
$this->_displayViewLink($token, $id);
if ($this->edit)
$this->_displayEditLink($token, $id);
if ($this->delete AND (!isset($this->_listSkipDelete) OR !in_array($id, $this->_listSkipDelete)))
$this->_displayDeleteLink($token, $id);
if ($this->duplicate)
$this->_displayDuplicate($token, $id);
echo ' | ';
}
echo ' ';
}
}
}
protected function _displayDeleteLink($token, $id)
{
global $currentIndex;
$_cacheLang['Delete'] = $this->l('Delete');
$_cacheLang['DeleteItem'] = $this->l('Delete item #', __CLASS__, TRUE, FALSE);
echo '
';
}
protected function _displayViewLink($token = NULL, $id)
{
global $currentIndex;
$_cacheLang['View'] = $this->l('View');
echo '
';
}
private function openUploadedFile()
{
$filename = $_GET['filename'];
$extensions = array('.txt' => 'text/plain', '.rtf' => 'application/rtf', '.doc' => 'application/msword', '.docx'=> 'application/msword',
'.pdf' => 'application/pdf', '.zip' => 'multipart/x-zip', '.png' => 'image/png', '.jpeg' => 'image/jpeg', '.gif' => 'image/gif', '.jpg' => 'image/jpeg');
$extension = '';
foreach ($extensions AS $key => $val)
if (substr($filename, -4) == $key OR substr($filename, -5) == $key)
{
$extension = $val;
break;
}
ob_end_clean();
header('Content-Type: '.$extension);
header('Content-Disposition:attachment;filename="'.$filename.'"');
readfile(_PS_UPLOAD_DIR_.$filename);
die;
}
private function displayMsgCustom($message, $email = false, $id_employee = null)
{
global $cookie, $currentIndex;
$customersToken = Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($cookie->id_employee));
$contacts = Contact::getContacts($cookie->id_lang);
$output = '';
if (!$email)
{
if (!empty($message['id_product']) AND empty($message['employee_name']))
$id_order_product = Db::getInstance()->getValue('
SELECT o.id_order
FROM '._DB_PREFIX_.'orders o
LEFT JOIN '._DB_PREFIX_.'order_detail od ON o.id_order = od.id_order
WHERE o.id_customer = '.(int)$message['id_customer'].'
AND od.product_id = '.(int)$message['id_product'].'
ORDER BY o.date_add DESC');
$output .= '
'.(!empty($message['employee_name'])
?' '.Configuration::get('PS_SHOP_NAME').' - '.$message['employee_name']
:'
'.(!empty($message['id_customer'])
?' '.strtoupper($message['customer_name']).''
: $message['email'])
).
'
'.Tools::displayDate($message['date_add'], (int)($cookie->id_lang), true).'
'.(
(!empty($message['file_name']) AND file_exists(_PS_UPLOAD_DIR_.$message['file_name']))
? ' '
: ''
)
.(empty($message['employee_name'])
?' '
:'').'
';
if(empty($message['employee_name'])){
$output .='
'.$this->l('Informations').'
';
}
$output .= ' ';
}
else
{
$output .= '
'.($id_employee ? ' '.$this->l('View this thread').'' : '').'
'.$this->l('Sent by:').' '.(!empty($message['customer_name']) ? $message['customer_name'].' ('.$message['email'].')' : $message['email'])
.((!empty($message['id_customer']) AND empty($message['employee_name'])) ? ' '.$this->l('Customer ID:').' '.(int)($message['id_customer']).' ' : '')
.((!empty($message['id_order']) AND empty($message['employee_name'])) ? ' '.$this->l('Order #').': '.(int)($message['id_order']).' ' : '')
.((!empty($message['id_product']) AND empty($message['employee_name'])) ? ' '.$this->l('Product #').': '.(int)($message['id_product']).' ' : '')
.' '.$this->l('Subject:').' '.$message['subject'];
}
$employees = Db::getInstance()->ExecuteS('
SELECT e.id_employee, e.firstname, e.lastname FROM '._DB_PREFIX_.'employee e
WHERE e.active = 1 ORDER BY e.lastname ASC');
$output .= ' ';
// Adding Antadis - linking with ant_support_form module
if (Module::isInstalled('ant_support_form')) {
$result = Db::getInstance()->getRow('
SELECT sr.*, srl.title
FROM `'._DB_PREFIX_.'support_reason` sr
LEFT JOIN `'._DB_PREFIX_.'support_reason_lang` srl ON (srl.id_reason = sr.id_reason)
LEFT JOIN `'._DB_PREFIX_.'support_reason_customerthread` src ON (src.id_reason = sr.id_reason)
WHERE `id_customer_thread` = '.(int) $message['id_customer_thread'].'
AND srl.id_lang = '.$cookie->id_lang
);
if ($result) {
$output .='
'.$this->l('Reason:').' '.$result['title'].' ';
}
}
// end adding
$message['message'] = preg_replace('/(https?:\/\/[a-z0-9#%&_=\(\)\.\? \+\-@\/]{6,1000})([\s\n<])/Uui', ' \1\2', html_entity_decode($message['message'], ENT_NOQUOTES, 'UTF-8'));
$output .= '
'.$this->l('Message:').'
'.$message['message'].'
';
if (!$email)
{
if (empty($message['employee_name'])) {
$orderMessages = OrderMessage::getOrderMessages((int)($message['id_lang']));
$output .= '
';
}
}
$output .= ' ';
return $output;
}
private function displayMsg($message, $email = false, $id_employee = null)
{
global $cookie, $currentIndex;
$customersToken = Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($cookie->id_employee));
$contacts = Contact::getContacts($cookie->id_lang);
if (!$email)
{
if (!empty($message['id_product']) AND empty($message['employee_name']))
$id_order_product = Db::getInstance()->getValue('
SELECT o.id_order
FROM '._DB_PREFIX_.'orders o
LEFT JOIN '._DB_PREFIX_.'order_detail od ON o.id_order = od.id_order
WHERE o.id_customer = '.(int)$message['id_customer'].'
AND od.product_id = '.(int)$message['id_product'].'
ORDER BY o.date_add DESC');
$output = '
|