Example #1
0
 public function get_observe()
 {
     $this->requiresLogin(true);
     $obs = [];
     foreach (scandir(__DIR__ . '/../observer/en') as $dir) {
         if ($dir[0] == '.') {
             continue;
         }
         $obs[] = $dir;
     }
     if (!$this->id) {
         return $this->status($obs, false, 'observers');
     }
     Bootstrap::$main->session('time_delta', Bootstrap::$main->user['delta']);
     Bootstrap::$main->human_datetime_format();
     $data = [];
     $data['cancel_reason'] = 'Bo tak';
     $data['host'] = Bootstrap::$main->user;
     $data['guest'] = Bootstrap::$main->user;
     $guest = new guestModel();
     $guests = $guest->getForUser($data['guest']['id']);
     $data['data'] = $guests[0];
     $event = new eventModel();
     $events = $event->get_for_user($data['guest']['id']);
     $data['event'] = $events[0];
     $image = new imageModel($data['event']['img']);
     $data['event']['img'] = $image->data();
     require_once __DIR__ . '/../models/paymentModel.php';
     $payment = new paymentModel();
     $payments = $payment->getAllForChannel('payu', Bootstrap::$main->now - 7 * 24 * 3600, 99);
     $data['payment'] = $payments[0];
     if (isset($data['payment']['notify'])) {
         $data['notify'] = json_decode($data['payment']['notify'], true);
     }
     return $this->status($obs, Tools::observe($this->id, $data), $this->id);
 }
Example #2
0
<?php

require_once __DIR__ . '/../base.php';
require_once __DIR__ . '/../../rest/models/guestModel.php';
require_once __DIR__ . '/../../rest/models/paymentModel.php';
require_once __DIR__ . '/../lib/class/payu.php';
$guest = new guestModel();
$payment = new paymentModel();
$timetoapprove = 10 * 24 * 3600;
$from = Bootstrap::$main->now - $timetoapprove;
$payu = new payu();
$payus = $payment->getAllForChannel('payu', $from, 5);
if (is_array($payus)) {
    foreach ($payus as $p) {
        $prc = 100 * (Bootstrap::$main->now - $p['d_payment_create']) / $timetoapprove;
        if ($p['d_cancel']) {
            $r = $payu->cancel_payment($p);
            Tools::log('payu', ['cancel', $r, $p]);
        } elseif ($p['d_deadline'] + 3600 < Bootstrap::$main->now || $prc > 90) {
            $r = $payu->confirm_payment($p);
            Tools::log('payu', ['confirm', $r, $p]);
        }
    }
}
foreach ($guest->getCanceledGuests() ?: [] as $g) {
    $payments = $payment->getForGuest($g['id']);
    if (is_array($payments)) {
        foreach ($payments as $p) {
            $classname = $p['channel'];
            $classfile = __DIR__ . '/../lib/class/' . $classname . '.php';
            if (!file_exists($classfile)) {