//module reinsurance is now multi-shop and multi-lang
@@ -28,6 +28,8 @@
|
|||||||
if (!defined('_CAN_LOAD_FILES_'))
|
if (!defined('_CAN_LOAD_FILES_'))
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
include_once _PS_MODULE_DIR_.'blockreinsurance/reinsuranceClass.php';
|
||||||
|
|
||||||
class Blockreinsurance extends Module
|
class Blockreinsurance extends Module
|
||||||
{
|
{
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@@ -37,43 +39,98 @@ class Blockreinsurance extends Module
|
|||||||
$this->tab = 'front_office_features';
|
$this->tab = 'front_office_features';
|
||||||
else
|
else
|
||||||
$this->tab = 'Blocks';
|
$this->tab = 'Blocks';
|
||||||
$this->version = '1.0';
|
$this->version = '2.0';
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->displayName = $this->l('Bloc reinsurance');
|
$this->displayName = $this->l('Bloc reinsurance');
|
||||||
$this->description = $this->l('Add a block to display more infos to reassure your customers');
|
$this->description = $this->l('Add a block to display more infos to reassure your customers');
|
||||||
|
|
||||||
|
$this->fields_list = array(
|
||||||
|
'id_reinsurance' => array(
|
||||||
|
'title' => $this->l('Id'),
|
||||||
|
'width' => 120,
|
||||||
|
'type' => 'text',
|
||||||
|
),
|
||||||
|
'text' => array(
|
||||||
|
'title' => $this->l('Text'),
|
||||||
|
'width' => 140,
|
||||||
|
'type' => 'text',
|
||||||
|
'filter_key' => 'a!lastname'
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Shop::isFeatureActive())
|
||||||
|
$this->fields_list['id_shop'] = array('title' => $this->l('ID Shop'), 'align' => 'center', 'width' => 25, 'type' => 'int');
|
||||||
|
|
||||||
|
$this->fields_form[0]['form'] = array(
|
||||||
|
'legend' => array(
|
||||||
|
'title' => $this->l('Reinsurance new block'),
|
||||||
|
),
|
||||||
|
'input' => array(
|
||||||
|
array(
|
||||||
|
'type' => 'file',
|
||||||
|
'label' => $this->l('Image:'),
|
||||||
|
'name' => 'image',
|
||||||
|
'value' => true
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'textarea',
|
||||||
|
'label' => $this->l('Text:'),
|
||||||
|
'lang' => true,
|
||||||
|
'name' => 'text',
|
||||||
|
'cols' => 40,
|
||||||
|
'rows' => 10
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'submit' => array(
|
||||||
|
'title' => $this->l(' Save '),
|
||||||
|
'class' => 'button'
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function install()
|
public function install()
|
||||||
{
|
{
|
||||||
$return = (parent::install() && $this->installDB() && Configuration::updateValue('blockreinsurance_nbblocks', 5) && $this->registerHook('footer'));
|
return parent::install() &&
|
||||||
$return &= $this->installFixtures();
|
$this->installDB() &&
|
||||||
return $return;
|
Configuration::updateValue('blockreinsurance_nbblocks', 5) &&
|
||||||
|
$this->registerHook('footer') && $this->installFixtures();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function installDB()
|
public function installDB()
|
||||||
{
|
{
|
||||||
return Db::getInstance()->execute('
|
$return = true;
|
||||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'reinsurance` (
|
$return &= Db::getInstance()->execute('
|
||||||
`id_contactinfos` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'reinsurance` (
|
||||||
`id_shop` int(10) unsigned NOT NULL ,
|
`id_reinsurance` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
`filename` VARCHAR(100) NOT NULL,
|
`id_shop` int(10) unsigned NOT NULL ,
|
||||||
`text` VARCHAR(300) NOT NULL,
|
`file_name` VARCHAR(100) NOT NULL,
|
||||||
PRIMARY KEY (`id_contactinfos`)
|
PRIMARY KEY (`id_reinsurance`)
|
||||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 ;');
|
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 ;');
|
||||||
|
|
||||||
|
$return &= Db::getInstance()->execute('
|
||||||
|
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'reinsurance_lang` (
|
||||||
|
`id_reinsurance` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
|
`id_lang` int(10) unsigned NOT NULL ,
|
||||||
|
`text` VARCHAR(300) NOT NULL,
|
||||||
|
PRIMARY KEY (`id_reinsurance`, `id_lang`)
|
||||||
|
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 ;');
|
||||||
|
|
||||||
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uninstall()
|
public function uninstall()
|
||||||
{
|
{
|
||||||
// Delete configuration
|
// Delete configuration
|
||||||
return (Configuration::deleteByName('blockreinsurance_nbblocks') && $this->uninstallDB() && parent::uninstall());
|
return Configuration::deleteByName('blockreinsurance_nbblocks') &&
|
||||||
|
$this->uninstallDB() &&
|
||||||
|
parent::uninstall();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uninstallDB()
|
public function uninstallDB()
|
||||||
{
|
{
|
||||||
return Db::getInstance()->execute('
|
return Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'reinsurance`') && Db::getInstance()->execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'reinsurance_lang`');
|
||||||
DROP TABLE IF EXISTS `'._DB_PREFIX_.'reinsurance`');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addToDB()
|
public function addToDB()
|
||||||
@@ -95,7 +152,7 @@ class Blockreinsurance extends Module
|
|||||||
}
|
}
|
||||||
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'reinsurance` (`filename`,`text`)
|
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'reinsurance` (`filename`,`text`)
|
||||||
VALUES ("'.((isset($filename[0]) && $filename[0] != '') ? pSQL($filename[0]) : '').
|
VALUES ("'.((isset($filename[0]) && $filename[0] != '') ? pSQL($filename[0]) : '').
|
||||||
'", "'.((isset($_POST['info'.$i.'_text']) && $_POST['info'.$i.'_text'] != '') ? pSQL($_POST['info'.$i.'_text']) : '').'")');
|
'", "'.((isset($_POST['info'.$i.'_text']) && $_POST['info'.$i.'_text'] != '') ? pSQL($_POST['info'.$i.'_text']) : '').'")');
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
@@ -116,15 +173,64 @@ class Blockreinsurance extends Module
|
|||||||
return Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'reinsurance`');
|
return Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'reinsurance`');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllFromDB()
|
|
||||||
{
|
|
||||||
return Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'reinsurance`');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getContent()
|
public function getContent()
|
||||||
{
|
{
|
||||||
// If we try to update the settings
|
$html = '';
|
||||||
$output = '';
|
$id_reinsurance = (int)Tools::getValue('id_reinsurance');
|
||||||
|
if (Tools::isSubmit('saveblockreinsurance'))
|
||||||
|
{
|
||||||
|
$reinsurance = new reinsuranceClass();
|
||||||
|
$reinsurance->copyFromPost();
|
||||||
|
$reinsurance->id_shop = $this->context->shop->id;
|
||||||
|
|
||||||
|
if ($reinsurance->validateFields(false) && $reinsurance->validateFieldsLang(false))
|
||||||
|
{
|
||||||
|
$reinsurance->save();
|
||||||
|
if (isset($_FILES['image']) && isset($_FILES['image']['tmp_name']) && !empty($_FILES['image']['tmp_name']))
|
||||||
|
{
|
||||||
|
if ($error = ImageManager::validateUpload($_FILES['image']))
|
||||||
|
return false;
|
||||||
|
elseif (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($_FILES['image']['tmp_name'], $tmpName))
|
||||||
|
return false;
|
||||||
|
elseif (!ImageManager::resize($tmpName, dirname(__FILE__).'/img/reinsurance-'.(int)$reinsurance->id.'-'.(int)$reinsurance->id_shop.'.jpg'))
|
||||||
|
return false;
|
||||||
|
unlink($tmpName);
|
||||||
|
$reinsurance->file_name = 'reinsurance-'.(int)$reinsurance->id.'-'.(int)$reinsurance->id_shop.'.jpg';
|
||||||
|
$reinsurance->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$html .= '<div class="conf error">'.$this->l('An error occurred during the save').'</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Tools::isSubmit('updateblockreinsurance') || Tools::isSubmit('addblockreinsurance'))
|
||||||
|
{
|
||||||
|
$helper = $this->initForm();
|
||||||
|
foreach (Language::getLanguages(false) as $lang)
|
||||||
|
if ($id_reinsurance)
|
||||||
|
{
|
||||||
|
$reinsurance = new reinsuranceClass((int)$id_reinsurance);
|
||||||
|
$helper->fields_value['text'][(int)$lang['id_lang']] = $reinsurance->text[(int)$lang['id_lang']];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$helper->fields_value['text'][(int)$lang['id_lang']] = Tools::getValue('text_'.(int)$lang['id_lang'], '');
|
||||||
|
|
||||||
|
return $html.$helper->generateForm($this->fields_form);
|
||||||
|
}
|
||||||
|
else if (Tools::isSubmit('deleteblockreinsurance'))
|
||||||
|
{
|
||||||
|
$reinsurance = new reinsuranceClass((int)$id_reinsurance);
|
||||||
|
if (file_exists(dirname(__FILE__).'/img/'.$reinsurance->file_name))
|
||||||
|
unlink(dirname(__FILE__).'/img/'.$reinsurance->file_name);
|
||||||
|
$reinsurance->delete();
|
||||||
|
Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules'));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$helper = $this->initList();
|
||||||
|
return $html.$helper->generateList($this->getListContent((int)Configuration::get('PS_LANG_DEFAULT')), $this->fields_list);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_POST['submitModule']))
|
if (isset($_POST['submitModule']))
|
||||||
{
|
{
|
||||||
Configuration::updateValue('blockreinsurance_nbblocks', ((isset($_POST['nbblocks']) && $_POST['nbblocks'] != '') ? (int)$_POST['nbblocks'] : ''));
|
Configuration::updateValue('blockreinsurance_nbblocks', ((isset($_POST['nbblocks']) && $_POST['nbblocks'] != '') ? (int)$_POST['nbblocks'] : ''));
|
||||||
@@ -133,95 +239,105 @@ class Blockreinsurance extends Module
|
|||||||
else
|
else
|
||||||
$output = '<div class="conf error"><img src="../img/admin/disabled.gif"/>'.$this->l('An error occurred during the save').'</div>';
|
$output = '<div class="conf error"><img src="../img/admin/disabled.gif"/>'.$this->l('An error occurred during the save').'</div>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$nb_blocks = Configuration::get('blockreinsurance_nbblocks');
|
protected function getListContent($id_lang)
|
||||||
$infos = $this->getAllFromDB();
|
{
|
||||||
|
return Db::getInstance()->executeS('
|
||||||
|
SELECT r.`id_reinsurance`, r.`id_shop`, r.`file_name`, rl.`text`
|
||||||
|
FROM `'._DB_PREFIX_.'reinsurance` r
|
||||||
|
LEFT JOIN `'._DB_PREFIX_.'reinsurance_lang` rl ON (r.`id_reinsurance` = rl.`id_reinsurance`)
|
||||||
|
WHERE `id_lang` = '.(int)$id_lang.' '.Shop::addSqlRestrictionOnLang());
|
||||||
|
}
|
||||||
|
|
||||||
$content = '
|
protected function initForm()
|
||||||
<script type="text/javascript">
|
{
|
||||||
$(document).ready(function(){
|
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||||
var nb_blocks = 5;
|
|
||||||
nb_blocks = $("select[name=nbblocks]").val();
|
|
||||||
$("div.container_infos").each(function(){
|
|
||||||
id_div = $(this).attr("id").split("container_infos");
|
|
||||||
if(parseInt(id_div[1]) <= nb_blocks)
|
|
||||||
$(this).show();
|
|
||||||
else
|
|
||||||
$(this).hide();
|
|
||||||
});
|
|
||||||
|
|
||||||
$("select[name=nbblocks]").change(function(){
|
$helper = new HelperForm();
|
||||||
nb_blocks = $("select[name=nbblocks]").val();
|
$helper->module = $this;
|
||||||
$("div.container_infos").each(function(){
|
$helper->name_controller = 'blockreinsurance';
|
||||||
id_div = $(this).attr("id").split("container_infos");
|
$helper->identifier = $this->identifier;
|
||||||
if(parseInt(id_div[1]) <= nb_blocks)
|
$helper->token = Tools::getAdminTokenLite('AdminModules');
|
||||||
$(this).show();
|
foreach (Language::getLanguages(false) as $lang)
|
||||||
else
|
$helper->languages[] = array(
|
||||||
$(this).hide();
|
'id_lang' => $lang['id_lang'],
|
||||||
});
|
'iso_code' => $lang['iso_code'],
|
||||||
});
|
'name' => $lang['name'],
|
||||||
});
|
'is_default' => ($default_lang == $lang['id_lang'] ? 1 : 0)
|
||||||
</script>
|
);
|
||||||
<h2>'.$this->displayName.'</h2>
|
|
||||||
'.$output.'
|
$helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name;
|
||||||
<form method="post" action="'.Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']).'" enctype="multipart/form-data">
|
$helper->default_form_language = $default_lang;
|
||||||
<fieldset class="width2">
|
$helper->allow_employee_form_lang = $default_lang;
|
||||||
<select name="nbblocks">';
|
$helper->toolbar_scroll = true;
|
||||||
// Show by default 5 blocks maximum
|
$helper->title = $this->displayName;
|
||||||
for ($i = 1; $i <= 5; $i++)
|
$helper->submit_action = 'saveblockreinsurance';
|
||||||
$content .= '<option value="'.$i.'" '.(($i == $nb_blocks) ? 'selected="selected"' : '').'>'.$i.' '.$this->l('block(s)').'</option>';
|
$helper->toolbar_btn = array(
|
||||||
$content .= '</select>
|
'save' =>
|
||||||
<div class="clear"> </div>';
|
array(
|
||||||
// Show by default 5 blocks maximum
|
'desc' => $this->l('Save'),
|
||||||
for ($i = 1; $i <= 5; $i++)
|
'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules'),
|
||||||
{
|
),
|
||||||
$content .= '<div id="container_infos'.$i.'" class="container_infos"><h3>'.$this->l('Block number').' '.$i.'</h3>'.
|
'back' =>
|
||||||
((!empty($infos[$i - 1]) && $infos[$i - 1]['filename'] != '') ? '<img src="'.Tools::getHttpHost(true)._MODULE_DIR_.$this->name.'/img/'.$infos[$i - 1]['filename'].'.jpg" />' : '').
|
array(
|
||||||
'<div class="clear"> </div>
|
'href' => AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules'),
|
||||||
<p><label for="info'.$i.'_file">'.$this->l('Image for this block').' :</label>
|
'desc' => $this->l('Back to list')
|
||||||
<input type="file" name="info'.$i.'_file" /></p>
|
)
|
||||||
<p><label for="info'.$i.'_text">'.$this->l('Alternative text for this block').' :</label>
|
);
|
||||||
<input type="text" id="info'.$i.'_text" name="info'.$i.'_text" value="'.((!empty($infos[$i - 1]) && $infos[$i - 1]['text'] != '') ? $infos[$i - 1]['text'] : '').'" /></p></div>';
|
return $helper;
|
||||||
}
|
}
|
||||||
$content .= '<div class="clear"> </div>
|
|
||||||
<br /><center><input type="submit" name="submitModule" value="'.$this->l('Update settings').'" class="button" /></center>
|
protected function initList()
|
||||||
</fieldset>
|
{
|
||||||
</form>';
|
$helper = new HelperList();
|
||||||
|
$helper->shopLinkType = '';
|
||||||
|
$helper->simple_header = true;
|
||||||
|
$helper->identifier = 'id_reinsurance';
|
||||||
|
$helper->actions = array('edit', 'delete');
|
||||||
|
$helper->show_toolbar = true;
|
||||||
|
$helper->imageType = 'jpg';
|
||||||
|
$helper->toolbar_btn['new'] = array(
|
||||||
|
'href' => AdminController::$currentIndex.'&configure='.$this->name.'&add'.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules'),
|
||||||
|
'desc' => $this->l('Add new')
|
||||||
|
);
|
||||||
|
|
||||||
|
$helper->title = $this->displayName;
|
||||||
|
$helper->table = $this->name;
|
||||||
|
$helper->token = Tools::getAdminTokenLite('AdminModules');
|
||||||
|
$helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name;
|
||||||
|
return $helper;
|
||||||
|
|
||||||
return $content;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hookFooter($params)
|
public function hookFooter($params)
|
||||||
{
|
{
|
||||||
global $smarty;
|
|
||||||
|
|
||||||
$this->context->controller->addCSS($this->_path.'style.css', 'all');
|
$this->context->controller->addCSS($this->_path.'style.css', 'all');
|
||||||
$infos = $this->getAllFromDB();
|
$infos = $this->getListContent($this->context->language->id);
|
||||||
|
$this->context->smarty->assign(array('infos' => $infos, 'nbblocks' => count($infos)));
|
||||||
$smarty->assign(array(
|
|
||||||
'nbblocks' => Configuration::get('blockreinsurance_nbblocks'),
|
|
||||||
'infos' => $infos
|
|
||||||
));
|
|
||||||
return $this->display(__FILE__, 'blockreinsurance.tpl');
|
return $this->display(__FILE__, 'blockreinsurance.tpl');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function installFixtures()
|
public function installFixtures()
|
||||||
{
|
{
|
||||||
$nb_blocks = Configuration::get('blockreinsurance_nbblocks');
|
$return = true;
|
||||||
$tab_texts = array(
|
$tab_texts = array(
|
||||||
$this->l('Money back'),
|
array('text' => 'Money back', 'file_name' => 'reinsurance-1-1.jpg'),
|
||||||
$this->l('Exchange in-store'),
|
array('text' => 'Exchange in-store', 'file_name' => 'reinsurance-2-1.jpg'),
|
||||||
$this->l('Payment upon shipment'),
|
array('text' => 'Payment upon shipment', 'file_name' => 'reinsurance-3-1.jpg'),
|
||||||
$this->l('Free Shipping'),
|
array('text' => 'Free Shipping', 'file_name' => 'reinsurance-4-1.jpg'),
|
||||||
$this->l('100% secured payment'),
|
array('text' => '100% secured payment', 'file_name' => 'reinsurance-5-1.jpg')
|
||||||
);
|
);
|
||||||
$success = true;
|
|
||||||
for ($a = 1; $a <= $nb_blocks; $a++)
|
foreach($tab_texts as $tab)
|
||||||
{
|
{
|
||||||
$success &= Db::getInstance()->execute('
|
$reinsurance = new reinsuranceClass();
|
||||||
INSERT INTO `'._DB_PREFIX_.'reinsurance` (`filename`, `text`, `id_shop`)
|
foreach (Language::getLanguages(false) as $lang)
|
||||||
VALUES ("reassurance'.$a.'", "'.$tab_texts[($a-1)].'", '.(int)$this->context->shop->id.')');
|
$reinsurance->text[$lang['id_lang']] = $tab['text'];
|
||||||
|
$reinsurance->file_name = $tab['file_name'];
|
||||||
|
$reinsurance->id_shop = $this->context->shop->id;
|
||||||
|
$return &= $reinsurance->save();
|
||||||
}
|
}
|
||||||
return $success;
|
return $return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
<div id="reinsurance_block" class="clearfix">
|
<div id="reinsurance_block" class="clearfix">
|
||||||
<ul class="width{$nbblocks}">
|
<ul class="width{$nbblocks}">
|
||||||
{foreach from=$infos item=info}
|
{foreach from=$infos item=info}
|
||||||
<li><img src="{$module_dir}img/{$info.filename}.jpg" alt="{$info.text}" /> <span>{$info.text}</span></li>
|
<li><img src="{$module_dir}img/{$info.file_name}" alt="{$info.text|escape:html:'UTF-8'}" /> <span>{$info.text|escape:html:'UTF-8'}</span></li>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<module>
|
<module>
|
||||||
<name>blockreinsurance</name>
|
<name>blockreinsurance</name>
|
||||||
<displayName><![CDATA[Bloc reinsurance]]></displayName>
|
<displayName><![CDATA[Bloc reinsurance]]></displayName>
|
||||||
<version><![CDATA[1.0]]></version>
|
<version><![CDATA[2.0]]></version>
|
||||||
<description><![CDATA[Add a block to display more infos to reassure your customers]]></description>
|
<description><![CDATA[Add a block to display more infos to reassure your customers]]></description>
|
||||||
<author><![CDATA[]]></author>
|
<author><![CDATA[]]></author>
|
||||||
<tab><![CDATA[front_office_features]]></tab>
|
<tab><![CDATA[front_office_features]]></tab>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* 2007-2012 PrestaShop
|
||||||
|
*
|
||||||
|
* NOTICE OF LICENSE
|
||||||
|
*
|
||||||
|
* This source file is subject to the Academic Free License (AFL 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/afl-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-2012 PrestaShop SA
|
||||||
|
* @version Release: $Revision: 6844 $
|
||||||
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
|
*/
|
||||||
|
|
||||||
|
class reinsuranceClass extends ObjectModel
|
||||||
|
{
|
||||||
|
/** @var integer reinsurance id*/
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
/** @var integer reinsurance id shop*/
|
||||||
|
public $id_shop;
|
||||||
|
|
||||||
|
/** @var string reinsurance file name icon*/
|
||||||
|
public $file_name;
|
||||||
|
|
||||||
|
/** @var string reinsurance text*/
|
||||||
|
public $text;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ObjectModel::$definition
|
||||||
|
*/
|
||||||
|
public static $definition = array(
|
||||||
|
'table' => 'reinsurance',
|
||||||
|
'primary' => 'id_reinsurance',
|
||||||
|
'multilang' => true,
|
||||||
|
'fields' => array(
|
||||||
|
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isunsignedInt', 'required' => true),
|
||||||
|
'file_name' => array('type' => self::TYPE_STRING, 'validate' => 'isFileName'),
|
||||||
|
// Lang fields
|
||||||
|
'text' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
public function copyFromPost()
|
||||||
|
{
|
||||||
|
/* Classical fields */
|
||||||
|
foreach ($_POST AS $key => $value)
|
||||||
|
if (key_exists($key, $this) AND $key != 'id_'.$this->table)
|
||||||
|
$this->{$key} = $value;
|
||||||
|
|
||||||
|
/* Multilingual fields */
|
||||||
|
if (sizeof($this->fieldsValidateLang))
|
||||||
|
{
|
||||||
|
$languages = Language::getLanguages(false);
|
||||||
|
foreach ($languages AS $language)
|
||||||
|
foreach ($this->fieldsValidateLang AS $field => $validation)
|
||||||
|
if (isset($_POST[$field.'_'.(int)($language['id_lang'])]))
|
||||||
|
$this->{$field}[(int)($language['id_lang'])] = $_POST[$field.'_'.(int)($language['id_lang'])];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||