public function index() { $this->load->library('session'); /* *make sure session is valid and check session user agent to help prevent session hijacking. */ $redirect_path = base_url() . "login"; //check that user is logged in if (!isset($_SESSION['loggedIn'])) { redirect($redirect_path); } //get user id from the session $userID = $_SESSION['userID']; //check session user agent $session_name = "userAgent"; check_session_user_agent_h($redirect_path, $session_name); //get the current workoutlogID $global_workout_log_id = $_SESSION['workout_log_id']; /* * Handle delete set functionality */ //if the delete set form has been submitted if (isset($_POST['delete_exercise_submit'])) { //get posted variables $exerciseID = $_POST['exerciseID']; $setID = $_POST['setID']; //delete the set from the database. $this->Database_model->delete_set($userID, $setID); //return the sets to the javascript file $sets = previous_exercise_sets_h($userID, $exerciseID, $global_workout_log_id); $sanitized_html = sanitize_object_h($sets); //send the sanitized data. echo json_encode($sanitized_html); } //end if /* * Take care of ajax post from javascript */ //if the submit-set-btn was clicked and the form was submitted if (isset($_POST['weight']) && isset($_POST['reps'])) { //get all post data $weight = $_POST['weight']; $reps = $_POST['reps']; $rest = $_POST['rest']; $exerciseID = $_POST['exerciseID']; $workoutID = $_POST['workoutsID']; $difficulty = $_POST['difficulty']; $workout_log_id = $_POST['workout-log-id']; $this->Database_model->enter_set($userID, $workoutID, $workout_log_id, $exerciseID, $weight, $reps, $rest, $difficulty); //get the sets to return to the javascript file to be posted in the view $sets = previous_exercise_sets_h($userID, $exerciseID, $global_workout_log_id); $sanitized_html = sanitize_object_h($sets); //send the sanitized data. echo json_encode($sanitized_html); } //end if }
<!-- end previous exercise sets --> <!-- <li class="centered medium">45lbs x 10 - 45secs</li> <li class="centered hard">45lbs x 10 - 45secs</li> <li class="centered very-hard">45lbs x 10 - 45secs</li> --> </ul> </div> <div class="columns small-6 stats-log"> <h5 class="white centered">Current</h5> <!-- data attribute helps determine if a current workout has been initiated - if it has we need to load any exercises that have been done for today in this workout --> <ul class="todays-sets"> <!-- if sets have already been entered for this workout - load them --> <?php if (previous_exercise_sets_h($userID, $exercise->id, $workout_log_id)) { ?> <?php foreach (previous_exercise_sets_h($userID, $exercise->id, $workout_log_id) as $set) { ?> <li class="centered <?php exercise_difficulty_h($set->difficulty); ?> " data-set-id="<?php echo $set->id; ?> " data-exercise-id="<?php echo $exercise->id; ?> " > <?php format_weight_reps_rest_h($set->weight, $set->reps, $set->rest); ?> <a class="delete-set-btn" href="#" data-reveal-id="delete-set-modal">