// Merg// Merge -> revision 8395

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8397 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2011-09-07 16:23:13 +00:00
parent 5aab81dc66
commit 24e213cda8
27 changed files with 2801 additions and 617 deletions
+61 -30
View File
@@ -59,7 +59,7 @@ class Ebay extends Module
{
$this->name = 'ebay';
$this->tab = 'market_place';
$this->version = '1.2.3';
$this->version = '1.2.4';
$this->author = 'PrestaShop';
parent::__construct ();
$this->displayName = $this->l('eBay');
@@ -111,6 +111,14 @@ class Ebay extends Module
if (!Configuration::get('EBAY_API_TOKEN'))
$this->warning = $this->l('You must register your module on eBay.');
// Loading Shipping Method
$this->loadShippingMethod();
}
}
public function loadShippingMethod()
{
// Shipping methods
$this->_shippingMethod = array(
7104 => array('description' => 'Colissimo', 'shippingService' => 'FR_ColiposteColissimo', 'shippingServiceID' => '7104'),
@@ -148,7 +156,6 @@ class Ebay extends Module
7109 => array('description' => 'UPS - Standard', 'shippingService' => 'FR_UPSStandard', 'shippingServiceID' => '7109'),
);
}
}
/******************************************************************/
@@ -515,7 +522,7 @@ class Ebay extends Module
// If isset Post Var, post process else display form
if (!empty($_POST) AND Tools::isSubmit('submitSave'))
if (!empty($_POST) && (Tools::isSubmit('submitSave') || Tools::isSubmit('submitSave1') || Tools::isSubmit('submitSave2')))
{
$this->_postValidation();
if (!sizeof($this->_postErrors))
@@ -1175,7 +1182,10 @@ class Ebay extends Module
// Display Form
$html = '<style>#button_ebay_sync{background-image:url('.$this->_path.'ebay.gif);background-repeat:no-repeat;background-position:center 90px;width:500px;height:191px;cursor:pointer;padding-bottom:100px;font-weight:bold;font-size:25px;}</style>
$html = '<style>
#button_ebay_sync1{background-image:url('.$this->_path.'ebay.gif);background-repeat:no-repeat;background-position:center 90px;width:400px;height:191px;cursor:pointer;padding-bottom:100px;font-weight:bold;font-size:25px;}
#button_ebay_sync2{background-image:url('.$this->_path.'ebay.gif);background-repeat:no-repeat;background-position:center 90px;width:400px;height:191px;cursor:pointer;padding-bottom:100px;font-weight:bold;font-size:25px;}
</style>
<script>
var nbProducts = '.$nbProducts.';
var nbProductsModeA = '.$nbProductsModeA.';
@@ -1196,7 +1206,8 @@ class Ebay extends Module
success: function(data) {
nbProducts = data;
nbProductsModeB = data;
$("#button_ebay_sync").attr("value", "'.$this->l('Sync with eBay').'\n(" + data + " '.$this->l('products').')");
$("#button_ebay_sync1").attr("value", "'.$this->l('Sync with eBay').'\n(" + data + " '.$this->l('products').')");
$("#button_ebay_sync2").attr("value", "'.$this->l('Sync with eBay').'\n'.$this->l('and update').'\n(" + data + " '.$this->l('products').')");
}
});
});
@@ -1207,37 +1218,41 @@ class Ebay extends Module
$("#ebay_sync_mode1").click(function() {
nbProducts = nbProductsModeA;
$("#catSync").hide("slow");
$("#button_ebay_sync").attr("value", "'.$this->l('Sync with eBay').'\n(" + nbProducts + " '.$this->l('products').')");
$("#button_ebay_sync1").attr("value", "'.$this->l('Sync with eBay').'\n(" + nbProducts + " '.$this->l('products').')");
$("#button_ebay_sync2").attr("value", "'.$this->l('Sync with eBay').'\n'.$this->l('and update').'\n(" + nbProducts + " '.$this->l('products').')");
});
$("#ebay_sync_mode2").click(function() {
nbProducts = nbProductsModeB;
$("#catSync").show("slow");
$("#button_ebay_sync").attr("value", "'.$this->l('Sync with eBay').'\n(" + nbProducts + " '.$this->l('products').')");
$("#button_ebay_sync1").attr("value", "'.$this->l('Sync with eBay').'\n(" + nbProducts + " '.$this->l('products').')");
$("#button_ebay_sync2").attr("value", "'.$this->l('Sync with eBay').'\n'.$this->l('and update').'\n(" + nbProducts + " '.$this->l('products').')");
});
});
function eBaySync()
function eBaySync(option)
{
$(".categorySync").attr("disabled", "true");
$("#ebay_sync_mode1").attr("disabled", "true");
$("#ebay_sync_mode2").attr("disabled", "true");
$("#ebay_sync_option_resync").attr("disabled", "true");
$("#button_ebay_sync").attr("disabled", "true");
$("#button_ebay_sync").hide("slow");
$("#button_ebay_sync1").attr("disabled", "true");
$("#button_ebay_sync1").css("background-color", "#D5D5D5");
$("#button_ebay_sync2").attr("disabled", "true");
$("#button_ebay_sync2").css("background-color", "#D5D5D5");
$("#resultSync").html("<img src=\"../modules/ebay/loading-small.gif\" border=\"0\" />");
eBaySyncProduct();
eBaySyncProduct(option);
}
function eBaySyncProduct()
function eBaySyncProduct(option)
{
$.ajax({
url: \''._MODULE_DIR_.'ebay/ajax/eBaySyncProduct.php?token='.Configuration::get('EBAY_SECURITY_TOKEN').'&time='.pSQL(date('Ymdhis').rand()).'\',
url: \''._MODULE_DIR_.'ebay/ajax/eBaySyncProduct.php?token='.Configuration::get('EBAY_SECURITY_TOKEN').'&option=\'+option+\'&time='.pSQL(date('Ymdhis').rand()).'\',
success: function(data)
{
tab = data.split("|");
$("#resultSync").html(tab[1]);
if (tab[0] != "OK")
eBaySyncProduct();
eBaySyncProduct(option);
}
});
}
@@ -1292,8 +1307,10 @@ class Ebay extends Module
}
}
$html .= '</tbody></table>';
if (Tools::getValue('section') == 'sync')
$html .= '<script>$(document).ready(function() { eBaySync(); });</script>';
if (Tools::getValue('section') == 'sync' && Tools::getValue('submitSave1') != '')
$html .= '<script>$(document).ready(function() { eBaySync(1); });</script>';
if (Tools::getValue('section') == 'sync' && Tools::getValue('submitSave2') != '')
$html .= '<script>$(document).ready(function() { eBaySync(2); });</script>';
if (Configuration::get('EBAY_SYNC_MODE') == 'B')
{
@@ -1308,8 +1325,21 @@ class Ebay extends Module
$html .= '
</div>
</fieldset>
<div class="margin-form"><input id="button_ebay_sync" class="button" name="submitSave" value="'.$this->l('Sync with eBay')."\n".'('.$nbProducts.' '.$this->l('products').')" OnClick="return confirm(\''.$this->l('You will push').' \' + nbProducts + \' '.$this->l('products on eBay. Do you want to confirm ?').'\');" type="submit"></div>
<h4>'.$this->l('Beware ! If some of your categories are not multi sku compliant, some of your products may create more than one product on eBay.').'</h4>
<table>
<tr>
<td style="color: #268CCD"><h4>'.$this->l('"Sync with eBay" option will only sync the products that are not already sync with eBay : ').'</h4></td>
<td style="width: 50px">&nbsp;</td>
<td style="color: #268CCD"><h4>'.$this->l('"Sync and update with eBay" will sync the products that are not already sync with eBay and update the products already sync with eBay : ').'</h4></td>
</tr>
<tr>
<td><input id="button_ebay_sync1" class="button" name="submitSave1" value="'.$this->l('Sync with eBay')."\n".'('.$nbProducts.' '.$this->l('products').')" OnClick="return confirm(\''.$this->l('You will push').' \' + nbProducts + \' '.$this->l('products on eBay. Do you want to confirm ?').'\');" type="submit"></td>
<td style="width: 50px">&nbsp;</td>
<td><input id="button_ebay_sync2" class="button" name="submitSave2" value="'.$this->l('Sync with eBay')."\n".$this->l('and update')."\n".'('.$nbProducts.' '.$this->l('products').')" OnClick="return confirm(\''.$this->l('You will push').' \' + nbProducts + \' '.$this->l('products on eBay. Do you want to confirm ?').'\');" type="submit"></td>
</tr>
</table>
<br />
</form>';
@@ -1348,11 +1378,7 @@ class Ebay extends Module
public function ajaxProductSync()
{
// Take the next product
$where = '';
if ((int)Configuration::get('EBAY_SYNC_LAST_PRODUCT') > 0)
$where = 'AND `id_product` > '.(int)Configuration::get('EBAY_SYNC_LAST_PRODUCT');
$whereOption1 = 'AND `id_product` NOT IN (SELECT `id_product` FROM `'._DB_PREFIX_.'ebay_product`)';
if (Configuration::get('EBAY_SYNC_MODE') == 'A')
{
@@ -1368,8 +1394,8 @@ class Ebay extends Module
SELECT `id_product` FROM `'._DB_PREFIX_.'product`
WHERE `quantity` > 0 AND `active` = 1
AND `id_category_default` IN (SELECT `id_category` FROM `'._DB_PREFIX_.'ebay_category_configuration` WHERE `id_category` > 0 AND `id_ebay_category` > 0)
AND `id_product` NOT IN (SELECT `id_product` FROM `'._DB_PREFIX_.'ebay_product`)
'.$where.'
'.(Tools::getValue('option') == 1 ? $whereOption1 : '').'
AND `id_product` > '.(int)Configuration::get('EBAY_SYNC_LAST_PRODUCT').'
ORDER BY `id_product`
LIMIT 1');
@@ -1378,8 +1404,8 @@ class Ebay extends Module
SELECT COUNT(`id_product`) FROM `'._DB_PREFIX_.'product`
WHERE `quantity` > 0 AND `active` = 1
AND `id_category_default` IN (SELECT `id_category` FROM `'._DB_PREFIX_.'ebay_category_configuration` WHERE `id_category` > 0 AND `id_ebay_category` > 0)
AND `id_product` NOT IN (SELECT `id_product` FROM `'._DB_PREFIX_.'ebay_product`)
'.$where);
'.(Tools::getValue('option') == 1 ? $whereOption1 : '').'
AND `id_product` > '.(int)Configuration::get('EBAY_SYNC_LAST_PRODUCT'));
}
else
{
@@ -1395,8 +1421,8 @@ class Ebay extends Module
SELECT `id_product` FROM `'._DB_PREFIX_.'product`
WHERE `quantity` > 0 AND `active` = 1
AND `id_category_default` IN (SELECT `id_category` FROM `'._DB_PREFIX_.'ebay_category_configuration` WHERE `id_category` > 0 AND `id_ebay_category` > 0 AND `sync` = 1)
AND `id_product` NOT IN (SELECT `id_product` FROM `'._DB_PREFIX_.'ebay_product`)
'.$where.'
'.(Tools::getValue('option') == 1 ? $whereOption1 : '').'
AND `id_product` > '.(int)Configuration::get('EBAY_SYNC_LAST_PRODUCT').'
ORDER BY `id_product`
LIMIT 1');
@@ -1405,8 +1431,8 @@ class Ebay extends Module
SELECT COUNT(`id_product`) FROM `'._DB_PREFIX_.'product`
WHERE `quantity` > 0 AND `active` = 1
AND `id_category_default` IN (SELECT `id_category` FROM `'._DB_PREFIX_.'ebay_category_configuration` WHERE `id_category` > 0 AND `id_ebay_category` > 0 AND `sync` = 1)
AND `id_product` NOT IN (SELECT `id_product` FROM `'._DB_PREFIX_.'ebay_product`)
'.$where);
'.(Tools::getValue('option') == 1 ? $whereOption1 : '').'
AND `id_product` > '.(int)Configuration::get('EBAY_SYNC_LAST_PRODUCT'));
}
// Send each product on eBay
@@ -1532,6 +1558,11 @@ class Ebay extends Module
$price = round($price, 2);
// Loading Shipping Method
if (!isset($this->_shippingMethod[Configuration::get('EBAY_SHIPPING_CARRIER_ID')]['shippingService']))
$this->loadShippingMethod();
// Generate array and try insert in database
$datas = array(
'id_product' => $product->id,