public function merit_update($checklist_id_old, $pidm) { $checklist_id_current = TrainingTracker::get_checklist_id($pidm); $sql = "UPDATE person_checklist_items SET checklist_id = ? WHERE (checklist_id = ? AND response = ?) OR (checklist_id = ? AND response = ?)"; $updated = PSU::db('hr')->Execute($sql, array($checklist_id_current, $checklist_id_old, 'merit', $checklist_id_old, 'demerit')); }
}); respond('POST', '/merit', function ($request, $responce, $app) { $type = $request->data['type']; $comments = $request->data['comments']; $wpid = $request->data['wpid']; if (TrainingTracker::valid_wpid($wpid)) { $comments = htmlentities($comments); $comments = stripslashes($comments); $comments = trim($comments); if ($type == 'star' || $type == 'dog-house') { $checklist_id = TrainingTracker::get_checklist_id($wpid); // If they don't have a checklist, most likely a mentor if (!$checklist_id) { $user_type = TrainingTracker::level_translation(TrainingTracker::get_user_level($wpid)); TrainingTracker::checklist_insert($wpid, $user_type); $checklist_id = TrainingTracker::get_checklist_id($wpid); } if ($type == 'star') { $type = 'merit'; } else { $type = 'demerit'; } $updated_by = $app->user->pidm; $item_id = 42; TrainingTracker::merit_insert($item_id, $checklist_id, $type, $comments, $updated_by); $last_insert_id = TrainingTracker::last_insert_id(); $data = array('id' => $last_insert_id); // echoed for ajax to pickup and use. echo json_encode($data); } }