bebeboutik/modules/ant_support/AdminSupport.php

101 lines
3.8 KiB
PHP
Raw Normal View History

<?php
if(!defined('_PS_VERSION_')) {
exit;
}
include_once(_PS_ROOT_DIR_.'/modules/ant_support/Section.php');
/*include_once(_PS_ROOT_DIR_.'/modules/ant_support/Question.php');*/
include_once(_PS_ROOT_DIR_.'/modules/ant_support/AdminSections.php');
include_once(_PS_ROOT_DIR_.'/modules/ant_support/AdminQuestions.php');
class AdminSupport extends AdminTab
{
private $adminSections;
private $adminQuestions;
private static $_section = null;
public function __construct()
{
global $cookie;
$id_section = abs((int)(Tools::getValue('id_section')));
if ($id_section) self::$_section = new Section($id_section);
$this->adminSections = new AdminSections();
$this->adminQuestions = new AdminQuestions();
parent::__construct();
}
public static function getCurrentSection()
{
return self::$_section;
}
public function postProcess()
{
if (Tools::isSubmit('submitSectionAdd') || Tools::isSubmit('submitSectionUpdate')) {
$this->adminSections->postProcess();
}
if (Tools::isSubmit('submitQuestionAdd') || Tools::isSubmit('submitQuestionUpdate')) {
$this->adminQuestions->postProcess();
}
}
public function display()
{
global $cookie, $currentIndex;
echo '<script type="text/javascript" src="'.__PS_BASE_URI__.'modules/ant_support/ant_support.js"></script>
<script type="text/javascript">
i18n_delete = "'.$this->l('Are you sure you want to delete this?').'";
current_location = "'.$currentIndex.'&token='.Tools::getAdminTokenLite('AdminSupport').(self::$_section!==null?'&id_section='.self::$_section->id_section:'').'";
url_ajax_admin_support = "'.__PS_BASE_URI__.'modules/ant_support/ajax_admin_support.php?&token='.Tools::getAdminTokenLite('AdminSupport').'";
</script>';
echo '<style type="text/css">
2016-10-06 11:55:13 +02:00
@import "'.__PS_BASE_URI__.'css/custom_admin.css";
.green {
background : #dffad3;
}
.red {
background : #f29b9b;
}
.position {
cursor:pointer;
}
</style>';
if (((Tools::isSubmit('submitAddsection') OR Tools::isSubmit('submitAddsectionAndStay')) AND sizeof($this->adminSections->_errors)) OR isset($_GET['updatesection']) OR isset($_GET['addsection']))
{
$this->adminSections->displayForm($this->token);
echo '<br /><br /><a href="'.$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to list').'</a><br />';
}
elseif (((Tools::isSubmit('submitAddquestion') OR Tools::isSubmit('submitAddquestionAndPreview') OR Tools::isSubmit('submitAddquestionAndStay') AND sizeof($this->adminQuestions->_errors)) OR isset($_GET['updatequestion']) OR isset($_GET['addquestion'])))
{
$this->adminQuestions->displayForm($this->token);
echo '<br /><br /><a href="index.php?tab='.Tools::getValue('tab').'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to list').'</a><br />';
}
elseif (isset($_GET['deletesection']))
{
$this->adminSections->deleteSection($this->token);
}
elseif (isset($_GET['deletequestion']))
{
$this->adminQuestions->deleteQuestion($this->token);
}
echo '<h2>'.$this->l('Sections').'</h2>';
$this->adminSections->display();
echo '<div style="margin:10px">&nbsp;</div>';
if (self::$_section !== null) {
echo '<h2>'.$this->l('Questions in this section').'</h2>';
$this->adminQuestions->display();
}
}
public function displayErrors()
{
parent::displayErrors();
$this->adminQuestions->displayErrors();
$this->adminSections->displayErrors();
}
}