import ATable from '/js/libs/js-ATable.js'
import AListBox from '/js/libs/js-AListBox.js'
import AButton from '/js/libs/js-AButton.js'

window.L2001 = function () {
	var bts = new AButton();
	var tb = new ATable(document.querySelector(".c-table"));
	tb.AddHeader("ID Task", "80px", "20%", "idComodity");
	tb.AddHeader("Name", "220px", "40%", "Name");
	tb.AddHeader("Fix Error", "80px", "20%", "FixError");
	tb.AddHeader("Status", "80px", "20%", "Status");
	tb.IsCheckBox(true);
	var data = [
		{
			"idComodity": 1,
			"Name": "CONSOL",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 2,
			"Name": "CONSOLOZ 736",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 3,
			"Name": "FRESH FRUITS",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 4,
			"Name": "YOUNG PLANTS",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 5,
			"Name": "LIVE DOG",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 6,
			"Name": "ELASTIC TAPE",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 7,
			"Name": "FROZEN SEAFOOD",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 8,
			"Name": "LIVE CRABS",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 9,
			"Name": "CERAMIC TEETH",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 10,
			"Name": "LIVE SEAFOOD",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 11,
			"Name": "LIVE LOBSTER",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 12,
			"Name": "LIVE CRAB",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 13,
			"Name": "GARMENT",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 14,
			"Name": "CLOTHES BAGS",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 15,
			"Name": "DOCUMENT",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 16,
			"Name": "LIVE TROPICAL FISH",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 17,
			"Name": "DOCUMENT AND SAMPLE",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 18,
			"Name": "GLASS GARMENT",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 19,
			"Name": "RAW MATERIAL S",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 20,
			"Name": "AIRWAY BILL",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 21,
			"Name": "CONCRETE PUMPING PAR",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 22,
			"Name": "FRESH FRUIT",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 23,
			"Name": "UN1866 RESIN SOLUTIO",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 24,
			"Name": "CAPITAL EQUIPMENT",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 25,
			"Name": "FRESH FLOWER",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 26,
			"Name": "JEWELRY",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 27,
			"Name": "96259004",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 28,
			"Name": "KAMS COURIER",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 29,
			"Name": "FRESH MANGO",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 30,
			"Name": "FABRIC FACEMASK",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 31,
			"Name": "DECORATIVE",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 32,
			"Name": "POSTAL MAIL",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 33,
			"Name": "FROZEN SEAFOODS",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 34,
			"Name": "CYLINDER",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 35,
			"Name": "CONSOLBR 392",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 36,
			"Name": "FRESH APPLE",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 37,
			"Name": "STELL TUBE",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 38,
			"Name": "DRY FOOD",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 39,
			"Name": "ACCESSOR Y OF GARMENT",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 40,
			"Name": "GRESH FRUITS",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 41,
			"Name": "CLOTHING",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 42,
			"Name": "HAKOIRI COILE",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 43,
			"Name": "TANSHIKA NAGU",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 44,
			"Name": "VEGETABL E SEEDS TOMA",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 45,
			"Name": "RETAIL BAG",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 46,
			"Name": "FURNITURE",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 47,
			"Name": "FRESH FLOWERS",
			"FixError": null,
			"Status": -1
		},
		{
			"idComodity": 48,
			"Name": "PERSONAL EFFECTS",
			"FixError": null,
			"Status": -1
		}
	];
	tb.absPaging.SetPaging(data.length, 5);
	tb.absPaging.on("PagingChange", (e) => {
		tb.LoadData(data.slice((e.activePage - 1) * e.pageSize, ((e.activePage - 1) * e.pageSize) + e.pageSize));
	});
	tb.LoadData(data.slice((tb.absPaging.activePage - 1) * tb.absPaging.pageSize, tb.absPaging.pageSize));

	var lb = new AListBox(document.querySelector(".listBoxComodity"));
	lb.AddHeader("", "60px", "1%", "Action", (a, b) => {
		var b = document.createElement("button");
		b.classList.add("btn", "btn-effect", "btn-primary", "waves-effect", "waves-float");
		b.setAttribute("id", "btn_" + a);
		b.setAttribute("group-name", "btn_list");
		b.innerHTML = "+";
		bts.AddEventBtn(b);
		return b;
	});
	lb.AddHeader("Name", "220px", "80%", "Name");
	lb.SetScrollBarY(300);
	lb.LoadData(data.slice(0, 40));
	bts.on("click_btn_list", (e) => {
		console.log(e.getAttribute("id"));

		bts.RemoveLoading(e);
	})
	window.tableH = tb;

}
window.AScript.set("2001", true);