Project Steps completion
This commit is contained in:
@@ -649,14 +649,14 @@ Future<List<Project>> GetProjects(bool forceOffline) async {
|
||||
}
|
||||
|
||||
List<Map> cats = await cacheDb.rawQuery('SELECT * FROM Projects');
|
||||
print(cats.length);
|
||||
print('projects : ${cats.length}');
|
||||
for (Map element in cats) {
|
||||
String? name = element[Project.colName];
|
||||
String? category = element[Project.colCat];
|
||||
String? stepsJson = element[Project.colSteps];
|
||||
String? deadline = element[Project.colDeadline];
|
||||
int? eta= element[Project.colEta];
|
||||
|
||||
print(name);
|
||||
|
||||
if (name == null || category == null || stepsJson == null || deadline == null || eta==null) {
|
||||
print("Something is null!\nname:${name == null}, cat:${category == null}, steps:${stepsJson == null}, deadline${deadline == null}");
|
||||
@@ -1139,6 +1139,47 @@ class UserOperations {
|
||||
await executeQueries();
|
||||
}
|
||||
|
||||
static Future<void> CompleteProjectStep(Project project, ProjectStep step, DateTime finishedDate) async {
|
||||
|
||||
project.steps.forEach((element) {
|
||||
if(element.stepName == step.stepName){
|
||||
element.finishedDate = finishedDate;
|
||||
}
|
||||
});
|
||||
|
||||
Map<String, String> queryBody = <String, String>{
|
||||
'name': username+project.name,
|
||||
'username': username,
|
||||
'steps': jsonEncode(project.steps),
|
||||
};
|
||||
|
||||
if (cacheEnabled) {
|
||||
//Add Query
|
||||
Map<String, Object> query = {Queries.colLink: 'update_projectSteps', Queries.colData: jsonEncode(queryBody)};
|
||||
|
||||
print("adding new query ${query[Queries.colLink]} : ${jsonEncode(queryBody)}");
|
||||
|
||||
await cacheDb.insert('Queries', query);
|
||||
await cacheDb.rawUpdate("UPDATE Projects SET steps='${jsonEncode(project.steps)}' WHERE ${Project.colName}='${project.name}'");
|
||||
//update Cache
|
||||
// Map<String, Object> data = {Project.colName: username+name, Project.colCat: category, Project.colSteps: jsonEncode(steps),Project.colEta: eta, Project.colDeadline: deadline.toString()};
|
||||
// await cacheDb.insert('Projects', data);
|
||||
await refreshUserData(forceOffline: true);
|
||||
} else {
|
||||
try {
|
||||
http.Response queryResponse = (await http.post(Uri.parse('http://161.97.127.136/task_tracker/update_projectSteps.php'), body: queryBody));
|
||||
print("Query executed : Results{${queryResponse.body}");
|
||||
if (queryResponse.body.toLowerCase().contains("success")) {
|
||||
//Success
|
||||
}
|
||||
} catch (e) {
|
||||
print('NC: Error completing prjctStep $e}');
|
||||
}
|
||||
}
|
||||
|
||||
await executeQueries();
|
||||
}
|
||||
|
||||
static Future<void> deleteTask(String name, {bulk = false}) async {
|
||||
Map<String, String> queryBody = <String, String>{
|
||||
'id': username + name,
|
||||
|
||||
Reference in New Issue
Block a user