public function initContent() { $admin_seur = new AdminSeur(false); if (!$admin_seur->module_enabled_and_configured) { $admin_seur->displayModuleConfigurationWarning(); $this->content = $admin_seur->content; return parent::initContent(); } $this->display = 'view'; $this->module_instance = Module::getInstanceByName('seur'); Context::getContext()->controller->addJqueryUI('ui.datepicker'); if (Tools::getValue('verDetalle')) { $response = Expedition::getExpeditions($admin_seur->getExpeditionData()); $this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries($response, true)); } elseif (Tools::getValue('createPickup')) { $error_response = Pickup::createPickup(); if (!empty($error_response)) { $this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries(null, null, $error_response)); } else { $this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries()); } } elseif (Tools::getValue('submitFilter')) { $response = Expedition::getExpeditions($admin_seur->getExpeditionData()); $this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries($response, false)); } else { $this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries()); } $this->content = $admin_seur->content; $this->fields_list = $admin_seur->fields_list; parent::initContent(); }
public function hookAdminOrder($params) { $versionSpecialClass = ''; if (!file_exists(_PS_MODULE_DIR_ . 'seur/img/logonew_32.png') && file_exists(_PS_MODULE_DIR_ . 'seur/img/logonew.png')) { ImageManager::resize(_PS_MODULE_DIR_ . 'seur/img/logonew.png', _PS_MODULE_DIR_ . 'seur/img/logonew_32.png', 32, 32, 'png'); } if (version_compare(_PS_VERSION_, '1.5', '<')) { $versionSpecialClass = 'ver14'; } $this->displayWarning(); if (Configuration::get('SEUR_Configured') == 1) { $cookie = $this->context->cookie; $token = Tools::getValue('token'); $back = Tools::safeOutput($_SERVER['REQUEST_URI']); $seur_carriers = SeurLib::getSeurCarriers(false); $ids_seur_carriers = array(); foreach ($seur_carriers as $value) { $ids_seur_carriers[] = (int) $value['id']; } $order = new Order((int) $params['id_order']); $address_saved = DB::getInstance()->getValue(' SELECT `id_address_delivery` FROM `' . _DB_PREFIX_ . 'seur_order` WHERE `id_order` = "' . (int) $order->id . '" '); if ($address_saved === '0') { $this->context->smarty->assign('pickup_point_warning', true); } if (!Validate::isLoadedObject($order)) { return false; } $delivery_price = $order_weigth = 0; $products = $order->getProductsDetail(); foreach ($products as $product) { $order_weigth += (double) $product['product_weight'] * (double) $product['product_quantity']; } $order_weigth = $order_weigth < 1.0 ? 1.0 : (double) $order_weigth; $customer = new Customer((int) $order->id_customer); $address_delivery = new Address((int) $order->id_address_delivery, (int) $cookie->id_lang); if (!Validate::isLoadedObject($address_delivery)) { return false; } $iso_country = Country::getIsoById((int) $address_delivery->id_country); if ($iso_country == 'PT') { $post_code = explode(' ', $address_delivery->postcode); $post_code = $post_code[0]; } else { $post_code = $address_delivery->postcode; } $international_orders = SeurLib::getConfigurationField('international_orders'); $date_calculate = strtotime('-14 day', strtotime(date('Y-m-d'))); $date_display = date('Y-m-d H:m:i', $date_calculate); if (strtotime($order->date_add) > strtotime($date_display) && in_array((int) $order->id_carrier, $ids_seur_carriers)) { if (!$international_orders && ($iso_country == 'ES' || $iso_country == 'PT' || $iso_country == 'AD') || $international_orders) { if (!SeurLib::getSeurOrder((int) $order->id)) { SeurLib::setSeurOrder((int) $order->id, 1, $order_weigth, null); } elseif (Tools::getValue('numBultos') && Tools::getValue('pesoBultos')) { SeurLib::setSeurOrder((int) $order->id, (int) Tools::getValue('numBultos'), str_replace(',', '.', Tools::getValue('pesoBultos')), null); } $order_data = SeurLib::getSeurOrder((int) $order->id); $response_post_code = Town::getTowns($post_code); $order_weigth = (double) $order_weigth != $order_data['peso_bultos'] ? (double) $order_data['peso_bultos'] : (double) $order_weigth; if (is_object($response_post_code)) { $towns = array(); $num = (int) $response_post_code->attributes()->NUM[0]; for ($i = 1; $i <= $num; $i++) { $name = 'REG' . $i; $towns[] = utf8_decode((string) $response_post_code->{$name}->NOM_POBLACION); } } $name = $address_delivery->firstname . ' ' . $address_delivery->lastname; $direccion = $address_delivery->address1 . ' ' . $address_delivery->address2; $newcountry = new Country((int) $address_delivery->id_country, (int) $cookie->id_lang); $iso_merchant = SeurLib::getMerchantField('country'); $rate_data = array('town' => $address_delivery->city, 'peso' => (double) $order_weigth, 'post_code' => $post_code, 'bultos' => $order_data['numero_bultos'], 'ccc' => SeurLib::getMerchantField('ccc'), 'franchise' => SeurLib::getMerchantField('franchise'), 'iso' => $newcountry->iso_code, 'iso_merchant' => $iso_merchant, 'id_employee' => $cookie->id_employee, 'token' => Tools::getAdminTokenLite('AdminOrders'), 'back' => $back); $order_messages_str = ''; $info_adicional_str = $address_delivery->other; $order_messages = Message::getMessagesByOrderId((int) $params['id_order']); if (is_array($order_messages)) { foreach ($order_messages as $order_messag_tmp) { $order_messages_str .= "\n" . $order_messag_tmp['message']; } if (substr_count($order_messages_str, "\n") > 5) { $order_messages_str = str_replace(array("\r", "\n"), ' | ', $order_messages_str); } if (Tools::strlen($order_messages_str) > 250) { $order_messages_str = Tools::substr($order_messages_str, 0, 247) . '...'; } $order_messages_str = trim($order_messages_str); } if (!empty($order_messages_str)) { $info_adicional_str = $order_messages_str; } $label_data = array('pedido' => sprintf('%06d', (int) $order->id), 'total_bultos' => $order_data['numero_bultos'], 'total_kilos' => (double) $order_weigth, 'direccion_consignatario' => $direccion, 'consignee_town' => $address_delivery->city, 'codPostal_consignatario' => $post_code, 'telefono_consignatario' => !empty($address_delivery->phone_mobile) ? $address_delivery->phone_mobile : $address_delivery->phone, 'movil' => $address_delivery->phone_mobile, 'name' => $name, 'companyia' => !empty($address_delivery->company) ? $address_delivery->company : '', 'email_consignatario' => Validate::isLoadedObject($customer) ? $customer->email : '', 'dni' => $address_delivery->dni, 'info_adicional' => $info_adicional_str, 'country' => $newcountry->name, 'iso' => $newcountry->iso_code, 'iso_merchant' => $iso_merchant, 'admin_dir' => utf8_encode(_PS_ADMIN_DIR_), 'id_employee' => $cookie->id_employee, 'token' => Tools::getAdminTokenLite('AdminOrders'), 'back' => $back); if (strcmp($order->module, 'seurcashondelivery') == 0) { $rate_data['reembolso'] = (double) $order->total_paid; $label_data['reembolso'] = (double) $order->total_paid; } $carrier_pos = SeurLib::getSeurCarrier('SEP'); $datospos = ''; if ((int) $order->id_carrier == $carrier_pos['id']) { $datospos = SeurLib::getOrderPos((int) $order->id_cart); if (!empty($datospos)) { $label_data = array('pedido' => sprintf('%06d', (int) $order->id), 'total_bultos' => $order_data['numero_bultos'], 'total_kilos' => (double) $order_weigth, 'direccion_consignatario' => $direccion, 'consignee_town' => $datospos['city'], 'codPostal_consignatario' => $datospos['postal_code'], 'telefono_consignatario' => !empty($address_delivery->phone_mobile) ? $address_delivery->phone_mobile : $address_delivery->phone, 'movil' => $address_delivery->phone_mobile, 'name' => $name, 'companyia' => $datospos['company'], 'email_consignatario' => Validate::isLoadedObject($customer) ? $customer->email : '', 'dni' => $address_delivery->dni, 'info_adicional' => $info_adicional_str, 'country' => $newcountry->name, 'iso' => $newcountry->iso_code, 'cod_centro' => $datospos['id_seur_pos'], 'iso_merchant' => $iso_merchant); $rate_data['cod_centro'] = $datospos['id_seur_pos']; } } if ($iso_country == 'ES' || $iso_country == 'PT' || $iso_country == 'AD') { $xml = Rate::getPrivateRate($rate_data); if (is_object($xml)) { foreach ($xml as $tarifa) { $delivery_price += (double) $tarifa->VALOR; } } } if (Tools::getValue('submitLabel')) { if ($this->isPrinted((int) $order->id)) { $success = true; } else { $success = Label::createLabels($label_data, 'pdf'); } if ($success === true) { if (!$this->setAsPrinted((int) $order->id)) { $this->context->smarty->assign('error', $this->l('Could not set printed value for this order')); } else { $this->printLabel((int) $order->id, 'pdf'); } } else { $this->context->smarty->assign('error', $success); } } if (Tools::getValue('submitPrint')) { if ($this->isPrinted((int) $order->id, true)) { $success = true; } else { $success = Label::createLabels($label_data, 'zebra'); } if ($success === true) { if (!$this->setAsPrinted((int) $order->id, true)) { $this->context->smarty->assign('error', $this->l('Could not set printed value for this order')); } else { $this->printLabel((int) $order->id, 'txt'); } } else { $this->context->smarty->assign('error', $success); } } $seur_carriers = SeurLib::getSeurCarriers(false); $pickup = Pickup::getLastPickup(); if (!empty($pickup)) { $pickup_date = explode(' ', $pickup['date']); $pickup_date = $pickup_date[0]; } $address_error = 0; if (!empty($towns) && !in_array(mb_strtoupper($this->replaceAccentedChars($address_delivery->city), 'UTF-8'), $towns)) { $address_error = 1; } $pickup_s = 0; if ($pickup && strtotime(date('Y-m-d')) == strtotime($pickup_date)) { $pickup_s = 1; } $state = Expedition::getExpeditions(array('reference_number' => sprintf('%06d', (int) $order->id))); $is_empty_state = false; $xml_s = false; if (!empty($state->out)) { $is_empty_state = true; } else { $string_xml = htmlspecialchars_decode($state->out); $string_xml = str_replace('&', '& ', $string_xml); $xml_s = simplexml_load_string($string_xml); } $rate_data_ajax = Tools::jsonEncode($rate_data); $path = '../modules/seur/js/'; $file = (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/seur/files/deliveries_labels/' . sprintf('%06d', (int) $order->id) . '.txt'; $filePath = _PS_MODULE_DIR_ . 'seur/files/deliveries_labels/' . sprintf('%06d', (int) $order->id) . '.txt'; $label_data['file'] = $file; $this->context->smarty->assign(array('path' => $this->_path, 'request_uri' => $_SERVER['REQUEST_URI'], 'module_instance' => $this, 'address_error' => $address_error, 'address_error_message' => $this->l('Addressess error, please check the customer address.'), 'pickup_s' => $pickup_s, 'pickup' => $pickup, 'isEmptyState' => $is_empty_state, 'xml' => $xml_s, 'order_data' => $order_data, 'iso_country' => $iso_country, 'order_weigth' => $order_weigth, 'delivery_price' => $delivery_price, 'rate_data_ajax' => $rate_data_ajax, 'js_path' => $path, 'token' => $token, 'order' => $order, 'label_data' => $label_data, 'fileExists' => file_exists($filePath), 'file' => $file, 'datospos' => $datospos, 'versionSpecialClass' => $versionSpecialClass, 'configured' => (int) Configuration::get('SEUR_Configured'), 'printed' => (bool) ($this->isPrinted((int) $order->id) || $this->isPrinted((int) $order->id, true)))); return $this->display(__FILE__, 'views/templates/admin/orders.tpl'); } } } else { $this->context->smarty->assign(array('configured' => Configuration::get('SEUR_Configured'), 'path' => $this->_path, 'configuration_warning_message' => $this->l('Please, first configure your SEUR module as a merchant.'))); return $this->display(__FILE__, 'views/templates/admin/orders.tpl'); } }
//All cases $case1 = $meetdt != 0 && $duedate < time() && $duedate != 0; //And the item is on a return basis $case2 = $meetdt != 0 && $meetdt < time() && $duedate == 0; //If the exchange is permanent $case3 = $meetdt != 0 && $meetdt < time() && $duedate != 0; //And the item is due for exchange //If the exchange is over (case1 or case2) if ($case1 || $case2) { //Print out the rating tool $newRating = new Rater($other_id); $newRating->output(); } else { if ($case3) { //Show the pickup countdown $newPickup = new Pickup($duedate); $newPickup->output(); } else { //If the meeting date has not been determined... if ($meetdt == 0) { //...show the calender $newCal = new Calender(trim($oid)); $newCal->output(); } else { //...print out the countdown to the meetup $newMeetup = new Meetup($meetdt); $newMeetup->output(); } } } echo "</div>";
public function actionAssigncancel() { if (!isset($_REQUEST['token']) && !isset($_REQUEST['awb'])) { echo CJSON::encode($this->statusError(0)); } else { $driver = Driver::getUserId($_REQUEST['token']); $shipment = Shipment::model()->findByAttributes(array('awb' => $_REQUEST['awb'], 'shipping_status' => 11)); if ($shipment == null) { echo CJSON::encode($this->statusError('shippment null')); } else { $shipment->shipping_status = 1; $shipment->save(false); $shipmentEvent = new ShipmentEvent(); $shipmentEvent->shipment_id = $shipment->id; $shipmentEvent->user_id = $driver; $shipmentEvent->status = 1; $shipmentEvent->created = time(); $shipmentEvent->event_time = time(); $shipmentEvent->description = isset($_REQUEST['keterangan']) ? $_REQUEST['keterangan'] : ''; $shipmentEvent->save(false); $pickup = Pickup::model()->findByAttributes(array('shipment_id' => $shipment->id)); $pickup->delete(false); echo CJSON::encode($this->statusSuccess(1)); } } Yii::app()->end(); }
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('&', '& ', $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>'; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Pickup::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
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; }
<?php $redirect = $this->getAction()->id; $this->widget('zii.widgets.grid.CGridView', array('id' => 'assign_courier-grid', 'dataProvider' => $driver_list_available, 'htmlOptions' => array('class' => 'hastable'), 'columns' => array(array('header' => 'Driver Name', 'type' => 'raw', 'name' => 'user.username', 'value' => function ($data, $row) use($shipment_id, $redirect) { return CHtml::link($data->user->username, array('pickup/' . $redirect, 'driver_id' => $data->user_id, 'shipment_id' => $shipment_id), array('class' => 'assign', 'id' => $data->user_id)); }), 'routing_code', array('header' => 'Assignment', 'type' => 'raw', 'value' => function ($data, $row) use($shipment_id) { return Pickup::model()->with(array('shipment' => array('condition' => 'shipping_status=11')))->count('driver_id=:driver_id', array(':driver_id' => $data->user_id)); }))));