109 lines
5.9 KiB
PHP
109 lines
5.9 KiB
PHP
|
<?php
|
||
|
require_once(dirname(__FILE__).'/../../config/config.inc.php');
|
||
|
require_once(dirname(__FILE__).'/../../init.php');
|
||
|
include_once(_PS_ROOT_DIR_.'/modules/ant_support/Question.php');
|
||
|
include_once(_PS_ROOT_DIR_.'/modules/ant_support/Section.php');
|
||
|
|
||
|
if (Tools::getValue('token')) {
|
||
|
if (isset($_GET['id']) && isset($_GET['position']) && Tools::getIsset('updatepositionQuestion')) {
|
||
|
$question = new Question((int) $_GET['id']);
|
||
|
$sql = Db::getInstance()->getRow('
|
||
|
SELECT `id_question`
|
||
|
FROM `'._DB_PREFIX_.'support_question`
|
||
|
WHERE `position` = '.(int) $_GET['position'].'
|
||
|
AND `id_section` = '.(int) $question->id_section
|
||
|
);
|
||
|
$question2 = new Question((int) $sql['id_question']);
|
||
|
Db::getInstance()->Execute('
|
||
|
UPDATE `'._DB_PREFIX_.'support_question` SET
|
||
|
`position` = '.(int) $question->position.'
|
||
|
WHERE `id_question` = '.(int) $question2->id.'
|
||
|
');
|
||
|
Db::getInstance()->Execute('
|
||
|
UPDATE `'._DB_PREFIX_.'support_question` SET
|
||
|
`position` = '.(int) $_GET['position'].'
|
||
|
WHERE `id_question` = '.(int) $question->id.'
|
||
|
');
|
||
|
|
||
|
$questions = Question::getQuestionsByIdSection($question->id_section);
|
||
|
$html = '';
|
||
|
foreach ($questions as $key => $question) {
|
||
|
$html .= '<tr id="item_'.$question->id. '" class="question_'.($key%2).'">
|
||
|
<td>'.$question->id.'</td>
|
||
|
<td><strong>'.$question->title[intval($cookie->id_lang)].'</strong></td>
|
||
|
<td><img src="../img/admin/'.($question->status?'enabled.gif':'disabled.gif').'"</td>
|
||
|
<td class="position">';
|
||
|
if($key != 0){
|
||
|
$html .= '<a onclick="updatePositionQuestion('.$question->id.',0,'.$question->position.')" class="position" data-way="0" data-position='. $question->position .'><img title="Haut" alt="Haut" src="../img/admin/up.gif"></a>';
|
||
|
}
|
||
|
if($key + 1 != count($questions)){
|
||
|
$html .= '<a onclick="updatePositionQuestion('.$question->id.',1,'.$question->position.')" class="position" data-way="1" data-position='. $question->position .'><img title="Bas" alt="Bas" src="../img/admin/down.gif"></a>';
|
||
|
}
|
||
|
$html .= '</td>
|
||
|
<td>
|
||
|
<img style="cursor: pointer;" onclick="questionItemEdition('.$question->id.')" title="Éditer cette question" alt="" src="../img/admin/edit.gif">
|
||
|
<img style="cursor: pointer;" onclick="questionItemDeletion('.$question->id.')" title="Supprimer cette question" alt="" src="../img/admin/delete.gif">
|
||
|
</td>
|
||
|
</tr>
|
||
|
';
|
||
|
}
|
||
|
die(Tools::jsonEncode(array(
|
||
|
'has_error' => false,
|
||
|
'html' => $html
|
||
|
),JSON_HEX_QUOT | JSON_HEX_TAG));
|
||
|
|
||
|
} elseif (isset($_GET['id']) && isset($_GET['position']) && Tools::getIsset('updatepositionSection')) {
|
||
|
$section = new Section((int) $_GET['id']);
|
||
|
$sql = Db::getInstance()->getRow('
|
||
|
SELECT `id_section`
|
||
|
FROM `'._DB_PREFIX_.'support_section`
|
||
|
WHERE `position` = '.(int) $_GET['position']
|
||
|
);
|
||
|
$section2 = new Section((int) $sql['id_section']);
|
||
|
Db::getInstance()->Execute('
|
||
|
UPDATE `'._DB_PREFIX_.'support_section` SET
|
||
|
`position` = '.(int) $section->position.'
|
||
|
WHERE `id_section` = '.(int) $section2->id.'
|
||
|
');
|
||
|
Db::getInstance()->Execute('
|
||
|
UPDATE `'._DB_PREFIX_.'support_section` SET
|
||
|
`position` = '.(int) $_GET['position'].'
|
||
|
WHERE `id_section` = '.(int) $section->id.'
|
||
|
');
|
||
|
|
||
|
$sections = Section::getSections();
|
||
|
$html='';
|
||
|
foreach ($sections as $key => $section) {
|
||
|
$html .= '<tr id="item_'.$section->id. '" class="section_'.($key%2).'">
|
||
|
<td>'.$section->id.'</td>
|
||
|
<td><strong>'.$section->title[intval($cookie->id_lang)].'</strong></td>
|
||
|
<td><img src="../img/admin/'.($section->status?'enabled.gif':'disabled.gif').'"</td>
|
||
|
<td class="position">';
|
||
|
if($key != 0){
|
||
|
$html .= '<a onclick="updatePositionSection('.$section->id.',0,'.$section->position.')" class="position" data-way="0" data-position='. $section->position .'><img title="Haut" alt="Haut" src="../img/admin/up.gif"></a>';
|
||
|
}
|
||
|
if($key + 1 != count($sections)){
|
||
|
$html .= '<a onclick="updatePositionSection('.$section->id.',1,'.$section->position.')" class="position" data-way="1" data-position='. $section->position .'><img title="Bas" alt="Bas" src="../img/admin/down.gif"></a>';
|
||
|
}
|
||
|
$html .= '</td>
|
||
|
<td>
|
||
|
<img style="cursor: pointer;" onclick="sectionItemEdition('.$section->id.')" title="Éditer cette section" alt="" src="../img/admin/edit.gif">
|
||
|
<img style="cursor: pointer;" onclick="sectionItemDeletion('.$section->id.')" title="Supprimer cette section" alt="" src="../img/admin/delete.gif">
|
||
|
<a href="index.php?tab=AdminSupport&id_section='.$section->id.'&token='.Tools::getValue('token').'">
|
||
|
<img style="cursor: pointer;" title="Voir cette section" alt="" src="../img/admin/details.gif">
|
||
|
</a>
|
||
|
</td>
|
||
|
</tr>
|
||
|
';
|
||
|
}
|
||
|
|
||
|
die(Tools::jsonEncode(array(
|
||
|
'has_error' => false,
|
||
|
'html' => $html
|
||
|
),JSON_HEX_QUOT | JSON_HEX_TAG));
|
||
|
}
|
||
|
}
|
||
|
die(Tools::jsonEncode(array(
|
||
|
'has_error' => true,
|
||
|
'html' => '<p>Probleme de token<p>'
|
||
|
)));
|