git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@7522 b9a71923-0436-4b27-9f14-aed3839534dd

This commit is contained in:
rGaillard
2011-07-06 10:10:43 +00:00
parent 9ff675b1e2
commit 69f2f09dc5
4695 changed files with 0 additions and 339293 deletions
-2
View File
@@ -1,2 +0,0 @@
Order deny,allow
Deny from all
-138
View File
@@ -1,138 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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 = (int)(Tools::getValue('id_tab')) AND $id_profile = (int)(Tools::getValue('id_profile')) AND $this->tabAccess['edit'] == 1)
{
if ($id_tab == -1 AND $action == 'all' AND (int)(Tools::getValue('perm')) == 0)
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'access` SET `view` = '.(int)(Tools::getValue('perm')).', `add` = '.(int)(Tools::getValue('perm')).', `edit` = '.(int)(Tools::getValue('perm')).', `delete` = '.(int)(Tools::getValue('perm')).' WHERE `id_profile` = '.(int)($id_profile).' AND `id_tab` != 31');
elseif ($id_tab == -1 AND $action == 'all')
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'access` SET `view` = '.(int)(Tools::getValue('perm')).', `add` = '.(int)(Tools::getValue('perm')).', `edit` = '.(int)(Tools::getValue('perm')).', `delete` = '.(int)(Tools::getValue('perm')).' WHERE `id_profile` = '.(int)($id_profile));
elseif ($id_tab == -1)
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'access` SET `'.pSQL($action).'` = '.(int)(Tools::getValue('perm')).' WHERE `id_profile` = '.(int)($id_profile));
elseif ($action == 'all')
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'access` SET `view` = '.(int)(Tools::getValue('perm')).', `add` = '.(int)(Tools::getValue('perm')).', `edit` = '.(int)(Tools::getValue('perm')).', `delete` = '.(int)(Tools::getValue('perm')).' WHERE `id_tab` = '.(int)($id_tab).' AND `id_profile` = '.(int)($id_profile));
else
Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'access` SET `'.pSQL($action).'` = '.(int)(Tools::getValue('perm')).' WHERE `id_tab` = '.(int)($id_tab).' AND `id_profile` = '.(int)($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'])) ? (int)($_GET['profile']) : 1;
}
public function displayForm($isMainTab = true)
{
global $cookie, $currentIndex;
parent::displayForm();
$currentProfile = (int)($this->getCurrentProfileId());
$tabs = Tab::getTabs($cookie->id_lang);
$profiles = Profile::getProfiles((int)($cookie->id_lang));
$accesses = Profile::getProfileAccesses((int)($currentProfile));
echo '
<script type="text/javascript">
setLang(Array(\''.$this->l('Profile updated').'\', \''.$this->l('Request failed!').'\', \''.$this->l('Update in progress. Please wait.').'\', \''.$this->l('Server connection failed!').'\'));
</script>
<div id="ajax_confirmation"></div>
<table class="table" cellspacing="0">
<tr>
<th '.($currentProfile == (int)(_PS_ADMIN_PROFILE_) ? 'colspan="6"' : '').'>
<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="'.(int)($profile['id_profile']).'" '.((int)($profile['id_profile']) == $currentProfile ? 'selected="selected"' : '').'>'.$profile['name'].'</option>';
$tabsize = sizeof($tabs);
foreach ($tabs AS $tab)
if ($tab['id_tab'] > $tabsize)
$tabsize = $tab['id_tab'];
echo '
</select>
</th>';
if ($currentProfile != (int)(_PS_ADMIN_PROFILE_))
echo '
<th class="center">'.$this->l('View').'<br /><input type="checkbox" name="1" id="viewall" onclick="ajax_power(this, \'view\', -1, '.$currentProfile.', \''.$this->token.'\', \''.$tabsize.'\', \''.sizeof($tabs).'\')" /></th>
<th class="center">'.$this->l('Add').'<br /><input type="checkbox" name="1" id="addall" onclick="ajax_power(this, \'add\', -1, '.$currentProfile.', \''.$this->token.'\', \''.$tabsize.'\', \''.sizeof($tabs).'\')" /></th>
<th class="center">'.$this->l('Edit').'<br /><input type="checkbox" name="1" id="editall" onclick="ajax_power(this, \'edit\', -1, '.$currentProfile.', \''.$this->token.'\', \''.$tabsize.'\', \''.sizeof($tabs).'\')" /></th>
<th class="center">'.$this->l('Delete').'<br /><input type="checkbox" name="1" id="deleteall" onclick="ajax_power(this, \'delete\', -1, '.$currentProfile.', \''.$this->token.'\', \''.$tabsize.'\', \''.sizeof($tabs).'\')" /></th>
<th class="center">'.$this->l('All').'<br /><input type="checkbox" name="1" id="allall" onclick="ajax_power(this, \'all\', -1, '.$currentProfile.', \''.$this->token.'\', \''.$tabsize.'\', \''.sizeof($tabs).'\')" /></th>
</tr>';
if (!sizeof($tabs))
echo '<tr><td colspan="5">'.$this->l('No tab').'</td></tr>';
elseif ($currentProfile == (int)(_PS_ADMIN_PROFILE_))
echo '<tr><td colspan="5">'.$this->l('Administrator permissions can\'t be modified.').'</td></tr>';
else
foreach ($tabs AS $tab)
if (!$tab['id_parent'] OR (int)($tab['id_parent']) == -1)
{
$this->printTabAccess((int)($currentProfile), $tab, $accesses[$tab['id_tab']], false, $tabsize, sizeof($tabs));
foreach ($tabs AS $child)
if ($child['id_parent'] === $tab['id_tab'])
$this->printTabAccess($currentProfile, $child, $accesses[$child['id_tab']], true, $tabsize, sizeof($tabs));
}
echo '</table>';
}
private function printTabAccess($currentProfile, $tab, $access, $is_child, $tabsize, $tabnumber)
{
$result_accesses = 0;
$perms = array('view', 'add', 'edit', 'delete');
echo '<tr><td'.($is_child ? '' : ' class="bold"').'>'.($is_child ? ' &raquo; ' : '').$tab['name'].'</td>';
foreach ($perms as $perm)
{
if($this->tabAccess['edit'] == 1)
echo '<td class="center"><input type="checkbox" name="1" id=\''.$perm.(int)($access['id_tab']).'\' class=\''.$perm.' '.(int)($access['id_tab']).'\' onclick="ajax_power(this, \''.$perm.'\', '.(int)($access['id_tab']).', '.(int)($access['id_profile']).', \''.$this->token.'\', \''.$tabsize.'\', \''.$tabnumber.'\')" '.((int)($access[$perm]) == 1 ? 'checked="checked"' : '').'/></td>';
else
echo '<td class="center"><input type="checkbox" name="1" disabled="disabled" '.((int)($access[$perm]) == 1 ? 'checked="checked"' : '').' /></td>';
$result_accesses += $access[$perm];
}
echo '<td class="center"><input type="checkbox" name="1" id=\'all'.(int)($access['id_tab']).'\' class=\'all '.(int)($access['id_tab']).'\' onclick="ajax_power(this, \'all\', '.(int)($access['id_tab']).', '.(int)($access['id_profile']).', \''.$this->token.'\', \''.$tabsize.'\', \''.$tabnumber.'\')" '.($result_accesses == 4 ? 'checked="checked"' : '').'/></td></tr>';
}
}
-38
View File
@@ -1,38 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminAddonsCatalog extends AdminTab
{
public function display()
{
$parentDomain = Tools::getHttpHost(true).substr($_SERVER['REQUEST_URI'], 0, -1 * strlen(basename($_SERVER['REQUEST_URI'])));
echo '<iframe frameborder="no" style="margin:0px;padding:0px;width:100%;height:920px" src="http://addons.prestashop.com/iframe/search.php?parentUrl='.$parentDomain.'"></iframe>
<div class="clear">&nbsp;</div>';
}
}
-38
View File
@@ -1,38 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminAddonsMyAccount extends AdminTab
{
public function display()
{
$parentDomain = Tools::getHttpHost(true).substr($_SERVER['REQUEST_URI'], 0, -1 * strlen(basename($_SERVER['REQUEST_URI'])));
echo '<iframe frameborder="no" style="margin:0px;padding:0px;width:100%;height:920px" src="http://addons.prestashop.com/iframe/myaccount.php?parentUrl='.$parentDomain.'"></iframe>
<div class="clear">&nbsp;</div>';
}
}
-504
View File
@@ -1,504 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');
if(Configuration::get('VATNUMBER_MANAGEMENT') AND file_exists(_PS_MODULE_DIR_.'vatnumber/vatnumber.php'))
include_once(_PS_MODULE_DIR_.'vatnumber/vatnumber.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->requiredDatabase = 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` = '.(int)($cookie->id_lang).')';
$countries = Country::getCountries((int)($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('Postcode/ 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' => '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((int)($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');
if (Country::isNeedDniByCountryId(Tools::getValue('id_country')) AND !Tools::getValue('dni'))
$this->_errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
}
// Check manufacturer selected
if ($this->addressType == 'manufacturer')
{
$manufacturer = new Manufacturer((int)(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 = (int)(Tools::getValue('id_state'));
if ($id_country = Tools::getValue('id_country') AND $country = new Country((int)($id_country)) AND !(int)($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 ((int)($country->contains_states) AND !$id_state)
$this->_errors[] = Tools::displayError('An address located in a country containing states must have a state selected.');
/* Check zip code */
if ($country->need_zip_code)
{
$zip_code_format = $country->zip_code_format;
if (($postcode = Tools::getValue('postcode')) AND $zip_code_format)
{
$zip_regexp = '/^'.$zip_code_format.'$/ui';
$zip_regexp = str_replace(' ', '( |)', $zip_regexp);
$zip_regexp = str_replace('-', '(-|)', $zip_regexp);
$zip_regexp = str_replace('N', '[0-9]', $zip_regexp);
$zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp);
$zip_regexp = str_replace('C', $country->iso_code, $zip_regexp);
if (!preg_match($zip_regexp, $postcode))
$this->_errors[] = Tools::displayError('Your zip/postal code is incorrect.').'<br />'.Tools::displayError('Must be typed as follows:').' '.str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $zip_code_format)));
}
elseif ($zip_code_format)
$this->_errors[] = Tools::displayError('Postcode required.');
elseif ($postcode AND !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode))
$this->_errors[] = Tools::displayError('Your zip/postal code is incorrect.');
}
/* 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 ((int)(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 = ((int)(Tools::getValue('address_type')) == 2 ? 'invoice' : ((int)(Tools::getValue('address_type')) == 1 ? 'delivery' : ''));
if (isset($_POST['submitAdd'.$this->table]) AND ($id_order = (int)(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 = (int)(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 = (int)($_POST['submitFilter'.$this->table] - 1) * $limit;
/* Cache */
$this->_lang = (int)($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` = '.(int)($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 = (int)($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` = '.(int)($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 '.(int)($start).','.(int)($limit));
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
echo '
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post">
'.((int)($obj->id) ? '<input type="hidden" name="id_'.$this->table.'" value="'.(int)($obj->id).'" />' : '').'
'.(($id_order = (int)(Tools::getValue('id_order'))) ? '<input type="hidden" name="id_order" value="'.(int)($id_order).'" />' : '').'
'.(($address_type = (int)(Tools::getValue('address_type'))) ? '<input type="hidden" name="address_type" value="'.(int)($address_type).'" />' : '').'
'.(Tools::getValue('realedit') ? '<input type="hidden" name="realedit" value="1" />' : '').'
<fieldset>
<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').'&nbsp</option>';
foreach ($manufacturers as $manufacturer)
echo '<option value="'.(int)($manufacturer['id_manufacturer']).'"'.($this->getFieldValue($obj, 'id_manufacturer') == $manufacturer['id_manufacturer'] ? ' selected="selected"' : '').'>'.$manufacturer['name'].'&nbsp</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'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($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.'" />
<input type="hidden" name="email" value="'.$customer->email.'" />';
}
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 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('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">&nbsp;</span></span>
</div>';
break;
}
$addresses_fields = $this->processAddressFormat();
$addresses_fields = $addresses_fields["dlv_all_fields"]; // we use delivery address
foreach($addresses_fields as $addr_field_item)
{
if ($addr_field_item == 'company')
{
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">&nbsp;</span></span>
</div>';
if ((Configuration::get('VATNUMBER_MANAGEMENT') AND file_exists(_PS_MODULE_DIR_.'vatnumber/vatnumber.php')) && VatNumber::isApplicable(Configuration::get('PS_COUNTRY_DEFAULT')))
echo '<div id="vat_area" style="display: visible">';
else if(Configuration::get('VATNUMBER_MANAGEMENT'))
echo '<div id="vat_area" style="display: hidden">';
else
echo'<div style="display: none;">';
echo '<label>'.$this->l('VAT number').'</label>
<div class="margin-form">
<input type="text" size="33" name="vat_number" value="'.htmlentities($this->getFieldValue($obj, 'vat_number'), ENT_COMPAT, 'UTF-8').'" />
</div>
</div>';
}
}
elseif ($addr_field_item == 'lastname')
{
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!<>,;?=+()@#"{}_$%:<span class="hint-pointer">&nbsp;</span></span>
</div>';
}
elseif ($addr_field_item == 'firstname')
{
echo '
<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!<>,;?=+()@#"{}_$%:<span class="hint-pointer">&nbsp;</span></span>
</div>';
}
elseif ($addr_field_item == 'address1')
{
echo '
<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>';
}
elseif ($addr_field_item == 'address2')
{
echo '
<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>';
}
elseif ($addr_field_item == 'postcode')
{
echo '
<label>'.$this->l('Postcode/ Zip Code').'</label>
<div class="margin-form">
<input type="text" size="33" name="postcode" value="'.htmlentities($this->getFieldValue($obj, 'postcode'), ENT_COMPAT, 'UTF-8').'" />
</div>';
}
elseif ($addr_field_item == 'city')
{
echo '
<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>';
}
elseif ($addr_field_item == 'country')
{
echo '
<label>'.$this->l('Country').'</label>
<div class="margin-form">
<select name="id_country" id="id_country" />';
$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>';
echo '
<div id="contains_states" '.(!Country::containsStates((int)$selectedCountry) ? 'style="display:none;"' : '').'>
<label>'.$this->l('State').'</label>
<div class="margin-form">
<select name="id_state" id="id_state">
</select>
</div>
</div>';
$id_country_ajax = (int)$this->getFieldValue($obj, 'id_country');
echo '
<script type="text/javascript">
$(document).ready(function(){
ajaxStates ();
$(\'#id_country\').change(function() {
ajaxStates ();
});
function ajaxStates ()
{
$.ajax({
url: "ajax.php",
cache: false,
data: "ajaxStates=1&id_country="+$(\'#id_country\').val()+"&id_state="+$(\'#id_state\').val(),
success: function(html)
{
if (html == \'false\')
{
$("#contains_states").fadeOut();
$(\'#id_state option[value=0]\').attr("selected", "selected");
}
else
{
$("#id_state").html(html);
$("#contains_states").fadeIn();
$(\'#id_state option[value='.(int)$obj->id_state.']\').attr("selected", "selected");
}
}
}); ';
if (file_exists(_MODULE_DIR_.'vatnumber/ajax.php'))
echo ' $.ajax({
type: "GET",
url: "'._MODULE_DIR_.'vatnumber/ajax.php?id_country="+$(\'#id_country\').val(),
success: function(isApplicable)
{
if(isApplicable == 1)
$(\'#vat_area\').show();
else
$(\'#vat_area\').hide();
}
});';
echo ' }; }); </script>';
}
} // End foreach
echo '
<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>';
echo '
<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>';
echo '
<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">&nbsp;</span></span>
</div>';
echo '
<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>';
echo '
</form>';
}
protected function processAddressFormat()
{
$tmp_addr = new Address((int)Tools::getValue("id_address"));
$selectedCountry = (!is_null($tmp_addr)) ? $tmp_addr->id_country : (int)(Configuration::get('PS_COUNTRY_DEFAULT'));
$inv_adr_fields = AddressFormat::getOrderedAddressFields($selectedCountry);
$dlv_adr_fields = AddressFormat::getOrderedAddressFields($selectedCountry);
$inv_all_fields = array();
$dlv_all_fields = array();
$out = array();
foreach (array('inv','dlv') as $adr_type)
{
foreach (${$adr_type.'_adr_fields'} as $fields_line)
foreach(explode(' ',$fields_line) as $field_item)
${$adr_type.'_all_fields'}[] = trim($field_item);
$out[$adr_type.'_adr_fields'] = ${$adr_type.'_adr_fields'};
$out[$adr_type.'_all_fields'] = ${$adr_type.'_all_fields'};
}
return $out;
}
}
-106
View File
@@ -1,106 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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();
if (!($obj = $this->loadObject(true)))
return;
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/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>';
}
}
-36
View File
@@ -1,36 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(dirname(__FILE__).'/AdminThemes.php');
class AdminAppearance extends AdminThemes // extends AdminThemes only for retro-compatibility
{
public function display()
{
Tools::redirectAdmin('index.php?tab=AdminThemes&token='.Tools::getAdminTokenLite('AdminThemes'));
}
}
-134
View File
@@ -1,134 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');
class AdminAttachments extends AdminTab
{
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 = (int)(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'] > (Configuration::get('PS_ATTACHMENT_MAXIMUM_SIZE') * 1024 * 1024))
$this->_errors[] = $this->l('File too large, maximum size allowed:').' '.(Configuration::get('PS_ATTACHMENT_MAXIMUM_SIZE') * 1024).' '.$this->l('kb').'. '.$this->l('File size you\'re trying to upload is:').number_format(($_FILES['attachment_file']['size']/1024), 2, '.', '').$this->l('kb');
else
{
do $uniqid = sha1(microtime()); while (file_exists(_PS_DOWNLOAD_DIR_.$uniqid));
if (!copy($_FILES['file']['tmp_name'], _PS_DOWNLOAD_DIR_.$uniqid))
$this->_errors[] = $this->l('File copy failed');
$_POST['file_name'] = $_FILES['file']['name'];
@unlink($_FILES['file']['tmp_name']);
$_POST['file'] = $uniqid;
$_POST['mime'] = $_FILES['file']['type'];
}
}
else if (array_key_exists('attachment_file', $_FILES) && (int)$_FILES['attachment_file']['error'] === 1)
{
$max_upload = (int)(ini_get('upload_max_filesize'));
$max_post = (int)(ini_get('post_max_size'));
$upload_mb = min($max_upload, $max_post);
$this->_errors[] = $this->l('the File').' <b>'.$_FILES['attachment_file']['name'].'</b> '.$this->l('exceeds the size allowed by the server. This limit is set to').' <b>'.$upload_mb.$this->l('Mb').'</b>';
}
else if (!empty($_FILES['file']['tmp_name']))
$this->_errors[] = $this->l('No file or your file isn\'t uploadable, check your server configuration about the upload maximum size.');
}
$this->validateRules();
}
return parent::postProcess();
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
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><legend><img src="../img/t/AdminAttachments.gif" />'.$this->l('Attachment').'</legend>
<label>'.$this->l('Filename:').' </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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'cname¤cdescription', 'cname');
echo ' </div>
<div class="clear">&nbsp;</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'cname¤cdescription', 'cdescription');
echo ' </div>
<div class="clear">&nbsp;</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">&nbsp;</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>';
}
}
-284
View File
@@ -1,284 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@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 += (float)($_POST['price_impact'][(int)($attr)]);
$weight += (float)($_POST['weight_impact'][(int)($attr)]);
}
if ($this->product->id)
{
return (array(
'id_product' => (int)($this->product->id),
'price' => (float)($price),
'weight' => (float)($weight),
'ecotax' => 0,
'quantity' => (int)($_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((int)(Tools::getValue('id_product')));
if (isset($_POST['generate']))
{
if (!is_array(Tools::getValue('options')))
$this->_errors[] = Tools::displayError('Please 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));
$this->product->deleteProductAttributes();
$res = $this->product->addProductAttributeMultiple($values);
$this->product->addAttributeCombinationMultiple($res, $this->combinations);
$this->product->updateQuantityProductWithAttributeQuantity();
}
else
$this->_errors[] = Tools::displayError('Unable to initialize parameters, combination is missing or object cannot be loaded.');
}
}
elseif (isset($_POST['back']))
Tools::redirectAdmin($currentIndex.'&id_product='.(int)(Tools::getValue('id_product')).'&id_category='.(int)(Tools::getValue('id_category')).'&addproduct'.'&tabs=3&token='.Tools::getValue('token'));
parent::postProcess();
}
static private function displayAndReturnAttributeJs()
{
global $cookie;
$attributes = Attribute::getAttributes((int)($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; margin-bottom: 10px;">';
foreach ($attributesGroups AS $k => $attributeGroup)
{
$idGroup = (int)$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="'.htmlspecialchars($v, ENT_QUOTES).'" title="'.htmlspecialchars($v, ENT_QUOTES).'"">'.$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[] = '('.(int)($id_product).', '.(int)($attribute).', '.(float)($_POST['price_impact'][(int)($attribute)]).', '.(float)($_POST['weight_impact'][(int)($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` = '.(int)($id_product));
if (!$result)
return array();
foreach ($result AS $impact)
{
$tab[$impact['id_attribute']]['price'] = (float)($impact['price']);
$tab[$impact['id_attribute']]['weight'] = (float)($impact['weight']);
}
return $tab;
}
private function displayGroupeTable($attributeJs, $attributesGroups)
{
global $cookie;
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$combinationsGroups = $this->product->getAttributesGroups((int)($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((int)($cookie->id_lang));
$this->product = new Product((int)(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_product='.(int)(Tools::getValue('id_product')).'&id_category='.(int)(Tools::getValue('id_category')).'&attributegenerator&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 product:').' <b>'.$this->product->name[$cookie->id_lang].'</b>
<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>
<p style="text-align: center;">
<input class="button" type="button" style="margin: 0 0 10px 20px;" value="'.$this->l('Add').'" class="button" onclick="add_attr_multiple();" />
<input class="button" type="button" style="margin: 0 0 10px 20px;" value="'.$this->l('Delete').'" class="button" onclick="del_attr_multiple();" /><br />
<input type="submit" class="button" name="back" value="'.$this->l('Back to product').'" />
</p>
</div>
</div>
<br />
</fieldset>
</form>';
}
}
-152
View File
@@ -1,152 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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();
if (!($obj = $this->loadObject(true)))
return;
$color = ($obj->color ? $obj->color : 0);
$attributes_groups = AttributeGroup::getAttributesGroups($this->_defaultFormLanguage);
$strAttributesGroups = '';
echo '
<script type="text/javascript">
var attributesGroups = {';
foreach ($attributes_groups AS $attribute_group)
$strAttributesGroups .= '"'.$attribute_group['id_attribute_group'].'" : '.$attribute_group['is_color_group'].',';
echo $strAttributesGroups.'};
</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><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', (int)($language['id_lang']))).'" /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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>
<script type="text/javascript" src="../js/jquery/jquery-colorpicker.js"></script>
<div id="colorAttributeProperties" style="'.((Validate::isLoadedObject($obj) AND $obj->isColorAttribute()) ? 'display: block;' : 'display: none;').'">
<label>'.$this->l('Color').'</label>
<div class="margin-form">
<input width="20px" type="color" data-hex="true" class="color mColorPickerInput" 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>
<script>
showAttributeColorGroup(\'id_attribute_group\', \'colorAttributeProperties\');
</script>';
}
/**
* 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();
}
}
-226
View File
@@ -1,226 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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/arrow2.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 = (int)($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="$(\'#attributes_'.$id.'\').slideToggle();">'.$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((int)($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>&nbsp;
<a href="'.$currentIndex.'&id_attribute='.$attribute['id_attribute'].'&deleteattribute&token='.$this->token.'"
onclick="return confirm(\''.$this->l('Delete attribute', __CLASS__, true, false).' : '.$attribute['name'].'?\');">
<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>&nbsp;
<a href="'.$currentIndex.'&id_'.$this->table.'='.$id.'&delete'.$this->table.'&token='.$this->token.'" onclick="return confirm(\''.$this->l('Delete item', __CLASS__, true, false).' : '.$tr['name'].'?\');">
<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();
if (!($obj = $this->loadObject(true)))
return;
echo '
<form action="'.$currentIndex.'&token='.$this->token.'" method="post">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
<fieldset><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', (int)($language['id_lang']))).'" /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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', (int)($language['id_lang']))).'" /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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>';
}
}
-261
View File
@@ -1,261 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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->requiredDatabase = false;
$this->fieldsDisplay = array (
'date' => array('title' => $this->l('Date'), 'type' => 'datetime', 'width' => 120, 'align' => 'right'),
'age' => array('title' => $this->l('Age')),
'filename' => array('title' => $this->l('File name'), '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
* "Backups" Directory in admin directory must be writeable (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/'))
{
if (!($object = $this->loadObject()))
return;
if ($object->add())
{
echo '<div class="conf confirm"><img src="../img/admin/ok.gif" />&nbsp;'.$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('"Backups" Directory in admin directory must be writeable (CHMOD 755 / 777)');
$this->displayErrors();
}
/**
* Displays the page which allows the backup to be downloaded
*/
public function viewbackup()
{
global $currentIndex;
if (!($object = $this->loadObject()))
return;
if ($object->id)
{
$url = $object->getBackupURL();
echo '<div class="conf confirm"><img src="../img/admin/ok.gif" />&nbsp;'.$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('"Backups" Directory in admin directory must be writeable (CHMOD 755 / 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 = (int)(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 = (int)($_POST['submitFilter'.$this->table] - 1) * $limit;
$this->_lang = (int)($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 = (int)($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]);
}
}
-352
View File
@@ -1,352 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');
class AdminCMS extends AdminTab
{
private $_category;
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),
'position' => array('title' => $this->l('Position'), 'width' => 40,'filter_key' => 'position', 'align' => 'center', 'position' => 'position'),
'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false)
);
$this->_category = AdminCMSContent::getCurrentCMSCategory();
$this->_join = '
LEFT JOIN `'._DB_PREFIX_.'cms_category` c ON (c.`id_cms_category` = a.`id_cms_category`)';
$this->_select = 'a.position ';
$this->_filter = 'AND c.id_cms_category = '.(int)($this->_category->id);
parent::__construct();
}
private function _displayDraftWarning($active)
{
return
'<div class="warn draft" style="'.($active ? 'display:none' : '').'">
<p>
<span style="float: left">
<img src="../img/admin/warn2.png" />
'.$this->l('Your CMS page will be saved as a draft').'
</span>
<input type="button" class="button" style="float: right;" value="'.$this->l('Save and preview').'" onclick="submitAddcmsAndPreview();">
<input type="hidden" name="previewSubmitAddcmsAndPreview" id="previewSubmitAddcmsAndPreview" />
<br class="clear" />
</p>
</div>';
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
$obj = $this->loadObject(true);
$iso = Language::getIsoById((int)($cookie->id_lang));
$divLangName = 'meta_title¤meta_description¤meta_keywords¤ccontent¤link_rewrite';
echo '
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.Tools::getAdminTokenLite('AdminCMSContent').'" method="post" name="cms" id="cms">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
'.$this->_displayDraftWarning($obj->active).'
<fieldset><legend><img src="../img/admin/cms.gif" />'.$this->l('CMS page').'</legend>';
// META TITLE
echo '<label>'.$this->l('CMS Category:').' </label>
<div class="margin-form">
<select name="id_cms_category">';
$categories = CMSCategory::getCategories((int)($cookie->id_lang), false);
CMSCategory::recurseCMSCategory($categories, $categories[0][1], 1, $this->getFieldValue($obj, 'id_cms_category'));
echo '
</select>
</div>
<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" onkeyup="copyMeta2friendlyURL();" id="name_'.$language['id_lang'].'" name="meta_title_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'meta_title', (int)($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">&nbsp;</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'meta_description');
echo ' </div><div class="clear space">&nbsp;</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $divLangName, 'meta_keywords');
echo ' </div><div class="clear space">&nbsp;</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" id="input_link_rewrite_'.$language['id_lang'].'" name="link_rewrite_'.$language['id_lang'].'" onkeyup="this.value = str2url(this.value); updateFriendlyURL();" value="'.htmlentities($this->getFieldValue($obj, 'link_rewrite', (int)($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">&nbsp;</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">&nbsp;</div>
<label>'.$this->l('Enable:').' </label>
<div class="margin-form">
<input type="radio" name="active" id="active_on" onclick="toggleDraftWarning(false);" 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" onclick="toggleDraftWarning(true);" 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>
</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><br />
'.$this->_displayDraftWarning($obj->active).'
</form>';
// TinyMCE
global $cookie;
$iso = Language::getIsoById((int)($cookie->id_lang));
$isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en');
$ad = dirname($_SERVER["PHP_SELF"]);
echo '
<script type="text/javascript">
var iso = \''.$isoTinyMCE.'\' ;
var pathCSS = \''._THEME_CSS_DIR_.'\' ;
var ad = \''.$ad.'\' ;
</script>
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tinymce.inc.js"></script>';
}
public function display($token = NULL)
{
global $currentIndex, $cookie;
if (($id_cms_category = (int)Tools::getValue('id_cms_category')))
$currentIndex .= '&id_cms_category='.$id_cms_category;
$this->getList((int)($cookie->id_lang), !$cookie->__get($this->table.'Orderby') ? 'position' : NULL, !$cookie->__get($this->table.'Orderway') ? 'ASC' : NULL);
//$this->getList((int)($cookie->id_lang));
if (!$id_cms_category)
$id_cms_category = 1;
echo '<h3>'.(!$this->_listTotal ? ($this->l('No pages found')) : ($this->_listTotal.' '.($this->_listTotal > 1 ? $this->l('pages') : $this->l('page')))).' '.
$this->l('in category').' "'.stripslashes(CMSCategory::hideCMSCategoryPosition($this->_category->getName())).'"</h3>';
echo '<a href="'.$currentIndex.'&id_cms_category='.$id_cms_category.'&add'.$this->table.'&token='.Tools::getAdminTokenLite('AdminCMSContent').'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add a new page').'</a>
<div style="margin:10px;">';
$this->displayList($token);
echo '</div>';
}
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);
}
function postProcess()
{
global $cookie, $link, $currentIndex;
if (Tools::isSubmit('viewcms') AND ($id_cms = (int)(Tools::getValue('id_cms'))) AND $cms = new CMS($id_cms, (int)($cookie->id_lang)) AND Validate::isLoadedObject($cms))
{
$redir = $link->getCMSLink($cms);
if (!$cms->active)
{
$admin_dir = dirname($_SERVER['PHP_SELF']);
$admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1);
$redir .= '?adtoken='.Tools::encrypt('PreviewCMS'.$cms->id).'&ad='.$admin_dir;
}
Tools::redirectAdmin($redir);
}
elseif (Tools::isSubmit('deletecms'))
{
if (Tools::getValue('id_cms') == Configuration::get('PS_CONDITIONS_CMS_ID'))
{
Configuration::updateValue('PS_CONDITIONS', 0);
Configuration::updateValue('PS_CONDITIONS_CMS_ID', 0);
}
$cms = new CMS((int)(Tools::getValue('id_cms')));
$cms->cleanPositions($cms->id_cms_category);
if (!$cms->delete())
$this->_errors[] = Tools::displayError('An error occurred while deleting object.').' <b>'.$this->table.' ('.mysql_error().')</b>';
else
Tools::redirectAdmin($currentIndex.'&id_cms_category='.$cms->id_cms_category.'&conf=1&token='.Tools::getAdminTokenLite('AdminCMSContent'));
}/* Delete multiple objects */
elseif (Tools::getValue('submitDel'.$this->table))
{
if ($this->tabAccess['delete'] === '1')
{
if (isset($_POST[$this->table.'Box']))
{
$cms = new CMS();
$result = true;
$result = $cms->deleteSelection(Tools::getValue($this->table.'Box'));
if ($result)
{
$cms->cleanPositions((int)(Tools::getValue('id_cms_category')));
Tools::redirectAdmin($currentIndex.'&conf=2&token='.Tools::getAdminTokenLite('AdminCMSContent').'&id_category='.(int)(Tools::getValue('id_cms_category')));
}
$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.');
}
elseif (Tools::isSubmit('submitAddcms') OR Tools::isSubmit('submitAddcmsAndPreview'))
{
parent::validateRules();
if (!sizeof($this->_errors))
{
if (!$id_cms = (int)(Tools::getValue('id_cms')))
{
$cms = new CMS();
$this->copyFromPost($cms, 'cms');
if (!$cms->add())
$this->_errors[] = Tools::displayError('An error occurred while creating object.').' <b>'.$this->table.' ('.mysql_error().')</b>';
elseif (Tools::isSubmit('submitAddcmsAndPreview'))
{
$preview_url = $link->getCMSLink($cms, $this->getFieldValue($object, 'link_rewrite', $this->_defaultFormLanguage), (int)($cookie->id_lang));
if (!$cms->active)
{
$admin_dir = dirname($_SERVER['PHP_SELF']);
$admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1);
$token = Tools::encrypt('PreviewCMS'.$cms->id);
$preview_url .= $object->active ? '' : '&adtoken='.$token.'&ad='.$admin_dir;
}
Tools::redirectAdmin($preview_url);
}
else
Tools::redirectAdmin($currentIndex.'&id_cms_category='.$cms->id_cms_category.'&conf=3&token='.Tools::getAdminTokenLite('AdminCMSContent'));
}
else
{
$cms = new CMS($id_cms);
$this->copyFromPost($cms, 'cms');
if (!$cms->update())
$this->_errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.' ('.mysql_error().')</b>';
elseif (Tools::isSubmit('submitAddcmsAndPreview'))
{
$preview_url = $link->getCMSLink($cms, $this->getFieldValue($object, 'link_rewrite', $this->_defaultFormLanguage), (int)($cookie->id_lang));
if (!$cms->active)
{
$admin_dir = dirname($_SERVER['PHP_SELF']);
$admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1);
$token = Tools::encrypt('PreviewCMS'.$cms->id);
$preview_url .= $object->active ? '' : '&adtoken='.$token.'&ad='.$admin_dir;
}
Tools::redirectAdmin($preview_url);
}
else
Tools::redirectAdmin($currentIndex.'&id_cms_category='.$cms->id_cms_category.'&conf=4&token='.Tools::getAdminTokenLite('AdminCMSContent'));
}
}
}
elseif (Tools::getValue('position'))
{
if ($this->tabAccess['edit'] !== '1')
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
elseif (!Validate::isLoadedObject($object = $this->loadObject()))
$this->_errors[] = Tools::displayError('An error occurred while updating status for object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
elseif (!$object->updatePosition((int)(Tools::getValue('way')), (int)(Tools::getValue('position'))))
$this->_errors[] = Tools::displayError('Failed to update the position.');
else
Tools::redirectAdmin($currentIndex.'&'.$this->table.'Orderby=position&'.$this->table.'Orderway=asc&conf=4'.(($id_category = (int)(Tools::getValue('id_cms_category'))) ? ('&id_cms_category='.$id_category) : '').'&token='.Tools::getAdminTokenLite('AdminCMSContent'));
}
/* Change object statuts (active, inactive) */
elseif (Tools::isSubmit('status') AND Tools::isSubmit($this->identifier))
{
if ($this->tabAccess['edit'] === '1')
{
if (Validate::isLoadedObject($object = $this->loadObject()))
{
if ($object->toggleStatus())
Tools::redirectAdmin($currentIndex.'&conf=5'.((int)Tools::getValue('id_cms_category') ? '&id_cms_category='.(int)Tools::getValue('id_cms_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 here.');
}
else
parent::postProcess(true);
}
}
-293
View File
@@ -1,293 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');
class AdminCMSCategories extends AdminTab
{
protected $maxImageSize = 300000;
/** @var object CMSCategory() instance for navigation*/
private $_CMSCategory;
public function __construct()
{
global $cookie;
$this->table = 'cms_category';
$this->className = 'CMSCategory';
$this->lang = true;
$this->edit = true;
$this->view = true;
$this->delete = true;
$this->fieldsDisplay = array(
'id_cms_category' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 30),
'name' => array('title' => $this->l('Name'), 'width' => 100, 'callback' => 'hideCMSCategoryPosition'),
'description' => array('title' => $this->l('Description'), 'width' => 500, 'maxlength' => 90, 'orderby' => false),
'position' => array('title' => $this->l('Position'), 'width' => 40,'filter_key' => 'position', 'align' => 'center', 'position' => 'position'),
'active' => array('title' => $this->l('Displayed'), 'active' => 'status', 'align' => 'center', 'type' => 'bool', 'orderby' => false));
$this->_CMSCategory = AdminCMSContent::getCurrentCMSCategory();
$this->_filter = 'AND `id_parent` = '.(int)($this->_CMSCategory->id);
$this->_select = 'position ';
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;
$id_cms_category = (int)(Tools::getValue('id_cms_category', 1));
$this->getList((int)($cookie->id_lang), !$cookie->__get($this->table.'Orderby') ? 'position' : 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('subCMS Category')))).' '.$this->l('in CMS Category').' "'.stripslashes(CMSCategory::hideCMSCategoryPosition($this->_CMSCategory->getName())).'"</h3>';
echo '<a href="'.__PS_BASE_URI__.substr($_SERVER['PHP_SELF'], strlen(__PS_BASE_URI__)).'?tab=AdminCMSContent&add'.$this->table.'&id_parent='.Tools::getValue('id_cms_category').'&token='.($token!=NULL ? $token : $this->token).'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add a new sub CMS Category').'</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_cms_category = (int)(Tools::getValue('id_cms_category')))
{
if (!CMSCategory::checkBeforeMove($id_cms_category, (int)(Tools::getValue('id_parent'))))
{
$this->_errors[] = Tools::displayError('CMS Category cannot be moved here');
return false;
}
}
}
/* Change object statuts (active, inactive) */
elseif (isset($_GET['statuscms_category']) AND Tools::getValue($this->identifier))
{
if ($this->tabAccess['edit'] === '1')
{
if (Validate::isLoadedObject($object = $this->loadObject()))
{
if ($object->toggleStatus())
Tools::redirectAdmin($currentIndex.'&conf=5'.((int)$object->id_parent ? '&id_cms_category='.(int)$object->id_parent : '').'&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 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><br />'.Tools::displayError('You cannot delete all of the items.');
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.');
}
elseif (isset($_GET['position']))
{
if ($this->tabAccess['edit'] !== '1')
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
elseif (!Validate::isLoadedObject($object = new CMSCategory((int)(Tools::getValue($this->identifier, Tools::getValue('id_cms_category_to_move', 1))))))
$this->_errors[] = Tools::displayError('An error occurred while updating status for object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
elseif (!$object->updatePosition((int)(Tools::getValue('way')), (int)(Tools::getValue('position'))))
$this->_errors[] = Tools::displayError('Failed to update the position.');
else
Tools::redirectAdmin($currentIndex.'&'.$this->table.'Orderby=position&'.$this->table.'Orderway=asc&conf=5'.(($id_category = (int)(Tools::getValue($this->identifier, Tools::getValue('id_cms_category_parent', 1)))) ? ('&'.$this->identifier.'='.$id_category) : '').'&token='.Tools::getAdminTokenLite('AdminCMSContent'));
}
/* Delete multiple objects */
elseif (Tools::getValue('submitDel'.$this->table))
{
if ($this->tabAccess['delete'] === '1')
{
if (isset($_POST[$this->table.'Box']))
{
$cms_category = new CMSCategory();
$result = true;
$result = $cms_category->deleteSelection(Tools::getValue($this->table.'Box'));
if ($result)
{
$cms_category->cleanPositions((int)(Tools::getValue('id_cms_category')));
Tools::redirectAdmin($currentIndex.'&conf=2&token='.Tools::getAdminTokenLite('AdminCMSContent').'&id_category='.(int)(Tools::getValue('id_cms_category')));
}
$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.');
}
parent::postProcess(true);
}
public function displayForm($token=NULL)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
$active = $this->getFieldValue($obj, 'active');
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 style="width:520px"><legend><img src="../img/admin/tab-categories.gif" />'.$this->l('CMS 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', (int)($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">&nbsp;</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 CMS Category:').' </label>
<div class="margin-form">
<select name="id_parent">';
$categories = CMSCategory::getCategories((int)($cookie->id_lang), false);
CMSCategory::recurseCMSCategory($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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
</div>';
echo ' <p class="clear"></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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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', (int)($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">&nbsp;</span></span>
</div>';
echo ' <p class="clear"></p>
</div>
<div class="margin-form">
<input type="submit" value="'.$this->l('Save and back to parent CMS Category').'" name="submitAdd'.$this->table.'AndBackToParent" class="button" />
&nbsp;<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>';
}
}
-129
View File
@@ -1,129 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');
include(PS_ADMIN_DIR.'/tabs/AdminCMSCategories.php');
include(PS_ADMIN_DIR.'/tabs/AdminCMS.php');
class AdminCMSContent extends AdminTab
{
/** @var object adminCMSCategories() instance */
private $adminCMSCategories;
/** @var object adminCMS() instance */
private $adminCMS;
/** @var object Category() instance for navigation*/
private static $_category = NULL;
public function __construct()
{
/* Get current category */
$id_cms_category = (int)(Tools::getValue('id_cms_category', Tools::getValue('id_cms_category_parent', 1)));
self::$_category = new CMSCategory($id_cms_category);
if (!Validate::isLoadedObject(self::$_category))
die('Category cannot be loaded');
$this->table = array('cms_category', 'cms');
$this->adminCMSCategories = new adminCMSCategories();
$this->adminCMS = new adminCMS();
parent::__construct();
}
/**
* Return current category
*
* @return object
*/
public static function getCurrentCMSCategory()
{
return self::$_category;
}
public function viewAccess($disable = false)
{
$result = parent::viewAccess($disable);
$this->adminCMSCategories->tabAccess = $this->tabAccess;
$this->adminCMS->tabAccess = $this->tabAccess;
return $result;
}
public function postProcess()
{
if (Tools::isSubmit('submitDelcms') OR Tools::isSubmit('previewSubmitAddcmsAndPreview') OR Tools::isSubmit('submitAddcms') OR isset($_GET['deletecms']) OR Tools::isSubmit('viewcms') OR (Tools::isSubmit('statuscms') AND Tools::isSubmit('id_cms')) OR (Tools::isSubmit('position') AND !Tools::isSubmit('id_cms_category_to_move')))
$this->adminCMS->postProcess();
if(Tools::isSubmit('submitDelcms_category') OR Tools::isSubmit('submitAddcms_categoryAndBackToParent') OR Tools::isSubmit('submitAddcms_category') OR isset($_GET['deletecms_category']) OR (Tools::isSubmit('statuscms_category') AND Tools::isSubmit('id_cms_category')) OR (Tools::isSubmit('position') AND Tools::isSubmit('id_cms_category_to_move')))
$this->adminCMSCategories->postProcess();
}
public function displayErrors()
{
parent::displayErrors();
$this->adminCMS->displayErrors();
$this->adminCMSCategories->displayErrors();
}
public function display()
{
global $currentIndex;
if (((Tools::isSubmit('submitAddcms_category') OR Tools::isSubmit('submitAddcms_categoryAndStay')) AND sizeof($this->adminCMSCategories->_errors)) OR isset($_GET['updatecms_category']) OR isset($_GET['addcms_category']))
{
$this->adminCMSCategories->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('submitAddcms') OR Tools::isSubmit('submitAddcmsAndStay')) AND sizeof($this->adminCMS->_errors)) OR isset($_GET['updatecms']) OR isset($_GET['addcms']))
{
$this->adminCMS->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 />';
}
else
{
$id_cms_category = (int)(Tools::getValue('id_cms_category'));
if (!$id_cms_category)
$id_cms_category = 1;
$cms_tabs = array('cms_category', 'cms');
// Cleaning links
$catBarIndex = $currentIndex;
foreach ($cms_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>&nbsp;&nbsp;&nbsp;'.getPath($catBarIndex, $id_cms_category,'','','cms').'</div>';
echo '<h2>'.$this->l('Categories').'</h2>';
$this->adminCMSCategories->display($this->token);
echo '<div style="margin:10px">&nbsp;</div>';
echo '<h2>'.$this->l('Pages in this category').'</h2>';
$this->adminCMS->display($this->token);
}
}
}
-332
View File
@@ -1,332 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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((int)(Configuration::get('PS_LANG_DEFAULT')), true , false,false, NULL, ALL_CARRIERS)),
);
parent::__construct();
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
$currentLanguage = (int)($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><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">&nbsp;</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', (int)($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_rules_group" id="id_tax_rules_group" '.(Tax::excludeTaxeOption() ? 'disabled="disabled"' : '' ).'>
<option value="0">'.$this->l('No Tax').'</option>';
foreach (TaxRulesGroup::getTaxRulesGroups(true) AS $tax_rules_group)
echo '<option value="'.$tax_rules_group['id_tax_rules_group'].'" '.(($this->getFieldValue($obj, 'id_tax_rules_group') == $tax_rules_group['id_tax_rules_group']) ? ' selected="selected"' : '').'>'.$tax_rules_group['name'].'</option>';
echo '</select>
</div>
<label>'.$this->l('Zone').'</label>
<div class="margin-form">';
$carrier_zones = $obj->getZones();
$zones = Zone::getZones(false);
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'], 'name' => $zone['name'], 'active' => $zone['active']), $carrier_zones))) ? ' checked="checked"' : '').'><label class="t" for="zone_'.$zone['id_zone'].'">&nbsp;<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((int)($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='.(int)($obj->id).' AND id_group='.(int)($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('Billing:').' </label>
<div class="margin-form">
<input type="radio" name="shipping_method" id="billing_default" value="'.Carrier::SHIPPING_METHOD_DEFAULT.'" '.($this->getFieldValue($obj, 'shipping_method') == Carrier::SHIPPING_METHOD_DEFAULT ? 'checked="checked" ' : '').'/>
<label class="t" for="billing_default">'.$this->l('Default behavior').'</label><br />
<input type="radio" name="shipping_method" id="billing_price" value="'.Carrier::SHIPPING_METHOD_PRICE.'" '.($this->getFieldValue($obj, 'shipping_method') == Carrier::SHIPPING_METHOD_PRICE ? 'checked="checked" ' : '').'/>
<label class="t" for="billing_price">'.$this->l('According to total price').'</label><br />
<input type="radio" name="shipping_method" id="billing_weight" value="'.Carrier::SHIPPING_METHOD_WEIGHT.'" '.($this->getFieldValue($obj, 'shipping_method') == Carrier::SHIPPING_METHOD_WEIGHT ? 'checked="checked" ' : '').'/>
<label class="t" for="billing_weight">'.$this->l('According to total weight').'</label><br />
</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 greater than the highest range limit)').'</p>
</div>';
if($this->getFieldValue($obj, 'is_module'))
{
echo '<label>'.$this->l('Module:').' </label>
<div class="margin-form"><p> - '.
$this->l('This carrier is bound to this module ').' => '.$this->getFieldValue($obj, 'external_module_name').'</p>
<input type="hidden" name="is_module" value="1">
<input type="hidden" name="external_module_name" value="'.$this->getFieldValue($obj, 'external_module_name').'">';
if($this->getFieldValue($obj, 'shipping_external'))
{
echo '<p> - '.$this->l('The shipping costs are calculated outside of your shop').'</p>
<input type="hidden" name="shipping_external" value="1">';
}
if($this->getFieldValue($obj, 'need_range'))
{
echo '<p> - '.$this->l('This carrier uses PrestaShop range to calculate shippping costs').'</p>
<input type="hidden" name="need_range" value="1">';
}
echo '</div>';
}
echo '
<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((int)($oldId));
}
private function changeGroups($id_carrier, $delete = true)
{
if ($delete)
Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'carrier_group WHERE id_carrier='.(int)($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('.(int)($group['id_group']).','.(int)($id_carrier).')');
}
public function postProcess()
{
global $currentIndex;
if (Tools::getValue('submitAdd'.$this->table))
{
/* Checking fields validity */
$this->validateRules();
if (!sizeof($this->_errors))
{
$id = (int)(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='.(int)($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((int)($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 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 here.');
}
}
}
else
{
if ((Tools::isSubmit('submitDel'.$this->table) && in_array(Configuration::get('PS_CARRIER_DEFAULT'), Tools::getValue('carrierBox')))
OR (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);
}
}
-323
View File
@@ -1,323 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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' => 'getOrderTotalUsingTaxCalculationMethod', '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', 'filter_key' => 'ca!name'),
'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;
if (!($cart = $this->loadObject(true)))
return;
$customer = new Customer($cart->id_customer);
$customerStats = $customer->getStats();
$products = $cart->getProducts();
$customizedDatas = Product::getAllCustomizedDatas((int)($cart->id));
Product::addCustomizationPrice($products, $customizedDatas);
$summary = $cart->getSummaryDetails();
$discounts = $cart->getDiscounts();
$currency = new Currency($cart->id_currency);
$currentLanguage = new Language((int)($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'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($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, (int)($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 = (int)(Order::getOrderByCartId($cart->id));
$order = new Order($id_order);
if ($order->getTaxCalculationMethod() == PS_TAX_EXC)
{
$total_products = $summary['total_products'];
$total_discount = $summary['total_discounts_tax_exc'];
$total_wrapping = $summary['total_wrapping_tax_exc'];
$total_price = $summary['total_price_without_tax'];
$total_shipping = $summary['total_shipping_tax_exc'];
} else {
$total_products = $summary['total_products_wt'];
$total_discount = $summary['total_discounts'];
$total_wrapping = $summary['total_wrapping'];
$total_price = $summary['total_price'];
$total_shipping = $summary['total_shipping'];
}
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='.(int)($order->id).'&vieworder&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee)).'"> '.$this->l('Order #').sprintf('%06d', $order->id).'</a></span>
<br /><br />
'.$this->l('Made on:').' '.Tools::displayDate($order->date_add, (int)$cookie->id_lang, true).'<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">&nbsp;</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'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee));
foreach ($products as $k => $product)
{
if ($order->getTaxCalculationMethod() == PS_TAX_EXC)
{
$product_price = $product['price'];
$product_total = $product['total'];
} else {
$product_price = $product['price_wt'];
$product_total = $product['total_wt'];
}
$image = array();
if (isset($product['id_product_attribute']) AND (int)($product['id_product_attribute']))
$image = Db::getInstance()->getRow('
SELECT id_image
FROM '._DB_PREFIX_.'product_attribute_image
WHERE id_product_attribute = '.(int)($product['id_product_attribute']));
if (!isset($image['id_image']))
$image = Db::getInstance()->getRow('
SELECT id_image
FROM '._DB_PREFIX_.'image
WHERE id_product = '.(int)($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 = '.(int)($product['id_product']).'
'.($product['id_product_attribute'] ? 'AND pa.id_product_attribute = '.(int)($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/'.(int)($product['id_product']).'-'.(int)($image['id_image']).'.jpg',
'product_mini_'.(int)($product['id_product']).(isset($product['id_product_attribute']) ? '_'.(int)($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, $currency, false, false).'</td>
<td align="center" class="productQuantity">'.((int)($product['cart_quantity']) - $product['customizationQuantityTotal']).'</td>
<td align="center" class="productQuantity">'.(int)($stock['quantity']).'</td>
<td align="right">'.Tools::displayPrice($product_total, $currency, false, false).'</td>
</tr>';
}
echo '
<tr class="cart_total_product">
<td colspan="5">'.$this->l('Total products:').'</td>
<td class="price bold right">'.Tools::displayPrice($total_products, $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($total_discount, $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($total_wrapping, $currency, false).'</td>
</tr>';
if ($cart->getOrderTotal(true, Cart::ONLY_SHIPPING) > 0)
echo '
<tr class="cart_total_delivery">
<td colspan="5">'.$this->l('Total shipping:').'</td>
<td class="price bold right">'.Tools::displayPrice($total_shipping, $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($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'.(int)(Tab::getIdFromClassName('AdminDiscounts')).(int)($cookie->id_employee)).'">'.$discount['name'].'</a></td>
<td align="center">- '.Tools::displayPrice($discount['value_real'], $currency, false).'</td>
</tr>';
echo '
</table>';
}
echo '<div style="float:left; margin-top:15px;">'.
$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.')).'
</div></div>';
// Cancel product
echo '
</fieldset>
<div class="clear" style="height:20px;">&nbsp;</div>';
}
private function displayCustomizedDatas(&$customizedDatas, &$product, &$currency, &$image, $tokenCatalog, &$stock)
{
if (!($order = $this->loadObject(true)))
return;
if (is_array($customizedDatas) AND isset($customizedDatas[(int)($product['id_product'])][(int)($product['id_product_attribute'])]))
{
echo '
<tr>
<td align="center">'.(isset($image['id_image']) ? cacheImage(_PS_IMG_DIR_.'p/'.(int)($product['id_product']).'-'.(int)($image['id_image']).'.jpg',
'product_mini_'.(int)($product['id_product']).(isset($product['id_product_attribute']) ? '_'.(int)($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">'.(int)($stock['quantity']).'</td>
<td align="right">'.Tools::displayPrice($product['total_customization_wt'], $currency, false, false).'</td>
</tr>';
foreach ($customizedDatas[(int)($product['id_product'])][(int)($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='.(int)($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'] ? $data['name'] : $this->l('Text #').++$i).$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((int)($cookie->id_lang), !Tools::getValue($this->table.'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL);
$this->displayList();
}
}
}
-176
View File
@@ -1,176 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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 imageResize() instance */
private $imageResize;
/** @var object Category() instance for navigation*/
private static $_category = NULL;
public function __construct()
{
/* Get current category */
$id_category = abs((int)(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()
{
parent::displayErrors();
$this->adminProducts->displayErrors();
$this->adminCategories->displayErrors();
if (Validate::isLoadedObject($this->attributeGenerator))
$this->attributeGenerator->displayErrors();
if (Validate::isLoadedObject($this->imageResize))
$this->imageResize->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('submitAddproductAndPreview') OR Tools::isSubmit('submitAddproductAndStay') OR Tools::isSubmit('submitSpecificPricePriorities') OR Tools::isSubmit('submitPriceAddition') OR Tools::isSubmit('submitPricesModification')) AND sizeof($this->adminProducts->_errors)) OR Tools::isSubmit('updateproduct') OR Tools::isSubmit('addproduct'))
{
$this->adminProducts->displayForm($this->token);
if (Tools::getValue('id_category') > 1)
echo '<br /><br /><a href="index.php?tab='.Tools::getValue('tab').'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to home').'</a><br />';
else
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 = (int)(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>&nbsp;&nbsp;&nbsp;'.getPath($catBarIndex, $id_category).'</div>';
echo '<h2>'.$this->l('Categories').'</h2>';
$this->adminCategories->display($this->token);
echo '<div style="margin:10px">&nbsp;</div>';
echo '<h2>'.$this->l('Products in this category').'</h2>';
$this->adminProducts->display($this->token);
}
}
}
-365
View File
@@ -1,365 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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),
'description' => array('title' => $this->l('Description'), 'width' => 500, 'maxlength' => 90, 'orderby' => false),
'position' => array('title' => $this->l('Position'), 'width' => 40,'filter_key' => 'position', 'align' => 'center', 'position' => 'position'),
'active' => array('title' => $this->l('Displayed'), 'active' => 'status', 'align' => 'center', 'type' => 'bool', 'orderby' => false));
$this->_category = AdminCatalog::getCurrentCategory();
$this->_filter = 'AND `id_parent` = '.(int)($this->_category->id);
$this->_select = 'position ';
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((int)($cookie->id_lang), !$cookie->__get($this->table.'Orderby') ? 'position' : 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($this->_category->getName()).'"</h3>';
if ($this->tabAccess['add'] === '1')
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>';
echo '<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 = (int)(Tools::getValue('id_category')))
{
if (!Category::checkBeforeMove($id_category, (int)(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 here.');
else
{
$object = new $this->className($id_category);
if (Tools::getValue('groupBox') != NULL)
{
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)');
}
else
$this->_errors[] = Tools::displayError('You must select at least one group.');
}
}
}
/* 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())
{
$target = '';
if (($id_category = (int)(Tools::getValue('id_category'))) AND Tools::getValue('id_product'))
$target = '&id_category='.(int)($id_category);
else
{
$referrer = Tools::secureReferrer($_SERVER['HTTP_REFERER']);
if (preg_match('/id_category=(\d+)/', $referrer, $matches))
$target = '&id_category='.(int)($matches[1]);
}
Module::hookExec('categoryUpdate');
Tools::redirectAdmin($currentIndex.'&conf=5'.$target.'&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 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><br />'.Tools::displayError('You cannot delete all of the items.');
else
{
$this->deleteImage($object->id);
if ($this->deleted)
{
$object->deleted = 1;
if ($object->update())
Tools::redirectAdmin($currentIndex.'&conf=1&token='.Tools::getValue('token').'&id_category='.(int)($object->id_parent));
}
elseif ($object->delete())
Tools::redirectAdmin($currentIndex.'&conf=1&token='.Tools::getValue('token').'&id_category='.(int)($object->id_parent));
$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 (isset($_GET['position']))
{
if ($this->tabAccess['edit'] !== '1')
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
elseif (!Validate::isLoadedObject($object = new Category((int)(Tools::getValue($this->identifier, Tools::getValue('id_category_to_move', 1))))))
$this->_errors[] = Tools::displayError('An error occurred while updating status for object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
if (!$object->updatePosition((int)(Tools::getValue('way')), (int)(Tools::getValue('position'))))
$this->_errors[] = Tools::displayError('Failed to update the position.');
else
Tools::redirectAdmin($currentIndex.'&'.$this->table.'Orderby=position&'.$this->table.'Orderway=asc&conf=5'.(($id_category = (int)(Tools::getValue($this->identifier, Tools::getValue('id_category_parent', 1)))) ? ('&'.$this->identifier.'='.$id_category) : '').'&token='.Tools::getAdminTokenLite('AdminCatalog'));
}
/* Delete multiple objects */
elseif (Tools::getValue('submitDel'.$this->table))
{
if ($this->tabAccess['delete'] === '1')
{
if (isset($_POST[$this->table.'Box']))
{
$category = new Category();
$result = true;
$result = $category->deleteSelection(Tools::getValue($this->table.'Box'));
if ($result)
{
$category->cleanPositions((int)(Tools::getValue('id_category')));
Tools::redirectAdmin($currentIndex.'&conf=2&token='.Tools::getAdminTokenLite('AdminCatalog').'&id_category='.(int)(Tools::getValue('id_category')));
}
$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.');
}
parent::postProcess();
}
protected function postImage($id)
{
$ret = parent::postImage($id);
if (($id_category = (int)(Tools::getValue('id_category'))) AND isset($_FILES) AND sizeof($_FILES) AND $_FILES['image']['name'] != NULL 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', (int)($imageType['width']), (int)($imageType['height']));
}
return $ret;
}
public function displayForm($token = NULL)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
$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><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', (int)($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">&nbsp;</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((int)($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', (int)($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'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" onchange="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">&nbsp;</span></span>
</div>';
echo ' <p class="clear"></p>
</div>
<label>'.$this->l('Groups access:').' </label>
<div class="margin-form">';
$groups = Group::getGroups((int)($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" />
&nbsp;<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>';
}
}
-98
View File
@@ -1,98 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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';
global $cookie;
$countryList = array();
$countryList[] = array('id' => '0', 'name' => $this->l('Choose your country'));
foreach (Country::getCountries(intval($cookie->id_lang)) AS $country)
$countryList[] = array('id' => $country['id_country'], 'name' => $country['name']);
$stateList = array();
$stateList[] = array('id' => '0', 'name' => $this->l('Choose your state (if applicable)'));
foreach (State::getStates(intval($cookie->id_lang)) AS $state)
$stateList[] = array('id' => $state['id_state'], 'name' => $state['name']);
$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' => 'isAddress', 'size' => 30, 'type' => 'text'),
'PS_SHOP_ADDR2' => array('title' => '', 'validation' => 'isAddress', '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_COUNTRY_ID' => array('title' => $this->l('Country:'), 'validation' => 'isInt', 'size' => 30, 'type' => 'select', 'list' => $countryList, 'identifier' => 'id', 'cast' => 'intval'),
'PS_SHOP_STATE_ID' => array('title' => $this->l('State:'), 'validation' => 'isInt', 'size' => 30, 'type' => 'select', 'list' => $stateList, 'identifier' => 'id', 'cast' => 'intval'),
'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 postProcess()
{
if (isset($_POST['PS_SHOP_STATE_ID']) && $_POST['PS_SHOP_STATE_ID'] != '0')
{
$isStateOk = Db::getInstance()->getValue('SELECT `active` FROM `'._DB_PREFIX_.'state` WHERE `id_country` = '.(int)(Tools::getValue('PS_SHOP_COUNTRY_ID')).' AND `id_state` = '.(int)(Tools::getValue('PS_SHOP_STATE_ID')));
if ($isStateOk != 1)
$this->_errors[] = Tools::displayError('This state is not in this country.');
}
parent::postProcess();
}
protected function _postConfig($fields)
{
global $cookie;
if (!$this->_errors && isset($_POST['PS_SHOP_COUNTRY_ID']))
{
$country = new Country((int)($_POST['PS_SHOP_COUNTRY_ID']), intval($cookie->id_lang));
Configuration::updateValue('PS_SHOP_COUNTRY', pSQL($country->name));
}
if (!$this->_errors && isset($_POST['PS_SHOP_STATE_ID']))
{
$state = new State((int)($_POST['PS_SHOP_STATE_ID']));
Configuration::updateValue('PS_SHOP_STATE', pSQL($state->name));
}
parent::_postConfig($fields);
}
public function display()
{
$this->_displayForm('shop', $this->_fieldsShop, $this->l('Contact details'), 'width3', 'tab-contact');
}
}
-114
View File
@@ -1,114 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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));
$this->optionTitle = $this->l('Contact options');
$this->_fieldsOptions = array(
'PS_CUSTOMER_SERVICE_FILE_UPLOAD' => array('title' => $this->l('Allow file upload'), 'desc' => $this->l('Allow customers to upload file using contact page'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => array(
'0' => array('value' => 0, 'name' => $this->l('No')),
'1' => array('value' => 1, 'name' => $this->l('Yes'))
)),
'PS_CUSTOMER_SERVICE_SIGNATURE' => array('title' => $this->l('Pre-defined message'), 'desc' => $this->l('Please fill the message that appears by default when you answer a thread on the customer service page'), 'cast' => 'pSQL', 'type' => 'textareaLang', 'identifier' => 'value',
'cols' => 40, 'rows' => 8
));
parent::__construct();
}
public function displayForm($isMainTab = true)
{
global $currentIndex;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
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/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', (int)($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').'" />
<p style="clear: both">'.$this->l('E-mails will be sent to this address').'</p>
</div>
<label>'.$this->l('Save in Customer Service?').'</label>
<div class="margin-form">
<input type="radio" name="customer_service" id="customer_service_on" value="1" '.($this->getFieldValue($obj, 'customer_service') ? 'checked="checked" ' : '').'/>
<label class="t" for="customer_service_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
<input type="radio" name="customer_service" id="customer_service_off" value="0" '.(!$this->getFieldValue($obj, 'customer_service') ? 'checked="checked" ' : '').'/>
<label class="t" for="customer_service_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
<p>'.$this->l('The messages will be saved in the Customer Service tab').'</p>
</div><div class="clear">&nbsp;</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', (int)($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>';
}
}
-205
View File
@@ -1,205 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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'),
'call_prefix' => array('title' => $this->l('Call prefix'), 'width' => 40, 'align' => 'center', 'callback' => 'displayCallPrefix'),
'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((int)($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
{
if (Tools::getValue('submitAdd'.$this->table))
{
$id_country = Tools::getValue('id_country');
$tmp_addr_format = new AddressFormat($id_country);
$save_status = false;
$is_new = is_null($tmp_addr_format->id_country);
if ($is_new)
{
$tmp_addr_format = new AddressFormat();
$tmp_addr_format->id_country = $id_country;
}
$tmp_addr_format->format = Tools::getValue('address_layout');
if (strlen($tmp_addr_format->format) > 0)
{
if ($tmp_addr_format->checkFormatFields())
$save_status = ($is_new) ? $tmp_addr_format->save(): $tmp_addr_format->update();
if (!$save_status)
$this->_errors[] = Tools::displayError('Invalid address layout'.Db::getInstance()->getMsgError());
}
unset($tmp_addr_format);
}
return parent::postProcess();
}
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
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/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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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('Call prefix:').' </label>
<div class="margin-form">
<input type="text" size="4" maxlength="3" name="call_prefix" value="'.(int)($this->getFieldValue($obj, 'call_prefix')).'" style="text-transform: uppercase;" /> <sup>*</sup>
<p>'.$this->l('International call prefix, e.g., 33 for France.').'.</p>
</div>
<label>'.$this->l('Default currency:').' </label>
<div class="margin-form">
<select name="id_currency">
<option value="0" '.(Tools::getValue('id_currency', $obj->id_currency) == 0 ? 'selected' : '').'>'.$this->l('Default store currency').'</option>
';
$currencies = Currency::getCurrencies();
foreach ($currencies AS $currency)
echo '<option value="'.intval($currency['id_currency']).'" '.(Tools::getValue('id_currency', $obj->id_currency) == $currency['id_currency'] ? 'selected' : '').'>'.Tools::htmlentitiesUTF8($currency['name']).'</option>';
echo '
</select>
</div>
<label>'.$this->l('Zone:').' </label>
<div class="margin-form">
<select name="id_zone">';
$zones = Zone::getZones();
foreach ($zones AS $zone)
echo ' <option value="'.(int)($zone['id_zone']).'"'.(($this->getFieldValue($obj, 'id_zone') == $zone['id_zone']) ? ' selected="selected"' : '').'>'.$zone['name'].'</option>';
$address_layout = AddressFormat::getAddressCountryFormat($obj->id);
echo ' </select>
<p>'.$this->l('Geographical zone where country is located').'</p>
</div>
<label>'.$this->l('Need zip code:').' </label>
<div class="margin-form">
<input type="radio" name="need_zip_code" id="need_zip_code_on" value="1" onchange="disableZipFormat();" '.((!$obj->id OR $this->getFieldValue($obj, 'need_zip_code')) ? 'checked="checked" ' : '').'/>
<label class="t" for="need_zip_code_on"> <img src="../img/admin/enabled.gif" alt="" title="'.$this->l('Yes').'" /></label>
<input type="radio" name="need_zip_code" id="need_zip_code_off" value="0" onchange="disableZipFormat();" '.((!$this->getFieldValue($obj, 'need_zip_code') AND $obj->id) ? 'checked="checked" ' : '').'/>
<label class="t" for="need_zip_code_off"> <img src="../img/admin/disabled.gif" alt="" title="'.$this->l('No').'" /></label>
</div>
<label class="zip_code_format">'.$this->l('Zip code format:').' </label>
<div class="margin-form zip_code_format">
<input type="text" name="zip_code_format" id="zip_code_format" value="'.$this->getFieldValue($obj, 'zip_code_format').'" onkeyup="$(\'#zip_code_format\').val($(\'#zip_code_format\').val().toUpperCase());" /> <sup>*</sup>
<p>'.$this->l('National zip code (L for a letter, N for a number and C for the Iso code), e.g., NNNNN for France. No verification if undefined').'.</p>
</div>
<label class="address_layout">'.$this->l('Address layout:').' </label>
<div class="margin-form" style="vertical-align: top;">
<p style="float: left;"><textarea id="ordered_fields" name="address_layout" style="width: 300px;height: 120px;">'.$address_layout.'</textarea></p>
<p style="float: left;margin-left: 10px;"><a href="#" onClick="$(\'textarea#ordered_fields\').val(unescape(\''.urlencode($address_layout).'\'.replace(/\+/g, \' \')));return false;" class="button">'.$this->l('Reset address layout').'</a></p>
<p class="clear">'.$this->l('Possible fields :').' '.implode(', ', (Address::getDispFieldsValidate())).'</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="clear"></div>
<label>'.$this->l('Display tax label:').' </label>
<div class="margin-form">
<input type="radio" name="display_tax_label" id="display_tax_label_on" value="1" '.((!$obj->id OR $this->getFieldValue($obj, 'display_tax_label')) ? 'checked="checked" ' : '').'/>
<label class="t" for="display_tax_label_on"> <img src="../img/admin/enabled.gif" alt="" title="" />'.$this->l('Yes').'</label>
<input type="radio" name="display_tax_label" id="display_tax_label_off" value="0" '.((!$this->getFieldValue($obj, 'display_tax_label') AND $obj->id) ? 'checked="checked" ' : '').'/>
<label class="t" for="display_tax_label_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>
<script type="text/javascript">disableZipFormat();</script>';
}
}
-219
View File
@@ -1,219 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminCounty extends AdminTab
{
public function __construct()
{
global $cookie;
$this->table = 'county';
$this->className = 'County';
$this->edit = true;
$this->delete = true;
$this->_select = 's.`name` AS state';
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_state` = a.`id_state`)';
$this->fieldsDisplay = array(
'id_county' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'name' => array('title' => $this->l('County'), 'width' => 130, 'filter_key' => 'b!name'),
'state' => array('title' => $this->l('State'), 'width' => 70, 'filter_key' => 's!name'),
'a!active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'a!active'));
parent::__construct();
}
public function renderJS()
{
return
'<script type="text/javascript">
function addZipCode()
{
zipcodes = $("#zipcodes").val();
id_county = $("#id_county").val();
$.ajax({
type: "POST",
url: "ajax.php",
data: "ajaxAddZipCode=1&zipcodes="+zipcodes+"&id_county="+id_county+"&token='.$this->token.'",
async : true,
success: function(msg) {
res = msg.split(":");
if (res.length == 2)
{
$("#error-msg").html(res[1]);
$("#zipcodes").css("border", "2px solid #FF0000");
} else {
$("#error-msg").html("");
$("#zipcodes").val("");
$("#zipcodes").css("border", "1px solid #E0D0B1");
$("#zipcodes-list").html(msg);
}
}
});
}
function populateStates(id_country, id_state)
{
$.ajax({
url: "ajax.php",
cache: false,
data: "ajaxStates=1&no_empty=false&id_country="+id_country+"&id_state="+id_state,
success: function(html){
$("#id_state").html(html);
}
});
}
function removeZipCodes(zipcodes)
{
id_county = $("#id_county").val();
$.ajax({
type: "POST",
url: "ajax.php",
data: "ajaxRemoveZipCode=1&zipcodes="+zipcodes+"&id_county="+id_county+"&token='.$this->token.'",
async : true,
success: function(msg) {
$("#zipcodes-list").html(msg);
}
});
}
</script>';
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
$cur_id_country = 0;
$cur_id_state = 0;
if (isset($obj->id_state))
{
$cur_state = new State($obj->id_state);
if (Validate::isLoadedObject($cur_state))
{
$cur_id_country = $cur_state->id_country;
$cur_id_state = $cur_state->id;
}
}
echo $this->renderJS().
'<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post">
'.($obj->id ? '<input type="hidden" id="id_county" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
<fieldset><legend><img src="../img/admin/world.gif" />'.$this->l('Counties').'</legend>';
if (!isset($obj->id))
echo '<div class="hint clear" style="display:block;">'.$this->l('Save this county then you will be able to associate zipcodes').'</div><br />';
$countries = Country::getCountries($cookie->id_lang, true, true);
echo '<label>'.$this->l('Country:').' </label>
<div class="margin-form"><select id="id_country" onchange="populateStates($(this).val(), '.(int)($this->getFieldValue($obj, 'id_state')).');">';
foreach ($countries AS $country)
echo '<option value="'.(int)$country['id_country'].'" '.($cur_id_country == $country['id_country'] ? 'selected' : '').'>'.Tools::htmlentitiesUTF8($country['name']).'</option>';
echo '</select></div>';
echo '<label>'.$this->l('State:').' </label>
<div class="margin-form">
<select name="id_state" id="id_state">
</select>
</div>
<script type="text/javascript">
id_country = $("#id_country").val();
populateStates(id_country,'.(int)$cur_id_state.');
</script>';
echo
'<label>'.$this->l('Name:').' </label>
<div class="margin-form">
<input type="text" size="30" maxlength="64" name="name" value="'.htmlentities($this->getFieldValue($obj, 'name'), 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" '.((!$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" />&nbsp;
<input type="submit" value="'.$this->l('Save and stay').'" name="submitAdd'.$this->table.'AndStay" class="button" />
</div>';
echo '<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>';
if (isset($obj->id))
{
echo '
<div class="margin-form">
'.$this->_renderZipCodeForm().'<br />
<div id="zipcodes-list">
'.AdminCounty::renderZipCodeList($obj->getZipCodes()).'
</div></div>';
}
echo '
</fieldset>
</form>';
}
protected function _renderZipCodeForm()
{
return '
<div>
Add Zip Codes:<br /> <input type="text" id="zipcodes" name="zipcodes" />
<a href="#" class="button" onclick="addZipCode()">Add</a>
<div id="error-msg" style="color: #FF0000"></div>
</div>';
}
public static function renderZipCodeList($zip_codes)
{
$html = '';
foreach ($zip_codes AS $zip_code)
{
$full_zip_code = $zip_code['from_zip_code'];
if ($zip_code['to_zip_code'] != 0)
$full_zip_code .= '-'.$zip_code['to_zip_code'];
$html .= '<div>'.Tools::htmlentitiesUTF8($full_zip_code).' <a href="#" onclick="removeZipCodes(\''.Tools::htmlentitiesUTF8($full_zip_code).'\')"><img src="../img/admin/delete.gif" alt="" /></a></div>';
}
return $html;
}
}
-233
View File
@@ -1,233 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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),
'iso_code_num' => array('title' => $this->l('ISO code num'), '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),
'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => 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')
.'<div class=warn"><img src="../img/admin/warn2.png" />'.$this->l('If you change default currency, you will have to manually edit every product price.').'</div>',
'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 ((isset($_GET['status'.$this->table]) OR isset($_GET['status'])) AND Tools::getValue($this->identifier))
{
if ($this->tabAccess['edit'] === '1')
{
if (Validate::isLoadedObject($object = $this->loadObject()))
{
if ($object->active AND $object->id == Configuration::get('PS_CURRENCY_DEFAULT'))
$this->_errors[] = $this->l('You can\'t disable the default currency');
elseif ($object->toggleStatus())
Tools::redirectAdmin($currentIndex.'&conf=5'.((($id_category = (int)(Tools::getValue('id_category'))) AND Tools::getValue('id_product')) ? '&id_category='.$id_category : '').'&token='.$this->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 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::refreshCurrencies();
}
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">
<fieldset>
<legend><img src="../img/admin/exchangesrate.gif" />'.$this->l('Currency rates').'</legend>
<label>'.$this->l('Update currency 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 currency rates').'" name="submitExchangesRates" class="button" />
</div>
</fieldset>
</form>';
}
public function displayForm($isMainTab = true)
{
global $currentIndex;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
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/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">&nbsp;</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">&nbsp;</span>
<p class="clear">'.$this->l('ISO code, e.g., USD for dollar, EUR for euro').'...</p>
</div>
<label>'.$this->l('Numeric ISO code:').' </label>
<div class="margin-form">
<input type="text" size="30" maxlength="32" name="iso_code_num" value="'.htmlentities($this->getFieldValue($obj, 'iso_code_num'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
<span class="hint-pointer">&nbsp;</span>
<p class="clear">'.$this->l('Numeric ISO code, e.g., 840 for dollar, 978 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., &euro;, $').'...</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.20\'').' 1&euro; = $1.20</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>
<label>'.$this->l('Enable:').' </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>
</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>';
}
}
-602
View File
@@ -1,602 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminCustomerThreads extends AdminTab
{
public function __construct()
{
global $cookie;
$this->table = 'customer_thread';
$this->lang = false;
$this->className = 'CustomerThread';
$this->edit = false;
$this->view = true;
$this->delete = true;
$this->_select = 'CONCAT(c.firstname," ",c.lastname) as customer, cl.name as contact, l.name as language, group_concat(message) as messages, (
SELECT IFNULL(CONCAT(LEFT(e.firstname, 1),". ",e.lastname), "--")
FROM '._DB_PREFIX_.'customer_message cm2 INNER JOIN '._DB_PREFIX_.'employee e ON e.id_employee = cm2.id_employee
WHERE cm2.id_employee > 0 AND cm2.`id_customer_thread` = a.`id_customer_thread`
ORDER BY cm2.date_add DESC LIMIT 1) as employee';
$this->_group = 'GROUP BY cm.id_customer_thread';
$this->_join = '
LEFT JOIN `'._DB_PREFIX_.'customer` c ON c.`id_customer` = a.`id_customer`
LEFT JOIN `'._DB_PREFIX_.'customer_message` cm ON cm.`id_customer_thread` = a.`id_customer_thread`
LEFT JOIN `'._DB_PREFIX_.'lang` l ON l.`id_lang` = a.`id_lang`
LEFT JOIN `'._DB_PREFIX_.'contact_lang` cl ON (cl.`id_contact` = a.`id_contact` AND cl.`id_lang` = '.(int)$cookie->id_lang.')';
$contactArray = array();
$contacts = Contact::getContacts($cookie->id_lang);
foreach ($contacts AS $contact)
$contactArray[$contact['id_contact']] = $contact['name'];
$languageArray = array();
$languages = Language::getLanguages();
foreach ($languages AS $language)
$languageArray[$language['id_lang']] = $language['name'];
$statusArray = array(
'open' => $this->l('Open'),
'closed' => $this->l('Closed'),
'pending1' => $this->l('Pending 1'),
'pending2' => $this->l('Pending 2')
);
$imagesArray = array(
'open' => 'status_green.gif',
'closed' => 'status_red.gif',
'pending1' => 'status_orange.gif',
'pending2' => 'status_orange.gif'
);
$this->fieldsDisplay = array(
'id_customer_thread' => array('title' => $this->l('ID'), 'width' => 25),
'customer' => array('title' => $this->l('Customer'), 'width' => 100, 'filter_key' => 'customer', 'tmpTableFilter' => true),
'email' => array('title' => $this->l('E-mail'), 'width' => 100, 'filter_key' => 'a!email'),
'contact' => array('title' => $this->l('Type'), 'width' => 75, 'type' => 'select', 'select' => $contactArray, 'filter_key' => 'cl!id_contact', 'filter_type' => 'int'),
'language' => array('title' => $this->l('Language'), 'width' => 60, 'type' => 'select', 'select' => $languageArray, 'filter_key' => 'l!id_lang', 'filter_type' => 'int'),
'status' => array('title' => $this->l('Status'), 'width' => 50, 'type' => 'select', 'select' => $statusArray, 'icon' => $imagesArray, 'align' => 'center', 'filter_key' => 'a!status', 'filter_type' => 'string'),
'employee' => array('title' => $this->l('Employee'), 'width' => 100, 'filter_key' => 'employee', 'tmpTableFilter' => true),
'messages' => array('title' => $this->l('Messages'), 'width' => 50, 'filter_key' => 'messages', 'tmpTableFilter' => true, 'maxlength' => 0),
'date_upd' => array('title' => $this->l('Last message'), 'width' => 90)
);
parent::__construct();
}
public function postProcess()
{
global $currentIndex, $cookie;
if ($id_customer_thread = (int)Tools::getValue('id_customer_thread'))
{
if (($id_contact = (int)Tools::getValue('id_contact')))
Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'customer_thread SET id_contact = '.(int)$id_contact.' WHERE id_customer_thread = '.(int)$id_customer_thread);
if ($id_status = (int)Tools::getValue('setstatus'))
{
$statusArray = array(1 => 'open', 2 => 'closed', 3 => 'pending1', 4 => 'pending2');
Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'customer_thread SET status = "'.$statusArray[$id_status].'" WHERE id_customer_thread = '.(int)$id_customer_thread.' LIMIT 1');
}
if (isset($_POST['id_employee_forward']))
{
// Todo: need to avoid doubles
$messages = Db::getInstance()->ExecuteS('
SELECT ct.*, cm.*, cl.name subject, CONCAT(e.firstname, \' \', e.lastname) employee_name, CONCAT(c.firstname, \' \', c.lastname) customer_name, c.firstname
FROM '._DB_PREFIX_.'customer_thread ct
LEFT JOIN '._DB_PREFIX_.'customer_message cm ON (ct.id_customer_thread = cm.id_customer_thread)
LEFT JOIN '._DB_PREFIX_.'contact_lang cl ON (cl.id_contact = ct.id_contact AND cl.id_lang = '.(int)$cookie->id_lang.')
LEFT OUTER JOIN '._DB_PREFIX_.'employee e ON e.id_employee = cm.id_employee
LEFT OUTER JOIN '._DB_PREFIX_.'customer c ON (c.email = ct.email)
WHERE ct.id_customer_thread = '.(int)Tools::getValue('id_customer_thread').'
ORDER BY cm.date_add DESC');
$output = '';
foreach ($messages AS $message)
$output .= $this->displayMsg($message, true, (int)Tools::getValue('id_employee_forward'));
$cm = new CustomerMessage();
$cm->id_employee = (int)$cookie->id_employee;
$cm->id_customer_thread = (int)Tools::getValue('id_customer_thread');
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
$currentEmployee = new Employee($cookie->id_employee);
if (($id_employee = (int)Tools::getValue('id_employee_forward')) AND ($employee = new Employee($id_employee)) AND Validate::isLoadedObject($employee))
{
$params = array(
'{messages}' => $output,
'{employee}' => $currentEmployee->firstname.' '.$currentEmployee->lastname,
'{comment}' => stripslashes($_POST['message_forward']));
Mail::Send((int)($cookie->id_lang), 'forward_msg', Mail::l('Fwd: Customer message'), $params,
$employee->email, $employee->firstname.' '.$employee->lastname,
$currentEmployee->email, $currentEmployee->firstname.' '.$currentEmployee->lastname);
$cm->message = $this->l('Message forwarded to').' '.$employee->firstname.' '.$employee->lastname."\n".$this->l('Comment:').' '.$_POST['message_forward'];
$cm->add();
}
elseif (($email = Tools::getValue('email')) AND Validate::isEmail($email))
{
$params = array(
'{messages}' => $output,
'{employee}' => $currentEmployee->firstname.' '.$currentEmployee->lastname,
'{comment}' => stripslashes($_POST['message_forward']));
Mail::Send((int)($cookie->id_lang), 'forward_msg', Mail::l('Fwd: Customer message'), $params,
$email, NULL,
$currentEmployee->email, $currentEmployee->firstname.' '.$currentEmployee->lastname);
$cm->message = $this->l('Message forwarded to').' '.$email."\n".$this->l('Comment:').' '.$_POST['message_forward'];
$cm->add();
}
else
echo '<div class="alert error">'.Tools::displayError('Email invalid.').'</div>';
}
if (Tools::isSubmit('submitReply'))
{
$ct = new CustomerThread($id_customer_thread);
$cm = new CustomerMessage();
$cm->id_employee = (int)$cookie->id_employee;
$cm->id_customer_thread = $ct->id;
$cm->message = Tools::htmlentitiesutf8(nl2br2(Tools::getValue('reply_message')));
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
if (isset($_FILES) AND !empty($_FILES['joinFile']['name']) AND $_FILES['joinFile']['error'] != 0)
$this->_errors[] = Tools::displayError('An error occurred with the file upload.');
else if ($cm->add())
{
$fileAttachment = NULL;
if (!empty($_FILES['joinFile']['name']))
{
$fileAttachment['content'] = file_get_contents($_FILES['joinFile']['tmp_name']);
$fileAttachment['name'] = $_FILES['joinFile']['name'];
$fileAttachment['mime'] = $_FILES['joinFile']['type'];
}
$params = array(
'{reply}' => nl2br2(Tools::getValue('reply_message')),
'{link}' => Tools::getHttpHost(true).__PS_BASE_URI__.'contact-form.php?id_customer_thread='.(int)($ct->id).'&token='.$ct->token);
Mail::Send($ct->id_lang, 'reply_msg', Mail::l('An answer to your message is available'), $params, Tools::getValue('msg_email'), NULL, NULL, NULL, $fileAttachment);
$ct->status = 'closed';
$ct->update();
Tools::redirectAdmin($currentIndex.'&id_customer_thread='.(int)$id_customer_thread.'&viewcustomer_thread&token='.Tools::getValue('token'));
}
else
$this->_errors[] = Tools::displayError('An error occurred, your message was not sent. Please contact your system administrator.');
}
}
return parent::postProcess();
}
public function display()
{
global $cookie;
if (isset($_GET['filename']) AND file_exists(_PS_UPLOAD_DIR_.$_GET['filename']))
self::openUploadedFile();
else if (isset($_GET['view'.$this->table]))
$this->viewcustomer_thread();
else
{
$this->getList((int)$cookie->id_lang, !Tools::getValue($this->table.'Orderby') ? 'date_upd' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL);
$this->displayList();
}
}
public function displayListHeader($token = NULL)
{
global $currentIndex, $cookie;
$contacts = Db::getInstance()->ExecuteS('
SELECT cl.*, COUNT(*) as total, (
SELECT id_customer_thread
FROM '._DB_PREFIX_.'customer_thread ct2
WHERE status = "open" AND ct.id_contact = ct2.id_contact
ORDER BY date_upd ASC
LIMIT 1
) as id_customer_thread
FROM '._DB_PREFIX_.'customer_thread ct
LEFT JOIN '._DB_PREFIX_.'contact_lang cl ON (cl.id_contact = ct.id_contact AND cl.id_lang = '.$cookie->id_lang.')
WHERE ct.status = "open"
GROUP BY ct.id_contact HAVING COUNT(*) > 0');
$categories = Db::getInstance()->ExecuteS('
SELECT cl.*
FROM '._DB_PREFIX_.'contact ct
LEFT JOIN '._DB_PREFIX_.'contact_lang cl ON (cl.id_contact = ct.id_contact AND cl.id_lang = '.$cookie->id_lang.')
WHERE ct.customer_service = 1');
$dim = count($categories);
echo '<div style="float:left;border:0;width:640px;">';
foreach ($categories as $key => $val)
{
$totalThread = 0;
$id_customer_thread = 0;
foreach ($contacts as $tmp => $tmp2)
if ($val['id_contact'] == $tmp2['id_contact'])
{
$totalThread = $tmp2['total'];
$id_customer_thread = $tmp2['id_customer_thread'];
break;
}
echo '<div style="background-color:#EFEFEF;float:left;margin:0 10px 10px 0;width:'.($dim > 6 ? '200' : '300').'px;border:1px solid #CFCFCF" >
<h3 style="overflow:hidden;line-height:25px;color:#812143;height:25px;margin:0;">&nbsp;'.$val['name'].'</h3>'.
($dim > 6 ? '' : '<p style="overflow:hidden;line-height:15px;height:45px;margin:0;padding:0 5px;">'.$val['description'].'</p>').
($totalThread == 0 ? '<h3 style="padding:0 5px;margin:0;height:23px;line-height:23px;background-color:#DEDEDE">'.$this->l('No new message').'</h3>'
: '<a href="'.$currentIndex.'&token='.Tools::getValue('token').'&id_customer_thread='.$id_customer_thread.'&viewcustomer_thread" style="padding:0 5px;display:block;height:23px;line-height:23px;border:0;" class="button">'.$totalThread.' '.($totalThread > 1 ? $this->l('new messages'): $this->l('new message')).'</a>').'
</div>';
}
echo '</div>';
$params = array(
$this->l('Total threads') => $all = Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'customer_thread'),
$this->l('Threads pending') => $pending = Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'customer_thread WHERE status LIKE "%pending%"'),
$this->l('Total customer messages') => Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'customer_message WHERE id_employee = 0'),
$this->l('Total employee messages') => Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'customer_message WHERE id_employee != 0'),
$this->l('Threads unread') => $unread = Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'customer_thread WHERE status = "open"'),
$this->l('Threads closed') => $all - ($unread + $pending));
echo '<div style="float:right;padding 0px;border:1px solid #CFCFCF;width:280px;">
<h3 class="button" style="margin:0;line-height:23px;height:23px;border:0;padding:0 5px;">'.$this->l('Customer service').' : '.$this->l('Statistics').'</h3>
<table cellspacing="1" class="table" style="border-collapse:separate;width:280px;border:0">';
$count = 0;
foreach ($params as $key => $val)
echo '<tr '.(++$count % 2 == 0 ? 'class="alt_row"' : '').'><td>'.$key.'</td><td>'.$val.'</td></tr>';
echo ' </table>
</div><p class="clear">&nbsp;</p>';
parent::displayListHeader($token);
}
private function openUploadedFile()
{
$filename = $_GET['filename'];
$extensions = array('.txt' => 'text/plain', '.rtf' => 'application/rtf', '.doc' => 'application/msword', '.docx'=> 'application/msword',
'.pdf' => 'application/pdf', '.zip' => 'multipart/x-zip', '.png' => 'image/png', '.jpeg' => 'image/jpeg', '.gif' => 'image/gif', '.jpg' => 'image/jpeg');
$extension = '';
foreach ($extensions AS $key => $val)
if (substr($filename, -4) == $key OR substr($filename, -5) == $key)
{
$extension = $val;
break;
}
ob_end_clean();
header('Content-Type: '.$extension);
header('Content-Disposition:attachment;filename="'.$filename.'"');
readfile(_PS_UPLOAD_DIR_.$filename);
die;
}
private function displayMsg($message, $email = false, $id_employee = null)
{
global $cookie, $currentIndex;
$customersToken = Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($cookie->id_employee));
$contacts = Contact::getContacts($cookie->id_lang);
if (!$email)
{
if (!empty($message['id_product']) AND empty($message['employee_name']))
$id_order_product = Db::getInstance()->getValue('
SELECT o.id_order
FROM '._DB_PREFIX_.'orders o
LEFT JOIN '._DB_PREFIX_.'order_detail od ON o.id_order = od.id_order
WHERE o.id_customer = '.(int)$message['id_customer'].'
AND od.product_id = '.(int)$message['id_product'].'
ORDER BY o.date_add DESC');
$output = '
<fieldset style="'.(!empty($message['employee_name']) ? 'background: rgb(255,236,242);' : '').'width:600px;margin-top:10px">
<legend '.(empty($message['employee_name']) ? '' : 'style="background:rgb(255,210,225)"').'>'.(
!empty($message['employee_name'])
? '<img src="../img/t/AdminCustomers.gif" alt="'.Configuration::get('PS_SHOP_NAME').'" /> '.Configuration::get('PS_SHOP_NAME').' - '.$message['employee_name']
: '<img src="'.__PS_BASE_URI__.'img/admin/tab-customers.gif" alt="'.Configuration::get('PS_SHOP_NAME').'" /> '.(
!empty($message['id_customer'])
? '<a href="index.php?tab=AdminCustomers&id_customer='.(int)($message['id_customer']).'&viewcustomer&token='.$customersToken.'" title="'.$this->l('View customer').'">'.$message['customer_name'].'</a>'
: $message['email']
)
).'</legend>
<div style="font-size:11px">'.(
(!empty($message['id_customer']) AND empty($message['employee_name']))
? '<b>'.$this->l('Customer ID:').'</b> <a href="index.php?tab=AdminCustomers&id_customer='.(int)($message['id_customer']).'&viewcustomer&token='.$customersToken.'" title="'.$this->l('View customer').'">'.(int)($message['id_customer']).' <img src="../img/admin/search.gif" alt="'.$this->l('view').'" /></a><br />'
: ''
).'
<b>'.$this->l('Sent on:').'</b> '.Tools::displayDate($message['date_add'], (int)($cookie->id_lang), true).'<br />'.(
empty($message['employee_name'])
? '<b>'.$this->l('Browser:').'</b> '.strip_tags($message['user_agent']).'<br />'
: ''
).(
(!empty($message['file_name']) AND file_exists(_PS_UPLOAD_DIR_.$message['file_name']))
? '<b>'.$this->l('File attachment').'</b> <a href="index.php?tab=AdminCustomerThreads&id_customer_thread='.$message['id_customer_thread'].'&viewcustomer_thread&token='.Tools::getAdminToken('AdminCustomerThreads'.(int)(Tab::getIdFromClassName('AdminCustomerThreads')).(int)($cookie->id_employee)).'&filename='.$message['file_name'].'" title="'.$this->l('View file').'"><img src="../img/admin/search.gif" alt="'.$this->l('view').'" /></a><br />'
: ''
).(
(!empty($message['id_order']) AND empty($message['employee_name']))
? '<b>'.$this->l('Order #').'</b> <a href="index.php?tab=AdminOrders&id_order='.(int)($message['id_order']).'&vieworder&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee)).'" title="'.$this->l('View order').'">'.(int)($message['id_order']).' <img src="../img/admin/search.gif" alt="'.$this->l('view').'" /></a><br />'
: ''
).(
(!empty($message['id_product']) AND empty($message['employee_name']))
? '<b>'.$this->l('Product #').'</b> <a href="index.php?tab=AdminOrders&id_order='.(int)($id_order_product).'&vieworder&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee)).'" title="'.$this->l('View order').'">'.(int)($message['id_product']).' <img src="../img/admin/search.gif" alt="'.$this->l('view').'" /></a><br />'
: ''
).'<br />
<form action="'.Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']).'" method="post">
<b>'.$this->l('Subject:').'</b>
<input type="hidden" name="id_customer_message" value="'.$message['id_customer_message'].'" />
<select name="id_contact" onchange="this.form.submit();">';
foreach ($contacts as $contact)
$output .= '<option value="'.(int)$contact['id_contact'].'" '.($contact['id_contact'] == $message['id_contact'] ? 'selected="selected"' : '').'>'.Tools::htmlentitiesutf8($contact['name']).'</option>';
$output .= '</select>
</form>';
}
else
{
$output = '<div style="font-size:11px">
'.($id_employee ? '<a href="'.Tools::getHttpHost(true).$currentIndex.'&token='.Tools::getAdminToken('AdminCustomerThreads'.(int)(Tab::getIdFromClassName('AdminCustomerThreads')).(int)($id_employee)).'&id_customer_thread='.(int)$message['id_customer_thread'].'&viewcustomer_thread">'.$this->l('View this thread').'</a><br />' : '').'
<b>'.$this->l('Sent by:').'</b> '.(!empty($message['customer_name']) ? $message['customer_name'].' ('.$message['email'].')' : $message['email'])
.((!empty($message['id_customer']) AND empty($message['employee_name'])) ? '<br /><b>'.$this->l('Customer ID:').'</b> '.(int)($message['id_customer']).'<br />' : '')
.((!empty($message['id_order']) AND empty($message['employee_name'])) ? '<br /><b>'.$this->l('Order #').':</b> '.(int)($message['id_order']).'<br />' : '')
.((!empty($message['id_product']) AND empty($message['employee_name'])) ? '<br /><b>'.$this->l('Product #').':</b> '.(int)($message['id_product']).'<br />' : '')
.'<br /><b>'.$this->l('Subject:').'</b> '.$message['subject'];
}
$message['message'] = preg_replace('/(https?:\/\/[a-z0-9#%&_=\(\)\.\? \+\-@\/]{6,1000})([\s\n<])/Uui', '<a href="\1">\1</a>\2', html_entity_decode($message['message'], ENT_NOQUOTES, 'UTF-8'));
$output .= '<br /><br />
<b>'.$this->l('Thread ID:').'</b> '.(int)$message['id_customer_thread'].'<br />
<b>'.$this->l('Message ID:').'</b> '.(int)$message['id_customer_message'].'<br />
<b>'.$this->l('Message:').'</b><br />
'.$message['message'].'
</div>';
if (!$email)
{
if (empty($message['employee_name']))
$output .= '
<p style="text-align:right">
<button style="font-family: Verdana; font-size: 11px; font-weight:bold; height: 65px; width: 120px;" onclick="$(\'#reply_to_'.(int)($message['id_customer_message']).'\').show(500); $(this).hide();">
<img src="'.__PS_BASE_URI__.'img/admin/contact.gif" alt="" style="margin-bottom: 5px;" /><br />'.$this->l('Reply to this message').'
</button>
</p>
<div id="reply_to_'.(int)($message['id_customer_message']).'" style="display: none; margin-top: 20px;"">
<form action="'.Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']).'" method="post" enctype="multipart/form-data">
<p>'.$this->l('Please type your reply below:').'</p>
<textarea style="width: 450px; height: 175px;" name="reply_message">'.str_replace('\r\n', "\n", Configuration::get('PS_CUSTOMER_SERVICE_SIGNATURE', $message['id_lang'])).'</textarea>
<div style="width: 450px; text-align: right; font-style: italic; font-size: 9px; margin-top: 2px;">
'.$this->l('Your reply will be sent to:').' '.$message['email'].'
</div>
<div style="width: 450px; margin-top: 0px;">
<input type="file" name="joinFile"/>
<div>
<div style="width: 450px; text-align: center;">
<input type="submit" class="button" name="submitReply" value="'.$this->l('Send my reply').'" style="margin-top:20px;" />
<input type="hidden" name="id_customer_thread" value="'.(int)($message['id_customer_thread']).'" />
<input type="hidden" name="msg_email" value="'.$message['email'].'" />
</div>
</form>
</div>';
$output .= '
</fieldset>';
}
return $output;
}
public function viewcustomer_thread()
{
global $cookie, $currentIndex;
if (!($thread = $this->loadObject()))
return;
$cookie->{'customer_threadFilter_cl!id_contact'} = $thread->id_contact;
$employees = Db::getInstance()->ExecuteS('
SELECT e.id_employee, e.firstname, e.lastname FROM '._DB_PREFIX_.'employee e
WHERE e.active = 1 ORDER BY e.lastname ASC');
echo '
<h2>'.$this->l('Messages').'</h2>
<form action="'.Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']).'" method="post" enctype="multipart/form-data">
<p>
<img src="../img/admin/msg-forward.png" alt="" style="vertical-align: middle;" /> '.$this->l('Forward this discussion to an employee:').'
<select name="id_employee_forward" style="vertical-align: middle;" onchange="
if ($(this).val() >= 0)
$(\'#message_forward\').show(400);
else
$(\'#message_forward\').hide(200);
if ($(this).val() == 0)
$(\'#message_forward_email\').show(200);
else
$(\'#message_forward_email\').hide(200);
">
<option value="-1">'.$this->l('-- Choose --').'</option>
<option value="0">'.$this->l('Someone else').'</option>';
foreach ($employees AS $employee)
echo ' <option value="'.(int)($employee['id_employee']).'">'.substr($employee['firstname'], 0, 1).'. '.$employee['lastname'].'</option>';
echo ' </select>
<div id="message_forward_email" style="display:none">
<b>'.$this->l('E-mail').'</b> <input type="text" name="email" />
</div>
<div id="message_forward" style="display:none;margin-bottom:10px">
<textarea name="message_forward" style="width: 500px; height: 80px; margin-top: 15px;" onclick="if ($(this).val() == \''.addslashes($this->l('You can add a comment here.')).'\') { $(this).val(\'\'); }">'.$this->l('You can add a comment here.').'</textarea><br />
<input type="Submit" name="submitForward" class="button" value="'.$this->l('Forward this discussion').'" style="margin-top: 10px;" />
</div>
</p>
</form>
<div class="clear">&nbsp;</div>';
$messages = Db::getInstance()->ExecuteS('
SELECT ct.*, cm.*, cl.name subject, CONCAT(e.firstname, \' \', e.lastname) employee_name, CONCAT(c.firstname, \' \', c.lastname) customer_name, c.firstname
FROM '._DB_PREFIX_.'customer_thread ct
LEFT JOIN '._DB_PREFIX_.'customer_message cm ON (ct.id_customer_thread = cm.id_customer_thread)
LEFT JOIN '._DB_PREFIX_.'contact_lang cl ON (cl.id_contact = ct.id_contact AND cl.id_lang = '.(int)$cookie->id_lang.')
LEFT JOIN '._DB_PREFIX_.'employee e ON e.id_employee = cm.id_employee
LEFT JOIN '._DB_PREFIX_.'customer c ON (IFNULL(ct.id_customer, ct.email) = IFNULL(c.id_customer, c.email))
WHERE ct.id_customer_thread = '.(int)Tools::getValue('id_customer_thread').'
ORDER BY cm.date_add DESC');
echo '<div style="float:right">';
$nextThread = Db::getInstance()->getValue('
SELECT id_customer_thread FROM '._DB_PREFIX_.'customer_thread ct
WHERE ct.status = "open" AND ct.date_upd > (
SELECT date_add FROM '._DB_PREFIX_.'customer_message
WHERE (id_employee IS NULL OR id_employee = 0) AND id_customer_thread = '.(int)$thread->id.'
ORDER BY date_add DESC LIMIT 1
)
'.($cookie->{'customer_threadFilter_cl!id_contact'} ? 'AND ct.id_contact = '.(int)$cookie->{'customer_threadFilter_cl!id_contact'} : '').'
'.($cookie->{'customer_threadFilter_l!id_lang'} ? 'AND ct.id_lang = '.(int)$cookie->{'customer_threadFilter_l!id_lang'} : '').
' ORDER BY ct.date_upd ASC');
if ($nextThread)
echo $this->displayButton('
<a href="'.$currentIndex.'&id_customer_thread='.(int)$nextThread.'&viewcustomer_thread&token='.$this->token.'">
<img src="../img/admin/next-msg.png" title="'.$this->l('Go to the oldest next unanswered message').'" style="margin-bottom: 10px;" />
<br />'.$this->l('Answer to the next unanswered message in this category').' &gt;
</a>');
else
echo $this->displayButton('
<img src="../img/admin/msg-ok.png" title="'.$this->l('Go to the oldest next unanswered message').'" style="margin-bottom: 10px;" />
<br />'.$this->l('The other messages in this category have been answered'));
if ($thread->status != "closed")
echo $this->displayButton('
<a href="'.$currentIndex.'&viewcustomer_thread&setstatus=2&id_customer_thread='.Tools::getValue('id_customer_thread').'&viewmsg&token='.$this->token.'">
<img src="../img/admin/msg-ok.png" style="margin-bottom:10px" />
<br />'.$this->l('Set this message as handled').'
</a>');
if ($thread->status != "pending1")
echo $this->displayButton('
<a href="'.$currentIndex.'&viewcustomer_thread&setstatus=3&id_customer_thread='.Tools::getValue('id_customer_thread').'&viewmsg&token='.$this->token.'">
<img src="../img/admin/msg-pending.png" style="margin-bottom:10px" />
<br />'.$this->l('Declare this message').'<br />'.$this->l('as "pending 1"').'<br />'.$this->l('(will be answered later)').'
</a>');
else
echo $this->displayButton('
<a href="'.$currentIndex.'&viewcustomer_thread&setstatus=1&id_customer_thread='.Tools::getValue('id_customer_thread').'&viewmsg&token='.$this->token.'">
<img src="../img/admin/msg-is-pending.png" style="margin-bottom:10px" />
<br />'.$this->l('Click here to disable pending status').'
</a>');
if ($thread->status != "pending2")
echo $this->displayButton('
<a href="'.$currentIndex.'&viewcustomer_thread&setstatus=4&id_customer_thread='.Tools::getValue('id_customer_thread').'&viewmsg&token='.$this->token.'">
<img src="../img/admin/msg-pending.png" style="margin-bottom:10px" />
<br />'.$this->l('Declare this message').'<br />'.$this->l('as "pending 2"').'<br />'.$this->l('(will be answered later)').'
</a>');
else
echo $this->displayButton('
<a href="'.$currentIndex.'&viewcustomer_thread&setstatus=1&id_customer_thread='.Tools::getValue('id_customer_thread').'&viewmsg&token='.$this->token.'">
<img src="../img/admin/msg-is-pending.png" style="margin-bottom:10px" />
<br />'.$this->l('Click here to disable pending status').'
</a>');
echo '</div>';
if ($thread->id_customer)
{
$customer = new Customer($thread->id_customer);
$products = $customer->getBoughtProducts();
$orders = Order::getCustomerOrders($customer->id);
echo '<div style="float:left;width:600px">';
if ($orders AND sizeof($orders))
{
$totalOK = 0;
$ordersOK = array();
$tokenOrders = Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee));
foreach ($orders as $order)
if ($order['valid'])
{
$ordersOK[] = $order;
$totalOK += $order['total_paid_real'];
}
if ($countOK = sizeof($ordersOK))
{
echo '<div style="float:left;margin-right:20px;">
<h2>'.$this->l('Orders').'</h2>
<table cellspacing="0" cellpadding="0" class="table float">
<tr>
<th class="center">'.$this->l('ID').'</th>
<th class="center">'.$this->l('Date').'</th>
<th class="center">'.$this->l('Products').'</th>
<th class="center">'.$this->l('Total paid').'</th>
<th class="center">'.$this->l('Payment').'</th>
<th class="center">'.$this->l('State').'</th>
<th class="center">'.$this->l('Actions').'</th>
</tr>';
$irow = 0;
foreach ($ordersOK 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">'.$order['id_order'].'</td>
<td>'.Tools::displayDate($order['date_add'], (int)($cookie->id_lang)).'</td>
<td align="right">'.$order['nb_products'].'</td>
<td align="right">'.Tools::displayPrice($order['total_paid_real'], new Currency((int)($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>
<h3 style="color:green;font-weight:700;margin-top:10px">'.$this->l('Validated Orders:').' '.$countOK.' '.$this->l('for').' '.Tools::displayPrice($totalOK, new Currency(1)).'</h3>
</div>';
}
}
if ($products AND sizeof($products))
{
echo '<div style="float:left;margin-right:20px">
<h2>'.$this->l('Products').'</h2>
<table cellspacing="0" cellpadding="0" class="table">
<tr>
<th class="center">'.$this->l('Date').'</th>
<th class="center">'.$this->l('ID').'</th>
<th class="center">'.$this->l('Name').'</th>
<th class="center">'.$this->l('Quantity').'</th>
<th class="center">'.$this->l('Actions').'</th>
</tr>';
$irow = 0;
$tokenOrders = Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($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'], (int)($cookie->id_lang), true).'</td>
<td>'.$product['product_id'].'</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></div>';
}
echo '</div>';
}
echo '<div style="float:left;margin-top:10px">';
foreach ($messages AS $message)
echo $this->displayMsg($message);
echo '</div><div class="clear">&nbsp;</div>';
}
private function displayButton($content)
{
return '
<div style="margin-bottom:10px;border:1px solid #005500;width:200px;height:130px;padding:10px;background:#EFE">
<p style="text-align:center;font-size:15px;font-weight:bold">
'.$content.'
</p>
</div>';
}
}
-802
View File
@@ -1,802 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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->requiredDatabase = 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' => 30, 'type' => 'date', 'align' => 'right'),
'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('Regenerate password:'), 'desc' => $this->l('Security minimum time to wait to regenerate the password'), 'cast' => 'intval', 'size' => 5, 'type' => 'text', 'suffix' => ' '.$this->l('minutes'))
);
parent::__construct();
}
public function postProcess()
{
global $currentIndex;
if (Tools::isSubmit('submitDel'.$this->table) OR Tools::isSubmit('delete'.$this->table))
{
$deleteForm = '
<form action="'.htmlentities($_SERVER['REQUEST_URI']).'" method="post">
<fieldset><legend>'.$this->l('How do you want to delete your customer(s)?').'</legend>
'.$this->l('You have two ways to delete a customer, please choose what you want to do.').'
<p>
<input type="radio" name="deleteMode" value="real" id="deleteMode_real" />
<label for="deleteMode_real" style="float:none">'.$this->l('I want to delete my customer(s) for real, all data will be removed from the database. A customer with the same e-mail address will be able to register again.').'</label>
</p>
<p>
<input type="radio" name="deleteMode" value="deleted" id="deleteMode_deleted" />
<label for="deleteMode_deleted" style="float:none">'.$this->l('I don\'t want my customer(s) to register again. The customer(s) will be removed from this list but all data will be kept in the database.').'</label>
</p>';
foreach ($_POST as $key => $value)
if (is_array($value))
foreach ($value as $val)
$deleteForm .= '<input type="hidden" name="'.htmlentities($key).'[]" value="'.htmlentities($val).'" />';
else
$deleteForm .= '<input type="hidden" name="'.htmlentities($key).'" value="'.htmlentities($value).'" />';
$deleteForm .= ' <br /><input type="submit" class="button" value="'.$this->l(' Delete ').'" />
</fieldset>
</form>
<div class="clear">&nbsp;</div>';
}
if (Tools::getValue('submitAdd'.$this->table))
{
$groupList = Tools::getValue('groupBox');
/* Checking fields validity */
$this->validateRules();
if (!sizeof($this->_errors))
{
$id = (int)(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 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 (!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 in 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, true);
$parent_id = (int)(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 here.');
}
}
}
elseif (Tools::isSubmit('delete'.$this->table) AND $this->tabAccess['delete'] === '1')
{
switch (Tools::getValue('deleteMode'))
{
case 'real':
$this->deleted = false;
Discount::deleteByIdCustomer((int)(Tools::getValue('id_customer')));
break;
case 'deleted':
$this->deleted = true;
break;
default:
echo $deleteForm;
if (isset($_POST['delete'.$this->table]))
unset($_POST['delete'.$this->table]);
if (isset($_GET['delete'.$this->table]))
unset($_GET['delete'.$this->table]);
break;
}
}
elseif (Tools::isSubmit('submitDel'.$this->table) AND $this->tabAccess['delete'] === '1')
{
switch (Tools::getValue('deleteMode'))
{
case 'real':
$this->deleted = false;
foreach (Tools::getValue('customerBox') as $id_customer)
Discount::deleteByIdCustomer((int)($id_customer));
break;
case 'deleted':
$this->deleted = true;
break;
default:
echo $deleteForm;
if (isset($_POST['submitDel'.$this->table]))
unset($_POST['submitDel'.$this->table]);
if (isset($_GET['submitDel'.$this->table]))
unset($_GET['submitDel'.$this->table]);
break;
}
}
elseif (Tools::isSubmit('submitGuestToCustomer') AND Tools::getValue('id_customer'))
{
if ($this->tabAccess['edit'] === '1')
{
$customer = new Customer((int)Tools::getValue('id_customer'));
if (!Validate::isLoadedObject($customer))
$this->_errors[] = Tools::displayError('This customer does not exist.');
if ($customer->transformToCustomer(Tools::getValue('id_lang', Configuration::get('PS_LANG_DEFAULT'))))
Tools::redirectAdmin($currentIndex.'&'.$this->identifier.'='.$customer->id.'&conf=3&token='.$this->token);
else
$this->_errors[] = Tools::displayError('An error occurred while updating customer.');
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
return parent::postProcess();
}
public function viewcustomer()
{
global $currentIndex, $cookie, $link;
$irow = 0;
$configurations = Configuration::getMultiple(array('PS_LANG_DEFAULT', 'PS_CURRENCY_DEFAULT'));
$defaultLanguage = (int)($configurations['PS_LANG_DEFAULT']);
$defaultCurrency = (int)($configurations['PS_CURRENCY_DEFAULT']);
if (!($customer = $this->loadObject()))
return;
$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();
$messages = CustomerThread::getCustomerMessages($customer->id);
$referrers = Referrer::getReferrers($customer->id);
if ($totalCustomer = Db::getInstance()->getValue('SELECT SUM(total_paid_real) FROM '._DB_PREFIX_.'orders WHERE id_customer = '.$customer->id.' AND valid = 1'))
{
Db::getInstance()->getValue('SELECT SQL_CALC_FOUND_ROWS COUNT(*) FROM '._DB_PREFIX_.'orders WHERE valid = 1 GROUP BY id_customer HAVING SUM(total_paid_real) > '.$totalCustomer);
$countBetterCustomers = (int)Db::getInstance()->getValue('SELECT FOUND_ROWS()') + 1;
}
else
$countBetterCustomers = '-';
echo '
<fieldset style="width:400px;float: left"><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).'<br />
'.$this->l('Registration date:').' '.Tools::displayDate($customer->date_add, (int)($cookie->id_lang), true).'<br />
'.$this->l('Last visit:').' '.($customerStats['last_visit'] ? Tools::displayDate($customerStats['last_visit'], (int)($cookie->id_lang), true) : $this->l('never')).'<br />
'.($countBetterCustomers != '-' ? $this->l('Rank: #').' '.(int)$countBetterCustomers.'<br />' : '').'
</fieldset>
<fieldset style="width:300px;float:left;margin-left:50px">
<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, (int)($cookie->id_lang)).')' : $this->l('unknown')).'<br /><br />
'.$this->l('Last update:').' '.Tools::displayDate($customer->date_upd, (int)($cookie->id_lang), true).'<br />
'.$this->l('Status:').' '.($customer->active ? '<img src="../img/admin/enabled.gif" />' : '<img src="../img/admin/disabled.gif" />');
if ($customer->isGuest())
echo '
<div>
'.$this->l('This customer is registered as').' <b>'.$this->l('guest').'</b>
<form method="POST" action="index.php?tab=AdminCustomers&id_customer='.(int)$customer->id.'&token='.Tools::getAdminTokenLite('AdminCustomers').'">
<input type="hidden" name="id_lang" value="'.(int)(sizeof($orders) ? $orders[0]['id_lang'] : Configuration::get('PS_LANG_DEFAULT')).'" />
<p class="center"><input class="button" type="submit" name="submitGuestToCustomer" value="'.$this->l('Transform to customer').'" /></p>
'.$this->l('This feature generates a random password and sends an e-mail to the customer').'
</form>
</div>
';
echo '
</fieldset>
<div class="clear">&nbsp;</div>';
echo '<fieldset style="height:190px"><legend><img src="../img/admin/cms.gif" /> '.$this->l('Add a private note').'</legend>
<p>'.$this->l('This note will be displayed to all the employees but not to the customer.').'</p>
<form action="ajax.php" method="post" onsubmit="saveCustomerNote();return false;" id="customer_note">
<textarea name="note" id="noteContent" style="width:600px;height:100px" onkeydown="$(\'#submitCustomerNote\').removeAttr(\'disabled\');">'.Tools::htmlentitiesUTF8($customer->note).'</textarea><br />
<input type="submit" id="submitCustomerNote" class="button" value="'.$this->l(' Save ').'" style="float:left;margin-top:5px" disabled="disabled" />
<span id="note_feedback" style="float:left;margin:10px 0 0 10px"></span>
</form>
</fieldset>
<div class="clear">&nbsp;</div>
<script type="text/javascript">
function saveCustomerNote()
{
$("#note_feedback").html("<img src=\"../img/loader.gif\" />").show();
var noteContent = $("#noteContent").val();
$.post("ajax.php", {submitCustomerNote:1,id_customer:'.(int)$customer->id.',note:noteContent}, function (r) {
$("#note_feedback").html("").hide();
if (r == "ok")
{
$("#note_feedback").html("<b style=\"color:green\">'.addslashes($this->l('Your note has been saved')).'</b>").fadeIn(400);
$("#submitCustomerNote").attr("disabled", "disabled");
}
else if (r == "error:validation")
$("#note_feedback").html("<b style=\"color:red\">'.addslashes($this->l('Error: your note is not valid')).'</b>").fadeIn(400);
else if (r == "error:update")
$("#note_feedback").html("<b style=\"color:red\">'.addslashes($this->l('Error: cannot save your note')).'</b>").fadeIn(400);
$("#note_feedback").fadeOut(3000);
});
}
</script>';
echo '<h2>'.$this->l('Messages').' ('.sizeof($messages).')</h2>';
if (sizeof($messages))
{
echo '
<table cellspacing="0" cellpadding="0" class="table">
<tr>
<th class="center">'.$this->l('Status').'</th>
<th class="center">'.$this->l('Message').'</th>
<th class="center">'.$this->l('Sent on').'</th>
</tr>';
foreach ($messages AS $message)
echo '<tr>
<td>'.$message['status'].'</td>
<td><a href="index.php?tab=AdminCustomerThreads&id_customer_thread='.(int)($message['id_customer_thread']).'&viewcustomer_thread&token='.Tools::getAdminTokenLite('AdminCustomerThreads').'">'.substr(strip_tags(html_entity_decode($message['message'], ENT_NOQUOTES, 'UTF-8')), 0, 75).'...</a></td>
<td>'.Tools::displayDate($message['date_add'], (int)($cookie->id_lang), true).'</td>
</tr>';
echo '</table>
<div class="clear">&nbsp;</div>';
}
else
echo $customer->firstname.' '.$customer->lastname.' '.$this->l('has never contacted you.');
// display hook specified to this page : AdminCustomers
if (($hook = Module::hookExec('adminCustomers', array('id_customer' => $customer->id))) !== false)
echo '<div>'.$hook.'</div>';
echo '<div class="clear">&nbsp;</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'.(int)(Tab::getIdFromClassName('AdminGroups')).(int)($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">&nbsp;</div>';
echo '<h2>'.$this->l('Orders').' ('.sizeof($orders).')</h2>';
if ($orders AND sizeof($orders))
{
$totalOK = 0;
$ordersOK = array();
$ordersKO = array();
$tokenOrders = Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee));
foreach ($orders as $order)
if ($order['valid'])
{
$ordersOK[] = $order;
$totalOK += $order['total_paid_real'];
}
else
$ordersKO[] = $order;
$orderHead = '
<table cellspacing="0" cellpadding="0" class="table float">
<tr>
<th class="center">'.$this->l('ID').'</th>
<th class="center">'.$this->l('Date').'</th>
<th class="center">'.$this->l('Products').'</th>
<th class="center">'.$this->l('Total paid').'</th>
<th class="center">'.$this->l('Payment').'</th>
<th class="center">'.$this->l('State').'</th>
<th class="center">'.$this->l('Actions').'</th>
</tr>';
$orderFoot = '</table>';
if ($countOK = sizeof($ordersOK))
{
echo '<div style="float:left;margin-right:20px"><h3 style="color:green;font-weight:700">'.$this->l('Valid orders:').' '.$countOK.' '.$this->l('for').' '.Tools::displayPrice($totalOK, new Currency($defaultCurrency)).'</h3>'.$orderHead;
foreach ($ordersOK 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">'.$order['id_order'].'</td>
<td>'.Tools::displayDate($order['date_add'], (int)($cookie->id_lang)).'</td>
<td align="right">'.$order['nb_products'].'</td>
<td align="right">'.Tools::displayPrice($order['total_paid_real'], new Currency((int)($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 $orderFoot.'</div>';
}
if ($countKO = sizeof($ordersKO))
{
echo '<div style="float:left;margin-right:20px"><h3 style="color:red;font-weight:700">'.$this->l('Invalid orders:').' '.$countKO.'</h3>'.$orderHead;
foreach ($ordersKO 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">'.$order['id_order'].'</td>
<td>'.Tools::displayDate($order['date_add'], (int)($cookie->id_lang)).'</td>
<td align="right">'.$order['nb_products'].'</td>
<td align="right">'.Tools::displayPrice($order['total_paid_real'], new Currency((int)($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 $orderFoot.'</div><div class="clear">&nbsp;</div>';
}
}
else
echo $customer->firstname.' '.$customer->lastname.' '.$this->l('has not placed any orders yet');
if ($products AND sizeof($products))
{
echo '<div class="clear">&nbsp;</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'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($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'], (int)($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">&nbsp;</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'.(int)(Tab::getIdFromClassName('AdminAddresses')).(int)($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 not registered any addresses yet').'.';
echo '<div class="clear">&nbsp;</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'.(int)(Tab::getIdFromClassName('AdminDiscounts')).(int)($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">&nbsp;</div>';
echo '<div style="float:left">
<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'.(int)(Tab::getIdFromClassName('AdminCarts')).(int)($cookie->id_employee));
foreach ($carts AS $cart)
{
$cartI = new Cart((int)($cart['id_cart']));
$summary = $cartI->getSummaryDetails();
$currency = new Currency((int)($cart['id_currency']));
$carrier = new Carrier((int)($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'], (int)($cookie->id_lang), true).'</td>
<td align="right">'.Tools::displayPrice($summary['total_price'], $currency).'</td>
<td>'.$carrier->name.'</td>
<td align="center"><a href="index.php?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>';
$interested = Db::getInstance()->ExecuteS('SELECT DISTINCT id_product FROM '._DB_PREFIX_.'cart_product cp INNER JOIN '._DB_PREFIX_.'cart c on c.id_cart = cp.id_cart WHERE c.id_customer = '.(int)$customer->id.' AND cp.id_product NOT IN (
SELECT product_id FROM '._DB_PREFIX_.'orders o inner join '._DB_PREFIX_.'order_detail od ON o.id_order = od.id_order WHERE o.valid = 1 AND o.id_customer = '.(int)$customer->id.')');
if (count($interested))
{
echo '<div style="float:left;margin-left:20px">
<h2>'.$this->l('Products').' ('.count($interested).')</h2>
<table cellspacing="0" cellpadding="0" class="table">';
foreach ($interested as $p)
{
$product = new Product((int)$p['id_product'], false, $cookie->id_lang);
echo '
<tr '.($irow++ % 2 ? 'class="alt_row"' : '').' style="cursor: pointer" onclick="document.location = \''.$link->getProductLink((int)$product->id, $product->link_rewrite, Category::getLinkRewrite($product->id_category_default, (int)($cookie->id_lang))).'\'">
<td>'.(int)$product->id.'</td>
<td>'.Tools::htmlentitiesUTF8($product->name).'</td>
<td align="center"><a href="'.$link->getProductLink((int)$product->id, $product->link_rewrite, Category::getLinkRewrite($product->id_category_default, (int)($cookie->id_lang))).'"><img src="../img/admin/details.gif" /></a></td>
</tr>';
}
echo '</table></div>';
}
echo '<div class="clear">&nbsp;</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'], (int)($cookie->id_lang), true).'</td>
<td>'.(int)($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">&nbsp;</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'], (int)($cookie->id_lang), true).'</td>
<td>'.$referrer['name'].'</td>
</tr>';
echo '</table><div class="clear">&nbsp;</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();
if (!($obj = $this->loadObject(true)))
return;
$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" autocomplete="off">
'.($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!<>,;?=+()@#"{}_$%:<span class="hint-pointer">&nbsp;</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!<>,;?=+()@#"{}_$%:<span class="hint-pointer">&nbsp;</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>';
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="'.(int)($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('Apply non-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('Check all the box(es) of groups of which the customer is to be a 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((int)($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();
}
}
-150
View File
@@ -1,150 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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 here.');
}
if (Tools::isSubmit('submitEngine'))
{
if (!isset($_POST['tablesBox']) OR !sizeof($_POST['tablesBox']))
$this->_errors[] = Tools::displayError('You do not have select tables');
else
{
$available_engines = $this->_getEngines();
$tables_status = $this->_getTablesStatus();
$tables_engine = array();
foreach ($tables_status AS $table)
$tables_engine[$table['Name']] = $table['Engine'];
$engineType = pSQL(Tools::getValue('engineType'));
foreach ($_POST['tablesBox'] AS $table)
{
if ($engineType == $tables_engine[$table])
$this->_errors[] = $table.' '.$this->l('is already in').' '.$engineType;
else
if (!Db::getInstance()->Execute('ALTER TABLE '.pSQL($table).' ENGINE='.pSQL($engineType)))
$this->_errors[] = $this->l('Can\'t change engine for').' '.$table;
else
echo '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="'.$this->l('Confirmation').'" />'.$this->l('Engine change of').' '.$table.' '.$this->l('to').' '.$engineType.'</div>';
}
}
}
}
public function display()
{
global $currentIndex;
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');
$engines = $this->_getEngines();
$irow = 0;
echo '<br /><fieldset class="width2"><legend>'.$this->l('MySQL Engine').'</legend><form name="updateEngine" action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post"><table cellspacing="0" cellpadding="0" class="table width2 clear">
<tr><th><input type="checkbox" onclick="checkDelBoxes(this.form, \'tablesBox[]\', this.checked)" class="noborder" name="checkme"></th><th>'.$this->l('Table').'</th><th>'.$this->l('Table Engine').'</th></tr>';
$tables_status = $this->_getTablesStatus();
foreach ($tables_status AS $table)
{
if (!preg_match('/^'._DB_PREFIX_.'.*/Ui', $table['Name']))
continue;
echo '<tr class="'.($irow++ % 2 ? 'alt_row' : '').'">
<td class="noborder"><input type="checkbox" name="tablesBox[]" value="'.$table['Name'].'"/></td><td>'.$table['Name'].'</td><td>'.$table['Engine'].'</td>
</tr>';
}
echo '</table><br />
<label for="dbEngine">'.$this->l('Change Engine to').'</label>
<div class="margin-form">
<select name="engineType">';
foreach ($engines AS $engine)
echo '<option value="'.$engine.'">'.$engine.'</option>';
echo '</select>
<input style="margin-left:15px;" class="button" type="submit" value="Submit" name="submitEngine" />
</div>
</fieldset>';
}
private function _getEngines()
{
$engines = Db::getInstance()->ExecuteS('SHOW ENGINES');
$allowed_engines = array();
foreach ($engines AS $engine)
{
if (in_array($engine['Engine'], array('InnoDB', 'MyISAM')) AND in_array($engine['Support'], array('DEFAULT', 'YES')))
$allowed_engines[] = $engine['Engine'];
}
return $allowed_engines;
}
private function _getTablesStatus()
{
return Db::getInstance()->ExecuteS('SHOW TABLE STATUS');
}
}
-104
View File
@@ -1,104 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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>
<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();
}
}
-486
View File
@@ -1,486 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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` = '.(int)($cookie->id_lang).')';
$typesArray = array();
$types = Discount::getDiscountTypes((int)($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', 'align' => 'right'),
'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))
{
if (Tools::getValue('id_discount_type') == 2 AND Tools::getValue('id_currency') == 0)
$this->_errors[] = Tools::displayError('Please set a currency for this voucher.');
if (!Validate::isBool_Id(Tools::getValue('id_target')))
$this->_errors[] = Tools::displayError('Invalid customer or group ID field');
else
{
$rules = explode('_', Tools::getValue('id_target'));
/* In form, there is one field for two differents fields in object*/
$_POST[($rules[0] ? 'id_group' : 'id_customer')] = $rules[1];
}
/* Checking fields validity */
$this->validateRules();
if (!sizeof($this->_errors))
{
$id = (int)(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 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 here.');
}
}
$this->_errors = array_unique($this->_errors);
}
else
return parent::postProcess();
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
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");
$(\'#behavior_not_exhausted\').show();
}
else if ($("#id_discount_type").val() == 3)
$("#value-div").css("display", "none");
if ($(\'#id_discount_type\').val() != 2)
$(\'#behavior_not_exhausted\').hide();
}
$(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><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').' !<>,;?=+()@#"{}_$%:<span class="hint-pointer">&nbsp;</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((int)($cookie->id_lang));
foreach ($discountTypes AS $discountType)
echo '<option value="'.(int)($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 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="'.(float)($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 id="behavior_not_exhausted" style="display:none;">
<label>'.$this->l('Behavior not exhausted:').'</label>
<div class="margin-form">
<select name="behavior_not_exhausted">
<option value="1" '.($obj->behavior_not_exhausted === 1 ? 'selected="selected"' : '').'>'.$this->l('Reduce the voucher to the total order amount').'</option>
<option value="2" '.($obj->behavior_not_exhausted == 2 ? 'selected="selected"' : '').'>'.$this->l('Create a new voucher with remaining amount').'</option>
<option value="3" '.($obj->behavior_not_exhausted == 3 ? 'selected="selected"' : '').'>'.$this->l('Create negative invoice').'</option>
</select>
</div>
</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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: 600px;">
<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((int)($cookie->id_lang), false);
foreach ($indexedCategories AS $k => $row)
$index[] = $row['id_category'];
$this->recurseCategoryForInclude((int)(Tools::getValue($this->identifier)), $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 applied').'<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="'.(int)($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="'.(int)($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') ? (float)($this->getFieldValue($obj, 'minimal')) : '0').'" onkeyup="javascript:this.value = this.value.replace(/,/g, \'.\'); " /> <sup>*</sup>
<p class="clear">'.$this->l('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">
<input type="hidden" name="id_customer" value="0">
<input type="hidden" name="id_group" value="0">
<select name="id_target" id="id_target">
<option value="0_0">-- '.$this->l('All customers').' --</option>
<optgroup label="'.$this->l('Groups').'" id="id_target_group">
</optgroup>
<optgroup label="'.$this->l('Customers').'" id="id_target_customers">
</optgroup>
</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 = (int)($this->getFieldValue($obj, 'id_customer'))) ? '0_'.$value : (($value = (int)($this->getFieldValue($obj, 'id_group'))) ? '1_'.$value : '')).'\';
if ($(\'#filter\').val())
filterValue = $(\'#filter\').val();
$.getJSON("'.dirname($currentIndex).'/ajax.php",{ajaxDiscountCustomers:1,filter:filterValue},
function(obj) {
var groups_length = obj.groups.length;
if (obj.groups.length == 0)
groups_length = 1;
var customers_length = obj.customers.length;
if (obj.customers.length == 0)
customers_length = 1;
formDiscount.id_target.length = 1 + customers_length + groups_length;
if (obj.groups.length == 0)
{
formDiscount.id_target.options[1].value = -1;
formDiscount.id_target.options[1].text = \''.$this->l('No match found').'\';
formDiscount.id_target.options[1].className = "groups_filtered";
}
else
{
for (i = 0; i < obj.groups.length && i < 50; i++)
{
formDiscount.id_target.options[i+1].value = obj.groups[i]["value"];
formDiscount.id_target.options[i+1].text = obj.groups[i]["text"];
formDiscount.id_target.options[i+1].className = "groups_filtered";
}
if (obj.groups.length >= 50)
{
formDiscount.id_target.options[50].text = "'.$this->l('Too many results...',__CLASS__ , true, false).'";
formDiscount.id_target.options[50].value = "_";
formDiscount.id_target.options[50].className = "groups_filtered";
}
}
if (obj.customers.length == 0)
{
formDiscount.id_target.options[groups_length+1].value = -1;
formDiscount.id_target.options[groups_length+1].text = \''.$this->l('No match found').'\';
formDiscount.id_target.options[groups_length+1].className = "customers_filtered";
}
else
{
for (i = 0; i < obj.customers.length && i < 50; i++)
{
formDiscount.id_target.options[groups_length+1+i].value = obj.customers[i]["value"];
formDiscount.id_target.options[groups_length+1+i].text = obj.customers[i]["text"];
formDiscount.id_target.options[groups_length+1+i].className = "customers_filtered";
}
if (obj.customers.length >= 50)
{
formDiscount.id_target.options[groups_length+50+i].text = "'.$this->l('Too many results...',__CLASS__ , true, false).'";
formDiscount.id_target.options[groups_length+50+i].value = "_";
formDiscount.id_target.options[groups_length+50+i].className = "customers_filtered";
}
}
$(".groups_filtered").appendTo($("#id_target_group"));
$(".customers_filtered").appendTo($("#id_target_customers"));
if ($(\'#filter\').val())
{
if (formDiscount.id_target.options[1].value != -1)
formDiscount.id_target.options.selectedIndex = 1;
else
formDiscount.id_target.options.selectedIndex = 2;
}
else if(filterValue)
for (i = 0; i < (customers_length + groups_length); i++)
if (formDiscount.id_target.options[i+1].value == filterValue)
formDiscount.id_target.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('Display the voucher in the cart summary:').' </label>
<div class="margin-form">
<input type="radio" name="cart_display" id="cart_active_on" value="1" '.($this->getFieldValue($obj, 'cart_display') ? 'checked="checked" ' : '').'/>
<label class="t" for="cart_display_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
<input type="radio" name="cart_display" id="cart_active_off" value="0" '.(!$this->getFieldValue($obj, 'cart_display') ? 'checked="checked" ' : '').'/>
<label class="t" for="cart_display_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
</div>
<div class="clear" / >
<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
*/
public static function recurseCategoryForInclude($id_obj, $indexedCategories, $categories, $current, $id_category = 1, $id_category_default = NULL, $has_suite = array())
{
global $done;
static $irow;
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;
echo '
<tr class="'.($irow++ % 2 ? 'alt_row' : '').'">
<td>
<input type="checkbox" name="categoryBox[]" class="categoryBox'.($id_category_default == $id_category ? ' id_category_default' : '').'" id="categoryBox_'.$id_category.'" value="'.$id_category.'"'.((in_array($id_category, $indexedCategories) OR ((int)(Tools::getValue('id_category')) == $id_category AND !(int)($id_obj)) OR Tools::getIsset('adddiscount')) ? ' checked="checked"' : '').' />
</td>
<td>
'.$id_category.'
</td>
<td>';
for ($i = 2; $i < $level; $i++)
echo '<img src="../img/admin/lvl_'.$has_suite[$i - 2].'.gif" alt="" style="vertical-align: middle;"/>';
echo '<img src="../img/admin/'.($level == 1 ? 'lv1.gif' : 'lv2_'.($todo == $doneC ? 'f' : 'b').'.gif').'" alt="" style="vertical-align: middle;"/> &nbsp;
<label for="categoryBox_'.$id_category.'" class="t">'.stripslashes($current['infos']['name']).'</label></td>
</tr>';
if ($level > 1)
$has_suite[] = ($todo == $doneC ? 0 : 1);
if (isset($categories[$id_category]))
foreach ($categories[$id_category] AS $key => $row)
if ($key != 'infos')
self::recurseCategoryForInclude($id_obj, $indexedCategories, $categories, $categories[$id_category][$key], $key, $id_category_default, $has_suite);
}
}
-108
View File
@@ -1,108 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(PS_ADMIN_DIR.'/tabs/AdminPreferences.php');
class AdminEmails extends AdminPreferences
{
public function __construct()
{
global $cookie;
$this->className = 'Configuration';
$this->table = 'configuration';
foreach (Contact::getContacts((int)$cookie->id_lang) AS $contact)
$arr[] = array('email_message' => $contact['id_contact'], 'name' => $contact['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' => $arr),
'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="$(\'#SMTP_CONTAINER\').slideUp();"', 2 => 'onclick="$(\'#SMTP_CONTAINER\').slideDown();"')),
'PS_MAIL_TYPE' => array('title' => '', 'validation' => 'isGenericName', 'required' => true, 'type' => 'radio', 'choices' => array(1 => $this->l('Send e-mail as HTML'), 2 => $this->l('Send e-mail as Text'), 3 => $this->l('Both'))),
'SMTP_CONTAINER' => array('title' => '', 'type' => 'container'),
'PS_MAIL_DOMAIN' => array('title' => $this->l('Mail domain:'), 'desc' => $this->l('Fully qualified domain name (keep it empty if you do not know)'), 'validation' => 'isUrl', 'size' => 30, 'type' => 'text'),
'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' => 'isPasswd', '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) { $(\'#SMTP_CONTAINER\').hide(); }</script>'));
parent::__construct();
}
public function postProcess()
{
if (isset($_POST['submitEmail'.$this->table]))
{
if ($this->tabAccess['edit'] === '1')
{
if ($_POST['PS_MAIL_METHOD'] == 2 AND (empty($_POST['PS_MAIL_SERVER']) OR empty($_POST['PS_MAIL_SMTP_PORT'])))
$this->_errors[] = Tools::displayError('You must define a SMTP server and a SMTP port. If you do not know, use the PHP mail() function instead.');
else
$this->_postConfig($this->_fieldsEmail);
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
}
public function display() {
$this->_displayForm('email', $this->_fieldsEmail, $this->l('E-mail'), 'width2', 'email');
$this->_displayMailTest();
}
private function _displayMailTest()
{
echo '
<fieldset class="width2" style="margin-top: 10px;">
<legend><img src="../img/admin/email.gif" alt="" /> '.$this->l('Test your e-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 sent').'";
var textSendError= "'.$this->l('Error: please check your configuration').'";
var errorMail = "'.$this->l('This email address 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 test e-mail to').'</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 an e-mail test').'" onClick="verifyMail();" /><br />
<p id="mailResultCheck" style="display:none;"></p>
</div>
</div>
</fieldset>';
}
}
-223
View File
@@ -1,223 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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` = '.(int)($cookie->id_lang).')';
$profiles = Profile::getProfiles((int)($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' => 'pl!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 to 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()
{
if (!($obj = $this->loadObject(true)))
return false;
$email = $this->getFieldValue($obj, '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();
if (!($obj = $this->loadObject(true)))
return;
$profiles = Profile::getProfiles((int)($cookie->id_lang));
echo '<script type="text/javascript" src="'._PS_JS_DIR_.'/jquery/jquery-colorpicker.js"></script>
<script type="text/javascript">
var employeePage = true;
</script>
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.((int)$this->tabAccess['view'] ? '' : '&updateemployee&id_employee='.(int)$obj->id).'" method="post" enctype="multipart/form-data" autocomplete="off">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
'.((int)$this->tabAccess['view'] ? '' : '<input type="hidden" name="back" value="'.$currentIndex.'&token='.$this->token.'&updateemployee&id_employee='.(int)$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><div class="clear">&nbsp;</div>
<label>'.$this->l('Back office color:').' </label>
<div class="margin-form">';
// Note : width= fix Firefox 4 display bug related to colorpicker librarie
echo '<input type="color" width="50px" data-hex="true" class="color mColorPickerInput" name="bo_color" value="'.htmlentities($this->getFieldValue($obj, 'bo_color'), ENT_COMPAT, 'UTF-8').'" />
<p>'.$this->l('Back office background will be displayed in this color. HTML colors only (e.g.,').' "lightblue", "#CC6600")</p>
</div><div class="clear">&nbsp;</div>
<label>'.$this->l('Language:').' </label>
<div class="margin-form">
<select name="id_lang">';
foreach (Language::getLanguages() as $lang)
echo ' <option value="'.(int)$lang['id_lang'].'" '.($this->getFieldValue($obj, 'id_lang') == $lang['id_lang'] ? 'selected="selected"' : '').'>'.Tools::htmlentitiesUTF8($lang['name']).'</option>';
echo ' </select> <sup>*</sup>
</div><div class="clear">&nbsp;</div>
<label>'.$this->l('Theme:').' </label>
<div class="margin-form">
<select name="bo_theme">';
$path = dirname(__FILE__).'/../themes/';
foreach (scandir($path) as $theme)
if ($theme[0] != '.' AND file_exists($path.$theme.'/admin.css'))
echo ' <option value="'.Tools::htmlentitiesUTF8($theme).'" '.($this->getFieldValue($obj, 'bo_theme') == $theme ? 'selected="selected"' : '').'>'.Tools::htmlentitiesUTF8($theme).'</option>';
echo ' </select> <sup>*</sup>
</div>';
if ((int)$this->tabAccess['edit'])
{
echo '<div class="clear">&nbsp;</div>
<label>'.$this->l('UI mode:').' </label>
<div class="margin-form">
<input type="radio" name="bo_uimode" id="uimode_on" value="hover" '.($this->getFieldValue($obj, 'bo_uimode') == 'hover' ? 'checked="checked" ' : '').'/>
<label class="t" for="uimode_on">'.$this->l('Hover on tabs').'</label>
<input type="radio" name="bo_uimode" id="uimode_off" value="click" '.($this->getFieldValue($obj, 'bo_uimode') == 'click' ? 'checked="checked" ' : '').'/>
<label class="t" for="uimode_off">'.$this->l('Click on tabs').'</label>
</div><div class="clear">&nbsp;</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 into this Back Office').'</p>
</div>
<label>'.$this->l('Profile:').' </label>
<div class="margin-form">
<select name="id_profile">
<option value="">'.$this->l('-- Choose --').'</option>';
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>';
}
echo '<div class="clear">&nbsp;</div>
<div class="floatr">
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
</div><div class="clear">&nbsp;</div>
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
</fieldset>
</form>';
}
public function postProcess()
{
global $cookie;
if (Tools::isSubmit('deleteemployee') OR Tools::isSubmit('status') OR Tools::isSubmit('statusemployee'))
{
if ($cookie->id_employee == Tools::getValue('id_employee'))
{
$this->_errors[] = Tools::displayError('You cannot disable or delete your own account.');
return false;
}
$employee = new Employee(Tools::getValue('id_employee'));
if ($employee->isLastAdmin())
{
$this->_errors[] = Tools::displayError('You cannot disable or delete the last administrator account.');
return false;
}
}
elseif (Tools::isSubmit('submitAddemployee'))
{
$employee = new Employee(Tools::getValue('id_employee'));
if (!(int)$this->tabAccess['edit'])
$_POST['id_profile'] = $_GET['id_profile'] = $employee->id_profile;
if ($employee->isLastAdmin())
{
if (Tools::getValue('id_profile') != (int)(_PS_ADMIN_PROFILE_))
{
$this->_errors[] = Tools::displayError('You should have at least one employee in the administrator group.');
return false;
}
if (Tools::getvalue('active') == 0)
{
$this->_errors[] = Tools::displayError('You cannot disable or delete the last administrator account.');
return false;
}
}
}
return parent::postProcess();
}
}
-202
View File
@@ -1,202 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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/arrow2.gif" alt="" /> '.$this->l('Back to the features 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 a new feature').'</b></a><br />
<a href="'.$currentIndex.'&addfeature_value&token='.$this->token.'"><img src="../img/admin/add.gif" border="0" /> '.$this->l('Add a new feature value').'</a><br /><br />
'.$this->l('Click on a feature name to view its values and then click again if you want 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 = (int)($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="$(\'#features_values_'.$id.'\').slideToggle();">'.$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((int)(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>&nbsp;
<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>&nbsp;
<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();
if (!($obj = $this->loadObject(true)))
return;
echo '
<h2>'.$this->l('Add a new feature').'</h2>
<form action="'.$currentIndex.'&token='.$this->token.'"" method="post">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
<fieldset class="width2">
<legend><img src="../img/t/AdminFeatures.gif" />'.$this->l('Add a new 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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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();
}
}
-118
View File
@@ -1,118 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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();
if (!($obj = $this->loadObject(true)))
return;
echo '
<h2>'.$this->l('Add a new feature value').'</h2>
<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="width2">
<legend><img src="../img/t/AdminFeatures.gif" />'.$this->l('Add a new feature 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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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();
}
}
-196
View File
@@ -1,196 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminGenerator extends AdminTab
{
public function __construct()
{
$this->_htFile = dirname(__FILE__).'/../../.htaccess';
$this->_rbFile = dirname(__FILE__).'/../../robots.txt';
$this->_smFile = dirname(__FILE__).'/../../sitemap.xml';
$this->_rbData = $this->_getRobotsContent();
return parent::__construct();
}
public function display()
{
global $currentIndex;
$languages = Language::getLanguages(false);
// Htaccess
echo '
<form action="'.$currentIndex.'&token='.$this->token.'" method="post" enctype="multipart/form-data">
<fieldset><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 give you the ability to do URL rewriting and to catch 404 errors.').'</p>
<p>'.$this->l('If you do not have "Friendly URL" enabled when generating the ".htaccess" file, this feature won\'t be available.').'</p>';
if ($this->_checkConfiguration($this->_htFile))
echo '
<div class="clear">&nbsp;</div>
<label for="imageCacheControl">'.$this->l('Optimization').'</label>
<div class="margin-form">
<input type="checkbox" name="PS_HTACCESS_CACHE_CONTROL" id="PS_HTACCESS_CACHE_CONTROL" value="1" '.(Configuration::get('PS_HTACCESS_CACHE_CONTROL') == 1 ? 'checked="checked"' : '').' />
<p>'.$this->l('This will add directives to your .htaccess file which should improve caching and compression.').'</p>
</div>
<div class="clear">&nbsp;</div>
<label for="imageCacheControl">'.$this->l('Friendly URL').'</label>
<div class="margin-form">
<input type="checkbox" name="PS_REWRITING_SETTINGS" id="PS_REWRITING_SETTINGS" value="1" '.(Configuration::get('PS_REWRITING_SETTINGS') ? 'checked="checked"' : '').' />
<p>'.$this->l('Enable only if your server allows URL rewriting.').'</p>
</div>
<div class="clear">&nbsp;</div>
<label for="specific_configuration">'.$this->l('Specific configuration').'</label>
<div class="margin-form">
<textarea rows="10" class="width3" id="specific_configuration" name="ps_htaccess_specific">'.Configuration::get('PS_HTACCESS_SPECIFIC').'</textarea>
<p>'.$this->l('Add here the specifical directives of your hosting (SetEnv PHP_VER 5, AddType x-mapp-php5 .php...).').'</p>
</div>
<p class="clear" 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 directory').' <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><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 directory 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 you can configure to deny access to search engines for some 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)
{
if (file_exists($file))
return is_writable($file);
return is_writable(dirname($file));
}
function postProcess()
{
global $currentIndex;
if (Tools::isSubmit('submitHtaccess'))
{
if ($this->tabAccess['edit'] === '1')
{
Configuration::updateValue('PS_HTACCESS_CACHE_CONTROL', (int)Tools::getValue('PS_HTACCESS_CACHE_CONTROL'));
Configuration::updateValue('PS_REWRITING_SETTINGS', (int)Tools::getValue('PS_REWRITING_SETTINGS'));
Configuration::updateValue('PS_HTACCESS_SPECIFIC', Tools::getValue('ps_htaccess_specific'), true);
if (Tools::generateHtaccess($this->_htFile, Configuration::get('PS_REWRITING_SETTINGS'), Configuration::get('PS_HTACCESS_CACHE_CONTROL'), Tools::getValue('ps_htaccess_specific')))
Tools::redirectAdmin($currentIndex.'&conf=4&token='.$this->token);
$this->_errors[] = $this->l('Cannot write into file:').' <b>'.$this->_htFile.'</b><br />'.$this->l('Please check write permissions.');
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit 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");
// Sitemap
fwrite($writeFd, "# Sitemap\n");
if (file_exists($this->_smFile))
if (filesize($this->_smFile))
fwrite($writeFd, 'Sitemap: '.(Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://').$_SERVER['SERVER_NAME'].__PS_BASE_URI__.'sitemap.xml'."\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 here.');
}
}
public function _getRobotsContent()
{
$tab = array();
$lang_dir = 'lang-'.Language::getIsoById(Configuration::get('PS_LANG_DEFAULT')).'/';
// Directories
$tab['Directories'] = array('classes/', 'config/', 'download/', 'mails/', 'modules/', 'translations/', 'tools/', $lang_dir);
// 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-opc.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',
'*orderby=','*orderway=','*p=','*tag=','*id_currency=','*search_query=','*id_lang=','*back=','*utm_source=','*utm_medium=','*utm_campaign=','*n=');
return $tab;
}
}
-189
View File
@@ -1,189 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminGeolocation extends AdminTab
{
public function display()
{
global $currentIndex, $cookie;
echo '
<h2>'.$this->l('Geolocation').'</h2>
';
if (!$this->_isGeoLiteCityAvailable())
$this->displayWarning($this->l('In order to use Geolocation, please download').' <a href="http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz">'.$this->l('this file').'</a> '.$this->l('and decompress it into tools/geoip/ directory'));
echo '
<form method="POST" action="'.$currentIndex.'&token='.Tools::getValue('token').'">
<fieldset>
<legend><img src="../img/admin/world.gif" alt="" /> '.$this->l('Geolocation by IP').'</legend>
<label>'.$this->l('Geolocation by IP:').'</label>
<div class="margin-form">
<input type="radio" name="PS_GEOLOCATION_ENABLED" id="PS_GEOLOCATION_ENABLED_1" value="1" '.(Configuration::get('PS_GEOLOCATION_ENABLED') ? 'checked="checked"' : '').' /> <label class="t" for="PS_GEOLOCATION_ENABLED_1"><img src="../img/admin/enabled.gif" alt="" /> '.$this->l('Enabled').'</label>
<input type="radio" name="PS_GEOLOCATION_ENABLED" id="PS_GEOLOCATION_ENABLED_0" value="0" '.(!Configuration::get('PS_GEOLOCATION_ENABLED') ? 'checked="checked"' : '').' /> <label class="t" for="PS_GEOLOCATION_ENABLED_0"><img src="../img/admin/disabled.gif" alt="" /> '.$this->l('Disabled').'</label>
<p>'.$this->l('This option allows you, among other things, to restrict access to your shop for many countries. See below.').'</p>
</div>
<div class="margin-form">
<input type="submit" class="button" name="submitGeolocationConfiguration" value="'.$this->l('Save').'" />
</div>
</fieldset>
</form>
';
$allowedCountries = explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'));
echo '
<form method="POST" action="'.$currentIndex.'&token='.Tools::getValue('token').'">
<fieldset style="margin-top:10px;">
<legend><img src="../img/admin/world.gif" alt="" /> '.$this->l('Options').'</legend>
<div class="hint" style="display:block;margin-bottom:20px;">
'.$this->l('The following features are only available if you enable the Geolocation by IP feature.').'
</div>
<label>'.$this->l('Geolocation behavior for restricted countries:').'</label>
<div class="margin-form">
<select name="PS_GEOLOCATION_BEHAVIOR">
<option value="'._PS_GEOLOCATION_NO_CATALOG_.'" '.(Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_ ? 'selected' : '').'>'.$this->l('Visitors can\'t see your catalog').'</option>
<option value="'._PS_GEOLOCATION_NO_ORDER_.'" '.(Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_ ? 'selected' : '').'>'.$this->l('Visitors can see your catalog but can\'t make an order').'</option>
</select>
</div>
<div class="clear" style="margin-top:10px;"></div>
<label>'.$this->l('Geolocation behavior for undefined countries:').'</label>
<div class="margin-form">
<select name="PS_GEOLOCATION_NA_BEHAVIOR">
<option value="-1" '.(Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == -1 ? 'selected' : '').'>'.$this->l('All features are available').'</option>
<option value="'._PS_GEOLOCATION_NO_CATALOG_.'" '.(Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_ ? 'selected' : '').'>'.$this->l('Visitors can\'t see your catalog').'</option>
<option value="'._PS_GEOLOCATION_NO_ORDER_.'" '.(Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_ ? 'selected' : '').'>'.$this->l('Visitors can see your catalog but can\'t make an order').'</option>
</select>
</div>
<div class="clear" style="margin-top:10px;"></div>
<label>'.$this->l('Select countries that can access your store:').'</label>
<div class="margin-form">
<table class="table" cellspacing="0">
<thead>
<tr>
<th><input type="checkbox" name="checkAll" onclick="checkDelBoxes(this.form, \'countries[]\', this.checked)" /></th>
<th>'.$this->l('Name').'</th>
<tr>
</thead>
<tbody>
';
foreach (Country::getCountries(intval($cookie->id_lang)) AS $country)
echo '
<tr>
<td><input type="checkbox" name="countries[]" value="'.strtoupper(Tools::htmlentitiesUTF8($country['iso_code'])).'" '.(in_array(strtoupper($country['iso_code']), $allowedCountries) ? 'checked="checked"' : '').' /></td>
<td>'.Tools::htmlentitiesUTF8($country['name']).'</td>
</tr>
';
echo '
</tbody>
</table>
</div>
<div class="margin-form">
<input type="submit" class="button" name="submitGeolocationCountries" value="'.$this->l('Save').'" />
</div>
</fieldset>
</form>
<form method="POST" action="'.$currentIndex.'&token='.Tools::getValue('token').'">
<fieldset style="margin-top:10px;">
<legend><img src="../img/admin/world.gif" alt="" /> '.$this->l('Whitelist of IP addresses').'</legend>
<div class="hint" style="display:block;margin-bottom:20px;">
'.$this->l('You can add many IP addresses, these addresses will always be allowed to access your shop (e.g. Google bots IP).').'
</div>
<label for="PS_GEOLOCATION_WHITELIST">'.$this->l('Allowed IP addresses:').'</label>
<div class="margin-form">
<textarea name="PS_GEOLOCATION_WHITELIST" id="PS_GEOLOCATION_WHITELIST" cols="80" rows="30">'.Tools::htmlentitiesUTF8(str_replace(';', "\n", Configuration::get('PS_GEOLOCATION_WHITELIST'))).'</textarea>
</div>
<div class="margin-form">
<input type="submit" class="button" name="submitGeolocationWhitelist" value="'.$this->l('Save').'" />
</div>
</fieldset>
</form>
';
}
public function postProcess()
{
global $currentIndex;
if (Tools::isSubmit('submitGeolocationConfiguration'))
{
if ($this->_isGeoLiteCityAvailable())
{
Configuration::updateValue('PS_GEOLOCATION_ENABLED', intval(Tools::getValue('PS_GEOLOCATION_ENABLED')));
Tools::redirectAdmin($currentIndex.'&token='.Tools::getValue('token').'&conf=4');
}
else
$this->_errors[] = Tools::displayError('Geolocation database is unavailable.');
}
if (Tools::isSubmit('submitGeolocationCountries'))
{
if (!is_array(Tools::getValue('countries')) OR !sizeof(Tools::getValue('countries')))
$this->_errors[] = Tools::displayError('Country selection is invalid');
else
{
Configuration::updateValue('PS_GEOLOCATION_BEHAVIOR', (!(int)(Tools::getValue('PS_GEOLOCATION_BEHAVIOR')) ? _PS_GEOLOCATION_NO_CATALOG_ : _PS_GEOLOCATION_NO_ORDER_));
Configuration::updateValue('PS_GEOLOCATION_NA_BEHAVIOR', (int)Tools::getValue('PS_GEOLOCATION_NA_BEHAVIOR'));
Configuration::updateValue('PS_ALLOWED_COUNTRIES', implode(';', Tools::getValue('countries')));
Tools::redirectAdmin($currentIndex.'&token='.Tools::getValue('token').'&conf=4');
}
}
if (Tools::isSubmit('submitGeolocationWhitelist'))
{
if (!Validate::isCleanHtml(Tools::getValue('PS_GEOLOCATION_WHITELIST')))
$this->_errors[] = Tools::displayError('Invalid whitelist');
else
{
Configuration::updateValue('PS_GEOLOCATION_WHITELIST', str_replace("\n", ';', str_replace("\r", '', Tools::getValue('PS_GEOLOCATION_WHITELIST'))));
Tools::redirectAdmin($currentIndex.'&token='.Tools::getValue('token').'&conf=4');
}
}
return parent::postProcess();
}
private function _isGeoLiteCityAvailable()
{
if (file_exists(_PS_GEOIP_DIR_.'GeoLiteCity.dat'))
return true;
return false;
}
}
-335
View File
@@ -1,335 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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('Discount'), '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', 'align' => 'right'));
parent::__construct();
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
$groupReductions = $obj->id ? GroupReduction::getGroupReductions($obj->id, (int)($cookie->id_lang)) : array();
$categories = Category::getSimpleCategories((int)($cookie->id_lang));
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/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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' 0-9!<>,;?=+()@#"{}_$%:<span class="hint-pointer">&nbsp;</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">&nbsp;</div>
<label>'.$this->l('Discount:').' </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 discount on ALL shop\'s products for this group\'s members.').'</p>
</div>';
if ($obj->id)
{
echo '
<label>'.$this->l('Current category discount:').'</label>
<div class="margin-form">';
if ($groupReductions)
{
echo '<table>
<tr>
<th>'.$this->l('Category').'</th>
<th>'.$this->l('Value').'</th>
<th>'.$this->l('Action').'</th>
</tr>';
foreach ($groupReductions AS $groupReduction)
echo '
<tr>
<td>'.Tools::htmlentitiesUTF8($groupReduction['category_name']).'</td>
<td><input type="hidden" name="gr_id_group_reduction[]" value="'.(int)($groupReduction['id_group_reduction']).'" /><input type="text" name="gr_reduction[]" value="'.($groupReduction['reduction'] * 100).'" /></td>
<td><a href="'.$currentIndex.'&deleteGroupReduction&id_group_reduction='.(int)($groupReduction['id_group_reduction']).'&id_group='.(int)($obj->id).'&token='.$this->token.'"><img src="" alt="'.$this->l('Delete').'" /></a></td>
</tr>';
echo '</table>';
}
else
echo $this->l('No discount');
echo ' </div>';
}
echo '
<label>'.$this->l('Price display method:').' </label>
<div class="margin-form">
<select name="price_display_method">
<option value="'.PS_TAX_EXC.'"'.((int)($this->getFieldValue($obj, 'price_display_method')) == PS_TAX_EXC ? ' selected="selected"' : '').'>'.$this->l('Tax excluded').'</option>
<option value="'.PS_TAX_INC.'"'.((int)($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">&nbsp;</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><br />';
if ($obj->id)
{
echo '
<form action="'.$currentIndex.'&update'.$this->table.'&id_group='.$obj->id.'&token='.$this->token.'" method="post" class="width3">
<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />
<fieldset><legend><img src="../img/admin/tab-groups.gif" />'.$this->l('New group discount').'</legend>
<label>'.$this->l('Category:').' </label>
<div class="margin-form">
<select name="id_category">';
foreach ($categories AS $category)
echo ' <option value="'.(int)($category['id_category']).'">'.Tools::htmlentitiesUTF8($category['name']).'</option>';
echo ' </select><sup>*</sup>
</div>
<label>'.$this->l('Discount (in %):').' </label>
<div class="margin-form">
<input type="text" name="reduction" value="" /><sup>*</sup>
</div>
<div class="clear">&nbsp;</div>
<div class="margin-form">
<input type="submit" value="'.$this->l(' Add ').'" name="submitAddGroupReduction" 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';
if (!($obj = $this->loadObject(true)))
return;
$group = new Group((int)($obj->id));
$defaultLanguage = (int)(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[(int)($cookie->id_lang)]).'</span>
<div class="clear">&nbsp;</div>
'.$this->l('Discount:').' '.(float)($obj->reduction).$this->l('%').'
</fieldset>
<div class="clear">&nbsp;</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('Registration 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('Customer members 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'], (int)($cookie->id_lang)).'</td>
<td>'.Tools::displayDate($customer['date_add'], (int)($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'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($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'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($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'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($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('deleteGroupReduction'))
{
if ($this->tabAccess['delete'] === '1')
{
if (!$id_group_reduction = Tools::getValue('id_group_reduction'))
$this->_errors[] = Tools::displayError('Invalid group reduction ID');
else
{
$groupReduction = new GroupReduction((int)($id_group_reduction));
if (!$groupReduction->delete())
$this->_errors[] = Tools::displayError('An error occurred while deleting the group reduction');
else
Tools::redirectAdmin($currentIndex.'&update'.$this->table.'&id_group='.(int)(Tools::getValue('id_group')).'&conf=1&token='.$token);
}
}
else
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
}
if (Tools::isSubmit('submitAddGroupReduction'))
{
if ($this->tabAccess['add'] === '1')
{
if (!($obj = $this->loadObject()))
return;
$groupReduction = new GroupReduction();
if (!$id_category = Tools::getValue('id_category') OR !Validate::isUnsignedId($id_category))
$this->_errors[] = Tools::displayError('Wrong category ID');
elseif (!$reduction = Tools::getValue('reduction') OR !Validate::isPrice($reduction))
$this->_errors[] = Tools::displayError('Invalid reduction (must be a percentage)');
elseif (GroupReduction::doesExist((int)($obj->id), $id_category))
$this->_errors[] = Tools::displayError('A reduction already exists for this category.');
else
{
$groupReduction->id_category = (int)($id_category);
$groupReduction->id_group = (int)($obj->id);
$groupReduction->reduction = (float)($reduction) / 100;
if (!$groupReduction->add())
$this->_errors[] = Tools::displayError('An error occurred while adding a category group reduction.');
else
Tools::redirectAdmin($currentIndex.'&update'.$this->table.'&id_group='.(int)(Tools::getValue('id_group')).'&conf=3&token='.$this->token);
}
}
else
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
if (Tools::isSubmit('submitAddgroup'))
{
if ($this->tabAccess['add'] === '1')
{
if (Tools::getValue('reduction') > 100 OR Tools::getValue('reduction') < 0)
$this->_errors[] = Tools::displayError('Reduction value is incorrect');
else
{
$id_group_reductions = Tools::getValue('gr_id_group_reduction');
$reductions = Tools::getValue('gr_reduction');
if ($id_group_reductions)
foreach ($id_group_reductions AS $key => $id_group_reduction)
if (!Validate::isUnsignedId($id_group_reductions[$key]) OR !Validate::isPrice($reductions[$key]))
$this->_errors[] = Tools::displayError();
else
{
$groupReduction = new GroupReduction((int)($id_group_reductions[$key]));
$groupReduction->reduction = $reductions[$key] / 100;
if (!$groupReduction->update())
$this->errors[] = Tools::displayError('Cannot update group reductions');
}
if (!sizeof($this->_errors))
parent::postProcess();
}
}
else
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
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();
}
}
-422
View File
@@ -1,422 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminHome extends AdminTab
{
public function postProcess()
{
}
private function _displayOptimizationTips()
{
$rewrite = 0;
if (Configuration::get('PS_REWRITING_SETTINGS'))
{
$rewrite = 2;
if (!file_exists(dirname(__FILE__).'/../../.htaccess'))
$rewrite = 1;
else
{
$stat = stat(dirname(__FILE__).'/../../.htaccess');
if (strtotime(Db::getInstance()->getValue('SELECT date_upd FROM '._DB_PREFIX_.'configuration WHERE name = "PS_REWRITING_SETTINGS"')) > $stat['mtime'])
$rewrite = 0;
}
}
$htaccessAfterUpdate = 2;
$htaccessOptimized = (Configuration::get('PS_HTACCESS_CACHE_CONTROL') ? 2 : 0);
if (!file_exists(dirname(__FILE__).'/../../.htaccess'))
{
if (Configuration::get('PS_HTACCESS_CACHE_CONTROL'))
$htaccessOptimized = 1;
}
else
{
$stat = stat(dirname(__FILE__).'/../../.htaccess');
$dateUpdHtaccess = Db::getInstance()->getValue('SELECT date_upd FROM '._DB_PREFIX_.'configuration WHERE name = "PS_HTACCESS_CACHE_CONTROL"');
if (Configuration::get('PS_HTACCESS_CACHE_CONTROL') AND strtotime($dateUpdHtaccess) > $stat['mtime'])
$htaccessOptimized = 1;
$dateUpdate = Configuration::get('PS_LAST_SHOP_UPDATE');
if ($dateUpdate AND strtotime($dateUpdate) > $stat['mtime'])
$htaccessAfterUpdate = 0;
}
$smartyOptimized = 0;
if (!Configuration::get('PS_SMARTY_FORCE_COMPILE'))
++$smartyOptimized;
if (Configuration::get('PS_SMARTY_CACHE'))
++$smartyOptimized;
$cccOptimized = Configuration::get('PS_CSS_THEME_CACHE')
+ Configuration::get('PS_JS_THEME_CACHE')
+ Configuration::get('PS_HTML_THEME_COMPRESSION')
+ Configuration::get('PS_JS_HTML_THEME_COMPRESSION');
if ($cccOptimized == 4)
$cccOptimized = 2;
else
$cccOptimized = 1;
$shopEnabled = (Configuration::get('PS_SHOP_ENABLE') ? 2 : 1);
$lights = array(
0 => array('image'=>'error2.png','color'=>'#fbe8e8'),
1 => array('image'=>'warn2.png','color'=>'#fffac6'),
2 => array('image'=>'ok2.png','color'=>'#dffad3'));
if ($rewrite + $htaccessOptimized + $smartyOptimized + $cccOptimized + $shopEnabled + $htaccessAfterUpdate != 12)
echo '
<div class="admin-box1">
<h5>'.$this->l('A good beginning...')
.'
<span style="float:right">
<a id="optimizationTipsFold"'.
(Configuration::get('PS_HIDE_OPTIMIZATION_TIPS')
?'" href="#"><img alt="v" style="padding-top:0px; padding-right: 5px;" src="../img/admin/down-white.gif" /></a>':'href="?hideOptimizationTips" >
<img alt="X" style="padding-top:0px; padding-right: 5px;" src="../img/admin/close-white.png" />
</a>').'</span></h5>';
echo '
<script type="text/javascript">
$(document).ready(function(){
$("#optimizationTipsFold").click(function(e){
$("#list-optimization-tips").toggle(function(){
if($("#optimizationTipsFold").children("img").attr("src") == "../img/admin/down-white.gif")
$("#optimizationTipsFold").children("img").attr("src","../img/admin/close-white.png");
else
$("#optimizationTipsFold").children("img").attr("src","../img/admin/down-white.gif");
});
})
});
</script>
';
echo '<ul id="list-optimization-tips" class="admin-home-box-list" '
.(Configuration::get('PS_HIDE_OPTIMIZATION_TIPS')?'style="display:none"':'').'>
<li style="background-color:'.$lights[$rewrite]['color'].'">
<img src="../img/admin/'.$lights[$rewrite]['image'].'" class="pico" />
<a href="index.php?tab=AdminGenerator&token='.Tools::getAdminTokenLite('AdminGenerator').'">'.$this->l('URL rewriting').'</a>
</li>
<li style="background-color:'.$lights[$htaccessOptimized]['color'].'">
<img src="../img/admin/'.$lights[$htaccessOptimized]['image'].'" class="pico" />
<a href="index.php?tab=AdminGenerator&token='.Tools::getAdminTokenLite('AdminGenerator').'">'.$this->l('Browser cache & compression').'</a>
</li>
<li style="background-color:'.$lights[$smartyOptimized]['color'].'">
<img src="../img/admin/'.$lights[$smartyOptimized]['image'].'" class="pico" />
<a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'">'.$this->l('Smarty optimization').'</a></li>
<li style="background-color:'.$lights[$cccOptimized]['color'].'">
<img src="../img/admin/'.$lights[$cccOptimized]['image'].'" class="pico" />
<a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'">'.$this->l('Combine, Compress & Cache').'</a></li>
<li style="background-color:'.$lights[$shopEnabled]['color'].'">
<img src="../img/admin/'.$lights[$shopEnabled]['image'].'" class="pico" />
<a href="index.php?tab=AdminPreferences&token='.Tools::getAdminTokenLite('AdminPreferences').'">'.$this->l('Shop enabled').'</a></li>
<li style="background-color:'.$lights[$htaccessAfterUpdate]['color'].'">
<img src="../img/admin/'.$lights[$htaccessAfterUpdate]['image'].'" class="pico" />
<a href="index.php?tab=AdminGenerator&token='.Tools::getAdminTokenLite('AdminGenerator').'">'.$this->l('.htaccess up-to-date').'</a></li>
</ul>
</div>';
}
public function display()
{
global $cookie;
$tab = get_class();
$protocol = (!empty($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS']) != 'off')?'https':'http';
$isoDefault = Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT')));
$isoUser = Language::getIsoById(intval($cookie->id_lang));
$isoCountry = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
$currency = new Currency((int)(Configuration::get('PS_CURRENCY_DEFAULT')));
echo '<div>
<h1>'.$this->l('Dashboard').'</h1>
<hr style="background-color: #812143;color: #812143;" />
<br />';
if (@ini_get('allow_url_fopen') AND $update = checkPSVersion())
echo '<div class="warning warn" style="margin-bottom:30px;"><h3>'.$this->l('New PrestaShop version available').' : <a style="text-decoration: underline;" href="'.$update['link'].'">'.$this->l('Download').'&nbsp;'.$update['name'].'</a> !</h3></div>';
elseif (!@ini_get('allow_url_fopen'))
{
echo '<p>'.$this->l('Update notification unavailable').'</p>';
echo '<p>&nbsp;</p>';
echo '<p>'.$this->l('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="http://www.php.net/manual/'.$isoUser.'/ref.filesystem.php">'.$this->l('more info').'</a>]</p>';
echo '<p>'.$this->l('If you don\'t know how to do that, please contact your host administrator !').'</p><br>';
}
echo '</div>';
if (!isset($cookie->show_screencast))
$cookie->show_screencast = true;
if ($cookie->show_screencast)
echo'
<div id="adminpresentation">
<iframe src="http://screencasts.prestashop.com/screencast.php?iso_lang='.Tools::strtolower($isoUser).'" style="border:none;width:100%;height:420px;" scrolling="no"></iframe>
<div id="footer_iframe_home">
<!--<a href="#">'.$this->l('View more video tutorials').'</a>-->
<input type="checkbox" id="screencast_dont_show_again"><label for="screencast_dont_show_again">'.$this->l('don\'t show again').'</label>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$(\'#screencast_dont_show_again\').click(function() {
if ($(this).is(\':checked\'))
{
$.ajax({
type: \'POST\',
async: true,
url: \'ajax.php?toggleScreencast\',
success: function(data) {
$(\'#adminpresentation\').slideUp(\'slow\');
}
});
}
});
});
</script>
<div class="clear"></div><br />';
echo '
<div id="column_left">
<ul class="F_list clearfix">
<li id="first_block">
<h4><a href="index.php?tab=AdminCatalog&addcategory&token='.Tools::getAdminTokenLite('AdminCatalog').'">'.$this->l('New category').'</a></h4>
<p>'.$this->l('Create a new category and organize your products.').'</p>
</li>
<li id="second_block">
<h4><a href="index.php?tab=AdminCatalog&id_category=1&addproduct&token='.Tools::getAdminTokenLite('AdminCatalog').'">'.$this->l('New product').'</a></h4>
<p>'.$this->l('Fill up your catalog with new articles and attributes.').'</p>
</li>
<li id="third_block">
<h4><a href="index.php?tab=AdminStats&token='.Tools::getAdminTokenLite('AdminStats').'">'.$this->l('Statistics').'</a></h4>
<p>'.$this->l('Manage your activity with a thorough analysis of your e-shop.').'</p>
</li>
<li id="fourth_block">
<h4><a href="index.php?tab=AdminEmployees&addemployee&token='.Tools::getAdminTokenLite('AdminEmployees').'">'.$this->l('New employee').'</a></h4>
<p>'.$this->l('Add a new employee account and discharge a part of your duties of shop owner.').'</p>
</li>
</ul>
';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT SUM(o.`total_paid_real` / o.conversion_rate) as total_sales, COUNT(*) as total_orders
FROM `'._DB_PREFIX_.'orders` o
WHERE o.valid = 1
AND o.`invoice_date` BETWEEN \''.date('Y-m').'-01 00:00:00\' AND \''.date('Y-m').'-31 23:59:59\' ');
$result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT COUNT(`id_customer`) AS total_registrations
FROM `'._DB_PREFIX_.'customer` c
WHERE c.`date_add` BETWEEN \''.date('Y-m').'-01 00:00:00\' AND \''.date('Y-m').'-31 23:59:59\'');
$result3 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT SUM(pv.`counter`) AS total_viewed
FROM `'._DB_PREFIX_.'page_viewed` pv
LEFT JOIN `'._DB_PREFIX_.'date_range` dr ON pv.`id_date_range` = dr.`id_date_range`
LEFT JOIN `'._DB_PREFIX_.'page` p ON pv.`id_page` = p.`id_page`
LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON pt.`id_page_type` = p.`id_page_type`
WHERE pt.`name` = \'product.php\'
AND dr.`time_start` BETWEEN \''.date('Y-m').'-01 00:00:00\' AND \''.date('Y-m').'-31 23:59:59\'
AND dr.`time_end` BETWEEN \''.date('Y-m').'-01 00:00:00\' AND \''.date('Y-m').'-31 23:59:59\'');
$results = array_merge($result, array_merge($result2, $result3));
echo '
<div class="table_info">
<h5><a href="index.php?tab=AdminStats&token='.Tools::getAdminTokenLite('AdminStats').'">'.$this->l('View more').'</a> '.$this->l('Monthly Statistics').' </h5>
<table class="table_info_details">
<tr class="tr_odd">
<td class="td_align_left">
'.$this->l('Sales').'
</td>
<td>
'.Tools::displayPrice($results['total_sales'], $currency).'
</td>
</tr>
<tr>
<td class="td_align_left">
'.$this->l('Total registrations').'
</td>
<td>
'.(int)($results['total_registrations']).'
</td>
</tr>
<tr class="tr_odd">
<td class="td_align_left">
'.$this->l('Total orders').'
</td>
<td>
'.(int)($results['total_orders']).'
</td>
</tr>
<tr>
<td class="td_align_left">
'.$this->l('Product pages viewed').'
</td>
<td>
'.(int)($results['total_viewed']).'
</td>
</tr>
</table>
</div>
';
$all = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'customer_thread');
$unread = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'customer_thread` WHERE `status` = "open"');
$pending = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'customer_thread` WHERE `status` LIKE "%pending%"');
$close = $all - ($unread + $pending);
echo '
<div class="table_info" id="table_info_last">
<h5><a href="index.php?tab=AdminCustomerThreads&token='.Tools::getAdminTokenLite('AdminCustomerThreads').'">'.$this->l('View more').'</a> '.$this->l('Customers service').'</h5>
<table class="table_info_details">
<tr class="tr_odd">
<td class="td_align_left">
'.$this->l('Thread unread').'
</td>
<td>
'.$unread.'
</td>
</tr>
<tr>
<td class="td_align_left">
'.$this->l('Thread pending').'
</td>
<td>
'.$pending.'
</td>
</tr>
<tr class="tr_odd">
<td class="td_align_left">
'.$this->l('Thread closed').'
</td>
<td>
'.$close.'
</td>
</tr>
<tr>
<td class="td_align_left">
'.$this->l('Total thread').'
</td>
<td>
'.$all.'
</td>
</tr>
</table>
</div>
<div id="table_info_large">
<h5><a href="index.php?tab=AdminStats&token='.Tools::getAdminTokenLite('AdminStats').'">'.$this->l('View more').'</a> <strong>'.$this->l('Statistics').'</strong> / '.$this->l('Sales of the week').'</h5>
<div id="stat_google">';
define('PS_BASE_URI', __PS_BASE_URI__);
$chart = new Chart();
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT total_paid / conversion_rate as total_converted, invoice_date
FROM '._DB_PREFIX_.'orders o
WHERE valid = 1
AND invoice_date BETWEEN \''.date('Y-m-d', strtotime('-7 DAYS', time())).' 00:00:00\' AND \''.date('Y-m-d H:i:s').'\'');
foreach ($result as $row)
$chart->getCurve(1)->setPoint(strtotime($row['invoice_date']), $row['total_converted']);
$chart->setSize(580, 170);
$chart->setTimeMode(strtotime('-7 DAYS', time()), time(), 'd');
$chart->getCurve(1)->setLabel($this->l('Sales +Tx').' ('.strtoupper($currency->iso_code).')');
$chart->display();
echo ' </div>
</div>
<table cellpadding="0" cellspacing="0" id="table_customer">
<thead>
<tr>
<th class="order_id"><span class="first">'.$this->l('ID').'</span></th>
<th class="order_customer"><span>'.$this->l('Customer Name').'</span></th>
<th class="order_status"><span>'.$this->l('Status').'</span></th>
<th class="order_total"><span>'.$this->l('Total').'</span></th>
<th class="order_action"><span class="last">'.$this->l('Action').'</span></th>
<tr>
</thead>
<tbody>';
$orders = Order::getOrdersWithInformations(10);
$i = 0;
foreach ($orders AS $order)
{
$currency = Currency::getCurrency((int)$order['id_currency']);
echo '
<tr'.($i % 2 ? ' id="order_line1"' : '').'>
<td class="order_td_first order_id">'.(int)$order['id_order'].'</td>
<td class="order_customer">'.Tools::htmlentitiesUTF8($order['firstname']).' '.Tools::htmlentitiesUTF8($order['lastname']).'</td>
<td class="order_status">'.Tools::htmlentitiesUTF8($order['state_name']).'</td>
<td class="order_total">'.Tools::displayPrice((float)$order['total_paid'], $currency).'</td>
<td class="order_action">
<a href="index.php?tab=AdminOrders&id_order='.(int)$order['id_order'].'&vieworder&token='.Tools::getAdminTokenLite('AdminOrders').'" title="'.$this->l('Details').'"><img src="../img/admin/details.gif" alt="'.$this->l('See').'" /></a>
</td>
</tr>
';
$i++;
}
echo '
</tbody>
</table>
</div>
<div id="column_right">
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
url: "ajax.php",
dataType: "json",
data: "getAdminHomeElement",
success: function(json) {
$(\'#partner_preactivation\').fadeOut(\'slow\', function() {
$(\'#partner_preactivation\').html(json.partner_preactivation);
$(\'#partner_preactivation\').fadeIn(\'slow\');
});
$(\'#discover_prestashop\').fadeOut(\'slow\', function() {
$(\'#discover_prestashop\').html(json.discover_prestashop);
$(\'#discover_prestashop\').fadeIn(\'slow\');
});
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
$(\'#adminpresentation\').fadeOut(\'slow\');
$(\'#partner_preactivation\').fadeOut(\'slow\');
$(\'#discover_prestashop\').fadeOut(\'slow\');
}
});
});
</script>
<div id="partner_preactivation">
<p class="center"><img src="../img/loader.gif" alt="" /> '.translate('Loading...').'</p>
</div>
';
if (Tools::isSubmit('hideOptimizationTips'))
Configuration::updateValue('PS_HIDE_OPTIMIZATION_TIPS', 1);
$this->_displayOptimizationTips();
echo '
<div id="discover_prestashop">
<p class="center"><img src="../img/loader.gif" alt="" /> '.translate('Loading...').'</p>
</div>
</div>
<div class="clear"></div>';
echo Module::hookExec('backOfficeHome');
}
}
-100
View File
@@ -1,100 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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='.(int)(Tools::getValue('id_category')).'&addproduct&conf=4&tabs=1&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)));
// Default behavior (save and back)
Tools::redirectAdmin($currentIndex.'&id_category='.(int)(Tools::getValue('id_category')).'&conf='.(int)(Tools::getValue('conf')).'&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($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'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($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>
<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="'._THEME_PROD_DIR_.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>';
}
}
-379
View File
@@ -1,379 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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 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();
if (!($obj = $this->loadObject(true)))
return;
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">
'.($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="'.(int)($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="'.(int)($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>
<label>'.$this->l('Stores:').' </label>
<div class="margin-form">
<input type="radio" name="stores" id="stores_on" value="1" '.($this->getFieldValue($obj, 'stores') ? 'checked="checked" ' : '').'/>
<label class="t" for="stores_on"><img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" /></label>
<input type="radio" name="stores" id="stores_off" value="0" '.(!$this->getFieldValue($obj, 'stores') ? 'checked="checked" ' : '').'/>
<label class="t" for="stores_off"><img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" /></label>
<p>'.$this->l('This type will be applied to stores 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'),
'stores' => $this->l('Stores')
);
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 class="width2">
<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>
<center><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).'\');" /></center>
</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))
continue;
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', (int)($imageType['width']), (int)($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', (int)($imageType['width']), (int)($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((int)(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', (int)($imageType['width']), (int)($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(false);
$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_),
array('type' => 'stores', 'dir' => _PS_STORE_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 finishing.');
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
-381
View File
@@ -1,381 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminInformation extends AdminTab
{
private function _getTestResultHtml()
{
$html = '';
// Functions list to test with 'test_system'
$funcs = array('fopen', 'fclose', 'fread', 'fwrite', 'rename', 'file_exists', 'unlink', 'rmdir', 'mkdir', 'getcwd', 'chdir', 'chmod');
// Test list to execute (function/args)
$tests = array(
'phpversion' => false,
'upload' => false,
'system' => $funcs,
'gd' => false,
'mysql_support' => false,
'config_dir' => PS_ADMIN_DIR.'/../config/',
'tools_dir' => PS_ADMIN_DIR.'/../tools/smarty/compile',
'cache_dir' => PS_ADMIN_DIR.'/../tools/smarty/cache/',
'sitemap' => PS_ADMIN_DIR.'/../sitemap.xml',
'img_dir' => PS_ADMIN_DIR.'/../img/',
'mails_dir' => PS_ADMIN_DIR.'/../mails/',
'module_dir' => PS_ADMIN_DIR.'/../modules/',
'theme_lang_dir' => PS_ADMIN_DIR.'/../themes/'._THEME_NAME_.'/lang/',
'translations_dir' => PS_ADMIN_DIR.'/../translations/',
'customizable_products_dir' => PS_ADMIN_DIR.'/../upload/',
'virtual_products_dir' => PS_ADMIN_DIR.'/../download/'
);
$tests_op = array(
'fopen' => false,
'register_globals' => false,
'gz' => false
);
$testsErrors = array(
'phpversion' => $this->l('Update your PHP version'),
'upload' => $this->l('Configure your server to allow the upload file'),
'system' => $this->l('Configure your server to allow the creation of directories and write to files'),
'gd' => $this->l('Enable the GD library on your server'),
'mysql_support' => $this->l('Enable the MySQL support on your server'),
'config_dir' => $this->l('Set write permissions for config folder'),
'tools_dir' => $this->l('Set write permissions for tools folder'),
'cache_dir' => $this->l('Set write permissions for cache folder'),
'sitemap' => $this->l('Set write permissions for sitemap.xml file'),
'img_dir' => $this->l('Set write permissions for img folder and subfolders/recursively'),
'mails_dir' => $this->l('Set write permissions for mails folder and subfolders/recursively'),
'module_dir' => $this->l('Set write permissions for modules folder and subfolders/recursively'),
'theme_lang_dir' => $this->l('Set write permissions for themes/')._THEME_NAME_.$this->l('/lang/ folder and subfolders/recursively'),
'translations_dir' => $this->l('Set write permissions for translations folder and subfolders/recursively'),
'customizable_products_dir' => $this->l('Set write permissions for upload folder and subfolders/recursively'),
'virtual_products_dir' => $this->l('Set write permissions for download folder and subfolders/recursively'),
'fopen' => $this->l('Enable fopen on your server'),
'register_globals' => $this->l('Set PHP register global option to off'),
'gz' => $this->l('Enable GZIP compression on your server')
);
$paramsRequiredResults = self::check($tests);
$paramsOptionalResults = self::check($tests_op);
$html .= '
<p>
<b>'.$this->l('Required parameters').':</b>';
if (!in_array('fail', $paramsRequiredResults))
$html .= ' <span style="color:green;font-weight:bold;">OK</span>
</p>
';
else
{
$html .= ' <span style="color:red">'.$this->l('Please consult the following error(s)').'</span>
</p>
<ul>
';
foreach ($paramsRequiredResults AS $key => $value)
if ($value == 'fail')
$html .= '<li>'.$testsErrors[$key].'</li>';
$html .= '</ul>';
}
$html .= '
<p>
<b>'.$this->l('Optional parameters').':</b>';
if (!in_array('fail', $paramsOptionalResults))
$html .= ' <span style="color:green;font-weight:bold;">OK</span>
</p>
';
else
{
$html .= ' <span style="color:red">'.$this->l('Please consult the following error(s)').'</span>
</p>
<ul>
';
foreach ($paramsOptionalResults AS $key => $value)
if ($value == 'fail')
$html .= '<li>'.$testsErrors[$key].'</li>';
$html .= '</ul>';
}
return $html;
}
public function display()
{
global $currentIndex;
echo '
<h2>'.$this->l('Information').'</h2>
<fieldset>
<legend><img src="../img/t/AdminInformation.gif" alt="" /> '.$this->l('Help').'</legend>
<p>'.$this->l('This information must be indicated when you report a bug on our bug tracker or if you report a problem on our forum.').'</p>
</fieldset>
<br />
<fieldset>
<legend><img src="../img/t/AdminInformation.gif" alt="" /> '.$this->l('Information about your configuration').'</legend>
<h3>'.$this->l('Server information').'</h3>
<p>
<b>'.$this->l('Prestashop Version').':</b>
'._PS_VERSION_.'
</p>';
if (function_exists('php_uname'))
echo '
<p>
<b>'.$this->l('Server information').':</b>
'.php_uname('s').' '.php_uname('v').' '.php_uname('m').'
</p>';
echo '
<p>
<b>'.$this->l('Server software Version').':</b>
'.$_SERVER['SERVER_SOFTWARE'].'
</p>
<p>
<b>'.$this->l('PHP Version').':</b>
'.phpversion().'
</p>
<p>
<b>'.$this->l('MySQL Version').':</b>
'.mysql_get_server_info().'
</p>';
if (function_exists('apache_get_modules') AND in_array('mod_instaweb', apache_get_modules()))
echo '<p style="color:red;font-weight:700">'.$this->l('PageSpeed module for Apache installed (mod_instaweb)').'</p>';
echo '
<hr />
<h3>'.$this->l('Store information').'</h3>
<p>
<b>'.$this->l('URL of your website').':</b>
'.Tools::getHttpHost(true).__PS_BASE_URI__.'
</p>
<p>
<b>'.$this->l('Theme name used').':</b>
'._THEME_NAME_.'
</p>
<hr />
<h3>'.$this->l('Mail information').'</h3>
<p>
<b>'.$this->l('Mail method').':</b>
';
if (Configuration::get('PS_MAIL_METHOD') == 1)
echo $this->l('You use PHP mail() function.').'</p>';
else
{
echo $this->l('You use your own SMTP parameters').'</p>';
echo '
<p>
<b>'.$this->l('SMTP server').':</b>
'.Configuration::get('PS_MAIL_SERVER').'
</p>
<p>
<b>'.$this->l('SMTP user').':</b>
'.(Configuration::get('PS_MAIL_USER') ? $this->l('Defined') : '<span style="color:red;">'.$this->l('Not defined').'</span>').'
</p>
<p>
<b>'.$this->l('SMTP password').':</b>
'.(Configuration::get('PS_MAIL_PASSWD') ? $this->l('Defined') : '<span style="color:red;">'.$this->l('Not defined').'</span>').'
</p>
<p>
<b>'.$this->l('Encryption').':</b>
'.Configuration::get('PS_MAIL_SMTP_ENCRYPTION').'
</p>
<p>
<b>'.$this->l('Port').':</b>
'.Configuration::get('PS_MAIL_SMTP_PORT').'
</p>
';
}
echo '
<hr />
<h3>'.$this->l('Your information').'</h3>
<p>
<b>'.$this->l('Information from you').':</b>
'.$_SERVER["HTTP_USER_AGENT"].'
</p>
</fieldset>
<br />
<fieldset id="checkConfiguration">
<legend><img src="../img/t/AdminInformation.gif" alt="" /> '.$this->l('Check your configuration').'</legend>
'.self::_getTestResultHtml().'
</fieldset>
';
}
static private function check($tests)
{
$res = array();
foreach ($tests AS $key => $test)
$res[$key] = self::run($key, $test);
return $res;
}
static private function run($ptr, $arg = 0)
{
if (call_user_func(array('self', 'test_'.$ptr), $arg))
return ('ok');
return ('fail');
}
// Misc functions
static private function test_phpversion()
{
return PHP_VERSION_ID >= 50000; /* PHP version > 5.0 */
}
static private function test_mysql_support()
{
return function_exists('mysql_connect');
}
static private function test_upload()
{
return ini_get('file_uploads');
}
static private function test_fopen()
{
return ini_get('allow_url_fopen');
}
static private function test_system($funcs)
{
foreach ($funcs AS $func)
if (!function_exists($func))
return false;
return true;
}
static private function test_gd()
{
return function_exists('imagecreatetruecolor');
}
static private function test_register_globals()
{
return !ini_get('register_globals');
}
static private function test_gz()
{
if (function_exists('gzencode'))
return !(@gzencode('dd') === false);
return false;
}
// is_writable dirs
static private function test_dir($dir, $recursive = false)
{
if (!is_writable($dir) OR !$dh = opendir($dir))
return false;
if ($recursive)
{
while (($file = readdir($dh)) !== false)
if (@filetype($dir.$file) == 'dir' AND $file != '.' AND $file != '..')
if (!self::test_dir($dir.$file, true))
return false;
}
closedir($dh);
return true;
}
// is_writable files
static private function test_file($file)
{
return (file_exists($file) AND is_writable($file));
}
static private function test_config_dir($dir)
{
return self::test_dir($dir);
}
static private function test_sitemap($dir)
{
return self::test_file($dir);
}
static private function test_root_dir($dir)
{
return self::test_dir($dir);
}
static private function test_admin_dir($dir)
{
return self::test_dir($dir);
}
static private function test_img_dir($dir)
{
return self::test_dir($dir, true);
}
static private function test_module_dir($dir)
{
return self::test_dir($dir, true);
}
static private function test_tools_dir($dir)
{
return self::test_dir($dir);
}
static function test_cache_dir($dir)
{
return self::test_dir($dir);
}
static private function test_download_dir($dir)
{
return self::test_dir($dir);
}
static private function test_mails_dir($dir)
{
return self::test_dir($dir, true);
}
static private function test_translations_dir($dir)
{
return self::test_dir($dir, true);
}
static private function test_theme_lang_dir($dir)
{
return self::test_dir($dir, true);
}
static private function test_customizable_products_dir($dir)
{
return self::test_dir($dir);
}
static private function test_virtual_products_dir($dir)
{
return self::test_dir($dir);
}
}
-158
View File
@@ -1,158 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminInvoices extends AdminTab
{
public function __construct()
{
global $cookie;
$this->table = 'invoice';
$this->optionTitle = $this->l('Invoice options');
$this->_fieldsOptions = array(
'PS_INVOICE' => array('title' => $this->l('Enable invoices:'), 'desc' => $this->l('Select whether or not to activate invoices 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_START_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. Set to 0 if you wan\'t to keep the current number (#').(Order::getLastInvoiceNumber() + 1).').', 'size' => 6, 'type' => 'text', 'cast' => 'intval')
);
parent::__construct();
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
$statuses = OrderState::getOrderStates($cookie->id_lang);
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT COUNT(*) as nbOrders, (
SELECT oh.id_order_state
FROM '._DB_PREFIX_.'order_history oh
WHERE oh.id_order = o.id_order
ORDER BY oh.date_add DESC, oh.id_order_history DESC
LIMIT 1
) id_order_state
FROM '._DB_PREFIX_.'orders o
GROUP BY id_order_state');
$statusStats = array();
foreach ($result as $row)
$statusStats[$row['id_order_state']] = $row['nbOrders'];
echo '
<h2>'.$this->l('Print PDF invoices').'</h2>
<fieldset style="float:left;width:300px"><legend><img src="../img/admin/pdf.gif" alt="" /> '.$this->l('By date').'</legend>
<form action="'.$currentIndex.'&token='.$this->token.'" method="post">
<label style="width:90px">'.$this->l('From:').' </label>
<div class="margin-form" style="padding-left:100px">
<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 style="width:90px">'.$this->l('To:').' </label>
<div class="margin-form" style="padding-left:100px">
<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" style="padding-left:100px">
<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>
<fieldset style="float:left;width: 500px;margin-left:10px"><legend><img src="../img/admin/pdf.gif" alt="" /> '.$this->l('By statuses').'</legend>
<form action="'.$currentIndex.'&token='.$this->token.'" method="post">
<label style="width:90px">'.$this->l('Statuses').' :</label>
<div class="margin-form" style="padding-left:100px">
<ul>';
foreach ($statuses as $status)
echo ' <li style="list-style: none;">
<input type="checkbox" name="id_order_state[]" value="'.(int)$status['id_order_state'].'" id="id_order_state_'.(int)$status['id_order_state'].'">
<label for="id_order_state_'.(int)$status['id_order_state'].'" style="float:none;'.((isset($statusStats[$status['id_order_state']]) AND $statusStats[$status['id_order_state']]) ? '' : 'font-weight:normal;').'padding:0;text-align:left;width:100%;color:#000">
<img src="../img/admin/charged_'.($status['invoice'] ? 'ok' : 'ko').'.gif" alt="" />
'.$status['name'].' ('.((isset($statusStats[$status['id_order_state']]) AND $statusStats[$status['id_order_state']]) ? $statusStats[$status['id_order_state']] : '0').')
</label>
</li>';
echo ' </ul>
<p class="clear">'.$this->l('You can also export orders which have not been charged yet.').'(<img src="../img/admin/charged_ko.gif" alt="" />)</p>
</div>
<div class="margin-form">
<input type="submit" value="'.$this->l('Generate PDF file').'" name="submitPrint2" class="button" />
</div>
</form>
</fieldset>
<div class="clear">&nbsp;</div>';
return parent::displayForm();
}
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('submitPrint2'))
{
if (!is_array($statusArray = Tools::getValue('id_order_state')) OR !count($statusArray))
$this->_errors[] = $this->l('Invalid order statuses');
else
{
foreach ($statusArray as $id_order_state)
if (count($orders = Order::getOrderIdsByStatus((int)$id_order_state)))
Tools::redirectAdmin('pdf.php?invoices2&id_order_state='.implode('-',$statusArray).'&token='.$this->token);
$this->_errors[] = $this->l('No invoice found for this status');
}
}
elseif (Tools::isSubmit('submitOptionsinvoice'))
{
if ((int)(Tools::getValue('PS_INVOICE_START_NUMBER')) != 0 AND (int)(Tools::getValue('PS_INVOICE_START_NUMBER')) <= Order::getLastInvoiceNumber())
$this->_errors[] = $this->l('Invalid invoice number (must be > ').Order::getLastInvoiceNumber() .')';
else
parent::postProcess();
}
else
parent::postProcess();
}
}
-413
View File
@@ -1,413 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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'),
'language_code' => array('title' => $this->l('Language 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(false)),
);
parent::__construct();
}
/**
* Copy a no-product image
*
* @param string $language Language iso_code for no-picture image filename
*/
public function copyNoPictureImage($language)
{
if (isset($_FILES['no-picture']) and $_FILES['no-picture']['error'] === 0)
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('n 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);
}
}
/**
* deleteNoPictureImages will delete all default image created for the language id_language
*
* @param string $id_language
* @return boolean true if no error
*/
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_, _PS_SUPP_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 image deletion.');
if (file_exists($dir.$language.'.jpg'))
if (!unlink($dir.$language.'.jpg'))
$this->_errors[] = Tools::displayError('An error occurred during 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((int)(Tools::getValue('id_lang'))) AND $object->delete())
Tools::redirectAdmin($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 ((int)(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']) OR !empty($_FILES['flag']['tmp_name'])) AND Validate::isLanguageIsoCode(Tools::getValue('iso_code')))
{
if ($_FILES['no-picture']['error'] == UPLOAD_ERR_OK)
$this->copyNoPictureImage(strtolower(Tools::getValue('iso_code')));
parent::postProcess();
}
else
{
$this->validateRules();
$this->_errors[] = Tools::displayError('Flag and No-Picture image fields are required.');
}
}
else
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
/* Language edition */
else
{
if ($this->tabAccess['edit'] === '1')
{
if (( isset($_FILES['no-picture']) AND !$_FILES['no-picture']['error'] OR isset($_FILES['flag']) AND !$_FILES['flag']['error'])
AND Validate::isLanguageIsoCode(Tools::getValue('iso_code')))
{
if ($_FILES['no-picture']['error'] == UPLOAD_ERR_OK)
$this->copyNoPictureImage(strtolower(Tools::getValue('iso_code')));
parent::postProcess();
}
if (!Validate::isLoadedObject($object = $this->loadObject()))
die(Tools::displayError());
if ((int)($object->id) == (int)(Configuration::get('PS_LANG_DEFAULT')) AND (int)($_POST['active']) != (int)($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 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 ((int)($object->id) == (int)(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 here.');
}
elseif (Tools::isSubmit('submitOptions'.$this->table))
{
$lang = new Language((int)Tools::getValue('PS_LANG_DEFAULT'));
if (!$lang->active)
$this->_errors[] = Tools::displayError('You cannot set this language as default language because it\'s disabled');
else
return parent::postProcess();
}
else
return 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, some translations files are missing for that iso-code";
$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']) ? '-'.(int)($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 you want to delete this language?', __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();
if (!($obj = $this->loadObject(true)))
return;
echo '
<script type="text/javascript">
var langPackOk = "<img src=\"'._PS_IMG_.'admin/information.png\" alt=\"\" /> '.$this->l('A language pack is available for this ISO (name is').'";
var langPackVersion = "'.$this->l('The compatible Prestashop version for this language and your system is: ').'";
var langPackInfo = "'.$this->l('After creating the language, you can import the content of the language pack, which you can download above under "Tools - Translations"').'";
var noLangPack = "<img src=\"'._PS_IMG_.'admin/information.png\" alt=\"\" /> '.$this->l('No language 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">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
<fieldset><legend><img src="../img/admin/world.gif" />'.$this->l('Languages').'</legend>
<input type="hidden" value="'._PS_VERSION_.'" name="ps_version" id="ps_version" />
<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('Language code:').' </label>
<div class="margin-form">
<input type="text" size="10" maxlength="5" name="language_code" id="language_code" value="'.htmlentities($this->getFieldValue($obj, 'language_code'), ENT_COMPAT, 'UTF-8').'"/> <sup>*</sup>
<p>'.$this->l('Full language code (e.g., en-us, pt-br)').'</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 />';
}
}
}
-130
View File
@@ -1,130 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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 (eg. kg or lbs)'), 'validation' => 'isWeightUnit', 'required' => true, 'type' => 'text'),
'PS_DISTANCE_UNIT' => array('title' => $this->l('Distance unit:'), 'desc' => $this->l('The distance unit of your shop (eg. km or mi)'), 'validation' => 'isDistanceUnit', 'required' => true, 'type' => 'text'),
'PS_VOLUME_UNIT' => array('title' => $this->l('Volume unit:'), 'desc' => $this->l('The volume unit of your shop'), 'validation' => 'isWeightUnit', 'required' => true, 'type' => 'text'),
'PS_DIMENSION_UNIT' => array('title' => $this->l('Dimension unit:'), 'desc' => $this->l('The dimension unit of your shop (eg. cm or in)'), 'validation' => 'isDistanceUnit', 'required' => true, 'type' => 'text'));
$this->_fieldsOptions = array(
'PS_LOCALE_LANGUAGE' => array('title' => $this->l('Language locale:'), 'desc' => $this->l('Your server\'s language locale.'), 'validation' => 'isLanguageIsoCode', 'type' => 'text'),
'PS_LOCALE_COUNTRY' => array('title' => $this->l('Country locale:'), 'desc' => $this->l('Your server\'s country locale.'), 'validation' => 'isLanguageIsoCode', 'type' => 'text')
);
parent::__construct();
}
public function postProcess()
{
global $currentIndex;
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 here.');
}
elseif (Tools::isSubmit('submitLocalizationPack'))
{
if (!$pack = @Tools::file_get_contents('http://www.prestashop.com/download/localization/'.Tools::getValue('iso_localization_pack').'.xml') AND !$pack = @Tools::file_get_contents(dirname(__FILE__).'/../../localization/'.Tools::getValue('iso_localization_pack').'.xml'))
$this->_errors[] = Tools::displayError('Cannot load localization pack (from prestashop.com and from your local folder "localization")');
elseif (!$selection = Tools::getValue('selection'))
$this->_errors[] = Tools::displayError('Please select at least one content item to import.');
else
{
foreach ($selection AS $selected)
if (!Validate::isLocalizationPackSelection($selected))
{
$this->_errors[] = Tools::displayError('Invalid selection');
return ;
}
$localizationPack = new LocalizationPack();
if (!$localizationPack->loadLocalisationPack($pack, $selection))
$this->_errors = array_merge($this->_errors, $localizationPack->getErrors());
else
Tools::redirectAdmin($currentIndex.'&conf=23&token='.$this->token);
}
}
parent::postProcess();
}
public function display()
{
global $currentIndex;
$this->_displayForm('localization', $this->_fieldsLocalization, $this->l('Localization'), 'width2', 'localization');
echo '<br />
<form method="post" action="'.$currentIndex.'&token='.$this->token.'" class="width2" enctype="multipart/form-data">
<fieldset>
<legend><img src="../img/admin/localization.gif" />'.$this->l('Localization pack import').'</legend>
<div style="clear: both; padding-top: 15px;">
<label>'.$this->l('Localization pack you want to import:').'</label>
<div class="margin-form">
<select id="iso_localization_pack" name="iso_localization_pack">';
$localization_packs = @simplexml_load_file('http://www.prestashop.com/rss/localization.xml');
if (!$localization_packs)
$localization_packs = simplexml_load_file(dirname(__FILE__).'/../../localization/localization.xml');
if ($localization_packs)
foreach($localization_packs->pack as $pack)
echo '<option value="'.$pack->iso.'">'.$pack->name.'</option>';
else
echo '<option value="0">'.$this->l('Cannot connect to prestashop.com').'</option>';
echo '</select></div>
<br />
<label>'.$this->l('Content to import:').'</label>
<div class="margin-form" style="padding-top: 5px;">
<input type="checkbox" name="selection[]" value="states" checked="checked" /> '.$this->l('States').'<br />
<input type="checkbox" name="selection[]" value="taxes" checked="checked" /> '.$this->l('Taxes').'<br />
<input type="checkbox" name="selection[]" value="currencies" checked="checked" /> '.$this->l('Currencies').'<br />
<input type="checkbox" name="selection[]" value="languages" checked="checked" /> '.$this->l('Languages').'<br />
<input type="checkbox" name="selection[]" value="units" checked="checked" /> '.$this->l('Units (e.g., weight, volume, distance)').'
</div>
<div align="center" style="margin-top: 20px;">
<input type="submit" class="button" name="submitLocalizationPack" value="'.$this->l(' Import ').'" />
</div>
</div>
</fieldset>
</form>
<br />';
$this->_displayForm('options', $this->_fieldsOptions, $this->l('Advanced'), 'width2', 'localization');
}
}
-83
View File
@@ -1,83 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');
class AdminLogs extends AdminTab
{
public function __construct()
{
$this->table = 'log';
$this->className = 'Logger';
$this->lang = false;
$this->edit = false;
$this->delete = true;
$this->noLink = true;
$this->view = false;
$this->fieldsDisplay = array(
'id_log' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'severity' => array('title' => $this->l('Severity (1-4)'), 'align' => 'center', 'width' => 50),
'message' => array('title' => $this->l('Message'), 'width' => 377),
'object_type' => array('title' => $this->l('Object type'), 'width' => 75),
'object_id' => array('title' => $this->l('Object ID'), 'width' => 50),
'error_code' => array('title' => $this->l('Error code'), 'width' => 75, 'prefix' => '0x'),
'date_add' => array('title' => $this->l('Date'), 'width' => 35, 'align' => 'right', 'type' => 'datetime'));
$this->optionTitle = $this->l('Logs by e-mail');
$this->_fieldsOptions = array(
'PS_LOGS_BY_EMAIL' => array(
'title' => $this->l('Minimum severity level:'),
'desc' => $this->l('Put "5" if you don\'t want to receive any emails.').'<br />'.$this->l('Emails will be sent to the shop owner.'),
'cast' => 'intval',
'type' => 'text',
'size' => 5
)
);
parent::__construct();
}
public function displayListHeader($token = NULL)
{
echo '
<fieldset>
<legend>'.$this->l('Severity levels').'</legend>
<p>'.$this->l('Here\'s the meaning of severity levels:').'</p>
<ol>
<li style="color: green;">'.$this->l('Informative only').'</li>
<li style="color: orange;">'.$this->l('Warning').'</li>
<li style="color: orange;">'.$this->l('Error').'</li>
<li style="color: red;">'.$this->l('Major issue (crash)').'</li>
</ol>
</fieldset>';
parent::displayListHeader();
}
}
?>
-311
View File
@@ -1,311 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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((int)($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('Postcode/ 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` = '.(int)($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),
'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false)
);
$countries = Country::getCountries((int)($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 = (int)(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', (int)($imageType['width']), (int)($imageType['height']));
}
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($manufacturer = $this->loadObject(true)))
return;
$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">
'.($manufacturer->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$manufacturer->id.'" />' : '').'
<fieldset style="width: 905px;">
<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">&nbsp;</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((int)($cookie->id_lang));
$isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en');
$ad = dirname($_SERVER["PHP_SELF"]);
echo '
<script type="text/javascript">
var iso = \''.$isoTinyMCE.'\' ;
var pathCSS = \''._THEME_CSS_DIR_.'\' ;
var ad = \''.$ad.'\' ;
</script>
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tinymce.inc.js"></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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $langtags, 'mmeta_keywords');
echo ' <div class="clear"></div>
</div>
<label>'.$this->l('Enable:').' </label>
<div class="margin-form">
<input type="radio" name="active" id="active_on" value="1" '.($this->getFieldValue($manufacturer, '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($manufacturer, '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>
<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;
if (!($manufacturer = $this->loadObject()))
return;
echo '<h2>'.$manufacturer->name.'</h2>';
$products = $manufacturer->getProductsLite((int)($cookie->id_lang));
$addresses = $manufacturer->getAddresses((int)($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, (int)($cookie->id_lang));
echo '<hr />';
if (!$product->hasAttributes())
{
echo '
<div style="float:right;">
<a href="?tab=AdminCatalog&id_product='.$product->id.'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'" class="button">'.$this->l('Edit').'</a>
<a href="?tab=AdminCatalog&id_product='.$product->id.'&deleteproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'" class="button" onclick="return confirm(\''.$this->l('Delete item #', __CLASS__, TRUE).$product->id.' ?\');">'.$this->l('Delete').'</a>
</div>
<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>' : '').'
'.(!empty($product->upc) ? '<th width="120">'.$this->l('UPC:').' '.$product->upc.'</th>' : '').'
'.(Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="50">'.$this->l('Qty:').' '.$product->quantity.'</th>' : '').'
</tr>
</table>';
}
else
{
echo '
<div style="float:right;">
<a href="?tab=AdminCatalog&id_product='.$product->id.'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'" class="button">'.$this->l('Edit').'</a>
<a href="?tab=AdminCatalog&id_product='.$product->id.'&deleteproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'" class="button" onclick="return confirm(\''.$this->l('Delete item #', __CLASS__, TRUE).$product->id.' ?\');">'.$this->l('Delete').'</a>
</div>
<h3><a href="?tab=AdminCatalog&id_product='.$product->id.'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($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>
<th width="80">'.$this->l('UPC').'</th>
'.(Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="40">'.$this->l('Quantity').'</th>' : '').'
</tr>';
/* Build attributes combinaisons */
$combinaisons = $product->getAttributeCombinaisons((int)($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']]['upc'] = $combinaison['upc'];
$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>'.$product_attribute['upc'].'</td>' : '').'
<td class="right">'.$product_attribute['quantity'].'</td>
</tr>';
}
unset($combArray);
echo '</table>';
}
}
}
}
-173
View File
@@ -1,173 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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 = (int)(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 = (int)($_POST['submitFilter'.$this->table] - 1) * $limit;
$this->_list = Db::getInstance()->ExecuteS('
SELECT SQL_CALC_FOUND_ROWS 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 = '.(int)($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 '.(int)($start).','.(int)($limit));
$this->_listTotal = Db::getInstance()->getValue('SELECT FOUND_ROWS()');
$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, $currentIndex;
if (isset($_GET['ajax']) && !empty($_GET['id_cart']))
{
ob_clean();
$messages = Message::getMessagesByCartId(Tools::getValue('id_cart'), true);
echo '
<style type="text/css">
* {
font-size: 12px;
font-family: Arial,Verdana,Helvetica,sans-serif;
}
</style>
<p style="color: #CC0000; font-weight: bold;">'.$this->l('This customer has not finalized their order, however here are their messages:').'</p>';
foreach ($messages AS $message)
{
echo '
<table cellpadding="5" border="1">
<tr>
<td>'.$this->l('Cart ID:').'</td>
<td>'.(int)$message['id_cart'].'</td>
</tr>
<tr>
<td>'.$this->l('Customer ID:').'</td>
<td>'.(int)$message['id_customer'].'</td>
</tr>
<tr>
<td>'.$this->l('Date:').'</td>
<td>'.Tools::displayDate($message['date_add'], (int)$cookie->id_lang, true).'</td>
</tr>
</table>
<p>'.$this->l('Message:').' '.Tools::htmlentitiesUTF8($message['message']).'</p>
<hr size="1" noshade style="margin-bottom: 15px;" />';
}
die;
}
elseif (isset($_GET['view'.$this->table]) AND !empty($_GET['id_order']) AND $_GET['id_order'] != '--')
Tools::redirectAdmin('index.php?tab=AdminOrders&id_order='.(int)($_GET['id_order']).'&vieworder'.'&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($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" /> &nbsp;'.
Tools::displayError('Cannot display this message because the customer has not finalized their 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').'...';
foreach ($this->_list AS $k => &$item)
if ($item['id_order'] == '--')
$this->_list[$k]['last_message'] .= ' <a class="iframe" onclick="$(this).parent().attr(\'onclick\', \'return false\');" href="'.$currentIndex.'&token='.Tools::getAdminToken('AdminMessages'.(int)(Tab::getIdFromClassName('AdminMessages')).(int)($cookie->id_employee)).'&ajax=1&id_cart='.(int)$this->_list[$k]['id_cart'].'" title="'.$this->l('View details').'"><img src="../img/admin/details.gif" alt="'.$this->l('View details').'" /></a>';
echo '
<link href="'._PS_CSS_DIR_.'jquery.fancybox-1.3.4.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="'._PS_JS_DIR_.'jquery/jquery.fancybox-1.3.4.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$(\'a.iframe\').fancybox();
});
</script>';
$this->displayList();
$this->displayOptionsList();
}
}
}
-198
View File
@@ -1,198 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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),
'url_rewrite' => array('title' => $this->l('Friendly URL'), 'width' => 120)
);
global $cookie;
$this->optionTitle = $this->l('URLs Setup');
$this->_fieldsOptions = 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' => 'isUrl', 'type' => 'text', 'size' => 20, 'default' => __PS_BASE_URI__),
'PS_HOMEPAGE_PHP_SELF' => array('title' => $this->l('Homepage file'), 'desc' => $this->l('Usually "index.php", but may be different for a few hosts.'), 'type' => 'string', 'size' => 50),
'PS_SHOP_DOMAIN' => array('title' => $this->l('Shop domain name'), 'desc' => $this->l('Domain name of your shop, used as a canonical URL (e.g., www.myshop.com). Keep it blank if you don\'t know what to do.'), 'validation' => 'isUrl', 'type' => 'text', 'size' => 30, 'default' => ''),
'PS_SHOP_DOMAIN_SSL' => array('title' => $this->l('Shop domain name for SSL'), 'desc' => $this->l('Domain name for the secured area of your shop, used as a canonical URL (e.g., secure.myshop.com). Keep it blank if you don\'t know what to do.'), 'validation' => 'isUrl', 'type' => 'text', 'size' => 30, 'default' => ''),
'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'.(int)(Tab::getIdFromClassName('AdminGenerator')).(int)$cookie->id_employee).'">'.$this->l('generate a .htaccess file').'</a></p><div class="clear"></div>', 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
'PS_CANONICAL_REDIRECT' => array('title' => $this->l('Automatically redirect to Canonical url'), 'desc' => $this->l('Recommended but your theme must be compliant'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
);
if (!Tools::getValue('__PS_BASE_URI__'))
$_POST['__PS_BASE_URI__'] = __PS_BASE_URI__;
parent::__construct();
}
public function displayForm($isMainTab = true)
{
global $currentIndex;
parent::displayForm();
if (!($meta = $this->loadObject(true)))
return;
$files = Meta::getPages(true, ($meta->page ? $meta->page : false));
echo '
<form action="'.$currentIndex.'&token='.$this->token.'&submitAdd'.$this->table.'=1" method="post">
'.($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&nbsp;</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
<p class="clear">'.$this->l('Title of this page').'</p>
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'title¤description¤keywords¤url_rewrite', 'title');
echo ' </div>
<div style="clear:both;">&nbsp;</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
<p class="clear">'.$this->l('A short description').'</p>
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'title¤description¤keywords¤url_rewrite', 'description');
echo ' </div>
<div style="clear:both;">&nbsp;</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
<p class="clear">'.$this->l('List of keywords').'</p>
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'title¤description¤keywords¤url_rewrite', 'keywords');
echo ' </div>
<div style="clear:both;">&nbsp;</div>
<label>'.$this->l('Rewritten URL:').' </label>
<div class="margin-form">';
foreach ($this->_languages as $language)
echo '
<div id="url_rewrite_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
<input style="width:300px" type="text" name="url_rewrite_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($meta, 'url_rewrite', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
<p class="clear" style="width:300px">'.$this->l('Example : "contacts" for http://mysite.com/shop/contacts to redirect to http://mysite.com/shop/contact-form.php').'</p>
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'title¤description¤keywords¤url_rewrite', 'url_rewrite');
echo ' </div>
<div style="clear:both;">&nbsp;</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('submitAddmeta'))
{
$langs = Language::getLanguages(true);
$default_language = Configuration::get('PS_LANG_DEFAULT');
if (Tools::getValue('page') != 'index')
{
$defaultLangIsValidated = Validate::isLinkRewrite(Tools::getValue('url_rewrite_'.$default_language));
$englishLangIsValidated = Validate::isLinkRewrite(Tools::getValue('url_rewrite_1'));
}
else
{ // index.php can have empty rewrite rule
$defaultLangIsValidated = !Tools::getValue('url_rewrite_'.$default_language) OR Validate::isLinkRewrite(Tools::getValue('url_rewrite_'.$default_language));
$englishLangIsValidated = !Tools::getValue('url_rewrite_1') OR Validate::isLinkRewrite(Tools::getValue('url_rewrite_1'));
}
if (!$defaultLangIsValidated AND !$englishLangIsValidated)
{
$this->_errors[] = Tools::displayError('Url rewrite field must be filled at least in default or english language.');
return false;
}
foreach ($langs as $lang)
{
$current = Tools::getValue('url_rewrite_'.$lang['id_lang']);
if (strlen($current) == 0)
// Prioritize default language first
if ($defaultLangIsValidated)
$_POST['url_rewrite_'.$lang['id_lang']] = Tools::getValue('url_rewrite_'.$default_language);
else
$_POST['url_rewrite_'.$lang['id_lang']] = Tools::getValue('url_rewrite_1');
}
}
if (Tools::isSubmit('submitOptions'.$this->table))
{
$baseUrls = array();
if ($__PS_BASE_URI__ = Tools::getValue('__PS_BASE_URI__'))
$baseUrls['__PS_BASE_URI__'] = $__PS_BASE_URI__;
rewriteSettingsFile($baseUrls, NULL, NULL);
unset($this->_fieldsGeneral['__PS_BASE_URI__']);
}
if (Tools::isSubmit('submitOptions'.$this->table) OR Tools::isSubmit('submitAddmeta'))
Module::hookExec('afterSaveAdminMeta');
return parent::postProcess();
}
}
-924
View File
@@ -1,924 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(PS_ADMIN_DIR.'/../tools/tar/Archive_Tar.php');
class AdminModules extends AdminTab
{
/** @var array map with $_GET keywords and their callback */
private $map = array(
'install' => 'install',
'uninstall' => 'uninstall',
'configure' => 'getContent',
'delete' => 'delete'
);
private $listTabModules;
private $listPartnerModules = array();
private $listNativeModules = array();
private $_moduleCacheFile;
static private $MAX_DISP_AUTHOR = 20; // maximum length to display
function __construct()
{
parent::__construct ();
$this->_moduleCacheFile = _PS_ROOT_DIR_.'/config/modules_list.xml';
//refresh modules_list.xml every week
if (!$this->isFresh())
$this->refresh();
$this->listTabModules = array('administration' => $this->l('Administration'), 'advertising_marketing' => $this->l('Advertising & Marketing'),
'analytics_stats' => $this->l('Analytics & Stats'), 'billing_invoicing' => $this->l('Billing & Invoicing'), 'checkout' => $this->l('Checkout'),
'content_management' => $this->l('Content Management'), 'export' => $this->l('Export'), 'front_office_features' => $this->l('Front Office Features'),
'i18n_localization' => $this->l('I18n & Localization'), 'merchandizing' => $this->l('Merchandizing'), 'migration_tools' => $this->l('Migration Tools'),
'payments_gateways' => $this->l('Payments & Gateways'), 'payment_security' => $this->l('Payment Security'), 'pricing_promotion' => $this->l('Pricing & Promotion'),
'quick_bulk_update' => $this->l('Quick / Bulk update'), 'search_filter' => $this->l('Search & Filter'), 'seo' => $this->l('SEO'), 'shipping_logistics' => $this->l('Shipping & Logistics'),
'slideshows' => $this->l('Slideshows'), 'smart_shopping' => $this->l('Smart Shopping'), 'market_place' => $this->l('Market Place'), 'social_networks' => $this->l('Social Networks'), 'others'=> $this->l('Other Modules'));
$xmlModules = @simplexml_load_file($this->_moduleCacheFile);
foreach($xmlModules->children() as $xmlModule)
if ($xmlModule->attributes() == 'native')
foreach($xmlModule->children() as $module)
foreach($module->attributes() as $key => $value)
if ($key == 'name')
$this->listNativeModules[] = (string)$value;
if ($xmlModule->attributes() == 'partner')
foreach($xmlModule->children() as $module)
foreach($module->attributes() as $key => $value)
if ($key == 'name')
$this->listPartnerModules[] = (string)$value;
}
public function postProcess()
{
global $currentIndex, $cookie;
$id_employee = (int)($cookie->id_employee);
$filter_conf = Configuration::getMultiple(array(
'PS_SHOW_TYPE_MODULES_'.$id_employee,
'PS_SHOW_COUNTRY_MODULES_'.$id_employee,
'PS_SHOW_INSTALLED_MODULES_'.$id_employee,
'PS_SHOW_ENABLED_MODULES_'.$id_employee
));
//reset filtre
if (Tools::isSubmit('desactive') && isset($filter_conf['PS_SHOW_ENABLED_MODULES_'.$id_employee]) && $filter_conf['PS_SHOW_ENABLED_MODULES_'.$id_employee] != 'enabledDisabled')
$this->setFilterModules($filter_conf['PS_SHOW_TYPE_MODULES_'.$id_employee], $filter_conf['PS_SHOW_COUNTRY_MODULES_'.$id_employee], $filter_conf['PS_SHOW_INSTALLED_MODULES_'.$id_employee], 'disabled');
if (Tools::isSubmit('active') && isset($filter_conf['PS_SHOW_ENABLED_MODULES_'.$id_employee]) && $filter_conf['PS_SHOW_ENABLED_MODULES_'.$id_employee] != 'enabledDisabled')
$this->setFilterModules($filter_conf['PS_SHOW_TYPE_MODULES_'.$id_employee], $filter_conf['PS_SHOW_COUNTRY_MODULES_'.$id_employee], $filter_conf['PS_SHOW_INSTALLED_MODULES_'.$id_employee], 'enabled');
if (Tools::isSubmit('uninstall') && isset($filter_conf['PS_SHOW_INSTALLED_MODULES_'.$id_employee]) && $filter_conf['PS_SHOW_INSTALLED_MODULES_'.$id_employee] != 'installedUninstalled')
$this->setFilterModules($filter_conf['PS_SHOW_TYPE_MODULES_'.$id_employee], $filter_conf['PS_SHOW_COUNTRY_MODULES_'.$id_employee], 'unistalled', $filter_conf['PS_SHOW_ENABLED_MODULES_'.$id_employee]);
if (Tools::isSubmit('install') && isset($filter_conf['PS_SHOW_INSTALLED_MODULES_'.$id_employee]) && $filter_conf['PS_SHOW_INSTALLED_MODULES_'.$id_employee] != 'installedUninstalled')
$this->setFilterModules($filter_conf['PS_SHOW_TYPE_MODULES_'.$id_employee], $filter_conf['PS_SHOW_COUNTRY_MODULES_'.$id_employee], 'installed', $filter_conf['PS_SHOW_ENABLED_MODULES_'.$id_employee]);
if (Tools::isSubmit('filterModules'))
{
$this->setFilterModules(Tools::getValue('module_type'), Tools::getValue('country_module_value'), Tools::getValue('module_install'), Tools::getValue('module_status'));
Tools::redirectAdmin($currentIndex.'&token='.$this->token);
}
elseif (Tools::isSubmit('resetFilterModules'))
{
$this->resetFilterModules();
Tools::redirectAdmin($currentIndex.'&token='.$this->token);
}
if (Tools::isSubmit('active'))
{
if ($this->tabAccess['edit'] === '1')
{
$module = Module::getInstanceByName(Tools::getValue('module_name'));
if (Validate::isLoadedObject($module))
{
$module->enable();
Tools::redirectAdmin($currentIndex.'&conf=5'.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
} else
$this->_errors[] = Tools::displayError('Cannot load module object');
} else
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
elseif (Tools::isSubmit('desactive'))
{
if ($this->tabAccess['edit'] === '1')
{
$module = Module::getInstanceByName(Tools::getValue('module_name'));
if (Validate::isLoadedObject($module))
{
$module->disable();
Tools::redirectAdmin($currentIndex.'&conf=5'.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
} else
$this->_errors[] = Tools::displayError('Cannot load module object');
} else
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
elseif (Tools::isSubmit('reset'))
{
if ($this->tabAccess['edit'] === '1')
{
$module = Module::getInstanceByName(Tools::getValue('module_name'));
if (Validate::isLoadedObject($module))
{
if ($module->uninstall())
if ($module->install())
Tools::redirectAdmin($currentIndex.'&conf=21'.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
else
$this->_errors[] = Tools::displayError('Cannot install module');
else
$this->_errors[] = Tools::displayError('Cannot uninstall module');
} else
$this->_errors[] = Tools::displayError('Cannot load module object');
} else
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
/* Automatically copy a module from external URL and unarchive it in the appropriated directory */
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 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 occurred 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 here.');
}
if (Tools::isSubmit('deleteModule'))
{
if ($this->tabAccess['delete'] === '1')
{
if (Tools::getValue('module_name') != '')
{
$moduleDir = _PS_MODULE_DIR_.Tools::getValue('module_name');
$this->recursiveDeleteOnDisk($moduleDir);
Tools::redirectAdmin($currentIndex.'&conf=22&token='.$this->token.'&tab_module='.Tools::getValue('tab_module').'&module_name='.Tools::getValue('module_name'));
}
Tools::redirectAdmin($currentIndex.'&token='.$this->token);
}
else
$this->_errors[] = Tools::displayError('You do not have permission to delete 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 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 here.');
elseif ($key == 'install' AND Module::isInstalled($module->name))
$this->_errors[] = Tools::displayError('This module is already installed : ').$module->name;
elseif ($key == 'uninstall' AND !Module::isInstalled($module->name))
$this->_errors[] = Tools::displayError('This module is already uninstalled : ').$module->name;
elseif (($echo = $module->{$method}()) AND ($key == 'configure') AND Module::isInstalled($module->name))
{
$backlink = $currentIndex.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name;
$hooklink = 'index.php?tab=AdminModulesPositions&token='.Tools::getAdminTokenLite('AdminModulesPositions').'&show_modules='.(int)$module->id;
$tradlink = 'index.php?tab=AdminTranslations&token='.Tools::getAdminTokenLite('AdminTranslations').'&type=modules&lang=';
$toolbar = '
<table class="table" cellpadding="0" cellspacing="0" style="margin:auto;text-align:center">
<tr>
<th>'.$this->l('Module').' <span style="color: green;">'.$module->name.'</span></th>
<th><a href="'.$backlink.'" style="padding:5px 10px">'.$this->l('Back').'</a></th>
<th><a href="'.$hooklink.'" style="padding:5px 10px">'.$this->l('Manage hooks').'</a></th>
<th style="padding:5px 10px">'.$this->l('Manage translations:').' ';
foreach (Language::getLanguages(false) AS $language)
$toolbar .= '<a href="'.$tradlink.$language['iso_code'].'#'.$module->name.'" style="margin-left:5px"><img src="'._THEME_LANG_DIR_.$language['id_lang'].'.jpg" alt="'.$language['iso_code'].'" title="'.$language['iso_code'].'" /></a>';
$toolbar .= '
</th>
</tr>
</table>';
echo
$toolbar.'
<div class="clear">&nbsp;</div>'.$echo.'<div class="clear">&nbsp;</div>
'.$toolbar;
}
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'.(int)(Tab::getIdFromClassName('AdminPayment')).(int)($cookie->id_employee)));
}
if (sizeof($module_errors))
{
$htmlError = '';
foreach ($module_errors AS $module_error)
$htmlError .= '<li>'.$module_error.'</li>';
$htmlError .= '</ul>';
$this->_errors[] = Tools::displayError('The following module(s) were not installed successfully:'.$htmlError);
}
}
if ($return)
Tools::redirectAdmin($currentIndex.'&conf='.$return.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
}
}
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']) AND !isset($_GET['delete']) OR sizeof($this->_errors) )
$this->displayList();
}
public function displayJavascript()
{
global $currentIndex;
echo '<script type="text/javascript" src="'._PS_JS_DIR_.'jquery/jquery.autocomplete.js"></script>
<script type="text/javascript" src="'._PS_JS_DIR_.'jquery/jquery.fancybox-1.3.4.js"></script>
<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;})}
function truncate_author(author)
{
return ((author.length > '.self::$MAX_DISP_AUTHOR.') ? author.substring(0, '.self::$MAX_DISP_AUTHOR.')+"..." : author);
}
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);
}
$(\'document\').ready( function() {
$(\'input[name="filtername"]\').autocomplete(moduleList, {
minChars: 0,
width: 310,
matchContains: true,
highlightItem: true,
formatItem: function(row, i, max, term) {
return "<img src=\"../modules/"+row.name+"/logo.gif\" style=\"float:left;margin:5px\"><strong>" + row.displayName + "</strong>"+((row.author != \'\') ? " '.$this->l("by").' "+ truncate_author(row.author) :"") + "<br /><span style=\'font-size: 80%;\'>"+ row.desc +"</span>";
},
formatResult: function(row) {
return row.displayName;
}
});
$(\'input[name="filtername"]\').result(function(event, data, formatted) {
$(\'#filternameForm\').submit();
});
});
</script>';
}
public static function sortModule($a, $b)
{
if (sizeof($a) == sizeof($b)) {
return 0;
}
return (sizeof($a) < sizeof($b)) ? -1 : 1;
}
/**
* Used for retreiving author name from submited field authorModules[name]
* @param String $value value to be clean
*
* @return String cleant value: name
*/
private function _getSubmitedModuleAuthor($value)
{
$value = str_replace('authorModules[', '', $value);
$value = str_replace("\'", "'", $value);
$value = substr($value, 0, -1);
return $value;
}
/**
* Used for building option group
* @param Array $authors contains modules authors
* @param String $fieldName name of optiongroup
* @return String built comp
*/
private function _buildModuleAuthorsOptGroup(Array $authors, $fieldName = "UNDEFINED")
{
$out = '<optgroup label="'.$this->l('Authors').'">';
foreach($authors as $author_item => $status)
{
$author_item = Tools::htmlentitiesUTF8($author_item);
$disp_author = $this->_getDispAuthor($author_item);
$out .= '<option value="'.$fieldName.'['.$author_item. ']"'. (($status === "selected") ? ' selected>' : '>').$disp_author .'</option>';
}
$out .= '</optgroup>';
return $out;
}
/**
* Used for truncating author name to display it nicely
* @param String $author original author
* @return String truncated author name
*/
private function _getDispAuthor($author)
{
return ((strlen($author) > self::$MAX_DISP_AUTHOR) ? substr($author, 0, self::$MAX_DISP_AUTHOR).'...' : $author);
}
public function displayList()
{
global $currentIndex, $cookie;
$modulesAuthors = array();
$autocompleteList = 'var moduleList = [';
$showTypeModules = Configuration::get('PS_SHOW_TYPE_MODULES_'.(int)($cookie->id_employee));
$showInstalledModules = Configuration::get('PS_SHOW_INSTALLED_MODULES_'.(int)($cookie->id_employee));
$showEnabledModules = Configuration::get('PS_SHOW_ENABLED_MODULES_'.(int)($cookie->id_employee));
$showCountryModules = Configuration::get('PS_SHOW_COUNTRY_MODULES_'.(int)($cookie->id_employee));
$nameCountryDefault = Country::getNameById($cookie->id_lang, Configuration::get('PS_COUNTRY_DEFAULT'));
$isoCountryDefault = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
$serialModules = '';
$modules = Module::getModulesOnDisk(true);
foreach ($modules AS $module)
{
if (!in_array($module->name, $this->listNativeModules))
$serialModules .= $module->name.' '.$module->version.'-'.($module->active ? 'a' : 'i')."\n";
$moduleAuthor = $module->author;
if (!empty($moduleAuthor)&& ($moduleAuthor != ""))
$modulesAuthors[(string)$moduleAuthor] = true;
}
$serialModules = urlencode($serialModules);
$filterName = Tools::getValue('filtername');
if (!empty($filterName))
{
echo '
<script type="text/javascript">
$(document).ready(function() {
$(\'#all_open\').hide();
$(\'#all_close\').show();
$(\'.tab_module_content\').each(function(){
$(this).slideDown();
$(\'.header_module_img\').each(function(){
$(this).attr(\'src\', \'../img/admin/less.png\');
});
});
});
</script>';
}
//filter module list
foreach($modules as $key => $module)
{
switch ($showTypeModules)
{
case 'nativeModules':
if (!in_array($module->name, $this->listNativeModules))
unset($modules[$key]);
break;
case 'partnerModules':
if (!in_array($module->name, $this->listPartnerModules))
unset($modules[$key]);
break;
case 'otherModules':
if (in_array($module->name, $this->listPartnerModules) OR in_array($module->name, $this->listNativeModules))
unset($modules[$key]);
break;
default:
if (strpos($showTypeModules, 'authorModules[') !== false)
{
$author_selected = $this->_getSubmitedModuleAuthor($showTypeModules);
$modulesAuthors[$author_selected] = 'selected'; // setting selected author in authors set
if (empty($module->author) || $module->author != $author_selected)
unset($modules[$key]);
}
break;
}
switch ($showInstalledModules)
{
case 'installed':
if (!$module->id)
unset($modules[$key]);
break;
case 'unistalled':
if ($module->id)
unset($modules[$key]);
break;
}
switch ($showEnabledModules)
{
case 'enabled':
if (!$module->active)
unset($modules[$key]);
break;
case 'disabled':
if ($module->active)
unset($modules[$key]);
break;
}
if ($showCountryModules)
if (isset($module->limited_countries) AND ((is_array($module->limited_countries) AND sizeof($module->limited_countries) AND !in_array(strtolower($isoCountryDefault), $module->limited_countries)) OR (!is_array($module->limited_countries) AND strtolower($isoCountryDefault) != strval($module->limited_countries))))
unset($modules[$key]);
if (!empty($filterName))
if (stristr($module->name, $filterName) === false AND stristr($module->displayName, $filterName) === false AND stristr($module->description, $filterName) === false)
unset($modules[$key]);
}
foreach($modules as $module)
$autocompleteList .= Tools::jsonEncode(array(
'displayName' => (string)$module->displayName,
'desc' => (string)$module->description,
'name' => (string)$module->name,
'author' => (string)$module->author
)).', ';
$autocompleteList = rtrim($autocompleteList, ' ,').'];';
// Display CSS Fancy Box
echo '<link href="'._PS_CSS_DIR_.'jquery.fancybox-1.3.4.css" rel="stylesheet" type="text/css" media="screen" />';
echo '<script type="text/javascript">'.$autocompleteList.'</script>';
$this->displayJavascript();
echo '
<span onclick="$(\'#module_install\').slideToggle()" style="cursor:pointer"><img src="../img/admin/add.gif" alt="'.$this->l('Add a new module').'" class="middle" />
'.$this->l('Add a module from my computer').'
</span>
&nbsp;|&nbsp;';
if (@fsockopen('www.prestashop.com', 80))
echo '<a href="index.php?tab=AdminAddonsMyAccount&token='.Tools::getAdminTokenLite('AdminAddonsMyAccount').'">
<img src="http://addons.prestashop.com/modules.php?'.(isset($_SERVER['SERVER_ADDR']) ? 'server='.ip2long($_SERVER['SERVER_ADDR']).'&' : '').'mods='.$serialModules.'" alt="Add" class="middle" />
'.$this->l('Add a module from PrestaShop Addons').'
</a>';
echo '<form action="'.$currentIndex.'&token='.$this->token.'" method="post" id="filternameForm" style="float:right"><input type="text" name="filtername" value="'.Tools::htmlentitiesUTF8(Tools::getValue('filtername')).'" /> <input type="submit" value="'.$this->l('Search').'" class="button" /></form>
<div class="clear">&nbsp;</div>
<div id="module_install" style="width:900px; '.((Tools::isSubmit('submitDownload') OR Tools::isSubmit('submitDownload2')) ? '' : 'display: none;').'">
<fieldset>
<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 />
<div style="float:right;margin-right:50px;border-left:solid 1px #DFD5C3">
<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>
</div>
<div>
<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>
</div>
</fieldset>
<br />
</div>';
if (Configuration::get('PRESTASTORE_LIVE'))
echo '
<div id="prestastore" style="margin-left:40px; display:none; float: left" class="width1">
</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) AND array_key_exists(strval($module->tab), $this->listTabModules)) ? strval($module->tab) : 'others' ][] = $module;
uasort($orderModule,array('AdminModules', 'sortModule'));
$concatWarning = array();
foreach ($orderModule AS $tabModule)
foreach ($tabModule AS $module)
if ($module->active AND $module->warning)
$warnings[] ='<a href="'.$currentIndex.'&configure='.urlencode($module->name).'&token='.$this->token.'">'.$module->displayName.'</a> - '.stripslashes(pSQL($module->warning));
$this->displayWarning($warnings);
echo '<form method="POST">
<table cellpadding="0" cellspacing="0" style="width:100%;;margin-bottom:5px;">
<tr>
<th style="border-right:solid 1px;border:inherit">
<span class="button" style="padding:0.4em;">
<a id="all_open" class="module_toggle_all" style="display:inherit;text-decoration:none;" href="#">
<span style="padding-right:0.5em">
<img src="../img/admin/more.png" alt="" />
</span>
<span id="all_open">'.$this->l('Open all tabs').'</span>
</a>
<a id="all_close" class="module_toggle_all" style="display:none;text-decoration:none;" href="#">
<span style="padding-right:0.5em">
<img src="../img/admin/less.png" alt="" />
</span>
<span id="all_open">'.$this->l('Close all tabs').'</span>
</a>
</span>
</th>
<th colspan="3" style="border:inherit">
<select name="module_type">
<option value="allModules" '.($showTypeModules == 'allModules' ? 'selected="selected"' : '').'>'.$this->l('All Modules').'</option>
<option value="nativeModules" '.($showTypeModules == 'nativeModules' ? 'selected="selected"' : '').'>'.$this->l('Native Modules').'</option>
<option value="partnerModules" '.($showTypeModules == 'partnerModules' ? 'selected="selected"' : '').'>'.$this->l('Partners Modules').'</option>'
.$this->_buildModuleAuthorsOptGroup($modulesAuthors, 'authorModules')
.'
<option value="otherModules" '.($showTypeModules == 'otherModules' ? 'selected="selected"' : '').'>'.$this->l('Others Modules').'</option>
</select>
&nbsp;
<select name="module_install">
<option value="installedUninstalled" '.($showInstalledModules == 'installedUninstalled' ? 'selected="selected"' : '').'>'.$this->l('Installed & Uninstalled').'</option>
<option value="installed" '.($showInstalledModules == 'installed' ? 'selected="selected"' : '').'>'.$this->l('Installed Modules').'</option>
<option value="unistalled" '.($showInstalledModules == 'unistalled' ? 'selected="selected"' : '').'>'.$this->l('Uninstalled Modules').'</option>
</select>
&nbsp;
<select name="module_status">
<option value="enabledDisabled" '.($showEnabledModules == 'enabledDisabled' ? 'selected="selected"' : '').'>'.$this->l('Enabled & Disabled').'</option>
<option value="enabled" '.($showEnabledModules == 'enabled' ? 'selected="selected"' : '').'>'.$this->l('Enabled Modules').'</option>
<option value="disabled" '.($showEnabledModules == 'disabled' ? 'selected="selected"' : '').'>'.$this->l('Disabled Modules').'</option>
</select>
&nbsp;
<select name="country_module_value">
<option value="0" >'.$this->l('All countries').'</option>
<option value="1" '.($showCountryModules == 1 ? 'selected="selected"' : '').'>'.$this->l('Current country:').' '.$nameCountryDefault.'</option>
</select>
</th>
<th style="border:inherit">
<div style="float:right">
<input type="submit" class="button" name="resetFilterModules" value="'.$this->l('Reset').'">
<input type="submit" class="button" name="filterModules" value="'.$this->l('Filter').'">
</div>
</th>
</tr>
</table>
</form>';
echo $this->displaySelectedFilter();
if ($tab_module = Tools::getValue('tab_module'))
if (array_key_exists($tab_module, $this->listTabModules))
$goto = $tab_module;
else
$goto = 'others';
else
$goto = false;
echo '
<script src="'.__PS_BASE_URI__.'js/jquery/jquery.scrollTo-1.4.2-min.js"></script>
<script>
$(document).ready(function() {
$(\'.header_module_toggle, .module_toggle_all\').unbind(\'click\').click(function(){
var id = $(this).attr(\'id\');
if (id == \'all_open\')
$(\'.tab_module_content\').each(function(){
$(this).slideDown();
$(\'#all_open\').hide();
$(\'#all_close\').show();
$(\'.header_module_img\').each(function(){
$(this).attr(\'src\', \'../img/admin/less.png\');
});
});
else if (id == \'all_close\')
$(\'.tab_module_content\').each(function(){
$(\'#all_open\').show();
$(\'#all_close\').hide();
$(this).slideUp();
$(\'.header_module_img\').each(function(){
$(this).attr(\'src\', \'../img/admin/more.png\');
});
});
else
{
if ($(\'#\'+id+\'_content\').css(\'display\') == \'none\')
$(\'#\'+id+\'_img\').attr(\'src\', \'../img/admin/less.png\');
else
$(\'#\'+id+\'_img\').attr(\'src\', \'../img/admin/more.png\');
$(\'#\'+$(this).attr(\'id\')+\'_content\').slideToggle();
}
return false;
});
'.(!$goto ? '': '$(\'#'.$goto.'_content\').slideToggle( function (){
$(\'#'.$goto.'_img\').attr(\'src\', \'../img/admin/less.png\');
'.(!$goto ? '' : '$.scrollTo($("#modgo_'.Tools::getValue('module_name').'"), 300 ,
{onAfter:function(){
$("#modgo_'.Tools::getValue('module_name').'").fadeTo(100, 0, function (){
$(this).fadeTo(100, 0, function (){
$(this).fadeTo(50, 1, function (){
$(this).fadeTo(50, 0, function (){
$(this).fadeTo(50, 1 )}
)}
)}
)}
)}
});').'
});').'
});
</script>';
if (!empty($orderModule))
{
/* Browse modules by tab type */
foreach ($orderModule AS $tab => $tabModule)
{
echo '
<div id="'.$tab.'" class="header_module">
<span class="nbr_module" style="width:100px;text-align:right">'.sizeof($tabModule).' '.((sizeof($tabModule) > 1) ? $this->l('modules') : $this->l('module')).'</span>
<a class="header_module_toggle" id="'.$tab.'" href="modgo_'.$tab.'" style="margin-left: 5px;">
<span style="padding-right:0.5em">
<img class="header_module_img" id="'.$tab.'_img" src="../img/admin/more.png" alt="" />
</span>'.$this->listTabModules[$tab].'</a>
</div>
<div id="'.$tab.'_content" class="tab_module_content" style="display:none;border:solid 1px #CCC">';
/* Display modules for each tab type */
foreach ($tabModule as $module)
{
echo '<div id="modgo_'.$module->name.'" >';
if ($module->id)
{
$img = '<img src="../img/admin/module_install.png" alt="'.$this->l('Module enabled').'" title="'.$this->l('Module enabled').'" />';
if ($module->warning)
$img = '<img src="../img/admin/module_warning.png" alt="'.$this->l('Module installed but with warnings').'" title="'.$this->l('Module installed but with warnings').'" />';
if (!$module->active)
$img = '<img src="../img/admin/module_disabled.png" alt="'.$this->l('Module disabled').'" title="'.$this->l('Module disabled').'" />';
} else
$img = '<img src="../img/admin/module_notinstall.png" alt="'.$this->l('Module not installed').'" title="'.$this->l('Module not installed').'" />';
$disp_author = $this->_getDispAuthor($module->author);
$disp_author = (empty($disp_author)) ? '' : ' '.$this->l('by').' <i>'.Tools::htmlentitiesUTF8($disp_author).'</i>';
echo '<table style="width:100%" cellpadding="0" cellspacing="0" >
<tr'.($irow % 2 ? ' class="alt_row"' : '').' style="height: 42px;">
<td style="padding-right: 10px;padding-left:10px;width:30px">
<input type="checkbox" name="modules" value="'.urlencode($module->name).'" '.(empty($module->confirmUninstall) ? 'rel="false"' : 'rel="'.addslashes($module->confirmUninstall).'"').' />
</td>
<td style="padding:2px 4px 2px 10px;width:500px"><img src="../modules/'.$module->name.'/logo.gif" alt="" /> <b>'.stripslashes($module->displayName).'</b>'.($module->version ? ' v'.$module->version.(strpos($module->version, '.') !== false ? '' : '.0') : '').$disp_author.'<br />'.stripslashes($module->description).'</td>
<td rowspan="2">';
if (Tools::getValue('module_name') == $module->name)
$this->displayConf();
echo '</td>
<td class="center" style="width:60px" rowspan="2">';
if ($module->id)
echo '<a href="'.$currentIndex.'&token='.$this->token.'&module_name='.$module->name.'&'.($module->active ? 'desactive' : 'active').'">';
echo $img;
if ($module->id)
'</a>';
$href = $currentIndex.'&uninstall='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name;
echo '
</td>
<td class="center" width="120" rowspan="2">'.((!$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.'&tab_module='.$module->tab.'&module_name='.$module->name.'\'">'
: '<input type="button" class="button small" name="Uninstall" value="'.$this->l('Uninstall').'"
onclick="'.((!method_exists($module, 'onclickOption')) ? ((empty($module->confirmUninstall)) ? '' : 'if(confirm(\''.addslashes($module->confirmUninstall).'\')) ').'document.location.href=\''.$href.'\'' : $module->onclickOption('uninstall', $href)).'">').'</td>
</tr>
<tr'.($irow++ % 2 ? ' class="alt_row"' : '').'>
<td style="padding-left:50px;padding-bottom:5px;padding-top:5px" colspan="2">'.$this->displayOptions($module).'</td>
</tr>
</table>
</div>';
}
echo '</div>';
}
echo '
<div style="margin-top: 12px; width:600px;">
<input type="button" class="button big" value="'.$this->l('Install the selection').'" onclick="modules_management(\'install\')"/>
<input type="button" class="button big" value="'.$this->l('Uninstall the selection').'" onclick="modules_management(\'uninstall\')" />
</div>
<br />
<table cellpadding="0" cellspacing="0" class="table" style="width:100%;">
<tr style="height:35px;background-color:#EEEEEE">
<td><strong>'.$this->l('Icon legend').' : </strong></td>
<td style="text-align:center;border-right:solid 1px gray"><img src="../img/admin/module_install.png" />&nbsp;&nbsp;'.$this->l('Module installed and enabled').'</td>
<td style="text-align:center;border-right:solid 1px gray"><img src="../img/admin/module_disabled.png" />&nbsp;&nbsp;'.$this->l('Module installed but disabled').'</td>
<td style="text-align:center;border-right:solid 1px gray"><img src="../img/admin/module_warning.png" />&nbsp;&nbsp;'.$this->l('Module installed but with warnings').'</td>
<td style="text-align:center"><img src="../img/admin/module_notinstall.png" />&nbsp;&nbsp;'.$this->l('Module not installed').'</td>
</tr>
</table>
<div style="clear:both">&nbsp;</div>';
}
else
echo '<table cellpadding="0" cellspacing="0" class="table" style="width:100%;"><tr><td align="center">'.$this->l('No module found').'</td></tr></table>';
}
public function recursiveDeleteOnDisk($dir)
{
if (is_dir($dir))
{
$objects = scandir($dir);
foreach ($objects as $object)
if ($object != "." && $object != "..")
{
if (filetype($dir."/".$object) == "dir")
$this->recursiveDeleteOnDisk($dir."/".$object);
else
unlink($dir."/".$object);
}
reset($objects);
rmdir($dir);
}
}
public function displayOptions($module)
{
global $currentIndex;
$return = '';
$href = $currentIndex.'&token='.$this->token.'&module_name='.
urlencode($module->name).'&tab_module='.$module->tab;
if ((int)($module->id))
$return .= '<a class="action_module" '.($module->active && method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('desactive', $href).'"' : '').' href="'.$currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&'.($module->active ? 'desactive' : 'active').'&tab_module='.$module->tab.'&module_name='.urlencode($module->name).'">'.($module->active ? $this->l('Disable') : $this->l('Enable')).'</a>&nbsp;&nbsp;';
if ((int)($module->id) AND $module->active)
$return .= '<a class="action_module" '.(method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('reset', $href).'"' : '').' href="'.$currentIndex.'&token='.$this->token.'&module_name='.urlencode($module->name).'&reset&tab_module='.$module->tab.'&module_name='.urlencode($module->name).'">'.$this->l('Reset').'</a>&nbsp;&nbsp;';
if ((int)($module->id) AND (method_exists($module, 'getContent') OR (isset($module->is_configurable) AND (int)$module->is_configurable)))
$return .= '<a class="action_module" '.(method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('configure', $href).'"' : '').' href="'.$currentIndex.'&configure='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name).'">'.$this->l('Configure').'</a>&nbsp;&nbsp;';
$return .= '<a class="action_module" '.(method_exists($module, 'onclickOption')? 'onclick="'.$module->onclickOption('delete', $href).'"' : '').' onclick="return confirm(\''.$this->l('This action will permanently remove the module from the server. Are you sure you want to do this ?').'\');" href="'.$currentIndex.'&deleteModule='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.urlencode($module->name).'">'.$this->l('Delete').'</a>&nbsp;&nbsp;';
return $return;
}
public function isFresh($timeout = 604800000)
{
if (file_exists($this->_moduleCacheFile))
return ((time() - filemtime($this->_moduleCacheFile)) < $timeout);
else
return false;
}
public function refresh()
{
return file_put_contents($this->_moduleCacheFile, Tools::file_get_contents('http://www.prestashop.com/xml/modules_list.xml'));
}
public function displaySelectedFilter()
{
global $cookie;
$selected_filter = '';
$id_employee = (int)($cookie->id_employee);
$showTypeModules = Configuration::get('PS_SHOW_TYPE_MODULES_'.(int)($cookie->id_employee));
$showInstalledModules = Configuration::get('PS_SHOW_INSTALLED_MODULES_'.(int)($cookie->id_employee));
$showEnabledModules = Configuration::get('PS_SHOW_ENABLED_MODULES_'.(int)($cookie->id_employee));
$showCountryModules = Configuration::get('PS_SHOW_COUNTRY_MODULES_'.(int)($cookie->id_employee));
$selected_filter .= ($showTypeModules == 'allModules' ? $this->l('All Modules').' - ' : '').
($showTypeModules == 'nativeModules' ? $this->l('Native Modules').' - ' : '').
($showTypeModules == 'partnerModules' ? $this->l('Partners Modules').' - ' : '').
($showTypeModules == 'otherModules' ? $this->l('Others Modules').' - ' : '').
($showInstalledModules == 'installedUninstalled' ? $this->l('Installed & Uninstalled').' - ' : '').
($showInstalledModules == 'installed' ? $this->l('Installed Modules').' - ' : '').
($showInstalledModules == 'unistalled' ? $this->l('Uninstalled Modules').' - ' : '').
($showEnabledModules == 'enabledDisabled' ? $this->l('Enabled & Disabled').' - ' : '').
($showEnabledModules == 'enabled' ? $this->l('Enabled Modules').' - ' : '').
($showEnabledModules == 'disabled' ? $this->l('Disabled Modules').' - ' : '').
($showCountryModules === 1 ? $this->l('Current country:').' '.$nameCountryDefault.' - ' : '').
($showCountryModules === 0 ? $this->l('All countries').' - ' : '');
if (strlen($selected_filter) != 0)
$selected_filter = '<div class="hint" style="display:block;background:#DDE9F7 no-repeat 6px 5px url(../img/admin/filter.png);"><b>'.$this->l('Selected filters').' : </b>'.rtrim($selected_filter, ' - ').'</div>';
return $selected_filter;
}
private function setFilterModules($module_type, $country_module_value, $module_install, $module_status)
{
global $cookie;
Configuration::updateValue('PS_SHOW_TYPE_MODULES_'.(int)($cookie->id_employee), $module_type);
Configuration::updateValue('PS_SHOW_COUNTRY_MODULES_'.(int)($cookie->id_employee), $country_module_value);
Configuration::updateValue('PS_SHOW_INSTALLED_MODULES_'.(int)($cookie->id_employee), $module_install);
Configuration::updateValue('PS_SHOW_ENABLED_MODULES_'.(int)($cookie->id_employee), $module_status);
}
private function resetFilterModules()
{
global $cookie;
Configuration::updateValue('PS_SHOW_TYPE_MODULES_'.(int)($cookie->id_employee), 'allModules');
Configuration::updateValue('PS_SHOW_COUNTRY_MODULES_'.(int)($cookie->id_employee), 0);
Configuration::updateValue('PS_SHOW_INSTALLED_MODULES_'.(int)($cookie->id_employee), 'installedUninstalled');
Configuration::updateValue('PS_SHOW_ENABLED_MODULES_'.(int)($cookie->id_employee), 'enabledDisabled');
}
}
-385
View File
@@ -1,385 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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 = (int)(Tools::getValue('show_modules'));
// Change position in hook
if (array_key_exists('changePosition', $_GET))
{
if ($this->tabAccess['edit'] === '1')
{
$id_module = (int)(Tools::getValue('id_module'));
$id_hook = (int)(Tools::getValue('id_hook'));
$module = Module::getInstanceById($id_module);
if (Validate::isLoadedObject($module))
{
$module->updatePosition($id_hook, (int)(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 here.');
}
// Add new module in hook
elseif (Tools::isSubmit('submitAddToHook'))
{
if ($this->tabAccess['add'] === '1')
{
// Getting vars...
$id_module = (int)(Tools::getValue('id_module'));
$module = Module::getInstanceById($id_module);
$id_hook = (int)(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.');
elseif (!$module->isHookableOn($hook->name))
$this->_errors[] = Tools::displayError('This module can\'t be 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 here.');
}
// Edit module from hook
elseif (Tools::isSubmit('submitEditGraft'))
{
if ($this->tabAccess['add'] === '1')
{
// Getting vars...
$id_module = (int)(Tools::getValue('id_module'));
$module = Module::getInstanceById($id_module);
$id_hook = (int)(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 here.');
}
// Delete module from hook
elseif (array_key_exists('deleteGraft', $_GET))
{
if ($this->tabAccess['delete'] === '1')
{
$id_module = (int)(Tools::getValue('id_module'));
$module = Module::getInstanceById($id_module);
$id_hook = (int)(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
{
$position = Db::getInstance()->getValue('SELECT `position` FROM `'._DB_PREFIX_.'hook_module` hm WHERE hm.`id_hook` = '.$id_hook.' AND hm.`id_module` = '.$id_module);
if (!$module->unregisterHook($id_hook) OR !$module->unregisterExceptions($id_hook))
$this->_errors[] = Tools::displayError('An error occurred while deleting module from hook.');
else
{
$this->placeCorrectlyOtherModules($id_hook, $position);
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.');
}
elseif (Tools::isSubmit('unhookform'))
{
if (!($unhooks = Tools::getValue('unhooks')) OR !is_array($unhooks))
$this->_errors[] = Tools::displayError('Select a module to unhook.');
else
{
foreach ($unhooks as $unhook)
{
$explode = explode('_', $unhook);
$id_hook = $explode[0];
$id_module = $explode[1];
$module = Module::getInstanceById((int)($id_module));
$hook = new Hook((int)($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
{
$position = Db::getInstance()->getValue('SELECT `position` FROM `'._DB_PREFIX_.'hook_module` hm WHERE hm.`id_hook` = '.(int)($id_hook).' AND hm.`id_module` = '.(int)($id_module));
if (!$module->unregisterHook((int)($id_hook)) OR !$module->unregisterExceptions((int)($id_hook)))
$this->_errors[] = Tools::displayError('An error occurred while deleting module from hook.');
else
$this->placeCorrectlyOtherModules((int)($id_hook), (int)($position));
}
}
if (!sizeof($this->_errors))
Tools::redirectAdmin($currentIndex.'&conf=17'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
}
}
}
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;
$link = new Link();
$admin_dir = dirname($_SERVER['PHP_SELF']);
$admin_dir = substr($admin_dir, strrpos($admin_dir,'/') + 1);
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').'&nbsp;</option>
<option>---------------</option>';
$modules = Module::getModulesInstalled();
foreach ($modules AS $module)
if ($tmpInstance = Module::getInstanceById((int)($module['id_module'])))
$cm[$tmpInstance->displayName] = $tmpInstance;
ksort($cm);
foreach ($cm AS $module)
echo '
<option value="'.(int)($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='.(int)(Tools::getValue('show_modules')).'&hook_position=\')" '.(Tools::getValue('hook_position') ? 'checked="checked" ' : '').' />&nbsp;<label class="t" for="hook_position">'.$this->l('Display non-positionable hook').'</label>
</form>
<fieldset style="width:250px;float:right"><legend>'.$this->l('Live edit').'</legend>
<p>'.$this->l('By clicking here you will be redirected to the front office of your shop to move and delete modules directly.').'</p>
<br>
<a href="'.$link->getPageLink('index.php').'?live_edit&ad='.$admin_dir.'&liveToken='.sha1($admin_dir._COOKIE_KEY_).'" target="_blank" class="button">'.$this->l('Run LiveEdit').'</a>
</fieldset>
';
// Print hook list
echo '<form method="post" action="'.$currentIndex.'&token='.$this->token.'">';
$irow = 0;
$hooks = Hook::getHooks(!(int)(Tools::getValue('hook_position')));
echo '<div id="unhook_button_position_top"><input class="button floatr" type="submit" name="unhookform" value="'.$this->l('Unhook the selection').'"/></div>';
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 ($nbModules)
echo '<input type="checkbox" id="Ghook'.$hook['id_hook'].'" class="floatr" style="margin-right: 2px;" onclick="hookCheckboxes('.$hook['id_hook'].', 0, this)"/>';
if (!empty($hook['description']))
echo '&nbsp;<span style="font-size:0.8em; font-weight: normal">['.$hook['description'].']</span>';
echo ' <sub style="color:grey;"><i>('.$this->l('Technical name: ').$hook['name'].')</i></sub></th></tr>';
// Print modules list
if ($nbModules)
{
$instances = array();
foreach ($modules AS $module)
if ($tmpInstance = Module::getInstanceById((int)($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">'.(int)($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;"><label class="lab_modules_positions" for="mod'.$hook['id_hook'].'_'.$instance->id.'">
';
}
else
echo '<td style="padding-left: 10px;" colspan="3"><label class="lab_modules_positions" for="'.$hook['id_hook'].'_'.$instance->id.'">';
echo '
<img src="../modules/'.$instance->name.'/logo.gif" alt="'.stripslashes($instance->name).'" /> <strong>'.stripslashes($instance->displayName).'</strong>
'.($instance->version ? ' v'.((int)($instance->version) == $instance->version? sprintf('%.1f', $instance->version) : (float)($instance->version)) : '').'<br />'.$instance->description.'
</label></td>
<td width="60">
<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>
<input type="checkbox" id="mod'.$hook['id_hook'].'_'.$instance->id.'" class="hook'.$hook['id_hook'].'" onclick="hookCheckboxes('.$hook['id_hook'].', 1, this)" name="unhooks[]" value="'.$hook['id_hook'].'_'.$instance->id.'"/>
</td>
</tr>';
}
} else
echo '<tr><td colspan="4">'.$this->l('No module for this hook').'</td></tr>';
echo '</table>';
}
echo '<div id="unhook_button_position_bottom"><input class="button floatr" type="submit" name="unhookform" value="'.$this->l('Unhook the selection').'"/></div></form>';
}
public function displayForm($isMainTab = true)
{
global $currentIndex;
parent::displayForm();
$id_module = (int)(Tools::getValue('id_module'));
$id_hook = (int)(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 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 for 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>';
}
private function placeCorrectlyOtherModules($id_hook, $position)
{
return Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'hook_module` hm SET hm.`position`= hm.`position` - 1 WHERE hm.`id_hook` = '.(int)($id_hook).' AND hm.`position` > '.(int)($position));
}
}
-87
View File
@@ -1,87 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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' => 600, 'maxlength' => 300));
parent::__construct();
}
public function displayForm($isMainTab = true)
{
global $currentIndex;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
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><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', (int)($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', (int)($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>';
}
}
File diff suppressed because it is too large Load Diff
-204
View File
@@ -1,204 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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()
{
global $cookie;
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(false);
foreach ($languages AS $language)
$_POST['template_'.$language['id_lang']] = '';
}
parent::postProcess();
}
elseif (isset($_GET['delete'.$this->table]))
{
$orderState = new OrderState((int)($_GET['id_order_state']), $cookie->id_lang);
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((int)($selection), $cookie->id_lang);
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();
if (!($obj = $this->loadObject(true)))
return;
echo '<script type="text/javascript" src="../js/jquery/jquery-colorpicker.js"></script>
<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><legend><img src="../img/admin/time.gif" />'.$this->l('Order statuses').'</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" style="width: 150px;" /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Invalid characters: numbers and').' !<>,;?=+()@#"{}_$%:<span class="hint-pointer">&nbsp;</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 width="20px" type="color" data-hex="true" class="color mColorPickerInput" 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="$(\'#tpl\').slideToggle();"'.
(($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', (int)($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">&nbsp;</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>';
}
}
-114
View File
@@ -1,114 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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' AND substr($file, -6) != 'bi.php' AND substr($file, -5) != 'b.php' AND substr($file, -5) != 'i.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' => array(
'title' => $this->l('Encoding:'),
'desc' => $this->l('Encoding for PDF invoice'),
'type' => 'selectLang',
'cast' => 'strval',
'identifier' => 'mode',
'list' => $encodingList),
'PS_PDF_FONT' => array(
'title' => $this->l('Font:'),
'desc' => $this->l('Font for PDF invoice'),
'type' => 'selectLang',
'cast' => 'strval',
'identifier' => 'mode',
'list' => $fontList)
);
parent::__construct();
}
public function postProcess()
{
if (isset($_POST['submitPDF'.$this->table]))
{
$fieldLangPDF = array();
$languages = Language::getLanguages(false);
foreach ($this->_fieldsPDF as $field => $fieldvalue)
foreach ($languages as $lang)
if (Tools::getValue($field.'_'.strtoupper($lang['iso_code'])))
$fieldLangPDF[$field.'_'.strtoupper($lang['iso_code'])] = array('type' => 'select', 'cast' => 'strval', 'identifier' => 'mode', 'list' => $fieldvalue['list']);
if ($this->tabAccess['edit'] === '1')
$this->_postConfig($fieldLangPDF);
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
}
public function display()
{
global $cookie;
$language = new Language((int)($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');
}
}
-95
View File
@@ -1,95 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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_CATALOG_MODE' => array('title' => $this->l('Catalog mode:'), 'desc' => $this->l('When active, all features for shopping will be disabled'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => true, 'type' => 'bool'),
'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_ATTRIBUTE_CATEGORY_DISPLAY' => array('title' => $this->l('Display "add to cart" button when product has attributes:'), 'desc' => $this->l('Display or hide the "add to cart" button on category pages for products that have attributes to force customers to see the product detail'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
'PS_COMPARATOR_MAX_ITEM' => array('title' => $this->l('Max items in the comparator:'), 'desc' => $this->l('Set to 0 to disable this feature'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'),
'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('Descending'))), '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 here.');
}
}
public function display()
{
$this->_displayForm('products', $this->_fieldsProduct, $this->l('Products'), 'width3', 'tab-orders');
echo '<script type="text/javascript">stockManagementActivationAuthorization();</script>';
}
}
-241
View File
@@ -1,241 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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 == 'payments_gateways')
{
if($module->id)
{
if(!get_class($module) == 'SimpleXMLElement')
$module->country = array();
$countries = DB::getInstance()->ExecuteS('SELECT id_country FROM '._DB_PREFIX_.'module_country WHERE id_module = '.(int)($module->id));
foreach ($countries as $country)
$module->country[] = $country['id_country'];
if(!get_class($module) == 'SimpleXMLElement')
$module->currency = array();
$currencies = DB::getInstance()->ExecuteS('SELECT id_currency FROM '._DB_PREFIX_.'module_currency WHERE id_module = '.(int)($module->id));
foreach ($currencies as $currency)
$module->currency[] = $currency['id_currency'];
if(!get_class($module) == 'SimpleXMLElement')
$module->group = array();
$groups = DB::getInstance()->ExecuteS('SELECT id_group FROM '._DB_PREFIX_.'module_group WHERE id_module = '.(int)($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[] = '('.(int)($module->id).', '.(int)($selected).')';
if (sizeof($values))
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;
$displayRestrictions = false;
$currencies = Currency::getCurrencies();
$countries = Country::getCountries((int)($cookie->id_lang));
$groups = Group::getGroups((int)($cookie->id_lang));
$tokenModules = Tools::getAdminToken('AdminModules'.(int)(Tab::getIdFromClassName('AdminModules')).(int)($cookie->id_employee));
echo '<h2 class="space">'.$this->l('Payment modules list').'</h2>';
echo '<input type="button" class="button" onclick="document.location=\'index.php?tab=AdminModules&token='.$tokenModules.'&module_name='.$this->paymentModules[0]->name.'&tab_module=payments_gateways\'" value="'.$this->l('Click to see the list of payment modules.').'" /><br>';
foreach ($this->paymentModules as $module)
if ($module->active)
$displayRestrictions= true;
if ($displayRestrictions)
{
echo '<br /><h2 class="space">'.$this->l('Payment module restrictions').'</h2>';
$textCurrencies = $this->l('Please mark the checkbox(es) for the currency or currencies for which you want the payment module(s) to be available.');
$textCountries = $this->l('Please mark the checkbox(es) for the country or countries for which you want the payment module(s) to be available.');
$textGroups = $this->l('Please mark the checkbox(es) for the groups for 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');
}
else
{
echo '<br>';
echo $this->displayWarning($this->l('No payment module installed'));
}
}
public function displayModuleRestrictions($items, $title, $nameId, $desc, $icon)
{
global $currentIndex;
$irow = 0;
echo '
<form action="'.$currentIndex.'&token='.$this->token.'" method="post" 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 '
&nbsp;<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)
{
if (isset($module->{$nameId}))
$value = $module->{$nameId};
else
$value = array();
echo '
<td style="text-align: center">';
if ($nameId == 'country' && isset($module->limited_countries) &&
count($module->limited_countries))
{
if (in_array($item['iso_code'], $module->limited_countries))
echo '<input type="checkbox" name="'.$module->name.'_'.
$nameId.'[]" value="'.$item['id_'.$nameId].'"'.
(in_array($item['id_'.$nameId.''], $value) ?
' checked="checked"' : '').' />';
else
echo '--';
}
else 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.''], $value) ? ' 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.''], $value) ? ' 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>';
}
}
-457
View File
@@ -1,457 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminPerformance extends AdminTab
{
public function postProcess()
{
global $currentIndex;
if (Tools::isSubmit('submitCaching'))
{
if ($this->tabAccess['edit'] === '1')
{
$settings = file_get_contents(dirname(__FILE__).'/../../config/settings.inc.php');
if (!Tools::getValue('active'))
$cache_active = 0;
else
$cache_active = 1;
if (!$caching_system = Tools::getValue('caching_system'))
$this->_errors[] = Tools::displayError('Caching system is missing');
else
$settings = preg_replace('/define\(\'_PS_CACHING_SYSTEM_\', \'([a-z0-9=\/+-_]+)\'\);/Ui', 'define(\'_PS_CACHING_SYSTEM_\', \''.$caching_system.'\');', $settings);
if ($cache_active AND $caching_system == 'MCached' AND !extension_loaded('memcache'))
$this->_errors[] = Tools::displayError('To use Memcached, you must to install the Memcache PECL extension on your server.').' <a href="http://www.php.net/manual/en/memcache.installation.php">http://www.php.net/manual/en/memcache.installation.php</a>';
elseif ($cache_active AND $caching_system == 'CacheFS' AND !is_writable(_PS_CACHEFS_DIRECTORY_))
$this->_errors[] = Tools::displayError('To use CacheFS the directory').' '.realpath(_PS_CACHEFS_DIRECTORY_).' '.Tools::displayError('must be writable');
if ($caching_system == 'CacheFS')
{
if (!($depth = Tools::getValue('ps_cache_fs_directory_depth')))
$this->_errors[] = Tools::displayError('Please set a directory depth');
if (!sizeof($this->_errors))
{
CacheFS::deleteCacheDirectory();
CacheFS::createCacheDirectories((int)$depth);
Configuration::updateValue('PS_CACHEFS_DIRECTORY_DEPTH', (int)$depth);
}
}
if (!sizeof($this->_errors))
{
$settings = preg_replace('/define\(\'_PS_CACHE_ENABLED_\', \'([0-9])\'\);/Ui', 'define(\'_PS_CACHE_ENABLED_\', \''.(int)$cache_active.'\');', $settings);
if (file_put_contents(dirname(__FILE__).'/../../config/settings.inc.php', $settings))
Tools::redirectAdmin($currentIndex.'&token='.Tools::getValue('token').'&conf=4');
else
$this->_errors[] = Tools::displayError('Cannot overwrite settings file.');
}
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
if (Tools::isSubmit('submitAddServer'))
{
if ($this->tabAccess['add'] === '1')
{
if (!Tools::getValue('memcachedIp'))
$this->_errors[] = Tools::displayError('Memcached IP is missing');
if (!Tools::getValue('memcachedPort'))
$this->_errors[] = Tools::displayError('Memcached port is missing');
if (!Tools::getValue('memcachedWeight'))
$this->_errors[] = Tools::displayError('Memcached weight is missing');
if (!sizeof($this->_errors))
{
if (MCached::addServer(pSQL(Tools::getValue('memcachedIp')), (int)Tools::getValue('memcachedPort'), (int)Tools::getValue('memcachedWeight')))
Tools::redirectAdmin($currentIndex.'&token='.Tools::getValue('token').'&conf=4');
else
$this->_errors[] = Tools::displayError('Cannot add Memcached server');
}
}
else
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
if (Tools::getValue('deleteMemcachedServer'))
{
if ($this->tabAccess['add'] === '1')
{
if (MCached::deleteServer((int)Tools::getValue('deleteMemcachedServer')))
Tools::redirectAdmin($currentIndex.'&token='.Tools::getValue('token').'&conf=4');
else
$this->_errors[] = Tools::displayError('Error in deleting Memcached server');
}
else
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
}
if (Tools::isSubmit('submitCiphering') AND Configuration::get('PS_CIPHER_ALGORITHM') != (int)Tools::getValue('PS_CIPHER_ALGORITHM'))
{
if ($this->tabAccess['edit'] === '1')
{
$algo = (int)Tools::getValue('PS_CIPHER_ALGORITHM');
$settings = file_get_contents(dirname(__FILE__).'/../../config/settings.inc.php');
if ($algo)
{
if (!function_exists('mcrypt_encrypt'))
$this->_errors[] = Tools::displayError('Mcrypt is not activated on this server.');
else
{
if (!strstr($settings, '_RIJNDAEL_KEY_'))
{
$key_size = mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
$key = Tools::passwdGen($key_size);
$settings = preg_replace('/define\(\'_COOKIE_KEY_\', \'([a-z0-9=\/+-_]+)\'\);/i', 'define(\'_COOKIE_KEY_\', \'\1\');'."\n".'define(\'_RIJNDAEL_KEY_\', \''.$key.'\');', $settings);
}
if (!strstr($settings, '_RIJNDAEL_IV_'))
{
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
$iv = base64_encode(mcrypt_create_iv($iv_size, MCRYPT_RAND));
$settings = preg_replace('/define\(\'_COOKIE_IV_\', \'([a-z0-9=\/+-_]+)\'\);/i', 'define(\'_COOKIE_IV_\', \'\1\');'."\n".'define(\'_RIJNDAEL_IV_\', \''.$iv.'\');', $settings);
}
}
}
if (!count($this->_errors))
{
if (file_put_contents(dirname(__FILE__).'/../../config/settings.inc.php', $settings))
{
Configuration::updateValue('PS_CIPHER_ALGORITHM', $algo);
Tools::redirectAdmin($currentIndex.'&token='.Tools::getValue('token').'&conf=4');
}
else
$this->_errors[] = Tools::displayError('Cannot overwrite settings file.');
}
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
if (Tools::isSubmit('submitCCC'))
{
if ($this->tabAccess['edit'] === '1')
{
if (
!Configuration::updateValue('PS_CSS_THEME_CACHE', (int)Tools::getValue('PS_CSS_THEME_CACHE')) OR
!Configuration::updateValue('PS_JS_THEME_CACHE', (int)Tools::getValue('PS_JS_THEME_CACHE')) OR
!Configuration::updateValue('PS_HTML_THEME_COMPRESSION', (int)Tools::getValue('PS_HTML_THEME_COMPRESSION')) OR
!Configuration::updateValue('PS_JS_HTML_THEME_COMPRESSION', (int)Tools::getValue('PS_JS_HTML_THEME_COMPRESSION')) OR
!Configuration::updateValue('PS_HIGH_HTML_THEME_COMPRESSION', (int)Tools::getValue('PS_HIGH_HTML_THEME_COMPRESSION'))
)
$this->_errors[] = Tools::displayError('Unknown error.');
else
Tools::redirectAdmin($currentIndex.'&token='.Tools::getValue('token').'&conf=4');
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
if (Tools::isSubmit('submitMediaServers'))
{
if ($this->tabAccess['edit'] === '1')
{
if (Tools::getValue('_MEDIA_SERVER_1_') != NULL AND !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_1_')))
$this->_errors[] = Tools::displayError('Media server #1 is invalid');
if (Tools::getValue('_MEDIA_SERVER_2_') != NULL AND !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_2_')))
$this->_errors[] = Tools::displayError('Media server #2 is invalid');
if (Tools::getValue('_MEDIA_SERVER_3_') != NULL AND !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_3_')))
$this->_errors[] = Tools::displayError('Media server #3 is invalid');
if (!sizeof($this->_errors))
{
$baseUrls = array();
$baseUrls['_MEDIA_SERVER_1_'] = Tools::getValue('_MEDIA_SERVER_1_');
$baseUrls['_MEDIA_SERVER_2_'] = Tools::getValue('_MEDIA_SERVER_2_');
$baseUrls['_MEDIA_SERVER_3_'] = Tools::getValue('_MEDIA_SERVER_3_');
rewriteSettingsFile($baseUrls, NULL, NULL);
unset($this->_fieldsGeneral['_MEDIA_SERVER_1_']);
unset($this->_fieldsGeneral['_MEDIA_SERVER_2_']);
unset($this->_fieldsGeneral['_MEDIA_SERVER_3_']);
Tools::redirectAdmin($currentIndex.'&token='.Tools::getValue('token').'&conf=4');
}
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
if (Tools::isSubmit('submitSmartyConfig'))
{
if ($this->tabAccess['edit'] === '1')
{
Configuration::updateValue('PS_SMARTY_FORCE_COMPILE', Tools::getValue('smarty_force_compile', 0));
Configuration::updateValue('PS_SMARTY_CACHE', Tools::getValue('smarty_cache', 0));
Tools::redirectAdmin($currentIndex.'&token='.Tools::getValue('token').'&conf=4');
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
return parent::postProcess();
}
public function display()
{
global $currentIndex;
$warnings = array();
if (!extension_loaded('memcache'))
$warnings[] = $this->l('To use Memcached, you must to install the Memcache PECL extension on your server.').' <a href="http://www.php.net/manual/en/memcache.installation.php">http://www.php.net/manual/en/memcache.installation.php</a>';
if(!is_writable(_PS_CACHEFS_DIRECTORY_))
$warnings[] = $this->l('To use CacheFS the directory').' '.realpath(_PS_CACHEFS_DIRECTORY_).' '.$this->l('must be writable');
if ($warnings)
$this->displayWarning($warnings);
echo '<script type="text/javascript">
$(document).ready(function() {
showMemcached();
$(\'#caching_system\').change(function() {
showMemcached();
});
function showMemcached()
{
if ($(\'#caching_system option:selected\').val() == \'MCached\')
{
$(\'#memcachedServers\').show();
$(\'#directory_depth\').hide();
}
else
{
$(\'#memcachedServers\').hide();
$(\'#directory_depth\').show();
}
}
$(\'#addMemcachedServer\').click(function() {
$(\'#formMemcachedServer\').show();
return false;
});
});
</script>
';
echo '
<form action="'.$currentIndex.'&token='.Tools::getValue('token').'" method="post" style="margin-top:10px;">
<fieldset>
<legend><img src="../img/admin/prefs.gif" /> '.$this->l('Smarty').'</legend>
<label>'.$this->l('Force compile:').'</label>
<div class="margin-form">
<input type="radio" name="smarty_force_compile" id="smarty_force_compile_1" value="1" '.(Configuration::get('PS_SMARTY_FORCE_COMPILE') ? 'checked="checked"' : '').' /> <label class="t"><img src="../img/admin/enabled.gif" alt="" /> '.$this->l('Yes').'</label>
<input type="radio" name="smarty_force_compile" id="smarty_force_compile_0" value="0" '.(!Configuration::get('PS_SMARTY_FORCE_COMPILE') ? 'checked="checked"' : '').' /> <label class="t"><img src="../img/admin/disabled.gif" alt="" /> '.$this->l('No').'</label>
<p>'.$this->l('This forces Smarty to (re)compile templates on every invocation. This is handy for development and debugging. It should never be used in a production environment.').'</p>
</div>
<label>'.$this->l('Cache:').'</label>
<div class="margin-form">
<input type="radio" name="smarty_cache" id="smarty_cache_1" value="1" '.(Configuration::get('PS_SMARTY_CACHE') ? 'checked="checked"' : '').' /> <label class="t"><img src="../img/admin/enabled.gif" alt="" /> '.$this->l('Yes').'</label>
<input type="radio" name="smarty_cache" id="smarty_cache_0" value="0" '.(!Configuration::get('PS_SMARTY_CACHE') ? 'checked="checked"' : '').' /> <label class="t"><img src="../img/admin/disabled.gif" alt="" /> '.$this->l('No').'</label>
<p>'.$this->l('Should be enabled except for debugging.').'</p>
</div>
<div class="margin-form">
<input type="submit" value="'.$this->l(' Save ').'" name="submitSmartyConfig" class="button" />
</div>
</fieldset>
</form>';
echo '
<form action="'.$currentIndex.'&token='.Tools::getValue('token').'" method="post" style="margin-top:10px;">
<fieldset>
<legend><img src="../img/admin/arrow_in.png" /> '.$this->l('CCC (Combine, Compress and Cache)').'</legend>
<p>'.$this->l('CCC allows you to reduce the loading time of your page. With these settings you will gain performance without even touching the code of your theme. Make sure, however, that your theme is compatible with PrestaShop 1.4+. Otherwise, CCC will cause problems.').'</p>
<label>'.$this->l('Smart cache for CSS').' </label>
<div class="margin-form">
<input type="radio" value="1" name="PS_CSS_THEME_CACHE" id="PS_CSS_THEME_CACHE_1" '.(Configuration::get('PS_CSS_THEME_CACHE') ? 'checked="checked"' : '').' />
<label class="t" for="PS_CSS_THEME_CACHE_1">'.$this->l('Use CCC for CSS.').'</label>
<br />
<input type="radio" value="0" name="PS_CSS_THEME_CACHE" id="PS_CSS_THEME_CACHE_0" '.(Configuration::get('PS_CSS_THEME_CACHE') ? '' : 'checked="checked"').' />
<label class="t" for="PS_CSS_THEME_CACHE_0">'.$this->l('Keep CSS as original').'</label>
</div>
<label>'.$this->l('Smart cache for JavaScript').' </label>
<div class="margin-form">
<input type="radio" value="1" name="PS_JS_THEME_CACHE" id="PS_JS_THEME_CACHE_1" '.(Configuration::get('PS_JS_THEME_CACHE') ? 'checked="checked"' : '').' />
<label class="t" for="PS_JS_THEME_CACHE_1">'.$this->l('Use CCC for JavaScript.').'</label>
<br />
<input type="radio" value="0" name="PS_JS_THEME_CACHE" id="PS_JS_THEME_CACHE_0" '.(Configuration::get('PS_JS_THEME_CACHE') ? '' : 'checked="checked"').' />
<label class="t" for="PS_JS_THEME_CACHE_0">'.$this->l('Keep JavaScript as original').'</label>
</div>
<label>'.$this->l('Minify HTML').' </label>
<div class="margin-form">
<input type="radio" value="1" name="PS_HTML_THEME_COMPRESSION" id="PS_HTML_THEME_COMPRESSION_1" '.(Configuration::get('PS_HTML_THEME_COMPRESSION') ? 'checked="checked"' : '').' />
<label class="t" for="PS_HTML_THEME_COMPRESSION_1">'.$this->l('Minify HTML after "smarty compile" execution.').'</label>
<br />
<input type="radio" value="0" name="PS_HTML_THEME_COMPRESSION" id="PS_HTML_THEME_COMPRESSION_0" '.(Configuration::get('PS_HTML_THEME_COMPRESSION') ? '' : 'checked="checked"').' />
<label class="t" for="PS_HTML_THEME_COMPRESSION_0">'.$this->l('Keep HTML as original').'</label>
</div>
<label>'.$this->l('Compress inline JavaScript in HTML').' </label>
<div class="margin-form">
<input type="radio" value="1" name="PS_JS_HTML_THEME_COMPRESSION" id="PS_JS_HTML_THEME_COMPRESSION_1" '.(Configuration::get('PS_JS_HTML_THEME_COMPRESSION') ? 'checked="checked"' : '').' />
<label class="t" for="PS_JS_HTML_THEME_COMPRESSION_1">'.$this->l('Compress inline JavaScript in HTML after "smarty compile" execution').'</label>
<br />
<input type="radio" value="0" name="PS_JS_HTML_THEME_COMPRESSION" id="PS_JS_HTML_THEME_COMPRESSION_0" '.(Configuration::get('PS_JS_HTML_THEME_COMPRESSION') ? '' : 'checked="checked"').' />
<label class="t" for="PS_JS_HTML_THEME_COMPRESSION_0">'.$this->l('Keep inline JavaScript in HTML as original').'</label>
</div>
<label>'.$this->l('High risk HTML compression').' </label>
<div class="margin-form">
<input type="radio" value="1" name="PS_HIGH_HTML_THEME_COMPRESSION" id="PS_HIGH_HTML_THEME_COMPRESSION_1" '.(Configuration::get('PS_HIGH_HTML_THEME_COMPRESSION') ? 'checked="checked"' : '').' />
<label class="t" for="PS_HIGH_HTML_THEME_COMPRESSION_1">'.$this->l('HTML is compressed but cancels the W3C validation (only when "Minify HTML" is enabled)').'</label>
<br />
<input type="radio" value="0" name="PS_HIGH_HTML_THEME_COMPRESSION" id="PS_HIGH_HTML_THEME_COMPRESSION_0" '.(Configuration::get('PS_HIGH_HTML_THEME_COMPRESSION') ? '' : 'checked="checked"').' />
<label class="t" for="PS_HIGH_HTML_THEME_COMPRESSION_0">'.$this->l('Keep W3C validation').'</label>
</div>
<div class="margin-form">
<input type="submit" value="'.$this->l(' Save ').'" name="submitCCC" class="button" />
</div>
</fieldset>
</form>';
echo '<form action="'.$currentIndex.'&token='.Tools::getValue('token').'" method="post" style="margin-top:10px;">
<fieldset>
<legend><img src="../img/admin/subdomain.gif" /> '.$this->l('Media servers (used only with CCC)').'</legend>
<p>'.$this->l('You must enter another domain or subdomain in order to use cookieless static content.').'</p>
<label for="_MEDIA_SERVER_1_">'.$this->l('Media server #1').'</label>
<div class="margin-form">
<input type="text" name="_MEDIA_SERVER_1_" id="_MEDIA_SERVER_1_" value="'.htmlentities(Tools::getValue('_MEDIA_SERVER_1_', _MEDIA_SERVER_1_), ENT_QUOTES, 'UTF-8').'" size="30" />
<p>'.$this->l('Name of the second domain of your shop, (e.g., myshop-media-server-1.com). If you do not have another domain, leave this field blank').'</p>
</div>
<label for="_MEDIA_SERVER_2_">'.$this->l('Media server #2').'</label>
<div class="margin-form">
<input type="text" name="_MEDIA_SERVER_2_" id="_MEDIA_SERVER_2_" value="'.htmlentities(Tools::getValue('_MEDIA_SERVER_2_', _MEDIA_SERVER_2_), ENT_QUOTES, 'UTF-8').'" size="30" />
<p>'.$this->l('Name of the third domain of your shop, (e.g., myshop-media-server-2.com). If you do not have another domain, leave this field blank').'</p>
</div>
<label for="_MEDIA_SERVER_3_">'.$this->l('Media server #3').'</label>
<div class="margin-form">
<input type="text" name="_MEDIA_SERVER_3_" id="_MEDIA_SERVER_3_" value="'.htmlentities(Tools::getValue('_MEDIA_SERVER_3_', _MEDIA_SERVER_3_), ENT_QUOTES, 'UTF-8').'" size="30" />
<p>'.$this->l('Name of the fourth domain of your shop, (e.g., myshop-media-server-3.com). If you do not have another domain, leave this field blank').'</p>
</div>
<div class="margin-form">
<input type="submit" value="'.$this->l(' Save ').'" name="submitMediaServers" class="button" />
</div>
</fieldset>
</form>';
echo '
<fieldset style="margin-top:10px;">
<legend><img src="../img/admin/computer_key.png" /> '.$this->l('Ciphering').'</legend>
<form action="'.$currentIndex.'&token='.Tools::getValue('token').'" method="post">
<p>'.$this->l('Mcrypt is faster than our custom BlowFish class, but requires the PHP extension "mcrypt". If you change this configuration, all cookies will be reset.').'</p>
<label>'.$this->l('Algorithm').' </label>
<div class="margin-form">
<input type="radio" value="1" name="PS_CIPHER_ALGORITHM" id="PS_CIPHER_ALGORITHM_1" '.(Configuration::get('PS_CIPHER_ALGORITHM') ? 'checked="checked"' : '').' />
<label class="t" for="PS_CIPHER_ALGORITHM_1">'.$this->l('Use Rijndael with mcrypt lib.').'</label>
<br />
<input type="radio" value="0" name="PS_CIPHER_ALGORITHM" id="PS_CIPHER_ALGORITHM_0" '.(Configuration::get('PS_CIPHER_ALGORITHM') ? '' : 'checked="checked"').' />
<label class="t" for="PS_CIPHER_ALGORITHM_0">'.$this->l('Keep the custom BlowFish class.').'</label>
</div>
<div class="margin-form">
<input type="submit" value="'.$this->l(' Save ').'" name="submitCiphering" class="button" />
</div>
</form>
</fieldset>
';
$depth = Configuration::get('PS_CACHEFS_DIRECTORY_DEPTH');
echo '<fieldset style="margin-top: 10px;">
<legend><img src="../img/admin/computer_key.png" /> '.$this->l('Caching').'</legend>
<form action="'.$currentIndex.'&token='.Tools::getValue('token').'" method="post">
<label>'.$this->l('Use cache:').' </label>
<div class="margin-form">
<input type="radio" name="active" id="active_on" value="1" '.(_PS_CACHE_ENABLED_ ? '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" '.(!_PS_CACHE_ENABLED_ ? '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 caching system').'</p>
</div>
<label>'.$this->l('Caching system:').' </label>
<div class="margin-form">
<select name="caching_system" id="caching_system">
<option value="MCached" '.(_PS_CACHING_SYSTEM_ == 'MCached' ? 'selected="selected"' : '' ).'>'.$this->l('Memcached').'</option>
<option value="CacheFS" '.(_PS_CACHING_SYSTEM_ == 'CacheFS' ? 'selected="selected"' : '' ).'>'.$this->l('File System').'</option>
</select>
</div>
<div id="directory_depth">
<label>'.$this->l('Directory depth:').' </label>
<div class="margin-form">
<input type="text" name="ps_cache_fs_directory_depth" value="'.($depth ? $depth : 1).'" />
</div>
</div>
<div class="margin-form">
<input type="submit" value="'.$this->l(' Save ').'" name="submitCaching" class="button" />
</div>
</form>
<div id="memcachedServers">
<div class="margin-form">
<a id="addMemcachedServer" href="#" ><img src="../img/admin/add.gif" />'.$this->l('Add server').'</a>
</div>
<div id="formMemcachedServer" style="margin-top: 10px; display:none;">
<form action="'.$currentIndex.'&token='.Tools::getValue('token').'" method="post">
<label>'.$this->l('IP Address:').' </label>
<div class="margin-form">
<input type="text" name="memcachedIp" />
</div>
<label>'.$this->l('Port:').' </label>
<div class="margin-form">
<input type="text" name="memcachedPort" value="11211" />
</div>
<label>'.$this->l('Weight:').' </label>
<div class="margin-form">
<input type="text" name="memcachedWeight" value="1" />
</div>
<div class="margin-form">
<input type="submit" value="'.$this->l(' Add Server ').'" name="submitAddServer" class="button" />
</div>
</form>
</div>';
$servers = MCached::getMemcachedServers();
if ($servers)
{
echo '<div class="margin-form">
<table style="width: 320px;" cellspacing="0" cellpadding="0" class="table">
<tr>
<th style="width: 20px; text-align: center">'.$this->l('Id').'</th>
<th style="width: 200px; text-align: center">'.$this->l('Ip').'</th>
<th style="width: 50px; text-align: center">'.$this->l('Port').'</th>
<th style="width: 30px; text-align: right; font-weight: bold;">'.$this->l('Weight').'</th>
<th style="width: 20px; text-align: right;">&nbsp;</th>
</tr>';
foreach($servers AS $server)
echo '<tr>
<td>'.$server['id_memcached_server'].'</td>
<td>'.$server['ip'].'</td>
<td>'.$server['port'].'</td>
<td>'.$server['weight'].'</td>
<td>
<a href="'.$currentIndex.'&token='.Tools::getValue('token').'&deleteMemcachedServer='.(int)$server['id_memcached_server'].'" ><img src="../img/admin/delete.gif" /></a>
</td>
</tr>';
echo '
</table>
</div>';
}
echo '
</div>
</fieldset>';
}
}
-494
View File
@@ -1,494 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminPreferences extends AdminTab
{
public function __construct()
{
global $cookie;
$this->className = 'Configuration';
$this->table = 'configuration';
$timezones = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT name FROM '._DB_PREFIX_.'timezone');
$taxes[] = array('id' => 0, 'name' => $this->l('None'));
foreach (Tax::getTaxes((int)($cookie->id_lang)) as $tax)
$taxes[] = array('id' => $tax['id_tax'], 'name' => $tax['name']);
$order_process_type = array(
array(
'value' => PS_ORDER_PROCESS_STANDARD,
'name' => $this->l('Standard (5 steps)')
),
array(
'value' => PS_ORDER_PROCESS_OPC,
'name' => $this->l('One page checkout')
)
);
$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')
)
);
$cms_tab = array(0 =>
array(
'id' => 0,
'name' => $this->l('None')
)
);
foreach (CMS::listCms($cookie->id_lang) as $cms_file)
$cms_tab[] = array('id' => $cms_file['id_cms'], 'name' => $cms_file['meta_title']);
$this->_fieldsGeneral = array(
'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. Please note that the webservice will not be disabled'), '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 a comma 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_COOKIE_CHECKIP' => array('title' => $this->l('Check IP on the cookie'), 'desc' => $this->l('Check the IP address of the cookie in order to avoid your cookie being stolen'), '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_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_ORDER_PROCESS_TYPE' => array('title' => $this->l('Order process type'), 'desc' => $this->l('You can choose the order process type as either standard (5 steps) or One Page Checkout'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $order_process_type, 'identifier' => 'value'),
'PS_GUEST_CHECKOUT_ENABLED' => array('title' => $this->l('Enable guest checkout'), 'desc' => $this->l('Your guest can make an order without registering'), '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', 'js' => array('on' => 'onchange="changeCMSActivationAuthorization()"', 'off' => 'onchange="changeCMSActivationAuthorization()"')),
'PS_CONDITIONS_CMS_ID' => array('title' => $this->l('Conditions of use CMS page'), 'desc' => $this->l('Choose the Conditions of use CMS page'), 'validation' => 'isInt', 'type' => 'select', 'list' => $cms_tab, 'identifier' => 'id', 'cast' => 'intval'),
'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_ATTACHMENT_MAXIMUM_SIZE' => array('title' => $this->l('Attachment maximum size'), 'desc' => $this->l('Set the maximum size of attachment files (in MegaBytes)'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'text'),
'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 how to round prices: always round superior; always round inferior, or classic rounding'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'select', 'list' => $round_mode, 'identifier' => 'value'),
'PRESTASTORE_LIVE' => array('title' => $this->l('Automatically check for module updates'), 'desc' => $this->l('New modules and updates are displayed on the modules page'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
'PS_HIDE_OPTIMIZATION_TIPS' => array('title' => $this->l('Hide optimization tips'), 'desc' => $this->l('Hide optimization tips on the back office homepage'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
'PS_DISPLAY_SUPPLIERS' => array('title' => $this->l('Display suppliers and manufacturers'), 'desc' => $this->l('Display manufacturers and suppliers list even if corresponding blocks are disabled'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
'PS_FORCE_SMARTY_2' => array('title' => $this->l('Use Smarty 2 instead of 3'), 'desc' => $this->l('Enable if your theme is incompatible with Smarty 3 (you should update your theme, since Smarty 2 will be unsupported from PrestaShop v1.5)'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
);
if (function_exists('date_default_timezone_set'))
$this->_fieldsGeneral['PS_TIMEZONE'] = array('title' => $this->l('Time Zone:'), 'validation' => 'isAnything', 'type' => 'select', 'list' => $timezones, 'identifier' => 'name');
parent::__construct();
}
public function display()
{
$this->_displayForm('general', $this->_fieldsGeneral, $this->l('General'), '', 'tab-preferences');
}
public function postProcess()
{
global $currentIndex;
if (isset($_POST['submitGeneral'.$this->table]))
{
Module::hookExec('categoryUpdate'); // We call this hook, for regenerate cache of categories
if (Tools::getValue('PS_CONDITIONS') == true AND (Tools::getValue('PS_CONDITIONS_CMS_ID') == 0 OR !Db::getInstance()->getValue('
SELECT `id_cms` FROM `'._DB_PREFIX_.'cms`
WHERE id_cms = '.(int)(Tools::getValue('PS_CONDITIONS_CMS_ID')))))
$this->_errors[] = Tools::displayError('Assign a valid CMS page if you want it to be read.');
if ($this->tabAccess['edit'] === '1')
$this->_postConfig($this->_fieldsGeneral);
else
$this->_errors[] = Tools::displayError('You do not have permission to edit 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 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 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 here.');
}
parent::postProcess();
}
/**
* 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, $smarty;
$languages = Language::getLanguages(false);
if (!Configuration::get('PS_FORCE_SMARTY_2'))
{
$files = scandir(_PS_THEME_DIR_);
foreach ($files AS $file)
if (!preg_match('/^\..*/', $file))
$smarty->clearCache($file);
}
else
$smarty->clear_all_cache();
/* Check required fields */
foreach ($fields AS $field => $values)
if (isset($values['required']) AND $values['required'])
if (isset($values['type']) AND $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 (isset($values['type']) AND $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 (Tools::isSubmit('submitAppearanceconfiguration'))
{
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 occurred during logo copy';
unlink($tmpName);
}
if (isset($_FILES['PS_LOGO_MAIL']['tmp_name']) AND $_FILES['PS_LOGO_MAIL']['tmp_name'])
{
if ($error = checkImage($_FILES['PS_LOGO_MAIL'], 300000))
$this->_errors[] = $error;
if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS_MAIL') OR !move_uploaded_file($_FILES['PS_LOGO_MAIL']['tmp_name'], $tmpName))
return false;
elseif (!@imageResize($tmpName, _PS_IMG_DIR_.'logo_mail.jpg'))
$this->_errors[] = 'an error occurred during logo copy';
unlink($tmpName);
}
if (isset($_FILES['PS_LOGO_INVOICE']['tmp_name']) AND $_FILES['PS_LOGO_INVOICE']['tmp_name'])
{
if ($error = checkImage($_FILES['PS_LOGO_INVOICE'], 300000))
$this->_errors[] = $error;
if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS_INVOICE') OR !move_uploaded_file($_FILES['PS_LOGO_INVOICE']['tmp_name'], $tmpName))
return false;
elseif (!@imageResize($tmpName, _PS_IMG_DIR_.'logo_invoice.jpg'))
$this->_errors[] = 'an error occurred during logo copy';
unlink($tmpName);
}
if (isset($_FILES['PS_STORES_ICON']['tmp_name']) AND $_FILES['PS_STORES_ICON']['tmp_name'])
{
if ($error = checkImage($_FILES['PS_STORES_ICON'], 300000))
$this->_errors[] = $error;
if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS_STORES_ICON') OR !move_uploaded_file($_FILES['PS_STORES_ICON']['tmp_name'], $tmpName))
return false;
elseif (!@imageResize($tmpName, _PS_IMG_DIR_.'logo_stores.gif'))
$this->_errors[] = 'an error occurred 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 (isset($values['type']) AND $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['_MEDIA_SERVER_1_'] = _MEDIA_SERVER_1_;
$tab['_MEDIA_SERVER_2_'] = _MEDIA_SERVER_2_;
$tab['_MEDIA_SERVER_3_'] = _MEDIA_SERVER_3_;
$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' || $field['type'] == 'selectLang')
$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 = (int)(Configuration::get('PS_LANG_DEFAULT'));
$languages = Language::getLanguages(false);
$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" 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'].'"' : '').' id="'.$key.'">';
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 'selectLang':
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;">
<select name="'.$key.'_'.strtoupper($language['iso_code']).'">';
foreach ($field['list'] AS $k => $value)
echo '<option value="'.(isset($value['cast']) ? $value['cast']($value[$field['identifier']]) : $value[$field['identifier']]).'"'.((htmlentities(Tools::getValue($key.'_'.strtoupper($language['iso_code']), (Configuration::get($key.'_'.strtoupper($language['iso_code'])) ? Configuration::get($key.'_'.strtoupper($language['iso_code'])) : '')), ENT_COMPAT, 'UTF-8') == $value[$field['identifier']]) ? ' selected="selected"' : '').'>'.$value['name'].'</option>';
echo '
</select>
</div>';
}
$this->displayFlags($languages, $defaultLanguage, $divLangName, $key);
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="'.(int)($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>';
if ($name == 'themes')
echo '
<td colspan="'.sizeof($field['list']).'">
<b>'.$this->l('In order to use a new theme, please follow this steps:', get_class()).'</b>
<ul>
<li>'.$this->l('Import your theme with using this module:', get_class()).' <a href="index.php?tab=AdminModules&token='.Tools::getAdminTokenLite('AdminModules').'&filtername=themeinstallator" style="text-decoration: underline;">'.$this->l('Theme installator', get_class()).'</a></li>
<li>'.$this->l('When your theme is imported, please select the theme in this page', get_class()).'</li>
</ul>
</td>
</tr>
<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((int)(Configuration::get("PS_CURRENCY_DEFAULT")));
echo $default_currency->getSign('left').'<input type="'.$field['type'].'" size="'.(isset($field['size']) ? (int)($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']) ? (int)($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']) ? (int)($field['size']) : 5).'" name="'.$key.'" value="'.($field['type'] == 'password' ? '' : htmlentities($val, ENT_COMPAT, 'UTF-8')).'" />'.(isset($field['next']) ? '&nbsp;'.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 the theme, the settings.inc.php file must be writable (CHMOD 755 / 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>';
if (get_class($this) == 'AdminPreferences')
echo '<script type="text/javascript">changeCMSActivationAuthorization();</script>';
}
}
File diff suppressed because it is too large Load Diff
-91
View File
@@ -1,91 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminProfiles extends AdminTab
{
public function __construct()
{
global $cookie;
$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';
$list_profile = array();
foreach(Profile::getProfiles($cookie->id_lang) as $profil)
$list_profile[] = array('value' => $profil['id_profile'], 'name' => $profil['name']);
parent::__construct();
}
public function postProcess()
{
if (isset($_GET['delete'.$this->table]) AND $_GET[$this->identifier] == (int)(_PS_ADMIN_PROFILE_))
$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();
if (!($obj = $this->loadObject(true)))
return;
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/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', (int)($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>';
}
}
-92
View File
@@ -1,92 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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();
if (!($obj = $this->loadObject(true)))
return;
$new_window = $this->getFieldValue($obj, 'new_window');
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/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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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>';
}
}
-110
View File
@@ -1,110 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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();
if (!($obj = $this->loadObject(true)))
return;
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
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/t/AdminRangePrice.gif" />'.$this->l('Price ranges').'</legend>
<label>'.$this->l('Carrier').'</label>
<div class="margin-form">
<select name="id_carrier">';
$carriers = Carrier::getCarriers((int)(Configuration::get('PS_LANG_DEFAULT')), true, false, false, NULL, PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
$id_carrier = Tools::getValue('id_carrier', $obj->id_carrier);
foreach ($carriers AS $carrier)
echo '<option value="'.(int)($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>';
}
}
-109
View File
@@ -1,109 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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();
if (!($obj = $this->loadObject(true)))
return;
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/t/AdminRangeWeight.gif" />'.$this->l('Weight ranges').'</legend>
<label>'.$this->l('Carrier').'</label>
<div class="margin-form">
<select name="id_carrier">';
$carriers = Carrier::getCarriers((int)(Configuration::get('PS_LANG_DEFAULT')), true , false,false, NULL, PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
$id_carrier = Tools::getValue('id_carrier', $obj->id_carrier);
foreach ($carriers AS $carrier)
echo '<option value="'.(int)($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>';
}
}
-472
View File
@@ -1,472 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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'.(int)(Tab::getIdFromClassName('AdminReferrers')).(int)(Tools::getValue('id_employee'))))
{
if (Tools::isSubmit('ajaxProductFilter'))
Referrer::getAjaxProduct((int)(Tools::getValue('id_referrer')), (int)(Tools::getValue('id_product')), new Employee((int)(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 = '.(int)(Tools::getValue('id_lang')).')
'.(Tools::getValue('filter') != 'undefined' ? 'WHERE name LIKE "%'.pSQL(Tools::getValue('filter')).'%"' : ''));
foreach ($result as $row)
$jsonArray[] = '{id_product:'.(int)($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((int)($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:'.(int)($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 style="width:630px"><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" '.((int)(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" '.(!(int)(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 enabling it only if you have a strong database server and a strong 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">&nbsp;</div>';
parent::display();
echo '<div class="clear space">&nbsp;</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', (int)(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();
if (!($obj = $this->loadObject(true)))
return;
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">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
<fieldset><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 their own data with this 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><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((float)($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((float)($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((float)($this->getFieldValue($obj, 'percent_fee')), 2).'" />
<p>'.$this->l('Percent of the sales.').'</p>
</div>
</fieldset>
<br class="clear" />
<fieldset><legend onclick="$(\'#tracking_help\').slideToggle();" 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 arrive.').'<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 arrives directly (by typing the URL of your shop or by using their 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 from which the customers come to your website.').'<br />
'.$this->l('For example, if the visitor accesses a product page, the URL will be').' "'.$uri.'music-ipods/1-ipod-nano.html".<br />
'.$this->l('This is interesting because you can add some tags or tokens in the links pointing to your website. For example, 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 at the document for more details...').'</a>
</li>
</ul>
</div>
</fieldset>
<br class="clear" />
<fieldset><legend><img src="../img/admin/affiliation.png" /> '.$this->l('Technical information - Simple mode').'</legend>
<a style="cursor: pointer; font-style: italic;" onclick="$(\'#tracking_help\').slideToggle();"><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="$(\'#tracking_expert\').slideToggle();">'.$this->l('expert mode').'.</a>
</fieldset>
<br class="clear" />
<fieldset><legend onclick="$(\'#tracking_expert\').slideToggle();" 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((int)(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:'.(int)($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:'.(int)($cookie->id_employee).',token:"'.Tools::getValue('token').'",id_lang:'.(int)($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 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>';
}
}
}
-288
View File
@@ -1,288 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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` = '.(int)($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', 'align' => 'right'));
$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 delivery 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 = (int)(Tools::getValue('id_order_detail'))) AND Validate::isUnsignedId($id_order_detail))
{
if (($id_order_return = (int)(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 ((int)($orderReturn->countProduct()) > 1)
{
if (OrderReturn::deleteOrderReturnDetail($id_order_return, $id_order_detail, (int)(Tools::getValue('id_customization', 0))))
Tools::redirectAdmin($currentIndex.'&conf=4token='.$this->token);
else
$this->_errors[] = Tools::displayError('An error occurred 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 = (int)(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 = (int)(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[(int)(Configuration::get('PS_LANG_DEFAULT'))]);
Mail::Send((int)($cookie->id_lang), 'order_return_state', Mail::l('Your order return state has changed'), $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((int)($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();
if (!($obj = $this->loadObject(true)))
return;
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><legend><img src="../img/admin/return.gif" />'.$this->l('Return Merchandise Authorization (RMA)').'</legend>
<label>'.$this->l('Customer:').' </label>';
$customer = new Customer((int)($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'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($cookie->id_employee)).'">'.$this->l('View details on customer page').'</a></p>
</div>
<label>'.$this->l('Order:').' </label>';
$order = new Order((int)($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'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($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'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($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">&nbsp;</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((int)($obj->id_order));
$quantityDisplayed = array();
/* Customized products */
if ($returnedCustomizations = OrderReturn::getReturnedCustomizedProducts((int)($obj->id_order)))
{
$allCustomizedDatas = Product::getAllCustomizedDatas((int)($order->id_cart));
foreach ($returnedCustomizations AS $returnedCustomization)
{
echo '
<tr>
<td>'.$returnedCustomization['reference'].'</td>
<td class="center">'.$returnedCustomization['name'].'</td>
<td class="center">'.(int)($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[(int)($returnedCustomization['product_id'])][(int)($returnedCustomization['product_attribute_id'])][(int)($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='.(int)($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'] ? $data['name'] : $this->l('Text #').++$i).$this->l(':').' '.$data['value'].'</li>';
echo '</ul>';
}
echo '</td>
</tr>';
}
$quantityDisplayed[(int)($returnedCustomization['id_order_detail'])] = isset($quantityDisplayed[(int)($returnedCustomization['id_order_detail'])]) ? $quantityDisplayed[(int)($returnedCustomization['id_order_detail'])] + (int)($returnedCustomization['product_quantity']) : (int)($returnedCustomization['product_quantity']);
}
}
/* Classic products */
$products = OrderReturn::getOrdersReturnProducts($obj->id, $order);
foreach ($products AS $k => $product)
if (!isset($quantityDisplayed[(int)($product['id_order_detail'])]) OR (int)($product['product_quantity']) > (int)($quantityDisplayed[(int)($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>';
}
}
-80
View File
@@ -1,80 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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();
if (!($obj = $this->loadObject(true)))
return;
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><legend><img src="../img/admin/time.gif" />'.$this->l('Order statuses').'</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Invalid characters: numbers and').' !<>,;?=+()@#"{}_$%:<span class="hint-pointer">&nbsp;</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>';
}
}
-284
View File
@@ -1,284 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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 */
if (!($obj = $this->loadObject(true)))
return;
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', (int)($imageType['width']), (int)($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', (int)($imageType['width']), (int)($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
*/
public function recurseCategoryForInclude($indexedCategories, $categories, $current, $id_category = 1, $id_category_default = NULL, $has_suite = array())
{
global $done;
static $irow;
$id_obj = (int)(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;
echo '
<tr class="'.($irow++ % 2 ? 'alt_row' : '').'">
<td>
<input type="checkbox" name="categoryBox[]" class="categoryBox'.($id_category_default == $id_category ? ' id_category_default' : '').'" id="categoryBox_'.$id_category.'" value="'.$id_category.'"'.((in_array($id_category, $indexedCategories) OR ((int)(Tools::getValue('id_category')) == $id_category AND !(int)($id_obj))) ? ' checked="checked"' : '').' />
</td>
<td>
'.$id_category.'
</td>
<td>';
for ($i = 2; $i < $level; $i++)
echo '<img src="../img/admin/lvl_'.$has_suite[$i - 2].'.gif" alt="" style="vertical-align: middle;"/>';
echo '<img src="../img/admin/'.($level == 1 ? 'lv1.gif' : 'lv2_'.($todo == $doneC ? 'f' : 'b').'.gif').'" alt="" style="vertical-align: middle;"/> &nbsp;
<label for="categoryBox_'.$id_category.'" class="t">'.stripslashes($current['infos']['name']).'</label></td>
</tr>';
if ($level > 1)
$has_suite[] = ($todo == $doneC ? 0 : 1);
if (isset($categories[$id_category]))
foreach ($categories[$id_category] AS $key => $row)
if ($key != 'infos')
$this->recurseCategoryForInclude($indexedCategories, $categories, $categories[$id_category][$key], $key, $id_category_default, $has_suite);
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
$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((int)($product['id_product']), true, (int)($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', (int)($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/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" />&nbsp;&nbsp;'.$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: 600px;">
<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((int)($cookie->id_lang), false);
$done = array();
$index = array();
if (Tools::isSubmit('categoryBox'))
foreach (Tools::getValue('categoryBox') AS $k => $row)
$index[] = $row;
elseif ($obj->id)
foreach (Scene::getIndexedCategories($obj->id) 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>';
}
}
-288
View File
@@ -1,288 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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((int)$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">'.Tools::htmlentitiesUTF8($query).'</span>', $this->_list['products'][$i]['name']);
$this->_list['categories'] = Category::searchByName((int)$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;
$query = trim(Tools::getValue('bo_query'));
$searchType = (int)Tools::getValue('bo_search_type');
/* Handle empty search field */
if (empty($query))
$this->_errors[] = Tools::displayError('Please fill in search form first.');
else
{
echo '<h2>'.$this->l('Search results').'</h2>';
if (!$searchType and strlen($query) > 1)
{
global $_LANGADM;
$tabs = array();
$result = Db::getInstance()->ExecuteS('SELECT class_name, name FROM '._DB_PREFIX_.'tab t INNER JOIN '._DB_PREFIX_.'tab_lang tl ON t.id_tab = tl.id_tab AND tl.id_lang = '.(int)$cookie->id_lang);
foreach ($result as $row)
$tabs[$row['class_name']] = $row['name'];
foreach (AdminTab::$tabParenting as $key => $value)
$tabs[$key] = $tabs[$value];
$matchingResults = array();
foreach ($_LANGADM as $key => $value)
if (stripos($value, $query) !== false)
{
$key = substr($key, 0, -32);
if (in_array($key, array('AdminTab', 'index')))
continue;
if (!isset($matchingResults[$tabs[$key]]))
$matchingResults[$tabs[$key]] = array();
$matchingResults[$tabs[$key]][] = array('tab' => $key, 'value' => $value);
}
if (count($matchingResults))
{
arsort($matchingResults);
echo '<h3>'.$this->l('Features matching your query:').' '.count($matchingResults).'</h3>
<table class="table" cellpadding="0" cellspacing="0">';
foreach ($matchingResults as $key => $tab)
{
for ($i = 0; isset($tab[$i]); ++$i)
echo '<tr>
<th>'.($i == 0 ? htmlentities($key, ENT_COMPAT, 'utf-8') : '&nbsp;').'</th>
<td>
<a href="?tab='.$tab[$i]['tab'].'&token='.Tools::getAdminTokenLite($tab[$i]['tab']).'">
'.htmlentities(stripslashes($tab[$i]['value']), ENT_COMPAT, 'utf-8').'
</a>
</td>
</tr>';
}
echo '</table><div class="clear">&nbsp;</div>';
}
}
/* Product research */
if (!$searchType OR $searchType == 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 ($searchType == 1 AND (int)$query AND Validate::isUnsignedInt((int)$query))
if ($product = new Product((int)$query) AND Validate::isLoadedObject($product))
Tools::redirectAdmin('index.php?tab=AdminCatalog&id_product='.(int)($product->id).'&addproduct'.'&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)));
/* Normal catalog search */
$this->searchCatalog($query);
}
/* Customer */
if (!$searchType OR $searchType == 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 ($searchType AND (int)$query AND Validate::isUnsignedInt((int)$query))
if ($customer = new Customer((int)$query) AND Validate::isLoadedObject($customer))
Tools::redirectAdmin('index.php?tab=AdminCustomers&id_customer='.(int)($customer->id).'&viewcustomer'.'&token='.Tools::getAdminToken('AdminCustomers'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($cookie->id_employee)));
/* Normal customer search */
$this->searchCustomer($query);
}
/* Order */
if ($searchType == 3)
{
if ((int)$query AND Validate::isUnsignedInt((int)$query) AND $order = new Order((int)$query) AND Validate::isLoadedObject($order))
Tools::redirectAdmin('index.php?tab=AdminOrders&id_order='.(int)($order->id).'&vieworder'.'&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)($cookie->id_employee)));
$this->_errors[] = Tools::displayError('No order found with this ID:').' '.Tools::htmlentitiesUTF8($query);
}
/* Invoices */
if ($searchType == 4)
{
if ((int)$query AND Validate::isUnsignedInt((int)$query) AND $invoice = Order::getInvoice((int)$query))
Tools::redirectAdmin('pdf.php?id_order='.(int)($invoice['id_order']).'&pdf');
$this->_errors[] = Tools::displayError('No invoice found with this ID:').' '.Tools::htmlentitiesUTF8($query);
}
/* Cart */
if ($searchType == 5)
{
if ((int)$query AND Validate::isUnsignedInt((int)$query) AND $cart = new Cart((int)$query) AND Validate::isLoadedObject($cart))
Tools::redirectAdmin('index.php?tab=AdminCarts&id_cart='.(int)($cart->id).'&viewcart'.'&token='.Tools::getAdminToken('AdminCarts'.(int)(Tab::getIdFromClassName('AdminCarts')).(int)($cookie->id_employee)));
$this->_errors[] = Tools::displayError('No cart found with this ID:').' '.Tools::htmlentitiesUTF8($query);
}
}
}
public function display()
{
global $cookie;
$currentIndex = 'index.php';
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$query = trim(Tools::getValue('bo_query'));
$nbCategories = $nbProducts = $nbCustomers = 0;
/* 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::htmlentitiesUTF8($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>
<div class="clear">&nbsp;</div>';
}
/* 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::htmlentitiesUTF8($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'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($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'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($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'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'">
<img src="../img/admin/edit.gif" alt="'.$this->l('Modify this product').'" /></a>&nbsp;
<a href="'.$currentIndex.'?tab=AdminCatalog&id_product='.$product['id_product'].'&deleteproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'"
onclick="return confirm(\''.$this->l('Do you want to delete this product?', __CLASS__, true, false).' ('.addslashes($product['name']).')\');">
<img src="../img/admin/delete.gif" alt="'.$this->l('Delete this product').'" /></a>
</td>
</tr>';
}
echo '</table>
<div class="clear">&nbsp;</div>';
}
/* 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::htmlentitiesUTF8($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'], (int)($cookie->id_lang)).'</td>
<td>'.Tools::displayDate($customer['date_add'], (int)($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'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($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'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($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'.(int)(Tab::getIdFromClassName('AdminCustomers')).(int)($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">&nbsp;</div>';
}
/* Display error if nothing has been matching */
if (!$nbCategories AND !$nbProducts AND !$nbCustomers)
echo '<h3>'.$this->l('Nothing found for').' "'.Tools::htmlentitiesUTF8($query).'"</h3>';
}
}
-87
View File
@@ -1,87 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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_INSTANT_SEARCH' => array('title' => $this->l('Instant search:'), 'desc' => $this->l('The fastest search solution for your shop'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
'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 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.php?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>
<legend><img src="../img/admin/search.gif" alt="" /> '.$this->l('Indexation').'</legend>
'.$this->l('Indexed products:').' <b>'.(int)($indexed).' / '.(int)($total).'</b>.<br /><br />
-&gt; <a href="searchcron.php?token='.substr(_COOKIE_KEY_, 34, 8).'" class="bold">'.$this->l('Add missing products to index.').'</a><br />
-&gt; <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">&nbsp;</div>';
$this->_displayForm('search', $this->_fieldsSearch, $this->l('Search'), 'width2', 'search');
}
}
-75
View File
@@ -1,75 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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();
if (!($obj = $this->loadObject(true)))
return;
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>'.$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>';
}
}
-287
View File
@@ -1,287 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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 here.');
}
/* Shipping fees */
elseif (isset($_POST['submitFees'.$this->table]))
{
if ($this->tabAccess['edit'] === '1')
{
if (($id_carrier = (int)(Tools::getValue('id_carrier'))) AND $id_carrier == ($id_carrier2 = (int)(Tools::getValue('id_carrier2'))))
{
$carrier = new Carrier($id_carrier);
if (Validate::isLoadedObject($carrier))
{
/* Get configuration values */
$shipping_method = $carrier->getShippingMethod();
$rangeTable = $carrier->getRangeTable();
$carrier->deleteDeliveryPrice($rangeTable);
/* Build prices list */
$priceList = '';
foreach ($_POST AS $key => $value)
if (strstr($key, 'fees_'))
{
$tmpArray = explode('_', $key);
$priceList .= '('.($shipping_method == Carrier::SHIPPING_METHOD_PRICE ? (int)($tmpArray[2]) : 'NULL').',
'.($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT ? (int)($tmpArray[2]) : 'NULL').', '.$carrier->id.',
'.(int)($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 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">
<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']) ? '&nbsp;'.$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">
<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((int)(Configuration::get('PS_LANG_DEFAULT')), true , false,false, NULL, PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
$id_carrier = Tools::getValue('id_carrier') ? (int)(Tools::getValue('id_carrier')) : (int)($carriers[0]['id_carrier']);
$carrierSelected = new Carrier($id_carrier);
foreach ($carriers AS $carrier)
echo '<option value="'.(int)($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>';
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$rangeObj = $carrierSelected->getRangeObject();
$rangeTable = $carrierSelected->getRangeTable();
$suffix = $carrierSelected->getRangeSuffix();
$rangeIdentifier = 'id_'.$rangeTable;
$ranges = $rangeObj->getRanges($id_carrier);
$delivery = Carrier::getDeliveryPriceByRanges($rangeTable, $id_carrier);
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;">'.(float)($range['delimiter1']).$suffix.' '.$this->l('to').' '.(float)($range['delimiter2']).$suffix.'</th>';
echo '</tr>';
$zones = $carrierSelected->getZones();
if (sizeof($ranges))
{
if(sizeof($zones) > 1)
{
echo '
<tr>
<th style="height: 30px;">'.$this->l('All').'</th>';
foreach ($ranges AS $range)
echo '<td class="center">'.$currency->getSign('left').'<input type="text" id="fees_all_'.$range[$rangeIdentifier].'" onkeyup="if ((event.keyCode||event.which) != 9){ spreadFees('.$range[$rangeIdentifier].') }" style="width: 45px;" />'.$currency->getSign('right').'</td>';
echo '</tr>';
}
foreach ($zones AS $zone)
{
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" class="fees_'.$range[$rangeIdentifier].'" name="fees_'.$zone['id_zone'].'_'.$range[$rangeIdentifier].'" onkeyup="clearAllFees('.$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 do not include tax.').'</p>
</fieldset>
<input type="hidden" name="id_carrier" value="'.$id_carrier.'" />
</form>';
}
}
-120
View File
@@ -1,120 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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', 'align' => 'right'));
$this->optionTitle = $this->l('Slip');
parent::__construct();
}
public function postProcess()
{
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))
{
$orderSlips = OrderSlip::getSlipsIdByDate(Tools::getValue('date_from'), Tools::getValue('date_to'));
if (count($orderSlips))
Tools::redirectAdmin('pdf.php?slips&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&token='.$this->token);
$this->_errors[] = $this->l('No order slips found for this period');
}
}
return parent::postProcess();
}
public function display()
{
global $cookie, $currentIndex;
echo '<div style="float:left;width:600px">';
$this->getList((int)($cookie->id_lang), !Tools::getValue($this->table.'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL);
$this->displayList();
echo '</div>';
echo '
<fieldset style="float:left;width:280px"><legend><img src="../img/admin/pdf.gif" alt="" /> '.$this->l('Print PDF').'</legend>
<form action="'.$currentIndex.'&token='.$this->token.'" method="post">
<label style="width:90px">'.$this->l('From:').' </label>
<div class="margin-form" style="padding-left:100px">
<input type="text" size="4" maxlength="10" name="date_from" value="'.date('Y-m-01').'" style="width: 120px;" />
<p class="clear">'.$this->l('Format: 2007-12-31 (inclusive)').'</p>
</div>
<label style="width:90px">'.$this->l('To:').' </label>
<div class="margin-form" style="padding-left:100px">
<input type="text" size="4" maxlength="10" name="date_to" value="'.date('Y-m-t').'" style="width: 120px;" />
<p class="clear">'.$this->l('Format: 2008-12-31 (inclusive)').'</p>
</div>
<div class="margin-form" style="padding-left:100px">
<input type="submit" value="'.$this->l('Generate PDF file').'" name="submitPrint" class="button" />
</div>
</form>
</fieldset><div class="clear">&nbsp;</div>';
}
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>';
}
}
}
-161
View File
@@ -1,161 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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 postProcess()
{
if (!isset($this->table)) return false;
/* Delete object */
if (isset($_GET['delete'.$this->table]))
{
global $currentIndex;
// set token
$token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
// Sub included tab postProcessing
$this->includeSubTab('postProcess', array('submitAdd1', 'submitDel', 'delete', 'submitFilter', 'submitReset'));
if ($this->tabAccess['delete'] === '1')
{
if (Validate::isLoadedObject($object = $this->loadObject()) AND isset($this->fieldImageSettings))
{
if (!$object->isUsed())
{
// 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><br />'.Tools::displayError('You cannot delete all of the items.');
else
{
$this->deleteImage($object->id);
if ($this->deleted)
{
$object->deleted = 1;
if ($object->update()) Tools::redirectAdmin($currentIndex.'&conf=1&token='.$token);
}
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('This state is currently in use');
}
}
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();
}
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
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/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 (search on Wikipedia if you don\'t know)').'</p>
</div>
<label>'.$this->l('Country:').' </label>
<div class="margin-form">
<select name="id_country">';
$countries = Country::getCountries((int)($cookie->id_lang), false, true);
foreach ($countries AS $country)
echo '<option value="'.(int)($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="'.(int)($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('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>';
}
}
-35
View File
@@ -1,35 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(dirname(__FILE__).'/AdminStatsTab.php');
class AdminStats extends AdminStatsTab
{
}
-119
View File
@@ -1,119 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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 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.'&nbsp;</option>';
echo ' </select>
</div>';
#End Of Form
echo '<input type="submit" value="'.$this->l(' Save ').'" name="submitSettings" class="button" />
</fieldset>
</form>';
}
}
-253
View File
@@ -1,253 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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 is invalid');
}
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 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">&nbsp;</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">&nbsp;</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" style="margin-top:2px">
<input type="submit" name="submitDateMonthPrev" class="button" value="'.$translations['Month'].'-1" style="margin-top:2px">
<input type="submit" name="submitDateYearPrev" class="button" value="'.$translations['Year'].'-1" style="margin-top:2px">
<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()
{
return Db::getInstance()->ExecuteS('
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`
WHERE h.`name` LIKE \'AdminStatsModules\'
AND m.`active` = 1
ORDER BY hm.`position`');
}
public function displayMenu()
{
global $currentIndex, $cookie;
$modules = $this->getModules();
echo '<fieldset style="width: 200px"><legend><img src="../img/admin/navigation.png" /> '.$this->l('Navigation', 'AdminStatsTab').'</legend>';
if (sizeof($modules))
{
foreach ($modules AS $module)
if ($moduleInstance = Module::getInstanceByName($module['name']))
echo '<h4><img src="../modules/'.$module['name'].'/logo.gif" /><a href="'.$currentIndex.'&token='.Tools::getValue('token').'&module='.$module['name'].'">'.$moduleInstance->displayName.'</a></h4>';
}
else
echo $this->l('No module installed', 'AdminStatsTab');
echo '</fieldset><div class="clear space">&nbsp;</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')) AND $moduleInstance = Module::getInstanceByName('statsforecast') AND $moduleInstance->active)
$moduleName = 'statsforecast';
if ($moduleName)
{
// Needed for the graphics display when this is the default module
$_GET['module'] = $moduleName;
if (!isset($moduleInstance))
$moduleInstance = Module::getInstanceByName($moduleName);
if ($moduleInstance AND $moduleInstance->active)
echo Module::hookExec('AdminStatsModules', NULL, $moduleInstance->id);
else
echo $this->l('Module not found', 'AdminStatsTab');
}
else
echo '<h3 class="space">'.$this->l('Please select a module in the left column.').'</h3>';
echo '</div><div class="clear"></div>';
}
}
-86
View File
@@ -1,86 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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 statuses').'</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">&nbsp;</div>';
echo '<h2>'.$this->l('Order return statuses').'</h2>';
$this->adminReturnStates->display($this->token);
}
}
}
-199
View File
@@ -1,199 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminStockMvt extends AdminTab
{
public function __construct()
{
$this->table = 'stock_mvt';
$this->className = 'StockMvt';
$this->edit = false;
$this->delete = false;
$this->view = true;
$this->fieldsDisplay = array(
'id_stock_mvt' => array('title' => $this->l('ID'), 'width' => 40),
'product_name' => array('title' => $this->l('Product Name'), 'width' => 250, 'havingFilter' => true),
'quantity' => array('title' => $this->l('Quantity'), 'width' => 40),
'reason' => array('title' => $this->l('Reason'), 'width' => 250),
'id_order' => array('title' => $this->l('ID Order'), 'width' => 40),
'employee' => array('title' => $this->l('Employee'), 'width' => 100, 'havingFilter' => true),
);
global $cookie;
$this->_select = 'CONCAT(pl.name, \' \', GROUP_CONCAT(IFNULL(al.name, \'\'), \'\')) product_name, CONCAT(e.lastname, \' \', e.firstname) employee, mrl.name reason';
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (a.id_product = pl.id_product AND pl.id_lang = '.(int)$cookie->id_lang.')
LEFT JOIN `'._DB_PREFIX_.'stock_mvt_reason_lang` mrl ON (a.id_stock_mvt_reason = mrl.id_stock_mvt_reason AND mrl.id_lang = '.(int)$cookie->id_lang.')
LEFT JOIN `'._DB_PREFIX_.'employee` e ON (e.id_employee = a.id_employee)
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.id_product_attribute = a.id_product_attribute)
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (al.id_attribute = pac.id_attribute AND al.id_lang = '.(int)$cookie->id_lang.')';
$this->_group = 'GROUP BY a.id_stock_mvt';
parent::__construct();
}
public function postProcess()
{
global $cookie;
if (Tools::isSubmit('rebuildStock'))
StockMvt::addMissingMvt((int)$cookie->id_employee, false);
return parent::postProcess();
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
$dl = 'name';
echo '<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'&addstock_mvt_reason" method="post">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
<fieldset><legend><img src="../img/admin/search.gif" />'.$this->l('Stock Movement').'</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="40" type="text" name="name_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'name', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $dl, 'name');
echo '</div>
<div class="clear space">&nbsp;</div>
<label>'.$this->l('Action:').'</label>
<div class="margin-form">
<select name="sign">
<option value="1">'.$this->l('Increase stock').'</option>
<option value="-1">'.$this->l('Decrease stock').'</option>
</select>
</div>
<div class="clear space">&nbsp;</div>';
echo '<div class="margin-form">
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
</div>
</fieldset>
</form>';
}
public function viewstock_mvt()
{
global $cookie;
$stockMvt = new StockMvt((int)Tools::getValue('id_stock_mvt'));
$product = new Product((int)$stockMvt->id_product, true, (int)$cookie->id_lang);
$movements = $product->getStockMvts((int)$cookie->id_lang);
echo '<h2>'.$this->l('Stock Movements for').' '.$product->name.'</h2>
<table cellspacing="0" cellpadding="0" class="table widthfull">
<tr>
<th>'.$this->l('ID').'</th>
<th>'.$this->l('Product Name').'</th>
<th>'.$this->l('Quantity').'</th>
<th>'.$this->l('Reason').'</th>
<th>'.$this->l('Employee').'</th>
<th>'.$this->l('Order').'</th>
<th>'.$this->l('Date').'</th>
</tr>';
$irow = 0;
foreach ($movements AS $k => $mvt)
{
echo '
<tr class="'.($irow++ % 2 ? 'alt_row' : '').'">
<td>'.$mvt['id_stock_mvt'].'</td>
<td>'.$mvt['product_name'].'</td>
<td>'.$mvt['quantity'].'</td>
<td>'.$mvt['reason'].'</td>
<td>'.$mvt['employee'].'</td>
<td>#'.$mvt['id_order'].'</td>
<td>'.Tools::displayDate($mvt['date_add'], (int)($cookie->id_lang)).'</td>
</tr>';
}
echo '</table>';
}
public function display()
{
global $currentIndex, $cookie;
$old_post = false;
if (!isset($_GET['addstock_mvt_reason']) OR (Tools::isSubmit('submitAddstock_mvt_reason') AND Tools::getValue('id_stock_mvt_reason')))
{
if (isset($_POST))
{
$old_post = $_POST;
}
echo '<h2>'.$this->l('Stock movement history').'</h2>';
parent::display();
if (!isset($_GET['view'.$this->table]))
echo '
<fieldset>
<form method="post" action="'.$currentIndex.'&token='.$this->token.'&rebuildMvt=1">
<label for="stock_rebuild">'.$this->l('Calculate the movement of inventory missing').'</label>
<div class="margin-form">
<input class="button" type="submit" name="rebuildStock" value="'.$this->l('Submit').'" />
</div>
</form>
</fieldset><br />';
}
if (isset($_GET['view'.$this->table]))
return;
if ($old_post)
$_POST = $old_post;
$this->table = 'stock_mvt_reason';
$this->className = 'StockMvtReason';
$this->identifier = 'id_stock_mvt_reason';
$this->edit = true;
$this->delete = true;
$this->lang = true;
$this->add = true;
$this->view = false;
$this->_listSkipDelete = array(1,2,3,4);
$this->_defaultOrderBy = $this->identifier;
$this->fieldsDisplay = array('id_stock_mvt_reason' => array('title' => $this->l('ID'), 'width' => 40),
'sign' => array('title' => $this->l('Sign'), 'width' => 15, 'align' => 'center', 'type' => 'select', 'icon' => array(-1 => 'arrow_down.png', 1 => 'arrow_up.png'), 'orderby' => false),
'name' => array('title' => $this->l('Name'), 'width' => 500));
$reasons = StockMvtReason::getStockMvtReasons((int)$cookie->id_lang);
$this->_fieldsOptions = array('PS_STOCK_MVT_REASON_DEFAULT' => array('title' => $this->l('Default Stock Movement reason:'),
'cast' => 'intval',
'type' => 'select',
'list' => $reasons,
'identifier' => 'id_stock_mvt_reason'));
unset($this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter);
echo '<h2>'.$this->l('Stock movement reason').'</h2>';
$this->postProcess();
return parent::display();
}
}
-303
View File
@@ -1,303 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(dirname(__FILE__).'/../../classes/AdminTab.php');
class AdminStores extends AdminTab
{
/** @var array countries list */
private $countriesArray = array();
public function __construct()
{
global $cookie;
$this->table = 'store';
$this->className = 'Store';
$this->lang = false;
$this->edit = true;
$this->delete = true;
$this->fieldImageSettings = array('name' => 'image', 'dir' => 'st');
$this->_select = 'cl.`name` country, st.`name` state';
$this->_join = '
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (cl.`id_country` = a.`id_country` AND cl.`id_lang` = '.(int)($cookie->id_lang).')
LEFT JOIN `'._DB_PREFIX_.'state` st ON (st.`id_state` = a.`id_state`)';
$countries = Country::getCountries((int)($cookie->id_lang));
foreach ($countries AS $country)
$this->countriesArray[$country['id_country']] = $country['name'];
$this->fieldsDisplay = array(
'id_store' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'country' => array('title' => $this->l('Country'), 'width' => 100),
'state' => array('title' => $this->l('State'), 'width' => 100),
'city' => array('title' => $this->l('City'), 'width' => 100),
'postcode' => array('title' => $this->l('Zip code'), 'width' => 50),
'name' => array('title' => $this->l('Name'), 'width' => 120),
'phone' => array('title' => $this->l('Phone'), 'width' => 70),
'fax' => array('title' => $this->l('Fax'), 'width' => 70),
'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false)
);
$this->optionTitle = $this->l('Parameters');
$this->_fieldsOptions = array(
'PS_STORES_DISPLAY_FOOTER' => array('title' => $this->l('Display in the footer:'), 'desc' => $this->l('Display a link to the store locator in the footer'), 'cast' => 'intval', 'type' => 'bool'),
'PS_STORES_DISPLAY_SITEMAP' => array('title' => $this->l('Display in the sitemap page:'), 'desc' => $this->l('Display a link to the store locator in the sitemap page'), 'cast' => 'intval', 'type' => 'bool'),
'PS_STORES_SIMPLIFIED' => array('title' => $this->l('Show a simplified store locator:'), 'desc' => $this->l('No map, no search, only a store directory'), 'cast' => 'intval', 'type' => 'bool'),
'PS_STORES_CENTER_LAT' => array('title' => $this->l('Latitude by default:'), 'desc' => $this->l('Used for the position by default of the map'), 'cast' => 'floatval', 'type' => 'float', 'size' => '10'),
'PS_STORES_CENTER_LONG' => array('title' => $this->l('Longitude by default:'), 'desc' => $this->l('Used for the position by default of the map'), 'cast' => 'floatval', 'type' => 'float', 'size' => '10'));
parent::__construct();
}
protected function postImage($id)
{
$ret = parent::postImage($id);
if (($id_store = (int)(Tools::getValue('id_store'))) AND isset($_FILES) AND sizeof($_FILES) AND file_exists(_PS_STORE_IMG_DIR_.$id_store.'.jpg'))
{
$imagesTypes = ImageType::getImagesTypes('categories');
foreach ($imagesTypes AS $k => $imageType)
imageResize(_PS_STORE_IMG_DIR_.$id_store.'.jpg', _PS_STORE_IMG_DIR_.$id_store.'-'.stripslashes($imageType['name']).'.jpg', (int)($imageType['width']), (int)($imageType['height']));
}
return $ret;
}
public function displayOptionsList()
{
parent::displayOptionsList();
echo '<br /><p><img src="../img/admin/asterisk.gif" class="middle" /> '.$this->l('You can also replace the icon representing your store in Google Maps. Go to the Preferences tab, and then the Appearance subtab.').'</p>';
}
public function postProcess()
{
if (isset($_POST['submitAdd'.$this->table]))
{
/* Cleaning fields */
foreach ($_POST as $kp => $vp)
$_POST[$kp] = trim($vp);
/* If the selected country does not contain states */
$id_state = (int)(Tools::getValue('id_state'));
if ($id_country = Tools::getValue('id_country') AND $country = new Country((int)($id_country)) AND !(int)($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 ((int)($country->contains_states) AND !$id_state)
$this->_errors[] = Tools::displayError('An address located in a country containing states must have a state selected.');
/* Check zip code */
if ($country->need_zip_code)
{
$zip_code_format = $country->zip_code_format;
if (($postcode = Tools::getValue('postcode')) AND $zip_code_format)
{
$zip_regexp = '/^'.$zip_code_format.'$/ui';
$zip_regexp = str_replace(' ', '( |)', $zip_regexp);
$zip_regexp = str_replace('-', '(-|)', $zip_regexp);
$zip_regexp = str_replace('N', '[0-9]', $zip_regexp);
$zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp);
$zip_regexp = str_replace('C', $country->iso_code, $zip_regexp);
if (!preg_match($zip_regexp, $postcode))
$this->_errors[] = Tools::displayError('Your zip/postal code is incorrect.').'<br />'.Tools::displayError('Must be typed as follows:').' '.str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $zip_code_format)));
}
elseif ($zip_code_format)
$this->_errors[] = Tools::displayError('Postcode required.');
elseif ($postcode AND !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode))
$this->_errors[] = Tools::displayError('Your zip/postal code is incorrect.');
}
/* Store hours */
$_POST['hours'] = array();
for ($i = 1; $i < 8; $i++)
$_POST['hours'][] .= Tools::getValue('hours_'.(int)($i));
$_POST['hours'] = serialize($_POST['hours']);
}
if (!sizeof($this->_errors))
parent::postProcess();
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
echo '
<script type="text/javascript">
$(document).ready(function(){
ajaxStates ();
$(\'#id_country\').change(function() {
ajaxStates ();
});
function ajaxStates ()
{
$.ajax({
url: "ajax.php",
cache: false,
data: "ajaxStates=1&id_country="+$(\'#id_country\').val()+"&id_state="+$(\'#id_state\').val(),
success: function(html)
{
if (html == \'false\')
$("#contains_states").fadeOut();
else
{
$("#id_state").html(html);
$("#contains_states").fadeIn();
}
}
});
};
});
</script>
<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>
<legend><img src="../img/admin/home.gif" />'.$this->l('Stores').'</legend>
<div style="padding-right: 40px; border-right: 1px solid #E0D0B1; float: left;">
<label>'.$this->l('Name:').'</label>
<div class="margin-form">
<input type="text" size="33" name="name" value="'.htmlentities(Tools::getValue('name', $obj->name), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Allowed characters: letters, spaces and').' (-)<span class="hint-pointer">&nbsp;</span></span>
<p class="clear">'.$this->l('Store name, e.g. Citycentre Mall Store').'</p>
</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('Postcode/ Zip Code:').'</label>
<div class="margin-form">
<input type="text" size="6" name="postcode" value="'.htmlentities($this->getFieldValue($obj, 'postcode'), ENT_COMPAT, 'UTF-8').'" />
</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"/>';
$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>
<div id="contains_states">
<label>'.$this->l('State:').'</label>
<div class="margin-form">
<select name="id_state" id="id_state">
</select> <sup>*</sup>
</div>
</div>
<label>'.$this->l('Latitude / Longitude:').'</label>
<div class="margin-form">
<input type="text" size="8" maxlength="10" name="latitude" value="'.htmlentities($this->getFieldValue($obj, 'latitude'), ENT_COMPAT, 'UTF-8').'" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" /> / <input type="text" size="8" maxlength="10" name="longitude" value="'.htmlentities($this->getFieldValue($obj, 'longitude'), ENT_COMPAT, 'UTF-8').'" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" />
<p class="clear">'.$this->l('Store coords, eg. 45.265469 / -47.226478').'</p>
</div>
<label>'.$this->l('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('Fax:').'</label>
<div class="margin-form">
<input type="text" size="33" name="fax" value="'.htmlentities($this->getFieldValue($obj, 'fax'), ENT_COMPAT, 'UTF-8').'" />
</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').'" />
</div>
<label>'.$this->l('Note:').' </label>
<div class="margin-form">
<textarea name="note" style="width: 250px; height: 75px;">'.htmlentities($this->getFieldValue($obj, 'note'), ENT_COMPAT, 'UTF-8').'</textarea>
</div>
<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('Enabled').'" title="'.$this->l('Enabled').'" /></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('Disabled').'" title="'.$this->l('Disabled').'" /></label>
<p>'.$this->l('Display or not this store').'</p>
</div>
</div>
<div style="padding-left: 40px; float: left;">
<label style="text-align: left; width: inherit;">'.$this->l('Picture:').' </label>
<div class="margin-form" style="padding: 0; display: inline;">
<input type="file" name="image" />
<p class="clear">'.$this->l('Store window picture').'</p>';
echo $this->displayImage($obj->id, _PS_STORE_IMG_DIR_.'/'.$obj->id.'.jpg', 350, NULL, Tools::getAdminToken('AdminStores'.(int)(Tab::getIdFromClassName('AdminStores')).(int)($cookie->id_employee)));
echo '</div>
<table cellpadding="2" cellspacing="2" style="padding: 10px; margin-top: 15px; border: 1px solid #BBB;">
<tr>
<th colspan="2">'.$this->l('Hours:').'</th>
</tr>
<tr>
<td>&nbsp;</td>
<td style="font-size: 0.85em;">'.$this->l('Sample: 10:00AM - 9:30PM').'</td>
</tr>';
$days = array();
$days[1] = $this->l('Monday');
$days[2] = $this->l('Tuesday');
$days[3] = $this->l('Wednesday');
$days[4] = $this->l('Thursday');
$days[5] = $this->l('Friday');
$days[6] = $this->l('Saturday');
$days[7] = $this->l('Sunday');
$hours = $this->getFieldValue($obj, 'hours');
if (!empty($hours))
$hoursUnserialized = unserialize($hours);
for ($i = 1; $i < 8; $i++)
echo '
<tr style="color: #7F7F7F; font-size: 0.85em;">
<td>'.$days[(int)($i)].'</td>
<td><input type="text" size="25" name="hours_'.(int)($i).'" value="'.(isset($hoursUnserialized) ? htmlentities($hoursUnserialized[$i - 1], ENT_COMPAT, 'UTF-8') : '').'" /><br /></td>
</tr>';
echo '
</table>
</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>';
}
}
-89
View File
@@ -1,89 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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()
{
$this->displayWarning($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".'));
return parent::displayList();
}
public function displayForm($isMainTab = true)
{
global $currentIndex;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
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/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('Additional 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();
}
}
-224
View File
@@ -1,224 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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),
'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false)
);
parent::__construct();
}
public function viewsupplier()
{
global $cookie;
if (!($supplier = $this->loadObject()))
return;
echo '<h2>'.$supplier->name.'</h2>';
$products = $supplier->getProductsLite((int)($cookie->id_lang));
echo '<h3>'.$this->l('Total products:').' '.sizeof($products).'</h3>';
foreach ($products AS $product)
{
$product = new Product($product['id_product'], false, (int)($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'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($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>' : '').'
'.(!empty($product->upc) ? '<th width="120">'.$this->l('UPC:').' '.$product->upc.'</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'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($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>
<th width="80">'.$this->l('UPC').'</th>
'.(Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="40">'.$this->l('Quantity').'</th>' : '').'
</tr>';
/* Build attributes combinaisons */
$combinaisons = $product->getAttributeCombinaisons((int)($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']]['upc'] = $combinaison['upc'];
$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>'.$product_attribute['upc'].'</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();
if (!($supplier = $this->loadObject(true)))
return;
$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">
'.($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">&nbsp;</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" />
<span class="hint" name="help_box">'.$this->l('Forbidden characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, $langtags, 'smeta_keywords');
echo ' <div class="clear"></div>
</div>
<label>'.$this->l('Enable:').' </label>
<div class="margin-form">
<input type="radio" name="active" id="active_on" value="1" '.($this->getFieldValue($supplier, '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($supplier, '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>
<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()
{
/* Generate image with differents size */
if (($id_supplier = (int)(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', (int)($imageType['width']), (int)($imageType['height']));
}
}
}
}
-178
View File
@@ -1,178 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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` = '.(int)($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((int)($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 = (int)(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>&nbsp;';
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((int)($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((int)($cookie->id_lang), $t['id_tab']));
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
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.'" />' : '').'
'.($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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name');
echo '
</div>
<div class="clear">&nbsp;</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">&nbsp;</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">&nbsp;</div>
<label>'.$this->l('Icon').'</label>
<div class="margin-form">
'.($obj->id ? '<img src="../img/t/'.$obj->class_name.'.gif" />&nbsp;/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">&nbsp;</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((int)($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">&nbsp;</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()
{
if (!($obj = $this->loadObject(true)))
return;
@rename(_PS_IMG_DIR_.'t/'.$obj->id.'.gif', _PS_IMG_DIR_.'t/'.$obj->class_name.'.gif');
}
}
-139
View File
@@ -1,139 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminTags extends AdminTab
{
public function __construct()
{
global $cookie;
$this->table = 'tag';
$this->className = 'Tag';
$this->edit = true;
$this->delete = true;
$this->fieldsDisplay = array(
'id_tag' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25, 'filter_key' => 'a!id_seller_message'),
'lang' => array('title' => $this->l('Language'), 'filter_key' => 'l!name'),
'name' => array('title' => $this->l('Name'), 'width' => 200, 'filter_key' => 'a!name'),
'products' => array('title' => $this->l('Products'), 'align' => 'right', 'havingFilter' => true));
$this->_select = 'l.name as lang, COUNT(pt.id_product) as products';
$this->_join = '
LEFT JOIN `'._DB_PREFIX_.'product_tag` pt ON (a.`id_tag` = pt.`id_tag`)
LEFT JOIN `'._DB_PREFIX_.'lang` l ON (l.`id_lang` = a.`id_lang`)';
$this->_group = 'GROUP BY a.name, a.id_lang';
parent::__construct();
}
public function postProcess()
{
if ($this->tabAccess['edit'] === '1' AND Tools::getValue('submitAdd'.$this->table))
if ($id = (int)(Tools::getValue($this->identifier)) AND $obj = new $this->className($id) AND Validate::isLoadedObject($obj))
$obj->setProducts($_POST['products']);
return parent::postProcess();
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
$products1 = $obj->getProducts(true);
$products2 = $obj->getProducts(false);
echo '
<form id="formTag" action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post" class="width5">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
<fieldset><legend><img src="../img/t/AdminTags.gif" />'.$this->l('Tag').'</legend>
<label>'.$this->l('Name').' </label>
<div class="margin-form">
<input type="text" size="33" name="name" value="'.htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
</div>
<label>'.$this->l('Language').' </label>
<div class="margin-form">
<select name="id_lang">
<option value="">-</option>';
foreach ($this->_languages as $language)
echo ' <option value="'.$language['id_lang'].'" '.($language['id_lang'] == $this->getFieldValue($obj, 'id_lang') ? 'selected="selected"' : '').'>'.$language['name'].'</option>';
echo ' </select> <sup>*</sup>
</div>
<h3>'.$this->l('Products').' </h3>
<table>
<tr>
<td>
<select multiple id="select1" name="products[]" style="width:300px;height:160px;">';
foreach ($products1 as $product)
echo ' <option value="'.$product['id_product'].'">'.$product['name'].'</option>';
echo ' </select><br /><br />
<a href="#" id="add"
style="text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px">
'.$this->l('Remove').' &gt;&gt;
</a>
</td>
<td style="padding-left:20px;">
<select multiple id="select2" style="width:300px;height:160px;">';
foreach ($products2 as $product)
echo ' <option value="'.$product['id_product'].'">'.$product['name'].'</option>';
echo ' </select><br /><br />
<a href="#" id="remove"
style="text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px">
&lt;&lt; '.$this->l('Add').'
</a>
</div>
</td>
</tr>
</table>
<div class="clear">&nbsp;</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>
<script type="text/javascript">
$().ready(function() {
$(\'#add\').click(function() {
return !$(\'#select1 option:selected\').remove().appendTo(\'#select2\');
});
$(\'#remove\').click(function() {
return !$(\'#select2 option:selected\').remove().appendTo(\'#select1\');
});
});
$(\'#formTag\').submit(function() {
$(\'#select1 option\').each(function(i) {
$(this).attr("selected", "selected");
});
});
</script>';
}
}
-565
View File
@@ -1,565 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminTaxRulesGroup extends AdminTab
{
public function __construct()
{
global $cookie;
$this->table = 'tax_rules_group';
$this->className = 'TaxRulesGroup';
$this->edit = true;
$this->delete = true;
$this->fieldsDisplay = array(
'id_tax_rules_group' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'name' => array('title' => $this->l('Name'), 'width' => 140),
'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status'.$this->table, 'type' => 'bool', 'orderby' => false));
parent::__construct();
}
public function displayTop()
{
echo '<div class="hint clear" style="display:block;">
'.$this->l('The tax rules allow you to define a product or a carrier with different taxes depending on their location (country, state, etc.).').'
<b>'.$this->l('In the majority of cases, the rules created by default by PrestaShop should be enough.').'</b> '.
$this->l('If, however, you need to change them, here is an example that will help you understand how it works:').
'<br /><br />'
.$this->l('You want to apply a tax of 19.6% to a product in France and Europe, but not apply this tax to other countries. Follow these steps:').'
<ul>
<li>'.$this->l('Click "Add New".').'</li>
<li>'.$this->l('Give a name to your tax rule (ex: "19.6% tax rule”).').'</li>
<li>'.$this->l('Move the current field to true.').'</li>
<li>'.$this->l('Edit its configuration by country by associating a 19.6% tax with France and with European countries, and a tax of 0% to other countries.').'</li>
<li>'.$this->l('Click on Save.').'</li>
<li>'.$this->l('Go to your product page (Catalog tab) and associate the "19.6% tax rule" to your product.').'</li>
</ul>
<br />
'.$this->l('Later, if you need to apply a different tax to Spain, you can simply edit the rule "19.6% tax rule" and change the tax associated with Spain.').'<br />
'.$this->l('Note: The default rate applied to your product will be based on your stores default country.').'
</div><br />';
}
public function displayForm($isMainTab = true)
{
global $cookie, $currentIndex;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
$tax_rules = isset($obj->id) ? $tax_rules = TaxRule::getTaxRulesByGroupId($obj->id) : array();
$param_product = Tools::getValue('id_product') ? '&id_product='.Tools::getValue('id_product') : '';
echo '<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.$param_product.'" method="post">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
<fieldset><legend><img src="../img/admin/dollar.gif" />'.$this->l('Tax Rules').'</legend>
<input type="hidden" name="tabs" id="tabs" value="0" />
';
echo '<label>'.$this->l('Name').'</label>
<div class="margin-form">
<input size="33" type="text" name="name" value="'.Tools::htmlentitiesUTF8($this->getFieldValue($obj, 'name')).'" /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
<p class="clear"></p>
</div>';
echo '
<label>'.$this->l('Enable:').' </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>
</div>
<div class="margin-form">
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />&nbsp;
<input type="submit" value="'.$this->l('Save and stay').'" name="submitAdd'.$this->table.'AndStay" class="button" />
</div>';
echo '<br />';
echo '<div class="tab-panet-tax" id="tab-pane-1">
<script type="text/javascript">
var pos_select = '.(($tab = Tools::getValue('tabs')) ? $tab : '0').';
function loadTab(id)
{}
function applyTax(id_zone)
{
cur_tax = $("#zone_"+id_zone).val();
$(".tax_"+id_zone).val(cur_tax);
return false;
}
function disableStateTaxRate(id_country, id_state)
{
if ($("#behavior_state_"+id_state).val() == '.PS_PRODUCT_TAX.')
$("#tax_"+id_country+"_"+id_state).attr("disabled", true);
else
$("#tax_"+id_country+"_"+id_state).attr("disabled", false);
}
function disableCountyTaxRate(id_country, id_state, id_county)
{
if ($("#behavior_county_"+id_county).val() == '.County::USE_STATE_TAX.')
$("#tax_"+id_country+"_"+id_state+"_"+id_county).attr("disabled", true);
else
{
$("#tax_"+id_country+"_"+id_state+"_"+id_county).attr("disabled", false);
}
}
$(\'document\').ready(function (){
$(\'.states\').hide();
$(\'.counties\').hide();
$(\'.open_state\').click(function (){
if ($(\'.\'+$(this).attr(\'id\')).is(\':hidden\'))
{
$(\'.\'+$(this).attr(\'id\')).show();
$(\'#\'+$(this).attr(\'id\')+\'_button\').attr("src","../img/admin/less.png");
}
else
{
$(\'.\'+$(this).attr(\'id\')).hide();
$(\'.county_\'+$(this).attr(\'id\')).hide();
$(\'.county_\'+$(this).attr(\'id\')+\'_button\').attr("src","../img/admin/more.png");
$(\'#\'+$(this).attr(\'id\')+\'_button\').attr("src","../img/admin/more.png");
}
});
$(\'.open_county\').click(function (){
if ($(\'.\'+$(this).attr(\'id\')).is(\':hidden\'))
{
$(\'.\'+$(this).attr(\'id\')).show();
$(\'#\'+$(this).attr(\'id\')+\'_button\').attr("src","../img/admin/less.png");
}
else
{
$(\'.\'+$(this).attr(\'id\')).hide();
$(\'#\'+$(this).attr(\'id\')+\'_button\').attr("src","../img/admin/more.png");
}
});
});
</script>
<script src="../js/tabpane.js" type="text/javascript"></script>
<script type="text/javascript">
var tabPane1 = new WebFXTabPane( document.getElementById( "tab-pane-1" ) );
</script>
<link type="text/css" rel="stylesheet" href="../css/tabpane.css" />'.$this->renderZones($tax_rules, (int)$cookie->id_lang);
echo '
<div class="margin-form" style="margin-top: 10px">
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />&nbsp;&nbsp;
<input type="submit" value="'.$this->l('Save and stay').'" name="submitAdd'.$this->table.'AndStay" class="button" />
</div>
</fieldset>
</form>';
}
public function renderZones($tax_rules, $id_lang)
{
$html = '';
$zones = Zone::getZones(true);
foreach ($zones AS $key => $zone)
{
$html .= '<div class="tab-page" id="tab-page-'.$key.'">
<h4 class="tab">'.$zone['name'].'</h4>
<script type="text/javascript">
tabPane1.addTabPage( document.getElementById( "tab-page-'.$key.'" ) );
</script>
'.$this->renderCountries($tax_rules, $zone['id_zone'], $id_lang).'
</div>';
}
return $html;
}
public function renderCountries($tax_rules, $id_zone, $id_lang)
{
$html = '
<table>
<tr>
<td width="260px" style="font-weight:bold">'.$this->l('All').'</td>
<td>'.$this->renderTaxesSelect($id_lang, '', array('id' => 'zone_'.(int)$id_zone)).' <input type="submit" onclick="return applyTax(\''.(int)$id_zone.'\')" class="button" value="'.$this->l('Apply').'"/></td>
</tr>
</table><hr />';
$html .= '
<table class="table" cellpadding="0" cellspacing="0" style="width: 100%;">
<thead>
<tr>
<th style="width: 3%;"></th>
<th style="width: 40%;">'.$this->l('Country / State / County').'</th>
<th style="width: 57%;">'.$this->l('Tax to apply').'</th>
</tr>
</thead>
<tbody>
';
$countries = Country::getCountriesByZoneId((int)$id_zone, (int)$id_lang);
$countCountries = sizeof($countries);
$i = 1;
foreach ($countries AS $country)
{
$id_tax = 0;
if (array_key_exists($country['id_country'], $tax_rules) AND array_key_exists(0, $tax_rules[$country['id_country']]))
$id_tax = (int)$tax_rules[$country['id_country']][0][0]['id_tax'];
$html .= '
<tr>
<td>'.($country['contains_states'] ? '<a class="open_state" id="state_'.(int)$country['id_country'].'"><img id="state_'.(int)$country['id_country'].'_button" src="../img/admin/more.png" alt="" style="vertical-align:middle;padding:0;" /></a>' : '').'</td>
<td>
<img src="../img/admin/lv2_'.($i == $countCountries ? 'f' : 'b').'.png" alt="" style="vertical-align:middle;" /> <label class="t">'.Tools::htmlentitiesUTF8($country['name']).'</label>
</td>
<td>'.$this->renderTaxesSelect($id_lang, $id_tax, array('class' => 'tax_'.$id_zone, 'id' => 'tax_'.$country['id_country'].'_0', 'name' => 'tax_'.$country['id_country'].'_0' )).'</td>
</tr>
';
if ($country['contains_states'])
$html .= $this->renderStates($tax_rules, (int)$id_zone, (int)$country['id_country'], (int)$id_lang);
$i++;
}
$html .= '
</tbody>
</table>
';
return $html;
}
public function renderStates($tax_rules, $id_zone, $id_country, $id_lang)
{
$states = State::getStatesByIdCountry((int)$id_country);
$countStates = sizeof($states);
$i = 1;
$html = '';
foreach ($states AS $state)
{
$id_tax = 0;
$selected = PS_PRODUCT_TAX;
if (array_key_exists($id_country, $tax_rules)
AND array_key_exists($state['id_state'], $tax_rules[$id_country])
AND array_key_exists(0, $tax_rules[$id_country][$state['id_state']]))
{
$id_tax = (int)$tax_rules[$id_country][$state['id_state']][0]['id_tax'];
$selected = (int)$tax_rules[$id_country][$state['id_state']][0]['state_behavior'];
}
$disable = (PS_PRODUCT_TAX == $selected ? 'disabled' : '');
$html .= '
<tr class="states state_'.(int)$id_country.' alt_row">
<td>'.(State::hasCounties($state['id_state']) ? '<a class="open_county" id="county_'.(int)$state['id_state'].'"><img id="county_'.(int)$state['id_state'].'_button" class="county_state_'.(int)$id_country.'_button" src="../img/admin/more.png" alt="" /></a>' : '').'</td>
<td><img src="../img/admin/lv3_'.($i == $countStates ? 'f' : 'b').'.png" alt="" style="vertical-align:middle;" /> <label class="t">'.Tools::htmlentitiesUTF8($state['name']).'</label></td>
<td>
'.$this->renderTaxesSelect($id_lang, $id_tax, array('class' => 'tax_'.$id_zone,
'id' => 'tax_'.$id_country.'_'.$state['id_state'],
'name' => 'tax_'.$id_country.'_'.$state['id_state'],
'disabled' => $disable )).'&nbsp;-&nbsp;
<select id="behavior_state_'.$state['id_state'].'" name="behavior_state_'.$state['id_state'].'" onchange="disableStateTaxRate(\''.$id_country.'\',\''.$state['id_state'].'\')">
<option value="'.(int)PS_PRODUCT_TAX.'" '.($selected == PS_PRODUCT_TAX ? 'selected="selected"' : '').'>'.$this->l('Apply country tax only').'</option>
<option value="'.(int)PS_STATE_TAX.'" '.($selected == PS_STATE_TAX ? 'selected="selected"' : '').'>'.$this->l('Apply state tax only').'</option>
<option value="'.(int)PS_BOTH_TAX.'" '.($selected == PS_BOTH_TAX ? 'selected="selected"' : '').'>'.$this->l('Apply both taxes').'</option>
</select>
</td>
</tr>
';
if (State::hasCounties($state['id_state']))
$html .= $this->renderCounties($tax_rules, $id_zone, $id_country, $state['id_state'], $id_lang);
$i++;
}
return $html;
}
public function renderCounties($tax_rules, $id_zone, $id_country, $id_state, $id_lang)
{
$counties = County::getCounties((int)$id_state);
$countCounties = sizeof($counties);
$i = 1;
$html = '';
foreach ($counties AS $county)
{
$id_tax = 0;
$selected = County::USE_STATE_TAX;
if (array_key_exists($id_country, $tax_rules)
AND array_key_exists($id_state, $tax_rules[$id_country])
AND array_key_exists($county['id_county'], $tax_rules[$id_country][$id_state]))
{
$id_tax = (int)$tax_rules[$id_country][$id_state][$county['id_county']]['id_tax'];
$selected = (int)$tax_rules[$id_country][$id_state][$county['id_county']]['county_behavior'];
}
$disable = (County::USE_STATE_TAX == $selected ? 'disabled' : '');
$html .= '
<tr class="counties county_state_'.(int)$id_country.' county_'.(int)$id_state.'">
<td></td>
<td><img src="../img/admin/lv4_'.($i == $countCounties ? 'f' : 'b').'.png" alt="" style="vertical-align:middle;" /> <label class="t">'.Tools::htmlentitiesUTF8($county['name']).'</label></td>
<td>
'.$this->renderTaxesSelect($id_lang, $id_tax, array('class' => 'tax_'.$id_zone,
'id' => 'tax_'.$id_country.'_'.$id_state.'_'.$county['id_county'],
'name' => 'tax_'.$id_country.'_'.$id_state.'_'.$county['id_county'],
'disabled' => $disable )).'&nbsp;-&nbsp;
<select id="behavior_county_'.$county['id_county'].'" name="behavior_county_'.$county['id_county'].'" onchange="disableCountyTaxRate(\''.$id_country.'\',\''.$id_state.'\',\''.$county['id_county'].'\')">
<option value="'.(int)County::USE_STATE_TAX.'" '.($selected == County::USE_STATE_TAX ? 'selected="selected"' : '').'>'.$this->l('Apply state tax only').'</option>
<option value="'.(int)County::USE_COUNTY_TAX.'" '.($selected == County::USE_COUNTY_TAX ? 'selected="selected"' : '').'>'.$this->l('Apply county tax only').'</option>
<option value="'.(int)County::USE_BOTH_TAX.'" '.($selected == County::USE_BOTH_TAX ? 'selected="selected"' : '').'>'.$this->l('Apply both taxes').'</option>
</select>
</td>
</tr>
';
}
return $html;
}
public function renderTaxesSelect($id_lang, $default_value, array $html_options)
{
$opt = '';
foreach( array('id', 'class', 'name', 'disabled') AS $prop)
if (array_key_exists($prop, $html_options) && !empty($html_options[$prop]))
$opt .= $prop.'="'.$html_options[$prop].'"';
$html = '<select '.$opt.'>
<option value="0">'.$this->l('No Tax').'</option>';
$taxes = Tax::getTaxes((int)$id_lang, true);
foreach ($taxes AS $tax)
{
$selected = ($default_value == $tax['id_tax']) ? 'selected="selected"' : '';
$html .= '<option value="'.(int)$tax['id_tax'].'" '.$selected.'>'.Tools::htmlentitiesUTF8($tax['name']).'</option>';
}
$html .= '</select>';
return $html;
}
protected function afterAdd($object)
{
$this->afterUpdate($object);
}
protected function afterUpdate($object)
{
global $cookie;
TaxRule::deleteByGroupId($object->id);
foreach(Country::getCountries($cookie->id_lang, true) AS $country)
{
$id_tax = (int)Tools::getValue('tax_'.$country['id_country'].'_0');
// default country rule
if (!empty($id_tax))
{
$tr = new TaxRule();
$tr->id_tax_rules_group = $object->id;
$tr->id_country = (int)$country['id_country'];
$tr->id_state = 0;
$tr->id_county = 0;
$tr->id_tax = $id_tax;
$tr->state_behavior = 0;
$tr->county_behavior = 0;
$tr->save();
}
// state specific rule
if (!empty($country['contains_states']))
{
foreach ($country['states'] AS $state)
{
$state_behavior = (int)Tools::getValue('behavior_state_'.$state['id_state']);
if ($state_behavior != PS_PRODUCT_TAX)
{
$tr = new TaxRule();
$tr->id_tax_rules_group = $object->id;
$tr->id_country = (int)$country['id_country'];
$tr->id_state = (int)$state['id_state'];
$tr->id_county = 0;
$tr->id_tax = (int)Tools::getValue('tax_'.$country['id_country'].'_'.$state['id_state']);
$tr->state_behavior = $state_behavior;
$tr->county_behavior = 0;
$tr->save();
}
// county specific rule
if (State::hasCounties($state['id_state']))
{
$counties = County::getCounties($state['id_state']);
foreach ($counties AS $county)
{
$county_behavior = (int)Tools::getValue('behavior_county_'.$county['id_county']);
if ($county_behavior != County::USE_STATE_TAX)
{
$tr = new TaxRule();
$tr->id_tax_rules_group = $object->id;
$tr->id_country = (int)$country['id_country'];
$tr->id_state = (int)$state['id_state'];
$tr->id_county = (int)$county['id_county'];
$tr->id_tax = (int)Tools::getValue('tax_'.$country['id_country'].'_'.$state['id_state'].'_'.$county['id_county']);
$tr->state_behavior = 0;
$tr->county_behavior = $county_behavior;
$tr->save();
}
}
}
}
}
}
}
public function postProcess()
{
global $currentIndex, $cookie;
if (!isset($this->table))
return false;
// set token
$token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
if (Tools::getValue('submitAdd'.$this->table))
{
$id_product = Tools::getValue('id_product');
/* Checking fields validity */
$this->validateRules();
if (!sizeof($this->_errors))
{
$id = (int)(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))
{
// Create new one with old objet values
$objectNew = new $this->className($object->id);
$objectNew->id = NULL;
$objectNew->date_add = '';
$objectNew->date_upd = '';
// Update old object to deleted
$object->deleted = 1;
$object->update();
// Update new object with post values
$this->copyFromPost($objectNew, $this->table);
$result = $objectNew->add();
if (Validate::isLoadedObject($objectNew))
$this->afterDelete($objectNew, $object->id);
}
else
{
$this->copyFromPost($object, $this->table);
$result = $object->update();
$this->afterUpdate($object);
}
if (!$result)
$this->_errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.'</b> ('.Db::getInstance()->getMsgError().')';
elseif ($this->postImage($object->id) AND !sizeof($this->_errors))
{
$parent_id = (int)(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=4&update'.$this->table.'&token='.$token);
// Default behavior (save and back)
$id_product = (int)Tools::getValue('id_product');
if ($id_product)
Tools::redirectAdmin('?tab=AdminCatalog&id_product='.$id_product.'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)));
Tools::redirectAdmin($currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=3&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 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.' ('.mysql_error().')</b>';
elseif (($_POST[$this->identifier] = $object->id /* voluntary */) AND $this->postImage($object->id) AND !sizeof($this->_errors) AND $this->_redirect)
{
$parent_id = (int)(Tools::getValue('id_parent', 1));
$this->afterAdd($object);
// 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='.$token);
$id_product = (int)Tools::getValue('id_product');
if ($id_product)
Tools::redirectAdmin('?tab=AdminCatalog&id_product='.$id_product.'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)));
Tools::redirectAdmin($currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=3&token='.$token);
// Default behavior (save and back)
Tools::redirectAdmin($currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=3&token='.$token);
}
}
else
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
}
$this->_errors = array_unique($this->_errors);
}
parent::postProcess();
}
}
-192
View File
@@ -1,192 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminTaxes extends AdminTab
{
public function __construct()
{
global $cookie;
$this->table = 'tax';
$this->className = 'Tax';
$this->lang = true;
$this->edit = true;
$this->delete = true;
$this->fieldsDisplay = array(
'id_tax' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'name' => array('title' => $this->l('Name'), 'width' => 140),
'rate' => array('title' => $this->l('Rate'), 'align' => 'center', 'suffix' => '%', 'width' => 50),
'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
$this->optionTitle = $this->l('Tax options');
$this->_fieldsOptions = array(
'PS_TAX' => array('title' => $this->l('Enable tax:'), 'desc' => $this->l('Select whether or not to include tax on purchases'), 'cast' => 'intval', 'type' => 'bool'),
'PS_TAX_DISPLAY' => array('title' => $this->l('Display tax in cart:'), 'desc' => $this->l('Select whether or not to display tax on a distinct line in the cart'), 'cast' => 'intval', 'type' => 'bool'),
'PS_TAX_ADDRESS_TYPE' => array('title' => $this->l('Base on:'), 'cast' => 'pSQL', 'type' => 'select', 'list' => array(array('name' => $this->l('Invoice Address'), 'id' => 'id_address_invoice'), array('name' => $this->l('Delivery Address'), 'id' => 'id_address_delivery')), 'identifier' => 'id'),
'PS_USE_ECOTAX' => array('title' => $this->l('Use ecotax'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
);
if (Configuration::get('PS_USE_ECOTAX'))
$this->_fieldsOptions['PS_ECOTAX_TAX_RULES_GROUP_ID'] = array('title' => $this->l('Ecotax:'), 'desc' => $this->l('The tax to apply on the ecotax (e.g., French ecotax: 19.6%).'),
'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_tax', 'identifier' => 'id_tax_rules_group', 'list' => TaxRulesGroup::getTaxRulesGroupsForOptions());
parent::__construct();
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
$zones = Zone::getZones(true);
$states = State::getStates((int)$cookie->id_lang);
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/dollar.gif" />'.$this->l('Taxes').'</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', (int)($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
</div>';
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name');
echo ' <p class="clear">'.$this->l('Tax name to display in cart and on invoice, e.g., VAT').'</p>
</div>
<label>'.$this->l('Rate:').' </label>
<div class="margin-form">
<input type="text" size="4" maxlength="6" name="rate" value="'.htmlentities($this->getFieldValue($obj, 'rate'), ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
<p class="clear">'.$this->l('Format: XX.XX or XX.XXX (e.g., 19.60 or 13.925)').'</p>
</div>
<label>'.$this->l('Enable:').' </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>
</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;
if(Tools::getValue('submitAdd'.$this->table))
{
/* Checking fields validity */
$this->validateRules();
if (!sizeof($this->_errors))
{
$id = (int)(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))
{
$this->copyFromPost($object, $this->table);
$result = $object->update(false, false);
if (!$result)
$this->_errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.'</b>';
elseif ($this->postImage($object->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 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)
{
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 here.');
}
}
}
else
parent::postProcess();
}
protected function _displayDeleteLink($token = NULL, $id)
{
global $currentIndex;
$_cacheLang['Delete'] = $this->l('Delete', __CLASS__, TRUE, FALSE);
$_cacheLang['DeleteItem'] = $this->l('Delete item #', __CLASS__, TRUE, FALSE).$id.' ?)';
if (TaxRule::isTaxInUse($id))
$_cacheLang['DeleteItem'] = $this->l('This tax is currently in use in a tax rule. Are you sure?');
echo '
<a href="'.$currentIndex.'&'.$this->identifier.'='.$id.'&delete'.$this->table.'&token='.($token!=NULL ? $token : $this->token).'" onclick="return confirm(\''.$_cacheLang['DeleteItem'].'\');">
<img src="../img/admin/delete.gif" alt="'.$_cacheLang['Delete'].'" title="'.$_cacheLang['Delete'].'" /></a>';
}
protected function _displayEnableLink($token, $id, $value, $active, $id_category = NULL, $id_product = NULL)
{
global $currentIndex;
$confirm = ($value AND TaxRule::isTaxInUse($id)) ? 'onclick="return confirm(\''. $this->l('This tax is currently in use in a tax rule. If you continue this tax will be removed from the tax rule, are you sure?').'\')"' : '';
echo '<a href="'.$currentIndex.'&'.$this->identifier.'='.$id.'&'.$active.
((int)$id_category AND (int)$id_product ? '&id_category='.$id_category : '').'&token='.($token!=NULL ? $token : $this->token).'" '.$confirm.'>
<img src="../img/admin/'.($value ? 'enabled.gif' : 'disabled.gif').'"
alt="'.($value ? $this->l('Enabled') : $this->l('Disabled')).'" title="'.($value ? $this->l('Enabled') : $this->l('Disabled')).'" /></a>';
}
}
-276
View File
@@ -1,276 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(PS_ADMIN_DIR.'/tabs/AdminPreferences.php');
class AdminThemes extends AdminPreferences
{
/** This value is used in isThemeCompatible method. only version node with an
* higher version number will be used in [theme]/config.xml
* @since 1.4.0.11, check theme compatibility 1.4
* @static
*/
static public $check_features_version = '1.4';
/** $check_features is a multidimensional array used to check [theme]/config.xml values,
* and also checks prestashop current configuration if not match.
* @static
*/
static public $check_features = array(
'ccc' => array( // feature key name
'attributes' => array(
'available' => array(
'value' => 'true', // accepted attribute value
// if value doesnt match,
// prestashop configuration value must have thoses values
'check_if_not_valid' => array(
'PS_CSS_THEME_CACHE' => 0,
'PS_JS_THEME_CACHE' => 0,
'PS_HTML_THEME_COMPRESSION' => 0,
'PS_JS_HTML_THEME_COMPRESSION' => 0,
'PS_HIGH_HTML_THEME_COMPRESSION' => 0,
),
),
),
'error' => 'This theme may not correctly use "combine, compress and cache"',
'tab' => 'AdminPerformance',
),
'guest_checkout' => array(
'attributes' => array(
'available' => array(
'value' => 'true',
'check_if_not_valid' => array('PS_GUEST_CHECKOUT_ENABLED' => 0)
),
),
'error' => 'This theme may not correctly use "guest checkout"',
'tab' => 'AdminPreferences',
),
'one_page_checkout' => array(
'attributes' => array(
'available' => array(
'value' => 'true',
'check_if_not_valid' => array('PS_ORDER_PROCESS_TYPE' => 0),
),
),
'error' => 'This theme may not correctly use "one page checkout"',
'tab' => 'AdminPreferences',
),
'store_locator' => array(
'attributes' => array(
'available' => array(
'value' => 'true',
'check_if_not_valid' => array('PS_STORES_SIMPLIFIED' => 0,'PS_STORES_DISPLAY_FOOTER' => 0),
)
),
'error' => 'This theme may not correctly use "display store location"',
'tab' => 'AdminStores',
)
);
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 main page'), 'type' => 'file', 'thumb' => array('file' => _PS_IMG_.'logo.jpg?date='.time(), 'pos' => 'before')),
'PS_LOGO_MAIL' => array('title' => $this->l('Mail logo:'), 'desc' => $this->l('Will appear on e-mail headers, if undefined the Header logo will be used'), 'type' => 'file', 'thumb' => array('file' => ((file_exists(_PS_IMG_DIR_.'logo_mail.jpg')) ? _PS_IMG_.'logo_mail.jpg?date='.time() : _PS_IMG_.'logo.jpg?date='.time()), 'pos' => 'before')),
'PS_LOGO_INVOICE' => array('title' => $this->l('Invoice logo:'), 'desc' => $this->l('Will appear on invoices headers, if undefined the Header logo will be used'), 'type' => 'file', 'thumb' => array('file' => (file_exists(_PS_IMG_DIR_.'logo_invoice.jpg') ? _PS_IMG_.'logo_invoice.jpg?date='.time() : _PS_IMG_.'logo.jpg?date='.time()), 'pos' => 'before')),
'PS_FAVICON' => array('title' => $this->l('Favicon:'), 'desc' => $this->l('Will appear in the address bar of your web browser'), 'type' => 'file', 'thumb' => array('file' => _PS_IMG_.'favicon.ico?date='.time(), 'pos' => 'after')),
'PS_STORES_ICON' => array('title' => $this->l('Store icon:'), 'desc' => $this->l('Will appear on the store locator (inside Google Maps)').'<br />'.$this->l('Suggested size: 30x30, Transparent GIF'), 'type' => 'file', 'thumb' => array('file' => _PS_IMG_.'logo_stores.gif?date='.time(), 'pos' => 'before')),
'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;
if (file_exists(_PS_IMG_DIR_.'logo.jpg'))
{
list($width, $height, $type, $attr) = getimagesize(_PS_IMG_DIR_.'logo.jpg');
Configuration::updateValue('SHOP_LOGO_WIDTH', (int)round($width));
Configuration::updateValue('SHOP_LOGO_HEIGHT', (int)round($height));
}
// 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') AND @fsockopen('addons.prestashop.com', 80, $errno, $errst, 3))
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 PrestaShop Addons!').'</legend>"+a;});
</script>
<fieldset id="prestastore-content" class="width3"></fieldset>';
else
echo '<a href="http://addons.prestashop.com/3-prestashop-themes">'.$this->l('Find new themes on PrestaShop Addons!').'</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();
}
/** This function checks if the theme designer has thunk to make his theme compatible 1.4,
* and noticed it on the $theme_dir/config.xml file. If not, some new functionnalities has
* to be desactivated
*
* @since 1.4
* @param string $theme_dir theme directory
* @return boolean Validity is ok or not
*/
private function _isThemeCompatible($theme_dir)
{
global $cookie;
$all_errors='';
$return=true;
$check_version=AdminThemes::$check_features_version;
if (!is_file(_PS_ALL_THEMES_DIR_ . $theme_dir . '/config.xml'))
{
$this->_errors[] = Tools::displayError('config.xml is missing in your theme path.').'<br/>';
$xml=null;
}
else
{
$xml=@simplexml_load_file(_PS_ALL_THEMES_DIR_.$theme_dir.'/config.xml');
if (!$xml)
{
$this->_errors[] = Tools::displayError('config.xml is not a valid xml file in your theme path.').'<br/>';
}
}
// will be set to false if any version node in xml is correct
$xml_version_too_old = true;
// foreach version in xml file,
// node means feature, attributes has to match
// the corresponding value in AdminThemes::$check_features[feature] array
$xmlArray = simpleXMLToArray($xml);
foreach($xmlArray AS $version)
{
if (isset($version['value']) AND version_compare($version['value'], $check_version) >= 0)
{
$checkedFeature = array();
foreach (AdminThemes::$check_features AS $codeFeature => $arrConfigToCheck)
foreach ($arrConfigToCheck['attributes'] AS $attr => $v)
if (!isset($version[$codeFeature]) OR !isset($version[$codeFeature][$attr]) OR $version[$codeFeature][$attr] != $v['value'])
if (!$this->_checkConfigForFeatures($codeFeature, $attr)) // feature missing in config.xml file, or wrong attribute value
$return = false;
$xml_version_too_old = false;
}
}
if ($xml_version_too_old AND !$this->_checkConfigForFeatures(array_keys(AdminThemes::$check_features)))
{
$this->_errors[] .= Tools::displayError('config.xml theme file has not been created for this version of prestashop.');
$return = false;
}
return $return;
}
/**
* _checkConfigForFeatures
*
* @param array $arrFeature array of feature code to check
* @param mixed $configItem will precise the attribute which not matches. If empty, will check every attributes
* @return error message, or null if disabled
*/
private function _checkConfigForFeatures($arrFeatures, $configItem = array())
{
$return = true;
if (is_array($configItem))
{
foreach ($arrFeatures as $feature)
if (!sizeof($configItem))
$configItem = array_keys(AdminThemes::$check_features[$feature]['attributes']);
foreach ($configItem as $attr)
{
$check = $this->_checkConfigForFeatures($arrFeatures,$attr);
if($check == false)
$return = false;
}
return $return;
}
$return = true;
if (!is_array($arrFeatures))
$arrFeatures = array($arrFeatures);
foreach ($arrFeatures as $feature)
{
$arrConfigToCheck = AdminThemes::$check_features[$feature]['attributes'][$configItem]['check_if_not_valid'];
foreach ($arrConfigToCheck as $config_key => $config_val)
{
$config_get = Configuration::get($config_key);
if ($config_get != $config_val)
{
$this->_errors[] = Tools::displayError(AdminThemes::$check_features[$feature]['error']).'.'
.(!empty(AdminThemes::$check_features[$feature]['tab'])
?' <a href="?tab='.AdminThemes::$check_features[$feature]['tab'].'&amp;token='
.Tools::getAdminTokenLite(AdminThemes::$check_features[$feature]['tab']).'" ><u>'
.Tools::displayError('You can disable this function on this page')
.'</u></a>':''
).'<br/>' ;
$return = false;
break; // break for this attributes
}
}
}
return $return;
}
/** this functions make checks about AdminThemes configuration edition only.
*
* @since 1.4
*/
public function postProcess()
{
// new check compatibility theme feature (1.4) :
$val = Tools::getValue('PS_THEME');
Configuration::updateValue('PS_IMG_UPDATE_TIME', time());
if (!empty($val) AND !$this->_isThemeCompatible($val)) // don't submit if errors
unset($_POST['submitThemes'.$this->table]);
parent::postProcess();
}
}
?>
-43
View File
@@ -1,43 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminTools extends AdminTab
{
public function postProcess()
{
}
public function display()
{
echo '<fieldset><legend><img src="../img/admin/tab-tools.gif" />'.$this->l('Shop Tools').'</legend>';
echo '<p>'.$this->l('Several tools are available to manage your shop.').'</p>';
echo '<br />';
echo '<p>'.$this->l('Please choose a tool by selecting a Tools sub-tab above.').'</p>';
echo '</fieldset>';
}
}
-267
View File
@@ -1,267 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminTracking extends AdminTab
{
public function __construct()
{
$this->table = 'none';
$this->className = 'none';
parent::__construct();
}
public function display()
{
global $currentIndex;
echo '<h2 class="space">'.$this->l('Catalog tracking').'</h2>';
$this->getObjects('categories_empty');
$this->displayCategories();
$this->getObjects('products_disabled');
$this->displayProducts();
$this->getObjects('products_nostock');
$this->displayProducts();
$this->getObjects('attributes_nostock');
$this->displayAttributes();
}
public function getObjects($type)
{
global $cookie;
switch ($type)
{
case 'categories_empty':
$sql = '
SELECT id_category
FROM `'._DB_PREFIX_.'category`
WHERE id_category NOT IN (
SELECT DISTINCT(id_category)
FROM `'._DB_PREFIX_.'category_product`
)
';
$this->_list['message'] = $this->l('List of empty categories:');
break ;
case 'products_disabled':
$sql = '
SELECT *
FROM `'._DB_PREFIX_.'product`
WHERE active = 0
';
$this->_list['message'] = $this->l('List of disabled products:');
break ;
case 'products_nostock':
$sql = '
SELECT DISTINCT(id_product)
FROM `'._DB_PREFIX_.'product`
WHERE id_product IN (
SELECT id_product
FROM `'._DB_PREFIX_.'product`
WHERE id_product NOT IN (
SELECT DISTINCT(id_product)
FROM `'._DB_PREFIX_.'product_attribute`
)
AND quantity <= 0
)
';
$this->_list['message'] = $this->l('List of out of stock products without attributes:');
break ;
case 'attributes_nostock':
$sql = '
SELECT pa.*, ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, al.`name` AS attribute_name, a.`id_attribute`,
m.`name` AS manufacturer_name, pl.`name` AS name, p.`weight` AS product_weight, p.`active` AS active
FROM `'._DB_PREFIX_.'product_attribute` pa
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute`
LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute`
LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON ag.`id_attribute_group` = a.`id_attribute_group`
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)($cookie->id_lang).')
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)($cookie->id_lang).')
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = pa.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)($cookie->id_lang).')
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (p.`id_manufacturer` = m.`id_manufacturer`)
WHERE pa.quantity <= 0
ORDER BY pa.`id_product_attribute`
';
$this->_list['message'] = $this->l('List of out of stock products with attributes:');
break ;
}
$this->_list['obj'] = Db::getInstance()->ExecuteS($sql);
}
public function displayCategories()
{
global $currentIndex;
if (isset($this->_list['obj']))
{
$nbCategories = sizeof($this->_list['obj']);
echo '<h3>'.$this->_list['message'].' '.$nbCategories.' '.$this->l('found').'</h3>';
if (!$nbCategories)
return ;
echo '
<table cellspacing="0" cellpadding="0" class="table">';
$irow = 0;
foreach ($this->_list['obj'] AS $k => $category)
echo '<tr class="'.($irow++ % 2 ? 'alt_row' : '').'"><td>'.rtrim(getPath('index.php?tab=AdminCatalog', $category['id_category']), ' >').'</td></tr>';
echo '</table><br /><br />';
}
}
public function displayProducts()
{
global $currentIndex, $cookie;
if (isset($this->_list['obj']))
{
$nbProducts = sizeof($this->_list['obj']);
echo '<h3>'.$this->_list['message'].' '.$nbProducts.' '.$this->l('found').'</h3>';
if (!$nbProducts)
return ;
$this->fieldsDisplay = (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'))
));
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
echo '
<table class="table" cellpadding="0" cellspacing="0">
<tr>';
foreach ($this->fieldsDisplay AS $field)
echo '<th'.(isset($field['width']) ? 'style="width: '.$field['width'].'"' : '').'>'.$field['title'].'</th>';
echo '
</tr>';
foreach ($this->_list['obj'] AS $k => $prod)
{
$product = new Product((int)($prod['id_product']));
$product->name = $product->name[(int)($cookie->id_lang)];
$taxrate = Tax::getProductTaxRate($product->id);
echo '
<tr>
<td>'.$product->id.'</td>
<td align="center">'.($product->manufacturer_name != NULL ? stripslashes($product->manufacturer_name) : '--').'</td>
<td>'.$product->reference.'</td>
<td><a href="index.php?tab=AdminCatalog&id_product='.$product->id.'&addproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'">'.stripslashes($product->name).'</a></td>
<td>'.Tools::displayPrice($product->getPrice(), $currency).'</td>
<td>'.(float)$taxrate.'% </td>
<td align="center">'.$product->quantity.'</td>
<td align="center">'.$product->weight.' '.Configuration::get('PS_WEIGHT_UNIT').'</td>
<td align="center"><a href="index.php?tab=AdminCatalog&id_product='.$product->id.'&status&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'"><img src="../img/admin/'.($product->active ? 'enabled.gif' : 'disabled.gif').'" alt="" /></a></td>
<td>
<a href="index.php?tab=AdminCatalog&id_product='.$product->id.'&addproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'">
<img src="../img/admin/edit.gif" alt="'.$this->l('Modify this product').'" /></a>&nbsp;
<a href="index.php?tab=AdminCatalog&id_product='.$product->id.'&deleteproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'" onclick="return confirm(\''.addslashes($this->l('Do you want to delete').' '.$product->name).' ?\');">
<img src="../img/admin/delete.gif" alt="'.$this->l('Delete this product').'" /></a>
</td>
</tr>';
}
echo '</table><br /><br />';
}
}
public function displayAttributes()
{
global $currentIndex, $cookie;
if (isset($this->_list['obj']))
{
$nbAttributes = sizeof($this->_list['obj']);
echo '<h3>'.$this->_list['message'].' '.$nbAttributes.' '.$this->l('found').'</h3>';
if (!$nbAttributes)
return ;
$this->fieldsDisplay = (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'))
));
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
echo '
<table class="table" cellpadding="0" cellspacing="0">
<tr>';
foreach ($this->fieldsDisplay AS $field)
echo '<th'.(isset($field['width']) ? 'style="width: '.$field['width'].'"' : '').'>'.$field['title'].'</th>';
echo '
</tr>';
$attributes = array();
$prevAttributeId = '';
foreach ($this->_list['obj'] AS $prod)
{
if ($prevAttributeId == $prod['id_product_attribute'])
$prod['combination_name'] = $attributes[$prod['id_product_attribute']]['combination_name'].', '.$prod['group_name'].' : '.$prod['attribute_name'];
else
$prod['combination_name'] = $prod['group_name'].' : '.$prod['attribute_name'];
$attributes[$prod['id_product_attribute']] = $prod;
$prevAttributeId = $prod['id_product_attribute'];
}
foreach ($attributes AS $prod)
{
$taxrate = Tax::getProductTaxRate($prod['id_product']);
echo '
<tr>
<td>'.$prod['id_product'].'</td>
<td align="center">'.($prod['manufacturer_name'] != NULL ? stripslashes($prod['manufacturer_name']) : '--').'</td>
<td>'.$prod['reference'].'</td>
<td><a href="index.php?tab=AdminCatalog&id_product='.$prod['id_product'].'&addproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'">'.stripslashes($prod['name']).' ('.$prod['combination_name'].')'.'</a></td>
<td>'.Tools::displayPrice(Product::getPriceStatic((int)($prod['id_product']), true, $prod['id_product_attribute']), $currency).'</td>
<td>'.(float)$taxrate.'% </td>
<td align="center">'.$prod['quantity'].'</td>
<td align="center">'.($prod['weight'] + $prod['product_weight']).' '.Configuration::get('PS_WEIGHT_UNIT').'</td>
<td align="center"><a href="index.php?tab=AdminCatalog&id_product='.$prod['id_product'].'&status&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'"><img src="../img/admin/'.($prod['active'] ? 'enabled.gif' : 'disabled.gif').'" alt="" /></a></td>
<td>
<a href="index.php?tab=AdminCatalog&id_product='.$prod['id_product'].'&addproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'">
<img src="../img/admin/edit.gif" alt="'.$this->l('Modify this product').'" /></a>&nbsp;
<a href="index.php?tab=AdminCatalog&id_product='.$prod['id_product'].'&deleteproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'" onclick="return confirm(\''.addslashes($this->l('Do you want to delete').' '.$prod['name']).' ?\');">
<img src="../img/admin/delete.gif" alt="'.$this->l('Delete this product').'" /></a>
</td>
</tr>';
}
echo '</table><br /><br />';
}
}
}
File diff suppressed because it is too large Load Diff
-230
View File
@@ -1,230 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(dirname(__FILE__).'/../../classes/AdminTab.php');
class AdminWebservice extends AdminTab
{
public function __construct()
{
$this->table = 'webservice_account';
$this->className = 'WebserviceKey';
$this->lang = false;
$this->edit = true;
$this->delete = true;
$this->id_lang_default = Configuration::get('PS_LANG_DEFAULT');
$this->fieldsDisplay = array(
'key' => array('title' => $this->l('Key'), 'align' => 'center', 'width' => 32),
'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false),
'description' => array('title' => $this->l('Key description'), 'align' => 'center', 'orderby' => false)
);
$this->optionTitle = $this->l('Configuration');
if (file_exists(_PS_ROOT_DIR_.'/.htaccess'))
$this->_fieldsOptions = array('PS_WEBSERVICE' => array('title' => $this->l('Enable PrestaShop Webservice:'),
'desc' => $this->l('Before activating the webservice, you must be sure to: ').
'<ol><li>'.$this->l('be certain URL rewrite is available on this server').
'</li><li>'.$this->l('be certain that the 5 methods GET, POST, PUT, DELETE and HEAD are supported by this server').
'</li></ol>',
'cast' => 'intval',
'type' => 'bool'));
parent::__construct();
}
protected function afterAdd($object) {
WebserviceKey::setPermissionForAccount($object->id, Tools::getValue('resources', array()));
}
protected function afterUpdate($object) {
WebserviceKey::setPermissionForAccount($object->id, Tools::getValue('resources', array()));
}
public function displayList()
{
global $cookie, $currentIndex;
$warnings = array();
if (!file_exists(_PS_ROOT_DIR_.'/.htaccess'))
$warnings[] = $this->l('In order to enable the PrestaShop Webservice, please generate the .htaccess file via the "Generators" tab (in the "Tools" tab).');
if (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === false)
$warnings[] = $this->l('To avoid operating problems, please use an Apache server.');
{
if (function_exists('apache_get_modules'))
{
$apache_modules = apache_get_modules();
if (!in_array('mod_auth_basic', $apache_modules))
$warnings[] = $this->l('Please activate the Apache module \'mod_auth_basic\' to allow authentication of PrestaShop webservice.');
if (!in_array('mod_rewrite', $apache_modules))
$warnings[] = $this->l('Please activate the Apache module \'mod_rewrite\' to allow using the PrestaShop webservice.');
}
else
{
$warnings[] = $this->l('We could not check if basic authentication and rewrite extensions are activated. Please manually check if they are activated in order to use the PrestaShop webservice.');
}
}
if (!extension_loaded('SimpleXML'))
$warnings[] = $this->l('Please activate the PHP extension \'SimpleXML\' to allow testing of PrestaShop webservice.');
if (!configuration::get('PS_SSL_ENABLED'))
$warnings[] = $this->l('If possible, it is preferable to use SSL (https) for webservice calls, as it avoids the security issues of type "man in the middle".');
$this->displayWarning($warnings);
parent::displayList();
}
public function displayForm($isMainTab = true)
{
global $currentIndex;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
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><legend><img src="../img/admin/access.png" />'.$this->l('Webservice Accounts').'</legend>
<label>'.$this->l('Key:').'</label>
<div class="margin-form">
<input type="text" size="32" name="key" id="code" value="'.htmlentities(Tools::getValue('key', $obj->key), ENT_COMPAT, 'UTF-8').'" />
<input type="button" value="'.$this->l(' Generate! ').'" class="button" onclick="gencode(32)" />
<sup>*</sup>
<p class="clear">'.$this->l('Webservice account key').'</p>
</div>
<label>'.$this->l('Key description').'</label>
<div class="margin-form">
<textarea rows="3" style="width:400px" name="description">'.htmlentities(Tools::getValue('description', $obj->description), ENT_COMPAT, 'UTF-8').'</textarea>
<p class="clear">'.$this->l('Key description').'</p>
</div>
<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('Enabled').'" title="'.$this->l('Enabled').'" /></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('Disabled').'" title="'.$this->l('Disabled').'" /></label>
</div>
<label>'.$this->l('Permissions:').' </label>
<div class="margin-form">
<p>'.$this->l('Set the resource permissions for this key:').'</p>
<table border="0" cellspacing="0" cellpadding="0" class="permissions">
<thead>
<tr>
<th>'.$this->l('Resource').'</th>
<th width="30"></th>
<th width="50">'.$this->l('View (GET)').'</th>
<th width="50">'.$this->l('Modify (PUT)').'</th>
<th width="50">'.$this->l('Add (POST)').'</th>
<th width="50">'.$this->l('Delete (DELETE)').'</th>
<th width="50">'.$this->l('Fast view (HEAD)').'</th>
</tr>
</thead>
<tbody>
<tr class="all" style="vertical-align:cen">
<th></th>
<th></th>
<th><input type="checkbox" class="all_get get " /></th>
<th><input type="checkbox" class="all_put put " /></th>
<th><input type="checkbox" class="all_post post " /></th>
<th><input type="checkbox" class="all_delete delete" /></th>
<th><input type="checkbox" class="all_head head" /></th>
</tr>
';
$ressources = WebserviceRequest::getResources();
$permissions = WebserviceKey::getPermissionForAccount($obj->key);
foreach ($ressources as $resourceName => $resource)
echo '
<tr>
<th>'.$resourceName.'</th>
<th><input type="checkbox" class="all"/></th>
<td><input type="checkbox" class="get" name="resources['.$resourceName.'][GET]" '.(isset($permissions[$resourceName]) && in_array('GET', $permissions[$resourceName]) ? 'checked="checked"' : '').' /></td>
<td><input type="checkbox" class="put" name="resources['.$resourceName.'][PUT]" '.(isset($permissions[$resourceName]) && in_array('PUT', $permissions[$resourceName]) ? 'checked="checked"' : '').'/></td>
<td><input type="checkbox" class="post" name="resources['.$resourceName.'][POST]" '.(isset($permissions[$resourceName]) && in_array('POST', $permissions[$resourceName]) ? 'checked="checked"' : '').'/></td>
<td><input type="checkbox" class="delete" name="resources['.$resourceName.'][DELETE]" '.(isset($permissions[$resourceName]) && in_array('DELETE', $permissions[$resourceName]) ? 'checked="checked"' : '').'/></td>
<td><input type="checkbox" class="head" name="resources['.$resourceName.'][HEAD]" '.(isset($permissions[$resourceName]) && in_array('HEAD', $permissions[$resourceName]) ? 'checked="checked"' : '').'/></td>
</tr>';
echo '
</tbody>
</table>
<script>';?>
$(function() {
$('table.permissions input.all').click(function() {
if($(this).is(':checked'))
$(this).parent().parent().find('input.get:not(:checked), input.put:not(:checked), input.post:not(:checked), input.delete:not(:checked), input.head:not(:checked)').click();
else
$(this).parent().parent().find('input.get:checked, input.put:checked, input.post:checked, input.delete:checked, input.head:checked').click();
});
$('table.permissions .all_get').click(function() {
if($(this).is(':checked'))
$(this).parent().parent().parent().find('input.get:not(:checked)').click();
else
$(this).parent().parent().parent().find('input.get:checked').click();
});
$('table.permissions .all_put').click(function() {
if($(this).is(':checked'))
$(this).parent().parent().parent().find('input.put:not(:checked)').click();
else
$(this).parent().parent().parent().find('input.put:checked').click();
});
$('table.permissions .all_post').click(function() {
if($(this).is(':checked'))
$(this).parent().parent().parent().find('input.post:not(:checked)').click();
else
$(this).parent().parent().parent().find('input.post:checked').click();
});
$('table.permissions .all_delete').click(function() {
if($(this).is(':checked'))
$(this).parent().parent().parent().find('input.delete:not(:checked)').click();
else
$(this).parent().parent().parent().find('input.delete:checked').click();
});
$('table.permissions .all_head').click(function() {
if($(this).is(':checked'))
$(this).parent().parent().parent().find('input.head:not(:checked)').click();
else
$(this).parent().parent().parent().find('input.head:checked').click();
});
});
<?php echo '
</script>
</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::getValue('key') && strlen(Tools::getValue('key')) < 32)
$this->_errors[] = Tools::displayError($this->l('Key length must be 32 character long'));
return parent::postProcess();
}
}
-83
View File
@@ -1,83 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(dirname(__FILE__).'/../../classes/AdminTab.php');
class AdminZones extends AdminTab
{
public function __construct()
{
$this->table = 'zone';
$this->className = 'Zone';
$this->lang = false;
$this->edit = true;
$this->delete = true;
$this->fieldsDisplay = array(
'id_zone' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'name' => array('title' => $this->l('Zone'), 'width' => 150),
'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false)
);
parent::__construct();
}
public function displayForm($isMainTab = true)
{
global $currentIndex;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
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/world.gif" />'.$this->l('Zones').'</legend>
<label>'.$this->l('Name').'</label>
<div class="margin-form">
<input type="text" size="33" name="name" value="'.htmlentities(Tools::getValue('name', $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">&nbsp;</span></span>
<p class="clear">'.$this->l('Zone name, e.g., Africa, West Coast, Neighboring Countries').'</p>
</div>
<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('Enabled').'" title="'.$this->l('Enabled').'" /></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('Disabled').'" title="'.$this->l('Disabled').'" /></label>
<p>'.$this->l('Allow or disallow shipping to this zone').'</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>';
}
}