Exemplo n.º 1
0
<?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,
Exemplo n.º 2
0
    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 
echo $LangUI->_('Create Shopping List');
?>
	</td>
</tr>
<tr>
	<td class="nav" align="left">
Exemplo n.º 3
0
$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
        $thisDate = $date;
        //save the current date
        $dbDate = DBUtils::dbDate($thisDate);
        //and the database formated date
        for ($currentRepeat; $currentRepeat > 0; $currentRepeat--) {
            $MPObj->insert($dbDate, htmlentities($_REQUEST[$currentMeal], ENT_QUOTES), htmlentities($_REQUEST[$currentRecipe], ENT_QUOTES), htmlentities($_REQUEST[$currentServ], ENT_QUOTES), $SMObj->getUserID());
            list($month, $day, $year) = split("-", $thisDate);
            list($day, $month, $year) = $MPObj->getNextDay($day, $month, $year);
            //get the next day in case we need it.
            $thisDate = $month . "-" . $day . "-" . $year;
            $dbDate = $dbDate = DBUtils::dbDate($thisDate);
        }
    }
    // Setup for next loop
    $iterator++;
    $currentMeal = $meal . $iterator;
}
echo $LangUI->_('Meal Plan Updated') . "<br />\n";
Exemplo n.º 4
0
     }
     echo "</table>";
 } else {
     if ($view == "weekly") {
         //-------------------------------------------------------------------------------
         // Weekly View
         //-------------------------------------------------------------------------------
         printWeekDays();
         $weekdays = $MPObj->getWeekDaysList($MPObj->currentDay, $MPObj->currentMonth, $MPObj->currentYear);
         // Load the meals into memory
         $startDate = DBUtils::dbDate($weekdays[0][1] . '-' . $weekdays[0][0] . '-' . $weekdays[0][2]);
         $endDate = DBUtils::dbDate($weekdays[6][1] . '-' . $weekdays[6][0] . '-' . $weekdays[6][2]);
         $MPObj->load($startDate, $endDate);
         // Print out the week
         foreach ($weekdays as $d) {
             $dbDate = DBUtils::dbDate($d[1] . '-' . $d[0] . '-' . $d[2]);
             // get the date in ISO format so that we have the key
             echo "<td width=80 height=140 valign=top";
             if ($d[1] != $MPObj->currentMonth) {
                 echo " bgcolor=#DBDBDB";
             } else {
                 if ($d[0] == $MPObj->realDay && $d[1] == $MPObj->realMonth && $d[2] == $MPObj->realYear) {
                     echo " bgcolor=#d6e6f5";
                 }
             }
             echo '><a href="index.php?m=meals&view=daily&date=' . $d[1] . '-' . $d[0] . '-' . $d[2] . '">' . $d[0] . '</a>';
             echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . createEditLink($d[1] . '-' . $d[0] . '-' . $d[2], "weekly");
             echo "<br/>";
             echo $MPObj->getMeals($dbDate, 2);
             echo "</td>\n";
         }