approvment

parent b903299b
......@@ -490,5 +490,21 @@ epal.ministryschools:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getSchoolsMinistry'
requirements:
_user_is_logged_in: 'TRUE'
epal.coursesperschoolsmin:
path: '/epal/coursesperschmin/{schoolid}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getCoursesPerSchoolMin'
requirements:
_user_is_logged_in: 'TRUE'
epal.approveclassesmin:
path: '/epal/approveclassesmin'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\SmallClassDistribution::ApproveClassesMin'
requirements:
_user_is_logged_in: 'TRUE'
\ No newline at end of file
......@@ -1496,4 +1496,111 @@ public function findStatusNew($id, $classId, $sector, $specialit)
return self::SUCCESS;
}
public function ApproveClassesMin(Request $request)
{
try {
if (!$request->isMethod('POST')) {
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);
}
if ($role === 'ministry') {
if ($content = $request->getContent()) {
$postData = json_decode($content);
$taxi = $postData -> taxi;
$arr = $postData -> classid;
$type = $postData -> type;
$valnew = intval($arr);
$typen = intval($type);
if ($taxi === 1)
$classesForConfirm = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(['id' => $valnew]);
if ($taxi === 2)
$classesForConfirm = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(['id' => $valnew]);
if ($taxi === 3 || $taxi === 4)
$classesForConfirm = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(['id' => $valnew]);
$classConfirm = reset($classesForConfirm);
if ($classConfirm) {
if ($typen === 1) {
if ($taxi === 1)
$classConfirm->set('approved_a', 1);
if ($taxi === 2)
$classConfirm->set('approved_sector', 1);
if ($taxi === 3)
$classConfirm->set('approved_speciality', 1);
if ($taxi === 4)
$classConfirm->set('approved_speciality_d', 1);
$classConfirm->save();
return $this->respondWithStatus(['message' => t('saved')], Response::HTTP_OK);
} elseif ($typen === 2) {
if ($taxi === 1)
$classConfirm->set('approved_a', 0);
if ($taxi === 2)
$classConfirm->set('approved_sector', 0);
if ($taxi === 3)
$classConfirm->set('approved_speciality', 0);
if ($taxi === 4)
$classConfirm->set('approved_speciality_d', 0);
$classConfirm->save();
return $this->respondWithStatus(['message' => t('saved')], Response::HTTP_OK);
} else {
return $this->respondWithStatus(['message' => t('Bad request')], Response::HTTP_FORBIDDEN);
}
} else {
return $this->respondWithStatus(['message' => t('Student not found')], Response::HTTP_FORBIDDEN);
}
} else {
return $this->respondWithStatus(['message' => t('post with no data')], Response::HTTP_BAD_REQUEST);
}
} else {
return $this->respondWithStatus(['error_code' => 4003], Response::HTTP_FORBIDDEN);
}
}//end try
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
return $this->respondWithStatus([
"message" => t("An unexpected problem occured during report")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
}
......@@ -2777,13 +2777,14 @@ public function FindCoursesPerSchoolGel(Request $request)
->condition('gSchool.school_id', $schoolid , '=')
->condition('gSchool.taxi', 'Α' , '=')
->condition(db_or()->condition('myschool_promoted', 1)->condition('myschool_promoted', 2))
->condition('gStudent.delapp', '0' , '=');
$studentPerSchool = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
$list[] = array(
'class' => 1,
'taxi' => 'Ά Λυκείου',
......@@ -3141,12 +3142,7 @@ public function getStudentPerSchoolGel(Request $request, $classId)
if ($classIdNew === "Α")
{
$existingstudents =array();
}
else
{
$sCon = $this->connection->select('gel_student', 'gStudent');
$sCon->leftJoin('gel_school', 'gSchool', 'gSchool.registry_no = gStudent.lastschool_registrynumber');
$sCon->fields('gStudent', array('id','lastschool_registrynumber','nextclass', 'delapp','name','studentsurname' ,'fatherfirstname' ,'motherfirstname' ,'regionaddress' ,'regiontk' ,'regionarea','telnum' ,'guardian_name' ,'guardian_surname','guardian_fathername ','guardian_mothername', 'birthdate', 'lastschool_schoolname','lastschool_class','lastschool_schoolyear','directorconfirm', 'created' ))
......@@ -3156,9 +3152,9 @@ public function getStudentPerSchoolGel(Request $request, $classId)
->condition('gStudent.delapp', '0' , '=')
->condition(db_or()->condition('myschool_promoted', 1)->condition('myschool_promoted', 2)->condition('myschool_promoted', 6)->condition('myschool_promoted', 7));
$existingstudents = $sCon->execute()->fetchAll(\PDO::FETCH_OBJ);
}
$this->logger->warning($sCon."existingstudents");
}
......
......@@ -30,20 +30,18 @@ import { IAppState } from "../../store/store";
</div>
<div style="min-height: 500px;">
<div style="min-height: 500px;">
<form>
<div *ngFor="let PdeNames$ of Pde$ | async; let k=index; let isOdd=odd; let isEven=even" style="font-size: 0.8em; font-weight: bold;">
<li class="list-group-item isclickable" (click)="clickPde(PdeNames$.id)"
[class.oddout]="isOdd"
[class.evenout]="isEven" [class.selectedout]="pdeActive === PdeNames$.id" >
<div class="col-md-12">{{PdeNames$.name}}</div>
<div class="col-md-12">{{PdeNames$.name}}!</div>
</li>
<div class = "row" [hidden]="PdeNames$.id !== pdeActive" style="margin: 0px 2px 0px 2px;">
<p style="margin-top: 20px; line-height: 2em;">Στην παρακάτω λίστα βλέπετε τα σχολεία ευθύνης σας.
<br/>Επιλέξτε σχολείο για να εμφανιστούν τα ολιγομελή τμήματα του σχολείου.</p>
<div class="row" style="margin-top: 20px; line-height: 2em;"><p><strong>Τα τμήματα</strong></p></div>
<div *ngFor="let SchoolNames$ of SchoolsPerPerf$ | async; let i=index; let isOdd=odd; let isEven=even" style="font-size: 0.8em; font-weight: bold;">
<div *ngFor="let SchoolNames$ of SchoolsPerPerf$ | async; let i=index; let isOdd=odd; let isEven=even" style="font-size: 0.8em; font-weight: bold;" [hidden]="PdeNames$.id !== pdeActive">
<li class="list-group-item isclickable" (click)="setActiveRegion(SchoolNames$.id)"
[class.oddout]="isOdd"
[class.evenout]="isEven" [class.selectedout]="regionActive === SchoolNames$.id" >
......@@ -81,59 +79,15 @@ import { IAppState } from "../../store/store";
</div>
</div>
</div>
</div>
</div>
</li>
</div>
<div class = "row" [hidden]="PdeNames$.id !== pdeActive" style="margin: 0px 2px 0px 2px;">
<p style="margin-top: 20px; line-height: 2em;">Στην παρακάτω λίστα βλέπετε τα σχολεία ευθύνης σας.
<br/>Επιλέξτε σχολείο για να εμφανιστούν τα ολιγομελή τμήματα του σχολείου.</p>
<div class="row" style="margin-top: 20px; line-height: 2em;"><p><strong>Τα τμήματα</strong></p></div>
<div *ngFor="let SchoolNames$ of SchoolsPerPerf$ | async; let i=index; let isOdd=odd; let isEven=even" style="font-size: 0.8em; font-weight: bold;">
<li class="list-group-item isclickable" (click)="setActiveRegion(SchoolNames$.id)"
[class.oddout]="isOdd"
[class.evenout]="isEven" [class.selectedout]="regionActive === SchoolNames$.id" >
<div [class.changelistcolor]= "SchoolNames$.status === false" class="col-md-12">{{SchoolNames$.name}}</div>
<div class = "row" [hidden]="SchoolNames$.id !== regionActive" style="margin: 0px 2px 0px 2px;">
<div class="col-md-8">Τμήματα</div>
<div class="col-md-4">Έγκριση Ολιγομελούς</div>
</div>
</li>
<p></p>
<div class = "row" [hidden]="SchoolNames$.id !== regionActive" style="margin: 0px 2px 0px 2px;">
<div class="col-md-8">&nbsp;</div>
<div [hidden]="SchoolNames$.id !== regionActive" class="col-md-4 pull-right" style="color: black;" >
<span aria-hidden="true">
<button type="button" class="btn-primary btn-sm pull-right" (click) ="setActiveRegion(SchoolNames$.id)">Κλείσιμο</button>
</span>
</div>
</div>
<div class = "row" *ngFor="let CoursesNames$ of CoursesPerPerf$ | async; let j=index; let isOdd2=odd; let isEven2=even"
[class.oddin]="isOdd2" [class.evenin]="isEven2" [class.changecolor]="calccolor(CoursesNames$.size,CoursesNames$.limitdown)"
[class.changecolorbalck]="calccolor(CoursesNames$.limitdown, CoursesNames$.size)"
[class.selectedappout]="regionActive === j"
[hidden]="(SchoolNames$.id !== regionActive) ||(calccolor(CoursesNames$.size,CoursesNames$.limitdown) === false) "
style="margin: 0px 2px 0px 2px;" >
<div class="col-md-8">{{CoursesNames$.name}}</div>
<div class="col-md-4">
<strong><label>Έγκριση Ολιγομελούς:</label> </strong>
<select class="form-control pull-right" #cb name="{{CoursesNames$.id}}" (change)="confirmApproved(CoursesNames$.classes,CoursesNames$.approved_id, cb, j)" >
<option value="1" [selected]="CoursesNames$.approved === '1' ">Ναι</option>
<option value="2" [selected]="CoursesNames$.approved === '0' ">Όχι</option>
</select>
</div>
</div>
</div>
</div>
</form>
</div>
......@@ -264,7 +218,7 @@ import { IAppState } from "../../store/store";
else {
this.regionActive = ind;
this.showLoader.next(true);
this.CoursesPerPerfSub = this._hds.getCoursePerPerfecture(this.regionActive)
this.CoursesPerPerfSub = this._hds.getCoursePerPerfectureMin(this.regionActive,this.minedu_userName, this.minedu_userPassword)
.subscribe(data => {
this.CoursesPerPerf$.next(data);
this.showLoader.next(false);
......@@ -290,7 +244,7 @@ import { IAppState } from "../../store/store";
let std = this.CoursesPerPerf$.getValue();
std[ind].approved = rtype;
this.SavedSApprovedSub = this._hds.saveApprovedClasses(taxi, classid, type).subscribe(data => {
this.SavedSApprovedSub = this._hds.saveApprovedClassesMin(taxi, classid, type,this.minedu_userName, this.minedu_userPassword).subscribe(data => {
this.SavedSApproved$.next(data);
this.showLoader.next(false);
},
......
......@@ -2020,4 +2020,38 @@ getPde(username, userpassword)
}
getCoursePerPerfectureMin(PerfectureId,username, userpassword) {
let PerfectureIdNew = PerfectureId.toString();
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/coursesperschmin/` + PerfectureIdNew, options)
.map(response => response.json());
}
saveApprovedClassesMin(taxi, classid, type,username, userpassword)
{
let headers = new Headers({
"Content-Type": "application/json",
});
this.createMinistryAuthorizationHeader(headers, username, userpassword);
let options = new RequestOptions({ headers: headers });
return this.http.post(`${AppSettings.API_ENDPOINT}/epal/approveclassesmin`, { taxi, classid, type }, 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