public function run() { $this->init(); $this->preProcess(); if (Tools::getValue('ajax') == 'true') { if (Tools::getIsset('summary')) { if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) { if (self::$cookie->id_customer) { $customer = new Customer((int) self::$cookie->id_customer); $groups = $customer->getGroups(); } else { $groups = array(1); } if ((int) self::$cart->id_address_delivery) { $deliveryAddress = new Address((int) self::$cart->id_address_delivery); } $result = array('carriers' => Carrier::getCarriersForOrder((int) Country::getIdZone((isset($deliveryAddress) and (int) $deliveryAddress->id) ? (int) $deliveryAddress->id_country : (int) Configuration::get('PS_COUNTRY_DEFAULT')), $groups)); } $result['summary'] = self::$cart->getSummaryDetails(); $result['customizedDatas'] = Product::getAllCustomizedDatas((int) self::$cart->id); $result['HOOK_SHOPPING_CART'] = Module::hookExec('shoppingCart', $result['summary']); $result['HOOK_SHOPPING_CART_EXTRA'] = Module::hookExec('shoppingCartExtra', $result['summary']); die(Tools::jsonEncode($result)); } else { $this->includeCartModule(); } } else { $this->setMedia(); $this->displayHeader(); $this->process(); $this->displayContent(); $this->displayFooter(); } }
/** * Imprime la forma para editar un nuevo registro sobre el DIV identificado por "formDiv". * * @param $id (int) Identificador del registro a ser editado. * @return $html (string) Devuelve una cadena de caracteres que contiene la forma con los datos * a extraidos de la base de datos para ser editados */ function formEdit($id) { global $locate; $asteriskcalls =& Customer::getRecordByID($id, 'asteriskcalls'); if ($_SESSION['curuser']['usertype'] == 'admin') { $grouphtml .= '<select name="groupid" id="groupid" > <option value=""></option>'; $res = Customer::getGroups(); while ($row = $res->fetchRow()) { $grouphtml .= '<option value="' . $row['groupid'] . '"'; if ($row['groupid'] == $asteriskcalls['groupid']) { $grouphtml .= ' selected '; } $grouphtml .= '>' . $row['groupname'] . '</option>'; } $grouphtml .= '</select>'; } else { $grouphtml .= $_SESSION['curuser']['group']['groupname'] . '<input type="hidden" name="groupid" id="groupid" value="' . $_SESSION['curuser']['groupid'] . '">'; } $html = ' <!-- No edit the next line --> <form method="post" name="f" id="f"> <table border="1" width="100%" class="adminlist"> <tr> <td nowrap align="left">' . $locate->Translate("Name") . ' *</td> <td align="left"><input type="text" id="asteriskcallsname" name="asteriskcallsname" size="30" maxlength="50" value="' . $asteriskcalls['asteriskcallsname'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Dialout context") . '</td> <td align="left"><input type="hidden" id="id" name="id" value="' . $asteriskcalls['id'] . '"><input type="text" id="dialoutcontext" name="dialoutcontext" size="30" maxlength="50" value="' . $asteriskcalls['outcontext'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Dialin context") . '</td> <td align="left"><input type="text" id="dialincontext" name="dialincontext" size="30" maxlength="50" value="' . $asteriskcalls['incontext'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Dialin extension") . '</td> <td align="left"><input type="text" id="dialinextension" name="dialinextension" size="30" maxlength="50" value="' . $asteriskcalls['inextension'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Group") . '</td> <td align="left">' . $grouphtml . '</td> </tr> <tr> <td colspan="2" align="center"><button id="submitButton" onClick=\'xajax_update(xajax.getFormValues("f"));return false;\'>' . $locate->Translate("continue") . '</button></td> </tr> </table> '; $html .= ' </form> ' . $locate->Translate("obligatory_fields") . ' '; return $html; }
/** * Return shipping total * * @param integer $id_carrier Carrier ID (default : current carrier) * @return float Shipping total */ function getOrderShippingCost($id_carrier = NULL, $useTax = true) { global $defaultCountry; if ($this->isVirtualCart()) { return 0; } // Checking discounts in cart $products = $this->getProducts(); $discounts = $this->getDiscounts(true); if ($discounts) { foreach ($discounts as $id_discount) { if ($id_discount['id_discount_type'] == 3) { if ($id_discount['minimal'] > 0) { $total_cart = 0; $categories = Discount::getCategories(intval($id_discount['id_discount'])); if (sizeof($categories)) { foreach ($products as $product) { if (Product::idIsOnCategoryId(intval($product['id_product']), $categories)) { $total_cart += $product['total_wt']; } } } if ($total_cart >= $id_discount['minimal']) { return 0; } } else { return 0; } } } } // Order total without fees $orderTotal = $this->getOrderTotal(true, 7); // Start with shipping cost at 0 $shipping_cost = 0; // If no product added, return 0 if ($orderTotal <= 0 and !intval(self::getNbProducts($this->id))) { return $shipping_cost; } // Get id zone if (isset($this->id_address_delivery) and $this->id_address_delivery) { $id_zone = Address::getZoneById(intval($this->id_address_delivery)); } else { $id_zone = intval($defaultCountry->id_zone); } // If no carrier, select default one if (!$id_carrier) { $id_carrier = $this->id_carrier; } if (empty($id_carrier)) { if (Configuration::get('PS_SHIPPING_METHOD') and Carrier::checkDeliveryPriceByWeight(intval(Configuration::get('PS_CARRIER_DEFAULT')), $this->getTotalWeight(), $id_zone) or !Configuration::get('PS_SHIPPING_METHOD') and Carrier::checkDeliveryPriceByPrice(intval(Configuration::get('PS_CARRIER_DEFAULT')), $this->getOrderTotal(true, 4), $id_zone)) { $id_carrier = intval(Configuration::get('PS_CARRIER_DEFAULT')); } } if (empty($id_carrier)) { if (intval($this->id_customer)) { $customer = new Customer(intval($this->id_customer)); $result = Carrier::getCarriers(intval(Configuration::get('PS_LANG_DEFAULT')), true, false, intval($id_zone), $customer->getGroups()); unset($customer); } else { $result = Carrier::getCarriers(intval(Configuration::get('PS_LANG_DEFAULT')), true, false, intval($id_zone)); } $resultsArray = array(); foreach ($result as $k => $row) { if ($row['id_carrier'] == Configuration::get('PS_CARRIER_DEFAULT')) { continue; } if (!isset(self::$_carriers[$row['id_carrier']])) { self::$_carriers[$row['id_carrier']] = new Carrier(intval($row['id_carrier'])); } $carrier = self::$_carriers[$row['id_carrier']]; // Get only carriers that are compliant with shipping method if (Configuration::get('PS_SHIPPING_METHOD') and $carrier->getMaxDeliveryPriceByWeight($id_zone) === false or !Configuration::get('PS_SHIPPING_METHOD') and $carrier->getMaxDeliveryPriceByPrice($id_zone) === false) { unset($result[$k]); continue; } // If out-of-range behavior carrier is set on "Desactivate carrier" if ($row['range_behavior']) { // Get only carriers that have a range compatible with cart if (Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->getTotalWeight(), $id_zone) or !Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $this->getOrderTotal(true, 4), $id_zone)) { unset($result[$k]); continue; } } if (intval(Configuration::get('PS_SHIPPING_METHOD'))) { $shipping = $carrier->getDeliveryPriceByWeight($this->getTotalWeight(), $id_zone); if (!isset($tmp)) { $tmp = $shipping; } if ($shipping <= $tmp) { $id_carrier = intval($row['id_carrier']); } } else { $shipping = $carrier->getDeliveryPriceByPrice($orderTotal, $id_zone); if (!isset($tmp)) { $tmp = $shipping; } if ($shipping <= $tmp) { $id_carrier = intval($row['id_carrier']); } } } } if (empty($id_carrier)) { $id_carrier = Configuration::get('PS_CARRIER_DEFAULT'); } if (!isset(self::$_carriers[$id_carrier])) { self::$_carriers[$id_carrier] = new Carrier(intval($id_carrier)); } $carrier = self::$_carriers[$id_carrier]; if (!Validate::isLoadedObject($carrier)) { die(Tools::displayError('Fatal error: "no default carrier"')); } if (!$carrier->active) { return $shipping_cost; } // Select carrier tax if ($useTax and $carrier->id_tax) { if (!isset(self::$_taxes[$carrier->id_tax])) { self::$_taxes[$carrier->id_tax] = new Tax(intval($carrier->id_tax)); } $tax = self::$_taxes[$carrier->id_tax]; if (Validate::isLoadedObject($tax) and Tax::zoneHasTax(intval($tax->id), intval($id_zone)) and !Tax::excludeTaxeOption()) { $carrierTax = $tax->rate; } } $configuration = Configuration::getMultiple(array('PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT')); // Free fees $free_fees_price = 0; if (isset($configuration['PS_SHIPPING_FREE_PRICE'])) { $free_fees_price = Tools::convertPrice(floatval($configuration['PS_SHIPPING_FREE_PRICE']), new Currency(intval($this->id_currency))); } $orderTotalwithDiscounts = $this->getOrderTotal(true, 4); if ($orderTotalwithDiscounts >= floatval($free_fees_price) and floatval($free_fees_price) > 0) { return $shipping_cost; } if (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) and $this->getTotalWeight() >= floatval($configuration['PS_SHIPPING_FREE_WEIGHT']) and floatval($configuration['PS_SHIPPING_FREE_WEIGHT']) > 0) { return $shipping_cost; } // Get shipping cost using correct method if ($carrier->range_behavior) { // Get id zone if (isset($this->id_address_delivery) and $this->id_address_delivery) { $id_zone = Address::getZoneById(intval($this->id_address_delivery)); } else { $id_zone = intval($defaultCountry->id_zone); } if (Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByWeight($carrier->id, $this->getTotalWeight(), $id_zone) or !Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByPrice($carrier->id, $this->getOrderTotal(true, 4), $id_zone)) { $shipping_cost += 0; } else { if (intval($configuration['PS_SHIPPING_METHOD'])) { $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight(), $id_zone); } else { $shipping_cost += $carrier->getDeliveryPriceByPrice($orderTotal, $id_zone); } } } else { if (intval($configuration['PS_SHIPPING_METHOD'])) { $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight(), $id_zone); } else { $shipping_cost += $carrier->getDeliveryPriceByPrice($orderTotal, $id_zone); } } // Adding handling charges if (isset($configuration['PS_SHIPPING_HANDLING']) and $carrier->shipping_handling) { $shipping_cost += floatval($configuration['PS_SHIPPING_HANDLING']); } $shipping_cost = Tools::convertPrice($shipping_cost, new Currency(intval($this->id_currency))); // Apply tax if (isset($carrierTax)) { $shipping_cost *= 1 + $carrierTax / 100; } return floatval(Tools::ps_round(floatval($shipping_cost), 2)); }
public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null, $id_zone = null) { if (!Configuration::get('LEGAL_SHIPTAXMETH')) { return parent::getPackageShippingCost($id_carrier, $use_tax, $default_country, $product_list, $id_zone); } if ($this->isVirtualCart()) { return 0; } if (!$default_country) { $default_country = Context::getContext()->country; } if (!is_null($product_list)) { foreach ($product_list as $key => $value) { if ($value['is_virtual'] == 1) { unset($product_list[$key]); } } } $complete_product_list = $this->getProducts(); if (is_null($product_list)) { $products = $complete_product_list; } else { $products = $product_list; } if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_invoice') { $address_id = (int) $this->id_address_invoice; } elseif (count($product_list)) { $prod = current($product_list); $address_id = (int) $prod['id_address_delivery']; } else { $address_id = null; } if (!Address::addressExists($address_id)) { $address_id = null; } $cache_id = 'getPackageShippingCost_' . (int) $this->id . '_' . (int) $address_id . '_' . (int) $id_carrier . '_' . (int) $use_tax . '_' . (int) $default_country->id; if ($products) { foreach ($products as $product) { $cache_id .= '_' . (int) $product['id_product'] . '_' . (int) $product['id_product_attribute']; } } if (Cache::isStored($cache_id)) { return Cache::retrieve($cache_id); } // Order total in default currency without fees $order_total = $this->getOrderTotal(true, Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING, $product_list); // Start with shipping cost at 0 $shipping_cost = 0; // If no product added, return 0 if (!count($products)) { Cache::store($cache_id, $shipping_cost); return $shipping_cost; } if (!isset($id_zone)) { // Get id zone if (!$this->isMultiAddressDelivery() && isset($this->id_address_delivery) && $this->id_address_delivery && Customer::customerHasAddress($this->id_customer, $this->id_address_delivery)) { $id_zone = Address::getZoneById((int) $this->id_address_delivery); } else { if (!Validate::isLoadedObject($default_country)) { $default_country = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT')); } $id_zone = (int) $default_country->id_zone; } } if ($id_carrier && !$this->isCarrierInRange((int) $id_carrier, (int) $id_zone)) { $id_carrier = ''; } if (empty($id_carrier) && $this->isCarrierInRange((int) Configuration::get('PS_CARRIER_DEFAULT'), (int) $id_zone)) { $id_carrier = (int) Configuration::get('PS_CARRIER_DEFAULT'); } $total_package_without_shipping_tax_inc = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list); if (empty($id_carrier)) { if ((int) $this->id_customer) { $customer = new Customer((int) $this->id_customer); $result = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, (int) $id_zone, $customer->getGroups()); unset($customer); } else { $result = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, (int) $id_zone); } foreach ($result as $k => $row) { if ($row['id_carrier'] == Configuration::get('PS_CARRIER_DEFAULT')) { continue; } if (!isset(self::$_carriers[$row['id_carrier']])) { self::$_carriers[$row['id_carrier']] = new Carrier((int) $row['id_carrier']); } $carrier = self::$_carriers[$row['id_carrier']]; // Get only carriers that are compliant with shipping method if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && $carrier->getMaxDeliveryPriceByWeight((int) $id_zone) === false || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && $carrier->getMaxDeliveryPriceByPrice((int) $id_zone) === false) { unset($result[$k]); continue; } // If out-of-range behavior carrier is set on "Desactivate carrier" if ($row['range_behavior']) { $check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->getTotalWeight(), (int) $id_zone); $total_order = $total_package_without_shipping_tax_inc; $check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $total_order, (int) $id_zone, (int) $this->id_currency); // Get only carriers that have a range compatible with cart if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && !$check_delivery_price_by_weight || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && !$check_delivery_price_by_price) { unset($result[$k]); continue; } } if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) { $shipping = $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), (int) $id_zone); } else { $shipping = $carrier->getDeliveryPriceByPrice($order_total, (int) $id_zone, (int) $this->id_currency); } if (!isset($min_shipping_price)) { $min_shipping_price = $shipping; } if ($shipping <= $min_shipping_price) { $id_carrier = (int) $row['id_carrier']; $min_shipping_price = $shipping; } } } if (empty($id_carrier)) { $id_carrier = Configuration::get('PS_CARRIER_DEFAULT'); } if (!isset(self::$_carriers[$id_carrier])) { self::$_carriers[$id_carrier] = new Carrier((int) $id_carrier, Configuration::get('PS_LANG_DEFAULT')); } $carrier = self::$_carriers[$id_carrier]; // No valid Carrier or $id_carrier <= 0 ? if (!Validate::isLoadedObject($carrier)) { Cache::store($cache_id, 0); return 0; } if (!$carrier->active) { Cache::store($cache_id, $shipping_cost); return $shipping_cost; } // Free fees if free carrier if ($carrier->is_free == 1) { Cache::store($cache_id, 0); return 0; } // Select carrier tax if ($use_tax && !Tax::excludeTaxeOption()) { $address = Address::initialize((int) $address_id); $carrier_tax = $carrier->getTaxesRate($address); } $configuration = Configuration::getMultiple(array('PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT')); // Free fees $free_fees_price = 0; if (isset($configuration['PS_SHIPPING_FREE_PRICE'])) { $free_fees_price = Tools::convertPrice((double) $configuration['PS_SHIPPING_FREE_PRICE'], Currency::getCurrencyInstance((int) $this->id_currency)); } $orderTotalwithDiscounts = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, null, null, false); if ($orderTotalwithDiscounts >= (double) $free_fees_price && (double) $free_fees_price > 0) { Cache::store($cache_id, $shipping_cost); return $shipping_cost; } if (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) && $this->getTotalWeight() >= (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] && (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] > 0) { Cache::store($cache_id, $shipping_cost); return $shipping_cost; } // Get shipping cost using correct method if ($carrier->range_behavior) { if (!isset($id_zone)) { // Get id zone if (isset($this->id_address_delivery) && $this->id_address_delivery && Customer::customerHasAddress($this->id_customer, $this->id_address_delivery)) { $id_zone = Address::getZoneById((int) $this->id_address_delivery); } else { $id_zone = (int) $default_country->id_zone; } } if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && !Carrier::checkDeliveryPriceByWeight($carrier->id, $this->getTotalWeight(), (int) $id_zone) || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && !Carrier::checkDeliveryPriceByPrice($carrier->id, $total_package_without_shipping_tax_inc, $id_zone, (int) $this->id_currency)) { $shipping_cost += 0; } else { if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) { $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone); } else { // by price $shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int) $this->id_currency); } } } else { if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) { $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone); } else { $shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int) $this->id_currency); } } // Adding handling charges if (isset($configuration['PS_SHIPPING_HANDLING']) && $carrier->shipping_handling) { $shipping_cost += (double) $configuration['PS_SHIPPING_HANDLING']; } // Additional Shipping Cost per product foreach ($products as $product) { if (!$product['is_virtual']) { $shipping_cost += $product['additional_shipping_cost'] * $product['cart_quantity']; } } $shipping_cost = Tools::convertPrice($shipping_cost, Currency::getCurrencyInstance((int) $this->id_currency)); //get external shipping cost from module if ($carrier->shipping_external) { $module_name = $carrier->external_module_name; $module = Module::getInstanceByName($module_name); if (Validate::isLoadedObject($module)) { if (array_key_exists('id_carrier', $module)) { $module->id_carrier = $carrier->id; } if ($carrier->need_range) { if (method_exists($module, 'getPackageShippingCost')) { $shipping_cost = $module->getPackageShippingCost($this, $shipping_cost, $products); } else { $shipping_cost = $module->getOrderShippingCost($this, $shipping_cost); } } else { $shipping_cost = $module->getOrderShippingCostExternal($this); } // Check if carrier is available if ($shipping_cost === false) { Cache::store($cache_id, false); return false; } } else { Cache::store($cache_id, false); return false; } } $shipping_cost = (double) Tools::ps_round((double) $shipping_cost, 2); Cache::store($cache_id, $shipping_cost); return $shipping_cost; }
/** * Return shipping total * * @param integer $id_carrier Carrier ID (default : current carrier) * @return float Shipping total */ function getOrderShippingCost($id_carrier = NULL, $useTax = true) { global $defaultCountry; if ($this->isVirtualCart()) { return 0; } // Checking discounts in cart $products = $this->getProducts(); $discounts = $this->getDiscounts(true); if ($discounts) { foreach ($discounts as $id_discount) { if ($id_discount['id_discount_type'] == 3) { if ($id_discount['minimal'] > 0) { $total_cart = 0; $categories = Discount::getCategories((int) $id_discount['id_discount']); if (sizeof($categories)) { foreach ($products as $product) { if (Product::idIsOnCategoryId((int) $product['id_product'], $categories)) { $total_cart += $product['total_wt']; } } } if ($total_cart >= $id_discount['minimal']) { return 0; } } else { return 0; } } } } // Order total in default currency without fees $order_total = $this->getOrderTotal(true, Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING); // Start with shipping cost at 0 $shipping_cost = 0; // If no product added, return 0 if ($order_total <= 0 and !(int) self::getNbProducts($this->id)) { return $shipping_cost; } // Get id zone if (isset($this->id_address_delivery) and $this->id_address_delivery and Customer::customerHasAddress($this->id_customer, $this->id_address_delivery)) { $id_zone = Address::getZoneById((int) $this->id_address_delivery); } else { // This method can be called from the backend, and $defaultCountry won't be defined if (!Validate::isLoadedObject($defaultCountry)) { $defaultCountry = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT')); } $id_zone = (int) $defaultCountry->id_zone; } // If no carrier, select default one if (!$id_carrier) { $id_carrier = $this->id_carrier; } if ($id_carrier && !$this->isCarrierInRange($id_carrier, $id_zone)) { $id_carrier = ''; } if (empty($id_carrier) && $this->isCarrierInRange(Configuration::get('PS_CARRIER_DEFAULT'), $id_zone)) { $id_carrier = (int) Configuration::get('PS_CARRIER_DEFAULT'); } if (empty($id_carrier)) { if ((int) $this->id_customer) { $customer = new Customer((int) $this->id_customer); $result = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, (int) $id_zone, $customer->getGroups()); unset($customer); } else { $result = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, (int) $id_zone); } foreach ($result as $k => $row) { if ($row['id_carrier'] == Configuration::get('PS_CARRIER_DEFAULT')) { continue; } if (!isset(self::$_carriers[$row['id_carrier']])) { self::$_carriers[$row['id_carrier']] = new Carrier((int) $row['id_carrier']); } $carrier = self::$_carriers[$row['id_carrier']]; // Get only carriers that are compliant with shipping method if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT and $carrier->getMaxDeliveryPriceByWeight($id_zone) === false or $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE and $carrier->getMaxDeliveryPriceByPrice($id_zone) === false) { unset($result[$k]); continue; } // If out-of-range behavior carrier is set on "Desactivate carrier" if ($row['range_behavior']) { // Get only carriers that have a range compatible with cart if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT and !Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->getTotalWeight(), $id_zone) or $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE and !Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), $id_zone, (int) $this->id_currency)) { unset($result[$k]); continue; } } if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) { $shipping = $carrier->getDeliveryPriceByWeight($this->getTotalWeight(), $id_zone); } else { $shipping = $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int) $this->id_currency); } if (!isset($minShippingPrice)) { $minShippingPrice = $shipping; } if ($shipping <= $minShippingPrice) { $id_carrier = (int) $row['id_carrier']; $minShippingPrice = $shipping; } } } if (empty($id_carrier)) { $id_carrier = Configuration::get('PS_CARRIER_DEFAULT'); } if (!isset(self::$_carriers[$id_carrier])) { self::$_carriers[$id_carrier] = new Carrier((int) $id_carrier, Configuration::get('PS_LANG_DEFAULT')); } $carrier = self::$_carriers[$id_carrier]; if (!Validate::isLoadedObject($carrier)) { die(Tools::displayError('Fatal error: "no default carrier"')); } if (!$carrier->active) { return $shipping_cost; } // Free fees if free carrier if ($carrier->is_free == 1) { return 0; } // Select carrier tax if ($useTax and !Tax::excludeTaxeOption()) { $carrierTax = Tax::getCarrierTaxRate((int) $carrier->id, (int) $this->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); } $configuration = Configuration::getMultiple(array('PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT')); // Free fees $free_fees_price = 0; if (isset($configuration['PS_SHIPPING_FREE_PRICE'])) { $free_fees_price = Tools::convertPrice((double) $configuration['PS_SHIPPING_FREE_PRICE'], Currency::getCurrencyInstance((int) $this->id_currency)); } $orderTotalwithDiscounts = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING); if ($orderTotalwithDiscounts >= (double) $free_fees_price and (double) $free_fees_price > 0) { return $shipping_cost; } if (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) and $this->getTotalWeight() >= (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] and (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] > 0) { return $shipping_cost; } // Get shipping cost using correct method if ($carrier->range_behavior) { // Get id zone if (isset($this->id_address_delivery) and $this->id_address_delivery and Customer::customerHasAddress($this->id_customer, $this->id_address_delivery)) { $id_zone = Address::getZoneById((int) $this->id_address_delivery); } else { $id_zone = (int) $defaultCountry->id_zone; } if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT and !Carrier::checkDeliveryPriceByWeight($carrier->id, $this->getTotalWeight(), $id_zone) or $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE and !Carrier::checkDeliveryPriceByPrice($carrier->id, $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), $id_zone, (int) $this->id_currency)) { $shipping_cost += 0; } else { if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) { $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight(), $id_zone); } else { // by price $shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int) $this->id_currency); } } } else { if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) { $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight(), $id_zone); } else { $shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int) $this->id_currency); } } // Adding handling charges if (isset($configuration['PS_SHIPPING_HANDLING']) and $carrier->shipping_handling) { $shipping_cost += (double) $configuration['PS_SHIPPING_HANDLING']; } // Additional Shipping Cost per product foreach ($products as $product) { $shipping_cost += $product['additional_shipping_cost'] * $product['cart_quantity']; } $shipping_cost = Tools::convertPrice($shipping_cost, Currency::getCurrencyInstance((int) $this->id_currency)); //get external shipping cost from module if ($carrier->shipping_external) { $moduleName = $carrier->external_module_name; $module = Module::getInstanceByName($moduleName); if (Validate::isLoadedObject($module)) { if (array_key_exists('id_carrier', $module)) { $module->id_carrier = $carrier->id; } if ($carrier->need_range) { $shipping_cost = $module->getOrderShippingCost($this, $shipping_cost); } else { $shipping_cost = $module->getOrderShippingCostExternal($this); } // Check if carrier is available if ($shipping_cost === false) { return false; } } else { return false; } } // Apply tax if (isset($carrierTax)) { $shipping_cost *= 1 + $carrierTax / 100; } return (double) Tools::ps_round((double) $shipping_cost, 2); }
protected function _assignCarrier() { $customer = new Customer((int) self::$cookie->id_customer); $address = new Address((int) self::$cart->id_address_delivery); $id_zone = Address::getZoneById((int) $address->id); $carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups()); $checked = 0; if (Validate::isUnsignedInt(self::$cart->id_carrier) and self::$cart->id_carrier) { $carrier = new Carrier((int) self::$cart->id_carrier); if ($carrier->active and !$carrier->deleted) { $checked = (int) self::$cart->id_carrier; } } self::$smarty->assign(array('checked' => (int) $checked, 'carriers' => $carriers, 'default_carrier' => (int) Configuration::get('PS_CARRIER_DEFAULT'), 'HOOK_EXTRACARRIER' => Module::hookExec('extraCarrier', array('address' => $address)), 'HOOK_BEFORECARRIER' => Module::hookExec('beforeCarrier', array('carriers' => $carriers)))); }
function formEdit($id) { global $locate; $diallist =& Customer::getRecordByID($id, 'diallist'); if ($_SESSION['curuser']['usertype'] == 'admin') { $res = Customer::getGroups(); $groupoptions .= '<select name="groupid" id="groupid" onchange="setCampaign();">'; while ($row = $res->fetchRow()) { $groupoptions .= '<option value="' . $row['groupid'] . '"'; if ($diallist['groupid'] == $row['groupid']) { $groupoptions .= ' selected'; } $groupoptions .= '>' . $row['groupname'] . '</option>'; } $groupoptions .= '</select>'; } else { $groupoptions .= $_SESSION['curuser']['group']['groupname'] . '<input id="groupid" name="groupid" type="hidden" value="' . $_SESSION['curuser']['groupid'] . '">'; } $campaignlist = Customer::getAll("campaign", "groupid", $diallist['groupid']); while ($row = $campaignlist->fetchRow()) { $campaign_options .= '<option value="' . $row['id'] . '"'; if ($diallist['campaignid'] == $row['id']) { $campaign_options .= ' selected'; } $campaign_options .= '>' . $row['campaignname'] . '</option>'; } $html = ' <!-- No edit the next line --> <form method="post" name="formDiallist" id="formDiallist"> <table border="1" width="100%" class="adminlist"> <tr> <td nowrap align="left">' . $locate->Translate("number") . '*</td> <td align="left"> <input type="text" id="dialnumber" name="dialnumber" size="35" value="' . $diallist['dialnumber'] . '"> <input type="hidden" id="id" name="id" value="' . $diallist['id'] . '"> </td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Name") . '</td> <td align="left"> <input type="text" id="customername" name="customername" value="' . $diallist['customername'] . '" size="35"> </td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Assign To") . '</td> <td align="left"> <input type="text" id="assign" name="assign" size="35" value="' . $diallist['assign'] . '"> </td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Call Order") . '</td> <td align="left"> <input type="text" id="callOrder" name="callOrder" size="35" value="' . $diallist['callOrder'] . '"> </td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Dialtime") . '</td> <td align="left"> <input type="text" name="dialtime" id="dialtime" size="20" value="' . $diallist['dialtime'] . '"> <INPUT onclick="displayCalendar(document.getElementById(\'dialtime\'),\'yyyy-mm-dd hh:ii\',this,true)" type="button" value="' . $locate->Translate("Cal") . '"> </td> </tr>'; $html .= ' <tr> <td align="left" width="25%">' . $locate->Translate("Group Name") . '</td> <td>' . $groupoptions . '</td> </tr>'; $html .= ' <tr> <td align="left" width="25%">' . $locate->Translate("Campaign Name") . '</td> <td><SELECT id="campaignid" name="campaignid">' . $campaign_options . '</SELECT></td> </tr>'; $html .= ' <tr> <td align="left" width="25%">' . $locate->Translate("Memo") . '</td> <td><textarea id="memo" name="memo" cols="50" rows="8">' . $diallist['memo'] . '</textarea></td> </tr>'; $html .= ' <tr> <td nowrap colspan=2 align=right><input type="button" id="btnAddDiallist" name="btnAddDiallist" value="' . $locate->Translate("continue") . '" onclick="xajax_update(xajax.getFormValues(\'formDiallist\'));return false;"></td> </tr> <table> </form> '; return $html; }
function displayCarrier() { global $smarty, $cart, $cookie, $defaultCountry, $link; $address = new Address(intval($cart->id_address_delivery)); $id_zone = Address::getZoneById(intval($address->id)); if (isset($cookie->id_customer)) { $customer = new Customer(intval($cookie->id_customer)); } else { die(Tools::displayError($this->l('Fatal error: No customer'))); } $result = Carrier::getCarriers(intval($cookie->id_lang), true, false, intval($id_zone), $customer->getGroups()); if (!$result) { $result = Carrier::getCarriers(intval($cookie->id_lang), true, false, intval($id_zone)); } $resultsArray = array(); foreach ($result as $k => $row) { $carrier = new Carrier(intval($row['id_carrier'])); // Get only carriers that are compliant with shipping method if (Configuration::get('PS_SHIPPING_METHOD') and $carrier->getMaxDeliveryPriceByWeight($id_zone) === false or !Configuration::get('PS_SHIPPING_METHOD') and $carrier->getMaxDeliveryPriceByPrice($id_zone) === false) { unset($result[$k]); continue; } // If out-of-range behavior carrier is set on "Desactivate carrier" if ($row['range_behavior']) { // Get id zone if (isset($cart->id_address_delivery) and $cart->id_address_delivery) { $id_zone = Address::getZoneById(intval($cart->id_address_delivery)); } else { $id_zone = intval($defaultCountry->id_zone); } // Get only carriers that have a range compatible with cart if (Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $cart->getTotalWeight(), $id_zone) or !Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $cart->getOrderTotal(true, 4), $id_zone)) { unset($result[$k]); continue; } } $row['name'] = strval($row['name']) != '0' ? $row['name'] : Configuration::get('PS_SHOP_NAME'); $row['price'] = $cart->getOrderShippingCost(intval($row['id_carrier'])); $row['price_tax_exc'] = $cart->getOrderShippingCost(intval($row['id_carrier']), false); $row['img'] = file_exists(_PS_SHIP_IMG_DIR_ . intval($row['id_carrier']) . '.jpg') ? _THEME_SHIP_DIR_ . intval($row['id_carrier']) . '.jpg' : ''; $resultsArray[] = $row; } // Wrapping fees $wrapping_fees = floatval(Configuration::get('PS_GIFT_WRAPPING_PRICE')); $wrapping_fees_tax = new Tax(intval(Configuration::get('PS_GIFT_WRAPPING_TAX'))); $wrapping_fees_tax_inc = $wrapping_fees * (1 + floatval($wrapping_fees_tax->rate) / 100); if (Validate::isUnsignedInt($cart->id_carrier) and $cart->id_carrier) { $carrier = new Carrier(intval($cart->id_carrier)); if ($carrier->active and !$carrier->deleted) { $checked = intval($cart->id_carrier); } } $cms = new CMS(3, intval($cookie->id_lang)); $link_conditions = $link->getCMSLink($cms, $cms->link_rewrite); if (!strpos($link_conditions, '?')) { $link_conditions .= '?content_only=1&TB_iframe=true&width=450&height=500&thickbox=true'; } else { $link_conditions .= '&content_only=1&TB_iframe=true&width=450&height=500&thickbox=true'; } if (!isset($checked) or intval($checked) == 0) { $checked = intval(Configuration::get('PS_CARRIER_DEFAULT')); } $smarty->assign(array('checkedTOS' => intval($cookie->checkedTOS), 'recyclablePackAllowed' => intval(Configuration::get('PS_RECYCLABLE_PACK')), 'giftAllowed' => intval(Configuration::get('PS_GIFT_WRAPPING')), 'conditions' => intval(Configuration::get('PS_CONDITIONS')), 'link_conditions' => $link_conditions, 'recyclable' => intval($cart->recyclable), 'gift_wrapping_price' => floatval(Configuration::get('PS_GIFT_WRAPPING_PRICE')), 'carriers' => $resultsArray, 'HOOK_EXTRACARRIER' => Module::hookExec('extraCarrier', array('address' => $address)), 'checked' => intval($checked), 'total_wrapping' => Tools::convertPrice($wrapping_fees_tax_inc, new Currency(intval($cookie->id_currency))), 'total_wrapping_tax_exc' => Tools::convertPrice($wrapping_fees, new Currency(intval($cookie->id_currency))))); Tools::safePostVars(); $css_files = array(__PS_BASE_URI__ . 'css/thickbox.css' => 'all'); $js_files = array(__PS_BASE_URI__ . 'js/jquery/thickbox-modified.js'); include_once dirname(__FILE__) . '/header.php'; $smarty->display(_PS_THEME_DIR_ . 'order-carrier.tpl'); }
/** * Imprime la forma para editar un nuevo registro sobre el DIV identificado por "formDiv". * * @param $id (int) Identificador del registro a ser editado. * @return $html (string) Devuelve una cadena de caracteres que contiene la forma con los datos * a extraidos de la base de datos para ser editados */ function formEdit($id) { global $locate; $account =& Customer::getRecordByID($id, 'astercrm_account'); if ($_SESSION['curuser']['usertype'] == 'admin') { $grouphtml .= '<select name="groupid" id="groupid" >'; $res = Customer::getGroups(); while ($row = $res->fetchRow()) { $grouphtml .= '<option value="' . $row['groupid'] . '"'; if ($row['groupid'] == $account['groupid']) { $grouphtml .= ' selected '; } $grouphtml .= '>' . $row['groupname'] . '</option>'; } $grouphtml .= '</select>'; } else { $grouphtml .= $_SESSION['curuser']['group']['groupname'] . '<input type="hidden" name="groupid" id="groupid" value="' . $_SESSION['curuser']['groupid'] . '">'; } $html = ' <!-- No edit the next line --> <form method="post" name="f" id="f"> <table border="1" width="100%" class="adminlist"> <tr> <td nowrap align="left">' . $locate->Translate("username") . '*</td> <td align="left"><input type="hidden" id="id" name="id" value="' . $account['id'] . '"><input type="text" id="username" name="username" size="25" maxlength="30" value="' . $account['username'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("password") . '*</td> <td align="left"><input type="text" id="password" name="password" size="25" maxlength="30" value="' . $account['password'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("first name") . '*</td> <td align="left"><input type="text" id="firstname" name="firstname" size="25" maxlength="15" value="' . $account['firstname'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("last name") . '*</td> <td align="left"><input type="text" id="lastname" name="lastname" size="25" maxlength="15" value="' . $account['lastname'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("callerid") . '</td> <td align="left"><input type="text" id="callerid" name="callerid" size="25" maxlength="30" value="' . $account['callerid'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("extension") . '*</td> <td align="left"><input type="text" id="extension" name="extension" size="25" maxlength="15" value="' . $account['extension'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("dynamic agent") . '</td> <td align="left"><input type="text" id="agent" name="agent" size="25" maxlength="15" value="' . $account['agent'] . '"></td> </tr> <tr><td nowrap align="left">' . $locate->Translate("extensions") . '</td> <td align="left">'; if ($account['extensions'] == '') { $html .= '<input type="text" id="extensions" name="extensions" size="25" maxlength="100" onclick="chkExtenionClick(this.value,this)" onblur="chkExtenionBlur(this.value,this)" style="color:#BBB" value="' . $locate->translate('extensions_input_tip') . '">'; } else { $html .= '<input type="text" id="extensions" name="extensions" size="25" maxlength="100" onclick="chkExtenionClick(this.value,this)" onblur="chkExtenionBlur(this.value,this)" value="' . $account['extensions'] . '">'; } $html .= ' <input type="radio" value="username" id="extensType" name="extensType" checked>' . $locate->Translate("username") . '<input type="radio" value="extension" id="extensType" name="extensType" >' . $locate->Translate("extension") . '</td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("channel") . '</td> <td align="left"><input type="text" id="channel" name="channel" size="25" maxlength="30" value="' . $account['channel'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("usertype") . '*</td> <td align="left"> <select id="usertypeSelect" onchange="usertypeChange(this)"> <option value="0" '; if ($account['usertype'] == '') { $html .= ' selected '; } $html .= '></option> <option value="0"'; if ($account['usertype'] == 'agent') { $html .= ' selected '; } $html .= ' >agent</option> <option value="0"'; if ($account['usertype'] == 'groupadmin') { $html .= ' selected '; } $html .= '>groupadmin</option>'; if ($_SESSION['curuser']['usertype'] == 'admin') { $html .= '<option value="0"'; if ($account['usertype'] == 'admin') { $html .= ' selected '; } $html .= '>admin</option>'; } $userTyperesult = Customer::getAstercrmUsertype(); if (!empty($userTyperesult)) { foreach ($userTyperesult as $usertype) { $html .= '<option value="' . $usertype['id'] . '" '; if ($usertype['id'] == $account['usertype_id']) { $html .= ' selected'; } $html .= '>' . $usertype['usertype_name'] . '</option>'; } } $html .= '</select><input type="hidden" id="usertype" name="usertype" value="' . $account['usertype'] . '" /><input type="hidden" id="usertype_id" name="usertype_id" value="' . $account['usertype_id'] . '" /> <!--<input type="text" id="usertype" name="usertype" size="25" maxlength="30" value="' . $account['usertype'] . '">--></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("account_code") . '</td> <td align="left"><input type="text" id="accountcode" name="accountcode" size="20" maxlength="20" value="' . $account['accountcode'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("group_name") . '</td> <td align="left">' . $grouphtml . ' </td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Dial Interval") . '</td> <td align="left"><input type="text" id="dialinterval" name="dialinterval" size="20" maxlength="20" value="' . $account['dialinterval'] . '"></td> </tr> <tr> <td colspan="2" align="center"><button id="submitButton" onClick=\'xajax_update(xajax.getFormValues("f"));return false;\'>' . $locate->Translate("continue") . '</button></td> </tr> </table> '; $html .= ' </form> ' . $locate->Translate("obligatory_fields") . ' '; return $html; }
function formAdd($surveyid = 0, $optionid = 0) { global $locate; $html = ' <!-- No edit the next line --> <form method="post" name="f" id="f"> <table border="1" width="100%" class="adminlist" id="tblSurvey"> '; $html .= '<tr><td colspan=2> ' . $locate->Translate("survey_title") . '* </td></tr>'; if ($surveyid == 0) { $html .= '<tr><td colspan=2> <input type="text" size="50" maxlangth="100" id="surveyname" name="surveyname"/> </td></tr>'; $html .= '<tr><td colspan=2> ' . $locate->Translate("Survey Note") . ' </td></tr>'; $html .= '<tr><td colspan=2> <input type="text" size="50" maxlangth="254" id="surveynote" name="surveynote"/> </td></tr>'; $enable_html = '<tr> <td colspan=2> <input type="radio" value="1" id="radEnable" name="radEnable" checked>' . $locate->Translate("enable") . ' <input type="radio" value="0" id="radEnable" name="radEnable">' . $locate->Translate("disable") . ' </td> </tr>'; } else { $survey = Customer::getRecord($surveyid, 'survey'); $nameCell = "TitleCol"; $html .= '<tr><td colspan="2" id="' . $nameCell . '" style="cursor: pointer;" onDblClick="xajax_editField(\'survey\',\'surveyname\',\'' . $nameCell . '\',\'' . $survey['surveyname'] . '\',\'' . $survey['id'] . '\');return false">' . $survey['surveyname'] . '<input type="hidden" id="surveyid" name="surveyid" value="' . $surveyid . '"/></td></tr>'; $nameCell = "NoteCol"; $html .= '<tr><td colspan=2> ' . $locate->Translate("Survey Note") . ' </td></tr>'; $html .= '<tr><td colspan="2" id="' . $nameCell . '" style="cursor: pointer;" onDblClick="xajax_editField(\'survey\',\'surveynote\',\'' . $nameCell . '\',\'' . $survey['surveynote'] . '\',\'' . $survey['id'] . '\');return false">' . $survey['surveynote'] . ' </td></tr>'; if ($survey['enable'] == 1) { $enable_html = '<tr> <td colspan=2> <input type="radio" value="1" id="radEnable" name="radEnable" checked>' . $locate->Translate("enable") . ' <input type="radio" value="0" id="radEnable" name="radEnable">' . $locate->Translate("disable"); } else { $enable_html = '<tr> <td colspan=2> <input type="radio" value="1" id="radEnable" name="radEnable" >' . $locate->Translate("enable") . ' <input type="radio" value="0" id="radEnable" name="radEnable" checked>' . $locate->Translate("disable"); } $enable_html .= '<input type="button" onclick="xajax_setSurvey(xajax.getFormValues(\'f\'));return false;" value="' . $locate->Translate("update") . '"> </td> </tr>'; } $options = Customer::getOptions($surveyid); if ($options) { $ind = 0; while ($options->fetchInto($row)) { $nameRow = "formDivRow" . $row['id']; $nameCell = $nameRow . "Col" . $ind; $html .= '<tr id="' . $nameRow . '" >' . "\n"; $item_html = ""; if ($row['optiontype'] == "text") { } else { $item_html = '(<a href=? onclick="showItem(\'' . $row['id'] . '\');return false;">' . $locate->Translate("Item") . '</a>)'; } $option_item_number = astercrm::getCountByField("optionid", $row['id'], "surveyoptionitems"); $html .= ' <td align="left" width="25%">' . $locate->Translate("option") . '(<a href="?" onclick="xajax_edit(\'' . $surveyid . '\',\'' . $row['id'] . '\');return false;"><img src="skin/default/images/edit.png"></a><a href="?" onclick="deleteOption(\'' . $row['id'] . '\',\'' . $nameRow . '\');return false;"><img src="skin/default/images/trash.png"></a>)' . $item_html . ' </td><td id="' . $nameCell . '" >' . $row['surveyoption'] . "(" . $locate->Translate($row['optiontype']) . ", {$option_item_number} " . $locate->Translate('items') . ")" . '</td></tr> <tr> <td align="left" width="25%">' . $locate->Translate("Option Note") . '</td> <td id="' . $nameCell . '_note">' . $row['optionnote'] . '</td> </tr> <tr><td colspan="2" height="1" bgcolor="#ccc"></td></tr> '; $ind++; } } $html .= '<tr><td colspan=2> ' . $locate->Translate("option") . ' </td></tr>'; if ($optionid == 0) { $button_value = $locate->Translate("Add Option"); $optionid = 0; } else { $button_value = $locate->Translate("Update Option"); $option = astercrm::getRecordById($optionid, "surveyoptions"); $optiontype[$option['optiontype']] = "selected"; } $html .= '<tr><td colspan=2>' . $locate->Translate("Title") . ': <input type="text" size="50" maxlength="50" id="surveyoption" name="surveyoption" value="' . $option['surveyoption'] . '"/> <SELECT id="optiontype" name="optiontype"> <option value="radio" ' . $optiontype['radio'] . '>' . $locate->Translate("Radio") . '</option> <option value="checkbox" ' . $optiontype['checkbox'] . '>' . $locate->Translate("Checkbox") . '</option> <option value="text" ' . $optiontype['text'] . '>' . $locate->Translate("Text") . '</option> </SELECT> </td></tr>'; $html .= '<tr><td colspan=2>' . $locate->Translate("Note") . ': <input type="text" size="50" maxlength="254" id="optionnote" name="optionnote" value="' . $option['optionnote'] . '"/> <input type="button" value="' . $button_value . '" onclick="addOption(\'f\',\'' . $optionid . '\');return false;"> </td></tr>'; $html .= $enable_html; if ($_SESSION['curuser']['usertype'] == 'admin') { $res = Customer::getGroups(); $groupoptions .= '<select name="groupid" id="groupid" onchange="setCampaign();">'; while ($row = $res->fetchRow()) { $groupoptions .= '<option value="' . $row['groupid'] . '"'; if ($survey['groupid'] == $row['groupid']) { $groupoptions .= ' selected'; } $groupoptions .= '>' . $row['groupname'] . '</option>'; } $groupoptions .= '</select>'; } else { $groupoptions .= $_SESSION['curuser']['group']['groupname'] . '<input id="groupid" name="groupid" type="hidden" value="' . $_SESSION['curuser']['groupid'] . '">'; } if ($survey['campaignid'] == 0) { $campaignoptions = '<option value="0">' . $locate->Translate("All") . '</option>'; } $campaignres = Customer::getRecordsByGroupid($survey['groupid'], "campaign"); while ($row = $campaignres->fetchRow()) { $campaignoptions .= '<option value="' . $row['id'] . '"'; if ($survey['campaignid'] == $row['id']) { $campaignoptions .= ' selected'; } $campaignoptions .= '>' . $row['campaignname'] . '</option>'; } $html .= ' <tr> <td align="left" width="25%">' . $locate->Translate("Group Name") . '</td> <td>' . $groupoptions . '</td> </tr> <tr> <td align="left" width="25%">' . $locate->Translate("Campaign Name") . '*</td> <td><SELECT id="campaignid" name="campaignid">' . $campaignoptions . '</SELECT></td> </tr>'; $html .= ' </table> </form> ' . $locate->Translate("obligatory_fields") . ' '; return $html; }
function getCarriersByZoneID($id_zone) { global $cookie, $cart; $id_groups = array(1); $islogged = _PS_VERSION_ > '1.5' ? Context::getContext()->customer->isLogged() : $cookie->isLogged(); if ($islogged) { $customer = new Customer((int) $cookie->id_customer); $id_groups = $customer->getGroups(); } $result = Carrier::getCarriers(intval($cookie->id_lang), true, false, intval($id_zone), $id_groups, Carrier::ALL_CARRIERS); $resultsArray = array(); foreach ($result as $k => $row) { $carrier = new Carrier(intval($row['id_carrier'])); $shipping_method = $carrier->getShippingMethod(); if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT and $carrier->getMaxDeliveryPriceByWeight($id_zone) === false or $shipping_method == Carrier::SHIPPING_METHOD_PRICE and $carrier->getMaxDeliveryPriceByPrice($id_zone) === false) { unset($result[$k]); continue; } if ($row['range_behavior']) { if (Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $cart->getTotalWeight(), $id_zone) or !Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), $id_zone)) { unset($result[$k]); continue; } } $row['name'] = strval($row['name']) != '0' ? $row['name'] : Configuration::get('PS_SHOP_NAME'); $method = $carrier->getShippingMethod(); $row['price'] = 0; if ($method == Carrier::SHIPPING_METHOD_PRICE) { $row['price'] = $carrier->getDeliveryPriceByPrice($cart->getOrderTotal(Cart::BOTH_WITHOUT_SHIPPING), $id_zone); } else { if ($method == Carrier::SHIPPING_METHOD_WEIGHT) { $row['price'] = $carrier->getDeliveryPriceByWeight($cart->getTotalWeight(), $id_zone); } } if ((int) $row['shipping_handling'] == 1) { $row['price'] = (double) $row['price'] + (double) Configuration::get('PS_SHIPPING_HANDLING'); } if ((int) $row['is_free']) { $row['price'] = 0; } $row['price_tax_exc'] = $row['price']; $address = new Address($cart->id_address_delivery); $tax_rate = $carrier->getTaxesRate($address); $currency = new Currency($cart->id_currency); $row['price'] = $row['price'] * $currency->conversion_rate * (1 + (double) $tax_rate / 100); $row['img'] = file_exists(_PS_SHIP_IMG_DIR_ . intval($row['id_carrier']) . '.jpg') ? _THEME_SHIP_DIR_ . intval($row['id_carrier']) . '.jpg' : ''; $resultsArray[] = $row; } return $resultsArray; }
function formDiallistAdd($userexten, $customerid) { global $locate; // echo $userexten.$customerid;exit; if ($_SESSION['curuser']['usertype'] == 'admin') { $res = Customer::getGroups(); $groupoptions .= '<select name="groupid" id="groupid" onchange="setCampaign();">'; while ($row = $res->fetchRow()) { $groupoptions .= '<option value="' . $row['groupid'] . '"'; $groupoptions .= '>' . $row['groupname'] . '</option>'; } $groupoptions .= '</select>'; $assignoptions = '<input type="text" id="assign" name="assign" size="35"">'; } elseif ($_SESSION['curuser']['usertype'] == 'groupadmin') { $groupoptions .= $_SESSION['curuser']['group']['groupname'] . '<input id="groupid" name="groupid" type="hidden" value="' . $_SESSION['curuser']['groupid'] . '">'; $res = Customer::getRecordsByField('groupid', $_SESSION['curuser']['groupid'], 'astercrm_account'); $assignoptions .= '<select name="assign" id="assign">'; $assignoptions .= '<option value="">' . $locate->Translate("none") . '</option>'; while ($row = $res->fetchRow()) { $assignoptions .= '<option value="' . $row['extension'] . '"'; $assignoptions .= '>' . $row['extension'] . '</option>'; } $assignoptions .= '</select>'; } else { $groupoptions .= $_SESSION['curuser']['group']['groupname'] . '<input id="groupid" name="groupid" type="hidden" value="' . $_SESSION['curuser']['groupid'] . '">'; $assignoptions = '<input type="text" id="assign" name="assign" size="35" value="' . $_SESSION['curuser']['extension'] . '" disabled><input type="hidden" id="assign" name="assign" value="' . $_SESSION['curuser']['extension'] . '">'; } $customernamehtml = ''; if ($userexten != '' && $customerid > 0) { $res_customer = astercrm::getRecordById($customerid, 'customer'); $res_contact = astercrm::getContactListByID($customerid); $numberblank = '<select name="dialnumber" id="dialnumber">'; if ($res_customer['phone'] != '') { $numberblank .= '<option value="' . $res_customer['phone'] . '">' . $res_customer['phone'] . '</option>'; } if ($res_customer['mobile'] != '') { $numberblank .= '<option value="' . $res_customer['mobile'] . '">' . $res_customer['mobile'] . '</option>'; } while ($res_contact->fetchInto($row)) { if ($row['phone'] != '') { $numberblank .= '<option value="' . $row['phone'] . '">' . $row['phone'] . '</option>'; } if ($row['phone1'] != '') { $numberblank .= '<option value="' . $row['phone1'] . '">' . $row['phone1'] . '</option>'; } if ($row['phone2'] != '') { $numberblank .= '<option value="' . $row['phone2'] . '">' . $row['phone2'] . '</option>'; } if ($row['mobile'] != '') { $numberblank .= '<option value="' . $row['mobile'] . '">' . $row['mobile'] . '</option>'; } } $numberblank .= '</select>'; $saveHtml = ' <tr> <td nowrap colspan=2 align=right><input type="button" id="btnAddDiallist" name="btnAddDiallist" value="' . $locate->Translate("continue") . '" onclick="xajax_saveDiallist(xajax.getFormValues(\'formaddDiallist\'),\'' . $userexten . '\',\'' . $customerid . '\');return false;"></td> </tr> <table> </form> '; } else { $numberblank = '<input name="dialnumber" id="dialnumber">'; $customernamehtml = '<tr> <td nowrap align="left">' . $locate->Translate("Customer Name") . '</td> <td align="left"><input name="customername" id="customername"></td> </tr>'; $saveHtml = ' <tr> <td nowrap colspan=2 align=right><input type="button" id="btnAddDiallist" name="btnAddDiallist" value="' . $locate->Translate("continue") . '" onclick="saveDiallistMain(xajax.getFormValues(\'formaddDiallist\'));return false;"></td> </tr> <table> </form> '; } $html = ' <!-- No edit the next line --> <form method="post" name="formaddDiallist" id="formaddDiallist"> <table border="1" width="100%" class="adminlist">' . $customernamehtml . ' <tr> <td nowrap align="left">' . $locate->Translate("Dialnumber") . '*</td> <td align="left">' . $numberblank . '</td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Assign To") . '</td> <td align="left"> ' . $assignoptions . ' </td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Call Order") . '</td> <td align="left"> <input type="text" id="callOrder" name="callOrder" size="20" value="1"> </td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Dialtime") . '</td> <td align="left"> <input type="text" id="dialtime" name="dialtime" size="20" value="' . date("Y-m-d H:i", time()) . '"> <INPUT onclick="displayCalendar(document.getElementById(\'dialtime\'),\'yyyy-mm-dd hh:ii\',this,true)" type="button" value="Cal"> </td> </tr>'; $html .= ' <tr> <td align="left" width="25%">' . $locate->Translate("Group Name") . '</td> <td>' . $groupoptions . '</td> </tr>'; $html .= ' <tr> <td align="left" width="25%">' . $locate->Translate("Campaign Name") . '</td> <td><SELECT id="campaignid" name="campaignid"></SELECT></td> </tr>'; $html .= ' <tr> <td align="left" width="25%">' . $locate->Translate("Memo") . '</td> <td><textarea id="memo" name="memo" cols="50" rows="8"></textarea></td> </tr>'; $html .= $saveHtml; return $html; }
/** * Imprime la forma para editar un nuevo registro sobre el DIV identificado por "formDiv". * * @param $id (int) Identificador del registro a ser editado. * @return $html (string) Devuelve una cadena de caracteres que contiene la forma con los datos * a extraidos de la base de datos para ser editados */ function formEdit($id) { global $locate, $db; $worktimes =& Customer::getRecordByID($id, 'worktimes'); if ($_SESSION['curuser']['usertype'] == 'admin') { $grouphtml .= '<select name="groupid" id="groupid" > <option value=""></option>'; $res = Customer::getGroups(); while ($row = $res->fetchRow()) { $grouphtml .= '<option value="' . $row['groupid'] . '"'; if ($row['groupid'] == $worktimes['groupid']) { $grouphtml .= ' selected '; } $grouphtml .= '>' . $row['groupname'] . '</option>'; } $grouphtml .= '</select>'; } else { $grouphtml .= $_SESSION['curuser']['group']['groupname'] . '<input type="hidden" name="groupid" id="groupid" value="' . $_SESSION['curuser']['groupid'] . '">'; } $html = ' <!-- No edit the next line --> <form method="post" name="f" id="f"> <table border="1" width="100%" class="adminlist"> <tr> <td nowrap align="left"><input type="hidden" id= "id" name="id" value="' . $worktimes['id'] . '">' . $locate->Translate("Time") . '*</td> <td align="left">' . $locate->Translate("From") . ': <input id="starttime" name="starttime" type="text" value="' . $worktimes['starttime'] . '" readonly onclick="showTimeList(\'timelist\');_SetTime(this)"/> ' . $locate->Translate("To") . ': <input id="endtime" name="endtime" type="text" value="' . $worktimes['endtime'] . '" readonly onclick="showTimeList(\'timelist\');_SetTime(this)"/><div id="timelist" ></div></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Week") . '*</td> <td align="left">' . $locate->Translate("From") . ': <SELECT id="startweek" name="startweek"> <OPTION value="1"'; if ($worktimes['startweek'] == 1) { $html .= 'selected'; } $html .= '>' . $locate->Translate("Monday") . '</OPTION> <OPTION value="2"'; if ($worktimes['startweek'] == 2) { $html .= 'selected'; } $html .= '>' . $locate->Translate("Tuesday") . '</OPTION> <OPTION value="3"'; if ($worktimes['startweek'] == 3) { $html .= 'selected'; } $html .= '>' . $locate->Translate("Wednesday") . '</OPTION> <OPTION value="4"'; if ($worktimes['startweek'] == 4) { $html .= 'selected'; } $html .= '>' . $locate->Translate("Thursday") . '</OPTION> <OPTION value="5"'; if ($worktimes['startweek'] == 5) { $html .= 'selected'; } $html .= '>' . $locate->Translate("Friday") . '</OPTION> <OPTION value="6"'; if ($worktimes['startweek'] == 6) { $html .= 'selected'; } $html .= '>' . $locate->Translate("Saturday") . '</OPTION> <OPTION value="7"'; if ($worktimes['startweek'] == 7) { $html .= 'selected'; } $html .= '>' . $locate->Translate("Sunday") . '</OPTION> </SELECT> ' . $locate->Translate("To") . ': <SELECT id="endweek" name="endweek"> <OPTION value="1"'; if ($worktimes['endweek'] == 1) { $html .= 'selected'; } $html .= '>' . $locate->Translate("Monday") . '</OPTION> <OPTION value="2"'; if ($worktimes['endweek'] == 2) { $html .= 'selected'; } $html .= '>' . $locate->Translate("Tuesday") . '</OPTION> <OPTION value="3"'; if ($worktimes['endweek'] == 3) { $html .= 'selected'; } $html .= '>' . $locate->Translate("Wednesday") . '</OPTION> <OPTION value="4"'; if ($worktimes['endweek'] == 4) { $html .= 'selected'; } $html .= '>' . $locate->Translate("Thursday") . '</OPTION> <OPTION value="5"'; if ($worktimes['endweek'] == 5) { $html .= 'selected'; } $html .= '>' . $locate->Translate("Friday") . '</OPTION> <OPTION value="6"'; if ($worktimes['endweek'] == 6) { $html .= 'selected'; } $html .= '>' . $locate->Translate("Saturday") . '</OPTION> <OPTION value="7"'; if ($worktimes['endweek'] == 7) { $html .= 'selected'; } $html .= '>' . $locate->Translate("Sunday") . '</OPTION> </SELECT> </td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Group") . '</td> <td align="left">' . $grouphtml . '</td> </tr> <tr> <td colspan="2" align="center"><button id="submitButton" onClick=\'xajax_update(xajax.getFormValues("f"));return false;\'>' . $locate->Translate("continue") . '</button></td> </tr> </table> '; $html .= ' </form> ' . $locate->Translate("obligatory_fields") . ' '; return $html; }
/** * @return array */ public function getCarriersListForCart() { $carrier_list = array(); //$currency = Currency::getCurrency($this->cart->id_currency); $country_code = Tools::strtoupper(Configuration::get('PS_LOCALE_COUNTRY')); $country = new Country(Country::getByIso($country_code)); $cart_products = $this->cart->getProducts(); $free_shipping = false; // turned off for 1.4 if (version_compare(_PS_VERSION_, '1.5', 'gt')) { foreach ($this->cart->getCartRules() as $rule) { if ($rule['free_shipping']) { $free_shipping = true; break; } } } if ($this->cart->id_carrier > 0) { $selected_carrier = new Carrier($this->cart->id_carrier); $shipping_method = $selected_carrier->getShippingMethod(); if ($free_shipping == false) { if (version_compare(_PS_VERSION_, '1.5', 'lt')) { $price = $shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $this->cart->getOrderShippingCost((int) $this->cart->id_carrier, true, $country, $cart_products); //$price_tax_exc = ($shipping_method == Carrier::SHIPPING_METHOD_FREE //? 0 : $this->cart->getOrderShippingCost((int)$this->cart->id_carrier, false, $country, $cart_products)); } else { $price = $shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $this->cart->getPackageShippingCost((int) $this->cart->id_carrier, true, $country, $cart_products); //$price_tax_exc = ($shipping_method == Carrier::SHIPPING_METHOD_FREE //? 0 : $this->cart->getPackageShippingCost((int)$this->cart->id_carrier, false, $country, $cart_products)); } //$tax_amount = $price - $price_tax_exc; } else { $price = 0; //$price_tax_exc = 0; //$tax_amount = 0; } if ((int) $selected_carrier->active == 1) { $carrier_list['shippingMethods'][] = array('name' => $selected_carrier->name . ' (' . $selected_carrier->id . ')', 'country' => $country->iso_code, 'price' => $this->toAmount($price)); } } else { $i = 0; if ((int) $this->context->cookie->id_customer > 0) { $customer = new Customer((int) $this->context->cookie->id_customer); $address = new Address((int) $this->cart->id_address_delivery); $id_zone = Address::getZoneById((int) $address->id); $carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups()); } else { $carriers = Carrier::getCarriers((int) $this->cart->id_lang, true); } if ($carriers) { foreach ($carriers as $carrier) { $c = new Carrier((int) $carrier['id_carrier']); $shipping_method = $c->getShippingMethod(); if ($free_shipping == false) { if (version_compare(_PS_VERSION_, '1.5', 'lt')) { $price = $shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $this->cart->getOrderShippingCost((int) $carrier['id_carrier'], true, $country, $cart_products); //$price_tax_exc = ($shipping_method == Carrier::SHIPPING_METHOD_FREE //? 0 : $this->cart->getOrderShippingCost((int)$carrier['id_carrier'], false, $country, $cart_products)); } else { $price = $shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $this->cart->getPackageShippingCost((int) $carrier['id_carrier'], true, $country, $cart_products); //$price_tax_exc = ($shipping_method == Carrier::SHIPPING_METHOD_FREE //? 0 : $this->cart->getPackageShippingCost((int)$carrier['id_carrier'], false, $country, $cart_products)); } //$tax_amount = $price - $price_tax_exc; } else { $price = 0; //$price_tax_exc = 0; //$tax_amount = 0; } if ($carrier['id_carrier'] != $this->cart->id_carrier) { if ((int) $carrier['active'] == 1) { $carrier_list['shippingMethods'][] = array('name' => $carrier['name'] . ' (' . $carrier['id_carrier'] . ')', 'country' => $country->iso_code, 'price' => $this->toAmount($price)); $i++; } } } } } return $carrier_list; }
public function getCarriers() { global $cookie, $cart; // code taken from ParentOrderController::_assignCarrier() $customer = new Customer((int) $cookie->id_customer); $address = new Address((int) $cart->id_address_delivery); $id_zone = Address::getZoneById((int) $address->id); $carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups()); return $carriers; }
protected function _assignCarrier() { $customer = new Customer((int) self::$cookie->id_customer); $address = new Address((int) self::$cart->id_address_delivery); $id_zone = Address::getZoneById((int) $address->id); $carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups()); self::$smarty->assign(array('checked' => $this->_setDefaultCarrierSelection($carriers), 'carriers' => $carriers, 'default_carrier' => (int) Configuration::get('PS_CARRIER_DEFAULT'), 'HOOK_EXTRACARRIER' => Module::hookExec('extraCarrier', array('address' => $address)), 'HOOK_BEFORECARRIER' => Module::hookExec('beforeCarrier', array('carriers' => $carriers)))); }
public function customerImport() { $customer_exist = false; $this->receiveTab(); $handle = $this->openCsvFile(); $default_language_id = (int) Configuration::get('PS_LANG_DEFAULT'); $id_lang = Language::getIdByIso(Tools::getValue('iso_lang')); if (!Validate::isUnsignedId($id_lang)) { $id_lang = $default_language_id; } AdminImportController::setLocale(); for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) { if (Tools::getValue('convert')) { $line = $this->utf8EncodeArray($line); } $info = AdminImportController::getMaskedRow($line); AdminImportController::setDefaultValues($info); if (Tools::getValue('forceIDs') && isset($info['id']) && (int) $info['id']) { $customer = new Customer((int) $info['id']); } else { if (array_key_exists('id', $info) && (int) $info['id'] && Customer::customerIdExistsStatic((int) $info['id'])) { $customer = new Customer((int) $info['id']); } else { $customer = new Customer(); } } if (array_key_exists('id', $info) && (int) $info['id'] && Customer::customerIdExistsStatic((int) $info['id'])) { $current_id_customer = $customer->id; $current_id_shop = $customer->id_shop; $current_id_shop_group = $customer->id_shop_group; $customer_exist = true; $customer_groups = $customer->getGroups(); $addresses = $customer->getAddresses((int) Configuration::get('PS_LANG_DEFAULT')); } // Group Importation if (isset($info['group']) && !empty($info['group'])) { foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group) { $group = trim($group); if (empty($group)) { continue; } $id_group = false; if (is_numeric($group) && $group) { $my_group = new Group((int) $group); if (Validate::isLoadedObject($my_group)) { $customer_groups[] = (int) $group; } continue; } $my_group = Group::searchByName($group); if (isset($my_group['id_group']) && $my_group['id_group']) { $id_group = (int) $my_group['id_group']; } if (!$id_group) { $my_group = new Group(); $my_group->name = array($id_lang => $group); if ($id_lang != $default_language_id) { $my_group->name = $my_group->name + array($default_language_id => $group); } $my_group->price_display_method = 1; $my_group->add(); if (Validate::isLoadedObject($my_group)) { $id_group = (int) $my_group->id; } } if ($id_group) { $customer_groups[] = (int) $id_group; } } } elseif (empty($info['group']) && isset($customer->id) && $customer->id) { $customer_groups = array(0 => Configuration::get('PS_CUSTOMER_GROUP')); } AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer); if ($customer->passwd) { $customer->passwd = Tools::encrypt($customer->passwd); } $id_shop_list = explode($this->multiple_value_separator, $customer->id_shop); $customers_shop = array(); $customers_shop['shared'] = array(); $default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT')); if (Shop::isFeatureActive() && $id_shop_list) { foreach ($id_shop_list as $id_shop) { if (empty($id_shop)) { continue; } $shop = new Shop((int) $id_shop); $group_shop = $shop->getGroup(); if ($group_shop->share_customer) { if (!in_array($group_shop->id, $customers_shop['shared'])) { $customers_shop['shared'][(int) $id_shop] = $group_shop->id; } } else { $customers_shop[(int) $id_shop] = $group_shop->id; } } } else { $default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT')); $default_shop->getGroup(); $customers_shop[$default_shop->id] = $default_shop->getGroup()->id; } //set temporally for validate field $customer->id_shop = $default_shop->id; $customer->id_shop_group = $default_shop->getGroup()->id; if (isset($info['id_default_group']) && !empty($info['id_default_group']) && !is_numeric($info['id_default_group'])) { $info['id_default_group'] = trim($info['id_default_group']); $my_group = Group::searchByName($info['id_default_group']); if (isset($my_group['id_group']) && $my_group['id_group']) { $info['id_default_group'] = (int) $my_group['id_group']; } } $my_group = new Group($customer->id_default_group); if (!Validate::isLoadedObject($my_group)) { $customer->id_default_group = (int) Configuration::get('PS_CUSTOMER_GROUP'); } $customer_groups[] = (int) $customer->id_default_group; $customer_groups = array_flip(array_flip($customer_groups)); $res = true; if (($field_error = $customer->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $customer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) { foreach ($customers_shop as $id_shop => $id_group) { $customer->force_id = (bool) Tools::getValue('forceIDs'); if ($id_shop == 'shared') { foreach ($id_group as $key => $id) { $customer->id_shop = (int) $key; $customer->id_shop_group = (int) $id; if ($customer_exist && ($current_id_shop_group == $id || in_array($current_id_shop, ShopGroup::getShopsFromGroup($id)))) { $customer->id = $current_id_customer; $res &= $customer->update(); } else { $res &= $customer->add(); if (isset($addresses)) { foreach ($addresses as $address) { $address['id_customer'] = $customer->id; unset($address['country'], $address['state'], $address['state_iso'], $address['id_address']); Db::getInstance()->insert('address', $address); } } } if ($res && isset($customer_groups)) { $customer->updateGroup($customer_groups); } } } else { $customer->id_shop = $id_shop; $customer->id_shop_group = $id_group; if ($customer_exist && $id_shop == $current_id_shop) { $customer->id = $current_id_customer; $res &= $customer->update(); } else { $res &= $customer->add(); if (isset($addresses)) { foreach ($addresses as $address) { $address['id_customer'] = $customer->id; unset($address['country'], $address['state'], $address['state_iso'], $address['id_address']); Db::getInstance()->insert('address', $address); } } } if ($res && isset($customer_groups)) { $customer->updateGroup($customer_groups); } } } } unset($customer_groups); $customer_exist = false; if (!$res) { $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $info['email'], isset($info['id']) && !empty($info['id']) ? $info['id'] : 'null'); $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError(); } } $this->closeCsvFile($handle); }
/** * Imprime la forma para editar un nuevo registro sobre el DIV identificado por "formDiv". * * @param $id (int) Identificador del registro a ser editado. * @return $html (string) Devuelve una cadena de caracteres que contiene la forma con los datos * a extraidos de la base de datos para ser editados */ function formEdit($id) { global $locate; $knowledge =& Customer::getRecordByID($id, 'knowledge'); if ($_SESSION['curuser']['usertype'] == 'admin') { $grouphtml .= '<select name="groupid" id="groupid" >'; $grouphtml .= '<option value="0">' . $locate->Translate("please_select") . '</option>'; $res = Customer::getGroups(); while ($row = $res->fetchRow()) { $grouphtml .= '<option value="' . $row['groupid'] . '"'; if ($row['groupid'] == $knowledge['groupid']) { $grouphtml .= ' selected '; } $grouphtml .= '>' . $row['groupname'] . '</option>'; } $grouphtml .= '</select>'; } else { $grouphtml .= $_SESSION['curuser']['group']['groupname'] . '<input type="hidden" name="groupid" id="groupid" value="' . $_SESSION['curuser']['groupid'] . '">'; } $html = ' <!-- No edit the next line --> <form method="post" name="f" id="f"> <table border="1" width="100%" class="adminlist"> <tr> <td nowrap align="left">' . $locate->Translate("knowledgetitle") . '*</td> <td align="left"><input type="hidden" id="id" name="id" value="' . $knowledge['id'] . '"><input type="text" id="knowledgetitle" name="knowledgetitle" size="45" maxlength="30" value="' . $knowledge['knowledgetitle'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("content") . '*</td> <td align="left"><textarea rows="10" cols="70" id="content" name="content" wrap="soft" style="overflow:auto;">' . $knowledge['content'] . '</textarea></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("group_name") . '</td> <td align="left">' . $grouphtml . ' </td> </tr> <tr> <td colspan="2" align="center"><button id="submitButton" onClick=\'xajax_update(xajax.getFormValues("f"));return false;\'>' . $locate->Translate("save") . '</button></td> </tr> </table> '; $html .= ' </form> ' . $locate->Translate("obligatory_fields") . ' '; return $html; }
/** * Return package shipping cost * * @param integer $id_carrier Carrier ID (default : current carrier) * @param booleal $use_tax * @param Country $default_country * @param Array $product_list * @param array $product_list List of product concerned by the shipping. If null, all the product of the cart are used to calculate the shipping cost * * @return float Shipping total */ public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null) { if ($this->isVirtualCart()) { return 0; } if (!$default_country) { $default_country = Context::getContext()->country; } $complete_product_list = $this->getProducts(); if (is_null($product_list)) { $products = $complete_product_list; } else { $products = $product_list; } if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_invoice') { $address_id = (int) $this->id_address_invoice; } elseif (count($product_list)) { $prod = current($product_list); $address_id = (int) $prod['id_address_delivery']; } else { $address_id = null; } if (!Address::addressExists($address_id)) { $address_id = null; } $cache_id = 'getPackageShippingCost_' . (int) $this->id . '_' . (int) $address_id . '_' . (int) $id_carrier . '_' . (int) $use_tax . '_' . (int) $default_country->id; if ($products) { foreach ($products as $product) { $cache_id .= '_' . (int) $product['id_product'] . '_' . (int) $product['id_product_attribute']; } } if (Cache::isStored($cache_id)) { return Cache::retrieve($cache_id); } // Order total in default currency without fees $order_total = $this->getOrderTotal(true, Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING, $product_list); // Start with shipping cost at 0 $shipping_cost = 0; // If no product added, return 0 if (!count($products)) { Cache::store($cache_id, $shipping_cost); return $shipping_cost; } // Get id zone if (!$this->isMultiAddressDelivery() && isset($this->id_address_delivery) && $this->id_address_delivery && Customer::customerHasAddress($this->id_customer, $this->id_address_delivery)) { $id_zone = Address::getZoneById((int) $this->id_address_delivery); } else { if (!Validate::isLoadedObject($default_country)) { $default_country = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT')); } $id_zone = (int) $default_country->id_zone; } if ($id_carrier && !$this->isCarrierInRange((int) $id_carrier, (int) $id_zone)) { $id_carrier = ''; } if (empty($id_carrier) && $this->isCarrierInRange((int) Configuration::get('PS_CARRIER_DEFAULT'), (int) $id_zone)) { $id_carrier = (int) Configuration::get('PS_CARRIER_DEFAULT'); } if (empty($id_carrier)) { if ((int) $this->id_customer) { $customer = new Customer((int) $this->id_customer); $result = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, (int) $id_zone, $customer->getGroups()); unset($customer); } else { $result = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, (int) $id_zone); } foreach ($result as $k => $row) { if ($row['id_carrier'] == Configuration::get('PS_CARRIER_DEFAULT')) { continue; } if (!isset(self::$_carriers[$row['id_carrier']])) { self::$_carriers[$row['id_carrier']] = new Carrier((int) $row['id_carrier']); } $carrier = self::$_carriers[$row['id_carrier']]; // Get only carriers that are compliant with shipping method if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && $carrier->getMaxDeliveryPriceByWeight((int) $id_zone) === false || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && $carrier->getMaxDeliveryPriceByPrice((int) $id_zone) === false) { unset($result[$k]); continue; } // If out-of-range behavior carrier is set on "Desactivate carrier" if ($row['range_behavior']) { $check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->getTotalWeight(), (int) $id_zone); $total_order = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list); $check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $total_order, (int) $id_zone, (int) $this->id_currency); // Get only carriers that have a range compatible with cart if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && !$check_delivery_price_by_weight || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && !$check_delivery_price_by_price) { unset($result[$k]); continue; } } if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) { $shipping = $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), (int) $id_zone); } else { $shipping = $carrier->getDeliveryPriceByPrice($order_total, (int) $id_zone, (int) $this->id_currency); } if (!isset($min_shipping_price)) { $min_shipping_price = $shipping; } if ($shipping <= $min_shipping_price) { $id_carrier = (int) $row['id_carrier']; $min_shipping_price = $shipping; } } } if (empty($id_carrier)) { $id_carrier = Configuration::get('PS_CARRIER_DEFAULT'); } if (!isset(self::$_carriers[$id_carrier])) { self::$_carriers[$id_carrier] = new Carrier((int) $id_carrier, Configuration::get('PS_LANG_DEFAULT')); } $carrier = self::$_carriers[$id_carrier]; if (!Validate::isLoadedObject($carrier)) { die(Tools::displayError('Fatal error: "no default carrier"')); } if (!$carrier->active) { Cache::store($cache_id, $shipping_cost); return $shipping_cost; } // Free fees if free carrier if ($carrier->is_free == 1) { Cache::store($cache_id, 0); return 0; } // Select carrier tax if ($use_tax && !Tax::excludeTaxeOption()) { $address = Address::initialize((int) $address_id); $carrier_tax = $carrier->getTaxesRate($address); } $configuration = Configuration::getMultiple(array('PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT')); // Free fees $free_fees_price = 0; if (isset($configuration['PS_SHIPPING_FREE_PRICE'])) { $free_fees_price = Tools::convertPrice((double) $configuration['PS_SHIPPING_FREE_PRICE'], Currency::getCurrencyInstance((int) $this->id_currency)); } $orderTotalwithDiscounts = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, null, null, false); if ($orderTotalwithDiscounts >= (double) $free_fees_price && (double) $free_fees_price > 0) { Cache::store($cache_id, $shipping_cost); return $shipping_cost; } if (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) && $this->getTotalWeight() >= (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] && (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] > 0) { Cache::store($cache_id, $shipping_cost); return $shipping_cost; } // Get shipping cost using correct method if ($carrier->range_behavior) { // Get id zone if (isset($this->id_address_delivery) && $this->id_address_delivery && Customer::customerHasAddress($this->id_customer, $this->id_address_delivery)) { $id_zone = Address::getZoneById((int) $this->id_address_delivery); } else { $id_zone = (int) $default_country->id_zone; } $check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight((int) $carrier->id, $this->getTotalWeight(), (int) $id_zone); // Code Review V&V TO FINISH $check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice($carrier->id, $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list), $id_zone, (int) $this->id_currency); if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && !$check_delivery_price_by_weight || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && !$check_delivery_price_by_price) { $shipping_cost += 0; } else { if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) { $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone); } else { // by price $shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int) $this->id_currency); } } } else { if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) { $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone); } else { $shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int) $this->id_currency); } } // Adding handling charges if (isset($configuration['PS_SHIPPING_HANDLING']) && $carrier->shipping_handling) { $shipping_cost += (double) $configuration['PS_SHIPPING_HANDLING']; } // Additional Shipping Cost per product foreach ($products as $product) { if (!$product['is_virtual']) { $shipping_cost += $product['additional_shipping_cost'] * $product['cart_quantity']; } } $shipping_cost = Tools::convertPrice($shipping_cost, Currency::getCurrencyInstance((int) $this->id_currency)); //get external shipping cost from module if ($carrier->shipping_external) { $module_name = $carrier->external_module_name; $module = Module::getInstanceByName($module_name); if (Validate::isLoadedObject($module)) { if (array_key_exists('id_carrier', $module)) { $module->id_carrier = $carrier->id; } if ($carrier->need_range) { if (method_exists($module, 'getPackageShippingCost')) { $shipping_cost = $module->getPackageShippingCost($this, $shipping_cost, $products); } else { $shipping_cost = $module->getOrderShippingCost($this, $shipping_cost); } } else { $shipping_cost = $module->getOrderShippingCostExternal($this); } // Check if carrier is available if ($shipping_cost === false) { Cache::store($cache_id, false); return false; } } else { Cache::store($cache_id, false); return false; } } // Apply tax if ($use_tax && isset($carrier_tax)) { $shipping_cost *= 1 + $carrier_tax / 100; } // ############################################################### $num = $this->getTotalWeight($product_list); $countryAndState = Address::getCountryAndState((int) $this->id_address_delivery); $state = $countryAndState['id_state']; $pri = false; if ($pri) { echo "carrierid =>" . $id_carrier . "-"; echo 'products => ' . $num . '-'; echo 'state => ' . $state . '-'; } //Ground //if( $id_carrier == 21 ){ if ($id_carrier == 31) { //NO CA if ($state == 313) { if ($num == 1) { $shipping_cost = 19.75; } elseif ($num == 2) { $shipping_cost = 20.5; } elseif ($num == 3) { $shipping_cost = 22.0; } elseif ($num == 4) { $shipping_cost = 24.5; } elseif ($num == 5) { $shipping_cost = 25.75; } elseif ($num == 6) { $shipping_cost = 27.0; } elseif ($num == 7) { $shipping_cost = 30.5; } elseif ($num == 8) { $shipping_cost = 31.5; } elseif ($num == 9) { $shipping_cost = 32.25; } elseif ($num == 10) { $shipping_cost = 33.5; } elseif ($num == 11) { $shipping_cost = 34.25; } else { $shipping_cost = 34.5; } } elseif ($state == 5 || $state == 28) { if ($num == 1) { $shipping_cost = 19.75; } elseif ($num == 2) { $shipping_cost = 20.5; } elseif ($num == 3) { $shipping_cost = 22.25; } elseif ($num == 4) { $shipping_cost = 25.25; } elseif ($num == 5) { $shipping_cost = 26.5; } elseif ($num == 6) { $shipping_cost = 28.0; } elseif ($num == 7) { $shipping_cost = 32.5; } elseif ($num == 8) { $shipping_cost = 33.25; } elseif ($num == 9) { $shipping_cost = 34.5; } elseif ($num == 10) { $shipping_cost = 35.25; } elseif ($num == 11) { $shipping_cost = 36.75; } else { $shipping_cost = 38.0; } } elseif ($state == 44 or $state == 37 or $state == 3 or $state == 47) { if ($num == 1) { $shipping_cost = 22.75; } elseif ($num == 2) { $shipping_cost = 23.75; } elseif ($num == 3) { $shipping_cost = 25.0; } elseif ($num == 4) { $shipping_cost = 25.75; } elseif ($num == 5) { $shipping_cost = 27.5; } elseif ($num == 6) { $shipping_cost = 28.25; } elseif ($num == 7) { $shipping_cost = 33.25; } elseif ($num == 8) { $shipping_cost = 34.5; } elseif ($num == 9) { $shipping_cost = 35.5; } elseif ($num == 10) { $shipping_cost = 36.75; } elseif ($num == 11) { $shipping_cost = 38.0; } else { $shipping_cost = 39.5; } } elseif ($state == 12 || $state == 26 || $state == 6 || $state == 31) { if ($num == 1) { $shipping_cost = 23.0; } elseif ($num == 2) { $shipping_cost = 24.5; } elseif ($num == 3) { $shipping_cost = 25.75; } elseif ($num == 4) { $shipping_cost = 26.5; } elseif ($num == 5) { $shipping_cost = 28.0; } elseif ($num == 6) { $shipping_cost = 29.5; } elseif ($num == 7) { $shipping_cost = 34.75; } elseif ($num == 8) { $shipping_cost = 36.75; } elseif ($num == 9) { $shipping_cost = 38.25; } elseif ($num == 10) { $shipping_cost = 39.5; } elseif ($num == 11) { $shipping_cost = 41.25; } else { $shipping_cost = 42.5; } } elseif ($state == 34 || $state == 41 || $state == 27 || $state == 16 || $state == 36 || $state == 50) { if ($num == 1) { $shipping_cost = 24.0; } elseif ($num == 2) { $shipping_cost = 24.75; } elseif ($num == 3) { $shipping_cost = 26.25; } elseif ($num == 4) { $shipping_cost = 27.75; } elseif ($num == 5) { $shipping_cost = 30.25; } elseif ($num == 6) { $shipping_cost = 33.25; } elseif ($num == 7) { $shipping_cost = 38.5; } elseif ($num == 8) { $shipping_cost = 41.25; } elseif ($num == 9) { $shipping_cost = 44.0; } elseif ($num == 10) { $shipping_cost = 45.75; } elseif ($num == 11) { $shipping_cost = 47.75; } else { $shipping_cost = 49.5; } } elseif ($state == 23 || $state == 15 || $state == 25 || $state == 4 || $state == 18 || $state == 24 || $state == 49) { if ($num == 1) { $shipping_cost = 24.0; } elseif ($num == 2) { $shipping_cost = 25.25; } elseif ($num == 3) { $shipping_cost = 27.5; } elseif ($num == 4) { $shipping_cost = 29.75; } elseif ($num == 5) { $shipping_cost = 32.75; } elseif ($num == 6) { $shipping_cost = 36.25; } elseif ($num == 7) { $shipping_cost = 42.25; } elseif ($num == 8) { $shipping_cost = 44.75; } elseif ($num == 9) { $shipping_cost = 47.0; } elseif ($num == 10) { $shipping_cost = 49.75; } elseif ($num == 11) { $shipping_cost = 52.0; } else { $shipping_cost = 54.0; } } elseif ($state == 2 || $state == 11) { if ($num == 1) { $shipping_cost = 46.0; } elseif ($num == 2) { $shipping_cost = 56.25; } elseif ($num == 3) { $shipping_cost = 64.75; } elseif ($num == 4) { $shipping_cost = 74.0; } elseif ($num == 5) { $shipping_cost = 77.25; } elseif ($num == 6) { $shipping_cost = 85.0; } elseif ($num == 7) { $shipping_cost = 91.5; } elseif ($num == 8) { $shipping_cost = 98.0; } elseif ($num == 9) { $shipping_cost = 105.25; } elseif ($num == 10) { $shipping_cost = 111.5; } elseif ($num == 11) { $shipping_cost = 117.5; } else { $shipping_cost = 124.25; } } else { if ($num == 1) { $shipping_cost = 24.75; } elseif ($num == 2) { $shipping_cost = 26.25; } elseif ($num == 3) { $shipping_cost = 28.75; } elseif ($num == 4) { $shipping_cost = 30.25; } elseif ($num == 5) { $shipping_cost = 35.0; } elseif ($num == 6) { $shipping_cost = 39.0; } elseif ($num == 7) { $shipping_cost = 45.5; } elseif ($num == 8) { $shipping_cost = 48.75; } elseif ($num == 9) { $shipping_cost = 51.75; } elseif ($num == 10) { $shipping_cost = 54.75; } elseif ($num == 11) { $shipping_cost = 58.0; } else { $shipping_cost = 60.5; } } } elseif ($id_carrier == 30) { //NO CA - 302 if ($state == 313) { if ($num == 1) { $shipping_cost = 24.0; } elseif ($num == 2) { $shipping_cost = 24.75; } elseif ($num == 3) { $shipping_cost = 25.25; } elseif ($num == 4) { $shipping_cost = 26.25; } elseif ($num == 5) { $shipping_cost = 27.75; } elseif ($num == 6) { $shipping_cost = 29.75; } elseif ($num == 7) { $shipping_cost = 32.25; } elseif ($num == 8) { $shipping_cost = 34.5; } elseif ($num == 9) { $shipping_cost = 36.25; } elseif ($num == 10) { $shipping_cost = 38.0; } elseif ($num == 11) { $shipping_cost = 40.0; } else { $shipping_cost = 42.0; } } elseif ($state == 5 || $state == 28) { if ($num == 1) { $shipping_cost = 24.0; } elseif ($num == 2) { $shipping_cost = 24.75; } elseif ($num == 3) { $shipping_cost = 25.75; } elseif ($num == 4) { $shipping_cost = 27.75; } elseif ($num == 5) { $shipping_cost = 30.25; } elseif ($num == 6) { $shipping_cost = 33.5; } elseif ($num == 7) { $shipping_cost = 38.0; } elseif ($num == 8) { $shipping_cost = 38.5; } elseif ($num == 9) { $shipping_cost = 40.0; } elseif ($num == 10) { $shipping_cost = 41.75; } elseif ($num == 11) { $shipping_cost = 45.5; } else { $shipping_cost = 47.75; } } elseif ($state == 44 or $state == 37 or $state == 3 or $state == 47) { if ($num == 1) { $shipping_cost = 24.75; } elseif ($num == 2) { $shipping_cost = 25.75; } elseif ($num == 3) { $shipping_cost = 27.0; } elseif ($num == 4) { $shipping_cost = 30.5; } elseif ($num == 5) { $shipping_cost = 34.0; } elseif ($num == 6) { $shipping_cost = 36.75; } elseif ($num == 7) { $shipping_cost = 40.25; } elseif ($num == 8) { $shipping_cost = 42.25; } elseif ($num == 9) { $shipping_cost = 45.25; } elseif ($num == 10) { $shipping_cost = 47.75; } elseif ($num == 11) { $shipping_cost = 50.75; } else { $shipping_cost = 53.5; } } elseif ($state == 12 || $state == 26 || $state == 6 || $state == 31) { if ($num == 1) { $shipping_cost = 24.75; } elseif ($num == 2) { $shipping_cost = 27.75; } elseif ($num == 3) { $shipping_cost = 29.5; } elseif ($num == 4) { $shipping_cost = 33.5; } elseif ($num == 5) { $shipping_cost = 38.0; } elseif ($num == 6) { $shipping_cost = 40.75; } elseif ($num == 7) { $shipping_cost = 45.25; } elseif ($num == 8) { $shipping_cost = 48.0; } elseif ($num == 9) { $shipping_cost = 52.25; } elseif ($num == 10) { $shipping_cost = 54.25; } elseif ($num == 11) { $shipping_cost = 57.25; } else { $shipping_cost = 62.25; } } elseif ($state == 34 || $state == 41 || $state == 27 || $state == 16 || $state == 36 || $state == 50) { if ($num == 1) { $shipping_cost = 25.5; } elseif ($num == 2) { $shipping_cost = 30.5; } elseif ($num == 3) { $shipping_cost = 36.0; } elseif ($num == 4) { $shipping_cost = 40.25; } elseif ($num == 5) { $shipping_cost = 47.75; } elseif ($num == 6) { $shipping_cost = 51.25; } elseif ($num == 7) { $shipping_cost = 56.25; } elseif ($num == 8) { $shipping_cost = 60.25; } elseif ($num == 9) { $shipping_cost = 65.0; } elseif ($num == 10) { $shipping_cost = 69.5; } elseif ($num == 11) { $shipping_cost = 74.25; } else { $shipping_cost = 78.5; } } elseif ($state == 23 || $state == 15 || $state == 25 || $state == 4 || $state == 18 || $state == 24 || $state == 49) { if ($num == 1) { $shipping_cost = 31.5; } elseif ($num == 2) { $shipping_cost = 33.25; } elseif ($num == 3) { $shipping_cost = 38.5; } elseif ($num == 4) { $shipping_cost = 43.75; } elseif ($num == 5) { $shipping_cost = 49.5; } elseif ($num == 6) { $shipping_cost = 54.75; } elseif ($num == 7) { $shipping_cost = 62.25; } elseif ($num == 8) { $shipping_cost = 67.0; } elseif ($num == 9) { $shipping_cost = 72.0; } elseif ($num == 10) { $shipping_cost = 77.25; } elseif ($num == 11) { $shipping_cost = 81.5; } else { $shipping_cost = 86.5; } } elseif ($state == 2 || $state == 11) { if ($num == 1) { $shipping_cost = -1; } elseif ($num == 2) { $shipping_cost = -1; } elseif ($num == 3) { $shipping_cost = -1; } elseif ($num == 4) { $shipping_cost = -1; } elseif ($num == 5) { $shipping_cost = -1; } elseif ($num == 6) { $shipping_cost = -1; } elseif ($num == 7) { $shipping_cost = -1; } elseif ($num == 8) { $shipping_cost = -1; } elseif ($num == 9) { $shipping_cost = -1; } elseif ($num == 10) { $shipping_cost = -1; } elseif ($num == 11) { $shipping_cost = -1; } else { $shipping_cost = -1; } } else { if ($num == 1) { $shipping_cost = 28.25; } elseif ($num == 2) { $shipping_cost = 34.25; } elseif ($num == 3) { $shipping_cost = 41.0; } elseif ($num == 4) { $shipping_cost = 48.25; } elseif ($num == 5) { $shipping_cost = 54.0; } elseif ($num == 6) { $shipping_cost = 59.0; } elseif ($num == 7) { $shipping_cost = 67.0; } elseif ($num == 8) { $shipping_cost = 73.75; } elseif ($num == 9) { $shipping_cost = 77.5; } elseif ($num == 10) { $shipping_cost = 83.25; } elseif ($num == 11) { $shipping_cost = 88.5; } else { $shipping_cost = 93.0; } } } elseif ($id_carrier == 32) { //NO CA - 202 if ($state == 313) { if ($num == 1) { $shipping_cost = 23.75; } elseif ($num == 2) { $shipping_cost = 23.75; } elseif ($num == 3) { $shipping_cost = 26.0; } elseif ($num == 4) { $shipping_cost = 27.5; } elseif ($num == 5) { $shipping_cost = 29.25; } elseif ($num == 6) { $shipping_cost = 30.75; } elseif ($num == 7) { $shipping_cost = 34.75; } elseif ($num == 8) { $shipping_cost = 37.5; } elseif ($num == 9) { $shipping_cost = 40.0; } elseif ($num == 10) { $shipping_cost = 40.75; } elseif ($num == 11) { $shipping_cost = 43.25; } else { $shipping_cost = 45.5; } } elseif ($state == 5 || $state == 28) { if ($num == 1) { $shipping_cost = 23.75; } elseif ($num == 2) { $shipping_cost = 24.25; } elseif ($num == 3) { $shipping_cost = 28.0; } elseif ($num == 4) { $shipping_cost = 29.25; } elseif ($num == 5) { $shipping_cost = 31.75; } elseif ($num == 6) { $shipping_cost = 34.75; } elseif ($num == 7) { $shipping_cost = 38.75; } elseif ($num == 8) { $shipping_cost = 41.25; } elseif ($num == 9) { $shipping_cost = 43.75; } elseif ($num == 10) { $shipping_cost = 46.25; } elseif ($num == 11) { $shipping_cost = 48.25; } else { $shipping_cost = 50.5; } } elseif ($state == 44 or $state == 37 or $state == 3 or $state == 47) { if ($num == 1) { $shipping_cost = 23.75; } elseif ($num == 2) { $shipping_cost = 25.5; } elseif ($num == 3) { $shipping_cost = 30.75; } elseif ($num == 4) { $shipping_cost = 33.0; } elseif ($num == 5) { $shipping_cost = 36.25; } elseif ($num == 6) { $shipping_cost = 40.5; } elseif ($num == 7) { $shipping_cost = 44.75; } elseif ($num == 8) { $shipping_cost = 46.5; } elseif ($num == 9) { $shipping_cost = 50.25; } elseif ($num == 10) { $shipping_cost = 52.5; } elseif ($num == 11) { $shipping_cost = 55.25; } else { $shipping_cost = 59.0; } } elseif ($state == 12 || $state == 26 || $state == 6 || $state == 31) { if ($num == 1) { $shipping_cost = 27.25; } elseif ($num == 2) { $shipping_cost = 30.75; } elseif ($num == 3) { $shipping_cost = 36.0; } elseif ($num == 4) { $shipping_cost = 41.0; } elseif ($num == 5) { $shipping_cost = 46.0; } elseif ($num == 6) { $shipping_cost = 50.5; } elseif ($num == 7) { $shipping_cost = 57.25; } elseif ($num == 8) { $shipping_cost = 61.75; } elseif ($num == 9) { $shipping_cost = 65.0; } elseif ($num == 10) { $shipping_cost = 68.75; } elseif ($num == 11) { $shipping_cost = 72.25; } else { $shipping_cost = 76.75; } } elseif ($state == 34 || $state == 41 || $state == 27 || $state == 16 || $state == 36 || $state == 50) { if ($num == 1) { $shipping_cost = 29.25; } elseif ($num == 2) { $shipping_cost = 38.75; } elseif ($num == 3) { $shipping_cost = 46.5; } elseif ($num == 4) { $shipping_cost = 54.75; } elseif ($num == 5) { $shipping_cost = 62.75; } elseif ($num == 6) { $shipping_cost = 69.75; } elseif ($num == 7) { $shipping_cost = 77.75; } elseif ($num == 8) { $shipping_cost = 84.25; } elseif ($num == 9) { $shipping_cost = 90.75; } elseif ($num == 10) { $shipping_cost = 96.75; } elseif ($num == 11) { $shipping_cost = 105.0; } else { $shipping_cost = 111.25; } } elseif ($state == 23 || $state == 15 || $state == 25 || $state == 4 || $state == 18 || $state == 24 || $state == 49) { if ($num == 1) { $shipping_cost = 32.0; } elseif ($num == 2) { $shipping_cost = 40.25; } elseif ($num == 3) { $shipping_cost = 49.75; } elseif ($num == 4) { $shipping_cost = 58.0; } elseif ($num == 5) { $shipping_cost = 65.5; } elseif ($num == 6) { $shipping_cost = 74.25; } elseif ($num == 7) { $shipping_cost = 82.5; } elseif ($num == 8) { $shipping_cost = 89.5; } elseif ($num == 9) { $shipping_cost = 96.5; } elseif ($num == 10) { $shipping_cost = 102.5; } elseif ($num == 11) { $shipping_cost = 109.25; } else { $shipping_cost = 116.75; } } elseif ($state == 2 || $state == 11) { if ($num == 1) { $shipping_cost = -1; } elseif ($num == 2) { $shipping_cost = -1; } elseif ($num == 3) { $shipping_cost = -1; } elseif ($num == 4) { $shipping_cost = -1; } elseif ($num == 5) { $shipping_cost = -1; } elseif ($num == 6) { $shipping_cost = -1; } elseif ($num == 7) { $shipping_cost = -1; } elseif ($num == 8) { $shipping_cost = -1; } elseif ($num == 9) { $shipping_cost = -1; } elseif ($num == 10) { $shipping_cost = -1; } elseif ($num == 11) { $shipping_cost = -1; } else { $shipping_cost = -1; } } else { if ($num == 1) { $shipping_cost = 34.75; } elseif ($num == 2) { $shipping_cost = 41.0; } elseif ($num == 3) { $shipping_cost = 50.25; } elseif ($num == 4) { $shipping_cost = 59.75; } elseif ($num == 5) { $shipping_cost = 66.5; } elseif ($num == 6) { $shipping_cost = 75.25; } elseif ($num == 7) { $shipping_cost = 84.5; } elseif ($num == 8) { $shipping_cost = 92.25; } elseif ($num == 9) { $shipping_cost = 98.5; } elseif ($num == 10) { $shipping_cost = 105.5; } elseif ($num == 11) { $shipping_cost = 112.0; } else { $shipping_cost = 119.25; } } } elseif ($id_carrier == 29) { //NO CA - 102 if ($state == 313) { if ($num == 1) { $shipping_cost = 27.25; } elseif ($num == 2) { $shipping_cost = 29.0; } elseif ($num == 3) { $shipping_cost = 32.75; } elseif ($num == 4) { $shipping_cost = 36.25; } elseif ($num == 5) { $shipping_cost = 38.75; } elseif ($num == 6) { $shipping_cost = 40.75; } elseif ($num == 7) { $shipping_cost = 45.25; } elseif ($num == 8) { $shipping_cost = 48.25; } elseif ($num == 9) { $shipping_cost = 50.5; } elseif ($num == 10) { $shipping_cost = 54.75; } elseif ($num == 11) { $shipping_cost = 56.25; } else { $shipping_cost = 60.5; } } elseif ($state == 5 || $state == 28) { if ($num == 1) { $shipping_cost = 31.75; } elseif ($num == 2) { $shipping_cost = 37.5; } elseif ($num == 3) { $shipping_cost = 39.5; } elseif ($num == 4) { $shipping_cost = 44.25; } elseif ($num == 5) { $shipping_cost = 48.0; } elseif ($num == 6) { $shipping_cost = 52.75; } elseif ($num == 7) { $shipping_cost = 56.75; } elseif ($num == 8) { $shipping_cost = 59.5; } elseif ($num == 9) { $shipping_cost = 65.0; } elseif ($num == 10) { $shipping_cost = 67.5; } elseif ($num == 11) { $shipping_cost = 71.25; } else { $shipping_cost = 76.5; } } elseif ($state == 44 or $state == 37 or $state == 3 or $state == 47) { if ($num == 1) { $shipping_cost = 38.75; } elseif ($num == 2) { $shipping_cost = 47.75; } elseif ($num == 3) { $shipping_cost = 57.75; } elseif ($num == 4) { $shipping_cost = 64.0; } elseif ($num == 5) { $shipping_cost = 71.25; } elseif ($num == 6) { $shipping_cost = 80.75; } elseif ($num == 7) { $shipping_cost = 85.75; } elseif ($num == 8) { $shipping_cost = 92.5; } elseif ($num == 9) { $shipping_cost = 100.75; } elseif ($num == 10) { $shipping_cost = 105.25; } elseif ($num == 11) { $shipping_cost = 111.5; } else { $shipping_cost = 117.75; } } elseif ($state == 12 || $state == 26 || $state == 6 || $state == 31) { if ($num == 1) { $shipping_cost = 41.25; } elseif ($num == 2) { $shipping_cost = 50.75; } elseif ($num == 3) { $shipping_cost = 61.75; } elseif ($num == 4) { $shipping_cost = 70.75; } elseif ($num == 5) { $shipping_cost = 78.75; } elseif ($num == 6) { $shipping_cost = 86.75; } elseif ($num == 7) { $shipping_cost = 91.5; } elseif ($num == 8) { $shipping_cost = 99.0; } elseif ($num == 9) { $shipping_cost = 105.5; } elseif ($num == 10) { $shipping_cost = 113.0; } elseif ($num == 11) { $shipping_cost = 119.75; } else { $shipping_cost = 126.5; } } elseif ($state == 34 || $state == 41 || $state == 27 || $state == 16 || $state == 36 || $state == 50) { if ($num == 1) { $shipping_cost = 46.75; } elseif ($num == 2) { $shipping_cost = 53.75; } elseif ($num == 3) { $shipping_cost = 67.25; } elseif ($num == 4) { $shipping_cost = 77.0; } elseif ($num == 5) { $shipping_cost = 83.75; } elseif ($num == 6) { $shipping_cost = 93.0; } elseif ($num == 7) { $shipping_cost = 100.25; } elseif ($num == 8) { $shipping_cost = 103.0; } elseif ($num == 9) { $shipping_cost = 112.25; } elseif ($num == 10) { $shipping_cost = 120.5; } elseif ($num == 11) { $shipping_cost = 126.25; } else { $shipping_cost = 132.0; } } elseif ($state == 23 || $state == 15 || $state == 25 || $state == 4 || $state == 18 || $state == 24 || $state == 49) { if ($num == 1) { $shipping_cost = 49.25; } elseif ($num == 2) { $shipping_cost = 56.25; } elseif ($num == 3) { $shipping_cost = 69.0; } elseif ($num == 4) { $shipping_cost = 79.25; } elseif ($num == 5) { $shipping_cost = 88.25; } elseif ($num == 6) { $shipping_cost = 95.75; } elseif ($num == 7) { $shipping_cost = 101.5; } elseif ($num == 8) { $shipping_cost = 109.25; } elseif ($num == 9) { $shipping_cost = 116.0; } elseif ($num == 10) { $shipping_cost = 123.25; } elseif ($num == 11) { $shipping_cost = 130.0; } else { $shipping_cost = 138.75; } } elseif ($state == 2 || $state == 11) { if ($num == 1) { $shipping_cost = 53.75; } elseif ($num == 2) { $shipping_cost = 67.5; } elseif ($num == 3) { $shipping_cost = 78.75; } elseif ($num == 4) { $shipping_cost = 85.5; } elseif ($num == 5) { $shipping_cost = 96.75; } elseif ($num == 6) { $shipping_cost = 101.5; } elseif ($num == 7) { $shipping_cost = 116.25; } elseif ($num == 8) { $shipping_cost = 130.0; } elseif ($num == 9) { $shipping_cost = 142.5; } elseif ($num == 10) { $shipping_cost = 152.5; } elseif ($num == 11) { $shipping_cost = 159.75; } else { $shipping_cost = 168.25; } } else { if ($num == 1) { $shipping_cost = 50.75; } elseif ($num == 2) { $shipping_cost = 60.5; } elseif ($num == 3) { $shipping_cost = 70.5; } elseif ($num == 4) { $shipping_cost = 81.0; } elseif ($num == 5) { $shipping_cost = 90.25; } elseif ($num == 6) { $shipping_cost = 98.5; } elseif ($num == 7) { $shipping_cost = 104.5; } elseif ($num == 8) { $shipping_cost = 113.0; } elseif ($num == 9) { $shipping_cost = 119.25; } elseif ($num == 10) { $shipping_cost = 127.0; } elseif ($num == 11) { $shipping_cost = 133.75; } else { $shipping_cost = 139.75; } } } elseif ($id_carrier == 16) { //NO CA if ($state == 313) { if ($num == 1) { $shipping_cost = 11.0; } elseif ($num == 2) { $shipping_cost = 12.0; } elseif ($num == 3) { $shipping_cost = 12.75; } elseif ($num == 4) { $shipping_cost = 14.75; } elseif ($num == 5) { $shipping_cost = 15.75; } elseif ($num == 6) { $shipping_cost = 16.0; } elseif ($num == 7) { $shipping_cost = 19.0; } elseif ($num == 8) { $shipping_cost = 19.25; } elseif ($num == 9) { $shipping_cost = 20.0; } elseif ($num == 10) { $shipping_cost = 20.75; } elseif ($num == 11) { $shipping_cost = 22.0; } else { $shipping_cost = 22.25; } } elseif ($state == 314) { if ($num == 1) { $shipping_cost = 11.75; } elseif ($num == 2) { $shipping_cost = 12.5; } elseif ($num == 3) { $shipping_cost = 13.75; } elseif ($num == 4) { $shipping_cost = 14.75; } elseif ($num == 5) { $shipping_cost = 16.0; } elseif ($num == 6) { $shipping_cost = 16.75; } elseif ($num == 7) { $shipping_cost = 20.0; } elseif ($num == 8) { $shipping_cost = 20.75; } elseif ($num == 9) { $shipping_cost = 22.0; } elseif ($num == 10) { $shipping_cost = 22.75; } elseif ($num == 11) { $shipping_cost = 24.0; } else { $shipping_cost = 24.0; } } elseif ($state == 315) { if ($num == 1) { $shipping_cost = 12.25; } elseif ($num == 2) { $shipping_cost = 13.75; } elseif ($num == 3) { $shipping_cost = 14.5; } elseif ($num == 4) { $shipping_cost = 15.75; } elseif ($num == 5) { $shipping_cost = 16.5; } elseif ($num == 6) { $shipping_cost = 17.0; } elseif ($num == 7) { $shipping_cost = 20.5; } elseif ($num == 8) { $shipping_cost = 22.0; } elseif ($num == 9) { $shipping_cost = 22.75; } elseif ($num == 10) { $shipping_cost = 24.0; } elseif ($num == 11) { $shipping_cost = 25.25; } else { $shipping_cost = 26.0; } } elseif ($state == 3 || $state == 28) { if ($num == 1) { $shipping_cost = 12.25; } elseif ($num == 2) { $shipping_cost = 14.0; } elseif ($num == 3) { $shipping_cost = 14.75; } elseif ($num == 4) { $shipping_cost = 16.25; } elseif ($num == 5) { $shipping_cost = 17.75; } elseif ($num == 6) { $shipping_cost = 18.75; } elseif ($num == 7) { $shipping_cost = 22.5; } elseif ($num == 8) { $shipping_cost = 24.0; } elseif ($num == 9) { $shipping_cost = 25.25; } elseif ($num == 10) { $shipping_cost = 26.75; } elseif ($num == 11) { $shipping_cost = 28.25; } else { $shipping_cost = 29.0; } } else { if ($num == 1) { $shipping_cost = -1; } elseif ($num == 2) { $shipping_cost = -1; } elseif ($num == 3) { $shipping_cost = -1; } elseif ($num == 4) { $shipping_cost = -1; } elseif ($num == 5) { $shipping_cost = -1; } elseif ($num == 6) { $shipping_cost = -1; } elseif ($num == 7) { $shipping_cost = -1; } elseif ($num == 8) { $shipping_cost = -1; } elseif ($num == 9) { $shipping_cost = -1; } elseif ($num == 10) { $shipping_cost = -1; } elseif ($num == 11) { $shipping_cost = -1; } else { $shipping_cost = -1; } } } //############################################################### $shipping_cost = (double) Tools::ps_round((double) $shipping_cost, 2); Cache::store($cache_id, $shipping_cost); return $shipping_cost; }
function formEdit($id) { global $locate; $diallist =& Customer::getRecordByID($id, 'dnc_list'); if ($_SESSION['curuser']['usertype'] == 'admin') { $res = Customer::getGroups(); $groupoptions .= '<select name="groupid" id="groupid" onchange="setCampaign();">'; $groupoptions .= '<option value="0"'; $groupoptions .= '>' . $locate->Translate("please select") . '</option>'; while ($row = $res->fetchRow()) { $groupoptions .= '<option value="' . $row['groupid'] . '"'; if ($diallist['groupid'] == $row['groupid']) { $groupoptions .= ' selected'; } $groupoptions .= '>' . $row['groupname'] . '</option>'; } $groupoptions .= '</select>'; } else { $groupoptions .= $_SESSION['curuser']['group']['groupname'] . '<input id="groupid" name="groupid" type="hidden" value="' . $_SESSION['curuser']['groupid'] . '">'; } $campaignlist = Customer::getAll("campaign", "groupid", $diallist['groupid']); while ($row = $campaignlist->fetchRow()) { $campaign_options .= '<option value="' . $row['id'] . '"'; if ($diallist['campaignid'] == $row['id']) { $campaign_options .= ' selected'; } $campaign_options .= '>' . $row['campaignname'] . '</option>'; } $html = ' <!-- No edit the next line --> <form method="post" name="formDiallist" id="formDiallist"> <table border="1" width="100%" class="adminlist"> <tr> <td nowrap align="left">' . $locate->Translate("number") . '*</td> <td align="left"> <input type="text" id="number" name="number" size="35" value="' . $diallist['number'] . '"> <input type="hidden" id="id" name="id" value="' . $diallist['id'] . '"> </td> </tr>'; $html .= ' <tr> <td align="left" width="25%">' . $locate->Translate("Group Name") . '</td> <td>' . $groupoptions . '</td> </tr>'; $html .= ' <tr> <td align="left" width="25%">' . $locate->Translate("Campaign Name") . '</td> <td><SELECT id="campaignid" name="campaignid">' . $campaign_options . '</SELECT></td> </tr>'; $html .= ' <tr> <td nowrap colspan=2 align=right><input type="button" id="btnAddDiallist" name="btnAddDiallist" value="' . $locate->Translate("continue") . '" onclick="xajax_update(xajax.getFormValues(\'formDiallist\'));return false;"></td> </tr> <table> </form> '; return $html; }
protected function _getCarrierList() { $address_delivery = new Address(self::$cart->id_address_delivery); if (self::$cookie->id_customer) { $customer = new Customer((int) self::$cookie->id_customer); $groups = $customer->getGroups(); } else { $groups = array(1); } if (!Address::isCountryActiveById((int) self::$cart->id_address_delivery)) { $this->errors[] = Tools::displayError('This address is not in a valid area.'); } elseif (!Validate::isLoadedObject($address_delivery) or $address_delivery->deleted) { $this->errors[] = Tools::displayError('This address is invalid.'); } else { $carriers = Carrier::getCarriersForOrder((int) Address::getZoneById((int) $address_delivery->id), $groups); $result = array('checked' => $this->_setDefaultCarrierSelection($carriers), 'carriers' => $carriers, 'HOOK_BEFORECARRIER' => Module::hookExec('beforeCarrier', array('carriers' => $carriers)), 'HOOK_EXTRACARRIER' => Module::hookExec('extraCarrier', array('address' => $address_delivery))); return $result; } if (sizeof($this->errors)) { return array('hasError' => true, 'errors' => $this->errors); } }
/** * Imprime la forma para editar un nuevo registro sobre el DIV identificado por "formDiv". * * @param $id (int) Identificador del registro a ser editado. * @return $html (string) Devuelve una cadena de caracteres que contiene la forma con los datos * a extraidos de la base de datos para ser editados */ function formEdit($id) { global $locate, $db; $campaignresult =& Customer::getRecordByID($id, 'campaignresult'); if ($_SESSION['curuser']['usertype'] == 'admin') { $grouphtml .= '<select name="groupid" id="groupid" onchange="setCampaign();"> <option value=""></option>'; $res = Customer::getGroups(); while ($row = $res->fetchRow()) { $grouphtml .= '<option value="' . $row['groupid'] . '"'; if ($row['groupid'] == $campaignresult['groupid']) { $grouphtml .= ' selected '; } $grouphtml .= '>' . $row['groupname'] . '</option>'; } $grouphtml .= '</select>'; } else { $grouphtml .= $_SESSION['curuser']['group']['groupname'] . '<input type="hidden" name="groupid" id="groupid" value="' . $_SESSION['curuser']['groupid'] . '">'; } $statusAnswered = ""; $statusNoanswer = ""; if ($campaignresult['status'] == 'ANSWERED') { $statusAnswered = "checked"; } else { $statusNoanswer = "checked"; } $campaign_res = Customer::getRecordsByGroupid($campaignresult['groupid'], "campaign"); while ($campaign_row = $campaign_res->fetchRow()) { $campaignoption .= '<option value="' . $campaign_row['id'] . '"'; if ($campaign_row['id'] == $campaignresult['campaignid']) { $campaignoption .= ' selected '; } $campaignoption .= '>' . $campaign_row['campaignname'] . '</option>'; } $parentoption .= '<option value="0"'; if ($campaignresult['parentid'] == 0) { $parentoption .= ' selected '; } $parentoption .= '>' . $locate->Translate("None") . '</option>'; $parent_res = Customer::getRecordsByField('campaignid', $campaignresult['campaignid'], 'campaignresult'); while ($parent_row = $parent_res->fetchRow()) { if ($parent_row['parentid'] == 0) { $parentoption .= '<option value="' . $parent_row['id'] . '"'; if ($parent_row['id'] == $campaignresult['parentid']) { $parentoption .= ' selected '; } $parentoption .= '>' . $parent_row['resultname'] . '</option>'; } } $html = ' <!-- No edit the next line --> <form method="post" name="f" id="f"> <table border="1" width="100%" class="adminlist"> <tr> <td nowrap align="left">' . $locate->Translate("Result Name") . '*</td> <td align="left"><input type="hidden" id="id" name="id" value="' . $campaignresult['id'] . '"><input type="text" id="resultname" name="resultname" size="30" maxlength="60" value="' . $campaignresult['resultname'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Result Note") . '</td> <td align="left"><input type="text" id="resultnote" name="resultnote" size="30" maxlength="255" value="' . $campaignresult['resultnote'] . '"></td> </tr> <tr> <td align="left" colspan="2">' . $locate->Translate("Answered") . ' <input type="radio" id="status" name="status" value="Answered" ' . $statusAnswered . '> ' . $locate->Translate("Noanswer") . ' <input type="radio" id="status" name="status" value="Noanswer" ' . $statusNoanswer . '> </td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Group") . '</td> <td align="left">' . $grouphtml . '</td> </tr> <tr> <td align="left" width="25%">' . $locate->Translate("Campaign Name") . '</td> <td><SELECT id="campaignid" name="campaignid" onchange="setParentResult();">' . $campaignoption . '</SELECT></td> </tr> <tr> <td align="left" width="25%">' . $locate->Translate("Parent Result Name") . '</td> <td><SELECT id="parentid" name="parentid" >' . $parentoption . '</SELECT></td> </tr> <tr> <td colspan="2" align="center"><button id="submitButton" onClick=\'xajax_update(xajax.getFormValues("f"));return false;\'>' . $locate->Translate("continue") . '</button></td> </tr> </table> '; $html .= ' </form> ' . $locate->Translate("obligatory_fields") . ' '; return $html; }
/** * Imprime la forma para editar un nuevo registro sobre el DIV identificado por "formDiv". * * @param $id (int) Identificador del registro a ser editado. * @return $html (string) Devuelve una cadena de caracteres que contiene la forma con los datos * a extraidos de la base de datos para ser editados */ function formEdit($id) { global $locate, $db; $worktimepackages =& Customer::getRecordByID($id, 'worktimepackages'); if ($_SESSION['curuser']['usertype'] == 'admin') { $grouphtml .= '<select name="groupid" id="groupid" > <option value=""></option>'; $res = Customer::getGroups(); while ($row = $res->fetchRow()) { $grouphtml .= '<option value="' . $row['groupid'] . '"'; if ($row['groupid'] == $worktimepackages['groupid']) { $grouphtml .= ' selected '; } $grouphtml .= '>' . $row['groupname'] . '</option>'; } $grouphtml .= '</select>'; } else { $grouphtml .= $_SESSION['curuser']['group']['groupname'] . '<input type="hidden" name="groupid" id="groupid" value="' . $_SESSION['curuser']['groupid'] . '">'; } //print_r($wp);exit; $query = "SELECT * FROM worktimes"; if ($_SESSION['curuser']['usertype'] != 'admin') { $query .= " WHERE groupid = " . $_SESSION['curuser']['groupid']; } $worktimes_res = $db->query($query); $worktimeshtml .= ''; $i = 0; $weekShow = array('', $locate->Translate("Monday"), $locate->Translate('Tuesday'), $locate->Translate('Wednesday'), $locate->Translate('Thursday'), $locate->Translate('Friday'), $locate->Translate('Saturday'), $locate->Translate('Sunday')); while ($worktimes_row = $worktimes_res->fetchRow()) { $i++; $cur_content = $worktimes_row['id'] . '-' . $locate->Translate("from") . ':' . $worktimes_row['starttime'] . ' ' . $locate->Translate("to") . ':' . $worktimes_row['endtime'] . ' (' . $weekShow[$worktimes_row['startweek']] . '->' . $weekShow[$worktimes_row['endweek']] . ')'; $worktimeshtml .= '<a href="javascript:void(0);" id="op_' . $i . '" onclick="mf_click(' . $i . ', \'' . $cur_content . '\');">' . $cur_content . '</a><input type="hidden" id="worktimeVal_' . $i . '" name="worktimeVal_' . $i . '" value="' . $worktimes_row['id'] . '">'; } $worktimeshtml = ' <table width="300" border="0" cellpadding="0" cellspacing="0" id="formTable"> <tr><td width="180"><div id="worktimeAllDiv">' . $worktimeshtml . '</div></td></tr> <tr><td><div id="worktimeSltdDiv"></div><input type="hidden" id="sltedWorktimes" name="sltedWorktimes" value=""></td></tr> </table>'; if ($worktimepackages['worktimepackage_status'] == 'enable') { $enable = 'checked'; } else { $disabled = 'checked'; } $html = ' <!-- No edit the next line --> <form method="post" name="f" id="f"> <table border="1" width="100%" class="adminlist"> <tr> <td nowrap align="left">' . $locate->Translate("Package Name") . '*</td> <td align="left"><input type="hidden" id="id" name="id" value="' . $worktimepackages['id'] . '"><input type="text" id="worktimepackage_name" name="worktimepackage_name" size="30" maxlength="60" value="' . $worktimepackages['worktimepackage_name'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Package Note") . '</td> <td align="left"><input type="text" id="worktimepackage_note" name="worktimepackage_note" size="30" maxlength="255" value="' . $worktimepackages['worktimepackage_note'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Status") . '*</td> <td align="left" colspan="2">' . $locate->Translate("Enable") . ' <input type="radio" id="worktimepackage_status" name="worktimepackage_status" value="enable" ' . $enable . '> ' . $locate->Translate("Disable") . ' <input type="radio" id="worktimepackage_status" name="worktimepackage_status" value="disabled" ' . $disabled . '></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Select Worktime") . '*</td> <td align="left"><div class="worktimeSltDiv">' . $worktimeshtml . '</div></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Group") . '</td> <td align="left">' . $grouphtml . '</td> </tr> <tr> <td colspan="2" align="center"><button id="submitButton" onClick=\'xajax_update(xajax.getFormValues("f"));return false;\'>' . $locate->Translate("continue") . '</button></td> </tr> </table> '; $html .= ' </form> ' . $locate->Translate("obligatory_fields") . ' '; return $html; }
/** * Imprime la forma para editar un nuevo registro sobre el DIV identificado por "formDiv". * * @param $id (int) Identificador del registro a ser editado. * @return $html (string) Devuelve una cadena de caracteres que contiene la forma con los datos * a extraidos de la base de datos para ser editados */ function formEdit($id) { global $locate; $tickets =& Customer::getRecordByID($id, 'tickets'); if ($_SESSION['curuser']['usertype'] == 'admin') { $grouphtml = '<select name="groupid" id="groupid" onchange="javascript:relateByGid(this.value,document.getElementById(\'id\').value);return false;"><option value="0">' . $locate->Translate("None") . '</option>'; $res = Customer::getGroups(); while ($row = $res->fetchRow()) { $grouphtml .= '<option value="' . $row['groupid'] . '"'; if ($row['groupid'] == $tickets['groupid']) { $grouphtml .= ' selected '; } $grouphtml .= '>' . $row['groupname'] . '</option>'; } $grouphtml .= '</select>'; } else { $grouphtml = '<input type="hidden" name="groupid" id="groupid" value="' . $_SESSION['curuser']['groupid'] . '" />' . $_SESSION['curuser']['group']['groupname']; } $campaignOption = Customer::getCampaignByGid($tickets['groupid'], $tickets['campaignid']); $parentOption = Customer::getParentCateGory($tickets['groupid'], $tickets['fid'], $tickets['id']); $html = ' <!-- No edit the next line --> <form method="post" name="f" id="f"> <table border="1" width="100%" class="adminlist"> <tr> <td nowrap align="left">' . $locate->Translate("Ticket Name") . '*</td> <td align="left"><input type="hidden" id="id" name="id" value="' . $tickets['id'] . '"><input type="text" id="ticketname" name="ticketname" size="25" maxlength="100" value="' . $tickets['ticketname'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Group Name") . '</td> <td align="left">' . $grouphtml . '</td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Campaign Name") . '</td> <td align="left" id="campaignMsg">' . $campaignOption . '</td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Parent Category") . '</td> <td align="left" id="parentMsg">' . $parentOption . '</td> </tr> <tr> <td colspan="2" align="center"><button id="submitButton" onClick=\'xajax_update(xajax.getFormValues("f"));return false;\'>' . $locate->Translate("continue") . '</button></td> </tr> </table> '; $html .= ' </form> ' . $locate->Translate("obligatory_fields") . ' '; return $html; }
/** * For a given {product, warehouse}, gets the carrier available * * @since 1.5.0 * @param Product $product The id of the product, or an array with at least the package size and weight * @return array */ public static function getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = null, $id_shop = null, $cart = null) { if (is_null($id_shop)) { $id_shop = Context::getContext()->shop->id; } if (is_null($cart)) { $cart = Context::getContext()->cart; } $id_address = (int) (!is_null($id_address_delivery) && $id_address_delivery != 0 ? $id_address_delivery : $cart->id_address_delivery); if ($id_address) { $address = new Address($id_address); $id_zone = Address::getZoneById($address->id); // Check the country of the address is activated if (!Address::isCountryActiveById($address->id)) { return array(); } } else { $country = new Country(Configuration::get('PS_COUNTRY_DEFAULT')); $id_zone = $country->id_zone; } // Does the product is linked with carriers? $query = new DbQuery(); $query->select('id_carrier'); $query->from('product_carrier', 'pc'); $query->innerJoin('carrier', 'c', 'c.id_reference = pc.id_carrier_reference AND c.deleted = 0'); $query->where('pc.id_product = ' . (int) $product->id); $query->where('pc.id_shop = ' . (int) $id_shop); $carriers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query); if (!empty($carriers)) { //the product is linked with carriers $carrier_list = array(); foreach ($carriers as $carrier) { //check if the linked carriers are available in current zone if (Carrier::checkCarrierZone($carrier['id_carrier'], $id_zone)) { $carrier_list[] = $carrier['id_carrier']; } } if (!empty($carrier_list)) { return $carrier_list; } else { return array(); } //no linked carrier are available for this zone } $carrier_list = array(); // The product is not dirrectly linked with a carrier // Get all the carriers linked to a warehouse if ($id_warehouse) { $warehouse = new Warehouse($id_warehouse); $warehouse_carrier_list = $warehouse->getCarriers(); } $available_carrier_list = array(); $customer = new Customer($cart->id_customer); $carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups(), $cart); foreach ($carriers as $carrier) { $available_carrier_list[] = $carrier['id_carrier']; } if (empty($warehouse_carrier_list)) { $carrier_list = $available_carrier_list; } else { $carrier_list = array_intersect($warehouse_carrier_list, $available_carrier_list); } if ($product->width > 0 || $product->height > 0 || $product->depth > 0 || $product->weight > 0) { foreach ($carrier_list as $key => $id_carrier) { $carrier = new Carrier($id_carrier); if ($carrier->max_width > 0 && $carrier->max_width < $product->width || $carrier->max_height > 0 && $carrier->max_height < $product->height || $carrier->max_depth > 0 && $carrier->max_depth < $product->depth || $carrier->max_weight > 0 && $carrier->max_weight < $product->weight) { unset($carrier_list[$key]); } } } return $carrier_list; }
/** * Imprime la forma para editar un nuevo registro sobre el DIV identificado por "formDiv". * * @param $id (int) Identificador del registro a ser editado. * @return $html (string) Devuelve una cadena de caracteres que contiene la forma con los datos * a extraidos de la base de datos para ser editados */ function formEdit($id) { global $locate, $db, $config; $campaign =& Customer::getRecordByID($id, 'campaign'); if ($_SESSION['curuser']['usertype'] == 'admin') { $grouphtml .= '<select name="groupid" id="groupid" > <option value=""></option>'; $res = Customer::getGroups(); while ($row = $res->fetchRow()) { $grouphtml .= '<option value="' . $row['groupid'] . '"'; if ($row['groupid'] == $campaign['groupid']) { $grouphtml .= ' selected '; } $grouphtml .= '>' . $row['groupname'] . '</option>'; } $grouphtml .= '</select>'; } else { $grouphtml .= $_SESSION['curuser']['group']['groupname'] . '<input type="hidden" name="groupid" id="groupid" value="' . $_SESSION['curuser']['groupid'] . '">'; } $bindqueue = ""; if ($campaign['bindqueue'] == 1) { $bindqueue = "checked"; } $dialTochecked = ""; if ($campaign['dialtwoparty'] == "yes") { $dialTochecked = "checked"; } $query = "SELECT id,name From servers"; $server_res = $db->query($query); $serverhtml .= '<select name="serverid" id="serverid"> <option value="0">' . $locate->Translate("Default Server") . '</option>'; while ($server_row = $server_res->fetchRow()) { $serverhtml .= '<option value="' . $server_row['id'] . '"'; if ($server_row['id'] == $campaign['serverid']) { $serverhtml .= ' selected '; } $serverhtml .= '>' . $server_row['name'] . '</option>'; } $serverhtml .= '</select>'; $query = "SELECT id,worktimepackage_name From worktimepackages"; if ($_SESSION['curuser']['usertype'] != 'admin') { $query .= " Where groupid =" . $_SESSION['curuser']['groupid']; } $worktimepackage_res = $db->query($query); $worktimepackagehtml .= '<select name="worktime_package_id" id="worktime_package_id"> <option value="0">' . $locate->Translate("Any time") . '</option>'; while ($worktimepackage_row = $worktimepackage_res->fetchRow()) { $worktimepackagehtml .= '<option value="' . $worktimepackage_row['id'] . '"'; if ($worktimepackage_row['id'] == $campaign['worktime_package_id']) { $worktimepackagehtml .= ' selected '; } $worktimepackagehtml .= '>' . $worktimepackage_row['worktimepackage_name'] . '</option>'; } $worktimepackagehtml .= '</select>'; $html = ' <!-- No edit the next line --> <form method="post" name="f" id="f"> <table border="1" width="100%" class="adminlist"> <tr> <td nowrap align="left">' . $locate->Translate("Campaign Name") . '*</td> <td align="left"><input type="hidden" id="id" name="id" value="' . $campaign['id'] . '"><input type="text" id="campaignname" name="campaignname" size="30" maxlength="60" value="' . $campaign['campaignname'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Campaign Note") . '</td> <td align="left"><input type="text" id="campaignnote" name="campaignnote" size="30" maxlength="255" value="' . $campaign['campaignnote'] . '"></td> </tr> <tr> <td align="left" colspan="2">' . $locate->Translate("Enable") . ' <input type="radio" id="enable" name="enable" value="1"'; if ($campaign['enable']) { $html .= 'checked> ' . $locate->Translate("Disable") . ' <input type="radio" id="enable" name="enable" value="0" ></td>'; } else { $html .= '> ' . $locate->Translate("Disable") . ' <input type="radio" id="enable" name="enable" value="0" checked></td>'; } if ($campaign['firstcontext'] != '' && $campaign['nextcontext'] != '') { $crdchecked = 'checked'; $outcontext = $campaign['firstcontext']; $crdcontext = $campaign['outcontext']; $crdtr = ''; $amdchecked = 'checked'; $incontext = $campaign['nextcontext']; $amdcontext = $campaign['incontext']; $amdtr = ''; } else { $outcontext = $campaign['outcontext']; $crdcontext = $config['system']['crdcontext']; $crdtr = 'style="display:none"'; $incontext = $campaign['incontext']; $amdcontext = $config['system']['amdcontext']; $amdtr = 'style="display:none"'; } if ($campaign['enablerecyle'] == 'no') { $recyleno = 'selected'; $recyleyes = ''; } else { $recyleno = ''; $recyleyes = 'selected'; } if ($campaign['use_ext_chan'] == 'yes') { $useExtChanChecked = 'checked'; } else { $useExtChanChecked = ''; } if ($campaign['enablebalance'] == 'no') { $enablebalanceNo = 'selected'; $enablebalanceYes = ''; $enablebalanceStrict = ''; } else { if ($campaign['enablebalance'] == 'yes') { $enablebalanceNo = ''; $enablebalanceYes = 'selected'; $enablebalanceStrict = ''; } else { $enablebalanceNo = ''; $enablebalanceYes = ''; $enablebalanceStrict = 'selected'; } } $html .= '</tr> <tr> <td nowrap align="left">' . $locate->Translate("Asterisk Server") . '*</td> <td align="left">' . $serverhtml . '</td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Worktime package") . '</td> <td align="left">' . $worktimepackagehtml . '</td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Waitting time") . '</td> <td align="left"><input type="text" id="waittime" name="waittime" size="30" maxlength="3" value="' . $campaign['waittime'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Call Result Detect") . '</td> <td align="left"><input type="checkbox" id="crdenable" name="crdenable" onclick="if(this.checked == true){xajax.$(\'crdtr\').style.display=\'\';xajax.$(\'amdtr\').style.display=\'\';}else{xajax.$(\'crdtr\').style.display=\'none\';xajax.$(\'amdtr\').style.display=\'none\';}" ' . $crdchecked . '> </td> </tr> <tr id="crdtr" ' . $crdtr . '> <td nowrap align="left">' . $locate->Translate("CRD context") . '</td> <td align="left"><input type="text" id="crdcontext" name="crdcontext" size="26" maxlength="60" value="' . $crdcontext . '" ></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Outcontext") . '*</td> <td align="left"><input type="text" id="outcontext" name="outcontext" size="30" maxlength="60" value="' . $outcontext . '"></td> </tr> <tr id="amdtr" ' . $amdtr . '> <td nowrap align="left">' . $locate->Translate("AMD context") . '</td> <td align="left"><input type="text" id="amdcontext" name="amdcontext" size="26" maxlength="60" value="' . $amdcontext . '" ></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Incontext") . '*</td> <td align="left"><input type="text" id="incontext" name="incontext" size="30" maxlength="60" value="' . $incontext . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Dial two party at same time") . '</td> <td align="left"><input type="checkbox" id="dialtwoparty" name="dialtwoparty" ' . $dialTochecked . '> </td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Inexten") . '</td> <td align="left"><input type="text" id="inexten" name="inexten" size="30" maxlength="30" value="' . $campaign['inexten'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Queue number") . '</td> <td align="left"> <input type="text" id="queuename" name="queuename" size="30" maxlength="30" value="' . $campaign['queuename'] . '"> <input type="checkbox" name="bindqueue" id="bindqueue" ' . $bindqueue . '>' . $locate->Translate("send calls to this queue directly") . ' </td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Queue Context") . '</td> <td align="left"><input type="text" id="queue_context" name="queue_context" size="30" maxlength="60" value="' . $campaign['queue_context'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Use Extension Channel For Queue") . '</td> <td align="left"><input type="checkbox" id="use_ext_chan" name="use_ext_chan" ' . $useExtChanChecked . '/></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("CallerID") . '</td> <td align="left"><input type="text" id="callerid" name="callerid" size="30" maxlength="30" value="' . $campaign['callerid'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Group") . '*</td> <td align="left">' . $grouphtml . '</td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Max Dialing") . '</td> <td align="left"><input type="text" id="max_dialing" name="max_dialing" size="10" maxlength="4" value="' . $campaign['max_dialing'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Max trytime") . '</td> <td align="left"><input type="text" id="maxtrytime" name="maxtrytime" size="30" maxlength="30" value="' . $campaign['maxtrytime'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Recyle time") . '</td> <td align="left"><input type="text" id="recyletime" name="recyletime" size="10" maxlength="10" value="' . $campaign['recyletime'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Enable Auto Recyle") . '</td> <td align="left"><select name="enablerecyle" id="enablerecyle"><option value="no" ' . $recyleno . ' >' . $locate->Translate("no") . '</option><option value="yes" ' . $recyleyes . '>' . $locate->Translate("yes") . '</option></select></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Min Duration") . '</td> <td align="left"><input type="text" id="minduration" name="minduration" size="10" maxlength="10" value="' . $campaign['minduration'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Agent Answer Min Duration") . '</td> <td align="left"><input type="text" id="minduration_billsec" name="minduration_billsec" size="10" maxlength="10" value="' . $campaign['minduration_billsec'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Customer Answer Min Duration") . '</td> <td align="left"><input type="text" id="minduration_leg_a" name="minduration_leg_a" size="10" maxlength="10" value="' . $campaign['minduration_leg_a'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("SMS Number") . '</td> <td align="left"><input type="text" id="sms_number" name="sms_number" size="20" maxlength="30" value="' . $campaign['sms_number'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Balance") . '</td> <td align="left"><input type="text" id="balance" name="balance" size="20" maxlength="11" value="' . $campaign['balance'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Init Billing") . '</td> <td align="left"><input type="text" id="init_billing" name="init_billing" size="20" maxlength="11" value="' . $campaign['init_billing'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Billing Block") . '</td> <td align="left"><input type="text" id="billing_block" name="billing_block" size="20" maxlength="11" value="' . $campaign['billing_block'] . '"></td> </tr> <tr> <td nowrap align="left">' . $locate->Translate("Enable Balance") . '</td> <td align="left"><select name="enablebalance" id="enablebalance"><option value="yes" ' . $enablebalanceYes . '>' . $locate->Translate("yes") . '</option><option value="no" ' . $enablebalanceNo . '>' . $locate->Translate("no") . '</option><option value="strict" ' . $enablebalanceStrict . '>' . $locate->Translate("strict") . '</option></select></td> </tr>'; //print_r($campaign);exit; $ad_hours = intval($campaign['billsec'] / 3600); $ad_min = intval($campaign['billsec'] % 3600 / 60); $ad_sec = $campaign['billsec'] % 60; $asr = round($campaign['answered'] / $campaign['dialed'] * 100, 2); $acd = round($campaign['billsec'] / $campaign['answered'] / 60, 1); if ($acd > 1) { $acd = $acd . ' ' . $locate->Translate("min"); } else { $acd = round($campaign['billsec'] / $campaign['answered'], 0); $acd = $acd . ' ' . $locate->Translate("sec"); } $rsd = round(($campaign['duration_answered'] + $campaign['duration_noanswer'] - $campaign['billsec_leg_a']) / $campaign['dialed'], 0); $abandoned =& $db->getOne("SELECT COUNT(*) FROM campaigndialedlist WHERE billsec_leg_a > 0 AND billsec = 0 AND campaignid = '{$id}'"); //print_r($campaign);exit; //统计数据 $html .= '<tr> <td colspan="2" nowrap align="left"><table border="1" width="100%" class="adminlist"> <tr> <td> ' . $locate->Translate("Total calls") . ': <b>' . $campaign['dialed'] . '</b> </td> <td> ' . $locate->Translate("Answered calls") . ': <b>' . $campaign['answered'] . '</b> </td> <tr> <tr> <td> ' . $locate->Translate("Transfered") . ': <b>' . $campaign['transfered'] . '</b> </td> <td> ' . $locate->Translate("Transfere Rate") . ': <b>' . round($campaign['transfered'] / $campaign['answered'] * 100, 2) . '%</b> </td> <tr> <tr> <td> ' . $locate->Translate("Answered duration") . ': <b>' . $ad_hours . ' ' . $locate->Translate("hour") . ' ' . $ad_min . $locate->Translate("min") . ' ' . $ad_sec . ' ' . $locate->Translate("sec") . ' </b> </td> <td> ' . $locate->Translate("ASR") . ': <b>' . $asr . '%</b> </td> <tr> <tr> <td> ' . $locate->Translate("ACD") . ': <b>' . $acd . '</b> </td> <td> ' . $locate->Translate("RSD") . ': <b>' . $rsd . ' ' . $locate->Translate("sec") . '</b> </td> <tr> <tr> <td> ' . $locate->Translate("abandoned") . ': <b>' . $abandoned . '</b> </td> <td> <a href="dialedlist.php?cid=' . $id . '&action=abandoned">' . $locate->Translate("abandoned detail") . '</a></b> </td> <tr> </table></td> </tr>'; $html .= '<tr> <td colspan="2" align="center"><button id="submitButton" onClick=\'xajax_update(xajax.getFormValues("f"));return false;\'>' . $locate->Translate("continue") . '</button></td> </tr> </table> '; $html .= ' </form> ' . $locate->Translate("obligatory_fields") . ' '; return $html; }
/** * For a given {product, warehouse}, gets the carrier available * * @since 1.5.0 * * @param Product $product The id of the product, or an array with at least the package size and weight * @param int $id_warehouse Warehouse ID * @param int $id_address_delivery Delivery Address ID * @param int $id_shop Shop ID * @param Cart $cart Cart object * @param array &$error contain an error message if an error occurs * * @return array Available Carriers * @throws PrestaShopDatabaseException */ public static function getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = null, $id_shop = null, $cart = null, &$error = array()) { static $ps_country_default = null; if ($ps_country_default === null) { $ps_country_default = Configuration::get('PS_COUNTRY_DEFAULT'); } if (is_null($id_shop)) { $id_shop = Context::getContext()->shop->id; } if (is_null($cart)) { $cart = Context::getContext()->cart; } if (is_null($error) || !is_array($error)) { $error = array(); } $id_address = (int) (!is_null($id_address_delivery) && $id_address_delivery != 0 ? $id_address_delivery : $cart->id_address_delivery); if ($id_address) { $id_zone = Address::getZoneById($id_address); // Check the country of the address is activated if (!Address::isCountryActiveById($id_address)) { return array(); } } else { $country = new Country($ps_country_default); $id_zone = $country->id_zone; } // Does the product is linked with carriers? $cache_id = 'Carrier::getAvailableCarrierList_' . (int) $product->id . '-' . (int) $id_shop; if (!Cache::isStored($cache_id)) { $query = new DbQuery(); $query->select('id_carrier'); $query->from('product_carrier', 'pc'); $query->innerJoin('carrier', 'c', 'c.id_reference = pc.id_carrier_reference AND c.deleted = 0 AND c.active = 1'); $query->where('pc.id_product = ' . (int) $product->id); $query->where('pc.id_shop = ' . (int) $id_shop); $carriers_for_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query); Cache::store($cache_id, $carriers_for_product); } else { $carriers_for_product = Cache::retrieve($cache_id); } $carrier_list = array(); if (!empty($carriers_for_product)) { //the product is linked with carriers foreach ($carriers_for_product as $carrier) { //check if the linked carriers are available in current zone if (Carrier::checkCarrierZone($carrier['id_carrier'], $id_zone)) { $carrier_list[$carrier['id_carrier']] = $carrier['id_carrier']; } } if (empty($carrier_list)) { return array(); } //no linked carrier are available for this zone } // The product is not directly linked with a carrier // Get all the carriers linked to a warehouse if ($id_warehouse) { $warehouse = new Warehouse($id_warehouse); $warehouse_carrier_list = $warehouse->getCarriers(); } $available_carrier_list = array(); $cache_id = 'Carrier::getAvailableCarrierList_getCarriersForOrder_' . (int) $id_zone . '-' . (int) $cart->id; if (!Cache::isStored($cache_id)) { $customer = new Customer($cart->id_customer); $carrier_error = array(); $carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups(), $cart, $carrier_error); Cache::store($cache_id, array($carriers, $carrier_error)); } else { list($carriers, $carrier_error) = Cache::retrieve($cache_id); } $error = array_merge($error, $carrier_error); foreach ($carriers as $carrier) { $available_carrier_list[$carrier['id_carrier']] = $carrier['id_carrier']; } if ($carrier_list) { $carrier_list = array_intersect($available_carrier_list, $carrier_list); } else { $carrier_list = $available_carrier_list; } if (isset($warehouse_carrier_list)) { $carrier_list = array_intersect($carrier_list, $warehouse_carrier_list); } $cart_quantity = 0; $cart_weight = 0; foreach ($cart->getProducts(false, false) as $cart_product) { if ($cart_product['id_product'] == $product->id) { $cart_quantity += $cart_product['cart_quantity']; } if (isset($cart_product['weight_attribute']) && $cart_product['weight_attribute'] > 0) { $cart_weight += $cart_product['weight_attribute'] * $cart_product['cart_quantity']; } else { $cart_weight += $cart_product['weight'] * $cart_product['cart_quantity']; } } if ($product->width > 0 || $product->height > 0 || $product->depth > 0 || $product->weight > 0 || $cart_weight > 0) { foreach ($carrier_list as $key => $id_carrier) { $carrier = new Carrier($id_carrier); // Get the sizes of the carrier and the product and sort them to check if the carrier can take the product. $carrier_sizes = array((int) $carrier->max_width, (int) $carrier->max_height, (int) $carrier->max_depth); $product_sizes = array((int) $product->width, (int) $product->height, (int) $product->depth); rsort($carrier_sizes, SORT_NUMERIC); rsort($product_sizes, SORT_NUMERIC); if ($carrier_sizes[0] > 0 && $carrier_sizes[0] < $product_sizes[0] || $carrier_sizes[1] > 0 && $carrier_sizes[1] < $product_sizes[1] || $carrier_sizes[2] > 0 && $carrier_sizes[2] < $product_sizes[2]) { $error[$carrier->id] = Carrier::SHIPPING_SIZE_EXCEPTION; unset($carrier_list[$key]); } if ($carrier->max_weight > 0 && ($carrier->max_weight < $product->weight * $cart_quantity || $carrier->max_weight < $cart_weight)) { $error[$carrier->id] = Carrier::SHIPPING_WEIGHT_EXCEPTION; unset($carrier_list[$key]); } } } return $carrier_list; }
public function customerImport() { $customer_exist = false; $this->receiveTab(); $handle = $this->openCsvFile(); AdminImportController::setLocale(); for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) { if (Tools::getValue('convert')) { $line = $this->utf8EncodeArray($line); } $info = AdminImportController::getMaskedRow($line); AdminImportController::setDefaultValues($info); if (array_key_exists('id', $info) && (int) $info['id'] && Customer::customerIdExistsStatic((int) $info['id'])) { $customer = new Customer((int) $info['id']); $current_id_customer = $customer->id; $current_id_shop = $customer->id_shop; $current_id_shop_group = $customer->id_shop_group; $customer_exist = true; $customer_groups = $customer->getGroups(); $addresses = $customer->getAddresses((int) Configuration::get('PS_LANG_DEFAULT')); foreach ($customer_groups as $key => $group) { if ($group == $customer->id_default_group) { unset($customer_groups[$key]); } } } else { $customer = new Customer(); } AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer); if ($customer->passwd) { $customer->passwd = Tools::encrypt($customer->passwd); } $id_shop_list = explode($this->multiple_value_separator, $customer->id_shop); $customers_shop = array(); $customers_shop['shared'] = array(); $default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT')); if (Shop::isFeatureActive() && $id_shop_list) { foreach ($id_shop_list as $id_shop) { $shop = new Shop((int) $id_shop); $group_shop = $shop->getGroup(); if ($group_shop->share_customer) { if (!in_array($group_shop->id, $customers_shop['shared'])) { $customers_shop['shared'][(int) $id_shop] = $group_shop->id; } } else { $customers_shop[(int) $id_shop] = $group_shop->id; } } } else { $default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT')); $default_shop->getGroup(); $customers_shop[$default_shop->id] = $default_shop->getGroup()->id; } //set temporally for validate field $customer->id_shop = $default_shop->id; $customer->id_shop_group = $default_shop->getGroup()->id; $res = true; if (($field_error = $customer->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $customer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) { foreach ($customers_shop as $id_shop => $id_group) { if ($id_shop == 'shared') { foreach ($id_group as $key => $id) { $customer->id_shop = (int) $key; $customer->id_shop_group = (int) $id; if ($customer_exist && ($current_id_shop_group == $id || in_array($current_id_shop, ShopGroup::getShopsFromGroup($id)))) { $customer->id = $current_id_customer; $res &= $customer->update(); } else { unset($customer->id); $res &= $customer->add(); if (isset($customer_groups)) { $customer->addGroups($customer_groups); } if (isset($addresses)) { foreach ($addresses as $address) { $address['id_customer'] = $customer->id; unset($address['country'], $address['state'], $address['state_iso'], $address['id_address']); Db::getInstance()->insert('address', $address); } } } } } else { $customer->id_shop = $id_shop; $customer->id_shop_group = $id_group; if ($customer_exist && $id_shop == $current_id_shop) { $customer->id = $current_id_customer; $res &= $customer->update(); } else { unset($customer->id); $res &= $customer->add(); if (isset($customer_groups)) { $customer->addGroups($customer_groups); } if (isset($addresses)) { foreach ($addresses as $address) { $address['id_customer'] = $customer->id; unset($address['country'], $address['state'], $address['state_iso'], $address['id_address']); Db::getInstance()->insert('address', $address); } } } } } } $customer_exist = false; if (!$res) { $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $info['email'], isset($info['id']) ? $info['id'] : 'null'); $this->errors[] = ($field_error !== true ? $field_error : '') . ($lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError(); } } $this->closeCsvFile($handle); }