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;
}
/**
......
......@@ -110,6 +110,7 @@ function entitychanger_install() {
//save demo STUDENTS
$created_student_ids = array();
foreach ($arr_students as $key => $value) {
......@@ -169,15 +170,15 @@ function entitychanger_install() {
//-------------------------------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');
$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
......@@ -193,16 +194,23 @@ function entitychanger_install() {
//-------------------------------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];
//$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';
}
......@@ -253,17 +261,19 @@ function entitychanger_uninstall() {
* Implements hook_user_login().
*/
function entitychanger_user_login($account){
$path = '';
// Get User Role(s).
$roles = $account->getRoles();
if(isset($roles) && is_array($roles)) {
if(in_array('diaxeiristis_iek', $roles)) {
$path ='aitiseis';
$path ='datacenter/aitiseis/iek';
} else if(in_array('diaxeiristis_eoppep', $roles)) {
$path = 'node/51';
} else if(in_array('aiton', $roles)) {
$path = 'node/7';
$path = 'maincustomform/form/multistep_one';
} else if(in_array('administrator', $roles)) {
$path = 'maincustomform/form/multistep_one';
}
$url_object = \Drupal::service('path.validator')->getUrlIfValid($path);
......
.progressbar-wrapper{padding:25px;background:#fff;border-radius:4px;text-align:center}.f1-steps{overflow:hidden;position:relative;margin-top:20px}.f1-progress{position:absolute;top:24px;left:0;width:100%;height:1px;background:#ddd}.f1-progress-line{position:absolute;top:0;left:0;height:1px;background:#466bc8}.f1-step{position:relative;float:left;width:33.3333%;padding:0 5px}.f1-step-icon{display:inline-block;width:40px;height:40px;margin-top:4px;background:#ddd;font-size:16px;color:#fff;line-height:40px;border-radius:50%}.f1-step.activated .f1-step-icon{background:#fff;border:1px solid #466bc8;color:#466bc8;line-height:38px}.f1-step.active .f1-step-icon{width:48px;height:48px;margin-top:0;background:#466bc8;font-size:22px;line-height:48px}.f1-step p{color:#ccc}.f1-step.activated p{color:#466bc8}.f1-step.active p{color:#466bc8}form.multistep-two-form h2.form-title{padding:15px}form.multistep-two-form .form-group{margin-bottom:1.2em;overflow:hidden}form.multistep-two-form .form-group label{float:left;width:28%;padding-right:10px;padding-top:8px;text-align:left}form.multistep-two-form .form-group .form-control{font-size:16px;padding:4px 8px;height:36px;width:72%;float:left;border-radius:4px !important}form.multistep-two-form .form-group .form-control[disabled]{background-color:grey;opacity:0.55;color:white;font-weight:bold}form.multistep-two-form .less-p label{padding-top:0}form.multistep-two-form #edit-sex--wrapper{padding-bottom:15px}form.multistep-two-form #edit-sex--wrapper legend{float:left;width:25%;font-size:18px;font-weight:bold;border-style:none}form.multistep-two-form #edit-sex--wrapper .fieldset-wrapper{float:left;width:75%}form.multistep-two-form #edit-sex--wrapper .fieldset-wrapper #edit-sex label{font-size:16px;font-weight:bold}
/*# sourceMappingURL=maincustomform.css.map */
\ No newline at end of file
(function ($, Drupal) {
Drupal.behaviors.logInForm = {
attach: function (context, settings) {
//get all available regions
jQuery.ajax({
url: Drupal.url('/jsonapi/region_entity/region_entity?_format=api_json&fields[region_entity--region_entity]=id,name'),
method: 'GET',
success: function(data, status, xhr) {
var arrObjects = data["data"];
var sel = $("#edit-region-select");
sel.empty();
arrObjects.forEach( function (arrayItem)
{
var attributes = arrayItem['attributes'];
sel.append('<option value="' + attributes['id'] + '">' + attributes['name'] + '</option>');
})
}
});
//select iek
jQuery.ajax({
url: Drupal.url('/jsonapi/school_entity/school_entity?_format=api_json&fields[school_entity--school_entity]=id,name'),
method: 'GET',
success: function(data, status, xhr) {
var arrObjects = data["data"];
var sel = $("#edit-iek-select");
sel.empty();
arrObjects.forEach( function (arrayItem)
{
var attributes = arrayItem['attributes'];
sel.append('<option value="' + attributes['id'] + '">' + attributes['name'] + '</option>');
})
}
});
//select eidikotita
jQuery.ajax({
url: Drupal.url('/jsonapi/eidikotita_entity/eidikotita_entity?_format=api_json&fields[eidikotita_entity--eidikotita_entity]=id,name'),
method: 'GET',
success: function(data, status, xhr) {
var arrObjects = data["data"];
var sel = $("#edit-eidikotita-select");
sel.empty();
arrObjects.forEach( function (arrayItem)
{
var attributes = arrayItem['attributes'];
sel.append('<option value="' + attributes['id'] + '">' + attributes['name'] + '</option>');
})
}
});
function getCsrfToken(callback) {
jQuery
.get(Drupal.url('/session/token'))
.done(function (data) {
var csrfToken = data;
callback(csrfToken);
});
}
function postNode(csrfToken, node) {
jQuery.ajax({
//url: 'http://localhost/drupal8new/api/custom/postentity/?_format=json',
url: Drupal.url('api/custom/postentity/?_format=json'),
method: 'POST',
headers: {
'Content-Type': 'application/hal+json',
'Authorization': 'Basic YWRtaW46Y3Jhenk2MTQ=',
'X-CSRF-Token': csrfToken
},
data: JSON.stringify(node),
success: function(data, textStatus, jqXHR)
{
if($.isNumeric(data['return-message'])) {
var insertedId = data['return-message'];
// e.stopPropagation();
window.location.href = Drupal.url('aitisi/'+insertedId);
} else {
$('#block-customformexample').html(data['return-message']);
}
},
error: function (jqXHR, textStatus, errorThrown)
{
console.log(textStatus);
}
});
}
//$("form.custom-form", context).submit(function(e) {
/* $("form.multistep-three-form #edit-submit", context).click(function(e) {
e.preventDefault();
alert($(this).attr('id'));
var first = drupalSettings.previousFormValues.first;
var last = drupalSettings.previousFormValues.last;
var fname = drupalSettings.previousFormValues.fname;
var mname = drupalSettings.previousFormValues.mname;
var idno = drupalSettings.previousFormValues.idno;
var birth_date = drupalSettings.previousFormValues.birth_date;
var birth_place = drupalSettings.previousFormValues.birth_place;
var email = drupalSettings.previousFormValues.email;
var telephone = drupalSettings.previousFormValues.telephone;
var afm = drupalSettings.previousFormValues.afm;
var sex = drupalSettings.previousFormValues.sex;
if(!sex) {
sex = 'male';
} else {
sex = 'female';
}
var prabek = $('form.multistep-three-form #edit-prabek').val();
var numbek = $('form.multistep-three-form #edit-numbek').val();
var regno = $('form.multistep-three-form #edit-regno').val();
var iek_select = $('form.multistep-three-form #edit-iek-select').val();
var region_select = $('form.multistep-three-form #edit-region-select').val();
var eidikotita_select = $('form.multistep-three-form #edit-eidikotita-select').val();
var newNode = {
"first": [{
"value": first
}],
"last": [{
"value": last
}],
"fname": [{
"value": fname
}],
"mname": [{
"value": mname
}],
"birthdate": [{
"value": birth_date
}],
"birthplace": [{
"value": birth_place
}],
"idno": [{
"value": idno
}],
"sex": [{
"value": sex
}],
"email": [{
"value": email
}],
"telephone": [{
"value": telephone
}],
"afm": [{
"value": afm
}],
"prabek": [{
"value": prabek
}],
"numbek": [{
"value": numbek
}],
"regno": [{
"value": regno
}],
"iek_id": [{
"value": iek_select
}],
"region_id": [{
"value": region_select
}],
"eidikotita_id": [{
"value": eidikotita_select
}],
};
getCsrfToken(function (csrfToken) {
postNode(csrfToken, newNode);
});
//return false;
});*/
}
};
})(jQuery, Drupal);
function isInt16(n) {
return +n === n && !(n % 1) && n < 0x8000 && n >= -0x8000;
}
(function ($, Drupal) {
Drupal.behaviors.progressline = {
attach: function (context, settings) {
// var parent_fieldset = $(this).parents('fieldset');
var next_step = true;
// navigation steps / progress steps
var current_active_step = $('.multistep-two-form').find('.f1-step.active');
var progress_line = $('.multistep-two-form').find('.f1-progress-line');
if( next_step ) {
// change icons
current_active_step.removeClass('active').addClass('activated').next().addClass('active');
// progress bar
bar_progress(progress_line, 'right');
}
// previous step
/*
$('.custom-form #edit-back').on('click', function() {
// navigation steps / progress steps
var current_active_step = $('.custom-form').find('.f1-step.active');
var progress_line = $('.custom-form').find('.f1-progress-line');
// change icons
current_active_step.removeClass('active').prev().removeClass('activated').addClass('active');
// progress bar
bar_progress(progress_line, 'left');
}); */
}
};
})(jQuery, Drupal);
function scroll_to_class(element_class, removed_height) {
var scroll_to = $(element_class).offset().top - removed_height;
if($(window).scrollTop() != scroll_to) {
$('html, body').stop().animate({scrollTop: scroll_to}, 0);
}
}
function bar_progress(progress_line_object, direction) {
var number_of_steps = progress_line_object.data('number-of-steps');
var now_value = progress_line_object.data('now-value');