Ejemplo n.º 1
0
 public static function updateShippingMethodDictionary(&$method)
 {
     global $cart;
     // this module is the return url to add the kiala order (with the point) after selection
     $returnUrl = CartAPI_Handlers_Helpers::getCartApiHomeUrl() . 'modules/kiala/return.php?';
     $address = new Address($cart->id_address_delivery);
     $kiala_request = new KialaRequest();
     $url = $kiala_request->getSearchRequest($address, $cart->id_lang, $returnUrl);
     $method['Module'] = 'WebShippingActivity';
     $params = array();
     $params['Url'] = $url;
     $params['CompleteTrigger'] = CartAPI_Handlers_Helpers::getShopBaseUrl();
     // return.php redirects there after finishing
     $method['ModuleParameters'] = $params;
 }
Ejemplo n.º 2
0
 /**
  * Display order tracking info
  *
  * @param array $params (order, cart)
  * @return string template rendering
  */
 public function hookOrderDetailDisplayed($params)
 {
     global $smarty;
     $kiala_order = KialaOrder::getByOrder($params['order']->id);
     if (!Validate::isLoadedObject($kiala_order)) {
         return false;
     }
     $address = new Address($params['order']->id_address_delivery);
     $kiala_country = KialaCountry::getByIdCountry($address->id_country);
     $search_by = Configuration::get('KIALA_SEARCH_BY');
     if ($search_by == 'customer') {
         $id = $kiala_order->id_customer;
     } elseif ($search_by == 'order') {
         $id = Configuration::get('KIALA_NUMBER_PREFIX') . $kiala_order->id;
     } else {
         return false;
     }
     $kiala_request = new KialaRequest();
     $url = $kiala_request->getTrackingRequest($address, $kiala_country, $params['order']->id_lang, $id, $search_by);
     $smarty->assign('url_tracking', Tools::safeOutput($url));
     return $this->display(__FILE__, 'orderDetail.tpl');
 }
Ejemplo n.º 3
0
    /**
     * Override parent function to display a list with bulk selection and export
     */
    public function displayListContent($token = NULL)
    {
        /* Display results in a table
         *
         * align  : determine value alignment
         * prefix : displayed before value
         * suffix : displayed after value
         * image  : object image
         * icon   : icon determined by values
         * active : allow to toggle status
         */
        global $currentIndex, $cookie;
        $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
        $id_category = 1;
        // default categ
        $irow = 0;
        if ($this->_list and isset($this->fieldsDisplay['position'])) {
            $positions = array_map(create_function('$elem', 'return (int)($elem[\'position\']);'), $this->_list);
            sort($positions);
        }
        if ($this->_list) {
            $isCms = false;
            $keyToGet = 'id_' . ($isCms ? 'cms_' : '') . 'category' . (in_array($this->identifier, array('id_category', 'id_cms_category')) ? '_parent' : '');
            foreach ($this->_list as $tr) {
                $id = $tr[$this->identifier];
                echo '<tr' . (array_key_exists($this->identifier, $this->identifiersDnd) ? ' id="tr_' . (($id_category = (int) Tools::getValue('id_' . ($isCms ? 'cms_' : '') . 'category', '1')) ? $id_category : '') . '_' . $id . '_' . $tr['position'] . '"' : '') . ($irow++ % 2 ? ' class="alt_row"' : '') . ' ' . ((isset($tr['color']) and $this->colorOnBackground) ? 'style="background-color: ' . $tr['color'] . '"' : '') . '>
							<td class="center">';
                echo '<input type="checkbox" name="' . $this->table . 'Box[]" value="' . $id . '" class="noborder" />';
                echo '</td>';
                foreach ($this->fieldsDisplay as $key => $params) {
                    $tmp = explode('!', $key);
                    $key = isset($tmp[1]) ? $tmp[1] : $tmp[0];
                    echo '
					<td ' . (isset($params['position']) ? ' id="td_' . (isset($id_category) and $id_category ? $id_category : 0) . '_' . $id . '"' : '') . ' class="' . ((!isset($this->noLink) or !$this->noLink) ? 'pointer' : '') . ((isset($params['position']) and $this->_orderBy == 'position') ? ' dragHandle' : '') . (isset($params['align']) ? ' ' . $params['align'] : '') . '" ';
                    if (!isset($params['position']) and (!isset($this->noLink) or !$this->noLink)) {
                        echo ' onclick="document.location = \'' . $currentIndex . '&' . $this->identifier . '=' . $id . ($this->view ? '&view' : '&update') . $this->table . '&token=' . ($token != NULL ? $token : $this->token) . '\'">' . (isset($params['prefix']) ? $params['prefix'] : '');
                    } else {
                        echo '>';
                    }
                    if (isset($params['active']) and isset($tr[$key])) {
                        $this->_displayEnableLink($token, $id, $tr[$key], $params['active'], Tools::getValue('id_category'), Tools::getValue('id_product'));
                    } elseif (isset($params['activeVisu']) and isset($tr[$key])) {
                        echo '<img src="../img/admin/' . ($tr[$key] ? 'enabled.gif' : 'disabled.gif') . '"
							alt="' . ($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')) . '" title="' . ($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')) . '" />';
                    } elseif (isset($params['position'])) {
                        if ($this->_orderBy == 'position' and $this->_orderWay != 'DESC') {
                            echo '<a' . (!($tr[$key] != $positions[sizeof($positions) - 1]) ? ' style="display: none;"' : '') . ' href="' . $currentIndex . '&' . $keyToGet . '=' . (int) $id_category . '&' . $this->identifiersDnd[$this->identifier] . '=' . $id . '
										&way=1&position=' . (int) ($tr['position'] + 1) . '&token=' . ($token != NULL ? $token : $this->token) . '">
										<img src="../img/admin/' . ($this->_orderWay == 'ASC' ? 'down' : 'up') . '.gif"
										alt="' . $this->l('Down') . '" title="' . $this->l('Down') . '" /></a>';
                            echo '<a' . (!($tr[$key] != $positions[0]) ? ' style="display: none;"' : '') . ' href="' . $currentIndex . '&' . $keyToGet . '=' . (int) $id_category . '&' . $this->identifiersDnd[$this->identifier] . '=' . $id . '
										&way=0&position=' . (int) ($tr['position'] - 1) . '&token=' . ($token != NULL ? $token : $this->token) . '">
										<img src="../img/admin/' . ($this->_orderWay == 'ASC' ? 'up' : 'down') . '.gif"
										alt="' . $this->l('Up') . '" title="' . $this->l('Up') . '" /></a>';
                        } else {
                            echo (int) ($tr[$key] + 1);
                        }
                    } elseif (isset($params['icon']) and (isset($params['icon'][$tr[$key]]) or isset($params['icon']['default']))) {
                        echo '<img src="../img/admin/' . (isset($params['icon'][$tr[$key]]) ? $params['icon'][$tr[$key]] : $params['icon']['default'] . '" alt="' . $tr[$key]) . '" title="' . $tr[$key] . '" />';
                    } elseif (isset($params['price'])) {
                        echo Tools::displayPrice($tr[$key], isset($params['currency']) ? Currency::getCurrencyInstance((int) $tr['id_currency']) : $currency, false);
                    } elseif (isset($params['float'])) {
                        echo rtrim(rtrim($tr[$key], '0'), '.');
                    } elseif (isset($params['type']) and $params['type'] == 'date') {
                        echo Tools::displayDate($tr[$key], (int) $cookie->id_lang);
                    } elseif (isset($params['type']) and $params['type'] == 'datetime') {
                        // Tools::displayDate on empty date can result in a die(), we don't want that.
                        if ($tr[$key] == "0000-00-00 00:00:00") {
                            echo '-';
                        } else {
                            echo Tools::displayDate($tr[$key], (int) $cookie->id_lang, true);
                        }
                    } elseif (isset($tr[$key])) {
                        $echo = $key == 'price' ? round($tr[$key], 2) : isset($params['maxlength']) ? Tools::substr($tr[$key], 0, $params['maxlength']) . '...' : $tr[$key];
                        echo isset($params['callback']) ? call_user_func_array(array($this->className, $params['callback']), array($echo, $tr)) : $echo;
                    } elseif ($key == 'kiala_point') {
                        $kiala_request = new KialaRequest();
                        $url = $kiala_request->getDetailsRequest($tr['point_short_id'], $tr['id_country_delivery'], $cookie->id_lang);
                        if ($url) {
                            echo '<a class="link blue" href="' . Tools::safeOutput($url) . '">' . $tr['point_name'] . '</a>';
                        } else {
                            echo '--';
                        }
                    } else {
                        echo '--';
                    }
                    echo (isset($params['suffix']) ? $params['suffix'] : '') . '</td>';
                }
                echo '<td class="center" style="white-space: nowrap;">';
                $this->_displayEditLink($token, $id);
                $this->_displayExportLink($token, $id);
                echo '</td>';
                echo '</tr>';
            }
        }
    }