<?php

namespace App\Reports\Sources\UnbalancedRows;

class ColumnsManager extends \App\Reports\Sources\ColumnsManagerAbstract
{

	/**
	 * The definition of report source columns.
	 * @var array
	 */
	protected array $columnsCfg = [

		'currentRowIndex'		=> [ 'type' => 'numeric',   'dbDef' => "INT UNSIGNED NOT NULL DEFAULT 0",					'cat' => "invoice"],
		'inv_id' 				=> [ 'type' => 'numeric', 	'dbDef' => "BIGINT UNSIGNED NOT NULL DEFAULT 0", 				'cat' => "invoice"],
		'inv_number' 			=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(20) NOT NULL DEFAULT ''", 					'cat' => "invoice"],
		'inv_date' 				=> [ 'type' => 'date', 		'dbDef' => "DATE NULL", 										'cat' => "invoice"],
		'inv_seriesId' 			=> [ 'type' => 'numeric', 	'dbDef' => "MEDIUMINT UNSIGNED NOT NULL DEFAULT 0", 			'cat' => "invoice"],
		'inv_seriesCode' 		=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''", 					'cat' => "invoice"],
		'inv_statusCode'  		=> [ 'type' => 'string', 	'dbDef' => "ENUM ('n', 'p', 't', 'o') NOT NULL DEFAULT 'n'", 	'cat' => "invoice"],
		'inv_statusName' 		=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(50) NOT NULL DEFAULT ''", 					'cat' => "invoice"],
		'inv_dueDate' 			=> [ 'type' => 'date', 		'dbDef' => "DATE NULL DEFAULT NULL", 							'cat' => "invoice"],
		'inv_comments' 			=> [ 'type' => 'string', 	'dbDef' => "TEXT NOT NULL", 									'cat' => "invoice"],
		'inv_remarks' 			=> [ 'type' => 'string', 	'dbDef' => "TEXT NOT NULL", 									'cat' => "invoice"],
		'inv_processedRemarks' 	=> [ 'type' => 'string', 	'dbDef' => "TEXT NOT NULL", 									'cat' => "invoice", 'disabled' => true, 'content' => 'remarks'],
		'inv_formOfPaymentCode'	=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(20) NOT NULL DEFAULT ''", 					'cat' => "invoice"],
		'inv_formOfPaymentName'	=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(50) NOT NULL DEFAULT ''", 					'cat' => "invoice"],
		'inv_cumulative' 		=> [ 'type' => 'boolean', 	'dbDef' => "TINYINT UNSIGNED NOT NULL DEFAULT 0", 				'cat' => "invoice"],
		'inv_genDocsAssoc'		=> [ 'type' => 'string',    'dbDef' => "VARCHAR(200) NOT NULL DEFAULT ''",					'cat' => "invoice", 'disabled' => true, 'content'=>'assocArray'],
		'inv_addTime' 			=> [ 'type' => 'datetime', 	'dbDef' => "DATETIME NULL", 									'cat' => "invoice"],

		'inv_partnerId' 		=> [ 'type' => 'numeric',	'dbDef' => "INT UNSIGNED NOT NULL DEFAULT 0", 					'cat' => "partner"],
		'inv_partnerName' 		=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(201) NOT NULL DEFAULT ''", 					'cat' => "partner"],
		'inv_partnerTypeCode' 	=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(2) NOT NULL DEFAULT ''", 					'cat' => "partner"],
		'inv_partnerTypeName' 	=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(30) NOT NULL DEFAULT ''", 					'cat' => "partner"],
		'inv_corporateId' 		=> [ 'type' => 'numeric', 	'dbDef' => "INT UNSIGNED NOT NULL DEFAULT 0", 					'cat' => "partner"],
		'inv_customerId' 		=> [ 'type' => 'numeric', 	'dbDef' => "INT UNSIGNED NOT NULL DEFAULT 0", 					'cat' => "partner"],
		'inv_supplierId' 		=> [ 'type' => 'numeric', 	'dbDef' => "MEDIUMINT UNSIGNED NOT NULL DEFAULT 0", 			'cat' => "partner"],

		'inv_userId' 			=> [ 'type' => 'numeric',	'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0",				'cat' => "invUser"],
		'inv_userName' 			=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(101) NOT NULL DEFAULT ''", 					'cat' => "invUser"],
		'inv_officeId' 			=> [ 'type' => 'numeric', 	'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0", 				'cat' => "invUser"],
		'inv_officeName' 		=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(150) NOT NULL DEFAULT ''", 					'cat' => "invUser"],
		'inv_departmentId' 		=> [ 'type' => 'numeric', 	'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0", 				'cat' => "invUser"],
		'inv_departmentName' 	=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''", 					'cat' => "invUser"],
		'inv_addUserId' 		=> [ 'type' => 'numeric', 	'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0", 				'cat' => "invUser"],
		'inv_addUserName' 		=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(101) NOT NULL DEFAULT ''", 					'cat' => "invUser"],

		'row_internalId'				=> [ 'type' => 'string',	'dbDef' => "VARCHAR(11) NOT NULL DEFAULT ''",			'cat' => "rowDetails", 'disabled' => true,],
		'row_id' 		    			=> [ 'type' => 'numeric',	'dbDef' => "BIGINT UNSIGNED NOT NULL DEFAULT 0",		'cat' => "rowDetails"],
		'row_serviceCode' 				=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(2) NOT NULL DEFAULT ''", 			'cat' => "rowDetails"],
		'row_serviceName' 				=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''", 			'cat' => "rowDetails"],
		'row_locationCode' 				=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(10) NOT NULL DEFAULT ''", 			'cat' => "rowDetails"],
		'row_locationName' 				=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(25) NOT NULL DEFAULT ''", 			'cat' => "rowDetails"],
		'row_calculationCode' 			=> [ 'type' => 'string', 	'dbDef' => "TINYINT NULL DEFAULT NULL", 				'cat' => "rowDetails"],
		'row_calculationName' 			=> [ 'type' => 'string',	'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''",			'cat' => "rowDetails"],
		'row_description' 				=> [ 'type' => 'string', 	'dbDef' => "TEXT NOT NULL", 							'cat' => "rowDetails"],

		'row_rowTypeCode' 				=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(15) NOT NULL DEFAULT ''", 			'cat' => "rowDetails"],
		'row_rowTypeName' 				=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(30) NOT NULL DEFAULT ''", 			'cat' => "rowDetails"],
		'row_destinationCountryCode' 	=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(2) NOT NULL DEFAULT ''", 			'cat' => "rowDetails"],
		'row_destinationCountryName' 	=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(150) NOT NULL DEFAULT ''", 			'cat' => "rowDetails"],
		'row_destinationCityId' 		=> [ 'type' => 'numeric', 	'dbDef' => "MEDIUMINT UNSIGNED NOT NULL DEFAULT 0", 	'cat' => "rowDetails"],
		'row_destinationCityName' 		=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''", 			'cat' => "rowDetails"],
		'row_passengerId' 				=> [ 'type' => 'string', 	'dbDef' => "INT UNSIGNED NOT NULL DEFAULT 0", 			'cat' => "rowDetails"],
		'row_passengerName' 			=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(201) NOT NULL DEFAULT ''", 			'cat' => "rowDetails"],
		'row_startDate' 				=> [ 'type' => 'date', 		'dbDef' => "DATE NULL DEFAULT NULL",		 			'cat' => "rowDetails"],
		'row_endDate' 					=> [ 'type' => 'date', 		'dbDef' => "DATE NULL DEFAULT NULL",					'cat' => "rowDetails"],
		'row_supplierProductId' 		=> [ 'type' => 'numeric', 	'dbDef' => "MEDIUMINT NOT NULL DEFAULT 0", 				'cat' => "rowDetails"],
		'row_supplierProductName' 		=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(250) NOT NULL DEFAULT ''", 			'cat' => "rowDetails"],
		'row_externalReservationId' 	=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(50) NOT NULL DEFAULT ''", 			'cat' => "rowDetails"],
		'row_externalReservationDate' 	=> [ 'type' => 'date', 		'dbDef' => "DATE NULL DEFAULT NULL", 					'cat' => "rowDetails"],
		'row_confirmationNumber' 		=> [ 'type' => 'string',	'dbDef' => "VARCHAR(50) NOT NULL DEFAULT ''",			'cat' => "rowDetails"],
		'row_firstTicketNumber' 		=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(50) NOT NULL DEFAULT ''", 			'cat' => "rowDetails"],

		'inv_currency' 				=> [ 'type' => 'string', 	'dbDef' => "CHAR(3) NOT NULL DEFAULT ''", 				'cat' => "rowPrices"],
		'inv_defCurrencyExchRate' 	=> [ 'type' => 'price',  	'dbDef' => "DECIMAL(15,8) NOT NULL DEFAULT 0",    		'cat' => "rowPrices"],
		'inv_workCurrencyExchRate' 	=> [ 'type' => 'price',  	'dbDef' => "DECIMAL(15,8) NOT NULL DEFAULT 0",    		'cat' => "rowPrices"],
		'row_value' 				=> [ 'type' => 'price', 	'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "rowPrices", 'subtotals' => "inv_currency"],
		'row_valueDefCurr' 			=> [ 'type' => 'price', 	'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "rowPrices", 'subtotals' => true],
		'row_valueWorkCurr' 		=> [ 'type' => 'price', 	'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "rowPrices", 'subtotals' => true],
		'row_vat' 					=> [ 'type' => 'price', 	'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "rowPrices", 'subtotals' => "inv_currency"],
		'row_vatDefCurr' 			=> [ 'type' => 'price', 	'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "rowPrices", 'subtotals' => true],
		'row_vatWorkCurr' 			=> [ 'type' => 'price', 	'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "rowPrices", 'subtotals' => true],
		'row_total' 				=> [ 'type' => 'price', 	'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "rowPrices", 'subtotals' => "inv_currency"],
		'row_totalDefCurr' 			=> [ 'type' => 'price', 	'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "rowPrices", 'subtotals' => true],
		'row_totalWorkCurr' 		=> [ 'type' => 'price', 	'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 			'cat' => "rowPrices", 'subtotals' => true],
		'row_vatPercent' 			=> [ 'type' => 'percent', 	'dbDef' => "DECIMAL(5,4) NOT NULL DEFAULT 0", 			'cat' => "rowPrices"],
		'row_vatText' 				=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''", 			'cat' => "rowPrices"],
		'row_netCompany' 			=> [ 'type' => 'price',     'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 		    'cat' => "rowPrices", 'subtotals' => 'inv_currency'],
		'row_netCompanyDefCurr'		=> [ 'type' => 'price',     'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 		    'cat' => "rowPrices", 'subtotals' => true],
		'row_netCompanyWorkCurr'	=> [ 'type' => 'price',     'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 		    'cat' => "rowPrices", 'subtotals' => true],
		'row_estOffProfit' 			=> [ 'type' => 'price',     'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 		    'cat' => "rowPrices", 'subtotals' => 'inv_currency'],
		'row_estOffProfitDefCurr'	=> [ 'type' => 'price',     'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 		    'cat' => "rowPrices", 'subtotals' => true],
		'row_estOffProfitWorkCurr'	=> [ 'type' => 'price',     'dbDef' => "DECIMAL(16,3) NOT NULL DEFAULT 0", 		    'cat' => "rowPrices", 'subtotals' => true],
		'row_refund' 				=> [ 'type' => 'boolean', 	'dbDef' => "TINYINT UNSIGNED NOT NULL DEFAULT 0", 		'cat' => "rowPrices"],

		'order_id' 				=> [ 'type' => 'numeric', 	'dbDef' => "BIGINT NOT NULL DEFAULT 0", 					'cat' => "order"],
		'order_idConverted' 	=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(8) NOT NULL DEFAULT ''", 				'cat' => "order"],
		'order_code' 			=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(50) NOT NULL DEFAULT ''", 				'cat' => "order"],
		'order_number' 			=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''", 				'cat' => "order"],
		'order_date' 			=> [ 'type' => 'date', 		'dbDef' => "DATE NULL DEFAULT NULL", 						'cat' => "order"],
		'order_startDate' 		=> [ 'type' => 'date', 		'dbDef' => "DATE NULL DEFAULT NULL", 						'cat' => "order"],
		'order_endDate' 		=> [ 'type' => 'date', 		'dbDef' => "DATE NULL DEFAULT NULL", 						'cat' => "order"],
		'order_idMiceProject' 	=> [ 'type' => 'numeric', 	'dbDef' => "SMALLINT NOT NULL DEFAULT 0", 					'cat' => "order"],
		'order_miceProjectName' => [ 'type' => 'string', 	'dbDef' => "VARCHAR(250) NOT NULL DEFAULT ''", 				'cat' => "order"],
		'order_userId' 			=> [ 'type' => 'numeric', 	'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0", 			'cat' => "order"],
		'order_userName' 		=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(101) NOT NULL DEFAULT ''", 				'cat' => "order"],
		'order_officeId' 		=> [ 'type' => 'numeric', 	'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0", 			'cat' => "order"],
		'order_officeName' 		=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(150) NOT NULL DEFAULT ''", 				'cat' => "order"],
		'order_deptId' 			=> [ 'type' => 'numeric', 	'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0", 			'cat' => "order"],
		'order_deptName' 		=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''", 				'cat' => "order"],

		'serv_id' 						=> [ 'type' => 'numeric',	'dbDef' => "BIGINT NOT NULL DEFAULT 0", 			'cat' => "service"],
		'serv_respUserId' 				=> [ 'type' => 'numeric', 	'dbDef' => "SMALLINT NOT NULL DEFAULT 0", 			'cat' => "service"],
		'serv_respUserName' 			=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(101) NOT NULL DEFAULT ''", 		'cat' => "service"],
		'serv_respOfficeId' 			=> [ 'type' => 'numeric', 	'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0", 	'cat' => "service"],
		'serv_respOfficeName'	 		=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(150) NOT NULL DEFAULT ''", 		'cat' => "service"],
		'serv_respDeptId' 				=> [ 'type' => 'numeric', 	'dbDef' => "SMALLINT UNSIGNED NOT NULL DEFAULT 0", 	'cat' => "service"],
		'serv_respDeptName' 			=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(100) NOT NULL DEFAULT ''", 		'cat' => "service"],

		'off_id' 						=> [ 'type' => 'numeric',	'dbDef' => "BIGINT NOT NULL DEFAULT 0", 			'cat' => "offer"],
		'off_currencyTypeCode'			=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(10) NOT NULL DEFAULT ''", 		'cat' => "offer"],
		'off_currencyTypeName'			=> [ 'type' => 'string', 	'dbDef' => "VARCHAR(50) NOT NULL DEFAULT ''", 		'cat' => "offer"],
		'off_currencyDate'				=> [ 'type' => 'date', 		'dbDef' => "DATE NULL DEFAULT NULL", 				'cat' => "offer"],

	];

	/**
	 * The primary key column.
	 * @var string
	 */
	protected string $primaryKeyColumn = 'row_internalId';

	/**
	 * The columns that are forced into the report.
	 * @var array
	 */
	protected array $forcedColumns = [ 'serv_id' ];

	/**
	 * The columns dependencies list.
	 * @var array
	 */
	protected array $columnsDependencies = [
		'inv_seriesCode'		=> ['inv_seriesId', 'inv_corporateId'],
		'inv_statusName'		=> ['inv_statusCode'],
		'inv_formOfPaymentName'	=> ['inv_formOfPaymentCode'],

		'inv_corporateId'		=> ['inv_id'],
		'inv_customerId'		=> ['inv_id'],
		'inv_supplierId'		=> ['inv_id'],
		'inv_partnerId'			=> ['inv_supplierId', 'inv_corporateId', 'inv_customerId'],
		'inv_partnerName'		=> ['inv_partnerId'],
		'inv_partnerTypeCode'	=> ['inv_supplierId', 'inv_corporateId', 'inv_customerId'],
		'inv_partnerTypeName'	=> ['inv_partnerTypeCode'],

		'inv_userName'			=> ['inv_userId'],
		'inv_officeName'		=> ['inv_officeId'],
		'inv_departmentId'		=> ['inv_id'],
		'inv_departmentName'	=> ['inv_departmentId'],
		'inv_addUserName'		=> ['inv_addUserId'],

		'row_serviceName'				=> ['row_serviceCode'],
		'row_locationName'				=> ['row_locationCode'],
		'row_rowTypeName'				=> ['row_rowTypeCode'],
		'row_passengerId'				=> ['serv_id'],
		'row_passengerName'				=> ['row_passengerId'],
		'row_destinationCountryName'	=> ['row_destinationCountryCode'],
		'row_destinationCityName'		=> ['row_destinationCityId'],
		'row_supplierProductName'		=> ['row_supplierProductId'],
		'row_calculationName'			=> ['row_serviceCode', 'row_locationCode', 'row_calculationCode'],

		'order_miceProjectName'	=> ['order_idMiceProject'],
		'order_userId'			=> ['order_id'],
		'order_userName'		=> ['order_userId'],
		'order_officeId'		=> ['order_id'],
		'order_officeName'		=> ['order_officeId'],
		'order_deptId'			=> ['order_id'],
		'order_deptName'		=> ['order_deptId'],

		'serv_id'				=> ['row_id'],
		'serv_respUserId'		=> ['serv_id'],
		'serv_respUserName'		=> ['serv_respUserId'],
		'serv_respOfficeId'		=> ['serv_id'],
		'serv_respOfficeName'	=> ['serv_respOfficeId'],
		'serv_respDeptId'		=> ['serv_id'],
		'serv_respDeptName'		=> ['serv_respDeptId'],

		'off_id'				=> ['serv_id'],
		'off_currencyTypeCode'	=> ['off_id'],
		'off_currencyTypeName'	=> ['off_currencyTypeCode'],
		'off_currencyDate'		=> ['off_id'],
	];


}