diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
commit | 75160b12821f7f4299cce7f0b69c83c1502ae071 (patch) | |
tree | 27e25e4ccaef45f0c58b22831164050d1af1d4db /frontend/payments | |
parent | prvi-commit (diff) | |
download | 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.gz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.bz2 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.lz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.xz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.zst 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.zip |
Diffstat (limited to '')
8 files changed, 325 insertions, 78 deletions
diff --git a/frontend/payments/classes/class.ApiNarocilaController.php b/frontend/payments/classes/class.ApiNarocilaController.php index 6c9daed..6a92fb6 100644 --- a/frontend/payments/classes/class.ApiNarocilaController.php +++ b/frontend/payments/classes/class.ApiNarocilaController.php @@ -36,8 +36,11 @@ class ApiNarocilaController{ // Logiramo response klica
$SL = new SurveyLog();
- if($this->response['success'] == true){
-
+ // Napaka pri klicu
+ if(isset($this->response['success']) && $this->response['success'] == false){
+ $SL->addMessage(SurveyLog::PAYMENT, "NAPAKA pri klicu za plačevanje ".$this->params['action'].": ".$this->response['error']);
+ }
+ else{
if(isset($this->data['email']))
$call_data = ', '.$this->data['email'];
elseif(isset($this->data['narocilo_id']))
@@ -47,9 +50,6 @@ class ApiNarocilaController{ $SL->addMessage(SurveyLog::PAYMENT, "USPEŠEN KLIC (".$this->params['action'] . $call_data.")");
}
- else{
- $SL->addMessage(SurveyLog::PAYMENT, "NAPAKA pri klicu za plačevanje ".$this->params['action'].": ".$this->response['error']);
- }
$SL->write();
@@ -128,6 +128,7 @@ class ApiNarocilaController{ switch ($this->params['action']) {
+
// Ustvari novo narocilo
case 'create_narocilo':
$narocilo = new UserNarocila();
@@ -135,6 +136,7 @@ class ApiNarocilaController{ break;
+
// Posodobi obstoječe narocilo (npr. nastavi nacin placila)
case 'update_narocilo':
$narocilo = new UserNarocila();
@@ -142,6 +144,36 @@ class ApiNarocilaController{ break;
+
+ // Dobi podatke zadnjega narocila za uporabnika
+ case 'get_last_narocilo':
+
+ $usr_id = 0;
+
+ // Dobimo user id iz emaila
+ if(isset($this->data['email'])){
+ $sqlU = sisplet_query("SELECT id FROM users WHERE email='".$this->data['email']."'");
+ $rowU = mysqli_fetch_array($sqlU);
+
+ $usr_id = $rowU['id'];
+ }
+
+ if($usr_id == '' || $usr_id == 0){
+ $this->response['error'] = 'ERROR! Missing user ID.';
+ $this->response['success'] = false;
+
+ break;
+ }
+
+ // Dobimo podatke zadnjega narocila
+ $narocilo = new UserNarocila();
+ $last_narocilo = $narocilo->getLastNarocilo($usr_id);
+
+ $this->response = $last_narocilo;
+
+ break;
+
+
// Dobimo pdf predracun (ce ne obstaja ga ustvarimo)
case 'get_predracun':
@@ -156,6 +188,7 @@ class ApiNarocilaController{ break;
+
// Dobimo pdf racun
case 'get_racun':
@@ -170,6 +203,7 @@ class ApiNarocilaController{ break;
+
// Placamo narocilo - aktiviramo uporabniku paket za uporabo, zgeneriramo in vrnemo url do pdf racuna in ga tudi posljemo po mailu
case 'placaj_narocilo':
@@ -349,7 +383,7 @@ class ApiNarocilaController{ $podatki = $reader->city($this->data['ip']);
// Vrnemo ime države
- $this->response['drzava'] = $podatki->country->name;
+ $this->response['drzava'] = $podatki->country->name ?? '';
break;
}
diff --git a/frontend/payments/classes/class.UserAccess.php b/frontend/payments/classes/class.UserAccess.php index 105d4c9..070c723 100644 --- a/frontend/payments/classes/class.UserAccess.php +++ b/frontend/payments/classes/class.UserAccess.php @@ -80,6 +80,7 @@ class UserAccess{ 'telephone' => 3, // Telefonska anketa
'chat' => 3, // Chat
'panel' => 3, // Panel
+ 'email_access' => 3, // Dostop z emailom
/* Ostale funkcionalnosti */
'prevajanje' => 2, // Vecjezikovna anketa
@@ -120,10 +121,9 @@ class UserAccess{ }
private function __construct($usr_id){
- global $app_settings;
// Ce so paketi onemogoceni nič ne preverjamo
- if(!isset($app_settings['commercial_packages']) || $app_settings['commercial_packages'] == false){
+ if(AppSettings::getInstance()->getSetting('app_settings-commercial_packages') !== true){
return;
}
@@ -133,7 +133,11 @@ class UserAccess{ if(isset($_POST['anketa']) || isset($_GET['anketa'])){
$ank_id = (isset($_GET['anketa'])) ? $_GET['anketa'] : $_POST['anketa'];
-
+
+ // Pogledamo, ce smo v izpolnjevanju ankete - imamo hash in pridobimo id iz njega
+ if($_SERVER["SCRIPT_NAME"] == '/main/survey/index.php')
+ $ank_id = getSurveyIdFromHash($ank_id);
+
$sqlU = sisplet_query("SELECT insert_uid FROM srv_anketa WHERE id='".$ank_id."'");
$rowU = mysqli_fetch_array($sqlU);
@@ -163,6 +167,8 @@ class UserAccess{ echo 'Napaka! Manjka ID uporabnika.';
die();
}
+
+
}
@@ -202,12 +208,12 @@ class UserAccess{ private function checkAnketaOld(){
// Ce nismo znotraj ankete ti ignoriramo
- if(!isset($_GET['anketa'])){
+ if(!isset($_GET['anketa']) && !isset($_POST['anketa'])){
return;
}
// Nastavimo id ankete
- $ank_id = $_GET['anketa'];
+ $ank_id = isset($_GET['anketa']) ? $_GET['anketa'] : $_POST['anketa'];
$sqlA = sisplet_query("SELECT insert_time FROM srv_anketa WHERE id='".$ank_id."'");
$rowA = mysqli_fetch_array($sqlA);
@@ -229,13 +235,12 @@ class UserAccess{ // Preverimo ce ima uporabnik dostop do neke funkcionalnosti
public function checkUserAccess($what=''){
- global $app_settings;
global $admin_type;
global $global_user_id;
global $mysql_database_name;
// Ce so paketi onemogoceni vrnemo vedno true
- if(!isset($app_settings['commercial_packages']) || $app_settings['commercial_packages'] == false){
+ if(AppSettings::getInstance()->getSetting('app_settings-commercial_packages') !== true){
return true;
}
@@ -277,11 +282,10 @@ class UserAccess{ // Vrnemo paket uporabnika
public function getPackage(){
- global $app_settings;
global $admin_type;
// Ce so paketi onemogoceni vrnemo -1
- if(!isset($app_settings['commercial_packages']) || $app_settings['commercial_packages'] == false){
+ if(AppSettings::getInstance()->getSetting('app_settings-commercial_packages') !== true){
return -1;
}
@@ -345,25 +349,44 @@ class UserAccess{ // Kateri paket je potreben za to funkcionalnost
$package_required = (isset($this->functionality_package[$what])) ? $this->functionality_package[$what] : 3;
- $package_required_name = $this->packages[$package_required]['name'];
+ $package_temp = $this->packages[$package_required]['name'];
+ $package_required_name = $lang['paket_opis_'.$package_temp];
if($lang['id'] == '2')
$drupal_url = $site_url.'d/en/purchase/'.$package_required.'/package';
else
$drupal_url = $site_url.'d/izvedi-nakup/'.$package_required.'/podatki';
-
+ echo '<div class="layout_right_item">';
echo '<div class="user_access_warning">';
-
+
+ echo '<div class="no_access_title"> <span class="faicon lock_close yellow"></span>'.$lang['srv_access_no_access_title'].'</div>';
+
// Ce user ni avtor ankete
if($this->user_not_author){
echo '<p>'.$lang['srv_access_no_access_not_author'].'</p>';
}
-
+ echo '<div class="no_access_stavki">';
echo '<p>'.$lang['srv_access_no_access'].' "'.$package_required_name.'".</p>';
+
+ echo '<p>'.$lang['srv_access_no_access_funkcionalnosti_intro'].'</p>';
+
+ echo '<ul class="no_access_list">';
+ echo '<li>'.$lang['srv_access_no_access_funkcionalnost_1'].'</li>';
+ echo '<li>'.$lang['srv_access_no_access_funkcionalnost_2'].'</li>';
+ echo '<li>'.$lang['srv_access_no_access_funkcionalnost_3'].'</li>';
+ echo '<li>'.$lang['srv_access_no_access_funkcionalnost_4'].'</li>';
+ echo '</ul>';
+
+
+ echo '</div>';
+
if(!$this->user_not_author)
- echo '<span class="floatLeft"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_blue" href="'.$drupal_url.'" target="_blank">'.$lang['srv_narocila_buy'].'</a></div></span>';
+ echo '<div class="button_holder top16 upgrade_packet">';
+ echo '<button class="medium yellow upgrade_packet" onClick="window.location.href=\''.$drupal_url.'\'" target="_blank">'.$lang['srv_narocila_buy'].'</button>';
+ echo '</div>';
echo '</div>';
+ echo '</div>';
}
// Izpisemo popup obvestilo, da je funkcionalnost onemogocena in naj kupi paket
@@ -373,22 +396,31 @@ class UserAccess{ // Kateri paket je potreben za to funkcionalnost
$package_required = (isset($this->functionality_package[$what])) ? $this->functionality_package[$what] : 3;
- $package_required_name = $this->packages[$package_required]['name'];
+ $package_temp = $this->packages[$package_required]['name'];
+ $package_required_name = $lang['paket_opis_'.$package_temp];
if($lang['id'] == '2')
$drupal_url = $site_url.'d/en/purchase/'.$package_required.'/package';
else
$drupal_url = $site_url.'d/izvedi-nakup/'.$package_required.'/podatki';
+
+ echo '<h2>'.$lang['srv_access_upgrade'].'</h2>';
+
+ echo '<div class="popup_close"><a href="#" onclick="popupUserAccess_close();">✕</a></div>';
+
// Ce user ni avtor ankete
if($this->user_not_author){
echo '<p>'.$lang['srv_access_no_access_not_author'].'</p>';
}
echo '<p>'.$lang['srv_access_no_access'].' "'.$package_required_name.'".</p>';
+
+ echo '<div class="button_holder">';
+ echo ' <button class="medium white-blue" href="#" onClick="popupUserAccess_close();">'.$lang['srv_zapri'].'</button>';
if(!$this->user_not_author)
- echo '<span class="floatRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_blue" href="'.$drupal_url.'" target="_blank">'.$lang['srv_narocila_buy'].'</a></div></span>';
- echo '<span class="floatRight spaceRight"><div class="buttonwrapper"><a class="ovalbutton ovalbutton_gray" href="#" onClick="popupUserAccess_close();">'.$lang['srv_zapri'].'</a></div></span>';
+ echo ' <a href="'.$drupal_url.'" target="_blank"><button class="medium blue">'.$lang['srv_narocila_buy'].'</button></a>';
+ echo '</div>';
}
// Izpisemo obvestilo, da je funkcionalnost onemogocena in naj kupi paket
@@ -402,7 +434,8 @@ class UserAccess{ // Kateri paket je potreben za to funkcionalnost
$package_required = (isset($this->functionality_package[$what])) ? $this->functionality_package[$what] : 3;
- $package_required_name = $this->packages[$package_required]['name'];
+ $package_temp = $this->packages[$package_required]['name'];
+ $package_required_name = $lang['paket_opis_'.$package_temp];
echo '<p class="user_access_warning_text">';
@@ -459,6 +492,22 @@ class UserAccess{ return $what;
}
+ public function getPackageName($package_id) {
+ global $lang;
+
+ $string = '';
+
+ if ($package_id == 1) {
+ $string = $lang['paket_opis_1ka'];
+ } else if($package_id == 2) {
+ $string = $lang['paket_opis_2ka'];
+ } else if($package_id == 3) {
+ $string = $lang['paket_opis_3ka'];
+ }
+
+ return $string;
+ }
+
// Ajax klici
public function ajax(){
diff --git a/frontend/payments/classes/class.UserNarocila.php b/frontend/payments/classes/class.UserNarocila.php index e831e33..cc562c2 100644 --- a/frontend/payments/classes/class.UserNarocila.php +++ b/frontend/payments/classes/class.UserNarocila.php @@ -32,6 +32,39 @@ class UserNarocila{ }
+ // Dobimo podatke zadnjega narocila za dolocenega uporabnika
+ public function getNarocilo($narocilo_id){
+ global $admin_type;
+
+ $return = array();
+
+ // Dobimo narocilo uporabnika
+ $sqlNarocilo = sisplet_query("SELECT un.*, up.name AS package_name, up.description AS package_description, up.price AS package_price
+ FROM user_access_narocilo un, user_access_paket up
+ WHERE un.id='".$narocilo_id."' AND un.package_id=up.id
+ ");
+
+ // Uporabnik nima se nobenega narocila
+ if(mysqli_num_rows($sqlNarocilo) == 0){
+ $return['id'] = '0';
+ }
+ else{
+ $row = mysqli_fetch_array($sqlNarocilo);
+ $return = $row;
+
+ // Cena
+ $cena = $this->getPrice($row['package_name'], $row['trajanje'], $row['discount'], $row['time']);
+
+ // Zavezanec iz tujine nima ddv-ja
+ if($this->isWithoutDDV($row['id']))
+ $return['koncna_cena'] = $cena['final_without_tax'];
+ else
+ $return['koncna_cena'] = $cena['final'];
+ }
+
+ return $return;
+ }
+
// Dobimo array narocil (vseh oz. za dolocenega uporabnika)
private function getNarocila($usr_id=0){
global $admin_type;
@@ -77,6 +110,30 @@ class UserNarocila{ return $narocila;
}
+ // Dobimo podatke zadnjega narocila za dolocenega uporabnika
+ public function getLastNarocilo($usr_id){
+ global $admin_type;
+
+ $return = array();
+
+ // Dobimo zadnje narocilo uporabnika
+ $sqlNarocilo = sisplet_query("SELECT un.*, up.name AS package_name, up.description AS package_description, up.price AS package_price
+ FROM user_access_narocilo un, user_access_paket up
+ WHERE un.usr_id='".$usr_id."' AND un.package_id=up.id
+ ORDER BY un.time DESC
+ ");
+
+ // Uporabnik nima se nobenega narocila
+ if(mysqli_num_rows($sqlNarocilo) == 0){
+ $return['id'] = '0';
+ }
+ else{
+ $return = mysqli_fetch_array($sqlNarocilo);
+ }
+
+ return $return;
+ }
+
// Izracunamo koncno ceno glede na paket, trajanje in popust (v eur)
public function getPrice($package_name, $trajanje, $discount=0, $time=''){
@@ -294,16 +351,71 @@ class UserNarocila{ $ua = UserAccess::getInstance($global_user_id);
$user_access = $ua->getAccess();
- // Ce ni polja v bazi oz je nastavljen paket na 1 ima osnovni paket
- if(!$user_access || $user_access['package_id'] == '1'){
- echo '<p>'.$lang['srv_narocila_current_package'].':</span> <span class="bold">1KA</span></p>';
+ $sqlA = sisplet_query("SELECT ua.time_activate, ua.time_expire, uap.id AS package_id, uap.name AS package_name
+ FROM user_access ua, user_access_paket uap
+ WHERE ua.usr_id='$global_user_id' AND uap.id=ua.package_id
+ ");
+ $rowA = mysqli_fetch_array($sqlA);
+
+ echo '<div id="user_info_segment_narocila">';
+
+ echo '<div class="user_info text">';
+ if(AppSettings::getInstance()->getSetting('app_settings-commercial_packages') === true){
+ echo '<div class="setting_holder">'.$lang['srv_access_package'].':</div>';
+ if($rowA['package_id'] == '2' || $rowA['package_id'] == '3'){
+ echo '<div class="setting_holder">'.$lang['srv_narocila_current_start'].':</div>';
+ echo '<div class="setting_holder">'.$lang['srv_narocila_current_expire'].':</div>';
+ }
+ }
+ echo '</div>';
+
+ echo '<div class="user_info data bold">';
+
+ // Trenutni paket funkcionalnosti
+
+ $drupal_url = ($lang['id'] == '2') ? $site_url.'d/en/' : $site_url.'d/';
+
+ // Ni nobenega paketa
+ if(mysqli_num_rows($sqlA) == 0){
+
+ $package_string = '<div class="setting_holder">'.$lang['paket_opis_1ka'].' ('.$lang['srv_access_package_free'].')</div>';
+ $package_string .= '<div class="setting_holder"><button class="medium yellow" type="button" onClick="window.location.href=\''.$drupal_url.''.$lang['srv_narocila_buyurl'].'\';">'.$lang['srv_narocila_buy'].'</button></div>';
}
- // Imamo aktiviran paket - izpisemo podatke
else{
- echo '<div class="data"><span class="setting_title">'.$lang['srv_narocila_current_package'].':</span> <span class="bold">'.$user_access['package_name'],'</span></div>';
- echo '<div class="data"><span class="setting_title">'.$lang['srv_narocila_current_start'].':</span> <span class="bold">'.date( 'd.m.Y', strtotime($user_access['time_activate'])).'</span></div>';
- echo '<div class="data"><span class="setting_title">'.$lang['srv_narocila_current_expire'].':</span> <span class="bold">'.date( 'd.m.Y', strtotime($user_access['time_expire'])),'</span></div>';
+
+ $userAccess = UserAccess::getInstance($global_user_id);
+ $package_name = $userAccess->getPackageName($rowA['package_id']);
+
+ // Ce ima paket 2 ali 3
+ if($rowA['package_id'] == '2' || $rowA['package_id'] == '3'){
+
+ // Ce je paket ze potekel
+ if(strtotime($rowA['time_expire']) < time()){
+
+ $package_string = '<div class="setting_holder">'.$package_name.'</div>';
+ $package_string .= '<div class="setting_holder">'.date("d.m.Y", strtotime($rowA['time_activate'])).'</div>';
+ $package_string .= '<div class="setting_holder">'.$lang['srv_access_package_expire'].' '.date("d.m.Y", strtotime($rowA['time_expire'])).'</div>';
+
+ $package_string .= '<div class="setting_holder"><button class="medium yellow" type="button" onClick="window.location.href=\''.$drupal_url.'izvedi-nakup/'.$rowA['package_id'].'/podatki/\';">'.$lang['srv_narocila_extend'].'</button></div>';
+ }
+ else{
+ $package_string = '<div class="setting_holder">'.$package_name.'</div>';
+ $package_string .= '<div class="setting_holder">'.date("d.m.Y", strtotime($rowA['time_activate'])).'</div>';
+ $package_string .= '<div class="setting_holder">'.date("d.m.Y", strtotime($rowA['time_expire'])).'</div>';
+
+ $package_string .= '<div class="setting_holder"><button class="medium yellow" type="button" onClick="window.location.href=\''.$drupal_url.'izvedi-nakup/'.$rowA['package_id'].'/podatki/\';">'.$lang['srv_narocila_extend'].'</button></div>';
+ }
+ }
+ else{
+ $package_string = '<div class="setting_holder">'.$package_name.' ('.$lang['srv_access_package_free'].')</div>';
+ $package_string .= '<div class="setting_holder"><button class="medium yellow" type="button" onClick="window.location.href=\''.$drupal_url.''.$lang['srv_narocila_buyurl'].'\';">'.$lang['srv_narocila_buy'].'</button></div>';
+ }
}
+ echo $package_string;
+
+ echo '</div>';
+
+ echo '</div>';
echo '</fieldset>';
@@ -337,37 +449,55 @@ class UserNarocila{ echo ' <thead>';
echo ' <tr>';
- echo ' <th>'.$lang['srv_narocilo_paket'].'</th>';
- echo ' <th>'.$lang['srv_narocilo_trajanje'].' ('.$lang['srv_narocilo_trajanje_mesecev'].')</th>';
echo ' <th>'.$lang['srv_narocilo_cas'].'</th>';
- echo ' <th>'.$lang['srv_narocilo_nacin_placila'].'</th>';
- echo ' <th>'.$lang['srv_narocilo_cena'].'</th>';
+ echo ' <th>'.$lang['srv_narocilo_paket'].'</th>';
+ echo ' <th>'.$lang['srv_narocilo_veljavnodo'].'</th>';
+ echo ' <th>'.$lang['srv_narocilo_samo_cena'].'</th>';
echo ' <th>'.$lang['srv_narocilo_status'].'</th>';
- echo ' <th>'.$lang['srv_narocilo_pdf'].'</th>';
-
+ echo ' <th class="center">'.$lang['srv_narocilo_pdf_predracun'].'</th>';
+ echo ' <th class="center">'.$lang['srv_narocilo_pdf_racun'].'</th>';
echo ' </tr>';
echo ' </thead>';
// Vsebina tabele
echo ' <tbody>';
+ $userAccess = UserAccess::getInstance($global_user_id);
+
foreach($data as $usr_id => $data_row){
+ $package_name = $userAccess->getPackageName($data_row['package_id']);
+
echo '<tr>';
- echo '<td>'.$data_row['package_name'].'</td>';
- echo '<td>'.$data_row['trajanje'].'</td>';
echo '<td>'.date("j.n.Y H:i", strtotime($data_row['time'])).'</td>';
- echo '<td>'.$data_row['payment_method'].'</td>';
+
+ //Sklanjanje za število mesecev
+ if ($data_row['trajanje'] == 1)
+ $trajanje = $data_row['trajanje'] .' '. $lang['srv_narocilo_trajanje_1'];
+ else if ($data_row['trajanje'] == 2)
+ $trajanje = $data_row['trajanje'] .' '. $lang['srv_narocilo_trajanje_2'];
+ else if ($data_row['trajanje'] == 3 || $data_row['trajanje'] == 4)
+ $trajanje = $data_row['trajanje'] .' '. $lang['srv_narocilo_trajanje_3_4'];
+ else
+ $trajanje = $data_row['trajanje'] .' '. $lang['srv_narocilo_trajanje_5'];
+
+ echo '<td>'.$package_name.' ('.$trajanje.')</td>';
+
+ //Veljavnost paketa
+ $meseci = $data_row['trajanje'];
+ $veljaven_do = date("j.n.Y H:i", strtotime("+$meseci months", strtotime($data_row['time'])));
+
+ echo '<td>'.$veljaven_do.'</td>';
// Cena
$cena = $this->getPrice($data_row['package_name'], $data_row['trajanje'], $data_row['discount'], $data_row['time']);
// Zavezanec iz tujine nima ddv-ja
if($this->isWithoutDDV($data_row['id']))
- echo '<td>'.$cena['final_without_tax'].'</td>';
+ echo '<td>'.$cena['final_without_tax'].'€</td>';
else
- echo '<td>'.$cena['final'].'</td>';
+ echo '<td>'.$cena['final'].'€</td>';
if($data_row['status'] == '0')
$status_color = 'red';
@@ -378,12 +508,13 @@ class UserNarocila{ echo '<td class="'.$status_color.'">'.$lang['srv_narocilo_status_'.$data_row['status']].'</td>';
// PDF
- echo '<td>';
- echo '<span class="pointer as_link" onClick="getNarociloPredracun(\''.$data_row['id'].'\')">'.$lang['srv_narocilo_pdf_predracun'].'</span>';
+ echo '<td class="center"><span class="faicon pdf empty red pointer" onClick="getNarociloPredracun(\''.$data_row['id'].'\')"></span></td>';
+
if($data_row['status'] == '1'){
- echo ' | <span class="pointer as_link" onClick="getNarociloRacun(\''.$data_row['id'].'\')">'.$lang['srv_narocilo_pdf_racun'].'</span>';
+ echo '<td class="center"><span class="faicon pdf empty red pointer" onClick="getNarociloRacun(\''.$data_row['id'].'\')"></span></td>';
}
- echo '</td>';
+ else
+ echo '<td></td>';
echo '</tr>';
}
@@ -395,16 +526,16 @@ class UserNarocila{ // Izpisemo seznam vseh narocil - admin
public function displayNarocilaTableAdmin(){
- global $lang, $global_user_id, $app_settings;
+ global $lang, $global_user_id;
// Admini vidijo vsa narocila
$data = $this->getNarocila();
// Filtri po statusu
echo '<div class="narocila_filters">';
- echo '<label for="filter_narocila_0"><input type="checkbox" id="filter_narocila_0" '.($this->narocila_filter['neplacana'] == 1 ? 'checked="checked"' : '').' onClick="filterNarocila(\'0\', this.checked)">'.$lang['srv_narocilo_filter_status_0'].'</label>';
- echo '<label for="filter_narocila_1"><input type="checkbox" id="filter_narocila_1" '.($this->narocila_filter['placana'] == 1 ? 'checked="checked"' : '').' onClick="filterNarocila(\'1\', this.checked)">'.$lang['srv_narocilo_filter_status_1'].'</label>';
- echo '<label for="filter_narocila_2"><input type="checkbox" id="filter_narocila_2" '.($this->narocila_filter['stornirana'] == 1 ? 'checked="checked"' : '').' onClick="filterNarocila(\'2\', this.checked)">'.$lang['srv_narocilo_filter_status_2'].'</label>';
+ echo ' <input type="checkbox" id="filter_narocila_0" '.($this->narocila_filter['neplacana'] == 1 ? 'checked="checked"' : '').' onClick="filterNarocila(\'0\', this.checked)"><label for="filter_narocila_0">'.$lang['srv_narocilo_filter_status_0'].'</label>';
+ echo ' <input type="checkbox" id="filter_narocila_1" '.($this->narocila_filter['placana'] == 1 ? 'checked="checked"' : '').' onClick="filterNarocila(\'1\', this.checked)"><label for="filter_narocila_1">'.$lang['srv_narocilo_filter_status_1'].'</label>';
+ echo ' <input type="checkbox" id="filter_narocila_2" '.($this->narocila_filter['stornirana'] == 1 ? 'checked="checked"' : '').' onClick="filterNarocila(\'2\', this.checked)"><label for="filter_narocila_2">'.$lang['srv_narocilo_filter_status_2'].'</label>';
echo '</div>';
echo '<table id="user_narocila" class="dataTable user_narocila_admin" style="width:100%">';
@@ -468,7 +599,7 @@ class UserNarocila{ echo $lang['srv_narocilo_status_'.$data_row['status']];
// Na www.1ka.si lahko narocilo placa samo Goran
- if($data_row['status'] != '1' && $data_row['status'] != '2' && ($app_settings['app_name'] != 'www.1ka.si' || $global_user_id == '112696')){
+ if($data_row['status'] != '1' && $data_row['status'] != '2' && (AppSettings::getInstance()->getSetting('app_settings-app_name') != 'www.1ka.si' || $global_user_id == '112696')){
echo '<br />';
echo '<span class="as_link" onClick="urediNarociloPay(\''.$data_row['id'].'\')">'.$lang['srv_narocilo_placaj'].'</span>';
@@ -761,6 +892,10 @@ class UserNarocila{ return $response;
}
+
+ // Ce je slucajno drzava prazna jo nastavimo na slovenijo - zankrat pustimo, da vidimo, ce se se kdaj poslje prazno polje (naceloma se nebi smelo)
+ /*if($podjetje_drzava == '')
+ $podjetje_drzava = 'Slovenija';*/
// Nastavimo ce placa DDV (zavezanci iz EU ga ne placajo)
if(self::checkPayDDV($podjetje_davcna, $podjetje_drzava))
@@ -1112,8 +1247,27 @@ class UserNarocila{ // Ustvarimo racun
- $cebelica = new UserNarocilaCebelica($narocilo_id);
- $response['racun'] = $cebelica->getNarociloRacun();
+ try{
+ $cebelica = new UserNarocilaCebelica($narocilo_id);
+ $response['racun'] = $cebelica->getNarociloRacun();
+ }
+ // Napaka pri komunikaciji s cebelco - posljemo mail Goranu
+ catch (Exception $e){
+
+ // Posljemo mail Goranu, da je prislo do napake pri generiranju racuna
+ $subject = '1ka - napaka pri generiranju računa';
+ $content = 'Prišlo je do napake pri generiranju računa (komunikacija s čebelco) pri naročilu št. '.$rowNarocilo['id'].' (uporabnik '.$rowNarocilo['email'].')!';
+ $content .= '<br /><br />Preveri in samo še enkrat odpri račun za to plačilo preko vmesnika (ga bo zgeneriralo avtomatsko).';
+
+ $MA = new MailAdapter($anketa=null, $type='payments');
+ $MA->addRecipients('goran@go-tel.si');
+ $MA->addRecipients('peter@1ka.si');
+ $resultX = $MA->sendMail($content, $subject);
+
+ $response['false'] = true;
+
+ return $response;
+ }
// Posljemo mail z racunom
@@ -1314,6 +1468,22 @@ class UserNarocila{ // Lastna instalacija - paket
$strinjanje_s_pogoji = isset($narocilo_data['strinjanje_s_pogoji']) ? $narocilo_data['strinjanje_s_pogoji'] : '';
+ // Varnostno preverimo, če robot izpolni polje
+ $varnostno_polje = isset($narocilo_data['varnostno-polje']) ? $narocilo_data['varnostno-polje'] : '';
+ if(!empty($varnostno_polje)){
+ return ['false' => true];
+ }
+
+ // Preverimo ReCaptcha
+ if (in_array($paket, [1,2,3]) && AppSettings::getInstance()->getSetting('google-secret_captcha') !== false) {
+ $recaptchaResponse = isset($narocilo_data['g-recaptcha-response']) ? $narocilo_data['g-recaptcha-response'] : '';
+ $requestReCaptcha = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . AppSettings::getInstance()->getSetting('google-secret_captcha') . '&response=' . $recaptchaResponse);
+
+ if (!strstr($requestReCaptcha, 'true')) {
+ return ['false' => true];
+ }
+ }
+
// Posljemo mail s podatki povprasevanja
$subject = $lang['srv_narocilo_poslovni_email_1ka_subject'];
@@ -1414,6 +1584,7 @@ class UserNarocila{ $countries_eu['Bulgaria'] = 'BG';
$countries_eu['Cyprus'] = 'CY';
$countries_eu['Czech Republic'] = 'CZ';
+ $countries_eu['Czechia'] = 'CZ';
$countries_eu['Germany'] = 'DE';
$countries_eu['Denmark'] = 'DK';
$countries_eu['Estonia'] = 'EE';
diff --git a/frontend/payments/classes/class.UserNarocilaCebelica.php b/frontend/payments/classes/class.UserNarocilaCebelica.php index f7c823b..0cd8e84 100644 --- a/frontend/payments/classes/class.UserNarocilaCebelica.php +++ b/frontend/payments/classes/class.UserNarocilaCebelica.php @@ -29,10 +29,9 @@ class UserNarocilaCebelica{ public function __construct($narocilo_id=0){
- global $cebelica_api;
// Api koda za komunikacijo s cebelico
- define("API_KODA", $cebelica_api);
+ define("API_KODA", AppSettings::getInstance()->getSetting('cebelica_api'));
if($narocilo_id > 0){
@@ -211,6 +210,7 @@ class UserNarocilaCebelica{ return $cebelica_id_new;
}
else{
+ throw new Exception("Napaka pri vnosu dokumenta v cebelca.biz.");
return "Napaka pri vnosu dokumenta v cebelca.biz.";
}
}
diff --git a/frontend/payments/classes/class.UserNarocilaCron.php b/frontend/payments/classes/class.UserNarocilaCron.php index a763dad..92ff8eb 100644 --- a/frontend/payments/classes/class.UserNarocilaCron.php +++ b/frontend/payments/classes/class.UserNarocilaCron.php @@ -16,7 +16,6 @@ class UserNarocilaCron{ public function __construct(){
- global $app_settings;
}
diff --git a/frontend/payments/classes/class.UserNarocilaPaypal.php b/frontend/payments/classes/class.UserNarocilaPaypal.php index de8bb64..d7c0189 100644 --- a/frontend/payments/classes/class.UserNarocilaPaypal.php +++ b/frontend/payments/classes/class.UserNarocilaPaypal.php @@ -21,10 +21,7 @@ class UserNarocilaPaypal{ private $paypal_client;
- public function __construct($narocilo_id){
- global $app_settings;
- global $paypal_client_id;
- global $paypal_secret;
+ public function __construct($narocilo_id){
global $mysql_database_name;
if($narocilo_id > 0){
@@ -43,9 +40,9 @@ class UserNarocilaPaypal{ // Ustvarimo okolje za paypal
if($mysql_database_name == 'real1kasi')
- $environment = new ProductionEnvironment($paypal_client_id, $paypal_secret);
+ $environment = new ProductionEnvironment(AppSettings::getInstance()->getSetting('paypal-client_id'), AppSettings::getInstance()->getSetting('paypal-secret'));
else
- $environment = new SandboxEnvironment($paypal_client_id, $paypal_secret);
+ $environment = new SandboxEnvironment(AppSettings::getInstance()->getSetting('paypal-client_id'), AppSettings::getInstance()->getSetting('paypal-secret'));
$this->paypal_client = new PayPalHttpClient($environment);
}
@@ -135,12 +132,12 @@ class UserNarocilaPaypal{ //$request->headers["prefer"] = "return=representation";
if($lang['id'] == '2'){
- $drupal_url_confirm = $site_url.'/d/en/paypal-purchase/success?narocilo_id='.$orderDetails['narocilo_id'];
- $drupal_url_cancel = $site_url.'/d/en/paypal-purchase/cancel?narocilo_id='.$orderDetails['narocilo_id'];
+ $drupal_url_confirm = $site_url.'/d/en/purchase/paypal?narocilo_id='.$orderDetails['narocilo_id'];
+ $drupal_url_cancel = $site_url.'/d/en/purchase/paypal-cancel?narocilo_id='.$orderDetails['narocilo_id'];
}
else{
- $drupal_url_confirm = $site_url.'/d/narocilo/paypal?narocilo_id='.$orderDetails['narocilo_id'];
- $drupal_url_cancel = $site_url.'/d/narocilo/paypal-cancel?narocilo_id='.$orderDetails['narocilo_id'];
+ $drupal_url_confirm = $site_url.'/d/sl/narocilo/paypal?narocilo_id='.$orderDetails['narocilo_id'];
+ $drupal_url_cancel = $site_url.'/d/sl/narocilo/paypal-cancel?narocilo_id='.$orderDetails['narocilo_id'];
}
$request->body = [
diff --git a/frontend/payments/classes/class.UserNarocilaStripe.php b/frontend/payments/classes/class.UserNarocilaStripe.php index 82efce2..d0b3ef5 100644 --- a/frontend/payments/classes/class.UserNarocilaStripe.php +++ b/frontend/payments/classes/class.UserNarocilaStripe.php @@ -25,11 +25,8 @@ class UserNarocilaStripe{ public function __construct($narocilo_id){
- global $app_settings;
- global $stripe_secret;
- global $stripe_key;
- $this->stripeService = new \Stripe\StripeClient($stripe_secret);
+ $this->stripeService = new \Stripe\StripeClient(AppSettings::getInstance()->getSetting('stripe-secret'));
if($narocilo_id > 0){
@@ -84,12 +81,12 @@ class UserNarocilaStripe{ // URL po potrditvi oz preklicu
if($lang['id'] == '2'){
- $drupal_url_confirm = $site_url.'/d/en/stripe-purchase/success?narocilo_id='.$this->narocilo['id'];
- $drupal_url_cancel = $site_url.'/d/en/stripe-purchase/cancel?narocilo_id='.$this->narocilo['id'];
+ $drupal_url_confirm = $site_url.'/d/en/purchase/stripe?narocilo_id='.$this->narocilo['id'];
+ $drupal_url_cancel = $site_url.'/d/en/purchase/stripe-cancel?narocilo_id='.$this->narocilo['id'];
}
else{
- $drupal_url_confirm = $site_url.'/d/narocilo/stripe?narocilo_id='.$this->narocilo['id'];
- $drupal_url_cancel = $site_url.'/d/narocilo/stripe-cancel?narocilo_id='.$this->narocilo['id'];
+ $drupal_url_confirm = $site_url.'/d/sl/narocilo/stripe?narocilo_id='.$this->narocilo['id'];
+ $drupal_url_cancel = $site_url.'/d/sl/narocilo/stripe-cancel?narocilo_id='.$this->narocilo['id'];
}
// Ustvarimo checkout session
diff --git a/frontend/payments/classes/class.UserPlacila.php b/frontend/payments/classes/class.UserPlacila.php index a21d6fb..53305fa 100644 --- a/frontend/payments/classes/class.UserPlacila.php +++ b/frontend/payments/classes/class.UserPlacila.php @@ -105,7 +105,7 @@ class UserPlacila{ // Izpisemo podatke o placilih
public function displayPlacila(){
- global $lang, $global_user_id, $app_settings;
+ global $lang, $global_user_id;
// Tabela vseh placil
$this->displayPlacilaTable();
@@ -116,13 +116,13 @@ class UserPlacila{ echo '</div>';*/
// Izracun zasluzka in provizij po mesecih - samo Goran
- if($app_settings['app_name'] == 'www.1ka.si' && $global_user_id == '112696')
+ if(AppSettings::getInstance()->getSetting('app_settings-app_name') == 'www.1ka.si' && $global_user_id == '112696')
$this->displayPlacilaPovzetek();
}
// Izpisemo seznam vseh placil
public function displayPlacilaTable(){
- global $lang, $global_user_id, $app_settings;
+ global $lang, $global_user_id;
// Admini vidijo vsa placila
$data = $this->getPlacila();
@@ -194,7 +194,7 @@ class UserPlacila{ // Edit / delete
echo '<td>';
// Na www.1ka.si lahko placilo ureja samo Goran
- if($app_settings['app_name'] != 'www.1ka.si' || $global_user_id == '112696'){
+ if(AppSettings::getInstance()->getSetting('app_settings-app_name') != 'www.1ka.si' || $global_user_id == '112696'){
// Uredi
echo '<a href="#" onClick="displayPlaciloPopup(\''.$data_row['id'].'\')" title="'.$lang['srv_placila_edit'].'"><i class="fa fa-pencil-alt link-sv-moder"></i></a> <span class="no-print"> | </span>';
|