import 'Prefs.dart';


class Unit {
  int id;
  String rangka;
  String mesin;
  String kode;
  String tahun;
  String tipe;
  String warna;
  String state;
  String flag;
  String timestamp;


  Unit({
    this.id,
    this.rangka,
    this.mesin,
    this.kode,
    this.tahun,
    this.tipe,
    this.warna,
    this.state,
    this.flag,
    this.timestamp,
  });

  factory Unit.fromJson(Map<String, dynamic> json) {
    return new Unit(
    id: json[columnName.id],
    rangka: json[columnName.rangka],
    mesin: json[columnName.mesin],
    kode: json[columnName.kode],
    tahun: json[columnName.tahun],
    tipe: json[columnName.tipe],
    warna : json[columnName.warna],
    state: json[columnName.state],
    flag: json[columnName.flag],
    timestamp: json[columnName.timestamp]??''
    );}

  Map<String, dynamic> toJson() => {
    columnName.id: id,
    columnName.rangka: rangka.toUpperCase(),
    columnName.mesin : mesin.toUpperCase(),
    columnName.kode : kode.toUpperCase(),
    columnName.tahun : tahun,
    columnName.tipe: tipe,
    columnName.warna: warna,
    columnName.state :state,
    columnName.flag :flag,
    columnName.timestamp :timestamp,
  };
}

class blobImage {
  int blob_id;
  var blob_file;
  String mesin;
  String lat;
  String long;
  String jenis;
  String no_urut;


  blobImage({
    this.blob_id,
    this.blob_file,
    this.mesin,
    this.lat,
    this.long,
    this.jenis,
    this.no_urut
  });

  Map<String, dynamic> toJson() => {
    columnName.blob_id: blob_id,
    columnName.blob_file : blob_file,
    columnName.mesin : mesin,
    columnName.lat : lat,
    columnName.long : long,
    columnName.jenis : jenis,
    columnName.no_urut : no_urut
  };

  factory blobImage.fromJson(Map<String, dynamic> json) => new blobImage(
    blob_id: json[columnName.blob_id],
    blob_file: json[columnName.blob_file],
    mesin: json[columnName.mesin],
    lat: json[columnName.lat],
    long: json[columnName.long],
    jenis:  json[columnName.jenis],
    no_urut: json[columnName.no_urut]
  );
}

class valueTab {
  String name;
  String value;


  valueTab({
    this.name,
    this.value
  });

  Map<String, dynamic> toJson() => {
    columnName.name : name,
    columnName.value : value,
  };

  factory valueTab.fromJson(Map<String, dynamic> json) => new valueTab(
    name: json[columnName.name],
    value: json[columnName.value],
  );
}

class jenisDrop {
  String value;
  String no_urut;

  jenisDrop({
    this.value,
    this.no_urut
  });

  Map<String, dynamic> toJson() => {
    columnName.value : value,
    columnName.no_urut : no_urut
  };

  factory jenisDrop.fromJson(Map<String, dynamic> json) => new jenisDrop(
    value: json[columnName.value],
    no_urut:  json[columnName.no_urut]
  );
}

class Count {
  int count;
  Count({
    this.count,
  });

  factory Count.fromJson(Map<String, dynamic> json) => new Count(
    count: json["count"],
  );
}
