From a17da821a9c684903b45cda07677dd2658dce70b Mon Sep 17 00:00:00 2001 From: Tim Repke <repketim@informatik.hu-berlin.de> Date: Wed, 3 Sep 2014 19:38:37 +0200 Subject: [PATCH] =?UTF-8?q?list=20page=20ausgegliedert,=20datumstyp=C3=A4n?= =?UTF-8?q?derung=20im=20code=20angepasst?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- registration-system/admin/pages.php | 79 +----------------- registration-system/admin/pages_list.php | 93 ++++++++++++++++++++++ registration-system/frameworks/commons.php | 2 +- registration-system/index.php | 11 ++- registration-system/status.php | 5 +- 5 files changed, 106 insertions(+), 84 deletions(-) create mode 100644 registration-system/admin/pages_list.php diff --git a/registration-system/admin/pages.php b/registration-system/admin/pages.php index 6aaf132..0be9cda 100644 --- a/registration-system/admin/pages.php +++ b/registration-system/admin/pages.php @@ -9,83 +9,8 @@ function page_stuff() $text .= "Übersichtsseite"; } -function page_list() -{ - global $text, $headers, $admin_db; - $headers =<<<END - <link rel="stylesheet" type="text/css" href="../view/css/DataTables/css/jquery.dataTables.min.css" /> - <script type="text/javascript" src="../view/js/jquery-1.11.1.min.js"></script> - <script type="text/javascript" src="../view/js/jquery.dataTables.min.js"></script> -END; - $text .= "Meldeliste"; - - $columns = array( - "bachelor_id", - "fahrt_id", - "forname", - "sirname", - "mehl", - "pseudo", - "antyp", - "abtyp", - "anday", - "abday", - "comment", - "studityp", - "paid", - "repaid", - "backstepped" - ); - - $columnFunctions = array( - "Anmelde-ID" => function($person) { return $person["bachelor_id"]; }, - "FahrtID" => function($person) { return $person["fahrt_id"]; }, - "Name" => function($person) { return "<a href='mailto:".$person["mehl"]."?subject=FS-Fahrt'>".$person["forname"]." ".$person["sirname"]." (".$person["pseudo"].")</a>"; }, - "Anreisetyp" => function($person) { return $person["antyp"]; }, - "Abreisetyp" => function($person) { return $person["abtyp"]; }, - "Anreisetag" => function($person) { return $person["anday"]; }, - "Abreisetag" => function($person) { return $person["abday"]; }, - "Kommentar" => function($person) { return $person["comment"]; }, - "StudiTyp" => function($person) { return $person["studityp"]; }, - "PaidReBack" => function($person) { return ($person["paid"] ? "1" : "0") . ($person["repaid"] ? "1" : "0") . ($person["backstepped"] ? "1" : "0"); } - ); - - $text .=<<<END - <table id="mlist"> - <thead> - <tr> -END; - foreach($columnFunctions as $key => $value) - { - $text .= "<th>".$key."</th>"; - } - $text .=<<<END - </tr> - </thead> - <tbody> -END; - // TODO: generate table content - - $people = $admin_db->select('bachelor',$columns); - foreach($people as $person) { - $text .= "<tr>"; - foreach($columnFunctions as $key => $value) - { - $text .= "<td>".$value($person)."</td>"; - } - $text .= "</tr>"; - } - - $text .=<<<END - </tbody> - </table> - <script type='text/javascript'> - $(document).ready(function(){ - $('#mlist').dataTable({}); - }); - </script> -END; - +function page_list(){ + require_page("pages_list.php"); } function page_404($pag) diff --git a/registration-system/admin/pages_list.php b/registration-system/admin/pages_list.php new file mode 100644 index 0000000..5d657b5 --- /dev/null +++ b/registration-system/admin/pages_list.php @@ -0,0 +1,93 @@ +<?php +/** + * Created by PhpStorm. + * User: tim + * Date: 9/3/14 + * Time: 7:09 PM + */ + +global $text, $headers, $admin_db, $config_current_fahrt_id; +$headers =<<<END + <link rel="stylesheet" type="text/css" href="../view/css/DataTables/css/jquery.dataTables.min.css" /> + <script type="text/javascript" src="../view/js/jquery-1.11.1.min.js"></script> + <script type="text/javascript" src="../view/js/jquery.dataTables.min.js"></script> +END; +$text .= "Meldeliste"; + +$columns = array( + "bachelor_id", + "fahrt_id", + "anm_time", + "forname", + "sirname", + "mehl", + "pseudo", + "antyp", + "abtyp", + "anday", + "abday", + "comment", + "studityp", + "paid", + "repaid", + "backstepped" +); + +$columnFunctions = array( + "Anmelde-ID" => function($person) { return $person["bachelor_id"]; } + //,"FahrtID" => function($person) { return $person["fahrt_id"]; } +,"Anmeldung" => function($person) { return date("m.d.Y", $person['anm_time']); }, + "Name" => function($person) { return "<a href='mailto:".$person["mehl"]."?subject=FS-Fahrt'>".$person["forname"]." ".$person["sirname"]." (".$person["pseudo"].")</a>"; }, + "Anreisetyp" => function($person) { return $person["antyp"]; }, + "Abreisetyp" => function($person) { return $person["abtyp"]; }, + "Anreisetag" => function($person) { return date("m.d.Y", $person["anday"]); }, + "Abreisetag" => function($person) { return date("m.d.Y", $person["abday"]); }, + "Kommentar" => function($person) { return $person["comment"]; }, + "StudiTyp" => function($person) { return $person["studityp"]; }, + "PaidReBack" => function($person) { return ($person["paid"] ? "1" : "0") . ($person["repaid"] ? "1" : "0") . ($person["backstepped"] ? "1" : "0"); } +); + +$text .=<<<END + <table id="mlist"> + <thead> + <tr> +END; +foreach($columnFunctions as $key => $value) +{ + $text .= "<th>".$key."</th>"; +} +$text .=<<<END + </tr> + </thead> + <tbody> +END; + +$people = $admin_db->select('bachelor',$columns, array("fahrt_id"=>$config_current_fahrt_id)); +foreach($people as $person) { + $text .= "<tr>"; + foreach($columnFunctions as $key => $value) + { + $text .= "<td class='".$key."'>".$value($person)."</td>"; + } + $text .= "</tr>"; +} + +$text .=<<<END + </tbody> + </table> + <script type='text/javascript'> + $(document).ready(function(){ + $('#mlist').dataTable({}); + + $('.PaidReBack').each(function(){ + $(this).text(function(){ + var btns = ""; + for(var i = 0, txt = $(this).text(); i < txt.length; i++){ + btns += txt[i]+","; + } + return btns; + }); + }); + }); + </script> +END; diff --git a/registration-system/frameworks/commons.php b/registration-system/frameworks/commons.php index bc64b2f..535a9dc 100644 --- a/registration-system/frameworks/commons.php +++ b/registration-system/frameworks/commons.php @@ -26,7 +26,7 @@ function comm_format_date($date){ } function comm_get_possible_dates($fid){ - return array("12.03.2014","13.03.2014","14.03.2014"); + return array("12.03.2014","13.03.2014","14.03.2014"); // FIXME dynamisch machen! } function comm_isopen_fid($db_handle, $fid){ diff --git a/registration-system/index.php b/registration-system/index.php index 0e6debc..9d71858 100644 --- a/registration-system/index.php +++ b/registration-system/index.php @@ -77,6 +77,9 @@ function index_form_to_db($data){ global $index_db, $config_baseurl, $lang_regmail, $config_current_fahrt_id; $data['version'] = 1; $data['bachelor_id'] = comm_generate_key($index_db, "bachelor", "bachelor_id", array('fahrt_id'=>$data['fahrt_id'])); + $data['anm_time'] = time(); + $data['anday'] = DateTime::createFromFormat('d.m.Y',$data['anday'])->getTimestamp(); + $data['abday'] = DateTime::createFromFormat('d.m.Y',$data['abday'])->getTimestamp(); $index_db->insert("bachelor", $data); $from = $index_db->get("fahrten", array("kontakt","leiter"), array("fahrt_id"=>$config_current_fahrt_id)); $mail = comm_get_lang("lang_regmail", array( "{{url}}" => $config_baseurl."status.php?hash=".$data['bachelor_id'], @@ -351,7 +354,7 @@ function index_show_signupTable($fid){ <table class="signups"> <thead> <tr> - <th></th> + <!--th></th--> <th>Anzeigename</th> <th>Anreisetag</th> <th>Anreiseart</th> @@ -362,11 +365,11 @@ function index_show_signupTable($fid){ </thead>'; foreach($data as $d){ echo '<tr> - <td>'.$d["studityp"].'</td> + <!--td>'.$d["studityp"].'</td--> <td>'.$d["pseudo"].'</td> - <td>'.$d["anday"].'</td> + <td>'.date('d.m.Y', $d["anday"]).'</td> <td>'.$d["antyp"].'</td> - <td>'.$d["abday"].'</td> + <td>'.date('d.m.Y', $d["abday"]).'</td> <td>'.$d["abtyp"].'</td> <td>'.$d["comment"].'</td> </tr>'; diff --git a/registration-system/status.php b/registration-system/status.php index c631be7..35425ff 100644 --- a/registration-system/status.php +++ b/registration-system/status.php @@ -36,10 +36,11 @@ function show_content(){ $infolist = Array( 'Anmelde ID' => $data['bachelor_id'], + 'Anmeldetag' => date('d.m.Y', $data['anm_time']), 'Vor-/Nachname' => $data['forname'].' '.$data['sirname'].(strlen($data['pseudo']) > 0 ? ' ('.$data['pseudo'].')' : ""), 'eMail-Adresse' => $data['mehl'], - 'Anreisetag & Art' => $data["anday"].' ('.$data["antyp"].')', - 'Abreisetag & Art' => $data["abday"].' ('.$data["abtyp"].')', + 'Anreisetag & Art' => date('d.m.Y', $data["anday"]).' ('.$data["antyp"].')', + 'Abreisetag & Art' => date('d.m.Y', $data["abday"]).' ('.$data["abtyp"].')', 'Essenswunsch' => $data["essen"], 'Zahlung erhalten' => ((is_null($data["paid"])) ? "nein" : date('d.m.Y',$data["paid"])), 'Rückzahlung gesendet' => ((is_null($data["repaid"])) ? "nein" : date('d.m.Y',$data["repaid"])), -- GitLab