<commit_before>class WorkOrderController < ApplicationController
    include Databasedotcom::Rails::Controller

	def index
	end

	def check
		work_order_code = params[:work_order][:WorkOrderCode]

		if not work_order_code =~ /^[0-9]+$/
			flash[:notice] = "Not a numeric work order"
			redirect_to work_order_home_path
		elsif Care_Package__c.find_by_id__c(work_order_code) == nil
		 	flash[:notice] = "Invalid work order code"
		 	redirect_to work_order_home_path
		else
			redirect_to item_list_path(work_order_code)
		end
	end

	def add_to_work_order
	end

	def add_item_confirm
		item_code = params[:item][:ItemCode]
		quantity = params[:item][:Quantity]
		if not Inventory.where(code: item_code).first
			flash[:notice] = "invalid item code"
		elsif not quantity =~ /^[0-9]+$/
			flash[:notice] = "quantity must be numeric"
		elsif Integer(quantity) > Inventory.where(code: item_code).first.quantity
			flash[:notice] = "not enough items in inventory"
		end

		if flash[:notice]
			redirect_to add_item_path
		else
			# add functionality
			
			redirect_to item_list_path
		end
	end

	def item_list
		@entry = Care_Package__c.find_by_id__c(params[:id])
		@list_details = Program_Detail__c.find_all_by_Care_Package__c(@entry.Id)
	end

	def destroy
  		@item = Program_Detail__c.find(params[:id])
  		@item.delete
  		redirect_to item_list_path
	end
	<commit_msg>Adding works now<commit_after>class WorkOrderController < ApplicationController
    include Databasedotcom::Rails::Controller

	def index
	end

	def check
		work_order_code = params[:work_order][:WorkOrderCode]

		if not work_order_code =~ /^[0-9]+$/
			flash[:notice] = "Not a numeric work order"
			redirect_to work_order_home_path
		elsif Care_Package__c.find_by_id__c(work_order_code) == nil
		 	flash[:notice] = "Invalid work order code"
		 	redirect_to work_order_home_path
		else
			redirect_to item_list_path(work_order_code)
		end
	end

	def add_to_work_order
	end

	def add_item_confirm
		item_code = params[:item][:ItemCode]
		quantity = params[:item][:Quantity]
		# if not Inventory.where(code: item_code).first
		# 	flash[:notice] = "invalid item code"
		# elsif not quantity =~ /^[0-9]+$/
		# 	flash[:notice] = "quantity must be numeric"
		# elsif Integer(quantity) > Inventory.where(code: item_code).first.quantity
		# 	flash[:notice] = "not enough items in inventory"
		# end

		if flash[:notice]
			redirect_to add_item_path
		else
			# add functionality
			program_detail = Program_Detail__c.new
			program_detail.Care_Package__c = Care_Package__c.find_by_id__c(params[:id]).Id
			program_detail.Name = item_code
			program_detail.Quantity__c = quantity
			program_detail.Program_Item__c = Item__c.find_by_Code__c(item_code).Name
			program_detail.save
			redirect_to item_list_path
		end
	end

	def item_list
		@entry = Care_Package__c.find_by_id__c(params[:id])
		@list_details = Program_Detail__c.find_all_by_Care_Package__c(@entry.Id)
	end

	def destroy
  		@item = Program_Detail__c.find(params[:id])
  		@item.delete
  		redirect_to item_list_path
	end
	
{'fraction_non_alphanumeric': 0.0942838370565046, 'fraction_numerical': 0.002628120893561104, 'mean_word_length': 4.659851301115242, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '659418', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1057, 'n_words': 217}