init
This commit is contained in:
commit
36283ffdc7
|
|
@ -0,0 +1,5 @@
|
|||
# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
|
||||
# http://www.prestashop.com - http://www.prestashop.com/forums
|
||||
|
||||
# Catch 404 errors
|
||||
ErrorDocument 404 /kaktusy/404.php
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
if (in_array(substr($_SERVER['REQUEST_URI'], -3), array('png', 'jpg', 'gif')))
|
||||
{
|
||||
include(dirname(__FILE__).'/config/settings.inc.php');
|
||||
header('Location: '.__PS_BASE_URI__.'img/404.gif');
|
||||
exit;
|
||||
}
|
||||
|
||||
include(dirname(__FILE__).'/config/config.inc.php');
|
||||
include(dirname(__FILE__).'/header.php');
|
||||
|
||||
$smarty->display(_PS_THEME_DIR_.'404.tpl');
|
||||
|
||||
include(dirname(__FILE__).'/footer.php');
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
<?php
|
||||
|
||||
/* SSL Management */
|
||||
$useSSL = true;
|
||||
|
||||
include(dirname(__FILE__).'/config/config.inc.php');
|
||||
include(dirname(__FILE__).'/init.php');
|
||||
|
||||
if (!$cookie->isLogged())
|
||||
Tools::redirect('authentication.php');
|
||||
|
||||
//CSS ans JS file calls
|
||||
$js_files = array(
|
||||
_THEME_JS_DIR_.'tools/statesManagement.js'
|
||||
);
|
||||
|
||||
if ($back = Tools::getValue('back'))
|
||||
$smarty->assign('back', Tools::safeOutput($back));
|
||||
if ($mod = Tools::getValue('mod'))
|
||||
$smarty->assign('mod', Tools::safeOutput($mod));
|
||||
|
||||
$errors = array();
|
||||
|
||||
if ($id_address = intval(Tools::getValue('id_address')))
|
||||
{
|
||||
$address = new Address(intval($id_address));
|
||||
if (Validate::isLoadedObject($address) AND Customer::customerHasAddress(intval($cookie->id_customer), intval($id_address)))
|
||||
{
|
||||
if (Tools::isSubmit('delete'))
|
||||
{
|
||||
if ($cart->id_address_invoice == $address->id)
|
||||
unset($cart->id_address_invoice);
|
||||
if ($cart->id_address_delivery == $address->id)
|
||||
unset($cart->id_address_delivery);
|
||||
if ($address->delete())
|
||||
Tools::redirect('addresses.php');
|
||||
$errors[] = Tools::displayError('this address cannot be deleted');
|
||||
}
|
||||
$smarty->assign(array(
|
||||
'address' => $address,
|
||||
'id_address' => intval($id_address)
|
||||
));
|
||||
}
|
||||
else
|
||||
Tools::redirect('addresses.php');
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitAddress'))
|
||||
{
|
||||
$address = new Address();
|
||||
$errors = $address->validateControler();
|
||||
$address->id_customer = intval($cookie->id_customer);
|
||||
|
||||
if (Configuration::get('PS_TOKEN_ENABLE') == 1 &&
|
||||
strcmp(Tools::getToken(false), Tools::getValue('token')) &&
|
||||
$cookie->isLogged() === true)
|
||||
$errors[] = Tools::displayError('invalid token');
|
||||
|
||||
if (!$country = new Country($address->id_country) OR !Validate::isLoadedObject($country))
|
||||
die(Tools::displayError());
|
||||
if (intval($country->contains_states) AND !intval($address->id_state))
|
||||
$errors[] = Tools::displayError('this country require a state selection');
|
||||
|
||||
if (!sizeof($errors))
|
||||
{
|
||||
if (isset($id_address))
|
||||
{
|
||||
$country = new Country(intval($address->id_country));
|
||||
if (Validate::isLoadedObject($country) AND !$country->contains_states)
|
||||
$address->id_state = false;
|
||||
$address_old = new Address(intval($id_address));
|
||||
if (Validate::isLoadedObject($address_old) AND Customer::customerHasAddress(intval($cookie->id_customer), intval($address_old->id)))
|
||||
{
|
||||
if ($cart->id_address_invoice == $address_old->id)
|
||||
unset($cart->id_address_invoice);
|
||||
if ($cart->id_address_delivery == $address_old->id)
|
||||
unset($cart->id_address_delivery);
|
||||
|
||||
if ($address_old->isUsed())
|
||||
$address_old->delete();
|
||||
else
|
||||
{
|
||||
$address->id = intval($address_old->id);
|
||||
$address->date_add = $address_old->date_add;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($result = $address->save())
|
||||
{
|
||||
if ((bool)(Tools::getValue('select_address', false)) == true)
|
||||
{
|
||||
/* This new adress is for invoice_adress, select it */
|
||||
$cart->id_address_invoice = intval($address->id);
|
||||
$cart->update();
|
||||
}
|
||||
Tools::redirect($back ? ($mod ? $back.'&back='.$mod : $back) : 'addresses.php');
|
||||
}
|
||||
$errors[] = Tools::displayError('an error occurred while updating your address');
|
||||
}
|
||||
}
|
||||
elseif (!$id_address)
|
||||
{
|
||||
$customer = new Customer(intval($cookie->id_customer));
|
||||
if (Validate::isLoadedObject($customer))
|
||||
{
|
||||
$_POST['firstname'] = $customer->firstname;
|
||||
$_POST['lastname'] = $customer->lastname;
|
||||
}
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('id_country') AND Tools::getValue('id_country') != NULL AND is_numeric(Tools::getValue('id_country')))
|
||||
$selectedCountry = intval(Tools::getValue('id_country'));
|
||||
elseif (isset($address) AND isset($address->id_country) AND !empty($address->id_country) AND is_numeric($address->id_country))
|
||||
$selectedCountry = intval($address->id_country);
|
||||
elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
|
||||
{
|
||||
$array = preg_split('/,|-/', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
||||
if (!Validate::isLanguageIsoCode($array[0]) OR !($selectedCountry = Country::getByIso($array[0])))
|
||||
$selectedCountry = intval(Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
}
|
||||
else
|
||||
$selectedCountry = intval(Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
|
||||
$countries = Country::getCountries(intval($cookie->id_lang), true);
|
||||
$countriesList = '';
|
||||
foreach ($countries AS $country)
|
||||
$countriesList .= '<option value="'.intval($country['id_country']).'" '.($country['id_country'] == $selectedCountry ? 'selected="selected"' : '').'>'.htmlentities($country['name'], ENT_COMPAT, 'UTF-8').'</option>';
|
||||
|
||||
include(dirname(__FILE__).'/header.php');
|
||||
$smarty->assign(array(
|
||||
'countries_list' => $countriesList,
|
||||
'countries' => $countries,
|
||||
'errors' => $errors,
|
||||
'token' => Tools::getToken(false),
|
||||
'select_address' => intval(Tools::getValue('select_address'))
|
||||
));
|
||||
Tools::safePostVars();
|
||||
$smarty->display(_PS_THEME_DIR_.'address.tpl');
|
||||
include(dirname(__FILE__).'/footer.php');
|
||||
?>
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
/* SSL Management */
|
||||
$useSSL = true;
|
||||
|
||||
include(dirname(__FILE__).'/config/config.inc.php');
|
||||
include(dirname(__FILE__).'/init.php');
|
||||
|
||||
if (!$cookie->isLogged())
|
||||
Tools::redirect('authentication.php?back=addresses.php');
|
||||
|
||||
$customer = new Customer(intval($cookie->id_customer));
|
||||
if (!Validate::isLoadedObject($customer))
|
||||
die(Tools::displayError('customer not found'));
|
||||
|
||||
include(dirname(__FILE__).'/header.php');
|
||||
$smarty->assign('addresses', $customer->getAddresses(intval($cookie->id_lang)));
|
||||
$smarty->display(_PS_THEME_DIR_.'addresses.tpl');
|
||||
include(dirname(__FILE__).'/footer.php');
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,200 @@
|
|||
<?php
|
||||
|
||||
define('PS_ADMIN_DIR', getcwd());
|
||||
include(PS_ADMIN_DIR.'/../config/config.inc.php');
|
||||
/* Getting cookie or logout */
|
||||
require_once(dirname(__FILE__).'/init.php');
|
||||
|
||||
if (isset($_GET['ajaxProductManufacturers']))
|
||||
{
|
||||
$currentIndex = 'index.php?tab=AdminCatalog';
|
||||
$manufacturers = Manufacturer::getManufacturers();
|
||||
if ($manufacturers)
|
||||
{
|
||||
$jsonArray = array();
|
||||
foreach ($manufacturers AS $manufacturer)
|
||||
$jsonArray[] = '{optionValue: '.$manufacturer['id_manufacturer'].', optionDisplay: \''.addslashes($manufacturer['name']).'\'}';
|
||||
die('['.implode(',', $jsonArray).']');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['ajaxProductSuppliers']))
|
||||
{
|
||||
$currentIndex = 'index.php?tab=AdminCatalog';
|
||||
$suppliers = Supplier::getSuppliers();
|
||||
if ($suppliers)
|
||||
{
|
||||
$jsonArray = array();
|
||||
foreach ($suppliers AS $supplier)
|
||||
$jsonArray[] = '{optionValue: '.$supplier['id_supplier'].', optionDisplay: \''.addslashes($supplier['name']).'\'}';
|
||||
die('['.implode(',', $jsonArray).']');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['ajaxProductAccessories']))
|
||||
{
|
||||
$currentIndex = 'index.php?tab=AdminCatalog';
|
||||
$jsonArray = array();
|
||||
|
||||
$products = Db::getInstance()->ExecuteS('
|
||||
SELECT p.`id_product`, pl.`name`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
NATURAL LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
WHERE pl.`id_lang` = '.intval(Tools::getValue('id_lang')).'
|
||||
AND p.`id_product` != '.intval(Tools::getValue('id_product')).'
|
||||
AND p.`id_product` NOT IN (
|
||||
SELECT a.`id_product_2`
|
||||
FROM `'._DB_PREFIX_.'accessory` a
|
||||
WHERE a.`id_product_1` = '.intval(Tools::getValue('id_product')).')
|
||||
ORDER BY pl.`name`');
|
||||
|
||||
foreach ($products AS $accessory)
|
||||
$jsonArray[] = '{value: \''.intval($accessory['id_product']).'-'.addslashes($accessory['name']).'\', text:\''.intval($accessory['id_product']).' - '.addslashes($accessory['name']).'\'}';
|
||||
die('['.implode(',', $jsonArray).']');
|
||||
}
|
||||
|
||||
if (isset($_GET['ajaxDiscountCustomers']))
|
||||
{
|
||||
$currentIndex = 'index.php?tab=AdminDiscounts';
|
||||
$jsonArray = array();
|
||||
$filter = Tools::getValue('filter');
|
||||
|
||||
$customers = Db::getInstance()->ExecuteS('
|
||||
SELECT `id_customer`, `email`, CONCAT(`lastname`, \' \', `firstname`) as name
|
||||
FROM `'._DB_PREFIX_.'customer`
|
||||
WHERE email LIKE "%'.pSQL($filter).'%"
|
||||
'.(intval($filter) ? 'OR id_customer = '.intval($filter) : '').'
|
||||
OR CONCAT(`firstname`, \' \', `lastname`) LIKE "%'.pSQL($filter).'%"
|
||||
OR CONCAT(`lastname`, \' \', `firstname`) LIKE "%'.pSQL($filter).'%"
|
||||
ORDER BY CONCAT(`lastname`, \' \', `firstname`) ASC
|
||||
LIMIT 50');
|
||||
|
||||
foreach ($customers AS $customer)
|
||||
$jsonArray[] = '{value:'.intval($customer['id_customer']).', text:\''.addslashes($customer['name']).' ('.addslashes($customer['email']).')\'}';
|
||||
die('['.implode(',', $jsonArray).']');
|
||||
}
|
||||
|
||||
if (Tools::getValue('page') == 'prestastore')
|
||||
readfile('http://www.prestastore.com/adminmodules.php?lang='.Language::getIsoById($cookie->id_lang));
|
||||
if (Tools::getValue('page') == 'themes')
|
||||
readfile('http://www.prestastore.com/adminthemes.php?lang='.Language::getIsoById($cookie->id_lang));
|
||||
|
||||
if ($step = intval(Tools::getValue('ajaxProductTab')))
|
||||
{
|
||||
require_once(dirname(__FILE__).'/tabs/AdminCatalog.php');
|
||||
$catalog = new AdminCatalog();
|
||||
$admin = new AdminProducts();
|
||||
|
||||
$languages = Language::getLanguages();
|
||||
$defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
|
||||
$product = new Product(intval(Tools::getValue('id_product')));
|
||||
if (!Validate::isLoadedObject($product))
|
||||
die (Tools::displayError('product cannot be loaded'));
|
||||
|
||||
$switchArray = array(3 => 'displayFormAttributes', 4 => 'displayFormFeatures', 5 => 'displayFormCustomization', 6 => 'displayFormQuantityDiscount', 7 => 'displayFormAttachments');
|
||||
$currentIndex = 'index.php?tab=AdminCatalog';
|
||||
if (key_exists($step, $switchArray))
|
||||
$admin->{$switchArray[$step]}($product, $languages, $defaultLanguage);
|
||||
}
|
||||
|
||||
if (isset($_GET['getAvailableFields']) and isset($_GET['entity']))
|
||||
{
|
||||
$currentIndex = 'index.php?tab=AdminImport';
|
||||
$jsonArray = array();
|
||||
require_once(dirname(__FILE__).'/tabs/AdminImport.php');
|
||||
$import = new AdminImport();
|
||||
|
||||
$languages = Language::getLanguages();
|
||||
$defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
|
||||
$fields = $import->getAvailableFields(true);
|
||||
foreach ($fields AS $field)
|
||||
$jsonArray[] = '{field: \''.addslashes($field).'\'}';
|
||||
die('['.implode(',', $jsonArray).']');
|
||||
}
|
||||
|
||||
if (array_key_exists('ajaxModulesPositions', $_POST))
|
||||
{
|
||||
$id_module = intval(Tools::getValue('id_module'));
|
||||
$id_hook = intval(Tools::getValue('id_hook'));
|
||||
$way = intval(Tools::getValue('way'));
|
||||
$positions = Tools::getValue(strval($id_hook));
|
||||
$position = (is_array($positions)) ? array_search($id_hook.'_'.$id_module, $positions) : null;
|
||||
$module = Module::getInstanceById($id_module);
|
||||
if (Validate::isLoadedObject($module))
|
||||
if ($module->updatePosition($id_hook, $way, $position))
|
||||
die(true);
|
||||
else
|
||||
die('{\'hasError\' : true, errors : \'Can not update module position\'}');
|
||||
else
|
||||
die('{\'hasError\' : true, errors : \'This module can not be loaded\'}');
|
||||
}
|
||||
|
||||
if (array_key_exists('ajaxProductsPositions', $_POST))
|
||||
{
|
||||
$way = intval(Tools::getValue('way'));
|
||||
$id_product = intval(Tools::getValue('id_product'));
|
||||
$id_category = intval(Tools::getValue('id_category'));
|
||||
$positions = Tools::getValue(strval($id_category));
|
||||
|
||||
if (is_array($positions))
|
||||
foreach ($positions AS $key => $value)
|
||||
{
|
||||
$pos = explode('_', $value);
|
||||
if ((isset($pos[1]) AND isset($pos[2])) AND ($pos[1] == $id_category AND $pos[2] == $id_product))
|
||||
{
|
||||
$position = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$product = new Product($id_product);
|
||||
if (Validate::isLoadedObject($product))
|
||||
{
|
||||
if (isset($position) && $product->updatePosition($way, $position))
|
||||
die(true);
|
||||
else
|
||||
die('{\'hasError\' : true, errors : \'Can not update product position\'}');
|
||||
}
|
||||
else
|
||||
die('{\'hasError\' : true, errors : \'This product can not be loaded\'}');
|
||||
}
|
||||
|
||||
if (isset($_GET['ajaxProductPackItems']))
|
||||
{
|
||||
$jsonArray = array();
|
||||
$products = Db::getInstance()->ExecuteS('
|
||||
SELECT p.`id_product`, pl.`name`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
NATURAL LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
WHERE pl.`id_lang` = '.intval(Tools::getValue('id_lang')).'
|
||||
AND p.`id_product` NOT IN (SELECT DISTINCT id_product_pack FROM `'._DB_PREFIX_.'pack`)
|
||||
AND p.`id_product` != '.intval(Tools::getValue('id_product')));
|
||||
|
||||
foreach ($products AS $packItem)
|
||||
$jsonArray[] = '{value: \''.intval($packItem['id_product']).'-'.addslashes($packItem['name']).'\', text:\''.intval($packItem['id_product']).' - '.addslashes($packItem['name']).'\'}';
|
||||
die('['.implode(',', $jsonArray).']');
|
||||
}
|
||||
|
||||
if (isset($_GET['ajaxStates']) AND isset($_GET['id_country']))
|
||||
{
|
||||
$states = Db::getInstance()->ExecuteS('
|
||||
SELECT s.id_state, s.name
|
||||
FROM '._DB_PREFIX_.'state s
|
||||
LEFT JOIN '._DB_PREFIX_.'country c ON (s.`id_country` = c.`id_country`)
|
||||
WHERE s.id_country = '.intval(Tools::getValue('id_country')).' AND s.active = 1 AND c.`contains_states` = 1');
|
||||
|
||||
$list = '<option value="0">-----------</option>'."\n";
|
||||
foreach ($states AS $state)
|
||||
$list .= '<option value="'.intval($state['id_state']).'"'.((isset($_GET['id_state']) AND $_GET['id_state'] == $state['id_state']) ? ' selected="selected"' : '').'>'.$state['name'].'</option>'."\n";
|
||||
|
||||
die($list);
|
||||
}
|
||||
|
||||
if (Tools::getValue('form_language_id'))
|
||||
{
|
||||
if (!($cookie->employee_form_lang = intval(Tools::getValue('form_language_id'))))
|
||||
die ('Error while updating cookie.');
|
||||
die ('Form language updated.');
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
define('PS_ADMIN_DIR', getcwd());
|
||||
include(PS_ADMIN_DIR.'/../config/config.inc.php');
|
||||
/* Getting cookie or logout */
|
||||
require_once(dirname(__FILE__).'/init.php');
|
||||
|
||||
if(!isset($_GET['iso']) OR empty($_GET['iso']))
|
||||
die('fail:0');
|
||||
|
||||
if(@fsockopen('www.prestashop.com', 80))
|
||||
{
|
||||
// Get all iso code available
|
||||
$lang_packs = file_get_contents('http://www.prestashop.com/rss/lang_exists.php');
|
||||
|
||||
if ($lang_packs)
|
||||
{
|
||||
$lang_packs = unserialize($lang_packs);
|
||||
foreach($lang_packs as $lang_pack)
|
||||
{
|
||||
if($lang_pack['iso_code'] == $_GET['iso'])
|
||||
die('ok');
|
||||
}
|
||||
die('fail:1');
|
||||
}
|
||||
else
|
||||
die('fail:2');
|
||||
}
|
||||
die('offline');
|
||||
?>
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
define('PS_ADMIN_DIR', getcwd());
|
||||
include(PS_ADMIN_DIR.'/../config/config.inc.php');
|
||||
/* Getting cookie or logout */
|
||||
require_once(dirname(__FILE__).'/init.php');
|
||||
|
||||
$query = Tools::getValue('q', false);
|
||||
if (!$query OR $query == '' OR strlen($query) < 1)
|
||||
die();
|
||||
|
||||
if ($excludeIds = Tools::getValue('excludeIds', false))
|
||||
$excludeIds = implode(',', array_map('intval', explode(',', $excludeIds)));
|
||||
|
||||
$items = Db::getInstance()->ExecuteS('
|
||||
SELECT p.`id_product`, `reference`, pl.name
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product = p.id_product)
|
||||
WHERE (pl.name LIKE \'%'.pSQL($query).'%\' OR p.reference LIKE \'%'.pSQL($query).'%\') AND pl.id_lang = '.intval($cookie->id_lang).
|
||||
(!empty($excludeIds) ? ' AND p.id_product NOT IN ('.$excludeIds.') ' : ''));
|
||||
|
||||
if ($items)
|
||||
foreach ($items AS $item)
|
||||
echo $item['name'].(!empty($item['reference']) ? ' ('.$item['reference'].')' : '').'|'.intval($item['id_product'])."\n";
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
include_once(dirname(__FILE__).'/../config/config.inc.php');
|
||||
|
||||
/* Getting cookie or logout */
|
||||
require_once(dirname(__FILE__).'/init.php');
|
||||
|
||||
$smtpChecked = (trim($_GET['mailMethod']) == 'smtp');
|
||||
$smtpServer = $_GET['smtpSrv'];
|
||||
$content = $_GET['testMsg'];
|
||||
$subject = $_GET['testSubject'];
|
||||
$type = 'text/html';
|
||||
$to = $_GET['testEmail'];
|
||||
$from = 'no-reply@'.Tools::getHttpHost(false, true).'.com';
|
||||
$smtpLogin = $_GET['smtpLogin'];
|
||||
$smtpPassword = $_GET['smtpPassword'];
|
||||
$smtpPort = $_GET['smtpPort'];
|
||||
$smtpEncryption = $_GET['smtpEnc'];
|
||||
|
||||
$result = Mail::sendMailTest($smtpChecked, $smtpServer, $content, $subject, $type, $to, $from, $smtpLogin, $smtpPassword, $smtpPort, $smtpEncryption);
|
||||
die($result ? 'ok' : 'fail');
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
/**
|
||||
* Simple file which allows fetching of backup files
|
||||
* @category admin
|
||||
*
|
||||
* @author Andrew Brampton
|
||||
* @copyright Andrew Brampton
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 0.1
|
||||
*
|
||||
*/
|
||||
|
||||
define('PS_ADMIN_DIR', getcwd());
|
||||
|
||||
include(PS_ADMIN_DIR.'/../config/config.inc.php');
|
||||
|
||||
/* Header can't be included, so cookie must be created here */
|
||||
$cookie = new Cookie('psAdmin');
|
||||
if (!$cookie->id_employee)
|
||||
Tools::redirect('login.php');
|
||||
|
||||
$tabAccess = Profile::getProfileAccess($cookie->profile, Tab::getIdFromClassName('AdminBackup'));
|
||||
|
||||
if ($tabAccess['view'] !== '1')
|
||||
die (Tools::displayError('You do not have permission to view here'));
|
||||
|
||||
$backupdir = realpath( PS_ADMIN_DIR . '/backups/');
|
||||
|
||||
if ($backupdir === false)
|
||||
die (Tools::displayError('Backups directory does not exist'));
|
||||
|
||||
if (!$backupfile = Tools::getValue('filename'))
|
||||
die (Tools::displayError('no file specified'));
|
||||
|
||||
// Check the realpath so we can validate the backup file is under the backup directory
|
||||
$backupfile = realpath($backupdir.'/'.$backupfile);
|
||||
|
||||
if ($backupfile === false OR strncmp($backupdir, $backupfile, strlen($backupdir)) != 0 )
|
||||
die (Tools::displayError());
|
||||
|
||||
if (substr($backupfile, -4) == '.bz2')
|
||||
$contentType = 'application/x-bzip2';
|
||||
else if (substr($backupfile, -3) == '.gz')
|
||||
$contentType = 'application/x-gzip';
|
||||
else
|
||||
$contentType = 'text/x-sql';
|
||||
$fp = @fopen($backupfile, 'r');
|
||||
|
||||
if ($fp === false)
|
||||
die (Tools::displayError('Unable to open backup file').' "'.addslashes($backupfile).'"');
|
||||
|
||||
// Add the correct headers, this forces the file is saved
|
||||
header('Content-Type: '.$contentType);
|
||||
header('Content-Disposition: attachment; filename="'.Tools::getValue('filename'). '"');
|
||||
|
||||
$ret = @fpassthru($fp);
|
||||
|
||||
fclose($fp);
|
||||
|
||||
if ($ret === false)
|
||||
die (Tools::displayError('Unable to display backup file').' "'.addslashes($backupfile).'"');
|
||||
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Order deny,allow
|
||||
Deny from all
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
define('PS_ADMIN_DIR', getcwd());
|
||||
|
||||
include(PS_ADMIN_DIR.'/../config/config.inc.php');
|
||||
$cookie = new Cookie('psAdmin');
|
||||
Tools::setCookieLanguage();
|
||||
|
||||
$translations = array(
|
||||
'FR' => array(
|
||||
'Referer is missing' => 'Vous devez indiquer un "referer"',
|
||||
'Confirmation' => 'Confirmation',
|
||||
'Yes' => 'Oui',
|
||||
'No' => 'Non',
|
||||
'close' => 'fermer')
|
||||
);
|
||||
|
||||
if (!Tools::getValue('referer')):
|
||||
echo '<p>'.Tools::historyc_l('Referer is missing', $translations).'</p>';
|
||||
echo '<p><a href="#" onclick="tb_remove()">'.Tools::historyc_l('close', $translations).'</a></p>';
|
||||
else:
|
||||
$referer = Tools::htmlentitiesUTF8(rawurldecode(Tools::getValue('referer')));
|
||||
|
||||
?>
|
||||
|
||||
<h2><?php echo Tools::historyc_l('Confirmation', $translations) ?></h2>
|
||||
<p>
|
||||
<a href="#" class="thickbox confirm_yes" title="" onclick="tb_remove(); window.open('<?php echo $referer ?>', '_self')">
|
||||
<?php echo Tools::historyc_l('Yes', $translations) ?>
|
||||
</a>
|
||||
<a href="#" class="confirm_no" onclick="tb_remove()"><?php echo Tools::historyc_l('No', $translations) ?></a>
|
||||
</p>
|
||||
|
||||
<?php endif; //check if referer exists ?>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
require_once(dirname(__FILE__).'/../config/config.inc.php');
|
||||
require_once(dirname(__FILE__).'/init.php');
|
||||
|
||||
if (isset($_GET['img']) AND Validate::isMd5($_GET['img']) AND isset($_GET['name']) AND Validate::isGenericName($_GET['name']) AND file_exists(_PS_PROD_PIC_DIR_.$_GET['img']))
|
||||
{
|
||||
header('Content-type: image/jpeg');
|
||||
header('Content-Disposition: attachment; filename="'.$_GET['name'].'.jpg"');
|
||||
echo file_get_contents(_PS_PROD_PIC_DIR_.$_GET['img']);
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
include_once(dirname(__FILE__).'/../config/config.inc.php');
|
||||
$cookie = new Cookie('psAdmin');
|
||||
|
||||
|
||||
$module = Tools::getValue('module');
|
||||
$render = Tools::getValue('render');
|
||||
$type = Tools::getValue('type');
|
||||
$option = Tools::getValue('option');
|
||||
$layers = Tools::getValue('layers');
|
||||
$width = Tools::getValue('width');
|
||||
$height = Tools::getValue('height');
|
||||
$id_employee = Tools::getValue('id_employee');
|
||||
$id_lang = Tools::getValue('id_lang');
|
||||
|
||||
if ($cookie->id_employee != $id_employee)
|
||||
die;
|
||||
|
||||
require_once(dirname(__FILE__).'/../modules/'.$module.'/'.$module.'.php');
|
||||
|
||||
$graph = new $module();
|
||||
$graph->setEmployee($id_employee);
|
||||
$graph->setLang($id_lang);
|
||||
if ($option) $graph->setOption($option, $layers);
|
||||
|
||||
$graph->create($render, $type, $width, $height, $layers);
|
||||
$graph->draw();
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Admin panel footer, footer.inc.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @copyright PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.3
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit();
|
||||
ob_flush();
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php echo Module::hookExec('backOfficeFooter'); ?>
|
||||
<p id="footer">
|
||||
Na silniku <a href="http://www.prestashop.com/" target="_blank">PrestaShop™</a> | <a href="http://www.prestashop.pl/" target="_blank">PL wersja:</a> <?php echo _PS_VERSION_; ?>
|
||||
- <?php echo number_format(microtime(true) - $timerStart, 3, '.', ''); ?>s
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,166 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Admin panel functions, functions.inc.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @copyright PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.3
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__).'/../images.inc.php');
|
||||
|
||||
function bindDatepicker($id, $time)
|
||||
{
|
||||
if ($time)
|
||||
echo '
|
||||
var dateObj = new Date();
|
||||
var hours = dateObj.getHours();
|
||||
var mins = dateObj.getMinutes();
|
||||
var secs = dateObj.getSeconds();
|
||||
if (hours < 10) { hours = "0" + hours; }
|
||||
if (mins < 10) { mins = "0" + mins; }
|
||||
if (secs < 10) { secs = "0" + secs; }
|
||||
var time = " "+hours+":"+mins+":"+secs;';
|
||||
|
||||
echo '
|
||||
$(function() {
|
||||
$("#'.$id.'").datepicker({
|
||||
prevText:"",
|
||||
nextText:"",
|
||||
dateFormat:"yy-mm-dd"'.($time ? '+time' : '').'});
|
||||
});';
|
||||
}
|
||||
|
||||
// id can be a identifier or an array of identifiers
|
||||
function includeDatepicker($id, $time = false)
|
||||
{
|
||||
global $cookie;
|
||||
echo '<script type="text/javascript" src="'.__PS_BASE_URI__.'js/jquery/datepicker/jquery-ui-personalized-1.6rc4.packed.js"></script>';
|
||||
$iso = Db::getInstance()->getValue('SELECT iso_code FROM '._DB_PREFIX_.'lang WHERE `id_lang` = '.intval($cookie->id_lang));
|
||||
if ($iso != 'en')
|
||||
echo '<script type="text/javascript" src="'.__PS_BASE_URI__.'js/jquery/datepicker/ui/i18n/ui.datepicker-'.$iso.'.js"></script>';
|
||||
echo '<script type="text/javascript">';
|
||||
if (is_array($id))
|
||||
foreach ($id as $id2)
|
||||
bindDatepicker($id2, $time);
|
||||
else
|
||||
bindDatepicker($id, $time);
|
||||
echo '</script>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new settings file, only transmitted parameters are updated
|
||||
*
|
||||
* @param string $baseUri Base URI
|
||||
* @param string $theme Theme name (eg. default)
|
||||
* @param array $arrayDB Parameters in order to connect to database
|
||||
*/
|
||||
function rewriteSettingsFile($baseUri = NULL, $theme = NULL, $arrayDB = NULL)
|
||||
{
|
||||
$defines = array();
|
||||
$defines['__PS_BASE_URI__'] = !is_null($baseUri) ? $baseUri : __PS_BASE_URI__;
|
||||
$defines['_THEME_NAME_'] = $theme ? $theme : _THEME_NAME_;
|
||||
$defines['_DB_NAME_'] = (($arrayDB AND isset($arrayDB['_DB_NAME_'])) ? $arrayDB['_DB_NAME_'] : _DB_NAME_);
|
||||
$defines['_DB_SERVER_'] = (($arrayDB AND isset($arrayDB['_DB_SERVER_'])) ? $arrayDB['_DB_SERVER_'] : _DB_SERVER_);
|
||||
$defines['_DB_USER_'] = (($arrayDB AND isset($arrayDB['_DB_USER_'])) ? $arrayDB['_DB_USER_'] : _DB_USER_);
|
||||
$defines['_DB_PREFIX_'] = (($arrayDB AND isset($arrayDB['_DB_PREFIX_'])) ? $arrayDB['_DB_PREFIX_'] : _DB_PREFIX_);
|
||||
$defines['_DB_PASSWD_'] = (($arrayDB AND isset($arrayDB['_DB_PASSWD_'])) ? $arrayDB['_DB_PASSWD_'] : _DB_PASSWD_);
|
||||
$defines['_DB_TYPE_'] = (($arrayDB AND isset($arrayDB['_DB_TYPE_'])) ? $arrayDB['_DB_TYPE_'] : _DB_TYPE_);
|
||||
$defines['_COOKIE_KEY_'] = addslashes(_COOKIE_KEY_);
|
||||
$defines['_COOKIE_IV_'] = addslashes(_COOKIE_IV_);
|
||||
$defines['_PS_VERSION_'] = addslashes(_PS_VERSION_);
|
||||
$content = "<?php\n\n";
|
||||
foreach ($defines as $k => $value)
|
||||
$content .= 'define(\''.$k.'\', \''.addslashes($value).'\');'."\n";
|
||||
$content .= "\n?>";
|
||||
if ($fd = @fopen(PS_ADMIN_DIR.'/../config/settings.inc.php', 'w'))
|
||||
{
|
||||
fwrite($fd, $content);
|
||||
fclose($fd);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display SQL date in friendly format
|
||||
*
|
||||
* @param string $sqlDate Date in SQL format (YYYY-MM-DD HH:mm:ss)
|
||||
* @param boolean $withTime Display both date and time
|
||||
* @todo Several formats (french : DD-MM-YYYY)
|
||||
*/
|
||||
function displayDate($sqlDate, $withTime = false)
|
||||
{
|
||||
return strftime('%Y-%m-%d'.($withTime ? ' %H:%M:%S' : ''), strtotime($sqlDate));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return path to a product category
|
||||
*
|
||||
* @param string $urlBase Start URL
|
||||
* @param integer $id_category Start category
|
||||
* @param string $path Current path
|
||||
* @param string $highlight String to highlight (in XHTML/CSS)
|
||||
*/
|
||||
function getPath($urlBase, $id_category, $path = '', $highlight = '')
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$category = new Category($id_category, intval($cookie->id_lang));
|
||||
if (!$category->id)
|
||||
return $path;
|
||||
$name = ($highlight != NULL) ? str_ireplace($highlight, '<span class="highlight">'.$highlight.'</span>',
|
||||
Category::hideCategoryPosition($category->name)) : Category::hideCategoryPosition($category->name);
|
||||
$edit = '<a href="'.$urlBase.'&id_category='.$category->id.'&addcategory&token=' . Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)).'"><img src="../img/admin/edit.gif" alt="Modify" /></a> ';
|
||||
if ($category->id == 1)
|
||||
$edit = '<a href="'.$urlBase.'&id_category='.$category->id.'&viewcategory&token=' . Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)).'"><img src="../img/admin/home.gif" alt="Home" /></a> ';
|
||||
$path = $edit.'<a href="'.$urlBase.'&id_category='.$category->id.'&viewcategory&token=' . Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)).'">'.$name.'</a> > '.$path;
|
||||
if ($category->id == 1)
|
||||
return substr($path, 0, strlen($path) - 3);
|
||||
return getPath($urlBase, $category->id_parent, $path);
|
||||
}
|
||||
|
||||
function getDirContent($path)
|
||||
{
|
||||
$content = array();
|
||||
if (is_dir($path))
|
||||
{
|
||||
$d = dir($path);
|
||||
while (false !== ($entry = $d->read()))
|
||||
if ($entry{0} != '.')
|
||||
$content[] = $entry;
|
||||
$d->close();
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
function createDir($path, $rights)
|
||||
{
|
||||
if (file_exists($path))
|
||||
return true;
|
||||
return @mkdir($path, $rights);
|
||||
}
|
||||
|
||||
function checkPSVersion()
|
||||
{
|
||||
libxml_set_streams_context(stream_context_create(array('http' => array('timeout' => 3))));
|
||||
if ($feed = @simplexml_load_file('http://www.prestashop.com/xml/version.xml') AND _PS_VERSION_ < $feed->version->num)
|
||||
return array('name' => $feed->version->name, 'link' => $feed->download->link);
|
||||
return false;
|
||||
}
|
||||
|
||||
function translate($string)
|
||||
{
|
||||
global $_LANGADM;
|
||||
if (!is_array($_LANGADM))
|
||||
return str_replace('"', '"', $string);
|
||||
$key = md5(str_replace('\'', '\\\'', $string));
|
||||
$str = (key_exists('index'.$key, $_LANGADM)) ? $_LANGADM['index'.$key] : ((key_exists('index'.$key, $_LANGADM)) ? $_LANGADM['index'.$key] : $string);
|
||||
return str_replace('"', '"', stripslashes($str));
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
define('PS_ADMIN_DIR', getcwd());
|
||||
|
||||
include(PS_ADMIN_DIR.'/../get-file.php');
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
include_once(dirname(__FILE__).'/../config/config.inc.php');
|
||||
$cookie = new Cookie('psAdmin');
|
||||
|
||||
$module = Tools::getValue('module');
|
||||
$render = Tools::getValue('render');
|
||||
$type = Tools::getValue('type');
|
||||
$option = Tools::getValue('option');
|
||||
$width = intval(Tools::getValue('width', 600));
|
||||
$height = intval(Tools::getValue('height', 920));
|
||||
$start = intval(Tools::getValue('start', 0));
|
||||
$limit = intval(Tools::getValue('limit', 40));
|
||||
$sort = Tools::getValue('sort', 0); // Should be a String. Default value is an Integer because we don't know what can be the name of the column to sort.
|
||||
$dir = Tools::getValue('dir', 0); // Should be a String : Either ASC or DESC
|
||||
$id_employee = intval(Tools::getValue('id_employee'));
|
||||
$id_lang = intval(Tools::getValue('id_lang'));
|
||||
|
||||
if ($cookie->id_employee != $id_employee)
|
||||
die;
|
||||
|
||||
if (!Validate::isModuleName($module))
|
||||
die(Tools::displayError());
|
||||
require_once(dirname(__FILE__).'/../modules/'.$module.'/'.$module.'.php');
|
||||
|
||||
$grid = new $module();
|
||||
$grid->setEmployee($id_employee);
|
||||
$grid->setLang($id_lang);
|
||||
if ($option)
|
||||
$grid->setOption($option);
|
||||
|
||||
$grid->create($render, $type, $width, $height, $start, $limit, $sort, $dir);
|
||||
$grid->render();
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,177 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Admin panel header, header.inc.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @copyright PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.3
|
||||
*
|
||||
*/
|
||||
|
||||
// P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies)
|
||||
header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); // HTTP/1.1
|
||||
header('Pragma: no-cache');
|
||||
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
|
||||
|
||||
require_once(dirname(__FILE__).'/init.php');
|
||||
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $iso; ?>" lang="<?php echo $iso; ?>">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link type="text/css" rel="stylesheet" href="../js/jquery/datepicker/datepicker.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../modules/gridextjs/extjs/resources/css/ext-all.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../css/admin.css" />
|
||||
<title>PrestaShop™ - <?php echo translate('Administration panel') ?></title>
|
||||
<script type="text/javascript">
|
||||
var search_texts = Array('<?php echo translate('product, customer, id...'); ?>','<?php echo translate('product, category...'); ?>', '<?php echo translate('customer id, name, e-mail...'); ?>', '<?php echo translate('order id'); ?>', '<?php echo translate('invoice id'); ?>', '<?php echo translate('cart id'); ?>');
|
||||
var helpboxes = <?php echo Configuration::get('PS_HELPBOX'); ?>;
|
||||
</script>
|
||||
<script type="text/javascript" src="<?php echo _PS_JS_DIR_ ?>jquery/jquery-1.2.6.pack.js"></script>
|
||||
<script type="text/javascript" src="../js/admin.js"></script>
|
||||
<script type="text/javascript" src="../js/toggle.js"></script>
|
||||
<script type="text/javascript" src="../js/tools.js"></script>
|
||||
<script type="text/javascript" src="../js/ajax.js"></script>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico" />
|
||||
<?php echo Module::hookExec('backOfficeHeader'); ?>
|
||||
<!--[if IE]>
|
||||
<style type="text/css">
|
||||
fieldset {
|
||||
position: relative;
|
||||
padding-top: 25px;
|
||||
}
|
||||
legend {
|
||||
position: absolute;
|
||||
top: -0.5em;
|
||||
left: 1.1em;
|
||||
}
|
||||
</style>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div style="float: left; margin-top: 11px;">
|
||||
<form action="index.php?tab=AdminSearch&token=<?php echo Tools::getAdminToken('AdminSearch'.intval(Tab::getIdFromClassName('AdminSearch')).intval($cookie->id_employee)) ?>" method="post">
|
||||
<input type="text" name="bo_query" id="bo_query" style="width: 140px;" value="<?php echo (isset($_POST['bo_query']) ? Tools::safeOutput(Tools::stripslashes($_POST['bo_query'])) : ''); ?>" /> <?php translate('in') ?>
|
||||
<select name="bo_search_type" id="bo_search_type" onchange="queryType();" style="font-size: 1em;">
|
||||
<option value="0"><?php echo translate('everywhere') ?></option>
|
||||
<option value="1"<?php echo (isset($_POST['bo_search_type']) AND
|
||||
($_POST['bo_search_type'] == 1)) ? ' selected="selected"' : '' ?>><?php echo translate('catalog') ?></option>
|
||||
<option value="2"<?php echo (isset($_POST['bo_search_type']) AND
|
||||
($_POST['bo_search_type'] == 2)) ? ' selected="selected"' : '' ?>><?php echo translate('customers') ?></option>
|
||||
<option value="3"<?php echo (isset($_POST['bo_search_type']) AND (
|
||||
$_POST['bo_search_type'] == 3)) ? ' selected="selected"' : '' ?>><?php echo translate('orders') ?></option>
|
||||
<option value="4"<?php echo (isset($_POST['bo_search_type']) AND (
|
||||
$_POST['bo_search_type'] == 4)) ? ' selected="selected"' : '' ?>><?php echo translate('invoices') ?></option>
|
||||
<option value="5"<?php echo (isset($_POST['bo_search_type']) AND (
|
||||
$_POST['bo_search_type'] == 5)) ? ' selected="selected"' : '' ?>><?php echo translate('carts') ?></option>
|
||||
</select>
|
||||
<input type="submit" name="bo_search" value="<?php echo translate('Search') ?>" class="button" />
|
||||
<script type="text/javascript">queryType();</script>
|
||||
</form>
|
||||
</div>
|
||||
<div style="float: left;margin: 11px 0px 0px 50px;" id="flagsLanguage">
|
||||
<div>
|
||||
<?php
|
||||
$link = new Link();
|
||||
$languages = Language::getLanguages();
|
||||
$i = 0;
|
||||
if (sizeof($languages) != 1)
|
||||
foreach ($languages AS $language)
|
||||
{
|
||||
echo '<a href="'.$link->getLanguageLinkAdmin($language['id_lang'], $language['name']).'&adminlang=1"><img src="'._PS_IMG_.'l/'.$language['id_lang'].'.jpg" alt="'.strtoupper($language['iso_code']).'" title="'.$language['name'].'" '.($language['id_lang'] == $cookie->id_lang ? 'class="selected_language"' : '').' /></a> ';
|
||||
if ($i == 4)
|
||||
echo '</div><div style="margin-top:5px;">';
|
||||
$i++;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">$('#flagsLanguage img[class!=selected_language]').css('opacity', '0.3')</script>
|
||||
<div style="float: right; margin: 11px 0px 0px 20px; text-align:right;">
|
||||
<img src="../img/admin/quick.gif" style="margin-top:5px;" />
|
||||
<script type="text/javascript">
|
||||
function quickSelect(elt)
|
||||
{
|
||||
var eltVal = $(elt).val();
|
||||
if (eltVal == '0') return false;
|
||||
else if (eltVal.substr(eltVal.length - 6) == '_blank')
|
||||
window.open(eltVal.substr(0, eltVal.length - 6), '_blank');
|
||||
else location.href = eltVal;
|
||||
}
|
||||
</script>
|
||||
<select onchange="quickSelect(this);" style="font-size: 1em; margin:5px 20px 0px 0px;">
|
||||
<?php
|
||||
$quicks = QuickAccess::getQuickAccesses(intval($cookie->id_lang));
|
||||
echo '<option value="0">'.translate('Quick access').'</option>';
|
||||
foreach ($quicks AS &$quick)
|
||||
{
|
||||
preg_match('/tab=(.+)(&.+)?$/', $quick['link'], $adminTab);
|
||||
if (isset($adminTab[1]))
|
||||
{
|
||||
if (strpos($adminTab[1], '&'))
|
||||
$adminTab[1] = substr($adminTab[1], 0, strpos($adminTab[1], '&'));
|
||||
$quick['link'] .= '&token='.Tools::getAdminToken($adminTab[1].intval(Tab::getIdFromClassName($adminTab[1])).intval($cookie->id_employee));
|
||||
}
|
||||
echo '<option value="'.$quick['link'].($quick['new_window'] ? '_blank' : '').'">> '.Category::hideCategoryPosition($quick['name']).'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<img src="../img/admin/nav-user.gif" alt="<?php echo translate('user') ?>" />
|
||||
<a href="index.php?logout" title="<?php echo translate('logout') ?>">
|
||||
<b><?php echo Tools::substr($cookie->firstname, 0, 1).'. '.htmlentities($cookie->lastname, ENT_COMPAT, 'UTF-8'); ?></b>
|
||||
<img src="../img/admin/nav-logout.gif" alt="<?php echo translate('logout') ?>" />
|
||||
</a>
|
||||
</div>
|
||||
<br style="clear:both;" />
|
||||
<?php echo Module::hookExec('backOfficeTop'); ?>
|
||||
<ul id="menu" style="margin-top:20px">
|
||||
<?php
|
||||
global $cookie;
|
||||
|
||||
/* Get current tab informations */
|
||||
$id_parent_tab_current = intval(Tab::getCurrentParentId());
|
||||
$tabs = Tab::getTabs(intval($cookie->id_lang), 0);
|
||||
foreach ($tabs AS $t)
|
||||
{
|
||||
if ($t['class_name'] == $tab)
|
||||
$id_parent = $t['id_tab'];
|
||||
if (checkTabRights($t['id_tab']) === true)
|
||||
{
|
||||
$img = '../img/t/'.$t['class_name'].'.gif';
|
||||
if (trim($t['module']) != '')
|
||||
$img = _MODULE_DIR_.$t['module'].'/'.$t['class_name'].'.gif';
|
||||
echo '
|
||||
<li'.((($t['class_name'] == $tab) OR ($id_parent_tab_current == $t['id_tab'])) ? ' class="active"' : '').'>
|
||||
<a href="index.php?tab='.$t['class_name'].'&token='.Tools::getAdminToken($t['class_name'].intval($t['id_tab']).intval($cookie->id_employee)).'"><img src="'.$img.'" alt="" style="width:16px;height:16px" /> '.$t['name'].'</a>
|
||||
</li>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<div id="main">
|
||||
<ul id="submenu">
|
||||
<?php
|
||||
global $cookie;
|
||||
|
||||
/* Display tabs belonging to opened tab */
|
||||
$id_parent = isset($id_parent) ? $id_parent : $id_parent_tab_current;
|
||||
if (isset($id_parent) AND $id_parent != -1)
|
||||
{
|
||||
$subTabs = Tab::getTabs(intval($cookie->id_lang), intval($id_parent));
|
||||
foreach ($subTabs AS $t)
|
||||
if (checkTabRights($t['id_tab']) === true)
|
||||
echo '
|
||||
<li>
|
||||
<a href="index.php?tab='.$t['class_name'].'&token='.Tools::getAdminToken($t['class_name'].intval($t['id_tab']).intval($cookie->id_employee)).'"><img src="../img/t/'.$t['class_name'].'.gif" alt="" style="width:16px;height:16px" /></a> <a href="index.php?tab='.$t['class_name'].'&token='.Tools::getAdminToken($t['class_name'].intval($t['id_tab']).intval($cookie->id_employee)).'">'.$t['name'].'</a>
|
||||
</li>';
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<div id="content">
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Order deny,allow
|
||||
Deny from all
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Homepage and main page for admin panel, index.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @copyright PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.3
|
||||
*
|
||||
*/
|
||||
|
||||
define('PS_ADMIN_DIR', getcwd());
|
||||
|
||||
include(PS_ADMIN_DIR.'/../config/config.inc.php');
|
||||
include(PS_ADMIN_DIR.'/functions.php');
|
||||
include(PS_ADMIN_DIR.'/toolbar.php');
|
||||
include(PS_ADMIN_DIR.'/header.inc.php');
|
||||
|
||||
if ($tab)
|
||||
{
|
||||
if ($id_tab = checkingTab($tab))
|
||||
{
|
||||
$tabs = array();
|
||||
recursiveTab($id_tab);
|
||||
$tabs = array_reverse($tabs);
|
||||
echo '<div class="path_bar"><img src="../img/admin/prefs.gif" style="margin-right:10px" /><a href="?token='.Tools::getAdminToken($tab.intval(Tab::getIdFromClassName($tab)).intval($cookie->id_employee)).'">'.translate('Back Office').'</a>';
|
||||
foreach ($tabs AS $key => $item)
|
||||
echo ' >> <img src="'.((trim($item['module']) != '') ? _MODULE_DIR_.$item['module'].'/'.$item['class_name'].'.gif' : '../img/t/'.$item['class_name'].'.gif').'" style="margin-right:5px" />'.((sizeof($tabs) - 1 > $key) ? '<a href="?tab='.$item['class_name'].'&token='.Tools::getAdminToken($item['class_name'].intval($item['id_tab']).intval($cookie->id_employee)).'">' : '').$item['name'].((sizeof($tabs) - 1 > $key) ? '</a>' : '');
|
||||
echo '</div>';
|
||||
|
||||
if (Validate::isLoadedObject($adminObj))
|
||||
if (!$adminObj->checkToken())
|
||||
return;
|
||||
|
||||
/* Filter memorization */
|
||||
if (isset($_POST) AND !empty($_POST) AND isset($adminObj->table))
|
||||
foreach ($_POST AS $key => $value)
|
||||
if (is_array($adminObj->table))
|
||||
{
|
||||
foreach ($adminObj->table AS $table)
|
||||
if (strncmp($key, $table.'Filter_', 7) === 0 OR strncmp($key, 'submitFilter', 12) === 0)
|
||||
$cookie->$key = !is_array($value) ? $value : serialize($value);
|
||||
}
|
||||
elseif (strncmp($key, $adminObj->table.'Filter_', 7) === 0 OR strncmp($key, 'submitFilter', 12) === 0)
|
||||
$cookie->$key = !is_array($value) ? $value : serialize($value);
|
||||
|
||||
if (isset($_GET) AND !empty($_GET) AND isset($adminObj->table))
|
||||
foreach ($_GET AS $key => $value)
|
||||
if (is_array($adminObj->table))
|
||||
{
|
||||
foreach ($adminObj->table AS $table)
|
||||
if (strncmp($key, $table.'OrderBy', 7) === 0 OR strncmp($key, $table.'Orderway', 8) === 0)
|
||||
$cookie->$key = $value;
|
||||
}
|
||||
elseif (strncmp($key, $adminObj->table.'OrderBy', 7) === 0 OR strncmp($key, $adminObj->table.'Orderway', 12) === 0)
|
||||
$cookie->$key = $value;
|
||||
|
||||
$adminObj->displayConf();
|
||||
$adminObj->postProcess();
|
||||
$adminObj->displayErrors();
|
||||
$adminObj->display();
|
||||
}
|
||||
}
|
||||
else /* Else display homepage */
|
||||
{
|
||||
echo '<div id="adminHeader">
|
||||
<img src="../img/logo.jpg" alt="Logo" title="Logo" /><br /><br />
|
||||
<h2>'.translate('Welcome to your Back Office').'</h2>
|
||||
'.translate('Click the tabs to navigate.').'
|
||||
<br /><br /><br />';
|
||||
|
||||
if (@ini_get('allow_url_fopen') AND $update = checkPSVersion())
|
||||
echo '<div class="warning warn" style="margin-bottom:30px;"><h3>'.translate('New PrestaShop version avalaible').' : <a style="text-decoration: underline;" href="'.$update['link'].'">'.translate('Download').' '.$update['name'].'</a> !</h3></div>';
|
||||
elseif (!@ini_get('allow_url_fopen'))
|
||||
{
|
||||
echo '<p>'.translate('Update notification unavailable').'</p>';
|
||||
echo '<p> </p>';
|
||||
echo '<p>'.translate('To receive PrestaShop update warnings, you need to activate the <b>allow_url_fopen</b> command in your <b>php.ini</b> config file.').' [<a href="'.translate('http://www.php.net/manual/en/ref.filesystem.php').'">'.translate('more infos').'</a>]</p>';
|
||||
echo '<p>'.translate('If you don\'t know how to do that, please contact your host administrator !').'</p><br>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
echo Module::hookExec('backOfficeHome');
|
||||
|
||||
/* News from PrestaShop website */
|
||||
echo '<div id="adminNews">
|
||||
<h2>'.translate('PrestaShop live feed').'</h2>';
|
||||
$isoDefault = Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT')));
|
||||
$isoUser = Language::getIsoById(intval($cookie->id_lang));
|
||||
echo'<iframe frameborder="no" style="margin: 0px; padding: 0px; width: 780px; height: 380px;" src="http://www.prestashop.com/rss/news.php?v='._PS_VERSION_.'&lang='.$isoUser.'"></iframe></div>';
|
||||
}
|
||||
|
||||
include(PS_ADMIN_DIR.'/footer.inc.php');
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Admin panel initialization file, init.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @copyright PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.3
|
||||
*
|
||||
*/
|
||||
|
||||
ob_start();
|
||||
$timerStart = microtime(true);
|
||||
|
||||
$destination = substr($_SERVER['REQUEST_URI'], strlen(dirname($_SERVER['SCRIPT_NAME'])) + 1);
|
||||
$url_redirect = '?redirect='.(empty($destination) ? 'index.php' : $destination);
|
||||
|
||||
/* Getting cookie or logout */
|
||||
if (!class_exists('Cookie'))
|
||||
exit();
|
||||
|
||||
// Required for BO cookie path
|
||||
$currentFileName = array_reverse(explode("/", $_SERVER['SCRIPT_NAME']));
|
||||
|
||||
$cookie = new Cookie('psAdmin', substr($_SERVER['SCRIPT_NAME'], strlen(__PS_BASE_URI__), -strlen($currentFileName['0'])));
|
||||
if (isset($_GET['logout'])) {
|
||||
$url_redirect = '';
|
||||
$cookie->logout();
|
||||
}
|
||||
|
||||
/* logged or not */
|
||||
if (!$cookie->isLoggedBack())
|
||||
Tools::redirectLink('login.php'.$url_redirect);
|
||||
|
||||
/* Current tab and current URL */
|
||||
$tab = Tools::getValue('tab');
|
||||
$currentIndex = __PS_BASE_URI__.substr($_SERVER['SCRIPT_NAME'], strlen(__PS_BASE_URI__)).($tab ? '?tab='.$tab : '');
|
||||
if ($back = Tools::getValue('back'))
|
||||
$currentIndex .= '&back='.urlencode($back);
|
||||
|
||||
/* Server Params */
|
||||
$server_host = Tools::getHttpHost(false, true);
|
||||
$protocol = 'http://';
|
||||
$protocol_ssl = 'https://';
|
||||
$protocol_link = (Configuration::get('PS_SSL_ENABLED')) ? $protocol_ssl : $protocol;
|
||||
$protocol_content = (isset($useSSL) AND $useSSL AND Configuration::get('PS_SSL_ENABLED')) ? $protocol_ssl : $protocol;
|
||||
define('_PS_BASE_URL_', $protocol.$server_host);
|
||||
define('_PS_BASE_URL_SSL_', $protocol_ssl.$server_host);
|
||||
|
||||
/* Include appropriate language file */
|
||||
Tools::setCookieLanguage();
|
||||
if (Tools::isSubmit('adminlang'))
|
||||
{
|
||||
Tools::switchLanguage();
|
||||
if ($id_lang = Tools::getValue('id_lang'))
|
||||
$cookie->id_lang = $id_lang;
|
||||
}
|
||||
|
||||
$iso = strtolower(Language::getIsoById($cookie->id_lang ? $cookie->id_lang : 1));
|
||||
include(_PS_TRANSLATIONS_DIR_.$iso.'/errors.php');
|
||||
include(_PS_TRANSLATIONS_DIR_.$iso.'/fields.php');
|
||||
include(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php');
|
||||
|
||||
/* Database connection (singleton) */
|
||||
Db::getInstance();
|
||||
|
||||
/* attribute id_lang is often needed, so we create a constant for performance reasons */
|
||||
define('_USER_ID_LANG_', intval($cookie->id_lang));
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,157 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Login for admin panel, login.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @copyright PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.3
|
||||
*
|
||||
*/
|
||||
|
||||
define('PS_ADMIN_DIR', getcwd());
|
||||
|
||||
include(PS_ADMIN_DIR.'/../config/config.inc.php');
|
||||
include(PS_ADMIN_DIR.'/functions.php');
|
||||
|
||||
$errors = array();
|
||||
|
||||
// Checking path
|
||||
$pathUser = preg_replace('!^/!', '', str_replace('\\', '/', $_SERVER['PHP_SELF']));
|
||||
$pathServer = preg_replace('!^/!', '', str_replace('\\', '/', str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_FILENAME'])));
|
||||
if ($pathServer != $pathUser)
|
||||
$errors[] = Tools::displayError('Path is not the same between your browser and you server :').'<br /><br /><b>'.
|
||||
Tools::displayError('- Server:').'</b><br />'.htmlentities($pathServer).'<br /><br /><b>'.
|
||||
Tools::displayError('- Browser:').'</b><br />'.htmlentities($pathUser);
|
||||
|
||||
$cookie = new Cookie('psAdmin', substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__), -10));
|
||||
if (!isset($cookie->id_lang))
|
||||
$cookie->id_lang = Configuration::get('PS_LANG_DEFAULT');
|
||||
$iso = strtolower(Language::getIsoById(intval($cookie->id_lang)));
|
||||
include(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php');
|
||||
|
||||
/* Cookie creation and redirection */
|
||||
if (Tools::isSubmit('Submit'))
|
||||
{
|
||||
/* Check fields validity */
|
||||
$passwd = trim(Tools::getValue('passwd'));
|
||||
$email = trim(Tools::getValue('email'));
|
||||
if (empty($email))
|
||||
$errors[] = Tools::displayError('e-mail is empty');
|
||||
elseif (!Validate::isEmail($email))
|
||||
$errors[] = Tools::displayError('invalid e-mail address');
|
||||
elseif (empty($passwd))
|
||||
$errors[] = Tools::displayError('password is blank');
|
||||
elseif (!Validate::isPasswd($passwd))
|
||||
$errors[] = Tools::displayError('invalid password');
|
||||
else
|
||||
{
|
||||
/* Seeking for employee */
|
||||
$employee = new Employee();
|
||||
$employee = $employee->getByemail($email, $passwd);
|
||||
if (!$employee)
|
||||
{
|
||||
$errors[] = Tools::displayError('employee does not exist, or bad password');
|
||||
$cookie->logout();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Creating cookie */
|
||||
$cookie->id_employee = $employee->id;
|
||||
$cookie->lastname = $employee->lastname;
|
||||
$cookie->firstname = $employee->firstname;
|
||||
$cookie->email = $employee->email;
|
||||
$cookie->profile = $employee->id_profile;
|
||||
$cookie->passwd = $employee->passwd;
|
||||
$cookie->remote_addr = ip2long($_SERVER['REMOTE_ADDR']);
|
||||
$cookie->write();
|
||||
/* Redirect to admin panel */
|
||||
if (isset($_GET['redirect']))
|
||||
$url = strval($_GET['redirect'].(isset($_GET['token']) ? ('&token='.$_GET['token']) : ''));
|
||||
else
|
||||
$url = 'index.php';
|
||||
if (!Validate::isCleanHtml($url))
|
||||
die(Tools::displayError());
|
||||
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
|
||||
<meta http-equiv="Refresh" content="0;URL='.Tools::safeOutput($url, true).'">
|
||||
<head>
|
||||
<script language="javascript" type="text/javascript">
|
||||
window.location.replace("'.Tools::safeOutput($url, true).'");
|
||||
</script>
|
||||
<div style="text-align:center; margin-top:250px;"><a href="'.Tools::safeOutput($url, true).'">'.translate('Click here to launch Administration panel').'</a></div>
|
||||
</head>
|
||||
</html>';
|
||||
exit ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link type="text/css" rel="stylesheet" href="../css/login.css" />
|
||||
<title>PrestaShop™ - '.translate('Administration panel').'</title>';
|
||||
echo '
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">';
|
||||
|
||||
if ($nbErrors = sizeof($errors))
|
||||
{
|
||||
echo '
|
||||
<div id="error">
|
||||
<h3>'.($nbErrors > 1 ? translate('There are') : translate('There is')).' '.$nbErrors.' '.($nbErrors > 1 ? translate('errors') : translate('error')).'</h3>
|
||||
<ol style="margin: 0 0 0 20px;">';
|
||||
foreach ($errors AS $error)
|
||||
echo '<li>'.$error.'</li>';
|
||||
echo '
|
||||
</ol>
|
||||
</div>
|
||||
<br />';
|
||||
}
|
||||
|
||||
echo '
|
||||
<div id="login">
|
||||
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">';
|
||||
|
||||
$randomNb = rand(100, 999);
|
||||
if(file_exists(PS_ADMIN_DIR.'/../install') OR file_exists(PS_ADMIN_DIR.'/../admin'))
|
||||
{
|
||||
echo ' <span>'.translate('For security reasons, you cannot connect to the Back Office until after you have:').'<br /><br />
|
||||
- '.translate('deleted the /install folder').'<br />
|
||||
- '.translate('renamed the /admin folder (eg. ').'/admin'.$randomNb.')<br />
|
||||
<br />'.translate('Please then access this page by the new url (eg. http://www.domain.tld/admin').$randomNb.')</span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo ' <label>'.translate('E-mail address:').'</label><br />
|
||||
<input type="text" id="email" name="email" value="'.Tools::safeOutput(Tools::getValue('email')).'" class="input"/>
|
||||
<div style="margin: 0.5em 0 0 0;">
|
||||
<label>'.translate('Password:').'</label><br />
|
||||
<input type="password" name="passwd" class="input" value=""/>
|
||||
</div>
|
||||
<div>
|
||||
<div id="submit"><input type="submit" name="Submit" value="'.translate('Connection').'" class="button" /></div>
|
||||
<div id="lost"><a href="password.php">'.translate('Lost password?').'</a></div>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
if (document.getElementById('email')) document.getElementById('email').focus();
|
||||
-->
|
||||
</script>
|
||||
<?php
|
||||
echo '
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Password recuperation for employees account, password.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @copyright PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.3
|
||||
*
|
||||
*/
|
||||
|
||||
define('PS_ADMIN_DIR', getcwd());
|
||||
|
||||
include(PS_ADMIN_DIR.'/../config/config.inc.php');
|
||||
include(PS_ADMIN_DIR.'/functions.php');
|
||||
|
||||
$errors = array();
|
||||
$cookie = new Cookie('psAdmin', substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__), -10));
|
||||
$id_lang = intval($cookie->id_lang) ? intval($cookie->id_lang) : 1;
|
||||
$iso = strtolower(Language::getIsoById($cookie->id_lang ? intval($cookie->id_lang) : 1));
|
||||
include(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php');
|
||||
|
||||
if (isset($_POST['Submit']))
|
||||
{
|
||||
$errors = array();
|
||||
if (empty($_POST['email']))
|
||||
$errors[] = Tools::displayError('e-mail is empty');
|
||||
elseif (!Validate::isEmail($_POST['email']))
|
||||
$errors[] = Tools::displayError('invalid e-mail address');
|
||||
else
|
||||
{
|
||||
$employee = new Employee();
|
||||
if (!$employee->getByemail($_POST['email']) OR !$employee)
|
||||
$errors[] = Tools::displayError('this account doesn\'t exist');
|
||||
else
|
||||
{
|
||||
if ((strtotime($employee->last_passwd_gen.'+'.Configuration::get('PS_PASSWD_TIME_BACK').' minutes') - time()) > 0 )
|
||||
$errors[] = Tools::displayError('You can regenerate your password only each').' '.Configuration::get('PS_PASSWD_TIME_BACK').' '.Tools::displayError('minute(s)');
|
||||
else
|
||||
{
|
||||
$pwd = Tools::passwdGen();
|
||||
$employee->passwd = md5(pSQL(_COOKIE_KEY_.$pwd));
|
||||
$employee->last_passwd_gen = date('Y-m-d H:i:s', time());
|
||||
$result = $employee->update();
|
||||
if (!$result)
|
||||
$errors[] = Tools::displayError('an error occurred during your password change');
|
||||
else
|
||||
{
|
||||
Mail::Send($id_lang, 'password', 'Your new admin password', array('{email}' => $employee->email, '{lastname}' => $employee->lastname, '{firstname}' => $employee->firstname, '{passwd}' => $pwd), $employee->email, $employee->firstname.' '.$employee->lastname);
|
||||
$confirmation = 'ok';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link type="text/css" rel="stylesheet" href="../css/login.css" />
|
||||
<title>PrestaShop™ - '.translate('Administration panel').'</title>
|
||||
</head>
|
||||
<body><div id="container">';
|
||||
if (sizeof($errors))
|
||||
{
|
||||
echo '<div id="error">
|
||||
<h3>'.translate('There is 1 error').'</h3>
|
||||
<ol>';
|
||||
foreach ($errors AS $error)
|
||||
echo '<li>'.$error.'</li>';
|
||||
echo '</ol>
|
||||
</div>';
|
||||
}
|
||||
echo '
|
||||
<div id="login">
|
||||
<form action="" method="post">
|
||||
<div class="page-title center">'.translate('Forgot your password?').'</div><br />';
|
||||
if (isset($confirmation))
|
||||
echo ' <br />
|
||||
<div style="font-weight: bold;">'.translate('Your password has been e-mailed to you').'.</div>
|
||||
<div style="margin: 2em 0 0 0; text-align: right;"><a href="login.php?email='.Tools::safeOutput(Tools::getValue('email')).'">> '.translate('back to login home').'</a></div>';
|
||||
else
|
||||
echo ' <span style="font-weight: bold;">'.translate('Please, enter your e-mail address').' </span>
|
||||
'.translate('(the one you wrote during your registration) in order to receive your access codes by e-mail').'.<br />
|
||||
<input type="text" name="email" class="input" />
|
||||
<div>
|
||||
<div id="submit"><input type="submit" name="Submit" value="'.translate('Send').'" class="button" /></div>
|
||||
<div id="lost"> </div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div></body></html>';
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PDF generation for admin, pdf.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @copyright PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.3
|
||||
*
|
||||
*/
|
||||
|
||||
define('PS_ADMIN_DIR', getcwd());
|
||||
|
||||
include(PS_ADMIN_DIR.'/../config/config.inc.php');
|
||||
|
||||
/* Header can't be included, so cookie must be created here */
|
||||
$cookie = new Cookie('psAdmin');
|
||||
if (!$cookie->id_employee)
|
||||
Tools::redirect('login.php');
|
||||
|
||||
if (isset($_GET['pdf']))
|
||||
{
|
||||
if (!isset($_GET['id_order']))
|
||||
die (Tools::displayError('order ID is missing'));
|
||||
$order = new Order(intval($_GET['id_order']));
|
||||
if (!Validate::isLoadedObject($order))
|
||||
die(Tools::displayError('cannot find order in database'));
|
||||
PDF::invoice($order);
|
||||
}
|
||||
elseif (isset($_GET['id_order_slip']))
|
||||
{
|
||||
$orderSlip = new OrderSlip(intval($_GET['id_order_slip']));
|
||||
$order = new Order(intval($orderSlip->id_order));
|
||||
if (!Validate::isLoadedObject($order))
|
||||
die(Tools::displayError('cannot find order in database'));
|
||||
$order->products = OrderSlip::getOrdersSlipProducts($orderSlip->id, $order);
|
||||
$tmp = NULL;
|
||||
PDF::invoice($order, 'D', false, $tmp, $orderSlip);
|
||||
}
|
||||
elseif (isset($_GET['id_delivery']))
|
||||
{
|
||||
$order = Order::getByDelivery(intval($_GET['id_delivery']));
|
||||
if (!Validate::isLoadedObject($order))
|
||||
die(Tools::displayError('cannot find order in database'));
|
||||
$tmp = NULL;
|
||||
PDF::invoice($order, 'D', false, $tmp, false, $order->delivery_number);
|
||||
}
|
||||
elseif (isset($_GET['invoices']))
|
||||
{
|
||||
$invoices = Order::getOrdersIdInvoiceByDate($_GET['date_from'], $_GET['date_to'], NULL, 'invoice');
|
||||
if (is_array($invoices))
|
||||
PDF::multipleInvoices($invoices);
|
||||
}
|
||||
elseif (isset($_GET['deliveryslips']))
|
||||
{
|
||||
$slips = unserialize(urldecode($_GET['deliveryslips']));
|
||||
if (is_array($slips))
|
||||
PDF::multipleDelivery($slips);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
include(dirname(__FILE__).'/../config/config.inc.php');
|
||||
|
||||
if (substr(_COOKIE_KEY_, 34, 8) != Tools::getValue('token'))
|
||||
die;
|
||||
|
||||
ini_set('max_execution_time', 7200);
|
||||
Search::indexation(Tools::getValue('full'));
|
||||
Tools::redirectAdmin($_SERVER['HTTP_REFERER'].'&conf=4');
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Access management tab for admin panel, AdminAccess.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminAccess extends AdminTab
|
||||
{
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::isSubmit('submitAddaccess') AND $action = Tools::getValue('action') AND $id_tab = intval(Tools::getValue('id_tab')) AND $id_profile = intval(Tools::getValue('id_profile')) AND $this->tabAccess['edit'] == 1)
|
||||
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'access` SET `'.pSQL($action).'` = '.intval(Tools::getValue('perm')).' WHERE `id_tab` = '.intval($id_tab).' AND `id_profile` = '.intval($id_profile));
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$this->displayForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current profile id
|
||||
*
|
||||
* @return the $_GET['profile'] if valid, else 1 (the first profile id)
|
||||
*/
|
||||
function getCurrentProfileId()
|
||||
{
|
||||
return (isset($_GET['profile']) AND !empty($_GET['profile']) AND is_numeric($_GET['profile'])) ? intval($_GET['profile']) : 1;
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $cookie, $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$currentProfile = intval($this->getCurrentProfileId());
|
||||
$tabs = Tab::getTabs($cookie->id_lang);
|
||||
$profiles = Profile::getProfiles(intval($cookie->id_lang));
|
||||
$accesses = Profile::getProfileAccesses(intval($currentProfile));
|
||||
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
setLang(Array(\''.$this->l('Profile updated').'\', \''.$this->l('Request failed!').'\', \''.$this->l('Updating in progress. Please wait.').'\', \''.$this->l('Server connection failed!').'\'));
|
||||
</script>
|
||||
<div id="ajax_confirmation"></div>
|
||||
<table class="table" cellspacing="0">
|
||||
<tr>
|
||||
<th>
|
||||
<select name="profile" onchange="redirect(\''.Tools::getHttpHost(true, true).$currentIndex.'&token='.$this->token.'&profile=\'+this.options[this.selectedIndex].value)">';
|
||||
if ($profiles)
|
||||
foreach ($profiles AS $profile)
|
||||
echo '<option value="'.intval($profile['id_profile']).'" '.(intval($profile['id_profile']) == $currentProfile ? 'selected="selected"' : '').'>'.$profile['name'].'</option>';
|
||||
echo '
|
||||
</select>
|
||||
</th>
|
||||
<th>'.$this->l('View').'</th>
|
||||
<th>'.$this->l('Add').'</th>
|
||||
<th>'.$this->l('Edit').'</th>
|
||||
<th>'.$this->l('Delete').'</th>
|
||||
</tr>';
|
||||
|
||||
if (!sizeof($tabs))
|
||||
echo '<tr><td colspan="5">'.$this->l('No tab').'</td></tr>';
|
||||
else
|
||||
foreach ($tabs AS $tab)
|
||||
if (!$tab['id_parent'] OR intval($tab['id_parent']) == -1)
|
||||
{
|
||||
$this->printTabAccess(intval($currentProfile), $tab, $accesses[$tab['id_tab']], false);
|
||||
foreach ($tabs AS $child)
|
||||
if ($child['id_parent'] === $tab['id_tab'])
|
||||
$this->printTabAccess($currentProfile, $child, $accesses[$child['id_tab']], true);
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
private function printTabAccess($currentProfile, $tab, $access, $is_child)
|
||||
{
|
||||
$perms = array('view', 'add', 'edit', 'delete');
|
||||
echo '<tr><td'.($is_child ? '' : ' class="bold"').'>'.($is_child ? ' » ' : '').$tab['name'].'</td>';
|
||||
foreach ($perms as $perm)
|
||||
if($this->tabAccess['edit'] == 1)
|
||||
echo '<td class="center"><input type="checkbox" name="1" onclick="ajax_power(this, \''.$perm.'\', '.intval($access['id_tab']).', '.intval($access['id_profile']).', \''.$this->token.'\')" '.(intval($access[$perm]) == 1 ? 'checked="checked"' : '').'/></td>';
|
||||
else
|
||||
echo '<td class="center"><input type="checkbox" name="1" disabled="disabled" '.(intval($access[$perm]) == 1 ? 'checked="checked"' : '').' /></td>';
|
||||
echo '</tr>';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,329 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Addresses tab for admin panel, AdminAddresses.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminAddresses extends AdminTab
|
||||
{
|
||||
/** @var array countries list */
|
||||
private $countriesArray = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$this->table = 'address';
|
||||
$this->className = 'Address';
|
||||
$this->lang = false;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
$this->addressType = 'customer';
|
||||
|
||||
if (!Tools::getValue('realedit'))
|
||||
$this->deleted = true;
|
||||
$this->_select = 'cl.`name` as country';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON
|
||||
(cl.`id_country` = a.`id_country` AND cl.`id_lang` = '.intval($cookie->id_lang).')';
|
||||
|
||||
$countries = Country::getCountries(intval($cookie->id_lang));
|
||||
foreach ($countries AS $country)
|
||||
$this->countriesArray[$country['id_country']] = $country['name'];
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_address' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'firstname' => array('title' => $this->l('First name'), 'width' => 80, 'filter_key' => 'a!firstname'),
|
||||
'lastname' => array('title' => $this->l('Last name'), 'width' => 100, 'filter_key' => 'a!lastname'),
|
||||
'address1' => array('title' => $this->l('Address'), 'width' => 200),
|
||||
'postcode' => array('title' => $this->l('Post/Zip code'), 'align' => 'right', 'width' => 50),
|
||||
'city' => array('title' => $this->l('City'), 'width' => 150),
|
||||
'country' => array('title' => $this->l('Country'), 'width' => 100, 'type' => 'select', 'select' => $this->countriesArray, 'filter_key' => 'cl!id_country'));
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (isset($_POST['submitAdd'.$this->table]))
|
||||
{
|
||||
// Transform e-mail in id_customer for parent processing
|
||||
if ($this->addressType == 'customer')
|
||||
{
|
||||
if (Validate::isEmail(Tools::getValue('email')))
|
||||
{
|
||||
$customer = new Customer;
|
||||
$customer = $customer->getByemail(Tools::getValue('email'));
|
||||
if (Validate::isLoadedObject($customer))
|
||||
$_POST['id_customer'] = $customer->id;
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('this e-mail address is not registered');
|
||||
}
|
||||
elseif ($id_customer = Tools::getValue('id_customer'))
|
||||
{
|
||||
$customer = new Customer(intval($id_customer));
|
||||
if (Validate::isLoadedObject($customer))
|
||||
$_POST['id_customer'] = $customer->id;
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('unknown customer');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('unknown customer');
|
||||
}
|
||||
|
||||
// Check manufacturer selected
|
||||
if ($this->addressType == 'manufacturer')
|
||||
{
|
||||
$manufacturer = new Manufacturer(intval(Tools::getValue('id_manufacturer')));
|
||||
if (!Validate::isLoadedObject($manufacturer))
|
||||
$this->_errors[] = Tools::displayError('manufacturer selected is not valid');
|
||||
}
|
||||
|
||||
/* If the selected country does not contain states */
|
||||
$id_state = intval(Tools::getValue('id_state'));
|
||||
if ($id_country = Tools::getValue('id_country') AND $country = new Country(intval($id_country)) AND !intval($country->contains_states) AND $id_state)
|
||||
$this->_errors[] = Tools::displayError('you have selected a state for a country that does not contain states');
|
||||
|
||||
/* If the selected country contains states, then a state have to be selected */
|
||||
if (intval($country->contains_states) AND !$id_state)
|
||||
$this->_errors[] = Tools::displayError('an address which is located in a country containing states must have a state selected');
|
||||
|
||||
/* If this address come from order's edition and is the same as the other one (invoice or delivery one)
|
||||
** we delete its id_address to force the creation of a new one */
|
||||
if (intval(Tools::getValue('id_order')))
|
||||
{
|
||||
$this->_redirect = false;
|
||||
if (isset($_POST['address_type']))
|
||||
$_POST['id_address'] = '';
|
||||
}
|
||||
}
|
||||
if (!sizeof($this->_errors))
|
||||
parent::postProcess();
|
||||
|
||||
/* Reassignation of the order's new (invoice or delivery) address */
|
||||
$address_type = (intval(Tools::getValue('address_type')) == 2 ? 'invoice' : (intval(Tools::getValue('address_type')) == 1 ? 'delivery' : ''));
|
||||
if (isset($_POST['submitAdd'.$this->table]) AND ($id_order = intval(Tools::getValue('id_order'))) AND !sizeof($this->_errors) AND !empty($address_type))
|
||||
{
|
||||
if(!Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'orders SET `id_address_'.$address_type.'` = '.Db::getInstance()->Insert_ID().' WHERE `id_order` = '.$id_order))
|
||||
$this->_errors[] = Tools::displayError('an error occurred while linking this address to its order');
|
||||
else
|
||||
Tools::redirectAdmin(Tools::getValue('back').'&conf=4');
|
||||
}
|
||||
}
|
||||
|
||||
public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL)
|
||||
{
|
||||
parent::getList($id_lang, $orderBy, $orderWay, $start, $limit);
|
||||
|
||||
global $cookie;
|
||||
|
||||
/* Manage default params values */
|
||||
if (empty($limit))
|
||||
$limit = ((!isset($cookie->{$this->table.'_pagination'})) ? $this->_pagination[0] : $limit = $cookie->{$this->table.'_pagination'});
|
||||
|
||||
if (!Validate::isTableOrIdentifier($this->table))
|
||||
die('filter is corrupted');
|
||||
if (empty($orderBy))
|
||||
$orderBy = Tools::getValue($this->table.'Orderby', 'id_'.$this->table);
|
||||
if (empty($orderWay))
|
||||
$orderWay = Tools::getValue($this->table.'Orderway', 'ASC');
|
||||
$limit = intval(Tools::getValue('pagination', $limit));
|
||||
$cookie->{$this->table.'_pagination'} = $limit;
|
||||
|
||||
/* Check params validity */
|
||||
if (!Validate::isOrderBy($orderBy) OR !Validate::isOrderWay($orderWay)
|
||||
OR !is_numeric($start) OR !is_numeric($limit)
|
||||
OR !Validate::isUnsignedId($id_lang))
|
||||
die(Tools::displayError('get list params is not valid'));
|
||||
|
||||
/* Determine offset from current page */
|
||||
if ((isset($_POST['submitFilter'.$this->table]) OR
|
||||
isset($_POST['submitFilter'.$this->table.'_x']) OR
|
||||
isset($_POST['submitFilter'.$this->table.'_y'])) AND
|
||||
!empty($_POST['submitFilter'.$this->table]) AND
|
||||
is_numeric($_POST['submitFilter'.$this->table]))
|
||||
$start = intval($_POST['submitFilter'.$this->table] - 1) * $limit;
|
||||
|
||||
/* Cache */
|
||||
$this->_lang = intval($id_lang);
|
||||
$this->_orderBy = $orderBy;
|
||||
$this->_orderWay = Tools::strtoupper($orderWay);
|
||||
|
||||
/* SQL table : orders, but class name is Order */
|
||||
$sqlTable = $this->table == 'order' ? 'orders' : $this->table;
|
||||
|
||||
/* Query in order to get results number */
|
||||
$queryTotal = Db::getInstance()->getRow('
|
||||
SELECT COUNT(a.`id_'.$this->table.'`) AS total
|
||||
FROM `'._DB_PREFIX_.$sqlTable.'` a
|
||||
'.($this->lang ? 'LEFT JOIN `'._DB_PREFIX_.$this->table.'_lang` b ON (b.`id_'.$this->table.'` = a.`id_'.$this->table.'` AND b.`id_lang` = '.intval($id_lang).')' : '').'
|
||||
'.(isset($this->_join) ? $this->_join.' ' : '').'
|
||||
WHERE 1 '.(isset($this->_where) ? $this->_where.' ' : '').(($this->deleted OR $this->table == 'currency') ? 'AND a.`deleted` = 0 ' : '').$this->_filter.'
|
||||
'.(isset($this->_group) ? $this->_group.' ' : '').'
|
||||
'.(isset($this->addressType) ? 'AND a.id_'.strval($this->addressType).' != 0' : ''));
|
||||
$this->_listTotal = intval($queryTotal['total']);
|
||||
|
||||
/* Query in order to get results with all fields */
|
||||
$this->_list = Db::getInstance()->ExecuteS('
|
||||
SELECT a.*'.($this->lang ? ', b.*' : '').(isset($this->_select) ? ', '.$this->_select.' ' : '').'
|
||||
FROM `'._DB_PREFIX_.$sqlTable.'` a
|
||||
'.($this->lang ? 'LEFT JOIN `'._DB_PREFIX_.$this->table.'_lang` b ON (b.`id_'.$this->table.'` = a.`id_'.$this->table.'` AND b.`id_lang` = '.intval($id_lang).')' : '').'
|
||||
'.(isset($this->_join) ? $this->_join.' ' : '').'
|
||||
WHERE 1 '.(isset($this->_where) ? $this->_where.' ' : '').(($this->deleted OR $this->table == 'currency') ? 'AND a.`deleted` = 0 ' : '').$this->_filter.'
|
||||
'.(isset($this->_group) ? $this->_group.' ' : '').'
|
||||
'.(isset($this->addressType) ? 'AND a.id_'.strval($this->addressType).' != 0' : '').'
|
||||
ORDER BY '.(($orderBy == 'id_'.$this->table) ? 'a.' : '').'`'.pSQL($orderBy).'` '.pSQL($orderWay).'
|
||||
LIMIT '.intval($start).','.intval($limit));
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
function populateStates(id_country, id_state)
|
||||
{
|
||||
$.ajax({
|
||||
url: "ajax.php",
|
||||
cache: false,
|
||||
data: "ajaxStates=1&id_country="+id_country+"&id_state="+id_state,
|
||||
success: function(html){
|
||||
$("#id_state").html(html);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post">
|
||||
'.(intval($obj->id) ? '<input type="hidden" name="id_'.$this->table.'" value="'.intval($obj->id).'" />' : '').'
|
||||
'.(($id_order = intval(Tools::getValue('id_order'))) ? '<input type="hidden" name="id_order" value="'.intval($id_order).'" />' : '').'
|
||||
'.(($address_type = intval(Tools::getValue('address_type'))) ? '<input type="hidden" name="address_type" value="'.intval($address_type).'" />' : '').'
|
||||
'.(Tools::getValue('realedit') ? '<input type="hidden" name="realedit" value="1" />' : '').'
|
||||
<fieldset class="width3">
|
||||
<legend><img src="../img/admin/contact.gif" alt="" />'.$this->l('Addresses').'</legend>';
|
||||
switch ($this->addressType)
|
||||
{
|
||||
case 'manufacturer':
|
||||
echo '<label>'.$this->l('Choose manufacturer:').'</label>
|
||||
<div class="margin-form">';
|
||||
$manufacturers = Manufacturer::getManufacturers();
|
||||
echo '<select name="id_manufacturer">';
|
||||
if (!sizeof($manufacturers))
|
||||
echo '<option value="0">'.$this->l('No manufacturer available').' </option>';
|
||||
foreach ($manufacturers as $manufacturer)
|
||||
echo '<option value="'.intval($manufacturer['id_manufacturer']).'"'.($this->getFieldValue($obj, 'id_manufacturer') == $manufacturer['id_manufacturer'] ? ' selected="selected"' : '').'>'.$manufacturer['name'].' </option>';
|
||||
echo '</select>';
|
||||
echo '</div>';
|
||||
echo '<input type="hidden" name="alias" value="manufacturer">';
|
||||
break;
|
||||
case 'customer':
|
||||
default:
|
||||
if ($obj->id)
|
||||
{
|
||||
$customer = new Customer($obj->id_customer);
|
||||
$tokenCustomer = Tools::getAdminToken('AdminCustomers'.intval(Tab::getIdFromClassName('AdminCustomers')).intval($cookie->id_employee));
|
||||
echo '
|
||||
<label>'.$this->l('Customer:').'</label>
|
||||
<div class="margin-form"><a style="display: block; padding-top: 4px;" href="?tab=AdminCustomers&id_customer='.$customer->id.'&viewcustomer&token='.$tokenCustomer.'">'.$customer->lastname.' '.$customer->firstname.' ('.$customer->email.')</a></div>
|
||||
<input type="hidden" name="id_customer" value="'.$customer->id.'" />';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo
|
||||
'<label>'.$this->l('Customer e-mail:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="email" value="'.htmlentities(Tools::getValue('email'), ENT_COMPAT, 'UTF-8').'" style="text-transform: lowercase;" /> <sup>*</sup>
|
||||
</div>';
|
||||
}
|
||||
echo '<label>'.$this->l('Alias:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="alias" value="'.htmlentities($this->getFieldValue($obj, 'alias'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
break;
|
||||
}
|
||||
if ($this->addressType != 'manufacturer')
|
||||
{
|
||||
echo '<label>'.$this->l('Company:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="company" value="'.htmlentities($this->getFieldValue($obj, 'company'), ENT_COMPAT, 'UTF-8').'" />
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
}
|
||||
echo '
|
||||
<label>'.$this->l('Last name:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="lastname" value="'.htmlentities($this->getFieldValue($obj, 'lastname'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' 0-9!<>,;?=+()@#"<22>{}_$%:<span class="hint-pointer"> </span></span>
|
||||
</div>
|
||||
<label>'.$this->l('First name:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="firstname" value="'.htmlentities($this->getFieldValue($obj, 'firstname'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' 0-9!<>,;?=+()@#"<22>{}_$%:<span class="hint-pointer"> </span></span>
|
||||
</div>
|
||||
<label>'.$this->l('Address:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="address1" value="'.htmlentities($this->getFieldValue($obj, 'address1'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
</div>
|
||||
<label>'.$this->l('Address').' (2):</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="address2" value="'.htmlentities($this->getFieldValue($obj, 'address2'), ENT_COMPAT, 'UTF-8').'" />
|
||||
</div>
|
||||
<label>'.$this->l('Post/Zip code:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="postcode" value="'.htmlentities($this->getFieldValue($obj, 'postcode'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
</div>
|
||||
<label>'.$this->l('City:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="city" value="'.htmlentities($this->getFieldValue($obj, 'city'), ENT_COMPAT, 'UTF-8').'" style="text-transform: uppercase;" /> <sup>*</sup>
|
||||
</div>
|
||||
<label>'.$this->l('Country:').'</label>
|
||||
<div class="margin-form">
|
||||
<select name="id_country" id="id_country" onchange="populateStates($(this).val(), '.intval($this->getFieldValue($obj, 'id_state')).');" />';
|
||||
$selectedCountry = $this->getFieldValue($obj, 'id_country');
|
||||
foreach ($this->countriesArray AS $id_country => $name)
|
||||
echo ' <option value="'.$id_country.'"'.((!$selectedCountry AND Configuration::get('PS_COUNTRY_DEFAULT') == $id_country) ? ' selected="selected"' : ($selectedCountry == $id_country ? ' selected="selected"' : '')).'>'.$name.'</option>';
|
||||
echo ' </select> <sup>*</sup>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
populateStates('.intval($this->getFieldValue($obj, 'id_country')).', '.intval($this->getFieldValue($obj, 'id_state')).');
|
||||
</script>
|
||||
<label>'.$this->l('State:').'</label>
|
||||
<div class="margin-form">
|
||||
<select name="id_state" id="id_state">
|
||||
</select>
|
||||
</div>
|
||||
<label>'.$this->l('Home phone:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="phone" value="'.htmlentities($this->getFieldValue($obj, 'phone'), ENT_COMPAT, 'UTF-8').'" />
|
||||
</div>
|
||||
<label>'.$this->l('Mobile phone:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="phone_mobile" value="'.htmlentities($this->getFieldValue($obj, 'phone_mobile'), ENT_COMPAT, 'UTF-8').'" />
|
||||
</div>
|
||||
<label>'.$this->l('Other:').'</label>
|
||||
<div class="margin-form">
|
||||
<textarea name="other" cols="36" rows="4">'.htmlentities($this->getFieldValue($obj, 'other'), ENT_COMPAT, 'UTF-8').'</textarea>
|
||||
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Categories class AdminAliases.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @copyright PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.3
|
||||
*
|
||||
*/
|
||||
|
||||
class AdminAliases extends AdminTab
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
$this->table = 'alias';
|
||||
$this->className = 'Alias';
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'alias' => array('title' => $this->l('Aliases'), 'width' => 160),
|
||||
'search' => array('title' => $this->l('Search'), 'width' => 40),
|
||||
'active' => array('title' => $this->l('Status'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false)
|
||||
);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (isset($_POST['submitAdd'.$this->table]))
|
||||
{
|
||||
$search = strval(Tools::getValue('search'));
|
||||
$string = strval(Tools::getValue('alias'));
|
||||
$aliases = explode(',', $string);
|
||||
if (empty($search) OR empty($string))
|
||||
$this->_errors[] = $this->l('aliases and result are both required');
|
||||
if (!Validate::isValidSearch($search))
|
||||
$this->_errors[] = $search.' '.$this->l('is not a valid result');
|
||||
foreach ($aliases AS $alias)
|
||||
if (!Validate::isValidSearch($alias))
|
||||
$this->_errors[] = $alias.' '.$this->l('is not a valid alias');
|
||||
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
Alias::deleteAliases($search);
|
||||
foreach ($aliases AS $alias)
|
||||
{
|
||||
$obj = new Alias(NULL, trim($alias), trim($search));
|
||||
$obj->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" class="width2">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset class="width3"><legend><img src="../img/admin/search.gif" />'.$this->l('Aliases').'</legend>
|
||||
<label>'.$this->l('Alias:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="40" name="alias" value="'.Tools::getValue('alias', htmlentities($obj->getAliases(), ENT_COMPAT, 'UTF-8')).'" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Enter each alias separated by a comma (\',\')').' '.$this->l('(e.g., \'prestshop,preztashop,prestasohp\')').'<br />
|
||||
'.$this->l('Forbidden characters:').' <>;=#{}</p>
|
||||
</div>
|
||||
<label>'.$this->l('Result:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="15" name="search" value="'.htmlentities($this->getFieldValue($obj, 'search'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Search this word instead.').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Database tab for admin panel, AdminDb.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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');
|
||||
include_once(PS_ADMIN_DIR.'/tabs/AdminPreferences.php');
|
||||
|
||||
class AdminAppearance extends AdminPreferences
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->className = 'Configuration';
|
||||
$this->table = 'configuration';
|
||||
|
||||
$this->_fieldsAppearance = array(
|
||||
'PS_LOGO' => array('title' => $this->l('Header logo:'), 'desc' => $this->l('Will appear on page and e-mail headers'), 'type' => 'file', 'thumb' => array('file' => _PS_IMG_.'logo.jpg?date='.time(), 'pos' => 'before')),
|
||||
'PS_FAVICON' => array('title' => $this->l('Favicon:'), 'desc' => $this->l('The favicon used by your shop'), 'type' => 'file', 'thumb' => array('file' => _PS_IMG_.'favicon.ico?date='.time(), 'pos' => 'after')),
|
||||
'PS_NAVIGATION_PIPE' => array('title' => $this->l('Navigation pipe:'), 'desc' => $this->l('Used for navigation path inside categories/product'), 'cast' => 'strval', 'type' => 'text', 'size' => 20),
|
||||
);
|
||||
$this->_fieldsTheme = array(
|
||||
'PS_THEME' => array('title' => $this->l('Theme'), 'validation' => 'isGenericName', 'type' => 'image', 'list' => $this->_getThemesList(), 'max' => 3)
|
||||
);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
// No cache for auto-refresh uploaded logo
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
$this->_displayForm('appearance', $this->_fieldsAppearance, $this->l('Appearance'), 'width3', 'appearance');
|
||||
echo '<br /><br />';
|
||||
$this->_displayForm('themes', $this->_fieldsTheme, $this->l('Themes'), 'width3', 'themes');
|
||||
echo '<br /><br />';
|
||||
if (@ini_get('allow_url_fopen'))
|
||||
echo '<script type="text/javascript">
|
||||
$.post("'.dirname($currentIndex).'/ajax.php",{page:"themes"},function(a){getE("prestastore-content").innerHTML="<legend><img src=\"../img/admin/prestastore.gif\" class=\"middle\" /> '.$this->l('Live from PrestaStore!').'</legend>"+a;});
|
||||
</script>
|
||||
<fieldset id="prestastore-content" class="width3"></fieldset>';
|
||||
else
|
||||
echo '<a href="http://www.prestastore.com/3-prestashop-themes">'.$this->l('Find new themes on PrestaStore!').'</a>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array with themes and thumbnails
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _getThemesList()
|
||||
{
|
||||
$dir = opendir(_PS_ALL_THEMES_DIR_);
|
||||
while ($folder = readdir($dir))
|
||||
if ($folder != '.' AND $folder != '..' AND file_exists(_PS_ALL_THEMES_DIR_.'/'.$folder.'/preview.jpg'))
|
||||
$themes[$folder]['name'] = $folder;
|
||||
closedir($dir);
|
||||
return isset($themes) ? $themes : array();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Attachments tab for admin panel, AdminAttachments.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminAttachments extends AdminTab
|
||||
{
|
||||
protected $maxFileSize = 2000000;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$this->table = 'attachment';
|
||||
$this->className = 'Attachment';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_attachment' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name')),
|
||||
'file' => array('title' => $this->l('File')));
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::isSubmit('submitAdd'.$this->table))
|
||||
{
|
||||
if ($id = intval(Tools::getValue('id_attachment')) AND $a = new Attachment($id))
|
||||
{
|
||||
$_POST['file'] = $a->file;
|
||||
$_POST['mime'] = $a->mime;
|
||||
}
|
||||
if (!sizeof($this->_errors))
|
||||
if (isset($_FILES['file']) AND is_uploaded_file($_FILES['file']['tmp_name']))
|
||||
{
|
||||
if ($_FILES['file']['size'] > $this->maxFileSize)
|
||||
$this->_errors[] = $this->l('File too large, maximum size allowed:').' '.($this->maxFileSize/1000).' '.$this->l('kb');
|
||||
else
|
||||
{
|
||||
$uploadDir = dirname(__FILE__).'/../../download/';
|
||||
do $uniqid = sha1(microtime()); while (file_exists($uploadDir.$uniqid));
|
||||
if (!copy($_FILES['file']['tmp_name'], $uploadDir.$uniqid))
|
||||
$this->_errors[] = $this->l('File copy failed');
|
||||
@unlink($_FILES['file']['tmp_name']);
|
||||
$_POST['name_2'] .= '.'.pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
|
||||
$_POST['file'] = $uniqid;
|
||||
$_POST['mime'] = $_FILES['file']['type'];
|
||||
}
|
||||
}
|
||||
$this->validateRules();
|
||||
}
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" enctype="multipart/form-data" class="width2">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/t/AdminAttachments.gif" />'.$this->l('Attachment').'</legend>
|
||||
<label>'.$this->l('Name:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo ' <div id="cname_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="33" type="text" name="name_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'cname¤cdescription', 'cname');
|
||||
echo ' </div>
|
||||
<div class="clear"> </div>
|
||||
<label>'.$this->l('Description:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo ' <div id="cdescription_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<textarea name="description_'.$language['id_lang'].'">'.htmlentities($this->getFieldValue($obj, 'description', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'cname¤cdescription', 'cdescription');
|
||||
echo ' </div>
|
||||
<div class="clear"> </div>
|
||||
<label>'.$this->l('File:').'</label>
|
||||
<div class="margin-form">
|
||||
<p><input type="file" name="file" /></p>
|
||||
<p>'.$this->l('Upload file from your computer').'</p>
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,268 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Attribute generator tab for admin panel, AdminAttributeGenerator.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @copyright PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.3
|
||||
*
|
||||
*/
|
||||
|
||||
@ini_set('max_execution_time', 3600);
|
||||
include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');
|
||||
|
||||
class AdminAttributeGenerator extends AdminTab
|
||||
{
|
||||
private $combinations = array();
|
||||
private $product;
|
||||
|
||||
private function addAttribute($arr, $price = 0, $weight = 0)
|
||||
{
|
||||
foreach ($arr AS $attr)
|
||||
{
|
||||
$price += floatval($_POST['price_impact'][intval($attr)]);
|
||||
$weight += floatval($_POST['weight_impact'][intval($attr)]);
|
||||
}
|
||||
if ($this->product->id)
|
||||
{
|
||||
return (array(
|
||||
'id_product' => intval($this->product->id),
|
||||
'price' => floatval($price),
|
||||
'weight' => floatval($weight),
|
||||
'ecotax' => 0,
|
||||
'quantity' => intval($_POST['quantity']),
|
||||
'reference' => pSQL($_POST['reference']),
|
||||
'default_on' => 0));
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
static private function createCombinations($list)
|
||||
{
|
||||
if (sizeof($list) <= 1)
|
||||
return sizeof($list) ? array_map(create_function('$v', 'return (array($v));'), $list[0]) : $list;
|
||||
$res = array();
|
||||
$first = array_pop($list);
|
||||
foreach ($first AS $attribute)
|
||||
{
|
||||
$tab = self::createCombinations($list);
|
||||
foreach ($tab AS $toAdd)
|
||||
$res[] = is_array($toAdd) ? array_merge($toAdd, array($attribute)) : array($toAdd, $attribute);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
$this->product = new Product(intval(Tools::getValue('id_product')));
|
||||
if (isset($_POST['generate']))
|
||||
{
|
||||
if (!is_array(Tools::getValue('options')))
|
||||
$this->_errors[] = Tools::displayError('You need to choose at least 1 attribute.');
|
||||
else
|
||||
{
|
||||
$tab = array_values($_POST['options']);
|
||||
if (sizeof($tab) AND Validate::isLoadedObject($this->product))
|
||||
{
|
||||
self::setAttributesImpacts($this->product->id, $tab);
|
||||
$this->combinations = array_values(self::createCombinations($tab));
|
||||
$values = array_values(array_map(array($this, 'addAttribute'), $this->combinations));
|
||||
$res = $this->product->addProductAttributeMultiple($values, (Product::getDefaultAttribute($this->product->id) ? false : true));
|
||||
$this->product->addAttributeCombinationMultiple($res, $this->combinations);
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('Unable to initialize parameters, combinations is missing or object cannot be load.');
|
||||
}
|
||||
}
|
||||
elseif (isset($_POST['back']))
|
||||
Tools::redirectAdmin($currentIndex.'&id_product='.intval(Tools::getValue('id_product')).'&id_category='.intval(Tools::getValue('id_category')).'&addproduct'.'&tabs=2&token='.Tools::getValue('token'));
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
static private function displayAndReturnAttributeJs()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$attributes = Attribute::getAttributes(intval($cookie->id_lang), true);
|
||||
$attributeJs = array();
|
||||
foreach ($attributes AS $k => $attribute)
|
||||
$attributeJs[$attribute['id_attribute_group']][$attribute['id_attribute']] = $attribute['name'];
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
var attrs = new Array();
|
||||
attrs[0] = new Array(0, \'---\');';
|
||||
foreach ($attributeJs AS $idgrp => $group)
|
||||
{
|
||||
echo '
|
||||
attrs['.$idgrp.'] = new Array(0, \'---\' ';
|
||||
foreach ($group AS $idattr => $attrname)
|
||||
echo ', '.$idattr.', \''.addslashes(($attrname)).'\'';
|
||||
echo ');';
|
||||
}
|
||||
echo '
|
||||
</script>';
|
||||
return $attributeJs;
|
||||
}
|
||||
|
||||
private function displayGroupSelect($attributeJs, $attributesGroups)
|
||||
{
|
||||
echo ' <div>
|
||||
<select multiple name="attributes[]" id="attribute_group" style="width: 200px; height: 350px;">';
|
||||
|
||||
foreach ($attributesGroups AS $k => $attributeGroup)
|
||||
{
|
||||
$idGroup = $attributeGroup['id_attribute_group'];
|
||||
|
||||
if (isset($attributeJs[$idGroup]))
|
||||
{
|
||||
echo ' <optgroup name="'.$idGroup.'" id="'.$idGroup.'" label="'.htmlspecialchars(stripslashes($attributeGroup['name'])).'">';
|
||||
|
||||
foreach ($attributeJs[$idGroup] AS $k => $v)
|
||||
echo ' <option name="'.$k.'" id="attr_'.$k.'" value="'.$v.'" title="'.$v.'"">'.$v.'</option>';
|
||||
|
||||
echo ' </optgroup>';
|
||||
}
|
||||
}
|
||||
echo ' </select>
|
||||
</div>';
|
||||
}
|
||||
|
||||
static private function setAttributesImpacts($id_product, $tab)
|
||||
{
|
||||
$attributes = array();
|
||||
foreach ($tab AS $group)
|
||||
foreach ($group AS $attribute)
|
||||
$attributes[] = '('.intval($id_product).', '.intval($attribute).', '.floatval($_POST['price_impact'][intval($attribute)]).', '.floatval($_POST['weight_impact'][intval($attribute)]).')';
|
||||
return Db::getInstance()->Execute(
|
||||
'INSERT INTO `'._DB_PREFIX_.'attribute_impact` (`id_product`, `id_attribute`, `price`, `weight`)
|
||||
VALUES '.implode(',', $attributes).'
|
||||
ON DUPLICATE KEY UPDATE `price`=VALUES(price), `weight`=VALUES(weight)'
|
||||
);
|
||||
}
|
||||
|
||||
static private function getAttributesImpacts($id_product)
|
||||
{
|
||||
$tab = array();
|
||||
$result = Db::getInstance()->ExecuteS(
|
||||
'SELECT ai.`id_attribute`, ai.`price`, ai.`weight`
|
||||
FROM `'._DB_PREFIX_.'attribute_impact` ai
|
||||
WHERE ai.`id_product` = '.intval($id_product));
|
||||
if (!$result)
|
||||
return array();
|
||||
foreach ($result AS $impact)
|
||||
{
|
||||
$tab[$impact['id_attribute']]['price'] = floatval($impact['price']);
|
||||
$tab[$impact['id_attribute']]['weight'] = floatval($impact['weight']);
|
||||
}
|
||||
return $tab;
|
||||
}
|
||||
|
||||
private function displayGroupeTable($attributeJs, $attributesGroups)
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
$combinationsGroups = $this->product->getAttributesGroups(intval($cookie->id_lang));
|
||||
$attributes = array();
|
||||
$impacts = self::getAttributesImpacts($this->product->id);
|
||||
foreach ($combinationsGroups AS &$combination)
|
||||
{
|
||||
$target = &$attributes[$combination['id_attribute_group']][$combination['id_attribute']];
|
||||
$target = $combination;
|
||||
if (isset($impacts[$combination['id_attribute']]))
|
||||
{
|
||||
$target['price'] = $impacts[$combination['id_attribute']]['price'];
|
||||
$target['weight'] = $impacts[$combination['id_attribute']]['weight'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($attributesGroups AS $k => $attributeGroup)
|
||||
{
|
||||
$idGroup = $attributeGroup['id_attribute_group'];
|
||||
if (isset($attributeJs[$idGroup]))
|
||||
{
|
||||
echo '
|
||||
<br class="clear"/>
|
||||
<table class="table" cellpadding="0" cellspacing="0" align="left" style="margin-bottom: 10px; display: none;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th id="tab_h1" style="width: 250px">'.htmlspecialchars(stripslashes($attributeGroup['name'])).'</th>
|
||||
<th id="tab_h2" style="width: 150px">'.$this->l('Price impact').' ('.$currency->sign.')'.' <sup>*</sup></th>
|
||||
<th style="width: 150px">'.$this->l('Weight impact').' ('.Configuration::get('PS_WEIGHT_UNIT').')'.'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="table_'.$idGroup.'" name="result_table">
|
||||
</tbody>
|
||||
</table>';
|
||||
if (isset($attributes[$idGroup]))
|
||||
foreach ($attributes[$idGroup] AS $k => $attribute)
|
||||
echo '<script type="text/javascript">getE(\'table_\' + '.$idGroup.').appendChild(create_attribute_row('.$k.', '.$idGroup.', \''.addslashes($attribute['attribute_name']).'\', '.$attribute['price'].', '.$attribute['weight'].'));toggle(getE(\'table_\' + '.$idGroup.').parentNode, true);</script>';
|
||||
}
|
||||
}
|
||||
echo '<p><sup>*</sup> '.$this->l('tax included').'</p>';
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
parent::displayForm();
|
||||
|
||||
$jsAttributes = self::displayAndReturnAttributeJs();
|
||||
$attributesGroups = AttributeGroup::getAttributesGroups(intval($cookie->id_lang));
|
||||
$this->product = new Product(intval(Tools::getValue('id_product')));
|
||||
if (isset($_POST['generate']) AND !sizeof($this->_errors))
|
||||
echo '
|
||||
<div class="module_confirmation conf confirm">
|
||||
<img src="../img/admin/ok.gif" alt="" title="" style="margin-right:5px; float:left;" />
|
||||
'.sizeof($this->combinations).' '.$this->l('product(s) successfully created.').'
|
||||
</div>';
|
||||
echo '
|
||||
<script type="text/javascript" src="../js/attributesBack.js"></script>
|
||||
<form enctype="multipart/form-data" method="post" id="generator" action=""'.$currentIndex.'&id_category='.intval(Tools::getValue('id_category')).'token='.Tools::getValue('token').'">
|
||||
<fieldset style="margin-bottom: 35px;"><legend><img src="../img/admin/asterisk.gif" />'.$this->l('Attributes generator').'</legend>'.
|
||||
$this->l('Add or modify attributes for this product:').'
|
||||
<br /><br />
|
||||
';
|
||||
echo '
|
||||
<div style="padding-top:10px; float: left; width: 570px;">
|
||||
<div style="float:left;">
|
||||
<label>'.$this->l('Quantity:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="20" name="quantity" value="1"/>
|
||||
</div>
|
||||
<label>'.$this->l('Reference:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="20" name="reference" value="'.$this->product->reference.'"/>
|
||||
</div>
|
||||
</div>
|
||||
<div style="float:left; text-align:center; margin-left:20px;">
|
||||
<input type="submit" class="button" style="margin-bottom:5px;" name="generate" value="'.$this->l('Generate').'" /><br />
|
||||
<input type="submit" class="button" name="back" value="'.$this->l('Back to product').'" />
|
||||
</div>
|
||||
<br style="clear:both;" />
|
||||
<div style="margin-top: 15px;">';
|
||||
self::displayGroupeTable($jsAttributes, $attributesGroups);
|
||||
echo '
|
||||
</div>
|
||||
</div>
|
||||
<div style="float: left; margin-left: 60px;">
|
||||
';
|
||||
self::displayGroupSelect($jsAttributes, $attributesGroups);
|
||||
echo '
|
||||
<div>
|
||||
<input class="button" type="button" style="margin-left: 20px;" value="'.$this->l('Add').'" class="button" onclick="add_attr_multiple();" />
|
||||
<input class="button" type="button" style="margin-left: 20px;" value="'.$this->l('Delete').'" class="button" onclick="del_attr_multiple();" />
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Attributes tab for admin panel, AdminAttributes.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminAttributes extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'attribute';
|
||||
$this->className = 'Attribute';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldImageSettings = array('name' => 'texture', 'dir' => 'co');
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display form
|
||||
*
|
||||
* @global string $currentIndex Current URL in order to keep current Tab
|
||||
*/
|
||||
public function displayForm($token = NULL)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
$color = ($obj->color ? $obj->color : 0);
|
||||
$attributes_groups = AttributeGroup::getAttributesGroups($this->_defaultFormLanguage);
|
||||
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
var attributesGroups = new Array();
|
||||
';
|
||||
foreach ($attributes_groups AS $attribute_group)
|
||||
echo 'attributesGroups['.$attribute_group['id_attribute_group'].'] = '.$attribute_group['is_color_group'].';'."\n";
|
||||
echo '
|
||||
</script>
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.($token ? $token : $this->token).'" method="post" enctype="multipart/form-data">
|
||||
'.($obj->id ? '<input type="hidden" name="id_attribute" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset class="width3"><legend><img src="../img/admin/asterisk.gif" />'.$this->l('Attribute').'</legend>
|
||||
<label>'.$this->l('Name:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="name_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="33" type="text" name="name_'.$language['id_lang'].'" value="'.htmlspecialchars($this->getFieldValue($obj, 'name', intval($language['id_lang']))).'" /><sup> *</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name');
|
||||
echo '
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<label>'.$this->l('Group:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name="id_attribute_group" id="id_attribute_group" onchange="showAttributeColorGroup(\'id_attribute_group\', \'colorAttributeProperties\')">';
|
||||
|
||||
foreach ($attributes_groups AS $attribute_group)
|
||||
echo '<option value="'.$attribute_group['id_attribute_group'].'"'.($this->getFieldValue($obj, 'id_attribute_group') == $attribute_group['id_attribute_group'] ? ' selected="selected"' : '').'>'.$attribute_group['name'].'</option>';
|
||||
echo '
|
||||
</select><sup> *</sup>
|
||||
</div>
|
||||
<div id="colorAttributeProperties" style="'.((Validate::isLoadedObject($obj) AND $obj->isColorAttribute()) ? 'display: block;' : 'display: none;').'">
|
||||
<label>'.$this->l('Color:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="color" value="'.(Tools::getValue('color', $color) ? htmlentities(Tools::getValue('color', $color)) : '#000000').'" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('HTML colors only (e.g.,').' "lightblue", "#CC6600")</p>
|
||||
</div>
|
||||
<label>'.$this->l('Texture:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="file" name="texture" />
|
||||
<p>'.$this->l('Upload color texture from your computer').'<br />'.$this->l('This will override the HTML color!').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Current texture:').' </label>
|
||||
<div class="margin-form">
|
||||
<p>'.(file_exists(_PS_IMG_DIR_.$this->fieldImageSettings['dir'].'/'.$obj->id.'.jpg')
|
||||
? '<img src="../img/'.$this->fieldImageSettings['dir'].'/'.$obj->id.'.jpg" alt="" title="" /> <a href="'.$_SERVER['REQUEST_URI'].'&deleteImage=1"><img src="../img/admin/delete.gif" alt="'.$this->l('delete').'" title="" /></a>'
|
||||
: $this->l('None')
|
||||
).'</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAddattribute" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage page processing
|
||||
*
|
||||
* @global string $currentIndex Current URL in order to keep current Tab
|
||||
*/
|
||||
public function postProcess($token = NULL)
|
||||
{
|
||||
global $currentIndex;
|
||||
if (Tools::getValue('submitDel'.$this->table))
|
||||
{
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
if (isset($_POST[$this->table.$_POST['groupid'].'Box']))
|
||||
{
|
||||
$object = new $this->className();
|
||||
if ($object->deleteSelection($_POST[$this->table.$_POST['groupid'].'Box']))
|
||||
Tools::redirectAdmin($currentIndex.'&conf=2'.'&token='.($token ? $token : $this->token));
|
||||
$this->_errors[] = Tools::displayError('an error occurred while deleting selection');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('you must select at least one element to delete');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,211 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Attributes tab for admin panel, AdminAttributesGroups.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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');
|
||||
include_once(PS_ADMIN_DIR.'/tabs/AdminAttributes.php');
|
||||
|
||||
class AdminAttributesGroups extends AdminTab
|
||||
{
|
||||
/** @var object AdminAttributes() instance */
|
||||
private $adminAttributes;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->adminAttributes = new AdminAttributes();
|
||||
$this->table = 'attribute_group';
|
||||
$this->className = 'AttributeGroup';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 140),
|
||||
'attribute' => array('title' => $this->l('Attributes'), 'width' => 240, 'orderby' => false, 'search' => false));
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if ((isset($_POST['submitAddattribute']) AND sizeof($this->adminAttributes->_errors))
|
||||
OR isset($_GET['updateattribute']) OR isset($_GET['addattribute']))
|
||||
{
|
||||
$this->adminAttributes->displayForm($this->token);
|
||||
echo '<br /><br /><a href="'.$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow.gif" /> '.$this->l('Back to list').'</a><br />';
|
||||
}
|
||||
else
|
||||
parent::display();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $cookie, $currentIndex;
|
||||
|
||||
$this->adminAttributes->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id);
|
||||
$this->adminAttributes->postProcess($this->token);
|
||||
|
||||
if(Tools::getValue('submitDel'.$this->table))
|
||||
{
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
if (isset($_POST[$this->table.'Box']))
|
||||
{
|
||||
$object = new $this->className();
|
||||
if ($object->deleteSelection($_POST[$this->table.'Box']))
|
||||
Tools::redirectAdmin($currentIndex.'&conf=2'.'&token='.$this->token);
|
||||
$this->_errors[] = Tools::displayError('an error occurred while deleting selection');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('you must select at least one element to delete');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
public function displayErrors()
|
||||
{
|
||||
$this->adminAttributes->displayErrors();
|
||||
parent::displayErrors();
|
||||
}
|
||||
|
||||
/* Report to AdminTab::displayList() for more details */
|
||||
public function displayList()
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
|
||||
echo '<br /><a href="'.$currentIndex.'&add'.$this->table.'&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> <b>'.$this->l('Add attributes group').'</b></a><br />
|
||||
<a href="'.$currentIndex.'&addattribute&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add attribute').'</a><br /><br />
|
||||
'.$this->l('Click on the group name to view its attributes. Click again to hide them.').'<br /><br />';
|
||||
if ($this->_list === false)
|
||||
Tools::displayError('no elements found');
|
||||
|
||||
$this->displayListHeader();
|
||||
echo '<input type="hidden" name="groupid" value="0">';
|
||||
|
||||
if (!sizeof($this->_list))
|
||||
echo '<tr><td class="center" colspan="'.sizeof($this->_list).'">'.$this->l('No elements found').'</td></tr>';
|
||||
|
||||
$irow = 0;
|
||||
foreach ($this->_list AS $tr)
|
||||
{
|
||||
$id = intval($tr['id_'.$this->table]);
|
||||
echo '
|
||||
<tr'.($irow++ % 2 ? ' class="alt_row"' : '').'>
|
||||
<td style="vertical-align: top; padding: 4px 0 4px 0" class="center"><input type="checkbox" name="'.$this->table.'Box[]" value="'.$id.'" class="noborder" /></td>
|
||||
<td style="width: 140px; vertical-align: top; padding: 4px 0 4px 0; cursor: pointer" onclick="openCloseLayer(\'attributes_'.$id.'\');">'.$tr['name'].'</td>
|
||||
<td style="vertical-align: top; padding: 4px 0 4px 0; width: 340px">
|
||||
<div id="attributes_'.$id.'" style="display: none">
|
||||
<table class="table" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'attribute'.$id.'Box[]\', this.checked)" /></th>
|
||||
<th width="100%">'.$this->l('Attribute').'</th>
|
||||
<th>'.$this->l('Actions').'</th>
|
||||
</tr>';
|
||||
$attributes = AttributeGroup::getAttributes(intval($cookie->id_lang), $id);
|
||||
foreach ($attributes AS $attribute)
|
||||
{
|
||||
echo '
|
||||
<tr>
|
||||
<td class="center"><input type="checkbox" name="attribute'.$id.'Box[]" value="'.$attribute['id_attribute'].'" class="noborder" /></td>
|
||||
<td>
|
||||
'.($tr['is_color_group'] ? '<div style="float: left; width: 18px; height: 12px; border: 1px solid #996633; background-color: '.$attribute['color'].'; margin-right: 4px;"></div>' : '')
|
||||
.$attribute['name'].'
|
||||
</td>
|
||||
<td class="center">
|
||||
<a href="'.$currentIndex.'&id_attribute='.$attribute['id_attribute'].'&updateattribute&token='.$this->token.'">
|
||||
<img src="../img/admin/edit.gif" border="0" alt="'.$this->l('Edit').'" title="'.$this->l('Edit').'" /></a>
|
||||
<a href="'.$currentIndex.'&id_attribute='.$attribute['id_attribute'].'&deleteattribute&token='.$this->token.'"
|
||||
onclick="return confirm(\''.$this->l('Delete attribute', __CLASS__, true, false).' #'.$attribute['id_attribute'].'?\');">
|
||||
<img src="../img/admin/delete.gif" border="0" alt="'.$this->l('Delete').'" title="'.$this->l('Delete').'" /></a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '
|
||||
</table>
|
||||
<p><input type="Submit" class="button" name="submitDelattribute" value="'.$this->l('Delete selection').'"
|
||||
onclick="changeFormParam(this.form, \''.$currentIndex.'\', '.$id.'); return confirm(\''.$this->l('Delete selected items?', __CLASS__, true, false).'\');" /></p>
|
||||
</div>
|
||||
</td>';
|
||||
|
||||
echo '
|
||||
<td style="vertical-align: top; padding: 4px 0 4px 0" class="center">
|
||||
<a href="'.$currentIndex.'&id_'.$this->table.'='.$id.'&update'.$this->table.'&token='.$this->token.'">
|
||||
<img src="../img/admin/edit.gif" border="0" alt="'.$this->l('Edit').'" title="'.$this->l('Edit').'" /></a>
|
||||
<a href="'.$currentIndex.'&id_'.$this->table.'='.$id.'&delete'.$this->table.'&token='.$this->token.'" onclick="return confirm(\''.$this->l('Delete item', __CLASS__, true, false).' #'.$id.'?\');">
|
||||
<img src="../img/admin/delete.gif" border="0" alt="'.$this->l('Delete').'" title="'.$this->l('Delete').'" /></a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
$this->displayListFooter();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&token='.$this->token.'" method="post">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset class="width3"><legend><img src="../img/admin/asterisk.gif" />'.$this->l('Attributes group').'</legend>
|
||||
<label>'.$this->l('Name:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="name_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="33" type="text" name="name_'.$language['id_lang'].'" value="'.htmlspecialchars($this->getFieldValue($obj, 'name', intval($language['id_lang']))).'" /><sup> *</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name¤public_name', 'name');
|
||||
echo '
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<label>'.$this->l('Public name:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="public_name_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="33" type="text" name="public_name_'.$language['id_lang'].'" value="'.htmlspecialchars($this->getFieldValue($obj, 'public_name', intval($language['id_lang']))).'" /><sup> *</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
<p style="clear: both">'.$this->l('Term or phrase displayed to the customer').'</p>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name¤public_name', 'public_name');
|
||||
echo '
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<label>'.$this->l('Color group:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="is_color_group" id="is_color_group_on" value="1" '.($this->getFieldValue($obj, 'is_color_group') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="is_color_group_on"><img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Yes').'" /></label>
|
||||
<input type="radio" name="is_color_group" id="is_color_group_off" value="0" '.(!$this->getFieldValue($obj, 'is_color_group') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="is_color_group_off"><img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('No').'" /></label>
|
||||
<p>'.$this->l('This is a color group').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,247 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Backup management tab for admin panel, AdminBackup.php
|
||||
* @category admin
|
||||
*
|
||||
* @author Andrew Brampton
|
||||
* @copyright Andrew Brampton
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 0.1
|
||||
*
|
||||
* @todo When exporting data, ExecuteS is used which returns a large array. I would prefer Db supported a way to retreive one row at a time
|
||||
* @todo Abstract some of the methods into the Db class, for example, listing table names, exporting schema
|
||||
* @todo Add a import backup option
|
||||
* @todo Make the filters work
|
||||
*/
|
||||
|
||||
include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');
|
||||
|
||||
class AdminBackup extends AdminTab
|
||||
{
|
||||
|
||||
/** @var string The field we are sorting on */
|
||||
protected $_sortBy = 'date';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'backup';
|
||||
$this->className = 'Backup';
|
||||
parent::__construct();
|
||||
|
||||
$this->edit = false;
|
||||
$this->delete = true;
|
||||
$this->view = true;
|
||||
|
||||
$this->deleted = false;
|
||||
|
||||
$this->fieldsDisplay = array (
|
||||
'date' => array('title' => $this->l('Date'), 'type' => 'datetime', 'width' => 120),
|
||||
'age' => array('title' => $this->l('Age')),
|
||||
'filename' => array('title' => $this->l('Filename'), 'width' => 200),
|
||||
'filesize' => array('title' => $this->l('File size')));
|
||||
$this->optionTitle = $this->l('Backup option');
|
||||
$this->_fieldsOptions = array('PS_BACKUP_ALL' => array('title' => $this->l('Backup all tables:'), 'desc' => $this->l('If you disable this option, only the necessary tables will be imported (connections and statistics will not be imported)'), 'cast' => 'intval', 'type' => 'bool'));
|
||||
|
||||
$this->identifier = 'filename';
|
||||
}
|
||||
|
||||
/**
|
||||
* Load class object using identifier in $_GET (if possible)
|
||||
* otherwise return an empty object
|
||||
* This method overrides the one in AdminTab because AdminTab assumes the id is a UnsignedInt
|
||||
*dir backups on admin dir must be writable (CHMOD 777)
|
||||
* @param boolean $opt Return an empty object if load fail
|
||||
* @return object
|
||||
*/
|
||||
protected function loadObject($opt = false)
|
||||
{
|
||||
if ($id = Tools::getValue($this->identifier))
|
||||
return new $this->className($id);
|
||||
return new $this->className();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new backup, and then displays the normal menu
|
||||
*/
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
if(is_writable(PS_ADMIN_DIR.'/backups/'))
|
||||
{
|
||||
$object = $this->loadObject();
|
||||
if ($object->add())
|
||||
{
|
||||
echo '<div class="conf confirm"><img src="../img/admin/ok.gif" /> '.$this->l('Back-up Creation successful').' !</div>';
|
||||
if ($this->tabAccess['view'] === '1')
|
||||
echo '<br />'.$this->l('You can now').' <b><a href="'.$object->getBackupURL().'">'.$this->l('download the back-up file').'</a></b>.';
|
||||
echo '<br />';
|
||||
}
|
||||
elseif ($object->error)
|
||||
$this->_errors[] = $object->error;
|
||||
}
|
||||
else
|
||||
$this->_errors[] = $this->l('dir backups on admin dir must be writable (CHMOD 777)');
|
||||
$this->displayErrors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the page which allows the backup to be downloaded
|
||||
*/
|
||||
public function viewbackup()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
$object = $this->loadObject();
|
||||
if ($object->id)
|
||||
{
|
||||
$url = $object->getBackupURL();
|
||||
echo '<div class="conf confirm"><img src="../img/admin/ok.gif" /> '.$this->l('Beginning download ...').'</div>';
|
||||
echo '<br />'.$this->l('Back-up file should automatically download.');
|
||||
echo '<br /><br />'.$this->l('If not,').' <b><a href="'.$url.'">'.$this->l('please click here!').'</a></b>';
|
||||
echo '<iframe width="0" height="0" scrolling="no" frameborder="0" src="'.$url.'"></iframe>';
|
||||
echo '<br /><br /><br /><a href="'.$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to list').'</a><br />';
|
||||
}
|
||||
elseif ($object->error)
|
||||
$this->_errors[] = $object->error;
|
||||
$this->displayErrors();
|
||||
}
|
||||
|
||||
public function displayList()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
// Test if the backup dir is writable
|
||||
if(!is_writable(PS_ADMIN_DIR.'/backups/'))
|
||||
$this->displayWarning($this->l('dir backups on admin dir must be writable (CHMOD 777)'));
|
||||
|
||||
$this->displayErrors();
|
||||
echo '<br /><a href="'.$currentIndex.'&add'.$this->table.'&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Create new back-up').'</a><br /><br />';
|
||||
parent::displayList();
|
||||
}
|
||||
|
||||
public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL)
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
if (!Validate::isTableOrIdentifier($this->table))
|
||||
die('filter is corrupted');
|
||||
if (empty($orderBy))
|
||||
$orderBy = Tools::getValue($this->table.'Orderby', $this->_defaultOrderBy);
|
||||
if (empty($orderWay))
|
||||
$orderWay = Tools::getValue($this->table.'Orderway', 'ASC');
|
||||
|
||||
// Try and obtain getList arguments from $_GET
|
||||
$orderBy = Tools::getValue($this->table.'Orderby');
|
||||
$orderWay = Tools::getValue($this->table.'Orderway');
|
||||
|
||||
// Validate the orderBy and orderWay fields
|
||||
switch ($orderBy)
|
||||
{
|
||||
case 'filename':
|
||||
case 'filesize':
|
||||
case 'date':
|
||||
case 'age':
|
||||
break;
|
||||
default:
|
||||
$orderBy = 'date';
|
||||
}
|
||||
switch ($orderWay)
|
||||
{
|
||||
case 'asc':
|
||||
case 'desc':
|
||||
break;
|
||||
default:
|
||||
$orderWay = 'desc';
|
||||
}
|
||||
if (empty($limit))
|
||||
$limit = ((!isset($cookie->{$this->table.'_pagination'})) ? $this->_pagination[0] : $limit = $cookie->{$this->table.'_pagination'});
|
||||
$limit = intval(Tools::getValue('pagination', $limit));
|
||||
$cookie->{$this->table.'_pagination'} = $limit;
|
||||
|
||||
/* Determine offset from current page */
|
||||
if (!empty($_POST['submitFilter'.$this->table]) AND is_numeric($_POST['submitFilter'.$this->table]))
|
||||
$start = intval($_POST['submitFilter'.$this->table] - 1) * $limit;
|
||||
$this->_lang = intval($id_lang);
|
||||
$this->_orderBy = $orderBy;
|
||||
$this->_orderWay = strtoupper($orderWay);
|
||||
$this->_list = array();
|
||||
|
||||
// Find all the backups
|
||||
$dh = @opendir(PS_ADMIN_DIR.'/backups/');
|
||||
if ($dh === false)
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('Unable to open backup directory "').addslashes(PS_ADMIN_DIR.'/backups/').'"';
|
||||
return;
|
||||
}
|
||||
while (($file = readdir($dh)) !== false)
|
||||
{
|
||||
if (preg_match('/^([\d]+-[a-z\d]+)\.sql(\.gz|\.bz2)?$/', $file, $matches) == 0)
|
||||
continue;
|
||||
$timestamp = intval($matches[1]);
|
||||
$date = date('Y-m-d h:i:s', $timestamp);
|
||||
$age = time() - $timestamp;
|
||||
if ($age < 3600)
|
||||
$age = '< 1 '.$this->l('hour');
|
||||
else if ($age < 86400)
|
||||
{
|
||||
$age = floor($age / 3600);
|
||||
$age = $age.' '.(($age == 1) ? $this->l('hour') : $this->l('hours'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$age = floor($age / 86400);
|
||||
$age = $age.' '.(($age == 1) ? $this->l('day') : $this->l('days'));
|
||||
}
|
||||
$size = filesize(PS_ADMIN_DIR.'/backups/'.$file);
|
||||
$this->_list[] = array(
|
||||
'filename' => $file,
|
||||
'age' => $age,
|
||||
'date' => $date,
|
||||
'filesize' => number_format($size / 1000, 2).' Kb',
|
||||
'timestamp' => $timestamp,
|
||||
'filesize_sort' => $size,
|
||||
);
|
||||
}
|
||||
closedir($dh);
|
||||
$this->_listTotal = count($this->_list);
|
||||
|
||||
// Sort the _list based on the order requirements
|
||||
switch ($this->_orderBy)
|
||||
{
|
||||
case 'filename':
|
||||
$this->_sortBy = 'filename';
|
||||
$sorter = 'str_sort';
|
||||
break;
|
||||
case 'filesize':
|
||||
$this->_sortBy = 'filesize_sort';
|
||||
$sorter = 'int_sort';
|
||||
break;
|
||||
case 'age':
|
||||
case 'date':
|
||||
$this->_sortBy = 'timestamp';
|
||||
$sorter = 'int_sort';
|
||||
break;
|
||||
}
|
||||
usort($this->_list, array($this, $sorter));
|
||||
$this->_list = array_slice($this->_list, $start, $limit);
|
||||
}
|
||||
|
||||
public function int_sort($a, $b)
|
||||
{
|
||||
if ($this->_orderWay == 'ASC')
|
||||
return $a[$this->_sortBy] - $b[$this->_sortBy];
|
||||
else
|
||||
return $b[$this->_sortBy] - $a[$this->_sortBy];
|
||||
}
|
||||
|
||||
public function str_sort($a, $b)
|
||||
{
|
||||
if ($this->_orderWay == 'ASC')
|
||||
return strcmp ($a[ $this->_sortBy], $b[$this->_sortBy]);
|
||||
else
|
||||
return strcmp ($b[ $this->_sortBy], $a[$this->_sortBy]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* CMS tab for admin panel, AdminCMS.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminCMS extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'cms';
|
||||
$this->className = 'CMS';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->view = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_cms' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'link_rewrite' => array('title' => $this->l('URL'), 'width' => 200),
|
||||
'meta_title' => array('title' => $this->l('Title'), 'width' => 300)
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
$iso = Language::getIsoById(intval($cookie->id_lang));
|
||||
$divLangName = 'meta_title¤meta_description¤meta_keywords¤ccontent¤link_rewrite';
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/admin/cms.gif" />'.$this->l('CMS').'</legend>';
|
||||
|
||||
// META TITLE
|
||||
echo ' <label>'.$this->l('Meta title').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo ' <div id="meta_title_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="40" type="text" name="meta_title_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'meta_title', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'meta_title');
|
||||
echo ' </div><div class="clear space"> </div>';
|
||||
|
||||
// META DESCRIPTION
|
||||
echo ' <label>'.$this->l('Meta description').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo ' <div id="meta_description_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="50" type="text" name="meta_description_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'meta_description', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'meta_description');
|
||||
echo ' </div><div class="clear space"> </div>';
|
||||
|
||||
// META KEYWORDS
|
||||
echo ' <label>'.$this->l('Meta keywords').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo ' <div id="meta_keywords_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="50" type="text" name="meta_keywords_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'meta_keywords', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'meta_keywords');
|
||||
echo ' </div><div class="clear space"> </div>';
|
||||
|
||||
// LINK REWRITE
|
||||
echo ' <label>'.$this->l('Friendly URL').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo ' <div id="link_rewrite_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="30" type="text" name="link_rewrite_'.$language['id_lang'].'" onkeyup="this.value = str2url(this.value); updateFriendlyURL();" value="'.htmlentities($this->getFieldValue($obj, 'link_rewrite', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'link_rewrite');
|
||||
echo ' </div><div class="clear space"> </div>';
|
||||
|
||||
// CONTENT
|
||||
echo ' <label>'.$this->l('Page content').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo ' <div id="ccontent_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').';float: left;">
|
||||
<textarea class="rte" cols="80" rows="30" id="content_'.$language['id_lang'].'" name="content_'.$language['id_lang'].'">'.htmlentities(stripslashes($this->getFieldValue($obj, 'content', $language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'ccontent');
|
||||
echo ' </div><div class="clear space"> </div>';
|
||||
|
||||
// SUBMIT
|
||||
echo ' <div class="margin-form space">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
|
||||
// TinyMCE
|
||||
echo '
|
||||
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tinymce/jscripts/tiny_mce/jquery.tinymce.js"></script>
|
||||
<script type="text/javascript">
|
||||
function tinyMCEInit(element)
|
||||
{
|
||||
$().ready(function() {
|
||||
$(element).tinymce({
|
||||
// Location of TinyMCE script
|
||||
script_url : \''.__PS_BASE_URI__.'js/tinymce/jscripts/tiny_mce/tiny_mce.js\',
|
||||
// General options
|
||||
theme : "advanced",
|
||||
plugins : "safari,pagebreak,style,layer,table,advimage,advlink,inlinepopups,media,searchreplace,contextmenu,paste,directionality,fullscreen",
|
||||
// Theme options
|
||||
theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
|
||||
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,,|,forecolor,backcolor",
|
||||
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,media,|,ltr,rtl,|,fullscreen",
|
||||
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,pagebreak",
|
||||
theme_advanced_toolbar_location : "top",
|
||||
theme_advanced_toolbar_align : "left",
|
||||
theme_advanced_statusbar_location : "bottom",
|
||||
theme_advanced_resizing : false,
|
||||
content_css : "'.__PS_BASE_URI__.'themes/'._THEME_NAME_.'/css/global.css",
|
||||
document_base_url : "'.__PS_BASE_URI__.'",
|
||||
width: "582",
|
||||
height: "auto",
|
||||
font_size_style_values : "8pt, 10pt, 12pt, 14pt, 18pt, 24pt, 36pt",
|
||||
// Drop lists for link/image/media/template dialogs
|
||||
template_external_list_url : "lists/template_list.js",
|
||||
external_link_list_url : "lists/link_list.js",
|
||||
external_image_list_url : "lists/image_list.js",
|
||||
media_external_list_url : "lists/media_list.js",
|
||||
elements : "nourlconvert",
|
||||
convert_urls : false,
|
||||
language : "'.(file_exists(_PS_ROOT_DIR_.'/js/tinymce/jscripts/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en').'"
|
||||
});
|
||||
});
|
||||
}
|
||||
tinyMCEInit(\'textarea.rte\');
|
||||
</script>
|
||||
';
|
||||
}
|
||||
|
||||
function postProcess()
|
||||
{
|
||||
global $cookie, $link;
|
||||
if (Tools::isSubmit('viewcms') AND ($id_cms = intval(Tools::getValue('id_cms'))) AND $cms = new CMS($id_cms, intval($cookie->id_lang)) AND Validate::isLoadedObject($cms))
|
||||
Tools::redirectLink($link->getCMSLink($cms));
|
||||
return parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,296 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Carriers tab for admin panel, AdminCarriers.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminCarriers extends AdminTab
|
||||
{
|
||||
protected $maxImageSize = 30000;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$this->table = 'carrier';
|
||||
$this->className = 'Carrier';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
$this->deleted = true;
|
||||
$this->fieldImageSettings = array('name' => 'logo', 'dir' => 's');
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_carrier' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 100),
|
||||
'logo' => array('title' => $this->l('Logo'), 'align' => 'center', 'image' => 's', 'orderby' => false, 'search' => false),
|
||||
'delay' => array('title' => $this->l('Delay'), 'width' => 300, 'orderby' => false),
|
||||
'active' => array('title' => $this->l('Status'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
|
||||
|
||||
$this->optionTitle = $this->l('Carrier options');
|
||||
$this->_fieldsOptions = array(
|
||||
'PS_CARRIER_DEFAULT' => array('title' => $this->l('Default carrier:'), 'desc' => $this->l('The default carrier used in shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_carrier', 'list' => Carrier::getCarriers(intval($cookie->id_lang), true)),
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
$currentLanguage = intval($cookie->id_lang);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" enctype="multipart/form-data">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset class="width3"><legend><img src="../img/admin/delivery.gif" />'.$this->l('Carriers').'</legend>
|
||||
<label>'.$this->l('Company:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="25" name="name" value="'.htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Allowed characters: letters, spaces and').' ().-<span class="hint-pointer"> </span></span>
|
||||
<p class="clear">'.$this->l('Carrier name displayed during checkout').'<br />'.$this->l('With a value of 0, the carrier name will be replaced by the shop name').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Logo:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="file" name="logo" />
|
||||
<p>'.$this->l('Upload logo from your computer').' (.gif, .jpg, .jpeg '.$this->l('or').' .png)</p>
|
||||
</div>
|
||||
<label>'.$this->l('Transit time:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="delay_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input type="text" size="41" maxlength="128" name="delay_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'delay', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'delay', 'delay');
|
||||
echo '
|
||||
<p style="clear: both">'.$this->l('Time taken for product delivery; displayed during checkout').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('URL:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="40" name="url" value="'.htmlentities($this->getFieldValue($obj, 'url'), ENT_COMPAT, 'UTF-8').'" />
|
||||
<p class="clear">'.$this->l('URL for the tracking number; type \'@\' where the tracking number will appear').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Tax:').'</label>
|
||||
<div class="margin-form">
|
||||
<select name="id_tax">
|
||||
<option value="0"'.(($obj->id AND $obj->id_tax == 0) ? ' selected="selected"' : '').'>'.$this->l('No tax').'</option>';
|
||||
$tvaList = Tax::getTaxes($currentLanguage);
|
||||
foreach ($tvaList AS $line)
|
||||
echo '<option value="'.$line['id_tax'].'"'.(($obj->id AND $obj->id_tax == $line['id_tax']) ? ' selected="selected"' : '').'>'.$line['name'].'</option>';
|
||||
echo '</select>
|
||||
<p>'.$this->l('Include tax on carrier, e.g., VAT').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Zone:').'</label>
|
||||
<div class="margin-form">';
|
||||
$carrier_zones = $obj->getZones();
|
||||
$zones = Zone::getZones(true);
|
||||
foreach ($zones AS $zone)
|
||||
echo '<input type="checkbox" id="zone_'.$zone['id_zone'].'" name="zone_'.$zone['id_zone'].'" value="true" '.(Tools::getValue('zone_'.$zone['id_zone'], (is_array($carrier_zones) AND in_array(array('id_carrier' => $obj->id, 'id_zone' => $zone['id_zone']), $carrier_zones))) ? ' checked="checked"' : '').'><label class="t" for="zone_'.$zone['id_zone'].'"> <b>'.$zone['name'].'</b></label><br />';
|
||||
echo '<p>'.$this->l('The zone in which this carrier is to be used').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Group access:').'</label>
|
||||
<div class="margin-form">';
|
||||
$groups = Group::getGroups(intval($cookie->id_lang));
|
||||
if (sizeof($groups))
|
||||
{
|
||||
echo '
|
||||
<table cellspacing="0" cellpadding="0" class="table" style="width: 28em;">
|
||||
<tr>
|
||||
<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'groupBox[]\', this.checked)"'.(!isset($obj->id) ? 'checked="checked" ' : '').' /></th>
|
||||
<th>'.$this->l('ID').'</th>
|
||||
<th>'.$this->l('Group name').'</th>
|
||||
</tr>';
|
||||
$irow = 0;
|
||||
foreach ($groups as $group)
|
||||
echo '
|
||||
<tr class="'.($irow++ % 2 ? 'alt_row' : '').'">
|
||||
<td><input type="checkbox" name="groupBox[]" class="groupBox" id="groupBox_'.$group['id_group'].'" value="'.$group['id_group'].'" '.((Db::getInstance()->getValue('SELECT id_group FROM '._DB_PREFIX_.'carrier_group WHERE id_carrier='.intval($obj->id).' AND id_group='.intval($group['id_group'])) OR (!isset($obj->id))) ? 'checked="checked" ' : '').'/></td>
|
||||
<td>'.$group['id_group'].'</td>
|
||||
<td><label for="groupBox_'.$group['id_group'].'" class="t">'.$group['name'].'</label></td>
|
||||
</tr>';
|
||||
echo '
|
||||
</table>
|
||||
<p style="padding:0px; margin:10px 0px 10px 0px;">'.$this->l('Mark all groups you want to give access to this carrier').'</p>
|
||||
';
|
||||
}
|
||||
else
|
||||
echo '<p>'.$this->l('No group created').'</p>';
|
||||
echo ' </div>
|
||||
<label>'.$this->l('Status:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="active" id="active_on" value="1" '.($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="active" id="active_off" value="0" '.(!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('Include or exclude carrier from list of carriers on Front Office').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Shipping & handling:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="shipping_handling" id="shipping_handling_on" value="1" '.($this->getFieldValue($obj, 'shipping_handling') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="shipping_handling_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="shipping_handling" id="shipping_handling_off" value="0" '.(!$this->getFieldValue($obj, 'shipping_handling') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="shipping_handling_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('Include the shipping & handling costs in carrier price').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Out-of-range behavior:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name="range_behavior">
|
||||
<option value="0"'.(!$this->getFieldValue($obj, 'range_behavior') ? ' selected="selected"' : '').'>'.$this->l('Apply the cost of the highest defined range').'</option>
|
||||
<option value="1"'.($this->getFieldValue($obj, 'range_behavior') ? ' selected="selected"' : '').'>'.$this->l('Disable carrier').'</option>
|
||||
</select>
|
||||
<p>'.$this->l('Out-of-range behavior when none is defined (e.g., when a customer\'s cart weight is superior to the highest range limit)').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Module:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="is_module" id="active_on" value="1" '.($this->getFieldValue($obj, 'is_module') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="is_module" id="active_off" value="0" '.(!$this->getFieldValue($obj, 'is_module') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('Mark this carrier as linked to a module').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
public function beforeDelete($object)
|
||||
{
|
||||
return $object->isUsed();
|
||||
}
|
||||
|
||||
public function afterDelete($object, $oldId)
|
||||
{
|
||||
$object->copyCarrierData(intval($oldId));
|
||||
}
|
||||
|
||||
private function changeGroups($id_carrier, $delete = true)
|
||||
{
|
||||
if ($delete)
|
||||
Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'carrier_group WHERE id_carrier='.intval($id_carrier));
|
||||
$groups = Db::getInstance()->ExecuteS('SELECT id_group FROM '._DB_PREFIX_.'group');
|
||||
foreach ($groups as $group)
|
||||
if (in_array($group['id_group'], $_POST['groupBox']))
|
||||
Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'carrier_group (id_group, id_carrier) VALUES('.intval($group['id_group']).','.intval($id_carrier).')');
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if (Tools::getValue('submitAdd'.$this->table))
|
||||
{
|
||||
/* Checking fields validity */
|
||||
$this->validateRules();
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
$id = intval(Tools::getValue('id_'.$this->table));
|
||||
|
||||
/* Object update */
|
||||
if (isset($id) AND !empty($id))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
$object = new $this->className($id);
|
||||
if (Validate::isLoadedObject($object))
|
||||
{
|
||||
Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'carrier_group WHERE id_carrier='.intval($id));
|
||||
$object->deleted = 1;
|
||||
$object->update();
|
||||
$objectNew = new $this->className();
|
||||
$this->copyFromPost($objectNew, $this->table);
|
||||
$result = $objectNew->add();
|
||||
if (Validate::isLoadedObject($objectNew))
|
||||
{
|
||||
$this->afterDelete($objectNew, $object->id);
|
||||
Hook::updateCarrier(intval($object->id), $objectNew);
|
||||
}
|
||||
$this->changeGroups($objectNew->id);
|
||||
if (!$result)
|
||||
$this->_errors[] = Tools::displayError('an error occurred while updating object').' <b>'.$this->table.'</b>';
|
||||
elseif ($this->postImage($objectNew->id))
|
||||
{
|
||||
$this->changeZones($objectNew->id);
|
||||
Tools::redirectAdmin($currentIndex.'&id_'.$this->table.'='.$object->id.'&conf=4'.'&token='.$this->token);
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('an error occurred while updating object').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
|
||||
/* Object creation */
|
||||
else
|
||||
{
|
||||
if ($this->tabAccess['add'] === '1')
|
||||
{
|
||||
$object = new $this->className();
|
||||
$this->copyFromPost($object, $this->table);
|
||||
if (!$object->add())
|
||||
$this->_errors[] = Tools::displayError('an error occurred while creating object').' <b>'.$this->table.'</b>';
|
||||
elseif (($_POST['id_'.$this->table] = $object->id /* voluntary */) AND $this->postImage($object->id) AND $this->_redirect)
|
||||
{
|
||||
$this->changeZones($object->id);
|
||||
$this->changeGroups($object->id);
|
||||
Tools::redirectAdmin($currentIndex.'&id_'.$this->table.'='.$object->id.'&conf=3'.'&token='.$this->token);
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to add anything here.');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($_GET['delete'.$this->table]) AND Tools::getValue('id_carrier') == Configuration::get('PS_CARRIER_DEFAULT'))
|
||||
$this->_errors[] = $this->l('Please set another carrier as default before deleting');
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function changeZones($id)
|
||||
{
|
||||
$carrier = new $this->className($id);
|
||||
if (!Validate::isLoadedObject($carrier))
|
||||
die (Tools::displayError('object cannot be loaded'));
|
||||
$zones = Zone::getZones(true);
|
||||
foreach ($zones as $zone)
|
||||
if (sizeof($carrier->getZone($zone['id_zone'])))
|
||||
{
|
||||
if (!isset($_POST['zone_'.$zone['id_zone']]) OR !$_POST['zone_'.$zone['id_zone']])
|
||||
$carrier->deleteZone($zone['id_zone']);
|
||||
}
|
||||
else
|
||||
if (isset($_POST['zone_'.$zone['id_zone']]) AND $_POST['zone_'.$zone['id_zone']])
|
||||
$carrier->addZone($zone['id_zone']);
|
||||
}
|
||||
|
||||
public function displayListContent($token = NULL)
|
||||
{
|
||||
foreach ($this->_list as $key => $list)
|
||||
if ($list['name'] == '0')
|
||||
$this->_list[$key]['name'] = Configuration::get('PS_SHOP_NAME');
|
||||
parent::displayListContent($token);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,285 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Customers tab for admin panel, AdminContacts.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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' => '<b>', 'suffix' => '</b>', '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 '<h2>'.(($customer->id) ? $customer->firstname.' '.$customer->lastname : $this->l('Guest')).' - '.$this->l('Cart #').sprintf('%06d', $cart->id).' '.$this->l('from').' '.$cart->date_upd.'</h2>';
|
||||
|
||||
/* Display customer information */
|
||||
echo '
|
||||
<br />
|
||||
<div style="float: left;">
|
||||
<fieldset style="width: 400px">
|
||||
<legend><img src="../img/admin/tab-customers.gif" /> '.$this->l('Customer information').'</legend>
|
||||
<span style="font-weight: bold; font-size: 14px;">';
|
||||
if ($customer->id)
|
||||
echo '
|
||||
<a href="?tab=AdminCustomers&id_customer='.$customer->id.'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.intval(Tab::getIdFromClassName('AdminCustomers')).intval($cookie->id_employee)).'"> '.$customer->firstname.' '.$customer->lastname.'</a></span> ('.$this->l('#').$customer->id.')<br />
|
||||
(<a href="mailto:'.$customer->email.'">'.$customer->email.'</a>)<br /><br />
|
||||
'.$this->l('Account registered:').' '.Tools::displayDate($customer->date_add, intval($cookie->id_lang), true).'<br />
|
||||
'.$this->l('Valid orders placed:').' <b>'.$customerStats['nb_orders'].'</b><br />
|
||||
'.$this->l('Total paid since registration:').' <b>'.Tools::displayPrice($customerStats['total_orders'], $currency, false, false).'</b><br />';
|
||||
else
|
||||
echo $this->l('Guest not registered').'</span>';
|
||||
echo '</fieldset>';
|
||||
echo '
|
||||
</div>
|
||||
<div style="float: left; margin-left: 40px">';
|
||||
|
||||
/* Display order information */
|
||||
$id_order = intval(Order::getOrderByCartId($cart->id));
|
||||
$order = new Order($id_order);
|
||||
echo '
|
||||
<fieldset style="width: 400px">
|
||||
<legend><img src="../img/admin/cart.gif" /> '.$this->l('Order information').'</legend>
|
||||
<span style="font-weight: bold; font-size: 14px;">';
|
||||
if ($order->id)
|
||||
echo '
|
||||
<a href="?tab=AdminOrders&id_order='.intval($order->id).'&vieworder&token='.Tools::getAdminToken('AdminOrders'.intval(Tab::getIdFromClassName('AdminOrders')).intval($cookie->id_employee)).'"> '.$this->l('Order #').sprintf('%06d', $order->id).'</a></span>
|
||||
<br /><br />
|
||||
'.$this->l('Made on:').' '.$order->date_add.'<br /><br /><br /><br />';
|
||||
else
|
||||
echo $this->l('No order created from this cart').'</span>';
|
||||
echo '</fieldset>';
|
||||
echo '
|
||||
</div>';
|
||||
|
||||
// List of products
|
||||
echo '
|
||||
<br style="clear:both;" />
|
||||
<fieldset style="margin-top:25px; width: 715px; ">
|
||||
<legend><img src="../img/admin/cart.gif" alt="'.$this->l('Products').'" />'.$this->l('Cart summary').'</legend>
|
||||
<div style="float:left;">
|
||||
<table style="width: 700px;" cellspacing="0" cellpadding="0" class="table" id="orderProducts">
|
||||
<tr>
|
||||
<th align="center" style="width: 60px"> </th>
|
||||
<th>'.$this->l('Product').'</th>
|
||||
<th style="width: 80px; text-align: center">'.$this->l('UP').'</th>
|
||||
<th style="width: 20px; text-align: center">'.$this->l('Qty').'</th>
|
||||
<th style="width: 30px; text-align: center">'.$this->l('Stock').'</th>
|
||||
<th style="width: 90px; text-align: right; font-weight:bold;">'.$this->l('Total').'</th>
|
||||
</tr>';
|
||||
$tokenCatalog = Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee));
|
||||
foreach ($products as $k => $product)
|
||||
{
|
||||
$image = array();
|
||||
if (isset($product['id_product_attribute']) AND intval($product['id_product_attribute']))
|
||||
$image = Db::getInstance()->getRow('
|
||||
SELECT id_image
|
||||
FROM '._DB_PREFIX_.'product_attribute_image
|
||||
WHERE id_product_attribute = '.intval($product['id_product_attribute']));
|
||||
if (!isset($image['id_image']))
|
||||
$image = Db::getInstance()->getRow('
|
||||
SELECT id_image
|
||||
FROM '._DB_PREFIX_.'image
|
||||
WHERE id_product = '.intval($product['id_product']).' AND cover = 1');
|
||||
$stock = Db::getInstance()->getRow('
|
||||
SELECT '.($product['id_product_attribute'] ? 'pa' : 'p').'.quantity
|
||||
FROM '._DB_PREFIX_.'product p
|
||||
'.($product['id_product_attribute'] ? 'LEFT JOIN '._DB_PREFIX_.'product_attribute pa ON p.id_product = pa.id_product' : '').'
|
||||
WHERE p.id_product = '.intval($product['id_product']).'
|
||||
'.($product['id_product_attribute'] ? 'AND pa.id_product_attribute = '.intval($product['id_product_attribute']) : ''));
|
||||
/* Customization display */
|
||||
$this->displayCustomizedDatas($customizedDatas, $product, $currency, $image, $tokenCatalog, $stock);
|
||||
if ($product['cart_quantity'] > $product['customizationQuantityTotal'])
|
||||
echo '
|
||||
<tr>
|
||||
<td align="center">'.(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') : '--').'</td>
|
||||
<td><a href="index.php?tab=AdminCatalog&id_product='.$product['id_product'].'&updateproduct&token='.$tokenCatalog.'">
|
||||
<span class="productName">'.$product['name'].'</span><br />
|
||||
'.($product['reference'] ? $this->l('Ref:').' '.$product['reference'] : '')
|
||||
.(($product['reference'] AND $product['supplier_reference']) ? ' / '.$product['supplier_reference'] : '')
|
||||
.'</a></td>
|
||||
<td align="center">'.Tools::displayPrice($product['price_wt'], $currency, false, false).'</td>
|
||||
<td align="center" class="productQuantity">'.(intval($product['cart_quantity']) - $product['customizationQuantityTotal']).'</td>
|
||||
<td align="center" class="productQuantity">'.intval($stock['quantity']).'</td>
|
||||
<td align="right">'.Tools::displayPrice($product['total_wt'], $currency, false, false).'</td>
|
||||
</tr>';
|
||||
if (isset($image['id_image']))
|
||||
{
|
||||
$target = '../img/tmp/product_mini_'.intval($product['id_product']).(isset($product['id_product_attribute']) ? '_'.intval($product['id_product_attribute']) : '').'.jpg';
|
||||
if (file_exists($target))
|
||||
$products[$k]['image_size'] = getimagesize($target);
|
||||
}
|
||||
}
|
||||
echo '
|
||||
<tr class="cart_total_product">
|
||||
<td colspan="5">'.$this->l('Total products:').'</td>
|
||||
<td class="price bold right">'.Tools::displayPrice($summary['total_products_wt'], $currency, false).'</td>
|
||||
</tr>';
|
||||
if ($summary['total_discounts'] != 0)
|
||||
echo '
|
||||
<tr class="cart_total_voucher">
|
||||
<td colspan="5">'.$this->l('Total vouchers:').'</td>
|
||||
<td class="price-discount bold right">'.Tools::displayPrice($summary['total_discounts'], $currency, false).'</td>
|
||||
</tr>';
|
||||
if ($summary['total_wrapping'] > 0)
|
||||
echo '
|
||||
<tr class="cart_total_voucher">
|
||||
<td colspan="5">'.$this->l('Total gift-wrapping:').'</td>
|
||||
<td class="price-discount bold right">'.Tools::displayPrice($summary['total_wrapping'], $currency, false).'</td>
|
||||
</tr>';
|
||||
if ($cart->getOrderTotal(true, 5) > 0)
|
||||
echo '
|
||||
<tr class="cart_total_delivery">
|
||||
<td colspan="5">'.$this->l('Total shipping:').'</td>
|
||||
<td class="price bold right">'.Tools::displayPrice($cart->getOrderTotal(true, 5), $currency, false).'</td>
|
||||
</tr>';
|
||||
echo '
|
||||
<tr class="cart_total_price">
|
||||
<td colspan="5" class="bold">'.$this->l('Total:').'</td>
|
||||
<td class="price bold right">'.Tools::displayPrice($summary['total_price'], $currency, false).'</td>
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
if (sizeof($discounts))
|
||||
{
|
||||
echo '
|
||||
<table cellspacing="0" cellpadding="0" class="table" style="width:280px; margin:15px 0px 0px 420px;">
|
||||
<tr>
|
||||
<th><img src="../img/admin/coupon.gif" alt="'.$this->l('Discounts').'" />'.$this->l('Discount name').'</th>
|
||||
<th align="center" style="width: 100px">'.$this->l('Value').'</th>
|
||||
</tr>';
|
||||
|
||||
foreach ($discounts as $discount)
|
||||
echo '
|
||||
<tr>
|
||||
<td><a href="?tab=AdminDiscounts&id_discount='.$discount['id_discount'].'&updatediscount&token='.Tools::getAdminToken('AdminDiscounts'.intval(Tab::getIdFromClassName('AdminDiscounts')).intval($cookie->id_employee)).'">'.$discount['name'].'</a></td>
|
||||
<td align="center">- '.Tools::displayPrice($discount['value_real'], $currency, false).'</td>
|
||||
</tr>';
|
||||
echo '
|
||||
</table>';
|
||||
}
|
||||
echo '
|
||||
</div>';
|
||||
|
||||
// Cancel product
|
||||
echo '
|
||||
</fieldset>
|
||||
<div class="clear" style="height:20px;"> </div>';
|
||||
}
|
||||
|
||||
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 '
|
||||
<tr>
|
||||
<td align="center">'.(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') : '--').'</td>
|
||||
<td><a href="index.php?tab=AdminCatalog&id_product='.$product['id_product'].'&updateproduct&token='.$tokenCatalog.'">
|
||||
<span class="productName">'.$product['name'].'</span><br />
|
||||
'.($product['reference'] ? $this->l('Ref:').' '.$product['reference'] : '')
|
||||
.(($product['reference'] AND $product['supplier_reference']) ? ' / '.$product['supplier_reference'] : '')
|
||||
.'</a></td>
|
||||
<td align="center">'.Tools::displayPrice($product['price_wt'], $currency, false, false).'</td>
|
||||
<td align="center" class="productQuantity">'.$product['customizationQuantityTotal'].'</td>
|
||||
<td align="center" class="productQuantity">'.intval($stock['quantity']).'</td>
|
||||
<td align="right">'.Tools::displayPrice($product['total_customization_wt'], $currency, false, false).'</td>
|
||||
</tr>';
|
||||
foreach ($customizedDatas[intval($product['id_product'])][intval($product['id_product_attribute'])] AS $customization)
|
||||
{
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="2">';
|
||||
foreach ($customization['datas'] AS $type => $datas)
|
||||
if ($type == _CUSTOMIZE_FILE_)
|
||||
{
|
||||
$i = 0;
|
||||
echo '<ul style="margin: 4px 0px 4px 0px; padding: 0px; list-style-type: none;">';
|
||||
foreach ($datas AS $data)
|
||||
echo '<li style="display: inline; margin: 2px;">
|
||||
<a href="displayImage.php?img='.$data['value'].'&name='.intval($order->id).'-file'.++$i.'" target="_blank"><img src="'._THEME_PROD_PIC_DIR_.$data['value'].'_small" alt="" /></a>
|
||||
</li>';
|
||||
echo '</ul>';
|
||||
}
|
||||
elseif ($type == _CUSTOMIZE_TEXTFIELD_)
|
||||
{
|
||||
$i = 0;
|
||||
echo '<ul style="margin: 0px 0px 4px 0px; padding: 0px 0px 0px 6px; list-style-type: none;">';
|
||||
foreach ($datas AS $data)
|
||||
echo '<li>'.($data['name']).$this->l(':').' '.$data['value'].'</li>';
|
||||
echo '</ul>';
|
||||
}
|
||||
echo '</td>
|
||||
<td align="center"></td>
|
||||
<td align="center" class="productQuantity">'.$customization['quantity'].'</td>
|
||||
<td align="center" class="productQuantity"></td>
|
||||
<td align="center"></td>
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Catalog tab for admin panel, AdminCatalog.php
|
||||
* Tab has been separated in 3 files : this one, AdminCategories.php and AdminProducts.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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');
|
||||
include(PS_ADMIN_DIR.'/tabs/AdminCategories.php');
|
||||
include(PS_ADMIN_DIR.'/tabs/AdminProducts.php');
|
||||
|
||||
class AdminCatalog extends AdminTab
|
||||
{
|
||||
/** @var object AdminCategories() instance */
|
||||
private $adminCategories;
|
||||
|
||||
/** @var object AdminProducts() instance */
|
||||
private $adminProducts;
|
||||
|
||||
/** @var object AttributeGenerator() instance */
|
||||
private $attributeGenerator;
|
||||
|
||||
/** @var object AttributeGenerator() instance */
|
||||
private $imageResize;
|
||||
|
||||
/** @var object Category() instance for navigation*/
|
||||
private static $_category = NULL;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
/* Get current category */
|
||||
$id_category = abs(intval(Tools::getValue('id_category')));
|
||||
if (!$id_category) $id_category = 1;
|
||||
self::$_category = new Category($id_category);
|
||||
if (!Validate::isLoadedObject(self::$_category))
|
||||
die('Category cannot be loaded');
|
||||
|
||||
$this->table = array('category', 'product');
|
||||
$this->adminCategories = new AdminCategories();
|
||||
$this->adminProducts = new AdminProducts();
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return current category
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public static function getCurrentCategory()
|
||||
{
|
||||
return self::$_category;
|
||||
}
|
||||
|
||||
public function viewAccess($disable = false)
|
||||
{
|
||||
$result = parent::viewAccess($disable);
|
||||
$this->adminCategories->tabAccess = $this->tabAccess;
|
||||
$this->adminProducts->tabAccess = $this->tabAccess;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (!Tools::getValue('id_product'))
|
||||
$this->adminCategories->postProcess();
|
||||
elseif (isset($_GET['attributegenerator']))
|
||||
{
|
||||
if (!isset($this->attributeGenerator))
|
||||
{
|
||||
include_once(PS_ADMIN_DIR.'/tabs/AdminAttributeGenerator.php');
|
||||
$this->attributeGenerator = new AdminAttributeGenerator();
|
||||
}
|
||||
$this->attributeGenerator->postProcess();
|
||||
}
|
||||
elseif (isset($_GET['imageresize']))
|
||||
{
|
||||
if (!isset($this->imageResize))
|
||||
{
|
||||
include_once(PS_ADMIN_DIR.'/tabs/AdminImageResize.php');
|
||||
$this->imageResize = new AdminImageResize();
|
||||
}
|
||||
$this->imageResize->postProcess();
|
||||
}
|
||||
$this->adminProducts->postProcess($this->token);
|
||||
}
|
||||
|
||||
public function displayErrors()
|
||||
{
|
||||
$this->adminProducts->displayErrors();
|
||||
$this->adminCategories->displayErrors();
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if (((Tools::isSubmit('submitAddcategory') OR Tools::isSubmit('submitAddcategoryAndStay')) AND sizeof($this->adminCategories->_errors)) OR isset($_GET['updatecategory']) OR isset($_GET['addcategory']))
|
||||
{
|
||||
$this->adminCategories->displayForm($this->token);
|
||||
echo '<br /><br /><a href="'.$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to list').'</a><br />';
|
||||
}
|
||||
elseif (((Tools::isSubmit('submitAddproduct') OR Tools::isSubmit('submitAddproductAndStay')) AND sizeof($this->adminProducts->_errors)) OR Tools::isSubmit('updateproduct') OR Tools::isSubmit('addproduct'))
|
||||
{
|
||||
$this->adminProducts->displayForm($this->token);
|
||||
echo '<br /><br /><a href="index.php?tab='.Tools::getValue('tab').'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to catalog').'</a><br />';
|
||||
}
|
||||
elseif (isset($_GET['attributegenerator']))
|
||||
{
|
||||
if (!isset($this->attributeGenerator))
|
||||
{
|
||||
include_once(PS_ADMIN_DIR.'/tabs/AdminAttributeGenerator.php');
|
||||
$this->attributeGenerator = new AdminAttributeGenerator();
|
||||
}
|
||||
$this->attributeGenerator->displayForm();
|
||||
}
|
||||
elseif (isset($_GET['imageresize']))
|
||||
{
|
||||
if (!isset($this->imageResize))
|
||||
{
|
||||
include_once(PS_ADMIN_DIR.'/tabs/AdminImageResize.php');
|
||||
$this->imageResize = new AdminImageResize();
|
||||
}
|
||||
$this->imageResize->displayForm();
|
||||
}
|
||||
elseif (!isset($_GET['editImage']))
|
||||
{
|
||||
$id_category = intval(Tools::getValue('id_category'));
|
||||
if (!$id_category)
|
||||
$id_category = 1;
|
||||
$catalog_tabs = array('category', 'product');
|
||||
// Cleaning links
|
||||
$catBarIndex = $currentIndex;
|
||||
foreach ($catalog_tabs AS $tab)
|
||||
if (Tools::getValue($tab.'Orderby') && Tools::getValue($tab.'Orderway'))
|
||||
$catBarIndex = preg_replace('/&'.$tab.'Orderby=([a-z _]*)&'.$tab.'Orderway=([a-z]*)/i', '', $currentIndex);
|
||||
|
||||
echo '<div class="cat_bar"><span style="color: #3C8534;">'.$this->l('Current category').' :</span> '.getPath($catBarIndex, $id_category).'</div>';
|
||||
echo '<h2>'.$this->l('Categories').'</h2>';
|
||||
$this->adminCategories->display($this->token);
|
||||
echo '<div style="margin:10px"> </div>';
|
||||
echo '<h2>'.$this->l('Products in this category').'</h2>';
|
||||
$this->adminProducts->display($this->token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,298 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Categories class for AdminCatalog tab, AdminCategories.php
|
||||
* This file is part of a group with 2 other files : AdminCatalog.php and AdminProducts.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminCategories extends AdminTab
|
||||
{
|
||||
protected $maxImageSize = 300000;
|
||||
|
||||
/** @var object Category() instance for navigation*/
|
||||
private $_category;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$this->table = 'category';
|
||||
$this->className = 'Category';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->view = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldImageSettings = array('name' => 'image', 'dir' => 'c');
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_category' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 30),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 100, 'callback' => 'hideCategoryPosition'),
|
||||
'description' => array('title' => $this->l('Description'), 'width' => 560, 'maxlength' => 90, 'orderby' => false),
|
||||
'active' => array('title' => $this->l('Displayed'), 'active' => 'status', 'align' => 'center', 'type' => 'bool', 'orderby' => false));
|
||||
|
||||
$this->_category = AdminCatalog::getCurrentCategory();
|
||||
$this->_filter = 'AND `id_parent` = '.intval($this->_category->id);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function displayList($token = NULL)
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
/* Display list header (filtering, pagination and column names) */
|
||||
$this->displayListHeader($token);
|
||||
if (!sizeof($this->_list))
|
||||
echo '<tr><td class="center" colspan="'.(sizeof($this->fieldsDisplay) + 2).'">'.$this->l('No items found').'</td></tr>';
|
||||
|
||||
/* Show the content of the table */
|
||||
$this->displayListContent($token);
|
||||
|
||||
/* Close list table and submit button */
|
||||
$this->displayListFooter($token);
|
||||
}
|
||||
|
||||
public function display($token = NULL)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
|
||||
$this->getList(intval($cookie->id_lang), !$cookie->__get($this->table.'Orderby') ? 'name' : NULL, !$cookie->__get($this->table.'Orderway') ? 'ASC' : NULL);
|
||||
echo '<h3>'.(!$this->_listTotal ? ($this->l('There are no subcategories')) : ($this->_listTotal.' '.($this->_listTotal > 1 ? $this->l('subcategories') : $this->l('subcategory')))).' '.$this->l('in category').' "'.stripslashes(Category::hideCategoryPosition($this->_category->getName())).'"</h3>';
|
||||
echo '<a href="'.__PS_BASE_URI__.substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__)).'?tab=AdminCatalog&add'.$this->table.'&id_parent='.Tools::getValue('id_category').'&token='.($token!=NULL ? $token : $this->token).'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add a new subcategory').'</a>
|
||||
<div style="margin:10px;">';
|
||||
$this->displayList($token);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
public function postProcess($token = NULL)
|
||||
{
|
||||
global $cookie, $currentIndex;
|
||||
|
||||
$this->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id);
|
||||
|
||||
if (Tools::isSubmit('submitAdd'.$this->table))
|
||||
{
|
||||
if ($id_category = intval(Tools::getValue('id_category')))
|
||||
{
|
||||
if (!Category::checkBeforeMove($id_category, intval(Tools::getValue('id_parent'))))
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('category cannot be moved here');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Updating customer's group
|
||||
if ($this->tabAccess['edit'] !== '1')
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
else
|
||||
{
|
||||
$object = new $this->className($id_category);
|
||||
if (Validate::isLoadedObject($object))
|
||||
$object->updateGroup(Tools::getValue('groupBox'));
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('an error occurred while updating object').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Change object statuts (active, inactive) */
|
||||
elseif (isset($_GET['status']) AND Tools::getValue($this->identifier))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (Validate::isLoadedObject($object = $this->loadObject()))
|
||||
{
|
||||
if ($object->toggleStatus())
|
||||
Tools::redirectAdmin($currentIndex.'&conf=5'.((($id_category = intval(Tools::getValue('id_category'))) AND Tools::getValue('id_product')) ? '&id_category='.$id_category : '').'&token='.Tools::getValue('token'));
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('an error occurred while updating status');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('an error occurred while updating status for object').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
/* Delete object */
|
||||
elseif (isset($_GET['delete'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
if (Validate::isLoadedObject($object = $this->loadObject()) AND isset($this->fieldImageSettings))
|
||||
{
|
||||
// check if request at least one object with noZeroObject
|
||||
if (isset($object->noZeroObject) AND sizeof($taxes = call_user_func(array($this->className, $object->noZeroObject))) <= 1)
|
||||
$this->_errors[] = Tools::displayError('you need at least one object').' <b>'.$this->table.'</b>'.Tools::displayError(', you cannot delete all of them');
|
||||
else
|
||||
{
|
||||
$this->deleteImage($object->id);
|
||||
if ($this->deleted)
|
||||
{
|
||||
$object->deleted = 1;
|
||||
if ($object->update())
|
||||
Tools::redirectAdmin($currentIndex.'&conf=1&token='.Tools::getValue('token'));
|
||||
}
|
||||
elseif ($object->delete())
|
||||
Tools::redirectAdmin($currentIndex.'&conf=1&token='.Tools::getValue('token'));
|
||||
$this->_errors[] = Tools::displayError('an error occurred during deletion');
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('an error occurred while deleting object').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
protected function postImage($id)
|
||||
{
|
||||
$ret = parent::postImage($id);
|
||||
if (($id_category = intval(Tools::getValue('id_category'))) AND isset($_FILES) AND sizeof($_FILES) AND file_exists(_PS_CAT_IMG_DIR_.$id_category.'.jpg'))
|
||||
{
|
||||
$imagesTypes = ImageType::getImagesTypes('categories');
|
||||
foreach ($imagesTypes AS $k => $imageType)
|
||||
imageResize(_PS_CAT_IMG_DIR_.$id_category.'.jpg', _PS_CAT_IMG_DIR_.$id_category.'-'.stripslashes($imageType['name']).'.jpg', intval($imageType['width']), intval($imageType['height']));
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function displayForm($token=NULL)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
$active = $this->getFieldValue($obj, 'active');
|
||||
$customer_groups = $obj->getGroups();
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.($token!=NULL ? $token : $this->token).'" method="post" enctype="multipart/form-data">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset class="width2" style="width:520px;"><legend><img src="../img/admin/tab-categories.gif" />'.$this->l('Category').'</legend>
|
||||
<label>'.$this->l('Name:').' </label>
|
||||
<div class="margin-form translatable">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input type="text" style="width: 260px" name="name_'.$language['id_lang'].'" id="name_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" '.((!$obj->id) ? ' onkeyup="copy2friendlyURL();"' : '').' /><sup> *</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
echo ' <p class="clear"></p>
|
||||
</div>
|
||||
<label>'.$this->l('Displayed:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="active" id="active_on" value="1" '.($active ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_on"><img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="active" id="active_off" value="0" '.(!$active ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_off"><img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
</div>
|
||||
<label>'.$this->l('Parent category:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name="id_parent">';
|
||||
$categories = Category::getCategories(intval($cookie->id_lang), false);
|
||||
Category::recurseCategory($categories, $categories[0][1], 1, $this->getFieldValue($obj, 'id_parent'));
|
||||
echo '
|
||||
</select>
|
||||
</div>
|
||||
<label>'.$this->l('Description:').' </label>
|
||||
<div class="margin-form translatable">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<textarea name="description_'.$language['id_lang'].'" rows="5" cols="40">'.htmlentities($this->getFieldValue($obj, 'description', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
|
||||
</div>';
|
||||
echo ' <p class="clear"></p>
|
||||
</div>
|
||||
<label>'.$this->l('Image:').' </label>
|
||||
<div class="margin-form">';
|
||||
echo $this->displayImage($obj->id, _PS_IMG_DIR_.'c/'.$obj->id.'.jpg', 350, NULL, Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)));
|
||||
echo ' <br /><input type="file" name="image" />
|
||||
<p>'.$this->l('Upload category logo from your computer').'</p>
|
||||
</div>
|
||||
<div class="clear"><br /></div>
|
||||
<label>'.$this->l('Meta title:').' </label>
|
||||
<div class="margin-form translatable">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input type="text" name="meta_title_'.$language['id_lang'].'" id="meta_title_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'meta_title', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
|
||||
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
echo ' <p class="clear"></p>
|
||||
</div>
|
||||
<label>'.$this->l('Meta description:').' </label>
|
||||
<div class="margin-form translatable">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '<div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input type="text" name="meta_description_'.$language['id_lang'].'" id="meta_description_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'meta_description', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
|
||||
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
echo ' <p class="clear"></p>
|
||||
</div>
|
||||
<label>'.$this->l('Meta keywords:').' </label>
|
||||
<div class="margin-form translatable">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input type="text" name="meta_keywords_'.$language['id_lang'].'" id="meta_keywords_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'meta_keywords', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
|
||||
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
echo ' <p class="clear"></p>
|
||||
</div>
|
||||
<label>'.$this->l('Friendly URL:').' </label>
|
||||
<div class="margin-form translatable">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '<div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input type="text" name="link_rewrite_'.$language['id_lang'].'" id="link_rewrite_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'link_rewrite', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" onkeyup="this.value = str2url(this.value);" /><sup> *</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Only letters and the minus (-) character are allowed').'<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
echo ' <p class="clear"></p>
|
||||
</div>
|
||||
<label>'.$this->l('Groups access:').' </label>
|
||||
<div class="margin-form">';
|
||||
$groups = Group::getGroups(intval($cookie->id_lang));
|
||||
if (sizeof($groups))
|
||||
{
|
||||
echo '
|
||||
<table cellspacing="0" cellpadding="0" class="table" style="width: 28em;">
|
||||
<tr>
|
||||
<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'groupBox[]\', this.checked)"'.(!isset($obj->id) ? 'checked="checked" ' : '').' /></th>
|
||||
<th>'.$this->l('ID').'</th>
|
||||
<th>'.$this->l('Group name').'</th>
|
||||
</tr>';
|
||||
$irow = 0;
|
||||
foreach ($groups as $group)
|
||||
echo '
|
||||
<tr class="'.($irow++ % 2 ? 'alt_row' : '').'">
|
||||
<td><input type="checkbox" name="groupBox[]" class="groupBox" id="groupBox_'.$group['id_group'].'" value="'.$group['id_group'].'" '.((in_array($group['id_group'], $customer_groups) OR (!isset($obj->id))) ? 'checked="checked" ' : '').'/></td>
|
||||
<td>'.$group['id_group'].'</td>
|
||||
<td><label for="groupBox_'.$group['id_group'].'" class="t">'.$group['name'].'</label></td>
|
||||
</tr>';
|
||||
echo '
|
||||
</table>
|
||||
<p style="padding:0px; margin:10px 0px 10px 0px;">'.$this->l('Mark all groups you want to give access to this category').'</p>
|
||||
';
|
||||
} else
|
||||
echo '<p>'.$this->l('No group created').'</p>';
|
||||
echo '
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l('Save and back to parent category').'" name="submitAdd'.$this->table.'AndBackToParent" class="button" />
|
||||
<input type="submit" class="button" name="submitAdd'.$this->table.'" value="'.$this->l('Save').'"/>
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
<p class="clear"></p>';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Database tab for admin panel, AdminDb.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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');
|
||||
include_once(PS_ADMIN_DIR.'/tabs/AdminPreferences.php');
|
||||
|
||||
class AdminContact extends AdminPreferences
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->className = 'Configuration';
|
||||
$this->table = 'configuration';
|
||||
|
||||
$this->_fieldsShop = array(
|
||||
'PS_SHOP_NAME' => array('title' => $this->l('Shop name:'), 'desc' => $this->l('Displayed in e-mails and page titles'), 'validation' => 'isGenericName', 'required' => true, 'size' => 30, 'type' => 'text'),
|
||||
'PS_SHOP_EMAIL' => array('title' => $this->l('Shop e-mail:'), 'desc' => $this->l('Displayed in e-mails sent to customers'), 'validation' => 'isEmail', 'required' => true, 'size' => 30, 'type' => 'text'),
|
||||
'PS_SHOP_DETAILS' => array('title' => $this->l('Registration:'), 'desc' => $this->l('Shop registration information (e.g., SIRET or RCS)'), 'validation' => 'isGenericName', 'size' => 30, 'type' => 'textarea', 'cols' => 30, 'rows' => 5),
|
||||
'PS_SHOP_ADDR1' => array('title' => $this->l('Shop address:'), 'validation' => 'isGenericName', 'size' => 30, 'type' => 'text'),
|
||||
'PS_SHOP_ADDR2' => array('title' => '', 'validation' => 'isGenericName', 'size' => 30, 'type' => 'text'),
|
||||
'PS_SHOP_CODE' => array('title' => $this->l('Post/Zip code:'), 'validation' => 'isGenericName', 'size' => 6, 'type' => 'text'),
|
||||
'PS_SHOP_CITY' => array('title' => $this->l('City:'), 'validation' => 'isGenericName', 'size' => 30, 'type' => 'text'),
|
||||
'PS_SHOP_STATE' => array('title' => $this->l('State (if applicable):'), 'validation' => 'isGenericName', 'size' => 30, 'type' => 'text'),
|
||||
'PS_SHOP_COUNTRY' => array('title' => $this->l('Country:'), 'validation' => 'isGenericName', 'size' => 30, 'type' => 'text'),
|
||||
'PS_SHOP_PHONE' => array('title' => $this->l('Phone:'), 'validation' => 'isGenericName', 'size' => 30, 'type' => 'text'),
|
||||
'PS_SHOP_FAX' => array('title' => $this->l('Fax:'), 'validation' => 'isGenericName', 'size' => 30, 'type' => 'text'),
|
||||
);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$this->_displayForm('shop', $this->_fieldsShop, $this->l('Contact details'), 'width2', 'tab-contact');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Contacts tab for admin panel, AdminContacts.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminContacts extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'contact';
|
||||
$this->className = 'Contact';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_contact' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Title'), 'width' => 130),
|
||||
'email' => array('title' => $this->l('E-mail address'), 'width' => 130),
|
||||
'description' => array('title' => $this->l('Description'), 'width' => 150));
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" class="width3">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/admin/contact.gif" />'.$this->l('Contacts').'</legend>
|
||||
<label>'.$this->l('Title:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="name_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="33" type="text" name="name_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name¤description', 'name');
|
||||
echo ' <p style="clear: both">'.$this->l('Contact name, e.g., Technical Support').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('E-mail address:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="email" value="'.htmlentities($this->getFieldValue($obj, 'email'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<p style="clear: both">'.$this->l('E-mails will be sent to this address').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Description:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="description_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<textarea name="description_'.$language['id_lang'].'" cols="36" rows="5">'.htmlentities($this->getFieldValue($obj, 'description', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name¤description', 'description');
|
||||
echo '
|
||||
<p style="clear: both">'.$this->l('Additional information about this contact').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Countries tab for admin panel, AdminCountries.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminCountries extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$this->table = 'country';
|
||||
$this->className = 'Country';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->deleted = false;
|
||||
$this->_select = 'z.`name` AS zone';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = a.`id_zone`)';
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_country' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Country'), 'width' => 130, 'filter_key' => 'b!name'),
|
||||
'iso_code' => array('title' => $this->l('ISO code'), 'width' => 70, 'align' => 'center'),
|
||||
'zone' => array('title' => $this->l('Zone'), 'width' => 100, 'filter_key' => 'z!name'),
|
||||
'a!active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'a!active'));
|
||||
|
||||
$this->optionTitle = $this->l('Countries options');
|
||||
$this->_fieldsOptions = array(
|
||||
'PS_COUNTRY_DEFAULT' => array('title' => $this->l('Default country:'), 'desc' => $this->l('The default country used in shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_country', 'list' => Country::getCountries(intval($cookie->id_lang))),
|
||||
);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (isset($_GET['delete'.$this->table]) OR Tools::getValue('submitDel'.$this->table))
|
||||
$this->_errors[] = Tools::displayError('You cannot delete a country. If you do not want it available for customers, please disable it.');
|
||||
else
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset class="width3"><legend><img src="../img/admin/world.gif" />'.$this->l('Countries').'</legend>
|
||||
<label>'.$this->l('Country:').' </label>
|
||||
<div class="margin-form">';
|
||||
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="name_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="30" type="text" name="name_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name');
|
||||
|
||||
echo ' <p style="clear: both">'.$this->l('Name of country').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('ISO code:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="4" maxlength="3" name="iso_code" value="'.htmlentities($this->getFieldValue($obj, 'iso_code'), ENT_COMPAT, 'UTF-8').'" style="text-transform: uppercase;" /> <sup>*</sup>
|
||||
<p>'.$this->l('2- or 3-letter ISO code, e.g., FR for France').'. <a href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html" target="_blank">'.$this->l('Official list here').'</a>.</p>
|
||||
</div>
|
||||
<label>'.$this->l('Zone:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name="id_zone">';
|
||||
|
||||
$zones = Zone::getZones();
|
||||
foreach ($zones AS $zone)
|
||||
echo '<option value="'.intval($zone['id_zone']).'"'.(($this->getFieldValue($obj, 'id_zone') == $zone['id_zone']) ? ' selected="selected"' : '').'>'.$zone['name'].'</option>';
|
||||
|
||||
echo '
|
||||
</select>
|
||||
<p>'.$this->l('Geographical zone where country is located').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Status:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="active" id="active_on" value="1" '.((!$obj->id OR $this->getFieldValue($obj, 'active')) ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="active" id="active_off" value="0" '.((!$this->getFieldValue($obj, 'active') AND $obj->id) ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('Enabled or disabled').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Contains states:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="contains_states" id="contains_states_on" value="1" '.((!$obj->id OR $this->getFieldValue($obj, 'contains_states')) ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="contains_states_on"> <img src="../img/admin/enabled.gif" alt="" title="" />'.$this->l('Yes').'</label>
|
||||
<input type="radio" name="contains_states" id="contains_states_off" value="0" '.((!$this->getFieldValue($obj, 'contains_states') AND $obj->id) ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="contains_states_off"> <img src="../img/admin/disabled.gif" alt="" title="" />'.$this->l('No').'</label>
|
||||
</div>
|
||||
<label>'.$this->l('Need tax identification number?').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="need_identification_number" id="need_identification_number_on" value="1" '.((!$obj->id OR $this->getFieldValue($obj, 'need_identification_number')) ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="need_identification_number_on"> <img src="../img/admin/enabled.gif" alt="" title="" />'.$this->l('Yes').'</label>
|
||||
<input type="radio" name="need_identification_number" id="need_identification_number_off" value="0" '.((!$this->getFieldValue($obj, 'need_identification_number') AND $obj->id) ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="need_identification_number_off"> <img src="../img/admin/disabled.gif" alt="" title="" />'.$this->l('No').'</label>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,181 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Currencies tab for admin panel, AdminCurrencies.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminCurrencies extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'currency';
|
||||
$this->className = 'Currency';
|
||||
$this->lang = false;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_currency' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Currency'), 'width' => 100),
|
||||
'iso_code' => array('title' => $this->l('ISO code'), 'align' => 'center', 'width' => 35),
|
||||
'sign' => array('title' => $this->l('Symbol'), 'width' => 20, 'align' => 'center', 'orderby' => false, 'search' => false),
|
||||
'conversion_rate' => array('title' => $this->l('Conversion rate'), 'float' => true, 'align' => 'center', 'width' => 50, 'search' => false));
|
||||
|
||||
$this->optionTitle = $this->l('Currencies options');
|
||||
$this->_fieldsOptions = array(
|
||||
'PS_CURRENCY_DEFAULT' => array('title' => $this->l('Default currency:'), 'desc' => $this->l('The default currency used in shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_currency', 'list' => Currency::getCurrencies()),
|
||||
);
|
||||
$this->_where = 'AND a.`deleted` = 0';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if (isset($_GET['delete'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
if (Validate::isLoadedObject($object = $this->loadObject()))
|
||||
{
|
||||
if ($object->id == Configuration::get('PS_CURRENCY_DEFAULT'))
|
||||
$this->_errors[] = $this->l('You can\'t delete the default currency');
|
||||
elseif ($object->delete())
|
||||
Tools::redirectAdmin($currentIndex.'&conf=1'.'&token='.$this->token);
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('an error occurred during deletion');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('an error occurred while deleting object').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
elseif (Tools::getValue('submitOptions'.$this->table))
|
||||
{
|
||||
foreach ($this->_fieldsOptions as $key => $field)
|
||||
{
|
||||
Configuration::updateValue($key, $field['cast'](Tools::getValue($key)));
|
||||
if ($key == 'PS_CURRENCY_DEFAULT')
|
||||
{
|
||||
$currency = new Currency($field['cast'](Tools::getValue($key)));
|
||||
$currency->conversion_rate = 1;
|
||||
$currency->update();
|
||||
}
|
||||
}
|
||||
Tools::redirectAdmin($currentIndex.'&conf=6'.'&token='.$this->token);
|
||||
}
|
||||
elseif (Tools::isSubmit('submitExchangesRates'))
|
||||
{
|
||||
if (!$this->_errors[] = Currency::refreshCurrencies())
|
||||
Tools::redirectAdmin($currentIndex.'&conf=6'.'&token='.$this->token);
|
||||
}
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
public function displayOptionsList()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
parent::displayOptionsList();
|
||||
echo '<br /><br />
|
||||
<form action="'.$currentIndex.'&token='.$this->token.'" method="post" class="width3">
|
||||
<fieldset>
|
||||
<legend><img src="../img/admin/exchangesrate.gif" />'.$this->l('Currency rates').'</legend>
|
||||
<label>'.$this->l('Update currencies rates:').'</label>
|
||||
<div class="margin-form">
|
||||
<p>'.$this->l('Update your currencies exchanges rates with a real-time tool').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l('Update currencies rates').'" name="submitExchangesRates" class="button" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" class="width3">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/admin/money.gif" />'.$this->l('Currencies').'</legend>
|
||||
<label>'.$this->l('Currency:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="30" maxlength="32" name="name" value="'.htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Only letters and the minus character are allowed').'<span class="hint-pointer"> </span></span>
|
||||
<p class="clear">'.$this->l('Will appear on Front Office, e.g., euro, dollar').'...</p>
|
||||
</div>
|
||||
<label>'.$this->l('ISO code:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="30" maxlength="32" name="iso_code" value="'.htmlentities($this->getFieldValue($obj, 'iso_code'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<span class="hint-pointer"> </span>
|
||||
<p class="clear">'.$this->l('ISO code, e.g., USD for dollar, EUR for euro').'...</p>
|
||||
</div>
|
||||
<label>'.$this->l('Symbol:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="3" maxlength="8" name="sign" value="'.htmlentities($this->getFieldValue($obj, 'sign'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Will appear on Front Office, e.g., €, $').'...</p>
|
||||
</div>
|
||||
<label>'.$this->l('Conversion rate:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="3" maxlength="11" name="conversion_rate" value="'.htmlentities($this->getFieldValue($obj, 'conversion_rate')).'" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Conversion rate from one unit of your shop\'s default currency (for example, 1€) to this currency. For example, if the default currency is euros and this currency is dollars, type \'1.52\'').' 1€ = $1.38</p>
|
||||
</div>
|
||||
<label>'.$this->l('Formatting:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name="format">';
|
||||
$currency_formats = array(
|
||||
1 => 'X0,000.00 ('.$this->l('as with dollars').')',
|
||||
2 => '0 000,00X ('.$this->l('as with euros').')',
|
||||
3 => 'X0.000,00',
|
||||
4 => '0,000.00X',
|
||||
);
|
||||
foreach ($currency_formats AS $nb => $desc)
|
||||
echo '<option value="'.$nb.'"'.($this->getFieldValue($obj, 'format') == $nb ? 'selected="selected"' : '').'>'.$desc.'</option>';
|
||||
echo '
|
||||
</select>
|
||||
<p class="clear">'.$this->l('Applies to all prices, e.g.,').' $1,240.15</p>
|
||||
</div>
|
||||
<label>'.$this->l('Decimals:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="decimals" id="decimals_on" value="1" '.($this->getFieldValue($obj, 'decimals') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="decimals_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Yes').'" title="'.$this->l('Yes').'" /></label>
|
||||
<input type="radio" name="decimals" id="decimals_off" value="0" '.(!$this->getFieldValue($obj, 'decimals') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="decimals_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('No').'" title="'.$this->l('No').'" /></label>
|
||||
<p>'.$this->l('Display decimals on prices').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Blank:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="blank" id="blank_on" value="1" '.($this->getFieldValue($obj, 'blank') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="blank_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="blank" id="blank_off" value="0" '.(!$this->getFieldValue($obj, 'blank') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="blank_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('Include a blank between sign and price, e.g.,').'<br />$1,240.15 -> $ 1,240.15</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,587 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Customers tab for admin panel, AdminContacts.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminCustomers extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'customer';
|
||||
$this->className = 'Customer';
|
||||
$this->lang = false;
|
||||
$this->edit = true;
|
||||
$this->view = true;
|
||||
$this->delete = true;
|
||||
$this->deleted = true;
|
||||
|
||||
$this->_select = '(YEAR(CURRENT_DATE)-YEAR(`birthday`)) - (RIGHT(CURRENT_DATE, 5)<RIGHT(`birthday`, 5)) as age, (
|
||||
SELECT c.date_add FROM '._DB_PREFIX_.'guest g
|
||||
LEFT JOIN '._DB_PREFIX_.'connections c ON c.id_guest = g.id_guest
|
||||
WHERE g.id_customer = a.id_customer
|
||||
ORDER BY c.date_add DESC
|
||||
LIMIT 1
|
||||
) as connect';
|
||||
$genders = array(1 => $this->l('M'), 2 => $this->l('F'), 9 => $this->l('?'));
|
||||
$this->fieldsDisplay = array(
|
||||
'id_customer' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'id_gender' => array('title' => $this->l('Gender'), 'width' => 25, 'align' => 'center', 'icon' => array(1 => 'male.gif', 2 => 'female.gif', 'default' => 'unknown.gif'), 'orderby' => false, 'type' => 'select', 'select' => $genders, 'filter_key' => 'a!id_gender'),
|
||||
'lastname' => array('title' => $this->l('Last Name'), 'width' => 80),
|
||||
'firstname' => array('title' => $this->l('First name'), 'width' => 60),
|
||||
'email' => array('title' => $this->l('E-mail address'), 'width' => 120, 'maxlength' => 19),
|
||||
'age' => array('title' => $this->l('Age'), 'width' => 30, 'search' => false),
|
||||
'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false),
|
||||
'newsletter' => array('title' => $this->l('News.'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'icon' => array(0 => 'disabled.gif', 1 => 'enabled.gif'), 'orderby' => false),
|
||||
'optin' => array('title' => $this->l('Opt.'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'icon' => array(0 => 'disabled.gif', 1 => 'enabled.gif'), 'orderby' => false),
|
||||
'date_add' => array('title' => $this->l('Registration'), 'width' => 60, 'type' => 'date'),
|
||||
'connect' => array('title' => $this->l('Connection'), 'width' => 60, 'type' => 'datetime', 'search' => false));
|
||||
|
||||
$this->optionTitle = $this->l('Customers options');
|
||||
$this->_fieldsOptions = array(
|
||||
'PS_PASSWD_TIME_FRONT' => array('title' => $this->l('Password regenerate:'), 'desc' => $this->l('Security minimum time to wait for regenerate a new password'), 'cast' => 'intval', 'size' => 5, 'type' => 'text', 'suffix' => ' '.$this->l('minutes'))
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if (Tools::getValue('submitAdd'.$this->table))
|
||||
{
|
||||
$groupList = Tools::getValue('groupBox');
|
||||
|
||||
/* Checking fields validity */
|
||||
$this->validateRules();
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
$id = intval(Tools::getValue('id_'.$this->table));
|
||||
if (isset($id) AND !empty($id))
|
||||
{
|
||||
if ($this->tabAccess['edit'] !== '1')
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
else
|
||||
{
|
||||
$object = new $this->className($id);
|
||||
if (Validate::isLoadedObject($object))
|
||||
{
|
||||
$customer_email = strval(Tools::getValue('email'));
|
||||
|
||||
// check if e-mail already used
|
||||
if ($customer_email != $object->email)
|
||||
{
|
||||
$customer = new Customer();
|
||||
$customer->getByEmail($customer_email);
|
||||
if ($customer->id)
|
||||
$this->_errors[] = Tools::displayError('an account already exists for this e-mail address:').' '.$customer_email;
|
||||
}
|
||||
|
||||
if ($object->getNeedDNI() AND Tools::getValue('dni') != NULL AND !Validate::isDni(Tools::getValue('dni')))
|
||||
$this->_errors[] = Tools::displayError('identification number is incorrect or already used');
|
||||
|
||||
if (!is_array($groupList) OR sizeof($groupList) == 0)
|
||||
$this->_errors[] = Tools::displayError('customer must be in at least one group');
|
||||
else
|
||||
if (!in_array(Tools::getValue('id_default_group'), $groupList))
|
||||
$this->_errors[] = Tools::displayError('default customer group must be selected on group box');
|
||||
|
||||
// Updating customer's group
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
$object->cleanGroups();
|
||||
if (is_array($groupList) AND sizeof($groupList) > 0)
|
||||
$object->addGroups($groupList);
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('an error occurred while loading object').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->tabAccess['add'] === '1')
|
||||
{
|
||||
$object = new $this->className();
|
||||
$this->copyFromPost($object, $this->table);
|
||||
if (!$object->add())
|
||||
$this->_errors[] = Tools::displayError('an error occurred while creating object').' <b>'.$this->table.' ('.mysql_error().')</b>';
|
||||
elseif (($_POST[$this->identifier] = $object->id /* voluntary */) AND $this->postImage($object->id) AND !sizeof($this->_errors) AND $this->_redirect)
|
||||
{
|
||||
// Add Associated groups
|
||||
$group_list = Tools::getValue('groupBox');
|
||||
if (is_array($group_list) && sizeof($group_list) > 0)
|
||||
$object->addGroups($group_list);
|
||||
$parent_id = intval(Tools::getValue('id_parent', 1));
|
||||
// Save and stay on same form
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
|
||||
Tools::redirectAdmin($currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=3&update'.$this->table.'&token='.$this->token);
|
||||
// Save and back to parent
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndBackToParent'))
|
||||
Tools::redirectAdmin($currentIndex.'&'.$this->identifier.'='.$parent_id.'&conf=3&token='.$this->token);
|
||||
// Default behavior (save and back)
|
||||
Tools::redirectAdmin($currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=3&token='.$this->token);
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to add anything here.');
|
||||
}
|
||||
}
|
||||
}
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
public function viewcustomer()
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
|
||||
$irow = 0;
|
||||
$configurations = Configuration::getMultiple(array('PS_LANG_DEFAULT', 'PS_CURRENCY_DEFAULT'));
|
||||
$defaultLanguage = intval($configurations['PS_LANG_DEFAULT']);
|
||||
$defaultCurrency = intval($configurations['PS_CURRENCY_DEFAULT']);
|
||||
$customer = $this->loadObject();
|
||||
$customerStats = $customer->getStats();
|
||||
$addresses = $customer->getAddresses($defaultLanguage);
|
||||
$products = $customer->getBoughtProducts();
|
||||
$discounts = Discount::getCustomerDiscounts($defaultLanguage, $customer->id, false, false);
|
||||
$orders = Order::getCustomerOrders($customer->id);
|
||||
$carts = Cart::getCustomerCarts($customer->id);
|
||||
$groups = $customer->getGroups();
|
||||
$referrers = Referrer::getReferrers($customer->id);
|
||||
|
||||
echo '
|
||||
<div style="float: left">
|
||||
<fieldset style="width: 400px"><div style="float: right"><a href="'.$currentIndex.'&addcustomer&id_customer='.$customer->id.'&token='.$this->token.'"><img src="../img/admin/edit.gif" /></a></div>
|
||||
<span style="font-weight: bold; font-size: 14px;">'.$customer->firstname.' '.$customer->lastname.'</span>
|
||||
<img src="../img/admin/'.($customer->id_gender == 2 ? 'female' : ($customer->id_gender == 1 ? 'male' : 'unknown')).'.gif" style="margin-bottom: 5px" /><br />
|
||||
<a href="mailto:'.$customer->email.'" style="text-decoration: underline; color: blue">'.$customer->email.'</a><br /><br />
|
||||
'.$this->l('ID:').' '.sprintf('%06d', $customer->id).($customer->dni != NULL ? ' | '.$this->l('DNI:').' '.$customer->dni : '').'<br />
|
||||
'.$this->l('Registration date:').' '.Tools::displayDate($customer->date_add, intval($cookie->id_lang), true).'<br />
|
||||
'.$this->l('Last visit:').' '.($customerStats['last_visit'] ? Tools::displayDate($customerStats['last_visit'], intval($cookie->id_lang), true) : $this->l('never')).'
|
||||
</fieldset>
|
||||
</div>
|
||||
<div style="float: left; margin-left: 50px">
|
||||
<fieldset style="width: 300px"><div style="float: right"><a href="'.$currentIndex.'&addcustomer&id_customer='.$customer->id.'&token='.$this->token.'"><img src="../img/admin/edit.gif" /></a></div>
|
||||
'.$this->l('Newsletter:').' '.($customer->newsletter ? '<img src="../img/admin/enabled.gif" />' : '<img src="../img/admin/disabled.gif" />').'<br />
|
||||
'.$this->l('Opt-in:').' '.($customer->optin ? '<img src="../img/admin/enabled.gif" />' : '<img src="../img/admin/disabled.gif" />').'<br />
|
||||
'.$this->l('Age:').' '.$customerStats['age'].' '.((!empty($customer->birthday['age'])) ? '('.Tools::displayDate($customer->birthday, intval($cookie->id_lang)).')' : $this->l('unknown')).'<br /><br />
|
||||
'.$this->l('Last update:').' '.Tools::displayDate($customer->date_upd, intval($cookie->id_lang), true).'<br />
|
||||
'.$this->l('Status:').' '.($customer->active ? '<img src="../img/admin/enabled.gif" />' : '<img src="../img/admin/disabled.gif" />').'
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="clear"> </div>';
|
||||
|
||||
// display hook specified to this page : AdminCustomers
|
||||
if (($hook = Module::hookExec('adminCustomers', array('id_customer' => $customer->id))) !== false)
|
||||
echo '<div>'.$hook.'</div>';
|
||||
|
||||
echo '<h2>'.$this->l('Groups').' ('.sizeof($groups).')</h2>';
|
||||
if ($groups AND sizeof($groups))
|
||||
{
|
||||
echo '
|
||||
<table cellspacing="0" cellpadding="0" class="table">
|
||||
<tr>
|
||||
<th class="center">'.$this->l('ID').'</th>
|
||||
<th class="center">'.$this->l('Name').'</th>
|
||||
<th class="center">'.$this->l('Actions').'</th>
|
||||
</tr>';
|
||||
$tokenGroups = Tools::getAdminToken('AdminGroups'.intval(Tab::getIdFromClassName('AdminGroups')).intval($cookie->id_employee));
|
||||
foreach ($groups AS $group)
|
||||
{
|
||||
$objGroup = new Group($group);
|
||||
echo '
|
||||
<tr '.($irow++ % 2 ? 'class="alt_row"' : '').' style="cursor: pointer" onclick="document.location = \'?tab=AdminGroups&id_group='.$objGroup->id.'&viewgroup&token='.$tokenGroups.'\'">
|
||||
<td class="center">'.$objGroup->id.'</td>
|
||||
<td>'.$objGroup->name[$defaultLanguage].'</td>
|
||||
<td align="center"><a href="?tab=AdminGroups&id_group='.$objGroup->id.'&viewgroup&token='.$tokenGroups.'"><img src="../img/admin/details.gif" /></a></td>
|
||||
</tr>';
|
||||
}
|
||||
echo '
|
||||
</table>';
|
||||
}
|
||||
echo '<div class="clear"> </div>';
|
||||
echo '<h2>'.$this->l('Orders').' ('.sizeof($orders).')</h2>';
|
||||
if ($orders AND sizeof($orders))
|
||||
{
|
||||
echo '
|
||||
<table cellspacing="0" cellpadding="0" class="table">
|
||||
<tr>
|
||||
<th class="center">'.$this->l('ID').'</th>
|
||||
<th class="center">'.$this->l('Date').'</th>
|
||||
<th class="center">'.$this->l('Quantity').'</th>
|
||||
<th class="center">'.$this->l('Total').'</th>
|
||||
<th class="center">'.$this->l('Payment').'</th>
|
||||
<th class="center">'.$this->l('State').'</th>
|
||||
<th class="center">'.$this->l('Actions').'</th>
|
||||
</tr>';
|
||||
$tokenOrders = Tools::getAdminToken('AdminOrders'.intval(Tab::getIdFromClassName('AdminOrders')).intval($cookie->id_employee));
|
||||
foreach ($orders AS $order)
|
||||
echo '
|
||||
<tr '.($irow++ % 2 ? 'class="alt_row"' : '').' style="cursor: pointer" onclick="document.location = \'?tab=AdminOrders&id_order='.$order['id_order'].'&vieworder&token='.$tokenOrders.'\'">
|
||||
<td class="center">'.sprintf('%06d', $order['id_order']).'</td>
|
||||
<td>'.Tools::displayDate($order['date_add'], intval($cookie->id_lang), true).'</td>
|
||||
<td align="right">'.$order['nb_products'].'</td>
|
||||
<td align="right">'.Tools::displayPrice($order['total_paid'], new Currency(intval($order['id_currency']))).'</td>
|
||||
<td>'.$order['payment'].'</td>
|
||||
<td>'.$order['order_state'].'</td>
|
||||
<td align="center"><a href="?tab=AdminOrders&id_order='.$order['id_order'].'&vieworder&token='.$tokenOrders.'"><img src="../img/admin/details.gif" /></a></td>
|
||||
</tr>';
|
||||
echo '
|
||||
</table>';
|
||||
}
|
||||
else
|
||||
echo $customer->firstname.' '.$customer->lastname.' '.$this->l('has placed no orders yet');
|
||||
if ($products AND sizeof($products))
|
||||
{
|
||||
echo '<div class="clear"> </div>
|
||||
<h2>'.$this->l('Products').' ('.sizeof($products).')</h2>
|
||||
<table cellspacing="0" cellpadding="0" class="table">
|
||||
<tr>
|
||||
<th class="center">'.$this->l('Date').'</th>
|
||||
<th class="center">'.$this->l('Name').'</th>
|
||||
<th class="center">'.$this->l('Quantity').'</th>
|
||||
<th class="center">'.$this->l('Actions').'</th>
|
||||
</tr>';
|
||||
$tokenOrders = Tools::getAdminToken('AdminOrders'.intval(Tab::getIdFromClassName('AdminOrders')).intval($cookie->id_employee));
|
||||
foreach ($products AS $product)
|
||||
echo '
|
||||
<tr '.($irow++ % 2 ? 'class="alt_row"' : '').' style="cursor: pointer" onclick="document.location = \'?tab=AdminOrders&id_order='.$product['id_order'].'&vieworder&token='.$tokenOrders.'\'">
|
||||
<td>'.Tools::displayDate($product['date_add'], intval($cookie->id_lang), true).'</td>
|
||||
<td>'.$product['product_name'].'</td>
|
||||
<td align="right">'.$product['product_quantity'].'</td>
|
||||
<td align="center"><a href="?tab=AdminOrders&id_order='.$product['id_order'].'&vieworder&token='.$tokenOrders.'"><img src="../img/admin/details.gif" /></a></td>
|
||||
</tr>';
|
||||
echo '
|
||||
</table>';
|
||||
}
|
||||
echo '<div class="clear"> </div>
|
||||
<h2>'.$this->l('Addresses').' ('.sizeof($addresses).')</h2>';
|
||||
if (sizeof($addresses))
|
||||
{
|
||||
echo '
|
||||
<table cellspacing="0" cellpadding="0" class="table">
|
||||
<tr>
|
||||
<th>'.$this->l('Company').'</th>
|
||||
<th>'.$this->l('Name').'</th>
|
||||
<th>'.$this->l('Address').'</th>
|
||||
<th>'.$this->l('Country').'</th>
|
||||
<th>'.$this->l('Phone number(s)').'</th>
|
||||
<th>'.$this->l('Actions').'</th>
|
||||
</tr>';
|
||||
$tokenAddresses = Tools::getAdminToken('AdminAddresses'.intval(Tab::getIdFromClassName('AdminAddresses')).intval($cookie->id_employee));
|
||||
foreach ($addresses AS $address)
|
||||
echo '
|
||||
<tr '.($irow++ % 2 ? 'class="alt_row"' : '').'>
|
||||
<td>'.($address['company'] ? $address['company'] : '--').'</td>
|
||||
<td>'.$address['firstname'].' '.$address['lastname'].'</td>
|
||||
<td>'.$address['address1'].($address['address2'] ? ' '.$address['address2'] : '').' '.$address['postcode'].' '.$address['city'].'</td>
|
||||
<td>'.$address['country'].'</td>
|
||||
<td>'.($address['phone'] ? ($address['phone'].($address['phone_mobile'] ? '<br />'.$address['phone_mobile'] : '')) : ($address['phone_mobile'] ? '<br />'.$address['phone_mobile'] : '--')).'</td>
|
||||
<td align="center">
|
||||
<a href="?tab=AdminAddresses&id_address='.$address['id_address'].'&addaddress&token='.$tokenAddresses.'"><img src="../img/admin/edit.gif" /></a>
|
||||
<a href="?tab=AdminAddresses&id_address='.$address['id_address'].'&deleteaddress&token='.$tokenAddresses.'"><img src="../img/admin/delete.gif" /></a>
|
||||
</td>
|
||||
</tr>';
|
||||
echo '
|
||||
</table>';
|
||||
}
|
||||
else
|
||||
echo $customer->firstname.' '.$customer->lastname.' '.$this->l('has registered no addresses yet').'.';
|
||||
echo '<div class="clear"> </div>
|
||||
<h2>'.$this->l('Discounts').' ('.sizeof($discounts).')</h2>';
|
||||
if (sizeof($discounts))
|
||||
{
|
||||
echo '
|
||||
<table cellspacing="0" cellpadding="0" class="table">
|
||||
<tr>
|
||||
<th>'.$this->l('ID').'</th>
|
||||
<th>'.$this->l('Code').'</th>
|
||||
<th>'.$this->l('Type').'</th>
|
||||
<th>'.$this->l('Value').'</th>
|
||||
<th>'.$this->l('Qty available').'</th>
|
||||
<th>'.$this->l('Status').'</th>
|
||||
<th>'.$this->l('Actions').'</th>
|
||||
</tr>';
|
||||
$tokenDiscounts = Tools::getAdminToken('AdminDiscounts'.intval(Tab::getIdFromClassName('AdminDiscounts')).intval($cookie->id_employee));
|
||||
foreach ($discounts AS $discount)
|
||||
{
|
||||
echo '
|
||||
<tr '.($irow++ % 2 ? 'class="alt_row"' : '').'>
|
||||
<td align="center">'.$discount['id_discount'].'</td>
|
||||
<td>'.$discount['name'].'</td>
|
||||
<td>'.$discount['type'].'</td>
|
||||
<td align="right">'.$discount['value'].'</td>
|
||||
<td align="center">'.$discount['quantity_for_user'].'</td>
|
||||
<td align="center"><img src="../img/admin/'.($discount['active'] ? 'enabled.gif' : 'disabled.gif').'" alt="'.$this->l('Status').'" title="'.$this->l('Status').'" /></td>
|
||||
<td align="center">
|
||||
<a href="?tab=AdminDiscounts&id_discount='.$discount['id_discount'].'&adddiscount&token='.$tokenDiscounts.'"><img src="../img/admin/edit.gif" /></a>
|
||||
<a href="?tab=AdminDiscounts&id_discount='.$discount['id_discount'].'&deletediscount&token='.$tokenDiscounts.'"><img src="../img/admin/delete.gif" /></a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '
|
||||
</table>';
|
||||
|
||||
}
|
||||
else
|
||||
echo $customer->firstname.' '.$customer->lastname.' '.$this->l('has no discount vouchers').'.';
|
||||
echo '<div class="clear"> </div>';
|
||||
|
||||
echo '<h2>'.$this->l('Carts').' ('.sizeof($carts).')</h2>';
|
||||
if ($carts AND sizeof($carts))
|
||||
{
|
||||
echo '
|
||||
<table cellspacing="0" cellpadding="0" class="table">
|
||||
<tr>
|
||||
<th class="center">'.$this->l('ID').'</th>
|
||||
<th class="center">'.$this->l('Date').'</th>
|
||||
<th class="center">'.$this->l('Total').'</th>
|
||||
<th class="center">'.$this->l('Carrier').'</th>
|
||||
<th class="center">'.$this->l('Actions').'</th>
|
||||
</tr>';
|
||||
$tokenCarts = Tools::getAdminToken('AdminCarts'.intval(Tab::getIdFromClassName('AdminCarts')).intval($cookie->id_employee));
|
||||
foreach ($carts AS $cart)
|
||||
{
|
||||
$cartI = new Cart(intval($cart['id_cart']));
|
||||
$summary = $cartI->getSummaryDetails();
|
||||
$currency = new Currency(intval($cart['id_currency']));
|
||||
$carrier = new Carrier(intval($cart['id_carrier']));
|
||||
echo '
|
||||
<tr '.($irow++ % 2 ? 'class="alt_row"' : '').' style="cursor: pointer" onclick="document.location = \'?tab=AdminCarts&id_cart='.$cart['id_cart'].'&viewcart&token='.$tokenCarts.'\'">
|
||||
<td class="center">'.sprintf('%06d', $cart['id_cart']).'</td>
|
||||
<td>'.Tools::displayDate($cart['date_add'], intval($cookie->id_lang), true).'</td>
|
||||
<td align="right">'.Tools::displayPrice($summary['total_price'], $currency).'</td>
|
||||
<td>'.$carrier->name.'</td>
|
||||
<td align="center"><a href="?tab=AdminCarts&id_cart='.$cart['id_cart'].'&viewcart&token='.$tokenCarts.'"><img src="../img/admin/details.gif" /></a></td>
|
||||
</tr>';
|
||||
}
|
||||
echo '
|
||||
</table>';
|
||||
}
|
||||
else
|
||||
echo $this->l('No cart available').'.';
|
||||
echo '<div class="clear"> </div>';
|
||||
|
||||
/* Last connections */
|
||||
$connections = $customer->getLastConnections();
|
||||
if (sizeof($connections))
|
||||
{
|
||||
echo '<h2>'.$this->l('Last connections').'</h2>
|
||||
<table cellspacing="0" cellpadding="0" class="table">
|
||||
<tr>
|
||||
<th style="width: 200px">'.$this->l('Date').'</th>
|
||||
<th style="width: 100px">'.$this->l('Pages viewed').'</th>
|
||||
<th style="width: 100px">'.$this->l('Total time').'</th>
|
||||
<th style="width: 100px">'.$this->l('Origin').'</th>
|
||||
<th style="width: 100px">'.$this->l('IP Address').'</th>
|
||||
</tr>';
|
||||
foreach ($connections as $connection)
|
||||
echo '<tr>
|
||||
<td>'.Tools::displayDate($connection['date_add'], intval($cookie->id_lang), true).'</td>
|
||||
<td>'.intval($connection['pages']).'</td>
|
||||
<td>'.$connection['time'].'</td>
|
||||
<td>'.($connection['http_referer'] ? preg_replace('/^www./', '', parse_url($connection['http_referer'], PHP_URL_HOST)) : $this->l('Direct link')).'</td>
|
||||
<td>'.$connection['ipaddress'].'</td>
|
||||
</tr>';
|
||||
echo '</table><div class="clear"> </div>';
|
||||
}
|
||||
if (sizeof($referrers))
|
||||
{
|
||||
echo '<h2>'.$this->l('Referrers').'</h2>
|
||||
<table cellspacing="0" cellpadding="0" class="table">
|
||||
<tr>
|
||||
<th style="width: 200px">'.$this->l('Date').'</th>
|
||||
<th style="width: 200px">'.$this->l('Name').'</th>
|
||||
</tr>';
|
||||
foreach ($referrers as $referrer)
|
||||
echo '<tr>
|
||||
<td>'.Tools::displayDate($referrer['date_add'], intval($cookie->id_lang), true).'</td>
|
||||
<td>'.$referrer['name'].'</td>
|
||||
</tr>';
|
||||
echo '</table><div class="clear"> </div>';
|
||||
}
|
||||
echo '<a href="'.$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to customer list').'</a><br />';
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
if ($obj->id) $need_identifcation_number = $obj->getNeedDNI();
|
||||
$birthday = explode('-', $this->getFieldValue($obj, 'birthday'));
|
||||
$customer_groups = Tools::getValue('groupBox', $obj->getGroups());
|
||||
$groups = Group::getGroups($this->_defaultFormLanguage, true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" class="width3">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/admin/tab-customers.gif" />'.$this->l('Customer').'</legend>
|
||||
<label>'.$this->l('Gender:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" size="33" name="id_gender" id="gender_1" value="1" '.($this->getFieldValue($obj, 'id_gender') == 1 ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="gender_1"> '.$this->l('Male').'</label>
|
||||
<input type="radio" size="33" name="id_gender" id="gender_2" value="2" '.($this->getFieldValue($obj, 'id_gender') == 2 ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="gender_2"> '.$this->l('Female').'</label>
|
||||
<input type="radio" size="33" name="id_gender" id="gender_3" value="9" '.(($this->getFieldValue($obj, 'id_gender') == 9 OR !$this->getFieldValue($obj, 'id_gender')) ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="gender_3"> '.$this->l('Unknown').'</label>
|
||||
</div>
|
||||
<label>'.$this->l('Last name:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="lastname" value="'.htmlentities($this->getFieldValue($obj, 'lastname'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' 0-9!<>,;?=+()@#"<22>{}_$%:<span class="hint-pointer"> </span></span>
|
||||
</div>
|
||||
<label>'.$this->l('First name:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="firstname" value="'.htmlentities($this->getFieldValue($obj, 'firstname'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' 0-9!<>,;?=+()@#"<22>{}_$%:<span class="hint-pointer"> </span></span>
|
||||
</div>
|
||||
<label>'.$this->l('Password:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="password" size="33" name="passwd" value="" /> '.(!$obj->id ? '<sup>*</sup>' : '').'
|
||||
<p>'.($obj->id ? $this->l('Leave blank if no change') : $this->l('5 characters min., only letters, numbers, or').' -_').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('E-mail address:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="email" value="'.htmlentities($this->getFieldValue($obj, 'email'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
</div>
|
||||
<label>'.$this->l('Birthday:').' </label>';
|
||||
$sl_year = ($this->getFieldValue($obj, 'birthday')) ? $birthday[0] : 0;
|
||||
$years = Tools::dateYears();
|
||||
$sl_month = ($this->getFieldValue($obj, 'birthday')) ? $birthday[1] : 0;
|
||||
$months = Tools::dateMonths();
|
||||
$sl_day = ($this->getFieldValue($obj, 'birthday')) ? $birthday[2] : 0;
|
||||
$days = Tools::dateDays();
|
||||
$tab_months = array(
|
||||
$this->l('January'),
|
||||
$this->l('February'),
|
||||
$this->l('March'),
|
||||
$this->l('April'),
|
||||
$this->l('May'),
|
||||
$this->l('June'),
|
||||
$this->l('July'),
|
||||
$this->l('August'),
|
||||
$this->l('September'),
|
||||
$this->l('October'),
|
||||
$this->l('November'),
|
||||
$this->l('December'));
|
||||
echo '
|
||||
<div class="margin-form">
|
||||
<select name="days">
|
||||
<option value="">-</option>';
|
||||
foreach ($days as $v)
|
||||
echo '<option value="'.$v.'" '.($sl_day == $v ? 'selected="selected"' : '').'>'.$v.'</option>';
|
||||
echo '
|
||||
</select>
|
||||
<select name="months">
|
||||
<option value="">-</option>';
|
||||
foreach ($months as $k => $v)
|
||||
echo '<option value="'.$k.'" '.($sl_month == $k ? 'selected="selected"' : '').'>'.$this->l($v).'</option>';
|
||||
echo '</select>
|
||||
<select name="years">
|
||||
<option value="">-</option>';
|
||||
foreach ($years as $v)
|
||||
echo '<option value="'.$v.'" '.($sl_year == $v ? 'selected="selected"' : '').'>'.$v.'</option>';
|
||||
echo '</select>
|
||||
</div>';
|
||||
if (isset($need_identifcation_number) AND $need_identifcation_number)
|
||||
echo '<label for="dni">'.$this->l('Identification Number:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" name="dni" id="dni" value="'.htmlentities($this->getFieldValue($obj, 'dni'), ENT_COMPAT, 'UTF-8').'" />
|
||||
<p>'.$this->l('DNI / NIF / NIE').'</p>
|
||||
</div>';
|
||||
echo '<label>'.$this->l('Status:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="active" id="active_on" value="1" '.($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_on"><img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="active" id="active_off" value="0" '.(!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_off"><img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('Allow or disallow this customer to log in').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Newsletter:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="newsletter" id="newsletter_on" value="1" '.($this->getFieldValue($obj, 'newsletter') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="newsletter_on"><img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="newsletter" id="newsletter_off" value="0" '.(!$this->getFieldValue($obj, 'newsletter') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="newsletter_off"><img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('Customer will receive your newsletter via e-mail').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Opt-in:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="optin" id="optin_on" value="1" '.($this->getFieldValue($obj, 'optin') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="optin_on"><img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="optin" id="optin_off" value="0" '.(!$this->getFieldValue($obj, 'optin') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="optin_off"><img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('Customer will receive your ads via e-mail').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Default group:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name="id_default_group" onchange="checkDefaultGroup(this.value);">';
|
||||
foreach ($groups as $group)
|
||||
echo '<option value="'.intval($group['id_group']).'"'.($group['id_group'] == $obj->id_default_group ? ' selected="selected"' : '').'>'.htmlentities($group['name'], ENT_NOQUOTES, 'utf-8').'</option>';
|
||||
echo '
|
||||
</select>
|
||||
<p>'.$this->l('The group from which apply none cumulative rules (e.g., price display method, reduction)').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Groups:').' </label>
|
||||
<div class="margin-form">';
|
||||
if (sizeof($groups))
|
||||
{
|
||||
echo '
|
||||
<table cellspacing="0" cellpadding="0" class="table" style="width: 29.5em;">
|
||||
<tr>
|
||||
<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'groupBox[]\', this.checked)" /></th>
|
||||
<th>'.$this->l('ID').'</th>
|
||||
<th>'.$this->l('Group name').'</th>
|
||||
</tr>';
|
||||
$irow = 0;
|
||||
foreach ($groups as $group)
|
||||
{
|
||||
echo '
|
||||
<tr class="'.($irow++ % 2 ? 'alt_row' : '').'">
|
||||
<td>'.'<input type="checkbox" name="groupBox[]" class="groupBox" id="groupBox_'.$group['id_group'].'" value="'.$group['id_group'].'" '.(in_array($group['id_group'], $customer_groups) ? 'checked="checked" ' : '').'/></td>
|
||||
<td>'.$group['id_group'].'</td>
|
||||
<td><label for="groupBox_'.$group['id_group'].'" class="t">'.$group['name'].'</label></td>
|
||||
</tr>';
|
||||
}
|
||||
echo '
|
||||
</table>
|
||||
<p style="padding:0px; margin:10px 0px 10px 0px;">'.$this->l('Mark all checkbox(es) of groups to which the customer is to be member').'<sup> *</sup></p>
|
||||
';
|
||||
} else
|
||||
echo '<p>'.$this->l('No group created').'</p>';
|
||||
echo '
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL)
|
||||
{
|
||||
global $cookie;
|
||||
return parent::getList(intval($cookie->id_lang), !Tools::getValue($this->table.'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL);
|
||||
}
|
||||
|
||||
public function beforeDelete($object)
|
||||
{
|
||||
return $object->isUsed();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Database tab for admin panel, AdminDb.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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');
|
||||
include_once(PS_ADMIN_DIR.'/tabs/AdminPreferences.php');
|
||||
|
||||
class AdminDb extends AdminPreferences
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->className = 'Configuration';
|
||||
$this->table = 'configuration';
|
||||
|
||||
$this->_fieldsDatabase = array(
|
||||
'db_server' => array('title' => $this->l('Server:'), 'desc' => $this->l('IP or server name; \'localhost\' will work in most cases'), 'size' => 30, 'type' => 'text', 'required' => true),
|
||||
'db_name' => array('title' => $this->l('Database:'), 'desc' => $this->l('Database name (e.g., \'prestashop\')'), 'size' => 30, 'type' => 'text', 'required' => true),
|
||||
'db_prefix' => array('title' => $this->l('Prefix:'), 'size' => 30, 'type' => 'text'),
|
||||
'db_user' => array('title' => $this->l('User:'), 'size' => 30, 'type' => 'text', 'required' => true),
|
||||
'db_passwd' => array('title' => $this->l('Password:'), 'size' => 30, 'type' => 'password', 'desc' => $this->l('Leave blank if no change')));
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if (isset($_POST['submitDatabase'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
foreach ($this->_fieldsDatabase AS $field => $values)
|
||||
if (isset($values['required']) AND $values['required'])
|
||||
if (($value = Tools::getValue($field)) == false AND (string)$value != '0')
|
||||
$this->_errors[] = Tools::displayError('field').' <b>'.$values['title'].'</b> '.Tools::displayError('is required');
|
||||
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
/* Datas are not saved in database but in config/settings.inc.php */
|
||||
$settings = array();
|
||||
foreach ($_POST as $k => $value)
|
||||
if ($value)
|
||||
$settings['_'.Tools::strtoupper($k).'_'] = $value;
|
||||
rewriteSettingsFile(NULL, NULL, $settings);
|
||||
Tools::redirectAdmin($currentIndex.'&conf=6'.'&token='.$this->token);
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
echo $this->displayWarning($this->l('Be VERY CAREFUL with these settings, as changes may cause your PrestaShop online store to malfunction. For all issues, check the config/settings.inc.php file.')).'<br />';
|
||||
$this->_displayForm('database', $this->_fieldsDatabase, $this->l('Database'), 'width2', 'database_gear');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Delivery slip tab for admin panel, AdminDeliverySlip.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @copyright PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.3
|
||||
*
|
||||
*/
|
||||
|
||||
class AdminDeliverySlip extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$this->table = 'delivery';
|
||||
|
||||
$this->optionTitle = $this->l('Delivery slips options');
|
||||
$this->_fieldsOptions = array(
|
||||
'PS_DELIVERY_PREFIX' => array('title' => $this->l('Delivery prefix:'), 'desc' => $this->l('Prefix used for delivery slips'), 'size' => 6, 'type' => 'textLang'),
|
||||
'PS_DELIVERY_NUMBER' => array('title' => $this->l('Delivery number:'), 'desc' => $this->l('The next delivery slip will begin with this number, and then increase with each additional slip'), 'size' => 6, 'type' => 'text'),
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$output = '
|
||||
<h2>'.$this->l('Print PDF delivery slips').'</h2>
|
||||
<fieldset class="width2">
|
||||
<form action="'.$currentIndex.'&submitPrint=1&token='.$this->token.'" method="post">
|
||||
<label>'.$this->l('From:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="4" maxlength="10" name="date_from" value="'.(date('Y-m-d')).'" style="width: 120px;" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Format: 2007-12-31 (inclusive)').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('To:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="4" maxlength="10" name="date_to" value="'.(date('Y-m-d')).'" style="width: 120px;" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Format: 2008-12-31 (inclusive)').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l('Generate PDF file').'" name="submitPrint" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required fields').'</div>
|
||||
</form>
|
||||
</fieldset>';
|
||||
|
||||
echo $output;
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$this->displayForm();
|
||||
$this->displayOptionsList();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if (Tools::getValue('submitPrint'))
|
||||
{
|
||||
if (!Validate::isDate($_POST['date_from']))
|
||||
$this->_errors[] = $this->l('Invalid from date');
|
||||
if (!Validate::isDate($_POST['date_to']))
|
||||
$this->_errors[] = $this->l('Invalid end date');
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
$orders = Order::getOrdersIdByDate($_POST['date_from'], $_POST['date_to'], NULL, 'delivery');
|
||||
if (sizeof($orders))
|
||||
Tools::redirectAdmin('pdf.php?deliveryslips='.urlencode(serialize($orders)).'&token='.$this->token);
|
||||
else
|
||||
$this->_errors[] = $this->l('No delivery slip found for this period');
|
||||
}
|
||||
}
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,397 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Discounts tab for admin panel, AdminDiscounts.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminDiscounts extends AdminTab
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$this->table = 'discount';
|
||||
$this->className = 'Discount';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
$this->_select = 'dtl.`name` AS discount_type,
|
||||
IF(a.id_discount_type = 1, CONCAT(a.value, " %"),
|
||||
IF(a.id_discount_type = 2, CONCAT(a.value, " ", c.sign),
|
||||
"--")) as strvalue';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'currency` c ON (c.`id_currency` = a.`id_currency`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'discount_type` dt ON (dt.`id_discount_type` = a.`id_discount_type`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'discount_type_lang` dtl ON (dt.`id_discount_type` = dtl.`id_discount_type` AND dtl.`id_lang` = '.intval($cookie->id_lang).')';
|
||||
|
||||
$typesArray = array();
|
||||
$types = Discount::getDiscountTypes(intval($cookie->id_lang));
|
||||
foreach ($types AS $type)
|
||||
$typesArray[$type['id_discount_type']] = $type['name'];
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_discount' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Code'), 'width' => 85, 'prefix' => '<span class="discount_name">', 'suffix' => '</span>', 'filter_key' => 'a!name'),
|
||||
'description' => array('title' => $this->l('Description'), 'width' => 100, 'filter_key' => 'b!description'),
|
||||
'discount_type' => array('title' => $this->l('Type'), 'type' => 'select', 'select' => $typesArray, 'filter_key' => 'dt!id_discount_type'),
|
||||
'strvalue' => array('title' => $this->l('Value'), 'width' => 50, 'align' => 'right', 'filter_key' => 'a!value'),
|
||||
'quantity' => array('title' => $this->l('Qty'), 'width' => 40, 'align' => 'right'),
|
||||
'date_to' => array('title' => $this->l('To'), 'width' => 60, 'type' => 'date'),
|
||||
'active' => array('title' => $this->l('Status'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
|
||||
|
||||
$this->optionTitle = $this->l('Discounts options');
|
||||
$this->_fieldsOptions = array(
|
||||
'PS_VOUCHERS' => array('title' => $this->l('Enable vouchers:'), 'desc' => $this->l('Allow the use of vouchers in shop'), 'cast' => 'intval', 'type' => 'bool'),
|
||||
);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function copyFromPost(&$object, $table)
|
||||
{
|
||||
parent::copyFromPost($object, $table);
|
||||
|
||||
$object->cumulable = (!isset($_POST['cumulable']) ? false : true);
|
||||
$object->cumulable_reduction = (!isset($_POST['cumulable_reduction']) ? false : true);
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
$token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
|
||||
|
||||
if ($discountName = Tools::getValue('name') AND Validate::isDiscountName($discountName) AND Discount::discountExists($discountName, Tools::getValue('id_discount')))
|
||||
$this->_errors[] = Tools::displayError('A voucher of this name already exists. Please choose another name.');
|
||||
|
||||
if (Tools::getValue('submitAdd'.$this->table))
|
||||
{
|
||||
/* Checking fields validity */
|
||||
$this->validateRules();
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
$id = intval(Tools::getValue($this->identifier));
|
||||
|
||||
/* Object update */
|
||||
if (isset($id) AND !empty($id))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
$object = new $this->className($id);
|
||||
if (Validate::isLoadedObject($object))
|
||||
{
|
||||
/* Specific to objects which must not be deleted */
|
||||
if ($this->deleted AND $this->beforeDelete($object))
|
||||
{
|
||||
$object->deleted = 1;
|
||||
$object->update();
|
||||
$objectNew = new $this->className();
|
||||
$this->copyFromPost($objectNew, $this->table);
|
||||
$result = $objectNew->add();
|
||||
if (Validate::isLoadedObject($objectNew))
|
||||
$this->afterDelete($objectNew, $object->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (($categories = Tools::getValue('categoryBox')) === false OR (!empty($categories) AND !is_array($categories)))
|
||||
die(Tools::displayError());
|
||||
$this->copyFromPost($object, $this->table);
|
||||
$result = $object->update(true, false, $categories);
|
||||
}
|
||||
if (!$result)
|
||||
$this->_errors[] = Tools::displayError('an error occurred while updating object').' <b>'.$this->table.'</b>';
|
||||
elseif ($this->postImage($object->id))
|
||||
{
|
||||
if ($back = Tools::getValue('back'))
|
||||
Tools::redirectAdmin(urldecode($back).'&conf=4');
|
||||
if (Tools::getValue('stay_here') == 'on' || Tools::getValue('stay_here') == 'true' || Tools::getValue('stay_here') == '1')
|
||||
Tools::redirectAdmin($currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=4&updatescene&token='.$token);
|
||||
Tools::redirectAdmin($currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=4&token='.$token);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('an error occurred while updating object').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
|
||||
/* Object creation */
|
||||
else
|
||||
{
|
||||
if ($this->tabAccess['add'] === '1')
|
||||
{
|
||||
$object = new $this->className();
|
||||
$this->copyFromPost($object, $this->table);
|
||||
$categories = Tools::getValue('categoryBox', null);
|
||||
if (!$object->add(true, false, $categories))
|
||||
$this->_errors[] = Tools::displayError('an error occurred while creating object').' <b>'.$this->table.'</b>';
|
||||
elseif (($_POST[$this->identifier] = $object->id /* voluntary */) AND $this->postImage($object->id) AND $this->_redirect)
|
||||
Tools::redirectAdmin($currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=3&token='.$token);
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to add anything here.');
|
||||
}
|
||||
}
|
||||
$this->_errors = array_unique($this->_errors);
|
||||
}
|
||||
else
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
function discountType()
|
||||
{
|
||||
if ($("#id_discount_type").val() == 0)
|
||||
$("#value-div").css("display", "none");
|
||||
else if ($("#id_discount_type").val() == 1)
|
||||
{
|
||||
$("#value-div").css("display", "block");
|
||||
$("#percent-span").css("display", "block");
|
||||
$("#id_currency").css("display", "none");
|
||||
}
|
||||
else if ($("#id_discount_type").val() == 2)
|
||||
{
|
||||
$("#value-div").css("display", "block");
|
||||
$("#percent-span").css("display", "none");
|
||||
$("#id_currency").css("display", "block");
|
||||
}
|
||||
else if ($("#id_discount_type").val() == 3)
|
||||
$("#value-div").css("display", "none");
|
||||
}
|
||||
$(document).ready(function(){
|
||||
$("#id_discount_type").change(function(){discountType();});
|
||||
discountType();
|
||||
});
|
||||
</script>
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" id="discount" name="discount" method="post" enctype="multipart/form-data">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset class="width3"><legend><img src="../img/admin/coupon.gif" />'.$this->l('Vouchers').'</legend>
|
||||
<label>'.$this->l('Code:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="30" maxlength="32" name="name" value="'.htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8').'" id="code" />
|
||||
<sup>*</sup>
|
||||
<img src="../img/admin/news-new.gif" onclick="gencode(8);" style="cursor: pointer" />
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters: numbers and').' !<>,;?=+()@#"<22>{}_$%:<span class="hint-pointer"> </span></span>
|
||||
<p class="clear">'.$this->l('The voucher\'s code, at least 3 characters long, which the customer types in during check-out').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Type:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name="id_discount_type" id="id_discount_type" onchange="free_shipping()">
|
||||
<option value="0">'.$this->l('-- Choose --').'</option>';
|
||||
$discountTypes = Discount::getDiscountTypes(intval($cookie->id_lang));
|
||||
foreach ($discountTypes AS $discountType)
|
||||
echo '<option value="'.intval($discountType['id_discount_type']).'"'.
|
||||
(($this->getFieldValue($obj, 'id_discount_type') == $discountType['id_discount_type']) ? ' selected="selected"' : '').'>'.$discountType['name'].'</option>';
|
||||
echo ' </select> <sup>*</sup>
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
<div id="value-div" style="display:none">
|
||||
<label>'.$this->l('Value:').'</label>
|
||||
<div class="margin-form">
|
||||
<input style="float:left;width:80px" type="text" name="value" id="discount_value" value="'.floatval($this->getFieldValue($obj, 'value')).'" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\'); " />
|
||||
<select id="id_currency" name="id_currency" style="float:left;margin-left:10px;width:50px;display:none">
|
||||
<option value="0">--</option>';
|
||||
foreach (Currency::getCurrencies() as $row)
|
||||
echo ' <option value="'.(int)$row['id_currency'].'" '.(($this->getFieldValue($obj, 'id_currency') == $row['id_currency']) ? 'selected="selected"' : '').'>'.$row['sign'].'</option>';
|
||||
echo ' </select>
|
||||
<span id="percent-span" style="margin-left:10px;display:none;float:left;font-size:12px;font-weight:bold;color:black"> %</span>
|
||||
<sup style="float:left;margin-left:5px">*</sup>
|
||||
<p class="clear">'.$this->l('Either the monetary amount or the %, depending on Type selected above').'</p>
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
</div>
|
||||
<label>'.$this->l('Description:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo ' <div id="description_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="33" type="text" name="description_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'description', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
<p class="clear">'.$this->l('Will appear in cart next to voucher code').'</p>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'description', 'description');
|
||||
echo ' </div>
|
||||
<div class="clear" / >
|
||||
<label>'.$this->l('Categories:').' </label>
|
||||
<div class="margin-form">
|
||||
<table cellspacing="0" cellpadding="0" class="table" style="width: 29.5em;">
|
||||
<tr>
|
||||
<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'categoryBox[]\', this.checked)" /></th>
|
||||
<th>'.$this->l('ID').'</th>
|
||||
<th>'.$this->l('Name').'</th>
|
||||
</tr>';
|
||||
$done = array();
|
||||
$index = array();
|
||||
$indexedCategories = isset($_POST['categoryBox']) ? $_POST['categoryBox'] : ($obj->id ? Discount::getCategories($obj->id) : array());
|
||||
$categories = Category::getCategories(intval($cookie->id_lang), false);
|
||||
foreach ($indexedCategories AS $k => $row)
|
||||
$index[] = $row['id_category'];
|
||||
$this->recurseCategoryForInclude($index, $categories, $categories[0][1], 1, $obj->id);
|
||||
echo '
|
||||
</table>
|
||||
<p style="padding:0px; margin:0px 0px 10px 0px;">'.$this->l('Mark all checkbox(es) of categories to which the discount is to be applicated').'<sup> *</sup></p>
|
||||
</div>
|
||||
<div class="clear" / >
|
||||
<label>'.$this->l('Total quantity:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="15" name="quantity" value="'.intval($this->getFieldValue($obj, 'quantity')).'" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Total quantity available (mainly for vouchers open to everyone)').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Qty per each user:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="15" name="quantity_per_user" value="'.intval($this->getFieldValue($obj, 'quantity_per_user')).'" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Number of times a single customer can use this voucher').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Minimum amount').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="15" name="minimal" value="'.($this->getFieldValue($obj, 'minimal') ? floatval($this->getFieldValue($obj, 'minimal')) : '0').'" onkeyup="javascript:this.value = this.value.replace(/,/g, \'.\'); " /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Leave blank or 0 if not applicable').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<p>
|
||||
<input type="checkbox" name="cumulable"'.(($this->getFieldValue($obj, 'cumulable') == 1) ? ' checked="checked"' : '').' id="cumulable_on" value="1" />
|
||||
<label class="t" for="cumulable_on"> '.$this->l('Cumulative with other vouchers').'</label>
|
||||
</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<p>
|
||||
<input type="checkbox" name="cumulable_reduction"'.(($this->getFieldValue($obj, 'cumulable_reduction') == 1) ? ' checked="checked"' : '').' id="cumulable_reduction_on" value="1" />
|
||||
<label class="t" for="cumulable_reduction_on"> '.$this->l('Cumulative with price reductions').'</label>
|
||||
</p>
|
||||
</div>
|
||||
<label>'.$this->l('To be used by:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name="id_customer" id="id_customer">
|
||||
<option value="0">-- '.$this->l('All customers').' --</option>
|
||||
</select><br />'.$this->l('Filter:').' <input type="text" size="25" name="filter" id="filter" onkeyup="fillCustomersAjax();" class="space" value="" />
|
||||
<script type="text/javascript">
|
||||
var formDiscount = document.layers ? document.forms.discount : document.discount;
|
||||
function fillCustomersAjax()
|
||||
{
|
||||
var filterValue = \''.(($value = intval($this->getFieldValue($obj, 'id_customer'))) ? $value : '').'\';
|
||||
if ($(\'#filter\').val())
|
||||
filterValue = $(\'#filter\').val();
|
||||
|
||||
$.getJSON("'.dirname($currentIndex).'/ajax.php",{ajaxDiscountCustomers:1,filter:filterValue},
|
||||
function(customers) {
|
||||
if (customers.length == 0)
|
||||
{
|
||||
formDiscount.id_customer.length = 2;
|
||||
formDiscount.id_customer.options[1].value = -1;
|
||||
formDiscount.id_customer.options[1].text = \''.$this->l('No match found').'\';
|
||||
formDiscount.id_customer.options.selectedIndex = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
formDiscount.id_customer.length = customers.length + 1;
|
||||
for (i = 0; i < customers.length && i < 50; i++)
|
||||
{
|
||||
formDiscount.id_customer.options[i+1].value = customers[i]["value"];
|
||||
formDiscount.id_customer.options[i+1].text = customers[i]["text"];
|
||||
}
|
||||
if (customers.length >= 50)
|
||||
{
|
||||
formDiscount.id_customer.options[50].text = "'.$this->l('Too much results...',__CLASS__ , true, false).'";
|
||||
formDiscount.id_customer.options[50].value = "_";
|
||||
}
|
||||
|
||||
if ($(\'#filter\').val())
|
||||
formDiscount.id_customer.options.selectedIndex = 1;
|
||||
else if(filterValue)
|
||||
for (i = 0; i < customers.length; i++)
|
||||
if (formDiscount.id_customer.options[i+1].value == filterValue)
|
||||
formDiscount.id_customer.options.selectedIndex = i + 1;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
fillCustomersAjax();
|
||||
</script>
|
||||
</div><br />';
|
||||
includeDatepicker(array('date_from', 'date_to'), true);
|
||||
echo '
|
||||
<label>'.$this->l('From:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="20" id="date_from" name="date_from" value="'.($this->getFieldValue($obj, 'date_from') ? htmlentities($this->getFieldValue($obj, 'date_from'), ENT_COMPAT, 'UTF-8') : date('Y-m-d H:i:s')).'" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Start date/time from which voucher can be used').'<br />'.$this->l('Format: YYYY-MM-DD HH:MM:SS').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('To:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="20" id="date_to" name="date_to" value="'.($this->getFieldValue($obj, 'date_to') ? htmlentities($this->getFieldValue($obj, 'date_to'), ENT_COMPAT, 'UTF-8') : (date('Y') + 1).date('-m-d H:i:s')).'" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('End date/time at which voucher is no longer valid').'<br />'.$this->l('Format: YYYY-MM-DD HH:MM:SS').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Status:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="active" id="active_on" value="1" '.($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="active" id="active_off" value="0" '.(!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('Enable or disable voucher').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
/**
|
||||
* Build a categories tree
|
||||
*
|
||||
* @param array $indexedCategories Array with categories where product is indexed (in order to check checkbox)
|
||||
* @param array $categories Categories to list
|
||||
* @param array $current Current category
|
||||
* @param integer $id_category Current category id
|
||||
*/
|
||||
function recurseCategoryForInclude($indexedCategories, $categories, $current, $id_category = 1, $id_category_default = NULL)
|
||||
{
|
||||
global $done;
|
||||
static $irow;
|
||||
$id_obj = intval(Tools::getValue($this->identifier));
|
||||
if (!isset($done[$current['infos']['id_parent']]))
|
||||
$done[$current['infos']['id_parent']] = 0;
|
||||
$done[$current['infos']['id_parent']] += 1;
|
||||
|
||||
$todo = sizeof($categories[$current['infos']['id_parent']]);
|
||||
$doneC = $done[$current['infos']['id_parent']];
|
||||
|
||||
$level = $current['infos']['level_depth'] + 1;
|
||||
$img = $level == 1 ? 'lv1.gif' : 'lv'.$level.'_'.($todo == $doneC ? 'f' : 'b').'.gif';
|
||||
|
||||
echo '
|
||||
<tr class="'.($irow++ % 2 ? 'alt_row' : '').'">
|
||||
<td>
|
||||
<input type="checkbox" name="categoryBox[]" class="categoryBox'.($id_category_default != NULL ? ' id_category_default' : '').'" id="categoryBox_'.$id_category.'" value="'.$id_category.'"'.(((in_array($id_category, $indexedCategories) OR (intval(Tools::getValue('id_category')) == $id_category AND !intval($id_obj))) OR Tools::getIsset('adddiscount')) ? ' checked="checked"' : '').' />
|
||||
</td>
|
||||
<td>
|
||||
'.$id_category.'
|
||||
</td>
|
||||
<td>
|
||||
<img src="../img/admin/'.$img.'" alt="" /> <label for="categoryBox_'.$id_category.'" class="t">'.stripslashes(Category::hideCategoryPosition($current['infos']['name'])).'</label>
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
if (isset($categories[$id_category]))
|
||||
foreach ($categories[$id_category] AS $key => $row)
|
||||
if ($key != 'infos')
|
||||
$this->recurseCategoryForInclude($indexedCategories, $categories, $categories[$id_category][$key], $key);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Emails tab for admin panel, AdminEmails.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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');
|
||||
include_once(PS_ADMIN_DIR.'/tabs/AdminPreferences.php');
|
||||
|
||||
class AdminEmails extends AdminPreferences
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$this->className = 'Configuration';
|
||||
$this->table = 'configuration';
|
||||
|
||||
$contacts = Contact::getContacts($cookie->id_lang);
|
||||
for ($i = 0; $i < sizeof($contacts); ++$i)
|
||||
$contact_message[$i] = array('email_message' => $contacts[$i]['id_contact'], 'name' => $contacts[$i]['name']);
|
||||
$this->_fieldsEmail = array(
|
||||
'PS_MAIL_EMAIL_MESSAGE' => array('title' => $this->l('Send e-mail to:'), 'desc' => $this->l('When customers send message from order page'), 'validation' => 'isUnsignedId', 'type' => 'select', 'cast' => 'intval', 'identifier' => 'email_message', 'list' => $contact_message),
|
||||
'PS_MAIL_METHOD' => array('title' => '', 'validation' => 'isGenericName', 'required' => true, 'type' => 'radio', 'choices' => array(1 => $this->l('Use PHP mail() function. Recommended; works in most cases'), 2 => $this->l('Set my own SMTP parameters. For advanced users ONLY')), 'js' => array(1 => 'onclick="javascript:toggleLayer(\'SMTP_CONTAINER\', 0);"', 2 => 'onclick="toggleLayer(\'SMTP_CONTAINER\', 1);"')),
|
||||
'PS_MAIL_TYPE' => array('title' => '', 'validation' => 'isGenericName', 'required' => true, 'type' => 'radio', 'choices' => array(1 => $this->l('Send mail as HTML'), 2 => $this->l('Send mail as Text'), 3 => $this->l('Both'))),
|
||||
'SMTP_CONTAINER' => array('title' => '', 'type' => 'container'),
|
||||
'PS_MAIL_SERVER' => array('title' => $this->l('SMTP server:'), 'desc' => $this->l('IP or server name (e.g., smtp.mydomain.com)'), 'validation' => 'isGenericName', 'size' => 30, 'type' => 'text'),
|
||||
'PS_MAIL_USER' => array('title' => $this->l('SMTP user:'), 'desc' => $this->l('Leave blank if not applicable'), 'validation' => 'isGenericName', 'size' => 30, 'type' => 'text'),
|
||||
'PS_MAIL_PASSWD' => array('title' => $this->l('SMTP password:'), 'desc' => $this->l('Leave blank if not applicable'), 'validation' => 'isGenericName', 'size' => 30, 'type' => 'password'),
|
||||
'PS_MAIL_SMTP_ENCRYPTION' => array('title' => $this->l('Encryption:'), 'desc' => $this->l('Use an encrypt protocol'), 'type' => 'select', 'cast' => 'strval', 'identifier' => 'mode', 'list' => array(array('mode' => 'off', 'name' => $this->l('None')), array('mode' => 'tls', 'name' => $this->l('TLS')), array('mode' => 'ssl', 'name' => $this->l('SSL')))),
|
||||
'PS_MAIL_SMTP_PORT' => array('title' => $this->l('Port:'), 'desc' => $this->l('Number of port to use'), 'validation' => 'isInt', 'size' => 5, 'type' => 'text', 'cast' => 'intval'),
|
||||
'SMTP_CONTAINER_END' => array('title' => '', 'type' => 'container_end', 'content' => '<script type="text/javascript">if (getE("PS_MAIL_METHOD2_on").checked == false) { toggleLayer(\'SMTP_CONTAINER\', 0); }</script>')
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (isset($_POST['submitEmail'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
$this->_postConfig($this->_fieldsEmail);
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
}
|
||||
|
||||
public function display() {
|
||||
$this->_displayForm('email', $this->_fieldsEmail, $this->l('E-mail'), 'width2', 'email');
|
||||
$this->_displayMailTest();
|
||||
}
|
||||
|
||||
private function _displayMailTest()
|
||||
{
|
||||
echo '
|
||||
<fieldset style="width:51%;margin-top:10px;">
|
||||
<legend><img src="../img/admin/email.gif" alt="" /> '.$this->l('Test your mail configuration').'</legend>
|
||||
<script type="text/javascript">
|
||||
var textMsg = "'.$this->l('This is a test message, your server is now available to send email').'";
|
||||
var textSubject = "'.$this->l('Test message - Prestashop').'";
|
||||
var textSendOk = "'.$this->l('Mail is send').'";
|
||||
var textSendError= "'.$this->l('Error: please check your configuration').'";
|
||||
var errorMail = "'.$this->l('This email adress is wrong!').'";
|
||||
</script>
|
||||
<script type="text/javascript" src="'._PS_JS_DIR_.'/sendMailTest.js"></script>
|
||||
<div style="clear: both; padding-top:15px;">
|
||||
<label>'.$this->l('Send a mail test at:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" name="testEmail" id="testEmail" value="'.Configuration::get('PS_SHOP_EMAIL').'" style="width:210px;margin-bottom:4px;" /><br />
|
||||
<input type="hidden" id="PS_MAIL_METHOD" name="PS_MAIL_METHOD" value="'.Configuration::get('PS_MAIL_METHOD').'" />
|
||||
<input type="hidden" id="PS_MAIL_SERVER" name="PS_MAIL_SERVER" value="'.Configuration::get('PS_MAIL_SERVER').'" />
|
||||
<input type="hidden" id="PS_MAIL_USER" name="PS_MAIL_USER" value="'.Configuration::get('PS_MAIL_USER').'" />
|
||||
<input type="hidden" id="PS_MAIL_PASSWD" name="PS_MAIL_PASSWD" value="'.Configuration::get('PS_MAIL_PASSWD').'" />
|
||||
<input type="hidden" id="PS_MAIL_SMTP_PORT" name="PS_MAIL_SMTP_PORT" value="'.Configuration::get('PS_MAIL_SMTP_PORT').'" />
|
||||
<input type="hidden" id="PS_MAIL_SMTP_ENCRYPTION" name="PS_MAIL_SMTP_ENCRYPTION" value="'.Configuration::get('PS_MAIL_SMTP_ENCRYPTION').'" />
|
||||
<input type="button" class="button" name="btEmailTest" id="btEmailTest" value="'.$this->l('Send a mail test').'" onClick="verifyMail();" /><br />
|
||||
<p id="mailResultCheck" style="display:none;"></p>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Employees tab for admin panel, AdminEmployees.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminEmployees extends AdminTab
|
||||
{
|
||||
/** @var array profiles list */
|
||||
private $profilesArray = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$this->table = 'employee';
|
||||
$this->className = 'Employee';
|
||||
$this->lang = false;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
$this->_select = 'pl.`name` AS profile';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'profile` p ON a.`id_profile` = p.`id_profile`
|
||||
LEFT JOIN `'._DB_PREFIX_.'profile_lang` pl ON (pl.`id_profile` = p.`id_profile` AND pl.`id_lang` = '.intval($cookie->id_lang).')';
|
||||
|
||||
$profiles = Profile::getProfiles(intval($cookie->id_lang));
|
||||
if (!$profiles)
|
||||
$this->_errors[] = Tools::displayError('No profile');
|
||||
else
|
||||
foreach ($profiles AS $profile)
|
||||
$this->profilesArray[$profile['name']] = $profile['name'];
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_employee' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'lastname' => array('title' => $this->l('Last name'), 'width' => 130),
|
||||
'firstname' => array('title' => $this->l('First name'), 'width' => 130),
|
||||
'email' => array('title' => $this->l('E-mail address'), 'width' => 180),
|
||||
'profile' => array('title' => $this->l('Profile'), 'width' => 90, 'type' => 'select', 'select' => $this->profilesArray, 'filter_key' => 'p!name'),
|
||||
'active' => array('title' => $this->l('Can log in'), 'align' => 'center', 'active' => 'status', 'type' => 'bool'));
|
||||
|
||||
$this->optionTitle = $this->l('Employees options');
|
||||
$this->_fieldsOptions = array(
|
||||
'PS_PASSWD_TIME_BACK' => array('title' => $this->l('Password regenerate:'), 'desc' => $this->l('Security minimum time to wait for regenerate a new password'), 'cast' => 'intval', 'size' => 5, 'type' => 'text', 'suffix' => ' '.$this->l('minutes')),
|
||||
'PS_BO_ALLOW_EMPLOYEE_FORM_LANG' => array('title' => $this->l('Memorize form language:'), 'desc' => $this->l('Allow employees to save their own default form language'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => array(
|
||||
'0' => array('value' => 0, 'name' => $this->l('No')),
|
||||
'1' => array('value' => 1, 'name' => $this->l('Yes'))
|
||||
))
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function _childValidation()
|
||||
{
|
||||
$email = $this->getFieldValue($this->loadObject(true), 'email');
|
||||
if (!Validate::isEmail($email))
|
||||
$this->_errors[] = Tools::displayError('Invalid e-mail');
|
||||
else if (Employee::employeeExists($email) AND !Tools::getValue('id_employee'))
|
||||
$this->_errors[] = Tools::displayError('an account already exists for this e-mail address:').' '.$email;
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
$profiles = Profile::getProfiles(intval($cookie->id_lang));
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" enctype="multipart/form-data" class="width2">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/admin/nav-user.gif" />'.$this->l('Employees').'</legend>
|
||||
<label>'.$this->l('Last name:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="lastname" value="'.htmlentities($this->getFieldValue($obj, 'lastname'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
</div>
|
||||
<label>'.$this->l('First name:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="firstname" value="'.htmlentities($this->getFieldValue($obj, 'firstname'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
</div>
|
||||
<label>'.$this->l('Password:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="password" size="33" name="passwd" value="" /> <sup>*</sup>
|
||||
<p>'.($obj->id ? $this->l('Leave blank if you do not want to change your password') : $this->l('Min. 8 characters; use only letters, numbers or').' -_').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('E-mail address:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="33" name="email" value="'.htmlentities($this->getFieldValue($obj, 'email'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
</div>
|
||||
<label>'.$this->l('Status:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="active" id="active_on" value="1" '.($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="active" id="active_off" value="0" '.(!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('Allow or disallow this employee to log in to this Back Office').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Profile:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name="id_profile">
|
||||
<option value="">---------</option>';
|
||||
/* Profile display */
|
||||
foreach ($profiles AS $profile)
|
||||
echo '
|
||||
<option value="'.$profile['id_profile'].'"'.($profile['id_profile'] === $this->getFieldValue($obj, 'id_profile') ? ' selected="selected"' : '').'>'.$profile['name'].'</option>';
|
||||
echo '</select> <sup>*</sup>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::isSubmit('deleteemployee') OR Tools::isSubmit('status'))
|
||||
{
|
||||
if (sizeof(Employee::getEmployees()) <= 1)
|
||||
{
|
||||
$this->_errors[] = Tools::displayError('You can\'t disable or delete the only account employee.');
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return parent::postProcess();
|
||||
}
|
||||
else
|
||||
return parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Features tab for admin panel, AdminFeatures.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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');
|
||||
include_once(PS_ADMIN_DIR.'/tabs/AdminFeaturesValues.php');
|
||||
|
||||
class AdminFeatures extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->adminFeaturesValues = new AdminFeaturesValues();
|
||||
$this->table = 'feature';
|
||||
$this->className = 'Feature';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 128),
|
||||
'value' => array('title' => $this->l('Values'), 'width' => 255, 'orderby' => false, 'search' => false));
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if ((isset($_POST['submitAddfeature_value']) AND sizeof($this->adminFeaturesValues->_errors))
|
||||
OR isset($_GET['updatefeature_value']) OR isset($_GET['addfeature_value']))
|
||||
{
|
||||
$this->adminFeaturesValues->displayForm($this->token);
|
||||
echo '<br /><br /><a href="'.$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow.gif" /> '.$this->l('Back to list').'</a><br />';
|
||||
}
|
||||
else
|
||||
parent::display();
|
||||
}
|
||||
|
||||
/* Report to AdminTab::displayList() for more details */
|
||||
public function displayList()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
echo '<br />
|
||||
<a href="'.$currentIndex.'&add'.$this->table.'&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> <b>'.$this->l('Add feature').'</b></a><br />
|
||||
<a href="'.$currentIndex.'&addfeature_value&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add feature value').'</a><br /><br />
|
||||
'.$this->l('Click on the feature name to view its values. Click again to hide them.').'<br /><br />';
|
||||
|
||||
$this->displayListHeader();
|
||||
echo '<input type="hidden" name="groupid" value="0">';
|
||||
|
||||
if (!sizeof($this->_list))
|
||||
echo '<tr><td class="center" colspan="'.sizeof($this->_list).'">'.$this->l('No features found.').'</td></tr>';
|
||||
|
||||
$irow = 0;
|
||||
foreach ($this->_list AS $tr)
|
||||
{
|
||||
$id = intval($tr['id_'.$this->table]);
|
||||
echo '
|
||||
<tr'.($irow++ % 2 ? ' class="alt_row"' : '').'>
|
||||
<td style="vertical-align: top; padding: 4px 0 4px 0" class="center"><input type="checkbox" name="'.$this->table.'Box[]" value="'.$id.'" class="noborder" /></td>
|
||||
<td style="width: 140px; vertical-align: top; padding: 4px 0 4px 0; cursor: pointer" onclick="openCloseLayer(\'features_values_'.$id.'\');">'.$tr['name'].'</td>
|
||||
<td style="vertical-align: top; padding: 4px 0 4px 0; width: 340px">
|
||||
<div id="features_values_'.$id.'" style="display: none">
|
||||
<table class="table" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'feature_value'.$id.'Box[]\', this.checked)" /></th>
|
||||
<th width="100%">'.$this->l('Value').'</th>
|
||||
<th>'.$this->l('Actions').'</th>
|
||||
</tr>';
|
||||
$features = FeatureValue::getFeatureValuesWithLang(intval(Configuration::get('PS_LANG_DEFAULT')), $id);
|
||||
foreach ($features AS $feature)
|
||||
{
|
||||
echo '
|
||||
<tr>
|
||||
<td class="center"><input type="checkbox" name="feature_value'.$id.'Box[]" value="'.$feature['id_feature_value'].'" class="noborder" /></td>
|
||||
<td>'.$feature['value'].'</td>
|
||||
<td class="center">
|
||||
<a href="'.$currentIndex.'&id_feature_value='.$feature['id_feature_value'].'&updatefeature_value&token='.$this->token.'">
|
||||
<img src="../img/admin/edit.gif" border="0" alt="'.$this->l('Edit').'" title="'.$this->l('Edit').'" /></a>
|
||||
<a href="'.$currentIndex.'&id_feature_value='.$feature['id_feature_value'].'&deletefeature_value&token='.$this->token.'"
|
||||
onclick="return confirm(\''.$this->l('Delete value', __CLASS__, true, false).' #'.$feature['id_feature_value'].'?\');">
|
||||
<img src="../img/admin/delete.gif" border="0" alt="'.$this->l('Delete').'" title="'.$this->l('Delete').'" /></a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
if (!sizeof($features))
|
||||
echo '
|
||||
<tr><td colspan="3" style="text-align:center">'.$this->l('No values defined').'</td></tr>';
|
||||
echo '
|
||||
</table>
|
||||
<p><input type="Submit" class="button" name="submitDelfeature_value" value="'.$this->l('Delete selection').'"
|
||||
onclick="changeFormParam(this.form, \'?tab=AdminFeatures\', '.$id.'); return confirm(\''.$this->l('Delete selected items?', __CLASS__, true, false).'\');" /></p>
|
||||
</div>
|
||||
</td>';
|
||||
|
||||
echo '
|
||||
<td style="vertical-align: top; padding: 4px 0 4px 0" class="center">
|
||||
<a href="'.$currentIndex.'&id_'.$this->table.'='.$id.'&update'.$this->table.'&token='.$this->token.'">
|
||||
<img src="../img/admin/edit.gif" border="0" alt="'.$this->l('Edit').'" title="'.$this->l('Edit').'" /></a>
|
||||
<a href="'.$currentIndex.'&id_'.$this->table.'='.$id.'&delete'.$this->table.'&token='.$this->token.'" onclick="return confirm(\''.$this->l('Delete item', __CLASS__, true, false).' #'.$id.'?\');">
|
||||
<img src="../img/admin/delete.gif" border="0" alt="'.$this->l('Delete').'" title="'.$this->l('Delete').'" /></a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
$this->displayListFooter();
|
||||
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&token='.$this->token.'"" method="post">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset class="width3"><legend><img src="../img/t/AdminFeatures.gif" />'.$this->l('Feature').'</legend>
|
||||
<label>'.$this->l('Name:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="name_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="33" type="text" name="name_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name');
|
||||
echo '
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
public function displayErrors()
|
||||
{
|
||||
$this->adminFeaturesValues->displayErrors();
|
||||
parent::displayErrors();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $cookie, $currentIndex;
|
||||
$this->adminFeaturesValues->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id);
|
||||
$this->adminFeaturesValues->postProcess($this->token);
|
||||
|
||||
if(Tools::getValue('submitDel'.$this->table))
|
||||
{
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
if (isset($_POST[$this->table.'Box']))
|
||||
{
|
||||
$object = new $this->className();
|
||||
if ($object->deleteSelection($_POST[$this->table.'Box']))
|
||||
Tools::redirectAdmin($currentIndex.'&conf=2'.'&token='.$this->token);
|
||||
$this->_errors[] = Tools::displayError('an error occurred while deleting selection');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('you must select at least one element to delete');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Features-values tab for admin panel, AdminFeaturesValues.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminFeaturesValues extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'feature_value';
|
||||
$this->className = 'FeatureValue';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display form
|
||||
*
|
||||
* @global string $currentIndex Current URL in order to keep current Tab
|
||||
*/
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.Tools::getValue('token').'" method="post">
|
||||
'.($obj->id ? '<input type="hidden" name="id_feature_value" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset class="width3"><legend><img src="../img/t/AdminFeatures.gif" />'.$this->l('Value').'</legend>
|
||||
<label>'.$this->l('Value:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="value_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="33" type="text" name="value_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'value', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'value', 'value');
|
||||
echo '
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<label>'.$this->l('Feature:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name="id_feature">';
|
||||
$features = Feature::getFeatures($this->_defaultFormLanguage);
|
||||
foreach ($features AS $feature)
|
||||
echo '<option value="'.$feature['id_feature'].'"'.($this->getFieldValue($obj, 'id_feature') == $feature['id_feature']? ' selected="selected"' : '').'>'.$feature['name'].'</option>';
|
||||
echo '
|
||||
</select><sup> *</sup>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage page processing
|
||||
*
|
||||
* @global string $currentIndex Current URL in order to keep current Tab
|
||||
*/
|
||||
public function postProcess($token = NULL)
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if(Tools::getValue('submitDel'.$this->table))
|
||||
{
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
if (isset($_POST[$this->table.$_POST['groupid'].'Box']))
|
||||
{
|
||||
$object = new $this->className();
|
||||
if ($object->deleteSelection($_POST[$this->table.$_POST['groupid'].'Box']))
|
||||
Tools::redirectAdmin($currentIndex.'&conf=2'.'&token='.($token ? $token : $this->token));
|
||||
$this->_errors[] = Tools::displayError('an error occurred while deleting selection');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('you must select at least one element to delete');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,205 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Generator tab for admin panel, AdminGenerator.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminGenerator extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->_path = dirname(__FILE__).'/../../';
|
||||
$this->_htFile = $this->_path.'.htaccess';
|
||||
$this->_rbFile = $this->_path.'robots.txt';
|
||||
$this->_htData = $this->_getHtaccessContent();
|
||||
$this->_rbData = $this->_getRobotsContent();
|
||||
return parent::__construct();
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
$languages = Language::getLanguages();
|
||||
|
||||
// Htaccess
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&token='.$this->token.'" method="post" enctype="multipart/form-data">
|
||||
<fieldset class="width2"><legend><img src="../img/admin/htaccess.gif" />'.$this->l('Htaccess file generation').'</legend>
|
||||
<p><b>'.$this->l('Warning:').'</b> '.$this->l('this tool can ONLY be used if you are hosted by an Apache web server. Please ask your webhost.').'</p>
|
||||
<p>'.$this->l('This tool will automatically generate a ".htaccess" file that will grant you the possibility to do URL rewriting and to catch 404 errors.').'</p>
|
||||
<p>'.$this->l('If you do not have the "Friendly URL" enabled when generating the ".htaccess" file, such feature won\'t be available.').'</p>';
|
||||
if ($this->_checkConfiguration($this->_htFile))
|
||||
echo '
|
||||
<p style="font-weight:bold;">'.$this->l('Generate your ".htaccess" file by clicking on the following button:').'<br /><br />
|
||||
<input type="submit" value="'.$this->l('Generate .htaccess file').'" name="submitHtaccess" class="button" /></p>
|
||||
<p>'.$this->l('This will erase your').'<b> '.$this->l('old').'</b> '.$this->l('.htaccess file!').'</p>';
|
||||
else
|
||||
echo '
|
||||
<p style="color:red; font-weight:bold;">'.$this->l('Before being able to use this tool, you need to:').'</p>
|
||||
<p>'.$this->l('- create a').' <b>'. $this->l('.htaccess').'</b> '.$this->l('blank file in dir:').' <b>'.__PS_BASE_URI__.'</b>
|
||||
<br />'.$this->l('- give it write permissions (CHMOD 666 on Unix system)').'</p>';
|
||||
echo '</p></fieldset></form>';
|
||||
|
||||
// Robots
|
||||
echo '<br /><br />
|
||||
<form action="'.$currentIndex.'&token='.$this->token.'" method="post" enctype="multipart/form-data">
|
||||
<fieldset class="width2"><legend><img src="../img/admin/robots.gif" />'.$this->l('Robots file generation').'</legend>
|
||||
<p><b>'.$this->l('Warning:').' </b>'.$this->l('Your file robots.txt MUST be in your website\'s root dir and nowhere else.').'</p>
|
||||
<p>'.$this->l('eg: http://www.yoursite.com/robots.txt').'.</p>
|
||||
<p>'.$this->l('This tool will automatically generate a "robots.txt" file that will grant you the possibility to deny access to search engines for somes pages.').'</p>';
|
||||
if ($this->_checkConfiguration($this->_rbFile))
|
||||
echo '
|
||||
<p style="font-weight:bold;">'.$this->l('Generate your "robots.txt" file by clicking on the following button:').'<br /><br />
|
||||
<input type="submit" value="'.$this->l('Generate robots.txt file').'" name="submitRobots" class="button" /></p>
|
||||
<p>'.$this->l('This will erase your').'<b> '.$this->l('old').'</b> '.$this->l('robots.txt file!').'</p>';
|
||||
else
|
||||
echo '
|
||||
<p style="color:red; font-weight:bold;">'.$this->l('Before being able to use this tool, you need to:').'</p>
|
||||
<p>'.$this->l('- create a').' <b>'. $this->l('robots.txt').'</b> '.$this->l('blank file in dir:').' <b>'.__PS_BASE_URI__.'</b>
|
||||
<br />'.$this->l('- give it write permissions (CHMOD 666 on Unix system)').'</p>';
|
||||
echo '</p></fieldset></form>';
|
||||
}
|
||||
|
||||
public function _checkConfiguration($file)
|
||||
{
|
||||
$ret = file_exists($file);
|
||||
$ret &= is_writable($file);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function postProcess()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if (Tools::isSubmit('submitHtaccess'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (!$writeFd = @fopen($this->_htFile, 'w'))
|
||||
die ($this->l('Cannot write into file:').' <b>'.$this->_htFile.'</b><br />'.$this->l('Please check write permissions.'));
|
||||
else
|
||||
{
|
||||
// PS Comments
|
||||
fwrite($writeFd, "# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution\n");
|
||||
fwrite($writeFd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n\n");
|
||||
|
||||
// RewriteEngine
|
||||
if (Configuration::get('PS_REWRITING_SETTINGS'))
|
||||
{
|
||||
fwrite($writeFd, $this->_htData['RewriteEngine']['comment']."\nRewriteEngine on\n\n");
|
||||
fwrite($writeFd, $this->_htData['RewriteRule']['comment']."\n");
|
||||
foreach ($this->_htData['RewriteRule']['content'] as $rule => $url)
|
||||
fwrite($writeFd, 'RewriteRule '.$rule.' '.__PS_BASE_URI__.$url."\n");
|
||||
fwrite($writeFd, "\n");
|
||||
}
|
||||
|
||||
// ErrorDocument
|
||||
fwrite($writeFd, $this->_htData['ErrorDocument']['comment']."\nErrorDocument ".$this->_htData['ErrorDocument']['content']."\n");
|
||||
|
||||
fclose($writeFd);
|
||||
Tools::redirectAdmin($currentIndex.'&conf=4&token='.$this->token);
|
||||
}
|
||||
} else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitRobots'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (!$writeFd = @fopen($this->_rbFile, 'w'))
|
||||
die ($this->l('Cannot write into file:').' <b>'.$this->_rbFile.'</b><br />'.$this->l('Please check write permissions.'));
|
||||
else
|
||||
{
|
||||
// PS Comments
|
||||
fwrite($writeFd, "# robots.txt automaticaly generated by PrestaShop e-commerce open-source solution\n");
|
||||
fwrite($writeFd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n\n");
|
||||
fwrite($writeFd, "# This file is to prevent the crawling and indexing of certain parts\n");
|
||||
fwrite($writeFd, "# of your site by web crawlers and spiders run by sites like Yahoo!\n");
|
||||
fwrite($writeFd, "# and Google. By telling these \"robots\" where not to go on your site,\n");
|
||||
fwrite($writeFd, "# you save bandwidth and server resources.\n\n");
|
||||
fwrite($writeFd, "# For more information about the robots.txt standard, see:\n");
|
||||
fwrite($writeFd, "# http://www.robotstxt.org/wc/robots.html\n\n");
|
||||
|
||||
// User-Agent
|
||||
fwrite($writeFd, "User-agent: *\n\n");
|
||||
|
||||
// Directories
|
||||
fwrite($writeFd, "# Directories\n");
|
||||
foreach ($this->_rbData['Directories'] as $dir)
|
||||
fwrite($writeFd, 'Disallow: '.__PS_BASE_URI__.$dir."\n");
|
||||
fwrite($writeFd, "\n");
|
||||
|
||||
// Files
|
||||
fwrite($writeFd, "# Files\n");
|
||||
foreach ($this->_rbData['Files'] as $file)
|
||||
fwrite($writeFd, 'Disallow: '.__PS_BASE_URI__.$file."\n");
|
||||
fwrite($writeFd, "\n");
|
||||
|
||||
fclose($writeFd);
|
||||
Tools::redirectAdmin($currentIndex.'&conf=4&token='.$this->token);
|
||||
}
|
||||
} else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
}
|
||||
|
||||
public function _getHtaccessContent()
|
||||
{
|
||||
$tab = array();
|
||||
|
||||
// ErrorDocument
|
||||
$tab['ErrorDocument']['comment'] = '# Catch 404 errors';
|
||||
$tab['ErrorDocument']['content'] = '404 '.__PS_BASE_URI__.'404.php';
|
||||
|
||||
// RewriteEngine
|
||||
$tab['RewriteEngine']['comment'] = '# URL rewriting module activation';
|
||||
|
||||
// RewriteRules
|
||||
//IMPORTANT : if you change the lines bellow, don"t forget to change the "urlcanonical" module too
|
||||
$tab['RewriteRule']['comment'] = '# URL rewriting rules';
|
||||
$tab['RewriteRule']['content']['^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)\.jpg$'] = 'img/p/$1-$2$3.jpg [L,E]';
|
||||
$tab['RewriteRule']['content']['^([0-9]+)\-([0-9]+)/([_a-zA-Z0-9-]*)\.jpg$'] = 'img/p/$1-$2.jpg [L,E]';
|
||||
$tab['RewriteRule']['content']['^([0-9]+)(\-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)\.jpg$'] = 'img/c/$1$2.jpg [L,E]';
|
||||
$tab['RewriteRule']['content']['^lang-([a-z]{2})/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$'] = 'product.php?id_product=$3&isolang=$1$5 [L,E]';
|
||||
$tab['RewriteRule']['content']['^lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$'] = 'product.php?id_product=$2&isolang=$1$4 [L,E]';
|
||||
$tab['RewriteRule']['content']['^lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$'] = 'category.php?id_category=$2&isolang=$1 [QSA,L,E]';
|
||||
$tab['RewriteRule']['content']['^([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$'] = 'product.php?id_product=$2$4 [L,E]';
|
||||
$tab['RewriteRule']['content']['^([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$'] = 'product.php?id_product=$1$3 [L,E]';
|
||||
$tab['RewriteRule']['content']['^([0-9]+)\-([a-zA-Z0-9-]*)(.*)$'] = 'category.php?id_category=$1 [QSA,L,E]';
|
||||
$tab['RewriteRule']['content']['^content/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$'] = 'cms.php?id_cms=$1 [QSA,L,E]';
|
||||
$tab['RewriteRule']['content']['^([0-9]+)__([a-zA-Z0-9-]*)(.*)$'] = 'supplier.php?id_supplier=$1$3 [QSA,L,E]';
|
||||
$tab['RewriteRule']['content']['^([0-9]+)_([a-zA-Z0-9-]*)(.*)$'] = 'manufacturer.php?id_manufacturer=$1$3 [QSA,L,E]';
|
||||
$tab['RewriteRule']['content']['^lang-([a-z]{2})/(.*)$'] = '$2?isolang=$1 [QSA,L,E]';
|
||||
|
||||
return $tab;
|
||||
}
|
||||
|
||||
public function _getRobotsContent()
|
||||
{
|
||||
$tab = array();
|
||||
|
||||
// Directories
|
||||
$tab['Directories'] = array('classes/', 'config/', 'download/', 'mails/', 'modules/', 'translations/', 'tools/');
|
||||
|
||||
// Files
|
||||
$tab['Files'] = array('addresses.php', 'address.php', 'authentication.php', 'cart.php', 'discount.php', 'footer.php',
|
||||
'get-file.php', 'header.php', 'history.php', 'identity.php', 'images.inc.php', 'init.php', 'my-account.php', 'order.php',
|
||||
'order-slip.php', 'order-detail.php', 'order-follow.php', 'order-return.php', 'order-confirmation.php', 'pagination.php', 'password.php',
|
||||
'pdf-invoice.php', 'pdf-order-return.php', 'pdf-order-slip.php', 'product-sort.php', 'search.php', 'statistics.php');
|
||||
|
||||
return $tab;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,201 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Customers tab for admin panel, AdminContacts.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminGroups extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'group';
|
||||
$this->className = 'Group';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->view = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->_select = '
|
||||
(SELECT COUNT(jcg.`id_customer`)
|
||||
FROM `'._DB_PREFIX_.'customer_group` jcg
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` jc ON (jc.`id_customer` = jcg.`id_customer`)
|
||||
WHERE jc.`deleted` != 1
|
||||
AND jcg.`id_group` = a.`id_group`) AS nb
|
||||
';
|
||||
$this->_group = 'GROUP BY a.id_group';
|
||||
$this->_listSkipDelete = array(1);
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_group' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 80, 'filter_key' => 'b!name'),
|
||||
'reduction' => array('title' => $this->l('Reduction'), 'width' => 50, 'align' => 'right'),
|
||||
'nb' => array('title' => $this->l('Members'), 'width' => 25, 'align' => 'center'),
|
||||
'date_add' => array('title' => $this->l('Creation date'), 'width' => 60, 'type' => 'date'));
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" class="width3">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/admin/tab-groups.gif" />'.$this->l('Group').'</legend>
|
||||
<label>'.$this->l('Name:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="name_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="33" type="text" name="name_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' 0-9!<>,;?=+()@#"<22>{}_$%:<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name');
|
||||
$reduction = htmlentities($this->getFieldValue($obj, 'reduction'), ENT_COMPAT, 'UTF-8');
|
||||
echo '
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
<label>'.$this->l('Reduction:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="5" name="reduction" value="'.($reduction ? $reduction : '0').'" /> '.$this->l('%').'
|
||||
<p>'.$this->l('Will automatically apply this value as a reduction on ALL shop\'s products for this group\'s members').'</p>
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
<label>'.$this->l('Price display method:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name="price_display_method">
|
||||
<option value="'.PS_TAX_EXC.'"'.(intval($this->getFieldValue($obj, 'price_display_method')) == PS_TAX_EXC ? ' selected="selected"' : '').'>'.$this->l('Tax excluded').'</option>
|
||||
<option value="'.PS_TAX_INC.'"'.(intval($this->getFieldValue($obj, 'price_display_method')) == PS_TAX_INC ? ' selected="selected"' : '').'>'.$this->l('Tax included').'</option>
|
||||
</select>
|
||||
<p>'.$this->l('How the prices are displayed on order summary for this customer group (tax included or excluded).').'</p>
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
public function viewgroup()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$currentIndex = 'index.php?tab=AdminGroups';
|
||||
$obj = $this->loadObject(true);
|
||||
$group = new Group(intval($obj->id));
|
||||
$defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
|
||||
|
||||
echo '
|
||||
<fieldset style="width: 400px">
|
||||
<div style="float: right"><a href="'.$currentIndex.'&updategroup&id_group='.$obj->id.'&token='.$this->token.'"><img src="../img/admin/edit.gif" /></a></div>
|
||||
<span style="font-weight: bold; font-size: 14px;">'.strval($obj->name[intval($cookie->id_lang)]).'</span>
|
||||
<div class="clear"> </div>
|
||||
'.$this->l('Reduction:').' '.floatval($obj->reduction).$this->l('%').'
|
||||
</fieldset>
|
||||
<div class="clear"> </div>';
|
||||
|
||||
$customers = $obj->getCustomers();
|
||||
$this->fieldsDisplay = (array(
|
||||
'ID' => array('title' => $this->l('ID')),
|
||||
'sex' => array('title' => $this->l('Sex')),
|
||||
'name' => array('title' => $this->l('Name')),
|
||||
'e-mail' => array('title' => $this->l('e-mail')),
|
||||
'birthdate' => array('title' => $this->l('Birth date')),
|
||||
'register_date' => array('title' => $this->l('Register date')),
|
||||
'orders' => array('title' => $this->l('Orders')),
|
||||
'status' => array('title' => $this->l('Status')),
|
||||
'actions' => array('title' => $this->l('Actions'))
|
||||
));
|
||||
|
||||
if (isset($customers) AND !empty($customers) AND $nbCustomers = sizeof($customers))
|
||||
{
|
||||
echo '<h2>'.$this->l('Customers member of this group').' ('.$nbCustomers.')</h2>
|
||||
<table cellspacing="0" cellpadding="0" class="table widthfull">
|
||||
<tr>';
|
||||
foreach ($this->fieldsDisplay AS $field)
|
||||
echo '<th'.(isset($field['width']) ? 'style="width: '.$field['width'].'"' : '').'>'.$field['title'].'</th>';
|
||||
echo '
|
||||
</tr>';
|
||||
$irow = 0;
|
||||
foreach ($customers AS $k => $customer)
|
||||
{
|
||||
$imgGender = $customer['id_gender'] == 1 ? '<img src="../img/admin/male.gif" alt="'.$this->l('Male').'" />' : ($customer['id_gender'] == 2 ? '<img src="../img/admin/female.gif" alt="'.$this->l('Female').'" />' : '');
|
||||
echo '
|
||||
<tr class="'.($irow++ % 2 ? 'alt_row' : '').'">
|
||||
<td>'.$customer['id_customer'].'</td>
|
||||
<td class="center">'.$imgGender.'</td>
|
||||
<td>'.stripslashes($customer['lastname']).' '.stripslashes($customer['firstname']).'</td>
|
||||
<td>'.stripslashes($customer['email']).'<a href="mailto:'.stripslashes($customer['email']).'"> <img src="../img/admin/email_edit.gif" alt="'.$this->l('Write to this customer').'" /></a></td>
|
||||
<td>'.Tools::displayDate($customer['birthday'], intval($cookie->id_lang)).'</td>
|
||||
<td>'.Tools::displayDate($customer['date_add'], intval($cookie->id_lang)).'</td>
|
||||
<td>'.Order::getCustomerNbOrders($customer['id_customer']).'</td>
|
||||
<td class="center"><img src="../img/admin/'.($customer['active'] ? 'enabled.gif' : 'forbbiden.gif').'" alt="" /></td>
|
||||
<td class="center" width="60px">
|
||||
<a href="index.php?tab=AdminCustomers&id_customer='.$customer['id_customer'].'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.intval(Tab::getIdFromClassName('AdminCustomers')).intval($cookie->id_employee)).'">
|
||||
<img src="../img/admin/details.gif" alt="'.$this->l('View orders').'" /></a>
|
||||
<a href="index.php?tab=AdminCustomers&id_customer='.$customer['id_customer'].'&addcustomer&token='.Tools::getAdminToken('AdminCustomers'.intval(Tab::getIdFromClassName('AdminCustomers')).intval($cookie->id_employee)).'">
|
||||
<img src="../img/admin/edit.gif" alt="'.$this->l('Modify this customer').'" /></a>
|
||||
<a href="index.php?tab=AdminCustomers&id_customer='.$customer['id_customer'].'&deletecustomer&token='.Tools::getAdminToken('AdminCustomers'.intval(Tab::getIdFromClassName('AdminCustomers')).intval($cookie->id_employee)).'" onclick="return confirm(\''.$this->l('Are you sure?', __CLASS__, true, false).'\');">
|
||||
<img src="../img/admin/delete.gif" alt="'.$this->l('Delete this customer').'" /></a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
}
|
||||
else
|
||||
echo '<p><img src="../img/admin/information.png" style="float:left;margin-right:5px;" alt="" /> '.$this->l('No user in this group.').'</p>';
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
$token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
|
||||
|
||||
if (Tools::isSubmit('submitAddgroup'))
|
||||
{
|
||||
if (Tools::getValue('reduction') > 100 OR Tools::getValue('reduction') < 0)
|
||||
$this->_errors[] = Tools::displayError('reduction value is incorrect');
|
||||
else
|
||||
return parent::postProcess();
|
||||
}
|
||||
elseif (isset($_GET['delete'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
if (Validate::isLoadedObject($object = $this->loadObject()))
|
||||
{
|
||||
if ($object->id == 1)
|
||||
$this->_errors[] = Tools::displayError('You cannot delete default group');
|
||||
else
|
||||
{
|
||||
if ($object->delete())
|
||||
Tools::redirectAdmin($currentIndex.'&conf=1&token='.$token);
|
||||
$this->_errors[] = Tools::displayError('an error occurred during deletion');
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('an error occurred while deleting object').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Image resize tab for admin panel, AdminImageResize.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminImageResize extends AdminTab
|
||||
{
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
|
||||
if (isset($_POST['resize']))
|
||||
{
|
||||
$imagesTypes = ImageType::getImagesTypes('products');
|
||||
$sourceFile['tmp_name'] = _PS_IMG_DIR_.'/p/'.Tools::getValue('id_product').'-'.Tools::getValue('id_image').'.jpg';
|
||||
foreach ($imagesTypes AS $k => $imageType)
|
||||
if (!imageCut
|
||||
($sourceFile,
|
||||
_PS_IMG_DIR_.'p/'.Tools::getValue('id_product').'-'.Tools::getValue('id_image').'-'.stripslashes($imageType['name']).'.jpg',
|
||||
$imageType['width'],
|
||||
$imageType['height'],
|
||||
'jpg',
|
||||
$_POST[$imageType['id_image_type'].'_x1'],
|
||||
$_POST[$imageType['id_image_type'].'_y1']))
|
||||
$this->_errors = Tools::displayError('an error occurred while copying image').' '.stripslashes($imageType['name']);
|
||||
// Save and stay on same form
|
||||
if (Tools::getValue('saveandstay') == 'on')
|
||||
Tools::redirectAdmin($currentIndex.'&id_product='.Tools::getValue('id_product').'&id_category='.intval(Tools::getValue('id_category')).'&addproduct&conf=4&tabs=1&token='.Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)));
|
||||
// Default behavior (save and back)
|
||||
Tools::redirectAdmin($currentIndex.'&id_category='.intval(Tools::getValue('id_category')).'&conf='.intval(Tools::getValue('conf')).'&token='.Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)));
|
||||
} else
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
parent::displayForm();
|
||||
|
||||
$imagesTypes = ImageType::getImagesTypes();
|
||||
|
||||
echo '
|
||||
<script type="text/javascript" src="../js/cropper/prototype.js"></script>
|
||||
<script type="text/javascript" src="../js/cropper/scriptaculous.js"></script>
|
||||
<script type="text/javascript" src="../js/cropper/builder.js"></script>
|
||||
<script type="text/javascript" src="../js/cropper/dragdrop.js"></script>
|
||||
<script type="text/javascript" src="../js/cropper/cropper.js"></script>
|
||||
<script type="text/javascript" src="../js/cropper/loader.js"></script>
|
||||
<form enctype="multipart/form-data" method="post" action="'.$currentIndex.'&imageresize&token='.Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)).'">
|
||||
<input type="hidden" name="id_product" value="'.Tools::getValue('id_product').'" />
|
||||
<input type="hidden" name="id_category" value="'.Tools::getValue('id_category').'" />
|
||||
<input type="hidden" name="saveandstay" value="'.Tools::getValue('submitAddAndStay').'" />
|
||||
<input type="hidden" name="conf" value="'.(Tools::getValue('toconf')).'" />
|
||||
<input type="hidden" name="imageresize" value="imageresize" />
|
||||
<input type="hidden" name="id_image" value="'.Tools::getValue('id_image').'" />
|
||||
<fieldset class="width2">
|
||||
<legend><img src="../img/admin/picture.gif" />'.$this->l('Image resize').'</legend>
|
||||
'.$this->l('Using your mouse, define which area of the image is to be used for generating each type of thumbnail.').'
|
||||
<br /><br />
|
||||
<img src="../img/p/'.Tools::getValue('id_product').'-'.Tools::getValue('id_image').'.jpg" id="testImage">
|
||||
<label for="imageChoice">'.$this->l('Thumbnails format:').'</label>
|
||||
<div class="margin-form"">
|
||||
<select name="imageChoice" id="imageChoice">';
|
||||
foreach ($imagesTypes as $type)
|
||||
echo '<option value="../img/p/'.Tools::getValue('id_product').'-'.Tools::getValue('id_image').'.jpg|'.$type['width'].'|'.$type['height'].'|'.$type['id_image_type'].'">'.$type['name'].'</option>';
|
||||
echo ' </select>
|
||||
<input type="submit" class="button" style="margin-left : 40px;" name="resize" value="'.$this->l(' Save all ').'" />
|
||||
</div>';
|
||||
foreach ($imagesTypes as $type)
|
||||
echo '
|
||||
<input type="hidden" name="'.$type['id_image_type'].'_x1" id="'.$type['id_image_type'].'_x1" value="0" />
|
||||
<input type="hidden" name="'.$type['id_image_type'].'_y1" id="'.$type['id_image_type'].'_y1" value="0" />
|
||||
<input type="hidden" name="'.$type['id_image_type'].'_x2" id="'.$type['id_image_type'].'_x2" value="0" />
|
||||
<input type="hidden" name="'.$type['id_image_type'].'_y2" id="'.$type['id_image_type'].'_y2" value="0" />';
|
||||
echo ' </fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,353 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Image settings tab for admin panel, AdminImages.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @copyright PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.3
|
||||
*
|
||||
*/
|
||||
|
||||
include_once(realpath(PS_ADMIN_DIR.'/../').'/classes/AdminTab.php');
|
||||
|
||||
class AdminImages extends AdminTab
|
||||
{
|
||||
private $start_time = 0;
|
||||
private $max_execution_time = 7200;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'image_type';
|
||||
$this->className = 'ImageType';
|
||||
$this->lang = false;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_image_type' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 140, 'size' => 16),
|
||||
'width' => array('title' => $this->l('Width'), 'align' => 'right', 'suffix' => ' px', 'width' => 50, 'size' => 5),
|
||||
'height' => array('title' => $this->l('Height'), 'align' => 'right', 'suffix' => ' px', 'width' => 50, 'size' => 5)
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function displayList()
|
||||
{
|
||||
parent::displayList();
|
||||
$this->displayRegenerate();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex;
|
||||
if (Tools::getValue('submitRegenerate'.$this->table))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if ($this->_regenerateThumbnails(Tools::getValue('type'), Tools::getValue('erase')))
|
||||
Tools::redirectAdmin($currentIndex.'&conf=9'.'&token='.$this->token);
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
protected function _childValidation()
|
||||
{
|
||||
if (!Tools::getValue('id_image_type') AND Validate::isImageTypeName($typeName = Tools::getValue('name')) AND ImageType::typeAlreadyExists($typeName))
|
||||
$this->_errors[] = Tools::displayError('this name already exists');
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo $obj->id ? $this->displayWarning($this->l('After modification, do not forget to regenerate thumbnails')) : '';
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" class="width2">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/admin/picture.gif" />'.$this->l('Images').'</legend><br />
|
||||
<label>'.$this->l('Type name:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" name="name" value="'.htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Letters only (e.g., small, medium, large, extra-large)').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Width:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="4" maxlength="5" name="width" value="'.intval($this->getFieldValue($obj, 'width')).'" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Maximum image width in pixels').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Height:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="4" maxlength="5" name="height" value="'.intval($this->getFieldValue($obj, 'height')).'" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Maximum image height in pixels').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Products:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="products" id="products_on" value="1" '.($this->getFieldValue($obj, 'products') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="products_on"><img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="products" id="products_off" value="0" '.(!$this->getFieldValue($obj, 'products') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="products_off"><img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('This type will be applied to product images').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Categories:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="categories" id="categories_on" value="1" '.($this->getFieldValue($obj, 'categories') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="categories_on"><img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="categories" id="categories_off" value="0" '.(!$this->getFieldValue($obj, 'categories') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="categories_off"><img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('This type will be applied to category images').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Manufacturers:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="manufacturers" id="manufacturers_on" value="1" '.($this->getFieldValue($obj, 'manufacturers') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="manufacturers_on"><img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="manufacturers" id="manufacturers_off" value="0" '.(!$this->getFieldValue($obj, 'manufacturers') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="manufacturers_off"><img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('This type will be applied to manufacturer images').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Suppliers:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="suppliers" id="suppliers_on" value="1" '.($this->getFieldValue($obj, 'suppliers') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="suppliers_on"><img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="suppliers" id="suppliers_off" value="0" '.(!$this->getFieldValue($obj, 'suppliers') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="suppliers_off"><img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('This type will be applied to suppliers images').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Scenes:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="scenes" id="scenes_on" value="1" '.($this->getFieldValue($obj, 'scenes') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="scenes_on"><img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="scenes" id="scenes_off" value="0" '.(!$this->getFieldValue($obj, 'scenes') ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="scenes_off"><img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('This type will be applied to scenes images').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Display form for thumbnails regeneration
|
||||
*
|
||||
* @global string $currentIndex Current URL in order to keep current Tab
|
||||
*/
|
||||
public function displayRegenerate()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
$types = array(
|
||||
'categories' => $this->l('Categories'),
|
||||
'manufacturers' => $this->l('Manufacturers'),
|
||||
'suppliers' => $this->l('Suppliers'),
|
||||
'scenes' => $this->l('Scenes'),
|
||||
'products' => $this->l('Products')
|
||||
);
|
||||
echo '
|
||||
<h2 class="space">'.$this->l('Regenerate thumbnails').'</h2>
|
||||
'.$this->l('Regenerates thumbnails for all existing product images').'.<br /><br />';
|
||||
$this->displayWarning($this->l('Please be patient, as this can take several minutes').'<br />'.$this->l('Be careful! Manually generated thumbnails will be erased by automatically generated thumbnails.'));
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&token='.$this->token.'" method="post">
|
||||
<fieldset style="width:800px;">
|
||||
<legend><img src="../img/admin/picture.gif" /> '.$this->l('Regenerate thumbnails').'</legend><br />
|
||||
<label>'.$this->l('Select image:').'</label>
|
||||
<div class="margin-form">
|
||||
<select name="type" onchange="changeFormat(this)">
|
||||
<option value="all">'.$this->l('All').'</option>';
|
||||
foreach ($types as $k => $type)
|
||||
echo '<option value="'.$k.'">'.$type.'</option>';
|
||||
echo '
|
||||
</select>
|
||||
</div>';
|
||||
|
||||
foreach ($types as $k => $type)
|
||||
{
|
||||
$formats = ImageType::getImagesTypes($k);
|
||||
echo '
|
||||
<label class="second-select format_'.$k.'" style="display:none;">'.$this->l('Select format:').'</label>
|
||||
<div class="second-select margin-form format_'.$k.'" style="display:none;">
|
||||
<select class="second-select format_'.$k.'" name="format_'.$k.'">
|
||||
<option value="all">'.$this->l('All').'</option>';
|
||||
foreach ($formats as $format)
|
||||
echo '<option value="'.$format['id_image_type'].'">'.$format['name'].'</option>';
|
||||
echo '</select></div>';
|
||||
}
|
||||
echo '
|
||||
<script>
|
||||
function changeFormat(elt)
|
||||
{
|
||||
$(\'.second-select\').hide();
|
||||
$(\'.format_\' + $(elt).val()).show();
|
||||
}
|
||||
</script>
|
||||
<label>'.$this->l('Erase previous images').'</label>
|
||||
<div class="margin-form">
|
||||
<input name="erase" type="checkbox" value="1" checked="checked" />
|
||||
<p>'.$this->l('Uncheck this checkbox only if your server timed out and you need to resume the regeneration.').'</p>
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
<input type="Submit" name="submitRegenerate'.$this->table.'" value="'.$this->l('Regenerate thumbnails').'" class="button space" onclick="return confirm(\''.$this->l('Are you sure?', __CLASS__, true, false).'\');" />
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete resized image then regenerate new one with updated settings
|
||||
*/
|
||||
private function _deleteOldImages($dir, $type, $product = false)
|
||||
{
|
||||
$toDel = scandir($dir);
|
||||
foreach ($toDel AS $d)
|
||||
foreach ($type as $imageType)
|
||||
if (preg_match('/^[0-9]+\-'.($product ? '[0-9]+\-' : '').$imageType['name'].'\.jpg$/', $d) OR preg_match('/^([[:lower:]]{2})\-default\-(.*)\.jpg$/', $d))
|
||||
if (file_exists($dir.$d))
|
||||
unlink($dir.$d);
|
||||
}
|
||||
|
||||
// Regenerate images
|
||||
private function _regenerateNewImages($dir, $type, $productsImages = false)
|
||||
{
|
||||
$errors = false;
|
||||
$toRegen = scandir($dir);
|
||||
if (!$productsImages)
|
||||
{
|
||||
foreach ($toRegen as $image)
|
||||
if (preg_match('/^[0-9]*\.jpg$/', $image))
|
||||
foreach ($type AS $k => $imageType)
|
||||
{
|
||||
// Customizable writing dir
|
||||
$newDir = $dir;
|
||||
if ($imageType['name'] == 'thumb_scene')
|
||||
$newDir .= 'thumbs/';
|
||||
if (!file_exists($newDir.substr($image, 0, -4).'-'.stripslashes($imageType['name']).'.jpg'))
|
||||
if (!imageResize($dir.$image, $newDir.substr($image, 0, -4).'-'.stripslashes($imageType['name']).'.jpg', intval($imageType['width']), intval($imageType['height'])))
|
||||
$errors = true;
|
||||
if (time() - $this->start_time > $this->max_execution_time - 4) // stop 4 seconds before the tiemout, just enough time to process the end of the page on a slow server
|
||||
return 'timeout';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$productsImages = Image::getAllImages();
|
||||
foreach ($productsImages AS $k => $image)
|
||||
if (file_exists($dir.$image['id_product'].'-'.$image['id_image'].'.jpg'))
|
||||
foreach ($type AS $k => $imageType)
|
||||
{
|
||||
if (!file_exists($dir.$image['id_product'].'-'.$image['id_image'].'-'.stripslashes($imageType['name']).'.jpg'))
|
||||
if (!imageResize($dir.$image['id_product'].'-'.$image['id_image'].'.jpg', $dir.$image['id_product'].'-'.$image['id_image'].'-'.stripslashes($imageType['name']).'.jpg', intval($imageType['width']), intval($imageType['height'])))
|
||||
$errors = true;
|
||||
if (time() - $this->start_time > $this->max_execution_time - 4) // stop 4 seconds before the tiemout, just enough time to process the end of the page on a slow server
|
||||
return 'timeout';
|
||||
}
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
// Regenerate no-pictures images
|
||||
private function _regenerateNoPictureImages($dir, $type, $languages)
|
||||
{
|
||||
$errors = false;
|
||||
foreach ($type AS $k => $imageType)
|
||||
foreach ($languages AS $language)
|
||||
{
|
||||
$file = $dir.$language['iso_code'].'.jpg';
|
||||
if (!file_exists($file))
|
||||
$file = _PS_PROD_IMG_DIR_.Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT'))).'.jpg';
|
||||
if (!file_exists($dir.$language['iso_code'].'-default-'.stripslashes($imageType['name']).'.jpg'))
|
||||
if (!imageResize($file, $dir.$language['iso_code'].'-default-'.stripslashes($imageType['name']).'.jpg', intval($imageType['width']), intval($imageType['height'])))
|
||||
$errors = true;
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
// Hook watermark optimization
|
||||
private function _regenerateWatermark($dir)
|
||||
{
|
||||
$result = Db::getInstance()->ExecuteS('
|
||||
SELECT m.`name` FROM `'._DB_PREFIX_.'module` m
|
||||
LEFT JOIN `'._DB_PREFIX_.'hook_module` hm ON hm.`id_module` = m.`id_module`
|
||||
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
|
||||
WHERE h.`name` = \'watermark\' AND m.`active` = 1');
|
||||
|
||||
if ($result AND sizeof($result))
|
||||
{
|
||||
$productsImages = Image::getAllImages();
|
||||
foreach ($productsImages AS $k => $image)
|
||||
if (file_exists($dir.$image['id_product'].'-'.$image['id_image'].'.jpg'))
|
||||
foreach ($result AS $k => $module)
|
||||
{
|
||||
if ($moduleInstance = Module::getInstanceByName($module['name']) AND is_callable(array($moduleInstance, 'hookwatermark')))
|
||||
call_user_func(array($moduleInstance, 'hookwatermark'), array('id_image' => $image['id_image'], 'id_product' => $image['id_product']));
|
||||
if (time() - $this->start_time > $this->max_execution_time - 4) // stop 4 seconds before the tiemout, just enough time to process the end of the page on a slow server
|
||||
return 'timeout';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _regenerateThumbnails($type = 'all', $deleteOldImages = false)
|
||||
{
|
||||
$this->start_time = time();
|
||||
ini_set('max_execution_time', $this->max_execution_time); // ini_set may be disabled, we need the real value
|
||||
$this->max_execution_time = (int)ini_get('max_execution_time');
|
||||
$languages = Language::getLanguages();
|
||||
|
||||
$process =
|
||||
array(
|
||||
array('type' => 'categories', 'dir' => _PS_CAT_IMG_DIR_),
|
||||
array('type' => 'manufacturers', 'dir' => _PS_MANU_IMG_DIR_),
|
||||
array('type' => 'suppliers', 'dir' => _PS_SUPP_IMG_DIR_),
|
||||
array('type' => 'scenes', 'dir' => _PS_SCENE_IMG_DIR_),
|
||||
array('type' => 'products', 'dir' => _PS_PROD_IMG_DIR_),
|
||||
);
|
||||
|
||||
// Launching generation process
|
||||
foreach ($process as $k => $proc)
|
||||
{
|
||||
if ($type != 'all' && $type != $proc['type'])
|
||||
continue ;
|
||||
|
||||
// Getting format generation
|
||||
$formats = ImageType::getImagesTypes($proc['type']);
|
||||
if ($type != 'all')
|
||||
{
|
||||
$format = strval(Tools::getValue('format_'.$type));
|
||||
if ($format != 'all')
|
||||
foreach ($formats as $k => $form)
|
||||
if ($form['id_image_type'] != $format)
|
||||
unset($formats[$k]);
|
||||
}
|
||||
|
||||
if ($deleteOldImages)
|
||||
$this->_deleteOldImages($proc['dir'], $formats, ($proc['type'] == 'products' ? true : false));
|
||||
if (($return = $this->_regenerateNewImages($proc['dir'], $formats, ($proc['type'] == 'products' ? true : false))) === true)
|
||||
$this->_errors[] = Tools::displayError('Cannot write ').$proc['type'].Tools::displayError(' images. Please check the folder\'s writing permissions.');
|
||||
elseif ($return == 'timeout')
|
||||
$this->_errors[] = Tools::displayError('Only part of the images have been regenerated, server timed out before the end.');
|
||||
else
|
||||
{
|
||||
if ($proc['type'] == 'products')
|
||||
if ($this->_regenerateWatermark($proc['dir']) == 'timeout')
|
||||
$this->_errors[] = Tools::displayError('Server timed out, the watermark may not have been applied on all your images.');
|
||||
if (!count($this->_errors))
|
||||
if ($this->_regenerateNoPictureImages($proc['dir'], $formats, $languages))
|
||||
$this->_errors[] = Tools::displayError('Cannot write no-picture image to (').$proc['type'].Tools::displayError(') images folder. Please check the folder\'s writing permissions.');
|
||||
}
|
||||
}
|
||||
return (sizeof($this->_errors) > 0 ? false : true);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Invoice tab for admin panel, AdminInvoices.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @copyright PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.3
|
||||
*
|
||||
*/
|
||||
|
||||
class AdminInvoices extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$this->table = 'invoice';
|
||||
|
||||
$this->optionTitle = $this->l('Invoices options');
|
||||
$this->_fieldsOptions = array(
|
||||
'PS_INVOICE' => array('title' => $this->l('Enable invoices:'), 'desc' => $this->l('Select whether or not to activate invoice for your shop'), 'cast' => 'intval', 'type' => 'bool'),
|
||||
'PS_INVOICE_PREFIX' => array('title' => $this->l('Invoice prefix:'), 'desc' => $this->l('Prefix used for invoices'), 'size' => 6, 'type' => 'textLang'),
|
||||
'PS_INVOICE_NUMBER' => array('title' => $this->l('Invoice number:'), 'desc' => $this->l('The next invoice will begin with this number, and then increase with each additional invoice'), 'size' => 6, 'type' => 'text', 'cast' => 'intval')
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$output = '
|
||||
<h2>'.$this->l('Print PDF invoices').'</h2>
|
||||
<fieldset class="width2">
|
||||
<form action="'.$currentIndex.'&submitPrint=1&token='.$this->token.'" method="post">
|
||||
<label>'.$this->l('From:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="4" maxlength="10" name="date_from" value="'.(date('Y-m-d')).'" style="width: 120px;" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Format: 2007-12-31 (inclusive)').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('To:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="4" maxlength="10" name="date_to" value="'.(date('Y-m-d')).'" style="width: 120px;" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Format: 2008-12-31 (inclusive)').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l('Generate PDF file').'" name="submitPrint" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required fields').'</div>
|
||||
</form>
|
||||
</fieldset>';
|
||||
|
||||
echo $output;
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$this->displayForm();
|
||||
$this->displayOptionsList();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if(Tools::isSubmit('submitPrint'))
|
||||
{
|
||||
if (!Validate::isDate(Tools::getValue('date_from')))
|
||||
$this->_errors[] = $this->l('Invalid from date');
|
||||
if (!Validate::isDate(Tools::getValue('date_to')))
|
||||
$this->_errors[] = $this->l('Invalid end date');
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
$orders = Order::getOrdersIdInvoiceByDate(Tools::getValue('date_from'), Tools::getValue('date_to'), NULL, 'invoice');
|
||||
if (sizeof($orders))
|
||||
Tools::redirectAdmin('pdf.php?invoices&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&token='.$this->token);
|
||||
$this->_errors[] = $this->l('No invoice found for this period');
|
||||
}
|
||||
}
|
||||
elseif (Tools::isSubmit('submitOptionsinvoice'))
|
||||
{
|
||||
if (intval(Tools::getValue('PS_INVOICE_NUMBER')) == 0)
|
||||
$this->_errors[] = $this->l('Invalid invoice number');
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,366 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Languages tab for admin panel, AdminLanguages.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminLanguages extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'lang';
|
||||
$this->className = 'Language';
|
||||
$this->lang = false;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldImageSettings = array(array('name' => 'flag', 'dir' => 'l'), array('name' => 'no-picture', 'dir' => 'p'));
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_lang' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'flag' => array('title' => $this->l('Logo'), 'align' => 'center', 'image' => 'l', 'orderby' => false, 'search' => false),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 120),
|
||||
'iso_code' => array('title' => $this->l('ISO code'), 'width' => 70, 'align' => 'center'),
|
||||
'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool'));
|
||||
|
||||
$this->optionTitle = $this->l('Languages options');
|
||||
$this->_fieldsOptions = array(
|
||||
'PS_LANG_DEFAULT' => array('title' => $this->l('Default language:'), 'desc' => $this->l('The default language used in shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_lang', 'list' => Language::getlanguages()),
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a no-product image
|
||||
*
|
||||
* @param string $language Language iso_code for no-picture image filename
|
||||
*/
|
||||
public function copyNoPictureImage($language)
|
||||
{
|
||||
if ($error = checkImage($_FILES['no-picture'], $this->maxImageSize))
|
||||
$this->_errors[] = $error;
|
||||
else
|
||||
{
|
||||
if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') OR !move_uploaded_file($_FILES['no-picture']['tmp_name'], $tmpName))
|
||||
return false;
|
||||
if (!imageResize($tmpName, _PS_IMG_DIR_.'p/'.$language.'.jpg'))
|
||||
$this->_errors[] = Tools::displayError('an error occurred while copying no-picture image to your product folder');
|
||||
if (!imageResize($tmpName, _PS_IMG_DIR_.'c/'.$language.'.jpg'))
|
||||
$this->_errors[] = Tools::displayError('an error occurred while copying no-picture image to your category folder');
|
||||
if (!imageResize($tmpName, _PS_IMG_DIR_.'m/'.$language.'.jpg'))
|
||||
$this->_errors[] = Tools::displayError('an error occurred while copying no-picture image to your manufacturer folder');
|
||||
else
|
||||
{
|
||||
$imagesTypes = ImageType::getImagesTypes('products');
|
||||
foreach ($imagesTypes AS $k => $imageType)
|
||||
{
|
||||
if (!imageResize($tmpName, _PS_IMG_DIR_.'p/'.$language.'-default-'.stripslashes($imageType['name']).'.jpg', $imageType['width'], $imageType['height']))
|
||||
$this->_errors[] = Tools::displayError('an error occurred while resizing no-picture image to your product directory');
|
||||
if (!imageResize($tmpName, _PS_IMG_DIR_.'c/'.$language.'-default-'.stripslashes($imageType['name']).'.jpg', $imageType['width'], $imageType['height']))
|
||||
$this->_errors[] = Tools::displayError('an error occurred while resizing no-picture image to your category directory');
|
||||
if (!imageResize($tmpName, _PS_IMG_DIR_.'m/'.$language.'-default-'.stripslashes($imageType['name']).'.jpg', $imageType['width'], $imageType['height']))
|
||||
$this->_errors[] = Tools::displayError('an error occurred while resizing no-picture image to your manufacturer directory');
|
||||
}
|
||||
}
|
||||
unlink($tmpName);
|
||||
}
|
||||
}
|
||||
|
||||
private function deleteNoPictureImages($id_language)
|
||||
{
|
||||
$language = Language::getIsoById($id_language);
|
||||
$imagesTypes = ImageType::getImagesTypes('products');
|
||||
$dirs = array(_PS_PROD_IMG_DIR_, _PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_);
|
||||
foreach ($dirs AS $dir)
|
||||
{
|
||||
foreach ($imagesTypes AS $k => $imageType)
|
||||
if (file_exists($dir.$language.'-default-'.stripslashes($imageType['name']).'.jpg'))
|
||||
if (!unlink($dir.$language.'-default-'.stripslashes($imageType['name']).'.jpg'))
|
||||
$this->_errors[] = Tools::displayError('an error occurred during the image deletion');
|
||||
if (file_exists($dir.$language.'.jpg'))
|
||||
if (!unlink($dir.$language.'.jpg'))
|
||||
$this->_errors[] = Tools::displayError('an error occurred during the image deletion');
|
||||
}
|
||||
return !sizeof($this->_errors) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
|
||||
if (isset($_GET['delete'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
if (Validate::isLoadedObject($object = $this->loadObject()) AND isset($this->fieldImageSettings))
|
||||
{
|
||||
if ($object->id == Configuration::get('PS_LANG_DEFAULT'))
|
||||
$this->_errors[] = $this->l('you cannot delete the default language');
|
||||
elseif ($object->id == $cookie->id_lang)
|
||||
$this->_errors[] = $this->l('you cannot delete the language currently in use, please change languages before deleting');
|
||||
elseif ($this->deleteNoPictureImages(intval(Tools::getValue('id_lang'))) AND $object->delete())
|
||||
Tools::redirectLink($currentIndex.'&conf=1'.'&token='.$this->token);
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('an error occurred while deleting object').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
elseif(Tools::getValue('submitDel'.$this->table) AND isset($_POST[$this->table.'Box']))
|
||||
{
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
if (in_array(Configuration::get('PS_LANG_DEFAULT'), $_POST[$this->table.'Box']))
|
||||
$this->_errors[] = $this->l('you cannot delete the default language');
|
||||
elseif (in_array($cookie->id_lang, $_POST[$this->table.'Box']))
|
||||
$this->_errors[] = $this->l('you cannot delete the language currently in use, please change languages before deleting');
|
||||
else
|
||||
{
|
||||
foreach ($_POST[$this->table.'Box'] AS $language)
|
||||
$this->deleteNoPictureImages($language);
|
||||
parent::postProcess();
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
elseif (Tools::isSubmit('submitAddlang'))
|
||||
{
|
||||
/* New language */
|
||||
if (intval(Tools::getValue('id_'.$this->table)) == 0)
|
||||
{
|
||||
if ($this->tabAccess['add'] === '1')
|
||||
{
|
||||
if (isset($_POST['iso_code']) AND !empty($_POST['iso_code']) AND Validate::isLanguageIsoCode(Tools::getValue('iso_code')) AND Language::getIdByIso($_POST['iso_code']))
|
||||
$this->_errors[] = Tools::displayError('this ISO code is already linked to another language');
|
||||
if (!empty($_FILES['no-picture']['tmp_name']) AND !empty($_FILES['flag']['tmp_name']) AND Validate::isLanguageIsoCode(Tools::getValue('iso_code')))
|
||||
{
|
||||
$this->copyNoPictureImage(strtolower(Tools::getValue('iso_code')));
|
||||
parent::postProcess();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->validateRules();
|
||||
$this->_errors[] = Tools::displayError('the Flag and No-Picture image fields are required');
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to add anything here.');
|
||||
}
|
||||
/* Language edition */
|
||||
else
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (!empty($_FILES['no-picture']['tmp_name']) AND Validate::isLanguageIsoCode(Tools::getValue('iso_code')))
|
||||
$this->copyNoPictureImage(strtolower(Tools::getValue('iso_code')));
|
||||
if (!Validate::isLoadedObject($object = $this->loadObject()))
|
||||
die(Tools::displayError());
|
||||
if (intval($object->id) == intval(Configuration::get('PS_LANG_DEFAULT')) AND intval($_POST['active']) != intval($object->active))
|
||||
$this->_errors[] = Tools::displayError('You cannot change the status of the default language.');
|
||||
else
|
||||
parent::postProcess();
|
||||
$this->validateRules();
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
}
|
||||
elseif (isset($_GET['status']) AND isset($_GET['id_lang']))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (!Validate::isLoadedObject($object = $this->loadObject()))
|
||||
die(Tools::displayError());
|
||||
if (intval($object->id) == intval(Configuration::get('PS_LANG_DEFAULT')))
|
||||
$this->_errors[] = Tools::displayError('You cannot change the status of the default language.');
|
||||
else
|
||||
return parent::postProcess();
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
public function displayList()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
$this->displayWarning($this->l('When you delete a language, all related translations in the database will be deleted.'));
|
||||
parent::displayList();
|
||||
$languages = Language::getLanguages(false);
|
||||
}
|
||||
|
||||
public function displayListContent($token=NULL)
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
$irow = 0;
|
||||
if ($this->_list)
|
||||
|
||||
foreach ($this->_list AS $tr)
|
||||
{
|
||||
$id = $tr[$this->identifier];
|
||||
if ($tr['active'])
|
||||
{
|
||||
$active['title'] = "Enabled";
|
||||
$active['img'] = "enabled";
|
||||
if (!Language::checkFilesWithIsoCode($tr['iso_code']))
|
||||
{
|
||||
$active['title'] = "Warning";
|
||||
$active['img'] = "warning";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$active['title'] = "Disabled";
|
||||
$active['img'] = "disabled";
|
||||
}
|
||||
echo '<tr'.($irow++ % 2 ? ' class="alt_row"' : '').' '.((isset($tr['color']) AND $this->colorOnBackground) ? 'style="background-color: '.$tr['color'].'"' : '').'>';
|
||||
echo '<td class="center"><input type="checkbox" name="'.$this->table.'Box[]" value="'.$id.'" class="noborder" /></td>';
|
||||
|
||||
foreach ($this->fieldsDisplay AS $key => $params)
|
||||
{
|
||||
$tmp = explode('!', $key);
|
||||
$key = isset($tmp[1]) ? $tmp[1] : $tmp[0];
|
||||
echo '<td class="pointer '.(isset($params['align']) ? $params['align'] : '').'" onclick="document.location = \''.$currentIndex.'&'.$this->identifier.'='.$id.'&update'.$this->table.'&token='.($token!=NULL ? $token : $this->token).'\'">';
|
||||
if (isset($params['active']) AND isset($tr[$key]))
|
||||
echo '<a href="'.$currentIndex.'&'.$this->identifier.'='.$id.'&'.$params['active'].'&token='.($token != NULL ? $token : $this->token).'"><img src="../img/admin/'.$active['img'].'.gif" alt="active" title="'.$active['title'].'" /></a>';
|
||||
elseif (isset($params['image']))
|
||||
echo cacheImage(_PS_IMG_DIR_.$params['image'].'/'.$id.(isset($tr['id_image']) ? '-'.intval($tr['id_image']) : '').'.'.$this->imageType, $this->table.'_mini_'.$id.'.'.$this->imageType, 45, $this->imageType);
|
||||
elseif (isset($tr[$key]))
|
||||
echo $tr[$key];
|
||||
else
|
||||
echo '--';
|
||||
'</td>';
|
||||
}
|
||||
if ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn'))
|
||||
{
|
||||
echo '<td class="center">';
|
||||
if ($this->edit)
|
||||
echo '
|
||||
<a href="'.$currentIndex.'&'.$this->identifier.'='.$id.'&update'.$this->table.'&token='.($token != NULL ? $token : $this->token).'">
|
||||
<img src="../img/admin/edit.gif" border="0" alt="'.$this->l('Edit').'" title="'.$this->l('Edit').'" /></a>';
|
||||
if ($this->delete)
|
||||
echo '
|
||||
<a href="'.$currentIndex.'&'.$this->identifier.'='.$id.'&delete'.$this->table.'&token='.($token != NULL ? $token : $this->token).'" onclick="return confirm(\''.$this->l('When you delete a language, ALL RELATED TRANSLATIONS IN THE DATABASE WILL BE DELETED, are you sure to delete this langauge ?', __CLASS__, true, false).'\');">
|
||||
<img src="../img/admin/delete.gif" border="0" alt="'.$this->l('Delete').'" title="'.$this->l('Delete').'" /></a>';
|
||||
echo '</td>';
|
||||
}
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
var langPackOk = "<img src=\"'._PS_IMG_.'admin/information.png\" alt=\"\" /> '.$this->l('A langage pack is available for this iso code:').'";
|
||||
var langPackInfo = "'.$this->l('After creation of the language you can import the content of language pack, that you can download above, on the "Tools> Translations"').'";
|
||||
var noLangPack = "<img src=\"'._PS_IMG_.'admin/information.png\" alt=\"\" /> '.$this->l('No langage pack available on prestashop.com for this iso code').'";
|
||||
var download = "'.$this->l('Download').'";
|
||||
</script>
|
||||
<script type="text/javascript" src="'._PS_JS_DIR_.'/checkLangPack.js"></script>
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" enctype="multipart/form-data" class="width3">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/admin/world.gif" />'.$this->l('Languages').'</legend>
|
||||
<label>'.$this->l('Name:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="8" maxlength="32" name="name" value="'.htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
</div>
|
||||
<label>'.$this->l('ISO code:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="4" maxlength="2" name="iso_code" id="iso_code" value="'.htmlentities($this->getFieldValue($obj, 'iso_code'), ENT_COMPAT, 'UTF-8').'" onKeyUp="checkLangPack();" /> <sup>*</sup>
|
||||
<p>'.$this->l('2-letter ISO code (e.g., fr, en, de)').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Flag:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="file" name="flag" /> <sup>*</sup>
|
||||
<p>'.$this->l('Upload country flag from your computer').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('"No-picture" image:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="file" name="no-picture" /> <sup>*</sup>
|
||||
<p>'.$this->l('Image displayed when "no picture found"').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Status:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="active" id="active_on" value="1" '.((!$obj->id OR $this->getFieldValue($obj, 'active')) ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="active" id="active_off" value="0" '.((!$this->getFieldValue($obj, 'active') AND $obj->id) ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('Allow or disallow this language to be selected by the customer').'</p>
|
||||
</div>
|
||||
<p id="resultCheckLangPack"><img src="'._PS_IMG_.'admin/ajax-loader.gif" alt="" /> '.$this->l('Check if a language pack is available for this iso code...').'</p>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
|
||||
if ($obj->id AND !$obj->checkFiles())
|
||||
{
|
||||
echo '
|
||||
<br /><br />
|
||||
<fieldset style="width:572px;"><legend><img src="../img/admin/warning.gif" />'.$this->l('Warning').'</legend>
|
||||
<p>'.$this->l('This language is NOT complete and cannot be used in the Front or Back Office because some files are missing.').'</p>
|
||||
<br />
|
||||
<label>'.$this->l('Translations files:').' </label>
|
||||
<div class="margin-form" style="margin-top:4px;">';
|
||||
$files = Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'tr', true);
|
||||
$this->displayFilesList($files);
|
||||
echo '
|
||||
</div><br style="clear:both;" />
|
||||
<label>'.$this->l('Theme files:').' </label>
|
||||
<div class="margin-form" style="margin-top:4px;">';
|
||||
$files = Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'theme', true);
|
||||
$this->displayFilesList($files);
|
||||
echo '
|
||||
</div><br style="clear:both;" />
|
||||
<label>'.$this->l('Mail files:').' </label>
|
||||
<div class="margin-form" style="margin-top:4px;">';
|
||||
$files = Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'mail', true);
|
||||
$this->displayFilesList($files);
|
||||
echo '
|
||||
</div>
|
||||
<br />
|
||||
<div class="small">'.$this->l('Missing files are marked in red').'</div>
|
||||
</fieldset>';
|
||||
}
|
||||
}
|
||||
|
||||
public function displayFilesList($files)
|
||||
{
|
||||
foreach ($files as $key => $file)
|
||||
{
|
||||
if (!file_exists($key))
|
||||
echo '<font color="red">';
|
||||
echo $key;
|
||||
if (!file_exists($key))
|
||||
echo '</font>';
|
||||
echo '<br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Localization tab for admin panel, AdminLocalization.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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');
|
||||
include_once(PS_ADMIN_DIR.'/tabs/AdminPreferences.php');
|
||||
|
||||
class AdminLocalization extends AdminPreferences
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$lang = strtoupper(Language::getIsoById($cookie->id_lang));
|
||||
$this->className = 'Configuration';
|
||||
$this->table = 'configuration';
|
||||
|
||||
$this->_fieldsLocalization = array(
|
||||
'PS_WEIGHT_UNIT' => array('title' => $this->l('Weight unit:'), 'desc' => $this->l('The weight unit of your shop'), 'validation' => 'isWeightUnit', 'required' => true, 'type' => 'text'));
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (isset($_POST['submitLocalization'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
$this->_postConfig($this->_fieldsLocalization);
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$this->_displayForm('localization', $this->_fieldsLocalization, $this->l('Localization'), 'width2', 'localization');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,308 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Manufacturers tab for admin panel, AdminManufacturers.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @copyright PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.3
|
||||
*
|
||||
*/
|
||||
|
||||
include_once(realpath(PS_ADMIN_DIR.'/../').'/classes/AdminTab.php');
|
||||
|
||||
class AdminManufacturers extends AdminTab
|
||||
{
|
||||
protected $maxImageSize = 200000;
|
||||
|
||||
/** @var array countries list */
|
||||
private $countriesArray = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$this->table = 'manufacturer';
|
||||
$this->className = 'Manufacturer';
|
||||
$this->lang = false;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
// Sub tab addresses
|
||||
$countries = Country::getCountries(intval($cookie->id_lang));
|
||||
foreach ($countries AS $country)
|
||||
$this->countriesArray[$country['id_country']] = $country['name'];
|
||||
$this->fieldsDisplayAddresses = array(
|
||||
'id_address' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'm!manufacturer_name' => array('title' => $this->l('Manufacturer'), 'width' => 100),
|
||||
'firstname' => array('title' => $this->l('First name'), 'width' => 80),
|
||||
'lastname' => array('title' => $this->l('Last name'), 'width' => 100, 'filter_key' => 'a!name'),
|
||||
'postcode' => array('title' => $this->l('Post/Zip code'), 'align' => 'right', 'width' => 50),
|
||||
'city' => array('title' => $this->l('City'), 'width' => 150),
|
||||
'country' => array('title' => $this->l('Country'), 'width' => 100, 'type' => 'select', 'select' => $this->countriesArray, 'filter_key' => 'cl!id_country'));
|
||||
$this->_includeTabTitle = array($this->l('Manufacturers addresses'));
|
||||
$this->_joinAddresses = 'LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON
|
||||
(cl.`id_country` = a.`id_country` AND cl.`id_lang` = '.intval($cookie->id_lang).') ';
|
||||
$this->_joinAddresses .= 'LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (a.`id_manufacturer` = m.`id_manufacturer`)';
|
||||
$this->_selectAddresses = 'cl.`name` as country, m.`name` AS manufacturer_name';
|
||||
$this->_includeTab = array('Addresses' => array('addressType' => 'manufacturer', 'fieldsDisplay' => $this->fieldsDisplayAddresses, '_join' => $this->_joinAddresses, '_select' => $this->_selectAddresses));
|
||||
$this->view = true;
|
||||
$this->_select = 'COUNT(`id_product`) AS `products`, (SELECT COUNT(ad.`id_manufacturer`) as `addresses` FROM `'._DB_PREFIX_.'address` ad WHERE ad.`id_manufacturer` = a.`id_manufacturer` AND ad.`deleted` = 0 GROUP BY ad.`id_manufacturer`) as `addresses`';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'product` p ON (a.`id_manufacturer` = p.`id_manufacturer`)';
|
||||
$this->_joinCount = false;
|
||||
$this->_group = 'GROUP BY a.`id_manufacturer`';
|
||||
|
||||
$this->fieldImageSettings = array('name' => 'logo', 'dir' => 'm');
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_manufacturer' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 200),
|
||||
'logo' => array('title' => $this->l('Logo'), 'align' => 'center', 'image' => 'm', 'orderby' => false, 'search' => false),
|
||||
'addresses' => array('title' => $this->l('Addresses'), 'align' => 'right', 'tmpTableFilter' => true, 'width' => 20),
|
||||
'products' => array('title' => $this->l('Products'), 'align' => 'right', 'tmpTableFilter' => true, 'width' => 20)
|
||||
);
|
||||
|
||||
$countries = Country::getCountries(intval($cookie->id_lang));
|
||||
foreach ($countries AS $country)
|
||||
$this->countriesArray[$country['id_country']] = $country['name'];
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function afterImageUpload()
|
||||
{
|
||||
/* Generate image with differents size */
|
||||
if (($id_manufacturer = intval(Tools::getValue('id_manufacturer'))) AND isset($_FILES) AND count($_FILES) AND file_exists(_PS_MANU_IMG_DIR_.$id_manufacturer.'.jpg'))
|
||||
{
|
||||
$imagesTypes = ImageType::getImagesTypes('manufacturers');
|
||||
foreach ($imagesTypes AS $k => $imageType)
|
||||
imageResize(_PS_MANU_IMG_DIR_.$id_manufacturer.'.jpg', _PS_MANU_IMG_DIR_.$id_manufacturer.'-'.stripslashes($imageType['name']).'.jpg', intval($imageType['width']), intval($imageType['height']));
|
||||
}
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
parent::displayForm();
|
||||
|
||||
$manufacturer = $this->loadObject(true);
|
||||
$langtags = 'cdesc2¤cdesc¤mmeta_title¤mmeta_keywords¤mmeta_description';
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" enctype="multipart/form-data" class="width3">
|
||||
'.($manufacturer->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$manufacturer->id.'" />' : '').'
|
||||
<fieldset style="width: 850px;">
|
||||
<legend><img src="../img/admin/manufacturers.gif" />'.$this->l('Manufacturers').'</legend>
|
||||
<label>'.$this->l('Name:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="40" name="name" value="'.htmlentities(Tools::getValue('name', $manufacturer->name), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
|
||||
echo '<br class="clear" /><label>'.$this->l('Short description:').'</label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="cdesc2_'.$language['id_lang'].'" style="float: left;'.($language['id_lang'] != $this->_defaultFormLanguage ? 'display:none;' : '').'">
|
||||
<textarea class="rte" cols="48" rows="5" id="short_description_'.$language['id_lang'].'" name="short_description_'.$language['id_lang'].'">'.htmlentities(stripslashes($this->getFieldValue($manufacturer, 'short_description', $language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $langtags, 'cdesc2');
|
||||
echo '</div>';
|
||||
|
||||
echo '<br class="clear" /><br /><br /><label>'.$this->l('Description:').'</label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="cdesc_'.$language['id_lang'].'" style="float: left;'.($language['id_lang'] != $this->_defaultFormLanguage ? 'display:none;' : '').'">
|
||||
<textarea class="rte" cols="48" rows="10" id="description_'.$language['id_lang'].'" name="description_'.$language['id_lang'].'">'.htmlentities(stripslashes($this->getFieldValue($manufacturer, 'description', $language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $langtags, 'cdesc');
|
||||
echo '</div>';
|
||||
|
||||
// TinyMCE
|
||||
global $cookie;
|
||||
$iso = Language::getIsoById(intval($cookie->id_lang));
|
||||
echo '
|
||||
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tinymce/jscripts/tiny_mce/jquery.tinymce.js"></script>
|
||||
<script type="text/javascript">
|
||||
function tinyMCEInit(element)
|
||||
{
|
||||
$().ready(function() {
|
||||
$(element).tinymce({
|
||||
// Location of TinyMCE script
|
||||
script_url : \''.__PS_BASE_URI__.'js/tinymce/jscripts/tiny_mce/tiny_mce.js\',
|
||||
// General options
|
||||
theme : "advanced",
|
||||
plugins : "safari,pagebreak,style,layer,table,advimage,advlink,inlinepopups,media,searchreplace,contextmenu,paste,directionality,fullscreen",
|
||||
// Theme options
|
||||
theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
|
||||
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,,|,forecolor,backcolor",
|
||||
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,media,|,ltr,rtl,|,fullscreen",
|
||||
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,pagebreak",
|
||||
theme_advanced_toolbar_location : "top",
|
||||
theme_advanced_toolbar_align : "left",
|
||||
theme_advanced_statusbar_location : "bottom",
|
||||
theme_advanced_resizing : false,
|
||||
content_css : "'.__PS_BASE_URI__.'themes/'._THEME_NAME_.'/css/global.css",
|
||||
document_base_url : "'.__PS_BASE_URI__.'",
|
||||
width: "582",
|
||||
height: "auto",
|
||||
font_size_style_values : "8pt, 10pt, 12pt, 14pt, 18pt, 24pt, 36pt",
|
||||
// Drop lists for link/image/media/template dialogs
|
||||
template_external_list_url : "lists/template_list.js",
|
||||
external_link_list_url : "lists/link_list.js",
|
||||
external_image_list_url : "lists/image_list.js",
|
||||
media_external_list_url : "lists/media_list.js",
|
||||
elements : "nourlconvert",
|
||||
convert_urls : false,
|
||||
language : "'.(file_exists(_PS_ROOT_DIR_.'/js/tinymce/jscripts/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en').'"
|
||||
});
|
||||
});
|
||||
}
|
||||
tinyMCEInit(\'textarea.rte\');
|
||||
</script>
|
||||
';
|
||||
echo '<br style="clear:both;" /><br/><br/><label>'.$this->l('Logo:').'</label>
|
||||
<div class="margin-form">';
|
||||
$this->displayImage($manufacturer->id, _PS_MANU_IMG_DIR_.$manufacturer->id.'.jpg', 350);
|
||||
echo ' <br /><input type="file" name="logo" />
|
||||
<p>'.$this->l('Upload manufacturer logo from your computer').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Meta title:').'</label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="mmeta_title_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input type="text" name="meta_title_'.$language['id_lang'].'" id="meta_title_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($manufacturer, 'meta_title', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
|
||||
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $langtags, 'mmeta_title');
|
||||
echo ' <div class="clear"></div>
|
||||
</div>
|
||||
<label>'.$this->l('Meta description:').'</label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '<div id="mmeta_description_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input type="text" name="meta_description_'.$language['id_lang'].'" id="meta_description_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($manufacturer, 'meta_description', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
|
||||
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $langtags, 'mmeta_description');
|
||||
echo ' <div class="clear"></div>
|
||||
</div>
|
||||
<label>'.$this->l('Meta keywords:').'</label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="mmeta_keywords_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input type="text" name="meta_keywords_'.$language['id_lang'].'" id="meta_keywords_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($manufacturer, 'meta_keywords', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
|
||||
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $langtags, 'mmeta_keywords');
|
||||
echo ' <div class="clear"></div>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
public function viewmanufacturer()
|
||||
{
|
||||
global $cookie;
|
||||
$manufacturer = $this->loadObject();
|
||||
echo '<h2>'.$manufacturer->name.'</h2>';
|
||||
|
||||
$products = $manufacturer->getProductsLite(intval($cookie->id_lang));
|
||||
$addresses = $manufacturer->getAddresses(intval($cookie->id_lang));
|
||||
|
||||
echo '<h3>'.$this->l('Total addresses:').' '.sizeof($addresses).'</h3>';
|
||||
echo '<hr />';
|
||||
foreach ($addresses AS $addresse)
|
||||
echo '
|
||||
<h3></h3>
|
||||
<table border="0" cellpadding="0" cellspacing="0" class="table" style="width: 600px;">
|
||||
<tr>
|
||||
<th><b>'.$addresse['firstname'].' '.$addresse['lastname'].'</b></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div style="padding:5px; float:left; width:350px;">
|
||||
'.$addresse['address1'].'<br />
|
||||
'.($addresse['address2'] ? $addresse['address2'].'<br />' : '').'
|
||||
'.$addresse['postcode'].' '.$addresse['city'].'<br />
|
||||
'.($addresse['state'] ? $addresse['state'].'<br />' : '').'
|
||||
<b>'.$addresse['country'].'</b><br />
|
||||
</div>
|
||||
<div style="padding:5px; float:left;">
|
||||
'.($addresse['phone'] ? $addresse['phone'].'<br />' : '').'
|
||||
'.($addresse['phone_mobile'] ? $addresse['phone_mobile'].'<br />' : '').'
|
||||
</div>
|
||||
'.($addresse['other'] ? '<div style="padding:5px; clear:both;"><br /><i>'.$addresse['other'].'</i></div>' : '').'
|
||||
</td>
|
||||
</tr>
|
||||
</table>';
|
||||
if (!sizeof($addresses))
|
||||
echo 'No address for this manufacturer.';
|
||||
echo '<br /><br />';
|
||||
echo '<h3>'.$this->l('Total products:').' '.sizeof($products).'</h3>';
|
||||
foreach ($products AS $product)
|
||||
{
|
||||
$product = new Product($product['id_product'], false, intval($cookie->id_lang));
|
||||
echo '<hr />';
|
||||
if (!$product->hasAttributes())
|
||||
{
|
||||
echo '
|
||||
<table border="0" cellpadding="0" cellspacing="0" class="table width3">
|
||||
<tr>
|
||||
<th>'.$product->name.'</th>
|
||||
'.(!empty($product->reference) ? '<th width="150">'.$this->l('Ref:').' '.$product->reference.'</th>' : '').'
|
||||
'.(!empty($product->ean13) ? '<th width="120">'.$this->l('EAN13:').' '.$product->ean13.'</th>' : '').'
|
||||
'.(Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="50">'.$this->l('Qty:').' '.$product->quantity.'</th>' : '').'
|
||||
</tr>
|
||||
</table>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '
|
||||
<h3><a href="?tab=AdminCatalog&id_product='.$product->id.'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)).'">'.$product->name.'</a></h3>
|
||||
<table border="0" cellpadding="0" cellspacing="0" class="table" style="width: 600px;">
|
||||
<tr>
|
||||
<th>'.$this->l('Attribute name').'</th>
|
||||
<th width="80">'.$this->l('Reference').'</th>
|
||||
<th width="80">'.$this->l('EAN13').'</th>
|
||||
'.(Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="40">'.$this->l('Quantity').'</th>' : '').'
|
||||
</tr>';
|
||||
/* Build attributes combinaisons */
|
||||
$combinaisons = $product->getAttributeCombinaisons(intval($cookie->id_lang));
|
||||
foreach ($combinaisons AS $k => $combinaison)
|
||||
{
|
||||
$combArray[$combinaison['id_product_attribute']]['reference'] = $combinaison['reference'];
|
||||
$combArray[$combinaison['id_product_attribute']]['ean13'] = $combinaison['ean13'];
|
||||
$combArray[$combinaison['id_product_attribute']]['quantity'] = $combinaison['quantity'];
|
||||
$combArray[$combinaison['id_product_attribute']]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']);
|
||||
}
|
||||
$irow = 0;
|
||||
foreach ($combArray AS $id_product_attribute => $product_attribute)
|
||||
{
|
||||
$list = '';
|
||||
foreach ($product_attribute['attributes'] AS $attribute)
|
||||
$list .= $attribute[0].' - '.$attribute[1].', ';
|
||||
$list = rtrim($list, ', ');
|
||||
echo '
|
||||
<tr'.($irow++ % 2 ? ' class="alt_row"' : '').' >
|
||||
<td>'.stripslashes($list).'</td>
|
||||
<td>'.$product_attribute['reference'].'</td>
|
||||
'.(Configuration::get('PS_STOCK_MANAGEMENT') ? '<td>'.$product_attribute['ean13'].'</td>' : '').'
|
||||
<td class="right">'.$product_attribute['quantity'].'</td>
|
||||
</tr>';
|
||||
}
|
||||
unset($combArray);
|
||||
echo '</table>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Orders tab for admin panel, AdminOrders.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminMessages extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
$this->table = 'order';
|
||||
$this->className = 'Order';
|
||||
$this->view = 'noActionColumn';
|
||||
$this->colorOnBackground = true;
|
||||
|
||||
$start = 0;
|
||||
$this->_defaultOrderBy = 'date_add';
|
||||
|
||||
/* Manage default params values */
|
||||
if (empty($limit))
|
||||
$limit = ((!isset($cookie->{$this->table.'_pagination'})) ? $this->_pagination[0] : $limit = $cookie->{$this->table.'_pagination'});
|
||||
|
||||
if (!Validate::isTableOrIdentifier($this->table))
|
||||
die (Tools::displayError('Table name is invalid:').' "'.$this->table.'"');
|
||||
|
||||
if (empty($orderBy))
|
||||
$orderBy = Tools::getValue($this->table.'Orderby', $this->_defaultOrderBy);
|
||||
elseif ($orderBy == 'id_order')
|
||||
$orderBy = 'm.id_order';
|
||||
|
||||
if (empty($orderWay))
|
||||
$orderWay = Tools::getValue($this->table.'Orderway', 'ASC');
|
||||
|
||||
$limit = intval(Tools::getValue('pagination', $limit));
|
||||
$cookie->{$this->table.'_pagination'} = $limit;
|
||||
|
||||
/* Check params validity */
|
||||
if (!Validate::isOrderBy($orderBy) OR !Validate::isOrderWay($orderWay)
|
||||
OR !is_numeric($start) OR !is_numeric($limit))
|
||||
die(Tools::displayError('get list params is not valid'));
|
||||
|
||||
if ($orderBy == 'id_order')
|
||||
$orderBy = 'm.id_order';
|
||||
|
||||
/* Determine offset from current page */
|
||||
if ((isset($_POST['submitFilter'.$this->table]) OR
|
||||
isset($_POST['submitFilter'.$this->table.'_x']) OR
|
||||
isset($_POST['submitFilter'.$this->table.'_y'])) AND
|
||||
!empty($_POST['submitFilter'.$this->table]) AND
|
||||
is_numeric($_POST['submitFilter'.$this->table]))
|
||||
$start = intval($_POST['submitFilter'.$this->table] - 1) * $limit;
|
||||
|
||||
$this->_list = Db::getInstance()->ExecuteS('
|
||||
SELECT m.id_message, m.id_cart, m.id_employee, IF(m.id_order > 0, m.id_order, \'--\') id_order, m.message, m.private, m.date_add, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS customer,
|
||||
c.id_customer, count(m.id_message) nb_messages, (SELECT message FROM '._DB_PREFIX_.'message WHERE id_order = m.id_order ORDER BY date_add DESC LIMIT 1) last_message,
|
||||
(SELECT COUNT(m2.id_message) FROM '._DB_PREFIX_.'message m2 WHERE 1 AND m2.id_customer != 0 AND m2.id_order = m.id_order AND m2.id_message NOT IN
|
||||
(SELECT mr2.id_message FROM '._DB_PREFIX_.'message_readed mr2 WHERE mr2.id_employee = '.intval($cookie->id_employee).') GROUP BY m2.id_order) nb_messages_not_read_by_me
|
||||
FROM '._DB_PREFIX_.'message m
|
||||
LEFT JOIN '._DB_PREFIX_.'orders o ON (o.id_order = m.id_order)
|
||||
LEFT JOIN '._DB_PREFIX_.'customer c ON (c.id_customer = m.id_customer)
|
||||
GROUP BY m.id_order
|
||||
ORDER BY '.(isset($orderBy) ? pSQL($orderBy) : 'date_add') .' '.(isset($orderWay) ? pSQL($orderWay) : 'DESC').'
|
||||
LIMIT '.intval($start).','.intval($limit));
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_order' => array('title' => $this->l('Order ID'), 'align' => 'center', 'width' => 30),
|
||||
'id_customer' => array('title' => $this->l('Customer ID'), 'align' => 'center', 'width' => 30),
|
||||
'customer' => array('title' => $this->l('Customer'), 'width' => 100, 'filter_key' => 'customer', 'tmpTableFilter' => true),
|
||||
'last_message' => array('title' => $this->l('Last message'), 'width' => 400, 'orderby' => false),
|
||||
'nb_messages_not_read_by_me' => array('title' => $this->l('Unread message(s)'), 'width' =>30, 'align' => 'center'),
|
||||
'nb_messages' => array('title' => $this->l('Number of messages'), 'width' => 30, 'align' => 'center'));
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
if (isset($_GET['view'.$this->table]) AND !empty($_GET['id_order']) AND $_GET['id_order'] != '--')
|
||||
Tools::redirectAdmin('index.php?tab=AdminOrders&id_order='.intval($_GET['id_order']).'&vieworder'.'&token='.Tools::getAdminToken('AdminOrders'.intval(Tab::getIdFromClassName('AdminOrders')).intval($cookie->id_employee)));
|
||||
else
|
||||
{
|
||||
if (isset($_GET['id_order']) AND (empty($_GET['id_order']) OR $_GET['id_order'] == '--'))
|
||||
{
|
||||
echo '<p class="warning bold"><img src="../img/admin/warning.gif" alt="" class="middle" /> '.
|
||||
Tools::displayError('Cannot display this message because the customer has not finalized its order').'</p>';
|
||||
}
|
||||
foreach ($this->_list AS $k => $item)
|
||||
if (Tools::strlen($item['last_message']) > 150 + Tools::strlen('...'))
|
||||
$this->_list[$k]['last_message'] = Tools::substr(html_entity_decode($item['last_message'], ENT_QUOTES, 'UTF-8'), 0, 150, 'UTF-8').'...';
|
||||
$this->displayList();
|
||||
$this->displayOptionsList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Suppliers tab for admin panel, AdminSuppliers.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminMeta extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'meta';
|
||||
$this->className = 'Meta';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_meta' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'page' => array('title' => $this->l('Page'), 'width' => 120, 'suffix' => '.php'),
|
||||
'title' => array('title' => $this->l('Title'), 'width' => 120),
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$meta = $this->loadObject(true);
|
||||
$files = Meta::getPages(true, ($meta->page ? $meta->page : false));
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&token='.$this->token.'&submitAdd'.$this->table.'=1" method="post" class="width3" style="width:650px;">
|
||||
'.($meta->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$meta->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/admin/metatags.gif" />'.$this->l('Meta-Tags').'</legend>
|
||||
<label>'.$this->l('Page:').' </label>
|
||||
<div class="margin-form">';
|
||||
if (!sizeof($files))
|
||||
echo '<p>'.$this->l('There is no page available!').'</p>';
|
||||
else
|
||||
{
|
||||
echo '
|
||||
<select name="page">';
|
||||
foreach ($files as $file)
|
||||
{
|
||||
echo '<option value="'.$file.'"';
|
||||
echo $meta->page == $file? ' selected="selected"' : '' ;
|
||||
echo'>'.$file.'.php </option>';
|
||||
}
|
||||
echo '
|
||||
</select><sup> *</sup>
|
||||
<p class="clear">'.$this->l('Name of the related page').'</p>';
|
||||
}
|
||||
echo '
|
||||
</div>
|
||||
<label>'.$this->l('Page\'s title:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="title_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="33" type="text" name="title_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($meta, 'title', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
<p class="clear">'.$this->l('Title of this page').'</p>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'title¤description¤keywords', 'title');
|
||||
echo ' </div>
|
||||
<div style="clear:both;"> </div>
|
||||
<label>'.$this->l('Meta description:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="description_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="50" type="text" name="description_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($meta, 'description', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
<p class="clear">'.$this->l('A short description').'</p>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'title¤description¤keywords', 'description');
|
||||
echo ' </div>
|
||||
<div style="clear:both;"> </div>
|
||||
<label>'.$this->l('Meta keywords:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="keywords_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="50" type="text" name="keywords_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($meta, 'keywords', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
<p class="clear">'.$this->l('List of keywords').'</p>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'title¤description¤keywords', 'keywords');
|
||||
echo ' </div>
|
||||
<div style="clear:both;"> </div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,378 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Modules tab for admin panel, AdminModules.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminModules extends AdminTab
|
||||
{
|
||||
/** @var array map with $_GET keywords and their callback */
|
||||
private $map = array(
|
||||
'install' => 'install',
|
||||
'uninstall' => 'uninstall',
|
||||
'configure' => 'getContent'
|
||||
);
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
|
||||
if (Tools::isSubmit('all_module_send'))
|
||||
{
|
||||
if (Tools::getValue('all_module'))
|
||||
Configuration::updateValue('PS_SHOW_ALL_MODULES', 0);
|
||||
else
|
||||
Configuration::updateValue('PS_SHOW_ALL_MODULES', 1);
|
||||
}
|
||||
/* Automatically copy a module from external URL and unarchive it in the appropriated directory */
|
||||
if (Tools::isSubmit('active'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
$module = Module::getInstanceByName(strval(Tools::getValue('module_name')));
|
||||
if (Validate::isLoadedObject($module))
|
||||
{
|
||||
Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'module`
|
||||
SET `active`= 1
|
||||
WHERE `name` = \''.pSQL(Tools::getValue('module_name')).'\'');
|
||||
Tools::redirectAdmin($currentIndex.'&conf=5'.'&token='.$this->token);
|
||||
} else
|
||||
$this->_errors[] = Tools::displayError('Cannot load module object');
|
||||
} else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to add anything here.');
|
||||
}
|
||||
elseif (Tools::isSubmit('desactive'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
$module = Module::getInstanceByName(Tools::getValue('module_name'));
|
||||
if (Validate::isLoadedObject($module))
|
||||
{
|
||||
Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'module`
|
||||
SET `active`= 0
|
||||
WHERE `name` = \''.pSQL(Tools::getValue('module_name')).'\'');
|
||||
Tools::redirectAdmin($currentIndex.'&conf=5'.'&token='.$this->token);
|
||||
} else
|
||||
$this->_errors[] = Tools::displayError('Cannot load module object');
|
||||
} else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to add anything here.');
|
||||
}
|
||||
if (Tools::isSubmit('submitDownload'))
|
||||
{
|
||||
if ($this->tabAccess['add'] === '1')
|
||||
{
|
||||
if (Validate::isModuleUrl($url = Tools::getValue('url'), $this->_errors))
|
||||
{
|
||||
if (!@copy($url, _PS_MODULE_DIR_.basename($url)))
|
||||
$this->_errors[] = Tools::displayError('404 Module not found');
|
||||
else
|
||||
$this->extractArchive(_PS_MODULE_DIR_.basename($url));
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to add anything here.');
|
||||
}
|
||||
if (Tools::isSubmit('submitDownload2'))
|
||||
{
|
||||
if ($this->tabAccess['add'] === '1')
|
||||
{
|
||||
if (!isset($_FILES['file']['tmp_name']) OR empty($_FILES['file']['tmp_name']))
|
||||
$this->_errors[] = $this->l('no file selected');
|
||||
elseif (substr($_FILES['file']['name'], -4) != '.tar' AND substr($_FILES['file']['name'], -4) != '.zip' AND substr($_FILES['file']['name'], -4) != '.tgz' AND substr($_FILES['file']['name'], -7) != '.tar.gz')
|
||||
$this->_errors[] = Tools::displayError('unknown archive type');
|
||||
elseif (!@copy($_FILES['file']['tmp_name'], _PS_MODULE_DIR_.$_FILES['file']['name']))
|
||||
$this->_errors[] = Tools::displayError('an error occured while copying archive to module directory');
|
||||
else
|
||||
$this->extractArchive(_PS_MODULE_DIR_.$_FILES['file']['name']);
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to add anything here.');
|
||||
}
|
||||
/* Call appropriate module callback */
|
||||
else
|
||||
{
|
||||
$return = false;
|
||||
foreach ($this->map as $key => $method)
|
||||
{
|
||||
$modules = Tools::getValue($key);
|
||||
if (strpos($modules, '|'))
|
||||
$modules = explode('|', $modules);
|
||||
else
|
||||
$modules = empty($modules) ? false : array($modules);
|
||||
$module_errors = array();
|
||||
if ($modules)
|
||||
foreach ($modules AS $name)
|
||||
{
|
||||
if (!($module = @Module::getInstanceByName(urldecode($name))))
|
||||
$this->_errors[] = $this->l('module not found');
|
||||
elseif ($key == 'install' AND $this->tabAccess['add'] !== '1')
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to add anything here.');
|
||||
elseif ($key == 'uninstall' AND $this->tabAccess['delete'] !== '1')
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
elseif ($key == 'configure' AND $this->tabAccess['edit'] !== '1')
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
elseif (($echo = $module->{$method}()) AND ($key == 'configure'))
|
||||
{
|
||||
echo '
|
||||
<p><a href="'.$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to modules list').'</a></p>
|
||||
<br />'.$echo.'<br />
|
||||
<p><a href="'.$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to modules list').'</a></p>';
|
||||
}
|
||||
elseif($echo)
|
||||
$return = ($method == 'install' ? 12 : 13);
|
||||
elseif ($echo === false)
|
||||
$module_errors[] = $name;
|
||||
if ($key != 'configure' AND isset($_GET['bpay']))
|
||||
Tools::redirectAdmin('index.php?tab=AdminPayment&token='.Tools::getAdminToken('AdminPayment'.intval(Tab::getIdFromClassName('AdminPayment')).intval($cookie->id_employee)));
|
||||
}
|
||||
if (sizeof($module_errors))
|
||||
{
|
||||
echo '<div class="alert">'.$this->l('The following module(s) were not installed successfully:').'<ul>';
|
||||
foreach ($module_errors AS $module_error)
|
||||
echo '<li>'.$module_error.'</li>';
|
||||
echo '</ul></div>';
|
||||
}
|
||||
}
|
||||
if ($return)
|
||||
Tools::redirectAdmin($currentIndex.'&conf='.$return.'&token='.$this->token);
|
||||
}
|
||||
}
|
||||
|
||||
function extractArchive($file)
|
||||
{
|
||||
global $currentIndex;
|
||||
$success = false;
|
||||
if (substr($file, -4) == '.zip')
|
||||
{
|
||||
if (class_exists('ZipArchive', false))
|
||||
{
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($file) === true AND $zip->extractTo(_PS_MODULE_DIR_) AND $zip->close())
|
||||
$success = true;
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('error while extracting module (file may be corrupted)');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('zip is not installed on your server. Ask your host for further information.');
|
||||
}
|
||||
else
|
||||
{
|
||||
$archive = new Archive_Tar($file);
|
||||
if ($archive->extract(_PS_MODULE_DIR_))
|
||||
$success = true;
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('error while extracting module (file may be corrupted)');
|
||||
}
|
||||
|
||||
@unlink($file);
|
||||
if ($success)
|
||||
Tools::redirectAdmin($currentIndex.'&conf=8'.'&token='.$this->token);
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
if (!isset($_GET['configure']) OR sizeof($this->_errors))
|
||||
$this->displayList();
|
||||
}
|
||||
|
||||
public function displayJavascript()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
function modules_management(action)
|
||||
{
|
||||
var modules = document.getElementsByName(\'modules\');
|
||||
var module_list = \'\';
|
||||
for (var i = 0; i < modules.length; i++)
|
||||
{
|
||||
if (modules[i].checked == true)
|
||||
{
|
||||
rel = modules[i].getAttribute(\'rel\');
|
||||
if (rel != "false" && action == "uninstall")
|
||||
{
|
||||
if (!confirm(rel))
|
||||
return false;
|
||||
}
|
||||
module_list += \'|\'+modules[i].value;
|
||||
}
|
||||
}
|
||||
document.location.href=\''.$currentIndex.'&token='.$this->token.'&\'+action+\'=\'+module_list.substring(1, module_list.length);
|
||||
}
|
||||
</script>';
|
||||
}
|
||||
|
||||
public function displayList()
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
|
||||
$serialModules = '';
|
||||
$modules = Module::getModulesOnDisk();
|
||||
foreach ($modules AS $module)
|
||||
$serialModules .= $module->name.' '.$module->version.'-'.($module->active ? 'a' : 'i')."\n";
|
||||
$serialModules = urlencode($serialModules);
|
||||
|
||||
$this->displayJavascript();
|
||||
|
||||
$linkToSettings = 'index.php?tab=AdminPreferences&token='.Tools::getAdminToken('AdminPreferences'.intval(Tab::getIdFromClassName('AdminPreferences')).intval($cookie->id_employee));
|
||||
echo '<span onclick="openCloseLayer(\'module_install\', 0);" style="cursor: pointer;font-weight: 700; float: left;"><img src="../img/admin/add.gif" alt="'.$this->l('Add a new module').'" class="middle" /> '.$this->l('Add a new module').'</span>';
|
||||
if (Configuration::get('PRESTASTORE_LIVE') AND @ini_get('allow_url_fopen'))
|
||||
echo '<script type="text/javascript">
|
||||
function getPrestaStore(){if (getE("prestastore").style.display!=\'block\')return;$.post("'.dirname($currentIndex).'/ajax.php",{page:"prestastore"},function(a){getE("prestastore-content").innerHTML=a;})}
|
||||
</script>
|
||||
<span onclick="openCloseLayer(\'prestastore\', 0); getPrestaStore();" style="cursor: pointer;font-weight: 700; float: left;margin-left:20px;"><img src="../img/admin/prestastore.gif" class="middle" /> '.$this->l('PrestaStore').'</span> (<a href="'.$linkToSettings.'">'.$this->l('disable').'</a>)';
|
||||
echo '
|
||||
<div class="clear"> </div>
|
||||
<div id="module_install" style="float: left;'.((Tools::isSubmit('submitDownload') OR Tools::isSubmit('submitDownload2')) ? '' : 'display: none;').'" class="width1">
|
||||
<fieldset class="width2">
|
||||
<legend><img src="../img/admin/add.gif" alt="'.$this->l('Add a new module').'" class="middle" /> '.$this->l('Add a new module').'</legend>
|
||||
<p>'.$this->l('The module must be either a zip file or a tarball.').'</p>
|
||||
<hr />
|
||||
<form action="'.$currentIndex.'&token='.$this->token.'" method="post">
|
||||
<label style="width: 100px">'.$this->l('Module URL:').'</label>
|
||||
<div class="margin-form" style="padding-left: 140px">
|
||||
<input type="text" name="url" style="width: 200px;" value="'.(Tools::getValue('url') ? Tools::getValue('url') : 'http://').'" />
|
||||
<p>'.$this->l('Download the module directly from a website.').'</p>
|
||||
</div>
|
||||
<div class="margin-form" style="padding-left: 140px">
|
||||
<input type="submit" name="submitDownload" value="'.$this->l('Download this module').'" class="button" />
|
||||
</div>
|
||||
</form>
|
||||
<hr />
|
||||
<form action="'.$currentIndex.'&token='.$this->token.'" method="post" enctype="multipart/form-data">
|
||||
<label style="width: 100px">'.$this->l('Module file:').'</label>
|
||||
<div class="margin-form" style="padding-left: 140px">
|
||||
<input type="file" name="file" />
|
||||
<p>'.$this->l('Upload the module from your computer.').'</p>
|
||||
</div>
|
||||
<div class="margin-form" style="padding-left: 140px">
|
||||
<input type="submit" name="submitDownload2" value="'.$this->l('Upload this module').'" class="button" />
|
||||
</div>
|
||||
</form>
|
||||
</fieldset>
|
||||
</div>';
|
||||
if (Configuration::get('PRESTASTORE_LIVE'))
|
||||
echo '
|
||||
<div id="prestastore" style="margin-left:40px; display:none; float: left" class="width1">
|
||||
<fieldset>
|
||||
<legend><img src="http://www.prestastore.com/modules.php?'.(isset($_SERVER['SERVER_ADDR']) ? 'server='.ip2long($_SERVER['SERVER_ADDR']).'&' : '').'mods='.$serialModules.'" class="middle" />'.$this->l('Live from PrestaStore!').'</legend>
|
||||
<div id="prestastore-content"></div>
|
||||
</fieldset>
|
||||
</div>';
|
||||
echo '<div class="clear"> </div>';
|
||||
|
||||
/* Scan modules directories and load modules classes */
|
||||
$warnings = array();
|
||||
$orderModule = array();
|
||||
$irow = 0;
|
||||
foreach ($modules AS $module)
|
||||
$orderModule[(isset($module->tab) AND !empty($module->tab)) ? $module->tab : $this->l('Not specified')][] = $module;
|
||||
asort($orderModule);
|
||||
|
||||
foreach ($orderModule AS $tabModule)
|
||||
foreach ($tabModule AS $module)
|
||||
if ($module->active AND $module->warning)
|
||||
$this->displayWarning('<a href="'.$currentIndex.'&configure='.urlencode($module->name).'&token='.$this->token.'">'.$module->displayName.'</a> - '.stripslashes(pSQL($module->warning)));
|
||||
|
||||
$nameCountryDefault = Country::getNameById($cookie->id_lang, Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
echo '
|
||||
<form method="POST" id="form_all_module" name="fomr_all_module" action="">
|
||||
<input type="hidden" name="all_module_send" value="" />
|
||||
<input type="checkbox" name="all_module" style="vertical-align: middle;" id="all_module" '.(!Configuration::get('PS_SHOW_ALL_MODULES') ? 'checked="checked"' : '').' onclick="document.getElementById(\'form_all_module\').submit();" />
|
||||
<label class="t" for="all_module">'.$this->l('Show only modules that can be used in my country').'</label> ('.$this->l('Current country:').' <a href="index.php?tab=AdminCountries&token='.Tools::getAdminToken('AdminCountries'.intval(Tab::getIdFromClassName('AdminCountries')).intval($cookie->id_employee)).'">'.$nameCountryDefault.'</a>)
|
||||
</form>';
|
||||
|
||||
$showAllModules = Configuration::get('PS_SHOW_ALL_MODULES');
|
||||
$isoCountryDefault = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
|
||||
echo '
|
||||
<div style="float:left; width:300px;">';
|
||||
/* Browse modules by tab type */
|
||||
foreach ($orderModule AS $tab => $tabModule)
|
||||
{
|
||||
echo '<br />
|
||||
<table cellpadding="0" cellspacing="0" class="table width3">
|
||||
<tr>
|
||||
<th colspan="4" class="center" style="cursor: pointer" onclick="openCloseLayer(\''.addslashes($tab).'\');"><b>'.$tab.'</b> - <span style="color: red">'.sizeof($tabModule).'</span> '.((sizeof($tabModule) > 1) ? $this->l('modules') : $this->l('module')).'</th>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="'.$tab.'" style="width:600px;">
|
||||
<table cellpadding="0" cellspacing="0" class="table width3">';
|
||||
|
||||
/* Display modules for each tab type */
|
||||
foreach ($tabModule as $module)
|
||||
{
|
||||
if ($showAllModules || (!$showAllModules && ((isset($module->limited_countries) && in_array(strtolower($isoCountryDefault), $module->limited_countries)) || !isset($module->limited_countries))))
|
||||
{
|
||||
if ($module->id)
|
||||
{
|
||||
$img = '<img src="../img/admin/enabled.gif" alt="'.$this->l('Module enabled').'" title="'.$this->l('Module enabled').'" />';
|
||||
if ($module->warning)
|
||||
$img = '<img src="../img/admin/warning.gif" alt="'.$this->l('Module installed but with warnings').'" title="'.$this->l('Module installed but with warnings').'" />';
|
||||
if (!$module->active)
|
||||
$img = '<img src="../img/admin/disabled.gif" alt="'.$this->l('Module disabled').'" title="'.$this->l('Module disabled').'" />';
|
||||
} else
|
||||
$img = '<img src="../img/admin/cog.gif" alt="'.$this->l('Module not installed').'" title="'.$this->l('Module not installed').'" />';
|
||||
echo '
|
||||
<tr'.($irow++ % 2 ? ' class="alt_row"' : '').' style="height: 42px;">
|
||||
<td style="padding-left: 10px;"><img src="../modules/'.$module->name.'/logo.gif" alt="" /> <b>'.stripslashes($module->displayName).'</b>'.($module->version ? ' v'.$module->version.(strpos($module->version, '.') !== false ? '' : '.0') : '').'<br />'.$module->description.'</td>
|
||||
<td width="85">'.(($module->id AND method_exists($module, 'getContent')) ? '<a href="'.$currentIndex.'&configure='.urlencode($module->name).'&token='.$this->token.'">>> '.$this->l('Configure').'</a>' : '').'</td>
|
||||
<td class="center" width="20">';
|
||||
if ($module->id)
|
||||
echo '<a href="'.$currentIndex.'&token='.$this->token.'&module_name='.$module->name.'&'.($module->active ? 'desactive' : 'active').'">';
|
||||
echo $img;
|
||||
if ($module->id)
|
||||
'</a>';
|
||||
echo '
|
||||
</td>
|
||||
<td class="center" width="80">'.((!$module->id)
|
||||
? '<input type="button" class="button small" name="Install" value="'.$this->l('Install').'"
|
||||
onclick="javascript:document.location.href=\''.$currentIndex.'&install='.urlencode($module->name).'&token='.$this->token.'\'" />'
|
||||
: '<input type="button" class="button small" name="Uninstall" value="'.$this->l('Uninstall').'"
|
||||
onclick="'.(empty($module->confirmUninstall) ? '' : 'if(confirm(\''.addslashes($module->confirmUninstall).'\')) ').'document.location.href=\''.$currentIndex.'&uninstall='.urlencode($module->name).'&token='.$this->token.'\';" />').'</td>
|
||||
<td style="padding-right: 10px">
|
||||
<input type="checkbox" name="modules" value="'.urlencode($module->name).'" '.(empty($module->confirmUninstall) ? 'rel="false"' : 'rel="'.addslashes($module->confirmUninstall).'"').' />
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
echo '</table>
|
||||
</div>';
|
||||
}
|
||||
echo '
|
||||
<div style="margin-top: 12px; width:600px;" class="center">
|
||||
<input type="button" class="button small" value="'.$this->l('Install the selection').'" onclick="modules_management(\'install\')"/>
|
||||
<input type="button" class="button small" value="'.$this->l('Uninstall the selection').'" onclick="modules_management(\'uninstall\')" />
|
||||
</div>
|
||||
</div>
|
||||
<div style="float:right; width:300px;">
|
||||
<br />
|
||||
<table cellpadding="0" cellspacing="0" class="table width3" style="width:300px;"><tr><th colspan="4" class="center"><strong>'.$this->l('Icon legend').'</strong></th></tr></table>
|
||||
<table cellpadding="0" cellspacing="0" class="table width3" style="width:300px;"><tr style="height: 42px;">
|
||||
<td>
|
||||
<table cellpadding="10" cellspacing="5">
|
||||
<tr><td><img src="../img/admin/cog.gif" /> '.$this->l('Module not installed').'</td></tr>
|
||||
<tr><td><img src="../img/admin/enabled.gif" /> '.$this->l('Module installed and enabled').'</td></tr>
|
||||
<tr><td><img src="../img/admin/disabled.gif" /> '.$this->l('Module installed but disabled').'</td></tr>
|
||||
<tr><td><img src="../img/admin/warning.gif" /> '.$this->l('Module installed but some warnings').'</td></tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr></table>
|
||||
</div>
|
||||
<div style="clear:both"> </div>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,315 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Modules positions tab for admin panel, AdminModulesPositions.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminModulesPositions extends AdminTab
|
||||
{
|
||||
private $displayKey = 0;
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
// Getting key value for display
|
||||
if (Tools::getValue('show_modules') AND strval(Tools::getValue('show_modules')) != 'all')
|
||||
$this->displayKey = intval(Tools::getValue('show_modules'));
|
||||
|
||||
// Change position in hook
|
||||
if (array_key_exists('changePosition', $_GET))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
$id_module = intval(Tools::getValue('id_module'));
|
||||
$id_hook = intval(Tools::getValue('id_hook'));
|
||||
$module = Module::getInstanceById($id_module);
|
||||
if (Validate::isLoadedObject($module))
|
||||
{
|
||||
$module->updatePosition($id_hook, intval(Tools::getValue('direction')));
|
||||
Tools::redirectAdmin($currentIndex.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('module cannot be loaded');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
|
||||
// Add new module in hook
|
||||
elseif (Tools::isSubmit('submitAddToHook'))
|
||||
{
|
||||
if ($this->tabAccess['add'] === '1')
|
||||
{
|
||||
// Getting vars...
|
||||
$id_module = intval(Tools::getValue('id_module'));
|
||||
$module = Module::getInstanceById($id_module);
|
||||
$id_hook = intval(Tools::getValue('id_hook'));
|
||||
$hook = new Hook($id_hook);
|
||||
$excepts = explode(',', str_replace(' ', '', Tools::getValue('exceptions')));
|
||||
|
||||
// Checking vars...
|
||||
foreach ($excepts AS $except)
|
||||
if (!Validate::isFileName($except))
|
||||
$this->_errors[] = Tools::displayError('no valid value for field exceptions');
|
||||
if (!$id_module OR !Validate::isLoadedObject($module))
|
||||
$this->_errors[] = Tools::displayError('module cannot be loaded');
|
||||
elseif (!$id_hook OR !Validate::isLoadedObject($hook))
|
||||
$this->_errors[] = Tools::displayError('hook cannot be loaded');
|
||||
elseif (Hook::getModuleFromHook($id_hook, $id_module))
|
||||
$this->_errors[] = Tools::displayError('this module is already transplanted to this hook');
|
||||
|
||||
// Adding vars...
|
||||
elseif (!$module->registerHook($hook->name))
|
||||
$this->_errors[] = Tools::displayError('an error occurred while transplanting module to hook');
|
||||
elseif (!$module->registerExceptions($id_hook, $excepts))
|
||||
$this->_errors[] = Tools::displayError('an error occurred while transplanting module to hook');
|
||||
else
|
||||
Tools::redirectAdmin($currentIndex.'&conf=16'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to add anything here.');
|
||||
}
|
||||
|
||||
// Edit module from hook
|
||||
elseif (Tools::isSubmit('submitEditGraft'))
|
||||
{
|
||||
if ($this->tabAccess['add'] === '1')
|
||||
{
|
||||
// Getting vars...
|
||||
$id_module = intval(Tools::getValue('id_module'));
|
||||
$module = Module::getInstanceById($id_module);
|
||||
$id_hook = intval(Tools::getValue('id_hook'));
|
||||
$hook = new Hook($id_hook);
|
||||
$excepts = explode(',', str_replace(' ', '', Tools::getValue('exceptions')));
|
||||
|
||||
// Checking vars...
|
||||
foreach ($excepts AS $except)
|
||||
if (!Validate::isFileName($except))
|
||||
$this->_errors[] = Tools::displayError('no valid value for field exceptions');
|
||||
if (!$id_module OR !Validate::isLoadedObject($module))
|
||||
$this->_errors[] = Tools::displayError('module cannot be loaded');
|
||||
elseif (!$id_hook OR !Validate::isLoadedObject($hook))
|
||||
$this->_errors[] = Tools::displayError('hook cannot be loaded');
|
||||
|
||||
// Adding vars...
|
||||
if (!$module->editExceptions($id_hook, $excepts))
|
||||
$this->_errors[] = Tools::displayError('an error occurred while transplanting module to hook');
|
||||
else
|
||||
Tools::redirectAdmin($currentIndex.'&conf=16'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to add anything here.');
|
||||
}
|
||||
|
||||
// Delete module from hook
|
||||
elseif (array_key_exists('deleteGraft', $_GET))
|
||||
{
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
$id_module = intval(Tools::getValue('id_module'));
|
||||
$module = Module::getInstanceById($id_module);
|
||||
$id_hook = intval(Tools::getValue('id_hook'));
|
||||
$hook = new Hook($id_hook);
|
||||
if (!Validate::isLoadedObject($module))
|
||||
$this->_errors[] = Tools::displayError('module cannot be loaded');
|
||||
elseif (!$id_hook OR !Validate::isLoadedObject($hook))
|
||||
$this->_errors[] = Tools::displayError('hook cannot be loaded');
|
||||
else
|
||||
{
|
||||
if (!$module->unregisterHook($id_hook) OR !$module->unregisterExceptions($id_hook))
|
||||
$this->_errors[] = Tools::displayError('an error occurred while deleting module from hook');
|
||||
else
|
||||
Tools::redirectAdmin($currentIndex.'&conf=17'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
if (array_key_exists('addToHook', $_GET) OR array_key_exists('editGraft', $_GET) OR (Tools::isSubmit('submitAddToHook') AND $this->_errors))
|
||||
$this->displayForm();
|
||||
else
|
||||
$this->displayList();
|
||||
}
|
||||
|
||||
public function displayList()
|
||||
{
|
||||
global $currentIndex;
|
||||
echo '
|
||||
<script type="text/javascript" src="../js/jquery/jquery.tablednd_0_5.js"></script>
|
||||
<script type="text/javascript">
|
||||
var token = \''.$this->token.'\';
|
||||
var come_from = \'AdminModulesPositions\';
|
||||
</script>
|
||||
<script type="text/javascript" src="../js/admin-dnd.js"></script>
|
||||
';
|
||||
echo '<a href="'.$currentIndex.'&addToHook'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> <b>'.$this->l('Transplant a module').'</b></a><br /><br />';
|
||||
|
||||
// Print select list
|
||||
echo '
|
||||
<form>
|
||||
'.$this->l('Show').' :
|
||||
<select id="show_modules" onChange="autoUrl(\'show_modules\', \''.$currentIndex.'&token='.$this->token.'&show_modules=\')">
|
||||
<option value="all">'.$this->l('All modules').' </option>
|
||||
<option>---------------</option>';
|
||||
$modules = Module::getModulesInstalled();
|
||||
|
||||
foreach ($modules AS $module)
|
||||
if ($tmpInstance = Module::getInstanceById(intval($module['id_module'])))
|
||||
$cm[$tmpInstance->displayName] = $tmpInstance;
|
||||
ksort($cm);
|
||||
foreach ($cm AS $module)
|
||||
echo '
|
||||
<option value="'.intval($module->id).'" '.($this->displayKey == $module->id ? 'selected="selected" ' : '').'>'.$module->displayName.'</option>';
|
||||
echo '
|
||||
</select><br /><br />
|
||||
<input type="checkbox" id="hook_position" onclick="autoUrlNoList(\'hook_position\', \''.$currentIndex.'&token='.$this->token.'&show_modules='.intval(Tools::getValue('show_modules')).'&hook_position=\')" '.(Tools::getValue('hook_position') ? 'checked="checked" ' : '').' /> '.$this->l('Display non-positionnable hook').'
|
||||
</form>';
|
||||
|
||||
// Print hook list
|
||||
$irow = 0;
|
||||
$hooks = Hook::getHooks(!intval(Tools::getValue('hook_position')));
|
||||
foreach ($hooks AS $hook)
|
||||
{
|
||||
$modules = array();
|
||||
if (!$this->displayKey)
|
||||
$modules = Hook::getModulesFromHook($hook['id_hook']);
|
||||
elseif ($res = Hook::getModuleFromHook($hook['id_hook'], $this->displayKey))
|
||||
$modules[0] = $res;
|
||||
$nbModules = sizeof($modules);
|
||||
echo '
|
||||
<a name="'.$hook['name'].'"/>
|
||||
<table cellpadding="0" cellspacing="0" class="table width3 space'.($nbModules >= 2? ' tableDnD' : '' ).'" id="'.$hook['id_hook'].'">
|
||||
<tr class="nodrag nodrop"><th colspan="4">'.$hook['title'].' - <span style="color: red">'.$nbModules.'</span> '.(($nbModules > 1) ? $this->l('modules') : $this->l('module'));
|
||||
if (!empty($hook['description']))
|
||||
echo ' <span style="font-size:0.8em; font-weight: normal">['.$hook['description'].']</span>';
|
||||
echo '</th></tr>';
|
||||
|
||||
// Print modules list
|
||||
if ($nbModules)
|
||||
{
|
||||
$instances = array();
|
||||
foreach ($modules AS $module)
|
||||
if ($tmpInstance = Module::getInstanceById(intval($module['id_module'])))
|
||||
$instances[$tmpInstance->getPosition($hook['id_hook'])] = $tmpInstance;
|
||||
ksort($instances);
|
||||
foreach ($instances AS $position => $instance)
|
||||
{
|
||||
echo '
|
||||
<tr id="'.$hook['id_hook'].'_'.$instance->id.'"'.($irow++ % 2 ? ' class="alt_row"' : '').' style="height: 42px;">';
|
||||
if (!$this->displayKey)
|
||||
{
|
||||
echo '
|
||||
<td class="positions" width="40">'.intval($position).'</td>
|
||||
<td'.($nbModules >= 2? ' class="dragHandle"' : '').' id="td_'.$hook['id_hook'].'_'.$instance->id.'" width="40">
|
||||
<a'.($position == 1 ? ' style="display: none;"' : '' ).' href="'.$currentIndex.'&id_module='.$instance->id.'&id_hook='.$hook['id_hook'].'&direction=0&token='.$this->token.'&changePosition='.rand().'#'.$hook['name'].'"><img src="../img/admin/up.gif" alt="'.$this->l('Up').'" title="'.$this->l('Up').'" /></a><br />
|
||||
<a '.($position == sizeof($instances) ? ' style="display: none;"' : '').'href="'.$currentIndex.'&id_module='.$instance->id.'&id_hook='.$hook['id_hook'].'&direction=1&token='.$this->token.'&changePosition='.rand().'#'.$hook['name'].'"><img src="../img/admin/down.gif" alt="'.$this->l('Down').'" title="'.$this->l('Down').'" /></a>
|
||||
</td>
|
||||
<td style="padding-left: 10px;">
|
||||
';
|
||||
}
|
||||
else
|
||||
echo '<td style="padding-left: 10px;" colspan="3">';
|
||||
echo '
|
||||
<img src="../modules/'.$instance->name.'/logo.gif" alt="'.stripslashes($instance->name).'" /> <strong>'.stripslashes($instance->displayName).'</strong>
|
||||
'.($instance->version ? ' v'.(intval($instance->version) == $instance->version? sprintf('%.1f', $instance->version) : floatval($instance->version)) : '').'<br />'.$instance->description.'
|
||||
</td>
|
||||
<td width="40">
|
||||
<a href="'.$currentIndex.'&id_module='.$instance->id.'&id_hook='.$hook['id_hook'].'&editGraft'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token.'"><img src="../img/admin/edit.gif" border="0" alt="'.$this->l('Edit').'" title="'.$this->l('Edit').'" /></a>
|
||||
<a href="'.$currentIndex.'&id_module='.$instance->id.'&id_hook='.$hook['id_hook'].'&deleteGraft'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token.'"><img src="../img/admin/delete.gif" border="0" alt="'.$this->l('Delete').'" title="'.$this->l('Delete').'" /></a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
} else
|
||||
echo '<tr><td colspan="4">'.$this->l('No module for this hook').'</td></tr>';
|
||||
echo '</table>';
|
||||
}
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$id_module = intval(Tools::getValue('id_module'));
|
||||
$id_hook = intval(Tools::getValue('id_hook'));
|
||||
if ($id_module AND $id_hook AND Tools::isSubmit('editGraft'))
|
||||
{
|
||||
$slModule = Module::getInstanceById($id_module);
|
||||
$exceptsList = $slModule->getExceptions($id_hook);
|
||||
$excepts = '';
|
||||
foreach ($exceptsList as $key => $except)
|
||||
$excepts .= ($key ? ',' : '').$except['file_name'];
|
||||
}
|
||||
$excepts = strval(Tools::getValue('exceptions', ((isset($slModule) AND Validate::isLoadedObject($slModule)) ? $excepts : '')));
|
||||
$modules = Module::getModulesInstalled(0);
|
||||
|
||||
$instances = array();
|
||||
foreach ($modules AS $module)
|
||||
if ($tmpInstance = Module::getInstanceById($module['id_module']))
|
||||
$instances[$tmpInstance->displayName] = $tmpInstance;
|
||||
ksort($instances);
|
||||
$modules = $instances;
|
||||
$hooks = Hook::getHooks(0);
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&token='.$this->token.'" method="post">';
|
||||
if ($this->displayKey)
|
||||
echo '<input type="hidden" name="show_modules" value="'.$this->displayKey.'" />';
|
||||
echo '<fieldset class="width3" style="width:700px;"><legend><img src="../img/t/AdminModulesPositions.gif" />'.$this->l('Transplant a module').'</legend>
|
||||
<label>'.$this->l('Module').' :</label>
|
||||
<div class="margin-form">
|
||||
<select name="id_module"'.(Tools::isSubmit('editGraft') ? ' disabled="disabled"' : '').'>';
|
||||
foreach ($modules AS $module)
|
||||
echo '
|
||||
<option value="'.$module->id.'" '.($id_module == $module->id ? 'selected="selected" ' : '').'>'.stripslashes($module->displayName).'</option>';
|
||||
echo '
|
||||
</select><sup> *</sup>
|
||||
</div>
|
||||
<label>'.$this->l('Hook into').' :</label>
|
||||
<div class="margin-form">
|
||||
<select name="id_hook"'.(Tools::isSubmit('editGraft') ? ' disabled="disabled"' : '').'>';
|
||||
foreach ($hooks AS $hook)
|
||||
echo '
|
||||
<option value="'.$hook['id_hook'].'" '.($id_hook == $hook['id_hook'] ? 'selected="selected" ' : '').'>'.$hook['title'].'</option>';
|
||||
echo '
|
||||
</select><sup> *</sup>
|
||||
</div>
|
||||
<label>'.$this->l('Exceptions').' :</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" name="exceptions" size="40" '.(!empty($excepts) ? 'value="'.$excepts.'"' : '').'><br />Ex: identity.php, history.php, order.php, product.php<br /><br />
|
||||
'.$this->l('Please specify those files in which you do not want the module to be displayed').'.<br />
|
||||
'.$this->l('These files are located in your base directory').', '.$this->l('e.g., ').' <b>identity.php</b>.<br />
|
||||
'.$this->l('Please type each filename separated by a comma').'.
|
||||
<br /><br />
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
';
|
||||
if (Tools::isSubmit('editGraft'))
|
||||
{
|
||||
echo '
|
||||
<input type="hidden" name="id_module" value="'.$id_module.'" />
|
||||
<input type="hidden" name="id_hook" value="'.$id_hook.'" />';
|
||||
}
|
||||
echo '
|
||||
<input type="submit" value="'.$this->l('Save').'" name="'.(Tools::isSubmit('editGraft') ? 'submitEditGraft' : 'submitAddToHook').'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Taxes tab for admin panel, AdminTaxes.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminOrderMessage extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'order_message';
|
||||
$this->className = 'OrderMessage';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_order_message' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 140),
|
||||
'message' => array('title' => $this->l('Message'), 'width' => 140, 'maxlength' => 300));
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&token='.$this->token.'&submitAdd'.$this->table.'=1" method="post">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset class="width3"><legend><img src="../img/admin/email.gif" />'.$this->l('Order messages').'</legend>
|
||||
<label>'.$this->l('Name:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="name_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input type="text" size="53" name="name_'.$language['id_lang'].'" value="'.$this->getFieldValue($obj, 'name', intval($language['id_lang'])).'" /><sup> *</sup>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name¤message', 'name');
|
||||
echo '</div>
|
||||
<div class="clear"></div><br />
|
||||
<label>'.$this->l('Message:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="message_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<textarea rows="15" cols="50" name="message_'.$language['id_lang'].'">'.$this->getFieldValue($obj, 'message', intval($language['id_lang'])).'</textarea><sup> *</sup>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name¤message', 'message');
|
||||
echo '</div>
|
||||
<div class="clear"></div><br />
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required fields').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,872 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Orders tab for admin panel, AdminOrders.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminOrders extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie, $currentIndex;
|
||||
|
||||
$this->table = 'order';
|
||||
$this->className = 'Order';
|
||||
$this->view = true;
|
||||
$this->colorOnBackground = true;
|
||||
$this->_select = '
|
||||
a.id_order AS id_pdf,
|
||||
CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
|
||||
osl.`name` AS `osname`,
|
||||
os.`color`,
|
||||
IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer AND so.valid = 1) > 1, 0, 1) as new,
|
||||
(SELECT COUNT(od.`id_order`) FROM `'._DB_PREFIX_.'order_detail` od WHERE od.`id_order` = a.`id_order` GROUP BY `id_order`) AS product_number';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = a.`id_order`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = oh.`id_order_state`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.intval($cookie->id_lang).')';
|
||||
$this->_where = 'AND oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `'._DB_PREFIX_.'order_history` moh WHERE moh.`id_order` = a.`id_order` GROUP BY moh.`id_order`)';
|
||||
|
||||
$statesArray = array();
|
||||
$states = OrderState::getOrderStates(intval($cookie->id_lang));
|
||||
|
||||
foreach ($states AS $state)
|
||||
$statesArray[$state['id_order_state']] = $state['name'];
|
||||
$this->fieldsDisplay = array(
|
||||
'id_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'new' => array('title' => $this->l('New'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'filter_key' => 'new', 'tmpTableFilter' => true, 'icon' => array(0 => 'blank.gif', 1 => 'news-new.gif'), 'orderby' => false),
|
||||
'customer' => array('title' => $this->l('Customer'), 'widthColumn' => 160, 'width' => 140, 'filter_key' => 'customer', 'tmpTableFilter' => true),
|
||||
'total_paid' => array('title' => $this->l('Total'), 'width' => 70, 'align' => 'right', 'prefix' => '<b>', 'suffix' => '</b>', 'price' => true, 'currency' => true),
|
||||
'payment' => array('title' => $this->l('Payment'), 'width' => 100),
|
||||
'osname' => array('title' => $this->l('Status'), 'widthColumn' => 250, 'type' => 'select', 'select' => $statesArray, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int', 'width' => 200),
|
||||
'date_add' => array('title' => $this->l('Date'), 'width' => 90, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add'),
|
||||
'id_pdf' => array('title' => $this->l('PDF'), 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false));
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @global object $cookie Employee cookie necessary to keep trace of his/her actions
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
|
||||
/* Update shipping number */
|
||||
if (Tools::isSubmit('submitShippingNumber') AND ($id_order = intval(Tools::getValue('id_order'))) AND Validate::isLoadedObject($order = new Order($id_order)))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (!$order->hasBeenShipped())
|
||||
die(Tools::displayError('The shipping number can only be set once the order has been shipped!'));
|
||||
$_GET['view'.$this->table] = true;
|
||||
|
||||
$shipping_number = pSQL(Tools::getValue('shipping_number'));
|
||||
$order->shipping_number = $shipping_number;
|
||||
$order->update();
|
||||
if ($shipping_number)
|
||||
{
|
||||
global $_LANGMAIL;
|
||||
$customer = new Customer(intval($order->id_customer));
|
||||
$carrier = new Carrier(intval($order->id_carrier));
|
||||
if (!Validate::isLoadedObject($customer) OR !Validate::isLoadedObject($carrier))
|
||||
die(Tools::displayError());
|
||||
$templateVars = array(
|
||||
'{followup}' => str_replace('@', $order->shipping_number, $carrier->url),
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{id_order}' => intval($order->id)
|
||||
);
|
||||
$subject = 'Package in transit';
|
||||
Mail::Send(intval($order->id_lang), 'in_transit', ((is_array($_LANGMAIL) AND key_exists($subject, $_LANGMAIL)) ? $_LANGMAIL[$subject] : $subject), $templateVars, $customer->email, $customer->firstname.' '.$customer->lastname);
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
|
||||
/* Change order state, add a new entry in order history and send an e-mail to the customer if needed */
|
||||
elseif (Tools::isSubmit('submitState') AND ($id_order = intval(Tools::getValue('id_order'))) AND Validate::isLoadedObject($order = new Order($id_order)))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
$_GET['view'.$this->table] = true;
|
||||
if (!$newOrderStatusId = intval(Tools::getValue('id_order_state')))
|
||||
$this->_errors[] = Tools::displayError('Invalid new order status!');
|
||||
else
|
||||
{
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = $id_order;
|
||||
$history->changeIdOrderState(intval($newOrderStatusId), intval($id_order));
|
||||
$history->id_employee = intval($cookie->id_employee);
|
||||
$carrier = new Carrier(intval($order->id_carrier), intval($order->id_lang));
|
||||
$templateVars = array('{followup}' => ($history->id_order_state == _PS_OS_SHIPPING_ AND $order->shipping_number) ? str_replace('@', $order->shipping_number, $carrier->url) : '');
|
||||
if ($history->addWithemail(true, $templateVars))
|
||||
Tools::redirectAdmin($currentIndex.'&id_order='.$id_order.'&vieworder'.'&token='.$this->token);
|
||||
$this->_errors[] = Tools::displayError('an error occurred while changing status or was unable to send e-mail to the customer');
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
|
||||
/* Add a new message for the current order and send an e-mail to the customer if needed */
|
||||
elseif (isset($_POST['submitMessage']))
|
||||
{
|
||||
$_GET['view'.$this->table] = true;
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (!($id_order = intval(Tools::getValue('id_order'))) OR !($id_customer = intval(Tools::getValue('id_customer'))))
|
||||
$this->_errors[] = Tools::displayError('an error occurred before sending message');
|
||||
elseif (!Tools::getValue('message'))
|
||||
$this->_errors[] = Tools::displayError('message cannot be blank');
|
||||
else
|
||||
{
|
||||
/* Get message rules and and check fields validity */
|
||||
$rules = call_user_func(array('Message', 'getValidationRules'), 'Message');
|
||||
foreach ($rules['required'] AS $field)
|
||||
if (($value = Tools::getValue($field)) == false AND (string)$value != '0')
|
||||
if (!Tools::getValue('id_'.$this->table) OR $field != 'passwd')
|
||||
$this->_errors[] = Tools::displayError('field').' <b>'.$field.'</b> '.Tools::displayError('is required');
|
||||
foreach ($rules['size'] AS $field => $maxLength)
|
||||
if (Tools::getValue($field) AND Tools::strlen(Tools::getValue($field)) > $maxLength)
|
||||
$this->_errors[] = Tools::displayError('field').' <b>'.$field.'</b> '.Tools::displayError('is too long').' ('.$maxLength.' '.Tools::displayError('chars max').')';
|
||||
foreach ($rules['validate'] AS $field => $function)
|
||||
if (Tools::getValue($field))
|
||||
if (!Validate::$function(htmlentities(Tools::getValue($field), ENT_COMPAT, 'UTF-8')))
|
||||
$this->_errors[] = Tools::displayError('field').' <b>'.$field.'</b> '.Tools::displayError('is invalid');
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
$message = new Message();
|
||||
$message->id_employee = intval($cookie->id_employee);
|
||||
$message->message = htmlentities(Tools::getValue('message'), ENT_COMPAT, 'UTF-8');
|
||||
$message->id_order = $id_order;
|
||||
$message->private = Tools::getValue('visibility');
|
||||
if (!$message->add())
|
||||
$this->_errors[] = Tools::displayError('an error occurred while sending message');
|
||||
elseif ($message->private)
|
||||
Tools::redirectAdmin($currentIndex.'&id_order='.$id_order.'&vieworder&conf=11'.'&token='.$this->token);
|
||||
elseif (Validate::isLoadedObject($customer = new Customer($id_customer)))
|
||||
{
|
||||
$order = new Order(intval($message->id_order));
|
||||
if (Validate::isLoadedObject($order))
|
||||
{
|
||||
$title = html_entity_decode($this->l('New message regarding your order').' '.$message->id_order, ENT_NOQUOTES, 'UTF-8');
|
||||
$varsTpl = array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{id_order}' => $message->id_order, '{message}' => (Configuration::get('PS_MAIL_TYPE') == 2 ? $message->message : nl2br2($message->message)));
|
||||
if (Mail::Send(intval($order->id_lang), 'order_merchant_comment', $title, $varsTpl, $customer->email, $customer->firstname.' '.$customer->lastname))
|
||||
Tools::redirectAdmin($currentIndex.'&id_order='.$id_order.'&vieworder&conf=11'.'&token='.$this->token);
|
||||
}
|
||||
}
|
||||
$this->_errors[] = Tools::displayError('an error occurred while sending e-mail to the customer');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
|
||||
/* Cancel product from order */
|
||||
elseif (Tools::isSubmit('cancelProduct') AND Validate::isLoadedObject($order = new Order(intval(Tools::getValue('id_order')))))
|
||||
{
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
$productList = Tools::getValue('id_order_detail');
|
||||
$customizationList = Tools::getValue('id_customization');
|
||||
$qtyList = Tools::getValue('cancelQuantity');
|
||||
$customizationQtyList = Tools::getValue('cancelCustomizationQuantity');
|
||||
|
||||
if ($productList OR $customizationList)
|
||||
{
|
||||
if ($productList)
|
||||
foreach ($productList AS $key => $id_order_detail)
|
||||
{
|
||||
$qtyCancelProduct = abs($qtyList[$key]);
|
||||
if (!$qtyCancelProduct)
|
||||
$this->_errors[] = Tools::displayError('No quantity selected for product.');
|
||||
}
|
||||
if ($customizationList)
|
||||
foreach ($customizationList AS $id_customization => $id_order_detail)
|
||||
{
|
||||
$qtyCancelProduct = abs($customizationQtyList[$id_customization]);
|
||||
if (!$qtyCancelProduct)
|
||||
$this->_errors[] = Tools::displayError('No quantity selected for product.');
|
||||
}
|
||||
|
||||
if (!sizeof($this->_errors) AND $productList)
|
||||
foreach ($productList AS $key => $id_order_detail)
|
||||
{
|
||||
$qtyCancelProduct = abs($qtyList[$key]);
|
||||
$orderDetail = new OrderDetail(intval($id_order_detail));
|
||||
|
||||
// Reinject product
|
||||
if (!$order->hasBeenDelivered() OR ($order->hasBeenDelivered() AND Tools::isSubmit('reinjectQuantities')))
|
||||
{
|
||||
$reinjectableQuantity = intval($orderDetail->product_quantity_in_stock) - intval($orderDetail->product_quantity_reinjected);
|
||||
$quantityToReinject = $qtyCancelProduct > $reinjectableQuantity ? $reinjectableQuantity : $qtyCancelProduct;
|
||||
if (!Product::reinjectQuantities($orderDetail, $quantityToReinject))
|
||||
$this->_errors[] = Tools::displayError('Cannot re-stock product').' <span class="bold">'.$orderDetail->product_name.'</span>';
|
||||
else
|
||||
{
|
||||
$updProductAttributeID = !empty($orderDetail->product_attribute_id) ? intval($orderDetail->product_attribute_id) : NULL;
|
||||
$newProductQty = Product::getQuantity(intval($orderDetail->product_id), $updProductAttributeID);
|
||||
if (!empty($orderDetail->product_attribute_id))
|
||||
$updProduct['quantity_attribute'] = intval($newProductQty);
|
||||
else
|
||||
$updProduct['stock_quantity'] = intval($newProductQty);
|
||||
Hook::updateQuantity($updProduct, $order);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete product
|
||||
if (!$order->deleteProduct($order, $orderDetail, $qtyCancelProduct))
|
||||
$this->_errors[] = Tools::displayError('an error occurred during deletion for the product').' <span class="bold">'.$orderDetail->product_name.'</span>';
|
||||
Module::hookExec('cancelProduct', array('order' => $order, 'id_order_detail' => $id_order_detail));
|
||||
}
|
||||
if (!sizeof($this->_errors) AND $customizationList)
|
||||
foreach ($customizationList AS $id_customization => $id_order_detail)
|
||||
{
|
||||
$orderDetail = new OrderDetail(intval($id_order_detail));
|
||||
$qtyCancelProduct = abs($customizationQtyList[$id_customization]);
|
||||
if (!$order->deleteCustomization($id_customization, $qtyCancelProduct, $orderDetail))
|
||||
$this->_errors[] = Tools::displayError('an error occurred during deletion for the product customization').' '.$id_customization;
|
||||
}
|
||||
// E-mail params
|
||||
if ((isset($_POST['generateCreditSlip']) OR isset($_POST['generateDiscount'])) AND !sizeof($this->_errors))
|
||||
{
|
||||
$customer = new Customer(intval($order->id_customer));
|
||||
$params['{lastname}'] = $customer->lastname;
|
||||
$params['{firstname}'] = $customer->firstname;
|
||||
$params['{id_order}'] = $order->id;
|
||||
}
|
||||
|
||||
// Generate credit slip
|
||||
if (isset($_POST['generateCreditSlip']) AND !sizeof($this->_errors))
|
||||
{
|
||||
if (!OrderSlip::createOrderSlip($order, $productList, $qtyList, isset($_POST['shippingBack'])))
|
||||
$this->_errors[] = Tools::displayError('Cannot generate credit slip');
|
||||
else
|
||||
{
|
||||
Module::hookExec('orderSlip', array('order' => $order, 'productList' => $productList, 'qtyList' => $qtyList));
|
||||
@Mail::Send(intval($order->id_lang), 'credit_slip', html_entity_decode($this->l('New credit slip regarding your order #').$order->id, ENT_NOQUOTES, 'UTF-8'), $params, $customer->email, $customer->firstname.' '.$customer->lastname);
|
||||
}
|
||||
}
|
||||
|
||||
// Generate voucher
|
||||
if (isset($_POST['generateDiscount']) AND !sizeof($this->_errors))
|
||||
{
|
||||
if (!$voucher = Discount::createOrderDiscount($order, $productList, $qtyList, $this->l('Credit Slip concerning the order #'), isset($_POST['shippingBack'])))
|
||||
$this->_errors[] = Tools::displayError('Cannot generate voucher');
|
||||
else
|
||||
{
|
||||
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
$params['{voucher_amount}'] = Tools::displayPrice($voucher->value, $currency, false, false);
|
||||
$params['{voucher_num}'] = $voucher->name;
|
||||
@Mail::Send(intval($order->id_lang), 'voucher', html_entity_decode($this->l('New voucher regarding your order #').$order->id, ENT_NOQUOTES, 'UTF-8'), $params, $customer->email, $customer->firstname.' '.$customer->lastname);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('No product or quantity selected.');
|
||||
|
||||
// Redirect if no errors
|
||||
if (!sizeof($this->_errors))
|
||||
Tools::redirectLink($currentIndex.'&id_order='.$order->id.'&vieworder&conf=1&token='.$this->token);
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
elseif (isset($_GET['messageReaded']))
|
||||
{
|
||||
Message::markAsReaded(intval($_GET['messageReaded']), intval($cookie->id_employee));
|
||||
}
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
private function displayCustomizedDatas(&$customizedDatas, &$product, &$currency, &$image, $tokenCatalog, $id_order_detail)
|
||||
{
|
||||
$order = $this->loadObject();
|
||||
|
||||
if (is_array($customizedDatas) AND isset($customizedDatas[intval($product['product_id'])][intval($product['product_attribute_id'])]))
|
||||
{
|
||||
echo '
|
||||
<tr>
|
||||
<td align="center">'.(isset($image['id_image']) ? cacheImage(_PS_IMG_DIR_.'p/'.intval($product['product_id']).'-'.intval($image['id_image']).'.jpg',
|
||||
'product_mini_'.intval($product['product_id']).(isset($product['product_attribute_id']) ? '_'.intval($product['product_attribute_id']) : '').'.jpg', 45, 'jpg') : '--').'</td>
|
||||
<td><a href="index.php?tab=AdminCatalog&id_product='.$product['product_id'].'&updateproduct&token='.$tokenCatalog.'">
|
||||
<span class="productName">'.$product['product_name'].' - '.$this->l('customized').'</span><br />
|
||||
'.($product['product_reference'] ? $this->l('Ref:').' '.$product['product_reference'] : '')
|
||||
.(($product['product_reference'] AND $product['product_supplier_reference']) ? ' / '.$product['product_supplier_reference'] : '')
|
||||
.'</a></td>
|
||||
<td align="center">'.Tools::displayPrice($product['product_price_wt'], $currency, false, false).'</td>
|
||||
<td align="center" class="productQuantity">'.$product['customizationQuantityTotal'].'</td>
|
||||
'.($order->hasBeenPaid() ? '<td align="center" class="productQuantity">'.$product['customizationQuantityRefunded'].'</td>' : '').'
|
||||
'.($order->hasBeenDelivered() ? '<td align="center" class="productQuantity">'.$product['customizationQuantityReturned'].'</td>' : '').'
|
||||
<td align="center" class="productQuantity"> - </td>
|
||||
<td align="center">'.Tools::displayPrice($product['total_customization_wt'], $currency, false, false).'</td>
|
||||
<td align="center" class="cancelCheck">--</td>
|
||||
</tr>';
|
||||
foreach ($customizedDatas[intval($product['product_id'])][intval($product['product_attribute_id'])] AS $customizationId => $customization)
|
||||
{
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="2">';
|
||||
foreach ($customization['datas'] AS $type => $datas)
|
||||
if ($type == _CUSTOMIZE_FILE_)
|
||||
{
|
||||
$i = 0;
|
||||
echo '<ul style="margin: 4px 0px 4px 0px; padding: 0px; list-style-type: none;">';
|
||||
foreach ($datas AS $data)
|
||||
echo '<li style="display: inline; margin: 2px;">
|
||||
<a href="displayImage.php?img='.$data['value'].'&name='.intval($order->id).'-file'.++$i.'" target="_blank"><img src="'._THEME_PROD_PIC_DIR_.$data['value'].'_small" alt="" /></a>
|
||||
</li>';
|
||||
echo '</ul>';
|
||||
}
|
||||
elseif ($type == _CUSTOMIZE_TEXTFIELD_)
|
||||
{
|
||||
$i = 0;
|
||||
echo '<ul style="margin: 0px 0px 4px 0px; padding: 0px 0px 0px 6px; list-style-type: none;">';
|
||||
foreach ($datas AS $data)
|
||||
echo '<li>'.($data['name']).$this->l(':').' '.$data['value'].'</li>';
|
||||
echo '</ul>';
|
||||
}
|
||||
echo '</td>
|
||||
<td align="center">-</td>
|
||||
<td align="center" class="productQuantity">'.$customization['quantity'].'</td>
|
||||
'.($order->hasBeenPaid() ? '<td align="center">'.$customization['quantity_refunded'].'</td>' : '').'
|
||||
'.($order->hasBeenDelivered() ? '<td align="center">'.$customization['quantity_returned'].'</td>' : '').'
|
||||
<td align="center">-</td>
|
||||
<td align="center">'.Tools::displayPrice(Tools::ps_round($product['product_price'], 2) * (1 + ($product['tax_rate'] * 0.01)) * ($customization['quantity']), $currency, false, false).'</td>
|
||||
<td align="center" class="cancelCheck">
|
||||
<input type="hidden" name="totalQtyReturn" id="totalQtyReturn" value="'.intval($customization['quantity_returned']).'" />
|
||||
<input type="hidden" name="totalQty" id="totalQty" value="'.intval($customization['quantity']).'" />
|
||||
<input type="hidden" name="productName" id="productName" value="'.$product['product_name'].'" />';
|
||||
if ((!$order->hasBeenDelivered() OR Configuration::get('PS_ORDER_RETURN')) AND intval(($customization['quantity_returned']) < intval($customization['quantity'])))
|
||||
echo '
|
||||
<input type="checkbox" name="id_customization['.$customizationId.']" id="id_customization['.$customizationId.']" value="'.$id_order_detail.'" onchange="setCancelQuantity(this, \'_'.$customizationId.'\', 1)" '.((intval($customization['quantity_returned'] + $customization['quantity_refunded']) >= intval($customization['quantity'])) ? 'disabled="disabled" ' : '').'/>';
|
||||
else
|
||||
echo '--';
|
||||
echo '
|
||||
</td>
|
||||
<td class="cancelQuantity">';
|
||||
if (intval($customization['quantity_returned'] + $customization['quantity_refunded']) >= intval($customization['quantity']))
|
||||
echo '<input type="hidden" name="cancelCustomizationQuantity['.$customizationId.']" value="0" />';
|
||||
elseif (!$order->hasBeenDelivered() OR Configuration::get('PS_ORDER_RETURN'))
|
||||
echo '
|
||||
<input type="text" id="cancelQuantity_'.$customizationId.'" name="cancelCustomizationQuantity['.$customizationId.']" size="2" onclick="selectCheckbox(this);" value="" /> ';
|
||||
echo ($order->hasBeenDelivered() ? intval($customization['quantity_returned']).'/'.(intval($customization['quantity']) - intval($customization['quantity_refunded'])) : ($order->hasBeenPaid() ? intval($customization['quantity_refunded']).'/'.intval($customization['quantity']) : '')).'
|
||||
</td>';
|
||||
echo '
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getCancelledProductNumber(&$order, &$product)
|
||||
{
|
||||
$productQuantity = array_key_exists('customizationQuantityTotal', $product) ? $product['product_quantity'] - $product['customizationQuantityTotal'] : $product['product_quantity'];
|
||||
$productRefunded = $product['product_quantity_refunded'];
|
||||
$productReturned = $product['product_quantity_return'];
|
||||
$content = '0/'.$productQuantity;
|
||||
if ($order->hasBeenDelivered())
|
||||
$content = $productReturned.'/'.($productQuantity - $productRefunded);
|
||||
elseif ($order->hasBeenPaid())
|
||||
$content = $productRefunded.'/'.$productQuantity;
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function viewDetails()
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
$irow = 0;
|
||||
$order = $this->loadObject();
|
||||
|
||||
$customer = new Customer($order->id_customer);
|
||||
$customerStats = $customer->getStats();
|
||||
$addressInvoice = new Address($order->id_address_invoice, intval($cookie->id_lang));
|
||||
if (Validate::isLoadedObject($addressInvoice) AND $addressInvoice->id_state)
|
||||
$invoiceState = new State(intval($addressInvoice->id_state));
|
||||
$addressDelivery = new Address($order->id_address_delivery, intval($cookie->id_lang));
|
||||
if (Validate::isLoadedObject($addressDelivery) AND $addressDelivery->id_state)
|
||||
$deliveryState = new State(intval($addressDelivery->id_state));
|
||||
$carrier = new Carrier($order->id_carrier);
|
||||
$history = $order->getHistory($cookie->id_lang);
|
||||
$products = $order->getProducts();
|
||||
$customizedDatas = Product::getAllCustomizedDatas(intval($order->id_cart));
|
||||
Product::addCustomizationPrice($products, $customizedDatas);
|
||||
$discounts = $order->getDiscounts();
|
||||
$messages = Message::getMessagesByOrderId($order->id, true);
|
||||
$states = OrderState::getOrderStates(intval($cookie->id_lang));
|
||||
$currency = new Currency($order->id_currency);
|
||||
$currentLanguage = new Language(intval($cookie->id_lang));
|
||||
$currentState = OrderHistory::getLastOrderState($order->id);
|
||||
$sources = ConnectionsSource::getOrderSources($order->id);
|
||||
$cart = Cart::getCartByOrderId($order->id);
|
||||
$link = new Link();
|
||||
|
||||
$row = array_shift($history);
|
||||
|
||||
if ($order->total_paid != $order->total_paid_real)
|
||||
echo '<center><span class="warning" style="font-size: 16px">'.$this->l('Warning:').' '.Tools::displayPrice($order->total_paid_real, $currency, false, false).' '.$this->l('paid instead of').' '.Tools::displayPrice($order->total_paid, $currency, false, false).' !</span></center><div class="clear"><br /><br /></div>';
|
||||
|
||||
// display bar code if module enabled
|
||||
$hook = Module::hookExec('invoice', array('id_order' => $order->id));
|
||||
if ($hook !== false)
|
||||
{
|
||||
echo '<div style="float: right; margin: -40px 40px 10px 0;">';
|
||||
echo $hook;
|
||||
echo '</div><br class="clear" />';
|
||||
}
|
||||
|
||||
// display order header
|
||||
echo '
|
||||
<div style="float: left;">';
|
||||
echo '
|
||||
<h2 style="width: 430px;">'.$customer->firstname.' '.$customer->lastname.' '.$this->l('#').sprintf('%06d', $order->id).
|
||||
((($currentState->invoice OR $order->invoice_number) AND count($products)) ? ' - <a href="pdf.php?id_order='.$order->id.'&pdf"><img src="../img/admin/tab-invoice.gif" alt="'.$this->l('View invoice').'" title="'.$this->l('View invoice').'" /></a>' : '').
|
||||
(($currentState->delivery OR $order->delivery_number) ? ' - <a href="pdf.php?id_delivery='.$order->delivery_number.'"><img src="../img/admin/delivery.gif" alt="'.$this->l('View delivery slip').'" title="'.$this->l('View delivery slip').'" /></a>' : '').
|
||||
' - <a href="javascript:window.print()"><img src="../img/admin/printer.gif" alt="'.$this->l('Print order').'" title="'.$this->l('Print order').'" /></a>';
|
||||
echo '</h2>';
|
||||
|
||||
/* Display current status */
|
||||
echo '
|
||||
<table cellspacing="0" cellpadding="0" class="table" style="width: 429px">
|
||||
<tr>
|
||||
<th>'.Tools::displayDate($row['date_add'], intval($cookie->id_lang), true).'</th>
|
||||
<th><img src="../img/os/'.$row['id_order_state'].'.gif" /></th>
|
||||
<th>'.stripslashes($row['ostate_name']).'</th>
|
||||
<th>'.((!empty($row['employee_lastname'])) ? '('.stripslashes(Tools::substr($row['employee_firstname'], 0, 1)).'. '.stripslashes($row['employee_lastname']).')' : '').'</th>
|
||||
</tr>';
|
||||
/* Display previous status */
|
||||
foreach ($history AS $row)
|
||||
{
|
||||
echo '
|
||||
<tr class="'.($irow++ % 2 ? 'alt_row' : '').'">
|
||||
<td>'.Tools::displayDate($row['date_add'], intval($cookie->id_lang), true).'</td>
|
||||
<td><img src="../img/os/'.$row['id_order_state'].'.gif" /></td>
|
||||
<td>'.stripslashes($row['ostate_name']).'</td>
|
||||
<td>'.((!empty($row['employee_lastname'])) ? '('.stripslashes(Tools::substr($row['employee_firstname'], 0, 1)).'. '.stripslashes($row['employee_lastname']).')' : '').'</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '
|
||||
</table>
|
||||
<br />';
|
||||
|
||||
/* Display status form */
|
||||
if (sizeof($products))
|
||||
{
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&view'.$this->table.'&token='.$this->token.'" method="post" style="text-align:center;">
|
||||
<select name="id_order_state">';
|
||||
$currentStateTab = $order->getCurrentStateFull($cookie->id_lang);
|
||||
foreach ($states AS $state)
|
||||
echo '<option value="'.$state['id_order_state'].'"'.(($state['id_order_state'] == $currentStateTab['id_order_state']) ? ' selected="selected"' : '').'>'.stripslashes($state['name']).'</option>';
|
||||
echo '
|
||||
</select>
|
||||
<input type="hidden" name="id_order" value="'.$order->id.'" />
|
||||
<input type="submit" name="submitState" value="'.$this->l('Change').'" class="button" />
|
||||
</form>';
|
||||
}
|
||||
|
||||
/* Display customer information */
|
||||
echo '
|
||||
<br />
|
||||
<fieldset style="width: 400px">
|
||||
<legend><img src="../img/admin/tab-customers.gif" /> '.$this->l('Customer information').'</legend>
|
||||
<span style="font-weight: bold; font-size: 14px;"><a href="?tab=AdminCustomers&id_customer='.$customer->id.'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.intval(Tab::getIdFromClassName('AdminCustomers')).intval($cookie->id_employee)).'"> '.$customer->firstname.' '.$customer->lastname.'</a></span> ('.$this->l('#').$customer->id.')<br />
|
||||
(<a href="mailto:'.$customer->email.'">'.$customer->email.'</a>)<br /><br />
|
||||
'.$this->l('Account registered:').' '.Tools::displayDate($customer->date_add, intval($cookie->id_lang), true).'<br />
|
||||
'.$this->l('Valid orders placed:').' <b>'.$customerStats['nb_orders'].'</b><br />
|
||||
'.$this->l('Total paid since registration:').' <b>'.Tools::displayPrice(Tools::ps_round(Tools::convertPrice($customerStats['total_orders'], $currency), 2), $currency, false, false).'</b><br />
|
||||
</fieldset>';
|
||||
|
||||
/* Display sources */
|
||||
if (sizeof($sources))
|
||||
{
|
||||
echo '<br />
|
||||
<fieldset style="width: 400px;"><legend><img src="../img/admin/tab-stats.gif" /> '.$this->l('Sources').'</legend><ul '.(sizeof($sources) > 3 ? 'style="overflow-y: scroll; height: 200px"' : '').'>';
|
||||
foreach ($sources as $source)
|
||||
echo '<li>
|
||||
'.Tools::displayDate($source['date_add'], intval($cookie->id_lang), true).'<br />
|
||||
<b>'.$this->l('From:').'</b> <a href="'.$source['http_referer'].'">'.preg_replace('/^www./', '', parse_url($source['http_referer'], PHP_URL_HOST)).'</a><br />
|
||||
<b>'.$this->l('To:').'</b> '.$source['request_uri'].'<br />
|
||||
'.($source['keywords'] ? '<b>'.$this->l('Keywords:').'</b> '.$source['keywords'].'<br />' : '').'<br />
|
||||
</li>';
|
||||
echo '</ul></fieldset>';
|
||||
}
|
||||
// display hook specified to this page : AdminOrder
|
||||
if (($hook = Module::hookExec('adminOrder', array('id_order' => $order->id))) !== false)
|
||||
echo $hook;
|
||||
|
||||
echo '
|
||||
</div>
|
||||
<div style="float: left; margin-left: 40px">';
|
||||
|
||||
/* Display invoice information */
|
||||
if (($currentState->invoice OR $order->invoice_number) AND count($products))
|
||||
echo '
|
||||
<fieldset style="width: 400px">
|
||||
<legend><a href="pdf.php?id_order='.$order->id.'&pdf"><img src="../img/admin/tab-invoice.gif" /> '.$this->l('Invoice').'</a></legend>
|
||||
<a href="pdf.php?id_order='.$order->id.'&pdf">'.$this->l('Invoice #').'<b>'.Configuration::get('PS_INVOICE_PREFIX', intval($cookie->id_lang)).sprintf('%06d', $order->invoice_number).'</b></a>
|
||||
<br />'.$this->l('Created on:').' '.$order->invoice_date.'
|
||||
</fieldset><br />';
|
||||
|
||||
/* Display shipping infos */
|
||||
echo '
|
||||
<fieldset style="width: 400px">
|
||||
<legend><img src="../img/admin/delivery.gif" /> '.$this->l('Shipping information').'</legend>
|
||||
'.$this->l('Total weight:').' <b>'.number_format($order->getTotalWeight(), 3).' '.Configuration::get('PS_WEIGHT_UNIT').'</b><br />
|
||||
'.$this->l('Carrier:').' <b>'.($carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name).'</b><br />
|
||||
'.(($currentState->delivery OR $order->delivery_number) ? '<br /><a href="pdf.php?id_delivery='.$order->delivery_number.'">'.$this->l('Delivery slip #').'<b>'.Configuration::get('PS_DELIVERY_PREFIX', intval($cookie->id_lang)).sprintf('%06d', $order->delivery_number).'</b></a><br />' : '');
|
||||
if ($order->shipping_number)
|
||||
echo $this->l('Tracking number:').' <b>'.$order->shipping_number.'</b> (<a href="'.str_replace('@', $order->shipping_number, $carrier->url).'">'.$this->l('Track the shipment').'</a>)';
|
||||
|
||||
/* Carrier module */
|
||||
if ($carrier->is_module == 1)
|
||||
{
|
||||
$module = Module::getInstanceByName($carrier->name);
|
||||
echo call_user_func(array($module, 'displayInfoByCart'), $order->id_cart);
|
||||
}
|
||||
|
||||
/* Display shipping number field */
|
||||
if ($carrier->url && $order->hasBeenShipped())
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&view'.$this->table.'&token='.$this->token.'" method="post" style="margin-top:10px;">
|
||||
<input type="text" name="shipping_number" value="'. $order->shipping_number.'" />
|
||||
<input type="hidden" name="id_order" value="'.$order->id.'" />
|
||||
<input type="submit" name="submitShippingNumber" value="'.$this->l('Set shipping number').'" class="button" />
|
||||
</form>';
|
||||
echo '
|
||||
</fieldset>';
|
||||
|
||||
/* Display summary order */
|
||||
echo '
|
||||
<br />
|
||||
<fieldset style="width: 400px">
|
||||
<legend><img src="../img/admin/details.gif" /> '.$this->l('Order details').'</legend>
|
||||
<label>'.$this->l('Original cart:').' </label>
|
||||
<div style="margin: 2px 0 1em 190px;"><a href="?tab=AdminCarts&id_cart='.$cart->id.'&viewcart&token='.Tools::getAdminToken('AdminCarts'.intval(Tab::getIdFromClassName('AdminCarts')).intval($cookie->id_employee)).'">'.$this->l('Cart #').sprintf('%06d', $cart->id).'</a></div>
|
||||
<label>'.$this->l('Payment mode:').' </label>
|
||||
<div style="margin: 2px 0 1em 190px;">'.$order->payment.' '.($order->module ? '('.$order->module.')' : '').'</div>
|
||||
<div style="margin: 2px 0 1em 50px;">
|
||||
<table class="table" width="300px;" cellspacing="0" cellpadding="0">
|
||||
<tr><td width="150px;">'.$this->l('Products').'</td><td align="right">'.Tools::displayPrice($order->getTotalProductsWithTaxes(), $currency, false, false).'</td></tr>
|
||||
'.($order->total_discounts > 0 ? '<tr><td>'.$this->l('Discounts').'</td><td align="right">-'.Tools::displayPrice($order->total_discounts, $currency, false, false).'</td></tr>' : '').'
|
||||
'.($order->total_wrapping > 0 ? '<tr><td>'.$this->l('Wrapping').'</td><td align="right">'.Tools::displayPrice($order->total_wrapping, $currency, false, false).'</td></tr>' : '').'
|
||||
<tr><td>'.$this->l('Shipping').'</td><td align="right">'.Tools::displayPrice($order->total_shipping, $currency, false, false).'</td></tr>
|
||||
<tr style="font-size: 20px"><td>'.$this->l('Total').'</td><td align="right">'.Tools::displayPrice($order->total_paid, $currency, false, false).($order->total_paid != $order->total_paid_real ? '<br /><font color="red">('.$this->l('Paid:').' '.Tools::displayPrice($order->total_paid_real, $currency, false, false).')</font>' : '').'</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
<div style="float: left; margin-right: 10px; margin-left: 42px;">
|
||||
<span class="bold">'.$this->l('Recycled package:').'</span>
|
||||
'.($order->recyclable ? '<img src="../img/admin/enabled.gif" />' : '<img src="../img/admin/disabled.gif" />').'
|
||||
</div>
|
||||
<div style="float: left; margin-right: 10px;">
|
||||
<span class="bold">'.$this->l('Gift wrapping:').'</span>
|
||||
'.($order->gift ? '<img src="../img/admin/enabled.gif" />
|
||||
</div>
|
||||
<div style="clear: left; margin: 0px 42px 0px 42px; padding-top: 2px;">
|
||||
'.(!empty($order->gift_message) ? '<div style="border: 1px dashed #999; padding: 5px; margin-top: 8px;"><b>'.$this->l('Message:').'</b><br />'.nl2br2($order->gift_message).'</div>' : '') : '<img src="../img/admin/disabled.gif" />').'
|
||||
</div>
|
||||
</fieldset>';
|
||||
|
||||
echo '
|
||||
</div>';
|
||||
|
||||
echo '
|
||||
<div class="clear"> </div>';
|
||||
|
||||
/* Display adresses : delivery & invoice */
|
||||
echo '<div class="clear"> </div>
|
||||
<div style="float: left">
|
||||
<fieldset style="width: 400px;">
|
||||
<legend><img src="../img/admin/delivery.gif" alt="'.$this->l('Shipping address').'" />'.$this->l('Shipping address').'</legend>
|
||||
<div style="float: right">
|
||||
<a href="'.$link->getUrlWith('tab', 'AdminAddresses').'&id_address='.$addressDelivery->id.'&addaddress&realedit=1&id_order='.$order->id.($addressDelivery->id == $addressInvoice->id ? '&address_type=1' : '').'&token='.Tools::getAdminToken('AdminAddresses'.intval(Tab::getIdFromClassName('AdminAddresses')).intval($cookie->id_employee)).'&back='.urlencode($_SERVER['REQUEST_URI']).'"><img src="../img/admin/edit.gif" /></a>
|
||||
<a href="http://maps.google.com/maps?f=q&hl='.$currentLanguage->iso_code.'&geocode=&q='.$addressDelivery->address1.' '.$addressDelivery->postcode.' '.$addressDelivery->city.($addressDelivery->id_state ? ' '.$deliveryState->name: '').'"><img src="../img/admin/google.gif" alt="" class="middle" /></a>
|
||||
</div>
|
||||
'. (!empty($addressDelivery->company) ? $addressDelivery->company.'<br />' : '') .$addressDelivery->firstname.' '.$addressDelivery->lastname.'<br />
|
||||
'.$addressDelivery->address1.'<br />'. (!empty($addressDelivery->address2) ? $addressDelivery->address2.'<br />' : '') .'
|
||||
'.$addressDelivery->postcode.' '.$addressDelivery->city.'<br />
|
||||
'.$addressDelivery->country.($addressDelivery->id_state ? ' - '.$deliveryState->name : '').'<br />
|
||||
'.(!empty($addressDelivery->phone) ? $addressDelivery->phone.'<br />' : '').'
|
||||
'.(!empty($addressDelivery->phone_mobile) ? $addressDelivery->phone_mobile.'<br />' : '').'
|
||||
'.(!empty($addressDelivery->other) ? '<hr />'.$addressDelivery->other.'<br />' : '').'
|
||||
</fieldset>
|
||||
</div>
|
||||
<div style="float: left; margin-left: 40px">
|
||||
<fieldset style="width: 400px;">
|
||||
<legend><img src="../img/admin/invoice.gif" alt="'.$this->l('Invoice address').'" />'.$this->l('Invoice address').'</legend>
|
||||
<div style="float: right"><a href="'.$link->getUrlWith('tab', 'AdminAddresses').'&id_address='.$addressInvoice->id.'&addaddress&realedit=1&id_order='.$order->id.($addressDelivery->id == $addressInvoice->id ? '&address_type=2' : '').'&back='.urlencode($_SERVER['REQUEST_URI']).'&token='.Tools::getAdminToken('AdminAddresses'.intval(Tab::getIdFromClassName('AdminAddresses')).intval($cookie->id_employee)).'"><img src="../img/admin/edit.gif" /></a></div>
|
||||
'. (!empty($addressInvoice->company) ? $addressInvoice->company.'<br />' : '') .$addressInvoice->firstname.' '.$addressInvoice->lastname.'<br />
|
||||
'.$addressInvoice->address1.'<br />'. (!empty($addressInvoice->address2) ? $addressInvoice->address2.'<br />' : '') .'
|
||||
'.$addressInvoice->postcode.' '.$addressInvoice->city.'<br />
|
||||
'.$addressInvoice->country.($addressInvoice->id_state ? ' - '.$invoiceState->name : '').'<br />
|
||||
'.(!empty($addressInvoice->phone) ? $addressInvoice->phone.'<br />' : '').'
|
||||
'.(!empty($addressInvoice->phone_mobile) ? $addressInvoice->phone_mobile.'<br />' : '').'
|
||||
'.(!empty($addressInvoice->other) ? '<hr />'.$addressInvoice->other.'<br />' : '').'
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="clear"> </div>';
|
||||
|
||||
// List of products
|
||||
echo '
|
||||
<a name="products"><br /></a>
|
||||
<form action="'.$currentIndex.'&submitCreditSlip&vieworder&token='.$this->token.'" method="post" onsubmit="return orderDeleteProduct(\''.$this->l('Cannot return this product').'\', \''.$this->l('Quantity to cancel is superior than quantity available').'\');">
|
||||
<input type="hidden" name="id_order" value="'.$order->id.'" />
|
||||
<fieldset style="width: 868px; ">
|
||||
<legend><img src="../img/admin/cart.gif" alt="'.$this->l('Products').'" />'.$this->l('Products').'</legend>
|
||||
<div style="float:left;">
|
||||
<table style="width: 868px;" cellspacing="0" cellpadding="0" class="table" id="orderProducts">
|
||||
<tr>
|
||||
<th align="center" style="width: 60px"> </th>
|
||||
<th>'.$this->l('Product').'</th>
|
||||
<th style="width: 80px; text-align: center">'.$this->l('UP').' <sup>*</sup></th>
|
||||
<th style="width: 20px; text-align: center">'.$this->l('Qty').'</th>
|
||||
'.($order->hasBeenPaid() ? '<th style="width: 20px; text-align: center">'.$this->l('Refunded').'</th>' : '').'
|
||||
'.($order->hasBeenDelivered() ? '<th style="width: 20px; text-align: center">'.$this->l('Returned').'</th>' : '').'
|
||||
<th style="width: 30px; text-align: center">'.$this->l('Stock').'</th>
|
||||
<th style="width: 90px; text-align: center">'.$this->l('Total').' <sup>*</sup></th>
|
||||
<th colspan="2" style="width: 120px;"><img src="../img/admin/delete.gif" alt="'.$this->l('Products').'" /> '.($order->hasBeenDelivered() ? $this->l('Return') : ($order->hasBeenPaid() ? $this->l('Refund') : $this->l('Cancel'))).'</th>';
|
||||
echo '
|
||||
</tr>';
|
||||
$tokenCatalog = Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee));
|
||||
foreach ($products as $k => $product)
|
||||
{
|
||||
$image = array();
|
||||
if (isset($product['product_attribute_id']) AND intval($product['product_attribute_id']))
|
||||
$image = Db::getInstance()->getRow('
|
||||
SELECT id_image
|
||||
FROM '._DB_PREFIX_.'product_attribute_image
|
||||
WHERE id_product_attribute = '.intval($product['product_attribute_id']));
|
||||
if (!isset($image['id_image']) OR !$image['id_image'])
|
||||
$image = Db::getInstance()->getRow('
|
||||
SELECT id_image
|
||||
FROM '._DB_PREFIX_.'image
|
||||
WHERE id_product = '.intval($product['product_id']).' AND cover = 1');
|
||||
$stock = Db::getInstance()->getRow('
|
||||
SELECT '.($product['product_attribute_id'] ? 'pa' : 'p').'.quantity
|
||||
FROM '._DB_PREFIX_.'product p
|
||||
'.($product['product_attribute_id'] ? 'LEFT JOIN '._DB_PREFIX_.'product_attribute pa ON p.id_product = pa.id_product' : '').'
|
||||
WHERE p.id_product = '.intval($product['product_id']).'
|
||||
'.($product['product_attribute_id'] ? 'AND pa.id_product_attribute = '.intval($product['product_attribute_id']) : ''));
|
||||
if (isset($image['id_image']))
|
||||
{
|
||||
$target = '../img/tmp/product_mini_'.intval($product['product_id']).(isset($product['product_attribute_id']) ? '_'.intval($product['product_attribute_id']) : '').'.jpg';
|
||||
if (file_exists($target))
|
||||
$products[$k]['image_size'] = getimagesize($target);
|
||||
}
|
||||
// Customization display
|
||||
$this->displayCustomizedDatas($customizedDatas, $product, $currency, $image, $tokenCatalog, $k);
|
||||
|
||||
// Normal display
|
||||
if ($product['product_quantity'] > $product['customizationQuantityTotal'])
|
||||
{
|
||||
echo '
|
||||
<tr'.((isset($image['id_image']) AND isset($products[$k]['image_size'])) ? ' height="'.($products[$k]['image_size'][1] + 7).'"' : '').'>
|
||||
<td align="center">'.(isset($image['id_image']) ? cacheImage(_PS_IMG_DIR_.'p/'.intval($product['product_id']).'-'.intval($image['id_image']).'.jpg',
|
||||
'product_mini_'.intval($product['product_id']).(isset($product['product_attribute_id']) ? '_'.intval($product['product_attribute_id']) : '').'.jpg', 45, 'jpg') : '--').'</td>
|
||||
<td><a href="index.php?tab=AdminCatalog&id_product='.$product['product_id'].'&updateproduct&token='.$tokenCatalog.'">
|
||||
<span class="productName">'.$product['product_name'].'</span><br />
|
||||
'.($product['product_reference'] ? $this->l('Ref:').' '.$product['product_reference'] : '')
|
||||
.(($product['product_reference'] AND $product['product_supplier_reference']) ? ' / '.$product['product_supplier_reference'] : '')
|
||||
.'</a></td>
|
||||
<td align="center">'.Tools::displayPrice($order->getTaxCalculationMethod() == PS_TAX_EXC ? $product['product_price'] : $product['product_price_wt'], $currency, false, false).'</td>
|
||||
<td align="center" class="productQuantity">'.(intval($product['product_quantity']) - $product['customizationQuantityTotal']).'</td>
|
||||
'.($order->hasBeenPaid() ? '<td align="center" class="productQuantity">'.intval($product['product_quantity_refunded']).'</td>' : '').'
|
||||
'.($order->hasBeenDelivered() ? '<td align="center" class="productQuantity">'.intval($product['product_quantity_return']).'</td>' : '').'
|
||||
<td align="center" class="productQuantity">'.intval($stock['quantity']).'</td>
|
||||
<td align="center">'.Tools::displayPrice(($order->getTaxCalculationMethod() == PS_TAX_EXC ? $product['product_price'] : Tools::ps_round($product['product_price'] * (1 + ($product['tax_rate'] * 0.01)), 2)) * (intval($product['product_quantity']) - $product['customizationQuantityTotal']), $currency, false, false).'</td>
|
||||
<td align="center" class="cancelCheck">
|
||||
<input type="hidden" name="totalQtyReturn" id="totalQtyReturn" value="'.intval($product['product_quantity_return']).'" />
|
||||
<input type="hidden" name="totalQty" id="totalQty" value="'.intval($product['product_quantity']).'" />
|
||||
<input type="hidden" name="productName" id="productName" value="'.$product['product_name'].'" />';
|
||||
if ((!$order->hasBeenDelivered() OR Configuration::get('PS_ORDER_RETURN')) AND intval($product['product_quantity_return']) < intval($product['product_quantity']))
|
||||
echo '
|
||||
<input type="checkbox" name="id_order_detail['.$k.']" id="id_order_detail['.$k.']" value="'.$product['id_order_detail'].'" onchange="setCancelQuantity(this, '.intval($product['id_order_detail']).', '.intval($product['product_quantity'] - $product['customizationQuantityTotal']).')" '.((intval($product['product_quantity_return'] + $product['product_quantity_refunded']) >= intval($product['product_quantity'])) ? 'disabled="disabled" ' : '').'/>';
|
||||
else
|
||||
echo '--';
|
||||
echo '
|
||||
</td>
|
||||
<td class="cancelQuantity">';
|
||||
if (intval($product['product_quantity_return'] + $product['product_quantity_refunded']) >= intval($product['product_quantity']))
|
||||
echo '<input type="hidden" name="cancelQuantity['.$k.']" value="0" />';
|
||||
elseif (!$order->hasBeenDelivered() OR Configuration::get('PS_ORDER_RETURN'))
|
||||
echo '
|
||||
<input type="text" id="cancelQuantity_'.intval($product['id_order_detail']).'" name="cancelQuantity['.$k.']" size="2" onclick="selectCheckbox(this);" value="" /> ';
|
||||
echo $this->getCancelledProductNumber($order, $product).'
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
echo '
|
||||
</table>
|
||||
<div style="float:left; width:280px; margin-top:15px;"><sup>*</sup> '.$this->l('According to the group of this customer, prices are printed:').' '.($order->getTaxCalculationMethod() == PS_TAX_EXC ? $this->l('tax excluded.') : $this->l('tax included.')).(!Configuration::get('PS_ORDER_RETURN') ? '<br /><br />'.$this->l('Merchandise returns are disabled') : '').'</div>';
|
||||
if (sizeof($discounts))
|
||||
{
|
||||
echo '
|
||||
<div style="float:right; width:280px; margin-top:15px;">
|
||||
<table cellspacing="0" cellpadding="0" class="table" style="width:100%;">
|
||||
<tr>
|
||||
<th><img src="../img/admin/coupon.gif" alt="'.$this->l('Discounts').'" />'.$this->l('Discount name').'</th>
|
||||
<th align="center" style="width: 100px">'.$this->l('Value').'</th>
|
||||
</tr>';
|
||||
foreach ($discounts as $discount)
|
||||
echo '
|
||||
<tr>
|
||||
<td>'.$discount['name'].'</td>
|
||||
<td align="center">- '.Tools::displayPrice($discount['value'], $currency, false).'</td>
|
||||
</tr>';
|
||||
echo '
|
||||
</table></div>';
|
||||
}
|
||||
echo '
|
||||
</div>';
|
||||
|
||||
// Cancel product
|
||||
echo '
|
||||
<div style="clear:both; height:15px;"> </div>
|
||||
<div style="float: right; width: 160px;">';
|
||||
if ($order->hasBeenDelivered())
|
||||
echo '
|
||||
<input type="checkbox" id="reinjectQuantities" name="reinjectQuantities" class="button" /> <label for="reinjectQuantities" style="float:none; font-weight:normal;">'.$this->l('Re-stock products').'</label><br />';
|
||||
if ((!$order->hasBeenDelivered() AND $order->hasBeenPaid()) OR ($order->hasBeenDelivered() AND Configuration::get('PS_ORDER_RETURN')))
|
||||
echo '
|
||||
<input type="checkbox" id="generateCreditSlip" name="generateCreditSlip" class="button" onclick="toogleShippingCost(this)" /> <label for="generateCreditSlip" style="float:none; font-weight:normal;">'.$this->l('Generate a credit slip').'</label><br />
|
||||
<input type="checkbox" id="generateDiscount" name="generateDiscount" class="button" onclick="toogleShippingCost(this)" /> <label for="generateDiscount" style="float:none; font-weight:normal;">'.$this->l('Generate a voucher').'</label><br />
|
||||
<span id="spanShippingBack" style="display:none;"><input type="checkbox" id="shippingBack" name="shippingBack" class="button" /> <label for="shippingBack" style="float:none; font-weight:normal;">'.$this->l('Repay shipping costs').'</label><br /></span>';
|
||||
if (!$order->hasBeenDelivered() OR ($order->hasBeenDelivered() AND Configuration::get('PS_ORDER_RETURN')))
|
||||
echo '
|
||||
<div style="text-align:center; margin-top:5px;"><input type="submit" name="cancelProduct" value="'.($order->hasBeenDelivered() ? $this->l('Return products') : ($order->hasBeenPaid() ? $this->l('Refund products') : $this->l('Cancel products'))).'" class="button" style="margin-top:8px;" /></div>';
|
||||
echo '
|
||||
</div>';
|
||||
echo '
|
||||
</fieldset>
|
||||
</form>
|
||||
<div class="clear" style="height:20px;"> </div>';
|
||||
|
||||
/* Display send a message to customer & returns/credit slip*/
|
||||
$returns = OrderReturn::getOrdersReturn($order->id_customer, $order->id);
|
||||
$slips = OrderSlip::getOrdersSlip($order->id_customer, $order->id);
|
||||
echo '
|
||||
<div style="float: left">
|
||||
<form action="'.$_SERVER['REQUEST_URI'].'&token='.$this->token.'" method="post" onsubmit="if (getE(\'visibility\').checked == true) return confirm(\''.$this->l('Do you want to send this message to the customer?', __CLASS__, true, false).'\');">
|
||||
<fieldset style="width: 400px;">
|
||||
<legend style="cursor: pointer;" onclick="openCloseLayer(\'message\');openCloseLayer(\'message_m\');"><img src="../img/admin/email_edit.gif" /> '.$this->l('New message').'</legend>
|
||||
<div id="message_m" style="display: '.(Tools::getValue('message') ? 'none' : 'block').'">
|
||||
<a href="javascript:openCloseLayer(\'message\');openCloseLayer(\'message_m\');"><b>'.$this->l('Click here').'</b> '.$this->l('to add a comment or send a message to the customer').'</a>
|
||||
</div>
|
||||
<div id="message" style="display: '.(Tools::getValue('message') ? 'block' : 'none').'">
|
||||
<select name="order_message" id="order_message" onchange="orderOverwriteMessage(this, \''.$this->l('Do you want to overwrite your existing message?').'\')">
|
||||
<option value="0" selected="selected">-- '.$this->l('Choose a standard message').' --</option>';
|
||||
$orderMessages = OrderMessage::getOrderMessages(intval($order->id_lang));
|
||||
foreach ($orderMessages AS $orderMessage)
|
||||
echo ' <option value="'.htmlentities($orderMessage['message'], ENT_COMPAT, 'UTF-8').'">'.$orderMessage['name'].'</option>';
|
||||
echo ' </select><br /><br />
|
||||
<b>'.$this->l('Display to consumer?').'</b>
|
||||
<input type="radio" name="visibility" id="visibility" value="0" /> '.$this->l('Yes').'
|
||||
<input type="radio" name="visibility" value="1" checked="checked" /> '.$this->l('No').'
|
||||
<p id="nbchars" style="display:inline;font-size:10px;color:#666;"></p><br /><br />
|
||||
<textarea id="txt_msg" name="message" cols="50" rows="8" onKeyUp="var length = document.getElementById(\'txt_msg\').value.length; if (length > 600) length = \'600+\'; document.getElementById(\'nbchars\').innerHTML = \''.$this->l('600 chars max').' (\' + length + \')\';">'.htmlentities(Tools::getValue('message'), ENT_COMPAT, 'UTF-8').'</textarea><br /><br />
|
||||
<input type="hidden" name="id_order" value="'.intval($order->id).'" />
|
||||
<input type="hidden" name="id_customer" value="'.intval($order->id_customer).'" />
|
||||
<input type="submit" class="button" name="submitMessage" value="'.$this->l('Send').'" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
/* Display list of messages */
|
||||
if (sizeof($messages))
|
||||
{
|
||||
echo '
|
||||
<br />
|
||||
<fieldset style="width: 400px;">
|
||||
<legend><img src="../img/admin/email.gif" /> '.$this->l('Messages').'</legend>';
|
||||
foreach ($messages as $message)
|
||||
{
|
||||
echo '<div style="overflow:auto; width:400px;" '.($message['is_new_for_me'] ?'class="new_message"':'').'>';
|
||||
if ($message['is_new_for_me'])
|
||||
echo '<a class="new_message" title="'.$this->l('Mark this message as \'viewed\'').'" href="'.$_SERVER['REQUEST_URI'].'&token='.$this->token.'&messageReaded='.intval($message['id_message']).'"><img src="../img/admin/enabled.gif" alt="" /></a>';
|
||||
echo $this->l('At').' <i>'.Tools::displayDate($message['date_add'], intval($cookie->id_lang), true);
|
||||
echo '</i> '.$this->l('from').' <b>'.(($message['elastname']) ? ($message['efirstname'].' '.$message['elastname']) : ($message['cfirstname'].' '.$message['clastname'])).'</b>';
|
||||
echo (intval($message['private']) == 1 ? '<span style="color:red; font-weight:bold;">'.$this->l('Private:').'</span>' : '');
|
||||
echo '<p>'.nl2br2($message['message']).'</p>';
|
||||
echo '</div>';
|
||||
echo '<br />';
|
||||
}
|
||||
echo '<p class="info">'.$this->l('When you read a message, please click on the green check.').'</p>';
|
||||
echo '</fieldset>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
/* Display return product */
|
||||
echo '<div style="float: left; margin-left: 40px">
|
||||
<fieldset style="width: 400px;">
|
||||
<legend><img src="../img/admin/return.gif" alt="'.$this->l('Merchandise returns').'" />'.$this->l('Merchandise returns').'</legend>';
|
||||
if (!sizeof($returns))
|
||||
echo $this->l('No merchandise return for this order.');
|
||||
else
|
||||
foreach ($returns as $return)
|
||||
{
|
||||
$state = new OrderReturnState($return['state']);
|
||||
echo '('.Tools::displayDate($return['date_upd'], $cookie->id_lang).') :
|
||||
<b><a href="index.php?tab=AdminReturn&id_order_return='.$return['id_order_return'].'&updateorder_return&token='.Tools::getAdminToken('AdminReturn'.intval(Tab::getIdFromClassName('AdminReturn')).intval($cookie->id_employee)).'">'.$this->l('#').sprintf('%06d', $return['id_order_return']).'</a></b> -
|
||||
'.$state->name[$cookie->id_lang].'<br />';
|
||||
}
|
||||
echo '</fieldset>';
|
||||
|
||||
/* Display credit slip */
|
||||
echo '
|
||||
<br />
|
||||
<fieldset style="width: 400px;">
|
||||
<legend><img src="../img/admin/slip.gif" alt="'.$this->l('Credit slip').'" />'.$this->l('Credit slip').'</legend>';
|
||||
if (!sizeof($slips))
|
||||
echo $this->l('No slip for this order.');
|
||||
else
|
||||
foreach ($slips as $slip)
|
||||
echo '('.Tools::displayDate($slip['date_upd'], $cookie->id_lang).') : <b><a href="pdf.php?id_order_slip='.$slip['id_order_slip'].'">'.$this->l('#').sprintf('%06d', $slip['id_order_slip']).'</a></b><br />';
|
||||
echo '</fieldset>
|
||||
</div>';
|
||||
echo '<div class="clear"> </div>';
|
||||
echo '<br /><br /><a href="'.$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to list').'</a><br />';
|
||||
}
|
||||
|
||||
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);
|
||||
$currency = new Currency(intval(Configuration::get('PS_CURRENCY_DEFAULT')));
|
||||
$this->displayList();
|
||||
echo '<h2 class="space" style="text-align:right; margin-right:44px;">'.$this->l('Total:').' '.Tools::displayPrice($this->getTotal(), $currency).'</h2>';
|
||||
}
|
||||
}
|
||||
|
||||
private function getTotal()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$total = 0;
|
||||
foreach($this->_list AS $item)
|
||||
if ($item['id_currency'] == Configuration::get('PS_CURRENCY_DEFAULT'))
|
||||
$total += floatval($item['total_paid']);
|
||||
else
|
||||
{
|
||||
$currency = new Currency(intval($item['id_currency']));
|
||||
$total += Tools::ps_round(floatval($item['total_paid']) / floatval($currency->conversion_rate), 2);
|
||||
}
|
||||
return $total;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,189 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Order statues tab for admin panel, AdminOrdersStates.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminOrdersStates extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'order_state';
|
||||
$this->className = 'OrderState';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
$this->colorOnBackground = true;
|
||||
|
||||
$this->fieldImageSettings = array('name' => 'icon', 'dir' => 'os');
|
||||
$this->imageType = 'gif';
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_order_state' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 130),
|
||||
'logo' => array('title' => $this->l('Icon'), 'align' => 'center', 'image' => 'os', 'orderby' => false, 'search' => false),
|
||||
'send_email' => array('title' => $this->l('Send e-mail to customer'), 'align' => 'center', 'icon' => array('1' => 'enabled.gif', '0' => 'disabled.gif'), 'type' => 'bool', 'orderby' => false),
|
||||
'invoice' => array('title' => $this->l('Invoice'), 'align' => 'center', 'icon' => array('1' => 'enabled.gif', '0' => 'disabled.gif'), 'type' => 'bool', 'orderby' => false),
|
||||
'template' => array('title' => $this->l('E-mail template'), 'width' => 100));
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::isSubmit('submitAdd'.$this->table))
|
||||
{
|
||||
$_POST['invoice'] = Tools::getValue('invoice');
|
||||
$_POST['logable'] = Tools::getValue('logable');
|
||||
$_POST['send_email'] = Tools::getValue('send_email');
|
||||
$_POST['hidden'] = Tools::getValue('hidden');
|
||||
if (!$_POST['send_email'])
|
||||
{
|
||||
$languages = Language::getLanguages();
|
||||
foreach ($languages AS $language)
|
||||
$_POST['template_'.$language['id_lang']] = '';
|
||||
}
|
||||
parent::postProcess();
|
||||
}
|
||||
elseif (isset($_GET['delete'.$this->table]))
|
||||
{
|
||||
$orderState = new OrderState(intval($_GET['id_order_state']));
|
||||
if (!$orderState->isRemovable())
|
||||
$this->_errors[] = $this->l('For security reasons, you cannot delete default order statuses.');
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
elseif (isset($_POST['submitDelorder_state']))
|
||||
{
|
||||
foreach ($_POST[$this->table.'Box'] AS $selection)
|
||||
{
|
||||
$orderState = new OrderState(intval($selection));
|
||||
if (!$orderState->isRemovable())
|
||||
{
|
||||
$this->_errors[] = $this->l('For security reasons, you cannot delete default order statuses.');
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (empty($this->_errors))
|
||||
parent::postProcess();
|
||||
}
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
private function getTemplates($iso_code)
|
||||
{
|
||||
$array = array();
|
||||
if (!file_exists(PS_ADMIN_DIR.'/../mails/'.$iso_code))
|
||||
return false;
|
||||
$templates = scandir(PS_ADMIN_DIR.'/../mails/'.$iso_code);
|
||||
foreach ($templates AS $template)
|
||||
if (!strncmp(strrev($template), 'lmth.', 5))
|
||||
$array[] = substr($template, 0, -5);
|
||||
return $array;
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" enctype="multipart/form-data">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset class="width3"><legend><img src="../img/admin/time.gif" />'.$this->l('Order statues').'</legend>
|
||||
<label>'.$this->l('Status name:').' </label>
|
||||
<div class="margin-form">';
|
||||
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="name_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="40" type="text" name="name_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" style="width: 150px;" /><sup> *</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters: numbers and').' !<>,;?=+()@#"<22>{}_$%:<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name¤template', 'name');
|
||||
|
||||
echo ' <p class="clear">'.$this->l('Order status (e.g., \'Pending\')').'</p>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<label>'.$this->l('Icon:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="file" name="icon" />
|
||||
<p>'.$this->l('Upload an icon from your computer (File type: .gif, suggested size: 16x16)').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Color:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" name="color" value="'.htmlentities($this->getFieldValue($obj, 'color'), ENT_COMPAT, 'UTF-8').'" />
|
||||
<p>'.$this->l('Status will be highlighted in this color. HTML colors only (e.g.,').' "lightblue", "#CC6600")</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<p>
|
||||
<input type="checkbox" style="vertical-align: text-bottom;" name="logable"'.(($this->getFieldValue($obj, 'logable') == 1) ? ' checked="checked"' : '').' id="logable_on" value="1" />
|
||||
<label class="t" for="logable_on"> '.$this->l('Consider the associated order as validated').'</label>
|
||||
</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<p>
|
||||
<input type="checkbox" style="vertical-align: text-bottom;" name="invoice"'.(($this->getFieldValue($obj, 'invoice') == 1) ? ' checked="checked"' : '').' id="invoice_on" value="1" />
|
||||
<label class="t" for="invoice_on"> '.$this->l('Allow customer to download and view PDF version of invoice').'</label>
|
||||
</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<p>
|
||||
<input type="checkbox" style="vertical-align: text-bottom;" name="hidden"'.(($this->getFieldValue($obj, 'hidden') == 1) ? ' checked="checked"' : '').' id="hidden_on" value="1" />
|
||||
<label class="t" for="hidden_on"> '.$this->l('Hide this state in order for customer').'</label>
|
||||
</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<p>
|
||||
<input type="checkbox" style="vertical-align: text-bottom;" id="send_email" name="send_email" onclick="javascript:openCloseLayer(\'tpl\');"'.
|
||||
(($this->getFieldValue($obj, 'send_email')) ? 'checked="checked"' : '').' value="1" />
|
||||
<label class="t" for="send_email"> '.$this->l('Send e-mail to customer when order is changed to this status').'</label>
|
||||
</p>
|
||||
</div>
|
||||
<div id="tpl" style="display: '.($this->getFieldValue($obj, 'send_email') ? 'block' : 'none').';">
|
||||
<label>'.$this->l('Template:').'</label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
{
|
||||
$templates = $this->getTemplates($language['iso_code']);
|
||||
echo ' <div id="template_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">';
|
||||
if (!$templates)
|
||||
echo '<strong>'.$this->l('Please first copy your e-mail templates in the directory').' mails/'.$language['iso_code'].'.</strong>';
|
||||
else
|
||||
{
|
||||
echo ' <select name="template_'.$language['id_lang'].'" id="template_select_'.$language['id_lang'].'">';
|
||||
foreach ($templates AS $template)
|
||||
echo ' <option value="'.$template.'" '.(($this->getFieldValue($obj, 'template', intval($language['id_lang'])) == $template) ? 'selected="selected"' : '').'>'.$template.'</option>';
|
||||
echo ' </select>';
|
||||
}
|
||||
echo ' <span class="hint" name="help_box">'.$this->l('Only letters, number and -_ are allowed').'<span class="hint-pointer"> </span></span>
|
||||
<img onclick="viewTemplates(\'template_select_'.$language['id_lang'].'\', '.$language['id_lang'].', \'../mails/'.$language['iso_code'].'/\', \'.html\');" src="../img/t/AdminFeatures.gif" class="pointer" alt="'.$this->l('Preview').'" title="'.$this->l('Preview').'" />
|
||||
</div>';
|
||||
}
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name¤template', 'template');
|
||||
echo '<p style="clear: both">'.$this->l('E-mail template for both .html and .txt').'</p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">if (getE(\'send_email\').checked) getE(\'tpl\').style.display = \'block\'; else getE(\'tpl\').style.display = \'none\';</script>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PDF tab for admin panel, AdminPDF.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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');
|
||||
include_once(PS_ADMIN_DIR.'/tabs/AdminPreferences.php');
|
||||
|
||||
class AdminPDF extends AdminPreferences
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$lang = strtoupper(Language::getIsoById($cookie->id_lang));
|
||||
$this->className = 'Configuration';
|
||||
$this->table = 'configuration';
|
||||
|
||||
/* Collect all font files and build array for combo box */
|
||||
$fontFiles = scandir(_PS_FPDF_PATH_.'font');
|
||||
$fontList = array();
|
||||
$arr = array();
|
||||
|
||||
foreach ($fontFiles as $file)
|
||||
if (substr($file, -4) == '.php' AND $file != 'index.php')
|
||||
{
|
||||
$arr['mode'] = substr($file, 0, -4);
|
||||
$arr['name'] = substr($file, 0, -4);
|
||||
array_push($fontList, $arr);
|
||||
}
|
||||
|
||||
/* Collect all encoding map files and build array for combo box */
|
||||
$encodingFiles = scandir(_PS_FPDF_PATH_.'font/makefont');
|
||||
$encodingList = array();
|
||||
$arr = array();
|
||||
foreach ($encodingFiles as $file)
|
||||
if (substr($file, -4) == '.map')
|
||||
{
|
||||
$arr['mode'] = substr($file, 0, -4);
|
||||
$arr['name'] = substr($file, 0, -4);
|
||||
array_push($encodingList, $arr);
|
||||
}
|
||||
|
||||
$this->_fieldsPDF = array(
|
||||
'PS_PDF_ENCODING_'.$lang => array(
|
||||
'title' => $this->l('Encoding:'),
|
||||
'desc' => $this->l('Encoding for PDF invoice'),
|
||||
'type' => 'select',
|
||||
'cast' => 'strval',
|
||||
'identifier' => 'mode',
|
||||
'list' => $encodingList),
|
||||
'PS_PDF_FONT_'.$lang => array(
|
||||
'title' => $this->l('Font:'),
|
||||
'desc' => $this->l('Font for PDF invoice'),
|
||||
'type' => 'select',
|
||||
'cast' => 'strval',
|
||||
'identifier' => 'mode',
|
||||
'list' => $fontList)
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (isset($_POST['submitPDF'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
$this->_postConfig($this->_fieldsPDF);
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$language = new Language(intval($cookie->id_lang));
|
||||
if (!Validate::isLoadedObject($language))
|
||||
die(Tools::displayError());
|
||||
$this->_displayForm('PDF', $this->_fieldsPDF, $this->l('PDF settings for the current language:').' '.$language->name, 'width2', 'pdf');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Product preferences tab for admin panel, AdminPPreferences.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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');
|
||||
include_once(PS_ADMIN_DIR.'/tabs/AdminPreferences.php');
|
||||
|
||||
class AdminPPreferences extends AdminPreferences
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->className = 'Configuration';
|
||||
$this->table = 'configuration';
|
||||
|
||||
$this->_fieldsProduct = array(
|
||||
'PS_ORDER_OUT_OF_STOCK' => array('title' => $this->l('Allow ordering out-of-stock product:'), 'desc' => $this->l('Add to cart button is hidden when product is unavailable'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => true, 'type' => 'bool'),
|
||||
'PS_STOCK_MANAGEMENT' => array('title' => $this->l('Enable stock management:'), 'desc' => '', 'validation' => 'isBool', 'cast' => 'intval', 'required' => true, 'type' => 'bool', 'js' => array('on' => 'onchange="stockManagementActivationAuthorization()"', 'off' => 'onchange="stockManagementActivationAuthorization()"')),
|
||||
'PS_DISPLAY_QTIES' => array('title' => $this->l('Display available quantities on product page:'), 'desc' => '', 'validation' => 'isBool', 'cast' => 'intval', 'required' => true, 'type' => 'bool'),
|
||||
'PS_DISPLAY_JQZOOM' => array('title' => $this->l('Enable JqZoom instead of Thickbox on product page:'), 'desc' => '', 'validation' => 'isBool', 'cast' => 'intval', 'required' => true, 'type' => 'bool'),
|
||||
'PS_DISP_UNAVAILABLE_ATTR' => array('title' => $this->l('Display unavailable product attributes on product page:'), 'desc' => '', 'validation' => 'isBool', 'cast' => 'intval', 'required' => true, 'type' => 'bool'),
|
||||
'PS_PURCHASE_MINIMUM' => array('title' => $this->l('Minimum purchase total required in order to validate order:'), 'desc' => $this->l('Set to 0 to disable this feature'), 'validation' => 'isFloat', 'cast' => 'floatval', 'type' => 'price'),
|
||||
'PS_LAST_QTIES' => array('title' => $this->l('Display last quantities when qty is lower than:'), 'desc' => $this->l('Set to 0 to disable this feature'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'),
|
||||
'PS_NB_DAYS_NEW_PRODUCT' => array('title' => $this->l('Number of days during which the product is considered \'new\':'), 'validation' => 'isUnsignedInt', 'cast' => 'intval', 'type' => 'text'),
|
||||
'PS_CART_REDIRECT' => array('title' => $this->l('Re-direction after adding product to cart:'), 'desc' => $this->l('Concerns only the non-AJAX version of the cart'), 'cast' => 'intval', 'show' => true, 'required' => true, 'type' => 'radio', 'validation' => 'isBool', 'choices' => array(0 => $this->l('previous page'), 1 => $this->l('cart summary'))),
|
||||
'PS_PRODUCTS_PER_PAGE' => array('title' => $this->l('Products per page:'), 'desc' => $this->l('Products displayed per page. Default is 10.'), 'validation' => 'isUnsignedInt', 'cast' => 'intval', 'type' => 'text'),
|
||||
'PS_PRODUCTS_ORDER_BY' => array('title' => $this->l('Default order by:'), 'desc' => $this->l('Default order by for product list'), 'type' => 'select', 'list' =>
|
||||
array(
|
||||
array('id' => '0', 'name' => $this->l('Product name')),
|
||||
array('id' => '1', 'name' => $this->l('Product price')),
|
||||
array('id' => '2', 'name' => $this->l('Product added date')),
|
||||
array('id' => '4', 'name' => $this->l('Position inside category')),
|
||||
array('id' => '5', 'name' => $this->l('Manufacturer')),
|
||||
array('id' => '3', 'name' => $this->l('Product modified date'))
|
||||
), 'identifier' => 'id'),
|
||||
'PS_PRODUCTS_ORDER_WAY' => array('title' => $this->l('Default order way:'), 'desc' => $this->l('Default order way for product list'), 'type' => 'select', 'list' => array(array('id' => '0', 'name' => $this->l('Ascending')), array('id' => '1', 'name' => $this->l('Decreasing'))), 'identifier' => 'id'),
|
||||
'PS_IMAGE_GENERATION_METHOD' => array('title' => $this->l('Image generated by:'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'select', 'list' => array(array('id' => '0', 'name' => $this->l('auto')), array('id' => '1', 'name' => $this->l('width')), array('id' => '2', 'name' => $this->l('height'))), 'identifier' => 'id'),
|
||||
'PS_PRODUCT_PICTURE_MAX_SIZE' => array('title' => $this->l('Maximum size of product pictures:'), 'desc' => $this->l('The maximum size of pictures uploadable by customers (in Bytes)'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'),
|
||||
'PS_PRODUCT_PICTURE_WIDTH' => array('title' => $this->l('Product pictures width:'), 'desc' => $this->l('The maximum width of pictures uploadable by customers'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'),
|
||||
'PS_PRODUCT_PICTURE_HEIGHT' => array('title' => $this->l('Product pictures height:'), 'desc' => $this->l('The maximum height of pictures uploadable by customers'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text')
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (isset($_POST['submitProducts'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['add'] === '1')
|
||||
{
|
||||
if(!Tools::getValue('PS_STOCK_MANAGEMENT'))
|
||||
{
|
||||
$_POST['PS_ORDER_OUT_OF_STOCK'] = 1;
|
||||
$_POST['PS_DISPLAY_QTIES'] = 0;
|
||||
}
|
||||
$this->_postConfig($this->_fieldsProduct);
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to add anything here.');
|
||||
}
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$this->_displayForm('products', $this->_fieldsProduct, $this->l('Products'), 'width3', 'tab-orders');
|
||||
echo '<script type="text/javascript">stockManagementActivationAuthorization();</script>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,241 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Payment tab for admin panel, AdminPayment.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminPayment extends AdminTab
|
||||
{
|
||||
public $paymentModules = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
/* Get all modules then select only payment ones*/
|
||||
$modules = Module::getModulesOnDisk();
|
||||
foreach ($modules AS $module)
|
||||
if ($module->tab == 'Payment')
|
||||
{
|
||||
if($module->id)
|
||||
{
|
||||
$module->country = array();
|
||||
$countries = DB::getInstance()->ExecuteS('SELECT id_country FROM '._DB_PREFIX_.'module_country WHERE id_module = '.intval($module->id));
|
||||
foreach ($countries as $country)
|
||||
$module->country[] = $country['id_country'];
|
||||
|
||||
$module->currency = array();
|
||||
$currencies = DB::getInstance()->ExecuteS('SELECT id_currency FROM '._DB_PREFIX_.'module_currency WHERE id_module = '.intval($module->id));
|
||||
foreach ($currencies as $currency)
|
||||
$module->currency[] = $currency['id_currency'];
|
||||
|
||||
$module->group = array();
|
||||
$groups = DB::getInstance()->ExecuteS('SELECT id_group FROM '._DB_PREFIX_.'module_group WHERE id_module = '.intval($module->id));
|
||||
foreach ($groups as $group)
|
||||
$module->group[] = $group['id_group'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$module->country = NULL;
|
||||
$module->currency = NULL;
|
||||
$module->group = NULL;
|
||||
}
|
||||
|
||||
$this->paymentModules[] = $module;
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::isSubmit('submitModulecountry'))
|
||||
$this->saveRestrictions('country');
|
||||
elseif (Tools::isSubmit('submitModulecurrency'))
|
||||
$this->saveRestrictions('currency');
|
||||
elseif (Tools::isSubmit('submitModulegroup'))
|
||||
$this->saveRestrictions('group');
|
||||
}
|
||||
|
||||
private function saveRestrictions($type)
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
Db::getInstance()->Execute('TRUNCATE '._DB_PREFIX_.'module_'.$type.'');
|
||||
foreach ($this->paymentModules as $module)
|
||||
if ($module->active AND isset($_POST[$module->name.'_'.$type.'']))
|
||||
foreach ($_POST[$module->name.'_'.$type.''] as $selected)
|
||||
$values[] = '('.intval($module->id).', '.intval($selected).')';
|
||||
Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'module_'.$type.' (`id_module`, `id_'.$type.'`) VALUES '.implode(',', $values));
|
||||
Tools::redirectAdmin($currentIndex.'&conf=4'.'&token='.$this->token);
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
foreach ($this->paymentModules AS $module)
|
||||
if ($module->active AND $module->warning)
|
||||
$this->displayWarning($module->displayName.' - '.stripslashes(pSQL($module->warning)));
|
||||
|
||||
$currencies = Currency::getCurrencies();
|
||||
$countries = Country::getCountries(intval($cookie->id_lang));
|
||||
$groups = Group::getGroups(intval($cookie->id_lang));
|
||||
|
||||
$this->displayModules();
|
||||
echo '<br /><h2 class="space">'.$this->l('Payment module restrictions').'</h2>';
|
||||
$textCurrencies = $this->l('Please mark the checkbox(es) for the currency or currencies in which you want the payment module(s) available.');
|
||||
$textCountries = $this->l('Please mark the checkbox(es) for the country or countries in which you want the payment module(s) available.');
|
||||
$textGroups = $this->l('Please mark the checkbox(es) for the groups in which you want the payment module(s) available.');
|
||||
$this->displayModuleRestrictions($currencies, $this->l('Currencies restrictions'), 'currency', $textCurrencies, 'dollar');
|
||||
echo '<br />';
|
||||
$this->displayModuleRestrictions($groups, $this->l('Groups restrictions'), 'group', $textGroups, 'group');
|
||||
echo '<br />';
|
||||
$this->displayModuleRestrictions($countries, $this->l('Countries restrictions'), 'country', $textCountries, 'world');
|
||||
}
|
||||
|
||||
public function displayModuleRestrictions($items, $title, $nameId, $desc, $icon)
|
||||
{
|
||||
global $currentIndex;
|
||||
$irow = 0;
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&token='.$this->token.'" method="post" class="width3" id="form_'.$nameId.'">
|
||||
<fieldset>
|
||||
<legend><img src="../img/admin/'.$icon.'.gif" />'.$title.'</legend>
|
||||
<p>'.$desc.'<p>
|
||||
<table cellpadding="0" cellspacing="0" class="table">
|
||||
<tr>
|
||||
<th style="width: 200px">'.$title.'</th>';
|
||||
foreach ($this->paymentModules as $module)
|
||||
{
|
||||
if ($module->active)
|
||||
{
|
||||
echo '
|
||||
<th>';
|
||||
if ($nameId != 'currency' OR ($nameId == 'currency' AND $module->currencies_mode == 'checkbox'))
|
||||
echo '
|
||||
<input type="hidden" id="checkedBox_'.$nameId.'_'.$module->name.'" value="checked">
|
||||
<a href="javascript:checkPaymentBoxes(\''.$nameId.'\', \''.$module->name.'\')" style="text-decoration:none;">';
|
||||
echo '
|
||||
<img src="'.__PS_BASE_URI__.'modules/'.$module->name.'/logo.gif" alt="'.$module->name.'" title="'.$module->displayName.'" />';
|
||||
if ($nameId != 'currency' OR ($nameId == 'currency' AND $module->currencies_mode == 'checkbox'))
|
||||
echo '
|
||||
</a>';
|
||||
echo '
|
||||
</th>';
|
||||
}
|
||||
}
|
||||
echo '
|
||||
</tr>';
|
||||
foreach ($items as $item)
|
||||
{
|
||||
echo '
|
||||
<tr'.($irow++ % 2 ? ' class="alt_row"' : '').'>
|
||||
<td>'.$item['name'].'</td>';
|
||||
foreach ($this->paymentModules as $module)
|
||||
{
|
||||
if ($module->active)
|
||||
{
|
||||
echo '
|
||||
<td style="text-align: center">';
|
||||
if ($nameId != 'currency' OR ($nameId == 'currency' AND $module->currencies AND $module->currencies_mode == 'checkbox'))
|
||||
echo '
|
||||
<input type="checkbox" name="'.$module->name.'_'.$nameId.'[]" value="'.$item['id_'.$nameId].'"'.(in_array($item['id_'.$nameId.''], $module->{$nameId}) ? ' checked="checked"' : '').' />';
|
||||
elseif ($nameId == 'currency' AND $module->currencies AND $module->currencies_mode == 'radio')
|
||||
echo '
|
||||
<input type="radio" name="'.$module->name.'_'.$nameId.'[]" value="'.$item['id_'.$nameId].'"'.(in_array($item['id_'.$nameId.''], $module->{$nameId}) ? ' checked="checked"' : '').' />';
|
||||
elseif ($nameId == 'currency')
|
||||
echo '--';
|
||||
echo '
|
||||
</td>';
|
||||
}
|
||||
}
|
||||
echo '
|
||||
</tr>';
|
||||
}
|
||||
if ($nameId == 'currency')
|
||||
{
|
||||
echo '
|
||||
<tr'.($irow++ % 2 ? ' class="alt_row"' : '').'>
|
||||
<td>'.$this->l('Customer currency').'</td>';
|
||||
foreach ($this->paymentModules as $module)
|
||||
if ($module->active)
|
||||
echo '
|
||||
<td style="text-align: center">'.(($module->currencies AND $module->currencies_mode == 'radio') ? '<input type="radio" name="'.$module->name.'_'.$nameId.'[]" value="-1"'.(in_array(-1, $module->{$nameId}) ? ' checked="checked"' : '').' />' : '--').'</td>';
|
||||
echo '
|
||||
</tr>';
|
||||
echo '
|
||||
<tr'.($irow++ % 2 ? ' class="alt_row"' : '').'>
|
||||
<td>'.$this->l('Shop default currency').'</td>';
|
||||
foreach ($this->paymentModules as $module)
|
||||
if ($module->active)
|
||||
echo '
|
||||
<td style="text-align: center">'.(($module->currencies AND $module->currencies_mode == 'radio') ? '<input type="radio" name="'.$module->name.'_'.$nameId.'[]" value="-2"'.(in_array(-2, $module->{$nameId}) ? ' checked="checked"' : '').' />' : '--').'</td>';
|
||||
echo '
|
||||
</tr>';
|
||||
}
|
||||
echo '
|
||||
</table>
|
||||
<div style="text-align:center;"><input type="submit" class="button space" name="submitModule'.$nameId.'" value="'.$this->l('Save restrictions').'" /></div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
public function displayModules()
|
||||
{
|
||||
global $cookie;
|
||||
$irow = 0;
|
||||
|
||||
echo '
|
||||
<h2 class="space">'.$this->l('Payment modules list').'</h2>
|
||||
<table cellpadding="0" cellspacing="0" class="table width3">
|
||||
<tr>
|
||||
<th colspan="4" class="center">
|
||||
<strong><span style="color: red">'.sizeof($this->paymentModules).'</span> '.((sizeof($this->paymentModules) > 1) ? $this->l('payment modules') : $this->l('payment module')).'</strong>
|
||||
</th>
|
||||
</tr>';
|
||||
$tokenModules = Tools::getAdminToken('AdminModules'.intval(Tab::getIdFromClassName('AdminModules')).intval($cookie->id_employee));
|
||||
/* Display payment modules */
|
||||
foreach ($this->paymentModules as $module)
|
||||
{
|
||||
if ($module->id)
|
||||
{
|
||||
$img = '<img src="../img/admin/enabled.gif" alt="disabled" title="'.$this->l('Module enabled').'" />';
|
||||
if ($module->warning)
|
||||
$img = '<img src="../img/admin/warning.gif" alt="disabled" title="'.$this->l('Module installed but with warnings').'" />';
|
||||
if (!$module->active)
|
||||
$img = '<img src="../img/admin/disabled.gif" alt="disabled" title="'.$this->l('Module disabled').'" />';
|
||||
} else
|
||||
$img = '<img src="../img/admin/cog.gif" alt="install" title="'.$this->l('Module no installed').'" />';
|
||||
echo '
|
||||
<tr'.($irow++ % 2 ? ' class="alt_row"' : '').' style="height: 42px;">
|
||||
<td style="padding-left: 10px;"><img src="../modules/'.$module->name.'/logo.gif" alt="" /> <strong>'.stripslashes($module->displayName).'</strong>'.($module->version ? ' v'.$module->version.(strpos($module->version, '.') !== false ? '' : '.0') : '').'<br />'.$module->description.'</td>
|
||||
<td width="85">'.(($module->active AND method_exists($module, 'getContent')) ? '<a href="index.php?tab=AdminModules&configure='.urlencode($module->name).'&token='.$tokenModules.'">'.$this->l('>> Configure').'</a>' : '').'</td>
|
||||
<td class="center" width="20">';
|
||||
if ($module->id)
|
||||
echo '<a href="index.php?tab=AdminModules&token='.$tokenModules.'&module_name='.$module->name.'&'.($module->active ? 'desactive' : 'active').'">';
|
||||
echo $img;
|
||||
if ($module->id)
|
||||
'</a>';
|
||||
echo '
|
||||
</td>
|
||||
<td class="center" width="80">'.((!$module->id)
|
||||
? '<input type="button" class="button small" name="Install" value="'.$this->l('Install').'"
|
||||
onclick="javascript:document.location.href=\'index.php?tab=AdminModules&install='.urlencode($module->name).'&token='.$tokenModules.'\'" />'
|
||||
: '<input type="button" class="button small" name="Uninstall" value="'.$this->l('Uninstall').'"
|
||||
onclick="'.(empty($module->confirmUninstall) ? '' : 'if(confirm(\''.addslashes($module->confirmUninstall).'\')) ').'document.location.href=\'index.php?tab=AdminModules&uninstall='.urlencode($module->name).'&token='.$tokenModules.'\';" />').'</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,385 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* General preferences tab for admin panel, AdminPreferences.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminPreferences extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
global $cookie;
|
||||
|
||||
$this->className = 'Configuration';
|
||||
$this->table = 'configuration';
|
||||
|
||||
$tmz = Tools::getTimezones();
|
||||
$txs = Tax::getTaxes(intval($cookie->id_lang));
|
||||
$timezone = array();
|
||||
foreach ($tmz as $id => $name)
|
||||
$timezone[] = array('id' => $id, 'name' => $name);
|
||||
$taxes[] = array('id' => 0, 'name' => $this->l('None'));
|
||||
foreach ($txs as $tax)
|
||||
$taxes[] = array('id' => $tax['id_tax'], 'name' => $tax['name']);
|
||||
|
||||
$round_mode = array(
|
||||
array(
|
||||
'value' => PS_ROUND_UP,
|
||||
'name' => $this->l('superior')
|
||||
),
|
||||
array(
|
||||
'value' => PS_ROUND_DOWN,
|
||||
'name' => $this->l('inferior')
|
||||
),
|
||||
array(
|
||||
'value' => PS_ROUND_HALF,
|
||||
'name' => $this->l('classical')
|
||||
)
|
||||
);
|
||||
|
||||
$this->_fieldsGeneral = array(
|
||||
'PS_BASE_URI' => array('title' => $this->l('PS directory:'), 'desc' => $this->l('Name of the PrestaShop directory on your Web server, bracketed by forward slashes (e.g., /shop/)'), 'validation' => 'isGenericName', 'type' => 'text', 'size' => 20, 'default' => '/'),
|
||||
'PS_SHOP_ENABLE' => array('title' => $this->l('Enable Shop:'), 'desc' => $this->l('Activate or deactivate your shop. Deactivate your shop while you perform maintenance on it'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
|
||||
'PS_MAINTENANCE_IP' => array('title' => $this->l('Maintenance IP:'), 'desc' => $this->l('IP addresses allowed to access the Front Office even if shop is disabled. Use coma to separate them (e.g., 42.24.4.2,127.0.0.1,99.98.97.96)'), 'validation' => 'isGenericName', 'type' => 'text', 'size' => 15, 'default' => ''),
|
||||
'PS_SSL_ENABLED' => array('title' => $this->l('Enable SSL'), 'desc' => $this->l('If your hosting provider allows SSL, you can activate SSL encryption (https://) for customer account identification and order processing'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0'),
|
||||
'PS_TOKEN_ENABLE' => array('title' => $this->l('Increase Front Office security'), 'desc' => $this->l('Enable or disable token on the Front Office in order to improve PrestaShop security'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'default' => '0'),
|
||||
'PS_REWRITING_SETTINGS' => array('title' => $this->l('Friendly URL:'), 'desc' => $this->l('Enable only if your server allows URL rewriting (recommended)').'<p class="hint clear" style="display: block;">'.$this->l('If you turn on this feature, you must').' <a href="?tab=AdminGenerator&token='.Tools::getAdminToken('AdminGenerator'.intval(Tab::getIdFromClassName('AdminGenerator')).intval($cookie->id_employee)).'">'.$this->l('generate a .htaccess file').'</a></p><div class="clear"></div>', 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
|
||||
'PS_HELPBOX' => array('title' => $this->l('Back Office help boxes:'), 'desc' => $this->l('Enable yellow help boxes which are displayed under form fields in the Back Office'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
|
||||
'PS_CONDITIONS' => array('title' => $this->l('Terms of service:'), 'desc' => $this->l('Require customers to accept or decline terms of service before processing the order'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
|
||||
'PS_GIFT_WRAPPING' => array('title' => $this->l('Offer gift-wrapping:'), 'desc' => $this->l('Suggest gift-wrapping to customer and possibility of leaving a message'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
|
||||
'PS_GIFT_WRAPPING_PRICE' => array('title' => $this->l('Gift-wrapping price:'), 'desc' => $this->l('Set a price for gift-wrapping'), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'price'),
|
||||
'PS_GIFT_WRAPPING_TAX' => array('title' => $this->l('Gift-wrapping tax:'), 'desc' => $this->l('Set a tax for gift-wrapping'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $taxes, 'identifier' => 'id'),
|
||||
'PS_RECYCLABLE_PACK' => array('title' => $this->l('Offer recycled packaging:'), 'desc' => $this->l('Suggest recycled packaging to customer'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
|
||||
'PS_CART_FOLLOWING' => array('title' => $this->l('Cart re-display at login:'), 'desc' => $this->l('After customer logs in, recall and display contents of his/her last shopping cart'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
|
||||
'PS_PRICE_ROUND_MODE' => array('title' => $this->l('Round mode:'), 'desc' => $this->l('You can choose the rounding of prices, rounding always superior, inferior or classical rounding.'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $round_mode, 'identifier' => 'value'),
|
||||
'PRESTASTORE_LIVE' => array('title' => $this->l('Automatically check updates to modules'), 'desc' => $this->l('New modules and updates are displayed on the modules page'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'));
|
||||
if (function_exists('date_default_timezone_set'))
|
||||
$this->_fieldsGeneral['PS_TIMEZONE'] = array('title' => $this->l('Timezone:'), 'validation' => 'isUnsignedId', 'cast' => 'intval', 'type' => 'select', 'list' => $timezone, 'identifier' => 'id');
|
||||
$this->_fieldsGeneral['PS_THEME_V11'] = array('title' => $this->l('v1.1 theme compatibility:'), 'desc' => $this->l('My shop use a PrestaShop v1.1 theme (SSL will generate warnings in customer browser)'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool');
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$this->_displayForm('general', $this->_fieldsGeneral, $this->l('General'), 'width2', 'tab-preferences');
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if (isset($_POST['submitGeneral'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
$this->_postConfig($this->_fieldsGeneral);
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
elseif (isset($_POST['submitShop'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
$this->_postConfig($this->_fieldsShop);
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
elseif (isset($_POST['submitAppearance'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
$this->_postConfig($this->_fieldsAppearance);
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
elseif (isset($_POST['submitThemes'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if ($val = Tools::getValue('PS_THEME'))
|
||||
{
|
||||
if (rewriteSettingsFile(NULL, $val, NULL))
|
||||
Tools::redirectAdmin($currentIndex.'&conf=6'.'&token='.$this->token);
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('cannot access settings file');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('you must choose a graphical theme');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update settings in database and configuration files
|
||||
*
|
||||
* @params array $fields Fields settings
|
||||
*
|
||||
* @global string $currentIndex Current URL in order to keep current Tab
|
||||
*/
|
||||
protected function _postConfig($fields)
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
$languages = Language::getLanguages();
|
||||
|
||||
/* Check required fields */
|
||||
foreach ($fields AS $field => $values)
|
||||
if (isset($values['required']) AND $values['required'])
|
||||
if ($values['type'] == 'textLang')
|
||||
{
|
||||
foreach ($languages as $language)
|
||||
if (($value = Tools::getValue($field.'_'.$language['id_lang'])) == false AND (string)$value != '0')
|
||||
$this->_errors[] = Tools::displayError('field').' <b>'.$values['title'].'</b> '.Tools::displayError('is required');
|
||||
}
|
||||
elseif (($value = Tools::getValue($field)) == false AND (string)$value != '0')
|
||||
$this->_errors[] = Tools::displayError('field').' <b>'.$values['title'].'</b> '.Tools::displayError('is required');
|
||||
|
||||
/* Check fields validity */
|
||||
foreach ($fields AS $field => $values)
|
||||
if ($values['type'] == 'textLang')
|
||||
{
|
||||
foreach ($languages as $language)
|
||||
if (Tools::getValue($field.'_'.$language['id_lang']) AND isset($values['validation']))
|
||||
if (!Validate::$values['validation'](Tools::getValue($field.'_'.$language['id_lang'])))
|
||||
$this->_errors[] = Tools::displayError('field').' <b>'.$values['title'].'</b> '.Tools::displayError('is invalid');
|
||||
}
|
||||
elseif (Tools::getValue($field) AND isset($values['validation']))
|
||||
if (!Validate::$values['validation'](Tools::getValue($field)))
|
||||
$this->_errors[] = Tools::displayError('field').' <b>'.$values['title'].'</b> '.Tools::displayError('is invalid');
|
||||
|
||||
/* Default value if null */
|
||||
foreach ($fields AS $field => $values)
|
||||
if (!Tools::getValue($field) AND isset($values['default']))
|
||||
$_POST[$field] = $values['default'];
|
||||
|
||||
/* Save process */
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
if (isset($_POST['submitGeneral'.$this->table]))
|
||||
{
|
||||
rewriteSettingsFile(isset($_POST['PS_BASE_URI']) ? $_POST['PS_BASE_URI'] : '', NULL, NULL);
|
||||
unset($this->_fieldsGeneral['PS_BASE_URI']);
|
||||
}
|
||||
elseif (isset($_POST['submitAppearance'.$this->table]))
|
||||
{
|
||||
if (isset($_FILES['PS_LOGO']['tmp_name']) AND $_FILES['PS_LOGO']['tmp_name'])
|
||||
{
|
||||
if ($error = checkImage($_FILES['PS_LOGO'], 300000))
|
||||
$this->_errors[] = $error;
|
||||
if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') OR !move_uploaded_file($_FILES['PS_LOGO']['tmp_name'], $tmpName))
|
||||
return false;
|
||||
elseif (!@imageResize($tmpName, _PS_IMG_DIR_.'logo.jpg'))
|
||||
$this->_errors[] = 'an error occured during logo copy';
|
||||
unlink($tmpName);
|
||||
}
|
||||
$this->uploadIco('PS_FAVICON', _PS_IMG_DIR_.'favicon.ico');
|
||||
}
|
||||
|
||||
/* Update settings in database */
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
foreach ($fields AS $field => $values)
|
||||
{
|
||||
unset($val);
|
||||
if ($values['type'] == 'textLang')
|
||||
foreach ($languages as $language)
|
||||
$val[$language['id_lang']] = isset($values['cast']) ? $values['cast'](Tools::getValue($field.'_'.$language['id_lang'])) : Tools::getValue($field.'_'.$language['id_lang']);
|
||||
else
|
||||
$val = isset($values['cast']) ? $values['cast'](Tools::getValue($field)) : Tools::getValue($field);
|
||||
Configuration::updateValue($field, $val);
|
||||
}
|
||||
Tools::redirectAdmin($currentIndex.'&conf=6'.'&token='.$this->token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getVal($conf, $key)
|
||||
{
|
||||
return Tools::getValue($key, (isset($conf[$key]) ? $conf[$key] : ''));
|
||||
}
|
||||
|
||||
private function getConf($fields, $languages)
|
||||
{
|
||||
foreach ($fields AS $key => $field)
|
||||
{
|
||||
if ($field['type'] == 'textLang')
|
||||
foreach ($languages as $language)
|
||||
$tab[$key.'_'.$language['id_lang']] = Tools::getValue($key.'_'.$language['id_lang'], Configuration::get($key, $language['id_lang']));
|
||||
else
|
||||
$tab[$key] = Tools::getValue($key, Configuration::get($key));
|
||||
}
|
||||
$tab['PS_BASE_URI'] = __PS_BASE_URI__;
|
||||
$tab['PS_THEME'] = _THEME_NAME_;
|
||||
$tab['db_type'] = _DB_TYPE_;
|
||||
$tab['db_server'] = _DB_SERVER_;
|
||||
$tab['db_name'] = _DB_NAME_;
|
||||
$tab['db_prefix'] = _DB_PREFIX_;
|
||||
$tab['db_user'] = _DB_USER_;
|
||||
$tab['db_passwd'] = '';
|
||||
return $tab;
|
||||
}
|
||||
|
||||
private function getDivLang($fields)
|
||||
{
|
||||
$tab = array();
|
||||
foreach ($fields AS $key => $field)
|
||||
if ($field['type'] == 'textLang')
|
||||
$tab[] = $key;
|
||||
return implode('¤', $tab);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display configuration form
|
||||
*
|
||||
* @params string $name Form name
|
||||
* @params array $fields Fields settings
|
||||
*
|
||||
* @global string $currentIndex Current URL in order to keep current Tab
|
||||
*/
|
||||
protected function _displayForm($name, $fields, $tabname, $size, $icon)
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
$defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
|
||||
$languages = Language::getLanguages();
|
||||
$confValues = $this->getConf($fields, $languages);
|
||||
$divLangName = $this->getDivLang($fields);
|
||||
$required = false;
|
||||
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
id_language = Number('.$defaultLanguage.');
|
||||
</script>
|
||||
<form action="'.$currentIndex.'&submit'.$name.$this->table.'=1&token='.$this->token.'" method="post" class="'.$size.'" enctype="multipart/form-data">
|
||||
<fieldset><legend><img src="../img/admin/'.strval($icon).'.gif" />'.$tabname.'</legend>';
|
||||
foreach ($fields AS $key => $field)
|
||||
{
|
||||
/* Specific line for e-mails settings */
|
||||
if (get_class($this) == 'Adminemails' AND $key == 'PS_MAIL_SERVER')
|
||||
echo '<div id="smtp" style="display: '.((isset($confValues['PS_MAIL_METHOD']) AND $confValues['PS_MAIL_METHOD'] == 2) ? 'block' : 'none').';">';
|
||||
if (isset($field['required']) AND $field['required'])
|
||||
$required = true;
|
||||
$val = $this->getVal($confValues, $key);
|
||||
if (!in_array($field['type'], array('image', 'radio', 'container', 'container_end')) OR isset($field['show']))
|
||||
echo '<div style="clear: both; padding-top:15px;">'.($field['title'] ? '<label >'.$field['title'].'</label>' : '').'<div class="margin-form" style="padding-top:5px;">';
|
||||
|
||||
/* Display the appropriate input type for each field */
|
||||
switch ($field['type'])
|
||||
{
|
||||
case 'select':
|
||||
echo '
|
||||
<select name="'.$key.'"'.(isset($field['js']) === true ? ' onchange="'.$field['js'].'"' : '').(isset($field['id']) === true ? ' id="'.$field['id'].'"' : '').'>';
|
||||
foreach ($field['list'] AS $k => $value)
|
||||
echo '<option value="'.(isset($value['cast']) ? $value['cast']($value[$field['identifier']]) : $value[$field['identifier']]).'"'.(($val == $value[$field['identifier']]) ? ' selected="selected"' : '').'>'.$value['name'].'</option>';
|
||||
echo '
|
||||
</select>';
|
||||
break;
|
||||
|
||||
case 'bool':
|
||||
echo '<label class="t" for="'.$key.'_on"><img src="../img/admin/enabled.gif" alt="'.$this->l('Yes').'" title="'.$this->l('Yes').'" /></label>
|
||||
<input type="radio" name="'.$key.'" id="'.$key.'_on" value="1"'.($val ? ' checked="checked"' : '').(isset($field['js']['on']) ? $field['js']['on'] : '').' />
|
||||
<label class="t" for="'.$key.'_on"> '.$this->l('Yes').'</label>
|
||||
<label class="t" for="'.$key.'_off"><img src="../img/admin/disabled.gif" alt="'.$this->l('No').'" title="'.$this->l('No').'" style="margin-left: 10px;" /></label>
|
||||
<input type="radio" name="'.$key.'" id="'.$key.'_off" value="0" '.(!$val ? 'checked="checked"' : '').(isset($field['js']['off']) ? $field['js']['off'] : '').'/>
|
||||
<label class="t" for="'.$key.'_off"> '.$this->l('No').'</label>';
|
||||
break;
|
||||
|
||||
case 'radio':
|
||||
foreach ($field['choices'] AS $cValue => $cKey)
|
||||
echo '<input type="radio" name="'.$key.'" id="'.$key.$cValue.'_on" value="'.intval($cValue).'"'.(($cValue == $val) ? ' checked="checked"' : '').(isset($field['js'][$cValue]) ? ' '.$field['js'][$cValue] : '').' /><label class="t" for="'.$key.$cValue.'_on"> '.$cKey.'</label><br />';
|
||||
echo '<br />';
|
||||
break;
|
||||
|
||||
case 'image':
|
||||
echo '
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tr>';
|
||||
$i = 0;
|
||||
foreach ($field['list'] AS $theme)
|
||||
{
|
||||
echo '<td class="center" style="width: 180px; padding:0px 20px 20px 0px;">
|
||||
<input type="radio" name="'.$key.'" id="'.$key.'_'.$theme['name'].'_on" style="vertical-align: text-bottom;" value="'.$theme['name'].'"'.
|
||||
(_THEME_NAME_ == $theme['name'] ? 'checked="checked"' : '').' />
|
||||
<label class="t" for="'.$key.'_'.$theme['name'].'_on"> '.Tools::strtolower($theme['name']).'</label>
|
||||
<br />
|
||||
<label class="t" for="'.$key.'_'.$theme['name'].'_on">
|
||||
<img src="../themes/'.$theme['name'].'/preview.jpg" alt="'.Tools::strtolower($theme['name']).'">
|
||||
</label>
|
||||
</td>';
|
||||
if (isset($field['max']) AND ($i+1) % $field['max'] == 0)
|
||||
echo '</tr><tr>';
|
||||
$i++;
|
||||
}
|
||||
echo '</tr>
|
||||
</table>';
|
||||
break;
|
||||
|
||||
case 'price':
|
||||
$default_currency = new Currency(intval(Configuration::get("PS_CURRENCY_DEFAULT")));
|
||||
echo $default_currency->getSign('left').'<input type="'.$field['type'].'" size="'.(isset($field['size']) ? intval($field['size']) : 5).'" name="'.$key.'" value="'.($field['type'] == 'password' ? '' : htmlentities($val, ENT_COMPAT, 'UTF-8')).'" />'.$default_currency->getSign('right').' '.$this->l('(tax excl.)');
|
||||
break;
|
||||
|
||||
case 'textLang':
|
||||
foreach ($languages as $language)
|
||||
echo '
|
||||
<div id="'.$key.'_'.$language['id_lang'].'" style="margin-bottom:8px; display: '.($language['id_lang'] == $defaultLanguage ? 'block' : 'none').'; float: left; vertical-align: top;">
|
||||
<input type="text" size="'.(isset($field['size']) ? intval($field['size']) : 5).'" name="'.$key.'_'.$language['id_lang'].'" value="'.htmlentities($this->getVal($confValues, $key.'_'.$language['id_lang']), ENT_COMPAT, 'UTF-8').'" />
|
||||
</div>';
|
||||
$this->displayFlags($languages, $defaultLanguage, $divLangName, $key);
|
||||
break;
|
||||
|
||||
case 'file':
|
||||
if (isset($field['thumb']) AND $field['thumb'] AND $field['thumb']['pos'] == 'before')
|
||||
echo '<img src="'.$field['thumb']['file'].'" alt="'.$field['title'].'" title="'.$field['title'].'" /><br />';
|
||||
echo '<input type="file" name="'.$key.'" />';
|
||||
break;
|
||||
|
||||
case 'textarea':
|
||||
echo '<textarea name='.$key.' cols="'.$field['cols'].'" rows="'.$field['rows'].'">'.htmlentities($val, ENT_COMPAT, 'UTF-8').'</textarea>';
|
||||
break;
|
||||
|
||||
case 'container':
|
||||
echo '<div id="'.$key.'">';
|
||||
break;
|
||||
|
||||
case 'container_end':
|
||||
echo (isset($field['content']) === true ? $field['content'] : '').'</div>';
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
default:
|
||||
echo '<input type="'.$field['type'].'"'.(isset($field['id']) === true ? ' id="'.$field['id'].'"' : '').' size="'.(isset($field['size']) ? intval($field['size']) : 5).'" name="'.$key.'" value="'.($field['type'] == 'password' ? '' : htmlentities($val, ENT_COMPAT, 'UTF-8')).'" />'.(isset($field['next']) ? ' '.strval($field['next']) : '');
|
||||
}
|
||||
echo ((isset($field['required']) AND $field['required'] AND !in_array($field['type'], array('image', 'radio'))) ? ' <sup>*</sup>' : '');
|
||||
echo (isset($field['desc']) ? '<p style="clear:both">'.((isset($field['thumb']) AND $field['thumb'] AND $field['thumb']['pos'] == 'after') ? '<img src="'.$field['thumb']['file'].'" alt="'.$field['title'].'" title="'.$field['title'].'" style="float:left;" />' : '' ).$field['desc'].'</p>' : '');
|
||||
if (!in_array($field['type'], array('image', 'radio', 'container', 'container_end')) OR isset($field['show']))
|
||||
echo '</div></div>';
|
||||
}
|
||||
|
||||
/* End of specific div for e-mails settings */
|
||||
if (get_class($this) == 'Adminemails')
|
||||
echo '<script type="text/javascript">if (getE(\'PS_MAIL_METHOD2_on\').checked) getE(\'smtp\').style.display = \'block\'; else getE(\'smtp\').style.display = \'none\';</script></div>';
|
||||
|
||||
if(!is_writable(PS_ADMIN_DIR.'/../config/settings.inc.php') AND $name == 'themes')
|
||||
echo '<p><img src="../img/admin/warning.gif" alt="" /> '.$this->l('if you change theme, the settings.inc.php file must be writable (CHMOD 777)').'</p>';
|
||||
|
||||
echo ' <div align="center" style="margin-top: 20px;">
|
||||
<input type="submit" value="'.$this->l(' Save ', 'AdminPreferences').'" name="submit'.ucfirst($name).$this->table.'" class="button" />
|
||||
</div>
|
||||
'.($required ? '<div class="small"><sup>*</sup> '.$this->l('Required field', 'AdminPreferences').'</div>' : '').'
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Profiles tab for admin panel, AdminProfiles.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminProfiles extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'profile';
|
||||
$this->className = 'Profile';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_profile' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 200));
|
||||
$this->identifier = 'id_profile';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (isset($_GET['delete'.$this->table]) AND $_GET[$this->identifier] === '1')
|
||||
$this->_errors[] = $this->l('For security reasons, you cannot delete the Administrator profile');
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" class="width3">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/admin/profiles.png" />'.$this->l('Profiles').'</legend>
|
||||
<label>'.$this->l('Name:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="name_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="33" type="text" name="name_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name');
|
||||
echo ' <div class="clear"></div>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* QuickAccesses tab for admin panel, AdminQuickAccesses.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminQuickAccesses extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'quick_access';
|
||||
$this->className = 'QuickAccess';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_quick_access' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 200),
|
||||
'link' => array('title' => $this->l('Link'), 'width' => 300),
|
||||
'new_window' => array('title' => $this->l('New window'), 'align' => 'center', 'type' => 'bool', 'activeVisu' => 'new_window'));
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
$new_window = $this->getFieldValue($obj, 'new_window');
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" class="width4">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/admin/quick.gif" />'.$this->l('Quick Access menu').'</legend>
|
||||
<label>'.$this->l('Name:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="name_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="33" type="text" name="name_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name');
|
||||
echo '
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<label>'.$this->l('URL:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="60" maxlength="128" name="link" value="'.htmlentities($this->getFieldValue($obj, 'link'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
</div>
|
||||
<label>'.$this->l('Open in new window:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="new_window" id="new_window_on" value="1" '.($new_window ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="new_window_on"><img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Yes').'" /></label>
|
||||
<input type="radio" name="new_window" id="new_window_off" value="0" '.(!$new_window ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="new_window_off"><img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('No').'" /></label>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Price ranges tab for admin panel, AdminRangePrice.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminRangePrice extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'range_price';
|
||||
$this->className = 'RangePrice';
|
||||
$this->lang = false;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_range_price' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'carrier_name' => array('title' => $this->l('Carrier'), 'align' => 'center', 'width' => 25, 'filter_key' => 'ca!name'),
|
||||
'delimiter1' => array('title' => $this->l('From'), 'width' => 86, 'price' => true, 'align' => 'right'),
|
||||
'delimiter2' => array('title' => $this->l('To'), 'width' => 86, 'price' => true, 'align' => 'right'));
|
||||
|
||||
$this->_join = 'LEFT JOIN '._DB_PREFIX_.'carrier ca ON (ca.`id_carrier` = a.`id_carrier`)';
|
||||
$this->_select = 'ca.`name` AS carrier_name';
|
||||
$this->_where = 'AND ca.`deleted` = 0';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function displayListContent($token = NULL)
|
||||
{
|
||||
foreach ($this->_list as $key => $list)
|
||||
if ($list['carrier_name'] == '0')
|
||||
$this->_list[$key]['carrier_name'] = Configuration::get('PS_SHOP_NAME');
|
||||
parent::displayListContent($token);
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (isset($_POST['submitAdd'.$this->table]) AND Tools::getValue('delimiter1') >= Tools::getValue('delimiter2'))
|
||||
$this->_errors[] = Tools::displayError('invalid range');
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" class="width2">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/t/AdminRangePrice.gif" />'.$this->l('Price ranges').'</legend>
|
||||
<label>'.$this->l('Carrier:').'</label>
|
||||
<div class="margin-form">
|
||||
<select name="id_carrier">';
|
||||
$carriers = Carrier::getCarriers(intval(Configuration::get('PS_LANG_DEFAULT')));
|
||||
$id_carrier = Tools::getValue('id_carrier', $obj->id_carrier);
|
||||
foreach ($carriers AS $carrier)
|
||||
echo '<option value="'.intval($carrier['id_carrier']).'"'.(($carrier['id_carrier'] == $id_carrier) ? ' selected="selected"' : '').'>'.$carrier['name'].'</option><sup>*</sup>';
|
||||
echo '
|
||||
</select>
|
||||
<p class="clear">'.$this->l('Carrier to which this range will be applied').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('From:').' </label>
|
||||
<div class="margin-form">
|
||||
'.$currency->getSign('left').'<input type="text" size="4" name="delimiter1" value="'.htmlentities($this->getFieldValue($obj, 'delimiter1'), ENT_COMPAT, 'UTF-8').'" />'.$currency->getSign('right').'<sup>*</sup>
|
||||
<p class="clear">'.$this->l('Range start (included)').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('To:').' </label>
|
||||
<div class="margin-form">
|
||||
'.$currency->getSign('left').'<input type="text" size="4" name="delimiter2" value="'.htmlentities($this->getFieldValue($obj, 'delimiter2'), ENT_COMPAT, 'UTF-8').'" />'.$currency->getSign('right').'<sup>*</sup>
|
||||
<p class="clear">'.$this->l('Range end (excluded)').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Weight ranges tab for admin panel, AdminRangeWeight.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminRangeWeight extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'range_weight';
|
||||
$this->className = 'RangeWeight';
|
||||
$this->lang = false;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_range_weight' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'carrier_name' => array('title' => $this->l('Carrier'), 'align' => 'center', 'width' => 25, 'filter_key' => 'ca!name'),
|
||||
'delimiter1' => array('title' => $this->l('From'), 'width' => 86, 'float' => true, 'suffix' => Configuration::get('PS_WEIGHT_UNIT'), 'align' => 'right'),
|
||||
'delimiter2' => array('title' => $this->l('To'), 'width' => 86, 'float' => true,'suffix' => Configuration::get('PS_WEIGHT_UNIT'), 'align' => 'right'));
|
||||
|
||||
$this->_join = 'LEFT JOIN '._DB_PREFIX_.'carrier ca ON (ca.`id_carrier` = a.`id_carrier`)';
|
||||
$this->_select = 'ca.`name` AS carrier_name';
|
||||
$this->_where = 'AND ca.`deleted` = 0';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function displayListContent($token = NULL)
|
||||
{
|
||||
foreach ($this->_list as $key => $list)
|
||||
if ($list['carrier_name'] == '0')
|
||||
$this->_list[$key]['carrier_name'] = Configuration::get('PS_SHOP_NAME');
|
||||
parent::displayListContent($token);
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (isset($_POST['submitAdd'.$this->table]) AND Tools::getValue('delimiter1') >= Tools::getValue('delimiter2'))
|
||||
$this->_errors[] = Tools::displayError('invalid range');
|
||||
else
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" class="width2">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/t/AdminRangeWeight.gif" />'.$this->l('Weight ranges').'</legend>
|
||||
<label>'.$this->l('Carrier:').'</label>
|
||||
<div class="margin-form">
|
||||
<select name="id_carrier">';
|
||||
$carriers = Carrier::getCarriers(intval(Configuration::get('PS_LANG_DEFAULT')));
|
||||
$id_carrier = Tools::getValue('id_carrier', $obj->id_carrier);
|
||||
foreach ($carriers AS $carrier)
|
||||
echo '<option value="'.intval($carrier['id_carrier']).'"'.(($carrier['id_carrier'] == $id_carrier) ? ' selected="selected"' : '').'>'.$carrier['name'].'</option><sup>*</sup>';
|
||||
echo '
|
||||
</select>
|
||||
<p class="clear">'.$this->l('Carrier to which this range will be applied').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('From:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="4" name="delimiter1" value="'.htmlentities($this->getFieldValue($obj, 'delimiter1'), ENT_COMPAT, 'UTF-8').'" /> '.Configuration::get('PS_WEIGHT_UNIT').' <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Range start (included)').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('To:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="4" name="delimiter2" value="'.htmlentities($this->getFieldValue($obj, 'delimiter2'), ENT_COMPAT, 'UTF-8').'" /> '.Configuration::get('PS_WEIGHT_UNIT').' <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Range end (excluded)').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,457 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Referrer tab for admin panel, AdminReferrers.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @copyright PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.3
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('PS_ADMIN_DIR')) define('PS_ADMIN_DIR', getcwd().'/..');
|
||||
include_once(PS_ADMIN_DIR.'/../config/config.inc.php');
|
||||
include_once(PS_ADMIN_DIR.'/init.php');
|
||||
|
||||
if (Tools::getValue('token') == Tools::getAdminToken('AdminReferrers'.intval(Tab::getIdFromClassName('AdminReferrers')).intval(Tools::getValue('id_employee'))))
|
||||
{
|
||||
if (Tools::isSubmit('ajaxProductFilter'))
|
||||
Referrer::getAjaxProduct(intval(Tools::getValue('id_referrer')), intval(Tools::getValue('id_product')), new Employee(intval(Tools::getValue('id_employee'))));
|
||||
else if (Tools::isSubmit('ajaxFillProducts'))
|
||||
{
|
||||
$jsonArray = array();
|
||||
$result = Db::getInstance()->ExecuteS('
|
||||
SELECT p.id_product, pl.name
|
||||
FROM '._DB_PREFIX_.'product p
|
||||
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = '.intval(Tools::getValue('id_lang')).')
|
||||
'.(Tools::getValue('filter') != 'undefined' ? 'WHERE name LIKE "%'.pSQL(Tools::getValue('filter')).'%"' : ''));
|
||||
foreach ($result as $row)
|
||||
$jsonArray[] = '{id_product:'.intval($row['id_product']).',name:\''.addslashes($row['name']).'\'}';
|
||||
die ('['.implode(',', $jsonArray).']');
|
||||
}
|
||||
}
|
||||
|
||||
include_once(dirname(__FILE__).'/AdminStats.php');
|
||||
|
||||
class AdminReferrers extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'referrer';
|
||||
$this->className = 'Referrer';
|
||||
$this->view = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->_select = 'IF(cache_orders > 0, ROUND(cache_sales/cache_orders, 2), 0) as cart, (cache_visits*click_fee) as fee0, (cache_orders*base_fee) as fee1, (cache_sales*percent_fee/100) as fee2';
|
||||
$this->fieldsDisplay = array(
|
||||
'id_referrer' => array('title' => $this->l('ID'), 'width' => 25, 'align' => 'center'),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 80),
|
||||
'cache_visitors' => array('title' => $this->l('Visitors'), 'width' => 30, 'align' => 'center'),
|
||||
'cache_visits' => array('title' => $this->l('Visits'), 'width' => 30, 'align' => 'center'),
|
||||
'cache_pages' => array('title' => $this->l('Pages'), 'width' => 30, 'align' => 'center'),
|
||||
'cache_registrations' => array('title' => $this->l('Reg.'), 'width' => 30, 'align' => 'center'),
|
||||
'cache_orders' => array('title' => $this->l('Ord.'), 'width' => 30, 'align' => 'center'),
|
||||
'cache_sales' => array('title' => $this->l('Sales'), 'width' => 80, 'align' => 'right', 'prefix' => '<b>', 'suffix' => '</b>', 'price' => true),
|
||||
'cart' => array('title' => $this->l('Avg. cart'), 'width' => 50, 'align' => 'right', 'price' => true),
|
||||
'cache_reg_rate' => array('title' => $this->l('Reg. rate'), 'width' => 30, 'align' => 'center'),
|
||||
'cache_order_rate' => array('title' => $this->l('Order rate'), 'width' => 30, 'align' => 'center'),
|
||||
'fee0' => array('title' => $this->l('Click'), 'width' => 30, 'align' => 'right', 'price' => true),
|
||||
'fee1' => array('title' => $this->l('Base'), 'width' => 30, 'align' => 'right', 'price' => true),
|
||||
'fee2' => array('title' => $this->l('Percent'), 'width' => 30, 'align' => 'right', 'price' => true));
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
private function enableCalendar()
|
||||
{
|
||||
return (!Tools::isSubmit('add'.$this->table) AND !Tools::isSubmit('submitAdd'.$this->table) AND !Tools::isSubmit('update'.$this->table));
|
||||
}
|
||||
|
||||
public function displayJavascript()
|
||||
{
|
||||
global $cookie, $currentIndex;
|
||||
|
||||
$products = Product::getSimpleProducts(intval($cookie->id_lang));
|
||||
$productsArray = array();
|
||||
foreach ($products as $product)
|
||||
$productsArray[] = $product['id_product'];
|
||||
|
||||
return '
|
||||
<script type="text/javascript">
|
||||
var productIds = new Array(\''.implode('\',\'', $productsArray).'\');
|
||||
var referrerStatus = new Array();
|
||||
|
||||
function newProductLine(id_referrer, result)
|
||||
{
|
||||
return \'\'+
|
||||
\'<tr id="trprid_\'+id_referrer+\'_\'+result.id_product+\'" style="background-color: rgb(255, 255, 187);">\'+
|
||||
\' <td align="center">--</td>\'+
|
||||
\' <td align="center">\'+result.id_product+\'</td>\'+
|
||||
\' <td>\'+result.product_name+\'</td>\'+
|
||||
\' <td align="center">\'+result.uniqs+\'</td>\'+
|
||||
\' <td align="center">\'+result.visits+\'</td>\'+
|
||||
\' <td align="center">\'+result.pages+\'</td>\'+
|
||||
\' <td align="center">\'+result.registrations+\'</td>\'+
|
||||
\' <td align="center">\'+result.orders+\'</td>\'+
|
||||
\' <td align="right">\'+result.sales+\'</td>\'+
|
||||
\' <td align="right">\'+result.cart+\'</td>\'+
|
||||
\' <td align="center">\'+result.reg_rate+\'</td>\'+
|
||||
\' <td align="center">\'+result.order_rate+\'</td>\'+
|
||||
\' <td align="center">\'+result.click_fee+\'</td>\'+
|
||||
\' <td align="center">\'+result.base_fee+\'</td>\'+
|
||||
\' <td align="center">\'+result.percent_fee+\'</td>\'+
|
||||
\' <td align="center">--</td>\'+
|
||||
\'</tr>\';
|
||||
}
|
||||
|
||||
function showProductLines(id_referrer)
|
||||
{
|
||||
if (!referrerStatus[id_referrer])
|
||||
{
|
||||
referrerStatus[id_referrer] = true;
|
||||
for (var i = 0; i < productIds.length; ++i)
|
||||
$.getJSON("'.dirname($currentIndex).'/tabs/AdminReferrers.php",{ajaxProductFilter:1,id_employee:'.intval($cookie->id_employee).',token:"'.Tools::getValue('token').'",id_referrer:id_referrer,id_product:productIds[i]},
|
||||
function(result) {
|
||||
var newLine = newProductLine(id_referrer, result[0]);
|
||||
$(newLine).hide().insertAfter(getE(\'trid_\'+id_referrer)).fadeIn();
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
referrerStatus[id_referrer] = false;
|
||||
for (var i = 0; i < productIds.length; ++i)
|
||||
$("#trprid_"+id_referrer+"_"+productIds[i]).fadeOut("fast", function(){$("#trprid_"+i).remove();});
|
||||
}
|
||||
}
|
||||
</script>';
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if (!Tools::isSubmit('viewreferrer'))
|
||||
echo $this->displayJavascript();
|
||||
|
||||
if ($this->enableCalendar())
|
||||
{
|
||||
echo '
|
||||
<div style="float: left; margin-right: 20px;">
|
||||
'.AdminStatsTab::displayCalendarStatic(array('Calendar' => $this->l('Calendar'), 'Day' => $this->l('Today'), 'Month' => $this->l('Month'), 'Year' => $this->l('Year'))).'
|
||||
</div>';
|
||||
if (!Tools::isSubmit('viewreferrer'))
|
||||
echo '
|
||||
<div style="float: left; margin-right: 20px;">
|
||||
<fieldset class="width3"><legend><img src="../img/admin/tab-preferences.gif" /> '.$this->l('Settings').'</legend>
|
||||
<form action="'.$currentIndex.'&token='.Tools::getValue('token').'" method="post">
|
||||
<label>'.$this->l('Save direct traffic').'</label>
|
||||
<div class="float" style="margin-left: 200px;">
|
||||
<label class="t" for="tracking_dt_on"><img src="../img/admin/enabled.gif" alt="'.$this->l('Yes').'" title="'.$this->l('Yes').'" /></label>
|
||||
<input type="radio" name="tracking_dt" id="tracking_dt_on" value="1" '.(intval(Tools::getValue('tracking_dt', Configuration::get('TRACKING_DIRECT_TRAFFIC'))) ? 'checked="checked"' : '').' />
|
||||
<label class="t" for="tracking_dt_on"> '.$this->l('Yes').'</label>
|
||||
<label class="t" for="tracking_dt_off"><img src="../img/admin/disabled.gif" alt="'.$this->l('No').'" title="'.$this->l('No').'" style="margin-left: 10px;" /></label>
|
||||
<input type="radio" name="tracking_dt" id="tracking_dt_off" value="0" '.(!intval(Tools::getValue('tracking_dt', Configuration::get('TRACKING_DIRECT_TRAFFIC'))) ? 'checked="checked"' : '').'/>
|
||||
<label class="t" for="tracking_dt_off"> '.$this->l('No').'</label>
|
||||
</div>
|
||||
<br class="clear" />
|
||||
<p>'.$this->l('Direct traffic can be quite consuming, you should consider to enable it only if you have a strong database server and the need for it.').'</p>
|
||||
<input type="submit" class="button" value="'.$this->l(' Save ').'" name="submitSettings" />
|
||||
</form>
|
||||
<hr />
|
||||
<form action="'.$currentIndex.'&token='.Tools::getValue('token').'" method="post">
|
||||
<p class="bold">'.$this->l('Indexation').'</p>
|
||||
<p>'.$this->l('There is a huge quantity of data, so each connection corresponding to a referrer is indexed. You can refresh this index by clicking on the button below. Be aware that it may take a long time and it is only needed if you modified or added a referrer and if you want your changes to be retroactive.').'</p>
|
||||
<input type="submit" class="button" value="'.$this->l('Refresh index').'" name="submitRefreshIndex" />
|
||||
</form>
|
||||
<hr />
|
||||
<form action="'.$currentIndex.'&token='.Tools::getValue('token').'" method="post">
|
||||
<p class="bold">'.$this->l('Cache').'</p>
|
||||
<p>'.$this->l('For you to sort and filter your data, it is cached. You can refresh the cache by clicking on the button below.').'</p>
|
||||
<input type="submit" class="button" value="'.$this->l('Refresh cache').'" name="submitRefreshCache" />
|
||||
</form>
|
||||
</fieldset>
|
||||
</div>';
|
||||
}
|
||||
echo '<div class="clear space"> </div>';
|
||||
parent::display();
|
||||
echo '<div class="clear space"> </div>';
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if ($this->enableCalendar())
|
||||
{
|
||||
$calendarTab = new AdminStats();
|
||||
$calendarTab->postProcess();
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitSettings'))
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
if (Configuration::updateValue('TRACKING_DIRECT_TRAFFIC', intval(Tools::getValue('tracking_dt'))))
|
||||
Tools::redirectAdmin($currentIndex.'&conf=4&token='.Tools::getValue('token'));
|
||||
|
||||
if (ModuleGraph::getDateBetween() != Configuration::get('PS_REFERRERS_CACHE_LIKE') OR Tools::isSubmit('submitRefreshCache'))
|
||||
Referrer::refreshCache();
|
||||
if (Tools::isSubmit('submitRefreshIndex'))
|
||||
Referrer::refreshIndex();
|
||||
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
foreach (array('http_referer_like', 'http_referer_regexp', 'request_uri_like', 'request_uri_regexp') as $field)
|
||||
$obj->{$field} = str_replace('\\', '\\\\', $obj->{$field});
|
||||
$uri = Tools::getHttpHost(true, true).__PS_BASE_URI__;
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" class="width2">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset class="width4"><legend><img src="../img/admin/affiliation.png" /> '.$this->l('Affiliate').'</legend>
|
||||
<label>'.$this->l('Name').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="20" name="name" value="'.htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
</div>
|
||||
<label>'.$this->l('Password').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="password" name="passwd" value="" />
|
||||
<p>'.$this->l('Leave blank if no change').'</p>
|
||||
</div>
|
||||
<p>
|
||||
'.$this->l('Affiliates can access to their own data with these name and password.').'<br />
|
||||
'.$this->l('Front access:').' <a href="'.$uri.'modules/trackingfront/stats.php" style="font-style: italic;">'.$uri.'modules/trackingfront/stats.php</a>
|
||||
</p>
|
||||
</fieldset>
|
||||
<br class="clear" />
|
||||
<fieldset class="width4"><legend><img src="../img/admin/money.png" /> '.$this->l('Commission plan').'</legend>
|
||||
<label>'.$this->l('Click fee').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="8" name="click_fee" value="'.number_format(floatval($this->getFieldValue($obj, 'click_fee')), 2).'" />
|
||||
<p>'.$this->l('Fee given for each visit.').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Base fee').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="8" name="base_fee" value="'.number_format(floatval($this->getFieldValue($obj, 'base_fee')), 2).'" />
|
||||
<p>'.$this->l('Fee given for each order placed.').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Percent fee').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="8" name="percent_fee" value="'.number_format(floatval($this->getFieldValue($obj, 'percent_fee')), 2).'" />
|
||||
<p>'.$this->l('Percent of the sales.').'</p>
|
||||
</div>
|
||||
</fieldset>
|
||||
<br class="clear" />
|
||||
<fieldset class="width4"><legend onclick="openCloseLayer(\'tracking_help\')" style="cursor: pointer;"><img src="../img/admin/help.png" /> '.$this->l('Help').'</legend>
|
||||
<div id="tracking_help" style="display: none;">
|
||||
<p>'.$this->l('Definitions:').'</p>
|
||||
<ul style="list-style: disc; margin-left: 20px;">
|
||||
<li>
|
||||
'.$this->l('The field `http_referer` is the website from which your customers come.').'<br />
|
||||
'.$this->l('For example, visitors coming from Google will have a `http_referer` like this one: "http://www.google.com/search?q=prestashop".').'<br />
|
||||
'.$this->l('If the visitor come directly (by typing the URL of your shop or by using its bookmarks for example), `http_referer` will be empty.').'<br />
|
||||
'.$this->l('So if you want all the visitors coming from google, you can type "%google%" in this field, or "%google.fr%" if you want the visitors coming from Google France only.').'<br />
|
||||
</li>
|
||||
<br />
|
||||
<li>
|
||||
'.$this->l('The field `request_uri` is the URL by which the customer come to your website.').'<br />
|
||||
'.$this->l('For example, if the visitor access to a product page, this URL will be').' "'.$uri.'music-ipods/1-ipod-nano.html".<br />
|
||||
'.$this->l('This is interesting because you can add some tags or token in the links pointing to your website. For exemple, you can post a link').' "'.$uri.'index.php?prestashop" '.$this->l('in the forum and get statistics by entering "%prestashop" in the field `request_uri`. You will get all the visitors coming from the forum.').'
|
||||
'.$this->l('This method is more reliable than the `http_referer` one, but there is a danger: if a search engine read a page with your link, then it will be displayed in its results and you will have not only the forum visitors, but also the ones from the search engine.').'
|
||||
</li>
|
||||
<br />
|
||||
<li>
|
||||
'.$this->l('The fields `include` indicate what has to be included in the URL.').'
|
||||
</li>
|
||||
<br />
|
||||
<li>
|
||||
'.$this->l('The fields `exclude` indicate what has to be excluded from the URL.').'
|
||||
</li>
|
||||
<br />
|
||||
<li>
|
||||
'.$this->l('When using the simple mode, you can use some generic characters which can replace any characters:').'
|
||||
<ul>
|
||||
<li>'.$this->l('"_" will replace one character. If you want to use the real "_", you should type').' "\\\\_".</li>
|
||||
<li>'.$this->l('"%" will replace any number of characters. If you want to use the real "%", you should type').' "\\\\%".</li>
|
||||
</ul>
|
||||
</li>
|
||||
<br />
|
||||
<li>
|
||||
'.$this->l('The simple mode uses the MySQL "LIKE", but for a higher potency you can use MySQL regular expressions.').'
|
||||
<a href="http://dev.mysql.com/doc/refman/5.0/en/regexp.html" target="_blank" style="font-style: italic;">'.$this->l('Take a look to the documentation for more details...').'</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</fieldset>
|
||||
<br class="clear" />
|
||||
<fieldset class="width4"><legend><img src="../img/admin/affiliation.png" /> '.$this->l('Technical information - Simple mode').'</legend>
|
||||
<a style="cursor: pointer; font-style: italic;" onclick="openCloseLayer(\'tracking_help\');"><img src="../img/admin/help.png" /> '.$this->l('Get help!').'</a><br />
|
||||
<br class="clear" />
|
||||
<h3>'.$this->l('HTTP referrer').'</h3>
|
||||
<label>'.$this->l('Include').'</label>
|
||||
<div class="margin-form">
|
||||
<textarea cols="40" rows="1" name="http_referer_like">'.str_replace('\\', '\\\\', htmlentities($this->getFieldValue($obj, 'http_referer_like'), ENT_COMPAT, 'UTF-8')).'</textarea>
|
||||
</div>
|
||||
<label>'.$this->l('Exclude').'</label>
|
||||
<div class="margin-form">
|
||||
<textarea cols="40" rows="1" name="http_referer_like_not">'.str_replace('\\', '\\\\', htmlentities($this->getFieldValue($obj, 'http_referer_like_not'), ENT_COMPAT, 'UTF-8')).'</textarea>
|
||||
</div>
|
||||
<h3>'.$this->l('Request Uri').'</h3>
|
||||
<label>'.$this->l('Include').'</label>
|
||||
<div class="margin-form">
|
||||
<textarea cols="40" rows="1" name="request_uri_like">'.str_replace('\\', '\\\\', htmlentities($this->getFieldValue($obj, 'request_uri_like'), ENT_COMPAT, 'UTF-8')).'</textarea>
|
||||
</div>
|
||||
<label>'.$this->l('Exclude').'</label>
|
||||
<div class="margin-form">
|
||||
<textarea cols="40" rows="1" name="request_uri_like_not">'.str_replace('\\', '\\\\', htmlentities($this->getFieldValue($obj, 'request_uri_like_not'), ENT_COMPAT, 'UTF-8')).'</textarea>
|
||||
</div>
|
||||
<br class="clear" />
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<br class="clear" />
|
||||
'.$this->l('If you know how to use MySQL regular expressions, you can use the').' <a style="cursor: pointer; font-weight: bold;" onclick="openCloseLayer(\'tracking_expert\');">'.$this->l('expert mode').'.</a>
|
||||
</fieldset>
|
||||
<br class="clear" />
|
||||
<fieldset class="width4"><legend onclick="openCloseLayer(\'tracking_expert\')" style="cursor: pointer;"><img src="../img/admin/affiliation.png" /> '.$this->l('Technical information - Expert mode').'</legend>
|
||||
<div id="tracking_expert" style="display: none;">
|
||||
<h3>'.$this->l('HTTP referrer').'</h3>
|
||||
<label>'.$this->l('Include').'</label>
|
||||
<div class="margin-form">
|
||||
<textarea cols="40" rows="1" name="http_referer_regexp">'.str_replace('\\', '\\\\', htmlentities($this->getFieldValue($obj, 'http_referer_regexp'), ENT_COMPAT, 'UTF-8')).'</textarea>
|
||||
</div>
|
||||
<label>'.$this->l('Exclude').'</label>
|
||||
<div class="margin-form">
|
||||
<textarea cols="40" rows="1" name="http_referer_regexp_not">'.str_replace('\\', '\\\\', htmlentities($this->getFieldValue($obj, 'http_referer_regexp_not'), ENT_COMPAT, 'UTF-8')).'</textarea>
|
||||
</div>
|
||||
<h3>'.$this->l('Request Uri').'</h3>
|
||||
<label>'.$this->l('Include').'</label>
|
||||
<div class="margin-form">
|
||||
<textarea cols="40" rows="1" name="request_uri_regexp">'.str_replace('\\', '\\\\', htmlentities($this->getFieldValue($obj, 'request_uri_regexp'), ENT_COMPAT, 'UTF-8')).'</textarea>
|
||||
</div>
|
||||
<label>'.$this->l('Exclude').'</label>
|
||||
<div class="margin-form">
|
||||
<textarea cols="40" rows="1" name="request_uri_regexp_not">'.str_replace('\\', '\\\\', htmlentities($this->getFieldValue($obj, 'request_uri_regexp_not'), ENT_COMPAT, 'UTF-8')).'</textarea>
|
||||
</div>
|
||||
<br class="clear" />
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
public function viewreferrer()
|
||||
{
|
||||
global $cookie, $currentIndex;
|
||||
$referrer = new Referrer(intval(Tools::getValue('id_referrer')));
|
||||
|
||||
$displayTab = array(
|
||||
'uniqs' => $this->l('Unique visitors'),
|
||||
'visitors' => $this->l('Visitors'),
|
||||
'visits' => $this->l('Visits'),
|
||||
'pages' => $this->l('Pages viewed'),
|
||||
'registrations' => $this->l('Registrations'),
|
||||
'orders' => $this->l('Orders'),
|
||||
'sales' => $this->l('Sales'),
|
||||
'reg_rate' => $this->l('Registration rate'),
|
||||
'order_rate' => $this->l('Order rate'),
|
||||
'click_fee' => $this->l('Click fee'),
|
||||
'base_fee' => $this->l('Base fee'),
|
||||
'percent_fee' => $this->l('Percent fee'));
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
function updateConversionRate(id_product)
|
||||
{
|
||||
$.getJSON("'.dirname($currentIndex).'/tabs/AdminReferrers.php",{ajaxProductFilter:1,id_employee:'.intval($cookie->id_employee).',token:"'.Tools::getValue('token').'",id_referrer:'.$referrer->id.',id_product:id_product},
|
||||
function(j) {';
|
||||
foreach ($displayTab as $key => $value)
|
||||
echo '$("#'.$key.'").html(j[0].'.$key.');';
|
||||
echo ' }
|
||||
)
|
||||
}
|
||||
|
||||
function fillProducts(filter)
|
||||
{
|
||||
var form = document.layers ? document.forms.product : document.product;
|
||||
var filter = form.filterProduct.value;
|
||||
$.getJSON("'.dirname($currentIndex).'/tabs/AdminReferrers.php",
|
||||
{ajaxFillProducts:1,id_employee:'.intval($cookie->id_employee).',token:"'.Tools::getValue('token').'",id_lang:'.intval($cookie->id_lang).',filter:filter},
|
||||
function(j) {
|
||||
|
||||
form.selectProduct.length = j.length + 1;
|
||||
for (var i = 0; i < j.length; i++)
|
||||
{
|
||||
form.selectProduct.options[i+1].value = j[i].id_product;
|
||||
form.selectProduct.options[i+1].text = j[i].name;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
</script>
|
||||
<fieldset class="width3" style="float: left"><legend><img src="../img/admin/tab-stats.gif" /> Statistics</legend>
|
||||
<h2>'.$referrer->name.'</h2>
|
||||
<table>';
|
||||
foreach ($displayTab as $data => $label)
|
||||
echo '<tr><td>'.$label.'</td><td style="color:green;font-weight:bold;padding-left:20px;" id="'.$data.'"></td></tr>';
|
||||
echo '</table>
|
||||
<br class="clear" />
|
||||
<form id="product" name="product">
|
||||
'.$this->l('Filter by product:').'
|
||||
<select id="selectProduct" name="selectProduct" style="width: 200px;" onfocus="fillProducts();" onchange="updateConversionRate(this.value);">
|
||||
<option value="0" selected="selected">-- '.$this->l('All').' --</option>
|
||||
</select> <input type="text" size="25" id="filterProduct" name="filterProduct" onkeyup="fillProducts();" class="space" />
|
||||
</form>
|
||||
</fieldset>
|
||||
<script type="text/javascript">
|
||||
updateConversionRate(0);
|
||||
</script>';
|
||||
}
|
||||
|
||||
public function displayListContent($token = NULL)
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
$irow = 0;
|
||||
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
if ($this->_list)
|
||||
foreach ($this->_list AS $tr)
|
||||
{
|
||||
$id = $tr[$this->identifier];
|
||||
echo '<tr id="trid_'.$id.'"'.($irow++ % 2 ? ' class="alt_row"' : '').'>
|
||||
<td class="center"><input type="checkbox" name="'.$this->table.'Box[]" value="'.$id.'" class="noborder" /></td>';
|
||||
foreach ($this->fieldsDisplay AS $key => $params)
|
||||
{
|
||||
echo '<td onclick="showProductLines('.$id.');" class="pointer '.(isset($params['align']) ? $params['align'] : '').'">'.(isset($params['prefix']) ? $params['prefix'] : '');
|
||||
if (isset($tr[$key]) AND isset($params['price']))
|
||||
echo Tools::displayPrice($tr[$key], $currency);
|
||||
elseif (isset($tr[$key]))
|
||||
echo $tr[$key];
|
||||
else
|
||||
echo '--';
|
||||
echo (isset($params['suffix']) ? $params['suffix'] : '').'</td>';
|
||||
}
|
||||
echo '
|
||||
<td class="center" style="width: 60px">
|
||||
<a href="'.$currentIndex.'&'.$this->identifier.'='.$id.'&view'.$this->table.'&token='.($token!=NULL ? $token : $this->token).'">
|
||||
<img src="../img/admin/details.gif" border="0" alt="'.$this->l('View').'" title="'.$this->l('View').'" /></a>
|
||||
<a href="'.$currentIndex.'&'.$this->identifier.'='.$id.'&update'.$this->table.'&token='.($token!=NULL ? $token : $this->token).'">
|
||||
<img src="../img/admin/edit.gif" border="0" alt="'.$this->l('Edit').'" title="'.$this->l('Edit').'" /></a>
|
||||
<a href="'.$currentIndex.'&'.$this->identifier.'='.$id.'&delete'.$this->table.'&token='.($token!=NULL ? $token : $this->token).'" onclick="return confirm(\''.addslashes($this->l('Delete item ?')).'\');">
|
||||
<img src="../img/admin/delete.gif" border="0" alt="'.$this->l('Delete').'" title="'.$this->l('Delete').'" /></a>
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,275 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Order statues tab for admin panel, AdminOrdersStates.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminReturn extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$this->table = 'order_return';
|
||||
$this->className = 'OrderReturn';
|
||||
$this->colorOnBackground = true;
|
||||
$this->_select = 'orsl.`name`';
|
||||
$this->_join = 'LEFT JOIN '._DB_PREFIX_.'order_return_state_lang orsl ON (orsl.`id_order_return_state` = a.`state` AND orsl.`id_lang` = '.intval($cookie->id_lang).')';
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_order_return' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'id_order' => array('title' => $this->l('Order ID'), 'width' => 75, 'align' => 'center'),
|
||||
'name' => array('title' => $this->l('Status'), 'width' => 150, 'align' => 'center'),
|
||||
'date_add' => array('title' => $this->l('Date issued'), 'width' => 60, 'type' => 'date'));
|
||||
|
||||
$this->optionTitle = $this->l('Merchandise return (RMA) options');
|
||||
$this->_fieldsOptions = array(
|
||||
'PS_ORDER_RETURN' => array('title' => $this->l('Enable returns:'), 'desc' => $this->l('Select whether or not to activate merchandise return for your shop'), 'cast' => 'intval', 'type' => 'bool'),
|
||||
'PS_ORDER_RETURN_NB_DAYS' => array('title' => $this->l('Time limit of validity:'), 'desc' => $this->l('Number of days the customer can make a return after the purchase date'), 'cast' => 'intval', 'type' => 'text', 'size' => '2'),
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
|
||||
if (Tools::isSubmit('deleteorder_return_detail'))
|
||||
{
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
if (($id_order_detail = intval(Tools::getValue('id_order_detail'))) AND Validate::isUnsignedId($id_order_detail))
|
||||
{
|
||||
if (($id_order_return = intval(Tools::getValue('id_order_return'))) AND Validate::isUnsignedId($id_order_return))
|
||||
{
|
||||
$orderReturn = new OrderReturn($id_order_return);
|
||||
if (!Validate::isLoadedObject($orderReturn))
|
||||
die(Tools::displayError());
|
||||
if (intval($orderReturn->countProduct()) > 1)
|
||||
{
|
||||
if (OrderReturn::deleteOrderReturnDetail($id_order_return, $id_order_detail, intval(Tools::getValue('id_customization', 0))))
|
||||
Tools::redirectAdmin($currentIndex.'&conf=4token='.$this->token);
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('an error occured while deleting an order return detail');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('you need at least one product');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('the order return is invalid');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('the order return detail is invalid');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
elseif (Tools::isSubmit('submitAddorder_return'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (($id_order_return = intval(Tools::getValue('id_order_return'))) AND Validate::isUnsignedId($id_order_return))
|
||||
{
|
||||
$orderReturn = new OrderReturn($id_order_return);
|
||||
$customer = new Customer($orderReturn->id_customer);
|
||||
$orderReturn->state = intval(Tools::getValue('state'));
|
||||
if ($orderReturn->save())
|
||||
{
|
||||
$orderReturnState = new OrderReturnState($orderReturn->state);
|
||||
$vars = array(
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{id_order_return}' => $id_order_return,
|
||||
'{state_order_return}' => $orderReturnState->name[intval(Configuration::get('PS_LANG_DEFAULT'))]);
|
||||
Mail::Send(intval($cookie->id_lang), 'order_return_state', html_entity_decode($this->l('Your order return state has changed'), ENT_NOQUOTES, 'UTF-8'), $vars, $customer->email, $customer->firstname.' '.$customer->lastname);
|
||||
Tools::redirectAdmin($currentIndex.'&conf=4&token='.$this->token);
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('no order return ID.');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
|
||||
// Include current tab
|
||||
if (isset($_GET['update'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
$this->displayForm();
|
||||
echo '<br /><br /><a href="'.$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to list').'</a><br />';
|
||||
}
|
||||
else
|
||||
echo $this->l('You do not have permission to edit here');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->getList(intval($cookie->id_lang), !Tools::getValue($this->table.'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL);
|
||||
$this->displayList();
|
||||
$this->displayOptionsList();
|
||||
$this->includeSubTab('display');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function displayListContent($token = NULL)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
$irow = 0;
|
||||
if ($this->_list)
|
||||
foreach ($this->_list AS $tr)
|
||||
{
|
||||
$tr['id_order'] = $this->l('#').sprintf('%06d', $tr['id_order']);
|
||||
$id = $tr['id_'.$this->table];
|
||||
echo '<tr'.($irow++ % 2 ? ' class="alt_row"' : '').' '.((isset($state->color) AND $this->colorOnBackground) ? 'style="background-color: '.$state->color.'"' : '').'>';
|
||||
foreach ($this->fieldsDisplay AS $key => $params)
|
||||
echo '<td class="pointer" onclick="document.location = \''.$currentIndex.'&id_'.$this->table.'='.$id.'&update'.$this->table.'&token='.($token!=NULL ? $token : $this->token).'\'"'.'>'.$tr[$key].'</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<input type="hidden" name="id_order" value="'.$obj->id_order.'" />
|
||||
<input type="hidden" name="id_customer" value="'.$obj->id_customer.'" />
|
||||
<fieldset class="width3"><legend><img src="../img/admin/return.gif" />'.$this->l('Return Merchandise Authorization (RMA)').'</legend>
|
||||
<label>'.$this->l('Customer:').' </label>';
|
||||
$customer = new Customer(intval($obj->id_customer));
|
||||
echo '
|
||||
<div class="margin-form">'.$customer->firstname.' '.$customer->lastname.'
|
||||
<p style="clear: both"><a href="index.php?tab=AdminCustomers&id_customer='.$customer->id.'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.intval(Tab::getIdFromClassName('AdminCustomers')).intval($cookie->id_employee)).'">'.$this->l('View details on customer page').'</a></p>
|
||||
</div>
|
||||
<label>'.$this->l('Order:').' </label>';
|
||||
$order = new Order(intval($obj->id_order));
|
||||
echo ' <div class="margin-form">'.$this->l('Order #').sprintf('%06d', $order->id).' '.$this->l('from').' '.Tools::displayDate($order->date_upd, $order->id_lang).'
|
||||
<p style="clear: both"><a href="index.php?tab=AdminOrders&id_order='.$order->id.'&vieworder&token='.Tools::getAdminToken('AdminOrders'.intval(Tab::getIdFromClassName('AdminOrders')).intval($cookie->id_employee)).'">'.$this->l('View details on order page').'</a></p>
|
||||
</div>
|
||||
<label>'.$this->l('Customer explanation:').' </label>
|
||||
<div class="margin-form">'.$obj->question.'</div>
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" style="float:right; margin-right:120px;"/>
|
||||
<label>'.$this->l('Status:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name=\'state\'>';
|
||||
$states = OrderReturnState::getOrderReturnStates($cookie->id_lang);
|
||||
foreach ($states as $state)
|
||||
echo '<option value="'.$state['id_order_return_state'].'"'.($obj->state == $state['id_order_return_state'] ? ' selected="selected"' : '').'>'.$state['name'].'</option>';
|
||||
echo ' </select>
|
||||
<p style="clear: both">'.$this->l('Merchandise return (RMA) status').'</p>
|
||||
</div>';
|
||||
if ($obj->state >= 3)
|
||||
echo ' <label>'.$this->l('Slip:').' </label>
|
||||
<div class="margin-form">'.$this->l('Generate a new slip from the customer order').'
|
||||
<p style="clear: both"><a href="index.php?tab=AdminOrders&id_order='.$order->id.'&vieworder&token='.Tools::getAdminToken('AdminOrders'.intval(Tab::getIdFromClassName('AdminOrders')).intval($cookie->id_employee)).'#products">'.$this->l('More information on order page').'</a></p>
|
||||
</div>';
|
||||
echo ' <label>'.$this->l('Products:').' </label>
|
||||
<div class="margin-form">';
|
||||
echo '<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td class="col-left"> </td>
|
||||
<td>
|
||||
<table cellspacing="0" cellpadding="0" class="table">
|
||||
<tr>
|
||||
<th style="width: 100px;">'.$this->l('Reference').'</th>
|
||||
<th>'.$this->l('Product name').'</th>
|
||||
<th>'.$this->l('Quantity').'</th>
|
||||
<th>'.$this->l('Action').'</th>
|
||||
</tr>';
|
||||
|
||||
$order = new Order(intval($obj->id_order));
|
||||
$quantityDisplayed = array();
|
||||
/* Customized products */
|
||||
if ($returnedCustomizations = OrderReturn::getReturnedCustomizedProducts(intval($obj->id_order)))
|
||||
{
|
||||
$allCustomizedDatas = Product::getAllCustomizedDatas(intval($order->id_cart));
|
||||
foreach ($returnedCustomizations AS $returnedCustomization)
|
||||
{
|
||||
echo '
|
||||
<tr>
|
||||
<td>'.$returnedCustomization['reference'].'</td>
|
||||
<td class="center">'.$returnedCustomization['name'].'</td>
|
||||
<td class="center">'.intval($returnedCustomization['product_quantity']).'</td>
|
||||
<td class="center"><a href="'.$currentIndex.'&deleteorder_return_detail&id_order_detail='.$returnedCustomization['id_order_detail'].'&id_customization='.$returnedCustomization['id_customization'].'&id_order_return='.$obj->id.'&token='.$this->token.'"><img src="../img/admin/delete.gif"></a></td>
|
||||
</tr>';
|
||||
$customizationDatas = &$allCustomizedDatas[intval($returnedCustomization['product_id'])][intval($returnedCustomization['product_attribute_id'])][intval($returnedCustomization['id_customization'])]['datas'];
|
||||
foreach ($customizationDatas AS $type => $datas)
|
||||
{
|
||||
echo '<tr>
|
||||
<td colspan="4">';
|
||||
if ($type == _CUSTOMIZE_FILE_)
|
||||
{
|
||||
$i = 0;
|
||||
echo '<ul style="margin: 4px 0px 4px 0px; padding: 0px; list-style-type: none;">';
|
||||
foreach ($datas AS $data)
|
||||
echo '<li style="display: inline; margin: 2px;">
|
||||
<a href="displayImage.php?img='.$data['value'].'&name='.intval($order->id).'-file'.++$i.'" target="_blank"><img src="'._THEME_PROD_PIC_DIR_.$data['value'].'_small" alt="" /></a>
|
||||
</li>';
|
||||
echo '</ul>';
|
||||
}
|
||||
elseif ($type == _CUSTOMIZE_TEXTFIELD_)
|
||||
{
|
||||
$i = 0;
|
||||
echo '<ul style="margin: 0px 0px 4px 0px; padding: 0px 0px 0px 6px; list-style-type: none;">';
|
||||
foreach ($datas AS $data)
|
||||
echo '<li>'.$this->l('Text #').++$i.$this->l(':').' '.$data['value'].'</li>';
|
||||
echo '</ul>';
|
||||
}
|
||||
echo '</td>
|
||||
</tr>';
|
||||
}
|
||||
$quantityDisplayed[intval($returnedCustomization['id_order_detail'])] = isset($quantityDisplayed[intval($returnedCustomization['id_order_detail'])]) ? $quantityDisplayed[intval($returnedCustomization['id_order_detail'])] + intval($returnedCustomization['product_quantity']) : intval($returnedCustomization['product_quantity']);
|
||||
}
|
||||
}
|
||||
|
||||
/* Classic products */
|
||||
$products = OrderReturn::getOrdersReturnProducts($obj->id, $order);
|
||||
foreach ($products AS $k => $product)
|
||||
if (!isset($quantityDisplayed[intval($product['id_order_detail'])]) OR intval($product['product_quantity']) > intval($quantityDisplayed[intval($product['id_order_detail'])]))
|
||||
echo '
|
||||
<tr>
|
||||
<td>'.$product['product_reference'].'</td>
|
||||
<td class="center">'.$product['product_name'].'</td>
|
||||
<td class="center">'.$product['product_quantity'].'</td>
|
||||
<td class="center"><a href="'.$currentIndex.'&deleteorder_return_detail&id_order_detail='.$product['id_order_detail'].'&id_order_return='.$obj->id.'&token='.$this->token.'"><img src="../img/admin/delete.gif"></a></td>
|
||||
</tr>';
|
||||
|
||||
echo '
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>'.$this->l('List of products in return package').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Order statues tab for admin panel, AdminOrdersStates.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminReturnStates extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'order_return_state';
|
||||
$this->className = 'OrderReturnState';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->noAdd = true;
|
||||
$this->delete = false;
|
||||
$this->colorOnBackground = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_order_return_state' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 130)
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" enctype="multipart/form-data">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset class="width3"><legend><img src="../img/admin/time.gif" />'.$this->l('Order statues').'</legend>
|
||||
<label>'.$this->l('Status name:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="name_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="40" type="text" name="name_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters: numbers and').' !<>,;?=+()@#"<22>{}_$%:<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name');
|
||||
echo ' <p style="clear: both">'.$this->l('Order return status name').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,264 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Scenes tab for admin panel, AdminScenes.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @copyright PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.3
|
||||
*
|
||||
*/
|
||||
|
||||
include_once(dirname(__FILE__).'/../../classes/AdminTab.php');
|
||||
|
||||
class AdminScenes extends AdminTab
|
||||
{
|
||||
protected $maxImageSize = 1000000;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'scene';
|
||||
$this->className = 'Scene';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldImageSettings = array(
|
||||
array('name' => 'image', 'dir' => 'scenes'),
|
||||
array('name' => 'thumb', 'dir' => 'scenes/thumbs')
|
||||
);
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_scene' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Image Maps'), 'width' => 150),
|
||||
'active' => array('title' => $this->l('Activated'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false)
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
public function delete()
|
||||
{
|
||||
removeZoneProducts();
|
||||
}
|
||||
|
||||
function afterImageUpload()
|
||||
{
|
||||
/* Generate image with differents size */
|
||||
$obj = $this->loadObject(true);
|
||||
if ($obj->id AND (isset($_FILES['image']) OR isset($_FILES['thumb'])))
|
||||
{
|
||||
$imagesTypes = ImageType::getImagesTypes('scenes');
|
||||
foreach ($imagesTypes AS $k => $imageType)
|
||||
{
|
||||
if ($imageType['name'] == 'large_scene' AND isset($_FILES['image']))
|
||||
imageResize($_FILES['image']['tmp_name'], _PS_SCENE_IMG_DIR_.$obj->id.'-'.stripslashes($imageType['name']).'.jpg', intval($imageType['width']), intval($imageType['height']));
|
||||
elseif ($imageType['name'] == 'thumb_scene')
|
||||
{
|
||||
if (isset($_FILES['thumb']) AND !$_FILES['thumb']['error'])
|
||||
$tmpName = $_FILES['thumb']['tmp_name'];
|
||||
else
|
||||
$tmpName = $_FILES['image']['tmp_name'];
|
||||
imageResize($tmpName, _PS_SCENE_THUMB_IMG_DIR_.$obj->id.'-'.stripslashes($imageType['name']).'.jpg', intval($imageType['width']), intval($imageType['height']));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Build a categories tree
|
||||
*
|
||||
* @param array $indexedCategories Array with categories where product is indexed (in order to check checkbox)
|
||||
* @param array $categories Categories to list
|
||||
* @param array $current Current category
|
||||
* @param integer $id_category Current category id
|
||||
*/
|
||||
function recurseCategoryForInclude($indexedCategories, $categories, $current, $id_category = 1, $id_category_default = NULL)
|
||||
{
|
||||
global $done;
|
||||
static $irow;
|
||||
$id_obj = intval(Tools::getValue($this->id));
|
||||
|
||||
if (!isset($done[$current['infos']['id_parent']]))
|
||||
$done[$current['infos']['id_parent']] = 0;
|
||||
$done[$current['infos']['id_parent']] += 1;
|
||||
|
||||
$todo = sizeof($categories[$current['infos']['id_parent']]);
|
||||
$doneC = $done[$current['infos']['id_parent']];
|
||||
|
||||
$level = $current['infos']['level_depth'] + 1;
|
||||
$img = $level == 1 ? 'lv1.gif' : 'lv'.$level.'_'.($todo == $doneC ? 'f' : 'b').'.gif';
|
||||
|
||||
echo '
|
||||
<tr class="'.($irow++ % 2 ? 'alt_row' : '').'">
|
||||
<td>
|
||||
'.($id_category == 1 ? ' ' : '<input type="checkbox" name="categoryBox[]" class="categoryBox'.($id_category_default != NULL ? ' id_category_default' : '').'" id="categoryBox_'.$id_category.'" value="'.$id_category.'"'.((in_array($id_category, $indexedCategories) OR (intval(Tools::getValue('id_category')) == $id_category AND !intval($id_obj))) ? ' checked="checked"' : '').' />').'
|
||||
</td>
|
||||
<td>
|
||||
'.$id_category.'
|
||||
</td>
|
||||
<td>
|
||||
<img src="../img/admin/'.$img.'" alt="" /> <label for="categoryBox_'.$id_category.'" class="t">'.stripslashes(Category::hideCategoryPosition($current['infos']['name'])).'</label>
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
if (isset($categories[$id_category]))
|
||||
foreach ($categories[$id_category] AS $key => $row)
|
||||
if ($key != 'infos')
|
||||
$this->recurseCategoryForInclude($indexedCategories, $categories, $categories[$id_category][$key], $key);
|
||||
}
|
||||
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
$langtags = 'name';
|
||||
$active = $this->getFieldValue($obj, 'active');
|
||||
|
||||
echo '
|
||||
<script type="text/javascript">';
|
||||
echo 'startingData = new Array();'."\n";
|
||||
foreach ($obj->getProducts() as $key => $product)
|
||||
{
|
||||
$productObj = new Product(intval($product['id_product']), true, intval($cookie->id_lang));
|
||||
echo 'startingData['.$key.'] = new Array(\''.$productObj->name.'\', '.$product['id_product'].', '.$product['x_axis'].', '.$product['y_axis'].', '.$product['zone_width'].', '.$product['zone_height'].');';
|
||||
}
|
||||
|
||||
echo
|
||||
'</script>
|
||||
<form id="scenesForm" action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" enctype="multipart/form-data">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/admin/photo.gif" />'.$this->l('Image Maps').'</legend>';
|
||||
|
||||
|
||||
echo '
|
||||
<label>'.$this->l('How to map products in the image:').' </label>
|
||||
<div class="margin-form">
|
||||
'.$this->l('When a customer hovers over the image with the mouse, a pop-up appears displaying a brief description of the product. The customer can then click to open the product\'s full product page. To achieve this, please define the \'mapping zone\' that, when hovered over, will display the pop-up. Left-click with your mouse to draw the four-sided mapping zone, then release. Then, begin typing the name of the associated product. A list of products appears. Click the appropriate product, then click OK. Repeat these steps for each mapping zone you wish to create. When you have finished mapping zones, click Save Image Map.').'
|
||||
</div>
|
||||
';
|
||||
|
||||
|
||||
echo '<label>'.$this->l('Image map name:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="name_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input type="text" style="width: 260px" name="name_'.$language['id_lang'].'" id="name_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $langtags, 'name');
|
||||
echo ' <div class="clear"></div>
|
||||
</div>';
|
||||
|
||||
|
||||
echo '<label>'.$this->l('Status:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="active" id="active_on" value="1" '.((!$obj->id OR Tools::getValue('active', $obj->active)) ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Activated').'" title="'.$this->l('Activated').'" /></label>
|
||||
<input type="radio" name="active" id="active_off" value="0" '.((!Tools::getValue('active', $obj->active) AND $obj->id) ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Deactivated').'" title="'.$this->l('Deactivated').'" /></label>
|
||||
<p>'.$this->l('Activate or deactivate the image map').'</p>
|
||||
</div>';
|
||||
|
||||
|
||||
$sceneImageTypes = ImageType::getImagesTypes('scenes');
|
||||
$largeSceneImageType = NULL;
|
||||
$thumbSceneImageType = NULL;
|
||||
foreach ($sceneImageTypes as $sceneImageType)
|
||||
{
|
||||
if ($sceneImageType['name'] == 'large_scene')
|
||||
$largeSceneImageType = $sceneImageType;
|
||||
if ($sceneImageType['name'] == 'thumb_scene')
|
||||
$thumbSceneImageType = $sceneImageType;
|
||||
}
|
||||
|
||||
|
||||
echo '<label>'.$this->l('Image to be mapped:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="hidden" id="stay_here" name="stay_here" value="" />
|
||||
<input type="file" name="image" id="image_input" /> <input type="button" value="'.$this->l('Upload image').'" onclick="{$(\'#stay_here\').val(\'true\');$(\'#scenesForm\').submit();}" class="button" /><br/>
|
||||
<p>'.$this->l('Format:').' JPG, GIF, PNG. '.$this->l('File size:').' '.($this->maxImageSize / 1000).''.$this->l('KB max.').' '.$this->l('If larger than the image size setting, the image will be reduced to ').' '.$largeSceneImageType['width'].'x'.$largeSceneImageType['height'].'px '.$this->l('(width x height). If smaller than the image-size setting, a white background will be added in order to achieve the correct image size.').'.<br />'.$this->l('Note: To change image dimensions, please change the \'large_scene\' image type settings to the desired size (in Back Office > Preferences > Images).').'</p>';
|
||||
|
||||
if ($obj->id && file_exists(_PS_SCENE_IMG_DIR_.$obj->id.'-large_scene.jpg'))
|
||||
{
|
||||
|
||||
echo '<img id="large_scene_image" style="clear:both;border:1px solid black;" alt="" src="'._THEME_SCENE_DIR_.$obj->id.'-large_scene.jpg" /><br />';
|
||||
|
||||
echo '
|
||||
<div id="ajax_choose_product" style="display:none; padding:6px; padding-top:2px; width:600px;">
|
||||
'.$this->l('Begin typing the first letters of the product name, then select the product from the drop-down list:').'<br /><input type="text" value="" id="product_autocomplete_input" /> <input type="button" class="button" value="'.$this->l('OK').'" onclick="$(this).prev().search();" /><input type="button" class="button" value="'.$this->l('Delete').'" onclick="undoEdit();" />
|
||||
</div>
|
||||
';
|
||||
|
||||
echo '
|
||||
<link rel="stylesheet" type="text/css" href="'.__PS_BASE_URI__.'css/jquery.autocomplete.css" />
|
||||
<link rel="stylesheet" type="text/css" href="'.__PS_BASE_URI__.'js/jquery/imgareaselect/imgareaselect-default.css" />
|
||||
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/jquery/jquery.autocomplete.js"></script>
|
||||
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/jquery/jquery.hotkeys-0.7.8-packed.js"></script>
|
||||
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/jquery/imgareaselect/jquery.imgareaselect.pack.js"></script>
|
||||
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/admin-scene-cropping.js"></script>
|
||||
';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
|
||||
echo '<label>'.$this->l('Alternative thumbnail:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="file" name="thumb" id="thumb_input" /> '.$this->l('(optional)').'
|
||||
<p>'.$this->l('If you want to use a thumbnail other than one generated from simply reducing the mapped image, please upload it here.').'<br />'.$this->l('Format:').' JPG, GIF, PNG. '.$this->l('Filesize:').' '.($this->maxImageSize / 1000).''.$this->l('Kb max.').' '.$this->l('Automatically resized to').' '.$thumbSceneImageType['width'].'x'.$thumbSceneImageType['height'].'px '.$this->l('(width x height)').'.<br />'.$this->l('Note: To change image dimensions, please change the \'thumb_scene\' image type settings to the desired size (in Back Office > Preferences > Images).').'</p>
|
||||
';
|
||||
if ($obj->id && file_exists(_PS_SCENE_IMG_DIR_.'thumbs/'.$obj->id.'-thumb_scene.jpg'))
|
||||
echo '<img id="large_scene_image" style="clear:both;border:1px solid black;" alt="" src="'._THEME_SCENE_DIR_.'thumbs/'.$obj->id.'-thumb_scene.jpg" /><br />';
|
||||
echo '</div>
|
||||
';
|
||||
|
||||
echo '<label>'.$this->l('Category:').' </label>
|
||||
<div class="margin-form">
|
||||
<div style="overflow: auto; min-height: 300px; padding-top: 0.6em;" id="categoryList">
|
||||
<table cellspacing="0" cellpadding="0" class="table" style="width: 29.5em;">
|
||||
<tr>
|
||||
<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'categoryBox[]\', this.checked)" /></th>
|
||||
<th>'.$this->l('ID').'</th>
|
||||
<th>'.$this->l('Image map name:').'</th>
|
||||
</tr>';
|
||||
$categories = Category::getCategories(intval($cookie->id_lang), false);
|
||||
$done = array();
|
||||
$index = array();
|
||||
$indexedCategories = isset($_POST['categoryBox']) ? $_POST['categoryBox'] : ($obj->id ? Scene::getIndexedCategories($obj->id) : array());
|
||||
foreach ($indexedCategories AS $k => $row)
|
||||
$index[] = $row['id_category'];
|
||||
$this->recurseCategoryForInclude($index, $categories, $categories[0][1], 1, null);
|
||||
echo '</table>
|
||||
<p style="padding:0px; margin:0px 0px 10px 0px;">'.$this->l('Mark all checkbox(es) of the categories for which the image map is to appear.').'<sup> *</sup></p>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo '
|
||||
<div id="save_scene" class="margin-form" '.(($obj->id && file_exists(_PS_SCENE_IMG_DIR_.$obj->id.'-large_scene.jpg')) ? '' : 'style="display:none;"') .'>
|
||||
<input type="submit" value="'.$this->l('Save Image Map(s)').'" class="button" />
|
||||
</div>';
|
||||
} else {
|
||||
echo '
|
||||
<br/><span class="bold">'.$this->l('Please add a picture to continue mapping the image...').'</span><br/><br/>';
|
||||
}
|
||||
echo '<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,334 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Search tab for admin panel, AdminSearch.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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, '<span class="highlight">'.$query.'</span>', $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 '<h2>'.$this->l('Search results').'</h2>';
|
||||
$this->_errors[] = Tools::displayError('please fill in search form first');
|
||||
}
|
||||
else
|
||||
{
|
||||
$_POST['bo_query'] = trim($_POST['bo_query']);
|
||||
|
||||
/* Product research */
|
||||
if (!intval($_POST['bo_search_type']) OR intval($_POST['bo_search_type']) == 1)
|
||||
{
|
||||
$this->fieldsDisplay['catalog'] = (array(
|
||||
'ID' => array('title' => $this->l('ID')),
|
||||
'manufacturer' => array('title' => $this->l('Manufacturer')),
|
||||
'reference' => array('title' => $this->l('Reference')),
|
||||
'name' => array('title' => $this->l('Name')),
|
||||
'price' => array('title' => $this->l('Price')),
|
||||
'tax' => array('title' => $this->l('Tax')),
|
||||
'stock' => array('title' => $this->l('Stock')),
|
||||
'weight' => array('title' => $this->l('Weight')),
|
||||
'status' => array('title' => $this->l('Status')),
|
||||
'action' => array('title' => $this->l('Actions'))
|
||||
));
|
||||
|
||||
/* Handle product ID */
|
||||
if (intval($_POST['bo_search_type']) AND intval($_POST['bo_query']) AND Validate::isUnsignedInt(intval($_POST['bo_query'])))
|
||||
{
|
||||
$product = new Product(intval($_POST['bo_query']));
|
||||
if (Validate::isLoadedObject($product))
|
||||
Tools::redirectAdmin('index.php?tab=AdminCatalog&id_product='.intval($_POST['bo_query']).'&addproduct'.'&token='.Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)));
|
||||
}
|
||||
$this->searchCatalog(trim(strval($_POST['bo_query'])));
|
||||
}
|
||||
|
||||
/* Customer */
|
||||
if (!intval($_POST['bo_search_type']) OR intval($_POST['bo_search_type']) == 2)
|
||||
{
|
||||
$this->fieldsDisplay['customers'] = (array(
|
||||
'ID' => array('title' => $this->l('ID')),
|
||||
'sex' => array('title' => $this->l('Sex')),
|
||||
'name' => array('title' => $this->l('Name')),
|
||||
'e-mail' => array('title' => $this->l('e-mail')),
|
||||
'birthdate' => array('title' => $this->l('Birth date')),
|
||||
'register_date' => array('title' => $this->l('Register date')),
|
||||
'orders' => array('title' => $this->l('Orders')),
|
||||
'status' => array('title' => $this->l('Status')),
|
||||
'actions' => array('title' => $this->l('Actions'))
|
||||
));
|
||||
|
||||
/* Handle customer ID */
|
||||
if (intval($_POST['bo_search_type']) AND intval($_POST['bo_query']) AND Validate::isUnsignedInt(intval($_POST['bo_query'])))
|
||||
{
|
||||
$customer = new Customer(intval($_POST['bo_query']));
|
||||
if ($customer->id)
|
||||
Tools::redirectAdmin('index.php?tab=AdminCustomers&id_customer='.intval($_POST['bo_query']).'&viewcustomer'.'&token='.Tools::getAdminToken('AdminCustomers'.intval(Tab::getIdFromClassName('AdminCustomers')).intval($cookie->id_employee)));
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('customer #').intval($_POST['bo_query']).' '.Tools::displayError('not found');
|
||||
}
|
||||
/* Search customers by name */
|
||||
else
|
||||
self::searchCustomer($_POST['bo_query']);
|
||||
}
|
||||
|
||||
/* Order */
|
||||
if (intval($_POST['bo_search_type']) == 3)
|
||||
{
|
||||
if (intval($_POST['bo_query']) AND Validate::isUnsignedInt(intval($_POST['bo_query'])))
|
||||
{
|
||||
$order = new Order(intval($_POST['bo_query']));
|
||||
if ($order->id)
|
||||
Tools::redirectAdmin('index.php?tab=AdminOrders&id_order='.intval($_POST['bo_query']).'&vieworder'.'&token='.Tools::getAdminToken('AdminOrders'.intval(Tab::getIdFromClassName('AdminOrders')).intval($cookie->id_employee)));
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('order #').intval($_POST['bo_query']).' '.Tools::displayError('not found');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('please type an order ID');
|
||||
}
|
||||
|
||||
/* Invoices */
|
||||
if (intval($_POST['bo_search_type']) == 4)
|
||||
{
|
||||
if (intval($_POST['bo_query']) AND Validate::isUnsignedInt(intval($_POST['bo_query'])))
|
||||
{
|
||||
if ($invoice = Order::getInvoice(intval($_POST['bo_query'])))
|
||||
{
|
||||
Tools::redirectAdmin('pdf.php?id_order='.intval($invoice['id_order']).'&pdf');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('invoice #').intval($_POST['bo_query']).' '.Tools::displayError('not found');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('please type an invoice ID');
|
||||
}
|
||||
else
|
||||
Tools::displayError('please fill in search form first.');
|
||||
|
||||
/* Cart */
|
||||
if (intval($_POST['bo_search_type']) == 5)
|
||||
{
|
||||
if (intval($_POST['bo_query']) AND Validate::isUnsignedInt(intval($_POST['bo_query'])))
|
||||
{
|
||||
if ($cart = new Cart(intval($_POST['bo_query'])) AND $cart->id)
|
||||
{
|
||||
Tools::redirectAdmin('index.php?tab=AdminCarts&id_cart='.intval($cart->id).'&viewcart'.'&token='.Tools::getAdminToken('AdminCarts'.intval(Tab::getIdFromClassName('AdminCarts')).intval($cookie->id_employee)));
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('cart #').intval($_POST['bo_query']).' '.Tools::displayError('not found');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('please type a cart ID');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
global $cookie;
|
||||
$currentIndex = 'index.php';
|
||||
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
|
||||
$query = isset($_POST['bo_query']) ? trim(strval($_POST['bo_query'])) : '';
|
||||
/* Display categories if any has been matching */
|
||||
if (isset($this->_list['categories']) AND $nbCategories = sizeof($this->_list['categories']))
|
||||
{
|
||||
echo '<h3>'.$nbCategories.' '.($nbCategories > 1 ? $this->l('categories found with') : $this->l('category found with')).' <b>"'.Tools::safeOutput($query).'"</b></h3>';
|
||||
echo '
|
||||
<table cellspacing="0" cellpadding="0" class="table">';
|
||||
$irow = 0;
|
||||
foreach ($this->_list['categories'] AS $k => $category)
|
||||
echo '<tr class="'.($irow++ % 2 ? 'alt_row' : '').'"><td>'.rtrim(getPath($currentIndex.'?tab=AdminCatalog', $category['id_category'], '', $query), ' >').'</td></tr>';
|
||||
echo '</table><br /><br />';
|
||||
}
|
||||
else
|
||||
$nbCategories = 0;
|
||||
|
||||
/* Display products if any has been matching */
|
||||
if (isset($this->_list['products']) AND !empty($this->_list['products']) AND $nbProducts = sizeof($this->_list['products']))
|
||||
{
|
||||
echo '<h3>'.$nbProducts.' '.($nbProducts > 1 ? $this->l('products found with') : $this->l('product found with')).' <b>"'.Tools::safeOutput($query).'"</b></h3>
|
||||
<table class="table" cellpadding="0" cellspacing="0">
|
||||
<tr>';
|
||||
foreach ($this->fieldsDisplay['catalog'] AS $field)
|
||||
echo '<th'.(isset($field['width']) ? 'style="width: '.$field['width'].'"' : '').'>'.$field['title'].'</th>';
|
||||
echo '
|
||||
</tr>';
|
||||
foreach ($this->_list['products'] AS $k => $product)
|
||||
{
|
||||
echo '
|
||||
<tr>
|
||||
<td>'.$product['id_product'].'</td>
|
||||
<td align="center">'.($product['manufacturer_name'] != NULL ? stripslashes($product['manufacturer_name']) : '--').'</td>
|
||||
<td>'.$product['reference'].'</td>
|
||||
<td><a href="'.$currentIndex.'?tab=AdminCatalog&id_product='.$product['id_product'].'&addproduct&token='.Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)).'">'.stripslashes($product['nameh']).'</a></td>
|
||||
<td>'.Tools::displayPrice($product['price'], $currency).'</td>
|
||||
<td>'.stripslashes($product['tax_name']).'</td>
|
||||
<td align="center">'.$product['quantity'].'</td>
|
||||
<td align="center">'.$product['weight'].' '.Configuration::get('PS_WEIGHT_UNIT').'</td>
|
||||
<td align="center"><a href="'.$currentIndex.'?tab=AdminCatalog&id_product='.$product['id_product'].'&status&token='.Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)).'">
|
||||
<img src="../img/admin/'.($product['active'] ? 'enabled.gif' : 'forbbiden.gif').'" alt="" /></a></td>
|
||||
<td>
|
||||
<a href="'.$currentIndex.'?tab=AdminCatalog&id_product='.$product['id_product'].'&addproduct&token='.Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)).'">
|
||||
<img src="../img/admin/edit.gif" alt="'.$this->l('Modify this product').'" /></a>
|
||||
<a href="'.$currentIndex.'?tab=AdminCatalog&id_product='.$product['id_product'].'&deleteproduct&token='.Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)).'" onclick="return confirm(\''.$this->l('Do you want to delete', __CLASS__, true, false).' '.addslashes($product['name']).$this->l('?', __CLASS__, true, false).'\');">
|
||||
<img src="../img/admin/delete.gif" alt="'.$this->l('Delete this product').'" /></a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '</table>
|
||||
<div class="clear"> </div>';
|
||||
}
|
||||
else
|
||||
$nbProducts = 0;
|
||||
|
||||
/* Display customers if any has been matching */
|
||||
if (isset($this->_list['customers']) AND !empty($this->_list['customers']) AND $nbCustomers = sizeof($this->_list['customers']))
|
||||
{
|
||||
echo '<h3>'.$nbCustomers.' '.($nbCustomers > 1 ? $this->l('customers') : $this->l('customer')).' '.$this->l('found with').' <b>"'.Tools::safeOutput($query).'"</b></h3>
|
||||
<table cellspacing="0" cellpadding="0" class="table widthfull">
|
||||
<tr>';
|
||||
foreach ($this->fieldsDisplay['customers'] AS $field)
|
||||
echo '<th'.(isset($field['width']) ? 'style="width: '.$field['width'].'"' : '').'>'.$field['title'].'</th>';
|
||||
echo '
|
||||
</tr>';
|
||||
$irow = 0;
|
||||
foreach ($this->_list['customers'] AS $k => $customer)
|
||||
{
|
||||
$imgGender = $customer['id_gender'] == 1 ? '<img src="../img/admin/male.gif" alt="'.$this->l('Male').'" />' : ($customer['id_gender'] == 2 ? '<img src="../img/admin/female.gif" alt="'.$this->l('Female').'" />' : '');
|
||||
echo '
|
||||
<tr class="'.($irow++ % 2 ? 'alt_row' : '').'">
|
||||
<td>'.$customer['id_customer'].'</td>
|
||||
<td class="center">'.$imgGender.'</td>
|
||||
<td>'.stripslashes($customer['lastname']).' '.stripslashes($customer['firstname']).'</td>
|
||||
<td>'.stripslashes($customer['email']).'<a href="mailto:'.stripslashes($customer['email']).'"> <img src="../img/admin/email_edit.gif" alt="'.$this->l('Write to this customer').'" /></a></td>
|
||||
<td>'.Tools::displayDate($customer['birthday'], intval($cookie->id_lang)).'</td>
|
||||
<td>'.Tools::displayDate($customer['date_add'], intval($cookie->id_lang)).'</td>
|
||||
<td>'.Order::getCustomerNbOrders($customer['id_customer']).'</td>
|
||||
<td class="center"><img src="../img/admin/'.($customer['active'] ? 'enabled.gif' : 'forbbiden.gif').'" alt="" /></td>
|
||||
<td class="center" width="60px">
|
||||
<a href="'.$currentIndex.'?tab=AdminCustomers&id_customer='.$customer['id_customer'].'&viewcustomer&token='.Tools::getAdminToken('AdminCustomers'.intval(Tab::getIdFromClassName('AdminCustomers')).intval($cookie->id_employee)).'">
|
||||
<img src="../img/admin/details.gif" alt="'.$this->l('View orders').'" /></a>
|
||||
<a href="'.$currentIndex.'?tab=AdminCustomers&id_customer='.$customer['id_customer'].'&addcustomer&token='.Tools::getAdminToken('AdminCustomers'.intval(Tab::getIdFromClassName('AdminCustomers')).intval($cookie->id_employee)).'">
|
||||
<img src="../img/admin/edit.gif" alt="'.$this->l('Modify this customer').'" /></a>
|
||||
<a href="'.$currentIndex.'?tab=AdminCustomers&id_customer='.$customer['id_customer'].'&deletecustomer&token='.Tools::getAdminToken('AdminCustomers'.intval(Tab::getIdFromClassName('AdminCustomers')).intval($cookie->id_employee)).'" onclick="return confirm(\''.$this->l('Are you sure?', __CLASS__, true, false).'\');">
|
||||
<img src="../img/admin/delete.gif" alt="'.$this->l('Delete this customer').'" /></a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '</table>
|
||||
<div class="clear"> </div>';
|
||||
}
|
||||
else
|
||||
$nbCustomers = 0;
|
||||
|
||||
if (isset($this->_list['cart']))
|
||||
{
|
||||
$cart = $this->_list['cart'];
|
||||
$products = $cart->getProducts();
|
||||
$discounts = $cart->getDiscounts();
|
||||
$total_discounts = $cart->getOrderTotal(false, 2);
|
||||
$total_shipping = $cart->getOrderShippingCost($cart->id_carrier);
|
||||
$total_wrapping = $cart->getOrderTotal(true, 6);
|
||||
$total_products = $cart->getOrderTotal(true, 1);
|
||||
$total_price = $cart->getOrderTotal();
|
||||
|
||||
echo '<h2>'.$this->l('Cart found:').' (#'.sprintf('%08d', $cart->id).')</h2>
|
||||
<table cellspacing="0" cellpadding="0" class="table">
|
||||
<tr>
|
||||
<th width="75" align="center">'.$this->l('Reference').'</th>
|
||||
<th>Product</th>
|
||||
<th width="55" align="center">'.$this->l('Quantity').'</th>
|
||||
<th width="88" align="right">'.$this->l('Unit price').'</th>
|
||||
<th width="80" align="right">'.$this->l('Total price').'</th>
|
||||
</tr>';
|
||||
if ($products)
|
||||
foreach ($products as $product)
|
||||
echo '
|
||||
<tr>
|
||||
<td>'.$product['reference'].'</td>
|
||||
<td>'.$product['name'].'</a></td>
|
||||
<td align="right">'.$product['quantity'].'</td>
|
||||
<td align="right">'.Tools::displayPrice($product['price'], $currency).'</td>
|
||||
<td align="right">'.Tools::displayPrice($product['total_wt'], $currency).'</td>
|
||||
</tr>';
|
||||
if ($discounts)
|
||||
foreach ($discounts as $discount)
|
||||
echo '
|
||||
<tr>
|
||||
<td>'.$discount['name'].'</td>
|
||||
<td>'.$discount['description'].'</td>
|
||||
<td align="right">1</td>
|
||||
<td align="right">-'.Tools::displayPrice($discount['value'], $currency).'</td>
|
||||
<td align="right">-'.Tools::displayPrice($discount['value'], $currency).'</td>
|
||||
</tr>';
|
||||
echo '
|
||||
<tr style="text-align: right; font-weight: bold;">
|
||||
<td colspan="4">'.$this->l('Products:').' </td>
|
||||
<td>'.Tools::displayPrice($total_products, $currency).'</td>
|
||||
</tr>
|
||||
<tr style="text-align: right; font-weight: bold;">
|
||||
<td colspan="4">'.$this->l('Vouchers').' </td>
|
||||
<td>'.Tools::displayPrice($total_discounts, $currency).'</td>
|
||||
</tr>
|
||||
<tr style="text-align: right; font-weight: bold;">
|
||||
<td colspan="4">'.$this->l('Gift-wrapping:').' </td>
|
||||
<td>'.Tools::displayPrice($total_wrapping, $currency).'</td>
|
||||
</tr>
|
||||
<tr style="text-align: right; font-weight: bold;">
|
||||
<td colspan="4">'.$this->l('Shipping:').' </td>
|
||||
<td>'.Tools::displayPrice($total_shipping, $currency).'</td>
|
||||
</tr>
|
||||
<tr style="text-align: right; font-weight: bold;">
|
||||
<td colspan="4">'.$this->l('Total:').' </td>
|
||||
<td>'.Tools::displayPrice($total_price, $currency).'</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="clear"> </div>';
|
||||
}
|
||||
|
||||
/* Display error if nothing has been matching */
|
||||
if (!$nbCategories AND !$nbProducts AND !$nbCustomers AND !isset($this->_list['cart']))
|
||||
echo '<h3>'.$this->l('Nothing found').'.</h3>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Emails tab for admin panel, AdminEmails.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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');
|
||||
include_once(PS_ADMIN_DIR.'/tabs/AdminPreferences.php');
|
||||
|
||||
class AdminSearchConf extends AdminPreferences
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$this->className = 'Configuration';
|
||||
$this->table = 'configuration';
|
||||
|
||||
$this->_fieldsSearch = array(
|
||||
'PS_SEARCH_AJAX' => array('title' => $this->l('Ajax search'), 'desc' => $this->l('Enable the ajax search for your visitors.'), 'validation' => 'isBool', 'type' => 'bool', 'cast' => 'intval'),
|
||||
'PS_SEARCH_MINWORDLEN' => array('title' => $this->l('Minimum word length'), 'desc' => $this->l('Only words from this size will be indexed.'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'),
|
||||
'PS_SEARCH_BLACKLIST' => array('title' => $this->l('Blacklisted words'), 'size' => 35, 'validation' => 'isGenericName', 'desc' => $this->l('Please enter the words separated by a "|".'), 'type' => 'textLang'),
|
||||
'PS_SEARCH_WEIGHT_PNAME' => array('title' => $this->l('Product name weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'),
|
||||
'PS_SEARCH_WEIGHT_REF' => array('title' => $this->l('Reference weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'),
|
||||
'PS_SEARCH_WEIGHT_SHORTDESC' => array('title' => $this->l('Short description weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'),
|
||||
'PS_SEARCH_WEIGHT_DESC' => array('title' => $this->l('Description weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'),
|
||||
'PS_SEARCH_WEIGHT_CNAME' => array('title' => $this->l('Category weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'),
|
||||
'PS_SEARCH_WEIGHT_MNAME' => array('title' => $this->l('Manufacturer weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'),
|
||||
'PS_SEARCH_WEIGHT_TAG' => array('title' => $this->l('Tags weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'),
|
||||
'PS_SEARCH_WEIGHT_ATTRIBUTE' => array('title' => $this->l('Attributes weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'),
|
||||
'PS_SEARCH_WEIGHT_FEATURE' => array('title' => $this->l('Features weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval')
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (isset($_POST['submitSearch'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
$this->_postConfig($this->_fieldsSearch);
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$currentFileName = array_reverse(explode("/", $_SERVER['SCRIPT_NAME']));
|
||||
$cronUrl = Tools::getHttpHost(true, true).__PS_BASE_URI__.substr($_SERVER['SCRIPT_NAME'], strlen(__PS_BASE_URI__), -strlen($currentFileName['0'])).'searchcron?full=1&token='.substr(_COOKIE_KEY_, 34, 8);
|
||||
list($total, $indexed) = Db::getInstance()->getRow('SELECT COUNT(*) as "0", SUM(indexed) as "1" FROM '._DB_PREFIX_.'product');
|
||||
echo '
|
||||
<fieldset class="width3"><legend>'.$this->l('Indexation').'</legend>
|
||||
'.$this->l('Indexed products:').' <b>'.intval($indexed).' / '.intval($total).'</b>.<br /><br />
|
||||
-> <a href="searchcron.php?token='.substr(_COOKIE_KEY_, 34, 8).'" class="bold">'.$this->l('Add missing products to index.').'</a><br />
|
||||
-> <a href="searchcron.php?full=1&token='.substr(_COOKIE_KEY_, 34, 8).'" class="bold">'.$this->l('Re-build entire index.').'</a><br /><br />
|
||||
'.$this->l('You can set a cron job that will re-build your index using the following URL:').' <a href="'.$cronUrl.'">'.$cronUrl.'</a>.
|
||||
</fieldset>
|
||||
<div class="clear"> </div>';
|
||||
$this->_displayForm('search', $this->_fieldsSearch, $this->l('Search'), 'width2', 'search');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Search engine tab for admin panel, AdminSearchEngines.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @copyright PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.3
|
||||
*
|
||||
*/
|
||||
|
||||
class AdminSearchEngines extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'search_engine';
|
||||
$this->className = 'SearchEngine';
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_search_engine' => array('title' => $this->l('ID'), 'width' => 25),
|
||||
'server' => array('title' => $this->l('Server'), 'width' => 200),
|
||||
'getvar' => array('title' => $this->l('GET variable'), 'width' => 40));
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" class="width2">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset class="width3"><legend>'.$this->l('Referrer').'</legend>
|
||||
<label>'.$this->l('Server').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="20" name="server" value="'.htmlentities($this->getFieldValue($obj, 'server'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
</div>
|
||||
<label>'.$this->l('$_GET variable').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="40" name="getvar" value="'.htmlentities($this->getFieldValue($obj, 'getvar'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,261 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Shipping tab for admin panel, AdminShipping.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminShipping extends AdminTab
|
||||
{
|
||||
private $_fieldsHandling;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'delivery';
|
||||
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
|
||||
$this->_fieldsHandling = array(
|
||||
'PS_SHIPPING_HANDLING' => array('title' => $this->l('Handling charges'), 'suffix' => $currency, 'validation' => 'isPrice', 'cast' => 'floatval'),
|
||||
'PS_SHIPPING_FREE_PRICE' => array('title' => $this->l('Free shipping starts at'), 'suffix' => $currency, 'validation' => 'isPrice', 'cast' => 'floatval'),
|
||||
'PS_SHIPPING_FREE_WEIGHT' => array('title' => $this->l('Free shipping starts at'), 'suffix' => Configuration::get('PS_WEIGHT_UNIT'), 'validation' => 'isUnsignedFloat', 'cast' => 'floatval'),
|
||||
'PS_SHIPPING_METHOD' => array('title' => $this->l('Billing'), 'validation' => 'isBool', 'cast' => 'intval'));
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
/* Handling settings */
|
||||
if (isset($_POST['submitHandling'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
/* Check required fields */
|
||||
foreach ($this->_fieldsHandling AS $field => $values)
|
||||
if (($value = Tools::getValue($field)) == false AND (string)$value != '0')
|
||||
$this->_errors[] = Tools::displayError('field').' <b>'.$values['title'].'</b> '.Tools::displayError('is required');
|
||||
|
||||
/* Check field validity */
|
||||
foreach ($this->_fieldsHandling AS $field => $values)
|
||||
if (Tools::getValue($field))
|
||||
{
|
||||
$function = $values['validation'];
|
||||
if (!Validate::$function(Tools::getValue($field)))
|
||||
$this->_errors[] = Tools::displayError('field').' <b>'.$values['title'].'</b> '.Tools::displayError('is invalid');
|
||||
}
|
||||
|
||||
/* Update configuration values */
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
foreach ($this->_fieldsHandling AS $field => $values)
|
||||
{
|
||||
$function = $values['cast'];
|
||||
Configuration::updateValue($field, call_user_func($function, Tools::getValue($field)));
|
||||
}
|
||||
|
||||
Tools::redirectAdmin($currentIndex.'&conf=6'.'&token='.$this->token);
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
|
||||
/* Shipping fees */
|
||||
elseif (isset($_POST['submitFees'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (($id_carrier = intval(Tools::getValue('id_carrier'))) AND $id_carrier == ($id_carrier2 = intval(Tools::getValue('id_carrier2'))))
|
||||
{
|
||||
$carrier = new Carrier($id_carrier);
|
||||
if (Validate::isLoadedObject($carrier))
|
||||
{
|
||||
/* Get configuration values */
|
||||
$shipping_method = intval(Configuration::get('PS_SHIPPING_METHOD'));
|
||||
|
||||
$rangeTable = $shipping_method ? 'range_weight' : 'range_price';
|
||||
$carrier->deleteDeliveryPrice($rangeTable);
|
||||
|
||||
/* Build prices list */
|
||||
$priceList = '';
|
||||
foreach ($_POST AS $key => $value)
|
||||
if (strstr($key, 'fees_'))
|
||||
{
|
||||
$tmpArray = explode('_', $key);
|
||||
$priceList .= '('.($shipping_method == 0 ? intval($tmpArray[2]) : 'NULL').',
|
||||
'.($shipping_method == 1 ? intval($tmpArray[2]) : 'NULL').', '.$carrier->id.',
|
||||
'.intval($tmpArray[1]).', '.number_format(abs($value), 2, '.', '').'),';
|
||||
unset($tmpArray);
|
||||
}
|
||||
$priceList = rtrim($priceList, ',');
|
||||
|
||||
/* Update delivery prices */
|
||||
$carrier->addDeliveryPrice($priceList);
|
||||
Tools::redirectAdmin($currentIndex.'&conf=6'.'&token='.$this->token);
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('an error occurred while updating fees (cannot load carrier object)');
|
||||
}
|
||||
elseif (isset($id_carrier2))
|
||||
{
|
||||
$_POST['id_carrier'] = $id_carrier2;
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('an error occurred while updating fees (cannot load carrier object)');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
|
||||
}
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$this->displayFormHandling();
|
||||
$this->displayFormFees();
|
||||
}
|
||||
|
||||
public function displayFormHandling()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
$confKeys = $this->_fieldsHandling;
|
||||
foreach ($confKeys AS $key => $confKey)
|
||||
$getConf[] = $key;
|
||||
$confValues = Configuration::getMultiple($getConf);
|
||||
unset($confKeys['PS_SHIPPING_METHOD']);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitHandling'.$this->table.'=1&token='.$this->token.'" method="post" class="width2">
|
||||
<fieldset>
|
||||
<legend><img src="../img/admin/delivery.gif" />'.$this->l('Handling').'</legend>';
|
||||
|
||||
foreach ($confKeys AS $key => $confKey)
|
||||
{
|
||||
$postValue = Tools::getValue($key);
|
||||
$sign_left = (is_object($confKey['suffix']) ? $confKey['suffix']->getSign('left') : '');
|
||||
$sign_right = (is_object($confKey['suffix']) ? $confKey['suffix']->getSign('right') : (is_string($confKey['suffix']) ? ' '.$confKey['suffix'] : ''));
|
||||
echo '
|
||||
<label class="clear">'.$confKey['title'].':</label>
|
||||
<div class="margin-form">';
|
||||
echo $sign_left;
|
||||
echo '<input size="6" type="text" name="'.$key.'" value="'.(($postValue != false OR (string)$postValue == '0') ? $postValue : $confValues[$key]).'" />';
|
||||
echo $sign_right.' '.($key == 'PS_SHIPPING_HANDLING' ? $this->l('(tax excl.)') : '');
|
||||
echo '</div>';
|
||||
}
|
||||
echo '
|
||||
<div class="margin-form" style="margin-top: 20px;">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitHandling'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<p style="font-weight: bold; font-size: 11px;">'.$this->l('Tips:').'</p>
|
||||
<ul style="list-style-type: disc; font-size: 11px; color:#7F7F7F; margin-left: 30px; line-height: 20px;">
|
||||
<li>'.$this->l('If you set these parameters to 0, they will be disabled').'</li>
|
||||
<li>'.$this->l('Coupons are not taken into account when calculating free shipping').'</li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
<br />
|
||||
<fieldset>
|
||||
<legend><img src="../img/admin/money.gif" />'.$this->l('Billing').'</legend>
|
||||
<label class="clear">'.$this->l('Choice of range:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="PS_SHIPPING_METHOD" value="0" id="total_price"
|
||||
'.((isset($confValues['PS_SHIPPING_METHOD']) AND $confValues['PS_SHIPPING_METHOD'] == 0) ? 'checked="checked"' : '').'/>
|
||||
<label class="t" for="total_price"> '.$this->l('According to total price').'</label><br />
|
||||
<input type="radio" name="PS_SHIPPING_METHOD" value="1" id="total_weight"
|
||||
'.((!isset($confValues['PS_SHIPPING_METHOD']) OR $confValues['PS_SHIPPING_METHOD'] == 1) ? 'checked="checked"' : '').'/>
|
||||
<label class="t" for="total_weight"> '.$this->l('According to total weight').'</label>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitHandling'.$this->table.'" class="button" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
public function displayFormFees()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
echo '<br /><br />
|
||||
<h2>'.$this->l('Fees by carrier, geographical zone, and ranges').'</h2>
|
||||
<form action="'.$currentIndex.'&token='.$this->token.'" id="fees" name="fees" method="post" class="width2">
|
||||
<fieldset>
|
||||
<legend><img src="../img/admin/delivery.gif" />'.$this->l('Fees').'</legend>
|
||||
<b>'.$this->l('Carrier:').' </b>
|
||||
<select name="id_carrier2" onchange="document.fees.submit();">';
|
||||
$carriers = Carrier::getCarriers(intval(Configuration::get('PS_LANG_DEFAULT')));
|
||||
$id_carrier = Tools::getValue('id_carrier') ? intval(Tools::getValue('id_carrier')) : intval($carriers[0]['id_carrier']);
|
||||
$carrierSelected = new Carrier($id_carrier);
|
||||
foreach ($carriers AS $carrier)
|
||||
echo '<option value="'.intval($carrier['id_carrier']).'"'.(($carrier['id_carrier'] == $id_carrier) ? ' selected="selected"' : '').'>'.$carrier['name'].'</option>';
|
||||
echo '
|
||||
</select><br />
|
||||
<table class="table space" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<th>'.$this->l('Zone / Range').'</th>';
|
||||
|
||||
$shipping_method = intval(Configuration::get('PS_SHIPPING_METHOD'));
|
||||
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
$rangeObj = $shipping_method ? new RangeWeight() : new RangePrice();
|
||||
$rangeTable = $shipping_method ? 'range_weight' : 'range_price';
|
||||
$rangeIdentifier = 'id_'.$rangeTable;
|
||||
$ranges = $rangeObj->getRanges($id_carrier);
|
||||
$suffix = $shipping_method ? Configuration::get('PS_WEIGHT_UNIT') : $currency->sign;
|
||||
$delivery = Carrier::getDeliveryPriceByRanges($rangeTable);
|
||||
foreach ($delivery AS $deliv)
|
||||
$deliveryArray[$deliv['id_zone']][$deliv['id_carrier']][$deliv[$rangeIdentifier]] = $deliv['price'];
|
||||
foreach ($ranges AS $range)
|
||||
echo '<th style="font-size: 11px;">'.floatval($range['delimiter1']).$suffix.' '.$this->l('to').' '.floatval($range['delimiter2']).$suffix.'</th>';
|
||||
echo '</tr>';
|
||||
|
||||
$zones = Zone::getZones(true);
|
||||
if (sizeof($ranges))
|
||||
foreach ($zones AS $zone)
|
||||
{
|
||||
if (!$carrierSelected->getZone($zone['id_zone']))
|
||||
continue ;
|
||||
echo '
|
||||
<tr>
|
||||
<th style="height: 30px;">'.$zone['name'].'</th>';
|
||||
foreach ($ranges AS $range)
|
||||
{
|
||||
if (isset($deliveryArray[$zone['id_zone']][$id_carrier][$range[$rangeIdentifier]]))
|
||||
$price = $deliveryArray[$zone['id_zone']][$id_carrier][$range[$rangeIdentifier]];
|
||||
else
|
||||
$price = '0.00';
|
||||
echo '<td class="center">'.$currency->getSign('left').'<input type="text" name="fees_'.$zone['id_zone'].'_'.$range[$rangeIdentifier].'" value="'.$price.'" style="width: 45px;" />'.$currency->getSign('right').'</td>';
|
||||
}
|
||||
echo '
|
||||
</tr>';
|
||||
}
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="'.(sizeof($ranges) + 1).'" class="center" style="border-bottom: none; height: 40px;">
|
||||
<input type="hidden" name="submitFees'.$this->table.'" value="1" />
|
||||
';
|
||||
if (sizeof($ranges))
|
||||
echo ' <input type="submit" value="'.$this->l(' Save ').'" class="button" />';
|
||||
else
|
||||
echo $this->l('No ranges set for this carrier');
|
||||
echo '
|
||||
</td>
|
||||
</tr>';
|
||||
echo '
|
||||
</table>
|
||||
<p>'.$this->l('Prices are tax excluded.').'</p>
|
||||
</fieldset>
|
||||
<input type="hidden" name="id_carrier" value="'.$id_carrier.'" />
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Order statues tab for admin panel, AdminOrdersStates.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminSlip extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'order_slip';
|
||||
$this->className = 'OrderSlip';
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
$this->noAdd = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_order_slip' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'id_order' => array('title' => $this->l('ID Order'), 'width' => 75, 'align' => 'center'),
|
||||
'date_add' => array('title' => $this->l('Date issued'), 'width' => 60, 'type' => 'date'));
|
||||
|
||||
$this->optionTitle = $this->l('Slip');
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$this->getList(intval($cookie->id_lang), !Tools::getValue($this->table.'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL);
|
||||
$this->displayList();
|
||||
}
|
||||
|
||||
public function displayListContent($token = NULL)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
$irow = 0;
|
||||
if ($this->_list)
|
||||
foreach ($this->_list AS $tr)
|
||||
{
|
||||
$tr['id_order'] = $this->l('#').sprintf('%06d', $tr['id_order']);
|
||||
echo '<tr'.($irow++ % 2 ? ' class="alt_row"' : '').'>';
|
||||
echo '<td class="center"><input type="checkbox" name="'.$this->table.'Box[]" value="'.$tr['id_order_slip'].'" class="noborder" /></td>';
|
||||
foreach ($this->fieldsDisplay AS $key => $params)
|
||||
echo '<td class="pointer" onclick="document.location = \'pdf.php?id_order_slip='.$tr['id_order_slip'].'\'">'.$tr[$key].'</td>';
|
||||
echo '<td class="center">';
|
||||
echo '
|
||||
<a href="pdf.php?id_order_slip='.$tr['id_order_slip'].'">
|
||||
<img src="../img/admin/details.gif" border="0" alt="'.$this->l('View').'" title="'.$this->l('View').'" /></a>';
|
||||
echo '
|
||||
<a href="'.$currentIndex.'&id_'.$this->table.'='.$tr['id_order_slip'].'&delete'.$this->table.'&token='.($token!=NULL ? $token : $this->token).'" onclick="return confirm(\''.$this->l('Delete item #', __CLASS__, true, false).$tr['id_order_slip'].$this->l('?', __CLASS__, true, false).'\');">
|
||||
<img src="../img/admin/delete.gif" border="0" alt="'.$this->l('Delete').'" title="'.$this->l('Delete').'" /></a>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* States tab for admin panel, AdminStates.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminStates extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'state';
|
||||
$this->className = 'State';
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_state' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 140, 'filter_key' => 'a!name'),
|
||||
'iso_code' => array('title' => $this->l('ISO code'), 'align' => 'center', 'width' => 50),
|
||||
'zone' => array('title' => $this->l('Zone'), 'width' => 100, 'filter_key' => 'z!name'));
|
||||
$this->_select = 'z.`name` AS zone';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = a.`id_zone`)';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset class="width3"><legend><img src="../img/admin/world.gif" />'.$this->l('States').'</legend>
|
||||
<label>'.$this->l('Name:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="30" maxlength="32" name="name" value="'.htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('State name to display in addresses and on invoices').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('ISO code:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="5" maxlength="4" name="iso_code" value="'.htmlentities($this->getFieldValue($obj, 'iso_code'), ENT_COMPAT, 'UTF-8').'" style="text-transform: uppercase;" /> <sup>*</sup>
|
||||
<p>'.$this->l('1 to 4 letter ISO code').' (<a href="http://simple.wikipedia.org/wiki/List_of_U.S._states" target="_blank">'.$this->l('official list here').'</a>)</p>
|
||||
</div>
|
||||
<label>'.$this->l('Country:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name="id_country">';
|
||||
$countries = Country::getCountries(intval($cookie->id_lang), false, true);
|
||||
foreach ($countries AS $country)
|
||||
echo '<option value="'.intval($country['id_country']).'"'.(($this->getFieldValue($obj, 'id_country') == $country['id_country']) ? ' selected="selected"' : '').'>'.$country['name'].'</option>';
|
||||
echo '
|
||||
</select>
|
||||
<p>'.$this->l('Country where state, region or city is located').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Zone:').' </label>
|
||||
<div class="margin-form">
|
||||
<select name="id_zone">';
|
||||
|
||||
$zones = Zone::getZones();
|
||||
foreach ($zones AS $zone)
|
||||
echo '<option value="'.intval($zone['id_zone']).'"'.(($this->getFieldValue($obj, 'id_zone') == $zone['id_zone']) ? ' selected="selected"' : '').'>'.$zone['name'].'</option>';
|
||||
|
||||
echo '
|
||||
</select>
|
||||
<p>'.$this->l('Geographical zone where this state is located').'<br />'.$this->l('Used for shipping').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Tax behavior:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="tax_behavior" id="product_tax" value="'.PS_PRODUCT_TAX.'" '.((!$obj->id OR $this->getFieldValue($obj, 'tax_behavior') == PS_PRODUCT_TAX) ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="product_tax">'.$this->l('Product tax').'</label>
|
||||
<input type="radio" name="tax_behavior" id="state_tax" value="'.PS_STATE_TAX.'" '.(($this->getFieldValue($obj, 'tax_behavior') == PS_STATE_TAX AND $obj->id) ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="state_tax">'.$this->l('State tax').'</label>
|
||||
<input type="radio" name="tax_behavior" id="both_tax" value="'.PS_BOTH_TAX.'" '.(($this->getFieldValue($obj, 'tax_behavior') == PS_BOTH_TAX AND $obj->id) ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="both_tax">'.$this->l('Both product & state tax').'</label>
|
||||
<p>'.$this->l('Chose how tax will be applied for this state: the product\'s tax, the state\'s tax, or both.').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Status:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="active" id="active_on" value="1" '.((!$obj->id OR $this->getFieldValue($obj, 'active')) ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
|
||||
<input type="radio" name="active" id="active_off" value="0" '.((!$this->getFieldValue($obj, 'active') AND $obj->id) ? 'checked="checked" ' : '').'/>
|
||||
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p>'.$this->l('Enabled or disabled').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,228 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Statistics
|
||||
* @category stats
|
||||
*
|
||||
* @author Damien Metzger / Epitech
|
||||
* @copyright Epitech / PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.2
|
||||
*/
|
||||
|
||||
include_once(dirname(__FILE__).'/AdminStatsTab.php');
|
||||
|
||||
class AdminStats extends AdminStatsTab
|
||||
{
|
||||
private static $validOrder;
|
||||
|
||||
private static function recordQuery($dateBetween, $format, $order)
|
||||
{
|
||||
return Db::getInstance()->getRow('
|
||||
SELECT date_format(o.`date_add`, \''.$format.'\') as date, SUM(o.`total_products` / c.conversion_rate) as totalht, SUM(o.`total_paid` / c.conversion_rate) as totalttc
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'currency` c ON o.id_currency = c.id_currency
|
||||
WHERE o.valid = 1
|
||||
AND o.`date_add` BETWEEN '.$dateBetween.'
|
||||
GROUP BY date_format(o.`date_add`, \''.$format.'\')
|
||||
ORDER BY totalht '.$order);
|
||||
}
|
||||
|
||||
public static function getRecords($dateBetween)
|
||||
{
|
||||
$xtrems = array();
|
||||
$xtrems['bestmonth'] = self::recordQuery($dateBetween, '%Y-%m', 'DESC');
|
||||
$xtrems['worstmonth'] = self::recordQuery($dateBetween, '%Y-%m', 'ASC');
|
||||
$xtrems['bestday'] = self::recordQuery($dateBetween, '%Y-%m-%d', 'DESC');
|
||||
$xtrems['worstday'] = self::recordQuery($dateBetween, '%Y-%m-%d', 'ASC');
|
||||
if ($xtrems['bestmonth'])
|
||||
return $xtrems;
|
||||
}
|
||||
|
||||
public static function getSales($dateBetween)
|
||||
{
|
||||
$result = Db::getInstance()->getRow('
|
||||
SELECT COUNT(DISTINCT o.`id_order`) as orders, SUM(o.`total_paid` / c.conversion_rate) as ttc, SUM(o.`total_products` / c.conversion_rate) as ht
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
INNER JOIN `'._DB_PREFIX_.'currency` c ON o.id_currency = c.id_currency
|
||||
WHERE o.valid = 1
|
||||
AND o.`invoice_date` BETWEEN '.$dateBetween);
|
||||
|
||||
$products = Db::getInstance()->getRow('
|
||||
SELECT COUNT(od.`id_order_detail`) as products
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.`id_order` = od.`id_order`
|
||||
WHERE o.valid = 1
|
||||
AND o.`invoice_date` BETWEEN '.$dateBetween);
|
||||
|
||||
$xtrems = Db::getInstance()->getRow('
|
||||
SELECT MAX(`total_products`) as maxht, MIN(`total_products`) as minht, MAX(`total_paid`) as maxttc, MIN(`total_paid`) as minttc
|
||||
FROM (
|
||||
SELECT o.`total_paid` / c.conversion_rate as total_paid, o.`total_products` / c.conversion_rate as total_products
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'currency` c ON o.id_currency = c.id_currency
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.`id_order` = od.`id_order`
|
||||
WHERE o.valid = 1
|
||||
AND o.`invoice_date` BETWEEN '.$dateBetween.') records');
|
||||
|
||||
return array_merge($result, array_merge($xtrems, $products));
|
||||
}
|
||||
|
||||
public static function getCarts($dateBetween)
|
||||
{
|
||||
return Db::getInstance()->getRow('
|
||||
SELECT AVG(cartsum) as average, MAX(cartsum) as highest, MIN(cartsum) as lowest
|
||||
FROM (
|
||||
SELECT SUM(
|
||||
((1+t.rate/100) * p.`price` + IF(cp.id_product_attribute IS NULL OR cp.id_product_attribute = 0, 0, (
|
||||
SELECT IFNULL(pa.price, 0)
|
||||
FROM '._DB_PREFIX_.'product_attribute pa
|
||||
WHERE pa.id_product = cp.id_product
|
||||
AND pa.id_product_attribute = cp.id_product_attribute
|
||||
))) * cp.quantity) / cu.conversion_rate as cartsum
|
||||
FROM `'._DB_PREFIX_.'cart` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'currency` cu ON c.id_currency = cu.id_currency
|
||||
LEFT JOIN `'._DB_PREFIX_.'cart_product` cp ON c.`id_cart` = cp.`id_cart`
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product`
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax` t ON p.`id_tax` = t.`id_tax`
|
||||
WHERE c.`date_upd` BETWEEN '.$dateBetween.'
|
||||
GROUP BY c.`id_cart`
|
||||
) carts');
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$currency = Currency::getCurrency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
$language = Language::getLanguage(intval($cookie->id_lang));
|
||||
$iso = $language['iso_code'];
|
||||
$dateBetween = ModuleGraph::getDateBetween();
|
||||
|
||||
$sales = self::getSales($dateBetween);
|
||||
$carts = self::getCarts($dateBetween);
|
||||
$records = self::getRecords($dateBetween);
|
||||
|
||||
echo '
|
||||
<div style="float: left">';
|
||||
$this->displayCalendar();
|
||||
$this->displayMenu(false);
|
||||
$this->displaySearch();
|
||||
echo '
|
||||
</div>
|
||||
<div style="float: left; margin-left: 40px;">
|
||||
<fieldset class="width3"><legend><img src="../img/admin/tab-stats.gif" /> '.$this->l('Help').'</legend>
|
||||
<p>'.$this->l('Use the calendar on the left to select the time period.').'</p>
|
||||
<p>'.$this->l('All available statistic modules are displayed in the Navigation list beneath the calendar.').'</p>
|
||||
<p>'.$this->l('In the Settings sub-tab, you can also customize the Stats tab to fit your needs and resources, change the graph rendering engine, and adjust the database settings.').'</p>
|
||||
</fieldset>
|
||||
<br /><br />
|
||||
<fieldset class="width3"><legend><img src="../img/admin/___info-ca.gif" style="vertical-align: middle" /> '.$this->l('Sales').'</legend>
|
||||
<table>
|
||||
<tr><td style="font-weight: bold">'.$this->l('Total placed orders').'</td><td style="padding-left: 20px">'.$sales['orders'].'</td></tr>
|
||||
<tr><td style="font-weight: bold">'.$this->l('Total products sold').'</td><td style="padding-left: 20px">'.$sales['products'].'</td></tr>
|
||||
</table>
|
||||
<table cellspacing="0" cellpadding="0" class="table space">
|
||||
<tr>
|
||||
<th style="width: 150px"></th>
|
||||
<th style="width: 180px; text-align: center; font-weight: bold">'.$this->l('total paid with tax').'</th>
|
||||
<th style="width: 220px; text-align: center; font-weight: bold">'.$this->l('total products not incl. tax').'</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="font-weight: bold">'.$this->l('Sales turnover').'</th>
|
||||
<td align="right">'.Tools::displayPrice($sales['ttc'], $currency).'</td>
|
||||
<td align="right">'.Tools::displayPrice($sales['ht'], $currency).'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="font-weight: bold">'.$this->l('Largest order').'</th>
|
||||
<td align="right">'.Tools::displayPrice($sales['maxttc'], $currency).'</td>
|
||||
<td align="right">'.Tools::displayPrice($sales['maxht'], $currency).'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="font-weight: bold">'.$this->l('Smallest order').'</th>
|
||||
<td align="right">'.Tools::displayPrice($sales['minttc'], $currency).'</td>
|
||||
<td align="right">'.Tools::displayPrice($sales['minht'], $currency).'</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
<br /><br />
|
||||
<fieldset class="width3"><legend><img src="../img/admin/products.gif" style="vertical-align: middle" /> '.$this->l('Carts').'</legend>
|
||||
<table cellspacing="0" cellpadding="0" class="table">
|
||||
<tr>
|
||||
<th style="width: 150px"></th>
|
||||
<th style="width: 180px; text-align: center; font-weight: bold">'.$this->l('Products total all tax inc.').'</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="font-weight: bold">'.$this->l('Average cart').'</th>
|
||||
<td align="right">'.Tools::displayPrice($carts['average'], $currency).'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="font-weight: bold">'.$this->l('Largest cart').'</th>
|
||||
<td align="right">'.Tools::displayPrice($carts['highest'], $currency).'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="font-weight: bold">'.$this->l('Smallest cart').'</th>
|
||||
<td align="right">'.Tools::displayPrice($carts['lowest'], $currency).'</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>';
|
||||
|
||||
if (strtolower($cookie->stats_granularity) != 'd' AND $records AND is_array($records))
|
||||
{
|
||||
echo '
|
||||
<br /><br />
|
||||
<fieldset class="width3"><legend><img src="../img/admin/medal.png" style="vertical-align: middle" />'.$this->l('Records').'</legend>
|
||||
<table cellspacing="0" cellpadding="0" class="table">
|
||||
<tr>
|
||||
<th style="width: 150px"></th>
|
||||
<th style="width: 100px; text-align: center; font-weight: bold">'.$this->l('date').'</th>
|
||||
<th style="width: 120px; text-align: center; font-weight: bold">'.$this->l('with tax').'</th>
|
||||
<th style="width: 180px; text-align: center; font-weight: bold">'.$this->l('only products not incl. tax').'</th>
|
||||
</tr>';
|
||||
if (strtolower($cookie->stats_granularity) == 'y')
|
||||
echo '
|
||||
<tr>
|
||||
<th style="font-weight: bold">'.$this->l('Best month').'</th>
|
||||
<td align="right">'.$this->displayDate($records['bestmonth']['date'], $iso).'</td>
|
||||
<td align="right">'.Tools::displayPrice($records['bestmonth']['totalttc'], $currency).'</td>
|
||||
<td align="right">'.Tools::displayPrice($records['bestmonth']['totalht'], $currency).'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="font-weight: bold">'.$this->l('Worst month').'</th>
|
||||
<td align="right">'.$this->displayDate($records['worstmonth']['date'], $iso).'</td>
|
||||
<td align="right">'.Tools::displayPrice($records['worstmonth']['totalttc'], $currency).'</td>
|
||||
<td align="right">'.Tools::displayPrice($records['worstmonth']['totalht'], $currency).'</td>
|
||||
</tr>';
|
||||
echo '
|
||||
<tr>
|
||||
<th style="font-weight: bold">'.$this->l('Best day').'</th>
|
||||
<td align="right">'.$this->displayDate($records['bestday']['date'], $iso).'</td>
|
||||
<td align="right">'.Tools::displayPrice($records['bestday']['totalttc'], $currency).'</td>
|
||||
<td align="right">'.Tools::displayPrice($records['bestday']['totalht'], $currency).'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="font-weight: bold">'.$this->l('Worst day').'</th>
|
||||
<td align="right">'.$this->displayDate($records['worstday']['date'], $iso).'</td>
|
||||
<td align="right">'.Tools::displayPrice($records['worstday']['totalttc'], $currency).'</td>
|
||||
<td align="right">'.Tools::displayPrice($records['worstday']['totalht'], $currency).'</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</div>
|
||||
<div class="clear"></div>';
|
||||
}
|
||||
|
||||
static public function displayDate($date, $iso)
|
||||
{
|
||||
$tmpTab = explode('-', $date);
|
||||
if (strtolower($iso == 'fr'))
|
||||
return (isset($tmpTab[2]) ? ($tmpTab[2].'-') : '').$tmpTab[1].'-'.$tmpTab[0];
|
||||
else
|
||||
return $tmpTab[0].'-'.$tmpTab[1].(isset($tmpTab[2]) ? ('-'.$tmpTab[2]) : '');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Statistics
|
||||
* @category stats
|
||||
*
|
||||
* @author Damien Metzger / Epitech
|
||||
* @copyright Epitech / PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.2
|
||||
*/
|
||||
|
||||
include_once(dirname(__FILE__).'/AdminStatsTab.php');
|
||||
include_once(PS_ADMIN_DIR.'/tabs/AdminPreferences.php');
|
||||
|
||||
class AdminStatsConf extends AdminPreferences
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->_fieldsSettings = array(
|
||||
'PS_STATS_RENDER' => array('title' => $this->l('Graph engine'), 'validation' => 'isGenericName'),
|
||||
'PS_STATS_GRID_RENDER' => array('title' => $this->l('Grid engine'), 'validation' => 'isGenericName'),
|
||||
'PS_STATS_OLD_CONNECT_AUTO_CLEAN' => array( 'title' => $this->l('Auto-clean period'), 'validation' => 'isGenericName'));
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::getValue('submitSettings'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
$this->_postConfig($this->_fieldsSettings);
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit something here.');
|
||||
}
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
|
||||
$graphEngine = Configuration::get('PS_STATS_RENDER');
|
||||
$gridEngine = Configuration::get('PS_STATS_GRID_RENDER');
|
||||
$autoclean = Configuration::get('PS_STATS_OLD_CONNECT_AUTO_CLEAN');
|
||||
$arrayGraphEngines = ModuleGraphEngine::getGraphEngines();
|
||||
$arrayGridEngines = ModuleGridEngine::getGridEngines();
|
||||
$autocleanPeriod = array('never' => $this->l('Never'),
|
||||
'week' => $this->l('Week'),
|
||||
'month' => $this->l('Month'),
|
||||
'year' => $this->l('Year'));
|
||||
|
||||
echo '<form action="'.$currentIndex.'&token='.$this->token.'&submitSettings=1" method="post">
|
||||
<fieldset><legend><img src="../img/admin/tab-preferences.gif" />'.$this->l('Settings').'</legend>';
|
||||
|
||||
#Graph Engines
|
||||
echo '<label class="clear">'.$this->l('Graph engine').': </label><div class="margin-form">';
|
||||
if (sizeof($arrayGraphEngines))
|
||||
{
|
||||
foreach ($arrayGraphEngines as $k => $value)
|
||||
echo '<div id="sgraphcontent_'.$k.'">'.$value[1].'</div><script language="javascript">getE(\'sgraphcontent_'.$k.'\').style.display = \'none\';</script>';
|
||||
echo '<div style="float: left"><select name="PS_STATS_RENDER">';
|
||||
foreach ($arrayGraphEngines as $k => $value)
|
||||
echo '<option value="'.$k.'"'.($k == $graphEngine ? ' selected="selected"' : '').' onclick="getE(\'render_graph_content\').innerHTML = getE(\'sgraphcontent_'.$k.'\').innerHTML;">'.$value[0].'</option>';
|
||||
echo '</select></div>
|
||||
<div id="render_graph_content" style="float:left;margin-left:20px;width:400px;">'.$arrayGraphEngines[$graphEngine][1].'</div>
|
||||
<div class="clear"></div>';
|
||||
}
|
||||
else
|
||||
echo $this->l('No graph engine module installed');
|
||||
echo '</div>';
|
||||
|
||||
#Grid Engines
|
||||
echo '<label class="clear">'.$this->l('Grid engine').': </label><div class="margin-form">';
|
||||
if (sizeof($arrayGridEngines))
|
||||
{
|
||||
foreach ($arrayGridEngines as $k => $value)
|
||||
echo '<div id="sgridcontent_'.$k.'">'.$value[1].' </div><script language="javascript">getE(\'sgridcontent_'.$k.'\').style.display = \'none\';</script>';
|
||||
echo '<div style="float: left"><select name="PS_STATS_GRID_RENDER">';
|
||||
foreach ($arrayGridEngines as $k => $value)
|
||||
echo '<option value="'.$k.'"'.($k == $gridEngine ? ' selected="selected"' : '').' onclick="getE(\'render_grid_content\').innerHTML = getE(\'sgridcontent_'.$k.'\').innerHTML;">'.$value[0].'</option>';
|
||||
echo '</select></div>
|
||||
<div id="render_grid_content" style="float:left;margin-left:20px;width:400px;">'.$arrayGridEngines[$gridEngine][1].'</div>
|
||||
<div class="clear"></div>';
|
||||
}
|
||||
else
|
||||
echo $this->l('No grid engine module installed');
|
||||
echo '</div>';
|
||||
|
||||
echo '<label class="clear">'.$this->l('Clean automatically').': </label>
|
||||
<div class="margin-form">
|
||||
<select id="PS_STATS_OLD_CONNECT_AUTO_CLEAN" name="PS_STATS_OLD_CONNECT_AUTO_CLEAN">';
|
||||
foreach ($autocleanPeriod as $k => $value)
|
||||
echo ' <option value="'.$k.'"'.($k == $autoclean ? ' selected="selected"' : '').'>'.$value.' </option>';
|
||||
echo ' </select>
|
||||
</div>';
|
||||
|
||||
#End Of Form
|
||||
echo '<input type="submit" value="'.$this->l(' Save ').'" name="submitSettings" class="button" />
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Statistics
|
||||
* @category stats
|
||||
*
|
||||
* @author Damien Metzger / Epitech
|
||||
* @copyright Epitech / PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.2
|
||||
*/
|
||||
|
||||
include_once(dirname(__FILE__).'/AdminStatsTab.php');
|
||||
|
||||
class AdminStatsModules extends AdminStatsTab
|
||||
{
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,245 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Statistics
|
||||
* @category stats
|
||||
*
|
||||
* @author Damien Metzger / Epitech
|
||||
* @copyright Epitech / PrestaShop
|
||||
* @license http://www.opensource.org/licenses/osl-3.0.php Open-source licence 3.0
|
||||
* @version 1.2
|
||||
*/
|
||||
|
||||
include_once(PS_ADMIN_DIR.'/tabs/AdminPreferences.php');
|
||||
|
||||
abstract class AdminStatsTab extends AdminPreferences
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->_fieldsSettings = array(
|
||||
'PS_STATS_RENDER' => array('title' => $this->l('Graph engine'), 'validation' => 'isGenericName'),
|
||||
'PS_STATS_GRID_RENDER' => array('title' => $this->l('Grid engine'), 'validation' => 'isGenericName')
|
||||
);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $cookie, $currentIndex;
|
||||
|
||||
if (Tools::isSubmit('submitDatePicker'))
|
||||
{
|
||||
if (!Validate::isDate($from = Tools::getValue('datepickerFrom')) OR !Validate::isDate($to = Tools::getValue('datepickerTo')))
|
||||
$this->_errors[] = Tools::displayError('date specified not valid');
|
||||
}
|
||||
if (Tools::isSubmit('submitDateDay'))
|
||||
{
|
||||
$from = date('Y-m-d');
|
||||
$to = date('Y-m-d');
|
||||
}
|
||||
if (Tools::isSubmit('submitDateDayPrev'))
|
||||
{
|
||||
$yesterday = time() - 60*60*24;
|
||||
$from = date('Y-m-d', $yesterday);
|
||||
$to = date('Y-m-d', $yesterday);
|
||||
}
|
||||
if (Tools::isSubmit('submitDateMonth'))
|
||||
{
|
||||
$from = date('Y-m-01');
|
||||
$to = date('Y-m-t');
|
||||
}
|
||||
if (Tools::isSubmit('submitDateMonthPrev'))
|
||||
{
|
||||
$m = (date('m') == 1 ? 12 : date('m') - 1);
|
||||
$y = ($m == 12 ? date('Y') - 1 : date('Y'));
|
||||
$from = $y.'-'.$m.'-01';
|
||||
$to = $y.'-'.$m.date('-t', mktime(12, 0, 0, $m, 15, $y));
|
||||
}
|
||||
if (Tools::isSubmit('submitDateYear'))
|
||||
{
|
||||
$from = date('Y-01-01');
|
||||
$to = date('Y-12-31');
|
||||
}
|
||||
if (Tools::isSubmit('submitDateYearPrev'))
|
||||
{
|
||||
$from = (date('Y') - 1).date('-01-01');
|
||||
$to = (date('Y') - 1).date('-12-31');
|
||||
}
|
||||
if (isset($from) AND isset($to) AND !sizeof($this->_errors))
|
||||
{
|
||||
$employee = new Employee($cookie->id_employee);
|
||||
$employee->stats_date_from = $from;
|
||||
$employee->stats_date_to = $to;
|
||||
$employee->update();
|
||||
Tools::redirectAdmin($_SERVER['REQUEST_URI']);
|
||||
}
|
||||
if (Tools::getValue('submitSettings'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
$currentIndex .= '&module='.Tools::getValue('module');
|
||||
$this->_postConfig($this->_fieldsSettings);
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit something here.');
|
||||
}
|
||||
if (sizeof($this->_errors))
|
||||
AdminTab::displayErrors();
|
||||
}
|
||||
|
||||
protected function displayEngines()
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
|
||||
$graphEngine = Configuration::get('PS_STATS_RENDER');
|
||||
$gridEngine = Configuration::get('PS_STATS_GRID_RENDER');
|
||||
$arrayGraphEngines = ModuleGraphEngine::getGraphEngines();
|
||||
$arrayGridEngines = ModuleGridEngine::getGridEngines();
|
||||
|
||||
echo '
|
||||
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
|
||||
<fieldset style="width: 200px;"><legend><img src="../img/admin/tab-preferences.gif" />'.$this->l('Settings', 'AdminStatsTab').'</legend>';
|
||||
echo '<p><strong>'.$this->l('Graph engine', 'AdminStatsTab').' </strong><br />';
|
||||
if (sizeof($arrayGraphEngines))
|
||||
{
|
||||
echo '<select name="PS_STATS_RENDER">';
|
||||
foreach ($arrayGraphEngines as $k => $value)
|
||||
echo '<option value="'.$k.'"'.($k == $graphEngine ? ' selected="selected"' : '').'>'.$value[0].'</option>';
|
||||
echo '</select><p>';
|
||||
}
|
||||
else
|
||||
echo $this->l('No graph engine module installed', 'AdminStatsTab');
|
||||
echo '<p><strong>'.$this->l('Grid engine', 'AdminStatsTab').' </strong><br />';
|
||||
if (sizeof($arrayGridEngines))
|
||||
{
|
||||
echo '<select name="PS_STATS_GRID_RENDER">';
|
||||
foreach ($arrayGridEngines as $k => $value)
|
||||
echo '<option value="'.$k.'"'.($k == $gridEngine ? ' selected="selected"' : '').'>'.$value[0].'</option>';
|
||||
echo '</select></p>';
|
||||
}
|
||||
else
|
||||
echo $this->l('No grid engine module installed', 'AdminStatsTab');
|
||||
echo '<p><input type="submit" value="'.$this->l(' Save ', 'AdminStatsTab').'" name="submitSettings" class="button" /></p>
|
||||
</fieldset>
|
||||
</form><div class="clear space"> </div>';
|
||||
}
|
||||
|
||||
protected function getDate()
|
||||
{
|
||||
global $cookie;
|
||||
$year = isset($cookie->stats_year) ? $cookie->stats_year : date('Y');
|
||||
$month = isset($cookie->stats_month) ? sprintf('%02d', $cookie->stats_month) : '%';
|
||||
$day = isset($cookie->stats_day) ? sprintf('%02d', $cookie->stats_day) : '%';
|
||||
return $year.'-'.$month.'-'.$day;
|
||||
}
|
||||
|
||||
public function displayCalendar()
|
||||
{
|
||||
echo '<div id="calendar">
|
||||
'.self::displayCalendarStatic(array(
|
||||
'Calendar' => $this->l('Calendar', 'AdminStatsTab'), 'Day' => $this->l('Day', 'AdminStatsTab'),
|
||||
'Month' => $this->l('Month', 'AdminStatsTab'), 'Year' => $this->l('Year', 'AdminStatsTab'),
|
||||
'From' => $this->l('From:', 'AdminStatsTab'), 'To' => $this->l('To:', 'AdminStatsTab'), 'Save' => $this->l('Save', 'AdminStatsTab')
|
||||
)).'
|
||||
<div class="clear space"> </div></div>';
|
||||
}
|
||||
|
||||
public static function displayCalendarStatic($translations)
|
||||
{
|
||||
global $cookie;
|
||||
$employee = new Employee($cookie->id_employee);
|
||||
|
||||
includeDatepicker(array('datepickerFrom', 'datepickerTo'));
|
||||
return '
|
||||
<fieldset style="width: 200px; font-size:13px;"><legend><img src="../img/admin/date.png" /> '.$translations['Calendar'].'</legend>
|
||||
<div>
|
||||
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
|
||||
<input type="submit" name="submitDateDay" class="button" value="'.$translations['Day'].'">
|
||||
<input type="submit" name="submitDateMonth" class="button" value="'.$translations['Month'].'">
|
||||
<input type="submit" name="submitDateYear" class="button" value="'.$translations['Year'].'"><br />
|
||||
<input type="submit" name="submitDateDayPrev" class="button" value="'.$translations['Day'].'-1">
|
||||
<input type="submit" name="submitDateMonthPrev" class="button" value="'.$translations['Month'].'-1">
|
||||
<input type="submit" name="submitDateYearPrev" class="button" value="'.$translations['Year'].'-1">
|
||||
<p>'.(isset($translations['From']) ? $translations['From'] : 'From:').' <input type="text" name="datepickerFrom" id="datepickerFrom" value="'.Tools::getValue('datepickerFrom', $employee->stats_date_from).'"></p>
|
||||
<p>'.(isset($translations['To']) ? $translations['To'] : 'To:').' <input type="text" name="datepickerTo" id="datepickerTo" value="'.Tools::getValue('datepickerTo', $employee->stats_date_to).'"></p>
|
||||
<input type="submit" name="submitDatePicker" class="button" value="'.(isset($translations['Save']) ? $translations['Save'] : ' Save ').'" />
|
||||
</form>
|
||||
</div>
|
||||
</fieldset>';
|
||||
}
|
||||
|
||||
public function displaySearch()
|
||||
{
|
||||
return;
|
||||
echo '
|
||||
<fieldset style="margin-top:20px; width: 200px;"><legend><img src="../img/admin/binoculars.png" /> '.$this->l('Search', 'AdminStatsTab').'</legend>
|
||||
<input type="text" /> <input type="button" class="button" value="'.$this->l('Go', 'AdminStatsTab').'" />
|
||||
</fieldset>';
|
||||
}
|
||||
|
||||
private function getModules($limit = false, $auto = true)
|
||||
{
|
||||
$function = $limit ? 'getRow' : 'ExecuteS';
|
||||
return Db::getInstance()->{$function}('
|
||||
SELECT h.`name` AS hook, m.`name`
|
||||
FROM `'._DB_PREFIX_.'module` m
|
||||
LEFT JOIN `'._DB_PREFIX_.'hook_module` hm ON hm.`id_module` = m.`id_module`
|
||||
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
|
||||
'.($auto ? 'WHERE h.`name` = \''.pSQL(Tools::getValue('tab')).'\'' : 'WHERE h.`name` LIKE \'AdminStats%\'').'
|
||||
AND m.`active` = 1
|
||||
ORDER BY hm.`position`');
|
||||
}
|
||||
|
||||
public function displayMenu($auto = true)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
$modules = $auto ? $this->getModules() : $this->getModules(false, false);
|
||||
|
||||
echo '<fieldset style="width: 200px"><legend><img src="../img/admin/navigation.png" /> '.$this->l('Navigation', 'AdminStatsTab').'</legend>';
|
||||
if (sizeof($modules))
|
||||
foreach ($modules AS $module)
|
||||
{
|
||||
$moduleInstance = Module::getInstanceByName($module['name']);
|
||||
if (!$moduleInstance)
|
||||
continue;
|
||||
echo '
|
||||
<h4><img src="../modules/'.$module['name'].'/logo.gif" /> <a href="index.php?tab='.$module['hook'].'&token='.Tools::getAdminToken($module['hook'].intval(Tab::getIdFromClassName($module['hook'])).intval($cookie->id_employee)).'&module='.$module['name'].'">'.$moduleInstance->displayName.'</a></h4>';
|
||||
}
|
||||
else
|
||||
echo $this->l('No module installed', 'AdminStatsTab');
|
||||
echo '</fieldset><div class="clear space"> </div>';
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
echo '<div style="float:left">';
|
||||
$this->displayCalendar();
|
||||
$this->displayEngines();
|
||||
$this->displayMenu();
|
||||
$this->displaySearch();
|
||||
echo '</div>
|
||||
<div style="float:left; margin-left:20px;">';
|
||||
|
||||
if (!($moduleName = Tools::getValue('module')))
|
||||
{
|
||||
$module = $this->getModules(true);
|
||||
if (isset($module['name']))
|
||||
$moduleName = $module['name'];
|
||||
else
|
||||
echo Tools::displayError('No module available');
|
||||
}
|
||||
if ($moduleName)
|
||||
{
|
||||
// Needed for the graphics display when this is the default module
|
||||
$_GET['module'] = $moduleName;
|
||||
$moduleInstance = Module::getInstanceByName($moduleName);
|
||||
if ($moduleInstance AND $moduleInstance->active)
|
||||
echo Module::hookExec(Tools::getValue('tab'), NULL, $moduleInstance->id);
|
||||
else
|
||||
echo $this->l('Module not found', 'AdminStatsTab');
|
||||
}
|
||||
echo '</div><div class="clear"></div>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Catalog tab for admin panel, AdminCatalog.php
|
||||
* Tab has been separated in 3 files : this one, AdminCategories.php and AdminProducts.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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');
|
||||
include(PS_ADMIN_DIR.'/tabs/AdminOrdersStates.php');
|
||||
include(PS_ADMIN_DIR.'/tabs/AdminReturnStates.php');
|
||||
|
||||
class AdminStatuses extends AdminTab
|
||||
{
|
||||
private $adminOrdersStates;
|
||||
private $adminReturnStates;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = array('order_state', 'order_return_state');
|
||||
$this->adminOrdersStates = new adminOrdersStates();
|
||||
$this->adminReturnStates = new adminReturnStates();
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function viewAccess($disable = false)
|
||||
{
|
||||
$result = parent::viewAccess($disable);
|
||||
$this->adminOrdersStates->tabAccess = $this->tabAccess;
|
||||
$this->adminReturnStates->tabAccess = $this->tabAccess;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
$this->adminOrdersStates->token = $this->token;
|
||||
$this->adminReturnStates->token = $this->token;
|
||||
|
||||
$this->adminOrdersStates->postProcess($this->token);
|
||||
$this->adminReturnStates->postProcess($this->token);
|
||||
}
|
||||
|
||||
public function displayErrors()
|
||||
{
|
||||
$this->adminOrdersStates->displayErrors($this->token);
|
||||
$this->adminReturnStates->displayErrors($this->token);
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if (!Tools::isSubmit('updateorder_return_state') AND !Tools::isSubmit('submitAddorder_return_state'))
|
||||
{
|
||||
echo '<h2>'.$this->l('Order states').'</h2>';
|
||||
$this->adminOrdersStates->display($this->token);
|
||||
}
|
||||
if (!Tools::isSubmit('updateorder_state') AND !Tools::isSubmit('submitAddupdateorder_state') AND !Tools::isSubmit('addorder_state'))
|
||||
{
|
||||
if (!Tools::isSubmit('updateorder_return_state') AND !Tools::isSubmit('submitAddorder_return_state'))
|
||||
echo '<div style="margin:10px"> </div>';
|
||||
echo '<h2>'.$this->l('Order return states').'</h2>';
|
||||
$this->adminReturnStates->display($this->token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Sub domains tab for admin panel, AdminSubDomains.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminSubDomains extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'subdomain';
|
||||
$this->className = 'SubDomain';
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_subdomain' => array('title' => $this->l('ID'), 'width' => 25),
|
||||
'name' => array('title' => $this->l('Subdomain'), 'width' => 200)
|
||||
);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function displayList()
|
||||
{
|
||||
echo '<fieldset>'.$this->l('Cookies are different on each subdomain of your Website. If you want to use the same cookie, please add here the subdomains used by your shop. The most common is "www".').'</fieldset>';
|
||||
return parent::displayList();
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" class="width2">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/admin/subdomain.gif" /> '.$this->l('Subdomains').'</legend>
|
||||
<label>'.$this->l('Subdomain:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="15" name="name" value="'.htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Additionnal subdomain').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
$result = Db::getInstance()->ExecuteS('
|
||||
SELECT `id_subdomain`
|
||||
FROM `'._DB_PREFIX_.'subdomain`
|
||||
');
|
||||
if (sizeof($result) === 1)
|
||||
foreach ($result AS $row)
|
||||
$this->_listSkipDelete = array($row['id_subdomain']);
|
||||
|
||||
return parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,202 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Suppliers tab for admin panel, AdminSuppliers.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminSuppliers extends AdminTab
|
||||
{
|
||||
protected $maxImageSize = 200000;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'supplier';
|
||||
$this->className = 'Supplier';
|
||||
$this->view = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
$this->_select = 'COUNT(p.`id_product`) AS products';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'product` p ON (a.`id_supplier` = p.`id_supplier`)';
|
||||
$this->_group = 'GROUP BY a.`id_supplier`';
|
||||
|
||||
$this->fieldImageSettings = array('name' => 'logo', 'dir' => 'su');
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_supplier' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 120),
|
||||
'logo' => array('title' => $this->l('Logo'), 'align' => 'center', 'image' => 'su', 'orderby' => false, 'search' => false),
|
||||
'products' => array('title' => $this->l('Number of products'), 'align' => 'right', 'filter_type' => 'int', 'tmpTableFilter' => true)
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function viewsupplier()
|
||||
{
|
||||
global $cookie;
|
||||
$supplier = $this->loadObject();
|
||||
echo '<h2>'.$supplier->name.'</h2>';
|
||||
|
||||
$products = $supplier->getProductsLite(intval($cookie->id_lang));
|
||||
echo '<h3>'.$this->l('Total products:').' '.sizeof($products).'</h3>';
|
||||
foreach ($products AS $product)
|
||||
{
|
||||
$product = new Product($product['id_product'], false, intval($cookie->id_lang));
|
||||
echo '<hr />';
|
||||
if (!$product->hasAttributes())
|
||||
{
|
||||
echo '
|
||||
<table border="0" cellpadding="0" cellspacing="0" class="table width3">
|
||||
<tr>
|
||||
<th><a href="index.php?tab=AdminCatalog&id_product='.$product->id.'&addproduct&token='.Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)).'" target="_blank">'.$product->name.'</a></th>
|
||||
'.(!empty($product->reference) ? '<th width="150">'.$this->l('Ref:').' '.$product->reference.'</th>' : '').'
|
||||
'.(!empty($product->ean13) ? '<th width="120">'.$this->l('EAN13:').' '.$product->ean13.'</th>' : '').'
|
||||
'.(Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="50">'.$this->l('Qty:').' '.$product->quantity.'</th>' : '').'
|
||||
</tr>
|
||||
</table>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '
|
||||
<h3><a href="index.php?tab=AdminCatalog&id_product='.$product->id.'&addproduct&token='.Tools::getAdminToken('AdminCatalog'.intval(Tab::getIdFromClassName('AdminCatalog')).intval($cookie->id_employee)).'" target="_blank">'.$product->name.'</a></h3>
|
||||
<table border="0" cellpadding="0" cellspacing="0" class="table" style="width: 600px;">
|
||||
<tr>
|
||||
<th>'.$this->l('Attribute name').'</th>
|
||||
<th width="80">'.$this->l('Reference').'</th>
|
||||
<th width="80">'.$this->l('EAN13').'</th>
|
||||
'.(Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="40">'.$this->l('Quantity').'</th>' : '').'
|
||||
</tr>';
|
||||
/* Build attributes combinaisons */
|
||||
$combinaisons = $product->getAttributeCombinaisons(intval($cookie->id_lang));
|
||||
foreach ($combinaisons AS $k => $combinaison)
|
||||
{
|
||||
$combArray[$combinaison['id_product_attribute']]['reference'] = $combinaison['reference'];
|
||||
$combArray[$combinaison['id_product_attribute']]['ean13'] = $combinaison['ean13'];
|
||||
$combArray[$combinaison['id_product_attribute']]['quantity'] = $combinaison['quantity'];
|
||||
$combArray[$combinaison['id_product_attribute']]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']);
|
||||
}
|
||||
$irow = 0;
|
||||
foreach ($combArray AS $id_product_attribute => $product_attribute)
|
||||
{
|
||||
$list = '';
|
||||
foreach ($product_attribute['attributes'] AS $attribute)
|
||||
$list .= $attribute[0].' - '.$attribute[1].', ';
|
||||
$list = rtrim($list, ', ');
|
||||
echo '
|
||||
<tr'.($irow++ % 2 ? ' class="alt_row"' : '').' >
|
||||
<td>'.stripslashes($list).'</td>
|
||||
<td>'.$product_attribute['reference'].'</td>
|
||||
'.(Configuration::get('PS_STOCK_MANAGEMENT') ? '<td>'.$product_attribute['ean13'].'</td>' : '').'
|
||||
<td class="right">'.$product_attribute['quantity'].'</td>
|
||||
</tr>';
|
||||
}
|
||||
unset($combArray);
|
||||
echo '</table>';
|
||||
echo '</td></tr></table>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex;
|
||||
parent::displayForm();
|
||||
|
||||
$supplier = $this->loadObject(true);
|
||||
|
||||
$langtags = 'description¤smeta_title¤smeta_keywords¤smeta_description';
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" enctype="multipart/form-data" class="width3">
|
||||
'.($supplier->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$supplier->id.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/admin/suppliers.gif" />'.$this->l('Suppliers').'</legend>
|
||||
<label>'.$this->l('Name:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="40" name="name" value="'.htmlentities(Tools::getValue('name', $supplier->name), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>
|
||||
<label>'.$this->l('Description:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="description_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="33" type="text" name="description_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($supplier, 'description', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
<p class="clear">'.$this->l('Will appear in supplier list').'</p>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $langtags, 'description');
|
||||
echo ' <div class="clear"></div>
|
||||
</div>
|
||||
<label>'.$this->l('Logo:').' </label>
|
||||
<div class="margin-form">';
|
||||
echo $this->displayImage($supplier->id, _PS_SUPP_IMG_DIR_.$supplier->id.'.jpg', 350);
|
||||
echo ' <br /><input type="file" name="logo" />
|
||||
<p>'.$this->l('Upload supplier logo from your computer').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Meta title:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="smeta_title_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input type="text" name="meta_title_'.$language['id_lang'].'" id="meta_title_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($supplier, 'meta_title', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
|
||||
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $langtags, 'smeta_title');
|
||||
echo ' <div class="clear"></div>
|
||||
</div>
|
||||
<label>'.$this->l('Meta description:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '<div id="smeta_description_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input type="text" name="meta_description_'.$language['id_lang'].'" id="meta_description_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($supplier, 'meta_description', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
|
||||
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $langtags, 'smeta_description');
|
||||
echo ' <div class="clear"></div>
|
||||
</div>
|
||||
<label>'.$this->l('Meta keywords:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="smeta_keywords_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input type="text" name="meta_keywords_'.$language['id_lang'].'" id="meta_keywords_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($supplier, 'meta_keywords', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
|
||||
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $langtags, 'smeta_keywords');
|
||||
echo ' <div class="clear"></div>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
/* Generate image with differents size */
|
||||
if (($id_supplier = intval(Tools::getValue('id_supplier'))) AND isset($_FILES) AND count($_FILES) AND file_exists(_PS_SUPP_IMG_DIR_.$id_supplier.'.jpg'))
|
||||
{
|
||||
$imagesTypes = ImageType::getImagesTypes('suppliers');
|
||||
foreach ($imagesTypes AS $k => $imageType)
|
||||
{
|
||||
$file = _PS_SUPP_IMG_DIR_.$id_supplier.'.jpg';
|
||||
imageResize($file, _PS_SUPP_IMG_DIR_.$id_supplier.'-'.stripslashes($imageType['name']).'.jpg', intval($imageType['width']), intval($imageType['height']));
|
||||
}
|
||||
}
|
||||
parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Tabs tab for admin panel, AdminTabs.php
|
||||
* @category admin
|
||||
*
|
||||
* @author PrestaShop <support@prestashop.com>
|
||||
* @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 AdminTabs extends AdminTab
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
$this->table = 'tab';
|
||||
$this->className = 'Tab';
|
||||
$this->lang = true;
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
$this->_select = '(SELECT stl.`name` FROM `'._DB_PREFIX_.'tab_lang` stl WHERE stl.`id_tab` = a.`id_parent` AND stl.`id_lang` = '.intval($cookie->id_lang).' LIMIT 1) AS parent';
|
||||
|
||||
$this->fieldImageSettings = array('name' => 'icon', 'dir' => 't');
|
||||
$this->imageType = 'gif';
|
||||
|
||||
$tabs = array(0 => $this->l('Home'));
|
||||
foreach (Tab::getTabs(intval($cookie->id_lang), 0) AS $tab)
|
||||
$tabs[$tab['id_tab']] = $tab['name'];
|
||||
$this->fieldsDisplay = array(
|
||||
'id_tab' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 200),
|
||||
'logo' => array('title' => $this->l('Icon'), 'align' => 'center', 'image' => 't', 'image_id' => 'class_name', 'orderby' => false, 'search' => false),
|
||||
'parent' => array('title' => $this->l('Parent'), 'width' => 200, 'type' => 'select', 'select' => $tabs, 'filter_key' => 'a!id_parent'),
|
||||
'module' => array('title' => $this->l('Module')));
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (($id_tab = intval(Tools::getValue('id_tab'))) AND ($direction = Tools::getValue('move')) AND Validate::isLoadedObject($tab = new Tab($id_tab)))
|
||||
{
|
||||
global $currentIndex;
|
||||
if ($tab->move($direction))
|
||||
Tools::redirectAdmin($currentIndex.'&token='.$this->token);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Tools::getValue('position'))
|
||||
$_POST['position'] = Tab::getNbTabs(Tools::getValue('id_parent'));
|
||||
parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
private function _posTabs($name, $arrayTabs)
|
||||
{
|
||||
global $currentIndex;
|
||||
|
||||
if (sizeof($arrayTabs) > 1)
|
||||
{
|
||||
echo '
|
||||
<table class="table" cellspacing="0" cellpadding="0" style="margin-bottom: 5px;">
|
||||
<tr>';
|
||||
for ($i = 0; $i < sizeof($arrayTabs); $i++)
|
||||
{
|
||||
$tab = $arrayTabs[$i];
|
||||
echo '<th style="text-align:center;">'.stripslashes($tab['name']).'<br />';
|
||||
if ($i)
|
||||
echo '<a href="'.$currentIndex.'&id_tab='.$tab['id_tab'].'&move=l&token='.$this->token.'"><img src="../img/admin/previous.gif" /></a> ';
|
||||
if ($i < sizeof($arrayTabs) - 1)
|
||||
echo '<a href="'.$currentIndex.'&id_tab='.$tab['id_tab'].'&move=r&token='.$this->token.'"><img src="../img/admin/next.gif" /></a></th>';
|
||||
}
|
||||
echo '
|
||||
</tr>
|
||||
</table>';
|
||||
}
|
||||
}
|
||||
|
||||
public function displayList()
|
||||
{
|
||||
global $cookie, $currentIndex;
|
||||
|
||||
parent::displayList();
|
||||
|
||||
$tabs = Tab::getTabs(intval($cookie->id_lang), 0);
|
||||
echo '<br /><h2>'.$this->l('Positions').'</h2>
|
||||
<h3>'.$this->l('Level').' 1</h3>';
|
||||
$this->_posTabs($this->l('Main'), $tabs);
|
||||
echo '<h3>'.$this->l('Level').' 2</h3>';
|
||||
foreach ($tabs AS $t)
|
||||
$this->_posTabs(stripslashes($t['name']), Tab::getTabs(intval($cookie->id_lang), $t['id_tab']));
|
||||
}
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
global $currentIndex, $cookie;
|
||||
parent::displayForm();
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
echo '
|
||||
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" enctype="multipart/form-data" class="width2">
|
||||
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
|
||||
'.($obj->position ? '<input type="hidden" name="position" value="'.$obj->position.'" />' : '').'
|
||||
<fieldset><legend><img src="../img/admin/tab.gif" />'.$this->l('Tabs').'</legend>
|
||||
<label>'.$this->l('Name:').' </label>
|
||||
<div class="margin-form">';
|
||||
foreach ($this->_languages as $language)
|
||||
echo '
|
||||
<div id="name_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
||||
<input size="33" type="text" name="name_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
|
||||
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>';
|
||||
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name');
|
||||
echo '
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
<label>'.$this->l('Class:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" name="class_name" value="'.htmlentities($this->getFieldValue($obj, 'class_name'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
<label>'.$this->l('Module:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" name="module" value="'.htmlentities($this->getFieldValue($obj, 'module'), ENT_COMPAT, 'UTF-8').'" />
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
<label>'.$this->l('Icon:').'</label>
|
||||
<div class="margin-form">
|
||||
'.($obj->id ? '<img src="../img/t/'.$obj->class_name.'.gif" /> /img/t/'.$obj->class_name.'.gif' : '').'
|
||||
<p><input type="file" name="icon" /></p>
|
||||
<p>'.$this->l('Upload logo from your computer').' (.gif, .jpg, .jpeg '.$this->l('or').' .png)</p>
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
<label>'.$this->l('Parent:').'</label>
|
||||
<div class="margin-form">
|
||||
<select name="id_parent">
|
||||
<option value="-1" '.(($this->getFieldValue($obj, 'id_parent') == -1) ? 'selected="selected"' : '').'>'.$this->l('None').'</option>
|
||||
<option value="0" '.(($this->getFieldValue($obj, 'id_parent') == 0) ? 'selected="selected"' : '').'>'.$this->l('Home').'</option>';
|
||||
foreach (Tab::getTabs(intval($cookie->id_lang), 0) AS $tab)
|
||||
echo ' <option value="'.$tab['id_tab'].'" '.($tab['id_tab'] == $this->getFieldValue($obj, 'id_parent') ? 'selected="selected"' : '').'>'.$tab['name'].'</option>';
|
||||
echo ' </select>
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
public function afterImageUpload()
|
||||
{
|
||||
$obj = $this->loadObject(true);
|
||||
@rename(_PS_IMG_DIR_.'t/'.$obj->id.'.gif', _PS_IMG_DIR_.'t/'.$obj->class_name.'.gif');
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue