{
	"name": "table/manager/product/product_work.json",
	"table_name": "product_work",
	"table_prefix": "prwo",
	"record_type": ["actual", "estimated", "schedule"],
	"main_table": "product",
	"default_order": [
	{
		"order": ">",
		"field": "material_id"
	},
	{
		"order": ">",
		"field": "work_phase_number"
	}],
	"save_script": [],
	"calculated_field":
	{
		"production_order_schedule_id":
		{
			"info": "link between work_phase_actual and production_order_schedule",
			"type": "text",
			"code": ["concat", ["prwo_production_lot", "#", "prwo_work_phase_number"]],
			"foreign_key": [
			{
				"link_type": "",
				"linked_record_type": "schedule",
				"linking_record_type": "actual"
			}]
		},
		"units_in_hour":
		{
			"type": "double",
			"code": [
				["prwo_units_in_hour", "=", [1, "/", "prwo_work_hours"]]
			],
			"run_script": ["prwo_units_in_hour", "prwo_work_hours"],
			"script": [
				["prwo_work_hours", "=", [1, "/", "prwo_units_in_hour"]],
				["prwo_C_KENTAT"]
			]
		}
	},
	"field": [
	{
		"field_name": "cost_price",
		"field_type": "double"
	},
	{
		"field_name": "description",
		"field_type": "text"
	},
	{
		"field_name": "event_time",
		"field_type": "datetime"
	},
	{
		"field_name": "extra_hours",
		"field_type": "double"
	},
	{
		"field_name": "failed_amount",
		"field_type": "double"
	},
	{
		"field_name": "info",
		"field_type": "text"
	},
	{
		"field_name": "machine_hours",
		"field_type": "double"
	},
	{
		"length": 80,
		"field_name": "person_id",
		"field_type": "varchar",
		"foreign_key": [
		{
			"link_type": "prevent delete",
			"linked_field": "person_id",
			"linked_record_type": "",
			"linked_table": "person",
			"linking_record_type": ""
		}]
	},
	{
		"field_name": "produced_amount",
		"field_type": "double"
	},
	{
		"length": 80,
		"field_name": "product_id",
		"field_type": "varchar",
		"foreign_key": [
		{
			"link_type": "prevent delete",
			"linked_field": "product_id",
			"linked_record_type": "product",
			"linked_table": "product",
			"linking_record_type": "product"
		},
		{
			"info": "aga, check",
			"link_type": "prevent delete",
			"linked_field": "product_id",
			"linked_record_type": "estimated",
			"linked_table": "product_work",
			"linking_record_type": "actual"
		},
		{
			"info": "aga, check",
			"link_type": "",
			"linked_field": "product_id",
			"linked_record_type": "schedule",
			"linked_table": "product_work",
			"linking_record_type": "actual"
		}]
	},
	{
		"field_name": "product_work_state",
		"field_type": "integer"
	},
	{
		"length": 40,
		"field_name": "production_lot",
		"field_type": "varchar",
		"foreign_key": [
		{
			"link_type": "prevent delete",
			"linked_field": "production_lot",
			"linked_record_type": "",
			"linked_table": "production_order",
			"linking_record_type": ""
		}]
	},
	{
		"field_name": "profit_multiplier",
		"field_type": "double"
	},
	{
		"length": 20,
		"allowed_value": ["estimated", "actual", "schedule"],
		"field_name": "record_type",
		"field_type": "varchar"
	},
	{
		"field_name": "remaining_amount",
		"field_type": "double"
	},
	{
		"length": 40,
		"constraint":
		{
			"save":
			{
				"allow": [
				{
					"code": [
						["prwo_resource_id", "<>", ""]
					],
					"message": "field '%s' may not be empty"
				}]
			}
		},
		"field_name": "resource_id",
		"field_type": "varchar",
		"foreign_key": [
		{
			"link_type": "prevent delete",
			"linked_field": "resource_id",
			"linked_record_type": "",
			"linked_table": "resource",
			"linking_record_type": ""
		}]
	},
	{
		"field_name": "salary",
		"field_type": "double"
	},
	{
		"field_name": "sales_price",
		"field_type": "double"
	},
	{
		"field_name": "setup_hourly_salary",
		"field_type": "double"
	},
	{
		"field_name": "setup_hourly_self_cost",
		"field_type": "double"
	},
	{
		"field_name": "setup_hours",
		"field_type": "double"
	},
	{
		"field_name": "started_amount",
		"field_type": "double"
	},
	{
		"field_name": "subcontract",
		"field_type": "boolean"
	},
	{
		"length": 40,
		"field_name": "subcontractor_id",
		"field_type": "varchar",
		"foreign_key": [
		{
			"link_type": "prevent delete",
			"linked_field": "company_id",
			"linked_record_type": "",
			"linked_table": "company",
			"linking_record_type": ""
		}],
		"nullable": true
	},
	{
		"field_name": "work_hourly_salary",
		"field_type": "double"
	},
	{
		"field_name": "work_hourly_self_cost",
		"field_type": "double"
	},
	{
		"field_name": "work_hours",
		"field_type": "double"
	},
	{
		"field_name": "work_phase_number",
		"field_type": "integer"
	},
	{
		"length": 40,
		"field_name": "work_phase_state",
		"field_type": "varchar"
	},
	{
		"length": 40,
		"field_name": "work_phase_type",
		"field_type": "varchar"
	}],
	"extra_field": [
	{
		"field_name": "json_data.extra_end_time",
		"field_type": "time"
	},
	{
		"field_name": "json_data.est_contract_price__unit",
		"field_type": "double"
	},
	{
		"field_name": "json_data.track_time_status",
		"field_type": "integer"
	},
	{
		"field_name": "json_data.evening_work_hours",
		"field_type": "double"
	},
	{
		"field_name": "json_data.social_cost_multiplier",
		"field_type": "double"
	},
	{
		"field_name": "json_data.kind",
		"field_type": "double"
	},
	{
		"field_name": "json_data.rest_time__hour",
		"field_type": "double"
	},
	{
		"field_name": "json_data.est_setup_salary__hour",
		"field_type": "double"
	},
	{
		"length": 24,
		"field_name": "json_data.user_id",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.firm_id",
		"field_type": "integer"
	},
	{
		"length": 80,
		"field_name": "json_data.next_phase",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.reclamation_count",
		"field_type": "integer"
	},
	{
		"field_name": "json_data.est_work_time__unit",
		"field_type": "double"
	},
	{
		"field_name": "json_data.delay",
		"field_type": "double"
	},
	{
		"length": 24,
		"field_name": "json_data.employee_id",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.critical_end_time",
		"field_type": "time"
	},
	{
		"field_name": "json_data.est_machine_setup_cost__hour",
		"field_type": "double"
	},
	{
		"field_name": "json_data.subcont_cost_total",
		"field_type": "double"
	},
	{
		"field_name": "json_data.purchase_multiplier",
		"field_type": "double"
	},
	{
		"field_name": "json_data.target_machine_time",
		"field_type": "double"
	},
	{
		"field_name": "json_data.planned_work_time",
		"field_type": "double"
	},
	{
		"field_name": "json_data.contract_default_salary",
		"field_type": "double"
	},
	{
		"length": 80,
		"field_name": "json_data.program_id",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.transfer_state",
		"field_type": "integer"
	},
	{
		"length": 40,
		"field_name": "json_data.modifier_id",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.work_sales_price_total",
		"field_type": "double"
	},
	{
		"field_name": "json_data.critical_start_time",
		"field_type": "time"
	},
	{
		"field_name": "json_data.work_cost_total",
		"field_type": "double"
	},
	{
		"field_name": "json_data.start_date",
		"field_type": "date"
	},
	{
		"length": 80,
		"field_name": "json_data.prod_lot__linked_phase",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.subcont_purc_price__unit",
		"field_type": "double"
	},
	{
		"field_name": "json_data.subcontract_purchase_price",
		"field_type": "double"
	},
	{
		"field_name": "json_data.setup_amount",
		"field_type": "double"
	},
	{
		"length": 20,
		"field_name": "json_data.stock_event_id",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.load_multiplier",
		"field_type": "double"
	},
	{
		"length": 80,
		"field_name": "json_data.project_id",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.subc_profit_multiplier",
		"field_type": "double"
	},
	{
		"field_name": "json_data.contract_price__unit",
		"field_type": "double"
	},
	{
		"length": 80,
		"field_name": "json_data.parcel_code",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.speed_unit",
		"field_type": "double"
	},
	{
		"field_name": "json_data.critical_extra_end_time",
		"field_type": "time"
	},
	{
		"field_name": "json_data.unpaid_hours",
		"field_type": "double"
	},
	{
		"field_name": "json_data.subcont_sales_price_total",
		"field_type": "double"
	},
	{
		"field_name": "json_data.critical_delayed_start_date",
		"field_type": "date"
	},
	{
		"field_name": "json_data.delivery_to_customer",
		"field_type": "integer"
	},
	{
		"field_name": "json_data.subcont_cost__unit",
		"field_type": "double"
	},
	{
		"length": 80,
		"field_name": "json_data.customer_project",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.phase_number",
		"field_type": "integer"
	},
	{
		"field_name": "json_data.est_bonus_work_time__unit",
		"field_type": "double"
	},
	{
		"field_name": "json_data.work_time__lot",
		"field_type": "double"
	},
	{
		"field_name": "json_data.est_salary__hour",
		"field_type": "double"
	},
	{
		"field_name": "json_data.link_target",
		"field_type": "integer"
	},
	{
		"field_name": "json_data.contract_salary",
		"field_type": "boolean"
	},
	{
		"field_name": "json_data.salary_bonus",
		"field_type": "double"
	},
	{
		"field_name": "json_data.work_salary__unit",
		"field_type": "double"
	},
	{
		"field_name": "json_data.work_shift",
		"field_type": "integer"
	},
	{
		"field_name": "json_data.link_to_start",
		"field_type": "boolean"
	},
	{
		"length": 60,
		"field_name": "json_data.work_number",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.units_in_hour",
		"field_type": "double"
	},
	{
		"field_name": "json_data.run_amount",
		"field_type": "integer"
	},
	{
		"field_name": "json_data.urgency_index",
		"field_type": "double"
	},
	{
		"field_name": "json_data.hourly_salary",
		"field_type": "boolean"
	},
	{
		"field_name": "json_data.target_time",
		"field_type": "double"
	},
	{
		"length": 60,
		"field_name": "json_data.work__position_num_id",
		"field_type": "varchar"
	},
	{
		"length": 120,
		"field_name": "json_data.transfer_id",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.track_time",
		"field_type": "double"
	},
	{
		"field_name": "json_data.start_work_shift",
		"field_type": "integer"
	},
	{
		"field_name": "json_data.target_extra_time",
		"field_type": "double"
	},
	{
		"length": 80,
		"field_name": "json_data.production_lot__work_ph",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.bonus_work_time__unit",
		"field_type": "double"
	},
	{
		"length": 160,
		"field_name": "json_data.tag",
		"field_type": "varchar"
	},
	{
		"length": 40,
		"field_name": "json_data.supplier_id",
		"field_type": "varchar"
	},
	{
		"length": 40,
		"field_name": "json_data.subtype",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.subcont_sales_price__unit",
		"field_type": "double"
	},
	{
		"field_name": "json_data.end_date",
		"field_type": "date"
	},
	{
		"field_name": "json_data.target_extra_time__unit",
		"field_type": "double"
	},
	{
		"field_name": "json_data.start_time",
		"field_type": "time"
	},
	{
		"field_name": "hours",
		"field_type": "double"
	},
	{
		"length": 40,
		"field_name": "json_data.start_subtype",
		"field_type": "varchar"
	},
	{
		"length": 24,
		"field_name": "json_data.start_person_id",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.special_extra_hours",
		"field_type": "double"
	},
	{
		"field_name": "json_data.critical_delayed_end_date",
		"field_type": "date"
	},
	{
		"field_name": "json_data.pieces__unit",
		"field_type": "double"
	},
	{
		"field_name": "json_data.end_time",
		"field_type": "time"
	},
	{
		"field_name": "json_data.night_work_hours",
		"field_type": "double"
	},
	{
		"field_name": "json_data.critical_date_difference",
		"field_type": "integer"
	},
	{
		"field_name": "json_data.work_phase_actual_id",
		"field_type": "integer"
	},
	{
		"field_name": "json_data.measured_track_time",
		"field_type": "double"
	},
	{
		"length": 40,
		"field_name": "json_data.cost_center",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.work_time",
		"field_type": "double"
	},
	{
		"field_name": "json_data.est_machine_work_cost__hour",
		"field_type": "double"
	},
	{
		"field_name": "json_data.act_end_date",
		"field_type": "date"
	},
	{
		"length": 80,
		"field_name": "json_data.previous_phase",
		"field_type": "varchar"
	},
	{
		"length": 4,
		"field_name": "json_data.cover__inside",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.setup_hours",
		"field_type": "double"
	},
	{
		"field_name": "json_data.linking_hours",
		"field_type": "double"
	},
	{
		"field_name": "json_data.advance",
		"field_type": "double"
	},
	{
		"field_name": "json_data.material_owner",
		"field_type": "integer"
	},
	{
		"length": 80,
		"field_name": "json_data.smelting_num",
		"field_type": "varchar"
	},
	{
		"field_name": "json_data.contract_multiplier",
		"field_type": "double"
	},
	{
		"field_name": "json_data.extra_end_date",
		"field_type": "date"
	},
	{
		"field_name": "json_data.critical_end_date",
		"field_type": "date"
	},
	{
		"field_name": "json_data.critical_extra_end_date",
		"field_type": "date"
	},
	{
		"field_name": "json_data.critical_extra_end_time",
		"field_type": "time"
	},
	{
		"field_name": "json_data.critical_start_date",
		"field_type": "date"
	},
	{
		"field_name": "json_data.est_setup_hours",
		"field_type": "double"
	},
	{
		"field_name": "json_data.previous_track_time",
		"field_type": "double"
	}],
	"default_field": "table/default_field.json",
	"field_change": [
	{
		"name": "product_work_state",
		"old_name": ["record_state"]
	}]
}
