Merge branch 'zaid_development_new' into majd_development_new
						commit
						798faf51a4
					
				
											
												Binary file not shown.
											
										
									
								| 
		 After Width: | Height: | Size: 4.2 KiB  | 
											
												Binary file not shown.
											
										
									
								| 
		 After Width: | Height: | Size: 8.0 KiB  | 
											
												Binary file not shown.
											
										
									
								| 
		 After Width: | Height: | Size: 21 KiB  | 
@ -0,0 +1,53 @@
 | 
				
			|||||||
 | 
					import 'dart:convert';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import 'package:flutter/cupertino.dart';
 | 
				
			||||||
 | 
					import 'package:flutter/material.dart';
 | 
				
			||||||
 | 
					import 'package:http/http.dart';
 | 
				
			||||||
 | 
					import 'package:test_sa/controllers/api_routes/api_manager.dart';
 | 
				
			||||||
 | 
					import 'package:test_sa/controllers/api_routes/urls.dart';
 | 
				
			||||||
 | 
					import 'package:test_sa/models/service_request/search_work_order.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class VendorProvider extends ChangeNotifier {
 | 
				
			||||||
 | 
					  void reset() {
 | 
				
			||||||
 | 
					    _vendors = null;
 | 
				
			||||||
 | 
					    _loading = null;
 | 
				
			||||||
 | 
					    _stateCode = null;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int _stateCode;
 | 
				
			||||||
 | 
					  int get stateCode => _stateCode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  List<Supplier> _vendors;
 | 
				
			||||||
 | 
					  List<Supplier> get vendors => _vendors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  bool _loading;
 | 
				
			||||||
 | 
					  bool get isLoading => _loading;
 | 
				
			||||||
 | 
					  set isLoading(bool isLoading) {
 | 
				
			||||||
 | 
					    _loading = isLoading;
 | 
				
			||||||
 | 
					    notifyListeners();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Future<int> getVendors(String text) async {
 | 
				
			||||||
 | 
					    if (_loading == true) return -2;
 | 
				
			||||||
 | 
					    _loading = true;
 | 
				
			||||||
 | 
					    notifyListeners();
 | 
				
			||||||
 | 
					    Response response;
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
 | 
					      response = await ApiManager.instance.get("${URLs.getSuppliersAutoComplete}?searchText=$text");
 | 
				
			||||||
 | 
					      _stateCode = response.statusCode;
 | 
				
			||||||
 | 
					      if (response.statusCode >= 200 && response.statusCode < 300) {
 | 
				
			||||||
 | 
					        // client's request was successfully received
 | 
				
			||||||
 | 
					        List suppliersJson = json.decode(response.body)["data"];
 | 
				
			||||||
 | 
					        _vendors = suppliersJson.map((type) => Supplier.fromJson(type)).toList();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      _loading = false;
 | 
				
			||||||
 | 
					      notifyListeners();
 | 
				
			||||||
 | 
					      return response.statusCode;
 | 
				
			||||||
 | 
					    } catch (error) {
 | 
				
			||||||
 | 
					      _loading = false;
 | 
				
			||||||
 | 
					      _stateCode = -1;
 | 
				
			||||||
 | 
					      notifyListeners();
 | 
				
			||||||
 | 
					      return -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,85 @@
 | 
				
			|||||||
 | 
					import 'package:flutter/material.dart';
 | 
				
			||||||
 | 
					import 'package:flutter_typeahead/flutter_typeahead.dart';
 | 
				
			||||||
 | 
					import 'package:provider/provider.dart';
 | 
				
			||||||
 | 
					import 'package:test_sa/models/service_request/search_work_order.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import '../../../controllers/providers/api/status_drop_down/report/vendor_provider.dart';
 | 
				
			||||||
 | 
					import '../../app_style/colors.dart';
 | 
				
			||||||
 | 
					import '../../app_style/sizing.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class AutoGeneratedVendorName extends StatefulWidget {
 | 
				
			||||||
 | 
					  final String initialValue;
 | 
				
			||||||
 | 
					  final Function(Supplier) onSearch;
 | 
				
			||||||
 | 
					  const AutoGeneratedVendorName({Key key, this.initialValue, this.onSearch}) : super(key: key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  State<AutoGeneratedVendorName> createState() => _AutoGeneratedVendorNameState();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class _AutoGeneratedVendorNameState extends State<AutoGeneratedVendorName> {
 | 
				
			||||||
 | 
					  TextEditingController _controller;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  void initState() {
 | 
				
			||||||
 | 
					    super.initState();
 | 
				
			||||||
 | 
					    _controller = TextEditingController(text: widget.initialValue ?? "");
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  void didUpdateWidget(covariant AutoGeneratedVendorName oldWidget) {
 | 
				
			||||||
 | 
					    super.didUpdateWidget(oldWidget);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (oldWidget.initialValue != widget.initialValue) {
 | 
				
			||||||
 | 
					      _controller = TextEditingController(text: widget.initialValue ?? "");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  void dispose() {
 | 
				
			||||||
 | 
					    _controller.dispose();
 | 
				
			||||||
 | 
					    super.dispose();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  Widget build(BuildContext context) {
 | 
				
			||||||
 | 
					    final vendorProvider = Provider.of<VendorProvider>(context, listen: false);
 | 
				
			||||||
 | 
					    return Container(
 | 
				
			||||||
 | 
					      padding: const EdgeInsets.symmetric(horizontal: 16),
 | 
				
			||||||
 | 
					      decoration: BoxDecoration(
 | 
				
			||||||
 | 
					        color: AColors.inputFieldBackgroundColor,
 | 
				
			||||||
 | 
					        border: Border.all(
 | 
				
			||||||
 | 
					          color: const Color(0xffefefef),
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
 | 
					        borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
 | 
				
			||||||
 | 
					        // boxShadow: [
 | 
				
			||||||
 | 
					        //   AppStyle.boxShadow
 | 
				
			||||||
 | 
					        // ]
 | 
				
			||||||
 | 
					      ),
 | 
				
			||||||
 | 
					      child: TypeAheadField<Supplier>(
 | 
				
			||||||
 | 
					        textFieldConfiguration: TextFieldConfiguration(
 | 
				
			||||||
 | 
					          style: Theme.of(context).textTheme.titleLarge,
 | 
				
			||||||
 | 
					          controller: _controller,
 | 
				
			||||||
 | 
					          textAlign: TextAlign.center,
 | 
				
			||||||
 | 
					          decoration: const InputDecoration(
 | 
				
			||||||
 | 
					            hintText: "Vendor Name",
 | 
				
			||||||
 | 
					            border: InputBorder.none,
 | 
				
			||||||
 | 
					            disabledBorder: InputBorder.none,
 | 
				
			||||||
 | 
					            focusedBorder: InputBorder.none,
 | 
				
			||||||
 | 
					            enabledBorder: InputBorder.none,
 | 
				
			||||||
 | 
					          ),
 | 
				
			||||||
 | 
					          textInputAction: TextInputAction.search,
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
 | 
					        suggestionsCallback: (vale) async {
 | 
				
			||||||
 | 
					          await vendorProvider.getVendors(_controller.text.trim());
 | 
				
			||||||
 | 
					          return vendorProvider.vendors;
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        itemBuilder: (context, vendor) {
 | 
				
			||||||
 | 
					          return ListTile(title: Text(vendor.suppliername));
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        onSuggestionSelected: (hospital) {
 | 
				
			||||||
 | 
					          widget.onSearch(hospital);
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					      ),
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,118 @@
 | 
				
			|||||||
 | 
					import 'package:flutter/material.dart';
 | 
				
			||||||
 | 
					import 'package:test_sa/models/service_request/search_work_order.dart';
 | 
				
			||||||
 | 
					import 'package:test_sa/views/app_style/colors.dart';
 | 
				
			||||||
 | 
					import 'package:test_sa/views/app_style/sizing.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class SupplierEngineersMenu extends StatefulWidget {
 | 
				
			||||||
 | 
					  final List<SuppPersons> engineers;
 | 
				
			||||||
 | 
					  final SuppEngineerWorkOrders initialValue;
 | 
				
			||||||
 | 
					  final Function(SuppEngineerWorkOrders) onSelect;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const SupplierEngineersMenu({Key key, this.engineers, this.onSelect, this.initialValue}) : super(key: key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  SingleAssistantEmployeeMenuState createState() => SingleAssistantEmployeeMenuState();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class SingleAssistantEmployeeMenuState extends State<SupplierEngineersMenu> {
 | 
				
			||||||
 | 
					  SuppPersons _selectedEngineer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  void setState(VoidCallback fn) {
 | 
				
			||||||
 | 
					    if (mounted) super.setState(fn);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  void didUpdateWidget(covariant SupplierEngineersMenu oldWidget) {
 | 
				
			||||||
 | 
					    if (widget.initialValue != null) {
 | 
				
			||||||
 | 
					      final result = widget.engineers?.where((element) {
 | 
				
			||||||
 | 
					        return element?.id == widget.initialValue?.supplierContactId;
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
 | 
					      if (result.isNotEmpty) {
 | 
				
			||||||
 | 
					        _selectedEngineer = result.first;
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        _selectedEngineer = null;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      if ((widget.initialValue?.supplierContactId ?? "") != (_selectedEngineer?.id ?? "")) {
 | 
				
			||||||
 | 
					        onSelect(_selectedEngineer);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      _selectedEngineer = null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    super.didUpdateWidget(oldWidget);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  void initState() {
 | 
				
			||||||
 | 
					    if (widget.initialValue != null) {
 | 
				
			||||||
 | 
					      final result = widget.engineers?.where((element) {
 | 
				
			||||||
 | 
					        return element?.id == widget.initialValue?.supplierContactId;
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
 | 
					      if (result.isNotEmpty) _selectedEngineer = result.first;
 | 
				
			||||||
 | 
					      if (widget.initialValue?.supplierContactId != _selectedEngineer?.id) {
 | 
				
			||||||
 | 
					        onSelect(_selectedEngineer);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    super.initState();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  Widget build(BuildContext context) {
 | 
				
			||||||
 | 
					    return Container(
 | 
				
			||||||
 | 
					      padding: const EdgeInsets.symmetric(horizontal: 16),
 | 
				
			||||||
 | 
					      decoration: BoxDecoration(
 | 
				
			||||||
 | 
					        color: AColors.inputFieldBackgroundColor,
 | 
				
			||||||
 | 
					        border: Border.all(
 | 
				
			||||||
 | 
					          color: const Color(0xffefefef),
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
 | 
					        borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
 | 
				
			||||||
 | 
					        // boxShadow: const [
 | 
				
			||||||
 | 
					        //   AppStyle.boxShadow
 | 
				
			||||||
 | 
					        // ]
 | 
				
			||||||
 | 
					      ),
 | 
				
			||||||
 | 
					      child: DropdownButton<SuppPersons>(
 | 
				
			||||||
 | 
					        value: _selectedEngineer,
 | 
				
			||||||
 | 
					        iconSize: 24,
 | 
				
			||||||
 | 
					        icon: const Icon(Icons.keyboard_arrow_down_rounded),
 | 
				
			||||||
 | 
					        elevation: 0,
 | 
				
			||||||
 | 
					        isExpanded: true,
 | 
				
			||||||
 | 
					        hint: Text("Vendor Engineer", style: Theme.of(context).textTheme.titleMedium),
 | 
				
			||||||
 | 
					        style: TextStyle(color: Theme.of(context).primaryColor),
 | 
				
			||||||
 | 
					        underline: const SizedBox.shrink(),
 | 
				
			||||||
 | 
					        onChanged: (SuppPersons newValue) {
 | 
				
			||||||
 | 
					          setState(() {
 | 
				
			||||||
 | 
					            _selectedEngineer = newValue;
 | 
				
			||||||
 | 
					          });
 | 
				
			||||||
 | 
					          onSelect(newValue);
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        items: widget.engineers?.map<DropdownMenuItem<SuppPersons>>((SuppPersons value) {
 | 
				
			||||||
 | 
					          return DropdownMenuItem<SuppPersons>(
 | 
				
			||||||
 | 
					            value: value,
 | 
				
			||||||
 | 
					            child: Text(
 | 
				
			||||||
 | 
					              value?.personName ?? "NULL",
 | 
				
			||||||
 | 
					              style: Theme.of(context).textTheme.titleMedium.copyWith(
 | 
				
			||||||
 | 
					                    color: Theme.of(context).primaryColor,
 | 
				
			||||||
 | 
					                    fontSize: 11,
 | 
				
			||||||
 | 
					                    //fontWeight: FontWeight.bold
 | 
				
			||||||
 | 
					                  ),
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
 | 
					          );
 | 
				
			||||||
 | 
					        })?.toList(),
 | 
				
			||||||
 | 
					      ),
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void onSelect(SuppPersons engineer) {
 | 
				
			||||||
 | 
					    widget.onSelect(
 | 
				
			||||||
 | 
					      SuppEngineerWorkOrders(
 | 
				
			||||||
 | 
					        id: engineer?.supplierId,
 | 
				
			||||||
 | 
					        supplierContactId: engineer?.id,
 | 
				
			||||||
 | 
					        personName: engineer?.personName,
 | 
				
			||||||
 | 
					        contact: engineer?.contact,
 | 
				
			||||||
 | 
					        externalEngCode: engineer?.externalEngCode,
 | 
				
			||||||
 | 
					        email: engineer?.email,
 | 
				
			||||||
 | 
					      ),
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
					Loading…
					
					
				
		Reference in New Issue