import 'package:flutter/material.dart';
import 'package:intl/intl.dart';


class DeliveredOrdersModel {
  String tankerName = '';
  String bookingid = '';
  String supplierId = '';
  String dateOfOrder='';
  String typeofwater='';
  String delivery_agent_mobile='';
  String delivery_agent='';
  String capacity='';
  String address='';
  String price='';
  String customerId='';
  String startTime = '';
  String stopTime = '';
  String orderStatus = '';
  String initialWaterLevel = '';
  String finalWaterLevel = '';
  String quantityDelivered = '';
  String amountPaid = '';
  String amountDue = '';
  String paymentMode = '';
  String deliverdWater = '';
  String supplierName = '';
  String deliveredDate = '';
  String displayDeliveredDate = '';
  String displayAddress = '';
  var tankerRunningStatus ;
  double lat=0;
  double lng=0;








  Color cardColor=Colors.white;

  DeliveredOrdersModel();

  factory DeliveredOrdersModel.fromJson(Map<String, dynamic> json){
    DeliveredOrdersModel rtvm = new DeliveredOrdersModel();

    rtvm.tankerName = json['tankerName'] ?? '';
    rtvm.bookingid = json['bookingid'] ?? '';
    rtvm.supplierId = json['supplierId'] ?? '';
    rtvm.dateOfOrder = json['dateOfOrder'] ??'';
    rtvm.typeofwater = json['typeofwater'] ??'';
    rtvm.supplierName = json['supplierName'] ??'';
    rtvm.delivery_agent_mobile = json['delivery_agent_mobile'] ??'';
    rtvm.capacity = json['capacity'] ??'';
    rtvm.address = json['address'] ??'';
    rtvm.price = json['price'] ??'';
    rtvm.orderStatus = json['orderStatus'] ??'';
    rtvm.customerId = json['customerId'] ??'';
    rtvm.startTime = json['start_time'] ??'';
    rtvm.stopTime = json['stop_time'] ??'';
    rtvm.initialWaterLevel = json['initial_water_level'] ??'';
    rtvm.finalWaterLevel = json['final_water_level'] ??'';
    rtvm.quantityDelivered = json['quantityDelivered'] ??'';
    rtvm.amountPaid = json['amount_paid'] ??'';
    rtvm.amountDue = json['amount_due'] ??'';
    rtvm.paymentMode = json['payment_mode'] ??'';
    rtvm.deliverdWater = json['quantityDelivered'] ??'';
    rtvm.deliveredDate = json['deliveredDate'] ??'';
    rtvm.tankerRunningStatus = json['tankerRunningStatus'] ??'';
    rtvm.delivery_agent = json['delivery_agent'] ??'';

    // Step 1: Parse input string into DateTime object
    DateFormat inputFormat = DateFormat("dd-MMM-yyyy - HH:mm");
    DateTime dateTime = inputFormat.parse(rtvm.deliveredDate);

    // Step 2: Format to desired output
    DateFormat outputFormat = DateFormat("MMMM d yyyy, h:mm a");

    rtvm.displayDeliveredDate = outputFormat.format(dateTime);
    List<String> parts = rtvm.address.split(',');
    rtvm.displayAddress = parts[2].trim();

    rtvm.lat = json['latitude'] ??0;
    rtvm.lng = json['longitude'] ??0;
    return rtvm;
  }

}