[+] Project: it's possible to create new genders, "Miss" gender is now added

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8578 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2011-09-14 15:15:51 +00:00
parent 62a578b314
commit 03eaee9bf4
35 changed files with 777 additions and 526 deletions
+57 -37
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -37,7 +37,7 @@ class AdminCustomers extends AdminTab
$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
@@ -45,10 +45,27 @@ class AdminCustomers extends AdminTab
ORDER BY c.date_add DESC
LIMIT 1
) as connect';
$genders = array(1 => $this->l('M'), 2 => $this->l('F'), 9 => $this->l('?'));
$genders_icon = array('default' => 'unknown.gif');
$genders = array(0 => $this->l('?'));
foreach (Gender::getGenders() as $gender)
{
$genders_icon[$gender['id_gender']] = '../genders/'.$gender['id_gender'].'.jpg';
$genders[$gender['id_gender']] = $gender['name'];
}
$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'),
'id_gender' => array(
'title' => $this->l('Gender'),
'width' => 30,
'align' => 'center',
'icon' => $genders_icon,
'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),
@@ -74,7 +91,7 @@ class AdminCustomers extends AdminTab
parent::__construct();
}
public function postProcess()
{
if (Tools::isSubmit('submitDel'.$this->table) OR Tools::isSubmit('delete'.$this->table))
@@ -102,11 +119,11 @@ class AdminCustomers extends AdminTab
</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))
@@ -122,7 +139,7 @@ class AdminCustomers extends AdminTab
if (Validate::isLoadedObject($object))
{
$customer_email = strval(Tools::getValue('email'));
// check if e-mail already used
if ($customer_email != $object->email)
{
@@ -131,13 +148,13 @@ class AdminCustomers extends AdminTab
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))
{
@@ -248,7 +265,7 @@ class AdminCustomers extends AdminTab
$update = Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'customer` SET newsletter = '.($customer->newsletter ? 0 : 1).' WHERE `id_customer` = '.(int)($customer->id));
if (!$update)
$this->_errors[] = Tools::displayError('An error occurred while updating customer.');
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
}elseif (Tools::isSubmit('changeOptinVal') AND Tools::getValue('id_customer'))
{
@@ -261,7 +278,7 @@ class AdminCustomers extends AdminTab
$this->_errors[] = Tools::displayError('An error occurred while updating customer.');
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
}
return parent::postProcess();
}
@@ -288,10 +305,12 @@ class AdminCustomers extends AdminTab
else
$countBetterCustomers = '-';
$gender = new Gender($customer->id_gender);
echo '
<fieldset style="width:400px;float: left"><div style="float: right"><a href="'.self::$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 />
<img src="'.$gender->getImage().'" 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, $this->context->language->id, true).'<br />
@@ -331,7 +350,7 @@ class AdminCustomers extends AdminTab
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">
@@ -361,8 +380,8 @@ class AdminCustomers extends AdminTab
});
}
</script>';
echo '<h2>'.$this->l('Messages').' ('.sizeof($messages).')</h2>';
if (sizeof($messages))
{
@@ -476,7 +495,7 @@ class AdminCustomers extends AdminTab
}
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>
@@ -572,7 +591,7 @@ class AdminCustomers extends AdminTab
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))
@@ -608,14 +627,14 @@ class AdminCustomers extends AdminTab
else
echo $this->l('No cart available').'.';
echo '</div>';
$sql = 'SELECT DISTINCT id_product, c.id_cart, c.id_shop, cp.id_shop AS cp_id_shop
FROM '._DB_PREFIX_.'cart_product cp
FROM '._DB_PREFIX_.'cart_product cp
JOIN '._DB_PREFIX_.'cart c ON (c.id_cart = cp.id_cart)
WHERE c.id_customer = '.(int)$customer->id.'
WHERE c.id_customer = '.(int)$customer->id.'
AND cp.id_product NOT IN (
SELECT product_id
FROM '._DB_PREFIX_.'orders o
SELECT product_id
FROM '._DB_PREFIX_.'orders o
JOIN '._DB_PREFIX_.'order_detail od ON (o.id_order = od.id_order)
WHERE o.valid = 1 AND o.id_customer = '.(int)$customer->id.'
)';
@@ -638,12 +657,12 @@ class AdminCustomers extends AdminTab
}
echo '</table></div>';
}
echo '<div class="clear">&nbsp;</div>';
/* Last connections */
$connections = $customer->getLastConnections();
if (sizeof($connections))
if (sizeof($connections))
{
echo '<h2>'.$this->l('Last connections').'</h2>
<table cellspacing="0" cellpadding="0" class="table">
@@ -665,7 +684,7 @@ class AdminCustomers extends AdminTab
echo '</table><div class="clear">&nbsp;</div>';
}
if (sizeof($referrers))
if (sizeof($referrers))
{
echo '<h2>'.$this->l('Referrers').'</h2>
<table cellspacing="0" cellpadding="0" class="table">
@@ -688,26 +707,27 @@ class AdminCustomers extends AdminTab
public function displayForm($isMainTab = true)
{
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="'.self::$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 class="margin-form">';
foreach (Gender::getGenders() as $gender)
{
echo '<input type="radio" size="33" name="id_gender" id="gender_'.$gender['id_gender'].'" value="'.$gender['id_gender'].'" '.($this->getFieldValue($obj, 'id_gender') == $gender['id_gender'] ? 'checked="checked" ' : '').'/>';
echo '<label class="t" for="gender_'.$gender['id_gender'].'"> '.$gender['name'].'</label> &nbsp; ';
}
echo ' <input type="radio" size="33" name="id_gender" id="gender_unknown" value="0" '.(($this->getFieldValue($obj, 'id_gender') == 9 || !$this->getFieldValue($obj, 'id_gender')) ? 'checked="checked" ' : '').'/>
<label class="t" for="gender_unknown"> '.$this->l('Unknown').'</label>
</div>
<label>'.$this->l('Last name:').' </label>
<div class="margin-form">
@@ -854,7 +874,7 @@ class AdminCustomers extends AdminTab
{
return parent::getList(Context::getContext()->language->id, !Tools::getValue($this->table.'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL);
}
public function beforeDelete($object)
{
return $object->isUsed();
+109
View File
@@ -0,0 +1,109 @@
<?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$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminGenders extends AdminTab
{
public function __construct()
{
$this->table = 'gender';
$this->className = 'Gender';
$this->lang = true;
$this->edit = true;
$this->delete = true;
$this->fieldImageSettings = array('name' => 'image', 'dir' => 'genders');
$this->fieldsDisplay = array(
'id_gender' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'name' => array('title' => $this->l('Name'), 'width' => 150, 'filter_key' => 'b!name'),
'type' => array(
'title' => $this->l('Type'),
'width' => 100,
'orderby' => false,
'type' => 'select',
'select' => array(0 => $this->l('Male'), 1 => $this->l('Female')),
'filter_key' => 'a!type',
'callback' => 'displayGenderType',
'callback_object' => $this,
),
'image' => array('title' => $this->l('Image'), 'align' => 'center', 'image' => 'genders', 'orderby' => false, 'search' => false),
);
parent::__construct();
}
public function displayGenderType($value, $tr)
{
return $this->fieldsDisplay['type']['select'][$value];
}
public function displayForm($isMainTab = true)
{
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
echo '
<form action="'.self::$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/tab-genders.gif" />'.$this->l('Gender').'</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');
echo '</div><div class="clear">&nbsp;</div>';
echo '<label>'.$this->l('Type:').' </label>
<div class="margin-form">
<input type="radio" name="type" id="type_male" value="0" '.($this->getFieldValue($obj, 'type') == 0 ? 'checked="checked" ' : '').'/>
<label class="t" for="type_male"> '.$this->l('Male').'</label>
<input type="radio" name="type" id="type_female" value="1" '.($this->getFieldValue($obj, 'type') == 1 ? 'checked="checked" ' : '').'/>
<label class="t" for="type_female"> '.$this->l('Female').'</label>
</div>
<div class="clear"></div>';
echo '<label>'.$this->l('Image:').' </label>
<div class="margin-form">';
echo ' <input type="file" name="image" /> ';
if ($obj->getImage())
echo '<img src="'.$obj->getImage().'" />';
echo '</div>
<div class="clear"></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><br />';
}
}
+22 -23
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -35,12 +35,12 @@ class AdminGroups extends AdminTab
$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
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->_listSkipDelete = array(1);
@@ -58,7 +58,7 @@ class AdminGroups extends AdminTab
public function displayForm($isMainTab = true)
{
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
$groupReductions = $obj->id ? GroupReduction::getGroupReductions($obj->id, $this->context->language->id) : array();
@@ -93,7 +93,7 @@ class AdminGroups extends AdminTab
<div class="margin-form">';
if ($groupReductions)
{
echo '
<table>
<tr>
@@ -168,11 +168,11 @@ class AdminGroups extends AdminTab
public function viewgroup()
{
$this->context = Context::getContext();
$this->context = Context::getContext();
self::$currentIndex = 'index.php?tab=AdminGroups';
if (!($obj = $this->loadObject(true)))
return;
echo '
<fieldset style="width: 400px">
<div style="float: right"><a href="'.self::$currentIndex.'&updategroup&id_group='.$obj->id.'&token='.$this->token.'"><img src="../img/admin/edit.gif" /></a></div>
@@ -197,50 +197,50 @@ class AdminGroups extends AdminTab
if ($nbCustomers = $obj->getCustomers(true))
{
echo '<h2>'.$this->l('Customer members of this group').' ('.$nbCustomers.')</h2>';
// Pagination Begin
$customersPerPage = (Tools::getValue('customerPerPage') ? (int)Tools::getValue('customerPerPage') : 50);
$customersPerPage = (Tools::getValue('customerPerPage') ? (int)Tools::getValue('customerPerPage') : 50);
$totalPages = ceil($nbCustomers / $customersPerPage);
$perPageOptions = array(20, 50, 100, 300);
$customerPageIndex = (Tools::getValue('customerPageIndex') && Tools::getValue('customerPageIndex') <= $totalPages ? (int)Tools::getValue('customerPageIndex') : 1);
$from = (Tools::getValue('customerPageIndex') ? ((int)$customerPageIndex - 1) * ((int)$customersPerPage) : 0);
$customers = $obj->getCustomers(false, $from, $customersPerPage);
echo '<table><tr>
<form method="post" action="'.Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']).'">
<td style="vertical-align: bottom;"><span style="float: left; height:30px">';
if ($customerPageIndex > 1)
{
echo '&nbsp<input type="image" onclick="document.getElementById(\'customerPageIndex\').value=1" src="../img/admin/list-prev2.gif">&nbsp';
echo '&nbsp<input type="image" onclick="document.getElementById(\'customerPageIndex\').value='.($customerPageIndex-1).'" src="../img/admin/list-prev.gif">&nbsp';
}
echo 'Page <b><select onChange="submit()" name="customerPageIndex" id="customerPageIndex">';
for ($i=1; $i <= $totalPages; $i++)
echo '<option value="'.$i.'"'.((int)$customerPageIndex === $i ? 'selected="selected"' : '').'>'.$i.'</option>';
echo '</select></b> / '.$totalPages;
if ($customerPageIndex < $totalPages)
{
echo '&nbsp<input type="image" onclick="document.getElementById(\'customerPageIndex\').value='.((int)$customerPageIndex+1).'" src="../img/admin/list-next.gif">';
echo '&nbsp<input type="image" onclick="document.getElementById(\'customerPageIndex\').value='.$totalPages.'" src="../img/admin/list-next2.gif">';
}
echo ' | Display
<select onchange="document.getElementById(\'customerPageIndex\').value=1; submit();" name="customerPerPage">';
foreach ($perPageOptions as $option)
echo '<option value="'.$option.'"'.((int)$customersPerPage == $option ? 'selected="selected"' : '').'>'.$option.'</option>';
echo ' </select> / '.$nbCustomers.' result(s)
echo ' </select> / '.$nbCustomers.' result(s)
</span><span class="clear"></span></td>
</form>
</tr>
</table>
<div class="clear"></div>';
// Pagination End
echo '<table cellspacing="0" cellpadding="0" class="table widthfull">
<tr>';
foreach ($this->fieldsDisplay AS $field)
@@ -248,14 +248,13 @@ class AdminGroups extends AdminTab
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 class="center"><img src="'.Gender::getStaticImage($customer['id_gender']).'" /></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'], $this->context->language->id).'</td>
+22 -22
View File
@@ -82,7 +82,7 @@ class AdminImport extends AdminTab
case $this->entities[$this->l('Combinations')]:
self::$required_fields = array('id_product', 'options');
$this->available_fields = array(
'no' => array('label' => $this->l('Ignore this column')),
'no' => array('label' => $this->l('Ignore this column')),
'id_product' => array('label' => $this->l('Product ID').'*'),
'options' => array('label' => $this->l('Options (Group:Value)').'*'),
'reference' => array('label' => $this->l('Reference')),
@@ -95,7 +95,7 @@ class AdminImport extends AdminTab
'quantity' => array('label' => $this->l('Quantity')),
'weight' => array('label' => $this->l('Weight')),
'default_on' => array('label' => $this->l('Default')),
'image_position' => array('label' => $this->l('Image position'),
'image_position' => array('label' => $this->l('Image position'),
'help' => $this->l('Position of the product image to use for this combination. If you use this field, leave image URL empty.')),
'image_url' => array('label' => $this->l('Image URL')),
);
@@ -180,7 +180,7 @@ class AdminImport extends AdminTab
'online_only' => array('label' => $this->l('Only available online')),
'condition' => array('label' => $this->l('Condition')),
'shop' => array(
'label' => $this->l('ID / Name of shop'),
'label' => $this->l('ID / Name of shop'),
'help' => $this->l('Ignore this field if you don\'t use multishop tool. If you leave this field empty, default shop will be used'),
),
);
@@ -210,7 +210,7 @@ class AdminImport extends AdminTab
'no' => array('label' => $this->l('Ignore this column')),
'id' => array('label' => $this->l('ID')),
'active' => array('label' => $this->l('Active (0/1)')),
'id_gender' => array('label' => $this->l('Gender ID (Mr = 1, Ms = 2, else 9)')),
'id_gender' => array('label' => $this->l('Gender ID (Mr = 1, Ms = 2, else 0)')),
'email' => array('label' => $this->l('E-mail *')),
'passwd' => array('label' => $this->l('Password *')),
'birthday' => array('label' => $this->l('Birthday (yyyy-mm-dd)')),
@@ -219,7 +219,7 @@ class AdminImport extends AdminTab
'newsletter' => array('label' => $this->l('Newsletter (0/1)')),
'optin' => array('label' => $this->l('Opt in (0/1)')),
'id_shop' => array(
'label' => $this->l('ID / Name of shop'),
'label' => $this->l('ID / Name of shop'),
'help' => $this->l('Ignore this field if you don\'t use multishop tool. If you leave this field empty, default shop will be used'),
),
);
@@ -282,11 +282,11 @@ class AdminImport extends AdminTab
'meta_keywords' => array('label' => $this->l('Meta-keywords')),
'meta_description' => array('label' => $this->l('Meta-description')),
'shop' => array(
'label' => $this->l('ID / Name of group shop'),
'label' => $this->l('ID / Name of group shop'),
'help' => $this->l('Ignore this field if you don\'t use multishop tool. If you leave this field empty, default shop will be used'),
),
);
self::$default_values = array(
'shop' => Shop::getGroupFromShop(Configuration::get('PS_SHOP_DEFAULT')),
);
@@ -446,11 +446,11 @@ class AdminImport extends AdminTab
/**
* copyImg copy an image located in $url and save it in a path
* according to $entity->$id_entity .
* according to $entity->$id_entity .
* $id_image is used if we need to add a watermark
*
*
* @param int $id_entity id of product or category (set in entity)
* @param int $id_image (default null) id of the image if watermark enabled.
* @param int $id_image (default null) id of the image if watermark enabled.
* @param string $url path or url to use
* @param string entity 'products' or 'categories'
* @return void
@@ -798,7 +798,7 @@ class AdminImport extends AdminTab
}
$product->associateTo($shops);
}
// SpecificPrice (only the basic reduction feature is supported by the import)
if ((isset($info['reduction_price']) AND $info['reduction_price'] > 0) OR (isset($info['reduction_percent']) AND $info['reduction_percent'] > 0))
{
@@ -863,7 +863,7 @@ class AdminImport extends AdminTab
$product->deleteImages();
elseif (isset($product->image) AND is_array($product->image) AND sizeof($product->image))
$product->deleteImages();
if (isset($product->image) AND is_array($product->image) and sizeof($product->image))
{
$productHasImages = (bool)Image::getImages($this->context->language->id, (int)($product->id));
@@ -926,10 +926,10 @@ class AdminImport extends AdminTab
$info = array_map('trim', $info);
self::setDefaultValues($info);
$product = new Product((int)($info['id_product']), false, $defaultLanguage);
$id_image = null;
if (isset($info['image_url']) && $info['image_url'])
{
$productHasImages = (bool)Image::getImages($this->context->language->id, $product->id);
@@ -1035,7 +1035,7 @@ class AdminImport extends AdminTab
if (($fieldError = $customer->validateFields(UNFRIENDLY_ERROR, true)) === true AND ($langFieldError = $customer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true)
{
$customer->id_group_shop = Shop::getGroupFromShop($customer->id_shop);
if ($customer->id AND $customer->customerIdExists($customer->id))
$res = $customer->update();
if (!$res)
@@ -1125,7 +1125,7 @@ class AdminImport extends AdminTab
}
if(isset($address->customer_email) and !empty($address->customer_email))
{
{
if( Validate::isEmail($address->customer_email))
{
$customer = Customer::customerExists($address->customer_email, true);
@@ -1211,7 +1211,7 @@ class AdminImport extends AdminTab
$res = $manufacturer->update();
if (!$res)
$res = $manufacturer->add();
if ($res)
{
// Associate supplier to group shop
@@ -1450,7 +1450,7 @@ class AdminImport extends AdminTab
$("label[for=match_ref],#match_ref").show();
}
$("#entitie").html($("#entity > option:selected").text().toLowerCase());
$.getJSON("'.dirname(self::$currentIndex).'/ajax.php",
$.getJSON("'.dirname(self::$currentIndex).'/ajax.php",
{
getAvailableFields:1,
entity: $("#entity").val()},
@@ -1478,7 +1478,7 @@ class AdminImport extends AdminTab
$array[$key] = utf8_encode($value);
else
$array = utf8_encode($array);
return $array;
}
@@ -1561,7 +1561,7 @@ class AdminImport extends AdminTab
public function displayCSV()
{
$importMatchs = Db::getInstance()->ExecuteS('SELECT * FROM '._DB_PREFIX_.'import_match');
echo '
<script src="'._PS_JS_DIR_.'adminImport.js"></script>
<script type="text/javascript">
@@ -1579,7 +1579,7 @@ class AdminImport extends AdminTab
</select>
<a class="button" id="loadImportMatchs" href="#">'.$this->l('Load').'</a>
<a class="button" id="deleteImportMatchs" href="#">'.$this->l('Delete').'</a>';
echo '</div></div><h3>'.$this->l('Please set the value type of each column').'</h3>
<div id="error_duplicate_type" class="warning warn" style="display:none;">
<h3>'.$this->l('Columns cannot have the same value type').'</h3>
@@ -1744,7 +1744,7 @@ class AdminImport extends AdminTab
$this->_errors[] = Tools::displayError('No file was uploaded');
break;
break;
}
}
}
elseif (!file_exists($_FILES['file']['tmp_name']) OR !@move_uploaded_file($_FILES['file']['tmp_name'], dirname(__FILE__).'/../import/'.$_FILES['file']['name'].'.'.date('Ymdhis')))
$this->_errors[] = $this->l('an error occurred while uploading and copying file');
+15 -16
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -32,7 +32,7 @@ class AdminSearch extends AdminTab
{
if (!ip2long(trim($query)))
return;
$this->_list['customers'] = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT DISTINCT c.*
FROM `'._DB_PREFIX_.'customer` c
@@ -40,7 +40,7 @@ class AdminSearch extends AdminTab
LEFT JOIN `'._DB_PREFIX_.'connections` co ON g.id_guest = co.id_guest
WHERE co.`ip_address` = \''.ip2long(trim($query)).'\'');
}
/**
* Search a specific string in the products and categories
*
@@ -48,7 +48,7 @@ class AdminSearch extends AdminTab
*/
public function searchCatalog($query)
{
$this->context = Context::getContext();
$this->context = Context::getContext();
$this->_list['products'] = Product::searchByName($this->context->language->id, $query);
if (!empty($this->_list['products']))
for ($i = 0; $i < count($this->_list['products']); $i++)
@@ -69,17 +69,17 @@ class AdminSearch extends AdminTab
function postProcess()
{
$this->context = Context::getContext();
$this->context = Context::getContext();
$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;
@@ -101,7 +101,7 @@ class AdminSearch extends AdminTab
$matchingResults[$tabs[$key]] = array();
$matchingResults[$tabs[$key]][] = array('tab' => $key, 'value' => $value);
}
if (count($matchingResults))
{
arsort($matchingResults);
@@ -122,8 +122,8 @@ class AdminSearch extends AdminTab
echo '</table><div class="clear">&nbsp;</div>';
}
}
/* Product research */
if (!$searchType OR $searchType == 1)
{
@@ -184,7 +184,7 @@ class AdminSearch extends AdminTab
Tools::redirectAdmin('index.php?tab=AdminOrders&id_order='.(int)($order->id).'&vieworder'.'&token='.Tools::getAdminToken('AdminOrders'.(int)(Tab::getIdFromClassName('AdminOrders')).(int)$this->context->employee->id));
$this->_errors[] = Tools::displayError('No order found with this ID:').' '.Tools::htmlentitiesUTF8($query);
}
/* Invoices */
if ($searchType == 4)
{
@@ -200,7 +200,7 @@ class AdminSearch extends AdminTab
Tools::redirectAdmin('index.php?tab=AdminCarts&id_cart='.(int)($cart->id).'&viewcart'.'&token='.Tools::getAdminToken('AdminCarts'.(int)(Tab::getIdFromClassName('AdminCarts')).(int)$this->context->employee->id));
$this->_errors[] = Tools::displayError('No cart found with this ID:').' '.Tools::htmlentitiesUTF8($query);
}
/* IP */
// 6 - but it is included in the customer block
}
@@ -211,7 +211,7 @@ class AdminSearch extends AdminTab
self::$currentIndex = 'index.php';
$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']))
{
@@ -270,11 +270,10 @@ class AdminSearch extends AdminTab
$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 class="center"><img src="'.Gender::getStaticImage($customer['id_gender']).'" /></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'], $this->context->language->id).'</td>
@@ -294,7 +293,7 @@ class AdminSearch extends AdminTab
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>';