Ejemplo n.º 1
0
 private static function get_delivery_info($target_delivery_id)
 {
     if (self::$active_cycle_query_complete === false || self::$delivery_id != $target_delivery_id) {
         global $connection;
         // Set up for pulling only order cycles appropriate to the current customer_type permissions
         // Allow "orderex" direct access to all order cycles
         $customer_type_query = CurrentMember::auth_type('orderex') ? '1' : '0';
         if (CurrentMember::auth_type('member')) {
             $customer_type_query .= '
           OR customer_type LIKE "%member%"';
         }
         if (CurrentMember::auth_type('institution')) {
             $customer_type_query .= '
           OR customer_type LIKE "%institution%"';
         }
         if ($target_delivery_id == '') {
             $query_where = '
             date_open < "' . date('Y-m-d H:i:s', time()) . '"
             AND (' . $customer_type_query . ')';
         } else {
             $query_where = '
             delivery_id = "' . mysql_real_escape_string($target_delivery_id) . '"';
         }
         // Get information about any shopping period that is currently open
         $query = '
           SELECT
             delivery_id,
             delivery_date,
             date_open,
             date_closed,
             order_fill_deadline,
             producer_markdown / 100 AS producer_markdown,
             retail_markup / 100 AS retail_markup,
             wholesale_markup / 100 AS wholesale_markup
           FROM
             ' . TABLE_ORDER_CYCLES . '
           WHERE' . $query_where . '
             /* AND order_fill_deadline > "' . date('Y-m-d H:i:s', time()) . '" */
           ORDER BY
             delivery_id DESC
           LIMIT
             1';
         $result = @mysql_query($query, $connection) or die(debug_print("ERROR: 730099 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
         // Set default values in case we returned nothing
         self::$delivery_id = 1;
         if ($row = mysql_fetch_object($result)) {
             self::$delivery_id = $row->delivery_id;
             self::$delivery_date = $row->delivery_date;
             self::$date_open = $row->date_open;
             self::$date_closed = $row->date_closed;
             self::$order_fill_deadline = $row->order_fill_deadline;
             self::$producer_markdown = $row->producer_markdown;
             self::$retail_markup = $row->retail_markup;
             self::$wholesale_markup = $row->wholesale_markup;
             if (time() > strtotime($row->date_open) && time() < strtotime($row->date_closed)) {
                 self::$ordering_window = 'open';
             } else {
                 self::$ordering_window = 'closed';
             }
             if (time() > strtotime($row->date_closed) && time() < strtotime($row->order_fill_deadline)) {
                 self::$producer_update_window = 'open';
             } else {
                 self::$producer_update_window = 'closed';
             }
             self::$active_cycle_query_complete = true;
         } elseif ($target_delivery_id != 0) {
             self::$delivery_id = $target_delivery_id;
             self::$delivery_date = '';
             self::$date_open = '';
             self::$date_closed = '';
             self::$order_fill_deadline = '';
             self::$producer_markdown = 0;
             self::$retail_markup = 0;
             self::$wholesale_markup = 0;
             self::$active_cycle_query_complete = true;
         }
     }
 }