From 47c538c334005124210c9be4a1ec1b3288b903cb Mon Sep 17 00:00:00 2001
From: Torsten Oppermann <torsten@sgalinski.de>
Date: Mon, 11 Dec 2017 11:39:51 +0100
Subject: [PATCH] [TASK] Adding job application tca, table etc.. WIP

---
 Classes/Domain/Model/JobApplication.php       |  41 +--
 ...tx_sgjobs_domain_model_job_application.php | 317 ++++++++++++++++++
 ext_tables.sql                                |  57 ++++
 3 files changed, 385 insertions(+), 30 deletions(-)
 create mode 100644 Configuration/TCA/tx_sgjobs_domain_model_job_application.php

diff --git a/Classes/Domain/Model/JobApplication.php b/Classes/Domain/Model/JobApplication.php
index bb58f047..82b6d27c 100644
--- a/Classes/Domain/Model/JobApplication.php
+++ b/Classes/Domain/Model/JobApplication.php
@@ -33,16 +33,11 @@ use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
  * The JobApplication model
  */
 class JobApplication extends AbstractEntity {
-	/**
-	 * @var string $jobTitle
-	 * @validate NotEmpty
-	 */
-	protected $jobTitle = '';
 
 	/**
-	 * @var \SGalinski\SgJobs\Domain\Model\Job
+	 * @var \SGalinski\SgJobs\Domain\Model\Job $job
 	 */
-	protected $jobId = '';
+	protected $job = '';
 
 	/**
 	 * @var string $gender
@@ -98,7 +93,7 @@ class JobApplication extends AbstractEntity {
 	protected $education = '';
 
 	/**
-	 * @var string $birthDate
+	 * @var int $birthDate
 	 */
 	protected $birthDate = '';
 
@@ -145,32 +140,18 @@ class JobApplication extends AbstractEntity {
 		$this->certificates = new ObjectStorage();
 	}
 
-	/**
-	 * @return string
-	 */
-	public function getJobTitle() {
-		return $this->jobTitle;
-	}
-
-	/**
-	 * @param string $jobTitle
-	 */
-	public function setJobTitle(string $jobTitle) {
-		$this->jobTitle = $jobTitle;
-	}
-
 	/**
 	 * @return \SGalinski\SgJobs\Domain\Model\Job
 	 */
-	public function getJobId() {
-		return $this->jobId;
+	public function getJob() {
+		return $this->job;
 	}
 
 	/**
-	 * @param \SGalinski\SgJobs\Domain\Model\Job $jobId
+	 * @param \SGalinski\SgJobs\Domain\Model\Job $job
 	 */
-	public function setJobId(Job $jobId) {
-		$this->jobId = $jobId;
+	public function setJob(Job $job) {
+		$this->job = $job;
 	}
 
 	/**
@@ -300,17 +281,17 @@ class JobApplication extends AbstractEntity {
 	}
 
 	/**
-	 * @return string
+	 * @return int
 	 */
 	public function getBirthDate() {
 		return $this->birthDate;
 	}
 
 	/**
-	 * @param string $birthDate
+	 * @param int $birthDate
 	 */
 	public function setBirthDate(string $birthDate) {
-		$this->birthDate = $birthDate;
+		$this->birthDate = (int) $birthDate;
 	}
 
 	/**
diff --git a/Configuration/TCA/tx_sgjobs_domain_model_job_application.php b/Configuration/TCA/tx_sgjobs_domain_model_job_application.php
new file mode 100644
index 00000000..f089f9a8
--- /dev/null
+++ b/Configuration/TCA/tx_sgjobs_domain_model_job_application.php
@@ -0,0 +1,317 @@
+<?php
+
+return [
+	'ctrl' => [
+		'title' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application',
+		'label' => 'title',
+		'tstamp' => 'tstamp',
+		'crdate' => 'crdate',
+		'cruser_id' => 'cruser_id',
+		'dividers2tabs' => TRUE,
+		'searchFields' => 'job_id, gender, first_name, last_name, street, city, zip, country, nationality, education, birth_date, phone, mobile, email, message, cover_letter, certificates, cv',
+		'versioningWS' => 2,
+		'versioning_followPages' => TRUE,
+		'origUid' => 't3_origuid',
+		'languageField' => 'sys_language_uid',
+		'transOrigPointerField' => 'l10n_parent',
+		'transOrigDiffSourceField' => 'l10n_diffsource',
+		'delete' => 'deleted',
+		'enablecolumns' => [
+			'disabled' => 'hidden',
+			'starttime' => 'starttime',
+			'endtime' => 'endtime',
+		],
+		'sortby' => 'sorting',
+		'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('sg_jobs') .
+			'Resources/Public/Icons/tx_sgjobs_domain_model_job.svg'
+	],
+	'interface' => [
+		'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, pid, title, job_id, area, job_function, start_date, alternative_start_date,
+		 company, task, qualification, description, contact',
+	],
+	'types' => [
+		'1' => [
+			'showitem' => '--palette--;;sysLanguageAndHidden,job_id, gender, first_name, last_name, street, city, zip, 
+				country, nationality, education, birth_date, phone, mobile, email, message, cover_letter, certificates, cv,
+			 	div;;richtext[*]:rte_transform[mode=ts],
+				--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime',
+		],
+	],
+	'palettes' => [
+		'sysLanguageAndHidden' => [
+			'showitem' => 'sys_language_uid;;;;1-1-1, l10n_diffsource, hidden;;1, ',
+			'canNotCollapse' => 1,
+		]
+	],
+	'columns' => [
+		'sys_language_uid' => [
+			'exclude' => 1,
+			'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xml:LGL.language',
+			'config' => [
+				'type' => 'select',
+				'special' => 'languages',
+			],
+		],
+		'l10n_parent' => [
+			'displayCond' => 'FIELD:sys_language_uid:>:0',
+			'exclude' => 1,
+			'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xml:LGL.l18n_parent',
+			'config' => [
+				'type' => 'select',
+				'items' => [
+					['', 0],
+				],
+				'foreign_table' => 'tx_sgjobs_domain_model_job_application',
+				'foreign_table_where' => 'AND tx_sgjobs_domain_model_job_application.pid=###CURRENT_PID### AND tx_sgjobs_domain_model_job_application.sys_language_uid IN (-1,0)',
+			],
+		],
+		'l10n_diffsource' => [
+			'config' => [
+				'type' => 'passthrough',
+			],
+		],
+		't3ver_label' => [
+			'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xml:LGL.versionLabel',
+			'config' => [
+				'type' => 'input',
+				'size' => 30,
+				'max' => 255,
+			]
+		],
+		'pid' => [
+			'exclude' => 0,
+			'label' => 'PID',
+			'config' => [
+				'type' => 'none',
+			]
+		],
+		'hidden' => [
+			'exclude' => 1,
+			'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xml:LGL.hidden',
+			'config' => [
+				'type' => 'check',
+			],
+		],
+		'starttime' => [
+			'exclude' => 1,
+			'l10n_mode' => 'mergeIfNotBlank',
+			'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xml:LGL.starttime',
+			'config' => [
+				'type' => 'input',
+				'size' => 13,
+				'max' => 20,
+				'eval' => 'datetime',
+				'checkbox' => 0,
+				'default' => 0,
+				'range' => [
+					'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y'))
+				],
+			],
+		],
+		'endtime' => [
+			'exclude' => 1,
+			'l10n_mode' => 'mergeIfNotBlank',
+			'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xml:LGL.endtime',
+			'config' => [
+				'type' => 'input',
+				'size' => 13,
+				'max' => 20,
+				'eval' => 'datetime',
+				'checkbox' => 0,
+				'default' => 0,
+				'range' => [
+					'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y'))
+				],
+			],
+		],
+		'job' => [
+			'exclude' => 0,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.job',
+			'config' => [
+				'type' => 'select',
+				'eval' => 'required',
+				'renderType' => 'selectSingle',
+				'internal_type' => 'db',
+				'foreign_table' => 'tx_sgjobs_domain_model_job',
+				'size' => 1,
+				'maxitems' => 1,
+				'multiple' => 0,
+				'fieldControl' => [
+					'editPopup' => [
+						'disabled' => FALSE,
+					],
+					'addRecord' => [
+						'disabled' => FALSE,
+					]
+				],
+			]
+		],
+		'gender' => [
+			'exclude' => 0,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.gender',
+			'config' => [
+				'type' => 'input',
+				'size' => 30,
+				'eval' => 'trim, required'
+			],
+		],
+		'first_name' => [
+			'exclude' => 0,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.first_name',
+			'config' => [
+				'type' => 'input',
+				'size' => 30,
+				'eval' => 'trim, required'
+			],
+		],
+		'last_name' => [
+			'exclude' => 0,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.last_name',
+			'config' => [
+				'type' => 'input',
+				'size' => 30,
+				'eval' => 'trim, required'
+			],
+		],
+		'street' => [
+			'exclude' => 0,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.street',
+			'config' => [
+				'type' => 'input',
+				'size' => 30,
+				'eval' => 'trim, required'
+			],
+		],
+		'city' => [
+			'exclude' => 0,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.city',
+			'config' => [
+				'type' => 'input',
+				'size' => 30,
+				'eval' => 'trim, required'
+			],
+		],
+		'zip' => [
+			'exclude' => 0,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.zip',
+			'config' => [
+				'type' => 'input',
+				'size' => 30,
+				'eval' => 'trim, required'
+			],
+		],
+		'country' => [
+			'exclude' => 0,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.zip',
+			'config' => [
+				'type' => 'input',
+				'size' => 30,
+				'eval' => 'trim, required'
+			],
+		],
+		'nationality' => [
+			'exclude' => 0,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.zip',
+			'config' => [
+				'type' => 'input',
+				'size' => 30,
+				'eval' => 'trim, required'
+			],
+		],
+		'education' => [
+			'exclude' => 0,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.zip',
+			'config' => [
+				'type' => 'input',
+				'size' => 30,
+				'eval' => 'trim, required'
+			],
+		],
+		'birth_date' => [
+			'exclude' => 1,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.birth_date',
+			'config' => [
+				'type' => 'input',
+				'size' => 13,
+				'max' => 20,
+				'eval' => 'date, required',
+				'checkbox' => 0,
+				'range' => [
+					'lower' => mktime(date('m'), date('d'), date('Y'))
+				],
+			],
+		],
+		'phone' => [
+			'exclude' => 0,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.phone',
+			'config' => [
+				'type' => 'input',
+				'size' => 30,
+				'eval' => 'trim, required'
+			],
+		],
+		'mobile' => [
+			'exclude' => 0,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.mobile',
+			'config' => [
+				'type' => 'input',
+				'size' => 30,
+				'eval' => 'trim, required'
+			],
+		],
+		'email' => [
+			'exclude' => 0,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.email',
+			'config' => [
+				'type' => 'input',
+				'size' => 30,
+				'eval' => 'trim, required'
+			],
+		],
+		'message' => [
+			'exclude' => 0,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.message',
+			'config' => [
+				'type' => 'input',
+				'size' => 1024,
+				'eval' => 'trim, required'
+			],
+		],
+		'cover_letter' => [
+			'exclude' => 0,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.cover_letter',
+			'config' => [
+				'type' => 'group',
+				'internal_type' => 'file',
+				'allowed' => 'pdf, doc',
+				'size' => 3,
+				'uploadfolder' => 'uploads/tx_sgjobs/',
+				'max_size' => 2000,
+			],
+		],
+		'certificates' => [
+			'exclude' => 0,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.certificates',
+			'config' => [
+				'type' => 'group',
+				'internal_type' => 'file',
+				'allowed' => 'pdf, doc',
+				'size' => 3,
+				'uploadfolder' => 'uploads/tx_sgjobs/',
+				'max_size' => 2000,
+			],
+		],
+		'cv' => [
+			'exclude' => 0,
+			'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job_application.cv',
+			'config' => [
+				'type' => 'group',
+				'internal_type' => 'file',
+				'allowed' => 'pdf, doc',
+				'size' => 3,
+				'uploadfolder' => 'uploads/tx_sgjobs/',
+				'max_size' => 2000,
+			],
+		]
+	],
+];
\ No newline at end of file
diff --git a/ext_tables.sql b/ext_tables.sql
index 79d06be3..683d4cb7 100644
--- a/ext_tables.sql
+++ b/ext_tables.sql
@@ -137,3 +137,60 @@ CREATE TABLE tx_sgjobs_domain_model_contact (
 	KEY t3ver_oid (t3ver_oid,t3ver_wsid),
 	KEY language (l10n_parent,sys_language_uid)
 );
+
+CREATE TABLE tx_sgjobs_domain_model_job_application (
+	uid int(11) NOT NULL auto_increment,
+	pid int(11) DEFAULT '0' NOT NULL,
+
+	-- Custom fields
+	job int(11) unsigned DEFAULT '0' NOT NULL,
+	gender varchar(30) DEFAULT '' NOT NULL,
+	first_name text DEFAULT '' NOT NULL,
+	last_name text DEFAULT '' NOT NULL,
+	street text DEFAULT '' NOT NULL,
+	city text DEFAULT '' NOT NULL,
+	zip text DEFAULT '' NOT NULL,
+	country text DEFAULT '' NOT NULL,
+	nationality text DEFAULT '' NOT NULL,
+	education text DEFAULT '' NOT NULL,
+	birth_date int(11) unsigned DEFAULT '0' NOT NULL,
+	phone text DEFAULT '' NOT NULL,
+	mobile text DEFAULT '' NOT NULL,
+	email text DEFAULT '' NOT NULL,
+	message text DEFAULT '' NOT NULL,
+	cover_letter int(11) unsigned DEFAULT '0' NOT NULL,
+	certificates int(11) unsigned DEFAULT '0' NOT NULL,
+	cv int(11) unsigned DEFAULT '0' NOT NULL,
+
+	-- TYPO3 fields
+	sorting int(11) unsigned DEFAULT '0' NOT NULL,
+	starttime int(11) unsigned DEFAULT '0' NOT NULL,
+	endtime int(11) unsigned DEFAULT '0' NOT NULL,
+	tstamp int(11) unsigned DEFAULT '0' NOT NULL,
+	crdate int(11) unsigned DEFAULT '0' NOT NULL,
+	cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
+	deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
+	hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
+
+    -- TYPO3 workspace fields
+	t3ver_oid int(11) DEFAULT '0' NOT NULL,
+	t3ver_id int(11) DEFAULT '0' NOT NULL,
+	t3ver_wsid int(11) DEFAULT '0' NOT NULL,
+	t3ver_label varchar(255) DEFAULT '' NOT NULL,
+	t3ver_state tinyint(4) DEFAULT '0' NOT NULL,
+	t3ver_stage int(11) DEFAULT '0' NOT NULL,
+	t3ver_count int(11) DEFAULT '0' NOT NULL,
+	t3ver_tstamp int(11) DEFAULT '0' NOT NULL,
+	t3ver_move_id int(11) DEFAULT '0' NOT NULL,
+	t3_origuid int(11) DEFAULT '0' NOT NULL,
+
+	-- TYPO3 multi language fields
+	sys_language_uid int(11) DEFAULT '0' NOT NULL,
+	l10n_parent int(11) DEFAULT '0' NOT NULL,
+	l10n_diffsource mediumblob,
+
+	PRIMARY KEY (uid),
+	KEY parent (pid),
+	KEY t3ver_oid (t3ver_oid,t3ver_wsid),
+	KEY language (l10n_parent,sys_language_uid)
+);
-- 
GitLab