From e4abdbad427eaa56525c26b00a9a532d5022e525 Mon Sep 17 00:00:00 2001 From: tmatsuzawa Date: Mon, 14 Dec 2009 02:34:53 +0000 Subject: [PATCH] Init Project git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/elecoma/trunk@1 06daa6dd-5c14-464e-8a85-0d68c524be32 --- COPYRIGHT | 45 + README | 386 ++ Rakefile | 10 + app/controllers/accounts_controller.rb | 525 +++ app/controllers/admin/accounts_controller.rb | 46 + app/controllers/admin/admin_users_controller.rb | 36 + app/controllers/admin/authorities_controller.rb | 66 + app/controllers/admin/base_controller.rb | 164 + app/controllers/admin/campaigns_controller.rb | 131 + app/controllers/admin/categories_controller.rb | 50 + app/controllers/admin/customers_controller.rb | 97 + app/controllers/admin/designs_controller.rb | 41 + .../admin/feature_products_controller.rb | 97 + app/controllers/admin/features_controller.rb | 59 + app/controllers/admin/home_controller.rb | 48 + .../admin/mail_magazine_templates_controller.rb | 25 + app/controllers/admin/mail_magazines_controller.rb | 268 ++ app/controllers/admin/mail_template_controller.rb | 2 + app/controllers/admin/mobile_devices_controller.rb | 66 + .../admin/new_informations_controller.rb | 58 + app/controllers/admin/order_statuses_controller.rb | 84 + app/controllers/admin/orders_controller.rb | 159 + app/controllers/admin/payment_controller.rb | 2 + app/controllers/admin/product_styles_controller.rb | 119 + app/controllers/admin/products_controller.rb | 223 + app/controllers/admin/questionnaires_controller.rb | 99 + .../admin/recommend_products_controller.rb | 51 + app/controllers/admin/shops_controller.rb | 451 ++ app/controllers/admin/status_controller.rb | 2 + .../admin/style_categories_controller.rb | 38 + app/controllers/admin/styles_controller.rb | 35 + app/controllers/admin/totals_controller.rb | 57 + app/controllers/application_controller.rb | 34 + app/controllers/base_controller.rb | 182 + app/controllers/campaigns_controller.rb | 85 + app/controllers/cart_controller.rb | 649 +++ app/controllers/features_controller.rb | 25 + app/controllers/image_resource_controller.rb | 66 + app/controllers/inquiries_controller.rb | 73 + app/controllers/portal_controller.rb | 103 + app/controllers/products_controller.rb | 108 + app/controllers/questionnaires_controller.rb | 149 + app/controllers/recommend_controller.rb | 27 + app/controllers/shop_controller.rb | 9 + app/helpers/accounts_helper.rb | 2 + app/helpers/admin/account_helper.rb | 2 + app/helpers/admin/admin_user_helper.rb | 2 + app/helpers/admin/authorities_helper.rb | 19 + app/helpers/admin/base_helper.rb | 7 + app/helpers/admin/campaigns_helper.rb | 15 + app/helpers/admin/categories_helper.rb | 33 + app/helpers/admin/customers_helper.rb | 17 + app/helpers/admin/design_helper.rb | 2 + app/helpers/admin/feature_products_helper.rb | 2 + app/helpers/admin/features_helper.rb | 2 + app/helpers/admin/home_helper.rb | 21 + app/helpers/admin/kiyaku_helper.rb | 2 + app/helpers/admin/mail_magazine_helper.rb | 126 + app/helpers/admin/mail_magazine_template_helper.rb | 2 + app/helpers/admin/mail_template_helper.rb | 2 + app/helpers/admin/mobile_device_helper.rb | 2 + app/helpers/admin/new_informations_helper.rb | 9 + app/helpers/admin/order_helper.rb | 2 + app/helpers/admin/order_status_helper.rb | 2 + app/helpers/admin/order_statuses_helper.rb | 2 + app/helpers/admin/payment_helper.rb | 2 + app/helpers/admin/product_helper.rb | 2 + app/helpers/admin/product_styles_helper.rb | 2 + app/helpers/admin/questionnaires_helper.rb | 2 + app/helpers/admin/recommend_products_helper.rb | 2 + app/helpers/admin/shops_helper.rb | 2 + app/helpers/admin/style_category_helper.rb | 2 + app/helpers/admin/style_helper.rb | 2 + app/helpers/admin/total_helper.rb | 2 + app/helpers/application_helper.rb | 176 + app/helpers/base_helper.rb | 483 +++ app/helpers/campaign_entry_helper.rb | 2 + app/helpers/campaigns_helper.rb | 2 + app/helpers/cart_helper.rb | 185 + app/helpers/features_helper.rb | 2 + app/helpers/image_resource_helper.rb | 2 + app/helpers/inquiries_helper.rb | 2 + app/helpers/portal_helper.rb | 2 + app/helpers/product_helper.rb | 52 + app/helpers/questionnaire_helper.rb | 2 + app/helpers/recommend_helper.rb | 2 + app/helpers/shop_helper.rb | 2 + app/helpers/user_helper.rb | 2 + app/models/admin_user.rb | 125 + app/models/authorities_function.rb | 2 + app/models/authority.rb | 30 + app/models/campaign.rb | 184 + app/models/cart.rb | 52 + app/models/cart_add_product_form.rb | 6 + app/models/category.rb | 134 + app/models/constant.rb | 23 + app/models/customer.rb | 501 +++ app/models/customer_search_form.rb | 328 ++ app/models/delivery_address.rb | 49 + app/models/delivery_date.rb | 5 + app/models/delivery_fee.rb | 18 + app/models/delivery_ticket.rb | 7 + app/models/delivery_time.rb | 8 + app/models/delivery_trader.rb | 30 + app/models/design.rb | 3 + app/models/design_form.rb | 3 + app/models/feature.rb | 48 + app/models/feature_product.rb | 40 + app/models/function.rb | 3 + app/models/image_resource.rb | 77 + app/models/inquiry.rb | 54 + app/models/kiyaku.rb | 9 + app/models/law.rb | 47 + app/models/mail.rb | 2 + app/models/mail_magazine.rb | 214 + app/models/mail_magazine_contents_form.rb | 9 + app/models/mail_magazine_search_form.rb | 11 + app/models/mail_magazine_template.rb | 15 + app/models/mail_template.rb | 8 + app/models/mobile_carrier.rb | 3 + app/models/mobile_device.rb | 48 + app/models/mobile_html_notifier.rb | 85 + app/models/new_information.rb | 14 + app/models/notifier.rb | 205 + app/models/occupation.rb | 5 + app/models/order.rb | 147 + app/models/order_delivery.rb | 488 +++ app/models/order_detail.rb | 45 + app/models/payment.rb | 49 + app/models/prefecture.rb | 5 + app/models/privacy.rb | 2 + app/models/product.rb | 556 +++ app/models/product_access_log.rb | 38 + app/models/product_status.rb | 6 + app/models/product_style.rb | 94 + app/models/question.rb | 24 + app/models/question_answer.rb | 21 + app/models/question_choice.rb | 15 + app/models/questionnaire.rb | 112 + app/models/questionnaire_answer.rb | 51 + app/models/recommend.rb | 75 + app/models/recommend_product.rb | 18 + app/models/recommend_xml.rb | 6 + app/models/resource_data.rb | 2 + app/models/search_form.rb | 180 + app/models/seo.rb | 15 + app/models/session.rb | 6 + app/models/shop.rb | 85 + app/models/status.rb | 5 + app/models/style.rb | 28 + app/models/style_category.rb | 16 + app/models/sub_product.rb | 30 + app/models/system.rb | 15 + app/models/zip.rb | 105 + app/views/accounts/_confirm.html.erb | 62 + app/views/accounts/_confirm_mobile.html.erb | 33 + app/views/accounts/_delivery_form.html.erb | 42 + app/views/accounts/_delivery_form_0.html.erb | 17 + app/views/accounts/_delivery_form_1.html.erb | 27 + app/views/accounts/_footer_mobile.html.erb | 4 + app/views/accounts/_form.html.erb | 105 + app/views/accounts/_form_mobile.html.erb | 54 + app/views/accounts/_form_mobile_0.html.erb | 30 + app/views/accounts/_form_mobile_1.html.erb | 37 + app/views/accounts/_form_mobile_2.html.erb | 49 + app/views/accounts/_mobile_domain_mobile.html.erb | 11 + app/views/accounts/activate.html.erb | 18 + app/views/accounts/activate_mobile.html.erb | 10 + app/views/accounts/close_popup.html.erb | 5 + app/views/accounts/delivery_confirm.html.erb | 57 + .../accounts/delivery_confirm_mobile.html.erb | 33 + app/views/accounts/delivery_confirm_popup.html.erb | 1 + app/views/accounts/delivery_edit.html.erb | 24 + app/views/accounts/delivery_edit_mobile.html.erb | 10 + app/views/accounts/delivery_edit_popup.html.erb | 1 + app/views/accounts/delivery_list.html.erb | 47 + app/views/accounts/delivery_list_mobile.html.erb | 28 + app/views/accounts/delivery_new.html.erb | 26 + app/views/accounts/delivery_new_mobile.html.erb | 10 + app/views/accounts/delivery_new_popup.html.erb | 1 + app/views/accounts/edit.html.erb | 21 + app/views/accounts/edit_complete.html.erb | 20 + app/views/accounts/edit_complete_mobile.html.erb | 5 + app/views/accounts/edit_confirm.html.erb | 36 + app/views/accounts/edit_confirm_mobile.html.erb | 22 + app/views/accounts/edit_mobile.html.erb | 11 + app/views/accounts/history_list.html.erb | 44 + app/views/accounts/history_list_mobile.html.erb | 23 + app/views/accounts/history_show.html.erb | 133 + app/views/accounts/history_show_mobile.html.erb | 44 + app/views/accounts/kiyaku.html.erb | 22 + app/views/accounts/kiyaku_intro_mobile.html.erb | 10 + app/views/accounts/kiyaku_mobile.html.erb | 21 + app/views/accounts/login.html.erb | 37 + app/views/accounts/login_mobile.html.erb | 13 + app/views/accounts/logout.html.erb | 2 + app/views/accounts/myindex_mobile.html.erb | 11 + app/views/accounts/regmailst_mobile_au.html.erb | 13 + .../accounts/regmailst_mobile_docomo.html.erb | 13 + .../accounts/regmailst_mobile_softbank.html.erb | 14 + app/views/accounts/reminder.html.erb | 17 + app/views/accounts/reminder_complete.html.erb | 12 + .../accounts/reminder_complete_mobile.html.erb | 13 + app/views/accounts/reminder_hint.html.erb | 20 + app/views/accounts/reminder_hint_mobile.html.erb | 18 + app/views/accounts/reminder_mobile.html.erb | 17 + app/views/accounts/salvage.html.erb | 36 + app/views/accounts/salvage_complete.html.erb | 15 + .../accounts/salvage_complete_mobile.html.erb | 6 + app/views/accounts/salvage_mobile.html.erb | 28 + app/views/accounts/signup.html.erb | 20 + app/views/accounts/signup_complete.html.erb | 15 + app/views/accounts/signup_complete_mobile.html.erb | 9 + app/views/accounts/signup_confirm.html.erb | 25 + app/views/accounts/signup_confirm_mobile.html.erb | 27 + app/views/accounts/signup_mobile.html.erb | 17 + app/views/accounts/withdraw.html.erb | 21 + app/views/accounts/withdraw_complete.html.erb | 19 + .../accounts/withdraw_complete_mobile.html.erb | 7 + app/views/accounts/withdraw_confirm.html.erb | 21 + .../accounts/withdraw_confirm_mobile.html.erb | 11 + app/views/accounts/withdraw_mobile.html.erb | 9 + app/views/admin/accounts/login.html.erb | 42 + app/views/admin/accounts/logout.html.erb | 2 + app/views/admin/admin_users/_form.html.erb | 44 + app/views/admin/admin_users/_submenu.html.erb | 1 + app/views/admin/admin_users/edit.html.erb | 11 + app/views/admin/admin_users/index.html.erb | 49 + app/views/admin/admin_users/new.html.erb | 11 + app/views/admin/authorities/_form.html.erb | 39 + app/views/admin/authorities/_submenu.html.erb | 1 + app/views/admin/authorities/edit.html.erb | 10 + app/views/admin/authorities/index.html.erb | 39 + app/views/admin/authorities/new.html.erb | 10 + app/views/admin/base/_form.rhtml | 53 + app/views/admin/base/_product_submenu.html.erb | 45 + app/views/admin/base/_search.rhtml | 43 + app/views/admin/base/_shop_submenu.html.erb | 44 + app/views/admin/base/confirm.rhtml | 56 + app/views/admin/base/edit.rhtml | 6 + app/views/admin/base/list.rhtml | 42 + app/views/admin/base/new.rhtml | 4 + app/views/admin/campaigns/_form.html.erb | 67 + app/views/admin/campaigns/_submenu.html.erb | 1 + app/views/admin/campaigns/campaign_design.html.erb | 36 + app/views/admin/campaigns/edit.html.erb | 8 + app/views/admin/campaigns/index.html.erb | 53 + app/views/admin/campaigns/new.html.erb | 8 + app/views/admin/categories/_form.html.erb | 26 + app/views/admin/categories/_submenu.html.erb | 1 + app/views/admin/categories/index.html.erb | 40 + app/views/admin/customers/_form.html.erb | 140 + app/views/admin/customers/_search.html.erb | 91 + app/views/admin/customers/_submenu.html.erb | 1 + app/views/admin/customers/confirm.html.erb | 28 + app/views/admin/customers/edit.html.erb | 38 + app/views/admin/customers/index.html.erb | 26 + app/views/admin/customers/search.html.erb | 85 + app/views/admin/designs/_submenu.html.erb | 1 + app/views/admin/designs/mobile.html.erb | 21 + app/views/admin/designs/pc.html.erb | 26 + app/views/admin/feature_products/_form.html.erb | 36 + app/views/admin/feature_products/_submenu.html.erb | 1 + app/views/admin/feature_products/confirm.html.erb | 35 + app/views/admin/feature_products/edit.html.erb | 23 + app/views/admin/feature_products/index.html.erb | 40 + app/views/admin/feature_products/new.html.erb | 24 + .../admin/feature_products/product_search.html.erb | 69 + app/views/admin/features/_form.html.erb | 31 + .../admin/features/_select_type_form.html.erb | 19 + app/views/admin/features/_submenu.html.erb | 1 + app/views/admin/features/confirm.html.erb | 36 + app/views/admin/features/edit.html.erb | 22 + app/views/admin/features/index.html.erb | 44 + app/views/admin/features/new.html.erb | 22 + app/views/admin/home/_submenu.html.erb | 10 + app/views/admin/home/index.html.erb | 69 + .../admin/mail_magazine_templates/_form.html.erb | 63 + .../mail_magazine_templates/_submenu.html.erb | 1 + .../admin/mail_magazine_templates/edit.html.erb | 11 + .../admin/mail_magazine_templates/index.html.erb | 36 + .../admin/mail_magazine_templates/new.html.erb | 12 + .../admin/mail_magazine_templates/preview.html.erb | 18 + app/views/admin/mail_magazines/_form.html.erb | 114 + .../admin/mail_magazines/_mail_contents.html.erb | 27 + app/views/admin/mail_magazines/_submenu.html.erb | 1 + .../admin/mail_magazines/condition_view.html.erb | 103 + app/views/admin/mail_magazines/confirm.html.erb | 29 + app/views/admin/mail_magazines/history.html.erb | 44 + app/views/admin/mail_magazines/index.html.erb | 13 + app/views/admin/mail_magazines/preview.html.erb | 15 + app/views/admin/mail_magazines/search.html.erb | 63 + .../admin/mail_magazines/template_search.html.erb | 52 + app/views/admin/mobile_devices/_submenu.html.erb | 1 + app/views/admin/mobile_devices/index.html.erb | 120 + app/views/admin/mobile_devices/list.html.erb | 107 + app/views/admin/new_informations/_form.html.erb | 38 + app/views/admin/new_informations/_submenu.html.erb | 1 + app/views/admin/new_informations/confirm.html.erb | 37 + app/views/admin/new_informations/edit.html.erb | 15 + app/views/admin/new_informations/index.html.erb | 47 + app/views/admin/new_informations/new.html.erb | 14 + app/views/admin/order_statuses/_submenu.html.erb | 1 + app/views/admin/order_statuses/index.html.erb | 85 + app/views/admin/orders/_form.html.erb | 175 + app/views/admin/orders/_search.html.erb | 79 + app/views/admin/orders/_show.html.erb | 154 + app/views/admin/orders/_submenu.html.erb | 1 + app/views/admin/orders/edit.html.erb | 10 + app/views/admin/orders/index.html.erb | 11 + app/views/admin/orders/new.html.erb | 16 + app/views/admin/orders/search.html.erb | 64 + .../admin/orders/select_delivery_time.html.erb | 1 + app/views/admin/orders/show.html.erb | 18 + .../admin/product_styles/_create_form.html.erb | 16 + app/views/admin/product_styles/_form.html.erb | 52 + app/views/admin/product_styles/_submenu.html.erb | 1 + app/views/admin/product_styles/confirm.html.erb | 71 + .../admin/product_styles/create_form.html.erb | 1 + app/views/admin/product_styles/new.html.erb | 52 + app/views/admin/products/_form.html.erb | 187 + app/views/admin/products/_search.html.erb | 73 + app/views/admin/products/_sub_product.html.erb | 74 + app/views/admin/products/_submenu.html.erb | 1 + .../admin/products/actual_count_index.html.erb | 12 + .../admin/products/actual_count_search.html.erb | 49 + app/views/admin/products/confirm.html.erb | 40 + app/views/admin/products/edit.html.erb | 14 + app/views/admin/products/index.html.erb | 23 + app/views/admin/products/new.html.erb | 16 + app/views/admin/products/search.html.erb | 88 + app/views/admin/products/show.html.erb | 13 + app/views/admin/questionnaires/_form.html.erb | 66 + app/views/admin/questionnaires/_submenu.html.erb | 1 + app/views/admin/questionnaires/edit.html.erb | 39 + app/views/admin/questionnaires/index.html.erb | 40 + app/views/admin/questionnaires/new.html.erb | 40 + app/views/admin/recommend_products/_form.html.erb | 31 + .../admin/recommend_products/_submenu.html.erb | 1 + app/views/admin/recommend_products/edit.html.erb | 11 + app/views/admin/recommend_products/index.html.erb | 40 + app/views/admin/recommend_products/new.html.erb | 11 + .../recommend_products/product_search.html.erb | 71 + app/views/admin/shops/_delivery_form.html.erb | 75 + app/views/admin/shops/_form.html.erb | 78 + app/views/admin/shops/_kiyaku_form.html.erb | 17 + app/views/admin/shops/_mail_form.html.erb | 26 + app/views/admin/shops/_payment_form.html.erb | 28 + app/views/admin/shops/_point_form.html.erb | 18 + app/views/admin/shops/_seo_form.html.erb | 32 + app/views/admin/shops/_submenu.html.erb | 1 + app/views/admin/shops/_tradelaw_form.html.erb | 71 + app/views/admin/shops/delivery_edit.html.erb | 15 + app/views/admin/shops/delivery_index.html.erb | 42 + app/views/admin/shops/delivery_new.html.erb | 10 + app/views/admin/shops/index.html.erb | 11 + app/views/admin/shops/kiyaku_index.html.erb | 46 + app/views/admin/shops/mail_index.html.erb | 35 + app/views/admin/shops/payment_complete.html.erb | 17 + app/views/admin/shops/payment_edit.html.erb | 11 + app/views/admin/shops/payment_index.html.erb | 47 + app/views/admin/shops/payment_new.html.erb | 10 + app/views/admin/shops/point_index.html.erb | 12 + app/views/admin/shops/privacy.html.erb | 17 + app/views/admin/shops/seo_index.html.erb | 10 + app/views/admin/shops/tradelaw_index.html.erb | 15 + app/views/admin/stock/_submenu.html.erb | 1 + app/views/admin/stock/confirm.html.erb | 2 + app/views/admin/stock/list.html.erb | 75 + app/views/admin/stock/new.html.erb | 140 + app/views/admin/style_categories/_form.html.erb | 15 + app/views/admin/style_categories/_submenu.html.erb | 1 + app/views/admin/style_categories/index.html.erb | 46 + app/views/admin/styles/_form.html.erb | 13 + app/views/admin/styles/_submenu.html.erb | 1 + app/views/admin/styles/index.html.erb | 38 + app/views/admin/totals/_submenu.html.erb | 1 + app/views/admin/totals/index.html.erb | 107 + app/views/base/_add_cart.html.erb | 40 + app/views/base/_add_cart_mobile.html.erb | 33 + app/views/base/_cart.html.erb | 6 + app/views/base/_category.html.erb | 13 + app/views/base/_category_mobile.html.erb | 16 + app/views/base/_left_sidebar.html.erb | 20 + app/views/base/_new_product.html.erb | 14 + app/views/base/_recommend_asp.html.erb | 32 + app/views/base/_recommend_asp_mobile.html.erb | 20 + app/views/base/_recommend_product.html.erb | 17 + app/views/base/_recommend_product_mobile.html.erb | 24 + app/views/base/_recommend_ranking.html.erb | 15 + app/views/base/_recommend_ranking_mobile.html.erb | 26 + app/views/base/_right_sidebar.html.erb | 64 + app/views/base/_title_mobile.html.erb | 8 + app/views/campaigns/complete.html.erb | 9 + app/views/campaigns/complete_mobile.html.erb | 11 + app/views/campaigns/show.html.erb | 94 + app/views/campaigns/show_mobile.html.erb | 73 + app/views/cart/405.html.erb | 11 + app/views/cart/_address_list.html.erb | 16 + app/views/cart/_address_list_mobile.html.erb | 13 + app/views/cart/_login_form.html.erb | 18 + app/views/cart/_login_form_mobile.html.erb | 22 + app/views/cart/_order_delivery_hiddens.html.erb | 14 + app/views/cart/add_product.html.erb | 2 + app/views/cart/complete.html.erb | 34 + app/views/cart/complete_mobile.html.erb | 11 + app/views/cart/confirm.html.erb | 194 + app/views/cart/confirm_mobile.html.erb | 167 + app/views/cart/purchase.html.erb | 96 + app/views/cart/purchase2_mobile.html.erb | 37 + app/views/cart/purchase_mobile.html.erb | 67 + app/views/cart/purchase_select_payment.rjs | 1 + app/views/cart/select_delivery_time.html.erb | 1 + app/views/cart/shipping.html.erb | 30 + app/views/cart/shipping_mobile.html.erb | 20 + app/views/cart/show.html.erb | 62 + app/views/cart/show_mobile.html.erb | 48 + app/views/cart/temporary_shipping.html.erb | 144 + app/views/cart/temporary_shipping_mobile.html.erb | 87 + app/views/features/_free.html.erb | 8 + app/views/features/_product.html.erb | 25 + app/views/features/show.html.erb | 25 + app/views/inquiries/complete.html.erb | 14 + app/views/inquiries/complete_mobile.html.erb | 13 + app/views/inquiries/confirm.html.erb | 49 + app/views/inquiries/confirm_mobile.html.erb | 44 + app/views/inquiries/new.html.erb | 57 + app/views/inquiries/new_mobile.html.erb | 49 + app/views/inquiries/privacy_mobile.html.erb | 12 + app/views/inquiries/show_mobile.html.erb | 23 + app/views/layouts/admin/base.html.erb | 38 + app/views/layouts/base.html.erb | 58 + app/views/layouts/base_mobile.html.erb | 82 + app/views/notifier/activate.html.erb | 14 + app/views/notifier/activate_mobile.html.erb | 11 + app/views/notifier/buying_complete.html.erb | 42 + app/views/notifier/buying_complete_mobile.html.erb | 37 + app/views/notifier/html_mailmagazine.html.erb | 1 + app/views/notifier/mobile_inquiry.html.erb | 15 + app/views/notifier/mobile_reminder.html.erb | 9 + app/views/notifier/pc_inquiry.html.erb | 15 + app/views/notifier/received_inquiry.html.erb | 9 + app/views/notifier/reminder.html.erb | 9 + app/views/notifier/text_mailmagazine.html.erb | 1 + app/views/portal/_footer_mobile.html.erb | 20 + app/views/portal/_new_information.html.erb | 15 + app/views/portal/_new_information_mobile.html.erb | 12 + app/views/portal/company.html.erb | 35 + app/views/portal/escape_clause.html.erb | 29 + app/views/portal/first_one_mobile.html.erb | 88 + app/views/portal/maintenance.html.erb | 45 + app/views/portal/maintenance_mobile.html.erb | 22 + app/views/portal/mymenu_mobile.html.erb | 45 + app/views/portal/notice.html.erb | 52 + app/views/portal/notice_mobile.html.erb | 21 + app/views/portal/privacy.html.erb | 29 + app/views/portal/privacy_mobile.html.erb | 218 + app/views/portal/show.html.erb | 20 + app/views/portal/show_mobile.html.erb | 87 + app/views/portal/show_tradelaw.html.erb | 69 + app/views/portal/show_tradelaw_mobile.html.erb | 48 + app/views/portal/supported_device_mobile.html.erb | 14 + .../portal/unsupported_device_mobile.html.erb | 38 + app/views/products/_form.html.erb | 35 + app/views/products/_recommend_products.html.erb | 13 + app/views/products/index.html.erb | 57 + app/views/products/index_mobile.html.erb | 49 + app/views/products/review_complete.html.erb | 7 + app/views/products/review_confirm.html.erb | 11 + app/views/products/review_new.html.erb | 18 + app/views/products/show.html.erb | 98 + app/views/products/show_image.html.erb | 22 + app/views/products/show_mobile.html.erb | 81 + app/views/products/stock_table.html.erb | 22 + app/views/questionnaires/complete.html.erb | 9 + app/views/questionnaires/complete_mobile.html.erb | 8 + app/views/questionnaires/confirm.html.erb | 127 + app/views/questionnaires/confirm_mobile.html.erb | 90 + app/views/questionnaires/new.html.erb | 96 + app/views/questionnaires/new_mobile.html.erb | 59 + app/views/recommend/tsv.html.erb | 0 app/views/resource/thumbnail.html.erb | 2 + app/views/shop/about.html.erb | 61 + app/views/user/_address_confirm.html.erb | 12 + app/views/user/_address_form.html.erb | 49 + app/views/user/_address_list.html.erb | 28 + app/views/user/_navigation.html.erb | 8 + app/views/user/address_complete.html.erb | 20 + app/views/user/address_create.html.erb | 0 app/views/user/address_create_confirm.html.erb | 26 + app/views/user/address_delete.html.erb | 0 app/views/user/address_edit.html.erb | 24 + app/views/user/address_list.html.erb | 28 + app/views/user/address_list_mobile.html.erb | 38 + app/views/user/address_new.html.erb | 23 + app/views/user/address_show.html.erb | 9 + app/views/user/address_update.html.erb | 0 app/views/user/address_update_confirm.html.erb | 26 + app/views/user/history_list.html.erb | 9 + app/views/user/history_list_mobile.html.erb | 21 + app/views/user/history_show.html.erb | 9 + app/views/user/mypage_mobile.html.erb | 18 + app/views/user/setting.html.erb | 16 + app/views/user/setting_mobile.html.erb | 24 + app/views/user/show.html.erb | 9 + config/boot.rb | 110 + config/database.example.yml | 18 + config/database.example.yml.sqllite | 16 + config/environment.rb | 81 + config/environments/development.rb | 25 + config/environments/production.rb | 36 + config/environments/test.rb | 32 + .../add_csv_download/add_csv_download.rb | 171 + config/initializers/backtrace_silencers.rb | 7 + config/initializers/inflections.rb | 10 + config/initializers/jpmobile_override.rb | 70 + config/initializers/mime_types.rb | 5 + config/initializers/new_rails_defaults.rb | 19 + config/initializers/session_store.rb | 15 + config/locales/ja.yml | 140 + config/locales/translation_ja.yml | 796 ++++ config/routes.rb | 82 + db/migrate/20090512061734_create_admin_users.rb | 26 + db/migrate/20090512081925_create_authorities.rb | 14 + .../20090512082526_create_authorities_functions.rb | 14 + db/migrate/20090512083801_create_campaigns.rb | 41 + db/migrate/20090512085119_create_faqs.rb | 20 + .../20090512094800_create_campaigns_customers.rb | 18 + db/migrate/20090512095649_create_carts.rb | 23 + db/migrate/20090513005806_create_categories.rb | 26 + db/migrate/20090513011211_create_functions.rb | 21 + db/migrate/20090513013825_create_inquiries.rb | 21 + db/migrate/20090513014030_create_constants.rb | 20 + db/migrate/20090513014555_create_kiyakus.rb | 20 + db/migrate/20090513014834_create_laws.rb | 36 + ...0090513021617_create_mail_magazine_templates.rb | 18 + db/migrate/20090513022200_create_mail_magazines.rb | 22 + db/migrate/20090513022926_create_mail_templates.rb | 19 + db/migrate/20090513024427_create_mails.rb | 19 + .../20090513025820_create_mobile_carriers.rb | 23 + db/migrate/20090513030410_create_mobile_devices.rb | 23 + .../20090513031025_create_new_informations.rb | 23 + db/migrate/20090513032912_create_occupations.rb | 19 + .../20090513034408_create_order_deliveries.rb | 86 + db/migrate/20090513061015_create_customers.rb | 68 + db/migrate/20090513061105_create_order_details.rb | 46 + db/migrate/20090513064455_create_orders.rb | 20 + db/migrate/20090513065225_create_payments.rb | 28 + db/migrate/20090513065957_create_prefectures.rb | 22 + db/migrate/20090513070304_create_privacies.rb | 16 + .../20090513073327_create_product_access_logs.rb | 22 + .../20090513075659_create_product_statuses.rb | 22 + .../20090513080712_create_question_answers.rb | 26 + .../20090513081253_create_question_choices.rb | 23 + .../20090513081352_create_questionnaire_answers.rb | 35 + db/migrate/20090513081453_create_questionnaires.rb | 18 + db/migrate/20090513081710_create_questions.rb | 25 + .../20090513081825_create_recommend_products.rb | 24 + db/migrate/20090513081950_create_recommend_xmls.rb | 21 + db/migrate/20090513082051_create_recommends.rb | 15 + db/migrate/20090513082209_create_resource_datas.rb | 17 + db/migrate/20090513082300_create_resources.rb | 18 + db/migrate/20090513082352_create_seos.rb | 20 + db/migrate/20090513082444_create_sessions.rb | 18 + db/migrate/20090513082549_create_shops.rb | 39 + db/migrate/20090513082754_create_statuses.rb | 19 + .../20090513083035_create_delivery_addresses.rb | 35 + db/migrate/20090513083130_create_stock_tables.rb | 17 + .../20090513083630_create_style_categories.rb | 22 + db/migrate/20090513083852_create_product_styles.rb | 33 + db/migrate/20090513084050_create_delivery_dates.rb | 18 + db/migrate/20090513084222_create_styles.rb | 19 + db/migrate/20090513084438_create_delivery_fees.rb | 22 + db/migrate/20090513084557_create_sub_products.rb | 27 + db/migrate/20090513084755_create_products.rb | 55 + .../20090513084925_create_delivery_tickets.rb | 15 + db/migrate/20090513085308_create_systems.rb | 21 + db/migrate/20090513091318_create_zips.rb | 27 + db/migrate/20090513092100_create_delivery_times.rb | 23 + .../20090513092607_create_delivery_traders.rb | 20 + db/migrate/20090513093001_create_designs.rb | 18 + db/migrate/20090520054539_add_data_functions.rb | 19 + .../20090520063143_create_image_resources.rb | 31 + db/migrate/20090521071313_add_date_shop.rb | 12 + db/migrate/20090521082527_add_data_statuses.rb | 12 + db/migrate/20090601080958_create_recalls.rb | 16 + db/migrate/20090601081026_create_recall_details.rb | 22 + db/migrate/20090603071104_add_column_designs.rb | 11 + db/migrate/20091009022605_create_features.rb | 18 + .../20091009032514_create_feature_products.rb | 18 + db/migrate/20091019095808_add_column_shops.rb | 11 + db/migrate/20091022105613_add_data_occupations.rb | 12 + .../20091213083945_add_data_mail_templates.rb | 12 + db/migrate/20091213085332_add_data_seos.rb | 11 + db/migrate/20091213131916_add_data_shops.rb | 11 + db/migrate/20091213134247_add_data_systems.rb | 11 + db/migrate/fixed_data/authorities.yml | 4 + db/migrate/fixed_data/authorities_functions.csv | 35 + db/migrate/fixed_data/constants.yml | 92 + db/migrate/fixed_data/csv_output_settings.yml | 41 + db/migrate/fixed_data/functions.yml | 199 + db/migrate/fixed_data/mail_templates.yml | 26 + db/migrate/fixed_data/mobile_carriers.csv | 4 + db/migrate/fixed_data/mobile_devices.csv | 316 ++ db/migrate/fixed_data/mobile_specs.txt | 593 +++ db/migrate/fixed_data/occupations.yml | 78 + db/migrate/fixed_data/prefectures.yml | 283 ++ db/migrate/fixed_data/seos.yml | 38 + db/migrate/fixed_data/shops.yml | 24 + db/migrate/fixed_data/statuses.yml | 18 + db/migrate/fixed_data/systems.yml | 6 + db/migrate/fixed_data/target_columns.yml | 1161 ++++++ db/migrate/fixed_data/target_tables.yml | 49 + god/common.god | 140 + god/production.god | 11 + lib/action_view_helper.rb | 75 + lib/active_record_helper.rb | 84 + lib/create_fixtures.rb | 97 + lib/csv_util.rb | 11 + lib/recall_controller_module.rb | 21 + lib/resource_controller/controller.rb | 69 + lib/rexml-expansion-fix.rb | 43 + lib/sazanami-gothic.ttf | Bin 0 -> 7690324 bytes lib/security_token.rb | 78 + lib/tasks/create_fixtures.rake | 11 + lib/tasks/rspec.rake | 167 + lib/totalizer.rb | 596 +++ lib/validates.rb | 40 + lib/veritrans.rb | 174 + public/.htaccess | 40 + public/404.html | 75 + public/404_mobile.html | 73 + public/422.html | 30 + public/500.html | 72 + public/500_mobile.html | 78 + public/admin/404.html | 16 + public/admin/500.html | 16 + public/blank.html | 33 + public/dispatch.cgi | 10 + public/dispatch.fcgi | 24 + public/dispatch.rb | 10 + public/favicon.ico | 0 public/images/body_bg.gif | Bin 0 -> 213 bytes public/images/btn_main.gif | Bin 0 -> 1064 bytes public/images/btn_s.gif | Bin 0 -> 149 bytes public/images/btn_side.gif | Bin 0 -> 377 bytes public/images/cart/cart_bg.gif | Bin 0 -> 96 bytes public/images/cart/cart_btm.gif | Bin 0 -> 252 bytes public/images/cart/cart_btn01.gif | Bin 0 -> 1769 bytes public/images/cart/cart_btn01_ov.gif | Bin 0 -> 1782 bytes public/images/cart/cart_btn02.gif | Bin 0 -> 1550 bytes public/images/cart/cart_btn02_ov.gif | Bin 0 -> 1551 bytes public/images/cart/cart_btn03.gif | Bin 0 -> 1174 bytes public/images/cart/cart_btn03_ov.gif | Bin 0 -> 1169 bytes public/images/cart/cart_btn04.gif | Bin 0 -> 1703 bytes public/images/cart/cart_btn04_ov.gif | Bin 0 -> 1695 bytes public/images/cart/cart_btn05.gif | Bin 0 -> 1107 bytes public/images/cart/cart_btn05_ov.gif | Bin 0 -> 1105 bytes public/images/cart/cart_t1.gif | Bin 0 -> 5100 bytes public/images/cart/cart_t2.gif | Bin 0 -> 4915 bytes public/images/cart/recalc.gif | Bin 0 -> 1100 bytes public/images/cart/route01.gif | Bin 0 -> 2948 bytes public/images/cart/route02.gif | Bin 0 -> 2877 bytes public/images/cart/route03.gif | Bin 0 -> 2829 bytes public/images/cart/route04.gif | Bin 0 -> 2936 bytes public/images/category/dummy/accessory01.jpg | Bin 0 -> 15967 bytes public/images/category/dummy/accessory02.jpg | Bin 0 -> 22013 bytes public/images/category/dummy/accessory03.jpg | Bin 0 -> 27621 bytes public/images/category/dummy/accessory04.jpg | Bin 0 -> 19125 bytes public/images/category/dummy/accessory05.jpg | Bin 0 -> 28093 bytes public/images/category/dummy/accessory06.jpg | Bin 0 -> 52883 bytes public/images/category/dummy/bag01.jpg | Bin 0 -> 21900 bytes public/images/category/dummy/bag02.jpg | Bin 0 -> 25179 bytes public/images/category/dummy/bag03.jpg | Bin 0 -> 13522 bytes public/images/category/dummy/bag04.jpg | Bin 0 -> 33235 bytes public/images/category/dummy/bag05.jpg | Bin 0 -> 39091 bytes public/images/category/dummy/bottoms01.jpg | Bin 0 -> 15421 bytes public/images/category/dummy/bottoms02.jpg | Bin 0 -> 37455 bytes public/images/category/dummy/bottoms03.jpg | Bin 0 -> 25650 bytes public/images/category/dummy/bottoms04.jpg | Bin 0 -> 34600 bytes public/images/category/dummy/bottoms05.jpg | Bin 0 -> 45104 bytes public/images/category/dummy/bottoms06.jpg | Bin 0 -> 24971 bytes public/images/category/dummy/hat01.jpg | Bin 0 -> 27361 bytes public/images/category/dummy/hat02.jpg | Bin 0 -> 32257 bytes public/images/category/dummy/hat03.jpg | Bin 0 -> 18297 bytes public/images/category/dummy/hat04.jpg | Bin 0 -> 31676 bytes public/images/category/dummy/outer01.jpg | Bin 0 -> 38762 bytes public/images/category/dummy/outer02.jpg | Bin 0 -> 33948 bytes public/images/category/dummy/outer03.jpg | Bin 0 -> 30258 bytes public/images/category/dummy/outer04.jpg | Bin 0 -> 32733 bytes public/images/category/dummy/outer05.jpg | Bin 0 -> 45888 bytes public/images/category/dummy/shoes01.jpg | Bin 0 -> 14515 bytes public/images/category/dummy/shoes02.jpg | Bin 0 -> 16269 bytes public/images/category/dummy/shoes03.jpg | Bin 0 -> 18018 bytes public/images/category/dummy/shoes04.jpg | Bin 0 -> 21629 bytes public/images/category/dummy/shoes05.jpg | Bin 0 -> 24912 bytes public/images/category/dummy/tops01.jpg | Bin 0 -> 11292 bytes public/images/category/dummy/tops02.jpg | Bin 0 -> 14149 bytes public/images/category/dummy/tops03.jpg | Bin 0 -> 14276 bytes public/images/category/dummy/tops04.jpg | Bin 0 -> 13008 bytes public/images/category/dummy/tops05.jpg | Bin 0 -> 33202 bytes public/images/category/head_img.jpg | Bin 0 -> 34895 bytes public/images/category/rank1.gif | Bin 0 -> 1921 bytes public/images/category/rank2.gif | Bin 0 -> 1555 bytes public/images/category/rank3.gif | Bin 0 -> 2012 bytes public/images/category/rank4.gif | Bin 0 -> 2021 bytes public/images/category/rank_t_bg.gif | Bin 0 -> 5087 bytes public/images/common/banner01.jpg | Bin 0 -> 8160 bytes public/images/common/banner02.jpg | Bin 0 -> 11126 bytes public/images/common/banner03.jpg | Bin 0 -> 11907 bytes public/images/common/banner04.jpg | Bin 0 -> 8549 bytes public/images/common/banner_mobile.gif | Bin 0 -> 11602 bytes public/images/common/body_bg.gif | Bin 0 -> 4103 bytes public/images/common/box_bg.gif | Bin 0 -> 70 bytes public/images/common/box_bg_btm.gif | Bin 0 -> 222 bytes public/images/common/box_bg_top.gif | Bin 0 -> 220 bytes public/images/common/btn01.gif | Bin 0 -> 1202 bytes public/images/common/btn02.gif | Bin 0 -> 1107 bytes public/images/common/btn03.gif | Bin 0 -> 1146 bytes public/images/common/cart_btn.gif | Bin 0 -> 1422 bytes public/images/common/cart_btn_ov.gif | Bin 0 -> 1405 bytes public/images/common/check_t.gif | Bin 0 -> 1945 bytes public/images/common/close.png | Bin 0 -> 1217 bytes public/images/common/container_bg.gif | Bin 0 -> 53 bytes public/images/common/footer_bg.gif | Bin 0 -> 18530 bytes public/images/common/gt.gif | Bin 0 -> 54 bytes public/images/common/guide_btn.gif | Bin 0 -> 1196 bytes public/images/common/guide_btn_ov.gif | Bin 0 -> 1202 bytes public/images/common/h3_category.gif | Bin 0 -> 2755 bytes public/images/common/h3_info.gif | Bin 0 -> 1271 bytes public/images/common/h3_kuchikomi.gif | Bin 0 -> 2722 bytes public/images/common/h3_login.gif | Bin 0 -> 1130 bytes public/images/common/h3_search.gif | Bin 0 -> 1361 bytes public/images/common/header_bg.jpg | Bin 0 -> 11106 bytes public/images/common/kuchi_01.gif | Bin 0 -> 1087 bytes public/images/common/kuchi_02.gif | Bin 0 -> 1135 bytes public/images/common/kuchi_03.gif | Bin 0 -> 1110 bytes public/images/common/kuchi_04.gif | Bin 0 -> 1002 bytes public/images/common/kuchi_05.gif | Bin 0 -> 1004 bytes public/images/common/kuchi_hr.gif | Bin 0 -> 58 bytes public/images/common/list_ore.gif | Bin 0 -> 69 bytes public/images/common/list_ore_s.gif | Bin 0 -> 48 bytes public/images/common/list_pink.gif | Bin 0 -> 65 bytes public/images/common/login_btn.gif | Bin 0 -> 1059 bytes public/images/common/login_btn_ov.gif | Bin 0 -> 1031 bytes public/images/common/logo.gif | Bin 0 -> 2181 bytes public/images/common/main_hr.gif | Bin 0 -> 86 bytes public/images/common/main_t_l.gif | Bin 0 -> 3311 bytes public/images/common/menu_accessory.gif | Bin 0 -> 4208 bytes public/images/common/menu_accessory_ov.gif | Bin 0 -> 4461 bytes public/images/common/menu_bag.gif | Bin 0 -> 4280 bytes public/images/common/menu_bag_ov.gif | Bin 0 -> 4316 bytes public/images/common/menu_bottoms.gif | Bin 0 -> 4506 bytes public/images/common/menu_bottoms_ov.gif | Bin 0 -> 4701 bytes public/images/common/menu_hat.gif | Bin 0 -> 3782 bytes public/images/common/menu_hat_ov.gif | Bin 0 -> 4000 bytes public/images/common/menu_outer.gif | Bin 0 -> 4059 bytes public/images/common/menu_outer_ov.gif | Bin 0 -> 4240 bytes public/images/common/menu_shoes.gif | Bin 0 -> 4177 bytes public/images/common/menu_shoes_ov.gif | Bin 0 -> 4437 bytes public/images/common/menu_tops.gif | Bin 0 -> 4005 bytes public/images/common/menu_tops_ov.gif | Bin 0 -> 4329 bytes public/images/common/mypage_btn.gif | Bin 0 -> 981 bytes public/images/common/mypage_btn_ov.gif | Bin 0 -> 969 bytes public/images/common/new_entry_btn.gif | Bin 0 -> 1846 bytes public/images/common/new_entry_btn_ov.gif | Bin 0 -> 1798 bytes public/images/common/pagetop_btn.gif | Bin 0 -> 893 bytes public/images/common/purchase_btn.gif | Bin 0 -> 1777 bytes public/images/common/purchase_btn_ov.gif | Bin 0 -> 1750 bytes public/images/common/rank_t_bg.gif | Bin 0 -> 1281 bytes public/images/common/search_btn.gif | Bin 0 -> 622 bytes public/images/common/search_btn_ov.gif | Bin 0 -> 622 bytes public/images/common/side_bg_btm.gif | Bin 0 -> 175 bytes public/images/common/side_bg_mid.gif | Bin 0 -> 62 bytes public/images/common/side_bg_top.gif | Bin 0 -> 173 bytes public/images/common/side_hr.gif | Bin 0 -> 66 bytes public/images/common/title_bg.gif | Bin 0 -> 3222 bytes public/images/common/top_img.jpg | Bin 0 -> 49311 bytes public/images/emoticons/24hours.gif | Bin 0 -> 173 bytes public/images/emoticons/airplane.gif | Bin 0 -> 130 bytes public/images/emoticons/angry.gif | Bin 0 -> 145 bytes public/images/emoticons/annoy.gif | Bin 0 -> 233 bytes public/images/emoticons/apple.gif | Bin 0 -> 248 bytes public/images/emoticons/appli01.gif | Bin 0 -> 132 bytes public/images/emoticons/appli02.gif | Bin 0 -> 141 bytes public/images/emoticons/aquarius.gif | Bin 0 -> 179 bytes public/images/emoticons/aries.gif | Bin 0 -> 182 bytes public/images/emoticons/art.gif | Bin 0 -> 186 bytes public/images/emoticons/atm.gif | Bin 0 -> 166 bytes public/images/emoticons/bag.gif | Bin 0 -> 154 bytes public/images/emoticons/ban.gif | Bin 0 -> 183 bytes public/images/emoticons/banana.gif | Bin 0 -> 173 bytes public/images/emoticons/bank.gif | Bin 0 -> 240 bytes public/images/emoticons/bar.gif | Bin 0 -> 218 bytes public/images/emoticons/baseball.gif | Bin 0 -> 196 bytes public/images/emoticons/basketball.gif | Bin 0 -> 271 bytes public/images/emoticons/bearing.gif | Bin 0 -> 148 bytes public/images/emoticons/beer.gif | Bin 0 -> 195 bytes public/images/emoticons/bell.gif | Bin 0 -> 176 bytes public/images/emoticons/bicycle.gif | Bin 0 -> 173 bytes public/images/emoticons/birthday.gif | Bin 0 -> 262 bytes public/images/emoticons/bleah.gif | Bin 0 -> 169 bytes public/images/emoticons/bomb.gif | Bin 0 -> 175 bytes public/images/emoticons/book.gif | Bin 0 -> 139 bytes public/images/emoticons/bottle.gif | Bin 0 -> 185 bytes public/images/emoticons/boutique.gif | Bin 0 -> 163 bytes public/images/emoticons/bread.gif | Bin 0 -> 252 bytes public/images/emoticons/bud.gif | Bin 0 -> 164 bytes public/images/emoticons/building.gif | Bin 0 -> 160 bytes public/images/emoticons/bullettrain.gif | Bin 0 -> 166 bytes public/images/emoticons/bus.gif | Bin 0 -> 224 bytes public/images/emoticons/by-d.gif | Bin 0 -> 124 bytes public/images/emoticons/cafe.gif | Bin 0 -> 181 bytes public/images/emoticons/cake.gif | Bin 0 -> 238 bytes public/images/emoticons/camera.gif | Bin 0 -> 174 bytes public/images/emoticons/cancer.gif | Bin 0 -> 153 bytes public/images/emoticons/capricornus.gif | Bin 0 -> 177 bytes public/images/emoticons/car.gif | Bin 0 -> 159 bytes public/images/emoticons/carouselpony.gif | Bin 0 -> 184 bytes public/images/emoticons/cat.gif | Bin 0 -> 175 bytes public/images/emoticons/catface.gif | Bin 0 -> 82 bytes public/images/emoticons/cd.gif | Bin 0 -> 194 bytes public/images/emoticons/chair.gif | Bin 0 -> 145 bytes public/images/emoticons/cherry.gif | Bin 0 -> 169 bytes public/images/emoticons/cherryblossom.gif | Bin 0 -> 187 bytes public/images/emoticons/chick.gif | Bin 0 -> 170 bytes public/images/emoticons/clear.gif | Bin 0 -> 171 bytes public/images/emoticons/clip.gif | Bin 0 -> 133 bytes public/images/emoticons/clock.gif | Bin 0 -> 195 bytes public/images/emoticons/cloud.gif | Bin 0 -> 242 bytes public/images/emoticons/clover.gif | Bin 0 -> 144 bytes public/images/emoticons/club.gif | Bin 0 -> 132 bytes public/images/emoticons/coldsweats01.gif | Bin 0 -> 215 bytes public/images/emoticons/coldsweats02.gif | Bin 0 -> 222 bytes public/images/emoticons/confident.gif | Bin 0 -> 83 bytes public/images/emoticons/copyright.gif | Bin 0 -> 129 bytes public/images/emoticons/crown.gif | Bin 0 -> 181 bytes public/images/emoticons/crying.gif | Bin 0 -> 233 bytes public/images/emoticons/cute.gif | Bin 0 -> 127 bytes public/images/emoticons/d-point.gif | Bin 0 -> 132 bytes public/images/emoticons/danger.gif | Bin 0 -> 174 bytes public/images/emoticons/dash.gif | Bin 0 -> 130 bytes public/images/emoticons/delicious.gif | Bin 0 -> 131 bytes public/images/emoticons/denim.gif | Bin 0 -> 145 bytes public/images/emoticons/despair.gif | Bin 0 -> 140 bytes public/images/emoticons/diamond.gif | Bin 0 -> 119 bytes public/images/emoticons/dog.gif | Bin 0 -> 137 bytes public/images/emoticons/dollar.gif | Bin 0 -> 188 bytes public/images/emoticons/door.gif | Bin 0 -> 159 bytes public/images/emoticons/down.gif | Bin 0 -> 123 bytes public/images/emoticons/downwardleft.gif | Bin 0 -> 109 bytes public/images/emoticons/downwardright.gif | Bin 0 -> 108 bytes public/images/emoticons/drama.gif | Bin 0 -> 168 bytes public/images/emoticons/ear.gif | Bin 0 -> 104 bytes public/images/emoticons/eight.gif | Bin 0 -> 174 bytes public/images/emoticons/emoticons.gif | Bin 0 -> 132746 bytes public/images/emoticons/empty.gif | Bin 0 -> 165 bytes public/images/emoticons/end.gif | Bin 0 -> 111 bytes public/images/emoticons/enter.gif | Bin 0 -> 126 bytes public/images/emoticons/event.gif | Bin 0 -> 167 bytes public/images/emoticons/eye.gif | Bin 0 -> 125 bytes public/images/emoticons/eyeglass.gif | Bin 0 -> 132 bytes public/images/emoticons/fastfood.gif | Bin 0 -> 243 bytes public/images/emoticons/faxto.gif | Bin 0 -> 199 bytes public/images/emoticons/fish.gif | Bin 0 -> 172 bytes public/images/emoticons/five.gif | Bin 0 -> 173 bytes public/images/emoticons/flag.gif | Bin 0 -> 145 bytes public/images/emoticons/flair.gif | Bin 0 -> 223 bytes public/images/emoticons/foot.gif | Bin 0 -> 94 bytes public/images/emoticons/four.gif | Bin 0 -> 174 bytes public/images/emoticons/free.gif | Bin 0 -> 110 bytes public/images/emoticons/freedial.gif | Bin 0 -> 130 bytes public/images/emoticons/fuji.gif | Bin 0 -> 246 bytes public/images/emoticons/full.gif | Bin 0 -> 171 bytes public/images/emoticons/fullmoon.gif | Bin 0 -> 144 bytes public/images/emoticons/game.gif | Bin 0 -> 156 bytes public/images/emoticons/gasstation.gif | Bin 0 -> 175 bytes public/images/emoticons/gawk.gif | Bin 0 -> 138 bytes public/images/emoticons/gemini.gif | Bin 0 -> 177 bytes public/images/emoticons/golf.gif | Bin 0 -> 148 bytes public/images/emoticons/good.gif | Bin 0 -> 134 bytes public/images/emoticons/hairsalon.gif | Bin 0 -> 159 bytes public/images/emoticons/happy01.gif | Bin 0 -> 154 bytes public/images/emoticons/happy02.gif | Bin 0 -> 157 bytes public/images/emoticons/heart.gif | Bin 0 -> 125 bytes public/images/emoticons/heart01.gif | Bin 0 -> 220 bytes public/images/emoticons/heart02.gif | Bin 0 -> 242 bytes public/images/emoticons/heart03.gif | Bin 0 -> 411 bytes public/images/emoticons/heart04.gif | Bin 0 -> 214 bytes public/images/emoticons/horse.gif | Bin 0 -> 173 bytes public/images/emoticons/hospital.gif | Bin 0 -> 184 bytes public/images/emoticons/hotel.gif | Bin 0 -> 187 bytes public/images/emoticons/house.gif | Bin 0 -> 250 bytes public/images/emoticons/id.gif | Bin 0 -> 168 bytes public/images/emoticons/impact.gif | Bin 0 -> 130 bytes public/images/emoticons/info01.gif | Bin 0 -> 107 bytes public/images/emoticons/info02.gif | Bin 0 -> 117 bytes public/images/emoticons/japanesetea.gif | Bin 0 -> 176 bytes public/images/emoticons/karaoke.gif | Bin 0 -> 144 bytes public/images/emoticons/key.gif | Bin 0 -> 129 bytes public/images/emoticons/kissmark.gif | Bin 0 -> 156 bytes public/images/emoticons/leftright.gif | Bin 0 -> 104 bytes public/images/emoticons/leo.gif | Bin 0 -> 259 bytes public/images/emoticons/libra.gif | Bin 0 -> 173 bytes public/images/emoticons/loveletter.gif | Bin 0 -> 160 bytes public/images/emoticons/lovely.gif | Bin 0 -> 170 bytes public/images/emoticons/mail.gif | Bin 0 -> 128 bytes public/images/emoticons/mailto.gif | Bin 0 -> 166 bytes public/images/emoticons/maple.gif | Bin 0 -> 144 bytes public/images/emoticons/memo.gif | Bin 0 -> 118 bytes public/images/emoticons/mist.gif | Bin 0 -> 165 bytes public/images/emoticons/mobaq.gif | Bin 0 -> 154 bytes public/images/emoticons/mobilephone.gif | Bin 0 -> 154 bytes public/images/emoticons/moneybag.gif | Bin 0 -> 179 bytes public/images/emoticons/moon1.gif | Bin 0 -> 139 bytes public/images/emoticons/moon2.gif | Bin 0 -> 125 bytes public/images/emoticons/moon3.gif | Bin 0 -> 124 bytes public/images/emoticons/motorsports.gif | Bin 0 -> 121 bytes public/images/emoticons/movie.gif | Bin 0 -> 176 bytes public/images/emoticons/music.gif | Bin 0 -> 124 bytes public/images/emoticons/new.gif | Bin 0 -> 130 bytes public/images/emoticons/newmoon.gif | Bin 0 -> 87 bytes public/images/emoticons/ng.gif | Bin 0 -> 170 bytes public/images/emoticons/night.gif | Bin 0 -> 163 bytes public/images/emoticons/nine.gif | Bin 0 -> 173 bytes public/images/emoticons/noodle.gif | Bin 0 -> 265 bytes public/images/emoticons/nosmoking.gif | Bin 0 -> 146 bytes public/images/emoticons/note.gif | Bin 0 -> 159 bytes public/images/emoticons/notes.gif | Bin 0 -> 118 bytes public/images/emoticons/ok.gif | Bin 0 -> 173 bytes public/images/emoticons/on.gif | Bin 0 -> 118 bytes public/images/emoticons/one.gif | Bin 0 -> 173 bytes public/images/emoticons/paper.gif | Bin 0 -> 126 bytes public/images/emoticons/parking.gif | Bin 0 -> 113 bytes public/images/emoticons/pass.gif | Bin 0 -> 181 bytes public/images/emoticons/pc.gif | Bin 0 -> 169 bytes public/images/emoticons/pen.gif | Bin 0 -> 136 bytes public/images/emoticons/pencil.gif | Bin 0 -> 157 bytes public/images/emoticons/penguin.gif | Bin 0 -> 174 bytes public/images/emoticons/phoneto.gif | Bin 0 -> 170 bytes public/images/emoticons/pig.gif | Bin 0 -> 177 bytes public/images/emoticons/pisces.gif | Bin 0 -> 146 bytes public/images/emoticons/pocketbell.gif | Bin 0 -> 159 bytes public/images/emoticons/postoffice.gif | Bin 0 -> 163 bytes public/images/emoticons/pouch.gif | Bin 0 -> 172 bytes public/images/emoticons/pout.gif | Bin 0 -> 152 bytes public/images/emoticons/present.gif | Bin 0 -> 186 bytes public/images/emoticons/punch.gif | Bin 0 -> 133 bytes public/images/emoticons/r-mark.gif | Bin 0 -> 127 bytes public/images/emoticons/rain.gif | Bin 0 -> 306 bytes public/images/emoticons/recycle.gif | Bin 0 -> 132 bytes public/images/emoticons/restaurant.gif | Bin 0 -> 162 bytes public/images/emoticons/ribbon.gif | Bin 0 -> 149 bytes public/images/emoticons/riceball.gif | Bin 0 -> 162 bytes public/images/emoticons/ring.gif | Bin 0 -> 161 bytes public/images/emoticons/rock.gif | Bin 0 -> 137 bytes public/images/emoticons/rouge.gif | Bin 0 -> 220 bytes public/images/emoticons/run.gif | Bin 0 -> 229 bytes public/images/emoticons/rvcar.gif | Bin 0 -> 231 bytes public/images/emoticons/sad.gif | Bin 0 -> 156 bytes public/images/emoticons/sagittarius.gif | Bin 0 -> 174 bytes public/images/emoticons/sandclock.gif | Bin 0 -> 188 bytes public/images/emoticons/school.gif | Bin 0 -> 245 bytes public/images/emoticons/scissors.gif | Bin 0 -> 135 bytes public/images/emoticons/scorpius.gif | Bin 0 -> 150 bytes public/images/emoticons/search.gif | Bin 0 -> 163 bytes public/images/emoticons/secret.gif | Bin 0 -> 186 bytes public/images/emoticons/seven.gif | Bin 0 -> 173 bytes public/images/emoticons/shadow.gif | Bin 0 -> 117 bytes public/images/emoticons/sharp.gif | Bin 0 -> 175 bytes public/images/emoticons/shine.gif | Bin 0 -> 170 bytes public/images/emoticons/ship.gif | Bin 0 -> 161 bytes public/images/emoticons/shock.gif | Bin 0 -> 325 bytes public/images/emoticons/shoe.gif | Bin 0 -> 157 bytes public/images/emoticons/sign01.gif | Bin 0 -> 110 bytes public/images/emoticons/sign02.gif | Bin 0 -> 137 bytes public/images/emoticons/sign03.gif | Bin 0 -> 133 bytes public/images/emoticons/sign04.gif | Bin 0 -> 86 bytes public/images/emoticons/sign05.gif | Bin 0 -> 104 bytes public/images/emoticons/signaler.gif | Bin 0 -> 236 bytes public/images/emoticons/six.gif | Bin 0 -> 175 bytes public/images/emoticons/ski.gif | Bin 0 -> 116 bytes public/images/emoticons/slate.gif | Bin 0 -> 121 bytes public/images/emoticons/sleepy.gif | Bin 0 -> 82 bytes public/images/emoticons/smile.gif | Bin 0 -> 134 bytes public/images/emoticons/smoking.gif | Bin 0 -> 206 bytes public/images/emoticons/snail.gif | Bin 0 -> 189 bytes public/images/emoticons/snow.gif | Bin 0 -> 297 bytes public/images/emoticons/snowboard.gif | Bin 0 -> 190 bytes public/images/emoticons/soccer.gif | Bin 0 -> 157 bytes public/images/emoticons/soon.gif | Bin 0 -> 111 bytes public/images/emoticons/spa.gif | Bin 0 -> 137 bytes public/images/emoticons/spade.gif | Bin 0 -> 125 bytes public/images/emoticons/sports.gif | Bin 0 -> 168 bytes public/images/emoticons/sprinkle.gif | Bin 0 -> 156 bytes public/images/emoticons/subway.gif | Bin 0 -> 234 bytes public/images/emoticons/sun.gif | Bin 0 -> 197 bytes public/images/emoticons/sweat01.gif | Bin 0 -> 143 bytes public/images/emoticons/sweat02.gif | Bin 0 -> 156 bytes public/images/emoticons/t-shirt.gif | Bin 0 -> 164 bytes public/images/emoticons/taurus.gif | Bin 0 -> 188 bytes public/images/emoticons/telephone.gif | Bin 0 -> 145 bytes public/images/emoticons/tennis.gif | Bin 0 -> 159 bytes public/images/emoticons/think.gif | Bin 0 -> 82 bytes public/images/emoticons/three.gif | Bin 0 -> 175 bytes public/images/emoticons/thunder.gif | Bin 0 -> 217 bytes public/images/emoticons/ticket.gif | Bin 0 -> 128 bytes public/images/emoticons/tm.gif | Bin 0 -> 93 bytes public/images/emoticons/toilet.gif | Bin 0 -> 169 bytes public/images/emoticons/train.gif | Bin 0 -> 162 bytes public/images/emoticons/tulip.gif | Bin 0 -> 185 bytes public/images/emoticons/tv.gif | Bin 0 -> 164 bytes public/images/emoticons/two.gif | Bin 0 -> 172 bytes public/images/emoticons/typhoon.gif | Bin 0 -> 657 bytes public/images/emoticons/up.gif | Bin 0 -> 125 bytes public/images/emoticons/updown.gif | Bin 0 -> 104 bytes public/images/emoticons/upwardleft.gif | Bin 0 -> 109 bytes public/images/emoticons/upwardright.gif | Bin 0 -> 114 bytes public/images/emoticons/virgo.gif | Bin 0 -> 252 bytes public/images/emoticons/watch.gif | Bin 0 -> 143 bytes public/images/emoticons/wave.gif | Bin 0 -> 185 bytes public/images/emoticons/weep.gif | Bin 0 -> 170 bytes public/images/emoticons/wheelchair.gif | Bin 0 -> 100 bytes public/images/emoticons/wine.gif | Bin 0 -> 166 bytes public/images/emoticons/wink.gif | Bin 0 -> 142 bytes public/images/emoticons/wobbly.gif | Bin 0 -> 156 bytes public/images/emoticons/wrench.gif | Bin 0 -> 123 bytes public/images/emoticons/xmas.gif | Bin 0 -> 159 bytes public/images/emoticons/yacht.gif | Bin 0 -> 170 bytes public/images/emoticons/yen.gif | Bin 0 -> 134 bytes public/images/emoticons/zero.gif | Bin 0 -> 173 bytes public/images/entry/entry_btn1.gif | Bin 0 -> 1385 bytes public/images/entry/entry_btn1_ov.gif | Bin 0 -> 1378 bytes public/images/entry/entry_btn2.gif | Bin 0 -> 1305 bytes public/images/entry/entry_btn2_ov.gif | Bin 0 -> 1303 bytes public/images/entry/entry_btn3.gif | Bin 0 -> 1087 bytes public/images/entry/entry_btn3_ov.gif | Bin 0 -> 1090 bytes public/images/foot_bg.gif | Bin 0 -> 282 bytes public/images/foot_btm.gif | Bin 0 -> 1273 bytes public/images/foot_left.gif | Bin 0 -> 1267 bytes public/images/goods_btn.gif | Bin 0 -> 2247 bytes public/images/goods_btn_l.gif | Bin 0 -> 7532 bytes public/images/goods_btn_ov.gif | Bin 0 -> 2335 bytes public/images/h2_bg.gif | Bin 0 -> 2620 bytes public/images/h3_bg.gif | Bin 0 -> 6198 bytes public/images/head_bg.gif | Bin 0 -> 5006 bytes public/images/indicator.gif | Bin 0 -> 1844 bytes public/images/item/cart_btn.gif | Bin 0 -> 2704 bytes public/images/item/cart_btn_ov.gif | Bin 0 -> 2684 bytes public/images/item/gt.gif | Bin 0 -> 633 bytes public/images/item/kuchi_btn.gif | Bin 0 -> 2437 bytes public/images/item/kuchi_btn_ov.gif | Bin 0 -> 2436 bytes public/images/item/kuchi_t.gif | Bin 0 -> 1695 bytes public/images/item/lt.gif | Bin 0 -> 631 bytes public/images/item/reco_bg.gif | Bin 0 -> 70 bytes public/images/item/reco_bg_btm.gif | Bin 0 -> 222 bytes public/images/item/reco_hr.gif | Bin 0 -> 56 bytes public/images/item/reco_t.gif | Bin 0 -> 3024 bytes public/images/list_mizu.gif | Bin 0 -> 51 bytes public/images/loadingAnimation.gif | Bin 0 -> 5886 bytes public/images/login/login_btm.gif | Bin 0 -> 269 bytes public/images/login/login_mid.gif | Bin 0 -> 80 bytes public/images/login/login_t1.gif | Bin 0 -> 6484 bytes public/images/login/login_t2.gif | Bin 0 -> 6921 bytes public/images/login_logo.png | Bin 0 -> 4526 bytes public/images/logo.gif | Bin 0 -> 3265 bytes public/images/logo_bg.gif | Bin 0 -> 1463 bytes public/images/logout.gif | Bin 0 -> 253 bytes public/images/main_bg.gif | Bin 0 -> 60 bytes public/images/menu_icon.gif | Bin 0 -> 791 bytes public/images/menu_icon_on.gif | Bin 0 -> 784 bytes public/images/menu_l.gif | Bin 0 -> 955 bytes public/images/menu_l_on.gif | Bin 0 -> 1316 bytes public/images/menu_s.gif | Bin 0 -> 1836 bytes public/images/mobile/border.gif | Bin 0 -> 43 bytes public/images/mobile/border_pink.gif | Bin 0 -> 70 bytes public/images/mobile/border_pink_q.gif | Bin 0 -> 70 bytes public/images/mobile/border_pink_v.gif | Bin 0 -> 84 bytes public/images/mobile/border_q.gif | Bin 0 -> 43 bytes public/images/mobile/border_v.gif | Bin 0 -> 43 bytes public/images/mobile/dummy01.jpg | Bin 0 -> 1387 bytes public/images/mobile/dummy02.jpg | Bin 0 -> 1585 bytes public/images/mobile/dummy03.jpg | Bin 0 -> 1158 bytes public/images/mobile/dummy04.jpg | Bin 0 -> 1387 bytes public/images/mobile/dummy05.jpg | Bin 0 -> 1127 bytes public/images/mobile/dummy06.jpg | Bin 0 -> 5571 bytes public/images/mobile/dummy07.jpg | Bin 0 -> 8529 bytes public/images/mobile/dummy08.jpg | Bin 0 -> 5622 bytes public/images/mobile/dummy09.jpg | Bin 0 -> 3603 bytes public/images/mobile/logo_q.gif | Bin 0 -> 3731 bytes public/images/mobile/logo_s.gif | Bin 0 -> 1573 bytes public/images/mobile/logo_s_q.gif | Bin 0 -> 1573 bytes public/images/mobile/logo_s_v.gif | Bin 0 -> 1672 bytes public/images/mobile/logo_v.gif | Bin 0 -> 4418 bytes public/images/mobile/rank_title.gif | Bin 0 -> 1200 bytes public/images/mobile/spacer.gif | Bin 0 -> 43 bytes public/images/mobile/spacer_q.gif | Bin 0 -> 43 bytes public/images/mobile/spacer_v.gif | Bin 0 -> 43 bytes public/images/mobile/title_gray_q.gif | Bin 0 -> 256 bytes public/images/mobile/title_gray_v.gif | Bin 0 -> 341 bytes public/images/mobile/title_pink_q.gif | Bin 0 -> 142 bytes public/images/mobile/title_pink_v.gif | Bin 0 -> 184 bytes public/images/mypage/btn01.gif | Bin 0 -> 1202 bytes public/images/mypage/btn01_ov.gif | Bin 0 -> 1210 bytes public/images/mypage/btn02.gif | Bin 0 -> 1107 bytes public/images/mypage/btn02_ov.gif | Bin 0 -> 1105 bytes public/images/mypage/btn03.gif | Bin 0 -> 1146 bytes public/images/mypage/btn03_ov.gif | Bin 0 -> 1157 bytes public/images/mypage/btn04.gif | Bin 0 -> 1337 bytes public/images/mypage/btn04_ov.gif | Bin 0 -> 1340 bytes public/images/mypage/btn05.gif | Bin 0 -> 1529 bytes public/images/mypage/btn05_ov.gif | Bin 0 -> 1522 bytes public/images/mypage/btn06.gif | Bin 0 -> 1317 bytes public/images/mypage/btn06_ov.gif | Bin 0 -> 1315 bytes public/images/mypage/btn07.gif | Bin 0 -> 1376 bytes public/images/mypage/btn07_ov.gif | Bin 0 -> 1373 bytes public/images/mypage/mymenu_1.gif | Bin 0 -> 4183 bytes public/images/mypage/mymenu_1_ov.gif | Bin 0 -> 4154 bytes public/images/mypage/mymenu_2.gif | Bin 0 -> 4352 bytes public/images/mypage/mymenu_2_ov.gif | Bin 0 -> 4322 bytes public/images/mypage/mymenu_3.gif | Bin 0 -> 4289 bytes public/images/mypage/mymenu_3_ov.gif | Bin 0 -> 4255 bytes public/images/mypage/mymenu_4.gif | Bin 0 -> 4102 bytes public/images/mypage/mymenu_4_ov.gif | Bin 0 -> 4129 bytes public/images/mypage/mymenu_t.gif | Bin 0 -> 2387 bytes public/images/mypage/mypage_bg.gif | Bin 0 -> 71 bytes public/images/mypage/mypage_btm.gif | Bin 0 -> 223 bytes public/images/mypage/mypage_t1.gif | Bin 0 -> 2589 bytes public/images/mypage/mypage_t2.gif | Bin 0 -> 3193 bytes public/images/mypage/mypage_t3.gif | Bin 0 -> 2763 bytes public/images/mypage/mypage_t4.gif | Bin 0 -> 2504 bytes public/images/order_btn.gif | Bin 0 -> 2586 bytes public/images/order_btn_l.gif | Bin 0 -> 8107 bytes public/images/order_btn_ov.gif | Bin 0 -> 2622 bytes public/images/site_btn.gif | Bin 0 -> 2619 bytes public/images/site_btn_ov.gif | Bin 0 -> 2543 bytes public/images/store_btn.gif | Bin 0 -> 2427 bytes public/images/store_btn_l.gif | Bin 0 -> 6914 bytes public/images/store_btn_ov.gif | Bin 0 -> 2497 bytes public/images/top/feature01.jpg | Bin 0 -> 3628 bytes public/images/top/feature02.jpg | Bin 0 -> 3661 bytes public/images/top/feature03.jpg | Bin 0 -> 3931 bytes public/images/top/feature04.jpg | Bin 0 -> 4267 bytes public/images/top/more.gif | Bin 0 -> 973 bytes public/images/top/new_item_t.gif | Bin 0 -> 7149 bytes public/images/top/rank1.gif | Bin 0 -> 958 bytes public/images/top/rank1_bg.gif | Bin 0 -> 305 bytes public/images/top/rank2.gif | Bin 0 -> 950 bytes public/images/top/rank2_bg.gif | Bin 0 -> 302 bytes public/images/top/rank3.gif | Bin 0 -> 991 bytes public/images/top/rank3_bg.gif | Bin 0 -> 302 bytes public/images/top/ranking_t.gif | Bin 0 -> 6865 bytes public/images/top/reco_item_t.gif | Bin 0 -> 7523 bytes public/images/top/title_r.gif | Bin 0 -> 2435 bytes public/images/top/top_bg.gif | Bin 0 -> 70 bytes public/images/top/top_bg_btm.gif | Bin 0 -> 222 bytes public/javascripts/active_scaffold/DO_NOT_EDIT | 2 + .../active_scaffold/default/active_scaffold.js | 418 ++ .../active_scaffold/default/dhtml_history.js | 942 +++++ .../active_scaffold/default/form_enhancements.js | 89 + .../active_scaffold/default/rico_corner.js | 370 ++ public/javascripts/admin/admin_user.js | 9 + public/javascripts/admin/campaign.js | 13 + public/javascripts/admin/common.js | 44 + public/javascripts/admin/emoji_palette.js | 760 ++++ public/javascripts/admin/feature_products.js | 22 + public/javascripts/admin/mail_magazine.js | 12 + public/javascripts/admin/order_status.js | 22 + public/javascripts/admin/product_style.js | 28 + public/javascripts/admin/questionnaire.js | 49 + public/javascripts/admin/recommend_product.js | 15 + public/javascripts/admin/shop.js | 67 + public/javascripts/application.js | 67 + public/javascripts/cart_credit.js | 32 + public/javascripts/cart_purchase.js | 23 + public/javascripts/close_popup.js | 7 + public/javascripts/controls.js | 963 +++++ public/javascripts/dragdrop.js | 972 +++++ public/javascripts/effects.js | 1120 +++++ public/javascripts/jquery.bgiframe.js | 100 + public/javascripts/jquery.js | 4376 ++++++++++++++++++++ public/javascripts/kbmj_kuchikomi.js | 43 + public/javascripts/kbmj_recommend.js | 28 + public/javascripts/login.js | 9 + public/javascripts/no_confrict.js | 2 + public/javascripts/prototype.js | 4225 +++++++++++++++++++ public/javascripts/recommender_details.js | 86 + public/javascripts/rollover.js | 53 + public/javascripts/sorry.js | 22 + public/javascripts/thickbox.js | 319 ++ public/javascripts/treemenu.js | 31 + public/javascripts/ui.core.js | 519 +++ public/javascripts/ui.draggable.js | 766 ++++ public/maint/index.html | 16 + public/robots.txt | 5 + public/stylesheets/active_scaffold/DO_NOT_EDIT | 2 + .../active_scaffold/default/stylesheet-ie.css | 35 + .../active_scaffold/default/stylesheet.css | 771 ++++ public/stylesheets/admin.css | 591 +++ public/stylesheets/common.css | 375 ++ public/stylesheets/emoji_palette.css | 58 + public/stylesheets/front/campaign.css | 135 + public/stylesheets/front/cart.css | 232 ++ public/stylesheets/front/category.css | 161 + public/stylesheets/front/common.css | 534 +++ public/stylesheets/front/entry.css | 124 + public/stylesheets/front/features.css | 60 + public/stylesheets/front/item.css | 196 + public/stylesheets/front/login.css | 73 + public/stylesheets/front/mypage.css | 189 + public/stylesheets/front/portal.css | 166 + public/stylesheets/front/questionnaire.css | 42 + public/stylesheets/front/top.css | 165 + public/stylesheets/kanri.css | 24 + public/stylesheets/mobile.css | 25 + public/stylesheets/scaffold.css | 75 + public/stylesheets/thickbox.css | 163 + script/about | 3 + script/autospec | 6 + script/console | 3 + script/dbconsole | 3 + script/destroy | 3 + script/generate | 3 + script/mail | 213 + script/mail_restart.sh | 22 + script/overkill.c | 270 ++ script/performance/benchmarker | 3 + script/performance/profiler | 3 + script/performance/request | 3 + script/plugin | 3 + script/process/inspector | 3 + script/process/reaper | 3 + script/process/spawner | 3 + script/runner | 3 + script/server | 3 + script/spec | 10 + script/spec_server | 9 + spec/authorities_functions.csv | 42 + spec/controllers/accounts_controller_spec.rb | 955 +++++ spec/controllers/admin/accounts_controller_spec.rb | 54 + .../admin/admin_users_controller_spec.rb | 169 + .../admin/authorities_controller_spec.rb | 123 + spec/controllers/admin/base_controller_spec.rb | 13 + .../controllers/admin/campaigns_controller_spec.rb | 186 + .../admin/categories_controller_spec.rb | 118 + .../controllers/admin/customers_controller_spec.rb | 186 + spec/controllers/admin/designs_controller_spec.rb | 65 + .../admin/feature_products_controller_spec.rb | 147 + spec/controllers/admin/features_controller_spec.rb | 111 + spec/controllers/admin/home_controller_spec.rb | 31 + .../mail_magazine_templates_controller_spec.rb | 93 + .../admin/mail_magazines_controller_spec.rb | 203 + .../admin/mail_template_controller_spec.rb | 10 + .../admin/mobile_devices_controller_spec.rb | 100 + .../admin/new_informations_controller_spec.rb | 213 + .../admin/order_statuses_controller_spec.rb | 76 + spec/controllers/admin/orders_controller_spec.rb | 282 ++ spec/controllers/admin/payment_controller_spec.rb | 10 + .../admin/product_styles_controller_spec.rb | 87 + spec/controllers/admin/products_controller_spec.rb | 185 + .../admin/questionnaires_controller_spec.rb | 279 ++ .../admin/recommend_products_controller_spec.rb | 119 + spec/controllers/admin/shops_controller_spec.rb | 651 +++ spec/controllers/admin/status_controller_spec.rb | 10 + .../admin/style_categories_controller_spec.rb | 88 + spec/controllers/admin/styles_controller_spec.rb | 83 + .../admin/totals_controller_others_spec.rb.orig | 141 + spec/controllers/admin/totals_controller_spec.rb | 463 +++ spec/controllers/application_controller_spec.rb | 27 + spec/controllers/base_controller_spec.rb | 60 + spec/controllers/campaigns_controller_spec.rb | 110 + spec/controllers/cart_controller_spec.rb | 489 +++ spec/controllers/features_controller_spec.rb | 44 + spec/controllers/image_resource_controller_spec.rb | 53 + spec/controllers/inquiries_controller_spec.rb | 131 + spec/controllers/portal_controller_spec.rb | 157 + spec/controllers/products_controller_spec.rb | 106 + spec/controllers/questionnaires_controller_spec.rb | 97 + spec/controllers/recommend_controller_spec.rb | 19 + spec/controllers/shop_controller_spec.rb | 31 + spec/customer_csv_upload_for_spec.csv | 3 + spec/customer_upload.csv | 2 + spec/fixtures/admin_users.yml | 170 + spec/fixtures/authorities.yml | 17 + spec/fixtures/authorities_functions.csv | 41 + spec/fixtures/campaigns.yml | 301 ++ spec/fixtures/campaigns_customers.yml | 3 + spec/fixtures/carts.yml | 90 + spec/fixtures/categories.yml | 30 + spec/fixtures/constants.yml | 5 + spec/fixtures/customers.yml | 440 ++ spec/fixtures/delivery_addresses.yml | 120 + spec/fixtures/delivery_dates.yml | 7 + spec/fixtures/delivery_fees.yml | 9 + spec/fixtures/delivery_tickets.yml | 17 + spec/fixtures/delivery_times.yml | 28 + spec/fixtures/delivery_traders.yml | 13 + spec/fixtures/designs.yml | 5 + spec/fixtures/feature_products.yml | 14 + spec/fixtures/features.yml | 27 + spec/fixtures/functions.yml | 3 + spec/fixtures/image_resources.yml | 23 + spec/fixtures/inquiries.yml | 16 + spec/fixtures/kiyakus.yml | 26 + spec/fixtures/laws.yml | 30 + spec/fixtures/mail_magazine_templates.yml | 25 + spec/fixtures/mail_magazines.yml | 15 + spec/fixtures/mail_templates.yml | 26 + spec/fixtures/mails.yml | 6 + spec/fixtures/mobile_carriers.yml | 23 + spec/fixtures/mobile_devices.csv | 316 ++ spec/fixtures/new_informations.yml | 35 + spec/fixtures/occupations.yml | 78 + spec/fixtures/order_deliveries.yml | 608 +++ spec/fixtures/order_details.yml | 363 ++ spec/fixtures/orders.yml | 114 + spec/fixtures/payments.yml | 37 + spec/fixtures/prefectures.yml | 283 ++ spec/fixtures/privacies.yml | 4 + spec/fixtures/product_access_logs.yml | 13 + spec/fixtures/product_statuses.yml | 36 + spec/fixtures/product_styles.yml | 195 + spec/fixtures/products.yml | 335 ++ spec/fixtures/question_answers.yml | 95 + spec/fixtures/question_choices.yml | 172 + spec/fixtures/questionnaire_answers.yml | 117 + spec/fixtures/questionnaires.yml | 58 + spec/fixtures/questions.yml | 101 + spec/fixtures/recommend_products.yml | 39 + spec/fixtures/recommend_xmls.yml | 17 + spec/fixtures/resource_datas.yml | 1872 +++++++++ spec/fixtures/seos.yml | 38 + spec/fixtures/shops.yml | 24 + spec/fixtures/statuses.yml | 9 + spec/fixtures/style_categories.yml | 43 + spec/fixtures/styles.yml | 37 + spec/fixtures/sub_products.yml | 7 + spec/fixtures/systems.yml | 6 + spec/fixtures/totals/admin_users.yml | 170 + spec/fixtures/totals/customers.yml | 266 ++ spec/fixtures/totals/occupations.yml | 78 + spec/fixtures/totals/order_deliveries.yml | 901 ++++ spec/fixtures/totals/order_details.yml | 300 ++ spec/fixtures/totals/orders.yml | 75 + spec/fixtures/totals/product_styles.yml | 970 +++++ spec/fixtures/totals/products.yml | 1051 +++++ spec/fixtures/zips.yml | 33 + spec/functions.yml | 245 ++ spec/helpers/accounts_helper_spec.rb | 11 + spec/helpers/admin/account_helper_spec.rb | 11 + spec/helpers/admin/admin_user_helper_spec.rb | 11 + spec/helpers/admin/authorities_helper_spec.rb | 11 + spec/helpers/admin/campaigns_helper_spec.rb | 11 + spec/helpers/admin/categories_helper_spec.rb | 11 + spec/helpers/admin/design_helper_spec.rb | 11 + spec/helpers/admin/feature_products_helper_spec.rb | 11 + spec/helpers/admin/features_helper_spec.rb | 11 + spec/helpers/admin/home_helper_spec.rb | 11 + spec/helpers/admin/kiyaku_helper_spec.rb | 11 + spec/helpers/admin/mail_magazine_helper_spec.rb | 11 + .../admin/mail_magazine_template_helper_spec.rb | 11 + spec/helpers/admin/mail_template_helper_spec.rb | 11 + spec/helpers/admin/mobile_device_helper_spec.rb | 11 + spec/helpers/admin/new_informations_helper_spec.rb | 11 + spec/helpers/admin/order_helper_spec.rb | 11 + spec/helpers/admin/order_status_helper_spec.rb | 11 + spec/helpers/admin/order_statuses_helper_spec.rb | 11 + spec/helpers/admin/payment_helper_spec.rb | 11 + spec/helpers/admin/product_helper_spec.rb | 11 + spec/helpers/admin/product_styles_helper_spec.rb | 11 + spec/helpers/admin/questionnaires_helper_spec.rb | 11 + .../admin/recommend_products_helper_spec.rb | 11 + spec/helpers/admin/shops_helper_spec.rb | 11 + spec/helpers/admin/total_helper_spec.rb | 11 + spec/helpers/application_helper_spec.rb | 21 + spec/helpers/base_helper_spec.rb | 22 + spec/helpers/campaigns_helper_spec.rb | 11 + spec/helpers/cart_helper_spec.rb | 62 + spec/helpers/features_helper_spec.rb | 11 + spec/helpers/image_resource_helper_spec.rb | 11 + spec/helpers/inquiries_helper_spec.rb | 11 + spec/helpers/portal_helper_spec.rb | 11 + spec/helpers/product_helper_spec.rb | 11 + spec/helpers/questionnaire_helper_spec.rb | 11 + spec/helpers/recommend_helper_spec.rb | 11 + spec/helpers/shop_helper_spec.rb | 11 + spec/helpers/user_helper_spec.rb | 10 + spec/models/admin_user_spec.rb | 101 + spec/models/authorities_function_spec.rb | 12 + spec/models/authority_spec.rb | 46 + spec/models/campaign_spec.rb | 117 + spec/models/cart_add_product_form_spec.rb | 47 + spec/models/cart_spec.rb | 66 + spec/models/category_spec.rb | 91 + spec/models/constant_spec.rb | 33 + spec/models/customer_search_form_spec.rb | 124 + spec/models/customer_spec.rb | 539 +++ spec/models/delivery_address_spec.rb | 141 + spec/models/delivery_date_spec.rb | 12 + spec/models/delivery_fee_spec.rb | 37 + spec/models/delivery_ticket_spec.rb | 24 + spec/models/delivery_time_spec.rb | 22 + spec/models/delivery_trader_spec.rb | 50 + spec/models/design_spec.rb | 11 + spec/models/feature_product_spec.rb | 34 + spec/models/feature_spec.rb | 32 + spec/models/function_spec.rb | 11 + spec/models/image_resource_spec.rb | 36 + spec/models/inquiry_spec.rb | 82 + spec/models/kiyaku_spec.rb | 35 + spec/models/laws_spec.rb | 285 ++ spec/models/mail_magazine_contents_form_spec.rb | 32 + spec/models/mail_magazine_search_form_spec.rb | 64 + spec/models/mail_magazine_spec.rb | 11 + spec/models/mail_magazine_template_spec.rb | 48 + spec/models/mail_spec.rb | 11 + spec/models/mail_template_spec.rb | 52 + spec/models/mobile_carrier_spec.rb | 11 + spec/models/mobile_device_spec.rb | 84 + spec/models/new_information_spec.rb | 36 + spec/models/notifier_spec.rb | 97 + spec/models/occupation_spec.rb | 11 + spec/models/order_delivery_spec.rb | 452 ++ spec/models/order_detail_spec.rb | 63 + spec/models/order_spec.rb | 117 + spec/models/payment_spec.rb | 105 + spec/models/prefecture_spec.rb | 11 + spec/models/privacy_spec.rb | 11 + spec/models/product_access_log_spec.rb | 11 + spec/models/product_spec.rb | 326 ++ spec/models/product_status_spec.rb | 12 + spec/models/product_style_spec.rb | 120 + spec/models/question_answer_spec.rb | 29 + spec/models/question_choice_spec.rb | 19 + spec/models/question_spec.rb | 28 + spec/models/questionnaire_answer_spec.rb | 134 + spec/models/questionnaire_spec.rb | 190 + spec/models/recommend_product_spec.rb | 43 + spec/models/recommend_spec.rb | 11 + spec/models/recommend_xml_spec.rb | 11 + spec/models/resource_data_spec.rb | 11 + spec/models/search_form_spec.rb | 50 + spec/models/seo_spec.rb | 46 + spec/models/session_spec.rb | 34 + spec/models/shop_spec.rb | 377 ++ spec/models/status_spec.rb | 11 + spec/models/style_category_spec.rb | 41 + spec/models/style_spec.rb | 35 + spec/models/sub_product_spec.rb | 27 + spec/models/system_spec.rb | 17 + spec/models/zip_spec.rb | 37 + spec/order_status_update.csv | 8 + spec/product_csv_upload_for_spec.csv | 3 + spec/product_csv_upload_image_for_spec.csv | 3 + spec/product_sample.csv | 3 + spec/rcov.opts | 2 + spec/sea1.PNG | Bin 0 -> 31223 bytes spec/spec.opts | 4 + spec/spec_helper.rb | 81 + stories/all.rb | 4 + stories/helper.rb | 3 + test/fixtures/admin_users.yml | 11 + test/fixtures/faqs.yml | 13 + test/test_helper.rb | 38 + test/unit/faq_test.rb | 8 + 1465 files changed, 75165 insertions(+) create mode 100644 COPYRIGHT create mode 100644 README create mode 100644 Rakefile create mode 100644 app/controllers/accounts_controller.rb create mode 100644 app/controllers/admin/accounts_controller.rb create mode 100644 app/controllers/admin/admin_users_controller.rb create mode 100644 app/controllers/admin/authorities_controller.rb create mode 100644 app/controllers/admin/base_controller.rb create mode 100644 app/controllers/admin/campaigns_controller.rb create mode 100644 app/controllers/admin/categories_controller.rb create mode 100644 app/controllers/admin/customers_controller.rb create mode 100644 app/controllers/admin/designs_controller.rb create mode 100644 app/controllers/admin/feature_products_controller.rb create mode 100644 app/controllers/admin/features_controller.rb create mode 100644 app/controllers/admin/home_controller.rb create mode 100644 app/controllers/admin/mail_magazine_templates_controller.rb create mode 100644 app/controllers/admin/mail_magazines_controller.rb create mode 100644 app/controllers/admin/mail_template_controller.rb create mode 100644 app/controllers/admin/mobile_devices_controller.rb create mode 100644 app/controllers/admin/new_informations_controller.rb create mode 100644 app/controllers/admin/order_statuses_controller.rb create mode 100644 app/controllers/admin/orders_controller.rb create mode 100644 app/controllers/admin/payment_controller.rb create mode 100644 app/controllers/admin/product_styles_controller.rb create mode 100644 app/controllers/admin/products_controller.rb create mode 100644 app/controllers/admin/questionnaires_controller.rb create mode 100644 app/controllers/admin/recommend_products_controller.rb create mode 100644 app/controllers/admin/shops_controller.rb create mode 100644 app/controllers/admin/status_controller.rb create mode 100644 app/controllers/admin/style_categories_controller.rb create mode 100644 app/controllers/admin/styles_controller.rb create mode 100644 app/controllers/admin/totals_controller.rb create mode 100644 app/controllers/application_controller.rb create mode 100644 app/controllers/base_controller.rb create mode 100644 app/controllers/campaigns_controller.rb create mode 100644 app/controllers/cart_controller.rb create mode 100644 app/controllers/features_controller.rb create mode 100644 app/controllers/image_resource_controller.rb create mode 100644 app/controllers/inquiries_controller.rb create mode 100644 app/controllers/portal_controller.rb create mode 100644 app/controllers/products_controller.rb create mode 100644 app/controllers/questionnaires_controller.rb create mode 100644 app/controllers/recommend_controller.rb create mode 100644 app/controllers/shop_controller.rb create mode 100644 app/helpers/accounts_helper.rb create mode 100644 app/helpers/admin/account_helper.rb create mode 100644 app/helpers/admin/admin_user_helper.rb create mode 100644 app/helpers/admin/authorities_helper.rb create mode 100644 app/helpers/admin/base_helper.rb create mode 100644 app/helpers/admin/campaigns_helper.rb create mode 100644 app/helpers/admin/categories_helper.rb create mode 100644 app/helpers/admin/customers_helper.rb create mode 100644 app/helpers/admin/design_helper.rb create mode 100644 app/helpers/admin/feature_products_helper.rb create mode 100644 app/helpers/admin/features_helper.rb create mode 100644 app/helpers/admin/home_helper.rb create mode 100644 app/helpers/admin/kiyaku_helper.rb create mode 100644 app/helpers/admin/mail_magazine_helper.rb create mode 100644 app/helpers/admin/mail_magazine_template_helper.rb create mode 100644 app/helpers/admin/mail_template_helper.rb create mode 100644 app/helpers/admin/mobile_device_helper.rb create mode 100644 app/helpers/admin/new_informations_helper.rb create mode 100644 app/helpers/admin/order_helper.rb create mode 100644 app/helpers/admin/order_status_helper.rb create mode 100644 app/helpers/admin/order_statuses_helper.rb create mode 100644 app/helpers/admin/payment_helper.rb create mode 100644 app/helpers/admin/product_helper.rb create mode 100644 app/helpers/admin/product_styles_helper.rb create mode 100644 app/helpers/admin/questionnaires_helper.rb create mode 100644 app/helpers/admin/recommend_products_helper.rb create mode 100644 app/helpers/admin/shops_helper.rb create mode 100644 app/helpers/admin/style_category_helper.rb create mode 100644 app/helpers/admin/style_helper.rb create mode 100644 app/helpers/admin/total_helper.rb create mode 100644 app/helpers/application_helper.rb create mode 100644 app/helpers/base_helper.rb create mode 100644 app/helpers/campaign_entry_helper.rb create mode 100644 app/helpers/campaigns_helper.rb create mode 100644 app/helpers/cart_helper.rb create mode 100644 app/helpers/features_helper.rb create mode 100644 app/helpers/image_resource_helper.rb create mode 100644 app/helpers/inquiries_helper.rb create mode 100644 app/helpers/portal_helper.rb create mode 100644 app/helpers/product_helper.rb create mode 100644 app/helpers/questionnaire_helper.rb create mode 100644 app/helpers/recommend_helper.rb create mode 100644 app/helpers/shop_helper.rb create mode 100644 app/helpers/user_helper.rb create mode 100644 app/models/admin_user.rb create mode 100644 app/models/authorities_function.rb create mode 100644 app/models/authority.rb create mode 100644 app/models/campaign.rb create mode 100644 app/models/cart.rb create mode 100755 app/models/cart_add_product_form.rb create mode 100644 app/models/category.rb create mode 100644 app/models/constant.rb create mode 100644 app/models/customer.rb create mode 100644 app/models/customer_search_form.rb create mode 100644 app/models/delivery_address.rb create mode 100644 app/models/delivery_date.rb create mode 100644 app/models/delivery_fee.rb create mode 100644 app/models/delivery_ticket.rb create mode 100644 app/models/delivery_time.rb create mode 100644 app/models/delivery_trader.rb create mode 100644 app/models/design.rb create mode 100644 app/models/design_form.rb create mode 100644 app/models/feature.rb create mode 100644 app/models/feature_product.rb create mode 100644 app/models/function.rb create mode 100644 app/models/image_resource.rb create mode 100644 app/models/inquiry.rb create mode 100644 app/models/kiyaku.rb create mode 100644 app/models/law.rb create mode 100644 app/models/mail.rb create mode 100644 app/models/mail_magazine.rb create mode 100644 app/models/mail_magazine_contents_form.rb create mode 100644 app/models/mail_magazine_search_form.rb create mode 100644 app/models/mail_magazine_template.rb create mode 100644 app/models/mail_template.rb create mode 100644 app/models/mobile_carrier.rb create mode 100644 app/models/mobile_device.rb create mode 100644 app/models/mobile_html_notifier.rb create mode 100644 app/models/new_information.rb create mode 100644 app/models/notifier.rb create mode 100644 app/models/occupation.rb create mode 100644 app/models/order.rb create mode 100644 app/models/order_delivery.rb create mode 100644 app/models/order_detail.rb create mode 100644 app/models/payment.rb create mode 100644 app/models/prefecture.rb create mode 100644 app/models/privacy.rb create mode 100644 app/models/product.rb create mode 100644 app/models/product_access_log.rb create mode 100644 app/models/product_status.rb create mode 100644 app/models/product_style.rb create mode 100644 app/models/question.rb create mode 100644 app/models/question_answer.rb create mode 100644 app/models/question_choice.rb create mode 100644 app/models/questionnaire.rb create mode 100644 app/models/questionnaire_answer.rb create mode 100644 app/models/recommend.rb create mode 100644 app/models/recommend_product.rb create mode 100644 app/models/recommend_xml.rb create mode 100644 app/models/resource_data.rb create mode 100755 app/models/search_form.rb create mode 100644 app/models/seo.rb create mode 100644 app/models/session.rb create mode 100644 app/models/shop.rb create mode 100644 app/models/status.rb create mode 100644 app/models/style.rb create mode 100644 app/models/style_category.rb create mode 100644 app/models/sub_product.rb create mode 100644 app/models/system.rb create mode 100644 app/models/zip.rb create mode 100644 app/views/accounts/_confirm.html.erb create mode 100644 app/views/accounts/_confirm_mobile.html.erb create mode 100644 app/views/accounts/_delivery_form.html.erb create mode 100644 app/views/accounts/_delivery_form_0.html.erb create mode 100644 app/views/accounts/_delivery_form_1.html.erb create mode 100644 app/views/accounts/_footer_mobile.html.erb create mode 100644 app/views/accounts/_form.html.erb create mode 100644 app/views/accounts/_form_mobile.html.erb create mode 100644 app/views/accounts/_form_mobile_0.html.erb create mode 100644 app/views/accounts/_form_mobile_1.html.erb create mode 100644 app/views/accounts/_form_mobile_2.html.erb create mode 100644 app/views/accounts/_mobile_domain_mobile.html.erb create mode 100644 app/views/accounts/activate.html.erb create mode 100644 app/views/accounts/activate_mobile.html.erb create mode 100644 app/views/accounts/close_popup.html.erb create mode 100644 app/views/accounts/delivery_confirm.html.erb create mode 100644 app/views/accounts/delivery_confirm_mobile.html.erb create mode 100644 app/views/accounts/delivery_confirm_popup.html.erb create mode 100644 app/views/accounts/delivery_edit.html.erb create mode 100644 app/views/accounts/delivery_edit_mobile.html.erb create mode 100644 app/views/accounts/delivery_edit_popup.html.erb create mode 100644 app/views/accounts/delivery_list.html.erb create mode 100644 app/views/accounts/delivery_list_mobile.html.erb create mode 100644 app/views/accounts/delivery_new.html.erb create mode 100644 app/views/accounts/delivery_new_mobile.html.erb create mode 100644 app/views/accounts/delivery_new_popup.html.erb create mode 100644 app/views/accounts/edit.html.erb create mode 100644 app/views/accounts/edit_complete.html.erb create mode 100644 app/views/accounts/edit_complete_mobile.html.erb create mode 100644 app/views/accounts/edit_confirm.html.erb create mode 100644 app/views/accounts/edit_confirm_mobile.html.erb create mode 100644 app/views/accounts/edit_mobile.html.erb create mode 100644 app/views/accounts/history_list.html.erb create mode 100644 app/views/accounts/history_list_mobile.html.erb create mode 100644 app/views/accounts/history_show.html.erb create mode 100644 app/views/accounts/history_show_mobile.html.erb create mode 100644 app/views/accounts/kiyaku.html.erb create mode 100644 app/views/accounts/kiyaku_intro_mobile.html.erb create mode 100644 app/views/accounts/kiyaku_mobile.html.erb create mode 100644 app/views/accounts/login.html.erb create mode 100644 app/views/accounts/login_mobile.html.erb create mode 100644 app/views/accounts/logout.html.erb create mode 100644 app/views/accounts/myindex_mobile.html.erb create mode 100644 app/views/accounts/regmailst_mobile_au.html.erb create mode 100644 app/views/accounts/regmailst_mobile_docomo.html.erb create mode 100644 app/views/accounts/regmailst_mobile_softbank.html.erb create mode 100644 app/views/accounts/reminder.html.erb create mode 100644 app/views/accounts/reminder_complete.html.erb create mode 100644 app/views/accounts/reminder_complete_mobile.html.erb create mode 100644 app/views/accounts/reminder_hint.html.erb create mode 100644 app/views/accounts/reminder_hint_mobile.html.erb create mode 100644 app/views/accounts/reminder_mobile.html.erb create mode 100644 app/views/accounts/salvage.html.erb create mode 100644 app/views/accounts/salvage_complete.html.erb create mode 100644 app/views/accounts/salvage_complete_mobile.html.erb create mode 100644 app/views/accounts/salvage_mobile.html.erb create mode 100644 app/views/accounts/signup.html.erb create mode 100644 app/views/accounts/signup_complete.html.erb create mode 100644 app/views/accounts/signup_complete_mobile.html.erb create mode 100644 app/views/accounts/signup_confirm.html.erb create mode 100644 app/views/accounts/signup_confirm_mobile.html.erb create mode 100644 app/views/accounts/signup_mobile.html.erb create mode 100644 app/views/accounts/withdraw.html.erb create mode 100644 app/views/accounts/withdraw_complete.html.erb create mode 100644 app/views/accounts/withdraw_complete_mobile.html.erb create mode 100644 app/views/accounts/withdraw_confirm.html.erb create mode 100644 app/views/accounts/withdraw_confirm_mobile.html.erb create mode 100644 app/views/accounts/withdraw_mobile.html.erb create mode 100644 app/views/admin/accounts/login.html.erb create mode 100644 app/views/admin/accounts/logout.html.erb create mode 100644 app/views/admin/admin_users/_form.html.erb create mode 100644 app/views/admin/admin_users/_submenu.html.erb create mode 100644 app/views/admin/admin_users/edit.html.erb create mode 100644 app/views/admin/admin_users/index.html.erb create mode 100644 app/views/admin/admin_users/new.html.erb create mode 100644 app/views/admin/authorities/_form.html.erb create mode 100644 app/views/admin/authorities/_submenu.html.erb create mode 100644 app/views/admin/authorities/edit.html.erb create mode 100644 app/views/admin/authorities/index.html.erb create mode 100644 app/views/admin/authorities/new.html.erb create mode 100644 app/views/admin/base/_form.rhtml create mode 100644 app/views/admin/base/_product_submenu.html.erb create mode 100644 app/views/admin/base/_search.rhtml create mode 100644 app/views/admin/base/_shop_submenu.html.erb create mode 100644 app/views/admin/base/confirm.rhtml create mode 100644 app/views/admin/base/edit.rhtml create mode 100644 app/views/admin/base/list.rhtml create mode 100644 app/views/admin/base/new.rhtml create mode 100644 app/views/admin/campaigns/_form.html.erb create mode 100644 app/views/admin/campaigns/_submenu.html.erb create mode 100644 app/views/admin/campaigns/campaign_design.html.erb create mode 100644 app/views/admin/campaigns/edit.html.erb create mode 100644 app/views/admin/campaigns/index.html.erb create mode 100644 app/views/admin/campaigns/new.html.erb create mode 100644 app/views/admin/categories/_form.html.erb create mode 100644 app/views/admin/categories/_submenu.html.erb create mode 100644 app/views/admin/categories/index.html.erb create mode 100644 app/views/admin/customers/_form.html.erb create mode 100644 app/views/admin/customers/_search.html.erb create mode 100644 app/views/admin/customers/_submenu.html.erb create mode 100644 app/views/admin/customers/confirm.html.erb create mode 100644 app/views/admin/customers/edit.html.erb create mode 100644 app/views/admin/customers/index.html.erb create mode 100644 app/views/admin/customers/search.html.erb create mode 100644 app/views/admin/designs/_submenu.html.erb create mode 100644 app/views/admin/designs/mobile.html.erb create mode 100644 app/views/admin/designs/pc.html.erb create mode 100644 app/views/admin/feature_products/_form.html.erb create mode 100644 app/views/admin/feature_products/_submenu.html.erb create mode 100644 app/views/admin/feature_products/confirm.html.erb create mode 100644 app/views/admin/feature_products/edit.html.erb create mode 100644 app/views/admin/feature_products/index.html.erb create mode 100644 app/views/admin/feature_products/new.html.erb create mode 100644 app/views/admin/feature_products/product_search.html.erb create mode 100644 app/views/admin/features/_form.html.erb create mode 100644 app/views/admin/features/_select_type_form.html.erb create mode 100644 app/views/admin/features/_submenu.html.erb create mode 100644 app/views/admin/features/confirm.html.erb create mode 100644 app/views/admin/features/edit.html.erb create mode 100644 app/views/admin/features/index.html.erb create mode 100644 app/views/admin/features/new.html.erb create mode 100644 app/views/admin/home/_submenu.html.erb create mode 100644 app/views/admin/home/index.html.erb create mode 100644 app/views/admin/mail_magazine_templates/_form.html.erb create mode 100644 app/views/admin/mail_magazine_templates/_submenu.html.erb create mode 100644 app/views/admin/mail_magazine_templates/edit.html.erb create mode 100644 app/views/admin/mail_magazine_templates/index.html.erb create mode 100644 app/views/admin/mail_magazine_templates/new.html.erb create mode 100644 app/views/admin/mail_magazine_templates/preview.html.erb create mode 100644 app/views/admin/mail_magazines/_form.html.erb create mode 100644 app/views/admin/mail_magazines/_mail_contents.html.erb create mode 100644 app/views/admin/mail_magazines/_submenu.html.erb create mode 100644 app/views/admin/mail_magazines/condition_view.html.erb create mode 100644 app/views/admin/mail_magazines/confirm.html.erb create mode 100644 app/views/admin/mail_magazines/history.html.erb create mode 100644 app/views/admin/mail_magazines/index.html.erb create mode 100644 app/views/admin/mail_magazines/preview.html.erb create mode 100644 app/views/admin/mail_magazines/search.html.erb create mode 100644 app/views/admin/mail_magazines/template_search.html.erb create mode 100644 app/views/admin/mobile_devices/_submenu.html.erb create mode 100644 app/views/admin/mobile_devices/index.html.erb create mode 100644 app/views/admin/mobile_devices/list.html.erb create mode 100644 app/views/admin/new_informations/_form.html.erb create mode 100644 app/views/admin/new_informations/_submenu.html.erb create mode 100644 app/views/admin/new_informations/confirm.html.erb create mode 100644 app/views/admin/new_informations/edit.html.erb create mode 100644 app/views/admin/new_informations/index.html.erb create mode 100644 app/views/admin/new_informations/new.html.erb create mode 100644 app/views/admin/order_statuses/_submenu.html.erb create mode 100644 app/views/admin/order_statuses/index.html.erb create mode 100644 app/views/admin/orders/_form.html.erb create mode 100644 app/views/admin/orders/_search.html.erb create mode 100644 app/views/admin/orders/_show.html.erb create mode 100644 app/views/admin/orders/_submenu.html.erb create mode 100644 app/views/admin/orders/edit.html.erb create mode 100644 app/views/admin/orders/index.html.erb create mode 100644 app/views/admin/orders/new.html.erb create mode 100644 app/views/admin/orders/search.html.erb create mode 100644 app/views/admin/orders/select_delivery_time.html.erb create mode 100644 app/views/admin/orders/show.html.erb create mode 100644 app/views/admin/product_styles/_create_form.html.erb create mode 100644 app/views/admin/product_styles/_form.html.erb create mode 100644 app/views/admin/product_styles/_submenu.html.erb create mode 100644 app/views/admin/product_styles/confirm.html.erb create mode 100644 app/views/admin/product_styles/create_form.html.erb create mode 100644 app/views/admin/product_styles/new.html.erb create mode 100644 app/views/admin/products/_form.html.erb create mode 100644 app/views/admin/products/_search.html.erb create mode 100644 app/views/admin/products/_sub_product.html.erb create mode 100644 app/views/admin/products/_submenu.html.erb create mode 100644 app/views/admin/products/actual_count_index.html.erb create mode 100644 app/views/admin/products/actual_count_search.html.erb create mode 100644 app/views/admin/products/confirm.html.erb create mode 100644 app/views/admin/products/edit.html.erb create mode 100644 app/views/admin/products/index.html.erb create mode 100644 app/views/admin/products/new.html.erb create mode 100644 app/views/admin/products/search.html.erb create mode 100644 app/views/admin/products/show.html.erb create mode 100644 app/views/admin/questionnaires/_form.html.erb create mode 100644 app/views/admin/questionnaires/_submenu.html.erb create mode 100644 app/views/admin/questionnaires/edit.html.erb create mode 100644 app/views/admin/questionnaires/index.html.erb create mode 100644 app/views/admin/questionnaires/new.html.erb create mode 100644 app/views/admin/recommend_products/_form.html.erb create mode 100644 app/views/admin/recommend_products/_submenu.html.erb create mode 100644 app/views/admin/recommend_products/edit.html.erb create mode 100644 app/views/admin/recommend_products/index.html.erb create mode 100644 app/views/admin/recommend_products/new.html.erb create mode 100644 app/views/admin/recommend_products/product_search.html.erb create mode 100644 app/views/admin/shops/_delivery_form.html.erb create mode 100644 app/views/admin/shops/_form.html.erb create mode 100644 app/views/admin/shops/_kiyaku_form.html.erb create mode 100644 app/views/admin/shops/_mail_form.html.erb create mode 100644 app/views/admin/shops/_payment_form.html.erb create mode 100644 app/views/admin/shops/_point_form.html.erb create mode 100644 app/views/admin/shops/_seo_form.html.erb create mode 100644 app/views/admin/shops/_submenu.html.erb create mode 100644 app/views/admin/shops/_tradelaw_form.html.erb create mode 100644 app/views/admin/shops/delivery_edit.html.erb create mode 100644 app/views/admin/shops/delivery_index.html.erb create mode 100644 app/views/admin/shops/delivery_new.html.erb create mode 100644 app/views/admin/shops/index.html.erb create mode 100644 app/views/admin/shops/kiyaku_index.html.erb create mode 100644 app/views/admin/shops/mail_index.html.erb create mode 100644 app/views/admin/shops/payment_complete.html.erb create mode 100644 app/views/admin/shops/payment_edit.html.erb create mode 100644 app/views/admin/shops/payment_index.html.erb create mode 100644 app/views/admin/shops/payment_new.html.erb create mode 100644 app/views/admin/shops/point_index.html.erb create mode 100644 app/views/admin/shops/privacy.html.erb create mode 100644 app/views/admin/shops/seo_index.html.erb create mode 100644 app/views/admin/shops/tradelaw_index.html.erb create mode 100644 app/views/admin/stock/_submenu.html.erb create mode 100644 app/views/admin/stock/confirm.html.erb create mode 100644 app/views/admin/stock/list.html.erb create mode 100644 app/views/admin/stock/new.html.erb create mode 100644 app/views/admin/style_categories/_form.html.erb create mode 100644 app/views/admin/style_categories/_submenu.html.erb create mode 100644 app/views/admin/style_categories/index.html.erb create mode 100644 app/views/admin/styles/_form.html.erb create mode 100644 app/views/admin/styles/_submenu.html.erb create mode 100644 app/views/admin/styles/index.html.erb create mode 100644 app/views/admin/totals/_submenu.html.erb create mode 100644 app/views/admin/totals/index.html.erb create mode 100755 app/views/base/_add_cart.html.erb create mode 100755 app/views/base/_add_cart_mobile.html.erb create mode 100644 app/views/base/_cart.html.erb create mode 100644 app/views/base/_category.html.erb create mode 100644 app/views/base/_category_mobile.html.erb create mode 100644 app/views/base/_left_sidebar.html.erb create mode 100644 app/views/base/_new_product.html.erb create mode 100644 app/views/base/_recommend_asp.html.erb create mode 100755 app/views/base/_recommend_asp_mobile.html.erb create mode 100644 app/views/base/_recommend_product.html.erb create mode 100644 app/views/base/_recommend_product_mobile.html.erb create mode 100644 app/views/base/_recommend_ranking.html.erb create mode 100755 app/views/base/_recommend_ranking_mobile.html.erb create mode 100644 app/views/base/_right_sidebar.html.erb create mode 100644 app/views/base/_title_mobile.html.erb create mode 100644 app/views/campaigns/complete.html.erb create mode 100644 app/views/campaigns/complete_mobile.html.erb create mode 100644 app/views/campaigns/show.html.erb create mode 100644 app/views/campaigns/show_mobile.html.erb create mode 100755 app/views/cart/405.html.erb create mode 100644 app/views/cart/_address_list.html.erb create mode 100644 app/views/cart/_address_list_mobile.html.erb create mode 100644 app/views/cart/_login_form.html.erb create mode 100644 app/views/cart/_login_form_mobile.html.erb create mode 100755 app/views/cart/_order_delivery_hiddens.html.erb create mode 100644 app/views/cart/add_product.html.erb create mode 100644 app/views/cart/complete.html.erb create mode 100644 app/views/cart/complete_mobile.html.erb create mode 100644 app/views/cart/confirm.html.erb create mode 100644 app/views/cart/confirm_mobile.html.erb create mode 100644 app/views/cart/purchase.html.erb create mode 100644 app/views/cart/purchase2_mobile.html.erb create mode 100644 app/views/cart/purchase_mobile.html.erb create mode 100755 app/views/cart/purchase_select_payment.rjs create mode 100755 app/views/cart/select_delivery_time.html.erb create mode 100644 app/views/cart/shipping.html.erb create mode 100644 app/views/cart/shipping_mobile.html.erb create mode 100644 app/views/cart/show.html.erb create mode 100644 app/views/cart/show_mobile.html.erb create mode 100644 app/views/cart/temporary_shipping.html.erb create mode 100644 app/views/cart/temporary_shipping_mobile.html.erb create mode 100644 app/views/features/_free.html.erb create mode 100644 app/views/features/_product.html.erb create mode 100644 app/views/features/show.html.erb create mode 100644 app/views/inquiries/complete.html.erb create mode 100644 app/views/inquiries/complete_mobile.html.erb create mode 100644 app/views/inquiries/confirm.html.erb create mode 100644 app/views/inquiries/confirm_mobile.html.erb create mode 100644 app/views/inquiries/new.html.erb create mode 100644 app/views/inquiries/new_mobile.html.erb create mode 100644 app/views/inquiries/privacy_mobile.html.erb create mode 100644 app/views/inquiries/show_mobile.html.erb create mode 100644 app/views/layouts/admin/base.html.erb create mode 100644 app/views/layouts/base.html.erb create mode 100644 app/views/layouts/base_mobile.html.erb create mode 100755 app/views/notifier/activate.html.erb create mode 100755 app/views/notifier/activate_mobile.html.erb create mode 100755 app/views/notifier/buying_complete.html.erb create mode 100644 app/views/notifier/buying_complete_mobile.html.erb create mode 100644 app/views/notifier/html_mailmagazine.html.erb create mode 100644 app/views/notifier/mobile_inquiry.html.erb create mode 100644 app/views/notifier/mobile_reminder.html.erb create mode 100644 app/views/notifier/pc_inquiry.html.erb create mode 100644 app/views/notifier/received_inquiry.html.erb create mode 100644 app/views/notifier/reminder.html.erb create mode 100644 app/views/notifier/text_mailmagazine.html.erb create mode 100644 app/views/portal/_footer_mobile.html.erb create mode 100644 app/views/portal/_new_information.html.erb create mode 100755 app/views/portal/_new_information_mobile.html.erb create mode 100644 app/views/portal/company.html.erb create mode 100644 app/views/portal/escape_clause.html.erb create mode 100644 app/views/portal/first_one_mobile.html.erb create mode 100755 app/views/portal/maintenance.html.erb create mode 100755 app/views/portal/maintenance_mobile.html.erb create mode 100755 app/views/portal/mymenu_mobile.html.erb create mode 100755 app/views/portal/notice.html.erb create mode 100755 app/views/portal/notice_mobile.html.erb create mode 100644 app/views/portal/privacy.html.erb create mode 100644 app/views/portal/privacy_mobile.html.erb create mode 100644 app/views/portal/show.html.erb create mode 100644 app/views/portal/show_mobile.html.erb create mode 100644 app/views/portal/show_tradelaw.html.erb create mode 100644 app/views/portal/show_tradelaw_mobile.html.erb create mode 100755 app/views/portal/supported_device_mobile.html.erb create mode 100644 app/views/portal/unsupported_device_mobile.html.erb create mode 100644 app/views/products/_form.html.erb create mode 100644 app/views/products/_recommend_products.html.erb create mode 100644 app/views/products/index.html.erb create mode 100644 app/views/products/index_mobile.html.erb create mode 100644 app/views/products/review_complete.html.erb create mode 100644 app/views/products/review_confirm.html.erb create mode 100644 app/views/products/review_new.html.erb create mode 100644 app/views/products/show.html.erb create mode 100644 app/views/products/show_image.html.erb create mode 100644 app/views/products/show_mobile.html.erb create mode 100755 app/views/products/stock_table.html.erb create mode 100644 app/views/questionnaires/complete.html.erb create mode 100644 app/views/questionnaires/complete_mobile.html.erb create mode 100644 app/views/questionnaires/confirm.html.erb create mode 100644 app/views/questionnaires/confirm_mobile.html.erb create mode 100644 app/views/questionnaires/new.html.erb create mode 100644 app/views/questionnaires/new_mobile.html.erb create mode 100644 app/views/recommend/tsv.html.erb create mode 100644 app/views/resource/thumbnail.html.erb create mode 100644 app/views/shop/about.html.erb create mode 100644 app/views/user/_address_confirm.html.erb create mode 100644 app/views/user/_address_form.html.erb create mode 100644 app/views/user/_address_list.html.erb create mode 100644 app/views/user/_navigation.html.erb create mode 100644 app/views/user/address_complete.html.erb create mode 100644 app/views/user/address_create.html.erb create mode 100644 app/views/user/address_create_confirm.html.erb create mode 100644 app/views/user/address_delete.html.erb create mode 100644 app/views/user/address_edit.html.erb create mode 100644 app/views/user/address_list.html.erb create mode 100644 app/views/user/address_list_mobile.html.erb create mode 100644 app/views/user/address_new.html.erb create mode 100644 app/views/user/address_show.html.erb create mode 100644 app/views/user/address_update.html.erb create mode 100644 app/views/user/address_update_confirm.html.erb create mode 100644 app/views/user/history_list.html.erb create mode 100644 app/views/user/history_list_mobile.html.erb create mode 100644 app/views/user/history_show.html.erb create mode 100644 app/views/user/mypage_mobile.html.erb create mode 100644 app/views/user/setting.html.erb create mode 100644 app/views/user/setting_mobile.html.erb create mode 100644 app/views/user/show.html.erb create mode 100644 config/boot.rb create mode 100644 config/database.example.yml create mode 100644 config/database.example.yml.sqllite create mode 100644 config/environment.rb create mode 100644 config/environments/development.rb create mode 100644 config/environments/production.rb create mode 100644 config/environments/test.rb create mode 100644 config/initializers/add_csv_download/add_csv_download.rb create mode 100644 config/initializers/backtrace_silencers.rb create mode 100644 config/initializers/inflections.rb create mode 100644 config/initializers/jpmobile_override.rb create mode 100644 config/initializers/mime_types.rb create mode 100644 config/initializers/new_rails_defaults.rb create mode 100644 config/initializers/session_store.rb create mode 100644 config/locales/ja.yml create mode 100644 config/locales/translation_ja.yml create mode 100644 config/routes.rb create mode 100644 db/migrate/20090512061734_create_admin_users.rb create mode 100644 db/migrate/20090512081925_create_authorities.rb create mode 100644 db/migrate/20090512082526_create_authorities_functions.rb create mode 100644 db/migrate/20090512083801_create_campaigns.rb create mode 100644 db/migrate/20090512085119_create_faqs.rb create mode 100644 db/migrate/20090512094800_create_campaigns_customers.rb create mode 100644 db/migrate/20090512095649_create_carts.rb create mode 100644 db/migrate/20090513005806_create_categories.rb create mode 100644 db/migrate/20090513011211_create_functions.rb create mode 100644 db/migrate/20090513013825_create_inquiries.rb create mode 100644 db/migrate/20090513014030_create_constants.rb create mode 100644 db/migrate/20090513014555_create_kiyakus.rb create mode 100644 db/migrate/20090513014834_create_laws.rb create mode 100644 db/migrate/20090513021617_create_mail_magazine_templates.rb create mode 100644 db/migrate/20090513022200_create_mail_magazines.rb create mode 100644 db/migrate/20090513022926_create_mail_templates.rb create mode 100644 db/migrate/20090513024427_create_mails.rb create mode 100644 db/migrate/20090513025820_create_mobile_carriers.rb create mode 100644 db/migrate/20090513030410_create_mobile_devices.rb create mode 100644 db/migrate/20090513031025_create_new_informations.rb create mode 100644 db/migrate/20090513032912_create_occupations.rb create mode 100644 db/migrate/20090513034408_create_order_deliveries.rb create mode 100644 db/migrate/20090513061015_create_customers.rb create mode 100644 db/migrate/20090513061105_create_order_details.rb create mode 100644 db/migrate/20090513064455_create_orders.rb create mode 100644 db/migrate/20090513065225_create_payments.rb create mode 100644 db/migrate/20090513065957_create_prefectures.rb create mode 100644 db/migrate/20090513070304_create_privacies.rb create mode 100644 db/migrate/20090513073327_create_product_access_logs.rb create mode 100644 db/migrate/20090513075659_create_product_statuses.rb create mode 100644 db/migrate/20090513080712_create_question_answers.rb create mode 100644 db/migrate/20090513081253_create_question_choices.rb create mode 100644 db/migrate/20090513081352_create_questionnaire_answers.rb create mode 100644 db/migrate/20090513081453_create_questionnaires.rb create mode 100644 db/migrate/20090513081710_create_questions.rb create mode 100644 db/migrate/20090513081825_create_recommend_products.rb create mode 100644 db/migrate/20090513081950_create_recommend_xmls.rb create mode 100644 db/migrate/20090513082051_create_recommends.rb create mode 100644 db/migrate/20090513082209_create_resource_datas.rb create mode 100644 db/migrate/20090513082300_create_resources.rb create mode 100644 db/migrate/20090513082352_create_seos.rb create mode 100644 db/migrate/20090513082444_create_sessions.rb create mode 100644 db/migrate/20090513082549_create_shops.rb create mode 100644 db/migrate/20090513082754_create_statuses.rb create mode 100644 db/migrate/20090513083035_create_delivery_addresses.rb create mode 100644 db/migrate/20090513083130_create_stock_tables.rb create mode 100644 db/migrate/20090513083630_create_style_categories.rb create mode 100644 db/migrate/20090513083852_create_product_styles.rb create mode 100644 db/migrate/20090513084050_create_delivery_dates.rb create mode 100644 db/migrate/20090513084222_create_styles.rb create mode 100644 db/migrate/20090513084438_create_delivery_fees.rb create mode 100644 db/migrate/20090513084557_create_sub_products.rb create mode 100644 db/migrate/20090513084755_create_products.rb create mode 100644 db/migrate/20090513084925_create_delivery_tickets.rb create mode 100644 db/migrate/20090513085308_create_systems.rb create mode 100644 db/migrate/20090513091318_create_zips.rb create mode 100644 db/migrate/20090513092100_create_delivery_times.rb create mode 100644 db/migrate/20090513092607_create_delivery_traders.rb create mode 100644 db/migrate/20090513093001_create_designs.rb create mode 100644 db/migrate/20090520054539_add_data_functions.rb create mode 100644 db/migrate/20090520063143_create_image_resources.rb create mode 100644 db/migrate/20090521071313_add_date_shop.rb create mode 100644 db/migrate/20090521082527_add_data_statuses.rb create mode 100644 db/migrate/20090601080958_create_recalls.rb create mode 100644 db/migrate/20090601081026_create_recall_details.rb create mode 100644 db/migrate/20090603071104_add_column_designs.rb create mode 100644 db/migrate/20091009022605_create_features.rb create mode 100644 db/migrate/20091009032514_create_feature_products.rb create mode 100644 db/migrate/20091019095808_add_column_shops.rb create mode 100644 db/migrate/20091022105613_add_data_occupations.rb create mode 100644 db/migrate/20091213083945_add_data_mail_templates.rb create mode 100644 db/migrate/20091213085332_add_data_seos.rb create mode 100644 db/migrate/20091213131916_add_data_shops.rb create mode 100644 db/migrate/20091213134247_add_data_systems.rb create mode 100644 db/migrate/fixed_data/authorities.yml create mode 100644 db/migrate/fixed_data/authorities_functions.csv create mode 100644 db/migrate/fixed_data/constants.yml create mode 100644 db/migrate/fixed_data/csv_output_settings.yml create mode 100644 db/migrate/fixed_data/functions.yml create mode 100644 db/migrate/fixed_data/mail_templates.yml create mode 100644 db/migrate/fixed_data/mobile_carriers.csv create mode 100644 db/migrate/fixed_data/mobile_devices.csv create mode 100644 db/migrate/fixed_data/mobile_specs.txt create mode 100644 db/migrate/fixed_data/occupations.yml create mode 100644 db/migrate/fixed_data/prefectures.yml create mode 100644 db/migrate/fixed_data/seos.yml create mode 100644 db/migrate/fixed_data/shops.yml create mode 100644 db/migrate/fixed_data/statuses.yml create mode 100644 db/migrate/fixed_data/systems.yml create mode 100644 db/migrate/fixed_data/target_columns.yml create mode 100644 db/migrate/fixed_data/target_tables.yml create mode 100644 god/common.god create mode 100644 god/production.god create mode 100644 lib/action_view_helper.rb create mode 100644 lib/active_record_helper.rb create mode 100644 lib/create_fixtures.rb create mode 100644 lib/csv_util.rb create mode 100755 lib/recall_controller_module.rb create mode 100644 lib/resource_controller/controller.rb create mode 100644 lib/rexml-expansion-fix.rb create mode 100644 lib/sazanami-gothic.ttf create mode 100644 lib/security_token.rb create mode 100644 lib/tasks/create_fixtures.rake create mode 100644 lib/tasks/rspec.rake create mode 100644 lib/totalizer.rb create mode 100644 lib/validates.rb create mode 100755 lib/veritrans.rb create mode 100644 public/.htaccess create mode 100644 public/404.html create mode 100644 public/404_mobile.html create mode 100644 public/422.html create mode 100644 public/500.html create mode 100644 public/500_mobile.html create mode 100644 public/admin/404.html create mode 100644 public/admin/500.html create mode 100644 public/blank.html create mode 100755 public/dispatch.cgi create mode 100755 public/dispatch.fcgi create mode 100755 public/dispatch.rb create mode 100644 public/favicon.ico create mode 100644 public/images/body_bg.gif create mode 100644 public/images/btn_main.gif create mode 100644 public/images/btn_s.gif create mode 100644 public/images/btn_side.gif create mode 100644 public/images/cart/cart_bg.gif create mode 100644 public/images/cart/cart_btm.gif create mode 100644 public/images/cart/cart_btn01.gif create mode 100644 public/images/cart/cart_btn01_ov.gif create mode 100644 public/images/cart/cart_btn02.gif create mode 100644 public/images/cart/cart_btn02_ov.gif create mode 100644 public/images/cart/cart_btn03.gif create mode 100644 public/images/cart/cart_btn03_ov.gif create mode 100644 public/images/cart/cart_btn04.gif create mode 100644 public/images/cart/cart_btn04_ov.gif create mode 100644 public/images/cart/cart_btn05.gif create mode 100644 public/images/cart/cart_btn05_ov.gif create mode 100644 public/images/cart/cart_t1.gif create mode 100644 public/images/cart/cart_t2.gif create mode 100644 public/images/cart/recalc.gif create mode 100644 public/images/cart/route01.gif create mode 100644 public/images/cart/route02.gif create mode 100644 public/images/cart/route03.gif create mode 100644 public/images/cart/route04.gif create mode 100644 public/images/category/dummy/accessory01.jpg create mode 100644 public/images/category/dummy/accessory02.jpg create mode 100644 public/images/category/dummy/accessory03.jpg create mode 100644 public/images/category/dummy/accessory04.jpg create mode 100644 public/images/category/dummy/accessory05.jpg create mode 100644 public/images/category/dummy/accessory06.jpg create mode 100644 public/images/category/dummy/bag01.jpg create mode 100644 public/images/category/dummy/bag02.jpg create mode 100644 public/images/category/dummy/bag03.jpg create mode 100644 public/images/category/dummy/bag04.jpg create mode 100644 public/images/category/dummy/bag05.jpg create mode 100644 public/images/category/dummy/bottoms01.jpg create mode 100644 public/images/category/dummy/bottoms02.jpg create mode 100644 public/images/category/dummy/bottoms03.jpg create mode 100644 public/images/category/dummy/bottoms04.jpg create mode 100644 public/images/category/dummy/bottoms05.jpg create mode 100644 public/images/category/dummy/bottoms06.jpg create mode 100644 public/images/category/dummy/hat01.jpg create mode 100644 public/images/category/dummy/hat02.jpg create mode 100644 public/images/category/dummy/hat03.jpg create mode 100644 public/images/category/dummy/hat04.jpg create mode 100644 public/images/category/dummy/outer01.jpg create mode 100644 public/images/category/dummy/outer02.jpg create mode 100644 public/images/category/dummy/outer03.jpg create mode 100644 public/images/category/dummy/outer04.jpg create mode 100644 public/images/category/dummy/outer05.jpg create mode 100644 public/images/category/dummy/shoes01.jpg create mode 100644 public/images/category/dummy/shoes02.jpg create mode 100644 public/images/category/dummy/shoes03.jpg create mode 100644 public/images/category/dummy/shoes04.jpg create mode 100644 public/images/category/dummy/shoes05.jpg create mode 100644 public/images/category/dummy/tops01.jpg create mode 100644 public/images/category/dummy/tops02.jpg create mode 100644 public/images/category/dummy/tops03.jpg create mode 100644 public/images/category/dummy/tops04.jpg create mode 100644 public/images/category/dummy/tops05.jpg create mode 100644 public/images/category/head_img.jpg create mode 100644 public/images/category/rank1.gif create mode 100644 public/images/category/rank2.gif create mode 100644 public/images/category/rank3.gif create mode 100644 public/images/category/rank4.gif create mode 100644 public/images/category/rank_t_bg.gif create mode 100644 public/images/common/banner01.jpg create mode 100644 public/images/common/banner02.jpg create mode 100644 public/images/common/banner03.jpg create mode 100644 public/images/common/banner04.jpg create mode 100644 public/images/common/banner_mobile.gif create mode 100644 public/images/common/body_bg.gif create mode 100644 public/images/common/box_bg.gif create mode 100644 public/images/common/box_bg_btm.gif create mode 100644 public/images/common/box_bg_top.gif create mode 100644 public/images/common/btn01.gif create mode 100644 public/images/common/btn02.gif create mode 100644 public/images/common/btn03.gif create mode 100644 public/images/common/cart_btn.gif create mode 100644 public/images/common/cart_btn_ov.gif create mode 100644 public/images/common/check_t.gif create mode 100644 public/images/common/close.png create mode 100644 public/images/common/container_bg.gif create mode 100644 public/images/common/footer_bg.gif create mode 100644 public/images/common/gt.gif create mode 100644 public/images/common/guide_btn.gif create mode 100644 public/images/common/guide_btn_ov.gif create mode 100644 public/images/common/h3_category.gif create mode 100644 public/images/common/h3_info.gif create mode 100644 public/images/common/h3_kuchikomi.gif create mode 100644 public/images/common/h3_login.gif create mode 100644 public/images/common/h3_search.gif create mode 100644 public/images/common/header_bg.jpg create mode 100644 public/images/common/kuchi_01.gif create mode 100644 public/images/common/kuchi_02.gif create mode 100644 public/images/common/kuchi_03.gif create mode 100644 public/images/common/kuchi_04.gif create mode 100644 public/images/common/kuchi_05.gif create mode 100644 public/images/common/kuchi_hr.gif create mode 100644 public/images/common/list_ore.gif create mode 100644 public/images/common/list_ore_s.gif create mode 100644 public/images/common/list_pink.gif create mode 100644 public/images/common/login_btn.gif create mode 100644 public/images/common/login_btn_ov.gif create mode 100644 public/images/common/logo.gif create mode 100644 public/images/common/main_hr.gif create mode 100644 public/images/common/main_t_l.gif create mode 100644 public/images/common/menu_accessory.gif create mode 100644 public/images/common/menu_accessory_ov.gif create mode 100644 public/images/common/menu_bag.gif create mode 100644 public/images/common/menu_bag_ov.gif create mode 100644 public/images/common/menu_bottoms.gif create mode 100644 public/images/common/menu_bottoms_ov.gif create mode 100644 public/images/common/menu_hat.gif create mode 100644 public/images/common/menu_hat_ov.gif create mode 100644 public/images/common/menu_outer.gif create mode 100644 public/images/common/menu_outer_ov.gif create mode 100644 public/images/common/menu_shoes.gif create mode 100644 public/images/common/menu_shoes_ov.gif create mode 100644 public/images/common/menu_tops.gif create mode 100644 public/images/common/menu_tops_ov.gif create mode 100644 public/images/common/mypage_btn.gif create mode 100644 public/images/common/mypage_btn_ov.gif create mode 100644 public/images/common/new_entry_btn.gif create mode 100644 public/images/common/new_entry_btn_ov.gif create mode 100644 public/images/common/pagetop_btn.gif create mode 100644 public/images/common/purchase_btn.gif create mode 100644 public/images/common/purchase_btn_ov.gif create mode 100644 public/images/common/rank_t_bg.gif create mode 100644 public/images/common/search_btn.gif create mode 100644 public/images/common/search_btn_ov.gif create mode 100644 public/images/common/side_bg_btm.gif create mode 100644 public/images/common/side_bg_mid.gif create mode 100644 public/images/common/side_bg_top.gif create mode 100644 public/images/common/side_hr.gif create mode 100644 public/images/common/title_bg.gif create mode 100644 public/images/common/top_img.jpg create mode 100644 public/images/emoticons/24hours.gif create mode 100644 public/images/emoticons/airplane.gif create mode 100644 public/images/emoticons/angry.gif create mode 100644 public/images/emoticons/annoy.gif create mode 100644 public/images/emoticons/apple.gif create mode 100644 public/images/emoticons/appli01.gif create mode 100644 public/images/emoticons/appli02.gif create mode 100644 public/images/emoticons/aquarius.gif create mode 100644 public/images/emoticons/aries.gif create mode 100644 public/images/emoticons/art.gif create mode 100644 public/images/emoticons/atm.gif create mode 100644 public/images/emoticons/bag.gif create mode 100644 public/images/emoticons/ban.gif create mode 100644 public/images/emoticons/banana.gif create mode 100644 public/images/emoticons/bank.gif create mode 100644 public/images/emoticons/bar.gif create mode 100644 public/images/emoticons/baseball.gif create mode 100644 public/images/emoticons/basketball.gif create mode 100644 public/images/emoticons/bearing.gif create mode 100644 public/images/emoticons/beer.gif create mode 100644 public/images/emoticons/bell.gif create mode 100644 public/images/emoticons/bicycle.gif create mode 100644 public/images/emoticons/birthday.gif create mode 100644 public/images/emoticons/bleah.gif create mode 100644 public/images/emoticons/bomb.gif create mode 100644 public/images/emoticons/book.gif create mode 100644 public/images/emoticons/bottle.gif create mode 100644 public/images/emoticons/boutique.gif create mode 100644 public/images/emoticons/bread.gif create mode 100644 public/images/emoticons/bud.gif create mode 100644 public/images/emoticons/building.gif create mode 100644 public/images/emoticons/bullettrain.gif create mode 100644 public/images/emoticons/bus.gif create mode 100644 public/images/emoticons/by-d.gif create mode 100644 public/images/emoticons/cafe.gif create mode 100644 public/images/emoticons/cake.gif create mode 100644 public/images/emoticons/camera.gif create mode 100644 public/images/emoticons/cancer.gif create mode 100644 public/images/emoticons/capricornus.gif create mode 100644 public/images/emoticons/car.gif create mode 100644 public/images/emoticons/carouselpony.gif create mode 100644 public/images/emoticons/cat.gif create mode 100644 public/images/emoticons/catface.gif create mode 100644 public/images/emoticons/cd.gif create mode 100644 public/images/emoticons/chair.gif create mode 100644 public/images/emoticons/cherry.gif create mode 100644 public/images/emoticons/cherryblossom.gif create mode 100644 public/images/emoticons/chick.gif create mode 100644 public/images/emoticons/clear.gif create mode 100644 public/images/emoticons/clip.gif create mode 100644 public/images/emoticons/clock.gif create mode 100644 public/images/emoticons/cloud.gif create mode 100644 public/images/emoticons/clover.gif create mode 100644 public/images/emoticons/club.gif create mode 100644 public/images/emoticons/coldsweats01.gif create mode 100644 public/images/emoticons/coldsweats02.gif create mode 100644 public/images/emoticons/confident.gif create mode 100644 public/images/emoticons/copyright.gif create mode 100644 public/images/emoticons/crown.gif create mode 100644 public/images/emoticons/crying.gif create mode 100644 public/images/emoticons/cute.gif create mode 100644 public/images/emoticons/d-point.gif create mode 100644 public/images/emoticons/danger.gif create mode 100644 public/images/emoticons/dash.gif create mode 100644 public/images/emoticons/delicious.gif create mode 100644 public/images/emoticons/denim.gif create mode 100644 public/images/emoticons/despair.gif create mode 100644 public/images/emoticons/diamond.gif create mode 100644 public/images/emoticons/dog.gif create mode 100644 public/images/emoticons/dollar.gif create mode 100644 public/images/emoticons/door.gif create mode 100644 public/images/emoticons/down.gif create mode 100644 public/images/emoticons/downwardleft.gif create mode 100644 public/images/emoticons/downwardright.gif create mode 100644 public/images/emoticons/drama.gif create mode 100644 public/images/emoticons/ear.gif create mode 100644 public/images/emoticons/eight.gif create mode 100644 public/images/emoticons/emoticons.gif create mode 100644 public/images/emoticons/empty.gif create mode 100644 public/images/emoticons/end.gif create mode 100644 public/images/emoticons/enter.gif create mode 100644 public/images/emoticons/event.gif create mode 100644 public/images/emoticons/eye.gif create mode 100644 public/images/emoticons/eyeglass.gif create mode 100644 public/images/emoticons/fastfood.gif create mode 100644 public/images/emoticons/faxto.gif create mode 100644 public/images/emoticons/fish.gif create mode 100644 public/images/emoticons/five.gif create mode 100644 public/images/emoticons/flag.gif create mode 100644 public/images/emoticons/flair.gif create mode 100644 public/images/emoticons/foot.gif create mode 100644 public/images/emoticons/four.gif create mode 100644 public/images/emoticons/free.gif create mode 100644 public/images/emoticons/freedial.gif create mode 100644 public/images/emoticons/fuji.gif create mode 100644 public/images/emoticons/full.gif create mode 100644 public/images/emoticons/fullmoon.gif create mode 100644 public/images/emoticons/game.gif create mode 100644 public/images/emoticons/gasstation.gif create mode 100644 public/images/emoticons/gawk.gif create mode 100644 public/images/emoticons/gemini.gif create mode 100644 public/images/emoticons/golf.gif create mode 100644 public/images/emoticons/good.gif create mode 100644 public/images/emoticons/hairsalon.gif create mode 100644 public/images/emoticons/happy01.gif create mode 100644 public/images/emoticons/happy02.gif create mode 100644 public/images/emoticons/heart.gif create mode 100644 public/images/emoticons/heart01.gif create mode 100644 public/images/emoticons/heart02.gif create mode 100644 public/images/emoticons/heart03.gif create mode 100644 public/images/emoticons/heart04.gif create mode 100644 public/images/emoticons/horse.gif create mode 100644 public/images/emoticons/hospital.gif create mode 100644 public/images/emoticons/hotel.gif create mode 100644 public/images/emoticons/house.gif create mode 100644 public/images/emoticons/id.gif create mode 100644 public/images/emoticons/impact.gif create mode 100644 public/images/emoticons/info01.gif create mode 100644 public/images/emoticons/info02.gif create mode 100644 public/images/emoticons/japanesetea.gif create mode 100644 public/images/emoticons/karaoke.gif create mode 100644 public/images/emoticons/key.gif create mode 100644 public/images/emoticons/kissmark.gif create mode 100644 public/images/emoticons/leftright.gif create mode 100644 public/images/emoticons/leo.gif create mode 100644 public/images/emoticons/libra.gif create mode 100644 public/images/emoticons/loveletter.gif create mode 100644 public/images/emoticons/lovely.gif create mode 100644 public/images/emoticons/mail.gif create mode 100644 public/images/emoticons/mailto.gif create mode 100644 public/images/emoticons/maple.gif create mode 100644 public/images/emoticons/memo.gif create mode 100644 public/images/emoticons/mist.gif create mode 100644 public/images/emoticons/mobaq.gif create mode 100644 public/images/emoticons/mobilephone.gif create mode 100644 public/images/emoticons/moneybag.gif create mode 100644 public/images/emoticons/moon1.gif create mode 100644 public/images/emoticons/moon2.gif create mode 100644 public/images/emoticons/moon3.gif create mode 100644 public/images/emoticons/motorsports.gif create mode 100644 public/images/emoticons/movie.gif create mode 100644 public/images/emoticons/music.gif create mode 100644 public/images/emoticons/new.gif create mode 100644 public/images/emoticons/newmoon.gif create mode 100644 public/images/emoticons/ng.gif create mode 100644 public/images/emoticons/night.gif create mode 100644 public/images/emoticons/nine.gif create mode 100644 public/images/emoticons/noodle.gif create mode 100644 public/images/emoticons/nosmoking.gif create mode 100644 public/images/emoticons/note.gif create mode 100644 public/images/emoticons/notes.gif create mode 100644 public/images/emoticons/ok.gif create mode 100644 public/images/emoticons/on.gif create mode 100644 public/images/emoticons/one.gif create mode 100644 public/images/emoticons/paper.gif create mode 100644 public/images/emoticons/parking.gif create mode 100644 public/images/emoticons/pass.gif create mode 100644 public/images/emoticons/pc.gif create mode 100644 public/images/emoticons/pen.gif create mode 100644 public/images/emoticons/pencil.gif create mode 100644 public/images/emoticons/penguin.gif create mode 100644 public/images/emoticons/phoneto.gif create mode 100644 public/images/emoticons/pig.gif create mode 100644 public/images/emoticons/pisces.gif create mode 100644 public/images/emoticons/pocketbell.gif create mode 100644 public/images/emoticons/postoffice.gif create mode 100644 public/images/emoticons/pouch.gif create mode 100644 public/images/emoticons/pout.gif create mode 100644 public/images/emoticons/present.gif create mode 100644 public/images/emoticons/punch.gif create mode 100644 public/images/emoticons/r-mark.gif create mode 100644 public/images/emoticons/rain.gif create mode 100644 public/images/emoticons/recycle.gif create mode 100644 public/images/emoticons/restaurant.gif create mode 100644 public/images/emoticons/ribbon.gif create mode 100644 public/images/emoticons/riceball.gif create mode 100644 public/images/emoticons/ring.gif create mode 100644 public/images/emoticons/rock.gif create mode 100644 public/images/emoticons/rouge.gif create mode 100644 public/images/emoticons/run.gif create mode 100644 public/images/emoticons/rvcar.gif create mode 100644 public/images/emoticons/sad.gif create mode 100644 public/images/emoticons/sagittarius.gif create mode 100644 public/images/emoticons/sandclock.gif create mode 100644 public/images/emoticons/school.gif create mode 100644 public/images/emoticons/scissors.gif create mode 100644 public/images/emoticons/scorpius.gif create mode 100644 public/images/emoticons/search.gif create mode 100644 public/images/emoticons/secret.gif create mode 100644 public/images/emoticons/seven.gif create mode 100644 public/images/emoticons/shadow.gif create mode 100644 public/images/emoticons/sharp.gif create mode 100644 public/images/emoticons/shine.gif create mode 100644 public/images/emoticons/ship.gif create mode 100644 public/images/emoticons/shock.gif create mode 100644 public/images/emoticons/shoe.gif create mode 100644 public/images/emoticons/sign01.gif create mode 100644 public/images/emoticons/sign02.gif create mode 100644 public/images/emoticons/sign03.gif create mode 100644 public/images/emoticons/sign04.gif create mode 100644 public/images/emoticons/sign05.gif create mode 100644 public/images/emoticons/signaler.gif create mode 100644 public/images/emoticons/six.gif create mode 100644 public/images/emoticons/ski.gif create mode 100644 public/images/emoticons/slate.gif create mode 100644 public/images/emoticons/sleepy.gif create mode 100644 public/images/emoticons/smile.gif create mode 100644 public/images/emoticons/smoking.gif create mode 100644 public/images/emoticons/snail.gif create mode 100644 public/images/emoticons/snow.gif create mode 100644 public/images/emoticons/snowboard.gif create mode 100644 public/images/emoticons/soccer.gif create mode 100644 public/images/emoticons/soon.gif create mode 100644 public/images/emoticons/spa.gif create mode 100644 public/images/emoticons/spade.gif create mode 100644 public/images/emoticons/sports.gif create mode 100644 public/images/emoticons/sprinkle.gif create mode 100644 public/images/emoticons/subway.gif create mode 100644 public/images/emoticons/sun.gif create mode 100644 public/images/emoticons/sweat01.gif create mode 100644 public/images/emoticons/sweat02.gif create mode 100644 public/images/emoticons/t-shirt.gif create mode 100644 public/images/emoticons/taurus.gif create mode 100644 public/images/emoticons/telephone.gif create mode 100644 public/images/emoticons/tennis.gif create mode 100644 public/images/emoticons/think.gif create mode 100644 public/images/emoticons/three.gif create mode 100644 public/images/emoticons/thunder.gif create mode 100644 public/images/emoticons/ticket.gif create mode 100644 public/images/emoticons/tm.gif create mode 100644 public/images/emoticons/toilet.gif create mode 100644 public/images/emoticons/train.gif create mode 100644 public/images/emoticons/tulip.gif create mode 100644 public/images/emoticons/tv.gif create mode 100644 public/images/emoticons/two.gif create mode 100644 public/images/emoticons/typhoon.gif create mode 100644 public/images/emoticons/up.gif create mode 100644 public/images/emoticons/updown.gif create mode 100644 public/images/emoticons/upwardleft.gif create mode 100644 public/images/emoticons/upwardright.gif create mode 100644 public/images/emoticons/virgo.gif create mode 100644 public/images/emoticons/watch.gif create mode 100644 public/images/emoticons/wave.gif create mode 100644 public/images/emoticons/weep.gif create mode 100644 public/images/emoticons/wheelchair.gif create mode 100644 public/images/emoticons/wine.gif create mode 100644 public/images/emoticons/wink.gif create mode 100644 public/images/emoticons/wobbly.gif create mode 100644 public/images/emoticons/wrench.gif create mode 100644 public/images/emoticons/xmas.gif create mode 100644 public/images/emoticons/yacht.gif create mode 100644 public/images/emoticons/yen.gif create mode 100644 public/images/emoticons/zero.gif create mode 100644 public/images/entry/entry_btn1.gif create mode 100644 public/images/entry/entry_btn1_ov.gif create mode 100644 public/images/entry/entry_btn2.gif create mode 100644 public/images/entry/entry_btn2_ov.gif create mode 100644 public/images/entry/entry_btn3.gif create mode 100644 public/images/entry/entry_btn3_ov.gif create mode 100644 public/images/foot_bg.gif create mode 100644 public/images/foot_btm.gif create mode 100644 public/images/foot_left.gif create mode 100644 public/images/goods_btn.gif create mode 100644 public/images/goods_btn_l.gif create mode 100644 public/images/goods_btn_ov.gif create mode 100644 public/images/h2_bg.gif create mode 100644 public/images/h3_bg.gif create mode 100644 public/images/head_bg.gif create mode 100644 public/images/indicator.gif create mode 100644 public/images/item/cart_btn.gif create mode 100644 public/images/item/cart_btn_ov.gif create mode 100644 public/images/item/gt.gif create mode 100644 public/images/item/kuchi_btn.gif create mode 100644 public/images/item/kuchi_btn_ov.gif create mode 100644 public/images/item/kuchi_t.gif create mode 100644 public/images/item/lt.gif create mode 100644 public/images/item/reco_bg.gif create mode 100644 public/images/item/reco_bg_btm.gif create mode 100644 public/images/item/reco_hr.gif create mode 100644 public/images/item/reco_t.gif create mode 100644 public/images/list_mizu.gif create mode 100644 public/images/loadingAnimation.gif create mode 100644 public/images/login/login_btm.gif create mode 100644 public/images/login/login_mid.gif create mode 100644 public/images/login/login_t1.gif create mode 100644 public/images/login/login_t2.gif create mode 100644 public/images/login_logo.png create mode 100644 public/images/logo.gif create mode 100644 public/images/logo_bg.gif create mode 100644 public/images/logout.gif create mode 100644 public/images/main_bg.gif create mode 100644 public/images/menu_icon.gif create mode 100644 public/images/menu_icon_on.gif create mode 100644 public/images/menu_l.gif create mode 100644 public/images/menu_l_on.gif create mode 100644 public/images/menu_s.gif create mode 100755 public/images/mobile/border.gif create mode 100755 public/images/mobile/border_pink.gif create mode 100644 public/images/mobile/border_pink_q.gif create mode 100644 public/images/mobile/border_pink_v.gif create mode 100644 public/images/mobile/border_q.gif create mode 100644 public/images/mobile/border_v.gif create mode 100755 public/images/mobile/dummy01.jpg create mode 100755 public/images/mobile/dummy02.jpg create mode 100755 public/images/mobile/dummy03.jpg create mode 100755 public/images/mobile/dummy04.jpg create mode 100755 public/images/mobile/dummy05.jpg create mode 100755 public/images/mobile/dummy06.jpg create mode 100755 public/images/mobile/dummy07.jpg create mode 100755 public/images/mobile/dummy08.jpg create mode 100755 public/images/mobile/dummy09.jpg create mode 100644 public/images/mobile/logo_q.gif create mode 100755 public/images/mobile/logo_s.gif create mode 100644 public/images/mobile/logo_s_q.gif create mode 100644 public/images/mobile/logo_s_v.gif create mode 100755 public/images/mobile/logo_v.gif create mode 100755 public/images/mobile/rank_title.gif create mode 100644 public/images/mobile/spacer.gif create mode 100644 public/images/mobile/spacer_q.gif create mode 100755 public/images/mobile/spacer_v.gif create mode 100644 public/images/mobile/title_gray_q.gif create mode 100755 public/images/mobile/title_gray_v.gif create mode 100644 public/images/mobile/title_pink_q.gif create mode 100755 public/images/mobile/title_pink_v.gif create mode 100644 public/images/mypage/btn01.gif create mode 100644 public/images/mypage/btn01_ov.gif create mode 100644 public/images/mypage/btn02.gif create mode 100644 public/images/mypage/btn02_ov.gif create mode 100644 public/images/mypage/btn03.gif create mode 100644 public/images/mypage/btn03_ov.gif create mode 100644 public/images/mypage/btn04.gif create mode 100644 public/images/mypage/btn04_ov.gif create mode 100644 public/images/mypage/btn05.gif create mode 100644 public/images/mypage/btn05_ov.gif create mode 100644 public/images/mypage/btn06.gif create mode 100644 public/images/mypage/btn06_ov.gif create mode 100644 public/images/mypage/btn07.gif create mode 100644 public/images/mypage/btn07_ov.gif create mode 100644 public/images/mypage/mymenu_1.gif create mode 100644 public/images/mypage/mymenu_1_ov.gif create mode 100644 public/images/mypage/mymenu_2.gif create mode 100644 public/images/mypage/mymenu_2_ov.gif create mode 100644 public/images/mypage/mymenu_3.gif create mode 100644 public/images/mypage/mymenu_3_ov.gif create mode 100644 public/images/mypage/mymenu_4.gif create mode 100644 public/images/mypage/mymenu_4_ov.gif create mode 100644 public/images/mypage/mymenu_t.gif create mode 100644 public/images/mypage/mypage_bg.gif create mode 100644 public/images/mypage/mypage_btm.gif create mode 100644 public/images/mypage/mypage_t1.gif create mode 100644 public/images/mypage/mypage_t2.gif create mode 100644 public/images/mypage/mypage_t3.gif create mode 100644 public/images/mypage/mypage_t4.gif create mode 100644 public/images/order_btn.gif create mode 100644 public/images/order_btn_l.gif create mode 100644 public/images/order_btn_ov.gif create mode 100644 public/images/site_btn.gif create mode 100644 public/images/site_btn_ov.gif create mode 100644 public/images/store_btn.gif create mode 100644 public/images/store_btn_l.gif create mode 100644 public/images/store_btn_ov.gif create mode 100644 public/images/top/feature01.jpg create mode 100644 public/images/top/feature02.jpg create mode 100644 public/images/top/feature03.jpg create mode 100644 public/images/top/feature04.jpg create mode 100644 public/images/top/more.gif create mode 100644 public/images/top/new_item_t.gif create mode 100644 public/images/top/rank1.gif create mode 100644 public/images/top/rank1_bg.gif create mode 100644 public/images/top/rank2.gif create mode 100644 public/images/top/rank2_bg.gif create mode 100644 public/images/top/rank3.gif create mode 100644 public/images/top/rank3_bg.gif create mode 100644 public/images/top/ranking_t.gif create mode 100644 public/images/top/reco_item_t.gif create mode 100644 public/images/top/title_r.gif create mode 100644 public/images/top/top_bg.gif create mode 100644 public/images/top/top_bg_btm.gif create mode 100644 public/javascripts/active_scaffold/DO_NOT_EDIT create mode 100644 public/javascripts/active_scaffold/default/active_scaffold.js create mode 100644 public/javascripts/active_scaffold/default/dhtml_history.js create mode 100644 public/javascripts/active_scaffold/default/form_enhancements.js create mode 100644 public/javascripts/active_scaffold/default/rico_corner.js create mode 100644 public/javascripts/admin/admin_user.js create mode 100644 public/javascripts/admin/campaign.js create mode 100755 public/javascripts/admin/common.js create mode 100644 public/javascripts/admin/emoji_palette.js create mode 100644 public/javascripts/admin/feature_products.js create mode 100644 public/javascripts/admin/mail_magazine.js create mode 100755 public/javascripts/admin/order_status.js create mode 100644 public/javascripts/admin/product_style.js create mode 100644 public/javascripts/admin/questionnaire.js create mode 100644 public/javascripts/admin/recommend_product.js create mode 100644 public/javascripts/admin/shop.js create mode 100644 public/javascripts/application.js create mode 100755 public/javascripts/cart_credit.js create mode 100755 public/javascripts/cart_purchase.js create mode 100755 public/javascripts/close_popup.js create mode 100644 public/javascripts/controls.js create mode 100644 public/javascripts/dragdrop.js create mode 100644 public/javascripts/effects.js create mode 100644 public/javascripts/jquery.bgiframe.js create mode 100644 public/javascripts/jquery.js create mode 100755 public/javascripts/kbmj_kuchikomi.js create mode 100755 public/javascripts/kbmj_recommend.js create mode 100644 public/javascripts/login.js create mode 100644 public/javascripts/no_confrict.js create mode 100644 public/javascripts/prototype.js create mode 100644 public/javascripts/recommender_details.js create mode 100644 public/javascripts/rollover.js create mode 100755 public/javascripts/sorry.js create mode 100644 public/javascripts/thickbox.js create mode 100644 public/javascripts/treemenu.js create mode 100644 public/javascripts/ui.core.js create mode 100644 public/javascripts/ui.draggable.js create mode 100644 public/maint/index.html create mode 100644 public/robots.txt create mode 100644 public/stylesheets/active_scaffold/DO_NOT_EDIT create mode 100644 public/stylesheets/active_scaffold/default/stylesheet-ie.css create mode 100644 public/stylesheets/active_scaffold/default/stylesheet.css create mode 100644 public/stylesheets/admin.css create mode 100644 public/stylesheets/common.css create mode 100644 public/stylesheets/emoji_palette.css create mode 100644 public/stylesheets/front/campaign.css create mode 100644 public/stylesheets/front/cart.css create mode 100644 public/stylesheets/front/category.css create mode 100644 public/stylesheets/front/common.css create mode 100644 public/stylesheets/front/entry.css create mode 100644 public/stylesheets/front/features.css create mode 100644 public/stylesheets/front/item.css create mode 100644 public/stylesheets/front/login.css create mode 100644 public/stylesheets/front/mypage.css create mode 100644 public/stylesheets/front/portal.css create mode 100644 public/stylesheets/front/questionnaire.css create mode 100644 public/stylesheets/front/top.css create mode 100644 public/stylesheets/kanri.css create mode 100755 public/stylesheets/mobile.css create mode 100644 public/stylesheets/scaffold.css create mode 100644 public/stylesheets/thickbox.css create mode 100755 script/about create mode 100755 script/autospec create mode 100755 script/console create mode 100755 script/dbconsole create mode 100755 script/destroy create mode 100755 script/generate create mode 100755 script/mail create mode 100755 script/mail_restart.sh create mode 100644 script/overkill.c create mode 100755 script/performance/benchmarker create mode 100755 script/performance/profiler create mode 100755 script/performance/request create mode 100755 script/plugin create mode 100755 script/process/inspector create mode 100755 script/process/reaper create mode 100755 script/process/spawner create mode 100755 script/runner create mode 100755 script/server create mode 100755 script/spec create mode 100755 script/spec_server create mode 100644 spec/authorities_functions.csv create mode 100644 spec/controllers/accounts_controller_spec.rb create mode 100644 spec/controllers/admin/accounts_controller_spec.rb create mode 100644 spec/controllers/admin/admin_users_controller_spec.rb create mode 100644 spec/controllers/admin/authorities_controller_spec.rb create mode 100644 spec/controllers/admin/base_controller_spec.rb create mode 100644 spec/controllers/admin/campaigns_controller_spec.rb create mode 100644 spec/controllers/admin/categories_controller_spec.rb create mode 100644 spec/controllers/admin/customers_controller_spec.rb create mode 100644 spec/controllers/admin/designs_controller_spec.rb create mode 100644 spec/controllers/admin/feature_products_controller_spec.rb create mode 100644 spec/controllers/admin/features_controller_spec.rb create mode 100644 spec/controllers/admin/home_controller_spec.rb create mode 100644 spec/controllers/admin/mail_magazine_templates_controller_spec.rb create mode 100644 spec/controllers/admin/mail_magazines_controller_spec.rb create mode 100644 spec/controllers/admin/mail_template_controller_spec.rb create mode 100644 spec/controllers/admin/mobile_devices_controller_spec.rb create mode 100644 spec/controllers/admin/new_informations_controller_spec.rb create mode 100644 spec/controllers/admin/order_statuses_controller_spec.rb create mode 100644 spec/controllers/admin/orders_controller_spec.rb create mode 100644 spec/controllers/admin/payment_controller_spec.rb create mode 100644 spec/controllers/admin/product_styles_controller_spec.rb create mode 100644 spec/controllers/admin/products_controller_spec.rb create mode 100644 spec/controllers/admin/questionnaires_controller_spec.rb create mode 100644 spec/controllers/admin/recommend_products_controller_spec.rb create mode 100644 spec/controllers/admin/shops_controller_spec.rb create mode 100644 spec/controllers/admin/status_controller_spec.rb create mode 100644 spec/controllers/admin/style_categories_controller_spec.rb create mode 100644 spec/controllers/admin/styles_controller_spec.rb create mode 100644 spec/controllers/admin/totals_controller_others_spec.rb.orig create mode 100644 spec/controllers/admin/totals_controller_spec.rb create mode 100644 spec/controllers/application_controller_spec.rb create mode 100644 spec/controllers/base_controller_spec.rb create mode 100644 spec/controllers/campaigns_controller_spec.rb create mode 100644 spec/controllers/cart_controller_spec.rb create mode 100644 spec/controllers/features_controller_spec.rb create mode 100644 spec/controllers/image_resource_controller_spec.rb create mode 100644 spec/controllers/inquiries_controller_spec.rb create mode 100644 spec/controllers/portal_controller_spec.rb create mode 100644 spec/controllers/products_controller_spec.rb create mode 100644 spec/controllers/questionnaires_controller_spec.rb create mode 100644 spec/controllers/recommend_controller_spec.rb create mode 100644 spec/controllers/shop_controller_spec.rb create mode 100644 spec/customer_csv_upload_for_spec.csv create mode 100644 spec/customer_upload.csv create mode 100644 spec/fixtures/admin_users.yml create mode 100644 spec/fixtures/authorities.yml create mode 100644 spec/fixtures/authorities_functions.csv create mode 100644 spec/fixtures/campaigns.yml create mode 100644 spec/fixtures/campaigns_customers.yml create mode 100644 spec/fixtures/carts.yml create mode 100644 spec/fixtures/categories.yml create mode 100644 spec/fixtures/constants.yml create mode 100644 spec/fixtures/customers.yml create mode 100644 spec/fixtures/delivery_addresses.yml create mode 100644 spec/fixtures/delivery_dates.yml create mode 100644 spec/fixtures/delivery_fees.yml create mode 100644 spec/fixtures/delivery_tickets.yml create mode 100644 spec/fixtures/delivery_times.yml create mode 100644 spec/fixtures/delivery_traders.yml create mode 100644 spec/fixtures/designs.yml create mode 100644 spec/fixtures/feature_products.yml create mode 100644 spec/fixtures/features.yml create mode 100644 spec/fixtures/functions.yml create mode 100644 spec/fixtures/image_resources.yml create mode 100644 spec/fixtures/inquiries.yml create mode 100644 spec/fixtures/kiyakus.yml create mode 100644 spec/fixtures/laws.yml create mode 100644 spec/fixtures/mail_magazine_templates.yml create mode 100644 spec/fixtures/mail_magazines.yml create mode 100644 spec/fixtures/mail_templates.yml create mode 100644 spec/fixtures/mails.yml create mode 100644 spec/fixtures/mobile_carriers.yml create mode 100644 spec/fixtures/mobile_devices.csv create mode 100644 spec/fixtures/new_informations.yml create mode 100644 spec/fixtures/occupations.yml create mode 100644 spec/fixtures/order_deliveries.yml create mode 100644 spec/fixtures/order_details.yml create mode 100644 spec/fixtures/orders.yml create mode 100644 spec/fixtures/payments.yml create mode 100644 spec/fixtures/prefectures.yml create mode 100644 spec/fixtures/privacies.yml create mode 100644 spec/fixtures/product_access_logs.yml create mode 100644 spec/fixtures/product_statuses.yml create mode 100644 spec/fixtures/product_styles.yml create mode 100644 spec/fixtures/products.yml create mode 100644 spec/fixtures/question_answers.yml create mode 100644 spec/fixtures/question_choices.yml create mode 100644 spec/fixtures/questionnaire_answers.yml create mode 100644 spec/fixtures/questionnaires.yml create mode 100644 spec/fixtures/questions.yml create mode 100644 spec/fixtures/recommend_products.yml create mode 100644 spec/fixtures/recommend_xmls.yml create mode 100644 spec/fixtures/resource_datas.yml create mode 100644 spec/fixtures/seos.yml create mode 100644 spec/fixtures/shops.yml create mode 100644 spec/fixtures/statuses.yml create mode 100644 spec/fixtures/style_categories.yml create mode 100644 spec/fixtures/styles.yml create mode 100644 spec/fixtures/sub_products.yml create mode 100644 spec/fixtures/systems.yml create mode 100644 spec/fixtures/totals/admin_users.yml create mode 100644 spec/fixtures/totals/customers.yml create mode 100644 spec/fixtures/totals/occupations.yml create mode 100644 spec/fixtures/totals/order_deliveries.yml create mode 100644 spec/fixtures/totals/order_details.yml create mode 100644 spec/fixtures/totals/orders.yml create mode 100644 spec/fixtures/totals/product_styles.yml create mode 100644 spec/fixtures/totals/products.yml create mode 100644 spec/fixtures/zips.yml create mode 100644 spec/functions.yml create mode 100644 spec/helpers/accounts_helper_spec.rb create mode 100644 spec/helpers/admin/account_helper_spec.rb create mode 100644 spec/helpers/admin/admin_user_helper_spec.rb create mode 100644 spec/helpers/admin/authorities_helper_spec.rb create mode 100644 spec/helpers/admin/campaigns_helper_spec.rb create mode 100644 spec/helpers/admin/categories_helper_spec.rb create mode 100644 spec/helpers/admin/design_helper_spec.rb create mode 100644 spec/helpers/admin/feature_products_helper_spec.rb create mode 100644 spec/helpers/admin/features_helper_spec.rb create mode 100644 spec/helpers/admin/home_helper_spec.rb create mode 100644 spec/helpers/admin/kiyaku_helper_spec.rb create mode 100644 spec/helpers/admin/mail_magazine_helper_spec.rb create mode 100644 spec/helpers/admin/mail_magazine_template_helper_spec.rb create mode 100644 spec/helpers/admin/mail_template_helper_spec.rb create mode 100644 spec/helpers/admin/mobile_device_helper_spec.rb create mode 100644 spec/helpers/admin/new_informations_helper_spec.rb create mode 100644 spec/helpers/admin/order_helper_spec.rb create mode 100644 spec/helpers/admin/order_status_helper_spec.rb create mode 100644 spec/helpers/admin/order_statuses_helper_spec.rb create mode 100644 spec/helpers/admin/payment_helper_spec.rb create mode 100644 spec/helpers/admin/product_helper_spec.rb create mode 100644 spec/helpers/admin/product_styles_helper_spec.rb create mode 100644 spec/helpers/admin/questionnaires_helper_spec.rb create mode 100644 spec/helpers/admin/recommend_products_helper_spec.rb create mode 100644 spec/helpers/admin/shops_helper_spec.rb create mode 100644 spec/helpers/admin/total_helper_spec.rb create mode 100644 spec/helpers/application_helper_spec.rb create mode 100644 spec/helpers/base_helper_spec.rb create mode 100644 spec/helpers/campaigns_helper_spec.rb create mode 100644 spec/helpers/cart_helper_spec.rb create mode 100644 spec/helpers/features_helper_spec.rb create mode 100644 spec/helpers/image_resource_helper_spec.rb create mode 100644 spec/helpers/inquiries_helper_spec.rb create mode 100644 spec/helpers/portal_helper_spec.rb create mode 100644 spec/helpers/product_helper_spec.rb create mode 100644 spec/helpers/questionnaire_helper_spec.rb create mode 100644 spec/helpers/recommend_helper_spec.rb create mode 100644 spec/helpers/shop_helper_spec.rb create mode 100644 spec/helpers/user_helper_spec.rb create mode 100644 spec/models/admin_user_spec.rb create mode 100644 spec/models/authorities_function_spec.rb create mode 100644 spec/models/authority_spec.rb create mode 100644 spec/models/campaign_spec.rb create mode 100755 spec/models/cart_add_product_form_spec.rb create mode 100644 spec/models/cart_spec.rb create mode 100644 spec/models/category_spec.rb create mode 100644 spec/models/constant_spec.rb create mode 100644 spec/models/customer_search_form_spec.rb create mode 100644 spec/models/customer_spec.rb create mode 100644 spec/models/delivery_address_spec.rb create mode 100644 spec/models/delivery_date_spec.rb create mode 100644 spec/models/delivery_fee_spec.rb create mode 100644 spec/models/delivery_ticket_spec.rb create mode 100644 spec/models/delivery_time_spec.rb create mode 100644 spec/models/delivery_trader_spec.rb create mode 100644 spec/models/design_spec.rb create mode 100644 spec/models/feature_product_spec.rb create mode 100644 spec/models/feature_spec.rb create mode 100644 spec/models/function_spec.rb create mode 100644 spec/models/image_resource_spec.rb create mode 100644 spec/models/inquiry_spec.rb create mode 100644 spec/models/kiyaku_spec.rb create mode 100644 spec/models/laws_spec.rb create mode 100644 spec/models/mail_magazine_contents_form_spec.rb create mode 100644 spec/models/mail_magazine_search_form_spec.rb create mode 100644 spec/models/mail_magazine_spec.rb create mode 100644 spec/models/mail_magazine_template_spec.rb create mode 100644 spec/models/mail_spec.rb create mode 100644 spec/models/mail_template_spec.rb create mode 100644 spec/models/mobile_carrier_spec.rb create mode 100644 spec/models/mobile_device_spec.rb create mode 100644 spec/models/new_information_spec.rb create mode 100644 spec/models/notifier_spec.rb create mode 100644 spec/models/occupation_spec.rb create mode 100644 spec/models/order_delivery_spec.rb create mode 100644 spec/models/order_detail_spec.rb create mode 100644 spec/models/order_spec.rb create mode 100644 spec/models/payment_spec.rb create mode 100644 spec/models/prefecture_spec.rb create mode 100644 spec/models/privacy_spec.rb create mode 100644 spec/models/product_access_log_spec.rb create mode 100644 spec/models/product_spec.rb create mode 100644 spec/models/product_status_spec.rb create mode 100644 spec/models/product_style_spec.rb create mode 100644 spec/models/question_answer_spec.rb create mode 100644 spec/models/question_choice_spec.rb create mode 100644 spec/models/question_spec.rb create mode 100644 spec/models/questionnaire_answer_spec.rb create mode 100644 spec/models/questionnaire_spec.rb create mode 100644 spec/models/recommend_product_spec.rb create mode 100644 spec/models/recommend_spec.rb create mode 100644 spec/models/recommend_xml_spec.rb create mode 100644 spec/models/resource_data_spec.rb create mode 100644 spec/models/search_form_spec.rb create mode 100644 spec/models/seo_spec.rb create mode 100644 spec/models/session_spec.rb create mode 100644 spec/models/shop_spec.rb create mode 100644 spec/models/status_spec.rb create mode 100644 spec/models/style_category_spec.rb create mode 100644 spec/models/style_spec.rb create mode 100644 spec/models/sub_product_spec.rb create mode 100644 spec/models/system_spec.rb create mode 100644 spec/models/zip_spec.rb create mode 100644 spec/order_status_update.csv create mode 100644 spec/product_csv_upload_for_spec.csv create mode 100644 spec/product_csv_upload_image_for_spec.csv create mode 100644 spec/product_sample.csv create mode 100644 spec/rcov.opts create mode 100644 spec/sea1.PNG create mode 100644 spec/spec.opts create mode 100644 spec/spec_helper.rb create mode 100644 stories/all.rb create mode 100644 stories/helper.rb create mode 100644 test/fixtures/admin_users.yml create mode 100644 test/fixtures/faqs.yml create mode 100644 test/test_helper.rb create mode 100644 test/unit/faq_test.rb diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 0000000..d137f4e --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1,45 @@ +Licence for Elephant Commerce +---------------------------------------------------------------------- +本ソフトウェアは、MITライセンスです。 + +Copyright (c) 2009 KBMJ, Inc. All Rights Reserved. + +以下に定める条件に従い、本ソフトウェアおよび関連文書のファイル(以下 +「ソフトウェア」)の複製を取得するすべての人に対し、ソフトウェアを無制限に +扱うことを無償で許可します。これには、ソフトウェアの複製を使用、複写、変更、 +結合、掲載、頒布、サブライセンス、および/または販売する権利、および +ソフトウェアを提供する相手に同じことを許可する権利も無制限に含まれます。 + +上記の著作権表示および本許諾表示を、ソフトウェアのすべての複製または重要な +部分に記載するものとします。 + +ソフトウェアは「現状のまま」で、明示であるか暗黙であるかを問わず、何らの +保証もなく提供されます。ここでいう保証とは、商品性、特定の目的への適合性、 +および権利非侵害についての保証も含みますが、それに限定されるものではあり +ません。作者または著作権者は、契約行為、不法行為、またはそれ以外であろうと、 +ソフトウェアに起因または関連し、あるいはソフトウェアの使用またはその他の +扱いによって生じる一切の請求、損害、その他の義務について何らの責任も負わ +ないものとします。 + +---------------------------------------------------------------------- +The MIT License + +Copyright (c) 2009 KBMJ, Inc. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README b/README new file mode 100644 index 0000000..84b1339 --- /dev/null +++ b/README @@ -0,0 +1,386 @@ +================================================================================ + エレコマ(Elephant Commerce) version 1.0.0 http://ec.kbmj.com/ +================================================================================ + +エレコマのダウンロードありがとうございます。 +エレコマは、Ruby on Railsで開発したECommerceシステムです。 +オープンソースとして、MIT Licenseを採用しています。 + +このREADMEでは、エレコマを稼動させるまでの必要最低限の手順を記載しています。 + +================================================================================ + エレコマ 動作環境 +================================================================================ +エレコマを動かすに辺り、以下の環境を奨励します。 +(下記環境以外でも動作する可能性はあります) + + - OS : CentOS 5.4 + - DB : postgresql 8.3系 + - Ruby : 1.8.7 + - Rails : 2.3.2 + +================================================================================ + エレコマ 依存plugin +================================================================================ +エレコマではpluginを含めて配布をしていません。 +以下のpluginが依存しています。各自インストールをお願いします。 + + +active-form + http://www.realityforge.org/svn/code/active-form/trunk/ + rev: 2833 + +acts_as_list + git://github.com/rails/acts_as_list.git + rev: 8771a632dc26a7782800347993869c964133ea29 + +acts_as_paranoid + git://github.com/technoweenie/acts_as_paranoid.git + rev: b0a5d2b8ba89eae03f673e4af2e52619260fcc30 + +acts_as_tree + git://github.com/rails/acts_as_tree.git + rev: 20988cac158bcf7f7535a3c5dd193165797d719a + +ar_fixtures + http://topfunky.net/svn/plugins/ar_fixtures/ + rev: 271 + +jpmobile + git://github.com/darashi/jpmobile.git + rev: 36bbbd881d7536f9fa1fff66158c80ba8c4f7b54 + +jpmobile_emoticon_filter + http://taslam-plugins.googlecode.com/svn/trunk/jpmobile_emoticon_filter/ + rev: 49 + +mbmail + git://github.com/tmtysk/mbmail.git + rev: 654ce3ec2dfa10ac3b05cd9354eb84456d206a6d + +resource_controller + git://github.com/giraffesoft/resource_controller.git + rev: 465c3357be3c11f68193e5ecda828667ca5c1040 + +will_paginate + git://github.com/mislav/will_paginate.git + rev: 839d821041a4cfaa4dfbcc5719ea17ff196189c7 + +yaml_waml + git://github.com/kakutani/yaml_waml.git + rev: 1b292b3e0df9a7e69ed90eebdca327a0888b0a12 + + +================================================================================ + エレコマ インストール手順 +================================================================================ +CentOS 5.4でのインストールを想定しています。 + 前提条件は以下となります。 + -ダウンロードページからエレコマをダウンロード済み。 + +1. rubyのインストール +$ sudo yum install gcc +$ sudo yum install zlib-devel +$ sudo yum install openssl-devel +$ sudo yum install ncurses-devel +$ sudo yum install readline-devel +$ wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p174.tar.gz +$ tar zxf ruby-1.8.7-p174.tar.gz +$ cd ruby-1.8.7-p174 +$ ./configure +$ make +$ sudo make install + +2. gemのインストール +$ wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz +$ tar zxf rubygems-1.3.5.tgz +$ cd rubygems-1.3.5 +$ sudo ruby setup.rb + +3. ImageMagickのインストール +$ sudo yum install libjpeg-devel libpng-devel gd-devel freetype-devel +$ wget ftp://ftp.kddlabs.co.jp/graphics/ImageMagick/ImageMagick-6.5.8-4.tar.gz +$ cd ImageMagick-6.5.8-4 +$ ./configure +$ make +$ sudo make install + +4. Rmagickのインストール +$ alias sudo="sudo PATH=$PATH" +$ sudo gem install rmagick -v 2.12.2 +$ unalias sudo + +5. 依存するgemのインストール +$ sudo gem install rails -v 2.3.2 +$ sudo gem install gettext -v 2.1.0 +$ sudo gem install gruff -v 0.3.6 +$ sudo gem install rspec-rails -v 1.2.9 +$ wget http://www.artonx.org/data/lhalib/lhalib-0.8.1.gem +$ sudo gem install lhalib-0.8.1.gem + +6. PostgreSQLのインストール +$ sudo yum install postgresql-devel +$ sudo yum install postgresql-server +$ sudo gem install postgres + +7. ecユーザの作成 +# adduser ec +# passwd ec +(パスワード変更) + +8. アプリケーションの展開 +# cd /usr/local +# tar zxf (DOWNLOAD_PATH)/elecoma-1.0.0.tar.gz +# mv elecoma-1.0.0 ec +# chown -R ec:ec /usr/local/ec + +9. postgresqlのセットアップ +# vim /var/lib/pgsql/data/pg_hba.conf +(password cryptを設定します) +# /etc/init.d/postgresql start +# su - postgres +$ psql template1 +# alert user postgres with password 'xxxx'; +# q\ +$ createuser ec +Shall the new role be a superuser? (y/n) y +$ psql template1 +# alter user ec with password 'elephant'; +# \q +$ createdb --owner=ec ec_dev +CREATE DATABASE +$ createdb --owner=ec ec_test +CREATE DATABASE +$ createdb --owner=ec ec +CREATE DATABASE +$ psql -l + List of databases + Name | Owner | Encoding +-----------+----------+---------- + ec | ec | UTF8 + ec_dev | ec | UTF8 + ec_test | ec | UTF8 + postgres | postgres | UTF8 + template0 | postgres | UTF8 + template1 | postgres | UTF8 +(6 rows) + +10. 開発向けセットアップ +# su - ec +$ cd /usr/local/ec/ +$ cd config +$ cp database.example.yml database.yml +$ vim database.yml +$ diff database.example.yml database.yml +3,4c3,4 +< username: postgres +< password: +--- +> username: ec +> password: elephant +$ cd environments +$ vim development.rb +(メールサーバの設定を変更) +$ vim production.rb +(メールサーバの設定を変更) +$ vim test.rb +(メールサーバの設定を変更) + +11. gitのインストール +$ wget http://kernel.org/pub/software/scm/git/git-1.6.5.5.tar.gz +$ tar zxf git-1.6.5.5.tar.gz +$ cd git-1.6.5.5 +$ ./configure +$ make +$ sudo make install + +12. プラグインのインストール +$ ruby script/plugin install http://www.realityforge.org/svn/code/active-form/trunk/ +$ ruby script/plugin install git://github.com/rails/acts_as_list.git +$ ruby script/plugin install git://github.com/technoweenie/acts_as_paranoid.git +$ ruby script/plugin install git://github.com/rails/acts_as_tree.git +$ ruby script/plugin install http://topfunky.net/svn/plugins/ar_fixtures/ +$ ruby script/plugin install git://github.com/darashi/jpmobile.git +$ ruby script/plugin install http://taslam-plugins.googlecode.com/svn/trunk/jpmobile_emoticon_filter/ +$ ruby script/plugin install git://github.com/tmtysk/mbmail.git +$ rm -fr vendor/plugins/mbmail/lib/jpmobile +$ ruby script/plugin install git://github.com/giraffesoft/resource_controller.git +$ ruby script/plugin install git://github.com/mislav/will_paginate.git +$ ruby script/plugin install git://github.com/kakutani/yaml_waml.git + +13. passengerのインストール +$ sudo yum install gcc-c++ +$ sudo yum install httpd-devel +$ sudo gem install passenger +$ sudo passenger-install-apache2-module + +14. apacheの設定 +$ sudo vim /etc/httpd/conf.d/ec.conf +LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.7/ext/apache2/mod_passenger.so +PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.7 +PassengerRuby /usr/local/bin/ruby + + + ServerName ec.example.com + DocumentRoot /usr/local/ec/public + RailsEnv production + + AllowOverride all + Options -MultiViews + + + +15. production DBの作成 +# su - ec +$ rake db:migrate RAILS_ENV=production + +16. apache の再起動 +$ sudo /etc/init.d/apache restart + +17. script/mailを起動 +$ ./script/mail_restart.sh -e production +(メールマガジン送信用のプロセスを立ち上げます) + +※webrickでの起動も可能です。 +$ ruby ./script/server -p production + + + +================================================================================ +* エレコマの管理者ユーザー追加 +================================================================================ +エレコマを起動した直後は管理者ユーザーが存在しません。 +ユーザー登録は、RAILS_ROOT/test/fixtures/admin_users.yml の5,6,8行目を任意のものに修正した後、 +コンソールから以下のようにデータを登録します。 + +$ rake db:fixtures:load FIXTURES=admin_users RAILS_ENV=production + +ユーザーを登録した後、管理画面:http://サイトドメイン/adminにアクセスすると、 +ログイン画面が表示されますので、RAILS_ROOT/test/fixtures/admin_users.ymlで指定した +登録したログインIDとパスワードでログインしてください。 + +================================================================================ +* エレコマの住所マスタ更新 +================================================================================ +エレコマの住所マスタは郵便事業株式会社の郵便番号マスタを利用しています。 +登録はコンソールから以下のように行ないます。 + +$ ruby script/runner -e production Zip.import + +郵便番号マスタは以下のサイトにて配布されているものを自動的に取り込みます。 +http://www.post.japanpost.jp/zipcode/download.html + +住所マスタ更新機能はLhaLibに依存しています。 +LhaLibの詳細については以下のサイトをご確認ください。 +http://www.artonx.org/collabo/backyard/?LhaLibEn + + +================================================================================ +* エレコマの商品追加 +================================================================================ +エレコマを起動した直後は商品が存在していません。 +管理画面から、商品の追加を行う必要があります。 + +1. 管理者ユーザーでログインする +-------------------------------------------------------------------------------- + +2. 商品の登録 +-------------------------------------------------------------------------------- +商品登録には、カテゴリ、規格が必要となります。 +>> カテゴリの登録 + -管理画面の商品管理 -> カテゴリ管理 よりカテゴリを登録する + +>> 規格の管理 + -管理画面の商品管理 -> 規格管理 より規格を登録する + +>> 商品の登録 +>>>> 1つずつ登録する場合 + - 管理画面の商品管理 -> 商品登録 より商品の登録を行う + +>>>> CSVで一括登録する場合 + - 管理画面の商品管理 -> 商品マスタ -> CSVアップロード から アップロードする + +商品登録後、商品の規格を設定します。 +>> 商品規格の登録 + 1. 商品登録完了画面もしくは商品マスタの商品一覧 -> 規格登録 から規格を選択し「表示する」ボタンを押下する + 2. 規格リストが表示されるので、必要な規格の登録項目にチェックを入れ、商品コード、在庫数、価格を入力し、登録を行う + +以上で、商品がフロント画面に表示されるようになります + + + +================================================================================ +* ユニットテスト +================================================================================ +エレコマではユニットテストにRspecを利用しています。 +利用するには、以下を実行してRspecのインストールを行なってください。 + +1. gemsのインストール +-------------------------------------------------------------------------------- +$ sudo gem install rspec +$ sudo gem install rspec-rails + +2. rspecの実行 +-------------------------------------------------------------------------------- +$ rake spec +このコマンドを発行するとユニットテストが実行されます。 +※ $ ruby ./script/spec ./spec + でも実行可能です。 + + +================================================================================ +* エレコマ ライセンス +================================================================================ +本ソフトウェアはMIT Licenceを採用しています。 +ライセンスの詳細についてはCopyrightファイルを参照してください。 + +配布物に含まれる「エレコマ」のロゴはクリエイティブ・コモンズノ表示-継承 2.1 +日本ライセンスに従った範囲内でご利用いただけます。 + + +================================================================================ +* 配布物に含まれる別プロジェクトのファイル +================================================================================ +1. TypePad 絵文字アイコン画像 +配布物に含まれる以下のファイルはTypePad 絵文字アイコン画像を利用しています。 +public/images/emoticons/* +TypePad 絵文字アイコンは以下のライセンスに基づきます。 + +TypePad 絵文字アイコン画像 by Six Apart Ltd is licensed +under a Creative Commons 表示 2.1 日本 License. +Permissions beyond the scope of this license may be +available at http://start.typepad.jp/typecast/. + +2. さざなみフォント +配布物に含まれる以下のファイルはさざなみフォントを利用しています。 +lib/sazanami-gothic.ttf +さざなみフォントは以下のライセンスに基づきます。 + +Copyright (c) 1990-2003 + Wada Laboratory, the University of Tokyo. All rights reserved. +Copyright (c) 2003-2004 + Electronic Font Open Laboratory (/efont/). All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of the Wada Laboratory, the University of Tokyo nor + the names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY WADA LABORATORY, THE UNIVERSITY OF TOKYO AND +CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT +NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LABORATORY OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..3bb0e85 --- /dev/null +++ b/Rakefile @@ -0,0 +1,10 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require(File.join(File.dirname(__FILE__), 'config', 'boot')) + +require 'rake' +require 'rake/testtask' +require 'rake/rdoctask' + +require 'tasks/rails' diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb new file mode 100644 index 0000000..4c20afb --- /dev/null +++ b/app/controllers/accounts_controller.rb @@ -0,0 +1,525 @@ +class AccountsController < BaseController + before_filter :login_check, :except => [ + :activate, :kiyaku, :kiyaku_intro, :login, :logout, :reminder, + :reminder_complete, :reminder_hint, :salvage, :salvage_complete, + :signup, :signup_complete, :signup_confirm, + :regmailst, :get_address + ] + before_filter :load_seo_mypage_index, :only => [:history, :history_list, :edit, :delivery, :withdraw] + before_filter :redirect_for_login_user, :only => [ + :login, :signup, :signup_confirm, :signup_complete, :kiyaku, :kiyaku_intro, :salvage, :salvage_complete + ] + + EMAIL_PATTERN = /^(([^@\s]+)@((?:[-a-z0-9]+\.)*[a-z]{2,})|)$/i + + def login + if request.request_method == :post + if params[:customer] + if params[:customer][:email] == '' + flash.now[:notice] = "メールアドレスを入力して下さい。" + return + end + if params[:customer][:password] == '' + flash.now[:notice] = "パスワードを入力して下さい。" + return + end + else + flash.now[:notice] = "メールアドレスを入力してください" + return + end + customer = Customer.find_by_email_and_password(params[:customer][:email], params[:customer][:password]) + if customer.nil? + flash.now[:notice] = "メールアドレスもしくはパスワードが正しくありません。" + return + elsif customer.activate == Customer::KARITOUROKU + flash.now[:notice] = '会員登録が完了していません。登録確認メールに書かれた URL にアクセスして会員登録を完了してください。' + elsif !customer.same_mobile_carrier?(request.mobile) + flash.now[:notice] = '登録時の端末でログインしてください。' + else + set_login_customer(customer) + # ログイン前に買い物していれば、その内容を取り込む + unless @carts.empty? + Cart.delete_all(['customer_id=?', customer.id]) + @carts.each_with_index do |cart, i| + cart.customer = customer + cart.position = i + cart.save + end + end + unless params[:reminder_id].blank? + cookies[:reminder_id] = { + :value => customer.email, + :expires => 14.days.from_now, + :path => '/' + } + customer.save + end + unless params[:auto_login].blank? + cookies[:auto_login] = { + :value => customer.generate_cookie!(request.remote_ip), + :expires => 14.days.from_now, + :path => '/' + } + customer.save + end + # 直前にいたページ or トップページへリダイレクト + if session[:return_to] + # login_check で飛ばされた場合 + redirect_to :controller=>session[:return_to]["controller"], + :action=>session[:return_to]["action"], + :action=>session[:return_to]["dir_name"], + :id=>session[:return_to][:id] + session[:return_to] = nil + else + # 普通に来た場合 + if request.mobile? + redirect_to :controller => "accounts", :action=>"myindex_mobile"# '/account/myindex_mobile' + else + redirect_to :controller => "portal", :action => "show" + end + end + end + else + if (cookie = cookies[:reminder_id]) + @customer = Customer.new(:email => cookie) + @reminder_id = 1 + end + if (cookie = cookies[:auto_login]) + @customer = Customer.find_by_cookie(cookie) + @auto_login = 1 + end + end + end + + def logout + @login_customer.update_attributes(:cookie => nil) unless @login_customer.cookie.nil? + session[:carts] = nil + set_login_customer(nil) + request.env["HTTP_REFERER"] ||= url_for(:controller=>:portal, :action=>:show) + redirect_to :back + end + + # モバイル専用規約入口 + def kiyaku_intro + redirect_to :action => :kiyaku unless request.mobile? + end + + def kiyaku + params[:position] ||= 1 if request.mobile? + # 章を指定されたらそこだけ出す。さもなくば全て。 + if params[:position] + kiyaku = Kiyaku.find_by_position(params[:position]) + raise ActiveRecord::RecordNotFound if kiyaku.nil? + @next = Kiyaku.minimum(:position, :conditions => ['position > ?', kiyaku.position]) + @prev = Kiyaku.maximum(:position, :conditions => ['position < ?', kiyaku.position]) + @kiyakus = [kiyaku] + else + @kiyakus = Kiyaku.find(:all, :order=>'position') + @kiyaku_content = '' + @kiyakus.each do |k| + @kiyaku_content = @kiyaku_content + k.name + "\n\n" + k.content + "\n\n" + end + end + end + + def signup + @stage = (params[:stage] || 0).to_i + params[:done] && !params[:back] and return signup_confirm + @customer = Customer.new + if request.method == :post # 2 ページ目とか + get_customer + end + end + + def signup_confirm + @customer = Customer.new + get_customer + @customer.editting = false if request.mobile? + unless @customer.valid? + render :action => :signup + return + end + @password = @customer.raw_password + render :action => :signup_confirm + end + + def signup_complete + if params[:back] + signup + return render(:action => 'signup') + end + + @customer = Customer.new(params[:customer]) + unless params[:password].blank? + @customer.set_password params[:password] + end + + # モバイル + @customer.set_mobile request.mobile + + # 登録直後は仮登録状態 + # 登録キーを生成してメールを送る + @customer.activate = Customer::KARITOUROKU + @customer.generate_activation_key! + + # カートを保存 + @customer.carts.clear + @customer.carts << @carts + + #ポイント付与 + unless Shop.find(:first).blank? + @customer.point = Shop.find(:first).point_at_admission + end + + unless @customer.valid? + render :action => 'signup' + return + end + + begin + url = url_for(:action => :activate, :activation_key => @customer.activation_key, :aff_id=>session[:aff_id]) + logger.debug "######## #{url} ########" + Notifier::deliver_activate(@customer, url) + rescue => e + flash.now[:error] = 'メールの送信に失敗しました' + render :action => 'signup' + return + end + + # 全てが終わったら保存 + @customer.save + end + + # 購入履歴 + def history + history_list + render :action => 'history_list' + end + + def history_list + # paginate する + @orders = Order.paginate(:page => params[:page], + :per_page => request.mobile ? 5 : 20, + :conditions => ['customer_id=?', @login_customer.id], + :order=>'received_at desc', + :limit => 20) + @orders.total_entries = 20 if request.mobile? && @orders.total_entries > 20 + end + + def history_show + @order = @login_customer.orders.find_by_id(params[:id]) + raise ActiveRecord::RecordNotFound unless @order + @order_delivery = @order.order_deliveries[0] + end + + # 会員登録内容変更 + def edit + @stage = (params[:stage] || 0).to_i + params[:done] && !params[:back] and return edit_confirm + @customer = Customer.find(@login_customer.id) + if request.method == :get # 1 ページ目 + @customer.email_confirm = @customer.email + if request.mobile? + @customer.email_user, @customer.email_domain = @customer.email.split('@', 2) + @customer.email_user_confirm = @customer.email_user + end + end + if request.method == :post # 2 ページ目とか + get_customer + end + end + + def edit_confirm + @customer = Customer.find(@login_customer.id) + get_customer + @customer.editting = false if request.mobile? + unless @customer.valid? + render :action => :edit + return + end + # 入力が正しい時だけ次へ引き継ぐ + @password = @customer.raw_password + render :action => :edit_confirm + end + + def edit_complete + if params[:back] + edit + return render(:action => 'edit') + end + @customer = Customer.find(@login_customer.id) + @customer.attributes = params[:customer] + unless @customer.valid? + render :action => 'edit' + return + end + @customer.set_mobile request.mobile + @customer.save + set_login_customer(@customer) + end + + def delivery + @delivery_addresses = @login_customer.delivery_addresses + render :action => 'delivery_list' + end + + def delivery_list + redirect_to :action => :delivery + end + + def delivery_new + @stage = (params[:stage] || 0).to_i + params[:done] && !params[:back] and return delivery_create + @delivery_address = @login_customer.delivery_addresses.build + if request.method == :post + get_delivery_address + end + render :action => 'delivery_new' unless performed? + end + + def delivery_new_popup + @popup = true + delivery_new + render :action => 'delivery_new_popup' unless performed? + end + + def delivery_create + @stage = params[:stage] + @popup = !params[:popup].blank? && params[:popup] == "true" + customer = @login_customer + @delivery_address = customer.delivery_addresses.build(params[:delivery_address]) + unless @delivery_address.valid? + return render(:action => 'delivery_new') + end + render :action => 'delivery_confirm' + end + + def delivery_edit + @stage = (params[:stage] || 0).to_i + params[:done] && !params[:back] and return delivery_update + @id = params[:id].to_i + @delivery_address = find_delivery_address @login_customer, params[:id] + if request.method == :post + get_delivery_address + end + render :action => 'delivery_edit' unless performed? + end + + def delivery_edit_popup + @popup = true + delivery_edit + render :action => 'delivery_edit_popup' unless performed? + end + + def delivery_update + @popup = !params[:popup].blank? && params[:popup] == "true" + @id = params[:id].to_i + @delivery_address = find_delivery_address @login_customer, params[:id] + @delivery_address.attributes = params[:delivery_address] + unless @delivery_address.valid? + return render(:action => 'delivery_edit') + end + if @popup + render :action => 'delivery_confirm_popup' + else + render :action => 'delivery_confirm' + end + end + + def delivery_complete + @popup = !params[:popup].blank? && params[:popup] == "true" + if params[:id].blank? + # 新規 + if params[:back] + return (@popup ? delivery_new_popup : delivery_new) + end + @delivery_address = @login_customer.delivery_addresses.build() + # 最大の position + 1 を割り当てる + max_position = @login_customer.delivery_addresses.map(&:position).map(&:to_i).max + @delivery_address.position = max_position + 1 + else + # 更新 + if params[:back] + return (@popup ? delivery_edit_popup : delivery_edit) + end + @delivery_address = find_delivery_address @login_customer, params[:id] + end + @delivery_address.attributes = params[:delivery_address] if @delivery_address + if @delivery_address && @delivery_address.save + flash.now[:notice] = 'データを保存しました。' + else + flash.now[:error] = 'データの保存に失敗しました。' + end + if @popup + render :action => 'close_popup' + else + if params[:backurl] # カートから来た時 + redirect_to :controller => 'cart', :action => 'shipping' + else + redirect_to :action => 'delivery' + end + end + end + + def delivery_destroy + @delivery_address = find_delivery_address @login_customer, params[:id] + if @delivery_address and @delivery_address.destroy + flash.now[:notice] = '削除しました。' + else + flash.now[:notice] = '削除に失敗しました。' + end + if params[:backurl] # カートから来た時 + redirect_to params[:backurl] + else + redirect_to :action => 'delivery' + end + end + + def activate + key = params[:activation_key] + unless key.blank? + @customer = Customer.activate_email(key) + @customer.reachable = true + if @customer + save_carts(@customer.carts) + @customer.carts.clear + end + end + end + + def withdraw + end + + def withdraw_confirm + end + + def withdraw_complete + unless request.post? + head :method_not_allowed + return + end + @login_customer.withdraw + set_login_customer(nil) + end + + def reminder + redirect_to :action => :salvage + end + + def salvage + flash.now[:notice] = flash.now[:error] = nil + end + + def salvage_complete + @input = Customer.new(params[:input]) + @customer = Customer.find_by_email_and_activate(@input.email, Customer::TOUROKU) + @input.id = @customer.id if @customer # メールアドレス重複エラー回避 + columns = [:email, :family_name, :first_name, :birthday, :tel01, :tel02, :tel03] + @input.attributes = {:password_confirm=>"dummy", :email_confirm=>"dummy@example.com"} + @input.target_columns = columns + unless @input.valid? + render :action => "salvage" + return + end + correct = @customer && columns.all?{ |c| @customer[c] == @input[c] } + unless correct + flash.now[:notice] = "入力された情報が正しくありません" + render :action => "salvage" + return + end + @password = @customer.regenerate_password! + unless @customer.save + flash.now[:notice] = "パスワードの再発行に失敗しました" + render :action => "salvage" + return + end + #メールの送信 + begin + if request.mobile? + Notifier::deliver_mobile_reminder(@customer, @password) + else + Notifier::deliver_reminder(@customer, @password) + end + rescue + flash.now[:notice] = "メールの送信に失敗しました" + render :action => "salvage" + return + end + end + + def regmailst + @target_domain = Shop.first.docomo_sender_address + @return_to = params[:return_to] + @return_to ||= request.env["HTTP_REFERER"] + @return_to ||= url_for(:action=>:kiyaku_intro, :only_path => false) + end + + private + + def get_shop_info + @shop = Shop.find(:first) + end + + def find_customer_by_email(email) + customer = Customer.find_by_email(email) + return customer + end + + def find_delivery_address customer, id + id or raise ActiveRecord::RecordNotFound + conditions = ["#{DeliveryAddress.table_name}.id = ? and #{Customer.table_name}.id = ?", + id, customer.id] + da = DeliveryAddress.find(:first, :conditions => conditions, :include => :customer) + da or raise ActiveRecord::RecordNotFound + end + + def load_seo_mypage_index + @seo = Seo.find(:first, :conditions=>{ :page_type => Seo::MYPAGE_INDEX}) + end + + def get_delivery_address + @popup ||= !params[:popup].blank? && params[:popup] == "true" + + @delivery_address.attributes = params[:delivery_address]||{} + if params[:back] + @delivery_address.target_columns = [] + @stage -= 1 + if @stage < 0 + if @popup + redirect_to :controller => :cart, :action => :shipping + else + redirect_to :action => :delivery + end + end + return + end + if params[:delivery_address] + @delivery_address.target_columns = params[:delivery_address].keys.map(&:to_s) + end + #@delivery_address.update_address!(@delivery_address.zipcode_first_changed?) + @delivery_address.update_address! + @stage += 1 if @delivery_address.valid? + end + + def get_customer + @customer.attributes = params[:c] if params[:c] + if params[:customer] + @customer.attributes = params[:customer] + @customer.target_columns = params[:customer].keys.map(&:to_s) + end + @customer.set_mobile request.mobile # 携帯電話の種類 + @customer.editting = true + if params[:back] + @customer.target_columns = [] + @stage -= 1 + return + end + @customer.update_address!(false) + @stage += 1 if @customer.valid? && @stage + end + + def redirect_for_login_user + redirect_to :controller => :portal, :action => :show if @login_customer + end + +end diff --git a/app/controllers/admin/accounts_controller.rb b/app/controllers/admin/accounts_controller.rb new file mode 100644 index 0000000..a56e895 --- /dev/null +++ b/app/controllers/admin/accounts_controller.rb @@ -0,0 +1,46 @@ +class Admin::AccountsController < Admin::BaseController + skip_before_filter :admin_login_check + layout nil, :only => 'login' + + def login + if request.request_method == :post + if params[:admin_user] + if params[:admin_user][:login_id] == '' + flash.now[:error] = "ログインIDを入力して下さい。" + return + elsif params[:admin_user][:password] == '' + flash.now[:error] = "パスワードを入力して下さい。" + return + end + else + flash.now[:error] = "ログインIDを入力してください" + return + end + admin_user = AdminUser.find_by_login_id_and_password(params[:admin_user][:login_id], params[:admin_user][:password]) + + if admin_user.nil? + flash.now[:error] = "ログインIDもしくはパスワードが正しくありません。" + return + else + session[:admin_user] = admin_user + if session[:return_to_admin] + # login_check で飛ばされた場合 + redirect_to url_for(session[:return_to_admin]) + session[:return_to_admin] = nil + return + else + # 普通に来た場合 + redirect_to :controller=>"/admin/home", :action=>:index + return + end + end + end + end + + def logout + session[:admin_user] = nil + session[:return_to_admin] = nil + redirect_to :controller=>"admin/accounts", :action=>:login + end + +end diff --git a/app/controllers/admin/admin_users_controller.rb b/app/controllers/admin/admin_users_controller.rb new file mode 100644 index 0000000..7a21e2b --- /dev/null +++ b/app/controllers/admin/admin_users_controller.rb @@ -0,0 +1,36 @@ +class Admin::AdminUsersController < Admin::BaseController + resource_controller + before_filter :admin_permission_check_member + before_filter :load_admin + + index.before do + @admin_users = AdminUser.find(:all, + :order => 'position') + end + + [create, update].each do |action| + action.wants.html do + redirect_to :action => "index" + end + end + + def up + super + redirect_to :action => "index" + end + def down + super + redirect_to :action => "index" + end + + #稼働/非稼働チェック(Ajax) + def update_activity + record = AdminUser.find_by_id(params[:id]) + if params[:activity] == "true" + record.update_attribute(:activity, true) + elsif params[:activity] == "false" + record.update_attribute(:activity, false) + end + render :text=>true + end +end diff --git a/app/controllers/admin/authorities_controller.rb b/app/controllers/admin/authorities_controller.rb new file mode 100644 index 0000000..a58d11c --- /dev/null +++ b/app/controllers/admin/authorities_controller.rb @@ -0,0 +1,66 @@ +class Admin::AuthoritiesController < Admin::BaseController + #共通 + resource_controller + before_filter :admin_permission_check_member + + #indexの前処理 + index.before do + @authorities = Authority.find(:all, + :order => 'position') + end + + #editの前処理 + edit.before do + #get authority.functions + @selected_functions = @authority.functions.map{|f| f.id} + end + + + def create + save(false) + end + + def update + save(true) + end + + #上へ + def up + super + redirect_to :action => "index" + end + #下へ + def down + super + redirect_to :action => "index" + end + + private + def save(type) + + if type + back_to = "edit" + @authority = Authority.find_by_id(params[:id]) + @authority.attributes = params[:authority] + else + back_to = "new" + @authority = Authority.new(params[:authority]) + end + + if @authority.save + #authority.functions 保存 + @authority.chang_functions(params[:functions] || {}) + flash.now[:notice] = "データを保存しました。" + redirect_to :action => :index + else + #エラーがある場合 + if params[:functions] + @selected_functions = params[:functions].keys.collect {|key| key.to_i} + end + flash.now[:notice] = "エラーが発生しました。" + render :action => back_to + return + end + end + +end diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb new file mode 100644 index 0000000..7fdc747 --- /dev/null +++ b/app/controllers/admin/base_controller.rb @@ -0,0 +1,164 @@ +class Admin::BaseController < ApplicationController + before_filter :load_system + before_filter :load_admin + before_filter :admin_login_check + + layout 'admin/base' + + def up + get_model(params[:model]) + @record = @model.find_by_id(params[:id]) + @record.move_higher + @record.save + end + + def down + get_model(params[:model]) + @record = @model.find_by_id(params[:id]) + @record.move_lower + @record.save + end + + def change_position + get_model + @record = @model.find_by_id(params[:id]) + @record.insert_at(params[:position]) + @record.save + end + + private + + def get_model(model_name = nil) + @model_name = "" + @model_name = $1 if self.class.to_s =~ /Admin::(.*)sController/ + @model_name = model_name || $1 if self.class.to_s =~ /Admin::(.*)Controller/ + @model_name = model_name || @model_name if defined? model_name + @model_name = params[:model] || @model_name + @model = eval @model_name.classify + end + + #管理側ユーザーのログインフィルター + def load_admin + @login_admin = AdminUser.find(:first, :conditions=>["id=?", session[:admin_user]["id"]]) if session[:admin_user] + end + + #管理側ユーザーのログインチェック + def admin_login_check + @login_check_error = false + unless session[:admin_user] + session[:return_to_admin] = params if params + redirect_to(:controller => 'admin/accounts', :action => 'login') + return false + end + end + + #管理側ユーザーの処理実行権限チェック + Function.find(:all).each do |rec| + name = "admin_permission_check_" + rec.code + define_method(name.to_sym) do + current_user = session[:admin_user] + current_controller_name = params[:controller] + current_action_name = params[:action] + + unless Authority.find(:first, + :conditions => ["authorities.id=? and functions.id=?", current_user.authority_id, rec.id], + :include=> :functions) + + flash[:notice] = "該当機能にアクセスする権限がありません" + redirect_to :controller => "home", :action => "index" + return false + end + end + end + + # 例外発生時、public/admin/#{status_code}.html を表示 + def render_optional_error_file(status_code) + status = interpret_status(status_code) + num = status[0,3] + root = Pathname.new(Rails.public_path) + filename = '%s.html' % num + path = root.join('admin', filename) # public/admin/xxx.html + path.exist? or path = root.join(filename) # public/xxx.html + if path.exist? + render :file => path.to_s, :status => status + else + head status + end + end + + def get_conditions(model_name = nil) + get_model(model_name) + @year = Hash.new + @month = Hash.new + @day = Hash.new + @search_list = [] + if params[:search] + hash = SearchForm.new(params[:search]).attributes + params[:search].find_all{|k,v| k.include?('.')}.each do |k,v| + hash[k] = v + end + hash.each do | column, value | + if column =~ /^(search_)?(.*)(_from|_to)(.*)/ + column = $2 + status = $3 + date = $4 + end + model = @model + # カラム名に . が含まれるならテーブル名付きで検索 + if column.include?(?.) + table, column = column.split('.') + ActiveRecord::Base.connection.table_exists?(table) or next + model = Object.const_get(table.classify) + else + model.columns_hash.include? column or next + end + full_name = "%s.%s" % [model.table_name, column] + + op = "=" + if status == "_from" + op = ">=" + elsif status == "_to" + op = "<=" + end + case model.columns_hash[column].type.to_s + when "integer" + @search_list << ["#{full_name} #{op} ?", value.to_i] unless value.blank? + when "boolean" + @search_list << ["#{full_name} #{op} ?", value] unless value.blank? + when "string", "text" + if op == "=" + @search_list << ilike_conditions(full_name, value) unless value.blank? + else + @search_list << ["#{full_name} #{op} ?", value] unless value.blank? + end + when "datetime", "date" + key = column+status + if date == "(1i)" + @year[key] = value + elsif date == "(2i)" + @month[key] = value + elsif date == "(3i)" + @day[key] = value + end + + time = nil + if !@year[key].blank? && !@month[key].blank? && !@day[key].blank? + time = Time.zone.local(@year[key].to_i, @month[key].to_i, @day[key].to_i) + elsif [Date, Time].any?{|c| value.is_a?(c)} + time = value + elsif date.empty? # search[:foo]='1900-01-01 00:00:00' みたいに来た場合 + time = Time.zone.parse(value) # 失敗したときは nil になる + end + + + if time && status == "_from" + @search_list << ["#{full_name} >= ?", time] + elsif time && status == "_to" + @search_list << ["#{full_name} < ?", time+(1.day)] + end + end + end + end + end + +end diff --git a/app/controllers/admin/campaigns_controller.rb b/app/controllers/admin/campaigns_controller.rb new file mode 100644 index 0000000..b3a1fdc --- /dev/null +++ b/app/controllers/admin/campaigns_controller.rb @@ -0,0 +1,131 @@ +require 'kconv' + +class Admin::CampaignsController < Admin::BaseController + resource_controller + before_filter :admin_permission_check_campaign + before_filter :design_init, :only=>[:campaign_design, :campaign_design_update] + + PAGE_TYPE_PC_OPEN = "open_pc" + PAGE_TYPE_PC_END = "end_pc" + PAGE_TYPE_MOBILE_OPEN = "open_mobile" + PAGE_TYPE_MOBILE_END = "end_mobile" + + index.before do + @campaigns = Campaign.find(:all, :order => "id") + end + + [create, update].each do |action| + #action.before do + # @campaign.set_product_id + #end + + action.wants.html do + redirect_to :action => "index" + end + end + + def csv_download + campaign = Campaign.find(params[:id]) + result = Campaign.csv(campaign) + filename = "campaign#{params[:id]}_#{Time.now.strftime('%Y%m%d%H%M%S')}.csv" + headers['Content-Type'] = "application/octet-stream; name=#{filename}" + headers['Content-Disposition'] = "attachment; filename=#{filename}" + render :text => Iconv.conv('cp932', 'UTF-8', result) + end + + def campaign_design + @type = params[:type] + @id = params[:id] + @campaign = Campaign.find(:first, :conditions=>["id=?", @id]) + get_form_names(@type) + end + + def campaign_design_update + @campaign.attributes = params[:campaign] + @id = params[:id] + @type = params[:type] + + get_form_names(@type) + if @campaign.save + flash[:camp_design] = "更新しました" + redirect_to :action=>"campaign_design", :id=>@id, :type=>@type + else + flash[:camp_design_e] = "更新に失敗しました" + render :action=>"campaign_design", :id=>@id, :type=>@type + end + end + + def campaign_preview + @id = params[:id] + @type = params[:type] + @campaign = Campaign.find(:first, :conditions=>["id=?", @id]) + unless @campaign.product_id.blank? + @product = @campaign.product + end + campaign = Campaign.new(params[:campaign]) + + @free_spaces = Hash::new + @free_space_names = [] + if /.*_mobile$/ =~ @type + is_mobile = true + if /^open_.*/ =~ @type + @status = "open" + else + @status = "end" + end + 3.times do |index| + free_space_name = @type + "_free_space_" + (index+1).to_s + @free_space_names << free_space_name + @free_spaces[free_space_name] = campaign.attributes[free_space_name] + end + @mobile_device = MobileDevice.new + @mobile_device.width = 640 + else + is_mobile = false + if /^open_.*/ =~ @type + @status = "open" + else + @status = "end" + end + 4.times do |index| + free_space_name = @type + "_free_space_" + (index+1).to_s + @free_space_names << free_space_name + @free_spaces[free_space_name] = campaign.send(free_space_name) + end + end + + @admin_preview = true + + if is_mobile + render :template => 'campaigns/show_mobile', :layout => 'base_mobile' + else + render :template => 'campaigns/show', :layout => 'base' + end + end + + private + + def design_init + @campaign = Campaign.find_by_id(params[:id]) + end + + def get_form_names(type) + @form_names = [] + + case type + when PAGE_TYPE_PC_OPEN + @title = "PC用キャンペーン中ページデザイン編集" + @form_names = ["open_pc_free_space_1", "open_pc_free_space_2", "open_pc_free_space_3", "open_pc_free_space_4"] + when PAGE_TYPE_PC_END + @title = "PC用キャンペーン終了ページデザイン編集" + @form_names = ["end_pc_free_space_1", "end_pc_free_space_2", "end_pc_free_space_3", "end_pc_free_space_4"] + when PAGE_TYPE_MOBILE_OPEN + @title = "携帯用キャンペーン中ページデザイン編集" + @form_names = ["open_mobile_free_space_1", "open_mobile_free_space_2", "open_mobile_free_space_3"] + when PAGE_TYPE_MOBILE_END + @title = "携帯用キャンペーン終了ページデザイン編集" + @form_names = ["end_mobile_free_space_1", "end_mobile_free_space_2", "end_mobile_free_space_3"] + end + end + +end diff --git a/app/controllers/admin/categories_controller.rb b/app/controllers/admin/categories_controller.rb new file mode 100644 index 0000000..b48b864 --- /dev/null +++ b/app/controllers/admin/categories_controller.rb @@ -0,0 +1,50 @@ +class Admin::CategoriesController < Admin::BaseController + resource_controller + + index.before do + @category = Category.find_by_id(params[:id]) + if @category + params[:category_id] ||= @category.parent_id + end + + @categories = Category.get_list(params[:category_id]) + @category ||= Category.new + end + + create.before do + @category.position_up + end + + create.after do + Category.update_all("children_ids = null") + end + + update.after do + Category.update_all("children_ids = null") + end + + [create, update].each do |action| + action.wants.html do + redirect_to :action => "index", :category_id => @category.parent_id + end + end + + def up + super + redirect_to :action => "index", :category_id => @record.parent_id + end + + def down + super + redirect_to :action => "index", :category_id => @record.parent_id + end + + destroy.before do + @parent_id = @category.parent_id + end + + destroy.after do + Category.re_position(@paremt_id) + end + +end diff --git a/app/controllers/admin/customers_controller.rb b/app/controllers/admin/customers_controller.rb new file mode 100644 index 0000000..8e22d0d --- /dev/null +++ b/app/controllers/admin/customers_controller.rb @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- +require 'pp' +require 'csv' +require 'kconv' + +class Admin::CustomersController < Admin::BaseController + before_filter :admin_permission_check_customer + resource_controller + + index.before do + @condition = CustomerSearchForm.new({}) + end + + def search + @condition = CustomerSearchForm.new(params[:condition]) + unless @condition.valid? + render :action => "index" + return + end + condition_sql = CustomerSearchForm.get_sql_select + CustomerSearchForm.get_sql_condition(@condition) + @customers = Customer.paginate_by_sql(condition_sql, + :page => params[:page], + :per_page => @condition.search_par_page, + :order => "id") + end + + edit.before do + get_customer + + @order_count = Order.count(:conditions => ["customer_id=?", params[:id]]) + @orders = Order.find(:all, :conditions => ["customer_id=?", params[:id]], + :include => :order_deliveries, :order => "orders.id,order_deliveries.id") + end + + def confirm + get_customer + + @order_count = params[:order_count] + unless @customer.valid? + render :action => :edit, :id => @customer.id + end + end + + update.wants.html do + redirect_to :action => :index + end + + def csv_download + csv_data = CustomerSearchForm.csv(params) + unless csv_data + flash.now[:notice] = 'ダウンロード対象データが1件もありませんでした' + render :action => :index + return + end + file_name = "customers_" + Time.now.strftime('%Y%m%d%H%M%S') + ".csv" + send_data csv_data.tosjis, :type => 'text/csv; charset=Shift_JIS', :filename => file_name + end + + def csv_upload + line = 0 + file = params[:upload_file] + + begin + if CSVUtil.valid_data_from_file?(file) + line, result = Customer.add_by_csv(file) + unless result + line = line + 1 + flash.now[:notice] = "#{line}行目のデータが不正です。最初からやり直して下さい。" + redirect_to :action => "index" + return + end + flash.now[:notice] = "#{line}件のデータが登録されました" + redirect_to :action => "index" + else + flash.now[:notice] = "CSVファイルが空か、指定されたファイルが存在しません" + redirect_to :action => "index" + end + rescue => e + logger.error("custermers_controller#csv_upload catch error: " + e.to_s) + flash.now[:notice] = "エラーが発生しました。最初からやり直して下さい。" + redirect_to :action => "index" + end + end + + private + + def get_customer + @customer = Customer.find_by_id(params[:id]) + @customer.attributes = params[:customer] + end + +end + + + + + diff --git a/app/controllers/admin/designs_controller.rb b/app/controllers/admin/designs_controller.rb new file mode 100644 index 0000000..8d84abe --- /dev/null +++ b/app/controllers/admin/designs_controller.rb @@ -0,0 +1,41 @@ +class Admin::DesignsController < Admin::BaseController + before_filter :admin_permission_check_pc_edit, :only => [:index, :pc, :update] + before_filter :admin_permission_check_mobile_edit, :only => :mobile + + def index + redirect_to :action => 'pc' + end + + def pc + @design = Design.first || Design.new + end + + def update_pc + @design = Design.first || Design.new + + if @design.update_attributes(params[:design]) + flash.now[:notice] = '保存しました。' + redirect_to :action => :pc + else + flash.now[:errors] = "保存に失敗しました" + render :action => :pc + end + end + + def mobile + @design = Design.first || Design.new + end + + def update_mobile + @design = Design.first || Design.new + + if @design.update_attributes(params[:design]) + flash.now[:notice] = "保存しました" + else + flash.now[:errors] = "保存に失敗しました" + end + + redirect_to :action => "mobile" + end + +end diff --git a/app/controllers/admin/feature_products_controller.rb b/app/controllers/admin/feature_products_controller.rb new file mode 100644 index 0000000..a8f00d3 --- /dev/null +++ b/app/controllers/admin/feature_products_controller.rb @@ -0,0 +1,97 @@ +class Admin::FeatureProductsController < Admin::BaseController + #共通 + resource_controller + before_filter :admin_permission_check_feature + + #indexの前処理 + index.before do + @feature = Feature.find_by_id(params[:feature_id]) + if @feature + @feature_products = @feature.feature_products + else + flash.now[:notice] = "特集が見つかりません" + redirect_to :action => :index + end + end + + #newの前処理 + new_action.before do + #@feature = Feature.find_by_id(params[:feature_id]) + @feature_product = FeatureProduct.new({:feature_id => params[:feature_id]}) + @feature_product.attributes = params[:feature_product] + end + + #確認画面 + def confirm + @feature_product = FeatureProduct.new(params[:feature_product]) + #入力チェック + unless @feature_product.valid? + render :action => :new + return + end + #画像表示処理 + set_resource_old + end + + #編集 + edit.before do + @feature_product.attributes = params[:feature_product] + end + + #商品登録用の商品検索 + def product_search + + @condition = SearchForm.new(params[:condition]) + + unless @condition.searched == "true" + render :layout=> false + return false + end + + cond = "" + value = {} + unless @condition.keyword.blank? + cond += "products.name like :product_name" + value[:product_name] = "%" + @condition.keyword + "%" + end + unless @condition.category_id.blank? + cond += " and " unless @condition.keyword.blank? + cond += "categories.id = :category_id" + value[:category_id] = @condition.category_id + end + conditions = [cond, value] + + #検索結果 + @products = ProductStyle.paginate(:page=>params[:page], + :conditions=>conditions, + :order=>"products.id", + :include => [:product, {:product => :category}], + :per_page=>10) + render :layout=> false + end + + #確認画面表示前の画像表示処理 + def set_resource_old + #画像入力欄に選択された場合のみ=>選択した画像 + #それ以外、商品一覧の画像で表示・登録 + product = Product.find_by_id(params[:feature_product][:product_id]) + small_resource = product.small_resource if product + if params[:feature_product_image_resource_old_id] && params[:feature_product_image_resource_old_id] == 0.to_s && params[:feature_product][:image_resource].blank? + @feature_product[:image_resource_id] = small_resource.id + elsif params[:feature_product] && !params[:feature_product][:image_resource].blank? + @feature_product[:image_resource] = params[:feature_product][:image_resource] + elsif params[:feature_product] && !params[:feature_product][:image_resource_id].blank? + @feature_product[:image_resource_id] = params[:feature_product][:image_resource_id] + else + @feature_product[:image_resource] = small_resource + end + end + + #遷移先指定 + [create, update, destroy].each do |action| + action.wants.html do + redirect_to :action => :index, :feature_id =>@feature_product.feature_id + end + end + +end diff --git a/app/controllers/admin/features_controller.rb b/app/controllers/admin/features_controller.rb new file mode 100644 index 0000000..70910aa --- /dev/null +++ b/app/controllers/admin/features_controller.rb @@ -0,0 +1,59 @@ +class Admin::FeaturesController < Admin::BaseController + #共通 + resource_controller + before_filter :admin_permission_check_feature + + #indexの前処理 + index.before do + @feature = Feature.new + @features = Feature.find(:all, :order => "id") + end + + #newの前処理 + new_action.before do + @feature = Feature.new(params[:feature]) + end + + #編集 + edit.before do + @feature.attributes = params[:feature] + end + + #遷移先指定 + [create, update].each do |action| + action.wants.html do + redirect_to :action => "index" + end + end + + #確認画面 + def confirm + if params[:id] + @feature = Feature.find_by_id(params[:id]) + @feature.attributes = params[:feature] + else + @feature = Feature.new(params[:feature]) + end + set_resource_old + #入力チェック + unless @feature.valid? + render :action => :new + return + end + end + + #確認画面表示前の画像表示処理 + def set_resource_old + image_resource_id = params["feature_image_resource_old_id".intern] + if image_resource_id.to_s == 0.to_s + if params[:feature][:image_resource].blank? + @feature["image_resource_id".intern] = nil + else + @feature[:image_resource] = params[:feature][:image_resource] + end + else + @feature["image_resource_id".intern] = image_resource_id unless params[:feature][:image_resource] + end + end + +end diff --git a/app/controllers/admin/home_controller.rb b/app/controllers/admin/home_controller.rb new file mode 100644 index 0000000..e16a1d8 --- /dev/null +++ b/app/controllers/admin/home_controller.rb @@ -0,0 +1,48 @@ +class Admin::HomeController < Admin::BaseController + before_filter :admin_login_check + #include AdminControllerModule + + def index + ### 検索に必要な日付 ここから### + # 今日 + today = Date.today + # 昨日 + yesterday = today - 1 + # 今月の1日 + today_one = Date.new(today.year, today.month, 1) + ### 検索に必要な日付 ここまで### + + #ショップの状況 + #現在の会員数 + @active_customer_num = Customer.count(:conditions=>["activate=?", Customer::TOUROKU]) + #昨日の受注金額 + @last_day_sales = OrderDelivery.sum(:payment_total, + :joins =>"LEFT JOIN orders ON order_deliveries.order_id = orders.id", + :conditions => ["(? <= orders.received_at and orders.received_at < ?) and order_deliveries.status in (?, ?, ?, ?)", + yesterday.to_s, today.to_s, OrderDelivery::JUTYUU, OrderDelivery::HASSOU_TEHAIZUMI, OrderDelivery::HASSOU_TYUU, OrderDelivery::HAITATU_KANRYO]) + + #昨日の受注件数 + @last_day_sales_num = OrderDelivery.count(:joins => "LEFT JOIN orders ON order_deliveries.order_id = orders.id", + :conditions=>["(? <= orders.received_at and ? > orders.received_at) and (status in (?, ?, ?, ?))", + yesterday.to_s, today.to_s, OrderDelivery::JUTYUU, OrderDelivery::HASSOU_TEHAIZUMI, OrderDelivery::HASSOU_TYUU, OrderDelivery::HAITATU_KANRYO]) + #今月の受注金額(昨日まで) + @this_month_sales = OrderDelivery.sum(:payment_total, + :joins =>"LEFT JOIN orders ON order_deliveries.order_id = orders.id", + :conditions => ["(? <= orders.received_at and orders.received_at < ?) and order_deliveries.status in (?, ?, ?, ?)", + today_one.to_s, today.to_s, OrderDelivery::JUTYUU, OrderDelivery::HASSOU_TEHAIZUMI, OrderDelivery::HASSOU_TYUU, OrderDelivery::HAITATU_KANRYO]) + + #今月の受注件数 (昨日まで) + @this_month_sales_num = OrderDelivery.count(:joins => "LEFT JOIN orders ON order_deliveries.order_id = orders.id", + :conditions=>["(? <= orders.received_at and orders.received_at < ?) and (order_deliveries.status in (?, ?, ?, ?))", + today_one.to_s, today.to_s, OrderDelivery::JUTYUU, OrderDelivery::HASSOU_TEHAIZUMI, OrderDelivery::HASSOU_TYUU, OrderDelivery::HAITATU_KANRYO]) + #品切れ商品 + @sold_outs = ProductStyle.find(:all, :conditions => <<-EOS, + product_styles.actual_count <= 0 + EOS + :joins => "LEFT JOIN products ON products.id = product_styles.product_id ", + :select => "products.name, product_styles.code", + :order => "products.id") + + @new_orders = OrderDelivery.find(:all, :order=>"created_at DESC", :limit=>10) + end +end diff --git a/app/controllers/admin/mail_magazine_templates_controller.rb b/app/controllers/admin/mail_magazine_templates_controller.rb new file mode 100644 index 0000000..af49a3d --- /dev/null +++ b/app/controllers/admin/mail_magazine_templates_controller.rb @@ -0,0 +1,25 @@ +class Admin::MailMagazineTemplatesController < Admin::BaseController + resource_controller + mobile_filter + emoticon_filter + before_filter :admin_permission_check_template + + new_action.before do + @mail_magazine_template.form = 2 + end + + [create, update].each do |action| + action.wants.html do + redirect_to :action => "index" + end + end + + def preview + @mail_magazine_template = MailMagazineTemplate.find_by_id(params[:id]) || MailMagazineTemplate.new + unless @mail_magazine_template.id + flash.now[:error] = "データがありません" + end + render :layout => false + end + +end diff --git a/app/controllers/admin/mail_magazines_controller.rb b/app/controllers/admin/mail_magazines_controller.rb new file mode 100644 index 0000000..ae1e30c --- /dev/null +++ b/app/controllers/admin/mail_magazines_controller.rb @@ -0,0 +1,268 @@ +require 'pp' +require 'drb' + +class Admin::MailMagazinesController < Admin::BaseController + resource_controller + before_filter :admin_permission_check_sending, :expect => :history + before_filter :admin_permission_check_sending_log, :only => :history + + cattr_accessor :drb_uri + DEFAULT_DRB_URI = 'druby://0.0.0.0:9999' +# DEFAULT_DRB_URI = 'druby://mail4.kbmj.com' + + emoticon_filter + + index.before do + @condition = MailMagazineSearchForm.new({}) + end + + def search + @condition = MailMagazineSearchForm.new(params[:condition]) + if params[:on_form] == 'true' + session[:except_list] = nil + end + + unless @condition.valid? + render :action => 'index' + return + end + session[:condition_save] = @condition + @customers = Customer.paginate_by_sql(MailMagazine.get_sql_select + MailMagazine.get_sql_condition(@condition), + :page => params[:page], + :per_page => @condition.search_par_page, + :order => "id") + + all_customers = Customer.find_by_sql(MailMagazine.get_sql_select + MailMagazine.get_sql_condition(@condition)) + + @check_all = true + customer_ids = [] + if !all_customers.blank? + all_customers.each do |r| + if !session[:except_list].blank? && session[:except_list].include?(r.id.to_s) + r.excepted = true + #画面で表示するのは@customersですので、除外ボックスもセットする + if !@customers.blank? + @customers.each do |c| + if c.id == r.id + c.excepted = true + break + end + end + end + else + @check_all = false + r.excepted = false + end + customer_ids << r.id + end + @customer_ids = customer_ids.join(",") + end + end + + def except_customer + except_list = session[:except_list] ||= [] + if params[:checked] == 'true' + unless except_list.include?(params[:id]) + except_list << params[:id] + end + else + except_list.delete(params[:id]) + end + session[:except_list] = except_list + render :nothing => true + end + + def except_customers + except_list = session[:except_list] ||= [] + excepts = params[:customer_ids].blank? ? [] : params[:customer_ids].split(",") + if params[:checked] == 'true' && !excepts.blank? + if except_list.size == 0 + except_list << excepts + except_list.flatten! + else + excepts.each do |id| + unless except_list.include?(id) + except_list << id + end + end + end + elsif except_list.size > 0 && !excepts.blank? + excepts.each do |id| + except_list.delete(id) + end + end + session[:except_list] = except_list + render :nothing => true + end + + def template_search + @contents = MailMagazineContentsForm.new(params[:contents]) + @customer_ids = params[:customer_ids] + end + + def template_re_search + @contents = MailMagazineContentsForm.new(params[:contents]) + @contents.template_id = id = params[:template_id] + if id.blank? + @contents.attributes = {:form_type=>"", :subject=>"", :body=>""} + else + template = MailMagazineTemplate.find(id, :select => "id,form,subject,body") + @contents.attributes = {:form_type=>template.form, + :subject=>template.subject, + :body=>template.body} + end + + render :partial => "mail_contents" + end + + def confirm + @contents = MailMagazineContentsForm.new(params[:contents]) + @contents.body = hidden_tag_check(@contents.body) + @customer_ids = params[:customer_ids] + unless @contents.valid? + render :action => 'template_search' + return + end + end + + #隠れているタグを取り除く + def hidden_tag_check(body) + check = body.sub(/<(.*)>/, "") + if check.blank? + return check + else + return body + end + end + + def complete + @condition = session[:condition_save] + except_list = session[:except_list] ||= [] + if @condition.blank? + redirect_to :ation => "index" + end + condition_data = MailMagazineCondition.new(@condition).to_yaml + @customers = Customer.find_by_sql(MailMagazine.get_sql_select + MailMagazine.get_sql_condition(@condition, except_list)) + + @contents = MailMagazineContentsForm.new(params[:contents]) + mm = MailMagazine.new + mm.subject = @contents.subject + mm.body = @contents.body + mm.condition = condition_data + mm.schedule_case = @customers.size + mm.delivered_case = 0 + mm.sent_start_at = Time.now + + unless mm.save + flash[:magazine_e] = "保存に失敗しました" + redirect_to :action => 'index' + return + end + + #customer_ids = params[:customer_ids].split(/\s*,\s*/) + ids_int = [] + @customers.each do |c| + ids_int << c.id.to_i + end + customers = Customer.find_all_by_id(ids_int) + + #メール送信 + begin + delivered_case = deliver_mail(customers, @contents) + rescue =>e + logger.error(e.message) + e.backtrace.each{|s|logger.error(s)} + flash[:magazine_e] = "メールの送信に失敗しました" + redirect_to :action => 'index' + return + end + + mm.delivered_case = delivered_case + mm.sent_end_at = Time.now + if mm.save + flash[:magazine] = "保存しました" + else + flash[:magazine_e] = "保存に失敗しました" + redirect_to :action => 'index' + return + end + + + session[:condition_save] = nil + redirect_to :action => "history" + end + + def history + @histories = MailMagazine.paginate( + :page => params[:page], + :per_page => 20, + :order => "updated_at DESC") + end + + def preview + mm = MailMagazine.find(params[:id]) + @subject = mm.subject + @body = mm.body.gsub(/\n/,'
') if mm.body + render :layout=>false + end + + def condition_view + mm = MailMagazine.find(params[:id]) + @condition = {} + if mm && mm.condition + @condition = YAML.load(mm.condition) + end + render :layout => false + end + + destroy.wants.html do + redirect_to :action => "history" + end + + private + class MailMagazineCondition + attr_accessor :customer_name_kanji, :customer_name_kana, :prefecture_id, :tel_no + attr_accessor :sex_male, :sex_female, :birth_month, :form_type + attr_accessor :order_count_up, :order_count_down, :product_code + attr_accessor :total_up, :total_down, :email, :mail_type + attr_accessor :occupation_id, :birthday_from, :birthday_to + attr_accessor :updated_at_from, :updated_at_to + attr_accessor :last_order_from, :last_order_to + attr_accessor :category_id, :product_name, :campaign_id + + def initialize(c) + c.attributes.each do |k,v| + if respond_to? k + "=" + if k =~ /_from$/ || k =~ /_to$/ + if !v.blank? + send(k + "=", v.strftime("%Y-%m-%d %H:%M:%S")) + end + else + send(k + "=", v) + end + end + end + end + end + + def deliver_mail(customers, contents) + customers.blank? and return 0 + delivered_case = 0 + drb = DRb::DRbObject.new_with_uri(@@drb_uri||DEFAULT_DRB_URI) + customers.each do |c| + if contents.form_type.to_i == MailMagazineTemplate::TEXT + mail = Notifier::create_text_mailmagazine(c, contents.body, contents.subject) + else + #mail = Notifier::create_html_mailmagazine(c, contents.body, contents.subject) + mail = MobileHtmlNotifier::create_html_mailmagazine(c, contents.body, contents.subject) + end + begin + timeout(1) do + drb.add(mail) + delivered_case += 1 + end + end + end #customers.each + delivered_case + end +end diff --git a/app/controllers/admin/mail_template_controller.rb b/app/controllers/admin/mail_template_controller.rb new file mode 100644 index 0000000..7219ada --- /dev/null +++ b/app/controllers/admin/mail_template_controller.rb @@ -0,0 +1,2 @@ +class Admin::MailTemplateController < Admin::BaseController +end diff --git a/app/controllers/admin/mobile_devices_controller.rb b/app/controllers/admin/mobile_devices_controller.rb new file mode 100644 index 0000000..f1ad4f5 --- /dev/null +++ b/app/controllers/admin/mobile_devices_controller.rb @@ -0,0 +1,66 @@ +class Admin::MobileDevicesController < Admin::BaseController + resource_controller + before_filter :admin_permission_check_mobile + before_filter :list + + index.before do + list + end + + def search + render :action => 'index' + end + + new_action.wants.html do + redirect_to :action => "index" + end + + [create, update].each do |action| + action.before do + @mobile_device.attributes = params[:mobile_device] + end + + action.wants.html do + redirect_to :action => "index" + end + + action.failure.after do + @mobile_device.remove_precent + end + + action.failure.wants.html do + unless @mobile_device.valid? + render :action => "index" + end + end + end + + private + + def list + unless params[:id].blank? + @mobile_device = MobileDevice.find_by_id(params[:id]) + @mobile_device.user_agent = remove_percent(@mobile_device.user_agent) + @status = "update" + @method = "put" + @id = params[:id] + else + @mobile_device = MobileDevice.new + @status = "create" + @method = "post" + end + + @search = SearchForm.new(params[:search]) + @search.mobile_carrier_id = @search.mobile_carrier_id.to_i if @search.mobile_carrier_id + get_conditions + @mobile_devices = MobileDevice.paginate(:all, + :conditions => flatten_conditions(@search_list||[]), + :order => "mobile_carrier_id,device_name", + :page => params[:page], + :per_page => 20) + end + + def remove_percent(str) + str.gsub(/%/, '') + end +end diff --git a/app/controllers/admin/new_informations_controller.rb b/app/controllers/admin/new_informations_controller.rb new file mode 100644 index 0000000..85c0016 --- /dev/null +++ b/app/controllers/admin/new_informations_controller.rb @@ -0,0 +1,58 @@ +class Admin::NewInformationsController < Admin::BaseController + resource_controller + before_filter :admin_permission_check_whats_new + +# index.before do +# @new_informations = NewInformation.find(:all, :order => "position") +# end + + def index + @new_informations = NewInformation.find(:all, :order => "position") + end + + def confirm + @new_information = NewInformation.find_by_id(params[:id]) || NewInformation.new + @new_information.attributes = params[:new_information] + unless @new_information.valid? + #redirect_to :action => (params[:id].blank? ? "new" : "edit") + if params[:id].blank? and params[:new_information][:id].blank? + render :action => "new" + else + render :action => "edit" + end + end + end + + [create, update].each do |action| + action.wants.html do + redirect_to :action => "index" + end + end + + edit.before do + #params[:id] = params[:id] || params[:new_information][:id] + #p params[:id] + unless params[:new_information].blank? + @new_information = NewInformation.find_by_id(params[:new_information][:id]) + @new_information.attributes = params[:new_information] + params[:id] = params[:new_information][:id] + end + end + + def up + super + redirect_to :action => "index" + end + + def down + super + redirect_to :action => "index" + end + + def change_position + super + #format.html {redirect_to :action => "index"} + redirect_to :action => "index" + end + +end diff --git a/app/controllers/admin/order_statuses_controller.rb b/app/controllers/admin/order_statuses_controller.rb new file mode 100644 index 0000000..70d15c6 --- /dev/null +++ b/app/controllers/admin/order_statuses_controller.rb @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +require 'ostruct' + +class Admin::OrderStatusesController < Admin::BaseController + before_filter :admin_permission_check_receive_status + + def index + @selected_status = params[:select] || OrderDelivery::YOYAKU_UKETSUKE + list + end + + # 選択された物のステータスを全て変更する + def update + if params[:id_array] + begin + OrderDelivery.transaction do + params[:id_array].each do | id | + if order_delivery = OrderDelivery.find_by_id(id) + order_delivery.status = params[:new_status] + order_delivery.update_ticket(params[:order_delivery_ticket_code][id]) + order_delivery.save! + end + end + flash[:status] = "保存しました" + end + rescue + flash[:status_e] = "保存に失敗しました" + end + end + redirect_to :action => "index", :select => params[:select] + end + + def csv_upload + line = 0 + update_line = 0 + file = params[:upload_file] + begin + if CSVUtil.valid_data_from_file?(file) + line, update_line, result = OrderDelivery.update_by_csv(file) + unless result + line = line + 1 + flash[:status] = "#{line}行目のデータが不正です。最初からやり直して下さい。" + redirect_to :action => "index" + return + end + if update_line == 0 + flash[:status] = "更新されたデータがありません。" + redirect_to :action => "index" + return + end + flash[:status] = "#{update_line}件のデータが登録されました" + redirect_to :action => "index" + else + flash[:status] = "CSVファイルが空か、指定されたファイルが存在しません" + redirect_to :action => "index" + end + rescue => e + logger.error("order_statuses_controller#csv_upload catch error: " + e.to_s) + flash[:status] = "エラーが発生しました。最初からやり直してく下さい。" +# flash[:error] = e.to_s + redirect_to :action => "index" + end + + end + + private + + def list + get_conditions + @order_deliveries = OrderDelivery.paginate( + :page => params[:page], + :per_page => 10, + :conditions => flatten_conditions(@search_list), + :order => "id desc" + ) + end + + def get_conditions + @search_list = [] + + status = params[:select] || OrderDelivery::YOYAKU_UKETSUKE + @search_list << ["status=?", status] + end +end diff --git a/app/controllers/admin/orders_controller.rb b/app/controllers/admin/orders_controller.rb new file mode 100644 index 0000000..ce5d227 --- /dev/null +++ b/app/controllers/admin/orders_controller.rb @@ -0,0 +1,159 @@ +# -*- coding: utf-8 -*- +require 'csv' + +class Admin::OrdersController < Admin::BaseController + before_filter :admin_permission_check_receive + before_filter :load_search_form + after_filter :save_search_form + + def index + get_search_form + end + + def search + list + end + + def edit + if params[:recalculate] + recalculate + return + end + if request.method == :put + update + return + end + @order_delivery = OrderDelivery.find_by_order_id(params[:id]) + @order_delivery_ticket = @order_delivery.ticket_code + select_delivery_time + end + + def recalculate + get_order_delivery + update_details + @order_delivery.calculate_total! + # 常に edit を再表示 + render :action => "edit" + end + + def update + get_order_delivery + #@order_delivery = OrderDelivery.find_by_order_id(params[:id]) + if @order_delivery.nil? + raise ActiveRecord::RecordNotFound + end + begin + OrderDelivery.transaction do + @order_delivery.update_attributes!(params[:order_delivery]) + @order_delivery.update_ticket(params[:order_delivery_ticket]) + complete_details + flash.now[:notice] = "保存しました" + redirect_to :action => 'index' + end + rescue => e + @order_delivery = OrderDelivery.find_by_order_id(params[:id]) + @order_delivery_ticket = @order_delivery.ticket_code + select_delivery_time + flash.now[:error] = "保存に失敗しました" + render :action => 'edit' + end + end + + def destroy + # 親と子も消す + order_delivery = OrderDelivery.find(:first, :conditions => ["id=?", params[:id]]) + begin + raise if order_delivery.nil? + order_delivery.order_details.each(&:destroy) + order = order_delivery.order + order_delivery.destroy + order.destroy + flash.now[:notice] = "削除しました" + rescue + flash.now[:error] = "削除に失敗しました" + end + redirect_to :action => "index" + end + + def show + get_order_delivery + select_delivery_time + if @order_delivery.nil? + raise ActiveRecord::RecordNotFound + end + render :layout => false + end + + def csv_download + get_search_form + csv_data, filename = Order.csv(@search_list) + headers['Content-Type'] = "application/octet-stream; name=#{filename}" + headers['Content-Disposition'] = "attachment; filename=#{filename}" + render :text => Iconv.conv('cp932', 'UTF-8', csv_data) + end + + private + + def select_delivery_time + h = @order_delivery || params + payment_id = h[:payment_id] + @selected = h[:delivery_time_id] + delivery_times = DeliveryTime.find( + :all, :conditions => ["payments.id=? and delivery_times.name <> ''", payment_id], + :include => [:delivery_trader=>:payments], :order => 'delivery_times.position') + @options = [['指定なし', nil]] + @options.concat(delivery_times.map do |dt| + [dt.name, dt.id] + end) + end + + def get_order_delivery + @order_delivery = OrderDelivery.find_by_order_id(params[:id]) + @order_delivery.attributes = params[:order_delivery] + end + + def get_search_form + @search = SearchForm.new(params[:search]) + @search, @search_list, @sex, @payment_id = Order.get_conditions(@search, params) + end + + def list + get_search_form + + find_options = { + :page => params[:page], + :per_page => @search.per_page || 10, + :conditions => flatten_conditions(@search_list), + :include => OrderDelivery::DEFAULT_INCLUDE, + :order => "order_deliveries.id desc" + } + @order_deliveries = OrderDelivery.paginate(find_options) + end + + def update_details + return if params[:detail].nil? + @order_delivery.order_details.each do | detail | + detail.attributes = params[:detail][detail.id.to_s] + end + end + + def complete_details + return unless params[:detail] + params[:detail].each do |id, values| + order_detail = OrderDetail.find(id) + order_detail.update_attributes!(values) + end + end + + def save_search_form + if @search + flash.now[:order_search] = @search.attributes.reject{|_,v|v.blank?} + end + end + + def load_search_form + unless @search + @search = SearchForm.new(flash.now[:order_search]) + end + end +end diff --git a/app/controllers/admin/payment_controller.rb b/app/controllers/admin/payment_controller.rb new file mode 100644 index 0000000..5f15ad1 --- /dev/null +++ b/app/controllers/admin/payment_controller.rb @@ -0,0 +1,2 @@ +class Admin::PaymentController < Admin::BaseController +end diff --git a/app/controllers/admin/product_styles_controller.rb b/app/controllers/admin/product_styles_controller.rb new file mode 100644 index 0000000..bddf2f9 --- /dev/null +++ b/app/controllers/admin/product_styles_controller.rb @@ -0,0 +1,119 @@ +class Admin::ProductStylesController < Admin::BaseController + before_filter :admin_permission_check_product, + :only => [:create, :new] + + def new + @product = Product.find_by_id(params[:id]) + set_product_styles(params[:id]) + set_style_category + end + + def create_form + @product = Product.find_by_id(params[:id]) + set_style_category + if @style1.nil? && ! @style2.nil? + @error_message = "規格1が無い状態で規格 2を登録出来ません。" + end + if @style1 && @style1 == @style2 + @error_message = "規格1、規格2で同一規格の選択はできません" + end + render :layout => false + end + + def confirm + set_product_styles + set_style_category + logger.debug "#{@product_styles.size } ----" + unless @save_flg + render :action => "new" + end + end + + def create + set_product_styles + + if @save_flg + @product.product_styles = @product_styles if @product.product_styles.empty? + @product.have_product_style = true + @product.save + flash.now[:notice] = "保存しました" + else + flash.now[:error] = "保存に失敗しました" + end + redirect_to :controller => "products", :action => "index" + end + + protected + + def set_style_category + @product_product_styles ||= [] + if params[:style_id1] + @style1 = Style.find_by_id(params[:style_id1]) unless params[:style_id1].blank? + @style2 = Style.find_by_id(params[:style_id2]) unless params[:style_id2].blank? + if @product_product_styles.blank? + @product.product_styles.each do | p_s | + @product_product_styles << p_s + end + end + else + unless @product.product_styles.empty? + @product.product_styles.each do | p_s | + @product_product_styles << p_s + end + #p @product_product_sytles + @style1 = @product.product_styles.first.style_category1 && @product.product_styles.first.style_category1.style + @style2 = @product.product_styles.first.style_category2 && @product.product_styles.first.style_category2.style + end + end + @style_category1 = @style1.style_categories if @style1 + @style_category2 = @style2.style_categories if @style2 + @style_category1 ||= [nil] + @style_category2 ||= [nil] + + @product_style_flg = false + @product_styles = {} + @product_product_styles.each do |p_s| + @product_style_flg = true + @product_styles["#{p_s.style_category_id1}_#{p_s.style_category_id2}"] = p_s + logger.debug "#{p_s.style_category_id1}_#{p_s.style_category_id2}" + end + end + + def set_product_styles(id = params[:product_id]) + @product = Product.find_by_id(id) + if params[:product_styles] + @product_styles = [] + @save_flg = true + params[:product_styles].each do |idx, value| + if value[:enable] == "on" + unless product_style = ProductStyle.find(:first, + :conditions => ["style_category_id1 #{value[:style_category1].blank? ? "is" : "=" } :style_category_id1 and style_category_id2 #{value[:style_category2].blank? ? "is" : "=" } :style_category_id2 and product_id = :product_id", + {:style_category_id1 => value[:style_category1].blank? ? nil : value[:style_category1] , :style_category_id2 => value[:style_category2].blank? ? nil : value[:style_category2], :product_id => @product.id }]) + product_style = ProductStyle.new(:style_category_id1 => value[:style_category1], + :style_category_id2 => value[:style_category2]) + end + if product_style[:id] + product_style.update_attributes({:sell_price=>value[:sell_price], + :actual_count=>value[:actual_count], + :code=>value[:code]}) + else + [:sell_price, :actual_count, :code].each do |column| + product_style[column] = value[column] + end + product_style[:position] = idx.to_i + 1 + end + logger.debug " ------" + logger.debug product_style + @product_styles << product_style + logger.debug "#{@product_styles.size } ----" + unless product_style.valid? + @save_flg = false + @error_messages ||= "" + @error_messages += "#{idx.to_i + 1}行目が不正です。" + end + end + end + end + end + +end diff --git a/app/controllers/admin/products_controller.rb b/app/controllers/admin/products_controller.rb new file mode 100644 index 0000000..ea7af5e --- /dev/null +++ b/app/controllers/admin/products_controller.rb @@ -0,0 +1,223 @@ +# -*- coding: utf-8 -*- +require 'nkf' +class Admin::ProductsController < Admin::BaseController + resource_controller + before_filter :admin_permission_check_product, + :only => [:index, :show, :actual_count_list, :destroy] + before_filter :admin_permission_check_product_entry, + :only => [:new, :create, :update, :complete] + before_filter :load_search_form + after_filter :save_search_form + + def index + get_search_form + end + + def search + get_search_form + find_options = { + :page => params[:page], + :per_page => @search.per_page || 10, + :conditions => flatten_conditions(@search_list), + :include => Product::DEFAULT_INCLUDE, + :order => "products.id" + } + @products = Product.paginate(find_options) + end + + new_action.before do + get_product + + get_product_status_by_params + get_sub_product_by_params + if params[:copy] + @old_product = Product.find_by_id(params[:id]) + @old_product.id = nil + params[:id] = nil + @product = Product.new @old_product.attributes.reject{ |key, value| key.to_s == "id" } + else + @product = Product.new(params[:product]) + @product.sale_end_at = Date.today + 3 * 365 #30年後 + @product.public_end_at = Date.today + 3 * 365 #30年後 + end + end + + def confirm + get_product + + get_sub_product_by_params + get_product_status_by_params + set_resource_old + + unless @product.valid? + render :action => (params[:id].blank? ? "new" : "edit") + end + end + + create.before do + get_sub_product_by_params + get_product_status_by_params + @product.product_statuses = @product_statuses + @product.sub_products = @sub_products + end + + edit.before do + get_product + + @product_statuses = ProductStatus.find(:all, :conditions=>["product_id=?", params[:id]]) + get_sub_product_by_params + get_product_status_by_params + end + + update.before do + get_sub_product_by_params + get_product_status_by_params + @product.product_statuses = @product_statuses + @product.sub_products = @sub_products + end + + + #在庫切れ一覧 + def actual_count_index + get_search_form(true) + end + + def actual_count_search + get_search_form(true) + unless @search.no_product_style_count && @search.no_product_style_count.to_s == 1.to_s + @search_list << ["product_styles.actual_count<=0"] + end + find_options = { + :page => params[:page], + :per_page => @search.per_page || 10, + :conditions => flatten_conditions(@search_list), + :joins => "LEFT JOIN products ON products.id = product_styles.product_id ", + :order => "id" + } + @products = ProductStyle.paginate(find_options) + end + + def permit_setting + params[:product_permit_ids] and params[:product_permit_ids].each do | id | + product = Product.find_by_id id + permit = params[:product_permit] && params[:product_permit][id] + product.permit = permit == "true" ? true : false + product.save_without_validation + end + redirect_to :action => "search", :search => params[:search], :page => params[:page] + end + + def csv_download + @search_list = [] + get_search_form + csv_data, filename = Product.csv(@search_list) + headers['Content-Type'] = "application/octet-stream; name=#{filename}" + headers['Content-Disposition'] = "attachment; filename=#{filename}" + render :text => NKF.nkf('-s', csv_data) + end + + def csv_upload + line = 0 + file = params[:upload_file] + + begin + if CSVUtil.valid_data_from_file?(file) + line, result = Product.add_by_csv(file) + unless result + line = line + 1 + flash[:product_csv_upload_e] = "#{line}行目のデータが不正です。最初からやり直して下さい。" + redirect_to :action => "index" + return + end + flash[:product_csv_upload] = "#{line}件のデータが登録されました" + redirect_to :action => "index" + else + flash[:product_csv_upload_e] = "CSVファイルが空か、指定されたファイルが存在しません" + redirect_to :action => "index" + end + rescue => e + logger.error("product_controller#csv_upload catch error: " + e.to_s) + flash[:product_csv_upload_e] = "エラーが発生しました。最初からやり直して下さい。" + redirect_to :action => "index" + end + end + + def actual_count_csv_download + @search_list = [] + get_search_form + csv_data, filename = Product.actual_count_list_csv(@search_list) + headers['Content-Type'] = "application/octet-stream; name=#{filename}" + headers['Content-Disposition'] = "attachment; filename=#{filename}" + render :text => Iconv.conv('cp932', 'UTF-8', csv_data) + end + + protected + + def set_resource_old + [:small_resource, :medium_resource, :large_resource].each do | resource_name | + resource_id = params["product_#{resource_name}_old_id".intern] + if resource_id.to_s == 0.to_s + if params[:product][resource_name] + @product[resource_name] = params[:product][resource_name] + else + @product["#{resource_name}_id".intern] = nil + end + else + @product["#{resource_name}_id".intern] = resource_id unless params[:product][resource_name] + end + end + end + + def get_sub_product_by_params + @sub_products = [] + @sub_products = SubProduct.find(:all, :conditions => ["product_id = ?",@product.id], :order => "no") unless @product.id.blank? + unless @sub_products.size == 5 + 5.times do |idx| + @sub_products << SubProduct.new(:no => idx ) + end + end + if params[:sub_product] + params[:sub_product].each do |idx, sub_products | + sub_product = @sub_products[idx.to_i] + sub_products.delete(:medium_resource_id) if sub_products && !sub_products[:medium_resource].blank? + sub_products.delete(:large_resource_id) if sub_products && !sub_products[:large_resource].blank? + sub_product.attributes = sub_products + @product.sub_products << sub_product + @sub_products[idx.to_i] = sub_product + end + end + end + + def get_product_status_by_params + @product_statuses ||= [] + if !params[:product_status_ids].blank? + params[:product_status_ids].each do | id | + @product_statuses << ProductStatus.new(:product_id => @product.id, :status_id => id.to_i) + end + end + end + + private + + def get_product + @product = Product.find_by_id(params[:id].to_i) || Product.new + @product.attributes = params[:product] + end + + def get_search_form(actual_flg=false) + @search = SearchForm.new(params[:search]) + @search, @search_list = Product.get_conditions(@search, params, actual_flg) + end + + def save_search_form + if @search + flash.now[:order_search] = @search.attributes.reject{|_,v|v.blank?} + end + end + + def load_search_form + unless @search + @search = SearchForm.new(flash.now[:order_search]) + end + end +end diff --git a/app/controllers/admin/questionnaires_controller.rb b/app/controllers/admin/questionnaires_controller.rb new file mode 100644 index 0000000..559b17b --- /dev/null +++ b/app/controllers/admin/questionnaires_controller.rb @@ -0,0 +1,99 @@ +class Admin::QuestionnairesController < Admin::BaseController + resource_controller + before_filter :admin_permission_check_enquete + QUESTION_COUNT = Questionnaire::QUESTION_COUNT + QUESTION_CHOICE_COUNT = Questionnaire::QUESTION_CHOICE_COUNT + + new_action.before do + @questionnaire.init_data + @questions = @questionnaire.questions + end + + create.before do + #質問項目作成 + @questions = [] + QUESTION_COUNT.times do | question_idx | + choice_id_name = "question#{question_idx}_choice0_format" + question = Question.new(:content=>params[:questions]["#{question_idx}"], + :position=>question_idx+1, + :question_choice_id=>params[choice_id_name]) + question_copy = Question.new(:content=>params[:questions]["#{question_idx}"], + :position=>question_idx+1, + :question_choice_id=>params[choice_id_name]) + #回答選択肢作成 + QUESTION_CHOICE_COUNT.times do | choice_idx | + #チェックボックスおよびラジオボタン時のみquestion_choice.contentセット + content = "" + if params[choice_id_name].to_i == QuestionChoice::CHECKBOX || params[choice_id_name].to_i == QuestionChoice::RADIOBUTTON + content = params["question#{question_idx}_choice#{choice_idx}"] + end + question_choice = QuestionChoice.new(:content => content, + :format => params["question#{question_idx}_choice0_format"], + :position => choice_idx+1) + question.question_choices << question_choice if choice_idx == 0 || (choice_idx > 0 && !question_choice.content.blank?) + question_copy.question_choices << question_choice + end + @questions << question_copy + @questionnaire.questions << question if !question.content.empty? + end + end + + edit.before do + @questions = @questionnaire.get_show_questions_data + end + + update.before do + @id = params[:id] + @old_questions = Question.find(:all, :conditions=>["questionnaire_id=?", @id]) + + @questions = [] + #質問項目更新 + QUESTION_COUNT.times do | question_idx | + choice_id_name = "question#{question_idx}_choice0_format" + question = @questionnaire.questions.build(:content=>params[:questions]["#{question_idx}"], + :position=>question_idx+1, + :question_choice_id=>params[choice_id_name]) if !params[:questions]["#{question_idx}"].empty? + question_copy = Question.new(:content=>params[:questions]["#{question_idx}"], + :position=>question_idx+1, + :question_choice_id=>params[choice_id_name]) + #質問選択肢更新 + QUESTION_CHOICE_COUNT.times do | choice_idx | + #チェックボックスおよびラジオボタン時のみquestion_choice.contentセット + content = "" + if params[choice_id_name].to_i == QuestionChoice::CHECKBOX || params[choice_id_name].to_i == QuestionChoice::RADIOBUTTON + content = params["question#{question_idx}_choice#{choice_idx}"] + end + if question && choice_idx == 0 || (choice_idx > 0 && !content.empty? ) + question.question_choices.build(:content=>content, + :format=>params["question#{question_idx}_choice0_format"], + :position=>choice_idx+1) + end + question_choice = QuestionChoice.new(:content=>content, + :format=>params["question#{question_idx}_choice0_format"], + :position=>choice_idx+1) + question_copy.question_choices << question_choice + end + + @questions << question_copy + end + end + + update.after do + Question.clear_questions(@old_questions) + end + + [create, update].each do |action| + action.wants.html do + redirect_to :action => "index" + end + end + + def csv_download + result = Questionnaire.csv(params[:id], QUESTION_COUNT) + filename = "questionnaire#{params[:id]}_#{Time.now.strftime('%Y%m%d%H%M%S')}.csv" + headers['Content-Type'] = "application/octet-stream; name=#{filename}" + headers['Content-Disposition'] = "attachment; filename=#{filename}" + render :text => Iconv.conv('cp932', 'UTF-8', result) + end + +end diff --git a/app/controllers/admin/recommend_products_controller.rb b/app/controllers/admin/recommend_products_controller.rb new file mode 100644 index 0000000..b5104fb --- /dev/null +++ b/app/controllers/admin/recommend_products_controller.rb @@ -0,0 +1,51 @@ +class Admin::RecommendProductsController < Admin::BaseController + resource_controller + before_filter :admin_permission_check_recommendation + + index.before do + @recommend_products = RecommendProduct.find(:all, + :order => "position") + end + + create.before do + @recommend_product.position_up + end + + [create, update].each do |action| + action.wants.html do + redirect_to :action => "index" + end + end + + #商品検索 + def product_search + @condition = SearchForm.new(params[:condition]) + + unless @condition.searched == "true" + render :layout=> false + return false + end + + cond = "" + value = {} + unless @condition.keyword.blank? + cond += "products.name like :product_name" + value[:product_name] = "%" + @condition.keyword + "%" + end + unless @condition.category_id.blank? + cond += " and " unless @condition.keyword.blank? + cond += "categories.id = :category_id" + value[:category_id] = @condition.category_id + end + conditions = [cond, value] + + #結果表示 + @products = ProductStyle.paginate(:page=>params[:page], + :conditions=>conditions, + :order=>"products.id", + :include => [:product, {:product => :category}], + :per_page=>10) + render :layout=> false + end + +end diff --git a/app/controllers/admin/shops_controller.rb b/app/controllers/admin/shops_controller.rb new file mode 100644 index 0000000..c75a7c9 --- /dev/null +++ b/app/controllers/admin/shops_controller.rb @@ -0,0 +1,451 @@ +class Admin::ShopsController < Admin::BaseController + before_filter :admin_permission_check_shop, :only => [:index, :update] + before_filter :admin_permission_check_commerce_low, + :only => [:tradelaw_index, :tradelaw_update] + before_filter :admin_permission_check_delivery, + :only => [:delivery_index, :delivery_new, :delivery_edit, :delivery_create, :delivery_update, :destroy, :sort] + before_filter :admin_permission_check_payment, + :only => [:payment_index, :payment_new, :payment_edit, :payment_create, :payment_update, :destroy, :sort] + before_filter :admin_permission_check_mail, :only => [:mail_index, :mail_update] + before_filter :admin_permission_check_seo, :only => [:seo_index, :seo_update] + before_filter :admin_permission_check_member_rule, + :only => [:kiyaku_index, :kiyaku_create, :kiyaku_update, :destroy, :sort] + before_filter :admin_permission_check_privacy, :only => [:privacy, :privacy_update] + + def index + @shop = Shop.find(:first) + if @shop + @id=@shop.id + end + end + + + def update + if params[:id] + @shop = Shop.find(:first)#1件のみ返す + @system = System.find(:first) + @shop.attributes = params[:shop] + @system.attributes = params[:system] + else + @shop = Shop.new params[:shop] + @system = System.new params[:system] + end + + unless @shop.valid? && @system.valid? + flash.now[:error] = "保存に失敗しました" + render :action => "index" + return + end + + if @system.save && @shop.save + flash.now[:notice] = "データを保存しました" + else + flash.now[:error] = "データの保存に失敗しました" + end + + redirect_to :action => "index" + end + + + def delivery_index + @model_name = "delivery_trader" + @model = DeliveryTrader + + @delivery_traders = @model.paginate(:page => params[:page], + :per_page => params[:per_page] || 10, + :order => :position) + end + + def delivery_new + @delivery_trader = DeliveryTrader.new + @delivery_time = [] + @delivery_fee = [] + (DeliveryFee::MAX_SIZE-1).times do |index| + df = DeliveryFee.new(:prefecture_id => index+1) + @delivery_fee << df + end + @delivery_fee << DeliveryFee.new + end + + def delivery_edit + @delivery_trader = DeliveryTrader.find(params[:id]) + @delivery_time = @delivery_trader.delivery_times + @delivery_fee = @delivery_trader.delivery_fees + end + + + def delivery_create + @delivery_time=[] + @delivery_fee=[] + + DeliveryTime::MAX_SIZE.times do |index| + dt = DeliveryTime.new(params[:delivery_time]["#{index}"]) + dt.position=index+1 + @delivery_time << dt + end + + DeliveryFee::MAX_SIZE.times do |index| + df = DeliveryFee.new(params[:delivery_fee]["#{index}"]) + df.prefecture_id=index+1 if index<47 + @delivery_fee << df + end + + @delivery_trader = DeliveryTrader.new params[:delivery_trader] + + DeliveryTrader.transaction do + @delivery_trader.position=DeliveryTrader.count+1 + + err_flg=false + err_flg = true unless @delivery_trader.valid? + @delivery_time.each {|dt| err_flg = true unless dt.valid? } + @delivery_fee.each {|df| err_flg = true unless df.valid? } + + if err_flg + flash.now[:error] = "保存に失敗しました" + render :action => "delivery_new" + return + end + + if @delivery_trader.delivery_times << @delivery_time && @delivery_trader.delivery_fees << @delivery_fee&& @delivery_trader.save + flash.now[:notice] = "データを保存しました" + redirect_to :action => "delivery_index" + else + flash.now[:error] = "保存に失敗しました" + render :action => "delivery_new" + end + end + end + + def delivery_update + @delivery_trader = DeliveryTrader.find(params[:id]) + @delivery_time = @delivery_trader.delivery_times + @delivery_fee =@delivery_trader.delivery_fees + DeliveryTime::MAX_SIZE.times do |index| + @delivery_time[index].attributes = params[:delivery_time]["#{index}"] + end + + DeliveryFee::MAX_SIZE.times do |index| + @delivery_fee[index].attributes = params[:delivery_fee]["#{index}"] + end + @delivery_trader.attributes = params[:delivery_trader] + err_flg=false + err_flg = true unless @delivery_trader.valid? + @delivery_time.each {|dt| err_flg = true unless dt.valid? } + @delivery_fee.each {|df| err_flg = true unless df.valid? } + + if err_flg + flash.now[:error] = "保存に失敗しました" + render :action => "delivery_edit" + return + end + DeliveryTrader.transaction do + if @delivery_trader.delivery_times << @delivery_time && @delivery_trader.delivery_fees << @delivery_fee&& @delivery_trader.save + flash.now[:notice] = "データを保存しました" + redirect_to :action => "delivery_index",:id=>params[:id] + else + flash.now[:error] = "保存に失敗しました" + render :action => "delivery_edit" + end + end + end + + def point_index + @shop = Shop.find(:first) + if @shop + @id=@shop.id + end + end + + def point_update + unless params[:id].blank? + @shop = Shop.find(:first) + @shop.attributes = {:point_granted_rate => params[:shop][:point_granted_rate],:point_at_admission =>params[:shop][:point_at_admission]} + else + flash.now[:error] = "保存に失敗しました。" + render :action => "point_index" + return + end + unless @shop.valid? + flash.now[:error] = "保存に失敗しました" + @id = params[:id] + render :action => "point_index" + return + end + if @shop.save + flash.now[:notice] = "データを保存しました" + else + flash.now[:error] = "データの保存に失敗しました" + end + redirect_to :action => "point_index" + end + + def payment_index + @model_name = "payment" + @model = Payment + + @payments = Payment.find(:all, :order => "position") + end + + def payment_new + @payment = Payment.new + end + + def payment_edit + @payment = Payment.find(params[:id]) + if !@payment.id + flash.now[:error] = "該当するデータがありませんでした" + redirect_to :action=>:payment_new + end + end + + def payment_create + @payment = Payment.new params[:payment] + Payment.transaction do + unless @payment.valid? + flash.now[:error] = "保存に失敗しました" + render :action => "payment_new" + return + end + if @payment && @payment.save + flash.now[:notice] = "データを保存しました" + else + flash.now[:error] = "保存に失敗しました" + end + redirect_to :action => "payment_index" + end + end + + def payment_update + @payment = Payment.find(params[:id]) + @payment.attributes = params[:payment] + set_payment_resource_old + unless @payment.valid? + flash.now[:error] = "保存に失敗しました" + render :action => "payment_edit" + return + end + + Payment.transaction do + if @payment && @payment.save + flash.now[:notice] = "データを保存しました" + else + flash.now[:error] = "保存に失敗しました" + end + end + redirect_to :action => "payment_index" + end + + def tradelaw_index + @law = Law.find(:first) + if @law + @status = "update" + @id=@law.id + else + @law = Law.new + @status = "create" + end + end + + def tradelaw_update + if !params[:id].blank? + @law = Law.find(:first) + @law.attributes = params[:law] + else + @law = Law.new params[:law] + end + + unless @law.valid? + flash.now[:error] = "保存に失敗しました" + render :action => "tradelaw_index" + return + end + + if @law && @law.save + flash.now[:notice] = "データを保存しました" + else + flash.now[:error] = "保存に失敗しました" + end + redirect_to :action => "tradelaw_index" + end + + def mail_index + @mail = MailTemplate.new + end + + def mail_search + @id = params[:id] + unless @id.blank? + @mail = MailTemplate.find(@id) + else + @mail = MailTemplate.new + end + render :partial => "mail_form" + end + + def mail_update + id = params[:mail][:id] + unless id.blank? + @mail = MailTemplate.find(id) + @mail.attributes = params[:mail] + else + flash[:mail_e] = "テンプレートを選択してください" + redirect_to :action => "mail_index" + return + end + + unless @mail.valid? + flash[:mail_e] = "保存に失敗しました" + render :action => "mail_index" + return + end + if @mail.save + flash[:mail] = @mail.name + "を保存しました" + else + flash[:mail_e] = "保存に失敗しました" + end + redirect_to :action => "mail_index" + end + + def seo_index + @seos = Seo.find(:all, :order=>"page_type") + end + + def seo_update + @seos = Seo.find(:all, :order=>"page_type") + if !params[:seo][:page_type].blank? + @seo = Seo.find_by_page_type(params[:seo][:page_type]) + @seo.attributes = params[:seo] + else + redirect_to :action => :seo_index + return + end + + unless @seo.valid? + flash.now[:error] = "保存に失敗しました" + render :action => :seo_index + return + end + + if @seo && @seo.save + flash.now[:notice] = "データを保存しました" + else + flash.now[:error] = "の保存に失敗しました" + end + redirect_to :action => :seo_index + end + + def kiyaku_index + kiyaku_list + if params[:id] + @kiyaku = Kiyaku.find_by_id(params[:id]) + else + @kiyaku = Kiyaku.new + end + end + + def kiyaku_create + @kiyaku = Kiyaku.new params[:kiyaku] + Kiyaku.transaction do + unless @kiyaku.valid? + kiyaku_list + flash.now[:error] = "保存に失敗しました" + render :action => :kiyaku_index + return + end + + if @kiyaku && @kiyaku.save + flash.now[:notice] = "データを保存しました" + else + flash.now[:error] = "保存に失敗しました" + end + redirect_to :action => "kiyaku_index" + end + end + + def kiyaku_update + @kiyaku = Kiyaku.find(params[:kiyaku][:id]) + @kiyaku.attributes = params[:kiyaku] + unless @kiyaku.valid? + kiyaku_list + flash.now[:error] = "保存に失敗しました" + render :action => "kiyaku_index" + return + end + + Kiyaku.transaction do + if @kiyaku && @kiyaku.save + flash.now[:notice] = "データを保存しました" + else + flash.now[:error] = "保存に失敗しました" + end + end + redirect_to :action => "kiyaku_index" + end + + def privacy + privacy = Privacy.first + @privacy = privacy && privacy.content + end + + def privacy_update + if request.method != :post + redirect_to :action=>:privacy + return + end + if (privacy = Privacy.first) + privacy.update_attribute(:content, params[:content]) + else + privacy = Privacy.create(:content=>params[:content]) + end + flash.now[:notice] = "データを保存しました" + redirect_to :action=>:privacy + end + + def up + super + redirect_to :action => params[:return_act] + end + + def down + super + redirect_to :action => params[:return_act] + end + + def destroy + get_model + if @model.find(:first, :conditions => ["id = ? ", params[:id]] ) && @model.destroy(params[:id]) + flash.now[:notice] = "削除しました" + else + flash.now[:error] = "削除に失敗しました" + end + + redirect_to :action => params[:return_act] + end + + private + + def set_payment_resource_old + if resource_id = params["payment_resource_old_id".intern] + if resource_id.to_s == 0.to_s + @payment["resource_id".intern] = nil + elsif !resource_id.blank? && params[:payment]["resource"] + return + else + @payment["resource_id".intern] = resource_id unless @product["resource_id".intern] + end + end + end + + def kiyaku_list + @model_name = "kiyaku" + @model = Kiyaku + if params[:id] + @status ="kiyaku_update" + else + @status="kiyaku_create" + end + + @kiyakus = Kiyaku.find(:all, :order=>"position") + end + +end diff --git a/app/controllers/admin/status_controller.rb b/app/controllers/admin/status_controller.rb new file mode 100644 index 0000000..43c4b5a --- /dev/null +++ b/app/controllers/admin/status_controller.rb @@ -0,0 +1,2 @@ +class Admin::StatusController < Admin::BaseController +end diff --git a/app/controllers/admin/style_categories_controller.rb b/app/controllers/admin/style_categories_controller.rb new file mode 100644 index 0000000..bc989e3 --- /dev/null +++ b/app/controllers/admin/style_categories_controller.rb @@ -0,0 +1,38 @@ +class Admin::StyleCategoriesController < Admin::BaseController + resource_controller + + index.before do + @style_categories = StyleCategory.find(:all, + :conditions => ["style_id = ?", params[:style_id]], + :order => "position") + @style_category = StyleCategory.find_by_id(params[:id]) || StyleCategory.new({:style_id=>params[:style_id]}) + end + + new_action.wants.html do + redirect_to :action => "index", :style_id => params[:style_id] + end + + [create, update, destroy].each do |action| + action.wants.html do + redirect_to :action => "index", :style_id => params[:style_id] + end + + action.failure.wants.html do + @style_categories = StyleCategory.find(:all, + :conditions => ["style_id = ?", params[:style_id]], + :order => "position") + render :action => "index" + end + end + + def up + super + redirect_to :action => :index, :style_id => params[:style_id] + end + + def down + super + redirect_to :action => :index, :style_id => params[:style_id] + end + +end diff --git a/app/controllers/admin/styles_controller.rb b/app/controllers/admin/styles_controller.rb new file mode 100644 index 0000000..167b775 --- /dev/null +++ b/app/controllers/admin/styles_controller.rb @@ -0,0 +1,35 @@ +class Admin::StylesController < Admin::BaseController + resource_controller + before_filter :admin_permission_check_standard + + index.before do + @styles = Style.find(:all, :order => "position") + @style = Style.find_by_id(params[:id]) || Style.new + end + + new_action.wants.html do + redirect_to :action => "index" + end + + [create, update, destroy].each do |action| + action.wants.html do + redirect_to :action => "index" + end + + action.failure.wants.html do + @styles = Style.find(:all, :order => "position") + render :action => "index" + end + end + + def up + super + redirect_to :action => :index + end + + def down + super + redirect_to :action => :index + end + +end diff --git a/app/controllers/admin/totals_controller.rb b/app/controllers/admin/totals_controller.rb new file mode 100644 index 0000000..0d1fe60 --- /dev/null +++ b/app/controllers/admin/totals_controller.rb @@ -0,0 +1,57 @@ +require 'ostruct' +require 'totalizer' + +class Admin::TotalsController < Admin::BaseController + before_filter :admin_permission_check_term + + def index + + params[:search] ||= {} + [:month, :date_from, :date_to, :sale_start_from, :sale_start_to].each do | key | + params[:search][key] = parse_date_select(params[:search], key) + end + @search = OpenStruct.new(params[:search]) + params[:page] ||= 'term' + @agent = Totalizer.get_instance(params[:page]) + if not @agent + params[:page] = 'term' + @agent = Totalizer.get_instance(params[:page]) + end + @sale_start_enabled = (params[:page] == 'product') + params[:type] ||= @agent.default_type + @title = @agent.title + @list_view = @agent.columns + @links = @agent.links + @labels = @agent.labels + begin + @records = @agent.get_records(params) + rescue => e + p e + end + @total = @agent.total + begin + flash[:graph] = @agent.graph + rescue =>e + logger.error(e.message) + e.backtrace.each{|bt|logger.error(bt)} + end + end + + def graph + if flash[:graph] + send_data flash[:graph], :type => 'image/png', :disposition => 'inline' + else + head :status => :not_found + end + end + + def csv + totalizer = Object.const_get("#{params[:page]}_totalizer".classify) + csv_data, filename = totalizer.csv(params) + headers['Content-Type'] = "application/octet-stream; name=#{filename}" + headers['Content-Disposition'] = "attachment; filename=#{filename}" + render :text => Iconv.conv('cp932', 'UTF-8', csv_data) + end + +end + diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 0000000..4378c3b --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,34 @@ +# Filters added to this controller apply to all controllers in the application. +# Likewise, all the methods added will be available for all controllers. + +class ApplicationController < ActionController::Base + helper :all # include all helpers, all the time + + # not leave password and card number for the log + filter_parameter_logging 'password', 'number' + + # See ActionController::RequestForgeryProtection for details + # Uncomment the :secret if you're not using the cookie session store + # protect_from_forgery # :secret => 'a24b54af4d852bf12a39dde03d4a0189' + + # See ActionController::Base for details + # Uncomment this to filter the contents of submitted sensitive data parameters + # from your application log (in this case, all fields with names like "password"). + # filter_parameter_logging :password + include ActiveRecordHelper + + + def load_system + @system = System.find(:first) + end + + #郵便番号から住所を取得 + def get_address + address = Zip.find(:first, :select => "prefecture_name, address_city, address_details, prefecture_id", + :conditions => ["zipcode01=? and zipcode02=?", params[:first], params[:second]]) + data = address[:prefecture_name] + '/' + address[:address_city] + '/' + address[:address_details] + '/' + address[:prefecture_id].to_s + render :text => data + end + +end + diff --git a/app/controllers/base_controller.rb b/app/controllers/base_controller.rb new file mode 100644 index 0000000..55b50b4 --- /dev/null +++ b/app/controllers/base_controller.rb @@ -0,0 +1,182 @@ +# -*- coding: utf-8 -*- +class BaseController < ApplicationController + before_filter :start_transaction + before_filter :verify_session_token + before_filter :load_data + before_filter :set_headers + before_filter :device_check + after_filter :end_transaction + layout 'base' + mobile_filter + trans_sid + + #バリデーションエラーの時、レイアウトが崩れる対応 + ActionView::Base.field_error_proc = Proc.new{ |snippet, + instance| "#{snippet}" + } + + def cart_total_prices carts + carts.map(&:subtotal).sum + end + + #エラーページ指定 + def rescue_action_in_public(exception) + case exception + when ActiveRecord::RecordNotFound, ::ActionController::UnknownAction, ::ActionController::RoutingError, ActionView::TemplateError, NoMethodError + if request.mobile? + render(:file => "public/404_mobile.html", :status => "404 NOT FOUND") + else + render(:file => "public/404.html", :status => "404 NOT FOUND") + end + else + if request.mobile? + render(:file => "public/500_mobile.html", :status => "500 ERROR") + else + render(:file => "public/500.html", :status => "500 ERROR") + end + end + end + + private + + def load_data + load_system + load_user + load_cart + load_category + end + +=begin rdoc + 1. ユーザ情報(ログインしている場合) + 2. session + 3. new carts + の順でカートを取得します。 +=end + def load_cart + #@carts = @login_customer.carts if @login_customer + #@carts ||= session[:carts] + if @carts.nil? && session[:carts] + @carts = session[:carts].map do | hash | + if @login_customer + @login_customer.carts.build(hash) + else + Cart.new(hash) + end + end + end + @carts ||= [] + + @cart_price = cart_total_prices(@carts) + end + + def save_carts(carts=nil) + carts ||= @carts + carts or return + session[:carts] = carts.map(&:attributes) + end + + def load_category + end + + def load_user + if session[:customer_id] + @login_customer = Customer.find_by_id(session[:customer_id]) + elsif cookies[:auto_login] + @login_customer = Customer.find_by_cookie(cookies[:auto_login]) + cookies.delete(:auto_login) unless @login_customer + elsif request.mobile? && (request.mobile.ident_subscriber || request.mobile.ident_device) + mo = request.mobile + conds = [] + conds << ['activate = ?', Customer::TOUROKU] + conds << ['mobile_serial = ?', mo.ident_subscriber] if mo.ident_subscriber + customer = Customer.find(:first, :conditions => flatten_conditions(conds)) + end + end + + def login_check + unless session[:customer_id] + session[:return_to] = params if params + redirect_to(:controller => 'accounts', :action => 'login') + end + end + + def set_login_customer(customer) + if customer.nil? + return set_login_customer_id(nil) + end + customer.instance_of?(Customer) or return + set_login_customer_id(customer.id) + end + + def set_login_customer_id(id) + cookies.delete(:auto_login) if id.nil? + + saved = {} + keys = [:return_to, :carts] + keys.each{|k| saved[k] = session[k]} + + reset_session + session[:customer_id] = id + keys.each{|k| session[k] = saved[k]} + end + + def set_headers + if request.mobile? and request.mobile.is_a?(Jpmobile::Mobile::Docomo) + headers["Content-Type"] = "application/xhtml+xml" + end + end + + def device_check + request.mobile? or return true + conditions = ['? like user_agent', request.user_agent] + @mobile_device = MobileDevice.find(:first, :conditions => conditions) + if @mobile_device.blank? + logger.info "device_check error #{request.user_agent}" + redirect_to :controller => 'portal', :action => 'unsupported_device' + return false + end + end + + alias_method :non_application_rescue_action, :rescue_action + def rescue_action(exception) + ActiveRecord::Base.connection.rollback_db_transaction + case exception + when ActiveRecord::RecordNotFound + if request.mobile? + render :text => IO.read(File.join(RAILS_ROOT, 'public', '404_mobile.html')), :status => 404, :layout => false + else + render :text => IO.read(File.join(RAILS_ROOT, 'public', '404.html')), :status => 404, :layout => false + end + else + non_application_rescue_action(exception) + end + end + + def start_transaction + ActiveRecord::Base.connection.begin_db_transaction + end + + def end_transaction + ActiveRecord::Base.connection.commit_db_transaction + end + + alias_method :old_render_optional_error_file, :render_optional_error_file + + def render_optional_error_file(status_code) + if is_lisagas? + old_render_optional_error_file(status_code) + else + status = interpret_status(status_code) + path = "#{Rails.public_path}/#{status[0,3]}_mobile.html" + if File.exist?(path) + render :file => path, :status => status + else + old_render_optional_error_file(status_code) + end + end + end + + def reset_session + session[:customer_id] = nil + end +end diff --git a/app/controllers/campaigns_controller.rb b/app/controllers/campaigns_controller.rb new file mode 100644 index 0000000..dd76aa8 --- /dev/null +++ b/app/controllers/campaigns_controller.rb @@ -0,0 +1,85 @@ +class CampaignsController < BaseController + before_filter :login_check, :only => [:complete, :show] + def show + btype = params[:btype] + if btype.blank? + if request.mobile? + btype = "mobile" + else + btype = "pc" + end + end + day = Time.now + @campaign = Campaign.find(:first, + :conditions => ["dir_name=? and opened_at < ? ", params[:dir_name], day]) + + if !@campaign + flash.now[:error] = "該当するキャンペーンがありません" + return + else + @campaign_name = @campaign.name + unless @campaign.product_id.blank? + @product = @campaign.product + end + status_interface = design_status(@campaign, day, btype) + @free_spaces = Hash::new + @free_space_names = [] + if btype == "mobile" + 3.times do |index| + free_space_name = status_interface + "_free_space_" + (index+1).to_s + @free_space_names << free_space_name + @free_spaces[free_space_name] = @campaign.attributes[free_space_name] + end + else + 4.times do |index| + free_space_name = status_interface + "_free_space_" + (index+1).to_s + @free_space_names << free_space_name + @free_spaces[free_space_name] = @campaign.attributes[free_space_name] + end + end + end + end + + #応募人数の更新とcampaign_entryにレコードを追加 + def complete + @id = params[:id] + @campaign = Campaign.find(@id) + @campaign.application_count = 0 if @campaign.application_count.blank? + + if @campaign.duplicated?(@login_customer) + flash.now[:error] = "すでに応募されています" + return + end + + if @campaign.check_max_application_number + @campaign.application_count += 1 + + if @campaign.customers << @login_customer && @campaign.save + flash.now[:notice] = "ご応募ありがとうございます" + else + flash.now[:error] = "応募に失敗しました" + end + else + flash.now[:error] = "応募人数枠を越えてしまったため、応募できません" + end + end + + private + + #どのデザインを表示させるかを判定 + def design_status(campaign, day, btype) + if request.mobile? || btype == "mobile" + interface = "_mobile" + else + interface = "_pc" + end + + if campaign.available?(day) + @status = "open" #”応募するボタンを出すためのフラグ + return "open" + interface + else + @status = "end" + return "end" + interface + end + end +end diff --git a/app/controllers/cart_controller.rb b/app/controllers/cart_controller.rb new file mode 100644 index 0000000..5040f21 --- /dev/null +++ b/app/controllers/cart_controller.rb @@ -0,0 +1,649 @@ +require 'timeout' +require 'open-uri' +class CartController < BaseController + before_filter :cart_check, :only => [:temporary_shipping,:shipping, :purchase,:purchase2, :confirm, :complete] + before_filter :login_divaricate ,:only =>[:purchase,:purchase2,:confirm, :complete] + before_filter :login_check, :only => [:shipping] + before_filter :force_post, :only => [:purchase,:purchase2,:confirm, :complete] + after_filter :save_carts + before_filter :verify_session_token, :except => :select_delivery_time + + CARTS_MAX_SIZE = 20 + DENA_AFFILIATE_URL = 'http://smaf.jp/req.cgi' + + # カートの中を見る。Loginの可否、カート内容の有無で動的に変動。カート操作全般はここから行う。 + def show + unless @carts.all?(&:valid?) + flash.now[:error] = cart_errors(@carts) + end + @cart_point = total_points + if @carts.last + @recommend_for_you = Recommend.recommend_get(@carts.last.product_id, Recommend::TYPE_VIEW) + end + end + +=begin rdoc + * INFO + + parametors: + :value => Fixnum[デフォルト値: 1] + :product_id => Fixnum[必須] + :classcategory_id1 => Fixnum[必須ではない] + :classcategory_id2 => Fixnum[必要ではない] + + return: + カート内の商品の個数を [value]分加算する + 規格分類1または規格分類2が指定された場合は、指定された規格分類の個数を加算する + 規格分類1と規格分類2が指定された場合は、両方の規格分類を持つ商品の個数を加算する + 規格分類が指定されない場合は、商品の個数を加算する + 加算できない場合は、加算しない +=end + def inc + # TODO キーはインデックスにしたい: そのほうがユーザ視点で自然なので。 + value = params[:value] || 1 + cart = find_cart(:product_style_id => params[:id].to_i) + if cart.nil? || cart.product_style.nil? + redirect_to :action => :show + return + end + new_quantity = cart.quantity + value + cart.quantity = cart.product_style.available?(new_quantity) + if cart.quantity < new_quantity + flash.now[:notice] = '購入できる上限を超えています' + end + redirect_to :action => 'show' + end + +=begin rdoc + * INFO + + parametors: + :value => Fixnum[デフォルト値: 1] + :product_id => Fixnum[必須] + + return: + カート内の商品の個数を [value]分減算する + 減算した結果、商品の個数が 0 以下となる場合は 1 個にする +=end + def dec + value = params[:value] || 1 + cart = find_cart(:product_style_id => params[:id].to_i) + if cart.nil? || cart.product_style.nil? + redirect_to :action => :show + return + end + new_quantity = cart.quantity - value + if new_quantity <= 1 then + new_quantity = 1 + end + cart.quantity = new_quantity + redirect_to :action => 'show' + end + +=begin rdoc + * INFO + + parametors: + :product_style_id => Fixnum[必須] + + return: + カートを削除する +=end + def delete + # セッションから消す + cart = find_cart(:product_style_id => params[:id].to_i) + if cart.nil? + redirect_to :action => :show + return + end + @carts.reject!{|i|i==cart} + # 保存されていれば DB から消す + cart.destroy unless cart.new_record? + redirect_to :action => 'show' + end + + #会員購入のお届け先指定画面 + def shipping + unless @carts.all?(&:valid?) + redirect_to :action => :show + return + end + cookies[:back_from_deliv] = { + :value => url_for({:controller => 'cart', :action => 'shipping'}), + :expires => 30.minutes.from_now + } + if @login_customer + @address_size = DeliveryAddress.count(:conditions => ["customer_id =?", @login_customer.id]) + @addresses = DeliveryAddress.find(:all, :conditions => ["customer_id =?", @login_customer.id], :include => :customer) + basic_address = @login_customer.basic_address + @addresses.unshift(basic_address) if basic_address + end + end + + #非会員購入 + def temporary_shipping + unless @carts.all?(&:valid?) + redirect_to :action => :show + return + end + @temporary_customer = Customer.new(params[:temporary_customer]) + @optional_address = DeliveryAddress.new(params[:optional_address]) + #戻るボタンから戻る時 + if params[:back] == "1" + convert(params[:order_delivery]) + end + end + + # Order を作る + def purchase + cookies.delete :back_from_deliv if cookies[:back_from_deliv] + + #2.配送先の情報を取ってくる + if @login_customer + # 会員の場合 + if params[:address_select].to_i.zero? + # 会員登録住所を使う + @delivery_address = @login_customer.basic_address + else + # 選ばれた配送先を使う + @delivery_address = DeliveryAddress.find_by_id_and_customer_id(params[:address_select], @login_customer.id) + end + elsif @not_login_customer + # 非会員 + @temporary_customer = Customer.new(params[:temporary_customer]) + @temporary_customer.from_cart = true + + # お届け先 + #if params[:address_enable].nil? + @optional_address = DeliveryAddress.new(params[:optional_address]) + #end + + # 確認画面から戻る時 + if params[:back] == "1" + convert(params[:order_delivery]) + end + # 入力チェック + # メールアドレス重複チェックを除き + @temporary_customer.activate = Customer::HIKAIIN + if !@temporary_customer.valid? or + (params[:address_enable].nil? and !@optional_address.valid?) + @error_back = true + render :action => "temporary_shipping" + return + end + + # お届け先設定 + if params[:address_enable].nil? + @delivery_address = @optional_address + else + @delivery_address = @temporary_customer.basic_address + end + end + + # 住所を取得できないと、この先困るので、どこかに飛ばす + return redirect_to(:action => 'show') unless @delivery_address + + # 確認ページから帰ってきた時は params[:order_delivery] があるはず + @order_delivery = OrderDelivery.new(params[:order_delivery]) + #確認ページから帰ってきた時、ポイント使用有無ラジオボタン維持 + if @login_customer && params[:back] == "1" + if !@order_delivery.use_point.blank? && @order_delivery.use_point > 0 + @point_check = true + else + @point_check = false + @order_delivery.use_point = nil + end + end + # 「戻る」以外の時代入 + @order_delivery.address_select ||= params[:address_select].to_i + if @order_delivery.deliv_zipcode01.blank? + @order_delivery.set_delivery_address(@delivery_address) + end + + if params[:order_delivery] + @order_delivery.target_columns = params[:order_delivery].keys.map(&:to_s) + end + #@payments = @order_delivery.payment_candidates(@cart_price) + #配送時間取得・表示のAJAXははお支払方法押下時のみ行い、戻るボタンで戻る時、配送時間表示がおかしくないため、 + #支払方法を強制にクリア。モバイルはAJAXを使っていないので、そのまま + @order_delivery.payment = nil unless request.mobile? + + # 非会員フラグ追加 + # 非会員購入時の顧客情報セット + if @not_login_customer + @order_delivery.set_customer(@temporary_customer) + end + render :action => 'purchase' + end + + #モバイルお届け時間選択 + def purchase2 + @order_delivery = OrderDelivery.new(params[:order_delivery]) + unless @order_delivery.valid? + if params[:point_check] == "true" + @point_check = true + end + render :action => 'purchase' + return + end + # ポイントチェック + if @login_customer + if params[:point_check] == "true" + @point_check = true + use_point = @order_delivery.use_point.to_i + if use_point == 0 + flash.now[:error] = '使用ポイントをご入力ください。 ' + render :action => 'purchase' + return + end + # ポイントの使いすぎをチェック + if use_point > @cart_price + flash.now[:error] = 'ご利用ポイントがご購入金額を超えています。' + render :action => 'purchase' + return + end + if use_point > @login_customer.point.to_i + flash.now[:error] = 'ご利用ポイントが所持ポイントを超えています。' + render :action => 'purchase' + return + end + else + @point_check = false + @order_delivery.attributes = {:use_point => 0} + end + end + #選択したお支払方法によりお届け時間取得 + select_delivery_time + @order_delivery.target_columns = params[:order_delivery].keys.map(&:to_s) + end + + # AJAXお届け時間取得 + def select_delivery_time + h = params[:order_delivery] || params + payment_id = h[:payment_id] + @selected = h[:delivery_time_id] + delivery_times = DeliveryTime.find( + :all, :conditions => ["payments.id=? and delivery_times.name <> ''", payment_id], + :include => [:delivery_trader=>:payments], :order => 'delivery_times.position') + @options = [['指定なし', nil]] + @options.concat(delivery_times.map do |dt| + [dt.name, dt.id] + end) + render :layout => false unless request.mobile? + end + + #確認画面へ + def confirm + init_order_delivery + unless @order_delivery.valid? + @order_delivery.payment = nil unless request.mobile? + if params[:point_check] == "true" + @point_check = true + end + render :action => 'purchase' + return + end + + # ポイント + if @login_customer + use_point = 0 + if params[:point_check] == "true" + @point_check = true + use_point = @order_delivery.use_point.to_i + if use_point == 0 + flash.now[:error] = '使用ポイントをご入力ください。 ' + @order_delivery.payment = nil unless request.mobile? + render :action => 'purchase' + return + end + # ポイントの使いすぎをチェック + if use_point > @cart_price + flash.now[:error] = 'ご利用ポイントがご購入金額を超えています。' + @order_delivery.payment = nil unless request.mobile? + render :action => 'purchase' + return + end + if use_point > @login_customer.point.to_i + flash.now[:error] = 'ご利用ポイントが所持ポイントを超えています。' + @order_delivery.payment = nil unless request.mobile? + render :action => 'purchase' + return + end + else + @point_check = false + @order_delivery.attributes = {:use_point => 0} + end + + @cart_point = total_points + @point_after_operation = @login_customer.point.to_i - use_point + total_points + #add_point追加 + @order_delivery.attributes = {:add_point => @cart_point} + end + #ポイントのことで再計算はここにする + @order_delivery.calculate_charge! + @order_delivery.calculate_total! + + @next = :complete + render :action => 'confirm' + end + + #完了画面 + def complete + unless @carts.all?(&:valid?) + redirect_to :action => :show + return + end + # 受注を作って受注可能数を減らす + #  非会員購入追加 + if @not_login_customer + @order = Order.new + elsif @login_customer + @login_customer.point = params[:point_after_operation] + @order = @login_customer.orders.build + end + + @order.received_at = DateTime.now + @order_delivery = @order.order_deliveries.build(params[:order_delivery]) + + #  非会員購入追加 + if @login_customer + @order_delivery.set_customer(@login_customer) + end + + ## ステータス + @order_delivery.status = OrderDelivery::JUTYUU + # 受注発注商品が一つでもあるか + product_styles = @carts.map(&:product_style) + if product_styles.any?{|ps| ps.actual_count == 0} + # 販売開始日が未来の物が一つでもあれば予約 + products = product_styles.map(&:product) + today = Date.today + if products.any?{|p| p.sale_start_at && p.sale_start_at > today} + @order_delivery.status = OrderDelivery::YOYAKU_UKETSUKE + else + @order_delivery.status = OrderDelivery::JUTYUU_TOIAWASE + end + end + @carts.each do |cart| + cart.product_style.order(cart.quantity) + end + @order_details = @order_delivery.details_build_from_carts(@carts) + @order_delivery.calculate_charge! + @order_delivery.calculate_total! + + unless @order_delivery.valid? and @order_details.all?(&:valid?) + render :action => 'purchase' + return + end + begin + Order.transaction do + @carts.each do | cart | + if request.mobile? + ProductAccessLog.create(:product_id => cart.product_style.product_id, + :session_id => session.session_id, + :customer_id => @login_customer && @login_customer.id, + :docomo_flg => request.mobile == Jpmobile::Mobile::Docomo, + :ident => request.mobile.ident, + :complete_flg => true) + end + product_style = ProductStyle.find(cart.product_style_id, :lock=>true) + product_style.order(cart.quantity) + product_style.save! + #会員のみキャンペーン処理 + if @login_customer + cart.campaign_id and process_campaign(cart, @login_customer) + end + end + # 非会員購入対応 + if @login_customer + @login_customer.carts.delete_all + @login_customer.save! + end + @order.save! + flash[:completed] = true + flash[:order_id] = @order.id + # メールを送る + Notifier::deliver_buying_complete(@order) + @carts.clear + end + rescue => e + flash.now[:error] = '失敗しました' + logger.error(e.message) + e.backtrace.each{|s|logger.error(s)} + redirect_to :action => 'show' + return + end + redirect_to :action => :finish, :ids => @order_details.map{|o_d| o_d.product_style.product_id} + end + + def finish + unless flash[:completed] + render :template => 'cart/405', :status => :method_not_allowed + return + end + @recommend_buys = Recommend.recommend_get(params[:ids][0], Recommend::TYPE_BUY) + render :action => 'complete' + end + +=begin rdoc + * INFO + + parametors: + :product_style_id => Fixnum[必須ではない] + :product_id => Fixnum[必須] + :style_category_id1 => Fixnum[必須ではない] + :style_id2 => Fixnum[必須ではない] + :size => Fixnum[必須] + + return: + セッションに保持しているカートに、商品を追加する + セッションにカートを保持していない場合は、カートそのものを新たに所持する + 既にカートに同じ商品がある場合は、カート内の商品の個数を [size] 分だけ加算する + [size] が購入可能な上限数を超過する場合、購入可能な上限数までカートへ入れ、 + 購入制限により購入できない、とする旨のメッセージを返す。 + 購入できない商品の場合は、カートに入れない +=end + def add_product + @add_product = CartAddProductForm.new(params) + unless @add_product.valid? + flash[:cart_add_product] = @add_product.errors.full_messages + if @add_product.product_id + flash['error_%d' % @add_product.product_id] = flash[:cart_add_product] + end + request.env['HTTP_REFERER'] ||= url_for(:action=>:show) + redirect_to :back + return + end + @carts ||= [] + product_style = + if params[:product_style_id] + ProductStyle.find_by_id(params[:product_style_id]) + else + ProductStyle.find_by_product_id_and_style_category_id1_and_style_category_id2(params[:product_id], params[:style_category_id1], params[:style_category_id2]) + end + + if product_style.nil? + flash[:cart_add_product] = "ご指定の商品は購入できません。" + request.env['HTTP_REFERER'] ||= url_for(:action=>:show) + redirect_to :back + return + end + + cart = find_cart(:product_style_id => product_style.id) + if cart.nil? + if @carts.size >= CARTS_MAX_SIZE + flash[:cart_add_product] = '一度に購入できる商品は ' + "#{CARTS_MAX_SIZE}" + '種類までです。' + redirect_to :action => 'show' + return + end + cart = Cart.new(:product_style => product_style, + :customer => @login_customer, + :quantity => 0) + @carts << cart + end + # キャンペ + unless params[:campaign_id].blank? + cart.campaign_id = params[:campaign_id] + end + + size = [params[:size].to_i, 1].max + # 購入可能であれば、カートに商品を追加する + insert_size = product_style.available?(cart.quantity + size) + incremental = insert_size - cart.quantity # 増分 + product_name = product_style.full_name + if insert_size.to_i <= 0 + # 購入可能な件数が 0 より小さい場合はカートを追加しない + @carts.delete(cart) + flash[:cart_add_product] = "「#{product_name}」は購入できません。" + elsif incremental < size + # 指定数の在庫が無かった + flash[:cart_add_product] = "「#{product_name}」は販売制限しております。一度にこれ以上の購入はできません。" + end + cart.quantity = insert_size + session[:cart_last_product_id] = product_style.product_id + redirect_to :action => 'show' + end + + private + +=begin rdoc + * INFO + + return: + 現在、カート内にある商品で購入時に加算されるポイントの合計値を返す。 + カートが空の場合はnilを返す。 +=end + def total_points + @carts.inject(0) do | result, cart | + cart.product or next + point_rate_product = cart.product.point_granted_rate + point_rate_shop = Shop.find(:first).point_granted_rate + point_granted_rate = 0 + unless point_rate_product.blank? + point_granted_rate = point_rate_product + else + unless point_rate_shop.blank? + point_granted_rate = point_rate_shop + end + end + result + cart.price * point_granted_rate / 100 * cart.quantity + end + end + + # 購入時にログイン有無を確認してrenderするフィルタ + def login_divaricate + if @login_customer.nil? + if params[:temporary_customer_flag] && params[:temporary_customer_flag] == "1" + @not_login_customer = true + end + end + unless @not_login_customer + unless session[:customer_id] + session[:return_to] = params if params + redirect_to(:controller => 'accounts', :action => 'login') + end + end + end + + # @carts から条件に合うものを探す + # ex) find_cart(:product_style_id => 1) + def find_cart(conditions) + @carts.detect do | cart | + conditions.all? do | key, value | + cart[key] == value + end + end + end + + # POST 以外のアクセス禁止 + def force_post + if request.method != :post + render :template => 'cart/405', :status => :method_not_allowed + end + end + + # カートが空の時はアクセス不可 + def cart_check + if @carts.blank? + flash.now[:notice] = 'カートが空です' + redirect_to(:action => 'show') + end + end + + def cart_errors(carts) + errors = carts.enum_for(:each_with_index).reject do |c,_| + c.valid? + end.map do |c,i| + c.errors.full_messages.map do |message| + if c.product_style + name = c.product_style.full_name + else + name = '%d 番目の商品' % (i+1) + end + '%s: %s' % [name, message] + end + end.flatten.uniq.join("\n") + end + + def init_order_delivery + @order_delivery = OrderDelivery.new(params[:order_delivery]) + @order_delivery.set_customer(@login_customer) if @login_customer + @order_details = @order_delivery.details_build_from_carts(@carts) + end + + def process_campaign(cart, customer) + cp = Campaign.find_by_id(cart.campaign_id) + return if cp.product_id != cart.product_style.product_id + return if cp.duplicated?(customer) + cp.customers << customer + cp.application_count ||= 0 + cp.application_count += 1 + cp.save! + end + + # purchase だけで必要だが、他のアクションから render されることもあるのでいっそ全部で読み込む + def find_payments + @card_price or return false + true + end + + #戻るボタンから非会員入力画面へ戻る時 + def convert(params) + order_delivery = OrderDelivery.new(params) + #顧客情報 + @temporary_customer.family_name = order_delivery.family_name + @temporary_customer.first_name = order_delivery.first_name + @temporary_customer.family_name_kana = order_delivery.family_name_kana + @temporary_customer.first_name_kana = order_delivery.first_name_kana + @temporary_customer.tel01 = order_delivery.tel01 + @temporary_customer.tel02 = order_delivery.tel02 + @temporary_customer.tel03 = order_delivery.tel03 + @temporary_customer.fax01 = order_delivery.fax01 + @temporary_customer.fax02 = order_delivery.fax02 + @temporary_customer.fax03 = order_delivery.fax03 + @temporary_customer.zipcode01 = order_delivery.zipcode01 + @temporary_customer.zipcode02 = order_delivery.zipcode02 + @temporary_customer.prefecture_id = order_delivery.prefecture_id + @temporary_customer.address_city = order_delivery.address_city + @temporary_customer.address_detail = order_delivery.address_detail + @temporary_customer.email = order_delivery.email + @temporary_customer.email_confirm = order_delivery.email + @temporary_customer.sex = order_delivery.sex + @temporary_customer.birthday = order_delivery.birthday + @temporary_customer.occupation_id = order_delivery.occupation_id + + #お届け先情報 + @optional_address.family_name = order_delivery.deliv_family_name + @optional_address.first_name = order_delivery.deliv_first_name + @optional_address.family_name_kana = order_delivery.deliv_family_name_kana + @optional_address.first_name_kana = order_delivery.deliv_first_name_kana + @optional_address.tel01 = order_delivery.deliv_tel01 + @optional_address.tel02 = order_delivery.deliv_tel02 + @optional_address.tel03 = order_delivery.deliv_tel03 + @optional_address.zipcode01 = order_delivery.deliv_zipcode01 + @optional_address.zipcode02 = order_delivery.deliv_zipcode02 + @optional_address.prefecture_id = order_delivery.deliv_pref_id + @optional_address.address_city = order_delivery.deliv_address_city + @optional_address.address_detail = order_delivery.deliv_address_detail + end +end diff --git a/app/controllers/features_controller.rb b/app/controllers/features_controller.rb new file mode 100644 index 0000000..e8dac7a --- /dev/null +++ b/app/controllers/features_controller.rb @@ -0,0 +1,25 @@ +class FeaturesController < BaseController + def show + #公開特集を取得 + @feature = Feature.find(:first, + :conditions => ["dir_name=? and permit = '1'", params[:dir_name]]) + + if @feature.blank? +# flash.now[:error] = "該当する特集がありません" + if request.mobile? + render :file => 'public/404_mobile.html' + else + render :file => 'public/404.html' + end + return + else + #特集が持っている商品一覧を取得 + if @feature.feature_type == Feature::PRODUCT + @products = FeatureProduct.paginate(:page => params[:page], + :per_page => 12, + :conditions => ["feature_id = ?", @feature.id], + :order => :position) + end + end + end +end diff --git a/app/controllers/image_resource_controller.rb b/app/controllers/image_resource_controller.rb new file mode 100644 index 0000000..4436169 --- /dev/null +++ b/app/controllers/image_resource_controller.rb @@ -0,0 +1,66 @@ +class ImageResourceController < BaseController + before_filter :set_mobile_spec + + #caches_page :show + def show + if params[:filename] + @res = ImageResource.find_by_name(params[:filename]) + end + if params[:id] + @res ||= ImageResource.find_by_id(params[:id]) + end + raise ActiveRecord::RecordNotFound unless @res + if @mobile_spec && @mobile_spec =~ /^(\d+)x(\d+)$/ + if params[:width].present? || params[:height].present? + width, height = [params[:width].to_i, params[:height].to_i] + else + width, height = [$1.to_i, $2.to_i] + end + send_file @res, @res.scaled_image(width, height) + else + send_file @res, @res.view + end + end + + def thumbnail + end + + private + + def send_file(res, data) + raise ActiveRecord::RecordNotFound unless res + raise ActiveRecord::RecordNotFound unless data + content_type = res.content_type + if request.mobile? + content_type.gsub!(/pjpeg/, "jpeg") + end + send_data(data, :type => content_type, :disposition => 'inline') + end + + MOBILE_SPEC = Hash[*File.read("#{RAILS_ROOT}/db/migrate/fixed_data/mobile_specs.txt").split(/\n/).compact.map{|a|a.split(/\t/)[0...2]}.flatten] + + def set_mobile_spec + begin + if request.mobile? + ua = request.user_agent || '' + @mobile_spec = case request.mobile + when Jpmobile::Mobile::Docomo + MOBILE_SPEC["i/#{$1}"] if ua =~ %r{^DoCoMo/(?:1.0/|2.0 )(\w+)} + when Jpmobile::Mobile::Au + MOBILE_SPEC["a/#{$1}"] if ua =~ %r{^(?:KDDI-|UP\.Browser/.*?-)(\w+)} + when Jpmobile::Mobile::Softbank + MOBILE_SPEC["s/#{$1}"] if ua =~ %r{^((.*?)/(.*?)/[\w-]+)} + end + if @mobile_device + @mobile_spec = "#{@mobile_device.width}x#{@mobile_device.height}" + end + @mobile_spec ||= "240x320" + end + rescue NoMethodError + # テストのときは user_agent メソッドがない + if request.mobile? + @mobile_spec ||= "240x320" if is_mobile? + end + end + end +end diff --git a/app/controllers/inquiries_controller.rb b/app/controllers/inquiries_controller.rb new file mode 100644 index 0000000..efb0771 --- /dev/null +++ b/app/controllers/inquiries_controller.rb @@ -0,0 +1,73 @@ +class InquiriesController < BaseController +# before_filter :device_check, :except => :unsupported_device + before_filter :init_by_params, :only=>[:new, :confirm, :complete] + + def show + if request.mobile? + @shop = Shop.find(:first) + @p = Product.find(:first) + else + redirect_to :action => "new" + end + end + + def new + end + + def confirm + + unless @inquiry.valid? + @inquiry.email = params[:inquiry][:email] + render :action => "new" + return + end + end + + def complete + + #メール送信処理 + begin + @inquiry.save! + request.mobile? ? Notifier::deliver_received_inquiry(@inquiry,true) : Notifier::deliver_received_inquiry(@inquiry,false) + request.mobile? ? Notifier::deliver_mobile_inquiry(@inquiry) : Notifier::deliver_pc_inquiry(@inquiry) + flash.now[:notice] = "お問い合わせを送信しました" + rescue + flash.now[:notice] = "お問い合わせ送信に失敗しました" + render :action => "new" + return + end + end + + def privacy + record = Privacy.first + @privacy = record && record.content + unless request.mobile? + render :action=>:privacy_mobile, :layout=>'base_mobile' + end + end + + private + + def init_by_params + if params[:inquiry] + @inquiry = Inquiry.new params[:inquiry] + @inquiry.kind = params[:inquiry][:kind].to_i if params[:inquiry][:kind] + if request.mobile? + unless @inquiry.email_user.blank? + @inquiry.email = '%s@%s' % [@inquiry.email_user.to_s, @inquiry.email_domain.to_s] + end + end + else + @inquiry = Inquiry.new + if request.mobile? + #携帯のドメインを表記 + if request.mobile.instance_of?(Jpmobile::Mobile::Docomo) + @inquiry.email = "@docomo.ne.jp" + elsif request.mobile.instance_of?(Jpmobile::Mobile::Au) + @inquiry.email = "@ezweb.ne.jp" + end + end + @inquiry.kind = Inquiry::GOODS + end + end +end diff --git a/app/controllers/portal_controller.rb b/app/controllers/portal_controller.rb new file mode 100644 index 0000000..a27a993 --- /dev/null +++ b/app/controllers/portal_controller.rb @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- +class PortalController < BaseController + before_filter :device_check, :except => :unsupported_device + + + def show + load_new_information + load_recommend_product + load_seo + load_new_product unless request.mobile? + @recommend_xmls = Recommend.ranking_get(3) + render :layout => false if request.mobile? + end + + def show_tradelaw + @law = Law.find(:first) + end + + def unsupported_device + get_shop_info + @devices = get_supported_devices + + render :layout => false + end + + def supported_device + get_shop_info + @devices = get_supported_devices + end + + def privacy + end + + def first_one + render :file => 'public/404.html', :status => :not_found unless request.mobile? + end + + def company + end + + def escape_clause + end + + # info maintenance + def maintenance + end + + # information + def notice + end + + private + def get_shop_info + @shop = Shop.find(:first) + end + + def load_new_information(character_id=nil) + conds = [] + conds << ['date <= ? ', Time.zone.now] + @new_informations = NewInformation.find(:all, + :conditions => flatten_conditions(conds), + :order => "position") + end + + def load_recommend_product + @recommend_products = RecommendProduct.find(:all, + :conditions=>["products.id >= ? and recommend_products.description <> ? and products.deleted_at is null", 1, ""], + :include=>"product", + :order => "recommend_products.position") + end + + def load_new_product + status = Status.find_by_name("NEW") + conditions = Product.defalt_condition + conditions << ["product_statuses.status_id = ?", status.id] if status + @new_products = Product.find(:all, + :conditions => flatten_conditions( conditions ), + :joins => "left join product_statuses on product_statuses.product_id = products.id" , + :include => Product::DEFAULT_INCLUDE, + :limit => 8, + :order => "id desc") + end + + def load_seo + @seo = Seo.find(:first, :conditions=>{ :page_type => Seo::TOP}) + end + + def get_supported_devices + if request.mobile.instance_of?(Jpmobile::Mobile::Vodafone) || + request.mobile.instance_of?(Jpmobile::Mobile::Jphone) + jpmobile_class_name = 'Jpmobile::Mobile::Softbank' + else + jpmobile_class_name = (request.mobile.class).to_s + end + + MobileDevice.paginate(:all, + :page => params[:page], + :per_page => 50, + :include => :mobile_carrier, + :conditions => ["mobile_carriers.jpmobile_class=?", jpmobile_class_name], + :order => :name) + end +end diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb new file mode 100644 index 0000000..e3141b6 --- /dev/null +++ b/app/controllers/products_controller.rb @@ -0,0 +1,108 @@ +class ProductsController < BaseController + before_filter :load_product, :only => %w(show stock_table) + before_filter :load_recommend_products, :only => %w(show) + before_filter :load_recommend_ranking_products, :only => %w(show index) + + def show + load_seo_products_detail + @recommend_buys = Recommend.recommend_get(@product.id, Recommend::TYPE_BUY) || [] + @recommend_views = Recommend.recommend_get(@product.id, Recommend::TYPE_VIEW) || [] + if request.mobile? + ProductAccessLog.create(:product_id => @product.id, + :session_id => session.session_id, + :customer_id => @login_customer && @login_customer.id, + :docomo_flg => request.mobile == Jpmobile::Mobile::Docomo, + :ident => request.mobile.ident) + end + end + + def search + index + + render :action => :index + end + + def index + load_seo_products_list + conditions = Product.defalt_condition + + unless params[:search].blank? + params[:search].split(" ").each do |search_str| + conditions << [ "(products.name || products.key_word || products.introduction) like ?", "%#{search_str}%"] + end + end + + if (! params[:category_id].blank? ) && params[:category_id] =~ /^[0-9]*$/ && params[:category_id].to_i < 2147483647 + @category = Category.find(:first, :conditions => ["id = ?", params[:category_id] ] ) + if @category + ids = @category.get_child_category_ids + conditions << ["category_id IN (#{ids.join(",")})" ] + @category_name = @category.name + end + end + + order = params[:order] == "price" ? "product_price.max_price desc" : "products.updated_at desc" + per_page = request.mobile? ? 10 : 16 + @products = Product.paginate(:page => params[:page], :per_page => per_page, :conditions => flatten_conditions( conditions ), + :joins => "left join (select product_styles.product_id,max(sell_price) as max_price from product_styles group by product_id) as product_price on product_price.product_id = products.id ", + :include => Product::DEFAULT_INCLUDE, + :order => order) + end + + def show_image + unless params[:id].blank? + @product = Product.find(:first, :conditions => ["products.id = ? and permit = ? and ? >= products.sale_start_at", params[:id], true, Date.today], + :include => Product::DEFAULT_INCLUDE) + end + render :layout => false + end + + def stock_table + @product_styles = @product.product_styles + @have_style = @product_styles.any?(&:style_category1) + if @have_style + @have_style2 = @have_style && @product_styles.any?(&:style_category2) + @style_name1 = @product_styles.first.style_name1 + @style_name2 = @product_styles.first.style_name2 + end + if params[:partial] + render :layout => false + end + end + + private + def load_product + unless params[:id].blank? + @product = Product.find(:first, :conditions => ["products.id = ? and permit = ? and ? >= products.public_start_at", params[:id], true, Date.today], + :include => Product::DEFAULT_INCLUDE) + end + if @product + unless @product.in_public_term? + redirect_to :action => "index" + return + end + @product_name = @product.name + @category_name = @product.category.name if @product.category + else + raise ActiveRecord::RecordNotFound + end + true + end + + def load_recommend_products + @recommend_products = RecommendProduct.find(:all, :order => "position") + end + + def load_seo_products_list + @seo= Seo.find(:first, :conditions=>{ :page_type => Seo::PRODUCTS_LIST}) + end + + def load_seo_products_detail + @seo = Seo.find(:first, :conditions=>{ :page_type => Seo::PRODUCTS_DETAIL}) + end + + def load_recommend_ranking_products + @recommend_xmls = Recommend.ranking_get(4) + end + +end diff --git a/app/controllers/questionnaires_controller.rb b/app/controllers/questionnaires_controller.rb new file mode 100644 index 0000000..5decf48 --- /dev/null +++ b/app/controllers/questionnaires_controller.rb @@ -0,0 +1,149 @@ +#class QuestionnairesController < ApplicationController +class QuestionnairesController < BaseController + before_filter :get_questionnaire + before_filter :device_check, :except => :unsupported_device + + def complete + questionnaire_answer = QuestionnaireAnswer.new params[:respondent] + questionnaire_answer.questionnaire_name = @questionnaire.name + questionnaire_answer.customer_id = Customer.find_by_email(params[:respondent][:email]).id if Customer.find_by_email(params[:respondent][:email]) + + answers = [] + @questions.each do | question | + #checkboxのものは一つのQuestionAnswerにまとめる: ex. answer = "1 2 3" + if question.question_choices[0][:format] == QuestionChoice::CHECKBOX + check_box_answer = [] #answer部分を初期化(この時点では)params[:answers]["#{question.id}"]["#{question_choice.id}"]のanswerが入っている + question_choices = question.question_choices.find(:all, :order=>"position") #position順に回答を格納していく + question_choices.each_with_index do | question_choice, index | + check_box_answer << question_choice.content if params[:answers]["#{question.id}"]["#{question_choice.id}"][:answer] == "on" + end + answer = QuestionAnswer.new(params[:answers]["#{question.id}"]["#{question.question_choices[0].id}"]) + answer.answer = check_box_answer.join(' ') + answers << answer + else + answers << QuestionAnswer.new(params[:answers]["#{question.id}"]) + end + end + + flash.now[:notice] = "アンケートにご協力頂き、ありがとうございました" + begin + #アンケート回答の保存 + @questionnaire.questionnaire_answers<<(questionnaire_answer) + questionnaire_answer.save! + #質問回答の保存 + answers.each do | answer | + questionnaire_answer.question_answers<<(answer) + questionnaire_answer.save! + end + rescue + flash.now[:notice] = "送信に失敗しました" + end + end + + def confirm + #回答フォーム名規則 + #params[:answers][question_idx][choice_idx] => 質問番号の回答(answer)が入っている + #params[:respondent] => 回答者情報 + @respondent = QuestionnaireAnswer.new params[:respondent] + @answers = [] #paramsから渡ってきた回答を入れる + #@answer_objects = Hash.new #@questionnaire_answerに入れるためのオブジェクト(QuestionAnswer)を入れる + + @questions.each_with_index do | question, question_idx | + answer_objects = [] #質問単位の回答 + + if question.question_choices[0][:format] == QuestionChoice::CHECKBOX #回答形式がチェックボックスのときはquestion_choice分の回答を取得 + #チェックボックスの選択肢を取得 + question_choices = question.question_choices.find(:all, + :conditions=>["question_id=?", question.id], + :order=>"position") + question_choices.each_with_index do | question_choice, choice_idx | + #チェックされた選択肢を取得 + answer = params[:answers]["#{question.id}"]["#{question_choice.id}"] if params[:answers]["#{question.id}"] + answer_object = new_answer_object(question.id, question_choice.id, question.position, answer) + #validateに引っかかったらnewに戻る + answer_objects << answer_object + unless answer_object.valid? + render :action => "new", :id => @questionnaire.id + return + end + end + + else #回答形式がチェックボックス以外のときは1つの回答を取得 + answer = params[:answers]["#{question.id}"] if params[:answers]["#{question.id}"] #QuectonChoice::NOUSEでは回答が存在しない + + question_choice_id = question.question_choices[0].id + if question.question_choices[0][:format] == QuestionChoice::RADIOBUTTON #回答形式がラジオボタンのときは、選択肢名を回答に入れる + question_choice_id = question.question_choices.find(:first, + :conditions=>["content=?", answer], + :select=>"id").id if answer + end + #質問回答を1つ取得 + answer_object = new_answer_object(question.id, question_choice_id, question.position, answer) + #validateに引っかかったらnewに戻る + answer_objects << answer_object + unless answer_object.valid? + @err = true + end + end + @answers << answer_objects #質問単位の回答を格納 + end + #回答者のvalidateチェック(引っかかったらnewに戻る) + if @err || !( @respondent.valid? ) + if @err + flash.now[:notice] = "文字数が多すぎます" + end + render :action => "new", :id => @questionnaire.id + return + end + + end + + def new + if params[:id] + init_answer + flash.now[:notice] = "このアンケートの期限は終了しています" unless @questionnaire.operation + elsif !params[:id] || !@questionnaire + flash.now[:notice] = "アンケートが指定されていません" + end + end + + private + + #アンケートを取得 + def get_questionnaire + begin + @questionnaire = Questionnaire.find(params[:id]) + @questions = Question.find(:all, :conditions=>["questionnaire_id=? and content is not null and question_choice_id <> 0", params[:id]], :order=>"position") + rescue + false + end + end + + #回答の初期化 + def init_answer + get_questionnaire + @answers = [] + @questions.each do | question | + answer = [] + question_choices = question.question_choices.find(:all, :conditions => ["content is not null"], :order => "position") + if !question_choices.blank? && question_choices[0][:format] == QuestionChoice::CHECKBOX + question_choices.each do | question_choice | + answer << QuestionAnswer.new + end + else + answer << QuestionAnswer.new + end + @answers << answer + end + end + + #新しいQuestionAnswerオブジェクトを作成 + def new_answer_object(question_id, question_choice_id, question_position, answer) + answer_object = QuestionAnswer.new(:question_id=>question_id, + :question_choice_id=>question_choice_id, + :question_position=>question_position, + :answer=>answer) + return answer_object + end + +end diff --git a/app/controllers/recommend_controller.rb b/app/controllers/recommend_controller.rb new file mode 100644 index 0000000..df756a5 --- /dev/null +++ b/app/controllers/recommend_controller.rb @@ -0,0 +1,27 @@ +class RecommendController < ApplicationController + def tsv + conditions = Product.defalt_condition + @products = Product.find(:all, :conditions => flatten_conditions(conditions)) + f = StringIO.new('', 'w') + CSV::Writer.generate(f,"\t","\r\n") do | writer | + writer << [:item_code, :name, :url, :stock_flg, :comment, :category, :area, :price, :img_url] + @products.each do | product | + columns = [] + columns << product.id + columns << product.name + columns << url_for(:controller => "/products", :action => "show", :id => product.id ) + columns << (product.have_zaiko? ? 2 : 0) + columns << product.introduction.gsub(/(\r\n|[\r\n])/, " ") + columns << nil + columns << nil + columns << product.price_label + columns << url_for(:controller => "/image_resource", :action => "show", :id => product.small_resource_id) + writer << columns + end + end + filename = "tsv.tsv" + headers['Content-Type'] = "application/octet-stream; name=#{filename}" + headers['Content-Disposition'] = "attachment; filename=#{filename}" + render :text => f.string + end +end diff --git a/app/controllers/shop_controller.rb b/app/controllers/shop_controller.rb new file mode 100644 index 0000000..504f861 --- /dev/null +++ b/app/controllers/shop_controller.rb @@ -0,0 +1,9 @@ +class ShopController < BaseController + + def show + end + + def about + @shop = Shop.first + end +end diff --git a/app/helpers/accounts_helper.rb b/app/helpers/accounts_helper.rb new file mode 100644 index 0000000..17850b4 --- /dev/null +++ b/app/helpers/accounts_helper.rb @@ -0,0 +1,2 @@ +module AccountsHelper +end diff --git a/app/helpers/admin/account_helper.rb b/app/helpers/admin/account_helper.rb new file mode 100644 index 0000000..ae85d36 --- /dev/null +++ b/app/helpers/admin/account_helper.rb @@ -0,0 +1,2 @@ +module Admin::AccountHelper +end diff --git a/app/helpers/admin/admin_user_helper.rb b/app/helpers/admin/admin_user_helper.rb new file mode 100644 index 0000000..a91ae1f --- /dev/null +++ b/app/helpers/admin/admin_user_helper.rb @@ -0,0 +1,2 @@ +module Admin::AdminUserHelper +end diff --git a/app/helpers/admin/authorities_helper.rb b/app/helpers/admin/authorities_helper.rb new file mode 100644 index 0000000..c26a967 --- /dev/null +++ b/app/helpers/admin/authorities_helper.rb @@ -0,0 +1,19 @@ +module Admin::AuthoritiesHelper + def to_table(src,cols) + + rows = src.size/cols + src.size%cols + + tr_datas = [] + rows.times do |i| + td_datas = [] + cols.times do |j| + if (i*cols + j) >= src.size + break + end + td_datas << src[i*cols + j] + end + tr_datas << td_datas + end + tr_datas + end +end diff --git a/app/helpers/admin/base_helper.rb b/app/helpers/admin/base_helper.rb new file mode 100644 index 0000000..10f3312 --- /dev/null +++ b/app/helpers/admin/base_helper.rb @@ -0,0 +1,7 @@ +module Admin::BaseHelper + def date_hyphen(date) + date && date.strftime("%Y-%m-%d") + end + + +end diff --git a/app/helpers/admin/campaigns_helper.rb b/app/helpers/admin/campaigns_helper.rb new file mode 100644 index 0000000..d057d0e --- /dev/null +++ b/app/helpers/admin/campaigns_helper.rb @@ -0,0 +1,15 @@ +module Admin::CampaignsHelper + def is_open + if(@type == Admin::CampaignsController::PAGE_TYPE_PC_OPEN || @type == Admin::CampaignsController::PAGE_TYPE_MOBILE_OPEN) + return true + end + return false + end + + def is_pc + if(@type == Admin::CampaignsController::PAGE_TYPE_PC_OPEN || @type == Admin::CampaignsController::PAGE_TYPE_PC_END) + return true + end + return false + end +end diff --git a/app/helpers/admin/categories_helper.rb b/app/helpers/admin/categories_helper.rb new file mode 100644 index 0000000..62102dc --- /dev/null +++ b/app/helpers/admin/categories_helper.rb @@ -0,0 +1,33 @@ +module Admin::CategoriesHelper + def set_category_list + id = params[:category_id] || 0 + return_str = "" + Category.find(:all, :conditions => ["parent_id is null"], :order => "position" ).each do |category| + return_str += make_category_list(category, id) + end + return return_str + end + + def make_category_list(category, id, depth = 0) + return_str = " " * depth + if id.to_s == category.id.to_s || depth > 3 + return_str += category.name + else + return_str +=link_to(category.name,{:category_id => category.id, :id => nil}) + end + return_str += "
" + + if category.get_child_category_ids.include?(id.to_i) + logger.debug category.id + if get_categories = Category.find(:all, :conditions => ["parent_id = ?", category.id], :order => "position") + logger.debug get_categories + if ! get_categories.empty? + get_categories.each do |get_category| + return_str += make_category_list get_category, id, depth + 1 + end + end + end + end + return return_str + end +end diff --git a/app/helpers/admin/customers_helper.rb b/app/helpers/admin/customers_helper.rb new file mode 100644 index 0000000..c6f19a0 --- /dev/null +++ b/app/helpers/admin/customers_helper.rb @@ -0,0 +1,17 @@ +module Admin::CustomersHelper + def get_hassou_name(order_delivery) + unless order_delivery.status + return "ステータス不正" + end + if order_delivery.status <= OrderDelivery::HASSOU_TEHAIZUMI + "未発送" + else + order_delivery.shipped_at.strftime("%Y/%m/%d") if order_delivery.shipped_at + end + end + + def purchase_price(total, point) + price = total.to_i - point.to_i + return "¥" + price.to_s + end +end diff --git a/app/helpers/admin/design_helper.rb b/app/helpers/admin/design_helper.rb new file mode 100644 index 0000000..165a7be --- /dev/null +++ b/app/helpers/admin/design_helper.rb @@ -0,0 +1,2 @@ +module Admin::DesignHelper +end diff --git a/app/helpers/admin/feature_products_helper.rb b/app/helpers/admin/feature_products_helper.rb new file mode 100644 index 0000000..db6f5ee --- /dev/null +++ b/app/helpers/admin/feature_products_helper.rb @@ -0,0 +1,2 @@ +module Admin::FeatureProductsHelper +end diff --git a/app/helpers/admin/features_helper.rb b/app/helpers/admin/features_helper.rb new file mode 100644 index 0000000..8f33e95 --- /dev/null +++ b/app/helpers/admin/features_helper.rb @@ -0,0 +1,2 @@ +module Admin::FeaturesHelper +end diff --git a/app/helpers/admin/home_helper.rb b/app/helpers/admin/home_helper.rb new file mode 100644 index 0000000..5c2b5b7 --- /dev/null +++ b/app/helpers/admin/home_helper.rb @@ -0,0 +1,21 @@ +module Admin::HomeHelper + def sold_outs(product_styles) + if product_styles.blank? + return "なし" + end + html = "" + (product_styles || []).each_with_index do |product_style,index| + if index >= 10 + break + end + html << h(product_style.code) << ":" << h(product_style.name) << "
" + end + html + end + + def sold_out_counts(product_styles) + unless product_styles.blank? + "総数: " << product_styles.size.to_s << " å“ç›®" + end + end +end diff --git a/app/helpers/admin/kiyaku_helper.rb b/app/helpers/admin/kiyaku_helper.rb new file mode 100644 index 0000000..9ff0615 --- /dev/null +++ b/app/helpers/admin/kiyaku_helper.rb @@ -0,0 +1,2 @@ +module Admin::KiyakuHelper +end diff --git a/app/helpers/admin/mail_magazine_helper.rb b/app/helpers/admin/mail_magazine_helper.rb new file mode 100644 index 0000000..bb1d31a --- /dev/null +++ b/app/helpers/admin/mail_magazine_helper.rb @@ -0,0 +1,126 @@ +module Admin::MailMagazineHelper + NOT_SELECTED = "(未指定)" + DATE_FORMAT = "%Y-%m-%d" + + def selected_check(value) + if value.blank? + return NOT_SELECTED + end + value + end + + def sex_name(male,female) + result = "" + male_selected = false + if male && male == "1" + result << "男性 " + end + if female && female == "1" + result << "女性" + end + if result.blank? + result = NOT_SELECTED + end + result + end + + def form_type_name(form_type) + if form_type.blank? + return NOT_SELECTED + end + if form_type == "0" + return "(両方)" + else + return Customer::MAILMAGAZINE_NAMES[form_type.to_i] + end + end + + def birth_month_name(birth_month) + if birth_month.blank? + return NOT_SELECTED + end + return birth_month + " æœˆ" + end + + def order_count_name(from, to) + if from.blank? && to.blank? + return NOT_SELECTED + elsif from.blank? && !to.blank? + return NOT_SELECTED + " ã€œ " + number_with_delimiter(to) + " å›ž" + elsif !from.blank? && to.blank? + return number_with_delimiter(from) + " å›ž ã€œ " + NOT_SELECTED + end + number_with_delimiter(from) + " å›ž ã€œ " + number_with_delimiter(to) + " å›ž" + end + + def total_name(from, to) + if from.blank? && to.blank? + return NOT_SELECTED + elsif from.blank? && !to.blank? + return NOT_SELECTED + " ã€œ " + number_to_currency(to) + " å††" + elsif !from.blank? && to.blank? + return number_with_delimiter(from) + " å†† ã€œ " + NOT_SELECTED + end + number_with_delimiter(from) + " å†† ã€œ " + number_with_delimiter(to) + " å††" + end + + def mail_type_name(mail_type) + if mail_type.blank? + return NOT_SELECTED + end + if mail_type == "0" + return "パソコン用アドレス" + end + "携帯用アドレス" + end + + def occupation_names(ids) + if ids.blank? + return NOT_SELECTED + end + result = "" + ids.each do |id| + result << Occupation.find(id).name + result << " " + end + result + end + + def date_selected_check(from, to) + if from.blank? && to.blank? + return NOT_SELECTED + elsif from.blank? && !to.blank? + return NOT_SELECTED + " ã€œ " + h(to[0,10]) + elsif !from.blank? && to.blank? + return h(from[0,10]) + " ã€œ " + NOT_SELECTED + else + end + h(from[0,10]) + " ã€œ " + h(to[0,10]) + end + + def templates_select + templates = MailMagazineTemplate.find(:all, + :select => "id,form,subject", + :order => "updated_at DESC") + + result = [] + if templates.blank? + return result + end + templates.each do |t| + if t.form == MailMagazineTemplate::TEXT + result << ["【テキスト】" + t.subject, t.id.to_s] + else + result << ["【HTML】" + t.subject, t.id.to_s] + end + end + result + end +end + + + + + + + diff --git a/app/helpers/admin/mail_magazine_template_helper.rb b/app/helpers/admin/mail_magazine_template_helper.rb new file mode 100644 index 0000000..bf2b33f --- /dev/null +++ b/app/helpers/admin/mail_magazine_template_helper.rb @@ -0,0 +1,2 @@ +module Admin::MailMagazineTemplateHelper +end diff --git a/app/helpers/admin/mail_template_helper.rb b/app/helpers/admin/mail_template_helper.rb new file mode 100644 index 0000000..417627f --- /dev/null +++ b/app/helpers/admin/mail_template_helper.rb @@ -0,0 +1,2 @@ +module Admin::MailTemplateHelper +end diff --git a/app/helpers/admin/mobile_device_helper.rb b/app/helpers/admin/mobile_device_helper.rb new file mode 100644 index 0000000..f5f6bdc --- /dev/null +++ b/app/helpers/admin/mobile_device_helper.rb @@ -0,0 +1,2 @@ +module Admin::MobileDeviceHelper +end diff --git a/app/helpers/admin/new_informations_helper.rb b/app/helpers/admin/new_informations_helper.rb new file mode 100644 index 0000000..a8a37c3 --- /dev/null +++ b/app/helpers/admin/new_informations_helper.rb @@ -0,0 +1,9 @@ +module Admin::NewInformationsHelper + def new_window(flg) + if flg + "別ウィンドウで開く" + else + "同じウィンドウで開く" + end + end +end diff --git a/app/helpers/admin/order_helper.rb b/app/helpers/admin/order_helper.rb new file mode 100644 index 0000000..68f1dce --- /dev/null +++ b/app/helpers/admin/order_helper.rb @@ -0,0 +1,2 @@ +module Admin::OrderHelper +end diff --git a/app/helpers/admin/order_status_helper.rb b/app/helpers/admin/order_status_helper.rb new file mode 100644 index 0000000..3dcfc22 --- /dev/null +++ b/app/helpers/admin/order_status_helper.rb @@ -0,0 +1,2 @@ +module Admin::OrderStatusHelper +end diff --git a/app/helpers/admin/order_statuses_helper.rb b/app/helpers/admin/order_statuses_helper.rb new file mode 100644 index 0000000..5594c74 --- /dev/null +++ b/app/helpers/admin/order_statuses_helper.rb @@ -0,0 +1,2 @@ +module Admin::OrderStatusesHelper +end diff --git a/app/helpers/admin/payment_helper.rb b/app/helpers/admin/payment_helper.rb new file mode 100644 index 0000000..ea63712 --- /dev/null +++ b/app/helpers/admin/payment_helper.rb @@ -0,0 +1,2 @@ +module Admin::PaymentHelper +end diff --git a/app/helpers/admin/product_helper.rb b/app/helpers/admin/product_helper.rb new file mode 100644 index 0000000..038be39 --- /dev/null +++ b/app/helpers/admin/product_helper.rb @@ -0,0 +1,2 @@ +module Admin::ProductHelper +end diff --git a/app/helpers/admin/product_styles_helper.rb b/app/helpers/admin/product_styles_helper.rb new file mode 100644 index 0000000..ca2356e --- /dev/null +++ b/app/helpers/admin/product_styles_helper.rb @@ -0,0 +1,2 @@ +module Admin::ProductStylesHelper +end diff --git a/app/helpers/admin/questionnaires_helper.rb b/app/helpers/admin/questionnaires_helper.rb new file mode 100644 index 0000000..546b159 --- /dev/null +++ b/app/helpers/admin/questionnaires_helper.rb @@ -0,0 +1,2 @@ +module Admin::QuestionnairesHelper +end diff --git a/app/helpers/admin/recommend_products_helper.rb b/app/helpers/admin/recommend_products_helper.rb new file mode 100644 index 0000000..c06975b --- /dev/null +++ b/app/helpers/admin/recommend_products_helper.rb @@ -0,0 +1,2 @@ +module Admin::RecommendProductsHelper +end diff --git a/app/helpers/admin/shops_helper.rb b/app/helpers/admin/shops_helper.rb new file mode 100644 index 0000000..0de6382 --- /dev/null +++ b/app/helpers/admin/shops_helper.rb @@ -0,0 +1,2 @@ +module Admin::ShopsHelper +end diff --git a/app/helpers/admin/style_category_helper.rb b/app/helpers/admin/style_category_helper.rb new file mode 100644 index 0000000..2e8f44d --- /dev/null +++ b/app/helpers/admin/style_category_helper.rb @@ -0,0 +1,2 @@ +module Admin::StyleCategoryHelper +end diff --git a/app/helpers/admin/style_helper.rb b/app/helpers/admin/style_helper.rb new file mode 100644 index 0000000..223ee27 --- /dev/null +++ b/app/helpers/admin/style_helper.rb @@ -0,0 +1,2 @@ +module Admin::StyleHelper +end diff --git a/app/helpers/admin/total_helper.rb b/app/helpers/admin/total_helper.rb new file mode 100644 index 0000000..144fde4 --- /dev/null +++ b/app/helpers/admin/total_helper.rb @@ -0,0 +1,2 @@ +module Admin::TotalHelper +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 0000000..71e4406 --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,176 @@ +# Methods added to this helper will be available to all templates in the application. +module ApplicationHelper + NOT_FOUND_STRING = "不明" + + def link_parameter(name, option) + param_datas = {} + params.each{ |key, value| param_datas[key.to_sym] = value } + option.each{ |key, value| param_datas[key.to_sym] = value } + link_to name, param_datas + end + + def h_br(text) + value = h(text) + value.freeze # freeze しないと、gsub の中で $1 が tainted になる模様 (Ruby 1.8.5) + #value.gsub(/(https?:\/\/[\x21-\x7f]+)/){"#{$1}"}.gsub(/(\r\n|[\r\n])/, "
\n") + value.gsub(/(\r\n|[\r\n])/, "
\n") + end + + def h_apos(text) + unless text.blank? + text.gsub!(/\r\n|\r|\n/, "
") + text.gsub("\'","'") + end + end + + def date(date) + date && date.strftime("%Y/%m/%d") + end + + def date_jp(date) + date && date.strftime("%Y年%m月%d日") + end + + def date_month_day_jp(date) + date && date.strftime("%m月%d日") + end + + def date_time(date_time) + date_time && date_time.strftime("%Y/%m/%d %H:%M:%S") + end + + def prefecture_name(id, not_exist_string=NOT_FOUND_STRING) + if id.blank? + return not_exist_string + end + begin + Prefecture.find(id).name + rescue ActiveRecord::RecordNotFound => e + logger.error e + not_exist_string + end + end + + def occupation_name(id, not_exist_string=NOT_FOUND_STRING) + if id.blank? + return not_exist_string + end + begin + Occupation.find(id).name + rescue ActiveRecord::RecordNotFound => e + logger.error e + not_exist_string + end + end + +# def favorite_character_name(id, not_exist_string=NOT_FOUND_STRING) +# if id.blank? +# return not_exist_string +# end +# begin +# FavoriteCharacter.find(id).name +# rescue ActiveRecord::RecordNotFound => e +# logger.error e +# not_exist_string +# end +# end + + def grouping_name(id, not_exist_string=NOT_FOUND_STRING) + if id.blank? + return not_exist_string + end + begin + Groupings.find(id).name + rescue ActiveRecord::RecordNotFound => e + logger.error e + not_exist_string + end + end + + def birthday_select(object_name, method, options={}, html_options={}) + defaults = {:start_year=>1900, :end_year=>Date.today.year, :use_month_numbers=>true} + options = defaults.merge(options) + date_select(object_name, method, options) + end + + def authority_name(id, not_exist_string=NOT_FOUND_STRING) + if id.blank? + return not_exist_string + end + begin + Authority.find(id).name + rescue ActiveRecord::RecordNotFound => e + logger.error e + not_exist_string + end + end + + def category_name(id, not_exist_string=NOT_FOUND_STRING) + if id.blank? + return not_exist_string + end + begin + Category.find(id).name + rescue ActiveRecord::RecordNotFound => e + logger.error e + not_exist_string + end + end + + def campaign_name(id, not_exist_string=NOT_FOUND_STRING) + if id.blank? + return not_exist_string + end + begin + Campaign.find(id).name + rescue ActiveRecord::RecordNotFound => e + logger.error e + not_exist_string + end + end + + def mobile_carrier_name(id, not_exist_string=NOT_FOUND_STRING) + if id.blank? + return not_exist_string + end + begin + MobileCarrier.find(id).name + rescue ActiveRecord::RecordNotFound => e + logger.error e + not_exist_string + end + end + + +# def date_select_tag(name, value = nil, options = {}) +# defaults = { :discard_type => true } +# options = defaults.merge(options) +# datetime = value + +# position = { :year => 1, :month => 2, :day => 3} + +# order = (options[:order] ||= [:year, :month, :day]) + +# [:day, :month, :year].each { |o| order.unshift(o) unless order.include?(o) } + +# date_or_time_select = '' +# order.reverse.each do |param| +# date_or_time_select += content_tag(:select, date_select_options(param), { "name" => "#{name}[#{param}]", "id" => "#{name}_#{param}" }.update(options.stringify_keys)) +# end +# return date_select_options +# end + +# def date_select_options(type) +# case type +# when :year +# [""] +# when :month +# [""] +# when :day +# [""] +# else +# [""] +# end +# [] +# end +end diff --git a/app/helpers/base_helper.rb b/app/helpers/base_helper.rb new file mode 100644 index 0000000..2547870 --- /dev/null +++ b/app/helpers/base_helper.rb @@ -0,0 +1,483 @@ +module BaseHelper + def link_to_product(product, name=nil, options = {}) + product or return name + name ||= h(product.name) + if product.permit + link_to name, {:controller => "/products", :action => "show", :id => product.id, :category_id => product.category_id}, options + else + name + end + end + + def link_to_product_image(product, size=:large) + link_to_product(product, product_image_tag(product, size)) + end + + def link_to_category(category, type = "PC", image_flg=false) + if type == "MOBILE" + if params[:category_id] && params[:category_id].to_s == category.id.to_s + return_str = h(category.name) + else + return_str = link_to h(category.name), :controller => "/products" ,:action => "index", :category_id => category.id + end + else + if params[:category_id] && params[:category_id].to_s == category.id.to_s + return_str = image_flg ? category_image_tag(category) : h(category.name) + else + return_str = link_to((image_flg ? category_image_tag(category) : h(category.name)), :controller => "/products" ,:action => "index", :category_id => category.id) + end + end + return return_str + end + + def link_to_campaign(name, dir_name, options={}, html_options={}) + options = { + :controller=>'campaigns', + :action=>'show', + :dir_name=>dir_name + }.merge(options) + link_to(name, options, html_options) + end + + def category_list_view(type = "PC", image_flg = false) + id = params[:category_id] || 0 + return_array = [] + Category.find(:all, :conditions => ["parent_id is null"], :order => "position" ).each do |category| + unless type == "MOBILE" && !category.get_child_category_ids.include?(id.to_i) && id != 0 + return_str = category_list_view_child(category, id, image_flg, type) + end + return_array << return_str unless return_str.blank? + end + if type == "MOBILE" + return return_array.join("|") + else + return return_array.join + end + end + + def category_list_view_child(category, id, image_flg = false, type = "PC", depth = 0) + return "" unless category.product_count > 0 + return_str ="" + return_array = [] + if type == "MOBILE" + return_str += link_to_category(category, type) + return_str += ' ' + else + return_str += "
  • " + return_str += " "*depth + " " unless image_flg + return_str += link_to_category category, type, image_flg + return_str += "
  • " + end + return_array << return_str + if category.get_child_category_ids.include?(id.to_i) + if get_categories = Category.find(:all, :conditions => ["parent_id = ?", category.id], :order => "position") + unless get_categories.blank? + get_categories.each do |get_category| + if (get_category.get_child_category_ids.include?(id.to_i) && type == "MOBILE") || get_category.parent_id == id.to_i || type == "PC" + return_str = category_list_view_child(get_category, id, image_flg, type, depth + 1) + return_array << return_str unless return_str.blank? + end + end + end + end + end + return return_array + end + + def view_resource(resource, options={}) + return options[:alt] || '' if resource.nil? + if resource + view_resource_id(resource.id) + else + image_tag "/images/no_image.gif", options + end + end + + def view_resource_id(resource_id, options = {}) + if resource_id && resource_id != 0 + image_tag url_for(:controller => "/image_resource", :action => "show", :id => resource_id, :height=>options[:height], :width=>options[:width]), options + elsif resource_id == 0 + "" + else + image_tag "/images/no_image.gif", options + end + end + + # * INFO お届け先の追加・変更時に開くサブウィンドウ制御用のJavaScriptTagを生成。 + def popup_for_delivery_address_script + js = <<"EJS" + function popdelivery(URL,Winname,Wwidth,Wheight){ + var WIN; + WIN = window.open(URL,Winname,"width="+Wwidth+",height="+Wheight+",scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no"); + WIN.focus(); + } + Event.observe(window, 'load', function() { + $$('.delivery_edit').each(function(link) { + Event.observe(link, 'click', function(e) { + var url = e.target.href; + popdelivery(url, 'update_deliv', 600, 640); + e.stop(); + }); + }); + }); +EJS + javascript_tag js + end + + # * INFO お届け先の追加・変更時にサブウィンドウを閉じるためのJavaScriptTagを生成。 + def closer_for_delivery_address_script + js = <<"EJS" + function checkDelivAddress() { + var ua = navigator.userAgent; + if( !!window.opener ) { + if( ua.indexOf('MSIE 4')!=-1 && ua.indexOf('Win')!=-1 ) { + return !window.opener.closed; + } else { + return typeof window.opener.document == 'object'; + } + } else { + return false; + } + } + + function closeDeliveryAddress(url){ + if(checkDelivAddress()){ + window.opener.location.href = url; + }else{ + window.close(); + } + } +EJS + javascript_tag js + end + + # * INFO 追加お届け先が20件未満の場合、お届け先追加アクション用のリンクを生成する + def link_to_create_address(str = '新規登録') + @address_size < DeliveryAddress::MAXIMUM_POSITION or return nil + link_to(str, {:controller => :accounts, :action => :delivery_new_popup}, :class => 'delivery_edit') + # link_to_function(str, "popdelivery('/account/delivery_new_popup', 'create_deliv', '600', '640')") if @address_size < DeliveryAddress::MAXIMUM_POSITION + end + + # * INFO 会員の場合は hidden_field に会員IDを埋め込む。 + def hidden_address_customer_id + hidden_field_tag('address[customer_id]', @login_customer.id) if @login_customer + end + + def confirm_select(nomal, confirm, object_name) + if params[:action] =~ /confirm/ || params[:action] =~ /create/|| params[:action] =~ /update/ + if (object = self.instance_variable_get("@#{object_name}")) && object.errors.empty? + return confirm + end + end + return nomal + end + + def image_field(*args) + return_str = "" + return_str = send(:file_field, *args) + return_str += "
    " + object_name, method_name = args[0].to_s.dup, args[1].to_s.dup + object = self.instance_variable_get("@#{object_name}") + resource_id = object.send "#{method_name}_id" + if resource_id + return_str += "
    " + return_str += view_resource_id resource_id + return_str += hidden_field_tag "#{object_name}_#{method_name}_old_id", resource_id + return_str += link_to_function "この画像を削除する", "document.getElementById(\"#{object_name}_#{method_name}_old_file\").style.display = 'none';document.getElementById(\"#{object_name}_#{method_name}_old_id\").value=0" + return_str += "
    " + end + return return_str + end + + def confirm_tag(*args) + if params[:action] =~ /confirm/ || params[:action] =~ /create/ || params[:action] =~ /update/ + if args.size >= 3 + object_name, method_name = args[1].to_s.dup, args[2].to_s.dup + object_name.sub!(/\[\]$/,"") + if (object = self.instance_variable_get("@#{object_name}")) && object.errors.empty? + if method_name =~ /_resource$/ + return view_resource_id( object.send("#{method_name}_id")) + else + if method_name == "permit" + return object.send("permit_label") + elsif method_name == "category_id" + return h(object.category_id) + else + method = object.send(method_name) + if method.class == ActiveSupport::TimeWithZone + return h_br( method.strftime("%Yå¹´%m月%d日")) + else + return h_br( method ) + end + end + end + else + return send(*args) + end + else + return nil + end + end + return send(*args) + end + + #商品画像を出すimage_tag + def product_image_tag(product, type=:large, options={}) + return nil if product.nil? + options = ({ + :alt => product.name + }).merge(options) + id = nil + case type + when :large + id = product.large_resource_id + when :medium + id = product.medium_resource_id + when :small + id = product.small_resource_id + options = ({:width=>120}).merge(options) + end + if id + view_resource_id(id, options) + else + '' + end + end + + def payment_image_tag(payment, options={}) + return nil if payment.nil? + options = ({ + :alt => payment.name + }).merge(options) + id = payment.resource_id + if id + view_resource_id(id, options) + else + '' + end + end + + def sub_product_image_tag(sub_product, options={}) + return nil if sub_product.nil? + options = ({ +# :alt => payment.name + }).merge(options) + id = sub_product.medium_resource_id + if id + view_resource_id(id, options) + else + '' + end + end + + def column_name(model,column,astarisk = false) + if object = self.instance_variable_get("@#{model}") + "#{object.class.field_names[column]}#{astarisk ? " *" : ""}" + else + "" + end + end + + def column_confirm_tag(method, model, column, *args) + if object = self.instance_variable_get("@#{model}") + "#{ column_name(model, column) }#{confirm_tag(method, model, column, *args)}" + else + "" + end + end + +=begin rdoc + + という感じです。 +=end +def category_select(object, method, options={}, html_options={}) + select object, method, category_options, options, html_options +end + +def category_options(include_blank=false) + category_options_internal(Category.find_as_nested_array) +end + +def category_options_internal(tree, indent='') + tree.inject([]) do |array, item| + if item.instance_of? Category + array << ['%s%s' % [indent, item.name], item.id] + else + array += category_options_internal(item, indent + '>') + end + end +end + +def number_field(object_name, method, options = {}) + class_name = 'number' + options[:class].blank? or class_name += ' ' + options[:class] + text_field(object_name, method, options.merge(:class=>class_name)) +end + +def product_category_image_tag(product) + category_image_tag(product && product.category) +end + +def category_image_tag(category) + default = image_tag('title_cat00.jpg', :alt=>"カテゴリー") + category or return default + category.resource_id.blank? and return default + view_resource_id(category.menu_resource_id, :alt=>category.name) +end + +def each_product_styles(product) + product or return + style_categories1 = [] + style_categories2 = [] + product.product_styles.each do |ps| + style_categories1 << ps.style_category1 if ps.style_category1 + style_categories2 << ps.style_category2 if ps.style_category2 + end + style_categories1 = style_categories1.uniq + style_categories2 = style_categories2.uniq + all = [[product.style1, style_categories1, 1], + [product.style2, style_categories2, 2]] + all.each do |style,style_categories,index| + if style && !style_categories.empty? + yield style,style_categories,index + end + end +end + +def image_tag_mobile(prefix, options={}) + width = @mobile_device.width.to_i unless @mobile_device.blank? + size = 'q' # q = QVGA, v = VGA + size = 'v' if !width.blank? && width >= 480 + format = 'gif' + #キャリア毎に変更するなら以下を利用する(今は使わないのでコメントアウト + #format = 'gif' if request.mobile.is_a?(Jpmobile::Mobile::Docomo) + #format = 'gif' if request.mobile.is_a?(Jpmobile::Mobile::Au) + #format = 'gif' if request.mobile.is_a?(Jpmobile::Mobile::Softbank) + image_tag("/images/mobile/%s_%s.%s" % [prefix, size, format], options) +end + +def link_to_mobile(name, options = {}, html_options = nil) + if html_options and html_options[:accesskey] + accesskey = html_options[:accesskey].to_i + accesskey = 0 if accesskey < 0 + accesskey = 9 if accesskey > 9 + h = { + 1 => '', + 2 => '', + 3 => '', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => '', + 0 => '', + } + if request.mobile.is_a?(Jpmobile::Mobile::Softbank) + h = { + 1 => '$F<', + 2 => '$F=', + 3 => '$F>', + 4 => '$F?', + 5 => '$F@', + 6 => '$FA', + 7 => '$FB', + 8 => '$FC', + 9 => '$FD', + 0 => '$FE', + } + end + h[accesskey] + link_to(name, options, html_options) + else + link_to(name, options, html_options) + end +end + +def compound_title_tag(parts, options={}) + title = parts.reject(&:nil?).join(options.delete(:delimiter) || ' - ') + content_tag('title', h(title), options) +end + +#KBMJのASPサービスであるパーソナライズド・レコメンダー用のロジックです +def recommend_beacon(ids) + unless ids.is_a?(Array) + ids = [ids] + end + query = {:k=>'dummy_id', :id=>ids}.to_param #TODO:dummy_idにレコメンド用ビーコンIDを設定して下さい。 + url = request.protocol + 'recommend.kbmj.com/bcon/heavier/?' + query + image_tag(url, :width=>1, :height=>1, :alt=>'') +end + +def link_to_new_information(new_information, options={}, html_options={}) + name = options.delete(:body) || new_information.body + return name if new_information.url.blank? + url = new_information.url + html_options = { + :target => new_information.new_window ? "_blank" : "" + }.merge(html_options) + u = URI.parse(url) + if request.host == u.host + path = u.path + params = ActionController::Routing::Routes.recognize_path(path) + url = url_for(params.merge(options)) + (u.query ? "?"+u.query : "") + end + link_to(name, url, html_options) +end + + # 携帯各キャリアの入力モード指定用のハッシュを取得 + # DoCoMo:style="-wap-input-format:…;" + # au : format="…" + # Softbank : mode="…" + # Softbankのmode指定 + # (hankakukana, alphabet, numeric) + # をシンボルで引数に渡す + def mobile_input_mode(mode) + istyle_hash = {"K" => 2, "E" => 3, "N" => 4} + hash = { + :hankakukana => { + :docomo => {:istyle => istyle_hash["K"], + :style => "-wap-input-format:"*<ja:hk>""}, + :au => {:istyle => istyle_hash["K"], + :format => "*M"}, + :softbank => {:istyle => istyle_hash["K"], + :mode => "hankakukana"}, + }, + :alphabet => { + :docomo => {:istyle => istyle_hash["E"], + :style => "-wap-input-format:"*<ja:en>""}, + :au => {:istyle => istyle_hash["E"], + :format => "*m"}, + :softbank => {:istyle => istyle_hash["E"], + :mode => "alphabet"}, + }, + :numeric => { + :docomo => {:istyle => istyle_hash["N"], + :style => "-wap-input-format:"*<ja:n>""}, + :au => {:istyle => istyle_hash["N"], + :format => "*N"}, + :softbank => {:istyle => istyle_hash["N"], + :mode => "numeric"}, + }, + } + mode = mode.to_sym + hash[mode][mobile_carrer_type] || {} + end + + def mobile_carrer_type + case request.mobile + when Jpmobile::Mobile::Docomo + :docomo + when Jpmobile::Mobile::Au + :au + when Jpmobile::Mobile::Softbank + :softbank + end + end +end diff --git a/app/helpers/campaign_entry_helper.rb b/app/helpers/campaign_entry_helper.rb new file mode 100644 index 0000000..673217d --- /dev/null +++ b/app/helpers/campaign_entry_helper.rb @@ -0,0 +1,2 @@ +module CampaignEntryHelper +end diff --git a/app/helpers/campaigns_helper.rb b/app/helpers/campaigns_helper.rb new file mode 100644 index 0000000..d9089a0 --- /dev/null +++ b/app/helpers/campaigns_helper.rb @@ -0,0 +1,2 @@ +module CampaignsHelper +end diff --git a/app/helpers/cart_helper.rb b/app/helpers/cart_helper.rb new file mode 100644 index 0000000..858c201 --- /dev/null +++ b/app/helpers/cart_helper.rb @@ -0,0 +1,185 @@ +module CartHelper + + # カートを渡すと、カート内の商品への加算用リンクを生成します。 + def incriment_tag(cart) + uri = {:controller => 'cart', + :action => 'inc', + :id => cart.product_style_id} + str = request.mobile? ? "増やす" : " + " + link_to str, url_for(uri), {:class => 'product_incriment'} + end + + # カートを渡すと、カート内の商品への減算用リンクを生成します。 + def decriment_tag(cart) + uri = {:controller => 'cart', + :action => 'dec', + :id => cart.product_style_id} + str = request.mobile? ? "減らす" : " - " + link_to str, url_for(uri), {:class => 'product_decriment'} + end + + # 非会員用お届け先追加のJavaScript + def optional_address_script + enable_setting = { + :parametor => false, + :style => {:backgroundColor => '#ffffff'} + } + + disable_setting = { + :parametor => true, + :style => {:backgroundColor => '#f0f0f0'} + } + js = <<"EJS" + function fnCheckOptionalAddress() { + if(!$$('.optional_address').first().disabled) { + fnChangeOptionalAddress('#dddddd'); + } else { + fnChangeOptionalAddress(''); + } + } + + function fnChangeOptionalAddress(color) { + if(color == "") { + #{update_page do |page| + page.select('.optional_address').each('disabled') do |element| + element.disabled = enable_setting[:parametor] + end + page.select('.optional_address').each('disabled') do |element| + element.setStyle enable_setting[:style] + end + end} + + } else { + + #{update_page do |page| + page.select('.optional_address').each('disabled') do |element| + element.disabled = disable_setting[:parametor] + end + page.select('.optional_address').each('disabled') do |element| + element.setStyle disable_setting[:style] + end + end} + + } + } +EJS + + javascript_tag js + end + +=begin rdoc + * INFO + + parametors: + :address => DeliveryAddress[必須] + + return: + 引数として渡された、DeliveryAddressインスタンスが、会員登録情報から生成されたものであれば + checked="checked"かつ、value="0"となるラジオボタンタグを生成する。 + 追加お届け先の場合は、checked="checked"とはならず、valueにはお届け先IDが格納された + ラジオボタンタグを生成する。 + + dependent: + Customer#basic_address + +=end + def address_button(address) + parametors = ['address_select'] + parametors << (address.frozen? ? '0' : address.id.to_s) + parametors << address.frozen? + radio_button_tag(parametors[0], parametors[1], parametors[2], :class => "radio_btn") + end + +=begin rdoc + * INFO + + parametors: + :address => DeliveryAddress[必須] + + return: + 引数として渡された、DeliveryAddressインスタンスが、会員登録情報から生成されたものであれば、 + "会員登録住所"と返し、そうでない場合(追加お届け先である場合)は、"追加登録住所"と返す + + dependent: + Customer#basic_address + +=end + def address_type_to_s(address) + h(address.frozen? ? "会員登録住所" : "追加登録住所") + end + +=begin rdoc + * INFO + + parametors: + :address => DeliveryAddress[必須] + + return: + 引数として渡された、DeliveryAddressの都道府県名、市区町村、詳細住所を結合して返す + +=end + def address_detail(address) + zip = '〒'+address.zipcode01 + '-' + address.zipcode02 + addr = [address.prefecture.name, address.address_city, address.address_detail].join(' ') + add_name = address.family_name + ' ' + address.first_name + res = '' + res << h(zip) + res << '
    ' + res << h(addr) + res << '
    ' + res << h(add_name) + end + +=begin rdoc + * INFO + + parametors: + :address => DeliveryAddress[必須] + + return: + 引数として渡された、DelivaryAddressインスタンスが、会員登録住所でない場合、 + お届け先内容変更ポップアップを開くリンクを生成する。 + + dependent: + Customer#basic_address + +=end + def link_to_edit_address(address) + address.frozen? and return nil + link_to('変更', {:controller => :accounts, :action => :delivery_edit_popup, :id => address.id}, :class => 'delivery_edit') + end + +=begin rdoc + * INFO + + parametors: + :address => DeliveryAddress[必須] + + return: + 引数として渡された、DelivaryAddressインスタンスが、会員登録住所でない場合、 + 追加お届け先を削除するリンクを生成する。 + + dependent: + Customer#basic_address + +=end + def link_to_delete_address(address) + link_to('削除', + { + :controller => 'accounts', + :action => 'delivery_destroy', + :id => address.id, + :backurl => url_for({:controller => 'cart', :action => 'shipping'}) + }, + {:confirm => "一度削除したデータは元には戻せません。\n削除してもよろしいですか?"} + ) unless address.frozen? + end + + def link_to_continue_shopping + if session[:cart_last_product_id] + link_to 'お買い物を続ける', {:controller => 'product', :action => 'show', :id => session[:cart_last_product_id]} + else + link_to 'お買い物を続ける', {:controller => 'portal', :action => 'show'} + end + end +end diff --git a/app/helpers/features_helper.rb b/app/helpers/features_helper.rb new file mode 100644 index 0000000..1a5e6b2 --- /dev/null +++ b/app/helpers/features_helper.rb @@ -0,0 +1,2 @@ +module FeaturesHelper +end diff --git a/app/helpers/image_resource_helper.rb b/app/helpers/image_resource_helper.rb new file mode 100644 index 0000000..b2822e6 --- /dev/null +++ b/app/helpers/image_resource_helper.rb @@ -0,0 +1,2 @@ +module ImageResourceHelper +end diff --git a/app/helpers/inquiries_helper.rb b/app/helpers/inquiries_helper.rb new file mode 100644 index 0000000..fbe3595 --- /dev/null +++ b/app/helpers/inquiries_helper.rb @@ -0,0 +1,2 @@ +module InquiriesHelper +end diff --git a/app/helpers/portal_helper.rb b/app/helpers/portal_helper.rb new file mode 100644 index 0000000..51f4f8f --- /dev/null +++ b/app/helpers/portal_helper.rb @@ -0,0 +1,2 @@ +module PortalHelper +end diff --git a/app/helpers/product_helper.rb b/app/helpers/product_helper.rb new file mode 100644 index 0000000..a25d206 --- /dev/null +++ b/app/helpers/product_helper.rb @@ -0,0 +1,52 @@ +module ProductHelper + def link_order(order) + if params[:order] == order || ( params[:order].blank? && order == "update" ) + return order_name(order) + else + link_parameter order_name(order), {:order => order} + end + end + + def order_name(order) + order == "price" ? "価格順" : "新着順" + end + + def print_date(date) + date.strftime("%Y年%m月%d日") + end + + def paginate_item_count(current_page, per_page, total) + num = current_page * per_page + if num <= total + num + else + total + end + end + + def blank_check(sub_product) + count = 0 + sub_product.each do |sp| + count = count + 1 unless sp.large_resource_id.blank? + end + if count == 0 + return false + else + true + end + end + + def stock_mark(count) + mark = '×' + rest = count.to_i + #例 在庫>10:○、0<在庫<=10:△ 在庫<=0:× + #在庫nilの場合、0として + #△の標準は必ず「0」わけではなく、設定できるよう + if rest > Product::ZAIKO_MUCH + mark = '○' + elsif rest > Product::ZAIKO_LITTLE + mark = '△' + end + mark + end +end diff --git a/app/helpers/questionnaire_helper.rb b/app/helpers/questionnaire_helper.rb new file mode 100644 index 0000000..508c97e --- /dev/null +++ b/app/helpers/questionnaire_helper.rb @@ -0,0 +1,2 @@ +module QuestionnaireHelper +end diff --git a/app/helpers/recommend_helper.rb b/app/helpers/recommend_helper.rb new file mode 100644 index 0000000..e7b3e1c --- /dev/null +++ b/app/helpers/recommend_helper.rb @@ -0,0 +1,2 @@ +module RecommendHelper +end diff --git a/app/helpers/shop_helper.rb b/app/helpers/shop_helper.rb new file mode 100644 index 0000000..747a88a --- /dev/null +++ b/app/helpers/shop_helper.rb @@ -0,0 +1,2 @@ +module ShopHelper +end diff --git a/app/helpers/user_helper.rb b/app/helpers/user_helper.rb new file mode 100644 index 0000000..0147c3f --- /dev/null +++ b/app/helpers/user_helper.rb @@ -0,0 +1,2 @@ +module UserHelper +end diff --git a/app/models/admin_user.rb b/app/models/admin_user.rb new file mode 100644 index 0000000..008ebc3 --- /dev/null +++ b/app/models/admin_user.rb @@ -0,0 +1,125 @@ +# -*- coding: utf-8 -*- +class AdminUser < ActiveRecord::Base + + acts_as_paranoid + acts_as_list + + belongs_to :authority + + def self.validates_uniqueness_of(*attr_names) + configuration = { :message => I18n.translate("activerecord.errors.messages")[:taken], :case_sensitive => true } + + configuration.update(attr_names.extract_options!) + + validates_each(attr_names,configuration) do |record, attr_name, value| + class_hierarchy = [record.class] + while class_hierarchy.first != self + class_hierarchy.insert(0, class_hierarchy.first.superclass) + end + + finder_class = class_hierarchy.detect { |klass| !klass.abstract_class? } + + if value.nil? || (configuration[:case_sensitive] || !finder_class.columns_hash[attr_name.to_s].text?) + condition_sql = attribute_condition("#{record.class.quoted_table_name}.#{attr_name}", value) + condition_params = [value] + else + condition_sql = attribute_condition("LOWER(#{record.class.quoted_table_name}.#{attr_name})", value) + condition_params = [value.downcase] + end + + if scope = configuration[:scope] + Array(scope).map do |scope_item| + scope_value = record.send(scope_item) + condition_sql << attribute_condition(" AND #{record.class.quoted_table_name}.#{scope_item}", scope_value) + condition_params << scope_value + end + end + + unless record.new_record? + condition_sql << " AND #{record.class.quoted_table_name}.#{record.class.primary_key} <> ?" + condition_params << record.send(:id) + end + + condition_sql << " AND (deleted_at IS NULL OR deleted_at > '#{Time.now.gmtime.strftime("%Y-%m-%d %H:%M:%S")}')" + results = finder_class.with_exclusive_scope do + connection.select_all( + construct_finder_sql( + :select => "#{connection.quote_column_name(attr_name)}", + :from => "#{finder_class.quoted_table_name}", + :conditions => [condition_sql, *condition_params] + ) + ) + end + + unless results.length.zero? + found = true + + if configuration[:case_sensitive] && finder_class.columns_hash[attr_name.to_s].text? + found = results.any? { |a| a[attr_name.to_s] == value } + end + + record.errors.add(attr_name, configuration[:message]) if found + end + end + end + + + validates_presence_of :name + + validates_presence_of :authority + + validates_presence_of :login_id + validates_length_of :login_id, :maximum => 15 + validates_format_of :login_id, :with => /^[a-zA-Z0-9]*$/ + validates_uniqueness_of :login_id + + validates_length_of :password, :maximum => 15, :allow_nil => true + validates_format_of :password, :with => /^[a-zA-Z0-9]*$/ + + before_create :crypt_password + before_create :activity_true + before_update :crypt_unless_empty + + + def self.encode_password(pass) + #passwordの文字数制限は15文字までなので、暗号化も15文字までとする + Digest::SHA1.hexdigest("change-me--#{pass}--")[0..14] + end + + def self.find_by_login_id_and_password login_id, password + find(:first, :conditions => [ + 'login_id=? and password=? and activity=?', + login_id, encode_password(password), 1 + ]) + end + + def model_name + 'AdminUser' + end + + def self.get_csv_settings + columns = ['id', 'login_id'] + titles = ['id', 'login_id'] + [columns, titles] + end + + protected + + def crypt_password + write_attribute "password", self.class.encode_password(password) + end + + def crypt_unless_empty + user = self.class.find_by_id(self.id) + if self.password.blank? + self.password = user.password + elsif user.password != self.password + write_attribute "password", self.class.encode_password(password) + end + end + + def activity_true + self.activity = true + end + +end diff --git a/app/models/authorities_function.rb b/app/models/authorities_function.rb new file mode 100644 index 0000000..2b9629f --- /dev/null +++ b/app/models/authorities_function.rb @@ -0,0 +1,2 @@ +class AuthoritiesFunction < ActiveRecord::Base +end diff --git a/app/models/authority.rb b/app/models/authority.rb new file mode 100644 index 0000000..4e7b19a --- /dev/null +++ b/app/models/authority.rb @@ -0,0 +1,30 @@ +class Authority < ActiveRecord::Base + + acts_as_list + + has_many :admin_users + has_and_belongs_to_many :functions + + #前処理 + before_create :position_up + + validates_presence_of :name, :message=>'を入力してください' + validates_uniqueness_of :name, :message=>'は、重複しています' + + def chang_functions(selected_functions) + function_ids = selected_functions.keys.collect {|key| key.to_i} + self.functions = Function.find(function_ids) + end + + protected + + def position_up + if Authority.maximum(:position) != nil + self.position = Authority.maximum(:position) + 1 + else + self.position = 1 + end + end + + +end diff --git a/app/models/campaign.rb b/app/models/campaign.rb new file mode 100644 index 0000000..8b4f557 --- /dev/null +++ b/app/models/campaign.rb @@ -0,0 +1,184 @@ +# -*- coding: utf-8 -*- +class Campaign < ActiveRecord::Base + + acts_as_paranoid + + belongs_to :product + has_and_belongs_to_many :customers + + validates_presence_of :name, :message => "を記入してください" + validates_presence_of :dir_name, :message => "を記入してください(半角英数字または記号)" + validates_presence_of :opened_at + validates_presence_of :closed_at + + validates_length_of :name, :maximum=>30, :message => "は30文字以内で入力してください" + validates_length_of :dir_name, :maximum=>30, :message => "は30文字以内で入力してください" + + validates_format_of :dir_name, :with=>/^[\x20-\x7e]*$/, :message=>'は半角英数字または記号で入力してください' + validates_format_of :product_id, :with => /^[0-9]*$/, :message=>'は半角数字で入力してください' + + def self.validates_uniqueness_of(*attr_names) + configuration = { :message => I18n.translate("activerecord.errors.messages")[:taken], :case_sensitive => true } + configuration.update(attr_names.extract_options!) + + validates_each(attr_names,configuration) do |record, attr_name, value| + class_hierarchy = [record.class] + while class_hierarchy.first != self + class_hierarchy.insert(0, class_hierarchy.first.superclass) + end + + finder_class = class_hierarchy.detect { |klass| !klass.abstract_class? } + + if value.nil? || (configuration[:case_sensitive] || !finder_class.columns_hash[attr_name.to_s].text?) + condition_sql = attribute_condition("#{record.class.quoted_table_name}.#{attr_name}", value) + condition_params = [value] + else + condition_sql = attribute_condition("LOWER(#{record.class.quoted_table_name}.#{attr_name})", value) + condition_params = [value.downcase] + end + + if scope = configuration[:scope] + Array(scope).map do |scope_item| + scope_value = record.send(scope_item) + condition_sql << attribute_condition(" AND #{record.class.quoted_table_name}.#{scope_item}", scope_value) + condition_params << scope_value + end + end + + unless record.new_record? + condition_sql << " AND #{record.class.quoted_table_name}.#{record.class.primary_key} <> ?" + condition_params << record.send(:id) + end + + condition_sql << " AND (deleted_at IS NULL OR deleted_at > '#{Time.now.gmtime.strftime("%Y-%m-%d %H:%M:%S")}')" + results = finder_class.with_exclusive_scope do + connection.select_all( + construct_finder_sql( + :select => "#{connection.quote_column_name(attr_name)}", + :from => "#{finder_class.quoted_table_name}", + :conditions => [condition_sql, *condition_params] + ) + ) + end + + unless results.length.zero? + found = true + + if configuration[:case_sensitive] && finder_class.columns_hash[attr_name.to_s].text? + found = results.any? { |a| a[attr_name.to_s] == value } + end + + record.errors.add(attr_name, configuration[:message]) if found + end + end + end + + validates_uniqueness_of :dir_name, :message=>'は重複しています' + validates_uniqueness_of :product_id, :allow_nil => true + + def validate + if !self.product_id.blank? && !Product.find(:first, :conditions=>["id=?", self.product_id]) + errors.add_to_base "指定されたIDを持つ商品がありません" + end + + if !self.closed_at.blank? && !self.opened_at.blank? && (self.closed_at < self.opened_at) + errors.add_to_base "公開終了日時が公開開始日時より前です" + end + end + + def available?(day=DateTime.now) + check_term(day) && check_max_application_number + end + + #公開期間中かをチェック + def check_term(day=DateTime.now) + day >= opened_at && day <= closed_at + end + + #申込人数をオーバーしているかをチェック + def check_max_application_number + count = application_count.to_i + max = max_application_number.to_i + if count == 0 && max == 0 + return true + elsif max == 0 + return true + end + + count < max + end + + #重複申込に引っかかっているかをチェック + def duplicated?(customer) + if repeat_application + if customers.find(:first, :conditions => ["customers.id=?", customer.id]) + return true + else + return false + end + else + return false + end + end + + def self.csv(campaign) + result = "" + header = ["顧客ID", + "名前1", + "名前2", + "フリガナ1", + "フリガナ2", + "郵便番号1", + "郵便番号2", + "都道府県", + "住所1", + "住所2", + "E-MAIL", + "電話番号1", + "電話番号2", + "電話番号3", + "FAX番号1", + "FAX番号2", + "FAX番号3", + "性別", + "職業"] + + result += header.map.join(",") + "\r\n" + + questionnaires = campaign.customers + + unless questionnaires + flash.now[:notice] = "ダウンロードデータがありません" + redirect_to :action => :index + end + + questionnaires.each do |c| + arr = [ + c.id, + c.family_name, + c.first_name, + c.family_name_kana, + c.first_name_kana, + c.zipcode01, + c.zipcode02, + c.prefecture.name, + c.address_city, + c.address_detail, + c.email, + c.tel01, + c.tel02, + c.tel03, + c.fax01, + c.fax02, + c.fax03, + System::SEX_NAMES[c.sex], + (c.occupation.blank? ? nil : c.occupation.name) + ] + result << arr.join(",") << "\r\n" + end + result + end + +end + + diff --git a/app/models/cart.rb b/app/models/cart.rb new file mode 100644 index 0000000..824c20a --- /dev/null +++ b/app/models/cart.rb @@ -0,0 +1,52 @@ +class Cart < ActiveRecord::Base + + acts_as_paranoid + belongs_to :customer + belongs_to :product_style + + delegate_to :product_style, :product + delegate_to :product_style, :product, :id, :as => :product_id + delegate_to :product_style, :product, :name, :as => :product_name + delegate_to :product_style, :sell_price, :as => :price + delegate_to :product_style, :style_category1, :name, :as => :classcategory_name1 + delegate_to :product_style, :style_category2, :name, :as => :classcategory_name2 + + def subtotal + if product_style + product_style.including_tax_sell_price * quantity.to_i + else + nil + end + end + + def validate + if customer && customer.black + errors.add_to_base('申し訳ありませんが販売を終了させて頂きました。') + end + if quantity == 0 + errors.add :quantity, 'が 0 です。削除してください。' + end + unless product_style + errors.add :product_style, 'がありません。削除してください。' + else + ## product_style が必要な検証 + # 受注可能数以内か + if quantity > product_style.available?(quantity) + errors.add_to_base('購入可能な数量を超過しています') + end + # キャンペーンが生きているか + if product_style.product && campaign = product_style.product.campaign + unless campaign.check_term + errors.add_to_base('キャンペーン期間外です。') + end + end + product = product_style.product + unless product.permit + errors.add_to_base('申し訳ありませんが販売を終了させて頂きました。') + end + unless product.in_sale_term? + errors.add_to_base('申し訳ありませんが販売を終了させて頂きました。') + end + end + end +end diff --git a/app/models/cart_add_product_form.rb b/app/models/cart_add_product_form.rb new file mode 100755 index 0000000..fea7876 --- /dev/null +++ b/app/models/cart_add_product_form.rb @@ -0,0 +1,6 @@ +# 「カートに入れる」フォーム +class CartAddProductForm < SearchForm + set_field_names :size => '個数' + validates_presence_of :size,:message => 'が入力されていません。' + validates_numericality_of :size, :greater_than_or_equal_to => 1, :only_integer => true, :allow_blank => true, :message => 'は 1 以上の数字(半角)を入力してください。' +end diff --git a/app/models/category.rb b/app/models/category.rb new file mode 100644 index 0000000..a796bb9 --- /dev/null +++ b/app/models/category.rb @@ -0,0 +1,134 @@ +class Category < ActiveRecord::Base + acts_as_paranoid + acts_as_list + acts_as_tree + has_many :products + belongs_to :resource, + :class_name => "ImageResource", + :foreign_key => "resource_id" + belongs_to :menu_resource, + :class_name => "ImageResource", + :foreign_key => "menu_resource_id" + + alias :resource_old= :resource= + alias :menu_resource_old= :menu_resource= + [:resource, :menu_resource].each do | method_name| + define_method("#{method_name}=") do | value | + if value.class == ActionController::UploadedStringIO || value.class == ActionController::UploadedTempfile || value.class == Tempfile + image_resource = ImageResource.new_file(value, value.original_filename) + self.send "#{method_name}_old=".intern, image_resource + elsif value.class == ImageResource + self.send "#{method_name}_old=".intern, value + else + nil + end + end + end + + def parent + Category.find_by_id(self.parent_id) + end + + def product_count + count_num = 0 + get_child_categories.each do | child_category | + conditions = Product.defalt_condition + conditions << ["category_id = ?", child_category.id] + count_num += Product.count(:conditions => flatten_conditions(conditions)) + end + return count_num + end + + def get_child_categories + get_child_category_ids.map{|child_id| Category.find(child_id)} + end + + def get_child_category_ids + if children_ids.nil? + self.children_ids = get_childs(true).join(",") + self.save + end + + children_ids.split(",").map{|child_id| child_id.to_i } + end + + def self.find_as_nested_array + return find_as_nested_array_intenal(nil, Category.all(:order => 'position')) + end + + def get_childs(ids_flg = false) + if self.children.blank? + return [return_model_or_id(self, ids_flg)] + else + return_childs = [return_model_or_id(self, ids_flg)] + children.each do | child | + child.get_child_categories.each do | child_s_child | + return_childs << return_model_or_id(child_s_child, ids_flg) + end + end + return return_childs + end + end + + def position_up + condition = self.parent_id ? ["parent_id = ?", self.parent_id.to_i] : ["parent_id is null"] + max_position = Category.maximum(:position, :conditions => condition) + self.position = max_position ? max_position+1 : 1 + end + + def self.re_position(parent_id) + condition = parent_id ? ["parent_id = ?", parent_id] : ["parent_id is null"] + records = Category.find(:all, :conditions=>condition, :order => "position asc") + records.each_with_index do |record, idx| + record.update_attribute(:position, idx+1) + end + end + + def move_higher + position_move(true) + end + + def move_lower + position_move(false) + end + + protected + + def position_move(posit) + condition = self.parent_id ? [["parent_id = ?", self.parent_id.to_i]] : [["parent_id is null"]] + if posit + condition << ["position < ?", self.position] + else + condition << ["position > ?", self.position] + end + next_record = Category.find(:first, :conditions => flatten_conditions(condition), :order => "position asc") + next_position = next_record.position + current_position = self.position + next_record.update_attribute(:position, current_position) + self.update_attribute(:position, next_position) + end + + def self.get_list(parent_id) + if parent_id + return Category.find(:all, :conditions => ["parent_id = ?", parent_id], :order => "position asc") + else + return Category.find(:all, :conditions => ["parent_id is null"], :order => "position asc") + end + end + + private + def return_model_or_id(model, id_flg) + id_flg ? model.id : model + end + + def self.find_as_nested_array_intenal(id, all) + categories = all.select{|c| c.parent_id == id} + categories.inject([]) do |array, category| + array << category + children = find_as_nested_array_intenal(category.id, all) + array << children unless children.empty? + array + end + end + +end diff --git a/app/models/constant.rb b/app/models/constant.rb new file mode 100644 index 0000000..bad2f20 --- /dev/null +++ b/app/models/constant.rb @@ -0,0 +1,23 @@ +class Constant < ActiveRecord::Base + + acts_as_paranoid + + ## キー + # ソフトバンクメールアドレスのドメイン + DOMAIN_SOFTBANK = 1 + # 開発環境でのURL + SITE_URL_DEVELOP = 2 + # 移動理由@在庫管理 + MOVEMENT_REASON = 5 + + def self.list key + find(:all, :conditions => ['key=?', key], :order => 'position') + end + + # options_for_select で使う + def self.list_for_options key + list(key).map do | record | + [record.value, record.value] + end + end +end diff --git a/app/models/customer.rb b/app/models/customer.rb new file mode 100644 index 0000000..00f4e5e --- /dev/null +++ b/app/models/customer.rb @@ -0,0 +1,501 @@ +# -*- coding: utf-8 -*- +require 'digest/sha1' + +class Customer < ActiveRecord::Base + + acts_as_paranoid + attr_accessor :email_confirm, :editting + attr_accessor :raw_password, :password_confirm + attr_accessor :email_user, :email_domain, :email_user_confirm + attr_accessor :excepted + belongs_to :prefecture + belongs_to :occupation + has_many :orders + has_many :delivery_addresses + has_many :carts, :order => "position" + belongs_to :campaign_entry + + KARITOUROKU, TOUROKU, TEISHI, HIKAIIN = 1, 2, 3, 4 + ACTIVATE_NAMES = { KARITOUROKU => '仮登録', TOUROKU => '登録', TEISHI => '退会', HIKAIIN => '非会員' } + TEXT_MAIL, HTML_MAIL, NO_MAIL = 1, 2, 0 + MAILMAGAZINE_NAMES = { HTML_MAIL => 'HTML メール', TEXT_MAIL => 'テキストメール', NO_MAIL => '希望しない' } + ON, OFF = true, false + BLACK_NAMES = {ON => "ON", OFF => "OFF"} + REACHE, NOT_REACHE = true, false + REACHABLE_NAMES = {REACHE => "到達可能", NOT_REACHE => "到達不可能"} + #モバイルキャリア + NOT_MOBILE, DOCOMO, AU, SOFTBANK = 0, 1, 2, 3 + DOMAIN_DOCOMO = 'docomo.ne.jp' + DOMAIN_AU = 'ezweb.ne.jp' + EMAIL_PATTERN = /^([^@]([\.\+_a-z0-9-]+)@((?:[-a-z0-9]+\.)+[a-z]{2,}))$/i + + attr_accessor :from_cart + attr_accessor :target_columns + attr_accessor :csv_input + + validates_presence_of :email + + validates_presence_of :family_name, :first_name + + validates_presence_of :family_name_kana, :first_name_kana + validates_format_of :family_name_kana, :first_name_kana, :with => System::KATAKANA_PATTERN + + validates_presence_of :zipcode01, :zipcode02 + validates_numericality_of :zipcode01, :zipcode02, :allow_blank=>true + validates_length_of :zipcode01, :is => 3, :allow_blank=>true + validates_length_of :zipcode02, :is => 4, :allow_blank=>true + + validates_presence_of :prefecture_id + validates_associated :prefecture + + validates_presence_of :address_city, :address_detail + + validates_presence_of :tel01, :tel02, :tel03 + validates_numericality_of :tel01, :tel02, :tel03, :allow_blank => true + validates_length_of :tel01, :tel02, :tel03, :maximum => 4, :allow_blank => true + + validates_numericality_of :fax01, :fax02, :fax03, :allow_blank => true + validates_length_of :fax01, :fax02, :fax03, :maximum => 4, :allow_blank => true + + validates_inclusion_of :sex, :in => [System::MALE, System::FEMALE], :allow_blank => true + + validates_presence_of :password, :unless => :new_record? + validates_presence_of :raw_password, :if => :password_presence_check? + validates_length_of :raw_password, :in => 4..10, :allow_blank => true + validates_length_of :password, :minimum => 4, :allow_blank => true + + validates_presence_of :receive_mailmagazine, :unless => :from_cart + + def password_presence_check? + #編集 CSVアップロード 非会員購入の場合、パスワード必須チェックを行わない + new_record? && !csv_input && activate != HIKAIIN + end + + def initialize(*) + super + self.receive_mailmagazine ||= HTML_MAIL + self.sex ||= System::MALE + end + + def before_validation + unless email_domain.blank? + self.email = '%s@%s' % [email_user, email_domain] + self.email_confirm = '%s@%s' % [email_user_confirm, email_domain] + end + end + + def validate + if email && email =~ EMAIL_PATTERN + m = TMail::Mail.new + m.from = email + if m.from.nil? + errors.add :email, '(%s)は当サイトではご利用になれません。' % email + end + end + if activate != TEISHI && activate != HIKAIIN # 退会済みと非会員は対象外(顧客管理での編集時) + str = 'email = :email and activate in (:activate)' + str += ' and id <> :id' if id + params = { :id => id, :email => email, + :activate => [self.class::TOUROKU, self.class::KARITOUROKU] } + if self.class.find(:first, :conditions => [str, params]) + errors.add :email, 'は、すでに登録されているメールアドレスです' + end + end + # 顧客登録/編集の時だけ + if editting + # メールアドレス確認入力 + if email != email_confirm + errors.add :email, 'が一致しません' + end + # パスワード確認入力 + if raw_password != password_confirm + errors.add :password, 'が一致しません' + end + end + # 非会員購入時のメールアドレス + if activate == HIKAIIN + # メールアドレス確認入力 + if email != email_confirm + errors.add :email, 'が一致しません' + end + end + + # PC からの登録では携帯電話のメールアドレスは不可 + if mobile_carrier == NOT_MOBILE + if email && (domain = email.split('@')[1]) + list = [DOMAIN_DOCOMO, DOMAIN_AU] + + Constant.list(Constant::DOMAIN_SOFTBANK).map(&:value) + if list.include?(domain) + errors.add :email, 'は PC アドレスのみ登録可能です' + end + end + end + strip_errors + end + + def validate_on_create + errors.add :email, '(確認用)を入力してください' if email_confirm.blank? && !csv_input + errors.add :password, '(確認用)を入力してください' if password_confirm.blank? && !csv_input && activate != HIKAIIN + end + + def after_validation + # パスワードを暗号化 + unless raw_password.blank? + set_password(raw_password) + end + end + + def strip_errors + # 対象のカラム以外のエラーは無視する + if self.target_columns + target_columns = self.target_columns.map(&:to_s) + if target_columns.include?('email_user') + target_columns << 'email' + end + if target_columns.include?('raw_password') + target_columns << 'password' + end + e = errors.select{|k,_|target_columns.include?(k)} + errors.clear + e.each do |k,v| + errors.add k, v + end + end + end + + def sex_view + System::SEX_NAMES[sex] + end + + def receive_mailmagazine_view + MAILMAGAZINE_NAMES[receive_mailmagazine] + end + + def prefecture_name + prefecture && prefecture.name + end + + def occupation_name + occupation && occupation.name + end + + def black_view + BLACK_NAMES[black] + end + + def reachable_view + REACHABLE_NAMES[reachable] + end + + def regenerate_password! + array = Array.new + i = 0; while i < 8 + array << rand(62) + i += 1 + end + pass = array.pack("C*").tr("\x00-\x3d", "A-Za-z0-9") + self.password = self.class.encode_password(pass) + return pass + end + + def self.encode_password(pass) + Digest::SHA1.hexdigest("change-me--#{pass}--") + end + + # 会員登録住所を得る。会員登録情報から生成されたお届け先は変更できないように凍結しておく。 + def basic_address + DeliveryAddress.new( + { + :family_name => family_name, + :first_name => first_name, + :family_name_kana => family_name_kana, + :first_name_kana => first_name_kana, + :prefecture_id => prefecture_id, + :zipcode01 => zipcode01, + :zipcode02 => zipcode02, + :address_city => address_city, + :address_detail => address_detail, + :tel01 => tel01, + :tel02 => tel02, + :tel03 => tel03 + } + ).freeze + end + + def self.find_by_email_and_password email, password + find(:first, :conditions => [ + 'email=? and password=? and activate in (?)', + email, encode_password(password), [TOUROKU, KARITOUROKU] + ]) + end + + def correct_password? raw_password + password == self.class.encode_password(raw_password) + end + + def set_password raw_password + self.password = self.class.encode_password(raw_password) + end + + def generate_activation_key! + self.activation_key = Digest::SHA1.hexdigest(email.to_s+DateTime.new.to_s) + end + + def self.activate_email key + record = find_by_activation_key_and_activate(key, KARITOUROKU) + return nil unless record + record.activate = TOUROKU + record.activation_key = nil + record.reachable = true + record.update_attributes(:activate=>TOUROKU, :activation_key=>nil, :reachable=>true) + record + end + + def set_mobile(mobile) + set_mobile_carrier(mobile) + mobile.nil? and return + self.mobile_serial = mobile.ident_subscriber + self.mobile_type = mobile.ident_device + end + + def set_mobile_carrier name + if name.nil? + self.mobile_carrier = self.class::NOT_MOBILE + else + self.mobile_carrier = get_mobile_id_by_class(name) + end + end + + def same_mobile_carrier? name + if name.nil? + return mobile_carrier.to_i == self.class::NOT_MOBILE + end + mobile_carrier == get_mobile_id_by_class(name) + end + + # 郵便番号から住所を取ってくる + def update_address!(overwrite=true) + return if zipcode01.blank? or zipcode02.blank? + return unless zipcode01_changed? or zipcode02_changed? + if overwrite || + (prefecture_id.blank? && address_city.blank? && address_detail.blank?) || + (!prefecture_id_changed? && !address_city_changed? && !address_detail_changed?) + then + zip = Zip.find_by_zipcode(zipcode01, zipcode02) + if zip + self.prefecture_id = zip.prefecture_id + self.address_city = zip.address_city + self.address_detail = zip.address_details + end + end + end + + def generate_cookie!(addr) + sha1 = Digest::SHA1.new + sha1 << addr + sha1 << DateTime.now.to_s + sha1 << email + self.cookie = sha1.hexdigest + end + + def full_name + "#{family_name} #{first_name}" + end + + def self.get_symbols + [ + :id, + :zipcode01, + :zipcode02, + :tel01, + :tel02, + :tel03, + :fax01, + :fax02, + :fax03, + :sex, + :age, + :point, + :occupation_id, + :prefecture_id, + :family_name, + :first_name, + :family_name_kana, + :first_name_kana, + :email, +# :mobile_serial, + :activation_key, + :password, + :address_city, + :address_detail, +# :login_id, + :birthday, + :activate, + :receive_mailmagazine, + :mobile_carrier, + :black, + :deleted_at, +# :mobile_type, +# :user_agent, +# :corporate_name, +# :corporate_name_kana, +# :section_name, +# :section_name_kana, +# :contact_tel01, +# :contact_tel02, +# :contact_tel03, +# :address_building, + :reachable, + :mail_delivery_count, + :created_at, + :updated_at + ] + end + + def self.field_names + { + :id => "id", + :zipcode01 => "郵便番号(前半)", + :zipcode02 => "郵便番号(後半)", + :tel01 => "電話番号1", + :tel02 => "電話番号2", + :tel03 => "電話番号3", + :fax01 => "FAX番号1", + :fax02 => "FAX番号2", + :fax03 => "FAX番号3", + :sex => "性別", + :age => "年齢", + :point => "ポイント", + :occupation_id => "職業ID", + :prefecture_id => "都道府県ID", + :family_name => "姓", + :first_name => "名", + :family_name_kana => "姓(カナ)", + :first_name_kana => "名(カナ)", + :email => "メールアドレス", +# :mobile_serial => "携帯固有識別ID", + :activation_key => "会員登録時のキー", + :address_city => "住所(市町村)", + :address_detail => "住所(番地・ビル名)", +# :login_id => "ログインID", + :birthday => "生年月日", + :created_at => "作成日", + :updated_at => "更新日", + :activate => "会員状態", + :receive_mailmagazine => "メールマガジン受信可否", + :mobile_carrier => "携帯電話キャリア", + :black => "ブラックリストフラグ", + :password => "パスワード", + :deleted_at => "削除日", +# :mobile_type => "機種ID", +# :user_agent => "ユーザーエージェント", +# :corporate_name => "会社名", +# :corporate_name_kana => "会社名カナ", +# :section_name => "部署名", +# :section_name_kana => "部署名カナ", +# :contact_tel01 => "昼間連絡先電話番号1", +# :contact_tel02 => "昼間連絡先電話番号2", +# :contact_tel03 => "昼間連絡先電話番号3", +# :address_building => "住所(建物)", + :reachable => "登録メール到着可能フラグ", + :mail_delivery_count => "メール送信回数" + } + end + + def withdraw + self.activate = TEISHI + self.cookie = nil + self.save_without_validation + end + + class << self + def add_by_csv(file) + line = 0 + Customer.transaction do + CSV::Reader.parse(file) do |row| + if line != 0 + customer = new_by_array(row) + unless customer.save! + return [line, false] + end + end + line = line + 1 + end + end + [line - 1, true] + end + + private + + def new_by_array(arr) + arr.map! do | val | + Iconv.conv('UTF-8', 'cp932', val) + end + #arr[0]が対応しているデータ存在する時、更新、存在しない時、新規作成 + unless !arr[0].blank? && customer = Customer.find_by_id(arr[0]) + customer = Customer.new + end + #CSVデータ設定 + set_data(customer,arr) + #customer + customer + end + #CSVデータ設定 + def set_data(customer,arr) + #ダウンロードCSVファイルをEXCELで開く時、[010]が[10]になる対応 + customer.zipcode01 = arr[1].rjust(3, '0') + customer.zipcode02 = arr[2].rjust(4, '0') + customer.tel01 = arr[3] + customer.tel02 = arr[4] + customer.tel03 = arr[5] + customer.fax01 = arr[6] + customer.fax02 = arr[7] + customer.fax03 = arr[8] + customer.sex = System::SEX_NAMES.index arr[9] + customer.age = arr[10] + customer.point = arr[11] + customer.occupation_id = arr[12] + customer.prefecture_id = arr[13] + customer.family_name = arr[14] + customer.first_name = arr[15] + customer.family_name_kana = arr[16] + customer.first_name_kana = arr[17] + customer.email = arr[18] + customer.activation_key = arr[19] + customer.password = arr[20] + customer.address_city = arr[21] + customer.address_detail = arr[22] +# customer.login_id = arr[23] + customer.birthday = arr[23] + customer.activate = arr[24] + customer.receive_mailmagazine = arr[25] + customer.mobile_carrier = arr[26] + customer.black = arr[27] + customer.deleted_at = arr[28] + customer.reachable = arr[29] + customer.mail_delivery_count = arr[30] + customer.created_at = arr[31] + customer.updated_at = arr[32] + customer.csv_input = true + end + + end + + private + def get_mobile_id_by_class name + case name + when Jpmobile::Mobile::Docomo + DOCOMO + when Jpmobile::Mobile::Au + AU + when Jpmobile::Mobile::Softbank + SOFTBANK + else + NOT_MOBILE + end + end + + + +end + diff --git a/app/models/customer_search_form.rb b/app/models/customer_search_form.rb new file mode 100644 index 0000000..f55ef43 --- /dev/null +++ b/app/models/customer_search_form.rb @@ -0,0 +1,328 @@ +# -*- coding: utf-8 -*- +# 顧客管理で検索条件を格納するフォーム +class CustomerSearchForm < SearchForm + set_field_names :customer_id => '顧客コード' + set_field_names :customer_name_kana => '顧客名(カナ)' + set_field_names :email => 'メールアドレス' + set_field_names :tel_no => '電話番号' + set_field_names :total_up => '購入金額(前半)' + set_field_names :total_down => '購入金額(後半)' + set_field_names :order_count_up => '購入回数(前半)' + set_field_names :order_count_down => '購入回数(後半)' + set_field_names :birthday_from => '誕生日(前半)' + set_field_names :birthday_to => '誕生日(後半)' + set_field_names :updated_at_from => '登録・更新日(前半)' + set_field_names :updated_at_to => '登録・更新日(後半)' + set_field_names :last_order_from => '最終購入日(前半)' + set_field_names :last_order_to => '最終購入日(後半)' + set_field_names :product_code => '購入商品コード' + + validates_numericality_of :customer_id, :only_integer => true, :allow_blank => true, :message => 'は半角数字のみを入力してください。' + validates_format_of :customer_name_kana, :with => System::KATAKANA_PATTERN, :allow_blank => true, :message => 'は全角カタカナを入力してください。' + validates_format_of :email, :with => /[\x1-\x7f]/, :allow_blank => true, :message => 'は半角英数字のみを入力してください。' + validates_numericality_of :tel_no, :only_integer => true, :allow_blank => true, :message => 'は半角数字のみを入力してください。' + validates_numericality_of :total_down, :only_integer => true, :allow_blank => true, :message => 'は半角数字のみを入力してください。' + validates_numericality_of :total_up, :only_integer => true, :allow_blank => true, :message => 'は半角数字のみを入力してください。' + validates_numericality_of :order_count_down, :only_integer => true, :allow_blank => true, :message => 'は半角数字のみを入力してください。' + validates_numericality_of :order_count_up, :only_integer => true, :allow_blank => true, :message => 'は半角数字のみを入力してください。' + validates_format_of :product_code, :with => /^[0-9A-Za-z]+$/, :allow_blank => true, :message => 'は半角英数字のみを入力してください。' + + def self.csv(params) + @condition = self.new(params[:condition] ||= []) + customers = Customer.find_by_sql(get_sql_select(true) + get_sql_condition(@condition)) + unless customers.size > 0 + return false + end + + col_names = [] + syms = Customer.get_symbols + field_names = Customer.field_names + syms.each do |sym| + col_names << field_names[sym] + end + f = StringIO.new('', 'w') + CSV::Writer.generate(f) do | writer | + writer << col_names + customers.each do |c| +# p c + arr = [] + syms.each do |sym| + if sym == "sex".to_sym + if c.send(sym) == 1 + arr << "男性" + else + arr << "女性" + end + elsif sym == "age".to_sym + #誕生日から年齢を割り出す + birthday = c.send("birthday".to_sym) + arr << self.get_age(birthday) + else + arr << c.send(sym) + end + end + writer << arr + end + end + f.string + end + + #誕生日から年齢を割り出すメソッド + def self.get_age(birthday) + unless birthday.blank? + today = Date.today + year = today.year.to_i - birthday.year.to_i + if today.month.to_i > birthday.month.to_i + + elsif today.month.to_i < birthday.month.to_i + year = year - 1 + elsif today.month.to_i == birthday.month.to_i + if today.day.to_i >= birthday.day.to_i + + else + year = year - 1 + end + end + return year + end + end + + def self.get_sql_select(for_csv=false) + if for_csv +<<-EOS +select + c.id, + c.zipcode01, + c.zipcode02, + c.tel01, + c.tel02, + c.tel03, + c.fax01, + c.fax02, + c.fax03, + c.sex, + c.age, + c.point, + c.occupation_id, + c.prefecture_id, + c.family_name, + c.first_name, + c.family_name_kana, + c.first_name_kana, + c.email, + c.mobile_serial, + c.activation_key, + c.password, + c.address_city, + c.address_detail, + c.login_id, + c.birthday, + c.activate, + c.receive_mailmagazine, + c.mobile_carrier, + c.black, + c.deleted_at, + c.mobile_type, + c.user_agent, + c.corporate_name, + c.corporate_name_kana, + c.section_name, + c.section_name_kana, + c.contact_tel01, + c.contact_tel02, + c.contact_tel03, + c.address_building, + c.reachable, + c.mail_delivery_count, + c.created_at, + c.updated_at +EOS + else +<<-EOS +select +c.id, +c.login_id, +c.prefecture_id, +c.sex, +c.activate, +to_char(c.birthday, 'MM') as birth_month, +c.family_name || c.first_name as name_kanji, +c.family_name_kana || c.first_name_kana as name_kana, +c.birthday, +c.email, +c.tel01 || '-' || c.tel02 || '-' || c.tel03 as tel_no, +c.occupation_id, +coalesce(sum_total.total,0) as total, +coalesce(sum_order_count.order_count,0) as order_count, +c.updated_at, +last_order.last_order_at +EOS + end + end + + def self.get_sql_condition(condition) + <<-EOS +from +customers c + +left join (select +o.customer_id, +sum(coalesce(d.total,0)) as total +from +orders o, +order_deliveries d +where +o.id=d.order_id +group by +o.customer_id) sum_total on +c.id=sum_total.customer_id + +left join (select +o.customer_id, +count(o.customer_id) as order_count +from +orders o +group by +o.customer_id) sum_order_count on +c.id=sum_order_count.customer_id + +left join (select +o.customer_id, +max(received_at) as last_order_at +from +orders o +group by o.customer_id) last_order on +c.id=last_order.customer_id + +#{if !condition.product_name.blank? || !condition.product_code.blank? || !condition.category_id.blank? +",(select +o.customer_id +from +orders o, +order_deliveries d, +order_details t +where o.id=d.order_id +and d.id=t.order_delivery_id +#{if !condition.product_name.blank? + "and t.product_name like '%#{condition.product_name}%'" + end} +#{if !condition.product_code.blank? + "and t.product_code like '%#{condition.product_code}%'" + end} +#{if !condition.category_id.blank? + "and t.product_category_id =#{condition.category_id}" + end} +group by o.customer_id) product_info" +end} + +where +(c.deleted_at IS NULL OR c.deleted_at > '#{Time.now.gmtime.strftime("%Y-%m-%d %H:%M:%S")}') +#{if !condition.product_name.blank? || !condition.product_code.blank? || !condition.category_id.blank? + "and c.id=product_info.customer_id" + end} + +#{unless condition.customer_id.blank? + "and c.id = #{condition.customer_id}" + end} +#{unless condition.prefecture_id.blank? + "and c.prefecture_id = '#{condition.prefecture_id}'" + end} +#{unless condition.customer_name_kanji.blank? + "and (c.family_name || c.first_name) like '%#{condition.customer_name_kanji}%'" + end} +#{unless condition.customer_name_kana.blank? + "and (c.family_name_kana || c.first_name_kana) like '%#{condition.customer_name_kana}%'" + end} +#{if condition.sex_male == "1" && condition.sex_female == "0" + "and c.sex=1" + elsif condition.sex_male == "0" && condition.sex_female == "1" + "and c.sex=2" + end} +#{unless condition.birth_month.blank? + "and to_char(c.birthday,'MM')='#{sprintf("%02d",condition.birth_month)}'" + end} +#{ + from = condition.birthday_from + to = condition.birthday_to + unless from.blank? && to.blank? + if !from.blank? && !to.blank? + "and (to_char(c.birthday,'YYYYMMDD') >= '#{from.strftime("%Y%m%d")}' + and to_char(c.birthday,'YYYYMMDD') <= '#{to.strftime("%Y%m%d")}')" + elsif !from.blank? + "and to_char(c.birthday,'YYYYMMDD') >= '#{from.strftime("%Y%m%d")}'" + else + "and to_char(c.birthday,'YYYYMMDD') <= '#{to.strftime("%Y%m%d")}'" + end + end +} +#{unless condition.email.blank? + "and c.email like '%#{condition.email}%'" + end} +#{if condition.reachable == '1' + "and c.reachable = '1'" + end} +#{unless condition.tel_no.blank? + "and (c.tel01 || c.tel02 || c.tel03) like '%#{condition.tel_no}%'" + end} +#{unless condition.occupation_id.blank? + "and c.occupation_id in ('" << condition.occupation_id.join("','") << "')" + end} +#{ + from = condition.total_up + to = condition.total_down + unless from.blank? && to.blank? + if !from.blank? && !to.blank? + "and (total >= #{from} and total <= #{to})" + elsif !from.blank? + "and total >= #{from}" + else + "and total <= #{to}" + end + end +} +#{ + from = condition.order_count_up + to = condition.order_count_down + unless from.blank? && to.blank? + if !from.blank? && !to.blank? + "and (order_count >= #{from} and order_count <= #{to})" + elsif !from.blank? + "and order_count >= #{from}" + else + "and order_count <= #{to}" + end + end +} +#{ + from = condition.updated_at_from + to = condition.updated_at_to + unless from.blank? && to.blank? + if !from.blank? && !to.blank? + "and (to_char(c.updated_at,'YYYYMMDD') >= '#{from.strftime("%Y%m%d")}' + and to_char(c.updated_at,'YYYYMMDD') <= '#{to.strftime("%Y%m%d")}')" + elsif !from.blank? + "and to_char(c.updated_at,'YYYYMMDD') >= '#{from.strftime("%Y%m%d")}'" + else + "and to_char(c.updated_at,'YYYYMMDD') <= '#{to.strftime("%Y%m%d")}'" + end + end +} +#{ + from = condition.last_order_from + to = condition.last_order_from + unless from.blank? && to.blank? + if !from.blank? && !to.blank? + "and (to_char(last_order_at,'YYYYMMDD') >= '#{from.strftime("%Y%m%d")}' + and to_char(last_order_at,'YYYYMMDD') <= '#{to.strftime("%Y%m%d")}')" + elsif !from.blank? + "and to_char(last_order_at,'YYYYMMDD') >= '#{from.strftime("%Y%m%d")}'" + else + "and to_char(last_order_at,'YYYYMMDD') <= '#{to.strftime("%Y%m%d")}'" + end + end +} +order by c.id +EOS + end + +end diff --git a/app/models/delivery_address.rb b/app/models/delivery_address.rb new file mode 100644 index 0000000..a8ff6b3 --- /dev/null +++ b/app/models/delivery_address.rb @@ -0,0 +1,49 @@ +class DeliveryAddress < ActiveRecord::Base + + acts_as_paranoid + belongs_to :customer + belongs_to :prefecture + + attr_accessor :target_columns + + # 追加お届け先の最大所持件数 + MAXIMUM_POSITION = 20 + + validates_presence_of :family_name, :first_name, :family_name_kana, :first_name_kana, + :zipcode01, :zipcode02, :tel01, :tel02, :tel03, + :prefecture_id, :address_city, :address_detail + validates_numericality_of :zipcode01, :zipcode02, :prefecture_id, + :tel01, :tel02, :tel03, :allow_blank => true + validates_length_of :zipcode01, :is => 3, :allow_blank => true + validates_length_of :zipcode02, :is => 4, :allow_blank => true + validates_format_of :family_name_kana, :with => System::KATAKANA_PATTERN + validates_format_of :first_name_kana, :with => System::KATAKANA_PATTERN + + def validate + strip_errors + end + + def strip_errors + # 対象のカラム以外のエラーは無視する + return if target_columns.nil? + e = errors.select{|k,_|target_columns.include?(k)} + errors.clear + e.each do |k,v| + errors.add k, v + end + end + + # 郵便番号から住所を取ってくる + def update_address!(overwrite=true) + return if zipcode01.blank? or zipcode02.blank? + if overwrite || (prefecture_id.blank? && address_city.blank? && address_detail.blank?) + zip = Zip.find_by_zipcode(zipcode01, zipcode02) + if zip + self.prefecture_id = zip.prefecture_id + self.address_city = zip.address_city + self.address_detail = zip.address_details + end + end + end + +end diff --git a/app/models/delivery_date.rb b/app/models/delivery_date.rb new file mode 100644 index 0000000..943ae6a --- /dev/null +++ b/app/models/delivery_date.rb @@ -0,0 +1,5 @@ +class DeliveryDate < ActiveRecord::Base + + acts_as_paranoid + belongs_to :product +end diff --git a/app/models/delivery_fee.rb b/app/models/delivery_fee.rb new file mode 100644 index 0000000..48939ed --- /dev/null +++ b/app/models/delivery_fee.rb @@ -0,0 +1,18 @@ +class DeliveryFee < ActiveRecord::Base + + acts_as_paranoid + belongs_to :delivery_trader + belongs_to :prefecture + MAX_SIZE = 48 + + validates_presence_of :price + + def prefecture_name + if prefecture + prefecture.name + else + '離島' + end + end + +end diff --git a/app/models/delivery_ticket.rb b/app/models/delivery_ticket.rb new file mode 100644 index 0000000..575e7f2 --- /dev/null +++ b/app/models/delivery_ticket.rb @@ -0,0 +1,7 @@ +class DeliveryTicket < ActiveRecord::Base + + belongs_to :order_delivery + + validates_presence_of :order_delivery_id + validates_presence_of :code +end diff --git a/app/models/delivery_time.rb b/app/models/delivery_time.rb new file mode 100644 index 0000000..4ecb430 --- /dev/null +++ b/app/models/delivery_time.rb @@ -0,0 +1,8 @@ +class DeliveryTime < ActiveRecord::Base + + acts_as_paranoid + belongs_to :delivery_trader + has_many :orders + + MAX_SIZE = 16 +end diff --git a/app/models/delivery_trader.rb b/app/models/delivery_trader.rb new file mode 100644 index 0000000..1f0c64e --- /dev/null +++ b/app/models/delivery_trader.rb @@ -0,0 +1,30 @@ +class DeliveryTrader < ActiveRecord::Base + + acts_as_paranoid + acts_as_list + + has_many :delivery_times,:order=>"position", :dependent => :destroy + has_many :delivery_fees, :dependent => :destroy, :order => :prefecture_id + has_many :payments + has_many :orders + + validates_presence_of :name + + validates_length_of :name,:url, :maximum => 50 + + validates_format_of :url, :with=>%r{^(https?://.*|)$}, :message=>"が不正です" + + def validate_on_update + n = DeliveryTrader.find_by_name(name) + if n && n.id!=self.id + errors.add "","重複した名前は登録できません。" + end + end + + def validate_on_create + n = DeliveryTrader.find_by_name(name) + if n + errors.add "","重複した名前は登録できません。" + end + end +end diff --git a/app/models/design.rb b/app/models/design.rb new file mode 100644 index 0000000..a6cf667 --- /dev/null +++ b/app/models/design.rb @@ -0,0 +1,3 @@ +class Design < ActiveRecord::Base + acts_as_paranoid +end diff --git a/app/models/design_form.rb b/app/models/design_form.rb new file mode 100644 index 0000000..b3f882b --- /dev/null +++ b/app/models/design_form.rb @@ -0,0 +1,3 @@ +class DesignForm < SearchForm + +end diff --git a/app/models/feature.rb b/app/models/feature.rb new file mode 100644 index 0000000..64464a0 --- /dev/null +++ b/app/models/feature.rb @@ -0,0 +1,48 @@ +class Feature < ActiveRecord::Base + + acts_as_paranoid + + has_many :feature_products, :dependent => :destroy + has_many :products, :through => :feature_products + belongs_to :image_resource, + :class_name => "ImageResource", + :foreign_key => "image_resource_id" + validates_presence_of :name,:dir_name, + :message => 'を入力してください' + validates_presence_of :feature_type,:message => 'を選択してください' + validates_uniqueness_of :dir_name, :message=>'は、重複しています' + + validates_format_of :dir_name, :with=>/^[\x20-\x7e]*$/, :message=>'は半角英数字または記号で入力してください' + + FREE, PRODUCT = 1, 2 + TYPE_LIST = {FREE => "フリー", PRODUCT => "商品一覧"} + + PERMIT_LABEL = {"公開" => true, "非公開" => false } + + def self.permit_select + PERMIT_LABEL.collect{|key, value| [key, value]} + end + + def permit_label + unless @permit_labels + @permit_labels = Hash.new + PERMIT_LABEL.each { |key, value| @permit_labels[value] = key } + end + @permit_labels[self.permit] + end + + alias :image_resource_old= :image_resource= + [:image_resource].each do | method_name| + define_method("#{method_name}=") do | value | + if value.class == ActionController::UploadedStringIO || value.class == ActionController::UploadedTempfile || value.class == Tempfile + image_resource = ImageResource.new_file(value, value.original_filename) + self.send "#{method_name}_old=".intern, image_resource + elsif value.class == ImageResource + self.send "#{method_name}_old=".intern, value + else + nil + end + end + end + +end diff --git a/app/models/feature_product.rb b/app/models/feature_product.rb new file mode 100644 index 0000000..4605fd0 --- /dev/null +++ b/app/models/feature_product.rb @@ -0,0 +1,40 @@ +class FeatureProduct < ActiveRecord::Base + acts_as_paranoid + + belongs_to :feature + belongs_to :product + belongs_to :image_resource, + :class_name => "ImageResource", + :foreign_key => "image_resource_id" + + validates_presence_of :product_id,:feature_id, + :message => "を選択してください" + + #前処理 + before_create :position_up + + #画像アップロード + alias :image_resource_old= :image_resource= + [:image_resource].each do | method_name| + define_method("#{method_name}=") do | value | + if value.class == ActionController::UploadedStringIO || value.class == ActionController::UploadedTempfile || value.class == Tempfile + image_resource = ImageResource.new_file(value, value.original_filename) + self.send "#{method_name}_old=".intern, image_resource + elsif value.class == ImageResource + self.send "#{method_name}_old=".intern, value + else + nil + end + end + end + + protected + + def position_up + if FeatureProduct.maximum(:position) != nil + self.position = FeatureProduct.maximum(:position) + 1 + else + self.position = 1 + end + end +end diff --git a/app/models/function.rb b/app/models/function.rb new file mode 100644 index 0000000..8050130 --- /dev/null +++ b/app/models/function.rb @@ -0,0 +1,3 @@ +class Function < ActiveRecord::Base + has_and_belongs_to_many :authorities +end diff --git a/app/models/image_resource.rb b/app/models/image_resource.rb new file mode 100644 index 0000000..81da753 --- /dev/null +++ b/app/models/image_resource.rb @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +require 'RMagick' +class ImageResource < ActiveRecord::Base + acts_as_paranoid + + has_many :resrouce_datas + + def view(width = nil, hight = nil) + resource_data = ResourceData.find_by_resource_id(self.id) + resource_data.content + end + + def content_data + resource_data = ResourceData.find_by_resource_id(self.id) + resource_data.content + end + + def self.new_file(file, file_name) + resource = ImageResource.new + resource.name = file_name + resource.content_type = file.content_type + resource.save + ResourceData.create(:resource_id => resource.id, :content => file.read) + resource + end + + def scaled_image(width, height) + image = read_image(content_data) + image.change_geometry("#{width}x#{height}") do |cols,rows,img| + rows = 1 if rows == 0 + cols = 1 if cols == 0 + if cols <= 64 && rows <= 64 + # 画像が小さいときはこっちのほうが速いらしい + img.thumbnail!(cols, rows) + else + img.resize!(cols, rows) + end + end + data = image_data(image) + run_gc + data + end + + def read_image(data) + temp_filename do |filename| + File.open(filename, "w+b") do |file| + file.write(data) + end + Magick::Image.read(filename)[0] + end + end + + def temp_filename(&block) + filename = File.join('/tmp', "user_photo_tmp.#{$$}") + begin + yield filename + ensure + File.delete filename if File.exist?(filename) + end + end + + def image_data(image) + temp_filename do |filename| + image.write(filename) + File.open(filename, "rb") do |file| + file.read + end + end + end + + def run_gc + fDisabled = GC.enable + GC.start + GC.disable if fDisabled + end + +end diff --git a/app/models/inquiry.rb b/app/models/inquiry.rb new file mode 100644 index 0000000..475b5cf --- /dev/null +++ b/app/models/inquiry.rb @@ -0,0 +1,54 @@ +class Inquiry < ActiveRecord::Base + + acts_as_paranoid + TABLE_NAME_JP = "お問い合わせ" + + attr_accessor :email_user, :email_domain + + validates_presence_of :email + validates_presence_of :body + validates_presence_of :kind + validates_presence_of :name + + #validates_format_of :email, :with => /^(([^@\s]+)@((?:[-a-z0-9]+\.)*[a-z]{2,})|)$/i + validates_format_of :tel, :with => /^[0-9()-]*$/, :allow_nil => true, :message => "の書式が不正です" + + def validate + # メールアドレスRFC準拠チェック + if email && email =~ Customer::EMAIL_PATTERN + m = TMail::Mail.new + m.from = email + if m.from.nil? + errors.add :email, '(%s)は当サイトではご利用になれません。' % email + end + end + end + + GOODS, ORDER, CLAIM, SEND, CAMPAIGN, RISAGASU, SITE, OTHER = 1, 2, 3, 4, 5, 6, 7, 8 + KIND_NAMES = {GOODS=>"商品について", ORDER=>"注文について", CLAIM=>"ご請求について", + SEND=>"発送について", CAMPAIGN=>"キャンペーンについて", RISAGASU=>"K&Bスタイルについて", + SITE=>"サイトについて", OTHER=>"その他"} + + def show_kind_name + KIND_NAMES[self.kind] + end + + def self.pc_kind_list + [[KIND_NAMES[GOODS], GOODS], + [KIND_NAMES[CLAIM], CLAIM], + [KIND_NAMES[SEND], SEND], + [KIND_NAMES[CAMPAIGN], CAMPAIGN], + [KIND_NAMES[RISAGASU], RISAGASU], + [KIND_NAMES[SITE], SITE], + [KIND_NAMES[OTHER], OTHER]] + end + + def self.mobile_kind_list + [[KIND_NAMES[GOODS], GOODS], + [KIND_NAMES[ORDER], ORDER], + [KIND_NAMES[CLAIM], CLAIM], + [KIND_NAMES[SEND], SEND], + [KIND_NAMES[CAMPAIGN], CAMPAIGN], + [KIND_NAMES[OTHER], OTHER]] + end +end diff --git a/app/models/kiyaku.rb b/app/models/kiyaku.rb new file mode 100644 index 0000000..1c2ff9f --- /dev/null +++ b/app/models/kiyaku.rb @@ -0,0 +1,9 @@ +class Kiyaku < ActiveRecord::Base + + acts_as_paranoid + acts_as_list + + validates_presence_of :name,:content + validates_length_of :name, :maximum => 250, :allow_blank => true + validates_length_of :content, :maximum => 2000, :allow_blank => true +end diff --git a/app/models/law.rb b/app/models/law.rb new file mode 100644 index 0000000..7c2400a --- /dev/null +++ b/app/models/law.rb @@ -0,0 +1,47 @@ +class Law < ActiveRecord::Base + + acts_as_paranoid + + belongs_to :prefecture + + validates_presence_of :company,:manager,:zipcode01, :zipcode02, + :prefecture_id,:address_city,:address_detail, + :tel01,:tel02,:tel03,:email,:url, + :necessary_charge,:order_method,:payment_method,:payment_time_limit,:delivery_time,:return_exchange + + validates_length_of :company,:manager,:address_city,:address_detail,:email,:url, :maximum => 50 + + validates_length_of :tel01,:tel02,:tel03,:fax01,:fax02,:fax03 , :maximum => 4 + + validates_numericality_of :zipcode01, :zipcode02,:tel01,:tel02,:tel03,:fax01,:fax02,:fax03, :allow_blank => true + + validates_length_of :zipcode01, :is => 3 + validates_length_of :zipcode02, :is => 4 + + validates_inclusion_of :prefecture_id, :in => 1..47,:message => "を選択してください" + + validates_length_of :necessary_charge,:order_method,:payment_method,:payment_time_limit,:delivery_time,:return_exchange , :maximum => 200 + + validates_format_of :url, :with=>%r{^(https?://.*|)$}, :message=>"が不正です" + + def validate_on_create + errors.add "","複数のデータは登録できません。" if Law.count > 0 + end + + # 表示系のメソッド + def zipcode + "#{zipcode01}-#{zipcode02}" + end + + def address + prefecture.name + address_city + address_detail + end + + def tel + "#{tel01}-#{tel02}-#{tel03}" + end + + def fax + "#{fax01}-#{fax02}-#{fax03}" + end +end diff --git a/app/models/mail.rb b/app/models/mail.rb new file mode 100644 index 0000000..f9bac8f --- /dev/null +++ b/app/models/mail.rb @@ -0,0 +1,2 @@ +class Mail < ActiveRecord::Base +end diff --git a/app/models/mail_magazine.rb b/app/models/mail_magazine.rb new file mode 100644 index 0000000..50d913b --- /dev/null +++ b/app/models/mail_magazine.rb @@ -0,0 +1,214 @@ +class MailMagazine < ActiveRecord::Base + acts_as_paranoid + + def self.get_sql_select +<<-EOS +select +c.id, +c.login_id, +c.prefecture_id, +c.sex, +c.receive_mailmagazine, +to_char(c.birthday, 'MM') as birth_month, +c.family_name || c.first_name as name_kanji, +c.family_name_kana || c.first_name_kana as name_kana, +c.birthday, +c.email, +c.occupation_id, +coalesce(sum_total.total,0) as total, +coalesce(sum_order_count.order_count,0) as order_count, +c.created_at, +c.updated_at, +last_order.last_order_at, +last_order.last_order_code +EOS + end + + def self.get_sql_condition(condition, except_list = []) + <<-EOS +from +customers c + +left join (select +o.customer_id, +sum(coalesce(d.total,0)) as total +from +orders o, +order_deliveries d +where +o.id=d.order_id +group by +o.customer_id) sum_total on +c.id=sum_total.customer_id + +left join (select +o.customer_id, +count(o.customer_id) as order_count +from +orders o +group by +o.customer_id) sum_order_count on +c.id=sum_order_count.customer_id + +left join (select +o.customer_id, +max(received_at) as last_order_at, +max(code) as last_order_code +from +orders o +group by o.customer_id) last_order on +c.id=last_order.customer_id + +#{unless condition.campaign_id.blank? +"left join (select customer_id +from campaigns_customers +where campaign_id=#{condition.campaign_id} +group by customer_id) cc" +end} + +#{if !condition.product_name.blank? || !condition.product_code.blank? || !condition.category_id.blank? +",(select +o.customer_id +from +orders o, +order_deliveries d, +order_details t +where o.id=d.order_id +and d.id=t.order_delivery_id +#{if !condition.product_name.blank? + "and t.product_name like '%#{condition.product_name}%'" + end} +#{if !condition.product_code.blank? + "and t.product_code like '%#{condition.product_code}%'" + end} +#{if !condition.category_id.blank? + "and t.product_category_id =#{condition.category_id}" + end} +group by o.customer_id) product_info" +end} + +where +(c.deleted_at IS NULL OR c.deleted_at > '#{Time.now.gmtime.strftime("%Y-%m-%d %H:%M:%S")}') +and c.activate = 2 +#{unless except_list.blank? + "and c.id not in (#{except_list.join(",")})" + end} +#{if condition.form_type == "0" + "and c.receive_mailmagazine <> #{Customer::NO_MAIL}" + else + "and c.receive_mailmagazine = #{condition.form_type}" + end} +#{if condition.mail_type == "0" + "and c.mobile_carrier = #{Customer::NOT_MOBILE}" + else + "and c.mobile_carrier <> #{Customer::NOT_MOBILE}" + end} +#{if !condition.product_name.blank? || !condition.product_code.blank? || !condition.category_id.blank? + "and c.id=product_info.customer_id" + end} + +#{unless condition.customer_id.blank? + "and c.id = #{condition.customer_id}" + end} +#{unless condition.prefecture_id.blank? + "and c.prefecture_id = '#{condition.prefecture_id}'" + end} +#{unless condition.customer_name_kanji.blank? + "and (c.family_name || c.first_name) like '%#{condition.customer_name_kanji}%'" + end} +#{unless condition.customer_name_kana.blank? + "and (c.family_name_kana || c.first_name_kana) like '%#{condition.customer_name_kana}%'" + end} +#{if condition.sex_male == "1" && condition.sex_female == "0" + "and c.sex=1" + elsif condition.sex_male == "0" && condition.sex_female == "1" + "and c.sex=2" + end} +#{unless condition.birth_month.blank? + "and to_char(c.birthday,'MM')='#{sprintf("%02d",condition.birth_month)}'" + end} +#{ + from = condition.birthday_from + to = condition.birthday_to + unless from.blank? && to.blank? + if !from.blank? && !to.blank? + "and (to_char(c.birthday,'YYYYMMDD') >= '#{from.strftime("%Y%m%d")}' + and to_char(c.birthday,'YYYYMMDD') <= '#{to.strftime("%Y%m%d")}')" + elsif !from.blank? + "and to_char(c.birthday,'YYYYMMDD') >= '#{from.strftime("%Y%m%d")}'" + else + "and to_char(c.birthday,'YYYYMMDD') <= '#{to.strftime("%Y%m%d")}'" + end + end +} +#{unless condition.email.blank? + "and c.email like '%#{condition.email}%'" + end} +#{unless condition.tel_no.blank? + "and (c.tel01 || c.tel02 || c.tel03) like '%#{condition.tel_no}%'" + end} +#{unless condition.occupation_id.blank? + "and c.occupation_id in ('" << condition.occupation_id.join("','") << "')" + end} +#{ + from = condition.total_up + to = condition.total_down + unless from.blank? && to.blank? + if !from.blank? && !to.blank? + "and (total >= #{from} and total <= #{to})" + elsif !from.blank? + "and total >= #{from}" + else + "and total <= #{to}" + end + end +} +#{ + from = condition.order_count_up + to = condition.order_count_down + unless from.blank? && to.blank? + if !from.blank? && !to.blank? + "and (order_count >= #{from} and order_count <= #{to})" + elsif !from.blank? + "and order_count >= #{from}" + else + "and order_count <= #{to}" + end + end +} +#{ + from = condition.updated_at_from + to = condition.updated_at_to + unless from.blank? && to.blank? + if !from.blank? && !to.blank? + "and (to_char(c.updated_at,'YYYYMMDD') >= '#{from.strftime("%Y%m%d")}' + and to_char(c.updated_at,'YYYYMMDD') <= '#{to.strftime("%Y%m%d")}')" + elsif !from.blank? + "and to_char(c.updated_at,'YYYYMMDD') >= '#{from.strftime("%Y%m%d")}'" + else + "and to_char(c.updated_at,'YYYYMMDD') <= '#{to.strftime("%Y%m%d")}'" + end + end +} +#{ + from = condition.last_order_from + to = condition.last_order_from + unless from.blank? && to.blank? + if !from.blank? && !to.blank? + "and (to_char(last_order_at,'YYYYMMDD') >= '#{from.strftime("%Y%m%d")}' + and to_char(last_order_at,'YYYYMMDD') <= '#{to.strftime("%Y%m%d")}')" + elsif !from.blank? + "and to_char(last_order_at,'YYYYMMDD') >= '#{from.strftime("%Y%m%d")}'" + else + "and to_char(last_order_at,'YYYYMMDD') <= '#{to.strftime("%Y%m%d")}'" + end + end +} +#{unless condition.campaign_id.blank? + "and c.id=cc.customer_id" +end} +order by c.id +EOS + end + +end diff --git a/app/models/mail_magazine_contents_form.rb b/app/models/mail_magazine_contents_form.rb new file mode 100644 index 0000000..394240f --- /dev/null +++ b/app/models/mail_magazine_contents_form.rb @@ -0,0 +1,9 @@ +class MailMagazineContentsForm < SearchForm + set_field_names :subject => '件名' + set_field_names :body => '本文' + + validates_presence_of :subject + validates_presence_of :body + validates_length_of :subject, :maximum => 256 + validates_length_of :body, :maximum => 5120 +end diff --git a/app/models/mail_magazine_search_form.rb b/app/models/mail_magazine_search_form.rb new file mode 100644 index 0000000..3675415 --- /dev/null +++ b/app/models/mail_magazine_search_form.rb @@ -0,0 +1,11 @@ +# 顧客管理で検索条件を格納するフォーム +class MailMagazineSearchForm < SearchForm + validates_numericality_of :customer_id, :only_integer => true, :allow_blank => true, :message => 'は半角数字のみを入力してください。' + validates_format_of :customer_name_kana, :with => System::KATAKANA_PATTERN, :allow_blank => true, :message => 'は全角カタカナを入力してください。' + validates_format_of :email, :with => /[\x1-\x7f]/, :allow_blank => true, :message => 'は半角英数字のみを入力してください。' + validates_numericality_of :tel_no, :only_integer => true, :allow_blank => true, :message => 'は半角数字のみを入力してください。' + validates_numericality_of :total_from, :only_integer => true, :allow_blank => true, :message => 'は半角数字のみを入力してください。' + validates_numericality_of :total_to, :only_integer => true, :allow_blank => true, :message => 'は半角数字のみを入力してください。' + validates_numericality_of :order_count_from, :only_integer => true, :allow_blank => true, :message => 'は半角数字のみを入力してください。' + validates_numericality_of :order_count_to, :only_integer => true, :allow_blank => true, :message => 'は半角数字のみを入力してください。' +end diff --git a/app/models/mail_magazine_template.rb b/app/models/mail_magazine_template.rb new file mode 100644 index 0000000..31cdf62 --- /dev/null +++ b/app/models/mail_magazine_template.rb @@ -0,0 +1,15 @@ +class MailMagazineTemplate < ActiveRecord::Base + + acts_as_paranoid + + TEXT, HTML = 1, 2 + FORM_TYPE_NAMES = {TEXT=>"テキスト", HTML=>"HTML"} + + validates_presence_of :form + validates_presence_of :subject + validates_presence_of :body + + def get_form_name + FORM_TYPE_NAMES[self.form] + end +end diff --git a/app/models/mail_template.rb b/app/models/mail_template.rb new file mode 100644 index 0000000..15c221f --- /dev/null +++ b/app/models/mail_template.rb @@ -0,0 +1,8 @@ +class MailTemplate < ActiveRecord::Base + + acts_as_paranoid + + validates_presence_of :name,:title + + validates_length_of :header,:footer, :maximum => 3000, :allow_blank => true +end diff --git a/app/models/mobile_carrier.rb b/app/models/mobile_carrier.rb new file mode 100644 index 0000000..a7fa1f0 --- /dev/null +++ b/app/models/mobile_carrier.rb @@ -0,0 +1,3 @@ +class MobileCarrier < ActiveRecord::Base + has_many :mobile_devices +end diff --git a/app/models/mobile_device.rb b/app/models/mobile_device.rb new file mode 100644 index 0000000..7d3802f --- /dev/null +++ b/app/models/mobile_device.rb @@ -0,0 +1,48 @@ +class MobileDevice < ActiveRecord::Base + acts_as_paranoid + + validates_presence_of :mobile_carrier_id, :device_name, :user_agent + validates_presence_of :width, :height + validates_format_of :user_agent, :with => /^[ .\-\:;\/%0-9A-Za-z]+$/ + def validate + check_uniqueness_of_device_name + end + + def check_uniqueness_of_device_name + conds = [] + if self.device_name + conds << ['device_name = ?', self.device_name] + else + conds << ['device_name is null'] + end + if self.id + conds << ['id <> ?', self.id] + end + if self.class.count(:conditions=>flatten_conditions(conds)) != 0 + errors.add :device_name, 'はすでに存在します' + return false + end + true + end + + belongs_to :mobile_carrier + + def before_save + self.user_agent = self.user_agent + '%' + end + + def remove_precent + self.user_agent = self.user_agent.gsub(/%/, '') + end + + # 画面サイズ表示 + def human_size + if width == 480 && height == 640 + 'VGA' + elsif width == 240 && height == 320 + 'QVGA' + else + '%d x %d' % [width, height] + end + end +end diff --git a/app/models/mobile_html_notifier.rb b/app/models/mobile_html_notifier.rb new file mode 100644 index 0000000..b4b1b22 --- /dev/null +++ b/app/models/mobile_html_notifier.rb @@ -0,0 +1,85 @@ +class MobileHtmlNotifier < ActiveRecord::Base + + def self.create_html_mailmagazine(customer, mail_body, mail_subject, sent_at = Time.now) + get_shop + @subject = "=?iso-2022-jp?B?#{[NKF.nkf('-j -m0', mail_subject)].pack('m').delete("\r\n")}?=" + @to = customer.email + @from = "=?iso-2022-jp?B?#{[NKF.nkf('-j -m0', @shop.name)].pack('m').delete("\r\n")}?= <#{@shop.mail_sender}>" + @body = mail_body.gsub("{name}", customer.full_name) + + @body = html_unescape(@body) + html_text = br_to_div(@body) + html_body = "#{html_text}" + text_body = ActionView::Base.full_sanitizer.sanitize(br_to_linefeedcode(@body)) + + # ヘッダーを作成 + @dm = MbMail::DMail.new + @dm.from_addrs = [TMail::Address.parse(@shop.mail_sender)] + @dm.from = @from + @dm.to = @to + @dm.subject = @subject + @dm.body = '' + @dm.content_type = 'multipart/mixed' + + @text_part = MbMail::DMail.new + @text_part.transfer_encoding = 'Base64' + @text_part.content_type = 'text/plain; charset="UTF-8"' + @text_part.body = Base64.encode64(Jpmobile::Emoticon.utf8_to_unicodecr(text_body)) + + @html_part = MbMail::DMail.new + @html_part.transfer_encoding = 'Base64' + @html_part.content_type = 'text/html; charset="UTF-8"' + @html_part.body = Base64.encode64(Jpmobile::Emoticon.utf8_to_unicodecr(html_body)) + + @alt_part = MbMail::DMail.new + @alt_part.body = '' + @alt_part.content_type = 'multipart/alternative' + @alt_part.parts << @text_part + @alt_part.parts << @html_part + + @rel_part = MbMail::DMail.new + @rel_part.body = '' + @rel_part.content_type = 'multipart/related' + @rel_part.parts << @alt_part + + @dm.parts << @rel_part + + if @to.to_s =~ /docomo.ne.jp/ + @dm = @dm.to_docomo_format + elsif @to.to_s =~ /ezweb.ne.jp/ + @dm = @dm.to_au_format + elsif @to.to_s =~ /softbank.ne.jp/ || @to.to_s =~ /vodafone.ne.jp/ || @to.to_s =~ /softbank.jp/ + @dm = @dm.to_softbank_format + end + return @dm + end + + private + def self.get_shop + @shop = Shop.find(:first) + end + + def self.html_unescape(s) + s.to_s.gsub(/&/, "&").gsub(/"/, "\"").gsub(/>/, ">").gsub(/</, "<") + end + + def self.br_to_div(str) + str = br_to_linefeedcode(str) + result = "" + str.split("\n").each do |spstr| + result += "
    #{spstr}
    " + end + result + end + + def self.br_to_linefeedcode(str) + return str.gsub(/<[^<>]*>/) do |match| + if match =~ /br|BR/ + "\n" + else + match + end + end + end + +end diff --git a/app/models/new_information.rb b/app/models/new_information.rb new file mode 100644 index 0000000..3e73e14 --- /dev/null +++ b/app/models/new_information.rb @@ -0,0 +1,14 @@ +class NewInformation < ActiveRecord::Base + + acts_as_paranoid + acts_as_list + + validates_presence_of :date + validates_presence_of :name + + validates_length_of :name, :maximum=>200, :to_long=>"は最大%d文字です" + validates_length_of :body, :maximum=>300, :to_long=>"は最大%d文字です" + + validates_format_of :url, :with=>%r{^(https?://\S*|)$}, :message=>"が不正です" + +end diff --git a/app/models/notifier.rb b/app/models/notifier.rb new file mode 100644 index 0000000..1627239 --- /dev/null +++ b/app/models/notifier.rb @@ -0,0 +1,205 @@ +#require 'gettext/rails' +GetText.locale = 'ja' + +class Notifier < ActionMailer::Base +@@charset='iso-2022-jp' + + def pc_inquiry(inquiry, sent_at = Time.now) + get_shop + mail_template = MailTemplate.find_by_name "問い合わせ確認メール" + @subject = Kconv.tojis(mail_template.title ) + @recipients = inquiry.email + @from = '"%s" <%s>' % [@shop.name, @shop.mail_sender] + @from = Kconv.tojis(@from) + @sent_on = sent_at + @headers = {} + @body = body :inquiry => inquiry, :mail_template => mail_template + end + + def mobile_inquiry(inquiry, sent_at = Time.now) + get_shop + mail_template = MailTemplate.find_by_name "問い合わせ確認メール" + @subject = Kconv.tojis(mail_template.title ) + @recipients = inquiry.email + @from = '"%s" <%s>' % [@shop.name, @shop.mail_sender] + @from = Kconv.tojis(@from) + @sent_on = sent_at + @headers = {} + @body = body :inquiry => inquiry, :mail_template => mail_template + end + + def received_inquiry(inquiry, is_mobile, sent_at = Time.now) + get_shop + @subject = Kconv.tojis("No:#{inquiry.id} お問い合わせがありました") + @recipients = @shop.mail_faq + @from = '"%s" <%s>' % [inquiry.name, inquiry.email] + @from = Kconv.tojis(@from) + @sent_on = sent_at + @headers = {} + @body = body(:inquiry => inquiry, :shop => @shop) + end + + def reminder(customer, password, sent_at = Time.now) + get_shop + mail_template = MailTemplate.find_by_name "パスワード再発行メール" + @subject = Kconv.tojis(mail_template.title ) + @recipients = customer.email + @from = '"%s" <%s>' % [@shop.name, @shop.mail_sender] + @from = Kconv.tojis(@from) + @sent_on = sent_at + @headers = {'Content-Transfer-Encoding' => '7bit'} + @body = body :customer => customer, :password => password, :shop => @shop, :mail_template => mail_template + end + + def mobile_reminder(customer, password, sent_at = Time.now) + get_shop + mail_template = MailTemplate.find_by_name "パスワード再発行メール" + @subject = Kconv.tojis(mail_template.title ) + @recipients = customer.email + @from = '"%s" <%s>' % [@shop.name, @shop.mail_sender] + @from = Kconv.tojis(@from) + @sent_on = sent_at + @headers = {'Content-Transfer-Encoding' => '7bit'} + @body = body :customer => customer, :password => password, :shop => @shop, :mail_template => mail_template + end + + def activate(customer, url, sent_at = Time.now) + get_shop + mail_template = MailTemplate.find_by_name "会員登録受付メール" + if customer.mobile_carrier != Customer::NOT_MOBILE + @template += '_mobile' + end + + @subject = Kconv.tojis(mail_template.title ) + @recipients = customer.email + @from = '"%s" <%s>' % [@shop.name, @shop.mail_sender] + @from = Kconv.tojis(@from) + @sent_on = sent_at + @headers = {'Content-Transfer-Encoding' => '7bit'} + @body = body :customer => customer, :url => url, :shop => @shop, :mail_template => mail_template + end + + def text_mailmagazine(customer, mail_body, mail_subject, sent_at = Time.now) + get_shop + @subject = Kconv.tojis(mail_subject) + @recipients = customer.email + @from = '"%s" <%s>' % [@shop.name, @shop.mail_sender] + @from = Kconv.tojis(@from) + @sent_on = sent_at + @headers = {'Content-Transfer-Encoding' => '7bit'} + @body = body :mail_body => mail_body.gsub(/\{name\}/, customer.full_name) + end + + def html_mailmagazine(customer, mail_body, mail_subject, sent_at = Time.now) + get_shop + @subject = Kconv.tojis(mail_subject) + @recipients = customer.email + @from = '"%s" <%s>' % [@shop.name, @shop.mail_sender] + @from = Kconv.tojis(@from) + @sent_on = sent_at + @headers = {'Content-Transfer-Encoding' => '7bit'} + @body = body :mail_body => mail_body.gsub("{name}", customer.full_name) + @content_type = "text/html" + end + + def buying_complete(order) + get_shop + order = order + order_delivery = order.order_deliveries[0] + order_details = order_delivery.order_details + + if order.customer && order.customer.mobile_carrier != Customer::NOT_MOBILE + @template += '_mobile' + end + + mail_template = MailTemplate.find_by_name "注文受付メール" + @subject = Kconv.tojis(mail_template.title ) + @recipients = order_delivery.email + @from = '"%s" <%s>' % [@shop.name, @shop.mail_sender] + @from = Kconv.tojis(@from) + @sent_on = Time.now + @body = body(:order=>order, :order_delivery=>order_delivery, :order_details=>order_details, :shop=>@shop, :mail_template => mail_template) + end + + private + + def get_shop + @shop = Shop.find(:first) + end + + # 本文 (body) を iso-2022-jp へ変換 + def create!(*) + super + @mobile_filter = nil + @docomo_or_au = nil + docomo_charset = "Shift_JIS" + au_charset = "'iso-2022-jp'" + softbank_charset = "UTF-8" + use_charset = nil + dummy_controller = DummyController.new + logger.debug "MAILTO------" + logger.debug @mail.to + if @mail.to.to_s =~ /docomo.ne.jp/ + dummy_controller.request.mobile = Jpmobile::Mobile::Docomo.new(dummy_controller.request) + @mobile_filter = true + @docomo_or_au = true + use_charset = docomo_charset + logger.debug "DOCOMO------" + elsif @mail.to.to_s =~ /ezweb.ne.jp/ + dummy_controller.request.mobile = Jpmobile::Mobile::Au.new(dummy_controller.request) + @mobile_filter = true + @docomo_or_au = true + use_charset = au_charset + logger.debug "EZWEB------" + elsif @mail.to.to_s =~ /softbank.ne.jp/ || @mail.to.to_s =~ /vodafone.ne.jp/ || @mail.to.to_s =~ /softbank.jp/ + dummy_controller.request.mobile = Jpmobile::Mobile::Softbank.new(dummy_controller.request) + @mobile_filter = true + use_charset = softbank_charset + logger.debug "SOFTBANK------" + end + + # セッション ID を削る + @mail.body = @mail.body.gsub(/([?&])_ec_session=[a-zA-Z0-9_]+(&?)/) do |m| + $2.empty? ? '' : $1 + end + + if @mobile_filter + use_webcode = false + mail_title = @docomo_or_au ? NKF.nkf("-xWs", @mail.subject) : @mail.subject + mail_title = Jpmobile::Filter::Emoticon::Outer.new.to_external(mail_title, dummy_controller, use_webcode) + @mail.subject = @docomo_or_au ? mail_title : (mail_title) + @mail.body = @docomo_or_au ? NKF.nkf("-xWs", @mail.body) : @mail.body + @mail.body = Jpmobile::Filter::Emoticon::Outer.new.to_external(@mail.body, dummy_controller, use_webcode) + @mail.body = @docomo_or_au ? @mail.body : Base64.b64encode(@mail.body) + if @mail.content_type =~ /.*text\/html.*/ + @mail.set_content_type "text/html; charset=#{use_charset}" + else + @mail.set_content_type "text/plain; charset=#{use_charset}" + end + + @mail.transfer_encoding = "base64" unless @docomo_or_au + else + if @mail.content_type =~ /.*text\/html.*/ + @mail.set_content_type "text/html; charset=iso-2022-jp" + else + @mail.set_content_type "text/plain; charset=iso-2022-jp" + end + @mail.body.gsub(/~/, '〜') # U+55FE(FULLWIDTH TILDE) -> U+301C(WAVE DASH) + @mail.subject = NKF.nkf('-j', @mail.subject) + @mail.body = NKF.nkf('-j', @mail.body) + end + @mail + end + + + class DummyController + attr_accessor :request + def initialize + self.request = DummyRequest.new + end + + class DummyRequest + attr_accessor :mobile + end + end +end diff --git a/app/models/occupation.rb b/app/models/occupation.rb new file mode 100644 index 0000000..9c53041 --- /dev/null +++ b/app/models/occupation.rb @@ -0,0 +1,5 @@ +class Occupation < ActiveRecord::Base + + acts_as_paranoid + has_many :occupations +end diff --git a/app/models/order.rb b/app/models/order.rb new file mode 100644 index 0000000..fd29aac --- /dev/null +++ b/app/models/order.rb @@ -0,0 +1,147 @@ +# -*- coding: utf-8 -*- +class Order < ActiveRecord::Base + acts_as_paranoid + belongs_to :customer + has_many :order_deliveries + + def subtotal + sum_deliveries :subtotal + end + + def total + sum_deliveries :total + end + + def payment_total + sum_deliveries :payment_total + end + + def proceeds + sum_deliveries :proceeds + end + + def self.find_sum conditions='' + OrderDelivery.find_sum conditions + end + + def after_create + generate_code + end + + def self.get_conditions(search, params) + search_list = [] + search && search.each do |k, v| + if (k =~ /^order_code/) + search[k.sub(pattern, 'orders.code')] = v + end + end + sex = params[:sex] || [] + payment_id = params[:payment_id] || [] + + if search + unless search.customer_name.blank? + search_list << ["order_deliveries.family_name || order_deliveries.first_name like ?", "%#{search.customer_name}%"] + end + unless search.customer_name_kana.blank? + search_list << ["order_deliveries.family_name_kana || order_deliveries.first_name_kana like ?", "%#{search.customer_name_kana}%"] + end + unless search.order_code_from.blank? + search_list << ["orders.code >= ?", search.order_code_from] + end + unless search.order_code_to.blank? + search_list << ["orders.code <= ?", search.order_code_to ] + end + unless search.status.blank? + search_list << ["order_deliveries.status = ? ", search.status.to_i] + end + unless search.email.blank? + search_list << ["order_deliveries.email like ?", "%#{search.email}%"] + end + unless search.tel.blank? + search_list << ["order_deliveries.tel01 || order_deliveries.tel02 || order_deliveries.tel03 like ?", "%#{search.tel}%"] + end + unless search.search_birth_from.blank? + search_list << ["order_deliveries.birthday >= ?", search.search_birth_from] + end + + unless search.search_birth_to.blank? + search_list << ["order_deliveries.birthday < ?", search.search_birth_to + 1 * 60 * 60 * 24 ] + end + unless search.search_updated_at_from.blank? + search_list << ["order_deliveries.created_at >= ?", search.search_updated_at_from] + end + unless search.search_updated_at_to.blank? + search_list << ["order_deliveries.created_at < ?", search.search_updated_at_to + 1 * 60 * 60 * 24 ] + end + unless search.search_updated_at_from.blank? + search_list << ["order_deliveries.updated_at >= ?", search.search_updated_at_from] + end + unless search.search_updated_at_to.blank? + search_list << ["order_deliveries.updated_at < ?", search.search_updated_at_to + 1 * 60 * 60 * 24 ] + end + unless search.total_from.blank? + if search.total_from =~ /^\d*$/ + search_list << ["order_deliveries.total >= ?", search.total_from] + else + search.errors.add nil, "購入金額は数字で入力してください。" + end + end + unless search.total_to.blank? + if search.total_to =~ /^\d*$/ + search_list << ["order_deliveries.total <= ?", search.total_to] + else + search.errors.add nil, "購入金額は数字で入力してください。" + end + end + unless search.product_code.blank? + search_list << ["order_details.product_code like ? ", "%#{search.product_code}%"] + end + unless search.shipped_at_from.blank? + search_list << ["order_deliveries.shipped_at >= ?", search.shipped_at_from] + end + unless search.shipped_at_to.blank? + search_list << ["order_deliveries.shipped_at < ?", search.shipped_at_to + 1 * 60 * 60 * 24 ] + end + end + search_list << ['order_deliveries.sex in (?)', sex] unless sex.empty? + search_list << ['order_deliveries.payment_id in (?)', payment_id] unless payment_id.empty? + + [search, search_list, sex, payment_id] + end + + def self.csv(search_list) + columns = OrderDelivery.csv_columns_name + order_deliveries = OrderDelivery.find(:all, + :conditions => flatten_conditions(search_list), + :include => OrderDelivery::DEFAULT_INCLUDE, + :order => "order_deliveries.id desc") + f = StringIO.new('', 'w') + CSV::Writer.generate(f) do | writer | + writer<< columns.map{|name| OrderDelivery.set_field_names[name]} + order_deliveries and order_deliveries.each do | od | + writer << columns.map do | column | + if ![:order_code,:prefecture_name,:occupation_name,:sex_name,:payment_name,:deliv_pref_name,:delivery_trader_name,:delivery_time_name,:status_view,:ticket_code].include?(column) && OrderDelivery.columns_hash[column.to_s].type == :datetime + (od[column] + (60*60*9)).strftime("%Y-%m-%d %H:%M") if od[column] + else + od[column] || od.send(column) + end + end + end + end + filename = "order_#{Time.now.strftime('%Y%m%d%H%M%S')}.csv" + [f.string, filename] + end + + private + + def generate_code + id_code = ("%04d" % self.id).slice(-4..-1) # レコード ID の下 4 桁 + self.code = created_at.strftime("%Y%m%d%H%M") + id_code + self.save_without_validation + end + + def sum_deliveries message + order_deliveries.map(&message).map(&:to_i).sum + end + +end diff --git a/app/models/order_delivery.rb b/app/models/order_delivery.rb new file mode 100644 index 0000000..11b9cfe --- /dev/null +++ b/app/models/order_delivery.rb @@ -0,0 +1,488 @@ +# -*- coding: utf-8 -*- +# 発送 +class OrderDelivery < ActiveRecord::Base + + acts_as_paranoid + belongs_to :order + belongs_to :prefecture + belongs_to :deliv_pref, :class_name => 'Prefecture' + belongs_to :occupation + belongs_to :delivery_trader + belongs_to :delivery_time + has_many :order_details, :order => 'position' + belongs_to :payment + has_many :recalls + has_many :delivery_tickets + + attr_accessor :target_columns + + YOYAKU_UKETSUKE, JUTYUU_TOIAWASE, JUTYUU, CANCEL, HASSOU_TEHAIZUMI, HASSOU_TYUU, HAITATU_KANRYO, HAITATU_CANCEL = 1, 2, 3, 4, 5, 6, 7, 8 + STATUS_NAMES = { YOYAKU_UKETSUKE => "予約受付済み", JUTYUU_TOIAWASE => "受注(メーカー問合わせ中)", JUTYUU => "受注", + CANCEL => "キャンセル", HASSOU_TEHAIZUMI => "発送手配済み", HASSOU_TYUU => "発送中", HAITATU_KANRYO => "配達完了", + HAITATU_CANCEL => "配達取り消し" } + + FRONT_STATUS_NAMES = STATUS_NAMES.merge({JUTYUU_TOIAWASE =>STATUS_NAMES[JUTYUU]}) + + DEFAULT_INCLUDE = [:order, :order_details] + + def self.find_sum conditions=nil + select = <<-EOS + sum(subtotal) as subtotal, + sum(discount) as discount, + sum(deliv_fee) as deliv_fee, + sum(charge) as charge, + sum(use_point) as use_point + EOS + joins = <<-EOS + join orders on orders.id = order_deliveries.order_id + EOS + record = find(:first, :select => select, :conditions => conditions, :joins => joins) + record.calculate_total! [:total, :payment_total] # subtotal 以外再計算 + record + end + + def status_view + STATUS_NAMES[status] + end + + # フロントページ用(ユーザ向け) + def front_status_view + FRONT_STATUS_NAMES[status] + end + + def self.status_options include_blank=false + a = STATUS_NAMES.sort_by {|_,value| value}.map {|key,value| [value,key]} + a.unshift(['', nil]) if include_blank + end + + def customer_id + order.customer_id + end + + # 受注金額 + def proceeds + total.to_i - charge.to_i + end + + # 合計を再計算する + def calculate_total! fields=[:subtotal, :total, :payment_total] + self.subtotal = get_subtotal() if fields.include? :subtotal + self.total = subtotal.to_i - discount.to_i + deliv_fee.to_i + charge.to_i if fields.include? :total + self.payment_total = total.to_i - use_point.to_i if fields.include? :payment_total + end + + def before_save + calculate_charge! + calculate_total! + update_commit_date! + update_shipped_at! + update_delivery_completed_at! + if payment + self.delivery_trader_id = payment.delivery_trader_id + end + end + + validates_presence_of :deliv_family_name, :deliv_first_name, + :deliv_family_name_kana, :deliv_first_name_kana, + :deliv_tel01, :deliv_tel02, :deliv_tel03, + :deliv_zipcode01, :deliv_zipcode02, + :deliv_pref_id, + :deliv_address_city, :deliv_address_detail, + :payment_id + + validates_associated :payment + + validates_numericality_of :deliv_tel01, :deliv_tel02, :deliv_tel03, + :deliv_zipcode01, :deliv_zipcode02 + + validates_length_of :message, :maximum=>3000, :allow_blank => true + validates_length_of :note, :maximum=>200, :allow_blank => true + + validates_format_of :family_name_kana, :first_name_kana, :deliv_family_name_kana, :deliv_first_name_kana, + :with => System::KATAKANA_PATTERN, :allow_blank => true, + :message => 'はカタカナで入力してください' + + def validate + super + # FAX どれかが入力されている時だけ検証 + if not [deliv_fax01, deliv_fax02, deliv_fax03].all?(&:blank?) + fax_items = %w(deliv_fax01 deliv_fax02 deliv_fax03) + errors.add_on_blank fax_items, "が入力されていません" + fax_items.each do | name | + errors.add name, "は数字で入力してください" if send(name) =~ /\D/ + end + end + end + + #顧客基本情報設定 + def set_customer(customer) + self.family_name = customer.family_name + self.first_name = customer.first_name + self.family_name_kana = customer.family_name_kana + self.first_name_kana = customer.first_name_kana + self.email = customer.email + self.tel01 = customer.tel01 + self.tel02 = customer.tel02 + self.tel03 = customer.tel03 + self.fax01 = customer.fax01 + self.fax02 = customer.fax02 + self.fax03 = customer.fax03 + self.zipcode01 = customer.zipcode01 + self.zipcode02 = customer.zipcode02 + self.prefecture_id = customer.prefecture_id + self.address_city = customer.address_city + self.address_detail = customer.address_detail + self.sex = customer.sex + self.birthday = customer.birthday + self.occupation_id = customer.occupation_id + end + + #住所情報を配送先に設定 + def set_delivery_address(delivery_address) + self.deliv_family_name = delivery_address.family_name + self.deliv_first_name = delivery_address.first_name + self.deliv_family_name_kana = delivery_address.family_name_kana + self.deliv_first_name_kana = delivery_address.first_name_kana + self.deliv_tel01 = delivery_address.tel01 + self.deliv_tel02 = delivery_address.tel02 + self.deliv_tel03 = delivery_address.tel03 + self.deliv_zipcode01 = delivery_address.zipcode01 + self.deliv_zipcode02 = delivery_address.zipcode02 + self.deliv_pref_id = delivery_address.prefecture_id + self.deliv_address_city = delivery_address.address_city + self.deliv_address_detail = delivery_address.address_detail + end + + #カート内容を注文詳細に設定 + def details_build_from_carts(carts) + carts.each do | cart | + d = order_details.build + d.set_cart(cart) + end + order_details + end + + # 手数料、送料を更新する + def calculate_charge! + self.charge = payment && payment.fee + self.deliv_fee = get_delivery_fee() + end + + def payment_name + payment && payment.name + end + + def delivery_time_name + delivery_time ? delivery_time.name : '指定なし' + end + + def order_code + order && order.code + end + + def prefecture_name + prefecture && prefecture.name + end + + def occupation_name + occupation && occupation.name + end + + def sex_name + System::SEX_NAMES[sex] + end + + def deliv_pref_name + deliv_pref && deliv_pref.name + end + + def delivery_trader_name + delivery_trader && delivery_trader.name + end + + def received_at + order && order.received_at + end + + def delivery_ticket_codes(delimiter="/") + delivery_tickets.map(&:code).join(delimiter) + end + + def ticket_code + delivery_tickets[0] && delivery_tickets[0].code + end + + # 送料を計算する + def get_delivery_fee + # 送料無料条件以上に買っていれば無料 + free_delivery_rule = System.find(:first).free_delivery_rule + if free_delivery_rule && get_subtotal() >= free_delivery_rule + return 0 + end + # 送料無料の商品があれば無料 + order_details.any? do |detail| + detail.product_style.product.free_delivery? + end and return 0 + # 離島だったら離島の価格(郵便番号が入力間違ってzipに存在しない時も離島として) + # 都道府県ID = nil として処理する + prefecture_id = deliv_pref_id + conds = [<<-SQL, self.attributes.symbolize_keys] + zipcode01=:deliv_zipcode01 and + zipcode02=:deliv_zipcode02 + SQL + zip = Zip.find(:first, :conditions => conds) + if !zip or zip.isolation_type == 1 + prefecture_id = nil + end + # 都道府県別の送料を求める + # 都道府県ID = nilの場合、離島であることとして + delivery_fee = DeliveryFee.find_by_delivery_trader_id_and_prefecture_id( + payment && payment.delivery_trader_id, prefecture_id) + delivery_fee && delivery_fee.price + end + + # 支払い方法の候補 + def payment_candidates(price) + payments = Payment.find_for_price(price) + payments + end + + #発送伝票番号の登録 + def update_ticket(ticket_code) + if status >= HASSOU_TYUU && !ticket_code.blank? + ticket = delivery_tickets[0] || DeliveryTicket.new({:order_delivery_id => id}) + ticket.code = ticket_code + ticket.save! + end + end + + class << self + def update_by_csv(file) + line = 0 + update_line = 0 + OrderDelivery.transaction do + CSV::Reader.parse(file) do |row| + if line != 0 + record = OrderDelivery.find_by_order_id(row[0].to_i) + params = get_params(Iconv.conv('UTF-8', 'cp932', row[49]), row[47], row[48]) + if record + if record.update_attributes(params) + #発送伝票番号の登録 + record.update_ticket(row[54]) + else + return [line-1, update_line, false] + end + else + return [line-1, update_line, false] + end + update_line = update_line + 1 + end + line = line + 1 + end #CSV::Reader.parse(file) do |row| + end + [line - 1, update_line, true] + end + + private + + def get_params(status, shipped_at, delivery_completed_at) + status_id = STATUS_NAMES.invert[status] + unless status_id == nil + if shipped_at.blank? + if HASSOU_TYUU <= status_id + shipped_at = DateTime.now + else + shipped_at = 'null' + end + end + if delivery_completed_at.blank? + if HAITATU_KANRYO <= status_id + delivery_completed_at = DateTime.now + else + delivery_completed_at = 'null' + end + end + end + return {:status=>status_id, :shipped_at=>shipped_at, :delivery_completed_at=>delivery_completed_at} + end + end + + def self.csv_columns_name + [ + :order_id, + :order_code, + :family_name, + :first_name, + :family_name_kana, + :first_name_kana, + :zipcode01, + :zipcode02, + :prefecture_name, + :address_city, + :address_detail, + :tel01, + :tel02, + :tel03, + :fax01, + :fax02, + :fax03, + :email, + :occupation_name, + :sex_name, + :birthday, + :subtotal, + :deliv_fee, + :charge, + :use_point, + :add_point, + :total, + :payment_name, + :payment_total, + :message, + :deliv_family_name, + :deliv_first_name, + :deliv_family_name_kana, + :deliv_first_name_kana, + :deliv_pref_name, + :deliv_zipcode01, + :deliv_zipcode02, + :deliv_address_city, + :deliv_address_detail, + :deliv_tel01, + :deliv_tel02, + :deliv_tel03, + :deliv_fax01, + :deliv_fax02, + :deliv_fax03, + :delivery_trader_name, + :delivery_time_name, + :shipped_at, + :delivery_completed_at, + :status_view, + :commit_date, + :created_at, + :updated_at, + :note, + :ticket_code + ] + end + + def self.set_field_names + { + :order_id => "注文ID", + :order_code => "受注番号", + :family_name => "姓", + :first_name => "名", + :family_name_kana => "姓(セイ)", + :first_name_kana => "名(メイ)", + :zipcode01 => "郵便番号(前半)", + :zipcode02 => "郵便番号(後半)", + :prefecture_name => "都道府県", + :address_city => "住所(市区町村)", + :address_detail => "住所(詳細)", + :tel01 => "電話番号01", + :tel02 => "電話番号02", + :tel03 => "電話番号03", + :fax01 => "FAX番号01", + :fax02 => "FAX番号02", + :fax03 => "FAX番号03", + :email => "メールアドレス", + :occupation_name => "職業", + :sex_name => "性別", + :birthday => "誕生日", + :subtotal => "小計", + :deliv_fee => "送料", + :charge => "手数料", + :use_point => "使用ポイント", + :add_pont => "追加ポイント", + :total => "合計", + :payment_name => "支払方法", + :payment_total => "支払合計", + :message => "メッセージ", + :deliv_family_name => "配送先 姓", + :deliv_first_name => "配送先 名", + :deliv_family_name_kana => "配送先 姓(カナ)", + :deliv_first_name_kana => "配送先 名(カナ)", + :deliv_pref_name => "配送先都道府県", + :deliv_zipcode01 => "発送先郵便番号(前半)", + :deliv_zipcode02 => "配送先郵便番号(後半)", + :deliv_address_city => "配送先住所(市区町村)", + :deliv_address_detail => "配送先住所(詳細)", + :deliv_tel01 => "配送先電話番号01", + :deliv_tel02 => "配送先電話番号02", + :deliv_tel03 => "配送先電話番号03", + :deliv_fax01 => "配送先FAX番号01", + :deliv_fax02 => "配送先FAX番号02", + :deliv_fax03 => "配送先FAX番号03", + :delivery_trader_name => "配送業者", + :delivery_time_name => "発送時間", + :shipped_at => "発送日", + :delivery_completed_at => "配達完了", + :status_view => "ステータス", + :commit_date => "受注日", + :created_at => "登録日", + :updated_at => "更新日", + :note => "SHOPメモ", + :ticket_code => "発送伝票番号" + } + end + + private + + # ステータスを発送中、配達完了に変更した場合、 + # その時点の日時を commit_date に入れる。 + # 逆の場合は commit_date をクリアする。 + # 例、 + # 受注から配送中へ変更する時、更新 + # 受注から配送完了へ変更する時、更新 + # 配送中から配送完了へ変更する時、そのまま + # 配送中から受注へ変更する時、クリア + # 配送完了から受注へ変更する時、クリア + def update_commit_date! + commited_statuses = [HASSOU_TYUU, HAITATU_KANRYO] + status_changed? or return + before, after = status_change + if !commited_statuses.include?(before) && commited_statuses.include?(after) + # 発送中に変わった + self.commit_date = DateTime.now + elsif commited_statuses.include?(before) && !commited_statuses.include?(after) + # 発送中から変わった + self.commit_date = nil + end + end + + def update_shipped_at! + shipped_statuses = [HASSOU_TYUU, HAITATU_KANRYO] + status_changed? or return + before, after = status_change + if !shipped_statuses.include?(before) && shipped_statuses.include?(after) + self.shipped_at = DateTime.now if self.shipped_at.blank? + elsif shipped_statuses.include?(before) && !shipped_statuses.include?(after) + self.shipped_at = nil if self.shipped_at.blank? + end + end + + def update_delivery_completed_at! + completed_statuses = [HAITATU_KANRYO] + status_changed? or return + before, after = status_change + if !completed_statuses.include?(before) && completed_statuses.include?(after) + self.delivery_completed_at = DateTime.now if self.delivery_completed_at.blank? + elsif completed_statuses.include?(before) && !completed_statuses.include?(after) + self.delivery_completed_at = nil if self.delivery_completed_at.blank? + end + end + + def get_subtotal + order_details.map(&:subtotal).map(&:to_i).sum + end + + def to_db_date(s) + if s + "'" + s + "'" + else + "null" + end + end + +end diff --git a/app/models/order_detail.rb b/app/models/order_detail.rb new file mode 100644 index 0000000..686fe97 --- /dev/null +++ b/app/models/order_detail.rb @@ -0,0 +1,45 @@ +class OrderDetail < ActiveRecord::Base + + acts_as_paranoid + + belongs_to :order_delivery + belongs_to :product_style + belongs_to :product_category, :class_name => 'Category' + + delegate_to :product_style, :product + + # 税込価格(商品1個あたり) + def price_with_tax + price.to_i + tax_price.to_i + end + + # 小計 (単価 + 税額) * 数) + def subtotal + (price.to_i + tax_price.to_i) * quantity.to_i + end + + validates_presence_of :price, :quantity, :message => 'が入力されていません' + + def set_cart(cart) + self.product_style_id = cart.product_style_id + self.quantity = cart.quantity + self.position = cart.position + product_style = cart.product_style + self.product_name = product_style.product.name + self.product_code = product_style.code + self.product_category_id = product_style.product.category_id + self.price = product_style.sell_price + self.style_category_name1 = product_style.style_category_name1 + self.style_category_name2 = product_style.style_category_name2 + self.style_name1 = product_style.style_name1 + self.style_name2 = product_style.style_name2 + self.product_id = product_style.product_id + self.tax_price = 0 # 内税なので + end + + # 商品名[ 規格名1[ 規格名2]] を出力 + def product_style_name(delimiter=' ') + product_style.full_name(delimiter) + end + +end diff --git a/app/models/payment.rb b/app/models/payment.rb new file mode 100644 index 0000000..b7900c7 --- /dev/null +++ b/app/models/payment.rb @@ -0,0 +1,49 @@ +class Payment < ActiveRecord::Base + + acts_as_paranoid + acts_as_list + + belongs_to :delivery_trader + belongs_to :resource, + :class_name => "ImageResource", + :foreign_key => "resource_id" + has_many :orders + + validates_presence_of :name,:fee,:delivery_trader_id + + def validate + if !upper_limit.blank? && !lower_limit.blank? && upper_limit.to_i < lower_limit.to_i + errors.add "","※ 利用条件(〜円以上)は利用条件(〜円以下)より大きい値を入力できません。" + end + errors.add(:fee,"は0以上の整数で入力してください") unless self.fee.to_i >= 0 + errors.add(:lower_limit,"は0以上の整数で入力してください") unless self.lower_limit.to_i >= 0 + errors.add(:upper_limit,"は0以上の整数で入力してください") unless self.upper_limit.to_i >= 0 + + errors.add(:fee,"は99,999,999円以下で入力してください") if self.fee.to_i >= 0 && self.fee.to_i>99999999 + errors.add(:lower_limit,"は99,999,999円で入力してください") if self.lower_limit.to_i >= 0 && self.lower_limit.to_i>99999999 + errors.add(:upper_limit,"は99,999,999円で入力してください") if self.upper_limit.to_i >= 0 && self.upper_limit.to_i>99999999 + end + + # 指定された価格に合う支払い方法の一覧 + def self.find_for_price(price) + conditions = ['(upper_limit is null or upper_limit >= ?)' + + ' and (lower_limit is null or lower_limit <= ?)', + price, price] + find(:all, :conditions => conditions, :order => 'position') + end + + alias :resource_old= :resource= + [:resource].each do | method_name| + define_method("#{method_name}=") do | value | + if value.class == ActionController::UploadedStringIO || value.class == ActionController::UploadedTempfile || value.class == Tempfile + image_resource = ImageResource.new_file(value, value.original_filename) + self.send "#{method_name}_old=".intern, image_resource + elsif value.class == ImageResource + self.send "#{method_name}_old=".intern, value + else + nil + end + end + end + +end diff --git a/app/models/prefecture.rb b/app/models/prefecture.rb new file mode 100644 index 0000000..871f602 --- /dev/null +++ b/app/models/prefecture.rb @@ -0,0 +1,5 @@ +class Prefecture < ActiveRecord::Base + + acts_as_paranoid + has_many :zips +end diff --git a/app/models/privacy.rb b/app/models/privacy.rb new file mode 100644 index 0000000..c01c527 --- /dev/null +++ b/app/models/privacy.rb @@ -0,0 +1,2 @@ +class Privacy < ActiveRecord::Base +end diff --git a/app/models/product.rb b/app/models/product.rb new file mode 100644 index 0000000..9d6e3ae --- /dev/null +++ b/app/models/product.rb @@ -0,0 +1,556 @@ +# -*- coding: utf-8 -*- +class Product < ActiveRecord::Base + + include ActionView::Helpers::NumberHelper + acts_as_paranoid + + has_many :sub_products, :dependent => :delete_all , :order => "no" + has_many :product_statuses, :order => :position + has_many :statuses, :through => :product_statuses + belongs_to :category + belongs_to :small_resource, + :class_name => "ImageResource", + :foreign_key => "small_resource_id" + belongs_to :medium_resource, + :class_name => "ImageResource", + :foreign_key => "medium_resource_id" + belongs_to :large_resource, + :class_name => "ImageResource", + :foreign_key => "large_resource_id" + has_many :recommend_products + has_one :delivery_date + has_many :styles + has_many :product_styles, :dependent => :destroy, :order => 'position' + has_many :order_details + has_one :campaign + + validates_length_of :name , :maximum => 50 + validates_length_of :name , :minimum => 1 + validates_length_of :url , :maximum => 300, :allow_blank => true + validates_length_of :key_word , :maximum => 99999, :allow_blank => true + validates_presence_of :category_id + validates_presence_of :small_resource + validates_presence_of :medium_resource + validates_presence_of :description + validates_presence_of :introduction + validates_associated :sub_products + + attr_accessor :small_resource_path + attr_accessor :medium_resource_path + attr_accessor :large_resource_path + + DEFAULT_INCLUDE = [:product_statuses, :category] + PERMIT_LABEL = {"公開" => true, "非公開" => false } + + DELIVERY_DATE = { "1週間前後" => 0, "2週間前後" => 1, "3日後" => 3, + "1週間以降" => 7, "2週間以降" => 14, "3週間以降" => 21, "1ヶ月以降" => 31, + "2ヶ月以降" => 62, "お取り寄せ(商品入荷後)" => 99 } + + ZAIKO_MUCH,ZAIKO_LITTLE = 10,0 + + def validate + if sale_start_at and sale_end_at + unless sale_start_at < sale_end_at + errors.add :sale_end_at, "は販売開始日以降の日付を設定してください。" + end + end + if public_start_at and public_end_at + unless public_start_at < public_end_at + errors.add :public_end_at, "は公開開始日以降の日付を設定してください。" + end + end + end + + def self.permit_select + PERMIT_LABEL.collect{|key, value| [key, value]} + end + + def self.delivery_dates_select + DELIVERY_DATE.collect{|key, value| [key, value]} + end + + def delivery_dates_label + DELIVERY_DATE.index self.delivery_dates + end + + def permit_label + permit_labels = Hash.new + PERMIT_LABEL.each { |key, value| permit_labels[value] = key } + permit_labels[self.permit] + end + + alias :small_resource_old= :small_resource= + alias :medium_resource_old= :medium_resource= + alias :large_resource_old= :large_resource= + [:small_resource , :medium_resource , :large_resource].each do | method_name| + define_method("#{method_name}=") do | value | + if value.class == ActionController::UploadedStringIO || value.class == ActionController::UploadedTempfile || value.class == Tempfile + image_resource = ImageResource.new_file(value, value.original_filename) + self.send "#{method_name}_old=".intern, image_resource + elsif value.class == ImageResource + self.send "#{method_name}_old=".intern, value + else + nil + end + end + end + + # 規格 + def first_product_style + product_styles.empty? and return nil + product_styles[0] + end + delegate_to :first_product_style, :style_category1, :style, :as => :style1 + delegate_to :first_product_style, :style_category2, :style, :as => :style2 + delegate_to :first_product_style, :style_category1, :style_id, :as => :style_id1 + delegate_to :first_product_style, :style_category2, :style_id, :as => :style_id2 + + # 最安値と最高値の 2 要素配列 + def price_range + [product_styles.minimum(:sell_price), product_styles.maximum(:sell_price)] + end + + def price_label + p_range = price_range + if p_range[0] == p_range[1] + number_with_delimiter(p_range[0]) + else + p_range.map{|p| number_with_delimiter(p)}.join("~") + end + end + + def category_name + self.category && self.category.name + end + + # 送料無料? + def free_delivery? + statuses.exists?(['name=?', '送料無料']) + end + + def permit_select_tag + PERMIT_LABEL.map{|key, value| "" }.join + end + +# # 購入可能? +# def can_be_bought?(now=Time.zone.now) +# permit && in_sale_term?(now) # TODO: have_zaiko? も入れて良い? +# end + + # 販売期間内 + def in_sale_term?(now=Time.zone.now) + sale_start_at <= now && now <= (sale_end_at + 1.day - 1 ) + end + + # 公開期間内 + def in_public_term?(now=Time.zone.now) + public_start_at <= now && now <= (public_end_at + 1.day - 1) + end + # 在庫がある + def have_zaiko? + product_styles or return false + product_styles.any? do |ps| + !ps.actual_count.blank? && ps.actual_count > 0 + end + end + + def self.defalt_condition + conditions = [["products.permit = ?", true]] + conditions << ["? between products.public_start_at and products.public_end_at", today_utc(Date.today)] + conditions << ["have_product_style = ?", true] + conditions + end + + def self.get_conditions(search, params, actual_count_list_flg = false) + search_list = [] + if search + unless search.product_id.blank? + if search.product_id =~ /^\d*$/ + if search.product_id.to_i < 2147483647 + search_list << ["products.id = ?", search.product_id.to_i] + else + search_list << ["products.id = ?", 0] + end + else + search.errors.add nil, "商品IDは数字で入力して下さい。" + end + end + unless search.code.blank? + code_condition = ["product_styles.code like ? ", "%#{search.code}%"] + if actual_count_list_flg + search_list << code_condition + else + product_styles = ProductStyle.find(:all, :select => "product_styles.product_id", + :conditions => code_condition ) + ids = product_styles.map{|p| p.product_id}.join(",") + ids = id_change_to_i(ids) +# ids = "0" if ids.blank? + search_list << ["products.id in (?) ", ids] + end + end + unless search.style.blank? + product_styles = ProductStyle.find(:all, :select => "product_styles.product_id", + :joins => "left join style_categories on product_styles.style_category_id1 = style_categories.id left join style_categories as style_categories2 on style_category_id2 = style_categories2.id ", + :conditions => ["style_categories.name like ? or style_categories2.name like ? ", "%#{search.style}%", "%#{search.style}%"] ) + ids = product_styles.map{|p| p.product_id}.join(",") + ids = id_change_to_i(ids) + + search_list << ["products.id in (?)", ids] + end + unless search.name.blank? + search_list << ["products.name like ?", "%#{search.name}%"] + end + unless search.category.blank? + search.category = search.category.to_i + category = Category.find_by_id search.category + ids = category.get_child_category_ids + search_list << ["products.category_id in (?)", ids] unless ids.empty? + end + unless search.permit.blank? + search_list << ["products.permit = ?", search.permit] + end + unless search.created_at_from.blank? + if actual_count_list_flg + search_list << ["product_styles.created_at >= ?", search.created_at_from] + else + search_list << ["products.created_at >= ?", search.created_at_from] + end + end + unless search.created_at_to.blank? + if actual_count_list_flg + search_list << ["product_styles.created_at < ?", search.created_at_to + 1 * 60 * 60 * 24] + else + search_list << ["products.created_at < ?", search.created_at_to + 1.day] + end + end + unless search.updated_at_from.blank? + if actual_count_list_flg + search_list << ["product_styles.updated_at >= ?", search.updated_at_from] + else + search_list << ["products.updated_at >= ?", search.updated_at_from] + end + end + unless search.updated_at_to.blank? + if actual_count_list_flg + search_list << ["product_styles.updated_at <= ?", search.updated_at_to ] + else + search_list << ["products.updated_at <= ?", search.updated_at_to + 1.day] + end + end + unless search.sale_start_at_start.blank? + search_list << ["products.sale_start_at >= ?", search.sale_start_at_start] + end + unless search.sale_start_at_end.blank? + search_list << ["products.sale_start_at <= ?", search.sale_start_at_end + 1.day] + end + end + unless params["product_status_ids"].blank? + product_status = ProductStatus.find(:all, :select => "distinct product_id", :conditions => "status_id IN (#{ params["product_status_ids"].join(",") })" ) + ids = product_status.map{|p| p.product_id||0}.join(",") + ids = id_change_to_i(ids) + search_list << ["products.id in (?)", ids] + end + [search, search_list] + end + + def self.csv(search_list) + columns = csv_columns_name + products = self.find(:all, + :conditions => flatten_conditions(search_list), + :include => DEFAULT_INCLUDE, + :order => "products.id") + f = StringIO.new('', 'w') + CSV::Writer.generate(f) do | writer | + writer<< columns.map{|name| set_field_names[name]} + products and products.each do | product | + writer << columns.map do | column | + if column.to_s == "permit" + if product[column] + "公開" + else + "非公開" + end + elsif column.to_s == "delivery_dates_label" + product.delivery_dates_label + elsif ![:small_resource_path,:medium_resource_path,:large_resource_path,:category_name,:delivery_dates_label].include?(column)&& Product.columns_hash[column.to_s].type == :datetime + (product[column] + (60*60*9)).strftime("%Y-%m-%d %H:%M") if product[column] + else + product[column] || product.send(column) + end + end + end + end + filename = "product_#{Time.now.strftime('%Y%m%d%H%M%S')}.csv" + [f.string, filename] + end + + def self.actual_count_list_csv(search_list) + products = ProductStyle.find(:all, + :conditions => flatten_conditions(search_list), + :joins => "LEFT JOIN products ON products.id = product_styles.product_id ", + :order => "id") + f = StringIO.new('', 'w') + title = ["商品名", "商品コード", "登録更新日", "実在個数"] + CSV::Writer.generate(f) do | writer | + writer<< title + products and products.each do | product | + columns = [] + columns << product.product_name + columns << product.code + columns << product.updated_at + columns << product.actual_count.to_i + writer << columns + end + end + filename = "actual_count_list_#{Time.now.strftime('%Y%m%d%H%M%S')}.csv" + [f.string, filename] + end + + class << self + def add_by_csv(file) + line = 0 + Product.transaction do + CSV::Reader.parse(file) do |row| + if line != 0 + product = new_by_array(row) + unless product.save! + return [line-1, false] + end + end + line = line + 1 + end + end + [line - 1, true] + end + + private + + def new_by_array(arr) + arr.map! do | val | + Iconv.conv('UTF-8', 'cp932', val) + end + #arr[0]が対応しているデータ存在する時、更新、存在しない時、新規作成 + unless !arr[0].blank? && product = Product.find_by_id(arr[0].to_i) + product = Product.new + end + #CSVデータ設定 + set_data(product,arr) + product + end + + #CSVデータ設定 + def set_data(product,arr) + setPermit(product, arr[1]) + product.name = arr[2] + product.url = arr[3] + product.introduction = arr[4] + product.description = arr[5] + product.key_word = arr[6] + product.price = arr[7] + setImageId(product,arr) + product.small_resource_comment = arr[9] + product.medium_resource_comment = arr[12] + product.large_resource_comment = arr[15] + product.sell_limit = arr[17] + product.point_granted_rate = arr[18] + product.sale_start_at = arr[19] + product.sale_end_at = arr[20] + setCategoryId(product, arr[21]) + product.arrival_expected_date = arr[22] + product.size_txt = arr[23] + product.material = arr[24] + product.origin_country = arr[25] + product.weight = arr[26] + product.arrival_date = arr[27] + product.other = arr[28] + product.free_comment = arr[29] + setDelivery_dates(product,arr[30]) + end + + def setPermit(product, permit) + if permit == "公開" + product.permit = true + else + product.permit = false + end + end + + def setDelivery_dates(product, delivery_dates_label) + product.delivery_dates = DELIVERY_DATE[delivery_dates_label] unless delivery_dates_label.blank? + end + + #画像データセット + def setImageId(product,arr) + #画像IDと画像パスの項目を別々に設定して画像パスがあった場合は、その先にある画像を登録し、なかった場合は画像IDを登録する + #指定パスの画像が存在ない時も画像IDを登録する + if arr[10].blank? + small_resource_id = arr[8] + else + small_resource_id = get_image_resource_seq(arr[10]) + if small_resource_id.blank? + small_resource_id = arr[8] + end + end + + if arr[13].blank? + medium_resource_id = arr[11] + else + medium_resource_id = get_image_resource_seq(arr[13]) + if medium_resource_id.blank? + medium_resource_id = arr[11] + end + end + + if arr[16].blank? + large_resource_id = arr[14] + else + large_resource_id = get_image_resource_seq(arr[16]) + if large_resource_id.blank? + large_resource_id = arr[14] + end + end + product.small_resource_id = small_resource_id + product.medium_resource_id = medium_resource_id + product.large_resource_id = large_resource_id + end + + def setCategoryId(product, catName) + c = Category.find_by_name(catName) + product.category_id = c.id + end + + #画像データをDB登録 + def get_image_resource_seq(image_path) + #常用画像タイプ + format = [".gif",".jpg",".jpeg",".jpe",".jfif",".png",".tif",".tiff",".bmp"] + #画像ファイル存在しない時、画像登録しない + if !image_path.blank? && format.include?(File.extname(image_path).downcase) && FileTest.exist?(image_path) + + resource = ImageResource.new + resource.name = File.basename(image_path) + resource.content_type = get_content_type(File.extname(image_path).downcase) + resource.save + + File.open(image_path,'rb') { |file| + ResourceData.create(:resource_id => resource.id, :content => file.read) + } + resource.id + end + end + #content_type設定 + def get_content_type(extname) + type = extname[1,extname.length-1] + base = "image/" + type_g = ["gif"] + type_j = ["jpg","jpeg","jpe","jfif"] + type_p = ["png"] + type_t = ["tif","tiff"] + type_b = ["bmp"] + if type_g.include?(type) + sub_type = "gif" + elsif type_j.include?(type) + sub_type = "jpeg" + elsif type_p.include?(type) + sub_type = "png" + elsif type_t.include?(type) + sub_type = "tiff" + elsif type_b.include?(type) + sub_type = "bmp" + else sub_type = "" + end + base << sub_type + end + end + + private + def self.csv_columns_name + [ + :id , + :permit, + :name, + :url, + :introduction, + :description, + :key_word, + :price, + :small_resource_id, + :small_resource_comment, + :small_resource_path, + :medium_resource_id, + :medium_resource_comment, + :medium_resource_path, + :large_resource_id, + :large_resource_comment, + :large_resource_path, + :sell_limit, + :point_granted_rate, + :sale_start_at, + :sale_end_at, + :category_name, +# :category_id, + :arrival_expected_date, + :size_txt, + :material, + :origin_country, + :weight, + :arrival_date, + :other, + :free_comment, + :delivery_dates_label, + :created_at, + :updated_at + ] + end + + def self.set_field_names + { + :id => "商品ID", + :permit => "公開設定", + :name => "名前", + :url => "参照URL", + :introduction => "一覧コメント", + :description => "詳細コメント", + :key_word => "キーワード", + :price => "参考市場価格", + :small_resource_id => "一覧・メイン画像ID", + :small_resource_comment => "一覧・メイン画像コメント", + :small_resource_path => "一覧・メイン画像パス", + :medium_resource_id => "詳細・メイン画像ID", + :medium_resource_comment => "詳細・メイン画像コメント", + :medium_resource_path => "詳細・メイン画像パス", + :large_resource_id => "詳細・メイン拡大画像ID", + :large_resource_comment => "詳細・メイン拡大画像コメント", + :large_resource_path => "詳細・メイン拡大画像パス", + :sell_limit => "購入制限", + :point_granted_rate => "ポイント付与率", + :sale_start_at => "販売開始日", + :sale_end_at => "販売終了日", + :category_name => "商品カテゴリ", + :arrival_expected_date => "入荷予定日", + :size_txt => "サイズ", + :material => "素材", + :origin_country => "原産国", + :weight => "重さ", + :arrival_date => "入荷日", + :other => "その他仕様", + :free_comment => "フリー入力", + :delivery_dates_label => "配送日", + :created_at => "登録日", + :updated_at => "更新日" + } + end + + def self.id_change_to_i(ids) + if ids.blank? + ids = 0 + else + ids = ids.split(/\s*,\s*/) + end + ids + end + + def self.today_utc(today) + ud = Time.zone.local_to_utc(Time.local(today.year,today.month,today.day)) + Date.new(ud.year, ud.month, ud.day) + end +end diff --git a/app/models/product_access_log.rb b/app/models/product_access_log.rb new file mode 100644 index 0000000..eb7afa7 --- /dev/null +++ b/app/models/product_access_log.rb @@ -0,0 +1,38 @@ +require 'net/http' +require 'timeout' + +class ProductAccessLog < ActiveRecord::Base + def self.send_bcon + product_access_logs = ProductAccessLog.find(:all, :conditions => ["send_flg = ? or send_flg is null", false]) + product_access_logs && product_access_logs.each do | product_access_log | + begin + next if product_access_log.send_flg + timeout(1) { + Net::HTTP.version_1_2 + Net::HTTP.start('recommend.kbmj.com', 80) {|http| + k = product_access_log.complete_flg ? "view_dummy_id" : "buy_dummy_id" #TODO:閲覧・購入履歴用のビーコンIDを設定して下さい + uid = "" + if product_access_log.docomo_flg + uid = product_access_log.customer_id.blank? ? product_access_log.session_id : product_access_log.customer_id + else + uid = product_access_log.ident.blank? ? product_access_log.session_id : product_access_log.ident + end + url ="/bcon/#{product_access_log.complete_flg ? "heavier" : "basic"}/?k=#{k}&id[]=#{product_access_log.product_id}&uid=#{uid}" + req = Net::HTTP::Get.new(url) + req['referer'] = "SITE_URL" #TODO:サイトURLを入れてください + response = http.request(req) + logger.info "send_bcon url:#{ url } / response #{ response.code } " + } + product_access_log.send_flg = true + product_access_log.save! + } + rescue TimeoutError => e + p "err: #{ e }" + logger.info "err: #{ e }" + return false + rescue + rescue + end + end + end +end diff --git a/app/models/product_status.rb b/app/models/product_status.rb new file mode 100644 index 0000000..f50d7b1 --- /dev/null +++ b/app/models/product_status.rb @@ -0,0 +1,6 @@ +class ProductStatus < ActiveRecord::Base + + acts_as_paranoid + belongs_to :product + belongs_to :status +end diff --git a/app/models/product_style.rb b/app/models/product_style.rb new file mode 100644 index 0000000..69349eb --- /dev/null +++ b/app/models/product_style.rb @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +class ProductStyle < ActiveRecord::Base + + acts_as_paranoid + + belongs_to :product + belongs_to :style_category1, + :class_name => "StyleCategory", + :foreign_key => "style_category_id1" + belongs_to :style_category2, + :class_name => "StyleCategory", + :foreign_key => "style_category_id2" + has_many :purchase_details + + belongs_to :style1, + :class_name => "Style", + :foreign_key => "style_id1" + belongs_to :style2, + :class_name => "Style", + :foreign_key => "style_id2" + + validates_format_of :code, :with => /^[a-zA-Z0-9]*$/ + + DEFAULT_DATA = {:actual_count => 0} + alias initialize_old initialize + + def initialize(attributes = nil) + initialize_old(attributes) + if @new_record && defined? DEFAULT_DATA + DEFAULT_DATA.each do | column, value | + @attributes[column.to_s] = value unless @attributes[column.to_s] && ! @attributes[column.to_s].blank? + end + end + end +=begin rdoc + * INFO + + parametors: + :size => Fixnum[必須] + + return: + 引数 [size] が購入可能な個数であれば、 [size] を返す。 + 引数 [size] が購入可能な個数を超過する場合は、 購入可能な最大数 を返す。 +=end + def available?(size) + actual_count.to_i > 0 ? (check = actual_count) : (check = 0) + limit = [check, size].min + product.sell_limit ? [limit, product.sell_limit].min : limit + end + + delegate_to :style_category1, :name, :as => :style_category_name1 + delegate_to :style_category2, :name, :as => :style_category_name2 + delegate_to :style_category1, :style, :name, :as => :style_name1 + delegate_to :style_category2, :style, :name, :as => :style_name2 + + # 税込販売額 + def including_tax_sell_price + sell_price # sell_price は税込み価格 + end + + def validate + if style_category1.nil? && ! style_category2.nil? + self.errors.add nil,"規格1が無い状態で規格 2を登録出来ません。" + end + if sell_price.to_s.length > 10 + self.errors.add :sell_price, "数値が大き過ぎます。" + end + if sell_price.blank? || sell_price == 0 + self.errors.add :sell_price, "を入力して下さい" + end + end + + # 受注する + def order(number) + if actual_count > 0 + self.actual_count -= number + else + raise '実在個数が0です' + end + end + + # 規格分類込みの名称 + def full_name(delimiter=' ') + [product.name, style_category_name1, style_category_name2].inject([]) do | xs, x | + x.blank? and break xs + xs << x + end.join(delimiter) + end + + def product_name + product && product.name + end + +end diff --git a/app/models/question.rb b/app/models/question.rb new file mode 100644 index 0000000..a6d6a4c --- /dev/null +++ b/app/models/question.rb @@ -0,0 +1,24 @@ +class Question < ActiveRecord::Base + + acts_as_paranoid + + belongs_to :questionnaire + has_many :question_choices, :dependent => :destroy + + + #質問項目を削除 + def self.clear_questions(questions) + begin + Question.transaction do + questions.each do |question| + question.question_choices.clear + question.destroy + end + end + return true + rescue + return false + end + end + +end diff --git a/app/models/question_answer.rb b/app/models/question_answer.rb new file mode 100644 index 0000000..60935ab --- /dev/null +++ b/app/models/question_answer.rb @@ -0,0 +1,21 @@ +class QuestionAnswer < ActiveRecord::Base + + acts_as_paranoid + + belongs_to :questionnaire_answer + belongs_to :question + belongs_to :question_choice + + validates_length_of :answer, :maximum=>200, :to_long=>"は最大%d文字です", :allow_nil => true + + def export_row + array = [] + columns = ["answer"] + for column in columns + value = self[column] + array << value + end + return array + end + +end diff --git a/app/models/question_choice.rb b/app/models/question_choice.rb new file mode 100644 index 0000000..faeabad --- /dev/null +++ b/app/models/question_choice.rb @@ -0,0 +1,15 @@ +class QuestionChoice < ActiveRecord::Base + + acts_as_paranoid + + NOUSE, TEXTAREA, TEXTBOX, CHECKBOX, RADIOBUTTON = 0, 1, 2, 3, 4 + CHOICE_FORMAT = { NOUSE => "使用しない", TEXTAREA => "テキストエリア", + TEXTBOX => "テキストボックス", CHECKBOX => "チェックボックス", + RADIOBUTTON => "ラジオボタン" } + belongs_to :question + + def format_view + CHOICE_FORMAT[format] + end + +end diff --git a/app/models/questionnaire.rb b/app/models/questionnaire.rb new file mode 100644 index 0000000..eb1e12c --- /dev/null +++ b/app/models/questionnaire.rb @@ -0,0 +1,112 @@ +class Questionnaire < ActiveRecord::Base + + acts_as_paranoid + + has_many :questions, :dependent => :destroy, :validate => false + has_many :questionnaire_answers + + validates_presence_of :name + validates_presence_of :content + + QUESTION_COUNT = 6 + QUESTION_CHOICE_COUNT = 8 + + def validate + #質問項目のvalidate + if questions.size == 0 + errors.add "dummy","質問がありません" + else + errors.add "dummy", "質問1がありません" if questions[0] && questions[0].position != 1 + questions.each_with_index do | question, index | + errors.add "dummy", "質問#{question.position}の内容がありません" if question.content.nil? + errors.add "dummy", "質問#{question.position}の内容は不正な値です" if !question.content.nil? && question.content.length > 100000 + + #選択四肢のvalidate + question.question_choices.each_with_index do | question_choice, choice_index | + errors.add "dummy", "質問#{question.position}の質問形式が選択されていません" if !question_choice.format && choice_index == 0 + errors.add "dummy", "質問#{question.position}の選択肢1がありません" if choice_index == 0 && (question_choice.format == QuestionChoice::CHECKBOX || question_choice.format == QuestionChoice::RADIOBUTTON) && question_choice.content.blank? + end + end + end + end + + def init_data + self.operation = false + QUESTION_COUNT.times do |question_idx| + question = Question.new(:content=>nil, :position=>question_idx+1) + QUESTION_CHOICE_COUNT.times do |choice_idx| + question.question_choices << QuestionChoice.new(:content=>nil, :position=>choice_idx+1) + end + questions << question + end + end + + def get_show_questions_data + questions_data = [] + QUESTION_COUNT.times do | question_idx | + if question = questions.find(:first, :conditions=>["position = ?", question_idx+1]) + QUESTION_CHOICE_COUNT.times do | choice_idx | + if question_choice = question.question_choices.find(:first, :conditions=>["position = ?", choice_idx+1]) #既存の選択肢があれば取得 + question.question_choices << question_choice + else #選択肢を新しく追加 + question.question_choices.build(:content => nil, :position=>choice_idx+1) + end + end + + else #質問項目を新しく作る + question = Question.new({:content => nil, :position => question_idx+1}) + + #選択肢を新しく作る + QUESTION_CHOICE_COUNT.times do | choice_idx | + question.question_choices << QuestionChoice.new({:content => nil, :position => choice_idx+1, :format => nil}) + end + end + questions_data << question + end + return questions_data + end + + def self.csv(id, count) + questionnaire = self.find(id) + header = get_csv_header(count) + f = StringIO.new('', 'w') + CSV::Writer.generate(f) do |writer| + writer << header + questionnaire.questionnaire_answers.each do | questionnaire_answer | + row = questionnaire_answer.export_row + questionnaire_answer.question_answers.each do |question_answer| + row.concat(question_answer.export_row) + end + writer << row + end + end + f.string + end + + private + + def self.get_csv_header(count) + header = ["アンケート回答ID", + "回答者(姓)", + "回答者(名)", + "回答者(セイ)", + "回答者(メイ)", + "回答者ID", + "郵便番号1", + "郵便番号2", + "都道府県名", + "市町村名", + "町域名", + "電話番号1", + "電話番号2", + "電話番号3", + "作成日", + "メールアドレス"] + + count.times do | index | + header += ["回答#{index+1}"] + end + header + end + +end diff --git a/app/models/questionnaire_answer.rb b/app/models/questionnaire_answer.rb new file mode 100644 index 0000000..168a8ab --- /dev/null +++ b/app/models/questionnaire_answer.rb @@ -0,0 +1,51 @@ +class QuestionnaireAnswer < ActiveRecord::Base + + acts_as_paranoid + + belongs_to :customers + belongs_to :questionnaire + has_many :question_answers + + validates_presence_of :customer_family_name + validates_presence_of :customer_first_name + validates_presence_of :customer_family_name_kana + validates_presence_of :customer_first_name_kana + validates_presence_of :address_city + validates_presence_of :address_details + validates_presence_of :tel01 + validates_presence_of :tel02 + validates_presence_of :tel03 + validates_presence_of :email + validates_presence_of :zipcode01 + validates_presence_of :zipcode02 + + validates_format_of :email, :with => /[^@]+@[^@\.]+\.[^@\.]+/ + validates_format_of :customer_family_name_kana, :with => System::KATAKANA_PATTERN + validates_format_of :customer_first_name_kana, :with => System::KATAKANA_PATTERN + validates_format_of :tel01, :with => /^[0-9]*$/, :message => "は数字です" + validates_format_of :tel02, :with => /^[0-9]*$/, :message => "は数字です" + validates_format_of :tel03, :with => /^[0-9]*$/, :message => "は数字です" + validates_format_of :zipcode01, :with => /^(([0-9]{3})|)$/, :message => "は3桁の数字です" + validates_format_of :zipcode02, :with => /^(([0-9]{4})|)$/, :message => "は4桁の数字です" + + validates_confirmation_of :email + + def export_row + array = [] + columns = ["id", "customer_family_name", "customer_first_name", "customer_family_name_kana", "customer_first_name_kana", "customer_id", + "zipcode01", "zipcode02", "prefecture_name", "address_city", "address_details", "tel01", "tel02", "tel03", + "created_at", "email"] + for column in columns + value = self.send(column) + case value + when Time + value = value.strftime('%Y-%m-%d %H:%M:%S') + when Array + value = value.join(',') + end + array << value + end + return array + end + +end diff --git a/app/models/recommend.rb b/app/models/recommend.rb new file mode 100644 index 0000000..f7d56c0 --- /dev/null +++ b/app/models/recommend.rb @@ -0,0 +1,75 @@ +require 'open-uri' +require 'rexml/document' +require 'timeout' + +#以下はKBMJのASPサービスであるパーソナライズド・レコメンダー用のロジックです +class Recommend < ActiveRecord::Base + + TYPE_BUY, TYPE_VIEW = 0, 1 + + #XML連携用レコメンドURL + RECOMMEND_URLS = { + TYPE_BUY => "RECOMMEND_BUY_URL", #購入履歴用のURLを設定して下さい(&id[]= まで) + TYPE_VIEW => "RECOMMEND_VIEW_URL", #閲覧履歴用のURLを設定して下さい(&id[]= まで) + } + RANKING_URL = "RECOMMEND_RANKING_URL" #ランキング用のURLを設定して下さい(team=w まで) + + def self.recommend_get(product_id, type=TYPE_BUY) + unless Recommend.find(:first, :conditions => ["product_id = ? and request_type = ? and created_at > ?", product_id, type, Time.zone.local_to_utc(Time.now - (60 * 60))]) + self.recommend_network_get(product_id, type) + end + + logger.info(RecommendXml.find(:first, :conditions => ["product_id = ? and request_type = ?", product_id, type]).to_s) + RecommendXml.find(:all, :conditions => ["product_id = ? and request_type = ?", product_id, type]) + end + + def self.ranking_get(limit = nil) + unless Recommend.find(:first, :conditions => ["created_at > ?",Time.zone.local_to_utc(Time.now - (60 * 60))]) + self.ranking_network_get + end + + RecommendXml.find(:all,:limit => limit) + end + + def self.recommend_network_get(product_id, type) + url = "#{RECOMMEND_URLS[type]}#{product_id}" + return unless self.network_get(url, ["product_id = ? and request_type = ?", product_id, type], product_id,type) + Recommend.create(:product_id => product_id, :request_type=>type) + end + + def self.ranking_network_get + url = RANKING_URL + return unless self.network_get(url, nil, nil, nil) + Recommend.create + end + + def self.network_get(url, delete_conditions, product_id, type) + begin + timeout(1) do + open(url) do | http | + response = http.read + doc = REXML::Document.new response + + RecommendXml.delete_all(delete_conditions) + columns = [:name, :url, :categroy, :price] + doc.elements.each("items/item") do | r | + recommend_xml = RecommendXml.new(:product_id => product_id, :request_type=>type) + recommend_xml[:recommend_id] = r.elements["id"].text + recommend_xml[:image_url] = r.elements["img_url"].text + columns.each do | column | + recommend_xml[column.to_s] = r.elements[column.to_s] && r.elements[column.to_s].text + end + recommend_xml.save + end + end + end + return true + rescue TimeoutError => e + p "err: #{ e }" + logger.info "err: #{ e }" + return false + rescue + return false + end + end +end diff --git a/app/models/recommend_product.rb b/app/models/recommend_product.rb new file mode 100644 index 0000000..d526e4f --- /dev/null +++ b/app/models/recommend_product.rb @@ -0,0 +1,18 @@ +class RecommendProduct < ActiveRecord::Base + + acts_as_paranoid + + belongs_to :product + + validates_presence_of :product_id + validates_presence_of :description + validates_length_of :description, :maximum=>300, :to_long=>"は最大%d文字です", :allow_nil=>true + + def position_up + if RecommendProduct.maximum(:position) != nil + self.position = RecommendProduct.maximum(:position) + 1 + else + self.position = 1 + end + end +end diff --git a/app/models/recommend_xml.rb b/app/models/recommend_xml.rb new file mode 100644 index 0000000..bcda94f --- /dev/null +++ b/app/models/recommend_xml.rb @@ -0,0 +1,6 @@ +class RecommendXml < ActiveRecord::Base + + belongs_to :recommend, :class_name => 'Product' + belongs_to :product + +end diff --git a/app/models/resource_data.rb b/app/models/resource_data.rb new file mode 100644 index 0000000..7c9271b --- /dev/null +++ b/app/models/resource_data.rb @@ -0,0 +1,2 @@ +class ResourceData < ActiveRecord::Base +end diff --git a/app/models/search_form.rb b/app/models/search_form.rb new file mode 100755 index 0000000..d5b45af --- /dev/null +++ b/app/models/search_form.rb @@ -0,0 +1,180 @@ +# 検索条件を格納する +# 例: @search = SearchForm.new(params[:search]) + +class SearchForm < ActiveForm + VALID_NAME = /^[a-zA-Z_][a-zA-Z0-9_]*$/ + include ActiveRecord::Validations + def validate + super + # from <= to etc... + attributes.each do | name, value | + value.blank? and next + if (m = name.match(/_from$/)) + prefix = m.pre_match + name_to = prefix+'_to' + from = value + to = send(name_to) + next if to.blank? + # 数字だけの場合数値として比較 + unless [from, to].any?{|v| v =~ /\D/} # 数字以外が含まれていない + from = from.strftime("%Y%m%d%H%M%S").to_i + to = to.strftime("%Y%m%d%H%M%S").to_i + end + unless from <= to + errors.add name, 'の範囲指定が不正です。' + errors.add name_to, 'の範囲指定が不正です。' + end + end + end + end + + # ActiveForm からコピペして改造 + def attributes + attributes = instance_variables + attributes.delete("@errors") + attributes.inject({}) do |hash, attribute| + hash[attribute[1..-1]] = instance_variable_get(attribute) + hash + end + end + + def attributes=(hash) + hash.each do | key, value | + next if value.nil? || value == '' + # datetime + name = key.to_s + if (m = name.match(/\((\d)i\)$/)) + next if m[1] != '1' + name = m.pre_match + if (date = parse_date_select(hash, name)) + send(name+'=', date) + end + elsif value.is_a?(String) && + value =~ /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/ + # 日時に見える文字列は Date に + send(name+'=', Time.zone.parse(value)) + else + send(name+'=', value) + end + end if hash + end + + def method_missing(key, *args) + begin + super + rescue NoMethodError + name = key.to_s + if name.size >= 2 && name[-1] == ?= # name =~ /^.+=$/ + # set + name = name[0, name.size-1] + value = args.first + instance_variable_set('@'+name, value) if name =~ VALID_NAME + else + # get + instance_variable_get('@'+name) if name =~ VALID_NAME + end + end + end + + private + + def parse_date_select(params, name) + arr = (1..6).map do |i| + params["%s(%di)" % [name, i]] + end + if arr.join.blank? + return + end + year,month,day,hour,min,sec = arr + + selected_date = false + selected_time = false + + if year || month || day + selected_date = true + end + + if hour || min || sec + selected_time = true + end + + now = DateTime.now + if selected_date + if year.blank? + year = now.year.to_s + end + if month.blank? + if ! day.blank? + month = now.month.to_s + elsif year + month = "1" + else + month = now.month.to_s + end + end + if day.blank? + if year || month + day = "1" + else + day = now.day.to_s + end + end + end + + if selected_time + if hour.blank? + hour = "00" + end + if min.blank? + if hour + min = "00" + else + min = now.min.to_s + end + end + if sec.blank? + if hour || min + sec = "00" + else + sec = now.sec.to_s + end + end + end + if selected_time + Time.zone.local(year.to_i,month.to_i,day.to_i,hour.to_i,min.to_i,sec.to_i) + else + Time.zone.local(year.to_i,month.to_i,day.to_i) + end + end + + ## from ActiveHeart + + class << self + def set_field_names(field_names = {}) + @field_names = HashWithIndifferentAccess.new unless @field_names + @field_names.update(field_names) + end + + alias_method :_human_attribute_name, :human_attribute_name + def human_attribute_name(attribute_key_name) + if @field_names && @field_names[attribute_key_name] + @field_names[attribute_key_name] + else + _human_attribute_name(attribute_key_name) + end + end + + def field_names + @field_names + end + + def self_and_descendants_from_active_record + [self] + end + + def human_name(*args) + name.humanize + end + end + +end diff --git a/app/models/seo.rb b/app/models/seo.rb new file mode 100644 index 0000000..5c03e3f --- /dev/null +++ b/app/models/seo.rb @@ -0,0 +1,15 @@ +class Seo < ActiveRecord::Base + + acts_as_paranoid + + TOP, PRODUCTS_LIST, PRODUCTS_DETAIL, MYPAGE_INDEX = 0,1,2,3 + TYPE_NAMES = { TOP => 'TOPページ', PRODUCTS_LIST => '商品一覧ページ', PRODUCTS_DETAIL => '商品詳細ページ', MYPAGE_INDEX => 'MYページ' } + + validates_length_of :author,:description,:keywords, :maximum => 50, :allow_blank => true + + + def before_save + self.name=TYPE_NAMES[self.page_type] + end + +end diff --git a/app/models/session.rb b/app/models/session.rb new file mode 100644 index 0000000..8718858 --- /dev/null +++ b/app/models/session.rb @@ -0,0 +1,6 @@ +class Session < ActiveRecord::Base + + def self.cleanup_session(num = 60) + Session.delete_all(["updated_at < ?", num.minute.ago] ) + end +end diff --git a/app/models/shop.rb b/app/models/shop.rb new file mode 100644 index 0000000..e22fc6f --- /dev/null +++ b/app/models/shop.rb @@ -0,0 +1,85 @@ +class Shop < ActiveRecord::Base + + acts_as_paranoid + + belongs_to :prefecture + + validates_presence_of :name, :corp_name + validates_length_of :name,:name_kana,:corp_name,:corp_name_kana, :maximum => 50 + validates_format_of :name_kana, :with => System::KATAKANA_PATTERN + validates_format_of :corp_name_kana, :with => System::KATAKANA_PATTERN + + validates_presence_of :zipcode01, :zipcode02 + validates_numericality_of :zipcode01, :zipcode02 + validates_length_of :zipcode01, :maximum => 3 + validates_length_of :zipcode02, :maximum => 4 + + validates_presence_of :prefecture_id,:address_city, :address_details + validates_length_of :address_city, :address_details, :maximum => 50 + validates_inclusion_of :prefecture_id, :in => 1..47,:message => "を選択してください" + + validates_length_of :businesstime, :maximum => 50 + + validates_presence_of :mail_faq,:mail_sender,:mail_admin, :mail_shop + validates_length_of :mail_shop,:mail_faq,:mail_sender,:mail_admin, :maximum => 50, :allow_blank => true + + validates_length_of :trade_item,:introduction, :maximum => 99999 + + validates_length_of :tel01,:fax01, :maximum => 3 + validates_length_of :tel02,:tel03, :fax02, :fax03, :maximum => 4 + + + def validate_on_create + errors.add "","複数のデータは登録できません。" if Shop.count > 0 + end + + def validate + if self.tel01.size > 0 + unless self.tel01 =~ /^(\d+)$/ + errors.add(:tel01, "を正しく入力してください") + end + end + if self.tel02.size > 0 + unless self.tel02 =~ /^(\d+)$/ + errors.add(:tel02, "を正しく入力してください") + end + end + if self.tel03.size > 0 + unless self.tel03 =~ /^(\d+)$/ + errors.add(:tel03, "を正しく入力してください") + end + end + if self.fax01.size > 0 + unless self.fax01 =~ /^(\d+)$/ + errors.add(:fax01, "を正しく入力してください") + end + end + if self.fax02.size > 0 + unless self.fax02 =~ /^(\d+)$/ + errors.add(:fax02, "を正しく入力してください") + end + end + if self.fax03.size > 0 + unless self.fax03 =~ /^(\d+)$/ + errors.add(:fax03, "を正しく入力してください") + end + end + end + + # 表示系メソッド + def tel + "#{tel01}-#{tel02}-#{tel03}" + end + + def fax + "#{fax01}-#{fax02}-#{fax03}" + end + + def zipcode + "#{zipcode01}-#{zipcode02}" + end + + def address + prefecture.try(:name) + address_city + address_details + end +end diff --git a/app/models/status.rb b/app/models/status.rb new file mode 100644 index 0000000..c7f9d5e --- /dev/null +++ b/app/models/status.rb @@ -0,0 +1,5 @@ +class Status < ActiveRecord::Base + + acts_as_paranoid + belongs_to :products +end diff --git a/app/models/style.rb b/app/models/style.rb new file mode 100644 index 0000000..2240f29 --- /dev/null +++ b/app/models/style.rb @@ -0,0 +1,28 @@ +class Style < ActiveRecord::Base + acts_as_paranoid + acts_as_list + has_many :style_categories, :order => 'position' + has_many :product_styles, + :class_name => "ProductStyle", + :foreign_key => "style_id1" + has_many :product_styles, + :class_name => "ProductStyle", + :foreign_key => "style_id2" + validates_uniqueness_of :name, :message=>'は、既に使われています。' + def self.select_options(id = nil) + array = "" + find(:all).each{|s| + if s.style_categories.size > 0 + array += "