Skip to content
Snippets Groups Projects
Verified Commit d4af88cf authored by Manuel Herrmann's avatar Manuel Herrmann
Browse files

transferring to/from waitlists works

parent c7d62b44
No related branches found
No related tags found
1 merge request!20refactor warteliste: allows modification of list items like on meldeliste
......@@ -7,6 +7,27 @@ class AdminListPage extends AdminPage {
$this->isWaitlist = isset($_GET['waitlist']) && $_GET['waitlist'] == 'true';
$this->isAlumniPage = isset($_GET['alumni']) && $_GET['alumni'] == 'true';
// moves entry to final list
if(isset($_REQUEST['move'])){
try {
$bachelor = Bachelor::makeFromDB($this->fahrt, $_REQUEST['move']);
if (empty($bachelor))
throw new Exception('Person nicht vorhanden.');
if ($this->isWaitlist) {
$transferResult = $bachelor->waitlistToRegistration();
} else {
$transferResult = $bachelor->registrationToWaitlist();
}
if ($transferResult == Bachelor::SAVE_SUCCESS) {
$this->message_succ = 'Person erfolgreich von '.($this->isWaitlist?"Warteliste":"Anmeldeliste").' auf '.($this->isWaitlist?"Anmeldeliste":"Warteliste").' übertragen.';
} else {
throw new Exception('Hat nicht geklappt. Fehlercode '.$transferResult);
}
} catch (Exception $e) {
$this->message_err = $e->getMessage();
}
}
if (isset($_REQUEST['change'])) {
try {
$bNew = Bachelor::makeFromForm(false, $this->fahrt, true, true);
......@@ -138,7 +159,7 @@ class AdminListPage extends AdminPage {
$thead .= '<th>toWaitlist</th>';
$toggle .= '<a class="toggle-vis" data-column=\'15\'>toWaitlist</a> - ';
}
print_r($extra_filters);
$tbody = '';
$people = $this->environment->database->select('bachelor', Bachelor::$ALLOWED_FIELDS,
['AND' => $extra_filters], ['anm_time' => 'ASC']);
......@@ -153,6 +174,8 @@ print_r($extra_filters);
$bezahltJaNein = $b['paid'] ? 1 : 0;
$zurueckgezahltJaNein = $b['repaid'] ? 1 : 0;
$kommentar = htmlspecialchars($b['comment'], ENT_QUOTES);
$waitlist_tf = $this->isWaitlist ? "true" : "false";
$alumni_tf = $this->isAlumniPage ? "true" : "false";
$tbody .= <<<EOF
<tr>
<td><a href="#" class="edit_bachelor">${b['bachelor_id']}</a></td>
......@@ -172,7 +195,7 @@ print_r($extra_filters);
<td>$bezahltJaNein,$zurueckgezahltJaNein,$zurueckgetreten</td>
EOF.($this->isWaitlist
? <<<EOF
<td><a href="?page=wl&move=${b['bachelor_id']}">&#8614; übertragen</a></td>
<td><a href="?page=list&waitlist=${waitlist_tf}&alumni=${alumni_tf}&move=${b['bachelor_id']}">&#8614; übertragen</a></td>
EOF
: <<< EOF
<td><a href="#" class="moveToWaitlist">&#8614; Warteliste</a></td>
......
......@@ -161,9 +161,8 @@ class Bachelor {
* @return int see SAVE_* constants
*/
public function waitlistToRegistration() {
if ($this->data['on_waitlist'] == 1 and
(!isset($this->data['transferred']) or is_null($this->data['transferred']))
) {
if ($this->data['on_waitlist'] == 1) {
$this->data['on_waitlist'] = 0;
$this->data['transferred'] = time();
$code = $this->save();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment