Fibinger Ádám
2019-11-27 c5946f44341c29594803c5b2ca64dcaf335fbca3
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
b40e93 25 } else {
a4186a 26     if (file_exists(STRIPE_JSON)) {
27         $raw_json = file_get_contents(STRIPE_JSON);
b40e93 28         $stateArray = json_decode($raw_json, true);
29         if (is_array($stateArray)) {
30             $s->loadFromArray($stateArray);
31         }
32     }
1867e1 33 }
b40e93 34
35 $teams = new \EOG\Models\TeamList();
36
a4186a 37 if (file_exists(TEAMS_JSON)) {
38     $teams->fromJson(file_get_contents(TEAMS_JSON));
1867e1 39 }
268b32 40
cc3ac8 41 $var = [
b40e93 42     'stripe' => $s,
43     'teamNames' => $teams->getTeamNames(),
44     'operators' => $s->getOperators(),
45     'post' => !empty($_POST['stripe'])
cc3ac8 46 ];
b40e93 47
3305a7 48 echo $twig->render('admin/stripe-form.twig', $var);
812087 49