Esempio n. 1
0
 public static function getExpeditions($expedition_data = null)
 {
     $response = false;
     try {
         $sc_options = array('connection_timeout' => 30);
         $soap_client = new SoapClient((string) Configuration::get('SEUR_URLWS_E'), $sc_options);
         if (!isset($expedition_data['start_date']) || !isset($expedition_data['end_date'])) {
             $new_date = strtotime('-15 days', strtotime(date('Y-m-d')));
         }
         $data = array('in0' => 'S', 'in1' => isset($expedition_data['expedition_number']) ? $expedition_data['expedition_number'] : '', 'in2' => '', 'in3' => isset($expedition_data['reference_number']) ? $expedition_data['reference_number'] : '', 'in4' => SeurLib::getMerchantField('ccc') . '-' . SeurLib::getMerchantField('franchise'), 'in5' => !isset($expedition_data['start_date']) ? date('d-m-Y', $new_date) : $expedition_data['start_date'], 'in6' => !isset($expedition_data['end_date']) ? date('d-m-Y') : $expedition_data['end_date'], 'in7' => isset($expedition_data['order_state']) ? $expedition_data['order_state'] : '', 'in8' => '', 'in9' => '', 'in10' => '', 'in11' => '0', 'in12' => Configuration::get('SEUR_WS_USERNAME'), 'in13' => Configuration::get('SEUR_WS_PASSWORD'), 'in14' => 'N');
         $response = $soap_client->consultaListadoExpedicionesStr($data);
         if (empty($response->out)) {
             return false;
         }
     } catch (PrestaShopException $e) {
         $e->displayMessage();
     }
     return $response;
 }
    include_once _PS_MODULE_DIR_ . 'seur/classes/SeurLib.php';
}
$token = Tools::getValue('token');
$admin_token = Tools::getAdminToken('AdminSeur' . (int) Tab::getIdFromClassName('AdminSeur') . (int) Tools::getValue('id_employee'));
$admin_token_15 = Tools::getAdminToken('AdminSeur15' . (int) Tab::getIdFromClassName('AdminSeur15') . (int) Tools::getValue('id_employee'));
if ($token != $admin_token && $token != $admin_token_15) {
    exit;
}
$back = Tools::getValue('back');
if (!Validate::isUrl($back)) {
    exit;
}
try {
    $sc_options = array('connection_timeout' => 30);
    $soap_client = new SoapClient((string) Configuration::get('SEUR_URLWS_M'), $sc_options);
    $merchant_data = SeurLib::getMerchantData();
    $data = array('in0' => $merchant_data['nif_dni'], 'in1' => $merchant_data['franchise'], 'in2' => $merchant_data['user'], 'in3' => $merchant_data['pass']);
    $response = $soap_client->generacionPDFDetalleNoFecha($data);
    if ($response->out == 'NO SE PUDIERON RECUPERAR DATOS PARA LA GENERACION DEL MANIFIESTO') {
        $url = $back . '&token=' . urlencode(Tools::getValue('token')) . '&codigo=-1&error=' . urlencode((string) $response->out);
        die(Tools::redirectAdmin($url));
    } elseif ($response->out == 'ERROR USUARIO/PASSWORD ERRONEOS') {
        $url = $back . '&token=' . urlencode(Tools::getValue('token')) . '&codigo=-1&error=' . urlencode((string) $response->out);
        die(Tools::redirectAdmin($url));
    } else {
        $pdf = base64_decode($response->out);
        ob_end_clean();
        header('Content-type: application/pdf');
        header('Content-Disposition: inline; filename="manifiesto_' . date('d-m-Y') . '".pdf"');
        echo $pdf;
    }
Esempio n. 3
0
    public function hookDisplayOrderConfirmation($params)
    {
        $carrier_pos = SeurLib::getSeurCarrier('SEP');
        if ($carrier_pos['id'] != (int) $params['objOrder']->id_carrier) {
            //check if COD carrier with pickup points
            return '';
        }
        if (Db::getInstance()->getValue('
			SELECT `id_address_delivery`
			FROM `' . _DB_PREFIX_ . 'seur_order`
			WHERE `id_order` = "' . (int) $params['objOrder']->id . '"
		')) {
            return;
        }
        $customer_address = new Address((int) $params['objOrder']->id_address_delivery);
        $pickup_point_info = SeurLib::getOrderPos((int) $params['objOrder']->id_cart);
        $pickup_point_address = new Address();
        $pickup_point_address->id_country = $customer_address->id_country;
        $pickup_point_address->id_state = $customer_address->id_state;
        $pickup_point_address->alias = $customer_address->alias;
        $pickup_point_address->company = urldecode($pickup_point_info['company']);
        $pickup_point_address->lastname = $customer_address->lastname;
        $pickup_point_address->firstname = $customer_address->firstname;
        $pickup_point_address->address1 = urldecode($pickup_point_info['address']);
        $pickup_point_address->postcode = urldecode($pickup_point_info['postal_code']);
        $pickup_point_address->city = urldecode($pickup_point_info['city']);
        $pickup_point_address->phone = $customer_address->phone_mobile ? $customer_address->phone_mobile : self::DEFAULT_PUDO_MOBILE;
        $order = new Order((int) $params['objOrder']->id);
        $products = $order->getProductsDetail();
        $order_weigth = 0;
        foreach ($products as $product) {
            $order_weigth += (double) $product['product_weight'] * (double) $product['product_quantity'];
        }
        $order_weigth = $order_weigth > 1 ? $order_weigth : 1;
        if ($pickup_point_address->save()) {
            $order->id_address_delivery = (int) $pickup_point_address->id;
            if ($order->save()) {
                Db::getInstance()->Execute('
					INSERT INTO `' . _DB_PREFIX_ . 'seur_order`
					VALUES ("' . (int) $order->id . '", "1", "' . (double) $order_weigth . '", null, "0", "0", "' . (int) $pickup_point_address->id . '");');
            } else {
                Db::getInstance()->Execute('
					INSERT INTO `' . _DB_PREFIX_ . 'seur_order`
					VALUES ("' . (int) $order->id . '", "1", "' . (double) $order_weigth . '", null, "0", "0", "");');
            }
        } else {
            Db::getInstance()->Execute('
				INSERT INTO `' . _DB_PREFIX_ . 'seur_order`
				VALUES ("' . (int) $order->id . '", "1", "' . (double) $order_weigth . '", null, "0", "0", "");');
        }
    }
Esempio n. 4
0
 private static function createStates()
 {
     $ps_state_iso_code_max_length = 7;
     if (version_compare(_PS_VERSION_, '1.5', '<')) {
         $ps_state_iso_code_max_length = 4;
     }
     foreach (SeurLib::$baleares_states as $iso_code => $state_name) {
         if (Tools::strlen($iso_code) > $ps_state_iso_code_max_length) {
             $tmpArray = explode('-', $iso_code);
             $iso_code = $tmpArray[0];
             if (count($tmpArray) > 0) {
                 $iso_code = 'E' . $tmpArray[1];
             }
         }
         $exists_id = State::getIdByIso($iso_code);
         if (isset($exists_id) && !empty($exists_id)) {
             $state = new State($exists_id);
             $state->active = true;
             $state->id_zone = self::$baleares->id;
             if (!$state->update()) {
                 return false;
             }
         } else {
             $state = new State();
             $state->name = $state_name;
             $state->id_country = self::$spain->id;
             $state->id_zone = self::$baleares->id;
             $state->iso_code = $iso_code;
             $state->active = true;
             if (!$state->save()) {
                 return false;
             }
         }
     }
     foreach (SeurLib::$canarias_states as $iso_code => $state_name) {
         if (Tools::strlen($iso_code) > $ps_state_iso_code_max_length) {
             $tmpArray = explode('-', $iso_code);
             $iso_code = $tmpArray[0];
             if (count($tmpArray) > 0) {
                 $iso_code = 'E' . $tmpArray[1];
             }
         }
         $exists_id = State::getIdByIso($iso_code);
         if (isset($exists_id) && !empty($exists_id)) {
             $state = new State($exists_id);
             $state->active = true;
             $state->id_zone = self::$canarias->id;
             if (!$state->update()) {
                 return false;
             }
         } else {
             $state = new State();
             $state->name = $state_name;
             $state->id_country = self::$spain->id;
             $state->id_zone = self::$canarias->id;
             $state->iso_code = $iso_code;
             $state->active = true;
             if (!$state->save()) {
                 return false;
             }
         }
     }
     foreach (SeurLib::$ceuta_melilla_states as $iso_code => $state_name) {
         if (Tools::strlen($iso_code) > $ps_state_iso_code_max_length) {
             $tmpArray = explode('-', $iso_code);
             $iso_code = $tmpArray[0];
             if (count($tmpArray) > 0) {
                 $iso_code = 'E' . $tmpArray[1];
             }
         }
         $exists_id = State::getIdByIso($iso_code);
         if (isset($exists_id) && !empty($exists_id)) {
             $state = new State($exists_id);
             $state->id_zone = self::$ceuta_melilla->id;
             $state->active = true;
             if (!$state->update()) {
                 return false;
             }
         } else {
             $state = new State();
             $state->name = $state_name;
             $state->id_country = self::$spain->id;
             $state->id_zone = self::$ceuta_melilla->id;
             $state->iso_code = $iso_code;
             $state->active = true;
             if (!$state->save()) {
                 return false;
             }
         }
     }
     foreach (SeurLib::$spain_states as $iso_code => $state_name) {
         if (Tools::strlen($iso_code) > $ps_state_iso_code_max_length) {
             $tmpArray = explode('-', $iso_code);
             $iso_code = $tmpArray[0];
             if (count($tmpArray) > 0) {
                 $iso_code = 'E' . $tmpArray[1];
             }
         }
         $exists_id = State::getIdByIso($iso_code);
         if (isset($exists_id) && !empty($exists_id)) {
             $state = new State($exists_id);
             $state->active = true;
             if (Tools::strtoupper($state_name) == Tools::strtoupper(SeurLib::getMerchantField('state'))) {
                 $state->id_zone = self::$provincia->id;
             } else {
                 $state->id_zone = self::$peninsula->id;
             }
             if (!$state->update()) {
                 return false;
             }
         } else {
             $state = new State();
             $state->name = $state_name;
             $state->id_country = self::$spain->id;
             if (Tools::strtoupper($state_name) == Tools::strtoupper(SeurLib::getMerchantField('state'))) {
                 $state->id_zone = self::$provincia->id;
             } else {
                 $state->id_zone = self::$peninsula->id;
             }
             $state->iso_code = $iso_code;
             $state->active = true;
             if (!$state->save()) {
                 return false;
             }
         }
     }
     return true;
 }
Esempio n. 5
0
    public function displayFormDeliveries($response = null, $detail = null, $error = null)
    {
        $token = Tools::getValue('token');
        $back = Tools::safeOutput($_SERVER['REQUEST_URI']);
        $seur_order_states = array('' => $this->module_instance->l('All', self::FILENAME), '1' => $this->module_instance->l('Delivered', self::FILENAME), '2' => $this->module_instance->l('In transit', self::FILENAME), '3' => $this->module_instance->l('Incidents fixable by customer', self::FILENAME), '4' => $this->module_instance->l('Incident management SEUR', self::FILENAME), '5' => $this->module_instance->l('Returned', self::FILENAME), '6' => $this->module_instance->l('Sinister', self::FILENAME), '7' => $this->module_instance->l('Canceled', self::FILENAME));
        Tools::safePostVars();
        if (empty($_POST)) {
            $delivery_valuend_data = date('d-m-Y');
            $start_data = strtotime('-1 day', strtotime(date('Y-m-d')));
            $start_data = date('d-m-Y', $start_data);
        } else {
            $start_data = Tools::getValue('start_date');
            $delivery_valuend_data = Tools::getValue('end_date');
        }
        if ($response == null && $detail == null) {
            $tab_view = 'deliveries';
        } elseif ($response == true && $detail == null) {
            $tab_view = 'deliveries';
        } elseif ($response == true && $detail == true) {
            $tab_view = 'deliveries';
        }
        $ps_version = 'ps' . (version_compare(_PS_VERSION_, '1.5', '>=') > 1.4 ? '5' : '4');
        $img_dir = __PS_BASE_URI__ . 'modules/seur/img/';
        if (!empty($error)) {
            $this->content .= $this->module_instance->displayError($error);
        }
        if (Tools::getValue('error')) {
            $this->content .= $this->module_instance->displayError(Tools::getValue('codigo') . ' => ' . Tools::getValue('error'));
        }
        $this->content .= "<div id='contenttab'>";
        if (_PS_VERSION_ > '1.5') {
            $this->content .= "<script>\n\t\t\t\t\$( document ).ready(function() {\n\t\t\t\t\t\$('#submitFilter').click(function(){\n\t\t\t\t\t\tdocument.formfilter.submit();\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t</script>";
        }
        $this->content .= "<fieldset>\n\t\t\t\t<legend>\n\t\t\t\t\t<img src='{$img_dir}/logonew.png' />\n\t\t\t \t</legend>\n\t\t\t\t<div id='seur_module' class='{$ps_version}'>\n\t\t\t\t\t<ul class='configuration_menu'>\n\t\t\t\t\t\t<li class='button btnTab" . ($tab_view == 'deliveries' ? ' active' : '') . "' tab='deliveries'>\n\t\t\t\t\t\t\t<img src='{$img_dir}/config.png' alt=" . $this->module_instance->l('Shipments', self::FILENAME) . ' title=' . $this->module_instance->l('Shipments', self::FILENAME) . ' />
							' . $this->module_instance->l('Shipments', self::FILENAME) . "\n\t\t\t\t\t\t</li>\n\t\t\t\t\t\t<li class='button btnTab" . ($tab_view == 'packing_list' ? ' active' : '') . "' tab='packing_list'>\n\t\t\t\t\t\t\t<img src='{$img_dir}/manifest.png' alt='" . $this->module_instance->l('Packing List', self::FILENAME) . "' title='" . $this->module_instance->l('Packing List', self::FILENAME) . "' />\n\t\t\t\t\t\t\t" . $this->module_instance->l('Packing List', self::FILENAME) . "\n\t\t\t\t\t\t</li>\n\t\t\t\t\t\t<li class='button btnTab" . ($tab_view == 'pickups' ? ' active' : '') . "' tab='pickups'>\n\t\t\t\t\t\t\t<img src='{$img_dir}/recogidas.png' alt='" . $this->module_instance->l('Pickups', self::FILENAME) . "' title='" . $this->module_instance->l('Pickups', self::FILENAME) . "' />\n\t\t\t\t\t\t\t" . $this->module_instance->l('Pickups', self::FILENAME) . "\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t\t<ul class='configuration_tabs'>\n\t\t\t\t\t\t<li id='deliveries'" . ($tab_view == 'deliveries' ? ' class="default"' : '') . ">\n\t\t\t\t\t\t\t<form action='index.php?controller=" . $this->current_controller . '&submitFilter=1&token=' . $token . $this->ps14_tab . "' method='post' id='formfilter' name='formfilter'>\n\t\t\t\t\t\t\t\t<table id='deliveriesTable' class='table' cellpadding='0' cellspacing='0'>\n\t\t\t\t\t\t\t\t\t<thead>\n\t\t\t\t\t\t\t\t\t\t<tr> \n\t\t\t\t\t\t\t\t\t\t\t<th>" . $this->module_instance->l('Reference number', self::FILENAME) . '</th>
											<th>' . $this->module_instance->l('Expedition number', self::FILENAME) . '</th>
											<th>' . $this->module_instance->l('Start date', self::FILENAME) . '</th>
											<th>' . $this->module_instance->l('End date', self::FILENAME) . "</th>\n\t\t\t\t\t\t\t\t\t\t\t<th colspan='5'>" . $this->module_instance->l('Estate', self::FILENAME) . "</th>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t<tr class='filtros'>\n\t\t\t\t\t\t\t\t\t\t\t<td><input class='ps14_input' type='text' name='reference_number' value='' autocomplete='off' /></td>\n\t\t\t\t\t\t\t\t\t\t\t<td><input class='ps14_input' type='text' name='expedition_number' value='' autocomplete='off' /></td>\n\t\t\t\t\t\t\t\t\t\t\t<td><input class='ps14_input' type='text' name='start_date' id='start_date' autocomplete='off' value='" . $start_data . "'/></td>\n\t\t\t\t\t\t\t\t\t\t\t<td><input class='ps14_input' type='text' name='end_date' id='end_date' class='datepicker' autocomplete='off' value='" . $delivery_valuend_data . "'/></td>\n\t\t\t\t\t\t\t\t\t\t\t<td colspan='4'>\n\t\t\t\t\t\t\t\t\t\t\t\t<select id='order_state' name='order_state' value='' autocomplete='off'>";
        foreach ($seur_order_states as $key => $seur_order_state) {
            $this->content .= "<option value='{$key}'>{$seur_order_state}</option>";
        }
        $this->content .= "</select>\n\t\t\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t\t\t<input type='submit' value=" . $this->module_instance->l('Filter', self::FILENAME) . " name='submitFilter' id='submitFilter' class='filter' />\n\t\t\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t</thead>";
        if ($response == true && $detail == null) {
            $string_xml = htmlspecialchars_decode($response->out);
            $string_xml = str_replace('&', '&amp; ', $string_xml);
            $xml = simplexml_load_string($string_xml);
            if ($xml->DESCRIPCION) {
                $this->content .= $this->module_instance->displayError($xml->DESCRIPCION);
            } else {
                if ($xml->attributes()->NUM[0] != 0) {
                    $deliveries_data = array();
                    foreach ($xml->EXPEDICION as $delivery) {
                        $headers = array('order' => $this->module_instance->l('Order/Reference', self::FILENAME), 'expedition' => $this->module_instance->l('Expedition', self::FILENAME), 'name' => $this->module_instance->l('Name'), 'description' => $this->module_instance->l('Description', self::FILENAME), 'date' => $this->module_instance->l('Date', self::FILENAME), 'delivery' => $this->module_instance->l('Delivery', self::FILENAME), 'details' => $this->module_instance->l('Details', self::FILENAME));
                        $headersOcultas = array('EXPEDICION', 'DESTINA_PAIS' => (string) $delivery->DESTINA_PAIS);
                        $deliveries_data[] = array('Pedido/Referencia' => (string) $delivery->REMITE_REF, 'Expedicion' => (string) $delivery->EXPEDICION_NUM, 'Nombre' => (string) $delivery->DESTINA_NOMBRE, 'Descripcion' => (string) $delivery->DESCRIPCION_PARA_CLIENTE, 'date' => (string) $delivery->FECHA_CAPTURA, 'EXPEDICION' => (string) $delivery->EXPEDICION_NUM, 'Detalles' => '');
                    }
                    $this->content .= "<tbody>\n\t\t\t\t\t\t<tr class='bold'>";
                    foreach ($headers as $key => $header) {
                        $this->content .= '<th ' . ($key == 'delivery' || $key == 'details' ? 'colspan="2"' : '') . '>' . $header . '</th>';
                    }
                    $this->content .= '</tr>';
                    $line = 1;
                    $countryTo = '';
                    foreach ($deliveries_data as $delivery_data) {
                        $this->content .= '<tr ' . ($line % 2 != 0 ? 'class="alternate"' : '') . '>';
                        $delivered = false;
                        foreach ($delivery_data as $key => $delivery_value) {
                            if ($key == 'Expedicion') {
                                $delivery_number = $delivery_value;
                            }
                            $this->content .= '<td class=' . $key . ' ' . ($key == 'EXPEDICION' || $key == 'Detalles' ? 'colspan="2"' : '') . '>' . (!in_array($key, $headersOcultas) ? $delivery_value : '');
                            if ($key == 'Descripcion' && $delivery_value == 'ENTREGA EFECTUADA') {
                                $delivered = true;
                            }
                            if ($key == 'EXPEDICION' && ($countryTo == 'ES' || $countryTo == '-' || $countryTo == '') && $delivered) {
                                $this->content .= '<a href="../modules/seur/ajax/createDeliveryNote.php?back=' . $back . '&token=' . Tools::getValue('token') . '&expedition_number=' . $delivery_value . '&token=' . $token . '&id_employee=' . (int) $this->context->cookie->id_employee . '">
										<img src="' . $img_dir . '/png_ico.png" alt="' . $this->module_instance->l('Delivery', self::FILENAME) . '" title="' . $this->module_instance->l('Delivery', self::FILENAME) . '" />
									</a>
									<!--a class="verDetalles" href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&verDetalle=1&token=' . $token . '&expedition_number=' . $delivery_value . '&id_employee=' . (int) $this->context->cookie->id_employee . '"-->';
                            }
                            if ($key == 'Detalles') {
                                $this->content .= '<a class="verDetalles" href="' . __PS_BASE_URI__ . 'modules/seur/ajax/getExpeditionAjax.php?expedition_number=' . $delivery_number . '&token=' . $token . '&id_employee=' . (int) $this->context->cookie->id_employee . '">
										<img src="' . $img_dir . '/details.png" alt="' . $this->module_instance->l('See details', self::FILENAME) . '" title="' . $this->module_instance->l('See details', self::FILENAME) . '" />
									</a>';
                            }
                            $this->content .= '</td>';
                        }
                        $this->content .= '</tr>';
                        $line++;
                    }
                } else {
                    $this->content .= $this->module_instance->displayError($this->module_instance->l('No results.', self::FILENAME));
                }
                $this->content .= ' </tbody>';
            }
        }
        $this->content .= '</table>
				</form>
			</li>
			<li id="packing_list"' . ($tab_view == 'packing_list' ? '  class="default"' : '') . '>
				<table class="table" cellspacing="0" cellpadding="0">
				<thead>
					<tr>
						<th>' . $this->module_instance->l('Download today packing list', self::FILENAME) . '</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td>
							<a href="../modules/seur/ajax/createPackingList.php?back=' . $back . '&token=' . Tools::getValue('token') . '&id_employee=' . $this->context->cookie->id_employee . '" target="_blank">
							<img src="' . $img_dir . '/ico_descargar.png" alt="' . $this->module_instance->l('Packing List', self::FILENAME) . '" />' . $this->module_instance->l('Download', self::FILENAME) . '</a>
						</td>
					</tr>
				</tbody>
				</table>
			</li>';
        $this->content .= '<li id="pickups"' . ($tab_view == 'pickups' ? 'class="default"' : '') . '>
			<table class="table" cellspacing="0">
			<thead>';
        $pickup_data = Pickup::getLastPickup();
        $steady_pickup = false;
        if ($pickup_data) {
            $pickup_date = explode(' ', $pickup_data['date']);
        }
        if (SeurLib::getConfigurationField('pickup') == 1) {
            $steady_pickup = true;
        }
        if (!empty($pickup_data) && strtotime(date('Y-m-d')) == strtotime($pickup_date[0]) && !$steady_pickup) {
            $this->content .= '<tr>
						<th>' . $this->module_instance->l('Localizer', self::FILENAME) . '</th>
						<th colspan="2">' . $this->module_instance->l('Date', self::FILENAME) . '</th>
					</tr>
				</thead>
				<tbody>
					<tr >
					   <td>' . $pickup_data['localizer'] . '</td>
					   <td>' . $pickup_data['date'] . '</td>
					</tr>
				</tbody>';
        } elseif ((int) date('H') < 14 && !$steady_pickup) {
            $this->content .= '<tr>
					<td class="createpickup">
						<a href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&createPickup=1">' . $this->module_instance->l('Create pickup', self::FILENAME) . '</a>
					</td>
					</tr>';
        } elseif ($steady_pickup) {
            $this->content .= '<tr>
					<th>' . $this->module_instance->l('Fixed pickup.', self::FILENAME) . '</th>
					</tr>';
        } elseif ((int) date('H') >= 14) {
            $this->content .= '<tbody>
						<tr>
							<td>
							<p><img src="../img/admin/help2.png" /> 
							   ' . $this->module_instance->l('14H is past, to create a pickup please contact SEUR on 902101010 or via ', self::FILENAME) . '
							</p>
							<p><a href="http://www.seur.com" target="_blank">www.seur.com</a></p>
							<p>' . $this->module_instance->l('Thank you.', self::FILENAME) . '</p>
							</td>
						</tr>
						</tbody>';
        }
        $this->content .= '</thead>
					</table>
				</li>
			</ul>
		  </div>
	  </fieldset>

	  </div>';
    }
 public function hookPayment($params)
 {
     if (!$this->active || !SeurLib::getConfigurationField('seur_cod')) {
         // Cash on delivery is disabled in Seur Configuration
         return;
     }
     $address = new Address((int) $params['cart']->id_address_delivery);
     $country = new Country((int) $address->id_country);
     $seur_carrier_sen = SeurLib::getSeurCarrier('SEN');
     $seur_carrier_scn = SeurLib::getSeurCarrier('SCN');
     $seur_carrier_sce = SeurLib::getSeurCarrier('SCE');
     $cod_carriers = array($seur_carrier_scn['id'], $seur_carrier_sen['id'], $seur_carrier_sce['id']);
     if (($country->iso_code == 'ES' || $country->iso_code == 'PT' || $country->iso_code == 'AD') && in_array($params['cart']->id_carrier, $cod_carriers)) {
         $cost = (double) abs($params['cart']->getOrderTotal(true, Cart::BOTH));
         $cargo = number_format($this->getCargo($params['cart']), 2, '.', '');
         $total_con_cargo = (double) ($cost + $cargo);
         if (version_compare(_PS_VERSION_, "1.5", ">=")) {
             $this->context->smarty->assign(array('ruta' => $this->_path, 'coste' => $cost, 'cargo' => $cargo, 'total' => $total_con_cargo, 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/', 'enlace' => $this->context->link->getModuleLink('seurcashondelivery', 'validation', array(), true), 'visible' => 1));
             $id_carrier = "";
             $delivery_options_array = Tools::getValue('delivery_option');
             if (is_array($delivery_options_array)) {
                 foreach ($delivery_options_array as $id_carrier) {
                     if ($seur_carrier_scn['id'] == (int) $id_carrier || $seur_carrier_sen['id'] == (int) $id_carrier || $seur_carrier_sce['id'] == (int) $id_carrier) {
                         return $this->display(__FILE__, 'views/templates/hook/payment.tpl');
                     }
                 }
             }
             if ($id_carrier == "") {
                 if (in_array(Configuration::get('PS_CARRIER_DEFAULT'), $cod_carriers)) {
                     return $this->display(__FILE__, 'views/templates/hook/payment.tpl');
                 } else {
                     $this->context->smarty->assign('visible', 0);
                     return $this->display(__FILE__, 'views/templates/hook/payment.tpl');
                 }
             }
         } else {
             $smarty = $this->context->smarty;
             $url = $this->getModuleLink('seurcashondelivery', 'payment.php');
             $smarty->assign(array('ruta' => $this->_path, 'coste' => $cost, 'cargo' => $cargo, 'total' => $total_con_cargo, 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/', 'enlace' => $url, 'visible' => 1));
             if (in_array(Tools::getValue('id_carrier'), $cod_carriers)) {
                 return $this->display($this->path, 'views/templates/hook/payment.tpl');
             } else {
                 $this->context->smarty->assign('visible', 0);
                 return $this->display($this->path, 'views/templates/hook/payment.tpl');
             }
         }
     }
     return '';
 }
Esempio n. 7
0
    public static function createLabels($label_data, $tipo)
    {
        try {
            if (Validate::isFileName($label_data['pedido'])) {
                $label_name = $label_data['pedido'];
            } else {
                $module_instance = Module::getInstanceByName('seur');
                return SeurLib::displayErrors($label_data['pedido'] . ' ' . $module_instance->l('could not be used as file name', 'Label'));
            }
            $sc_options = array('connection_timeout' => 30);
            $soap_client = new SoapClient((string) Configuration::get('SEUR_URLWS_ET'), $sc_options);
            $merchant_data = SeurLib::getMerchantData();
            $notification = SeurLib::getConfigurationField('notification_advice_radio');
            $advice_checkbox = SeurLib::getConfigurationField('advice_checkbox');
            $distribution_checkbox = SeurLib::getConfigurationField('distribution_checkbox');
            $servicio = 31;
            $producto = 2;
            $mercancia = false;
            $claveReembolso = '';
            $valorReembolso = '';
            if (SeurLib::getConfigurationField('international_orders') == 1 && ($label_data['iso'] != 'ES' && $label_data['iso'] != 'PT' && $label_data['iso'] != 'AD')) {
                $servicio = 77;
                $producto = 70;
                $mercancia = true;
                $label_data['total_bultos'] = 1;
            }
            if (isset($label_data['reembolso']) && ($label_data['iso'] == 'ES' || $label_data['iso'] == 'PT' || $label_data['iso'] == 'AD')) {
                $claveReembolso = 'f';
                $valorReembolso = (double) $label_data['reembolso'];
            }
            if (isset($label_data['cod_centro']) && ($label_data['iso'] == 'ES' || $label_data['iso'] == 'PT' || $label_data['iso'] == 'AD')) {
                $servicio = 1;
                $producto = 48;
            }
            $total_weight = $label_data['total_kilos'];
            $total_packages = $label_data['total_bultos'];
            $pesoBulto = $total_weight / $total_packages;
            if ($pesoBulto < 1) {
                $pesoBulto = 1;
                $total_weight = $total_packages;
            }
            $cont = 0;
            $xml = '<?xml version="1.0" encoding="ISO-8859-1"?><root><exp>';
            for ($i = 0; $i <= (double) $total_packages - 1; $i++) {
                $cont++;
                $xml .= '<bulto>
							<ci>' . (int) $merchant_data['cit'] . '</ci>
							<nif>' . pSQL($merchant_data['nif_dni']) . '</nif>
							<ccc>' . (int) $merchant_data['ccc'] . '</ccc>
							<servicio>' . pSQL($servicio) . '</servicio>
							<producto>' . pSQL($producto) . '</producto>';
                if ($mercancia) {
                    $xml .= '<id_mercancia>382</id_mercancia>';
                }
                $xml .= '<cod_centro></cod_centro>
							<total_bultos>' . pSQL($total_packages) . '</total_bultos>
							<total_kilos>' . pSQL($total_weight) . '</total_kilos>
							<pesoBulto>' . pSQL($pesoBulto) . '</pesoBulto>
							<observaciones>' . pSQL($label_data['info_adicional']) . '</observaciones>
							<referencia_expedicion>' . pSQL($label_data['pedido']) . '</referencia_expedicion>
							<ref_bulto>' . pSQL($label_data['pedido'] . sprintf('%03d', (int) $i + 1)) . '</ref_bulto>
							<clavePortes>F</clavePortes>
							<clavePod></clavePod>
							<claveReembolso>' . pSQL($claveReembolso) . '</claveReembolso>
							<valorReembolso>' . pSQL($valorReembolso) . '</valorReembolso>
							<libroControl></libroControl>
							<nombre_consignatario>' . pSQL($label_data['name']) . '</nombre_consignatario>
							<direccion_consignatario>' . pSQL($label_data['direccion_consignatario']) . '</direccion_consignatario>
							<tipoVia_consignatario>CL</tipoVia_consignatario>
							<tNumVia_consignatario>N</tNumVia_consignatario>
							<numVia_consignatario>.</numVia_consignatario>
							<escalera_consignatario>.</escalera_consignatario>
							<piso_consignatario>.</piso_consignatario>
							<puerta_consignatario>.</puerta_consignatario>
							<poblacion_consignatario>' . pSQL($label_data['consignee_town']) . '</poblacion_consignatario>';
                if (!empty($label_data['codPostal_consignatario'])) {
                    $xml .= '<codPostal_consignatario>' . pSQL($label_data['codPostal_consignatario']) . '</codPostal_consignatario>';
                }
                $xml .= '   <pais_consignatario>' . pSQL($label_data['iso']) . '</pais_consignatario>
							<codigo_pais_origen>' . pSQL($label_data['iso_merchant']) . '</codigo_pais_origen>
							<email_consignatario>' . pSQL($label_data['email_consignatario']) . '</email_consignatario>
							<sms_consignatario>' . ((int) $notification ? pSQL($label_data['movil']) : '') . '</sms_consignatario>
							<test_sms>' . ((int) $notification ? 'S' : 'N') . '</test_sms>
							<test_preaviso>' . ((int) $advice_checkbox ? 'S' : 'N') . '</test_preaviso>
							<test_reparto>' . ((int) $distribution_checkbox ? 'S' : 'N') . '</test_reparto>
							<test_email>' . ((int) $notification ? 'N' : 'S') . '</test_email>
							<eci>N</eci>
							<et>N</et>
							<telefono_consignatario>' . pSQL($label_data['telefono_consignatario']) . '</telefono_consignatario>
							<atencion_de>' . pSQL($label_data['companyia']) . '</atencion_de>
						 </bulto>
						 ';
            }
            $xml .= '</exp></root>';
            $xml_name = (int) $merchant_data['franchise'] . '_' . (int) $merchant_data['cit'] . '_' . date('dmYHi') . '.xml';
            $make_pickup = false;
            $auto = false;
            $pickup_data = Pickup::getLastPickup();
            if (!empty($pickup_data)) {
                $datepickup = explode(' ', $pickup_data['date']);
                $datepickup = $datepickup[0];
                if (strtotime(date('Y-m-d')) != strtotime($datepickup)) {
                    $make_pickup = true;
                }
                if (SeurLib::getConfigurationField('pickup') == 0) {
                    $auto = true;
                }
            }
            if ($tipo == 'pdf') {
                $data = array('in0' => $merchant_data['user'], 'in1' => $merchant_data['pass'], 'in2' => $xml, 'in3' => $xml_name, 'in4' => $merchant_data['nif_dni'], 'in5' => $merchant_data['franchise'], 'in6' => '-1', 'in7' => 'prestashop');
                $response = $soap_client->impresionIntegracionPDFConECBWS($data);
                if ($response->out == 'ERROR') {
                    return SeurLib::displayErrors((string) $response->out);
                }
                if ($response->out->mensaje != 'OK') {
                    return SeurLib::displayErrors((string) $response->out->mensaje);
                } else {
                    $pdf = base64_decode($response->out->PDF);
                    if (is_writable(_PS_MODULE_DIR_ . 'seur/files/deliveries_labels/')) {
                        file_put_contents(_PS_MODULE_DIR_ . 'seur/files/deliveries_labels/' . $label_name . '.pdf', $pdf);
                    }
                    SeurLib::setSeurOrder($label_data['pedido'], $total_packages, $total_weight, 'PDF');
                    if ($make_pickup && $auto) {
                        Pickup::createPickup();
                    }
                }
            } elseif ($tipo == 'zebra') {
                $data = array('in0' => pSQL($merchant_data['user']), 'in1' => pSQL($merchant_data['pass']), 'in2' => 'ZEBRA', 'in3' => 'LP2844-Z', 'in4' => '2C', 'in5' => $xml, 'in6' => $xml_name, 'in7' => pSQL($merchant_data['nif_dni']), 'in8' => pSQL($merchant_data['franchise']), 'in9' => '-1', 'in10' => 'prestashop');
                $response = $soap_client->impresionIntegracionConECBWS($data);
                if ($response->out == 'ERROR' || $response->out->mensaje != 'OK') {
                    return SeurLib::displayErrors('Error al crear el envio y la etiqueta: ' . $response->out->mensaje);
                } else {
                    if (is_writable(_PS_MODULE_DIR_ . 'seur/files/deliveries_labels/')) {
                        file_put_contents(_PS_MODULE_DIR_ . 'seur/files/deliveries_labels/' . pSQL($label_name) . '.txt', (string) $response->out->traza);
                    }
                    SeurLib::setSeurOrder(pSQL($label_data['pedido']), (double) $total_packages, (double) $total_weight, 'zebra');
                    if ($make_pickup && $auto) {
                        Pickup::createPickup();
                    }
                }
            }
        } catch (PrestaShopException $e) {
            $e->displayMessage();
        }
        return true;
    }
Esempio n. 8
0
    public static function createPickup()
    {
        if ((int) date('H') < '14') {
            try {
                $sc_options = array('connection_timeout' => 30);
                $soap_client = new SoapClient((string) Configuration::get('SEUR_URLWS_R'), $sc_options);
                $merchant_data = SeurLib::getMerchantData();
                if (!isset($merchant_data['street_number'])) {
                    return false;
                }
                $numeroVia = filter_var($merchant_data['street_number'], FILTER_SANITIZE_NUMBER_INT);
                $plano = '
					<recogida>
						<usuario>' . Configuration::get('SEUR_WS_USERNAME') . '</usuario>
						<password>' . Configuration::get('SEUR_WS_PASSWORD') . '</password>
						<razonSocial>' . pSQL($merchant_data['company_name']) . '</razonSocial>
						<nombreEmpresa>' . pSQL($merchant_data['company_name']) . '</nombreEmpresa>
						<nombreContactoOrdenante>' . pSQL($merchant_data['name']) . '</nombreContactoOrdenante>
						<apellidosContactoOrdenante>' . pSQL($merchant_data['first_name']) . '</apellidosContactoOrdenante>
						<prefijoTelefonoOrdenante>34</prefijoTelefonoOrdenante>
						<telefonoOrdenante>' . pSQL($merchant_data['phone']) . '</telefonoOrdenante>
						<prefijoFaxOrdenante />
						<faxOrdenante />
						<nifOrdenante>' . pSQL($merchant_data['nif_dni']) . '</nifOrdenante>
						<paisNifOrdenante>ES</paisNifOrdenante>
						<mailOrdenante>' . pSQL($merchant_data['email']) . '</mailOrdenante>
						<tipoViaOrdenante>' . pSQL($merchant_data['street_type']) . '</tipoViaOrdenante>
						<calleOrdenante>' . pSQL($merchant_data['street_name']) . '</calleOrdenante>
						<tipoNumeroOrdenante>N.</tipoNumeroOrdenante>
						<numeroOrdenante>' . pSQL($numeroVia) . '</numeroOrdenante>
						<escaleraOrdenante />
						<pisoOrdenante />
						<puertaOrdenante />
						<codigoPostalOrdenante>' . pSQL($merchant_data['post_code']) . '</codigoPostalOrdenante>
						<poblacionOrdenante>' . pSQL($merchant_data['town']) . '</poblacionOrdenante>
						<provinciaOrdenante>' . pSQL($merchant_data['state']) . '</provinciaOrdenante>
						<paisOrdenante>' . pSQL($merchant_data['country']) . '</paisOrdenante>

						<diaRecogida>' . pSQL(sprintf('%02d', date('d'))) . '</diaRecogida>
						<mesRecogida>' . date('m') . '</mesRecogida>
						<anioRecogida>' . date('Y') . '</anioRecogida>
						<servicio>1</servicio>
						<horaMananaDe></horaMananaDe>
						<horaMananaA></horaMananaA>
						<numeroBultos>1</numeroBultos>
						<mercancia>2</mercancia>
						<horaTardeDe>16:00</horaTardeDe>
						<horaTardeA>20:00</horaTardeA>
						<tipoPorte>P</tipoPorte>
						<observaciones></observaciones>
						<tipoAviso>EMAIL</tipoAviso>
						<idiomaContactoOrdenante>' . pSQL($merchant_data['country']) . '</idiomaContactoOrdenante>

						<razonSocialDestino>' . pSQL($merchant_data['company_name']) . '</razonSocialDestino>
						<nombreContactoDestino>' . pSQL($merchant_data['name']) . '</nombreContactoDestino>
						<apellidosContactoDestino>' . pSQL($merchant_data['first_name']) . '</apellidosContactoDestino>
						<telefonoDestino>' . pSQL($merchant_data['phone']) . '</telefonoDestino>
						<tipoViaDestino>' . pSQL($merchant_data['street_type']) . '</tipoViaDestino>
						<calleDestino>' . pSQL($merchant_data['street_name']) . '</calleDestino>
						<tipoNumeroDestino>N.</tipoNumeroDestino>
						<numeroDestino>' . pSQL($numeroVia) . '</numeroDestino>
						<escaleraDestino />
						<pisoDestino />
						<puertaDestino />
						<codigoPostalDestino>' . pSQL($merchant_data['post_code']) . '</codigoPostalDestino>
						<poblacionDestino>' . pSQL($merchant_data['town']) . '</poblacionDestino>
						<provinciaDestino>' . pSQL($merchant_data['state']) . '</provinciaDestino>
						<paisDestino>' . pSQL($merchant_data['country']) . '</paisDestino>
						<prefijoTelefonoDestino>34</prefijoTelefonoDestino>

						<razonSocialOrigen>' . pSQL($merchant_data['company_name']) . '</razonSocialOrigen>
						<nombreContactoOrigen>' . pSQL($merchant_data['name']) . '</nombreContactoOrigen>
						<apellidosContactoOrigen>' . pSQL($merchant_data['first_name']) . '</apellidosContactoOrigen>
						<telefonoRecogidaOrigen>' . pSQL($merchant_data['phone']) . '</telefonoRecogidaOrigen>
						<tipoViaOrigen>' . pSQL($merchant_data['street_type']) . '</tipoViaOrigen>
						<calleOrigen>' . pSQL($merchant_data['street_name']) . '</calleOrigen>
						<tipoNumeroOrigen>N.</tipoNumeroOrigen>
						<numeroOrigen>' . pSQL($numeroVia) . '</numeroOrigen>
						<escaleraOrigen />
						<pisoOrigen />
						<puertaOrigen />
						<codigoPostalOrigen>' . pSQL($merchant_data['post_code']) . '</codigoPostalOrigen>
						<poblacionOrigen>' . pSQL($merchant_data['town']) . '</poblacionOrigen>
						<provinciaOrigen>' . pSQL($merchant_data['state']) . '</provinciaOrigen>
						<paisOrigen>' . pSQL($merchant_data['country']) . '</paisOrigen>
						<prefijoTelefonoOrigen>34</prefijoTelefonoOrigen>

						<producto>2</producto>
						<entregaSabado>N</entregaSabado>
						<entregaNave>N</entregaNave>
						<tipoEnvio>N</tipoEnvio>
						<valorDeclarado>0</valorDeclarado>
						<listaBultos>1;1;1;1;1/</listaBultos>
						<cccOrdenante>' . pSQL($merchant_data['ccc']) . '-' . pSQL($merchant_data['franchise']) . '</cccOrdenante>
						<numeroReferencia></numeroReferencia>
						<ultimaRecogidaDia />
						<nifOrigen></nifOrigen>
						<paisNifOrigen></paisNifOrigen>
						<aviso>N</aviso>
						<cccDonde />
						<cccAdonde></cccAdonde>
						<tipoRecogida></tipoRecogida>
					 </recogida>
			   ';
                $data = array('in0' => utf8_encode($plano));
                $response = $soap_client->crearRecogida($data);
                $string_xml = htmlspecialchars_decode($response->out);
                $xml = simplexml_load_string($string_xml);
                if (!empty($xml->DESCRIPCION)) {
                    return (string) $xml->DESCRIPCION;
                } elseif (!self::insertPickup((int) $xml->LOCALIZADOR, (string) $xml->NUM_RECOGIDA, (double) $xml->TASACION)) {
                    return 'Error en base de datos.';
                }
                // @TODO check if must be translatable
                Configuration::updateValue('SEUR_CONFIGURATION_OK', true);
            } catch (PrestaShopException $e) {
                $e->displayMessage();
            }
        } else {
            $module_instance = Module::getInstanceByName('seur');
            $module_instance->adminDisplayWarning($module_instance->l('Pickups after 2pm cannot be arranged via module, contact us by phone to arrange it manually.'));
        }
    }
Esempio n. 9
0
    public static function newUser()
    {
        try {
            $nif_dni = utf8_decode(Tools::getValue('nif_dni'));
            $nif_dni = preg_replace('([^A-Za-z0-9])', '', $nif_dni);
            $sc_options = array('connection_timeout' => 30);
            $soap_client = new SoapClient((string) Configuration::get('SEUR_URLWS_SP'), $sc_options);
            $plano = '<peticion>
				<p_nif>' . pSQL($nif_dni) . '</p_nif>
				<p_franquicia>' . pSQL(Tools::getValue('franchise_cfg')) . '</p_franquicia>
				<p_ccc>' . pSQL(Tools::getValue('ccc_cfg')) . '-' . pSQL(Tools::getValue('franchise_cfg')) . '</p_ccc>
				<razon_social>' . pSQL(Tools::getValue('company_name')) . '</razon_social>
				<p_nombre>' . pSQL(Tools::getValue('name')) . '</p_nombre>
				<p_apellidos>' . pSQL(Tools::getValue('first_name')) . '</p_apellidos>
				<p_tipo_via>' . pSQL(Tools::getValue('street_type')) . '</p_tipo_via>
				<p_nom_via>' . pSQL(Tools::getValue('street_name')) . '</p_nom_via>
				<p_tipo_num_via>N.</p_tipo_num_via>
				<p_numero>' . pSQL(Tools::getValue('street_number')) . '</p_numero>
				<p_escalera>' . pSQL(Tools::getValue('staircase')) . '</p_escalera>
				<p_piso>' . pSQL(Tools::getValue('floor')) . '</p_piso>
				<p_puerta>' . pSQL(Tools::getValue('door')) . '</p_puerta>
				<p_poblacion>' . pSQL(Tools::getValue('town_cfg')) . '</p_poblacion>
				<p_provincia>' . pSQL(Tools::getValue('state_cfg')) . '</p_provincia>
				<p_cp>' . pSQL(Tools::getValue('post_code_cfg')) . '</p_cp>
				<p_pais>' . pSQL(Tools::getValue('country_cfg')) . '</p_pais>
				<p_telefono>' . pSQL(Tools::getValue('phone')) . '</p_telefono>
				<p_fax>' . pSQL(Tools::getValue('fax')) . '</p_fax>
				<p_email>' . pSQL(Tools::getValue('email')) . '</p_email>
				<p_tipo_ecommerce>4</p_tipo_ecommerce>
				<usuario>' . Configuration::get('SEUR_WS_USERNAME') . '</usuario>
				<password>' . Configuration::get('SEUR_WS_PASSWORD') . '</password>
			</peticion>';
            $data = array('in0' => Tools::strtoupper($plano));
            $user = $pass = $ccc = '';
            $cit = 0;
            $success = false;
            $response = $soap_client->creacionClienteIntegradoStr($data);
            $string_xml = htmlspecialchars_decode($response->out);
            $xml = simplexml_load_string($string_xml);
            if (!empty($xml->REG1->DESCRIPCION_ERROR)) {
                $user = Tools::isSubmit('user_cfg') ? Tools::getValue('user_cfg') : '';
                $pass = Tools::isSubmit('pass_cfg') ? Tools::getValue('pass_cfg') : '';
                $ccc = Tools::isSubmit('ccc_cfg') ? Tools::getValue('ccc_cfg') : '';
                $cit = Tools::isSubmit('ci') ? Tools::getValue('ci') : '';
                if (!SeurLib::setMerchantField('user', $user) || !SeurLib::setMerchantField('pass', $pass) || !SeurLib::setMerchantField('ccc', $ccc || !SeurLib::setMerchantField('cit', $cit))) {
                    return -2;
                }
                return $xml->REG1->DESCRIPCION_ERROR;
            }
            $user = (string) $xml->REG1->USUARIO_CIT;
            $pass = (string) $xml->REG1->CLAVE_CONEX__CIT;
            $ccc = (string) $xml->REG1->COD_CLIENTE_CCC;
            $cit = (int) $xml->REG1->COD_CLIENTE_CIT;
            if (Tools::strlen($user) > 0 && Tools::strlen($pass) > 0 && Tools::strlen($ccc) > 0 && $cit > 0) {
                $success = true;
            }
            if ($success == false) {
                return -1;
            }
        } catch (PrestaShopException $e) {
            $e->displayMessage();
        }
        $ccc = explode('-', $ccc);
        if (!SeurLib::setMerchantField('user', $user) || !SeurLib::setMerchantField('pass', $pass) || !SeurLib::setMerchantField('ccc', $ccc[0]) || !SeurLib::setMerchantField('cit', $cit)) {
            return -2;
        }
        $emailData = array('{nif_dni}' => $nif_dni, '{franquicia}' => Tools::getValue('franchise_cfg'), '{ccc}' => Tools::getValue('ccc_cfg') . '-' . Tools::getValue('franchise_cfg'), '{razon_social}' => Tools::getValue('company_name'), '{nombre}' => Tools::getValue('name'), '{apellidos}' => Tools::getValue('first_name'), '{tipo_via}' => Tools::getValue('street_type'), '{nombre_via}' => Tools::getValue('street_name'), '{numero_via}' => Tools::getValue('street_number'), '{escalera}' => Tools::getValue('staircase'), '{piso}' => Tools::getValue('floor'), '{puerta}' => Tools::getValue('door'), '{poblacion}' => Tools::getValue('town_cfg'), '{provincia}' => Tools::getValue('state_cfg'), '{cp}' => Tools::getValue('post_code_cfg'), '{pais}' => Tools::getValue('country_cfg'), '{telefono}' => Tools::getValue('phone'), '{fax}' => Tools::getValue('fax'), '{COD_CLIENTE_CIT}' => $cit, '{USUARIO_CIT}' => $user, '{email}' => Tools::getValue('email'));
        $emailSubject = 'Alta Prestashop;FRQ:' . Tools::getValue('franchise_cfg') . ';NIF:' . $nif_dni . ';CI:' . $cit . ';CCC:' . Tools::getValue('ccc_cfg') . '';
        $emailTemplate = _PS_MODULE_DIR_ . '/seur/mails/';
        $email = '*****@*****.**';
        $id_email_language = self::getIdEmailLanguage();
        if ($id_email_language && !Mail::Send((int) $id_email_language, 'seur', $emailSubject, $emailData, $email, null, null, null, null, null, $emailTemplate)) {
            $module_instance = Module::getInstanceByName('seur');
            Context::getContext()->smarty->assign(array('email_warning_message' => $module_instance->l('Email could not be sent', self::FILENAME), 'module_instance' => $module_instance));
        }
        return 1;
    }
require_once dirname(__FILE__) . '/../../../config/config.inc.php';
require_once dirname(__FILE__) . '/../../../init.php';
if (class_exists('SeurLib') == false) {
    include_once _PS_MODULE_DIR_ . 'seur/classes/SeurLib.php';
}
$token = Tools::getValue('token');
$admin_token = Tools::getAdminToken('AdminSeur' . (int) Tab::getIdFromClassName('AdminSeur') . (int) Tools::getValue('id_employee'));
if ($token != $admin_token) {
    exit;
}
$module_instance = Module::getInstanceByName('seur');
try {
    $sc_options = array('connection_timeout' => 30);
    $soap_client = new SoapClient((string) Configuration::get('SEUR_URLWS_E'), $sc_options);
    $nuevadate = strtotime('-15 days', strtotime(date('Y-m-d')));
    $data_merchant = SeurLib::getMerchantData();
    $data = array('in0' => 'S', 'in1' => Tools::getValue('expedition_number') ? pSQL(Tools::getValue('expedition_number')) : '', 'in2' => '', 'in3' => Tools::getValue('reference_number') ? pSQL(Tools::getValue('reference_number')) : '', 'in4' => pSQL($data_merchant['ccc']) . '-' . pSQL($data_merchant['franchise']), 'in5' => !Tools::getValue('start_date') ? date('d-m-Y', $nuevadate) : Tools::getValue('start_date'), 'in6' => !Tools::getValue('end_date') ? date('d-m-Y', $nuevadate) : Tools::getValue('end_date'), 'in7' => Tools::getValue('order_state') ? Tools::getValue('order_state') : '', 'in8' => '', 'in9' => '', 'in10' => '', 'in11' => '', 'in12' => Configuration::get('SEUR_WS_USERNAME'), 'in13' => Configuration::get('SEUR_WS_PASSWORD'), 'in14' => 'N');
    $response = $soap_client->consultaListadoExpedicionesStr($data);
    if (empty($response->out)) {
        echo SeurLib::displayErrors($module_instance->l('No results.', 'getExpeditionAjax'));
        return false;
    }
    $string_xml = htmlspecialchars_decode($response->out);
    $xml = simplexml_load_string($string_xml);
    $delivery = $xml->EXPEDICION;
    $context = Context::getContext();
    $context->smarty->assign('delivery', $delivery);
    $context->smarty->display(_PS_MODULE_DIR_ . 'seur/views/templates/admin/get_expedition.tpl');
} catch (PrestaShopException $e) {
    $e->displayMessage();
}