コード例 #1
0
ファイル: mealPlans.php プロジェクト: ncowan15/FoodApp3
 public function copy()
 {
     return MealPlan::copy($this->params);
 }
コード例 #2
0
 public static function calculateMeal($id)
 {
     // Prepare needed data
     $mealPlan = MealPlan::getMealPlan($id);
     $returnNutrition = self::createNutrition($id, $mealPlan["name"]);
     // Calculate each meal plan component
     $mealPlanComponents = MealPlanComponent::getComponents($id);
     foreach ($mealPlanComponents as $mealPlanComponent) {
         $componentNutrition = self::calculate($mealPlanComponent["foodId"], $mealPlanComponent["quantity"]);
         self::add($returnNutrition, $componentNutrition);
     }
     // Divide by number of days in meal plan
     self::divide($returnNutrition, MealPlan::getDays($mealPlanComponents));
     return $returnNutrition;
 }
コード例 #3
0
ファイル: edit.php プロジェクト: pjflameboy/phprecipebook
<?php

require_once "classes/MealPlan.class.php";
require_once "classes/DBUtils.class.php";
// Initalize the Vars
$date = isset($_GET['date']) ? $_GET['date'] : date('m-d-Y');
$view = isset($_GET['view']) ? $_GET['view'] : "daily";
$dbDate = DBUtils::dbDate($date);
// get the date in ISO format so that we have the key
if ($SMObj->getUserLoginID() == NULL) {
    die($LangUI->_('You must be logged in to use the Meal Planner!'));
}
// Create a new meal plan object
$MPObj = new MealPlan($date);
$MPObj->load($dbDate, $dbDate);
//just want this one day
$minshow = 4;
// Min number of empty fields to show
$defaultServings = 2;
// The default number of servings
// Read in a list of Meals and recipes
$rc = DBUtils::fetchColumn($db_table_meals, 'meal_name', 'meal_id', 'meal_id');
$mealList = DBUtils::createList($rc, 'meal_id', 'meal_name');
?>
<script type="text/javascript">
	$(document).ready(function() {
			$(".ui-widget").find("input[id^='recipeAuto_']").each(function()
			{
					$(this).autocomplete({
						source: "index.php?m=recipes&a=get&format=no",
						minLength: 1,
コード例 #4
0
<?php

require_once "classes/MealPlan.class.php";
// Initalize the POST/GET Vars
$view = isset($_GET['view']) ? $_GET['view'] : 'weekly';
$date = isset($_GET['date']) ? $_GET['date'] : date('m-d-Y');
if ($SMObj->getUserLoginID() == NULL) {
    die($LangUI->_('You must be logged in to use the Meal Planner!'));
}
// Create a new meal plan object
global $MPObj;
$MPObj = new MealPlan($date);
// Setup the forward and backward links and the title
$forwardLink = NULL;
$backwardLink = NULL;
$title = NULL;
$subtitle = NULL;
// title of what day/week/month we are in
if ($view == "daily") {
    //-------------------------------------------------------------------------------
    // Daily View
    //-------------------------------------------------------------------------------
    $weekDay = date('w', mktime(0, 0, 0, $MPObj->currentMonth, $MPObj->currentDay, $MPObj->currentYear));
    $dbDate = DBUtils::dbDate($date);
    // get the date in ISO format so that we have the key
    $MPObj->load($dbDate, $dbDate);
    //just want this one day
    echo '<b>' . $MPObj->daysFull[$weekDay] . '</b>';
    echo '<ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="b">';
    echo $MPObj->getMeals($dbDate, 3);
    echo '</ul>';
コード例 #5
0
ファイル: update.php プロジェクト: pjflameboy/phprecipebook
<?php

require_once "classes/MealPlan.class.php";
require_once "classes/DBUtils.class.php";
// Initalize the Vars
$date = isset($_GET['date']) ? $_GET['date'] : date('m-d-Y');
$dbDate = DBUtils::dbDate($date);
if ($SMObj->getUserLoginID() == NULL) {
    die($LangUI->_('You must be logged in to use the Meal Planner!'));
}
// Create a new meal plan object
$MPObj = new MealPlan($date);
// Delete all of the existing items for this day if they exist
$MPObj->delete($dbDate);
$meal = "meal_id_";
$servings = "servings_";
$recipe = "recipeId_";
$repeat = "repeat_";
$delete = "delete_";
$iterator = 0;
// Remove all of the meals currently set for this day
$MPObj->clearDay($dbDate);
// Set the first value
$currentMeal = $meal . $iterator;
while (isset($_REQUEST[$currentMeal]) && $_REQUEST[$currentMeal] != 0) {
    $currentServ = $servings . $iterator;
    $currentRecipe = $recipe . $iterator;
    $currentRepeat = $_REQUEST[$repeat . $iterator];
    $currentDelete = isset($_REQUEST[$delete . $iterator]) ? $_REQUEST[$delete . $iterator] : "";
    if ($currentDelete != "yes") {
        // Now repeat this item for the given number of days
コード例 #6
0
<?php

require_once "classes/MealPlan.class.php";
$date = isset($_GET['date']) ? $_GET['date'] : date('m-d-Y');
$view = isset($_GET['view']) ? $_GET['view'] : 'weekly';
if ($SMObj->getUserLoginID() == NULL) {
    die($LangUI->_('You must be logged in to use the Meal Planner!'));
}
// Create a new meal plan object
$MPObj = new MealPlan($date);
// Depending on the view type, load the need amount of meals.
if ($view == "daily") {
    // Just need to load the current date
    $dbDate = DBUtils::dbDate($date);
    // get the date in ISO format so that we have the key
    $MPObj->load($dbDate, $dbDate);
} else {
    if ($view == "weekly") {
        // Most likely to happen
        $weekList = $MPObj->getWeekDaysList($MPObj->currentDay, $MPObj->currentMonth, $MPObj->currentYear);
        $startDate = DBUtils::dbDate($weekList[0][1] . '-' . $weekList[0][0] . '-' . $weekList[0][2]);
        $endDate = DBUtils::dbDate($weekList[6][1] . '-' . $weekList[6][0] . '-' . $weekList[6][2]);
        $MPObj->load($startDate, $endDate);
    }
}
// we are not going to create a list for an entire month, that is just crazy...
?>
<table cellspacing="0" cellpadding="1" border="0" width="100%">
<tr>
	<td align="left" class="title">
		<?php 
コード例 #7
0
ファイル: index.php プロジェクト: pjflameboy/phprecipebook
<?php

require_once "classes/MealPlan.class.php";
// Initalize the POST/GET Vars
$view = isset($_GET['view']) ? $_GET['view'] : 'weekly';
$date = isset($_GET['date']) ? $_GET['date'] : date('m-d-Y');
if ($SMObj->getUserLoginID() == NULL) {
    die($LangUI->_('You must be logged in to use the Meal Planner!'));
}
// Create a new meal plan object
global $MPObj;
$MPObj = new MealPlan($date);
// Setup the forward and backward links and the title
$forwardLink = NULL;
$backwardLink = NULL;
$title = NULL;
$subtitle = NULL;
// title of what day/week/month we are in
// Now set the forward/backward/titles...
if ($view == "daily") {
    // daily view
    list($day, $month, $year) = $MPObj->getNextDay($MPObj->currentDay, $MPObj->currentMonth, $MPObj->currentYear, 1);
    $forwardLink = "<a href=\"index.php?m=meals&view=daily&date={$month}-{$day}-{$year}\">" . $LangUI->_('Next Day') . "</a>\n";
    list($day, $month, $year) = $MPObj->getPreviousDay($MPObj->currentDay, $MPObj->currentMonth, $MPObj->currentYear, 1);
    $backwardLink = "<a href=\"index.php?m=meals&view=daily&date={$month}-{$day}-{$year}\">" . $LangUI->_('Previous Day') . "</a>\n";
    $title = $LangUI->_('Daily Meal Planner');
    $subtitle = $MPObj->monthsFull[$MPObj->currentMonth - 1] . " " . $MPObj->currentDay . " " . $MPObj->currentYear;
    $shoppingLink = "<a href=\"index.php?m=meals&a=createlist&view=daily&date={$date}\">" . $LangUI->_('Create Shopping List') . '</a>';
} else {
    if ($view == "monthly") {
        // Monthly view