/// /// file này dành cho việc download plugin và hiển thị hóa đơn ajax function create(htmlStr) { var frag = document.createDocumentFragment(), temp = document.createElement('div'); temp.innerHTML = htmlStr; while (temp.firstChild) { frag.appendChild(temp.firstChild); } return frag; } $(function () { fragment = create(''); document.body.insertBefore(fragment, document.body.childNodes[0]); }); //hien thi hoa don trong portal function ajxCall4Portal(idInvoice, pattern) { var jsondata = "idInvoice=" + idInvoice + "&pattern=" + pattern; $.ajax({ type: "POST", url: "/Invoice/ajxPreview/", data: jsondata, success: function (data) { if (data.success == true) { $('#container').html(data.str + ""); // them du lieu de hien thi cac button su kien : In + Ký Số + Tai về var btnBar = '
'; // them du lieu de hien thi cac button su kien : In + Ký Số + Tai về if (data.cusType === 1 && data.clientNotSign === true) { btnBar += ""; } btnBar += getToolbarHtml(idInvoice, pattern, data.attachFile, data.fKey, data.status, data.toolbarType); btnBar += '
'; $('#invoice-footer').html(btnBar); var fragment = create('') document.body.insertBefore(fragment, document.body.childNodes[0]); $('#ViewInvoice').modal('show'); $('.VATTEMP .invtable .prds').ProductNumberPagination({ number: data.rowPerData }, data); if (data.status === 3 || data.status === 5) addCanceledMark(); } else { sweetAlert("Thông báo", "Không có quyền xem hóa đơn này", "error"); } }, error: function () { } }); } function addCanceledMark() { $('.VATTEMP').prepend(''); $('#imgCancel').css({ "position": "absolute", "z-index": "3", "width": "790px", "height": "800px" }); } function getToolbarHtml(idInvoice, pattern, attachFile, fKey, status, toolbarType) { if (typeof toolbarType === 'undefined' || toolbarType === null || toolbarType === '') { return buildCommonToolbar(idInvoice, pattern, attachFile, fKey, status); } else if (toolbarType === 'DA_LIEU') { return buildDaLieuToolbar(idInvoice, pattern, attachFile, fKey, status); } } function buildCommonToolbar(idInvoice, pattern, attachFile, fKey, status) { var btnBar = ""; btnBar += ""; //btnBar += getDownloadPDFAndFileAttachButton(attachFile, idInvoice, pattern, fKey); if (status !== -1 && status !== 0) { btnBar += ""; if (status !== 3 && status !== 5) { btnBar += ""; btnBar += ""; btnBar += ''; } } //if (attachFile) { // btnBar += ""; //} btnBar += " "; return btnBar; } function buildDaLieuToolbar(idInvoice, pattern, attachFile, fKey, status) { var btnBar = ""; //btnBar += ""; if (status !== -1 && status !== 0 & status !== 3 && status !== 5) { btnBar += ""; btnBar += ""; btnBar += ''; } btnBar += " "; return btnBar; } function getDownloadPDFAndFileAttachButton(attachFile, idInvoice, pattern, fKey) { var btnDropdown = ''; if (attachFile) { btnDropdown += '
' + ' ' + ' ' + ' ' + '
'; } else { btnDropdown += ""; } return btnDropdown; } //unused function ajxCall4Convert(idInvoice, pattern, str) { var jsondata = { id: idInvoice, patt: pattern }; $.ajax({ type: "POST", url: "/InvConvertion/" + str, data: jsondata, success: function (data) { if (data === "nochange" || data === "nosuccess") { ChangePage(); } else { $("#container").html(data + ""); var fragment = create('') document.body.insertBefore(fragment, document.body.childNodes[0]); $(function () { $("#ViewInvoice").dialog({ modal: true, height: 650, width: 840, close: function (ev, ui) { ChangePage(); } }); $('.VATTEMP .invtable .prds').ProductNumberPagination({ number: 10 }, null); }); } } }); } function downloadCertificate(id, pattern) { document.location.href = "/Invoice/DownloadCertificate?id=" + id + "&pattern=" + pattern; } function downloadAttachFile(invId, pattern, fKey) { document.location.href = "/Invoice/DownloadFileAttach?invId=" + invId + "&pattern=" + pattern + "&fKey=" + fKey; } function downloadXML(invId, pattern) { window.location.href = "/Invoice/DownloadXML?invId=" + invId + "&pattern=" + pattern; } function downloadPdf(invId, pattern, fKey) { document.location.href = "/Invoice/DownloadPdf?id=" + invId + "&pattern=" + pattern + "&fKey=" + fKey; } function downloadPdfAndFileAttach(invId, pattern, fKey) { document.location.href = "/Invoice/DownloadPdfAndFileAttach?id=" + invId + "&pattern=" + pattern + "&fKey=" + fKey; }