Popravek cen - pred 7.12 se morajo upostevati stare

This commit is contained in:
pero1203 2020-12-07 11:07:54 +01:00
parent 069b95a658
commit c2295ec15b
5 changed files with 55 additions and 25 deletions

View File

@ -78,34 +78,64 @@ class UserNarocila{
} }
// Izracunamo koncno ceno glede na paket, trajanje in popust (v eur) // Izracunamo koncno ceno glede na paket, trajanje in popust (v eur)
public function getPrice($package_name, $trajanje, $discount=0){ public function getPrice($package_name, $trajanje, $discount=0, $time=''){
$cena = array(); $cena = array();
// Mesecna cena paketa // Mesecna cena paketa
$package_price = $this->packages[$package_name]['price']; $package_price = $this->packages[$package_name]['price'];
// Mesecno ceno zmanjsamo glede na trajanje // Narocila pred 7.12. morajo imeti stare cene
if($package_name == '2ka'){ if($time != '' && strtotime($time) < strtotime('2020-12-07')){
if((int)$trajanje >= 12){
$cena['monthly'] = number_format($package_price - 4, 2, '.', ''); // Mesecno ceno zmanjsamo glede na trajanje
if($package_name == '2ka'){
if((int)$trajanje >= 12){
$cena['monthly'] = number_format(11.90 - 2, 2, '.', '');
}
elseif((int)$trajanje >= 3){
$cena['monthly'] = number_format(11.90 - 1, 2, '.', '');
}
else{
$cena['monthly'] = number_format(11.90, 2, '.', '');
}
} }
elseif((int)$trajanje >= 3){ elseif($package_name == '3ka'){
$cena['monthly'] = number_format($package_price - 2, 2, '.', ''); if((int)$trajanje >= 12){
} $cena['monthly'] = number_format(21.90 - 2, 2, '.', '');
else{ }
$cena['monthly'] = number_format($package_price, 2, '.', ''); elseif((int)$trajanje >= 3){
$cena['monthly'] = number_format(21.90 - 1, 2, '.', '');
}
else{
$cena['monthly'] = number_format(21.90, 2, '.', '');
}
} }
} }
elseif($package_name == '3ka'){ else{
if((int)$trajanje >= 12){
$cena['monthly'] = number_format($package_price - 3, 2, '.', ''); // Mesecno ceno zmanjsamo glede na trajanje
if($package_name == '2ka'){
if((int)$trajanje >= 12){
$cena['monthly'] = number_format($package_price - 4, 2, '.', '');
}
elseif((int)$trajanje >= 3){
$cena['monthly'] = number_format($package_price - 2, 2, '.', '');
}
else{
$cena['monthly'] = number_format($package_price, 2, '.', '');
}
} }
elseif((int)$trajanje >= 3){ elseif($package_name == '3ka'){
$cena['monthly'] = number_format($package_price - 1.5, 2, '.', ''); if((int)$trajanje >= 12){
} $cena['monthly'] = number_format($package_price - 3, 2, '.', '');
else{ }
$cena['monthly'] = number_format($package_price, 2, '.', ''); elseif((int)$trajanje >= 3){
$cena['monthly'] = number_format($package_price - 1.5, 2, '.', '');
}
else{
$cena['monthly'] = number_format($package_price, 2, '.', '');
}
} }
} }
@ -324,7 +354,7 @@ class UserNarocila{
echo '<td>'.$data_row['payment_method'].'</td>'; echo '<td>'.$data_row['payment_method'].'</td>';
// Cena // Cena
$cena = $this->getPrice($data_row['package_name'], $data_row['trajanje'], $data_row['discount']); $cena = $this->getPrice($data_row['package_name'], $data_row['trajanje'], $data_row['discount'], $data_row['time']);
// Zavezanec iz tujine nima ddv-ja // Zavezanec iz tujine nima ddv-ja
if($this->isWithoutDDV($data_row['id'])) if($this->isWithoutDDV($data_row['id']))
@ -417,7 +447,7 @@ class UserNarocila{
echo '<td>'.($this->isWithoutDDV($data_row['id']) ? $lang['no'] : $lang['yes']).'</td>'; echo '<td>'.($this->isWithoutDDV($data_row['id']) ? $lang['no'] : $lang['yes']).'</td>';
// Cena // Cena
$cena = $this->getPrice($data_row['package_name'], $data_row['trajanje'], $data_row['discount']); $cena = $this->getPrice($data_row['package_name'], $data_row['trajanje'], $data_row['discount'], $data_row['time']);
// Zavezanec iz tujine nima ddv-ja // Zavezanec iz tujine nima ddv-ja
if($this->isWithoutDDV($data_row['id'])) if($this->isWithoutDDV($data_row['id']))
@ -519,7 +549,7 @@ class UserNarocila{
// Podatki narocila // Podatki narocila
$cena = $this->getPrice($rowNarocilo['package_name'], $rowNarocilo['trajanje'], $rowNarocilo['discount']); $cena = $this->getPrice($rowNarocilo['package_name'], $rowNarocilo['trajanje'], $rowNarocilo['discount'], $rowNarocilo['time']);
echo '<div class="edit_narocilo_segment">'; echo '<div class="edit_narocilo_segment">';

View File

@ -122,7 +122,7 @@ class UserNarocilaCebelica{
$UA = new UserNarocila(); $UA = new UserNarocila();
// Dobimo ceno // Dobimo ceno
$cena = $UA->getPrice($this->narocilo['package_name'], $this->narocilo['trajanje'], $this->narocilo['discount']); $cena = $UA->getPrice($this->narocilo['package_name'], $this->narocilo['trajanje'], $this->narocilo['discount'], $this->narocilo['time']);
// Dobimo jezik za predracun/racun // Dobimo jezik za predracun/racun
$lang = $UA->getNarociloLanguage($this->narocilo['id']); $lang = $UA->getNarociloLanguage($this->narocilo['id']);

View File

@ -63,7 +63,7 @@ class UserNarocilaPaypal{
$UA = new UserNarocila(); $UA = new UserNarocila();
$cena = $UA->getPrice($this->narocilo['package_name'], $this->narocilo['trajanje'], $this->narocilo['discount']); $cena = $UA->getPrice($this->narocilo['package_name'], $this->narocilo['trajanje'], $this->narocilo['discount'], $this->narocilo['time']);
if($this->narocilo['trajanje'] == 1) if($this->narocilo['trajanje'] == 1)
$months_string = 'mesec'; $months_string = 'mesec';

View File

@ -59,7 +59,7 @@ class UserNarocilaStripe{
$UA = new UserNarocila(); $UA = new UserNarocila();
$cena = $UA->getPrice($this->narocilo['package_name'], $this->narocilo['trajanje'], $this->narocilo['discount']); $cena = $UA->getPrice($this->narocilo['package_name'], $this->narocilo['trajanje'], $this->narocilo['discount'], $this->narocilo['time']);
if($this->narocilo['trajanje'] == 1) if($this->narocilo['trajanje'] == 1)
$months_string = 'mesec'; $months_string = 'mesec';

View File

@ -85,7 +85,7 @@ class UserPlacila{
$rowPackage = mysqli_fetch_array($sqlPackage); $rowPackage = mysqli_fetch_array($sqlPackage);
$UA = new UserNarocila(); $UA = new UserNarocila();
$cena = $UA->getPrice($rowPackage['name'], $narocilo['trajanje'], $narocilo['discount']); $cena = $UA->getPrice($rowPackage['name'], $narocilo['trajanje'], $narocilo['discount'], $narocilo['time']);
// Zavezanec iz tujine je placal brez ddv // Zavezanec iz tujine je placal brez ddv
$cena_placano = ($UA->isWithoutDDV($narocilo['id'])) ? $cena['final_without_tax'] : $cena['final']; $cena_placano = ($UA->isWithoutDDV($narocilo['id'])) ? $cena['final_without_tax'] : $cena['final'];