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
+ @shop = Shop.find(:first) || Shop.new
+ @shop.attributes = params[:shop]
+ @system = System.find(:first) || System.new
+ @system.attributes = params[:system]
unless @shop.valid? && @system.valid?
- flash.now[:error] = "保存に失敗しました"
render :action => "index"
return
end
if @system.save && @shop.save
- flash.now[:notice] = "データを保存しました"
+ flash[:shop_update] = "データを保存しました"
else
- flash.now[:error] = "データの保存に失敗しました"
+ flash[:shop_update_e] = "データの保存に失敗しました"
end
redirect_to :action => "index"
end
#使用機能一覧
def settings
-
+ #初期化
+ @system ||= System.new
+ @system.supplier_use_flag ||= false
end
#使用機能設定
def settings_update
end
#仕入先を使用するかどうか設定
def supplier_update
+ @system ||= System.new
@system.attributes = params[:system]
if @system.save
if @system.supplier_use_flag
#使用する->使用しない変更する時、既存の仕入先をそのまま
#supplier_use_flagの変更のみ
redirect_to :controller => "suppliers",:action => ""
+ return
else
- flash.now[:notice] = "仕入先を使用しないように設定しました"
- render :action => "settings"
+ flash[:system_update] = "仕入先を使用しないように設定しました"
+ redirect_to :controller => "shops",:action => "settings"
+ return
end
else
flash.now[:error] = "設定に失敗しました"
render :action => "settings"
+ return
end
end
end
#仕入先を使用しているかしないと判断のフィルタ
def check_supplier_use
- unless @system.supplier_use_flag
+ unless @system_supplier_use_flag
redirect_to :controller=>"/admin/home"
return
end
def load_system
@system = System.find(:first)
- @system.supplier_use_flag ||= false
+ @system_supplier_use_flag = true if @system && @system.supplier_use_flag
end
#郵便番号から住所を取得
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_presence_of :mail_faq,:mail_sender,:mail_admin
+ validates_length_of :mail_faq,:mail_sender,:mail_admin, :maximum => 50, :allow_blank => true
validates_length_of :trade_item,:introduction, :maximum => 99999
</script>\r
<div id="sub"><!-- サブメニュー -->\r
<div id="menu" class="clearfix"><!-- g_menu -->\r
- <% if @system.supplier_use_flag %>\r
+ <% if @system_supplier_use_flag %>\r
<p><a href="JavaScript:onClick=Tree('display1');ImgC('img1');"><img src="/images/menu_icon.gif" width="36" height="36" alt="" id="img1" /><span>仕入先管理</span></a></p>\r
<ul id="display1" style="display:block">\r
<li><%= link_to '仕入先マスタ管理', {:controller => 'suppliers', :action => 'index'} %></li>\r
<p id="category_info">編集したいカテゴリをクリックして下さい。</p>
<a href="/admin/shops"><img src="/images/store_btn_l.gif" width="222" height="138" alt="店舗管理" /></a>
<a href="/admin/products"><img src="/images/goods_btn_l.gif" width="222" height="138" alt="商品管理" id="category_img" /></a>
- <% if @system.supplier_use_flag %>
+ <% if @system_supplier_use_flag %>
<a href="/admin/suppliers"><img src="/images/order_btn_l.gif" width="222" height="138" alt="発注・出荷管理" /></a>
<%else%>
<a href="/admin/stock_in"><img src="/images/order_btn_l.gif" width="222" height="138" alt="発注・出荷管理" /></a>
<%= confirm_tag :text_field, :product, :name, :class=>"data_m" %> (上限50文字)
</td>
</tr>
- <%if @system.supplier_use_flag%>
+ <%if @system_supplier_use_flag%>
<tr>
<th>仕入先名<span class="pnt">※</span></th>
<td><%suppliers = Supplier.find(:all,:order=>'id')%>
<th>商品名</th>
<td><%= f.text_field :name, :class=>"data_m" %></td>
</tr>
- <%if @system.supplier_use_flag%>
+ <%if @system_supplier_use_flag%>
<tr>
<th>仕入先名</th>
<td><%suppliers = Supplier.find(:all,:order=>'id')%>
-<%=h flash[:notice] %>
-<%=h flash[:error] %>
+<%=h flash[:shop_update] %>
+<%=h flash[:shop_update_e] %>
<%= error_messages_for :shop %>
<%= error_messages_for :system %>
<p class="req"><span class="pnt">※</span>は必須入力です</p>
-<%=h flash[:notice] %>
+<%=h flash[:system_update] %>
<%=h flash[:error] %>
-<%= error_messages_for :shop %>
+<%= error_messages_for :system %>
<!--仕入先-->
<% form_for :system, :url =>{:action => "settings_update"} do |f|%>
<table cellspacing="1" cellpadding="0" class="data" >
<%= h(@stock_history.product.name) %>
</td>
</tr>
- <%if @system.supplier_use_flag%>
+ <%if @system_supplier_use_flag%>
<tr>
<th>仕入先名</th>
<td><%= h(@stock_history.product.supplier_name) %></td>
<%= h(@product_style.product_name) %>
</td>
</tr>
- <%if @system.supplier_use_flag%>
+ <%if @system_supplier_use_flag%>
<tr>
<th>仕入先名</th>
<td><%= h(@product_style.product.supplier_name) %></td>
<th>商品型番</th>
<td><%= f.text_field :manufacturer, :class=>"data_m" %></td>
</tr>
- <%if @system.supplier_use_flag%>
+ <%if @system_supplier_use_flag%>
<tr>
<th>仕入先名</th>
<td><%suppliers = Supplier.find(:all,:order=>'id')%>
<%= h(@product_style.product_name) %>
</td>
</tr>
- <%if @system.supplier_use_flag%>
+ <%if @system_supplier_use_flag%>
<tr>
<th>仕入先名</th>
<td><%= h(@product_style.product.supplier_name) %></td>
<th>商品型番</th>
<td><%= f.text_field :manufacturer, :class=>"data_m" %></td>
</tr>
- <%if @system.supplier_use_flag%>
+ <%if @system_supplier_use_flag%>
<tr>
<th>仕入先名</th>
<td><%suppliers = Supplier.find(:all,:order=>'id')%>
<ul id="con_menu" class="clearfix">
<li><a href="/admin/shops" id="shop"><img src="/images/store_btn.gif" width="122" height="51" alt="店舗管理" class="hoverImg" /></a></li>
<li><a href="/admin/products" id="product"><img src="/images/goods_btn.gif" width="122" height="51" alt="商品管理" class="hoverImg" /></a></li>
- <% if @system.supplier_use_flag %>
+ <% if @system_supplier_use_flag %>
<li><a href="/admin/suppliers" id="depot"><img src="/images/order_btn.gif" width="122" height="51" alt="発注出荷管理" class="hoverImg" /></a></li>
<%else%>
<li><a href="/admin/stock_in" id="depot"><img src="/images/order_btn.gif" width="122" height="51" alt="発注出荷管理" class="hoverImg" /></a></li>
@shop.should_not be_valid
end
- it "注文受付メールアドレス : 必須" do
- @shop.mail_shop = ""
- @shop.should_not be_valid
- end
-
- it "注文受付メールアドレス フォーマット" do
- @shop.mail_shop = 'foo@example.com'
- @shop.should be_valid
- @shop.mail_shop = 'foo.bar@example.com'
- @shop.should be_valid
- @shop.mail_shop = 'foo+bar@example.com'
- @shop.should be_valid
- @shop.mail_shop = 'foo@example'
- @shop.should_not be_valid
- @shop.mail_shop = 'foo@example.'
- @shop.should_not be_valid
- @shop.mail_shop = 'foo@.com'
- @shop.should_not be_valid
- @shop.mail_shop = 'foo'
- @shop.should_not be_valid
- @shop.mail_shop = 'foo@'
- @shop.should_not be_valid
- @shop.mail_shop = '@example.com'
- @shop.should_not be_valid
- end
-
- it "注文受付メールアドレス 50 文字まで" do
- suffix = '@example.com'
- name = 'x' * (50 - suffix.size)
- email = name + suffix
- email.size.should == 50
- @shop.mail_shop = email
- @shop.should be_valid
- @shop.mail_shop = 'x'+email
- @shop.should_not be_valid
- end
-
it "問合せ受付メールアドレス : 必須" do
@shop.mail_faq = ""
@shop.should_not be_valid