<div class="route_row"> <div class="route_name">' . $route_name . '</div> </div>'; } if ($site_inactive == '1') { $site_class = 'suspended'; } elseif ($site_inactive == '2') { $site_class = 'standby'; } else { $site_class = 'active'; } $display .= ' <div class="site_row ' . $site_class . '"> <div class="hub">Hub: ' . $hub_short . '</div> <div class="site_short">' . $site_short . '</span></div> <div class="site_orders"><span class="site_long">' . $site_long . '</span><span class="num_orders">' . $num_orders . ' ' . Inflect::pluralize_if($num_orders, 'order') . '</span></div> <div class="link"><a href="delivery_list.php?route_id=' . $route_id . '&site_id=' . $site_id . '&delivery_id=' . $delivery_id . '">View by member</a></div> </div>'; $total_orders = $total_orders + $num_orders; $route_id_prior = $route_id; } $content_delivery = ' <div id="delivery_id_nav"> <a class="prior" href="' . $_SERVER['SCRIPT_NAME'] . '?delivery_id=' . ($delivery_id - 1) . '">← PRIOR CYCLE </a> <a class="next" href="' . $_SERVER['SCRIPT_NAME'] . '?delivery_id=' . ($delivery_id + 1) . '"> NEXT CYCLE →</a> </div> <h5>' . $total_orders . ' Total Orders for this Cycle</h5> <div id="site_list"> ' . $display . ' </div>'; $page_specific_css = '
} if (CurrentMember::auth_type('site_admin')) { $panel_admin_menu = ' <div class="tab_frame"> <a href="' . PATH . 'panel_admin.php" class="' . ($page_tab == 'admin_panel' ? ' current_tab' : '') . '">Site Admin</a> </div>'; } $logout_menu = ' <div class="tab_frame right"> <a href="' . PATH . 'index.php?action=logout" class="' . ($page_tab == 'login' ? ' current_tab' : '') . '">Logout</a> </div>'; if (isset($basket_id) && $basket_id != 0) { if (CurrentMember::auth_type('orderex') || ActiveCycle::ordering_window() == 'open') { $basket_menu = ' <div class="tab_frame right"> <a href="' . PATH . 'product_list.php?type=basket" class="">View Basket [' . $basket_quantity . ' ' . Inflect::pluralize_if($basket_quantity, 'item') . ']</a> </div>'; } } } else { $login_menu = ' <div class="tab_frame right"> <a href="' . PATH . 'index.php?action=login" class="' . ($page_tab == 'login' ? ' current_tab' : '') . '">Login</a> </div>'; } // Put it all together now //////////////////////////////////////////////////////////////////////////////// ////////////// //////////////////// ////////////// ASSEMBLE FINAL OUTPUT FOR POPUP PAGES //////////////////// ////////////// //////////////////// ////////////////////////////////////////////////////////////////////////////////
<?php require '../../inc/admin/config.php'; $session->auth_or_redirect('admin', '/login.php'); @session_start(); $x = 0; if ($session->auth('admin')) { $timestamp = time(); $errors = array(); $tools = array('admin_creator', 'form_builder', 'project_starter'); foreach ($tools as $tool) { $dir = ROOT . '/tools/_shared/tmp/'; $files = scandir($dir); list($prefix) = explode('_', $tool); foreach ($files as $file) { $filename = split('-', basename($file, '.zip')); if ($filename[0] == $prefix && $filename[1] < $timestamp) { if (unlink($dir . $file)) { ++$x; } else { $errors[] = 'Could not delete: ' . $dir . $file; } } } } } Flash::add('success', 'Cleared ' . Inflect::pluralize_if($x, 'file')); if (!empty($errors)) { Flash::add('error', implode('<br />', $errors)); } header("Location: ../");
<tr> <td rowspan="5" width="50%" valign="top"><strong>' . $row->product_name . '</strong><br>' . $row->detailed_notes . '</td> <td class="prod_desc">Product ID: </td> <td class="prod_data"><input type="text" name="product_id" size="3" value="' . $row->product_id . '"><br> </tr> <tr> <td class="prod_desc">Repeat after first order: </td> <td class="prod_data"><input type="text" name="repeat_cycles" size="3" value="' . $row->repeat_cycles . '"> ' . Inflect::pluralize_if($row->repeat_cycles, 'time') . '<br> </tr> <tr> <td class="prod_desc">Warn on remaining: </td> <td class="prod_data"><input type="text" name="warn_cycles" size="3" value="' . $row->warn_cycles . '"> ' . Inflect::pluralize_if($row->warn_cycles, 'cycle') . '<br> </tr> <tr> <td class="prod_desc">Orders to process: </td> <td class="prod_data">' . $row->quantity . ' ' . Inflect::pluralize_if($row->quantity, 'member') . '<br> </tr> <tr> <td class="prod_desc">Last added for: </td> <td class="prod_data">' . ($row->delivery_date ? date("M d, Y", strtotime($row->delivery_date)) : '[NEVER]') . '</td> </tr>'; if ($repeat_id == $row->repeat_id && count($completion_array) > 0) { sort($completion_array, SORT_NUMERIC); $display .= ' <tr> <td colspan="3"> <div class="completion_list"> ' . implode('<br>', $completion_array) . ' </div> </td> </tr>';
AND product_id = "' . mysql_real_escape_string($product_id) . '"'; } elseif ($update_field == 'quantity' || $update_field == 'total_weight' || $update_field == 'out_of_stock') { $where_condition = ' WHERE basket_id = "' . mysql_real_escape_string($basket_id) . '" AND product_id = "' . mysql_real_escape_string($product_id) . '"'; } $query = ' UPDATE ' . NEW_TABLE_BASKET_ITEMS . ' RIGHT JOIN ' . NEW_TABLE_BASKETS . ' USING (basket_id) SET ' . mysql_real_escape_string($update_field) . ' = "' . mysql_real_escape_string($update_content) . '"' . $where_condition; $result = mysql_query("{$query}") or die("Error: 853040" . mysql_error()); if (($affected_rows = mysql_affected_rows()) > 0) { // $affected_rows = mysql_affected_rows($result); $ajax_content .= "SUCCESS Updated {$affected_rows} " . Inflect::pluralize_if($affected_rows, 'row') . '.<pre>' . $query . '</pre>'; } else { $ajax_content .= $query; } echo "{$ajax_content}"; exit(0); } //////////////////////////////////////////////////////////////////////////// // // // MAJOR SECTION FOR AJAX // // Display the old invoice for this order // // // //////////////////////////////////////////////////////////////////////////// if ($_REQUEST['process'] == 'view_invoice') { $basket_id = $_REQUEST['basket_id']; $ajax_content = '
function inventory_display_calc($data) { return $data['inventory_id'] ? '<span id="available' . $data['product_id'] . '">' . ($data['inventory_quantity'] == 0 ? '[OUT OF STOCK] No' : $data['inventory_quantity']) . '</span> more ' . Inflect::pluralize_if($data['inventory_quantity'], $data['ordering_unit']) . ' available. ' : ''; }
function check_membership_renewal($membership_info) { global $connection; $renewal_info = array(); $renewal_info['used_expiration_range'] = 0; // Check for the simple case where the membership does NOT expire if ($membership_info['expire_type'] == '') { $expiration_units = ''; $renewal_info['used_expiration_range'] = 0; $renewal_info['standard_renewal_date'] = ''; // Or should this be 'N/A'? $renewal_info['suggested_renewal_date'] = date('Y-m-d', time()); // Or should this be 'N/A'? $renewal_info['total_expiration_range'] = $membership_info['expire_after']; $renewal_info['membership_percent_complete'] = 0; $renewal_info['membership_message'] = 'Your "' . $membership_info['membership_class'] . '" membership does not expire.'; } elseif ($membership_info['expire_type'] == 'cycle') { // Get a count of the number of cycles since the last_renewal_date and the current date. // NOTE: overlapping cycles might cause this to be a little screwy: e.g. if an order opens // and I start shopping, then another delivery date happens... my cycle count will increment // and I may need to renew before I can continue shopping. $query = ' SELECT delivery_id, delivery_date FROM ' . TABLE_ORDER_CYCLES . ' WHERE delivery_date >= "' . mysql_real_escape_string($membership_info['last_renewal_date']) . '" AND delivery_date < CURDATE()'; $result = mysql_query($query, $connection) or die(debug_print("ERROR: 780322 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__)); $grace_count = 0; $renewal_info['used_expiration_range'] = 0; $renewal_info['standard_renewal_date'] = 'Not established'; $renewal_info['suggested_renewal_date'] = ''; // Presume not expired, but clobber this value later if expiration is discovered $renewal_info['membership_expired'] = false; while ($row = mysql_fetch_array($result)) { // Count how many deliveries transpired $renewal_info['used_expiration_range']++; // Check if this is the order when the expiration would have occurred if ($renewal_info['used_expiration_range'] == $membership_info['expire_after']) { // The standard renewal date would be the day after the last regularly allowed delivery date $renewal_info['membership_expired'] = true; $renewal_info['standard_renewal_date'] = date('Y-m-d', strtotime($row['delivery_date']) + 24 * 3600); } // Keep track of whether we are in the grace_period if ($renewal_info['used_expiration_range'] >= $membership_info['expire_after']) { $grace_count++; $renewal_info['membership_expired'] = true; if ($grace_count <= $membership_info['grace_period']) { // Keep the standard renewal date if within the grace period $renewal_info['suggested_renewal_date'] = $renewal_info['standard_renewal_date']; } else { // Set to the current date if the grace period is expired $renewal_info['suggested_renewal_date'] = date('Y-m-d', time()); } } } $renewal_info['total_expiration_range'] = $membership_info['expire_after']; $renewal_info['membership_percent_complete'] = round($renewal_info['used_expiration_range'] / $renewal_info['total_expiration_range'] * 100, 0); // Set message if expired if ($renewal_info['membership_expired'] == true) { $renewal_info['membership_message'] = 'Time to renew. Your "' . $membership_info['membership_class'] . '" membership expired after ' . $membership_info['expire_after'] . ' ' . Inflect::pluralize_if($membership_info['expire_after'], $membership_info['expire_type']) . '.'; } else { $renewal_info['membership_message'] = 'You are ' . $renewal_info['membership_percent_complete'] . '% through your "' . $membership_info['membership_class'] . '" membership period.'; } } elseif ($membership_info['expire_type'] == 'order') { // Get a count of the number of cycles since the last_renewal_date and the current date. // NOTE: overlapping cycles might cause this to be a little screwy: e.g. if an order opens // and I start shopping, then another delivery date happens... my cycle count will increment // and I may need to renew before I can continue shopping. $query = ' SELECT delivery_id, delivery_date FROM ' . NEW_TABLE_BASKETS . ' LEFT JOIN ' . TABLE_ORDER_CYCLES . ' USING(delivery_id) WHERE ' . NEW_TABLE_BASKETS . '.member_id = ' . mysql_real_escape_string($membership_info['member_id']) . ' AND ' . TABLE_ORDER_CYCLES . '.delivery_date >= "' . mysql_real_escape_string($membership_info['last_renewal_date']) . '" AND ' . TABLE_ORDER_CYCLES . '.delivery_date < CURDATE() AND checked_out != 0'; // Does not include NULL (i.e not checked_out items) $result = mysql_query($query, $connection) or die(debug_print("ERROR: 780322 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__)); $grace_count = 0; $renewal_info['used_expiration_range'] = 0; $renewal_info['standard_renewal_date'] = 'Not established'; $renewal_info['suggested_renewal_date'] = ''; // Presume not expired, but clobber this value later if expiration is discovered $renewal_info['membership_expired'] = false; while ($row = mysql_fetch_array($result)) { // Count how many deliveries transpired $renewal_info['used_expiration_range']++; // Check if this is the order when the expiration would have occurred if ($renewal_info['used_expiration_range'] == $membership_info['expire_after']) { // The standard renewal date would be the day after the last regularly allowed delivery date $renewal_info['membership_expired'] = true; $renewal_info['standard_renewal_date'] = date('Y-m-d', strtotime($row['delivery_date']) + 24 * 3600); } // Keep track of whether we are in the grace_period if ($renewal_info['used_expiration_range'] >= $membership_info['expire_after']) { $grace_count++; $renewal_info['membership_expired'] = true; if ($grace_count <= $membership_info['grace_period']) { // Keep the standard renewal date if within the grace period $renewal_info['suggested_renewal_date'] = $renewal_info['standard_renewal_date']; } else { // Set to the current date if the grace period is expired $renewal_info['suggested_renewal_date'] = date('Y-m-d', time()); } } } $renewal_info['total_expiration_range'] = $membership_info['expire_after']; $renewal_info['membership_percent_complete'] = round($renewal_info['used_expiration_range'] / $renewal_info['total_expiration_range'] * 100, 0); // Set message if expired if ($renewal_info['membership_expired'] == true) { $renewal_info['membership_message'] = 'Time to renew. Your "' . $membership_info['membership_class'] . '" membership expired after ' . $membership_info['expire_after'] . ' ' . Inflect::pluralize_if($membership_info['expire_after'], $membership_info['expire_type']) . '.'; } else { $renewal_info['membership_message'] = 'You are ' . $renewal_info['membership_percent_complete'] . '% through your "' . $membership_info['membership_class'] . '" membership period.'; } } elseif ($membership_info['expire_type'] == 'day') { $renewal_info['used_expiration_range'] = 0; $renewal_info['standard_renewal_date'] = ''; $renewal_info['suggested_renewal_date'] = ''; $renewal_info['total_expiration_range'] = $membership_info['expire_after']; $renewal_info['used_expiration_range'] = (time() - strtotime($membership_info['last_renewal_date'])) / (24 * 3600); $renewal_info['membership_percent_complete'] = round($renewal_info['used_expiration_range'] / $renewal_info['total_expiration_range'] * 100, 0); $renewal_info['standard_renewal_date'] = date('Y-m-d', strtotime($membership_info['last_renewal_date']) + 24 * 3600 * $membership_info['expire_after']); // If the account is expired if ($renewal_info['used_expiration_range'] >= $membership_info['expire_after']) { $renewal_info['standard_renewal_date'] = date('Y-m-d', strtotime($membership_info['last_renewal_date']) + 24 * 3600 * $membership_info['expire_after']); // If the grace period is still in effect, then use the standard_renewal_date if (strtotime($renewal_info['standard_renewal_date']) + 24 * 3600 * $membership_info['grace_period'] > time()) { $renewal_info['suggested_renewal_date'] = $renewal_info['standard_renewal_date']; } else { $renewal_info['suggested_renewal_date'] = date('Y-m-d', time()); } $renewal_info['membership_expired'] = true; $renewal_info['membership_message'] = 'Time to renew. Your "' . $membership_info['membership_class'] . '" membership expired after ' . $membership_info['expire_after'] . ' ' . Inflect::pluralize_if($membership_info['expire_after'], $membership_info['expire_type']) . '.'; } else { $renewal_info['membership_expired'] = false; $renewal_info['membership_message'] = 'You are ' . $renewal_info['membership_percent_complete'] . '% through your "' . $membership_info['membership_class'] . '" membership period.'; } } elseif ($membership_info['expire_type'] == 'week') { $renewal_info['used_expiration_range'] = 0; $renewal_info['standard_renewal_date'] = ''; $renewal_info['suggested_renewal_date'] = ''; $renewal_info['total_expiration_range'] = $membership_info['expire_after']; $renewal_info['used_expiration_range'] = (time() - strtotime($membership_info['last_renewal_date'])) / (7 * 24 * 3600); $renewal_info['membership_percent_complete'] = round($renewal_info['used_expiration_range'] / $renewal_info['total_expiration_range'] * 100, 0); $renewal_info['standard_renewal_date'] = date('Y-m-d', strtotime($membership_info['last_renewal_date']) + 7 * 24 * 3600 * $membership_info['expire_after']); // If the account is expired if ($renewal_info['used_expiration_range'] >= $membership_info['expire_after']) { $renewal_info['standard_renewal_date'] = date('Y-m-d', strtotime($membership_info['last_renewal_date']) + 7 * 24 * 3600 * $membership_info['expire_after']); // If the grace period is still in effect, then use the standard_renewal_date if (strtotime($renewal_info['standard_renewal_date']) + 7 * 24 * 3600 * $membership_info['grace_period'] > time()) { $renewal_info['suggested_renewal_date'] = $renewal_info['standard_renewal_date']; } else { $renewal_info['suggested_renewal_date'] = date('Y-m-d', time()); } $renewal_info['membership_expired'] = true; $renewal_info['membership_message'] = 'Time to renew. Your "' . $membership_info['membership_class'] . '" membership expired after ' . $membership_info['expire_after'] . ' ' . Inflect::pluralize_if($membership_info['expire_after'], $membership_info['expire_type']) . '.'; } else { $renewal_info['membership_expired'] = false; $renewal_info['membership_message'] = 'You are ' . $renewal_info['membership_percent_complete'] . '% through your "' . $membership_info['membership_class'] . '" membership period.'; } } elseif ($membership_info['expire_type'] == 'month') { $renewal_info['used_expiration_range'] = 0; $renewal_info['standard_renewal_date'] = ''; $renewal_info['suggested_renewal_date'] = ''; $standard_renewal_date = array(); // Months are counted from the same day of each month $last_renewal_date = explode('-', date('Y-n-j', strtotime($membership_info['last_renewal_date']))); $current_date = explode('-', date('Y-n-j', time())); if (is_array($last_renewal_date) && is_array($current_date)) { $year_difference = $current_date[0] - $last_renewal_date[0]; $month_difference = $current_date[1] - $last_renewal_date[1]; $day_difference = $current_date[2] - $last_renewal_date[2]; $renewal_info['used_expiration_range'] = $day_difference > 0 ? $month_difference : $month_difference - 1; $renewal_info['used_expiration_range'] += $year_difference * 12; } $renewal_info['total_expiration_range'] = $membership_info['expire_after']; $renewal_info['membership_percent_complete'] = round($renewal_info['used_expiration_range'] / $renewal_info['total_expiration_range'] * 100, 0); // Go get the standard_renewal_date $standard_year_difference = floor($membership_info['expire_after'] / 12); $standard_month_difference = $membership_info['expire_after'] - $standard_year_difference * 12; $standard_renewal_day = $last_renewal_date[2]; $standard_renewal_month = $last_renewal_date[1] + $standard_month_difference; $standard_renewal_year = $last_renewal_date[0] + $standard_year_difference; if ($standard_renewal_month > 12) { $standard_renewal_month = $standard_renewal_month - 12; $standard_renewal_year = $standard_renewal_year + 1; } if (!checkdate($standard_renewal_month, $standard_renewal_day, $standard_renewal_year)) { $standard_renewal_day--; // Take 31 to 30 if (!checkdate($standard_renewal_month, $standard_renewal_day, $standard_renewal_year)) { $standard_renewal_day--; // Take 30 to 29 if (!checkdate($standard_renewal_month, $standard_renewal_day, $standard_renewal_year)) { $standard_renewal_day--; // Take 29 to 28 // Should not need any further checks since this will cover longest to shortest month } } } $renewal_info['standard_renewal_date'] = date('Y-m-d', strtotime("{$standard_renewal_year}-{$standard_renewal_month}-{$standard_renewal_day}")); // Go get the suggested_renewal_date (assuming we are still inside the grace_period $suggested_year_difference = floor(($membership_info['expire_after'] + $membership_info['grace_period']) / 12); $suggested_month_difference = $membership_info['expire_after'] + $membership_info['grace_period'] - $suggested_year_difference * 12; $suggested_renewal_day = $last_renewal_date[2]; $suggested_renewal_month = $last_renewal_date[1] + $suggested_month_difference; $suggested_renewal_year = $last_renewal_date[0] + $suggested_year_difference; if ($suggested_renewal_month > 12) { $suggested_renewal_month = $suggested_renewal_month - 12; $suggested_renewal_year = $suggested_renewal_year + 1; } if (!checkdate($suggested_renewal_month, $suggested_renewal_day, $suggested_renewal_year)) { $suggested_renewal_day--; // Take 31 to 30 if (!checkdate($suggested_renewal_month, $suggested_renewal_day, $suggested_renewal_year)) { $suggested_renewal_day--; // Take 30 to 29 if (!checkdate($suggested_renewal_month, $suggested_renewal_day, $suggested_renewal_year)) { $suggested_renewal_day--; // Take 29 to 28 // Should not need any further checks since this will cover longest to shortest month } } } // Check if the grace_period has passed if (strtotime("{$suggested_renewal_year}-{$suggested_renewal_month}-{$suggested_renewal_day}") < time()) { // So use the current time $renewal_info['suggested_renewal_date'] = date('Y-m-d', time()); $renewal_info['membership_expired'] = true; $renewal_info['membership_message'] = 'Time to renew. Your "' . $membership_info['membership_class'] . '" membership expired after ' . $membership_info['expire_after'] . ' ' . Inflect::pluralize_if($membership_info['expire_after'], $membership_info['expire_type']) . '.'; } elseif (strtotime($renewal_info['standard_renewal_date']) < time()) { $renewal_info['suggested_renewal_date'] = $renewal_info['standard_renewal_date']; $renewal_info['membership_expired'] = true; $renewal_info['membership_message'] = 'Time to renew. Your "' . $membership_info['membership_class'] . '" membership expired after ' . $membership_info['expire_after'] . ' ' . Inflect::pluralize_if($membership_info['expire_after'], $membership_info['expire_type']) . '.'; } else { $renewal_info['membership_expired'] = false; $renewal_info['membership_message'] = 'You are ' . $renewal_info['membership_percent_complete'] . '% through your "' . $membership_info['membership_class'] . '" membership period.'; } } elseif ($membership_info['expire_type'] == 'year') { $renewal_info['used_expiration_range'] = 0; $renewal_info['standard_renewal_date'] = ''; $renewal_info['suggested_renewal_date'] = ''; $renewal_info['total_expiration_range'] = $membership_info['expire_after']; $renewal_info['used_expiration_range'] = (time() - strtotime($membership_info['last_renewal_date'])) / (365.24 * 24 * 3600); $renewal_info['membership_percent_complete'] = round($renewal_info['used_expiration_range'] / $renewal_info['total_expiration_range'] * 100, 0); $renewal_info['standard_renewal_date'] = date('Y-m-d', strtotime($membership_info['last_renewal_date']) + 365.24 * 24 * 3600 * $membership_info['expire_after']); // If the account is expired, then set the standard_renewal_date to the same day if ($renewal_info['used_expiration_range'] >= $membership_info['expire_after']) { $renewal_info['membership_expired'] = true; $renewal_info['standard_renewal_date'] = date('Y-m-d', strtotime($membership_info['last_renewal_date']) + 365.24 * 24 * 3600 * $membership_info['expire_after']); // If the grace period is still in effect, then use the standard_renewal_date if (strtotime($renewal_info['standard_renewal_date']) + 365.24 * 24 * 3600 * $membership_info['grace_period'] > time()) { $renewal_info['suggested_renewal_date'] = $renewal_info['standard_renewal_date']; } else { $renewal_info['suggested_renewal_date'] = date('Y-m-d', time()); } $renewal_info['membership_message'] = 'Time to renew. Your "' . $membership_info['membership_class'] . '" membership expired after ' . $membership_info['expire_after'] . ' ' . Inflect::pluralize_if($membership_info['expire_after'], $membership_info['expire_type']) . '.'; } else { $renewal_info['membership_expired'] = false; $renewal_info['membership_message'] = 'You are ' . $renewal_info['membership_percent_complete'] . '% through your "' . $membership_info['membership_class'] . '" membership period.'; } } elseif ($membership_info['expire_type'] == 'calendar year') { // Calendar year is based upon the day-number in the year $renewal_info['used_expiration_range'] = 0; $renewal_info['standard_renewal_date'] = ''; $renewal_info['suggested_renewal_date'] = ''; // This gets the year (YYYY+1) after the last renewal date $standard_renewal_time = strtotime(date('Y', strtotime($membership_info['last_renewal_date'])) + 1 . '-01-01'); // And this adds the days until the annual renewal date $standard_renewal_time += 24 * 3600 * $membership_info['expire_after']; // Adjust standard_renewal time... // If it is longer than a year, but still within the grace_period, it is okay. while ($standard_renewal_time > strtotime($membership_info['last_renewal_date']) + 3600 * 24 * 365.24 + $membership_info['grace_period']) { $standard_renewal_time -= 3600 * 24 * 365.24; } // Now convert standard_renewal_time to date format $renewal_info['standard_renewal_date'] = date('Y-m-d', $standard_renewal_time); // So the number of days between those two (normally would be 365, but the annual date may have changed) $renewal_info['total_expiration_range'] = (strtotime($renewal_info['standard_renewal_date']) - strtotime($membership_info['last_renewal_date'])) / (24 * 3600); $renewal_info['used_expiration_range'] = (time() - strtotime($membership_info['last_renewal_date'])) / (24 * 3600); $renewal_info['membership_percent_complete'] = round($renewal_info['used_expiration_range'] / 365.24 * 100, 0); // Get the most recent annual renewal date $this_year = date('Y', time()); $previous_renewal_date = date('Y-m-d', strtotime($this_year . '-01-01') + 24 * 3600 * $membership_info['expire_after']); // Check if our most_recent_renewal_date is in the future. If so, then use the one from last year if (time() < strtotime($previous_renewal_date)) { // Save this just to avoid recalculation $next_renewal_date = $previous_renewal_date; // ... and get the renewal date from last year. $previous_renewal_date = date('Y-m-d', strtotime($this_year - 1 . '-01-01') + 24 * 3600 * $membership_info['expire_after']); } else { $next_renewal_date = date('Y-m-d', strtotime($previous_renewal_date + 1 . '-01-01') + 24 * 3600 * $membership_info['expire_after']); } // If still within the year then no need to renew yet if ($renewal_info['total_expiration_range'] > $renewal_info['used_expiration_range']) { $renewal_info['membership_expired'] = false; // $renewal_info['suggested_renewal_date'] = $renewal_info['standard_renewal_date']; $renewal_info['membership_message'] = 'You are ' . $renewal_info['membership_percent_complete'] . '% through your "' . $membership_info['membership_class'] . '" membership period which began ' . $previous_renewal_date . '.'; } elseif ($renewal_info['total_expiration_range'] + $membership_info['grace_period'] > $renewal_info['used_expiration_range']) { $renewal_info['membership_expired'] = true; $renewal_info['suggested_renewal_date'] = $renewal_info['standard_renewal_date']; $renewal_info['membership_message'] = 'Time to renew your "' . $membership_info['membership_class'] . '" membership for the calendar year beginning ' . $renewal_info['suggested_renewal_date'] . '.'; } elseif (time() - $membership_info['grace_period'] * 24 * 3600 < strtotime($previous_renewal_date)) { $renewal_info['membership_expired'] = true; $renewal_info['suggested_renewal_date'] = $previous_renewal_date; $renewal_info['membership_message'] = 'Renew your "' . $membership_info['membership_class'] . '" membership for the calendar year beginning ' . $renewal_info['suggested_renewal_date'] . '.'; } else { $renewal_info['membership_expired'] = true; $renewal_info['suggested_renewal_date'] = $next_renewal_date; $renewal_info['membership_message'] = 'Renew your "' . $membership_info['membership_class'] . '" membership for the calendar year beginning ' . $renewal_info['suggested_renewal_date'] . '.'; } } $renewal_info['expire_message'] = $membership_info['expire_message']; $renewal_info['expire_type'] = $membership_info['expire_type']; $renewal_info['membership_class'] = $membership_info['membership_class']; $renewal_info['membership_type_id'] = $membership_info['membership_type_id']; $renewal_info['membership_description'] = $membership_info['membership_description']; $renewal_info['membership_date'] = $membership_info['membership_date']; return $renewal_info; }
business_name, sum_p DESC'; $result = @mysql_query($query, $connection) or die(debug_print("ERROR: 860342 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__)); while ($row = mysql_fetch_array($result)) { $product_id = $row['product_id']; $product_name = $row['product_name']; $product_quantity = $row['sum_p']; $ordering_unit = $row['ordering_unit']; $business_name = $row['business_name']; if (strlen($business_name) > 16) { $business_name = str_replace(' ', ' ', substr($business_name, 0, 9) . '...' . substr($business_name, -4, 4)); } $display_p .= ' <tr> <td align="right">' . $product_quantity . '</td> <td align="left">' . str_replace(' ', ' ', Inflect::pluralize_if($product_quantity, $ordering_unit)) . ' </td> <td align="left">' . $business_name . '</td> <td> ' . $product_name . ' (# ' . $product_id . ')</td> </tr>'; $quantity_all += $row['sum_p']; } $content_delivery = ' <div align="center"> <div id="delivery_id_nav"> <a class="prior" href="' . $_SERVER['SCRIPT_NAME'] . '?route_id=' . $route_id . '&site_id=' . $site_id . '&delivery_id=' . ($delivery_id - 1) . '">← PRIOR CYCLE </a> <a class="next" href="' . $_SERVER['SCRIPT_NAME'] . '?route_id=' . $route_id . '&site_id=' . $site_id . '&delivery_id=' . ($delivery_id + 1) . '"> NEXT CYCLE →</a> </div> <table width="80%" bgcolor="#FFFFFF" cellspacing="2" cellpadding="2" border="0"> <tr> <td align="left"> <h3>Route List: ' . $site_array['delivery_date'] . '</h3>
// the current number of views to send back, so do the next query first... } $query = ' SELECT COUNT(status_key) AS total_views, MIN(timestamp) AS oldest_view FROM ' . NEW_TABLE_STATUS . ' WHERE status_scope = "motd_viewed" AND status_value = "popup"'; $result = @mysql_query($query, $connection) or die(debug_print("ERROR: 578230 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__)); if ($row = mysql_fetch_object($result)) { $total_views = $row->total_views; $oldest_view = $row->oldest_view; } $views_text = 'Viewed by ' . $total_views . ' ' . Inflect::pluralize_if($total_views, 'member') . (isset($oldest_view) ? ' since<br />' . $oldest_view : '') . '.'; if ($_GET['action'] == 'reset_motd') { echo $views_text; exit(0); } $motd_reset = ' <fieldset id="motd_admin"> <legend>Admin Function</legend> <div class="instructions"> Administrators may edit the MOTD message (in HTML) under Site Admin / Edit Site Configuration. By default, members will be forced to view the MOTD every ' . MOTD_REPEAT_TIME . ' days. Pressing the reset button below (twice to confirm) will force all members to view the MOTD the next time they access this site. </div> <span id="total_views" class="total_views">' . $views_text . '</span> <input id="reset_motd" class="reset_motd" type="button" onblur="reset_motd(this,\'clear\')" onclick="reset_motd(this,\'set\')" value="RESET ALL MOTD VIEWS" title="Reset all MOTD views"> </div>'; }
function row_activity_link_calc($data, $pager) { return '<td class="basket_control" id="activity' . $data['product_id'] . '">' . (!$data['checked_out'] ? $data['availability'] == true ? $data['basket_quantity'] > 0 || !$data['inventory_id'] || $data['inventory_quantity'] > 0 ? $data['order_open'] ? '<form action="' . $_SERVER['SCRIPT_NAME'] . '?type=' . $_GET['type'] . '#X' . $data['product_id'] . '" method="post"> <input id="add' . $data['product_id'] . '" class="basket_add" type="image" name="basket_add" src="' . DIR_GRAPHICS . 'basket_add.png" width="24" height="24" border="0" alt="Submit" onclick="AddToCart(' . $data['product_id'] . ',' . $data['product_version'] . ',\'add\'); return false;" ' . ($data['basket_quantity'] > 0 ? $data['inventory_id'] && $data['inventory_quantity'] == 0 ? 'style="display:none;"' : '' : 'style="display:none;"') . '> <input id="sub' . $data['product_id'] . '" class="basket_sub" type="image" name="basket_sub" src="' . DIR_GRAPHICS . 'basket_sub.png" width="24" height="24" border="0" alt="Submit" onclick="AddToCart(' . $data['product_id'] . ',' . $data['product_version'] . ',\'sub\'); return false;" ' . ($data['basket_quantity'] > 0 ? '' : 'style="display:none;"') . '> <input type="hidden" name="product_id" value="' . $data['product_id'] . '"> <input type="hidden" name="product_version" value="' . $data['product_version'] . '"> <input type="hidden" name="producer_id" value="' . $data['producer_id'] . '"> <input type="hidden" name="product_id_printed" value="' . $data['product_id'] . '"> <input type="hidden" name="product_name" value="' . $data['product_name'] . '"> <input type="hidden" name="subcategory_id" value="' . $data['subcategory_id'] . '"> <input type="hidden" name="process_type" value="customer_basket"> <div class="basket_button"> <input id="basket_empty' . $data['product_id'] . '" class="basket" type="image" name="basket" src="' . DIR_GRAPHICS . 'basket-egi_add.png" width="48" height="48" border="0" alt="Submit" onClick="AddToCart(' . $data['product_id'] . ',' . $data['product_version'] . ',\'add\'); return false;" ' . ($data['basket_quantity'] > 0 ? 'style="display:none;"' : '') . '> <img id="basket_full' . $data['product_id'] . '" class="basket" src="' . DIR_GRAPHICS . 'basket-fcs.png" width="48" height="48" border="0" ' . ($data['basket_quantity'] > 0 ? '' : 'style="display:none;"') . '> </div> </form> <span id="in_basket' . $data['product_id'] . '" class="in_basket" ' . ($data['basket_quantity'] > 0 ? '' : 'style="display:none;"') . '><span id="basket_qty' . $data['product_id'] . '" class="basket_qty">' . $data['basket_quantity'] . '</span> in basket</span>' : ' <span id="in_basket' . $data['product_id'] . '" class="in_basket"><span id="basket_qty' . $data['product_id'] . '" class="basket_qty_closed">' . $data['basket_quantity'] . '</span> in basket</span>' : '' : 'Unavailable for ' . $data['site_long'] : ($data['checked_out'] ? $data['basket_quantity'] . ' ' . Inflect::pluralize_if($data['basket_quantity'], $data['ordering_unit']) . ($data['random_weight'] ? '<br>' . ($data['total_weight'] ? $data['total_weight'] . ' ' . Inflect::pluralize_if($data['total_weight'], $data['pricing_unit']) : '(wt. pending)') : '') : '')) . '</td>'; }
$result = @mysql_query($query, $connection) or die(debug_print("ERROR: 657922 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__)); $basket_quantity = 0; if ($row = mysql_fetch_object($result)) { $basket_quantity = $row->basket_quantity; $basket_id = $row->basket_id; $delivery_type = $row->delivery_type; } if (ActiveCycle::ordering_window() == 'open') { if ($basket_id) { $basket_status = 'Ready for shopping<br>' . $basket_quantity . ' ' . Inflect::pluralize_if($basket_quantity, 'item') . ' in basket'; } else { $basket_status = ' <em>Use Select Location (above) to open a shopping basket</em>'; } } else { $basket_status = 'Ordering is currently closed<br>' . $basket_quantity . ' ' . Inflect::pluralize_if($basket_quantity, 'item') . ' in basket'; } // Set content_top to show basket selector... $delivery_codes_list .= get_delivery_codes_list(array('action' => $_GET['action'], 'member_id' => $_SESSION['member_id'], 'delivery_id' => ActiveCycle::delivery_id(), 'site_id' => $_GET['site_id'], 'delivery_type' => $_GET['delivery_type'])); $baskets_list .= get_baskets_list(); // Generate the display output $display .= ' <table width="100%" class="compact"> <tr valign="top"> <td align="left" width="50%">' . ($delivery_codes_list ? '<div class="content_top">' . $delivery_codes_list . ' </div>' : '') . ' </td> <td align="right" width="50%">' . ($baskets_list ? '<div class="content_top" style="float:right;">' . $baskets_list . ' </div>' : '') . ' </td> </tr>
function generate_producer_summary($producer_id, $delivery_id, $detail_type, $use) { global $connection, $include_header, $include_footer, $producer_markdown, $retail_markup, $wholesale_markup; $query = ' SELECT * FROM ' . TABLE_ORDER_CYCLES . ' WHERE delivery_id = ' . mysql_real_escape_string($delivery_id); $result = mysql_query("{$query}") or die("Error: " . mysql_error()); while ($row = mysql_fetch_array($result)) { $delivery_date = date("M j, Y", strtotime($row['delivery_date'])); } /// OBTAIN PRODUCER BUSINESS AND NAME INFO. /// $sqlp = ' SELECT ' . TABLE_PRODUCER . '.business_name, ' . TABLE_MEMBER . '.first_name, ' . TABLE_MEMBER . '.last_name, ' . TABLE_MEMBER . '.address_line1, ' . TABLE_MEMBER . '.address_line2, ' . TABLE_MEMBER . '.city, ' . TABLE_MEMBER . '.state, ' . TABLE_MEMBER . '.zip, ' . TABLE_MEMBER . '.county, ' . TABLE_MEMBER . '.email_address, ' . TABLE_MEMBER . '.home_phone, ' . TABLE_MEMBER . '.work_phone, ' . TABLE_MEMBER . '.mobile_phone FROM ' . TABLE_PRODUCER . ', ' . TABLE_MEMBER . ' WHERE ' . TABLE_PRODUCER . '.producer_id = "' . mysql_real_escape_string($producer_id) . '" AND ' . TABLE_PRODUCER . '.member_id = ' . TABLE_MEMBER . '.member_id GROUP BY ' . TABLE_PRODUCER . '.producer_id ORDER BY business_name ASC, last_name ASC'; $resultp = @mysql_query($sqlp, $connection) or die(debug_print("ERROR: 762930 ", array($sqlp, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__)); while ($row = mysql_fetch_array($resultp)) { $a_business_name = $row['business_name']; $a_first_name = $row['first_name']; $a_last_name = $row['last_name']; $a_address_line1 = $row['address_line1']; $a_address_line2 = $row['address_line2']; $a_city = $row['city']; $a_state = $row['state']; $a_zip = $row['zip']; $a_county = $row['county']; $a_email_address = $row['email_address']; $a_home_phone = $row['home_phone']; $a_work_phone = $row['work_phone']; $a_mobile_phone = $row['cell_phone']; } $sqlpr = ' SELECT ' . NEW_TABLE_BASKET_ITEMS . '.*, ' . NEW_TABLE_PRODUCTS . '.*, ' . TABLE_PRODUCT_STORAGE_TYPES . '.storage_code, ' . NEW_TABLE_SITES . '.site_id, ' . NEW_TABLE_SITES . '.site_short, ' . NEW_TABLE_SITES . '.site_long, ' . TABLE_MEMBER . '.first_name, ' . TABLE_MEMBER . '.last_name, ' . TABLE_MEMBER . '.business_name, ' . TABLE_MEMBER . '.preferred_name, ' . TABLE_MEMBER . '.member_id, ' . TABLE_MEMBER . '.auth_type, ' . NEW_TABLE_BASKETS . '.delivery_type FROM ' . NEW_TABLE_BASKET_ITEMS . ' LEFT JOIN ' . NEW_TABLE_PRODUCTS . ' USING(product_id,product_version) LEFT JOIN ' . TABLE_PRODUCT_STORAGE_TYPES . ' USING(storage_id) LEFT JOIN ' . NEW_TABLE_BASKETS . ' USING(basket_id) LEFT JOIN ' . TABLE_MEMBER . ' USING(member_id) LEFT JOIN ' . NEW_TABLE_SITES . ' USING(site_id) WHERE ' . NEW_TABLE_PRODUCTS . '.producer_id = "' . mysql_real_escape_string($producer_id) . '" AND hide_from_invoice = 0 AND ' . NEW_TABLE_BASKETS . '.delivery_id = ' . $delivery_id . ' ORDER BY ' . NEW_TABLE_SITES . '.site_long, ' . NEW_TABLE_PRODUCTS . '.product_name, ' . TABLE_MEMBER . '.last_name, ' . TABLE_MEMBER . '.business_name, ' . TABLE_MEMBER . '.first_name'; $resultpr = @mysql_query($sqlpr) or die(debug_print("ERROR: 758493 ", array($sqlp, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__)); while ($row = mysql_fetch_array($resultpr)) { $product_adjust_fee = $row['product_fee_percent']; $subcat_adjust_fee = $row['subcategory_fee_percent']; $producer_adjust_fee = $row['producer_fee_percent']; // Set the coop_markup according to auth_type if (in_array('institution', explode(',', $row['auth_type']))) { $coop_markup = 1 + $wholesale_markup; } else { $coop_markup = 1 + $retail_markup; } // Set the adjust_markup $adjust_markup = 1 + $product_adjust_fee + $subcat_adjust_fee + $producer_adjust_fee; $product_id = $row['product_id']; $product_name = $row['product_name']; $customer_notes_to_producer = $row['customer_notes_to_producer']; $site_id = $row['site_id']; $site_short = $row['site_short']; $site_long = $row['site_long']; $member_id = $row['member_id']; $last_name = $row['last_name']; $first_name = $row['first_name']; $business_name = $row['business_name']; $preferred_name = $row['preferred_name']; $delivery_type = $row['delivery_type']; $out_of_stock = $row['out_of_stock']; $extra_charge = $row['extra_charge']; // Set the display_unit_price according to SHOW_ACTUAL_PRICE if (SHOW_ACTUAL_PRICE) { $unit_price = round($row['item_price'] * $adjust_markup * $coop_markup, 2); } else { $unit_price = round($row['item_price'] * $adjust_markup, 2); } $quantity = $row['quantity']; $total_weight = $row['total_weight']; $ordering_unit = $row['ordering_unit']; $pricing_unit = $row['pricing_unit']; $storage_code = $row['storage_code']; // Figure out how to display the quantity $pricing_per_unit = ''; if ($unit_price != 0) { $pricing_per_unit = '$' . number_format($unit_price, 2) . '/' . Inflect::singularize($pricing_unit); } if ($unit_price != 0 && $extra_charge != 0) { $pricing_per_unit .= ' + '; } if ($extra_charge != 0) { $pricing_per_unit .= '$' . number_format($extra_charge, 2) . '/' . Inflect::singularize($ordering_unit); } if ($out_of_stock == 1) { $show_quantity = $quantity; $show_unit = '<img src="' . DIR_GRAPHICS . 'checkmark_wht.gif"> ' . Inflect::pluralize_if($show_quantity, $ordering_unit); $pricing_per_unit = 'N/A'; // Clobber the value } elseif ($quantity) { $show_quantity = $quantity; $show_unit = Inflect::pluralize_if($show_quantity, $ordering_unit); } elseif ($total_weight) { $show_quantity = $total_weight; $show_unit = Inflect::pluralize_if($show_quantity, $pricing_unit); } // Set up primary data structure $summary_qty[$site_id][$product_id][$member_id] = $show_quantity; // Configure delivery_type to only show when order is a delivery if ($delivery_type != 'P') { $summary_delivery_type[$member_id] = $delivery_type . '-'; // Will give something like D-BOISE-117 } else { $summary_delivery_type[$member_id] = ''; // Will give something like BOISE-117 } $summary_unit[$product_id] = $show_unit; $sordering_unit[$product_id] = $pricing_unit; $site_subtotal[$site_id][$product_id] += $show_quantity; $product_subtotal[$product_id] += $show_quantity; // Set up trivial data relationships $site_id_2_site[$site_id] = $site_long; $site_id_2_site_short[$site_id] = $site_short; $product_id_2_product_name[$product_id] = $product_name; $product_id_2_storage_code[$product_id] = $storage_code; $product_id_2_pricing_per_unit[$product_id][$member_id] = $pricing_per_unit; $member_id_2_preferred_name[$member_id] = $preferred_name; $customer_notes_2_member_product[$product_id][$member_id] = $customer_notes_to_producer; } if ($a_address_line1 && $a_address_line2) { $a_address = "{$a_address_line1}<br>\n{$a_address_line2}"; } else { $a_address = $a_address_line1 . $a_address_line2; } $producer_header = ' <table cellspacing="5"> <tr> <td colspan="2" width="95%"><h3>' . $a_business_name . '</h3></td><td><font size="+1"><strong>Order #' . $delivery_id . ' - ' . $delivery_date . '</strong></font></td> </tr> <tr> <td rowspan="4" width="35%" valign="top"> ' . $a_address . '<br> ' . $a_city . ', ' . $a_state . ' ' . $a_zip . '<br> (' . $a_county . ' County) </td> <td width="15%" align="right"> Email address: </td><td width="45%">' . $a_email_address . '</td></tr> <tr><td width="15%" align="right">Home phone: </td><td width="45%">' . $a_home_phone . '</td></tr> <tr><td width="15%" align="right">Work phone: </td><td width="45%">' . $a_work_phone . '</td></tr> <tr><td width="15%" align="right">Mobile phone: </td><td width="45%">' . $a_mobile_phone . '</td></tr> </table><br>'; if (is_array($summary_qty)) { $include_header = true; $include_footer = true; if ($detail_type == '' || $detail_type == 'customer') { $page_links = ' <a href="' . $_SERVER['SCRIPT_NAME'] . '?detail_type=product">Summary by product</a><br> <a href="' . PATH . 'product_list.php?&type=labels_bystoragecustomer">One Label per Customer/Storage</a><br> <a href="' . PATH . 'product_list.php?&type=labels_byproduct">One Label per Item</a><br> <!--<a href="' . $_SERVER['SCRIPT_NAME'] . '?detail_type=labels">Labels for this order</a><br> <a href="configure_labels.php">Configure or select label format</a><br>--><br> <h2>Summary for<br>' . $a_business_name . '</h2> '; $display_page .= ' <table border="0" cellspacing="0" width="95%"> '; foreach (array_keys($summary_qty) as $site_id) { $display_page .= ' <tr><th colspan="5"> </th></tr> <tr><th colspan="5" bgcolor="#444444"><font size="+1" color="#ffffff" align="center">' . $site_id_2_site[$site_id] . ' (' . $site_id_2_site_short[$site_id] . ')</font></td></tr> <tr><th colspan="5"> </th></tr> '; foreach (array_keys($summary_qty[$site_id]) as $product_id) { $display_page .= ' <tr><td colspan="5"><br>' . $a_business_name . ' – (#' . $product_id . ') ' . $product_id_2_product_name[$product_id] . ' [' . $product_id_2_storage_code[$product_id] . ']</td></tr> '; foreach (array_keys($summary_qty[$site_id][$product_id]) as $member_id) { $quantity = $summary_qty[$site_id][$product_id][$member_id]; $display_page .= ' <tr><td width="5%"> </td> <td width="10%">#' . $member_id . '</td> <td width="40%">' . $member_id_2_preferred_name[$member_id] . '</td> <td width="20%">' . $product_id_2_pricing_per_unit[$product_id][$member_id] . '</td> <td width="20%">(' . $quantity . ') - ' . Inflect::pluralize_if($quantity, $summary_unit[$product_id]) . '<br></td></tr>'; if ($customer_notes_2_member_product[$product_id][$member_id]) { $display_page .= ' <tr><td width="5%"> </td> <td colspan="4" width="90%"><b>Customer Notes: </b>' . $customer_notes_2_member_product[$product_id][$member_id] . '</td></tr>'; } } // Delivery Code summary $subtotal = $site_subtotal[$site_id][$product_id]; $total = $product_subtotal[$product_id]; // Product summary $display_page .= ' <tr><td width="5%"> </td> <td width="70%" colspan="3" bgcolor="#dddddd">Product quantity (' . $site_id_2_site[$site_id] . '): </td> <td width="20%" bgcolor="#dddddd">(' . $subtotal . ' of ' . $total . ') - ' . Inflect::pluralize_if($total, $summary_unit[$product_id]) . '</td></tr> '; } } // $display_page .= '<hr width="50%" style="text-align:left;margin:3em 0em 3em;">'; $display_page .= '</table>'; if ($use == 'batch') { $display_page = $producer_header . $display_page; } else { $display_page = '</font><div style="font-size:0.9em;">' . $page_links . $producer_header . $display_page . "</div>"; } } elseif ($detail_type == 'product') { $include_header = true; $include_footer = true; $page_links = ' <a href="' . $_SERVER['SCRIPT_NAME'] . '?detail_type=customer">Summary by customer</a><br> <a href="' . PATH . 'product_list.php?&type=labels_bystoragecustomer">One Label per Customer/Storage</a><br> <a href="' . PATH . 'product_list.php?&type=labels_byproduct">One Label per Item</a><br> <!--<a href="' . $_SERVER['SCRIPT_NAME'] . '?detail_type=labels">Labels for this order</a><br> <a href="configure_labels.php">Configure or select label format</a><br>--><br> <h2>Overall Product Summary for<br>' . $a_business_name . '</h2> '; foreach (array_keys($product_id_2_storage_code) as $product_id) { // Delivery Code summary $total = $product_subtotal[$product_id]; $unit = $summary_unit[$product_id]; // Product summary $display_page .= '<div style="width:40em;float:left;">' . $product_id_2_product_name[$product_id] . ' (#' . $product_id . ') [' . $product_id_2_storage_code[$product_id] . ']</div><div style="width:10em;float:left;">(' . $total . ') - ' . Inflect::pluralize_if($total, $unit) . '</div><br>'; } if ($use == 'batch') { $display_page = $producer_header . $display_page; } else { $display_page = '</font><div style="font-size:0.9em;">' . $page_links . $producer_header . $display_page . '</div>'; } } elseif ($detail_type == 'labels') { require_once "../func/label_config.class.php"; // Choose the labels that were selected from configure_labels.php $label_name = $_SESSION['label_select']; // Set up the label based on stored cookie label values $current_label = output_Label::cookieToLabel($label_name); if ($label_name) { // If a printer has been chosen, then include label styles $label_sheet_styles .= ' .container { overflow:hidden; width:100%; height:100% } ' . $current_label->getLabelCSS(); // Set up font scaling $font_scaling = $current_label->font_scaling; if (!$font_scaling) { $font_scaling = 1.0; } $font_scaling_link = ''; // Scaling is automatic, so not controls are given } else { // Otherwise include a simple spacer style between labels $label_sheet_styles .= ' .container { margin-bottom: 3em; } a { text-decoration: none; color:#880088; } a:hover { text-decoration: underline; color:#0000ff; } '; // Set up font scaling $font_scaling = $_GET['font_scaling']; if (!$font_scaling) { $font_scaling = 1.0; } if ($font_scaling < 0.3) { $font_scaling = 0.3; } if ($font_scaling > 4.0) { $font_scaling = 4.0; } // Controls for scaling the label $font_scaling_link = '<!-- A custom label-sheet is NOT selected.<br> Click <a href="configure_labels.php">here</a> to configure custom labels (i.e. Avery labels)<br> --> Change label size: [<a href="' . $_SERVER['SCRIPT_NAME'] . '?detail_type=labels&font_scaling=' . ($font_scaling - 0.1) . '">Smaller</a>] [<a href="' . $_SERVER['SCRIPT_NAME'] . '?detail_type=labels&font_scaling=' . ($font_scaling + 0.1) . '">Larger</a>] <br><br><br>'; } // Include the header and styles for this particular application $label_sheet .= ' <head> <style> .counter { float:left; font-size:' . number_format(3 * $font_scaling, 2) . 'em; font-weight:bold; } .site { font-size:' . number_format(1.2 * $font_scaling, 2) . 'em; font-weight:bold; } .customer { font-size:' . number_format(1.0 * $font_scaling, 2) . 'em; } .producer { font-size:' . number_format(1.0 * $font_scaling, 2) . 'em; } .product { font-size:' . number_format(0.9 * $font_scaling, 2) . 'em; font-style:italic; line-height:100%; } ' . $label_sheet_styles; // Close the header and open the body $label_sheet .= ' </style> </head> <body>' . $font_scaling_link; // Begin the label sheet content $label_sheet .= $current_label->beginLabelSheet(); foreach (array_keys($product_id_2_product_name) as $product_id) { foreach (array_keys($summary_qty) as $site_id) { if (is_array($summary_qty[$site_id][$product_id])) { foreach (array_keys($summary_qty[$site_id][$product_id]) as $member_id) { $quantity = $summary_qty[$site_id][$product_id][$member_id]; $delivery_type = $summary_delivery_type[$member_id]; $unit = $summary_unit[$product_id]; $label_sheet .= ' <div class="container"> <div class="site">' . $delivery_type . $site_id . '-' . $member_id . '[' . $product_id_2_storage_code[$product_id] . ']</div> <div class="customer">' . $member_id_2_preferred_name[$member_id] . '</div> <div class="producer">' . $a_business_name . '</div> <div class="product">(' . $quantity . ') - ' . Inflect::pluralize_if($quantity, $summary_unit[$product_id]) . $product_id_2_product_name[$product_id] . ' (#' . $product_id . ')</div> </div>'; $label_sheet .= $current_label->advanceLabel(); } } } } $label_sheet .= $current_label->finishLabelSheet(); // Finally, just before printing, clear the $_SESSION['label_select'] // variable so the next use of this function will require choosing a // label type again. // unset ($_SESSION['label_select']); $display_page .= $label_sheet; } } else { $include_header = true; $include_footer = true; $display_page .= "</font>"; $display_page .= '<div style="font-size:0.9em;">'; $display_page .= "<h2>No products to report</h2><br>\n"; $display_page .= '</div>'; } return $display_page; }
function show_listing_row($data, $row_type) { switch ($row_type) { // Row type case 'product_short': $row_content = ' #' . $data['product_id'] . ' - ' . $data['product_name'] . ' (' . $data['basket_quantity'] . Inflect::pluralize_if($data['basket_quantity'], $data['ordering_unit']) . ')<br>'; break; // Row type // Row type case 'member_short': $row_content = ''; break; // Row type // Row type case 'product_short_site': $row_content = ''; break; // Row type // Row type case 'product': $row_content = ''; break; // Otherwise... $row_content = ' '; break; } return $row_content; }
$content_list .= $value . ' '; $this_edit = $value; } else { $content_list .= '[<a href="producer_product_list.php?a=' . $key . '">' . $value . '</a>] '; } } $content_list .= '</h3>'; if ($show_search) { $search_display = ' <form action="' . $_SERVER['SCRIPT_NAME'] . '" method="get">' . ($_REQUEST['a'] ? '<input type="hidden" name="a" value="' . $_REQUEST['a'] . '">' : '') . '<input type="text" name="query" value="' . $search_query . '"> <input type="submit" name="type" value="search"> </form>'; } if (isset($pager['found_rows'])) { $search_display .= ' <span class="found_rows">Found ' . $pager['found_rows'] . ' ' . Inflect::pluralize_if($pager['found_rows'], 'item') . '</span>'; } $page_specific_css .= ' <link rel="stylesheet" type="text/css" href="' . PATH . 'product_list.css"> <link rel="stylesheet" type="text/css" href="basket_dropdown.css"> <style type="text/css"> #basket_dropdown { right:3%; } #content_top { margin-bottom:25px; } #simplemodal-data { height:100%; background-color:#fff;
' . TABLE_PRODUCER . '.producer_id ORDER BY ' . TABLE_PRODUCER . '.business_name'; $result = @mysql_query($query, $connection) or die(debug_print("ERROR: 897650 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__)); while ($row = mysql_fetch_array($result)) { $producer_id = $row['producer_id']; $business_name = $row['business_name']; $producttypes = $row['producttypes']; $product_count = $row['product_count']; if ($product_count > 0 || $show_all) { $show_name = ""; $row_color = $row_count % 2 ? $color1 : $color2; $display_top .= ' <tr bgcolor="' . $row_color . '"> <td width="25%"><font face="arial" size="3"><b><a href="product_list.php?type=producer_id&producer_id=' . $producer_id . '">' . $business_name . '</a></b></td> <td width="75%">' . strip_tags($producttypes) . ' (' . ($product_count > 0 ? number_format($product_count, 0) . ' ' . Inflect::pluralize_if($product_count, 'product') : 'no products currently listed') . ')</font></td> </tr>'; $row_count++; } } if ($show_all) { $content_list .= ' <font face="arial"> All producers listed below have been approved for selling by ' . SITE_NAME . ', although some may not currently have products for sale. Also available is a list of only those <a href="' . $_SERVER['SCRIPT_NAME'] . '">producers with products for sale</a>.<br><br> Not from this region? Don’t despair. Many of these producers are ready and able to ship their products to you, including frozen meats! Please contact the producers directly about the shipping policies. <br><br>'; } else { $content_list .= '
function get_baskets_list() { global $connection; // Get a list of the order cycles since the member joined $delivery_id_array = array(); $delivery_attrib = array(); $query = ' SELECT delivery_id, date_open, date_closed, order_fill_deadline, delivery_date FROM ' . TABLE_ORDER_CYCLES . ' WHERE delivery_date > "' . mysql_real_escape_string($_SESSION['renewal_info']['membership_date']) . '" AND date_open < NOW() ORDER BY delivery_date DESC'; $result = @mysql_query($query, $connection) or die(debug_print("ERROR: 898034 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__)); while ($row = mysql_fetch_array($result)) { array_push($delivery_id_array, $row['delivery_id']); $delivery_attrib[$row['delivery_id']]['date_open'] = $row['date_open']; $delivery_attrib[$row['delivery_id']]['time_open'] = strtotime($row['date_open']); $delivery_attrib[$row['delivery_id']]['date_closed'] = $row['date_closed']; $delivery_attrib[$row['delivery_id']]['time_closed'] = strtotime($row['date_closed']); $delivery_attrib[$row['delivery_id']]['order_fill_deadline'] = $row['order_fill_deadline']; $delivery_attrib[$row['delivery_id']]['delivery_date'] = $row['delivery_date']; } // Now get this customer's baskets $query = ' SELECT * FROM ' . NEW_TABLE_BASKETS . ' WHERE member_id = "' . mysql_real_escape_string($_SESSION['member_id']) . '" ORDER BY delivery_id DESC'; $result = @mysql_query($query, $connection) or die(debug_print("ERROR: 898034 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__)); while ($row = mysql_fetch_array($result)) { $delivery_attrib[$row['delivery_id']]['basket_id'] = $row['basket_id']; $delivery_attrib[$row['delivery_id']]['site_id'] = $row['site_id']; $delivery_attrib[$row['delivery_id']]['delivery_type'] = $row['delivery_type']; $delivery_attrib[$row['delivery_id']]['checked_out'] = $row['checked_out']; } // Display the order cycles and baskets... $display .= ' <div id="basket_dropdown" class="dropdown"> <a href="' . $_SERVER['SCRIPT_NAME'] . '?action=basket_list_only"><h1 class="basket_history"> Ordering History </h1></a> <div id="basket_history"> <ul class="basket_history">'; foreach ($delivery_id_array as $delivery_id) { $full_empty = ''; $open_closed = ''; $future_past = ''; // Check if basket for the delivery had any items... if ($delivery_attrib[$delivery_id]['checked_out'] != 0) { $fe = 'f'; // full $full_empty = 'full'; } else { $fe = 'e'; // empty $full_empty = 'empty'; } // Check if this basket is currently open... if ($delivery_attrib[$delivery_id]['time_open'] < time() && $delivery_attrib[$delivery_id]['time_closed'] > time()) { $cg = 'c'; // colored $current = true; // Start the after_current counter $open_closed = 'open'; $after_current_count = 1; } else { $cg = 'g'; // grey $open_closed = 'closed'; } // Check if this is a future delivery... if ($delivery_attrib[$delivery_id]['time_open'] > time()) { $is = 'i'; // insubstantial $cg = 'c'; // colored $current = false; $after_current_count++; $future_past = 'future'; } else { $is = 's'; // substantial $future_past = 'past'; } $day_open = date('j', $delivery_attrib[$delivery_id]['time_open']); $month_open = date('M', $delivery_attrib[$delivery_id]['time_open']); $year_open = date('Y', $delivery_attrib[$delivery_id]['time_open']); $day_closed = date('j', $delivery_attrib[$delivery_id]['time_closed']); $month_closed = date('M', $delivery_attrib[$delivery_id]['time_closed']); $year_closed = date('Y', $delivery_attrib[$delivery_id]['time_closed']); if ($day_open == $day_closed) { $day_open = ''; } if ($month_open == $month_closed) { $month_closed = ''; } if ($year_open == $year_closed) { $year_open = ''; } $items_in_basket = abs($delivery_attrib[$delivery_id]['checked_out']); $current_link = ''; // Process basket quantity display if ($future_past != 'future') { if ($items_in_basket) { $basket_quantity_text = '[' . $items_in_basket . ' ' . Inflect::pluralize_if($items_in_basket, 'item') . ']'; $current_link = 'View <a href="product_list.php?type=basket&delivery_id=' . $delivery_id . '">Basket</a> / <a href="show_report.php?type=customer_invoice&delivery_id=' . $delivery_id . '">Invoice</a>'; } else { $basket_quantity_text = '[Empty]'; } } // Current order... set link for opening or checking basket if ($open_closed == 'open') { // Basket does not exist? if (!$delivery_attrib[$delivery_id]['basket_id']) { $current_link = ' <!-- <a href="">Start an Order</a> -->'; } else { $current_link = 'View... <a href="product_list.php?type=basket&delivery_id=' . $delivery_id . '">Basket</a>'; } $basket_quantity_text = ''; } if ($after_current_count <= 2) { // Need some onclick code for class=view (full baskets) $display .= ' <li class="' . $fe . $cg . $is . ($full_empty == 'full' || $current == 'true' ? ' view' : '') . '"' . ($open_closed == 'open' ? ' id="current"' : '') . '> <span class="delivery_date">Delivery: ' . date('M j, Y', strtotime($delivery_attrib[$delivery_id]['delivery_date'])) . '</span>' . (CurrentBasket::basket_id() && $current == 'true' ? ' <span class="basket_link"><a href="product_list.php?type=basket&delivery_id=' . $delivery_id . '">Basket</a></span> • <!-- <span class="accounting_link"><a href="member_view_balance.php?account_type=member&delivery_id=' . $delivery_id . '">Account</a></span> • --> <span class="accounting_link"><a href="show_report.php?type=customer_invoice&delivery_id=' . $delivery_id . '&member_id=' . $_SESSION['member_id'] . '">Invoice</a></span>' : '') . ' <span class="order_dates">' . $month_open . ' ' . $day_open . ' ' . $year_open . ' – ' . $month_closed . ' ' . $day_closed . ' ' . $year_closed . '</span> <span class="basket_qty">' . $basket_quantity_text . '</span> <span class="basket_action">' . $current_link . '</span> </li>'; } } $display .= ' </ul> </div> </div>'; return $display; }
function show_product_row(&$product, &$unique) { $this_row = $product['this_row']; $display_line = ''; // Capture producer product costs if ($product[$this_row]['text_key'] == 'quantity cost' || $product[$this_row]['text_key'] == 'weight cost' || $product[$this_row]['text_key'] == 'extra charge') { $unique['total_bpid_amount'] += $product[$this_row]['amount']; $unique['total_product_amount'] += $product[$this_row]['amount']; $unique['total_order_amount'] += $product[$this_row]['amount']; } else { $unique['total_bpid_fee'] += $product[$this_row]['amount']; $unique['total_product_fee'] += $product[$this_row]['amount']; $unique['total_order_fee'] += $product[$this_row]['amount']; } // Aggregate customer fee over whole order if ($product[$this_row]['text_key'] == 'customer fee') { $unique['total_order_customer_fee'] += $product[$this_row]['amount']; } // Aggregate tax over whole order if (!strpos($product[$this_row]['text_key'], 'tax') === false) { $unique['total_order_tax'] += $product[$this_row]['amount']; $product['total_product_tax'] += $product[$this_row]['amount']; } // If the product will be different on the next go-around // or if this is the last row, then show product details if ($product[$this_row + 1]['bpid'] != $product[$this_row]['bpid'] || $product['this_row'] == $product['number_of_rows']) { $display_line = ' <tr align="center"> <td width="40" align="right" valign="top" style="text-align:right;">' . ($unique['view'] == 'editable' ? '<img src="' . DIR_GRAPHICS . 'edit_icon.png" onclick="popup_src(\'adjust_ledger.php?type=product&target=' . $product[$this_row]['bpid'] . '\', \'adjust_ledger\', \'\');">' : '') . '</td> <td width="50" align="right" valign="top" style="text-align:right;">' . $product[$this_row]['member_id'] . ' </td> <td align="left" valign="top">' . $product[$this_row]['preferred_name'] . '</td> <td align="center" valign="top">' . ($product[$this_row]['out_of_stock'] != 0 ? $product[$this_row]['basket_quantity'] - $product[$this_row]['out_of_stock'] . ' of ' : '') . $product[$this_row]['basket_quantity'] . ' ' . Inflect::pluralize_if($product[$this_row]['basket_quantity'], $product[$this_row]['ordering_unit']) . '</td> <td align="center" valign="top">' . ($product[$this_row]['random_weight'] ? $product[$this_row]['total_weight'] ? $product[$this_row]['total_weight'] . ' ' . Inflect::pluralize_if($product[$this_row]['total_weight'], $product[$this_row]['pricing_unit']) : '(wt. pending)' : '') . '</td> <td width="13" align="right" valign="top" style="text-align:right;">' . number_format($unique['total_bpid_amount'], 2) . '</td> <td align="center" valign="top"></td> </tr>'; // Reset totals for this row (bpid) $unique['total_bpid_amount'] = 0; $unique['total_bpid_fee'] = 0; $unique['product_count']++; } return $display_line; }
function show_product_row(&$product, &$unique) { $this_row = $product['this_row']; $display_line = ''; // Check if this is an adjusted quantity if ($product[$this_row]['adjustment_group_memo'] != "") { $adjustment_class = ' adjusted'; // Use an associative key...[$product[$this_row]['adjustment_group_memo']]...to prevent repeating memos $unique['adjustment_markup'][$product[$this_row]['adjustment_group_memo']] = ' <tr align="center" class="' . $adjustment_class . '"> <td colspan="2"></td> <td colspan="5" align="left" class="adjustment">Adjustment: ' . $product[$this_row]['adjustment_group_memo'] . '</td> </tr>'; } // Aggregate the total order cost over the whole order $unique['total_order_amount'] += $product[$this_row]['amount']; if ($unique['invoice_price'] == 1) { $product['total_product_amount'] += $product[$this_row]['amount']; } elseif ($product[$this_row]['text_key'] != 'customer fee') { $product['total_product_amount'] += $product[$this_row]['amount']; } // Aggregate customer fee over whole order if ($product[$this_row]['text_key'] == 'customer fee') { $unique['total_order_customer_fee'] += $product[$this_row]['amount']; } // Aggregate tax over whole order if (!strpos($product[$this_row]['text_key'], 'tax') === false) { $unique['total_order_tax'] += $product[$this_row]['amount']; $product['total_product_tax'] += $product[$this_row]['amount']; } // If the product will be different on the next go-around // or if this is the last row, then show product details if ($product[$this_row + 1]['product_id'] != $product[$this_row]['product_id'] || $product['this_row'] == $product['number_of_rows']) { $tax_display = $product[$this_row]['taxable'] == 1 ? '* ' : ''; $display_line = ' <tr align="center" class="' . $adjustment_class . '"> <td width="40" align="right" valign="top">' . ($unique['view'] == 'editable' ? '<img src="' . DIR_GRAPHICS . 'edit_icon.png" onclick="popup_src(\'adjust_ledger.php?type=product&target=' . $product[$this_row]['bpid'] . '\', \'edit_transaction\', \'\');">' : '') . '</td> <td width="50" align="right" valign="top">' . $product[$this_row]['product_id'] . ' </td> <td align="left" valign="top">' . $product[$this_row]['product_name'] . ($product[$this_row]['customer_message'] != '' ? '<br /> <font color="#6666aa" face="arial" size="-1"><b>Customer Note: </b>' . $product[$this_row]['customer_message'] . '</font>' : '') . '</td> <td align="center" valign="top">' . $product[$this_row]['pricing_display'] . '</td> <td align="center" valign="top">' . ($product[$this_row]['out_of_stock'] != 0 ? $product[$this_row]['basket_quantity'] - $product[$this_row]['out_of_stock'] . ' of ' : '') . $product[$this_row]['basket_quantity'] . ' ' . Inflect::pluralize_if($product[$this_row]['basket_quantity'], $product[$this_row]['ordering_unit']) . '</td> <td align="center" valign="top">' . ($product[$this_row]['random_weight'] ? $product[$this_row]['total_weight'] ? $product[$this_row]['total_weight'] . ' ' . Inflect::pluralize_if($product[$this_row]['total_weight'], $product[$this_row]['pricing_unit']) : '(wt. pending)' : '') . '</td> <td width="13" align="right" valign="top" style="text-align:right;"><b>' . $tax_display . '$' . number_format($product['total_product_amount'] - $product['total_product_tax'], 2) . '</b></td> </tr>' . (count($unique['adjustment_markup']) > 0 ? implode('', $unique['adjustment_markup']) : ''); // Set product aggregations to zero unset($unique['adjustment_markup']); $product['total_product_amount'] = 0; $product['total_product_tax'] = 0; } return $display_line; }
$result = @mysql_query($query, $connection) or die(debug_print("ERROR: 730302 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__)); while ($row = mysql_fetch_object($result)) { if ($row->site_id != $site_id_prior) { $output .= ' </pre>' . ($_GET['paginate'] == 'true' ? '<!-- NEW SHEET -->' : '') . ' <h3>' . $row->site_long . ' [' . $row->site_short . ']</h3> <pre> (MEMBR) ROUTE CODE - NAME PROD_ID CHK STOR DESCRIPTION QUANTITY ___________________________________________________________________________________________________'; } $route_code = convert_route_code((array) $row); if ($row->member_id != $member_id_prior || $row->site_id != $site_id_prior) { $output .= "\n\n " . str_pad('(' . $row->member_id . ')', 6, ' ', STR_PAD_LEFT) . ' ' . $route_code . ' - ' . $row->first_name . ' ' . $row->last_name . "\n " . str_pad($row->product_id, 7, ' ', STR_PAD_LEFT) . ' ' . $checkbox . ' ' . str_pad($row->storage_code, 6) . str_pad(substr($row->product_name, 0, 40), 40) . ' ' . '(' . $row->quantity . ') - ' . Inflect::pluralize_if($row->quantity, $row->ordering_unit); } else { $output .= "\n " . str_pad($row->product_id, 7, ' ', STR_PAD_LEFT) . ' ' . $checkbox . ' ' . str_pad($row->storage_code, 6) . str_pad(substr($row->product_name, 0, 40), 40) . ' ' . '(' . $row->quantity . ') - ' . Inflect::pluralize_if($row->quantity, $row->ordering_unit); } // $output .= ' // // <tr> // <td width="7%">'.$row->storage_code.'</td> // <td width="75%">('.$row->member_id.') ['.$row->product_id.'] '.$row->product_name.'</td> // <td width="18%">('.$row->quantity.') - '.Inflect::pluralize_if ($row->product_quantity, $row->ordering_unit).'</td> // </tr>'; $site_id_prior = $row->site_id; $storage_code_prior = $row->storage_code; $member_id_prior = $row->member_id; } $output .= ' </pre>'; }
LEFT JOIN ' . NEW_TABLE_PRODUCTS . ' USING(product_id,product_version) LEFT JOIN ' . NEW_TABLE_BASKETS . ' USING(basket_id) WHERE ' . NEW_TABLE_BASKETS . '.delivery_id = "' . mysql_real_escape_string($_REQUEST['delivery_id']) . '" AND producer_id = "' . mysql_real_escape_string($row["producer_id"]) . '" AND out_of_stock != quantity AND random_weight = 1 AND total_weight = 0'; $result_weight = @mysql_query($query_weight, $connection) or die(debug_print("ERROR: 860323 ", array($query_weight, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__)); $unfilled_random_weights = 0; if ($row_weight = mysql_fetch_array($result_weight)) { $unfilled_random_weights = $row_weight['count']; } if ($unfilled_random_weights) { $display .= ' [waiting on ' . $unfilled_random_weights . ' ' . Inflect::pluralize_if($unfilled_random_weights, 'weight') . ']'; } $display .= ' </td> </tr>'; $i++; } $query = ' SELECT delivery_id, delivery_date FROM ' . TABLE_ORDER_CYCLES . ' WHERE delivery_id = "' . mysql_real_escape_string($_REQUEST['delivery_id']) . '"'; $result = @mysql_query($query, $connection) or die(debug_print("ERROR: 906324 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));