All pastes #500488 Raw Edit

rdgn

public php v1 · immutable
·published 2007-05-21 16:36 UTC
rendered paste body
<?php/*  $Id: ot_popust.php,v 1.11 2003/02/14 06:03:32 hpdl Exp $  osCommerce, Open Source E-Commerce Solutions  http://www.oscommerce.com  Copyright (c) 2003 osCommerce  Released under the GNU General Public License*/  class ot_popust {    var $title, $output;    function ot_popust() {      $this->code = 'ot_popust';      $this->title = 'Popust';      $this->description = 'Racuna popust na ukupnu kolicinu';      $this->enabled = ((MODULE_ORDER_TOTAL_POPUST_STATUS == 'true') ? true : false);      $this->sort_order = MODULE_ORDER_TOTAL_POPUST_SORT_ORDER;      $this->output = array();    }    function process() {      global $order, $currencies;      $popust_factor = 0;      if ($order->info['total'] >= 5000) {	$popust_factor = 20;      } elseif ($order->info['total'] >= 2500) {        $popust_factor = 10;      }      if (strstr($order->info['payment_method'], 'Kreditna kartica')) $popust_factor /= 2;      if ($popust_factor) {        $popust_txt = $popust_factor . '%';	$popust = $popust_factor * $order->info['total'] / 100;        $order->info['total'] -= $popust;      $this->output[] = array('title' => 'Popust:',                              'text' => $currencies->format($popust, true, $order->info['currency'], $order->info['currency_value']),                              'value' => -1 * $popust);	}  if (strstr($order->info['payment_method'], 'Kreditna kartica'))  {  $this->output[] = array('title' => 'Karti&#269;no pla&#263;anje:',                              'text' => $currencies->format(round($order->info['total']*1.1, 2), true, $order->info['currency'], $order->info['currency_value']),                              'value' => round($order->info['total']*1.1, 2));  }    }    function check() {      if (!isset($this->_check)) {        $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_POPUST_STATUS'");        $this->_check = tep_db_num_rows($check_query);      }      return $this->_check;    }    function keys() {      return array('MODULE_ORDER_TOTAL_POPUST_STATUS', 'MODULE_ORDER_TOTAL_POPUST_SORT_ORDER');    }    function install() {      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Display Popust', 'MODULE_ORDER_TOTAL_POPUST_STATUS', 'true', 'Do you want to display popust?', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_POPUST_SORT_ORDER', '4', 'Sort order of display.', '6', '2', now())");    }    function remove() {      tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");    }  }?>