add carton from mix_box & from cargos
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:fcs/domain/constants.dart';
|
||||
import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/helpers/api_helper.dart';
|
||||
import 'package:fcs/helpers/firebase_helper.dart';
|
||||
@@ -31,4 +34,32 @@ class CartonDataProvider {
|
||||
return await requestAPI("/cartons/deliver", "PUT",
|
||||
payload: carton.toMap(), token: await getToken());
|
||||
}
|
||||
|
||||
Future<List<Carton>> searchCarton(String term) async {
|
||||
if (term == null || term == '') return List();
|
||||
|
||||
// var bytes = utf8.encode(term);
|
||||
// var base64Str = base64.encode(bytes);
|
||||
// HtmlEscape htmlEscape = const HtmlEscape();
|
||||
// String escapeBuyer = htmlEscape.convert(base64Str);
|
||||
|
||||
try {
|
||||
String path = "/$cartons_collection";
|
||||
var querySnap = await Firestore.instance
|
||||
.collection(path)
|
||||
.where("carton_number", isEqualTo: term)
|
||||
.where("carton_type",
|
||||
whereIn: [carton_from_packages, carton_from_cargos])
|
||||
.where("status", isEqualTo: carton_packed_status)
|
||||
.where("is_deleted", isEqualTo: false)
|
||||
.orderBy("user_name")
|
||||
.getDocuments();
|
||||
return querySnap.documents
|
||||
.map((e) => Carton.fromMap(e.data, e.documentID))
|
||||
.toList();
|
||||
} catch (e) {
|
||||
log.warning("carton error:" + e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,4 +33,9 @@ class CartonServiceImp implements CartonService {
|
||||
Future<void> deliver(Carton carton) {
|
||||
return cartonDataProvider.deliver(carton);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<Carton>> searchCarton(String term) {
|
||||
return cartonDataProvider.searchCarton(term);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,4 +5,5 @@ abstract class CartonService {
|
||||
Future<void> updateCarton(Carton carton);
|
||||
Future<void> deleteCarton(Carton carton);
|
||||
Future<void> deliver(Carton carton);
|
||||
Future<List<Carton>> searchCarton(String term);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user