Redirect & confirmation

This commit is contained in:
Michael RICOIS 2017-12-05 17:55:53 +01:00
parent 1702e23439
commit dc4c4dffc0

View File

@ -68,16 +68,20 @@ class Fraud extends Module
{
global $currentIndex;
// @todo : Must be exec in postProcess before display
if (Tools::getIsset('validFraud')) {
$token = Tools::getValue('token');
$id_order = Tools::getValue('id_order');
if (!FraudCore::validOrder($id_order)) {
echo '<br /><p class="alert" style="width:300px">'.$this->l('Update impossible').'</p>';
} else {
echo '<br /><p class="conf">'.$this->l('Valid order with success').'</p>';
Tools::redirectAdmin($currentIndex.'&id_order='.$id_order.'&vieworder&hookconf=1&token='.$token);
}
}
if (Tools::getIsset('hookconf')) {
echo '<br /><p class="conf">'.$this->l('Valid order with success').'</p>';
}
$reputation = FraudCore::getReputationOrder((int) $params['id_order']);
if ($reputation) {
if ($reputation['score'] >= 100) {
@ -118,28 +122,36 @@ class Fraud extends Module
<div class="clearfix"></div>
</div>
<div class="panel-content">';
if (Tools::getIsset('validFraud')) {
$id_order = Tools::getValue('id_order');
if (!FraudCore::validOrder($id_order)) {
$data .= '<br /><p class="alert">'.$this->l('Update impossible').'</p>';
} else {
$data .= '<br /><p class="conf">'.$this->l('Valid order with success').'</p>';
}
}
if ($reputation['score'] >= 100) {
$info = json_decode($reputation['report']);
$data .= '
<a class="btn btn-danger" role="button" data-toggle="collapse" href="#collapseFraudModule">
<b>'.$this->l('Score : ').'</b> <span class="badge">'.$reputation['score'].'</span>
</a>
<div class="collapse" id="collapseFraudModule">
<h4>'.$this->l('Details : ').'</h4>
<p>'.implode('<br />', $info).'</p>
</div>';
if ($reputation['pass'] == 0) {
$data .= '<a class="pull-right btn btn-primary btn-sm" onclick="if(!confirm(\'Voulez-vous valider la commande ? \')) return false;" href="'.$_SERVER['REQUEST_URI'].'&validFraud=1" class="button">'.$this->l('Valid Order').'</a>';
}
}
if (Tools::getIsset('validFraud')) {
$token = Tools::getValue('token');
$id_order = Tools::getValue('id_order');
if (!FraudCore::validOrder($id_order)) {
$data .= '<br /><p class="alert">'.$this->l('Update impossible').'</p>';
} else {
Tools::redirectAdmin($currentIndex.'&id_order='.$id_order.'&vieworder&hookconf=1&token='.$token);
}
}
if (Tools::getIsset('hookconf')) {
$data .= '<br /><p class="conf">'.$this->l('Valid order with success').'</p>';
}
if ($reputation['score'] >= 100) {
$info = json_decode($reputation['report']);
$data .= '
<a class="btn btn-danger" role="button" data-toggle="collapse" href="#collapseFraudModule">
<b>'.$this->l('Score : ').'</b> <span class="badge">'.$reputation['score'].'</span>
</a>
<div class="collapse" id="collapseFraudModule">
<h4>'.$this->l('Details : ').'</h4>
<p>'.implode('<br />', $info).'</p>
</div>';
if ($reputation['pass'] == 0) {
$data .= '<a class="pull-right btn btn-primary btn-sm" onclick="if(!confirm(\'Voulez-vous valider la commande ? \')) return false;" href="'.$_SERVER['REQUEST_URI'].'&validFraud=1" class="button">'.$this->l('Valid Order').'</a>';
}
}
$data .= '</div>
</div>
</div>';