{"id":2692,"date":"2019-10-31T17:00:53","date_gmt":"2019-10-31T16:00:53","guid":{"rendered":"https:\/\/eenvoudigfactureren.be\/info\/?page_id=2692"},"modified":"2020-01-02T15:15:56","modified_gmt":"2020-01-02T14:15:56","slug":"gls","status":"publish","type":"page","link":"https:\/\/eenvoudigfactureren.be\/info\/tools\/gls\/","title":{"rendered":"CSV voor GLS"},"content":{"rendered":"<div class=\"wrap-container60 border-bottom reading-text\"><div class=\"container\">\r\n\t\t<p>Genereer CSV-bestand met facturen voor GLS verzendingen. Gelieve aan te melden op uw account alvorens facturen te zoeken en toe te voegen.<\/p>\r\n\r\n\t\t<form onsubmit=\"searchInvoices(); return false;\">\r\n\t\t\t<input type=\"text\" name=\"search\" id=\"search-invoices\" value=\"\" placeholder=\"Zoek facturen...\"\/>\r\n\t\t\t<button type=\"button\" onclick=\"searchInvoices();\">Zoek<\/button>\r\n\t\t<\/form>\r\n\r\n\t\t<form>\r\n\t\t\t<a href=\"data:text\/csv;charset=utf-8,\" id=\"download-csv\" download=\"gls.csv\" onclick=\"downloadCsv();\" class=\"btn\">Download (0)<\/a>\r\n\t\t<\/form>\r\n\r\n\t\t<table id=\"invoice-table\" width=\"100%\">\r\n\t\t\t<thead>\r\n\t\t\t<tr>\r\n\t\t\t\t<th>Nummer<\/th>\r\n\t\t\t\t<th>Datum<\/th>\r\n\t\t\t\t<th>Klant<\/th>\r\n\t\t\t\t<th>Omschrijving<\/th>\r\n\t\t\t\t<th>Bedrag<\/th>\r\n\t\t\t\t<th><\/th>\r\n\t\t\t<\/tr>\r\n\t\t\t<\/thead>\r\n\t\t\t<tbody id=\"invoice-table-content\">\r\n\t\t\t<\/tbody>\r\n\t\t<\/table>\r\n\r\n\t<\/div><\/div>\r\n\r\n<script type=\"application\/javascript\">\r\n\tfunction rebuildTable(invoices) {\r\n\t\tvar contentBlock = document.getElementById('invoice-table-content');\r\n\t\tcontentBlock.innerHTML = '';\r\n\t\tinvoices.forEach(function(invoice) {\r\n\t\t\tvar row = document.createElement(\"TR\");\r\n\r\n\t\t\tvar number = document.createElement('TD');\r\n\t\t\tnumber.innerHTML = invoice.number;\r\n\t\t\trow.appendChild(number);\r\n\r\n\t\t\tvar date = document.createElement('TD');\r\n\t\t\tdate.innerHTML = invoice.date;\r\n\t\t\trow.appendChild(date);\r\n\r\n\t\t\tvar client = document.createElement('TD');\r\n\t\t\tclient.innerHTML = invoice.client_name;\r\n\t\t\trow.appendChild(client);\r\n\r\n\t\t\tvar description = document.createElement('TD');\r\n\t\t\tdescription.innerHTML = invoice.description;\r\n\t\t\trow.appendChild(description);\r\n\r\n\t\t\tvar amount = document.createElement('TD');\r\n\t\t\tamount.innerHTML = invoice.total_with_tax.replace('.', ',') + ' ' + invoice.currency;\r\n\t\t\trow.appendChild(amount);\r\n\r\n\t\t\tvar add = document.createElement('TD');\r\n\t\t\tvar button = document.createElement('BUTTON');\r\n\t\t\tbutton.innerHTML = 'Toevoegen';\r\n\t\t\tbutton.className = 'addInvoice';\r\n\t\t\tbutton.addEventListener('click', function() {\r\n\t\t\t\taddInvoice(invoice);\r\n\t\t\t\tcontentBlock.removeChild(row);\r\n\t\t\t});\r\n\r\n\t\t\tadd.appendChild(button);\r\n\t\t\trow.appendChild(add);\r\n\r\n\t\t\tcontentBlock.appendChild(row);\r\n\t\t});\r\n\t}\r\n\r\n\tfunction getCountryCode(country_code, country) {\r\n\t\tif (country_code) {\r\n\t\t\treturn country_code;\r\n\t\t}\r\n\r\n\t\tvar countryCode = 'BE';\r\n\r\n\t\tif (country.length == 2) {\r\n\t\t\tcountryCode = country.toUpperCase();\r\n\t\t} else {\r\n\t\t\tvar determineCountryCode = country.substring(0, 2).toUpperCase();\r\n\t\t\tif (determineCountryCode == 'NE' || determineCountryCode == 'NL') {\r\n\t\t\t\tcountryCode = 'NL';\r\n\t\t\t}\r\n\t\t\tif (determineCountryCode == 'FR') {\r\n\t\t\t\tcountryCode = 'FR';\r\n\t\t\t}\r\n\t\t\tif (determineCountryCode == 'LU') {\r\n\t\t\t\tcountryCode = 'LU';\r\n\t\t\t}\r\n\t\t\tif (determineCountryCode == 'DE' || determineCountryCode == 'DU') {\r\n\t\t\t\tcountryCode = 'DE';\r\n\t\t\t}\r\n\t\t\tif (determineCountryCode == 'VE' || determineCountryCode == 'GR') {\r\n\t\t\t\tcountryCode = 'GB';\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn countryCode;\r\n\t}\r\n\r\n\tfunction isCashOnDelivery(client) {\r\n\t\tvar cash = false;\r\n\r\n\t\tif (client.details) {\r\n\t\t\tclient.details.forEach(function(detail) {\r\n\t\t\t\tif (detail.name.toUpperCase() === 'REMBOURS' && detail.value !== '0' && detail.value.toUpperCase() !== 'NEE' && detail.value.toUpperCase() !== 'NO' && detail.value !== '') {\r\n\t\t\t\t\tcash = true;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn cash;\r\n\t}\r\n\r\n\tfunction buildCsvRowContent(invoice, client) {\r\n\t\tvar date = invoice.date.replace('-','').replace('-','');\r\n\t\tvar totalPay = '';\r\n\t\tif (isCashOnDelivery(client) && invoice.status=='open') {\r\n\t\t\ttotalPay = invoice.total_with_tax.toString().replace('.', ',');\r\n\t\t}\r\n\r\n\t\tif (client.hasOwnProperty('delivery_address') && client.delivery_address) {\r\n\t\t\treturn invoice.number+';'+client.name+';'+client.attention+';'+client.delivery_address.street+';'+client.delivery_address.postal_code+';'+client.delivery_address.city+';'+getCountryCode(client.delivery_address.country_code, '')+';'+client.phone_number+';'+client.email_address+';1;1;PCO;'+totalPay+';'+invoice.currency;\r\n\t\t} else {\r\n\t\t\treturn invoice.number+';'+client.name+';'+client.attention+';'+client.street+';'+client.postal_code+';'+client.city+';'+getCountryCode(client.country_code, client.country)+';'+client.phone_number+';'+client.email_address+';1;1;PCO;'+totalPay+';'+invoice.currency;\r\n\t\t}\r\n\t}\r\n\r\n\tfunction addInvoiceToCsv(invoice, client) {\r\n\t\tvar download = document.getElementById('download-csv');\r\n\r\n\t\tif (!download.dataset.hasOwnProperty('lines')) {\r\n\t\t\tdownload.dataset.lines = JSON.stringify([]);\r\n\t\t}\r\n\r\n\t\tvar lines = JSON.parse(download.dataset.lines);\r\n\r\n\t\tlines.push(buildCsvRowContent(invoice, client));\r\n\r\n\t\tvar csvContent = \"data:text\/csv;charset=utf-8,\";\r\n\t\tcsvContent += lines.join('\\r\\n');\r\n\r\n\t\tdownload.href = encodeURI(csvContent);\r\n\r\n\t\tdownload.innerHTML = \"Download (\"+lines.length+\")\";\r\n\t\tdownload.dataset.lines = JSON.stringify(lines);\r\n\t}\r\n\r\n\tfunction addInvoice(invoice) {\r\n\t\tvar xhr = new XMLHttpRequest();\r\n\t\txhr.onreadystatechange = function() {\r\n\t\t\tif (xhr.readyState === 4){\r\n\t\t\t\tvar client = JSON.parse(xhr.responseText);\r\n\t\t\t\taddInvoiceToCsv(invoice, client);\r\n\t\t\t}\r\n\t\t};\r\n\t\txhr.open('GET', '\/api\/v1\/clients\/'+invoice.client_id+'?format=json');\r\n\t\txhr.send();\r\n\t}\r\n\r\n\tfunction downloadCsv() {\r\n\t\tvar download = document.getElementById('download-csv');\r\n\r\n\t\tif (!download.dataset.hasOwnProperty('lines')) {\r\n\t\t\talert('Geen selectie');\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar lines = JSON.parse(download.dataset.lines);\r\n\t\tif (lines.length === 0) {\r\n\t\t\talert('Geen selectie');\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t\/\/ var csvContent = \"data:text\/csv;charset=utf-8,\";\r\n\t\t\/\/ csvContent += lines.join(\"\\n\");\r\n\r\n\t\t\/\/ var encodedUri = encodeURI(csvContent);\r\n\t\t\/\/ window.open(encodedUri);\r\n\r\n\t\twindow.setTimeout(function() {\r\n\t\t\tdownload.innerHTML = \"Download (0)\";\r\n\t\t\tdownload.dataset.lines = JSON.stringify([]);\r\n\t\t}, 300);\r\n\t}\r\n\r\n\tfunction searchInvoices() {\r\n\t\tvar search = document.getElementById('search-invoices').value;\r\n\r\n\t\tvar xhr = new XMLHttpRequest();\r\n\t\txhr.onreadystatechange = function() {\r\n\t\t\tif (xhr.readyState === 4){\r\n\t\t\t\trebuildTable(JSON.parse(xhr.responseText));\r\n\t\t\t}\r\n\t\t};\r\n\t\txhr.open('GET', '\/api\/v1\/invoices?format=json&limit=50&sort=-date%2B-number&fields=number,client_id,client_name,date,status,description,total_with_tax,currency&search='+encodeURI(search));\r\n\t\txhr.send();\r\n\t}\r\n\r\n\tsearchInvoices();\r\n<\/script>\r\n","protected":false},"excerpt":{"rendered":"Genereer CSV-bestand met facturen voor GLS verzendingen. Gelieve aan te melden op uw account alvorens facturen te zoeken en toe te voegen. Zoek Download (0) Nummer Datum Klant Omschrijving Bedrag","protected":false},"author":1,"featured_media":0,"parent":446,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"footnotes":""},"class_list":["post-2692","page","type-page","status-publish","hentry","no-wpautop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>CSV voor GLS<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/eenvoudigfactureren.be\/info\/tools\/gls\/\" \/>\n<meta property=\"og:locale\" content=\"nl_BE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CSV voor GLS\" \/>\n<meta property=\"og:description\" content=\"Genereer CSV-bestand met facturen voor GLS verzendingen. Gelieve aan te melden op uw account alvorens facturen te zoeken en toe te voegen. Zoek Download (0) Nummer Datum Klant Omschrijving Bedrag\" \/>\n<meta property=\"og:url\" content=\"https:\/\/eenvoudigfactureren.be\/info\/tools\/gls\/\" \/>\n<meta property=\"og:site_name\" content=\"EenvoudigFactureren\" \/>\n<meta property=\"article:modified_time\" content=\"2020-01-02T14:15:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/eenvoudigfactureren.be\/info\/wp-content\/uploads\/2021\/09\/Logo-EenvoudigFactureren.png\" \/>\n\t<meta property=\"og:image:width\" content=\"500\" \/>\n\t<meta property=\"og:image:height\" content=\"222\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/eenvoudigfactureren.be\/info\/tools\/gls\/\",\"url\":\"https:\/\/eenvoudigfactureren.be\/info\/tools\/gls\/\",\"name\":\"CSV voor GLS\",\"isPartOf\":{\"@id\":\"https:\/\/eenvoudigfactureren.be\/info\/#website\"},\"datePublished\":\"2019-10-31T16:00:53+00:00\",\"dateModified\":\"2020-01-02T14:15:56+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/eenvoudigfactureren.be\/info\/tools\/gls\/#breadcrumb\"},\"inLanguage\":\"nl-BE\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/eenvoudigfactureren.be\/info\/tools\/gls\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/eenvoudigfactureren.be\/info\/tools\/gls\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/eenvoudigfactureren.be\/info\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tools\",\"item\":\"https:\/\/eenvoudigfactureren.be\/info\/tools\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"CSV voor GLS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/eenvoudigfactureren.be\/info\/#website\",\"url\":\"https:\/\/eenvoudigfactureren.be\/info\/\",\"name\":\"EenvoudigFactureren\",\"description\":\"Online facturatie\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/eenvoudigfactureren.be\/info\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"nl-BE\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CSV voor GLS","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/eenvoudigfactureren.be\/info\/tools\/gls\/","og_locale":"nl_BE","og_type":"article","og_title":"CSV voor GLS","og_description":"Genereer CSV-bestand met facturen voor GLS verzendingen. Gelieve aan te melden op uw account alvorens facturen te zoeken en toe te voegen. Zoek Download (0) Nummer Datum Klant Omschrijving Bedrag","og_url":"https:\/\/eenvoudigfactureren.be\/info\/tools\/gls\/","og_site_name":"EenvoudigFactureren","article_modified_time":"2020-01-02T14:15:56+00:00","og_image":[{"width":500,"height":222,"url":"https:\/\/eenvoudigfactureren.be\/info\/wp-content\/uploads\/2021\/09\/Logo-EenvoudigFactureren.png","type":"image\/png"}],"twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/eenvoudigfactureren.be\/info\/tools\/gls\/","url":"https:\/\/eenvoudigfactureren.be\/info\/tools\/gls\/","name":"CSV voor GLS","isPartOf":{"@id":"https:\/\/eenvoudigfactureren.be\/info\/#website"},"datePublished":"2019-10-31T16:00:53+00:00","dateModified":"2020-01-02T14:15:56+00:00","breadcrumb":{"@id":"https:\/\/eenvoudigfactureren.be\/info\/tools\/gls\/#breadcrumb"},"inLanguage":"nl-BE","potentialAction":[{"@type":"ReadAction","target":["https:\/\/eenvoudigfactureren.be\/info\/tools\/gls\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/eenvoudigfactureren.be\/info\/tools\/gls\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/eenvoudigfactureren.be\/info\/"},{"@type":"ListItem","position":2,"name":"Tools","item":"https:\/\/eenvoudigfactureren.be\/info\/tools\/"},{"@type":"ListItem","position":3,"name":"CSV voor GLS"}]},{"@type":"WebSite","@id":"https:\/\/eenvoudigfactureren.be\/info\/#website","url":"https:\/\/eenvoudigfactureren.be\/info\/","name":"EenvoudigFactureren","description":"Online facturatie","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/eenvoudigfactureren.be\/info\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"nl-BE"}]}},"_links":{"self":[{"href":"https:\/\/eenvoudigfactureren.be\/info\/wp-json\/wp\/v2\/pages\/2692","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eenvoudigfactureren.be\/info\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/eenvoudigfactureren.be\/info\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/eenvoudigfactureren.be\/info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eenvoudigfactureren.be\/info\/wp-json\/wp\/v2\/comments?post=2692"}],"version-history":[{"count":7,"href":"https:\/\/eenvoudigfactureren.be\/info\/wp-json\/wp\/v2\/pages\/2692\/revisions"}],"predecessor-version":[{"id":2865,"href":"https:\/\/eenvoudigfactureren.be\/info\/wp-json\/wp\/v2\/pages\/2692\/revisions\/2865"}],"up":[{"embeddable":true,"href":"https:\/\/eenvoudigfactureren.be\/info\/wp-json\/wp\/v2\/pages\/446"}],"wp:attachment":[{"href":"https:\/\/eenvoudigfactureren.be\/info\/wp-json\/wp\/v2\/media?parent=2692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}