Fibinger Ádám
2020-01-09 cffd2c46efe5875ad1eb86a566a9b41bdb461861
commit | author | age
812087 1 <?php
b40e93 2 include_once "common/base.php";
812087 3
cc3ac8 4 $s = new \EOG\Models\Stripe();
5
b40e93 6 if (!empty($_POST['stripe'])) {
7     $s->loadFromArray($_POST['stripe']);
812087 8
b40e93 9     if (!empty($s->getState())) {
a4186a 10         file_put_contents(STRIPE_JSON, $s->getJson());
b40e93 11     }
cc3ac8 12
b40e93 13     $s->setClass('simple');
c5946f 14     $html_content = $twig->render('overlays/stripe.twig', ['stripe' => $s]);
b40e93 15     file_put_contents(OVERLAY_DIR . 'simple.html', $html_content);
1867e1 16
b40e93 17     $s->setClass('team');
c5946f 18     $html_content = $twig->render('overlays/stripe.twig', ['stripe' => $s]);
b40e93 19     file_put_contents(OVERLAY_DIR . 'team.html', $html_content);
1867e1 20
b40e93 21     $s->setClass('team-ban');
c5946f 22     $html_content = $twig->render('overlays/stripe.twig', ['stripe' => $s]);
b40e93 23     file_put_contents(OVERLAY_DIR . 'team-ban.html', $html_content);
1867e1 24
cffd2c 25     $s->setClass('team-ban');
26     $html_content = $twig->render('overlays/stripe.twig', ['stripe' => $s, 'autorefresh' => 30]);
27     file_put_contents(OVERLAY_DIR . 'team-ban-refresh.html', $html_content);
28
b40e93 29 } else {
a4186a 30     if (file_exists(STRIPE_JSON)) {
31         $raw_json = file_get_contents(STRIPE_JSON);
b40e93 32         $stateArray = json_decode($raw_json, true);
33         if (is_array($stateArray)) {
34             $s->loadFromArray($stateArray);
35         }
36     }
1867e1 37 }
b40e93 38
39 $teams = new \EOG\Models\TeamList();
40
a4186a 41 if (file_exists(TEAMS_JSON)) {
42     $teams->fromJson(file_get_contents(TEAMS_JSON));
1867e1 43 }
268b32 44
cc3ac8 45 $var = [
b40e93 46     'stripe' => $s,
47     'teamNames' => $teams->getTeamNames(),
48     'operators' => $s->getOperators(),
49     'post' => !empty($_POST['stripe'])
cc3ac8 50 ];
b40e93 51
3305a7 52 echo $twig->render('admin/stripe-form.twig', $var);
812087 53