Compare commits
126 Commits
Release_ca
...
Hotfix-4
| Author | SHA1 | Date | |
|---|---|---|---|
| 07c7278d9b | |||
| 575d51a772 | |||
| cf698e9ab8 | |||
| 7a0e74fa7b | |||
| 8b0e1f78ef | |||
| dd4a0c606e | |||
| b6e481e08d | |||
| ff5c45f6ff | |||
| 08cc34d25a | |||
| d8d088f5cb | |||
| d7f71c381e | |||
| 267fbcb6d5 | |||
| 3a2217eb99 | |||
| dd527768cd | |||
| ba7144c23e | |||
| 872db7820c | |||
| a9a75a2bdd | |||
| 64df4a7139 | |||
| 6c46d127e7 | |||
| bccaeec280 | |||
| 6c282f01a4 | |||
| c1aa31a180 | |||
| 7fb09edb43 | |||
| 1fc13d7d9e | |||
| 43e560303b | |||
| 95b63ed6e3 | |||
| 0d14e2f7e2 | |||
| e81c8f14f5 | |||
| b1d92b796b | |||
| 784b4afcf7 | |||
| 3c9f1daab0 | |||
| 49ff282e59 | |||
| 93e18650ea | |||
| c10799665b | |||
| afa981edc0 | |||
| 9a580d2be0 | |||
| 66af3f5514 | |||
| f89112d01f | |||
| 78176fba04 | |||
| a924ad9573 | |||
| 81105cd10b | |||
| 4b12007403 | |||
| f84c33ab03 | |||
| 5f627358c8 | |||
| 442e0bf7b1 | |||
| 2b8ff873c4 | |||
| fe4f851f5c | |||
| 1242c75f8e | |||
| 99ab8df449 | |||
| b4b3e45350 | |||
| 467214f0ae | |||
| 7a11422f86 | |||
| 653d476eab | |||
| 3ba8c4f1dc | |||
| 062c474db5 | |||
| 4cae8ad40b | |||
| 25212b712e | |||
| 82e08a1a55 | |||
| cf0988fee6 | |||
| 9c0d1de484 | |||
| 4a7f0e47e5 | |||
| aea000514b | |||
| 4ffc4ba95a | |||
| 4171fab84a | |||
| ee1a639734 | |||
| ca347de911 | |||
| ebaf8ed2e5 | |||
| be17bf9020 | |||
| a47acb80f9 | |||
| 361a7752bf | |||
| 181b6922c4 | |||
| 773e150862 | |||
| 2c9983c12f | |||
| 2e7df9f691 | |||
| 59b6c6d579 | |||
| 25f62f43b0 | |||
| 07592ab0f0 | |||
| 2df5a4f23d | |||
| 91c1cfc279 | |||
| 90ebbfc190 | |||
| 112d2ba652 | |||
| 6f74678730 | |||
| 4d2ffdeeb8 | |||
| a534d7d2eb | |||
| e4ddd6d83a | |||
| 2c829c8abf | |||
| 3491d9b894 | |||
| 9f7f41a67b | |||
| 6799ad7694 | |||
| 929f8998a7 | |||
| c2db2d1a2a | |||
| e687055e0a | |||
| 6028a64a5b | |||
| ca3dc49c12 | |||
| b5a13a13f8 | |||
| 35e0098606 | |||
| 497d1fb9ba | |||
| bf6fbbae72 | |||
| c252f533e5 | |||
| 42b035604a | |||
| 7522f4f517 | |||
| 13eb9b7340 | |||
| dfb3ee776d | |||
| 6e755dd239 | |||
| f3f2540902 | |||
| 12a587c84c | |||
|
|
29e8ee715a | ||
| 10cd087c09 | |||
| cbd8856788 | |||
| 23f3ad3068 | |||
| 9388a3b3a9 | |||
| 574b54e4fa | |||
| 7335806122 | |||
| 056c00d103 | |||
| e2be26ba23 | |||
| c6ab941772 | |||
| 2bfc6e9d7c | |||
| 8f0b930d54 | |||
| a04dcd26c1 | |||
| 0ee4751ff2 | |||
| b1b36fe139 | |||
| 4073944270 | |||
| 5a1d206ea6 | |||
| fc7bed2e01 | |||
| cd03c3d834 | |||
| d4261c4fbe |
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="TaskProblemsInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
||||
5
.idea/php.xml
generated
5
.idea/php.xml
generated
@@ -1,5 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PhpDebugIgnoredPathsSettings">
|
||||
<skipped_paths>
|
||||
<skipped_path path="$PROJECT_DIR$/../REPO-IMAGES" />
|
||||
</skipped_paths>
|
||||
</component>
|
||||
<component name="PhpIncludePathManager">
|
||||
<include_path>
|
||||
<path value="$PROJECT_DIR$/public_html/vendor/athari/yalinqo" />
|
||||
|
||||
@@ -29,8 +29,11 @@ var _arr_aziende = [
|
||||
{n: "smetar"},
|
||||
{n: "suit", sub: ["santantonio", "carni_sardegna"]},
|
||||
{n: "tosca_ce"},
|
||||
{n: "tosca_mi"},
|
||||
{n: "tosca_rm"},
|
||||
{n: "tosca_rg"},
|
||||
{n: "twobrothers"},
|
||||
{n: "vgalimenti"},
|
||||
{n: "vgalimenti", sub:['salpar']},
|
||||
{n: "vinella"}
|
||||
];
|
||||
// </editor-fold >
|
||||
|
||||
8466
package-lock.json
generated
8466
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -15,23 +15,23 @@ include Controller::current_gestpath_include("ajax.php");
|
||||
<? include pvm_tagHead; ?>
|
||||
</head>
|
||||
<body>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if(!PVM\CurrentModule::isAuthorizedToCurrentUser()){
|
||||
include pvm_unauthorized;
|
||||
} else{
|
||||
if(isset($_GET["viewdoc"])){
|
||||
include Controller::current_gestpath_include("viewdoc.php");
|
||||
} else if(isset($_GET["viewchk"])){
|
||||
include Controller::current_gestpath_include("viewchks.php");
|
||||
} else{
|
||||
include Controller::current_gestpath_include("step1.php");
|
||||
}
|
||||
}?>
|
||||
</div>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if (!PVM\CurrentModule::isAuthorizedToCurrentUser()) {
|
||||
include pvm_unauthorized;
|
||||
} else {
|
||||
if (isset($_GET["viewdoc"])) {
|
||||
include Controller::current_gestpath_include("viewdoc.php");
|
||||
} else if (isset($_GET["viewchk"])) {
|
||||
include Controller::current_gestpath_include("viewchks.php");
|
||||
} else {
|
||||
include Controller::current_gestpath_include("step1.php");
|
||||
}
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -15,17 +15,17 @@ include Controller::current_gestpath_include("ajax.php");
|
||||
<? include pvm_tagHead; ?>
|
||||
</head>
|
||||
<body>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if(!PVM\CurrentModule::isAuthorizedToCurrentUser()){
|
||||
include pvm_unauthorized;
|
||||
} else{
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if (!PVM\CurrentModule::isAuthorizedToCurrentUser()) {
|
||||
include pvm_unauthorized;
|
||||
} else {
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -19,17 +19,17 @@ include Controller::current_gestpath_include("ajax.php");
|
||||
<? include pvm_tagHead; ?>
|
||||
</head>
|
||||
<body>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if(!PVM\CurrentModule::isAuthorizedToCurrentUser()){
|
||||
include pvm_unauthorized;
|
||||
} else{
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if (!PVM\CurrentModule::isAuthorizedToCurrentUser()) {
|
||||
include pvm_unauthorized;
|
||||
} else {
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -15,17 +15,17 @@ include Controller::current_gestpath_include("ajax.php");
|
||||
<? include pvm_tagHead; ?>
|
||||
</head>
|
||||
<body>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if(!PVM\CurrentModule::isAuthorizedToCurrentUser()){
|
||||
include pvm_unauthorized;
|
||||
} else{
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if (!PVM\CurrentModule::isAuthorizedToCurrentUser()) {
|
||||
include pvm_unauthorized;
|
||||
} else {
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -15,17 +15,17 @@ include Controller::current_gestpath_include("ajax.php");
|
||||
<? include pvm_tagHead; ?>
|
||||
</head>
|
||||
<body>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if(!PVM\CurrentModule::isAuthorizedToCurrentUser()){
|
||||
include pvm_unauthorized;
|
||||
} else{
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if (!PVM\CurrentModule::isAuthorizedToCurrentUser()) {
|
||||
include pvm_unauthorized;
|
||||
} else {
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -15,17 +15,17 @@ include Controller::current_gestpath_include("ajax.php");
|
||||
<? include pvm_tagHead; ?>
|
||||
</head>
|
||||
<body>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if(!PVM\CurrentModule::isAuthorizedToCurrentUser()){
|
||||
include pvm_unauthorized;
|
||||
} else{
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if (!PVM\CurrentModule::isAuthorizedToCurrentUser()) {
|
||||
include pvm_unauthorized;
|
||||
} else {
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -68,12 +68,15 @@
|
||||
"assets/datatables/js/dataTables.fixedHeader.min.js",
|
||||
"assets/datatables/js/dataTables.responsive.min.js",
|
||||
"assets/datatables/js/responsive.bootstrap.min.js",
|
||||
"assets/datatables/js/dataTables.scroller.min.js"
|
||||
"assets/datatables/js/dataTables.scroller.min.js",
|
||||
"assets/datatables/js/dataTables.buttons.min.js",
|
||||
"assets/datatables/js/buttons.bootstrap.min.js"
|
||||
],
|
||||
"css": [
|
||||
"assets/datatables/css/dataTables.bootstrap.css",
|
||||
"assets/datatables/css/fixedHeader.bootstrap.min.css",
|
||||
"assets/datatables/css/scroller.dataTables.min.css"
|
||||
"assets/datatables/css/scroller.dataTables.min.css",
|
||||
"assets/datatables/css/buttons.bootstrap.min.css"
|
||||
]
|
||||
},
|
||||
"bootstrap": {
|
||||
|
||||
1
public_html/assets/datatables/css/buttons.bootstrap.min.css
vendored
Normal file
1
public_html/assets/datatables/css/buttons.bootstrap.min.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
@keyframes dtb-spinner{100%{transform:rotate(360deg)}}@-o-keyframes dtb-spinner{100%{-o-transform:rotate(360deg);transform:rotate(360deg)}}@-ms-keyframes dtb-spinner{100%{-ms-transform:rotate(360deg);transform:rotate(360deg)}}@-webkit-keyframes dtb-spinner{100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@-moz-keyframes dtb-spinner{100%{-moz-transform:rotate(360deg);transform:rotate(360deg)}}div.dt-button-info{position:fixed;top:50%;left:50%;width:400px;margin-top:-100px;margin-left:-200px;background-color:white;border:2px solid #111;box-shadow:3px 3px 8px rgba(0, 0, 0, 0.3);border-radius:3px;text-align:center;z-index:21}div.dt-button-info h2{padding:.5em;margin:0;font-weight:normal;border-bottom:1px solid #ddd;background-color:#f3f3f3}div.dt-button-info>div{padding:1em}button.dtb-hide-drop{display:none !important}div.dt-button-collection-title{text-align:center;padding:.3em 0 .5em;font-size:.9em}div.dt-button-collection-title:empty{display:none}div.dt-button-collection{position:absolute;z-index:2001;width:100%}div.dt-button-collection ul.dropdown-menu{position:relative;display:block;z-index:2002;min-width:100%}div.dt-button-collection div.dt-button-collection-title{background-color:white}div.dt-button-collection div.dt-btn-split-wrapper{width:100%;display:inline-flex;padding-left:5px;padding-right:5px}div.dt-button-collection button.dt-btn-split-drop-button{width:100%;border:none;border-radius:0px;margin-left:0px !important}div.dt-button-collection button.dt-btn-split-drop-button:focus{border:none;border-radius:0px;outline:none}div.dt-button-collection.fixed{position:fixed;top:50%;left:50%;margin-left:-75px;border-radius:0}div.dt-button-collection.fixed.two-column{margin-left:-200px}div.dt-button-collection.fixed.three-column{margin-left:-225px}div.dt-button-collection.fixed.four-column{margin-left:-300px}div.dt-button-collection>:last-child{display:block !important;-webkit-column-gap:8px;-moz-column-gap:8px;-ms-column-gap:8px;-o-column-gap:8px;column-gap:8px}div.dt-button-collection>:last-child>*{-webkit-column-break-inside:avoid;break-inside:avoid}div.dt-button-collection.two-column{width:400px}div.dt-button-collection.two-column>:last-child{padding-bottom:1px;-webkit-column-count:2;-moz-column-count:2;-ms-column-count:2;-o-column-count:2;column-count:2}div.dt-button-collection.three-column{width:450px}div.dt-button-collection.three-column>:last-child{padding-bottom:1px;-webkit-column-count:3;-moz-column-count:3;-ms-column-count:3;-o-column-count:3;column-count:3}div.dt-button-collection.four-column{width:600px}div.dt-button-collection.four-column>:last-child{padding-bottom:1px;-webkit-column-count:4;-moz-column-count:4;-ms-column-count:4;-o-column-count:4;column-count:4}div.dt-button-collection .dt-button{border-radius:0}div.dt-button-background{position:fixed;top:0;left:0;width:100%;height:100%;z-index:2001}@media screen and (max-width: 767px){div.dt-buttons{float:none;width:100%;text-align:center;margin-bottom:.5em}div.dt-buttons a.btn{float:none}}div.dt-buttons button.btn.processing,div.dt-buttons div.btn.processing,div.dt-buttons a.btn.processing{color:rgba(0, 0, 0, 0.2)}div.dt-buttons button.btn.processing:after,div.dt-buttons div.btn.processing:after,div.dt-buttons a.btn.processing:after{position:absolute;top:50%;left:50%;width:16px;height:16px;margin:-8px 0 0 -8px;box-sizing:border-box;display:block;content:" ";border:2px solid #282828;border-radius:50%;border-left-color:transparent;border-right-color:transparent;animation:dtb-spinner 1500ms infinite linear;-o-animation:dtb-spinner 1500ms infinite linear;-ms-animation:dtb-spinner 1500ms infinite linear;-webkit-animation:dtb-spinner 1500ms infinite linear;-moz-animation:dtb-spinner 1500ms infinite linear}div.dt-btn-split-wrapper button.dt-btn-split-drop{border-top-right-radius:4px !important;border-bottom-right-radius:4px !important}span.dt-down-arrow{color:rgba(70, 70, 70, 0.9);font-size:10px;padding-left:10px}div.dataTables_wrapper div.dt-buttons.btn-group button.btn:last-of-type:first-of-type{border-radius:4px !important}
|
||||
7
public_html/assets/datatables/js/buttons.bootstrap.min.js
vendored
Normal file
7
public_html/assets/datatables/js/buttons.bootstrap.min.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
Bootstrap integration for DataTables' Buttons
|
||||
©2016 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
(function(c){"function"===typeof define&&define.amd?define(["jquery","datatables.net-bs","datatables.net-buttons"],function(a){return c(a,window,document)}):"object"===typeof exports?module.exports=function(a,b){a||(a=window);b&&b.fn.dataTable||(b=require("datatables.net-bs")(a,b).$);b.fn.dataTable.Buttons||require("datatables.net-buttons")(a,b);return c(b,a,a.document)}:c(jQuery,window,document)})(function(c,a,b,e){a=c.fn.dataTable;c.extend(!0,a.Buttons.defaults,{dom:{container:{className:"dt-buttons btn-group"},
|
||||
button:{className:"btn btn-default"},collection:{tag:"ul",className:"dropdown-menu",button:{tag:"li",className:"dt-button",active:"active",disabled:"disabled"},buttonLiner:{tag:"a",className:""}},splitWrapper:{tag:"div",className:"dt-btn-split-wrapper btn-group"},splitDropdown:{tag:"button",text:"▼",className:"btn btn-default dt-btn-split-drop dropdown-toggle",align:"split-left",splitAlignClass:"dt-button-split-left"},splitDropdownButton:{tag:"button",className:"dt-btn-split-drop-button btn btn-default"}}});
|
||||
a.ext.buttons.collection.text=function(d){return d.i18n("buttons.collection",'Collection <span class="caret"/>')};return a.Buttons});
|
||||
51
public_html/assets/datatables/js/dataTables.buttons.min.js
vendored
Normal file
51
public_html/assets/datatables/js/dataTables.buttons.min.js
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
/*!
|
||||
Buttons for DataTables 2.0.1
|
||||
©2016-2021 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
(function(e){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(C){return e(C,window,document)}):"object"===typeof exports?module.exports=function(C,y){C||(C=window);y&&y.fn.dataTable||(y=require("datatables.net")(C,y).$);return e(y,C,C.document)}:e(jQuery,window,document)})(function(e,C,y,p){function I(a,b,c){e.fn.animate?a.stop().fadeIn(b,c):(a.css("display","block"),c&&c.call(a))}function J(a,b,c){e.fn.animate?a.stop().fadeOut(b,c):(a.css("display","none"),c&&c.call(a))}
|
||||
function L(a,b){a=new u.Api(a);b=b?b:a.init().buttons||u.defaults.buttons;return(new v(a,b)).container()}var u=e.fn.dataTable,O=0,P=0,z=u.ext.buttons,v=function(a,b){if(!(this instanceof v))return function(c){return(new v(c,a)).container()};"undefined"===typeof b&&(b={});!0===b&&(b={});Array.isArray(b)&&(b={buttons:b});this.c=e.extend(!0,{},v.defaults,b);b.buttons&&(this.c.buttons=b.buttons);this.s={dt:new u.Api(a),buttons:[],listenKeys:"",namespace:"dtb"+O++};this.dom={container:e("<"+this.c.dom.container.tag+
|
||||
"/>").addClass(this.c.dom.container.className)};this._constructor()};e.extend(v.prototype,{action:function(a,b){a=this._nodeToButton(a);if(b===p)return a.conf.action;a.conf.action=b;return this},active:function(a,b){var c=this._nodeToButton(a);a=this.c.dom.button.active;c=e(c.node);if(b===p)return c.hasClass(a);c.toggleClass(a,b===p?!0:b);return this},add:function(a,b){var c=this.s.buttons;if("string"===typeof b){b=b.split("-");var d=this.s;c=0;for(var l=b.length-1;c<l;c++)d=d.buttons[1*b[c]];c=d.buttons;
|
||||
b=1*b[b.length-1]}this._expandButton(c,a,a!==p?a.split:p,(a===p||a.split===p||0===a.split.length)&&d!==p,!1,b);this._draw();return this},collectionRebuild:function(a,b){a=this._nodeToButton(a);if(b!==p){var c;for(c=a.buttons.length-1;0<=c;c--)this.remove(a.buttons[c].node);for(c=0;c<b.length;c++)this._expandButton(a.buttons,b[c],b[c]!==p&&b[c].config!==p&&b[c].config.split!==p,!0,b[c].parentConf!==p&&b[c].parentConf.split!==p,c,b[c].parentConf)}this._draw(a.collection,a.buttons)},container:function(){return this.dom.container},
|
||||
disable:function(a){a=this._nodeToButton(a);e(a.node).addClass(this.c.dom.button.disabled).attr("disabled",!0);return this},destroy:function(){e("body").off("keyup."+this.s.namespace);var a=this.s.buttons.slice(),b;var c=0;for(b=a.length;c<b;c++)this.remove(a[c].node);this.dom.container.remove();a=this.s.dt.settings()[0];c=0;for(b=a.length;c<b;c++)if(a.inst===this){a.splice(c,1);break}return this},enable:function(a,b){if(!1===b)return this.disable(a);a=this._nodeToButton(a);e(a.node).removeClass(this.c.dom.button.disabled).removeAttr("disabled");
|
||||
return this},name:function(){return this.c.name},node:function(a){if(!a)return this.dom.container;a=this._nodeToButton(a);return e(a.node)},processing:function(a,b){var c=this.s.dt,d=this._nodeToButton(a);if(b===p)return e(d.node).hasClass("processing");e(d.node).toggleClass("processing",b);e(c.table().node()).triggerHandler("buttons-processing.dt",[b,c.button(a),c,e(a),d.conf]);return this},remove:function(a){var b=this._nodeToButton(a),c=this._nodeToHost(a),d=this.s.dt;if(b.buttons.length)for(var l=
|
||||
b.buttons.length-1;0<=l;l--)this.remove(b.buttons[l].node);b.conf.destroying=!0;b.conf.destroy&&b.conf.destroy.call(d.button(a),d,e(a),b.conf);this._removeKey(b.conf);e(b.node).remove();a=e.inArray(b,c);c.splice(a,1);return this},text:function(a,b){var c=this._nodeToButton(a);a=this.c.dom.collection.buttonLiner;a=c.inCollection&&a&&a.tag?a.tag:this.c.dom.buttonLiner.tag;var d=this.s.dt,l=e(c.node),f=function(k){return"function"===typeof k?k(d,l,c.conf):k};if(b===p)return f(c.conf.text);c.conf.text=
|
||||
b;a?l.children(a).filter(":not(.dt-down-arrow)").html(f(b)):l.html(f(b));return this},_constructor:function(){var a=this,b=this.s.dt,c=b.settings()[0],d=this.c.buttons;c._buttons||(c._buttons=[]);c._buttons.push({inst:this,name:this.c.name});for(var l=0,f=d.length;l<f;l++)this.add(d[l]);b.on("destroy",function(k,h){h===c&&a.destroy()});e("body").on("keyup."+this.s.namespace,function(k){if(!y.activeElement||y.activeElement===y.body){var h=String.fromCharCode(k.keyCode).toLowerCase();-1!==a.s.listenKeys.toLowerCase().indexOf(h)&&
|
||||
a._keypress(h,k)}})},_addKey:function(a){a.key&&(this.s.listenKeys+=e.isPlainObject(a.key)?a.key.key:a.key)},_draw:function(a,b){a||(a=this.dom.container,b=this.s.buttons);a.children().detach();for(var c=0,d=b.length;c<d;c++)a.append(b[c].inserter),a.append(" "),b[c].buttons&&b[c].buttons.length&&this._draw(b[c].collection,b[c].buttons)},_expandButton:function(a,b,c,d,l,f,k){var h=this.s.dt,n=0,q=Array.isArray(b)?b:[b];b===p&&(q=Array.isArray(c)?c:[c]);c=0;for(var r=q.length;c<r;c++){var m=this._resolveExtends(q[c]);
|
||||
if(m)if(b=m.config!==p&&m.config.split?!0:!1,Array.isArray(m))this._expandButton(a,m,g!==p&&g.conf!==p?g.conf.split:p,d,k!==p&&k.split!==p,f,k);else{var g=this._buildButton(m,d,m.split!==p||m.config!==p&&m.config.split!==p,l);if(g){f!==p&&null!==f?(a.splice(f,0,g),f++):a.push(g);if(g.conf.buttons||g.conf.split){g.collection=e("<"+(b?this.c.dom.splitCollection.tag:this.c.dom.collection.tag)+"/>");g.conf._collection=g.collection;if(g.conf.split)for(var t=0;t<g.conf.split.length;t++)"object"===typeof g.conf.split[t]&&
|
||||
(g.conf.split[c].parent=k,g.conf.split[t].collectionLayout===p&&(g.conf.split[t].collectionLayout=g.conf.collectionLayout),g.conf.split[t].dropup===p&&(g.conf.split[t].dropup=g.conf.dropup),g.conf.split[t].fade===p&&(g.conf.split[t].fade=g.conf.fade));else e(g.node).append(e('<span class="dt-down-arrow">'+this.c.dom.splitDropdown.text+"</span>"));this._expandButton(g.buttons,g.conf.buttons,g.conf.split,!b,b,f,g.conf)}g.conf.parent=k;m.init&&m.init.call(h.button(g.node),h,e(g.node),m);n++}}}},_buildButton:function(a,
|
||||
b,c,d){var l=this.c.dom.button,f=this.c.dom.buttonLiner,k=this.c.dom.collection,h=this.c.dom.splitCollection,n=this.c.dom.splitDropdownButton,q=this.s.dt,r=function(w){return"function"===typeof w?w(q,m,a):w};!c&&d&&h?l=n:!c&&b&&k.button&&(l=k.button);!c&&d&&h.buttonLiner?f=h.buttonLiner:!c&&b&&k.buttonLiner&&(f=k.buttonLiner);if(a.available&&!a.available(q,a)&&!a.hasOwnProperty("html"))return!1;if(a.hasOwnProperty("html"))var m=e(a.html);else{var g=function(w,B,E,F){F.action.call(B.button(E),w,B,
|
||||
E,F);e(B.table().node()).triggerHandler("buttons-action.dt",[B.button(E),B,E,F])};k=a.tag||l.tag;var t=a.clickBlurs===p?!1:a.clickBlurs;m=e("<"+k+"/>").addClass(l.className).addClass(d?this.c.dom.splitDropdownButton.className:"").attr("tabindex",this.s.dt.settings()[0].iTabIndex).attr("aria-controls",this.s.dt.table().node().id).on("click.dtb",function(w){w.preventDefault();!m.hasClass(l.disabled)&&a.action&&g(w,q,m,a);t&&m.trigger("blur")}).on("keyup.dtb",function(w){13===w.keyCode&&!m.hasClass(l.disabled)&&
|
||||
a.action&&g(w,q,m,a)});"a"===k.toLowerCase()&&m.attr("href","#");"button"===k.toLowerCase()&&m.attr("type","button");f.tag?(k=e("<"+f.tag+"/>").html(r(a.text)).addClass(f.className),"a"===f.tag.toLowerCase()&&k.attr("href","#"),m.append(k)):m.html(r(a.text));!1===a.enabled&&m.addClass(l.disabled);a.className&&m.addClass(a.className);a.titleAttr&&m.attr("title",r(a.titleAttr));a.attr&&m.attr(a.attr);a.namespace||(a.namespace=".dt-button-"+P++);a.config!==p&&a.config.split&&(a.split=a.config.split)}f=
|
||||
(f=this.c.dom.buttonContainer)&&f.tag?e("<"+f.tag+"/>").addClass(f.className).append(m):m;this._addKey(a);this.c.buttonCreated&&(f=this.c.buttonCreated(a,f));if(c){var x=e("<div/>").addClass(this.c.dom.splitWrapper.className);x.append(m);var A=e.extend(a,{text:this.c.dom.splitDropdown.text,className:this.c.dom.splitDropdown.className,attr:{"aria-haspopup":!0,"aria-expanded":!1},align:this.c.dom.splitDropdown.align,splitAlignClass:this.c.dom.splitDropdown.splitAlignClass});this._addKey(A);var G=function(w,
|
||||
B,E,F){z.split.action.call(B.button(e("div.dt-btn-split-wrapper")[0]),w,B,E,F);e(B.table().node()).triggerHandler("buttons-action.dt",[B.button(E),B,E,F]);E.attr("aria-expanded",!0)},D=e('<button class="'+this.c.dom.splitDropdown.className+' dt-button"><span class="dt-btn-split-drop-arrow">'+this.c.dom.splitDropdown.text+"</span></button>").on("click.dtb",function(w){w.preventDefault();w.stopPropagation();!D.hasClass(l.disabled)&&A.action&&G(w,q,D,A);t&&D.trigger("blur")}).on("keyup.dtb",function(w){13===
|
||||
w.keyCode&&!D.hasClass(l.disabled)&&A.action&&G(w,q,D,A)});0===a.split.length&&D.addClass("dtb-hide-drop");x.append(D).attr(A.attr)}return{conf:a,node:c?x.get(0):m.get(0),inserter:c?x:f,buttons:[],inCollection:b,isSplit:c,inSplit:d,collection:null}},_nodeToButton:function(a,b){b||(b=this.s.buttons);for(var c=0,d=b.length;c<d;c++){if(b[c].node===a)return b[c];if(b[c].buttons.length){var l=this._nodeToButton(a,b[c].buttons);if(l)return l}}},_nodeToHost:function(a,b){b||(b=this.s.buttons);for(var c=
|
||||
0,d=b.length;c<d;c++){if(b[c].node===a)return b;if(b[c].buttons.length){var l=this._nodeToHost(a,b[c].buttons);if(l)return l}}},_keypress:function(a,b){if(!b._buttonsHandled){var c=function(d){for(var l=0,f=d.length;l<f;l++){var k=d[l].conf,h=d[l].node;k.key&&(k.key===a?(b._buttonsHandled=!0,e(h).click()):!e.isPlainObject(k.key)||k.key.key!==a||k.key.shiftKey&&!b.shiftKey||k.key.altKey&&!b.altKey||k.key.ctrlKey&&!b.ctrlKey||k.key.metaKey&&!b.metaKey||(b._buttonsHandled=!0,e(h).click()));d[l].buttons.length&&
|
||||
c(d[l].buttons)}};c(this.s.buttons)}},_removeKey:function(a){if(a.key){var b=e.isPlainObject(a.key)?a.key.key:a.key;a=this.s.listenKeys.split("");b=e.inArray(b,a);a.splice(b,1);this.s.listenKeys=a.join("")}},_resolveExtends:function(a){var b=this.s.dt,c,d=function(h){for(var n=0;!e.isPlainObject(h)&&!Array.isArray(h);){if(h===p)return;if("function"===typeof h){if(h=h(b,a),!h)return!1}else if("string"===typeof h){if(!z[h])return{html:h};h=z[h]}n++;if(30<n)throw"Buttons: Too many iterations";}return Array.isArray(h)?
|
||||
h:e.extend({},h)};for(a=d(a);a&&a.extend;){if(!z[a.extend])throw"Cannot extend unknown button type: "+a.extend;var l=d(z[a.extend]);if(Array.isArray(l))return l;if(!l)return!1;var f=l.className;a.config!==p&&l.config!==p&&(a.config=e.extend({},l.config,a.config));a=e.extend({},l,a);f&&a.className!==f&&(a.className=f+" "+a.className);var k=a.postfixButtons;if(k){a.buttons||(a.buttons=[]);f=0;for(c=k.length;f<c;f++)a.buttons.push(k[f]);a.postfixButtons=null}if(k=a.prefixButtons){a.buttons||(a.buttons=
|
||||
[]);f=0;for(c=k.length;f<c;f++)a.buttons.splice(f,0,k[f]);a.prefixButtons=null}a.extend=l.extend}return a},_popover:function(a,b,c,d){d=this.c;var l=!1,f=e.extend({align:"button-left",autoClose:!1,background:!0,backgroundClassName:"dt-button-background",contentClassName:d.dom.collection.className,collectionLayout:"",collectionTitle:"",dropup:!1,fade:400,popoverTitle:"",rightAlignClassName:"dt-button-right",splitRightAlignClassName:"dt-button-split-right",splitLeftAlignClassName:"dt-button-split-left",
|
||||
tag:d.dom.collection.tag},c),k=b.node(),h=function(){l=!0;J(e(".dt-button-collection"),f.fade,function(){e(this).detach()});e(b.buttons('[aria-haspopup="true"][aria-expanded="true"]').nodes()).attr("aria-expanded","false");e("div.dt-button-background").off("click.dtb-collection");v.background(!1,f.backgroundClassName,f.fade,k);e("body").off(".dtb-collection");b.off("buttons-action.b-internal");b.off("destroy")};!1===a&&h();c=e(b.buttons('[aria-haspopup="true"][aria-expanded="true"]').nodes());c.length&&
|
||||
(k=c.eq(0),h());c=e("<div/>").addClass("dt-button-collection").addClass(f.collectionLayout).addClass(f.splitAlignClass).css("display","none");a=e(a).addClass(f.contentClassName).attr("role","menu").appendTo(c);k.attr("aria-expanded","true");k.parents("body")[0]!==y.body&&(k=y.body.lastChild);f.popoverTitle?c.prepend('<div class="dt-button-collection-title">'+f.popoverTitle+"</div>"):f.collectionTitle&&c.prepend('<div class="dt-button-collection-title">'+f.collectionTitle+"</div>");I(c.insertAfter(k),
|
||||
f.fade);var n=e(b.table().container());d=c.css("position");"dt-container"===f.align&&(k=k.parent(),c.css("width",n.width()));if("absolute"===d){var q=k.position();d=e(b.node()).position();c.css({top:e(e(b[0].node).parent()[0]).hasClass("dt-buttons")?d.top+k.outerHeight():q.top+k.outerHeight(),left:q.left});q=c.outerHeight();var r=n.offset().top+n.height();r=d.top+k.outerHeight()+q-r;var m=d.top-q,g=n.offset().top;d=d.top-q-5;(r>g-m||f.dropup)&&-d<g&&c.css("top",d);d=n.offset().left;n=n.width();n=
|
||||
d+n;q=c.offset().left;r=c.outerWidth();0===r&&0<c.children().length&&(r=e(c.children()[0]).outerWidth());r=q+r;var t=k.offset().left;g=k.outerWidth();m=t+g;if(c.hasClass(f.rightAlignClassName)||c.hasClass(f.leftAlignClassName)||c.hasClass(f.splitAlignClass)||"dt-container"===f.align){var x=m;k.hasClass("dt-btn-split-wrapper")&&0<k.children("button.dt-btn-split-drop").length&&(t=k.children("button.dt-btn-split-drop").offset().left,g=k.children("button.dt-btn-split-drop").outerWidth(),x=t+g);g=0;if(c.hasClass(f.rightAlignClassName))g=
|
||||
m-r,d>q+g&&(d-=q+g,n-=r+g,g=d>n?g+n:g+d);else if(c.hasClass(f.splitRightAlignClassName))g=x-r,d>q+g&&(d-=q+g,n-=r+g,g=d>n?g+n:g+d);else if(c.hasClass(f.splitLeftAlignClassName)){if(g=t-q,n<r+g||d>q+g)d-=q+g,n-=r+g,g=d>n?g+n:g+d}else g=d-q,n<r+g&&(d-=q+g,n-=r+g,g=d>n?g+n:g+d)}else d=k.offset().top,g=0,g="button-right"===f.align?m-r:t-q;c.css("left",c.position().left+g)}else d=c.height()/2,d>e(C).height()/2&&(d=e(C).height()/2),c.css("marginTop",-1*d);f.background&&v.background(!0,f.backgroundClassName,
|
||||
f.fade,k);e("div.dt-button-background").on("click.dtb-collection",function(){});f.autoClose&&setTimeout(function(){b.on("buttons-action.b-internal",function(A,G,D,w){w[0]!==k[0]&&h()})},0);e(c).trigger("buttons-popover.dt");b.on("destroy",h);setTimeout(function(){l=!1;e("body").on("click.dtb-collection",function(A){if(!l){var G=e.fn.addBack?"addBack":"andSelf",D=e(A.target).parent()[0];(!e(A.target).parents()[G]().filter(a).length&&!e(D).hasClass("dt-buttons")||e(A.target).hasClass("dt-button-background"))&&
|
||||
h()}}).on("keyup.dtb-collection",function(A){27===A.keyCode&&h()})},0)}});v.background=function(a,b,c,d){c===p&&(c=400);d||(d=y.body);a?I(e("<div/>").addClass(b).css("display","none").insertAfter(d),c):J(e("div."+b),c,function(){e(this).removeClass(b).remove()})};v.instanceSelector=function(a,b){if(a===p||null===a)return e.map(b,function(f){return f.inst});var c=[],d=e.map(b,function(f){return f.name}),l=function(f){if(Array.isArray(f))for(var k=0,h=f.length;k<h;k++)l(f[k]);else"string"===typeof f?
|
||||
-1!==f.indexOf(",")?l(f.split(",")):(f=e.inArray(f.trim(),d),-1!==f&&c.push(b[f].inst)):"number"===typeof f&&c.push(b[f].inst)};l(a);return c};v.buttonSelector=function(a,b){for(var c=[],d=function(h,n,q){for(var r,m,g=0,t=n.length;g<t;g++)if(r=n[g])m=q!==p?q+g:g+"",h.push({node:r.node,name:r.conf.name,idx:m}),r.buttons&&d(h,r.buttons,m+"-")},l=function(h,n){var q,r=[];d(r,n.s.buttons);var m=e.map(r,function(g){return g.node});if(Array.isArray(h)||h instanceof e)for(m=0,q=h.length;m<q;m++)l(h[m],
|
||||
n);else if(null===h||h===p||"*"===h)for(m=0,q=r.length;m<q;m++)c.push({inst:n,node:r[m].node});else if("number"===typeof h)c.push({inst:n,node:n.s.buttons[h].node});else if("string"===typeof h)if(-1!==h.indexOf(","))for(r=h.split(","),m=0,q=r.length;m<q;m++)l(r[m].trim(),n);else if(h.match(/^\d+(\-\d+)*$/))m=e.map(r,function(g){return g.idx}),c.push({inst:n,node:r[e.inArray(h,m)].node});else if(-1!==h.indexOf(":name"))for(h=h.replace(":name",""),m=0,q=r.length;m<q;m++)r[m].name===h&&c.push({inst:n,
|
||||
node:r[m].node});else e(m).filter(h).each(function(){c.push({inst:n,node:this})});else"object"===typeof h&&h.nodeName&&(r=e.inArray(h,m),-1!==r&&c.push({inst:n,node:m[r]}))},f=0,k=a.length;f<k;f++)l(b,a[f]);return c};v.stripData=function(a,b){if("string"!==typeof a)return a;a=a.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"");a=a.replace(/<!\-\-.*?\-\->/g,"");if(!b||b.stripHtml)a=a.replace(/<[^>]*>/g,"");if(!b||b.trim)a=a.replace(/^\s+|\s+$/g,"");if(!b||b.stripNewlines)a=a.replace(/\n/g,
|
||||
" ");if(!b||b.decodeEntities)M.innerHTML=a,a=M.value;return a};v.defaults={buttons:["copy","excel","csv","pdf","print"],name:"main",tabIndex:0,dom:{container:{tag:"div",className:"dt-buttons"},collection:{tag:"div",className:""},button:{tag:"button",className:"dt-button",active:"active",disabled:"disabled"},buttonLiner:{tag:"span",className:""},split:{tag:"div",className:"dt-button-split"},splitWrapper:{tag:"div",className:"dt-btn-split-wrapper"},splitDropdown:{tag:"button",text:"▼",className:"dt-btn-split-drop",
|
||||
align:"split-right",splitAlignClass:"dt-button-split-left"},splitDropdownButton:{tag:"button",className:"dt-btn-split-drop-button dt-button"},splitCollection:{tag:"div",className:"dt-button-split-collection"}}};v.version="2.0.1";e.extend(z,{collection:{text:function(a){return a.i18n("buttons.collection","Collection")},className:"buttons-collection",init:function(a,b,c){b.attr("aria-expanded",!1)},action:function(a,b,c,d){d._collection.parents("body").length?this.popover(!1,d):this.popover(d._collection,
|
||||
d)},attr:{"aria-haspopup":!0}},split:{text:function(a){return a.i18n("buttons.split","Split")},className:"buttons-split",init:function(a,b,c){return b.attr("aria-expanded",!1)},action:function(a,b,c,d){this.popover(d._collection,d)},attr:{"aria-haspopup":!0}},copy:function(a,b){if(z.copyHtml5)return"copyHtml5"},csv:function(a,b){if(z.csvHtml5&&z.csvHtml5.available(a,b))return"csvHtml5"},excel:function(a,b){if(z.excelHtml5&&z.excelHtml5.available(a,b))return"excelHtml5"},pdf:function(a,b){if(z.pdfHtml5&&
|
||||
z.pdfHtml5.available(a,b))return"pdfHtml5"},pageLength:function(a){a=a.settings()[0].aLengthMenu;var b=[],c=[];if(Array.isArray(a[0]))b=a[0],c=a[1];else for(var d=0;d<a.length;d++){var l=a[d];e.isPlainObject(l)?(b.push(l.value),c.push(l.label)):(b.push(l),c.push(l))}return{extend:"collection",text:function(f){return f.i18n("buttons.pageLength",{"-1":"Show all rows",_:"Show %d rows"},f.page.len())},className:"buttons-page-length",autoClose:!0,buttons:e.map(b,function(f,k){return{text:c[k],className:"button-page-length",
|
||||
action:function(h,n){n.page.len(f).draw()},init:function(h,n,q){var r=this;n=function(){r.active(h.page.len()===f)};h.on("length.dt"+q.namespace,n);n()},destroy:function(h,n,q){h.off("length.dt"+q.namespace)}}}),init:function(f,k,h){var n=this;f.on("length.dt"+h.namespace,function(){n.text(h.text)})},destroy:function(f,k,h){f.off("length.dt"+h.namespace)}}}});u.Api.register("buttons()",function(a,b){b===p&&(b=a,a=p);this.selector.buttonGroup=a;var c=this.iterator(!0,"table",function(d){if(d._buttons)return v.buttonSelector(v.instanceSelector(a,
|
||||
d._buttons),b)},!0);c._groupSelector=a;return c});u.Api.register("button()",function(a,b){a=this.buttons(a,b);1<a.length&&a.splice(1,a.length);return a});u.Api.registerPlural("buttons().active()","button().active()",function(a){return a===p?this.map(function(b){return b.inst.active(b.node)}):this.each(function(b){b.inst.active(b.node,a)})});u.Api.registerPlural("buttons().action()","button().action()",function(a){return a===p?this.map(function(b){return b.inst.action(b.node)}):this.each(function(b){b.inst.action(b.node,
|
||||
a)})});u.Api.registerPlural("buttons().collectionRebuild()","button().collectionRebuild()",function(a){return this.each(function(b){for(var c=0;c<a.length;c++)"object"===typeof a[c]&&(a[c].parentConf=b);b.inst.collectionRebuild(b.node,a)})});u.Api.register(["buttons().enable()","button().enable()"],function(a){return this.each(function(b){b.inst.enable(b.node,a)})});u.Api.register(["buttons().disable()","button().disable()"],function(){return this.each(function(a){a.inst.disable(a.node)})});u.Api.registerPlural("buttons().nodes()",
|
||||
"button().node()",function(){var a=e();e(this.each(function(b){a=a.add(b.inst.node(b.node))}));return a});u.Api.registerPlural("buttons().processing()","button().processing()",function(a){return a===p?this.map(function(b){return b.inst.processing(b.node)}):this.each(function(b){b.inst.processing(b.node,a)})});u.Api.registerPlural("buttons().text()","button().text()",function(a){return a===p?this.map(function(b){return b.inst.text(b.node)}):this.each(function(b){b.inst.text(b.node,a)})});u.Api.registerPlural("buttons().trigger()",
|
||||
"button().trigger()",function(){return this.each(function(a){a.inst.node(a.node).trigger("click")})});u.Api.register("button().popover()",function(a,b){return this.map(function(c){return c.inst._popover(a,this.button(this[0].node),b)})});u.Api.register("buttons().containers()",function(){var a=e(),b=this._groupSelector;this.iterator(!0,"table",function(c){if(c._buttons){c=v.instanceSelector(b,c._buttons);for(var d=0,l=c.length;d<l;d++)a=a.add(c[d].container())}});return a});u.Api.register("buttons().container()",
|
||||
function(){return this.containers().eq(0)});u.Api.register("button().add()",function(a,b){var c=this.context;c.length&&(c=v.instanceSelector(this._groupSelector,c[0]._buttons),c.length&&c[0].add(b,a));return this.button(this._groupSelector,a)});u.Api.register("buttons().destroy()",function(){this.pluck("inst").unique().each(function(a){a.destroy()});return this});u.Api.registerPlural("buttons().remove()","buttons().remove()",function(){this.each(function(a){a.inst.remove(a.node)});return this});var H;
|
||||
u.Api.register("buttons.info()",function(a,b,c){var d=this;if(!1===a)return this.off("destroy.btn-info"),J(e("#datatables_buttons_info"),400,function(){e(this).remove()}),clearTimeout(H),H=null,this;H&&clearTimeout(H);e("#datatables_buttons_info").length&&e("#datatables_buttons_info").remove();a=a?"<h2>"+a+"</h2>":"";I(e('<div id="datatables_buttons_info" class="dt-button-info"/>').html(a).append(e("<div/>")["string"===typeof b?"html":"append"](b)).css("display","none").appendTo("body"));c!==p&&0!==
|
||||
c&&(H=setTimeout(function(){d.buttons.info(!1)},c));this.on("destroy.btn-info",function(){d.buttons.info(!1)});return this});u.Api.register("buttons.exportData()",function(a){if(this.context.length)return Q(new u.Api(this.context[0]),a)});u.Api.register("buttons.exportInfo()",function(a){a||(a={});var b=a;var c="*"===b.filename&&"*"!==b.title&&b.title!==p&&null!==b.title&&""!==b.title?b.title:b.filename;"function"===typeof c&&(c=c());c===p||null===c?c=null:(-1!==c.indexOf("*")&&(c=c.replace("*",e("head > title").text()).trim()),
|
||||
c=c.replace(/[^a-zA-Z0-9_\u00A1-\uFFFF\.,\-_ !\(\)]/g,""),(b=K(b.extension))||(b=""),c+=b);b=K(a.title);b=null===b?null:-1!==b.indexOf("*")?b.replace("*",e("head > title").text()||"Exported data"):b;return{filename:c,title:b,messageTop:N(this,a.message||a.messageTop,"top"),messageBottom:N(this,a.messageBottom,"bottom")}});var K=function(a){return null===a||a===p?null:"function"===typeof a?a():a},N=function(a,b,c){b=K(b);if(null===b)return null;a=e("caption",a.table().container()).eq(0);return"*"===
|
||||
b?a.css("caption-side")!==c?null:a.length?a.text():"":b},M=e("<textarea/>")[0],Q=function(a,b){var c=e.extend(!0,{},{rows:null,columns:"",modifier:{search:"applied",order:"applied"},orthogonal:"display",stripHtml:!0,stripNewlines:!0,decodeEntities:!0,trim:!0,format:{header:function(t){return v.stripData(t,c)},footer:function(t){return v.stripData(t,c)},body:function(t){return v.stripData(t,c)}},customizeData:null},b);b=a.columns(c.columns).indexes().map(function(t){var x=a.column(t).header();return c.format.header(x.innerHTML,
|
||||
t,x)}).toArray();var d=a.table().footer()?a.columns(c.columns).indexes().map(function(t){var x=a.column(t).footer();return c.format.footer(x?x.innerHTML:"",t,x)}).toArray():null,l=e.extend({},c.modifier);a.select&&"function"===typeof a.select.info&&l.selected===p&&a.rows(c.rows,e.extend({selected:!0},l)).any()&&e.extend(l,{selected:!0});l=a.rows(c.rows,l).indexes().toArray();var f=a.cells(l,c.columns);l=f.render(c.orthogonal).toArray();f=f.nodes().toArray();for(var k=b.length,h=[],n=0,q=0,r=0<k?l.length/
|
||||
k:0;q<r;q++){for(var m=[k],g=0;g<k;g++)m[g]=c.format.body(l[n],q,g,f[n]),n++;h[q]=m}b={header:b,footer:d,body:h};c.customizeData&&c.customizeData(b);return b};e.fn.dataTable.Buttons=v;e.fn.DataTable.Buttons=v;e(y).on("init.dt plugin-init.dt",function(a,b){"dt"===a.namespace&&(a=b.oInit.buttons||u.defaults.buttons)&&!b._buttons&&(new v(b,a)).container()});u.ext.feature.push({fnInit:L,cFeature:"B"});u.ext.features&&u.ext.features.register("buttons",L);return v});
|
||||
31
public_html/associazione_report.php
Normal file
31
public_html/associazione_report.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?
|
||||
session_start();
|
||||
include "functions.php";
|
||||
require_once "include_login.php";
|
||||
include "config.php";
|
||||
include "include/module.php";
|
||||
|
||||
include Controller::current_mainClasspath();
|
||||
include Controller::current_gestpath_include("ajax.php");
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<!--html manifest="manifest.appcache"-->
|
||||
<html>
|
||||
<head>
|
||||
<? include pvm_tagHead; ?>
|
||||
</head>
|
||||
<body>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if (!PVM\CurrentModule::isAuthorizedToCurrentUser()) {
|
||||
include pvm_unauthorized;
|
||||
} else {
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -15,17 +15,17 @@ include Controller::current_gestpath_include("ajax.php");
|
||||
<? include pvm_tagHead; ?>
|
||||
</head>
|
||||
<body>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if(!PVM\CurrentModule::isAuthorizedToCurrentUser()){
|
||||
include pvm_unauthorized;
|
||||
} else{
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if (!PVM\CurrentModule::isAuthorizedToCurrentUser()) {
|
||||
include pvm_unauthorized;
|
||||
} else {
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -15,17 +15,17 @@ include Controller::current_gestpath_include("ajax.php");
|
||||
<? include pvm_tagHead; ?>
|
||||
</head>
|
||||
<body>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if(!PVM\CurrentModule::isAuthorizedToCurrentUser()){
|
||||
include pvm_unauthorized;
|
||||
} else{
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if (!PVM\CurrentModule::isAuthorizedToCurrentUser()) {
|
||||
include pvm_unauthorized;
|
||||
} else {
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -15,17 +15,17 @@ include Controller::current_gestpath_include("ajax.php");
|
||||
<? include pvm_tagHead; ?>
|
||||
</head>
|
||||
<body>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if(!PVM\CurrentModule::isAuthorizedToCurrentUser()){
|
||||
include pvm_unauthorized;
|
||||
} else{
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if (!PVM\CurrentModule::isAuthorizedToCurrentUser()) {
|
||||
include pvm_unauthorized;
|
||||
} else {
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -15,17 +15,17 @@ include Controller::current_gestpath_include("ajax.php");
|
||||
<? include pvm_tagHead; ?>
|
||||
</head>
|
||||
<body>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if(!PVM\CurrentModule::isAuthorizedToCurrentUser()){
|
||||
include pvm_unauthorized;
|
||||
} else{
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if (!PVM\CurrentModule::isAuthorizedToCurrentUser()) {
|
||||
include pvm_unauthorized;
|
||||
} else {
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -15,17 +15,17 @@ include Controller::current_gestpath_include("ajax.php");
|
||||
<? include pvm_tagHead; ?>
|
||||
</head>
|
||||
<body>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if(!PVM\CurrentModule::isAuthorizedToCurrentUser()){
|
||||
include pvm_unauthorized;
|
||||
} else{
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_headerNavbar; ?>
|
||||
<div id="content">
|
||||
<div><?
|
||||
include pvm_navTab;
|
||||
if (!PVM\CurrentModule::isAuthorizedToCurrentUser()) {
|
||||
include pvm_unauthorized;
|
||||
} else {
|
||||
include Controller::current_gestpath_mainPage();
|
||||
} ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</div>
|
||||
<? include pvm_footerMinimal; ?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,82 +1,83 @@
|
||||
<?php
|
||||
class Azienda{
|
||||
|
||||
class Azienda {
|
||||
private static $datiAzienda = null;
|
||||
|
||||
private static function getDatiAzienda(){
|
||||
if(is_null(self::$datiAzienda)){
|
||||
|
||||
private static function getDatiAzienda() {
|
||||
if (is_null(self::$datiAzienda)) {
|
||||
$Query = new Query;
|
||||
$Query->select("nome_ditta AS nome_azienda", "indirizzo", "cap", "citta", "prov", "e_mail")->from("azienda");
|
||||
$Ret = $Query->firstRow()->toRet()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
self::$datiAzienda = $Ret->get_data();
|
||||
}
|
||||
}
|
||||
return self::$datiAzienda;
|
||||
}
|
||||
|
||||
private static function getKeyValue($key){
|
||||
|
||||
private static function getKeyValue($key) {
|
||||
$datiAzienda = self::getDatiAzienda();
|
||||
if(!is_null($datiAzienda) && array_key_exists($key, $datiAzienda)){
|
||||
if (!is_null($datiAzienda) && array_key_exists($key, $datiAzienda)) {
|
||||
return $datiAzienda[$key];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getNomeAzienda(){
|
||||
|
||||
public static function getNomeAzienda() {
|
||||
return self::getKeyValue("nome_azienda");
|
||||
}
|
||||
|
||||
public static function getIndirizzo(){
|
||||
|
||||
public static function getIndirizzo() {
|
||||
return self::getKeyValue("indirizzo");
|
||||
}
|
||||
|
||||
public static function getCitta(){
|
||||
|
||||
public static function getCitta() {
|
||||
return self::getKeyValue("citta");
|
||||
}
|
||||
|
||||
public static function getProv(){
|
||||
|
||||
public static function getProv() {
|
||||
return self::getKeyValue("prov");
|
||||
}
|
||||
|
||||
public static function getEmail(){
|
||||
|
||||
public static function getEmail() {
|
||||
return self::getKeyValue("e_mail");
|
||||
}
|
||||
|
||||
public static function getLatLng(){
|
||||
|
||||
public static function getLatLng() {
|
||||
$datiAzienda = self::getDatiAzienda();
|
||||
$location = Utility\Str::format_indirizzoCompleto($datiAzienda);
|
||||
$Ret = \Utility\Geo::rawAddressToLatLng($location);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
if(isset($retData["lat"]) && isset($retData["lng"])){
|
||||
if (isset($retData["lat"]) && isset($retData["lng"])) {
|
||||
return $retData;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getProfileDb(){
|
||||
|
||||
public static function getProfileDb() {
|
||||
return \User::get_current_profileDb();
|
||||
}
|
||||
|
||||
public static function getId(){
|
||||
|
||||
public static function getId() {
|
||||
return \Config::get_azienda();
|
||||
}
|
||||
|
||||
public static function getLogo(){
|
||||
|
||||
public static function getLogo() {
|
||||
return \AziendaUtils::getLogo(self::getProfileDb());
|
||||
}
|
||||
|
||||
public static function getPathHome($fileName = ""){
|
||||
|
||||
public static function getPathHome($fileName = "") {
|
||||
return AziendaUtils::getPathHome(Config::get_azienda(), $fileName);
|
||||
}
|
||||
|
||||
public static function getPathHomeCurrentModulo($fileName = ""){
|
||||
|
||||
public static function getPathHomeCurrentModulo($fileName = "") {
|
||||
$moduloName = \Controller::current_module();
|
||||
return self::getPathHome().$moduloName."/".$fileName;
|
||||
return self::getPathHome() . $moduloName . "/" . $fileName;
|
||||
}
|
||||
|
||||
public static function hasModulo($idModulo){
|
||||
|
||||
public static function hasModulo($idModulo) {
|
||||
return !is_null(AziendaUtils::getModulo($idModulo));
|
||||
}
|
||||
}
|
||||
@@ -1,71 +1,74 @@
|
||||
<?php
|
||||
class AziendaUtils{
|
||||
|
||||
public static function getLogo($profileDB){
|
||||
|
||||
class AziendaUtils {
|
||||
|
||||
public static function getLogo($profileDB) {
|
||||
$logoAziendaConfig = Config::get_logoAzienda($profileDB);
|
||||
$aziendaMain = Config::get_azienda($profileDB);
|
||||
if(is_null($logoAziendaConfig)){
|
||||
if (is_null($logoAziendaConfig)) {
|
||||
$profileDB = Config::get_azienda();
|
||||
}
|
||||
$azienda = $profileDB;
|
||||
$fileName = if_null(Config::get_logoAzienda($azienda), "logo_azienda.png");
|
||||
$filePath = str_replace(DIRECTORY_SEPARATOR, "/", self::getPathHome($aziendaMain, "images")."/".$fileName);
|
||||
return file_exists($filePath) ? $filePath: null;
|
||||
$filePath = str_replace(DIRECTORY_SEPARATOR, "/", self::getPathHome($aziendaMain, "images") . "/" . $fileName);
|
||||
return file_exists($filePath) ? $filePath : null;
|
||||
}
|
||||
|
||||
public static function getPathHome($azienda, $fileName = ""){
|
||||
|
||||
public static function getPathHome($azienda, $fileName = "") {
|
||||
$azienda = is_null($azienda) ? Config::get_azienda() : $azienda;
|
||||
return "config_aziende".DIRECTORY_SEPARATOR.strtoupper($azienda).DIRECTORY_SEPARATOR.$fileName;
|
||||
return "config_aziende" . DIRECTORY_SEPARATOR . strtoupper($azienda) . DIRECTORY_SEPARATOR . $fileName;
|
||||
}
|
||||
|
||||
public static function getModuli($azienda = null){// echopre(debug_backtrace());
|
||||
|
||||
public static function getModuli($azienda = null) {// echopre(debug_backtrace());
|
||||
$arr_moduliAzienda = self::getModuliFromConfig($azienda);
|
||||
$arr_moduliStandard = PVM\ModuloUtils::getModuliStandard();
|
||||
foreach($arr_moduliStandard as $moduloStandard){ // evito il ripetersi di eventuali gestioni gia definite
|
||||
foreach ($arr_moduliStandard as $moduloStandard) { // evito il ripetersi di eventuali gestioni gia definite
|
||||
$idModulo = $moduloStandard["name"];
|
||||
$result = from($arr_moduliAzienda)->where(function($x) use($idModulo){ return $x["name"] == $idModulo;})->count();
|
||||
if($result==0){
|
||||
$result = from($arr_moduliAzienda)->where(function ($x) use ($idModulo) {
|
||||
return $x["name"] == $idModulo;
|
||||
})->count();
|
||||
if ($result == 0) {
|
||||
$arr_moduliAzienda[] = $moduloStandard;
|
||||
}
|
||||
}
|
||||
return $arr_moduliAzienda;
|
||||
}
|
||||
|
||||
public static function getModulo($idModulo, $azienda = null){
|
||||
|
||||
public static function getModulo($idModulo, $azienda = null) {
|
||||
$arr_moduli = self::getModuli($azienda);
|
||||
foreach($arr_moduli as $modulo){
|
||||
if($modulo["name"]===$idModulo){
|
||||
foreach ($arr_moduli as $modulo) {
|
||||
if ($modulo["name"] === $idModulo) {
|
||||
return $modulo;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getIdModuliFromConfig($azienda = null){
|
||||
|
||||
public static function getIdModuliFromConfig($azienda = null) {
|
||||
return array_column(self::getModuliFromConfig($azienda), "name");
|
||||
}
|
||||
|
||||
public static function getModuliFromConfig($azienda = null){
|
||||
|
||||
public static function getModuliFromConfig($azienda = null) {
|
||||
$azienda = is_null($azienda) ? Config::get_azienda() : $azienda;
|
||||
if(!is_null($azienda)){
|
||||
if (!is_null($azienda)) {
|
||||
$idx = "moduliAzienda{$azienda}";
|
||||
|
||||
if(!isset($GLOBALS[$idx])){
|
||||
|
||||
if (!isset($GLOBALS[$idx])) {
|
||||
$ret = array();
|
||||
$moduleConfigFileAzienda = AziendaUtils::getPathHome($azienda, "gestioni.json");
|
||||
if(file_exists($moduleConfigFileAzienda)){
|
||||
if (file_exists($moduleConfigFileAzienda)) {
|
||||
$ret = json_decode(file_get_contents($moduleConfigFileAzienda), true);
|
||||
}
|
||||
|
||||
|
||||
//$ret[] = array("name" => "messenger", "group" => "NULL");
|
||||
|
||||
|
||||
|
||||
|
||||
$GLOBALS[$idx] = $ret;
|
||||
}
|
||||
|
||||
|
||||
return $GLOBALS[$idx];
|
||||
}
|
||||
|
||||
|
||||
return array();
|
||||
}
|
||||
/*
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace BC;
|
||||
class Alert{
|
||||
class Alert {
|
||||
private $id = null;
|
||||
private $text = null;
|
||||
private $title = null;
|
||||
@@ -12,155 +13,162 @@ class Alert{
|
||||
private $columns = null; // 12
|
||||
private $offsetColumns = null; // 0
|
||||
private $size = null;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
$this->info()->closeBtn(false);
|
||||
}
|
||||
|
||||
public function _class($v){
|
||||
if(is_array($v)){
|
||||
|
||||
public function _class($v) {
|
||||
if (is_array($v)) {
|
||||
$this->class = array_merge($this->class, $v);
|
||||
} else{
|
||||
} else {
|
||||
$this->class[] = $v;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function css($property, $v){
|
||||
|
||||
public function css($property, $v) {
|
||||
$this->css[$property] = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function closeBtn($v = true){
|
||||
|
||||
public function closeBtn($v = true) {
|
||||
$this->closeBtn = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function icon($v){
|
||||
|
||||
public function icon($v) {
|
||||
$this->icon = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function sm(){
|
||||
|
||||
public function sm() {
|
||||
$this->size = "sm";
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function size($v){
|
||||
|
||||
public function size($v) {
|
||||
$this->columns = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function offset($v = null){
|
||||
|
||||
public function offset($v = null) {
|
||||
$this->offsetColumns = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function title($v){
|
||||
|
||||
public function title($v) {
|
||||
$this->title = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function message($v){ // alias text
|
||||
|
||||
public function message($v) { // alias text
|
||||
return $this->text($v);
|
||||
}
|
||||
|
||||
public function text($v){
|
||||
|
||||
public function text($v) {
|
||||
$this->text = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function success(){
|
||||
|
||||
public function success() {
|
||||
return $this->theme("success");
|
||||
}
|
||||
public function info(){
|
||||
|
||||
public function info() {
|
||||
return $this->theme("info");
|
||||
}
|
||||
public function warning(){
|
||||
|
||||
public function warning() {
|
||||
return $this->theme("warning");
|
||||
}
|
||||
public function danger(){
|
||||
|
||||
public function danger() {
|
||||
return $this->theme("danger");
|
||||
}
|
||||
public function primary(){
|
||||
|
||||
public function primary() {
|
||||
return $this->theme("primary");
|
||||
}
|
||||
public function secondary(){
|
||||
|
||||
public function secondary() {
|
||||
return $this->theme("secondary");
|
||||
}
|
||||
public function dark(){
|
||||
|
||||
public function dark() {
|
||||
return $this->theme("dark");
|
||||
}
|
||||
public function light(){
|
||||
|
||||
public function light() {
|
||||
return $this->theme("light");
|
||||
}
|
||||
|
||||
public function theme($v){
|
||||
|
||||
public function theme($v) {
|
||||
$this->theme = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTheme(){
|
||||
|
||||
public function getTheme() {
|
||||
return $this->theme;
|
||||
}
|
||||
|
||||
public function getId(){
|
||||
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function id($v){
|
||||
|
||||
public function id($v) {
|
||||
$this->id = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function buildHtml(){
|
||||
$id = !is_null($this->id) ? "id='".$this->id."'" : "";
|
||||
|
||||
$this->_class("alert-".$this->theme);
|
||||
|
||||
|
||||
public function buildHtml() {
|
||||
$id = !is_null($this->id) ? "id='" . $this->id . "'" : "";
|
||||
|
||||
$this->_class("alert-" . $this->theme);
|
||||
|
||||
$columns = !is_null($this->columns) ? $this->columns : 12;
|
||||
$this->_class("col-sm-".$columns);
|
||||
|
||||
if(is_null($this->offsetColumns)){
|
||||
$offsetColumns = floor((12-$columns)/2);
|
||||
} else{
|
||||
$this->_class("col-sm-" . $columns);
|
||||
|
||||
if (is_null($this->offsetColumns)) {
|
||||
$offsetColumns = floor((12 - $columns) / 2);
|
||||
} else {
|
||||
$offsetColumns = $this->offsetColumns;
|
||||
}
|
||||
$this->_class("col-sm-offset-".$offsetColumns);
|
||||
|
||||
if(!is_null($this->size)){
|
||||
$this->_class("alert-".$this->size);
|
||||
$this->_class("col-sm-offset-" . $offsetColumns);
|
||||
|
||||
if (!is_null($this->size)) {
|
||||
$this->_class("alert-" . $this->size);
|
||||
}
|
||||
|
||||
$closeBtn = $this->closeBtn===true;
|
||||
if($closeBtn){
|
||||
|
||||
$closeBtn = $this->closeBtn === true;
|
||||
if ($closeBtn) {
|
||||
$this->_class("alert-dismissible");
|
||||
}
|
||||
|
||||
|
||||
$classes = implode(" ", $this->class);
|
||||
|
||||
|
||||
$style = "";
|
||||
foreach($this->css as $property => $value){
|
||||
foreach ($this->css as $property => $value) {
|
||||
$style .= "$property:$value;";
|
||||
}
|
||||
|
||||
$div = '<div '.$id.' class="alert text-left '.$classes.'" style="'.$style.'">';
|
||||
if($closeBtn){
|
||||
|
||||
$div = '<div ' . $id . ' class="alert text-left ' . $classes . '" style="' . $style . '">';
|
||||
if ($closeBtn) {
|
||||
$div .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span>×</span></button>';
|
||||
}
|
||||
if(!is_null($this->icon)){
|
||||
$div .= "<i class='fa fa-".$this->icon."'></i> ";
|
||||
if (!is_null($this->icon)) {
|
||||
$div .= "<i class='fa fa-" . $this->icon . "'></i> ";
|
||||
}
|
||||
if(!is_null($this->title)){
|
||||
$div .= "<strong>".$this->title."</strong><br/>";
|
||||
if (!is_null($this->title)) {
|
||||
$div .= "<strong>" . $this->title . "</strong><br/>";
|
||||
}
|
||||
|
||||
$div .= $this->text."</div>";
|
||||
|
||||
$div .= $this->text . "</div>";
|
||||
return \Utility\Str::remove_multiple_spaces($div);
|
||||
}
|
||||
|
||||
public function show(){
|
||||
|
||||
public function show() {
|
||||
echo $this->buildHtml();
|
||||
// echo htmlentities($this->buildHtml());
|
||||
// echo htmlentities($this->buildHtml());
|
||||
}
|
||||
}
|
||||
@@ -1,70 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace BC;
|
||||
class Icon{
|
||||
class Icon {
|
||||
private $classes = null;
|
||||
private $fa = null;
|
||||
private $type = null;
|
||||
|
||||
public function __construct(){
|
||||
// $this->regular();
|
||||
|
||||
public function __construct() {
|
||||
// $this->regular();
|
||||
}
|
||||
|
||||
public function classes($value){
|
||||
|
||||
public function classes($value) {
|
||||
$this->classes = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fa($value){
|
||||
|
||||
public function fa($value) {
|
||||
$this->fa = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function type($value){
|
||||
|
||||
public function type($value) {
|
||||
$this->type = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function solid(){
|
||||
|
||||
public function solid() {
|
||||
return $this->type("s");
|
||||
}
|
||||
|
||||
public function regular(){
|
||||
|
||||
public function regular() {
|
||||
return $this->type("r");
|
||||
}
|
||||
|
||||
public static function show($options = null){
|
||||
|
||||
public static function show($options = null) {
|
||||
$Icon = new \BC\Icon;
|
||||
return $Icon->parseOptions($options)->render();
|
||||
}
|
||||
|
||||
private function parseOptions($options = null){
|
||||
if(!is_null($options)){
|
||||
if(array_key_exists("classes", $options)){
|
||||
|
||||
private function parseOptions($options = null) {
|
||||
if (!is_null($options)) {
|
||||
if (array_key_exists("classes", $options)) {
|
||||
$this->classes($options["classes"]);
|
||||
}
|
||||
if(array_key_exists("fa", $options)){
|
||||
if (array_key_exists("fa", $options)) {
|
||||
$this->fa($options["fa"]);
|
||||
}
|
||||
if(array_key_exists("r", $options)){
|
||||
if (array_key_exists("r", $options)) {
|
||||
$this->regular();
|
||||
}
|
||||
if(array_key_exists("s", $options)){
|
||||
if (array_key_exists("s", $options)) {
|
||||
$this->solid();
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render(){
|
||||
|
||||
public function render() {
|
||||
$class = "";
|
||||
if(!is_null($this->classes)){
|
||||
$class .= $this->classes." ";
|
||||
if (!is_null($this->classes)) {
|
||||
$class .= $this->classes . " ";
|
||||
}
|
||||
if(!is_null($this->type)){
|
||||
$class .= "fa".$this->type." ";
|
||||
if (!is_null($this->type)) {
|
||||
$class .= "fa" . $this->type . " ";
|
||||
}
|
||||
if(!is_null($this->fa)){
|
||||
$class .= "fa-".$this->fa." ";
|
||||
if (!is_null($this->fa)) {
|
||||
$class .= "fa-" . $this->fa . " ";
|
||||
}
|
||||
return "<i class='{$class}'></i>";
|
||||
}
|
||||
|
||||
@@ -1,54 +1,55 @@
|
||||
<?php // BootstrapComponents
|
||||
include "BC.Alert.class.php";
|
||||
class BC{
|
||||
|
||||
public static function show_progressBar($options){
|
||||
if(isset($options["perc"])){
|
||||
|
||||
class BC {
|
||||
|
||||
public static function show_progressBar($options) {
|
||||
if (isset($options["perc"])) {
|
||||
$perc = $options["perc"];
|
||||
|
||||
} else if(isset($options["value"]) && isset($options["max"])){
|
||||
|
||||
} else if (isset($options["value"]) && isset($options["max"])) {
|
||||
$perc = ($options["value"] / $options["max"]) * 100;
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
$theme = null;
|
||||
if(isset($options["theme"])){
|
||||
if(is_array($options["theme"])){
|
||||
if (isset($options["theme"])) {
|
||||
if (is_array($options["theme"])) {
|
||||
ksort($options["theme"]);
|
||||
foreach($options["theme"] as $p => $pTheme){
|
||||
if(is_null($theme)){
|
||||
foreach ($options["theme"] as $p => $pTheme) {
|
||||
if (is_null($theme)) {
|
||||
$theme = $pTheme;
|
||||
}
|
||||
if($perc>=floatval($p)){
|
||||
if ($perc >= floatval($p)) {
|
||||
$theme = $pTheme;
|
||||
}
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$theme = $options["theme"];
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$theme = "info";
|
||||
}
|
||||
|
||||
|
||||
$viewVal = !(isset($options["viewVal"]) && !$options["viewVal"]);
|
||||
|
||||
$percSys = $perc>100 ? 100 : $perc;
|
||||
|
||||
$percSys = $perc > 100 ? 100 : $perc;
|
||||
$div = "<div class='progress'>
|
||||
<div class='progress-bar progress-bar-{$theme}' role='progressbar' aria-valuenow='{$percSys}' aria-valuemin='0' aria-valuemax='100' style='width:{$percSys}%'>
|
||||
".($viewVal?intval($perc)."%":"")."
|
||||
" . ($viewVal ? intval($perc) . "%" : "") . "
|
||||
</div>
|
||||
</div>";
|
||||
return Utility\Str::remove_multiple_spaces($div);
|
||||
}
|
||||
|
||||
public static function get_titleBarText(){
|
||||
|
||||
public static function get_titleBarText() {
|
||||
global $pageTitle;
|
||||
$currentModuleTitle = PVM\CurrentModule::getTitle();
|
||||
if(!is_null($currentModuleTitle)){
|
||||
if (!is_null($currentModuleTitle)) {
|
||||
return $currentModuleTitle;
|
||||
} else if(isset($pageTitle)){
|
||||
} else if (isset($pageTitle)) {
|
||||
return $pageTitle;
|
||||
}
|
||||
return "Portale WEB";
|
||||
|
||||
@@ -1,159 +1,159 @@
|
||||
<?php
|
||||
class Cache{
|
||||
|
||||
class Cache {
|
||||
private static $cache_folder = "cache/";
|
||||
const time_in_cache = 86400; // 24 * 60 * 60 (24 ore in secondi)
|
||||
const delete_ignore = "T87"; // estensioni file non auto-eliminabili, separati da virgola
|
||||
|
||||
public static function get_cacheRoot(){
|
||||
|
||||
public static function get_cacheRoot() {
|
||||
return self::$cache_folder;
|
||||
}
|
||||
|
||||
public static function set_cacheRoot($cacheFolder){
|
||||
|
||||
public static function set_cacheRoot($cacheFolder) {
|
||||
self::$cache_folder = $cacheFolder;
|
||||
}
|
||||
|
||||
private static function gen_filename_rnd($cachePath, $filenameIn, $c = 0){
|
||||
|
||||
private static function gen_filename_rnd($cachePath, $filenameIn, $c = 0) {
|
||||
$basename = pathinfo($filenameIn, PATHINFO_FILENAME);
|
||||
$ext = pathinfo($filenameIn, PATHINFO_EXTENSION);
|
||||
|
||||
|
||||
$filenameOut = $basename;
|
||||
if($c>0){
|
||||
$filenameOut .= "-".rand(1, 10000);
|
||||
if ($c > 0) {
|
||||
$filenameOut .= "-" . rand(1, 10000);
|
||||
}
|
||||
$filenameOut .= ".".$ext;
|
||||
|
||||
$filePath = $cachePath.$filenameOut;
|
||||
if(file_exists($filePath)){
|
||||
$filenameOut .= "." . $ext;
|
||||
|
||||
$filePath = $cachePath . $filenameOut;
|
||||
if (file_exists($filePath)) {
|
||||
$c++;
|
||||
return self::gen_filename_rnd($cachePath, $filenameOut, $c);
|
||||
} else{
|
||||
} else {
|
||||
return $filenameOut;
|
||||
}
|
||||
}
|
||||
|
||||
private static function get_cachePath($fileName = null, $subfolder = null){
|
||||
|
||||
private static function get_cachePath($fileName = null, $subfolder = null) {
|
||||
$subfolder = !is_null($fileName) ? self::complete_subfolder($fileName, $subfolder) : $subfolder;
|
||||
$cacheRoot = self::get_cacheRoot();
|
||||
if(!file_exists($cacheRoot)){
|
||||
if (!file_exists($cacheRoot)) {
|
||||
@mkdir($cacheRoot, 0777);
|
||||
}
|
||||
if(!is_null($subfolder)){
|
||||
$cachePath = $cacheRoot.$subfolder."/";
|
||||
if(!file_exists($cachePath)){
|
||||
if (!is_null($subfolder)) {
|
||||
$cachePath = $cacheRoot . $subfolder . "/";
|
||||
if (!file_exists($cachePath)) {
|
||||
@mkdir($cachePath, 0777);
|
||||
}
|
||||
return $cachePath;
|
||||
}
|
||||
return $cacheRoot;
|
||||
}
|
||||
|
||||
public static function read($fileName, $subfolder = null, $timeInCache = null){
|
||||
|
||||
public static function read($fileName, $subfolder = null, $timeInCache = null) {
|
||||
$filePath = self::get_filepath($fileName, $subfolder, true);
|
||||
self::clean_folder($filePath, $timeInCache);
|
||||
return file_exists($filePath) ? file_get_contents($filePath) : null;
|
||||
}
|
||||
|
||||
private static function exists_filename($cachePath, $fileName){
|
||||
return file_exists($cachePath.$fileName);
|
||||
|
||||
private static function exists_filename($cachePath, $fileName) {
|
||||
return file_exists($cachePath . $fileName);
|
||||
}
|
||||
|
||||
private static function generateIncrementalFilename($cachePath, $fileName){
|
||||
|
||||
private static function generateIncrementalFilename($cachePath, $fileName) {
|
||||
$IncrementName = new \Utility\File\IncrementName($fileName);
|
||||
$pattern = (!is_null(nullIfBlank($fileName)) ? " - " : "")."[N]";
|
||||
$pattern = (!is_null(nullIfBlank($fileName)) ? " - " : "") . "[N]";
|
||||
$IncrementName->set_pattern($pattern)->set_numPad(2);
|
||||
$i = 0;
|
||||
do{
|
||||
do {
|
||||
$result = $IncrementName->set_number($i)->get_result();
|
||||
$i++;
|
||||
}
|
||||
while(self::exists_filename($cachePath, $result));
|
||||
} while (self::exists_filename($cachePath, $result));
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function get_filepath($fileName = null, $subfolder = null, $overwrite = false){
|
||||
|
||||
public static function get_filepath($fileName = null, $subfolder = null, $overwrite = false) {
|
||||
$fileName = !is_null($fileName) ? Utility\File::nameSanitized(str_replace("/", "-", $fileName)) : "file";
|
||||
$cachePath = self::get_cachePath($fileName, $subfolder);
|
||||
|
||||
if(!$overwrite){
|
||||
|
||||
if (!$overwrite) {
|
||||
$fileName = self::generateIncrementalFilename($cachePath, $fileName);
|
||||
//$fileName = !is_null($fileName) ? self::gen_filename_rnd($cachePath, $fileName) : null;
|
||||
}
|
||||
|
||||
return $cachePath.blankIfNull($fileName);
|
||||
|
||||
return $cachePath . blankIfNull($fileName);
|
||||
}
|
||||
|
||||
private static function complete_subfolder($fileName, $subfolder){
|
||||
if($subfolder===true){ // usa l'estensione del file in automatico
|
||||
if(\Utility\File::isImageFromName($fileName)){
|
||||
|
||||
private static function complete_subfolder($fileName, $subfolder) {
|
||||
if ($subfolder === true) { // usa l'estensione del file in automatico
|
||||
if (\Utility\File::isImageFromName($fileName)) {
|
||||
return "images";
|
||||
}
|
||||
return nullIfBlank(strtolower(pathinfo($fileName, PATHINFO_EXTENSION)));
|
||||
}
|
||||
return $subfolder;
|
||||
}
|
||||
|
||||
private static function clean_folder($filePath, $timeInCache = self::time_in_cache){
|
||||
|
||||
private static function clean_folder($filePath, $timeInCache = self::time_in_cache) {
|
||||
$folder = pathinfo($filePath, PATHINFO_DIRNAME);
|
||||
$ext = pathinfo($filePath, PATHINFO_EXTENSION);
|
||||
$arr_deleteIgnore = explode(",", self::delete_ignore);
|
||||
|
||||
if($handle = opendir($folder)){
|
||||
while(false!==($file = readdir($handle))){
|
||||
$fpath = $folder."/".$file;
|
||||
if(file_exists($fpath) && !is_dir($fpath)){
|
||||
|
||||
if ($handle = opendir($folder)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
$fpath = $folder . "/" . $file;
|
||||
if (file_exists($fpath) && !is_dir($fpath)) {
|
||||
$fpath_ext = strtolower(pathinfo($fpath, PATHINFO_EXTENSION));
|
||||
if((!$ext || \Utility\Str::ciEquals($fpath_ext, $ext)) && !in_arrayi($fpath_ext, $arr_deleteIgnore)){
|
||||
if ((!$ext || \Utility\Str::ciEquals($fpath_ext, $ext)) && !in_arrayi($fpath_ext, $arr_deleteIgnore)) {
|
||||
$filelastmodified = filemtime($fpath);
|
||||
if((Utility\Date::getNow() - $filelastmodified) > $timeInCache){
|
||||
if ((Utility\Date::getNow() - $filelastmodified) > $timeInCache) {
|
||||
unlink($fpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
|
||||
public static function writeR($fileName, $content = null, $subfolder = null, $overwrite = false, $timeInCache = self::time_in_cache){
|
||||
|
||||
public static function writeR($fileName, $content = null, $subfolder = null, $overwrite = false, $timeInCache = self::time_in_cache) {
|
||||
$Ret = new \Ret;
|
||||
$filePath = self::get_filepath($fileName, $subfolder, $overwrite);
|
||||
|
||||
if($overwrite && file_exists($filePath)){
|
||||
|
||||
if ($overwrite && file_exists($filePath)) {
|
||||
unlink($filePath);
|
||||
}
|
||||
|
||||
|
||||
self::clean_folder($filePath, $timeInCache);
|
||||
|
||||
if(!is_null(\nullIfBlank($content))){
|
||||
|
||||
if (!is_null(\nullIfBlank($content))) {
|
||||
$filePath = @file_put_contents($filePath, $content) ? $filePath : false;
|
||||
if($filePath!==false){
|
||||
if ($filePath !== false) {
|
||||
$Ret->set_string($filePath);
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("Si è verificato un errore durante la scrittura del file nel percorso temporaneo")
|
||||
->set_errorTitle(pathinfo($fileName, PATHINFO_FILENAME));
|
||||
}
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Il contenuto del file non è valido")->set_errorTitle(pathinfo($fileName, PATHINFO_FILENAME));
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static function write($fileName, $content = null, $subfolder = null, $overwrite = false, $timeInCache = self::time_in_cache){
|
||||
* @deprecated
|
||||
*/
|
||||
public static function write($fileName, $content = null, $subfolder = null, $overwrite = false, $timeInCache = self::time_in_cache) {
|
||||
$Ret = self::writeR($fileName, $content, $subfolder, $overwrite, $timeInCache);
|
||||
return $Ret->is_OK() ? $Ret->get_string() : false;
|
||||
}
|
||||
|
||||
public static function tempFile(){
|
||||
$cachePath = self::get_cachePath(null, "temp");
|
||||
|
||||
public static function tempFile() {
|
||||
$cachePath = self::get_cachePath(null, "temp");
|
||||
$filePath = self::gen_filename_rnd($cachePath, "cache.temp");
|
||||
register_shutdown_function(function() use($filePath){
|
||||
register_shutdown_function(function () use ($filePath) {
|
||||
@unlink($filePath);
|
||||
});
|
||||
return $cachePath.$filePath;
|
||||
return $cachePath . $filePath;
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,10 @@ class Config {
|
||||
if (!is_null($endPoint)) {
|
||||
$endPoint = Controller::endPointParsed($endPoint);
|
||||
}
|
||||
|
||||
if (is_number(strpos($endPoint,"192.168.3.15:8080")) && is_number(strpos(ISSET($_SERVER["HTTP_REFERER"])?$_SERVER["HTTP_REFERER"]:$_SERVER["PHP_SELF"],"/dev/pvm"))){
|
||||
$endPoint = "http://192.168.2.215:8080";
|
||||
}
|
||||
return $endPoint;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,182 +1,195 @@
|
||||
<?php
|
||||
class Controller{
|
||||
|
||||
class Controller {
|
||||
public static $baseModule = "base";
|
||||
public static $abs_root_project = null;
|
||||
|
||||
//public static $gestname = null;
|
||||
|
||||
public static function current_url(){
|
||||
|
||||
public static function current_url() {
|
||||
return (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] === "on" ? "https" : "http") . "://{$_SERVER["HTTP_HOST"]}{$_SERVER["REQUEST_URI"]}";
|
||||
}
|
||||
|
||||
public static function current_module(){ // è data dal nome della gestione .php
|
||||
|
||||
public static function current_module() { // è data dal nome della gestione .php
|
||||
/*if(!is_null(self::$gestname)){
|
||||
return self::$gestname;
|
||||
}*/
|
||||
// valutare ModuloUtils\CurrentModule\getId
|
||||
|
||||
|
||||
return pathinfo($_SERVER["PHP_SELF"], PATHINFO_FILENAME);
|
||||
}
|
||||
|
||||
public static function current_gestpath(){
|
||||
|
||||
public static function current_gestpath() {
|
||||
return self::module_gestpath(self::current_module());
|
||||
}
|
||||
public static function module_gestpath($moduleName){
|
||||
return "gest-lib".DIRECTORY_SEPARATOR."{$moduleName}".DIRECTORY_SEPARATOR;
|
||||
|
||||
public static function module_gestpath($moduleName) {
|
||||
return "gest-lib" . DIRECTORY_SEPARATOR . "{$moduleName}" . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
public static function current_gestpath_resource($resource){
|
||||
|
||||
public static function current_gestpath_resource($resource) {
|
||||
return self::module_gestpath_resource(self::current_module(), $resource);
|
||||
}
|
||||
public static function module_gestpath_resource($moduleName, $resource){
|
||||
return self::module_gestpath($moduleName).$resource.DIRECTORY_SEPARATOR;
|
||||
|
||||
public static function module_gestpath_resource($moduleName, $resource) {
|
||||
return self::module_gestpath($moduleName) . $resource . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
|
||||
// PATH SERVER-SIDE
|
||||
public static function current_gestpath_classes($fileName = ""){
|
||||
public static function current_gestpath_classes($fileName = "") {
|
||||
return self::module_gestpath_classes(self::current_module(), $fileName);
|
||||
}
|
||||
public static function module_gestpath_classes($moduleName, $fileName = ""){
|
||||
return self::$abs_root_project.DIRECTORY_SEPARATOR.self::module_gestpath_resource($moduleName, "classes").$fileName;
|
||||
|
||||
public static function module_gestpath_classes($moduleName, $fileName = "") {
|
||||
return self::$abs_root_project . DIRECTORY_SEPARATOR . self::module_gestpath_resource($moduleName, "classes") . $fileName;
|
||||
}
|
||||
|
||||
|
||||
// PATH SERVER-SIDE
|
||||
/*
|
||||
public static function current_gestpath_widgets($fileName = ""){
|
||||
return self::module_gestpath_classes(self::current_module(), $fileName);
|
||||
}*/
|
||||
public static function module_gestpath_widgets($moduleName, $fileName = ""){
|
||||
return self::$abs_root_project.DIRECTORY_SEPARATOR.self::module_gestpath_resource($moduleName, "widgets").$fileName;
|
||||
}
|
||||
|
||||
// PATH SERVER-SIDE
|
||||
public static function current_mainClasspath(){
|
||||
return self::module_mainClasspath(self::current_module());
|
||||
}
|
||||
public static function module_mainClasspath($moduleName){
|
||||
$fileName = ucfirst(\Utility\Str::camelCaseEncode($moduleName)).".class.php";
|
||||
return self::module_gestpath_classes($moduleName, $fileName);
|
||||
}
|
||||
|
||||
// PATH SERVER-SIDE
|
||||
public static function current_gestpath_sql($fileName = ""){
|
||||
return self::module_gestpath_sql(self::current_module(), $fileName);
|
||||
}
|
||||
/* here you can understand what module name use to reach your sql file */
|
||||
public static function module_gestpath_sql($moduleName, $fileName = ""){
|
||||
return self::$abs_root_project."/".self::module_gestpath_resource($moduleName, "sql").$fileName;
|
||||
}
|
||||
|
||||
// PATH SERVER-SIDE
|
||||
public static function current_gestpath_include($fileName = ""){
|
||||
return self::module_gestpath_include(self::current_module(), $fileName);
|
||||
}
|
||||
public static function module_gestpath_include($moduleName, $fileName = ""){
|
||||
return self::module_gestpath_resource($moduleName, "include").$fileName;
|
||||
}
|
||||
|
||||
// PATH SERVER-SIDE
|
||||
/************************************* RELATION BETWEEN MAIN.PHP AND {GESTIONE}.PHP *************************************************/
|
||||
public static function current_gestpath_mainPage(){
|
||||
return self::module_gestpath_mainPage(self::current_module());
|
||||
}
|
||||
public static function module_gestpath_mainPage($moduleName){
|
||||
return self::module_gestpath_include($moduleName, "main.php");
|
||||
}
|
||||
|
||||
// PATH SERVER-SIDE
|
||||
public static function current_gestpath_certs($fileName = ""){
|
||||
return self::module_gestpath_certs(self::current_module(), $fileName);
|
||||
}
|
||||
public static function module_gestpath_certs($moduleName, $fileName = ""){
|
||||
return self::module_gestpath_resource($moduleName, "certs").$fileName;
|
||||
}
|
||||
|
||||
// PATH CLIENT-SIDE
|
||||
public static function module_gestpath_js($moduleName, $fileName = ""){
|
||||
return str_replace(DIRECTORY_SEPARATOR, "/", self::module_gestpath_resource($moduleName, "js")).$fileName;
|
||||
public static function module_gestpath_widgets($moduleName, $fileName = "") {
|
||||
return self::$abs_root_project . DIRECTORY_SEPARATOR . self::module_gestpath_resource($moduleName, "widgets") . $fileName;
|
||||
}
|
||||
|
||||
public static function module_gestpath_audio($moduleName, $fileName = ""){
|
||||
return str_replace(DIRECTORY_SEPARATOR, "/", self::module_gestpath_resource($moduleName, "audio")).$fileName;
|
||||
// PATH SERVER-SIDE
|
||||
public static function current_mainClasspath() {
|
||||
return self::module_mainClasspath(self::current_module());
|
||||
}
|
||||
|
||||
public static function module_gestpath_css($moduleName, $fileName = ""){
|
||||
return str_replace(DIRECTORY_SEPARATOR, "/", self::module_gestpath_resource($moduleName, "css")).$fileName;
|
||||
|
||||
public static function module_mainClasspath($moduleName) {
|
||||
$fileName = ucfirst(\Utility\Str::camelCaseEncode($moduleName)) . ".class.php";
|
||||
return self::module_gestpath_classes($moduleName, $fileName);
|
||||
}
|
||||
|
||||
|
||||
// PATH SERVER-SIDE
|
||||
public static function current_gestpath_sql($fileName = "") {
|
||||
return self::module_gestpath_sql(self::current_module(), $fileName);
|
||||
}
|
||||
|
||||
/* here you can understand what module name use to reach your sql file */
|
||||
public static function module_gestpath_sql($moduleName, $fileName = "") {
|
||||
return self::$abs_root_project . "/" . self::module_gestpath_resource($moduleName, "sql") . $fileName;
|
||||
}
|
||||
|
||||
// PATH SERVER-SIDE
|
||||
public static function current_gestpath_include($fileName = "") {
|
||||
return self::module_gestpath_include(self::current_module(), $fileName);
|
||||
}
|
||||
|
||||
public static function module_gestpath_include($moduleName, $fileName = "") {
|
||||
return self::module_gestpath_resource($moduleName, "include") . $fileName;
|
||||
}
|
||||
|
||||
// PATH SERVER-SIDE
|
||||
|
||||
/************************************* RELATION BETWEEN MAIN.PHP AND {GESTIONE}.PHP *************************************************/
|
||||
public static function current_gestpath_mainPage() {
|
||||
return self::module_gestpath_mainPage(self::current_module());
|
||||
}
|
||||
|
||||
public static function module_gestpath_mainPage($moduleName) {
|
||||
return self::module_gestpath_include($moduleName, "main.php");
|
||||
}
|
||||
|
||||
// PATH SERVER-SIDE
|
||||
public static function current_gestpath_certs($fileName = "") {
|
||||
return self::module_gestpath_certs(self::current_module(), $fileName);
|
||||
}
|
||||
|
||||
public static function module_gestpath_certs($moduleName, $fileName = "") {
|
||||
return self::module_gestpath_resource($moduleName, "certs") . $fileName;
|
||||
}
|
||||
|
||||
// PATH CLIENT-SIDE
|
||||
public static function current_gestpath_images($fileName = ""){
|
||||
public static function module_gestpath_js($moduleName, $fileName = "") {
|
||||
return str_replace(DIRECTORY_SEPARATOR, "/", self::module_gestpath_resource($moduleName, "js")) . $fileName;
|
||||
}
|
||||
|
||||
public static function module_gestpath_audio($moduleName, $fileName = "") {
|
||||
return str_replace(DIRECTORY_SEPARATOR, "/", self::module_gestpath_resource($moduleName, "audio")) . $fileName;
|
||||
}
|
||||
|
||||
public static function module_gestpath_css($moduleName, $fileName = "") {
|
||||
return str_replace(DIRECTORY_SEPARATOR, "/", self::module_gestpath_resource($moduleName, "css")) . $fileName;
|
||||
}
|
||||
|
||||
// PATH CLIENT-SIDE
|
||||
public static function current_gestpath_images($fileName = "") {
|
||||
return self::module_gestpath_images(self::current_module(), $fileName);
|
||||
}
|
||||
public static function module_gestpath_images($moduleName, $fileName = ""){
|
||||
return self::module_gestpath_resource($moduleName, "images").$fileName;
|
||||
|
||||
public static function module_gestpath_images($moduleName, $fileName = "") {
|
||||
return self::module_gestpath_resource($moduleName, "images") . $fileName;
|
||||
}
|
||||
|
||||
public static function current_gestpath_html($fileName = ""){
|
||||
|
||||
public static function current_gestpath_html($fileName = "") {
|
||||
return self::module_gestpath_html(self::current_module(), $fileName);
|
||||
}
|
||||
public static function module_gestpath_html($moduleName, $fileName = ""){
|
||||
return self::module_gestpath_resource($moduleName, "html").$fileName;
|
||||
|
||||
public static function module_gestpath_html($moduleName, $fileName = "") {
|
||||
return self::module_gestpath_resource($moduleName, "html") . $fileName;
|
||||
}
|
||||
|
||||
public static function wwwpath(){
|
||||
return (PVM::isDebugEnv() && file_exists("../public_html") ? "../" : "")."../";
|
||||
|
||||
public static function wwwpath() {
|
||||
return (PVM::isDebugEnv() && file_exists("../public_html") ? "../" : "") . "../";
|
||||
}
|
||||
|
||||
public static function endPointParsed($endPoint){
|
||||
|
||||
public static function endPointParsed($endPoint) {
|
||||
$scheme = parse_url($endPoint, PHP_URL_SCHEME);
|
||||
$host = parse_url($endPoint, PHP_URL_HOST);
|
||||
$path = parse_url($endPoint, PHP_URL_PATH);
|
||||
$port = parse_url($endPoint, PHP_URL_PORT);
|
||||
if(is_null($host)){
|
||||
if (is_null($host)) {
|
||||
$host = $path;
|
||||
}
|
||||
$protocol = is_null($scheme) ? Rest::$protocol : $scheme;
|
||||
$endPoint = $protocol."://".$host;
|
||||
if(!is_null($port)){
|
||||
$endPoint .= ":".$port;
|
||||
$endPoint = $protocol . "://" . $host;
|
||||
if (!is_null($port)) {
|
||||
$endPoint .= ":" . $port;
|
||||
}
|
||||
return $endPoint;
|
||||
}
|
||||
|
||||
private static function getCurrentUrlParameters(){
|
||||
|
||||
private static function getCurrentUrlParameters() {
|
||||
$currentUrl = self::current_url();
|
||||
$params = array();
|
||||
parse_str(parse_url($currentUrl, PHP_URL_QUERY), $params);
|
||||
return array_keys($params);
|
||||
}
|
||||
|
||||
private static function calcNavTabScore($navParams){
|
||||
|
||||
private static function calcNavTabScore($navParams) {
|
||||
$currentParams = self::getCurrentUrlParameters();
|
||||
$navTabScore = 0;
|
||||
foreach($currentParams as $param){
|
||||
if(in_array($param, $navParams)){
|
||||
foreach ($currentParams as $param) {
|
||||
if (in_array($param, $navParams)) {
|
||||
$navTabScore++;
|
||||
}
|
||||
}
|
||||
return $navTabScore;
|
||||
}
|
||||
|
||||
private static function getIdxActiveNavTab(){
|
||||
|
||||
private static function getIdxActiveNavTab() {
|
||||
$userNavTabs = self::getUserNavTabs();
|
||||
$idx = $maxScore = 0;
|
||||
foreach($userNavTabs as $i => $userNavTab){
|
||||
if($userNavTab["score"]>$maxScore){
|
||||
foreach ($userNavTabs as $i => $userNavTab) {
|
||||
if ($userNavTab["score"] > $maxScore) {
|
||||
$idx = $i;
|
||||
$maxScore = $userNavTab["score"];
|
||||
}
|
||||
}
|
||||
return $idx;
|
||||
}
|
||||
|
||||
private static function getUserNavTabs(){
|
||||
|
||||
private static function getUserNavTabs() {
|
||||
$userNavTabs = array();
|
||||
$currentUrl = self::current_url();
|
||||
$Modulo = PVM\CurrentModule::getModulo();
|
||||
if(!is_null($currentUrl) && !is_null($Modulo) && $Modulo->isLoaded()){
|
||||
foreach($Modulo->getPosition() as $pItem){
|
||||
if (!is_null($currentUrl) && !is_null($Modulo) && $Modulo->isLoaded()) {
|
||||
foreach ($Modulo->getPosition() as $pItem) {
|
||||
$flagView = PVM::processItemPolicyToCurrentUser($pItem);
|
||||
if($flagView){
|
||||
if ($flagView) {
|
||||
$navTab = array_pick($pItem, "title", "url");
|
||||
$pQ = array();
|
||||
parse_str(parse_url($navTab["url"], PHP_URL_QUERY), $pQ);
|
||||
@@ -187,20 +200,20 @@ class Controller{
|
||||
}
|
||||
return $userNavTabs;
|
||||
}
|
||||
|
||||
public static function getNavTabs(){
|
||||
|
||||
public static function getNavTabs() {
|
||||
$navTabs = self::getUserNavTabs();
|
||||
if(count($navTabs)>0){
|
||||
if (count($navTabs) > 0) {
|
||||
$idxAttivo = self::getIdxActiveNavTab();
|
||||
foreach($navTabs as $i => $navTab){
|
||||
if(isset($navTab["usergroups"]) && !array_key_exists(User::get_current_group(), $navTab["usergroups"])) {
|
||||
foreach ($navTabs as $i => $navTab) {
|
||||
if (isset($navTab["usergroups"]) && !array_key_exists(User::get_current_group(), $navTab["usergroups"])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if($idxAttivo===$i){
|
||||
if ($idxAttivo === $i) {
|
||||
$navTab["active"] = true;
|
||||
$navTab["url"] = "#";
|
||||
} else{
|
||||
} else {
|
||||
$navTab["active"] = false;
|
||||
}
|
||||
$navTabs[$i] = $navTab;
|
||||
@@ -209,106 +222,105 @@ class Controller{
|
||||
return $navTabs;
|
||||
}
|
||||
|
||||
public static function get_js_files(){
|
||||
public static function get_js_files() {
|
||||
$files = array();
|
||||
$assetsLibs = self::loadCurrentAssetsLibs();
|
||||
foreach($assetsLibs as $lib){
|
||||
foreach ($assetsLibs as $lib) {
|
||||
$files = array_merge($files, self::loadLibrary($lib, "js"));
|
||||
}
|
||||
if(empty($files)){
|
||||
if (empty($files)) {
|
||||
$files = self::loadLibrary(self::$baseModule, "js");
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
||||
public static function get_css_files(){
|
||||
|
||||
public static function get_css_files() {
|
||||
$files = array();
|
||||
$assetsLibs = self::loadCurrentAssetsLibs();
|
||||
foreach($assetsLibs as $lib){
|
||||
foreach ($assetsLibs as $lib) {
|
||||
$files = array_merge($files, self::loadLibrary($lib, "css"));
|
||||
}
|
||||
if(empty($files)){
|
||||
if (empty($files)) {
|
||||
$files = self::loadLibrary(self::$baseModule, "css");
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
||||
private static function loadCurrentAssetsLibs(){
|
||||
|
||||
private static function loadCurrentAssetsLibs() {
|
||||
$modules = PVM::get_userModulesTree();
|
||||
$mergedModules = array();
|
||||
foreach($modules as $module){
|
||||
foreach ($modules as $module) {
|
||||
$mergedModules = array_merge($mergedModules, $module);
|
||||
}
|
||||
|
||||
|
||||
$currentActiveModuleName = array(self::current_module());
|
||||
if(self::current_module()!=="login"){
|
||||
if (self::current_module() !== "login") {
|
||||
$currentActiveModuleName = array_merge($currentActiveModuleName, \PVM\ModuloUtils::getIdModuliBase());
|
||||
}
|
||||
|
||||
|
||||
$libs = array();
|
||||
foreach($mergedModules as $commonModule){
|
||||
if(in_array($commonModule["id"], $currentActiveModuleName)){
|
||||
foreach ($mergedModules as $commonModule) {
|
||||
if (in_array($commonModule["id"], $currentActiveModuleName)) {
|
||||
$libs = array_merge($libs, $commonModule["libs"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return array_values(array_unique($libs));
|
||||
}
|
||||
|
||||
public static function loadLibrary($libName, $fileType){
|
||||
public static function loadLibrary($libName, $fileType) {
|
||||
$libs = PVM::loadAssetsLibs();
|
||||
$fileList = array();
|
||||
|
||||
if(isset($libs[$libName])){
|
||||
|
||||
if (isset($libs[$libName])) {
|
||||
$lib = $libs[$libName];
|
||||
|
||||
if(isset($lib[$fileType])){
|
||||
foreach($lib[$fileType] as $file){
|
||||
if(file_exists($file)){
|
||||
|
||||
if (isset($lib[$fileType])) {
|
||||
foreach ($lib[$fileType] as $file) {
|
||||
if (file_exists($file)) {
|
||||
$fileList[] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($lib["children"])){
|
||||
foreach($lib["children"] as $childLibName){
|
||||
|
||||
if (isset($lib["children"])) {
|
||||
foreach ($lib["children"] as $childLibName) {
|
||||
$fileList = array_merge($fileList, self::loadLibrary($childLibName, $fileType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $fileList;
|
||||
}
|
||||
|
||||
public static function get_build(){
|
||||
public static function get_build() {
|
||||
return file_exists("build.json") ? json_decode(file_get_contents("build.json"), true) : null;
|
||||
}
|
||||
|
||||
public static function is_ajaxRequest(){
|
||||
|
||||
public static function is_ajaxRequest() {
|
||||
return isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && \Utility\Str::ciEquals($_SERVER["HTTP_X_REQUESTED_WITH"], "xmlhttprequest");
|
||||
}
|
||||
|
||||
public static function loginRedirect(){
|
||||
|
||||
public static function loginRedirect() {
|
||||
header("Location: login.php");
|
||||
}
|
||||
|
||||
public static function homeRedirect(){
|
||||
$url = $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
|
||||
if(strpos($url, "public_html") !== false){
|
||||
|
||||
public static function homeRedirect() {
|
||||
$url = $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
|
||||
if (strpos($url, "public_html") !== false) {
|
||||
header("Location: ../");
|
||||
} else{
|
||||
} else {
|
||||
header("Location: ./");
|
||||
}
|
||||
}
|
||||
|
||||
public static function get_audio_files()
|
||||
{
|
||||
public static function get_audio_files() {
|
||||
$files = array();
|
||||
$assetsLibs = self::loadCurrentAssetsLibs();
|
||||
foreach($assetsLibs as $lib){
|
||||
foreach ($assetsLibs as $lib) {
|
||||
$files = array_merge($files, self::loadLibrary($lib, "mp3"));
|
||||
}
|
||||
if(empty($files)){
|
||||
if (empty($files)) {
|
||||
$files = self::loadLibrary(self::$baseModule, "mp3");
|
||||
}
|
||||
return $files;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
class EntityItem
|
||||
{
|
||||
class EntityItem {
|
||||
public $endPoint = null;
|
||||
private $authUsername = null;
|
||||
private $authPassword = null;
|
||||
@@ -25,31 +24,26 @@ class EntityItem
|
||||
const SELECT_OBJECT = "SELECT_OBJECT";
|
||||
const NO_OP = "NO_OP";
|
||||
|
||||
public function __construct($type = null)
|
||||
{
|
||||
public function __construct($type = null) {
|
||||
if (!is_null($type)) {
|
||||
$this->type($type);
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
public function __toString() {
|
||||
return self::get_jsonBody();
|
||||
}
|
||||
|
||||
public function type($type)
|
||||
{
|
||||
public function type($type) {
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
public function getType() {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
private static function is_validKey($key)
|
||||
{
|
||||
private static function is_validKey($key) {
|
||||
if (strpos($key, "_") !== false) { // deve accettare solo chiavi camelCase
|
||||
print_r("EntityItem->field accetta solo key con nomenclatura camel-case ('{$key}')");
|
||||
return false;
|
||||
@@ -57,29 +51,25 @@ class EntityItem
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function is_entityItem($value)
|
||||
{
|
||||
public static function is_entityItem($value) {
|
||||
return !is_null($value) && gettype($value) == "object" && (get_class($value) == "EntityItem" || is_subclass_of($value, "EntityItem"));
|
||||
}
|
||||
|
||||
public function count_entityChildren($key)
|
||||
{
|
||||
public function count_entityChildren($key) {
|
||||
if (isset($this->childEntityArray[$key])) {
|
||||
return count($this->childEntityArray[$key]->get_children());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function get_childEntityArray($key)
|
||||
{
|
||||
private function get_childEntityArray($key) {
|
||||
if (!isset($this->childEntityArray[$key])) {
|
||||
$this->childEntityArray[$key] = new EntityArray($key);
|
||||
}
|
||||
return $this->childEntityArray[$key];
|
||||
}
|
||||
|
||||
private static function log_deprecatedFunction()
|
||||
{
|
||||
private static function log_deprecatedFunction() {
|
||||
$caller = debug_backtrace();
|
||||
$caller = array_pick($caller[1], "file", "line");
|
||||
|
||||
@@ -98,13 +88,11 @@ class EntityItem
|
||||
@Cache::writeR($logFile, $content, null, true);
|
||||
}
|
||||
|
||||
public function unset_child($key)
|
||||
{
|
||||
public function unset_child($key) {
|
||||
return $this->unset_field($key);
|
||||
}
|
||||
|
||||
public function unset_field($key)
|
||||
{
|
||||
public function unset_field($key) {
|
||||
if (array_key_exists($key, $this->arr_fields)) {
|
||||
unset($this->arr_fields[$key]);
|
||||
}
|
||||
@@ -114,27 +102,23 @@ class EntityItem
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get_field($key)
|
||||
{
|
||||
public function get_field($key) {
|
||||
return (self::is_validKey($key) && isset($this->arr_fields[$key])) ? $this->arr_fields[$key] : null;
|
||||
}
|
||||
|
||||
public function setDatetime($key, $value, $setNullConstant = false)
|
||||
{
|
||||
public function setDatetime($key, $value, $setNullConstant = false) {
|
||||
$setNullConstant = $setNullConstant === true ? \Format::IMS_NULL_TIME : $setNullConstant;
|
||||
$value = \Utility\Date::isValidUnixtime($value) ? strftime(\Format::strftimeYMDHMS, $value) : $value;
|
||||
return $this->set($key, $value, $setNullConstant);
|
||||
}
|
||||
|
||||
public function setDate($key, $value, $setNullConstant = false)
|
||||
{
|
||||
public function setDate($key, $value, $setNullConstant = false) {
|
||||
$setNullConstant = $setNullConstant === true ? \Format::IMS_NULL_TIME : $setNullConstant;
|
||||
$value = \Utility\Date::isValidUnixtime($value) ? strftime(\Format::strftimeYMD, $value) : $value;
|
||||
return $this->set($key, $value, $setNullConstant);
|
||||
}
|
||||
|
||||
public function set($key, $value = false, $setNullConstant = false, $oneToOneRelationship = false)
|
||||
{
|
||||
public function set($key, $value = false, $setNullConstant = false, $oneToOneRelationship = false) {
|
||||
if (count(func_get_args()) == 1) { // GET
|
||||
if (isset($this->arr_fields[$key])) {
|
||||
return $this->arr_fields[$key];
|
||||
@@ -187,8 +171,7 @@ class EntityItem
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setOldPk($input)
|
||||
{ // esclusivo substitute
|
||||
public function setOldPk($input) { // esclusivo substitute
|
||||
if (self::is_entityItem($input)) {
|
||||
$this->detail("oldPk", $input);
|
||||
|
||||
@@ -203,8 +186,7 @@ class EntityItem
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function detail($type, $value)
|
||||
{
|
||||
public function detail($type, $value) {
|
||||
if (self::is_validKey($type)) {
|
||||
$this->arr_fields[$type] = $value;
|
||||
return $this;
|
||||
@@ -212,44 +194,37 @@ class EntityItem
|
||||
return false;
|
||||
}
|
||||
|
||||
public function profileDB($value)
|
||||
{
|
||||
public function profileDB($value) {
|
||||
$this->profileDB = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function endPoint($endPoint)
|
||||
{
|
||||
public function endPoint($endPoint) {
|
||||
$this->endPoint = $endPoint;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function authUsername($value)
|
||||
{
|
||||
public function authUsername($value) {
|
||||
$this->authUsername = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function authPassword($value)
|
||||
{
|
||||
public function authPassword($value) {
|
||||
$this->authPassword = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function anonymousAuth($value = true)
|
||||
{
|
||||
public function anonymousAuth($value = true) {
|
||||
$this->anonymousAuth = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function onlyPkMaster($enabled = true)
|
||||
{
|
||||
public function onlyPkMaster($enabled = true) {
|
||||
$this->onlyPkMaster = (bool)$enabled;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function send()
|
||||
{
|
||||
public function send() {
|
||||
if ($this->cacheFile !== false) {
|
||||
$this->writeJsonToCache();
|
||||
}
|
||||
@@ -270,8 +245,7 @@ class EntityItem
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function get_result($entityType = false, $idx = 0)
|
||||
{
|
||||
public function get_result($entityType = false, $idx = 0) {
|
||||
if ($entityType === false) {
|
||||
$entityType = $this->type;
|
||||
}
|
||||
@@ -293,8 +267,7 @@ class EntityItem
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get_body()
|
||||
{
|
||||
public function get_body() {
|
||||
$body = array();
|
||||
if (!is_null($this->type)) {
|
||||
$body["type"] = $this->type;
|
||||
@@ -328,13 +301,11 @@ class EntityItem
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function get_jsonBody()
|
||||
{
|
||||
public function get_jsonBody() {
|
||||
return Utility::json_encode($this->get_body());
|
||||
}
|
||||
|
||||
public function select()
|
||||
{
|
||||
public function select() {
|
||||
$arr_columns = func_get_args();
|
||||
if (count($arr_columns) == 1 && is_array($arr_columns[0])) {
|
||||
$arr_columns = $arr_columns[0];
|
||||
@@ -370,95 +341,77 @@ class EntityItem
|
||||
return $Ret->is_OK() ? $Ret->get_data() : null;
|
||||
}
|
||||
|
||||
public function get_operation()
|
||||
{
|
||||
public function get_operation() {
|
||||
return $this->operation;
|
||||
}
|
||||
|
||||
public function operation($operation)
|
||||
{
|
||||
public function operation($operation) {
|
||||
$this->operation = $operation;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function is_insert()
|
||||
{
|
||||
public function is_insert() {
|
||||
return $this->operation == self::INSERT;
|
||||
}
|
||||
|
||||
public function is_update()
|
||||
{
|
||||
public function is_update() {
|
||||
return $this->operation == self::UPDATE;
|
||||
}
|
||||
|
||||
public function is_insert_or_update()
|
||||
{
|
||||
public function is_insert_or_update() {
|
||||
return $this->operation == self::INSERT_OR_UPDATE;
|
||||
}
|
||||
|
||||
public function is_delete()
|
||||
{
|
||||
public function is_delete() {
|
||||
return $this->operation == self::DELETE;
|
||||
}
|
||||
|
||||
public function is_substitute()
|
||||
{
|
||||
public function is_substitute() {
|
||||
return $this->operation == self::SUBSTITUTE;
|
||||
}
|
||||
|
||||
public function is_no_op()
|
||||
{
|
||||
public function is_no_op() {
|
||||
return $this->operation == self::NO_OP;
|
||||
}
|
||||
|
||||
public function insert()
|
||||
{
|
||||
public function insert() {
|
||||
return $this->operation(self::INSERT);
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
public function update() {
|
||||
return $this->operation(self::UPDATE);
|
||||
}
|
||||
|
||||
public function insert_or_update()
|
||||
{
|
||||
public function insert_or_update() {
|
||||
return $this->operation(self::INSERT_OR_UPDATE);
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
public function delete() {
|
||||
return $this->operation(self::DELETE);
|
||||
}
|
||||
|
||||
public function substitute()
|
||||
{
|
||||
public function substitute() {
|
||||
return $this->operation(self::SUBSTITUTE);
|
||||
}
|
||||
|
||||
public function select_object()
|
||||
{
|
||||
public function select_object() {
|
||||
return $this->operation(self::SELECT_OBJECT);
|
||||
}
|
||||
|
||||
public function select_entity()
|
||||
{
|
||||
public function select_entity() {
|
||||
return $this->operation(self::SELECT);
|
||||
}
|
||||
|
||||
public function no_op()
|
||||
{
|
||||
public function no_op() {
|
||||
return $this->operation(self::NO_OP);
|
||||
}
|
||||
|
||||
public function cacheFile($prefix = true)
|
||||
{
|
||||
public function cacheFile($prefix = true) {
|
||||
$this->cacheFile = $prefix;
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function writeJsonToCache()
|
||||
{
|
||||
private function writeJsonToCache() {
|
||||
if (is_string($this->cacheFile)) {
|
||||
$filename = $this->cacheFile;
|
||||
|
||||
@@ -475,20 +428,17 @@ class EntityItem
|
||||
}
|
||||
}
|
||||
|
||||
class EntityArray
|
||||
{
|
||||
class EntityArray {
|
||||
private $children = array();
|
||||
private $type = null;
|
||||
|
||||
public function __construct($type = null)
|
||||
{
|
||||
public function __construct($type = null) {
|
||||
if (!is_null($type)) {
|
||||
$this->type($type);
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
public function __toString() {
|
||||
$arr_body = array();
|
||||
foreach ($this->get_children() as $EntityItem) {
|
||||
$arr_body[] = $EntityItem->get_body();
|
||||
@@ -496,20 +446,17 @@ class EntityArray
|
||||
return json_encode($arr_body);
|
||||
}
|
||||
|
||||
public function type($type)
|
||||
{
|
||||
public function type($type) {
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function append($EntityItem)
|
||||
{
|
||||
public function append($EntityItem) {
|
||||
$this->children[] = $EntityItem;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get_children()
|
||||
{
|
||||
public function get_children() {
|
||||
return $this->children;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
class EntityList{
|
||||
|
||||
class EntityList {
|
||||
private $endPoint = null;
|
||||
private $profileDB = null;
|
||||
private $entityItems = array();
|
||||
@@ -8,100 +9,101 @@ class EntityList{
|
||||
private $authPassword = null;
|
||||
private $anonymousAuth = false;
|
||||
private $cacheFile = false;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
$arr_entityItem = func_get_args();
|
||||
foreach($arr_entityItem as $EntityItem){
|
||||
foreach ($arr_entityItem as $EntityItem) {
|
||||
$this->push($EntityItem);
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString(){
|
||||
|
||||
public function __toString() {
|
||||
return self::get_jsonBody();
|
||||
}
|
||||
|
||||
public function cacheFile($prefix = true){
|
||||
|
||||
public function cacheFile($prefix = true) {
|
||||
$this->cacheFile = $prefix;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get_jsonBody(){
|
||||
|
||||
public function get_jsonBody() {
|
||||
return json_encode($this->get_body());
|
||||
}
|
||||
|
||||
public function profileDB($value){
|
||||
|
||||
public function profileDB($value) {
|
||||
$this->profileDB = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function endPoint($endPoint){
|
||||
|
||||
public function endPoint($endPoint) {
|
||||
$this->endPoint = $endPoint;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function authUsername($value){
|
||||
|
||||
public function authUsername($value) {
|
||||
$this->authUsername = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function authPassword($value){
|
||||
|
||||
public function authPassword($value) {
|
||||
$this->authPassword = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function anonymousAuth($value = true){
|
||||
|
||||
public function anonymousAuth($value = true) {
|
||||
$this->anonymousAuth = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function push(){
|
||||
|
||||
public function push() {
|
||||
$arr_entityItem = func_get_args();
|
||||
foreach($arr_entityItem as $EntityItem){
|
||||
if(\EntityItem::is_entityItem($EntityItem)){
|
||||
foreach ($arr_entityItem as $EntityItem) {
|
||||
if (\EntityItem::is_entityItem($EntityItem)) {
|
||||
$this->entityItems[] = $EntityItem;
|
||||
if(!is_null($EntityItem->endPoint)){
|
||||
if (!is_null($EntityItem->endPoint)) {
|
||||
$this->endPoint($EntityItem->endPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get_body(){
|
||||
|
||||
public function get_body() {
|
||||
$body = array();
|
||||
foreach($this->entityItems as $EntityItem){
|
||||
foreach ($this->entityItems as $EntityItem) {
|
||||
$body[] = $EntityItem->get_body();
|
||||
}
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function get_result($entityType = false, $idx = null){
|
||||
if($entityType===false){
|
||||
|
||||
public function get_result($entityType = false, $idx = null) {
|
||||
if ($entityType === false) {
|
||||
$result = $this->entityResult;
|
||||
|
||||
} else{
|
||||
$result = array_values(from($this->entityResult)->where(function($x) use($entityType){ return $x["type"] == $entityType; })->toArray());
|
||||
|
||||
} else {
|
||||
$result = array_values(from($this->entityResult)->where(function ($x) use ($entityType) {
|
||||
return $x["type"] == $entityType;
|
||||
})->toArray());
|
||||
}
|
||||
|
||||
if(isset($result) && count($result)>0){
|
||||
if(!is_null($idx)){
|
||||
if(isset($result[$idx])){
|
||||
|
||||
if (isset($result) && count($result) > 0) {
|
||||
if (!is_null($idx)) {
|
||||
if (isset($result[$idx])) {
|
||||
return $result[$idx];
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function count(){
|
||||
|
||||
public function count() {
|
||||
return count($this->entityItems);
|
||||
}
|
||||
|
||||
public function send()
|
||||
{
|
||||
public function send() {
|
||||
$Ret = new Ret;
|
||||
if (count($this->entityItems) > 0) {
|
||||
|
||||
@@ -148,8 +150,8 @@ class EntityList{
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function is_entityList($value){
|
||||
return gettype($value)=="object" && get_class($value)=="EntityList";
|
||||
|
||||
public static function is_entityList($value) {
|
||||
return gettype($value) == "object" && get_class($value) == "EntityList";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
class ErrorHandler{
|
||||
|
||||
class ErrorHandler {
|
||||
const EMSCONNECT = 0;
|
||||
const EMSHTTP = 1;
|
||||
const EMSHTTP400 = 2;
|
||||
@@ -12,7 +13,7 @@ class ErrorHandler{
|
||||
const UNAUTHORIZED_USER = 9;
|
||||
const FAIL_IMAGERESIZE = 10;
|
||||
const UNEXPECTED_METHOD = 11;
|
||||
|
||||
|
||||
// apixu (deprecated)
|
||||
const APIXU_MISSING_INVALID_KEY = 1002;
|
||||
const APIXU_MISSING_Q = 1003;
|
||||
@@ -23,149 +24,148 @@ class ErrorHandler{
|
||||
const APIXU_EXCEED_QUOTA = 2007;
|
||||
const APIXU_DISABLED_KEY = 2008;
|
||||
const APIXU_INTERNAL_ERROR = 9999;
|
||||
|
||||
|
||||
|
||||
|
||||
// reCAPTCHA
|
||||
const MISSINGINPUTSECRET = "missing-input-secret";
|
||||
const INVALIDINPUTSECRET = "invalid-input-secret";
|
||||
const MISSINGINPUTRESPONSE = "missing-input-response";
|
||||
const INVALIDINPUTRESPONSE = "invalid-input-response";
|
||||
const INVALIDINPUTRESPONSE = "invalid-input-response";
|
||||
const BADREQUEST = "bad-request";
|
||||
|
||||
public static function get_message($errorCode, $p1 = null, $p2 = null, $p3 = null){
|
||||
|
||||
public static function get_message($errorCode, $p1 = null, $p2 = null, $p3 = null) {
|
||||
// sostituito switch/case con if/elseif perche non veniva cfatta la comparazione col tipo
|
||||
if($errorCode===self::EMSCONNECT){
|
||||
return (!is_null($p1)?"<span class='text-monospace'>Servizio <b>{$p1}</b></span><hr class='mt-0 mb-10'/>":"")
|
||||
."Il servizio EMS non è raggiungibile";
|
||||
|
||||
} else if($errorCode===self::EMSHTTP){
|
||||
return (!is_null($p1)?"<span class='text-monospace'>Servizio <b>{$p3}</b></span><hr class='mt-0 mb-10'/>":"")
|
||||
."La chiamata al servizio ha restituito l'errore http <u>".blankIfNull($p1)."</u>".(!is_null($p2)?"<div class='mt-10 text-muted text-monospace small'>{$p2}</div>":"");
|
||||
|
||||
} else if($errorCode===self::EMSHTTP400){
|
||||
return (!is_null($p1)?"<span class='text-monospace'>Servizio <b>{$p1}</b></span><hr class='mt-0 mb-10'/>":"")
|
||||
."La chiamata al servizio ha restituito l'errore http <u>400</u> (Bad Request)";
|
||||
|
||||
} else if($errorCode===self::EMSPARSE){
|
||||
return (!is_null($p1)?"<span class='text-monospace'>Servizio <b>{$p1}</b></span><hr class='mt-0 mb-10'/>":"").
|
||||
"Parse della risposta del servizio <b>".blankIfNull($p1)."</b> fallita";
|
||||
|
||||
} else if($errorCode===self::EMSNOMESSAGE){
|
||||
return (!is_null($p1)?"<span class='text-monospace'>Servizio <b>{$p1}</b></span><hr class='mt-0 mb-10'/>":"")
|
||||
."Messaggio di errore non pervenuto";
|
||||
|
||||
} else if($errorCode===self::MISSINGINPUTSECRET){
|
||||
if ($errorCode === self::EMSCONNECT) {
|
||||
return (!is_null($p1) ? "<span class='text-monospace'>Servizio <b>{$p1}</b></span><hr class='mt-0 mb-10'/>" : "")
|
||||
. "Il servizio EMS non è raggiungibile";
|
||||
|
||||
} else if ($errorCode === self::EMSHTTP) {
|
||||
return (!is_null($p1) ? "<span class='text-monospace'>Servizio <b>{$p3}</b></span><hr class='mt-0 mb-10'/>" : "")
|
||||
. "La chiamata al servizio ha restituito l'errore http <u>" . blankIfNull($p1) . "</u>" . (!is_null($p2) ? "<div class='mt-10 text-muted text-monospace small'>{$p2}</div>" : "");
|
||||
|
||||
} else if ($errorCode === self::EMSHTTP400) {
|
||||
return (!is_null($p1) ? "<span class='text-monospace'>Servizio <b>{$p1}</b></span><hr class='mt-0 mb-10'/>" : "")
|
||||
. "La chiamata al servizio ha restituito l'errore http <u>400</u> (Bad Request)";
|
||||
|
||||
} else if ($errorCode === self::EMSPARSE) {
|
||||
return (!is_null($p1) ? "<span class='text-monospace'>Servizio <b>{$p1}</b></span><hr class='mt-0 mb-10'/>" : "") .
|
||||
"Parse della risposta del servizio <b>" . blankIfNull($p1) . "</b> fallita";
|
||||
|
||||
} else if ($errorCode === self::EMSNOMESSAGE) {
|
||||
return (!is_null($p1) ? "<span class='text-monospace'>Servizio <b>{$p1}</b></span><hr class='mt-0 mb-10'/>" : "")
|
||||
. "Messaggio di errore non pervenuto";
|
||||
|
||||
} else if ($errorCode === self::MISSINGINPUTSECRET) {
|
||||
return "Parametro secret mancante";
|
||||
|
||||
} else if($errorCode===self::INVALIDINPUTSECRET){
|
||||
|
||||
} else if ($errorCode === self::INVALIDINPUTSECRET) {
|
||||
return "Parametro secret mancante o non valido";
|
||||
|
||||
} else if($errorCode===self::MISSINGINPUTRESPONSE){
|
||||
|
||||
} else if ($errorCode === self::MISSINGINPUTRESPONSE) {
|
||||
return "Parametro response mancante";
|
||||
|
||||
} else if($errorCode===self::INVALIDINPUTRESPONSE){
|
||||
|
||||
} else if ($errorCode === self::INVALIDINPUTRESPONSE) {
|
||||
return "Parametro response mancante o non valido";
|
||||
|
||||
} else if($errorCode===self::BADREQUEST){
|
||||
|
||||
} else if ($errorCode === self::BADREQUEST) {
|
||||
return "La richiesta non è valida";
|
||||
|
||||
} else if($errorCode===self::UNEXPECTED_AJAX_METHOD){
|
||||
|
||||
} else if ($errorCode === self::UNEXPECTED_AJAX_METHOD) {
|
||||
$body = $_SERVER["REQUEST_METHOD"] === "POST" ? $_POST : $_GET;
|
||||
unset($body["_"]);
|
||||
$method = count($body)>0 ? "<i>".implode(", ", array_keys($body))."</i>" : "ajax";
|
||||
$method = count($body) > 0 ? "<i>" . implode(", ", array_keys($body)) . "</i>" : "ajax";
|
||||
return "Il metodo richiesto {$method} non è previsto";
|
||||
|
||||
} else if($errorCode===self::MISSING_SETUP){
|
||||
|
||||
} else if ($errorCode === self::MISSING_SETUP) {
|
||||
$message = self::getGestSetupMissingInfo($p1);
|
||||
if(!is_null($message)){
|
||||
if (!is_null($message)) {
|
||||
return $message;
|
||||
|
||||
} else if(!is_null($p1) && is_string($p1)){
|
||||
|
||||
} else if (!is_null($p1) && is_string($p1)) {
|
||||
return "Il parametro <i>{$p1}</i> non è stato configurato";
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
return "Un parametro del modulo corrente non è stato configurato";
|
||||
}
|
||||
|
||||
} else if($errorCode===self::INVALID_REPORT){
|
||||
|
||||
} else if ($errorCode === self::INVALID_REPORT) {
|
||||
$message = self::getGestSetupMissingInfo($p1);
|
||||
if(!is_null($message)){
|
||||
return "Il report non risulta esser stato configurato:<br/>".$message;
|
||||
|
||||
} else{
|
||||
return "Il report ".((!is_null($p1) && is_string($p1))?"<i>{$p1}</i>":"")." non è valido";
|
||||
if (!is_null($message)) {
|
||||
return "Il report non risulta esser stato configurato:<br/>" . $message;
|
||||
|
||||
} else {
|
||||
return "Il report " . ((!is_null($p1) && is_string($p1)) ? "<i>{$p1}</i>" : "") . " non è valido";
|
||||
}
|
||||
|
||||
} else if($errorCode===self::NORESULT_REPORT){
|
||||
|
||||
} else if ($errorCode === self::NORESULT_REPORT) {
|
||||
return "Il report non ha generato alcun risultato";
|
||||
|
||||
} else if($errorCode===self::UNAUTHORIZED_USER){
|
||||
|
||||
} else if ($errorCode === self::UNAUTHORIZED_USER) {
|
||||
return "La procedura non è abilitata all'utente";
|
||||
|
||||
} else if($errorCode===self::FAIL_IMAGERESIZE){
|
||||
|
||||
} else if ($errorCode === self::FAIL_IMAGERESIZE) {
|
||||
return "Ridimensionamento immagine fallito";
|
||||
}
|
||||
else if($errorCode===self::APIXU_MISSING_INVALID_KEY){
|
||||
} else if ($errorCode === self::APIXU_MISSING_INVALID_KEY) {
|
||||
return "La chiave API non è valida o non è stata specificata";
|
||||
|
||||
} else if($errorCode===self::APIXU_MISSING_Q){
|
||||
|
||||
} else if ($errorCode === self::APIXU_MISSING_Q) {
|
||||
return "Il parametro q non è stato specificato";
|
||||
} else if($errorCode===self::APIXU_INVALID_URL){
|
||||
} else if ($errorCode === self::APIXU_INVALID_URL) {
|
||||
return "L'url della richiesta non è valido";
|
||||
} else if($errorCode===self::APIXU_LOCATION_NOT_FOUND){
|
||||
} else if ($errorCode === self::APIXU_LOCATION_NOT_FOUND) {
|
||||
return "Luogo non trovato";
|
||||
} else if($errorCode===self::APIXU_DAY_UNAVAILABLE){
|
||||
} else if ($errorCode === self::APIXU_DAY_UNAVAILABLE) {
|
||||
return "Il meteo non è disponibile alla data selezionata";
|
||||
} else if($errorCode===self::APIXU_INVALID_KEY){
|
||||
} else if ($errorCode === self::APIXU_INVALID_KEY) {
|
||||
return "La chiave API non è valida";
|
||||
} else if($errorCode===self::APIXU_EXCEED_QUOTA){
|
||||
} else if ($errorCode === self::APIXU_EXCEED_QUOTA) {
|
||||
return "La chiave API ha superato il numero massimo di richieste consentite";
|
||||
} else if($errorCode===self::APIXU_DISABLED_KEY){
|
||||
} else if ($errorCode === self::APIXU_DISABLED_KEY) {
|
||||
return "La chiave API non è abilitata";
|
||||
} else if($errorCode===self::APIXU_INTERNAL_ERROR){
|
||||
} else if ($errorCode === self::APIXU_INTERNAL_ERROR) {
|
||||
return "Si è verificato un errore di applicazione interno";
|
||||
} else{
|
||||
} else {
|
||||
return "Si è verificato un errore non codificato";
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static function getGestSetupMissingInfo($GestSetup){
|
||||
if(\GestSetup::isGestSetupObject($GestSetup)){
|
||||
|
||||
private static function getGestSetupMissingInfo($GestSetup) {
|
||||
if (\GestSetup::isGestSetupObject($GestSetup)) {
|
||||
$description = $GestSetup->getDescription();
|
||||
|
||||
$message = "<span class='small font-italic text-uppercase'>".$GestSetup->getGestName()." > ".$GestSetup->getSection()." > <b>".$GestSetup->getKeySection()."</b></span>";
|
||||
if(!is_null($description)){
|
||||
$message .= " <span class='text-xs opacity-90 font-italic'>(".ucfirst($description).")</span>";
|
||||
|
||||
$message = "<span class='small font-italic text-uppercase'>" . $GestSetup->getGestName() . " > " . $GestSetup->getSection() . " > <b>" . $GestSetup->getKeySection() . "</b></span>";
|
||||
if (!is_null($description)) {
|
||||
$message .= " <span class='text-xs opacity-90 font-italic'>(" . ucfirst($description) . ")</span>";
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function get_title($errorCode, $p1 = null, $p2 = null, $p3 = null){
|
||||
if(in_array($errorCode, array(self::EMSHTTP400, self::EMSHTTP, self::EMSPARSE, self::EMSNOMESSAGE, self::EMSCONNECT))){
|
||||
|
||||
public static function get_title($errorCode, $p1 = null, $p2 = null, $p3 = null) {
|
||||
if (in_array($errorCode, array(self::EMSHTTP400, self::EMSHTTP, self::EMSPARSE, self::EMSNOMESSAGE, self::EMSCONNECT))) {
|
||||
return "Servizio non disponibile";
|
||||
|
||||
} else if(in_array($errorCode, array(self::UNEXPECTED_AJAX_METHOD, self::UNEXPECTED_METHOD))){
|
||||
|
||||
} else if (in_array($errorCode, array(self::UNEXPECTED_AJAX_METHOD, self::UNEXPECTED_METHOD))) {
|
||||
return "Operazione non valida";
|
||||
|
||||
} else if(in_array($errorCode, array(self::MISSING_SETUP))){
|
||||
|
||||
} else if (in_array($errorCode, array(self::MISSING_SETUP))) {
|
||||
return "Configurazione setup incompleta";
|
||||
|
||||
} else if(in_array($errorCode, array(self::INVALID_REPORT))){
|
||||
|
||||
} else if (in_array($errorCode, array(self::INVALID_REPORT))) {
|
||||
return "Report non configurato";
|
||||
|
||||
} else if(in_array($errorCode, array(self::NORESULT_REPORT))){
|
||||
|
||||
} else if (in_array($errorCode, array(self::NORESULT_REPORT))) {
|
||||
return "Report non generato";
|
||||
|
||||
} else if(in_array($errorCode, array(self::UNAUTHORIZED_USER))){
|
||||
|
||||
} else if (in_array($errorCode, array(self::UNAUTHORIZED_USER))) {
|
||||
return "Utente non autorizzato";
|
||||
|
||||
} else if(in_array($errorCode, array(self::APIXU_MISSING_INVALID_KEY, self::APIXU_MISSING_Q, self::APIXU_INVALID_URL, self::APIXU_LOCATION_NOT_FOUND, self::APIXU_DAY_UNAVAILABLE, self::APIXU_INVALID_KEY, self::APIXU_EXCEED_QUOTA, self::APIXU_DISABLED_KEY, self::APIXU_INTERNAL_ERROR))){
|
||||
|
||||
} else if (in_array($errorCode, array(self::APIXU_MISSING_INVALID_KEY, self::APIXU_MISSING_Q, self::APIXU_INVALID_URL, self::APIXU_LOCATION_NOT_FOUND, self::APIXU_DAY_UNAVAILABLE, self::APIXU_INVALID_KEY, self::APIXU_EXCEED_QUOTA, self::APIXU_DISABLED_KEY, self::APIXU_INTERNAL_ERROR))) {
|
||||
return "Servizio meteo non disponibile";
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
<?php
|
||||
|
||||
class EscposPrinter{
|
||||
class EscposPrinter {
|
||||
private $tempFile = null;
|
||||
private $instance = null;
|
||||
private $html = null;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
$this->init_instance();
|
||||
$this->html = "";
|
||||
}
|
||||
|
||||
public function init_instance(){
|
||||
|
||||
public function init_instance() {
|
||||
$this->tempFile = Cache::tempFile();
|
||||
$connector = new Mike42\Escpos\PrintConnectors\FilePrintConnector($this->tempFile);
|
||||
// $connector = new Mike42\Escpos\PrintConnectors\NetworkPrintConnector("127.0.0.1", 9100);
|
||||
// $connector = new Mike42\Escpos\PrintConnectors\NetworkPrintConnector("127.0.0.1", 9100);
|
||||
$this->instance = new Mike42\Escpos\Printer($connector);
|
||||
}
|
||||
|
||||
public function get_blob(){
|
||||
if(!is_null($this->tempFile) && file_exists($this->tempFile)){
|
||||
|
||||
public function get_blob() {
|
||||
if (!is_null($this->tempFile) && file_exists($this->tempFile)) {
|
||||
return file_get_contents($this->tempFile);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function to_html(){
|
||||
|
||||
public function to_html() {
|
||||
return $this->html;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// <editor-fold desc="FUNZIONI Mike42\Escpos" defaultstate="collapsed">
|
||||
const MODE_DOUBLE_WIDTH = Mike42\Escpos\Printer::MODE_DOUBLE_WIDTH;
|
||||
const MODE_FONT_A = Mike42\Escpos\Printer::MODE_FONT_A;
|
||||
@@ -36,32 +36,39 @@ class EscposPrinter{
|
||||
const JUSTIFY_LEFT = Mike42\Escpos\Printer::JUSTIFY_LEFT;
|
||||
const JUSTIFY_CENTER = Mike42\Escpos\Printer::JUSTIFY_CENTER;
|
||||
const JUSTIFY_RIGHT = Mike42\Escpos\Printer::JUSTIFY_RIGHT;
|
||||
public function feed($lines = 1){
|
||||
|
||||
public function feed($lines = 1) {
|
||||
$this->instance->feed($lines);
|
||||
return $this;
|
||||
}
|
||||
public function text($str = ""){
|
||||
|
||||
public function text($str = "") {
|
||||
$this->instance->text($str);
|
||||
$this->html .= str_replace(" ", " ", str_replace("\n", "<br/>", $str));
|
||||
return $this;
|
||||
}
|
||||
public function selectPrintMode($mode = self::MODE_FONT_A){
|
||||
|
||||
public function selectPrintMode($mode = self::MODE_FONT_A) {
|
||||
$this->instance->selectPrintMode($mode);
|
||||
return $this;
|
||||
}
|
||||
public function setEmphasis($on = true){
|
||||
|
||||
public function setEmphasis($on = true) {
|
||||
$this->instance->setEmphasis($on);
|
||||
return $this;
|
||||
}
|
||||
public function setJustification($justification = self::JUSTIFY_LEFT){
|
||||
|
||||
public function setJustification($justification = self::JUSTIFY_LEFT) {
|
||||
$this->instance->setJustification($justification);
|
||||
return $this;
|
||||
}
|
||||
public function cut($mode = Mike42\Escpos\Printer::CUT_FULL, $lines = 3){
|
||||
|
||||
public function cut($mode = Mike42\Escpos\Printer::CUT_FULL, $lines = 3) {
|
||||
$this->instance->cut($mode, $lines);
|
||||
return $this;
|
||||
}
|
||||
public function close(){
|
||||
|
||||
public function close() {
|
||||
$this->instance->close();
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
class FileExchange{
|
||||
|
||||
class FileExchange {
|
||||
// <editor-fold desc="PARAMETERS" defaultstate="collapsed">
|
||||
private $profileDB = null;
|
||||
private $codMdep = null;
|
||||
private $filename = null;
|
||||
private $subDirs = null;
|
||||
private $content = null;
|
||||
|
||||
|
||||
private $urlService = null;
|
||||
private $action = null;
|
||||
private $asServer = false;
|
||||
@@ -14,49 +15,58 @@ class FileExchange{
|
||||
private $contentHash = null;
|
||||
// </editor-fold>
|
||||
// <editor-fold desc="SETTERS" defaultstate="collapsed">
|
||||
public function profileDB($value){
|
||||
public function profileDB($value) {
|
||||
$this->profileDB = $value;
|
||||
return $this;
|
||||
}
|
||||
public function codMdep($value){
|
||||
|
||||
public function codMdep($value) {
|
||||
$this->codMdep = $value;
|
||||
return $this;
|
||||
}
|
||||
public function subDirs($value){
|
||||
|
||||
public function subDirs($value) {
|
||||
$this->subDirs = $value;
|
||||
return $this;
|
||||
}
|
||||
public function filename($value){
|
||||
|
||||
public function filename($value) {
|
||||
$this->filename = $value;
|
||||
return $this;
|
||||
}
|
||||
public function content($value){
|
||||
|
||||
public function content($value) {
|
||||
$this->content = base64_encode(Utility\Compression\GZ::encode($value));
|
||||
$this->contentSize = Utility::blobSize($value);
|
||||
$this->contentHash = $this->get_blobHash($value);
|
||||
return $this;
|
||||
}
|
||||
public function urlService($value){
|
||||
|
||||
public function urlService($value) {
|
||||
$this->urlService = $value;
|
||||
return $this;
|
||||
}
|
||||
public function asServer($value = true){
|
||||
|
||||
public function asServer($value = true) {
|
||||
$this->asServer = $value;
|
||||
return $this;
|
||||
}
|
||||
public function upload(){
|
||||
|
||||
public function upload() {
|
||||
$this->action = "upload";
|
||||
return $this;
|
||||
}
|
||||
public function download(){
|
||||
|
||||
public function download() {
|
||||
$this->action = "download";
|
||||
return $this;
|
||||
}
|
||||
public function getLog(){
|
||||
|
||||
public function getLog() {
|
||||
$this->action = "get_log";
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
// </editor-fold>
|
||||
// <editor-fold desc="GETTERS" defaultstate="collapsed">
|
||||
/*
|
||||
@@ -67,58 +77,59 @@ class FileExchange{
|
||||
return strlen($byte);
|
||||
}
|
||||
}*/
|
||||
|
||||
private function get_blobHash($byte){
|
||||
|
||||
private function get_blobHash($byte) {
|
||||
return strtolower(md5($byte));
|
||||
}
|
||||
|
||||
private function get_urlService(){
|
||||
if(!is_null($this->urlService)){
|
||||
|
||||
private function get_urlService() {
|
||||
if (!is_null($this->urlService)) {
|
||||
return $this->urlService;
|
||||
}
|
||||
return self::get_defaultUrlService();
|
||||
}
|
||||
|
||||
public static function get_defaultUrlService(){
|
||||
if(PVM::isDevClient()){
|
||||
|
||||
public static function get_defaultUrlService() {
|
||||
if (PVM::isDevClient()) {
|
||||
return "http://192.168.2.26/sync/filesync.php";
|
||||
// return "http://127.0.0.1/sync/filesync.php";
|
||||
// return "http://127.0.0.1/sync/filesync.php";
|
||||
}
|
||||
$GestSetup = new GestSetup;
|
||||
return $GestSetup->gest_name("INTEGRETAIL")->section("SYNC")->keySection("ENDPOINT_WEB")->get();
|
||||
}
|
||||
|
||||
private function get_profileDb(){
|
||||
if(is_null($this->profileDB)){
|
||||
|
||||
private function get_profileDb() {
|
||||
if (is_null($this->profileDB)) {
|
||||
return User::get_current_profileDb();
|
||||
}
|
||||
return $this->profileDB;
|
||||
}
|
||||
|
||||
private function get_codMdep(){
|
||||
if(is_null($this->codMdep)){
|
||||
|
||||
private function get_codMdep() {
|
||||
if (is_null($this->codMdep)) {
|
||||
return User::get_current_userCodMdep();
|
||||
}
|
||||
return $this->codMdep;
|
||||
}
|
||||
|
||||
private function get_mode(){
|
||||
|
||||
private function get_mode() {
|
||||
return $this->asServer === true ? "SERVER" : "CLIENT";
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
public function send(){
|
||||
|
||||
public function send() {
|
||||
$Ret = new Ret;
|
||||
$action = $this->action;
|
||||
if(!is_null($action)){
|
||||
try{
|
||||
if (!is_null($action)) {
|
||||
try {
|
||||
$data = array(
|
||||
"action" => $action,
|
||||
"profileDB" => $this->get_profileDb(),
|
||||
"cod_mdep" => $this->get_codMdep()
|
||||
);
|
||||
|
||||
if($action=="upload"){
|
||||
|
||||
if ($action == "upload") {
|
||||
$data = array_merge($data, array(
|
||||
"hash" => $this->contentHash,
|
||||
"size" => $this->contentSize,
|
||||
@@ -128,39 +139,39 @@ class FileExchange{
|
||||
"content" => $this->content
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
$url = $this->get_urlService();
|
||||
if(!is_null($url)){
|
||||
|
||||
if (!is_null($url)) {
|
||||
|
||||
$Httpful = Httpful\Request::init();
|
||||
|
||||
if($action=="upload"){
|
||||
|
||||
if ($action == "upload") {
|
||||
$Httpful->method(Httpful\Http::POST)
|
||||
->uri($url)
|
||||
->sendsType(Httpful\Mime::FORM)
|
||||
->body(http_build_query(array("data" => Utility::B64JSON_stringify($data))));
|
||||
|
||||
}else{ // download / get_log
|
||||
$url .= "?".http_build_query(array("data" => Utility::B64JSON_stringify($data)));
|
||||
->uri($url)
|
||||
->sendsType(Httpful\Mime::FORM)
|
||||
->body(http_build_query(array("data" => Utility::B64JSON_stringify($data))));
|
||||
|
||||
} else { // download / get_log
|
||||
$url .= "?" . http_build_query(array("data" => Utility::B64JSON_stringify($data)));
|
||||
$Httpful->method(Httpful\Http::GET)->uri($url);
|
||||
}
|
||||
|
||||
|
||||
$response = $Httpful->send();
|
||||
if($response->code==200){
|
||||
if ($response->code == 200) {
|
||||
$Ret->parse($response->raw_body);
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_errorCode(ErrorHandler::EMSHTTP, $response->code);
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("Url del servizio FileExchange nullo");
|
||||
}
|
||||
} catch(Httpful\Exception\ConnectionErrorException $e){
|
||||
$Ret->set_error("Servizio FileExchange non disponibile (".$e->getMessage().")");
|
||||
} catch(Exception $e){
|
||||
} catch (Httpful\Exception\ConnectionErrorException $e) {
|
||||
$Ret->set_error("Servizio FileExchange non disponibile (" . $e->getMessage() . ")");
|
||||
} catch (Exception $e) {
|
||||
$Ret->set_error($e->getMessage());
|
||||
}
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Operazione servizio FileExchange non definita");
|
||||
}
|
||||
return $Ret;
|
||||
|
||||
@@ -1,42 +1,43 @@
|
||||
<?php
|
||||
class Format{
|
||||
|
||||
class Format {
|
||||
const EXCEL = "EXCEL";
|
||||
const PDF = "PDF";
|
||||
|
||||
|
||||
const IMS_NULL_STRING = "[NULL]";
|
||||
const IMS_NULL_ANY = "NULL";
|
||||
const IMS_NULL_TIME = "1900-01-01 00:00:00";
|
||||
|
||||
|
||||
const strtotimeDMY = "d/m/Y";
|
||||
const strtotimeDMYHMS = "d/m/Y H:i:s";
|
||||
const strtotimeDMYHM = "d/m/Y H:i";
|
||||
|
||||
|
||||
const strtotimeYMDHMS = "Y-m-d H:i:s";
|
||||
const strtotimeYMDHM = "Y-m-d H:i";
|
||||
const strtotimeYMD = "Y-m-d";
|
||||
|
||||
|
||||
const strtotimeHM = "H:i";
|
||||
const strtotimeHMS = "H:i:s";
|
||||
|
||||
|
||||
const strftimeYMD = "%Y-%m-%d";
|
||||
const strftimeSlashedYMD = "%Y/%m/%d";
|
||||
|
||||
const strftimeYMDHMS = "%Y-%m-%d %H:%M:%S";
|
||||
const strftimeYMDHM = "%Y-%m-%d %H:%M";
|
||||
|
||||
|
||||
const strftimeDMY = "%d/%m/%Y";
|
||||
const strftimeDMYHM = "%d/%m/%Y %H:%M";
|
||||
const strftimeDMYHMS = "%d/%m/%Y %H:%M:%S";
|
||||
|
||||
|
||||
const strftimeDMy = "%d/%m/%y";
|
||||
const strftimeDMYY = "%d/%m/%Y";
|
||||
const strftimeDMyHM = "%d/%m/%y %H:%M";
|
||||
const strftimeDMyHMS = "%d/%m/%y %H:%M:%S";
|
||||
|
||||
|
||||
const strftimeDM = "%d/%m";
|
||||
|
||||
|
||||
const strftimeHM = "%H:%M";
|
||||
const strftimeHMS = "%H:%M:%S";
|
||||
|
||||
|
||||
const latLng1 = "lat;lng";
|
||||
}
|
||||
@@ -1,32 +1,32 @@
|
||||
<?php
|
||||
class FotoArticoli{
|
||||
public static function resizeImage($blob, $fileName, $maxWidth, $maxHeight, $forceRewrite = false){
|
||||
|
||||
class FotoArticoli {
|
||||
public static function resizeImage($blob, $fileName, $maxWidth, $maxHeight, $forceRewrite = false) {
|
||||
$ret = false;
|
||||
$Image = new \Utility\Image;
|
||||
if($Image->importFromBlob($blob)){
|
||||
if ($Image->importFromBlob($blob)) {
|
||||
$Image->basename($fileName);
|
||||
if($Image->resize($maxWidth, $maxHeight, true, true, $forceRewrite)){
|
||||
if ($Image->resize($maxWidth, $maxHeight, true, true, $forceRewrite)) {
|
||||
$ret = $Image->get_fileCachedPath();
|
||||
} else{
|
||||
} else {
|
||||
//echo "no";exit;
|
||||
}
|
||||
}
|
||||
unset($Image);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private static function set_additionalInfo($item){
|
||||
|
||||
private static function set_additionalInfo($item) {
|
||||
$base_path_dest = PVM::isDevClient() ? "../" : "";
|
||||
$item["flag_exists"] = true;
|
||||
if(!is_null($item["path_link"])){
|
||||
$item["path_link"] = $base_path_dest."../".$item["path_link"];
|
||||
if (!is_null($item["path_link"])) {
|
||||
$item["path_link"] = $base_path_dest . "../" . $item["path_link"];
|
||||
$item["flag_exists"] = file_exists($item["path_link"]);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function get_photoArt($codMart, $idRiga = null)
|
||||
{
|
||||
public static function get_photoArt($codMart, $idRiga = null) {
|
||||
$Ret = MtbAartLink::get_items($codMart, $idRiga);
|
||||
if ($Ret->is_OK()) {
|
||||
$arr_rows = $Ret->get_data();
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
<?php
|
||||
class GestSetup{
|
||||
|
||||
class GestSetup {
|
||||
private $setupTable = "stb_gest_setup";
|
||||
|
||||
|
||||
private $profileDB;
|
||||
|
||||
|
||||
public $gest_name = null;
|
||||
public $section = null;
|
||||
public $key_section = null;
|
||||
|
||||
|
||||
private $default_value;
|
||||
private $asArray;
|
||||
private $asJson;
|
||||
@@ -18,281 +19,281 @@ class GestSetup{
|
||||
private $separator = "|";
|
||||
private $_currentModule = null;
|
||||
private $_caller = null;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
$this->init();
|
||||
}
|
||||
|
||||
public function init(){
|
||||
|
||||
public function init() {
|
||||
$this->_currentModule = Controller::current_module();
|
||||
$caller = debug_backtrace();
|
||||
if(isset($caller[3])){
|
||||
if (isset($caller[3])) {
|
||||
$this->_caller = $caller[3];
|
||||
}
|
||||
|
||||
|
||||
return $this->gest_name("PVM")
|
||||
// ->section(Controller::current_module())
|
||||
->keySection(null)
|
||||
->default_value(false)
|
||||
->asString();
|
||||
// ->section(Controller::current_module())
|
||||
->keySection(null)
|
||||
->default_value(false)
|
||||
->asString();
|
||||
}
|
||||
|
||||
private function getModulo(){
|
||||
|
||||
private function getModulo() {
|
||||
$caller = $this->_caller;
|
||||
$azienda = Config::get_azienda();
|
||||
if(isset($caller["class"])){
|
||||
if (isset($caller["class"])) {
|
||||
$callerClassName = strtolower(\Utility\Str::camelCaseDecode($caller["class"]));
|
||||
if(!is_null(AziendaUtils::getModulo($callerClassName, $azienda))){
|
||||
if (!is_null(AziendaUtils::getModulo($callerClassName, $azienda))) {
|
||||
return $callerClassName;
|
||||
}
|
||||
}
|
||||
return $this->_currentModule;
|
||||
}
|
||||
|
||||
public function profileDB($v){
|
||||
|
||||
public function profileDB($v) {
|
||||
$this->profileDB = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getGestName(){
|
||||
|
||||
public function getGestName() {
|
||||
return $this->gest_name;
|
||||
}
|
||||
|
||||
public function getSection(){
|
||||
if(is_null($this->section)){
|
||||
|
||||
public function getSection() {
|
||||
if (is_null($this->section)) {
|
||||
$this->section(strtoupper($this->getModulo()));
|
||||
}
|
||||
return $this->section;
|
||||
}
|
||||
|
||||
public function getKeySection(){
|
||||
|
||||
public function getKeySection() {
|
||||
return $this->key_section;
|
||||
}
|
||||
|
||||
public function getDescription(){
|
||||
|
||||
public function getDescription() {
|
||||
$Ret = self::getRecord();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$record = $Ret->get_data();
|
||||
if(!is_null($record)){
|
||||
return $record["description"];
|
||||
if (!is_null($record)) {
|
||||
return $record["description"];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function gest_name($v){
|
||||
* @deprecated
|
||||
*/
|
||||
public function gest_name($v) {
|
||||
return $this->gestName($v);
|
||||
}
|
||||
|
||||
public function gestName($v){
|
||||
|
||||
public function gestName($v) {
|
||||
$this->gest_name = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function section($v){
|
||||
|
||||
public function section($v) {
|
||||
$this->section = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function key_section($v){
|
||||
* @deprecated
|
||||
*/
|
||||
public function key_section($v) {
|
||||
return $this->keySection($v);
|
||||
}
|
||||
|
||||
public function keySection($v){
|
||||
|
||||
public function keySection($v) {
|
||||
$this->key_section = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function default_value($v){
|
||||
* @deprecated
|
||||
*/
|
||||
public function default_value($v) {
|
||||
return $this->defaultValue($v);
|
||||
}
|
||||
|
||||
public function defaultValue($v){
|
||||
|
||||
public function defaultValue($v) {
|
||||
$this->default_value = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function asString($v = true){
|
||||
if($v===true){
|
||||
|
||||
public function asString($v = true) {
|
||||
if ($v === true) {
|
||||
$this->asArray(false)->asFloat(false)->asInt(false)->asJson(false)->asBoolean(false);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function asArray($v = true){
|
||||
|
||||
public function asArray($v = true) {
|
||||
$this->asArray = $v;
|
||||
if($v===true){
|
||||
if ($v === true) {
|
||||
$this->asFloat(false)->asInt(false)->asJson(false)->asBoolean(false);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function asFloat($v = true){
|
||||
|
||||
public function asFloat($v = true) {
|
||||
$this->asFloat = $v;
|
||||
if($v===true){
|
||||
if ($v === true) {
|
||||
$this->asArray(false)->asInt(false)->asJson(false)->asBoolean(false);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function asInt($v = true){
|
||||
|
||||
public function asInt($v = true) {
|
||||
$this->asInt = $v;
|
||||
if($v===true){
|
||||
if ($v === true) {
|
||||
$this->asArray(false)->asFloat(false)->asJson(false)->asBoolean(false);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function asJson($v = true){
|
||||
|
||||
public function asJson($v = true) {
|
||||
$this->asJson = $v;
|
||||
if($v===true){
|
||||
if ($v === true) {
|
||||
$this->asArray(false)->asFloat(false)->asInt(false)->asBoolean(false);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function asBoolean($v = true){
|
||||
|
||||
public function asBoolean($v = true) {
|
||||
$this->asBoolean = $v;
|
||||
if($v===true){
|
||||
if ($v === true) {
|
||||
$this->asArray(false)->asFloat(false)->asInt(false)->asJson(false);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function parseValue($value){
|
||||
if($this->default_value===false){
|
||||
if($this->asBoolean===true){
|
||||
|
||||
public function parseValue($value) {
|
||||
if ($this->default_value === false) {
|
||||
if ($this->asBoolean === true) {
|
||||
$this->default_value("N"); // perchè boolval(null) = false
|
||||
|
||||
} else if($this->asArray===true){
|
||||
|
||||
} else if ($this->asArray === true) {
|
||||
$this->default_value(array());
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$this->default_value(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$value = nullIfBlank($value);
|
||||
if(is_null($value)){
|
||||
if (is_null($value)) {
|
||||
$value = $this->default_value;
|
||||
}
|
||||
|
||||
if(!is_null($value)){
|
||||
if($this->asArray===true){
|
||||
if(is_string($value)){
|
||||
if(strpos($value, $this->separator)===false){
|
||||
|
||||
if (!is_null($value)) {
|
||||
if ($this->asArray === true) {
|
||||
if (is_string($value)) {
|
||||
if (strpos($value, $this->separator) === false) {
|
||||
$this->separator = ",";
|
||||
}
|
||||
return explode($this->separator, $value);
|
||||
}
|
||||
|
||||
} else if($this->asJson===true){
|
||||
if(is_string($value)){
|
||||
|
||||
} else if ($this->asJson === true) {
|
||||
if (is_string($value)) {
|
||||
return @json_decode($value, true);
|
||||
}
|
||||
|
||||
} else if($this->asBoolean===true){
|
||||
|
||||
} else if ($this->asBoolean === true) {
|
||||
return boolValue($value);
|
||||
|
||||
} else if($this->asInt===true){
|
||||
if(is_numeric($value)){
|
||||
} else if ($this->asInt === true) {
|
||||
if (is_numeric($value)) {
|
||||
return intval($value);
|
||||
}
|
||||
|
||||
} else if($this->asFloat===true){
|
||||
if(is_numeric($value)){
|
||||
|
||||
} else if ($this->asFloat === true) {
|
||||
if (is_numeric($value)) {
|
||||
return floatval($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function getHash(){
|
||||
$rawString = !is_null($this->profileDB) ? $this->profileDB.";" : "";
|
||||
$rawString .= $this->gest_name.";";
|
||||
$rawString .= $this->getSection().";";
|
||||
|
||||
private function getHash() {
|
||||
$rawString = !is_null($this->profileDB) ? $this->profileDB . ";" : "";
|
||||
$rawString .= $this->gest_name . ";";
|
||||
$rawString .= $this->getSection() . ";";
|
||||
$rawString .= $this->key_section;
|
||||
return md5($rawString);
|
||||
}
|
||||
|
||||
private function getFromCache(){
|
||||
|
||||
private function getFromCache() {
|
||||
$hash = $this->getHash();
|
||||
if(!isset($GLOBALS[$this->setupTable])){
|
||||
if (!isset($GLOBALS[$this->setupTable])) {
|
||||
$GLOBALS[$this->setupTable] = array();
|
||||
}
|
||||
|
||||
if(array_key_exists($hash, $GLOBALS[$this->setupTable])){
|
||||
|
||||
if (array_key_exists($hash, $GLOBALS[$this->setupTable])) {
|
||||
$Ret = new Ret;
|
||||
return $Ret->set_data($GLOBALS[$this->setupTable][$hash]);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function cacheValue($value){
|
||||
|
||||
private function cacheValue($value) {
|
||||
$hash = $this->getHash();
|
||||
if(!isset($GLOBALS[$this->setupTable])){
|
||||
if (!isset($GLOBALS[$this->setupTable])) {
|
||||
$GLOBALS[$this->setupTable] = array();
|
||||
}
|
||||
$GLOBALS[$this->setupTable][$hash] = $value;
|
||||
}
|
||||
|
||||
private function getRecord(){
|
||||
|
||||
private function getRecord() {
|
||||
$Query = new Query;
|
||||
$Query->select(
|
||||
"CONVERT(TEXT, value) AS value",
|
||||
$this->setupTable.".description",
|
||||
"stb_gest_setup_query.cod_query",
|
||||
"stb_gest_setup_query.description AS query_description"
|
||||
)
|
||||
->from($this->setupTable." LEFT OUTER JOIN stb_gest_setup_query ON ".$this->setupTable.".query_default = stb_gest_setup_query.cod_query")
|
||||
->where("section", $this->getSection())
|
||||
->where("gest_name", $this->gest_name)
|
||||
->where("key_section", $this->key_section);
|
||||
if(!is_null($this->profileDB)){
|
||||
"CONVERT(TEXT, value) AS value",
|
||||
$this->setupTable . ".description",
|
||||
"stb_gest_setup_query.cod_query",
|
||||
"stb_gest_setup_query.description AS query_description"
|
||||
)
|
||||
->from($this->setupTable . " LEFT OUTER JOIN stb_gest_setup_query ON " . $this->setupTable . ".query_default = stb_gest_setup_query.cod_query")
|
||||
->where("section", $this->getSection())
|
||||
->where("gest_name", $this->gest_name)
|
||||
->where("key_section", $this->key_section);
|
||||
if (!is_null($this->profileDB)) {
|
||||
$Query->profileDB($this->profileDB);
|
||||
}
|
||||
|
||||
|
||||
$Ret = $Query->firstRow()->toRet()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$this->cacheValue($Ret->get_data());
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function get(){
|
||||
|
||||
public function get() {
|
||||
$Ret = $this->getFromCache();
|
||||
if(is_null($Ret)){
|
||||
if (is_null($Ret)) {
|
||||
$Ret = $this->getRecord();
|
||||
}
|
||||
|
||||
|
||||
$data = $Ret->is_OK() ? $Ret->get_data() : null;
|
||||
return $this->parseValue($data["value"]);
|
||||
}
|
||||
|
||||
public static function isGestSetupObject($value){
|
||||
return (gettype($value)=="object" && (get_class($value)=="GestSetup" || is_subclass_of($value, "GestSetup")));
|
||||
|
||||
public static function isGestSetupObject($value) {
|
||||
return (gettype($value) == "object" && (get_class($value) == "GestSetup" || is_subclass_of($value, "GestSetup")));
|
||||
}
|
||||
|
||||
public function set($value){
|
||||
|
||||
public function set($value) {
|
||||
$EntityItem = new \EntityItem($this->setupTable);
|
||||
$EntityItem->insert_or_update()
|
||||
->set("gestName", $this->gest_name)
|
||||
->set("section", $this->getSection())
|
||||
->set("keySection", $this->key_section)
|
||||
->set("value", $value);
|
||||
->set("gestName", $this->gest_name)
|
||||
->set("section", $this->getSection())
|
||||
->set("keySection", $this->key_section)
|
||||
->set("value", $value);
|
||||
return $EntityItem->send();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
<?php
|
||||
class GestSetupDepo extends GestSetup{
|
||||
|
||||
class GestSetupDepo extends GestSetup {
|
||||
private $setupTable = "stb_gest_setup_depo";
|
||||
private $codMdep = null;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
$this->init();
|
||||
}
|
||||
|
||||
public function init(){
|
||||
|
||||
public function init() {
|
||||
return parent::init()->cod_mdep(User::get_current_userCodMdep());
|
||||
}
|
||||
|
||||
public function cod_mdep($value){
|
||||
|
||||
public function cod_mdep($value) {
|
||||
$this->codMdep = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get(){
|
||||
|
||||
public function get() {
|
||||
$Query = new Query;
|
||||
$Query->select("CONVERT(TEXT, value) AS value")
|
||||
->from($this->setupTable)
|
||||
->where("cod_mdep", $this->codMdep)
|
||||
->where("section", $this->getSection())
|
||||
->where("gest_name", $this->gest_name)
|
||||
->where("key_section", $this->key_section);
|
||||
|
||||
->from($this->setupTable)
|
||||
->where("cod_mdep", $this->codMdep)
|
||||
->where("section", $this->getSection())
|
||||
->where("gest_name", $this->gest_name)
|
||||
->where("key_section", $this->key_section);
|
||||
|
||||
$Ret = $Query->firstRowFirstValue()->toRet()->execute();
|
||||
$value = $Ret->is_OK() ? $Ret->get_data() : null;
|
||||
return $this->parseValue($value);
|
||||
|
||||
@@ -1,70 +1,71 @@
|
||||
<?php
|
||||
class GestSetupWebUser extends GestSetup{
|
||||
|
||||
class GestSetupWebUser extends GestSetup {
|
||||
private $setupTable = "wtb_gest_setup_user";
|
||||
private $userName = null;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
$this->init();
|
||||
}
|
||||
|
||||
public function init(){
|
||||
|
||||
public function init() {
|
||||
return parent::init()->userName(User::get_current_username());
|
||||
}
|
||||
|
||||
public function userName($value){
|
||||
|
||||
public function userName($value) {
|
||||
$this->userName = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function check_userGrant(){
|
||||
if(!User::group_is(User::RESPONSABILE_EDP, User::AMMINISTRATORE_SISTEMA)){
|
||||
|
||||
private function check_userGrant() {
|
||||
if (!User::group_is(User::RESPONSABILE_EDP, User::AMMINISTRATORE_SISTEMA)) {
|
||||
return \Utility\Str::ciEquals($this->userName, User::get_current_username());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function get(){
|
||||
|
||||
public function get() {
|
||||
$Query = new Query;
|
||||
$Query->select("CONVERT(TEXT, value) AS value")
|
||||
->from($this->setupTable)
|
||||
->where("user_name", $this->userName)
|
||||
->where("section", $this->getSection())
|
||||
->where("gest_name", $this->gest_name)
|
||||
->where("key_section", $this->key_section);
|
||||
|
||||
->from($this->setupTable)
|
||||
->where("user_name", $this->userName)
|
||||
->where("section", $this->getSection())
|
||||
->where("gest_name", $this->gest_name)
|
||||
->where("key_section", $this->key_section);
|
||||
|
||||
$Ret = $Query->firstRowFirstValue()->toRet()->execute();
|
||||
$value = $Ret->is_OK() ? $Ret->get_data() : null;
|
||||
return $this->parseValue($value);
|
||||
}
|
||||
|
||||
public function set($value){
|
||||
|
||||
public function set($value) {
|
||||
$Ret = new Ret;
|
||||
if($this->checkKey()){
|
||||
if($this->check_userGrant()){
|
||||
|
||||
if ($this->checkKey()) {
|
||||
if ($this->check_userGrant()) {
|
||||
|
||||
$EntityItem = new \EntityItem($this->setupTable);
|
||||
$EntityItem->insert_or_update()
|
||||
->set("userName", $this->userName)
|
||||
->set("gestName", $this->gest_name)
|
||||
->set("section", $this->getSection())
|
||||
->set("keySection", $this->key_section)
|
||||
->set("value", $value);
|
||||
|
||||
->set("userName", $this->userName)
|
||||
->set("gestName", $this->gest_name)
|
||||
->set("section", $this->getSection())
|
||||
->set("keySection", $this->key_section)
|
||||
->set("value", $value);
|
||||
|
||||
$Ret = $EntityItem->send();
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Utente non abilitato");
|
||||
}
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Chiave setup incompleta");
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function checkKey(){
|
||||
|
||||
public function checkKey() {
|
||||
return !is_null($this->gest_name) && !is_null($this->getSection()) && !is_null($this->key_section) && !is_null($this->userName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,52 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace IMSApi;
|
||||
class CheckPartitaIva extends \IMSApi{
|
||||
class CheckPartitaIva extends \IMSApi {
|
||||
private $countryCode = null;
|
||||
private $vatNumber = null;
|
||||
|
||||
|
||||
// <editor-fold desc="SETTERS" defaultstate="collapsed">
|
||||
public function countryCode($value){
|
||||
public function countryCode($value) {
|
||||
$this->countryCode = strtoupper($value);
|
||||
return $this;
|
||||
}
|
||||
public function vatNumber($value){
|
||||
|
||||
public function vatNumber($value) {
|
||||
$this->vatNumber = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
$this->countryCode("IT")->service("checkPartitaIva")->post()->asJson();
|
||||
}
|
||||
|
||||
private static function get_indirizzo($address){ // portarlo fuori
|
||||
|
||||
private static function get_indirizzo($address) { // portarlo fuori
|
||||
$IMSApi = new \IMSApi("geocode");
|
||||
$Ret = $IMSApi->queryParams(array("address" => $address))->send();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
if(isset($retData[0]["dto"])){
|
||||
if (isset($retData[0]["dto"])) {
|
||||
$Ret->set_data($retData[0]["dto"]);
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_data(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function send(){
|
||||
|
||||
public function send() {
|
||||
$Ret = new \Ret;
|
||||
if(!is_null($this->countryCode) && !is_null($this->vatNumber)){
|
||||
if($this->is_valid()){
|
||||
if (!is_null($this->countryCode) && !is_null($this->vatNumber)) {
|
||||
if ($this->is_valid()) {
|
||||
$body = array("countryCode" => $this->countryCode, "vatNumber" => $this->vatNumber);
|
||||
$this->body($body);
|
||||
$Ret = parent::send();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
$dto = $retData[0]["dto"];
|
||||
|
||||
|
||||
$newtemp = true;
|
||||
if(!$newtemp){
|
||||
if (!$newtemp) {
|
||||
$return = array(
|
||||
"valid" => $dto["valid"],
|
||||
"name" => $dto["name"],
|
||||
@@ -57,7 +60,7 @@ class CheckPartitaIva extends \IMSApi{
|
||||
"prov" => null
|
||||
);
|
||||
$Ret2 = self::get_indirizzo($dto["address"]);
|
||||
if($Ret2->is_OK()){
|
||||
if ($Ret2->is_OK()) {
|
||||
$retData = $Ret2->get_data();
|
||||
$return["indirizzo"] = $retData["indirizzo"];
|
||||
$return["citta"] = $retData["citta"];
|
||||
@@ -65,31 +68,31 @@ class CheckPartitaIva extends \IMSApi{
|
||||
$return["prov"] = $retData["prov"];
|
||||
}
|
||||
$Ret->set_data($return);
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_data($dto);
|
||||
}
|
||||
|
||||
} else{
|
||||
if($Ret->get_number()==400){
|
||||
|
||||
} else {
|
||||
if ($Ret->get_number() == 400) {
|
||||
$Ret->set_error("Partita IVA non formalmente valida");
|
||||
}
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("Partita IVA non valida");
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("Parametri incompleti");
|
||||
}
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
private function is_valid(){
|
||||
if($this->countryCode=="IT"){
|
||||
|
||||
private function is_valid() {
|
||||
if ($this->countryCode == "IT") {
|
||||
$pi = $this->vatNumber;
|
||||
if(is_string($pi) && strlen($pi)==11 && is_numeric($pi)){
|
||||
if (is_string($pi) && strlen($pi) == 11 && is_numeric($pi)) {
|
||||
$checksum = "";
|
||||
foreach(str_split(strrev($pi)) as $i => $d) {
|
||||
$checksum .= $i%2 !== 0 ? $d*2 : $d;
|
||||
foreach (str_split(strrev($pi)) as $i => $d) {
|
||||
$checksum .= $i % 2 !== 0 ? $d * 2 : $d;
|
||||
}
|
||||
return array_sum(str_split($checksum)) % 10 === 0;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace IMSApi;
|
||||
class Export extends \IMSApi\ImportExport{
|
||||
|
||||
public function __construct(){
|
||||
class Export extends \IMSApi\ImportExport {
|
||||
|
||||
public function __construct() {
|
||||
$this->service("export")->post()->asJson();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace IMSApi;
|
||||
class Import extends \IMSApi\ImportExport{
|
||||
|
||||
public function __construct(){
|
||||
class Import extends \IMSApi\ImportExport {
|
||||
|
||||
public function __construct() {
|
||||
$this->service("import")->post()->asJson();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace IMSApi;
|
||||
class ImportAnagListini extends \IMSApi{
|
||||
public function __construct(){
|
||||
class ImportAnagListini extends \IMSApi {
|
||||
public function __construct() {
|
||||
$this->post("importAnagListini")->queryParam("tipoImportListino", "V")->asJson();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace IMSApi;
|
||||
class ImportDoc extends \IMSApi\ImportExport{
|
||||
|
||||
public function __construct(){
|
||||
class ImportDoc extends \IMSApi\ImportExport {
|
||||
|
||||
public function __construct() {
|
||||
$this->service("importDoc")->post()->asJson();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,85 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace IMSApi;
|
||||
class ImportExport extends \IMSApi{
|
||||
class ImportExport extends \IMSApi {
|
||||
private $type = null;
|
||||
private $format = null;
|
||||
private $whereCond = array();
|
||||
private $arr_parameters = array();
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
$this->post()->asJson();
|
||||
}
|
||||
|
||||
public function type($v){
|
||||
|
||||
public function type($v) {
|
||||
$this->type = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function format($v){
|
||||
|
||||
public function format($v) {
|
||||
$this->format = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function where($k, $v){
|
||||
|
||||
public function where($k, $v) {
|
||||
$this->whereCond[$k] = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereDate($k, $v){
|
||||
|
||||
public function whereDate($k, $v) {
|
||||
$v = \Utility\Date::isValidUnixtime($v) ? strftime(\Format::strftimeYMD, $v) : $v;
|
||||
return $this->where($k, $v);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public function whereCond(array $v){
|
||||
$this->whereCond = $v;
|
||||
return $this;
|
||||
}*/
|
||||
|
||||
public function dateParameter($k, $v){
|
||||
|
||||
public function dateParameter($k, $v) {
|
||||
$v = \Utility\Date::isValidUnixtime($v) ? strftime(\Format::strftimeYMD, $v) : $v;
|
||||
return $this->parameter($k, $v);
|
||||
}
|
||||
|
||||
public function parameter($k, $v){
|
||||
|
||||
public function parameter($k, $v) {
|
||||
$this->arr_parameters[$k] = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function send(){
|
||||
|
||||
public function send() {
|
||||
$Ret = new \Ret;
|
||||
if(is_null($this->type) && is_null($this->format)){
|
||||
if (is_null($this->type) && is_null($this->format)) {
|
||||
$Ret->set_error("Parametri type e format non specificati");
|
||||
|
||||
} else if(is_null($this->type)){
|
||||
|
||||
} else if (is_null($this->type)) {
|
||||
$Ret->set_error("Parametro type non specificato");
|
||||
|
||||
} else if(is_null($this->format)){
|
||||
|
||||
} else if (is_null($this->format)) {
|
||||
$Ret->set_error("Parametro format non specificato");
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$this->queryParams(array("type" => $this->type, "format" => $this->format));
|
||||
|
||||
|
||||
$body = $this->body();
|
||||
if(count($this->arr_parameters)>0){
|
||||
if (count($this->arr_parameters) > 0) {
|
||||
$body = is_null($body) ? array() : $body;
|
||||
$body = array_merge($body, array("parameter" => $this->arr_parameters));
|
||||
}
|
||||
|
||||
if(!is_null($this->whereCond) && count($this->whereCond)>0){
|
||||
|
||||
if (!is_null($this->whereCond) && count($this->whereCond) > 0) {
|
||||
$whereCond = isset($body["whereCond"]) ? $body["whereCond"] : "";
|
||||
foreach($this->whereCond as $k => $v){
|
||||
$whereCond .= \Query::process_whereParameters($k, $v)." AND ";
|
||||
foreach ($this->whereCond as $k => $v) {
|
||||
$whereCond .= \Query::process_whereParameters($k, $v) . " AND ";
|
||||
}
|
||||
$body["whereCond"] = rtrim($whereCond, " AND ");
|
||||
}
|
||||
|
||||
|
||||
//echojson($body);exit;
|
||||
$this->body($body);
|
||||
|
||||
|
||||
$Ret = parent::send();
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,120 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace IMSApi;
|
||||
class InfoComuni extends \IMSApi{
|
||||
|
||||
class InfoComuni extends \IMSApi {
|
||||
|
||||
private $nome = null;
|
||||
private $cap = null;
|
||||
private $indirizzo = null;
|
||||
private $codiceCatastale = null;
|
||||
private $prov = null;
|
||||
private $regione = null;
|
||||
|
||||
|
||||
// <editor-fold desc="SETTERS" defaultstate="collapsed">
|
||||
public function nome($value){
|
||||
public function nome($value) {
|
||||
$this->nome = $value;
|
||||
return $this;
|
||||
}
|
||||
public function cap($value){
|
||||
|
||||
public function cap($value) {
|
||||
$this->cap = $value;
|
||||
return $this;
|
||||
}
|
||||
public function indirizzo($value){
|
||||
|
||||
public function indirizzo($value) {
|
||||
$this->indirizzo = $value;
|
||||
return $this;
|
||||
}
|
||||
public function codiceCatastale($value){
|
||||
|
||||
public function codiceCatastale($value) {
|
||||
$this->codiceCatastale = $value;
|
||||
return $this;
|
||||
}
|
||||
public function prov($value){
|
||||
|
||||
public function prov($value) {
|
||||
$this->prov = $value;
|
||||
return $this;
|
||||
}
|
||||
public function regione($value){
|
||||
|
||||
public function regione($value) {
|
||||
$this->regione = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
$this->service("infoComuni")->post()->asJson();
|
||||
}
|
||||
|
||||
public function get_comuneByNome($value = null){
|
||||
if(!is_null($value)){
|
||||
|
||||
public function get_comuneByNome($value = null) {
|
||||
if (!is_null($value)) {
|
||||
$this->nome($value);
|
||||
}
|
||||
$Ret = $this->send();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
$Ret->set_data($retData[0]);
|
||||
}
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function get_comuneByCap($value = null){
|
||||
if(!is_null($value)){
|
||||
|
||||
public function get_comuneByCap($value = null) {
|
||||
if (!is_null($value)) {
|
||||
$this->cap($value);
|
||||
}
|
||||
$Ret = $this->send();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
$Ret->set_data($retData[0]);
|
||||
}
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function get_comuneByCodiceCatastale($value){
|
||||
|
||||
public function get_comuneByCodiceCatastale($value) {
|
||||
$Ret = $this->codiceCatastale($value)->send();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
$Ret->set_data($retData[0]);
|
||||
}
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function get_listComuniByProv($value){
|
||||
|
||||
public function get_listComuniByProv($value) {
|
||||
return $this->prov($value)->send();
|
||||
}
|
||||
|
||||
public function get_listComuniByRegione($value){
|
||||
|
||||
public function get_listComuniByRegione($value) {
|
||||
return $this->regione($value)->send();
|
||||
}
|
||||
|
||||
public function send(){
|
||||
|
||||
public function send() {
|
||||
$Ret = new \Ret;
|
||||
$params = array();
|
||||
if(!is_null($this->nome)){
|
||||
if (!is_null($this->nome)) {
|
||||
$params["nome"] = $this->nome;
|
||||
}
|
||||
if(!is_null($this->cap)){
|
||||
if (!is_null($this->cap)) {
|
||||
$params["cap"] = $this->cap;
|
||||
}
|
||||
if(!is_null($this->indirizzo)){
|
||||
if (!is_null($this->indirizzo)) {
|
||||
$params["indirizzo"] = $this->indirizzo;
|
||||
}
|
||||
if(!is_null($this->codiceCatastale)){
|
||||
if (!is_null($this->codiceCatastale)) {
|
||||
$params["codiceCatastale"] = $this->codiceCatastale;
|
||||
}
|
||||
if(!is_null($this->prov)){
|
||||
if (!is_null($this->prov)) {
|
||||
$params["prov"] = $this->prov;
|
||||
}
|
||||
if(!is_null($this->regione)){
|
||||
if (!is_null($this->regione)) {
|
||||
$params["regione"] = $this->regione;
|
||||
}
|
||||
if(count($params)>0){
|
||||
if (count($params) > 0) {
|
||||
$this->queryParams($params);
|
||||
$Ret = parent::send();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
$dto = $retData[0]["dto"];
|
||||
if(count($dto)>0){
|
||||
if (count($dto) > 0) {
|
||||
$Ret->set_data($dto);
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_warning("Nessun risultato");
|
||||
}
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("Nessun parametro specificato");
|
||||
}
|
||||
return $Ret;
|
||||
|
||||
@@ -1,41 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace IMSApi;
|
||||
class PrintFile extends \IMSApi{
|
||||
class PrintFile extends \IMSApi {
|
||||
private $_blob = null;
|
||||
private $_printerName = null;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
$this->service("print")->post()->asJson();
|
||||
}
|
||||
|
||||
public function blob($v){
|
||||
|
||||
public function blob($v) {
|
||||
$this->_blob = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function printerName($v){
|
||||
|
||||
public function printerName($v) {
|
||||
$this->_printerName = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function send(){
|
||||
|
||||
public function send() {
|
||||
$Ret = new \Ret;
|
||||
|
||||
if(!is_null($this->_blob)){
|
||||
|
||||
|
||||
if (!is_null($this->_blob)) {
|
||||
|
||||
$IMSApi = new IMSApi;
|
||||
$IMSApi->post("print")
|
||||
->asText()
|
||||
// ->queryParam("mimeType", Mime::PDF)
|
||||
->queryParam("printerName", $this->_printerName)
|
||||
->body(base64_encode(Utility\Compression\GZ::encode($this->_blob)));
|
||||
->asText()
|
||||
// ->queryParam("mimeType", Mime::PDF)
|
||||
->queryParam("printerName", $this->_printerName)
|
||||
->body(base64_encode(Utility\Compression\GZ::encode($this->_blob)));
|
||||
$Ret = $IMSApi->send();
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Il contenuto del file non è valido");
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,46 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace IMSApi;
|
||||
class ProcessSql extends \IMSApi{
|
||||
class ProcessSql extends \IMSApi {
|
||||
private $sql = null;
|
||||
private $date2ts = false;
|
||||
public function __construct($sql = null){
|
||||
|
||||
public function __construct($sql = null) {
|
||||
$this->service("processSql")->post()->asJson()->sql($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $date2ts
|
||||
*/
|
||||
public function setDate2ts($date2ts)
|
||||
{
|
||||
public function setDate2ts($date2ts) {
|
||||
$this->date2ts = $date2ts;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function sql($value){
|
||||
if(\Query::is_typeQuery($value)){
|
||||
|
||||
public function sql($value) {
|
||||
if (\Query::is_typeQuery($value)) {
|
||||
$this->sql = $value->getSql();
|
||||
} else{
|
||||
} else {
|
||||
$this->sql = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function send(){
|
||||
|
||||
public function send() {
|
||||
$Ret = new \Ret;
|
||||
if(!is_null($this->sql)){
|
||||
$this->body(array("nativeSql" => $this->sql));
|
||||
|
||||
if (!is_null($this->sql)) {
|
||||
$this->body(array("nativeSql" => $this->sql));
|
||||
|
||||
$Ret = parent::send();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
//$dto = $retData[0]["dto"];
|
||||
|
||||
|
||||
}
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Nessun parametro specificato");
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace IMSApi;
|
||||
class ProcessStoredProcedure extends \IMSApi{
|
||||
class ProcessStoredProcedure extends \IMSApi {
|
||||
private $name = null;
|
||||
private $parameters = array();
|
||||
|
||||
public function __construct($name = null){
|
||||
|
||||
public function __construct($name = null) {
|
||||
$this->service("processStoredProcedure")->post()->asJson()->name($name);
|
||||
}
|
||||
|
||||
public function name($value){
|
||||
|
||||
public function name($value) {
|
||||
$this->name = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function parameter($type, $value, $isOutput){
|
||||
|
||||
private function parameter($type, $value, $isOutput) {
|
||||
$this->parameters[] = array("type" => $type, "value" => $value, "isOutput" => $isOutput);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringParameter($value, $isOutput = false){
|
||||
|
||||
public function stringParameter($value, $isOutput = false) {
|
||||
return $this->parameter("string", $value, $isOutput);
|
||||
}
|
||||
|
||||
public function intParameter($value, $isOutput = false){
|
||||
|
||||
public function intParameter($value, $isOutput = false) {
|
||||
return $this->parameter("int", $value, $isOutput);
|
||||
}
|
||||
|
||||
public function shortParameter($value, $isOutput = false){
|
||||
|
||||
public function shortParameter($value, $isOutput = false) {
|
||||
return $this->parameter("short", $value, $isOutput);
|
||||
}
|
||||
|
||||
public function send(){
|
||||
|
||||
public function send() {
|
||||
$Ret = new \Ret;
|
||||
if(!is_null($this->name)){
|
||||
$this->body(array("procedure" => $this->name, "parameters" => $this->parameters));
|
||||
|
||||
if (!is_null($this->name)) {
|
||||
$this->body(array("procedure" => $this->name, "parameters" => $this->parameters));
|
||||
|
||||
$Ret = parent::send();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
$Ret->set_data($retData[0]["genericList"]);
|
||||
}
|
||||
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("Stored Procedure non specificata");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace IMSApi;
|
||||
class Response extends \IMSApi{
|
||||
class Response extends \IMSApi {
|
||||
private $esito = null;
|
||||
private $execDate = null;
|
||||
private $execTime = null;
|
||||
@@ -15,102 +16,111 @@ class Response extends \IMSApi{
|
||||
private $entity = null;
|
||||
private $jsonObject = null;
|
||||
private $listResponse = false;
|
||||
|
||||
public function __construct($returnData = null){
|
||||
if(!is_null($returnData)){
|
||||
|
||||
public function __construct($returnData = null) {
|
||||
if (!is_null($returnData)) {
|
||||
$this->parse($returnData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// <editor-fold desc="GET/SET/CHECK SEMPLICI" defaultstate="collapsed">
|
||||
public function is_OK(){
|
||||
public function is_OK() {
|
||||
return $this->esito == 1;
|
||||
}
|
||||
public function is_KO(){
|
||||
|
||||
public function is_KO() {
|
||||
return !$this->is_OK();
|
||||
}
|
||||
private function set_OK(){
|
||||
|
||||
private function set_OK() {
|
||||
$this->esito = 1;
|
||||
return $this;
|
||||
}
|
||||
private function set_KO(){
|
||||
|
||||
private function set_KO() {
|
||||
$this->esito = -1;
|
||||
return $this;
|
||||
}
|
||||
public function get_errorMessage(){
|
||||
|
||||
public function get_errorMessage() {
|
||||
return $this->errorMessage;
|
||||
}
|
||||
private function set_errorMessage($v){
|
||||
|
||||
private function set_errorMessage($v) {
|
||||
$this->errorMessage = $v;
|
||||
return $this;
|
||||
}
|
||||
public function get_jsonObject(){
|
||||
|
||||
public function get_jsonObject() {
|
||||
return $this->jsonObject;
|
||||
}
|
||||
private function set_jsonObject($v){
|
||||
|
||||
private function set_jsonObject($v) {
|
||||
$this->jsonObject = $v;
|
||||
return $this;
|
||||
}
|
||||
private function is_list(){
|
||||
return $this->listResponse!==false && is_array($this->listResponse);
|
||||
|
||||
private function is_list() {
|
||||
return $this->listResponse !== false && is_array($this->listResponse);
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
public function get_item($i){
|
||||
if($this->is_list() && array_key_exists($i, $this->listResponse)){
|
||||
|
||||
public function get_item($i) {
|
||||
if ($this->is_list() && array_key_exists($i, $this->listResponse)) {
|
||||
return $this->listResponse[$i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function parse($returnData){
|
||||
if(isset($returnData[0])){ // LISTA
|
||||
|
||||
private function parse($returnData) {
|
||||
if (isset($returnData[0])) { // LISTA
|
||||
$this->set_OK();
|
||||
$this->listResponse = array();
|
||||
foreach($returnData as $retDataItem){
|
||||
foreach ($returnData as $retDataItem) {
|
||||
$Response = new Response($retDataItem);
|
||||
if($Response->is_KO()){
|
||||
if ($Response->is_KO()) {
|
||||
$this->set_KO()->set_errorMessage($Response->get_errorMessage());
|
||||
}
|
||||
$this->listResponse[] = $Response;
|
||||
}
|
||||
|
||||
} else{ // SINGOLO
|
||||
if(array_key_exists("esito", $returnData)){
|
||||
|
||||
} else { // SINGOLO
|
||||
if (array_key_exists("esito", $returnData)) {
|
||||
$this->esito = $returnData["esito"];
|
||||
}
|
||||
if(array_key_exists("execDate", $returnData)){
|
||||
if (array_key_exists("execDate", $returnData)) {
|
||||
$this->execDate = $returnData["execDate"];
|
||||
$this->execTime = \Utility\Date::strtotime($this->execDate, \Format::strtotimeYMDHMS);
|
||||
}
|
||||
if(array_key_exists("profileDB", $returnData)){
|
||||
if (array_key_exists("profileDB", $returnData)) {
|
||||
$this->profileDB = $returnData["profileDB"];
|
||||
}
|
||||
if(array_key_exists("operationType", $returnData)){
|
||||
if (array_key_exists("operationType", $returnData)) {
|
||||
$this->operationType = $returnData["operationType"];
|
||||
}
|
||||
if(array_key_exists("errorMessage", $returnData)){
|
||||
if (array_key_exists("errorMessage", $returnData)) {
|
||||
$this->errorMessage = $returnData["errorMessage"];
|
||||
}
|
||||
if(array_key_exists("errorType", $returnData)){
|
||||
if (array_key_exists("errorType", $returnData)) {
|
||||
$this->errorType = $returnData["errorType"];
|
||||
}
|
||||
if(array_key_exists("report", $returnData)){
|
||||
if (array_key_exists("report", $returnData)) {
|
||||
$this->report = $returnData["report"];
|
||||
}
|
||||
if(array_key_exists("xml", $returnData)){
|
||||
if (array_key_exists("xml", $returnData)) {
|
||||
$this->xml = $returnData["xml"];
|
||||
}
|
||||
if(array_key_exists("lastTransactionIdImport", $returnData)){
|
||||
if (array_key_exists("lastTransactionIdImport", $returnData)) {
|
||||
$this->lastTransactionIdImport = $returnData["lastTransactionIdImport"];
|
||||
}
|
||||
if(array_key_exists("syncActive", $returnData)){
|
||||
if (array_key_exists("syncActive", $returnData)) {
|
||||
$this->syncActive = $returnData["syncActive"];
|
||||
}
|
||||
if(array_key_exists("entity", $returnData)){
|
||||
if (array_key_exists("entity", $returnData)) {
|
||||
$this->entity = $returnData["entity"];
|
||||
}
|
||||
if(array_key_exists("dto", $returnData)){
|
||||
if (array_key_exists("dto", $returnData)) {
|
||||
$this->jsonObject = $returnData["dto"];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace IMSApi;
|
||||
class SaveTerminalino extends \IMSApi{
|
||||
class SaveTerminalino extends \IMSApi {
|
||||
private $file = null;
|
||||
|
||||
public function __construct($file=null){
|
||||
|
||||
public function __construct($file = null) {
|
||||
$this->post("saveTerminalino")->asText()->file($file);
|
||||
}
|
||||
|
||||
public function file($value){
|
||||
|
||||
public function file($value) {
|
||||
$this->file = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function send(){
|
||||
|
||||
public function send() {
|
||||
$Ret = new \Ret;
|
||||
$file = $this->file;
|
||||
if(is_null($file)){
|
||||
if (is_null($file)) {
|
||||
return $Ret->set_error("File non pervenuto");
|
||||
}
|
||||
|
||||
if(!\Utility\File::checkFileNameExtension($file["name"], "xml")){
|
||||
|
||||
if (!\Utility\File::checkFileNameExtension($file["name"], "xml")) {
|
||||
return $Ret->set_error("Tipo file non valido<br/>");
|
||||
}
|
||||
|
||||
|
||||
$xml = simplexml_load_file($file["tmp_name"]);
|
||||
if(!isset($xml->COD_MDEP)){
|
||||
if (!isset($xml->COD_MDEP)) {
|
||||
return $Ret->set_error("Il file non è conforme poiché il deposito non è stato specificato<br/>");
|
||||
}
|
||||
|
||||
|
||||
$xmlCodMdep = (string)$xml->COD_MDEP;
|
||||
if(strlen(trim($xmlCodMdep))==0){
|
||||
if (strlen(trim($xmlCodMdep)) == 0) {
|
||||
$xml->COD_MDEP = $xmlCodMdep = \User::get_current_userCodMdep();
|
||||
}
|
||||
|
||||
if($xmlCodMdep != \User::get_current_userCodMdep()){
|
||||
|
||||
if ($xmlCodMdep != \User::get_current_userCodMdep()) {
|
||||
return $Ret->set_error("Il file non è conforme poiché è stato creato per un altro deposito<br/>");
|
||||
}
|
||||
|
||||
if(!isset($xml->ROW)){
|
||||
|
||||
if (!isset($xml->ROW)) {
|
||||
return $Ret->set_error("Il file non è conforme poiché non ci sono righe<br/>");
|
||||
}
|
||||
|
||||
|
||||
$this->body(utf8_encode($xml->asXML()));
|
||||
$Ret = parent::send();
|
||||
// $ImsAPI = new IMSApi;
|
||||
// $Ret = $ImsAPI->post("saveTerminalino")->body(utf8_encode($xml->asXML()))->asText()->send();
|
||||
if($Ret->is_OK()){
|
||||
// $ImsAPI = new IMSApi;
|
||||
// $Ret = $ImsAPI->post("saveTerminalino")->body(utf8_encode($xml->asXML()))->asText()->send();
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
$Ret->set_data($retData[0]);
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace IMSApi;
|
||||
class SearchComuni extends \IMSApi{
|
||||
|
||||
class SearchComuni extends \IMSApi {
|
||||
|
||||
private $q = null;
|
||||
private $limit = null;
|
||||
|
||||
// <editor-fold desc="SETTERS" defaultstate="collapsed">
|
||||
public function q($value){
|
||||
public function q($value) {
|
||||
$this->q = $value;
|
||||
return $this;
|
||||
}
|
||||
public function limit($value){
|
||||
if(is_int($value) && $value>=0){
|
||||
|
||||
public function limit($value) {
|
||||
if (is_int($value) && $value >= 0) {
|
||||
$this->limit = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
$this->service("searchComuni")->post()->asJson();
|
||||
}
|
||||
|
||||
public function send(){
|
||||
|
||||
public function send() {
|
||||
$Ret = new \Ret;
|
||||
if(!is_null($this->q)){
|
||||
if (!is_null($this->q)) {
|
||||
$params = array("q" => $this->q);
|
||||
if(!is_null($this->limit)){
|
||||
if (!is_null($this->limit)) {
|
||||
$params["limit"] = $this->limit;
|
||||
}
|
||||
|
||||
|
||||
$this->queryParams($params);
|
||||
$Ret = parent::send();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
$dto = $retData[0]["dto"];//var_dump($dto);
|
||||
if(count($dto)>0){
|
||||
foreach($dto as $i => $row){
|
||||
if (count($dto) > 0) {
|
||||
foreach ($dto as $i => $row) {
|
||||
$dto[$i] = array(
|
||||
"citta" => $row["nome"],
|
||||
"cap" => $row["cap"],
|
||||
@@ -49,7 +52,7 @@ class SearchComuni extends \IMSApi{
|
||||
}
|
||||
$Ret->set_data($dto);
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("Nessun parametro specificato");
|
||||
}
|
||||
return $Ret;
|
||||
|
||||
@@ -1,91 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace IMSApi;
|
||||
class SqlToExcel extends \IMSApi{
|
||||
class SqlToExcel extends \IMSApi {
|
||||
private $_title = null;
|
||||
private $_sql = null;
|
||||
private $_dataSource = null;
|
||||
private $_arr_fields = array();
|
||||
private $_cacheAs = false;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
$this->service("sqlToExcel")->post()->asJson();
|
||||
}
|
||||
|
||||
public function title($v){
|
||||
|
||||
public function title($v) {
|
||||
$this->_title = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSql($v){
|
||||
if(\Query::is_typeQuery($v)){
|
||||
|
||||
public function setSql($v) {
|
||||
if (\Query::is_typeQuery($v)) {
|
||||
$this->_sql = $v->getSql();
|
||||
} else if(is_string($v)){
|
||||
} else if (is_string($v)) {
|
||||
$this->_sql = $v;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDataSource($v){
|
||||
|
||||
public function setDataSource($v) {
|
||||
$this->_dataSource = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fields(){
|
||||
|
||||
public function fields() {
|
||||
$arr_values = func_get_args();
|
||||
foreach($arr_values as $value){
|
||||
if(is_array($value)){
|
||||
foreach($value as $field){
|
||||
foreach ($arr_values as $value) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $field) {
|
||||
$this->fields($field);
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$this->_arr_fields[] = $value;
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function cacheAs($fileName = true){
|
||||
|
||||
public function cacheAs($fileName = true) {
|
||||
$this->_cacheAs = $fileName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function send(){
|
||||
if(!is_null($this->_dataSource)){
|
||||
|
||||
public function send() {
|
||||
if (!is_null($this->_dataSource)) {
|
||||
$TempTable = new \Utility\Db\TempTable;
|
||||
$Ret = $TempTable->prefix("SqlToExcel")->source($this->_dataSource)->run();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$tableTempName = $Ret->get_string();
|
||||
$this->setSql("SELECT * FROM ".$tableTempName);
|
||||
$this->setSql("SELECT * FROM " . $tableTempName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$Query = new \Query($this->_sql);
|
||||
$Ret = $Query->checkSyntax();
|
||||
if($Ret->is_OK()){
|
||||
$this->body(array("sql" => $this->_sql, "fields" => $this->_arr_fields));
|
||||
if ($Ret->is_OK()) {
|
||||
$this->body(array("sql" => $this->_sql, "fields" => $this->_arr_fields));
|
||||
$Ret = parent::send();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
$content = base64_decode($retData[0]["dto"]);
|
||||
$Ret->set_byte(null)->set_string(null)->set_data(null);
|
||||
|
||||
if($this->_cacheAs===true || is_string($this->_cacheAs)){
|
||||
|
||||
if ($this->_cacheAs === true || is_string($this->_cacheAs)) {
|
||||
$fileName = is_string($this->_cacheAs) ? $this->_cacheAs : null;
|
||||
$overwrite = true;
|
||||
|
||||
if(is_null($fileName)){
|
||||
|
||||
if (is_null($fileName)) {
|
||||
$overwrite = false;
|
||||
$fileName = "Foglio ".date("Ymd His");
|
||||
$fileName = "Foglio " . date("Ymd His");
|
||||
}
|
||||
|
||||
$Ret = \Cache::writeR($fileName.".xlsx", $content, true, $overwrite);
|
||||
|
||||
} else{
|
||||
|
||||
$Ret = \Cache::writeR($fileName . ".xlsx", $content, true, $overwrite);
|
||||
|
||||
} else {
|
||||
$Ret->set_byte($content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
class IMSApi{
|
||||
|
||||
class IMSApi {
|
||||
const serviceRootPath = "ems-api/";
|
||||
private $contentType = null;
|
||||
private $serviceName = null;
|
||||
@@ -13,86 +14,86 @@ class IMSApi{
|
||||
private $anonymousAuth = false;
|
||||
private $isDownload = false;
|
||||
private $timeout = 0;
|
||||
|
||||
public function __construct($serviceName = null){
|
||||
|
||||
public function __construct($serviceName = null) {
|
||||
$this->get()->asJson()->service($serviceName);
|
||||
}
|
||||
|
||||
|
||||
// <editor-fold desc="Setters" defaultstate="collapsed">
|
||||
public function service($value){
|
||||
public function service($value) {
|
||||
$this->serviceName = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function method($value){
|
||||
|
||||
public function method($value) {
|
||||
$this->serviceMethod = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function profileDB($value){
|
||||
|
||||
public function profileDB($value) {
|
||||
$this->profileDB = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function endpoint($value){
|
||||
|
||||
public function endpoint($value) {
|
||||
$this->endpoint = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function authUsername($value){
|
||||
|
||||
public function authUsername($value) {
|
||||
$this->authUsername = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function authPassword($value){
|
||||
|
||||
public function authPassword($value) {
|
||||
$this->authPassword = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function anonymousAuth($value = true){
|
||||
$this->anonymousAuth = $value!==false;
|
||||
|
||||
public function anonymousAuth($value = true) {
|
||||
$this->anonymousAuth = $value !== false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function queryDateParam($key, $value){
|
||||
|
||||
public function queryDateParam($key, $value) {
|
||||
return $this->queryParam($key, $value, \Format::strftimeYMD);
|
||||
}
|
||||
|
||||
public function queryDatetimeParam($key, $value){
|
||||
|
||||
public function queryDatetimeParam($key, $value) {
|
||||
return $this->queryParam($key, $value, \Format::strftimeYMDHMS);
|
||||
}
|
||||
|
||||
public function queryParam($key, $value, $type = null){
|
||||
if($type==\Format::strftimeYMD && \Utility\Date::isValidUnixtime($value)){
|
||||
|
||||
public function queryParam($key, $value, $type = null) {
|
||||
if ($type == \Format::strftimeYMD && \Utility\Date::isValidUnixtime($value)) {
|
||||
$value = strftime(\Format::strftimeYMD, $value);
|
||||
|
||||
} else if($type==\Format::strftimeYMDHMS && \Utility\Date::isValidUnixtime($value)){
|
||||
|
||||
} else if ($type == \Format::strftimeYMDHMS && \Utility\Date::isValidUnixtime($value)) {
|
||||
$value = strftime(\Format::strftimeYMDHMS, $value);
|
||||
|
||||
} else if($type==\Format::latLng1){
|
||||
|
||||
|
||||
} else if ($type == \Format::latLng1) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
$this->queryParams[$key] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function queryParams($array){
|
||||
|
||||
public function queryParams($array) {
|
||||
$this->queryParams = array_merge($this->queryParams, $array);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get($serviceName = null){
|
||||
|
||||
public function get($serviceName = null) {
|
||||
$this->method("GET");
|
||||
if(!is_null($serviceName)){
|
||||
if (!is_null($serviceName)) {
|
||||
$this->service($serviceName);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function post($serviceName = null){
|
||||
|
||||
public function post($serviceName = null) {
|
||||
$this->method("POST");
|
||||
if(!is_null($serviceName)){
|
||||
if (!is_null($serviceName)) {
|
||||
$this->service($serviceName);
|
||||
}
|
||||
return $this;
|
||||
@@ -113,128 +114,130 @@ class IMSApi{
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function asText(){
|
||||
|
||||
public function asText() {
|
||||
$this->contentType = Rest::TEXTPLAIN;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function asJson(){
|
||||
|
||||
public function asJson() {
|
||||
$this->contentType = Rest::APPLICATIONJSON;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function asForm(){
|
||||
|
||||
public function asForm() {
|
||||
$this->contentType = Rest::FORM;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function timeout($seconds){
|
||||
public function timeout($seconds) {
|
||||
$this->timeout = $seconds;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function body($value = null){
|
||||
if(is_null($value)){ // GET
|
||||
if(is_array($this->body)){
|
||||
if($this->contentType == Rest::FORM){
|
||||
|
||||
public function body($value = null) {
|
||||
if (is_null($value)) { // GET
|
||||
if (is_array($this->body)) {
|
||||
if ($this->contentType == Rest::FORM) {
|
||||
return http_build_query($this->body);
|
||||
} else{
|
||||
} else {
|
||||
return Utility::json_encode($this->body);
|
||||
}
|
||||
}
|
||||
return $this->body;
|
||||
|
||||
} else{ // SET
|
||||
if(EntityItem::is_entityItem($value) || EntityList::is_entityList($value)){
|
||||
|
||||
} else { // SET
|
||||
if (EntityItem::is_entityItem($value) || EntityList::is_entityList($value)) {
|
||||
$value = $value->get_body();
|
||||
}
|
||||
|
||||
|
||||
$this->body = $value;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
public function writeLog_body(){
|
||||
if(!is_null($this->body())){
|
||||
$filename = "IMSApi".( !is_null($this->serviceName)?"-".$this->serviceName:"" ).".json";
|
||||
|
||||
public function writeLog_body() {
|
||||
if (!is_null($this->body())) {
|
||||
$filename = "IMSApi" . (!is_null($this->serviceName) ? "-" . $this->serviceName : "") . ".json";
|
||||
\Cache::writeR($filename, $this->body(), "logs");
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function get_serviceRootPath(){
|
||||
|
||||
public static function get_serviceRootPath() {
|
||||
return self::serviceRootPath;
|
||||
}
|
||||
|
||||
private function get_authCredentials(){
|
||||
if($this->anonymousAuth && (!is_null($this->profileDB) || isset($GLOBALS["profileDB"]))){
|
||||
$profileDb = !is_null($this->profileDB) ? $this->profileDB : (isset($GLOBALS["profileDB"])?$GLOBALS["profileDB"]:null);
|
||||
|
||||
private function get_authCredentials() {
|
||||
if ($this->anonymousAuth && (!is_null($this->profileDB) || isset($GLOBALS["profileDB"]))) {
|
||||
$profileDb = !is_null($this->profileDB) ? $this->profileDB : (isset($GLOBALS["profileDB"]) ? $GLOBALS["profileDB"] : null);
|
||||
return array("username" => $profileDb, "password" => $profileDb);
|
||||
|
||||
} else if(!is_null($this->authUsername) && !is_null($this->authPassword)){
|
||||
|
||||
} else if (!is_null($this->authUsername) && !is_null($this->authPassword)) {
|
||||
return array("username" => $this->authUsername, "password" => $this->authPassword);
|
||||
|
||||
} else if(\User::is_authenticated() && isset($_SESSION["password"])){
|
||||
|
||||
} else if (\User::is_authenticated() && isset($_SESSION["password"])) {
|
||||
return array("username" => $_SESSION["username"], "password" => $_SESSION["password"]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function send(){
|
||||
|
||||
public function send() {
|
||||
$Ret = new Ret;
|
||||
|
||||
if(!is_null($this->profileDB)){
|
||||
|
||||
if (!is_null($this->profileDB)) {
|
||||
$this->queryParam("profileDb", $this->profileDB);
|
||||
}
|
||||
$queryParams = $this->queryParams;
|
||||
|
||||
|
||||
$Rest = new Rest;
|
||||
$Rest->service($this->serviceName)
|
||||
->contentType($this->contentType)
|
||||
->method($this->serviceMethod)
|
||||
->urlData($queryParams)
|
||||
->serviceRootPath(self::get_serviceRootPath())
|
||||
->timeout($this->timeout)
|
||||
->setIsDownload($this->isDownload)
|
||||
->setProfileDb($this->profileDB)
|
||||
->endPoint($this->endpoint)
|
||||
->body($this->body()); /**** here the body of IMSApi is passed to $Rest; *******/
|
||||
|
||||
->contentType($this->contentType)
|
||||
->method($this->serviceMethod)
|
||||
->urlData($queryParams)
|
||||
->serviceRootPath(self::get_serviceRootPath())
|
||||
->timeout($this->timeout)
|
||||
->setIsDownload($this->isDownload)
|
||||
->setProfileDb($this->profileDB)
|
||||
->endPoint($this->endpoint)
|
||||
->body($this->body());
|
||||
/**** here the body of IMSApi is passed to $Rest; *******/
|
||||
|
||||
$credentials = $this->get_authCredentials();
|
||||
if(!is_null($credentials)){
|
||||
if (!is_null($credentials)) {
|
||||
$Rest->authUsername($credentials["username"])->authPassword($credentials["password"]);
|
||||
} else{
|
||||
return $Ret->set_error("Credenziali di autenticazione al servizio <i>".$this->serviceName."</i> non valide");
|
||||
} else {
|
||||
return $Ret->set_error("Credenziali di autenticazione al servizio <i>" . $this->serviceName . "</i> non valide");
|
||||
}
|
||||
|
||||
/********************************** HERE IT IS PERFORMED THE REST APIs CALL *************************************/
|
||||
$Ret = $Rest->send();
|
||||
/****************************************************************************************************************/
|
||||
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data(); // utilizzato solo per verificare errore (non dati di ritorno)
|
||||
if(!$this->isDownload){
|
||||
foreach($retData as $entityResponse){
|
||||
if($entityResponse["esito"] != 1){
|
||||
if (!$this->isDownload) {
|
||||
foreach ($retData as $entityResponse) {
|
||||
if ($entityResponse["esito"] != 1) {
|
||||
$Ret->set_error($entityResponse["errorMessage"]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
@$Ret->set_Response(new IMSApi\Response($retData));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function download($serviceName){
|
||||
public function download($serviceName) {
|
||||
$this->method("GET");
|
||||
$this->isDownload = true;
|
||||
if(!is_null($serviceName)){
|
||||
if (!is_null($serviceName)) {
|
||||
$this->service($serviceName);
|
||||
}
|
||||
return $this;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
class JasperProcessor{
|
||||
|
||||
use Report\Parameter;
|
||||
|
||||
class JasperProcessor {
|
||||
private $_title = null; // non necessario per l'esecuzione, lo carica solo leggendolo dal db
|
||||
private $_QUERY = null;
|
||||
private $_REPORT_NAME = null;
|
||||
@@ -11,316 +14,365 @@ class JasperProcessor{
|
||||
private $_SUBREPORTS = null;
|
||||
private $_cacheAs = false;
|
||||
private $_report = null;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
$this->asPdf();
|
||||
}
|
||||
|
||||
private function is_loaded(){
|
||||
|
||||
private function is_loaded() {
|
||||
$Ret = new Ret;
|
||||
if(is_null($this->_B64_JRXML) && is_null($this->_REPORT_NAME)){
|
||||
if (is_null($this->_B64_JRXML) && is_null($this->_REPORT_NAME)) {
|
||||
$Ret->set_error("Risorsa non caricata nel JasperProcessor");
|
||||
}
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
private function process(){
|
||||
|
||||
private function process() {
|
||||
$IMSApi = new IMSApi;
|
||||
|
||||
if(!\User::is_authenticated()){
|
||||
|
||||
if (!\User::is_authenticated()) {
|
||||
$IMSApi->anonymousAuth();
|
||||
}
|
||||
|
||||
|
||||
$Ret = $IMSApi->post("processReport")->body($this->getJasperDTO())->send();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
if(isset($retData[0])){
|
||||
if (isset($retData[0])) {
|
||||
$retData = $retData[0];
|
||||
}
|
||||
if($retData["esito"]==1){
|
||||
if(isset($retData["report"]["fileb64Content"]) && !is_null($retData["report"])){
|
||||
if ($retData["esito"] == 1) {
|
||||
if (isset($retData["report"]["fileb64Content"]) && !is_null($retData["report"])) {
|
||||
$content = base64_decode($retData["report"]["fileb64Content"]);
|
||||
|
||||
if($this->_cacheAs===true || is_string($this->_cacheAs)){
|
||||
if($content){
|
||||
|
||||
if ($this->_cacheAs === true || is_string($this->_cacheAs)) {
|
||||
if ($content) {
|
||||
$fileName = is_string($this->_cacheAs) ? $this->_cacheAs : null;
|
||||
$overwrite = true;
|
||||
|
||||
if(is_null($fileName)){
|
||||
|
||||
if (is_null($fileName)) {
|
||||
$overwrite = false;
|
||||
if(!is_null($this->_REPORT_NAME)){
|
||||
if (!is_null($this->_REPORT_NAME)) {
|
||||
$fileName = $this->_REPORT_NAME;
|
||||
|
||||
} else if(!is_null($this->_B64_JRXML)){
|
||||
|
||||
} else if (!is_null($this->_B64_JRXML)) {
|
||||
$fileName = Report::getNameFromJrxml_static($this->_B64_JRXML);
|
||||
}
|
||||
|
||||
if(is_null($fileName)){
|
||||
|
||||
if (is_null($fileName)) {
|
||||
$fileName = "Report";
|
||||
}
|
||||
}
|
||||
|
||||
$Ret = \Cache::writeR($fileName.".pdf", $content, true, $overwrite);
|
||||
|
||||
} else{
|
||||
|
||||
$Ret = \Cache::writeR($fileName . ".pdf", $content, true, $overwrite);
|
||||
|
||||
} else {
|
||||
$Ret->set_errorCode(\ErrorHandler::NORESULT_REPORT)->set_WARN();
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_byte($content);
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_errorCode(\ErrorHandler::NORESULT_REPORT)->set_WARN();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function run(){
|
||||
|
||||
public function run() {
|
||||
$Ret = $this->is_loaded();
|
||||
if($Ret->is_KO() && !is_null($this->_report)){
|
||||
if ($Ret->is_KO() && !is_null($this->_report)) {
|
||||
$Ret = $this->load($this->_report);
|
||||
}
|
||||
|
||||
if($Ret->is_OK()){
|
||||
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret = $this->is_loaded();
|
||||
if($Ret->is_OK()){
|
||||
if($this->_FORMATO_EXPORT == Format::PDF){
|
||||
if ($Ret->is_OK()) {
|
||||
if ($this->_FORMATO_EXPORT == Format::PDF) {
|
||||
$Ret = $this->process();
|
||||
} else{
|
||||
$Ret->set_error("Formato export report non supportato (".$this->_FORMATO_EXPORT.")");
|
||||
} else {
|
||||
$Ret->set_error("Formato export report non supportato (" . $this->_FORMATO_EXPORT . ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function sendToPrinter($printerName = null, $numberOfCopies = null){
|
||||
|
||||
public function sendToPrinter($printerName = null, $numberOfCopies = null) {
|
||||
$Ret = $this->is_loaded();
|
||||
if($Ret->is_KO() && !is_null($this->_report)){
|
||||
if ($Ret->is_KO() && !is_null($this->_report)) {
|
||||
$Ret = $this->load($this->_report);
|
||||
}
|
||||
|
||||
if($Ret->is_OK()){
|
||||
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret = $this->is_loaded();
|
||||
if($Ret->is_OK()){
|
||||
if(\Utility\Str::ciEquals($this->_FORMATO_EXPORT, \Format::PDF)){
|
||||
|
||||
if ($Ret->is_OK()) {
|
||||
if (\Utility\Str::ciEquals($this->_FORMATO_EXPORT, \Format::PDF)) {
|
||||
|
||||
$IMSApi = new IMSApi;
|
||||
if(!\User::is_authenticated()){
|
||||
if (!\User::is_authenticated()) {
|
||||
$IMSApi->anonymousAuth();
|
||||
}
|
||||
|
||||
|
||||
$IMSApi->post("processPrintReport")
|
||||
->queryParam("printerName", $printerName)
|
||||
->queryParam("numberOfCopies", $numberOfCopies)
|
||||
->body($this->getJasperDTO());
|
||||
|
||||
->queryParam("printerName", $printerName)
|
||||
->queryParam("numberOfCopies", $numberOfCopies)
|
||||
->body($this->getJasperDTO());
|
||||
|
||||
$Ret = $IMSApi->send();
|
||||
|
||||
} else{
|
||||
$Ret->set_error("Formato export report non supportato (".$this->_FORMATO_EXPORT.")");
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Formato export report non supportato (" . $this->_FORMATO_EXPORT . ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function loadFromJtbDisegni($codProd, $fileTypes = null){
|
||||
|
||||
public function loadFromJtbDisegni($codProd, $fileTypes = null) {
|
||||
$fileTypes = !is_null($fileTypes) ? array($fileTypes) : array(\JtbDisegniFiles::REPORT_JASPER, \JtbDisegniFiles::SUBREPORT_JASPER);
|
||||
$Ret = \JtbDisegniFiles::get_items(array("cod_prod" => $codProd, "file_type" => $fileTypes));
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$arr_files = $Ret->get_data();
|
||||
$jrxml = null;
|
||||
if(count($arr_files)>0){
|
||||
$result = array_values(from($arr_files)->where(function($x) use($fileTypes){ return $x["file_type"]===$fileTypes[0];})->toArray());
|
||||
if(count($result)>0){
|
||||
if (count($arr_files) > 0) {
|
||||
$result = array_values(from($arr_files)->where(function ($x) use ($fileTypes) {
|
||||
return $x["file_type"] === $fileTypes[0];
|
||||
})->toArray());
|
||||
if (count($result) > 0) {
|
||||
$jrxml = $result[0]["content"];
|
||||
}
|
||||
}
|
||||
|
||||
if(!is_null($jrxml)){
|
||||
|
||||
if (!is_null($jrxml)) {
|
||||
$Report = new \Report;
|
||||
$Report->setJrxml($jrxml);
|
||||
|
||||
$arr_subreportItem = array_values(from($arr_files)->where(function($x){ return $x["file_type"]===\JtbDisegniFiles::SUBREPORT_JASPER;})->toArray());
|
||||
foreach($arr_subreportItem as $subreportItem){
|
||||
|
||||
$arr_subreportItem = array_values(from($arr_files)->where(function ($x) {
|
||||
return $x["file_type"] === \JtbDisegniFiles::SUBREPORT_JASPER;
|
||||
})->toArray());
|
||||
foreach ($arr_subreportItem as $subreportItem) {
|
||||
$Report->appendSubreport(array("jasper_filename" => $subreportItem["file_name"], "b64_jasper" => $subreportItem["content"]));
|
||||
}
|
||||
|
||||
|
||||
$Ret = $this->load($Report);
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Risorsa JtbDisegni non valida");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function load($input){
|
||||
|
||||
public function load($input) {
|
||||
$Ret = new Ret;
|
||||
if(!is_null($input)){
|
||||
if(is_string($input)){ // reportName
|
||||
if (!is_null($input)) {
|
||||
if (is_string($input)) { // reportName
|
||||
$Report = new \Report;
|
||||
$Ret = $Report->load_report($input);
|
||||
|
||||
} else if(\Report::isReportObject($input)){
|
||||
|
||||
} else if (\Report::isReportObject($input)) {
|
||||
$Report = $input;
|
||||
|
||||
} else if(\GestSetup::isGestSetupObject($input)){
|
||||
|
||||
} else if (\GestSetup::isGestSetupObject($input)) {
|
||||
$reportName = $input->get();
|
||||
$Report = new \Report;
|
||||
$Ret = $Report->load_report($reportName);
|
||||
if(!$Ret->is_OK()){
|
||||
if (!$Ret->is_OK()) {
|
||||
return $Ret->set_errorCode(\ErrorHandler::INVALID_REPORT, $input);
|
||||
}
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Valore in input non valido");
|
||||
}
|
||||
|
||||
if($Ret->is_OK()){
|
||||
if($Report->is_loaded()){
|
||||
|
||||
if ($Ret->is_OK()) {
|
||||
if ($Report->is_loaded()) {
|
||||
$this->setReportName($Report->name)
|
||||
->setTitle($Report->title)
|
||||
->setQuery(nullIfBlank($Report->query));
|
||||
|
||||
if(is_null($Report->name)){
|
||||
$this->setB64Jrxml($Report->b64_jrxml)
|
||||
->setSubreports($Report->getSubreports());
|
||||
->setTitle($Report->title)
|
||||
->setQuery(nullIfBlank($Report->query));
|
||||
|
||||
if (is_array($Report->Parameters)) {
|
||||
/**
|
||||
* @var Parameter $param
|
||||
*/
|
||||
foreach ($Report->Parameters as $param) {
|
||||
if (!empty($param->expression) && !$this->hasParam($param->name)) {
|
||||
switch ($param->tipo) {
|
||||
case Parameter::TYPE_DATESTATIC:
|
||||
case Parameter::TYPE_DATEDYNAMIC:
|
||||
$value = base64_decode($param->expression);
|
||||
|
||||
if (strtolower($value) === "today") {
|
||||
$value = time();
|
||||
}
|
||||
|
||||
$this->paramDate($param->name, $value);
|
||||
break;
|
||||
case Parameter::TYPE_TEXT:
|
||||
case Parameter::TYPE_WHERE:
|
||||
$this->param($param->name, base64_decode($param->expression));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (is_null($Report->name)) {
|
||||
$this->setB64Jrxml($Report->b64_jrxml)
|
||||
->setSubreports($Report->getSubreports());
|
||||
}
|
||||
|
||||
$Ret->set("JP", $this);
|
||||
|
||||
} else{
|
||||
$Ret->set_errorCode(ErrorHandler::INVALID_REPORT, is_string($input)?$input:null);
|
||||
|
||||
} else {
|
||||
$Ret->set_errorCode(ErrorHandler::INVALID_REPORT, is_string($input) ? $input : null);
|
||||
}
|
||||
}
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Parametro nome report non specificato");
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function getTitle(){
|
||||
|
||||
public function getTitle() {
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
public function report($v){
|
||||
|
||||
public function report($v) {
|
||||
$this->_report = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function asPdf(){
|
||||
|
||||
public function asPdf() {
|
||||
return $this->asFormat(\Format::PDF);
|
||||
}
|
||||
|
||||
public function asFormat($v){
|
||||
|
||||
public function asFormat($v) {
|
||||
$this->_FORMATO_EXPORT = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTitle($v){
|
||||
|
||||
public function setTitle($v) {
|
||||
$this->_title = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setReportName($v){
|
||||
|
||||
public function setReportName($v) {
|
||||
$this->_REPORT_NAME = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setB64Jrxml($v){
|
||||
|
||||
public function getReportName() {
|
||||
return $this->_REPORT_NAME;
|
||||
}
|
||||
|
||||
public function setB64Jrxml($v) {
|
||||
$this->_B64_JRXML = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSubreports($v){
|
||||
|
||||
public function setSubreports($v) {
|
||||
$this->_SUBREPORTS = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setQuery($v){
|
||||
|
||||
public function setQuery($v) {
|
||||
$this->_QUERY = Utility::isBase64Encoded($v) ? base64_decode($v) : $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setJsonSource($v){
|
||||
if((is_array($v) || is_object($v)) && !is_string($v)){ // è possibile fornire anche una struttura, la conversione in json string avviene in atuomatico
|
||||
|
||||
public function setJsonSource($v) {
|
||||
if ((is_array($v) || is_object($v)) && !is_string($v)) { // è possibile fornire anche una struttura, la conversione in json string avviene in atuomatico
|
||||
$v = json_encode($v);
|
||||
}
|
||||
$this->_JSON_SOURCE = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function cacheAs($fileName = true){
|
||||
|
||||
public function cacheAs($fileName = true) {
|
||||
$this->_cacheAs = $fileName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function paramDate($key, $value){
|
||||
|
||||
public function paramDate($key, $value) {
|
||||
return $this->param($key, $value, \Format::strftimeYMD);
|
||||
}
|
||||
|
||||
public function param($key, $value, $type = null){ // append parametro singolo
|
||||
if(!is_null($type) && $type==\Format::strftimeYMD && \Utility\Date::isValidUnixtime($value)){
|
||||
|
||||
public function param($key, $value, $type = null) { // append parametro singolo
|
||||
if (!is_null($type) && $type == \Format::strftimeYMD && \Utility\Date::isValidUnixtime($value)) {
|
||||
$value = strftime(\Format::strftimeYMD, $value);
|
||||
|
||||
} else if(!is_null($type) && $type==\Format::strftimeYMDHMS && \Utility\Date::isValidUnixtime($value)){
|
||||
|
||||
} else if (!is_null($type) && $type == \Format::strftimeYMDHMS && \Utility\Date::isValidUnixtime($value)) {
|
||||
$value = strftime(\Format::strftimeYMDHMS, $value);
|
||||
|
||||
} else if(!is_null($type) && $type==\Format::strftimeSlashedYMD && \Utility\Date::isValidUnixtime($value)){
|
||||
|
||||
} else if (!is_null($type) && $type == \Format::strftimeSlashedYMD && \Utility\Date::isValidUnixtime($value)) {
|
||||
$value = strftime(\Format::strftimeSlashedYMD, $value);
|
||||
|
||||
} else if(!is_null($type) && $type==\Format::latLng1){
|
||||
|
||||
} else if (!is_null($type) && $type == \Format::latLng1) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ($this->hasParam($key)) {
|
||||
$this->_PARAMS = array_filter($this->_PARAMS, function ($param) use ($key) {
|
||||
return $param["name"] !== $key;
|
||||
});
|
||||
}
|
||||
|
||||
$this->_PARAMS[] = array("name" => $key, "value" => $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function params($v = null){ // set tutti parametri (sovrascrive)
|
||||
|
||||
public function hasParam($paramName) {
|
||||
$param = array_filter($this->_PARAMS, function ($pr) use ($paramName) {
|
||||
return $pr["name"] === $paramName;
|
||||
});
|
||||
|
||||
return !empty($param);
|
||||
}
|
||||
|
||||
public function params($v = null) { // set tutti parametri (sovrascrive)
|
||||
$this->_PARAMS = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function resetParams(){
|
||||
|
||||
public function resetParams() {
|
||||
return $this->params(array());
|
||||
}
|
||||
|
||||
private function get_where(){
|
||||
return !is_null($this->_WHERE_COND)? rtrim($this->_WHERE_COND, " AND ") : null;
|
||||
|
||||
private function get_where() {
|
||||
return !is_null($this->_WHERE_COND) ? rtrim($this->_WHERE_COND, " AND ") : null;
|
||||
}
|
||||
|
||||
public function where($fieldname = null, $value = false, $type = null){ // si puo settare in onetime o in append
|
||||
$this->_WHERE_COND = blankIfNull($this->_WHERE_COND).Query::process_whereParameters($fieldname, $value, $type)." AND ";
|
||||
|
||||
public function where($fieldname = null, $value = false, $type = null) { // si puo settare in onetime o in append
|
||||
$this->_WHERE_COND = blankIfNull($this->_WHERE_COND) . Query::process_whereParameters($fieldname, $value, $type) . " AND ";
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function get_queryCompiled(){
|
||||
if(!is_null($this->_QUERY)){
|
||||
|
||||
private function get_queryCompiled() {
|
||||
if (!is_null($this->_QUERY)) {
|
||||
$query = $this->_QUERY;
|
||||
foreach($this->_PARAMS as $param){
|
||||
foreach ($this->_PARAMS as $param) {
|
||||
$query = str_replace("[[{$param["name"]}]]", "'{$param["value"]}'", $query);
|
||||
}
|
||||
return nullIfBlank($query);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function getSubreportDTOList(){
|
||||
|
||||
private function getSubreportDTOList() {
|
||||
$itemList = null;
|
||||
if(!is_null($this->_SUBREPORTS) && count($this->_SUBREPORTS)>0){
|
||||
if (!is_null($this->_SUBREPORTS) && count($this->_SUBREPORTS) > 0) {
|
||||
$itemList = array();
|
||||
foreach($this->_SUBREPORTS as $item){
|
||||
if(\boolValue($item["setted"])){
|
||||
foreach ($this->_SUBREPORTS as $item) {
|
||||
if (\boolValue($item["setted"])) {
|
||||
$isJrxml = \Utility\Str::ciEquals($item["format"], "jrxml");
|
||||
$itemList[] = array(
|
||||
"name" => $item["jasper_filename"],
|
||||
@@ -332,22 +384,22 @@ class JasperProcessor{
|
||||
}
|
||||
return $itemList;
|
||||
}
|
||||
|
||||
private function getJasperDTO(){
|
||||
|
||||
private function getJasperDTO() {
|
||||
$JasperDTO = new EntityItem;
|
||||
$JasperDTO->set("reportName", $this->_REPORT_NAME)
|
||||
->set("query", $this->get_queryCompiled())
|
||||
->set("jsonSource", $this->_JSON_SOURCE)
|
||||
->set("b64ReportJrxml", $this->_B64_JRXML)
|
||||
->set("subreports", $this->getSubreportDTOList())
|
||||
->set("whereCond", $this->get_where());
|
||||
|
||||
foreach($this->_PARAMS as $item){
|
||||
->set("query", $this->get_queryCompiled())
|
||||
->set("jsonSource", $this->_JSON_SOURCE)
|
||||
->set("b64ReportJrxml", $this->_B64_JRXML)
|
||||
->set("subreports", $this->getSubreportDTOList())
|
||||
->set("whereCond", $this->get_where());
|
||||
|
||||
foreach ($this->_PARAMS as $item) {
|
||||
$Param = new EntityItem;
|
||||
$Param->set("name", $item["name"])->set("value", $item["value"]);
|
||||
$JasperDTO->set("params")->append($Param);
|
||||
}
|
||||
|
||||
|
||||
return $JasperDTO;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
<?php
|
||||
class JtbDisegniFiles{
|
||||
|
||||
class JtbDisegniFiles {
|
||||
const DISEGNO_ALLEGATO = "DISEGNO/ALLEGATO";
|
||||
const ETICHETTA_CARTONE = "ETICHETTA_UI";
|
||||
const ETICHETTA_PRODOTTO = "ETICHETTA_UC";
|
||||
const ETICHETTA_SSCC = "ETICHETTA_UL";
|
||||
const REPORT_JASPER = "REPORT_JASPER";
|
||||
const SUBREPORT_JASPER = "SUBREPORT_JASPER";
|
||||
|
||||
public static function get_items($filter){ // pk cod_disegno + filename
|
||||
|
||||
public static function get_items($filter) { // pk cod_disegno + filename
|
||||
$sql = "SELECT * FROM(
|
||||
SELECT jtb_disegni_files.cod_disegno,
|
||||
jtb_disegni_files.file_name,
|
||||
@@ -21,15 +22,15 @@ class JtbDisegniFiles{
|
||||
FROM jtb_disegni_files LEFT OUTER JOIN jrl_cicl_disegni ON jtb_disegni_files.cod_disegno = jrl_cicl_disegni.cod_disegno
|
||||
) t
|
||||
WHERE 1=1";
|
||||
|
||||
|
||||
$Query = new Query($sql);
|
||||
foreach($filter as $k => $v){
|
||||
foreach ($filter as $k => $v) {
|
||||
$Query->where($k, $v);
|
||||
}
|
||||
$Ret = $Query->toRet()->date2ts()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$arr_rows = $Ret->get_data();
|
||||
foreach($arr_rows as $i => $row){
|
||||
foreach ($arr_rows as $i => $row) {
|
||||
$row["content"] = Utility\Compression\GZ::uncompress($row["content"]);
|
||||
$content = $row["content"];
|
||||
$fileName = $row["file_name"];
|
||||
@@ -43,35 +44,35 @@ class JtbDisegniFiles{
|
||||
"icon_style" => $icon["style"]
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
$Ret->set_data($arr_rows);
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function get_item($key){
|
||||
|
||||
public static function get_item($key) {
|
||||
$Ret = self::get_items($key);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
if(count($retData)>0){
|
||||
if (count($retData) > 0) {
|
||||
$Ret->set_data($retData[0]);
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("Allegato non valido");
|
||||
}
|
||||
}
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function cache($key){
|
||||
|
||||
public static function cache($key) {
|
||||
$Ret = self::get_item($key);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
$content = $retData["content"];
|
||||
$fileName = pathinfo($retData["file_name"], PATHINFO_BASENAME);
|
||||
$Ret = \Cache::writeR($fileName, $content, "JtbDisegniFiles", true);
|
||||
}
|
||||
|
||||
|
||||
return $Ret->set_data(null);
|
||||
}
|
||||
}
|
||||
121
public_html/classes/KendoService.class.php
Normal file
121
public_html/classes/KendoService.class.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
class KendoService {
|
||||
public static function queryInizializerService($data, $sqlFile, $boolSOLO, $defaultOrderField) {
|
||||
$sort = (isset($data['sort'])) ? $data['sort'] : null;
|
||||
$limit = (isset($data['pageSize'])) ? $data['pageSize'] : '20';
|
||||
$offset = (isset($data['skip'])) ? $data['skip'] : '0';
|
||||
|
||||
if (is_null($sort)) {
|
||||
$order_string = $defaultOrderField;
|
||||
} else {
|
||||
$order_string = implode(",", array_map(function ($element) {
|
||||
return $element["field"] . " " . strtoupper($element["dir"]);
|
||||
}, $sort));
|
||||
}
|
||||
|
||||
$query = new Query();
|
||||
|
||||
$query
|
||||
->importSqlFile($sqlFile)
|
||||
->cacheResult()
|
||||
->toRet()
|
||||
->date2ts();
|
||||
|
||||
if ($boolSOLO) {
|
||||
$query
|
||||
->setVar('order_string', $order_string)
|
||||
->setVar('limit', $limit)
|
||||
->setVar('offset', $offset);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
public static function queryFiltersService($data) {
|
||||
$filter = (isset($data['filter'])) ? $data['filter'] : array();
|
||||
$filtered = array();
|
||||
|
||||
if (isset($filter["filters"])) {
|
||||
$filters = from($filter["filters"])->groupBy(function ($x) {
|
||||
return $x["field"];
|
||||
})->toArrayDeep();
|
||||
|
||||
foreach ($filters as $filt) {
|
||||
$filt = $filt[0];
|
||||
|
||||
$operator = (array_key_exists('operator', $filt)) ? $filt['operator'] : "";
|
||||
$field = (array_key_exists('field', $filt)) ? $filt['field'] : "";
|
||||
$value = (array_key_exists('value', $filt)) ? $filt['value'] : "";
|
||||
$val = null;
|
||||
|
||||
switch ($operator) {
|
||||
case 'contains' :
|
||||
$op = 'LIKE';
|
||||
$val = '%' . $value . '%';
|
||||
break;
|
||||
case 'doesnotcontain' :
|
||||
$op = 'NOT LIKE';
|
||||
$val = '%' . $value . '%';
|
||||
break;
|
||||
case 'neq' :
|
||||
$op = '<>';
|
||||
$val = $value;
|
||||
break;
|
||||
case 'startswith' :
|
||||
$op = 'LIKE';
|
||||
$val = $value . '%';
|
||||
break;
|
||||
case 'endswith' :
|
||||
$op = 'LIKE';
|
||||
$val = '%' . $value;
|
||||
break;
|
||||
case 'isnull' :
|
||||
$op = 'IS NULL';
|
||||
break;
|
||||
case 'isnotnull' :
|
||||
$op = 'IS NOT NULL';
|
||||
break;
|
||||
case 'isempty' :
|
||||
$op = 'LIKE';
|
||||
$val = '';
|
||||
break;
|
||||
case 'isnotempty' :
|
||||
$op = 'NOT LIKE';
|
||||
$val = '';
|
||||
break;
|
||||
case 'gte' :
|
||||
$op = '>=';
|
||||
$val = $value;
|
||||
break;
|
||||
case 'gt' :
|
||||
$op = '>';
|
||||
$val = $value;
|
||||
break;
|
||||
case 'lte' :
|
||||
$op = '<=';
|
||||
$val = $value;
|
||||
break;
|
||||
case 'lt' :
|
||||
$op = '<';
|
||||
$val = $value;
|
||||
break;
|
||||
case 'eq':
|
||||
default:
|
||||
$op = '=';
|
||||
$val = $value;
|
||||
break;
|
||||
}
|
||||
|
||||
$filtered[] = array(
|
||||
"field" => $field,
|
||||
"op" => $op,
|
||||
"val" => $val,
|
||||
"value" => $value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $filtered;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
class Mime{
|
||||
|
||||
class Mime {
|
||||
const JPG = "image/jpeg";
|
||||
const JPEG = "image/jpeg";
|
||||
const PNG = "image/png";
|
||||
@@ -17,12 +18,12 @@ class Mime{
|
||||
const DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
||||
const PPT = "application/vnd.ms-powerpoint";
|
||||
const PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
||||
|
||||
public static function get_list(){ // restituisce lista ["application/json" => ["json"],...]
|
||||
|
||||
public static function get_list() { // restituisce lista ["application/json" => ["json"],...]
|
||||
$mimeClass = new ReflectionClass("Mime");
|
||||
$returnArray = array();
|
||||
foreach($mimeClass->getConstants() as $key => $value){
|
||||
if(!isset($returnArray[$value])){
|
||||
foreach ($mimeClass->getConstants() as $key => $value) {
|
||||
if (!isset($returnArray[$value])) {
|
||||
$returnArray[$value] = array();
|
||||
}
|
||||
$returnArray[$value][] = strtolower($key);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Modulo
|
||||
{
|
||||
class Modulo {
|
||||
private $id = null; // camel case decoded
|
||||
private $title = null;
|
||||
private $pages = null;
|
||||
@@ -18,30 +17,25 @@ class Modulo
|
||||
private $azienda = null; // current default
|
||||
private $optionsAzienda = null;
|
||||
|
||||
public function __construct($id = null, $azienda = null)
|
||||
{
|
||||
public function __construct($id = null, $azienda = null) {
|
||||
$id = \Utility\Str::isCamelCaseEncoded($id) ? strtolower(\Utility\Str::camelCaseDecode($id)) : $id;
|
||||
$this->setAzienda($azienda)->load($id);
|
||||
}
|
||||
|
||||
public function isLoaded()
|
||||
{
|
||||
public function isLoaded() {
|
||||
return !is_null($this->id);
|
||||
}
|
||||
|
||||
private function getIdCamelCaseEncoded()
|
||||
{
|
||||
private function getIdCamelCaseEncoded() {
|
||||
return ucfirst(\Utility\Str::camelCaseEncode($this->id));
|
||||
}
|
||||
|
||||
public function setAzienda($v)
|
||||
{
|
||||
public function setAzienda($v) {
|
||||
$this->azienda = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function load($id)
|
||||
{
|
||||
public function load($id) {
|
||||
if (!is_null($id)) {//var_dump($id);
|
||||
$listModuli = \PVM::getListModuli();//echopre($listModuli);
|
||||
if (isset($listModuli[$id])) {
|
||||
@@ -65,36 +59,30 @@ class Modulo
|
||||
}
|
||||
}
|
||||
|
||||
public function getOptionAzienda($key)
|
||||
{
|
||||
public function getOptionAzienda($key) {
|
||||
if (!is_null($this->optionsAzienda) && array_key_exists($key, $this->optionsAzienda)) {
|
||||
return $this->optionsAzienda[$key];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
public function getTitle() {
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function getLibs()
|
||||
{
|
||||
public function getLibs() {
|
||||
return $this->libs;
|
||||
}
|
||||
|
||||
public function getGroup()
|
||||
{
|
||||
public function getGroup() {
|
||||
return $this->group;
|
||||
}
|
||||
|
||||
public function getPosition()
|
||||
{
|
||||
public function getPosition() {
|
||||
if (!is_null($this->getOptionAzienda("position"))) {
|
||||
$positions = $this->position;
|
||||
|
||||
@@ -114,30 +102,25 @@ class Modulo
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
public function getChildren()
|
||||
{
|
||||
public function getChildren() {
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
public function getPages()
|
||||
{
|
||||
public function getPages() {
|
||||
return $this->pages;
|
||||
}
|
||||
|
||||
public function getPage()
|
||||
{
|
||||
public function getPage() {
|
||||
$parts = explode("?", $this->getPages()); // es. "colli_aperti.php?spedizione" -> "colli_aperti.php", "spedizione"
|
||||
return $parts[0];
|
||||
}
|
||||
|
||||
public function getPageDet()
|
||||
{
|
||||
public function getPageDet() {
|
||||
$parts = explode("?", $this->getPages()); // es. "colli_aperti.php?spedizione" -> "colli_aperti.php", "spedizione"
|
||||
return isset($parts[1]) ? $parts[1] : null;
|
||||
}
|
||||
|
||||
private function loadOptionsAzienda()
|
||||
{
|
||||
private function loadOptionsAzienda() {
|
||||
$id = $this->id;
|
||||
$result = array_values(array_filter(AziendaUtils::getModuli($this->azienda), function ($x) use ($id) {
|
||||
return $x["name"] === $id;
|
||||
@@ -157,8 +140,7 @@ class Modulo
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isAuthorizedToCurrentUser($ignoreDev = false)
|
||||
{
|
||||
public function isAuthorizedToCurrentUser($ignoreDev = false) {
|
||||
if (!$ignoreDev && \PVM::isDevClient() && $this->flagDev === true) {
|
||||
return true;
|
||||
}
|
||||
@@ -170,23 +152,19 @@ class Modulo
|
||||
return \PVM::processItemPolicyToCurrentUser($this->optionsAzienda);
|
||||
}
|
||||
|
||||
private static function getObjectValue($object, $key, $default = null)
|
||||
{
|
||||
private static function getObjectValue($object, $key, $default = null) {
|
||||
return array_key_exists($key, $object) ? $object[$key] : $default;
|
||||
}
|
||||
|
||||
public function getUsergroupsPolicy()
|
||||
{
|
||||
public function getUsergroupsPolicy() {
|
||||
return $this->getOptionAzienda("usergroups");
|
||||
}
|
||||
|
||||
public function getUsersPolicy()
|
||||
{
|
||||
public function getUsersPolicy() {
|
||||
return $this->getOptionAzienda("users");
|
||||
}
|
||||
|
||||
public function getParsedPolicy()
|
||||
{
|
||||
public function getParsedPolicy() {
|
||||
$retGroup = null;
|
||||
|
||||
$usergroups = $this->getUsergroupsPolicy();
|
||||
@@ -220,8 +198,7 @@ class Modulo
|
||||
return array("groups" => $retGroup, "users" => $retUser);
|
||||
}
|
||||
|
||||
public function runMethod($method, $data = array())
|
||||
{
|
||||
public function runMethod($method, $data = array()) {
|
||||
$Ret = new \Ret;
|
||||
if ($this->isLoaded()) {
|
||||
$idModulo = $this->id;
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
<?php
|
||||
class Mssql{
|
||||
|
||||
class Mssql {
|
||||
private $hostName = null;
|
||||
private $userName = null;
|
||||
private $password = null;
|
||||
private $dbName = null;
|
||||
|
||||
|
||||
public $Row;
|
||||
public $Error_message = null;
|
||||
private $Link_ID = 0;
|
||||
private $Query_ID = 0;
|
||||
private $Record = array();
|
||||
|
||||
public function __construct($settings = null){
|
||||
if(!is_null($settings)){
|
||||
|
||||
public function __construct($settings = null) {
|
||||
if (!is_null($settings)) {
|
||||
$this->hostName = $settings["hostName"];
|
||||
$this->userName = $settings["userName"];
|
||||
$this->password = $settings["password"];
|
||||
@@ -21,106 +22,106 @@ class Mssql{
|
||||
}
|
||||
|
||||
|
||||
private function close(){
|
||||
private function close() {
|
||||
$this->connection = null;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
public function __destruct() {
|
||||
$this->close();
|
||||
}
|
||||
private function connect(){
|
||||
if($this->Link_ID==0){
|
||||
|
||||
private function connect() {
|
||||
if ($this->Link_ID == 0) {
|
||||
$this->Link_ID = @mssql_connect($this->hostName, $this->userName, $this->password);
|
||||
if(!$this->Link_ID){
|
||||
$this->Error_message = "Connessione su database host ".$this->hostName." fallita";
|
||||
if (!$this->Link_ID) {
|
||||
$this->Error_message = "Connessione su database host " . $this->hostName . " fallita";
|
||||
return false;
|
||||
}
|
||||
if(!@mssql_select_db($this->dbName, $this->Link_ID)){
|
||||
$this->Error_message = "Database ".$this->dbName." non disponibile (".mssql_get_last_message().")";
|
||||
if (!@mssql_select_db($this->dbName, $this->Link_ID)) {
|
||||
$this->Error_message = "Database " . $this->dbName . " non disponibile (" . mssql_get_last_message() . ")";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function query($Query_String){
|
||||
if($this->connect()){
|
||||
public function query($Query_String) {
|
||||
if ($this->connect()) {
|
||||
@mssql_query("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED");
|
||||
// @mssql_query("SET ANSI_WARNINGS ON");
|
||||
// @mssql_query("SET ANSI_WARNINGS ON");
|
||||
|
||||
$this->Query_ID = @mssql_query($Query_String, $this->Link_ID);
|
||||
$this->Row = 0;
|
||||
// var_dump($this->Query_ID." ".$Query_String);
|
||||
if(!$this->Query_ID){
|
||||
// var_dump($this->Query_ID." ".$Query_String);
|
||||
if (!$this->Query_ID) {
|
||||
$this->Error_message = mssql_get_last_message();
|
||||
}
|
||||
return $this->Query_ID;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function begin_transaction(){
|
||||
|
||||
public function begin_transaction() {
|
||||
$this->connect();
|
||||
$result = @mssql_query("BEGIN TRAN");
|
||||
return !($result===false);
|
||||
return !($result === false);
|
||||
//return $this->query("BEGIN TRAN");
|
||||
}
|
||||
|
||||
public function commit(){
|
||||
if($this->Link_ID!=0){
|
||||
|
||||
public function commit() {
|
||||
if ($this->Link_ID != 0) {
|
||||
$result = @mssql_query("COMMIT");
|
||||
if($result===false){
|
||||
if ($result === false) {
|
||||
$this->Error_message = mssql_get_last_message();
|
||||
}
|
||||
return !($result===false);
|
||||
return !($result === false);
|
||||
//return $this->query("COMMIT");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function rollback(){
|
||||
if($this->Link_ID!=0){
|
||||
|
||||
public function rollback() {
|
||||
if ($this->Link_ID != 0) {
|
||||
$result = @mssql_query("ROLLBACK");
|
||||
if($result===false){
|
||||
if ($result === false) {
|
||||
$this->Error_message = mssql_get_last_message();
|
||||
}
|
||||
return !($result===false);
|
||||
// return $this->query("ROLLBACK");
|
||||
return !($result === false);
|
||||
// return $this->query("ROLLBACK");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function next_record(){
|
||||
|
||||
public function next_record() {
|
||||
$this->Record = mssql_fetch_array($this->Query_ID);
|
||||
$this->Row += 1;
|
||||
$stat = is_array($this->Record);
|
||||
return $stat;
|
||||
}
|
||||
|
||||
public function free_stmt(){ // libera memoria
|
||||
|
||||
public function free_stmt() { // libera memoria
|
||||
mssql_free_result($this->Query_ID);
|
||||
// mssql_free_statement($stmt)
|
||||
// mssql_free_statement($stmt)
|
||||
return true;
|
||||
}
|
||||
|
||||
public function num_rows(){
|
||||
|
||||
public function num_rows() {
|
||||
return mssql_num_rows($this->Query_ID);
|
||||
}
|
||||
|
||||
public function num_fields(){
|
||||
public function num_fields() {
|
||||
return mssql_num_fields($this->Query_ID);
|
||||
}
|
||||
|
||||
public function field_name($column){
|
||||
|
||||
public function field_name($column) {
|
||||
return mssql_field_name($this->Query_ID, $column);
|
||||
}
|
||||
|
||||
public function field_type($column){
|
||||
|
||||
public function field_type($column) {
|
||||
return mssql_field_type($this->Query_ID, $column);
|
||||
}
|
||||
|
||||
public function f($Name){
|
||||
|
||||
public function f($Name) {
|
||||
return $this->Record[$Name];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,20 @@
|
||||
<?php
|
||||
class MtbAartLink{
|
||||
|
||||
public static function get_items($codMart, $idRiga = null){
|
||||
class MtbAartLink {
|
||||
|
||||
public static function get_items($codMart, $idRiga = null) {
|
||||
$Query = new Query;
|
||||
$Query->select("cod_mart", "id_riga", "path_link", "descrizione_link", "3*(DATALENGTH(b64_content)/4) AS file_size")
|
||||
->from("mtb_aart_link")
|
||||
->where("cod_mart", $codMart);
|
||||
if(!is_null($idRiga)){
|
||||
if (!is_null($idRiga)) {
|
||||
$Query->where("id_riga", $idRiga);
|
||||
}
|
||||
|
||||
$Ret = $Query->toRet()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$arr_rows = $Ret->get_data();
|
||||
foreach($arr_rows as $i => $row){
|
||||
foreach ($arr_rows as $i => $row) {
|
||||
$pathLink = $row["path_link"];
|
||||
$icon = Utility\File::getFaIcoFromName($pathLink);
|
||||
$arr_rows[$i]["file_name"] = $pathLink;
|
||||
@@ -31,9 +32,9 @@ class MtbAartLink{
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function get_item($codMart, $idRiga){
|
||||
public static function get_item($codMart, $idRiga) {
|
||||
$Ret = self::get_items($codMart, $idRiga);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
$Ret->set_data(count($retData) > 0 ? $retData[0] : null);
|
||||
}
|
||||
@@ -41,8 +42,7 @@ class MtbAartLink{
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function getItemContent($codMart, $idRiga, $includeDescrizione = false, $includeB64 = true)
|
||||
{
|
||||
public static function getItemContent($codMart, $idRiga, $includeDescrizione = false, $includeB64 = true) {
|
||||
$Query = new Query;
|
||||
|
||||
$Query->select("path_link", "id_riga");
|
||||
@@ -87,61 +87,60 @@ class MtbAartLink{
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function remove($codMart, $idRiga){
|
||||
public static function remove($codMart, $idRiga) {
|
||||
$MtbAartLink = new EntityItem("mtb_aart_link");
|
||||
$MtbAartLink->set("idRiga", $idRiga)->delete();
|
||||
|
||||
$MtbAart = new EntityItem("mtb_aart");
|
||||
$MtbAart->update()
|
||||
->set("codMart", $codMart)
|
||||
->set("mtbAartLink")->append($MtbAartLink);
|
||||
|
||||
->set("codMart", $codMart)
|
||||
->set("mtbAartLink")->append($MtbAartLink);
|
||||
|
||||
$Ret = $MtbAart->send()->set_data(null);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret->set_data(array("cod_mart" => $codMart, "id_riga" => $idRiga));
|
||||
}
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function upload($codMart, $fileItem){
|
||||
public static function upload($codMart, $fileItem) {
|
||||
$Ret = new Ret;
|
||||
|
||||
if(file_exists($fileItem["tmp_name"])){
|
||||
if (file_exists($fileItem["tmp_name"])) {
|
||||
$name = str_replace("'", "", $fileItem["name"]);
|
||||
$content = file_get_contents($fileItem["tmp_name"]);
|
||||
|
||||
if(Utility\File::isImageFromBlob($content)){
|
||||
if (Utility\File::isImageFromBlob($content)) {
|
||||
$content = \Utility\Image::resizeStaticToBlob($content, 1600, 1200);
|
||||
if($content === false){
|
||||
if ($content === false) {
|
||||
return $Ret->set_errorCode(\ErrorHandler::FAIL_IMAGERESIZE);
|
||||
}
|
||||
}
|
||||
|
||||
$Ret = self::save($codMart, $name, base64_encode($content));
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
@unlink($fileItem["tmp_name"]);
|
||||
}
|
||||
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("File non trovato");
|
||||
}
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
private static function get_uniqueFileName($fileName){
|
||||
private static function get_uniqueFileName($fileName) {
|
||||
$Query = new Query;
|
||||
$Query->select("path_link")->from("mtb_aart_link");
|
||||
$Ret = $Query->firstColumn()->toRet()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret->set_string(Utility\File::check_duplicateFilename($Ret->get_data(), $fileName, "-[N]", 3));
|
||||
}
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function save($codMart, $pathLink = null, $b64Content = null, $idRiga = null, $descrizioneLink = null, $uniqueFileName = false)
|
||||
{
|
||||
public static function save($codMart, $pathLink = null, $b64Content = null, $idRiga = null, $descrizioneLink = null, $uniqueFileName = false) {
|
||||
$MtbAartLink = new EntityItem("mtb_aart_link");
|
||||
$MtbAartLink->insert_or_update()
|
||||
->set("idRiga", $idRiga)
|
||||
@@ -188,38 +187,38 @@ class MtbAartLink{
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function cache($codMart, $idRiga, $options = array()){
|
||||
public static function cache($codMart, $idRiga, $options = array()) {
|
||||
$retData = null;
|
||||
$options["renew"] = isset($options["renew"]) && $options["renew"] !== false;
|
||||
$options["quality"] = isset($options["quality"]) ? $options["quality"] : null;
|
||||
$options["resize"] = isset($options["resize"]) && is_array($options["resize"]) && isset($options["resize"][0]) ? $options["resize"] : false;
|
||||
$sadImageOnError = isset($options["sadImageOnError"]) && $options["sadImageOnError"] !== false;
|
||||
|
||||
|
||||
$Ret = \MtbAartLink::getItemContent($codMart, $idRiga);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$fileItem = $Ret->get_data();
|
||||
$fileName = $fileItem["file_name"];
|
||||
|
||||
if(Utility\File::isImageFromName($fileName) && $options["resize"] !== false){
|
||||
if (Utility\File::isImageFromName($fileName) && $options["resize"] !== false) {
|
||||
$Ret = \Utility\Image::getResizeImage($fileName, $options, $fileItem["content"]);
|
||||
|
||||
} else{
|
||||
} else {
|
||||
$filePath = \Cache::get_filepath($fileName, true, true);
|
||||
if($options["renew"] === false && file_exists($filePath)){
|
||||
if ($options["renew"] === false && file_exists($filePath)) {
|
||||
$Ret->set_string($filePath)->set_data(null);
|
||||
|
||||
} else{
|
||||
} else {
|
||||
$Ret = \Cache::writeR($fileName, $fileItem["content"], true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$Ret->is_OK() && $sadImageOnError){
|
||||
if (!$Ret->is_OK() && $sadImageOnError) {
|
||||
$retData = array("sad" => true);
|
||||
$filePath = "images/sad.png";
|
||||
if($options["resize"] !== false){
|
||||
if ($options["resize"] !== false) {
|
||||
$Ret = Utility\Image::getResizeImage($filePath, $options);
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_OK()->set_string($filePath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,123 +1,124 @@
|
||||
<?php
|
||||
class OrdiniWeb{
|
||||
private static function build_entityItem($key){
|
||||
|
||||
class OrdiniWeb {
|
||||
private static function build_entityItem($key) {
|
||||
$WdtbOrdt = new EntityItem("wdtb_ordt");
|
||||
$WdtbOrdt->set("gestione", $key["gestione"])
|
||||
->setDate("dataOrd", $key["data_ord"])
|
||||
->set("numOrd", $key["num_ord"])
|
||||
->set("serie", $key["serie"]);
|
||||
->setDate("dataOrd", $key["data_ord"])
|
||||
->set("numOrd", $key["num_ord"])
|
||||
->set("serie", $key["serie"]);
|
||||
return $WdtbOrdt;
|
||||
}
|
||||
|
||||
private static function isDeletable($key){
|
||||
|
||||
private static function isDeletable($key) {
|
||||
$Query = new Query;
|
||||
$Query->select("num_ord")
|
||||
->from("dtb_ordt")
|
||||
->where("gestione", $key["gestione"])
|
||||
->whereDate("data_ord", $key["data_ord"])
|
||||
->where("serie", $key["serie"])
|
||||
->where("num_ord_provv", $key["num_ord"]);
|
||||
->from("dtb_ordt")
|
||||
->where("gestione", $key["gestione"])
|
||||
->whereDate("data_ord", $key["data_ord"])
|
||||
->where("serie", $key["serie"])
|
||||
->where("num_ord_provv", $key["num_ord"]);
|
||||
$Ret = $Query->toRet()->countRows();
|
||||
if($Ret->is_OK()){
|
||||
$Ret->set_boolean($Ret->get_number()==0);
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret->set_boolean($Ret->get_number() == 0);
|
||||
}
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
private static function getFlagElaborato($key){
|
||||
|
||||
private static function getFlagElaborato($key) {
|
||||
$Query = new Query;
|
||||
$Query->select("flag_elaborato")
|
||||
->from("wdtb_ordt")
|
||||
->where("gestione", $key["gestione"])
|
||||
->whereDate("data_ord", $key["data_ord"])
|
||||
->where("num_ord", $key["num_ord"])
|
||||
->where("serie", $key["serie"]);
|
||||
|
||||
->from("wdtb_ordt")
|
||||
->where("gestione", $key["gestione"])
|
||||
->whereDate("data_ord", $key["data_ord"])
|
||||
->where("num_ord", $key["num_ord"])
|
||||
->where("serie", $key["serie"]);
|
||||
|
||||
return $Query->toRet()->firstRowFirstValue()->execute();
|
||||
}
|
||||
|
||||
public static function isElaborato($key){
|
||||
|
||||
public static function isElaborato($key) {
|
||||
$Ret = self::getFlagElaborato($key);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$flagElaborato = $Ret->get_data();
|
||||
$Ret->set_boolean($flagElaborato==="S");
|
||||
$Ret->set_boolean($flagElaborato === "S");
|
||||
}
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function delete($data){
|
||||
|
||||
public static function delete($data) {
|
||||
$Ret = new Ret;
|
||||
$key = $data["key"];
|
||||
if(!is_null($key)){
|
||||
if (!is_null($key)) {
|
||||
$Ret = self::isDeletable($key);
|
||||
if($Ret->is_OK()){
|
||||
if($Ret->get_boolean()){
|
||||
if ($Ret->is_OK()) {
|
||||
if ($Ret->get_boolean()) {
|
||||
$WdtbOrdt = self::build_entityItem($key);
|
||||
$Ret = $WdtbOrdt->delete()->send();
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Non è possibile eliminare un ordine già importato");
|
||||
}
|
||||
}
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Chiave ordine non valida");
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function confirm($data, $flagElaborato = "N"){
|
||||
|
||||
public static function confirm($data, $flagElaborato = "N") {
|
||||
$Ret = new Ret;
|
||||
if(!is_null($data["key"])){
|
||||
if (!is_null($data["key"])) {
|
||||
$WdtbOrdt = self::build_entityItem($data["key"]);
|
||||
$WdtbOrdt->set("flagElaborato", $flagElaborato);
|
||||
|
||||
if(array_key_exists("note", $data)){
|
||||
|
||||
if (array_key_exists("note", $data)) {
|
||||
$WdtbOrdt->set("note", !is_null($data["note"]) ? substr($data["note"], 0, 255) : null, true);
|
||||
}
|
||||
|
||||
|
||||
$Ret = $WdtbOrdt->update()->send();
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Ordine non valido");
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function reopen($data){
|
||||
|
||||
public static function reopen($data) {
|
||||
$Ret = new Ret;
|
||||
if(!is_null($data["key"])){
|
||||
if (!is_null($data["key"])) {
|
||||
$Ret = self::getFlagElaborato($data["key"]);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$flagElaborato = $Ret->get_data(); // ignorato stato 'I'
|
||||
if($flagElaborato=="S"){
|
||||
if ($flagElaborato == "S") {
|
||||
$Ret->set_error("Non è possibile aprire un ordine già importato");
|
||||
|
||||
} else if(in_array($flagElaborato, array("N", "P")) || array_key_exists("note", $data)){ // AGGIORNO SE IL FLAG ELABORATO E' N OPPURE SE CI SONO NOTE DA SALVARE
|
||||
} else if (in_array($flagElaborato, array("N", "P")) || array_key_exists("note", $data)) { // AGGIORNO SE IL FLAG ELABORATO E' N OPPURE SE CI SONO NOTE DA SALVARE
|
||||
$WdtbOrdt = self::build_entityItem($data["key"]);
|
||||
$WdtbOrdt->update()
|
||||
->set("flagElaborato", "I")
|
||||
->set("userName", User::get_current_username());
|
||||
|
||||
if(array_key_exists("note", $data)){
|
||||
->set("flagElaborato", "I")
|
||||
->set("userName", User::get_current_username());
|
||||
|
||||
if (array_key_exists("note", $data)) {
|
||||
$WdtbOrdt->set("note", !is_null($data["note"]) ? substr($data["note"], 0, 255) : null, true);
|
||||
}
|
||||
|
||||
|
||||
$Ret = $WdtbOrdt->send();
|
||||
}
|
||||
}
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Ordine non valido");
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function calc_hashOrdine($key){
|
||||
$s = $key["data_ord"].$key["gestione"].(isset($key["serie"])?$key["serie"]:"").$key["num_ord"];
|
||||
|
||||
public static function calc_hashOrdine($key) {
|
||||
$s = $key["data_ord"] . $key["gestione"] . (isset($key["serie"]) ? $key["serie"] : "") . $key["num_ord"];
|
||||
return substr(md5($s), 0, 10);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,20 @@
|
||||
<?php
|
||||
class PDOSqlsrv{
|
||||
|
||||
class PDOSqlsrv {
|
||||
private $hostName = null;
|
||||
private $userName = null;
|
||||
private $password = null;
|
||||
private $dbName = null;
|
||||
|
||||
|
||||
private $connection = null;
|
||||
private $stmt = null;
|
||||
|
||||
|
||||
public $Row;
|
||||
public $Error_message = null;
|
||||
private $Record = array();
|
||||
|
||||
public function __construct($settings = null){
|
||||
if(!is_null($settings)){
|
||||
|
||||
public function __construct($settings = null) {
|
||||
if (!is_null($settings)) {
|
||||
$this->hostName = $settings["hostName"];
|
||||
$this->userName = $settings["userName"];
|
||||
$this->password = $settings["password"];
|
||||
@@ -21,22 +22,21 @@ class PDOSqlsrv{
|
||||
}
|
||||
}
|
||||
|
||||
private function close(){
|
||||
private function close() {
|
||||
$this->connection = null;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
public function __destruct() {
|
||||
$this->close();
|
||||
}
|
||||
|
||||
|
||||
private function connect(){
|
||||
private function connect() {
|
||||
$this->connection = new PDO(
|
||||
"sqlsrv:".
|
||||
"server=".$this->hostName.";".
|
||||
"Database=".$this->dbName.";".
|
||||
"TransactionIsolation=".PDO::SQLSRV_TXN_READ_UNCOMMITTED,
|
||||
"sqlsrv:" .
|
||||
"server=" . $this->hostName . ";" .
|
||||
"Database=" . $this->dbName . ";" .
|
||||
"TransactionIsolation=" . PDO::SQLSRV_TXN_READ_UNCOMMITTED,
|
||||
$this->userName,
|
||||
$this->password,
|
||||
array(
|
||||
@@ -46,21 +46,21 @@ class PDOSqlsrv{
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getConnection(){
|
||||
if(is_null($this->connection)){
|
||||
|
||||
public function getConnection() {
|
||||
if (is_null($this->connection)) {
|
||||
$this->connect();
|
||||
}
|
||||
return $this->connection;
|
||||
}
|
||||
|
||||
public function query($sql){
|
||||
if(is_null($this->connection)){
|
||||
|
||||
public function query($sql) {
|
||||
if (is_null($this->connection)) {
|
||||
$this->connect();
|
||||
}
|
||||
|
||||
|
||||
$this->stmt = $this->connection->query($sql);
|
||||
if(!$this->stmt){//
|
||||
if (!$this->stmt) {//
|
||||
$errorInfo = $this->connection->errorInfo();
|
||||
/*
|
||||
STRUTTURA errorInfo:
|
||||
@@ -71,9 +71,10 @@ class PDOSqlsrv{
|
||||
*/
|
||||
$this->Error_message = $errorInfo[2];
|
||||
}
|
||||
|
||||
|
||||
return $this->stmt;
|
||||
}
|
||||
|
||||
/*
|
||||
public function prepare($sql){
|
||||
if(is_null($this->connection)){
|
||||
@@ -102,14 +103,14 @@ class PDOSqlsrv{
|
||||
}
|
||||
}
|
||||
*/
|
||||
public function begin_transaction(){/*
|
||||
public function begin_transaction() {/*
|
||||
$this->connect();
|
||||
$result = @mssql_query("BEGIN TRAN");
|
||||
return !($result===false);*/
|
||||
//return $this->query("BEGIN TRAN");
|
||||
}
|
||||
|
||||
public function commit(){/*
|
||||
|
||||
public function commit() {/*
|
||||
if($this->Link_ID!=0){
|
||||
$result = @mssql_query("COMMIT");
|
||||
if($result===false){
|
||||
@@ -120,8 +121,8 @@ class PDOSqlsrv{
|
||||
}
|
||||
return false;*/
|
||||
}
|
||||
|
||||
public function rollback(){
|
||||
|
||||
public function rollback() {
|
||||
/*
|
||||
if($this->Link_ID!=0){
|
||||
$result = @mssql_query("ROLLBACK");
|
||||
@@ -133,44 +134,44 @@ class PDOSqlsrv{
|
||||
}
|
||||
return false;*/
|
||||
}
|
||||
|
||||
public function next_record(){
|
||||
|
||||
public function next_record() {
|
||||
$this->Record = $this->stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$this->Row += 1;
|
||||
return is_array($this->Record);
|
||||
}
|
||||
|
||||
public function free_stmt(){ // libera memoria
|
||||
if(!is_null($this->stmt)){
|
||||
|
||||
public function free_stmt() { // libera memoria
|
||||
if (!is_null($this->stmt)) {
|
||||
$this->stmt->closeCursor();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function num_rows(){
|
||||
|
||||
public function num_rows() {
|
||||
return $this->stmt->rowCount();
|
||||
}
|
||||
|
||||
public function num_fields(){
|
||||
public function num_fields() {
|
||||
return $this->stmt->columnCount();
|
||||
}
|
||||
|
||||
public function field_name($column){
|
||||
|
||||
public function field_name($column) {
|
||||
$meta = $this->stmt->getColumnMeta($column);
|
||||
return $meta["name"];
|
||||
}
|
||||
|
||||
public function field_type($column){
|
||||
|
||||
public function field_type($column) {
|
||||
$meta = $this->stmt->getColumnMeta($column);
|
||||
// echo $meta["name"].":".$meta["sqlsrv:decl_type"]." ";
|
||||
// echo $meta["name"].":".$meta["sqlsrv:decl_type"]." ";
|
||||
return self::get_typeDesc($meta["sqlsrv:decl_type"]);
|
||||
}
|
||||
|
||||
public function f($Name){
|
||||
|
||||
public function f($Name) {
|
||||
return $this->Record[$Name];
|
||||
}
|
||||
|
||||
private static function get_typeDesc($sqlsrvDeclType){
|
||||
|
||||
private static function get_typeDesc($sqlsrvDeclType) {
|
||||
return $sqlsrvDeclType;
|
||||
//return null;
|
||||
}
|
||||
|
||||
@@ -1,180 +1,243 @@
|
||||
<?php
|
||||
|
||||
namespace PVM;
|
||||
class Ajax{
|
||||
public static function getInfoComune($filter){
|
||||
class Ajax {
|
||||
public static function getInfoComune($filter) {
|
||||
$Ret = new \Ret;
|
||||
$InfoComuni = new \IMSApi\InfoComuni;
|
||||
if(isset($filter["cap"])){
|
||||
if (isset($filter["cap"])) {
|
||||
$Ret = $InfoComuni->get_comuneByCap($filter["cap"]);
|
||||
|
||||
} else if(isset($filter["nome"])){
|
||||
if(isset($filter["indirizzo"])){
|
||||
|
||||
} else if (isset($filter["nome"])) {
|
||||
if (isset($filter["indirizzo"])) {
|
||||
$InfoComuni->indirizzo($filter["indirizzo"]);
|
||||
}
|
||||
$Ret = $InfoComuni->get_comuneByNome($filter["nome"]);
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Parametri non validi");
|
||||
}
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret->set_data(array_pick($Ret->get_data(), "nome", "cap", "sigla"));
|
||||
}
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function searchComuni($filter){
|
||||
|
||||
public static function searchComuni($filter) {
|
||||
$Ret = new \Ret;
|
||||
$SearchComuni = new \IMSApi\SearchComuni;
|
||||
if(isset($filter["q"])){
|
||||
if(isset($filter["limit"])){
|
||||
if (isset($filter["q"])) {
|
||||
if (isset($filter["limit"])) {
|
||||
$SearchComuni->limit($filter["limit"]);
|
||||
}
|
||||
$Ret = $SearchComuni->q($filter["q"])->send();
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("Parametri non validi");
|
||||
}
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function check_pIva($filter){
|
||||
|
||||
public static function check_pIva($filter) {
|
||||
$CheckPIva = new \IMSApi\CheckPartitaIva;
|
||||
return $CheckPIva->countryCode($filter["nazione"])->vatNumber($filter["pIva"])->send();
|
||||
}
|
||||
|
||||
public static function check_eMail($eMail){
|
||||
|
||||
public static function check_eMail($eMail) {
|
||||
$Ret = new \Ret;
|
||||
return $Ret->set_boolean(\Utility::is_validEmail($eMail));
|
||||
}
|
||||
|
||||
public static function userTipClosed($data){
|
||||
|
||||
public static function userTipClosed($data) {
|
||||
$id = $data["id"];
|
||||
$UserTip = new \User\Tip;
|
||||
return $UserTip->close($id);
|
||||
}
|
||||
|
||||
public static function check_codFisc($cf){
|
||||
|
||||
public static function check_codFisc($cf) {
|
||||
$Ret = new \Ret;
|
||||
$isValid = true;
|
||||
|
||||
if(strlen($cf) != 16){
|
||||
|
||||
if (strlen($cf) != 16) {
|
||||
$isValid = false; // Lunghezza del codice fiscale non corretta
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$cf = strtoupper($cf);
|
||||
if(preg_match("/^[A-Za-z0-9]+\$/", $cf) != 1 ){
|
||||
if (preg_match("/^[A-Za-z0-9]+\$/", $cf) != 1) {
|
||||
$isValid = false; // contiene dei caratteri non validi
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$s = 0;
|
||||
for($i=1; $i<=13; $i+=2){
|
||||
for ($i = 1; $i <= 13; $i += 2) {
|
||||
$c = $cf[$i];
|
||||
if(strcmp($c, "0") >= 0 and strcmp($c, "9") <= 0){
|
||||
if (strcmp($c, "0") >= 0 and strcmp($c, "9") <= 0) {
|
||||
$s += ord($c) - ord("0");
|
||||
} else{
|
||||
} else {
|
||||
$s += ord($c) - ord("A");
|
||||
}
|
||||
}
|
||||
for($i=0; $i<=14; $i+=2){
|
||||
$c = $cf[$i];
|
||||
switch($c){
|
||||
case '0': case 'A': $s += 1; break;
|
||||
case '1': case 'B': $s += 0; break;
|
||||
case '2': case 'C': $s += 5; break;
|
||||
case '3': case 'D': $s += 7; break;
|
||||
case '4': case 'E': $s += 9; break;
|
||||
case '5': case 'F': $s += 13; break;
|
||||
case '6': case 'G': $s += 15; break;
|
||||
case '7': case 'H': $s += 17; break;
|
||||
case '8': case 'I': $s += 19; break;
|
||||
case '9': case 'J': $s += 21; break;
|
||||
case 'K': $s += 2; break;
|
||||
case 'L': $s += 4; break;
|
||||
case 'M': $s += 18; break;
|
||||
case 'N': $s += 20; break;
|
||||
case 'O': $s += 11; break;
|
||||
case 'P': $s += 3; break;
|
||||
case 'Q': $s += 6; break;
|
||||
case 'R': $s += 8; break;
|
||||
case 'S': $s += 12; break;
|
||||
case 'T': $s += 14; break;
|
||||
case 'U': $s += 16; break;
|
||||
case 'V': $s += 10; break;
|
||||
case 'W': $s += 22; break;
|
||||
case 'X': $s += 25; break;
|
||||
case 'Y': $s += 24; break;
|
||||
case 'Z': $s += 23; break;
|
||||
}
|
||||
}
|
||||
$isValid = chr($s%26 + ord('A')) == $cf[15];
|
||||
for ($i = 0; $i <= 14; $i += 2) {
|
||||
$c = $cf[$i];
|
||||
switch ($c) {
|
||||
case '0':
|
||||
case 'A':
|
||||
$s += 1;
|
||||
break;
|
||||
case '1':
|
||||
case 'B':
|
||||
$s += 0;
|
||||
break;
|
||||
case '2':
|
||||
case 'C':
|
||||
$s += 5;
|
||||
break;
|
||||
case '3':
|
||||
case 'D':
|
||||
$s += 7;
|
||||
break;
|
||||
case '4':
|
||||
case 'E':
|
||||
$s += 9;
|
||||
break;
|
||||
case '5':
|
||||
case 'F':
|
||||
$s += 13;
|
||||
break;
|
||||
case '6':
|
||||
case 'G':
|
||||
$s += 15;
|
||||
break;
|
||||
case '7':
|
||||
case 'H':
|
||||
$s += 17;
|
||||
break;
|
||||
case '8':
|
||||
case 'I':
|
||||
$s += 19;
|
||||
break;
|
||||
case '9':
|
||||
case 'J':
|
||||
$s += 21;
|
||||
break;
|
||||
case 'K':
|
||||
$s += 2;
|
||||
break;
|
||||
case 'L':
|
||||
$s += 4;
|
||||
break;
|
||||
case 'M':
|
||||
$s += 18;
|
||||
break;
|
||||
case 'N':
|
||||
$s += 20;
|
||||
break;
|
||||
case 'O':
|
||||
$s += 11;
|
||||
break;
|
||||
case 'P':
|
||||
$s += 3;
|
||||
break;
|
||||
case 'Q':
|
||||
$s += 6;
|
||||
break;
|
||||
case 'R':
|
||||
$s += 8;
|
||||
break;
|
||||
case 'S':
|
||||
$s += 12;
|
||||
break;
|
||||
case 'T':
|
||||
$s += 14;
|
||||
break;
|
||||
case 'U':
|
||||
$s += 16;
|
||||
break;
|
||||
case 'V':
|
||||
$s += 10;
|
||||
break;
|
||||
case 'W':
|
||||
$s += 22;
|
||||
break;
|
||||
case 'X':
|
||||
$s += 25;
|
||||
break;
|
||||
case 'Y':
|
||||
$s += 24;
|
||||
break;
|
||||
case 'Z':
|
||||
$s += 23;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$isValid = chr($s % 26 + ord('A')) == $cf[15];
|
||||
}
|
||||
}
|
||||
return $Ret->set_boolean($isValid);
|
||||
}
|
||||
|
||||
public static function stayinAlive(){
|
||||
|
||||
public static function stayinAlive() {
|
||||
@session_start();
|
||||
$Ret = new \Ret;
|
||||
return $Ret->set_string("stayin' alive, stayin' alive");
|
||||
}
|
||||
|
||||
public static function autocomplete_indirizzo($filter){
|
||||
|
||||
public static function autocomplete_indirizzo($filter) {
|
||||
return \Utility\Geo::autocomplete($filter["q"]);
|
||||
}
|
||||
|
||||
public static function getPlaceInfo($data){
|
||||
|
||||
public static function getPlaceInfo($data) {
|
||||
return \Utility\Geo::getPlaceInfo($data["placeId"]);
|
||||
}
|
||||
|
||||
public static function coordinatesToAddress($data){
|
||||
|
||||
public static function coordinatesToAddress($data) {
|
||||
$latLng = null;
|
||||
if(isset($data["latLng"])){
|
||||
if(is_string($data["latLng"])){
|
||||
if (isset($data["latLng"])) {
|
||||
if (is_string($data["latLng"])) {
|
||||
$latLng = $data["latLng"];
|
||||
} else if(is_array($data["latLng"])){
|
||||
} else if (is_array($data["latLng"])) {
|
||||
$latLng = implode(",", $data["latLng"]);
|
||||
}
|
||||
} else if(isset($data["lat"]) && isset($data["lng"])){
|
||||
$latLng = $data["lat"].",".$data["lng"];
|
||||
} else if (isset($data["lat"]) && isset($data["lng"])) {
|
||||
$latLng = $data["lat"] . "," . $data["lng"];
|
||||
}
|
||||
return \Utility\Geo::coordinatesToAddress($latLng);
|
||||
}
|
||||
|
||||
public static function appendModalNotification($data){
|
||||
|
||||
public static function appendModalNotification($data) {
|
||||
$data["type"] = "modal";
|
||||
self::appendNotification($data);
|
||||
}
|
||||
|
||||
private static function appendNotification($data){
|
||||
$type = isset($data["type"]) && $data["type"]=="modal" ? "modal" : "toast";
|
||||
if($_SESSION){
|
||||
if(!isset($_SESSION["onload-messages"])){
|
||||
|
||||
private static function appendNotification($data) {
|
||||
$type = isset($data["type"]) && $data["type"] == "modal" ? "modal" : "toast";
|
||||
if ($_SESSION) {
|
||||
if (!isset($_SESSION["onload-messages"])) {
|
||||
$_SESSION["onload-messages"] = array("toast" => array(), "modal" => array());
|
||||
}
|
||||
$_SESSION["onload-messages"][$type][] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
public static function appendToastNotification($data){
|
||||
|
||||
public static function appendToastNotification($data) {
|
||||
$data["type"] = "toast";
|
||||
self::appendNotification($data);
|
||||
}
|
||||
|
||||
public static function get_moduleTemplates($data){
|
||||
|
||||
public static function get_moduleTemplates($data) {
|
||||
$moduleName = $data["module_name"];
|
||||
$moduleNameCc = ucfirst(\Utility\Str::camelCaseEncode($moduleName));
|
||||
include \Controller::module_gestpath_classes($moduleName, "{$moduleNameCc}.class.php");
|
||||
$templateId = isset($data["template_id"]) ? $data["template_id"] : null;
|
||||
$retData = array();
|
||||
$gestPathHtml = \Controller::module_gestpath_resource($moduleName, "html");
|
||||
if(file_exists($gestPathHtml)){
|
||||
$arr_files = glob($gestPathHtml."*.{html,htm,php}", GLOB_BRACE);
|
||||
foreach($arr_files as $file){
|
||||
if (file_exists($gestPathHtml)) {
|
||||
$arr_files = glob($gestPathHtml . "*.{html,htm,php}", GLOB_BRACE);
|
||||
foreach ($arr_files as $file) {
|
||||
$id = pathinfo($file, PATHINFO_FILENAME);
|
||||
if(is_null($templateId) || $templateId==$id){
|
||||
if (is_null($templateId) || $templateId == $id) {
|
||||
$ext = pathinfo($file, PATHINFO_EXTENSION);
|
||||
if(in_array($ext, array("html", "htm"))){
|
||||
if (in_array($ext, array("html", "htm"))) {
|
||||
$html = file_get_contents($file);
|
||||
} else{ // .php
|
||||
} else { // .php
|
||||
ob_start();
|
||||
include $file;
|
||||
$html = ob_get_contents();
|
||||
@@ -188,99 +251,99 @@ class Ajax{
|
||||
$Ret = new \Ret;
|
||||
return $Ret->set_data($retData);
|
||||
}
|
||||
|
||||
public static function get_moduleTemplate($data){
|
||||
|
||||
public static function get_moduleTemplate($data) {
|
||||
return self::get_moduleTemplates($data);
|
||||
}
|
||||
|
||||
public static function get_moduleDatasource($data){
|
||||
|
||||
public static function get_moduleDatasource($data) {
|
||||
$Ret = new \Ret;
|
||||
$idModulo = $data["module_name"];
|
||||
$idModuloCC = ucfirst(\Utility\Str::camelCaseEncode($idModulo));
|
||||
$methodName = "_moduleDatasource";
|
||||
include \Controller::module_gestpath_classes($idModulo, "{$idModuloCC}.class.php");
|
||||
if(class_exists($idModuloCC)){
|
||||
if(isset($data["profileDB"])){
|
||||
if (class_exists($idModuloCC)) {
|
||||
if (isset($data["profileDB"])) {
|
||||
$GLOBALS["profileDB"] = $data["profileDB"];
|
||||
}
|
||||
if(method_exists("\\{$idModuloCC}", $methodName)){
|
||||
if (method_exists("\\{$idModuloCC}", $methodName)) {
|
||||
$filter = isset($data["filter"]) ? $data["filter"] : array();
|
||||
$Ret = call_user_func_array("\\{$idModuloCC}::{$methodName}", array($filter));
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_string("Method {$idModuloCC}::{$methodName} not exists");
|
||||
}
|
||||
}
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function get_forecast($data){
|
||||
|
||||
public static function get_forecast($data) {
|
||||
$dayFrom = \Utility\Date::startOfDay($data["day_from"]);
|
||||
$dayTo = isset($data["day_to"]) ? \Utility\Date::startOfDay($data["day_to"]) : $dayFrom;
|
||||
$Wheater = new \Utility\Weather;
|
||||
return $Wheater->setLatLng($data["latLng"])->setDayFrom($dayFrom)->setDayTo($dayTo)->forceRefresh(true)->loadForecastDaysInterval();
|
||||
}
|
||||
|
||||
public static function urlToImage($data){
|
||||
|
||||
public static function urlToImage($data) {
|
||||
$url = $data["url"];
|
||||
$Ret = self::loadUrl($url);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$content = $Ret->get_byte();
|
||||
$Ret->set_byte(null);
|
||||
$mimeType = \Utility\File::getMimeTypeFromBlob($content);
|
||||
$fileName = pathinfo($url, PATHINFO_BASENAME);
|
||||
|
||||
if(\Utility\File::isImageFromMimeType($mimeType)){
|
||||
|
||||
|
||||
if (\Utility\File::isImageFromMimeType($mimeType)) {
|
||||
|
||||
$Image = new \Utility\Image;
|
||||
if($Image->importFromBlob($content)){
|
||||
|
||||
if($Image->resize(1600, 1200, true, true, true)){
|
||||
|
||||
if ($Image->importFromBlob($content)) {
|
||||
|
||||
if ($Image->resize(1600, 1200, true, true, true)) {
|
||||
|
||||
$retData = array(
|
||||
"fileName" => $fileName,
|
||||
"fileCachePath" => $Image->get_fileCachedPath(),
|
||||
"mimeType" => $mimeType,
|
||||
"isImage" => \Utility\File::isImageFromMimeType($mimeType)
|
||||
);
|
||||
|
||||
|
||||
$Ret->set_data($retData)->set_byte(null);
|
||||
}
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Errore importazione immagine");
|
||||
}
|
||||
|
||||
|
||||
unset($Image);
|
||||
|
||||
} else if($mimeType==\Mime::HTML){
|
||||
|
||||
} else if ($mimeType == \Mime::HTML) {
|
||||
$doc = \phpQuery::newDocumentHTML($content);
|
||||
|
||||
|
||||
$ogImageUrl = nullIfBlank($doc["meta[property='og:image']"]->attr("content"));
|
||||
|
||||
if(is_null($ogImageUrl)){ // PROVA AMAZON
|
||||
|
||||
if (is_null($ogImageUrl)) { // PROVA AMAZON
|
||||
$ogImageUrl = nullIfBlank(pq($doc["#landingImage"])->attr("src"));
|
||||
}
|
||||
|
||||
if(!is_null($ogImageUrl)){
|
||||
|
||||
if (!is_null($ogImageUrl)) {
|
||||
$Ret = self::urlToImage(array("url" => $ogImageUrl));
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_warning("Il link immesso non contiene alcuna immagine");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function urlToBase64($data){
|
||||
|
||||
public static function urlToBase64($data) {
|
||||
$url = $data["url"];
|
||||
$Ret = self::loadUrl($url);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$content = $Ret->get_byte();
|
||||
$mimeType = \Utility\File::getMimeTypeFromBlob($content);
|
||||
$fileName = pathinfo($url, PATHINFO_BASENAME);
|
||||
|
||||
|
||||
$retData = array(
|
||||
"fileName" => $fileName,
|
||||
"fileBase64" => base64_encode($content),
|
||||
@@ -289,14 +352,14 @@ class Ajax{
|
||||
);
|
||||
$Ret->set_data($retData)->set_byte(null);
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function urlToFile($data){
|
||||
|
||||
public static function urlToFile($data) {
|
||||
$url = $data["url"];
|
||||
$Ret = self::loadUrl($url);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$content = $Ret->get_byte();
|
||||
$mimeType = \Utility\File::getMimeTypeFromBlob($content);
|
||||
$fileName = pathinfo($url, PATHINFO_BASENAME);
|
||||
@@ -307,49 +370,49 @@ class Ajax{
|
||||
"mimeType" => $mimeType,
|
||||
"isImage" => \Utility\File::isImageFromMimeType($mimeType)
|
||||
);
|
||||
|
||||
|
||||
$Ret->set_data($retData)->set_byte(null);
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
private static function get_httpResponseCode($url){//return "200";
|
||||
|
||||
private static function get_httpResponseCode($url) {//return "200";
|
||||
$headers = @get_headers($url);
|
||||
return $headers!==false ? substr($headers[0], 9, 3) : false;
|
||||
return $headers !== false ? substr($headers[0], 9, 3) : false;
|
||||
}
|
||||
|
||||
private static function getSslPage($url){ // non con php 5.3
|
||||
|
||||
private static function getSslPage($url) { // non con php 5.3
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
// Edit: prior variable $postFields should be $postfields;
|
||||
// curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
|
||||
// curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // On dev server only!
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
/*
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_REFERER, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
$result = curl_exec($ch);var_dump($result);
|
||||
curl_close($ch);
|
||||
return $result;*/
|
||||
}
|
||||
|
||||
private static function loadUrl($url){
|
||||
/*
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_REFERER, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
$result = curl_exec($ch);var_dump($result);
|
||||
curl_close($ch);
|
||||
return $result;*/
|
||||
}
|
||||
|
||||
private static function loadUrl($url) {
|
||||
$Ret = self::validateUrlSintax($url);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$responseCode = self::get_httpResponseCode($url);
|
||||
if($responseCode!==false && $responseCode=="200"){
|
||||
$arrContextOptions=array(/*
|
||||
if ($responseCode !== false && $responseCode == "200") {
|
||||
$arrContextOptions = array(/*
|
||||
"http" => array(
|
||||
"method" => "POST",
|
||||
"header" =>
|
||||
@@ -359,10 +422,10 @@ class Ajax{
|
||||
"timeout" => (float)30.0,
|
||||
"content" => $strRequestXML,
|
||||
),*/
|
||||
"ssl"=>array(
|
||||
"allow_self_signed"=>true,
|
||||
"verify_peer"=>false,
|
||||
"verify_peer_name"=>false,
|
||||
"ssl" => array(
|
||||
"allow_self_signed" => true,
|
||||
"verify_peer" => false,
|
||||
"verify_peer_name" => false,
|
||||
),
|
||||
);
|
||||
/*
|
||||
@@ -372,26 +435,26 @@ class Ajax{
|
||||
"verify_peer_name"=>false,
|
||||
),
|
||||
); */
|
||||
|
||||
// $content = self::getSslPage($url);
|
||||
|
||||
// $content = self::getSslPage($url);
|
||||
$content = @file_get_contents($url);
|
||||
// $content = file_get_contents($url, false, stream_context_create($arrContextOptions));
|
||||
if($content!==false){
|
||||
// $content = file_get_contents($url, false, stream_context_create($arrContextOptions));
|
||||
if ($content !== false) {
|
||||
$Ret->set_byte($content);
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("Contenuto risorsa non valido");
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("Risorsa non disponibile o non valida")->set_number($responseCode)->set_string($url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
private static function validateUrlSintax($url){
|
||||
|
||||
private static function validateUrlSintax($url) {
|
||||
$Ret = new \Ret;
|
||||
if(is_null($url) || !filter_var($url, FILTER_VALIDATE_URL)){
|
||||
if (is_null($url) || !filter_var($url, FILTER_VALIDATE_URL)) {
|
||||
$Ret->set_error("URL non valido");
|
||||
}
|
||||
return $Ret;
|
||||
|
||||
@@ -1,41 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace PVM;
|
||||
|
||||
use PVM\ModuloUtils;
|
||||
use Modulo;
|
||||
class CurrentModule{
|
||||
|
||||
public static function isAuthorizedToCurrentUser(){
|
||||
|
||||
class CurrentModule {
|
||||
|
||||
public static function isAuthorizedToCurrentUser() {
|
||||
$Modulo = self::getModulo();
|
||||
if(!is_null($Modulo)){
|
||||
if (!is_null($Modulo)) {
|
||||
return $Modulo->isAuthorizedToCurrentUser();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
public static function is_userAuthorized(){
|
||||
return !is_null(self::get_info()) || in_array(\Controller::current_module(), array("login", "index"));
|
||||
}*/
|
||||
|
||||
public static function getModulo(){
|
||||
|
||||
public static function getModulo() {
|
||||
$id = ModuloUtils::searchIdByCurrentPageUrl();
|
||||
return !is_null($id) ? new Modulo($id) : null;
|
||||
}
|
||||
|
||||
public static function isLoad(){
|
||||
|
||||
public static function isLoad() {
|
||||
return !is_null(self::getModulo());
|
||||
}
|
||||
|
||||
public static function getGroup(){
|
||||
|
||||
public static function getGroup() {
|
||||
$Modulo = self::getModulo();
|
||||
return !is_null($Modulo) ? $Modulo->getGroup() : null;
|
||||
}
|
||||
|
||||
public static function getId(){
|
||||
|
||||
public static function getId() {
|
||||
$Modulo = self::getModulo();
|
||||
return !is_null($Modulo) ? $Modulo->getId() : null;
|
||||
}
|
||||
|
||||
public static function getTitle(){
|
||||
|
||||
public static function getTitle() {
|
||||
$Modulo = self::getModulo();
|
||||
return !is_null($Modulo) ? $Modulo->getTitle() : null;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace PVM;
|
||||
class Mailer{
|
||||
class Mailer {
|
||||
private $_from = null;
|
||||
private $_fromName = null;
|
||||
private $_to = array();
|
||||
@@ -15,18 +16,18 @@ class Mailer{
|
||||
private $_replyToName = null;
|
||||
private $_sendDev = false;
|
||||
private $_useTemplate = true;
|
||||
|
||||
|
||||
private $_disableSafeDebugging = false;
|
||||
private $_mailDefaultSafeDebugging = null;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
$this->_subject = "Comunicazione dal Portale WEB";
|
||||
$this->_mailDefaultSafeDebugging = "v.castellana@integry.it";
|
||||
$this->_mailDefaultSafeDebugging = "developer@integry.it";
|
||||
}
|
||||
|
||||
|
||||
// <editor-fold desc="SETTERS MITT e DEST" defaultstate="collapsed">
|
||||
|
||||
public static function parseRecipients($arg1, $name = null){
|
||||
|
||||
public static function parseRecipients($arg1, $name = null) {
|
||||
$results = array();
|
||||
|
||||
if (is_array($arg1)) { // array
|
||||
@@ -49,116 +50,116 @@ class Mailer{
|
||||
$results[] = array($arg1, $name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function addTo($arg1, $name = null){
|
||||
|
||||
public function addTo($arg1, $name = null) {
|
||||
$this->_to = array_merge($this->_to, self::parseRecipients($arg1, $name));
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getListTo(){
|
||||
|
||||
public function getListTo() {
|
||||
$Ret = self::implodeEmailList($this->_to);
|
||||
return $Ret->is_OK() ? $Ret->get_string() : null;
|
||||
}
|
||||
|
||||
public function addCc($arg1, $name = null){
|
||||
|
||||
public function addCc($arg1, $name = null) {
|
||||
$this->_cc = array_merge($this->_cc, self::parseRecipients($arg1, $name));
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getListCc(){
|
||||
|
||||
public function getListCc() {
|
||||
$Ret = self::implodeEmailList($this->_cc);
|
||||
return $Ret->is_OK() ? $Ret->get_string() : null;
|
||||
}
|
||||
|
||||
public function addCcn($arg1, $name = null){
|
||||
|
||||
public function addCcn($arg1, $name = null) {
|
||||
$this->_ccn = array_merge($this->_ccn, self::parseRecipients($arg1, $name));
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getListCcn(){
|
||||
|
||||
public function getListCcn() {
|
||||
$Ret = self::implodeEmailList($this->_ccn);
|
||||
return $Ret->is_OK() ? $Ret->get_string() : null;
|
||||
}
|
||||
|
||||
public function replyTo($eMail, $name = null){
|
||||
if(\Utility::is_validEmail($eMail)){
|
||||
|
||||
public function replyTo($eMail, $name = null) {
|
||||
if (\Utility::is_validEmail($eMail)) {
|
||||
$this->_replyTo = $eMail;
|
||||
$this->_replyToName = $name;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function from($eMail, $name = null){
|
||||
if(\Utility::is_validEmail($eMail)){
|
||||
|
||||
public function from($eMail, $name = null) {
|
||||
if (\Utility::is_validEmail($eMail)) {
|
||||
$this->_from = $eMail;
|
||||
if(!is_null($name)){
|
||||
$this->_fromName = $name;
|
||||
if (!is_null($name)) {
|
||||
$this->_fromName = $name;
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fromName($name){
|
||||
|
||||
public function fromName($name) {
|
||||
$this->_fromName = $name;
|
||||
return $this;
|
||||
}
|
||||
// </editor-fold>
|
||||
|
||||
|
||||
// <editor-fold desc="ALLEGATO" defaultstate="collapsed">
|
||||
public function addAttachment($filePath, $content = null){
|
||||
public function addAttachment($filePath, $content = null) {
|
||||
$name = pathinfo($filePath, PATHINFO_BASENAME);
|
||||
if(is_null($content) && file_exists($filePath)){
|
||||
if (is_null($content) && file_exists($filePath)) {
|
||||
$content = file_get_contents($filePath);
|
||||
}
|
||||
if(!is_null($content)){
|
||||
if (!is_null($content)) {
|
||||
$this->_attachments[] = array("name" => $name, "content" => $content);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
// </editor-fold>
|
||||
|
||||
|
||||
// <editor-fold desc="ALTRI SETTERS" defaultstate="collapsed">
|
||||
public function host($value){
|
||||
public function host($value) {
|
||||
$this->_host = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function azienda($value = null){
|
||||
|
||||
public function azienda($value = null) {
|
||||
$this->_azienda = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function subject($value){
|
||||
|
||||
public function subject($value) {
|
||||
$this->_subject = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function safeDebugging($value){
|
||||
if(is_bool($value)){
|
||||
|
||||
public function safeDebugging($value) {
|
||||
if (is_bool($value)) {
|
||||
$this->_disableSafeDebugging = !$value;
|
||||
} else if(\Utility::is_validEmail($value)){
|
||||
} else if (\Utility::is_validEmail($value)) {
|
||||
$this->_mailDefaultSafeDebugging = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
// </editor-fold>
|
||||
|
||||
|
||||
// <editor-fold desc="SETTERS BODY MESSAGGIO" defaultstate="collapsed">
|
||||
public function message($value){
|
||||
public function message($value) {
|
||||
return $this->body($value);
|
||||
}
|
||||
|
||||
public function body($value){
|
||||
|
||||
public function body($value) {
|
||||
$this->_textMessage = blankIfNull($value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function getMessage(){
|
||||
if(!is_null($this->_textMessage)){
|
||||
if($this->_useTemplate){
|
||||
|
||||
private function getMessage() {
|
||||
if (!is_null($this->_textMessage)) {
|
||||
if ($this->_useTemplate) {
|
||||
ob_start();
|
||||
$azienda = $this->_azienda; // SERVE IN TEMPLATE.PHP
|
||||
$GLOBALS["profileDB"] = $azienda;
|
||||
@@ -170,7 +171,7 @@ class Mailer{
|
||||
$doc = \phpQuery::newDocumentHTML($template);
|
||||
$doc["#mailbody"]->html($this->_textMessage);
|
||||
return \Utility\Str::remove_multiple_spaces($doc->htmlOuter());
|
||||
|
||||
|
||||
} else {
|
||||
return \Utility\Str::remove_multiple_spaces($this->_textMessage);
|
||||
}
|
||||
@@ -178,32 +179,33 @@ class Mailer{
|
||||
return null;
|
||||
}
|
||||
// </editor-fold>
|
||||
|
||||
|
||||
// <editor-fold desc="VALIDAZIONE E PREPARAZIONE INDIRIZZI EMAIL" defaultstate="collapsed">
|
||||
private static function implodeEmailList($emailList){
|
||||
private static function implodeEmailList($emailList) {
|
||||
$Ret = new \Ret;
|
||||
$emails = "";
|
||||
foreach($emailList as $emailItem){
|
||||
foreach ($emailList as $emailItem) {
|
||||
$emailItem[0] = trim($emailItem[0]);
|
||||
if(\Utility::is_validEmail($emailItem[0])){
|
||||
if(is_null($emailItem[1])){
|
||||
$emails .= $emailItem[0].";";
|
||||
} else{
|
||||
$emails .= $emailItem[1]." <".$emailItem[0].">;";
|
||||
if (\Utility::is_validEmail($emailItem[0])) {
|
||||
if (is_null($emailItem[1])) {
|
||||
$emails .= $emailItem[0] . ";";
|
||||
} else {
|
||||
$emails .= $emailItem[1] . " <" . $emailItem[0] . ">;";
|
||||
}
|
||||
} else{
|
||||
return $Ret->set_error("Indirizzo email non valido: ".$emailItem[0]);
|
||||
} else {
|
||||
return $Ret->set_error("Indirizzo email non valido: " . $emailItem[0]);
|
||||
}
|
||||
}
|
||||
return $Ret->set_string(rtrim($emails, ";"));
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
public function send(){
|
||||
if(!$this->_disableSafeDebugging){
|
||||
|
||||
public function send() {
|
||||
if (!$this->_disableSafeDebugging) {
|
||||
$this->runSafeDebugging();
|
||||
}
|
||||
|
||||
|
||||
$body = array(
|
||||
"from" => $this->_from,
|
||||
"fromName" => !is_null($this->_fromName) ? $this->_fromName : \Azienda::getNomeAzienda(),
|
||||
@@ -212,51 +214,51 @@ class Mailer{
|
||||
"isHtml" => true,
|
||||
"attachments" => array()
|
||||
);
|
||||
|
||||
|
||||
$Ret = self::implodeEmailList($this->_to);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$body["to"] = $Ret->get_string();
|
||||
} else{
|
||||
} else {
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
$Ret = self::implodeEmailList($this->_ccn);
|
||||
if($Ret->is_OK()){
|
||||
$s = $Ret->get_string();
|
||||
if(strlen($s)>0){
|
||||
$body["ccn"] = $s;
|
||||
}
|
||||
} else{
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
$Ret = self::implodeEmailList($this->_cc);
|
||||
if($Ret->is_OK()){
|
||||
$s = $Ret->get_string();
|
||||
if(strlen($s)>0){
|
||||
$body["cc"] = $s;
|
||||
}
|
||||
} else{
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
if(!is_null($this->_replyTo)){
|
||||
$body["replyTo"] = $this->_replyTo;
|
||||
}
|
||||
|
||||
if(isset($body["to"]) && strlen($body["to"])>0){
|
||||
foreach($this->_attachments as $attachmentItem){
|
||||
$Ret = self::implodeEmailList($this->_ccn);
|
||||
if ($Ret->is_OK()) {
|
||||
$s = $Ret->get_string();
|
||||
if (strlen($s) > 0) {
|
||||
$body["ccn"] = $s;
|
||||
}
|
||||
} else {
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
$Ret = self::implodeEmailList($this->_cc);
|
||||
if ($Ret->is_OK()) {
|
||||
$s = $Ret->get_string();
|
||||
if (strlen($s) > 0) {
|
||||
$body["cc"] = $s;
|
||||
}
|
||||
} else {
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
if (!is_null($this->_replyTo)) {
|
||||
$body["replyTo"] = $this->_replyTo;
|
||||
}
|
||||
|
||||
if (isset($body["to"]) && strlen($body["to"]) > 0) {
|
||||
foreach ($this->_attachments as $attachmentItem) {
|
||||
$body["attachments"][] = array("fileName" => $attachmentItem["name"], "fileb64Content" => base64_encode($attachmentItem["content"]));
|
||||
}
|
||||
|
||||
|
||||
$IMSApi = new \IMSApi;
|
||||
if(!\User::is_authenticated()){
|
||||
if (!\User::is_authenticated()) {
|
||||
$IMSApi->anonymousAuth();
|
||||
//$IMSApi->authUsername($GLOBALS["profileDB"])->authPassword($GLOBALS["profileDB"]);
|
||||
}
|
||||
if (!\PVM::isDevClient() || $this->_sendDev){
|
||||
if (!\PVM::isDevClient() || $this->_sendDev) {
|
||||
$Ret = $IMSApi->post("sendEmail")->body($body)->send();
|
||||
}else{
|
||||
} else {
|
||||
$fileContent = sprintf(
|
||||
"<pre>%s</pre>",
|
||||
print_r($body, true)
|
||||
@@ -268,49 +270,50 @@ class Mailer{
|
||||
$Ret->set_OK();
|
||||
}
|
||||
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("Lista email destinatari vuota");
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
private function runSafeDebugging(){
|
||||
if(\PVM::isDevMode()){
|
||||
|
||||
private function runSafeDebugging() {
|
||||
if (\PVM::isDevMode()) {
|
||||
|
||||
$defaultEmail = $this->_mailDefaultSafeDebugging;
|
||||
$arr_debugEmailWL = array("@integry.it");
|
||||
|
||||
$safetize = function($arr_emails) use($arr_debugEmailWL, $defaultEmail){
|
||||
foreach($arr_emails as &$d){
|
||||
$safetize = function ($arr_emails) use ($arr_debugEmailWL, $defaultEmail) {
|
||||
foreach ($arr_emails as &$d) {
|
||||
$flag_replace = true;
|
||||
$email = $d[0];
|
||||
if(count($arr_debugEmailWL)>0){
|
||||
foreach($arr_debugEmailWL as $debugEmailWL){
|
||||
if(\Utility\Str::ciEquals($email, $debugEmailWL) || \Utility\Str::endsWith($email, $debugEmailWL, false)){
|
||||
if (count($arr_debugEmailWL) > 0) {
|
||||
foreach ($arr_debugEmailWL as $debugEmailWL) {
|
||||
if (\Utility\Str::ciEquals($email, $debugEmailWL) || \Utility\Str::endsWith($email, $debugEmailWL, false)) {
|
||||
$flag_replace = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($flag_replace){
|
||||
if ($flag_replace) {
|
||||
$d[0] = $defaultEmail;
|
||||
}
|
||||
}
|
||||
return $arr_emails;
|
||||
};
|
||||
|
||||
|
||||
$this->_to = $safetize($this->_to);
|
||||
$this->_cc = $safetize($this->_cc);
|
||||
$this->_ccn = $safetize($this->_ccn);
|
||||
}
|
||||
}
|
||||
|
||||
public function ignoreTemplate(){
|
||||
|
||||
public function ignoreTemplate() {
|
||||
$this->_useTemplate = false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function sendDev($sendDev = true){
|
||||
public function sendDev($sendDev = true) {
|
||||
$this->_sendDev = $sendDev;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -1,27 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace PVM;
|
||||
|
||||
use User;
|
||||
class ModuloUtils{
|
||||
|
||||
public static function searchIdByCurrentPageUrl(){
|
||||
|
||||
class ModuloUtils {
|
||||
|
||||
public static function searchIdByCurrentPageUrl() {
|
||||
$currentPage = basename($_SERVER["PHP_SELF"]);
|
||||
$queryString = $_SERVER["QUERY_STRING"];
|
||||
$id = null;
|
||||
$f_priority = false;
|
||||
|
||||
|
||||
$userModulesTree = \PVM::get_userModulesTree();
|
||||
foreach($userModulesTree as $menuGroup){
|
||||
foreach($menuGroup as $menuOpt){
|
||||
if(isset($menuOpt["pages"])){ // è false se non aut.
|
||||
foreach ($userModulesTree as $menuGroup) {
|
||||
foreach ($menuGroup as $menuOpt) {
|
||||
if (isset($menuOpt["pages"])) { // è false se non aut.
|
||||
$page = $menuOpt["pages"];
|
||||
$pageDet = $menuOpt["page-det"];
|
||||
if($currentPage==$page){
|
||||
if(is_null($pageDet) || \Utility\Str::contains($queryString, $pageDet)){
|
||||
if(!$f_priority){
|
||||
if ($currentPage == $page) {
|
||||
if (is_null($pageDet) || \Utility\Str::contains($queryString, $pageDet)) {
|
||||
if (!$f_priority) {
|
||||
$parts = explode("-", $menuOpt["id"]); // es. "catalogo-ordini" : "catalogo"
|
||||
$id = $parts[0];
|
||||
}
|
||||
if(\Utility\Str::contains($queryString, $pageDet)){
|
||||
if (\Utility\Str::contains($queryString, $pageDet)) {
|
||||
$id = $menuOpt["id"];
|
||||
$f_priority = true;
|
||||
}
|
||||
@@ -30,35 +33,35 @@ class ModuloUtils{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
public static function getIdAttivi(){
|
||||
|
||||
public static function getIdAttivi() {
|
||||
$currentIdModulo = \Controller::current_module();
|
||||
|
||||
|
||||
$idsModuli = array($currentIdModulo);
|
||||
if($currentIdModulo!=="login"){
|
||||
if ($currentIdModulo !== "login") {
|
||||
$idsModuli = array_merge($idsModuli, self::getIdModuliBase());
|
||||
}
|
||||
|
||||
|
||||
$Modulo = new \Modulo($currentIdModulo);
|
||||
if($Modulo->isLoaded()){
|
||||
if ($Modulo->isLoaded()) {
|
||||
$idsModuli = array_merge($idsModuli, $Modulo->getChildren());
|
||||
|
||||
if (in_array("gettext", $Modulo->getLibs())) {
|
||||
$idsModuli[] = "i18n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return array_unique($idsModuli);
|
||||
}
|
||||
|
||||
public static function getIdModuliBase(){
|
||||
|
||||
public static function getIdModuliBase() {
|
||||
return array(/*"messenger",*/ "allegati", "notifiche");
|
||||
}
|
||||
|
||||
public static function getModuliStandard(){
|
||||
|
||||
public static function getModuliStandard() {
|
||||
return array(
|
||||
array("name" => "impostazioni", "group" => "Sistema", "usergroups" => array(\User::AMMINISTRATORE_SISTEMA, \User::RESPONSABILE_EDP)),
|
||||
array("name" => "phpinfo", "group" => "Sistema", "usergroups" => array(\User::AMMINISTRATORE_SISTEMA, \User::RESPONSABILE_EDP)),
|
||||
@@ -67,7 +70,7 @@ class ModuloUtils{
|
||||
array("name" => "logs", "group" => "Utilità", "usergroups" => array(\User::AMMINISTRATORE_SISTEMA, User::RESPONSABILE_EDP)),
|
||||
array("name" => "report_area", "group" => "Utilità"),
|
||||
array("name" => "weather", "group" => "NULL"),
|
||||
array("name" => "user_settings", "group" => "NULL", "usergroups" => array("!".\User::OSPITE)),
|
||||
array("name" => "user_settings", "group" => "NULL", "usergroups" => array("!" . \User::OSPITE)),
|
||||
array("name" => "index", "group" => "NULL"),
|
||||
array("name" => "login", "group" => "NULL"),
|
||||
array("name" => "emailcheck", "group" => "NULL"),
|
||||
@@ -75,8 +78,8 @@ class ModuloUtils{
|
||||
array("name" => "blank", "group" => "Utilità", "group" => "NULL")
|
||||
);
|
||||
}
|
||||
|
||||
public static function getIdModuliStandard(){
|
||||
|
||||
public static function getIdModuliStandard() {
|
||||
return array_column(self::getModuliStandard(), "name");
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace PVM;
|
||||
class Tips{
|
||||
class Tips {
|
||||
private $arr_alerts = array();
|
||||
|
||||
public function append($Tip){
|
||||
|
||||
public function append($Tip) {
|
||||
$this->arr_alerts[] = $Tip;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get_alerts(){
|
||||
|
||||
public function get_alerts() {
|
||||
return $this->arr_alerts;
|
||||
}
|
||||
|
||||
public static function Tip(){
|
||||
|
||||
public static function Tip() {
|
||||
$Alert = new \BC\Alert;
|
||||
return $Alert->closeBtn();
|
||||
}
|
||||
|
||||
@@ -1,176 +1,180 @@
|
||||
<?php
|
||||
class PVM{
|
||||
|
||||
class PVM {
|
||||
const RECAPTCHA_KEY = "6Lc5jYEUAAAAADrmRdJMxphOkSNLTHknFX1Wzgms";
|
||||
const RECAPTCHA_SECRET = "6Lc5jYEUAAAAAOwV7vb1zUn-g780xg2ePR-V4GMR";
|
||||
|
||||
public static function is_integryClient(){
|
||||
|
||||
public static function is_integryClient() {
|
||||
$arr_publicIpIntegry = array("79.11.173.216", "79.8.93.221", "195.81.66.239", "151.58.240.141", "79.10.170.29");
|
||||
return in_array(self::get_clientIp(), $arr_publicIpIntegry);
|
||||
}
|
||||
|
||||
public static function get_clientIp(){
|
||||
|
||||
public static function get_clientIp() {
|
||||
return $_SERVER["REMOTE_ADDR"];
|
||||
}
|
||||
|
||||
public static function isDebugEnv(){
|
||||
return self::getAziendaHost()==="studioml";
|
||||
|
||||
public static function isDebugEnv() {
|
||||
return self::getAziendaHost() === "studioml";
|
||||
}
|
||||
|
||||
public static function isDevMode(){
|
||||
|
||||
public static function isDevMode() {
|
||||
return self::is_integryClient() || self::isDebugEnv();
|
||||
}
|
||||
|
||||
public static function get_hostPublicIp(){
|
||||
|
||||
public static function get_hostPublicIp() {
|
||||
$ipCached = self::get_hostPublicIp_cached();
|
||||
if(is_null($ipCached)){
|
||||
if (is_null($ipCached)) {
|
||||
$url = "https://api.ipify.org/?format=json";
|
||||
$req = \Httpful\Request::get($url);
|
||||
$result = $req->send();
|
||||
if($result->code==200){
|
||||
if ($result->code == 200) {
|
||||
$retData = json_decode($result->raw_body, true);
|
||||
self::set_hostPublicIp_cached($retData["ip"]);
|
||||
return $retData["ip"];
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
return $ipCached;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static function get_hostPublicIp_cached(){
|
||||
|
||||
private static function get_hostPublicIp_cached() {
|
||||
$filePath = Cache::get_filepath("ip.txt", null, true);
|
||||
$value = file_exists($filePath) ? file_get_contents($filePath) : null;
|
||||
return (!is_null($value) && filter_var($value, FILTER_VALIDATE_IP)) ? $value : null;
|
||||
}
|
||||
|
||||
private static function set_hostPublicIp_cached($ip){
|
||||
|
||||
private static function set_hostPublicIp_cached($ip) {
|
||||
return Cache::write("ip.txt", $ip, null, true);
|
||||
}
|
||||
|
||||
public static function get_lastAppUpdateTime(){
|
||||
|
||||
public static function get_lastAppUpdateTime() {
|
||||
$lastAppUpdateTime = 0;
|
||||
$arr_rootFiles = glob(Controller::$abs_root_project.DIRECTORY_SEPARATOR."*.*");
|
||||
foreach($arr_rootFiles as $file){
|
||||
if(filemtime($file)>$lastAppUpdateTime){
|
||||
$arr_rootFiles = glob(Controller::$abs_root_project . DIRECTORY_SEPARATOR . "*.*");
|
||||
foreach ($arr_rootFiles as $file) {
|
||||
if (filemtime($file) > $lastAppUpdateTime) {
|
||||
$lastAppUpdateTime = filemtime($file);
|
||||
}
|
||||
}
|
||||
return $lastAppUpdateTime;
|
||||
}
|
||||
|
||||
public static function getAziendaHost(){
|
||||
|
||||
public static function getAziendaHost() {
|
||||
$nomeAzienda = self::rootFileExists("nome_azienda.txt");
|
||||
if($nomeAzienda!==false){
|
||||
if ($nomeAzienda !== false) {
|
||||
$azienda = nullIfBlank(file_get_contents($nomeAzienda));
|
||||
return is_null($azienda) ? "studioml" : strtolower($azienda);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function isDevClient(){
|
||||
return self::rootFileExists("Gruntfile.js")!==false;
|
||||
|
||||
public static function isDevClient() {
|
||||
return self::rootFileExists("Gruntfile.js") !== false;
|
||||
}
|
||||
|
||||
private static function rootFileExists($filename, $upTo = 5){
|
||||
|
||||
private static function rootFileExists($filename, $upTo = 5) {
|
||||
// VERIFICA L'ESISTENZA DEL FILE SALENDO FINO A $upTo LIVELLI
|
||||
for($i=1; $i<=$upTo; $i++){
|
||||
if(file_exists($filename)){
|
||||
for ($i = 1; $i <= $upTo; $i++) {
|
||||
if (file_exists($filename)) {
|
||||
return $filename;
|
||||
}
|
||||
$filename = "../".$filename;
|
||||
$filename = "../" . $filename;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function get_projectName(){
|
||||
|
||||
public static function get_projectName() {
|
||||
$parts = explode("/", trim($_SERVER["REQUEST_URI"], "/"));
|
||||
return $parts[0];
|
||||
}
|
||||
|
||||
public static function get_rootPath(){
|
||||
$root = substr($_SERVER["PHP_SELF"],0,strrpos($_SERVER["PHP_SELF"], "/"));
|
||||
public static function get_rootPath() {
|
||||
$root = substr($_SERVER["PHP_SELF"], 0, strrpos($_SERVER["PHP_SELF"], "/"));
|
||||
return $root;
|
||||
}
|
||||
|
||||
public static function get_protocol(){
|
||||
return isset($_SERVER["HTTPS"])?"https":"http";
|
||||
|
||||
public static function get_protocol() {
|
||||
return isset($_SERVER["HTTPS"]) ? "https" : "http";
|
||||
}
|
||||
|
||||
public static function get_current_projectPublicUrl(){
|
||||
|
||||
public static function get_current_projectPublicUrl() {
|
||||
$publicUrl = Config::get_publicUrl();
|
||||
if(!is_null($publicUrl)){
|
||||
if (!is_null($publicUrl)) {
|
||||
return $publicUrl;
|
||||
} else{
|
||||
} else {
|
||||
$projectName = self::get_projectName();
|
||||
$protocol = self::get_protocol();
|
||||
return $protocol."://"."{$_SERVER["HTTP_HOST"]}/{$projectName}/";
|
||||
return $protocol . "://" . "{$_SERVER["HTTP_HOST"]}/{$projectName}/";
|
||||
}
|
||||
}
|
||||
|
||||
public static function getCurrentUrl(){
|
||||
public static function getCurrentUrl() {
|
||||
$projectName = self::get_rootPath();
|
||||
$protocol = self::get_protocol();
|
||||
return $protocol."://"."{$_SERVER["HTTP_HOST"]}{$projectName}/";
|
||||
return $protocol . "://" . "{$_SERVER["HTTP_HOST"]}{$projectName}/";
|
||||
}
|
||||
|
||||
public static function get_userModulesTree(){
|
||||
|
||||
public static function get_userModulesTree() {
|
||||
$retData = array();
|
||||
$arr_modules = self::getListModuliUtente();
|
||||
foreach($arr_modules as $module){
|
||||
foreach ($arr_modules as $module) {
|
||||
$retData[$module["group"]][] = $module;
|
||||
}
|
||||
return $retData;
|
||||
}
|
||||
|
||||
public static function getListIdModuli($includeAlias = true){
|
||||
|
||||
public static function getListIdModuli($includeAlias = true) {
|
||||
$listIdModuli = array_keys(self::getListModuli());
|
||||
|
||||
if($includeAlias===false){
|
||||
$listIdModuli = array_unique(array_map(function($x){ $parts = explode("-", $x); return $parts[0];}, $listIdModuli));
|
||||
|
||||
if ($includeAlias === false) {
|
||||
$listIdModuli = array_unique(array_map(function ($x) {
|
||||
$parts = explode("-", $x);
|
||||
return $parts[0];
|
||||
}, $listIdModuli));
|
||||
}
|
||||
|
||||
|
||||
sort($listIdModuli);
|
||||
return $listIdModuli;
|
||||
}
|
||||
|
||||
public static function getListModuli(){ // TUTTE LE GESTIONI ESISTENTI
|
||||
|
||||
public static function getListModuli() { // TUTTE LE GESTIONI ESISTENTI
|
||||
$idx = "config-menu.json";
|
||||
if(!isset($GLOBALS[$idx])){
|
||||
if (!isset($GLOBALS[$idx])) {
|
||||
$list = json_decode(file_get_contents("config-menu.json"), true);
|
||||
ksort($list);
|
||||
$GLOBALS[$idx] = $list;
|
||||
}
|
||||
return $GLOBALS[$idx];
|
||||
}
|
||||
|
||||
public static function getListModuliUtente(){
|
||||
|
||||
public static function getListModuliUtente() {
|
||||
$arr_pvmModule = self::getListModuli(); // TUTTE LE GESTIONI ESISTENTI
|
||||
$arr_aziModule = AziendaUtils::getModuli(); // GESTIONI ATTIVE PER L'AZIENDA + INFO AGG
|
||||
$ret = array();
|
||||
foreach($arr_aziModule as $aziModule){ // COMBINA I DATI DEI 2 ARRAY (ABILITAZIONE UTENTI ECC), FILTRANDO QUELLE PER L'UTENTE CONNESSO
|
||||
foreach ($arr_aziModule as $aziModule) { // COMBINA I DATI DEI 2 ARRAY (ABILITAZIONE UTENTI ECC), FILTRANDO QUELLE PER L'UTENTE CONNESSO
|
||||
$idModule = $aziModule["name"];
|
||||
if(isset($arr_pvmModule[$idModule])){
|
||||
if (isset($arr_pvmModule[$idModule])) {
|
||||
$pvmModule = $arr_pvmModule[$idModule];
|
||||
|
||||
|
||||
|
||||
|
||||
$parts = explode("?", $pvmModule["pages"]); // es. "colli_aperti.php?spedizione" -> "colli_aperti.php", "spedizione"
|
||||
$page = $parts[0];
|
||||
$pageDet = isset($parts[1]) ? $parts[1] : null;
|
||||
|
||||
|
||||
$arr_position = $pvmModule["position"];
|
||||
|
||||
if(isset($aziModule["position"])){
|
||||
foreach($arr_position as $i => $posPvm){
|
||||
|
||||
if (isset($aziModule["position"])) {
|
||||
foreach ($arr_position as $i => $posPvm) {
|
||||
$posPvmTitle = $posPvm["title"];
|
||||
foreach($aziModule["position"] as $posAzi){
|
||||
foreach ($aziModule["position"] as $posAzi) {
|
||||
$posPvmAzi = $posAzi["title"];//
|
||||
if($posPvmTitle==$posPvmAzi && isset($posAzi["usergroups"])){
|
||||
if ($posPvmTitle == $posPvmAzi && isset($posAzi["usergroups"])) {
|
||||
$arr_position[$i] = array_merge($posPvm, $posAzi);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$section = array(
|
||||
"id" => $aziModule["name"],
|
||||
"title" => isset($pvmModule["title"]) ? $pvmModule["title"] : null,
|
||||
@@ -184,111 +188,113 @@ class PVM{
|
||||
"sqlNotification" => isset($pvmModule["sqlNotification"]) ? $pvmModule["sqlNotification"] : null,
|
||||
"widgets" => isset($pvmModule["widgets"]) ? $pvmModule["widgets"] : array()
|
||||
);
|
||||
|
||||
|
||||
$parts = explode("-", $idModule); // es. "colli_aperti-spedizione" -> "colli_aperti"
|
||||
$idMainModule = $parts[0];
|
||||
$section["icon"] = "gest-lib/{$idMainModule}/".(isset($pvmModule["icon"]) ? $pvmModule["icon"] : "icon.png");
|
||||
|
||||
if(isset($aziModule["usergroups"])){
|
||||
$section["icon"] = "gest-lib/{$idMainModule}/" . (isset($pvmModule["icon"]) ? $pvmModule["icon"] : "icon.png");
|
||||
|
||||
if (isset($aziModule["usergroups"])) {
|
||||
$section["usergroups"] = $aziModule["usergroups"];
|
||||
}
|
||||
|
||||
if(isset($aziModule["users"])){
|
||||
|
||||
if (isset($aziModule["users"])) {
|
||||
$section["users"] = $aziModule["users"];
|
||||
}
|
||||
|
||||
if(self::processItemPolicyToCurrentUser($section)){
|
||||
|
||||
if (self::processItemPolicyToCurrentUser($section)) {
|
||||
$ret[$idModule] = $section;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function processItemPolicyToUser($item, $user){
|
||||
|
||||
public static function processItemPolicyToUser($item, $user) {
|
||||
$isGranted = false;
|
||||
|
||||
if(isset($item["id"]) && $item["id"]=="phpinfo" && self::isDebugEnv()){
|
||||
|
||||
if (isset($item["id"]) && $item["id"] == "phpinfo" && self::isDebugEnv()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(isset($user["group"])) {
|
||||
if (isset($user["group"])) {
|
||||
// Permesso per Amministratore aziendale e di sistema di accedere a tutto
|
||||
if($user["group"] == 9 or $user["group"] == 1) {
|
||||
if ($user["group"] == 9 or $user["group"] == 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($item["usergroups"]) && !isset($item["users"])){
|
||||
|
||||
if (!isset($item["usergroups"]) && !isset($item["users"])) {
|
||||
$isGranted = true;
|
||||
|
||||
} else{
|
||||
if(isset($item["usergroups"])){
|
||||
if(count($item["usergroups"])>0){
|
||||
$countNegati = from($item["usergroups"])->where(function($x){ return $x[0]=="!";})->count();
|
||||
|
||||
} else {
|
||||
if (isset($item["usergroups"])) {
|
||||
if (count($item["usergroups"]) > 0) {
|
||||
$countNegati = from($item["usergroups"])->where(function ($x) {
|
||||
return $x[0] == "!";
|
||||
})->count();
|
||||
$isGranted = count($item["usergroups"]) == $countNegati;
|
||||
}
|
||||
|
||||
if(in_arrayi($user["group"], $item["usergroups"])){
|
||||
|
||||
if (in_arrayi($user["group"], $item["usergroups"])) {
|
||||
$isGranted = true;
|
||||
} else if(in_arrayi("!".$user["group"], $item["usergroups"])){
|
||||
} else if (in_arrayi("!" . $user["group"], $item["usergroups"])) {
|
||||
$isGranted = false;
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$isGranted = true;
|
||||
}
|
||||
|
||||
if(isset($item["users"])){
|
||||
if(in_arrayi($user["name"], $item["users"])){
|
||||
|
||||
if (isset($item["users"])) {
|
||||
if (in_arrayi($user["name"], $item["users"])) {
|
||||
$isGranted = true;
|
||||
} else if(in_arrayi("!".$user["name"], $item["users"])){
|
||||
} else if (in_arrayi("!" . $user["name"], $item["users"])) {
|
||||
$isGranted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $isGranted;
|
||||
}
|
||||
|
||||
public static function processItemPolicyToCurrentUser($item){
|
||||
|
||||
public static function processItemPolicyToCurrentUser($item) {
|
||||
$user = array("name" => User::get_current_username(), "group" => User::get_current_group());
|
||||
return self::processItemPolicyToUser($item, $user);
|
||||
}
|
||||
|
||||
public static function get_userMenuItems(){
|
||||
|
||||
public static function get_userMenuItems() {
|
||||
$retData = array();
|
||||
$userModulesTree = PVM::get_userModulesTree();
|
||||
$currentModuleTitle = PVM\CurrentModule::getTitle();
|
||||
foreach($userModulesTree as $groupId => $menuGroup){
|
||||
foreach ($userModulesTree as $groupId => $menuGroup) {
|
||||
$is_currentGroup = false;
|
||||
$arr_submenu = array();
|
||||
$notificationGroup = 0;
|
||||
foreach($menuGroup as $menuOpt){
|
||||
if($currentModuleTitle==$menuOpt["title"]){
|
||||
foreach ($menuGroup as $menuOpt) {
|
||||
if ($currentModuleTitle == $menuOpt["title"]) {
|
||||
$is_currentGroup = true;
|
||||
}
|
||||
|
||||
|
||||
$href = isset($menuOpt["pages"]) ? $menuOpt["pages"] : null;
|
||||
if(!is_null($href) && !is_null($menuOpt["page-det"])){
|
||||
$href .= "?".$menuOpt["page-det"];
|
||||
if (!is_null($href) && !is_null($menuOpt["page-det"])) {
|
||||
$href .= "?" . $menuOpt["page-det"];
|
||||
}
|
||||
$idModulo = pathinfo($href, PATHINFO_FILENAME);
|
||||
|
||||
|
||||
$notification = null;
|
||||
if(!is_null($menuOpt["sqlNotification"])){
|
||||
if (!is_null($menuOpt["sqlNotification"])) {
|
||||
$Query = new Query;
|
||||
$Query->importSqlFile($menuOpt["sqlNotification"], $idModulo)
|
||||
->setVar("user_name", User::get_current_username());
|
||||
->setVar("user_name", User::get_current_username());
|
||||
$Ret = $Query->firstRowFirstValue()->toRet()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$notification = $Ret->get_data();
|
||||
$notificationGroup += $notification;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$menuItem = array(
|
||||
"current" => $currentModuleTitle==$menuOpt["title"],
|
||||
"current" => $currentModuleTitle == $menuOpt["title"],
|
||||
"href" => $href,
|
||||
"module" => $idModulo,
|
||||
"title" => $menuOpt["title"],
|
||||
@@ -296,36 +302,38 @@ class PVM{
|
||||
"asPopup" => $menuOpt["asPopup"],
|
||||
"notification" => $notification
|
||||
);
|
||||
|
||||
|
||||
$arr_submenu[] = $menuItem;
|
||||
}
|
||||
|
||||
if(count($arr_submenu)>0){
|
||||
$arr_submenu = array_values(from($arr_submenu)->orderBy(function($x){ return $x["title"];})->toArray());
|
||||
$retData[] = array("id" => $groupId, "href" =>null, "current" => $is_currentGroup, "notification" => $notificationGroup, "items" => $arr_submenu);
|
||||
|
||||
if (count($arr_submenu) > 0) {
|
||||
$arr_submenu = array_values(from($arr_submenu)->orderBy(function ($x) {
|
||||
return $x["title"];
|
||||
})->toArray());
|
||||
$retData[] = array("id" => $groupId, "href" => null, "current" => $is_currentGroup, "notification" => $notificationGroup, "items" => $arr_submenu);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $retData;
|
||||
}
|
||||
|
||||
public static function getUrlImgResized($src, $w = null, $h = null, $nograiny = false){
|
||||
$url = "image.php?src=".$src;
|
||||
$url .= !is_null($w) && is_numeric($w) ? "&w=".$w : "";
|
||||
$url .= !is_null($h) && is_numeric($h) ? "&h=".$h : "";
|
||||
|
||||
public static function getUrlImgResized($src, $w = null, $h = null, $nograiny = false) {
|
||||
$url = "image.php?src=" . $src;
|
||||
$url .= !is_null($w) && is_numeric($w) ? "&w=" . $w : "";
|
||||
$url .= !is_null($h) && is_numeric($h) ? "&h=" . $h : "";
|
||||
$url .= $nograiny ? "&nograiny=1" : "";
|
||||
return $url;
|
||||
}
|
||||
|
||||
public static function loadAssetsLibs(){
|
||||
|
||||
public static function loadAssetsLibs() {
|
||||
return json_decode(file_get_contents("assets/assets-libs.json"), true);
|
||||
}
|
||||
|
||||
public static function getListAziende(){
|
||||
|
||||
public static function getListAziende() {
|
||||
$arr_ret = array();
|
||||
foreach(glob("config_aziende/*.config.json") as $filename){
|
||||
foreach (glob("config_aziende/*.config.json") as $filename) {
|
||||
$azienda = strtoupper(basename($filename, ".config.json"));
|
||||
if($azienda != "empty"){
|
||||
if ($azienda != "empty") {
|
||||
$arr_ret[] = $azienda;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
class Pagination{
|
||||
|
||||
class Pagination {
|
||||
private $errorText = null;
|
||||
private $passo;
|
||||
private $adjacents = 2;
|
||||
@@ -13,28 +14,28 @@ class Pagination{
|
||||
private $sql = null;
|
||||
private $orderBy = array();
|
||||
private $newMode = true;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
global $_GET;
|
||||
$this->passo(10)->setCurrentPage(!isset($_GET["pag"]) ? 1 : $_GET["pag"]);
|
||||
}
|
||||
|
||||
public function setCurrentPage($c){
|
||||
if((is_numeric($c) || is_number($c)) && intval($c)>0){
|
||||
|
||||
public function setCurrentPage($c) {
|
||||
if ((is_numeric($c) || is_number($c)) && intval($c) > 0) {
|
||||
$this->currentPage = intval($c);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getErrorText(){
|
||||
|
||||
public function getErrorText() {
|
||||
return $this->errorText;
|
||||
}
|
||||
|
||||
private function setResultsCount(){
|
||||
if(!is_null($this->sql)){
|
||||
|
||||
private function setResultsCount() {
|
||||
if (!is_null($this->sql)) {
|
||||
$Query = new Query;
|
||||
$Ret = $Query->setSql($this->sql)->toRet()->countRowsSql();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$this->resultsCount = $Ret->get_number();
|
||||
$this->setListPagesNumber();
|
||||
$this->flagBtPrev = !$this->isFirstPage($this->getCurrentNumPage());
|
||||
@@ -43,97 +44,98 @@ class Pagination{
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
// <editor-fold desc="GETTERS" defaultstate="collapsed">
|
||||
public function getMaxNumPage(){
|
||||
if($this->getPasso() > 0){
|
||||
public function getMaxNumPage() {
|
||||
if ($this->getPasso() > 0) {
|
||||
return ceil($this->getResultsCount() / $this->getPasso());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public function getResultsCount(){
|
||||
|
||||
public function getResultsCount() {
|
||||
return $this->resultsCount;
|
||||
}
|
||||
|
||||
public function getPasso(){
|
||||
|
||||
public function getPasso() {
|
||||
return $this->passo;
|
||||
}
|
||||
|
||||
public function getListNumPage(){
|
||||
|
||||
public function getListNumPage() {
|
||||
return $this->pages;
|
||||
}
|
||||
|
||||
public function getCurrentNumPage(){
|
||||
|
||||
public function getCurrentNumPage() {
|
||||
return $this->currentPage;
|
||||
}
|
||||
|
||||
public function getFlagBtPrev(){
|
||||
|
||||
public function getFlagBtPrev() {
|
||||
return $this->flagBtPrev;
|
||||
}
|
||||
|
||||
public function getFlagBtNext(){
|
||||
|
||||
public function getFlagBtNext() {
|
||||
return $this->flagBtNext;
|
||||
}
|
||||
// </editor-fold>
|
||||
|
||||
|
||||
// <editor-fold desc="PREPARE + EXEC QUERY" defaultstate="collapsed">
|
||||
|
||||
public function execute(){
|
||||
|
||||
public function execute() {
|
||||
$Query = new Query;
|
||||
$Ret = $Query->setSql($this->get_query_fixed())->cacheFile($this->cacheFile)->toRet()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret->set("pagination", $this);
|
||||
}
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function orderBy($arr_values){
|
||||
|
||||
public function orderBy($arr_values) {
|
||||
$this->orderBy = array();
|
||||
foreach($arr_values as $field => $typeSort){
|
||||
foreach ($arr_values as $field => $typeSort) {
|
||||
$this->orderBy[$field] = array($typeSort); // x ora mantengo compatibilita formato vecchio
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function newMode($b = true){
|
||||
|
||||
public function newMode($b = true) {
|
||||
$this->newMode = $b;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get_query_fixed(){
|
||||
|
||||
public function get_query_fixed() {
|
||||
$this->setResultsCount();
|
||||
|
||||
if($this->newMode){
|
||||
$from = ($this->currentPage-1) * $this->getPasso();
|
||||
|
||||
if ($this->newMode) {
|
||||
$from = ($this->currentPage - 1) * $this->getPasso();
|
||||
$to = $from + $this->getPasso();
|
||||
|
||||
|
||||
$orderBy = "";
|
||||
foreach($this->orderBy as $sorterField => $sortOption){
|
||||
foreach ($this->orderBy as $sorterField => $sortOption) {
|
||||
$sortType = in_arrayi("DESC", $sortOption) ? "DESC" : "ASC";
|
||||
$orderBy .= " ".$sorterField." ".$sortType.",";
|
||||
$orderBy .= " " . $sorterField . " " . $sortType . ",";
|
||||
}
|
||||
|
||||
|
||||
$Query = new Query($this->sql);
|
||||
$sql = $Query->fromToRow($from, $to, rtrim($orderBy, ","))->getSql();
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$currentNumPage = $this->getCurrentNumPage();
|
||||
$isTheLastNumPage = $this->isCurrentPage($currentNumPage);
|
||||
$to = $isTheLastNumPage ? $this->getResultsCount() : $currentNumPage * $this->getPasso();
|
||||
|
||||
|
||||
$orderBy1 = $orderBy2 = "";
|
||||
foreach($this->orderBy as $sorterField => $sortOption){
|
||||
foreach ($this->orderBy as $sorterField => $sortOption) {
|
||||
$isDescending = isset($sortOption["DESC"]) || in_arrayi("DESC", $sortOption);
|
||||
$orderBy1 .= " ".$sorterField." ".($isDescending ? " ASC" : " DESC").","; // INVERSO
|
||||
$orderBy2 .= " ".$sorterField." ".($isDescending ? " DESC" : " ASC").",";
|
||||
$orderBy1 .= " " . $sorterField . " " . ($isDescending ? " ASC" : " DESC") . ","; // INVERSO
|
||||
$orderBy2 .= " " . $sorterField . " " . ($isDescending ? " DESC" : " ASC") . ",";
|
||||
}
|
||||
$orderBy1 = rtrim($orderBy1, ",");
|
||||
$orderBy2 = rtrim($orderBy2, ",");
|
||||
|
||||
|
||||
$sql = "SELECT * FROM (
|
||||
SELECT TOP ".$this->getPasso()." * FROM (
|
||||
SELECT TOP ".$to." * FROM (
|
||||
".$this->sql."
|
||||
SELECT TOP " . $this->getPasso() . " * FROM (
|
||||
SELECT TOP " . $to . " * FROM (
|
||||
" . $this->sql . "
|
||||
) tb1
|
||||
ORDER BY {$orderBy1}
|
||||
) tb2
|
||||
@@ -143,153 +145,160 @@ class Pagination{
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
public function passo($value){
|
||||
|
||||
public function passo($value) {
|
||||
$this->passo = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function adjacents($value){
|
||||
|
||||
public function adjacents($value) {
|
||||
$this->adjacents = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function sm(){
|
||||
|
||||
public function sm() {
|
||||
$this->size = "sm";
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function lg(){
|
||||
|
||||
public function lg() {
|
||||
$this->size = "lg";
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function md(){
|
||||
|
||||
public function md() {
|
||||
$this->size = "md";
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function cacheFile($prefix = true){
|
||||
|
||||
public function cacheFile($prefix = true) {
|
||||
$this->cacheFile = $prefix;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function query($value){
|
||||
if(\Query::is_typeQuery($value)){
|
||||
|
||||
public function query($value) {
|
||||
if (\Query::is_typeQuery($value)) {
|
||||
$this->sql = $value->getSql();
|
||||
if($this->cacheFile===false){
|
||||
if ($this->cacheFile === false) {
|
||||
$this->cacheFile($value->getCacheFile());
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$this->sql = $value;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function isCurrentPage($numPage){
|
||||
|
||||
private function isCurrentPage($numPage) {
|
||||
return $numPage === $this->getCurrentNumPage();
|
||||
}
|
||||
|
||||
private function isLastPage($numPage){
|
||||
|
||||
private function isLastPage($numPage) {
|
||||
return $numPage >= $this->getMaxNumPage();
|
||||
}
|
||||
|
||||
private function isFirstPage($numPage){
|
||||
|
||||
private function isFirstPage($numPage) {
|
||||
return $numPage === 1;
|
||||
}
|
||||
|
||||
public function render(){
|
||||
|
||||
public function render() {
|
||||
global $_GET;
|
||||
if($this->getMaxNumPage()>1){
|
||||
if ($this->getMaxNumPage() > 1) {
|
||||
$get_p = $_GET;
|
||||
unset($get_p["pag"]);
|
||||
parse_str(http_build_query($get_p), $HttpQuery);
|
||||
$queryUri = http_build_query($HttpQuery);
|
||||
$queryUri = preg_replace('/%5B[0-9]+%5D/simU', '%5B%5D', $queryUri);
|
||||
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div>
|
||||
<ul class="pagination pagination-<?=$this->size?>"><?
|
||||
if($this->flagBtPrev){?>
|
||||
<li>
|
||||
<a href="<?="{$_SERVER["PHP_SELF"]}?{$queryUri}&pag=".($this->getCurrentNumPage()-1)?>" aria-label="Precedente">
|
||||
<span aria-hidden="true">«</span>
|
||||
</a>
|
||||
</li><?
|
||||
<ul class="pagination pagination-<?= $this->size ?>"><?
|
||||
if ($this->flagBtPrev) {
|
||||
?>
|
||||
<li>
|
||||
<a href="<?= "{$_SERVER["PHP_SELF"]}?{$queryUri}&pag=" . ($this->getCurrentNumPage() - 1) ?>"
|
||||
aria-label="Precedente">
|
||||
<span aria-hidden="true">«</span>
|
||||
</a>
|
||||
</li><?
|
||||
}
|
||||
|
||||
$arr_pagesList = $this->getListNumPage();
|
||||
foreach ($arr_pagesList as $c => $number) {
|
||||
if ($arr_pagesList[(($c == 0) ? 0 : $c - 1)] + 1 != $number && $c > 0) {
|
||||
?>
|
||||
<li class="disabled"><a href="#">...</a></li><?
|
||||
}
|
||||
|
||||
$arr_pagesList = $this->getListNumPage();
|
||||
foreach($arr_pagesList as $c => $number){
|
||||
if($arr_pagesList[(($c==0)?0:$c-1)]+1!=$number && $c>0){?>
|
||||
<li class="disabled"><a href="#">...</a></li><?
|
||||
}
|
||||
if(!$this->isCurrentPage($number)){?>
|
||||
<li>
|
||||
<a href="<?="{$_SERVER["PHP_SELF"]}?{$queryUri}&pag={$number}"?>">
|
||||
<?=number_format($number, 0, ".", "'")?>
|
||||
</a>
|
||||
</li><?
|
||||
} else{ // corrente ?>
|
||||
<li class="active"><a href="#"><?=number_format($number, 0, ".", "'")?></a></li><?
|
||||
}
|
||||
}
|
||||
|
||||
if($this->flagBtNext){?>
|
||||
if (!$this->isCurrentPage($number)) {
|
||||
?>
|
||||
<li>
|
||||
<a href="<?="{$_SERVER["PHP_SELF"]}?{$queryUri}&pag=".($this->getCurrentNumPage()+1)?>" aria-label="Successiva">
|
||||
<span aria-hidden="true">»</span>
|
||||
</a>
|
||||
<a href="<?= "{$_SERVER["PHP_SELF"]}?{$queryUri}&pag={$number}" ?>">
|
||||
<?= number_format($number, 0, ".", "'") ?>
|
||||
</a>
|
||||
</li><?
|
||||
}?>
|
||||
</ul>
|
||||
} else { // corrente ?>
|
||||
<li class="active"><a href="#"><?= number_format($number, 0, ".", "'") ?></a></li><?
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->flagBtNext) {
|
||||
?>
|
||||
<li>
|
||||
<a href="<?= "{$_SERVER["PHP_SELF"]}?{$queryUri}&pag=" . ($this->getCurrentNumPage() + 1) ?>"
|
||||
aria-label="Successiva">
|
||||
<span aria-hidden="true">»</span>
|
||||
</a>
|
||||
</li><?
|
||||
} ?>
|
||||
</ul>
|
||||
</div><?
|
||||
|
||||
|
||||
$html = Utility\Str::remove_multiple_spaces(ob_get_contents());
|
||||
@ob_end_clean();
|
||||
@ob_end_flush();
|
||||
echo $html;
|
||||
}
|
||||
}
|
||||
|
||||
public function display(){
|
||||
|
||||
public function display() {
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
private function setListPagesNumber(){
|
||||
|
||||
private function setListPagesNumber() {
|
||||
$lastpage = $this->getMaxNumPage();
|
||||
$thispage = $this->getCurrentNumPage();
|
||||
|
||||
|
||||
$array = array();
|
||||
$adjacents = $this->adjacents;
|
||||
$n_extr_pages = 2;
|
||||
if(Utility::is_mobile()){
|
||||
if (Utility::is_mobile()) {
|
||||
$adjacents = 1;
|
||||
$n_extr_pages = 1;
|
||||
}
|
||||
|
||||
for($counter = 1; $counter <= $lastpage; $counter++){
|
||||
if($lastpage < 7 + $adjacents * 2){
|
||||
|
||||
for ($counter = 1; $counter <= $lastpage; $counter++) {
|
||||
if ($lastpage < 7 + $adjacents * 2) {
|
||||
$array[] = $counter;
|
||||
} else if($lastpage > 5 + $adjacents * 2){
|
||||
if($thispage < 1 + $adjacents * 2){ //close to beginning; only hide later pages
|
||||
if($counter < 4 + $adjacents * 2 || ($counter <= $lastpage && $counter >= $lastpage-($n_extr_pages-1))){
|
||||
} else if ($lastpage > 5 + $adjacents * 2) {
|
||||
if ($thispage < 1 + $adjacents * 2) { //close to beginning; only hide later pages
|
||||
if ($counter < 4 + $adjacents * 2 || ($counter <= $lastpage && $counter >= $lastpage - ($n_extr_pages - 1))) {
|
||||
$array[] = $counter;
|
||||
}
|
||||
} else if($lastpage - $adjacents * 2 > $thispage && $thispage > $adjacents * 2){ //in middle; hide some front and some back
|
||||
if($counter <= $n_extr_pages || ( $counter >= $thispage - $adjacents && $counter <= $thispage + $adjacents) || ($counter >= $lastpage-($n_extr_pages-1) || $counter <= $n_extr_pages)){
|
||||
} else if ($lastpage - $adjacents * 2 > $thispage && $thispage > $adjacents * 2) { //in middle; hide some front and some back
|
||||
if ($counter <= $n_extr_pages || ($counter >= $thispage - $adjacents && $counter <= $thispage + $adjacents) || ($counter >= $lastpage - ($n_extr_pages - 1) || $counter <= $n_extr_pages)) {
|
||||
$array[] = $counter; // PRIME PAGINE || PAGINE NEL MEZZO || ULTIME PAGINE
|
||||
}
|
||||
} else{ //close to end; only hide early pages
|
||||
if($counter <= $n_extr_pages || ($counter >= $lastpage - (2 + $adjacents * 2) && $counter <= $lastpage)){
|
||||
} else { //close to end; only hide early pages
|
||||
if ($counter <= $n_extr_pages || ($counter >= $lastpage - (2 + $adjacents * 2) && $counter <= $lastpage)) {
|
||||
$array[] = $counter; // PRIME PAGINE || PAGINE NEL MEZZO || ULTIME PAGINE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->pages = $array;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
<?php
|
||||
class PdfDoc{
|
||||
|
||||
class PdfDoc {
|
||||
private $arr_whereCond = array();
|
||||
|
||||
public function whereDate($k, $v){
|
||||
|
||||
public function whereDate($k, $v) {
|
||||
$v = \Utility\Date::isValidUnixtime($v) ? strftime(\Format::strftimeYMD, $v) : $v;
|
||||
return $this->where($k, $v);
|
||||
}
|
||||
|
||||
public function where($k, $v = false){
|
||||
if($v!==false){
|
||||
if(in_array($k, array("ser_doc", "cod_anag", "cod_dtip", "data_doc", "num_doc"))){
|
||||
$k = "dtb_doc_pdf.".$k;
|
||||
|
||||
public function where($k, $v = false) {
|
||||
if ($v !== false) {
|
||||
if (in_array($k, array("ser_doc", "cod_anag", "cod_dtip", "data_doc", "num_doc"))) {
|
||||
$k = "dtb_doc_pdf." . $k;
|
||||
}
|
||||
$this->arr_whereCond[] = array("k" => $k, "v" => $v);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getList(){
|
||||
|
||||
public function getList() {
|
||||
$Ret = new Ret;
|
||||
if(count($this->arr_whereCond)>0){
|
||||
if (count($this->arr_whereCond) > 0) {
|
||||
$sql = "SELECT t.*,
|
||||
dtb_doc_pdf.filename,
|
||||
dtb_doc_pdf.filesize,
|
||||
@@ -59,68 +60,68 @@ class PdfDoc{
|
||||
dtb_doc_pdf.ser_doc = t.ser_doc AND
|
||||
dtb_doc_pdf.versione = t.versione
|
||||
WHERE 1 = 1";
|
||||
|
||||
|
||||
$Query = new Query($sql);
|
||||
foreach($this->arr_whereCond as $whereCond){
|
||||
foreach ($this->arr_whereCond as $whereCond) {
|
||||
$Query->where($whereCond["k"], $whereCond["v"]);
|
||||
}
|
||||
$Ret = $Query->toRet()->date2ts()->execute();
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Condizione non pervenuta");
|
||||
}
|
||||
|
||||
return $Ret;
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function get($key){
|
||||
|
||||
public static function get($key) {
|
||||
$Query = new \Query;
|
||||
$Query->select("data_doc", "num_doc", "ser_doc", "cod_anag", "cod_dtip", "versione", "filename AS name")
|
||||
->from("dtb_doc_pdf")
|
||||
->where("(filecontent IS NOT NULL OR ref_uuid IS NOT NULL)")
|
||||
->whereDate("data_doc", $key["data_doc"])
|
||||
->where("num_doc", $key["num_doc"])
|
||||
->where("ser_doc", $key["ser_doc"])
|
||||
->where("cod_anag", $key["cod_anag"])
|
||||
->where("cod_dtip", $key["cod_dtip"])
|
||||
->orderBy("versione DESC");
|
||||
|
||||
if(array_key_exists("versione", $key)){
|
||||
->from("dtb_doc_pdf")
|
||||
->where("(filecontent IS NOT NULL OR ref_uuid IS NOT NULL)")
|
||||
->whereDate("data_doc", $key["data_doc"])
|
||||
->where("num_doc", $key["num_doc"])
|
||||
->where("ser_doc", $key["ser_doc"])
|
||||
->where("cod_anag", $key["cod_anag"])
|
||||
->where("cod_dtip", $key["cod_dtip"])
|
||||
->orderBy("versione DESC");
|
||||
|
||||
if (array_key_exists("versione", $key)) {
|
||||
$Query->where("versione", $key["versione"]);
|
||||
}
|
||||
|
||||
|
||||
$Ret = $Query->firstRow()->toRet()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$item = $Ret->get_data();
|
||||
if(!is_null($item)){
|
||||
if (!is_null($item)) {
|
||||
$IMSApi = new IMSApi;
|
||||
$IMSApi->download("downloadDtbDocPdf")
|
||||
->queryDateParam("dataDoc", $item["data_doc"])
|
||||
->queryParam("numDoc", $item["num_doc"])
|
||||
->queryParam("serDoc", $item["ser_doc"])
|
||||
->queryParam("codAnag", $item["cod_anag"])
|
||||
->queryParam("codDtip", $item["cod_dtip"])
|
||||
->queryParam("versione", $item["versione"]);
|
||||
->queryDateParam("dataDoc", $item["data_doc"])
|
||||
->queryParam("numDoc", $item["num_doc"])
|
||||
->queryParam("serDoc", $item["ser_doc"])
|
||||
->queryParam("codAnag", $item["cod_anag"])
|
||||
->queryParam("codDtip", $item["cod_dtip"])
|
||||
->queryParam("versione", $item["versione"]);
|
||||
$Ret = $IMSApi->send();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret->set_byte(Utility\Compression\GZ::uncompress($Ret->get_data()))
|
||||
->set_string($item["name"])
|
||||
->set_data($item);
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("File non trovato");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function cache($key){
|
||||
|
||||
public static function cache($key) {
|
||||
$Ret = self::get($key);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret = Cache::writeR($Ret->get_string(), $Ret->get_byte(), true, true);
|
||||
}
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,25 +1,26 @@
|
||||
<?php
|
||||
class PdfOrd{
|
||||
|
||||
class PdfOrd {
|
||||
private $arr_whereCond = array();
|
||||
|
||||
public function whereDate($k, $v){
|
||||
|
||||
public function whereDate($k, $v) {
|
||||
$v = \Utility\Date::isValidUnixtime($v) ? strftime(\Format::strftimeYMD, $v) : $v;
|
||||
return $this->where($k, $v);
|
||||
}
|
||||
|
||||
public function where($k, $v = false){
|
||||
if($v!==false){
|
||||
if(in_array($k, array("gestione", "data_ord", "num_ord"))){
|
||||
$k = "dtb_ord_pdf.".$k;
|
||||
|
||||
public function where($k, $v = false) {
|
||||
if ($v !== false) {
|
||||
if (in_array($k, array("gestione", "data_ord", "num_ord"))) {
|
||||
$k = "dtb_ord_pdf." . $k;
|
||||
}
|
||||
$this->arr_whereCond[] = array("k" => $k, "v" => $v);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getList(){
|
||||
|
||||
public function getList() {
|
||||
$Ret = new Ret;
|
||||
if(count($this->arr_whereCond)>0){
|
||||
if (count($this->arr_whereCond) > 0) {
|
||||
$sql = "SELECT t.*,
|
||||
dtb_ord_pdf.filename,
|
||||
dtb_ord_pdf.filesize,
|
||||
@@ -40,64 +41,64 @@ class PdfOrd{
|
||||
dtb_ord_pdf.gestione = t.gestione AND
|
||||
dtb_ord_pdf.versione = t.versione
|
||||
WHERE 1 = 1";
|
||||
|
||||
|
||||
$Query = new Query($sql);
|
||||
foreach($this->arr_whereCond as $whereCond){
|
||||
foreach ($this->arr_whereCond as $whereCond) {
|
||||
$Query->where($whereCond["k"], $whereCond["v"]);
|
||||
}
|
||||
$Ret = $Query->toRet()->date2ts()->execute();
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Condizione non pervenuta");
|
||||
}
|
||||
|
||||
return $Ret;
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function get($key){
|
||||
|
||||
public static function get($key) {
|
||||
$Query = new \Query;
|
||||
$Query->select("data_ord", "num_ord", "gestione", "versione", "filename AS name")
|
||||
->from("dtb_ord_pdf")
|
||||
->where("filecontent IS NOT NULL")
|
||||
->whereDate("data_ord", $key["data_ord"])
|
||||
->where("num_ord", $key["num_ord"])
|
||||
->where("gestione", $key["gestione"])
|
||||
->orderBy("versione DESC");
|
||||
|
||||
if(array_key_exists("versione", $key)){
|
||||
->from("dtb_ord_pdf")
|
||||
->where("filecontent IS NOT NULL")
|
||||
->whereDate("data_ord", $key["data_ord"])
|
||||
->where("num_ord", $key["num_ord"])
|
||||
->where("gestione", $key["gestione"])
|
||||
->orderBy("versione DESC");
|
||||
|
||||
if (array_key_exists("versione", $key)) {
|
||||
$Query->where("versione", $key["versione"]);
|
||||
}
|
||||
|
||||
|
||||
$Ret = $Query->firstRow()->toRet()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$item = $Ret->get_data();
|
||||
if(!is_null($item)){
|
||||
if (!is_null($item)) {
|
||||
$IMSApi = new IMSApi;
|
||||
$IMSApi->download("downloadDtbOrdPdf")
|
||||
->queryDateParam("dataOrd", $item["data_ord"])
|
||||
->queryParam("numOrd", $item["num_ord"])
|
||||
->queryParam("gestione", $item["gestione"])
|
||||
->queryParam("versione", $item["versione"]);
|
||||
->queryDateParam("dataOrd", $item["data_ord"])
|
||||
->queryParam("numOrd", $item["num_ord"])
|
||||
->queryParam("gestione", $item["gestione"])
|
||||
->queryParam("versione", $item["versione"]);
|
||||
$Ret = $IMSApi->send();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret->set_byte(Utility\Compression\GZ::uncompress($Ret->get_data()))
|
||||
->set_string($item["name"])
|
||||
->set_data($item);
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("File non trovato");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function cache($key){
|
||||
|
||||
public static function cache($key) {
|
||||
$Ret = self::get($key);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret = Cache::writeR($Ret->get_string(), $Ret->get_byte(), true, true);
|
||||
}
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,100 +1,101 @@
|
||||
<?php
|
||||
class PdfUtils{
|
||||
|
||||
class PdfUtils {
|
||||
private $arr_pdfBlobs = array();
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
$this->arr_pdfBlobs = array();
|
||||
}
|
||||
|
||||
public function add($blob){
|
||||
if(!is_null($blob)){
|
||||
|
||||
public function add($blob) {
|
||||
if (!is_null($blob)) {
|
||||
$this->arr_pdfBlobs[] = $blob;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function merge(){
|
||||
|
||||
public function merge() {
|
||||
$Ret = new Ret;
|
||||
try{
|
||||
try {
|
||||
$body = $this->buildBody();
|
||||
if(count($body)>0){
|
||||
if(count($body)==1){ // un solo pdf, non chiamo il servizio di merging
|
||||
if (count($body) > 0) {
|
||||
if (count($body) == 1) { // un solo pdf, non chiamo il servizio di merging
|
||||
$Ret->set_byte($this->arr_pdfBlobs[0]);
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$IMSApi = new IMSApi;
|
||||
$Ret = $IMSApi->post("mergePDF")->body($body)->send();
|
||||
|
||||
if($Ret->is_OK()){
|
||||
|
||||
if ($Ret->is_OK()) {
|
||||
$returnData = $Ret->get_data();
|
||||
if(!is_null($returnData) && isset($returnData[0])){
|
||||
if($returnData[0]["esito"]==1){
|
||||
if (!is_null($returnData) && isset($returnData[0])) {
|
||||
if ($returnData[0]["esito"] == 1) {
|
||||
$Ret->set_byte(self::decodeBlob($returnData[0]["genericList"][0]));
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error($returnData[0]["errorMessage"]);
|
||||
}
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Return data vuota");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("Lista file pdf vuota");
|
||||
}
|
||||
|
||||
} catch(Exception $e){
|
||||
$Ret->set_error("PdfUtils.merge.catch: ".$e->getMessage());
|
||||
|
||||
} catch (Exception $e) {
|
||||
$Ret->set_error("PdfUtils.merge.catch: " . $e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function split(){
|
||||
|
||||
public function split() {
|
||||
$Ret = new Ret;
|
||||
try{
|
||||
try {
|
||||
$body = $this->buildBody();
|
||||
if(count($body)>0){
|
||||
if (count($body) > 0) {
|
||||
$IMSApi = new IMSApi;
|
||||
$Ret = $IMSApi->post("splitPDF")->body($body)->send();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$returnData = $Ret->get_data();
|
||||
if(count($returnData[0]["dto"])>0){
|
||||
foreach($returnData[0]["dto"] as $i => $blob){
|
||||
if (count($returnData[0]["dto"]) > 0) {
|
||||
foreach ($returnData[0]["dto"] as $i => $blob) {
|
||||
$returnData[0]["dto"][$i] = self::decodeBlob($blob);
|
||||
}
|
||||
$Ret->set_data($returnData[0]["dto"]);
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("Non è stato generato alcun file");
|
||||
}
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("File pdf non pervenuto");
|
||||
}
|
||||
} catch(Exception $e){
|
||||
$Ret->set_error("PdfUtils.split.catch: ".$e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
$Ret->set_error("PdfUtils.split.catch: " . $e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
private function buildBody(){
|
||||
|
||||
private function buildBody() {
|
||||
$body = array();
|
||||
foreach($this->arr_pdfBlobs as $blob){
|
||||
foreach ($this->arr_pdfBlobs as $blob) {
|
||||
$body[] = array("b64_gz_blob_pdf" => base64_encode(\Utility\Compression\GZ::compress($blob)));
|
||||
}
|
||||
return $body;
|
||||
}
|
||||
|
||||
private static function decodeBlob($blob){
|
||||
if(self::isBase64Encoded($blob)){
|
||||
|
||||
private static function decodeBlob($blob) {
|
||||
if (self::isBase64Encoded($blob)) {
|
||||
$blob = base64_decode($blob);
|
||||
}
|
||||
return Utility\Compression\GZ::uncompress($blob);
|
||||
}
|
||||
|
||||
private static function isBase64Encoded($data){
|
||||
|
||||
private static function isBase64Encoded($data) {
|
||||
return !(base64_decode($data, true) === false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +1,40 @@
|
||||
<?php
|
||||
class PvwClientiProspect{ // VALUTARE POSSIBILITA DI CREARE PROGENITORE
|
||||
|
||||
class PvwClientiProspect { // VALUTARE POSSIBILITA DI CREARE PROGENITORE
|
||||
const view = "pvw_clienti_prospect";
|
||||
const oneRow = true;
|
||||
|
||||
|
||||
private $key = array();
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
public function key($key, $value){
|
||||
|
||||
public function key($key, $value) {
|
||||
$this->key[$key] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get(){
|
||||
|
||||
public function get() {
|
||||
$arr_columns = func_get_args();
|
||||
if(count($arr_columns)>0){
|
||||
foreach($arr_columns as &$item){
|
||||
if (count($arr_columns) > 0) {
|
||||
foreach ($arr_columns as &$item) {
|
||||
$item = Utility\Str::camelCaseDecode($item);
|
||||
}
|
||||
|
||||
|
||||
$table = $this->get_tableName();
|
||||
$Query = new Query;
|
||||
$Query = $Query->select($arr_columns)->from($table);
|
||||
foreach($this->key as $key => $value){
|
||||
foreach ($this->key as $key => $value) {
|
||||
$key = Utility\Str::camelCaseDecode($key);
|
||||
$Query->where($key, $value);
|
||||
}
|
||||
|
||||
|
||||
$Ret = $Query->date2ts()->toRet()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$arr_rows = $Ret->get_data();
|
||||
if(self::oneRow){
|
||||
if(count($arr_rows)>0){
|
||||
if(count($arr_columns)==1){
|
||||
if (self::oneRow) {
|
||||
if (count($arr_rows) > 0) {
|
||||
if (count($arr_columns) == 1) {
|
||||
return $arr_rows[0][$arr_columns[0]];
|
||||
}
|
||||
return $arr_rows[0];
|
||||
@@ -45,8 +46,8 @@ class PvwClientiProspect{ // VALUTARE POSSIBILITA DI CREARE PROGENITORE
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function get_tableName(){
|
||||
|
||||
private function get_tableName() {
|
||||
return self::view;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Query
|
||||
{
|
||||
class Query {
|
||||
public $errorText = null;
|
||||
public $sql = null;
|
||||
public $processSql = false;
|
||||
@@ -35,24 +34,20 @@ class Query
|
||||
private $arr_values = array(); // WARN va insieme a insert()
|
||||
private $arr_select = array(); // CONTIENE IL NOME DELLE SOLE COLONNE DA TORNARE (NON COMPLETAMENTE SUPPORTATO)
|
||||
|
||||
public function __construct($s = null)
|
||||
{//var_dump($s);
|
||||
public function __construct($s = null) {//var_dump($s);
|
||||
$this->construct($s)//->cacheFile()
|
||||
;
|
||||
}
|
||||
|
||||
public function construct($s)
|
||||
{
|
||||
public function construct($s) {
|
||||
return $this->setSql($s, false)->date2ts()->profileDB();
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
public function __destruct() {
|
||||
$this->db = null;
|
||||
}
|
||||
|
||||
public function profileDB($profileDB = null)
|
||||
{
|
||||
public function profileDB($profileDB = null) {
|
||||
$this->db = false;
|
||||
$this->profileDB = $profileDB;
|
||||
|
||||
@@ -73,8 +68,7 @@ class Query
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function getAvailableDrivers()
|
||||
{
|
||||
public static function getAvailableDrivers() {
|
||||
$drivers = array("mssql");
|
||||
if (extension_loaded("sqlsrv")) {
|
||||
$drivers[] = "sqlsrv";
|
||||
@@ -85,13 +79,11 @@ class Query
|
||||
return $drivers;
|
||||
}
|
||||
|
||||
public static function getDefaultDriver()
|
||||
{
|
||||
public static function getDefaultDriver() {
|
||||
return "mssql";
|
||||
}
|
||||
|
||||
private function getDriver()
|
||||
{
|
||||
private function getDriver() {
|
||||
$driver = self::getDefaultDriver();
|
||||
$dbConfig = Config::get_dbData($this->profileDB);
|
||||
if (!is_null($dbConfig)) {
|
||||
@@ -105,8 +97,7 @@ class Query
|
||||
return $driver;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
public function __toString() {
|
||||
return \Utility\Str::remove_multiple_spaces($this->getSql());
|
||||
}
|
||||
|
||||
@@ -123,31 +114,26 @@ class Query
|
||||
return true;
|
||||
}*/
|
||||
|
||||
public function fromToRow($from = null, $to = null, $orderByFromTo = null)
|
||||
{
|
||||
public function fromToRow($from = null, $to = null, $orderByFromTo = null) {
|
||||
return $this->fromRow($from)->toRow($to)->orderByFromTo($orderByFromTo);
|
||||
}
|
||||
|
||||
private function fromRow($n)
|
||||
{
|
||||
private function fromRow($n) {
|
||||
$this->fromRow = $n;
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function toRow($n)
|
||||
{
|
||||
private function toRow($n) {
|
||||
$this->toRow = $n;
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function orderByFromTo($value)
|
||||
{
|
||||
private function orderByFromTo($value) {
|
||||
$this->orderByFromTo = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function groupBy($values)
|
||||
{
|
||||
public function groupBy($values) {
|
||||
$values = func_get_args();
|
||||
if (count($values) > 0) {
|
||||
$this->groupBy = implode(",", $values);
|
||||
@@ -155,14 +141,12 @@ class Query
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function orderBy($value)
|
||||
{
|
||||
public function orderBy($value) {
|
||||
$this->orderBy = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSql()
|
||||
{
|
||||
public function getSql() {
|
||||
if ($this->is_insertSql() && count($this->arr_values) > 0) {
|
||||
if (!$this->staticSql) {
|
||||
self::complete_insertSql();
|
||||
@@ -211,18 +195,15 @@ class Query
|
||||
return $this->sql;
|
||||
}
|
||||
|
||||
private static function is_selectSql($sql)
|
||||
{
|
||||
private static function is_selectSql($sql) {
|
||||
return !is_null($sql) ? Utility\Str::startsWith($sql, "SELECT ", false) : false;
|
||||
}
|
||||
|
||||
private function is_insertSql()
|
||||
{
|
||||
private function is_insertSql() {
|
||||
return !is_null($this->sql) ? Utility\Str::startsWith($this->sql, "INSERT INTO ", false) : false;
|
||||
}
|
||||
|
||||
private function complete_insertSql()
|
||||
{
|
||||
private function complete_insertSql() {
|
||||
if (!is_null($this->sql)) {
|
||||
$this->sql .= "(";
|
||||
foreach ($this->arr_values as $fieldname => $value) {
|
||||
@@ -237,75 +218,63 @@ class Query
|
||||
}
|
||||
}
|
||||
|
||||
public function setSql($sql, $staticSql = true)
|
||||
{
|
||||
public function setSql($sql, $staticSql = true) {
|
||||
$this->sql = self::is_typeQuery($sql) ? $sql->getSql() : $sql;
|
||||
$this->staticSql = $staticSql;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function top($n)
|
||||
{
|
||||
public function top($n) {
|
||||
$this->top = $n;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function camelCaseColumnName($b = true)
|
||||
{
|
||||
public function camelCaseColumnName($b = true) {
|
||||
$this->camelCaseColumnName = $b !== false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function date2ts($b = true)
|
||||
{
|
||||
public function date2ts($b = true) {
|
||||
$this->date2ts = $b !== false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function cacheResult($b = true)
|
||||
{
|
||||
public function cacheResult($b = true) {
|
||||
$this->cacheResult = $b !== false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function firstColumn($b = true)
|
||||
{ // se la query ha successo, torna solo un array di valori della prima colonna
|
||||
public function firstColumn($b = true) { // se la query ha successo, torna solo un array di valori della prima colonna
|
||||
$this->firstColumn = $b !== false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function firstRow($b = true)
|
||||
{ // se la query ha successo, torna solo la prima riga (non in un array)
|
||||
public function firstRow($b = true) { // se la query ha successo, torna solo la prima riga (non in un array)
|
||||
$this->firstRow = $b !== false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function firstRowFirstValue($b = true)
|
||||
{ // se la query ha successo, torna solo il valore semplice della prima colonna e della prima riga
|
||||
public function firstRowFirstValue($b = true) { // se la query ha successo, torna solo il valore semplice della prima colonna e della prima riga
|
||||
$this->firstRowFirstValue = $b !== false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toRet($b = true)
|
||||
{ // è necessario posizionarlo "prima" di execute()
|
||||
public function toRet($b = true) { // è necessario posizionarlo "prima" di execute()
|
||||
$this->toRet = $b !== false;
|
||||
$this->_flagSettedToRet = true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function cacheFile($prefix = true)
|
||||
{
|
||||
public function cacheFile($prefix = true) {
|
||||
$this->cacheSqlFile = $prefix;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCacheFile()
|
||||
{
|
||||
public function getCacheFile() {
|
||||
return $this->cacheSqlFile;
|
||||
}
|
||||
|
||||
private static function getModuloCaller()
|
||||
{
|
||||
private static function getModuloCaller() {
|
||||
try {
|
||||
$caller = debug_backtrace();
|
||||
$caller = $caller[3]; //echopre($caller);
|
||||
@@ -322,20 +291,17 @@ class Query
|
||||
return null;
|
||||
}
|
||||
|
||||
public function distinct()
|
||||
{ /* WARN crea una vista esterna, se la query originaria contiene ORDER BY non funziona. utilizzare il metodo orderBy()*/
|
||||
public function distinct() { /* WARN crea una vista esterna, se la query originaria contiene ORDER BY non funziona. utilizzare il metodo orderBy()*/
|
||||
$this->arr_distinct = array_merge($this->arr_distinct, func_get_args());
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function module($moduleName)
|
||||
{
|
||||
public function module($moduleName) {
|
||||
$this->module = $moduleName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function importSqlFile($fileName, $moduleName = null)
|
||||
{
|
||||
public function importSqlFile($fileName, $moduleName = null) {
|
||||
$ext = nullIfBlank(pathinfo($fileName, PATHINFO_EXTENSION));
|
||||
if (is_null($ext)) {
|
||||
$fileName .= ".sql";
|
||||
@@ -351,8 +317,7 @@ class Query
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function getSqlFilePath()
|
||||
{
|
||||
private function getSqlFilePath() {
|
||||
$dirname = nullIfBlank(trim(pathinfo($this->sqlFilename, PATHINFO_DIRNAME), "."));
|
||||
if (!is_null($dirname)) { // passato un percorso completo col file .sql (non controlla nella cartella sql interna alla gestione corrente)
|
||||
$filePath = $this->sqlFilename;
|
||||
@@ -372,8 +337,7 @@ class Query
|
||||
return file_exists($filePath) ? $filePath : null;
|
||||
}
|
||||
|
||||
private function loadSqlFile()
|
||||
{
|
||||
private function loadSqlFile() {
|
||||
$Ret = new Ret;
|
||||
$filePath = $this->getSqlFilePath();
|
||||
if (!is_null($filePath)) {
|
||||
@@ -384,8 +348,7 @@ class Query
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function select()
|
||||
{ // è importante eseguire in ordine select -> from -> where
|
||||
public function select() { // è importante eseguire in ordine select -> from -> where
|
||||
// ACCETTA: nessun argument = * ; argument come array: array("campo1", "campo2") ; piu argument (anche misti cona array): "campo1", "campo2"
|
||||
$arr_values = func_get_args();
|
||||
// PREVENT OVERWRITE SQL
|
||||
@@ -413,14 +376,12 @@ class Query
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function fromView($input, $viewName = "v")
|
||||
{
|
||||
public function fromView($input, $viewName = "v") {
|
||||
$sql = self::is_typeQuery($input) ? $input->getSql() : $input;
|
||||
return $this->from("({$sql}) {$viewName} WHERE 1=1");
|
||||
}
|
||||
|
||||
public function from($value)
|
||||
{/*
|
||||
public function from($value) {/*
|
||||
if(self::is_selectSql($value)){
|
||||
$this->sql .= " FROM (".$value.") v1";
|
||||
|
||||
@@ -431,35 +392,30 @@ class Query
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function insert($table)
|
||||
{// è importante eseguire in ordine insert -> value
|
||||
public function insert($table) {// è importante eseguire in ordine insert -> value
|
||||
if (!is_null($table) && strlen(trim($table)) > 0) {
|
||||
$this->sql = "INSERT INTO {$table} ";
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function valueDatetime($fieldname, $value)
|
||||
{
|
||||
public function valueDatetime($fieldname, $value) {
|
||||
return $this->value($fieldname, strftime(\Format::strftimeYMDHMS, $value));
|
||||
}
|
||||
|
||||
public function value($fieldname, $value = null)
|
||||
{ // WARN va insieme a insert()
|
||||
public function value($fieldname, $value = null) { // WARN va insieme a insert()
|
||||
$this->arr_values[$fieldname] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function update($table)
|
||||
{// è importante eseguire in ordine update -> set -> from -> where
|
||||
public function update($table) {// è importante eseguire in ordine update -> set -> from -> where
|
||||
if (!is_null($table) && strlen(trim($table)) > 0) {
|
||||
$this->sql = "UPDATE " . $table . " SET ";
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function delete($table)
|
||||
{
|
||||
public function delete($table) {
|
||||
if (!is_null($table) && strlen(trim($table)) > 0) {
|
||||
$this->sql = "DELETE FROM " . $table;
|
||||
}
|
||||
@@ -471,16 +427,14 @@ class Query
|
||||
|
||||
}*/
|
||||
|
||||
public function set($field, $value)
|
||||
{// WARN va insieme a update()
|
||||
public function set($field, $value) {// WARN va insieme a update()
|
||||
if (!is_null($this->sql)) {
|
||||
$this->sql .= "{$field} = " . self::sqlValue($value) . ",";
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function sqlValue($v, $type = null)
|
||||
{
|
||||
public static function sqlValue($v, $type = null) {
|
||||
if ($type == \Format::strftimeYMD) {
|
||||
$v = strftime(\Format::strftimeYMD, $v);
|
||||
|
||||
@@ -494,12 +448,11 @@ class Query
|
||||
return is_null($v) ? "NULL" : ((is_float($v) || is_int($v)) ? $v : "'" . str_replace("'", "''", $v) . "'");
|
||||
}
|
||||
|
||||
public static function process_whereParameters($fieldname, $value = false, $type = null)
|
||||
{
|
||||
public static function process_whereParameters($fieldname, $value = false, $type = null) {
|
||||
return self::processWhereParameters($fieldname, $value, $type);
|
||||
}
|
||||
|
||||
public static function processWhereParameters($fieldname, $value = false, $type = null, $mode = "AND"){
|
||||
|
||||
public static function processWhereParameters($fieldname, $value = false, $type = null, $mode = "AND") {
|
||||
$whereCond = "";
|
||||
if ($value !== false) {
|
||||
if (is_null($value)) {
|
||||
@@ -549,12 +502,11 @@ class Query
|
||||
} else {
|
||||
$whereCond = $fieldname; // condizione fissa
|
||||
}
|
||||
|
||||
return strlen($whereCond)>0 ? " (".rtrim($whereCond, " {$mode} ").") " : "";
|
||||
|
||||
return strlen($whereCond) > 0 ? " (" . rtrim($whereCond, " {$mode} ") . ") " : "";
|
||||
}
|
||||
|
||||
public static function processWhereLikeParameters($fieldname, $value, $type = null)
|
||||
{/*
|
||||
public static function processWhereLikeParameters($fieldname, $value, $type = null) {/*
|
||||
if($type==\Format::strftimeYMD){
|
||||
$value = strftime(\Format::strftimeYMD, $value);
|
||||
|
||||
@@ -569,8 +521,7 @@ class Query
|
||||
return strlen($whereCond) > 0 ? " (" . rtrim($whereCond, " AND ") . ") " : "";
|
||||
}
|
||||
|
||||
public function whereNot($fieldname, $value = false, $type = null)
|
||||
{
|
||||
public function whereNot($fieldname, $value = false, $type = null) {
|
||||
if (is_array($fieldname)) {
|
||||
foreach ($fieldname as $_fieldname => $_value) {
|
||||
$this->whereNot($_fieldname, $_value);
|
||||
@@ -582,20 +533,17 @@ class Query
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereDatetime($fieldname, $value = false)
|
||||
{
|
||||
public function whereDatetime($fieldname, $value = false) {
|
||||
$whereCond = self::process_whereParameters($fieldname, $value, Format::strftimeYMDHMS);
|
||||
return $this->whereAppend($whereCond);
|
||||
}
|
||||
|
||||
public function whereDate($fieldname, $value = false)
|
||||
{
|
||||
public function whereDate($fieldname, $value = false) {
|
||||
$whereCond = self::process_whereParameters($fieldname, $value, Format::strftimeYMD);
|
||||
return $this->whereAppend($whereCond);
|
||||
}
|
||||
|
||||
private function applyWhereCondDateComparison($fieldname, $value, $operator)
|
||||
{
|
||||
private function applyWhereCondDateComparison($fieldname, $value, $operator) {
|
||||
$value = \Utility\Date::isValidUnixtime($value) ? strftime(\Format::strftimeYMDHMS, $value) : null;
|
||||
if (!is_null($value)) {
|
||||
return $this->whereAppend("$fieldname $operator '{$value}'");
|
||||
@@ -609,8 +557,7 @@ class Query
|
||||
* @param string $fieldname nome colonna
|
||||
* @param int $value timestamp
|
||||
*/
|
||||
public function whereDateLT($fieldname, $value)
|
||||
{
|
||||
public function whereDateLT($fieldname, $value) {
|
||||
return $this->applyWhereCondDateComparison($fieldname, $value, "<");
|
||||
}
|
||||
|
||||
@@ -620,8 +567,7 @@ class Query
|
||||
* @param string $fieldname nome colonna
|
||||
* @param int $value timestamp
|
||||
*/
|
||||
public function whereDateLE($fieldname, $value)
|
||||
{
|
||||
public function whereDateLE($fieldname, $value) {
|
||||
return $this->applyWhereCondDateComparison($fieldname, $value, "<=");
|
||||
}
|
||||
|
||||
@@ -631,8 +577,7 @@ class Query
|
||||
* @param string $fieldname nome colonna
|
||||
* @param int $value timestamp
|
||||
*/
|
||||
public function whereDateGTE($fieldname, $value)
|
||||
{
|
||||
public function whereDateGTE($fieldname, $value) {
|
||||
return $this->applyWhereCondDateComparison($fieldname, $value, ">=");
|
||||
}
|
||||
|
||||
@@ -642,15 +587,14 @@ class Query
|
||||
* @param string $fieldname nome colonna
|
||||
* @param int $value timestamp
|
||||
*/
|
||||
public function whereDateGT($fieldname, $value)
|
||||
{
|
||||
public function whereDateGT($fieldname, $value) {
|
||||
return $this->applyWhereCondDateComparison($fieldname, $value, ">");
|
||||
}
|
||||
|
||||
public function where($fieldname, $value = false, $type = null, $mode = "AND"){
|
||||
if(is_array($fieldname)){
|
||||
foreach($fieldname as $key => $_value){
|
||||
if(is_array($_value)){
|
||||
|
||||
public function where($fieldname, $value = false, $type = null, $mode = "AND") {
|
||||
if (is_array($fieldname)) {
|
||||
foreach ($fieldname as $key => $_value) {
|
||||
if (is_array($_value)) {
|
||||
$this->where($_value[0], $_value[1]);
|
||||
} else if (!is_numeric($key)) { // array associativo
|
||||
$this->where($key, $_value);
|
||||
@@ -658,27 +602,27 @@ class Query
|
||||
$this->where($_value);
|
||||
}
|
||||
}
|
||||
|
||||
} else if(is_string($fieldname)){
|
||||
|
||||
} else if (is_string($fieldname)) {
|
||||
$whereCond = self::processWhereParameters($fieldname, $value, $type, $mode);
|
||||
$this->whereAppend($whereCond, $mode);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereLike($fieldname, $value = false, $type = null, $mode = "AND"){
|
||||
|
||||
public function whereLike($fieldname, $value = false, $type = null, $mode = "AND") {
|
||||
$whereCond = self::processWhereLikeParameters($fieldname, $value, $type);
|
||||
return $this->whereAppend($whereCond, $mode);
|
||||
}
|
||||
|
||||
private function whereAppend($whereCond, $mode = "AND"){
|
||||
|
||||
private function whereAppend($whereCond, $mode = "AND") {
|
||||
$this->sql = self::addWhereCondToSql($whereCond, $this->sql, $mode);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function addWhereCondToSql($whereCond, $sql, $mode = "AND"){ // non va sulle union
|
||||
if(!is_null($sql)){
|
||||
|
||||
public static function addWhereCondToSql($whereCond, $sql, $mode = "AND") { // non va sulle union
|
||||
if (!is_null($sql)) {
|
||||
$sql = rtrim($sql, ",");
|
||||
$keyword = "WHERE";
|
||||
$wherePos = strrpos(strtoupper($sql), $keyword);
|
||||
@@ -686,7 +630,7 @@ class Query
|
||||
$SQL_select_from = substr($sql, 0, $wherePos);
|
||||
$SQL_where = substr(substr($sql, $wherePos, strlen($sql)), strlen($keyword));
|
||||
$whereCond = " ({$whereCond}) {$mode} ";
|
||||
} else{
|
||||
} else {
|
||||
$SQL_select_from = $sql;
|
||||
$SQL_where = "";
|
||||
}
|
||||
@@ -696,18 +640,15 @@ class Query
|
||||
return null;
|
||||
}
|
||||
|
||||
public function setDateVar($key, $value)
|
||||
{
|
||||
public function setDateVar($key, $value) {
|
||||
return $this->setVar($key, $value, \Format::strftimeYMD);
|
||||
}
|
||||
|
||||
public function setDatetimeVar($key, $value)
|
||||
{
|
||||
public function setDatetimeVar($key, $value) {
|
||||
return $this->setVar($key, $value, \Format::strftimeYMDHMS);
|
||||
}
|
||||
|
||||
public function setVar($key, $value, $type = null)
|
||||
{
|
||||
public function setVar($key, $value, $type = null) {
|
||||
if (!is_null($this->sql)) {
|
||||
if (!is_null($type) && !is_null($value) && $type == \Format::strftimeYMD) {
|
||||
$value = strftime(\Format::strftimeYMD, $value);
|
||||
@@ -749,8 +690,7 @@ class Query
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function sqlToFileCache($filename = "")
|
||||
{
|
||||
private function sqlToFileCache($filename = "") {
|
||||
$Ret = $this->checkSql();
|
||||
if ($Ret->is_OK()) {
|
||||
$filename .= (strlen($filename) > 0 ? "_" : "") . date("Ymd-His") . ".sql";
|
||||
@@ -759,10 +699,9 @@ class Query
|
||||
return null;
|
||||
}
|
||||
|
||||
public function countRowsSql()
|
||||
{
|
||||
public function countRowsSql() {
|
||||
$Query = new Query("SELECT COUNT(*) AS counter FROM (" . $this->getSql() . ") TCOUNT");
|
||||
$Ret = $Query->firstRowFirstValue()->toRet()->execute();
|
||||
$Ret = $Query->profileDB($this->profileDB)->firstRowFirstValue()->toRet()->execute();
|
||||
if ($this->toRet === true) {
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret->set_number($Ret->get_data())->set_data(null);
|
||||
@@ -776,13 +715,13 @@ class Query
|
||||
return $Ret->is_OK() ? $Ret->get_data() : false;
|
||||
}
|
||||
|
||||
public function countRows()
|
||||
{ // su tante richie(clienti fid anag, 200k) la memoria non cia fa
|
||||
$Query = new Query($this->getSql());
|
||||
$Ret = $Query->toRet()->cacheFile($this->cacheSqlFile)->execute();
|
||||
public function countRows() { // su tante richie(clienti fid anag, 200k) la memoria non cia fa
|
||||
// $Query = new Query($this->getSql());
|
||||
// $Ret = $Query->toRet()->cacheFile($this->cacheSqlFile)->execute();
|
||||
$Ret = $this->execute();
|
||||
if ($this->toRet === true) {
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret->set_number(count($Ret->get_data()))->set_data(null);
|
||||
$Ret->set_number(count($Ret->get_data()))->set_data();
|
||||
}
|
||||
return $Ret;
|
||||
|
||||
@@ -791,12 +730,11 @@ class Query
|
||||
@Utility::send_debugMessage("sqlToRet3");
|
||||
}
|
||||
|
||||
return $Ret->is_OK() ? count($Ret->get_data()) : false;
|
||||
return count($Ret);
|
||||
}
|
||||
}
|
||||
|
||||
public function commit()
|
||||
{
|
||||
public function commit() {
|
||||
if ($this->autocommit === false && $this->db !== false) {
|
||||
$result = $this->db->commit();
|
||||
if ($result === false) {
|
||||
@@ -807,8 +745,7 @@ class Query
|
||||
return false;
|
||||
}
|
||||
|
||||
public function rollback()
|
||||
{
|
||||
public function rollback() {
|
||||
if ($this->autocommit === false && $this->db !== false) {
|
||||
$result = $this->db->rollback();
|
||||
if ($result === false) {
|
||||
@@ -819,8 +756,7 @@ class Query
|
||||
return false;
|
||||
}
|
||||
|
||||
public function begin_transaction()
|
||||
{
|
||||
public function begin_transaction() {
|
||||
$this->autocommit = false;
|
||||
if ($this->db !== false) {
|
||||
$this->db->begin_transaction();
|
||||
@@ -828,8 +764,7 @@ class Query
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function processResource()
|
||||
{
|
||||
private function processResource() {
|
||||
$arr_rows = array();
|
||||
while ($this->db->next_record()) {
|
||||
if ($this->db->Row == 1) { // LETTURA NOME COLONNE
|
||||
@@ -841,7 +776,7 @@ class Query
|
||||
$value = $this->db->f($field);
|
||||
$type = $this->db->field_type($i); //if($field=="content")exit($field. " ".$value." - ");
|
||||
if (!is_null($value)) { // echo ' {'.$field.': '.$type.'}';
|
||||
if (in_array($type, array("int", "bigint", "smallint", "tinyint"))) {
|
||||
if (in_array($type, array("int", "bigint", "smallint", "tinyint", "bit"))) {
|
||||
$value = intval($value);
|
||||
|
||||
} else if (in_array($type, array("real", "decimal", "float", "numeric"))) {
|
||||
@@ -897,8 +832,7 @@ class Query
|
||||
return $retValue;
|
||||
}
|
||||
|
||||
public function checkSyntax()
|
||||
{
|
||||
public function checkSyntax() {
|
||||
$Ret = $this->checkSql();
|
||||
if ($Ret->is_OK()) {
|
||||
$sql = "SET FMTONLY ON;" . $this->getSql() . ";SET FMTONLY OFF;";
|
||||
@@ -908,8 +842,7 @@ class Query
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
private function checkSql()
|
||||
{
|
||||
private function checkSql() {
|
||||
$Ret = new Ret;
|
||||
if (!is_null($this->sqlFilename)) {
|
||||
// NON LO IMPORTA (LO FA IN PRECEDENZA), LO RIPETE X VERIFICARE CHE SIA ANDATO A BUON FINE
|
||||
@@ -927,13 +860,11 @@ class Query
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
public function execute() {
|
||||
return $this->run();
|
||||
}
|
||||
|
||||
public function getConnection()
|
||||
{
|
||||
public function getConnection() {
|
||||
if ($this->db !== false) {
|
||||
return $this->db->getConnection();
|
||||
}
|
||||
@@ -960,13 +891,11 @@ class Query
|
||||
}
|
||||
}*/
|
||||
|
||||
public static function calcSqlHash($sql)
|
||||
{
|
||||
public static function calcSqlHash($sql) {
|
||||
return md5($sql);
|
||||
}
|
||||
|
||||
private function getCachedResult()
|
||||
{
|
||||
private function getCachedResult() {
|
||||
$sql = $this->getSql();
|
||||
$sqlHash = self::calcSqlHash($sql);
|
||||
if (isset($GLOBALS["QueryResult"]) && array_key_exists($sqlHash, $GLOBALS["QueryResult"])) {
|
||||
@@ -975,8 +904,7 @@ class Query
|
||||
return false;
|
||||
}
|
||||
|
||||
private function setCachedResult($value)
|
||||
{
|
||||
private function setCachedResult($value) {
|
||||
$sql = $this->getSql();
|
||||
$sqlHash = self::calcSqlHash($sql);
|
||||
if (!isset($GLOBALS["QueryResult"]) || !is_array($GLOBALS["QueryResult"])) {
|
||||
@@ -985,8 +913,7 @@ class Query
|
||||
$GLOBALS["QueryResult"][$sqlHash] = $value;
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
public function run() {
|
||||
$retValue = false;
|
||||
|
||||
$Ret = new Ret;
|
||||
@@ -1098,8 +1025,7 @@ class Query
|
||||
return $retValue;
|
||||
}
|
||||
|
||||
public function execute_multiSql($arr_sql)
|
||||
{
|
||||
public function execute_multiSql($arr_sql) {
|
||||
$Ret = new Ret;
|
||||
$this->begin_transaction();
|
||||
foreach ($arr_sql as $sql) {
|
||||
@@ -1117,13 +1043,11 @@ class Query
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function get_lastSqlMessage()
|
||||
{
|
||||
public function get_lastSqlMessage() {
|
||||
return $this->lastSqlMessage;
|
||||
}
|
||||
|
||||
public function exportToSqlInsert($tablename)
|
||||
{
|
||||
public function exportToSqlInsert($tablename) {
|
||||
$arr_res = $this->execute();
|
||||
$arr_sqlOut = array();
|
||||
if ($arr_res !== false) {
|
||||
@@ -1152,8 +1076,7 @@ class Query
|
||||
return $arr_sqlOut;
|
||||
}
|
||||
|
||||
private static function parse_pointValue($s)
|
||||
{ //$txt='POINT (40.9953441 17.2195846)';
|
||||
private static function parse_pointValue($s) { //$txt='POINT (40.9953441 17.2195846)';
|
||||
if (is_string($s)) {
|
||||
$re1 = '(POINT)'; # Word 1
|
||||
$re2 = '.*?'; # Non-greedy match on filler
|
||||
@@ -1177,21 +1100,18 @@ class Query
|
||||
return $s;
|
||||
}
|
||||
|
||||
public static function is_typeQuery($value)
|
||||
{
|
||||
public static function is_typeQuery($value) {
|
||||
return gettype($value) == "object" && (get_class($value) == "Query" || is_subclass_of($value, "Query"));
|
||||
}
|
||||
|
||||
public function addSelect($select)
|
||||
{
|
||||
public function addSelect($select) {
|
||||
if (!is_null($this->sql)) {
|
||||
$selectPos = strpos($this->sql, "SELECT");
|
||||
$this->sql = substr_replace($this->sql, " " . $select . ", \n\r", ($selectPos + 6), 0);
|
||||
}
|
||||
}
|
||||
|
||||
public function processSql($processSql = true)
|
||||
{
|
||||
public function processSql($processSql = true) {
|
||||
$this->processSql = $processSql;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -1,71 +1,72 @@
|
||||
<?php
|
||||
class RemoteModuleUrl{
|
||||
|
||||
class RemoteModuleUrl {
|
||||
private $profileDB = null;
|
||||
private $module = null;
|
||||
private $destPage = null;
|
||||
private $urlParamName = null;
|
||||
private $data = array();
|
||||
private $customQueryParams = array();
|
||||
|
||||
public function __construct(){
|
||||
|
||||
public function __construct() {
|
||||
$this->profileDB(User::get_current_profileDb())->urlParamName("d")->destPage("emailcheck.php");
|
||||
}
|
||||
|
||||
public function get_url(){
|
||||
|
||||
public function get_url() {
|
||||
$urlData = array(
|
||||
"profileDB" => $this->profileDB,
|
||||
"gest-lib" => $this->module,
|
||||
"data" => $this->data
|
||||
);
|
||||
|
||||
|
||||
$baseUrl = PVM::get_current_projectPublicUrl();
|
||||
if(PVM::isDevClient()){
|
||||
if (PVM::isDevClient()) {
|
||||
$protocol = PVM::get_protocol();
|
||||
$projectName = PVM::get_projectName();
|
||||
$baseUrl = $protocol."://localhost/{$projectName}/";
|
||||
$baseUrl = $protocol . "://localhost/{$projectName}/";
|
||||
}
|
||||
|
||||
|
||||
$params = $this->customQueryParams;
|
||||
if(!is_null($this->urlParamName)){
|
||||
if (!is_null($this->urlParamName)) {
|
||||
$params[$this->urlParamName] = Utility::B64JSON_stringify($urlData);
|
||||
}
|
||||
|
||||
return $baseUrl.$this->destPage."?".http_build_query($params);
|
||||
|
||||
return $baseUrl . $this->destPage . "?" . http_build_query($params);
|
||||
//return $baseUrl.$this->destPage."?".$this->urlParamName."=".Utility::B64JSON_stringify($urlData);
|
||||
}
|
||||
|
||||
public function profileDB($v){
|
||||
|
||||
public function profileDB($v) {
|
||||
$this->profileDB = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function urlParamName($v){
|
||||
|
||||
public function urlParamName($v) {
|
||||
$this->urlParamName = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function destPage($v){
|
||||
|
||||
public function destPage($v) {
|
||||
$this->destPage = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function module($v){
|
||||
|
||||
public function module($v) {
|
||||
$this->module = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function data($v){
|
||||
|
||||
public function data($v) {
|
||||
$this->data = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function appendCustomQueryParam($k, $v){
|
||||
|
||||
public function appendCustomQueryParam($k, $v) {
|
||||
$this->customQueryParams[$k] = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function redirectToModulo($v){
|
||||
return $this->destPage("login.php")->appendCustomQueryParam("ref", $v.".php");
|
||||
|
||||
public function redirectToModulo($v) {
|
||||
return $this->destPage("login.php")->appendCustomQueryParam("ref", $v . ".php");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,67 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Report;
|
||||
class Functions{
|
||||
|
||||
public static function parsePoliciesList($item){
|
||||
class Functions {
|
||||
|
||||
public static function parsePoliciesList($item) {
|
||||
$showToUsergroups = is_null(\nullIfBlank($item["show_to_usergroups"])) ? array() : explode(",", $item["show_to_usergroups"]);
|
||||
$hideToUsergroups = is_null(\nullIfBlank($item["hide_to_usergroups"])) ? array() : explode(",", $item["hide_to_usergroups"]);
|
||||
$showToUsers = is_null(\nullIfBlank($item["show_to_users"])) ? array() : explode(",", $item["show_to_users"]);
|
||||
$hideToUsers = is_null(\nullIfBlank($item["hide_to_users"])) ? array() : explode(",", $item["hide_to_users"]);
|
||||
|
||||
|
||||
return array(
|
||||
"G" => array("show" => $showToUsergroups, "hide" => $hideToUsergroups),
|
||||
"U" => array("show" => $showToUsers, "hide" => $hideToUsers)
|
||||
);
|
||||
}
|
||||
|
||||
public static function applyPolicies($item, $userName, $userGroup){
|
||||
|
||||
public static function applyPolicies($item, $userName, $userGroup) {
|
||||
$retData = array("G" => null, "U" => null);
|
||||
|
||||
|
||||
// PREPARAZIONE DELLE LISTE
|
||||
$parsedList = self::parsePoliciesList($item);
|
||||
$showToUsergroups = $parsedList["G"]["show"];
|
||||
$hideToUsergroups = $parsedList["G"]["hide"];
|
||||
$showToUsers = $parsedList["U"]["show"];
|
||||
$hideToUsers = $parsedList["U"]["hide"];
|
||||
|
||||
|
||||
//***** CONTROLLO GRUPPO *****//
|
||||
if(is_null($retData["G"]) && count($showToUsergroups)>0){
|
||||
if (is_null($retData["G"]) && count($showToUsergroups) > 0) {
|
||||
// REPORT/PARAMETRO DICHIARATO 'VISIBILE' PER GRUPPI SPECIFICI
|
||||
if(in_array($userGroup, $showToUsergroups)){
|
||||
if (in_array($userGroup, $showToUsergroups)) {
|
||||
$retData["G"] = true;
|
||||
// IL GRUPPO CORRENTE E' INCLUSO NELLA LISTA
|
||||
} else if(!in_array($userGroup, $showToUsergroups)){
|
||||
} else if (!in_array($userGroup, $showToUsergroups)) {
|
||||
$retData["G"] = false;
|
||||
// IL GRUPPO CORRENTE NON E' INCLUSO NELLA LISTA
|
||||
}
|
||||
}
|
||||
|
||||
if(is_null($retData["G"]) && count($hideToUsergroups)>0){
|
||||
if (is_null($retData["G"]) && count($hideToUsergroups) > 0) {
|
||||
// REPORT/PARAMETRO DICHIARATO 'NASCOSTO' PER GRUPPI SPECIFICI
|
||||
if(in_array($userGroup, $hideToUsergroups)){
|
||||
if (in_array($userGroup, $hideToUsergroups)) {
|
||||
$retData["G"] = false; // IL GRUPPO CORRENTE E' INCLUSO NELLA LISTA
|
||||
}
|
||||
}
|
||||
|
||||
//***** CONTROLLO SPECIFICO UTENTE *****//
|
||||
if(is_null($retData["U"]) && count($showToUsers)>0){
|
||||
if (is_null($retData["U"]) && count($showToUsers) > 0) {
|
||||
// REPORT/PARAMETRO DICHIARATO 'VISIBILE' PER UTENTI SPECIFICI
|
||||
if(in_array($userName, $showToUsers)){
|
||||
if (in_array($userName, $showToUsers)) {
|
||||
// L'UTENTE CORRENTE E' INCLUSO NELLA LISTA
|
||||
$retData["U"] = true;
|
||||
} else if(!in_array($userName, $showToUsers) && is_null($retData["G"])){
|
||||
} else if (!in_array($userName, $showToUsers) && is_null($retData["G"])) {
|
||||
// L'UTENTE CORRENTE NON E' INCLUSO NELLA LISTA, E NON E' ESPLICITAMENTE INCLUSO/ESCLUSO NELLA POLICY 'GRUPPO'
|
||||
$retData["U"] = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(is_null($retData["U"]) && count($hideToUsers)>0){
|
||||
if (is_null($retData["U"]) && count($hideToUsers) > 0) {
|
||||
// REPORT/PARAMETRO DICHIARATO 'NASCOSTO' PER UTENTI SPECIFICI
|
||||
if(in_array($userName, $hideToUsers)){ // L'UTENTE CORRENTE E' INCLUSO NELLA LISTA
|
||||
if (in_array($userName, $hideToUsers)) { // L'UTENTE CORRENTE E' INCLUSO NELLA LISTA
|
||||
$retData["U"] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $retData;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Report;
|
||||
class Parameter{
|
||||
class Parameter {
|
||||
const TYPE_TEXT = "text";
|
||||
const TYPE_DATESTATIC = "date_static";
|
||||
const TYPE_DATEDYNAMIC = "date_dynamic";
|
||||
@@ -8,7 +9,7 @@ class Parameter{
|
||||
const TYPE_MONOSELECT = "monoselect_sql";
|
||||
const TYPE_WHERE = "where_static";
|
||||
const TYPE_IMAGE = "image";
|
||||
|
||||
|
||||
public $expression = null;
|
||||
public $name = null;
|
||||
public $report_id = null;
|
||||
@@ -25,14 +26,14 @@ class Parameter{
|
||||
public $hide_to_usergroups = null;
|
||||
public $show_to_users = null;
|
||||
public $hide_to_users = null;
|
||||
|
||||
|
||||
public $sys_param = null;
|
||||
|
||||
|
||||
public $dependenceChildren = null;
|
||||
public $dependenceParents = null;
|
||||
|
||||
function __construct($array = null){
|
||||
if(!is_null($array)){
|
||||
|
||||
function __construct($array = null) {
|
||||
if (!is_null($array)) {
|
||||
$this->expression = $array["expression"];
|
||||
$this->name = $array["name"];
|
||||
$this->report_id = $array["report_id"];
|
||||
@@ -45,50 +46,50 @@ class Parameter{
|
||||
$this->field_to_search = nullIfBlank($array["field_to_search"]);
|
||||
$this->obbl_groups = nullIfBlank($array["obbl_groups"]);
|
||||
$this->ordine = $array["ordine"];
|
||||
|
||||
|
||||
$this->show_to_usergroups = nullIfBlank($array["show_to_usergroups"]);
|
||||
$this->hide_to_usergroups = nullIfBlank($array["hide_to_usergroups"]);
|
||||
$this->show_to_users = nullIfBlank($array["show_to_users"]);
|
||||
$this->hide_to_users = nullIfBlank($array["hide_to_users"]);
|
||||
|
||||
|
||||
$this->sys_param = $array["sys_param"];
|
||||
|
||||
|
||||
$this->dependenceChildren = $this->get_dependenceChildren();
|
||||
$this->dependenceParents = $this->get_dependenceParents();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function get_dependenceChildren(){
|
||||
|
||||
private function get_dependenceChildren() {
|
||||
$Query = new \Query(self::get_sql_dependenceChildren());
|
||||
$Query->setVar("report_id", $this->report_id)
|
||||
->setVar("parameter_name", $this->name);
|
||||
->setVar("parameter_name", $this->name);
|
||||
$Ret = $Query->toRet()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$arr_rows = $Ret->get_data();
|
||||
$arr_dependenceChildren = array();
|
||||
foreach($arr_rows as $row){
|
||||
if(strpos(base64_decode($row["expression"]), "[[".$this->name."]]") !== false){
|
||||
foreach ($arr_rows as $row) {
|
||||
if (strpos(base64_decode($row["expression"]), "[[" . $this->name . "]]") !== false) {
|
||||
$arr_dependenceChildren[] = $row["name"];
|
||||
}
|
||||
}
|
||||
return count($arr_dependenceChildren)>0 ? $arr_dependenceChildren : null;
|
||||
return count($arr_dependenceChildren) > 0 ? $arr_dependenceChildren : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function get_dependenceParents(){
|
||||
|
||||
private function get_dependenceParents() {
|
||||
$expression = $this->get_expression();
|
||||
if(!is_null($expression)){
|
||||
if (!is_null($expression)) {
|
||||
preg_match_all("/\[\[.*?\]\]/", $expression, $m);
|
||||
$arr_parts = $m[0];
|
||||
if(count($arr_parts)>0){
|
||||
if (count($arr_parts) > 0) {
|
||||
$arr_parents = array();
|
||||
foreach($arr_parts as $part){
|
||||
foreach ($arr_parts as $part) {
|
||||
$parent_pname = str_replace("[[", "", str_replace("]]", "", $part)); // PRENDE NOME PARAMETRO
|
||||
if(!in_array($parent_pname, $arr_parents)){
|
||||
if (!in_array($parent_pname, $arr_parents)) {
|
||||
$arr_parents[] = $parent_pname;
|
||||
}
|
||||
}
|
||||
@@ -97,179 +98,180 @@ class Parameter{
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function load_from_db($reportId, $parameterName){
|
||||
|
||||
public function load_from_db($reportId, $parameterName) {
|
||||
$sql = "SELECT *, CONVERT(TEXT, expression) AS expression, parameter_name AS name
|
||||
FROM wtb_jrepr
|
||||
WHERE report_id = '[report_id]' AND
|
||||
parameter_name = '[parameter_name]'";
|
||||
$Query = new \Query($sql);
|
||||
$Ret = $Query->setVar("report_id", $reportId)->setVar("parameter_name", $parameterName)->toRet()->firstRow()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$result = $Ret->get_data();
|
||||
if(!is_null($result)){
|
||||
if (!is_null($result)) {
|
||||
$result["sys_param"] = false; // fittizio, ininfluente in questa posizione
|
||||
return $this->__construct($result);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function process_groovyExpression($value, $class){
|
||||
if($class=="java.lang.String"){
|
||||
|
||||
public static function process_groovyExpression($value, $class) {
|
||||
if ($class == "java.lang.String") {
|
||||
return trim($value, "\"");
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function get_tipo(){
|
||||
|
||||
public function get_tipo() {
|
||||
return $this->tipo;
|
||||
}
|
||||
|
||||
public function get_expression(){
|
||||
if(!is_null($this->expression) && !$this->is_image()){
|
||||
|
||||
public function get_expression() {
|
||||
if (!is_null($this->expression) && !$this->is_image()) {
|
||||
return base64_decode($this->expression);
|
||||
}
|
||||
return $this->expression;
|
||||
}
|
||||
|
||||
public function set_expression($value){
|
||||
|
||||
public function set_expression($value) {
|
||||
$this->expression = !$this->is_image() ? base64_encode($value) : $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get_fieldToSearch(){
|
||||
|
||||
public function get_fieldToSearch() {
|
||||
return $this->field_to_search;
|
||||
}
|
||||
|
||||
public function is_sysParam(){
|
||||
|
||||
public function is_sysParam() {
|
||||
return $this->sys_param;
|
||||
}
|
||||
|
||||
public function is_disabled(){
|
||||
|
||||
public function is_disabled() {
|
||||
return \boolValue($this->flag_disabled);
|
||||
}
|
||||
|
||||
private function process_value_dateStatic($value){
|
||||
if(strlen($value)>0){
|
||||
try{
|
||||
|
||||
private function process_value_dateStatic($value) {
|
||||
if (strlen($value) > 0) {
|
||||
try {
|
||||
return date($value);
|
||||
} catch(Exception $e){
|
||||
} catch (Exception $e) {
|
||||
return "-1";
|
||||
}
|
||||
}
|
||||
return ""; // strftime("%d/%m/%Y");
|
||||
}
|
||||
|
||||
public function is_weekPicker(){
|
||||
|
||||
public function is_weekPicker() {
|
||||
return substr($this->get_expression(), 0, 4) == "WEEK";
|
||||
}
|
||||
|
||||
public function process_value_dateDynamic($value, $format = "d/m/Y"){
|
||||
if($this->is_weekPicker()){
|
||||
|
||||
public function process_value_dateDynamic($value, $format = "d/m/Y") {
|
||||
if ($this->is_weekPicker()) {
|
||||
preg_match('#\((.*?)\)#', $value, $m); // estrae il valore dentro le parentesi
|
||||
$value = nullIfBlank($m[1]);
|
||||
}
|
||||
|
||||
if(!is_null($value) && strlen(trim($value))>0){
|
||||
try{
|
||||
|
||||
if (!is_null($value) && strlen(trim($value)) > 0) {
|
||||
try {
|
||||
$d = new \DateTime($value);
|
||||
return $d->format($format);
|
||||
} catch(Exception $e){
|
||||
} catch (Exception $e) {
|
||||
return "01/01/1970";
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$d = new \DateTime();
|
||||
return $d->format($format);
|
||||
}
|
||||
}
|
||||
|
||||
public function load_expressionResult(){
|
||||
|
||||
public function load_expressionResult() {
|
||||
$Ret = new \Ret;
|
||||
|
||||
|
||||
$expression = $this->get_expression();
|
||||
if(!is_null($expression)){
|
||||
if($this->is_dateStatic()){
|
||||
if (!is_null($expression)) {
|
||||
if ($this->is_dateStatic()) {
|
||||
$Ret->set_data($this->process_value_dateStatic($expression));
|
||||
|
||||
} else if($this->is_dateDynamic()){
|
||||
|
||||
} else if ($this->is_dateDynamic()) {
|
||||
$sel_arr = explode("<br />", nl2br($expression));
|
||||
|
||||
if(count($sel_arr)==1){ // DATA SINGOLA
|
||||
|
||||
if (count($sel_arr) == 1) { // DATA SINGOLA
|
||||
$Ret->set_data($this->process_value_dateDynamic($expression));
|
||||
|
||||
} else if(count($sel_arr)==2){ // INTERVALLO DI 2 DATE
|
||||
|
||||
} else if (count($sel_arr) == 2) { // INTERVALLO DI 2 DATE
|
||||
$data1 = $data2 = null;
|
||||
if(strpos($sel_arr[0], "|") !== false){
|
||||
if (strpos($sel_arr[0], "|") !== false) {
|
||||
list($data1, $descrVal1) = explode("|", $sel_arr[0]);
|
||||
} else{
|
||||
} else {
|
||||
$data1 = trim($sel_arr[0]);
|
||||
}
|
||||
if(strpos($sel_arr[1], '|') !== false){
|
||||
if (strpos($sel_arr[1], '|') !== false) {
|
||||
list($data2, $descrVal2) = explode("|", $sel_arr[1]);
|
||||
} else{
|
||||
} else {
|
||||
$data2 = trim($sel_arr[1]);
|
||||
}
|
||||
|
||||
|
||||
$Ret->set_data(array(
|
||||
$this->process_value_dateDynamic($data1),
|
||||
$this->process_value_dateDynamic($data2)
|
||||
));
|
||||
} else{
|
||||
));
|
||||
} else {
|
||||
$Ret->set_error("Valori dateDynamic non validi");
|
||||
}
|
||||
|
||||
} else if($this->is_text()){
|
||||
|
||||
} else if ($this->is_text()) {
|
||||
$sel_arr = explode("<br />", nl2br($expression));
|
||||
if(count($sel_arr)>1){
|
||||
if (count($sel_arr) > 1) {
|
||||
$result = array();
|
||||
foreach($sel_arr as $sel_opt){
|
||||
if(strpos($sel_opt, '|') !== false){
|
||||
foreach ($sel_arr as $sel_opt) {
|
||||
if (strpos($sel_opt, '|') !== false) {
|
||||
list($val, $descrVal) = explode("|", $sel_opt);
|
||||
} else{
|
||||
} else {
|
||||
$val = $descrVal = $sel_opt;
|
||||
}
|
||||
$val = $this->get_phpvar_value($val);
|
||||
$result[] = array("value" => $val, "descr" => $descrVal);
|
||||
}
|
||||
$Ret->set_data($result);
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_data($this->get_phpvar_value($expression));
|
||||
}
|
||||
|
||||
} else if($this->is_whereCond()){
|
||||
|
||||
} else if ($this->is_whereCond()) {
|
||||
$sel_arr = explode("<br />", nl2br($expression));
|
||||
if(count($sel_arr)>1){
|
||||
if (count($sel_arr) > 1) {
|
||||
$result = array();
|
||||
foreach($sel_arr as $sel_opt){
|
||||
if(strpos($sel_opt, '|') !== false){
|
||||
foreach ($sel_arr as $sel_opt) {
|
||||
if (strpos($sel_opt, '|') !== false) {
|
||||
list($val, $descrVal) = explode("|", $sel_opt);
|
||||
} else{
|
||||
} else {
|
||||
$val = $descrVal = trim($sel_opt);
|
||||
}
|
||||
$val = $this->replace_sql_phpvars_to_value($val);
|
||||
$result[] = array("value" => $val, "descr" => $descrVal);
|
||||
}
|
||||
$Ret->set_data($result);
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$expression = $this->replace_sql_phpvars_to_value($expression);
|
||||
$Ret->set_data($expression);//$Ret->set_data($this->get_phpvar_value($expression));
|
||||
}
|
||||
|
||||
} else if($this->is_monoSelect()){
|
||||
|
||||
} else if ($this->is_monoSelect()) {
|
||||
$Ret = $this->processMonoselect($expression);
|
||||
|
||||
} else if($this->is_multiSelect()){
|
||||
|
||||
} else if ($this->is_multiSelect()) {
|
||||
$Ret = $this->processMultiselect($expression);
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_data($expression);
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
/*
|
||||
private function replaceSubstrIfStartsWith($haystack, $needle, $replaceWith){ // case insensitive
|
||||
if(\Utility\String::startsWith($haystack, $needle, false)){
|
||||
@@ -277,32 +279,32 @@ class Parameter{
|
||||
}
|
||||
return $haystack;
|
||||
}*/
|
||||
|
||||
public function processMultiselect($expression){
|
||||
|
||||
public function processMultiselect($expression) {
|
||||
$sql = $this->replace_sql_phpvars_to_value(str_replace("NOPREVIEW:", "", $expression));
|
||||
|
||||
|
||||
$GestSetup = new \GestSetup;
|
||||
$maxResults = $GestSetup->section("REPORT_AREA")->keySection("RESULT_LIMIT_MULTISELECT")->defaultValue(500)->asInt()->get();
|
||||
|
||||
|
||||
$arr_replacements = array(
|
||||
array("from" => "SELECT DISTINCT", "to" => "SELECT DISTINCT TOP {$maxResults}"),
|
||||
array("from" => "SELECT", "to" => "SELECT TOP {$maxResults}"),
|
||||
);
|
||||
|
||||
foreach($arr_replacements as $replacement){
|
||||
if(\Utility\Str::startsWith($sql, $replacement["from"], false)){
|
||||
$sql = $replacement["to"].substr(trim($sql), strlen($replacement["from"]));
|
||||
|
||||
foreach ($arr_replacements as $replacement) {
|
||||
if (\Utility\Str::startsWith($sql, $replacement["from"], false)) {
|
||||
$sql = $replacement["to"] . substr(trim($sql), strlen($replacement["from"]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$Query = new \Query;
|
||||
$Ret = $Query->setSql($sql)->toRet()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$rows = $Ret->get_data();
|
||||
foreach($rows as $i => $row){
|
||||
foreach($row as $key => $field){
|
||||
if($key != $this->name){
|
||||
foreach ($rows as $i => $row) {
|
||||
foreach ($row as $key => $field) {
|
||||
if ($key != $this->name) {
|
||||
$row[$key] = htmlentities($field);
|
||||
}
|
||||
}
|
||||
@@ -310,32 +312,32 @@ class Parameter{
|
||||
}
|
||||
$Ret->set_data($rows);
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function processMonoselect($expression){
|
||||
|
||||
public function processMonoselect($expression) {
|
||||
$expression = str_replace("NOPREVIEW:", "", $expression);
|
||||
$sql = $this->replace_sql_phpvars_to_value(str_replace("MONOSELECT:", "", $expression));
|
||||
|
||||
|
||||
$Query = new \Query($sql);
|
||||
$Ret = $Query->toRet()->date2ts()->execute();
|
||||
$retData = array();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$arr_rows = $Ret->get_data();
|
||||
if(count($arr_rows)>0){
|
||||
if(isset($arr_rows[0][$this->name])){
|
||||
if (count($arr_rows) > 0) {
|
||||
if (isset($arr_rows[0][$this->name])) {
|
||||
|
||||
// SELEZIONO NOME COLONNA DESCRITTIVA
|
||||
$descr_columnName = $this->name;
|
||||
foreach($arr_rows[0] as $key => $value){
|
||||
if($key!=$this->name){
|
||||
foreach ($arr_rows[0] as $key => $value) {
|
||||
if ($key != $this->name) {
|
||||
$descr_columnName = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($arr_rows as $row){
|
||||
|
||||
foreach ($arr_rows as $row) {
|
||||
$retData[] = array(
|
||||
"value" => $row[$this->name],
|
||||
"descr" => htmlentities($row[$descr_columnName])
|
||||
@@ -344,86 +346,86 @@ class Parameter{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $Ret->set_data($retData);
|
||||
}
|
||||
|
||||
public function replace_sql_phpvars_to_value($sql){
|
||||
|
||||
public function replace_sql_phpvars_to_value($sql) {
|
||||
preg_match_all('~{(.+?)}~', $sql, $m);
|
||||
$values = $m[1];
|
||||
foreach($values as $val){
|
||||
$varname = '{'.$val.'}';
|
||||
foreach ($values as $val) {
|
||||
$varname = '{' . $val . '}';
|
||||
$sql = str_replace($varname, $this->get_phpvar_value($val), $sql);
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
|
||||
private function get_phpvar_value($string){
|
||||
if(strlen(trim($string))>0){
|
||||
if(strpos($string, '$_SESSION[') !== false){ // PRENDE UNA VARIABILE DI SESSIONE
|
||||
|
||||
private function get_phpvar_value($string) {
|
||||
if (strlen(trim($string)) > 0) {
|
||||
if (strpos($string, '$_SESSION[') !== false) { // PRENDE UNA VARIABILE DI SESSIONE
|
||||
$string = str_replace('$_SESSION[', "", str_replace(']', "", $string));
|
||||
$string = str_replace('"', "", str_replace("'", "", $string));
|
||||
$string = $_SESSION[trim($string)];
|
||||
} else if($string{0}=="$"){ // PRENDE UNA VARIABILE DEL CODICE
|
||||
$string = substr($string, 1);
|
||||
$string = $GLOBALS[$string];
|
||||
} else if ($string{0} == "$") { // PRENDE UNA VARIABILE DEL CODICE
|
||||
$string = substr($string, 1);
|
||||
$string = $GLOBALS[$string];
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function is_text(){
|
||||
|
||||
public function is_text() {
|
||||
return !is_null($this->tipo) && $this->tipo == self::TYPE_TEXT;
|
||||
}
|
||||
|
||||
public function is_multiSelect(){
|
||||
|
||||
public function is_multiSelect() {
|
||||
return !is_null($this->tipo) && $this->tipo == self::TYPE_MULTISELECT;
|
||||
}
|
||||
|
||||
public function is_monoSelect(){
|
||||
|
||||
public function is_monoSelect() {
|
||||
return !is_null($this->tipo) && $this->tipo == self::TYPE_MONOSELECT;
|
||||
}
|
||||
|
||||
public function is_date(){
|
||||
|
||||
public function is_date() {
|
||||
return $this->is_dateStatic() || $this->is_dateDynamic();
|
||||
}
|
||||
|
||||
public function is_dateStatic(){
|
||||
|
||||
public function is_dateStatic() {
|
||||
return !is_null($this->tipo) && $this->tipo == self::TYPE_DATESTATIC;
|
||||
}
|
||||
|
||||
public function is_dateDynamic(){
|
||||
|
||||
public function is_dateDynamic() {
|
||||
return !is_null($this->tipo) && $this->tipo == self::TYPE_DATEDYNAMIC;
|
||||
}
|
||||
|
||||
public function is_whereCond(){
|
||||
|
||||
public function is_whereCond() {
|
||||
return !is_null($this->tipo) && $this->tipo == self::TYPE_WHERE;
|
||||
}
|
||||
|
||||
public function is_image(){
|
||||
|
||||
public function is_image() {
|
||||
return !is_null($this->tipo) && $this->tipo == self::TYPE_IMAGE;
|
||||
}
|
||||
|
||||
public function is_visible(){
|
||||
|
||||
public function is_visible() {
|
||||
return \boolValue($this->flag_visible);
|
||||
}
|
||||
|
||||
public function is_editable(){
|
||||
|
||||
public function is_editable() {
|
||||
return \boolValue($this->flag_editable);
|
||||
}
|
||||
|
||||
public function get_obblGroups(){
|
||||
|
||||
public function get_obblGroups() {
|
||||
return $this->obbl_groups;
|
||||
}
|
||||
|
||||
|
||||
// <editor-fold desc="SQL dependence-children" defaultstate="collapsed">
|
||||
private static function get_sql_dependenceChildren(){
|
||||
private static function get_sql_dependenceChildren() {
|
||||
return "SELECT CONVERT(TEXT, expression) AS expression,
|
||||
parameter_name AS name
|
||||
FROM wtb_jrepr
|
||||
WHERE report_id = [report_id] AND
|
||||
tipo IN ('".self::TYPE_MULTISELECT."', '".self::TYPE_MONOSELECT."', '".self::TYPE_TEXT."') AND
|
||||
tipo IN ('" . self::TYPE_MULTISELECT . "', '" . self::TYPE_MONOSELECT . "', '" . self::TYPE_TEXT . "') AND
|
||||
parameter_name <> '[parameter_name]' AND
|
||||
flag_disabled = 'N'";
|
||||
}
|
||||
|
||||
@@ -1,97 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Report\Processor;
|
||||
class DtbDocPdf extends \Report\Processor{
|
||||
class DtbDocPdf extends \Report\Processor {
|
||||
private $dataDoc = null;
|
||||
private $serDoc = null;
|
||||
private $numDoc = null;
|
||||
private $codAnag = null;
|
||||
private $codDtip = null;
|
||||
|
||||
public function __construct($key = null){
|
||||
if(!is_null($key)){
|
||||
|
||||
public function __construct($key = null) {
|
||||
if (!is_null($key)) {
|
||||
$this->setKeyDoc($key);
|
||||
}
|
||||
}
|
||||
|
||||
public function setKeyDoc($key){
|
||||
if(isset($key["data_doc"])){
|
||||
|
||||
public function setKeyDoc($key) {
|
||||
if (isset($key["data_doc"])) {
|
||||
$this->dataDoc($key["data_doc"]);
|
||||
}
|
||||
if(isset($key["ser_doc"])){
|
||||
if (isset($key["ser_doc"])) {
|
||||
$this->serDoc($key["ser_doc"]);
|
||||
}
|
||||
if(isset($key["num_doc"])){
|
||||
if (isset($key["num_doc"])) {
|
||||
$this->numDoc($key["num_doc"]);
|
||||
}
|
||||
if(isset($key["cod_anag"])){
|
||||
if (isset($key["cod_anag"])) {
|
||||
$this->codAnag($key["cod_anag"]);
|
||||
}
|
||||
if(isset($key["cod_dtip"])){
|
||||
if (isset($key["cod_dtip"])) {
|
||||
$this->codDtip($key["cod_dtip"]);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function dataDoc($v){
|
||||
|
||||
public function dataDoc($v) {
|
||||
$this->dataDoc = $v;
|
||||
return $this;
|
||||
}
|
||||
public function serDoc($v){
|
||||
|
||||
public function serDoc($v) {
|
||||
$this->serDoc = $v;
|
||||
return $this;
|
||||
}
|
||||
public function numDoc($v){
|
||||
|
||||
public function numDoc($v) {
|
||||
$this->numDoc = $v;
|
||||
return $this;
|
||||
}
|
||||
public function codAnag($v){
|
||||
|
||||
public function codAnag($v) {
|
||||
$this->codAnag = $v;
|
||||
return $this;
|
||||
}
|
||||
public function codDtip($v){
|
||||
|
||||
public function codDtip($v) {
|
||||
$this->codDtip = $v;
|
||||
return $this;
|
||||
}
|
||||
public function reportName($v){
|
||||
|
||||
public function reportName($v) {
|
||||
$this->setReport($v);
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function checkParameters(){
|
||||
|
||||
private function checkParameters() {
|
||||
return !is_null($this->dataDoc) && !is_null($this->serDoc) && !is_null($this->numDoc) && !is_null($this->codAnag) && !is_null($this->codDtip);
|
||||
}
|
||||
|
||||
private function process(){
|
||||
|
||||
private function process() {
|
||||
$Ret = new \Ret;
|
||||
if($this->checkParameters()){
|
||||
if ($this->checkParameters()) {
|
||||
$Ret = $this->processJasper();
|
||||
|
||||
} else{
|
||||
$Ret->set_error("I parametri Report\Processor\DtbDocPdf sono incompleti");
|
||||
|
||||
} else {
|
||||
$Ret->set_error("I parametri Report\Processor\DtbDocPdf sono incompleti");
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function backup(){
|
||||
|
||||
public function backup() {
|
||||
$Ret = $this->process();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$fileContent = $Ret->get_byte();
|
||||
|
||||
$DtbDocPdf = new \EntityItem("dtb_doc_pdf");
|
||||
$DtbDocPdf->insert()
|
||||
->setDate("dataDoc", $this->dataDoc)
|
||||
->set("numDoc", $this->numDoc)
|
||||
->set("serDoc", $this->serDoc)
|
||||
->set("codDtip", $this->codDtip)
|
||||
->set("codAnag", $this->codAnag)
|
||||
->set("utente", \User::get_current_username())
|
||||
->set("filesize", \Utility::blobSize($fileContent))
|
||||
->set("filecontent", base64_encode(\Utility\Compression\GZ::compress($fileContent)));
|
||||
->setDate("dataDoc", $this->dataDoc)
|
||||
->set("numDoc", $this->numDoc)
|
||||
->set("serDoc", $this->serDoc)
|
||||
->set("codDtip", $this->codDtip)
|
||||
->set("codAnag", $this->codAnag)
|
||||
->set("utente", \User::get_current_username())
|
||||
->set("filesize", \Utility::blobSize($fileContent))
|
||||
->set("filecontent", base64_encode(\Utility\Compression\GZ::compress($fileContent)));
|
||||
$Ret = $DtbDocPdf->send();
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,88 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace Report\Processor;
|
||||
class DtbOrdPdf extends \Report\Processor{
|
||||
class DtbOrdPdf extends \Report\Processor {
|
||||
private $gestione = null;
|
||||
private $dataOrd = null;
|
||||
private $numOrd = null;
|
||||
|
||||
//private $file = null;
|
||||
|
||||
public function __construct($key = null){
|
||||
if(!is_null($key)){
|
||||
|
||||
public function __construct($key = null) {
|
||||
if (!is_null($key)) {
|
||||
$this->setKeyDoc($key);
|
||||
}
|
||||
}
|
||||
|
||||
public function setKeyOrd($key){
|
||||
if(isset($key["gestione"])){
|
||||
|
||||
public function setKeyOrd($key) {
|
||||
if (isset($key["gestione"])) {
|
||||
$this->gestione($key["gestione"]);
|
||||
}
|
||||
if(isset($key["data_ord"])){
|
||||
if (isset($key["data_ord"])) {
|
||||
$this->dataOrd($key["data_ord"]);
|
||||
}
|
||||
if(isset($key["num_ord"])){
|
||||
if (isset($key["num_ord"])) {
|
||||
$this->numOrd($key["num_ord"]);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function gestione($v){
|
||||
|
||||
public function gestione($v) {
|
||||
$this->gestione = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function dataOrd($v){
|
||||
|
||||
public function dataOrd($v) {
|
||||
$this->dataOrd = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function numOrd($v){
|
||||
|
||||
public function numOrd($v) {
|
||||
$this->numOrd = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function reportName($v){
|
||||
|
||||
public function reportName($v) {
|
||||
$this->setReport($v);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*
|
||||
public function file($name, $content){
|
||||
$this->file = array("name" => $name, "content" => $content);
|
||||
return $this;
|
||||
}*/
|
||||
|
||||
private function checkParameters(){
|
||||
|
||||
private function checkParameters() {
|
||||
return !is_null($this->gestione) && !is_null($this->dataOrd) && !is_null($this->numOrd);
|
||||
}
|
||||
|
||||
private function process(){
|
||||
|
||||
private function process() {
|
||||
$Ret = new \Ret;
|
||||
if($this->checkParameters()){
|
||||
if ($this->checkParameters()) {
|
||||
$Ret = $this->processJasper();
|
||||
|
||||
} else{
|
||||
$Ret->set_error("I parametri Report\Processor\DtbOrdPdf sono incompleti");
|
||||
|
||||
} else {
|
||||
$Ret->set_error("I parametri Report\Processor\DtbOrdPdf sono incompleti");
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function backup(){
|
||||
|
||||
public function backup() {
|
||||
$Ret = $this->process();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$fileContent = $Ret->get_byte();
|
||||
|
||||
$DtbOrdPdf = new \EntityItem("dtb_ord_pdf");
|
||||
$DtbOrdPdf->insert()
|
||||
->set("gestione", $this->gestione)
|
||||
->setDate("dataOrd", $this->dataOrd)
|
||||
->set("numOrd", $this->numOrd)
|
||||
->set("utente", \User::get_current_username())
|
||||
->set("filesize", \Utility::blobSize($fileContent))
|
||||
->set("filecontent", base64_encode(\Utility\Compression\GZ::compress($fileContent)));
|
||||
->set("gestione", $this->gestione)
|
||||
->setDate("dataOrd", $this->dataOrd)
|
||||
->set("numOrd", $this->numOrd)
|
||||
->set("utente", \User::get_current_username())
|
||||
->set("filesize", \Utility::blobSize($fileContent))
|
||||
->set("filecontent", base64_encode(\Utility\Compression\GZ::compress($fileContent)));
|
||||
$Ret = $DtbOrdPdf->send();
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,251 +1,252 @@
|
||||
<?php
|
||||
|
||||
namespace Report;
|
||||
class Processor{
|
||||
class Processor {
|
||||
private $Report = null;
|
||||
private $arr_params = array();
|
||||
private $arr_whereCond = array();
|
||||
|
||||
public function __construct($input = null){
|
||||
|
||||
public function __construct($input = null) {
|
||||
return $this->setReport($input);
|
||||
}
|
||||
|
||||
public function setReport($input){
|
||||
if(is_string($input)){
|
||||
|
||||
public function setReport($input) {
|
||||
if (is_string($input)) {
|
||||
$this->Report = new \Report($input);
|
||||
} else{
|
||||
} else {
|
||||
$this->Report = $input;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addParam($name, $value){
|
||||
|
||||
public function addParam($name, $value) {
|
||||
$this->arr_params[] = array("name" => $name, "value" => $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addParamDate($name, $value){
|
||||
|
||||
public function addParamDate($name, $value) {
|
||||
return $this->addParam($name, \Utility\Date::format($value, "%Y/%m/%d"));
|
||||
}
|
||||
|
||||
public function add_whereCond($whereCond){
|
||||
|
||||
public function add_whereCond($whereCond) {
|
||||
$this->arr_whereCond[] = $whereCond;
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function set_monoSelect_value($Parameter, $value){
|
||||
|
||||
private function set_monoSelect_value($Parameter, $value) {
|
||||
$name = $Parameter->name;
|
||||
if($Parameter->is_sysParam()){
|
||||
if ($Parameter->is_sysParam()) {
|
||||
$this->addParam($name, $value);
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$campoSelect = $Parameter->campo_select;
|
||||
if(strlen($value)>0){
|
||||
if (strlen($value) > 0) {
|
||||
$arr_values = explode("|", $value);
|
||||
if(count($arr_values)>0){
|
||||
if(!is_null($campoSelect) && strlen(trim($campoSelect))>0){
|
||||
$this->add_whereCond($campoSelect." IN ('".implode("','", $arr_values)."')");
|
||||
if (count($arr_values) > 0) {
|
||||
if (!is_null($campoSelect) && strlen(trim($campoSelect)) > 0) {
|
||||
$this->add_whereCond($campoSelect . " IN ('" . implode("','", $arr_values) . "')");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function set_multiSelect_value($Parameter, $value){
|
||||
|
||||
private function set_multiSelect_value($Parameter, $value) {
|
||||
$name = $Parameter->name;
|
||||
$campoSelect = $Parameter->campo_select;
|
||||
if(strlen($value)>0){
|
||||
if($Parameter->is_sysParam()){ // NORMALMENTE QUESTA COMBINAZIONE NON E' USATA
|
||||
if (strlen($value) > 0) {
|
||||
if ($Parameter->is_sysParam()) { // NORMALMENTE QUESTA COMBINAZIONE NON E' USATA
|
||||
$this->addParam($name, $value);
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$arr_values = explode("|", $value);
|
||||
if(count($arr_values)>0){
|
||||
if(!is_null($campoSelect) && strlen(trim($campoSelect))>0){
|
||||
$this->add_whereCond($campoSelect." IN ('".implode("','", $arr_values)."')");
|
||||
if (count($arr_values) > 0) {
|
||||
if (!is_null($campoSelect) && strlen(trim($campoSelect)) > 0) {
|
||||
$this->add_whereCond($campoSelect . " IN ('" . implode("','", $arr_values) . "')");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if($Parameter->is_sysParam()){
|
||||
} else if ($Parameter->is_sysParam()) {
|
||||
$this->addParam($name, "");
|
||||
}
|
||||
}
|
||||
|
||||
private function set_date_value($Parameter, $value){
|
||||
|
||||
private function set_date_value($Parameter, $value) {
|
||||
$key = $Parameter->name;
|
||||
$p_campoSelect = $Parameter->campo_select;
|
||||
if(strlen($value)>0){
|
||||
if (strlen($value) > 0) {
|
||||
$value = strftime("%Y/%m/%d", \Utility\Date::strtotime($value, \Format::strtotimeDMY));
|
||||
if($Parameter->is_sysParam()){
|
||||
if ($Parameter->is_sysParam()) {
|
||||
$this->addParam($key, $value);
|
||||
} else{// verifica caso between
|
||||
if(!is_null($p_campoSelect) && strlen(trim($p_campoSelect))>0){
|
||||
$this->add_whereCond($p_campoSelect." = ".\Query::sqlValue($value));
|
||||
} else {// verifica caso between
|
||||
if (!is_null($p_campoSelect) && strlen(trim($p_campoSelect)) > 0) {
|
||||
$this->add_whereCond($p_campoSelect . " = " . \Query::sqlValue($value));
|
||||
}
|
||||
}
|
||||
|
||||
} else if($Parameter->is_sysParam()){
|
||||
|
||||
} else if ($Parameter->is_sysParam()) {
|
||||
$this->addParam($key, "");
|
||||
}
|
||||
}
|
||||
|
||||
private function set_text_value($Parameter, $p_value){
|
||||
|
||||
private function set_text_value($Parameter, $p_value) {
|
||||
$p_name = $Parameter->name;
|
||||
$p_campoSelect = $Parameter->campo_select;
|
||||
if(strlen($p_value)>0){
|
||||
if($Parameter->is_sysParam()){
|
||||
if (strlen($p_value) > 0) {
|
||||
if ($Parameter->is_sysParam()) {
|
||||
$this->addParam($p_name, $p_value);
|
||||
} else{
|
||||
if(!is_null($p_campoSelect) && strlen(trim($p_campoSelect))>0){
|
||||
$this->add_whereCond($p_campoSelect." = ".\Query::sqlValue($p_value));
|
||||
} else {
|
||||
if (!is_null($p_campoSelect) && strlen(trim($p_campoSelect)) > 0) {
|
||||
$this->add_whereCond($p_campoSelect . " = " . \Query::sqlValue($p_value));
|
||||
}
|
||||
}
|
||||
} else if($Parameter->is_sysParam()){
|
||||
} else if ($Parameter->is_sysParam()) {
|
||||
$this->addParam($p_name, "");
|
||||
}
|
||||
}
|
||||
|
||||
private function set_whereCond_value($Parameter, $value){
|
||||
if(strlen($value)>0){
|
||||
if(\Utility::isBase64Encoded($value)){
|
||||
|
||||
private function set_whereCond_value($Parameter, $value) {
|
||||
if (strlen($value) > 0) {
|
||||
if (\Utility::isBase64Encoded($value)) {
|
||||
$value = base64_decode($value);
|
||||
}
|
||||
$this->add_whereCond($value);
|
||||
}
|
||||
}
|
||||
|
||||
private function set_image_value($Parameter, $value){
|
||||
|
||||
private function set_image_value($Parameter, $value) {
|
||||
$key = $Parameter->name;
|
||||
if(!is_null($value)){
|
||||
if (!is_null($value)) {
|
||||
$parts = explode(",", $value);
|
||||
if(isset($parts[1])){
|
||||
if (isset($parts[1])) {
|
||||
$value = $parts[1];
|
||||
}
|
||||
}
|
||||
|
||||
if($Parameter->is_sysParam()){
|
||||
|
||||
if ($Parameter->is_sysParam()) {
|
||||
$this->addParam($key, \nullIfBlank($value));
|
||||
}
|
||||
}
|
||||
|
||||
private function check_subreports(){
|
||||
|
||||
private function check_subreports() {
|
||||
$arr_subreport = $this->Report->subreports;
|
||||
if(!is_null($arr_subreport)){
|
||||
foreach($arr_subreport as $subreport){
|
||||
if($subreport["setted"]==0){
|
||||
if (!is_null($arr_subreport)) {
|
||||
foreach ($arr_subreport as $subreport) {
|
||||
if ($subreport["setted"] == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function prepareFilter($filterData){
|
||||
|
||||
private function prepareFilter($filterData) {
|
||||
$Ret = new \Ret;
|
||||
if(!isset($filterData["SUBREPORT_DIR"])){
|
||||
if (!isset($filterData["SUBREPORT_DIR"])) {
|
||||
$filterData["SUBREPORT_DIR"] = "";
|
||||
}
|
||||
if(!isset($filterData["ROOT_DIR"])){
|
||||
if (!isset($filterData["ROOT_DIR"])) {
|
||||
$filterData["ROOT_DIR"] = "";
|
||||
}
|
||||
|
||||
if($this->check_subreports()===false){
|
||||
|
||||
if ($this->check_subreports() === false) {
|
||||
$Ret->set_error("Uno o più sottoreport non sono stati caricati");
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
|
||||
$arr_reportParam = $this->Report->get_parametersVisibleToThisUser();
|
||||
$arr_check_obblGroups = array();
|
||||
foreach($arr_reportParam as $Parameter){
|
||||
if(!is_null($Parameter->get_obblGroups())){
|
||||
foreach ($arr_reportParam as $Parameter) {
|
||||
if (!is_null($Parameter->get_obblGroups())) {
|
||||
$arr_check_obblGroups[] = (string)$Parameter->get_obblGroups();
|
||||
}
|
||||
}
|
||||
|
||||
foreach($arr_reportParam as $Parameter){
|
||||
|
||||
foreach ($arr_reportParam as $Parameter) {
|
||||
$key = $Parameter->name;
|
||||
$expression = $Parameter->get_expression();
|
||||
|
||||
if(!array_key_exists($key, $filterData) && !$Parameter->is_image()){
|
||||
|
||||
if (!array_key_exists($key, $filterData) && !$Parameter->is_image()) {
|
||||
$Ret->showError("Parametro \"{$key}\" non pervenuto");
|
||||
}
|
||||
|
||||
|
||||
$value = trim($filterData[$key]);
|
||||
|
||||
if($Parameter->is_multiSelect()){
|
||||
|
||||
if ($Parameter->is_multiSelect()) {
|
||||
$this->set_multiSelect_value($Parameter, $value);
|
||||
|
||||
} else if($Parameter->is_monoSelect()){
|
||||
|
||||
} else if ($Parameter->is_monoSelect()) {
|
||||
$this->set_monoSelect_value($Parameter, $value);
|
||||
|
||||
} else if($Parameter->is_date() && substr($expression, 0, 4) != "WEEK"){
|
||||
|
||||
} else if ($Parameter->is_date() && substr($expression, 0, 4) != "WEEK") {
|
||||
$this->set_date_value($Parameter, $value);
|
||||
|
||||
} else if($Parameter->is_text()){
|
||||
|
||||
} else if ($Parameter->is_text()) {
|
||||
$this->set_text_value($Parameter, $value);
|
||||
|
||||
} else if($Parameter->is_whereCond()){
|
||||
|
||||
} else if ($Parameter->is_whereCond()) {
|
||||
$this->set_whereCond_value($Parameter, $value);
|
||||
|
||||
} else if($Parameter->is_image()){
|
||||
|
||||
} else if ($Parameter->is_image()) {
|
||||
$this->set_image_value($Parameter, $value);
|
||||
}
|
||||
|
||||
if(!is_null($Parameter->get_obblGroups())){
|
||||
if(!is_null(nullIfBlank($value))){
|
||||
|
||||
if (!is_null($Parameter->get_obblGroups())) {
|
||||
if (!is_null(nullIfBlank($value))) {
|
||||
$arr_check_obblGroups = array_diff($arr_check_obblGroups, array((string)$Parameter->get_obblGroups()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(count($arr_check_obblGroups)>0){
|
||||
|
||||
if (count($arr_check_obblGroups) > 0) {
|
||||
$Ret->set_warning("Uno o più parametri obbligatori non sono stati compilati");
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function processJasper(){
|
||||
|
||||
public function processJasper() {
|
||||
$JP = new \JasperProcessor;
|
||||
$Ret = $JP->load($this->Report);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$JP->where($this->arr_whereCond)->params($this->arr_params);
|
||||
$Ret = $JP->run();
|
||||
}
|
||||
return $Ret->set_string(null)->set_data(null);
|
||||
}
|
||||
|
||||
public function processExcel(){
|
||||
|
||||
public function processExcel() {
|
||||
$QueryBuilder = new \Query($this->Report->queryString);
|
||||
foreach($this->arr_params as $param){
|
||||
foreach ($this->arr_params as $param) {
|
||||
$QueryBuilder->setVar($param["name"], $param["value"]);
|
||||
}
|
||||
foreach($this->arr_whereCond as $whereCond){
|
||||
foreach ($this->arr_whereCond as $whereCond) {
|
||||
$QueryBuilder->where($whereCond);
|
||||
}
|
||||
|
||||
|
||||
$SqlToExcel = new \IMSApi\SqlToExcel;
|
||||
return $SqlToExcel->setSql($QueryBuilder)->send();
|
||||
}
|
||||
|
||||
public function run($filterData, $format){
|
||||
|
||||
public function run($filterData, $format) {
|
||||
$Ret = new \Ret();
|
||||
if($this->Report->is_loaded()){
|
||||
if ($this->Report->is_loaded()) {
|
||||
$Ret = $this->prepareFilter($filterData);
|
||||
if($Ret->is_OK()){
|
||||
if($format== \Format::PDF){
|
||||
if ($Ret->is_OK()) {
|
||||
if ($format == \Format::PDF) {
|
||||
$Ret = $this->processJasper();
|
||||
|
||||
} else if($format== \Format::EXCEL){
|
||||
} else if ($format == \Format::EXCEL) {
|
||||
$Ret = $this->processExcel();
|
||||
|
||||
} else{
|
||||
$Ret->set_error("Formato export report non supportato (".$format.")");
|
||||
} else {
|
||||
$Ret->set_error("Formato export report non supportato (" . $format . ")");
|
||||
}
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_error("Report non caricato");
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ require "Report.Functions.class.php";
|
||||
require "Report.Parameter.class.php";
|
||||
require "Report.Processor.class.php";
|
||||
|
||||
class Report{
|
||||
class Report {
|
||||
// letti dal db
|
||||
public $id = null;
|
||||
|
||||
@@ -35,50 +35,50 @@ class Report{
|
||||
public $Parameters = null;
|
||||
|
||||
|
||||
function __construct($reportName = null, $loadParameters = true, $loadSubreports = true, $loadQueryInfo = true){
|
||||
if(!is_null($reportName)){
|
||||
function __construct($reportName = null, $loadParameters = true, $loadSubreports = true, $loadQueryInfo = true) {
|
||||
if (!is_null($reportName)) {
|
||||
$this->load_report($reportName, $loadParameters, $loadSubreports, $loadQueryInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public function load_report($reportName, $loadParameters = true, $loadSubreports = true, $loadQueryInfo = true){
|
||||
public function load_report($reportName, $loadParameters = true, $loadSubreports = true, $loadQueryInfo = true) {
|
||||
$Query = new \Query(self::get_sql_report());
|
||||
$Query->setVar("report_name", $reportName);
|
||||
$Ret = $Query->toRet()->firstRow()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$result = $Ret->get_data();
|
||||
if(is_null($result)){
|
||||
if (is_null($result)) {
|
||||
$Ret->set_errorCode(ErrorHandler::INVALID_REPORT, $reportName);
|
||||
}
|
||||
}
|
||||
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$this->id = $result["id"];
|
||||
$this->name = $reportName;
|
||||
$this->b64_jrxml = $result["b64_jrxml"];
|
||||
$this->title = $result["title"];
|
||||
$this->descrizione_gruppo = $result["descrizione_gruppo"];
|
||||
$this->note = $result["note"];
|
||||
$this->query = !is_null($result["b64_query"])? base64_decode($result["b64_query"]) : null;
|
||||
$this->query = !is_null($result["b64_query"]) ? base64_decode($result["b64_query"]) : null;
|
||||
$this->show_to_usergroups = nullIfBlank($result["show_to_usergroups"]);
|
||||
$this->hide_to_usergroups = nullIfBlank($result["hide_to_usergroups"]);
|
||||
$this->show_to_users = nullIfBlank($result["show_to_users"]);
|
||||
$this->hide_to_users = nullIfBlank($result["hide_to_users"]);
|
||||
}
|
||||
|
||||
if($Ret->is_OK() && $loadParameters){
|
||||
if ($Ret->is_OK() && $loadParameters) {
|
||||
$Ret = $this->load_parameters();
|
||||
}
|
||||
|
||||
if($Ret->is_OK() && $loadSubreports){
|
||||
if ($Ret->is_OK() && $loadSubreports) {
|
||||
$Ret = $this->load_subreports();
|
||||
}
|
||||
|
||||
if($Ret->is_OK() && $loadQueryInfo){
|
||||
if ($Ret->is_OK() && $loadQueryInfo) {
|
||||
$Ret = $this->load_queryInfo();
|
||||
}
|
||||
|
||||
if($Ret->is_KO()){
|
||||
if ($Ret->is_KO()) {
|
||||
$this->name = null;
|
||||
$this->errorText = $Ret->get_errorText();
|
||||
}
|
||||
@@ -90,23 +90,23 @@ class Report{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getTitle(){
|
||||
public function getTitle() {
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function getErrorText(){
|
||||
public function getErrorText() {
|
||||
return $this->errorText;
|
||||
}
|
||||
|
||||
public function is_loaded(){
|
||||
public function is_loaded() {
|
||||
return !(is_null($this->id) && is_null($this->name) && is_null($this->b64_jrxml));
|
||||
}
|
||||
|
||||
public static function getNameFromJrxml_static($jrxml){
|
||||
public static function getNameFromJrxml_static($jrxml) {
|
||||
$jrxml = \Utility::isBase64Encoded($jrxml) ? @base64_decode($jrxml) : $jrxml;
|
||||
if(!is_null($jrxml) && $jrxml!==false){
|
||||
if (!is_null($jrxml) && $jrxml !== false) {
|
||||
$simpleXML = @simplexml_load_string($jrxml);
|
||||
if(!is_null($simpleXML) && $simpleXML!==false){
|
||||
if (!is_null($simpleXML) && $simpleXML !== false) {
|
||||
return (string)$simpleXML->attributes()->name;
|
||||
}
|
||||
}
|
||||
@@ -114,29 +114,30 @@ class Report{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getNameFromJrxml(){
|
||||
public function getNameFromJrxml() {
|
||||
return self::getNameFromJrxml_static($this->b64_jrxml);
|
||||
}
|
||||
|
||||
private function load_queryInfo(){
|
||||
private function load_queryInfo() {
|
||||
$Ret = new Ret;
|
||||
$xml = $this->getJrxml();
|
||||
if(!is_null($xml)){
|
||||
if (!is_null($xml)) {
|
||||
$jrxml = simplexml_load_string($xml);
|
||||
$this->queryString = strtolower(str_replace("\t", " ", str_replace("\n", " ", trim((string)$jrxml->queryString))));
|
||||
$this->queryLang = strtolower(trim((string) $jrxml->queryString->attributes()->language));
|
||||
$this->queryLang = strtolower(trim((string)$jrxml->queryString->attributes()->language));
|
||||
}
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function getSubreports(){
|
||||
public function getSubreports() {
|
||||
return $this->subreports;
|
||||
}
|
||||
|
||||
public function prepareSubreportItem($item){
|
||||
public function prepareSubreportItem($item) {
|
||||
$content = \Utility::isBase64Encoded($item["b64_jasper"]) ? base64_decode($item["b64_jasper"]) : $item["b64_jasper"];
|
||||
$isJrxml = Utility\Str::is_xmlString($content);
|
||||
return array(
|
||||
"id" => $item["id"],
|
||||
"jasper_filename" => $item["jasper_filename"],
|
||||
"b64_jasper" => !is_null($content) ? base64_encode($content) : null,
|
||||
"format" => $isJrxml ? "JRXML" : "JASPER",
|
||||
@@ -144,18 +145,18 @@ class Report{
|
||||
);
|
||||
}
|
||||
|
||||
public function appendSubreport($item){
|
||||
public function appendSubreport($item) {
|
||||
$this->subreports[] = $this->prepareSubreportItem($item);
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function load_subreports(){
|
||||
private function load_subreports() {
|
||||
$Query = new \Query;
|
||||
$Query->select("jasper_filename", "b64_jasper")->from("wtb_jrepr_sub")->where("report_id", $this->id);
|
||||
$Query->select("id", "jasper_filename", "b64_jasper")->from("wtb_jrepr_sub")->where("report_id", $this->id);
|
||||
$Ret = $Query->toRet()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$this->subreports = $Ret->get_data();
|
||||
foreach($this->subreports as $i => $item){
|
||||
foreach ($this->subreports as $i => $item) {
|
||||
$this->subreports[$i] = $this->prepareSubreportItem($item);/*
|
||||
$isJrxml = Utility\Str::is_xmlString(base64_decode($item["b64_jasper"]));
|
||||
$item["format"] = $isJrxml ? "JRXML" : "JASPER";
|
||||
@@ -166,18 +167,18 @@ class Report{
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
private function load_parameters(){
|
||||
private function load_parameters() {
|
||||
$this->Parameters = array();
|
||||
$jrxml = simplexml_load_string($this->getJrxml());
|
||||
$Query = new \Query(self::get_sql_listParameters());
|
||||
$Query->setVar("report_id", $this->id);
|
||||
$Ret = $Query->toRet()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$arr_items = $Ret->get_data();
|
||||
foreach($arr_items as $item){
|
||||
foreach ($arr_items as $item) {
|
||||
$item["sys_param"] = false;
|
||||
foreach($jrxml->parameter as $parameter){ // CONTROLLO SE APPARTIENE AI PARAMETRI NATIVI DEL "JRXML"...
|
||||
if($item["name"] == (string)$parameter->attributes()->name){
|
||||
foreach ($jrxml->parameter as $parameter) { // CONTROLLO SE APPARTIENE AI PARAMETRI NATIVI DEL "JRXML"...
|
||||
if ($item["name"] == (string)$parameter->attributes()->name) {
|
||||
$item["sys_param"] = true;
|
||||
break;
|
||||
}
|
||||
@@ -189,10 +190,10 @@ class Report{
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function get_parameter($paramName){
|
||||
if(!is_null($this->Parameters)){
|
||||
foreach($this->Parameters as $Parameter){
|
||||
if($Parameter->name==$paramName){
|
||||
public function get_parameter($paramName) {
|
||||
if (!is_null($this->Parameters)) {
|
||||
foreach ($this->Parameters as $Parameter) {
|
||||
if ($Parameter->name == $paramName) {
|
||||
return $Parameter;
|
||||
}
|
||||
}
|
||||
@@ -200,46 +201,46 @@ class Report{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get_parameterExpression($paramName){
|
||||
public function get_parameterExpression($paramName) {
|
||||
$Parameter = $this->get_parameter($paramName);
|
||||
return !is_null($Parameter) ? $Parameter->get_expression() : null;
|
||||
}
|
||||
|
||||
public function getJrxml(){
|
||||
public function getJrxml() {
|
||||
return !is_null($this->b64_jrxml) ? base64_decode($this->b64_jrxml) : null;
|
||||
}
|
||||
|
||||
public function setJrxml($v){
|
||||
public function setJrxml($v) {
|
||||
$this->b64_jrxml = \Utility::isBase64Encoded($v) ? $v : base64_encode($v);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get_parametersVisibleToThisUser(){
|
||||
public function get_parametersVisibleToThisUser() {
|
||||
$retData = array();
|
||||
foreach($this->Parameters as $Parameter){
|
||||
if(!$Parameter->is_disabled()){
|
||||
foreach ($this->Parameters as $Parameter) {
|
||||
if (!$Parameter->is_disabled()) {
|
||||
$userGroup = \User::get_current_group();
|
||||
$userName = \User::get_current_username();
|
||||
|
||||
$itemPolicies = array("show_to_usergroups" => $Parameter->show_to_usergroups,
|
||||
"hide_to_usergroups" => $Parameter->hide_to_usergroups,
|
||||
"show_to_users" => $Parameter->show_to_users,
|
||||
"hide_to_users" => $Parameter->hide_to_users);
|
||||
"hide_to_usergroups" => $Parameter->hide_to_usergroups,
|
||||
"show_to_users" => $Parameter->show_to_users,
|
||||
"hide_to_users" => $Parameter->hide_to_users);
|
||||
|
||||
$policies = Report\Functions::applyPolicies($itemPolicies, $userName, $userGroup);
|
||||
|
||||
$flag_visibleToThisUser = true;
|
||||
if(is_null($policies["U"])){
|
||||
if(is_null($policies["G"])){
|
||||
if (is_null($policies["U"])) {
|
||||
if (is_null($policies["G"])) {
|
||||
$flag_visibleToThisUser = true;
|
||||
} else{
|
||||
} else {
|
||||
$flag_visibleToThisUser = $policies["G"];
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$flag_visibleToThisUser = $policies["U"];
|
||||
}
|
||||
|
||||
if($flag_visibleToThisUser){
|
||||
if ($flag_visibleToThisUser) {
|
||||
$retData[] = $Parameter;
|
||||
}
|
||||
}
|
||||
@@ -247,17 +248,17 @@ class Report{
|
||||
return $retData;
|
||||
}
|
||||
|
||||
public function process($filterData, $format = Format::PDF){
|
||||
public function process($filterData, $format = Format::PDF) {
|
||||
$Processor = new \Report\Processor($this);
|
||||
return $Processor->run($filterData, $format);
|
||||
}
|
||||
|
||||
public static function isReportObject($value){
|
||||
return !is_null($value) && gettype($value)=="object" && (get_class($value)=="Report" || is_subclass_of($value, "Report"));
|
||||
public static function isReportObject($value) {
|
||||
return !is_null($value) && gettype($value) == "object" && (get_class($value) == "Report" || is_subclass_of($value, "Report"));
|
||||
}
|
||||
|
||||
// <editor-fold desc="SQL report" defaultstate="collapsed">
|
||||
private static function get_sql_report(){
|
||||
private static function get_sql_report() {
|
||||
return "SELECT id,
|
||||
title,
|
||||
descrizione_gruppo,
|
||||
@@ -274,7 +275,7 @@ class Report{
|
||||
// </editor-fold>
|
||||
|
||||
// <editor-fold desc="SQL list-parameters" defaultstate="collapsed">
|
||||
private static function get_sql_listParameters(){
|
||||
private static function get_sql_listParameters() {
|
||||
return "SELECT CONVERT(TEXT, expression) AS expression,
|
||||
parameter_name AS name,
|
||||
report_id,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
class Rest{
|
||||
|
||||
class Rest {
|
||||
const GET = "GET";
|
||||
const POST = "POST";
|
||||
const PUT = "PUT";
|
||||
@@ -7,9 +8,9 @@ class Rest{
|
||||
const TEXTPLAIN = "TEXT";
|
||||
const APPLICATIONJSON = "JSON";
|
||||
const FORM = "FORM";
|
||||
|
||||
|
||||
public static $protocol = "http";
|
||||
|
||||
|
||||
private $endPoint = null;
|
||||
private $contentType = null;
|
||||
private $method = null;
|
||||
@@ -25,54 +26,54 @@ class Rest{
|
||||
private $isDownload = false;
|
||||
private $profileDb = null;
|
||||
private $timeout = 0;
|
||||
|
||||
|
||||
// <editor-fold desc="SETTERS" defaultstate="collapsed">
|
||||
public function post(){
|
||||
public function post() {
|
||||
return $this->method(self::POST);
|
||||
}
|
||||
|
||||
public function get(){
|
||||
|
||||
public function get() {
|
||||
return $this->method(self::GET);
|
||||
}
|
||||
|
||||
public function asText(){
|
||||
|
||||
public function asText() {
|
||||
return $this->contentType(self::TEXTPLAIN);
|
||||
}
|
||||
|
||||
public function asJson(){
|
||||
|
||||
public function asJson() {
|
||||
return $this->contentType(self::APPLICATIONJSON);
|
||||
}
|
||||
|
||||
public function asForm(){
|
||||
|
||||
public function asForm() {
|
||||
return $this->contentType(self::FORM);
|
||||
}
|
||||
|
||||
public function header($key, $value){
|
||||
|
||||
public function header($key, $value) {
|
||||
$this->headers[$key] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function headers($array){
|
||||
|
||||
public function headers($array) {
|
||||
$this->headers = array_merge($this->headers, $array);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function urlData($value){
|
||||
|
||||
public function urlData($value) {
|
||||
$this->urlData = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function body($value){
|
||||
|
||||
public function body($value) {
|
||||
$this->body = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function contentType($value){
|
||||
|
||||
public function contentType($value) {
|
||||
$this->contentType = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function endPoint($value){
|
||||
|
||||
public function endPoint($value) {
|
||||
$this->endPoint = $value;
|
||||
return $this;
|
||||
}
|
||||
@@ -80,8 +81,7 @@ class Rest{
|
||||
/**
|
||||
* @param null $profileDb
|
||||
*/
|
||||
public function setProfileDb($profileDb)
|
||||
{
|
||||
public function setProfileDb($profileDb) {
|
||||
$this->profileDb = $profileDb;
|
||||
return $this;
|
||||
}
|
||||
@@ -89,122 +89,122 @@ class Rest{
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getProfileDb()
|
||||
{
|
||||
public function getProfileDb() {
|
||||
return $this->profileDb;
|
||||
}
|
||||
|
||||
public function method($value){
|
||||
|
||||
public function method($value) {
|
||||
$this->method = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function serviceRootPath($value){
|
||||
|
||||
public function serviceRootPath($value) {
|
||||
$this->serviceRootPath = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function service($value){
|
||||
|
||||
public function service($value) {
|
||||
$this->service = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function authUsername($value){
|
||||
|
||||
public function authUsername($value) {
|
||||
$this->authUsername = $value;
|
||||
return $this->header("username", $value); /********* it memorizes in the object headers the key "username" with the value "$value" ***************/
|
||||
return $this->header("username", $value);
|
||||
/********* it memorizes in the object headers the key "username" with the value "$value" ***************/
|
||||
}
|
||||
|
||||
public function authPassword($value){
|
||||
|
||||
public function authPassword($value) {
|
||||
$this->authPassword = $value;
|
||||
return $this->header("password", $value);
|
||||
}
|
||||
|
||||
public function privateKey($value){
|
||||
|
||||
public function privateKey($value) {
|
||||
$this->privateKey = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function publicKey($value){
|
||||
|
||||
public function publicKey($value) {
|
||||
$this->publicKey = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function timeout($seconds){
|
||||
public function timeout($seconds) {
|
||||
$this->timeout = $seconds;
|
||||
return $this;
|
||||
}
|
||||
// </editor-fold>
|
||||
|
||||
// <editor-fold desc="GETTERS" defaultstate="collapsed">
|
||||
public function get_endPoint(){
|
||||
if(!is_null($this->endPoint)){
|
||||
return $this->endPoint;
|
||||
} else{
|
||||
public function get_endPoint() {
|
||||
if (!is_null($this->endPoint)) {
|
||||
return $this->endPoint;
|
||||
} else {
|
||||
$endPoint = null;
|
||||
if(file_exists("classes/Restful.config.json")){
|
||||
if (file_exists("classes/Restful.config.json")) {
|
||||
$restConfig = @json_decode(file_get_contents("classes/Restful.config.json"), true);
|
||||
if(!is_null($restConfig) && isset($restConfig["endPoint"])){
|
||||
$endPoint = Controller::endPointParsed($restConfig["endPoint"])."/";
|
||||
if (!is_null($restConfig) && isset($restConfig["endPoint"])) {
|
||||
$endPoint = Controller::endPointParsed($restConfig["endPoint"]) . "/";
|
||||
}
|
||||
}
|
||||
if(is_null($endPoint)){
|
||||
if(PVM::isDevClient()){
|
||||
$endPoint = Controller::endPointParsed("localhost:8080")."/";
|
||||
} else{
|
||||
$endPoint = Config::get_endPoint($this->profileDb)."/";
|
||||
if (is_null($endPoint)) {
|
||||
if (PVM::isDevClient()) {
|
||||
$endPoint = Controller::endPointParsed("localhost:8080") . "/";
|
||||
} else {
|
||||
$endPoint = Config::get_endPoint($this->profileDb) . "/";
|
||||
}
|
||||
}
|
||||
if(!is_null($this->serviceRootPath)){
|
||||
if (!is_null($this->serviceRootPath)) {
|
||||
$endPoint .= $this->serviceRootPath;
|
||||
}
|
||||
return $endPoint;
|
||||
}
|
||||
}
|
||||
|
||||
public static function get_endPointRemote(){
|
||||
|
||||
public static function get_endPointRemote() {
|
||||
$endPoint = null;
|
||||
if(file_exists("classes/Restful.config.json")){
|
||||
if (file_exists("classes/Restful.config.json")) {
|
||||
$restConfig = @json_decode(file_get_contents("classes/Restful.config.json"), true);
|
||||
if(!is_null($restConfig) && isset($restConfig["endPointRemote"])){
|
||||
$endPoint = Controller::endPointParsed($restConfig["endPointRemote"])."/";
|
||||
if (!is_null($restConfig) && isset($restConfig["endPointRemote"])) {
|
||||
$endPoint = Controller::endPointParsed($restConfig["endPointRemote"]) . "/";
|
||||
}
|
||||
}
|
||||
if(is_null($endPoint)){
|
||||
if(PVM::isDevClient()){
|
||||
$endPoint = Controller::endPointParsed("localhost:8080")."/";
|
||||
} else{
|
||||
$endPoint = Controller::endPointParsed(Config::get_endPointRemote())."/";
|
||||
if (is_null($endPoint)) {
|
||||
if (PVM::isDevClient()) {
|
||||
$endPoint = Controller::endPointParsed("localhost:8080") . "/";
|
||||
} else {
|
||||
$endPoint = Controller::endPointParsed(Config::get_endPointRemote()) . "/";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $endPoint;
|
||||
}
|
||||
|
||||
private static function get_profileDb(){
|
||||
|
||||
private static function get_profileDb() {
|
||||
return Config::get_dbNameWeb();
|
||||
}
|
||||
|
||||
|
||||
/******************************* SERVICE URL CONSTRUCTION **********************************************************/
|
||||
private function get_url(){
|
||||
private function get_url() {
|
||||
|
||||
$url = $this->get_endPoint().$this->service;
|
||||
$url = $this->get_endPoint() . $this->service;
|
||||
|
||||
$urlData = $this->urlData;
|
||||
if(!array_key_exists("profileDb", $urlData)){
|
||||
if (!array_key_exists("profileDb", $urlData)) {
|
||||
$profileDb = self::get_profileDb();
|
||||
if(!is_null($profileDb)){
|
||||
if (!is_null($profileDb)) {
|
||||
$urlData["profileDb"] = $profileDb;
|
||||
}
|
||||
}
|
||||
if(count($urlData)>0){
|
||||
if (count($urlData) > 0) {
|
||||
$url = sprintf("%s?%s", $url, http_build_query($urlData));
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
private function get_authCredentials(){
|
||||
|
||||
private function get_authCredentials() {
|
||||
return (!is_null($this->authUsername) && !is_null($this->authPassword)) ? array("username" => $this->authUsername, "password" => $this->authPassword) : null;
|
||||
}
|
||||
|
||||
@@ -212,15 +212,15 @@ class Rest{
|
||||
|
||||
|
||||
/************************************ CONNECTION BETWEEN PHP AND REST APIs *****************************************/
|
||||
public function send(){
|
||||
public function send() {
|
||||
$Ret = new Ret;
|
||||
$ret = array("headers" => null, "url" => null, "payload" => null, "http_code" => null, "body" => null);
|
||||
|
||||
try{
|
||||
|
||||
try {
|
||||
$url = $this->get_url();
|
||||
|
||||
/************************ creation of REQUEST OBJ ************************/
|
||||
switch($this->method) {
|
||||
switch ($this->method) {
|
||||
case self::POST:
|
||||
$req = \Httpful\Request::post($url);
|
||||
|
||||
@@ -236,124 +236,126 @@ class Rest{
|
||||
default:
|
||||
$req = \Httpful\Request::get($url);
|
||||
}
|
||||
|
||||
|
||||
$credentials = $this->get_authCredentials();
|
||||
if(!is_null($credentials)){
|
||||
if (!is_null($credentials)) {
|
||||
$req->authenticateWith($credentials["username"], $credentials["password"]);
|
||||
}
|
||||
|
||||
foreach($this->headers as $k => $v){
|
||||
|
||||
foreach ($this->headers as $k => $v) {
|
||||
$req->addHeader($k, $v);
|
||||
}
|
||||
/***************** here the body of Rest is passed to Request *******************/
|
||||
if(!is_null($this->publicKey)){
|
||||
if (!is_null($this->publicKey)) {
|
||||
$req->body(self::encryptRsa(json_encode($this->body), $this->publicKey));
|
||||
} else{
|
||||
} else {
|
||||
$req->body($this->body);
|
||||
}
|
||||
|
||||
if($this->contentType == self::APPLICATIONJSON){
|
||||
|
||||
if ($this->contentType == self::APPLICATIONJSON) {
|
||||
$req->sendsJson();
|
||||
} else if($this->contentType == self::FORM){
|
||||
} else if ($this->contentType == self::FORM) {
|
||||
$req->sendsType(Httpful\Mime::FORM);
|
||||
}
|
||||
|
||||
if($this->timeout > 0){
|
||||
|
||||
if ($this->timeout > 0) {
|
||||
$req->timeoutIn($this->timeout);
|
||||
}
|
||||
|
||||
$ret["headers"] = $req->headers;
|
||||
|
||||
/************************** if there's password, overwrites it with asterisks in ret *************** */
|
||||
if(isset($ret["headers"]["password"])){
|
||||
$ret["headers"]["password"] = str_pad("", strlen($ret["headers"]["password"]), "*");/****** last option: STR_PAD_RIGHT default */
|
||||
if (isset($ret["headers"]["password"])) {
|
||||
$ret["headers"]["password"] = str_pad("", strlen($ret["headers"]["password"]), "*");
|
||||
/****** last option: STR_PAD_RIGHT default */
|
||||
}
|
||||
|
||||
|
||||
$ret["payload"] = $req->payload;
|
||||
$ret["url"] = $url;
|
||||
/**************************** FINALLY SEND *******************************/
|
||||
$result = @$req->send(); /************* no parameters passed!!! ******************/
|
||||
|
||||
$result = @$req->send();
|
||||
/************* no parameters passed!!! ******************/
|
||||
|
||||
$httpCode = $result->code;
|
||||
$rawHeaders = $result->raw_headers;
|
||||
$ret["http_code"] = $httpCode;
|
||||
$ret["body"] = $result->raw_body;
|
||||
$Ret->set_number($httpCode);
|
||||
if($httpCode==200){
|
||||
if ($httpCode == 200) {
|
||||
$rawResponse = $result->raw_body;
|
||||
if(!is_null($this->privateKey)){
|
||||
if (!is_null($this->privateKey)) {
|
||||
$rawResponse = self::decryptRsa($rawResponse, $this->privateKey);
|
||||
}
|
||||
|
||||
if ($this->isDownload()){
|
||||
if ($this->isDownload()) {
|
||||
$retData = $rawResponse;
|
||||
$Ret->set_data($retData);
|
||||
}else{
|
||||
} else {
|
||||
$retData = json_decode($rawResponse, true);
|
||||
|
||||
if(!isset($retData[0])){
|
||||
if (!isset($retData[0])) {
|
||||
$retData = array($retData);
|
||||
}
|
||||
|
||||
if(isset($retData[0]["esito"])){
|
||||
if($retData[0]["esito"]==1){
|
||||
if (isset($retData[0]["esito"])) {
|
||||
if ($retData[0]["esito"] == 1) {
|
||||
$Ret->set_data($retData);
|
||||
} else{
|
||||
if(isset($retData[0]["errorMessage"])){
|
||||
} else {
|
||||
if (isset($retData[0]["errorMessage"])) {
|
||||
$Ret->set_error($retData[0]["errorMessage"]);
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_errorCode(ErrorHandler::EMSNOMESSAGE, $this->service);
|
||||
}
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_errorCode(ErrorHandler::EMSPARSE, $this->service);
|
||||
$suffixPath = "EMSPARSE-".User::get_current_username();
|
||||
$logPath = Utility::write_log("Parse error rest call: ".$result->raw_body, $suffixPath);
|
||||
if($logPath!==false && PVM::isDebugEnv()){
|
||||
$Ret->append_errorText("<br/><span class='small text-monospace'>Consulta <a href='{$logPath}' download>".basename($logPath)."</a></span>");
|
||||
$suffixPath = "EMSPARSE-" . User::get_current_username();
|
||||
$logPath = Utility::write_log("Parse error rest call: " . $result->raw_body, $suffixPath);
|
||||
if ($logPath !== false && PVM::isDebugEnv()) {
|
||||
$Ret->append_errorText("<br/><span class='small text-monospace'>Consulta <a href='{$logPath}' download>" . basename($logPath) . "</a></span>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if($httpCode==400){
|
||||
} else if ($httpCode == 400) {
|
||||
$errorLog = "400";
|
||||
$Ret->set_errorCode(ErrorHandler::EMSHTTP400, $this->service);
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$errorLog = $httpCode;
|
||||
$Ret->set_errorCode(ErrorHandler::EMSHTTP, $httpCode, $rawHeaders, $this->service);
|
||||
}
|
||||
|
||||
} catch(Httpful\Exception\ConnectionErrorException $e){
|
||||
|
||||
} catch (Httpful\Exception\ConnectionErrorException $e) {
|
||||
$errorLog = "EMSCONNECT";
|
||||
$Ret->set_errorCode(ErrorHandler::EMSCONNECT, $this->service)->append_errorText(" su <span class='text-monospace'>".$this->get_endPoint()."</span>");
|
||||
|
||||
} catch(Exception $e){
|
||||
$Ret->set_errorCode(ErrorHandler::EMSCONNECT, $this->service)->append_errorText(" su <span class='text-monospace'>" . $this->get_endPoint() . "</span>");
|
||||
|
||||
} catch (Exception $e) {
|
||||
$errorLog = "restCatchError";
|
||||
$Ret->set_error($e->getMessage());
|
||||
}
|
||||
|
||||
if(!$Ret->is_OK() && isset($errorLog) && !PVM::isDevClient()){ // SE NON VA A BUON FINE SCRIVE SEMPRE NEL LOG
|
||||
if(isset($this->body)){
|
||||
$fileName = "Payload_".$errorLog."_". blankIfNull($this->service)."_".User::get_current_username();
|
||||
|
||||
if (!$Ret->is_OK() && isset($errorLog) && !PVM::isDevClient()) { // SE NON VA A BUON FINE SCRIVE SEMPRE NEL LOG
|
||||
if (isset($this->body)) {
|
||||
$fileName = "Payload_" . $errorLog . "_" . blankIfNull($this->service) . "_" . User::get_current_username();
|
||||
@Utility::write_log($this->body, $fileName);
|
||||
}
|
||||
|
||||
$suffixPath = isset($suffixPath) ? $suffixPath : $errorLog."_". blankIfNull($this->service)."_".User::get_current_username();
|
||||
|
||||
$suffixPath = isset($suffixPath) ? $suffixPath : $errorLog . "_" . blankIfNull($this->service) . "_" . User::get_current_username();
|
||||
@Utility::write_log($ret, $suffixPath);
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
private static function encryptRsa($data, $pubKey){
|
||||
private static function encryptRsa($data, $pubKey) {
|
||||
$rsa = new Crypt_RSA;
|
||||
$rsa->loadKey($pubKey);
|
||||
$rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
|
||||
return base64_encode($rsa->encrypt($data));
|
||||
}
|
||||
|
||||
private static function decryptRsa($data, $privKey){
|
||||
|
||||
private static function decryptRsa($data, $privKey) {
|
||||
$rsa = new Crypt_RSA;
|
||||
$rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
|
||||
$ciphertext = base64_decode($data);
|
||||
@@ -364,8 +366,7 @@ class Rest{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDownload()
|
||||
{
|
||||
public function isDownload() {
|
||||
return $this->isDownload;
|
||||
}
|
||||
|
||||
@@ -373,8 +374,7 @@ class Rest{
|
||||
* @param bool $isDownload
|
||||
* @return Rest
|
||||
*/
|
||||
public function setIsDownload($isDownload)
|
||||
{
|
||||
public function setIsDownload($isDownload) {
|
||||
$this->isDownload = $isDownload;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Ret
|
||||
{
|
||||
class Ret {
|
||||
const OK = 1;
|
||||
const KO = -1;
|
||||
const WARN = 0;
|
||||
@@ -18,36 +17,30 @@ class Ret
|
||||
private $returnArray;
|
||||
private $Response;*/
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
$this->set_OK();
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
public function __toString() {
|
||||
return $this->toJson();
|
||||
}
|
||||
|
||||
/********************************* THIS IS THE CONNECTION BETWEEN PHP AND JS ***********************************/
|
||||
public function display()
|
||||
{
|
||||
public function display() {
|
||||
@header("Content-Type: " . \Mime::JSON);
|
||||
exit($this->toJson());
|
||||
}
|
||||
|
||||
public function showError($errorText = null)
|
||||
{
|
||||
public function showError($errorText = null) {
|
||||
$this->set_error($errorText)->display();
|
||||
}
|
||||
|
||||
public function errorAlert()
|
||||
{
|
||||
public function errorAlert() {
|
||||
$Alert = new BC\Alert;
|
||||
return $Alert->danger()->icon("exclamation-circle")->text($this->ret["errorText"]);
|
||||
}
|
||||
|
||||
private function getAlert($opt)
|
||||
{
|
||||
private function getAlert($opt) {
|
||||
$Alert = new BC\Alert;
|
||||
$Alert->danger()->text($this->ret["errorText"]);
|
||||
|
||||
@@ -70,49 +63,41 @@ class Ret
|
||||
return $Alert;
|
||||
}
|
||||
|
||||
public function showErrorAlert($opt = array())
|
||||
{
|
||||
public function showErrorAlert($opt = array()) {
|
||||
$Alert = $this->getAlert($opt);
|
||||
$Alert->show();
|
||||
}
|
||||
|
||||
public function showErrorTip($opt = array())
|
||||
{
|
||||
public function showErrorTip($opt = array()) {
|
||||
global $UserTips;
|
||||
$UserTips = new \PVM\Tips;
|
||||
$UserTips->append($this->getAlert($opt));
|
||||
}
|
||||
|
||||
public function jslog($value)
|
||||
{
|
||||
public function jslog($value) {
|
||||
if (!isset($this->ret["returnLog"])) {
|
||||
$this->ret["returnLog"] = array();
|
||||
}
|
||||
$this->ret["returnLog"][] = "PHP-LOG: " . (is_array($value) ? json_encode($value) : $value);
|
||||
}
|
||||
|
||||
public function set_warning($errorText = null, $errorTitle = null)
|
||||
{
|
||||
public function set_warning($errorText = null, $errorTitle = null) {
|
||||
return $this->set_WARN()->set_errorText($errorText)->set_errorTitle($errorTitle);
|
||||
}
|
||||
|
||||
public function set_OK()
|
||||
{
|
||||
public function set_OK() {
|
||||
return $this->set("returnId", self::OK);
|
||||
}
|
||||
|
||||
private function set_KO()
|
||||
{
|
||||
private function set_KO() {
|
||||
return $this->set("returnId", self::KO);
|
||||
}
|
||||
|
||||
public function set_WARN()
|
||||
{
|
||||
public function set_WARN() {
|
||||
return $this->set("returnId", self::WARN);
|
||||
}
|
||||
|
||||
public function prepend_errorText($errorText = "")
|
||||
{
|
||||
public function prepend_errorText($errorText = "") {
|
||||
if (!isset($this->ret["errorText"]) || is_null($this->ret["errorText"])) {
|
||||
$this->ret["errorText"] = "";
|
||||
}
|
||||
@@ -123,13 +108,11 @@ class Ret
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function append_error($errorText = "")
|
||||
{
|
||||
public function append_error($errorText = "") {
|
||||
return self::append_errorText($errorText);
|
||||
}
|
||||
|
||||
public function append_errorText($errorText = "")
|
||||
{
|
||||
public function append_errorText($errorText = "") {
|
||||
if (!isset($this->ret["errorText"]) || is_null($this->ret["errorText"])) {
|
||||
$this->ret["errorText"] = "";
|
||||
}
|
||||
@@ -137,8 +120,7 @@ class Ret
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function set_errorText($value = null)
|
||||
{
|
||||
private function set_errorText($value = null) {
|
||||
if (!is_null($value) || !isset($this->ret["errorText"])) {
|
||||
return $this->set("errorText", $value);
|
||||
}
|
||||
@@ -148,54 +130,45 @@ class Ret
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function get_error()
|
||||
{
|
||||
public function get_error() {
|
||||
return $this->get("errorText");
|
||||
}
|
||||
|
||||
public function get_errorText()
|
||||
{
|
||||
public function get_errorText() {
|
||||
return $this->get("errorText");
|
||||
}
|
||||
|
||||
public function set_error($text = null, $title = null)
|
||||
{
|
||||
public function set_error($text = null, $title = null) {
|
||||
return $this->set_KO()->set_errorText($text)->set_errorTitle($title);
|
||||
}
|
||||
|
||||
public function set_errorTitle($value = null)
|
||||
{
|
||||
public function set_errorTitle($value = null) {
|
||||
if (!is_null($value) || !isset($this->ret["errorTitle"])) {
|
||||
return $this->set("errorTitle", $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get_errorTitle()
|
||||
{
|
||||
public function get_errorTitle() {
|
||||
return $this->get("errorTitle");
|
||||
}
|
||||
|
||||
public function set_title($value = null)
|
||||
{
|
||||
public function set_title($value = null) {
|
||||
if (!is_null($value) || !isset($this->ret["title"])) {
|
||||
return $this->set("title", $value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get_title()
|
||||
{
|
||||
public function get_title() {
|
||||
return $this->get("title");
|
||||
}
|
||||
|
||||
public function set_warnCode($errorCode = null, $p1 = null, $p2 = null, $p3 = null)
|
||||
{
|
||||
public function set_warnCode($errorCode = null, $p1 = null, $p2 = null, $p3 = null) {
|
||||
return $this->set_errorCode($errorCode, $p1, $p2, $p3)->set_WARN();
|
||||
}
|
||||
|
||||
public function set_errorCode($errorCode = null, $p1 = null, $p2 = null, $p3 = null)
|
||||
{
|
||||
public function set_errorCode($errorCode = null, $p1 = null, $p2 = null, $p3 = null) {
|
||||
$this->set_KO();
|
||||
if (!is_null($errorCode) || !isset($this->ret["errorCode"])) {
|
||||
$this->set("errorCode", $errorCode)
|
||||
@@ -205,83 +178,67 @@ class Ret
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get_errorCode()
|
||||
{
|
||||
public function get_errorCode() {
|
||||
return $this->get("errorCode");
|
||||
}
|
||||
|
||||
public function set_string($value = null)
|
||||
{
|
||||
public function set_string($value = null) {
|
||||
return $this->set("returnString", $value);
|
||||
}
|
||||
|
||||
public function get_string()
|
||||
{
|
||||
public function get_string() {
|
||||
return $this->get("returnString");
|
||||
}
|
||||
|
||||
public function set_byte($value = null)
|
||||
{
|
||||
public function set_byte($value = null) {
|
||||
return $this->set("returnByte", $value);
|
||||
}
|
||||
|
||||
public function get_byte()
|
||||
{
|
||||
public function get_byte() {
|
||||
return $this->get("returnByte");
|
||||
}
|
||||
|
||||
public function set_boolean($value = null)
|
||||
{
|
||||
public function set_boolean($value = null) {
|
||||
return $this->set("returnBoolean", $value);
|
||||
}
|
||||
|
||||
public function get_boolean()
|
||||
{
|
||||
public function get_boolean() {
|
||||
return $this->get("returnBoolean");
|
||||
}
|
||||
|
||||
public function set_number($value = null)
|
||||
{
|
||||
public function set_number($value = null) {
|
||||
return $this->set("returnNumber", $value);
|
||||
}
|
||||
|
||||
public function get_number()
|
||||
{
|
||||
public function get_number() {
|
||||
return $this->get("returnNumber");
|
||||
}
|
||||
|
||||
public function set_data($value = null)
|
||||
{
|
||||
public function set_data($value = null) {
|
||||
return $this->set("returnData", $value);
|
||||
}
|
||||
|
||||
public function get_data()
|
||||
{
|
||||
public function get_data() {
|
||||
return $this->get("returnData");
|
||||
}
|
||||
|
||||
public function get_entity()
|
||||
{
|
||||
public function get_entity() {
|
||||
return $this->get("entityResult");
|
||||
}
|
||||
|
||||
public function set_array($value = null)
|
||||
{
|
||||
public function set_array($value = null) {
|
||||
return $this->set("returnArray", $value);
|
||||
}
|
||||
|
||||
public function get_array()
|
||||
{
|
||||
public function get_array() {
|
||||
return $this->get("returnArray");
|
||||
}
|
||||
|
||||
public function set_Response($value = null)
|
||||
{
|
||||
public function set_Response($value = null) {
|
||||
return $this->set("Response", $value);
|
||||
}
|
||||
|
||||
public function getDto()
|
||||
{
|
||||
public function getDto() {
|
||||
$data = $this->get_data();
|
||||
if (!empty($data)) {
|
||||
return $data[0]["dto"];
|
||||
@@ -289,50 +246,42 @@ class Ret
|
||||
return null;
|
||||
}
|
||||
|
||||
public function get_Response()
|
||||
{
|
||||
public function get_Response() {
|
||||
return $this->get("Response");
|
||||
}
|
||||
|
||||
public function get($propertyName)
|
||||
{
|
||||
public function get($propertyName) {
|
||||
//
|
||||
return isset($this->ret[$propertyName]) ? $this->ret[$propertyName] : null;
|
||||
}
|
||||
|
||||
|
||||
/* @ saves the passed value into ret property */
|
||||
public function set($propertyName, $value = null)
|
||||
{
|
||||
public function set($propertyName, $value = null) {
|
||||
$this->ret[$propertyName] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function remove($propertyName)
|
||||
{
|
||||
public function remove($propertyName) {
|
||||
if (array_key_exists($propertyName, $this->ret)) {
|
||||
unset($this->ret[$propertyName]);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function is_OK()
|
||||
{
|
||||
public function is_OK() {
|
||||
return $this->get("returnId") == self::OK;
|
||||
}
|
||||
|
||||
public function is_KO()
|
||||
{
|
||||
public function is_KO() {
|
||||
return $this->get("returnId") == self::KO;
|
||||
}
|
||||
|
||||
public function is_warning()
|
||||
{
|
||||
public function is_warning() {
|
||||
return $this->get("returnId") == self::WARN;
|
||||
}
|
||||
|
||||
public function toFile($filename = null)
|
||||
{
|
||||
public function toFile($filename = null) {
|
||||
if (is_null($filename)) {
|
||||
$filename = "Ret_" . rand(0, 10000);
|
||||
}
|
||||
@@ -341,8 +290,7 @@ class Ret
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function parse($arr_values = null)
|
||||
{
|
||||
public function parse($arr_values = null) {
|
||||
if (is_string($arr_values)) {
|
||||
$json = $arr_values;
|
||||
$arr_values = @json_decode($json, true);
|
||||
@@ -367,26 +315,22 @@ class Ret
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toJson()
|
||||
{
|
||||
public function toJson() {
|
||||
$Ret = clone $this;
|
||||
$Ret->remove("Response")->remove("Message");
|
||||
return Utility::json_encode($Ret->toArray());
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
public function toArray() {
|
||||
return $this->ret;
|
||||
}
|
||||
|
||||
public function displayDataAsJson()
|
||||
{
|
||||
public function displayDataAsJson() {
|
||||
@header("Content-Type: " . \Mime::JSON);
|
||||
exit($this->dataToJson());
|
||||
}
|
||||
|
||||
private function dataToJson()
|
||||
{
|
||||
private function dataToJson() {
|
||||
$Ret = clone $this;
|
||||
return Utility::json_encode($Ret->get_data());
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
class SignupMode {
|
||||
const MODE_MAILONLY = "MAILONLY";
|
||||
const MODE_CODANAG_PARTIVA = "CODANAG_PARTIVA";
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
<?php
|
||||
class Sqlsrv{
|
||||
|
||||
class Sqlsrv {
|
||||
private $hostName = null;
|
||||
private $userName = null;
|
||||
private $password = null;
|
||||
private $dbName = null;
|
||||
|
||||
|
||||
private $Link_ID = 0;
|
||||
private $Query_ID = 0;
|
||||
private $Record = array();
|
||||
public $Row;
|
||||
public $Error_message = null;
|
||||
|
||||
public function __construct($settings = null){
|
||||
if(!is_null($settings)){
|
||||
|
||||
public function __construct($settings = null) {
|
||||
if (!is_null($settings)) {
|
||||
$this->hostName = $settings["hostName"];
|
||||
$this->userName = $settings["userName"];
|
||||
$this->password = $settings["password"];
|
||||
@@ -20,58 +21,57 @@ class Sqlsrv{
|
||||
}
|
||||
}
|
||||
|
||||
private function close(){
|
||||
private function close() {
|
||||
$this->connection = null;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
public function __destruct() {
|
||||
$this->close();
|
||||
}
|
||||
|
||||
private function connect(){
|
||||
if($this->Link_ID==0){
|
||||
$connectionInfo = array("Database" => $this->dbName,
|
||||
"UID" => $this->userName,
|
||||
"PWD" => $this->password,
|
||||
"ReturnDatesAsStrings" => true,
|
||||
"CharacterSet" => "UTF-8");
|
||||
|
||||
private function connect() {
|
||||
if ($this->Link_ID == 0) {
|
||||
$connectionInfo = array("Database" => $this->dbName,
|
||||
"UID" => $this->userName,
|
||||
"PWD" => $this->password,
|
||||
"ReturnDatesAsStrings" => true,
|
||||
"CharacterSet" => "UTF-8");
|
||||
|
||||
$hostname = str_replace(":", ", ", $this->hostName);
|
||||
$this->Link_ID = sqlsrv_connect($hostname, $connectionInfo);
|
||||
if(!$this->Link_ID){
|
||||
if (!$this->Link_ID) {
|
||||
$errorMessage = "";
|
||||
$errors = sqlsrv_errors();
|
||||
foreach($errors as $error){
|
||||
$errorMessage.= "SQLSTATE: ".$error["SQLSTATE"]."<br/>";
|
||||
$errorMessage.= "Code: ".$error["code"]."<br/>";
|
||||
$errorMessage.= "Message: ".$error["message"]."<br/><br/>";
|
||||
foreach ($errors as $error) {
|
||||
$errorMessage .= "SQLSTATE: " . $error["SQLSTATE"] . "<br/>";
|
||||
$errorMessage .= "Code: " . $error["code"] . "<br/>";
|
||||
$errorMessage .= "Message: " . $error["message"] . "<br/><br/>";
|
||||
}
|
||||
|
||||
$this->Error_message = "Connessione su database host ".$this->hostName." fallita";
|
||||
|
||||
$this->Error_message = "Connessione su database host " . $this->hostName . " fallita";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!sqlsrv_query($this->Link_ID, sprintf("use %s", $this->dbName))){
|
||||
$this->Error_message = "Database ".$this->dbName." non disponibile";
|
||||
|
||||
if (!sqlsrv_query($this->Link_ID, sprintf("use %s", $this->dbName))) {
|
||||
$this->Error_message = "Database " . $this->dbName . " non disponibile";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function query($sql, $params = array()){
|
||||
public function query($sql, $params = array()) {
|
||||
$options = array("Scrollable" => SQLSRV_CURSOR_KEYSET);
|
||||
if($this->connect()){
|
||||
if ($this->connect()) {
|
||||
$this->Query_ID = sqlsrv_query($this->Link_ID, $sql, $params, $options);
|
||||
$this->Row = 0;
|
||||
if(!$this->Query_ID){
|
||||
if (!$this->Query_ID) {
|
||||
$this->Error_message = "";
|
||||
if(!is_null($errors = sqlsrv_errors())){
|
||||
foreach($errors as $error){
|
||||
$this->Error_message .= "SQLSTATE: ".$error["SQLSTATE"]." - ";
|
||||
$this->Error_message .= "code: ".$error["code"]." - ";
|
||||
$this->Error_message .= "message: ".$error["message"];
|
||||
if (!is_null($errors = sqlsrv_errors())) {
|
||||
foreach ($errors as $error) {
|
||||
$this->Error_message .= "SQLSTATE: " . $error["SQLSTATE"] . " - ";
|
||||
$this->Error_message .= "code: " . $error["code"] . " - ";
|
||||
$this->Error_message .= "message: " . $error["message"];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,15 +79,15 @@ class Sqlsrv{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function begin_transaction(){ //TODO
|
||||
|
||||
public function begin_transaction() { //TODO
|
||||
/*
|
||||
$this->connect();
|
||||
$result = @mssql_query("BEGIN TRAN");
|
||||
return !($result===false);*/
|
||||
}
|
||||
|
||||
public function commit(){ //TODO
|
||||
|
||||
public function commit() { //TODO
|
||||
/*
|
||||
if($this->Link_ID!=0){
|
||||
$result = @mssql_query("COMMIT");
|
||||
@@ -98,8 +98,8 @@ class Sqlsrv{
|
||||
}*/
|
||||
return false;
|
||||
}
|
||||
|
||||
public function rollback(){ //TODO
|
||||
|
||||
public function rollback() { //TODO
|
||||
/*
|
||||
if($this->Link_ID!=0){
|
||||
$result = @mssql_query("ROLLBACK");
|
||||
@@ -110,93 +110,125 @@ class Sqlsrv{
|
||||
}*/
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function next_record(){
|
||||
|
||||
public function next_record() {
|
||||
$this->Record = sqlsrv_fetch_array($this->Query_ID);
|
||||
$this->Row += 1;
|
||||
return is_array($this->Record);
|
||||
}
|
||||
|
||||
public function free_stmt(){ // libera memoria
|
||||
|
||||
public function free_stmt() { // libera memoria
|
||||
return sqlsrv_free_stmt($this->Query_ID);
|
||||
}
|
||||
|
||||
/*
|
||||
function affected_rows(){
|
||||
return mssql_affected_rows($this->Link_ID);
|
||||
}*/
|
||||
|
||||
public function num_rows(){
|
||||
public function num_rows() {
|
||||
return sqlsrv_num_rows($this->Query_ID);
|
||||
}
|
||||
|
||||
public function num_fields(){
|
||||
public function num_fields() {
|
||||
return sqlsrv_num_fields($this->Query_ID);
|
||||
}
|
||||
|
||||
public function field_name($column){
|
||||
|
||||
public function field_name($column) {
|
||||
$field = sqlsrv_field_metadata($this->Query_ID);
|
||||
foreach($field as $i => $fieldData){
|
||||
if($i == $column){
|
||||
foreach ($field as $i => $fieldData) {
|
||||
if ($i == $column) {
|
||||
return $fieldData["Name"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function field_type($column){
|
||||
|
||||
public function field_type($column) {
|
||||
$field = sqlsrv_field_metadata($this->Query_ID);
|
||||
$i = 0;
|
||||
foreach($field as $fieldData){
|
||||
if($i == $column){
|
||||
foreach ($field as $fieldData) {
|
||||
if ($i == $column) {
|
||||
return self::get_typeDesc($fieldData["Type"]);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function f($Name){
|
||||
|
||||
public function f($Name) {
|
||||
return $this->Record[$Name];
|
||||
}
|
||||
|
||||
private static function get_typeDesc($code){
|
||||
if($code==12){ return "varchar";
|
||||
} else if($code==-1){ return "text";
|
||||
} else if($code==-8){ return "nchar";
|
||||
} else if($code==-10){ return "ntext";
|
||||
} else if($code==-9){ return "nvarchar";
|
||||
|
||||
} else if($code==93){ return "datetime";
|
||||
} else if($code==93){ return "smalldatetime";
|
||||
} else if($code==-154){ return "time";
|
||||
} else if($code==-2){ return "timestamp";
|
||||
} else if($code==93){ return "datetime2";
|
||||
|
||||
} else if($code==-2){ return "binary";
|
||||
} else if($code==-4){ return "image";
|
||||
} else if($code==-3){ return "varbinary";
|
||||
} else if($code==-7){ return "bit";
|
||||
} else if($code==1){ return "char";
|
||||
} else if($code==91){ return "data";
|
||||
} else if($code==-155){ return "datetimeoffset";
|
||||
|
||||
} else if($code==4){ return "int";
|
||||
} else if($code==-5){ return "bigint";
|
||||
} else if($code==5){ return "smallint";
|
||||
} else if($code==-6){ return "tinyint";
|
||||
|
||||
} else if($code==3){ return "money";
|
||||
} else if($code==3){ return "smallmoney";
|
||||
|
||||
} else if($code==2){ return "numeric";
|
||||
} else if($code==3){ return "decimal";
|
||||
} else if($code==6){ return "float";
|
||||
} else if($code==7){ return "real";
|
||||
|
||||
} else if($code==-151){ return "udt";
|
||||
} else if($code==-11){ return "uniqueidentifier";
|
||||
} else if($code==-152){ return "xml";
|
||||
} return null;
|
||||
|
||||
private static function get_typeDesc($code) {
|
||||
if ($code == 12) {
|
||||
return "varchar";
|
||||
} else if ($code == -1) {
|
||||
return "text";
|
||||
} else if ($code == -8) {
|
||||
return "nchar";
|
||||
} else if ($code == -10) {
|
||||
return "ntext";
|
||||
} else if ($code == -9) {
|
||||
return "nvarchar";
|
||||
|
||||
} else if ($code == 93) {
|
||||
return "datetime";
|
||||
} else if ($code == 93) {
|
||||
return "smalldatetime";
|
||||
} else if ($code == -154) {
|
||||
return "time";
|
||||
} else if ($code == -2) {
|
||||
return "timestamp";
|
||||
} else if ($code == 93) {
|
||||
return "datetime2";
|
||||
|
||||
} else if ($code == -2) {
|
||||
return "binary";
|
||||
} else if ($code == -4) {
|
||||
return "image";
|
||||
} else if ($code == -3) {
|
||||
return "varbinary";
|
||||
} else if ($code == -7) {
|
||||
return "bit";
|
||||
} else if ($code == 1) {
|
||||
return "char";
|
||||
} else if ($code == 91) {
|
||||
return "data";
|
||||
} else if ($code == -155) {
|
||||
return "datetimeoffset";
|
||||
|
||||
} else if ($code == 4) {
|
||||
return "int";
|
||||
} else if ($code == -5) {
|
||||
return "bigint";
|
||||
} else if ($code == 5) {
|
||||
return "smallint";
|
||||
} else if ($code == -6) {
|
||||
return "tinyint";
|
||||
|
||||
} else if ($code == 3) {
|
||||
return "money";
|
||||
} else if ($code == 3) {
|
||||
return "smallmoney";
|
||||
|
||||
} else if ($code == 2) {
|
||||
return "numeric";
|
||||
} else if ($code == 3) {
|
||||
return "decimal";
|
||||
} else if ($code == 6) {
|
||||
return "float";
|
||||
} else if ($code == 7) {
|
||||
return "real";
|
||||
|
||||
} else if ($code == -151) {
|
||||
return "udt";
|
||||
} else if ($code == -11) {
|
||||
return "uniqueidentifier";
|
||||
} else if ($code == -152) {
|
||||
return "xml";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
<?php
|
||||
|
||||
class StbActivityFile
|
||||
{
|
||||
class StbActivityFile {
|
||||
|
||||
public static function get_items($activityId, $fileName = null, $profileDb = null)
|
||||
{
|
||||
public static function get_items($activityId, $fileName = null, $profileDb = null) {
|
||||
$Query = new Query;
|
||||
|
||||
$fields = array("file_name", "original_size", "descrizione", "id AS activity_id", "last_upd");
|
||||
@@ -50,8 +48,7 @@ class StbActivityFile
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function get_item($activityId, $fileName, $profileDb = null)
|
||||
{
|
||||
public static function get_item($activityId, $fileName, $profileDb = null) {
|
||||
$Ret = self::get_items($activityId, $fileName, $profileDb);
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
@@ -64,8 +61,7 @@ class StbActivityFile
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function upload($activityId, $fileItem, $profileDb = null)
|
||||
{
|
||||
public static function upload($activityId, $fileItem, $profileDb = null) {
|
||||
$Ret = new Ret;
|
||||
if (file_exists($fileItem["tmp_name"])) {
|
||||
$content = file_get_contents($fileItem["tmp_name"]);
|
||||
@@ -99,14 +95,13 @@ class StbActivityFile
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function save_item($activityId, $fileName, $content = null, $descrizione = null, $insert = true, $profileDb = null)
|
||||
{
|
||||
public static function save_item($activityId, $fileName, $content = null, $descrizione = null, $insert = true, $profileDb = null) {
|
||||
$Ret = new Ret;
|
||||
|
||||
if ($insert) { // cambio nome se ne esiste un altro
|
||||
$Query = new Query;
|
||||
$Query->select("file_name")->from("stb_activity_file")->where("id", $activityId);
|
||||
if ($profileDb){
|
||||
if ($profileDb) {
|
||||
$Query->profileDB();
|
||||
}
|
||||
$Ret = $Query->firstColumn()->toRet()->execute();
|
||||
@@ -132,7 +127,7 @@ class StbActivityFile
|
||||
}
|
||||
$stbActivity->set("stbActivityFile")->append($StbActivityFile);
|
||||
|
||||
if ($profileDb){
|
||||
if ($profileDb) {
|
||||
$stbActivity->profileDB($profileDb);
|
||||
}
|
||||
$Ret = $stbActivity->send();
|
||||
@@ -143,15 +138,14 @@ class StbActivityFile
|
||||
$Ret->set_data($retEntity);
|
||||
$fileName = $retEntity["fileName"];
|
||||
}
|
||||
$Ret = self::get_item($activityId, $fileName,$profileDb);
|
||||
$Ret = self::get_item($activityId, $fileName, $profileDb);
|
||||
}
|
||||
}
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function cache($activityId, $fileName, $options = array(), $profileDb = null)
|
||||
{
|
||||
public static function cache($activityId, $fileName, $options = array(), $profileDb = null) {
|
||||
$retData = null;
|
||||
$options["renew"] = isset($options["renew"]) && $options["renew"] !== false;
|
||||
$options["resize"] = isset($options["resize"]) && is_array($options["resize"]) && isset($options["resize"][0]) ? $options["resize"] : false;
|
||||
@@ -198,8 +192,7 @@ class StbActivityFile
|
||||
return $Ret->set_data($retData);
|
||||
}
|
||||
|
||||
public static function remove($activityId, $fileName)
|
||||
{
|
||||
public static function remove($activityId, $fileName) {
|
||||
$Ret = \StbActivityFile::get_item($activityId, $fileName);
|
||||
$stbActivity = new EntityItem("stb_activity");
|
||||
$stbActivity->update()->set("activityId", $activityId);
|
||||
|
||||
@@ -1,50 +1,51 @@
|
||||
<?php
|
||||
class System{
|
||||
|
||||
class System {
|
||||
const LOCALE_IT = "it";
|
||||
|
||||
public static function setLocale($locale = null){
|
||||
if($locale==self::LOCALE_IT){
|
||||
|
||||
public static function setLocale($locale = null) {
|
||||
if ($locale == self::LOCALE_IT) {
|
||||
setlocale(LC_ALL, "ita", "it_IT");/*
|
||||
if(strtoupper(substr(PHP_OS, 0, 3)) === "WIN") {
|
||||
return setlocale(LC_TIME, "ita");
|
||||
} else {
|
||||
return setlocale(LC_TIME, "it_IT");
|
||||
}*/
|
||||
} else if(!is_null($locale)){
|
||||
} else if (!is_null($locale)) {
|
||||
return setlocale(LC_ALL, $locale);
|
||||
}
|
||||
}
|
||||
|
||||
public static function filter_variablesType($arr_vars, $typeName = null){
|
||||
if(is_null($typeName)){
|
||||
|
||||
public static function filter_variablesType($arr_vars, $typeName = null) {
|
||||
if (is_null($typeName)) {
|
||||
return $arr_vars;
|
||||
} else{
|
||||
} else {
|
||||
$ret = array();
|
||||
foreach($arr_vars as $var){
|
||||
if(gettype($var)==$typeName){
|
||||
foreach ($arr_vars as $var) {
|
||||
if (gettype($var) == $typeName) {
|
||||
$ret[] = $var;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
public static function filter_variablesClass($arr_vars, $className){
|
||||
|
||||
public static function filter_variablesClass($arr_vars, $className) {
|
||||
$ret = array();
|
||||
$arr_vars = self::filter_variablesType($arr_vars, "object");
|
||||
foreach($arr_vars as $var){
|
||||
if(get_class($var)==$className){
|
||||
foreach ($arr_vars as $var) {
|
||||
if (get_class($var) == $className) {
|
||||
$ret[] = $var;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function is32Bit(){
|
||||
|
||||
public static function is32Bit() {
|
||||
return PHP_INT_SIZE === 4;
|
||||
}
|
||||
|
||||
public static function is64Bit(){
|
||||
|
||||
public static function is64Bit() {
|
||||
return PHP_INT_SIZE === 8;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace User;
|
||||
class Tip extends \GestSetupWebUser{
|
||||
class Tip extends \GestSetupWebUser {
|
||||
private $Tip = null;
|
||||
|
||||
public function tip($value){
|
||||
if(is_string($value)){
|
||||
|
||||
public function tip($value) {
|
||||
if (is_string($value)) {
|
||||
$this->Tip = \PVM\Tips::Tip()->warning()->text($value);
|
||||
} else if(gettype($value)=="object" && get_class($value)=="BC\Alert"){
|
||||
} else if (gettype($value) == "object" && get_class($value) == "BC\Alert") {
|
||||
$this->Tip = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function get_computedId(){
|
||||
|
||||
private function get_computedId() {
|
||||
return \Utility::B64JSON_stringify(array($this->gest_name, $this->getSection(), $this->key_section));
|
||||
}
|
||||
|
||||
private function explode_computedId($id){
|
||||
|
||||
private function explode_computedId($id) {
|
||||
$parts = \Utility::B64JSON_parse($id);
|
||||
if(count($parts)==3){
|
||||
if (count($parts) == 3) {
|
||||
$this->gest_name($parts[0])->section($parts[1])->keySection($parts[2]);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function show(){
|
||||
|
||||
public function show() {
|
||||
$computedId = $this->get_computedId();
|
||||
$value = $this->get();
|
||||
if(!is_null($this->Tip) && is_null($value)){
|
||||
if(is_null($this->Tip->getId())){
|
||||
if (!is_null($this->Tip) && is_null($value)) {
|
||||
if (is_null($this->Tip->getId())) {
|
||||
$this->Tip->id($computedId);
|
||||
}
|
||||
if(is_null($this->Tip->getTheme())){
|
||||
if (is_null($this->Tip->getTheme())) {
|
||||
$this->Tip->warning();
|
||||
}
|
||||
$this->Tip->_class("_user_tip");
|
||||
|
||||
|
||||
global $UserTips;
|
||||
$UserTips = new \PVM\Tips;
|
||||
$UserTips->append($this->Tip);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function close($id){
|
||||
|
||||
public function close($id) {
|
||||
return $this->explode_computedId($id)->set("S");
|
||||
}
|
||||
}
|
||||
@@ -1,91 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace User;
|
||||
class Token{
|
||||
|
||||
public static function enable($tokenId){
|
||||
class Token {
|
||||
|
||||
public static function enable($tokenId) {
|
||||
return self::changeStatus($tokenId, "S");
|
||||
}
|
||||
|
||||
public static function disable($tokenId){
|
||||
|
||||
public static function disable($tokenId) {
|
||||
return self::changeStatus($tokenId, "N");
|
||||
}
|
||||
|
||||
private static function changeStatus($tokenId, $flagAttivo){
|
||||
|
||||
private static function changeStatus($tokenId, $flagAttivo) {
|
||||
$WtbUserTokens = new \EntityItem("wtb_user_tokens");
|
||||
$WtbUserTokens->update()
|
||||
->set("tokenId", $tokenId)
|
||||
->set("flagAttivo", $flagAttivo, true);
|
||||
if(!\User::is_authenticated()){
|
||||
->set("tokenId", $tokenId)
|
||||
->set("flagAttivo", $flagAttivo, true);
|
||||
if (!\User::is_authenticated()) {
|
||||
$WtbUserTokens->anonymousAuth();
|
||||
}
|
||||
return $WtbUserTokens->send();
|
||||
}
|
||||
|
||||
public static function delete($tokenId){
|
||||
|
||||
public static function delete($tokenId) {
|
||||
$WtbUserTokens = new \EntityItem("wtb_user_tokens");
|
||||
return $WtbUserTokens->delete()->set("tokenId", $tokenId)->send();
|
||||
}
|
||||
|
||||
public static function set_lastAccess($tokenId){
|
||||
|
||||
public static function set_lastAccess($tokenId) {
|
||||
$WtbUserTokens = new \EntityItem("wtb_user_tokens");
|
||||
$WtbUserTokens->update()
|
||||
->set("tokenId", $tokenId)
|
||||
->setDatetime("dataUltimoAccesso", \Utility\Date::getNow());
|
||||
->set("tokenId", $tokenId)
|
||||
->setDatetime("dataUltimoAccesso", \Utility\Date::getNow());
|
||||
return $WtbUserTokens->send();
|
||||
}
|
||||
|
||||
public static function get($tokenId){
|
||||
|
||||
public static function get($tokenId) {
|
||||
$Query = new \Query;
|
||||
$Query->select("flag_attivo", "data_scadenza", "user_name", "note")
|
||||
->from("wtb_user_tokens")
|
||||
->where("token_id", $tokenId);
|
||||
|
||||
->from("wtb_user_tokens")
|
||||
->where("token_id", $tokenId);
|
||||
|
||||
$Ret = $Query->toRet()->firstRow()->execute();
|
||||
if($Ret->is_OK() && is_null($Ret->get_data())){
|
||||
if ($Ret->is_OK() && is_null($Ret->get_data())) {
|
||||
$Ret->set_error("Token non trovato");
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function send_mail_activation($tokenId){ // invia email di attivazione all'utente
|
||||
|
||||
public static function send_mail_activation($tokenId) { // invia email di attivazione all'utente
|
||||
$Ret = self::get($tokenId);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$token = $Ret->get_data();
|
||||
$userName = $token["user_name"];
|
||||
|
||||
|
||||
$Ret = \User::get_userData($userName);
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$user = $Ret->get_data();
|
||||
if(!is_null($user["e_mail"])){
|
||||
if (!is_null($user["e_mail"])) {
|
||||
$url = \PVM::get_current_projectPublicUrl();
|
||||
|
||||
$mailText = "Gentile utente <b>".strtoupper($userName)."</b>,<br/>
|
||||
|
||||
$mailText = "Gentile utente <b>" . strtoupper($userName) . "</b>,<br/>
|
||||
ti informiamo che la tua richiesta di abilitazione e' stata accettata.<br/>
|
||||
Puoi accedere al portale web <a href='{$url}' target='_blank'>cliccando qui</a>.";
|
||||
|
||||
|
||||
$Mailer = new \PVM\Mailer;
|
||||
$Mailer->subject("Richiesta di autenticazione accettata")
|
||||
->addTo($user["e_mail"], $userName)
|
||||
->message($mailText)
|
||||
->azienda(\Azienda::getId());
|
||||
->addTo($user["e_mail"], $userName)
|
||||
->message($mailText)
|
||||
->azienda(\Azienda::getId());
|
||||
$Ret = $Mailer->send();
|
||||
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret->set_string("L'accesso è stato attivato ed è stata inviata un'email di conferma all'utente <b>{$userName}</b> (<i>{$user["e_mail"]}</i>)");
|
||||
} else{
|
||||
} else {
|
||||
$Ret->set_string("L'accesso è stato attivato, tuttavia si è verificato un errore durante l'invio della comunicazione via email.<br/>Si prega di informare l'utente {$userName}.");
|
||||
}
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_string("L'accesso è stato attivato, tuttavia l'utente {$userName} non ha alcun indirizzo email associato.<br/>Si prega di informare l'utente {$userName}.");
|
||||
}
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_string("L'accesso è stato attivato, tuttavia si è verificato un errore durante la ricerca dell'utente.<br/>Si prega di informare l'utente {$userName} e di notificare ciò allo sviluppatore.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
class User
|
||||
{
|
||||
class User {
|
||||
const AMMINISTRATORE_SISTEMA = "1";
|
||||
const UTENTE_AZIENDALE = "2";
|
||||
const CLIENTE = "3";
|
||||
@@ -23,45 +22,37 @@ class User
|
||||
const SOTTOSCRITTORE = "26";
|
||||
const OSPITE = "27";
|
||||
|
||||
public static function is_authenticated()
|
||||
{
|
||||
public static function is_authenticated() {
|
||||
return isset($_SESSION["username"]);
|
||||
}
|
||||
|
||||
private static function get_sessionValue($key)
|
||||
{
|
||||
private static function get_sessionValue($key) {
|
||||
return self::is_authenticated() && isset($_SESSION[$key]) ? $_SESSION[$key] : null;
|
||||
}
|
||||
|
||||
public static function get_current_username()
|
||||
{
|
||||
public static function get_current_username() {
|
||||
return self::get_sessionValue("username");
|
||||
}
|
||||
|
||||
public static function get_current_fullname()
|
||||
{
|
||||
public static function get_current_fullname() {
|
||||
$fullname = self::get_sessionValue("fullname");
|
||||
return !is_null($fullname) ? ucwords(strtolower($fullname)) : null;
|
||||
}
|
||||
|
||||
public static function get_current_group()
|
||||
{
|
||||
public static function get_current_group() {
|
||||
return self::get_sessionValue("gruppo");
|
||||
}
|
||||
|
||||
public static function get_current_groupName()
|
||||
{
|
||||
public static function get_current_groupName() {
|
||||
return self::get_groupName(self::get_current_group());
|
||||
}
|
||||
|
||||
public static function get_groups()
|
||||
{
|
||||
public static function get_groups() {
|
||||
$userClass = new ReflectionClass("User");
|
||||
return $userClass->getConstants();
|
||||
}
|
||||
|
||||
public static function get_groupName($groupId)
|
||||
{
|
||||
public static function get_groupName($groupId) {
|
||||
$groups = self::get_groups();
|
||||
foreach ($groups as $groupName => $id) {
|
||||
if ($id == $groupId) {
|
||||
@@ -71,29 +62,24 @@ class User
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function get_current_profileDb()
|
||||
{
|
||||
public static function get_current_profileDb() {
|
||||
return self::get_sessionValue("profileDB");
|
||||
}
|
||||
|
||||
public static function get_current_userCode()
|
||||
{
|
||||
public static function get_current_userCode() {
|
||||
return self::get_sessionValue("user_code");
|
||||
}
|
||||
|
||||
public static function get_current_userCodMdep()
|
||||
{
|
||||
public static function get_current_userCodMdep() {
|
||||
return self::get_sessionValue("cod_mdep");
|
||||
}
|
||||
|
||||
public static function get_current_userEmail()
|
||||
{
|
||||
public static function get_current_userEmail() {
|
||||
$value = self::get_current_userData("e_mail");
|
||||
return Utility::is_validEmail($value) ? $value : null;
|
||||
}
|
||||
|
||||
public static function is_old()
|
||||
{
|
||||
public static function is_old() {
|
||||
$ts_userCreationTime = self::get_current_userCreationTime();
|
||||
$ts_lastAppUpdateTime = PVM::get_lastAppUpdateTime();
|
||||
if (!is_null($ts_userCreationTime) && !is_null($ts_lastAppUpdateTime)) {
|
||||
@@ -102,19 +88,16 @@ class User
|
||||
return true; // L'UTENTE E' STATO CREATO PRIMA DELL'ULTIMO AGGIORNAMENTO
|
||||
}
|
||||
|
||||
private static function get_current_userCreationTime()
|
||||
{
|
||||
private static function get_current_userCreationTime() {
|
||||
return self::get_current_userData("creation_datetime");
|
||||
}
|
||||
|
||||
public static function get_current_userData($key = null)
|
||||
{
|
||||
public static function get_current_userData($key = null) {
|
||||
$Ret = self::get_userData(self::get_current_username(), $key);
|
||||
return $Ret->is_OK() ? $Ret->get_data() : null;
|
||||
}
|
||||
|
||||
public static function get_current_userDepo()
|
||||
{
|
||||
public static function get_current_userDepo() {
|
||||
$userName = self::get_current_username();
|
||||
|
||||
$query = self::run_sql("SELECT wtb_depo.cod_mdep FROM mtb_depo INNER JOIN wtb_depo ON mtb_depo.cod_mdep = wtb_depo.cod_mdep WHERE user_name = '{$userName}'");
|
||||
@@ -122,35 +105,29 @@ class User
|
||||
return $query["cod_mdep"];
|
||||
}
|
||||
|
||||
private static function run_sql($sql)
|
||||
{
|
||||
private static function run_sql($sql) {
|
||||
$Query = new Query($sql);
|
||||
$result = $Query->firstRow()->toRet(false)->execute();
|
||||
return $result !== false ? $result : null;
|
||||
}
|
||||
|
||||
private static function get_anagClie($codAnag)
|
||||
{
|
||||
private static function get_anagClie($codAnag) {
|
||||
return !is_null($codAnag) ? self::run_sql("SELECT rag_soc, indirizzo, cap, citta, prov, nazione, gtb_anag.cod_anag FROM gtb_anag INNER JOIN vtb_clie ON gtb_anag.cod_anag = vtb_clie.cod_anag WHERE gtb_anag.cod_anag = '{$codAnag}'") : null;
|
||||
}
|
||||
|
||||
private static function get_anagAgen($codVage)
|
||||
{
|
||||
private static function get_anagAgen($codVage) {
|
||||
return !is_null($codVage) ? self::run_sql("SELECT rag_soc, indirizzo, cap, citta, prov, nazione, NULL AS cod_anag FROM vtb_agen WHERE cod_vage = '{$codVage}'") : null;
|
||||
}
|
||||
|
||||
private static function get_anagIspe($codVisp)
|
||||
{
|
||||
private static function get_anagIspe($codVisp) {
|
||||
return !is_null($codVisp) ? self::run_sql("SELECT rag_soc, indirizzo, cap, citta, prov, nazione, NULL AS cod_anag FROM vtb_ispe WHERE cod_visp = '{$codVisp}'") : null;
|
||||
}
|
||||
|
||||
public static function get_anagDepo($userName)
|
||||
{
|
||||
public static function get_anagDepo($userName) {
|
||||
return !is_null($userName) ? self::run_sql("SELECT descrizione, indirizzo, cap, citta, prov, nazione, NULL AS cod_anag FROM mtb_depo INNER JOIN wtb_depo ON mtb_depo.cod_mdep = wtb_depo.cod_mdep WHERE user_name = '{$userName}'") : null;
|
||||
}
|
||||
|
||||
public static function get_current_userAnag()
|
||||
{
|
||||
public static function get_current_userAnag() {
|
||||
$userCode = self::get_current_userCode();
|
||||
$userName = self::get_current_username();
|
||||
$groupId = self::get_current_group();
|
||||
@@ -167,19 +144,16 @@ class User
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getCodAnag()
|
||||
{
|
||||
public static function getCodAnag() {
|
||||
$userAnag = self::get_current_userAnag();
|
||||
return !is_null($userAnag) ? $userAnag["cod_anag"] : null;
|
||||
}
|
||||
|
||||
public static function getCodVage()
|
||||
{
|
||||
public static function getCodVage() {
|
||||
return self::get_current_userCode();
|
||||
}
|
||||
|
||||
public static function getLatLng()
|
||||
{
|
||||
public static function getLatLng() {
|
||||
$userAnag = self::get_current_userAnag();
|
||||
if (!is_null($userAnag)) {
|
||||
$location = Utility\Str::format_indirizzoCompleto($userAnag);
|
||||
@@ -196,8 +170,7 @@ class User
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function get_userData($userName, $key = null)
|
||||
{
|
||||
public static function get_userData($userName, $key = null) {
|
||||
if (!is_null($userName)) {
|
||||
$Query = new Query;
|
||||
if (is_null($key)) {
|
||||
@@ -217,8 +190,7 @@ class User
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function group_is()
|
||||
{ // concatenare con virgola gli argomenti per cercare diversi gruppi in OR
|
||||
public static function group_is() { // concatenare con virgola gli argomenti per cercare diversi gruppi in OR
|
||||
$currentGroup = self::get_current_group();
|
||||
$arr_groupsName = func_get_args();
|
||||
foreach ($arr_groupsName as $group) {
|
||||
@@ -230,95 +202,77 @@ class User
|
||||
}
|
||||
|
||||
// <editor-fold desc="'group_is'" defaultstate="collapsed">
|
||||
public static function is_cliente()
|
||||
{
|
||||
public static function is_cliente() {
|
||||
return User::group_is(User::CLIENTE);
|
||||
}
|
||||
|
||||
public static function is_utenteAziendale()
|
||||
{
|
||||
public static function is_utenteAziendale() {
|
||||
return User::group_is(User::UTENTE_AZIENDALE);
|
||||
}
|
||||
|
||||
public static function is_agente()
|
||||
{
|
||||
public static function is_agente() {
|
||||
return User::group_is(User::AGENTE);
|
||||
}
|
||||
|
||||
public static function is_ispettore()
|
||||
{
|
||||
public static function is_ispettore() {
|
||||
return User::group_is(User::ISPETTORE);
|
||||
}
|
||||
|
||||
public static function is_squadraLavoro()
|
||||
{
|
||||
public static function is_squadraLavoro() {
|
||||
return User::group_is(User::SQUADRA_LAVORO);
|
||||
}
|
||||
|
||||
public static function is_rilevatore()
|
||||
{
|
||||
public static function is_rilevatore() {
|
||||
return User::group_is(User::RILEVATORE);
|
||||
}
|
||||
|
||||
public static function is_amministratoreAziendale()
|
||||
{
|
||||
public static function is_amministratoreAziendale() {
|
||||
return User::group_is(User::AMMINISTRATORE_AZIENDALE);
|
||||
}
|
||||
|
||||
public static function is_amministratoreSistema()
|
||||
{
|
||||
public static function is_amministratoreSistema() {
|
||||
return User::group_is(User::AMMINISTRATORE_SISTEMA);
|
||||
}
|
||||
|
||||
public static function is_puntoVendita()
|
||||
{
|
||||
public static function is_puntoVendita() {
|
||||
return User::group_is(User::PUNTO_VENDITA);
|
||||
}
|
||||
|
||||
public static function is_responsabileProduzione()
|
||||
{
|
||||
public static function is_responsabileProduzione() {
|
||||
return User::group_is(User::RESPONSABILE_PRODUZIONE);
|
||||
}
|
||||
|
||||
public static function is_responsabileCommerciale()
|
||||
{
|
||||
public static function is_responsabileCommerciale() {
|
||||
return User::group_is(User::RESPONSABILE_COMMERCIALE);
|
||||
}
|
||||
|
||||
public static function is_tecnico()
|
||||
{
|
||||
public static function is_tecnico() {
|
||||
return User::group_is(User::TECNICO);
|
||||
}
|
||||
|
||||
public static function is_responsabileReparto()
|
||||
{
|
||||
public static function is_responsabileReparto() {
|
||||
return User::group_is(User::RESPONSABILE_REPARTO);
|
||||
}
|
||||
|
||||
public static function is_responsabileAcquisti()
|
||||
{
|
||||
public static function is_responsabileAcquisti() {
|
||||
return User::group_is(User::RESPONSABILE_ACQUISTI);
|
||||
}
|
||||
|
||||
public static function is_responsabileEdp()
|
||||
{
|
||||
public static function is_responsabileEdp() {
|
||||
return User::group_is(User::RESPONSABILE_EDP);
|
||||
}
|
||||
|
||||
public static function is_sottoscrittore()
|
||||
{
|
||||
public static function is_sottoscrittore() {
|
||||
return User::group_is(User::SOTTOSCRITTORE);
|
||||
}
|
||||
|
||||
public static function is_ospite()
|
||||
{
|
||||
public static function is_ospite() {
|
||||
return User::group_is(User::OSPITE);
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
public static function logout()
|
||||
{
|
||||
public static function logout() {
|
||||
session_start();
|
||||
//operazioni e controlli per effettura il logout dell'utente/agente
|
||||
if (isset($_SESSION["login"])) {
|
||||
@@ -330,8 +284,7 @@ class User
|
||||
session_destroy();
|
||||
}
|
||||
|
||||
public static function validate_password($password)
|
||||
{
|
||||
public static function validate_password($password) {
|
||||
$Ret = new Ret;
|
||||
if (strlen(\blankIfNull($password)) >= 7) {
|
||||
// immettere eventuali altri controlli
|
||||
@@ -341,8 +294,7 @@ class User
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
private static function getInfoPassword($userName)
|
||||
{
|
||||
private static function getInfoPassword($userName) {
|
||||
$Query = new Query;
|
||||
$Query->select("password", "password_expires_days", "flag_password_expiring")
|
||||
->from("wtb_users")
|
||||
@@ -354,16 +306,14 @@ class User
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function updateUser($userName, $dati)
|
||||
{
|
||||
public static function updateUser($userName, $dati) {
|
||||
$Ret = new Ret();
|
||||
|
||||
$WtbUsers = new EntityItem("wtb_users");
|
||||
|
||||
$WtbUsers->set("userName", $userName)
|
||||
->set("fullName", $dati["fullName"])
|
||||
->set("eMail", implode(";", json_decode($dati["eMail"])))
|
||||
;
|
||||
->set("eMail", implode(";", json_decode($dati["eMail"])));
|
||||
|
||||
if ($dati["old"] && $dati["new"] && $dati["new"] === $dati["confirmNew"]) {
|
||||
$Ret = \User::updatePassword($userName, $dati["new"], $dati["old"], false, true, true);
|
||||
@@ -373,8 +323,7 @@ class User
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public static function updatePassword($userName, $newPwd, $oldPasswordCheck = null, $updateLastAccessDatetime = false, $refreshSession = false, $differentFromPrev = false)
|
||||
{
|
||||
public static function updatePassword($userName, $newPwd, $oldPasswordCheck = null, $updateLastAccessDatetime = false, $refreshSession = false, $differentFromPrev = false) {
|
||||
$Ret = self::getInfoPassword($userName);
|
||||
if ($Ret->is_OK()) {
|
||||
$info = $Ret->get_data();
|
||||
@@ -418,8 +367,7 @@ class User
|
||||
return $Ret->set_data(null);
|
||||
}
|
||||
|
||||
public static function hasModulo($idModulo = null)
|
||||
{
|
||||
public static function hasModulo($idModulo = null) {
|
||||
if (!is_null($idModulo)) {
|
||||
$arr_userModules = PVM::getListModuliUtente();
|
||||
return array_key_exists($idModulo, $arr_userModules);
|
||||
@@ -427,8 +375,7 @@ class User
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getWidgets()
|
||||
{
|
||||
public static function getWidgets() {
|
||||
$arr_widgets = array();
|
||||
$arr_userModules = array_values(PVM::getListModuliUtente());
|
||||
foreach ($arr_userModules as $moduleItem) {
|
||||
@@ -456,8 +403,7 @@ class User
|
||||
return array_values($arr_widgets);
|
||||
}
|
||||
|
||||
public static function isGestioneAbilitata($gestione)
|
||||
{
|
||||
public static function isGestioneAbilitata($gestione) {
|
||||
$query = new Query("select flag_abil from stb_abil sa inner join stb_menu_opz sm on sa.cod_opz = sm.cod_opz where sa.user_name = '[user]' and sm.gest_name = '[gest]'");
|
||||
$query
|
||||
->setVar("user", self::get_current_username())
|
||||
@@ -466,6 +412,36 @@ class User
|
||||
// N = permessi negati / R = solo visualizzazione
|
||||
return $flag != null && $flag != "N" && $flag != "R";
|
||||
}
|
||||
|
||||
public static function checkValidUsername($data) {
|
||||
$ret = new \Ret();
|
||||
|
||||
$username = isset($data["username"]) && $data["username"] != "" ? $data["username"] : null;
|
||||
|
||||
if (isset($username)) {
|
||||
$query = new \Query();
|
||||
|
||||
$count = $query
|
||||
->profileDB(isset($data["azienda"]) ? $data["azienda"] : null)
|
||||
->select("User_name")
|
||||
->from("Wtb_users")
|
||||
->where("User_name", $data["username"])
|
||||
->toRet(false)
|
||||
->countRowsSql();
|
||||
|
||||
$ret->set_data(array(
|
||||
"valid" => $count == 0,
|
||||
"message" => $count == 0 ? "Nome utente valido." : "Nome utente già registrato."
|
||||
));
|
||||
} else {
|
||||
$ret->set_data(array(
|
||||
"valid" => false,
|
||||
"message" => "Il nome utente non può essere vuoto."
|
||||
));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
include "User.Token.class.php";
|
||||
|
||||
@@ -1,60 +1,62 @@
|
||||
<?php
|
||||
class UserAgentParser{
|
||||
|
||||
class UserAgentParser {
|
||||
private $regexes = array();
|
||||
|
||||
public function __construct($regexesPath = null){
|
||||
if(null === $regexesPath){
|
||||
$regexesPath = __DIR__."/regexes.json";
|
||||
public function __construct($regexesPath = null) {
|
||||
if (null === $regexesPath) {
|
||||
$regexesPath = __DIR__ . "/regexes.json";
|
||||
}
|
||||
$this->regexes = json_decode(file_get_contents($regexesPath), true);
|
||||
}
|
||||
|
||||
public function parse($userAgent, $referer = null){
|
||||
public function parse($userAgent, $referer = null) {
|
||||
$data = array(
|
||||
"browser" => $this->parseBrowser($userAgent),
|
||||
"browser" => $this->parseBrowser($userAgent),
|
||||
"rendering_engine" => $this->parseRenderingEngine($userAgent),
|
||||
"device" => $this->parseDevice($userAgent),
|
||||
"operating_system" => $this->parseOperatingSystem($userAgent),
|
||||
// "email_client" => $this->parseEmailClient($userAgent, $referer),
|
||||
// "email_client" => $this->parseEmailClient($userAgent, $referer),
|
||||
);
|
||||
|
||||
|
||||
$browser = null;
|
||||
if(isset($data["browser"]["family"])){
|
||||
if (isset($data["browser"]["family"])) {
|
||||
$browser = $data["browser"]["family"];
|
||||
if(isset($data["browser"]["major"])){
|
||||
$browser .= " ".$data["browser"]["major"];
|
||||
if(isset($data["browser"]["minor"])){
|
||||
$browser .= ".".$data["browser"]["minor"];
|
||||
if (isset($data["browser"]["major"])) {
|
||||
$browser .= " " . $data["browser"]["major"];
|
||||
if (isset($data["browser"]["minor"])) {
|
||||
$browser .= "." . $data["browser"]["minor"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$so = null;
|
||||
if(isset($data["operating_system"]["family"])){
|
||||
if (isset($data["operating_system"]["family"])) {
|
||||
$so = $data["operating_system"]["family"];
|
||||
if(isset($data["operating_system"]["major"])){
|
||||
if(isset($data["operating_system"]["major"])){
|
||||
$so .= " ".$data["operating_system"]["major"];
|
||||
if(isset($data["operating_system"]["minor"])){
|
||||
$so .= ".".$data["operating_system"]["minor"];
|
||||
if (isset($data["operating_system"]["major"])) {
|
||||
if (isset($data["operating_system"]["major"])) {
|
||||
$so .= " " . $data["operating_system"]["major"];
|
||||
if (isset($data["operating_system"]["minor"])) {
|
||||
$so .= "." . $data["operating_system"]["minor"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$device = null;
|
||||
if(isset($data["device"]["constructor"])){
|
||||
if (isset($data["device"]["constructor"])) {
|
||||
$device = $data["device"]["constructor"];
|
||||
if(isset($data["device"]["model"])){
|
||||
$device .= " ".$data["device"]["model"];
|
||||
if (isset($data["device"]["model"])) {
|
||||
$device .= " " . $data["device"]["model"];
|
||||
}
|
||||
}
|
||||
// ["device"]=> array(3) { ["constructor"]=> string(5) "Apple" ["model"]=> string(4) "iPad" ["type"]=> string(6) "tablet"
|
||||
// ["device"]=> array(3) { ["constructor"]=> string(5) "Apple" ["model"]=> string(4) "iPad" ["type"]=> string(6) "tablet"
|
||||
$data["browser"]["full_desc"] = $browser;
|
||||
$data["operating_system"]["full_desc"] = $so;
|
||||
$data["device"]["full_desc"] = $device;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the user agent an extract the browser informations
|
||||
*
|
||||
@@ -62,22 +64,30 @@ class UserAgentParser{
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function parseBrowser($userAgent){
|
||||
protected function parseBrowser($userAgent) {
|
||||
$result = array(
|
||||
"family" => "Other",
|
||||
"major" => null,
|
||||
"minor" => null,
|
||||
"patch" => null,
|
||||
);
|
||||
if(!isset($this->regexes["browser_parsers"])) {
|
||||
if (!isset($this->regexes["browser_parsers"])) {
|
||||
return $result;
|
||||
}
|
||||
foreach ($this->regexes["browser_parsers"] as $expression) {
|
||||
if (preg_match("/".str_replace("/", "\/", str_replace("\/", "/", $expression["regex"]))."/i", $userAgent, $matches)) {
|
||||
if(!isset($matches[1])) { $matches[1] = "Other"; }
|
||||
if(!isset($matches[2])) { $matches[2] = null; }
|
||||
if(!isset($matches[3])) { $matches[3] = null; }
|
||||
if(!isset($matches[4])) { $matches[4] = null; }
|
||||
if (preg_match("/" . str_replace("/", "\/", str_replace("\/", "/", $expression["regex"])) . "/i", $userAgent, $matches)) {
|
||||
if (!isset($matches[1])) {
|
||||
$matches[1] = "Other";
|
||||
}
|
||||
if (!isset($matches[2])) {
|
||||
$matches[2] = null;
|
||||
}
|
||||
if (!isset($matches[3])) {
|
||||
$matches[3] = null;
|
||||
}
|
||||
if (!isset($matches[4])) {
|
||||
$matches[4] = null;
|
||||
}
|
||||
$result["family"] = isset($expression["family_replacement"]) ? str_replace("$1", $matches[1], $expression["family_replacement"]) : $matches[1];
|
||||
$result["major"] = isset($expression["major_replacement"]) ? $expression["major_replacement"] : $matches[2];
|
||||
$result["minor"] = isset($expression["minor_replacement"]) ? $expression["minor_replacement"] : $matches[3];
|
||||
@@ -87,6 +97,7 @@ class UserAgentParser{
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the user agent an extract the rendering engine informations
|
||||
*
|
||||
@@ -94,18 +105,22 @@ class UserAgentParser{
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function parseRenderingEngine($userAgent){
|
||||
protected function parseRenderingEngine($userAgent) {
|
||||
$result = array(
|
||||
"family" => "Other",
|
||||
"version" => null,
|
||||
);
|
||||
if(!isset($this->regexes["rendering_engine_parsers"])) {
|
||||
if (!isset($this->regexes["rendering_engine_parsers"])) {
|
||||
return $result;
|
||||
}
|
||||
foreach($this->regexes["rendering_engine_parsers"] as $expression) {
|
||||
if(preg_match("/".str_replace("/","\/",str_replace("\/","/", $expression["regex"]))."/i", $userAgent, $matches)) {
|
||||
if (!isset($matches[1])) { $matches[1] = "Other"; }
|
||||
if (!isset($matches[2])) { $matches[2] = null; }
|
||||
foreach ($this->regexes["rendering_engine_parsers"] as $expression) {
|
||||
if (preg_match("/" . str_replace("/", "\/", str_replace("\/", "/", $expression["regex"])) . "/i", $userAgent, $matches)) {
|
||||
if (!isset($matches[1])) {
|
||||
$matches[1] = "Other";
|
||||
}
|
||||
if (!isset($matches[2])) {
|
||||
$matches[2] = null;
|
||||
}
|
||||
$result["family"] = isset($expression["family_replacement"]) ? str_replace("$2", $matches[2], $expression["family_replacement"]) : $matches[1];
|
||||
$result["version"] = isset($expression["version_replacement"]) ? str_replace("$1", $matches[1], $expression["version_replacement"]) : $matches[2];
|
||||
return $result;
|
||||
@@ -113,6 +128,7 @@ class UserAgentParser{
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the user agent an extract the operating system informations
|
||||
*
|
||||
@@ -120,22 +136,30 @@ class UserAgentParser{
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function parseOperatingsystem($userAgent){
|
||||
protected function parseOperatingsystem($userAgent) {
|
||||
$result = array(
|
||||
"family" => "Other",
|
||||
"major" => null,
|
||||
"minor" => null,
|
||||
"patch" => null,
|
||||
);
|
||||
if(!isset($this->regexes["operating_system_parsers"])){
|
||||
if (!isset($this->regexes["operating_system_parsers"])) {
|
||||
return $result;
|
||||
}
|
||||
foreach ($this->regexes["operating_system_parsers"] as $expression) {
|
||||
if (preg_match("/".str_replace("/","\/",str_replace("\/","/", $expression["regex"]))."/i", $userAgent, $matches)) {
|
||||
if (!isset($matches[1])) { $matches[1] = "Other"; }
|
||||
if (!isset($matches[2])) { $matches[2] = null; }
|
||||
if (!isset($matches[3])) { $matches[3] = null; }
|
||||
if (!isset($matches[4])) { $matches[4] = null; }
|
||||
if (preg_match("/" . str_replace("/", "\/", str_replace("\/", "/", $expression["regex"])) . "/i", $userAgent, $matches)) {
|
||||
if (!isset($matches[1])) {
|
||||
$matches[1] = "Other";
|
||||
}
|
||||
if (!isset($matches[2])) {
|
||||
$matches[2] = null;
|
||||
}
|
||||
if (!isset($matches[3])) {
|
||||
$matches[3] = null;
|
||||
}
|
||||
if (!isset($matches[4])) {
|
||||
$matches[4] = null;
|
||||
}
|
||||
$result["family"] = isset($expression["family_replacement"]) ? str_replace("$1", $matches[1], $expression["family_replacement"]) : $matches[1];
|
||||
$result["major"] = isset($expression["major_replacement"]) ? $expression["major_replacement"] : $matches[2];
|
||||
$result["minor"] = isset($expression["minor_replacement"]) ? $expression["minor_replacement"] : $matches[3];
|
||||
@@ -145,6 +169,7 @@ class UserAgentParser{
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the user agent an extract the device informations
|
||||
*
|
||||
@@ -152,21 +177,27 @@ class UserAgentParser{
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function parseDevice($userAgent){
|
||||
protected function parseDevice($userAgent) {
|
||||
$result = array(
|
||||
// "constructor" => "Other",
|
||||
// "constructor" => "Other",
|
||||
"constructor" => null,
|
||||
"model" => null,
|
||||
"type" => null,
|
||||
);
|
||||
if(!isset($this->regexes["device_parsers"])) {
|
||||
if (!isset($this->regexes["device_parsers"])) {
|
||||
return $result;
|
||||
}
|
||||
foreach($this->regexes["device_parsers"] as $expression) {
|
||||
if(preg_match("/".str_replace("/","\/",str_replace("\/","/", $expression["regex"]))."/i", $userAgent, $matches)) {
|
||||
if (!isset($matches[1])) { $matches[1] = "Other"; }
|
||||
if (!isset($matches[2])) { $matches[2] = null; }
|
||||
if (!isset($matches[3])) { $matches[3] = null; }
|
||||
foreach ($this->regexes["device_parsers"] as $expression) {
|
||||
if (preg_match("/" . str_replace("/", "\/", str_replace("\/", "/", $expression["regex"])) . "/i", $userAgent, $matches)) {
|
||||
if (!isset($matches[1])) {
|
||||
$matches[1] = "Other";
|
||||
}
|
||||
if (!isset($matches[2])) {
|
||||
$matches[2] = null;
|
||||
}
|
||||
if (!isset($matches[3])) {
|
||||
$matches[3] = null;
|
||||
}
|
||||
$result["constructor"] = isset($expression["constructor_replacement"]) ? str_replace(array("$1", "$2"), array($matches[1], $matches[2]), $expression["constructor_replacement"]) : $matches[1];
|
||||
$result["model"] = isset($expression["model_replacement"]) ? str_replace(array("$1", "$2"), array($matches[1], $matches[2]), $expression["model_replacement"]) : $matches[2];
|
||||
$result["type"] = isset($expression["type_replacement"]) ? $expression["type_replacement"] : $matches[3];
|
||||
@@ -175,7 +206,7 @@ class UserAgentParser{
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse the user agent and optionnaly the referer an extract the email client informations
|
||||
*
|
||||
@@ -184,23 +215,33 @@ class UserAgentParser{
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function parseEmailClient($userAgent, $referer = null){
|
||||
protected function parseEmailClient($userAgent, $referer = null) {
|
||||
$result = array(
|
||||
"family" => "Other",
|
||||
"major" => null,
|
||||
"minor" => null,
|
||||
"patch" => null,
|
||||
);
|
||||
if(!isset($this->regexes["email_client_parsers"])){
|
||||
if (!isset($this->regexes["email_client_parsers"])) {
|
||||
return $result;
|
||||
}
|
||||
foreach($this->regexes["email_client_parsers"] as $expression){
|
||||
if(preg_match("/".str_replace("/","\/",str_replace("\/","/", $expression["regex"]))."/i", $userAgent, $matches)) {
|
||||
if(!isset($matches[1])) { $matches[1] = "Other"; }
|
||||
if(!isset($matches[2])) { $matches[2] = null; }
|
||||
if(!isset($matches[3])) { $matches[3] = null; }
|
||||
if(!isset($matches[4])) { $matches[4] = null; }
|
||||
if(!isset($matches[5])) { $matches[5] = null; }
|
||||
foreach ($this->regexes["email_client_parsers"] as $expression) {
|
||||
if (preg_match("/" . str_replace("/", "\/", str_replace("\/", "/", $expression["regex"])) . "/i", $userAgent, $matches)) {
|
||||
if (!isset($matches[1])) {
|
||||
$matches[1] = "Other";
|
||||
}
|
||||
if (!isset($matches[2])) {
|
||||
$matches[2] = null;
|
||||
}
|
||||
if (!isset($matches[3])) {
|
||||
$matches[3] = null;
|
||||
}
|
||||
if (!isset($matches[4])) {
|
||||
$matches[4] = null;
|
||||
}
|
||||
if (!isset($matches[5])) {
|
||||
$matches[5] = null;
|
||||
}
|
||||
$result["family"] = isset($expression["family_replacement"]) ? str_replace("$1", $matches[1], $expression["family_replacement"]) : $matches[1];
|
||||
$result["major"] = isset($expression["major_replacement"]) ? $expression["major_replacement"] : $matches[2];
|
||||
$result["minor"] = isset($expression["minor_replacement"]) ? $expression["minor_replacement"] : $matches[3];
|
||||
@@ -210,11 +251,15 @@ class UserAgentParser{
|
||||
}
|
||||
}
|
||||
referer:
|
||||
if($result["family"] == "Other" && null !== $referer){
|
||||
foreach($this->regexes["email_client_parsers"] as $emailClientRegexe){
|
||||
if(preg_match("/".str_replace("/","\/",str_replace("\/","/", $emailClientRegexe["regex"]))."/i", $referer, $emailClientRefererMatches)) {
|
||||
if (!isset($emailClientRefererMatches[1])) { $emailClientRefererMatches[1] = "Other"; }
|
||||
if (!isset($emailClientRefererMatches[2])) { $emailClientRefererMatches[2] = null; }
|
||||
if ($result["family"] == "Other" && null !== $referer) {
|
||||
foreach ($this->regexes["email_client_parsers"] as $emailClientRegexe) {
|
||||
if (preg_match("/" . str_replace("/", "\/", str_replace("\/", "/", $emailClientRegexe["regex"])) . "/i", $referer, $emailClientRefererMatches)) {
|
||||
if (!isset($emailClientRefererMatches[1])) {
|
||||
$emailClientRefererMatches[1] = "Other";
|
||||
}
|
||||
if (!isset($emailClientRefererMatches[2])) {
|
||||
$emailClientRefererMatches[2] = null;
|
||||
}
|
||||
$result["family"] = isset($emailClientRegexe["family_replacement"]) ? str_replace("$1", $emailClientRefererMatches[1], $emailClientRegexe["family_replacement"]) : $emailClientRefererMatches[1];
|
||||
$result["type"] = isset($emailClientRegexe["type_replacement"]) ? $emailClientRegexe["type_replacement"] : $emailClientRefererMatches[2];
|
||||
return $result;
|
||||
|
||||
@@ -1,32 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Utility\Compression;
|
||||
class GZ{
|
||||
|
||||
class GZ {
|
||||
|
||||
/**
|
||||
* Decodes a gzip compressed string
|
||||
* <p>This function returns a decoded version of the input <code>data</code>.</p>
|
||||
* @param string $data <p>The data to decode, encoded by <code>gzencode()</code>.</p>
|
||||
* @param int $length <p>The maximum length of data to decode.</p>
|
||||
* @return string <p>The decoded string, or <b><code>FALSE</code></b> if an error occurred.</p>
|
||||
*/
|
||||
public static function encode($data, $level = -1, $encoding_mode = 31 /*FORCE_GZIP*/){
|
||||
* Decodes a gzip compressed string
|
||||
* <p>This function returns a decoded version of the input <code>data</code>.</p>
|
||||
* @param string $data <p>The data to decode, encoded by <code>gzencode()</code>.</p>
|
||||
* @param int $length <p>The maximum length of data to decode.</p>
|
||||
* @return string <p>The decoded string, or <b><code>FALSE</code></b> if an error occurred.</p>
|
||||
*/
|
||||
public static function encode($data, $level = -1, $encoding_mode = 31 /*FORCE_GZIP*/) {
|
||||
return gzencode($data, $level/*, $encoding_mode*/);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decodes a gzip compressed string
|
||||
* <p>This function returns a decoded version of the input <code>data</code>.</p>
|
||||
* @param string $data <p>The data to decode, encoded by <code>gzencode()</code>.</p>
|
||||
* @param int $length <p>The maximum length of data to decode.</p>
|
||||
* @return string <p>The decoded string, or <b><code>FALSE</code></b> if an error occurred.</p>
|
||||
*/
|
||||
public static function decode($data, $length = null){
|
||||
if(!(function_exists("gzdecode"))){ // PHP 5 < 5.4.0
|
||||
* Decodes a gzip compressed string
|
||||
* <p>This function returns a decoded version of the input <code>data</code>.</p>
|
||||
* @param string $data <p>The data to decode, encoded by <code>gzencode()</code>.</p>
|
||||
* @param int $length <p>The maximum length of data to decode.</p>
|
||||
* @return string <p>The decoded string, or <b><code>FALSE</code></b> if an error occurred.</p>
|
||||
*/
|
||||
public static function decode($data, $length = null) {
|
||||
if (!(function_exists("gzdecode"))) { // PHP 5 < 5.4.0
|
||||
return self::inflate(substr($data, 10, -8));
|
||||
}
|
||||
return gzdecode($data, $length);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compress a string
|
||||
* <p>This function compresses the given string using the <i>ZLIB</i> data format.</p><p>For details on the ZLIB compression algorithm see the document "ZLIB Compressed Data Format Specification version 3.3" (RFC 1950).</p><p><b>Note</b>:</p><p>This is <i>not</i> the same as gzip compression, which includes some header data. See <code>gzencode()</code> for gzip compression.</p>
|
||||
@@ -35,50 +36,50 @@ class GZ{
|
||||
* @param int $encoding <p>One of <b><code>ZLIB_ENCODING_*</code></b> constants.</p>
|
||||
* @return string <p>The compressed string or <b><code>FALSE</code></b> if an error occurred.</p>
|
||||
*/
|
||||
public static function compress($data, $level = -1, $encoding = 15 /*ZLIB_ENCODING_DEFLATE*/){
|
||||
public static function compress($data, $level = -1, $encoding = 15 /*ZLIB_ENCODING_DEFLATE*/) {
|
||||
return gzcompress($data, $level/*, $encoding*/);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Uncompress a compressed string
|
||||
* <p>This function uncompress a compressed string.</p>
|
||||
* @param string $data <p>The data compressed by <code>gzcompress()</code>.</p>
|
||||
* @param int $length <p>The maximum length of data to decode.</p>
|
||||
* @return string <p>The original uncompressed data or <b><code>FALSE</code></b> on error.</p><p>The function will return an error if the uncompressed data is more than 32768 times the length of the compressed input <code>data</code> or more than the optional parameter <code>length</code>.</p>
|
||||
*/
|
||||
public static function uncompress($data, $length = 0){
|
||||
* Uncompress a compressed string
|
||||
* <p>This function uncompress a compressed string.</p>
|
||||
* @param string $data <p>The data compressed by <code>gzcompress()</code>.</p>
|
||||
* @param int $length <p>The maximum length of data to decode.</p>
|
||||
* @return string <p>The original uncompressed data or <b><code>FALSE</code></b> on error.</p><p>The function will return an error if the uncompressed data is more than 32768 times the length of the compressed input <code>data</code> or more than the optional parameter <code>length</code>.</p>
|
||||
*/
|
||||
public static function uncompress($data, $length = 0) {
|
||||
$decompressed = @gzuncompress($data, $length);
|
||||
if($decompressed!==false){
|
||||
if ($decompressed !== false) {
|
||||
return $decompressed;
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deflate a string
|
||||
* <p>This function compresses the given string using the <i>DEFLATE</i> data format.</p><p>For details on the DEFLATE compression algorithm see the document "DEFLATE Compressed Data Format Specification version 1.3" (RFC 1951).</p>
|
||||
* @param string $data <p>The data to deflate.</p>
|
||||
* @param int $level <p>The level of compression. Can be given as 0 for no compression up to 9 for maximum compression. If not given, the default compression level will be the default compression level of the zlib library.</p>
|
||||
* @param int $encoding <p>One of <b><code>ZLIB_ENCODING_*</code></b> constants.</p>
|
||||
* @return string <p>The deflated string or <b><code>FALSE</code></b> if an error occurred.</p>
|
||||
*/
|
||||
public static function deflate($data, $level = -1/*, $encoding = ZLIB_ENCODING_RAW*/){
|
||||
* Deflate a string
|
||||
* <p>This function compresses the given string using the <i>DEFLATE</i> data format.</p><p>For details on the DEFLATE compression algorithm see the document "DEFLATE Compressed Data Format Specification version 1.3" (RFC 1951).</p>
|
||||
* @param string $data <p>The data to deflate.</p>
|
||||
* @param int $level <p>The level of compression. Can be given as 0 for no compression up to 9 for maximum compression. If not given, the default compression level will be the default compression level of the zlib library.</p>
|
||||
* @param int $encoding <p>One of <b><code>ZLIB_ENCODING_*</code></b> constants.</p>
|
||||
* @return string <p>The deflated string or <b><code>FALSE</code></b> if an error occurred.</p>
|
||||
*/
|
||||
public static function deflate($data, $level = -1/*, $encoding = ZLIB_ENCODING_RAW*/) {
|
||||
return gzdeflate($data, $level/*, $encoding*/);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inflate a deflated string
|
||||
* <p>This function inflates a deflated string.</p>
|
||||
* @param string $data <p>The data compressed by <code>gzdeflate()</code>.</p>
|
||||
* @param int $length <p>The maximum length of data to decode.</p>
|
||||
* @return string <p>The original uncompressed data or <b><code>FALSE</code></b> on error.</p><p>The function will return an error if the uncompressed data is more than 32768 times the length of the compressed input <code>data</code> or more than the optional parameter <code>length</code>.</p>
|
||||
*/
|
||||
public static function inflate($data, $length = 0){
|
||||
* Inflate a deflated string
|
||||
* <p>This function inflates a deflated string.</p>
|
||||
* @param string $data <p>The data compressed by <code>gzdeflate()</code>.</p>
|
||||
* @param int $length <p>The maximum length of data to decode.</p>
|
||||
* @return string <p>The original uncompressed data or <b><code>FALSE</code></b> on error.</p><p>The function will return an error if the uncompressed data is more than 32768 times the length of the compressed input <code>data</code> or more than the optional parameter <code>length</code>.</p>
|
||||
*/
|
||||
public static function inflate($data, $length = 0) {
|
||||
return gzinflate($data, $length);
|
||||
}
|
||||
|
||||
public static function isCompressed($data){
|
||||
|
||||
public static function isCompressed($data) {
|
||||
return @self::uncompress($data) !== false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,80 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Utility\Date;
|
||||
class Day{
|
||||
|
||||
public static function isToday($t){
|
||||
return self::diffFromToday($t)===0;
|
||||
class Day {
|
||||
|
||||
public static function isToday($t) {
|
||||
return self::diffFromToday($t) === 0;
|
||||
}
|
||||
|
||||
public static function add($t, $n){
|
||||
return strtotime(" +".$n." days", $t);
|
||||
|
||||
public static function add($t, $n) {
|
||||
return strtotime(" +" . $n . " days", $t);
|
||||
}
|
||||
|
||||
public static function diff($t1, $t2){
|
||||
|
||||
public static function diff($t1, $t2) {
|
||||
$d1 = new \DateTime(date(\Format::strtotimeYMD, \Utility\Date::startOfDay($t1)));
|
||||
$d2 = new \DateTime(date(\Format::strtotimeYMD, \Utility\Date::startOfDay($t2)));
|
||||
return (int)$d1->diff($d2)->format("%r%a");
|
||||
//return (int)\Utility\Date::diff($dayTs1, $dayTs2, "%r%a");
|
||||
}
|
||||
|
||||
public static function diffFromToday($t){
|
||||
|
||||
public static function diffFromToday($t) {
|
||||
return self::diff($t, \Utility\Date::getToday());
|
||||
}
|
||||
|
||||
public static function get_initialName($day, $locale = "it"){ // $day: unixtimestamp / ISO-8601 numeric representation of the day of the week: 1 (for Monday) through 7 (for Sunday)
|
||||
|
||||
public static function get_initialName($day, $locale = "it") { // $day: unixtimestamp / ISO-8601 numeric representation of the day of the week: 1 (for Monday) through 7 (for Sunday)
|
||||
$v = self::get_name($day, $locale);
|
||||
return !is_null($v) ? substr($v, 0, 1) : null;
|
||||
}
|
||||
|
||||
public static function get_shortName($day, $locale = "it"){ // $day: unixtimestamp / ISO-8601 numeric representation of the day of the week: 1 (for Monday) through 7 (for Sunday)
|
||||
|
||||
public static function get_shortName($day, $locale = "it") { // $day: unixtimestamp / ISO-8601 numeric representation of the day of the week: 1 (for Monday) through 7 (for Sunday)
|
||||
$v = self::get_name($day, $locale);
|
||||
return !is_null($v) ? substr($v, 0, 3) : null;
|
||||
}
|
||||
|
||||
public static function get_name($day, $locale = "it"){ // $day: unixtimestamp / ISO-8601 numeric representation of the day of the week: 1 (for Monday) through 7 (for Sunday)
|
||||
if(is_numeric($day)){
|
||||
if(gettype($day)!="integer"){
|
||||
|
||||
public static function get_name($day, $locale = "it") { // $day: unixtimestamp / ISO-8601 numeric representation of the day of the week: 1 (for Monday) through 7 (for Sunday)
|
||||
if (is_numeric($day)) {
|
||||
if (gettype($day) != "integer") {
|
||||
$day = intval($day);
|
||||
}
|
||||
if(!($day>=1 && $day<=7)){ // lo considero timestamp
|
||||
if (!($day >= 1 && $day <= 7)) { // lo considero timestamp
|
||||
$day = self::getWeekDay($day);
|
||||
}
|
||||
|
||||
if(is_null($locale)){
|
||||
return strtolower(date("l", strtotime("Sunday + ".($day-1)." days")));
|
||||
|
||||
} else{
|
||||
if (is_null($locale)) {
|
||||
return strtolower(date("l", strtotime("Sunday + " . ($day - 1) . " days")));
|
||||
|
||||
} else {
|
||||
// impostando il locale IT ci sono problemi di formato con le date da db. impostato una volta non reimposta piu quello di default
|
||||
/*
|
||||
$oldLocale = \System::setLocale(\System::LOCALE_IT);
|
||||
$value = utf8_encode(strftime("%A", strtotime("Sunday +{$day} days")));
|
||||
\System::setLocale($oldLocale);
|
||||
return $value;*/
|
||||
if($locale=="it"){
|
||||
if ($locale == "it") {
|
||||
$arr_weekDay = array("lunedì", "martedì", "mercoledì", "giovedì", "venerdì", "sabato", "domenica");
|
||||
}
|
||||
if(isset($arr_weekDay[$day-1])){
|
||||
return $arr_weekDay[$day-1];
|
||||
if (isset($arr_weekDay[$day - 1])) {
|
||||
return $arr_weekDay[$day - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getWeekDay($t){ // $ts: unixtimestamp
|
||||
|
||||
public static function getWeekDay($t) { // $ts: unixtimestamp
|
||||
return intval(date("N", $t));
|
||||
}
|
||||
|
||||
public static function isNotWorking($t){
|
||||
|
||||
public static function isNotWorking($t) {
|
||||
$weekDays = func_get_args();
|
||||
unset($weekDays[0]);
|
||||
$weekDays = array_values($weekDays);
|
||||
|
||||
|
||||
$noWorkingDays = array(
|
||||
"01/01" => "Capodanno",
|
||||
"06/01" => "Epifania",
|
||||
date("d/m", easter_date(date("Y", $t))) => "Pasqua",
|
||||
date("d/m", easter_date(date("Y", $t))+86400) => "Lunedì dell'Angelo",
|
||||
date("d/m", easter_date(date("Y", $t)) + 86400) => "Lunedì dell'Angelo",
|
||||
"25/04" => "Festa della Liberazione",
|
||||
"01/05" => "Festa del Lavoro",
|
||||
"02/06" => "Festa della Repubblica",
|
||||
@@ -84,17 +85,17 @@ class Day{
|
||||
"25/12" => "Natale",
|
||||
"26/12" => "Santo Stefano"
|
||||
);
|
||||
|
||||
|
||||
$dm = date("d/m", $t);
|
||||
if(array_key_exists($dm, $noWorkingDays)){
|
||||
if (array_key_exists($dm, $noWorkingDays)) {
|
||||
return $noWorkingDays[$dm];
|
||||
}
|
||||
|
||||
if(in_array(self::getWeekDay($t), $weekDays)){ // messo dopo affinche i nomi delle feste da calendario abbiano priorita agli eventuali giorni festivi settimanali (es sabato, domenica)
|
||||
|
||||
if (in_array(self::getWeekDay($t), $weekDays)) { // messo dopo affinche i nomi delle feste da calendario abbiano priorita agli eventuali giorni festivi settimanali (es sabato, domenica)
|
||||
return ucfirst(self::get_name($t));
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,23 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Utility\Date;
|
||||
class Format{
|
||||
|
||||
public static function DMY($t, $dateSeparator = "/"){
|
||||
class Format {
|
||||
|
||||
public static function DMY($t, $dateSeparator = "/") {
|
||||
$format = "%d{$dateSeparator}%m{$dateSeparator}%Y";
|
||||
return \Utility\Date::format($t, $format);
|
||||
}
|
||||
|
||||
/*
|
||||
public static function DMy($t, $dateSeparator = "/"){
|
||||
$format = "%d{$dateSeparator}%m{$dateSeparator}%y";
|
||||
return \Utility\Date::format($t, $format);
|
||||
}
|
||||
*/
|
||||
public static function HMS($t, $timeSeparator = ":"){
|
||||
public static function HMS($t, $timeSeparator = ":") {
|
||||
$format = "%H{$timeSeparator}%M{$timeSeparator}%S";
|
||||
return \Utility\Date::format($t, $format);
|
||||
}
|
||||
|
||||
public static function DMYHMS($t, $dateSeparator = "/", $timeSeparator = ":"){
|
||||
|
||||
public static function DMYHMS($t, $dateSeparator = "/", $timeSeparator = ":") {
|
||||
$format = "%d{$dateSeparator}%m{$dateSeparator}%Y %H{$timeSeparator}%M{$timeSeparator}%S";
|
||||
return \Utility\Date::format($t, $format);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Utility\Date;
|
||||
class Month{
|
||||
|
||||
public static function diff($monthTs1, $monthTs2){
|
||||
class Month {
|
||||
|
||||
public static function diff($monthTs1, $monthTs2) {
|
||||
$y1 = date("Y", $monthTs1);
|
||||
$y2 = date("Y", $monthTs2);
|
||||
$m1 = date("m", $monthTs1);
|
||||
@@ -17,50 +18,50 @@ class Month{
|
||||
return \Utility\Date::diff($monthTs1, $monthTs2, "%r%m");
|
||||
*/
|
||||
}
|
||||
|
||||
public static function get_shortName($month, $locale = "it"){
|
||||
|
||||
public static function get_shortName($month, $locale = "it") {
|
||||
$v = self::get_name($month, $locale);
|
||||
return !is_null($v) ? substr($v, 0, 3) : null;
|
||||
}
|
||||
|
||||
public static function get_name($month, $locale = "it"){ // unixtimestamp / mese da 1 a 12
|
||||
if(is_numeric($month)){
|
||||
if(!is_int($month)){
|
||||
|
||||
public static function get_name($month, $locale = "it") { // unixtimestamp / mese da 1 a 12
|
||||
if (is_numeric($month)) {
|
||||
if (!is_int($month)) {
|
||||
$month = intval($month);
|
||||
}
|
||||
if(!($month>=1 && $month<=12)){ // lo considero timestamp
|
||||
if (!($month >= 1 && $month <= 12)) { // lo considero timestamp
|
||||
$month = date("m", $month);
|
||||
}
|
||||
|
||||
if(is_null($locale)){
|
||||
|
||||
if (is_null($locale)) {
|
||||
return strtolower(date("F", \Utility\Date::strtotime("2017-{$month}-01", \Format::strtotimeYMD)));
|
||||
|
||||
} else{
|
||||
if(\Utility\Str::ciEquals($locale, "it")){
|
||||
} else {
|
||||
if (\Utility\Str::ciEquals($locale, "it")) {
|
||||
$arr_month = array("gennaio", "febbraio", "marzo", "aprile", "maggio", "giugno", "luglio", "agosto", "settembre", "ottobre", "novembre", "dicembre");
|
||||
}
|
||||
if(isset($arr_month[$month-1])){
|
||||
return $arr_month[$month-1];
|
||||
if (isset($arr_month[$month - 1])) {
|
||||
return $arr_month[$month - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getList(){
|
||||
|
||||
public static function getList() {
|
||||
$ret = array();
|
||||
for($i=1; $i<=12; $i++){
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$ret[$i] = array("name" => self::get_name($i), "shortName" => self::get_shortName($i));
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function get_limitDates($mm, $yy){
|
||||
|
||||
public static function get_limitDates($mm, $yy) {
|
||||
$ret = array("start" => null, "end" => null);
|
||||
$ret["start"] = \Utility\Date::strtotime($yy."-".str_pad($mm, 2, "0", STR_PAD_LEFT)."-01", \Format::strtotimeYMD);
|
||||
$ret["start"] = \Utility\Date::strtotime($yy . "-" . str_pad($mm, 2, "0", STR_PAD_LEFT) . "-01", \Format::strtotimeYMD);
|
||||
$endMonthDay = date("t", $ret["start"]);
|
||||
$ret["end"] = \Utility\Date::strtotime($yy."-".str_pad($mm, 2, "0", STR_PAD_LEFT)."-".str_pad($endMonthDay, 2, "0", STR_PAD_LEFT), \Format::strtotimeYMD);
|
||||
$ret["end"] = \Utility\Date::strtotime($yy . "-" . str_pad($mm, 2, "0", STR_PAD_LEFT) . "-" . str_pad($endMonthDay, 2, "0", STR_PAD_LEFT), \Format::strtotimeYMD);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,37 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Utility\Date;
|
||||
class Time{
|
||||
|
||||
public static function addSeconds($t, $amount){
|
||||
class Time {
|
||||
|
||||
public static function addSeconds($t, $amount) {
|
||||
return self::addTimeUnit($t, $amount, "seconds");
|
||||
}
|
||||
|
||||
public static function addMinutes($t, $amount){
|
||||
|
||||
public static function addMinutes($t, $amount) {
|
||||
return self::addTimeUnit($t, $amount, "minutes");
|
||||
}
|
||||
|
||||
public static function addHours($t, $amount){
|
||||
|
||||
public static function addHours($t, $amount) {
|
||||
return self::addTimeUnit($t, $amount, "hours");
|
||||
}
|
||||
|
||||
private static function addTimeUnit($t, $amount, $unit){
|
||||
|
||||
private static function addTimeUnit($t, $amount, $unit) {
|
||||
return \Utility\Date::isValidUnixtime($t) && is_numeric($amount) ? strtotime("+{$amount} {$unit}", $t) : $t;
|
||||
}
|
||||
|
||||
private static function timeToSeconds($time){ // $time ex 11:30:15
|
||||
|
||||
private static function timeToSeconds($time) { // $time ex 11:30:15
|
||||
$dt = new \DateTime("1970-01-01 {$time}", new \DateTimeZone("UTC"));
|
||||
return (int)$dt->getTimestamp();
|
||||
}
|
||||
|
||||
public static function setTime($t, $time){ // $time es. 11:30:15, null(0)
|
||||
if(\Utility\Date::isValidUnixtime($t)){
|
||||
return self::addSeconds(\Utility\Date::startOfDay($t), !is_null(nullIfZero($time))?self::timeToSeconds($time):0);
|
||||
|
||||
public static function setTime($t, $time) { // $time es. 11:30:15, null(0)
|
||||
if (\Utility\Date::isValidUnixtime($t)) {
|
||||
return self::addSeconds(\Utility\Date::startOfDay($t), !is_null(nullIfZero($time)) ? self::timeToSeconds($time) : 0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getTime($t){ // $time ex 11:30:15
|
||||
|
||||
public static function getTime($t) { // $time ex 11:30:15
|
||||
return \Utility\Date::isValidUnixtime($t) ? strftime(\Format::strftimeHMS, $t) : null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,106 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace Utility;
|
||||
class Date{
|
||||
/**
|
||||
* Converte una data in unixtime in stringa nel formato desiderato
|
||||
*
|
||||
* @param int $t Data in formato unixtime
|
||||
* @param string $format Formato da restituire in output
|
||||
*/
|
||||
public static function format($t, $format){
|
||||
if(self::isValidUnixtime($t) !== false){
|
||||
class Date {
|
||||
/**
|
||||
* Converte una data in unixtime in stringa nel formato desiderato
|
||||
*
|
||||
* @param int $t Data in formato unixtime
|
||||
* @param string $format Formato da restituire in output
|
||||
*/
|
||||
public static function format($t, $format) {
|
||||
if (self::isValidUnixtime($t) !== false) {
|
||||
return !is_null($format) ? strftime($format, $t) : $t;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function diff($t1, $t2, $format){
|
||||
|
||||
public static function diff($t1, $t2, $format) {
|
||||
$d1 = new \DateTime;
|
||||
$d1->setTimestamp($t1);
|
||||
|
||||
|
||||
$d2 = new \DateTime;
|
||||
$d2->setTimestamp($t2);
|
||||
|
||||
|
||||
// formati intervallo applicabili: http://php.net/manual/en/dateinterval.format.php
|
||||
return $d1->diff($d2)->format($format);
|
||||
}
|
||||
|
||||
public static function oreDiff($t1, $t2){
|
||||
|
||||
public static function oreDiff($t1, $t2) {
|
||||
return intval(self::diff($t1, $t2, "%h"));
|
||||
}
|
||||
|
||||
public static function minutiDiff($t1, $t2){
|
||||
|
||||
public static function minutiDiff($t1, $t2) {
|
||||
return intval(self::diff($t1, $t2, "%i"));
|
||||
}
|
||||
|
||||
public static function strtotime($date, $format = null){
|
||||
if(!is_null($date)){
|
||||
if(is_null($format)){
|
||||
|
||||
public static function strtotime($date, $format = null) {
|
||||
if (!is_null($date)) {
|
||||
if (is_null($format)) {
|
||||
return \strtotime($date);
|
||||
} else{
|
||||
if(!\Utility\Str::contains($format, "H", "i", "s")){
|
||||
} else {
|
||||
if (!\Utility\Str::contains($format, "H", "i", "s")) {
|
||||
$date .= " 00:00:00";
|
||||
$format .= " H:i:s";
|
||||
}
|
||||
|
||||
|
||||
$value = self::convert($date, $format, "U");
|
||||
return $value !== false ? (int)$value : $value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function convert($t, $formatFrom, $formatTo){
|
||||
|
||||
public static function convert($t, $formatFrom, $formatTo) {
|
||||
$d = \DateTime::createFromFormat($formatFrom, $t); // 'd-m-Y', 'd/m/Y H:i:s' ecc
|
||||
return $d ? $d->format($formatTo) : false;
|
||||
}
|
||||
|
||||
public static function parseMonthYear($ym = null, $minYear = null, $maxYear = null){
|
||||
if(!is_null($ym)){
|
||||
|
||||
public static function parseMonthYear($ym = null, $minYear = null, $maxYear = null) {
|
||||
if (!is_null($ym)) {
|
||||
$my = trim(\Utility::sanitize($ym));
|
||||
if(strlen($my) == 6 && is_numeric($my)){
|
||||
if (strlen($my) == 6 && is_numeric($my)) {
|
||||
$yy = intval(substr($my, 0, 4));
|
||||
$mm = intval(substr($my, 4, 2));
|
||||
if(self::isValidMonth($mm) && self::isValidYear($yy, $minYear, $maxYear)){
|
||||
if (self::isValidMonth($mm) && self::isValidYear($yy, $minYear, $maxYear)) {
|
||||
return array("m" => $mm, "y" => $yy);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function isValidMonth($mm){
|
||||
|
||||
public static function isValidMonth($mm) {
|
||||
return is_numeric($mm) && (intval($mm) <= 12 || intval($mm) >= 1);
|
||||
}
|
||||
|
||||
public static function isValidYear($yy, $min = null, $max = null){
|
||||
|
||||
public static function isValidYear($yy, $min = null, $max = null) {
|
||||
$yy = is_numeric($yy) && is_string($yy) ? intval($yy) : $yy;
|
||||
$min = is_numeric($min) && is_string($min) ? intval($min) : $min;
|
||||
$max = is_numeric($max) && is_string($max) ? intval($max) : $max;
|
||||
return is_number($yy) && (is_number($min) && $yy >= $min) && (is_number($max) && $yy <= $max);
|
||||
}
|
||||
|
||||
public static function isValidUnixtime($t){
|
||||
|
||||
public static function isValidUnixtime($t) {
|
||||
return !is_null($t) && (is_integer($t) || ((string)(int)$t === $t) && ($t <= PHP_INT_MAX) && ($t >= ~PHP_INT_MAX));
|
||||
}
|
||||
|
||||
public static function isValidWeekDay($day){
|
||||
|
||||
public static function isValidWeekDay($day) {
|
||||
return !is_null($day) && is_numeric($day) && (int)$day >= 1 && (int)$day <= 7;
|
||||
}
|
||||
|
||||
public static function isBetween($t, $tFrom, $tTo){
|
||||
|
||||
public static function isBetween($t, $tFrom, $tTo) {
|
||||
return self::isValidUnixtime($t) && self::isValidUnixtime($tFrom) && self::isValidUnixtime($tTo) ? $t >= $tFrom && $t <= $tTo : false;
|
||||
}
|
||||
|
||||
public static function startOfDay($t){
|
||||
|
||||
public static function startOfDay($t) {
|
||||
return self::isValidUnixtime($t) ? strtotime("midnight", $t) : null;
|
||||
}
|
||||
|
||||
public static function endOfDay($t){
|
||||
|
||||
public static function endOfDay($t) {
|
||||
return self::isValidUnixtime($t) ? strtotime("tomorrow", $t) - 1 : null;
|
||||
}
|
||||
|
||||
public static function isDate($value){
|
||||
public static function isDate($value) {
|
||||
if (!$value) {
|
||||
return false;
|
||||
}
|
||||
@@ -111,7 +112,7 @@ class Date{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public static function getStartAndEndDate($isoWeek, $isoYear){
|
||||
$dto = new \DateTime();
|
||||
@@ -121,160 +122,159 @@ class Date{
|
||||
$ret["week_end"] = $dto->format(\Format::strtotimeYMD);
|
||||
return $ret;
|
||||
}*/
|
||||
|
||||
public static function getDayIsoWeek($isoDayOfWeek /* 1-7 */, $isoWeek, $isoYear){
|
||||
|
||||
public static function getDayIsoWeek($isoDayOfWeek /* 1-7 */, $isoWeek, $isoYear) {
|
||||
$d = new \DateTime();
|
||||
$d->setISODate($isoYear, $isoWeek);
|
||||
|
||||
|
||||
$time = self::startOfDay($d->format("U"));
|
||||
|
||||
|
||||
$d = new \DateTime();
|
||||
$d->setTimestamp($time);
|
||||
$d->modify("+".($isoDayOfWeek-1)." days");
|
||||
$d->modify("+" . ($isoDayOfWeek - 1) . " days");
|
||||
$timezoneOffset = 0;
|
||||
// $timezoneOffset = $d->format("Z"); // prendo l'offset in data
|
||||
// $timezoneOffset = $d->format("Z"); // prendo l'offset in data
|
||||
return $d->format("U") + $timezoneOffset;
|
||||
}
|
||||
|
||||
public static function getMondayIsoWeek($isoWeek, $isoYear){
|
||||
|
||||
public static function getMondayIsoWeek($isoWeek, $isoYear) {
|
||||
return self::getDayIsoWeek(1, $isoWeek, $isoYear);
|
||||
}
|
||||
|
||||
public static function getSundayIsoWeek($isoWeek, $isoYear){
|
||||
|
||||
public static function getSundayIsoWeek($isoWeek, $isoYear) {
|
||||
return self::getDayIsoWeek(7, $isoWeek, $isoYear);
|
||||
}
|
||||
|
||||
public static function getIsoWeekLimitDays($isoWeek, $isoYear){
|
||||
|
||||
public static function getIsoWeekLimitDays($isoWeek, $isoYear) {
|
||||
return array(self::getMondayIsoWeek($isoWeek, $isoYear), self::getSundayIsoWeek($isoWeek, $isoYear));
|
||||
}
|
||||
|
||||
public static function getLastIsoWeekYear($isoYear){
|
||||
|
||||
public static function getLastIsoWeekYear($isoYear) {
|
||||
$d = new \DateTime;
|
||||
$d->setISODate($isoYear, 53);
|
||||
return $d->format("W") === "53" ? 53 : 52;
|
||||
}
|
||||
|
||||
|
||||
// calcola la differenza in settimane fra 2 coppie settimana/anno
|
||||
public static function weekDiff($isoWeek1, $isoYear1, $isoWeek2, $isoYear2){ // TODO validazione input
|
||||
public static function weekDiff($isoWeek1, $isoYear1, $isoWeek2, $isoYear2) { // TODO validazione input
|
||||
$monday1 = self::getMondayIsoWeek($isoWeek1, $isoYear1);
|
||||
$monday2 = self::getMondayIsoWeek($isoWeek2, $isoYear2);
|
||||
return floor(intval(self::diff($monday1, $monday2, "%r%a"))/7);
|
||||
return floor(intval(self::diff($monday1, $monday2, "%r%a")) / 7);
|
||||
}
|
||||
|
||||
public static function formatHumanDateRange($t1, $t2, $flagFormatoMeseEsteso = true){
|
||||
|
||||
public static function formatHumanDateRange($t1, $t2, $flagFormatoMeseEsteso = true) {
|
||||
$s = "";
|
||||
$isValidT1 = self::isValidUnixtime($t1);
|
||||
$isValidT2 = self::isValidUnixtime($t2);
|
||||
|
||||
if($isValidT1 || $isValidT2){
|
||||
|
||||
if ($isValidT1 || $isValidT2) {
|
||||
$fDay = $flagFormatoMeseEsteso ? "%#d" : "%d";
|
||||
$charSeparator = $flagFormatoMeseEsteso ? " " : "/";
|
||||
|
||||
if($isValidT1 && $isValidT2){
|
||||
|
||||
if ($isValidT1 && $isValidT2) {
|
||||
$dayDiff = Date\Day::diff($t1, $t2);
|
||||
if($dayDiff==0){
|
||||
$f = $flagFormatoMeseEsteso ? $fDay." ".ucfirst(Date\Month::get_name($t1))." %Y" : "%m %Y";
|
||||
$s = "del ". strftime($f, $t1);
|
||||
|
||||
} else{
|
||||
if($dayDiff<0){ // inverto se passati al contrario
|
||||
if ($dayDiff == 0) {
|
||||
$f = $flagFormatoMeseEsteso ? $fDay . " " . ucfirst(Date\Month::get_name($t1)) . " %Y" : "%m %Y";
|
||||
$s = "del " . strftime($f, $t1);
|
||||
|
||||
} else {
|
||||
if ($dayDiff < 0) { // inverto se passati al contrario
|
||||
$tmp = $t2;
|
||||
$t2 = $t1;
|
||||
$t1 = $tmp;
|
||||
}
|
||||
|
||||
|
||||
$d1 = strftime($fDay, $t1);
|
||||
$m1 = $flagFormatoMeseEsteso ? ucfirst(Date\Month::get_name($t1)) : strftime("%m", $t1);
|
||||
$m2 = $flagFormatoMeseEsteso ? ucfirst(Date\Month::get_name($t2)) : strftime("%m", $t2);
|
||||
$y1 = strftime("%Y", $t1);
|
||||
$y2 = strftime("%Y", $t2);
|
||||
|
||||
$dal = $d1.$charSeparator.($m1!==$m2? $m1 . ($y1!==$y2 ? $y1:"") : "");
|
||||
$f = $fDay.$charSeparator.($flagFormatoMeseEsteso ? ucfirst(Date\Month::get_name($t2)) : "%m").$charSeparator."%Y";
|
||||
|
||||
$dal = $d1 . $charSeparator . ($m1 !== $m2 ? $m1 . ($y1 !== $y2 ? $y1 : "") : "");
|
||||
$f = $fDay . $charSeparator . ($flagFormatoMeseEsteso ? ucfirst(Date\Month::get_name($t2)) : "%m") . $charSeparator . "%Y";
|
||||
$al = strftime($f, $t2);
|
||||
|
||||
|
||||
$s = "dal {$dal} al {$al}";
|
||||
}
|
||||
|
||||
} else if($isValidT1){
|
||||
$f = $fDay.$charSeparator.($flagFormatoMeseEsteso ? ucfirst(Date\Month::get_name($t1)) : "%m").$charSeparator."%Y";
|
||||
$s .= "dal ".strftime($f, $t1);
|
||||
|
||||
} else if($isValidT2){
|
||||
$f = $fDay.$charSeparator.($flagFormatoMeseEsteso ? ucfirst(Date\Month::get_name($t2)) : "%m").$charSeparator."%Y";
|
||||
$s .= "al ".strftime($f, $t2);
|
||||
|
||||
} else if ($isValidT1) {
|
||||
$f = $fDay . $charSeparator . ($flagFormatoMeseEsteso ? ucfirst(Date\Month::get_name($t1)) : "%m") . $charSeparator . "%Y";
|
||||
$s .= "dal " . strftime($f, $t1);
|
||||
|
||||
} else if ($isValidT2) {
|
||||
$f = $fDay . $charSeparator . ($flagFormatoMeseEsteso ? ucfirst(Date\Month::get_name($t2)) : "%m") . $charSeparator . "%Y";
|
||||
$s .= "al " . strftime($f, $t2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
public static function getIsoWeek($t){
|
||||
|
||||
public static function getIsoWeek($t) {
|
||||
return intval(date("W", $t));
|
||||
}
|
||||
|
||||
public static function getIsoWeekYear($t){
|
||||
|
||||
public static function getIsoWeekYear($t) {
|
||||
return intval(date("o", $t));
|
||||
}
|
||||
|
||||
public static function getYear($t){
|
||||
|
||||
public static function getYear($t) {
|
||||
return intval(date("Y", $t));
|
||||
}
|
||||
|
||||
public static function getCurrentYear(){
|
||||
|
||||
public static function getCurrentYear() {
|
||||
return intval(date("Y", self::getNow()));
|
||||
}
|
||||
|
||||
public static function getCurrentMonth(){
|
||||
|
||||
public static function getCurrentMonth() {
|
||||
return intval(date("m", self::getNow()));
|
||||
}
|
||||
|
||||
public static function getToday(){
|
||||
|
||||
public static function getToday() {
|
||||
return self::startOfDay(self::getNow());
|
||||
}
|
||||
|
||||
public static function getNow(){
|
||||
|
||||
public static function getNow() {
|
||||
return time();
|
||||
}
|
||||
|
||||
public static function getMaxDay32Bit(){
|
||||
|
||||
public static function getMaxDay32Bit() {
|
||||
return 2147483647; // corrisponde a PHP_INT_MAX (32bit)
|
||||
}
|
||||
|
||||
public static function fromNow($days)
|
||||
{
|
||||
public static function fromNow($days) {
|
||||
$now = new \DateTime();
|
||||
$period = "P".abs($days)."D";
|
||||
$period = "P" . abs($days) . "D";
|
||||
$interval = new \DateInterval($period);
|
||||
if ($days > 0 ){
|
||||
if ($days > 0) {
|
||||
$now->add($interval);
|
||||
}else{
|
||||
} else {
|
||||
$now->sub($interval);
|
||||
}
|
||||
return $now;
|
||||
}
|
||||
|
||||
public function getTimezoneOffset($v){
|
||||
if(!is_null($v)){
|
||||
public function getTimezoneOffset($v) {
|
||||
if (!is_null($v)) {
|
||||
$d = new \DateTime();
|
||||
$d->setTimestamp($v);
|
||||
return $d->format("Z");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function isCurrentYear($year){
|
||||
|
||||
public static function isCurrentYear($year) {
|
||||
return $year === self::getCurrentYear();
|
||||
}
|
||||
|
||||
public static function getFirstDayOfYear($year = null){
|
||||
return strtotime("first day of january ".(is_null($year)? self::getCurrentYear() : $year));
|
||||
|
||||
public static function getFirstDayOfYear($year = null) {
|
||||
return strtotime("first day of january " . (is_null($year) ? self::getCurrentYear() : $year));
|
||||
}
|
||||
|
||||
public static function getLastDayOfYear($year = null){
|
||||
return strtotime("last day of december ".(is_null($year)? self::getCurrentYear() : $year));
|
||||
|
||||
public static function getLastDayOfYear($year = null) {
|
||||
return strtotime("last day of december " . (is_null($year) ? self::getCurrentYear() : $year));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public static function getWeekIsoNumber($time){
|
||||
$number = strftime("%V", $time);
|
||||
|
||||
@@ -1,40 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Utility\Db;
|
||||
class TempTable{
|
||||
|
||||
class TempTable {
|
||||
|
||||
private $prefix = null;
|
||||
private $source = null;
|
||||
|
||||
|
||||
const prefixPVM = "t1_PVM"; // 60 * 60 (1 ora in secondi)
|
||||
const lifetime = 3600; // 60 * 60 (1 ora in secondi)
|
||||
|
||||
public function prefix($value = null){
|
||||
if(!is_null($value)){
|
||||
|
||||
public function prefix($value = null) {
|
||||
if (!is_null($value)) {
|
||||
$this->prefix = \Utility\Str::remove_spaces(\Utility\Str::alphanumericFilter(\Utility\Str::normalize($value), false));
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function source($value = null){
|
||||
|
||||
public function source($value = null) {
|
||||
$this->source = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function get_fieldsInfo(){
|
||||
if(!is_null($this->source) && count($this->source)>0){
|
||||
|
||||
private function get_fieldsInfo() {
|
||||
if (!is_null($this->source) && count($this->source) > 0) {
|
||||
$arr_fields = array();
|
||||
foreach($this->source as $row){
|
||||
foreach($row as $key => $value){
|
||||
foreach ($this->source as $row) {
|
||||
foreach ($row as $key => $value) {
|
||||
$type = !is_null($value) ? gettype($value) : null;
|
||||
if(!isset($arr_fields[$key])){
|
||||
|
||||
if (!isset($arr_fields[$key])) {
|
||||
|
||||
$arr_fields[$key] = array("name" => $key, "type" => $type);
|
||||
|
||||
} else{
|
||||
if(is_null($arr_fields[$key]["type"]) && !is_null($type)){
|
||||
|
||||
} else {
|
||||
if (is_null($arr_fields[$key]["type"]) && !is_null($type)) {
|
||||
$arr_fields[$key]["type"] = $type; // correzione se prec. nullo
|
||||
|
||||
} else if($arr_fields[$key]["type"]=="integer" && $type=="double"){
|
||||
|
||||
} else if ($arr_fields[$key]["type"] == "integer" && $type == "double") {
|
||||
$arr_fields[$key]["type"] = "double"; // correzione se prec. int e dopo riceve double
|
||||
}
|
||||
}
|
||||
@@ -44,99 +45,99 @@ class TempTable{
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static function create($arr_fields, $tableName, &$Query){
|
||||
$sql = "CREATE TABLE {$tableName} (";
|
||||
foreach($arr_fields as $field){
|
||||
$sql .= $field["name"]." ";
|
||||
if($field["type"]=="string"){
|
||||
$sql .= "VARCHAR(MAX)";
|
||||
|
||||
} else if($field["type"]=="integer"){
|
||||
private static function create($arr_fields, $tableName, &$Query) {
|
||||
$sql = "CREATE TABLE {$tableName} (";
|
||||
foreach ($arr_fields as $field) {
|
||||
$sql .= $field["name"] . " ";
|
||||
if ($field["type"] == "string") {
|
||||
$sql .= "VARCHAR(MAX)";
|
||||
|
||||
} else if ($field["type"] == "integer") {
|
||||
$sql .= "INTEGER";
|
||||
|
||||
} else if($field["type"]=="double"){
|
||||
} else if ($field["type"] == "double") {
|
||||
$sql .= "DECIMAL(20, 5)";
|
||||
|
||||
} else if(is_null($field["type"])){
|
||||
} else if (is_null($field["type"])) {
|
||||
$sql .= "VARCHAR(1)";
|
||||
}
|
||||
$sql .= " NULL,";
|
||||
}
|
||||
$sql = rtrim($sql, ",").")";
|
||||
|
||||
$sql = rtrim($sql, ",") . ")";
|
||||
|
||||
return $Query->setSql($sql)->toRet()->execute();
|
||||
}
|
||||
|
||||
private static function insert($arr_rows, $arr_fields, $tableName, &$Query){
|
||||
|
||||
private static function insert($arr_rows, $arr_fields, $tableName, &$Query) {
|
||||
$Ret = new \Ret;
|
||||
foreach($arr_rows as $row){
|
||||
foreach ($arr_rows as $row) {
|
||||
$QueryB = new \Query;
|
||||
$QueryB->insert($tableName);
|
||||
|
||||
foreach($arr_fields as $field){
|
||||
|
||||
foreach ($arr_fields as $field) {
|
||||
$fieldName = $field["name"];
|
||||
$value = isset($row[$fieldName]) ? $row[$fieldName] : null;
|
||||
$QueryB->value($fieldName, $value);
|
||||
}
|
||||
|
||||
|
||||
$Ret = $Query->setSql($QueryB->getSql())->toRet()->execute();
|
||||
if(!$Ret->is_OK()){
|
||||
if (!$Ret->is_OK()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
public function run(){
|
||||
|
||||
public function run() {
|
||||
self::clean();
|
||||
|
||||
$Ret = new \Ret;
|
||||
|
||||
$Ret = new \Ret;
|
||||
$arr_rows = $this->source;
|
||||
if(!is_null($arr_rows) && count($arr_rows)>0){
|
||||
if (!is_null($arr_rows) && count($arr_rows) > 0) {
|
||||
$Query = new \Query;
|
||||
$Query->begin_transaction();
|
||||
|
||||
|
||||
$arr_fields = $this->get_fieldsInfo();
|
||||
$tableName = $this->gen_tableName();
|
||||
|
||||
|
||||
$Ret = self::create($arr_fields, $tableName, $Query);
|
||||
|
||||
if($Ret->is_OK()){
|
||||
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret = self::insert($arr_rows, $arr_fields, $tableName, $Query);
|
||||
}
|
||||
|
||||
if($Ret->is_OK()){
|
||||
|
||||
if ($Ret->is_OK()) {
|
||||
$Query->commit();
|
||||
$Ret->set_string($tableName);
|
||||
} else{
|
||||
} else {
|
||||
$Query->rollback();
|
||||
}
|
||||
|
||||
} else{
|
||||
|
||||
} else {
|
||||
$Ret->set_error("Nessuna riga ricevuta");
|
||||
}
|
||||
|
||||
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
private function gen_tableName($c = null){
|
||||
|
||||
private function gen_tableName($c = null) {
|
||||
$prefix = $this->prefix;
|
||||
$effPrefix = self::prefixPVM.(!is_null($prefix)?"_".$prefix:".")."__".\Utility\Date::getNow();
|
||||
if(!is_null($c)){
|
||||
$effPrefix = self::prefixPVM . (!is_null($prefix) ? "_" . $prefix : ".") . "__" . \Utility\Date::getNow();
|
||||
if (!is_null($c)) {
|
||||
$effPrefix .= "-{$c}";
|
||||
}
|
||||
if(\Utility\Db::table_exists($effPrefix)){
|
||||
if(is_null($c)){
|
||||
if (\Utility\Db::table_exists($effPrefix)) {
|
||||
if (is_null($c)) {
|
||||
$c = 0;
|
||||
}
|
||||
return $this->gen_tableName($c+1);
|
||||
return $this->gen_tableName($c + 1);
|
||||
}
|
||||
return $effPrefix;
|
||||
}
|
||||
|
||||
private static function clean($lifetime = null){ // $lifetime in sec.
|
||||
if(is_null($lifetime) || is_int($lifetime)){
|
||||
|
||||
private static function clean($lifetime = null) { // $lifetime in sec.
|
||||
if (is_null($lifetime) || is_int($lifetime)) {
|
||||
$lifetime = self::lifetime;
|
||||
}
|
||||
$sql = "SELECT TABLE_NAME
|
||||
@@ -145,15 +146,15 @@ class TempTable{
|
||||
TABLE_NAME
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE TABLE_SCHEMA = 'dbo' AND
|
||||
TABLE_NAME LIKE '".self::prefixPVM."%'
|
||||
TABLE_NAME LIKE '" . self::prefixPVM . "%'
|
||||
) t
|
||||
WHERE (t_now-t_table) > {$lifetime}";
|
||||
$Query = new \Query($sql);
|
||||
$Ret = $Query->firstColumn()->toRet()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$arr_tables = $Ret->get_data();
|
||||
|
||||
foreach($arr_tables as $table){
|
||||
|
||||
foreach ($arr_tables as $table) {
|
||||
\Utility\Db::table_drop($table);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Utility;
|
||||
class Db{
|
||||
public static function table_exists($tableName){
|
||||
class Db {
|
||||
public static function table_exists($tableName) {
|
||||
$sql = "SELECT *
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
where TABLE_SCHEMA = 'dbo' AND
|
||||
TABLE_NAME = ".\Query::sqlValue($tableName);
|
||||
TABLE_NAME = " . \Query::sqlValue($tableName);
|
||||
$Query = new \Query($sql);
|
||||
$Ret = $Query->toRet()->execute();
|
||||
return $Ret->is_OK() ? count($Ret->get_data())>0 : false;
|
||||
return $Ret->is_OK() ? count($Ret->get_data()) > 0 : false;
|
||||
}
|
||||
|
||||
public static function table_drop($tableName){
|
||||
|
||||
public static function table_drop($tableName) {
|
||||
$Query = new \Query("DROP TABLE {$tableName}");
|
||||
return $Query->toRet()->execute();
|
||||
}
|
||||
|
||||
public static function get_newSeqNumber($tableName, $fieldName){
|
||||
|
||||
public static function get_newSeqNumber($tableName, $fieldName) {
|
||||
$Query = new \Query;
|
||||
$Query->select($fieldName)->from($tableName)->orderBy("{$fieldName} DESC");
|
||||
$Ret = $Query->toRet()->firstRowFirstValue()->execute();
|
||||
if($Ret->is_OK()){
|
||||
if ($Ret->is_OK()) {
|
||||
$c = $Ret->get_data();
|
||||
if(!is_null($c) && is_number($c)){
|
||||
if (!is_null($c) && is_number($c)) {
|
||||
return $c + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Utility\File;
|
||||
class IncrementName{
|
||||
class IncrementName {
|
||||
private $nameOriginal = null;
|
||||
private $result = null;
|
||||
private $ext = null;
|
||||
private $pattern = null;
|
||||
private $numPad = null;
|
||||
|
||||
public function __construct($nameOriginal = null){
|
||||
if(!is_null($nameOriginal)){
|
||||
|
||||
public function __construct($nameOriginal = null) {
|
||||
if (!is_null($nameOriginal)) {
|
||||
$this->set_nameOriginal($nameOriginal);
|
||||
}
|
||||
$this->set_pattern(" ([N])")->set_numPad(1);
|
||||
}
|
||||
|
||||
public function set_pattern($s){
|
||||
|
||||
public function set_pattern($s) {
|
||||
$this->pattern = $s;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function set_numPad($n){
|
||||
if(is_int($n)){
|
||||
|
||||
public function set_numPad($n) {
|
||||
if (is_int($n)) {
|
||||
$this->numPad = $n;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function set_nameOriginal($s){
|
||||
|
||||
public function set_nameOriginal($s) {
|
||||
$this->nameOriginal = "";
|
||||
$dir = pathinfo($s, PATHINFO_DIRNAME)."/"; // warn non gestisce il \\
|
||||
if(\Utility\Str::startsWith($s, $dir)){
|
||||
$dir = pathinfo($s, PATHINFO_DIRNAME) . "/"; // warn non gestisce il \\
|
||||
if (\Utility\Str::startsWith($s, $dir)) {
|
||||
$this->nameOriginal = $dir;
|
||||
}
|
||||
$this->nameOriginal .= pathinfo($s, PATHINFO_FILENAME);
|
||||
|
||||
|
||||
$this->ext = \nullIfBlank(pathinfo($s, PATHINFO_EXTENSION));
|
||||
$this->result = $s;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function set_number($i){
|
||||
|
||||
public function set_number($i) {
|
||||
$result = (string)$this->nameOriginal;
|
||||
if($i>0){
|
||||
if ($i > 0) {
|
||||
$numPad = is_int($this->numPad) ? $this->numPad : 1;
|
||||
$numPadded = str_pad($i, $numPad, "0", STR_PAD_LEFT);
|
||||
$pattern = is_null($this->pattern) ? " ([N])" : $this->pattern;
|
||||
$result .= str_replace("[N]", $numPadded, $pattern);
|
||||
}
|
||||
if(!is_null($this->ext)){
|
||||
$result .= ".".$this->ext;
|
||||
if (!is_null($this->ext)) {
|
||||
$result .= "." . $this->ext;
|
||||
}
|
||||
$this->result = $result;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get_result(){
|
||||
|
||||
public function get_result() {
|
||||
return $this->result;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user