{"id":2836,"date":"2019-12-20T17:56:08","date_gmt":"2019-12-20T16:56:08","guid":{"rendered":"https:\/\/eenvoudigfactureren.be\/info\/?page_id=2836"},"modified":"2019-12-23T09:31:17","modified_gmt":"2019-12-23T08:31:17","slug":"bpost-diberget","status":"publish","type":"page","link":"https:\/\/eenvoudigfactureren.be\/info\/tools\/bpost-diberget\/","title":{"rendered":"BPost Diberget"},"content":{"rendered":"<div class=\"wrap-container60 border-bottom reading-text\"><div class=\"container\">\r\n        <p>Print BPost labels Diberget.<\/p>\r\n\r\n        <form onsubmit=\"searchInvoices(); return false;\">\r\n            <input type=\"text\" name=\"search\" id=\"search-invoices\" value=\"\" placeholder=\"Zoek facturen...\"\/>\r\n            <button type=\"button\" onclick=\"searchInvoices();\">Zoek<\/button>\r\n        <\/form>\r\n\r\n        <table id=\"invoice-table\" width=\"100%\">\r\n            <thead>\r\n            <tr>\r\n                <th>Nummer<\/th>\r\n                <th>Datum<\/th>\r\n                <th>Klant<\/th>\r\n                <th>Omschrijving<\/th>\r\n                <th>Bedrag<\/th>\r\n                <th><\/th>\r\n            <\/tr>\r\n            <\/thead>\r\n            <tbody id=\"invoice-table-content\">\r\n            <\/tbody>\r\n        <\/table>\r\n\r\n<\/div><\/div>\r\n\r\n<script type=\"application\/javascript\">\r\n\r\n    function rebuildTable(invoices) {\r\n        var contentBlock = document.getElementById('invoice-table-content');\r\n        contentBlock.innerHTML = '';\r\n        invoices.forEach(function(invoice) {\r\n            var row = document.createElement(\"TR\");\r\n\r\n            var number = document.createElement('TD');\r\n            number.innerHTML = invoice.number;\r\n            row.appendChild(number);\r\n\r\n            var date = document.createElement('TD');\r\n            date.innerHTML = invoice.date;\r\n            row.appendChild(date);\r\n\r\n            var client = document.createElement('TD');\r\n            client.innerHTML = invoice.client_name;\r\n            row.appendChild(client);\r\n\r\n            var description = document.createElement('TD');\r\n            description.innerHTML = invoice.description;\r\n            row.appendChild(description);\r\n\r\n            var amount = document.createElement('TD');\r\n            amount.innerHTML = invoice.total_with_tax.replace('.', ',') + ' ' + invoice.currency;\r\n            row.appendChild(amount);\r\n\r\n            var add = document.createElement('TD');\r\n            var button = document.createElement('BUTTON');\r\n            button.innerHTML = 'Print';\r\n            button.className = 'printInvoice';\r\n            button.addEventListener('click', function() {\r\n                printInvoice(invoice);\r\n            });\r\n\r\n            add.appendChild(button);\r\n            row.appendChild(add);\r\n\r\n            contentBlock.appendChild(row);\r\n        });\r\n    }\r\n\r\n    function searchInvoices() {\r\n        var search = document.getElementById('search-invoices').value;\r\n\r\n        var xhr = new XMLHttpRequest();\r\n        xhr.onreadystatechange = function() {\r\n            if (xhr.readyState === 4){\r\n                rebuildTable(JSON.parse(xhr.responseText));\r\n            }\r\n        };\r\n        xhr.open('GET', '\/api\/v1\/invoices?format=json&take=20&sort=-date%2B-number&fields=number,client_id,client_name,date,description,total_with_tax,currency&search='+encodeURI(search));\r\n        xhr.send();\r\n    }\r\n\r\n    function getClient(client_id, callback) {\r\n        var xhr = new XMLHttpRequest();\r\n        xhr.onreadystatechange = function() {\r\n            if (xhr.readyState === 4){\r\n                callback(JSON.parse(xhr.responseText));\r\n            }\r\n        };\r\n        xhr.open('GET', '\/api\/v1\/clients\/'+client_id+'?format=json');\r\n        xhr.send();\r\n    }\r\n\r\n    function printInvoice(invoice) {\r\n        var type = 'Business';\r\n        if (invoice.total_with_tax > 1000) {\r\n            type = 'Express';\r\n        } else {\r\n            if (window.confirm('Express verzenden? Klik OK om express te verzenden.')) {\r\n                type = 'Express';\r\n            }\r\n        }\r\n\r\n        getClient(invoice.client_id, function(client) {\r\n            var shipping = (client.hasOwnProperty('delivery_address') && window.confirm('Alternatief verzendadres gedetecteerd. Alternatief verzendadres printen?'));\r\n\r\n            var url = buildPrintUrl(client, type, shipping);\r\n            window.open(url);\r\n        });\r\n    }\r\n\r\n    function buildPrintUrl(client, type, shipping) {\r\n        var firstname = client.name;\r\n        var street = client.street;\r\n        if (shipping) {\r\n            street = client.delivery_address.street;\r\n        }\r\n        var zip = client.postal_code;\r\n        if (shipping) {\r\n            zip = client.delivery_address.postal_code;\r\n        }\r\n        var city = client.city;\r\n        if (shipping) {\r\n            city = client.delivery_address.city;\r\n        }\r\n        var country = client.country_code;\r\n        if (!country) {\r\n            country = client.country;\r\n        }\r\n        if (shipping) {\r\n            country = client.delivery_address.country_code;\r\n        }\r\n        var phone = client.phone_number;\r\n\r\n        var url = 'http:\/\/webshop.diberget.be\/bpost?method=int' + type + '&firstname='+ encodeURI(firstname) + '&lastname= &street=' + encodeURI(street) + '&zip=' + encodeURI(zip) + '&country=' + encodeURI(country) + '&phone=' + encodeURI(phone) + '&city=' + encodeURI(city);\r\n\r\n        return url;\r\n    }\r\n\r\n    searchInvoices();\r\n\r\n<\/script>\r\n","protected":false},"excerpt":{"rendered":"Print BPost labels Diberget. Zoek 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-2836","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>BPost Diberget<\/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\/bpost-diberget\/\" \/>\n<meta property=\"og:locale\" content=\"nl_BE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"BPost Diberget\" \/>\n<meta property=\"og:description\" content=\"Print BPost labels Diberget. Zoek Nummer Datum Klant Omschrijving Bedrag\" \/>\n<meta property=\"og:url\" content=\"https:\/\/eenvoudigfactureren.be\/info\/tools\/bpost-diberget\/\" \/>\n<meta property=\"og:site_name\" content=\"EenvoudigFactureren\" \/>\n<meta property=\"article:modified_time\" content=\"2019-12-23T08:31:17+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\/bpost-diberget\/\",\"url\":\"https:\/\/eenvoudigfactureren.be\/info\/tools\/bpost-diberget\/\",\"name\":\"BPost Diberget\",\"isPartOf\":{\"@id\":\"https:\/\/eenvoudigfactureren.be\/info\/#website\"},\"datePublished\":\"2019-12-20T16:56:08+00:00\",\"dateModified\":\"2019-12-23T08:31:17+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/eenvoudigfactureren.be\/info\/tools\/bpost-diberget\/#breadcrumb\"},\"inLanguage\":\"nl-BE\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/eenvoudigfactureren.be\/info\/tools\/bpost-diberget\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/eenvoudigfactureren.be\/info\/tools\/bpost-diberget\/#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\":\"BPost Diberget\"}]},{\"@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":"BPost Diberget","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\/bpost-diberget\/","og_locale":"nl_BE","og_type":"article","og_title":"BPost Diberget","og_description":"Print BPost labels Diberget. Zoek Nummer Datum Klant Omschrijving Bedrag","og_url":"https:\/\/eenvoudigfactureren.be\/info\/tools\/bpost-diberget\/","og_site_name":"EenvoudigFactureren","article_modified_time":"2019-12-23T08:31:17+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\/bpost-diberget\/","url":"https:\/\/eenvoudigfactureren.be\/info\/tools\/bpost-diberget\/","name":"BPost Diberget","isPartOf":{"@id":"https:\/\/eenvoudigfactureren.be\/info\/#website"},"datePublished":"2019-12-20T16:56:08+00:00","dateModified":"2019-12-23T08:31:17+00:00","breadcrumb":{"@id":"https:\/\/eenvoudigfactureren.be\/info\/tools\/bpost-diberget\/#breadcrumb"},"inLanguage":"nl-BE","potentialAction":[{"@type":"ReadAction","target":["https:\/\/eenvoudigfactureren.be\/info\/tools\/bpost-diberget\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/eenvoudigfactureren.be\/info\/tools\/bpost-diberget\/#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":"BPost Diberget"}]},{"@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\/2836","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=2836"}],"version-history":[{"count":9,"href":"https:\/\/eenvoudigfactureren.be\/info\/wp-json\/wp\/v2\/pages\/2836\/revisions"}],"predecessor-version":[{"id":2849,"href":"https:\/\/eenvoudigfactureren.be\/info\/wp-json\/wp\/v2\/pages\/2836\/revisions\/2849"}],"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=2836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}