share attachment implemented

feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
PGAN-MIS 2023-08-27 16:38:05 +08:00
parent 690af305d6
commit e7d6cb8133
54 changed files with 1573 additions and 471 deletions

View File

@ -10,7 +10,7 @@
<application <application
android:label="uniT App" android:label="uniT App"
android:name="${applicationName}" android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"> android:icon="@mipmap/unit">
<provider <provider
android:authorities = "${applicationId}.fileprovider" android:authorities = "${applicationId}.fileprovider"
android:exported = "false" android:exported = "false"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 721 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1,5 +1,5 @@
buildscript { buildscript {
ext.kotlin_version = '1.6.10' ext.kotlin_version = '1.8.0'
repositories { repositories {
google() google()
mavenCentral() mavenCentral()

View File

@ -1,10 +1,18 @@
import 'dart:io';
import 'package:bloc/bloc.dart'; import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:share_plus/share_plus.dart';
import 'package:unit2/model/profile/educational_background.dart'; import 'package:unit2/model/profile/educational_background.dart';
import 'package:unit2/sevices/profile/education_services.dart'; import 'package:unit2/sevices/profile/education_services.dart';
import 'package:unit2/utils/request_permission.dart';
import '../../../model/profile/attachment.dart'; import '../../../model/profile/attachment.dart';
import '../../../utils/attachment_services.dart'; import '../../../utils/attachment_services.dart';
import '../../../utils/urls.dart';
part 'education_event.dart'; part 'education_event.dart';
part 'education_state.dart'; part 'education_state.dart';
@ -14,9 +22,13 @@ class EducationBloc extends Bloc<EducationEvent, EducationState> {
List<School> schools = []; List<School> schools = [];
List<Course> programs = []; List<Course> programs = [];
List<Honor> honors = []; List<Honor> honors = [];
int? profileId;
String? token;
List<AttachmentCategory> attachmentCategories = []; List<AttachmentCategory> attachmentCategories = [];
EducationBloc() : super(EducationInitial()) { EducationBloc() : super(EducationInitial()) {
on<GetEducationalBackground>((event, emit) async { on<GetEducationalBackground>((event, emit) async {
profileId = event.profileId;
token = event.token;
emit(EducationalBackgroundLoadingState()); emit(EducationalBackgroundLoadingState());
try { try {
if (attachmentCategories.isEmpty) { if (attachmentCategories.isEmpty) {
@ -206,5 +218,44 @@ class EducationBloc extends Bloc<EducationEvent, EducationState> {
emit(EducationalBackgroundErrorState(message: e.toString())); emit(EducationalBackgroundErrorState(message: e.toString()));
} }
}); });
on<EducationViewAttachment>((event, emit) {
String fileUrl =
'${Url.instance.prefixHost()}://${Url.instance.host()}${event.source}';
emit(EducationAttachmentViewState(
fileUrl: fileUrl, fileName: event.fileName));
});
on<ShareAttachment>((event, emit) async {
emit(EducationalBackgroundLoadingState());
Directory directory;
String? appDocumentPath;
if (await requestPermission(Permission.storage)) {
directory = await getApplicationDocumentsDirectory();
appDocumentPath = directory.path;
}
try{
final bool success = await AttachmentServices.instance.downloadAttachment(
filename: event.fileName,
source: event.source,
downLoadDir: appDocumentPath!);
if (success) {
final result = await Share.shareXFiles(
[XFile("$appDocumentPath/${event.fileName}")]);
if (result.status == ShareResultStatus.success) {
Fluttertoast.showToast(msg: "Attachment shared successfully");
emit(EducationAttachmentViewState(
fileUrl: event.source, fileName: event.fileName));
} else {
Fluttertoast.showToast(msg: "Attachment shared unsuccessfully");
emit(EducationAttachmentViewState(
fileUrl: event.source, fileName: event.fileName));
}
} else {
emit(EducationAttachmentViewState(
fileUrl: event.source, fileName: event.fileName));
}
}catch(e){
emit(EducationalBackgroundErrorState(message: e.toString()));
}
});
} }
} }

View File

@ -83,3 +83,15 @@ class DeleteEducationAttachment extends EducationEvent{
final int profileId; final int profileId;
const DeleteEducationAttachment({required this.attachment, required this.moduleId, required this.profileId, required this.token}); const DeleteEducationAttachment({required this.attachment, required this.moduleId, required this.profileId, required this.token});
} }
class EducationViewAttachment extends EducationEvent{
final String fileName;
final String source;
const EducationViewAttachment({required this.source,required this.fileName});
}
class ShareAttachment extends EducationEvent{
final String fileName;
final String source;
const ShareAttachment({required this.fileName, required this.source});
}

View File

@ -60,7 +60,6 @@ class EducationAddedState extends EducationState {
List<Object> get props => [response]; List<Object> get props => [response];
} }
//// Edited State //// Edited State
class EditedEducationState extends EducationState { class EditedEducationState extends EducationState {
final Map<dynamic, dynamic> response; final Map<dynamic, dynamic> response;
@ -89,4 +88,15 @@ class EducationAttachmentDeletedState extends EducationState {
const EducationAttachmentDeletedState({required this.success}); const EducationAttachmentDeletedState({required this.success});
@override @override
List<Object> get props => [success]; List<Object> get props => [success];
} }
class EducationAttachmentViewState extends EducationState {
final String fileUrl;
final String fileName;
const EducationAttachmentViewState({required this.fileUrl, required this.fileName});
}
class EducationAttachmentShareState extends EducationState{
final bool success;
const EducationAttachmentShareState({required this.success,});
}

View File

@ -11,6 +11,7 @@ import '../../../model/utils/eligibility.dart';
import '../../../sevices/profile/eligibility_services.dart'; import '../../../sevices/profile/eligibility_services.dart';
import '../../../utils/location_utilities.dart'; import '../../../utils/location_utilities.dart';
import '../../../utils/profile_utilities.dart'; import '../../../utils/profile_utilities.dart';
import '../../../utils/urls.dart';
part 'eligibility_event.dart'; part 'eligibility_event.dart';
part 'eligibility_state.dart'; part 'eligibility_state.dart';
@ -52,6 +53,7 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
//// GET ELIGIBILITY //// GET ELIGIBILITY
on<GetEligibilities>((event, emit) async { on<GetEligibilities>((event, emit) async {
emit(EligibilityLoadingState());
try { try {
if (attachmentCategories.isEmpty) { if (attachmentCategories.isEmpty) {
attachmentCategories = attachmentCategories =
@ -257,7 +259,7 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
on<DeleteEligibyAttachment>((event, emit) async { on<DeleteEligibyAttachment>((event, emit) async {
emit(EligibilityLoadingState()); emit(EligibilityLoadingState());
// try { try {
final bool success = await AttachmentServices.instance.deleteAttachment( final bool success = await AttachmentServices.instance.deleteAttachment(
attachment: event.attachment, attachment: event.attachment,
moduleId: int.parse(event.moduleId), moduleId: int.parse(event.moduleId),
@ -275,9 +277,13 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
} else { } else {
emit(EligibilitytAttachmentDeletedState(success: success)); emit(EligibilitytAttachmentDeletedState(success: success));
} }
// } catch (e) { } catch (e) {
// emit(EligibilityErrorState(message: e.toString())); emit(EligibilityErrorState(message: e.toString()));
// } }
});
on<EligibiltyViewAttachmentEvent>((event,emit){
String fileUrl = '${Url.instance.prefixHost()}://${Url.instance.host()}${event.source}';
emit(EligibilityAttachmentViewState(fileUrl: fileUrl));
}); });
} }
} }

View File

@ -7,38 +7,44 @@ abstract class EligibilityEvent extends Equatable {
List<Object> get props => []; List<Object> get props => [];
} }
class ShowAddEligibilityForm extends EligibilityEvent { class ShowAddEligibilityForm extends EligibilityEvent {}
} class GetEligibilities extends EligibilityEvent {
class GetEligibilities extends EligibilityEvent{
final int profileId; final int profileId;
final String token; final String token;
const GetEligibilities({required this.profileId, required this.token}); const GetEligibilities({required this.profileId, required this.token});
@override @override
List<Object> get props => [profileId,token]; List<Object> get props => [profileId, token];
} }
class AddEligibility extends EligibilityEvent{ class AddEligibility extends EligibilityEvent {
final EligibityCert eligibityCert; final EligibityCert eligibityCert;
final String profileId; final String profileId;
final String token; final String token;
const AddEligibility({required this.eligibityCert, required this.profileId, required this.token}); const AddEligibility(
{required this.eligibityCert,
required this.profileId,
required this.token});
@override @override
List<Object> get props => [eligibityCert, profileId, token]; List<Object> get props => [eligibityCert, profileId, token];
} }
class UpdateEligibility extends EligibilityEvent{
class UpdateEligibility extends EligibilityEvent {
final EligibityCert eligibityCert; final EligibityCert eligibityCert;
final String profileId; final String profileId;
final String token; final String token;
final int oldEligibility; final int oldEligibility;
const UpdateEligibility({required this.eligibityCert, required this.oldEligibility,required this.profileId, required this.token}); const UpdateEligibility(
{required this.eligibityCert,
required this.oldEligibility,
required this.profileId,
required this.token});
@override @override
List<Object> get props =>[eligibityCert,profileId,token,oldEligibility]; List<Object> get props => [eligibityCert, profileId, token, oldEligibility];
} }
class LoadEligibility extends EligibilityEvent {
class LoadEligibility extends EligibilityEvent {
const LoadEligibility(); const LoadEligibility();
@override @override
List<Object> get props => []; List<Object> get props => [];
@ -55,45 +61,55 @@ class DeleteEligibility extends EligibilityEvent {
final String profileId; final String profileId;
final int eligibilityId; final int eligibilityId;
final String token; final String token;
const DeleteEligibility( const DeleteEligibility(
{ {required this.eligibilityId,
required this.eligibilityId,
required this.profileId, required this.profileId,
required this.token}); required this.token});
@override @override
List<Object> get props => [ profileId, eligibilityId, token]; List<Object> get props => [profileId, eligibilityId, token];
} }
class CallErrorState extends EligibilityEvent{ class CallErrorState extends EligibilityEvent {}
}
////Add Attachment ////Add Attachment
class AddEligibiltyAttachment extends EligibilityEvent{ class AddEligibiltyAttachment extends EligibilityEvent {
final String categoryId; final String categoryId;
final String attachmentModule; final String attachmentModule;
final List<String> filePaths; final List<String> filePaths;
final String token; final String token;
final String profileId; final String profileId;
const AddEligibiltyAttachment({required this.attachmentModule, required this.filePaths, required this.categoryId, required this.profileId, required this.token}); const AddEligibiltyAttachment(
{required this.attachmentModule,
required this.filePaths,
required this.categoryId,
required this.profileId,
required this.token});
@override @override
List<Object> get props => [categoryId,attachmentModule,filePaths, token,profileId]; List<Object> get props =>
[categoryId, attachmentModule, filePaths, token, profileId];
} }
////Delete Attachment ////Delete Attachment
class DeleteEligibyAttachment extends EligibilityEvent{ class DeleteEligibyAttachment extends EligibilityEvent {
final String profileId; final String profileId;
final String token; final String token;
final Attachment attachment; final Attachment attachment;
final String moduleId; final String moduleId;
const DeleteEligibyAttachment({required this.attachment,required this.moduleId, required this.profileId, required this.token}); const DeleteEligibyAttachment(
{required this.attachment,
required this.moduleId,
required this.profileId,
required this.token});
} }
class EligibilityViewAttachments extends EligibilityEvent {
final String source;
const EligibilityViewAttachments({required this.source});
}
class EligibiltyViewAttachmentEvent extends EligibilityEvent{
final String source;
const EligibiltyViewAttachmentEvent({required this.source});
}

View File

@ -107,3 +107,8 @@ class EligibilitytAttachmentDeletedState extends EligibilityState {
@override @override
List<Object> get props => [success]; List<Object> get props => [success];
} }
class EligibilityAttachmentViewState extends EligibilityState {
final String fileUrl;
const EligibilityAttachmentViewState({required this.fileUrl});
}

View File

@ -13,6 +13,7 @@ import '../../../model/utils/category.dart';
import '../../../utils/attachment_services.dart'; import '../../../utils/attachment_services.dart';
import '../../../utils/location_utilities.dart'; import '../../../utils/location_utilities.dart';
import '../../../utils/profile_utilities.dart'; import '../../../utils/profile_utilities.dart';
import '../../../utils/urls.dart';
part 'learning_development_event.dart'; part 'learning_development_event.dart';
part 'learning_development_state.dart'; part 'learning_development_state.dart';
@ -325,5 +326,10 @@ class LearningDevelopmentBloc
emit(LearningDevelopmentErrorState(message: e.toString())); emit(LearningDevelopmentErrorState(message: e.toString()));
} }
}); });
on<LearningDevelopmentViewAttachmentEvent>((event,emit){
String fileUrl = '${Url.instance.prefixHost()}://${Url.instance.host()}${event.source}';
emit(LearningAndDevelopmentAttachmentViewState(fileUrl: fileUrl));
});
} }
} }

View File

@ -88,3 +88,9 @@ class DeleteLearningDevAttachment extends LearningDevelopmentEvent{
const DeleteLearningDevAttachment({required this.attachment, required this.moduleId, required this.profileId, required this.token}); const DeleteLearningDevAttachment({required this.attachment, required this.moduleId, required this.profileId, required this.token});
} }
class LearningDevelopmentViewAttachmentEvent extends LearningDevelopmentEvent{
final String source;
const LearningDevelopmentViewAttachmentEvent({required this.source});
}

View File

@ -133,3 +133,9 @@ class LearningDevAttachmentDeletedState extends LearningDevelopmentState {
@override @override
List<Object> get props => [success]; List<Object> get props => [success];
} }
class LearningAndDevelopmentAttachmentViewState extends LearningDevelopmentState {
final String fileUrl;
const LearningAndDevelopmentAttachmentViewState({required this.fileUrl});
}

View File

@ -7,6 +7,7 @@ import 'package:unit2/model/utils/position.dart';
import 'package:unit2/sevices/profile/work_history_services.dart'; import 'package:unit2/sevices/profile/work_history_services.dart';
import 'package:unit2/utils/profile_utilities.dart'; import 'package:unit2/utils/profile_utilities.dart';
import '../../../model/profile/attachment.dart'; import '../../../model/profile/attachment.dart';
import '../../../model/utils/category.dart'; import '../../../model/utils/category.dart';
import '../../../utils/attachment_services.dart'; import '../../../utils/attachment_services.dart';
part 'workHistory_event.dart'; part 'workHistory_event.dart';
@ -67,8 +68,10 @@ class WorkHistoryBloc extends Bloc<WorkHistorytEvent, WorkHistoryState> {
}); });
//// ADD WORK HISTORIES //// ADD WORK HISTORIES
on<AddWorkHostory>((event, emit) async { on<AddWorkHostory>((event, emit) async {
try { // try {
Map<dynamic, dynamic> status = await WorkHistoryService.instance.add( Map<dynamic, dynamic> status = await WorkHistoryService.instance.add(
accomplishment: event.accomplishment,
actualDuties: event.actualDuties,
isPrivate: event.isPrivate, isPrivate: event.isPrivate,
workHistory: event.workHistory, workHistory: event.workHistory,
token: event.token, token: event.token,
@ -80,35 +83,35 @@ class WorkHistoryBloc extends Bloc<WorkHistorytEvent, WorkHistoryState> {
} else { } else {
emit(WorkHistoryAddedState(response: status)); emit(WorkHistoryAddedState(response: status));
} }
} catch (e) { // } catch (e) {
emit(WorkHistoryErrorState(message: e.toString())); // emit(WorkHistoryErrorState(message: e.toString()));
} // }
}); });
////UPDATE WORK HISTORY ////UPDATE WORK HISTORY
on<UpdateWorkHistory>((event, emit) async { // on<UpdateWorkHistory>((event, emit) async {
try { // try {
Map<dynamic, dynamic> status = await WorkHistoryService.instance.update( // Map<dynamic, dynamic> status = await WorkHistoryService.instance.update(
oldWorkHistory: event.oldWorkHistory, // oldWorkHistory: event.oldWorkHistory,
newWorkHistory: event.workHistory, // newWorkHistory: event.workHistory,
token: event.token, // token: event.token,
profileId: event.profileId); // profileId: event.profileId);
if (status['success']) { // if (status['success']) {
WorkHistory workHistory = WorkHistory.fromJson(status['data']); // WorkHistory workHistory = WorkHistory.fromJson(status['data']);
workExperiences.removeWhere((WorkHistory work) { // workExperiences.removeWhere((WorkHistory work) {
return work.id == event.oldWorkHistory.id; // return work.id == event.oldWorkHistory.id;
}); // });
workExperiences.add(workHistory); // workExperiences.add(workHistory);
emit(WorkHistoryEditedState(response: status)); // emit(WorkHistoryEditedState(response: status));
} else { // } else {
emit(WorkHistoryEditedState( // emit(WorkHistoryEditedState(
response: status, // response: status,
)); // ));
} // }
} catch (e) { // } catch (e) {
emit(WorkHistoryErrorState(message: e.toString())); // emit(WorkHistoryErrorState(message: e.toString()));
} // }
}); // });
////SHOW EDIT WORK HISTORIES ////SHOW EDIT WORK HISTORIES
on<ShowEditWorkHistoryForm>((event, emit) async { on<ShowEditWorkHistoryForm>((event, emit) async {
@ -209,12 +212,12 @@ class WorkHistoryBloc extends Bloc<WorkHistorytEvent, WorkHistoryState> {
Attachment newAttachment = Attachment.fromJson(element); Attachment newAttachment = Attachment.fromJson(element);
attachments.add(newAttachment); attachments.add(newAttachment);
}); });
workHistory.attachments == null // workHistory.attachments == null
? workHistory.attachments = attachments // ? workHistory.attachments = attachments
: workHistory.attachments = [ // : workHistory.attachments = [
...workHistory.attachments!, // ...workHistory.attachments!,
...attachments // ...attachments
]; // ];
emit(WorkHistoryDevAttachmentAddedState(response: status)); emit(WorkHistoryDevAttachmentAddedState(response: status));
} else { } else {
emit(WorkHistoryDevAttachmentAddedState(response: status)); emit(WorkHistoryDevAttachmentAddedState(response: status));
@ -223,31 +226,31 @@ class WorkHistoryBloc extends Bloc<WorkHistorytEvent, WorkHistoryState> {
emit(WorkHistoryErrorState(message: e.toString())); emit(WorkHistoryErrorState(message: e.toString()));
} }
}); });
////Delete Attachment // ////Delete Attachment
on<DeleteWorkHistoryAttachment>((event, emit) async { // on<DeleteWorkHistoryAttachment>((event, emit) async {
emit(WorkHistoryLoadingState()); // emit(WorkHistoryLoadingState());
try { // try {
final bool success = await AttachmentServices.instance.deleteAttachment( // final bool success = await AttachmentServices.instance.deleteAttachment(
attachment: event.attachment, // attachment: event.attachment,
moduleId: event.moduleId, // moduleId: event.moduleId,
profileId: event.profileId.toString(), // profileId: event.profileId.toString(),
token: event.token); // token: event.token);
if (success) { // if (success) {
final WorkHistory workHistory = // final WorkHistory workHistory =
workExperiences // workExperiences
.firstWhere((element) => element.id == event.moduleId); // .firstWhere((element) => element.id == event.moduleId);
workHistory.attachments // workHistory.attachments
?.removeWhere((element) => element.id == event.attachment.id); // ?.removeWhere((element) => element.id == event.attachment.id);
workExperiences // workExperiences
.removeWhere((element) => element.id == event.moduleId); // .removeWhere((element) => element.id == event.moduleId);
workExperiences.add(workHistory); // workExperiences.add(workHistory);
emit(WorkHistoryDevAttachmentDeletedState(success: success)); // emit(WorkHistoryDevAttachmentDeletedState(success: success));
} else { // } else {
emit(WorkHistoryDevAttachmentDeletedState(success: success)); // emit(WorkHistoryDevAttachmentDeletedState(success: success));
} // }
} catch (e) { // } catch (e) {
emit(WorkHistoryErrorState(message: e.toString())); // emit(WorkHistoryErrorState(message: e.toString()));
} // }
}); // });
} }
} }

View File

@ -43,12 +43,14 @@ class DeleteWorkHistory extends WorkHistorytEvent{
class UpdateWorkHistory extends WorkHistorytEvent{ class UpdateWorkHistory extends WorkHistorytEvent{
final WorkHistory workHistory; final WorkHistory workHistory;
final WorkHistory oldWorkHistory; final bool isPrivate;
final String profileId; final int profileId;
final String token; final String token;
const UpdateWorkHistory({required this.oldWorkHistory, required this.profileId, required this.token, required this.workHistory}); final String? actualDuties;
final String? accomplishment;
const UpdateWorkHistory({required this.profileId, required this.token, required this.workHistory, required this.accomplishment, required this.actualDuties, required this.isPrivate});
@override @override
List<Object> get props => [profileId,token,workHistory,oldWorkHistory]; List<Object> get props => [profileId,token,workHistory,];
} }
class AddWorkHostory extends WorkHistorytEvent{ class AddWorkHostory extends WorkHistorytEvent{
@ -56,7 +58,9 @@ class AddWorkHostory extends WorkHistorytEvent{
final bool isPrivate; final bool isPrivate;
final int profileId; final int profileId;
final String token; final String token;
const AddWorkHostory({required this.workHistory, required this.isPrivate, required this.profileId, required this.token}); final String? actualDuties;
final String? accomplishment;
const AddWorkHostory({required this.workHistory, required this.isPrivate, required this.profileId, required this.token, required this.accomplishment, required this.actualDuties});
@override @override
List<Object> get props => [workHistory,profileId,token,isPrivate]; List<Object> get props => [workHistory,profileId,token,isPrivate];
} }

View File

@ -22,15 +22,15 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
int? stationId; int? stationId;
String? cpId; String? cpId;
on<GetPassCheckAreas>((event, emit) async { on<GetPassCheckAreas>((event, emit) async {
// try { try {
emit(PassCheckLoadingState()); emit(PassCheckLoadingState());
List<dynamic> response = await PassCheckServices.instance List<dynamic> response = await PassCheckServices.instance
.getPassCheckArea(roleId: event.roleId, userId: event.userId); .getPassCheckArea(roleId: event.roleId, userId: event.userId);
roleId = event.roleId; roleId = event.roleId;
emit(AssignAreaLoaded(assignedArea: response, roleId: roleId!)); emit(AssignAreaLoaded(assignedArea: response, roleId: roleId!));
// } catch (e) { } catch (e) {
// emit(PassCheckErrorState(message: e.toString())); emit(PassCheckErrorState(message: e.toString()));
// } }
}); });
on<SetScannerSettings>((event, emit) { on<SetScannerSettings>((event, emit) {
otherInputs = event.includeOtherInputs; otherInputs = event.includeOtherInputs;

View File

@ -1,75 +1,163 @@
// To parse this JSON data, do import 'package:unit2/model/utils/industry_class.dart';
//
// final workHistory = workHistoryFromJson(jsonString);
import 'dart:convert';
import '../utils/agency.dart'; import '../utils/agency.dart';
import '../utils/category.dart';
import '../utils/industry_class.dart';
import '../utils/position.dart'; import '../utils/position.dart';
import 'attachment.dart';
WorkHistory workHistoryFromJson(String str) => WorkHistory.fromJson(json.decode(str));
String workHistoryToJson(WorkHistory data) => json.encode(data.toJson());
class WorkHistory { class WorkHistory {
WorkHistory({ final PositionTitle? position;
this.id, final Agency? agency;
this.agency, final Supervisor? supervisor;
this.sgStep, final int? id;
this.toDate, final DateTime? fromDate;
this.position, final DateTime? toDate;
this.fromDate, final int? agencydepid;
this.attachments, final double? monthlysalary;
this.salaryGrade, final String? statusAppointment;
this.monthlySalary, final int? salarygrade;
this.appointmentStatus, final int? sgstep;
}); final List<Accomplishment>? accomplishment;
final List<ActualDuty>? actualDuties;
final int? id; WorkHistory({
final Agency? agency; required this.position,
final int? sgStep; required this.agency,
final DateTime? toDate; required this.supervisor,
final PositionTitle? position; required this.id,
final DateTime? fromDate; required this.fromDate,
List<Attachment>? attachments; required this.toDate,
final int? salaryGrade; required this.agencydepid,
final double? monthlySalary; required this.monthlysalary,
final String? appointmentStatus; required this.statusAppointment,
required this.salarygrade,
required this.sgstep,
required this.accomplishment,
required this.actualDuties,
});
factory WorkHistory.fromJson(Map<String, dynamic> json) => WorkHistory( factory WorkHistory.fromJson(Map<String, dynamic> json) => WorkHistory(
position: PositionTitle.fromJson(json["position"]),
agency: json['agency'] == null?null: Agency.fromJson(json["agency"]),
supervisor: json['supervisor'] == null?null: Supervisor.fromJson(json["supervisor"]),
id: json["id"], id: json["id"],
agency: json["agency"] == null ? null : Agency.fromJson(json["agency"]), fromDate: json['from_date'] == null?null: DateTime.tryParse(json["from_date"]),
sgStep: json["sg_step"], toDate: json['to_date'] == null?null: DateTime.tryParse(json["to_date"]),
toDate: json["to_date"] == null ? null : DateTime.parse(json["to_date"]), agencydepid: json["agencydepid"],
position: json["position"] == null ? null : PositionTitle.fromJson(json["position"]), monthlysalary: json["monthlysalary"],
fromDate: json["from_date"] == null ? null : DateTime.parse(json["from_date"]), statusAppointment: json["status_appointment"],
attachments: json['attachments'] ==null?null: List<Attachment>.from(json["attachments"].map((x) => Attachment.fromJson(x))), salarygrade: json["salarygrade"],
salaryGrade: json["salary_grade"], sgstep: json["sgstep"],
monthlySalary: json["monthly_salary"], accomplishment:json['accomplishment'] == null?null: json['accomplishment'] == null?null: List<Accomplishment>.from(
appointmentStatus: json["appointment_status"], json["accomplishment"].map((x) => Accomplishment.fromJson(x))),
); actualDuties: json['actual_duties'] == null?null: List<ActualDuty>.from(
json["actual_duties"].map((x) => ActualDuty.fromJson(x))),
);
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"id": id,
"agency": agency?.toJson(),
"sg_step": sgStep,
"to_date": "${toDate!.year.toString().padLeft(4, '0')}-${toDate!.month.toString().padLeft(2, '0')}-${toDate!.day.toString().padLeft(2, '0')}",
"position": position?.toJson(), "position": position?.toJson(),
"from_date": "${fromDate!.year.toString().padLeft(4, '0')}-${fromDate!.month.toString().padLeft(2, '0')}-${fromDate!.day.toString().padLeft(2, '0')}", "agency": agency?.toJson(),
// "attachments": attachments, "supervisor": supervisor?.toJson(),
"salary_grade": salaryGrade, "id": id,
"monthly_salary": monthlySalary, "from_date":
"appointment_status": appointmentStatus, "${fromDate?.year.toString().padLeft(4, '0')}-${fromDate?.month.toString().padLeft(2, '0')}-${fromDate?.day.toString().padLeft(2, '0')}",
}; "to_date": toDate,
"agencydepid": agencydepid,
"monthlysalary": monthlysalary,
"status_appointment": statusAppointment,
"salarygrade": salarygrade,
"sgstep": sgstep,
"accomplishment":
List<dynamic>.from(accomplishment!.map((x) => x.toJson())),
"actual_duties":
List<dynamic>.from(actualDuties!.map((x) => x.toJson())),
};
}
class Accomplishment {
final int? id;
final int? workExperienceId;
final String? accomplishment;
Accomplishment({
required this.id,
required this.workExperienceId,
required this.accomplishment,
});
factory Accomplishment.fromJson(Map<String, dynamic> json) => Accomplishment(
id: json["id"],
workExperienceId: json["work_experience_id"],
accomplishment: json["accomplishment"],
);
Map<String, dynamic> toJson() => {
"id": id,
"work_experience_id": workExperienceId,
"accomplishment": accomplishment,
};
}
class ActualDuty {
final int? id;
final int? workExperienceId;
final String description;
ActualDuty({
required this.id,
required this.workExperienceId,
required this.description,
});
factory ActualDuty.fromJson(Map<String, dynamic> json) => ActualDuty(
id: json["id"],
workExperienceId: json["work_experience_id"],
description: json["description"],
);
Map<String, dynamic> toJson() => {
"id": id,
"work_experience_id": workExperienceId,
"description": description,
};
}
class Supervisor {
final int? id;
final int? agencyId;
final String? lastname;
final String? firstname;
final String? middlename;
final String? stationName;
Supervisor({
required this.id,
required this.agencyId,
required this.lastname,
required this.firstname,
required this.middlename,
required this.stationName,
});
factory Supervisor.fromJson(Map<String, dynamic> json) => Supervisor(
id: json["id"],
agencyId: json["agency_id"],
lastname: json["lastname"],
firstname: json["firstname"],
middlename: json["middlename"],
stationName: json["station_name"],
);
Map<String, dynamic> toJson() => {
"id": id,
"agency_id": agencyId,
"lastname": lastname,
"firstname": firstname,
"middlename": middlename,
"station_name": stationName,
};
} }

View File

@ -0,0 +1,121 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:share_plus/share_plus.dart';
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
import 'package:unit2/bloc/profile/education/education_bloc.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart';
class EudcationViewAttachment extends StatefulWidget {
const EudcationViewAttachment({super.key});
@override
State<EudcationViewAttachment> createState() =>
_EudcationViewAttachmentState();
}
class _EudcationViewAttachmentState extends State<EudcationViewAttachment> {
@override
Widget build(BuildContext context) {
String? fileUrl;
String? filename;
return Scaffold(
floatingActionButton: FloatingActionButton(
onPressed: () async {
await _launchInBrowser(fileUrl!);
},
child: const Icon(Icons.file_download),
),
appBar: AppBar(
title: const Text("Attachment"),
centerTitle: true,
actions: [
IconButton(
onPressed: () {
context.read<EducationBloc>().add(
ShareAttachment(fileName: filename!, source: fileUrl!));
},
icon: const Icon(Icons.share)),
],
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<EducationBloc, EducationState>(
builder: (context, state) {
if (state is EducationAttachmentViewState) {
fileUrl = state.fileUrl;
filename = state.fileName;
bool isPDF = state.fileUrl[state.fileUrl.length - 1] == 'f'
? true
: false;
return SizedBox(
child: isPDF
? SfPdfViewer.network(
state.fileUrl,
onDocumentLoadFailed: (details) {
Center(
child: Text(details.description),
);
},
)
: Center(
child: CachedNetworkImage(
progressIndicatorBuilder: (context, url, progress) {
return const SizedBox(
height: 100,
width: 100,
child: CircularProgressIndicator(
color: primary,
));
},
imageBuilder: (context, imageProvider) => Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider, fit: BoxFit.fill)),
),
imageUrl: state.fileUrl,
width: double.infinity,
height: 220,
fit: BoxFit.cover,
),
),
);
}
return Container();
},
listener: (context, state) {
if (state is EducationalBackgroundLoadingState) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is EducationAttachmentViewState) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
},
),
));
}
Future<void> _launchInBrowser(String url) async {
final UrlLauncherPlatform launcher = UrlLauncherPlatform.instance;
if (!await launcher.launch(
url,
useSafariVC: false,
useWebView: false,
enableJavaScript: false,
enableDomStorage: false,
universalLinksOnly: false,
headers: <String, String>{},
)) {
throw Exception('Could not launch $url');
}
}
}

View File

@ -11,6 +11,7 @@ import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart'; import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/model/profile/educational_background.dart'; import 'package:unit2/model/profile/educational_background.dart';
import 'package:unit2/screens/profile/components/education/add_modal.dart'; import 'package:unit2/screens/profile/components/education/add_modal.dart';
import 'package:unit2/screens/profile/shared/view_attachment.dart';
import 'package:unit2/theme-data.dart/box_shadow.dart'; import 'package:unit2/theme-data.dart/box_shadow.dart';
import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart'; import 'package:unit2/widgets/Leadings/add_leading.dart';
@ -26,6 +27,7 @@ import '../../../widgets/Leadings/close_leading.dart';
import '../shared/multiple_attachment.dart'; import '../shared/multiple_attachment.dart';
import '../shared/single_attachment.dart'; import '../shared/single_attachment.dart';
import 'education/edit_modal.dart'; import 'education/edit_modal.dart';
import 'education/education_view_attachment.dart';
class EducationScreen extends StatelessWidget { class EducationScreen extends StatelessWidget {
const EducationScreen({super.key}); const EducationScreen({super.key});
@ -321,12 +323,12 @@ class EducationScreen extends StatelessWidget {
Column( Column(
children: honors children: honors
.map((Honor honor) => Padding( .map((Honor honor) => Padding(
padding: const EdgeInsets.all(3.0), padding: const EdgeInsets.all(3.0),
child: Text( child: Text(
"-${honor.name!.trim()}", "-${honor.name!.trim()}",
style: Theme.of(context).textTheme.labelSmall, style: Theme.of(context).textTheme.labelSmall,
), ),
)) ))
.toList(), .toList(),
), ),
], ],
@ -696,6 +698,15 @@ class EducationScreen extends StatelessWidget {
children: [ children: [
const Divider(), const Divider(),
SingleAttachment( SingleAttachment(
view: () {
Navigator.push(
context,
MaterialPageRoute(
builder: ((context) => BlocProvider.value(
value: EducationBloc()..add(EducationViewAttachment(source: state.educationalBackground[index].attachments!.first.source!,fileName: state.educationalBackground[index].attachments!.first.filename!)),
child: const EudcationViewAttachment(),
))));
},
onpressed: onpressed:
() { () {
confirmAlert( confirmAlert(
@ -728,6 +739,17 @@ class EducationScreen extends StatelessWidget {
) )
////Multiple Attachments View ////Multiple Attachments View
: MultipleAttachments( : MultipleAttachments(
viewAttachment:
(source,filname) {
Navigator.push(
context,
MaterialPageRoute(
builder: ((context) =>
BlocProvider.value(
value: EducationBloc()..add(EducationViewAttachment(source: source,fileName: filname)),
child: const EudcationViewAttachment(),
))));
},
profileId: profileId:
profileId, profileId,
token: token!, token: token!,

View File

@ -0,0 +1,73 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
import 'package:unit2/bloc/profile/education/education_bloc.dart';
import 'package:unit2/bloc/profile/eligibility/eligibility_bloc.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../../../utils/urls.dart';
class EligibilityViewAttachment extends StatefulWidget {
const EligibilityViewAttachment({super.key});
@override
State<EligibilityViewAttachment> createState() => _EligibilityViewAttachmentState();
}
class _EligibilityViewAttachmentState extends State<EligibilityViewAttachment> {
@override
Widget build(BuildContext context) {
String? fileUrl;
return Scaffold(
floatingActionButton: FloatingActionButton(
onPressed: ()async {
await launchUrl(Uri.parse(fileUrl!));
},
child: const Icon(Icons.file_download),
),
appBar: AppBar(
title: const Text("Attachment"),
centerTitle: true,
actions: [
IconButton(onPressed: () {}, icon: const Icon(Icons.share)),
],
),
body: BlocConsumer<EligibilityBloc, EligibilityState>(builder: (context,state){
if(state is EligibilityAttachmentViewState){
fileUrl = state.fileUrl;
bool isPDF = state.fileUrl[state.fileUrl.length - 1] == 'f' ? true : false;
return SizedBox(
child: isPDF?SfPdfViewer.network(
state.fileUrl,onDocumentLoadFailed: (details) {
Center(child: Text(details.description),);
},): Center(
child: CachedNetworkImage(
progressIndicatorBuilder: (context, url, progress) {
return const SizedBox(
height: 100,
width: 100,
child: CircularProgressIndicator(color: primary,));
},
imageBuilder: (context, imageProvider) => Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider, fit: BoxFit.fill)),
),
imageUrl:
state.fileUrl,
width: double.infinity,
height: 220,
fit: BoxFit.cover,
),
),
);
}
return Container();
},listener: (context, state) {
},)
);
}
}

View File

@ -28,6 +28,8 @@ import '../../../bloc/profile/eligibility/eligibility_bloc.dart';
import '../../../utils/alerts.dart'; import '../../../utils/alerts.dart';
import '../shared/multiple_attachment.dart'; import '../shared/multiple_attachment.dart';
import '../shared/single_attachment.dart'; import '../shared/single_attachment.dart';
import '../shared/view_attachment.dart';
import 'eligibility/eligibility_view_attachment.dart';
class EligibiltyScreen extends StatelessWidget { class EligibiltyScreen extends StatelessWidget {
const EligibiltyScreen({super.key}); const EligibiltyScreen({super.key});
@ -629,6 +631,17 @@ class EligibiltyScreen extends StatelessWidget {
? ?
////Single Attachment view ////Single Attachment view
SingleAttachment( SingleAttachment(
view: (){
Navigator.push(
context,
MaterialPageRoute(
builder: ((context) => BlocProvider.value(
value: EligibilityBloc()..add(EligibiltyViewAttachmentEvent(source: state.eligibilities[index].attachments!.first.source!)),
child: const EligibilityViewAttachment(),
))));
},
onpressed: onpressed:
() { () {
confirmAlert( confirmAlert(
@ -660,6 +673,15 @@ class EligibiltyScreen extends StatelessWidget {
) )
////Multiple Attachments View ////Multiple Attachments View
: MultipleAttachments( : MultipleAttachments(
viewAttachment: (source,filename) {
Navigator.push(
context,
MaterialPageRoute(
builder: ((context) => BlocProvider.value(
value: EligibilityBloc()..add(EligibiltyViewAttachmentEvent(source: source)),
child: const EligibilityViewAttachment(),
))));
},
profileId: profileId:
profileId!, profileId!,
token: token!, token: token!,

View File

@ -12,6 +12,7 @@ import 'package:intl/intl.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart'; import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart'; import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/screens/profile/components/learning_development/edit_modal.dart'; import 'package:unit2/screens/profile/components/learning_development/edit_modal.dart';
import 'package:unit2/screens/profile/components/learning_development/learning_development_view_attachment.dart';
import 'package:unit2/theme-data.dart/box_shadow.dart'; import 'package:unit2/theme-data.dart/box_shadow.dart';
import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/utils/global.dart'; import 'package:unit2/utils/global.dart';
@ -27,6 +28,7 @@ import '../../../utils/alerts.dart';
import '../../../widgets/Leadings/close_leading.dart'; import '../../../widgets/Leadings/close_leading.dart';
import '../shared/multiple_attachment.dart'; import '../shared/multiple_attachment.dart';
import '../shared/single_attachment.dart'; import '../shared/single_attachment.dart';
import '../shared/view_attachment.dart';
import 'learning_development/add_modal.dart'; import 'learning_development/add_modal.dart';
class LearningAndDevelopmentScreen extends StatelessWidget { class LearningAndDevelopmentScreen extends StatelessWidget {
@ -673,6 +675,15 @@ class LearningAndDevelopmentScreen extends StatelessWidget {
? ?
////Single Attachment view ////Single Attachment view
SingleAttachment( SingleAttachment(
view: (){
Navigator.push(
context,
MaterialPageRoute(
builder: ((context) => BlocProvider.value(
value: LearningDevelopmentBloc()..add(LearningDevelopmentViewAttachmentEvent(source: state.learningsAndDevelopment[index].attachments!.first.source!)),
child: const LearningDevelopmentViewAttachment(),
))));
},
onpressed: () { onpressed: () {
confirmAlert( confirmAlert(
context, context,
@ -703,6 +714,17 @@ class LearningAndDevelopmentScreen extends StatelessWidget {
) )
////Multiple Attachments View ////Multiple Attachments View
: MultipleAttachments( : MultipleAttachments(
viewAttachment:
(source,filename) {
Navigator.push(
context,
MaterialPageRoute(
builder: ((context) =>
BlocProvider.value(
value: LearningDevelopmentBloc()..add(LearningDevelopmentViewAttachmentEvent(source: source)),
child: const LearningDevelopmentViewAttachment(),
))));
},
profileId: profileId:
profileId, profileId,
token: token, token: token,

View File

@ -0,0 +1,71 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
import 'package:unit2/bloc/profile/learningDevelopment/learning_development_bloc.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import 'package:url_launcher/url_launcher.dart';
class LearningDevelopmentViewAttachment extends StatefulWidget {
const LearningDevelopmentViewAttachment({super.key});
@override
State<LearningDevelopmentViewAttachment> createState() => _LearningDevelopmentViewAttachmentState();
}
class _LearningDevelopmentViewAttachmentState extends State<LearningDevelopmentViewAttachment> {
@override
Widget build(BuildContext context) {
String? fileUrl;
return Scaffold(
floatingActionButton: FloatingActionButton(
onPressed: ()async {
await launchUrl(Uri.parse(fileUrl!));
},
child: const Icon(Icons.file_download),
),
appBar: AppBar(
title: const Text("Attachment"),
centerTitle: true,
actions: [
IconButton(onPressed: () {}, icon: const Icon(Icons.share)),
],
),
body: BlocConsumer<LearningDevelopmentBloc, LearningDevelopmentState>(builder: (context,state){
if(state is LearningAndDevelopmentAttachmentViewState){
fileUrl = state.fileUrl;
bool isPDF = state.fileUrl[state.fileUrl.length - 1] == 'f' ? true : false;
return SizedBox(
child: isPDF?SfPdfViewer.network(
state.fileUrl,onDocumentLoadFailed: (details) {
Center(child: Text(details.description),);
},): Center(
child: CachedNetworkImage(
progressIndicatorBuilder: (context, url, progress) {
return const SizedBox(
height: 100,
width: 100,
child: CircularProgressIndicator(color: primary,));
},
imageBuilder: (context, imageProvider) => Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider, fit: BoxFit.fill)),
),
imageUrl:
state.fileUrl,
width: double.infinity,
height: 220,
fit: BoxFit.cover,
),
),
);
}
return Container();
},listener: (context, state) {
},)
);
}
}

View File

@ -14,7 +14,7 @@ import 'package:unit2/model/utils/category.dart';
import 'package:unit2/theme-data.dart/box_shadow.dart'; import 'package:unit2/theme-data.dart/box_shadow.dart';
import 'package:unit2/theme-data.dart/btn-style.dart'; import 'package:unit2/theme-data.dart/btn-style.dart';
import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/theme-data.dart/form-style.dart'; import 'package:unit2/theme-data.dart/form-style.dart';
import 'package:unit2/utils/global.dart'; import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/text_container.dart'; import 'package:unit2/utils/text_container.dart';
import 'package:unit2/utils/validators.dart'; import 'package:unit2/utils/validators.dart';
@ -45,6 +45,12 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
String? salary; String? salary;
String? salaryGrade; String? salaryGrade;
String? salaryGradeStep; String? salaryGradeStep;
String? accomplishment;
String? duties;
String? sFname;
String? sLname;
String? sMname;
String? sOffice;
bool showAgency = false; bool showAgency = false;
bool showSalaryGradeAndSalaryStep = false; bool showSalaryGradeAndSalaryStep = false;
bool? isPrivate = false; bool? isPrivate = false;
@ -67,7 +73,9 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocConsumer<WorkHistoryBloc, WorkHistoryState>( return BlocConsumer<WorkHistoryBloc, WorkHistoryState>(
listener: (context, state) { listener: (context, state) {
if (state is AddWorkHistoryState) { if (state is AddWorkHistoryState) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
@ -77,15 +85,14 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
if (state is AddWorkHistoryState) { if (state is AddWorkHistoryState) {
return FormBuilder( return FormBuilder(
key: _formKey, key: _formKey,
child: SizedBox( child: SingleChildScrollView(
height: blockSizeVertical * 90,
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(vertical: 32, horizontal: 28), padding: const EdgeInsets.symmetric(vertical: 32, horizontal: 28),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Flexible(
child: ListView(
children: [
////POSITIONS ////POSITIONS
StatefulBuilder(builder: (context, setState) { StatefulBuilder(builder: (context, setState) {
return SearchField( return SearchField(
@ -93,18 +100,18 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
itemHeight: 70, itemHeight: 70,
suggestionsDecoration: box1(), suggestionsDecoration: box1(),
suggestions: state.agencyPositions suggestions: state.agencyPositions
.map((PositionTitle position) => SearchFieldListItem( .map((PositionTitle position) =>
position.title!, SearchFieldListItem(position.title!,
item: position, item: position,
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 10), horizontal: 10),
child: ListTile( child: ListTile(
title: Text( title: Text(
position.title!, position.title!,
overflow: TextOverflow.visible, overflow: TextOverflow.visible,
), ),
)))) ))))
.toList(), .toList(),
focusNode: positionFocusNode, focusNode: positionFocusNode,
searchInputDecoration: searchInputDecoration:
@ -127,11 +134,12 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
controller: addPositionController, controller: addPositionController,
onpressed: () { onpressed: () {
setState(() { setState(() {
PositionTitle newAgencyPosition = PositionTitle( PositionTitle newAgencyPosition =
id: null, PositionTitle(
title: addPositionController.text id: null,
.toUpperCase()); title: addPositionController.text
.toUpperCase());
state.agencyPositions state.agencyPositions
.insert(0, newAgencyPosition); .insert(0, newAgencyPosition);
selectedPosition = newAgencyPosition; selectedPosition = newAgencyPosition;
@ -170,7 +178,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
}, },
onSuggestionTap: (status) { onSuggestionTap: (status) {
selectedStatus = status.item; selectedStatus = status.item;
appointmentStatusNode.unfocus(); appointmentStatusNode.unfocus();
}, },
searchInputDecoration: searchInputDecoration:
@ -182,7 +190,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
appointmentStatusNode.unfocus(); appointmentStatusNode.unfocus();
}, },
))), ))),
const SizedBox( const SizedBox(
height: 12, height: 12,
), ),
@ -226,7 +234,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
onSuggestionTap: (agency) { onSuggestionTap: (agency) {
setState(() { setState(() {
selectedAgency = agency.item; selectedAgency = agency.item;
if (selectedAgency!.privateEntity == if (selectedAgency!.privateEntity ==
null) { null) {
showIsPrivateRadio = true; showIsPrivateRadio = true;
@ -260,19 +268,19 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
.toUpperCase(), .toUpperCase(),
category: null, category: null,
privateEntity: null); privateEntity: null);
state.agencies.insert(0, newAgency); state.agencies.insert(0, newAgency);
selectedAgency = newAgency; selectedAgency = newAgency;
addAgencyController.text = ""; addAgencyController.text = "";
showAgency = true; showAgency = true;
showIsPrivateRadio = true; showIsPrivateRadio = true;
Navigator.pop(context); Navigator.pop(context);
}); });
}, },
title: "Add Agency")), title: "Add Agency")),
SizedBox( SizedBox(
height: showAgency ? 12 : 0, height: showAgency ? 12 : 0,
), ),
@ -335,7 +343,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
) )
: const SizedBox(), : const SizedBox(),
), ),
////PRVIATE SECTOR ////PRVIATE SECTOR
SizedBox( SizedBox(
child: showIsPrivateRadio child: showIsPrivateRadio
@ -356,7 +364,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
], ],
), ),
), ),
////onvhange private sector ////onvhange private sector
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
@ -381,7 +389,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
agencyCategoryFocusNode.unfocus(); agencyCategoryFocusNode.unfocus();
}); });
}, },
name: 'isPrivate', name: 'isPrivate',
validator: validator:
FormBuilderValidators.required(), FormBuilderValidators.required(),
@ -476,21 +484,80 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
const SizedBox( const SizedBox(
height: 12, height: 12,
), ),
////MONTHLY SALARY //// NAME OF OFFICE UNIT
FormBuilderTextField( FormBuilderTextField(
keyboardType: TextInputType.number, onChanged: (value){
onChanged: (value) { sOffice = value;
setState(() {
salary = value;
});
}, },
validator: numericRequired, validator: FormBuilderValidators.required(
name: "salary", errorText: "This field is required"),
decoration: name: 'office',
normalTextFieldStyle("Monthly Salary *", "") decoration: normalTextFieldStyle(
.copyWith(prefix: const Text("")), "Name of Office/Unit", "Name of Office/Unit"),
), ),
const SizedBox(
height: 12,
),
////MONTHLY SALARY
StatefulBuilder(builder: (context, setState) {
return FormBuilderTextField(
keyboardType: TextInputType.number,
onChanged: (value) {
setState(() {
salary = value;
});
},
validator: numericRequired,
name: "salary",
decoration:
normalTextFieldStyle("Monthly Salary *", "")
.copyWith(prefix: const Text("")),
);
}),
const SizedBox(
height: 12,
),
const Text("Immediate SuperVisor"),
const SizedBox(
height: 12,
),
////IMMEDIATE SUPERVISOR
FormBuilderTextField(
onChanged: (value){
sFname = value;
},
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: 'supervisor_firstname',
decoration:
normalTextFieldStyle("First name", "First Name"),
),
const SizedBox(
height: 12,
),
FormBuilderTextField(
onChanged: (value){
sMname = value;
},
name: 'supervisor_middlename',
decoration: normalTextFieldStyle(
"Middle name", "Middle Name"),
),
const SizedBox(
height: 12,
),
FormBuilderTextField(
onChanged: (value){
sLname = value;
},
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: 'supervisor_lastname',
decoration:
normalTextFieldStyle("Last name", "Last Name"),
),
const SizedBox( const SizedBox(
height: 12, height: 12,
), ),
@ -595,12 +662,11 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
} }
return true; return true;
}, },
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
to = to = DateTime.parse(value);
DateTime.parse(value); });
}); },
},
initialDate: from == null initialDate: from == null
? DateTime.now() ? DateTime.now()
: from!.add( : from!.add(
@ -624,8 +690,40 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
], ],
); );
}), }),
],
), const Text("Work Experience"),
const SizedBox(
height: 8,
),
FormBuilderTextField(
onChanged: (value){
accomplishment = value;
},
name: "accomplishment",
decoration: normalTextFieldStyle(
"List of Accomplishment and Contribution",
"",
),
),
const SizedBox(
height: 12,
),
FormBuilderTextField(
onChanged: (value){
duties = value;
},
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: "summary",
decoration: normalTextFieldStyle(
"Summary of Actual Duties",
"",
),
),
const SizedBox(
height: 20,
), ),
////SUBMIT BUTTON ////SUBMIT BUTTON
SizedBox( SizedBox(
@ -635,11 +733,24 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
style: style:
mainBtnStyle(primary, Colors.transparent, second), mainBtnStyle(primary, Colors.transparent, second),
onPressed: () { onPressed: () {
print(selectedStatus?.value); print(salaryGrade);
print(salaryGradeStep);
if (_formKey.currentState!.validate()) { if (_formKey.currentState!.validate()) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress!.showWithText("Loading..."); progress!.showWithText("Loading...");
WorkHistory workHistory = WorkHistory( WorkHistory workHistory = WorkHistory(
accomplishment: null,
actualDuties: null,
agencydepid: null,
supervisor: Supervisor(
agencyId: selectedAgency?.id,
id: null,
lastname: sLname,
firstname: sFname,
middlename: sMname,
stationName: sOffice),
position: selectedPosition, position: selectedPosition,
id: null, id: null,
agency: selectedAgency, agency: selectedAgency,
@ -651,15 +762,17 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
"PRESENT" "PRESENT"
? null ? null
: DateTime.parse(toDateController.text), : DateTime.parse(toDateController.text),
salaryGrade: salaryGrade == null salarygrade: salaryGrade == null
? null ? null
: int.parse(salaryGrade!), : int.parse(salaryGrade!),
sgStep: salaryGradeStep == null sgstep: salaryGradeStep == null
? null ? null
: int.parse(salaryGradeStep!), : int.parse(salaryGradeStep!),
monthlySalary: double.parse(salary!), monthlysalary: double.parse(salary!),
appointmentStatus: selectedStatus!.value); statusAppointment: selectedStatus!.value);
context.read<WorkHistoryBloc>().add(AddWorkHostory( context.read<WorkHistoryBloc>().add(AddWorkHostory(
accomplishment: accomplishment,
actualDuties: duties,
workHistory: workHistory, workHistory: workHistory,
profileId: widget.profileId, profileId: widget.profileId,
token: widget.token, token: widget.token,

View File

@ -81,7 +81,7 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
if (state is EditWorkHistoryState) { if (state is EditWorkHistoryState) {
oldPositionController.text = state.workHistory.position!.title!; oldPositionController.text = state.workHistory.position!.title!;
oldAppointmentStatusController.text = oldAppointmentStatusController.text =
state.workHistory.appointmentStatus!; state.workHistory.statusAppointment!;
oldAgencyController.text = state.workHistory.agency!.name!; oldAgencyController.text = state.workHistory.agency!.name!;
currentlyEmployed = state.workHistory.toDate == null ? true : false; currentlyEmployed = state.workHistory.toDate == null ? true : false;
showSalaryGradeAndSalaryStep = showSalaryGradeAndSalaryStep =
@ -428,7 +428,7 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
child: FormBuilderTextField( child: FormBuilderTextField(
initialValue: state initialValue: state
.workHistory .workHistory
.salaryGrade .salarygrade
?.toString(), ?.toString(),
name: 'salary_grade', name: 'salary_grade',
keyboardType: keyboardType:
@ -452,7 +452,7 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
flex: 1, flex: 1,
child: FormBuilderTextField( child: FormBuilderTextField(
initialValue: state initialValue: state
.workHistory.sgStep .workHistory.sgstep
?.toString(), ?.toString(),
name: 'salary_step', name: 'salary_step',
keyboardType: keyboardType:
@ -482,7 +482,7 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
////MONTHLY SALARY ////MONTHLY SALARY
FormBuilderTextField( FormBuilderTextField(
initialValue: initialValue:
state.workHistory.monthlySalary.toString(), state.workHistory.monthlysalary.toString(),
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
salary = value; salary = value;
@ -654,50 +654,50 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
style: style:
mainBtnStyle(primary, Colors.transparent, second), mainBtnStyle(primary, Colors.transparent, second),
onPressed: () { onPressed: () {
if (_formKey.currentState!.saveAndValidate()) { // if (_formKey.currentState!.saveAndValidate()) {
final progress = ProgressHUD.of(context); // final progress = ProgressHUD.of(context);
progress!.showWithText("Loading..."); // progress!.showWithText("Loading...");
salary = _formKey.currentState!.value['salary']; // salary = _formKey.currentState!.value['salary'];
selectedPosition ??= state.workHistory.position; // selectedPosition ??= state.workHistory.position;
salaryGrade = // salaryGrade =
_formKey.currentState!.value['salary_grade']; // _formKey.currentState!.value['salary_grade'];
salaryGradeStep = // salaryGradeStep =
_formKey.currentState!.value['salary_step']; // _formKey.currentState!.value['salary_step'];
selectedAgency ??= state.workHistory.agency; // selectedAgency ??= state.workHistory.agency;
selectedStatus ??= AppoinemtStatus( // selectedStatus ??= AppoinemtStatus(
value: state.workHistory.appointmentStatus!, // value: state.workHistory.statusAppointment!,
label: state.workHistory.appointmentStatus!); // label: state.workHistory.statusAppointment!);
WorkHistory newWorkHistory = WorkHistory( // WorkHistory newWorkHistory = WorkHistory(
id: state.workHistory.id, // id: state.workHistory.id,
position: selectedPosition, // position: selectedPosition,
agency: selectedAgency, // agency: selectedAgency,
fromDate: fromDateController.text.isEmpty // fromDate: fromDateController.text.isEmpty
? null // ? null
: DateTime.parse(fromDateController.text), // : DateTime.parse(fromDateController.text),
toDate: toDateController.text.isEmpty || // toDate: toDateController.text.isEmpty ||
toDateController.text.toUpperCase() == // toDateController.text.toUpperCase() ==
"PRESENT" || // "PRESENT" ||
toDateController.text.toLowerCase() == // toDateController.text.toLowerCase() ==
'null' // 'null'
? null // ? null
: DateTime.parse(toDateController.text), // : DateTime.parse(toDateController.text),
monthlySalary: double.parse(salary!), // monthlySalary: double.parse(salary!),
appointmentStatus: selectedStatus!.value, // appointmentStatus: selectedStatus!.value,
salaryGrade: salaryGrade == null // salaryGrade: salaryGrade == null
? null // ? null
: int.parse(salaryGrade!), // : int.parse(salaryGrade!),
sgStep: salaryGradeStep == null // sgStep: salaryGradeStep == null
? null // ? null
: int.parse(salaryGradeStep!), // : int.parse(salaryGradeStep!),
); // );
context.read<WorkHistoryBloc>().add( // context.read<WorkHistoryBloc>().add(
UpdateWorkHistory( // UpdateWorkHistory(
oldWorkHistory: state.workHistory, // oldWorkHistory: state.workHistory,
profileId: widget.profileId.toString(), // profileId: widget.profileId.toString(),
token: widget.token, // token: widget.token,
workHistory: newWorkHistory)); // workHistory: newWorkHistory));
} // }
}, },
child: const Text(submit)), child: const Text(submit)),
), ),

View File

@ -44,7 +44,7 @@ class WorkHistoryScreen extends StatelessWidget {
AttachmentCategory? selectedAttachmentCategory; AttachmentCategory? selectedAttachmentCategory;
List<AttachmentCategory> attachmentCategories = []; List<AttachmentCategory> attachmentCategories = [];
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: true,
appBar: AppBar( appBar: AppBar(
title: context.watch<WorkHistoryBloc>().state is AddWorkHistoryState title: context.watch<WorkHistoryBloc>().state is AddWorkHistoryState
? const FittedBox(child: Text("Add Work History")) ? const FittedBox(child: Text("Add Work History"))
@ -623,87 +623,87 @@ class WorkHistoryScreen extends StatelessWidget {
]), ]),
const Divider(), const Divider(),
////Show Attachments ////Show Attachments
SizedBox( // SizedBox(
child: state // child: state
.workExperiences[ // .workExperiences[
index] // index]
.attachments == // .attachments ==
null || // null ||
state // state
.workExperiences[ // .workExperiences[
index] // index]
.attachments! // .attachments!
.isEmpty // .isEmpty
? const SizedBox() // ? const SizedBox()
: state // : state
.workExperiences[ // .workExperiences[
index] // index]
.attachments != // .attachments !=
null && // null &&
state // state
.workExperiences[ // .workExperiences[
index] // index]
.attachments! // .attachments!
.length == // .length ==
1 // 1
? // ?
////Single Attachment view // ////Single Attachment view
SingleAttachment( // SingleAttachment(
onpressed: () { // onpressed: () {
confirmAlert( // confirmAlert(
context, // context,
() { // () {
parent.read<WorkHistoryBloc>().add(DeleteWorkHistoryAttachment( // parent.read<WorkHistoryBloc>().add(DeleteWorkHistoryAttachment(
attachment: state // attachment: state
.workExperiences[ // .workExperiences[
index] // index]
.attachments! // .attachments!
.first, // .first,
moduleId: state // moduleId: state
.workExperiences[ // .workExperiences[
index] // index]
.id!, // .id!,
profileId: // profileId:
profileId!, // profileId!,
token: // token:
token!)); // token!));
}, "Delete?", // }, "Delete?",
"Confirm Delete?"); // "Confirm Delete?");
}, // },
attachment: state // attachment: state
.workExperiences[ // .workExperiences[
index] // index]
.attachments! // .attachments!
.first, // .first,
) // )
////Multiple Attachments View // ////Multiple Attachments View
: MultipleAttachments( // : MultipleAttachments(
profileId: // profileId:
profileId!, // profileId!,
token: token!, // token: token!,
moduleId: state // moduleId: state
.workExperiences[ // .workExperiences[
index] // index]
.id!, // .id!,
educationBloc: // educationBloc:
null, // null,
workHistoryBloc: // workHistoryBloc:
BlocProvider.of<WorkHistoryBloc>(context), // BlocProvider.of<WorkHistoryBloc>(context),
eligibilityBloc: // eligibilityBloc:
null, // null,
learningDevelopmentBloc: // learningDevelopmentBloc:
null, // null,
blocId: 3, // blocId: 3,
eligibilityName: state // eligibilityName: state
.workExperiences[ // .workExperiences[
index] // index]
.position! // .position!
.title!, // .title!,
attachments: state // attachments: state
.workExperiences[ // .workExperiences[
index] // index]
.attachments!, // .attachments!,
)) // ))
], ],
), ),
), ),

View File

@ -7,6 +7,7 @@ import 'package:unit2/bloc/profile/education/education_bloc.dart';
import 'package:unit2/bloc/profile/eligibility/eligibility_bloc.dart'; import 'package:unit2/bloc/profile/eligibility/eligibility_bloc.dart';
import 'package:unit2/bloc/profile/learningDevelopment/learning_development_bloc.dart'; import 'package:unit2/bloc/profile/learningDevelopment/learning_development_bloc.dart';
import 'package:unit2/bloc/profile/workHistory/workHistory_bloc.dart'; import 'package:unit2/bloc/profile/workHistory/workHistory_bloc.dart';
import 'package:unit2/screens/profile/shared/view_attachment.dart';
import 'package:unit2/utils/global_context.dart'; import 'package:unit2/utils/global_context.dart';
import '../../../model/profile/attachment.dart'; import '../../../model/profile/attachment.dart';
@ -16,6 +17,7 @@ import '../../../utils/alerts.dart';
import '../../../utils/global.dart'; import '../../../utils/global.dart';
class MultipleAttachments extends StatelessWidget { class MultipleAttachments extends StatelessWidget {
final Function(String source, String fileName) viewAttachment;
final List<Attachment> attachments; final List<Attachment> attachments;
final String eligibilityName; final String eligibilityName;
final EducationBloc? educationBloc; final EducationBloc? educationBloc;
@ -28,6 +30,7 @@ class MultipleAttachments extends StatelessWidget {
final String token; final String token;
const MultipleAttachments( const MultipleAttachments(
{super.key, {super.key,
required this.viewAttachment,
required this.blocId, required this.blocId,
required this.educationBloc, required this.educationBloc,
required this.eligibilityBloc, required this.eligibilityBloc,
@ -128,9 +131,14 @@ class MultipleAttachments extends StatelessWidget {
flex: 4, flex: 4,
child: Tooltip( child: Tooltip(
message: e.filename, message: e.filename,
child: Text( child: GestureDetector(
e.filename!, onTap: (){
overflow: TextOverflow.ellipsis, viewAttachment(e.source!,e.filename!);
},
child: Text(
e.filename!,
overflow: TextOverflow.ellipsis,
),
)), )),
), ),
const SizedBox( const SizedBox(

View File

@ -10,9 +10,11 @@ import '../../../utils/alerts.dart';
class SingleAttachment extends StatelessWidget { class SingleAttachment extends StatelessWidget {
final Function()? onpressed; final Function()? onpressed;
final Attachment attachment; final Attachment attachment;
final Function()? view;
const SingleAttachment({ const SingleAttachment({
required this.attachment, required this.attachment,
required this.onpressed, required this.onpressed,
required this.view,
super.key, super.key,
}); });
@ -32,11 +34,14 @@ class SingleAttachment extends StatelessWidget {
children: [ children: [
Expanded( Expanded(
child: child:
AutoSizeText( GestureDetector(
attachment.filename!, onTap: view,
wrapWords: false, child: AutoSizeText(
maxLines: 1, attachment.filename!,
), wrapWords: false,
maxLines: 1,
),
),
), ),
const SizedBox( const SizedBox(
width: width:

View File

@ -0,0 +1,62 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/widgets/error_state.dart';
import '../../../utils/urls.dart';
class ImageAttachment extends StatefulWidget {
final String imgUrl;
const ImageAttachment({super.key, required this.imgUrl});
@override
State<ImageAttachment> createState() => _ImageAttachmentState();
}
class _ImageAttachmentState extends State<ImageAttachment> {
@override
Widget build(BuildContext context) {
bool isPDF = widget.imgUrl[widget.imgUrl.length - 1] == 'f' ? true : false;
return Scaffold(
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: const Icon(Icons.file_download),
),
appBar: AppBar(
title: const Text("Attachment"),
centerTitle: true,
actions: [
IconButton(onPressed: () {}, icon: const Icon(Icons.share)),
],
),
body: isPDF
? SfPdfViewer.network(
'${Url.instance.prefixHost()}://${Url.instance.host()}${widget.imgUrl}',onDocumentLoadFailed: (details) {
Center(child: Text(details.description),);
},)
: Center(
child: CachedNetworkImage(
progressIndicatorBuilder: (context, url, progress) {
return const SizedBox(
height: 100,
width: 100,
child: CircularProgressIndicator(color: primary,));
},
imageBuilder: (context, imageProvider) => Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider, fit: BoxFit.fill)),
),
imageUrl:
'${Url.instance.prefixHost()}://${Url.instance.host()}${widget.imgUrl}',
width: double.infinity,
height: 220,
fit: BoxFit.cover,
),
),
);
}
}

View File

@ -32,6 +32,7 @@ class RbacRoleAssignment extends StatelessWidget {
List<ValueItem> selectedValueItemRoles = []; List<ValueItem> selectedValueItemRoles = [];
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
elevation: 0,
centerTitle: true, centerTitle: true,
backgroundColor: primary, backgroundColor: primary,
title: const Text("User Roles Screenss"), title: const Text("User Roles Screenss"),

View File

@ -8,13 +8,10 @@ import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/superadmi
import 'package:unit2/screens/unit2/homepage.dart/module-screen.dart'; import 'package:unit2/screens/unit2/homepage.dart/module-screen.dart';
import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/theme-data.dart/form-style.dart'; import 'package:unit2/theme-data.dart/form-style.dart';
import '../../../../../bloc/rbac/rbac_operations/agency/agency_bloc.dart';
import '../../../../../bloc/role/pass_check/est_point_person/assign_area/assign_area_agency_bloc.dart'; import '../../../../../bloc/role/pass_check/est_point_person/assign_area/assign_area_agency_bloc.dart';
import '../../../../../bloc/role/pass_check/est_point_person/est_point_person_assignable/est_point_person_assinable_role_bloc.dart'; import '../../../../../bloc/role/pass_check/est_point_person/est_point_person_assignable/est_point_person_assinable_role_bloc.dart';
import '../../../../../bloc/role/pass_check/est_point_person/est_point_person_role_assignment/est_role_assignment_bloc.dart'; import '../../../../../bloc/role/pass_check/est_point_person/est_point_person_role_assignment/est_role_assignment_bloc.dart';
import '../../../../../bloc/role/pass_check/est_point_person/est_point_person_station/est_point_person_station_bloc.dart'; import '../../../../../bloc/role/pass_check/est_point_person/est_point_person_station/est_point_person_station_bloc.dart';
import '../../../../../sevices/roles/est_point_person/est_point_person_role_assignment_services.dart';
import '../../../../superadmin/agency/agency_screen.dart';
import '../../../roles/establishment_point_person/est_point_person_agecies.dart'; import '../../../roles/establishment_point_person/est_point_person_agecies.dart';
import '../../../roles/establishment_point_person/est_point_person_role_member_screen.dart'; import '../../../roles/establishment_point_person/est_point_person_role_member_screen.dart';
import '../../../roles/establishment_point_person/est_point_person_role_under_screen.dart'; import '../../../roles/establishment_point_person/est_point_person_role_under_screen.dart';
@ -71,7 +68,9 @@ class _DashBoardState extends State<DashBoard> {
docSmsCards.add(e); docSmsCards.add(e);
} }
}); });
unit2Cards.forEach((element) {
print("${element.moduleName} - ${element.object.name!} - ${element.roleName} " );
});
if (superadminCards.length > 3) { if (superadminCards.length > 3) {
tempSuperAdminCards = superadminCards.sublist(0, 4); tempSuperAdminCards = superadminCards.sublist(0, 4);
} }
@ -85,6 +84,7 @@ class _DashBoardState extends State<DashBoard> {
child: ListView( child: ListView(
children: [ children: [
Column( Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
////unit2 module operations ////unit2 module operations
@ -107,7 +107,7 @@ class _DashBoardState extends State<DashBoard> {
), ),
Container( Container(
child: unit2Cards.isEmpty child: unit2Cards.isEmpty
? const SizedBox() ? const SizedBox.shrink()
: GridView.count( : GridView.count(
shrinkWrap: true, shrinkWrap: true,
crossAxisCount: 4, crossAxisCount: 4,
@ -185,7 +185,7 @@ class _DashBoardState extends State<DashBoard> {
child: child:
FadeInAnimation( FadeInAnimation(
child: Container( child: Container(
child: (e.roleName == 'superadmin' || e.roleName == 'qr code scanner' || e.roleName == 'security guard' || e.roleName == 'establishment point-person' || e.roleName == 'registration in-charge') && e.moduleName == 'unit2' child: (e.roleName == 'qr code scanner' || e.roleName == 'security guard' || e.roleName == 'establishment point-person' || e.roleName == 'registration in-charge') && e.moduleName == 'unit2'
? CardLabel( ? CardLabel(
icon: iconGenerator(name: e.object.name!), icon: iconGenerator(name: e.object.name!),
title: e.object.name!.toLowerCase() == 'role based access control' title: e.object.name!.toLowerCase() == 'role based access control'
@ -195,7 +195,7 @@ class _DashBoardState extends State<DashBoard> {
: e.object.name!, : e.object.name!,
ontap: () { ontap: () {
if (e.object.name!.toLowerCase() == 'pass check') { if (e.object.name!.toLowerCase() == 'pass check') {
PassCheckArguments passCheckArguments = PassCheckArguments(roleId: 10, userId: widget.userId); PassCheckArguments passCheckArguments = PassCheckArguments(roleId: e.roleId, userId: widget.userId);
Navigator.pushNamed(context, '/pass-check', arguments: passCheckArguments); Navigator.pushNamed(context, '/pass-check', arguments: passCheckArguments);
} }
if (e.object.name!.toLowerCase() == 'role based access control') { if (e.object.name!.toLowerCase() == 'role based access control') {
@ -210,19 +210,22 @@ class _DashBoardState extends State<DashBoard> {
})); }));
} }
if (e.object.name!.toLowerCase() == "role member") { if (e.object.name!.toLowerCase() == "role member") {
Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) { Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) {
return BlocProvider<EstRoleAssignmentBloc>( return BlocProvider<EstRoleAssignmentBloc>(
create: (context) => EstRoleAssignmentBloc()..add(GetEstPointPersonRolesUnder(userId: widget.userId)), create: (context) => EstRoleAssignmentBloc()..add(GetEstPointPersonRolesUnder(userId: widget.userId)),
child: EstPointPersonRoleAssignmentScreen(id: widget.userId,), child: EstPointPersonRoleAssignmentScreen(
id: widget.userId,
),
); );
})); }));
} }
if (e.object.name!.toLowerCase() == 'assignable role') { if (e.object.name!.toLowerCase() == 'assignable role') {
Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) { Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) {
return BlocProvider<EstPointPersonAssinableRoleBloc>( return BlocProvider<EstPointPersonAssinableRoleBloc>(
create: (context) => EstPointPersonAssinableRoleBloc()..add(const GetEstPointPersonAssignableRoles(roleId: 16)), create: (context) => EstPointPersonAssinableRoleBloc()..add(const GetEstPointPersonAssignableRoles(roleId: 16)),
child: EstPointPersonRoleUnderScreen(id: widget.userId,), child: EstPointPersonRoleUnderScreen(
id: widget.userId,
),
); );
})); }));
} }
@ -421,11 +424,11 @@ class _DashBoardState extends State<DashBoard> {
), ),
), ),
SizedBox( SizedBox(
height: unit2Cards.isEmpty ? 0 : 24, height: superadminCards.isEmpty ? 0 : 24,
), ),
Container( Container(
child: superadminCards.isEmpty child: superadminCards.isEmpty
? const SizedBox() ? const SizedBox.shrink()
: Text( : Text(
"Superadmin module operations", "Superadmin module operations",
style: Theme.of(context) style: Theme.of(context)
@ -442,7 +445,7 @@ class _DashBoardState extends State<DashBoard> {
), ),
Container( Container(
child: superadminCards.isEmpty child: superadminCards.isEmpty
? const SizedBox() ? const SizedBox.shrink()
: GridView.count( : GridView.count(
shrinkWrap: true, shrinkWrap: true,
crossAxisCount: 4, crossAxisCount: 4,
@ -602,12 +605,12 @@ class _DashBoardState extends State<DashBoard> {
columnCount: 4, columnCount: 4,
)); ));
}).toList())), }).toList())),
const SizedBox( SizedBox(
height: 24, height: rpassCards.isEmpty?0: 24,
), ),
Container( Container(
child: rpassCards.isEmpty child: rpassCards.isEmpty
? const SizedBox() ? const SizedBox.shrink()
: Text( : Text(
"RPAss module operations", "RPAss module operations",
style: Theme.of(context) style: Theme.of(context)
@ -624,7 +627,7 @@ class _DashBoardState extends State<DashBoard> {
), ),
Container( Container(
child: rpassCards.isEmpty child: rpassCards.isEmpty
? const SizedBox() ? const SizedBox.shrink()
: GridView.count( : GridView.count(
shrinkWrap: true, shrinkWrap: true,
crossAxisCount: 4, crossAxisCount: 4,
@ -649,12 +652,12 @@ class _DashBoardState extends State<DashBoard> {
}).toList(), }).toList(),
), ),
), ),
const SizedBox( SizedBox(
height: 24, height: docSmsCards.isEmpty?0: 24,
), ),
Container( Container(
child: docSmsCards.isEmpty child: docSmsCards.isEmpty
? const SizedBox() ? const SizedBox.shrink()
: Text( : Text(
"DocSMS module operations", "DocSMS module operations",
style: Theme.of(context) style: Theme.of(context)

View File

@ -77,7 +77,9 @@ class SuperAdminMenu extends StatelessWidget {
title: title:
object.object.name!, object.object.name!,
ontap: () { ontap: () {
if (object.object.name == 'Role') { if (object.object.name == 'Role') {
Navigator.push(context, MaterialPageRoute( Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
return BlocProvider( return BlocProvider(

View File

@ -43,6 +43,7 @@ class _MainScreenState extends State<MainScreen> {
for (var module in role.modules!) { for (var module in role.modules!) {
for (var object in module!.objects!) { for (var object in module!.objects!) {
DisplayCard newCard = DisplayCard( DisplayCard newCard = DisplayCard(
roleId: role.id!,
moduleName: module.name!.toLowerCase(), moduleName: module.name!.toLowerCase(),
object: object!, object: object!,
roleName: role.name!.toLowerCase()); roleName: role.name!.toLowerCase());
@ -91,8 +92,9 @@ class DisplayCard {
final String roleName; final String roleName;
final String moduleName; final String moduleName;
final ModuleObject object; final ModuleObject object;
final int roleId;
const DisplayCard( const DisplayCard(
{required this.moduleName, required this.object, required this.roleName}); {required this.moduleName, required this.object, required this.roleName,required this.roleId});
} }
class Module { class Module {

View File

@ -1,5 +1,6 @@
import 'dart:convert'; import 'dart:convert';
import 'package:intl/intl.dart';
import 'package:unit2/model/profile/work_history.dart'; import 'package:unit2/model/profile/work_history.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:unit2/model/utils/agency_position.dart'; import 'package:unit2/model/utils/agency_position.dart';
@ -48,17 +49,17 @@ class WorkHistoryService {
bool? success; bool? success;
Map<String, dynamic> params = {"force_mode": "true"}; Map<String, dynamic> params = {"force_mode": "true"};
String authToken = "Token $token"; String authToken = "Token $token";
String path = "${Url.instance.workhistory()}$profileId/"; String path = "${Url.instance.deleteWorkHistory()}$profileId/";
Map body = { Map body = {
"id": work.id, "id": work.id,
"position_id": work.position!.id, "position_id": work.position!.id,
"agency_id": work.agency!.id, "agency_id": work.agency!.id,
"from_date": work.fromDate?.toString(), "from_date": work.fromDate?.toString(),
"to_date": work.toDate?.toString(), "to_date": work.toDate?.toString(),
"monthly_salary": work.monthlySalary, // "monthly_salary": work.monthlysalary,
"appointment_status": work.appointmentStatus, // "appointment_status": work.statusAppointment,
"salary_step": work.sgStep, // "salary_step": work.sgstep,
"salary_grade": work.salaryGrade, // "salary_grade": work.salarygrade,
}; };
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
@ -82,85 +83,212 @@ class WorkHistoryService {
////edit work history ////edit work history
Future<Map<dynamic,dynamic>> update({required WorkHistory oldWorkHistory, required WorkHistory newWorkHistory, required String token, required String profileId})async{ // Future<Map<dynamic,dynamic>> update({required WorkHistory oldWorkHistory, required WorkHistory newWorkHistory, required String token, required String profileId})async{
Map<dynamic, dynamic>? statusResponse={}; // Map<dynamic, dynamic>? statusResponse={};
String authtoken = "Token $token"; // String authtoken = "Token $token";
String path = '${Url.instance.workhistory()}$profileId/'; // String path = '${Url.instance.workhistory()}$profileId/';
Map<String, String> headers = { // Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', // 'Content-Type': 'application/json; charset=UTF-8',
'Authorization': authtoken // 'Authorization': authtoken
}; // };
Map body = { // Map body = {
"id":newWorkHistory.id, // "id":newWorkHistory.id,
"position_id":newWorkHistory.position!.id, // "position_id":newWorkHistory.position!.id,
"agency_id":newWorkHistory.agency!.id, // "agency_id":newWorkHistory.agency!.id,
"from_date":newWorkHistory.fromDate?.toString(), // "from_date":newWorkHistory.fromDate?.toString(),
"to_date":newWorkHistory.toDate?.toString(), // "to_date":newWorkHistory.toDate?.toString(),
"monthly_salary":newWorkHistory.monthlySalary, // "monthly_salary":newWorkHistory.monthlysalary,
"appointment_status":newWorkHistory.appointmentStatus, // "appointment_status":newWorkHistory.statusAppointment,
"salary_grade":newWorkHistory.salaryGrade, // "salary_grade":newWorkHistory.salarygrade,
"sg_step":newWorkHistory.sgStep, // "sg_step":newWorkHistory.sgstep,
"_positionName":newWorkHistory.position!.title!, // "_positionName":newWorkHistory.position!.title!,
"_agencyName":newWorkHistory.agency!.name!, // "_agencyName":newWorkHistory.agency!.name!,
"_agencyCatId":newWorkHistory.agency!.category!.id!, // "_agencyCatId":newWorkHistory.agency!.category!.id!,
"_privateEntity":newWorkHistory.agency!.privateEntity, // "_privateEntity":newWorkHistory.agency!.privateEntity,
"oldPosId":oldWorkHistory.position!.id, // "oldPosId":oldWorkHistory.position!.id,
"_oldAgencyId":oldWorkHistory.agency!.id, // "_oldAgencyId":oldWorkHistory.agency!.id,
"oldFromDate":oldWorkHistory.fromDate?.toString(), // "oldFromDate":oldWorkHistory.fromDate?.toString(),
}; // };
try{
http.Response response = await Request.instance.putRequest(path: path, headers: headers, body: body, param: {});
if(response.statusCode == 200 ){ // try{
Map data = jsonDecode(response.body); // http.Response response = await Request.instance.putRequest(path: path, headers: headers, body: body, param: {});
statusResponse = data; // if(response.statusCode == 200 ){
}else{ // Map data = jsonDecode(response.body);
statusResponse.addAll({'success':false}); // statusResponse = data;
} // }else{
return statusResponse; // statusResponse.addAll({'success':false});
}catch(e){ // }
throw e.toString(); // return statusResponse;
} // }catch(e){
} // throw e.toString();
// }
// }
////Add work history ////Add work history
Future<Map<dynamic, dynamic>>add({required WorkHistory workHistory, required String token, required int profileId , required bool isPrivate})async{ Future<Map<dynamic, dynamic>>add({required WorkHistory workHistory, required String token, required int profileId , required bool isPrivate,required String? accomplishment, required String? actualDuties})async{
String authtoken = "Token $token"; String authtoken = "Token $token";
String path = '${Url.instance.workhistory()}$profileId/'; String path = '${Url.instance.workhistory()}$profileId/';
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'Authorization': authtoken 'Authorization': authtoken
}; };
Map<String,String> body = {};
Map<dynamic,dynamic> statusResponse = {}; Map<dynamic,dynamic> statusResponse = {};
Map body = { String fromDate = DateFormat('yyyy-MM-dd').format(workHistory.fromDate!);
'position_id':workHistory.position?.id, String? toDate;
'agency_id': workHistory.agency?.id, if(workHistory.toDate != null){
'from_date': workHistory.fromDate?.toString(), toDate = DateFormat('yyyy-MM-dd').format(workHistory.toDate!);
'to_date': workHistory.toDate?.toString(), }
'monthly_salary': workHistory.monthlySalary, if(workHistory.toDate == null){
'appointment_status': workHistory.appointmentStatus, body = {
'salary_grade': workHistory.salaryGrade, "a_category_id ": workHistory.agency?.category?.id == null? "":workHistory.agency!.category!.id.toString(),
'sg_step':workHistory.sgStep, "a_name" : workHistory.agency?.name == null? "":workHistory.agency!.name!,
'_positionName':workHistory.position?.title, " a_private_entity ": workHistory.agency?.privateEntity == null?"":workHistory.agency!.privateEntity.toString(),
'_agencyName':workHistory.agency?.name, "accomplishment" : accomplishment??"",
'_agencyCatId':workHistory.agency?.category?.id, "actual_duties ": actualDuties!,
'_privateEntity':workHistory.agency?.privateEntity, "agency_id" : workHistory.agency?.id == null?"": workHistory.agency!.id.toString() ,
"from_date" : fromDate,
"monthly_salary" : workHistory.monthlysalary == null? "": workHistory.monthlysalary.toString(),
"position_id" : workHistory.position?.id == null? "": workHistory.position!.id.toString(),
"position_name" : workHistory.position?.title == null? "":workHistory.position!.title!,
"s_fname" : workHistory.supervisor?.firstname == null?"":workHistory.supervisor!.firstname!,
"s_lname" : workHistory.supervisor?.lastname == null? "":workHistory.supervisor!.lastname!,
"s_mname" : workHistory.supervisor?.middlename == null?"":workHistory.supervisor!.middlename!,
"s_office" : workHistory.supervisor?.stationName == null?"":workHistory.supervisor!.stationName!,
"salary_grade" : workHistory.salarygrade == null? "":workHistory.salarygrade.toString(),
"sg_step" : workHistory.sgstep == null?"":workHistory.sgstep.toString() ,
'status_appointment' : workHistory.statusAppointment??"",
}; };
try{ }else{
http.Response response = await Request.instance.postRequest(path: path,param: {},body: body,headers: headers); body = {
if(response.statusCode == 201){ "a_category_id ": workHistory.agency?.category?.id == null? "":workHistory.agency!.category!.id.toString(),
Map data = jsonDecode(response.body); "a_name" : workHistory.agency?.name == null? "":workHistory.agency!.name!,
" a_private_entity ": workHistory.agency?.privateEntity == null?"":workHistory.agency!.privateEntity.toString(),
"accomplishment" : accomplishment??"",
"actual_duties ": actualDuties!,
"agency_id" : workHistory.agency?.id == null?"": workHistory.agency!.id.toString() ,
"from_date" : workHistory.fromDate == null? "2018-10-04":"2018-06-04",
"monthly_salary" : workHistory.monthlysalary == null? "": workHistory.monthlysalary.toString(),
"position_id" : workHistory.position?.id == null? "": workHistory.position!.id.toString(),
"position_name" : workHistory.position?.title == null? "":workHistory.position!.title!,
"s_fname" : workHistory.supervisor?.firstname == null?"":workHistory.supervisor!.firstname!,
"s_lname" : workHistory.supervisor?.lastname == null? "":workHistory.supervisor!.lastname!,
"s_mname" : workHistory.supervisor?.middlename == null?"":workHistory.supervisor!.middlename!,
"s_office" : workHistory.supervisor?.stationName == null?"":workHistory.supervisor!.stationName!,
"salary_grade" : workHistory.salarygrade == null? "":workHistory.salarygrade.toString(),
"sg_step" : workHistory.sgstep == null?"":workHistory.sgstep.toString() ,
'status_appointment' : workHistory.statusAppointment??"",
"to_date" : toDate!,
};
}
var request = http.MultipartRequest('POST',Uri.parse('${Url.instance.prefixHost()}://${Url.instance.host()}$path'));
request.fields.addAll(body);
request.headers.addAll(headers);
try {
http.StreamedResponse response = await request.send();
final steamResponse = await response.stream.bytesToString();
Map data = jsonDecode(steamResponse);
if (response.statusCode == 201) {
statusResponse = data; statusResponse = data;
} else {
}else{ String message = data['response']['details'];
statusResponse.addAll({'success':false}); statusResponse.addAll({'message': message});
statusResponse.addAll(
{'success': false},
);
} }
return statusResponse; } catch (e) {
}catch(e){
throw e.toString(); throw e.toString();
} }
return statusResponse;
} }
Future<Map<dynamic, dynamic>>update({required WorkHistory workHistory, required String token, required int profileId , required bool isPrivate,required String? accomplishment, required String? actualDuties})async{
String authtoken = "Token $token";
String path = '${Url.instance.workhistory()}$profileId/';
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': authtoken
};
Map<String,String> body = {};
Map<dynamic,dynamic> statusResponse = {};
String fromDate = DateFormat('yyyy-MM-dd').format(workHistory.fromDate!);
String? toDate;
if(workHistory.toDate != null){
toDate = DateFormat('yyyy-MM-dd').format(workHistory.toDate!);
}
if(workHistory.toDate == null){
body = {
"a_category_id ": workHistory.agency?.category?.id == null? "":workHistory.agency!.category!.id.toString(),
"a_name" : workHistory.agency?.name == null? "":workHistory.agency!.name!,
" a_private_entity ": workHistory.agency?.privateEntity == null?"":workHistory.agency!.privateEntity.toString(),
"accomplishment" : accomplishment??"",
"actual_duties ": actualDuties!,
"agency_id" : workHistory.agency?.id == null?"": workHistory.agency!.id.toString() ,
"from_date" : fromDate,
"monthly_salary" : workHistory.monthlysalary == null? "": workHistory.monthlysalary.toString(),
"position_id" : workHistory.position?.id == null? "": workHistory.position!.id.toString(),
"position_name" : workHistory.position?.title == null? "":workHistory.position!.title!,
"s_fname" : workHistory.supervisor?.firstname == null?"":workHistory.supervisor!.firstname!,
"s_lname" : workHistory.supervisor?.lastname == null? "":workHistory.supervisor!.lastname!,
"s_mname" : workHistory.supervisor?.middlename == null?"":workHistory.supervisor!.middlename!,
"s_office" : workHistory.supervisor?.stationName == null?"":workHistory.supervisor!.stationName!,
"salary_grade" : workHistory.salarygrade == null? "":workHistory.salarygrade.toString(),
"sg_step" : workHistory.sgstep == null?"":workHistory.sgstep.toString() ,
'status_appointment' : workHistory.statusAppointment??"",
};
}else{
body = {
"a_category_id ": workHistory.agency?.category?.id == null? "":workHistory.agency!.category!.id.toString(),
"a_name" : workHistory.agency?.name == null? "":workHistory.agency!.name!,
" a_private_entity ": workHistory.agency?.privateEntity == null?"":workHistory.agency!.privateEntity.toString(),
"accomplishment" : accomplishment??"",
"actual_duties ": actualDuties!,
"agency_id" : workHistory.agency?.id == null?"": workHistory.agency!.id.toString() ,
"from_date" : workHistory.fromDate == null? "2018-10-04":"2018-06-04",
"monthly_salary" : workHistory.monthlysalary == null? "": workHistory.monthlysalary.toString(),
"position_id" : workHistory.position?.id == null? "": workHistory.position!.id.toString(),
"position_name" : workHistory.position?.title == null? "":workHistory.position!.title!,
"s_fname" : workHistory.supervisor?.firstname == null?"":workHistory.supervisor!.firstname!,
"s_lname" : workHistory.supervisor?.lastname == null? "":workHistory.supervisor!.lastname!,
"s_mname" : workHistory.supervisor?.middlename == null?"":workHistory.supervisor!.middlename!,
"s_office" : workHistory.supervisor?.stationName == null?"":workHistory.supervisor!.stationName!,
"salary_grade" : workHistory.salarygrade == null? "":workHistory.salarygrade.toString(),
"sg_step" : workHistory.sgstep == null?"":workHistory.sgstep.toString() ,
'status_appointment' : workHistory.statusAppointment??"",
"to_date" : toDate!,
};
}
var request = http.MultipartRequest('PUT',Uri.parse('${Url.instance.prefixHost()}://${Url.instance.host()}$path'));
request.fields.addAll(body);
request.headers.addAll(headers);
try {
http.StreamedResponse response = await request.send();
final steamResponse = await response.stream.bytesToString();
Map data = jsonDecode(steamResponse);
if (response.statusCode == 201) {
statusResponse = data;
} else {
String message = data['response']['details'];
statusResponse.addAll({'message': message});
statusResponse.addAll(
{'success': false},
);
}
} catch (e) {
throw e.toString();
}
return statusResponse;
}
////get agency position ////get agency position
Future<List<PositionTitle>> getAgencyPosition() async { Future<List<PositionTitle>> getAgencyPosition() async {
List<PositionTitle> agencyPositions = []; List<PositionTitle> agencyPositions = [];

View File

@ -32,7 +32,7 @@ class PassCheckServices {
'X-Client-Key': xClientKey, 'X-Client-Key': xClientKey,
'X-Client-Secret': xClientSecret 'X-Client-Secret': xClientSecret
}; };
// try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(param: params, headers: headers, path: path); .getRequest(param: params, headers: headers, path: path);
if (response.statusCode == 200) { if (response.statusCode == 200) {
@ -133,9 +133,9 @@ class PassCheckServices {
statusResponse = assignedArea; statusResponse = assignedArea;
} }
} }
// } catch (e) { } catch (e) {
// throw e.toString(); throw e.toString();
// } }
return statusResponse!; return statusResponse!;
} }

View File

@ -1,6 +1,10 @@
import 'dart:convert'; import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:share_plus/share_plus.dart';
import 'package:unit2/utils/request.dart'; import 'package:unit2/utils/request.dart';
import 'package:unit2/utils/request_permission.dart';
import 'package:unit2/utils/urls.dart'; import 'package:unit2/utils/urls.dart';
import '../model/profile/attachment.dart'; import '../model/profile/attachment.dart';
@ -12,7 +16,7 @@ class AttachmentServices {
Future<List<AttachmentCategory>> getCategories() async { Future<List<AttachmentCategory>> getCategories() async {
List<AttachmentCategory> attachmentCategories = []; List<AttachmentCategory> attachmentCategories = [];
String path = Url.instance.attachmentCategories()+"11232"; String path = Url.instance.attachmentCategories();
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
}; };
@ -113,7 +117,7 @@ class AttachmentServices {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'Authorization': authtoken 'Authorization': authtoken
}; };
// try { try {
http.Response response = await Request.instance.deleteRequest( http.Response response = await Request.instance.deleteRequest(
path: path, headers: headers, body: body, param: params); path: path, headers: headers, body: body, param: params);
if (response.statusCode == 200) { if (response.statusCode == 200) {
@ -122,9 +126,29 @@ class AttachmentServices {
} else { } else {
success = false; success = false;
} }
// } catch (e) { } catch (e) {
// throw (e.toString()); throw (e.toString());
// } }
return success!; return success!;
} }
Future<bool> downloadAttachment(
{required String filename,
required String source,
required String downLoadDir}) async {
bool success = false;
var dio = Dio();
Response response;
try {
if (await requestPermission(Permission.storage)) {
response = await dio.download(source, "$downLoadDir/$filename");
if (response.statusCode == 200) {
success = true;
}
}
return success;
} catch (e) {
throw e.toString();
}
}
} }

View File

@ -19,7 +19,7 @@ class Request {
Map<String, String>? param}) async { Map<String, String>? param}) async {
Response response; Response response;
try { try {
response = await get(Uri.http(host, path!, param), headers: headers) response = await get(Uri.https(host, path!, param), headers: headers)
.timeout(Duration(seconds: requestTimeout)); .timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) { } on TimeoutException catch (_) {
Fluttertoast.showToast( Fluttertoast.showToast(
@ -61,7 +61,7 @@ class Request {
Map<String, String>? param}) async { Map<String, String>? param}) async {
Response response; Response response;
try { try {
response = await post(Uri.http(host, path!, param), response = await post(Uri.https(host, path!, param),
headers: headers, body: jsonEncode(body)) headers: headers, body: jsonEncode(body))
.timeout(Duration(seconds: requestTimeout)); .timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) { } on TimeoutException catch (_) {
@ -104,7 +104,7 @@ class Request {
required Map<String, dynamic>? param}) async { required Map<String, dynamic>? param}) async {
Response response; Response response;
try { try {
response =await put(Uri.http(host,path,param),headers: headers,body: jsonEncode(body)); response =await put(Uri.https(host,path,param),headers: headers,body: jsonEncode(body));
} on TimeoutException catch (_) { } on TimeoutException catch (_) {
Fluttertoast.showToast( Fluttertoast.showToast(
msg: timeoutError, msg: timeoutError,
@ -186,7 +186,7 @@ class Request {
required Map<String, dynamic>? param}) async { required Map<String, dynamic>? param}) async {
Response response; Response response;
try { try {
response = await delete(Uri.http(host, path, param), response = await delete(Uri.https(host, path, param),
headers: headers, body: jsonEncode(body)) headers: headers, body: jsonEncode(body))
.timeout(Duration(seconds: requestTimeout)); .timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) { } on TimeoutException catch (_) {

View File

@ -0,0 +1,14 @@
import 'package:permission_handler/permission_handler.dart';
Future<bool> requestPermission(Permission permission) async {
if (await permission.isGranted) {
return true;
} else {
var result = await permission.request();
if (result == PermissionStatus.granted) {
return true;
}
}
return false;
}

View File

@ -5,13 +5,17 @@ class Url {
String host() { String host() {
// return '192.168.10.183:3000'; // return '192.168.10.183:3000';
// return 'agusandelnorte.gov.ph'; return 'agusandelnorte.gov.ph';
return "192.168.10.219:3000"; // return "192.168.10.219:3000";
// return "192.168.10.241"; // return "192.168.10.241";
// return "192.168.10.221:3004"; // return "192.168.10.221:3004";
// return "playweb.agusandelnorte.gov.ph"; // return "playweb.agusandelnorte.gov.ph";
// return 'devapi.agusandelnorte.gov.ph:3004'; // return 'devapi.agusandelnorte.gov.ph:3004';
} }
String prefixHost(){
return "https";
// return "https";
}
String authentication() { String authentication() {
return '/api/account/auth/login/'; return '/api/account/auth/login/';
@ -58,7 +62,10 @@ class Url {
//// work history paths //// work history paths
String workhistory() { String workhistory() {
return "/api/jobnet_app/profile/pds/work/"; return "/api/jobnet_app/profile/pds/work_experience/";
}
String deleteWorkHistory(){
return "/api/jobnet_app/profile/pds/work/";
} }
String getPositions() { String getPositions() {

View File

@ -9,6 +9,7 @@
#include <audioplayers_linux/audioplayers_linux_plugin.h> #include <audioplayers_linux/audioplayers_linux_plugin.h>
#include <modal_progress_hud_nsn/modal_progress_hud_nsn_plugin.h> #include <modal_progress_hud_nsn/modal_progress_hud_nsn_plugin.h>
#include <platform_device_id_linux/platform_device_id_linux_plugin.h> #include <platform_device_id_linux/platform_device_id_linux_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) { void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) audioplayers_linux_registrar = g_autoptr(FlPluginRegistrar) audioplayers_linux_registrar =
@ -20,4 +21,7 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) platform_device_id_linux_registrar = g_autoptr(FlPluginRegistrar) platform_device_id_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "PlatformDeviceIdLinuxPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "PlatformDeviceIdLinuxPlugin");
platform_device_id_linux_plugin_register_with_registrar(platform_device_id_linux_registrar); platform_device_id_linux_plugin_register_with_registrar(platform_device_id_linux_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
} }

View File

@ -6,6 +6,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
audioplayers_linux audioplayers_linux
modal_progress_hud_nsn modal_progress_hud_nsn
platform_device_id_linux platform_device_id_linux
url_launcher_linux
) )
list(APPEND FLUTTER_FFI_PLUGIN_LIST list(APPEND FLUTTER_FFI_PLUGIN_LIST

View File

@ -8,6 +8,7 @@ import Foundation
import assets_audio_player import assets_audio_player
import assets_audio_player_web import assets_audio_player_web
import audioplayers_darwin import audioplayers_darwin
import device_info_plus
import location import location
import modal_progress_hud_nsn import modal_progress_hud_nsn
import package_info_plus import package_info_plus
@ -15,13 +16,17 @@ import path_provider_foundation
import platform_device_id import platform_device_id
import platform_device_id_macos import platform_device_id_macos
import rive_common import rive_common
import share_plus
import shared_preferences_foundation import shared_preferences_foundation
import sqflite import sqflite
import syncfusion_pdfviewer_macos
import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AssetsAudioPlayerPlugin.register(with: registry.registrar(forPlugin: "AssetsAudioPlayerPlugin")) AssetsAudioPlayerPlugin.register(with: registry.registrar(forPlugin: "AssetsAudioPlayerPlugin"))
AssetsAudioPlayerWebPlugin.register(with: registry.registrar(forPlugin: "AssetsAudioPlayerWebPlugin")) AssetsAudioPlayerWebPlugin.register(with: registry.registrar(forPlugin: "AssetsAudioPlayerWebPlugin"))
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin")) AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
LocationPlugin.register(with: registry.registrar(forPlugin: "LocationPlugin")) LocationPlugin.register(with: registry.registrar(forPlugin: "LocationPlugin"))
ModalProgressHudNsnPlugin.register(with: registry.registrar(forPlugin: "ModalProgressHudNsnPlugin")) ModalProgressHudNsnPlugin.register(with: registry.registrar(forPlugin: "ModalProgressHudNsnPlugin"))
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
@ -29,6 +34,9 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PlatformDeviceIdMacosPlugin.register(with: registry.registrar(forPlugin: "PlatformDeviceIdMacosPlugin")) PlatformDeviceIdMacosPlugin.register(with: registry.registrar(forPlugin: "PlatformDeviceIdMacosPlugin"))
PlatformDeviceIdMacosPlugin.register(with: registry.registrar(forPlugin: "PlatformDeviceIdMacosPlugin")) PlatformDeviceIdMacosPlugin.register(with: registry.registrar(forPlugin: "PlatformDeviceIdMacosPlugin"))
RivePlugin.register(with: registry.registrar(forPlugin: "RivePlugin")) RivePlugin.register(with: registry.registrar(forPlugin: "RivePlugin"))
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
SyncfusionFlutterPdfViewerPlugin.register(with: registry.registrar(forPlugin: "SyncfusionFlutterPdfViewerPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
} }

View File

@ -337,6 +337,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
cross_file:
dependency: transitive
description:
name: cross_file
sha256: "0b0036e8cccbfbe0555fd83c1d31a6f30b77a96b598b35a5d36dd41f718695e9"
url: "https://pub.dev"
source: hosted
version: "0.3.3+4"
crypto: crypto:
dependency: transitive dependency: transitive
description: description:
@ -385,6 +393,22 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.1" version: "2.0.1"
device_info_plus:
dependency: transitive
description:
name: device_info_plus
sha256: f52ab3b76b36ede4d135aab80194df8925b553686f0fa12226b4e2d658e45903
url: "https://pub.dev"
source: hosted
version: "8.2.2"
device_info_plus_platform_interface:
dependency: transitive
description:
name: device_info_plus_platform_interface
sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64
url: "https://pub.dev"
source: hosted
version: "7.0.0"
device_preview: device_preview:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1253,6 +1277,22 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.8" version: "0.7.8"
share_plus:
dependency: "direct main"
description:
name: share_plus
sha256: "6cec740fa0943a826951223e76218df002804adb588235a8910dc3d6b0654e11"
url: "https://pub.dev"
source: hosted
version: "7.1.0"
share_plus_platform_interface:
dependency: transitive
description:
name: share_plus_platform_interface
sha256: "357412af4178d8e11d14f41723f80f12caea54cf0d5cd29af9dcdab85d58aea7"
url: "https://pub.dev"
source: hosted
version: "3.3.0"
shared_preferences: shared_preferences:
dependency: transitive dependency: transitive
description: description:
@ -1418,6 +1458,62 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
syncfusion_flutter_core:
dependency: transitive
description:
name: syncfusion_flutter_core
sha256: "8db8f55c77f56968681447d3837c10f27a9e861e238a898fda116c7531def979"
url: "https://pub.dev"
source: hosted
version: "21.2.10"
syncfusion_flutter_pdf:
dependency: transitive
description:
name: syncfusion_flutter_pdf
sha256: a42186922a416c2c9634a8f221aee261101babc2d30b1a1e908a7f034e743046
url: "https://pub.dev"
source: hosted
version: "21.2.4"
syncfusion_flutter_pdfviewer:
dependency: "direct main"
description:
name: syncfusion_flutter_pdfviewer
sha256: "2dc016f251c675f8e4923135c485356473b4d89c677670164292159cd1dd4f45"
url: "https://pub.dev"
source: hosted
version: "21.2.3"
syncfusion_pdfviewer_macos:
dependency: transitive
description:
name: syncfusion_pdfviewer_macos
sha256: "8cc925cae532c0fa17e849165796d962107f45b86e66ee334dcaabf6b7305c82"
url: "https://pub.dev"
source: hosted
version: "21.2.10"
syncfusion_pdfviewer_platform_interface:
dependency: transitive
description:
name: syncfusion_pdfviewer_platform_interface
sha256: "08039ecdb8f79454fb367c6bf5a833846a666039415d2b5d76a7e59a5b3ff710"
url: "https://pub.dev"
source: hosted
version: "21.2.10"
syncfusion_pdfviewer_web:
dependency: transitive
description:
name: syncfusion_pdfviewer_web
sha256: "8e5ed0d313a1aa3869e4f2e8d079bc9bfa37ce79d91be7bb328e456f37b7995f"
url: "https://pub.dev"
source: hosted
version: "21.2.10"
syncfusion_pdfviewer_windows:
dependency: transitive
description:
name: syncfusion_pdfviewer_windows
sha256: "3e93f281135fb0562f7e6c343d2db741cf3cbd78c5b04884eef9af414408bc77"
url: "https://pub.dev"
source: hosted
version: "21.2.10"
synchronized: synchronized:
dependency: transitive dependency: transitive
description: description:
@ -1474,6 +1570,70 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.3.2" version: "1.3.2"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
sha256: eb1e00ab44303d50dd487aab67ebc575456c146c6af44422f9c13889984c00f3
url: "https://pub.dev"
source: hosted
version: "6.1.11"
url_launcher_android:
dependency: "direct main"
description:
name: url_launcher_android
sha256: "3dd2388cc0c42912eee04434531a26a82512b9cb1827e0214430c9bcbddfe025"
url: "https://pub.dev"
source: hosted
version: "6.0.38"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
sha256: "9af7ea73259886b92199f9e42c116072f05ff9bea2dcb339ab935dfc957392c2"
url: "https://pub.dev"
source: hosted
version: "6.1.4"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
sha256: "207f4ddda99b95b4d4868320a352d374b0b7e05eefad95a4a26f57da413443f5"
url: "https://pub.dev"
source: hosted
version: "3.0.5"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
sha256: "1c4fdc0bfea61a70792ce97157e5cc17260f61abbe4f39354513f39ec6fd73b1"
url: "https://pub.dev"
source: hosted
version: "3.0.6"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
sha256: bfdfa402f1f3298637d71ca8ecfe840b4696698213d5346e9d12d4ab647ee2ea
url: "https://pub.dev"
source: hosted
version: "2.1.3"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
sha256: cc26720eefe98c1b71d85f9dc7ef0cada5132617046369d9dc296b3ecaa5cbb4
url: "https://pub.dev"
source: hosted
version: "2.0.18"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
sha256: "7967065dd2b5fccc18c653b97958fdf839c5478c28e767c61ee879f4e7882422"
url: "https://pub.dev"
source: hosted
version: "3.0.7"
uuid: uuid:
dependency: transitive dependency: transitive
description: description:

View File

@ -89,6 +89,10 @@ dependencies:
file_picker: ^5.3.1 file_picker: ^5.3.1
expandable: ^5.0.1 expandable: ^5.0.1
flutter_simple_treeview: ^3.0.2 flutter_simple_treeview: ^3.0.2
syncfusion_flutter_pdfviewer: ^21.2.3
url_launcher: ^6.1.11
url_launcher_android: ^6.0.38
share_plus: ^7.1.0

View File

@ -11,6 +11,9 @@
#include <permission_handler_windows/permission_handler_windows_plugin.h> #include <permission_handler_windows/permission_handler_windows_plugin.h>
#include <platform_device_id_windows/platform_device_id_windows_plugin.h> #include <platform_device_id_windows/platform_device_id_windows_plugin.h>
#include <rive_common/rive_plugin.h> #include <rive_common/rive_plugin.h>
#include <share_plus/share_plus_windows_plugin_c_api.h>
#include <syncfusion_pdfviewer_windows/syncfusion_pdfviewer_windows_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) { void RegisterPlugins(flutter::PluginRegistry* registry) {
AudioplayersWindowsPluginRegisterWithRegistrar( AudioplayersWindowsPluginRegisterWithRegistrar(
@ -23,4 +26,10 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("PlatformDeviceIdWindowsPlugin")); registry->GetRegistrarForPlugin("PlatformDeviceIdWindowsPlugin"));
RivePluginRegisterWithRegistrar( RivePluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("RivePlugin")); registry->GetRegistrarForPlugin("RivePlugin"));
SharePlusWindowsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
SyncfusionPdfviewerWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("SyncfusionPdfviewerWindowsPlugin"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
} }

View File

@ -8,6 +8,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
permission_handler_windows permission_handler_windows
platform_device_id_windows platform_device_id_windows
rive_common rive_common
share_plus
syncfusion_pdfviewer_windows
url_launcher_windows
) )
list(APPEND FLUTTER_FFI_PLUGIN_LIST list(APPEND FLUTTER_FFI_PLUGIN_LIST