Merge branch 'ticket-14436-WP' into develop

This commit is contained in:
Marion Muszynski 2017-10-27 13:16:11 +02:00
commit c3ea5cd75f
3 changed files with 608 additions and 0 deletions

View File

@ -0,0 +1,174 @@
<?php
require_once(PS_ADMIN_DIR . '/helpers/HelperFormBootstrap.php');
//include_once(_PS_ROOT_DIR_.'/modules/ant_wp/GenerateWp.php');
class AdminAntWp extends AdminTab
{
protected $_html;
public $module_name;
public $config_tab;
public $controller;
public $helperForm;
public $_object;
public function __construct($config_tab = true)
{
parent::__construct();
$this->_object = false;
$this->controller = 'AdminModules';
$this->module_name = 'ant_wp';
$this->config_tab = (bool)$config_tab;
if ($config_tab) {
$this->controller = 'AdminAntWp';
}
$this->helperForm = new HelperFormBootstrap();
// $this->helperForm->_select2 = true;
// $this->helperForm->_inputSwitch = true;
}
public function display()
{
parent::displayForm();
$this->_html = '';
$this->_postProcess();
$this->_addCss();
$this->_html .= $this->helperForm->renderStyle();
$this->_displayForm();
//$this->_displayList();
$this->_html .='<div class="clearfix"></div>';
$this->_addJs();
$this->_html .= $this->helperForm->renderScript();
echo $this->_html;
}
protected function _addJs()
{
$this->helperForm->_js .= '<script type="text/javascript"></script>';
}
protected function _addCss()
{
$this->helperForm->_css .='
.table tr th {
background: #565485;
background: rgba(86,84,133,0.9);
color: #fff;
font-size: 12px;
}
.table tr:nth-child(even) {
background: #F1F1F1;
}
.table .input-group-btn .btn {
padding: 4px 5px;
color: #504d8b;
}
.table .input-group-btn .btn .anticon{
font-size: 12px;
}
.bg-grey{
background: #EFEFEF;
border-radius:4px;
}
.bg-grey .div-title {
border-bottom: 2px solid #504D8B;
}
.control-label.text-left{
text-align:left!important;
}
';
}
protected function _postProcess()
{
if (Tools::getValue('found') && Tools::getValue('new')) {
$this->_html .= HelperFormBootstrap::displaySuccess($this->l('Génération complète <br>Produit trouvés : '.Tools::getValue('found').'<br>Produit nouveau : '.Tools::getValue('new')));
// if ($res) {
// } else {
// $this->_html .= HelperFormBootstrap::displayErrors($this->l('Des erreurs sont survenues : '));
// }
} elseif(Tools::getValue('error_file')) {
$this->_html .= HelperFormBootstrap::displayErrors($this->l('Veuillez charger un fichier correct !'));
}
}
private function _displayForm()
{
global $cookie, $currentIndex;
if (Validate::isLoadedObject($this->_object)){
$trackingTag = $this->_object;
}
$ps_url = ((Configuration::get('PS_SSL_ENABLED') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PORT'] == '443')) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].__PS_BASE_URI__;
$this->helperForm->_forms = array(
array(
// 'action' => $currentIndex . '&token=' . Tools::getAdminTokenLite('AdminAntWp'),
'action' => $ps_url.'modules/ant_wp/GenerateWp.php?url='.$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminAntWp'),
'title' => '<span class="text-rose anticon anticon-table2"></span> '.$this->l('WP'),
'class' => 'form-horizontal',
'class_div' => 'col-md-12',
'sections' => array(
array(
'class' => 'col-md-6',
'inputs' => array(
array(
'type' => 'simpleText',
'name' => 'filename',
'label-class' => 'col-md-12 text-left',
'input-class' => 'col-md-6',
'text-class' => 'input-sm',
'label' => $this->l('Sale name :'),
),
array(
'type' => 'file',
'label' => $this->l('File :'),
'name' => 'csvfile',
'label-class' => 'col-md-12 text-left',
'input-class' => 'col-md-6',
),
),
'actions' => array(),
'actions-class' => 'text-right',
),
array(
'class' => 'col-md-6 bg-grey',
'title' => '<span class="anticon anticon-info"></span> Informations',
'inputs' => array(),
'info_html' => '
<p>Pour la génération du WP</p>
<p>Veuillez importer un fichier sous format csv<br>
Avec les colonnes suivantes :<br>
</p>
<ul style="list-style:none;">
<li style="font-size:13px;"><i>ean;ref_fournisseur;nom_produit_HA;quantite;PPC;prix_achat</i></li>
</ul>
<p>Les colonnes suivantes et la première ligne du fichier seront ignorées.</p>
<p></p>'
),
),
'actions' => array(),
'actions-class' => 'text-right',
)
);
$this->helperForm->_forms[0]['sections'][0]['title'] = "Générer un WP";
$this->helperForm->_forms[0]['sections'][0]['actions'] = array(
array(
'type' => 'submit',
'class' => 'btn-primary',
'name' => 'uploadWP',
'value' => $this->l('Générer')
),
);
$this->helperForm->renderForm();
}
}

File diff suppressed because one or more lines are too long

33
modules/ant_wp/ant_wp.php Normal file
View File

@ -0,0 +1,33 @@
<?php
if (!defined('_PS_VERSION_'))
exit;
class Ant_Wp extends Module {
public function __construct() {
$this->name = 'ant_wp';
$this->tab = 'advertising_marketing';
$this->version = '1.0';
$this->author = 'Antadis';
$this->need_instance = 0;
$this->displayName = $this->l('WP generation');
$this->description = $this->l('Allows to generate WP docs');
}
public function install() {
if(!parent::install()) {
return false;
}
return true;
}
public function uninstall() {
if(parent::uninstall() == false) {
return false;
}
return true;
}
}