?> "></i><?php echo $age; ?> years old</p> <p class="small mb-10 text-muted"><i class="pl-5 pr-5 fa fa-map-marker"></i><?php echo $address->primary_city . '/' . $address->state; ?> </p> <a class="btn btn-gray collapsed map-show btn-animated" data-toggle="collapse" href="#collapseMap" aria-expanded="false" aria-controls="collapseMap">Show Map <i class="fa fa-plus"></i></a> <!--<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam atque ipsam nihil, adipisci rem minus? Voluptatem distinctio laborum porro aspernatur.</p> --> </div> <div class="body"> <?php if (dietStatus()) { ?> <h4>Diet Status</h4> <div class="separator-2"></div> <div class="knob-container"> <input class="knob" data-fgcolor="#f0ad4e" data-thickness=".10" data-animate-value="<?php echo $progress_status . $dietStats->ds_percent; ?> " value="0" data-displayInput="false" data-readOnly="true"> <div class="knob-text"> <i id="diet-progress" class="<?php echo $icon_diet_progres_class; ?> " style="margin-bottom:10px;"></i><br/> <label>Goal</label>
function startDiet($currentWeight, $targetWeight, $targetDate) { global $db; $errorList = ''; $firstError = true; session_start(); if (dietStatus()) { if ($firstError) { $errorList .= 'You already have an active diet!'; $firstError = false; } else { $errorList .= '<br />You already have an active diet!'; } } if ($firstError == false) { returnError($errorList); } if (strlen($currentWeight) == 0 || strlen($targetWeight) == 0 || strlen($targetDate) == 0) { if ($firstError) { $errorList .= 'Please fill all the required fields!'; $firstError = false; } else { $errorList .= '<br />Please fill all the required fields!'; } } if (!is_numeric($currentWeight) || !is_numeric($targetWeight)) { if ($firstError) { $errorList .= 'Format error!'; $firstError = false; } else { $errorList .= '<br />Format error!'; } } if ($currentWeight == $targetWeight) { if ($firstError) { $errorList .= 'Your current weight end target weight can not be some!'; $firstError = false; } else { $errorList .= '<br />Your current weight end target weight can not be some!'; } } if ($firstError == false) { returnError($errorList); } date_default_timezone_set("America/New_York"); $date = date("Y-m-d H:i:s"); $sql = "INSERT INTO user_goal (u_id, ug_weight, ug_first_weight, ug_date, ug_create_date) VALUES(:u_id, :ug_weight, :ug_first_weight, :ug_date, :ug_create_date)"; $stmt = $db->prepare($sql); $stmt->bindParam(':u_id', $_SESSION['user']->u_id, PDO::PARAM_INT); $stmt->bindParam(':ug_weight', $targetWeight, PDO::PARAM_STR); $stmt->bindParam(':ug_first_weight', $currentWeight, PDO::PARAM_STR); $stmt->bindParam(':ug_date', $targetDate, PDO::PARAM_STR); $stmt->bindParam(':ug_create_date', $date, PDO::PARAM_STR); $stmt->execute(); $lastId = $db->lastInsertId(); $total_goal = $stmt->rowCount(); $sql = "INSERT INTO user_physical (u_id, up_weight, up_date) VALUES(:u_id, :up_weight, :up_date)"; $stmt = $db->prepare($sql); $stmt->bindParam(':u_id', $_SESSION['user']->u_id, PDO::PARAM_INT); $stmt->bindParam(':up_weight', $currentWeight, PDO::PARAM_STR); $stmt->bindParam(':up_date', $date, PDO::PARAM_STR); $stmt->execute(); $total_physical = $stmt->rowCount(); $sql = "INSERT INTO diet_stats (u_id, ds_weight, ds_date) VALUES(:u_id, :ds_weight, :ds_date)"; $stmt = $db->prepare($sql); $stmt->bindParam(':u_id', $_SESSION['user']->u_id, PDO::PARAM_INT); $stmt->bindParam(':ds_weight', $currentWeight, PDO::PARAM_INT); $stmt->bindParam(':ds_date', $date, PDO::PARAM_STR); $stmt->execute(); if ($total_goal && $total_physical) { $type = 'u_started_diet'; $action = addUserAction($_SESSION['user']->u_id, $lastId, $type); $result['status'] = 'success'; $result['msg'] = 'Your diet created'; echo json_encode($result); exit; } else { $result['status'] = 'error'; $result['msg'] = 'Your diet could not create'; echo json_encode($result); exit; } }