1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247:
<?php
if (!defined("OBJENABLED")) {
require_once(dirname(__FILE__) . "/obj.class.php");
}
class PHPShopUser extends PHPShopObj {
function __construct($objID) {
$this->objID = $objID;
$this->cache = false;
$this->objBase = $GLOBALS['SysValue']['base']['shopusers'];
parent::__construct();
}
function getParam($str) {
return str_replace("\"", """, parent::getParam($str));
}
function getAdresList() {
$data_adres = unserialize(parent::getParam('data_adres'));
if (!is_array($data_adres) OR !count($data_adres['list']))
return "";
foreach ($data_adres['list'] as $index => $data_adres_one) {
$dis = "";
foreach ($data_adres_one as $key => $value) {
if ($value)
$dis .= " ," . $value;
}
if ($dis) {
if ($index == $data_adres['main'])
$sel = 'selected="selected"';
else
$sel = "";
$disp .= '<option value="' . $index . '" ' . $sel . '>' . substr($dis, 2) . '</option>';
}
}
if ($disp)
$disp = '
<b>'.__('').'</b>
<select name="adres_id" id="adres_id" class="form-control selectpicker show-menu-arrow">
<option value="none">'.__('').'</option>
' . $disp . '
</select><br>
<input type="checkbox" name="adres_this_default" value="1"> '.__('').'
<input type="hidden" class="adresListJson" value=\'' . PHPShopString::json_safe_encode($data_adres['list']) . '\'>
';
return $disp;
}
function getValue($str) {
return $this->getParam($str);
}
function getName() {
return $this->getParam("name");
}
function getPersonalDiscount() {
return $this->getParam("cumulative_discount");
}
function getStatus() {
return $this->getParam("status");
}
function getStatusName() {
$PHPShopUserStatus = new PHPShopUserStatus($this->getStatus());
return $PHPShopUserStatus->getParam("name");
}
function getDiscount() {
$PHPShopUserStatus = new PHPShopUserStatus($this->getStatus());
return $PHPShopUserStatus->getDiscount();
}
function getBonus(){
return intval($this->getParam("bonus"));
}
}
class PHPShopUserStatus extends PHPShopObj {
function __construct($objID, $import_data = null) {
$this->objID = $objID;
$this->cache = true;
$this->objBase = $GLOBALS['SysValue']['base']['table_name28'];
parent::__construct('id', $import_data);
}
function getPrice() {
return parent::getParam("price");
}
function getDiscount() {
$discount_status = parent::getParam("discount");
$PHPShopUser = new PHPShopUser($_SESSION['UsersId']);
$discount_user = $PHPShopUser->getPersonalDiscount();
$discount = max($discount_status, $discount_user);
return $discount;
}
}
class PHPShopUserFunction {
static function ChekDiscount($mysum) {
global $PHPShopSystem,$link_db;
$maxsum = 0;
$userdiscount = 0;
$maxdiscount = 0;
$sql = "select * from " . $GLOBALS['SysValue']['base']['table_name23'] . " where sum < '$mysum' and enabled='1'";
$result = mysqli_query($link_db,$sql);
while ($row = mysqli_fetch_array($result)) {
$sum = $row['sum'];
if ($sum > $maxsum) {
$maxsum = $sum;
$maxdiscount = $row['discount'];
}
}
if (!empty($_SESSION['UsersStatus'])) {
$PHPShopUserStatus = new PHPShopUserStatus($_SESSION['UsersStatus']);
$userdiscount = $PHPShopUserStatus->getDiscount();
}
else
$userdiscoun = 0;
if ($userdiscount > $maxdiscount)
$maxdiscount = $userdiscount;
$sum = $mysum - ($mysum * @$maxdiscount / 100);
$format = $PHPShopSystem->getSerilizeParam("admoption.price_znak");
$array = array(0 + @$maxdiscount, number_format($sum, $format, ".", ""));
return $array;
}
}
class PHPShopUserStatusArray extends PHPShopArray {
function __construct() {
$this->objBase=$GLOBALS['SysValue']['base']['shopusers_status'];
$this->objSQL=array('enabled'=>"='1'");
parent::__construct('id',"name",'discount','price');
}
}
?>