static function getTrainingData($instructor_email = false, $trainingType = false, $instructors = false, $departmentID = false) { //echo "Get Training Data ".$trainingType ." ".$instructor_email; //echo date("m-d-Y H:i:s.u"); $posts_array; if ($instructors) { $posts_array = $instructors; } else { $posts_array = get_posts(array('post_type' => 'instructor', 'posts_per_page' => -1, 'cache_results' => false)); } $result = array(); foreach ($posts_array as $instructor) { //print_r($instructor); $courses = get_instructor_courses($instructor->ID); if ($instructor_email != false) { $email = get_field('email', $instructor->ID); if (strcmp($email, $instructor_email) != 0) { continue; } } foreach ($courses as $course) { $date = ""; if (isset($course["completion_date"])) { $date = $course["completion_date"]; } $type = "QM"; if ($course["course_type"] == 'atccourses') { $type = "ATC"; } $training = new TrainingCourse($instructor, get_the_title($course['qm_courses_select']), $type, $date); //Selected type but the type is not what we expect if ($trainingType != false && $trainingType != $training->courseType) { continue; } $result[] = $training; } } return $result; }
function qm_training_courses_html() { global $post; //$qm_training_courses = query_posts('post_type=qmtrainingcourse'); $postId = $post->ID; ?> <h1>Training Courses</h1> <h3>ATC Courses Taken</h3> <!-- TOTAL HACK only one form works--> <form action="http://www.example.com/wp-admin/admin-post.php" method="post"> <?php $instructor_courses = get_instructor_courses($postId, 'atccourses'); // echo "Courses"; //print_r($instructor_courses); renderAddNewCourseHTML('atccourses'); renderInstructorCoursesList($instructor_courses, 'atccourses'); echo $postId; ?> <hr /> <h3>QM Courses Taken</h3> <?php wp_reset_postdata(); $instructor_courses = get_instructor_courses($postId, 'qmtrainingcourse'); renderAddNewCourseHTML('qmtrainingcourse'); renderInstructorCoursesList($instructor_courses, 'qmtrainingcourse'); wp_reset_postdata(); echo $postId; ?> </form> <script> /* jQuery('.metabox_submit').click(function(e) { e.preventDefault(); jQuery('#publish').click(); }); */ </script> <?php }