fix return condition

This commit is contained in:
root 2017-12-07 10:55:49 +01:00
parent aa2f9b98cf
commit 93fd9f929c

View File

@ -1721,8 +1721,7 @@ class AdminOrders extends AdminTab
<div class="panel-content">';
if (!sizeof($returns)){
$html.= '
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;cursor:pointer" data-toggle="collapse" href="#div_returns">'.$this->l('Create a product return').'</h5>
<div class="alert alert-info collapse" id="div_returns">'.$this->l('No merchandise return for this order.').'</div>';
<div class="alert alert-info">'.$this->l('No merchandise return for this order.').'</div>';
} else {
$html.='
<table class="table table-condensed th-grey" width="100%" >
@ -1756,114 +1755,114 @@ class AdminOrders extends AdminTab
}
$html.='</tbody>
</table>';
}
if(in_array($addressDelivery->id_country, array(3, 6, 8))) {
$returnable = array();
foreach ($products as $k => $product) {
$product['id_sale'] = $product_psale[(int) $product['product_id']];
$qty = OrderReturn::getOrderDetailReturnQty($product, $currentState->id);
if($qty > 0) {
$returnable[$product['id_order_detail']] = array($product['product_name'], $qty);
}
if(in_array($addressDelivery->id_country, array(3, 6, 8))) {
$returnable = array();
foreach ($products as $k => $product) {
$product['id_sale'] = $product_psale[(int) $product['product_id']];
$qty = OrderReturn::getOrderDetailReturnQty($product, $currentState->id);
if($qty > 0) {
$returnable[$product['id_order_detail']] = array($product['product_name'], $qty);
}
if(count($returnable) > 0) {
$instructions = array(
1 => 'Remboursement + Mise en stock',
2 => 'Échange',
3 => 'Défectueux',
4 => 'Commande à ré-expédier',
5 => 'Commande à rembourser',
);
$reasons = array(
// 1 => 'CLIENT : Annulation pré-envoi',
2 => 'CLIENT : Rétractation post-envoi',
11 => 'CLIENT : Annulation pour ré-achat',
4 => 'FEUR : Problème SAV',
5 => 'FEUR : Produit manquant',
3 => 'BBB : Erreur Achat / Prod',
6 => 'BBB : Erreur Logistique ',
8 => 'BBB : Pbme Site / Paiment',
12 => 'BBB : Suspicion de fraude',
9 => 'TRANS : Colis détruit',
10 => 'TRANS : Colis perdu',
7 => 'Autre'
);
}
if(count($returnable) > 0) {
$instructions = array(
1 => 'Remboursement + Mise en stock',
2 => 'Échange',
3 => 'Défectueux',
4 => 'Commande à ré-expédier',
5 => 'Commande à rembourser',
);
$reasons = array(
// 1 => 'CLIENT : Annulation pré-envoi',
2 => 'CLIENT : Rétractation post-envoi',
11 => 'CLIENT : Annulation pour ré-achat',
4 => 'FEUR : Problème SAV',
5 => 'FEUR : Produit manquant',
3 => 'BBB : Erreur Achat / Prod',
6 => 'BBB : Erreur Logistique ',
8 => 'BBB : Pbme Site / Paiment',
12 => 'BBB : Suspicion de fraude',
9 => 'TRANS : Colis détruit',
10 => 'TRANS : Colis perdu',
7 => 'Autre'
);
$helper->_js .= '<script type="text/javascript">
$(document).ready(function() {
$(".return_input").change(function() {
var id_order_detail = $(this).attr("data-order-detail");
var qty = parseInt($(this).val());
var max = parseInt($(this).attr("max"));
if(qty == 0) {
$(".return_" + id_order_detail).hide();
}
for(var j = 1; j <= max; j=j+1) {
var id = "#return_" + id_order_detail + "_" + j;
if(j <= qty) {
$(id).show();
} else {
$(id).hide();
}
}
});
$(".return_input").trigger("change");
});
</script>';
$html.= '
<div>
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;cursor:pointer" data-toggle="collapse" href="#new_product_return">'.$this->l('Create a product return').'</h5>
<form id="new_product_return" class="collapse" action="" method="post">
<ul style="list-style: outside none; margin: 0; padding: 0;">';
foreach($returnable as $id_order_detail => $product) {
$html.= '
<li style="padding: 5px; background: #eee;"><input data-order-detail="'.(int) $id_order_detail.'" class="return_input" style="width: 30px; text-align: right; border: 1px solid #E0D0B1; padding: 2px 4px;" type="number" name="return_product['.(int) $id_order_detail.']" value="0" autocomplete="off" step="1" max="'.(int) $product[1].'" min="0" /> x '.$product[0]. '</li>
<li id="reason_'.$id_order_detail.'">';
for($i = 1; $i <= $product[1]; $i++) {
$html.= '
<div id="return_'.(int) $id_order_detail.'_'.$i.'">
<label style="margin: 0px; padding: 0px; float: none; text-align: left; font-weight: normal; display: block; margin-bottom: 5px;">'.sprintf($this->l('Return reason product #%s'), $i).'</label>
<select class="form-control" autocomplete="off" name="return_reason_'.(int) $id_order_detail.'_'.$i.'">';
foreach($reasons as $id_reason => $label) {
$html.= '<option value="'.$id_reason.'">'.$label.'</option>';
}
$html.= '
</select>
<label style="margin: 0px; padding: 0px; float: none; text-align: left; font-weight: normal;display: block; margin-bottom: 5px;">'.sprintf($this->l('Return instruction product #%s'), $i).'</label>
<select class="form-control" autocomplete="off" name="return_instruction_'.(int) $id_order_detail.'_'.$i.'">';
foreach($instructions as $id_instruction => $label) {
$html.= '<option value="'.$id_instruction.'">'.$this->l($label).'</option>';
}
$html.= '
</select>
<div class="ln_solid"></div>
</div>';
}
$html.= '</li>';
$helper->_js .= '<script type="text/javascript">
$(document).ready(function() {
$(".return_input").change(function() {
var id_order_detail = $(this).attr("data-order-detail");
var qty = parseInt($(this).val());
var max = parseInt($(this).attr("max"));
if(qty == 0) {
$(".return_" + id_order_detail).hide();
}
$html.= '</ul>
<p>
<label for="return_option" style="margin: 0px; padding: 0px; float: none; text-align: left; font-weight: bold;">'.$this->l('This return will be').'</label>
<select class="form-control" autocomplete="off" name="return_option" id="return_option">
<!--option value="1">'.$this->l('paid by the customer').'</option-->
<option value="2">'.$this->l('free').'</option>
</select>
</p>
<p>
<label style="width: auto; margin-bottom: 5px;">'.$this->l('Insert a comment (optional):').'</label>
<textarea class="form-control" name="return_comment" rows="5" cols="50" style="resize: vertical"></textarea>
</p>
<div style="text-right">
<input type="submit" value="'.$this->l('Confirm').'" name="submitCreateReturn" class="btn btn-primary" />
</div>
</form>
</div>';
} else {
$html.= '
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;cursor:pointer" data-toggle="collapse" href="#div_returns">'.$this->l('Create a product return').'</h5>
<div class="alert alert-warning-light collapse" id="div_returns">'.$this->l('No product can currently be returned on this order').'</div>';
}
for(var j = 1; j <= max; j=j+1) {
var id = "#return_" + id_order_detail + "_" + j;
if(j <= qty) {
$(id).show();
} else {
$(id).hide();
}
}
});
$(".return_input").trigger("change");
});
</script>';
$html.= '
<div>
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;cursor:pointer" data-toggle="collapse" href="#new_product_return">'.$this->l('Create a product return').'</h5>
<form id="new_product_return" class="collapse" action="" method="post">
<ul style="list-style: outside none; margin: 0; padding: 0;">';
foreach($returnable as $id_order_detail => $product) {
$html.= '
<li style="padding: 5px; background: #eee;"><input data-order-detail="'.(int) $id_order_detail.'" class="return_input" style="width: 30px; text-align: right; border: 1px solid #E0D0B1; padding: 2px 4px;" type="number" name="return_product['.(int) $id_order_detail.']" value="0" autocomplete="off" step="1" max="'.(int) $product[1].'" min="0" /> x '.$product[0]. '</li>
<li id="reason_'.$id_order_detail.'">';
for($i = 1; $i <= $product[1]; $i++) {
$html.= '
<div id="return_'.(int) $id_order_detail.'_'.$i.'">
<label style="margin: 0px; padding: 0px; float: none; text-align: left; font-weight: normal; display: block; margin-bottom: 5px;">'.sprintf($this->l('Return reason product #%s'), $i).'</label>
<select class="form-control" autocomplete="off" name="return_reason_'.(int) $id_order_detail.'_'.$i.'">';
foreach($reasons as $id_reason => $label) {
$html.= '<option value="'.$id_reason.'">'.$label.'</option>';
}
$html.= '
</select>
<label style="margin: 0px; padding: 0px; float: none; text-align: left; font-weight: normal;display: block; margin-bottom: 5px;">'.sprintf($this->l('Return instruction product #%s'), $i).'</label>
<select class="form-control" autocomplete="off" name="return_instruction_'.(int) $id_order_detail.'_'.$i.'">';
foreach($instructions as $id_instruction => $label) {
$html.= '<option value="'.$id_instruction.'">'.$this->l($label).'</option>';
}
$html.= '
</select>
<div class="ln_solid"></div>
</div>';
}
$html.= '</li>';
}
$html.= '</ul>
<p>
<label for="return_option" style="margin: 0px; padding: 0px; float: none; text-align: left; font-weight: bold;">'.$this->l('This return will be').'</label>
<select class="form-control" autocomplete="off" name="return_option" id="return_option">
<!--option value="1">'.$this->l('paid by the customer').'</option-->
<option value="2">'.$this->l('free').'</option>
</select>
</p>
<p>
<label style="width: auto; margin-bottom: 5px;">'.$this->l('Insert a comment (optional):').'</label>
<textarea class="form-control" name="return_comment" rows="5" cols="50" style="resize: vertical"></textarea>
</p>
<div style="text-right">
<input type="submit" value="'.$this->l('Confirm').'" name="submitCreateReturn" class="btn btn-primary" />
</div>
</form>
</div>';
} else {
$html.= '
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;cursor:pointer" data-toggle="collapse" href="#div_returns">'.$this->l('Create a product return').'</h5>
<div class="alert alert-warning-light collapse" id="div_returns">'.$this->l('No product can currently be returned on this order').'</div>';
}
}
$html.= '</div>