From 3d405bd86bd1666f6ff3fe1d4fbc7f4440a20eff Mon Sep 17 00:00:00 2001 From: Kilian Saffran Date: Mon, 30 Nov 2020 06:47:19 +0100 Subject: [PATCH] v20201129 --- .gitignore | 1 + admin/.htaccess | 6 +- admin/css/theme.css | 185 +----------------- admin/db.php | 90 +++++---- admin/index.php | 3 +- admin/js/dataform.js | 2 +- .../js/modules/{websites.js => frontpage.js} | 0 admin/js/modules/galleries.js | 7 +- admin/js/modules/gallery.js | 60 ++++-- admin/js/modules/notification.js | 10 + admin/js/modules/notifications.js | 23 +++ admin/js/modules/order.js | 10 + admin/js/modules/orders.js | 23 +++ admin/js/modules/products.js | 131 +++++++++++++ admin/js/modules/rendezvous.js | 49 +++++ admin/js/modules/rendezvous_config.js | 7 + admin/js/modules/webarticle.js | 10 + admin/js/modules/webarticles.js | 23 +++ admin/js/modules/webpage.js | 12 ++ admin/js/modules/webpages.js | 52 +++++ admin/js/myapp.js | 20 +- admin/js/request.js | 32 +-- admin/lib/config.php | 3 +- admin/lib/database.php | 26 ++- admin/lib/image.php | 99 ++++++++++ .../modules/{templates.php => .templates.php} | 0 .../lib/modules/{webmenu.php => .webmenu.php} | 2 +- admin/lib/modules/Gallery.php | 93 ++++++--- admin/lib/modules/RendezVous.php | 47 ++++- admin/lib/modules/WebArticles.php | 13 ++ admin/lib/modules/orders.php | 26 +++ admin/lib/modules/products.php | 41 ++++ admin/lib/modules/users.php | 37 ++++ admin/lib/modules/websites.php | 18 +- admin/lib/session.php | 5 + .../elements/dialogs/dataload.html.mustache | 18 +- .../dialogs/dlgaddgalleryitem.html.mustache | 10 +- .../elements/panels/pnl_gallery.html.mustache | 6 + .../elements/panels/pnl_order.html.mustache | 6 + .../elements/panels/pnl_orders.html.mustache | 25 +++ .../elements/panels/pnl_rdvcfg.html.mustache | 25 +++ .../panels/pnl_rendezvous.html.mustache | 24 +++ .../panels/pnl_webarticle.html.mustache | 6 + .../panels/pnl_webarticles.html.mustache | 25 +++ .../elements/panels/pnl_webpage.html.mustache | 6 + .../panels/pnl_webpages.html.mustache | 25 +++ admin/tmpl/index.html.mustache | 8 +- admin/tmpl/pages/config/shop.html.mustache | 0 admin/tmpl/pages/config/site.html.mustache | 0 .../tmpl/pages/config/template.html.mustache | 32 --- admin/tmpl/pages/config/users.html.mustache | 0 admin/tmpl/pages/frontpage.html.mustache | 29 +++ admin/tmpl/pages/galleries.html.mustache | 4 +- admin/tmpl/pages/index.html.mustache | 28 ++- ...l.mustache => notifications.html.mustache} | 0 admin/tmpl/pages/orders.html.mustache | 12 ++ admin/tmpl/pages/products.html.mustache | 94 +++++++++ admin/tmpl/pages/rendezvous.html.mustache | 120 +++++++++++- .../pages/rendezvous_config.html.mustache | 8 + admin/tmpl/pages/shop.html.mustache | 22 +++ admin/tmpl/pages/site.html.mustache | 22 +++ admin/tmpl/pages/users.html.mustache | 39 ++++ admin/tmpl/pages/webarticles.html.mustache | 12 ++ admin/tmpl/pages/webpages.html.mustache | 13 ++ admin/tmpl/pages/websites.html.mustache | 0 admin/upload.php | 29 ++- website/.htaccess | 1 + website/db.php | 2 +- website/info.php | 2 + website/mkdir weeklysoap.txt | 7 - website/tmpl/index.html.mustache | 4 +- website/tmpl/pages/gallery.html.mustache | 13 +- 72 files changed, 1442 insertions(+), 401 deletions(-) rename admin/js/modules/{websites.js => frontpage.js} (100%) create mode 100644 admin/js/modules/notification.js create mode 100644 admin/js/modules/notifications.js create mode 100644 admin/js/modules/order.js create mode 100644 admin/js/modules/orders.js create mode 100644 admin/js/modules/products.js create mode 100644 admin/js/modules/webarticle.js create mode 100644 admin/js/modules/webarticles.js create mode 100644 admin/js/modules/webpage.js create mode 100644 admin/js/modules/webpages.js create mode 100644 admin/lib/image.php rename admin/lib/modules/{templates.php => .templates.php} (100%) rename admin/lib/modules/{webmenu.php => .webmenu.php} (96%) create mode 100644 admin/lib/modules/orders.php create mode 100644 admin/lib/modules/products.php create mode 100644 admin/lib/modules/users.php create mode 100644 admin/tmpl/elements/panels/pnl_order.html.mustache create mode 100644 admin/tmpl/elements/panels/pnl_orders.html.mustache create mode 100644 admin/tmpl/elements/panels/pnl_rdvcfg.html.mustache create mode 100644 admin/tmpl/elements/panels/pnl_rendezvous.html.mustache create mode 100644 admin/tmpl/elements/panels/pnl_webarticle.html.mustache create mode 100644 admin/tmpl/elements/panels/pnl_webarticles.html.mustache create mode 100644 admin/tmpl/elements/panels/pnl_webpage.html.mustache create mode 100644 admin/tmpl/elements/panels/pnl_webpages.html.mustache delete mode 100644 admin/tmpl/pages/config/shop.html.mustache delete mode 100644 admin/tmpl/pages/config/site.html.mustache delete mode 100644 admin/tmpl/pages/config/template.html.mustache delete mode 100644 admin/tmpl/pages/config/users.html.mustache create mode 100644 admin/tmpl/pages/frontpage.html.mustache rename admin/tmpl/pages/{config/rendezvous.html.mustache => notifications.html.mustache} (100%) create mode 100644 admin/tmpl/pages/products.html.mustache create mode 100644 admin/tmpl/pages/rendezvous_config.html.mustache create mode 100644 admin/tmpl/pages/site.html.mustache create mode 100644 admin/tmpl/pages/users.html.mustache create mode 100644 admin/tmpl/pages/webarticles.html.mustache create mode 100644 admin/tmpl/pages/webpages.html.mustache delete mode 100644 admin/tmpl/pages/websites.html.mustache delete mode 100644 website/mkdir weeklysoap.txt diff --git a/.gitignore b/.gitignore index 5fc2bf7..cca2f48 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ website/lib/vendor/* website/media/* admin/media/* admin/lib/vendor/* +admin/tools/* diff --git a/admin/.htaccess b/admin/.htaccess index 46aed99..edc875e 100644 --- a/admin/.htaccess +++ b/admin/.htaccess @@ -1,9 +1,9 @@ RewriteEngine on DirectoryIndex index.php index.html -php_flag display_startup_errors on -php_flag display_errors on -php_flag html_errors on +php_flag display_startup_errors off +php_flag display_errors off +php_flag html_errors off RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule "^(.*)$" "index.php" [NC,L,QSA] \ No newline at end of file diff --git a/admin/css/theme.css b/admin/css/theme.css index 7d36c92..2dc74f1 100644 --- a/admin/css/theme.css +++ b/admin/css/theme.css @@ -1,4 +1,3 @@ -/* W3PRO.CSS 4.13 June 2019 by Jan Egil and Borge Refsnes */ html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit} /* Extract from normalize.css by Nicolas Gallagher and Jonathan Neal git.io/normalize */ html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0} @@ -257,12 +256,6 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0} .hover-text-theme:hover {color:#6a92d3 !important} .hover-border-theme:hover {border-color:#6a92d3 !important} -/* .label { color: #000; font-size: 8pt;} */ -/* #main {margin-left: 210px;} */ -/* @media (max-width:768px){ - #sidebar { display: none;} - #main { margin-left: 0px;} -} */ .info-panel { padding: 3px; @@ -338,17 +331,6 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0} background-color: #d3d3d3!important; } - - -.right-side-bg { - background: url("../img/bg1.jpg"); - background-size: cover; - min-height: 100vh; -} - - - - /* .mceContentBody { background: #fff; color:#000; @@ -381,9 +363,6 @@ button:focus background-color: #343434; } - - - header { background-color: #fff; @@ -465,95 +444,12 @@ footer } -div.group_container -{ - background-color: #e3e3e3; - border-top-color: rgba(80%,80%,80%,1); - border-right-color: rgba(80%,80%,80%,1); - border-bottom-color: rgba(80%,80%,80%,1); - border-left-color: rgba(80%,80%,80%,1); - border-top-style: solid; - border-right-style: solid; - border-bottom-style: solid; - border-left-style: solid; - border-top-width: 1pt; - border-right-width: 1pt; - border-bottom-width: 1pt; - border-left-width: 1pt; - padding-top: 4px; - padding-bottom: 8px; -} - -/* Custom Styles */ -.ListView_Default -{ - - background-color: rgba(0%,0%,0%,0); - border-top-style: none; - border-right-style: none; - border-bottom-style: none; - border-left-style: none; - - color: #000; - text-align: left; - margin-top: 2pt; - margin-right: 2pt; - margin-bottom: 2pt; - margin-left: 2pt; -} - - -button.btnNavigation -{ - - background-color: rgba(0%,0%,0%,0); - - font-family: -fm-font-family(Arial,Arial-BoldMT); - font-weight: bold; - font-size: 10pt; - color: #fff; - padding-top: 0pt; - padding-right: 0pt; - padding-bottom: 0pt; - padding-left: 0pt; -} - -div.PageListHeader -{ - border-top-color: rgba(80%,80%,80%,1); - border-right-color: rgba(80%,80%,80%,1); - border-bottom-color: rgba(80%,80%,80%,1); - border-left-color: rgba(80%,80%,80%,1); - border-top-style: solid; - border-right-style: solid; - border-bottom-style: solid; - border-left-style: solid; - border-top-width: 1pt; - border-right-width: 1pt; - border-bottom-width: 1pt; - border-left-width: 1pt; - color: #fff; - -fm-text-vertical-align: center; -} -div.PageListHeader .inner_border -{ - padding-top: 5pt; - padding-right: 5pt; - padding-bottom: 5pt; - padding-left: 5pt; -} - .moduletoolbar { background-color: #293146; color: #fff; } -div.BodySectionHeader -{ - font-family: -fm-font-family(Arial,Arial-BoldMT); - font-weight: bold; -} div.PageHeadTitle @@ -568,13 +464,6 @@ div.SubHeadTitle color: #fff; } -div.SectionHeader -{ - - background-color: rgba(22.3529%,26.6667%,38.4314%,1); - -} - button.toolbarbtn { border: 0.5px solid #c6c6c6; @@ -687,33 +576,6 @@ a.bodybtn:focus border-left-color: rgba(80%,80%,80%,1); } - -div.ListView_Header -{ - border-top-color: rgba(80%,80%,80%,1); - border-right-color: rgba(80%,80%,80%,1); - border-bottom-color: rgba(80%,80%,80%,1); - border-left-color: rgba(80%,80%,80%,1); - border-top-style: solid; - border-right-style: solid; - border-bottom-style: solid; - border-left-style: solid; - border-top-width: 1pt; - border-right-width: 1pt; - border-bottom-width: 1pt; - border-left-width: 1pt; - font-weight: normal; - color: #fff; - -fm-text-vertical-align: center; -} -div.ListView_Header .inner_border -{ - padding-top: 2pt; - padding-right: 2pt; - padding-bottom: 2pt; - padding-left: 2pt; -} - div.toolbar { @@ -763,10 +625,6 @@ div.portaltextheader { border: 1px solid white; } - - - - select { /* -webkit-appearance: none; */ display: block; @@ -784,11 +642,6 @@ select { font-weight: normal; font-size: 11pt; background-color: #fff; - /* background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23000%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E'), - linear-gradient(to bottom, #fff 0%,#fff 100%); - background-repeat: no-repeat, repeat; - background-position: right .7em top 50%, 0 0; - background-size: .65em auto, 100%; */ } @@ -812,34 +665,6 @@ select:focus div.DataFooter{ background: #384462; } -.input-sum{padding:2px;display:block;border: 1px solid #ccc;width:100%;background-color: #4D4D4D; } - - -.currency-sum {padding:2px;display:block;border: 1px solid #ccc;width:100%;background-color: #4D4D4D;} - -.currency-sum,.currency-sum:read-only { - display: block; - color: #fff; - padding: 2px; - padding-right: 12px; - width: 100%; - max-width: 100%; - box-sizing: border-box; - margin: 0; - border: 1px solid #ccc; - border-radius: unset; - -moz-appearance: none; - -webkit-appearance: none; - appearance: none; - background-color: #4D4D4D; - background-image: url('data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22225%22%20height=%22300%22%3E%3Cpath%20fill=%22white%22%20stroke=%22none%22%20d=%22m%20224.99996,16.22698%20-8.11342,36.41161%20q%20-24.14255,-19.78892%20-54.61741,-19.78892%20-41.3588,0%20-65.00658,23.74671%20-23.647774,23.7467%20-28.397115,53.23215%20l%20134.960355,0%20-5.14505,26.71508%20-132.981532,0%20-0.395848,7.71771%200.395848,18.20566%20127.242642,0%20-5.14505,26.71508%20-117.941954,0%20q%207.519719,40.17154%2032.552754,59.06997%2025.03303,18.89844%2056.49745,18.89844%2037.20302,0%2057.98149,-19.59107%20l%200,40.9631%20Q%20192.34828,300%20162.26913,300%2053.034301,300%2030.474864,189.18206%20l%20-30.474864,0%205.738751,-26.71508%2020.580475,0%20q%20-0.395708,-4.74934%20-0.395708,-17.80995%20l%200,-8.11342%20-25.923518,0%205.738751,-26.71508%2023.152999,0%20Q%2039.181988,55.21112%2076.583149,27.60556%20113.98417,0%20163.06069,0%20199.868,0%20224.99996,16.22698%20z%22%20/%3E%3C/svg%3E'); - background-repeat: no-repeat, repeat; - background-position: right 2px top 50%, 0 0; - background-size: 9px auto, 100%; -} - - - /* input[type=date]::-webkit-inner-spin-button, input[type=date]::-webkit-outer-spin-button { @@ -891,8 +716,8 @@ input[type=number]::-webkit-outer-spin-button { border: 1px solid green; } */ -input[class=currency] { - padding: 2px; +input[class*="currency"] { + padding: 6px; padding-right: 12px; text-align: right; background-image: url('data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22225%22%20height=%22300%22%3E%3Cpath%20stroke=%22none%22%20d=%22m%20224.99996,16.22698%20-8.11342,36.41161%20q%20-24.14255,-19.78892%20-54.61741,-19.78892%20-41.3588,0%20-65.00658,23.74671%20-23.647774,23.7467%20-28.397115,53.23215%20l%20134.960355,0%20-5.14505,26.71508%20-132.981532,0%20-0.395848,7.71771%200.395848,18.20566%20127.242642,0%20-5.14505,26.71508%20-117.941954,0%20q%207.519719,40.17154%2032.552754,59.06997%2025.03303,18.89844%2056.49745,18.89844%2037.20302,0%2057.98149,-19.59107%20l%200,40.9631%20Q%20192.34828,300%20162.26913,300%2053.034301,300%2030.474864,189.18206%20l%20-30.474864,0%205.738751,-26.71508%2020.580475,0%20q%20-0.395708,-4.74934%20-0.395708,-17.80995%20l%200,-8.11342%20-25.923518,0%205.738751,-26.71508%2023.152999,0%20Q%2039.181988,55.21112%2076.583149,27.60556%20113.98417,0%20163.06069,0%20199.868,0%20224.99996,16.22698%20z%22%20/%3E%0A%3C/svg%3E'), @@ -902,13 +727,13 @@ input[class=currency] { background-size: 9px auto, 100%; } -input[class=currency]:read-only { +input[class*="currency"]:read-only { background-image: url('data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22225%22%20height=%22300%22%3E%3Cpath%20stroke=%22none%22%20d=%22m%20224.99996,16.22698%20-8.11342,36.41161%20q%20-24.14255,-19.78892%20-54.61741,-19.78892%20-41.3588,0%20-65.00658,23.74671%20-23.647774,23.7467%20-28.397115,53.23215%20l%20134.960355,0%20-5.14505,26.71508%20-132.981532,0%20-0.395848,7.71771%200.395848,18.20566%20127.242642,0%20-5.14505,26.71508%20-117.941954,0%20q%207.519719,40.17154%2032.552754,59.06997%2025.03303,18.89844%2056.49745,18.89844%2037.20302,0%2057.98149,-19.59107%20l%200,40.9631%20Q%20192.34828,300%20162.26913,300%2053.034301,300%2030.474864,189.18206%20l%20-30.474864,0%205.738751,-26.71508%2020.580475,0%20q%20-0.395708,-4.74934%20-0.395708,-17.80995%20l%200,-8.11342%20-25.923518,0%205.738751,-26.71508%2023.152999,0%20Q%2039.181988,55.21112%2076.583149,27.60556%20113.98417,0%20163.06069,0%20199.868,0%20224.99996,16.22698%20z%22%20/%3E%0A%3C/svg%3E'), linear-gradient(to bottom, #d3d3d3 0%,#d3d3d3 100%); } -input[class=percent] { - padding: 2px; +input[class*="percent"] { + padding: 6px; padding-right: 12px; text-align: right; background-image: url('data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22256%22%20height=%22232%22%20version=%221.0%22%3E%3Cg%20transform=%22translate(-112.3674,-128.3649)%22%3E%3Cpath%20style=%22fill:black;fill-opacity:1;stroke:none%22%20d=%22M%20317.1674,257.53698%20C%20308.53463,257.53708%20301.73774,261.20839%20296.77671,268.55094%20C%20291.91449,275.89365%20289.48349,286.1138%20289.48368,299.2114%20C%20289.48349,312.11067%20291.91449,322.2812%20296.77671,329.72303%20C%20301.73774,337.06568%20308.53463,340.737%20317.1674,340.73698%20C%20325.60128,340.737%20332.24934,337.06568%20337.11159,329.72303%20C%20342.07258,322.2812%20344.5532,312.11067%20344.55345,299.2114%20C%20344.5532,286.21302%20342.07258,276.04249%20337.11159,268.69977%20C%20332.24934,261.25801%20325.60128,257.53708%20317.1674,257.53698%20M%20317.1674,238.63466%20C%20332.84469,238.63477%20345.29739,244.09213%20354.52554,255.00675%20C%20363.75318,265.92157%20368.36713,280.65644%20368.3674,299.2114%20C%20368.36713,317.76648%20363.70357,332.50135%20354.37671,343.41605%20C%20345.14855,354.23156%20332.74546,359.6393%20317.1674,359.63931%20C%20301.29123,359.6393%20288.7393,354.23156%20279.51159,343.41605%20C%20270.28351,332.50135%20265.66956,317.76648%20265.66973,299.2114%20C%20265.66956,280.55721%20270.28351,265.82234%20279.51159,255.00675%20C%20288.83853,244.09213%20301.39045,238.63477%20317.1674,238.63466%20M%20163.5674,147.9928%20C%20155.03401,147.993%20148.28673,151.71393%20143.32554,159.15559%20C%20138.46349,166.49841%20136.03248,176.61933%20136.03252,189.51838%20C%20136.03248,202.61621%20138.46349,212.83635%20143.32554,220.17884%20C%20148.18751,227.52161%20154.93479,231.19292%20163.5674,231.1928%20C%20172.19989,231.19292%20178.94717,227.52161%20183.80926,220.17884%20C%20188.77041,212.83635%20191.25103,202.61621%20191.25113,189.51838%20C%20191.25103,176.71856%20188.77041,166.59764%20183.80926,159.15559%20C%20178.84794,151.71393%20172.10066,147.993%20163.5674,147.9928%20M%20297.9674,129.09047%20L%20321.78136,129.09047%20L%20182.7674,359.63931%20L%20158.95345,359.63931%20L%20297.9674,129.09047%20M%20163.5674,129.09047%20C%20179.24484,129.0907%20191.74715,134.54806%20201.07438,145.46256%20C%20210.4014,156.27827%20215.06496,170.96352%20215.06508,189.51838%20C%20215.06496,208.27201%20210.4014,223.05649%20201.07438,233.87187%20C%20191.84638,244.68748%20179.34406,250.09523%20163.5674,250.09512%20C%20147.79061,250.09523%20135.28829,244.68748%20126.06043,233.87187%20C%20116.93172,222.95727%20112.36739,208.17279%20112.3674,189.51838%20C%20112.36739,171.06275%20116.98134,156.37749%20126.20926,145.46256%20C%20135.43713,134.54806%20147.88983,129.0907%20163.5674,129.09047%22%20/%3E%3C/g%3E%3C/svg%3E'), diff --git a/admin/db.php b/admin/db.php index b4a776d..582dff7 100644 --- a/admin/db.php +++ b/admin/db.php @@ -1,9 +1,19 @@ $value) + { + if ((is_file("lib/".$value) && strpos($value,'.') !== 0) && substr_compare($value, ".php", -strlen(".php")) === 0){ + require("lib/".$value); + } + } + $moduleclasses = scandir("lib/modules"); + foreach ($moduleclasses as $key => $value) + { + if ((is_file("lib/modules/".$value) && strpos($value,'.') !== 0) && substr_compare($value, ".php", -strlen(".php")) === 0){ + require("lib/modules/".$value); + } + } + $db = new database($cfg["db"]); $sess = new session($db); $vars = array(); @@ -13,53 +23,53 @@ } if (isset($vars["sid"]) && ($vars["sid"] != "")){ $vars["session"] = $sess->getSession($vars["sid"]); - // if (!isset($vars["session"]["id_session"])){ - // $vars["sid"] = ""; - // } } $params = array(); $html["session"] = $vars["session"]; $params = json_decode(file_get_contents('php://input'), true); + //$params =$_GET; $html["params"] = $params; if(count($vars["session"]) == 0) { header('Content-Type: application/json'); echo json_encode($html); exit(1); } - if (isset($params["get"])){ - if (strpos($params["get"], 'gallery_') === 0) { - $gl = new Gallery($db); - if ($params["get"] == "gallery_galleries"){ - $html["data"] = $gl->getGalleries(); - } - elseif ($params["get"] == "gallery_data"){ - $html["data"] = $gl->getGallery($params["id"]); + if (isset($params["cl"]) && isset($params["fn"])){ + if (class_exists($params["cl"])) { + $strclass=$params["cl"]; + $cl = new $strclass($db,$cfg); + if (!method_exists($cl,$params["fn"])){ + $html["error"] = "class ".$params["cl"]."->method ".$params["fn"]." does not exist!"; } - elseif ($params["get"] == "gallery_items"){ - $html["data"] = $gl->getGalleryItems($params["id"]); + $r = new ReflectionMethod($strclass, $params["fn"]); + $metparams = $r->getParameters(); + $fnp = array(); + $prcnt = 0; + foreach ($metparams as $p) { + if (isset($params[$p->getName()])){ + array_push($fnp,$params[$p->getName()]); + } + if ($p->isOptional() === false){ + $prcnt++; + } + $html["fnparams"][$p->getName()] = (($p->isOptional() === true)?"optional":"required"); } - } elseif (strpos($params["get"], 'rdv_') === 0){ - - } elseif (strpos($params["get"], 'website_') === 0){ - - } elseif (strpos($params["get"], 'users_') === 0){ - - } elseif (strpos($params["get"], 'template_') === 0){ - $tmpl = new templates($cfg["sitetemplatepath"]); - if ($params["get"] == "template_files"){ - $html["files"] = $tmpl->gettemplatefiles(); - } - elseif ($params["get"] == "template_media"){ - $html["files"] = $tmpl->getmediafiles(); + if (count($fnp) < $prcnt){ + $html["error"] = "Function has ".$prcnt." required parameters!"; + } else { + $html["data"] = call_user_func_array(array($cl, $params["fn"]), $fnp); } - } - - } elseif (isset($params["fn"])){ - - - } elseif(isset($params["savefield"])){ - db.exec("UPDATE ".$params["table"]." set ".$params["column"]."=".$db->value($params["value"])." where id=".$db->value($params["id"]).";"); - } + } else { + $html["error"] = "class ".$params["cl"]." does not exist!"; + } + } + elseif(isset($params["savefield"])){ + db.exec("UPDATE ".$params["table"]." set ".$params["column"]."=".$db->value($params["value"])." where id=".$db->value($params["id"]).";"); + } + elseif(isset($params["logout"])){ + $html["data"] = $sess->deleteSession($vars["sid"]); + } header('Content-Type: application/json'); echo json_encode($html); -?> \ No newline at end of file + +?> diff --git a/admin/index.php b/admin/index.php index ac96795..9719cdf 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1,7 +1,6 @@ ".print_r($vars).""; + //echo "
".print_r($vars,true)."
"; ?> \ No newline at end of file diff --git a/admin/js/dataform.js b/admin/js/dataform.js index ab958e6..0b9098f 100644 --- a/admin/js/dataform.js +++ b/admin/js/dataform.js @@ -246,7 +246,7 @@ let dataform = { } fdata["savefield"] = 1; postData({fdata}).then(ret => { - + console.log(ret); }); return false; }, diff --git a/admin/js/modules/websites.js b/admin/js/modules/frontpage.js similarity index 100% rename from admin/js/modules/websites.js rename to admin/js/modules/frontpage.js diff --git a/admin/js/modules/galleries.js b/admin/js/modules/galleries.js index 9fe6b51..c0ba7a0 100644 --- a/admin/js/modules/galleries.js +++ b/admin/js/modules/galleries.js @@ -1,3 +1,4 @@ + let galleries = { tbl: null, tblitems: null, @@ -8,6 +9,10 @@ let galleries = { layout: "fitColumns", responsiveLayout:true, selectable: 1, + // rowDblClick:function(e, row){ + // //e.preventDefault(); + // galleries.edit(); + // }, rowContext:function(e, row){ e.preventDefault(); }, columns: [ {title: "Gallerie", field: "gallery"}, @@ -18,7 +23,7 @@ let galleries = { galleries.gettbldata(); }, gettbldata: function(){ - postData({"get":"gallery_galleries"}).then(data => { + postData({"cl":"gallery","fn":"getAll"}).then(data => { console.log("galleries Data",data.data); galleries.tbl.setData(data.data); diff --git a/admin/js/modules/gallery.js b/admin/js/modules/gallery.js index 3a8a31f..ded9441 100644 --- a/admin/js/modules/gallery.js +++ b/admin/js/modules/gallery.js @@ -8,7 +8,7 @@ let gallery = { let sel = galleries.tbl.getSelectedData(); this.gallery_folder = sel[0].link; dataform.cleanform("galleries"); - postData({"get":"gallery_data","id":gallery.id_gallery}).then(data => { + postData({"cl":"gallery","fn":"get","id":gallery.id_gallery}).then(data => { console.log("Gallery Data:",data.data); dataform.fillform("galleries",gallery.selects,data.data); gallery.gettabledata(); @@ -64,7 +64,7 @@ let gallery = { selectable: 1, autoResize:false, rowFormatter:function(row, data){ - console.log(row); + //console.log(row); }, @@ -79,7 +79,7 @@ let gallery = { }); }, gettabledata: function(){ - postData({"get":"gallery_items","id":gallery.id_gallery}).then(data => { + postData({"cl":"gallery","fn":"getItems","id":gallery.id_gallery}).then(data => { console.log("Gallery Items:",data.data); gallery.tbl.setData(data.data); }) @@ -88,20 +88,44 @@ let gallery = { myapp.viewdialog("addgalleryitem"); }, uploadItem: function(){ - let data = dataform.getformcontent("addgalleryitem"); + let data = {}; + data["folder"] = "galleries/" + this.gallery_folder; myapp.closedlg("addgalleryitem"); - myapp.openDataLoad("Téléchargement en cours","Attendez s.v.p.!"); - postFile("addgalleryitem_file",data).then(data => { - myapp.closeDataLoad(); - - // postData({"fn":"gallery_addfiles",}).then( data => { - - // }); - - - }).catch(err => { - myapp.closeDataLoad(); - }); + var uplfiles = document.getElementById("addgalleryitem_file"); + console.log("files:",uplfiles.files); + progresssteps = uplfiles.files.length * 2; + cstep = 0; + myapp.openDataLoad("Téléchargement en cours","Attendez s.v.p.!",progresssteps); + for (let i = 0; i < uplfiles.files.length; i++) { + myapp.setDataLoadMsg("Upload File " + uplfiles.files[i].name,cstep); + postFile(uplfiles.files[i],data).then(filedata => { + console.log("File uploaded!",filedata); + cstep++; + myapp.setDataLoadMsg("Process File " + uplfiles.files[i].name,cstep); + postData({"cl":"gallery","fn":"addItem","idgallery":gallery.id_gallery,"filename":filedata.file}).then( data => { + console.log(data," added!"); + if (cstep >= progresssteps){ + gallery.gettabledata(); + myapp.closeDataLoad(); + } + }) .catch(err => { + + console.log("postData RETURN ERROR",err); + console.log(err); + gallery.gettabledata(); + myapp.closeDataLoad(); + return false; + }); + }).catch(err => { + console.log("postFile RETURN ERROR",err); + gallery.gettabledata(); + myapp.closeDataLoad(); + return false; + }); + cstep++; + } + + }, confirmRemove: function(){ @@ -113,7 +137,7 @@ let gallery = { }, remove: function(){ var sel = gallery.tbl.getSelectedData(); - postData({"fn":"gallery_deleteitem","id":id}).then(data => { + postData({"cl":"gallery","fn":"remove","id":id}).then(data => { gallery.tbl.deselectRow(sel[0].id); gallery.gettabledata(); }); @@ -141,5 +165,5 @@ let gallery = { let pictureFormatter = function(cell, formatterParams){ - return '
'; + return '
'; }; \ No newline at end of file diff --git a/admin/js/modules/notification.js b/admin/js/modules/notification.js new file mode 100644 index 0000000..cf12ad4 --- /dev/null +++ b/admin/js/modules/notification.js @@ -0,0 +1,10 @@ +let notification = { + current_id: null, + selects:{}, + init: function(){ + + }, + viewpanel: function(id){ + notification.current_id=id; + } +} \ No newline at end of file diff --git a/admin/js/modules/notifications.js b/admin/js/modules/notifications.js new file mode 100644 index 0000000..7b55bb4 --- /dev/null +++ b/admin/js/modules/notifications.js @@ -0,0 +1,23 @@ +let webarticles = { + tbl: null, + selects:{}, + init: function(){ + + }, + gettabledata: function(){ + + }, + add: function(){ + + }, + edit: function(){ + + }, + confirmRemove: function(){ + + }, + remove: function(){ + + } + +} \ No newline at end of file diff --git a/admin/js/modules/order.js b/admin/js/modules/order.js new file mode 100644 index 0000000..b1c0d90 --- /dev/null +++ b/admin/js/modules/order.js @@ -0,0 +1,10 @@ +let order = { + current_id: null, + selects:{}, + init: function(){ + + }, + viewpanel: function(id){ + order.current_id=id; + } +} \ No newline at end of file diff --git a/admin/js/modules/orders.js b/admin/js/modules/orders.js new file mode 100644 index 0000000..0558194 --- /dev/null +++ b/admin/js/modules/orders.js @@ -0,0 +1,23 @@ +let orders = { + tbl: null, + selects:{}, + init: function(){ + + }, + gettabledata: function(){ + + }, + add: function(){ + + }, + edit: function(){ + + }, + confirmRemove: function(){ + + }, + remove: function(){ + + } + +} \ No newline at end of file diff --git a/admin/js/modules/products.js b/admin/js/modules/products.js new file mode 100644 index 0000000..24122fb --- /dev/null +++ b/admin/js/modules/products.js @@ -0,0 +1,131 @@ +let products = { + tbl: null, + selects: {"products_productgroup":null}, + init: function(){ + flatpickr("#products_publishdate",{altInput: true, + altFormat: "d.m.Y", dateFormat: "Y-m-d","locale": "fr", + onClose: function(selectedDates, dateStr, instance) {dataform.savefield(document.getElementById('products_publishdate'),null); } + }); + flatpickr("#products_unpublishdate",{altInput: true, + altFormat: "d.m.Y",dateFormat: "Y-m-d","locale": "fr", + onClose: function(selectedDates, dateStr, instance) {dataform.savefield(document.getElementById('products_unpublishdate'),null);} + }); + products.selects["products_productgroup"] = new SlimSelect({ + select: "#products_productgroup", + allowDeselectOption: true, + searchPlaceholder:"groupe...", + placeholderText: "groupe...", + searchText:"pas de groupe...", + addable: function (value) {return value;/*return {text: value,value: value.toLowerCase()}*/}, + afterClose: function(){ + //console.log("set timetrack"); + dataform.savefield(document.getElementById('products_productgroup'),null); + } + }); + products.selects["products_productoptions"] = new SlimSelect({ + select: "#products_productoptions", + searchPlaceholder:"options...", + placeholderText: "option...", + allowDeselectOption: true, + searchText:"pas d'options'...", + addable: function (value) {return value;/*return {text: value,value: value.toLowerCase()}*/}, + afterClose: function(){ + //console.log("set timetrack"); + dataform.savefield(document.getElementById('products_productoptions'),null); + } + }); + tinymce.init({ + selector: '#products_description', + plugins: 'paste importcss searchreplace autolink directionality visualblocks visualchars template charmap nonbreaking advlist lists textpattern noneditable charmap autoresize ', + menubar: false, + entity_encoding : 'raw', + toolbar: 'bold italic underline strikethrough | fontsizeselect | forecolor removeformat | charmap', + toolbar_sticky: false, + language: 'fr', + content_css: [ + 'css/theme.css' + ], + statusbar: false, + forced_root_block : '', + min_height: 350, + branding: false, + importcss_append: true, + noneditable_noneditable_class: "mceNonEditable", + contextmenu: false, + setup: function(editor) { + editor.on('blur', function(e) { + console.log("tmce blur:",e.target.id); + if (e.target.id == "products_description"){ + dataform.savefield(document.getElementById(e.id)); + console.log("TODO: savefield"); + } + // + //e.id + //console.log('The Editor has initialized.'); + }); + } + }); + products.tbl =new Tabulator("#tbl_products",{ + height: "calc(100vh - 60px)", + layout: "fitColumns", + responsiveLayout:true, + selectable: 1, + autoResize:false, + groupBy:["productgroup"], + groupStartOpen:[true], + groupHeader:[function(value, count, data){ return ((value)?value:"");}], + rowClick:function(e, row){ + products.edit(); + }, + + rowContext:function(e, row){ e.preventDefault(); }, + columns: [ + {title: "Produit", field: "name" ,width: 100}, + ] + }); + }, + gettabledata: function(){ + postData({"cl":"products","fn":"getAll"}).then(data => { + products.tbl.setData(data.data); + }); + }, + calculate: function(){ + + }, + edit: function(){ + let sel = products.tbl.getSelectedData(); + if (sel[0]){ + dataform.cleanform("products"); + postData({"get":"products","fn":"get","id":sel[0].id}).then(data => { + dataform.fillform("products",data.data); + }); + } + }, + add: function(){ + postData({"cl":"products","fn":"add"}).then(data => { + products.gettabledata(); + }); + }, + confirmRemove: function(){ + let sel = products.tbl.getSelectedData(); + if (sel[0]){ + myapp.confirm("supprimer le produit?","êtes-vous sûre de voulvoir supprimer ce produit?","Supprimer","Abondonner",'products.remove();'); + } + }, + remove: function(){ + let sel = products.tbl.getSelectedData(); + if (sel[0]){ + postData({"cl":"products","fn":"delete","id":sel[0].id}).then(data => { + products.gettabledata(); + }); + } + }, + duplicate: function(){ + let sel = products.tbl.getSelectedData(); + if (sel[0]){ + postData({"cl":"products","fn":"duplicate","id":sel[0].id}).then(data => { + products.gettabledata(); + }); + } + } +} \ No newline at end of file diff --git a/admin/js/modules/rendezvous.js b/admin/js/modules/rendezvous.js index 1639547..be3eda1 100644 --- a/admin/js/modules/rendezvous.js +++ b/admin/js/modules/rendezvous.js @@ -1,5 +1,54 @@ let rendezvous = { + tblday: null, + tblweek: null, + init: function(){ + flatpickr("#filter_daydate",{altInput: true, + altFormat: "D, d.m.Y", dateFormat: "Y-m-d","locale": "fr", + disableMobile: true, + onClose: function(selectedDates, dateStr, instance) { + rendezvous.gettabledata(); + } + }); + rendezvous.tblday = new Tabulator("#tbl_day",{ + height: "calc(100vh - 60px)", + layout: "fitColumns", + responsiveLayout:true, + selectable: 1, + // rowDblClick:function(e, row){ + // //e.preventDefault(); + // galleries.edit(); + // }, + rowContext:function(e, row){ e.preventDefault(); }, + columns: [ + {title: "heure", field: "rdvtime",width: 70,headerSort: false}, + {title: "RendezVous",field: "clientname",headerSort: false,formatter:RDVFormatter} + ] + }); + document.getElementById("filter_daydate")._flatpickr.setDate(moment().format('YYYY-MM-DD')); + rendezvous.gettabledata(); + }, + gettabledata: function(){ + postData({"cl":"rendezvous","fn":"getRDVByDay","daydate":document.getElementById("filter_daydate").value}).then(data => { + rendezvous.tblday.setData(data.data); + }); + }, + nextday: function(){ + document.getElementById("filter_daydate")._flatpickr.setDate(moment(document.getElementById("filter_daydate").value).add(1,'day').format('YYYY-MM-DD')); + rendezvous.gettabledata(); + }, + prevday: function(){ + document.getElementById("filter_daydate")._flatpickr.setDate(moment(document.getElementById("filter_daydate").value).subtract(1,'day').format('YYYY-MM-DD')); + rendezvous.gettabledata(); + } +} + +let RDVFormatter = function(cell, formatterParams){ + if (cell.getValue()){ + var newcelldata = '' + cell.getValue() + ' - '+cell._cell.row.data.clientphone+'
'+cell._cell.row.data.product + return newcelldata; + } + return cell.getValue(); } \ No newline at end of file diff --git a/admin/js/modules/rendezvous_config.js b/admin/js/modules/rendezvous_config.js index e69de29..74ec257 100644 --- a/admin/js/modules/rendezvous_config.js +++ b/admin/js/modules/rendezvous_config.js @@ -0,0 +1,7 @@ +let rdvcfg = { + tbl: null, + tblexclude: null, + init: function(){ + + } +} \ No newline at end of file diff --git a/admin/js/modules/webarticle.js b/admin/js/modules/webarticle.js new file mode 100644 index 0000000..6af843b --- /dev/null +++ b/admin/js/modules/webarticle.js @@ -0,0 +1,10 @@ +let webarticle = { + current_id: null, + selects:{}, + init: function(){ + + }, + viewpanel: function(id){ + webarticle.current_id=id; + } +} \ No newline at end of file diff --git a/admin/js/modules/webarticles.js b/admin/js/modules/webarticles.js new file mode 100644 index 0000000..7b55bb4 --- /dev/null +++ b/admin/js/modules/webarticles.js @@ -0,0 +1,23 @@ +let webarticles = { + tbl: null, + selects:{}, + init: function(){ + + }, + gettabledata: function(){ + + }, + add: function(){ + + }, + edit: function(){ + + }, + confirmRemove: function(){ + + }, + remove: function(){ + + } + +} \ No newline at end of file diff --git a/admin/js/modules/webpage.js b/admin/js/modules/webpage.js new file mode 100644 index 0000000..31b3c72 --- /dev/null +++ b/admin/js/modules/webpage.js @@ -0,0 +1,12 @@ +let webpage = { + current_id: null, + tbl: null, + selects:{}, + viewpanel: function(id){ + webpage.current_id=id; + }, + init: function(){ + + }, + +} \ No newline at end of file diff --git a/admin/js/modules/webpages.js b/admin/js/modules/webpages.js new file mode 100644 index 0000000..66ac818 --- /dev/null +++ b/admin/js/modules/webpages.js @@ -0,0 +1,52 @@ +let webpages = { + tbl: null, + selects:{}, + init: function(){ + webpages.tbl = new Tabulator("#tbl_webpages",{ + height: "calc(100vh - 60px)", + layout: "fitColumns", + responsiveLayout:true, + selectable: 1, + // rowDblClick:function(e, row){ + // //e.preventDefault(); + // galleries.edit(); + // }, + rowContext:function(e, row){ e.preventDefault(); }, + columns: [ + {title: "title", field: "gallery"}, + {title: "description" , field:"description"} + ] + }); + webpages.gettabledata(); + }, + gettabledata: function(){ + postData({"cl":"webpages","fn":"getAll"}).then(data => { + webpages.tbl.setData(data.data); + }); + }, + add: function(){ + postData({"cl":"webpages","fn":"add"}).then(data => { + webpages.tbl.setData(data.data); + }); + }, + edit: function(){ + let sel = webpages.getSelectedData(); + if (sel[0]){ + webpage.viewpanel(sel[0].id); + } + }, + confirmRemove: function(){ + var sel = gallery.tbl.getSelectedData(); + //delcallback = ; + if (sel[0]) { + myapp.confirm("Supprimer cette page?","êtes vous sûre de supprimer cette Page?","oui","non","webpages.remove();"); + } + }, + remove: function(){ + var sel = webpages.tbl.getSelectedData(); + postData({"cl":"webpages","fn":"remove","id":id}).then(data => { + webpages.tbl.deselectRow(sel[0].id); + webpages.gettabledata(); + }); + } +} \ No newline at end of file diff --git a/admin/js/myapp.js b/admin/js/myapp.js index b0141a7..3e8a9cd 100644 --- a/admin/js/myapp.js +++ b/admin/js/myapp.js @@ -11,7 +11,10 @@ let myapp = { } }, logout: function() { - postData(location.href, { "logout": "1" }).then (data => { location.href = 'login.html';}); + postData({"logout":1}).then (data => { location.href = 'login.html';}).catch(err => { + console.log(err); + location.href = 'login.html'; + }); }, viewpanel: function(pnlname){ @@ -53,7 +56,7 @@ let myapp = { } }, closedlg: function(dlgid){ - document.getElementById(dlgid).style.display='none'; + document.getElementById("dlg_" + dlgid).style.display='none'; }, confirm(title,message,strbtnok,strbtncancel,action){ document.getElementById("dlgconfirm_title").innerHTML = title; @@ -69,10 +72,17 @@ let myapp = { document.getElementById('dlgmessage').style.display='block'; return false; }, - openDataLoad: function(title,message){ + openDataLoad: function(title,message,steps){ document.getElementById('dlgdataload_title').innerHTML=title; document.getElementById('dlgdataload_text').innerHTML=message; + document.getElementById('dlgdataload_progress').removeAttribute("value"); + if (steps){ + //document.getElementById('dlgdataload_progress').addAttribute("value"); + document.getElementById('dlgdataload_progress').value = 0; + document.getElementById('dlgdataload_progress').max = steps; + } document.getElementById('dlgdataload').style.display='block'; + return false; }, closeDataLoad(){ @@ -81,9 +91,11 @@ let myapp = { document.getElementById('dlgdataload').style.display='none'; return false; }, - setDataLoadMsg(msg){ + setDataLoadMsg(msg,step){ document.getElementById('dlgdataload_text').innerHTML=msg; + document.getElementById('dlgdataload_progress').value=step; } + } document.addEventListener("DOMContentLoaded", function() { moment.locale('fr'); diff --git a/admin/js/request.js b/admin/js/request.js index f28e1b7..ea9533d 100644 --- a/admin/js/request.js +++ b/admin/js/request.js @@ -20,28 +20,30 @@ async function postData(data = {}) { return response.json(); } -async function postFile(fileobjid,data = {}) { +async function postFile(fileobj,data = {}) { var mfd = new FormData(); for (var o in data){ - mfd.append(o,mfd); - } - var fileobj = document.getElementById(fileobjid); - for (let i = 0; i < fileobj.files.length; i++) { - mfd.append('file', fileobj.files[i]); + mfd.append(o,data[o]); } + //var fileobj = document.getElementById(fileobjid); + //console.log("files:",fileobj.files); + // for (let i = 0; i < fileobj.files.length; i++) { + + mfd.append('file', fileobj,fileobj.name); + // } const response = await fetch(api + 'upload.php', { method: 'POST', - mode: 'same-origin', - cache: 'no-cache', - credentials: 'same-origin', - headers: { - 'Content-Type': 'multipart/form-data' - }, - redirect: 'follow', - referrerPolicy: 'strict-origin', + // mode: 'same-origin', + // cache: 'no-cache', + // credentials: 'same-origin', + // headers: { + // 'Content-Type': undefined + // }, + // redirect: 'follow', + // referrerPolicy: 'strict-origin', body: mfd }); - + console.log(response); return response.json(); } diff --git a/admin/lib/config.php b/admin/lib/config.php index 8b61faf..f45be8c 100644 --- a/admin/lib/config.php +++ b/admin/lib/config.php @@ -5,6 +5,7 @@ "templatepath" => "tmpl/", "webdocroot" => $_SERVER["DOCUMENT_ROOT"].'/oldbell_lu/', "webmediapath" => $_SERVER["DOCUMENT_ROOT"].'/oldbell_lu/media/', + "adminmediapath" => $_SERVER["DOCUMENT_ROOT"].'/oldbelladmin/media/', "datapath" => "data/", "db"=> array( "type" => "pgsql", @@ -15,7 +16,7 @@ ), "appversion" => date("YmdHis"), "minify" => "", - "sitename" => "oldbell", + "sitename" => "oldbell.lu", "sitetemplatepath" => $_SERVER["DOCUMENT_ROOT"].'/oldbell_lu' ); diff --git a/admin/lib/database.php b/admin/lib/database.php index 68c9999..4467d05 100644 --- a/admin/lib/database.php +++ b/admin/lib/database.php @@ -2,7 +2,7 @@ class database { private $conn; private $dbconf; - private $debug=1; + private $debug=0; public function __construct($pdbconf){ $this->dbconf = $pdbconf; try { @@ -98,6 +98,30 @@ class database { return -1; } + public function createUpdateDDL($schema,$table,$idents,$data){ + $da = array(); + $di = array(); + foreach ($data as $col => $val){ + array_push($da,$col."=".$this->value($val)); + } + foreach ($idents as $col => $val){ + array_push($di,$col."=".$this->value($val)); + } + $updsql = "UPDATE ".$schema.".".$table." SET ".join(",",$da)." WHERE ".join(" AND ",$di).";"; + return $updsql; + } + + public function createInsertDDL($schema,$table,$data){ + $dc = array(); + $dv = array(); + foreach ($data as $col => $val){ + array_push($dc,$col); + array_push($dv,$this->value($val)); + } + $inssql = "INSERT INTO ".$schema.".".$table." (".join(",",$dc).") VALUES (".join(",",$dv).");"; + return $inssql; + } + public function newuuid(){ $nid = $this->query("SELECT uuid_in(md5(random()::text || clock_timestamp()::text)::cstring) as id"); return $nid["id"]; diff --git a/admin/lib/image.php b/admin/lib/image.php new file mode 100644 index 0000000..3289116 --- /dev/null +++ b/admin/lib/image.php @@ -0,0 +1,99 @@ + 72,"img_height" => 380,"img_width" => 700, "thumb_width" => 128, "thumb_height" => 128); + private $picdef= array(); + public function __construct($npicdef,$env){ + foreach ($npicdef as $key => $value){ + $this->picdef[$key] = $value["pref"]; + } + } + public function __destruct(){ + + } + public function set_picdef($npicdef){ + foreach ($npicdef as $key => $value){ + $this->picdef[$key] = $value["pref"]; + } + } + public function resize($imgfile,$outpath,$wm){ + $outfile = null; + if (!is_dir($outpath)){ + mkdir($outpath); + } + if (file_exists($imgfile)){ + $fpinfo = pathinfo($imgfile); + list($pwidth, $pheight) = getimagesize($imgfile); + $width=0; + $height =0; + $density = $this->picdef["density"]; + if ($pwidth>$this->picdef["img_width"]){ + $width = $this->picdef["img_width"]; + } elseif ($height > $this->picdef["img_height"]) { + $height = $this->picdef["img_height"]; + } + if ($height == 0){ + $height = ($pheight/$pwidth) * $width; + } + elseif ($width == 0) { + $width = ($pwidth/$pheight) * $height; + } + if ($height > $this->picdef["img_height"]){ + $height = $this->picdef["img_height"]; + $width = ($width/$height) * $height; + } + if ($outpath === null){ + $outfile = $imgfile; + $res = system("mogrify -resize ".$width."x".$height." -density ".$density." ".$imgfile); + } else { + $outfile = $outpath.'/'.$fpinfo['basename']; + error_log("convert -resize ".$width."x".$height." -density ".$density." ".$imgfile." ".$outfile); + $res = system("convert -resize ".$width."x".$height." -density ".$density." ".$imgfile." ".$outfile); + } + if (($wm !== null) && (file_exists($wm))){ + $tmpcopy = $outpath.'/'.$fpinfo['name'].".copy.".$fpinfo['extension']; + copy($outfile,$tmpcopy); + $res = system("composite -gravity ".$this->picdef["wm_gravity"]." ".$this->picdef["wm_image"]." ".$tmpcopy." ".$outfile); + unlink($tmpcopy); + } + } + return $outfile; + } + + public function createthump($imgfile,$outpath){ + $fpinfo = pathinfo($imgfile); + + $outfile = $outpath.'/thumb/'.$fpinfo['filename'].'.'.$fpinfo['extension']; + if (!id_dir($outpath.'/thumb')){ + mkdir($outpath.'/thumb'); + } + if ($imgfile == $outfile) { return null;} + + system('convert -thumbnail x'.$this->picdef['thumbwidth'].' -background black -alpha remove "'.$imgfile.'" "'.$outfile.'"'); + // if ($type == "cube"){ + // system("convert ".$imgfile." -gravity center -crop ".$this->picdef['thumbwidth']."x".$this->picdef['thumbheight']."+0+0 +repage \"".$outfile."\""); + // } + return $outfile; + } + + public function extractframefromvideo($videofile,$outpath){ + $outfile = null; + $ffmpeg= dirname($_SERVER['SCRIPT_FILENAME']).'/tools/ffmpeg/ffmpeg'; + if (!is_dir($outpath)){ + mkdir($outpath); + } + + if (file_exists($videofile)){ + $vfinfo=pathinfo($videofile); + $outfile=$outpath.'/'.$vfinfo['basename'].'.png'; + if (file_exists($outfile)){ + unlink($oufile); + } + system($ffmpeg." -ss ".$this->picdef["video_extract_start"]." -i ".$videofile." -frames:v ".$this->picdef["video_extract_frames"]." ".$outfile); + //convert input.mp4[1] thumbnail.png + } + return $outfile; + } + +} +?> \ No newline at end of file diff --git a/admin/lib/modules/templates.php b/admin/lib/modules/.templates.php similarity index 100% rename from admin/lib/modules/templates.php rename to admin/lib/modules/.templates.php diff --git a/admin/lib/modules/webmenu.php b/admin/lib/modules/.webmenu.php similarity index 96% rename from admin/lib/modules/webmenu.php rename to admin/lib/modules/.webmenu.php index b8aa838..65f5a29 100644 --- a/admin/lib/modules/webmenu.php +++ b/admin/lib/modules/.webmenu.php @@ -1,5 +1,5 @@ dbh = $dblink; diff --git a/admin/lib/modules/Gallery.php b/admin/lib/modules/Gallery.php index cfabcc7..08575a2 100644 --- a/admin/lib/modules/Gallery.php +++ b/admin/lib/modules/Gallery.php @@ -1,59 +1,108 @@ dbh = $dblink; + $this->cfg = $cfg; } - public function getGalleries(){ + public function getAll(){ $sql = "select * from galleries"; return $this->dbh->queryarray($sql); } - public function getGallery($id){ + public function get($id){ $sql = "select * from galleries where id='".$id."'"; return $this->dbh->query($sql); } - public function getGalleryItems($id){ + public function getItems($id){ $sql = "select * from galleryitems where id_gallery='".$id."'"; return $this->dbh->queryarray($sql); } - public function addgallery(){ - + public function addItem($filename,$idgallery){ + $gld = $this->dbh->query("select id,link from galleries where id=".$this->dbh->value($idgallery).";"); + $filepath = $this->cfg["adminmediapath"].'galleries/'.$gld["link"].'/'.$filename; + if (file_exists($filepath)){ + $mt = mime_content_type($filepath); + $newitemid = $this->dbh->newuuid(); + $thumbname = $filename; + if (strpos($mt,'image/') !== 0){ + $findo =pathinfo($filename); + $thumbname=$finfo["basename"].'.png'; + } + $data = array("id" => $newitemid,"id_gallery" => $gld["id"],"filename" => $filename,"filetype" => $mt,"thumnname" => $thumbname); + $inssql = $this->dbh->createInsertDDL("public","galleryitems",$data); + $this->dbh->exec($inssql); + $this->setItemCopies($newitemid); + } else { + return 0; + } + return 1; } - public function duplicateGallery($id){ + public function setDefaultImage($idgallery,$id){ } - public function removeGallery($id){ - - } - - public function updateGallery($id,$data){ - + private function setItemCopies($id){ + $gld = $this->dbh->query("SELECT gi.filename,g.link,gi.filetype,gi.thumbname from public.galleries g join public.galleryitems gi on (g.id=gi.id_gallery) where gi.id=".$this->dbh->value($id).";"); + $imgopts = $this->dbh->querybykey("id","select id,pref from defaultdata where category='gallery';"); + $img = new image($imgopts); + $filepath = $this->cfg["adminmediapath"]."galleries/".$gld["link"]."/".$gld["filename"]; + $adminoutpath = $this->cfg["adminmediapath"]."galleries/".$gld["link"]; + $weboutpath = $this->cfg["webmediapath"]."galleries/".$gld["link"]; + if (strpos($gld["filetype"],'video/') === 0){ + $newfile = $img->extractframefromvideo($filepath,$adminoutpath); + $filepath = $newfile; + } + $img->resize($filepath,$weboutpath,$this->cfg["adminmediapath"]."galleries/wm.png"); + $img->createthumb($filepath,$adminoutpath); + $img->createthumb($filepath,$weboutpath); + return 1; } - public function newItem(){ - + public function removeItem($idgallery,$id){ + $sqlfile = "SELECT gi.filename,g.link,gi.filetype,gi.thumbname from public.galleries g join public.galleryitems gi on (g.id=gi.id_gallery) where gi.id=".$this->dbh->value($id)." AND gi.id_gallery=".$this->dbh->value($idgallery).";"; + $sqldel ="DELETE FROM galleryitems WHERE id=".$this->dbh->value($id)." and id_gallery=".$this->dbh->value($idgallery).";"; + $fdata = $this->dbh->query($sqlfile); + $this->dbh->exec($sqldel); + unlink($this->cfg["adminmediapath"]."galleries/".$gld["link"]."/".$gld["filename"]); + unlink($this->cfg["adminmediapath"]."galleries/".$gld["link"]."/thumb/".$gld["thumbname"]); + unlink($this->cfg["webmediapath"]."galleries/".$gld["link"]."/".$gld["filename"]); + unlink($this->cfg["webmediapath"]."galleries/".$gld["link"]."/thumb/".$gld["thumbname"]); + return 1; } - public function setItemFile($id,$file){ - + public function updateItemData($id,$data){ + $updsql = $this->dbh->createUpdateDDL("public","galleryitems",array("id" => $this->dbh->value($id)),$data); + $this->dbh->exec($updsql); + $gi = $this->dbh->query("SELECT * from galleryitems WHERE id=".$this->dbh->value($id).";"); } - public function removeItem($id){ - + public function remove($id){ + $this->dbh->exec("DELETE FROM galleryitems where id_gallery=".$this->dbh->value($id).";"); + $gld = $this->dbh->query("select * from galleries where id=".$this->dbh->value($id).";"); + $this->dbh->exec("DELETE FROM galleries where id=".$this->dbh->value($id).";"); + $this->deleteDirectory($this->cfg["webmediapath"]."galleries/".$gld["link"]); + $this->deleteDirectory($this->cfg["adminmediapath"]."galleries/".$gld["link"]); + return 1; } - public function duplicateItem($id){ + public function update($id,$data){ } - public function updateItem($id,$data){ - + private function deleteDirectory($dir) { + if (!file_exists($dir)) {return true;} + if (!is_dir($dir)) {return unlink($dir);} + foreach (scandir($dir) as $item) { + if ($item == '.' || $item == '..') {continue;} + if (!deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) {return false;} + } + return rmdir($dir); } public function __destruct(){ diff --git a/admin/lib/modules/RendezVous.php b/admin/lib/modules/RendezVous.php index 7e44cb5..d1e1999 100644 --- a/admin/lib/modules/RendezVous.php +++ b/admin/lib/modules/RendezVous.php @@ -1,14 +1,57 @@ dbh = $dblink; + $this->cfg = $cfg; } - public function __destruct(){ $this->dbh = null; } + public function getRDVByDay($daydate){ + $sql = "select tm.daydate,tm.rdvtime,clientname,product,clientphone,isconfirmed,iscanceled from ( + select date(rdvtime) as daydate,to_char(rdvtime,'HH24:MI') as rdvtime from ( + select generate_series(date('".$daydate."') + starttime::interval,date('".$daydate."') + endtime::interval,timesteps) as rdvtime + from rendezvoushours where date_part('isodow',date('".$daydate."')) = weekday) altm + ) tm + left join ( + select daydate,to_char(timestart,'HH24:MI') as timestart,clientname,clientphone,product,isconfirmed,iscanceled from rendezvous where daydate=date('2020-11-16')) rdv + on (tm.daydate=rdv.daydate and rdv.timestart=tm.rdvtime)"; + return $this->dbh->queryarray($sql); + } + + public function get($id){ + return $this->dbh->query("select * from rendezvous where id=".$this->dbh->value($id).";"); + } + + public function add($data){ + $data["id"] = $this->dbh->newuuid(); + $sql = $this->dbh->createInsertDDL("public","rendezvous",$data); + $this->dbh->exec($sql); + return array("id" => $data["id"]); + } + + public function delete($id){ + $this->dbh->exec("DELETE from rendezvous where id=".$this->dbh->value($id).";"); + return 1; + } + } +/*select calweek,max(mon) as mon,max(tue) as tue,max(wed) as wed,max(thu) as thu,max(fri) as fri,max(sat) as sat,max(sun) as sun from ( + select calweek, + case when dow = 1 then daydate else null end as mon, + case when dow = 2 then daydate else null end as tue, + case when dow = 3 then daydate else null end as wed, + case when dow = 4 then daydate else null end as thu, + case when dow = 5 then daydate else null end as fri, + case when dow = 6 then daydate else null end as sat, + case when dow = 7 then daydate else null end as sun from ( + select date_part('year',generate_series) || '-' || date_part('week',generate_series) as calweek , + date_part('isodow',generate_series) as dow, + date(generate_series) as daydate + from pg_catalog.generate_series(date('2020-12-01'),date('2020-12-01') + interval '1 month' - interval '1 day','1 day') + ) monthdays) monthweeks group by calweek order by calweek;*/ ?> \ No newline at end of file diff --git a/admin/lib/modules/WebArticles.php b/admin/lib/modules/WebArticles.php index e69de29..6312661 100644 --- a/admin/lib/modules/WebArticles.php +++ b/admin/lib/modules/WebArticles.php @@ -0,0 +1,13 @@ +dbh = $dblink; + $this->cfg = $cfg; + } + public function __destruct(){ + $this->dbh = null; + } +} +?> \ No newline at end of file diff --git a/admin/lib/modules/orders.php b/admin/lib/modules/orders.php new file mode 100644 index 0000000..070f3b4 --- /dev/null +++ b/admin/lib/modules/orders.php @@ -0,0 +1,26 @@ +dbh = $dblink; + $this->cfg = $cfg; + } + public function __destruct(){ + $this->dbh = null; + } + + public function add(){ + + } + + public function remove(){ + + } + + public function duplicate(){ + + } + +} +?> \ No newline at end of file diff --git a/admin/lib/modules/products.php b/admin/lib/modules/products.php new file mode 100644 index 0000000..705a9c9 --- /dev/null +++ b/admin/lib/modules/products.php @@ -0,0 +1,41 @@ +dbh = $dblink; + $this->cfg = $cfg; + } + public function __destruct(){ + $this->dbh = null; + } + + public function getAll(){ + return $this->dbh->queryarray("select * from products;"); + } + + public function get($id){ + return $this->dbh->query("select * from products where id=".$this->dbh->value($id).";"); + } + + public function add(){ + $tblvals = array("id" => $this->dbh->newuuid(),"product" => "nouveau produit"); + $sql = $this->dbh->createInsertDDL("public","products",$tblvals); + $this->dbh->exec($sql); + return array("id" => $tblvals["id"]); + } + + public function delete($id){ + $this->dbh->exec("DELETE from products where id=".$this->dbh->value($id).";"); + return 1; + } + + public function duplicate($id){ + $copydata = $this->dbh->query("select * from products where id=".$this->dbh->value($id).";"); + $copydata["id"] = $this->dbh->newuuid(); + $sql = $this->dbh->createInsertDDL("public","products",$copydata); + $this->dbh->exec($sql); + return array("id" => $copydata["id"]); + } +} +?> \ No newline at end of file diff --git a/admin/lib/modules/users.php b/admin/lib/modules/users.php new file mode 100644 index 0000000..b0040c5 --- /dev/null +++ b/admin/lib/modules/users.php @@ -0,0 +1,37 @@ +dbh = $dblink; + $this->cfg = $cfg; + } + public function __destruct(){ + $this->dbh = null; + } + public function getAll(){ + return $this->dbh->queryarray("select * from users;"); + } + + public function get($id){ + return $this->dbh->query("select * from users where id=".$this->dbh->value($id).";"); + } + + public function checkusername($username){ + return $this->dbh->query("select count(*) as found from users where username=".$this->dbh->value($usernme).";"); + } + + public function add($username){ + $tblvals = array("id" => $this->dbh->newuuid(),"username" => $this->dbh->securetext($username)); + $sql = $this->dbh->createInsertDDL("public","users",$tblvals); + $this->dbh->exec($sql); + return array("id" => $tblvals["id"]); + } + + public function delete($id){ + $this->dbh->exec("DELETE from users where id=".$this->dbh->value($id).";"); + return 1; + } + +} +?> \ No newline at end of file diff --git a/admin/lib/modules/websites.php b/admin/lib/modules/websites.php index 470e86b..7450e84 100644 --- a/admin/lib/modules/websites.php +++ b/admin/lib/modules/websites.php @@ -1,12 +1,16 @@ dbh = $dblink; + $this->cfg = $cfg; + } + public function __destruct(){ + $this->dbh = null; } - public function addWebsite($id){ - + } public function updateWebsite($id,$data){ @@ -20,10 +24,6 @@ public function duplicateWebsite($id){ } - - - public function __destruct(){ - $this->dbh = null; - } + } ?> \ No newline at end of file diff --git a/admin/lib/session.php b/admin/lib/session.php index c9b467f..ec7ec78 100644 --- a/admin/lib/session.php +++ b/admin/lib/session.php @@ -29,6 +29,11 @@ class session { return null; } + public function deleteSession($sid){ + $this->dbh->exec("DELETE FROM public.sessions where id=".$this->dbh->value($sid).";"); + return 1; + } + public function __destruct(){ $this->conn = null; } diff --git a/admin/tmpl/elements/dialogs/dataload.html.mustache b/admin/tmpl/elements/dialogs/dataload.html.mustache index 6d0e7d4..312b8d8 100644 --- a/admin/tmpl/elements/dialogs/dataload.html.mustache +++ b/admin/tmpl/elements/dialogs/dataload.html.mustache @@ -8,7 +8,7 @@ Attentez s.v.p.!
- +