|
|
@ -1746,24 +1746,26 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
# 删除
|
|
|
|
# 删除
|
|
|
|
def delete_applied_departments
|
|
|
|
def delete_applied_departments
|
|
|
|
applied_department = ApplyAddDepartment.find params[:depart_id]
|
|
|
|
transaction do
|
|
|
|
applied_message = AppliedMessage.where(:applied_id => applied_department.id, :applied_type => "ApplyAddDepartment")
|
|
|
|
applied_department = ApplyAddDepartment.find params[:depart_id]
|
|
|
|
applied_message.update_all(:status => 3)
|
|
|
|
applied_message = AppliedMessage.where(:applied_id => applied_department.id, :applied_type => "ApplyAddDepartment")
|
|
|
|
applied_department.update_attribute(:status, 3)
|
|
|
|
applied_message.update_all(:status => 3)
|
|
|
|
# 未审批删除
|
|
|
|
applied_department.update_attribute(:status, 3)
|
|
|
|
if params[:tip] == "unapplied"
|
|
|
|
# 未审批删除
|
|
|
|
# AppliedMessage.create(:user_id => applied_department.user_id, :status => 3, :viewed => 0, :applied_id => applied_department.id, :applied_type => "ApplyAddDepartment", :name => applied_department.name )
|
|
|
|
if params[:tip] == "unapplied"
|
|
|
|
Tiding.where(:user_id => 1, :trigger_user_id => applied_department.user_id, :container_id => applied_department.id, :container_type => 'ApplyAddDepartment', :status => 0, :tiding_type => "Apply").update_all(:status => 1)
|
|
|
|
# AppliedMessage.create(:user_id => applied_department.user_id, :status => 3, :viewed => 0, :applied_id => applied_department.id, :applied_type => "ApplyAddDepartment", :name => applied_department.name )
|
|
|
|
Tiding.create(:user_id => applied_department.user_id, :trigger_user_id => 0, :container_id => applied_department.id, :container_type =>'ApplyAddDepartment', :belong_container_id => applied_department.department.school_id, :belong_container_type=> 'School', :tiding_type => "System", :status => 2, :extra => params[:reason])
|
|
|
|
Tiding.where(:user_id => 1, :trigger_user_id => applied_department.user_id, :container_id => applied_department.id, :container_type => 'ApplyAddDepartment', :status => 0, :tiding_type => "Apply").update_all(:status => 1)
|
|
|
|
# 删除学校的用户
|
|
|
|
Tiding.create(:user_id => applied_department.user_id, :trigger_user_id => 0, :container_id => applied_department.id, :container_type =>'ApplyAddDepartment', :belong_container_id => applied_department.department.school_id, :belong_container_type=> 'School', :tiding_type => "System", :status => 2, :extra => params[:reason])
|
|
|
|
user_exs = UserExtensions.where("department_id = #{applied_department.department_id}")
|
|
|
|
# 删除学校的用户
|
|
|
|
users = User.where(id: user_exs.pluck(:user_id))
|
|
|
|
user_exs = UserExtensions.where("department_id = #{applied_department.department_id}")
|
|
|
|
user_exs.update_all(department_id: nil)
|
|
|
|
users = User.where(id: user_exs.pluck(:user_id))
|
|
|
|
users.update_all(profile_completed: false)
|
|
|
|
user_exs.update_all(department_id: nil)
|
|
|
|
applied_department.department.destroy
|
|
|
|
users.update_all(profile_completed: false)
|
|
|
|
# 已审批删除
|
|
|
|
applied_department.department.destroy
|
|
|
|
elsif params[:tip] == "applied"
|
|
|
|
# 已审批删除
|
|
|
|
applied_department.destroy
|
|
|
|
elsif params[:tip] == "applied"
|
|
|
|
|
|
|
|
applied_department.destroy
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html{ redirect_to depart_managements_path }
|
|
|
|
format.html{ redirect_to depart_managements_path }
|
|
|
|