{
	"name": "form/nc/nc-work-center/column/work.json",
	"option": {
		"grid_option": {
			"cell_class_rules-": {
				"red": "colDef.field === 'pro.production_order_state' && data.pro.production_order_state === 'stopped'",
				"darkblue": "data.pro.production_order_state === 'setup'",
				"lightblue": "data.pro.production_order_state === 'started'",
				"grey": "data.pro.production_order_state === 'done'",
				"brown": "data.virtual",
				"green": "data.calc?.can_start_amount > 0 && data.pro.production_order_state === 'confirmed'"
			},
			"row_class_rules": {
				"red": "data.pro.production_order_state === 'stopped'",
				"darkblue": "data.pro.production_order_state === 'setup' || (data.calc.started_amount > 0 && data.calc.done_amount < 1)",
				"lightblue": "data.pro.production_order_state === 'started' || data.calc.done_amount > 0",
				"grey": "data.pro.production_order_state === 'done'",
				"brown": "data.virtual",
				"green": "data.calc?.can_start_amount && data.calc.can_start_amount > 0 && data.pro.calc.material_can_start >= data.calc.can_start_amount && data.pro.production_order_state === 'confirmed'",
				"darkgreen": "data.calc?.can_start_amount && data.calc.can_start_amount > 0 && data.pro.calc.material_can_start < data.calc.can_start_amount && data.pro.production_order_state === 'confirmed'",
				"nc-grid-row-new": "data.calc && data.calc.change == 'new'",
				"nc-grid-row-changed": "data.calc && data.calc.change == 'modify'",
				"nc-grid-row-deleted": "data.calc && data.calc.change == 'delete'"
			}
		}
	},
	"column": [
		{
			"name": "",
			"width": 70,
			"variable": "idx",
			"link_field-": "prwo.record_id",
			"link_field": "pro.production_order_id",
			"record_type": "schedule",
			"include_form_id-": "start-stop",
			"include_row_count": 2,
			"move_row_column": "true"
		},
		{
			"name": "Resource",
			"name_fi": "Kuorm. ryhmä",
			"field": "prwo.resource_id",
			"width": 95
		},
		{
			"name": "Customer",
			"name_fi": "Asiakas",
			"field": "pro.company_id",
			"width": 110
		},
		{
			"name": "Order",
			"name_fi": "Myyntitil.",
			"field": "pro.sales_order_id",
			"width": 75
		},
		{
			"name": "Work name",
			"name_fi": "Työn nimi",
			"field": "pr.name",
			"width": 300
		},
		{
			"name": "Prod. ord.",
			"name_fi": "Valm. erä",
			"field": "prwo.production_order_id",
			"width": 125
		},
		{
			"name": "Phase",
			"name_fi": "Vaihe",
			"field": "prwo.calc.phase_total",
			"width": 60
		},
		{
			"name": "Drawing",
			"name_fi": "Piir. nro",
			"field": "pro.drawing_number",
			"width": 60,
			"hide": true
		},
		{
			"name": "Days",
			"width": 75,
			"name_fi": "Jäljellä",
			"variable": "prwo.calc.days_left",
			"cell_class": "gridGraph",
			"cell_graph_formatter": {
				"html": "<svg class='nc-cell-graph'><rect x='{{x}}%' y='5%' height='90%' width='{{size}}%' fill='{{color}}'></rect><text dy='75%'>{{value}}</text></svg>",
				"negative_from_end": true,
				"percent_color": [
					{
						"color": "red",
						"end": 0
					},
					{
						"color": "orange",
						"end": 8,
						"start": 0
					},
					{
						"color": "lightgreen",
						"end": 30,
						"start": 8
					},
					{
						"color": "MediumSeaGreen",
						"start": 30
					}
				],
				"percent_max": 30
			}
		},
		{
			"name": "Can start",
			"name_fi": "Voi aloittaa",
			"width": 80,
			"type": "integer",
			"cell_class_rules": {
				"white": "x === 0",
				"darkred": "x < 0"
			},
			"variable": "prwo.calc.can_start_amount"
		},
		{
			"name": "Mat. available",
			"name_fi": "Mater. riittää",
			"variable": "pro.calc.material_can_start",
			"width": 110,
			"type": "integer",
			"cell_class_rules": {
				"bold red": "x <= 0"
			}
		},
		{
			"name": "Started",
			"type": "integer",
			"width": 70,
			"cell_class_rules": {
				"white": "x === 0",
				"darkred": "x < 0"
			},
			"name_fi": "Aloitettu",
			"variable": "prwo.calc.started_amount"
		},
		{
			"name": "Person",
			"name_fi": "Henkilö",
			"variable": "prwo.calc.start_html",
			"width": 140
		},
		{
			"name": "Notes",
			"name_fi": "Kommentit",
			"variable": "prwo.calc.info",
			"width": 120
		},
		{
			"name": "Machine",
			"name_fi": "Kone",
			"field": "prwo.calc.machine.html",
			"width": 75,
			"hide": true
		},
		{
			"name": "Produced",
			"name_fi": "Tehty",
			"variable": "prwo.calc.done_amount",
			"type": "integer",
			"cell_class_rules": {
				"white": "x === 0",
				"darkred": "x < 0"
			},
			"width": 80,
			"cell_class": "gridGraph",
			"cell_graph_formatter": {
				"show_zero": false,
				"graph_value_from": "calc.done_fraction",
				"html": "<svg class='nc-cell-graph'><rect x='{{x}}%' y='4px' height='90%' width='{{size}}%' fill='{{color}}' opacity='0.5'></rect><text x='4px' y='18px'>{{value}}</text></svg>",
				"negative_from_end": true,
				"percent_color": [
					{
						"color": "orange",
						"start": 0,
						"end": 0.2
					},
					{
						"color": "lightgreen",
						"start": 0.2,
						"end": 0.8
					},
					{
						"color": "MediumSeaGreen",
						"start": 0.8,
						"end": 1
					},
					{
						"color": "grey",
						"start": 1,
						"end": 1.00001
					},
					{
						"color": "red",
						"start": 1.00001
					}
				],
				"percent_max": 1
			}
		},
		{
			"name": "Failed",
			"name_fi": "Susia",
			"width": 60,
			"variable": "prwo.calc.failed_amount",
			"cell_class_rules": {
				"white": "x === 0",
				"darkred": "x < 0"
			}
		},
		{
			"name": "Duration",
			"hide": true,
			"name_fi": "Kesto",
			"variable": "pro.calc.duration",
			"cell_class": ["oblique"],
			"type": "time",
			"cell_class_rules": {
				"white": "x === 0",
				"darkred": "x < 0"
			},
			"width": 75
		},
		{
			"name": "Setup time",
			"width": 90,
			"field": "prwo.setup_hours",
			"name_fi": "As. aika",
			"format": "%'.2f",
			"group": ["work_time"],
			"footerValue": "==Sum"
		},
		{
			"name": "Work time",
			"width": 85,
			"field": "prwo.work_hours",
			"name_fi": "Aika/erä",
			"format": "%'.2f",
			"group": ["work_time"],
			"footerValue": "==Sum"
		},
		{
			"name": "Prod. ord.",
			"name_fi": "Työm. tila",
			"field": "pro.production_order_state",
			"cell_class": ["oblique", "center"],
			"value_map": "plugin/nc-calc-server/constant.json/production_order_state_view",
			"width": 90,
			"cell_class_rules": {
				"red": "x === 'stopped'",
				"darkblue": "x === 'setup'",
				"lightblue": "x === 'started'",
				"grey": "x === 'done'"
			}
		},
		{
			"name": "Need",
			"name_fi": "Tarve",
			"type": "integer",
			"field": "pro.amount_to_produce",
			"cell_class": ["oblique"],
			"width": 60
		},
		{
			"name": "Produced",
			"type": "integer",
			"width": 80,
			"name_fi": "Valmistunut",
			"field": "pro.produced_amount",
			"cell_class": ["oblique", "gridGraph"],
			"cell_graph_formatter": {
				"show_zero": false,
				"graph_value_from": "pro.calc.produced_fraction",
				"html": "<svg class='nc-cell-graph'><rect x='{{x}}%' y='4px' height='90%' width='{{size}}%' fill='{{color}}' opacity='0.5'></rect><text x='4px' y='18px'>{{value}}</text></svg>",
				"negative_from_end": true,
				"percent_color": [
					{
						"color": "orange",
						"start": 0,
						"end": 0.2
					},
					{
						"color": "lightgreen",
						"start": 0.2,
						"end": 0.8
					},
					{
						"color": "MediumSeaGreen",
						"start": 0.8,
						"end": 1
					},
					{
						"color": "grey",
						"start": 1,
						"end": 1.00001
					},
					{
						"color": "red",
						"start": 1.00001
					}
				],
				"percent_max": 1
			}
		},
		{
			"name": "Failed",
			"name_fi": "Susia",
			"width": 60,
			"variable": "pro.failed_amount",
			"cell_class": ["oblique"],
			"cell_class_rules": {
				"white": "x === 0",
				"darkred": "x < 0"
			}
		},
		{
			"name": "Remaining",
			"field": "pro.remaining_amount",
			"cell_class": ["oblique"],
			"width": 90,
			"name_fi": "Jäljellä"
		},
		{
			"name": "Start",
			"name_fi": "Vaih. alkupäivä",
			"field": "prwo.json_data.critical_start_date",
			"type": "date",
			"width": 95
		},
		{
			"name": "Deliv. date",
			"name_fi": "Työm. kr pv",
			"field": "pro.json_data.critical_end_date",
			"cell_class": ["oblique"],
			"type": "date",
			"width": 95
		},
		{
			"name": "End",
			"name_fi": "Vaih. eräp. norm",
			"field": "prwo.json_data.critical_end_date",
			"type": "date",
			"width": 95
		},
		{
			"name": "Mat. batch",
			"width": 100,
			"name_fi": "Mater. erä",
			"field": "prwo.json_data.material_batch"
		},
		{
			"name": "Description",
			"name_fi": "Kuvaus",
			"field": "prwo.description",
			"width": 250
		},
		{
			"name": "Product",
			"name_fi": "Tuote",
			"field": "pr.product_id",
			"width": 210
		},
		{
			"name": "Prod. ord. info",
			"name_fi": "Työm. lisätietoja",
			"cell_class": ["oblique"],
			"field": "pro.info",
			"width": 650
		},
		{
			"name": "db",
			"name_fi": "tk",
			"variable": "pro.from_db",
			"width": 43
		},
		{
			"name": "id",
			"name_fi": "id",
			"field": "prwo.record_id",
			"width": 160
		}
	],
	"calculated_column": [
		{
			"name": "Start time",
			"name_fi": "Aloitusaika",
			"field": "pro.json_data.start_time",
			"type": "time",
			"width": 90
		},
		{
			"name": "",
			"name_fi": "Ohj.\raika",
			"field": "",
			"field-": "ld_work_agTrackTimeGraph",
			"width": 47
		},
		{
			"name": "",
			"name_fi": "RA",
			"field": "",
			"field-": "ld_work_alRawMaterialState",
			"width": 65
		},
		{
			"name": "",
			"name_fi": "Kiireellisyys",
			"field": "",
			"field-": "ld_work_agGraph",
			"width": 180
		},
		{
			"name": "",
			"name_fi": "Vaiheita\rennen",
			"field": "",
			"field-": "ld_work_alPhasesBefore",
			"width": 61
		},
		{
			"name": "",
			"name_fi": "Kumul",
			"field": "",
			"field-": "ld_work_arCumulativeFree",
			"width": 140
		},
		{
			"name": "",
			"name_fi": "Voi aloittaa",
			"info": "material phase: PrevPhaseProducedAmount-prwo.produced_amount, own phase: PrevPhaseProducedAmount-prwo.produced_amount-wosfailed_amount, subcontract phase: PrevPhaseProducedAmount-prwo.produced_amount-wosfailed_amount-porComingAmount",
			"field": "",
			"field-": "ld_work_arAmountToStart",
			"width": 59
		},
		{
			"name": "",
			"name_fi": "Valm. %",
			"info": "(wpaWorkTimeSum/prwo.json_data.target_time)*100",
			"field": "",
			"field-": "ld_work_arWorkTimeProgress",
			"width": 160
		},
		{
			"name": "",
			"name_fi": "Ero",
			"info": "EndDate (many optional dates) - CurrentDate",
			"field": "",
			"field-": "ld_work_alDaysToFinish",
			"width": 44
		}
	],
	"columns_fix": [
		{
			"name": "Row",
			"name_fi": "Rivi",
			"field": "pro.row_number",
			"width": 60,
			"hide": true
		},
		{
			"name": "Phase",
			"name_fi": "Tila",
			"field": "prwo.work_phase_state",
			"field-": "prwo.json_data.start_time",
			"width": 80
		},
		{
			"name": "Active",
			"field": "prwo.active_state",
			"name_fi": "Akt.",
			"width": 80,
			"organization_id": { "4d": { "load": false } }
		},
		{
			"name": "Work ord.",
			"width": 85,
			"name_fi": "Työmäär.",
			"field": "pro.json_data.production_order_number"
		},
		{
			"name": "Phase start",
			"name_fi": "Vaih. alkupäivä",
			"field": "prwo.json_data.critical_start_time",
			"type": "time",
			"width": 100
		},
		{
			"name": "Cr. end date",
			"name_fi": "Vaih. eräp. norm",
			"field": "prwo.json_data.critical_end_time",
			"type": "time",
			"width": 100
		},
		{
			"name": "Cr. end prep.",
			"name_fi": "Vaih. eräp. aik.",
			"field": "prwo.json_data.critical_delayed_end_date",
			"width": 100
		},
		{
			"name": "Recl.",
			"name_fi": "Rekl.",
			"field": "prwo.json_data.reclamation_count",
			"width": 120
		},
		{
			"name": "Name",
			"name_fi": "Asiakkaan nimi",
			"field": "co.name",
			"width": 100
		},
		{
			"name": "",
			"name_fi": "Vaihe",
			"field": "prwo.json_data.production_lot__work_ph",
			"width": 120
		},
		{
			"name": "",
			"name_fi": "On AH",
			"field": "prwo.json_data.subcontract",
			"width": 140
		},
		{
			"name": "",
			"name_fi": "Vaiheaika",
			"field": "prwo.work_hours",
			"width": 66
		},
		{
			"name": "",
			"name_fi": "Asetusaika",
			"field": "prwo.setup_hours",
			"width": 66
		},
		{
			"name": "",
			"name_fi": "Koneaika",
			"field": "prwo.machine_hours",
			"width": 66
		},
		{
			"name": "",
			"name_fi": "Toim. asiakkaalle",
			"field": "prwo.json_data.delivery_to_customer",
			"width": 180
		},
		{
			"name": "",
			"name_fi": "Standardiaika [t/erä]:",
			"field": "prwo.json_data.target_time",
			"width": 180
		},
		{
			"name": "",
			"name_fi": "Alatila",
			"field": "prwo.json_data.substate",
			"width": 46
		},
		{
			"name": "",
			"name_fi": "Piirustus",
			"field": "pro.drawing_number",
			"width": 83
		},
		{
			"name": "",
			"name_fi": "Ohj. aika",
			"field": "prwo.json_data.track_time_status",
			"cell_class": "gridGraph",
			"cell_graph_formatter-": {
				"html": "<svg width='100%' height='100%'><circle cx='60%' cy='60%' r='0.5em' fill='{{color}}'></circle><text dy='75%'>{{value}}</text></svg>",
				"value_color": [
					{
						"color": "none",
						"end": 0
					},
					{
						"color": "none",
						"end": 1,
						"start": 0
					},
					{
						"color": "orange",
						"end": 2,
						"start": 1
					},
					{
						"color": "lightgreen",
						"end": 3,
						"start": 2
					},
					{
						"color": "DarkGrey",
						"end": 4,
						"start": 3
					},
					{
						"color": "red",
						"start": 4
					}
				]
			},
			"width": 140
		},
		{
			"name": "",
			"name_fi": "Rekl. mrä",
			"field": "prwo.json_data.reclamation_count",
			"width": 66
		},
		{
			"name": "",
			"name_fi": "Järj.",
			"field": "xx",
			"width": 48
		},
		{
			"name": "",
			"name_fi": "Lisäaika",
			"field": "prwo.extra_hours",
			"width": 85
		},
		{
			"name": "",
			"name_fi": "Kriittinen pv",
			"field": "pro.json_data.critical_delayed_end_date",
			"field-": "ld_work_adCriticalDateDelayed",
			"width": 73
		},
		{
			"name": "",
			"name_fi": "Kr. pv AITO",
			"field": "pro.json_data.critical_real_end_date",
			"field-": "ld_work_adCriticalDateReal",
			"width": 73
		},
		{
			"name": "",
			"name_fi": "Dok",
			"field": "pr.json_data.document_count",
			"field-": "ld_work_alDocumentCount",
			"width": 55
		},
		{
			"name": "",
			"name_fi": "T/V",
			"field": "pr.production_type",
			"field-": "ld_work_alProductionControlType",
			"width": 42
		},
		{
			"name": "",
			"name_fi": "Luk.",
			"field": "xx",
			"field-": "ld_work_alOtherPhaseLockedState",
			"width": 55
		},
		{
			"name": "",
			"name_fi": "Vaiheaika s",
			"field": "prwo.json_data.planned_work_time",
			"field-": "ld_work_arPlannedWorkTime",
			"width": 55
		},
		{
			"name": "",
			"name_fi": "Jonoalku",
			"field": "prwo.json_data.start_time",
			"field-": "ld_work_adStart_Date",
			"width": 73
		},
		{
			"name": "",
			"name_fi": "Jonoalku",
			"field": "prwo.json_data.start_time",
			"field-": "ld_work_ahStart_Time",
			"width": 73
		},
		{
			"name": "",
			"name_fi": "Jonoloppu",
			"field": "prwo.json_data.end_time",
			"field-": "ld_work_adEnd_Date",
			"width": 73
		},
		{
			"name": "",
			"name_fi": "Jonoloppu",
			"field": "prwo.json_data.end_time",
			"field-": "ld_work_adEnd_Time",
			"width": 73
		},
		{
			"name": "",
			"name_fi": "Viiväst.",
			"field": "prwo.json_data.delay",
			"field-": "ld_work_arDelay",
			"width": 73
		},
		{
			"name": "",
			"name_fi": "Aikaist.",
			"field": "prwo.json_data.advance",
			"field-": "ld_work_arAdvance",
			"width": 58
		}
	]
}
