Ejemplo n.º 1
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";
Ejemplo n.º 2
0
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
        list($day, $month, $year) = $MPObj->getNextMonth($MPObj->currentDay, $MPObj->currentMonth, $MPObj->currentYear);
        $forwardLink = "<a href=\"index.php?m=meals&view=monthly&date={$month}-{$day}-{$year}\">" . $LangUI->_('Next Month') . "</a>\n";
        list($day, $month, $year) = $MPObj->getPreviousMonth($MPObj->currentDay, $MPObj->currentMonth, $MPObj->currentYear);
        $backwardLink = "<a href=\"index.php?m=meals&view=monthly&date={$month}-{$day}-{$year}\">" . $LangUI->_('Previous Month') . "</a>\n";
        $title = $LangUI->_('Monthly Meal Planner');
        $subtitle = $MPObj->monthsFull[$MPObj->currentMonth - 1] . " " . $MPObj->currentYear;