/*
Copyright DHTMLX LTD. http://www.dhtmlx.com
*/
scheduler.toPDF=function(url,mode,header,footer){
var dx = 0;
var dy = 0;
mode = mode||"color";
function x_norm(x) {
x = parseFloat(x);
if (isNaN(x)) return "auto";
return 100 * x / dx;
}
function y_norm(y) {
y = parseFloat(y);
if (isNaN(y)) return "auto";
return 100 * y / dy;
}
function xml_month_scale(xh){
var xml="";
for (var i = 0; i < xh.length; i++)
xml += "\n";
dx = xh[0].offsetWidth;
return xml;
}
function de_day(node,n){
var x = parseInt(node.style.left);
for (var dx=0; dx < scheduler._cols.length; dx++){
x-=scheduler._cols[dx];
if (x<0) return dx;
}
return n;
}
function de_week(node,n){
var y = parseInt(node.style.top);
for (var dy=0; dy < scheduler._colsS.heights.length; dy++)
if (scheduler._colsS.heights[dy]>y) return dy;
return n;
}
function xml_month(yh){
var xml="";
var r = yh.firstChild.rows;
for (var i = 0; i < r.length; i++) {
var days = [];
for (var j = 0; j < r[i].cells.length; j++){
/* var dd = r[i].cells[j];
var css = dd.className;
if (css!=" " && css!="dhx_now ")
days.push("");
else*/
days.push(r[i].cells[j].firstChild.innerHTML);
}
xml += "\n" + days.join("|") + "
";
dy = yh.firstChild.rows[0].cells[0].offsetHeight;
}
return xml;
}
function xml_top(profile) {
var xml = "";
xml += "";
if (scheduler._mode == "agenda"){
var xh = scheduler._els.dhx_cal_header[0].childNodes[0].childNodes;
xml+=""+xh[0].innerHTML+""+xh[1].innerHTML+""
} else if (scheduler._mode == "year"){
var xh = scheduler._els.dhx_cal_data[0].childNodes;
for (var i=0; i < xh.length; i++) {
xml+="";
xml+=xml_month_scale(xh[i].childNodes[1].childNodes);
xml+=xml_month(xh[i].childNodes[2]);
xml+="";
};
} else {
xml += "";
var xh = scheduler._els.dhx_cal_header[0].childNodes;
xml+=xml_month_scale(xh);
xml += "";
var yh = scheduler._els.dhx_cal_data[0];
if (yh.firstChild.tagName == "TABLE") {
xml += xml_month(yh);
} else {
yh = yh.childNodes[yh.childNodes.length - 1];
if (yh.className.indexOf("dhx_cal_event") != -1)
yh = yh.previousSibling;
yh = yh.childNodes;
xml += "";
for (var i = 0; i < yh.length; i++)
xml += "\n
";
xml += "";
dy = yh[0].offsetHeight;
}
}
xml += "";
return xml;
}
function xml_body() {
var xml = "";
var evs = scheduler._rendered;
if (scheduler._mode == "agenda"){
for (var i=0; i < evs.length; i++)
xml+=""+evs[i].childNodes[0].innerHTML+""+evs[i].childNodes[2].innerHTML+"";
} else if (scheduler._mode == "year"){
var evs = scheduler.get_visible_events();
for (var i=0; i < evs.length; i++) {
var d = evs[i].start_date;
if (d.valueOf()";
scheduler._mark_year_date(d);
d = scheduler.date.add(d,1,"day");
if (d.valueOf()>=scheduler._max_date.valueOf())
break;
}
}
} else {
for (var i = 0; i < evs.length; i++) {
var zx = x_norm(evs[i].style.left);
var zy = y_norm(evs[i].style.top);
var zdx = x_norm(evs[i].style.width);
var zdy = y_norm(evs[i].style.height);
var e_type = evs[i].className.split(" ")[0].replace("dhx_cal_", "");
var dets = scheduler.getEvent(evs[i].getAttribute("event_id"))
var day = dets._sday;
var week = dets._sweek;
if (scheduler._mode != "month") {
if (parseInt(evs[i].style.left) <= 26) {
zx = 2;
zdx += x_norm(evs[i].style.left)-1;
}
if (evs[i].parentNode == scheduler._els.dhx_cal_data[0]) continue;
zx += x_norm(evs[i].parentNode.style.left);
zx -= x_norm(51);
} else {
zdy = parseInt(evs[i].offsetHeight);
zy = parseInt(evs[i].style.top) - 22;
day = de_day(evs[i],day);
week = de_week(evs[i],week);
}
xml += "\n";
if (e_type == "event") {
xml += "";
var color = window.getComputedStyle ? (window.getComputedStyle(evs[i].childNodes[2], null)["backgroundColor"]) : (evs[i].childNodes[2].currentStyle["backgroundColor"]);
xml += "";
} else {
var color = window.getComputedStyle ? (window.getComputedStyle(evs[i], null)["backgroundColor"]) : (evs[i].currentStyle["backgroundColor"]);
xml += "";
}
xml += "";
}
}
return xml;
}
function xml_end(){
var xml = "";
return xml;
}
var win = window.open("", "_blank");
win.document.open();
win.document.write("
");
win.document.write('');
// as long dash in post converts to some special symbols we need to convert it to simple dash by replacing using unicode \u2013
win.document.getElementById("mycoolxmlbody").value = xml_top(mode).replace("\u2013", "-") + xml_body() + xml_end();
win.document.write("");
win.document.getElementById("mycollformname").submit();
win.document.close();
}