wb = xlsx_package.workbook
wb.styles do |s|
    time_format = wb.styles.add_style :format_code => 'hh:mm:ss'

    wrap_text = s.add_style :sz => 11,
                            :alignment =>  { :horizontal => :left,:vertical => :center ,
                            :wrap_text => true}
    header_text = s.add_style :fg_color=> "FFFFFF",
                            :b => true,
                            :bg_color => "004586",
                            :sz => 12,
                            :border => { :style => :thin, :color => "00" },
                            :alignment => { :horizontal => :left,
                                            :vertical => :center ,
                                            :header_text => true}
    wb.add_worksheet(name: "Account") do |sheet|
	  sheet.add_row %w(id title account_type discount point bonus rebate), :style=>header_text
	  Account.all.each do |acc|
	    sheet.add_row [acc.id, acc.title,acc.account_type,acc.discount,acc.point,acc.bonus,acc.rebate], :style=>wrap_text
	  end
	end

	wb.add_worksheet(name: "Item Set") do |sheet|
	  sheet.add_row %w(id name alt_name min_selectable_qty max_selectable_qty), :style=>header_text
	  ItemSet.all.each do |set|
	    sheet.add_row [set.id,set.name, set.alt_name, set.min_selectable_qty, set.max_selectable_qty], :style=>wrap_text
	  end
	end

	wb.add_worksheet(name: "Menu Item Options") do |sheet|
	  sheet.add_row %w(id option_type name value), :style=>header_text
	  MenuItemOption.all.each do |option|
	    sheet.add_row [option.id, option.option_type, option.name, option.value], :style=>wrap_text
	  end
	end

	wb.add_worksheet(name: "Menu Item Attributes") do |sheet|
	  sheet.add_row %w(id attribute_type name value), :style=>header_text
	  MenuItemAttribute.all.each do |attr|
	    sheet.add_row [attr.id, attr.attribute_type,attr.name,attr.value], :style=>wrap_text
	  end
	end

	wb.add_worksheet(name: "Menu") do |sheet|
	  sheet.add_row %w( id name is_active valid_days valid_time_from valid_time_to created_by ), :style=>header_text
	  @settings_menus.each do |menu|
	    sheet.add_row [ menu.id, menu.name, menu.is_active, menu.valid_days, menu.valid_time_from,menu.valid_time_to, menu.created_by], :style=>[wrap_text,time_format]
	  end
	end

	wb.add_worksheet(name: "Menu Category") do |sheet|
	  sheet.add_row %w(id menu_id code name alt_name order_by created_by menu_category_id is_available), :style=>header_text
	  MenuCategory.all.each do |mc|
	    sheet.add_row [mc.id, mc.menu_id, mc.code, mc.name, mc.alt_name, mc.order_by, mc.created_by, mc.menu_category_id, mc.is_available], :style=>wrap_text
	  end
	end

	wb.add_worksheet(name: "Menu Item") do |sheet|
	  sheet.add_row %w(id item_code name alt_name image_path description information unit type menu_category_id item_attributes item_options account_id min_qty taxable is_sub_item is_available created_by), :style=>header_text
	  MenuItem.all.each do |mi|
	    sheet.add_row [mi.id,mi.item_code, mi.name, mi.alt_name, mi.image_path, mi.description, mi.information, mi.unit, mi.type, mi.menu_category_id, mi.item_attributes, mi.item_options, mi.account_id, mi.min_qty, mi.taxable, mi.is_sub_item, mi.is_available, mi.created_by], :style=>wrap_text
	  end
	end

	wb.add_worksheet(name: "Menu Item Instance") do |sheet|
	  sheet.add_row %w(id menu_item_id item_instance_code item_instance_name item_attributes price is_on_promotion promotion_price is_available is_default), :style=>header_text
	  MenuItemInstance.all.each do |mii|
	    sheet.add_row [mii.id, mii.menu_item_id, mii.item_instance_code, mii.item_instance_name, mii.item_attributes, mii.price, mii.is_on_promotion, mii.promotion_price, mii.is_available, mii.is_default], :style=>wrap_text
	  end
	end

	wb.add_worksheet(name: "Menu Instance Item Set") do |sheet|
	  sheet.add_row %w(id item_set_id menu_item_instance_id), :style=>header_text
	  MenuInstanceItemSet.all.each do |miis|
	    sheet.add_row [miis.id ,miis.item_set_id, miis.menu_item_instance_id], :style=>wrap_text
	  end
	end

	wb.add_worksheet(name: "Menu Item Set") do |sheet|
	  sheet.add_row %w(id item_set_id menu_item_id), :style=>header_text
	  MenuItemSet.all.each do |mis|
	    sheet.add_row [mis.id,mis.item_set_id, mis.menu_item_id], :style=>wrap_text
	  end
	end 

end
