several updates in Drupal Controllers

parent 4fb6c85a
......@@ -182,6 +182,14 @@ epal.ministry.massive_mail_unallocated:
_controller: '\Drupal\epal\Controller\InformUnlocatedStudents::sendMailToUnallocatedStudents'
requirements:
_user_is_logged_in: 'TRUE'
epal.ministry.massive_mail_unallocated_smallclass:
path: '/ministry/send-unallocated-sc-massive-mail'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\InformUnlocatedStudents::sendMailToUnallocatedStudentsSC'
requirements:
_user_is_logged_in: 'TRUE'
epal.ministry.massive_mail_located:
path: '/ministry/send-located-massive-mail'
options:
......
......@@ -559,9 +559,10 @@ public function checkCapacityAndArrange($epalId, $classId, $secCourId, $limitup,
//Αν δεν απέμειναν θέσεις (δηλαδή αν η χωρητικότητα είναι μικρότερη ή ίση από το πλήθος μαθητών που ήδη φοιτούν στο σχολείο)
//τότε διέγραψέ τους από τον προσωρινό πίνακα αποτελεσμάτων και βάλε τους στον στον πίνακα εκκρεμοτήτων
if ($newlimit <= 0) {
foreach($students as $student) {
foreach($students as $student) {
if ($student->currentepal !== $student->epal_id) {
if ($newlimit <= 0) {
//print_r("<br>ΣΕ ΕΚΚΡΕΜΟΤΗΤΑ - ΔΙΑΓΡΑΦΗ: " . $student->student_id);
array_push($this->pendingStudents, $student->student_id);
try {
......@@ -574,9 +575,27 @@ public function checkCapacityAndArrange($epalId, $classId, $secCourId, $limitup,
$transaction->rollback();
return ERROR_DB;
}
} //end if currentepal
} //end foreach
} //endif newlimit
} //endif new limit
else { //$newlimit > 0
//NEW CODE LINES
if ($this->choice_id !== 1)
$this->removeFromPendingStudents($student->student_id);
}
//END NEW CODE LINES
} //endif currentepal
} //end foreach
//NEW CODE LINES
/*
else {
foreach($students as $student)
if ($student->currentepal !== $student->epal_id)
if ($this->choice_id !== 1)
$this->removeFromPendingStudents($student->student_id);
}
*/
//END NEW CODE LINES
return SUCCESS;
......
......@@ -92,14 +92,15 @@ class InformUnlocatedStudents extends ControllerBase {
$cnt_success = 0;
$cnt_fail = 0;
// εύρεση μαθητών που η αίτησή τους ΔΕΝ ικανοποιήθηκε
// εύρεση μαθητών που η αίτησή τους ΔΕΝ ικανοποιήθηκε,
//(δεν κατανεμήθηκαν πουθενά)
$sCon = $this->connection->select('epal_student_class', 'eStudent')
->fields('eStudent', array('student_id'))
->condition('eStudent.finalized', 0 , '=');
->fields('eStudent', array('student_id'));
//->condition('eStudent.finalized', 0 , '=');
$epalStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$studentIds = array();
//array_push($studentIds,-1);
array_push($studentIds,-1);
foreach ($epalStudents as $epalStudent)
array_push($studentIds, $epalStudent->student_id);
......@@ -107,7 +108,6 @@ class InformUnlocatedStudents extends ControllerBase {
$sCon = $this->connection->select('epal_student', 'eStudent')
->fields('eStudent', array('id', 'user_id', 'created'))
->condition('eStudent.id', $studentIds, 'NOT IN');
//$numNoAllocated = $sCon->countQuery()->execute()->fetchField();
$epalNonLocatedStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($epalNonLocatedStudents as $epalNonLocatedStudent) {
......@@ -155,6 +155,106 @@ class InformUnlocatedStudents extends ControllerBase {
}
public function sendMailToUnallocatedStudentsSC(Request $request) {
try {
if (!$request->isMethod('GET')) {
return $this->respondWithStatus([
"message" => t("Method Not Allowed")
], Response::HTTP_METHOD_NOT_ALLOWED);
}
//user validation
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if (!$user) {
return $this->respondWithStatus([
'message' => t("User not found"),
], Response::HTTP_FORBIDDEN);
}
//user role validation
$roles = $user->getRoles();
$validRole = false;
foreach ($roles as $role)
if ($role === "ministry") {
$validRole = true;
break;
}
if (!$validRole) {
return $this->respondWithStatus([
'message' => t("User Invalid Role"),
], Response::HTTP_FORBIDDEN);
}
$cnt_success = 0;
$cnt_fail = 0;
// εύρεση μαθητών που η αίτησή τους ΔΕΝ ικανοποιήθηκε,
//(δεν κατανεμήθηκαν πουθενά)
$sCon = $this->connection->select('epal_student_class', 'eStudent')
->fields('eStudent', array('student_id'))
->condition('eStudent.finalized', 0 , '=');
$epalStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$studentIds = array();
array_push($studentIds,-1);
foreach ($epalStudents as $epalStudent)
array_push($studentIds, $epalStudent->student_id);
$sCon = $this->connection->select('epal_student', 'eStudent')
->fields('eStudent', array('id', 'user_id', 'created'))
->condition('eStudent.id', $studentIds, 'IN');
$epalNonLocatedStudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
foreach ($epalNonLocatedStudents as $epalNonLocatedStudent) {
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('user_id' => $epalNonLocatedStudent->user_id));
$epalUser = reset($epalUsers);
if ($epalUser) {
$user = $this->entityTypeManager->getStorage('user')->load($epalUser->user_id->target_id);
//$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('uid' => $epalUser->user_id));
//$user = reset($users);
if ($user) {
$langcode = $user->getPreferredLangcode();
if ($this->sendEmailToUnallocated($user->getEmail(), $epalNonLocatedStudent->id, $epalNonLocatedStudent->created, $langcode))
$cnt_success++;
}
else {
return $this->respondWithStatus([
'message' => t("user not found"),
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
} else {
$cnt_fail++;
}
} //end foreach
return $this->respondWithStatus([
'message' => t("post successful"),
'num_success_mail' => $cnt_success,
'num_fail_mail' => $cnt_fail,
//'test' => $test,
], Response::HTTP_OK);
} //end try
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
return $this->respondWithStatus([
"message" => t("An unexpected problem occured during sendMailToStudents Method ")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
//sendEmail(e-mail address, A/A, application Date, lang)
private function sendEmailToUnallocated($email, $appId, $appDate, $langcode) {
$mailManager = \Drupal::service('plugin.manager.mail');
......@@ -163,9 +263,10 @@ class InformUnlocatedStudents extends ControllerBase {
$key = 'massive_mail_unallocated'; //to be checked..
$to = $email;
$params['message'] = "Σας ενημερώνουμε ότι η αίτησή σας με Α/Α: " . $appId . " - " . date('d-m-y H:i:s', $appDate)
. " δεν ικανοποιήθηκε. Παρακαλώ επικοινωνήστε άμεσα τηλεφωνικά με τη Διεύθυνση Δευτεροβάθμιας Εκπαίδευσης / Τμήμα Επαγγελματικής Εκπαίδευσης,"
. "\r\nΤεστ1\nΤεστ2" ;//e-mail body
$params['message'] = "Σας ενημερώνουμε ότι η αίτησή σας με Α/Α: " . $appId . " / " . date('d-m-y H:i:s', $appDate)
. " δεν ικανοποιήθηκε. Παρακαλώ επικοινωνήστε άμεσα τηλεφωνικά με τη Διεύθυνση Δευτεροβάθμιας Εκπαίδευσης / Τμήμα Επαγγελματικής Εκπαίδευσης."
. "\r\n\r\n Ομάδα Διαχείρισης της εφαρμογής e-epal."
. "\r\n Προσοχή: το μήνυμα που διαβάζετε είναι αυτοματοποιημένο. Παρακαλώ μην απαντάτε σε αυτό το μήνυμα.." ;//e-mail body" ;//e-mail body
//add new lines with SENDER name - check it
//$params['subject'] = t('Μη ικανοποίηση ηλεκτρονικής αίτησης για εγγραφή σε ΕΠΑΛ');
......@@ -231,7 +332,7 @@ class InformUnlocatedStudents extends ControllerBase {
$studentIds = array();
//if sizeof(studentIds = 0..distribution has not been made!)
//array_push($studentIds, -1);
array_push($studentIds, -1);
foreach ($epalStudents as $epalStudent)
array_push($studentIds, $epalStudent->student_id);
......@@ -328,12 +429,13 @@ class InformUnlocatedStudents extends ControllerBase {
$key = 'massive_mail_located';
$to = $email;
$params['message'] = "Σας ενημερώνουμε ότι η αίτησή σας με Α/Α: " . $appId . " - " . date('d-m-y H:i:s', $appDate)
$params['message'] = "Σας ενημερώνουμε ότι η αίτησή σας με Α/Α: " . $appId . " / " . date('d-m-y H:i:s', $appDate)
. " ΙΚΑΝΟΠΟΙΗΘΗΚΕ. Έχετε επιλεγεί να γίνει η εγγραφή σας στο " . $schName .", που βρίσκεται στη διεύθυνση: " . $schStreet
. ". Παρακαλώ επικοινωνήστε άμεσα με τη Σχολική Μονάδα τοποθέτησής σας"
. ", ώστε να ενημερωθείτε για τη διαδικασία που πρέπει να ακολουθήσετε για την εγγραφή σας στο σχολείο. "
. "Τηλέφωνο επικοινωνίας σχολείου: " . $schTel
. "\r\nΤεστ1\nΤεστ2" ;//e-mail body
. "\r\n\r\n Ομάδα Διαχείρισης της εφαρμογής e-epal."
. "\r\n Προσοχή: το μήνυμα που διαβάζετε είναι αυτοματοποιημένο. Παρακαλώ μην απαντάτε σε αυτό το μήνυμα." ;//e-mail body
//$this->logger->info($params['message']);
......
......@@ -42,14 +42,20 @@ import { API_ENDPOINT } from '../../app.settings';
<h5> >Αποστολή ειδοποιήσεων <br></h5>
<br><br>
<div class="col-md-12">
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents(true)" [disabled] = "!applicantsResultsDisabled" >
Μαζική αποστολή e-mail στους μαθητές που ΔΕΝ τοποθετήθηκαν<span class="glyphicon glyphicon-menu-right"></span>
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents(1)" [disabled] = "!applicantsResultsDisabled" >
Αποστολή e-mail στους μαθητές που ΔΕΝ τοποθετήθηκαν<span class="glyphicon glyphicon-menu-right"></span>
</button>
</div>
<br>
<div class="col-md-12">
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents(false)" [disabled] = "!applicantsResultsDisabled">
Μαζική αποστολή e-mail στους μαθητές που τοποθετήθηκαν<span class="glyphicon glyphicon-menu-right"></span>
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents(2)" [disabled] = "!applicantsResultsDisabled" >
Αποστολή e-mail στους μαθητές που τοποθετήθηκαν προσωρινά σε ολιγομελή τμήματα<span class="glyphicon glyphicon-menu-right"></span>
</button>
</div>
<br>
<div class="col-md-12">
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents(3)" [disabled] = "!applicantsResultsDisabled">
Αποστολή e-mail στους μαθητές που τοποθετήθηκαν<span class="glyphicon glyphicon-menu-right"></span>
</button>
</div>
......
......@@ -84,8 +84,8 @@ export default class MinistryHome implements OnInit {
this.userDataGroup = this.fb.group({
minedu_username: ['minedu01', [Validators.required]],
minedu_userpassword: ['12345678', [Validators.required]],
minedu_username: ['', [Validators.required]],
minedu_userpassword: ['', [Validators.required]],
cu_name: [''],
auth_role: [''],
});
......
import { Component, OnInit, OnDestroy, ElementRef, ViewChild} from "@angular/core";
let jsPDF = require('jspdf');
//let jsPDF = require('jspdf');
import { Injectable } from "@angular/core";
import { AppSettings } from '../../app.settings';
import { HelperDataService } from '../../services/helper-data-service';
......@@ -207,6 +207,10 @@ import { BehaviorSubject, Subscription } from 'rxjs/Rx';
ind--;
this.userActive = ind + 1;
this.showLoader$.next(true);
//OBSOLETE
this.SubmitedDetailsSub = this._hds.getStudentDetails(this.userActive + 1).subscribe(data => {
this.SubmitedDetails$.next(data);
this.showLoader$.next(false);
......@@ -220,6 +224,8 @@ import { BehaviorSubject, Subscription } from 'rxjs/Rx';
console.log("Getting Schools");
this.showLoader$.next(false);
});
this.EpalChosenSub = this._hds.getEpalchosen(this.userActive + 1).subscribe(data => {
this.EpalChosen$.next(data)
},
......@@ -228,6 +234,7 @@ import { BehaviorSubject, Subscription } from 'rxjs/Rx';
console.log("Error Getting Schools");
},
() => console.log("Getting Schools"));
}
createPdfServerSide() {
......
import { Component, OnInit, OnDestroy,ElementRef, ViewChild} from "@angular/core";
let jsPDF = require('jspdf');
//let jsPDF = require('jspdf');
import { Injectable } from "@angular/core";
import { AppSettings } from '../../app.settings';
import { HelperDataService } from '../../services/helper-data-service';
......@@ -84,6 +84,9 @@ import { BehaviorSubject, Subscription } from 'rxjs/Rx';
this.route.params.subscribe(params => {this.StudentId = params['id'];});
}
//OBSOLETE
/*
createPdf()
{
......@@ -95,6 +98,7 @@ import { BehaviorSubject, Subscription } from 'rxjs/Rx';
doc.save('applications.pdf');
});
}
*/
createPdfServerSide()
{
......
......@@ -677,9 +677,11 @@ export class HelperDataService implements OnInit, OnDestroy {
let options = new RequestOptions({ headers: headers });
let route = "";
if (unallocated == true)
if (unallocated == 1)
route = "ministry/send-unallocated-massive-mail";
else
else if(unallocated == 2)
route = "ministry/send-unallocated-sc-massive-mail";
else if(unallocated == 3)
route = "ministry/send-located-massive-mail";
return this.http.get(`${AppSettings.API_ENDPOINT}/` + route, options)
......@@ -992,7 +994,7 @@ createPdfServerSide_OLD(auth_token, role) {
console.log(data);
var blob = new Blob([data['pdfString']], {type: 'application/pdf'});
console.log(blob);
FileSaver.saveAs(blob, "testData.pdf");
FileSaver.saveAs(blob, "appConfirmation.pdf");
},
err => console.error(err),
......@@ -1011,7 +1013,7 @@ createPdfServerSide_OLD(auth_token, role) {
var blob = new Blob([data['_body']], {type: 'application/pdf'});
console.log(blob);
FileSaver.saveAs(blob, "testData.pdf");
FileSaver.saveAs(blob, "appConfirmation.pdf");
//console.log(data['_body']);
},
error => {
......@@ -1050,7 +1052,7 @@ createPdfServerSide(headerid) {
.subscribe(
data => {
console.log(data);
FileSaver.saveAs(data, "testData.pdf");
FileSaver.saveAs(data, "appConfirmation.pdf");
},
err => console.error(err),
() => console.log('PDF export completed')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment