class BackordersListsController < CommLogistics::Base::Controller::ListController
  #
  # バックオーダー
  # 
  def get_record_list
    @control_keys = 'backorders_lists'
    
    ss = BackordersSearch.new
    ss.date_table = 'b'
    ss.table_alias = {'shipping_details' => 'a',
                      'shippings' => 'b'}
    join_mcls = [{:tab => 'shippings',
                  :cols => Shipping.column_names}]
    ars = ss.search(FLAG_ON, ShippingDetail, join_mcls, params, MFIND_V)
    return ars
  end
  
  class BackordersSearch < Comm::Tool::SqlSearch
    def get_columns_and_tables(tab, join_lists, params, str_vals)
      str_cols = ' a.shipping_id,
                   a.id,
                   b.warehouse_id,
                   b.customer_id,
                   b.supplier_id,
                   b.user_position_id,
                   b.sales_area_id,
                   a.product_category_id,
                   a.product_set_id,
                   a.product_id,
                   a.quantity,
                   b.shipping_type_code,
                   b.input_date '
      str_tab =  ' FROM shipping_details as a LEFT JOIN shippings AS b ON a.shipping_id=b.id '
      return str_cols, str_tab, str_vals
    end
    def set_additional_where(str_where, params)
      add_str_where(str_where, " b.shipping_state_code=#{MCODE_SHIPPING_STATE_BO}")
    end
  end
end