summaryrefslogtreecommitdiffstats
path: root/frontend/payments/classes/class.ApiNarocilaController.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--frontend/payments/classes/class.ApiNarocilaController.php46
1 files changed, 40 insertions, 6 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;
}