Merge branch 'develop' of gitlab.antadis.net:dev-antadis/bebeboutik into develop

This commit is contained in:
root 2017-05-18 13:03:21 +02:00
commit 52e544cb7d

View File

@ -6,6 +6,62 @@ require_once(PS_ADMIN_DIR . '/helpers/HelperFormBootstrap.php');
class AdminAntReturnprocess extends AdminTab
{
private function printLabel($data) {
global $cookie;
//require dirname(__FILE__).'/libs/predis/autoload.php'; // Conflicts with Prestashop autoload
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/OptionInterface.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/AbstractOption.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/Processor/CommandProcessingInterface.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/PrefixableCommandInterface.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/CommandInterface.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/AbstractCommand.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/PrefixableCommand.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Command/PubSubPublish.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/ConnectionInterface.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/SingleConnectionInterface.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/AbstractConnection.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/StreamConnection.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/ConnectionParametersInterface.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/ConnectionParameters.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/ConnectionFactoryInterface.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Connection/ConnectionFactory.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Profile/ServerProfileInterface.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Profile/ServerProfile.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Profile/ServerVersion26.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientCluster.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientPrefix.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientExceptions.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientReplication.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientConnectionFactory.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientProfile.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientOptionsInterface.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Option/ClientOptions.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/BasicClientInterface.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/ClientInterface.php';
require_once dirname(__FILE__).'/libs/predis/lib/Predis/Client.php';
$redis = new Predis\Client();
$redis->publish(
Configuration::get('LOGISTICS_QUEUE_'.(int) $cookie->id_employee),
json_encode(array('data' => base64_encode(
/*chr(2).'n'."\n" // Inch mode
.chr(2).'O0100'."\n" // Start position
.chr(2).'L'."\n"
.'C0000'."\n"
.'D11'."\n"
.chr(2).'L'."\n"
.$this->isoreplace($data)
.'Q0001'."\n" // Number of labels to print
.'E'."\n" // End*/
$data
)))
);
return TRUE;
}
public function postProcess()
{
global $currentIndex, $cookie;
@ -483,7 +539,20 @@ class AdminAntReturnprocess extends AdminTab
}
HelperFormBootstrap::displaySuccess('Remboursement Effectué');
}
} elseif(Tools::isSubmit('submitResendParcel') && Tools::getValue('id_order_return') && ($id_order = (int)(Tools::getValue('id_order'))) AND Validate::isLoadedObject($order = new Order($id_order))) {
HelperFormBootstrap::displaySuccess('Option en cours de developpement...');
// $products = Tools::getValue('resendQuantity');
// if(!empty($products)) {
// $result = $logistics_carriers[$parcel_carrier]->registerParcel($order, $products, $weight);
// if($result[0] != '') {
// $this->_html .= $result[0];
// return;
// }
// $render = $logistics_carriers[$parcel_carrier]->renderLabel($order, $weight, $result[1]);
// HelperFormBootstrap::displaySuccess('Etiquette envoyée à l\'imprimante');
// }
}
}
@ -554,8 +623,13 @@ class AdminAntReturnprocess extends AdminTab
die(Tools::displayError());
}
}
$carriers_socol = explode(',', Configuration::get('ANT_CARRIERS_SOCOL'));
$carriers_mr = explode(',', Configuration::get('ANT_CARRIERS_MR'));
$order = new Order($orderReturn->id_order);
$cart = new Cart((int)$order->id_cart);
$addressDelivery = new Address((int)$order->id_address_delivery);
$addressInvoice = new Address((int)$order->id_address_invoice);
$customer = new Customer((int)$order->id_customer);
$data = $this->getOrderDetail($cart,(int)$cart->id_lang,$order);
$currency = new Currency((int)(Configuration::get('PS_CURRENCY_DEFAULT')));
@ -806,7 +880,12 @@ class AdminAntReturnprocess extends AdminTab
<p style="padding:5px 20px;background:#efefef;">'.$data['order_invoice_address'].'</p>
</div>
<div class="col-md-6">
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">Adresse Livraison</h5>
<h5 style="background:#504D8B;color:#fff;padding:5px; text-align:center;">
Adresse Livraison
'.($cart->id_carrier!=(int)Configuration::get('ANT_CARRIER_DOM') && in_array($cart->id_carrier,$carriers_socol)?'<a style="color:#fff;cursor:pointer;" class="pull-right" id="changeAddress" data-url="scaddressedit.php?id_cart='.(int)$order->id_cart.'"><i class="glyphicon glyphicon-edit"></i></a>':'').'
'.(in_array($cart->id_carrier,$carriers_mr)?'<a style="color:#fff;" class="pull-right" id="changeAddress" data-url="mraddressedit.php?id_cart='.(int)$order->id_cart.'"><i class="glyphicon glyphicon-edit"></i></a>':'').'
'.($cart->id_carrier==(int)Configuration::get('ANT_CARRIER_DOM')?'<a style="color:#fff;" class="pull-right" href="?tab=AdminAddresses&id_address='.$addressDelivery->id.'&addaddress&realedit=1&id_order='.$order->id.($addressDelivery->id == $addressInvoice->id ? '&address_type=1' : '').'&token='.Tools::getAdminToken('AdminAddresses'.(int)(Tab::getIdFromClassName('AdminAddresses')).(int)($cookie->id_employee)).'&back='.urlencode($_SERVER['REQUEST_URI']).'"><i class="glyphicon glyphicon-edit"></i></a>':'').'
</h5>
<p style="padding:5px 20px;background:#efefef;">'.$data['order_address'].'</p>
</div>
</div>
@ -932,7 +1011,61 @@ class AdminAntReturnprocess extends AdminTab
<div class="panel-content">
<div class="row">
<div class="col-md-12">
EN COURS DE DEVELOPPEMENT !
<form action="'.$currentIndex.'&submitResendParcel=1&updateorder_return&id_order_return='.(int)$orderReturn->id.'&token='.$this->token.'" method="post">
<div class="table-responsive">
<table class="table table-custombordered">
<tbody>';
foreach ($returnProducts AS $k => $product) {
$img_path = '';
$img = Db::getInstance()->getRow('
SELECT id_image
FROM `'._DB_PREFIX_.'image` i
WHERE i.`id_product` = '.(int)$product['product_id'].'
AND i.`cover` = 1'
);
if (isset($img['id_image']) && !empty($img['id_image'])) {
$image_obj = new Image((int)$img['id_image']);
$img_path = (isset($image_obj)?$image_obj->getExistingImgPath():'');
}
if (!isset($quantityDisplayed[(int)($product['id_order_detail'])]) OR (int)($product['product_quantity']) > (int)($quantityDisplayed[(int)($product['id_order_detail'])])) {
$html .='
<tr>
<td style="vertical-align:middle;color:#444;font-weight:bold;">
<a style="display: block;color:#444;" target="_blank" href="index.php?tab=AdminCatalog&id_product='.(int)($product['product_id']).'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'" title="'.$this->l('View product').'">
<img style="display:inline-block;" width="50" src="'.(isset($img_path)?_THEME_PROD_DIR_.$img_path.'-small.jpg':'').'"/><span style="font-weight:bold;display:inline-block;margin-left:5px;vertical-align:middle;">'.mb_strimwidth($product['product_name'], 0, 55, "...").'</span>
<div class="clearfix"></div>
</a>
</td>
<td width="70" style="vertical-align:middle;color:#444;">
<input class="form-control" type="number" id="resendQuantity_'.(int)($product['id_order_detail']).'" name="resendQuantity['.(int)($product['id_order_detail']).']" min="0" max="'.$product['product_quantity'].'" value="0"/>
</td>
</tr>';
}
}
$html .='</tbody>
</table>
</div>
<div class="form-grou">
<input type="hidden" name="id_order" value="'.$order->id.'" />
<input type="hidden" name="id_order_return" value="'.$orderReturn->id.'" />
<div class="col-md-4 center">
<select class="form-control input-sm">
<option value="laposte">La poste</option>
<option value="mondialrelay">Mondial Relay</option>
</select>
</div>
<div class="col-md-4 center">
<div class="input-group input-group-sm">
<input class="form-control input-sm" type="text" name="weght" value="0.24"/>
<span class="input-group-addon">Kg</span>
</div>
</div>
<div class="col-md-4 center">
<input class="btn btn-primary btn-block btn-sm" type="submit" name="submitResendParcel" value="Générer Etiquette" />
</div>
</div>
</form>
</div>
</div>
</div>
@ -1039,6 +1172,18 @@ class AdminAntReturnprocess extends AdminTab
</div>
</div>';
$helper->_js .= '
<script type="text/javascript">
$(function() {
$("#changeAddress").click(function(){
url = $(this).data("url");
var p = window.open(url, "Modification Addresse de livraison", "width=720, height=360, resizable=1, scrollbars=1");
return false;
});
});
</script>
';
$html .= $helper->renderScript();
echo $html;
@ -1254,12 +1399,7 @@ class AdminAntReturnprocess extends AdminTab
AND `cecountry` IN ("FR","BE","ES")
AND (`pradress1`!= "" OR `pradress2`!= "" OR `pradress3`!= "" OR `pradress4`!= "")
');
if((int) $cart->id_carrier == (int)Configuration::get('ANT_CARRIER_DOM')) {
$DOM_front = true;
} else {
$DOM_front = false;
}
if($socol && !$DOM_front) {
if($socol && (int)$cart->id_carrier != (int)Configuration::get('ANT_CARRIER_DOM')) {
$order_address = nl2br(preg_replace("/(\r\n){2,}/", "\r\n", implode("\r\n", array(
$socol['cefirstname'].' '.$socol['cename'],
$socol['cecompanyname'],
@ -1283,6 +1423,7 @@ class AdminAntReturnprocess extends AdminTab
SELECT COUNT(*)
FROM `'._DB_PREFIX_.'mr_method`
WHERE `id_carrier` = '.(int) $cart->id_carrier.'
AND `MR_Selected_Num` IS NOT NULL
')) {
$mr = Db::getInstance()->getRow('
SELECT mr_s.*