This commit is contained in:
2024-04-27 09:23:34 +02:00
commit 11e713ca6f
11884 changed files with 3263371 additions and 0 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
!function($){$.extend({metadata:{defaults:{type:"class",name:"metadata",cre:/(\{.*\})/,single:"metadata"},setType:function(t,e){this.defaults.type=t,this.defaults.name=e},get:function(elem,opts){var data,m,e,attr,settings=$.extend({},this.defaults,opts);if(settings.single.length||(settings.single="metadata"),data=$.data(elem,settings.single),data)return data;if(data="{}","class"===settings.type)m=settings.cre.exec(elem.className),m&&(data=m[1]);else if("elem"===settings.type){if(!elem.getElementsByTagName)return;e=elem.getElementsByTagName(settings.name),e.length&&(data=$.trim(e[0].innerHTML))}else void 0!==elem.getAttribute&&(attr=elem.getAttribute(settings.name),attr&&(data=attr));return data.indexOf("{")<0&&(data="{"+data+"}"),data=eval("("+data+")"),$.data(elem,settings.single,data),data}}}),$.fn.metadata=function(t){return $.metadata.get(this[0],t)}}(jQuery);return jQuery;}));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,11 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: Extract out date - updated 10/26/2014 (v2.18.0) */
!function(e){"use strict";var a=/[A-Z]{3,10}\.?\s+\d{1,2},?\s+(?:\d{4})(?:\s+\d{1,2}:\d{2}(?::\d{2})?(?:\s+[AP]M)?)?/i,n=/(\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/i,i=/(\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/i,s=/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/,d=/(\d{4}[\/\s]\d{1,2}[\/\s]\d{1,2}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/i,c=/(\d{4})[\/\s](\d{1,2})[\/\s](\d{1,2})/;
/*! extract US Long Date */e.tablesorter.addParser({id:"extractUSLongDate",is:function(){return!1},format:function(e){var t,r=e?e.match(a):e;return r&&(t=new Date(r[0]))instanceof Date&&isFinite(t)?t.getTime():e},type:"numeric"}),
/*! extract MMDDYYYY */
e.tablesorter.addParser({id:"extractMMDDYYYY",is:function(){return!1},format:function(e){var t,r=e?e.replace(/\s+/g," ").replace(/[\-.,]/g,"/").match(n):e;return r&&(t=new Date(r[0]))instanceof Date&&isFinite(t)?t.getTime():e},type:"numeric"}),
/*! extract DDMMYYYY */
e.tablesorter.addParser({id:"extractDDMMYYYY",is:function(){return!1},format:function(e){var t,r=e?e.replace(/\s+/g," ").replace(/[\-.,]/g,"/").match(i):e;return r&&(t=new Date(r[0].replace(s,"$2/$1/$3")))instanceof Date&&isFinite(t)?t.getTime():e},type:"numeric"}),
/*! extract YYYYMMDD */
e.tablesorter.addParser({id:"extractYYYYMMDD",is:function(){return!1},format:function(e){var t,r=e?e.replace(/\s+/g," ").replace(/[\-.,]/g,"/").match(d):e;return r&&(t=new Date(r[0].replace(c,"$2/$3/$1")))instanceof Date&&isFinite(t)?t.getTime():e},type:"numeric"})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: ISO-8601 date - updated 10/26/2014 (v2.18.0) */
!function(e){"use strict";var s=/^([0-9]{4})(-([0-9]{2})(-([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?$/;e.tablesorter.addParser({id:"iso8601date",is:function(e){return!!e&&e.match(s)},format:function(e){var t=e?e.match(s):e;if(t){var r=new Date(t[1],0,1);return t[3]&&r.setMonth(t[3]-1),t[5]&&r.setDate(t[5]),t[7]&&r.setHours(t[7]),t[8]&&r.setMinutes(t[8]),t[10]&&r.setSeconds(t[10]),t[12]&&r.setMilliseconds(1e3*Number("0."+t[12])),r.getTime()}return e},type:"numeric"})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: Month - updated 11/22/2015 (v2.24.6) */
!function(){"use strict";var c=jQuery.tablesorter;c.dates||(c.dates={}),c.dates.months||(c.dates.months={}),c.dates.months.en={1:"Jan",2:"Feb",3:"Mar",4:"Apr",5:"May",6:"Jun",7:"Jul",8:"Aug",9:"Sep",10:"Oct",11:"Nov",12:"Dec"},c.addParser({id:"month",is:function(){return!1},format:function(e,t,n,a){if(e){var r,o,s=t.config,i=s.globalize&&(s.globalize[a]||s.globalize)||{},u=c.dates.months[i.lang||"en"];for(o in s.ignoreCase&&(e=e.toLowerCase()),u)if("string"==typeof o&&(r=u[o],s.ignoreCase&&(r=r.toLowerCase()),e.match(r)))return parseInt(o,10)}return e},type:"numeric"})}();return jQuery;}));

View File

@@ -0,0 +1,11 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: date ranges -updated 11/22/2015 (v2.24.6) */
!function(e){"use strict";var u,f=e.tablesorter,i=/(\d{1,2}[-\s]\d{1,2}[-\s]\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/gi,d=/(\d{1,2}[-\s]\d{1,2}[-\s]\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/gi,o=/(\d{1,2})[-\s](\d{1,2})[-\s](\d{4})/,c=/(\d{4}[-\s]\d{1,2}[-\s]\d{1,2}(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?)/gi,g=/(\d{4})[-\s](\d{1,2})[-\s](\d{1,2})/,l=/(\d{1,2}\s+\w+\s+\d{4}(\s+\d{1,2}:\d{2}(:\d{2})?(\s\w+)?)?)/g,p=/(\d{1,2})\s+(\w+)\s+(\d{4})/;
/*! date-range MMDDYYYY */e.tablesorter.addParser({id:"date-range-mdy",is:function(){return!1},format:function(e){var t,r,a,n,s=[];if(n=(r=e.replace(/\s+/g," ").replace(/[\/\-.,]/g,"-").match(i))&&r.length){for(a=0;a<n;a++)t=new Date(r[a]),s.push(t instanceof Date&&isFinite(t)?t.getTime():r[a]);return s.sort().join(" - ")}return e},type:"text"}),
/*! date-range DDMMYYYY */
e.tablesorter.addParser({id:"date-range-dmy",is:function(){return!1},format:function(e){var t,r,a,n,s=[];if(n=(r=e.replace(/\s+/g," ").replace(/[\/\-.,]/g,"-").match(d))&&r.length){for(a=0;a<n;a++)t=new Date((""+r[a]).replace(o,"$2/$1/$3")),s.push(t instanceof Date&&isFinite(t)?t.getTime():r[a]);return s.sort().join(" - ")}return e},type:"text"}),
/*! date-range DDMMYYYY */
e.tablesorter.addParser({id:"date-range-ymd",is:function(){return!1},format:function(e){var t,r,a,n,s=[];if(n=(r=e.replace(/\s+/g," ").replace(/[\/\-.,]/g,"-").match(c))&&r.length){for(a=0;a<n;a++)t=new Date((""+r[a]).replace(g,"$2/$3/$1")),s.push(t instanceof Date&&isFinite(t)?t.getTime():r[a]);return s.sort().join(" - ")}return e},type:"text"}),f.dates||(f.dates={}),f.dates.months||(f.dates.months={}),f.dates.months.en={1:"Jan",2:"Feb",3:"Mar",4:"Apr",5:"May",6:"Jun",7:"Jul",8:"Aug",9:"Sep",10:"Oct",11:"Nov",12:"Dec"},u=function(e,t,r){var a,n,s=t.globalize&&(t.globalize[r]||t.globalize)||{},i=f.dates.months[s.lang||"en"];for(n in t.ignoreCase&&(e=e.toLowerCase()),i)if("string"==typeof n&&(a=i[n],t.ignoreCase&&(a=a.toLowerCase()),e.match(a)))return parseInt(n,10);return e},
/*! date-range "dd MMM yyyy - dd MMM yyyy" */
f.addParser({id:"date-range-dMMMyyyy",is:function(){return!1},format:function(e,t,r,a){var n,s,i,d,o=[],c=e.replace(/\s+/g," ").match(l),g=c&&c.length;if(g){for(d=0;d<g;d++)n="",(i=c[d].match(p))&&4<=i.length&&(i.shift(),s=u(i[1],t.config,a),isNaN(s)||(c[d]=c[d].replace(i[1],s)),n=new Date((""+c[d]).replace(f.regex.shortDateXXY,"$3/$2/$1"))),o.push(n instanceof Date&&isFinite(n)?n.getTime():c[d]);return o.sort().join(" - ")}return e},type:"text"})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: two digit year - updated 11/26/2016 (v2.28.0) */
!function(e){"use strict";var r=e.tablesorter,u=(new Date).getFullYear();r.defaults.dataRange="",r.dates||(r.dates={}),r.dates.regxxxxyy=/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{2})/,r.dates.regyyxxxx=/(\d{2})[\/\s](\d{1,2})[\/\s](\d{1,2})/,r.formatDate=function(e,t,r,a){if(e){var n,d,s=e.replace(/\s+/g," ").replace(/[-.,]/g,"/").replace(t,r),i=new Date(s);if(i instanceof Date&&isFinite(i)){for(n=i.getFullYear(),d=a&&a.config.dateRange||50;d<u-n;)n+=100;return i.setFullYear(n)}}return e},e.tablesorter.addParser({id:"ddmmyy",is:function(){return!1},format:function(e,t){return r.formatDate(e,r.dates.regxxxxyy,"$2/$1/19$3",t)},type:"numeric"}),e.tablesorter.addParser({id:"mmddyy",is:function(){return!1},format:function(e,t){return r.formatDate(e,r.dates.regxxxxyy,"$1/$2/19$3",t)},type:"numeric"}),e.tablesorter.addParser({id:"yymmdd",is:function(){return!1},format:function(e,t){return r.formatDate(e,r.dates.regyyxxxx,"$2/$3/19$1",t)},type:"numeric"})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: weekday - updated 11/22/2015 (v2.24.6) */
!function(w){"use strict";var y=w.tablesorter;y.dates||(y.dates={}),y.dates.weekdays||(y.dates.weekdays={}),y.dates.weekdays.en={sun:"Sun",mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat"},y.dates.weekStartList={sun:"1995",mon:"1996",fri:"1999",sat:"2000"},y.dates.weekdaysXref=["sun","mon","tue","wed","thu","fri","sat"],y.addParser({id:"weekday",is:function(){return!1},format:function(e,t,a,r){if(e){var n,s,i,d=t.config,o=d.globalize&&(d.globalize[r]||d.globalize)||{},u=y.dates.weekdays[o.lang||"en"],f=y.dates.weekdaysXref;for(s in d.ignoreCase&&(e=e.toLowerCase()),u)if("string"==typeof s&&(n=u[s],d.ignoreCase&&(n=n.toLowerCase()),e.match(n)))return-1<(i=w.inArray(s,f))?i:e}return e},type:"numeric"}),y.addParser({id:"weekday-index",is:function(){return!1},format:function(e,t){if(e){var a=t.config,r=new Date(e);if(r instanceof Date&&isFinite(r))return new Date("1/"+(r.getDay()+1)+"/"+y.dates.weekStartList[a.weekStarts||"sun"])}return e},type:"numeric"})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,7 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: dates - updated 5/24/2017 (v2.28.11) */
!function(e){"use strict";
/*! Sugar (https://sugarjs.com/docs/#/DateParsing) */e.tablesorter.addParser({id:"sugar",is:function(){return!1},format:function(e){var t=Date.create||Sugar.Date.create,r=t?t(e):e?new Date(e):e;return r instanceof Date&&isFinite(r)?r.getTime():e},type:"numeric"}),
/*! Datejs (http://www.datejs.com/) */
e.tablesorter.addParser({id:"datejs",is:function(){return!1},format:function(e){var t=Date.parse?Date.parse(e):e?new Date(e):e;return t instanceof Date&&isFinite(t)?t.getTime():e},type:"numeric"})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,6 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: duration & countdown - updated 2/7/2015 (v2.19.0) */
!function(e){"use strict";e.tablesorter.addParser({id:"duration",is:function(){return!1},format:function(e,r){var t,n,s=r.config,i="",o="",a=s.durationLength||4,u=new Array(a+1).join("0"),d=(s.durationLabels||"(?:years|year|y),(?:days|day|d),(?:hours|hour|h),(?:minutes|minute|min|m),(?:seconds|second|sec|s)").split(/\s*,\s*/),c=d.length;if(!s.durationRegex){for(t=0;t<c;t++)i+="(?:(\\d+)\\s*"+d[t]+"\\s*)?";s.durationRegex=new RegExp(i,"i")}for(n=(s.usNumberFormat?e.replace(/,/g,""):e.replace(/(\d)(?:\.|\s*)(\d)/g,"$1$2")).match(s.durationRegex),t=1;t<c+1;t++)o+=(u+(n[t]||0)).slice(-a);return o},type:"text"}),
/*! Countdown parser ( hh:mm:ss ) */
e.tablesorter.addParser({id:"countdown",is:function(){return!1},format:function(e,r){for(var t=r.config.durationLength||4,n=new Array(t+1).join("0"),s=e.split(/\s*:\s*/),i=s.length,o=[];i;)o.push((n+(s[--i]||0)).slice(-t));return o.length?o.reverse().join(""):e},type:"text"})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: distance */
!function(a){"use strict";var n=a.tablesorter;n.symbolRegex=/[\u215b\u215c\u215d\u215e\u00bc\u00bd\u00be]/g,n.processFractions=function(t,e){if(t){var r,s=0;t=a.trim(t.replace(/\"/,"")),/\s/.test(t)&&(s=n.formatFloat(t.split(" ")[0],e),t=a.trim(t.substring(t.indexOf(" "),t.length))),/\//g.test(t)?(r=t.split("/"),t=s+parseInt(r[0],10)/parseInt(r[1]||1,10)):n.symbolRegex.test(t)&&(t=s+t.replace(n.symbolRegex,function(t){return{"⅛":".125","⅜":".375","⅝":".625","⅞":".875","¼":".25","½":".5","¾":".75"}[t]}))}return t||0},a.tablesorter.addParser({id:"distance",is:function(){return!1},format:function(t,e){if(""===t)return"";var r=/^\s*\S*(\s+\S+)?\s*\'/.test(t)?t.split(/\'/):[0,t],s=n.processFractions(r[0],e),a=n.processFractions(r[1],e);return/[\'\"]/.test(t)?parseFloat(s)+(parseFloat(a)/12||0):parseFloat(s)+parseFloat(a)},type:"numeric"})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: filetype - updated 11/10/2015 (v2.24.4) */
!function(c){"use strict";c.tablesorter.fileTypes={separator:"|",equivalents:{"3D Image":"3dm|3ds|dwg|max|obj",Audio:"aif|aac|ape|flac|la|m4a|mid|midi|mp2|mp3|ogg|ra|raw|rm|wav|wma",Compressed:"7z|bin|cab|cbr|gz|gzip|iso|lha|lz|rar|tar|tgz|zip|zipx|zoo",Database:"csv|dat|db|dbf|json|ldb|mdb|myd|pdb|sql|tsv|wdb|wmdb|xlr|xls|xlsx|xml",Development:"asm|c|class|cls|cpp|cc|cs|cxx|cbp|cs|dba|fla|h|java|lua|pl|py|pyc|pyo|sh|sln|r|rb|vb",Document:"doc|docx|odt|ott|pages|pdf|rtf|tex|wpd|wps|wrd|wri",Executable:"apk|app|com|exe|gadget|lnk|msi",Fonts:"eot|fnt|fon|otf|ttf|woff",Icons:"ani|cur|icns|ico",Images:"bmp|gif|jpg|jpeg|jpe|jp2|pic|png|psd|tga|tif|tiff|wmf|webp",Presentation:"pps|ppt",Published:"chp|epub|lit|pub|ppp|fm|mobi",Script:"as|bat|cgi|cmd|jar|js|lua|scpt|scptd|sh|vbs|vb|wsf",Styles:"css|less|sass",Text:"info|log|md|markdown|nfo|tex|text|txt",Vectors:"awg|ai|eps|cdr|ps|svg",Video:"asf|avi|flv|m4v|mkv|mov|mp4|mpe|mpeg|mpg|ogg|rm|rv|swf|vob|wmv",Web:"asp|aspx|cer|cfm|htm|html|php|url|xhtml"}},c.tablesorter.addParser({id:"filetype",is:function(){return!1},format:function(t,e){var s,a=e.config.widgetOptions,p=a.group_separator||"-",r=t.lastIndexOf("."),i=c.tablesorter.fileTypes.separator,o=c.tablesorter.fileTypes.matching,n=c.tablesorter.fileTypes.equivalents;if(o||(s=[],c.each(n,function(t,e){s.push(e)}),o=c.tablesorter.fileTypes.matching=i+s.join(i)+i),0<=r&&(s=i+t.substring(r+1,t.length)+i,0<=o.indexOf(s)))for(r in n)if(0<=(i+n[r]+i).indexOf(s))return r+("/"!==p.toString().charAt(0)?a.group_separator:"-")+t;return t},type:"text"}),c.tablesorter.addParser({id:"file-extension",is:function(){return!1},format:function(t){var e,s=t.split(".");return s.length?(e=s.pop(),s.unshift(e),s.join(".")):t},type:"text"})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,7 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: jQuery Globalize - updated 11/2/2015 (v2.24.1) */
!function(b){"use strict";
/*! jQuery Globalize date parser (https://github.com/jquery/globalize#date-module) */b.tablesorter.addParser({id:"globalize-date",is:function(){return!1},format:function(e,l,a,o){var r,i,t=l.config,n=t.globalize&&(t.globalize[o]||t.globalize)||{};return Globalize&&(r="object"==typeof n.Globalize?n.Globalize:Globalize(n.lang||"en"),n.Globalize||(n.Globalize=r)),(i=r&&r.dateParser?r.dateParser(n)(e):e?new Date(e):e)instanceof Date&&isFinite(i)?i.getTime():e},type:"numeric"}),
/*! jQuery Globalize number parser (https://github.com/jquery/globalize#number-module) */
b.tablesorter.addParser({id:"globalize-number",is:function(){return!1},format:function(e,l,a,o){var r,i,t=l.config,n=t.globalize&&(t.globalize[o]||t.globalize)||{};return Globalize&&(r="object"==typeof n.Globalize?n.Globalize:Globalize(n.lang||"en"),n.Globalize||(n.Globalize=r)),i=r&&r.numberParser?r.numberParser(n)(e):e?b.tablesorter.formatFloat((e||"").replace(/[^\w,. \-()]/g,""),l):e,e&&"number"==typeof i?i:e},type:"numeric"})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: hugeNumbers - updated 3/1/2016 (v2.25.5) */
!function(){"use strict";jQuery.tablesorter.addParser({id:"hugeNumbers",is:function(){return!1},format:function(e){return e.replace(/\B(?=(\d{12})+(?!\d))/g,",")},type:"text"})}();return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: ignoreArticles - updated 9/15/2014 (v2.17.8) */
!function(o){"use strict";var g=o.tablesorter;g.ignoreArticles={en:"the, a, an",de:"der, die, das, des, dem, den, ein, eine, einer, eines, einem, einen",nl:"de, het, de, een",es:"el, la, lo, los, las, un, una, unos, unas",pt:"o, a, os, as, um, uma, uns, umas",fr:"le, la, l'_, les, un, une, des",it:"il, lo, la, l'_, i, gli, le, un', uno, una, un",hu:"a, az, egy"},g.addParser({id:"ignoreArticles",is:function(){return!1},format:function(e,r,s,a){var n,i,t,l=r.config,d=e||"";return l.headers&&l.headers[a]&&l.headers[a].ignoreArticlesRegex||(l.headers||(l.headers={}),l.headers[a]||(l.headers[a]={}),t=g.getData(l.$headers.eq(a),g.getColumnData(r,l.headers,a),"ignoreArticles"),n=(g.ignoreArticles[t]||"the, a, an")+"",l.headers[a].ignoreArticlesRegex=new RegExp("^("+o.trim(n.split(/\s*\,\s*/).join("\\s|")+"\\s").replace("_\\s","")+")","i"),i=g.getData(l.$headers.eq(a),g.getColumnData(r,l.headers,a),"ignoreArticlesExcept"),l.headers[a].ignoreArticlesRegex2=""!==i?new RegExp("^("+i.replace(/\s/g,"\\s")+")","i"):""),!(n=l.headers[a].ignoreArticlesRegex).test(d)||(i=l.headers[a].ignoreArticlesRegex2)&&i.test(d)?d:d.replace(n,"")},type:"text"})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: image - new 7/17/2014 (v2.17.5) */
!function(i){"use strict";i.tablesorter.addParser({id:"image",is:function(){return!1},format:function(t,r,e){return i(e).find("img").attr(r.config.imgAttr||"alt")||t},parsed:!0,type:"text"})}(jQuery);return jQuery;}));

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: leading zeros - updated 4/2/2017 (v2.28.6) */
!function(){"use strict";var i=jQuery.tablesorter;i.addParser({id:"leadingZeros",is:function(){return!1},format:function(e,t){var r=(e||"").replace(i.regex.nondigit,""),n=i.formatFloat(r,t),a=n.toString();return isNaN(n)||n!=r||r.length===a.length||(n-=1e-10*(e.length-a.length)),n},type:"number"})}();return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: metric */
!function(h){"use strict";var f={"Y|Yotta|yotta":[1e24,Math.pow(1024,8)],"Z|Zetta|zetta":[1e21,Math.pow(1024,7)],"E|Exa|exa":[1e18,Math.pow(1024,6)],"P|Peta|peta":[1e15,Math.pow(1024,5)],"T|Tera|tera":[1e12,Math.pow(1024,4)],"G|Giga|giga":[1e9,Math.pow(1024,3)],"M|Mega|mega":[1e6,Math.pow(1024,2)],"k|Kilo|kilo":[1e3,1024],"h|hecto":[100,100],"da|deka":[10,10],"d|deci":[.1,.1],"c|centi":[.01,.01],"m|milli":[.001,.001],"µ|micro":[1e-6,1e-6],"n|nano":[1e-9,1e-9],"p|pico":[1e-12,1e-12],"f|femto":[1e-15,1e-15],"a|atto":[1e-18,1e-18],"z|zepto":[1e-21,1e-21],"y|yocto":[1e-24,1e-24]},l=/^[b|bit|byte|o|octet]/i;h.tablesorter.addParser({id:"metric",is:function(){return!1},format:function(e,t,a,o){var r,i,c,n,m="m|meter",p=h.tablesorter.formatFloat(e.replace(/[^\w,. \-()]/g,""),t),d=t.config.$headerIndexed[o],s=d.data("metric");if(s||(r=(d.attr("data-metric-name")||m).split("|"),c=d.attr("data-metric-name-full")||"",n=d.attr("data-metric-name-abbr")||"",s=[c||r[1]||r[0].substring(1),n||r[0]],i=l.test(s.join("")),s[2]=new RegExp("(\\d+)(\\s+)?([Zz]etta|[Ee]xa|[Pp]eta|[Tt]era|[Gg]iga|[Mm]ega|kilo|hecto|deka|deci|centi|milli|micro|nano|pico|femto|atto|zepto|yocto)("+((""===c?"":c+"|"+n)||(i?s[0].toLowerCase()+"|"+s[0].toUpperCase():s[0])+"|"+(i?s[1].toLowerCase()+"|"+s[1].toUpperCase():s[1]))+")"),s[3]=new RegExp("(\\d+)(\\s+)?(Z|E|P|T|G|M|k|h|da|d|c|m|µ|n|p|f|a|z|y)("+(n||(i?s[1].toLowerCase()+"|"+s[1].toUpperCase():s[1]))+")"),d.data("metric",s)),r=e.match(s[2])||e.match(s[3]))for(m in f)if(r[3].match(m))return i=l.test(r[4])?1:0,p*f[m][i];return p},type:"numeric"})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: namedNumbers - updated 10/26/2014 (v2.18.0) */
!function(d){"use strict";var g,v,c={negative:["negative","minus"],numbers:{zero:0,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,thirteen:13,fourteen:14,fifteen:15,sixteen:16,seventeen:17,eighteen:18,nineteen:19,twenty:20,thirty:30,forty:40,fourty:40,fifty:50,sixty:60,seventy:70,eighty:80,ninety:90},hundred:"hundred",powers:{thousand:1e3,million:1e6,billion:1e9,trillion:1e12,quadrillion:1e15,quintillion:1e18,sextillion:1e21,septillion:1e24,octillion:1e27,nonillion:1e30,decillion:1e33,undecillion:1e36,duodecillion:1e39,tredecillion:1e42,quattuordecillion:1e45,quindecillion:1e48,sexdecillion:1e51,septendecillion:1e54,octodecillion:1e57,novemdecillion:1e60,vigintillion:1e63,unvigintillion:1e66,duovigintillion:1e69,trevigintillion:1e72,quattuorvigintillion:1e75,quinvigintillion:1e78,sexvigintillion:1e81,septenvigintillion:1e84,octovigintillion:1e87,novemvigintillion:1e90,trigintillion:1e93,untrigintillion:1e96,duotrigintillion:1e99,googl:1e100}},f=new RegExp("("+c.negative.join("|")+")");d.tablesorter.addParser({id:"namedNumbers",is:function(){return!1},format:function(e,i){v=g=0;var n,t,l,o,r,u,s=(e||"").split(/[\s-]+/),a=s.length;for(n=0;n<a;n++)t=s[n].toLowerCase(),l=i,r=void 0,o=t.replace(/[,."']/g,""),r=d.tablesorter.formatFloat(t||"",l),u=c.powers.hasOwnProperty(o)?c.powers[o]:null,null!==(r="number"==typeof r?r:c.numbers.hasOwnProperty(o)?c.numbers[o]:null)?v+=r:o===c.hundred?v*=100:null!==u&&(g+=v*u,v=0);return(g=(g+v)*(e.match(f)?-1:1))||c.numbers.hasOwnProperty(e)?g:d.tablesorter.formatFloat(e||"",i)},type:"numeric"})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,9 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: network - updated 2018-01-10 (v2.29.3) */
!function(d){"use strict";var e,t,o=d.tablesorter;
/*! IPv6 Address parser (WIP) */d.extend(o.regex,{},{ipv4Validate:/((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})/,ipv4Extract:/([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/,ipv6Validate:/^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/i}),o.defaults.ipv6HexFormat=!1,o.addParser({id:"ipv6Address",is:function(d){return o.regex.ipv6Validate.test(d)},format:function(d,e){var t,a,r,i,f,s=!!e&&("boolean"==typeof e?e:e&&e.config.ipv6HexFormat||!1),n="",p="";if(d=d.replace(/\s*/g,""),o.regex.ipv4Validate.test(d)){for(i=d.match(o.regex.ipv4Extract),a="",t=1;t<i.length;t++)a+=("00"+parseInt(i[t],10).toString(16)).slice(-2)+(2===t?":":"");d=d.replace(o.regex.ipv4Extract,a)}if(-1===d.indexOf("::"))n=d;else{for(r=d.split("::"),t=f=0;t<r.length;t++)f+=r[t].split(":").length;for(n+=r[0]+":",t=0;t<8-f;t++)n+="0000:";n+=r[1]}for(i=n.split(":"),t=0;t<8;t++)i[t]=s?("0000"+i[t]).slice(-4):("00000"+(parseInt(i[t],16)||0)).slice(-5),p+=7!==t?i[t]+":":i[t];return p},type:"text"}),t=function(d){return/^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$/.test(d)},e=function(d){var e,t=d?d.split("."):"",a=[],r=t.length;for(e=0;e<r;e++)a.push(("000"+t[e]).slice(-3));return d?a.join("."):d},
/*! Parser: ipv4Address (a.k.a. ipAddress) */
o.addParser({id:"ipAddress",is:t,format:e,type:"text"}),o.addParser({id:"ipv4Address",is:t,format:e,type:"text"}),
/*! Parser: MAC address */
o.addParser({id:"MAC",is:function(){return!1},format:function(d){var e,t,a=[],r=(d||"").replace(/[:.-]/g,"").match(/\w{2}/g);if(r){for(t=r.length,e=0;e<t;e++)a.push(("000"+parseInt(r[e],16)).slice(-3));return a.join(".")}return d},type:"text"})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Parser: roman - updated 6/28/MMXIV (v2.17.3) */
!function(c){"use strict";var p=/^M*(?:D?C{0,3}|C[MD])(?:L?X{0,3}|X[CL])(?:V?I{0,3}|I[XV])$/i,m=/\b([MCDLXVI]+\b)/gi,l={I:1,V:5,X:10,L:50,C:100,D:500,M:1e3};c.tablesorter.addParser({id:"roman",is:function(){return!1},format:function(r){var t,e=r.toUpperCase().split(""),n=0;if(!r||!p.test(r))return r;for(;e.length;)n+=(t=l[e.shift()])*(t<l[e[0]]?-1:1);return n},type:"numeric"}),c.tablesorter.addParser({id:"roman-ignore",is:function(){return!1},format:function(r,t,e,n){var i,a,o=t.config,s=c.isArray(o.roman_ignore)?o.roman_ignore[n]:0,u=(isNaN(s)?c.trim(r.replace(s,"")):c.trim(r.substring(0,r.length-s))).match(m),f=0;if(!p.test(u))return r;for(u=(a=u[0]).toUpperCase().split("");u.length;)(i=l[u.shift()])&&(f+=i*(i<l[u[0]]?-1:1));return f?r.replace(a,f):r},type:"text"}),c.tablesorter.addParser({id:"roman-extract",is:function(){return!1},format:function(r){var t,e=c.grep(r.split(/\b/),function(r){return p.test(r)?r:""}).join("").match(m),n=0;if(!(e?p.test(e):0))return r;for(e=e[0].toUpperCase().split("");e.length;)(t=l[e.shift()])&&(n+=t*(t<l[e[0]]?-1:1));return n||r},type:"numeric"})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Widget: alignChar - updated 2/7/2015 (v2.19.0) */
!function(_){"use strict";var e=_.tablesorter;e.alignChar={init:function(i,t,r){t.$headers.filter("["+r.alignChar_charAttrib+"]").each(function(){var n=_(this),a={column:this.column,align:n.attr(r.alignChar_charAttrib),alignIndex:parseInt(n.attr(r.alignChar_indexAttrib)||0,10),adjust:parseFloat(n.attr(r.alignChar_adjustAttrib))||0};a.regex=new RegExp("\\"+a.align,"g"),void 0!==a.align&&(r.alignChar_savedVars[this.column]=a,e.alignChar.setup(i,t,r,a))})},setup:function(n,a,i,t){if(!_.isEmptyObject(a.cache)){var r,e,l,h,g,o,s,d,c,u,f,m,p,C,w=[],b=[];for(r=0;r<a.$tbodies.length;r++)for(u=(s=a.cache[r]).normalized.length,e=0;e<u;e++){if(0<(c=((d=(C=s.row?s.row[e]:s.normalized[e][a.columns].$row).find("td").eq(t.column).text().replace(/[ ]/g," ")).match(t.regex)||[]).length)&&0<t.alignIndex)for(h=Math.min(t.alignIndex,c),g=o=l=0;l++<h;)o=(g=d.indexOf(t.align,g+1))<0?o:g;else o=d.indexOf(t.align);0<=o?(w.push(d.substring(0,o)||""),b.push(d.substring(o,d.length)||"")):(w.push(1<=c&&t.alignIndex>=c?"":d||""),b.push(1<=c&&t.alignIndex>=c&&d||""))}for(f=_.extend([],w).sort(function(n,a){return a.length-n.length})[0],m=_.extend([],b).sort(function(n,a){return a.length-n.length})[0],t.width=t.width||Math.floor(f.length/(f.length+m.length)*100)+t.adjust,f="min-width:"+t.width+"%",m="min-width:"+(100-t.width)+"%",r=0;r<a.$tbodies.length;r++)for(u=(s=a.cache[r]).normalized.length,e=0;e<u;e++)p=_(i.alignChar_wrap).length?_(i.alignChar_wrap).html(t.align)[0].outerHTML:t.align,C=s.row?s.row[e]:s.normalized[e][a.columns].$row,g=b[e].slice(t.align.length),C.find("td").eq(t.column).html('<span class="ts-align-wrap"><span class="ts-align-left" style="'+f+'">'+w[e]+'</span><span class="ts-align-right" style="'+m+'">'+(g.length?p+g:"")+"</span></span>");i.alignChar_initialized=!0}},remove:function(n,a,i){var t,r,e,l,h;if(!_.isEmptyObject(a.cache))for(t=0;t<a.$tbodies.length;t++)for(e=(l=a.cache[t]).normalized.length,r=0;r<e;r++)(h=(l.row?l.row[r]:l.normalized[r][a.columns].$row).find("td").eq(i)).html(h.text().replace(/\s/g," "))}},e.addWidget({id:"alignChar",priority:100,options:{alignChar_wrap:"",alignChar_charAttrib:"data-align-char",alignChar_indexAttrib:"data-align-index",alignChar_adjustAttrib:"data-align-adjust"},init:function(n,a,i,t){t.alignChar_initialized=!1,t.alignChar_savedVars=[],e.alignChar.init(n,i,t),i.$table.on("pagerEnd refreshAlign",function(){i.$headers.filter("["+t.alignChar_charAttrib+"]").each(function(){e.alignChar.remove(n,i,this.column)}),e.alignChar.init(n,i,t)})},format:function(n,a,i){i.alignChar_initialized||a.$table.triggerHandler("refreshAlign")},remove:function(n,a,i,t){t||(a.$headers.filter("["+i.alignChar_charAttrib+"]").each(function(){e.alignChar.remove(n,a,this.column)}),i.alignChar_initialized=!1)}})}(jQuery);return jQuery;}));

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
!function(l){"use strict";var n=l.tablesorter,s=[],c=[],u=[],a=[],_=[],f=[],d=[],g=[],p=n.chart={nonDigit:/[^\d,.\-()]/g,init:function(t,e){t.$table.off(e.chart_event).on(e.chart_event,function(){if(this.hasInitialized){var t=this.config;p.getCols(t,t.widgetOptions),p.getData(t,t.widgetOptions)}})},getCols:function(t,e){var a;for(s=[],f=[],g=[],a=0;a<t.columns;a++)e.chart_useSelector&&n.hasWidget(t.table,"columnSelector")&&!t.selector.auto?(t.selector.states[a]&&l.inArray(a,e.chart_ignoreColumns)<0||a===e.chart_labelCol||a===e.chart_sort[0][0])&&s.push(a):(l.inArray(a,e.chart_ignoreColumns)<0||a===e.chart_labelCol||a===e.chart_sort[0][0])&&s.push(a)},getData:function(t,e){p.getHeaders(t,e),p.getRows(t,e),a=[c],l.each(u,function(t,e){a.push(e)}),t.chart={data:a,categories:_,series:f,category:d,dataset:g}},getHeaders:function(a,r){var o;f=[],g=[],(c=[]).push(a.headerContent[r.chart_labelCol]),l.each(s,function(t,e){if(e===r.chart_labelCol)return!0;o=a.headerContent[e],c.push(o),f.push({name:o,data:[]}),g.push({seriesname:o,data:[]})})},getRows:function(c,i){var t=c.cache[0].normalized,h=[];u=[],_=[],d=[],l.each(t,function(t,e){var a,r,o=e[c.columns].$row,s=o.children("th,td"),n=[];if(/v/i.test(i.chart_incRows)&&o.is(":visible")||/f/i.test(i.chart_incRows)&&!o.hasClass(i.filter_filteredRow||"filtered")||!/(v|f)/i.test(i.chart_incRows)){for(a=0;a<c.columns;a++)0<=l.inArray(t,i.chart_parsed)?n.push(e[a]):(r=s[a].getAttribute(c.textAttribute)||s[a].textContent||s.eq(a).text(),n.push(l.trim(r)));h.push(n)}}),h.sort(function(t,e){return 1===i.chart_sort[0][1]?n.sortNatural(e[i.chart_sort[0][0]],t[i.chart_sort[0][0]]):n.sortNatural(t[i.chart_sort[0][0]],e[i.chart_sort[0][0]])}),l.each(h,function(t,e){var r,o=0,s=[],a=e[i.chart_labelCol];s.push(""+a),l.each(e,function(t,e){var a;if(t===i.chart_labelCol)return _.push(e),d.push({label:e}),!0;r=!1,i.chart_useSelector&&n.hasWidget(c.table,"columnSelector")&&!c.selector.auto?c.selector.states[t]&&l.inArray(t,i.chart_ignoreColumns)<0&&(r=""+e):l.inArray(t,i.chart_ignoreColumns)<0&&(r=""+e),!1!==r&&(/s/i.test(""+i.chart_layout[t])?(s.push(r),f[o].data.push(r),g[o].data.push(r)):(a=n.formatFloat(r.replace(p.nonDigit,""),c.table),a=isNaN(a)?r:a,s.push(a),f[o].data.push(a),g[o].data.push({value:a})),o++)}),u.push(s)})},remove:function(t,e){t.$table.off(e.chart_event)}};n.addWidget({id:"chart",options:{chart_incRows:"filtered",chart_useSelector:!1,chart_ignoreColumns:[],chart_parsed:[],chart_layout:{0:"string"},chart_labelCol:0,chart_sort:[[0,0]],chart_event:"chartData"},init:function(t,e,a,r){p.init(a,r)},remove:function(t,e,a){p.remove(e,a)}})}(jQuery);return jQuery;}));

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Widget: columns - updated 5/24/2017 (v2.28.11) */
!function(b){"use strict";var v=b.tablesorter||{};v.addWidget({id:"columns",priority:65,options:{columns:["primary","secondary","tertiary"]},format:function(e,r,o){var t,s,n,i,a,d,l,c,h=r.$table,f=r.$tbodies,m=r.sortList,y=m.length,u=o&&o.columns||["primary","secondary","tertiary"],p=u.length-1;for(l=u.join(" "),s=0;s<f.length;s++)(n=(t=v.processTbody(e,f.eq(s),!0)).children("tr")).each(function(){if(a=b(this),"none"!==this.style.display&&(d=a.children().removeClass(l),m&&m[0]&&(d.eq(m[0][0]).addClass(u[0]),1<y)))for(c=1;c<y;c++)d.eq(m[c][0]).addClass(u[c]||u[p])}),v.processTbody(e,t,!1);if(i=!1!==o.columns_thead?["thead tr"]:[],!1!==o.columns_tfoot&&i.push("tfoot tr"),i.length&&(n=h.find(i.join(",")).children().removeClass(l),y))for(c=0;c<y;c++)n.filter('[data-column="'+m[c][0]+'"]').addClass(u[c]||u[p])},remove:function(e,r,o){var t,s,n=r.$tbodies,i=(o.columns||["primary","secondary","tertiary"]).join(" ");for(r.$headers.removeClass(i),r.$table.children("tfoot").children("tr").children("th, td").removeClass(i),t=0;t<n.length;t++)(s=v.processTbody(e,n.eq(t),!0)).children("tr").each(function(){b(this).children().removeClass(i)}),v.processTbody(e,s,!1)}})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Widget: cssStickyHeaders - updated 6/16/2018 (v2.30.6) */
!function(d,o){"use strict";var s=d.tablesorter;function a(r,l){function p(e,t){var s=0===t?"":"translate(0px,"+t+"px)";e.css({transform:s,"-ms-transform":s,"-webkit-transform":s})}var e,h,f=r.$table,g=d(l.cssStickyHeaders_attachTo),k="ActiveXObject"in o||-1<o.navigator.userAgent.indexOf("Edge"),t=r.namespace+"cssstickyheader ",y=f.children("thead"),H=f.children("caption"),u=g.length?g:d(o),S=f.parent().closest("table."+s.css.table),b=S.length&&s.hasWidget(S[0],"cssStickyHeaders")?S.children("thead"):[],m=parseInt(f.css("border-top-width"),10)||0,_=f.height(),C=l.cssStickyHeaders_addCaption,T=!1,v=!1;H.length&&(H.hide(),v=f.height()===_,H.show(),e=f.offset().top,p(H,20),T=f.offset().top!==e,p(H,0)),u.unbind("scroll resize ".split(" ").join(t).replace(/\s+/g," ")).bind("scroll resize ".split(" ").join(t),function(){l=r.widgetOptions,T&&(p(H,0),h=f.offset().top),u.scrollTop()<H.outerHeight(!0)&&(_=f.height());var e=g.length?g.offset().top:u.scrollTop(),t=(H.outerHeight(!0)||0)+(parseInt(f.css("padding-top"),10)||0)+(parseInt(f.css("border-spacing"),10)||0),s=_+(v&&l.cssStickyHeaders_addCaption?t:0)-y.height()-(f.children("tfoot").height()||0)-(l.cssStickyHeaders_addCaption?t:v?0:t),i=b.length?b.height():0,a=b.length?k?S.data("cssStickyHeaderBottom")+i:b.offset().top+i-u.scrollTop():0,d=T?h:f.offset().top,o=e-(v?d-(l.cssStickyHeaders_addCaption?t:0):d)+a+m+(l.cssStickyHeaders_offset||0)-(l.cssStickyHeaders_addCaption?v?t:0:t),c=0<o&&o<=s?o:0,n=k?y.children().children():y;k&&r.$table.data("cssStickyHeaderBottom",(b.length?i:0)-(l.cssStickyHeaders_addCaption?t:0)),l.cssStickyHeaders_addCaption&&(n=n.add(H)),C!==l.cssStickyHeaders_addCaption&&((C=l.cssStickyHeaders_addCaption)||p(H,0)),p(n,c)}),f.unbind("filterEnd updateComplete ".split(" ").join(t).replace(/\s+/g," ")).bind("filterEnd"+t,function(){l.cssStickyHeaders_filteredToTop&&o.scrollTo(0,f.position().top)}).bind("updateComplete"+t,function(){a(r,r.widgetOptions)})}s.addWidget({id:"cssStickyHeaders",priority:10,options:{cssStickyHeaders_offset:0,cssStickyHeaders_addCaption:!1,cssStickyHeaders_attachTo:null,cssStickyHeaders_filteredToTop:!0},init:function(e,t,s,i){a(s,i)},remove:function(e,t,s,i){if(!i){var a=t.namespace+"cssstickyheader ";d(o).unbind("scroll resize ".split(" ").join(a).replace(/\s+/g," ")),t.$table.unbind("filterEnd scroll resize updateComplete ".split(" ").join(a).replace(/\s+/g," ")).add(t.$table.children("thead").children().children()).children("thead, caption").css({transform:"","-ms-transform":"","-webkit-transform":""})}}})}(jQuery,window);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Widget: currentSort - 7/31/2016 (v2.27.0) */
!function(){"use strict";var i=jQuery.tablesorter;i.currentSortLanguage={0:"asc",1:"desc",2:"unsorted"},i.currentSort={init:function(t){t.$table.on("sortEnd.tscurrentSort",function(){i.currentSort.update(this.config)})},update:function(t){if(t){var r,n=t.widgetOptions,o=i.currentSortLanguage,e=o[2],c=Array.apply(null,Array(t.columns)).map(String.prototype.valueOf,e),u=t.sortList,a=u.length;for(r=0;r<a;r++)c[u[r][0]]=o[u[r][1]];t.currentSort=c,"function"==typeof n.currentSort_callback&&n.currentSort_callback(t,c)}}},i.addWidget({id:"currentSort",options:{currentSort_callback:null},init:function(t,r,n,o){i.currentSort.init(n,o)},remove:function(t,r){r.$table.off("sortEnd.tscurrentSort")}})}();return jQuery;}));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Widget: filter, select2 formatter function - updated 12/1/2019 (v2.31.2) */
!function(g){"use strict";var h=g.tablesorter||{};h.filterFormatter=h.filterFormatter||{},h.filterFormatter.select2=function(i,c,e){function t(){a=[],l=h.filter.getOptionSource(s.$table[0],c,f)||[],g.each(l,function(e,t){a.push({id:""+t.parsed,text:t.text})}),n.data=a}var l,a,n=g.extend({cellText:"",match:!0,value:"",multiple:!0,width:"100%"},e),s=i.addClass("select2col"+c).closest("table")[0].config,d=s.widgetOptions,r=g('<input class="filter" type="hidden">').appendTo(i).bind("change"+s.namespace+"filter",function(){var e=v(this.value);s.$table.find(".select2col"+c+" .select2").select2("val",e),$()}),o=s.$headerIndexed[c],f=o.hasClass(d.filter_onlyAvail),p=n.match?"":"^",u=n.match?"":"$",b=d.filter_ignoreCase?"i":"",v=function(e){return e.replace(/^\/\(\^?/,"").replace(/\$\|\^/g,"|").replace(/\$?\)\/i?$/g,"").replace(/\\/g,"").split("|")},$=function(){var e=!1,t=s.$table.find(".select2col"+c+" .select2").select2("val")||n.value||"";g.isArray(t)&&(e=!0,t=t.join("\0"));var l=t.replace(/[-[\]{}()*+?.,/\\^$|#]/g,"\\$&");e&&(t=t.split("\0"),l=l.split("\0")),h.isEmptyObject(i.find(".select2").data())||(r.val(g.isArray(l)&&l.length&&""!==l.join("")?"/("+p+(l||[]).join(u+"|"+p)+u+")/"+b:"").trigger("search"),i.find(".select2").select2("val",t),s.widgetOptions.$sticky&&s.widgetOptions.$sticky.find(".select2col"+c+" .select2").select2("val",t))};return o.toggleClass("filter-match",n.match),n.cellText&&i.prepend("<label>"+n.cellText+"</label>"),n.ajax&&!g.isEmptyObject(n.ajax)||n.data||(t(),s.$table.bind("filterEnd",function(){t(),s.$table.find(".select2col"+c).add(s.widgetOptions.$sticky&&s.widgetOptions.$sticky.find(".select2col"+c)).find(".select2").select2(n)})),g('<input class="select2 select2-'+c+'" type="hidden" />').val(n.value).appendTo(i).select2(n).bind("change",function(){$()}),s.$table.bind("filterFomatterUpdate",function(){var e=v(s.$table.data("lastSearch")[c]||"");(i=s.$table.find(".select2col"+c)).find(".select2").select2("val",e),$(),h.filter.formatterUpdated(i,c)}),s.$table.bind("stickyHeadersInit",function(){var e=s.widgetOptions.$sticky.find(".select2col"+c).empty();g('<input class="select2 select2-'+c+'" type="hidden">').val(n.value).appendTo(e).select2(n).bind("change",function(){s.$table.find(".select2col"+c).find(".select2").select2("val",s.widgetOptions.$sticky.find(".select2col"+c+" .select2").select2("val")),$()}),n.cellText&&e.prepend("<label>"+n.cellText+"</label>")}),s.$table.bind("filterReset",function(){s.$table.find(".select2col"+c).find(".select2").select2("val",n.value||""),setTimeout(function(){$()},0)}),$(),r}}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Widget: filter, insideRange filter type - updated 12/10/2015 (v2.25.0) */
!function(){"use strict";function f(t){return isNaN(t)?t:parseFloat(t)}var t=jQuery.tablesorter,o=/\d+/,p=/\s+-\s+/;t.filter.types.insideRange=function(t,e){if(!e.anyMatch&&o.test(e.iFilter)&&p.test(e.iExact)){var r,i,n,a,s=e.index,l=e.$cells[s],u=e.iExact.split(p),c=t.parsers[e.index]&&t.parsers[e.index].format;return u&&u.length<2||"function"!=typeof c?null:(n=f(c(u[0],t.table,l,s)),(a=f(c(u[1],t.table,l,s)))<n&&(r=a,a=n,n=r),n<=(i=f(c(e.iFilter,t.table,l,s)))&&i<=a)}return null}}();return jQuery;}));

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Widget: formatter - 2/9/2015 (v2.19.1) */
!function(d){"use strict";var u=d.tablesorter;u.formatter={init:function(t){var e=t.widgetOptions.formatter_event+" pagerComplete updateComplete ".split(" ").join(".tsformatter ");t.$table.off(e.replace(/\s+/g," ")).on(e,function(){u.formatter.setup(t)}),u.formatter.setup(t)},setup:function(t){if(!d.isEmptyObject(t.cache)){var e,o,r,n,i,a,l,c=t.widgetOptions,f={config:t,wo:c},s=[],m=[];for(l=0;l<t.columns;l++)m[l]=t.$headerIndexed[l],s[l]=u.getColumnData(t.table,c.formatter_column,l)||!1;for(o=0;o<t.$tbodies.length;o++){for(e=u.processTbody(t.table,t.$tbodies.eq(o),!0),a=(n=t.cache[o]).normalized.length,r=0;r<a;r++)for(f.$row=n.normalized[r][t.columns].$row,f.$cells=f.$row.children("th, td"),l=0;l<t.columns;l++)s[l]&&(f.columnIndex=l,f.$header=m[l],f.$cell=f.$cells.eq(l),i=f.$cell[0],f.text=i.getAttribute(t.textAttribute)||i.textContent||f.$cell.text(),i.innerHTML=s[l](f.text,f));u.processTbody(t.table,e,!1)}}}},u.addWidget({id:"formatter",priority:100,options:{formatter_column:{},formatter_event:"applyFormatter"},init:function(t){u.formatter.init(t.config)}})}(jQuery);return jQuery;}));

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Widget: headerTitles - updated 11/10/2015 (v2.24.4) */
!function(d){"use strict";var n=d.tablesorter;n.addWidget({id:"headerTitles",options:{headerTitle_useAria:!1,headerTitle_tooltip:"",headerTitle_cur_text:[" sort: A - Z"," sort: Z - A","ly unsorted"],headerTitle_cur_numeric:[" sort: 0 - 9"," sort: 9 - 0","ly unsorted"],headerTitle_nxt_text:[" sort: A - Z"," sort: Z - A","remove sort"],headerTitle_nxt_numeric:[" sort: 0 - 9"," sort: 9 - 0","remove sort"],headerTitle_output_sorted:"current{current}; activate to {next}",headerTitle_output_unsorted:"current{current}; activate to {next} ",headerTitle_output_nosort:"No sort available",headerTitle_type:[],headerTitle_callback:null},init:function(e,t,r,a){r.$table.on("refreshHeaderTitle",function(){t.format(e,r,a)}),d.isArray(a.headerTitle_tooltip)?r.$headers.each(function(){d(this).addClass(a.headerTitle_tooltip[this.column]||"")}):""!==a.headerTitle_tooltip&&r.$headers.addClass(a.headerTitle_tooltip)},format:function(e,s,i){var l;s.$headers.each(function(){var t=d(this),e=parseInt(t.attr("data-column"),10),r=i.headerTitle_type[e]||s.parsers[e].type||"text",a=t.hasClass(n.css.sortAsc)?0:t.hasClass(n.css.sortDesc)?1:2,o=s.sortVars[e].order[(s.sortVars[e].count+1)%(s.sortReset?3:2)];l=i.headerTitle_useAria?t.attr("aria-label")||i.headerTitle_output_nosort||"":(l=(i.headerTitle_prefix||"")+(t.hasClass("sorter-false")?i.headerTitle_output_nosort:0<=n.isValueInArray(e,s.sortList)?i.headerTitle_output_sorted:i.headerTitle_output_unsorted)).replace(/\{(current|next|name)\}/gi,function(e){return{"{name}":t.text(),"{current}":i["headerTitle_cur_"+r][a]||"","{next}":i["headerTitle_nxt_"+r][o]||""}[e.toLowerCase()]}),t.attr("title",d.isFunction(i.headerTitle_callback)?i.headerTitle_callback(t,l):l)})},remove:function(e,t,r){t.$headers.attr("title",""),t.$table.off("refreshHeaderTitle"),d.isArray(r.headerTitle_tooltip)?t.$headers.each(function(){d(this).removeClass(r.headerTitle_tooltip[this.column]||"")}):""!==r.headerTitle_tooltip&&t.$headers.removeClass(r.headerTitle_tooltip)}})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,19 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Widget: lazyload (BETA) - 4/1/2016 (v2.25.7) */
!function(r,o){"use strict";var n=r.tablesorter;n.lazyload={init:function(t,e){"scrollstop"!==e.lazyload_event||n.addScrollStopDone||(n.addScrollStop(),n.addScrollStopDone=!0,r.event.special.scrollstop.latency=e.lazyload_latency||250),n.lazyload.update(t,e);var l=t.namespace+"lazyload ",a=[e.lazyload_update,"pagerUpdate",e.columnSelector_updated||"columnUpdate",""].join(l);t.$table.on(a,function(){n.lazyload.update(t,t.widgetOptions)}).on("filterEnd"+l,function(){r(o).scroll()})},update:function(t,e){var l=(/(\.|#)/.test(e.lazyload_imageClass)?"":".")+e.lazyload_imageClass;t.$table.find(l).lazyload({threshold:e.lazyload_threshold,failure_limit:e.lazyload_failure_limit,event:e.lazyload_event,effect:e.lazyload_effect,container:e.lazyload_container,data_attribute:e.lazyload_data_attribute,skip_invisible:e.lazyload_skip_invisible,appear:e.lazyload_appear,load:e.lazyload_load,placeholder:e.lazyload_placeholder}),setTimeout(function(){r(o).scroll()},1)},remove:function(t){t.$table.off(t.namespace+"lazyload")}},n.addWidget({id:"lazyload",options:{lazyload_imageClass:"lazy",lazyload_update:"lazyloadUpdate",lazyload_latency:250,lazyload_threshold:0,lazyload_failure_limit:0,lazyload_event:"scrollstop",lazyload_effect:"show",lazyload_container:o,lazyload_data_attribute:"original",lazyload_skip_invisible:!0,lazyload_appear:null,lazyload_load:null,lazyload_placeholder:"data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="},init:function(t,e,l,a){n.lazyload.init(l,a)},remove:function(t,e,l){n.lazyload.remove(e,l)}}),n.addScrollStop=function(){var n=r.event.dispatch||r.event.handle,i=r.event.special,o="D"+ +new Date,l="D"+(+new Date+1);i.scrollstart={setup:function(t){function e(t){var e=arguments;l?clearTimeout(l):(t.type="scrollstart",n.apply(this,e)),l=setTimeout(function(){l=null},a.latency)}var l,a=r.extend({latency:i.scrollstop.latency},t);r(this).bind("scroll",e).data(o,e)},teardown:function(){r(this).unbind("scroll",r(this).data(o))}},i.scrollstop={latency:250,setup:function(t){function e(t){var e=this,l=arguments;a&&clearTimeout(a),a=setTimeout(function(){a=null,t.type="scrollstop",n.apply(e,l)},o.latency)}var a,o=r.extend({latency:i.scrollstop.latency},t);r(this).bind("scroll",e).data(l,e)},teardown:function(){r(this).unbind("scroll",r(this).data(l))}}}}(jQuery,window),
/*!
* Lazy Load - jQuery plugin for lazy loading images
*
* Copyright (c) 2007-2015 Mika Tuupola
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Project home:
* http://www.appelsiini.net/projects/lazyload
*
* Version: 1.9.7
*
*/
function(r,a,o,d){var f=r(a);r.fn.lazyload=function(t){var e,n=this,i={threshold:0,failure_limit:0,event:"scroll",effect:"show",container:a,data_attribute:"original",skip_invisible:!1,appear:null,load:null,placeholder:"data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="};function l(){var e=0;n.each(function(){var t=r(this);if((!i.skip_invisible||t.is(":visible"))&&!r.abovethetop(this,i)&&!r.leftofbegin(this,i))if(r.belowthefold(this,i)||r.rightoffold(this,i)){if(++e>i.failure_limit)return!1}else t.trigger("appear"),e=0})}return t&&(d!==t.failurelimit&&(t.failure_limit=t.failurelimit,delete t.failurelimit),d!==t.effectspeed&&(t.effect_speed=t.effectspeed,delete t.effectspeed),r.extend(i,t)),e=i.container===d||i.container===a?f:r(i.container),0===i.event.indexOf("scroll")&&e.bind(i.event,function(){return l()}),this.each(function(){var a=this,o=r(a);a.loaded=!1,o.attr("src")!==d&&!1!==o.attr("src")||o.is("img")&&o.attr("src",i.placeholder),o.one("appear",function(){if(!this.loaded){if(i.appear){var t=n.length;i.appear.call(a,t,i)}r("<img />").bind("load",function(){var t=o.attr("data-"+i.data_attribute);o.hide(),o.is("img")?o.attr("src",t):o.css("background-image",'url("'+t+'")'),o[i.effect](i.effect_speed),a.loaded=!0;var e=r.grep(n,function(t){return!t.loaded});if(n=r(e),i.load){var l=n.length;i.load.call(a,l,i)}}).attr("src",o.attr("data-"+i.data_attribute))}}),0!==i.event.indexOf("scroll")&&o.bind(i.event,function(){a.loaded||o.trigger("appear")})}),f.bind("resize",function(){l()}),/(?:iphone|ipod|ipad).*os 5/gi.test(navigator.appVersion)&&f.bind("pageshow",function(t){t.originalEvent&&t.originalEvent.persisted&&n.each(function(){r(this).trigger("appear")})}),r(o).ready(function(){l()}),this},r.belowthefold=function(t,e){return(e.container===d||e.container===a?(a.innerHeight?a.innerHeight:f.height())+f.scrollTop():r(e.container).offset().top+r(e.container).height())<=r(t).offset().top-e.threshold},r.rightoffold=function(t,e){return(e.container===d||e.container===a?f.width()+f.scrollLeft():r(e.container).offset().left+r(e.container).width())<=r(t).offset().left-e.threshold},r.abovethetop=function(t,e){return(e.container===d||e.container===a?f.scrollTop():r(e.container).offset().top)>=r(t).offset().top+e.threshold+r(t).height()},r.leftofbegin=function(t,e){return(e.container===d||e.container===a?f.scrollLeft():r(e.container).offset().left)>=r(t).offset().left+e.threshold+r(t).width()},r.inviewport=function(t,e){return!(r.rightoffold(t,e)||r.leftofbegin(t,e)||r.belowthefold(t,e)||r.abovethetop(t,e))},r.extend(r.expr[":"],{"below-the-fold":function(t){return r.belowthefold(t,{threshold:0})},"above-the-top":function(t){return!r.belowthefold(t,{threshold:0})},"right-of-screen":function(t){return r.rightoffold(t,{threshold:0})},"left-of-screen":function(t){return!r.rightoffold(t,{threshold:0})},"in-viewport":function(t){return r.inviewport(t,{threshold:0})},"above-the-fold":function(t){return!r.belowthefold(t,{threshold:0})},"right-of-fold":function(t){return r.rightoffold(t,{threshold:0})},"left-of-fold":function(t){return!r.rightoffold(t,{threshold:0})}})}(jQuery,window,document);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Widget: mark.js - updated 9/23/2016 (v2.27.7) */
!function(c){"use strict";var d=c.tablesorter;d.mark={init:function(r){if("function"==typeof c.fn.mark){var e,n=r.widgetOptions.mark_tsUpdate;r.$table.on("filterEnd.tsmark pagerComplete.tsmark"+(n?" "+n:""),function(e,t){d.mark.update(r,e.type===n?t:"")}),e="(?:<|=|>|\\||\"|\\'|\\s+(?:&&|-|"+(d.language.and||"and")+"|"+(d.language.or||"or")+"|"+(d.language.to||"to")+")\\s+)",d.mark.regex.filter=new RegExp(e,"gim")}else console.warn('Widget-mark not initialized: missing "jquery.mark.js"')},regex:{mark:/^mark_(.+)$/,pure:/^\/((?:\\\/|[^\/])+)\/([mig]{0,3})?$/},checkRegex:function(e){if(e instanceof RegExp){var t="".match(e);return null===t||t.length<5}return!1},cleanMatches:function(e){for(var t=[],r=e&&e.length||0;r--;)""!==e[r]&&(t[t.length]=e[r]);return t},ignoreColumns:function(e){for(var t=e.widgetOptions,r=e.columns,n=[];r--;)(t.mark_tsIgnore[r]||c(e.$headerIndexed[r]).hasClass("mark-ignore"))&&(n[n.length]=":nth-child("+(r+1)+")");return n.length?":not("+n.join(",")+")":""},update:function(o,e){var l={},g=o.widgetOptions,m=d.mark.regex,s=o.$table.find("tbody tr").unmark().not("."+(o.widgetOptions.filter_filteredRow||"filtered"));e=e||c.tablesorter.getFilters(o.$table),c.each(o.widgetOptions,function(e,t){var r=e.match(m.mark);r&&void 0!==r[1]&&(l[r[1]]=t)}),c.each(e,function(e,t){if(t&&!c(o.$headerIndexed[e]).hasClass("mark-ignore")&&!g.mark_tsIgnore[e]){var r=null,n=t,a=!1,i=e===o.columns?d.mark.ignoreColumns(o):":nth-child("+(e+1)+")";if(m.pure.test(t)){".*"===(n=m.pure.exec(t))[1]&&(n[1]="");try{r=new RegExp(n[1],"gim"),n=new RegExp(n[1],n[2])}catch(e){n=null}return void(d.mark.checkRegex(r)&&s.children(i).markRegExp(n,l))}n=0===t.indexOf("~")?(a=!0,t.replace(/~/g,"").split("")):(-1<t.indexOf("?")&&(a=!0,t=t.replace(/\?/g,"\\S{1}")),-1<t.indexOf("*")&&(a=!0,t=t.replace(/\*/g,"\\S*")),t.split(m.filter)),a&&n&&n.length?(n=new RegExp(d.mark.cleanMatches(n).join(".*"),"gm"),d.mark.checkRegex(n)&&s.children(i).markRegExp(n,l)):s.children(i).mark(d.mark.cleanMatches(n),l)}})}},d.addWidget({id:"mark",options:{mark_tsUpdate:"markUpdate",mark_tsIgnore:{}},init:function(e,t,r,n){d.mark.init(r,n)},remove:function(e,t){var r=t.widgetOptions.mark_tsUpdate;t.$table.off("filterEnd.tsmark pagerComplete.tsmark"+(r?" "+r:""))}})}(jQuery);return jQuery;}));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
!function(a){"use strict";var p=a.tablesorter,s=p.printTable={event:"printTable",basicStyle:"table, tr, td, th { border : solid 1px black; border-collapse : collapse; } td, th { padding: 2px; }",popupStyle:"width=500,height=300,scrollbars=1,resizable=1",init:function(t){t.$table.unbind(s.event).bind(s.event,function(){return s.process(t,t.widgetOptions),!1})},process:function(t,e){var i,n,r=a("<div/>").append(t.$table.clone()),o=s.basicStyle+"table { width: 100%; }."+(p.css.filterRow||"tablesorter-filter-row")+", ."+(e.filter_filteredRow||"filtered")+" { display: none; }."+(p.css.header||"tablesorter-header")+" { background-image: none !important; }@media print { .print_widget_hidden { display: none; } }";r.find("["+e.print_dataAttrib+"]").each(function(){(i=a(this)).text(i.attr(e.print_dataAttrib))}),n="data-"+(e.lazyload_data_attribute||"original"),r.find("img["+n+"]").each(function(){(i=a(this)).attr("src",i.attr(n))}),/^f/i.test(e.print_rows)?o+="tbody tr:not(."+(e.filter_filteredRow||"filtered")+") { display: table-row !important; }":/^a/i.test(e.print_rows)?o+="tbody tr { display: table-row !important; }":/^[.#:\[]/.test(e.print_rows)&&(o+="tbody tr"+e.print_rows+" { display: table-row !important; }"),/s/i.test(e.print_columns)&&t.selector&&p.hasWidget(t.table,"columnSelector")?o+=e.columnSelector_mediaquery&&t.selector.auto?"":t.selector.$style.text():/a/i.test(e.print_columns)&&(o+="td, th { display: table-cell !important; }"),o+=e.print_extraCSS,a.isFunction(e.print_callback)?e.print_callback(t,r,o):s.printOutput(t,r.html(),o)},printOutput:function(t,e,i){var n=t.widgetOptions,r=p.language,o=window.open("",n.print_title,s.popupStyle),a=n.print_title||t.$table.find("caption").text()||t.$table[0].id||document.title||"table",l=n.print_now?"":'<div class="print_widget_hidden"><a href="javascript:window.print();"><button type="button">'+r.button_print+'</button></a> <a href="javascript:window.close();"><button type="button">'+r.button_close+"</button></a><hr></div>";return o.document.write("<html><head><title>"+a+"</title>"+(n.print_styleSheet?'<link rel="stylesheet" href="'+n.print_styleSheet+'">':"")+"<style>"+i+"</style></head><body>"+l+e+"</body></html>"),o.document.close(),n.print_now&&setTimeout(function(){o.print(),o.close()},10),!0},remove:function(t){t.$table.off(s.event)}};p.language.button_close="Close",p.language.button_print="Print",p.addWidget({id:"print",options:{print_title:"",print_dataAttrib:"data-name",print_rows:"filtered",print_columns:"selected",print_extraCSS:"",print_styleSheet:"",print_now:!0,print_callback:null},init:function(t,e,i){s.init(i)},remove:function(t,e){s.remove(e)}})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,3 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
!function(u){"use strict";var h=u.tablesorter,w={init:function(e,t,l){var o,r=l.reflow_dataAttrib,a=l.reflow_headerAttrib,s=[];t.$table.addClass(l.reflow_className).off("refresh.tsreflow updateComplete.tsreflow2").on("refresh.tsreflow updateComplete.tsreflow2",function(){w.init(e,t,l)}),t.$headers.each(function(){o=u(this),s.push(u.trim(o.attr(a)||o.text()))}),t.$tbodies.children().each(function(){u(this).children().each(function(e){u(this).attr(r,s[e])})})},init2:function(e,t,l){var o,r,a,s,i,n,f=t.columns,c=l.reflow2_headerAttrib,d=[];for(t.$table.addClass(l.reflow2_className).off("refresh.tsreflow2 updateComplete.tsreflow2").on("refresh.tsreflow2 updateComplete.tsreflow2",function(){w.init2(e,t,l)}),a=0;a<f;a++)1<(s=t.$headers.filter('[data-column="'+a+'"]')).length?(i=[],s.each(function(){(o=u(this)).hasClass(l.reflow2_classIgnore)||i.push(o.attr(c)||o.text())})):i=[s.attr(c)||s.text()],d.push(i);i='<b class="'+t.selectorRemove.slice(1)+" "+l.reflow2_labelClass,t.$tbodies.children().each(function(){(r=h.processTbody(e,u(this),!0)).children().each(function(e){for(o=u(this),n=d[e].length,a=n-1;0<=a;)o.prepend(i+(0===a&&1<n?" "+l.reflow2_labelTop:"")+'">'+d[e][a]+"</b>"),a--}),h.processTbody(e,r,!1)})},remove:function(e,t,l){t.$table.removeClass(l.reflow_className)},remove2:function(e,t,l){t.$table.removeClass(l.reflow2_className)}};h.addWidget({id:"reflow",options:{reflow_className:"ui-table-reflow",reflow_headerAttrib:"data-name",reflow_dataAttrib:"data-title"},init:function(e,t,l,o){w.init(e,l,o)},remove:function(e,t,l){w.remove(e,t,l)}}),h.addWidget({id:"reflow2",options:{reflow2_className:"ui-table-reflow",reflow2_classIgnore:"ui-table-reflow-ignore",reflow2_headerAttrib:"data-name",reflow2_labelClass:"ui-table-cell-label",reflow2_labelTop:"ui-table-cell-label-top"},init:function(e,t,l,o){w.init2(e,l,o)},remove:function(e,t,l){w.remove2(e,t,l)}})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Widget: repeatHeaders - updated 9/23/2016 (v2.27.7) */
!function(n){"use strict";n.tablesorter.addWidget({id:"repeatHeaders",priority:10,options:{rowsToSkip:4},format:function(e,r,t){var a,o,d,i,s="";if(!t.repeatHeaders){for(s='<tr class="repeated-header '+r.selectorRemove.slice(1)+'">',a=0;a<r.columns;a++)s+="<th>"+n.trim(r.$headers.eq(a).html())+"</th>";t.repeatHeaders=s+"</tr>"}for(i=t&&t.rowsToSkip||4,r.$table.find("tr.repeated-header").remove(),d=(o=r.$tbodies.find("tr")).length,a=i;a<d;a+=i)o.eq(a).before(t.repeatHeaders)},remove:function(e,r,t){t.repeatHeaders="",r.$table.find("tr.repeated-header").remove()}})}(jQuery);return jQuery;}));

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Widget: saveSort - updated 2018-03-19 (v2.30.1) */
!function(o){"use strict";var v=o.tablesorter||{};function g(t){var s=v.storage(t.table,"tablesorter-savesort");return s&&s.hasOwnProperty("sortList")&&o.isArray(s.sortList)?s.sortList:[]}function S(t,s){return(s||g(t)).join(",")!==t.sortList.join(",")}v.addWidget({id:"saveSort",priority:20,options:{saveSort:!0},init:function(t,s,o,r){s.format(t,o,r,!0)},format:function(s,t,o,r){var a,e=t.$table,i=!1!==o.saveSort,n={sortList:t.sortList},l=v.debug(t,"saveSort");l&&(a=new Date),e.hasClass("hasSaveSort")?i&&s.hasInitialized&&v.storage&&S(t)&&(v.storage(s,"tablesorter-savesort",n),l&&console.log("saveSort >> Saving last sort: "+t.sortList+v.benchmark(a))):(e.addClass("hasSaveSort"),n="",v.storage&&(n=g(t),l&&console.log('saveSort >> Last sort loaded: "'+n+'"'+v.benchmark(a)),e.bind("saveSortReset",function(t){t.stopPropagation(),v.storage(s,"tablesorter-savesort","")})),r&&n&&0<n.length?t.sortList=n:s.hasInitialized&&n&&0<n.length&&S(t,n)&&v.sortOn(t,n))},remove:function(t,s){s.$table.removeClass("hasSaveSort"),v.storage&&v.storage(t,"tablesorter-savesort","")}})}(jQuery);return jQuery;}));

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Widget: sort2Hash (BETA) - updated 9/27/2017 (v2.29.0) */
!function(g){"use strict";var p=g.tablesorter||{},u=p.sort2Hash={init:function(e,t){var a,r,o,s,n=e.table,i=e.pager,h=p.hasWidget(n,"saveSort"),l=u.decodeHash(e,t,"sort");(l&&!h||l&&h&&t.sort2Hash_overrideSaveSort)&&u.convertString2Sort(e,t,l),p.hasWidget(e.table,"pager")&&(r=parseInt(u.decodeHash(e,t,"page"),10),o=i.page=r<0?0:r>i.totalPages?i.totalPages-1:r,s=i.size=parseInt(u.decodeHash(e,t,"size"),10)),p.hasWidget(n,"filter")&&(a=u.decodeHash(e,t,"filter"))&&(a=a.split(t.sort2Hash_separator),e.$table.one("tablesorter-ready",function(){setTimeout(function(){e.$table.one("filterEnd",function(){g(this).triggerHandler("pageAndSize",[o,s])}),(r=p.filter.equalFilters?p.filter.equalFilters(e,e.lastSearch,a):(e.lastSearch||[]).join("")!==(a||[]).join(""))||g.tablesorter.setFilters(n,a,!0)},100)})),a||e.$table.one("tablesorter-ready",function(){e.$table.triggerHandler("pageAndSize",[o,s])}),e.$table.on("sortEnd.sort2hash filterEnd.sort2hash pagerComplete.sort2Hash",function(){this.hasInitialized&&u.setHash(this.config,this.config.widgetOptions)})},getTableId:function(e,t){return t.sort2Hash_tableId||e.table.id||"table"+g("table").index(e.$table)},regexEscape:function(e){return e.replace(/([\.\^\$\*\+\-\?\(\)\[\]\{\}\\\|])/g,"\\$1")},convertString2Sort:function(e,t,a){for(var r,o,s,n,i,h,l=a.split(t.sort2Hash_separator),d=0,c=l.length,H=[];d<c;){if(o=l[d++],n=parseInt(o,10),isNaN(n)||n>e.columns)for(r=new RegExp("("+u.regexEscape(o)+")","i"),i=0;i<e.columns;i++)h=e.$headerIndexed[i],r.test(h.attr(t.sort2Hash_headerTextAttr))&&(o=i,i=e.columns);s=l[d++],void 0!==o&&void 0!==s&&(isNaN(s)&&(s=-1<s.indexOf(t.sort2Hash_directionText[1])?1:0),H.push([o,s]))}H.length&&(e.sortList=H)},convertSort2String:function(e,t){var a,r,o,s,n=[],i=e.sortList||[],h=i.length;for(a=0;a<h;a++)o=i[a][0],r=g.trim(e.$headerIndexed[o].attr(t.sort2Hash_headerTextAttr)),n.push(""!==r?encodeURIComponent(r):o),s=t.sort2Hash_directionText[i[a][1]],n.push(s);return n.join(t.sort2Hash_separator)},convertFilter2String:function(e,t){var a,r,o,s,n=[],i=e.sortList||[],h=i.length;for(a=0;a<h;a++)o=i[a][0],o=void 0!==(r=g.trim(e.$headerIndexed[o].attr(t.sort2Hash_headerTextAttr)))?encodeURIComponent(r):o,n.push(o),s=t.sort2Hash_directionText[i[a][1]],n.push(s);return n.join(t.sort2Hash_separator)},getParam:function(e,t,a){t=t||window.location.hash;var r=new RegExp("[\\?&]"+u.regexEscape(e)+"=([^&#]*)"),o=r.exec(t);return a?r:null===o?"":decodeURIComponent(o[1])},removeParam:function(e,t){t=t||window.location.hash;var a,r=u.getParam(e,t,!0),o=[],s=t.split("&"),n=s.length;for(a=0;a<n;a++)r.test("&"+s[a])||o.push(s[a]);return o.length?o.join("&"):""},encodeHash:function(e,t,a,r,o){var s=!1,n=u.getTableId(e,t);return"function"==typeof t.sort2Hash_encodeHash&&(s=t.sort2Hash_encodeHash(e,n,a,r,o||r)),!1===s&&(s="&"+a+"["+n+"]="+r),s},decodeHash:function(e,t,a){var r=!1,o=u.getTableId(e,t);return"function"==typeof t.sort2Hash_decodeHash&&(r=t.sort2Hash_decodeHash(e,o,a)),!1===r&&(r=u.getParam(a+"["+o+"]")),r||""},cleanHash:function(e,t,a,r){var o=!1,s=u.getTableId(e,t);return"function"==typeof t.sort2Hash_cleanHash&&(o=t.sort2Hash_cleanHash(e,s,a,r)),!1===o&&(o=u.removeParam(a+"["+s+"]",r)),o||""},setHash:function(a,r){var o="",s=window.location.hash,e=p.hasWidget(a.table,"pager"),t=p.hasWidget(a.table,"filter"),n=u.convertSort2String(a,r),i=t&&""!==a.lastSearch.join("")?a.lastSearch:[],h=encodeURIComponent(i.join(a.widgetOptions.sort2Hash_separator)),l={sort:n?u.encodeHash(a,r,"sort",n,a.sortList):"",page:e?u.encodeHash(a,r,"page",a.pager.page+1):"",size:e?u.encodeHash(a,r,"size",a.pager.size):"",filter:h?u.encodeHash(a,r,"filter",h,i):""};g.each(l,function(e,t){s=u.cleanHash(a,r,e,s),o+=t});var d=r.sort2Hash_hash,c=((window.location.hash||"").replace(d,"").length?s:d)+o;if(r.sort2Hash_replaceHistory){var H=window.location.href.split(d)[0];c[0]!==d&&(c=d+c),window.location.replace(H+c)}else window.location.hash=c}};p.addWidget({id:"sort2Hash",priority:60,options:{sort2Hash_hash:"#",sort2Hash_separator:"-",sort2Hash_headerTextAttr:"data-header",sort2Hash_directionText:[0,1],sort2Hash_overrideSaveSort:!1,sort2Hash_replaceHistory:!1,sort2Hash_tableId:null,sort2Hash_encodeHash:null,sort2Hash_decodeHash:null,sort2Hash_cleanHash:null},init:function(e,t,a,r){u.init(a,r)},remove:function(e,t){t.$table.off(".sort2hash")}})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,8 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! tablesorter tbody sorting widget (BETA) - 11/26/2016 (v2.28.0)
* Requires tablesorter v2.22.2+ and jQuery 1.4+
* by Rob Garrison
* Contributors: Chris Rogers
*/
!function(x){"use strict";var q=x.tablesorter;q.sortTbodies={init:function(o,r){var t,e,s,n,i,d=o.namespace+"sortTbody",a=o.$table.children("tbody"),b=a.length;for(r.sortTbody_original_serverSideSorting=o.serverSideSorting,r.sortTbody_original_cssInfoBlock=o.cssInfoBlock,o.cssInfoBlock=r.sortTbody_noSort,q.sortTbodies.setTbodies(o,r),t=0;t<b;t++)a.eq(t).attr("data-ts-original-order",t);for(o.$table.unbind("sortBegin updateComplete ".split(" ").join(d+" ")).bind("sortBegin"+d,function(){q.sortTbodies.sorter(o)}).bind("updateComplete"+d,function(){q.sortTbodies.setTbodies(o,r),q.updateCache(o,null,o.$tbodies)}).bind("sortEnd",function(){var t=r.sortTbody_primaryRow;r.sortTbody_lockHead&&t&&o.$table.find(t).each(function(){x(this).parents("tbody").prepend(this)})}),!x.isEmptyObject(o.parsers)&&o.$tbodies.length===a.length||(q.sortTbodies.setTbodies(o,r),q.updateCache(o,null,o.$tbodies)),b=(i=a.children("tr")).length,t=0;t<o.columns;t++){if(n=0,"numeric"===o.parsers[t].type)for(e=0;e<b;e++)s=q.getParsedText(o,i.eq(e).children()[t],t),n=Math.max(Math.abs(s)||0,n);o.$headerIndexed[t].attr("data-ts-col-max-value",n)}},setTbodies:function(t,o){t.$tbodies=t.$table.children("tbody").not("."+o.sortTbody_noSort)},sorter:function(m){var t=m.$table,o=m.widgetOptions;if(!0!==o.sortTbody_busy){o.sortTbody_busy=!0;var r=t.children("tbody").not("."+o.sortTbody_noSort),S=o.sortTbody_primaryRow||"tr:eq(0)",v=m.sortList||[],$=v.length;$&&(m.serverSideSorting=!o.sortTbody_sortRows,r.sort(function(t,o){var r,e,s,n,i,d,a,b,l,c,y,T=m.table,p=m.parsers,f=m.textSorter||"",u=x(t),g=x(o),h=u.find(S).children("td, th"),_=g.find(S).children("td, th");for(r=0;r<$;r++){if(a=v[r][0],s=0===v[r][1],e=q.getElementText(m,h.eq(a),a),b=p[a].format(e,T,h[a],a),e=q.getElementText(m,_.eq(a),a),l=p[a].format(e,T,_[a],a),m.sortStable&&b===l&&1===$)return u.attr("data-ts-original-order")-g.attr("data-ts-original-order");if(d=(n=/n/i.test(p&&p[a]&&p[a].type||""))&&m.strings[a]?(i=m.$headerIndexed[a].attr("data-ts-col-max-value")||179e306,n="boolean"==typeof q.string[m.strings[a]]?(s?1:-1)*(q.string[m.strings[a]]?-1:1):m.strings[a]&&q.string[m.strings[a]]||0,m.numberSorter?m.numberSorter(b,l,s,i,T):q["sortNumeric"+(s?"Asc":"Desc")](b,l,n,i,a,m)):(c=s?b:l,y=s?l:b,"function"==typeof f?f(c,y,s,a,T):"object"==typeof f&&f.hasOwnProperty(a)?f[a](c,y,s,a,T):q["sortNatural"+(s?"Asc":"Desc")](b,l,a,m)))return d}return u.attr("data-ts-original-order")-g.attr("data-ts-original-order")}),q.sortTbodies.restoreTbodies(m,o,r),o.sortTbody_busy=!1)}},restoreTbodies:function(t,o,r){var e,s,n,i,d,a,b,l=t.$table,c=!0,y=0;if(l.hide(),r.appendTo(l),i=(s=l.children("tbody")).length,d=(e=s.filter("."+o.sortTbody_noSort).appendTo(l)).length)for(;c&&y<d;){for(c=!1,a=0;a<d;a++)(b=i<=(b=parseInt(e.eq(a).attr("data-ts-original-order"),10))?i:b<0?0:b)!==e.eq(a).index()&&(c=!0,n=e.eq(a).detach(),i<=b?n.appendTo(l):0===b?n.prependTo(l):n.insertBefore(l.children("tbody:eq("+b+")")));y++}l.show()}},q.addWidget({id:"sortTbody",priority:40,options:{sortTbody_lockHead:!1,sortTbody_primaryRow:null,sortTbody_sortRows:!1,sortTbody_noSort:"tablesorter-no-sort-tbody"},init:function(t,o,r,e){q.sortTbodies.init(r,e)},remove:function(t,o,r){o.$table.unbind("sortBegin updateComplete ".split(" ").join(o.namespace+"sortTbody ")),o.serverSideSorting=r.sortTbody_original_serverSideSorting,o.cssInfoBlock=r.sortTbody_original_cssInfoBlock}})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! widget: staticRow - updated 10/31/2015 (v2.24.0) */
!function(p){"use strict";function s(t){var e,i,a,s,o,n=t.config;n&&(i=n.widgetOptions,n.$tbodies.each(function(){e=p(this).children(),o=e.length,e.filter(i.staticRow_class).each(function(){e=p(this),s=void 0!==(s=e.data(i.staticRow_index))?(a=parseFloat(s),/%/.test(s)?Math.round(a/100*o):a):e.index(),e.data(i.staticRow_data,s)})}))}var o=p.tablesorter;o.addWidget({id:"staticRow",options:{staticRow_class:".static",staticRow_data:"static-index",staticRow_index:"row-index",staticRow_event:"staticRowsRefresh"},init:function(t,e,i,a){s(t),i.$table.unbind(("updateComplete.tsstaticrows "+a.staticRow_event).replace(/\s+/g," ")).bind("updateComplete.tsstaticrows "+a.staticRow_event,function(){s(t),o.applyWidget(t)})},format:function(t,e,i){var a,s,o,n,c,d,r,l;e.$tbodies.each(function(){for(c=p.tablesorter.processTbody(t,p(this),!0),d=!0,o=0,r=c.children(i.staticRow_class),n=c.children("tr").length-1,l=r.length;d&&o<l;)d=!1,r.each(function(){a=p(this).data(i.staticRow_data),(a=n<=a?n:a<0?0:a)!==p(this).index()&&(d=!0,s=p(this).detach(),n<=a?s.appendTo(c):0===a?s.prependTo(c):s.insertBefore(c.find("tr:eq("+a+")")))}),o++;p.tablesorter.processTbody(t,c,!1)}),e.$table.triggerHandler("staticRowsComplete",t)},remove:function(t,e,i){e.$table.unbind(("updateComplete.tsstaticrows "+i.staticRow_event).replace(/\s+/g," "))}})}(jQuery);return jQuery;}));

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Widget: storage - updated 2018-03-18 (v2.30.0) */
!function(m,y,O){"use strict";var w=m.tablesorter||{};m.extend(!0,w.defaults,{fixedUrl:"",widgetOptions:{storage_fixedUrl:"",storage_group:"",storage_page:"",storage_storageType:"",storage_tableId:"",storage_useSessionStorage:""}}),w.storage=function(e,t,r,o){var s,a,i,g=!1,n={},p=(e=m(e)[0]).config,l=p&&p.widgetOptions,d=w.debug(p,"storage"),u=(o&&o.storageType||l&&l.storage_storageType).toString().charAt(0).toLowerCase(),S=u?"":o&&o.useSessionStorage||l&&l.storage_useSessionStorage,c=m(e),_=o&&o.id||c.attr(o&&o.group||l&&l.storage_group||"data-table-group")||l&&l.storage_tableId||e.id||m(".tablesorter").index(c),f=o&&o.url||c.attr(o&&o.page||l&&l.storage_page||"data-table-page")||l&&l.storage_fixedUrl||p&&p.fixedUrl||y.location.pathname;if("c"!==u&&(u="s"===u||S?"sessionStorage":"localStorage")in y)try{y[u].setItem("_tmptest","temp"),g=!0,y[u].removeItem("_tmptest")}catch(e){console.warn(u+" is not supported in this browser")}if(d&&console.log("Storage >> Using",g?u:"cookies"),m.parseJSON&&(n=g?m.parseJSON(y[u][t]||"null")||{}:(a=O.cookie.split(/[;\s|=]/),0!==(s=m.inArray(t,a)+1)&&m.parseJSON(a[s]||"null")||{})),void 0===r||!y.JSON||!JSON.hasOwnProperty("stringify"))return n&&n[f]?n[f][_]:"";n[f]||(n[f]={}),n[f][_]=r,g?y[u][t]=JSON.stringify(n):((i=new Date).setTime(i.getTime()+31536e6),O.cookie=t+"="+JSON.stringify(n).replace(/\"/g,'"')+"; expires="+i.toGMTString()+"; path=/")}}(jQuery,window,document);return jQuery;}));

View File

@@ -0,0 +1,7 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! tablesorter enable/disable sort & filter (BETA) - 11/10/2015 (v2.24.4)
* Requires tablesorter v2.24.4+ & jQuery 1.7+
* by Rob Garrison
*/
!function(){"use strict";var g=jQuery.tablesorter,s=g.toggleTS={init:function(e,l){l.toggleTS_isEnabled=!0,l.toggleTS_areDisabled={headers:[],filters:[]},e.$table.on("enable.toggleTS disable.toggleTS",function(e){s.toggle(this.config,this.config.widgetOptions,"enable"===e.type)})},toggle:function(e,l,t){if(l.toggleTS_isEnabled!==t){l.toggleTS_isEnabled=t;var i,s,o=e.$headers.length;for(i=0;i<o;i++)s=e.$headers.eq(i),g.setColumnSort(e,s,!t),g.setColumnAriaLabel(e,s,t);if(l.toggleTS_hideFilterRow)e.$table.find("."+g.css.filterRow).toggle(t);else if(g.hasWidget(e.$table,"filter"))for(o=e.$filters.length,i=0;i<o;i++)t&&!l.toggleTS_areDisabled.filters[i]?e.$filters.eq(i).find("input, select").removeClass(g.css.filterDisabled).prop("disabled",!1):t||((s=e.$filters.eq(i).find("input, select")).hasClass(g.css.filterDisabled)&&(l.toggleTS_areDisabled.filters[i]=!0),s.addClass(g.css.filterDisabled).prop("disabled",!0));l.filter_$externalFilters.toggleClass(g.css.filterDisabled,t).prop("disabled",!t)}"function"==typeof l.toggleTS_callback&&l.toggleTS_callback(e,t)}};g.addWidget({id:"toggle-ts",options:{toggleTS_hideFilterRow:!1,toggleTS_callback:null},init:function(e,l,t,i){s.init(t,i)},remove:function(e,l){l.$table.off("enable.toggleTS disable.toggleTS")}})}();return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Widget: uitheme - updated 2018-03-18 (v2.30.0) */
!function(A){"use strict";var N=A.tablesorter||{};N.themes={bootstrap:{table:"table table-bordered table-striped",caption:"caption",header:"bootstrap-header",sortNone:"",sortAsc:"",sortDesc:"",active:"",hover:"",icons:"",iconSortNone:"bootstrap-icon-unsorted",iconSortAsc:"glyphicon glyphicon-chevron-up",iconSortDesc:"glyphicon glyphicon-chevron-down",filterRow:"",footerRow:"",footerCells:"",even:"",odd:""},jui:{table:"ui-widget ui-widget-content ui-corner-all",caption:"ui-widget-content",header:"ui-widget-header ui-corner-all ui-state-default",sortNone:"",sortAsc:"",sortDesc:"",active:"ui-state-active",hover:"ui-state-hover",icons:"ui-icon",iconSortNone:"ui-icon-carat-2-n-s ui-icon-caret-2-n-s",iconSortAsc:"ui-icon-carat-1-n ui-icon-caret-1-n",iconSortDesc:"ui-icon-carat-1-s ui-icon-caret-1-s",filterRow:"",footerRow:"",footerCells:"",even:"ui-widget-content",odd:"ui-state-default"}},A.extend(N.css,{wrapper:"tablesorter-wrapper"}),N.addWidget({id:"uitheme",priority:10,format:function(e,o,t){var s,r,i,a,n,c,l,d,h,m,u,p,v,f=N.themes,b=o.$table.add(A(o.namespace+"_extra_table")),C=o.$headers.add(A(o.namespace+"_extra_headers")),w=o.theme||"jui",S=f[w]||{},g=A.trim([S.sortNone,S.sortDesc,S.sortAsc,S.active].join(" ")),j=A.trim([S.iconSortNone,S.iconSortDesc,S.iconSortAsc].join(" ")),D=N.debug(o,"uitheme");for(D&&(n=new Date),b.hasClass("tablesorter-"+w)&&o.theme===o.appliedTheme&&t.uitheme_applied||(t.uitheme_applied=!0,m=f[o.appliedTheme]||{},u=(v=!A.isEmptyObject(m))?[m.sortNone,m.sortDesc,m.sortAsc,m.active].join(" "):"",p=v?[m.iconSortNone,m.iconSortDesc,m.iconSortAsc].join(" "):"",v&&(t.zebra[0]=A.trim(" "+t.zebra[0].replace(" "+m.even,"")),t.zebra[1]=A.trim(" "+t.zebra[1].replace(" "+m.odd,"")),o.$tbodies.children().removeClass([m.even,m.odd].join(" "))),S.even&&(t.zebra[0]+=" "+S.even),S.odd&&(t.zebra[1]+=" "+S.odd),b.children("caption").removeClass(m.caption||"").addClass(S.caption),d=b.removeClass((o.appliedTheme?"tablesorter-"+(o.appliedTheme||""):"")+" "+(m.table||"")).addClass("tablesorter-"+w+" "+(S.table||"")).children("tfoot"),o.appliedTheme=o.theme,d.length&&d.children("tr").removeClass(m.footerRow||"").addClass(S.footerRow).children("th, td").removeClass(m.footerCells||"").addClass(S.footerCells),C.removeClass((v?[m.header,m.hover,u].join(" "):"")||"").addClass(S.header).not(".sorter-false").unbind("mouseenter.tsuitheme mouseleave.tsuitheme").bind("mouseenter.tsuitheme mouseleave.tsuitheme",function(e){A(this)["mouseenter"===e.type?"addClass":"removeClass"](S.hover||"")}),C.each(function(){var e=A(this);e.find("."+N.css.wrapper).length||e.wrapInner('<div class="'+N.css.wrapper+'" style="position:relative;height:100%;width:100%"></div>')}),o.cssIcon&&C.find("."+N.css.icon).removeClass(v?[m.icons,p].join(" "):"").addClass(S.icons||""),N.hasWidget(o.table,"filter")&&(r=function(){b.children("thead").children("."+N.css.filterRow).removeClass(v&&m.filterRow||"").addClass(S.filterRow||"")},t.filter_initialized?r():b.one("filterInit",function(){r()}))),s=0;s<o.columns;s++)c=o.$headers.add(A(o.namespace+"_extra_headers")).not(".sorter-false").filter('[data-column="'+s+'"]'),l=N.css.icon?c.find("."+N.css.icon):A(),(h=C.not(".sorter-false").filter('[data-column="'+s+'"]:last')).length&&(c.removeClass(g),l.removeClass(j),h[0].sortDisabled?l.removeClass(S.icons||""):(i=S.sortNone,a=S.iconSortNone,h.hasClass(N.css.sortAsc)?(i=[S.sortAsc,S.active].join(" "),a=S.iconSortAsc):h.hasClass(N.css.sortDesc)&&(i=[S.sortDesc,S.active].join(" "),a=S.iconSortDesc),c.addClass(i),l.addClass(a||"")));D&&console.log("uitheme >> Applied "+w+" theme"+N.benchmark(n))},remove:function(e,o,t,s){if(t.uitheme_applied){var r=o.$table,i=o.appliedTheme||"jui",a=N.themes[i]||N.themes.jui,n=r.children("thead").children(),c=a.sortNone+" "+a.sortDesc+" "+a.sortAsc,l=a.iconSortNone+" "+a.iconSortDesc+" "+a.iconSortAsc;r.removeClass("tablesorter-"+i+" "+a.table),t.uitheme_applied=!1,s||(r.find(N.css.header).removeClass(a.header),n.unbind("mouseenter.tsuitheme mouseleave.tsuitheme").removeClass(a.hover+" "+c+" "+a.active).filter("."+N.css.filterRow).removeClass(a.filterRow),n.find("."+N.css.icon).removeClass(a.icons+" "+l))}}})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,4 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
/*! Widget: vertical-group (BETA) - updated 12/13/2017 (v2.29.1) */
!function(h){"use strict";var G=h.tablesorter,f=G.css;function g(r){r.removeClass(f.verticalGroupHide+" "+f.verticalGroupShow)}function C(r,e,a){e.parent().removeClass(r.zebra[(a+1)%2]).addClass(r.zebra[a%2])}function r(r,e,a){var o=-1,i=r.tBodies[0].rows,t=G.hasWidget(r,"zebra"),l=[],s=[];if(!a.vertical_group_lock){if(a.vertical_group_lock=!0,""===(l=h.map(e.$headerIndexed,function(r){return r.hasClass(f.verticalGroupHeader)?1:""})).join(""))return g(h(i).find("."+f.verticalGroupHide+",."+f.verticalGroupShow)),void(a.vertical_group_lock=!1);for(var c=0;c<i.length;c++)for(var u=!1,v=0;v<e.columns;v++)if(l[v]&&i[c].cells[v]){var d=h(i[c].cells[v]),p=G.isValueInArray(v,e.sortList),n=d.html();p<0?g(d):u||n!==s[v]?0===p&&(u=!0,d.hasClass(f.verticalGroupShow)||d.addClass(f.verticalGroupShow),d.removeClass(f.verticalGroupHide),t&&C(a,d,p?o:++o)):(d.hasClass(f.verticalGroupHide)||d.addClass(f.verticalGroupHide),t&&C(a,d,o),d.removeClass(f.verticalGroupShow)),s[v]=n}else o++;a.vertical_group_lock=!1}}h.extend(G.css,{verticalGroupHeader:"tablesorter-vertical-group",verticalGroupHide:"tablesorter-vertical-group-hide",verticalGroupShow:"tablesorter-vertical-group-show"}),G.addWidget({id:"vertical-group",priority:99,init:r,format:r})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,3 @@
(function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery){
!function(r){"use strict";var i,a,o,n=r.tablesorter,l=!1,c=n.view={copyCaption:function(e,t){c.removeCaption(e,t),0<e.$table.find("caption").length&&r(t.view_caption).text(e.$table.find("caption").text())},removeCaption:function(e,t){r(t.view_caption).empty()},buildToolBar:function(t,o){c.removeToolBar(t,o),c.copyCaption(t,o);var n=r(o.view_toolbar);r.each(o.view_layouts,function(e,t){var i=o.view_switcher_class;e===o.view_layout&&(i+=" active");var a=r("<a>",{href:"#","class":i,"data-view-type":e,title:t.title});a.append(r("<i>",{"class":t.icon})),n.append(a)}),n.find("."+o.view_switcher_class).on("click",function(e){if(e.preventDefault(),r(this).hasClass("active"))return!1;n.find("."+o.view_switcher_class).removeClass("active"),r(this).addClass("active"),o.view_layout=r(this).attr("data-view-type"),!0===o.view_layouts[o.view_layout].raw?(c.remove(t,o),c.buildToolBar(t,o)):(!1===l&&c.hideTable(t,o),c.buildView(t,o))})},removeToolBar:function(e,t){r(t.view_toolbar).empty(),c.removeCaption(e,t)},buildView:function(e,t){c.removeView(e,t);var a=t.view_layouts[t.view_layout],o=r(a.container,{"class":t.view_layout});n.getColumnText(e.$table,0,function(e){var l=a.tmpl;r.each(r(e.$row).find("td"),function(e,t){var i={},a="{col"+e+"}";r.each(t.attributes,function(e,t){i[t.nodeName]=t.nodeValue});var o=r(t).html(),n=r("<span />").append(r("<span/>",i).append(o));l=l.replace(new RegExp(a,"g"),n.html()),a="{col"+e+":raw}",l=l.replace(new RegExp(a,"g"),r(t).text())});var i=r(l);r.each(e.$row[0].attributes,function(e,t){"class"===t.nodeName?i.attr(t.nodeName,i.attr(t.nodeName)+" "+t.nodeValue):i.attr(t.nodeName,t.nodeValue)}),o.append(i)}),r(t.view_container).append(o),e.$table.triggerHandler("viewComplete")},removeView:function(e,t){r(t.view_container).empty()},hideTable:function(e){i=e.$table.css("position"),a=e.$table.css("bottom"),o=e.$table.css("left"),e.$table.css({position:"absolute",top:"-10000px",left:"-10000px"}),l=!0},init:function(e,t){!1!==t.view_layout&&void 0!==t.view_layouts[t.view_layout]&&(!1===l&&c.hideTable(e,t),e.$table.on("tablesorter-ready",function(){c.buildToolBar(e,t),c.buildView(e,t)}))},remove:function(e,t){c.removeToolBar(e,t),c.removeView(e,t),e.$table.css({position:i,top:a,left:o}),l=!1}};n.addWidget({id:"view",options:{view_toolbar:"#ts-view-toolbar",view_container:"#ts-view",view_caption:"#ts-view-caption",view_switcher_class:"ts-view-switcher",view_layout:!1,view_layouts:{}},init:function(e,t,i,a){c.init(i,a)},remove:function(e,t,i){c.remove(t,i)}})}(jQuery);return jQuery;}));

View File

@@ -0,0 +1,505 @@
$(document).ready(function () {
$.tablesorter.addParser({
id: 'production_date',
is: function (s, table, cell, $cell) {
return false;
},
format: function (s, table, cell, cellIndex) {
return $(cell).find("input[id^=production-date]").val() || "1970-01-01";
},
parsed: false,
type: 'text'
});
$("#allTable").tablesorter({
sortList: [[13, 1]],
theme: 'blue',
widthFixed: true,
widgets: ['filter', 'zebra', 'stickyHeaders'],
fixedWidth: true,
widgetOptions: {
resizable: false,
filter_formatter: {
6: function ($cell, indx) {
return $.tablesorter.filterFormatter.select2($cell, indx, {
match: true
});
},
7: function ($cell, indx) {
return $.tablesorter.filterFormatter.select2($cell, indx, {
match: true
});
},
8: function ($cell, indx) {
return $.tablesorter.filterFormatter.select2($cell, indx, {
match: true
});
},
9: function ($cell, indx) {
return $.tablesorter.filterFormatter.select2($cell, indx, {
match: true
});
},
10: function ($cell, indx) {
return $.tablesorter.filterFormatter.select2($cell, indx, {
match: true
});
},
13: function ($cell, indx) {
return $.tablesorter.filterFormatter.select2($cell, indx, {
match: true
});
},
},
},
headers: {
17: { sorter: 'production_date' },
},
});
$("#allTable").bind('filterEnd', function (event, config) {
updateAllPositions();
localStorage.setItem('productBySales_filters', $.tablesorter.getFilters($('#allTable')));
});
$("#allTable").bind('sortEnd', function (event, config) {
updateAllPositions();
try {
localStorage.setItem('productBySales_sort',
$("#allTable")[0].config.sortList[0][0] + '|' + $("#allTable")[0].config.sortList[0][1]);
} catch { }
});
setTimeout(() => {
var filters = localStorage.getItem('productBySales_filters');
if (filters) {
$.tablesorter.setFilters($('#allTable'), filters.split(','), true);
}
var sort = localStorage.getItem('productBySales_sort');
if (sort) {
try {
var tmp = sort.split('|');
$("#allTable")[0].config.sortList = [[parseInt(tmp[0]), parseInt(tmp[1])]];
$.tablesorter.sortOn($("#allTable")[0].config, [[parseInt(tmp[0]), parseInt(tmp[1])]]);
} catch { }
}
}, 500);
$("#selectAll").click(function () {
if (this.checked) {
$(".allCheck").prop('checked', true);
} else {
$(".allCheck").prop('checked', false);
}
});
$("#orderComponents").click(orderComponents);
$("#orderRawMaterials").click(orderRawMaterials);
$("#createInsideOrder").click(createInsideOrder);
$("#toogleReadyProducts").click(() => {
if (SelectedTab == '2') {
showReadyProducts = !showReadyProducts;
showReadyProducts ? $("#toogleReadyProducts").val("Ukryj gotowe") : $("#toogleReadyProducts").val("Pokaz gotowe");
filterComponents();
} else if (SelectedTab == '3') {
showReadyProducts = !showReadyProducts;
showReadyProducts ? $("#toogleReadyProducts").val("Ukryj gotowe") : $("#toogleReadyProducts").val("Pokaz gotowe");
filterRawMaterials();
} else if (SelectedTab == '1') {
$("#hideReadyProducts").val($("#hideReadyProducts").val() === "true" ? "false" : "true");
$("#submitForm").trigger("click");
}
});
$("#toogleServices").click(() => {
showServices = !showServices;
showServices ? $("#toogleServices").val("Ukryj usługi") : $("#toogleServices").val("Pokaz usługi");
if (SelectedTab == '2') {
filterComponents();
} else if (SelectedTab == '3') {
filterRawMaterials();
}
});
$("#hideReadyProducts").val() === "false" ? $("#toogleReadyProducts").val("Ukryj gotowe") : $("#toogleReadyProducts").val("Pokaz gotowe");
updateAllPositions();
});
let showReadyProducts = true;
let showServices = true;
var SelectedTab = "";
var TabsMainBlock = false;
var Components;
var RawMaterials;
var OrderTypes
function SetTab(tab_name) {
if (TabsMainBlock) return;
var TabMenu = document.getElementById('groupTabsPanels');
var tabs = TabMenu.getElementsByTagName('li');
for (i = 0; i < tabs.length; i++) {
if ((tab_name + '_menu') === tabs[i].id) {
tabs[i].className = 'active';
tabs[i].getElementsByTagName('a')[0].className = 'current';
} else {
tabs[i].className = '';
tabs[i].getElementsByTagName('a')[0].className = '';
}
}
var prev = document.getElementById(SelectedTab);
var curr = document.getElementById(tab_name);
prev.style.display = 'none';
curr.style.display = '';
SelectedTab = tab_name;
showReadyProducts = true;
showServices = true;
$("#toogleReadyProducts").val("Ukryj gotowe");
$("#toogleServices").val("Ukryj usługi");
if (SelectedTab == '3') {
getRawMaterials();
$("#toogleReadyProducts").show();
$("#toogleServices").show();
}
if (SelectedTab == '2') {
getComnponents();
$("#toogleReadyProducts").show();
$("#toogleServices").show();
}
if (SelectedTab == '1') {
$("#toogleServices").hide();
$("#hideReadyProducts").val() === "false" ? $("#toogleReadyProducts").val("Ukryj gotowe") : $("#toogleReadyProducts").val("Pokaz gotowe");
}
}
function getComnponents() {
var ids = [];
$('input.allCheck:checkbox:checked').each(function () {
// check if this element is visible on site
if ($(this).parent().parent().css('display') === 'table-row') {
ids.push($(this).val());
}
});
if (ids.length === 0) {
alert('Wybierz pozycje zamówień');
SetTab('1');
return;
}
showLoader();
var url = $(location).attr('href') + "&to_pdf=1&ajaxAction=getComponents";
$.ajax({
method: 'post',
url: url,
data: {
ids
},
success: function (data) {
var result = JSON.parse(data);
Components = result;
drawComponents(result);
updateComponentsPositions();
hideLoader();
},
error: function () {
alert('Błąd ładowania komponentów');
hideLoader();
}
});
}
function drawComponents(data) {
$("#componentsTableContainer").html(componentsTablePrototype());
data.forEach((el, index) => {
var tr = $("<tr></tr>");
tr.append("<td><input type=\"checkbox\" value=" + el.productId + " class=\"componentCheck\" /></td>");
tr.append("<td>" + (index + 1) + "</td>");
tr.append("<td><a target=\"_blank\" href=\"index.php?module=EcmProducts&action=DetailView&record=" + el.productId + "\">" + el.productCode + "</a></td>");
tr.append("<td title=\"" + el.productFullName +"\">" + el.productName + "</td>");
tr.append("<td id=\"qty-" + el.productId + "\">" + el.productQty + "</td>");
tr.append("<td>" + el.productUnit + "</td>");
tr.append("<td id=\"state-" + el.productId + "\">" + el.productStockState + "</td>");
tr.append("<td id=\"ordered-" + el.productId + "\">" + el.productOrdered + "</td>");
tr.append("<td><a target=\"_blank\" href=\"index.php?module=Accounts&action=DetailView&record=" + el.productVendorId + "\">" + el.productVendorName + "</a></td>");
var orders = "<td>";
el.orders.forEach((o) => {
orders += "<a target=\"_blank\" href=\"index.php?module=EcmPurchaseOrders&action=DetailView&record=" + o.orderId + "\">" + o.orderNr + "</a>";
if (o.orderDeliveryDate.length) {
orders += "&nbsp;(" + o.orderDeliveryDate + ")&nbsp;";
}
});
orders += "</td>";
tr.append(orders);
$("#componentsTable > tbody").append(tr);
});
$("#componentsTable").tablesorter({
theme: 'blue',
widthFixed: true,
widgets: ['filter', 'stickyHeaders'],
});
$("#componentsTable").bind('filterEnd', function (event, config) {
updateComponentsPositions();
});
$("#componentsTable").bind('sortEnd', function (event, config) {
updateComponentsPositions();
$('#componentsTable tfoot').find("td").each(function () {
$(this).css('background-color', 'white');
})
});
$("#selectAllComponents").attr('checked', false);
$("#selectAllComponents").click(function () {
if (this.checked) {
$(".componentCheck").prop('checked', true);
} else {
$(".componentCheck").prop('checked', false);
}
});
}
function filterComponents() {
let filtered = Components;
if (!showReadyProducts) {
filtered = filtered.filter(x => x.productOrdered + x.productStockState < x.productQty)
}
if (!showServices) {
filtered = filtered.filter(x => x.productGroupKS != 4);
}
drawComponents(filtered);
updateComponentsPositions();
}
function getRawMaterials() {
var ids = [];
$('input.allCheck:checkbox:checked').each(function () {
ids.push($(this).val());
});
if (ids.length === 0) {
alert('Wybierz pozycje zamówień');
SetTab('1');
return;
}
var cids = [];
$('input.componentCheck:checkbox:checked').each(function () {
cids.push($(this).val());
});
if (cids.length === 0) {
alert('Wybierz komponenty');
SetTab('2');
return;
}
showLoader();
var url = $(location).attr('href') + "&to_pdf=1&ajaxAction=getRawMaterials";
$.ajax({
method: 'post',
url: url,
data: {
ids,
cids
},
success: function (data) {
console.log(data);
var result = JSON.parse(data);
RawMaterials = result;
drawRawMaterials(result);
updateRawMaterialsPositions();
hideLoader();
},
error: function () {
alert('Błąd ładowania surowców');
hideLoader();
}
});
}
function drawRawMaterials(data) {
$("#rawMaterialsTableContainer").html(rawMaterialsTablePrototype());
data.forEach((el, index) => {
var tr = $("<tr></tr>");
tr.append("<td><input type=\"checkbox\" value=" + el.productId + " class=\"rawMaterialCheck\" /></td>");
tr.append("<td>" + (index + 1) + "</td>");
tr.append("<td><a target=\"_blank\" href=\"index.php?module=EcmProducts&action=DetailView&record=" + el.productId + "\">" + el.productCode + "</a></td>");
tr.append("<td title=\""+ el.productFullName +"\">" + el.productName + "</td>");
tr.append("<td id=\"qty-" + el.productId + "\">" + el.productQty + "</td>");
tr.append("<td>" + el.productUnit + "</td>");
tr.append("<td id=\"state-" + el.productId + "\">" + el.productStockState + "</td>");
tr.append("<td id=\"ordered-" + el.productId + "\">" + el.productOrdered + "</td>");
tr.append("<td><a target=\"_blank\" href=\"index.php?module=Accounts&action=DetailView&record=" + el.productVendorId + "\">" + el.productVendorName + "</a></td>");
var orders = "<td>";
el.orders.forEach((o) => {
orders += "<a target=\"_blank\" href=\"index.php?module=EcmPurchaseOrders&action=DetailView&record=" + o.orderId + "\">" + o.orderNr + "</a>";
if (o.orderDeliveryDate.length) {
orders += "&nbsp;(" + o.orderDeliveryDate + ")&nbsp;";
}
});
orders += "</td>";
tr.append(orders);
$("#rawMaterialsTable > tbody").append(tr);
});
$("#rawMaterialsTable").tablesorter({
theme: 'blue',
widthFixed: true,
widgets: ['filter', 'stickyHeaders'],
});
$("#rawMaterialsTable").bind('filterEnd', function (event, config) {
updateRawMaterialsPositions();
});
$("#rawMaterialsTable").bind('sortEnd', function (event, config) {
updateRawMaterialsPositions();
$('#rawMaterialsTable tfoot').find("td").each(function () {
$(this).css('background-color', 'white');
})
});
$("#selectAllRawMaterials").attr('checked', false);
$("#selectAllRawMaterials").click(function () {
if (this.checked) {
$(".rawMaterialCheck").prop('checked', true);
} else {
$(".rawMaterialCheck").prop('checked', false);
}
});
}
function filterRawMaterials() {
let filtered = RawMaterials;
if (!showReadyProducts) {
filtered = filtered.filter(x => x.productOrdered + x.productStockState < x.productQty)
}
if (!showServices) {
filtered = filtered.filter(x => x.productGroupKS != 4);
}
drawRawMaterials(filtered);
updateRawMaterialsPositions();
}
function orderComponents() {
var ids = [];
$('input.componentCheck:checkbox:checked').each(function () {
ids.push($(this).val());
});
if (ids.length === 0) {
alert('Wybierz komponenty');
return;
} else {
var toOrder = [];
ids.forEach(el => {
const qty = parseFloat($("#qty-" + el).html().trim());
const state = parseFloat($("#state-" + el).html().trim());
const ordered = parseFloat($("#ordered-" + el).html().trim());
toOrder.push(el + "|" + (qty - state - ordered));
});
$("#componentsToOrder").val(toOrder.join('*'));
$("#orderComponentsForm").submit();
}
}
function createInsideOrder() {
var ids = [];
$('input.allCheck:checkbox:checked').each(function () {
ids.push($(this).val());
});
if (ids.length === 0) {
alert('Wybierz pozycje zamówień');
return;
}
var products = [];
ids.forEach(el => {
const qty = parseFloat($("#productQty-" + el).html().trim());
const id = $("#productId-" + el).val();
products.push(id + "|" + qty);
});
$("#insideOrderProducts").val(products.join('*'));
$("#createInsideOrderForm").submit();
}
function orderRawMaterials() {
var ids = [];
$('input.rawMaterialCheck:checkbox:checked').each(function () {
ids.push($(this).val());
});
if (ids.length === 0) {
alert('Wybierz surowce');
return;
} else {
var toOrder = [];
ids.forEach(el => {
const qty = parseFloat($("#qty-" + el).html().trim());
const state = parseFloat($("#state-" + el).html().trim());
const ordered = parseFloat($("#ordered-" + el).html().trim());
toOrder.push(el + "|" + (qty - state - ordered));
});
$("#rawMaterialsToOrder").val(toOrder.join('*'));
$("#orderRawMaterialsForm").submit();
}
}
function saveProductionDate(id) {
$.ajax({
method: 'get',
url: $(location).attr('href') + "&to_pdf=1&ajaxAction=saveProductionDate&itemId=" + id + "&date=" + $("#production-date-" + id).val(),
});
}
function editComment(positionId) {
$("#edit-" + positionId).css("display", "none");
$("#description-" + positionId).css("display", "none");
$("#descriptionInput-" + positionId).css("display", "inline");
$("#descriptionInput-" + positionId).select();
$("#save-" + positionId).css("display", "inline-block");
}
function saveComment(id) {
$("#edit-" + id).css("display", "inline-block");
$("#description-" + id).css("display", "inline");
$("#descriptionInput-" + id).css("display", "none");
$("#save-" + id).css("display", "none");
$.ajax({
method: 'get',
url: $(location).attr('href') + "&to_pdf=1&ajaxAction=saveProductDescription&itemId=" + id + "&description=" + $("#descriptionInput-" + id).val(),
success: function (data) {
$("#description-" + id).html($("#descriptionInput-" + id).val());
},
});
}
function showLoader() {
$.blockUI({
css: {
border: 'none',
padding: '15px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .5,
'font-weight': 'bold',
'font-size': '16px',
color: '#fff',
},
message: "Pobieranie danych..."
});
}
function hideLoader() {
$.unblockUI();
}
function updateAllPositions() {
var i = 0;
var sum = 0;
$("#allTable").find("tr").each(function (index) {
if (index >= 2 && $(this).css('display') === 'table-row' && $(this).find("td").length > 3) {
i++;
sum += parseFloat($($(this).find("td")[4]).html().trim());
$($(this).find("td")[1]).html(i);
}
});
$("#allTableSum").html(sum);
}
function updateComponentsPositions() {
var i = 0;
var sum = 0;
$("#componentsTable").find("tr").each(function (index) {
if (index >= 2 && $(this).css('display') === 'table-row' && $(this).find("td").length > 3) {
i++;
sum += parseFloat($($(this).find("td")[4]).html().trim());
$($(this).find("td")[1]).html(i);
}
});
$("#componentsTableSum").html(Math.ceil(sum));
}
function updateRawMaterialsPositions() {
var i = 0;
var sum = 0;
$("#rawMaterialsTable").find("tr").each(function (index) {
if (index >= 2 && $(this).css('display') === 'table-row' && $(this).find("td").length > 3) {
i++;
sum += parseFloat($($(this).find("td")[4]).html().trim());
$($(this).find("td")[1]).html(i);
}
});
$("#rawMaterialsTableSum").html(Math.ceil(sum));
}
function componentsTablePrototype() {
return '<table id="componentsTable"><thead><tr><th class="filter-false"><input type="checkbox" id="selectAllComponents" /></th><th>Pozycja</th><th>Indeks</th><th>Nazwa</th><th>Ilość</th><th>JM.</th><th>Stan</th><th>Zamówiono</th><th>Dostawca</th><th>Zamówienie</th></tr></thead><tbody aria-live="polite" aria-relevant="all"></tbody><tfoot><tr><td colspan=4></td><td id="componentsTableSum">0</td><td colspan="5"></td></tr></tfoot></table>'
}
function rawMaterialsTablePrototype() {
return '<table id="rawMaterialsTable"><thead><tr><th class="filter-false"><input type="checkbox" id="selectAllRawMaterials" /></th><th>Pozycja</th><th>Indeks</th><th>Nazwa</th><th>Ilość</th><th>JM.</th><th>Stan</th><th>Zamówiono</th><th>Dostawca</th><th>Zamówienie</th></tr></thead><tbody aria-live="polite" aria-relevant="all"></tbody><tfoot><tr><td colspan=4></td><td id="rawMaterialsTableSum">0</td><td colspan="5"></td></tr></tfoot></table>'
}

View File

@@ -0,0 +1,357 @@
<?
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
$db = $GLOBALS['db'];
global $app_list_strings;
if (isset($_GET['date_from'])) {
$dateFrom = date("Y-m-d", strtotime($_GET['date_from']));
} else {
$dateFrom = date("Y-m-d");
}
if (isset($_GET['date_to'])) {
if (strlen($_GET['date_to']) > 0) {
$dateTo = date("Y-m-d", strtotime($_GET['date_to']));
}
} else {
$dateTo = date("Y-m-d", strtotime("+ 1 month"));
}
if (!isset($_GET['hideReadyProducts'])) {
$_GET['hideReadyProducts'] = "false";
}
if (!isset($_GET['ajaxAction'])) {
$allQuery = "SELECT s.id, s.document_no, s.status, s.parent_name, s.parent_id, s.send_date, s.type,
s.register_date, s.delivery_date, si.code, si.name, si.ecmproduct_id, si.description,
si.quantity, p.vendor_part_no as kind, p.brand, p.part_no as size, p.shape,
ss.quantity as stockState, si.id as item_id, s.shipping_address_name, si.production_date
FROM ecmsaleitems AS si
INNER JOIN ecmsales AS s
ON s.id = si.ecmsale_id
INNER JOIN ecmproducts AS p
ON si.ecmproduct_id = p.id
LEFT JOIN ecmstockstates AS ss
ON ss.product_id = si.ecmproduct_id AND ss.stock_id = 'c7afd71a-4c3a-bde4-138d-4acaee1644e4'
WHERE s.delivery_date > '$dateFrom' AND s.status IN ('s10', 's20', 's30')";
if (is_array($_GET['exclude']) && count($_GET['exclude']) > 0) {
foreach ($_GET['exclude'] as $name) {
if (strlen($name) > 0) {
$allQuery .= " AND s.parent_name NOT LIKE '%$name%'";
}
}
}
if (is_array($_GET['excludeType']) && count($_GET['excludeType']) > 0) {
foreach ($_GET['excludeType'] as $type) {
if (strlen($type) > 0) {
if ($type == 'other') {
$allQuery .= " AND s.type NOT IN ('b2b', 'interval_order')";
} else {
$allQuery .= " AND s.type != '$type'";
}
}
}
}
$typesWhere = "";
if (strlen($dateTo) > 0) {
$allQuery .= " AND s.delivery_date < '$dateTo'";
$typesWhere = " AND s.delivery_date < '$dateTo'";
} else {
$allQuery .= " OR s.delivery_date IS NULL";
$typesWhere = " OR s.delivery_date IS NULL";
}
$allQuery .= " ORDER BY s.delivery_date ASC, s.register_date ASC, s.document_no ASC";
$rows = $db->query($allQuery);
$allData = array();
$i = 0;
while ($r = $db->fetchByAssoc($rows)) {
$row = array();
$i++;
$row['position'] = $i;
$row['productName'] = strlen($r['name']) > 55 ? substr($r['name'], 0, 55) . "..." : $r['name'];
$row['productFullName'] = $r['name'];
$row['productCode'] = strlen($r['code']) > 20 ? substr($r['code'], 0, 20) . "..." : $r['code'];
$row['productFullCode'] = $r['code'];
$row['productId'] = $r['ecmproduct_id'];
$row['productQty'] = $r['quantity'];
$row['productKind'] = $r['kind'];
$row['productSize'] = $r['size'];
$row['productShape'] = $app_list_strings['ecmproducts_shape_dom'][$r['shape']];
$row['productBrand'] = $app_list_strings['ecmproducts_brand_dom'][$r['brand']];
$row['orderNo'] = $r['document_no'];
$row['orderId'] = $r['id'];
$row['orderStatus'] = $app_list_strings['ecmsales_status_dom'][$r['status']];
$row['orderParent'] = $r['parent_name'];
$row['orderParentId'] = $r['parent_id'];
$row['orderRegisterDate'] = $r['register_date'];
$row['orderDeliveryDate'] = $r['delivery_date'];
$row['orderSendDate'] = $r['send_date'];
$row['orderItemId'] = $r['item_id'];
$row['description'] = strlen($r['description']) > 0 ? substr($r['description'], 0, 30) : '';
$row['fullDescription'] = $r['description'];
$row['shippingTo'] = ($r['shipping_address_name'] == 'Adres korespondencyjny' ? '' : $r['shipping_address_name']);
$row['productionDate'] = $r['production_date'];
$row['productStockState'] = $r['stockState'] | 0;
if ($_GET['hideReadyProducts'] == "false" || $row['productQty'] > $row['productStockState']) {
$allData[] = $row;
}
}
$orderTypes = [];
$res = $db->query("SELECT distinct s.type FROM ecmsales AS s WHERE s.delivery_date > '$dateFrom' $typesWhere");
while ($r = $db->fetchByAssoc($res)) {
$orderTypes[] = $r['type'];
}
$types = [];
foreach ($app_list_strings['ecmsales_type_dom'] as $key => $value) {
if (in_array($key, $orderTypes)) {
$types[$key] = $value;
}
}
$smarty = new Sugar_Smarty();
$smarty->assign("exclude", $_GET['exclude']);
$smarty->assign("excludeType", $_GET['excludeType']);
$smarty->assign("allData", $allData);
$smarty->assign("dateFrom", $GLOBALS['timedate']->to_display_date($dateFrom));
$smarty->assign("dateTo", $GLOBALS['timedate']->to_display_date($dateTo));
$smarty->assign("types", $types);
$smarty->assign("hideReadyProducts", $_GET['hideReadyProducts']);
echo $smarty->display('modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.tpl');
} else {
switch ($_GET['ajaxAction']) {
case 'getComponents':
echo getComponents($_POST['ids'], $dateFrom, $dateTo);
break;
case 'getRawMaterials':
echo getRawMaterials($_POST['ids'], $_POST['cids']);
case 'saveProductionDate':
saveProductionDate($_GET['itemId'], $_GET['date']);
break;
case 'saveProductDescription':
saveProductDescription($_GET['itemId'], $_GET['description']);
break;
}
}
// helpers
function findProduct($array, $value)
{
for ($i = 0; $i < count($array); $i++) {
if ($array[$i]['productId'] == $value) {
return $i;
}
}
return -1;
}
function getComponents($ids, $dateFrom, $dateTo)
{
$db = $GLOBALS['db'];
global $app_list_strings;
$idsString = join("','", $ids);
$productsQuery = "SELECT si.ecmproduct_id, SUM(si.quantity) as quantity
FROM ecmsaleitems AS si
INNER JOIN ecmsales AS s
ON s.id = si.ecmsale_id
WHERE si.id IN ('" . $idsString . "')
GROUP BY si.ecmproduct_id";
$rows = $db->query($productsQuery);
$componentsData = array();
while ($r = $db->fetchByAssoc($rows)) {
$componentsQuery = "SELECT p.code, p.name, c.quantity, p.unit_id, c.ecmcomponent_id, ss.quantity as stockState, p.group_ks
FROM ecmproductcomponents as c
INNER JOIN ecmproducts AS p
ON p.id = c.ecmcomponent_id
LEFT JOIN ecmstockstates AS ss
ON ss.product_id = p.id AND ss.stock_id = '368479db-22c5-0220-3a14-4bc426b1c709'
WHERE c.ecmproduct_id = '" . $r['ecmproduct_id'] . "'";
$crows = $db->query($componentsQuery);
while ($cr = $db->fetchByAssoc($crows)) {
$exists = findProduct($componentsData, $cr['ecmcomponent_id']);
if ($exists > -1) {
$componentsData[$exists]['productQty'] += $r['quantity'] * $cr['quantity'];
} else {
$ordered = $db->fetchByAssoc($db->query("SELECT SUM(poi.quantity) as ordered, GROUP_CONCAT(poi.ecmpurchaseorder_id SEPARATOR '|') AS orders
FROM ecmpurchaseorderitems as poi
INNER JOIN ecmpurchaseorders as po
ON poi.ecmpurchaseorder_id = po.id AND (po.status='registered' OR po.status='accepted') AND po.deleted=0
WHERE poi.deleted=0 AND poi.ecmproduct_id = '" . $cr['ecmcomponent_id'] . "'"));
$orders = array();
$ordersIds = explode('|', $ordered['orders']);
$ordersRes = $db->query("SELECT id, document_no, delivery_date FROM ecmpurchaseorders WHERE id IN ('" . join("','", $ordersIds) . "') ORDER BY date_entered DESC");
while ($o = $db->fetchByAssoc($ordersRes)) {
$orders[] = array(
'orderId' => $o['id'],
'orderNr' => $o['document_no'],
'orderDeliveryDate' => isset($o['delivery_date']) ? explode(' ', $o['delivery_date'])[0] : ''
);
}
$vendor = $db->fetchByAssoc($db->query("SELECT d.parent_id, a.name
FROM ecmstockdocinitems AS i
INNER JOIN ecmstockdocins AS d
ON d.id = i.ecmstockdocin_id
INNER JOIN accounts AS a
ON a.id = d.parent_id
WHERE i.ecmproduct_id = '" . $cr['ecmcomponent_id'] . "'
ORDER BY d.register_date DESC
LIMIT 0,1"));
$row = array();
$row['productId'] = $cr['ecmcomponent_id'];
$row['productName'] = strlen($cr['name']) > 55 ? substr($cr['name'], 0, 55) . "..." : $cr['name'];
$row['productFullName'] = $cr['name'];
$row['productCode'] = strlen($cr['code']) > 20 ? substr($cr['code'], 0, 20) . "..." : $cr['code'];
$row['productFullCode'] = $cr['code'];
$row['productUnit'] = $app_list_strings['ecmproducts_unit_dom'][$cr['unit_id']];
$row['productOrdered'] = (!empty($ordered['ordered'])) ? $ordered['ordered'] : 0;
$row['productVendorName'] = $vendor ? $vendor['name'] : '';
$row['productVendorId'] = $vendor ? $vendor['parent_id'] : '';
$row['productQty'] = $r['quantity'] * $cr['quantity'];
$row['productGroupKS'] = $cr['group_ks'];
$row['orders'] = $orders;
$row['productStockState'] = (!empty($cr['stockState'])) ? $cr['stockState'] : 0;
$componentsData[] = $row;
}
}
}
echo json_encode($componentsData);
}
function getRawMaterials($ids, $cids)
{
$db = $GLOBALS['db'];
global $app_list_strings;
$idsString = join("','", $ids);
$cidsString = join("','", $cids);
$productsQuery = "SELECT si.ecmproduct_id, SUM(si.quantity) as quantity
FROM ecmsaleitems AS si
INNER JOIN ecmsales AS s
ON s.id = si.ecmsale_id
WHERE si.id IN ('$idsString')
GROUP BY si.ecmproduct_id";
$prows = $db->query($productsQuery);
$rawMaterialsData = array();
while ($p = $db->fetchByAssoc($prows)) {
$componentsQuery = "SELECT c.ecmcomponent_id, c.quantity
FROM ecmproductcomponents as c
WHERE c.ecmproduct_id = '" . $p['ecmproduct_id'] . "' AND c.ecmcomponent_id IN ('$cidsString')";
$crows = $db->query($componentsQuery);
while ($c = $db->fetchByAssoc($crows)) {
// szukamy komponentów wdal
$componentRawMaterials = getProductRawMaterials($c['ecmcomponent_id'], $c['quantity']);
foreach ($componentRawMaterials as $material) {
$product = $db->fetchByAssoc($db->query("
SELECT p.id, p.code, p.name, p.group_ks, p.unit_id, ss.quantity as stockState
FROM ecmproducts AS p
LEFT JOIN ecmstockstates AS ss
ON ss.product_id = p.id AND ss.stock_id = '368479db-22c5-0220-3a14-4bc426b1c709'
WHERE p.id='" . $material['ecmproduct_id'] . "'
"));
$ordered = $db->fetchByAssoc($db->query("SELECT SUM(poi.quantity) as ordered, GROUP_CONCAT(poi.ecmpurchaseorder_id SEPARATOR '|') AS orders
FROM ecmpurchaseorderitems as poi
INNER JOIN ecmpurchaseorders as po
ON poi.ecmpurchaseorder_id = po.id AND (po.status='registered' OR po.status='accepted') AND po.deleted=0
WHERE poi.deleted=0 AND poi.ecmproduct_id = '" . $material['ecmproduct_id'] . "'"));
$orders = array();
$ordersIds = explode('|', $ordered['orders']);
$ordersRes = $db->query("SELECT id, document_no, delivery_date FROM ecmpurchaseorders WHERE id IN ('" . join("','", $ordersIds) . "') ORDER BY date_entered DESC");
while ($o = $db->fetchByAssoc($ordersRes)) {
$orders[] = array(
'orderId' => $o['id'],
'orderNr' => $o['document_no'],
'orderDeliveryDate' => isset($o['delivery_date']) ? explode(' ', $o['delivery_date'])[0] : ''
);
}
$vendor = $db->fetchByAssoc($db->query("SELECT d.parent_id, a.name
FROM ecmstockdocinitems AS i
INNER JOIN ecmstockdocins AS d
ON d.id = i.ecmstockdocin_id
INNER JOIN accounts AS a
ON a.id = d.parent_id
WHERE i.ecmproduct_id = '" . $material['ecmproduct_id'] . "'
ORDER BY d.register_date DESC
LIMIT 0,1"));
$row = array();
$row['productId'] = $product['id'];
$row['productName'] = strlen($product['name']) > 55 ? substr($product['name'], 0, 55) . "..." : $product['name'];
$row['productFullName'] = $product['name'];
$row['productCode'] = strlen($product['code']) > 20 ? substr($product['code'], 0, 20) . "..." : $product['code'];
$row['productFullCode'] = $product['code'];
$row['productUnit'] = $app_list_strings['ecmproducts_unit_dom'][$product['unit_id']];
$row['productOrdered'] = (!empty($ordered['ordered'])) ? $ordered['ordered'] : 0;
$row['productVendorName'] = $vendor ? $vendor['name'] : '';
$row['productVendorId'] = $vendor ? $vendor['parent_id'] : '';
$row['productQty'] = $p['quantity'] * $material['quantity'];
$row['productGroupKS'] = $product['group_ks'];
$row['orders'] = $orders;
$row['productStockState'] = (!empty($product['stockState'])) ? $product['stockState'] : 0;
$rawMaterialsData[] = $row;
}
}
}
// group rawMaterialsData by productId and sum quantity and ordered
$tmp = array_reduce($rawMaterialsData, function ($carry, $item) {
if (isset($carry[$item['productId']])) {
$carry[$item['productId']]['productQty'] += $item['productQty'];
} else {
$carry[$item['productId']] = $item;
}
return $carry;
}, array());
// flat tmp array
$rawMaterialsData = array_values($tmp);
echo json_encode($rawMaterialsData);
}
function saveProductionDate($itemId, $date)
{
$db = $GLOBALS['db'];
$date = date("Y-m-d", strtotime($date));
if ($date == '1970-01-01') {
$db->query("UPDATE ecmsaleitems SET production_date=NULL WHERE id='$itemId'");
} else {
$db->query("UPDATE ecmsaleitems SET production_date='$date' WHERE id='$itemId'");
}
}
function saveProductDescription($itemId, $description)
{
$db = $GLOBALS['db'];
$description = mysql_escape_string($description);
$db->query("UPDATE ecmsaleitems SET description='$description' WHERE id='$itemId'");
}
function getProductRawMaterials($productId, $quantity)
{
$db = $GLOBALS['db'];
$response = array();
$componentsQuery = "SELECT c.ecmcomponent_id, c.quantity
FROM ecmproductcomponents as c
WHERE c.ecmproduct_id = '$productId'";
$crows = $db->query($componentsQuery);
if ($crows->num_rows == 0) {
return array(
array(
'ecmproduct_id' => $productId,
'quantity' => $quantity
)
);
} else {
while ($c = $db->fetchByAssoc($crows)) {
$response = array_merge($response, getProductRawMaterials($c['ecmcomponent_id'], $quantity * $c['quantity']));
}
return $response;
}
}

View File

@@ -0,0 +1,293 @@
<script type="text/javascript" src="modules/EcmReports/javascript/jquery.js"></script>
<link rel="stylesheet" href="modules/EcmReports/BimIT-Reports/lib/tablesorter-2.31.3/dist/css/theme.blue.min.css">
<script type="text/javascript"
src="modules/EcmReports/BimIT-Reports/lib/tablesorter-2.31.3/dist/js/jquery.tablesorter.js"></script>
<script type="text/javascript"
src="modules/EcmReports/BimIT-Reports/lib/tablesorter-2.31.3/dist/js/jquery.tablesorter.widgets.js">
</script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/3.4.6/select2.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/3.4.6/select2.min.js"></script>
<script type="text/javascript"
src="modules/EcmReports/BimIT-Reports/lib/tablesorter-2.31.3/dist/js/widgets/widget-filter-formatter-select2.min.js">
</script>
<script type="text/javascript" src="modules/EcmReports/javascript/jquery.blockUI.js"></script>
<script type="text/javascript" src="modules/EcmReports/BimIT-Reports/productsBySales/productsBySales.js"></script>
<!-- HEADER -->
<table id="tableMenu" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<img src="themes/Sugar5/images/CaseReports.gif" style="margin-top: 3px; margin-right: 3px;" width="16"
height="16">
</td>
<td>
<h2>Produkcja</h2>
</td>
</tr>
</table>
<!-- SEARCH -->
<form action="index.php" method="get" name="searchProductBySales">
<input type="hidden" name="module" value="EcmReports" />
<input type="hidden" name="action" value="index" />
<input type="hidden" name="reportName" value="productsBySales" />
<input type="hidden" name="hideReadyProducts" id="hideReadyProducts" value="{$hideReadyProducts}" />
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td class="dataLabel" width="5%" nowrap="nowrap">
Data wysyłki: od
&nbsp;
<input id="date_from" name="date_from" type="text" maxlength="10" size="11" tabindex="" title=""
value="{$dateFrom}" autocomplete="off">
<img id="date_from_trigger" src="themes/default/images/jscalendar.gif">
<script language="JavaScript" type="text/javascript">
Calendar.setup ({ldelim}
inputField: "date_from",
daFormat: "%d.%m.%Y",
button: "date_from_trigger",
singleClick: true,
dateStr: "",
step: 1
{rdelim}
);
</script>
&nbsp;
do
&nbsp;
<input autocomplete="off" name="date_to" id="date_to" value="{$dateTo}" title="" tabindex="" size="11"
maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_to_trigger">
<script language="JavaScript" type="text/javascript">
Calendar.setup ({ldelim}
inputField: "date_to",
daFormat: "%d.%m.%Y",
button: "date_to_trigger",
singleClick: true,
dateStr: "",
step: 1
{rdelim}
);
</script>
&nbsp;&nbsp;
Wyklucz:&nbsp;
<select name="exclude[]" size="3" style="width: 150px" multiple="true">
<option></option>
<option value="Media Markt" {if @in_array('Media Markt', $exclude)}selected="selected" {/if}>Media
Markt</option>
<option value="TwinPol" {if @in_array('TwinPol', $exclude)}selected="selected" {/if}>TwinPol
</option>
<option value="Euro-net" {if @in_array('Euro-net', $exclude)}selected="selected" {/if}>Euro-net
</option>
<option value="Carrefour" {if @in_array('Carrefour', $exclude)}selected="selected" {/if}>Carrefour
</option>
</select>
&nbsp;&nbsp;
<select name="excludeType[]" size="3" style="width: 150px" multiple="true">
<option></option>
{foreach from=$types key=k item=v}
<option value="{$k}" {if @in_array($k, $excludeType)}selected="selected" {/if}>{$v}
</option>
{/foreach}
</select>
<input class="button" id="submitForm" name="submit" value="Wykonaj" type="submit">
<input class="button" id="toogleReadyProducts" value="Ukryj gotowe" type="button">
<input class="button" id="toogleServices" value="Ukryj usługi" type="button" style="display: none">
</td>
</tr>
</tbody>
</table>
</form>
<!-- TAB MENU -->
<ul class="subpanelTablist" style="margin-top:10px;" id="groupTabsPanels">
<li class="active" id="1_menu">
<script language="javascript">
{literal}
var set1 = function() { SetTab('1'); };
SelectedTab = '1';
{/literal}
</script>
<a class="current" href="javascript:set1();">Produkty</a>
</li>
<li class="" id="2_menu">
<script language="javascript">
{literal}
var set2 = function() { SetTab('2'); };
{/literal}
</script>
<a class="" href="javascript:set2();">Komponenty</a>
</li>
<li class="" id="3_menu">
<script language="javascript">
{literal}
var set3 = function() { SetTab('3'); };
{/literal}
</script>
<a class="" href="javascript:set3();">Surowce</a>
</li>
</ul>
<!-- TABS -->
<div id="1">
<br>
<input class="button" name="submit" value="Utwórz zamówienie wewnętrzne" type="button" id="createInsideOrder" />
<br>
<form action="index.php?module=EcmInsideOrders&action=EditView&fromProductsBySalesReport=true" method="post"
target="_blank" id="createInsideOrderForm">
<input id="insideOrderProducts" name="insideOrderProducts" type="hidden" value="" />
</form>
<table id="allTable">
<thead>
<tr>
<th class="filter-false"><input type="checkbox" id="selectAll" /></th>
<th>Pozycja</th>
<th>Indeks</th>
<th>Nazwa</th>
<th>Ilość</th>
<th>Stan</th>
<th>ZS E5</th>
<th>Status</th>
<th>Zamawiający</th>
<th>Odbiorca</th>
<th>Rodzaj</th>
<th>Rozmiar</th>
<th>Forma</th>
<th>Marka</th>
<th>Data rejestracji</th>
<th>Data wysyłki</th>
<th>Data dostawy</th>
<th>Data produkcji</th>
<th>Uwagi</th>
</tr>
</thead>
<tbody aria-live="polite" aria-relevant="all">
{foreach from=$allData item=ROW name=loop}
{if $smarty.foreach.loop.index % 2 == 1}
<tr>
{else}
<tr style="background-color: #e6e6e6;" role="row">
{/if}
<td>
<input type="checkbox" value="{$ROW.orderItemId}" class="allCheck" />
<input type="hidden" id="productId-{$ROW.orderItemId}" value="{$ROW.productId}" />
</td>
<td>
{$ROW.position}
</td>
<td>
<a title="{$ROW.productFullCode}" target="_blank" href="index.php?module=EcmProducts&action=DetailView&record={$ROW.productId}">
{$ROW.productCode}
</a>
</td>
<td title="{$ROW.productFullName}">
{$ROW.productName}
</td>
<td id="productQty-{$ROW.orderItemId}">
{$ROW.productQty}
</td>
<td>
{$ROW.productStockState}
</td>
<td>
<a target="_blank" href="index.php?module=EcmSales&action=DetailView&record={$ROW.orderId}">
{$ROW.orderNo}
</a>
</td>
<td>
{$ROW.orderStatus}
</td>
<td>
<a target="_blank" href="index.php?module=Accounts&action=DetailView&record={$ROW.orderParentId}">
{$ROW.orderParent}
</a>
</td>
<td>
{$ROW.shippingTo}
</td>
<td>
{$ROW.productKind}
</td>
<td>
{$ROW.productSize}
</td>
<td>
{$ROW.productShape}
</td>
<td>
{$ROW.productBrand}
</td>
<td>
{$ROW.orderRegisterDate}
</td>
<td>
{$ROW.orderSendDate}
</td>
<td>
{$ROW.orderDeliveryDate}
</td>
<td>
<input id="production-date-{$ROW.orderItemId}" name="production-date-{$ROW.orderItemId}" type="text"
maxlength="10" size="11" tabindex="" title="" value="{$ROW.productionDate}" autocomplete="off"
id="production-date-{$ROW.orderItemId}" onchange="saveProductionDate('{$ROW.orderItemId}')">
<img id="production-date-trigger-{$ROW.orderItemId}" src="themes/default/images/jscalendar.gif"
style="width: 13px;">
<script language="JavaScript" type="text/javascript">
Calendar.setup ({ldelim}
inputField: "production-date-{$ROW.orderItemId}",
daFormat: "%Y-%m-%d",
button: "production-date-trigger-{$ROW.orderItemId}",
singleClick: true,
dateStr: "",
step: 1
{rdelim}
);
</script>
</td>
<td title="{$ROW.fullDescription}">
<div id="edit-{$ROW.orderItemId}" class="ui-icon ui-icon-pencil"
onclick="editComment('{$ROW.orderItemId}')" style="display: inline-block;"></div>
<div id="save-{$ROW.orderItemId}" class="ui-icon ui-icon-check"
onclick="saveComment('{$ROW.orderItemId}')" style="display: none;"></div>
<div id="description-{$ROW.orderItemId}" style="display: inline; width: 300px;">{$ROW.description}
</div>
<input id="descriptionInput-{$ROW.orderItemId}" type="text" value="{$ROW.fullDescription}"
style="width: 300px; display: none;" />
</td>
</tr>
{/foreach}
</tbody>
<tfoot>
<tr>
<td colspan=4></td>
<td id="allTableSum">0</td>
<td colspan="13"></td>
</tr>
</tfoot>
</table>
</div>
<div id="2" style="display: none">
<br>
<input class="button" name="submit" value="Zamówienie - komponenty" type="button" id="orderComponents" />
<br>
<form action="index.php?module=EcmPurchaseOrders&action=EditView&fromProductsBySalesReport=true" method="post"
target="_blank" id="orderComponentsForm">
<input id="componentsToOrder" name="componentsToOrder" type="hidden" value="" />
</form>
<div id="componentsTableContainer">
</div>
</div>
<div id="3" style="display: none">
<br>
<input class="button" name="submit" value="Zamówienie - surowce" type="button" id="orderRawMaterials" />
<br>
<form action="index.php?module=EcmPurchaseOrders&action=EditView&fromProductsBySalesReport=true" method="post"
target="_blank" id="orderRawMaterialsForm">
<input id="rawMaterialsToOrder" name="rawMaterialsToOrder" type="hidden" value="" />
</form>
<div id="rawMaterialsTableContainer">
</div>
</div>

701
modules/EcmReports/CreateXLS.php Executable file
View File

@@ -0,0 +1,701 @@
<?php
set_time_limit(999999);
$year=$_GET['year'];
function sum($year,$account_id=""){
if($account_id)$accw=" and parent_id='".$account_id."'";
else $accw="";
$w=$GLOBALS['db']->query("select id,type,register_date,ecminvoiceout_id,currency_value from ecminvoiceouts where register_date like '".$year."%'".$accw." and deleted='0'");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
if(!$r['currency_value'])$currency_value=1;
else $currency_value=$r['currency_value'];
$d=explode("-",$r['register_date']);
$dat=$year."-".$d[1];
$ww=$GLOBALS['db']->query("select price,ecmvat_value,quantity,purchase_price,ecmproduct_id,ecminvoiceoutitem_id from ecminvoiceoutitems where ecminvoiceout_id='".$r['id']."' and deleted='0'");
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
if($r['type']!="correct"){
$rrr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select product_active,product_category_id,carton_volume_meter as cvm,pieces_per_carton as ppc from ecmproducts where id='".$rr['ecmproduct_id']."'"));
$rr['c']=$rrr['product_category_id'];
$rr['ppc']=$rrr['ppc'];
$rr['cvm']=$rrr['cvm'];
$pprice=$rr['purchase_price'];
$total_netto=$currency_value*$rr['price']*$rr['quantity'];
$total_qty=$rr['quantity'];
$total_pur=$pprice*$rr['quantity'];
$sum['all']+=$total_netto;
$sum['all_qty']+=$total_qty;
$sum['all_pur']+=$total_pur;
if($rr['ppc']>0)$sum['all_cbm']+=$rr['quantity']*($rr['cvm']/$rr['ppc']);
$sum[$dat]['all']+=$total_netto;
$sum[$dat]['all_qty']+=$total_qty;
$sum[$dat]['all_pur']+=$total_pur;
if($rr['ppc']>0)$sum[$dat]['all_cbm']+=$rr['quantity']*($rr['cvm']/$rr['ppc']);
$sum[$dat]['category_'.$rr['c']]+=$total_netto;
$sum[$dat]['category_qty_'.$rr['c']]+=$total_qty;
$sum[$dat]['category_pur_'.$rr['c']]+=$total_pur;
if($rr['ppc']>0)$sum[$dat]['category_cbm_'.$rr['c']]+=$rr['quantity']*($rr['cvm']/$rr['ppc']);
$sum[$dat]['product_'.$rr['ecmproduct_id']]+=$total_netto;
$sum[$dat]['product_qty_'.$rr['ecmproduct_id']]+=$total_qty;
$sum[$dat]['product_pur_'.$rr['ecmproduct_id']]+=$total_pur;
if($rr['ppc']>0)$sum[$dat]['product_cbm_'.$rr['ecmproduct_id']]+=$rr['quantity']*($rr['cvm']/$rr['ppc']);
$sum[$year]['category_sum_'.$rr['c']]+=$total_netto;
$sum[$year]['category_qty_sum_'.$rr['c']]+=$total_qty;
$sum[$year]['category_pur_sum_'.$rr['c']]+=$total_pur;
if($rr['ppc']>0)$sum[$year]['category_cbm_sum_'.$rr['c']]+=$rr['quantity']*($rr['cvm']/$rr['ppc']);
$sum[$year]['product_sum_'.$rr['ecmproduct_id']]+=$total_netto;
$sum[$year]['product_qty_sum_'.$rr['ecmproduct_id']]+=$total_qty;
$sum[$year]['product_pur_sum_'.$rr['ecmproduct_id']]+=$total_pur;
if($rr['ppc']>0)$sum[$year]['product_cbm_sum_'.$rr['ecmproduct_id']]+=$rr['quantity']*($rr['cvm']/$rr['ppc']);
}
else{
$rrr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select product_active,product_category_id,carton_volume_meter as cvm,pieces_per_carton as ppc from ecmproducts where id='".$rr['ecmproduct_id']."'"));
//if($rrr['product_active']!=1)continue;
$rr['c']=$rrr['product_category_id'];
$rr['ppc']=$rrr['ppc'];
$rr['cvm']=$rrr['cvm'];
/*if($r['type']=="correct"){
$rrr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select purchase_price from ecminvoiceoutitems where ecmproduct_id='".$rr['ecmproduct_id']."' and ecminvoiceout_id='".$r['ecminvoiceout_id']."' and deleted='0'"));
$pprice=$rrr['purchase_price'];
}
else*/
$rrrr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select price,quantity,purchase_price from ecminvoiceoutitems where id='".$rr['ecminvoiceoutitem_id']."'"));
$pprice=$rrrr['purchase_price'];
$total_netto=$currency_value*$rr['price']*$rr['quantity']-$currency_value*$rrrr['price']*$rrrr['quantity'];
$total_qty=$rr['quantity']-$rrrr['quantity'];
$total_pur=$pprice*($rr['quantity']-$rrrr['quantity']);
$sum['all']+=$total_netto;
$sum['all_qty']+=$total_qty;
$sum['all_pur']+=$total_pur;
if($rr['ppc']>0)$sum['all_cbm']+=($rr['quantity']-$rrrr['quantity'])*($rr['cvm']/$rr['ppc']);
$sum[$dat]['all']+=$total_netto;
$sum[$dat]['all_qty']+=$total_qty;
$sum[$dat]['all_pur']+=$total_pur;
if($rr['ppc']>0)$sum[$dat]['all_cbm']+=($rr['quantity']-$rrrr['quantity'])*($rr['cvm']/$rr['ppc']);
$sum[$dat]['category_'.$rr['c']]+=$total_netto;
$sum[$dat]['category_qty_'.$rr['c']]+=$total_qty;
$sum[$dat]['category_pur_'.$rr['c']]+=$total_pur;
if($rr['ppc']>0)$sum[$dat]['category_cbm_'.$rr['c']]+=($rr['quantity']-$rrrr['quantity'])*($rr['cvm']/$rr['ppc']);
$sum[$dat]['product_'.$rr['ecmproduct_id']]+=$total_netto;
$sum[$dat]['product_qty_'.$rr['ecmproduct_id']]+=$total_qty;
$sum[$dat]['product_pur_'.$rr['ecmproduct_id']]+=$total_pur;
if($rr['ppc']>0)$sum[$dat]['product_cbm_'.$rr['ecmproduct_id']]+=($rr['quantity']-$rrrr['quantity'])*($rr['cvm']/$rr['ppc']);
$sum[$year]['category_sum_'.$rr['c']]+=$total_netto;
$sum[$year]['category_qty_sum_'.$rr['c']]+=$total_qty;
$sum[$year]['category_pur_sum_'.$rr['c']]+=$total_pur;
if($rr['ppc']>0)$sum[$year]['category_cbm_sum_'.$rr['c']]+=($rr['quantity']-$rrrr['quantity'])*($rr['cvm']/$rr['ppc']);
$sum[$year]['product_sum_'.$rr['ecmproduct_id']]+=$total_netto;
$sum[$year]['product_qty_sum_'.$rr['ecmproduct_id']]+=$total_qty;
$sum[$year]['product_pur_sum_'.$rr['ecmproduct_id']]+=$total_pur;
if($rr['ppc']>0)$sum[$year]['product_cbm_sum_'.$rr['ecmproduct_id']]+=($rr['quantity']-$rrrr['quantity'])*($rr['cvm']/$rr['ppc']);
}
}
}
return $sum;
}
if(!$year)$year=(int)date("Y");
if($year==date(Y)){
$mmm=(int)date("m")-1;
}
else $mmm=12;
set_include_path('include/PHPExcel/');
include 'PHPExcel.php';
include 'PHPExcel/Writer/Excel2007.php';
include 'PHPExcel/IOFactory.php';
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("E5 CRM");
$objPHPExcel->getProperties()->setLastModifiedBy("E5 CRM");
$objPHPExcel->getProperties()->setTitle("Office 2007 PRICEBOOK");
$objPHPExcel->getProperties()->setSubject("Office 2007 PRICEBOOK");
$objPHPExcel->getProperties()->setDescription("PRICEBOOK");
$alf1="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for($i=0;$i<strlen($alf1);$i++)$alf[$i]=$alf1[$i];
$alf[26]="AA";
$alf[27]="AB";
$alf[28]="AC";
$alf[29]="AD";
$alf[30]="AE";
$alf[31]="AF";
$alf[32]="AG";
$alf[33]="AH";
$alf[34]="AI";
$alf[35]="AJ";
$alf[36]="AK";
$alf[37]="AL";
$alf[38]="AM";
$alf[39]="AN";
$alf[40]="AO";
$alf[41]="AP";
$alf[42]="AQ";
$alf[43]="AR";
$alf[44]="AS";
$alf[45]="AT";
$alf[46]="AU";
$alf[47]="AV";
$alf[48]="AW";
$alf[49]="AX";
$alf[50]="AY";
$alf[51]="AZ";
$alf[52]="BA";
$alf[53]="BB";
$alf[54]="BC";
$alf[55]="BD";
$alf[56]="BE";
$alf[]="BF";
$alf[]="BG";
$alf[]="BH";
$alf[]="BI";
$alf[]="BJ";
$alf[]="BK";
$alf[]="BL";
$alf[]="BM";
$alf[]="BN";
$alf[]="BO";
$alf[]="BP";
$alf[]="BQ";
$alf[]="BR";
$alf[]="BS";
$alf[]="BT";
$alf[]="BU";
$alf[]="BV";
$alf[]="BW";
$alf[]="BX";
$alf[]="BY";
$alf[]="BZ";
$alf[]="CA";
$alf[]="CB";
$alf[]="CC";
$alf[]="CD";
$alf[]="CE";
$alf[]="CF";
$alf[]="CG";
$alf[]="CH";
$alf[]="CI";
$alf[]="CJ";
$alf[]="CK";
$alf[]="CL";
$alf[]="CM";
$alf[]="CN";
$alf[]="CO";
$alf[]="CP";
$alf[]="CQ";
$alf[]="CR";
$alf[]="CS";
$alf[]="CT";
$alf[]="CU";
$alf[]="CV";
$alf[]="CW";
$alf[]="CX";
$alf[]="CY";
$alf[]="CZ";
$alf[]="DA";
$alf[]="DB";
$alf[]="DC";
$alf[]="DD";
$alf[]="DE";
$alf[]="DF";
$alf[]="DG";
$alf[]="DH";
$alf[]="DI";
$alf[]="DJ";
$alf[]="DK";
$alf[]="DL";
$alf[]="DM";
$alf[]="DN";
$alf[]="DO";
$alf[]="DP";
$alf[]="DQ";
$alf[]="DR";
$alf[]="DS";
$alf[]="DT";
$alf[]="DU";
$alf[]="DV";
$alf[]="DW";
$alf[]="DX";
$alf[]="DY";
$alf[]="DZ";
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(80);
for($i=3;$i<=100;$i++){
$objPHPExcel->getActiveSheet()->getColumnDimension($alf[$i])->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension($alf[$i+1])->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension($alf[$i+2])->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension($alf[$i+3])->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension($alf[$i+4])->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension($alf[$i+5])->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension($alf[$i+6])->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension($alf[$i+7])->setWidth(20);
}
$objPHPExcel->getActiveSheet()->SetCellValue('A1','Name');
$objPHPExcel->getActiveSheet()->SetCellValue('B1','Inventory');
$objPHPExcel->getActiveSheet()->SetCellValue('C1','Inv value');
$objPHPExcel->getActiveSheet()->SetCellValue('D1','CBM');
$months=array("01","02","03","04","05","06","07","08","09","10","11","12");
$months_names=array("01"=>"January","02"=>"February","03"=>"March","04"=>"April","05"=>"May","06"=>"June","07"=>"July","08"=>"August","09"=>"September","10"=>"October","11"=>"November","12"=>"December");
for($i=0;$i<12;$i++){
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+4].'1',$months_names[$months[$i]]." ".$year);
}
$m=2;
for($i=0;$i<=12;$i++){
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+4].'2','Qty');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+5].'2','Value');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+6].'2','Margin');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+7].'2','CBM');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+8].'2','Avg sale');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+9].'2','Avg qty');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+10].'2','Pred. sale');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+11].'2','Pred. qty');
}
$GLOBALS['db']->query("set names utf8");
/*function sum($year,$c,$all,$acc,$active=""){
if($acc)$ah="ecminvoiceouts.parent_name like '".$acc."' and ";
else $ah="";
if($all)$wh="";
else $wh=" and ecmproducts.product_category_id='".$c."'";
if(!$active)$aa="";
elseif($active=="inactive")$aa=" and ecmproducts.product_active='0'";
else $aa=" and ecmproducts.product_active='1'";
$ww=$GLOBALS['db']->query("select ecmproducts.id as ecmproduct_id,ecmproducts.carton_volume_meter as cvm,ecmproducts.pieces_per_carton as ppc,ecminvoiceouts.register_date as d,ecminvoiceoutitems.purchase_price as purchase_price,ecminvoiceoutitems.price as price,ecminvoiceoutitems.quantity as quantity,ecminvoiceoutitems.ecmproduct_id as ecmproduct_id from ecminvoiceoutitems inner join ecminvoiceouts on ecminvoiceouts.id=ecminvoiceoutitems.ecminvoiceout_id inner join ecmproducts on ecmproducts.id=ecminvoiceoutitems.ecmproduct_id where ".$ah."ecminvoiceouts.register_date like '".$year."%' and ecminvoiceoutitems.deleted='0'".$wh." and ecminvoiceouts.type!='correct'".$aa);
echo mysql_error();
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
$d=explode("-",$rr['d']);
$dat=$year."-".$d[1];
$sum['all']+=$rr['price']*$rr['quantity'];
$_SESSION['EcmReports_sum_all']+=$rr['price']*$rr['quantity'];
$sum['all_qty']+=$rr['quantity'];
$_SESSION['EcmReports_sum_all_qty']+=$rr['quantity'];
$sum['all_pur']+=$rr['purchase_price']*$rr['quantity'];
$_SESSION['EcmReports_sum_all_pur']+=$rr['purchase_price']*$rr['quantity'];
if($rr['ppc']>0){
$sum['all_cbm']+=$rr['quantity']*($rr['cvm']/$rr['ppc']);
$_SESSION['EcmReports_sum_all_cbm']+=$rr['quantity']*($rr['cvm']/$rr['ppc']);
}
$sum[$dat]['all']+=$rr['price']*$rr['quantity'];
$sum[$dat]['all_qty']+=$rr['quantity'];
$sum[$dat]['all_pur']+=$rr['purchase_price']*$rr['quantity'];
if($rr['ppc']>0)$sum[$dat]['all_cbm']+=$rr['quantity']*($rr['cvm']/$rr['ppc']);
if(!$all){
$sum[$dat]['category_'.$c]+=$rr['price']*$rr['quantity'];
$sum[$dat]['category_qty_'.$c]+=$rr['quantity'];
$sum[$dat]['category_pur_'.$c]+=$rr['purchase_price']*$rr['quantity'];
if($rr['ppc']>0)$sum[$dat]['category_cbm_'.$c]+=$rr['quantity']*($rr['cvm']/$rr['ppc']);
$sum[$dat]['product_'.$rr['ecmproduct_id']]+=$rr['price']*$rr['quantity'];
$sum[$dat]['product_qty_'.$rr['ecmproduct_id']]+=$rr['quantity'];
$sum[$dat]['product_pur_'.$rr['ecmproduct_id']]+=$rr['purchase_price']*$rr['quantity'];
if($rr['ppc']>0)$sum[$dat]['product_cbm_'.$rr['ecmproduct_id']]+=$rr['quantity']*($rr['cvm']/$rr['ppc']);
$sum[$year]['category_sum_'.$c]+=$rr['price']*$rr['quantity'];
$sum[$year]['category_qty_sum_'.$c]+=$rr['quantity'];
$sum[$year]['category_pur_sum_'.$c]+=$rr['purchase_price']*$rr['quantity'];
if($rr['ppc']>0)$sum[$year]['category_cbm_sum_'.$c]+=$rr['quantity']*($rr['cvm']/$rr['ppc']);
$sum[$year]['product_sum_'.$rr['ecmproduct_id']]+=$rr['price']*$rr['quantity'];
$sum[$year]['product_qty_sum_'.$rr['ecmproduct_id']]+=$rr['quantity'];
$sum[$year]['product_pur_sum_'.$rr['ecmproduct_id']]+=$rr['purchase_price']*$rr['quantity'];
if($rr['ppc']>0)$sum[$year]['product_cbm_sum_'.$rr['ecmproduct_id']]+=$rr['quantity']*($rr['cvm']/$rr['ppc']);
}
}
$ww=$GLOBALS['db']->query("select ecminvoiceouts.id as invid,ecminvoiceouts.ecminvoiceout_id as ecminvoiceout_id,ecmproducts.id as ecmproduct_id,ecmproducts.carton_volume_meter as cvm,ecmproducts.pieces_per_carton as ppc,ecminvoiceouts.register_date as d,ecminvoiceoutitems.purchase_price as purchase_price,ecminvoiceoutitems.price as price,ecminvoiceoutitems.quantity as quantity,ecminvoiceoutitems.ecmproduct_id as ecmproduct_id from ecminvoiceoutitems inner join ecminvoiceouts on ecminvoiceouts.id=ecminvoiceoutitems.ecminvoiceout_id inner join ecmproducts on ecmproducts.id=ecminvoiceoutitems.ecmproduct_id where ".$ah."ecminvoiceouts.register_date like '".$year."%' and ecminvoiceoutitems.deleted='0'".$wh." and ecminvoiceouts.type='correct'".$aa);
echo mysql_error();
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
$www=$GLOBALS['db']->query("select id from ecminvoiceoutitems where ecminvoiceout_id='".$rr['ecminvoiceout_id']."' and ecmproduct_id='".$rr['ecmproduct_id']."' and deleted='0' and (price='".$rr['price']."' and quantity='".$rr['quantity']."')");
if(mysql_num_rows($www)>0)continue;
$www=$GLOBALS['db']->query("select quantity,price,purchase_price from ecminvoiceoutitems where ecminvoiceout_id='".$rr['ecminvoiceout_id']."' and ecmproduct_id='".$rr['ecmproduct_id']."' and deleted='0' and (price!='".$rr['price']."' or quantity!='".$rr['quantity']."')");
$rrr=$GLOBALS['db']->fetchByAssoc($www);
$cqty=$rr['quantity']-$rrr['quantity'];
$cprice=$rr['quantity']*$rr['price']-$rrr['quantity']*$rrr['price'];
$cpprice=$cqty*$rr['purchase_price'];
if($cqty==0 && $rr['price']==$rrr['price'])continue;
$d=explode("-",$rr['d']);
$dat=$year."-".$d[1];
$sum['all']+=$cprice;
$_SESSION['EcmReports_sum_all']+=$cprice;
$sum['all_qty']+=$cqty;
$_SESSION['EcmReports_sum_all_qty']+=$cqty;
$sum['all_pur']+=$cpprice;
$_SESSION['EcmReports_sum_all_pur']+=$cpprice;
if($rr['ppc']>0){
$sum['all_cbm']+=$cqty*($rr['cvm']/$rr['ppc']);
$_SESSION['EcmReports_sum_all_cbm']+=$cqty*($rr['cvm']/$rr['ppc']);
}
$sum[$dat]['all']+=$cprice;
$sum[$dat]['all_qty']+=$cqty;
$sum[$dat]['all_pur']+=$cpprice;
if($rr['ppc']>0)$sum[$dat]['all_cbm']+=$cqty*($rr['cvm']/$rr['ppc']);
if(!$all){
$sum[$dat]['category_'.$c]+=$cprice;
$sum[$dat]['category_qty_'.$c]+=$cqty;
$sum[$dat]['category_pur_'.$c]+=$cpprice;
if($rr['ppc']>0)$sum[$dat]['category_cbm_'.$c]+=$cqty*($rr['cvm']/$rr['ppc']);
$sum[$dat]['product_'.$rr['ecmproduct_id']]+=$cprice;
$sum[$dat]['product_qty_'.$rr['ecmproduct_id']]+=$cqty;
$sum[$dat]['product_pur_'.$rr['ecmproduct_id']]+=$cpprice;
if($rr['ppc']>0)$sum[$dat]['product_cbm_'.$rr['ecmproduct_id']]+=$cqty*($rr['cvm']/$rr['ppc']);
$sum[$year]['category_sum_'.$c]+=$cprice;
$sum[$year]['category_qty_sum_'.$c]+=$cqty;
$sum[$year]['category_pur_sum_'.$c]+=$cpprice;
if($rr['ppc']>0)$sum[$year]['category_cbm_sum_'.$c]+=$cqty*($rr['cvm']/$rr['ppc']);
$sum[$year]['product_sum_'.$rr['ecmproduct_id']]+=$cprice;
$sum[$year]['product_qty_sum_'.$rr['ecmproduct_id']]+=$cqty;
$sum[$year]['product_pur_sum_'.$rr['ecmproduct_id']]+=$cpprice;
if($rr['ppc']>0)$sum[$year]['product_cbm_sum_'.$rr['ecmproduct_id']]+=$cqty*($rr['cvm']/$rr['ppc']);
}
}
return $sum;
}*/
if($_GET['category'])$cw=" and id='".$_GET['category']."'";
else $cw="";
$z="select name,id from ecmproductcategories where deleted='0'".$cw." order by name";
$w=$GLOBALS['db']->query($z);
if($_REQUEST['account'])$sum=sum($year,$_REQUEST['account']);
else $sum=unserialize(base64_decode(file_get_contents("modules/EcmReports/cache".$year.$dddd.".dat")));
while($r=$GLOBALS['db']->fetchByAssoc($w)){
$m++;
$ems_qty_in_stock=0;
$stock_value=0;
$cbm=0;
$cat_arr[]=$m;
$objPHPExcel->getActiveSheet()->SetCellValue('A'.$m,$r['name']);
$zz="select ems_qty_in_stock,ems_price,carton_volume_meter as cvm,pieces_per_carton as ppc from ecmproducts where product_category_id='".$r['id']."' and deleted='0'";
$ww=$GLOBALS['db']->query($zz);
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
$ems_qty_in_stock+=$rr['ems_qty_in_stock'];
$stock_value+=$rr['ems_qty_in_stock']*$rr['ems_price'];
$cbm+=$rr['ems_qty_in_stock']*($rr['cvm']/$rr['ppc']);
}
$objPHPExcel->getActiveSheet()->SetCellValue('B'.$m,$ems_qty_in_stock);
$objPHPExcel->getActiveSheet()->SetCellValue('C'.$m,$stock_value);
$objPHPExcel->getActiveSheet()->SetCellValue('D'.$m,$cbm);
$ems_total+=$ems_qty_in_stock;
$stock_value_total+=$stock_value;
$cbm_total+=$cbm;
$avg_cat=0;
$avg_cat_qty=0;
for($i=0;$i<count($months)*8;$i+=8){
$avg_cat+=$sum[$year."-".$months[($i/8)]]['category_'.$r['id']];
$avg_cat_qty+=$sum[$year."-".$months[($i/8)]]['category_qty_'.$r['id']];
}
for($i=0;$i<count($months)*8;$i+=8){
$cat=$sum[$year."-".$months[($i/8)]]['category_'.$r['id']];
$cat_pur=$sum[$year."-".$months[($i/8)]]['category_pur_'.$r['id']];
$cat_qty=$sum[$year."-".$months[($i/8)]]['category_qty_'.$r['id']];
$cbm=$sum[$year."-".$months[($i/8)]]['category_cbm_'.$r['id']];
if($cat)$margin=100*($cat-$cat_pur)/$cat;
else $margin=0;
if(!$cat)$cat=0;
if(!$cat_qty)$cat_qty=0;
if(!$cbm)$cbm=0;
$rvs=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select value from ecmsalesreports_predictions_cat where account_id='".$_REQUEST['account']."' and year='".$year."' and month='".$i."' and bean_id='".$r['id']."' and type='sale'"));
$rvq=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select value from ecmsalesreports_predictions_cat where account_id='".$_REQUEST['account']."' and year='".$year."' and month='".$i."' and bean_id='".$r['id']."' and type='qty'"));
if($rvs['value']<=0)$rvs['value']=$avg_cat/$mmm;
if($rvq['value']<=0)$rvq['value']=$avg_cat_qty/$mmm;
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+4].$m,$cat_qty);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+5].$m,$cat);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+6].$m,$margin);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+7].$m,$cbm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+8].$m,$avg_cat/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+9].$m,$avg_cat_qty/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+10].$m,$rvs['value']);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+11].$m,$rvq['value']);
}
if($sum[$year]['category_sum_'.$r['id']])$margin=100*($sum[$year]['category_sum_'.$r['id']]-$sum[$year]['category_pur_sum_'.$r['id']])/$sum[$year]['category_sum_'.$r['id']];
else $margin=0;
$cbm=$sum[$year]['category_cbm_sum_'.$r['id']];
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+4].$m,($sum[$year]['category_qty_sum_'.$r['id']]/$mmm));
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+5].$m,$sum[$year]['category_sum_'.$r['id']]);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+6].$m,$margin);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+7].$m,$cbm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+8].$m,$avg_cat/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+9].$m,$avg_cat_qty/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+10].$m,$avg_cat/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+11].$m,$avg_cat_qty/$mmm);
if(!$_GET['only_cat']){
$zz="select id,name,code,ems_qty_in_stock,ems_price,carton_volume_meter as cvm,pieces_per_carton as ppc from ecmproducts where product_category_id='".$r['id']."' and deleted='0' order by code asc";
$ww=$GLOBALS['db']->query($zz);
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
$m++;
$objPHPExcel->getActiveSheet()->SetCellValue('A'.$m,$rr['code'].' '.$rr['name']);
$objPHPExcel->getActiveSheet()->SetCellValue('B'.$m,$rr['ems_qty_in_stock']);
$objPHPExcel->getActiveSheet()->SetCellValue('C'.$m,($rr['ems_qty_in_stock']*$rr['ems_price']));
$objPHPExcel->getActiveSheet()->SetCellValue('D'.$m,($rr['ems_qty_in_stock']*($rr['cvm']/$rr['ppc'])));
for($i=0;$i<count($months)*8;$i+=8){
$avg_p_qty+=$sum[$year."-".$months[($i/8)]]['product_qty_'.$rr['id']];
$avg_p+=$sum[$year."-".$months[($i/8)]]['product_'.$rr['id']];
}
for($i=0;$i<count($months)*8;$i+=8){
$p_pur=$sum[$year."-".$months[($i/8)]]['product_pur_'.$rr['id']];
$p_qty=$sum[$year."-".$months[($i/8)]]['product_qty_'.$rr['id']];
$p=$sum[$year."-".$months[($i/8)]]['product_'.$rr['id']];
$cbm=$sum[$year."-".$months[($i/8)]]['product_cbm_'.$rr['id']];
if($p)$margin=100*($p-$p_pur)/$p;
else $margin=0;
if(!$p)$p=0;
if(!$cbm)$cbm=0;
if(!$p_qty)$p_qty=0;
$rvs=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select value from ecmsalesreports_predictions_cat where account_id='".$_REQUEST['account']."' and year='".$_REQUEST['year']."' and month='".$i."' and bean_id='".$rr['id']."' and type='sale'"));
$rvq=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select value from ecmsalesreports_predictions_cat where account_id='".$_REQUEST['account']."' and year='".$_REQUEST['year']."' and month='".$i."' and bean_id='".$rr['id']."' and type='qty'"));
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+4].$m,$p_qty);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+5].$m,$p);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+6].$m,$margin);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+7].$m,$cbm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+8].$m,$avg_p/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+9].$m,$avg_p_qty/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+10].$m,$rvs['value']);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+11].$m,$rvq['value']);
}
$s_pur=$sum[$year]['product_pur_sum_'.$rr['id']];
$s_qty=$sum[$year]['product_qty_sum_'.$rr['id']];
$s=$sum[$year]['product_sum_'.$rr['id']];
$cbm=$sum[$year]['product_cbm_'.$rr['id']];
if($s)$margin=100*($s-$s_pur)/$s;
else $margin=0;
if(!$cbm)$cbm=0;
if(!$s)$s=0;
if(!$s_qty)$s_qty=0;
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+4].$m,($s_qty/$mmm));
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+5].$m,$s);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+6].$m,$margin);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+7].$m,$cbm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+8].$m,$avg_p/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+9].$m,$avg_p_qty/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+10].$m,$avg_p/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+11].$m,$avg_p_qty/$mmm);
}
}
}
$m++;
if($_REQUEST['account'])$sum=sum($year,$_REQUEST['account']);
else $sum=unserialize(base64_decode(file_get_contents("modules/EcmReports/cache".$year.$dddd.".dat")));
$objPHPExcel->getActiveSheet()->SetCellValue('B'.$m,$ems_total);
$objPHPExcel->getActiveSheet()->SetCellValue('C'.$m,$stock_total);
$objPHPExcel->getActiveSheet()->SetCellValue('D'.$m,$cbm_total);
$avg_cat=0;
$avg_cat_qty=0;
function sumCat($year,$month,$account,$type){
$w=$GLOBALS['db']->query("select id from ecmproductcategories where deleted='0'");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
$arr[]="bean_id='".$r['id']."'";
}
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select sum(value) as sum from ecmsalesreports_predictions_cat where deleted='0' and type='".$type."' and account_id='".$account."' and month='".$month."' and year='".$year."' and (".implode(" or ",$arr).")"));
return $r['sum'];
}
for($i=0;$i<count($months)*8;$i+=8){
$avg_cat+=$sum[$year."-".$months[($i/8)]]['all'];
$avg_cat_qty+=$sum[$year."-".$months[($i/8)]]['all_qty'];
}
for($i=0;$i<count($months)*8;$i+=8){
$cat=$sum[$year."-".$months[($i/8)]]['all'];
$cat_pur=$sum[$year."-".$months[($i/8)]]['all_pur'];
$cat_qty=$sum[$year."-".$months[($i/8)]]['all_qty'];
$cbm=$sum[$year."-".$months[($i/8)]]['all_cbm'];
if($cat)$margin=100*($cat-$cat_pur)/$cat;
else $margin=0;
if(!$cbm)$cbm=0;
if(!$cat)$cat=0;
if(!$cat_qty)$cat_qty=0;
$sum_pred_cat+=$pred_cat=sumCat($year,$i,$_REQUEST['account'],"sale");
$sum_pred_cat_qty+=$pred_cat_qty=sumCat($year,$i,$_REQUEST['account'],"qty");
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+4].$m,$cat_qty);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+5].$m,$cat);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+6].$m,$margin);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+7].$m,$cbm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+8].$m,$avg_cat/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+9].$m,$avg_cat_qty/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+10].$m,$pred_cat);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+11].$m,$pred_cat_qty);
}
$m++;
$sa=$sum['all'];
$sa_pur=$sum['all_pur'];
$sa_qty=$sum['all_qty'];
$cbm=$sum['all_cbm'];
if($sa)$margin=100*($sa-$sa_pur)/$sa;
else $margin=0;
if(!$cbm)$cbm=0;
if(!$sa)$sa=0;
if(!$sa_qty)$sa_qty=0;
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+4].($m-1),($sa_qty/$mmm));
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+5].($m-1),$sa);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+6].($m-1),$margin);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+7].($m-1),$cbm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+8].($m-1),$sa/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+9].($m-1),$sum['all_qty']/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+10].($m-1),$sum_pred_cat);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$i+11].($m-1),$sum_pred_cat_qty);
$objPHPExcel->getActiveSheet()->setTitle('Simple');
$objPHPExcel->setActiveSheetIndex(0);
if(!$_GET['only_cat']){
foreach($cat_arr as $ca){
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => 'FF00FF00')
),
'borders' => array(
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
)
),
"A".$ca.":DDS".$ca
);
}
}
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => 'F0F0F0')
),
'borders' => array(
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
)
),
"A".($m-1).":DD".($m-1)
);
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => 'BBDDFF')
),
'borders' => array(
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
)
),
"CW1:DD".($m-1)
);
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => '75BAFF')
),
'borders' => array(
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
)
),
"CW".($m-1).":DD".($m-1)
);
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => 'FFCCFFCC')
),
'borders' => array(
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
)
),
"A1:DD1"
);
foreach($cat_arr as $ca){
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => '75BAFF')
),
'borders' => array(
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
)
),
"CW".$ca.":DD".$ca
);
}
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
chmod("cache/upload",0777);
$microtime=str_replace(".","",str_replace(" ","",microtime()));
$name="cache/upload/Report".$microtime.".xlsx";
$objWriter->save($name);
chmod($name,0777);
header("Location: ".$name);
?>

424
modules/EcmReports/CreateXLS2.php Executable file
View File

@@ -0,0 +1,424 @@
<?php
include_once("modules/EcmReports/cache.php");
include_once("modules/EcmProductReports/vtigerConnector.php");
$vc=new vtigerConnector();
//$wc[]="purchaseorder.tracking_no!=''";
$vc->pp=99999;
$vc->where="(purchaseorder.postatus='Created' or purchaseorder.postatus='Approved' or purchaseorder.postatus='Delivered')";
$vc->getData();
$cnt=$vc->getCount();
$data=$vc->data;
$vd=$data;
function getValueByCode($data,$code,$status=""){
$r=mysql_fetch_array(mysql_query("select conversion_rate from currencies where name like 'USD'"));
for($i=0;$i<count($data);$i++){
if($data[$i]['productcode']==$code || $data[$i]['productcode']==$code."_S"){
if($status){
if($status==$data[$i]['postatus'])$value+=$r['conversion_rate']*$data[$i]['quantity']*$data[$i]['listprice']/0.8;
}
else $value+=$r['conversion_rate']*$data[$i]['quantity']*$data[$i]['listprice']/0.8;
}
}
return $value;
}
function getSumLast($account_id,$product_active){
$wh[]="e.register_date>'".date("Y-m-d",mktime()-12*30*24*3600)."'";
$wh[]="e.deleted='0'";
$wh[]="i.deleted='0'";
$wh[]="p.deleted='0'";
$wh[]="e.status='accepted'";
if($account_id)$wh[]="(e.parent_id='".$account_id."' or w.parent_id='".$account_id."')";
if($product_active && $product_active=="active")$wh[]="p.product_active='1'";
elseif($product_active && $product_active=="inactive")$wh[]="p.product_active='0'";
elseif($product_active && $product_active=="inactive")$wh=" and p.product_active='0'";
$w=mysql_query("select i.purchase_price,i.quantity,i.ecmproduct_id,p.product_category_id from ecminvoiceoutitems as i inner join ecminvoiceouts as e on e.id=i.ecminvoiceout_id inner join ecmproducts as p on i.ecmproduct_id=p.id where ".implode(" and ",$wh));
while($r=mysql_fetch_array($w)){
$arr[$r['product_category_id']]+=$r['purchase_price']*$r['quantity'];
$arr[$r['ecmproduct_id']]+=$r['purchase_price']*$r['quantity'];
}
return $arr;
}
set_time_limit(999999);
$year=$_GET['year'];
if(!$year)$year=(int)date("Y");
if($year==date(Y)){
$mmm=(int)date("m")-1;
}
else $mmm=12;
set_include_path('include/PHPExcel/');
include 'PHPExcel.php';
include 'PHPExcel/Writer/Excel2007.php';
include 'PHPExcel/IOFactory.php';
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("E5 CRM");
$objPHPExcel->getProperties()->setLastModifiedBy("E5 CRM");
$objPHPExcel->getProperties()->setTitle("Office 2007 PRICEBOOK");
$objPHPExcel->getProperties()->setSubject("Office 2007 PRICEBOOK");
$objPHPExcel->getProperties()->setDescription("PRICEBOOK");
$alf1="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for($i=0;$i<strlen($alf1);$i++){
$alf[]=$alf1[$i];
}
for($i=0;$i<strlen($alf1);$i++){
for($j=0;$j<strlen($alf1);$j++){
$alf[]=$alf1[$i].$alf1[$j];
}
}
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(80);
for($i=1;$i<=160;$i++){
$objPHPExcel->getActiveSheet()->getColumnDimension($alf[$i])->setWidth(30);
}
//ilosc poczatkowych kolumn
$pc=11;
//kolumny glowne
$objPHPExcel->getActiveSheet()->SetCellValue('A1','Name');
$objPHPExcel->getActiveSheet()->SetCellValue('B1','Inv qty');
$objPHPExcel->getActiveSheet()->SetCellValue('C1','Inv value');
$objPHPExcel->getActiveSheet()->SetCellValue('D1','Order value');
$objPHPExcel->getActiveSheet()->SetCellValue('E1','Order created value');
$objPHPExcel->getActiveSheet()->SetCellValue('F1','Order approved value');
$objPHPExcel->getActiveSheet()->SetCellValue('G1','Order delivered value');
$objPHPExcel->getActiveSheet()->SetCellValue('H1','Pur 12m');
$objPHPExcel->getActiveSheet()->SetCellValue('I1','Stock m');
$objPHPExcel->getActiveSheet()->SetCellValue('J1','Stock m + ord');
$objPHPExcel->getActiveSheet()->SetCellValue('K1','CBM');
//miesiace
$months=array("01","02","03","04","05","06","07","08","09","10","11","12");
$months_names=array("01"=>"January","02"=>"February","03"=>"March","04"=>"April","05"=>"May","06"=>"June","07"=>"July","08"=>"August","09"=>"September","10"=>"October","11"=>"November","12"=>"December");
//drukowanie kolumn miesiecy
for($i=0;$i<12;$i++){
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+$pc].'1',$months_names[$months[$i]]." ".$year);
}
//drukowanie kolumn z wartosciami dla miesiecy
$m=2;
for($i=0;$i<=12;$i++){
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+$pc].'2','Qty');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+$pc+1].'2','Avg qty');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+$pc+2].'2','Sales');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+$pc+3].'2','Avg sales');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+$pc+4].'2','Purchase');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+$pc+5].'2','Avg purchase');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+$pc+6].'2','Margin %');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+$pc+7].'2','CBM');
//$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+$pc+8].'2','Pred. sales');
//$objPHPExcel->getActiveSheet()->SetCellValue($alf[8*$i+$pc+9].'2','Pred. qty');
}
$m++;
if($_GET['category'])$cw=" and id='".$_GET['category']."'";
else $cw="";
$z="select name,id from ecmproductcategories where deleted='0'".$cw." order by name";
$w=$GLOBALS['db']->query($z);
$GLOBALS['db']->query("set names utf8");
$as=sum($year,$_REQUEST['account'],"","",$_REQUEST['active']);
$last=getSumLast($_REQUEST['account'],$_REQUEST['active']);
while($r=$GLOBALS['db']->fetchByAssoc($w)){
//nr kolumny
$col=0;
//zerowanie wartosci
$ems_qty_in_stock=0;
$stock_value=0;
$order_value=0;
$order_created_value=0;
$order_approved_value=0;
$order_delivered_value=0;
$cbm=0;
//wartosci do kategorii
$act="";
if($_REQUEST['active']=="active")$act=" and product_active='1'";
elseif($_REQUEST['active']=="active")$act=" and product_active='0'";
$zz="select ems_qty_in_stock,ems_price,carton_volume_meter as cvm,pieces_per_carton as ppc,code from ecmproducts where product_category_id='".$r['id']."' and deleted='0'".$act;
$ww=$GLOBALS['db']->query($zz);
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
$ems_qty_in_stock+=$rr['ems_qty_in_stock'];
$stock_value+=$rr['ems_qty_in_stock']*$rr['ems_price'];
@$cbm+=$rr['ems_qty_in_stock']*($rr['cvm']/$rr['ppc']);
$order_value+=getValueByCode($vd,$rr['code']);
$order_created_value+=getValueByCode($vd,$rr['code'],"Created");
$order_approved_value+=getValueByCode($vd,$rr['code'],"Approved");
$order_delivered_value+=getValueByCode($vd,$rr['code'],"Delivered");
}
//sumowanie
$cbm_total+=$cbm;
$ems_qty_in_stock_total+=$ems_qty_in_stock;
$stock_value_total+=$stock_value;
$order_value_total+=$order_value;
$order_created_value_total+=$order_created_value;
$order_approved_value_total+=$order_approved_value;
$order_delivered_value_total+=$order_delivered_value;
//wartosci sprzedazy i zakupu w grupach
$sumy=getSum($as,$year,"",$r['id']);
//sumowanie
$tot_pur+=$sumy['total_purchase'];
$stock_m=0;
$stock_m_order=0;
if($sumy['total_purchase'])$stock_m=@$stock_value/($last[$r['id']]/12);
if($sumy['total_purchase'])$stock_m_order=@($stock_value+$order_value)/($last[$r['id']]/12);
$stock_m_total+=$stock_m;
$stock_m_order_total+=$stock_m_order;
$pur12m+=$last[$r['id']];
//tworzenie kolumn
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$r['name']);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$ems_qty_in_stock);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$stock_value);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$order_value);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$order_created_value);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$order_approved_value);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$order_delivered_value);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$last[$r['id']]/12);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$stock_m);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$stock_m_order);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$cbm);
$avg_cat=0;
$avg_cat_qty=0;
$avg_cat_pur=0;
$sumy=getSum($as,$year,"",$r['id']);
$avg_cat+=$sumy["total"];
$summary_avg_cat+=$sumy['total'];
$avg_cat_pur+=$sumy["total_purchase"];
$summary_avg_cat_pur+=$sumy['total_purchase'];
$avg_cat_qty+=$sumy["qty"];
$summary_avg_cat_qty+=$sumy['qty'];
//tworzenie kolumn w miesiacach
for($i=0;$i<count($months);$i++){
$sum=getSum($as,$year."-".$months[$i],"",$r['id']);
$cat=$sum["total"];
$cat_pur=$sum["total_purchase"];
$cat_qty=$sum["qty"];
$cbm=$sum["cbm"];
if($cat)$margin=100*($cat-$cat_pur)/$cat;
else $margin=0;
if(!$cat)$cat=number_format(0,2,"",".");
$rvs=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select value from ecmsalesreports_predictions_cat where account_id='".$_REQUEST['account']."' and year='".$year."' and month='".$i."' and bean_id='".$r['id']."' and type='sale'"));
$rvq=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select value from ecmsalesreports_predictions_cat where account_id='".$_REQUEST['account']."' and year='".$year."' and month='".$i."' and bean_id='".$r['id']."' and type='qty'"));
if($rvs['value']<=0)$rvs['value']=$avg_cat/$mmm;
if($rvq['value']<=0)$rvq['value']=$avg_cat_qty/$mmm;
$ajax_cat=ajaxWindow($r['id'],$i,$rvs['value'],$_REQUEST['account'],"sale",$year);
@$ajax_cat_qty=ajaxWindow($r['id'],$i,$rvq['value'],$_REQUEST['account'],"qty",$year,($avg_cat/$avg_cat_qty));
$summary['total'][$year."-".$months[$i]]+=$cat;
$summary['total_purchase'][$year."-".$months[$i]]+=$cat_pur;
$summary['total_qty'][$year."-".$months[$i]]+=$cat_qty;
$summary['total_cbm'][$year."-".$months[$i]]+=$cbm;
$summary['total'][$year]+=$cat;
$summary['total_purchase'][$year]+=$cat_pur;
$summary['total_qty'][$year]+=$cat_qty;
$summary['total_cbm'][$year]+=$cbm;
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$cat_qty);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$avg_cat_qty/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$cat);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$avg_cat/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$cat_pur);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$avg_cat_pur/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$margin);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$cbm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$rvs['value']);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$rvq['value']);
}
//sumowanie wiersza
if($sumy["total_purchase"])$margin=100*($sumy["total"]-$sumy["total_purchase"])/$sumy["total"];
else $margin=0;
$cbm=$sumy["cbm"];
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,($sumy["qty"]/$mmm));
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$avg_cat_qty/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$sumy["total"]);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$avg_cat/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$sumy["total_purchase"]);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$avg_cat_pur/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$margin);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$cbm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$avg_cat/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$avg_cat_qty/$mmm);
$m++;
if($_REQUEST['category']){
$col=0;
$as=sum($year,$_REQUEST['account'],"",$_REQUEST['category'],$_REQUEST['active']);
$act="";
if($_REQUEST['active']=="active")$act=" and product_active='1'";
elseif($_REQUEST['active']=="active")$act=" and product_active='0'";
$zz="select * from ecmproducts where product_category_id='".$_REQUEST['category']."' and deleted='0'".$act." order by code asc";
$ww=$GLOBALS['db']->query($zz);
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
$col=0;
$avg_p=0;
$avg_p_qty=0;
$avg_p_pur=0;
$sumy=getSum($as,$year,$rr['id'],$_REQUEST['category']);
for($i=0;$i<count($months);$i++){
$avg_p_qty+=$sumy["qty"];
$avg_p+=$sumy["total"];
$avg_p_pur+=$sumy["total_purchase"];
}
//$sumy=getSum($as,$year,$rr['id'],"");
$stock_m=0;
$stock_m_order=0;
$o_value=0;
$o_value+=getValueByCode($vd,$rr['code']);
$o_c_value=0;
$o_c_value+=getValueByCode($vd,$rr['code'],"Created");
$o_a_value=0;
$o_a_value+=getValueByCode($vd,$rr['code'],"Approved");
$o_d_value=0;
$o_d_value+=getValueByCode($vd,$rr['code'],"Delivered");
if($sumy['total_purchase'])$stock_m=@($rr['ems_qty_in_stock']*$rr['ems_price'])/($last[$rr['id']]/12);
if($sumy['total_purchase'])$stock_m_order=@(($rr['ems_qty_in_stock']*$rr['ems_price'])+$o_value)/($last[$rr['id']]/12);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$rr['name']);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$rr['ems_qty_in_stock']);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$rr['ems_qty_in_stock']*$rr['ems_price']);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$o_value);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$o_created_value);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$o_approved_value);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$o_delivered_value);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$last[$rr['id']]/12);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$stock_m);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$stock_m_order);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,($rr['ems_qty_in_stock']*($rr['cvm']/$rr['ppc'])));
for($i=0;$i<count($months);$i++){
$sum=getSum($as,$year."-".$months[$i],$rr['id'],$_REQUEST['category']);
$p_pur=$sum["total_purchase"];
$p_qty=$sum["qty"];
$p=$sum["total"];
$cbm=$sum["cbm"];
if($p)$margin=100*($p-$p_pur)/$p;
else $margin=0;
if(!$p)$p=number_format(0,2,",",".");
$rvs=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select value from ecmsalesreports_predictions_cat where account_id='".$_REQUEST['account']."' and year='".$year."' and month='".$i."' and bean_id='".$rr['id']."' and type='sale'"));
$rvq=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select value from ecmsalesreports_predictions_cat where account_id='".$_REQUEST['account']."' and year='".$year."' and month='".$i."' and bean_id='".$rr['id']."' and type='qty'"));
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$p_qty);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$avg_p_qty/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$p);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$avg_p/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$p_pur);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$avg_p_pur/$mmm);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$margin);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$cbm);
//$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$rvs['value']);
//$objPHPExcel->getActiveSheet()->SetCellValue($alf[$col++].$m,$rvq['value']);
}
$m++;
}
}
}
$objPHPExcel->getActiveSheet()->setTitle('Simple');
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => 'F0F0F0')
),
'borders' => array(
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
)
),
"A".($m).":EH".($m)
);
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => 'BBDDFF')
),
'borders' => array(
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
)
),
"DY1:EH".($m)
);
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => '75BAFF')
),
'borders' => array(
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
)
),
"DY".($m).":EH".($m)
);
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => 'FFCCFFCC')
),
'borders' => array(
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
)
),
"A1:EH1"
);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
chmod("cache/upload",0777);
$microtime=str_replace(".","",str_replace(" ","",microtime()));
$name="cache/upload/Report".$microtime.".xlsx";
$objWriter->save($name);
chmod($name,0777);
header("Location: ".$name);
?>

View File

@@ -0,0 +1,189 @@
<?php
global $db;
if(!$_REQUEST['year']){
$_REQUEST['year']=date("Y");
$_GET['year']=date("Y");
}
//error_reporting(0);
include_once("modules/EcmReports/class.sales.php");
set_include_path('include/PHPExcel/');
include 'PHPExcel.php';
include 'PHPExcel/Writer/Excel2007.php';
include 'PHPExcel/IOFactory.php';
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("E5 CRM");
$objPHPExcel->getProperties()->setLastModifiedBy("E5 CRM");
$objPHPExcel->getProperties()->setTitle("Office 2007 PRICEBOOK");
$objPHPExcel->getProperties()->setSubject("Office 2007 PRICEBOOK");
$objPHPExcel->getProperties()->setDescription("PRICEBOOK");
$alf1="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for($i=0;$i<strlen($alf1);$i++)$alf[]=$alf1[$i];
for($i=0;$i<strlen($alf1);$i++){
for($j=0;$j<strlen($alf1);$j++){
$alf[]=$alf1[$i].$alf1[$j];
}
}
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(70);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(20);
for($i=3;$i<count($alf);$i++)$objPHPExcel->getActiveSheet()->getColumnDimension($alf[$i])->setWidth(15);
$w=$db->query("select id from accounts where deleted='0' and core_client='1'");
while($r=$db->fetchByAssoc($w)){
$s=new Sales();
$s->date_from=$_REQUEST['year']."-01-01";
$s->date_to=$_REQUEST['year']."-12-31";
$s->account_id=$r['id'];
$s->product_active="active";
$sdata[$r['id']]=$s->getSalesByProductForecast();
}
$a=0;
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'1','Index');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'1','Name');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'1','Category');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'1','Inventory'); $a+=2;
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'1','SRP price');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'1','Total'); $a+=3;
$w=$db->query("select name from accounts where deleted='0' and core_client='1' order by name asc");
while($r=$db->fetchByAssoc($w)){
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'1',$r['name']); $a+=4;
}
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'1',"New clients"); $a+=4;
$a=3;
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'2','Qty');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'2','Price');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'2','Value'); $a++;
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'2','Sales');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'2','Qty');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'2','Pred. sales');
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'2','Pred. qty');
$w=$db->query("select name from accounts where deleted='0' and core_client='1' order by name asc");
while($r=$db->fetchByAssoc($w)){
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'2',"Avg. price");
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'2',"Qty");
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'2',"Sales");
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'2',"Pred. qty");
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'2',"Pred. sales");
}
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'2',"Avg. price");
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'2',"Qty");
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'2',"Sales");
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'2',"Pred. qty");
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].'2',"Pred. sales");
function getTotalFromAccounts($d,$id,$type="sales"){
global $db;
$ww=$db->query("select name,id from accounts where deleted='0' and core_client='1' order by name asc");
while($rr=$db->fetchByAssoc($ww)){
$total+=$d[$rr['id']][$id][$type];
}
return $total;
}
if($_REQUEST['category'])$wh_cat=" and product_category_id='".$_REQUEST['category']."'";
else $wh_cat="";
$w=$db->query("select ems_price,ems_qty_in_stock,id,name,code,product_category_name,product_category_id,srp_price from ecmproducts where product_active='1' and production!='1'".$wh_cat." and deleted='0' order by product_category_name asc,code asc");
$m=3;
while($r=$db->fetchByAssoc($w)){
$a=0;
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].$m,$r['code']);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].$m,$r['name']);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].$m,$r['product_category_name']);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].$m,$r['ems_qty_in_stock']);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].$m,$r['ems_price']);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].$m,$r['ems_price']*$r['ems_qty_in_stock']);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].$m,$r['srp_price']);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].$m,getTotalFromAccounts($sdata,$r['id']));
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].$m,getTotalFromAccounts($sdata,$r['id'],"quantity"));
$total_pred_sales=$a;
$a++;
$total_pred_qty=$a;
$a++;
$total_srp_price+=$r['srp_price'];
$total_ems_qty+=$r['ems_qty_in_stock'];
$total_ems_price+=$r['ems_qty_in_stock'];
$total_ems_value+=$r['ems_qty_in_stock']*$r['ems_price'];
$total_sales+=getTotalFromAccounts($sdata,$r['id']);
$total_qty+=getTotalFromAccounts($sdata,$r['id'],"quantity");
$total_pred_sales_v=0;
$total_pred_qty_v=0;
$ww=$db->query("select name,id from accounts where deleted='0' and core_client='1' order by name asc");
while($rr=$db->fetchByAssoc($ww)){
if($sdata[$rr['id']][$r['id']]['quantity']>0)$aprice=$sdata[$rr['id']][$r['id']]['sales']/$sdata[$rr['id']][$r['id']]['quantity'];
else $aprice=0;
if($aprice==0){
$rpb=$db->fetchByAssoc($db->query("select price from ecmpricebooks_ecmproducts where active=1 and account_id='".$rr['id']."' and ecmproduct_id='".$r['id']."' and deleted='0'"));
$aprice=$rpb['price'];
}
if($aprice==0){
$rpb=$db->fetchByAssoc($db->query("select price from ecmpricebooks_ecmproducts where ecmpricebook_id='7b840616-a226-4a15-a831-4d11f116995a' and ecmproduct_id='".$r['id']."' and deleted='0'"));
$aprice=$rpb['price'];
}
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].$m,$aprice);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].$m,$sdata[$rr['id']][$r['id']]['quantity']);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].$m,$sdata[$rr['id']][$r['id']]['sales']);
$rrr=$db->fetchByAssoc($db->query("select value from ecmforecasts where ecmproduct_id='".$r['id']."' and account_id='".$rr['id']."'"));
$pred=(int)$rrr['value'];
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].$m,$pred);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].$m,$rrr['value']*$aprice);
$total_pred_sales_v+=$rrr['value']*round($aprice,2);
$total_pred_qty_v+=$rrr['value'];
$totals_quantity[$rr['id']]+=$sdata[$rr['id']][$r['id']]['quantity'];
$totals_sales[$rr['id']]+=$sdata[$rr['id']][$r['id']]['sales'];
$totals_pred[$rr['id']]+=$rrr['value']*round($aprice,2);
$totals_pred_qty[$rr['id']]+=$rrr['value'];
}
if(getTotalFromAccounts($sdata,$r['id'],"quantity")>0)$avg_price=getTotalFromAccounts($sdata,$r['id'])/getTotalFromAccounts($sdata,$r['id'],"quantity");
else $avg_price=0;
if($avg_price==0){
$rpb=$db->fetchByAssoc($db->query("select price from ecmpricebooks_ecmproducts where ecmpricebook_id='7b840616-a226-4a15-a831-4d11f116995a' and ecmproduct_id='".$r['id']."' and deleted='0'"));
$avg_price=$rpb['price'];
}
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].$m,$avg_price);
$rrr=$db->fetchByAssoc($db->query("select value from ecmforecasts where ecmproduct_id='".$r['id']."' and account_id='new'"));
$pred=(int)$rrr['value'];
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].$m,$pred);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$a++].$m,$rrr['value']*$aprice);
$total_pred_sales_v+=$rrr['value']*round($avg_price,2);
$total_pred_qty_v+=$rrr['value'];
$totals_pred["new"]+=$rrr['value']*round($avg_price,2);
$totals_pred_qty["new"]+=$rrr['value'];
$t.=$tre;
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$total_pred_sales].$m,$total_pred_sales_v);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$total_pred_qty].$m,$total_pred_qty_v);
$m++;
}
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => 'F0F0F0')
),
),
"A1:".$alf[$a+1]."2"
);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
chmod("cache/upload",0777);
$microtime=str_replace(".","",str_replace(" ","",microtime()));
$name="cache/upload/Report".$microtime.".xlsx";
$objWriter->save($name);
chmod($name,0777);
header("Location: ".$name);
?>

View File

@@ -0,0 +1,274 @@
<?php
$date_from=$_GET['date_from'];
$date_to=$_GET['date_to'];
set_include_path('include/PHPExcel/');
include 'PHPExcel.php';
include 'PHPExcel/Writer/Excel2007.php';
include 'PHPExcel/IOFactory.php';
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("E5 CRM");
$objPHPExcel->getProperties()->setLastModifiedBy("E5 CRM");
$objPHPExcel->getProperties()->setTitle("Office 2007 RPH");
$objPHPExcel->getProperties()->setSubject("Office 2007 RPH");
$objPHPExcel->getProperties()->setDescription("RPH");
$alf1="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for($i=0;$i<strlen($alf1);$i++)$alf[$i]=$alf1[$i];
$alf[]="AA";
$alf[]="AB";
$alf[]="AC";
$alf[]="AD";
$alf[]="AE";
$alf[]="AF";
$alf[]="AG";
$alf[]="AH";
$alf[]="AI";
$alf[]="AJ";
$alf[]="AK";
$alf[]="AL";
$alf[]="AM";
$alf[]="AN";
$alf[]="AO";
$alf[]="AP";
$alf[]="AQ";
$alf[]="AR";
$alf[]="AS";
$alf[]="AT";
$alf[]="AU";
$alf[]="AV";
$alf[]="AW";
$alf[]="AX";
$alf[]="AY";
$alf[]="AZ";
$alf[]="BA";
$alf[]="BB";
$alf[]="BC";
$alf[]="BD";
$alf[]="BE";
$alf[]="BF";
$alf[]="BG";
$alf[]="BH";
$alf[]="BI";
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(5);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(40);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('L')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('M')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('N')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('O')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('P')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('Q')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('R')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('S')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('T')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('U')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('V')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('W')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('X')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('Y')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('Z')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('AB')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('AC')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('AD')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('AE')->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension('AY')->setWidth(30);
$objPHPExcel->getActiveSheet()->getColumnDimension('AZ')->setWidth(30);
$objPHPExcel->getActiveSheet()->getColumnDimension('BA')->setWidth(30);
$objPHPExcel->getActiveSheet()->getColumnDimension('BB')->setWidth(30);
$objPHPExcel->getActiveSheet()->getColumnDimension('BC')->setWidth(30);
$objPHPExcel->getActiveSheet()->setTitle('Simple');
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->SetCellValue("A1","Lp.");
$objPHPExcel->getActiveSheet()->SetCellValue("B1","Name");
$objPHPExcel->getActiveSheet()->SetCellValue("C1","January");
$objPHPExcel->getActiveSheet()->SetCellValue("G1","February");
$objPHPExcel->getActiveSheet()->SetCellValue("K1","March");
$objPHPExcel->getActiveSheet()->SetCellValue("O1","April");
$objPHPExcel->getActiveSheet()->SetCellValue("S1","May");
$objPHPExcel->getActiveSheet()->SetCellValue("W1","June");
$objPHPExcel->getActiveSheet()->SetCellValue("AA1","July");
$objPHPExcel->getActiveSheet()->SetCellValue("AE1","August");
$objPHPExcel->getActiveSheet()->SetCellValue("AI1","September");
$objPHPExcel->getActiveSheet()->SetCellValue("AM1","October");
$objPHPExcel->getActiveSheet()->SetCellValue("AQ1","November");
$objPHPExcel->getActiveSheet()->SetCellValue("AU1","Dezember");
$objPHPExcel->getActiveSheet()->SetCellValue("AY1",$_REQUEST['year']." total");
$objPHPExcel->getActiveSheet()->SetCellValue("AZ1",$_REQUEST['year']." avg");
$objPHPExcel->getActiveSheet()->SetCellValue("BA1",($_REQUEST['year']-1)." total");
$objPHPExcel->getActiveSheet()->SetCellValue("BB1",($_REQUEST['year']-1)." avg");
$objPHPExcel->getActiveSheet()->SetCellValue("BC1","User");
$i=2;
$wh[]="deleted='0'";
if($_REQUEST['user_id'])$wh[]="assigned_user_id='".$_REQUEST['user_id']."'";
if($_REQUEST['account_id']){
$wh[]="parent_id='".$_REQUEST['account_id']."'";
$wh[]="parent_id is not null";
}
if(count($wh)>0)$where=" and ".implode(" and ",$wh);
else $where="";
$z="select * from accounts where 1=1".$where." order by name asc";
$w=mysql_query($z);
function getSumWz($year){
$w=$GLOBALS['db']->query("select id,type,register_date,currency_value,wz_id,parent_id,ecminvoiceout_id from ecminvoiceouts where register_date like '".$year."%' and deleted='0'");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
if(!$r['currency_value'])
$currency_value=1;
else $currency_value=$r['currency_value'];
$d=explode("-",$r['register_date']);
$dat=$d[0]."-".$d[1];
if($r['type']!="correct"){
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select sum(price*quantity) as s from ecminvoiceoutitems where ecminvoiceout_id='".$r['id']."' and deleted='0'"));
$total_netto=$currency_value*$rr['s'];
}
else{
$ww=$GLOBALS['db']->query("select price,quantity,ecminvoiceoutitem_id from ecminvoiceoutitems where ecminvoiceout_id='".$r['id']."' and deleted='0'");
$total_netto=0;
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
$rrrr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select price,quantity from ecminvoiceoutitems where id='".$rr['ecminvoiceoutitem_id']."'"));
$total_netto+=$currency_value*$rr['price']*$rr['quantity']-$currency_value*$rrrr['price']*$rrrr['quantity'];
}
}
if($r['wz_id']){
$rrr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select parent_id from ecmstockdocouts where id='".$r['wz_id']."'"));
$parent_id=$rrr['parent_id'];
}
else {
if($r['type']!="correct")$parent_id=$r['parent_id'];
else{
$rrr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select wz_id from ecminvoiceouts where id='".$r['ecminvoiceout_id']."'"));
$rrr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select parent_id from ecmstockdocouts where id='".$rrr['wz_id']."'"));
$parent_id=$rrr['parent_id'];
}
$parent_id=$r['parent_id'];
}
$sum[$dat][$parent_id]['tn']+=$total_netto;
}
return $sum;
}
function getMinSec($v){
$min=floor($v/60);
$sec=$v-$min*60;
if($min>0 || $sec>0)$str=$min."m ".$sec."s";
return $str;
}
$swz1=getSumWz($_REQUEST['year']);
$swz1m=getSumWz($_REQUEST['year']-1);
if($_REQUEST['account_id'] && $_REQUEST['user_id']){
$time=$_SESSION['EcmSalesReport_time'];
$ll=4;
}
else $ll=4;
while($r=mysql_fetch_array($w)){
$objPHPExcel->getActiveSheet()->SetCellValue("A".$i,($i-1));
$objPHPExcel->getActiveSheet()->SetCellValue("B".$i,$r['name']);
for($k=1;$k<=12;$k++){
if($k<10)$n="0".$k;
else $n=$k;
$swz=$swz1[$_REQUEST['year']."-".$n][$r['id']];
$total_netto=$swz['tn'];
$rval=mysql_fetch_array(mysql_query("select value from ecmsalesreports_predictions where account_id='".$r['id']."' and year='".$_REQUEST['year']."' and month='".$n."' and deleted='0'"));
$value=$rval['value'];
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$ll*($k-1)+2].$i,$total_netto);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$ll*($k-1)+3].$i,$value);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$ll*($k-1)+4].$i,getMinSec($time[$r['id']][$_REQUEST['year']."-".$n]['duration']));
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$ll*($k-1)+5].$i,$time[$r['id']][$_REQUEST['year']."-".$n]['l']);
$sum_total_netto[$_REQUEST['year']."-".$n]+=$total_netto;
$sum_total_netto[$_REQUEST['year']]+=$total_netto;
$account_total[$r['id']]+=$total_netto;
}
for($k=1;$k<=12;$k++){
if($k<10)$n="0".$k;
else $n=$k;
$swzm=$swz1m[($_REQUEST['year']-1)."-".$n][$r['id']];
$total_netto_m=$swzm['tn'];
$sum_total_netto_m[($_REQUEST['year']-1)."-".$n]+=$total_netto_m;
$sum_total_netto_m[($_REQUEST['year']-1)]+=$total_netto_m;
$account_total_m[$r['id']]+=$total_netto_m;
}
$objPHPExcel->getActiveSheet()->SetCellValue("AY".$i,$account_total[$r['id']]);
$objPHPExcel->getActiveSheet()->SetCellValue("AZ".$i,($account_total[$r['id']]/((int)date("m"))));
$objPHPExcel->getActiveSheet()->SetCellValue("BA".$i,$account_total_m[$r['id']]);
$objPHPExcel->getActiveSheet()->SetCellValue("BB".$i,($account_total_m[$r['id']]/12));
$ruser=mysql_fetch_array(mysql_query("select * from users where id='".$r['assigned_user_id']."'"));
$objPHPExcel->getActiveSheet()->SetCellValue("BC".$i,$ruser['first_name'].' '.$ruser['last_name']);
$i++;
}
for($k=1;$k<=12;$k++){
if($k<10)$n="0".$k;
else $n=$k;
$allvalue=0;
$wacc=mysql_query("select * from accounts where 1=1".$where." order by name asc");
while($racc=mysql_fetch_array($wacc)){
$wval=mysql_query("select value from ecmsalesreports_predictions where account_id='".$racc['id']."' and year='".$_REQUEST['year']."' and month='".$n."' and deleted='0'");
while($rval=mysql_fetch_array($wval)){
$allvalue+=$rval['value'];
}
}
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$ll*($k-1)+2].$i,($sum_total_netto[$_REQUEST['year'].'-'.$n]));
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$ll*($k-1)+3].$i,$allvalue);
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$ll*($k-1)+4].$i,getMinSec($time[$_REQUEST['year']."-".$n]['duration']));
$objPHPExcel->getActiveSheet()->SetCellValue($alf[$ll*($k-1)+5].$i,$time[$_REQUEST['year']."-".$n]['l']);
}
$objPHPExcel->getActiveSheet()->SetCellValue("AY".$i,$sum_total_netto[$_REQUEST['year']]);
$objPHPExcel->getActiveSheet()->SetCellValue("AZ".$i,($sum_total_netto[$_REQUEST['year']]/((int)date("m"))));
$objPHPExcel->getActiveSheet()->SetCellValue("BA".$i,$sum_total_netto_m[$_REQUEST['year']-1]);
$objPHPExcel->getActiveSheet()->SetCellValue("BB".$i,($sum_total_netto_m[$_REQUEST['year']-1]/12));
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => 'F0F0F0')
),
'borders' => array(
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
)
),
"A1:BA1"
);
$objPHPExcel->getActiveSheet()->duplicateStyleArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => 'F0F0F0')
),
'borders' => array(
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
)
),
"A".($i).":BA".($i)
);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
chmod("cache/upload",0777);
$microtime=str_replace(".","",str_replace(" ","",microtime()));
$name="cache/upload/RPHReport".$microtime.".xlsx";
$objWriter->save($name);
chmod($name,0777);
header("Location: ".$name);
?>

View File

@@ -0,0 +1,36 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings, $current_user, $app_list_strings;
require_once('modules/EcmReports/EcmReport.php');
require_once('modules/EcmReports/Forms.php');
require_once ('include/time.php');
require_once('include/json_config.php');
$json_config = new json_config();
$focus = new EcmReport();
if(isset($_REQUEST['record']))$focus->retrieve($_REQUEST['record']);
require_once('include/MVC/View/SugarView.php');
if(file_exists('modules/EcmReports/views/view.detail.php')) {
require_once('modules/EcmReports/views/view.detail.php');
$detail = new EcmReport();
}
else{
require_once('include/MVC/View/views/view.detail.php');
$detail = new ViewDetail();
$detail->ss = new Sugar_Smarty();
$detail->module = 'EcmReports';
}
global $app_list_strings;
$detail->bean = $focus;
$detail->preDisplay();
echo $detail->display();
?>

161
modules/EcmReports/EcmReport.php Executable file
View File

@@ -0,0 +1,161 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*********************************************************************************
* Description: TODO: To be written.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
********************************************************************************/
require_once('data/SugarBean.php');
require_once('include/utils.php');
class EcmReport extends SugarBean {
var $field_name_map = array();
var $id;
var $date_entered;
var $date_modified;
var $modified_user_id;
var $assigned_user_id;
var $name;
var $value;
var $module_dir = 'EcmReports';
var $table_name = "ecmreports";
var $object_name = "EcmReport";
var $new_schema = true;
var $additional_column_fields = array('assigned_user_name', 'assigned_user_id');
function EcmReport() {
parent::SugarBean();
$this->setupCustomFields('EcmReports');
foreach($this->field_defs as $field){
$this->field_name_map[$field['name']] = $field;
}
}
function get_summary_text(){
return $this->name;
}
function create_list_query($order_by, $where, $show_deleted = 0){
$custom_join = $this->custom_fields->getJOIN();
$query ="SELECT ";
$query.="ecmreports.*,users.user_name as assigned_user_name";
if($custom_join)$query.=$custom_join['select'];
$query.=" FROM ecmreports ";
$query.="LEFT JOIN users ON ecmreports.assigned_user_id=users.id";
$query.=" ";
if($custom_join)$query.=$custom_join['join'];
$where_auto='1=1';
if($show_deleted==0)$where_auto=" $this->table_name.deleted=0 ";
elseif($show_deleted==1)$where_auto=" $this->table_name.deleted=1 ";
if($where!="")$query.="where $where AND ".$where_auto;
else $query.="where ".$where_auto;
if(substr_count($order_by,'.')>0)$query .= " ORDER BY $order_by";
elseif($order_by != "")$query .= " ORDER BY $order_by";
else $query .= " ORDER BY ecmreports.name";
return $query;
}
function create_export_query($order_by,$where){
$custom_join = $this->custom_fields->getJOIN();
$query ="SELECT ";
$query.="ecmreports.*,users.user_name as assigned_user_name";
if($custom_join)$query.=$custom_join['select'];
$query.=" FROM ecmreports ";
$query.="LEFT JOIN users ON ecmreports.assigned_user_id=users.id";
$query.=" ";
if($custom_join)$query.=$custom_join['join'];
$where_auto='1=1';
if($show_deleted==0)$where_auto=" $this->table_name.deleted=0 ";
elseif($show_deleted==1)$where_auto=" $this->table_name.deleted=1 ";
if($where!="")$query.="where $where AND ".$where_auto;
else $query.="where ".$where_auto;
if(substr_count($order_by,'.')>0)$query .= " ORDER BY $order_by";
elseif($order_by != "")$query .= " ORDER BY $order_by";
else $query .= " ORDER BY ecmreports.name";
return $query;
}
function fill_in_additional_list_fields(){
}
function fill_in_additional_detail_fields(){
parent::fill_in_additional_detail_fields();
}
function get_list_view_data(){
global $current_language;
$the_array=parent::get_list_view_data();
$app_list_strings=return_app_list_strings_language($current_language);
$mod_strings=return_module_language($current_language,'EcmReports');
$the_array['NAME']=(($this->name == "") ? "<em>blank</em>" : $this->name);
$the_array['ENCODED_NAME']=$this->name;
return $the_array;
}
function build_generic_where_clause($the_query_string){
$where_clauses=array();
$the_query_string=PearDatabase::quote(from_html($the_query_string));
array_push($where_clauses,"ecmreports.name like '$the_query_string%'");
$the_where="";
foreach($where_clauses as $clause){
if($the_where!="")$the_where.=" or ";
$the_where.=$clause;
}
return $the_where;
}
function set_notification_body($xtpl,$ecmreport)
{
global $mod_strings,$app_list_strings;
$xtpl->assign("ECMREPORT_SUBJECT",$ecmreport->name);
return $xtpl;
}
function bean_implements($interface){
switch($interface){
case 'ACL':return true;
}
return false;
}
function save($check_notify=FALSE){
return parent::save($check_notify);
}
}
?>

View File

@@ -0,0 +1,73 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
require_once('include/EditView/QuickCreate.php');
require_once('modules/EcmReports/EcmReport.php');
require_once('include/javascript/javascript.php');
class EcmReportsQuickCreate extends QuickCreate {
var $javascript;
function process() {
global $current_user, $timedate, $app_list_strings, $current_language, $mod_strings;
$mod_strings = return_module_language($current_language, 'EcmReports');
parent::process();
$this->ss->assign("PRIORITY_OPTIONS", get_select_options_with_id($app_list_strings['ecmreport_priority_dom'], $app_list_strings['ecmreport_priority_default_key']));
$this->ss->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['ecmreport_status_dom'], $app_list_strings['ecmreport_status_default_key']));
$this->ss->assign("TYPE_OPTIONS", get_select_options_with_id($app_list_strings['ecmreport_type_dom'],$app_list_strings['ecmreport_type_default_key']));
if($this->viaAJAX) { // override for ajax call
$this->ss->assign('saveOnclick', "onclick='if(check_form(\"ecmreportsQuickCreate\")) return SUGAR.subpanelUtils.inlineSave(this.form.id, \"ecmreports\"); else return false;'");
$this->ss->assign('cancelOnclick', "onclick='return SUGAR.subpanelUtils.cancelCreate(\"subpanel_ecmreports\")';");
}
$this->ss->assign('viaAJAX', $this->viaAJAX);
$this->javascript = new javascript();
$this->javascript->setFormName('ecmreportsQuickCreate');
$focus = new EcmReport();
$this->javascript->setSugarBean($focus);
$this->javascript->addAllFields('');
$this->ss->assign('additionalScripts', $this->javascript->getScript(false));
}
}
?>

View File

@@ -0,0 +1,5 @@
<?php
include 'modules/EcmReports/optima/ExportOptima.php';
?>

View File

@@ -0,0 +1,305 @@
<?php
global $db;
if(!$_REQUEST['year']){
$_REQUEST['year']=date("Y");
$_GET['year']=date("Y");
}
if($_REQUEST['save']){
//print_r($_REQUEST);
$w=$db->query("select id from ecmproducts where product_active='1' and deleted='0' order by product_category_name asc,code asc");
while($r=$db->fetchByAssoc($w)){
$ww=$db->query("select id from accounts where deleted='0' and core_client='1' order by name asc");
while($rr=$db->fetchByAssoc($ww)){
$rrr=$db->fetchByAssoc($db->query("select count(*) as cnt from ecmforecasts where ecmproduct_id='".$r['id']."' and account_id='".$rr['id']."'"));
if($_REQUEST['pred'][$r['id']][$rr['id']]!=0){
$value=$_REQUEST['pred'][$r['id']][$rr['id']];
if($rrr['cnt']>0){
$db->query("update ecmforecasts set value='".$value."' where ecmproduct_id='".$r['id']."' and account_id='".$rr['id']."'");
}
else{
$db->query("insert into ecmforecasts set id='".create_guid()."',ecmproduct_id='".$r['id']."',account_id='".$rr['id']."',value='".$value."'");
}
}
}
$rrr=$db->fetchByAssoc($db->query("select count(*) as cnt from ecmforecasts where ecmproduct_id='".$r['id']."' and account_id='new'"));
if($_REQUEST['pred'][$r['id']]["new"]!=0){
$value=$_REQUEST['pred'][$r['id']]["new"];
if($rrr['cnt']>0){
$db->query("update ecmforecasts set value='".$value."' where ecmproduct_id='".$r['id']."' and account_id='new'");
}
else{
$db->query("insert into ecmforecasts set id='".create_guid()."',ecmproduct_id='".$r['id']."',account_id='new',value='".$value."'");
}
}
}
header("Location: index.php?module=EcmReports&action=Forecast&category=".$_REQUEST['category']);
}
?>
<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts" width="16" border="0" height="16"></td><td><h2>Charts: Products </h2></td></tr></table><br />
<ul class="tablist">
<li>
<a class="current" href="#">Basic Search</a>
</li>
</ul>
<form action="index.php" method="get" name="search_reports">
<input type="hidden" name="module" value="EcmReports" />
<input type="hidden" name="action" value="Forecast" />
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="dataLabel" width="20%" nowrap="nowrap">Year</td>
<td class="dataField" width="30%" nowrap="nowrap">
<select name="year" id="year">
<?
$ey=(int)date("Y");
$sy=2000;
for($i=$sy;$i<=$ey;$i++){
echo '<option value="'.$i.'"';
if($i==$_GET['year'])echo ' selected';
echo '>'.$i.'</option>';
}
?>
</select>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">Category</td>
<td class="dataField" width="90%" nowrap="nowrap">
<select name="category" id="category"><option value="">select</option>
<?
$w=mysql_query("select id,name from ecmproductcategories where deleted='0' order by name asc");
while($r=mysql_fetch_array($w)){
echo '<option value="'.$r['id'].'"';
if($_REQUEST['category']==$r['id'])echo ' selected';
echo '>'.$r['name'].'</option>';
}
?>
</select>
</td>
</tr>
</tbody>
</table>
<input class="button" name="submit" value="Search" type="submit">
<input class="button" name="xls" value="Create XLS" type="button" onclick="location.href='index.php?module=EcmReports&action=CreateXLSforecast&category=<?php echo $_REQUEST['category'];?>&year=<?php echo $_REQUEST['year'];?>';">
<br />
</form>
<?php
$trs='<tr>';
$tre='</tr>';
$tds='<td class="oddListRowS1" style="text-align:center">';
$tds_left='<td class="oddListRowS1">';
$tds_l='<td class="listViewThS1" style="width:40px;border: 1px solid #cccccc;text-align:center">';
$tds_cat='<td class="listViewThS1" style="width:80px;border: 1px solid #cccccc;text-align:center">';
$tds_inv='<td class="listViewThS1" colspan="3" style="width:80px;border: 1px solid #cccccc;text-align:center">';
$tds_name='<td class="listViewThS1" style="width:130px;border: 1px solid #cccccc;text-align:center">';
$tds_index='<td class="listViewThS1" style="width:50px;border: 1px solid #cccccc;text-align:center">';
$tds_total='<td class="listViewThS1" colspan="4" style="width:30px;border: 1px solid #cccccc;text-align:center">';
$tds_account='<td colspan="5" class="listViewThS1" style="width:200px;border: 1px solid #cccccc;text-align:center">';
$tds_account_new='<td colspan="3" class="listViewThS1" style="width:100px;border: 1px solid #cccccc;text-align:center">';
$tbs='<table cellpadding="0" cellspacing="0" border="0" class="ListView" width="100%">';
$tbe='</table>';
$tde='</td>';
$tdr='</tr>';
include_once("modules/EcmReports/class.sales.php");
$w=$db->query("select id from accounts where deleted='0' and core_client='1'");
if(!$_REQUEST['year'])$_REQUEST['year']=date("Y");
while($r=$db->fetchByAssoc($w)){
$s=new Sales();
$s->date_from=$_REQUEST['year']."-01-01";
$s->date_to=$_REQUEST['year']."-12-31";
$s->account_id=$r['id'];
$s->product_active="active";
$sdata[$r['id']]=$s->getSalesByProductForecast();
}
echo '<script language="javascript" src="modules/EcmProducts/helper.js"></script>';
echo '<script language="javascript" src="modules/EcmProducts/mintajax.js"></script>';
echo '<script>
function nf(nStr, inD, outD, sep)
{
nStr += \'\';
var dpos = nStr.indexOf(inD);
var nStrEnd = \'\';
if (dpos != -1) {
nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
nStr = nStr.substring(0, dpos);
}
var rgx = /(\d+)(\d{3})/;
while (rgx.test(nStr)) {
nStr = nStr.replace(rgx, \'$1\' + sep + \'$2\');
}
return nStr + nStrEnd;
}
function countTotals(){
var q;var s;var st=0;var qt=0;';
if($_REQUEST['category'])$wh_cat=" and product_category_id='".$_REQUEST['category']."'";
else $wh_cat="";
$w=$db->query("select ems_price,ems_qty_in_stock,id,name,code,product_category_name,product_category_id,srp_price from ecmproducts where product_active='1' and production!='1'".$wh_cat." and deleted='0' order by product_category_name asc,code asc");
while($r=$db->fetchByAssoc($w)){
echo 'q=0;s=0;';
$ww=$db->query("select name,id from accounts where deleted='0' and core_client='1' order by name asc");
while($rr=$db->fetchByAssoc($ww)){
echo 'q+=parseInt(document.getElementById("pred['.$r['id'].']['.$rr['id'].']").value);
s+=parseFloat(document.getElementById("avg_'.$r['id'].'_'.$rr['id'].'").value)*parseInt(document.getElementById("pred['.$r['id'].']['.$rr['id'].']").value);';
}
echo 'q+=parseInt(document.getElementById("pred['.$r['id'].'][new]").value);
s+=parseFloat(document.getElementById("avg_'.$r['id'].'_new").value)*parseInt(document.getElementById("pred['.$r['id'].'][new]").value);';
echo 'document.getElementById("total_pred_sales_'.$r['id'].'").innerHTML=nf(s.toFixed(2),\'.\',\',\',\'.\');document.getElementById("total_pred_qty_'.$r['id'].'").innerHTML=q;st+=s;qt+=q;';
}
echo 'document.getElementById("total_pred_sales").innerHTML=nf(st.toFixed(2),\'.\',\',\',\'.\');document.getElementById("total_pred_qty").innerHTML=qt;
}
function countPrediction(p,a){
var q=document.getElementById("pred["+p+"]["+a+"]").value;
var s=document.getElementById("avg_"+p+"_"+a).value;
q=q.replace(",",".");
q=parseFloat(q);
s=s.replace(",",".");
s=parseFloat(s);
if(s && q)document.getElementById("pred_"+p+"_"+a).innerHTML=nf(s*q,\'.\',\',\',\'.\');
countTotals();
}
</script>';
$t.='<br><form action="index.php?module=EcmReports&action=Forecast&category='.$_REQUEST['category'].'" method="post"><input type="submit" name="save" class="button" value="Save" /><br><br>';
$t.=$tbs;
$t.=$trs;
$t.=$tds_index."Index".$tde;
$t.=$tds_name."Name".$tde;
$t.=$tds_cat."Category".$tde;
$t.=$tds_inv."Inventory".$tde;
$t.=$tds_cat."SRP price".$tde;
$t.=$tds_total."Total".$tde;
$w=$db->query("select name from accounts where deleted='0' and core_client='1' order by name asc");
while($r=$db->fetchByAssoc($w)){
$t.=$tds_account.$r['name'].$tde;
}
$t.=$tds_account_new."New clients".$tde;
$t.=$tre;
$t.=$trs;
$t.=$tds_index."&nbsp;".$tde;
$t.=$tds_name."&nbsp;".$tde;
$t.=$tds_cat."&nbsp;".$tde;
$t.=$tds_cat."Qty".$tde;
$t.=$tds_cat."Price".$tde;
$t.=$tds_cat."Value".$tde;
$t.=$tds_cat."&nbsp;".$tde;
$t.=$tds_cat."Sales".$tde;
$t.=$tds_cat."Qty".$tde;
$t.=$tds_cat."Pred. sales".$tde;
$t.=$tds_cat."Pred. qty".$tde;
$w=$db->query("select name from accounts where deleted='0' and core_client='1' order by name asc");
while($r=$db->fetchByAssoc($w)){
$t.=$tds_l."Avg. price".$tde;
$t.=$tds_l."Qty".$tde;
$t.=$tds_l."Sales".$tde;
$t.=$tds_l."Pred. qty".$tde;
$t.=$tds_l."Pred. sales".$tde;
}
$t.=$tds_l."Avg. price".$tde;
$t.=$tds_l."Qty".$tde;
$t.=$tds_l."Prediction".$tde;
$t.=$tre;
function getTotalFromAccounts($d,$id,$type="sales"){
global $db;
$ww=$db->query("select name,id from accounts where deleted='0' and core_client='1' order by name asc");
while($rr=$db->fetchByAssoc($ww)){
$total+=$d[$rr['id']][$id][$type];
}
return $total;
}
if($_REQUEST['category'])$wh_cat=" and product_category_id='".$_REQUEST['category']."'";
else $wh_cat="";
$w=$db->query("select ems_price,ems_qty_in_stock,id,name,code,product_category_name,product_category_id,srp_price from ecmproducts where product_active='1' and production!='1'".$wh_cat." and deleted='0' order by product_category_name asc,code asc");
while($r=$db->fetchByAssoc($w)){
$m++;
$t.=$trs;
$t.=$tds_left.$r['code'].$tde;
$t.=$tds_left.'<a href="index.php?module=EcmProducts&action=DetailView&record='.$r['id'].'">'.$r['name'].'</a>'.$tde;
$t.=$tds.'<a href="index.php?modules=EcmProductCategories&action=DetailView&record='.$r['product_category_id'].'">'.$r['product_category_name'].'</a>'.$tde;
$t.=$tds.number_format($r['ems_qty_in_stock'],0,",",".").$tde;
$t.=$tds.number_format($r['ems_price'],2,",",".").$tde;
$t.=$tds.number_format($r['ems_price']*$r['ems_qty_in_stock'],2,",",".").$tde;
$t.=$tds.'<div id="srp_price_'.$r['id'].'">'.number_format($r['srp_price'],2,",",".").'</div>'.$tde;
$t.=$tds.number_format(getTotalFromAccounts($sdata,$r['id']),2,",",".").$tde;
$t.=$tds.number_format(getTotalFromAccounts($sdata,$r['id'],"quantity"),0,",",".").$tde;
$t.=$tds.'<div id="total_pred_sales_'.$r['id'].'"><div>'.$tde;
$t.=$tds.'<div id="total_pred_qty_'.$r['id'].'"><div>'.$tde;
$total_srp_price+=$r['srp_price'];
$total_ems_qty+=$r['ems_qty_in_stock'];
$total_ems_price+=$r['ems_qty_in_stock'];
$total_ems_value+=$r['ems_qty_in_stock']*$r['ems_price'];
$total_sales+=getTotalFromAccounts($sdata,$r['id']);
$total_qty+=getTotalFromAccounts($sdata,$r['id'],"quantity");
$ww=$db->query("select name,id from accounts where deleted='0' and core_client='1' order by name asc");
while($rr=$db->fetchByAssoc($ww)){
if($sdata[$rr['id']][$r['id']]['quantity']>0)$aprice=$sdata[$rr['id']][$r['id']]['sales']/$sdata[$rr['id']][$r['id']]['quantity'];
else $aprice=0;
if($aprice==0){
$rpb=$db->fetchByAssoc($db->query("select price from ecmpricebooks_ecmproducts where active=1 and account_id='".$rr['id']."' and ecmproduct_id='".$r['id']."' and deleted='0'"));
$aprice=$rpb['price'];
}
if($aprice==0){
$rpb=$db->fetchByAssoc($db->query("select price from ecmpricebooks_ecmproducts where ecmpricebook_id='7b840616-a226-4a15-a831-4d11f116995a' and ecmproduct_id='".$r['id']."' and deleted='0'"));
$aprice=$rpb['price'];
}
$t.=$tds.'<input size="2" type="hidden" name="avg_'.$r['id'].'_'.$rr['id'].'" id="avg_'.$r['id'].'_'.$rr['id'].'" value="'.round($aprice,2).'">'.number_format($aprice,2,",",".").$tde;
$t.=$tds.number_format($sdata[$rr['id']][$r['id']]['quantity'],0,",",".").$tde;
$t.=$tds.number_format($sdata[$rr['id']][$r['id']]['sales'],2,",",".").$tde;
$rrr=$db->fetchByAssoc($db->query("select value from ecmforecasts where ecmproduct_id='".$r['id']."' and account_id='".$rr['id']."'"));
$pred=(int)$rrr['value'];
$t.=$tds.'<input onclick="countPrediction(\''.$r['id'].'\',\''.$rr['id'].'\');" onblur="countPrediction(\''.$r['id'].'\',\''.$rr['id'].'\');" type="text" name="pred['.$r['id'].']['.$rr['id'].']" id="pred['.$r['id'].']['.$rr['id'].']" value="'.$pred.'" size="4">'.$tde;
$t.=$tds.'<div id="pred_'.$r['id'].'_'.$rr['id'].'" style="text-align:center">'.number_format($rrr['value']*round($aprice,2),2,",",".").'</div>'.$tde;
$totals_quantity[$rr['id']]+=$sdata[$rr['id']][$r['id']]['quantity'];
$totals_sales[$rr['id']]+=$sdata[$rr['id']][$r['id']]['sales'];
$totals_pred[$rr['id']]+=$rrr['value']*round($aprice,2);
$totals_pred_qty[$rr['id']]+=$rrr['value'];
}
if(getTotalFromAccounts($sdata,$r['id'],"quantity")>0)$avg_price=getTotalFromAccounts($sdata,$r['id'])/getTotalFromAccounts($sdata,$r['id'],"quantity");
else $avg_price=0;
if($avg_price==0){
$rpb=$db->fetchByAssoc($db->query("select price from ecmpricebooks_ecmproducts where ecmpricebook_id='7b840616-a226-4a15-a831-4d11f116995a' and ecmproduct_id='".$r['id']."' and deleted='0'"));
$avg_price=$rpb['price'];
}
$t.=$tds.'<input size="2" type="hidden" name="avg_'.$r['id'].'_new" id="avg_'.$r['id'].'_new" value="'.round($avg_price,2).'">'.number_format($avg_price,2,",",".").$tde;
$rrr=$db->fetchByAssoc($db->query("select value from ecmforecasts where ecmproduct_id='".$r['id']."' and account_id='new'"));
$pred=(int)$rrr['value'];
$t.=$tds.'<input onclick="countPrediction(\''.$r['id'].'\',\'new\');" onblur="countPrediction(\''.$r['id'].'\',\'new\');" type="text" name="pred['.$r['id'].'][new]" id="pred['.$r['id'].'][new]" value="'.$pred.'" size="4">'.$tde;
$t.=$tds.'<div id="pred_'.$r['id'].'_new" style="text-align:center">'.number_format($rrr['value']*round($avg_price,2),2,",",".").'</div>'.$tde;
$totals_pred["new"]+=$rrr['value']*round($avg_price,2);
$totals_pred_qty["new"]+=$rrr['value'];
$t.=$tre;
}
$t.='<tr style="font-weight:bold;">';
$t.=$tds_left."&nbsp;".$tde;
$t.=$tds_left."&nbsp;".$tde;
$t.=$tds."&nbsp;".$tde;
$t.=$tds.number_format($total_ems_qty,0,",",".").$tde;
$t.=$tds.number_format($total_ems_value/$total_ems_qty,2,",",".").$tde;
$t.=$tds.number_format($total_ems_value,2,",",".").$tde;
$t.=$tds.number_format($total_srp_price/$m,2,",",".").$tde;
$t.=$tds.number_format($total_sales,2,",",".").$tde;
$t.=$tds.number_format($total_qty,0,",",".").$tde;
$t.=$tds.'<div id="total_pred_sales"></div>'.$tde;
$t.=$tds.'<div id="total_pred_qty"></div>'.$tde;
$ww=$db->query("select name,id from accounts where deleted='0' and core_client='1' order by name asc");
while($rr=$db->fetchByAssoc($ww)){
$t.=$tds.@number_format($totals_sales[$rr['id']]/$totals_quantity[$rr['id']],2,",",".").$tde;
$t.=$tds.number_format($totals_quantity[$rr['id']],0,",",".").$tde;
$t.=$tds.number_format($totals_sales[$rr['id']],2,",",".").$tde;
$t.=$tds.'<div id="total_pred_qty_'.$rr['id'].'">'.number_format($totals_pred_qty[$rr['id']],0,",",".").'</div>'.$tde;
$t.=$tds.'<div id="total_pred_sales_'.$rr['id'].'">'.number_format($totals_pred[$rr['id']],2,",",".").'</div>'.$tde;
}
$t.=$tds.@number_format($totals_pred["new"]/$totals_pred_qty["new"],2,",",".").$tde;
$t.=$tds.number_format($totals_pred_qty["new"],0,",",".").$tde;
$t.=$tds.number_format($totals_pred["new"],2,",",".").$tde;
$t.=$tre;
$t.=$tbe;
$t.='</form><script>countTotals();</script>';
echo $t;
?>

37
modules/EcmReports/Forms.php Executable file
View File

@@ -0,0 +1,37 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*********************************************************************************/
require_once('include/EditView/SideQuickCreate.php');

View File

@@ -0,0 +1,445 @@
<?
session_start();
$db = $GLOBALS['db'];
$account=$_GET['account'];
$account_id=$_GET['account_id'];
$account_name=$_GET['account_name'];
$type=$_GET['type'];
if(!$_GET['date_from'])$date_from=date("Y-m-d");
else $date_from=$GLOBALS['timedate']->to_db_date($_GET['date_from']);
$exp=explode("-",$date_from);
$date_from=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])+24*3600);
if(!$date_from)$date_from=date("Y-m-d");
if(!$_GET['date_to'])$date_to=date("Y-m-d");
else $date_to=$GLOBALS['timedate']->to_db_date($_GET['date_to']);
$exp=explode("-",$date_to);
$date_to=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])+24*3600);
if(!$date_to)$date_to=date("Y-m-d");
?>
<link rel="stylesheet" href="include/jQuery/jquery-ui/themes/base/jquery-ui.css">
<script src="include/jQuery/jquery-2.1.0.min.js"></script>
<script src="include/jQuery/jquery-ui/ui/jquery-ui.js"></script>
<style>
#draggable { width: 150px; height: 150px; padding: 0.5em; }
#tab table, #tab td, #tab th {border: 1px solid black; width:100%}
</style>
<script>
$(function() {
$( "div[name=lol]" ).draggable();
});
$("div[name=lol]").mousemove(function(e){
var mousePos = {'x': e.layerX, 'y': e.layerY};
});
function hide(obj) {
var el = document.getElementById(obj);
el.style.display = 'none';
}
function show(obj,event) {
var el = document.getElementById(obj);
el.style.display = 'block';
var x=event.clientX;
var y=event.clientY;
x=x-300;
el.style.position = "absolute";
el.style.top = y+'px'; //or whatever
el.style.left = x+'px'; // or whatever
}
</script>
<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts" width="16" border="0" height="16"></td><td><h2>Raport sprzedaży po kategorii </h2></td></tr></table><br />
<ul class="tablist" style="width:100%;">
<li>
<a class="current" href="#">Podstawowe wyszukiwanie</a>
</li>
</ul>
<form action="index.php" method="get" name="search_reports">
<input type="hidden" name="module" value="EcmReports" />
<input type="hidden" name="action" value="InvoiceCatRap" />
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="dataLabel" width="5%" nowrap="nowrap">
Data od </td>
<td class="dataField" width="10%" nowrap="nowrap">
<input autocomplete="off" name="date_from" id="date_from" value="<? echo $GLOBALS['timedate']->to_display_date($date_from);?>" title="" tabindex="" size="11" maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_from_trigger" align="absmiddle" border="0">
<script type="text/javascript">
Calendar.setup ({
inputField : "date_from",
daFormat : "<? echo str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));?>",
button : "date_from_trigger",
singleClick : true,
dateStr : "",
step : 1
}
);
</script>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Data do</td>
<td class="dataField" width="30%" nowrap="nowrap">
<input autocomplete="off" name="date_to" id="date_to" value="<? echo $GLOBALS['timedate']->to_display_date($date_to);?>" title="" tabindex="" size="11" maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_to_trigger" align="absmiddle" border="0">
<script type="text/javascript">
Calendar.setup ({
inputField : "date_to",
daFormat : "<? echo str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));?>",
button : "date_to_trigger",
singleClick : true,
dateStr : "",
step : 1
}
);
</script>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Kategoria </td>
<td class="dataField" width="30%" nowrap="nowrap">
<select name="account[]" multiple=1>
<option value="">Wybierz</option>
<?php
$w=$db->query("select id,name from ecmproductcategories where deleted='0' order by name asc");
while($r=$db->fetchByAssoc($w)){
echo '<option value="'.$r['id'].'"';
foreach ($account as $value)
{
if($r['id']==$value)echo ' selected';
}
if($account==$r['id'])echo ' selected';
echo '>'.$r['name'].'</option>';
}
?>
</select>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Typ dokumentu </td>
<td class="dataField" width="30%" nowrap="nowrap">
<select name="type">
<option value="" <? if($type=="")echo 'selected';?>>normalny i korekta</option>
<option value="normal" <? if($type=="normal")echo 'selected';?>>normalny</option>
<option value="correct" <? if($type=="correct")echo 'selected';?>>korekta</option>
</select>
</td>
</tr>
</tbody>
</table>
<input class="button" name="submit" value="Szukaj" type="submit">
<input class="button" name="clear" value="Wyczyść" type="button" onclick="location.href='index.php?module=EcmReports&action=ListDailySales';"><?
$ids='';
if(count($account)>0 && count($account)<2){
foreach ($account as $item){
$ids="&account[]=".$item."";
}
} else {
foreach ($account as $item){
$ids.="&account[]=".$item."";
}
}
echo '&nbsp;<input type="button" class="button" name="CreateXLS" value="Otwórz XLS" onclick="location.href=\'index.php?module=EcmProductCategories&action=createXLS&date_from='.$date_from.'&date_to='.$date_to.''.$ids.'&type='.$type.'\';">';
unset($ids);
?>
<input class="button" name="txt" value="Utwórz TXT" type="submit">
</form><br />
<?php
$tds1='<td class="listViewThS1">';
$trs='<tr onMouseover="this.bgColor=\'#EEEEEE\'"onMouseout="this.bgColor=\'#FFFFFF\'">';
$tre='</tr>';
$tds='<td class="oddListRowS1">';
$tde='</td>';
$tbs='<table cellpadding="0" cellspacing="0" border="0" class="ListView" style="width:100%;">';
$tbe='</table>';
$t.=$tbs;
$t.=$trs;
$t.=$tds1;
$t.="Produkt";
$t.=$tde;
$t.=$tds1;
$t.="Kod";
$t.=$tde;
$t.=$tds1;
$t.='<p style="text-align: right;">'."Ilość".'</p>';
$t.=$tde;
$t.=$tds1;
$t.='<p style="text-align: right;">'."Kwota".'</p>';
$t.=$tde;
$t.=$tds1;
$t.='<p style="text-align: right;">'."Szczegóły".'</p>';
$t.=$tde;
$t.=$tds1;
$t.='<p style="text-align: right;">'."Kategoria".'</p>';
$t.=$tde;
$t.=$tre;
$i=1;
$wh[]="fk.deleted='0'";
$wh[]="fk.canceled='0'";
if($type)$wh[]="fk.type='".$type."'";
//note that sel1[] is now $sel1
$ids=array();
unset($_SESSION);
if(count($account)>0 && count($account)<2){
foreach ($account as $item){
$wh[]="cat.id='".$item."'";
$_SESSION['zaznaczone'][]=$item;
}
} else {
foreach ($account as $item){
$ids[]="'".$item."'";
}
$ac=implode(",",$ids);
$wh[]='cat.id IN ('.$ac.')';
}
if($date_from)$wh[]="fk.register_date>='".$date_from."'";
if($date_to)$wh[]="fk.register_date<='".$date_to."'";
$where=implode(" and ",$wh);
//Print out the selection
$z="select fk.id,p.name,p.code,p.ecmproduct_id, sum(
CASE WHEN fk.type!='correct'
THEN
CASE WHEN fk.currency_value is null or fk.currency_value='' or fk.currency_value=0
THEN
p.subtotal
ELSE
p.subtotal*fk.currency_value
END
ELSE
CASE WHEN p.old_subtotal IS null OR p.old_subtotal='' THEN
0
ELSE
CASE WHEN fk.currency_value is null or fk.currency_value='' or fk.currency_value=0
THEN
p.subtotal-p.old_subtotal
ELSE
(p.subtotal-p.old_subtotal)*fk.currency_value
END
END
END
) as razem,
sum(
CASE WHEN fk.type!='correct'
THEN
p.quantity
ELSE
p.quantity-p.old_quantity
END
) as quantity,p.subprice,cat.name as cname,cat.id as cid from ecminvoiceouts as fk
inner join ecminvoiceoutitems as p on p.ecminvoiceout_id=fk.id
inner join ecmproducts as pr on pr.id=p.ecmproduct_id
inner join ecmproductcategories as cat on cat.id=pr.product_category_id
where ".$where."
group by p.ecmproduct_id order by pr.product_category_id,razem desc;";
$w=$db->query($z);
echo '<br>'.$w->num_rows.'<br>';
echo mysql_error();
$ilosc=0;
$razem=0;
$microtime=str_replace(".","",str_replace(" ","",microtime()));
$name='fakury_'.$microtime;
$fp = fopen('modules/EcmReports/TXT/'.$name.'.txt', 'w');
fwrite($fp, 'RaportCat'."\n");
$abc=0;
$note="";
$sum=array();
while($r=$db->fetchByAssoc($w)){
$z2="select fk.id,p.name,p.code,p.ecmproduct_id, sum(
CASE WHEN fk.type!='correct'
THEN
CASE WHEN fk.currency_value is null or fk.currency_value='' or fk.currency_value=0
THEN
p.subtotal
ELSE
p.subtotal*fk.currency_value
END
ELSE
CASE WHEN p.old_subtotal IS null OR p.old_subtotal='' THEN
0
ELSE
CASE WHEN fk.currency_value is null or fk.currency_value='' or fk.currency_value=0
THEN
p.subtotal-p.old_subtotal
ELSE
(p.subtotal-p.old_subtotal)*fk.currency_value
END
END
END
) as razem,
sum(
CASE WHEN fk.type!='correct'
THEN
p.quantity
ELSE
p.quantity-p.old_quantity
END
) as quantity,p.subprice,fk.parent_id,fk.parent_name
from ecminvoiceouts as fk
inner join ecminvoiceoutitems as p on p.ecminvoiceout_id=fk.id
inner join ecmproducts as pr on pr.id=p.ecmproduct_id
inner join ecmproductcategories as cat on cat.id=pr.product_category_id
where ".$where." and p.ecmproduct_id='".$r['ecmproduct_id']."'
group by fk.parent_id order by razem desc;";
$w2=$db->query($z2);
$note.='<div id="draggable'.$abc.'" name="lol" class="ui-widget-content" style="display:none; width:300px;z-index: '.$abc.';">
<img border="0" src="themes/Sugar/images/close_inline.gif" onmousedown="hide(\'draggable'.$abc.'\')"></img>'.$r['name'].'<br>'.$r['code'].'<br><table id="tab"><tr><td>Kontrahent</td><td><p style="text-align: right;">Ilość</p></td><td><p style="text-align: right;">Kwota</p></td></tr>';
while($r2=$db->fetchByAssoc($w2)){
$note.='<tr><td><a href="index.php?module=Accounts&action=DetailView&record='.$r2['parent_id'].'">'.$r2['parent_name'].'</a></td><td><p style="text-align: right;">'.format_number($r2['quantity']).'</p></td><td><p style="text-align: right;">'.format_number($r2['razem']).'</p></tr></tr>';
}
$note.='</table></div>';
$b=$r['cid'];
$sum[$b]['total']+=$r['razem'];
$sum[$b]['quantity']+=$r['quantity'];
$sum[$b]['cat']=$r['cname'];
$sum[$b]['c']=0;
foreach($sum as $k=>$v ){
if(($k!=$r['cid'] && $sum[$k]['c']==0)){
$t.=$trs;
//if($sum_total_netto-$sum_total_margin>0)$sum_margin=100*$sum_total_margin/($sum_total_netto-$sum_total_margin);
//else $sum_margin=0;
$t.=$tds1;
$t.="Podsumowanie ".$sum[$k]['cat'];
$t.=$tde;
$t.=$tds1;
$t.="";
$t.=$tde;
$t.=$tds1;
$t.='<p style="text-align: right;">'.format_number($sum[$k]['quantity']).'</p>';
$t.=$tde;
$t.=$tds1;
$t.='<p style="text-align: right;">'.format_number($sum[$k]['total']).'</p>';
$t.=$tde;
$t.=$tds;
$t.='';
$t.=$tde;
$t.=$tre;
$sum[$k]['c']=1;
}
}
$t.=$trs;
$t.=$tds;
$t.='<a href="index.php?module=EcmProducts&action=DetailView&record='.$r['ecmproduct_id'].'">'.$r['name'].'</a>';
$t.=$tde;
$t.=$tds;
$t.=$r['code'];
$t.=$tde;
$t.=$tds;
$t.='<p style="text-align: right;">'.format_number($r['quantity']).'</p>';
$t.=$tde;
$t.=$tds;
$t.='<p style="text-align: right;">'.format_number($r['razem']).'</p>';
$t.=$tde;
$t.=$tds;
$show='<p style="text-align: right;"><a href="#" onClick="show(\'draggable'.$abc.'\',event)"><img src="themes/Sugar5/images/info_inline.gif?s=bed8cd35065048ceebdc639ebe305e2c&c=1"></a></p>';
$t.=$show;
$t.=$tde;
$t.=$tds;
$t.='<p style="text-align: right;">'.$r['cname'].'</p>';
$t.=$tde;
$t.=$tre;
$ilosc+=$r['quantity'];
$razem+=$r['razem'];
foreach($sum as $k=>$v ){
if(($w->num_rows==$i && $sum[$k]['c']==0)){
$t.=$trs;
//if($sum_total_netto-$sum_total_margin>0)$sum_margin=100*$sum_total_margin/($sum_total_netto-$sum_total_margin);
//else $sum_margin=0;
$t.=$tds1;
$t.="Podsumowanie ".$sum[$k]['cat'];
$t.=$tde;
$t.=$tds1;
$t.="";
$t.=$tde;
$t.=$tds1;
$t.='<p style="text-align: right;">'.format_number($sum[$k]['quantity']).'</p>';
$t.=$tde;
$t.=$tds1;
$t.='<p style="text-align: right;">'.format_number($sum[$k]['total']).'</p>';
$t.=$tde;
$t.=$tds;
$t.='';
$t.=$tde;
$t.=$tre;
$sum[$k]['c']=1;
}
}
$i++;
$abc++;
}
fclose($fp);
$t.=$trs;
//if($sum_total_netto-$sum_total_margin>0)$sum_margin=100*$sum_total_margin/($sum_total_netto-$sum_total_margin);
//else $sum_margin=0;
$t.=$tds1;
$t.="Podsumowanie";
$t.=$tde;
$t.=$tds1;
$t.="&nbsp;";
$t.=$tde;
$t.=$tds1;
$t.='<p style="text-align: right;">'.format_number($ilosc).'</p>';
$t.=$tde;
$t.=$tds1;
$t.='<p style="text-align: right;">'.format_number($razem).'</p>';
$t.=$tde;
$t.=$tre;
$t.=$tbe;
echo $t;
if(isset($_REQUEST['txt'])){
// send the right headers
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename('modules/EcmReports/TXT/'.$name.'.txt'));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize('modules/EcmReports/TXT/'.$name.'.txt'));
ob_clean();
flush();
readfile('modules/EcmReports/TXT/'.$name.'.txt');
exit;
// dump the picture and stop the script
}
echo $note;
?>

View File

@@ -0,0 +1,303 @@
<?
$db = $GLOBALS['db'];
$account=$_GET['account'];
$account_id=$_GET['account_id'];
$account_name=$_GET['account_name'];
$type=$_GET['type'];
if(!$_GET['date_from'])$date_from=date("Y-m-d");
else $date_from=$GLOBALS['timedate']->to_db_date($_GET['date_from']);
$exp=explode("-",$date_from);
$date_from=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])+24*3600);
if(!$date_from)$date_from=date("Y-m-d");
if(!$_GET['date_to'])$date_to=date("Y-m-d");
else $date_to=$GLOBALS['timedate']->to_db_date($_GET['date_to']);
$exp=explode("-",$date_to);
$date_to=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])+24*3600);
if(!$date_to)$date_to=date("Y-m-d");
?>
<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts" width="16" border="0" height="16"></td><td><h2>Eksport Faktury </h2></td></tr></table><br />
<ul class="tablist" style="width:100%;">
<li>
<a class="current" href="#">Podstawowe wyszukiwanie</a>
</li>
</ul>
<form action="index.php" method="get" name="search_reports">
<input type="hidden" name="module" value="EcmReports" />
<input type="hidden" name="action" value="InvoiceTXT" />
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="dataLabel" width="5%" nowrap="nowrap">
Data od </td>
<td class="dataField" width="10%" nowrap="nowrap">
<input autocomplete="off" name="date_from" id="date_from" value="<? echo $GLOBALS['timedate']->to_display_date($date_from);?>" title="" tabindex="" size="11" maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_from_trigger" align="absmiddle" border="0">
<script type="text/javascript">
Calendar.setup ({
inputField : "date_from",
daFormat : "<? echo str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));?>",
button : "date_from_trigger",
singleClick : true,
dateStr : "",
step : 1
}
);
</script>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Data do</td>
<td class="dataField" width="30%" nowrap="nowrap">
<input autocomplete="off" name="date_to" id="date_to" value="<? echo $GLOBALS['timedate']->to_display_date($date_to);?>" title="" tabindex="" size="11" maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_to_trigger" align="absmiddle" border="0">
<script type="text/javascript">
Calendar.setup ({
inputField : "date_to",
daFormat : "<? echo str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));?>",
button : "date_to_trigger",
singleClick : true,
dateStr : "",
step : 1
}
);
</script>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Kontrahent </td>
<td class="dataField" width="30%" nowrap="nowrap">
<!--<select name="account">
<option value="">select</option>
<?php
$w=$db->query("select id,name from accounts where deleted='0' order by name asc");
while($r=$db->fetchByAssoc($w)){
echo '<option value="'.$r['id'].'"';
if($account==$r['id'])echo ' selected';
echo '>'.$r['name'].'</option>';
}
?>
</select>-->
<input name="account_name" tabindex="" id="account_name" size="" value="<?php echo $_REQUEST['account_name'];?>" title="" type="text">
<input name="account_id" id="account_id" value="<?php echo $_REQUEST['account_id'];?>" type="hidden">
<input name="btn_account_name" tabindex="" title="Select [Alt+T]" accesskey="T" class="button" value="Wybierz" onclick='open_popup("Accounts", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"search_reports","field_to_name_array":{"id":"account_id","name":"account_name"}}, "single", true);' type="button">
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Typ dokumentu </td>
<td class="dataField" width="30%" nowrap="nowrap">
<select name="type">
<option value="" <? if($type=="")echo 'selected';?>>normalny i korekta</option>
<option value="normal" <? if($type=="normal")echo 'selected';?>>normalny</option>
<option value="correct" <? if($type=="correct")echo 'selected';?>>korekta</option>
</select>
</td>
</tr>
</tbody>
</table>
<input class="button" name="submit" value="Szukaj" type="submit">
<input class="button" name="clear" value="Wyczyść" type="button" onclick="location.href='index.php?module=EcmReports&action=ListDailySales';"><?
echo '&nbsp;<input type="button" class="button" name="CreateXLS" value="Otwórz XLS" onclick="location.href=\'index.php?module=EcmInvoiceOuts&action=CreateXLS&date_from='.$date_from.'&date_to='.$date_to.'&account_id='.$account_id.'&account_name='.$account_name.'&type='.$type.'\';">';
?>
<input class="button" name="txt" value="Utwórz TXT" type="submit">
</form><br />
<?php
$tds1='<td class="listViewThS1">';
$trs='<tr onMouseover="this.bgColor=\'#EEEEEE\'"onMouseout="this.bgColor=\'#FFFFFF\'">';
$tre='</tr>';
$tds='<td class="oddListRowS1">';
$tde='</td>';
$tbs='<table cellpadding="0" cellspacing="0" border="0" class="ListView" style="width:100%;">';
$tbe='</table>';
$t.=$tbs;
$t.=$trs;
$t.=$tds1;
$t.="Nr faktury";
$t.=$tde;
$t.=$tds1;
$t.="Typ";
$t.=$tde;
$t.=$tds1;
$t.="Kontrahent";
$t.=$tde;
$t.=$tds1;
$t.="Data utworzenia";
$t.=$tde;
$t.=$tds1;
$t.="Razem Brutto";
$t.=$tde;
$t.=$tds1;
$t.="Razem Netto";
$t.=$tde;
$t.=$tds1;
$t.="Koszt";
$t.=$tde;
$t.=$tds1;
$t.="PLN Margin";
$t.=$tde;
$t.=$tre;
$i=1;
$wh[]="deleted='0'";
$wh[]="canceled='0'";
if($type)$wh[]="type='".$type."'";
if($account_id)$wh[]="parent_id='".$account_id."'";
if($account_name)$wh[]="parent_name like '".$account_name."%'";
if($date_from)$wh[]="register_date>='".$date_from."'";
if($date_to)$wh[]="register_date<='".$date_to."'";
$where=implode(" and ",$wh);
$z="select purchase_price,total, subtotal,document_no,register_date,stock_id,payment_date,currency_id,id,parent_id,parent_name,sell_date,type,ecminvoiceout_id,currency_value,discount,to_nip from ecminvoiceouts where ".$where." order by type desc, register_date asc, name asc";
echo $z;
$w=$db->query($z);
echo '<br>'.$w->num_rows.'<br>';
echo mysql_error();
$sum_margin = 0;
$count_normal = 0;
$microtime=str_replace(".","",str_replace(" ","",microtime()));
$name='fakury_'.$microtime;
$fp = fopen('modules/EcmReports/TXT/'.$name.'.txt', 'w');
fwrite($fp, 'Faktura'."\n");
while($r=$db->fetchByAssoc($w)){
if(!$r['currency_value'])$currency_value=1;
else {
$currency_value=$r['currency_value'];
//echo $currency_value;
}
//$currency_value=1;
$nip=$db->query("select to_vatid from accounts where id='".$r['parent_id']."'");
$wal=$db->query("select name from currencies where id='".$r['currency_id']."'");
$nip=$db->fetchByAssoc($nip);
$waluta=$db->fetchByAssoc($wal);
if($db->getRowCount($wal)==0) $waluta['name']='PLN';
if($currency_value==1){
$vat=$r['total']-$r['subtotal'];
} else {$vat=0;}
if($r['stock_id']==''){
$stock='c7afd71a-4c3a-bde4-138d-4acaee1644e4';
} else {
$stock=$r['stock_id'];
} if($r['currency_value']=="")$r['currency_value']='0';
$total_pur=$r['purchase_price'];
if($total_pur=='')$total_pur='0';
fwrite($fp, $r['document_no'].' | '.$r['register_date'].' | '.$r['sell_date'].' | '.$r['parent_name'].' | '.$nip['to_vatid'].' | '.$r['parent_name'].' | '.$r['subtotal'].' | '.$vat.' | '.$r['total'].' | '.$total_pur.' | '.$r['payment_date'].' | '.$stock.' | '.$waluta['name'].' | '.$r['currency_value']."\n");
$total_netto=$r['subtotal']*$currency_value;
$total_brutto=$r['total']*$currency_value;
$total_margin=0;
if ($r['document_no']=='001/E/2013') echo $currency_value.'<br>'.$r['subtotal'].'<br>'.$total_netto;
if($total_netto-$total_margin>0)$margin=100*$total_margin/($total_netto-$total_margin);
else $margin=0;
if ($r['type']=='normal') {
$total_margin = (($total_netto-$total_pur)/$total_netto)*100;
$count_normal++;
$sum_margin+=$total_margin;
}
if($r['discount']>0){
$vr=$total_brutto/$total_netto;
$total_brutto=$total_brutto-$r['discount'];
$total_netto=$total_brutto/$vr;
}
$t.=$trs;
$t.=$tds;
$t.='<a href="index.php?module=EcmInvoiceOuts&action=DetailView&record='.$r['id'].'">'.$r['document_no'].'</a>';
$t.=$tde;
$t.=$tds;
$t.=$r['type'];
$t.=$tde;
$t.=$tds;
$t.='<a href="index.php?module=Accounts&action=DetailView&record='.$r['parent_id'].'">'.$r['parent_name'].'</a>';
$t.=$tde;
$t.=$tds;
$t.=$GLOBALS['timedate']->to_display_date($r['register_date']);
$t.=$tde;
$t.=$tds;
$t.=format_number($total_brutto);
$t.=$tde;
$t.=$tds;
$t.=format_number($total_netto);
$t.=$tde;
$t.=$tds;
$t.=format_number($total_pur);
$t.=$tde;
$t.=$tds;
$t.=format_number($total_margin)."%";
$t.=$tde;
$t.=$tre;
$sum_total_netto+=$total_netto;
$sum_total_pur+=$total_pur;
$sum_total_brutto+=$total_brutto;
$sum_total_margin+=$total_margin;
$i++;
}
fclose($fp);
$t.=$trs;
//if($sum_total_netto-$sum_total_margin>0)$sum_margin=100*$sum_total_margin/($sum_total_netto-$sum_total_margin);
//else $sum_margin=0;
$t.=$tds1;
$t.="&nbsp;";
$t.=$tde;
$t.=$tds1;
$t.="&nbsp;";
$t.=$tde;
$t.=$tds1;
$t.="&nbsp;";
$t.=$tde;
$t.=$tds1;
$t.="&nbsp;";
$t.=$tde;
$t.=$tds1;
$t.=format_number($sum_total_brutto);
$t.=$tde;
$t.=$tds1;
$t.=format_number($sum_total_netto);
$t.=$tde;
$t.=$tds1;
$t.=format_number($sum_total_pur);
$t.=$tde;
$t.=$tds1;
$t.=format_number($sum_margin/$count_normal)."%";
$t.=$tde;
$t.=$tre;
$t.=$tbe;
//echo $t;
if(isset($_REQUEST['txt'])){
// send the right headers
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename('modules/EcmReports/TXT/'.$name.'.txt'));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize('modules/EcmReports/TXT/'.$name.'.txt'));
ob_clean();
flush();
readfile('modules/EcmReports/TXT/'.$name.'.txt');
exit;
// dump the picture and stop the script
}
?>

View File

@@ -0,0 +1,173 @@
<?php
if ($_REQUEST ['date']) {
$date_from = new DateTime ( date ( '01.m.Y' ,strtotime( $_REQUEST ['date'])));
$date_to = new DateTime ( date ( 't.m.Y' ,strtotime( $_REQUEST ['date'])));
$date = new DateTime($_REQUEST ['date']);
} else {
$date_from = new DateTime ( date ( '01.m.Y' ) );
$date_to = new DateTime ( date ( 't.m.Y' ) );
$date = new DateTime();
}
class WorkCostByWorker {
public $date_from;
public $date_to;
public $db;
public $category;
public $workerTime;
public $workerCost;
public $totalh;
public $totalc;
public $totalQuantityPw;
public $totalCostPw;
public function __construct(DateTime $date_from, DateTime $date_to, $category) {
$this->date_from = $date_from;
$this->date_to = $date_to;
$this->category=$category;
$this->db = $GLOBALS ['db'];
}
public function getWorkerList() {
$this->db = $GLOBALS ['db'];
$query = "select id,CONCAT(first_name,' ',last_name) as name from ecmworkers where deleted=0";
$res = $this->db->query ( $query );
$workers=[];
while ( $dane = $this->db->fetchByAssoc ( $res ) ) {
$workers[$dane['id']]=$dane['name'];
}
return $workers;
}
public function getWorkerCostInMont(){
$query="select worker_id,price from ecmworkcosts where deleted=0 and date>='".$this->date_from->format("Y-m-d")."'";
$res = $this->db->query ( $query );
$this->workerCost=[];
while ( $dane = $this->db->fetchByAssoc ( $res ) ) {
$this->workerCost[$dane['worker_id']]=$dane['price'];
}
}
public function getWokerTimeInMonth(){
$query="select worker_id,SEC_TO_TIME( SUM( TIME_TO_SEC( TIMEDIFF(time_to, time_from)) ) ) AS timeSum from ecmworkcards where date>='".$this->date_from->format("Y-m-d")."' and date<='".$this->date_to->format("Y-m-d")."' and deleted=0 group by worker_id";
$res = $this->db->query ( $query );
$this->workerTime=[];
while ( $dane = $this->db->fetchByAssoc ( $res ) ) {
$this->workerTime[$dane['worker_id']]['time']=$dane['timeSum'];
$parts = explode(':', $dane['timeSum']);
$this->workerTime[$dane['worker_id']]['work_hour_cost']=round($this->workerCost[$dane['worker_id']]/($parts[0] + floor(($parts[1]/60)*100) / 100),2);
}
}
public function getProductTimeByWorkers(){
$query="select w.product_id,p.code,p.name,w.worker_id,SEC_TO_TIME( SUM( TIME_TO_SEC( TIMEDIFF(w.time_to, w.time_from)) ) ) AS timeSum,sum(w.quantity) as quantity from ecmworkcards w
inner join ecmproducts p on p.id=w.product_id
where w.date>='".$this->date_from->format("Y-m-d")."' and w.date<='".$this->date_to->format("Y-m-d")."' and w.deleted=0 group by w.product_id,w.worker_id";
$res = $this->db->query ( $query );
$workers=$this->getWorkerList();
$this->data=[];
$this->totalh=0;
$this->totalc=0;
while ( $dane = $this->db->fetchByAssoc ( $res ) ) {
$this->data[$dane['product_id']]['name']=$dane['name'];
$this->data[$dane['product_id']]['indeks']=create_guid ();
$this->data[$dane['product_id']]['code']=$dane['code'];
$parts = explode(':', $dane['timeSum']);
$this->data[$dane['product_id']]['hours']=$this->data[$dane['product_id']]['hours']+($parts[0] + floor(($parts[1]/60)*100) / 100);
$this->totalh=$this->totalh+($parts[0] + floor(($parts[1]/60)*100) / 100);
$this->data[$dane['product_id']]['cost']=$this->data[$dane['product_id']]['cost']+($this->workerTime[$dane['worker_id']]['work_hour_cost']*($parts[0] + floor(($parts[1]/60)*100) / 100));
$this->data[$dane['product_id']]['workers'][$dane['worker_id']]['name']=$workers[$dane['worker_id']];
$this->data[$dane['product_id']]['workers'][$dane['worker_id']]['quantity']=$dane['quantity'];
$this->data[$dane['product_id']]['workers'][$dane['worker_id']]['hours']=($parts[0] + floor(($parts[1]/60)*100) / 100);
$this->data[$dane['product_id']]['workers'][$dane['worker_id']]['cost']=($this->workerTime[$dane['worker_id']]['work_hour_cost']*($parts[0] + floor(($parts[1]/60)*100) / 100));
$this->totalc=$this->totalc+$this->data[$dane['product_id']]['cost'];
}
return $this->data;
}
public function getProductByPW(){
$query="select i.ecmproduct_id as product_id,sum(i.quantity) as pw_quantity,sum(i.total) as pw_total,p.code,p.name from ecmstockdocinsideinitems i
inner join ecmstockdocinsideins d on d.id = i.ecmstockdocinsidein_id
inner join ecmproducts p on p.id=i.ecmproduct_id
where
d.register_date>='".$this->date_from->format("Y-m-d")."' and d.register_date<='".$this->date_to->format("Y-m-d")."' and d.deleted=0 GROUP by i.ecmproduct_id";
$res = $this->db->query ( $query );
$this->totalQuantityPw=0;
$this->totalCostPw=0;
while ( $dane = $this->db->fetchByAssoc ( $res ) ) {
$this->data[$dane['product_id']]['name']=$dane['name'];
if($this->data[$dane['product_id']]['indeks']=="")create_guid ();
$this->data[$dane['product_id']]['code']=$dane['code'];
$this->data[$dane['product_id']]['pw_quantity']=$dane['pw_quantity'];
$this->data[$dane['product_id']]['pw_total']=$dane['pw_total'];
$this->totalCostPw=$this->totalCostPw+$this->data[$dane['product_id']]['pw_total'];
$this->totalQuantityPw=$this->totalQuantityPw+$this->data[$dane['product_id']]['pw_quantity'];
}
return $this->data;
}
}
$wcbw = new WorkCostByWorker($date_from,$date_to);
$wcbw->getWorkerCostInMont();
$wcbw->getWokerTimeInMonth();
$wcbw->getProductTimeByWorkers();
$data=$wcbw->getProductByPW();
function compareByName($a, $b) {
return strcmp($a["code"], $b["code"]);
}
usort($data, 'compareByName');
$smarty = new Sugar_Smarty ();
$smarty->assign ( "data", $data );
$smarty->assign ( "totalc", $wcbw->totalc);
$smarty->assign ( "totalh", $wcbw->totalh);
$smarty->assign ( "totalQuantityPw", $wcbw->totalQuantityPw);
$smarty->assign ( "totalCostPw", $wcbw->totalCostPw);
$smarty->assign ( "date", $date->format('d.m.Y'));
if($_REQUEST['to_pdf']=='1'){
$smarty->assign ( "dateformat", $date->format('mY'));
include_once ("include/MPDF57/mpdf.php");
$p = new mPDF ( '', 'A4', null, 'helvetica', 10, 10, 5, 5, 5, 5 );
$content= $smarty->fetch ( 'modules/EcmReports/tpls/PDF/KosztProdukcjiWgPracownikow.html' );
$p->WriteHTML ( $content );
//echo $content;
// draw PDF
$p->Output ();
} else {
echo $smarty->display ( 'modules/EcmReports/tpls/KosztProdukcjiWgPracownikow.html' );
}
?>

View File

@@ -0,0 +1,43 @@
<?php
require_once 'ListDailySales.inc';
/*****************************************************/
/********************** SMARTY ***********************/
/*****************************************************/
$Calendar_daFormat = str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));
// Default value from date input
$currentDate = $GLOBALS['timedate']->to_display_date($date_from);
$date_from = $GLOBALS['timedate']->to_display_date($date_from);
$date_to = $GLOBALS['timedate']->to_display_date($date_to);
// create & execute smarty
$smarty = new Sugar_Smarty ();
global $mod_strings;
$smarty -> assign( "MOD", $mod_strings );
$smarty -> assign( "DATA", $data);
$smarty -> assign( "SUM", $sum);
$smarty -> assign( "date_from", $date_from );
$smarty -> assign( "date_to", $date_to );
$smarty -> assign("dateFormat", $Calendar_daFormat);
$smarty -> assign("searchByType", $searchByType);
$smarty -> assign("contractorId", $contractorId);
$smarty -> assign("contractorName", $contractorName);
$smarty -> assign("pdfTypeU", $pdfTypeU);
$smarty -> assign("pdfTypeK", $pdfTypeK);
$smarty -> assign("pdfTypeE", $pdfTypeE);
// Eksport do PDF
if( $_GET['toPDF'] == '1' ) {
$output = $smarty->fetch( 'modules/EcmReports/tpls/PDF/ListDailySales.tpl' );
include_once ("include/MPDF57/mpdf.php");
$p = new mPDF ( '', 'A4', null, 'helvetica', 10, 10, 10, 10, 5, 5 );
$p->setTitle($mod_strings["LBL_SUBPANEL_TITLE"]);
$p->writeHTML( $output );
$p->Output ('RaportSprzedazy.pdf', 'I');
} else {
echo $smarty->display ( 'modules/EcmReports/tpls/ListDailySales.tpl' );
}
?>

View File

@@ -0,0 +1,256 @@
<?
$db = $GLOBALS['db'];
$account=$_GET['account'];
$account_id=$_GET['account_id'];
$account_name=$_GET['account_name'];
$type=$_GET['type'];
if(!$_GET['date_from'])$date_from=date("Y-m-d");
else $date_from=$GLOBALS['timedate']->to_db_date($_GET['date_from']);
$exp=explode("-",$date_from);
$date_from=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])+24*3600);
if(!$date_from)$date_from=date("Y-m-d");
if(!$_GET['date_to'])$date_to=date("Y-m-d");
else $date_to=$GLOBALS['timedate']->to_db_date($_GET['date_to']);
$exp=explode("-",$date_to);
$date_to=date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])+24*3600);
if(!$date_to)$date_to=date("Y-m-d");
?>
<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts" width="16" border="0" height="16"></td><td><h2>Sprzedaż </h2></td></tr></table><br />
<ul class="tablist" style="width:100%;">
<li>
<a class="current" href="#">Podstawowe wyszukiwanie</a>
</li>
</ul>
<form action="index.php" method="get" name="search_reports">
<input type="hidden" name="module" value="EcmReports" />
<input type="hidden" name="action" value="ListDailySales2" />
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="dataLabel" width="5%" nowrap="nowrap">
Data od </td>
<td class="dataField" width="10%" nowrap="nowrap">
<input autocomplete="off" name="date_from" id="date_from" value="<? echo $GLOBALS['timedate']->to_display_date($date_from);?>" title="" tabindex="" size="11" maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_from_trigger" align="absmiddle" border="0">
<script type="text/javascript">
Calendar.setup ({
inputField : "date_from",
daFormat : "<? echo str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));?>",
button : "date_from_trigger",
singleClick : true,
dateStr : "",
step : 1
}
);
</script>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Data do</td>
<td class="dataField" width="30%" nowrap="nowrap">
<input autocomplete="off" name="date_to" id="date_to" value="<? echo $GLOBALS['timedate']->to_display_date($date_to);?>" title="" tabindex="" size="11" maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_to_trigger" align="absmiddle" border="0">
<script type="text/javascript">
Calendar.setup ({
inputField : "date_to",
daFormat : "<? echo str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));?>",
button : "date_to_trigger",
singleClick : true,
dateStr : "",
step : 1
}
);
</script>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Kontrahent </td>
<td class="dataField" width="30%" nowrap="nowrap">
<!--<select name="account">
<option value="">select</option>
<?php
$w=$db->query("select id,name from accounts where deleted='0' order by name asc");
while($r=$db->fetchByAssoc($w)){
echo '<option value="'.$r['id'].'"';
if($account==$r['id'])echo ' selected';
echo '>'.$r['name'].'</option>';
}
?>
</select>-->
<input name="account_name" tabindex="" id="account_name" size="" value="<?php echo $_REQUEST['account_name'];?>" title="" type="text">
<input name="account_id" id="account_id" value="<?php echo $_REQUEST['account_id'];?>" type="hidden">
<input name="btn_account_name" tabindex="" title="Select [Alt+T]" accesskey="T" class="button" value="Wybierz" onclick='open_popup("Accounts", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"search_reports","field_to_name_array":{"id":"account_id","name":"account_name"}}, "single", true);' type="button">
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Typ dokumentu </td>
<td class="dataField" width="30%" nowrap="nowrap">
<select name="type">
<option value="" <? if($type=="")echo 'selected';?>>normalny i korekta</option>
<option value="normal" <? if($type=="normal")echo 'selected';?>>normalny</option>
<option value="correct" <? if($type=="correct")echo 'selected';?>>korekta</option>
</select>
</td>
</tr>
</tbody>
</table>
<input class="button" name="submit" value="Szukaj" type="submit">
<input class="button" name="clear" value="Wyczyść" type="button" onclick="location.href='index.php?module=EcmReports&action=ListDailySales';"><?
echo '&nbsp;<input type="button" class="button" name="CreateXLS" value="Otwórz XLS" onclick="location.href=\'index.php?module=EcmInvoiceOuts&action=CreateXLS&date_from='.$date_from.'&date_to='.$date_to.'&account_id='.$account_id.'&account_name='.$account_name.'&type='.$type.'\';">';
?>
</form><br />
<?php
$tds1='<td class="listViewThS1">';
$trs='<tr onMouseover="this.bgColor=\'#EEEEEE\'"onMouseout="this.bgColor=\'#FFFFFF\'">';
$tre='</tr>';
$tds='<td class="oddListRowS1">';
$tde='</td>';
$tbs='<table cellpadding="0" cellspacing="0" border="0" class="ListView" style="width:100%;">';
$tbe='</table>';
$i=1;
$wh[]="deleted='0'";
$wh[]="canceled='0'";
if($type)$wh[]="type='".$type."'";
if($account_id)$wh[]="parent_id='".$account_id."'";
if($account_name)$wh[]="parent_name like '".$account_name."%'";
if($date_from)$wh[]="register_date>='".$date_from."'";
if($date_to)$wh[]="register_date<='".$date_to."'";
$where=implode(" and ",$wh);
$z="select purchase_price,total, subtotal,document_no,register_date,id,parent_id,parent_name,type,ecminvoiceout_id,currency_value,discount from ecminvoiceouts where ".$where." order by type desc, register_date asc, name asc";
$w=$db->query($z);
$z2="select purchase_price,total, subtotal,document_no,register_date,id,parent_id,parent_name,type,ecminvoiceout_id,currency_value,discount from ecminvoiceouts where ".$where." group by parent_id";
//echo $z2;
$w2=$db->query($z2);
$i=0;
$ar=array();
while($r2=$db->fetchByAssoc($w2)){
$ar[$i]['parent_id']=$r2['parent_id'];
$ar[$i]['parent_name']=$r2['parent_name'];
$ar[$i]['total']=0;
$ar[$i]['subtotal']=0;
$w3=$db->query("select ac.assigned_user_id,us.first_name,us.last_name,us.id from accounts as ac
inner join users as us on us.id=ac.assigned_user_id where ac.id='".$r2['parent_id']."'");
$us=$db->fetchByAssoc($w3);
$ar[$i]['user']=$us['first_name'].' '.$us['last_name'];
$ar[$i]['userid']=$us['id'];
$i++;
}
//echo '<br>'.$w->num_rows.'<br>';
echo mysql_error();
$sum_margin = 0;
$count_normal = 0;
while($r=$db->fetchByAssoc($w)){
if(!$r['currency_value'])$currency_value=1;
else {
$currency_value=$r['currency_value'];
//echo $currency_value;
}
//$currency_value=1;
$total_netto=$r['subtotal']*$currency_value;
$total_pur=$r['purchase_price'];
$total_brutto=$r['total']*$currency_value;
$total_margin=0;
for($ac=0;$ac<count($ar);$ac++){
if($ar[$ac]['parent_id']==$r['parent_id']){
$ar[$ac]['total']+=$total_brutto;
$ar[$ac]['subtotal']+=$total_netto;
}
}
if ($r['document_no']=='001/E/2013') echo $currency_value.'<br>'.$r['subtotal'].'<br>'.$total_netto;
if($total_netto-$total_margin>0)$margin=100*$total_margin/($total_netto-$total_margin);
else $margin=0;
if($r['discount']>0){
$vr=$total_brutto/$total_netto;
$total_brutto=$total_brutto-$r['discount'];
$total_netto=$total_brutto/$vr;
}
$i++;
}
$pokaz=0;
$t.=$tbs;
$t.=$trs;
$t.=$tds1;
$t.="Kontrahent";
$t.=$tde;
$t.=$tds1;
$t.="Razem Brutto";
$t.=$tde;
$t.=$tds1;
$t.="Razem Netto";
$t.=$tde;
$t.=$tds1;
$t.="Koszt";
$t.=$tde;
$t.=$tds1;
$t.="PLN Margin";
$t.=$tde;
$t.=$tds1;
$t.="Użytkownik";
$t.=$tde;
$t.=$tre;
for($ac=0;$ac<count($ar);$ac++){
$pokaz+=$ar[$ac]['total'];
$pokaz2+=$ar[$ac]['subtotal'];
$t.=$trs;
$t.=$tds;
$t.='<a href="index.php?module=Accounts&action=DetailView&record='.$ar[$ac]['parent_id'].'">'.$ar[$ac]['parent_name'].'</a>';
$t.=$tde;
$t.=$tds;
$t.=format_number($ar[$ac]['total']);
$t.=$tde;
$t.=$tds;
$t.=format_number($ar[$ac]['subtotal']);
$t.=$tde;
$t.=$tds;
$t.=format_number($total_pur);
$t.=$tde;
$t.=$tds;
$t.=format_number($total_margin)."%";
$t.=$tde;
$t.=$tds;
$t.='<a href="index.php?module=Users&action=DetailView&record='.$ar[$ac]['userid'].'">'.$ar[$ac]['user'].'</a>';
$t.=$tde;
$t.=$tre;
}
$t.=$trs;
//if($sum_total_netto-$sum_total_margin>0)$sum_margin=100*$sum_total_margin/($sum_total_netto-$sum_total_margin);
//else $sum_margin=0;
$t.=$tds1;
$t.="&nbsp;";
$t.=$tde;
$t.=$tds1;
$t.=format_number($pokaz);
$t.=$tde;
$t.=$tds1;
$t.=format_number($pokaz2);
$t.=$tde;
$t.=$tds1;
$t.=format_number($sum_total_pur);
$t.=$tde;
$t.=$tds1;
$t.=format_number($sum_margin/$count_normal)."%";
$t.=$tde;
$t.=$tre;
$t.=$tbe;
echo $t;
?>

View File

@@ -0,0 +1,270 @@
<?
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
die ( 'Not A Valid Entry Point' );
// prepare data
$db = $GLOBALS ['db'];
// GET variables
$account = $_GET['account'];
$account_id = $_GET['account_id'];
$account_name = $_GET['account_name'];
$type = $_GET['type'];
if(!$_GET['date_from'])
$date_from = date("Y-m-d");
else
$date_from = $GLOBALS['timedate'] -> to_db_date($_GET['date_from']);
$exp = explode("-", $date_from);
$date_from = date("Y-m-d", mktime(0,0,0, $exp[1], $exp[2], $exp[0])+24*3600);
if(!$date_from)$date_from = date("Y-m-d");
if(!$_GET['date_to'])
$date_to = date("Y-m-d");
else
$date_to = $GLOBALS['timedate'] -> to_db_date($_GET['date_to']);
$exp = explode("-",$date_to);
$date_to = date("Y-m-d", mktime(0, 0, 0, $exp[1], $exp[2], $exp[0])+24*3600);
if(!$date_to)
$date_to=date("Y-m-d");
?>
<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts" width="16" border="0" height="16"></td><td><h2>Invoices: Daily sales </h2></td></tr></table><br />
<ul class="tablist" style="width:100%;">
<li>
<a class="current" href="#">Podstawowe wyszukiwanie</a>
</li>
</ul>
<form action="index.php" method="get" name="search_reports">
<input type="hidden" name="module" value="EcmReports" />
<input type="hidden" name="action" value="ListDailySalesOLD" />
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="dataLabel" width="5%" nowrap="nowrap">Data od</td>
<td class="dataField" width="10%" nowrap="nowrap">
<input autocomplete="off" name="date_from" id="date_from" value="<? echo $GLOBALS['timedate']->to_display_date($date_from);?>" title="" tabindex="" size="11" maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_from_trigger" align="absmiddle" border="0">
<script type="text/javascript">
Calendar.setup ({
inputField : "date_from",
daFormat : "<? echo str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));?>",
button : "date_from_trigger",
singleClick : true,
dateStr : "",
step : 1
}
);
</script>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">Data do</td>
<td class="dataField" width="30%" nowrap="nowrap">
<input autocomplete="off" name="date_to" id="date_to" value="<? echo $GLOBALS['timedate']->to_display_date($date_to);?>" title="" tabindex="" size="11" maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_to_trigger" align="absmiddle" border="0">
<script type="text/javascript">
Calendar.setup ({
inputField : "date_to",
daFormat : "<? echo str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));?>",
button : "date_to_trigger",
singleClick : true,
dateStr : "",
step : 1
}
);
</script>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">Kontrahent</td>
<td class="dataField" width="30%" nowrap="nowrap">
<!--<select name="account">
<option value="">select</option>
<?php
$w=$db->query("select id,name from accounts where deleted='0' order by name asc");
while($r=$db->fetchByAssoc($w)){
echo '<option value="'.$r['id'].'"';
if($account==$r['id'])
echo ' selected';
echo '>'.$r['name'].'</option>';
}
?>
</select>-->
<input name="account_name" tabindex="" id="account_name" size="" value="<?php echo $_REQUEST['account_name'];?>" title="" type="text">
<input name="account_id" id="account_id" value="<?php echo $_REQUEST['account_id'];?>" type="hidden">
<input name="btn_account_name" tabindex="" title="Select [Alt+T]" accesskey="T" class="button" value="Wybierz" onclick='open_popup("Accounts", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"search_reports","field_to_name_array":{"id":"account_id","name":"account_name"}}, "single", true);' type="button">
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">Typ dokumentu </td>
<td class="dataField" width="30%" nowrap="nowrap">
<select name="type">
<option value=""
<?php
if($type=="")echo 'selected';?>>normalny i korekta</option>
<option value="normal" <? if($type=="normal")echo 'selected';?>>normalny</option>
<option value="correct" <? if($type=="correct")echo 'selected';?>>korekta</option>
</select>
</td>
</tr>
</tbody>
</table>
<input class="button" name="submit" value="Szukaj" type="submit">
<input class="button" name="clear" value="Wyczyść" type="button" onclick="location.href='index.php?module=EcmReports&action=ListDailySales';"><?
echo '&nbsp;<input type="button" class="button" name="CreateXLS" value="Otwórz XLS" onclick="location.href=\'index.php?module=EcmInvoiceOuts&action=CreateXLS&date_from='.$date_from.'&date_to='.$date_to.'&account_id='.$account_id.'&account_name='.$account_name.'&type='.$type.'\';">';
?>
</form><br />
<?php
$tds1='<td class="listViewThS1">';
$trs='<tr onMouseover="this.bgColor=\'#EEEEEE\'"onMouseout="this.bgColor=\'#FFFFFF\'">';
$tre='</tr>';
$tds='<td class="oddListRowS1">';
$tde='</td>';
$tbs='<table cellpadding="0" cellspacing="0" border="0" class="ListView" style="width:100%;">';
$tbe='</table>';
$t.=$tbs;
$t.=$trs;
$t.=$tds1;
$t.="Nr faktury";
$t.=$tde;
$t.=$tds1;
$t.="Typ";
$t.=$tde;
$t.=$tds1;
$t.="Kontrahent";
$t.=$tde;
$t.=$tds1;
$t.="Data utworzenia";
$t.=$tde;
$t.=$tds1;
$t.="Razem Brutto";
$t.=$tde;
$t.=$tds1;
$t.="Razem Netto";
$t.=$tde;
$t.=$tds1;
$t.="Koszt";
$t.=$tde;
$t.=$tds1;
$t.="PLN Margin";
$t.=$tde;
$t.=$tre;
$i=1;
$wh[]="deleted='0'";
$wh[]="canceled='0'";
if($type)$wh[]="type='".$type."'";
if($account_id)$wh[]="parent_id='".$account_id."'";
if($account_name)$wh[]="parent_name like '".$account_name."%'";
if($date_from)$wh[]="register_date>='".$date_from."'";
if($date_to)$wh[]="register_date<='".$date_to."'";
$where=implode(" and ",$wh);
$z="select purchase_price,total, subtotal,document_no,register_date,id,parent_id,parent_name,type,ecminvoiceout_id,currency_value,discount from ecminvoiceoutolds where ".$where." order by type desc, register_date asc, name asc";
echo $z;
$w=$db->query($z);
echo '<br>'.$w->num_rows.'<br>';
echo mysql_error();
$sum_margin = 0;
$count_normal = 0;
while($r=$db->fetchByAssoc($w)){
if(!$r['currency_value'])$currency_value=1;
else {
$currency_value=$r['currency_value'];
//echo $currency_value;
}
//$currency_value=1;
$total_netto=$r['subtotal']*$currency_value;
$total_pur=$r['purchase_price'];
$total_brutto=$r['total']*$currency_value;
$total_margin=0;
if ($r['document_no']=='001/E/2013') echo $currency_value.'<br>'.$r['subtotal'].'<br>'.$total_netto;
if($total_netto-$total_margin>0)$margin=100*$total_margin/($total_netto-$total_margin);
else $margin=0;
if ($r['type']=='normal') {
$total_margin = (($total_netto-$total_pur)/$total_netto)*100;
$count_normal++;
$sum_margin+=$total_margin;
}
if($r['discount']>0){
$vr=$total_brutto/$total_netto;
$total_brutto=$total_brutto-$r['discount'];
$total_netto=$total_brutto/$vr;
}
$t.=$trs;
$t.=$tds;
$t.='<a href="index.php?module=EcmInvoiceOuts&action=DetailView&record='.$r['id'].'">'.$r['document_no'].'</a>';
$t.=$tde;
$t.=$tds;
$t.=$r['type'];
$t.=$tde;
$t.=$tds;
$t.='<a href="index.php?module=Accounts&action=DetailView&record='.$r['parent_id'].'">'.$r['parent_name'].'</a>';
$t.=$tde;
$t.=$tds;
$t.=$GLOBALS['timedate']->to_display_date($r['register_date']);
$t.=$tde;
$t.=$tds;
$t.=format_number($total_brutto);
$t.=$tde;
$t.=$tds;
$t.=format_number($total_netto);
$t.=$tde;
$t.=$tds;
$t.=format_number($total_pur);
$t.=$tde;
$t.=$tds;
$t.=format_number($total_margin)."%";
$t.=$tde;
$t.=$tre;
$sum_total_netto+=$total_netto;
$sum_total_pur+=$total_pur;
$sum_total_brutto+=$total_brutto;
$sum_total_margin+=$total_margin;
$i++;
}
$t.=$trs;
//if($sum_total_netto-$sum_total_margin>0)$sum_margin=100*$sum_total_margin/($sum_total_netto-$sum_total_margin);
//else $sum_margin=0;
$t.=$tds1;
$t.="&nbsp;";
$t.=$tde;
$t.=$tds1;
$t.="&nbsp;";
$t.=$tde;
$t.=$tds1;
$t.="&nbsp;";
$t.=$tde;
$t.=$tds1;
$t.="&nbsp;";
$t.=$tde;
$t.=$tds1;
$t.=format_number($sum_total_brutto);
$t.=$tde;
$t.=$tds1;
$t.=format_number($sum_total_netto);
$t.=$tde;
$t.=$tds1;
$t.=format_number($sum_total_pur);
$t.=$tde;
$t.=$tds1;
$t.=format_number($sum_margin/$count_normal)."%";
$t.=$tde;
$t.=$tre;
$t.=$tbe;
echo $t;
?>
echo "Hello"

View File

@@ -0,0 +1,290 @@
<?php
require_once 'ListDailySales.inc';
/*****************************************************/
/******************* EXCELL Export *******************/
/*****************************************************/
/**
* PHPExcel
*
* Copyright (C) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.8.0, 2014-03-02
*/
/** PHPExcel_IOFactory */
require_once dirname(__FILE__) . '/PhpExcell/Classes/PHPExcel/IOFactory.php';
$objPHPExcel = new PHPExcel();
// Set document properties
echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("E5")
->setLastModifiedBy("E5")
->setTitle("E5 - Dily Sales Report")
->setSubject("E5 - Report Document")
->setDescription("Report Sales - description")
->setKeywords("e5, report, daily sales, daily, sales")
->setCategory("Reports");
/*****************************************************/
/******************* EXCELL Styles *******************/
/*****************************************************/
// Set default widths and heights
$objPHPExcel->getActiveSheet()->getDefaultColumnDimension()->setWidth(15);
$objPHPExcel->getActiveSheet()->getDefaultRowDimension()->setRowHeight(20);
$headerStyle = array(
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
),
'font' => array(
'bold' => true,
'color' => array('rgb' => 'FFFFFF'),
'name' => 'Verdana',
),
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'startcolor' => array(
'rgb' => '272822',
),
),
);
$columnAlignRight = array(
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_RIGHT,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
),
);
$objPHPExcel->setActiveSheetIndex(0)->getRowDimension('1')->setRowHeight(25);
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('A')->setWidth(60);
/*****************************************************/
/********************* EXCELL Data *******************/
/*****************************************************/
// Add header
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', $mod_strings['LBL_CONTRACTOR'] )
->setCellValue('B1', $mod_strings['LBL_INVOICE_NUMBER'])
->setCellValue('C1', $mod_strings['LBL_TYPE'])
->setCellValue('D1', $mod_strings['LBL_REGISTER_DATE'])
->setCellValue('E1', $mod_strings['LBL_PDF_TYPE'])
->setCellValue('F1', $mod_strings['LBL_NET_VALUE'])
->setCellValue('G1', "TH1")
->setCellValue('H1', "WG1")
->setCellValue('I1', "PP1")
->setCellValue('J1', "TR1")
->setCellValue('K1', $mod_strings['LBL_VAT_A'])
->setCellValue('L1', $mod_strings['LBL_VAT_B'])
->setCellValue('M1', $mod_strings['LBL_VAT_C'])
->setCellValue('N1', $mod_strings['LBL_GROSS_VALUE'])
->setCellValue('O1', $mod_strings['LBL_COST'])
->setCellValue('P1', "TH2")
->setCellValue('Q1', "WG2")
->setCellValue('R1', "PP2")
->setCellValue('S1', "TR2")
->setCellValue('T1', $mod_strings['LBL_MARGIN']);
/*****************************************************/
/********************* EXCELL Data *******************/
/*****************************************************/
// Add all data
$lastRowNumber = 2;
foreach ( $data as $rowNumber => &$row )
{
// --------------------------------------------
$pdfType = "";
if( $row["pdf_type"] == 'U')
$pdfType = $mod_strings['LBL_PDF_TYPE_U'];
else if( $row["pdf_type"] == 'K')
$pdfType = $mod_strings['LBL_PDF_TYPE_K'];
else if( $row["pdf_type"] == 'E')
$pdfType = $mod_strings['LBL_PDF_TYPE_E'];
// --------------------------------------------
$type = "";
if( $row["type"] == 'normal' )
$type = $mod_strings['LBL_PDF_TYPE_NORMAL'];
else if( $row["type"] == 'correct' )
$type = $mod_strings['LBL_PDF_TYPE_CORRECT'];
// --------------------------------------------
// Jeżeli z bazy danych sumy są nullami tu o to dbam, żeby nie było pustych pól w Excelu
$purchase1 = "0";
$purchase2 = "0";
$purchase3 = "0";
if( $row['purchasePriceGroupKS1'] != NULL && $row['purchasePriceGroupKS1'] != '' )
{
$purchase1 = $row['purchasePriceGroupKS1'];
}
if( $row['purchasePriceGroupKS2'] != NULL && $row['purchasePriceGroupKS2'] != '' )
{
$purchase2 = $row['purchasePriceGroupKS2'];
}
if( $row['purchasePriceGroupKS3'] != NULL && $row['purchasePriceGroupKS3'] != '' )
{
$purchase3 = $row['purchasePriceGroupKS3'];
}
if( $row['purchasePriceGroupKS4'] != NULL && $row['purchasePriceGroupKS4'] != '' )
{
$purchase4 = $row['purchasePriceGroupKS4'];
}
//echo number_format($row["subtotal"],2,".","")."(".gettype(number_format($row["subtotal"],2,".","")).")<br>";
//echo printf("%01.2f", $row['subtotal'])."(".gettype(printf("%01.2f", $row['subtotal'])).")<br>";
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A'.($rowNumber+2), $row['contractorName'])
->setCellValue('B'.($rowNumber+2), $row['document_no'])
->setCellValue('C'.($rowNumber+2), $type)
->setCellValue('D'.($rowNumber+2), $row['register_date'])
->setCellValue('E'.($rowNumber+2), $pdfType)
->setCellValue('F'.($rowNumber+2), number_format( $row['subtotal'], 2, ".", "" ))
->setCellValue('G'.($rowNumber+2), number_format( $row['subPriceGroupKS1'], 2, ".", "" ))
->setCellValue('H'.($rowNumber+2), number_format( $row['subPriceGroupKS2'], 2, ".", "" ))
->setCellValue('I'.($rowNumber+2), number_format( $row['subPriceGroupKS3'], 2, ".", "" ))
->setCellValue('J'.($rowNumber+2), number_format( $row['subPriceGroupKS3'], 2, ".", "" ))
->setCellValue('K'.($rowNumber+2), number_format( $row['vata'], 2, ".", "" ))
->setCellValue('L'.($rowNumber+2), number_format( $row['vatb'], 2, ".", "" ))
->setCellValue('M'.($rowNumber+2), number_format( $row['vatc'], 2, ".", "" ))
->setCellValue('N'.($rowNumber+2), number_format( $row['total'], 2, ".", "" ))
->setCellValue('O'.($rowNumber+2), number_format( $row['cost'], 2, ".", "" ))
->setCellValue('P'.($rowNumber+2), number_format( $purchase1 , 2, ".", "" ))
->setCellValue('Q'.($rowNumber+2), number_format( $purchase2 , 2, ".", "" ))
->setCellValue('R'.($rowNumber+2), number_format( $purchase3 , 2, ".", "" ))
->setCellValue('S'.($rowNumber+2), number_format( $purchase4 , 2, ".", "" ))
->setCellValue('T'.($rowNumber+2), number_format( $row['margin'], 2, ".", "")."%");
// Formatowanie walutowe
$objPHPExcel->setActiveSheetIndex(0)->getStyle('F'.($rowNumber+2))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('G'.($rowNumber+2))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('H'.($rowNumber+2))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('I'.($rowNumber+2))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('J'.($rowNumber+2))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('K'.($rowNumber+2))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('L'.($rowNumber+2))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('M'.($rowNumber+2))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('N'.($rowNumber+2))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('O'.($rowNumber+2))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('P'.($rowNumber+2))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('Q'.($rowNumber+2))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('R'.($rowNumber+2))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('S'.($rowNumber+2))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('T'.($rowNumber+2))->getNumberFormat()->setFormatCode("#0.#0");
// Wyrównanie pól do prawej
$objPHPExcel->setActiveSheetIndex(0)->getStyle("F".($rowNumber+2))->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("G".($rowNumber+2))->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("H".($rowNumber+2))->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("I".($rowNumber+2))->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("J".($rowNumber+2))->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("K".($rowNumber+2))->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("L".($rowNumber+2))->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("M".($rowNumber+2))->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("N".($rowNumber+2))->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("O".($rowNumber+2))->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("P".($rowNumber+2))->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("Q".($rowNumber+2))->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("R".($rowNumber+2))->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("S".($rowNumber+2))->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("T".($rowNumber+2))->applyFromArray($columnAlignRight);
$lastRowNumber++;
}
// Sumy --------------------------------------------------------------------------------------------------
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('E'.($lastRowNumber), "Podsumowanie: ")
->setCellValue('F'.($lastRowNumber), number_format( $sum['subtotalSum'], 2, ".", "" ))
->setCellValue('G'.($lastRowNumber), number_format( $sum['subPriceGroupKS1Sum'], 2, ".", "" ))
->setCellValue('H'.($lastRowNumber), number_format( $sum['subPriceGroupKS2Sum'], 2, ".", "" ))
->setCellValue('I'.($lastRowNumber), number_format( $sum['subPriceGroupKS3Sum'], 2, ".", "" ))
->setCellValue('J'.($lastRowNumber), number_format( $sum['subPriceGroupKS4Sum'], 2, ".", "" ))
->setCellValue('K'.($lastRowNumber), number_format( $sum['vataSum'], 2, ".", "" ))
->setCellValue('L'.($lastRowNumber), number_format( $sum['vatbSum'], 2, ".", "" ))
->setCellValue('M'.($lastRowNumber), number_format( $sum['vatcSum'], 2, ".", "" ))
->setCellValue('N'.($lastRowNumber), number_format( $sum['totalSum'], 2, ".", "" ))
->setCellValue('O'.($lastRowNumber), number_format( $sum['costSum'], 2, ".", "" ))
->setCellValue('P'.($lastRowNumber), number_format( $sum['purchasePriceGroupKS1Sum'], 2, ".", "" ))
->setCellValue('Q'.($lastRowNumber), number_format( $sum['purchasePriceGroupKS2Sum'], 2, ".", "" ))
->setCellValue('R'.($lastRowNumber), number_format( $sum['purchasePriceGroupKS3Sum'], 2, ".", "" ))
->setCellValue('S'.($lastRowNumber), number_format( $sum['purchasePriceGroupKS4Sum'], 2, ".", "" ))
->setCellValue('T'.($lastRowNumber), number_format( $sum['marginSum'], 2, ".", "" ));
$objPHPExcel->setActiveSheetIndex(0)->getStyle('F'.($lastRowNumber))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('G'.($lastRowNumber))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('H'.($lastRowNumber))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('I'.($lastRowNumber))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('J'.($lastRowNumber))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('K'.($lastRowNumber))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('L'.($lastRowNumber))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('M'.($lastRowNumber))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('N'.($lastRowNumber))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('O'.($lastRowNumber))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('P'.($lastRowNumber))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('Q'.($lastRowNumber))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('R'.($lastRowNumber))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('S'.($lastRowNumber))->getNumberFormat()->setFormatCode("#,#0.#0 zł");
$objPHPExcel->setActiveSheetIndex(0)->getStyle('T'.($lastRowNumber))->getNumberFormat()->setFormatCode("#0.#0");
// Wyrównanie pól ostatniego wiersza do prawej
$objPHPExcel->setActiveSheetIndex(0)->getStyle("E".$lastRowNumber.":T".$lastRowNumber)->applyFromArray($headerStyle);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("F".$lastRowNumber)->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("G".$lastRowNumber)->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("H".$lastRowNumber)->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("I".$lastRowNumber)->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("J".$lastRowNumber)->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("K".$lastRowNumber)->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("L".$lastRowNumber)->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("M".$lastRowNumber)->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("N".$lastRowNumber)->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("O".$lastRowNumber)->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("P".$lastRowNumber)->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("Q".$lastRowNumber)->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("R".$lastRowNumber)->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("S".$lastRowNumber)->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("T".$lastRowNumber)->applyFromArray($columnAlignRight);
$objPHPExcel->setActiveSheetIndex(0)->getStyle("A1:T1")->applyFromArray($headerStyle);
// Rename worksheet
$objPHPExcel->getActiveSheet()->setTitle('Raport sprzedaży');
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save( __DIR__ . "/ExcelFiles/DailySales.xls");
?>

View File

@@ -0,0 +1,442 @@
<?
if(!$_REQUEST['account_id'] && !$_REQUEST['year'])$_REQUEST['account_id']=134;
if(!$_REQUEST['year'])$_REQUEST['year']=2012;
$date_from=$GLOBALS['timedate']->to_db_date($_GET['date_from']);
$exp=explode("-",$date_from);
$date_from=date("Y-m-d",@mktime(0,0,0,$exp[1],$exp[2],$exp[0])+24*3600);
if(!$date_from)$date_from=date("Y-m-d");
$date_to=$GLOBALS['timedate']->to_db_date($_GET['date_to']);
$exp=explode("-",$date_to);
$date_to=date("Y-m-d",@mktime(0,0,0,$exp[1],$exp[2],$exp[0])+24*3600);
if(!$date_to)$date_to=date("Y-m-d");
if(!$_REQUEST['year'])$_REQUEST['year']=date("Y");
?>
<table cellspacing="0" cellpadding="0" border="0"><tr><td><img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" alt="EcmProducts" width="16" border="0" height="16"></td><td><h2>RPH Report:</h2></td></tr></table><br />
<ul class="tablist" style="width:100%;">
<li>
<a class="current" href="#">Basic Search</a>
</li>
</ul>
<form action="index.php" method="get" name="SearchFormSales">
<input type="hidden" name="module" value="EcmReports" />
<input type="hidden" name="action" value="ListSalesReport" />
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="dataLabel" width="10%" nowrap="nowrap">
Year </td>
<td class="dataField" width="23%" nowrap="nowrap">
<select name="year">
<option value="2010"<? if($_REQUEST['year']=="2010")echo " selected";?>>2010</option>
<option value="2011"<? if($_REQUEST['year']=="2011")echo " selected";?>>2011</option>
<option value="2012"<? if($_REQUEST['year']=="2012")echo " selected";?>>2012</option>
</select>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Account </td>
<td class="dataField" width="23%" nowrap="nowrap">
<select name="account_id">
<option value="">All</option>
<?php
$w=$GLOBALS['db']->query("select id,name from accounts where deleted='0' and (parent_id='' or parent_id is null or parent_id=id) order by name asc");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
echo '<option value="'.$r['id'].'"';
if($_REQUEST['account_id']==$r['id'])echo ' selected';
echo '>'.$r['name'].'</option>';
}
?>
</select>
</td>
<td class="dataLabel" width="10%" nowrap="nowrap">
Assigned User </td>
<td class="dataField" width="23%" nowrap="nowrap">
<select name="user_id">
<option value="">All</option>
<?php
$w=$GLOBALS['db']->query("select id,first_name,last_name,user_name from users where status='Active' order by first_name asc, last_name asc");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
echo '<option value="'.$r['id'].'"';
if($_REQUEST['user_id']==$r['id'])echo ' selected';
echo '>'.$r['first_name'].' '.$r['last_name'].'</option>';
}
?>
</select>
</td>
</tr>
</tbody>
</table>
<input class="button" name="submit" value="Search" type="submit">
<input class="button" name="clear" value="Clear" type="button" onclick="location.href='index.php?module=EcmReports&action=ListSalesReport';"><?
echo '&nbsp;<input type="button" class="button" name="CreateXLS" value="Create XLS" onclick="location.href=\'index.php?module=EcmReports&action=CreateXLSrph&year='.$_REQUEST['year'].'&user_id='.$_REQUEST['user_id'].'&account_id='.$_REQUEST['account_id'].'\';">';
?>
</form><br />
<?php
$tds1='<td valign="top" class="listViewThS1" style="vertical-align:top;">';
$trs='<tr>';
$tre='</tr>';
$tds='<td valign="top" class="oddListRowS1" style="vertical-align:top;">';
$tde='</td>';
$tbs='<table cellpadding="0" cellspacing="0" border="0" class="ListView" style="width:100%;">';
$tbe='</table>';
echo $tbs;
echo $trs;
echo $tds1;
echo "Lp.";
echo $tde;
echo $tds1;
echo "Name";
echo $tde;
echo $tds1;
echo "January";
echo $tde;
echo $tds1;
echo "February";
echo $tde;
echo $tds1;
echo "March";
echo $tde;
echo $tds1;
echo "April";
echo $tde;
echo $tds1;
echo "May";
echo $tde;
echo $tds1;
echo "June";
echo $tde;
echo $tds1;
echo "July";
echo $tde;
echo $tds1;
echo "August";
echo $tde;
echo $tds1;
echo "September";
echo $tde;
echo $tds1;
echo "October";
echo $tde;
echo $tds1;
echo "November";
echo $tde;
echo $tds1;
echo "December";
echo $tde;
echo $tds1;
echo $_REQUEST['year']." total";
echo $tde;
echo $tds1;
echo $_REQUEST['year']." avg";
echo $tde;
echo $tds1;
echo ($_REQUEST['year']-1)." total";
echo $tde;
echo $tds1;
echo ($_REQUEST['year']-1)." avg";
echo $tde;
echo $tds1;
echo "User";
echo $tde;
echo $tre;
$l=1;
$wh[]="deleted='0'";
if($_REQUEST['user_id'])$wh[]="assigned_user_id='".$_REQUEST['user_id']."'";
if($_REQUEST['account_id']){
$wh[]="(parent_id='".$_REQUEST['account_id']."' or id='".$_REQUEST['account_id']."')";
$wh[]="(parent_id is not null or id='".$_REQUEST['account_id']."')";
}
if(count($wh)>0)$where=" and ".implode(" and ",$wh);
else $where="";
$z="select * from accounts where 1=1".$where." order by name asc";
$w=$GLOBALS['db']->query($z);
function getSumWz($year){
/*$w=$GLOBALS['db']->query("select id,type,register_date,currency_value,wz_id,parent_id,ecminvoiceout_id from ecminvoiceouts where register_date like '".$_REQUEST['year']."%' and deleted='0'");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
if(!$r['currency_value'])
$currency_value=1;
else $currency_value=$r['currency_value'];
$d=explode("-",$r['register_date']);
$dat=$d[0]."-".$d[1];
if($r['type']!="correct"){
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select sum(price*quantity) as s from ecminvoiceoutitems where ecminvoiceout_id='".$r['id']."' and deleted='0'"));
$total_netto=$currency_value*$rr['s'];
}
else{
$ww=$GLOBALS['db']->query("select price,quantity,ecminvoiceoutitem_id from ecminvoiceoutitems where ecminvoiceout_id='".$r['id']."' and deleted='0'");
$total_netto=0;
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
$rrrr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select price,quantity from ecminvoiceoutitems where id='".$rr['ecminvoiceoutitem_id']."'"));
$total_netto+=$currency_value*$rr['price']*$rr['quantity']-$currency_value*$rrrr['price']*$rrrr['quantity'];
}
}
if($r['wz_id']){
$rrr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select parent_id from ecmstockdocouts where id='".$r['wz_id']."'"));
$parent_id=$rrr['parent_id'];
}
else {
if($r['type']!="correct")$parent_id=$r['parent_id'];
else{
$rrr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select wz_id from ecminvoiceouts where id='".$r['ecminvoiceout_id']."'"));
$rrr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select parent_id from ecmstockdocouts where id='".$rrr['wz_id']."'"));
$parent_id=$rrr['parent_id'];
}
$parent_id=$r['parent_id'];
}
$sum[$dat][$parent_id]['tn']+=$total_netto;
}*/
$wh=array();
$wh[]="e.deleted='0'";
$wh[]="i.deleted='0'";
$wh[]="(w.deleted is null or w.deleted='0')";
$wh[]="(p.deleted is null or p.deleted='0')";
$wh[]="(ci.deleted is null or ci.deleted='0')";
$wh[]="e.status='accepted'";
$wh[]="e.register_date like '".$year."%'";
if($_REQUEST['account_id'])$wh[]="(e.parent_id='".$_REQUEST['account_id']."' or w.parent_id='".$_REQUEST['account_id']."')";
$q="select
sum(
CASE WHEN e.type!='correct'
THEN
CASE WHEN e.currency_value is null or e.currency_value=''
THEN
i.price*i.quantity
ELSE
i.price*i.quantity*e.currency_value
END
ELSE
CASE WHEN ci.price is null or ci.quantity is null
THEN
0
ELSE
i.price*i.quantity-ci.price*ci.quantity
END
END
) as sales,
sum(
CASE WHEN e.type!='correct'
THEN
i.purchase_price*i.quantity
ELSE
CASE WHEN ci.quantity is null
THEN
0
ELSE
i.purchase_price*i.quantity-i.purchase_price*ci.quantity
END
END
) as purchase,
sum(
CASE WHEN e.type!='correct'
THEN
i.quantity
ELSE
CASE WHEN ci.quantity is null
THEN
0
ELSE
i.quantity-ci.quantity
END
END
) as quantity,
sum(
CASE WHEN e.type!='correct' THEN
CASE WHEN p.pieces_per_carton>0 and p.pieces_per_carton is not null THEN
i.quantity*p.carton_volume_meter/p.pieces_per_carton
ELSE
0
END
ELSE
CASE WHEN ci.quantity is null THEN
0
ELSE
CASE WHEN p.pieces_per_carton>0 and p.pieces_per_carton is not null THEN
(i.quantity-ci.quantity)*p.carton_volume_meter/p.pieces_per_carton
ELSE
0
END
END
END
) as cbm,
w.parent_id as pid,
month(e.register_date) as month,
year(e.register_date) as year
from ecminvoiceoutitems as i
left join ecminvoiceoutitems as ci on i.ecminvoiceoutitem_id=ci.id
inner join ecminvoiceouts as e on e.id=i.ecminvoiceout_id
left join ecmstockdocouts as w on e.wz_id=w.id
left join ecmproducts as p on p.id=i.ecmproduct_id
where
".implode(" and ",$wh)."
group by w.parent_id,month(e.register_date)";
$query=$GLOBALS['db']->query($q);
echo mysql_error();
while($r=$GLOBALS['db']->fetchByAssoc($query)){
$sum[$r['year'].'-'.$r['month']][$r['pid']]['tn']+=$r['sales'];
}
return $sum;
}
function getCallTime($z){
$www=$GLOBALS['db']->query($z);
while($rrr=$GLOBALS['db']->fetchByAssoc($www)){
$acc_ids=array();
$con_ids=array();
$acc_ids[]="e.bean_id='".$rrr['id']."'";
$w=$GLOBALS['db']->query("select contact_id from accounts_contacts where deleted='0' and account_id='".$rrr['id']."'");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
$con_ids[]="e.bean_id='".$r['contact_id']."'";
}
if(count($acc_ids)>0){
$w=$GLOBALS['db']->query("select c.duration,e.date_modified from ecmcalls_beans as e inner join cdr as c on c.id=e.ecmcall_id where ".$acc_ids[0]." and e.bean_module='Accounts' and e.date_modified like '".$_REQUEST['year']."%'");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
$d=explode("-",$r['date_modified']);
$arr[$rrr['id']][$d[0]."-".$d[1]]['duration']+=$r['duration'];
$arr[$rrr['id']][$d[0]."-".$d[1]]['l']++;
$arr[$d[0]."-".$d[1]]['duration']+=$r['duration'];
$arr[$d[0]."-".$d[1]]['l']++;
}
}
if(count($con_ids)>0){
$w=$GLOBALS['db']->query("select c.duration,e.date_modified from ecmcalls_beans as e inner join cdr as c on c.id=e.ecmcall_id where (".implode(" or ",$con_ids).") and e.date_modified like '".$_REQUEST['year']."%'");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
$d=explode("-",$r['date_modified']);
$arr[$rrr['id']][$d[0]."-".$d[1]]['duration']+=$r['duration'];
$arr[$rrr['id']][$d[0]."-".$d[1]]['l']++;
$arr[$d[0]."-".$d[1]]['duration']+=$r['duration'];
$arr[$d[0]."-".$d[1]]['l']++;
}
}
}
return $arr;
}
function getMinSec($v){
$min=floor($v/60);
$sec=$v-$min*60;
if($min>0 || $sec>0)$str=$min."m ".$sec."s";
return $str;
}
$swz1=getSumWz($_REQUEST['year']);
$swz11=getSumWz($_REQUEST['year']-1);
if($_REQUEST['account_id'] && $_REQUEST['user_id']){
$time=getCallTime($z);
$_SESSION['EcmSalesReport_time']=$time;
}
//echo '<pre>';print_r($time);echo '</pre>';
//die();
//echo '<pre>';print_r($swz1);echo '</pre>';
echo '<script language="javascript" src="modules/EcmProducts/helper.js"></script>';
echo '<script language="javascript" src="modules/EcmProducts/mintajax.js"></script>';
echo '<div id="ret" style="display:none;"></div>';
while($r=$GLOBALS['db']->fetchByAssoc($w)){
echo $trs;
echo $tds;
echo $l;
echo $tde;
echo $tds;
echo '<a href="index.php?module=Accounts&action=DetailView&record='.$r['id'].'">'.$r['name'].'</a>';
echo $tde;
for($i=1;$i<=12;$i++){
if($i<10)$n="0".$i;
else $n=$i;
$swz=$swz1[$_REQUEST['year']."-".$i][$r['id']];
$total_netto=$swz['tn'];
$rval=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select value from ecmsalesreports_predictions where account_id='".$r['id']."' and year='".$_REQUEST['year']."' and month='".$i."' and deleted='0'"));
$value=$rval['value'];
echo $tds;
echo number_format($total_netto,2,",",".");
//if($i>(int)date("m")){
echo '<div id="new'.$r['id'].'_'.$i.'" style="display:inline;">&nbsp;('.number_format($value,2,",",".").')</div>&nbsp;<a style="cursor:pointer;display:inline;" onclick="if(document.getElementById(\'div'.$r['id'].'_'.$i.'\').style.display==\'none\'){document.getElementById(\'div'.$r['id'].'_'.$i.'\').style.display=\'block\';}else{document.getElementById(\'div'.$r['id'].'_'.$i.'\').style.display=\'none\';}"><img src="modules/EcmQuotes/images/search.gif" border="0" /></a><div id="div'.$r['id'].'_'.$i.'" style="display:none; border: 1px solid #cccccc;background-color:#e6e6e6;padding:3px;text-align:center;"><input id=\'value'.$r['id'].'_'.$i.'\' value=\''.number_format($value,2,".","").'\' style="width:80px;"><input type="button" onclick="mintajaxget(\'index.php?to_pdf=1&module=EcmReports&action=setVal&account_id='.$r['id'].'&year='.$_REQUEST['year'].'&month='.$i.'&value=\'+document.getElementById(\'value'.$r['id'].'_'.$i.'\').value,\'new'.$r['id'].'_'.$i.'\');document.getElementById(\'div'.$r['id'].'_'.$i.'\').style.display=\'none\';" value="Save" class="button"></div><br>'.getMinSec($time[$r['id']][$_REQUEST['year']."-".$n]['duration']).' - '.$time[$r['id']][$_REQUEST['year']."-".$n]['l'].'';
//}
echo $tde;
$sum_total_netto[$_REQUEST['year']."-".$n]+=$total_netto;
$sum_total_netto[$_REQUEST['year']]+=$total_netto;
$account_total[$r['id']]+=$total_netto;
}
for($i=1;$i<=12;$i++){
if($i<10)$n="0".$i;
else $n=$i;
$swzm=$swz11[($_REQUEST['year']-1)."-".$i][$r['id']];
$total_netto_m=$swzm['tn'];
$sum_total_netto_m[($_REQUEST['year']-1)."-".$n]+=$total_netto_m;
$sum_total_netto_m[$_REQUEST['year']-1]+=$total_netto_m;
$account_total_m[$r['id']]+=$total_netto_m;
}
echo $tds;
echo number_format($account_total[$r['id']],2,",",".");
echo $tde;
echo $tds;
echo number_format(($account_total[$r['id']]/((int)date("m"))),2,",",".");
echo $tde;
echo $tds;
echo number_format($account_total_m[$r['id']],2,",",".");
echo $tde;
echo $tds;
echo number_format(($account_total_m[$r['id']]/12),2,",",".");
echo $tde;
$ruser=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select first_name,last_name from users where id='".$r['assigned_user_id']."'"));
echo $tds;
echo $ruser['first_name'].' '.$ruser['last_name'];
echo $tde;
echo $tre;
$l++;
}
echo $trs;
echo $tds1;
echo '&nbsp;';
echo $tde;
echo $tds1;
echo '&nbsp;';
echo $tde;
for($i=1;$i<=12;$i++){
$allvalue=0;
$wacc=$GLOBALS['db']->query("select * from accounts where 1=1".$where." order by name asc");
while($racc=$GLOBALS['db']->fetchByAssoc($wacc)){
$wval=$GLOBALS['db']->query("select value from ecmsalesreports_predictions where account_id='".$racc['id']."' and year='".$_REQUEST['year']."' and month='".$i."' and deleted='0'");
while($rval=$GLOBALS['db']->fetchByAssoc($wval)){
$allvalue+=$rval['value'];
}
}
if($i<10)$n="0".$i;
else $n=$i;
echo $tds1;
echo number_format(($sum_total_netto[$_REQUEST['year'].'-'.$n]),2,",",".")." (".number_format($allvalue,2,",",".").")<br>".getMinSec($time[$_REQUEST['year']."-".$n]['duration']).' - '.$time[$_REQUEST['year']."-".$n]['l'];
echo $tde;
}
echo $tds1;
echo number_format($sum_total_netto[$_REQUEST['year']],2,",",".");
echo $tde;
echo $tds1;
echo number_format(($sum_total_netto[$_REQUEST['year']]/((int)date("m"))),2,",",".");
echo $tde;
echo $tds1;
echo number_format($sum_total_netto_m[$_REQUEST['year']-1],2,",",".");
echo $tde;
echo $tds1;
echo number_format(($sum_total_netto_m[$_REQUEST['year']-1]/12),2,",",".");
echo $tde;
echo $tds1;
echo '&nbsp;';
echo $tde;
echo $tre;
echo $tbe;
//echo $t;
?>

154
modules/EcmReports/Menu.php Executable file
View File

@@ -0,0 +1,154 @@
<?php
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
die ( 'Not A Valid Entry Point' );
/**
* *******************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc.
* Copyright (C) 2004 - 2007 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
* ******************************************************************************
*/
/**
* *******************************************************************************
*
* Description: TODO To be written.
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
* All Rights Reserved.
* Contributor(s): ______________________________________..
* ******************************************************************************
*/
global $mod_strings;
if (ACLController::checkAccess ( 'EcmReports', 'list', true ))
$module_menu [] = array (
"index.php?module=EcmReports&action=ReportStocks&return_module=EcmReports&return_action=DetailView",
"Raport stanów magazynowych",
"EcmReports",
'EcmReports'
);
if (ACLController::checkAccess ( 'EcmReports', 'list', true ))
$module_menu [] = array (
"index.php?module=EcmReports&action=ReportSales&return_module=EcmReports&return_action=DetailView",
"Raport sprzadaży z podziałem na kategorie",
"EcmReports",
'EcmReports'
);
if (ACLController::checkAccess ( 'EcmReports', 'list', true ))
$module_menu [] = array (
"index.php?module=EcmReports&action=ReportSalesByContractor&return_module=EcmReports&return_action=DetailView",
"Raport sprzadaży z podziałem na kontrahentów",
"EcmReports",
'EcmReports'
);
if (ACLController::checkAccess ( 'EcmReports', 'list', true ))
$module_menu [] = array (
"index.php?module=EcmReports&action=ListDailySales&return_module=EcmReports&return_action=DetailView",
"Raport sprzadaży z podziałem na dokumenty",
"EcmReports",
'EcmReports'
);
if (ACLController::checkAccess ( 'EcmReports', 'list', true ))
$module_menu [] = array (
"index.php?module=EcmReports&action=salesByCategory&return_module=EcmReports&return_action=DetailView",
"Raport sprzadaży z podziałem na kategorie (STARY)",
"EcmReports",
'EcmReports'
);
if (ACLController::checkAccess ( 'EcmReports', 'list', true ))
$module_menu [] = array (
"index.php?module=EcmReports&action=sales_by_accounts&return_module=EcmReports&return_action=DetailView",
"Raport sprzadaży z podziałem na kontrahentów (STARY)",
"EcmReports",
'EcmReports'
);
if (ACLController::checkAccess ( 'EcmReports', 'list', true ))
$module_menu [] = array (
"index.php?module=EcmReports&action=ReportSalesByProductGroups&return_module=EcmReports&return_action=DetailView",
"Raport sprzadaży z podziałem na grupy produktowe",
"EcmReports",
'EcmReports'
);
if (ACLController::checkAccess ( 'EcmReports', 'list', true ))
$module_menu [] = array (
"index.php?module=EcmReports&action=ListDailySalesOLD&return_module=EcmReports&return_action=DetailView",
"Raport sprzadaży z podziałem na dokumenty (STARY DAILY SALES)",
"EcmReports",
'EcmReports'
);
if (ACLController::checkAccess ( 'EcmReports', 'list', true ))
$module_menu [] = array (
"index.php?module=EcmReports&action=ReportStockDocMoves&return_module=EcmReports&return_action=DetailView",
"Raport - Obroty wg. dokumentów",
"EcmReports",
'EcmReports'
);
if (ACLController::checkAccess ( 'EcmReports', 'list', true ))
$module_menu [] = array (
"index.php?module=EcmReports&action=ReportSalesVatSales&return_module=EcmReports&return_action=DetailView",
"Raport - Rejestr sprzedaży VAT",
"EcmReports",
'EcmReports'
);
if (ACLController::checkAccess ( 'EcmReports', 'list', true ))
$module_menu [] = array (
"index.php?module=EcmReports&action=ReportBuyesByVat&return_module=EcmReports&return_action=DetailView",
"Raport - Rejestr zakupu VAT",
"EcmReports",
'EcmReports'
);
if (ACLController::checkAccess ( 'EcmReports', 'list', true ))
$module_menu [] = array (
"index.php?module=EcmReports&action=RewizorGT",
"Raport - eksport dokumentów Rewizor",
"EcmReports",
'EcmReports'
);
if (ACLController::checkAccess ( 'EcmReports', 'list', true ))
$module_menu [] = array (
"index.php?module=EcmReports&action=ReportStockNew",
"Raport magazynowy - Stany magazynowe za okres",
"EcmReports",
'EcmReports'
);
if (ACLController::checkAccess ( 'EcmReports', 'list', true ))
$module_menu [] = array (
"index.php?module=EcmReports&action=mzVatPurchases",
"Raport ilościowy zakupu",
"EcmReports",
'EcmReports'
);
?>

View File

@@ -0,0 +1,9 @@
build/PHPExcel.phar
unitTests/codeCoverage
analysis
## IDE support
*.buildpath
*.project
/.settings
/.idea

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,89 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
PHPExcel_Autoloader::Register();
// As we always try to run the autoloader before anything else, we can use it to do a few
// simple checks and initialisations
//PHPExcel_Shared_ZipStreamWrapper::register();
// check mbstring.func_overload
if (ini_get('mbstring.func_overload') & 2) {
throw new PHPExcel_Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}
PHPExcel_Shared_String::buildCharacterSets();
/**
* PHPExcel_Autoloader
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Autoloader
{
/**
* Register the Autoloader with SPL
*
*/
public static function Register() {
if (function_exists('__autoload')) {
// Register any existing autoloader function with SPL, so we don't get any clashes
spl_autoload_register('__autoload');
}
// Register ourselves with SPL
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'), true, true);
} else {
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
}
} // function Register()
/**
* Autoload a class identified by name
*
* @param string $pClassName Name of the object to load
*/
public static function Load($pClassName){
if ((class_exists($pClassName,FALSE)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
// Either already loaded, or not a PHPExcel class request
return FALSE;
}
$pClassFilePath = PHPEXCEL_ROOT .
str_replace('_',DIRECTORY_SEPARATOR,$pClassName) .
'.php';
if ((file_exists($pClassFilePath) === FALSE) || (is_readable($pClassFilePath) === FALSE)) {
// Can't load
return FALSE;
}
require($pClassFilePath);
} // function Load()
}

View File

@@ -0,0 +1,295 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_APC
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Prefix used to uniquely identify cache data for this worksheet
*
* @access private
* @var string
*/
private $_cachePrefix = null;
/**
* Cache timeout
*
* @access private
* @var integer
*/
private $_cacheTime = 600;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @access private
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
$this->_currentObject->detach();
if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in APC');
}
$this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @access public
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_cellCache[$pCoord] = true;
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @access public
* @param string $pCoord Coordinate address of the cell to check
* @throws PHPExcel_Exception
* @return boolean
*/
public function isDataSet($pCoord) {
// Check if the requested entry is the current object, or exists in the cache
if (parent::isDataSet($pCoord)) {
if ($this->_currentObjectID == $pCoord) {
return true;
}
// Check if the requested entry still exists in apc
$success = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
if ($success === FALSE) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
}
return true;
}
return false;
} // function isDataSet()
/**
* Get cell at a specific coordinate
*
* @access public
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (parent::isDataSet($pCoord)) {
$obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
if ($obj === FALSE) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
}
} else {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->_currentObject = unserialize($obj);
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
}
return parent::getCellList();
}
/**
* Delete a cell in cache identified by coordinate address
*
* @access public
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord) {
// Delete the entry from APC
apc_delete($this->_cachePrefix.$pCoord.'.cache');
// Delete the entry from our cell address array
parent::deleteCacheData($pCoord);
} // function deleteCacheData()
/**
* Clone the cell collection
*
* @access public
* @param PHPExcel_Worksheet $parent The new worksheet
* @throws PHPExcel_Exception
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
parent::copyCellCollection($parent);
// Get a new id for the new file name
$baseUnique = $this->_getUniqueID();
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
if ($cellID != $this->_currentObjectID) {
$obj = apc_fetch($this->_cachePrefix.$cellID.'.cache');
if ($obj === FALSE) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($cellID);
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in APC');
}
if (!apc_store($newCachePrefix.$cellID.'.cache',$obj,$this->_cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in APC');
}
}
}
$this->_cachePrefix = $newCachePrefix;
} // function copyCellCollection()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
if ($this->_currentObject !== NULL) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
// Flush the APC cache
$this->__destruct();
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if ($this->_cachePrefix === NULL) {
$baseUnique = $this->_getUniqueID();
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
$this->_cacheTime = $cacheTime;
parent::__construct($parent);
}
} // function __construct()
/**
* Destroy this cell collection
*/
public function __destruct() {
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
apc_delete($this->_cachePrefix.$cellID.'.cache');
}
} // function __destruct()
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable() {
if (!function_exists('apc_store')) {
return FALSE;
}
if (apc_sma_info() === FALSE) {
return FALSE;
}
return TRUE;
}
}

View File

@@ -0,0 +1,347 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_CacheBase
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
abstract class PHPExcel_CachedObjectStorage_CacheBase {
/**
* Parent worksheet
*
* @var PHPExcel_Worksheet
*/
protected $_parent;
/**
* The currently active Cell
*
* @var PHPExcel_Cell
*/
protected $_currentObject = null;
/**
* Coordinate address of the currently active Cell
*
* @var string
*/
protected $_currentObjectID = null;
/**
* Flag indicating whether the currently active Cell requires saving
*
* @var boolean
*/
protected $_currentCellIsDirty = true;
/**
* An array of cells or cell pointers for the worksheet cells held in this cache,
* and indexed by their coordinate address within the worksheet
*
* @var array of mixed
*/
protected $_cellCache = array();
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
*/
public function __construct(PHPExcel_Worksheet $parent) {
// Set our parent worksheet.
// This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
// they are woken from a serialized state
$this->_parent = $parent;
} // function __construct()
/**
* Return the parent worksheet for this cell collection
*
* @return PHPExcel_Worksheet
*/
public function getParent()
{
return $this->_parent;
}
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return true;
}
// Check if the requested entry exists in the cache
return isset($this->_cellCache[$pCoord]);
} // function isDataSet()
/**
* Move a cell object from one address to another
*
* @param string $fromAddress Current address of the cell to move
* @param string $toAddress Destination address of the cell to move
* @return boolean
*/
public function moveCell($fromAddress, $toAddress) {
if ($fromAddress === $this->_currentObjectID) {
$this->_currentObjectID = $toAddress;
}
$this->_currentCellIsDirty = true;
if (isset($this->_cellCache[$fromAddress])) {
$this->_cellCache[$toAddress] = &$this->_cellCache[$fromAddress];
unset($this->_cellCache[$fromAddress]);
}
return TRUE;
} // function moveCell()
/**
* Add or Update a cell in cache
*
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function updateCacheData(PHPExcel_Cell $cell) {
return $this->addCacheData($cell->getCoordinate(),$cell);
} // function updateCacheData()
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
$this->_currentObject->detach();
$this->_currentObjectID = $this->_currentObject = null;
}
if (is_object($this->_cellCache[$pCoord])) {
$this->_cellCache[$pCoord]->detach();
unset($this->_cellCache[$pCoord]);
}
$this->_currentCellIsDirty = false;
} // function deleteCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList() {
return array_keys($this->_cellCache);
} // function getCellList()
/**
* Sort the list of all cell addresses currently held in cache by row and column
*
* @return string[]
*/
public function getSortedCellList() {
$sortKeys = array();
foreach ($this->getCellList() as $coord) {
sscanf($coord,'%[A-Z]%d', $column, $row);
$sortKeys[sprintf('%09d%3s',$row,$column)] = $coord;
}
ksort($sortKeys);
return array_values($sortKeys);
} // function sortCellList()
/**
* Get highest worksheet column and highest row that have cell records
*
* @return array Highest column name and highest row number
*/
public function getHighestRowAndColumn()
{
// Lookup highest column and highest row
$col = array('A' => '1A');
$row = array(1);
foreach ($this->getCellList() as $coord) {
sscanf($coord,'%[A-Z]%d', $c, $r);
$row[$r] = $r;
$col[$c] = strlen($c).$c;
}
if (!empty($row)) {
// Determine highest column and row
$highestRow = max($row);
$highestColumn = substr(max($col),1);
}
return array( 'row' => $highestRow,
'column' => $highestColumn
);
}
/**
* Return the cell address of the currently active cell object
*
* @return string
*/
public function getCurrentAddress()
{
return $this->_currentObjectID;
}
/**
* Return the column address of the currently active cell object
*
* @return string
*/
public function getCurrentColumn()
{
sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);
return $column;
}
/**
* Return the row address of the currently active cell object
*
* @return integer
*/
public function getCurrentRow()
{
sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);
return (integer) $row;
}
/**
* Get highest worksheet column
*
* @param string $row Return the highest column for the specified row,
* or the highest column of any row if no row number is passed
* @return string Highest column name
*/
public function getHighestColumn($row = null)
{
if ($row == null) {
$colRow = $this->getHighestRowAndColumn();
return $colRow['column'];
}
$columnList = array(1);
foreach ($this->getCellList() as $coord) {
sscanf($coord,'%[A-Z]%d', $c, $r);
if ($r != $row) {
continue;
}
$columnList[] = PHPExcel_Cell::columnIndexFromString($c);
}
return PHPExcel_Cell::stringFromColumnIndex(max($columnList) - 1);
}
/**
* Get highest worksheet row
*
* @param string $column Return the highest row for the specified column,
* or the highest row of any column if no column letter is passed
* @return int Highest row number
*/
public function getHighestRow($column = null)
{
if ($column == null) {
$colRow = $this->getHighestRowAndColumn();
return $colRow['row'];
}
$rowList = array(0);
foreach ($this->getCellList() as $coord) {
sscanf($coord,'%[A-Z]%d', $c, $r);
if ($c != $column) {
continue;
}
$rowList[] = $r;
}
return max($rowList);
}
/**
* Generate a unique ID for cache referencing
*
* @return string Unique Reference
*/
protected function _getUniqueID() {
if (function_exists('posix_getpid')) {
$baseUnique = posix_getpid();
} else {
$baseUnique = mt_rand();
}
return uniqid($baseUnique,true);
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
$this->_currentCellIsDirty;
$this->_storeData();
$this->_parent = $parent;
if (($this->_currentObject !== NULL) && (is_object($this->_currentObject))) {
$this->_currentObject->attach($this);
}
} // function copyCellCollection()
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable() {
return true;
}
}

View File

@@ -0,0 +1,219 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_DiscISAM
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Name of the file for this cache
*
* @var string
*/
private $_fileName = NULL;
/**
* File handle for this cache file
*
* @var resource
*/
private $_fileHandle = NULL;
/**
* Directory/Folder where the cache file is located
*
* @var string
*/
private $_cacheDirectory = NULL;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
$this->_currentObject->detach();
fseek($this->_fileHandle,0,SEEK_END);
$this->_cellCache[$this->_currentObjectID] = array(
'ptr' => ftell($this->_fileHandle),
'sz' => fwrite($this->_fileHandle, serialize($this->_currentObject))
);
$this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->_cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
fseek($this->_fileHandle, $this->_cellCache[$pCoord]['ptr']);
$this->_currentObject = unserialize(fread($this->_fileHandle, $this->_cellCache[$pCoord]['sz']));
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
}
return parent::getCellList();
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
parent::copyCellCollection($parent);
// Get a new id for the new file name
$baseUnique = $this->_getUniqueID();
$newFileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
// Copy the existing cell cache file
copy ($this->_fileName,$newFileName);
$this->_fileName = $newFileName;
// Open the copied cell cache file
$this->_fileHandle = fopen($this->_fileName,'a+');
} // function copyCellCollection()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
// Close down the temporary cache file
$this->__destruct();
} // function unsetWorksheetCells()
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$this->_cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== NULL))
? $arguments['dir']
: PHPExcel_Shared_File::sys_get_temp_dir();
parent::__construct($parent);
if (is_null($this->_fileHandle)) {
$baseUnique = $this->_getUniqueID();
$this->_fileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
$this->_fileHandle = fopen($this->_fileName,'a+');
}
} // function __construct()
/**
* Destroy this cell collection
*/
public function __destruct() {
if (!is_null($this->_fileHandle)) {
fclose($this->_fileHandle);
unlink($this->_fileName);
}
$this->_fileHandle = null;
} // function __destruct()
}

View File

@@ -0,0 +1,112 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_ICache
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_CachedObjectStorage_ICache
{
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell);
/**
* Add or Update a cell in cache
*
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function updateCacheData(PHPExcel_Cell $cell);
/**
* Fetch a cell from cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to retrieve
* @return PHPExcel_Cell Cell that was found, or null if not found
* @throws PHPExcel_Exception
*/
public function getCacheData($pCoord);
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord);
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord);
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList();
/**
* Get the list of all cell addresses currently held in cache sorted by column and row
*
* @return string[]
*/
public function getSortedCellList();
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent);
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable();
}

View File

@@ -0,0 +1,152 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_Igbinary
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
$this->_currentObject->detach();
$this->_cellCache[$this->_currentObjectID] = igbinary_serialize($this->_currentObject);
$this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->_cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->_currentObject = igbinary_unserialize($this->_cellCache[$pCoord]);
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
}
return parent::getCellList();
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable() {
if (!function_exists('igbinary_serialize')) {
return false;
}
return true;
}
}

View File

@@ -0,0 +1,312 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_Memcache
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Prefix used to uniquely identify cache data for this worksheet
*
* @var string
*/
private $_cachePrefix = null;
/**
* Cache timeout
*
* @var integer
*/
private $_cacheTime = 600;
/**
* Memcache interface
*
* @var resource
*/
private $_memcache = null;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
$this->_currentObject->detach();
$obj = serialize($this->_currentObject);
if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in MemCache');
}
}
$this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_cellCache[$pCoord] = true;
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
* @return boolean
*/
public function isDataSet($pCoord) {
// Check if the requested entry is the current object, or exists in the cache
if (parent::isDataSet($pCoord)) {
if ($this->_currentObjectID == $pCoord) {
return true;
}
// Check if the requested entry still exists in Memcache
$success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
if ($success === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
}
return true;
}
return false;
} // function isDataSet()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (parent::isDataSet($pCoord)) {
$obj = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
if ($obj === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
}
} else {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->_currentObject = unserialize($obj);
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
}
return parent::getCellList();
}
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord) {
// Delete the entry from Memcache
$this->_memcache->delete($this->_cachePrefix.$pCoord.'.cache');
// Delete the entry from our cell address array
parent::deleteCacheData($pCoord);
} // function deleteCacheData()
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
parent::copyCellCollection($parent);
// Get a new id for the new file name
$baseUnique = $this->_getUniqueID();
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
if ($cellID != $this->_currentObjectID) {
$obj = $this->_memcache->get($this->_cachePrefix.$cellID.'.cache');
if ($obj === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($cellID);
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in MemCache');
}
if (!$this->_memcache->add($newCachePrefix.$cellID.'.cache',$obj,NULL,$this->_cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in MemCache');
}
}
}
$this->_cachePrefix = $newCachePrefix;
} // function copyCellCollection()
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
// Flush the Memcache cache
$this->__destruct();
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if (is_null($this->_cachePrefix)) {
$baseUnique = $this->_getUniqueID();
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
// Set a new Memcache object and connect to the Memcache server
$this->_memcache = new Memcache();
if (!$this->_memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) {
throw new PHPExcel_Exception('Could not connect to MemCache server at '.$memcacheServer.':'.$memcachePort);
}
$this->_cacheTime = $cacheTime;
parent::__construct($parent);
}
} // function __construct()
/**
* Memcache error handler
*
* @param string $host Memcache server
* @param integer $port Memcache port
* @throws PHPExcel_Exception
*/
public function failureCallback($host, $port) {
throw new PHPExcel_Exception('memcache '.$host.':'.$port.' failed');
}
/**
* Destroy this cell collection
*/
public function __destruct() {
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
$this->_memcache->delete($this->_cachePrefix.$cellID.'.cache');
}
} // function __destruct()
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable() {
if (!function_exists('memcache_add')) {
return false;
}
return true;
}
}

View File

@@ -0,0 +1,125 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_Memory
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Dummy method callable from CacheBase, but unused by Memory cache
*
* @return void
*/
protected function _storeData() {
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
$this->_cellCache[$pCoord] = $cell;
// Set current entry to the new/updated entry
$this->_currentObjectID = $pCoord;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
// Check if the entry that has been requested actually exists
if (!isset($this->_cellCache[$pCoord])) {
$this->_currentObjectID = NULL;
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
// Return requested entry
return $this->_cellCache[$pCoord];
} // function getCacheData()
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent) {
parent::copyCellCollection($parent);
$newCollection = array();
foreach($this->_cellCache as $k => &$cell) {
$newCollection[$k] = clone $cell;
$newCollection[$k]->attach($this);
}
$this->_cellCache = $newCollection;
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
// Because cells are all stored as intact objects in memory, we need to detach each one from the parent
foreach($this->_cellCache as $k => &$cell) {
$cell->detach();
$this->_cellCache[$k] = null;
}
unset($cell);
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
}

View File

@@ -0,0 +1,137 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_CachedObjectStorage_MemoryGZip
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function _storeData() {
if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
$this->_currentObject->detach();
$this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));
$this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
$this->_currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->_cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord]));
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {
$this->_storeData();
}
return parent::getCellList();
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
}

Some files were not shown because too many files have changed in this diff Show More