diff --git a/classes/erlhcoreclasscbschedulervalidation.php b/classes/erlhcoreclasscbschedulervalidation.php index e6741fb..213a34d 100644 --- a/classes/erlhcoreclasscbschedulervalidation.php +++ b/classes/erlhcoreclasscbschedulervalidation.php @@ -419,6 +419,9 @@ public static function validateSchedule($item, $params) { 'description' => new ezcInputFormDefinitionElement( ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw' ), + 'terms_agree' => new ezcInputFormDefinitionElement( + ezcInputFormDefinitionElement::OPTIONAL, 'boolean' + ), 'email' => new ezcInputFormDefinitionElement( ezcInputFormDefinitionElement::OPTIONAL, 'validate_email' ), @@ -465,6 +468,16 @@ public static function validateSchedule($item, $params) { $item->attempt = $form->attempt; } + if ($form->hasValidData( 'terms_agree' ) && $form->terms_agree == true) { + $item->terms_agree = $form->terms_agree; + } else { + $cbOptions = erLhcoreClassModelChatConfig::fetch('lhcbscheduler_options'); + $data = (array)$cbOptions->data; + if (isset($data['terms_of_service']) && $data['terms_of_service'] != '') { + $Errors['terms_of_service'] = erTranslationClassLhTranslation::getInstance()->getTranslation('module/cbscheduler','You have to agree to our terms of service.'); + } + } + if ( !$form->hasValidData( 'username' ) || $form->username == '' ) { $Errors['username'] = erTranslationClassLhTranslation::getInstance()->getTranslation('module/cbscheduler','Please enter a username'); } elseif ($form->hasValidData( 'username' )) { diff --git a/design/cbschedulertheme/js/cbscheduler.legacy.js b/design/cbschedulertheme/js/cbscheduler.legacy.js index c3c0830..8319480 100644 --- a/design/cbschedulertheme/js/cbscheduler.legacy.js +++ b/design/cbschedulertheme/js/cbscheduler.legacy.js @@ -82,7 +82,7 @@ var th = document.getElementsByTagName('head')[0]; // Insert CSS - var srcCSS = WWW_DIR_LHC_WEBPACK_ADMIN.replace('/design/defaulttheme/js/admin/dist/','') + '/extension/cbscheduler/design/cbschedulertheme/css/cbscheduler.css?v=5'; + var srcCSS = WWW_DIR_LHC_WEBPACK_ADMIN.replace('/design/defaulttheme/js/admin/dist/','') + '/extension/cbscheduler/design/cbschedulertheme/css/cbscheduler.css?v=6'; var styleSheet = document.createElement("link"); styleSheet.setAttribute('rel',"stylesheet"); @@ -91,7 +91,7 @@ th.appendChild(styleSheet); // Insert JS - var src = WWW_DIR_LHC_WEBPACK_ADMIN.replace('/design/defaulttheme/js/admin/dist/','') + '/extension/cbscheduler/design/cbschedulertheme/js/scheduler/dist/react.cbscheduler.app.js?v=5'; + var src = WWW_DIR_LHC_WEBPACK_ADMIN.replace('/design/defaulttheme/js/admin/dist/','') + '/extension/cbscheduler/design/cbschedulertheme/js/scheduler/dist/react.cbscheduler.app.js?v=6'; var s = document.createElement('script'); s.setAttribute('type','text/javascript'); diff --git a/design/cbschedulertheme/js/cbscheduler.widget.js b/design/cbschedulertheme/js/cbscheduler.widget.js index adf5505..c974d06 100644 --- a/design/cbschedulertheme/js/cbscheduler.widget.js +++ b/design/cbschedulertheme/js/cbscheduler.widget.js @@ -93,7 +93,7 @@ var th = document.getElementsByTagName('head')[0]; // Insert CSS - var srcCSS = window.lhcChat['staticJS']['chunk_js'].replace('/design/defaulttheme/js/widgetv2','') + '/extension/cbscheduler/design/cbschedulertheme/css/cbscheduler.css?v=5'; + var srcCSS = window.lhcChat['staticJS']['chunk_js'].replace('/design/defaulttheme/js/widgetv2','') + '/extension/cbscheduler/design/cbschedulertheme/css/cbscheduler.css?v=6'; var styleSheet = document.createElement("link"); styleSheet.setAttribute('rel',"stylesheet"); @@ -102,7 +102,7 @@ th.appendChild(styleSheet); // Insert JS - var src = window.lhcChat['staticJS']['chunk_js'].replace('/design/defaulttheme/js/widgetv2','') + '/extension/cbscheduler/design/cbschedulertheme/js/scheduler/dist/react.cbscheduler.app.js?v=5'; + var src = window.lhcChat['staticJS']['chunk_js'].replace('/design/defaulttheme/js/widgetv2','') + '/extension/cbscheduler/design/cbschedulertheme/js/scheduler/dist/react.cbscheduler.app.js?v=6'; var s = document.createElement('script'); s.setAttribute('type','text/javascript'); diff --git a/design/cbschedulertheme/js/scheduler/dist/2.087582c6c82538517b9c.js b/design/cbschedulertheme/js/scheduler/dist/2.087582c6c82538517b9c.js deleted file mode 100644 index 2019e6e..0000000 --- a/design/cbschedulertheme/js/scheduler/dist/2.087582c6c82538517b9c.js +++ /dev/null @@ -1 +0,0 @@ -(window.webpackJsonpLHCReactAPPCBScheduler=window.webpackJsonpLHCReactAPPCBScheduler||[]).push([[2],{58:function(e,t,a){"use strict";a.r(t);var l=a(2),n=a.n(l),c=a(17),s=a.n(c),r=a(0),i=a.n(r),m=a(31),o=a.n(m),u=a(53),d=a(59);t.default=function(e){var t,a=Object(r.useState)([]),l=s()(a,2),c=l[0],m=l[1],f=Object(r.useState)([]),b=s()(f,2),h=b[0],p=b[1],v=Object(r.useState)([]),E=s()(v,2),g=E[0],N=E[1],j=Object(r.useState)([]),O=s()(j,2),_=O[0],y=O[1],S=Object(r.useState)(null),C=s()(S,2),w=C[0],k=C[1],z=Object(r.useState)(null),x=s()(z,2),T=x[0],F=x[1],V=Object(r.useState)(null),D=s()(V,2),L=D[0],M=D[1],P=Object(r.useState)(""!=e.username&&null!=e.username&&"Visitor"!=e.username&&"undefined"!=e.username?e.username:null),A=s()(P,2),B=A[0],H=A[1],J=Object(r.useState)(""!=e.subject&&null!=e.subject?e.subject:null),R=s()(J,2),Y=R[0],I=R[1],Q=Object(r.useState)(""!=e.description&&null!=e.description?e.description:null),U=s()(Q,2),Z=U[0],q=U[1],G=Object(r.useState)(""!=e.phone&&null!=e.phone?e.phone:null),K=s()(G,2),W=K[0],X=K[1],$=Object(r.useState)(""!=e.email&&null!=e.email?e.email:null),ee=s()($,2),te=ee[0],ae=ee[1],le=Object(r.useState)(null),ne=s()(le,2),ce=ne[0],se=ne[1],re=Object(r.useState)(e.dep_id),ie=s()(re,2),me=ie[0],oe=ie[1],ue=Object(r.useState)(!1),de=s()(ue,2),fe=de[0],be=(de[1],Object(r.useState)(!1)),he=s()(be,2),pe=he[0],ve=he[1],Ee=Object(r.useState)(!1),ge=s()(Ee,2),Ne=ge[0],je=ge[1],Oe=Object(r.useState)(null),_e=s()(Oe,2),ye=_e[0],Se=_e[1],Ce=Object(r.useState)(null),we=s()(Ce,2),ke=we[0],ze=we[1],xe=Object(r.useState)(null),Te=s()(xe,2),Fe=Te[0],Ve=Te[1],De=Object(r.useState)(!1),Le=s()(De,2),Me=Le[0],Pe=Le[1],Ae=Object(r.useState)(0),Be=s()(Ae,2),He=Be[0],Je=Be[1],Re=function(){e.ee.emitEvent("endCheduler",[e])},Ye=Object(r.useState)(function(){try{var e=Intl.DateTimeFormat().resolvedOptions().timeZone;return"undefined"==e&&(e="UTC"),e}catch(e){Date.prototype.stdTimezoneOffset=function(){var e=new Date(this.getFullYear(),0,1),t=new Date(this.getFullYear(),6,1);return Math.max(e.getTimezoneOffset(),t.getTimezoneOffset())},Date.prototype.dst=function(){return this.getTimezoneOffset()0&&i.a.createElement("div",{className:"form-group"},i.a.createElement("select",(t={className:"form-control form-control-sm",defaultValue:L},n()(t,"className","form-control form-control-sm"+(_.time?" is-invalid":"")),n()(t,"onChange",(function(e){return M(e.target.value)})),t),i.a.createElement("option",{value:""},qe("fields.choose_time")),h.map((function(e){return i.a.createElement("option",{value:e.id},e.name)}))),_.time&&i.a.createElement("div",{className:"invalid-feedback"},_.time)),T&&0==h.length&&i.a.createElement("div",{className:"form-group"},i.a.createElement("i",{className:"material-icons"},"")," ",qe("fields.loading")),w&&i.a.createElement("div",{className:"alert alert-danger",role:"alert"},w),i.a.createElement("div",{className:"form-group mb-0"},i.a.createElement("button",{type:"button",disabled:fe||pe,className:"btn btn-sm btn-secondary",onClick:function(){return ve(!0),void o.a.post(e.base_path+"cbscheduler/schedulecb",Ue()).then((function(e){y([]),k(null),1==e.data.error?(ve(!1),e.data.messages&&(y(e.data.messages),e.data.messages.errorModal&&Je(He+1)),e.data.message&&k(e.data.message)):(Se(e.data.data),je(!0))}))}},pe&&i.a.createElement("i",{className:"material-icons"},"")," ",qe("fields.schedule_callback"))))))}}}]); \ No newline at end of file diff --git a/design/cbschedulertheme/js/scheduler/dist/2.b9f82863aa68881b56cf.js b/design/cbschedulertheme/js/scheduler/dist/2.b9f82863aa68881b56cf.js new file mode 100644 index 0000000..782f9c2 --- /dev/null +++ b/design/cbschedulertheme/js/scheduler/dist/2.b9f82863aa68881b56cf.js @@ -0,0 +1 @@ +(window.webpackJsonpLHCReactAPPCBScheduler=window.webpackJsonpLHCReactAPPCBScheduler||[]).push([[2],{58:function(e,t,a){"use strict";a.r(t);var l=a(2),n=a.n(l),c=a(17),s=a.n(c),r=a(0),i=a.n(r),m=a(31),o=a.n(m),d=a(53),u=a(59);t.default=function(e){var t,a=Object(r.useState)([]),l=s()(a,2),c=l[0],m=l[1],f=Object(r.useState)([]),b=s()(f,2),h=b[0],p=b[1],v=Object(r.useState)([]),E=s()(v,2),g=E[0],N=E[1],_=Object(r.useState)([]),j=s()(_,2),O=j[0],S=j[1],y=Object(r.useState)(null),k=s()(y,2),C=k[0],w=k[1],x=Object(r.useState)(null),z=s()(x,2),T=z[0],F=z[1],V=Object(r.useState)(null),D=s()(V,2),L=D[0],M=D[1],P=Object(r.useState)(""!=e.username&&null!=e.username&&"Visitor"!=e.username&&"undefined"!=e.username?e.username:null),A=s()(P,2),B=A[0],H=A[1],J=Object(r.useState)(""!=e.subject&&null!=e.subject?e.subject:null),R=s()(J,2),Y=R[0],I=R[1],Q=Object(r.useState)(""!=e.description&&null!=e.description?e.description:null),U=s()(Q,2),Z=U[0],q=U[1],G=Object(r.useState)(""!=e.phone&&null!=e.phone?e.phone:null),K=s()(G,2),W=K[0],X=K[1],$=Object(r.useState)(""!=e.email&&null!=e.email?e.email:null),ee=s()($,2),te=ee[0],ae=ee[1],le=Object(r.useState)(null),ne=s()(le,2),ce=ne[0],se=ne[1],re=Object(r.useState)(e.dep_id),ie=s()(re,2),me=ie[0],oe=ie[1],de=Object(r.useState)(null),ue=s()(de,2),fe=ue[0],be=ue[1],he=Object(r.useState)(!1),pe=s()(he,2),ve=pe[0],Ee=(pe[1],Object(r.useState)(!1)),ge=s()(Ee,2),Ne=ge[0],_e=ge[1],je=Object(r.useState)(!1),Oe=s()(je,2),Se=Oe[0],ye=Oe[1],ke=Object(r.useState)(null),Ce=s()(ke,2),we=Ce[0],xe=Ce[1],ze=Object(r.useState)(null),Te=s()(ze,2),Fe=Te[0],Ve=Te[1],De=Object(r.useState)(null),Le=s()(De,2),Me=Le[0],Pe=Le[1],Ae=Object(r.useState)(!1),Be=s()(Ae,2),He=Be[0],Je=Be[1],Re=Object(r.useState)(!1),Ye=s()(Re,2),Ie=Ye[0],Qe=Ye[1],Ue=Object(r.useState)(0),Ze=s()(Ue,2),qe=Ze[0],Ge=Ze[1],Ke=function(){e.ee.emitEvent("endCheduler",[e])},We=Object(r.useState)(function(){try{var e=Intl.DateTimeFormat().resolvedOptions().timeZone;return"undefined"==e&&(e="UTC"),e}catch(e){Date.prototype.stdTimezoneOffset=function(){var e=new Date(this.getFullYear(),0,1),t=new Date(this.getFullYear(),6,1);return Math.max(e.getTimezoneOffset(),t.getTimezoneOffset())},Date.prototype.dst=function(){return this.getTimezoneOffset()0&&i.a.createElement("div",{className:"form-group"},i.a.createElement("select",(t={className:"form-control form-control-sm",defaultValue:L},n()(t,"className","form-control form-control-sm"+(O.time?" is-invalid":"")),n()(t,"onChange",(function(e){return M(e.target.value)})),t),i.a.createElement("option",{value:""},at("fields.choose_time")),h.map((function(e){return i.a.createElement("option",{value:e.id},e.name)}))),O.time&&i.a.createElement("div",{className:"invalid-feedback"},O.time)),T&&0==h.length&&i.a.createElement("div",{className:"form-group"},i.a.createElement("i",{className:"material-icons"},"")," ",at("fields.loading")),C&&i.a.createElement("div",{className:"alert alert-danger",role:"alert"},C),fe&&i.a.createElement("div",{className:"form-check form-check-sm pb-2"},i.a.createElement("input",{type:"checkbox",id:"id-terms-of-service",className:"form-check-input"+(O.terms_of_service?" is-invalid":""),onChange:function(e){return Qe(e.target.checked)}}),i.a.createElement("label",{className:"form-check-label",for:"id-terms-of-service"}," ",i.a.createElement("small",null,fe)),O.terms_of_service&&i.a.createElement("div",{className:"invalid-feedback font-weight-bold"},O.terms_of_service)),i.a.createElement("div",{className:"form-group mb-0"},i.a.createElement("button",{type:"button",disabled:ve||Ne,className:"btn btn-sm btn-secondary",onClick:function(){return _e(!0),void o.a.post(e.base_path+"cbscheduler/schedulecb",et()).then((function(e){S([]),w(null),1==e.data.error?(_e(!1),e.data.messages&&(S(e.data.messages),e.data.messages.errorModal&&Ge(qe+1)),e.data.message&&w(e.data.message)):(xe(e.data.data),ye(!0))}))}},Ne&&i.a.createElement("i",{className:"material-icons"},"")," ",at("fields.schedule_callback"))))))}}}]); \ No newline at end of file diff --git a/design/cbschedulertheme/js/scheduler/dist/react.cbscheduler.app.js b/design/cbschedulertheme/js/scheduler/dist/react.cbscheduler.app.js index 8b5cc3a..391c55d 100644 --- a/design/cbschedulertheme/js/scheduler/dist/react.cbscheduler.app.js +++ b/design/cbschedulertheme/js/scheduler/dist/react.cbscheduler.app.js @@ -1,4 +1,4 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.LHCReactAPPCBScheduler=t():e.LHCReactAPPCBScheduler=t()}(window,(function(){return function(e){function t(t){for(var n,i,o=t[0],a=t[1],l=0,s=[];l { const [email, setEmail] = useState((props.email != '' && props.email != null) ? props.email : null); const [countries, setCountries] = useState(null); const [department, setDepartment] = useState(props.dep_id); + const [termsOfService, setTermsOfService] = useState(null); + // logical attributes const [isDisabled, setDisabled] = useState(false); @@ -36,6 +38,7 @@ const CBScheduler = props => { const [defaultCountry, setDefaultCountry] = useState(null); const [logo, setLogo] = useState(null); const [isLoaded, setLoaded] = useState(false); + const [isTermsAgree, setTermsOfServiceAgree] = useState(false); const [attempt, setAttempt] = useState(0); const onClose = () => { @@ -93,6 +96,10 @@ const CBScheduler = props => { setCountries(result.data.countries); } + if (result.data.terms_of_service) { + setTermsOfService(result.data.terms_of_service); + } + if (department === null) { setDepartment(result.data.department); } @@ -121,7 +128,8 @@ const CBScheduler = props => { 'email':email, 'day':day, 'time':time, - 'attempt': attempt + 'attempt': attempt, + 'terms_agree': isTermsAgree, }; } @@ -190,7 +198,7 @@ const CBScheduler = props => { var logoFormated =
{logo !== null &&
} -
{t('fields.schedule_title')}
+
{t('fields.schedule_title')}
{props.mode == 'widget' &&
}
; @@ -314,6 +322,14 @@ const CBScheduler = props => { {error} } + {termsOfService &&
+ setTermsOfServiceAgree(e.target.checked)} /> + + {errors.terms_of_service &&
+ {errors.terms_of_service} +
} +
} +
diff --git a/design/cbschedulertheme/tpl/lhcbscheduler/options.tpl.php b/design/cbschedulertheme/tpl/lhcbscheduler/options.tpl.php index b69b848..1225948 100644 --- a/design/cbschedulertheme/tpl/lhcbscheduler/options.tpl.php +++ b/design/cbschedulertheme/tpl/lhcbscheduler/options.tpl.php @@ -48,6 +48,11 @@ +
+ + +
+
diff --git a/modules/lhcbscheduler/getdays.php b/modules/lhcbscheduler/getdays.php index da8714a..9a04634 100644 --- a/modules/lhcbscheduler/getdays.php +++ b/modules/lhcbscheduler/getdays.php @@ -69,11 +69,14 @@ 'email' => $email, ]; +$cbOptions = erLhcoreClassModelChatConfig::fetch('lhcbscheduler_options'); +$data = (array)$cbOptions->data; -if (is_numeric($department)) { - $cbOptions = erLhcoreClassModelChatConfig::fetch('lhcbscheduler_options'); - $data = (array)$cbOptions->data; +if (isset($data['terms_of_service']) && $data['terms_of_service'] != '') { + $responseArray['terms_of_service'] = $data['terms_of_service']; +} +if (is_numeric($department)) { $allowArray = []; if (isset($data['allow_countries']) && !empty($data['allow_countries'])) { $pairs = explode("\n",trim(strtoupper($data['allow_countries']))); diff --git a/modules/lhcbscheduler/options.php b/modules/lhcbscheduler/options.php index 2676b8c..7026fad 100644 --- a/modules/lhcbscheduler/options.php +++ b/modules/lhcbscheduler/options.php @@ -26,6 +26,9 @@ 'exclude_countries' => new ezcInputFormDefinitionElement( ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw' ), + 'terms_of_service' => new ezcInputFormDefinitionElement( + ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw' + ), 'unique' => new ezcInputFormDefinitionElement( ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw',null,FILTER_REQUIRE_ARRAY ) @@ -46,6 +49,12 @@ $data['allow_countries'] = ''; } + if ( $form->hasValidData( 'terms_of_service' )) { + $data['terms_of_service'] = $form->terms_of_service; + } else { + $data['terms_of_service'] = ''; + } + if ( $form->hasValidData( 'exclude_countries' )) { $data['exclude_countries'] = $form->exclude_countries; } else {