Commit 317b6908 authored by achilleas's avatar achilleas

changes to eiek entitychanger new module maincustomform

parent 8f1fa405
......@@ -97,21 +97,43 @@ class AitisiEntity extends RevisionableContentEntityBase implements AitisiEntity
}
public function getStudent_id() {
public function getSchool() {
return $this->get('iek_id')->entity;
}
public function getSchoolId() {
return $this->get('iek_id')->value;
}
public function setSchoolId($studentId) {
$this->set('iek_id', $studentId);
return $this;
}
public function getStudent() {
return $this->get('student_id')->entity;
}
public function getStudentId() {
return $this->get('student_id')->value;
}
public function setStudent_id($student_id) {
public function setStudentId($student_id) {
$this->set('student_id', $student_id);
return $this;
}
public function getEidikotita() {
return $this->get('eidikotita_id')->entity;
}
public function getEidikotita_id() {
public function getEidikotitaId() {
return $this->get('eidikotita_id')->value;
}
public function setEidikotita_id($eidikotita_id) {
public function setEidikotitaId($eidikotita_id) {
$this->set('eidikotita_id', $eidikotita_id);
return $this;
}
......@@ -143,16 +165,65 @@ class AitisiEntity extends RevisionableContentEntityBase implements AitisiEntity
return $this;
}
public function getRegion_id() {
public function getRegion() {
return $this->get('region_id')->entity;
}
public function getRegionId() {
return $this->get('region_id')->value;
}
public function setRegion_id($region_id) {
public function setRegionId($region_id) {
$this->set('region_id', $region_id);
return $this;
}
/**
* {@inheritdoc}
*/
public function getState() {
return $this->get('state')->value;
}
/**
* {@inheritdoc}
*/
public function setState($state) {
$this->set('state', $state);
return $this;
}
/**
* {@inheritdoc}
*/
public function getFlagiek() {
return $this->get('flagiek')->value;
}
/**
* {@inheritdoc}
*/
public function setFlagiek($flagiek) {
$this->set('flagiek', $flagiek);
return $this;
}
/**
* {@inheritdoc}
*/
public function getFlagbank() {
return $this->get('flagbank')->value;
}
/**
* {@inheritdoc}
*/
public function setFlagbank($flagbank) {
$this->set('flagbank', $flagbank);
return $this;
}
/**
......@@ -427,7 +498,54 @@ class AitisiEntity extends RevisionableContentEntityBase implements AitisiEntity
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['state'] = BaseFieldDefinition::create('list_string')
->setLabel(t('Κατάσταση Αίτησης'))
->setDescription(t('Κατάσταση Αίτησης'))
->setRequired(TRUE)
->setSettings(array(
'max_length' => 16,
'default_value' => 'Draft',
'allowed_values' => array(
'Draft' => 'Draft',
'Pending' => 'Pending',
'Ready' => 'Ready',
),
))
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'options_select',
'weight' => -17,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['flagiek'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Έλεγχος υπεύθυνου ΙΕΚ'))
->setDefaultValue(FALSE)
->setDisplayOptions('form', array(
'type' => 'boolean_checkbox',
'settings' => array(
'display_label' => TRUE,
),
'weight' => -18,
))
->setDisplayConfigurable('form', TRUE);
$fields['flagbank'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Έλεγχος υπεύθυνου τράπεζας'))
->setDefaultValue(FALSE)
->setDisplayOptions('form', array(
'type' => 'boolean_checkbox',
'settings' => array(
'display_label' => TRUE,
),
'weight' => -18,
))
->setDisplayConfigurable('form', TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')
......
......@@ -19,11 +19,18 @@ interface AitisiEntityInterface extends RevisionableInterface, RevisionLogInterf
// Add get/set methods for your configuration properties here.
public function getStudent_id();
public function setStudent_id($student_id);
public function getSchool();
public function getSchoolId();
public function setSchoolId($studentId);
public function getStudent();
public function getStudentId();
public function setStudentId($student_id);
public function getEidikotita();
public function getEidikotitaId();
public function setEidikotitaId($eidikotita_id);
public function getEidikotita_id();
public function setEidikotita_id($eidikotita_id);
public function getPrabek();
public function setPrabek($prabek);
......@@ -34,8 +41,9 @@ interface AitisiEntityInterface extends RevisionableInterface, RevisionLogInterf
public function getRegno();
public function setRegno($regno);
public function getRegion_id();
public function setRegion_id($region_id);
public function getRegion();
public function getRegionId();
public function setRegionId($region_id);
/**
* Gets the Aitisi entity creation timestamp.
......
......@@ -87,7 +87,7 @@ class SchoolEntity extends ContentEntityBase implements SchoolEntityInterface {
* {@inheritdoc}
*/
public function getIekcode() {
return $this->get('iek_code')->value;
return $this->get('iekcode')->value;
}
/**
......
......@@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
*/
/*
function entitychanger_entity_base_field_info(EntityTypeInterface $entity_type) {
if ($entity_type->id() === 'student_entity') {
$fields['iekbek'] = BaseFieldDefinition::create('string')
......@@ -70,16 +70,16 @@ function entitychanger_entity_base_field_info(EntityTypeInterface $entity_type)
* Implements hook_help().
*/
function entitychanger_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the entitychanger module.
case 'help.page.entitychanger':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('My Awesome Module') . '</p>';
return $output;
default:
}
switch ($route_name) {
// Main module help for the entitychanger module.
case 'help.page.entitychanger':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('My Awesome Module') . '</p>';
return $output;
default:
}
}
......@@ -89,189 +89,199 @@ function entitychanger_help($route_name, RouteMatchInterface $route_match) {
function entitychanger_install() {
$entity_manager = \Drupal::entityManager();
$entity_storage_student = $entity_manager->getStorage('student_entity');
$entity_storage_eidikotita = $entity_manager->getStorage('eidikotita_entity');
$entity_storage_request = $entity_manager->getStorage('aitisi_entity');
$entity_storage_regions = $entity_manager->getStorage('region_entity');
$entity_storage_iek = $entity_manager->getStorage('school_entity');
//------------------------------------------------------------------------------------------------//
//-------------------------------CREATE STUDENT ENTITIES------------------------------------------//
//------------------------------------------------------------------------------------------------//
$arr_students = array();
$arr_students[] = array('last'=>'ΝΑΚΟΥ', 'first'=>'ΜΑΡΙΑ','fname'=>'ΓΙΩΡΓΟΣ','mname'=>'ΕΛΕΝΗ','idno' => 'Χ664666', 'sex' => 'female', 'birthdate' => '2000-01-01', 'birthplace'=>'ΓΑΛΑΤΣΙ ΑΤΤΙΚΗΣ', 'email'=>'ach@yahoo.gr', 'telephone'=>'2102525096', 'afm' => '067335676');
$arr_students[] = array('last'=>'ΝΕΟΧΩΡΛΗ', 'first'=>'ΕΛΕΝΗ','fname'=>'ΚΩΝΣΤΑΝΤΙΝΟΣ','mname'=>'ΣΤΑΥΡΟΥΛΑ','idno' => 'ΖΔ111111', 'sex' => 'female', 'birthdate' => '1992-11-01', 'birthplace'=>'ΦΙΛΑΔΕΛΦΕΙΑ ΑΤΤΙΚΗΣ', 'email'=>'ach@yahoo.gr', 'telephone'=>'2102520755', 'afm' => '077335676');
$arr_students[] = array('last'=>'ΒΛΑΧΟΔΗΜΟΣ', 'first'=>'ΝΙΚΟΣ','fname'=>'ΜΑΡΙΟΣ','mname'=>'ΜΑΡΙΑ','idno' => 'Ψ664666', 'sex' => 'male', 'birthdate' => '1995-05-22', 'birthplace'=>'ΙΛΙΟΝ ΑΤΤΙΚΗΣ', 'email'=>'ach@yahoo.gr', 'telephone'=>'2106565755', 'afm' => '087335676');
$arr_students[] = array('last'=>'ΤΡΙΑΝΤΑΦΥΛΛΟΥ', 'first'=>'ΓΙΩΡΓΟΣ','fname'=>'ΣΤΑΥΡΟΣ','mname'=>'ΧΑΡΟΥΛΑ','idno' => 'Τ664666', 'sex' => 'male', 'birthdate' => '1984-12-26', 'birthplace'=>'ΠΕΙΡΑΙΑΣ ΑΤΤΙΚΗΣ', 'email'=>'ach@yahoo.gr', 'telephone'=>'2102525096', 'afm' => '067335676');
$arr_students[] = array('last'=>'ΔΕΛΗΓΙΑΝΝΗΣ', 'first'=>'ΧΑΡΗΣ','fname'=>'ΓΙΩΡΓΟΣ','mname'=>'ΕΥΓΕΝΙΑ','idno' => 'Ζ664666', 'sex' => 'male', 'birthdate' => '1994-02-10', 'birthplace'=>'ΘΕΣΣΑΛΟΝΙΚΗ', 'email'=>'ach@yahoo.gr', 'telephone'=>'2310454545', 'afm' => '067335666');
//save demo STUDENTS
$created_student_ids = array();
foreach ($arr_students as $key => $value) {
$entity_object = $entity_storage_student->create($value);
$entity_storage_student->save($entity_object);
$created_student_ids[] = $entity_object->id();
}
//------------------------------------------------------------------------------------------------//
//-------------------------------CREATE EIDIKOTITES ENTITIES------------------------------------------//
//------------------------------------------------------------------------------------------------//
$arr_eidikotites = array ();
$arr_eidikotites[] = array('name'=>'ΕΙΔΙΚΟΣ ΕΦΑΡΜΟΓΩΝ ΠΛΗΡΟΦΟΡΙΚΗΣ', 'eidcode' => '010101');
$arr_eidikotites[] = array('name'=>'ΤΕΧΝΙΚΟΣ ΒΙΟΜΗΧΑΝΙΚΟΥ ΛΟΓΙΣΜΙΚΟΥ', 'eidcode' => '010103');
$arr_eidikotites[] = array('name'=>'ΕΙΔΙΚΟΣ ΓΕΩΓΡΑΦΙΚΩΝ ΣΥΣΤΗΜΑΤΩΝ ΠΛΗΡΟΦΟΡΙΩΝ (G.I.S.)', 'eidcode' => '010104');
$arr_eidikotites[] = array('name'=>'ΤΕΧΝΙΚΟΣ ΤΗΛΕΠΛΗΡΟΦΟΡΙΚΗΣ', 'eidcode' => '010105');
$arr_eidikotites[] = array('name'=>'ΤΕΧΝΙΚΟΣ ΕΦΑΡΜΟΓΩΝ ΙΑΤΡΙΚΗΣ ΠΛΗΡΟΦΟΡΙΚΗΣ', 'eidcode' => '010106');
//create demo eidikotites
$created_eidikotites_ids = array();
foreach ($arr_eidikotites as $key => $value) {
$entity_object = $entity_storage_eidikotita->create($value);
$entity_storage_eidikotita->save($entity_object);
$created_eidikotites_ids[] = $entity_object->id();
}
//------------------------------------------------------------------------------------------------//
//-------------------------------CREATE REGIONS ENTITIES------------------------------------------//
//------------------------------------------------------------------------------------------------//
$arr_regions = array();
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΑΤΤΙΚΗΣ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΒΟΡΕΙΟΥ ΑΙΓΑΙΟΥ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΔΥΤΙΚΗΣ ΕΛΛΑΔΑΣ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΔΥΤΙΚΗΣ ΜΑΚΕΔΟΝΙΑΣ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΚΕΝΤΡΙΚΗΣ ΜΑΚΕΔΟΝΙΑΣ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΑΝΑΤΟΛΙΚΗΣ ΜΑΚΕΔΟΝΙΑΣ-ΘΡΑΚΗΣ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΘΕΣΣΑΛΙΑΣ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΗΠΕΙΡΟΥ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΚΡΗΤΗΣ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΝΟΤΙΟΥ ΑΙΓΑΙΟΥ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΙΟΝΙΩΝ ΝΗΣΩΝ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΠΕΛΟΠΟΝΝΗΣΟΥ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΣΤΕΡΕΑΣ ΕΛΛΑΔΑΣ');
//save regions
$created_regions_ids = array();
foreach ($arr_regions as $key => $value) {
$entity_object = $entity_storage_regions->create($value);
$entity_storage_regions->save($entity_object);
$created_regions_ids[] = $entity_object->id();
}
//------------------------------------------------------------------------------------------------//
//-------------------------------CREATE SCHOOL(IEK) ENTITIES------------------------------------------//
//------------------------------------------------------------------------------------------------//
$arr_iek = array();
$arr_iek[] = array('region_id'=> $created_regions_ids[0], 'name'=> 'ΣΙΒΙΤΑΝΙΔΕΙΟΣ', 'iekcode'=>'00530', 'iektype' => 'public');
$arr_iek[] = array('region_id'=> $created_regions_ids[0], 'name'=> 'Ο.Α.Ε.Δ. - ΥΜΗΤΤΟΥ', 'iekcode'=>'00506', 'iektype' => 'public');
$arr_iek[] = array('region_id'=> $created_regions_ids[0], 'name'=> 'TechnoGrafico', 'iekcode'=>'01002', 'iektype' => 'private');
$arr_iek[] = array('region_id'=> $created_regions_ids[8], 'name'=> 'Ο.Α.Ε.Δ. - ΗΡΑΚΛΕΙΟΥ ΚΡΗΤΗΣ', 'iekcode'=>'01701', 'iektype' => 'public');
$arr_iek[] = array('region_id'=> $created_regions_ids[1], 'name'=> 'ΧΙΟΥ', 'iekcode'=>'00075', 'iektype' => 'public');
$arr_iek[] = array('region_id'=> $created_regions_ids[11], 'name'=> 'ΣΠΑΡΤΗΣ', 'iekcode'=>'00058', 'iektype' => 'public');
$arr_iek[] = array('region_id'=> $created_regions_ids[12],'name'=> 'ΧΑΛΚΙΔΑΣ', 'iekcode'=>'00049', 'iektype' => 'public');
$arr_iek[] = array('region_id'=> $created_regions_ids[11], 'name'=> 'ΠΥΡΓΟΥ', 'iekcode'=>'00054', 'iektype' => 'public');
$arr_iek[] = array('region_id'=> $created_regions_ids[10], 'name'=> 'ΚΕΡΚΥΡΑΣ', 'iekcode'=>'00052', 'iektype' => 'public');
//save iek entities
$created_iek_ids = array();
foreach ($arr_iek as $key => $value) {
$entity_object = $entity_storage_iek->create($value);
$entity_storage_iek->save($entity_object);
$created_iek_ids[] = $entity_object->id();
}
//------------------------------------------------------------------------------------------------//
//-------------------------------CREATE AITISEIS ENTITIES------------------------------------------//
//------------------------------------------------------------------------------------------------//
$arr_aitiseis = array();
$arr_aitiseis[] = array('prabek'=> '22/10-1-2017', 'numbek'=> '123','regno'=> '010');
$arr_aitiseis[] = array('prabek'=> '65/9-1-2017', 'numbek'=> '77','regno'=> '066');
$arr_aitiseis[] = array('prabek'=> '10/10-2-2017', 'numbek'=> '65','regno'=> '045');
$arr_aitiseis[] = array('prabek'=> '9/9-2-2017', 'numbek'=> '17','regno'=> '023');
for ($i=0; $i <=3; $i++) {
$arr_aitiseis[$i]['eidikotita_id'] = $created_eidikotites_ids[$i];
$arr_aitiseis[$i]['student_id'] = $created_student_ids[$i];
$arr_aitiseis[$i]['region_id'] = $created_regions_ids[$i];
$arr_aitiseis[$i]['iek_id'] = $created_iek_ids[$i];
}
foreach ($arr_aitiseis as $key => $value) {
$entity_object = $entity_storage_request->create($value);
$entity_storage_request->save($entity_object);
}
$entity_manager = \Drupal::entityManager();
$entity_storage_student = $entity_manager->getStorage('student_entity');
$entity_storage_eidikotita = $entity_manager->getStorage('eidikotita_entity');
$entity_storage_request = $entity_manager->getStorage('aitisi_entity');
$entity_storage_regions = $entity_manager->getStorage('region_entity');
$entity_storage_iek = $entity_manager->getStorage('school_entity');
//------------------------------------------------------------------------------------------------//
//-------------------------------CREATE STUDENT ENTITIES------------------------------------------//
//------------------------------------------------------------------------------------------------//
$arr_students = array();
$arr_students[] = array('last'=>'ΝΑΚΟΥ', 'first'=>'ΜΑΡΙΑ','fname'=>'ΓΙΩΡΓΟΣ','mname'=>'ΕΛΕΝΗ','idno' => 'Χ664666', 'sex' => 'female', 'birthdate' => '2000-01-01', 'birthplace'=>'ΓΑΛΑΤΣΙ ΑΤΤΙΚΗΣ', 'email'=>'ach@yahoo.gr', 'telephone'=>'2102525096', 'afm' => '067335676');
$arr_students[] = array('last'=>'ΝΕΟΧΩΡΛΗ', 'first'=>'ΕΛΕΝΗ','fname'=>'ΚΩΝΣΤΑΝΤΙΝΟΣ','mname'=>'ΣΤΑΥΡΟΥΛΑ','idno' => 'ΖΔ111111', 'sex' => 'female', 'birthdate' => '1992-11-01', 'birthplace'=>'ΦΙΛΑΔΕΛΦΕΙΑ ΑΤΤΙΚΗΣ', 'email'=>'ach@yahoo.gr', 'telephone'=>'2102520755', 'afm' => '077335676');
$arr_students[] = array('last'=>'ΒΛΑΧΟΔΗΜΟΣ', 'first'=>'ΝΙΚΟΣ','fname'=>'ΜΑΡΙΟΣ','mname'=>'ΜΑΡΙΑ','idno' => 'Ψ664666', 'sex' => 'male', 'birthdate' => '1995-05-22', 'birthplace'=>'ΙΛΙΟΝ ΑΤΤΙΚΗΣ', 'email'=>'ach@yahoo.gr', 'telephone'=>'2106565755', 'afm' => '087335676');
$arr_students[] = array('last'=>'ΤΡΙΑΝΤΑΦΥΛΛΟΥ', 'first'=>'ΓΙΩΡΓΟΣ','fname'=>'ΣΤΑΥΡΟΣ','mname'=>'ΧΑΡΟΥΛΑ','idno' => 'Τ664666', 'sex' => 'male', 'birthdate' => '1984-12-26', 'birthplace'=>'ΠΕΙΡΑΙΑΣ ΑΤΤΙΚΗΣ', 'email'=>'ach@yahoo.gr', 'telephone'=>'2102525096', 'afm' => '067335676');
$arr_students[] = array('last'=>'ΔΕΛΗΓΙΑΝΝΗΣ', 'first'=>'ΧΑΡΗΣ','fname'=>'ΓΙΩΡΓΟΣ','mname'=>'ΕΥΓΕΝΙΑ','idno' => 'Ζ664666', 'sex' => 'male', 'birthdate' => '1994-02-10', 'birthplace'=>'ΘΕΣΣΑΛΟΝΙΚΗ', 'email'=>'ach@yahoo.gr', 'telephone'=>'2310454545', 'afm' => '067335666');
//save demo STUDENTS
$created_student_ids = array();
foreach ($arr_students as $key => $value) {
$entity_object = $entity_storage_student->create($value);
$entity_storage_student->save($entity_object);
$created_student_ids[] = $entity_object->id();
}
//------------------------------------------------------------------------------------------------//
//-------------------------------CREATE EIDIKOTITES ENTITIES------------------------------------------//
//------------------------------------------------------------------------------------------------//
$arr_eidikotites = array ();
$arr_eidikotites[] = array('name'=>'ΕΙΔΙΚΟΣ ΕΦΑΡΜΟΓΩΝ ΠΛΗΡΟΦΟΡΙΚΗΣ', 'eidcode' => '010101');
$arr_eidikotites[] = array('name'=>'ΤΕΧΝΙΚΟΣ ΒΙΟΜΗΧΑΝΙΚΟΥ ΛΟΓΙΣΜΙΚΟΥ', 'eidcode' => '010103');
$arr_eidikotites[] = array('name'=>'ΕΙΔΙΚΟΣ ΓΕΩΓΡΑΦΙΚΩΝ ΣΥΣΤΗΜΑΤΩΝ ΠΛΗΡΟΦΟΡΙΩΝ (G.I.S.)', 'eidcode' => '010104');
$arr_eidikotites[] = array('name'=>'ΤΕΧΝΙΚΟΣ ΤΗΛΕΠΛΗΡΟΦΟΡΙΚΗΣ', 'eidcode' => '010105');
$arr_eidikotites[] = array('name'=>'ΤΕΧΝΙΚΟΣ ΕΦΑΡΜΟΓΩΝ ΙΑΤΡΙΚΗΣ ΠΛΗΡΟΦΟΡΙΚΗΣ', 'eidcode' => '010106');
//create demo eidikotites
$created_eidikotites_ids = array();
foreach ($arr_eidikotites as $key => $value) {
$entity_object = $entity_storage_eidikotita->create($value);
$entity_storage_eidikotita->save($entity_object);
$created_eidikotites_ids[] = $entity_object->id();
}
//------------------------------------------------------------------------------------------------//
//-------------------------------CREATE REGIONS ENTITIES------------------------------------------//
//------------------------------------------------------------------------------------------------//
$arr_regions = array();
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΑΤΤΙΚΗΣ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΒΟΡΕΙΟΥ ΑΙΓΑΙΟΥ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΔΥΤΙΚΗΣ ΕΛΛΑΔΑΣ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΔΥΤΙΚΗΣ ΜΑΚΕΔΟΝΙΑΣ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΚΕΝΤΡΙΚΗΣ ΜΑΚΕΔΟΝΙΑΣ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΑΝΑΤΟΛΙΚΗΣ ΜΑΚΕΔΟΝΙΑΣ-ΘΡΑΚΗΣ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΘΕΣΣΑΛΙΑΣ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΗΠΕΙΡΟΥ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΚΡΗΤΗΣ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΝΟΤΙΟΥ ΑΙΓΑΙΟΥ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΙΟΝΙΩΝ ΝΗΣΩΝ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΠΕΛΟΠΟΝΝΗΣΟΥ');
$arr_regions[] = array('name'=>'ΔΙΟΙΚ. ΠΕΡΙΦ. ΣΤΕΡΕΑΣ ΕΛΛΑΔΑΣ');
//save regions
$created_regions_ids = array();
foreach ($arr_regions as $key => $value) {
$entity_object = $entity_storage_regions->create($value);
$entity_storage_regions->save($entity_object);
$created_regions_ids[] = $entity_object->id();
}
//------------------------------------------------------------------------------------------------//
//-------------------------------CREATE SCHOOL(IEK) ENTITIES------------------------------------------//
//------------------------------------------------------------------------------------------------//
$arr_iek = array();
$arr_iek[] = array('region_id'=> $created_regions_ids[0], 'name'=> 'ΣΙΒΙΤΑΝΙΔΕΙΟΣ', 'iekcode'=>'0053076', 'iektype' => 'public');
$arr_iek[] = array('region_id'=> $created_regions_ids[0], 'name'=> 'Ο.Α.Ε.Δ. - ΥΜΗΤΤΟΥ', 'iekcode'=>'0050665', 'iektype' => 'public');
$arr_iek[] = array('region_id'=> $created_regions_ids[0], 'name'=> 'TechnoGrafico', 'iekcode'=>'0100221', 'iektype' => 'private');
$arr_iek[] = array('region_id'=> $created_regions_ids[8], 'name'=> 'Ο.Α.Ε.Δ. - ΗΡΑΚΛΕΙΟΥ ΚΡΗΤΗΣ', 'iekcode'=>'0170102', 'iektype' => 'public');
$arr_iek[] = array('region_id'=> $created_regions_ids[1], 'name'=> 'ΧΙΟΥ', 'iekcode'=>'0007545', 'iektype' => 'public');
$arr_iek[] = array('region_id'=> $created_regions_ids[11], 'name'=> 'ΣΠΑΡΤΗΣ', 'iekcode'=>'0005823', 'iektype' => 'public');
$arr_iek[] = array('region_id'=> $created_regions_ids[12],'name'=> 'ΧΑΛΚΙΔΑΣ', 'iekcode'=>'0004911', 'iektype' => 'public');
$arr_iek[] = array('region_id'=> $created_regions_ids[11], 'name'=> 'ΠΥΡΓΟΥ', 'iekcode'=>'0005423', 'iektype' => 'public');
$arr_iek[] = array('region_id'=> $created_regions_ids[10], 'name'=> 'ΚΕΡΚΥΡΑΣ', 'iekcode'=>'0005210', 'iektype' => 'public');
//save iek entities
$created_iek_ids = array();
foreach ($arr_iek as $key => $value) {
$entity_object = $entity_storage_iek->create($value);
$entity_storage_iek->save($entity_object);
$created_iek_ids[] = $entity_object->id();
}
//------------------------------------------------------------------------------------------------//
//-------------------------------CREATE AITISEIS ENTITIES------------------------------------------//
//------------------------------------------------------------------------------------------------//
$arr_aitiseis = array();
//$arr_aitiseis[] = array('prabek'=> '22/10-1-2017', 'numbek'=> '123','regno'=> '010');
//$arr_aitiseis[] = array('prabek'=> '65/9-1-2017', 'numbek'=> '77','regno'=> '066');
//$arr_aitiseis[] = array('prabek'=> '10/10-2-2017', 'numbek'=> '65','regno'=> '045');
//$arr_aitiseis[] = array('prabek'=> '9/9-2-2017', 'numbek'=> '17','regno'=> '023');
for ($i=0; $i <=249; $i++) {
$arr_aitiseis[$i]['eidikotita_id'] = $created_eidikotites_ids[rand(0,4)];
$arr_aitiseis[$i]['student_id'] = $created_student_ids[rand(0,4)];
$arr_aitiseis[$i]['region_id'] = $created_regions_ids[rand(0,12)];
$arr_aitiseis[$i]['iek_id'] = $created_iek_ids[rand(0,8)];
$arr_aitiseis[$i]['prabek'] = '123/45';
$arr_aitiseis[$i]['numbek'] = '18';
$arr_aitiseis[$i]['regno'] = '181';
$arr_aitiseis[$i]['state'] = 'DRAFT';
}
foreach ($arr_aitiseis as $key => $value) {
$entity_object = $entity_storage_request->create($value);
$entity_storage_request->save($entity_object);
}
}
function entitychanger_uninstall() {
//delete all student and eidikotites
$entity_manager = \Drupal::entityManager();
$entity_storage_student = $entity_manager->getStorage('student_entity');
$entity_storage_eidikotita = $entity_manager->getStorage('eidikotita_entity');
$entity_storage_region = $entity_manager->getStorage('region_entity');
$entity_storage_school = $entity_manager->getStorage('school_entity');
$entity_storage_aitisi = $entity_manager->getStorage('aitisi_entity');
//delete all student and eidikotites
$entity_manager = \Drupal::entityManager();
$entity_storage_student = $entity_manager->getStorage('student_entity');
$entity_storage_eidikotita = $entity_manager->getStorage('eidikotita_entity');
$entity_storage_region = $entity_manager->getStorage('region_entity');
$entity_storage_school = $entity_manager->getStorage('school_entity');
$entity_storage_aitisi = $entity_manager->getStorage('aitisi_entity');
//delete all aitiseis
$all_aitiseis = $entity_storage_aitisi->loadMultiple(NULL);
$entity_storage_aitisi->delete($all_aitiseis);
//delete all aitiseis
$all_aitiseis = $entity_storage_aitisi->loadMultiple(NULL);
$entity_storage_aitisi->delete($all_aitiseis);
//delete all student entities
$all_students = $entity_storage_student->loadMultiple(NULL);
$entity_storage_student->delete($all_students);
//delete all student entities
$all_students = $entity_storage_student->loadMultiple(NULL);
$entity_storage_student->delete($all_students);
//delete all eidikotita entities
$all_eidikotites = $entity_storage_eidikotita->loadMultiple(NULL);
$entity_storage_eidikotita->delete($all_eidikotites);
//delete all eidikotita entities
$all_eidikotites = $entity_storage_eidikotita->loadMultiple(NULL);
$entity_storage_eidikotita->delete($all_eidikotites);
//delete all region entities
$all_regions = $entity_storage_region->loadMultiple(NULL);
$entity_storage_region->delete($all_regions);
//delete all region entities
$all_regions = $entity_storage_region->loadMultiple(NULL);
$entity_storage_region->delete($all_regions);
//delete all school emtities
$all_eidikotites = $entity_storage_school->loadMultiple(NULL);
$entity_storage_school->delete($all_eidikotites);
//delete all school emtities
$all_eidikotites = $entity_storage_school->loadMultiple(NULL);
$entity_storage_school->delete($all_eidikotites);