Commit 1657f00c authored by Νίκος Κατσαούνος's avatar Νίκος Κατσαούνος

conflicts fixed

parents 7e3efd8b a1c0e7c1
......@@ -412,3 +412,11 @@ epal.svc.getstudentinfo:
_controller: '\Drupal\epal\Controller\WSConsumer::getStudentEpalInfo'
requirements:
_user_is_logged_in: 'TRUE'
epal.offlinecalculation:
path: '/epal/offlinecalculationsmallclasses'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\SmallClassDistribution::OffLineCalculationSmallClasses'
requirements:
_user_is_logged_in: 'TRUE'
\ No newline at end of file
......@@ -1097,8 +1097,160 @@ public function getCoursesPerSchoolSmallClassesNight(Request $request, $courseAc
}
public function OffLineCalculationSmallClasses(Request $request)
{
try {
if (!$request->isMethod('GET')) {
return $this->respondWithStatus([
"message" => t("Method Not Allowed")
], Response::HTTP_METHOD_NOT_ALLOWED);
}
$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);
}
$selectionId = $user->init->value;
$userRoles = $user->getRoles();
$userRole = '';
foreach ($userRoles as $tmpRole)
{
if ($tmpRole === 'ministry')
{
$userRole = $tmpRole;
}
}
if ($userRole === '')
{
return $this->respondWithStatus([
'error_code' => 4003,
"message" => t("1")
], Response::HTTP_FORBIDDEN);
}
elseif ($userRole === 'ministry')
{
$schools = $this->entityTypeManager
->getStorage('eepal_school')
->loadByProperties(array());
}
else
{
$schools = [];
}
if ($schools)
{
$list = array();
foreach ($schools as $object)
{
$categ = $object->metathesis_region->value;
$limit = $this->getLimit(1, $categ);
$status = $this-> findStatus($object->id(),1,0,0);
$stat = intval($status);
$lim = intval($limit);
if ($stat <= $limit )
{
$object->set('approved_a', 0);
$object->save();
}
$limit = $this->getLimit(2, $categ);
$courses = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $object->id()));
if ($courses){
foreach ($courses as $key)
{
$sector = $key -> sector_id -> entity ->id();
$status = $this-> findStatus($object->id(),$classId, $sector, 0);
$stat = intval($status);
$lim = intval($limit);
if ($stat < $limit )
{
$key->set('approved_sector', 0);
$key->save();
}
}
}
$limit = $this->getLimit(3, $categ);
$courses = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $object->id()));
if ($courses){
foreach ($courses as $key)
{
$specialit = $key -> specialty_id -> entity -> id();
$status = $this-> findStatus($object->id(),3, 0, $specialit);
$stat = intval($status);
$lim = intval($limit);
if ($stat < $limit )
{
$key->set('approved_speciality', 0);
$key->save();
}
}
}
$limit = $this->getLimit(4, $categ);
$courses = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $object->id()));
if ($courses){
foreach ($courses as $key)
{
$specialit = $key -> specialty_id -> entity -> id();
$status = $this-> findStatus($object->id(),4, 0, $specialit);
$stat = intval($status);
$lim = intval($limit);
if ($stat < $limit )
{
$key->set('approved_speciality_d', 0);
$key->save();
}
}
}
}
return $this->respondWithStatus($list, Response::HTTP_OK);
}
else
{
return $this->respondWithStatus([
'message' => t('No schools found!'),
], Response::HTTP_FORBIDDEN);
}
}
//end try
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
return $this->respondWithStatus([
"message" => t("An unexpected problem occured during retrieveSettings Method ")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
}
......@@ -16,7 +16,7 @@ import { IAppState } from "../../store/store";
template: `
<div
class = "loading" *ngIf="dataRetrieved == -1 " >
class = "loading" *ngIf="(dataRetrieved == -1 || (showLoader | async) === true)" >
</div>
<div id="configNotice" (onHidden)="onHidden()" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
......@@ -176,6 +176,8 @@ import { IAppState } from "../../store/store";
private modalText: BehaviorSubject<string>;
private modalHeader: BehaviorSubject<string>;
private settings$: BehaviorSubject<any>;
private OffLineCalculation$: BehaviorSubject<any>;
private OffLineCalculationSub: Subscription;
private loginInfoSub: Subscription;
private settingsSub: Subscription;
private capacityDisabled: boolean;
......@@ -189,6 +191,7 @@ import { IAppState } from "../../store/store";
private dataRetrieved: number;
private smallClassApproved: boolean;
private wsIdentEnabled: boolean;
private showLoader: BehaviorSubject<boolean>;
private minedu_userName: string;
private minedu_userPassword: string;
......@@ -223,6 +226,8 @@ import { IAppState } from "../../store/store";
this.modalTitle = new BehaviorSubject("");
this.modalText = new BehaviorSubject("");
this.modalHeader = new BehaviorSubject("");
this.OffLineCalculation$ = new BehaviorSubject([{}]);
this.showLoader = new BehaviorSubject(false);
}
......@@ -368,11 +373,24 @@ import { IAppState } from "../../store/store";
}
toggleSmallClassesFilter(){
this.showLoader.next(true);
this.OffLineCalculationSub = this._hds.OffLinecalculationofSmallClasses(this.minedu_userName, this.minedu_userPassword)
.subscribe(data => {
this.showLoader.next(false);
this.OffLineCalculation$.next(data);
},
error => {
this.showLoader.next(false);
console.log("Error for the offlineCalculation");
});
this.smallClassApproved =!this.smallClassApproved;
}
toggleWsIdent(){
this.wsIdentEnabled =!this.wsIdentEnabled;
}
}
......@@ -417,6 +417,9 @@ import { StudentCourseChosen, StudentEpalChosen, StudentSectorChosen } from "../
}
// this.ServiceStudentCertifSub = this._hds.getServiceStudentCertification(8)
this.ServiceStudentCertifSub = this._hds.getServiceStudentPromotion('24','null','null','null','null','04-01-1997','0540961','777')
.subscribe(data => {
......
......@@ -1410,6 +1410,7 @@ createGelPdfServerSide(headerid, status) {
err => console.error(err));
}
isWS_ident_enabled()
{
this.loginInfo$.getValue().forEach(loginInfoToken => {
......@@ -1426,4 +1427,20 @@ isWS_ident_enabled()
}
OffLinecalculationofSmallClasses(username, userpassword) {
let headers = new Headers({
"Content-Type": "application/json",
});
this.createMinistryAuthorizationHeader(headers, username, userpassword);
let options = new RequestOptions({ headers: headers });
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/offlinecalculationsmallclasses` , options)
.map(response => response.json());
}
}
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