[+] FO : add files for combination
[*] FO : Create virtual products with no associated file
This commit is contained in:
@@ -27,4 +27,4 @@
|
|||||||
|
|
||||||
define('_PS_ADMIN_DIR_', getcwd());
|
define('_PS_ADMIN_DIR_', getcwd());
|
||||||
require(dirname(dirname(__FILE__)).'/config/config.inc.php');
|
require(dirname(dirname(__FILE__)).'/config/config.inc.php');
|
||||||
Controller::getController('getFileController')->run();
|
Controller::getController('GetFileController')->run();
|
||||||
+620
-124
@@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* 2007-2011 PrestaShop
|
* 2007-2011 PrestaShop
|
||||||
*
|
|
||||||
* NOTICE OF LICENSE
|
* NOTICE OF LICENSE
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0)
|
* This source file is subject to the Open Software License (OSL 3.0)
|
||||||
* that is bundled with this package in the file LICENSE.txt.
|
* that is bundled with this package in the file LICENSE.txt.
|
||||||
* It is also available through the world-wide-web at this URL:
|
* It is also available through the world-wide-web at this URL:
|
||||||
@@ -25,16 +25,15 @@
|
|||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*/
|
*/
|
||||||
include_once(_PS_ADMIN_DIR_.'/tabs/AdminProfiles.php');
|
include_once(_PS_ADMIN_DIR_.'/tabs/AdminProfiles.php');
|
||||||
|
include_once('functions.php');
|
||||||
|
|
||||||
class AdminProducts extends AdminTab
|
class AdminProducts extends AdminTab
|
||||||
{
|
{
|
||||||
protected $maxFileSize = 20000000;
|
protected $maxFileSize = 20000000;
|
||||||
|
|
||||||
private $_category;
|
private $_category;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->table = 'product';
|
$this->table = 'product';
|
||||||
$this->className = 'Product';
|
$this->className = 'Product';
|
||||||
$this->lang = true;
|
$this->lang = true;
|
||||||
@@ -129,8 +128,6 @@ class AdminProducts extends AdminTab
|
|||||||
$nb = count($this->_list);
|
$nb = count($this->_list);
|
||||||
if ($this->_list)
|
if ($this->_list)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/* update product final price */
|
/* update product final price */
|
||||||
for ($i = 0; $i < $nb; $i++)
|
for ($i = 0; $i < $nb; $i++)
|
||||||
$this->_list[$i]['price_tmp'] = Product::getPriceStatic($this->_list[$i]['id_product'], true, null, 6, null, false, true, 1, true);
|
$this->_list[$i]['price_tmp'] = Product::getPriceStatic($this->_list[$i]['id_product'], true, null, 6, null, false, true, 1, true);
|
||||||
@@ -158,6 +155,14 @@ class AdminProducts extends AdminTab
|
|||||||
return $productDownload->deleteFile();
|
return $productDownload->deleteFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteVirtualProductAttribute()
|
||||||
|
{
|
||||||
|
if (!($id_product_download = ProductDownload::getIdFromIdAttibute((int) Tools::getValue('id_product_attribute'))))
|
||||||
|
return false;
|
||||||
|
$productDownload = new ProductDownload((int)($id_product_download));
|
||||||
|
return $productDownload->deleteFile();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* postProcess handle every checks before saving products information
|
* postProcess handle every checks before saving products information
|
||||||
*
|
*
|
||||||
@@ -182,6 +187,15 @@ class AdminProducts extends AdminTab
|
|||||||
$this->deleteVirtualProduct();
|
$this->deleteVirtualProduct();
|
||||||
else
|
else
|
||||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Delete a product in the download folder */
|
||||||
|
if (Tools::getValue('deleteVirtualProductAttribute'))
|
||||||
|
{
|
||||||
|
if ($this->tabAccess['delete'] === '1')
|
||||||
|
$this->deleteVirtualProductAttribute();
|
||||||
|
else
|
||||||
|
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update attachments */
|
/* Update attachments */
|
||||||
@@ -509,6 +523,7 @@ class AdminProducts extends AdminTab
|
|||||||
$this->_errors[] = Tools::displayError('An error occurred while updating qty.');
|
$this->_errors[] = Tools::displayError('An error occurred while updating qty.');
|
||||||
}
|
}
|
||||||
Hook::updateProductAttribute((int)$id_product_attribute);
|
Hook::updateProductAttribute((int)$id_product_attribute);
|
||||||
|
$this->updateDownloadProduct($product, 1, $id_product_attribute);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -541,6 +556,7 @@ class AdminProducts extends AdminTab
|
|||||||
Tools::getValue('attribute_default'),
|
Tools::getValue('attribute_default'),
|
||||||
Tools::getValue('attribute_location'),
|
Tools::getValue('attribute_location'),
|
||||||
Tools::getValue('attribute_upc'));
|
Tools::getValue('attribute_upc'));
|
||||||
|
$this->updateDownloadProduct($product, 0, $id_product_attribute);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$this->_errors[] = Tools::displayError('You do not have permission to').'<hr>'.Tools::displayError('Edit here.');
|
$this->_errors[] = Tools::displayError('You do not have permission to').'<hr>'.Tools::displayError('Edit here.');
|
||||||
@@ -555,7 +571,7 @@ class AdminProducts extends AdminTab
|
|||||||
if (!$product->cache_default_attribute)
|
if (!$product->cache_default_attribute)
|
||||||
Product::updateDefaultAttribute($product->id);
|
Product::updateDefaultAttribute($product->id);
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&id_product='.$product->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&add'.$this->table.'&tabs=3&token='.($token ? $token : $this->token));
|
Tools::redirectAdmin(self::$currentIndex.'&id_product='.$product->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&add'.$this->table.'&tabs=3&token='.($token ? $token : $this->token));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -568,6 +584,14 @@ class AdminProducts extends AdminTab
|
|||||||
if (($id_product = (int)(Tools::getValue('id_product'))) && Validate::isUnsignedId($id_product) && Validate::isLoadedObject($product = new Product($id_product)))
|
if (($id_product = (int)(Tools::getValue('id_product'))) && Validate::isUnsignedId($id_product) && Validate::isLoadedObject($product = new Product($id_product)))
|
||||||
{
|
{
|
||||||
$product->deleteAttributeCombinaison(Tools::getValue('id_product_attribute'));
|
$product->deleteAttributeCombinaison(Tools::getValue('id_product_attribute'));
|
||||||
|
|
||||||
|
$id_product_download = ProductDownload::getIdFromIdAttibute((int) Tools::getValue('id_product_attribute'));
|
||||||
|
if ($id_product_download)
|
||||||
|
{
|
||||||
|
$productDownload = new ProductDownload((int) $id_product_download);
|
||||||
|
$this->deleteDownloadProduct((int) $id_product_download);
|
||||||
|
$productDownload->deleteFile();
|
||||||
|
}
|
||||||
$product->checkDefaultAttributes();
|
$product->checkDefaultAttributes();
|
||||||
$product->updateQuantityProductWithAttributeQuantity();
|
$product->updateQuantityProductWithAttributeQuantity();
|
||||||
if (!$product->hasAttributes())
|
if (!$product->hasAttributes())
|
||||||
@@ -1107,7 +1131,7 @@ class AdminProducts extends AdminTab
|
|||||||
$this->_errors[] = Tools::displayError('An error occurred while updating qty.');
|
$this->_errors[] = Tools::displayError('An error occurred while updating qty.');
|
||||||
}
|
}
|
||||||
$this->updateAccessories($object);
|
$this->updateAccessories($object);
|
||||||
$this->updateDownloadProduct($object);
|
$this->updateDownloadProduct($object, 1);
|
||||||
$this->updateAssoShop((int)$object->id);
|
$this->updateAssoShop((int)$object->id);
|
||||||
|
|
||||||
if (!$this->updatePackItems($object))
|
if (!$this->updatePackItems($object))
|
||||||
@@ -1234,48 +1258,159 @@ class AdminProducts extends AdminTab
|
|||||||
* @param object $product Product
|
* @param object $product Product
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function updateDownloadProduct($product)
|
public function updateDownloadProduct($product, $edit = 0, $id_product_attribute = null)
|
||||||
{
|
{
|
||||||
|
$filename = '';
|
||||||
|
$is_virtual_file = 0;
|
||||||
|
$id_product_download = 0;
|
||||||
|
|
||||||
|
$is_shareable = 0;
|
||||||
|
$virtual_product_name = '';
|
||||||
|
$virtual_product_nb_days = 0;
|
||||||
|
$virtual_product_filename = '';
|
||||||
|
$virtual_product_nb_downloable = 0;
|
||||||
|
$virtual_product_expiration_date = '';
|
||||||
|
|
||||||
|
$is_shareable_attribute = 0;
|
||||||
|
$virtual_product_name_attribute = '';
|
||||||
|
$virtual_product_nb_days_attribute = 0;
|
||||||
|
$virtual_product_filename_attribute = '';
|
||||||
|
$virtual_product_nb_downloable_attribute = 0;
|
||||||
|
$virtual_product_expiration_date_attribute = '';
|
||||||
|
|
||||||
|
$is_virtual_file = (int) Tools::getValue('is_virtual_file');
|
||||||
|
|
||||||
/* add or update a virtual product */
|
/* add or update a virtual product */
|
||||||
if (Tools::getValue('is_virtual_good') == 'true')
|
if (Tools::getValue('is_virtual_good') == 'true')
|
||||||
{
|
{
|
||||||
if (!Tools::getValue('virtual_product_name'))
|
if (!Tools::getValue('virtual_product_id') && !Tools::getValue('virtual_product_name_attribute') && !empty($is_virtual_file))
|
||||||
{
|
{
|
||||||
$this->_errors[] = $this->l('the field').' <b>'.$this->l('display filename').'</b> '.$this->l('is required');
|
if (!Tools::getValue('virtual_product_name'))
|
||||||
return false;
|
{
|
||||||
|
if (!Tools::getValue('virtual_product_name_attribute') && !empty($id_product_attribute))
|
||||||
|
{
|
||||||
|
$this->_errors[] = $this->l('the field').' <b>'.$this->l('display filename attribute').'</b> '.$this->l('is required');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (!empty($id_product_attribute))
|
||||||
|
{
|
||||||
|
$this->_errors[] = $this->l('the field').' <b>'.$this->l('display filename').'</b> '.$this->l('is required');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (Tools::getValue('virtual_product_nb_days') === false)
|
|
||||||
|
if (Tools::getValue('virtual_product_nb_days') === false && Tools::getValue('virtual_product_nb_days_attribute') === false && !empty($is_virtual_file))
|
||||||
{
|
{
|
||||||
$this->_errors[] = $this->l('the field').' <b>'.$this->l('number of days').'</b> '.$this->l('is required');
|
if (!Tools::getValue('virtual_product_name'))
|
||||||
return false;
|
{
|
||||||
}
|
if (!Tools::getValue('virtual_product_name_attribute'))
|
||||||
if (Tools::getValue('virtual_product_expiration_date') && !Validate::isDate(Tools::getValue('virtual_product_expiration_date')))
|
{
|
||||||
|
$this->_errors[] = $this->l('the field').' <b>'.$this->l('number of days attribute').'</b> '.$this->l('is required');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->_errors[] = $this->l('the field').' <b>'.$this->l('number of days').'</b> '.$this->l('is required');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Tools::getValue('virtual_product_expiration_date') AND !Validate::isDate(Tools::getValue('virtual_product_expiration_date') && !empty($is_virtual_file))
|
||||||
|
&& Tools::getValue('virtual_product_expiration_date_attribute') AND !Validate::isDate(Tools::getValue('virtual_product_expiration_date_attribute')))
|
||||||
{
|
{
|
||||||
$this->_errors[] = $this->l('the field').' <b>'.$this->l('expiration date').'</b> '.$this->l('is not valid');
|
if (!Tools::getValue('virtual_product_expiration_date'))
|
||||||
return false;
|
{
|
||||||
|
if (!Tools::getValue('virtual_product_expiration_date_attribute'))
|
||||||
|
{
|
||||||
|
$this->_errors[] = $this->l('the field').' <b>'.$this->l('expiration date attribute').'</b> '.$this->l('is required');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->_errors[] = $this->l('the field').' <b>'.$this->l('expiration date').'</b> '.$this->l('is not valid');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The oos behavior MUST be "Deny orders" for virtual products
|
// The oos behavior MUST be "Deny orders" for virtual products
|
||||||
if (Tools::getValue('out_of_stock') != 0)
|
if (Tools::getValue('out_of_stock') != 0)
|
||||||
{
|
{
|
||||||
$this->_errors[] = $this->l('The "when out of stock" behavior selection must be "deny order" for virtual products');
|
$this->_errors[] = $this->l('The "when out of stock" behavior selection must be "deny order" for virtual products');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Trick's
|
||||||
|
if ($edit == 1)
|
||||||
|
{
|
||||||
|
$id_product_download_attibute = ProductDownload::getIdFromIdAttibute($id_product_attribute);
|
||||||
|
$id_product_download = ($id_product_download_attibute) ? (int) $id_product_download_attibute : (int) Tools::getValue('virtual_product_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
$is_shareable = Tools::getValue('virtual_product_is_shareable');
|
||||||
|
$virtual_product_name = Tools::getValue('virtual_product_name');
|
||||||
|
$virtual_product_filename = Tools::getValue('virtual_product_filename');
|
||||||
|
$virtual_product_nb_days = Tools::getValue('virtual_product_nb_days');
|
||||||
|
$virtual_product_nb_downloable = Tools::getValue('virtual_product_nb_downloable');
|
||||||
|
$virtual_product_expiration_date = Tools::getValue('virtual_product_expiration_date');
|
||||||
|
|
||||||
|
$is_shareable_attribute = Tools::getValue('virtual_product_is_shareable_attribute');
|
||||||
|
$virtual_product_name_attribute = Tools::getValue('virtual_product_name_attribute');
|
||||||
|
$virtual_product_filename_attribute = Tools::getValue('virtual_product_filename_attribute');
|
||||||
|
$virtual_product_nb_days_attribute = Tools::getValue('virtual_product_nb_days_attribute');
|
||||||
|
$virtual_product_nb_downloable_attribute = Tools::getValue('virtual_product_nb_downloable_attribute');
|
||||||
|
$virtual_product_expiration_date_attribute = Tools::getValue('virtual_product_expiration_date_attribute');
|
||||||
|
|
||||||
|
if (!empty($is_shareable_attribute))
|
||||||
|
$is_shareable = $is_shareable_attribute;
|
||||||
|
|
||||||
|
if (!empty($virtual_product_name_attribute))
|
||||||
|
$virtual_product_name = $virtual_product_name_attribute;
|
||||||
|
|
||||||
|
if (!empty($virtual_product_nb_days_attribute))
|
||||||
|
$virtual_product_nb_days = $virtual_product_nb_days_attribute;
|
||||||
|
|
||||||
|
if (!empty($virtual_product_nb_downloable_attribute))
|
||||||
|
$virtual_product_nb_downloable = $virtual_product_nb_downloable_attribute;
|
||||||
|
|
||||||
|
if (!empty($virtual_product_expiration_date_attribute))
|
||||||
|
$virtual_product_expiration_date = $virtual_product_expiration_date_attribute;
|
||||||
|
|
||||||
$productDownload = new ProductDownload(Tools::getValue('virtual_product_id'));
|
if (!empty($virtual_product_filename_attribute))
|
||||||
$productDownload->id_product = $product->id;
|
$filename = $virtual_product_filename_attribute;
|
||||||
$productDownload->display_filename = Tools::getValue('virtual_product_name');
|
else if ($virtual_product_filename)
|
||||||
$productDownload->physically_filename = Tools::getValue('virtual_product_filename') ? Tools::getValue('virtual_product_filename') : ProductDownload::getNewFilename();
|
$filename = $virtual_product_filename;
|
||||||
$productDownload->date_deposit = date('Y-m-d H:i:s');
|
else
|
||||||
$productDownload->date_expiration = Tools::getValue('virtual_product_expiration_date') ? Tools::getValue('virtual_product_expiration_date').' 23:59:59' : '';
|
$filename = ProductDownload::getNewFilename();
|
||||||
$productDownload->nb_days_accessible = Tools::getValue('virtual_product_nb_days');
|
|
||||||
$productDownload->nb_downloadable = Tools::getValue('virtual_product_nb_downloable');
|
$download = new ProductDownload($id_product_download);
|
||||||
$productDownload->active = 1;
|
$download->id_product = (int) $product->id;
|
||||||
return $productDownload->save();
|
$download->id_product_attribute = (int) $id_product_attribute;
|
||||||
|
$download->display_filename = $virtual_product_name;
|
||||||
|
$download->filename = $filename;
|
||||||
|
$download->date_add = date('Y-m-d H:i:s');
|
||||||
|
$download->date_expiration = $virtual_product_expiration_date ? $virtual_product_expiration_date.' 23:59:59' : '';
|
||||||
|
$download->nb_days_accessible = (int) $virtual_product_nb_days;
|
||||||
|
$download->nb_downloadable = (int) $virtual_product_nb_downloable;
|
||||||
|
$download->active = 1;
|
||||||
|
$download->is_shareable = (int) $is_shareable;
|
||||||
|
|
||||||
|
if ($download->save())
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* unactive download product if checkbox not checked */
|
/* unactive download product if checkbox not checked */
|
||||||
if ($id_product_download = ProductDownload::getIdFromIdProduct($product->id))
|
if ($edit == 1)
|
||||||
|
{
|
||||||
|
$id_product_download_attibute = ProductDownload::getIdFromIdAttibute($id_product_attribute);
|
||||||
|
$id_product_download = ($id_product_download_attibute) ? (int) $id_product_download_attibute : (int) Tools::getValue('virtual_product_id');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$id_product_download = ProductDownload::getIdFromIdProduct($product->id);
|
||||||
|
|
||||||
|
if (!empty($id_product_download))
|
||||||
{
|
{
|
||||||
$productDownload = new ProductDownload($id_product_download);
|
$productDownload = new ProductDownload($id_product_download);
|
||||||
$productDownload->date_expiration = date('Y-m-d H:i:s', time()-1);
|
$productDownload->date_expiration = date('Y-m-d H:i:s', time()-1);
|
||||||
@@ -1285,7 +1420,19 @@ class AdminProducts extends AdminTab
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteDownloadProduct($id_product_attribute = NULL)
|
||||||
|
{
|
||||||
|
if (!empty($id_product_attribute))
|
||||||
|
{
|
||||||
|
$productDownload = new ProductDownload($id_product_attribute);
|
||||||
|
$productDownload->date_expiration = date('Y-m-d H:i:s', time()-1);
|
||||||
|
$productDownload->active = 0;
|
||||||
|
return $productDownload->save();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update product accessories
|
* Update product accessories
|
||||||
*
|
*
|
||||||
@@ -1822,7 +1969,6 @@ class AdminProducts extends AdminTab
|
|||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
';
|
';
|
||||||
include_once('functions.php');
|
|
||||||
includeDatepicker(array('sp_from', 'sp_to'), true);
|
includeDatepicker(array('sp_from', 'sp_to'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2029,7 +2175,143 @@ class AdminProducts extends AdminTab
|
|||||||
$cover = Product::getCover($obj->id);
|
$cover = Product::getCover($obj->id);
|
||||||
$this->_applyTaxToEcotax($obj);
|
$this->_applyTaxToEcotax($obj);
|
||||||
|
|
||||||
echo '
|
/*
|
||||||
|
* Form for add a virtual product like software, mp3, etc...
|
||||||
|
*/
|
||||||
|
$productDownload = new ProductDownload();
|
||||||
|
if ($id_product_download = $productDownload->getIdFromIdProduct($this->getFieldValue($obj, 'id')))
|
||||||
|
$productDownload = new ProductDownload($id_product_download);
|
||||||
|
|
||||||
|
$hidden = $display_filename = $check = '';
|
||||||
|
?>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
// <![CDATA[
|
||||||
|
ThickboxI18nImage = '<?php echo $this->l('Image') ?>';
|
||||||
|
ThickboxI18nOf = '<?php echo $this->l('of') ?>';
|
||||||
|
ThickboxI18nClose = '<?php echo $this->l('Close') ?>';
|
||||||
|
ThickboxI18nOrEscKey = '<?php echo $this->l('(or "Esc")') ?>';
|
||||||
|
ThickboxI18nNext = '<?php echo $this->l('Next >') ?>';
|
||||||
|
ThickboxI18nPrev = '<?php echo $this->l('< Previous') ?>';
|
||||||
|
tb_pathToImage = '../img/loadingAnimation.gif';
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript" src="<?php echo _PS_JS_DIR_ ?>jquery/thickbox-modified.js"></script>
|
||||||
|
<script type="text/javascript" src="<?php echo _PS_JS_DIR_ ?>jquery/ajaxfileupload.js"></script>
|
||||||
|
<script type="text/javascript" src="<?php echo _PS_JS_DIR_ ?>date.js"></script>
|
||||||
|
<style type="text/css">
|
||||||
|
<!--
|
||||||
|
@import url(<?php echo _PS_CSS_DIR_?>thickbox.css);
|
||||||
|
-->
|
||||||
|
</style>
|
||||||
|
<script type="text/javascript">
|
||||||
|
//<![CDATA[
|
||||||
|
function toggleVirtualProduct(elt)
|
||||||
|
{
|
||||||
|
$("#is_virtual_file_product").hide();
|
||||||
|
$("#virtual_good_attributes").hide();
|
||||||
|
|
||||||
|
if (elt.checked)
|
||||||
|
{
|
||||||
|
$('#virtual_good').show('slow');
|
||||||
|
$('#virtual_good_more').show('slow');
|
||||||
|
getE('out_of_stock_1').checked = 'checked';
|
||||||
|
getE('out_of_stock_2').disabled = 'disabled';
|
||||||
|
getE('out_of_stock_3').disabled = 'disabled';
|
||||||
|
getE('label_out_of_stock_2').setAttribute('for', '');
|
||||||
|
getE('label_out_of_stock_3').setAttribute('for', '');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$('#virtual_good').hide('slow');
|
||||||
|
$('#virtual_good_more').hide('slow');
|
||||||
|
getE('out_of_stock_2').disabled = false;
|
||||||
|
getE('out_of_stock_3').disabled = false;
|
||||||
|
getE('label_out_of_stock_2').setAttribute('for', 'out_of_stock_2');
|
||||||
|
getE('label_out_of_stock_3').setAttribute('for', 'out_of_stock_3');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function uploadFile()
|
||||||
|
{
|
||||||
|
$.ajaxFileUpload (
|
||||||
|
{
|
||||||
|
url:'./uploadProductFile.php',
|
||||||
|
secureuri:false,
|
||||||
|
fileElementId:'virtual_product_file',
|
||||||
|
dataType: 'xml',
|
||||||
|
success: function (data, status)
|
||||||
|
{
|
||||||
|
data = data.getElementsByTagName('return')[0];
|
||||||
|
var result = data.getAttribute("result");
|
||||||
|
var msg = data.getAttribute("msg");
|
||||||
|
var fileName = data.getAttribute("filename")
|
||||||
|
if(result == "error")
|
||||||
|
$("#upload-confirmation").html('<p>error: ' + msg + '</p>');
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$('#virtual_product_file').remove();
|
||||||
|
$('#virtual_product_file_label').hide();
|
||||||
|
$('#file_missing').hide();
|
||||||
|
$('#delete_downloadable_product').show();
|
||||||
|
$('#virtual_product_name').attr('value', fileName);
|
||||||
|
$('#upload-confirmation').html(
|
||||||
|
'<a class="link" href="get-file-admin.php?file='+msg+'&filename='+fileName+'"><?php echo $this->l('The file') ?> "' + fileName + '" <?php echo $this->l('has successfully been uploaded') ?></a>' +
|
||||||
|
'<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="' + msg + '" />');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function uploadFile2()
|
||||||
|
{
|
||||||
|
var link = '';
|
||||||
|
$.ajaxFileUpload (
|
||||||
|
{
|
||||||
|
url:'./uploadProductFileAttribute.php',
|
||||||
|
secureuri:false,
|
||||||
|
fileElementId:'virtual_product_file_attribute',
|
||||||
|
dataType: 'xml',
|
||||||
|
success: function (data, status)
|
||||||
|
{
|
||||||
|
data = data.getElementsByTagName('return')[0];
|
||||||
|
var result = data.getAttribute("result");
|
||||||
|
var msg = data.getAttribute("msg");
|
||||||
|
var fileName = data.getAttribute("filename");
|
||||||
|
if(result == "error")
|
||||||
|
$("#upload-confirmation2").html('<p>error: ' + msg + '</p>');
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$('#virtual_product_file_attribute').remove();
|
||||||
|
$('#virtual_product_file_label').hide();
|
||||||
|
$('#file_missing').hide();
|
||||||
|
$('#delete_downloadable_product_attribute').show();
|
||||||
|
$('#virtual_product_name_attribute').attr('value', fileName);
|
||||||
|
$('#upload-confirmation2').html(
|
||||||
|
'<a class="link" href="get-file-admin.php?file='+msg+'&filename='+fileName+'"><?php echo $this->l('The file') ?> "' + fileName + '" <?php echo $this->l('has successfully been uploaded') ?></a>' +
|
||||||
|
'<input type="hidden" id="virtual_product_filename_attribute" name="virtual_product_filename_attribute" value="' + msg + '" />');
|
||||||
|
|
||||||
|
link = $("#delete_downloadable_product_attribute").attr('href');
|
||||||
|
$("#delete_downloadable_product_attribute").attr('href', link+"&file="+msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if(($productDownload->id OR Tools::getValue('is_virtual_good')=='true') AND $productDownload->active)
|
||||||
|
$check = 'checked="checked"';
|
||||||
|
|
||||||
|
if(!$productDownload->id OR !$productDownload->active)
|
||||||
|
$hidden = 'style="display:none;"';
|
||||||
|
|
||||||
|
$cache_default_attribute = $this->getFieldValue($obj, 'cache_default_attribute');
|
||||||
|
|
||||||
|
echo '
|
||||||
<div class="tab-page" id="step1">
|
<div class="tab-page" id="step1">
|
||||||
<h4 class="tab">1. '.$this->l('Info.').'</h4>
|
<h4 class="tab">1. '.$this->l('Info.').'</h4>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@@ -2347,89 +2629,183 @@ class AdminProducts extends AdminTab
|
|||||||
var customizationTextFieldNumber = '.(int)($this->getFieldValue($obj, 'text_fields')).';
|
var customizationTextFieldNumber = '.(int)($this->getFieldValue($obj, 'text_fields')).';
|
||||||
var uploadableFileLabel = 0;
|
var uploadableFileLabel = 0;
|
||||||
var textFieldLabel = 0;
|
var textFieldLabel = 0;
|
||||||
</script>';
|
</script>
|
||||||
?>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<p><input type="checkbox" id="is_virtual_good" name="is_virtual_good" value="true" onclick="toggleVirtualProduct(this);" <?php if (($productDownload->id || Tools::getValue('is_virtual_good')=='true') && $productDownload->active) echo 'checked="checked"' ?> />
|
|
||||||
<label for="is_virtual_good" class="t bold" style="color: black;"><?php echo $this->l('Is this a downloadable product?') ?></label></p>
|
|
||||||
<div id="virtual_good" <?php if (!$productDownload->id || !$productDownload->active) echo 'style="display:none;"' ?> >
|
|
||||||
<?php if (!ProductDownload::checkWritableDir()): ?>
|
|
||||||
<p class="alert">
|
|
||||||
<?php echo $this->l('Your download repository is not writable.'); ?><br/>
|
|
||||||
<?php echo realpath(_PS_DOWNLOAD_DIR_); ?>
|
|
||||||
</p>
|
|
||||||
<?php else: ?>
|
|
||||||
<?php if ($productDownload->id) echo '<input type="hidden" id="virtual_product_id" name="virtual_product_id" value="'.$productDownload->id.'" />' ?>
|
|
||||||
<p class="block">
|
|
||||||
<?php if (!$productDownload->checkFile()): ?>
|
|
||||||
|
|
||||||
<div style="padding:5px;width:50%;float:left;margin-right:20px;border-right:1px solid #E0D0B1">
|
<p><input type="checkbox" id="is_virtual_good" name="is_virtual_good" value="true" onclick="toggleVirtualProduct(this);" '.$check.' />
|
||||||
<?php if ($productDownload->id): ?>
|
<label for="is_virtual_good" class="t bold" style="color: black;">'.$this->l('Is this a virtual product?').'</label></p>
|
||||||
<p class="alert" id="file_missing">
|
<div id="virtual_good" '.$hidden.'>
|
||||||
<?php echo $this->l('This product is missing') ?>:<br/>
|
|
||||||
<?php echo realpath(_PS_DOWNLOAD_DIR_) .'/'. $productDownload->physically_filename ?>
|
<br/>'.$this->l('Does this product has an associated file ?').'<br/>';
|
||||||
|
|
||||||
|
$exists_file = realpath(_PS_DOWNLOAD_DIR_).'/'.$productDownload->filename;
|
||||||
|
|
||||||
|
if ($productDownload->id && file_exists($exists_file) || !empty($productDownload->display_filename))
|
||||||
|
{
|
||||||
|
echo '<input type="radio" value="1" id="virtual_good_file_1" name="is_virtual_file" checked="checked" />'. $this->l('Yes').'
|
||||||
|
<input type="radio" value="0" id="virtual_good_file_2" name="is_virtual_file" />'.$this->l('No').'<br /><br />';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo '<input type="radio" value="1" id="virtual_good_file_1" name="is_virtual_file" />'. $this->l('Yes').'
|
||||||
|
<input type="radio" value="0" id="virtual_good_file_2" name="is_virtual_file" checked="checked" />'.$this->l('No').'<br /><br />';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file_exists($exists_file) && !empty($productDownload->display_filename) && empty($cache_default_attribute))
|
||||||
|
{
|
||||||
|
$msg = sprintf(Tools::displayError('This file "%s" is missing'), $productDownload->display_filename);
|
||||||
|
echo '<p class="alert" id="file_missing">
|
||||||
|
<b>'.$msg.' :<br/>
|
||||||
|
'.realpath(_PS_DOWNLOAD_DIR_) .'/'. $productDownload->filename.'</b>
|
||||||
|
</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ProductDownload::checkWritableDir())
|
||||||
|
{
|
||||||
|
echo '<p class="alert">
|
||||||
|
'.$this->l('Your download repository is not writable.').'<br/>
|
||||||
|
'.realpath(_PS_DOWNLOAD_DIR_).'
|
||||||
|
</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<div id="is_virtual_file_product" style="display:none;">';
|
||||||
|
if (empty($cache_default_attribute))
|
||||||
|
{
|
||||||
|
if($productDownload->id)
|
||||||
|
echo '<input type="hidden" id="virtual_product_id" name="virtual_product_id" value="'.$productDownload->id.'" />';
|
||||||
|
|
||||||
|
echo '<p class="block">';
|
||||||
|
|
||||||
|
if (!$productDownload->checkFile())
|
||||||
|
{
|
||||||
|
echo '<div style="padding:5px;width:50%;float:left;margin-right:20px;border-right:1px solid #E0D0B1">
|
||||||
|
<p>'.$this->l('Your server\'s maximum upload file size is') . ': ' . ini_get('upload_max_filesize').'</p>';
|
||||||
|
if (!strval(Tools::getValue('virtual_product_filename')) OR $productDownload->id > 0)
|
||||||
|
{
|
||||||
|
echo '<label id="virtual_product_file_label" for="virtual_product_file" class="t">'.$this->l('Upload a file').'</label>
|
||||||
|
<p><input type="file" id="virtual_product_file" name="virtual_product_file" onchange="uploadFile();" maxlength="'.$this->maxFileSize.'" /></p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<div id="upload-confirmation">';
|
||||||
|
if ($up_filename = strval(Tools::getValue('virtual_product_filename')))
|
||||||
|
echo '<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="'.$up_filename.'" />';
|
||||||
|
|
||||||
|
echo '</div>
|
||||||
|
<a id="delete_downloadable_product" style="display:none;" onclick="return confirm(\''.addslashes($this->l('Delete this file')).'\')" href="'.$_SERVER['REQUEST_URI'].'&deleteVirtualProduct=true'.'" class="red">'.$this->l('Delete this file').'</a>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo '<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="'.$productDownload->filename.'" />
|
||||||
|
'.$this->l('This is the link').': '.$productDownload->getHtmlLink(false, true).'
|
||||||
|
<a onclick="return confirm(\''.addslashes($this->l('Delete this file')).'\')" href="'.$_SERVER['REQUEST_URI'].'&deleteVirtualProduct=true'.'" class="red">'.$this->l('Delete this file').'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$display_filename = ($productDownload->id > 0) ? $productDownload->display_filename : htmlentities(Tools::getValue('virtual_product_name'), ENT_COMPAT, 'UTF-8');
|
||||||
|
echo '</p><p class="block">
|
||||||
|
<label for="virtual_product_name" class="t">'.$this->l('Filename').'</label>
|
||||||
|
<input type="text" id="virtual_product_name" name="virtual_product_name" style="width:200px" value="'.$display_filename.'" />
|
||||||
|
<span class="hint" name="help_box" style="display:none;">'.$this->l('The full filename with its extension (e.g., Book.pdf)').'</span>
|
||||||
</p>
|
</p>
|
||||||
<?php endif; ?>
|
|
||||||
<p><?php echo $this->l('Your server\'s maximum upload file size is') . ': ' . ini_get('upload_max_filesize') ?></p>
|
</div>';
|
||||||
<?php if (!strval(Tools::getValue('virtual_product_filename'))): ?>
|
|
||||||
<label id="virtual_product_file_label" for="virtual_product_file" class="t"><?php echo $this->l('Upload a file') ?></label>
|
if (!$productDownload->id || !$productDownload->active)
|
||||||
<p><input type="file" id="virtual_product_file" name="virtual_product_file" onchange="uploadFile();" maxlength="<?php echo $this->maxFileSize ?>" /></p>
|
$hidden = 'display:none;';
|
||||||
<?php endif; ?>
|
|
||||||
<div id="upload-confirmation">
|
$nb_downloadable = ($productDownload->id > 0) ? $productDownload->nb_downloadable : htmlentities(Tools::getValue('virtual_product_nb_downloable'), ENT_COMPAT, 'UTF-8');
|
||||||
<?php if ($up_filename = strval(Tools::getValue('virtual_product_filename'))): ?>
|
$date_expiration = ($productDownload->id > 0) ? ((!empty($productDownload->date_expiration) && $productDownload->date_expiration != '0000-00-00 00:00:00') ? date('Y-m-d', strtotime($productDownload->date_expiration)) : '' ) : htmlentities(Tools::getValue('virtual_product_expiration_date'), ENT_COMPAT, 'UTF-8');
|
||||||
<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="<?php echo $up_filename ?>" />
|
$nb_days_accessible = ($productDownload->id > 0) ? $productDownload->nb_days_accessible : htmlentities(Tools::getValue('virtual_product_nb_days'), ENT_COMPAT, 'UTF-8');
|
||||||
<?php endif; ?>
|
$is_shareable = ($productDownload->id > 0 && $productDownload->is_shareable) ? 'checked="checked"' : '';
|
||||||
|
|
||||||
|
echo '<div id="virtual_good_more" style="'.$hidden.'padding:5px;width:40%;float:left;margin-left:10px">
|
||||||
|
<p class="block">
|
||||||
|
<label for="virtual_product_nb_downloable" class="t">'.$this->l('Number of downloads').'</label>
|
||||||
|
<input type="text" id="virtual_product_nb_downloable" name="virtual_product_nb_downloable" value="'.$nb_downloadable.'" class="" size="6" />
|
||||||
|
<span class="hint" name="help_box" style="display:none">'.$this->l('Number of authorized downloads per customer').'</span>
|
||||||
|
</p>
|
||||||
|
<p class="block">
|
||||||
|
<label for="virtual_product_expiration_date" class="t">'.$this->l('Expiration date').'</label>
|
||||||
|
<input type="text" id="virtual_product_expiration_date" name="virtual_product_expiration_date" value="'.$date_expiration.'" size="11" maxlength="10" autocomplete="off" /> '.$this->l('Format: YYYY-MM-DD').'
|
||||||
|
<span class="hint" name="help_box" style="display:none">'.$this->l('No expiration date if you leave this blank').'</span>
|
||||||
|
</p>
|
||||||
|
<p class="block">
|
||||||
|
<label for="virtual_product_nb_days" class="t">'.$this->l('Number of days').'</label>
|
||||||
|
<input type="text" id="virtual_product_nb_days" name="virtual_product_nb_days" value="'.$nb_days_accessible.'" class="" size="4" /><sup> *</sup>
|
||||||
|
<span class="hint" name="help_box" style="display:none">'.$this->l('How many days this file can be accessed by customers').' - <em>('.$this->l('set to zero for unlimited access').')</em></span>
|
||||||
|
</p>
|
||||||
|
<p class="block">
|
||||||
|
<label for="virtual_product_is_shareable" class="t">'.$this->l('is shareable').'</label>
|
||||||
|
<input type="checkbox" id="virtual_product_is_shareable" name="virtual_product_is_shareable" value="1" '.$is_shareable.'/>
|
||||||
|
<span class="hint" name="help_box" style="display:none">'.$this->l('Specify if the file can be shared').'</span>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<a id="delete_downloadable_product" style="display:none;" onclick="return confirm('<?php echo addslashes($this->l('Delete this file')) ?>')" href="<?php echo $_SERVER['REQUEST_URI'].'&deleteVirtualProduct=true' ?>" class="red"><?php echo $this->l('Delete this file') ?></a>
|
';
|
||||||
<?php else: ?>
|
}
|
||||||
<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="<?php echo $productDownload->physically_filename ?>" />
|
else
|
||||||
<?php echo $this->l('This is the link').': '.$productDownload->getHtmlLink(false, true) ?>
|
{
|
||||||
<a onclick="return confirm('<?php echo addslashes($this->l('Delete this file')) ?>')" href="<?php echo $_SERVER['REQUEST_URI'].'&deleteVirtualProduct=true' ?>" class="red"><?php echo $this->l('Delete this file') ?></a>
|
$error ='';
|
||||||
<?php endif; // check if file exists ?>
|
echo '<div class="hint clear" style="display: block;width: 70%;">'.$this->l('You used combinations, for this reason you can\'t edit your file here, but in the Combinations tab').'</div>
|
||||||
</p>
|
<br />';
|
||||||
<p class="block">
|
$product_attribute = ProductDownload::getAttributeFromIdProduct($this->getFieldValue($obj, 'id'));
|
||||||
<label for="virtual_product_name" class="t"><?php echo $this->l('Filename') ?></label>
|
foreach ($product_attribute as $product)
|
||||||
<input type="text" id="virtual_product_name" name="virtual_product_name" style="width:200px" value="<?php echo $productDownload->id > 0 ? $productDownload->display_filename : htmlentities(Tools::getValue('virtual_product_name'), ENT_COMPAT, 'UTF-8') ?>" />
|
{
|
||||||
<span class="hint" name="help_box" style="display:none;"><?php echo $this->l('The full filename with its extension (e.g., Book.pdf)') ?></span>
|
$productDownloadAttribute = new ProductDownload($product['id_product_download']);
|
||||||
</p>
|
$exists_file2 = realpath(_PS_DOWNLOAD_DIR_).'/'.$productDownloadAttribute->filename;
|
||||||
|
if (!file_exists($exists_file2))
|
||||||
</div>
|
{
|
||||||
<div id="virtual_good_more" style="<?php if (!$productDownload->id || !$productDownload->active) echo 'display:none;' ?>padding:5px;width:40%;float:left;margin-left:10px">
|
$msg = sprintf(Tools::displayError('This file "%s" is missing'), $productDownloadAttribute->display_filename);
|
||||||
|
$error .= '<p class="alert" id="file_missing">
|
||||||
<p class="block">
|
<b>'.$msg.' :<br/>
|
||||||
<label for="virtual_product_nb_downloable" class="t"><?php echo $this->l('Number of downloads') ?></label>
|
'.realpath(_PS_DOWNLOAD_DIR_) .'/'. $productDownloadAttribute->filename.'</b>
|
||||||
<input type="text" id="virtual_product_nb_downloable" name="virtual_product_nb_downloable" value="<?php echo $productDownload->id > 0 ? $productDownload->nb_downloadable : htmlentities(Tools::getValue('virtual_product_nb_downloable'), ENT_COMPAT, 'UTF-8') ?>" class="" size="6" />
|
</p>';
|
||||||
<span class="hint" name="help_box" style="display:none"><?php echo $this->l('Number of authorized downloads per customer') ?></span>
|
}
|
||||||
</p>
|
}
|
||||||
<p class="block">
|
echo $error;
|
||||||
<label for="virtual_product_expiration_date" class="t"><?php echo $this->l('Expiration date') ?></label>
|
}
|
||||||
<input type="text" id="virtual_product_expiration_date" name="virtual_product_expiration_date" value="<?php echo ($productDownload->id > 0) ? ((!empty($productDownload->date_expiration) && $productDownload->date_expiration != '0000-00-00 00:00:00') ? date('Y-m-d', strtotime($productDownload->date_expiration))
|
echo '</div>
|
||||||
: '' ) : htmlentities(Tools::getValue('virtual_product_expiration_date'), ENT_COMPAT, 'UTF-8') ?>" size="11" maxlength="10" autocomplete="off" /> <?php echo $this->l('Format: YYYY-MM-DD'); ?>
|
|
||||||
<span class="hint" name="help_box" style="display:none"><?php echo $this->l('No expiration date if you leave this blank'); ?></span>
|
|
||||||
</p>
|
|
||||||
<p class="block">
|
|
||||||
<label for="virtual_product_nb_days" class="t"><?php echo $this->l('Number of days') ?></label>
|
|
||||||
<input type="text" id="virtual_product_nb_days" name="virtual_product_nb_days" value="<?php echo $productDownload->id > 0 ? $productDownload->nb_days_accessible : htmlentities(Tools::getValue('virtual_product_nb_days'), ENT_COMPAT, 'UTF-8') ?>" class="" size="4" /><sup> *</sup>
|
|
||||||
<span class="hint" name="help_box" style="display:none"><?php echo $this->l('How many days this file can be accessed by customers') ?> - <em>(<?php echo $this->l('set to zero for unlimited access'); ?>)</em></span>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<?php endif; // check if download directory is writable ?>
|
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>';
|
||||||
<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>
|
|
||||||
<script type="text/javascript">
|
includeDatepicker('virtual_product_expiration_date');
|
||||||
if ($('#is_virtual_good').attr('checked'))
|
|
||||||
{
|
echo '<tr>
|
||||||
$('#virtual_good').show('slow');
|
<td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td>
|
||||||
$('#virtual_good_more').show('slow');
|
</tr>
|
||||||
}
|
<script type="text/javascript">
|
||||||
</script>
|
$(document).ready(function(){
|
||||||
|
if ($("#is_virtual_good").attr("checked"))
|
||||||
|
{
|
||||||
|
$("#virtual_good").show("slow");
|
||||||
|
$("#virtual_good_more").show("slow");
|
||||||
|
}
|
||||||
|
|
||||||
<?php
|
if ( $("input[name=is_virtual_file]:checked").val() == 1)
|
||||||
|
{
|
||||||
echo '
|
$("#virtual_good_attributes").show();
|
||||||
|
$("#is_virtual_file_product").show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#virtual_good_attributes").hide();
|
||||||
|
$("#is_virtual_file_product").hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
$("input[name=is_virtual_file]").live("change", function() {
|
||||||
|
if($(this).val() == "1")
|
||||||
|
{
|
||||||
|
$("#virtual_good_attributes").show();
|
||||||
|
$("#is_virtual_file_product").show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#virtual_good_attributes").hide();
|
||||||
|
$("#is_virtual_file_product").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="col-left">'.$this->l('Pre-tax wholesale price:').'</td>
|
<td class="col-left">'.$this->l('Pre-tax wholesale price:').'</td>
|
||||||
<td style="padding-bottom:5px;">
|
<td style="padding-bottom:5px;">
|
||||||
@@ -2482,7 +2858,6 @@ class AdminProducts extends AdminTab
|
|||||||
echo '<input type="hidden" value="'.(int)($this->getFieldValue($obj, 'id_tax_rules_group')).'" name="id_tax_rules_group" />';
|
echo '<input type="hidden" value="'.(int)($this->getFieldValue($obj, 'id_tax_rules_group')).'" name="id_tax_rules_group" />';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
echo '</td>
|
echo '</td>
|
||||||
</tr>
|
</tr>
|
||||||
';
|
';
|
||||||
@@ -2505,9 +2880,10 @@ class AdminProducts extends AdminTab
|
|||||||
'.($currency->format % 2 != 0 ? ' '.$currency->sign : '').' <input size="11" maxlength="14" id="priceTI" type="text" value="" onchange="noComma(\'priceTI\');" onkeyup="if (isArrowKey(event)) return; calcPriceTE();" />'.($currency->format % 2 == 0 ? ' '.$currency->sign : '').'
|
'.($currency->format % 2 != 0 ? ' '.$currency->sign : '').' <input size="11" maxlength="14" id="priceTI" type="text" value="" onchange="noComma(\'priceTI\');" onkeyup="if (isArrowKey(event)) return; calcPriceTE();" />'.($currency->format % 2 == 0 ? ' '.$currency->sign : '').'
|
||||||
</td>
|
</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
echo '<input size="11" maxlength="14" id="priceTI" type="hidden" value="" onchange="noComma(\'priceTI\');" onkeyup="if (isArrowKey(event)) return; calcPriceTE();" />';
|
echo '<input size="11" maxlength="14" id="priceTI" type="hidden" value="" onchange="noComma(\'priceTI\');" onkeyup="if (isArrowKey(event)) return; calcPriceTE();" />';
|
||||||
}
|
|
||||||
echo '
|
echo '
|
||||||
<tr id="tr_unit_price">
|
<tr id="tr_unit_price">
|
||||||
<td class="col-left">'.$this->l('Unit price without tax:').'</td>
|
<td class="col-left">'.$this->l('Unit price without tax:').'</td>
|
||||||
@@ -2669,7 +3045,6 @@ class AdminProducts extends AdminTab
|
|||||||
</td>
|
</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
// date picker include
|
// date picker include
|
||||||
include_once('functions.php');
|
|
||||||
includeDatepicker('available_date');
|
includeDatepicker('available_date');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3222,8 +3597,6 @@ class AdminProducts extends AdminTab
|
|||||||
|
|
||||||
foreach ($images as $k => $image)
|
foreach ($images as $k => $image)
|
||||||
echo $this->getLineTableImage($image, $imagesTotal, $token, $shops);
|
echo $this->getLineTableImage($image, $imagesTotal, $token, $shops);
|
||||||
|
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
@@ -3321,7 +3694,12 @@ class AdminProducts extends AdminTab
|
|||||||
$currency = $this->context->currency;
|
$currency = $this->context->currency;
|
||||||
$attributes_groups = AttributeGroup::getAttributesGroups($this->context->language->id);
|
$attributes_groups = AttributeGroup::getAttributesGroups($this->context->language->id);
|
||||||
$default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT'));
|
$default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||||
|
|
||||||
|
$productDownload = new ProductDownload();
|
||||||
|
$id_product_download = (int) $productDownload->getIdFromIdProduct($this->getFieldValue($obj, 'id'));
|
||||||
|
if (!empty($id_product_download))
|
||||||
|
$productDownload = new ProductDownload($id_product_download);
|
||||||
|
|
||||||
$images = Image::getImages($this->context->language->id, $obj->id);
|
$images = Image::getImages($this->context->language->id, $obj->id);
|
||||||
if ($obj->id)
|
if ($obj->id)
|
||||||
{
|
{
|
||||||
@@ -3332,7 +3710,31 @@ class AdminProducts extends AdminTab
|
|||||||
updateMvtStatus($(this).val());
|
updateMvtStatus($(this).val());
|
||||||
});
|
});
|
||||||
updateMvtStatus($(this).val());
|
updateMvtStatus($(this).val());
|
||||||
});
|
|
||||||
|
if ( $("input[name=is_virtual_file]:checked").val() == 1)
|
||||||
|
{
|
||||||
|
$("#virtual_good_attributes").show();
|
||||||
|
$("#is_virtual_file_product").show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#virtual_good_attributes").hide();
|
||||||
|
$("#is_virtual_file_product").hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
$("input[name=is_virtual_file]").live("change", function() {
|
||||||
|
if($(this).val() == "1")
|
||||||
|
{
|
||||||
|
$("#virtual_good_attributes").show();
|
||||||
|
$("#is_virtual_file_product").show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#virtual_good_attributes").hide();
|
||||||
|
$("#is_virtual_file_product").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<table cellpadding="5">
|
<table cellpadding="5">
|
||||||
<tr>
|
<tr>
|
||||||
@@ -3371,6 +3773,7 @@ class AdminProducts extends AdminTab
|
|||||||
<select id="product_att_list" name="attribute_combinaison_list[]" multiple="multiple" size="4" style="width: 320px;"></select>
|
<select id="product_att_list" name="attribute_combinaison_list[]" multiple="multiple" size="4" style="width: 320px;"></select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr><td colspan="2"><hr style="width:100%;" /></td></tr>
|
<tr><td colspan="2"><hr style="width:100%;" /></td></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">'.$this->l('Reference:').'</td>
|
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">'.$this->l('Reference:').'</td>
|
||||||
@@ -3389,7 +3792,59 @@ class AdminProducts extends AdminTab
|
|||||||
<span class="hint" name="help_box">'.$this->l('Special characters allowed:').' .-_#<span class="hint-pointer"> </span></span>
|
<span class="hint" name="help_box">'.$this->l('Special characters allowed:').' .-_#<span class="hint-pointer"> </span></span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td colspan="2"><hr style="width:100%;" /></td></tr>
|
<tr><td colspan="2"><hr style="width:100%;" /></td></tr>
|
||||||
|
<table cellpadding="5" id="virtual_good_attributes" style="width:100%;display:none;">
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div style="padding:5px;width:50%;float:left;margin-right:20px;border-right:1px solid #E0D0B1">
|
||||||
|
<p>'.$this->l('Your server\'s maximum upload file size is') . ': ' . ini_get('upload_max_filesize').'</p>
|
||||||
|
<label id="virtual_product_file_attribute_label" for="virtual_product_file_attribute" class="t">'.$this->l('Upload a file').'</label>
|
||||||
|
<p><input id="virtual_product_file_attribute" name="virtual_product_file_attribute" onchange="uploadFile2();" maxlength="'.$this->maxFileSize.'" type="file"></p>
|
||||||
|
<div id="upload-confirmation2">';
|
||||||
|
|
||||||
|
echo '<p id="gethtmlink" style="display: none;">'.$this->l('This is the link').': '.$productDownload->getHtmlLink(false, true).'
|
||||||
|
<a id="make_downloadable_product_attribute" onclick="return confirm(\''.addslashes($this->l('Delete this file')).'\')" href="'.$_SERVER['HTTP_REFERER'].'&deleteVirtualProductAttribute=true'.'" class="red">'.$this->l('Delete this file').'</a></p>';
|
||||||
|
|
||||||
|
echo '</div>
|
||||||
|
<a id="delete_downloadable_product_attribute" style="display:none;" onclick="return confirm(\''.addslashes($this->l('Delete this file')).'\')" href="'.$_SERVER['HTTP_REFERER'].'&deleteVirtualProductAttribute=true" class="red">'.$this->l('Delete this file').'</a>';
|
||||||
|
|
||||||
|
if ($up_filename = strval(Tools::getValue('virtual_product_filename_attribute')))
|
||||||
|
echo '<input type="hidden" id="virtual_product_filename_attribute" name="virtual_product_filename_attribute" value="'.$up_filename.'" />';
|
||||||
|
|
||||||
|
echo '<p class="block">
|
||||||
|
<label for="virtual_product_name" class="t">'.$this->l('Filename').'</label>
|
||||||
|
<input id="virtual_product_name_attribute" name="virtual_product_name_attribute" style="width:200px" value="" type="text">
|
||||||
|
<span class="hint" name="help_box" style="display:none;">'.$this->l('The full filename with its extension (e.g., Book.pdf)').'</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div id="virtual_good_more_attribute" style="padding:5px;width:40%;float:left;margin-left:10px">
|
||||||
|
<p class="block">
|
||||||
|
<label for="virtual_product_nb_downloable" class="t">'.$this->l('Number of downloads').'</label>
|
||||||
|
<input type="text" id="virtual_product_nb_downloable_attribute" name="virtual_product_nb_downloable_attribute" value="" class="" size="6" />
|
||||||
|
<span class="hint" name="help_box" style="display:none">'.$this->l('Number of authorized downloads per customer').'</span>
|
||||||
|
</p>
|
||||||
|
<p class="block">
|
||||||
|
<label for="virtual_product_expiration_date_attribute" class="t">'.$this->l('Expiration date').'</label>
|
||||||
|
<input type="text" id="virtual_product_expiration_date_attribute" name="virtual_product_expiration_date_attribute" value="" size="11" maxlength="10" autocomplete="off" /> '.$this->l('Format: YYYY-MM-DD').'
|
||||||
|
<span class="hint" name="help_box" style="display:none">'.$this->l('No expiration date if you leave this blank').'</span>
|
||||||
|
</p>
|
||||||
|
<p class="block">
|
||||||
|
<label for="virtual_product_nb_days" class="t">'.$this->l('Number of days').'</label>
|
||||||
|
<input type="text" id="virtual_product_nb_days_attribute" name="virtual_product_nb_days_attribute" value="" class="" size="4" /><sup> *</sup>
|
||||||
|
<span class="hint" name="help_box" style="display:none">'.$this->l('How many days this file can be accessed by customers').' - <em>('.$this->l('set to zero for unlimited access').')</em></span>
|
||||||
|
</p>
|
||||||
|
<p class="block">
|
||||||
|
<label for="virtual_product_is_shareable_attribute" class="t">'.$this->l('is shareable').'</label>
|
||||||
|
<input type="checkbox" id="virtual_product_is_shareable_attribute" name="virtual_product_is_shareable" value="1" />
|
||||||
|
<span class="hint" name="help_box" style="display:none">'.$this->l('Specify if the file can be shared').'</span>
|
||||||
|
</p>
|
||||||
|
</div>';
|
||||||
|
includeDatepicker('virtual_product_expiration_date_attribute');
|
||||||
|
echo '</td>
|
||||||
|
</tr>
|
||||||
|
<tr><td colspan="2"><hr style="width:100%;" /></td></tr>
|
||||||
|
</table>
|
||||||
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">'.$this->l('Wholesale price:').'</td>
|
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">'.$this->l('Wholesale price:').'</td>
|
||||||
<td style="padding-bottom:5px;">'.($currency->format % 2 != 0 ? $currency->sign.' ' : '').'<input type="text" size="6" name="attribute_wholesale_price" id="attribute_wholesale_price" value="0.00" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" />'.($currency->format % 2 == 0 ? ' '.$currency->sign : '').' ('.$this->l('overrides Wholesale price on Information tab').')</td>
|
<td style="padding-bottom:5px;">'.($currency->format % 2 != 0 ? $currency->sign.' ' : '').'<input type="text" size="6" name="attribute_wholesale_price" id="attribute_wholesale_price" value="0.00" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" />'.($currency->format % 2 == 0 ? ' '.$currency->sign : '').' ('.$this->l('overrides Wholesale price on Information tab').')</td>
|
||||||
@@ -3480,7 +3935,6 @@ class AdminProducts extends AdminTab
|
|||||||
</td>
|
</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
// date picker include
|
// date picker include
|
||||||
include_once('functions.php');
|
|
||||||
includeDatepicker('available_date');
|
includeDatepicker('available_date');
|
||||||
echo '
|
echo '
|
||||||
<tr><td colspan="2"><hr style="width:100%;" /></td></tr>
|
<tr><td colspan="2"><hr style="width:100%;" /></td></tr>
|
||||||
@@ -3529,8 +3983,18 @@ class AdminProducts extends AdminTab
|
|||||||
<th>'.$this->l('Reference').'</th>
|
<th>'.$this->l('Reference').'</th>
|
||||||
<th>'.$this->l('EAN13').'</th>
|
<th>'.$this->l('EAN13').'</th>
|
||||||
<th>'.$this->l('UPC').'</th>
|
<th>'.$this->l('UPC').'</th>
|
||||||
<th class="center">'.$this->l('Quantity').'</th>
|
<th class="center">'.$this->l('Quantity').'</th>';
|
||||||
<th class="center">'.$this->l('Actions').'</th>
|
|
||||||
|
if ($id_product_download && !empty($productDownload->display_filename))
|
||||||
|
{
|
||||||
|
echo '
|
||||||
|
<th class="center">'.$this->l('Filename').'</th>
|
||||||
|
<th class="center">'.$this->l('Number of downloads').'</th>
|
||||||
|
<th class="center">'.$this->l('Number of days').'</th>
|
||||||
|
<th class="center">'.$this->l('Share').'</th>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<th class="center">'.$this->l('Actions').'</th>
|
||||||
</tr>';
|
</tr>';
|
||||||
if ($obj->id)
|
if ($obj->id)
|
||||||
{
|
{
|
||||||
@@ -3582,6 +4046,22 @@ class AdminProducts extends AdminTab
|
|||||||
$jsList = rtrim($jsList, ', ');
|
$jsList = rtrim($jsList, ', ');
|
||||||
$attrImage = $product_attribute['id_image'] ? new Image($product_attribute['id_image']) : false;
|
$attrImage = $product_attribute['id_image'] ? new Image($product_attribute['id_image']) : false;
|
||||||
$available_date = ($product_attribute['available_date'] != 0) ? date('Y-m-d', strtotime($product_attribute['available_date'])) : '0000-00-00';
|
$available_date = ($product_attribute['available_date'] != 0) ? date('Y-m-d', strtotime($product_attribute['available_date'])) : '0000-00-00';
|
||||||
|
|
||||||
|
$id_product_download = $productDownload->getIdFromIdAttibute((int) $id_product_attribute);
|
||||||
|
|
||||||
|
if ($id_product_download)
|
||||||
|
$productDownload = new ProductDownload($id_product_download);
|
||||||
|
|
||||||
|
$available_date_attribute = substr($productDownload->date_expiration, 0, -9);
|
||||||
|
|
||||||
|
if ($available_date_attribute == '0000-00-00')
|
||||||
|
$available_date_attribute = '';
|
||||||
|
|
||||||
|
if ($productDownload->is_shareable == 1)
|
||||||
|
$is_shareable = $this->l('Yes');
|
||||||
|
else
|
||||||
|
$is_shareable = $this->l('No');
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<tr'.($irow++ % 2 ? ' class="alt_row"' : '').($product_attribute['default_on'] ? ' style="background-color:#D1EAEF"' : '').'>
|
<tr'.($irow++ % 2 ? ' class="alt_row"' : '').($product_attribute['default_on'] ? ' style="background-color:#D1EAEF"' : '').'>
|
||||||
<td>'.stripslashes($list).'</td>
|
<td>'.stripslashes($list).'</td>
|
||||||
@@ -3590,12 +4070,29 @@ class AdminProducts extends AdminTab
|
|||||||
<td class="right">'.$product_attribute['reference'].'</td>
|
<td class="right">'.$product_attribute['reference'].'</td>
|
||||||
<td class="right">'.$product_attribute['ean13'].'</td>
|
<td class="right">'.$product_attribute['ean13'].'</td>
|
||||||
<td class="right">'.$product_attribute['upc'].'</td>
|
<td class="right">'.$product_attribute['upc'].'</td>
|
||||||
<td class="center">'.$product_attribute['quantity'].'</td>
|
<td class="center">'.$product_attribute['quantity'].'</td>';
|
||||||
<td class="center">
|
|
||||||
|
if ($id_product_download && !empty($productDownload->display_filename))
|
||||||
|
{
|
||||||
|
echo '<td class="right">'.$productDownload->getHtmlLink(false, true).'</td>
|
||||||
|
<td class="center">'.$productDownload->nb_downloadable.'</td>
|
||||||
|
<td class="center">'.$productDownload->nb_downloadable.'</td>
|
||||||
|
<td class="right">'.$is_shareable.'</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$exists_file = realpath(_PS_DOWNLOAD_DIR_).'/'.$productDownload->filename;
|
||||||
|
|
||||||
|
if ($productDownload->id && file_exists($exists_file))
|
||||||
|
$filename = $productDownload->filename;
|
||||||
|
else
|
||||||
|
$filename = '';
|
||||||
|
|
||||||
|
echo '<td class="center">
|
||||||
<a style="cursor: pointer;">
|
<a style="cursor: pointer;">
|
||||||
<img src="../img/admin/edit.gif" alt="'.$this->l('Modify this combination').'"
|
<img src="../img/admin/edit.gif" alt="'.$this->l('Modify this combination').'"
|
||||||
onclick="javascript:fillCombinaison(\''.$product_attribute['wholesale_price'].'\', \''.$product_attribute['price'].'\', \''.$product_attribute['weight'].'\', \''.$product_attribute['unit_impact'].'\', \''.$product_attribute['reference'].'\', \''.$product_attribute['supplier_reference'].'\', \''.$product_attribute['ean13'].'\',
|
onclick="javascript:fillCombinaison(\''.$product_attribute['wholesale_price'].'\', \''.$product_attribute['price'].'\', \''.$product_attribute['weight'].'\', \''.$product_attribute['unit_impact'].'\', \''.$product_attribute['reference'].'\', \''.$product_attribute['supplier_reference'].'\', \''.$product_attribute['ean13'].'\',
|
||||||
\''.$product_attribute['quantity'].'\', \''.($attrImage ? $attrImage->id : 0).'\', Array('.$jsList.'), \''.$id_product_attribute.'\', \''.$product_attribute['default_on'].'\', \''.$product_attribute['ecotax'].'\', \''.$product_attribute['location'].'\', \''.$product_attribute['upc'].'\', \''.$product_attribute['minimal_quantity'].'\', \''.pSQL($available_date).'\'); calcImpactPriceTI();" /></a>
|
\''.$product_attribute['quantity'].'\', \''.($attrImage ? $attrImage->id : 0).'\', Array('.$jsList.'), \''.$id_product_attribute.'\', \''.$product_attribute['default_on'].'\', \''.$product_attribute['ecotax'].'\', \''.$product_attribute['location'].'\', \''.$product_attribute['upc'].'\', \''.$product_attribute['minimal_quantity'].'\', \''.$available_date.'\',
|
||||||
|
\''.$productDownload->display_filename.'\', \''.$filename.'\', \''.$productDownload->nb_downloadable.'\', \''.$available_date_attribute.'\', \''.$productDownload->nb_days_accessible.'\', \''.$productDownload->is_shareable.'\'); calcImpactPriceTI();" /></a>
|
||||||
'.(!$product_attribute['default_on'] ? '<a href="'.self::$currentIndex.'&defaultProductAttribute&id_product_attribute='.$id_product_attribute.'&id_product='.$obj->id.'&'.(Tools::isSubmit('id_category') ? 'id_category='.(int)(Tools::getValue('id_category')).'&' : '&').'token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).$this->context->employee->id).'">
|
'.(!$product_attribute['default_on'] ? '<a href="'.self::$currentIndex.'&defaultProductAttribute&id_product_attribute='.$id_product_attribute.'&id_product='.$obj->id.'&'.(Tools::isSubmit('id_category') ? 'id_category='.(int)(Tools::getValue('id_category')).'&' : '&').'token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).$this->context->employee->id).'">
|
||||||
<img src="../img/admin/asterisk.gif" alt="'.$this->l('Make this the default combination').'" title="'.$this->l('Make this combination the default one').'"></a>' : '').'
|
<img src="../img/admin/asterisk.gif" alt="'.$this->l('Make this the default combination').'" title="'.$this->l('Make this combination the default one').'"></a>' : '').'
|
||||||
<a href="'.self::$currentIndex.'&deleteProductAttribute&id_product_attribute='.$id_product_attribute.'&id_product='.$obj->id.'&'.(Tools::isSubmit('id_category') ? 'id_category='.(int)(Tools::getValue('id_category')).'&' : '&').'token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$this->context->employee->id).'" onclick="return confirm(\''.$this->l('Are you sure?', __CLASS__, true, false).'\');">
|
<a href="'.self::$currentIndex.'&deleteProductAttribute&id_product_attribute='.$id_product_attribute.'&id_product='.$obj->id.'&'.(Tools::isSubmit('id_category') ? 'id_category='.(int)(Tools::getValue('id_category')).'&' : '&').'token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$this->context->employee->id).'" onclick="return confirm(\''.$this->l('Are you sure?', __CLASS__, true, false).'\');">
|
||||||
@@ -3991,5 +4488,4 @@ class AdminProducts extends AdminTab
|
|||||||
|
|
||||||
$this->displayErrors();
|
$this->displayErrors();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<?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: 6844 $
|
||||||
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||||
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
|
*/
|
||||||
|
|
||||||
|
define('_PS_ADMIN_DIR_', getcwd());
|
||||||
|
|
||||||
|
include(_PS_ADMIN_DIR_.'/../config/config.inc.php');
|
||||||
|
|
||||||
|
if (!isset(Context::getContext()->employee) || !Context::getContext()->employee->isLoggedBack())
|
||||||
|
die;
|
||||||
|
|
||||||
|
if (isset($_FILES['virtual_product_file_attribute']) && is_uploaded_file($_FILES['virtual_product_file_attribute']['tmp_name']) &&
|
||||||
|
(isset($_FILES['virtual_product_file_attribute']['error']) && !$_FILES['virtual_product_file_attribute']['error']) ||
|
||||||
|
(!empty($_FILES['virtual_product_file_attribute']['tmp_name']) && $_FILES['virtual_product_file_attribute']['tmp_name'] != 'none'))
|
||||||
|
{
|
||||||
|
$filename = $_FILES['virtual_product_file_attribute']['name'];
|
||||||
|
$file = $_FILES['virtual_product_file_attribute']['tmp_name'];
|
||||||
|
$newfilename = ProductDownload::getNewFilename();
|
||||||
|
|
||||||
|
if (!copy($file, _PS_DOWNLOAD_DIR_.$newfilename))
|
||||||
|
{
|
||||||
|
header('HTTP/1.1 500 Error');
|
||||||
|
echo '<return result="error" msg="No permissions to write in the download folder" filename="'.$filename.'" />';
|
||||||
|
}
|
||||||
|
@unlink($file);
|
||||||
|
|
||||||
|
header('HTTP/1.1 200 OK');
|
||||||
|
echo '<return result="success" msg="'.$newfilename.'" filename="'.$filename.'" />';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
header('HTTP/1.1 500 Error');
|
||||||
|
echo '<return result="error" msg="Unknown error" filename="'.ProductDownload::getNewFilename().'" />';
|
||||||
|
}
|
||||||
+17
-6
@@ -1530,28 +1530,39 @@ class CartCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public function isVirtualCart()
|
public function isVirtualCart()
|
||||||
{
|
{
|
||||||
|
$prod = array();
|
||||||
if (!ProductDownload::isFeatureActive())
|
if (!ProductDownload::isFeatureActive())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!isset(self::$_isVirtualCart[$this->id]))
|
if (!isset(self::$_isVirtualCart[$this->id]))
|
||||||
{
|
{
|
||||||
$products = $this->getProducts();
|
$products = $this->getProducts();
|
||||||
|
|
||||||
if (!sizeof($products))
|
if (!sizeof($products))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$list = '';
|
|
||||||
foreach ($products AS $product)
|
foreach ($products AS $product)
|
||||||
$list .= (int)($product['id_product']).',';
|
{
|
||||||
|
$prod[] = (int) $product['id_product'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$unique_product = array_unique($prod);
|
||||||
|
|
||||||
|
$list = '';
|
||||||
|
foreach ($unique_product AS $product)
|
||||||
|
{
|
||||||
|
$list .= (int)($product).',';
|
||||||
|
}
|
||||||
$list = rtrim($list, ',');
|
$list = rtrim($list, ',');
|
||||||
|
|
||||||
$n = (int)Db::getInstance()->getValue('
|
$n = (int)Db::getInstance()->getValue('
|
||||||
SELECT COUNT(`id_product_download`) n
|
SELECT COUNT(`id_product_download`) n
|
||||||
FROM `'._DB_PREFIX_.'product_download`
|
FROM `'._DB_PREFIX_.'product_download`
|
||||||
WHERE `id_product` IN ('.pSQL($list).') AND `active` = 1');
|
WHERE `id_product` IN ('.pSQL($list).')
|
||||||
|
AND `active` = 1');
|
||||||
|
|
||||||
self::$_isVirtualCart[$this->id] = ($n == sizeof($products));
|
self::$_isVirtualCart[$this->id] = ($n == sizeof($products));
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$_isVirtualCart[$this->id];
|
return self::$_isVirtualCart[$this->id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -1107,10 +1107,10 @@ class ProductCore extends ObjectModel
|
|||||||
$result = Db::getInstance()->Execute('
|
$result = Db::getInstance()->Execute('
|
||||||
DELETE FROM `'._DB_PREFIX_.'product_attribute_combination`
|
DELETE FROM `'._DB_PREFIX_.'product_attribute_combination`
|
||||||
WHERE `id_product_attribute` IN (SELECT `id_product_attribute` FROM `'._DB_PREFIX_.'product_attribute` WHERE `id_product` = '.(int)($this->id).')');
|
WHERE `id_product_attribute` IN (SELECT `id_product_attribute` FROM `'._DB_PREFIX_.'product_attribute` WHERE `id_product` = '.(int)($this->id).')');
|
||||||
|
|
||||||
$result2 = Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'product_attribute` WHERE `id_product` = '.(int)($this->id));
|
$result2 = Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'product_attribute` WHERE `id_product` = '.(int)($this->id));
|
||||||
|
$result3 = Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'product_download` WHERE `id_product` = '.(int)($this->id));
|
||||||
|
|
||||||
return ($result & $result2);
|
return ($result & $result2 & $result3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2658,12 +2658,12 @@ class ProductCore extends ObjectModel
|
|||||||
|
|
||||||
public static function duplicateDownload($id_product_old, $id_product_new)
|
public static function duplicateDownload($id_product_old, $id_product_new)
|
||||||
{
|
{
|
||||||
$resource = Db::getInstance()->ExecuteS('SELECT `display_filename`, `physically_filename`, `date_deposit`, `date_expiration`, `nb_days_accessible`, `nb_downloadable`, `active` FROM `'._DB_PREFIX_.'product_download` WHERE `id_product` = '.(int)($id_product_old));
|
$resource = Db::getInstance()->ExecuteS('SELECT `display_filename`, `filename`, `date_add`, `date_expiration`, `nb_days_accessible`, `nb_downloadable`, `active`, `is_shareable` FROM `'._DB_PREFIX_.'product_download` WHERE `id_product` = '.(int)($id_product_old));
|
||||||
if (!Db::getInstance()->NumRows())
|
if (!Db::getInstance()->NumRows())
|
||||||
return true;
|
return true;
|
||||||
$query = 'INSERT INTO `'._DB_PREFIX_.'product_download` (`id_product`, `display_filename`, `physically_filename`, `date_deposit`, `date_expiration`, `nb_days_accessible`, `nb_downloadable`, `active`) VALUES';
|
$query = 'INSERT INTO `'._DB_PREFIX_.'product_download` (`id_product`, `display_filename`, `filename`, `date_add`, `date_expiration`, `nb_days_accessible`, `nb_downloadable`, `active`, `is_shareable`) VALUES';
|
||||||
while ($row = Db::getInstance()->nextRow($resource))
|
while ($row = Db::getInstance()->nextRow($resource))
|
||||||
$query .= ' ('.(int)($id_product_new).', \''.pSQL($row['display_filename']).'\', \''.pSQL($row['physically_filename']).'\', \''.pSQL($row['date_deposit']).'\', \''.pSQL($row['date_expiration']).'\', '.(int)($row['nb_days_accessible']).', '.(int)($row['nb_downloadable']).', '.(int)($row['active']).'),';
|
$query .= ' ('.(int)($id_product_new).', \''.pSQL($row['display_filename']).'\', \''.pSQL($row['filename']).'\', \''.pSQL($row['date_add']).'\', \''.pSQL($row['date_expiration']).'\', '.(int)($row['nb_days_accessible']).', '.(int)($row['nb_downloadable']).', '.(int)($row['active']).'), '.(int)($row['is_shareable']).'),';
|
||||||
$query = rtrim($query, ',');
|
$query = rtrim($query, ',');
|
||||||
return Db::getInstance()->Execute($query);
|
return Db::getInstance()->Execute($query);
|
||||||
}
|
}
|
||||||
|
|||||||
+88
-29
@@ -29,19 +29,22 @@ class ProductDownloadCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
/** @var integer Product id which download belongs */
|
/** @var integer Product id which download belongs */
|
||||||
public $id_product;
|
public $id_product;
|
||||||
|
|
||||||
|
/** @var integer Attribute Product id which download belongs */
|
||||||
|
public $id_product_attribute;
|
||||||
|
|
||||||
/** @var string DisplayFilename the name which appear */
|
/** @var string DisplayFilename the name which appear */
|
||||||
public $display_filename;
|
public $display_filename;
|
||||||
|
|
||||||
/** @var string PhysicallyFilename the name of the file on hard disk */
|
/** @var string PhysicallyFilename the name of the file on hard disk */
|
||||||
public $physically_filename;
|
public $filename;
|
||||||
|
|
||||||
/** @var string DateDeposit when the file is upload */
|
/** @var string DateDeposit when the file is upload */
|
||||||
public $date_deposit;
|
public $date_add;
|
||||||
|
|
||||||
/** @var string DateExpiration deadline of the file */
|
/** @var string DateExpiration deadline of the file */
|
||||||
public $date_expiration;
|
public $date_expiration;
|
||||||
|
|
||||||
/** @var string NbDaysAccessible how many days the customer can access to file */
|
/** @var string NbDaysAccessible how many days the customer can access to file */
|
||||||
public $nb_days_accessible;
|
public $nb_days_accessible;
|
||||||
|
|
||||||
@@ -50,31 +53,37 @@ class ProductDownloadCore extends ObjectModel
|
|||||||
|
|
||||||
/** @var boolean Active if file is accessible or not */
|
/** @var boolean Active if file is accessible or not */
|
||||||
public $active = 1;
|
public $active = 1;
|
||||||
|
|
||||||
|
/** @var boolean is_shareable indicates whether the product can be shared */
|
||||||
|
public $is_shareable = 0;
|
||||||
|
|
||||||
protected static $_productIds = array();
|
protected static $_productIds = array();
|
||||||
|
|
||||||
protected $fieldsRequired = array(
|
protected $fieldsRequired = array(
|
||||||
'id_product',
|
'id_product'
|
||||||
'display_filename'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $fieldsSize = array(
|
protected $fieldsSize = array(
|
||||||
'display_filename' => 255,
|
'display_filename' => 255,
|
||||||
'physically_filename' => 255,
|
'filename' => 255,
|
||||||
'date_deposit' => 20,
|
'date_add' => 20,
|
||||||
'date_expiration' => 20,
|
'date_expiration' => 20,
|
||||||
'nb_days_accessible' => 10,
|
'nb_days_accessible' => 10,
|
||||||
'nb_downloadable' => 10,
|
'nb_downloadable' => 10,
|
||||||
'active' => 1
|
'active' => 1,
|
||||||
|
'is_shareable' => 1
|
||||||
);
|
);
|
||||||
protected $fieldsValidate = array(
|
protected $fieldsValidate = array(
|
||||||
'id_product' => 'isUnsignedId',
|
'id_product' => 'isUnsignedId',
|
||||||
|
'id_product_attribute ' => 'isUnsignedId',
|
||||||
'display_filename' => 'isGenericName',
|
'display_filename' => 'isGenericName',
|
||||||
'physically_filename' => 'isSha1',
|
'filename' => 'isSha1',
|
||||||
'date_deposit' => 'isDate',
|
'date_add' => 'isDate',
|
||||||
'date_expiration' => 'isDate',
|
'date_expiration' => 'isDate',
|
||||||
'nb_days_accessible' => 'isUnsignedInt',
|
'nb_days_accessible' => 'isUnsignedInt',
|
||||||
'nb_downloadable' => 'isUnsignedInt',
|
'nb_downloadable' => 'isUnsignedInt',
|
||||||
'active' => 'isUnsignedInt'
|
'active' => 'isUnsignedInt',
|
||||||
|
'is_shareable' => 'isUnsignedInt'
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $table = 'product_download';
|
protected $table = 'product_download';
|
||||||
@@ -129,13 +138,15 @@ class ProductDownloadCore extends ObjectModel
|
|||||||
$this->date_expiration = '0000-00-00 00:00:00';
|
$this->date_expiration = '0000-00-00 00:00:00';
|
||||||
|
|
||||||
$fields['id_product'] = (int)($this->id_product);
|
$fields['id_product'] = (int)($this->id_product);
|
||||||
|
$fields['id_product_attribute'] = pSQL($this->id_product_attribute);
|
||||||
$fields['display_filename'] = pSQL($this->display_filename);
|
$fields['display_filename'] = pSQL($this->display_filename);
|
||||||
$fields['physically_filename'] = pSQL($this->physically_filename);
|
$fields['filename'] = pSQL($this->filename);
|
||||||
$fields['date_deposit'] = pSQL($this->date_deposit);
|
$fields['date_add'] = pSQL($this->date_add);
|
||||||
$fields['date_expiration'] = pSQL($this->date_expiration);
|
$fields['date_expiration'] = pSQL($this->date_expiration);
|
||||||
$fields['nb_days_accessible'] = (int)($this->nb_days_accessible);
|
$fields['nb_days_accessible'] = (int)($this->nb_days_accessible);
|
||||||
$fields['nb_downloadable'] = (int)($this->nb_downloadable);
|
$fields['nb_downloadable'] = (int)($this->nb_downloadable);
|
||||||
$fields['active'] = (int)($this->active);
|
$fields['active'] = (int)($this->active);
|
||||||
|
$fields['is_shareable'] = (int)($this->is_shareable);
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +159,7 @@ class ProductDownloadCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
if (!$this->checkFile())
|
if (!$this->checkFile())
|
||||||
return false;
|
return false;
|
||||||
return unlink(_PS_DOWNLOAD_DIR_.$this->physically_filename);
|
return unlink(_PS_DOWNLOAD_DIR_.$this->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,8 +169,8 @@ class ProductDownloadCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public function checkFile()
|
public function checkFile()
|
||||||
{
|
{
|
||||||
if (!$this->physically_filename) return false;
|
if (!$this->filename) return false;
|
||||||
return file_exists(_PS_DOWNLOAD_DIR_.$this->physically_filename);
|
return file_exists(_PS_DOWNLOAD_DIR_.$this->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -182,18 +193,68 @@ class ProductDownloadCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
if (!self::isFeatureActive())
|
if (!self::isFeatureActive())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (array_key_exists($id_product, self::$_productIds))
|
if (array_key_exists($id_product, self::$_productIds))
|
||||||
return self::$_productIds[$id_product];
|
return self::$_productIds[$id_product];
|
||||||
|
|
||||||
self::$_productIds[$id_product] = (int)Db::getInstance()->getValue('
|
self::$_productIds[$id_product] = (int)Db::getInstance()->getValue('
|
||||||
SELECT `id_product_download`
|
SELECT `id_product_download`
|
||||||
FROM `'._DB_PREFIX_.'product_download`
|
FROM `'._DB_PREFIX_.'product_download`
|
||||||
WHERE `id_product` = '.(int)$id_product.' AND `active` = 1');
|
WHERE `id_product` = '.(int)$id_product.' AND `active` = 1');
|
||||||
|
|
||||||
return self::$_productIds[$id_product];
|
return self::$_productIds[$id_product];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the id_product_download from an id_product
|
||||||
|
* @since 1.5.0.1
|
||||||
|
* @param int $id_product Product the id
|
||||||
|
* @return integer Product the id for this virtual product
|
||||||
|
*/
|
||||||
|
public static function getIdFromIdAttibute($id_product_attribute)
|
||||||
|
{
|
||||||
|
if (!self::isFeatureActive())
|
||||||
|
return false;
|
||||||
|
if (array_key_exists($id_product_attribute, self::$_productIds))
|
||||||
|
return self::$_productIds[$id_product];
|
||||||
|
self::$_productIds[$id_product_attribute] = (int)Db::getInstance()->getValue('
|
||||||
|
SELECT `id_product_download`
|
||||||
|
FROM `'._DB_PREFIX_.'product_download`
|
||||||
|
WHERE `id_product_attribute` = '.(int)$id_product_attribute.' AND `active` = 1');
|
||||||
|
return self::$_productIds[$id_product_attribute];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the display filename from a physical filename
|
||||||
|
*
|
||||||
|
* @since 1.5.0.1
|
||||||
|
*
|
||||||
|
* @param string $filename Filename physically
|
||||||
|
* @return integer Product the id for this virtual product
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function getAttributeFromIdProduct($id_product)
|
||||||
|
{
|
||||||
|
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
||||||
|
SELECT `id_product_download`
|
||||||
|
FROM `'._DB_PREFIX_.'product_download`
|
||||||
|
WHERE `id_product` = '.(int)$id_product.' AND `active` = 1');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the display filename from a physical filename
|
||||||
|
*
|
||||||
|
* @since 1.5.0.1
|
||||||
|
*
|
||||||
|
* @param string $filename Filename physically
|
||||||
|
* @return integer Product the id for this virtual product
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function getIdFromFilename($filename)
|
||||||
|
{
|
||||||
|
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||||
|
SELECT `id_product_download`
|
||||||
|
FROM `'._DB_PREFIX_.'product_download`
|
||||||
|
WHERE `filename` = \''.pSQL($filename).'\'');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the filename from an id_product
|
* Return the filename from an id_product
|
||||||
*
|
*
|
||||||
@@ -203,7 +264,7 @@ class ProductDownloadCore extends ObjectModel
|
|||||||
public static function getFilenameFromIdProduct($id_product)
|
public static function getFilenameFromIdProduct($id_product)
|
||||||
{
|
{
|
||||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||||
SELECT `physically_filename`
|
SELECT `filename`
|
||||||
FROM `'._DB_PREFIX_.'product_download`
|
FROM `'._DB_PREFIX_.'product_download`
|
||||||
WHERE `id_product` = '.(int)$id_product.'
|
WHERE `id_product` = '.(int)$id_product.'
|
||||||
AND `active` = 1');
|
AND `active` = 1');
|
||||||
@@ -212,15 +273,15 @@ class ProductDownloadCore extends ObjectModel
|
|||||||
/**
|
/**
|
||||||
* Return the display filename from a physical filename
|
* Return the display filename from a physical filename
|
||||||
*
|
*
|
||||||
* @param string $physically_filename Filename physically
|
* @param string $filename Filename physically
|
||||||
* @return string Filename the display filename for this virtual product
|
* @return string Filename the display filename for this virtual product
|
||||||
*/
|
*/
|
||||||
public static function getFilenameFromFilename($physically_filename)
|
public static function getFilenameFromFilename($filename)
|
||||||
{
|
{
|
||||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||||
SELECT `display_filename`
|
SELECT `display_filename`
|
||||||
FROM `'._DB_PREFIX_.'product_download`
|
FROM `'._DB_PREFIX_.'product_download`
|
||||||
WHERE `physically_filename` = \''.pSQL($physically_filename).'\'');
|
WHERE `filename` = \''.pSQL($filename).'\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -233,9 +294,9 @@ class ProductDownloadCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public function getTextLink($admin = true, $hash = false)
|
public function getTextLink($admin = true, $hash = false)
|
||||||
{
|
{
|
||||||
$key = $this->physically_filename . '-' . ($hash ? $hash : 'orderdetail');
|
$key = $this->filename . '-' . ($hash ? $hash : 'orderdetail');
|
||||||
$link = ($admin) ? 'get-file-admin.php?' : Tools::getHttpHost(true, true).'index.php?controller=get-file&';
|
$link = ($admin) ? 'get-file-admin.php?' : Tools::getHttpHost(true, true).'index.php?controller=get-file&';
|
||||||
$link .= ($admin) ? 'file='.$this->physically_filename : 'key='.$key;
|
$link .= ($admin) ? 'file='.$this->filename : 'key='.$key;
|
||||||
return $link;
|
return $link;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,6 +363,4 @@ class ProductDownloadCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
return Configuration::get('PS_VIRTUAL_PROD_FEATURE_ACTIVE');
|
return Configuration::get('PS_VIRTUAL_PROD_FEATURE_ACTIVE');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ class GetFileControllerCore extends FrontController
|
|||||||
/* Access is authorized -> increment download value for the customer */
|
/* Access is authorized -> increment download value for the customer */
|
||||||
OrderDetail::incrementDownload($info['id_order_detail']);
|
OrderDetail::incrementDownload($info['id_order_detail']);
|
||||||
|
|
||||||
$file = _PS_DOWNLOAD_DIR_.$info['physically_filename'];
|
$file = _PS_DOWNLOAD_DIR_.$info['filename'];
|
||||||
$filename = $info['display_filename'];
|
$filename = $info['display_filename'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -412,7 +412,7 @@ select optgroup option {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#content .alert {
|
#content .alert {
|
||||||
width: 500px;
|
width: auto;
|
||||||
margin: 0 0 15px 0;
|
margin: 0 0 15px 0;
|
||||||
padding: 10px 15px;
|
padding: 10px 15px;
|
||||||
border-top: 1px solid #DF7B7B;
|
border-top: 1px solid #DF7B7B;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ function latin1_database_to_utf8()
|
|||||||
array('name' => 'order_state_lang', 'id' => 'id_order_state', 'lang' => true, 'fields' => array('name', 'template')),
|
array('name' => 'order_state_lang', 'id' => 'id_order_state', 'lang' => true, 'fields' => array('name', 'template')),
|
||||||
array('name' => 'product', 'id' => 'id_product', 'fields' => array('ean13', 'reference')),
|
array('name' => 'product', 'id' => 'id_product', 'fields' => array('ean13', 'reference')),
|
||||||
array('name' => 'product_attribute', 'id' => 'id_product_attribute', 'fields' => array('reference', 'ean13')),
|
array('name' => 'product_attribute', 'id' => 'id_product_attribute', 'fields' => array('reference', 'ean13')),
|
||||||
array('name' => 'product_download', 'id' => 'id_product_download', 'fields' => array('display_filename', 'physically_filename')),
|
array('name' => 'product_download', 'id' => 'id_product_download', 'fields' => array('display_filename', 'filename')),
|
||||||
array('name' => 'product_lang', 'id' => 'id_product', 'lang' => true, 'fields' => array('description', 'description_short', 'link_rewrite', 'meta_description', 'meta_keywords', 'meta_title', 'name', 'availability')),
|
array('name' => 'product_lang', 'id' => 'id_product', 'lang' => true, 'fields' => array('description', 'description_short', 'link_rewrite', 'meta_description', 'meta_keywords', 'meta_title', 'name', 'availability')),
|
||||||
array('name' => 'profile_lang', 'id' => 'id_profile', 'lang' => true, 'fields' => array('name')),
|
array('name' => 'profile_lang', 'id' => 'id_profile', 'lang' => true, 'fields' => array('name')),
|
||||||
array('name' => 'quick_access', 'id' => 'id_quick_access', 'fields' => array('link')),
|
array('name' => 'quick_access', 'id' => 'id_quick_access', 'fields' => array('link')),
|
||||||
|
|||||||
+4
-1
@@ -403,7 +403,10 @@ if (helpboxes)
|
|||||||
if ($('input'))
|
if ($('input'))
|
||||||
{
|
{
|
||||||
//Display by rollover
|
//Display by rollover
|
||||||
$('input').mouseover(function() { $(this).parent().find('.hint:first').css('display', 'block'); });
|
$('input').mouseover(function() {
|
||||||
|
console.log($(this).parent());
|
||||||
|
$(this).parent().find('.hint:first').css('display', 'block');
|
||||||
|
});
|
||||||
$('input').mouseout(function() { $(this).parent().find('.hint:first').css('display', 'none'); });
|
$('input').mouseout(function() { $(this).parent().find('.hint:first').css('display', 'none'); });
|
||||||
|
|
||||||
//display when you press the tab key
|
//display when you press the tab key
|
||||||
|
|||||||
+21
-1
@@ -26,9 +26,14 @@
|
|||||||
|
|
||||||
var storeUsedGroups = {};
|
var storeUsedGroups = {};
|
||||||
|
|
||||||
function fillCombinaison(wholesale_price, price_impact, weight_impact, unit_impact, reference, supplier_reference, ean, quantity, image, old_attr, id_product_attribute, default_attribute, eco_tax, location, upc, minimal_quantity, available_date)
|
function fillCombinaison(wholesale_price, price_impact, weight_impact, unit_impact, reference, supplier_reference,
|
||||||
|
ean, quantity, image, old_attr, id_product_attribute, default_attribute, eco_tax, location, upc, minimal_quantity, available_date,
|
||||||
|
virtual_product_name_attribute, virtual_product_filename_attribute, virtual_product_nb_downloable, virtual_product_expiration_date_attribute,
|
||||||
|
virtual_product_nb_days, is_shareable)
|
||||||
{
|
{
|
||||||
|
var link = '';
|
||||||
init_elems();
|
init_elems();
|
||||||
|
$("#virtual_good_attributes").show();
|
||||||
$('#stock_mvt_attribute').show();
|
$('#stock_mvt_attribute').show();
|
||||||
$('#initial_stock_attribute').hide();
|
$('#initial_stock_attribute').hide();
|
||||||
$('#attribute_quantity').html(quantity);
|
$('#attribute_quantity').html(quantity);
|
||||||
@@ -40,6 +45,13 @@ function fillCombinaison(wholesale_price, price_impact, weight_impact, unit_impa
|
|||||||
getE('available_date').value = '0000-00-00';
|
getE('available_date').value = '0000-00-00';
|
||||||
getE('minimal_quantity').value = minimal_quantity;
|
getE('minimal_quantity').value = minimal_quantity;
|
||||||
getE('attribute_reference').value = reference;
|
getE('attribute_reference').value = reference;
|
||||||
|
|
||||||
|
getE('virtual_product_name_attribute').value = virtual_product_name_attribute;
|
||||||
|
getE('virtual_product_nb_downloable_attribute').value = virtual_product_nb_downloable;
|
||||||
|
getE('virtual_product_expiration_date_attribute').value = virtual_product_nb_downloable;
|
||||||
|
getE('virtual_product_expiration_date_attribute').value = virtual_product_expiration_date_attribute;
|
||||||
|
getE('virtual_product_nb_days_attribute').value = virtual_product_nb_days;
|
||||||
|
|
||||||
getE('attribute_supplier_reference').value = supplier_reference;
|
getE('attribute_supplier_reference').value = supplier_reference;
|
||||||
getE('attribute_ean13').value = ean;
|
getE('attribute_ean13').value = ean;
|
||||||
getE('attribute_upc').value = upc;
|
getE('attribute_upc').value = upc;
|
||||||
@@ -102,6 +114,14 @@ function fillCombinaison(wholesale_price, price_impact, weight_impact, unit_impa
|
|||||||
getE('attribute_unit_impact').selectedIndex = 1;
|
getE('attribute_unit_impact').selectedIndex = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_shareable > 0)
|
||||||
|
$("#virtual_product_is_shareable_attribute").attr("checked", "checked");
|
||||||
|
|
||||||
|
if (id_product_attribute != '' && virtual_product_filename_attribute != '')
|
||||||
|
$("#gethtmlink").show();
|
||||||
|
link = $("#make_downloadable_product_attribute").attr('href');
|
||||||
|
$("#make_downloadable_product_attribute").attr('href', link+"&id_product_attribute="+id_product_attribute);
|
||||||
|
|
||||||
/* Reset all combination images */
|
/* Reset all combination images */
|
||||||
combinationImages = $('#id_image_attr').find("input[id^=id_image_attr_]");
|
combinationImages = $('#id_image_attr').find("input[id^=id_image_attr_]");
|
||||||
combinationImages.each(function() {
|
combinationImages.each(function() {
|
||||||
|
|||||||
Vendored
+193
-52
@@ -1,53 +1,194 @@
|
|||||||
/*
|
jQuery.extend({
|
||||||
* this file come from:
|
createUploadIframe: function(id, uri)
|
||||||
* http://www.phpletter.com/Demo/AjaxFileUpload-Demo/
|
{
|
||||||
* v 1.0
|
//create frame
|
||||||
*/
|
var frameId = 'jUploadFrame' + id;
|
||||||
|
var iframeHtml = '<iframe id="' + frameId + '" name="' + frameId + '" style="position:absolute; top:-9999px; left:-9999px"';
|
||||||
|
if(window.ActiveXObject)
|
||||||
|
{
|
||||||
|
if(typeof uri== 'boolean'){
|
||||||
|
iframeHtml += ' src="' + 'javascript:false' + '"';
|
||||||
|
|
||||||
jQuery.extend({createUploadIframe:function(id,uri)
|
}
|
||||||
{var frameId='jUploadFrame'+id;if(window.ActiveXObject){var io=document.createElement('<iframe id="'+frameId+'" name="'+frameId+'" />');if(typeof uri=='boolean'){io.src='javascript:false';}
|
else if(typeof uri== 'string'){
|
||||||
else if(typeof uri=='string'){io.src=uri;}}
|
iframeHtml += ' src="' + uri + '"';
|
||||||
else{var io=document.createElement('iframe');io.id=frameId;io.name=frameId;}
|
|
||||||
io.style.position='absolute';io.style.top='-1000px';io.style.left='-1000px';document.body.appendChild(io);return io},createUploadForm:function(id,fileElementId)
|
}
|
||||||
{var formId='jUploadForm'+id;var fileId='jUploadFile'+id;var form=$('<form action="" method="POST" name="'+formId+'" id="'+formId+'" enctype="multipart/form-data"></form>');var oldElement=$('#'+fileElementId);var newElement=$(oldElement).clone();$(oldElement).attr('id',fileId);$(oldElement).before(newElement);$(oldElement).appendTo(form);$(form).css('position','absolute');$(form).css('top','-1200px');$(form).css('left','-1200px');$(form).appendTo('body');return form;},ajaxFileUpload:function(s){s=jQuery.extend({},jQuery.ajaxSettings,s);var id=new Date().getTime()
|
}
|
||||||
var form=jQuery.createUploadForm(id,s.fileElementId);var io=jQuery.createUploadIframe(id,s.secureuri);var frameId='jUploadFrame'+id;var formId='jUploadForm'+id;if(s.global&&!jQuery.active++)
|
iframeHtml += ' />';
|
||||||
{jQuery.event.trigger("ajaxStart");}
|
jQuery(iframeHtml).appendTo(document.body);
|
||||||
var requestDone=false;var xml={}
|
|
||||||
if(s.global)
|
return jQuery('#' + frameId).get(0);
|
||||||
jQuery.event.trigger("ajaxSend",[xml,s]);var uploadCallback=function(isTimeout)
|
},
|
||||||
{var io=document.getElementById(frameId);try
|
createUploadForm: function(id, fileElementId, data)
|
||||||
{if(io.contentWindow)
|
{
|
||||||
{xml.responseText=io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;xml.responseXML=io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;}else if(io.contentDocument)
|
//create form
|
||||||
{xml.responseText=io.contentDocument.document.body?io.contentDocument.document.body.innerHTML:null;xml.responseXML=io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocument:io.contentDocument.document;}}catch(e)
|
var formId = 'jUploadForm' + id;
|
||||||
{jQuery.handleError(s,xml,null,e);}
|
var fileId = 'jUploadFile' + id;
|
||||||
if(xml||isTimeout=="timeout")
|
var form = jQuery('<form action="" method="POST" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>');
|
||||||
{requestDone=true;var status;try{status=isTimeout!="timeout"?"success":"error";if(status!="error")
|
if(data)
|
||||||
{var data=jQuery.uploadHttpData(xml,s.dataType);if(s.success)
|
{
|
||||||
s.success(data,status);if(s.global)
|
for(var i in data)
|
||||||
jQuery.event.trigger("ajaxSuccess",[xml,s]);}else
|
{
|
||||||
jQuery.handleError(s,xml,status);}catch(e)
|
jQuery('<input type="hidden" name="' + i + '" value="' + data[i] + '" />').appendTo(form);
|
||||||
{status="error";jQuery.handleError(s,xml,status,e);}
|
}
|
||||||
if(s.global)
|
}
|
||||||
jQuery.event.trigger("ajaxComplete",[xml,s]);if(s.global&&!--jQuery.active)
|
var oldElement = jQuery('#' + fileElementId);
|
||||||
jQuery.event.trigger("ajaxStop");if(s.complete)
|
var newElement = jQuery(oldElement).clone();
|
||||||
s.complete(xml,status);jQuery(io).unbind()
|
jQuery(oldElement).attr('id', fileId);
|
||||||
setTimeout(function()
|
jQuery(oldElement).before(newElement);
|
||||||
{try
|
jQuery(oldElement).appendTo(form);
|
||||||
{$(io).remove();$(form).remove();}catch(e)
|
|
||||||
{jQuery.handleError(s,xml,null,e);}},100)
|
|
||||||
xml=null}}
|
|
||||||
if(s.timeout>0)
|
//set attributes
|
||||||
{setTimeout(function(){if(!requestDone)uploadCallback("timeout");},s.timeout);}
|
jQuery(form).css('position', 'absolute');
|
||||||
try
|
jQuery(form).css('top', '-1200px');
|
||||||
{var form=$('#'+formId);$(form).attr('action',s.url);$(form).attr('method','POST');$(form).attr('target',frameId);if(form.encoding)
|
jQuery(form).css('left', '-1200px');
|
||||||
{form.encoding='multipart/form-data';}
|
jQuery(form).appendTo('body');
|
||||||
else
|
return form;
|
||||||
{form.enctype='multipart/form-data';}
|
},
|
||||||
$(form).submit();}catch(e)
|
|
||||||
{jQuery.handleError(s,xml,null,e);}
|
ajaxFileUpload: function(s) {
|
||||||
if(window.attachEvent){document.getElementById(frameId).attachEvent('onload',uploadCallback);}
|
// TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
|
||||||
else{document.getElementById(frameId).addEventListener('load',uploadCallback,false);}
|
s = jQuery.extend({}, jQuery.ajaxSettings, s);
|
||||||
return{abort:function(){}};},uploadHttpData:function(r,type){var data=!type;data=type=="xml"||data?r.responseXML:r.responseText;if(type=="script")
|
var id = new Date().getTime()
|
||||||
jQuery.globalEval(data);if(type=="json")
|
var form = jQuery.createUploadForm(id, s.fileElementId, (typeof(s.data)=='undefined'?false:s.data));
|
||||||
eval("data = "+data);if(type=="html")
|
var io = jQuery.createUploadIframe(id, s.secureuri);
|
||||||
jQuery("<div>").html(data).evalScripts();return data;}})
|
var frameId = 'jUploadFrame' + id;
|
||||||
|
var formId = 'jUploadForm' + id;
|
||||||
|
// Watch for a new set of requests
|
||||||
|
if ( s.global && ! jQuery.active++ )
|
||||||
|
{
|
||||||
|
jQuery.event.trigger( "ajaxStart" );
|
||||||
|
}
|
||||||
|
var requestDone = false;
|
||||||
|
// Create the request object
|
||||||
|
var xml = {}
|
||||||
|
if ( s.global )
|
||||||
|
jQuery.event.trigger("ajaxSend", [xml, s]);
|
||||||
|
// Wait for a response to come back
|
||||||
|
var uploadCallback = function(isTimeout)
|
||||||
|
{
|
||||||
|
var io = document.getElementById(frameId);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(io.contentWindow)
|
||||||
|
{
|
||||||
|
xml.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
|
||||||
|
xml.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
|
||||||
|
|
||||||
|
}else if(io.contentDocument)
|
||||||
|
{
|
||||||
|
xml.responseText = io.contentDocument.document.body?io.contentDocument.document.body.innerHTML:null;
|
||||||
|
xml.responseXML = io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocument:io.contentDocument.document;
|
||||||
|
}
|
||||||
|
}catch(e)
|
||||||
|
{
|
||||||
|
jQuery.handleError(s, xml, null, e);
|
||||||
|
}
|
||||||
|
if ( xml || isTimeout == "timeout")
|
||||||
|
{
|
||||||
|
requestDone = true;
|
||||||
|
var status;
|
||||||
|
try {
|
||||||
|
status = isTimeout != "timeout" ? "success" : "error";
|
||||||
|
// Make sure that the request was successful or notmodified
|
||||||
|
if ( status != "error" )
|
||||||
|
{
|
||||||
|
// process the data (runs the xml through httpData regardless of callback)
|
||||||
|
var data = jQuery.uploadHttpData( xml, s.dataType );
|
||||||
|
// If a local callback was specified, fire it and pass it the data
|
||||||
|
if ( s.success )
|
||||||
|
s.success( data, status );
|
||||||
|
|
||||||
|
// Fire the global callback
|
||||||
|
if( s.global )
|
||||||
|
jQuery.event.trigger( "ajaxSuccess", [xml, s] );
|
||||||
|
} else
|
||||||
|
jQuery.handleError(s, xml, status);
|
||||||
|
} catch(e)
|
||||||
|
{
|
||||||
|
status = "error";
|
||||||
|
jQuery.handleError(s, xml, status, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The request was completed
|
||||||
|
if( s.global )
|
||||||
|
jQuery.event.trigger( "ajaxComplete", [xml, s] );
|
||||||
|
|
||||||
|
// Handle the global AJAX counter
|
||||||
|
if ( s.global && ! --jQuery.active )
|
||||||
|
jQuery.event.trigger( "ajaxStop" );
|
||||||
|
|
||||||
|
// Process result
|
||||||
|
if ( s.complete )
|
||||||
|
s.complete(xml, status);
|
||||||
|
|
||||||
|
jQuery(io).unbind()
|
||||||
|
|
||||||
|
setTimeout(function()
|
||||||
|
{ try
|
||||||
|
{
|
||||||
|
jQuery(io).remove();
|
||||||
|
jQuery(form).remove();
|
||||||
|
|
||||||
|
} catch(e)
|
||||||
|
{
|
||||||
|
jQuery.handleError(s, xml, null, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}, 100)
|
||||||
|
xml = null
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Timeout checker
|
||||||
|
if ( s.timeout > 0 )
|
||||||
|
{
|
||||||
|
setTimeout(function(){
|
||||||
|
// Check to see if the request is still happening
|
||||||
|
if( !requestDone ) uploadCallback( "timeout" );
|
||||||
|
}, s.timeout);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
var form = jQuery('#' + formId);
|
||||||
|
jQuery(form).attr('action', s.url);
|
||||||
|
jQuery(form).attr('method', 'POST');
|
||||||
|
jQuery(form).attr('target', frameId);
|
||||||
|
if(form.encoding)
|
||||||
|
{
|
||||||
|
jQuery(form).attr('encoding', 'multipart/form-data');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jQuery(form).attr('enctype', 'multipart/form-data');
|
||||||
|
}
|
||||||
|
jQuery(form).submit();
|
||||||
|
|
||||||
|
} catch(e)
|
||||||
|
{
|
||||||
|
jQuery.handleError(s, xml, null, e);
|
||||||
|
}
|
||||||
|
jQuery('#' + frameId).load(uploadCallback );
|
||||||
|
return {abort: function () {}};
|
||||||
|
},
|
||||||
|
|
||||||
|
uploadHttpData: function( r, type ) {
|
||||||
|
var data = !type;
|
||||||
|
data = type == "xml" || data ? r.responseXML : r.responseText;
|
||||||
|
// If the type is "script", eval it in global context
|
||||||
|
if ( type == "script" )
|
||||||
|
jQuery.globalEval( data );
|
||||||
|
// Get the JavaScript object, if JSON is used.
|
||||||
|
if ( type == "json" )
|
||||||
|
eval( "data = " + data );
|
||||||
|
// evaluate scripts within html
|
||||||
|
if ( type == "html" )
|
||||||
|
jQuery("<div>").html(data).evalScripts();
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user