����JFIFXX�����    $.' ",#(7),01444'9=82<.342  2!!22222222222222222222222222222222222222222222222222����"��4�� ���,�PG"Z_�4�˷����kjز�Z�,F+��_z�,�© �����zh6�٨�ic�fu���#ډb���_�N�?��wQ���5-�~�I���8����TK<5o�Iv-�����k�_U_�����~b�M��d����Ӝ�U�Hh��?]��E�w��Q���k�{��_}qFW7HTՑ��Y��F�?_�'ϔ��_�Ջt��=||I ��6�έ"�����D���/[�k�9���Y�8ds|\���Ҿp6�Ҵ���]��.����6�z<�v��@]�i%��$j��~�g��J>��no����pM[me�i$[����s�o�ᘨ�˸ nɜG-�ĨU�ycP�3.DB�li�;��hj���x7Z^�N�h������N3u{�:j�x�힞��#M&��jL P@_���� P��&��o8������9�����@Sz6�t7#O�ߋ �s}Yf�T���lmr����Z)'N��k�۞p����w\�Tȯ?�8`�O��i{wﭹW�[�r�� ��Q4F�׊���3m&L�=��h3����z~��#�\�l :�F,j@�� ʱ�wQT����8�"kJO���6�֚l����}���R�>ډK���]��y����&����p�}b��;N�1�m�r$�|��7�>e�@B�TM*-iH��g�D�)� E�m�|�ؘbҗ�a��Ҿ����t4���o���G��*oCN�rP���Q��@z,|?W[0�����:�n,jWiE��W��$~/�hp\��?��{(�0���+�Y8rΟ�+����>S-S����VN;�}�s?.����� w�9��˟<���Mq4�Wv'��{)0�1mB��V����W[�����8�/<� �%���wT^�5���b��)iM� pg�N�&ݝ��VO~�q���u���9� ����!��J27����$O-���! �:�%H��� ـ����y�ΠM=t{!S�� oK8������t<����è:a������[�����ա�H���~��w��Qz`�po�^ ����Q��n� �,uu�C�$ ^���,������8�#��:�6��e�|~���!�3�3.�\0��q��o�4`.|� ����y�Q�`~;�d�ׯ,��O�Zw�������`73�v�܋�<���Ȏ�� ـ4k��5�K�a�u�=9Yd��$>x�A�&�� j0� ���vF��� Y�|�y��� ~�6�@c��1vOp�Ig����4��l�OD���L����� R���c���j�_�uX6��3?nk��Wy�f;^*B� ��@�~a�`��Eu������+���6�L��.ü>��}y���}_�O�6�͐�:�YrG�X��kG�����l^w���~㒶sy��Iu�!� W ��X��N�7BV��O��!X�2����wvG�R�f�T#�����t�/?���%8�^�W�aT��G�cL�M���I��(J����1~�8�?aT ���]����AS�E��(��*E}� 2��#I/�׍qz��^t�̔���b�Yz4x���t�){ OH��+(E��A&�N�������XT��o��"�XC��'���)}�J�z�p� ��~5�}�^����+�6����w��c��Q�|Lp�d�H��}�(�.|����k��c4^�"�����Z?ȕ ��a<�L�!039C� �Eu�C�F�Ew�ç ;�n?�*o���B�8�bʝ���'#Rqf���M}7����]����s2tcS{�\icTx;�\��7K���P���ʇ Z O-��~��c>"��?�������P��E��O�8��@�8��G��Q�g�a�Վ���󁶠�䧘��_%#r�>�1�z�a��eb��qcPѵ��n���#L��� =��׀t� L�7�`��V���A{�C:�g���e@�w1 Xp3�c3�ġ����p��M"'-�@n4���fG��B3�DJ�8[Jo�ߐ���gK)ƛ��$���� ���8�3�����+���� �����6�ʻ���� ���S�kI�*KZlT _`���?��K����QK�d����B`�s}�>���`��*�>��,*@J�d�oF*����弝��O}�k��s��]��y�ߘ��c1G�V���<=�7��7����6�q�PT��tXԀ�!9*4�4Tހ3XΛex�46���Y��D ����� �BdemDa����\�_l,��G�/���֌7���Y�](�xTt^%�GE�����4�}bT���ڹ�����;Y)���B�Q��u��>J/J �⮶.�XԄ��j�ݳ�+E��d ��r�5�_D�1 ��o�� �B�x�΢�#���<��W�����8���R6�@g�M�.��� dr�D��>(otU��@x=��~v���2� ӣ�d�oBd��3�eO�6�㣷�����ݜ6��6Y��Qz`��S��{���\P�~z m5{J/L��1������<�e�ͅPu�b�]�ϔ���'������f�b� Zpw��c`"��i���BD@:)ִ�:�]��hv�E�w���T�l��P���"Ju�}��وV J��G6��. J/�Qgl߭�e�����@�z�Zev2u�)]կ�����7x���s�M�-<ɯ�c��r�v�����@��$�ޮ}lk���a���'����>x��O\�ZFu>�����ck#��&:��`�$�ai�>2Δ����l���oF[h��lE�ܺ�Πk:)���`�� $[6�����9�����kOw�\|���8}������ބ:��񶐕��I�A1/�=�2[�,�!��.}gN#�u����b��� ~��݊��}34q����d�E��Lc��$��"�[q�U�硬g^��%B �z���r�pJ�ru%v\h1Y�ne`ǥ:g���pQM~�^�Xi� ��`S�:V29.�P���V�?B�k�� AEvw%�_�9C�Q����wKekPؠ�\�;Io d�{ ߞo�c1eP����\� `����E=���@K<�Y���eڼ�J���w����{av�F�'�M�@/J��+9p���|]�����Iw &`��8���&M�hg��[�{��Xj��%��Ӓ�$��(����ʹN���<>�I���RY���K2�NPlL�ɀ)��&e����B+ь����( � �JTx���_?EZ� }@ 6�U���뙢ط�z��dWI�n` D����噥�[��uV��"�G&Ú����2g�}&m��?ċ�"����Om#��������� ��{�ON��"S�X��Ne��ysQ���@Fn��Vg���dX�~nj�]J�<�K]:��FW��b�������62�=��5f����JKw��bf�X�55��~J �%^����:�-�QIE��P��v�nZum� z � ~ə ���� ���ة����;�f��\v���g�8�1��f24;�V���ǔ�)����9���1\��c��v�/'Ƞ�w�������$�4�R-��t���� e�6�/�ġ �̕Ecy�J���u�B���<�W�ַ~�w[B1L۲�-JS΂�{���΃������A��20�c#��@ 0!1@AP"#2Q`$3V�%45a6�FRUq��� ����^7ׅ,$n�������+��F�`��2X'��0vM��p�L=������5��8������u�p~���.�`r�����\���O��,ư�0oS ��_�M�����l���4�kv\JSd���x���SW�<��Ae�IX����������$I���w�:S���y���›R��9�Q[���,�5�;�@]�%���u�@ *ro�lbI �� ��+���%m:�͇ZV�����u�̉����θau<�fc�.����{�4Ա� �Q����*�Sm��8\ujqs]{kN���)qO�y�_*dJ�b�7���yQqI&9�ԌK!�M}�R�;������S�T���1���i[U�ɵz�]��U)V�S6���3$K{�ߊ<�(� E]Զ[ǼENg�����'�\?#)Dkf��J���o��v���'�%ƞ�&K�u�!��b�35LX�Ϸ��63$K�a�;�9>,R��W��3�3� d�JeTYE.Mϧ��-�o�j3+y��y^�c�������VO�9NV\nd�1 ��!͕_)a�v;����թ�M�lWR1��)El��P;��yوÏ�u 3�k�5Pr6<�⒲l�!˞*��u־�n�!�l:����UNW ��%��Chx8vL'��X�@��*��)���̮��ˍ��� ���D-M�+J�U�kvK����+�x8��cY������?�Ԡ��~3mo��|�u@[XeY�C�\Kp�x8�oC�C�&����N�~3-H���� ��MX�s�u<`���~"WL��$8ξ��3���a�)|:@�m�\���^�`�@ҷ)�5p+��6���p�%i)P M���ngc�����#0Aruz���RL+xSS?���ʮ}()#�t��mˇ!��0}}y����<�e� �-ή�Ԩ��X������ MF���ԙ~l L.3���}�V뽺�v�����멬��Nl�)�2����^�Iq��a��M��qG��T�����c3#������3U�Ǎ���}��לS�|qa��ڃ�+���-��2�f����/��bz��ڐ�� �ݼ[2�ç����k�X�2�* �Z�d���J�G����M*9W���s{��w���T��x��y,�in�O�v��]���n����P�$�JB@=4�OTI�n��e�22a\����q�d���%�$��(���:���: /*�K[PR�fr\nڙdN���F�n�$�4�[�� U�zƶ����� �mʋ���,�ao�u 3�z� �x��Kn����\[��VFmbE;�_U��&V�Gg�]L�۪&#n%�$ɯ�dG���D�TI=�%+AB�Ru#��b4�1�»x�cs�YzڙJG��f��Il��d�eF'T� iA��T���uC�$����Y��H?����[!G`}���ͪ� �纤Hv\������j�Ex�K���!���OiƸ�Yj�+u-<���'q����uN�*�r\��+�]���<�wOZ.fp�ێ��,-*)V?j-kÊ#�`�r��dV����(�ݽBk�����G�ƛk�QmUڗe��Z���f}|����8�8��a���i��3'J�����~G_�^���d�8w������ R�`(�~�.��u���l�s+g�bv���W���lGc}��u���afE~1�Ue������Z�0�8�=e�� f@/�jqEKQQ�J��oN��J���W5~M>$6�Lt�;$ʳ{���^��6�{����v6���ķܰg�V�cnn �~z�x�«�,2�u�?cE+Ș�H؎�%�Za�)���X>uW�Tz�Nyo����s���FQƤ��$��*�&�LLXL)�1�" L��eO��ɟ�9=���:t��Z���c��Ž���Y?�ӭV�wv�~,Y��r�ۗ�|�y��GaF�����C�����.�+� ���v1���fήJ�����]�S��T��B��n5sW}y�$��~z�'�c ��8 ��� ,! �p��VN�S��N�N�q��y8z˱�A��4��*��'������2n<�s���^ǧ˭P�Jޮɏ�U�G�L�J�*#��<�V��t7�8����TĜ>��i}K%,���)[��z�21z ?�N�i�n1?T�I�R#��m-�����������������1����lA�`��fT5+��ܐ�c�q՝��ʐ��,���3�f2U�եmab��#ŠdQ�y>\��)�SLY����w#��.���ʑ�f��� ,"+�w�~�N�'�c�O�3F�������N<���)j��&��,-� �љ���֊�_�zS���TǦ����w�>��?�������n��U仆�V���e�����0���$�C�d���rP �m�׈e�Xm�Vu� �L��.�bֹ��� �[Դaզ���*��\y�8�Է:�Ez\�0�Kq�C b��̘��cө���Q��=0Y��s�N��S.���3.���O�o:���#���v7�[#߫ ��5�܎�L���Er4���9n��COWlG�^��0k�%<���ZB���aB_���������'=��{i�v�l�$�uC���mƎҝ{�c㱼�y]���W�i ��ߧc��m�H� m�"�"�����;Y�ߝ�Z�Ǔ�����:S#��|}�y�,/k�Ld� TA�(�AI$+I3��;Y*���Z��}|��ӧO��d�v��..#:n��f>�>���ȶI�TX��� 8��y����"d�R�|�)0���=���n4��6ⲑ�+��r<�O�܂~zh�z����7ܓ�HH�Ga롏���nCo�>������a ���~]���R���̲c?�6(�q�;5%� |�uj�~z8R=X��I�V=�|{v�Gj\gc��q����z�؋%M�ߍ����1y��#��@f^���^�>N�����#x#۹��6�Y~�?�dfPO��{��P�4��V��u1E1J �*|���%���JN��`eWu�zk M6���q t[�� ��g�G���v��WIG��u_ft����5�j�"�Y�:T��ɐ���*�;� e5���4����q$C��2d�}���� _S�L#m�Yp��O�.�C�;��c����Hi#֩%+) �Ӎ��ƲV���SYź��g |���tj��3�8���r|���V��1#;.SQ�A[���S������#���`n�+���$��$I �P\[�@�s��(�ED�z���P��])8�G#��0B��[ى��X�II�q<��9�~[Z멜�Z�⊔IWU&A>�P~�#��dp<�?����7���c��'~���5 ��+$���lx@�M�dm��n<=e�dyX��?{�|Aef ,|n3�<~z�ƃ�uۧ�����P��Y,�ӥQ�*g�#먙R�\���;T��i,��[9Qi歉����c>]9�� ��"�c��P�� �Md?٥��If�ت�u��k��/����F��9�c*9��Ǎ:�ØF���z�n*�@|I�ށ9����N3{'��[�'ͬ�Ҳ4��#}��!�V� Fu��,�,mTIk���v C�7v���B�6k�T9��1�*l� '~��ƞF��lU��'�M ����][ΩũJ_�{�i�I�n��$���L�� j��O�dx�����kza۪��#�E��Cl����x˘�o�����V���ɞ�ljr��)�/,�߬h�L��#��^��L�ф�,íMƁe�̩�NB�L�����iL����q�}��(��q��6IçJ$�W�E$��:������=#����(�K�B����zђ <��K(�N�۫K�w��^O{!����)�H���>x�������lx�?>Պ�+�>�W���,Ly!_�D���Ō�l���Q�!�[ �S����J��1��Ɛ�Y}��b,+�Lo�x�ɓ)����=�y�oh�@�꥟/��I��ѭ=��P�y9��� �ۍYӘ�e+�p�Jnϱ?V\SO%�(�t� ���=?MR�[Ș�����d�/ ��n�l��B�7j� ��!�;ӥ�/�[-���A�>�dN�sLj ��,ɪv��=1c�.SQ�O3�U���ƀ�ܽ�E����������̻��9G�ϷD�7(�}��Ävӌ\�y�_0[w ���<΍>����a_��[0+�L��F.�޺��f�>oN�T����q;���y\��bՃ��y�jH�<|q-eɏ�_?_9+P���Hp$�����[ux�K w�Mw��N�ی'$Y2�=��q���KB��P��~������Yul:�[<����F1�2�O���5=d����]Y�sw:���Ϯ���E��j,_Q��X��z`H1,#II ��d�wr��P˂@�ZJV����y$�\y�{}��^~���[:N����ߌ�U�������O��d�����ؾe��${p>G��3c���Ė�lʌ�� ת��[��`ϱ�-W����dg�I��ig2��� ��}s ��ؤ(%#sS@���~���3�X�nRG�~\jc3�v��ӍL��M[JB�T��s3}��j�Nʖ��W����;7��ç?=X�F=-�=����q�ߚ���#���='�c��7���ڑW�I(O+=:uxq�������������e2�zi+�kuG�R��������0�&e�n���iT^J����~\jy���p'dtG��s����O��3����9* �b#Ɋ�� p������[Bws�T�>d4�ۧs���nv�n���U���_�~,�v����ƜJ1��s�� �QIz��)�(lv8M���U=�;����56��G���s#�K���MP�=��LvyGd��}�VwWBF�'�à �?MH�U�g2�� ����!�p�7Q��j��ڴ����=��j�u��� Jn�A s���uM������e��Ɔ�Ҕ�!)'��8Ϣ�ٔ��ޝ(��Vp���צ֖d=�IC�J�Ǡ{q������kԭ�߸���i��@K����u�|�p=..�*+����x�����z[Aqġ#s2a�Ɗ���RR�)*HRsi�~�a &f��M��P����-K�L@��Z��Xy�'x�{}��Zm+���:�)�) IJ�-i�u���� ���ܒH��'�L(7�y�GӜq���� j��� 6ߌg1�g�o���,kر���tY�?W,���p���e���f�OQS��!K�۟cҒA�|ս�j�>��=⬒��˧L[�� �߿2JaB~R��u�:��Q�] �0H~���]�7��Ƽ�I���(}��cq '�ήET���q�?f�ab���ӥvr� �)o��-Q��_'����ᴎo��K������;��V���o��%���~OK ����*��b�f:���-ťIR��`B�5!RB@���ï�� �u �̯e\�_U�_������� g�ES��3�������QT��a����x����U<~�c?�*�#]�MW,[8O�a�x��]�1bC|踤�P��lw5V%�)�{t�<��d��5���0i�XSU��m:��Z�┵�i�"��1�^B�-��P�hJ��&)O��*�D��c�W��vM��)����}���P��ܗ-q����\mmζZ-l@�}��a��E�6��F�@��&Sg@���ݚ�M����� ȹ 4����#p�\H����dYDo�H���"��\��..R�B�H�z_�/5˘����6��KhJR��P�mƶi�m���3�,#c�co��q�a)*Pt����R�m�k�7x�D�E�\Y�閣_X�<���~�)���c[[�BP����6�Yq���S��0����%_����;��Àv�~�| VS؇ ��'O0��F0��\���U�-�d@�����7�SJ*z��3n��y��P����O���������m�~�P�3|Y��ʉr#�C�<�G~�.,! ���bqx���h~0=��!ǫ�jy����l�O,�[B��~��|9��ٱ����Xly�#�i�B��g%�S��������tˋ���e���ې��\[d�t)��.+u�|1 ������#�~Oj����hS�%��i.�~X���I�H�m��0n���c�1uE�q��cF�RF�o���7� �O�ꮧ� ���ۛ{��ʛi5�rw?׌#Qn�TW��~?y$��m\�\o����%W� ?=>S�N@�� �Ʈ���R����N�)�r"C�:��:����� �����#��qb��Y�. �6[��2K����2u�Ǧ�HYR��Q�MV��� �G�$��Q+.>�����nNH��q�^��� ����q��mM��V��D�+�-�#*�U�̒ ���p욳��u:�������IB���m���PV@O���r[b= �� ��1U�E��_Nm�yKbN�O���U�}�the�`�|6֮P>�\2�P�V���I�D�i�P�O;�9�r�mAHG�W�S]��J*�_�G��+kP�2����Ka�Z���H�'K�x�W�MZ%�O�YD�Rc+o��?�q��Ghm��d�S�oh�\�D�|:W������UA�Qc yT�q������~^�H��/��#p�CZ���T�I�1�ӏT����4��"�ČZ�����}��`w�#�*,ʹ�� ��0�i��課�Om�*�da��^gJ݅{���l�e9uF#T�ֲ��̲�ٞC"�q���ߍ ոޑ�o#�XZTp����@ o�8��(jd��xw�]�,f���`~�|,s��^����f�1���t��|��m�򸄭/ctr��5s��7�9Q�4�H1꠲BB@l9@���C�����+�wp�xu�£Yc�9��?`@#�o�mH�s2��)�=��2�.�l����jg�9$�Y�S�%*L������R�Y������7Z���,*=�䷘$�������arm�o�ϰ���UW.|�r�uf����IGw�t����Zwo��~5 ��YյhO+=8fF�)�W�7�L9lM�̘·Y���֘YLf�큹�pRF���99.A �"wz��=E\Z���'a� 2��Ǚ�#;�'}�G���*��l��^"q��+2FQ� hj��kŦ��${���ޮ-�T�٭cf�|�3#~�RJ����t��$b�(R��(����r���dx� >U b�&9,>���%E\� Ά�e�$��'�q't��*�א���ެ�b��-|d���SB�O�O��$�R+�H�)�܎�K��1m`;�J�2�Y~9��O�g8=vqD`K[�F)k�[���1m޼c��n���]s�k�z$@��)!I �x՝"v��9=�ZA=`Ɠi �:�E��)`7��vI��}d�YI�_ �o�:ob���o ���3Q��&D&�2=�� �Ά��;>�h����y.*ⅥS������Ӭ�+q&����j|UƧ����}���J0��WW< ۋS�)jQR�j���Ư��rN)�Gű�4Ѷ(�S)Ǣ�8��i��W52���No˓� ۍ%�5brOn�L�;�n��\G����=�^U�dI���8$�&���h��'���+�(������cȁ߫k�l��S^���cƗjԌE�ꭔ��gF���Ȓ��@���}O���*;e�v�WV���YJ\�]X'5��ղ�k�F��b 6R�o՜m��i N�i����>J����?��lPm�U��}>_Z&�KK��q�r��I�D�Չ~�q�3fL�:S�e>���E���-G���{L�6p�e,8��������QI��h��a�Xa��U�A'���ʂ���s�+טIjP�-��y�8ۈZ?J$��W�P� ��R�s�]��|�l(�ԓ��sƊi��o(��S0��Y� 8�T97.�����WiL��c�~�dxc�E|�2!�X�K�Ƙਫ਼�$((�6�~|d9u+�qd�^3�89��Y�6L�.I�����?���iI�q���9�)O/뚅����O���X��X�V��ZF[�یgQ�L��K1���RҖr@v�#��X�l��F���Нy�S�8�7�kF!A��sM���^rkp�jP�DyS$N���q��nxҍ!U�f�!eh�i�2�m���`�Y�I�9r�6� �TF���C}/�y�^���Η���5d�'��9A-��J��>{�_l+�`��A���[�'��յ�ϛ#w:݅�%��X�}�&�PSt�Q�"�-��\縵�/����$Ɨh�Xb�*�y��BS����;W�ջ_mc�����vt?2}1�;qS�d�d~u:2k5�2�R�~�z+|HE!)�Ǟl��7`��0�<�,�2*���Hl-��x�^����'_TV�gZA�'j� ^�2Ϊ��N7t�����?w�� �x1��f��Iz�C-Ȗ��K�^q�;���-W�DvT�7��8�Z�������� hK�(P:��Q- �8�n�Z���܃e貾�<�1�YT<�,�����"�6{/ �?�͟��|1�:�#g��W�>$����d��J��d�B��=��jf[��%rE^��il:��B���x���Sּ�1հ��,�=��*�7 fcG��#q� �eh?��2�7�����,�!7x��6�n�LC�4x��},Geǝ�tC.��vS �F�43��zz\��;QYC,6����~;RYS/6���|2���5���v��T��i����������mlv��������&� �nRh^ejR�LG�f���? �ۉҬܦƩ��|��Ȱ����>3����!v��i�ʯ�>�v��オ�X3e���_1z�Kȗ\<������!�8���V��]��?b�k41�Re��T�q��mz��TiOʦ�Z��Xq���L������q"+���2ۨ��8}�&N7XU7Ap�d�X��~�׿��&4e�o�F��� �H����O���č�c�� 懴�6���͉��+)��v;j��ݷ�� �UV�� i��� j���Y9GdÒJ1��詞�����V?h��l����l�cGs�ځ�������y�Ac�����\V3�? �� ܙg�>qH�S,�E�W�[�㺨�uch�⍸�O�}���a��>�q�6�n6����N6�q������N ! 1AQaq�0@����"2BRb�#Pr���3C`��Scst���$4D���%Td�� ?���N����a��3��m���C���w��������xA�m�q�m���m������$����4n淿t'��C"w��zU=D�\R+w�p+Y�T�&�պ@��ƃ��3ޯ?�Aﶂ��aŘ���@-�����Q�=���9D��ռ�ѻ@��M�V��P��܅�G5�f�Y<�u=,EC)�<�Fy'�"�&�չ�X~f��l�KԆV��?�� �W�N����=(� �;���{�r����ٌ�Y���h{�١������jW����P���Tc�����X�K�r��}���w�R��%��?���E��m�� �Y�q|����\lEE4���r���}�lsI�Y������f�$�=�d�yO����p�����yBj8jU�o�/�S��?�U��*������ˍ�0������u�q�m [�?f����a�� )Q�>����6#������� ?����0UQ����,IX���(6ڵ[�DI�MNލ�c&���υ�j\��X�R|,4��� j������T�hA�e��^���d���b<����n�� �즇�=!���3�^�`j�h�ȓr��jẕ�c�,ٞX����-����a�ﶔ���#�$��]w�O��Ӫ�1y%��L�Y<�wg#�ǝ�̗`�x�xa�t�w��»1���o7o5��>�m뭛C���Uƃߜ}�C���y1Xνm�F8�jI���]����H���ۺиE@I�i;r�8ӭ����V�F�Շ| ��&?�3|x�B�MuS�Ge�=Ӕ�#BE5G�����Y!z��_e��q�р/W>|-�Ci߇�t�1ޯќd�R3�u��g�=0 5��[?�#͏��q�cf���H��{ ?u�=?�?ǯ���}Z��z���hmΔ�BFTW�����<�q�(v� ��!��z���iW]*�J�V�z��gX֧A�q�&��/w���u�gYӘa���; �i=����g:��?2�dž6�ى�k�4�>�Pxs����}������G�9��3 ���)gG�R<>r h�$��'nc�h�P��Bj��J�ҧH� -��N1���N��?��~��}-q!=��_2hc�M��l�vY%UE�@|�v����M2�.Y[|y�"Eï��K�ZF,�ɯ?,q�?v�M 80jx�"�;�9vk�����+ ֧�� �ȺU��?�%�vcV��mA�6��Qg^M����A}�3�nl� QRN�l8�kkn�'�����(��M�7m9و�q���%ޟ���*h$Zk"��$�9��: �?U8�Sl��,,|ɒ��xH(ѷ����Gn�/Q�4�P��G�%��Ա8�N��!� �&�7�;���eKM7�4��9R/%����l�c>�x;������>��C�:�����t��h?aKX�bhe�ᜋ^�$�Iհ �hr7%F$�E��Fd���t��5���+�(M6�t����Ü�UU|zW�=a�Ts�Tg������dqP�Q����b'�m���1{|Y����X�N��b �P~��F^F:����k6�"�j!�� �I�r�`��1&�-$�Bevk:y���#yw��I0��x��=D�4��tU���P�ZH��ڠ底taP��6����b>�xa����Q�#� WeF��ŮNj�p�J* mQ�N����*I�-*�ȩ�F�g�3 �5��V�ʊ�ɮ�a��5F���O@{���NX��?����H�]3��1�Ri_u��������ѕ�� ����0��� F��~��:60�p�͈�S��qX#a�5>���`�o&+�<2�D����: �������ڝ�$�nP���*)�N�|y�Ej�F�5ټ�e���ihy�Z �>���k�bH�a�v��h�-#���!�Po=@k̆IEN��@��}Ll?j�O������߭�ʞ���Q|A07x���wt!xf���I2?Z��<ץ�T���cU�j��]��陎Ltl �}5�ϓ��$�,��O�mˊ�;�@O��jE��j(�ا,��LX���LO���Ц�90�O �.����a��nA���7������j4 ��W��_ٓ���zW�jcB������y՗+EM�)d���N�g6�y1_x��p�$Lv:��9�"z��p���ʙ$��^��JԼ*�ϭ����o���=x�Lj�6�J��u82�A�H�3$�ٕ@�=Vv�]�'�qEz�;I˼��)��=��ɯ���x �/�W(V���p�����$ �m�������u�����񶤑Oqˎ�T����r��㠚x�sr�GC��byp�G��1ߠ�w e�8�$⿄����/�M{*}��W�]˷.�CK\�ުx���/$�WPw���r� |i���&�}�{�X� �>��$-��l���?-z���g����lΆ���(F���h�vS*���b���߲ڡn,|)mrH[���a�3�ר�[1��3o_�U�3�TC�$��(�=�)0�kgP���� ��u�^=��4 �WYCҸ:��vQ�ר�X�à��tk�m,�t*��^�,�}D*� �"(�I��9R����>`�`��[~Q]�#af��i6l��8���6�:,s�s�N6�j"�A4���IuQ��6E,�GnH��zS�HO�uk�5$�I�4��ؤ�Q9�@��C����wp�BGv[]�u�Ov���0I4���\��y�����Q�Ѹ��~>Z��8�T��a��q�ޣ;z��a���/��S��I:�ܫ_�|������>=Z����8:�S��U�I�J��"IY���8%b8���H��:�QO�6�;7�I�S��J��ҌAά3��>c���E+&jf$eC+�z�;��V����� �r���ʺ������my�e���aQ�f&��6�ND��.:��NT�vm�<- u���ǝ\MvZY�N�NT��-A�>jr!S��n�O 1�3�Ns�%�3D@���`������ܟ 1�^c<���� �a�ɽ�̲�Xë#�w�|y�cW�=�9I*H8�p�^(4���՗�k��arOcW�tO�\�ƍR��8����'�K���I�Q�����?5�>[�}��yU�ײ -h��=��% q�ThG�2�)���"ו3]�!kB��*p�FDl�A���,�eEi�H�f�Ps�����5�H:�Փ~�H�0Dت�D�I����h�F3�������c��2���E��9�H��5�zԑ�ʚ�i�X�=:m�xg�hd(�v����׊�9iS��O��d@0ڽ���:�p�5�h-��t�&���X�q�ӕ,��ie�|���7A�2���O%P��E��htj��Y1��w�Ѓ!����  ���� ࢽ��My�7�\�a�@�ţ�J �4�Ȼ�F�@o�̒?4�wx��)��]�P��~�����u�����5�����7X ��9��^ܩ�U;Iꭆ 5 �������eK2�7(�{|��Y׎ �V��\"���Z�1� Z�����}��(�Ǝ"�1S���_�vE30>���p;� ΝD��%x�W�?W?v����o�^V�i�d��r[��/&>�~`�9Wh��y�;���R��� ;;ɮT��?����r$�g1�K����A��C��c��K��l:�'��3 c�ﳯ*"t8�~l��)���m��+U,z��`(�>yJ�?����h>��]��v��ЍG*�{`��;y]��I�T� ;c��NU�fo¾h���/$���|NS���1�S�"�H��V���T���4��uhǜ�]�v;���5�͠x��'C\�SBpl���h}�N����� A�Bx���%��ޭ�l��/����T��w�ʽ]D�=����K���ž�r㻠l4�S�O?=�k �M:� ��c�C�a�#ha���)�ѐxc�s���gP�iG��{+���x���Q���I= �� z��ԫ+ �8"�k�ñ�j=|����c ��y��CF��/��*9ж�h{ �?4�o� ��k�m�Q�N�x��;�Y��4膚�a�w?�6�>e]�����Q�r�:����g�,i"�����ԩA�*M�<�G��b�if��l^M��5� �Ҩ�{����6J��ZJ�����P�*�����Y���ݛu�_4�9�I8�7���������,^ToR���m4�H��?�N�S�ѕw��/S��甍�@�9H�S�T��t�ƻ���ʒU��*{Xs�@����f�����֒Li�K{H�w^���������Ϥm�tq���s� ���ք��f:��o~s��g�r��ט� �S�ѱC�e]�x���a��) ���(b-$(�j>�7q�B?ӕ�F��hV25r[7 Y� }L�R��}����*sg+��x�r�2�U=�*'WS��ZDW]�WǞ�<��叓���{�$�9Ou4��y�90-�1�'*D`�c�^o?(�9��u���ݐ��'PI&� f�Jݮ�������:wS����jfP1F:X �H�9dԯ���˝[�_54 �}*;@�ܨ�� ð�yn�T���?�ןd�#���4rG�ͨ��H�1�|-#���Mr�S3��G�3�����)�.᧏3v�z֑��r����$G"�`j �1t��x0<Ɔ�Wh6�y�6��,œ�Ga��gA����y��b��)��h�D��ß�_�m��ü �gG;��e�v��ݝ�nQ� ��C����-�*��o���y�a��M��I�>�<���]obD��"�:���G�A��-\%LT�8���c�)��+y76���o�Q�#*{�(F�⽕�y����=���rW�\p���۩�c���A���^e6��K������ʐ�cVf5$�'->���ՉN"���F�"�UQ@�f��Gb~��#�&�M=��8�ט�JNu9��D��[̤�s�o�~������ G��9T�tW^g5y$b��Y'��س�Ǵ�=��U-2 #�MC�t(�i� �lj�@Q 5�̣i�*�O����s�x�K�f��}\��M{E�V�{�υ��Ƈ�����);�H����I��fe�Lȣr�2��>��W�I�Ȃ6������i��k�� �5�YOxȺ����>��Y�f5'��|��H+��98pj�n�.O�y�������jY��~��i�w'������l�;�s�2��Y��:'lg�ꥴ)o#'Sa�a�K��Z� �m��}�`169�n���"���x��I ��*+� }F<��cГ���F�P�������ֹ*�PqX�x۩��,� ��N�� �4<-����%����:��7����W���u�`����� $�?�I��&����o��o��`v�>��P��"��l���4��5'�Z�gE���8���?��[�X�7(��.Q�-��*���ތL@̲����v��.5���[��=�t\+�CNܛ��,g�SQnH����}*F�G16���&:�t��4ُ"A��̣��$�b �|����#rs��a�����T�� ]�<�j��BS�('$�ɻ� �wP;�/�n��?�ݜ��x�F��yUn�~mL*-�������Xf�wd^�a�}��f�,=t�׵i�.2/wpN�Ep8�OР���•��R�FJ� 55TZ��T �ɭ�<��]��/�0�r�@�f��V��V����Nz�G��^���7hZi����k��3�,kN�e|�vg�1{9]_i��X5y7� 8e]�U����'�-2,���e"����]ot�I��Y_��n�(JҼ��1�O ]bXc���Nu�No��pS���Q_���_�?i�~�x h5d'�(qw52] ��'ޤ�q��o1�R!���`ywy�A4u���h<קy���\[~�4�\ X�Wt/� 6�����n�F�a8��f���z �3$�t(���q��q�x��^�XWeN'p<-v�!�{�(>ӽDP7��ո0�y)�e$ٕv�Ih'Q�EA�m*�H��RI��=:��� ���4牢) �%_iN�ݧ�l]� �Nt���G��H�L��� ɱ�g<���1V�,�J~�ٹ�"K��Q�� 9�HS�9�?@��k����r�;we݁�]I�!{ �@�G�[�"��`���J:�n]�{�cA�E����V��ʆ���#��U9�6����j�#Y�m\��q�e4h�B�7��C�������d<�?J����1g:ٳ���=Y���D�p�ц� ׈ǔ��1�]26؜oS�'��9�V�FVu�P�h�9�xc�oq�X��p�o�5��Ա5$�9W�V(�[Ak�aY錎qf;�'�[�|���b�6�Ck��)��#a#a˙��8���=äh�4��2��C��4tm^ �n'c���]GQ$[Wҿ��i���vN�{Fu ��1�gx��1┷���N�m��{j-,��x�� Ūm�ЧS�[�s���Gna���䑴�� x�p 8<������97�Q���ϴ�v�aϚG��Rt�Һ׈�f^\r��WH�JU�7Z���y)�vg=����n��4�_)y��D'y�6�]�c�5̪�\� �PF�k����&�c;��cq�$~T�7j ���nç]�<�g ":�to�t}�159�<�/�8������m�b�K#g'I'.W�����6��I/��>v��\�MN��g���m�A�yQL�4u�Lj�j9��#44�t��l^�}L����n��R��!��t��±]��r��h6ٍ>�yҏ�N��fU�� ���� Fm@�8}�/u��jb9������he:A�y�ծw��GpΧh�5����l}�3p468��)U��d��c����;Us/�֔�YX�1�O2��uq�s��`hwg�r~�{ R��mhN��؎*q 42�*th��>�#���E����#��Hv�O����q�}�����6�e��\�,Wk�#���X��b>��p}�դ��3���T5��†��6��[��@�P�y*n��|'f�֧>�lư΂�̺����SU�'*�q�p�_S�����M�� '��c�6�����m�� ySʨ;M��r���Ƌ�m�Kxo,���Gm�P��A�G�:��i��w�9�}M(�^�V��$ǒ�ѽ�9���|���� �a����J�SQ�a���r�B;����}���ٻ֢�2�%U���c�#�g���N�a�ݕ�'�v�[�OY'��3L�3�;,p�]@�S��{ls��X�'���c�jw�k'a�.��}�}&�� �dP�*�bK=ɍ!����;3n�gΊU�ߴmt�'*{,=SzfD� A��ko~�G�aoq�_mi}#�m�������P�Xhύ����mxǍ�΂���巿zf��Q���c���|kc�����?���W��Y�$���_Lv����l߶��c���`?����l�j�ݲˏ!V��6����U�Ђ(A���4y)H���p�Z_�x��>���e��R��$�/�`^'3qˏ�-&Q�=?��CFVR �D�fV�9��{�8g�������n�h�(P"��6�[�D���< E�����~0<@�`�G�6����Hг�cc�� �c�K.5��D��d�B���`?�XQ��2��ٿyqo&+�1^� DW�0�ꊩ���G�#��Q�nL3��c���������/��x ��1�1[y�x�პCW��C�c�UĨ80�m�e�4.{�m��u���I=��f�����0QRls9���f���������9���~f�����Ǩ��a�"@�8���ȁ�Q����#c�ic������G��$���G���r/$W�(��W���V�"��m�7�[m�A�m����bo��D� j����۳� l���^�k�h׽����� ��#� iXn�v��eT�k�a�^Y�4�BN��ĕ��0 !01@Q"2AaPq3BR������?���@4�Q�����T3,���㺠�W�[=JK�Ϟ���2�r^7��vc�:�9 �E�ߴ�w�S#d���Ix��u��:��Hp��9E!�� V 2;73|F��9Y���*ʬ�F��D����u&���y؟��^EA��A��(ɩ���^��GV:ݜDy�`��Jr29ܾ�㝉��[���E;Fzx��YG��U�e�Y�C���� ����v-tx����I�sם�Ę�q��Eb�+P\ :>�i�C'�;�����k|z�رn�y]�#ǿb��Q��������w�����(�r|ӹs��[�D��2v-%��@;�8<a���[\o[ϧw��I!��*0�krs)�[�J9^��ʜ��p1)� "��/_>��o��<1����A�E�y^�C��`�x1'ܣn�p��s`l���fQ��):�l����b>�Me�jH^?�kl3(�z:���1ŠK&?Q�~�{�ٺ�h�y���/�[��V�|6��}�KbX����mn[-��7�5q�94�������dm���c^���h� X��5��<�eޘ>G���-�}�دB�ޟ� ��|�rt�M��V+�]�c?�-#ڛ��^ǂ}���Lkr���O��u�>�-D�ry� D?:ޞ�U��ǜ�7�V��?瓮�"�#���r��չģVR;�n���/_� ؉v�ݶe5d�b9��/O��009�G���5n�W����JpA�*�r9�>�1��.[t���s�F���nQ� V 77R�]�ɫ8����_0<՜�IF�u(v��4��F�k�3��E)��N:��yڮe��P�`�1}�$WS��J�SQ�N�j�ٺ��޵�#l���ј(�5=��5�lǏmoW�v-�1����v,W�mn��߀$x�<����v�j(����c]��@#��1������Ǔ���o'��u+����;G�#�޸��v-lη��/(`i⣍Pm^���ԯ̾9Z��F��������n��1��� ��]�[��)�'������:�֪�W��FC����� �B9،!?���]��V��A�Վ�M��b�w��G F>_DȬ0¤�#�QR�[V��kz���m�w�"��9ZG�7'[��=�Q����j8R?�zf�\a�=��O�U����*oB�A�|G���2�54 �p��.w7� �� ��&������ξxGHp� B%��$g�����t�Џ򤵍z���HN�u�Я�-�'4��0��;_��3 !01"@AQa2Pq#3BR������?��ʩca��en��^��8���<�u#��m*08r��y�N"�<�Ѳ0��@\�p��� �����Kv�D��J8�Fҽ� �f�Y��-m�ybX�NP����}�!*8t(�OqѢ��Q�wW�K��ZD��Δ^e��!� ��B�K��p~�����e*l}z#9ң�k���q#�Ft�o��S�R����-�w�!�S���Ӥß|M�l޶V��!eˈ�8Y���c�ЮM2��tk���� ������J�fS����Ö*i/2�����n]�k�\���|4yX�8��U�P.���Ы[���l��@"�t�<������5�lF���vU�����W��W��;�b�cД^6[#7@vU�xgZv��F�6��Q,K�v��� �+Ъ��n��Ǣ��Ft���8��0��c�@�!�Zq s�v�t�;#](B��-�nῃ~���3g������5�J�%���O������n�kB�ĺ�.r��+���#�N$?�q�/�s�6��p��a����a��J/��M�8��6�ܰ"�*������ɗud"\w���aT(����[��F��U՛����RT�b���n�*��6���O��SJ�.�ij<�v�MT��R\c��5l�sZB>F��<7�;EA��{��E���Ö��1U/�#��d1�a�n.1ě����0�ʾR�h��|�R��Ao�3�m3 ��%�� ���28Q� ��y��φ���H�To�7�lW>����#i`�q���c����a��� �m,B�-j����݋�'mR1Ήt�>��V��p���s�0IbI�C.���1R�ea�����]H�6����������4B>��o��](��$B���m�����a�!=��?�B� K�Ǿ+�Ծ"�n���K��*��+��[T#�{E�J�S����Q�����s�5�:�U�\wĐ�f�3����܆&�)����I���Ԇw��E T�lrTf6Q|R�h:��[K�� �z��c֧�G�C��%\��_�a�84��HcO�bi��ؖV��7H �)*ģK~Xhչ0��4?�0��� �E<���}3���#���u�?�� ��|g�S�6ꊤ�|�I#Hڛ� �ա��w�X��9��7���Ŀ%�SL��y6č��|�F�a 8���b��$�sק�h���b9RAu7�˨p�Č�_\*w��묦��F ����4D~�f����|(�"m���NK��i�S�>�$d7SlA��/�²����SL��|6N�}���S�˯���g��]6��; �#�.��<���q'Q�1|KQ$�����񛩶"�$r�b:���N8�w@��8$�� �AjfG|~�9F ���Y��ʺ��Bwؒ������M:I岎�G��`s�YV5����6��A �b:�W���G�q%l�����F��H���7�������Fsv7��k�� 403WebShell
403Webshell
Server IP : 54.89.25.11  /  Your IP : 216.73.216.121
Web Server : Apache/2.4.7 (Ubuntu)
System : Linux ip-172-31-88-18 3.13.0-74-generic #118-Ubuntu SMP Thu Dec 17 22:52:10 UTC 2015 x86_64
User : www-data ( 33)
PHP Version : 5.5.9-1ubuntu4.24
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/kalemon/module-old/Application/src/Application/Controller/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/kalemon/module-old/Application/src/Application/Controller//IndexController.php
<?php

/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Application\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Session\Container;
use Secure\Model\Atb\AtbTable;
use Secure\Model\Admgrade\AdmgradeTable;
use CouponCode\Model\CouponTable;
use Secure\Model\Assignment\AssignmentTable;
use Zend\View\Model\JsonModel;
use Checkondispatch\Custom\IP2Location;
use Application\Form\BookSubscribeForm;
use Application\Form\AddCommentForm;
use Application\Model\BookSubscribeInputFilter;
use Application\Model\AddCommentInputFilter;
use Secure\Controller\Plugin\EmailPlugin;
use Secure\Model\UserManagement\UserManagementTable;
use Application\Model\AskQuestionTable;
use Secure\Form\UserManagement\UserProfileForm;
use Secure\Model\UserManagement\UserProfileInputFilter;
use Zend\Http\Client as HttpClient;
use Secure\Controller\AtbController;
use Secure\Controller\AdmGradeController;
use Aws\Sdk;
use ZipArchive;
use Checkondispatch\Custom\AbstractApplicationController;
use ScormEngineUtilities;
use ScormEngineService;
use ReportingService;
use Configuration;
use GetReportageAuth;
use FFMpeg\FFmpeg;

class IndexController extends AbstractApplicationController {

    //get adapter
    function getAdapter() {
        return $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
    }

    public function indexAction() {

        $this->redirectLoggedUser();
        $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
        $csHomePageData = $this->getHomePageCsData();
        $viewModel->setVariables(['csHomePageData' => $csHomePageData]);
        return $viewModel;
    }

    public function questionAction() {

        $this->CommonClass()->setCustomLayout($this, 'subjectLayout');
        $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
        $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
        $askquestionObj = new AskQuestionTable($dbadapter);
        // $askQuestionDetails = $askquestionObj->getQuestionDetails();
        $translator = $this->getServiceLocator()->get('translator');


        $countryTable = $this->initTable('Country\Model\CountryTable');
        $country_data = $countryTable->fetchData('t_adm_cnf_country', ['STATUS_FLAG' => 'A'], array('*'), null, true);
        $country = $translator->translate('Select Country');
        $str = '<option value="0">' . $country . '</option>';
        // $this->db->getBatches($this->container->authDetail['ORG_ID']);
        if (count($country_data)) {
            foreach ($country_data as $val) {
                $str .= '<option value="' . $val['COUNTRY_ID'] . '">' . $val['SHORT_NAME'] . '</option>';
            }
        }
        $loginUserId=$this->container->authDetail['USER_OID'];
        $request = $this->getRequest();
        $postData = $request->getPost()->toArray();
        if ($this->getRequest()->isXmlHttpRequest()) {
            //echo $postData['start'].'<pre />';  die('macro');
            $askQuestionDetails = $askquestionObj->getQuestionDetails($postData['serchText'], (int) $postData['start'], 10);
            $countaskQsnDetails = count($askQuestionDetails);
            $htmlViewPart = new ViewModel();
            $htmlViewPart->setTerminal(true)
                    ->setTemplate('application/index/questionlist')
                    ->setVariables(array('askQuestionDetails' => $askQuestionDetails,'loginUserId'=>$loginUserId));
            $htmlOutput = $this->getServiceLocator()->get('viewrenderer')->render($htmlViewPart);
            //print_r($htmlOutput); die;
            $jsonModel = new JsonModel();
            
            $jsonModel->setVariables(array('html' => $htmlOutput, 'askQsnDetails' => $countaskQsnDetails,'loginUserId'=>$loginUserId));
            return $jsonModel;
        }
        $viewModel->setVariables(array(
            "country_data" => $str
        ));
        return $viewModel;
    }

    // update like or unlike answer 
    public function updateVoteAction() {
        $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
        $askquestionObj = new AskQuestionTable($dbadapter);
        $postData = $this->getRequest()->getPost()->toArray();
        $translator = $this->getServiceLocator()->get('translator');
        if ($this->getRequest()->isXmlHttpRequest()) {
            $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
            $uId = !empty($postData['uId']) ? $postData['uId'] : '';
            $ansid = !empty($postData['ansid']) ? $postData['ansid'] : '';
            $IS_UNLIKE = !empty($postData['IS_UNLIKE']) ? $postData['IS_UNLIKE'] : '';
            $lastInsertId = $askquestionObj->insertupdatelikeorunlikeanswer($ansid, $uId, $IS_UNLIKE, 't_ae_answer_like');
            $result = ['result' => true, 'current_path_redirect' => 'Y'];
            $success = $translator->translate('Your vote have been successfully submitted.');
            $viewModel->setVariables(['data' => $result, 'success' => $success, 'target' => '#displayMessage']);
            return $viewModel;
        } else {
            die("Invalid Access");
        }
        return $result;
    }

    // update comment
    public function updatCommentAction() {
        // echo $answerId = $this->params('answerId');            
        $baseUrl = $this->getRequest()->getUri()->getScheme() . '://' . $this->getRequest()->getUri()->getHost() . $this->getRequest()->getBasePath();
        $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
        $askquestionObj = new AskQuestionTable($dbadapter);

        $config = $this->getServiceLocator()->get('config');
        $translator = $this->getServiceLocator()->get('translator');

        $postData = $this->getRequest()->getPost()->toArray();

        $htmlcontent = '';
        if ($this->getRequest()->isXmlHttpRequest()) {
            $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
            $newarray = array();
            $error = "";
            $countComment=0;
            $postData['answercomment'] = preg_replace('#<p[^>]*>(\s|&nbsp;?)*</p>#', '', $postData['answercomment']);
            $postData['answercomment'] = str_replace("&nbsp;", "", $postData['answercomment']);
            if (trim($postData['answercomment']) == '') {
                $error = $translator->translate('Please enter comment description');
            }if ($error == "" && trim($postData['answercomment']) != '') {
                $answerId = !empty($postData['answerId']) ? $postData['answerId'] : '';
                $uId = !empty($postData['uId']) ? $postData['uId'] : '';
                $answercomment = !empty($postData['answercomment']) ? $postData['answercomment'] : '';
                $newarray['ANSWER_ID'] = $answerId;
                $newarray['USER_OID'] = $uId;
                $newarray['ANS_COMMENT'] = $answercomment;
                $newarray['CREATED_ON'] = date("Y-m-d h:i:s");
                $lastInsertId = $askquestionObj->insertCommentDatas($newarray, 't_ae_answer_comment');
                $fetchCommentData = $askquestionObj->getCommentallDetailRecentData($answerId, $lastInsertId);
                if(!empty($answerId)){
                     $countComment=$askquestionObj->getCommentCount($answerId);
                 }
                // Fetch the user profile image dynamically
                $commonHelper = $this->getServiceLocator()->get('ViewHelperManager')->get('CommonHelper');
                $user_oid = $commonHelper->isLogged();
                $default_image = $baseUrl . '/images/default-user.png';
                $user_image = $commonHelper->getUserProfileImage($user_oid);
                if (!empty($user_image)) {
                    //$default_image = str_replace('https', 'http', $this->s3Link("USER/" . $user_image, $config['s3bucket']));
                    $viewHelperManager = $this->getServiceLocator()->get('ViewHelperManager'); // Getting the headTitle helper from the view helper manager 
                    $s3Link = $viewHelperManager->get('s3Link');
                    $default_image = str_replace('https', 'http', $s3Link("USER/" . $fetchCommentData[0]['PROFILE_PHOTO'], $config['s3bucket']));
                } else if (!empty($result['PROFILE_PHOTO'])) {
                    $viewHelperManager = $this->getServiceLocator()->get('ViewHelperManager'); // Getting the headTitle helper from the view helper manager 
                    $s3Link = $viewHelperManager->get('s3Link');
                    $default_image = str_replace('https', 'http', $s3Link("USER/" . $fetchCommentData[0]['PROFILE_PHOTO'], $config['s3bucket']));
                }
                if (!$config['liveurl']) {
                    $default_image = $baseUrl . '/images/default-user.png';
                }
                $createdOn = $commonHelper->time2string(time() - strtotime($fetchCommentData[0]['CREATED_ON']));
                $ago = $translator->translate('ago');
                $htmlcontent .= '<div class="forum-comments appendcomment">
                                                    <div class="forum-profile">
                                                        <figure>
                                                            <div class="avtar-circle">
                                                                <img src="' . $default_image . '" class="img-responsive">
                                                            </div>
                                                        </figure>
                                                        <div class="forum-profile-content">
                                                            <div class="forum-profile-title">' . ucfirst($fetchCommentData[0]['FIRST_NAME']) . ' ' . ucfirst($fetchCommentData[0]['LAST_NAME']) . '</div>
                                                            <div class="forum-details-list">
                                                                <ul>
                                                                    <li><i class="fa fa-clock-o pr-5"></i>' . $createdOn . ' ' . $ago . '</li>
                                                                </ul>
                                                            </div>
                                                            <div class="forum-content">
                                                                <div class="comment moredetails">' . $fetchCommentData[0]['ANS_COMMENT'] . '</div>
                                                            </div>
                                                           
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="forum-devider"></div>';
                $success = $translator->translate('You have successfully comment on your answer.!!!');
                $result = ['result' => true, 'success' => $success,'countComment'=>$countComment, 'lastInsertId' => $lastInsertId, 'htmlcontent' => $htmlcontent, 'target' => '#displayMessage', 'current_path_redirect' => 'Y'];
            } else {
                $result = ['result' => false, 'error' => $error, 'target' => '#displayMessage',];
            }
            $viewModel->setVariables(['data' => $result]);
            return $viewModel;
        } else {
            die("Invalid Access");
        }
        return $result;
    }

    // update answer
    public function updateanswerAction() {

        $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
        $askquestionObj = new AskQuestionTable($dbadapter);
        $postData = $this->getRequest()->getPost()->toArray();
        $translator = $this->getServiceLocator()->get('translator');
        if ($this->getRequest()->isXmlHttpRequest()) {
            $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
            $newarray = array();
            $error = "";
            //$postData['newAnswer'] = strip_tags($postData['newAnswer']);
            /* preg_match("/<\/?\w+((\s+\w+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)\/?>/",$postData['newAnswer'], $matches); */

            /* if($postData['newAnswer'] != strip_tags($postData['newAnswer'])) {
              $postData['newAnswer'] = strip_tags($postData['newAnswer']);
              } */
            //$postData['newAnswer'] = ($postData['newAnswer'] == strip_tags($postData['newAnswer'])) ? strip_tags($postData['newAnswer']):$postData['newAnswer'];
            //echo $postData['newAnswer'];exit;
            //echo  $postData['newAnswer'];exit;
            $postData['newAnswer'] = preg_replace('#<p[^>]*>(\s|&nbsp;?)*</p>#', '', $postData['newAnswer']);
            $postData['newAnswer'] = str_replace("&nbsp;", "", $postData['newAnswer']);
            $postData['newAnswer']=str_replace("<br>", "", $postData['newAnswer']);
            if (trim($postData['newAnswer']) == '' || empty($postData['newAnswer'])) {
                $error = $translator->translate('Please enter answer description');
            }if ($error == "" && trim($postData['newAnswer']) != '') {

                $questionId = !empty($postData['questionId']) ? $postData['questionId'] : '';
                $uId = !empty($postData['uId']) ? $postData['uId'] : '';
                $newAnswer = !empty($postData['newAnswer']) ? $postData['newAnswer'] : '';
                $newarray['ASK_ID'] = $questionId;
                $newarray['USER_OID'] = $uId;
                $newarray['ANSWER'] = $newAnswer;
                $newarray['CREATED_ON'] = date("Y-m-d h:i:s");
                $lastInsertId = $askquestionObj->insertDatas($newarray, 't_ae_answer');
                $success = $translator->translate('You have successfully posted your answer.');
                $result = ['result' => true, 'success' => $success, 'lastInsertId' => $lastInsertId, 'target' => '#displayMessage', 'current_path_redirect' => 'Y'];
            } else {
                $result = ['result' => false, 'error' => $error, 'target' => '#displayMessage',];
            }
            $viewModel->setVariables(['data' => $result]);
            return $viewModel;
        } else {
            die("Invalid Access");
        }
        return $result;
    }

    public function getStandardAction() {
        $country_id = $this->params('id');
        $conditions = array('COUNTRY_ID' => $country_id);
        $standardTable = $this->initTable('Standard\Model\StandardTable');
        $standards = $standardTable->fetchData('t_b2c_cm_cnf_standard', $conditions, array('*'), null, true);
        $translator = $this->getServiceLocator()->get('translator');
        $sel_standard = $translator->translate('Select Standard');
        $str = '<option value="0">' . $sel_standard . '</option>';

        if (count($standards)) {
            foreach ($standards as $val) {
                $str .= '<option value="' . $val['STANDARD_ID'] . '">' . $val['STANDARD_NAME'] . '</option>';
            }
        } else {
            $sel_standard = $translator->translate('Select Standard');
            $str = '<option value="0">' . $sel_standard . '</option>';
        }
        echo $str;
        die;
    }

    public function getGradeAction() {
        $standardId = $this->params('id');
        $standardTable = $this->initTable('Standard\Model\StandardTable');
        $grade = $standardTable->fetchData('t_b2c_cm_mgr_grade', ['STANDARD_ID' => $standardId], null, 'GRADE_ORDER');
        $translator = $this->getServiceLocator()->get('translator');
        $cls = $translator->translate('Select Grade');
        $str = '<option value="0">' . $cls . '</option>';
        if (count($grade)) {
            foreach ($grade as $val) {
                $str .= '<option value="' . $val['GRADE_ID'] . '" >' . $val['GRADE_NAME'] . '</option>';
            }
        } else {
            $cls = $translator->translate('Select Grade');
            $str = '<option value="0">' . $cls . '</option>';
        }
        echo $str;
        die;
    }

    public function getSubjectAction() {
        $grade_id = $this->params('id');
        $requestData = $this->getRequest()->getQuery()->toArray();
        $standardTable = $this->initTable('Standard\Model\StandardTable');
        $subjects = $standardTable->fetchData('t_b2c_cm_mgr_subject', ['GRADE_ID' => $grade_id], null, 'SUBJECT_ORDER');
        $translator = $this->getServiceLocator()->get('translator');
        $sel_subject = $translator->translate('Select Subject');
        $str = '<option value="0" >' . $sel_subject . '</option>';
        if (count($subjects)) {
            foreach ($subjects as $val) {
                $str .= '<option value="' . $val['SUBJECT_ID'] . '" >' . $val['SUBJECT_NAME'] . '</option>';
            }
        } else {
            $sel_subject = $translator->translate('Select Subject');
            $str = '<option value="0" >' . $sel_subject . '</option>';
        }
        echo $str;
        die;
    }

    public function questionDetailAction() {
        $questionId = $this->params('id');
        $this->CommonClass()->setCustomLayout($this, 'subjectLayout');
        $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
        $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
        $askquestionObj = new AskQuestionTable($dbadapter);
        $questionDetail = $askquestionObj->getQuestionDetailById($questionId);
//        echo "<pre>";
//        print_r($questionDetail);
//        die;
        $viewModel->setVariables(array(
            'questionDetail' => $questionDetail,
        ));
        return $viewModel;
    }

    function saveQsnAction() {
        $request = $this->getRequest();
        $postData = $request->getPost()->toArray();
        if ($this->getRequest()->isXmlHttpRequest()) {
            $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
            $error = "";
            if (empty($postData['title']) || empty($postData['description'])) {
                $translator = $this->getServiceLocator()->get('translator');
                $error = $translator->translate('Please enter question title and description');
            }
            if (trim($postData['title']) != '') {
                $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
                $askquestionObj = new AskQuestionTable($dbadapter);
                $resultQuesCount = $askquestionObj->selectquestion(trim($postData['title']));
                if ($resultQuesCount > 0) {
                    $translator = $this->getServiceLocator()->get('translator');
                    $error = $translator->translate('This question is already exist');
                }
            }

            if ($error == "") {
                $postData['subject_id'] = $postData['subject'];
                $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
                $askquestionObj = new AskQuestionTable($dbadapter);
                $askquestionObj->saveQsn($postData);
                $result = ['result' => true, 'current_path_redirect' => 'Y'];
            } else {
                $result = ['result' => false, 'message' => $error, 'target' => '#displayMsg',];
            }




            $viewModel->setVariables(['data' => $result]);
            return $viewModel;
        } else {
            die("Invalid Access");
        }
    }

    /////// Content Read Page ///////
    function contentreadAction() {
        $content_id = $this->params('id');
        $this->db = new AdmgradeTable($this->getAdapter());

        $ORG_ID = !empty($this->container->authDetail['ORG_ID']) ? $this->container->authDetail['ORG_ID'] : null;
        $UT_ID = !empty($this->container->authDetail['UT_ID']) ? $this->container->authDetail['UT_ID'] : "";
        $arrEnv["user_id"] = (!empty($this->container->authDetail['USER_OID'])) ? $this->container->authDetail['USER_OID'] : null;
        $arrEnv["content_id"] = $content_id;
        $inrollData = $this->db->getContentUserEnrollData($arrEnv);
        $commonHelper = $this->getServiceLocator()->get('ViewHelperManager')->get('CommonHelper');
        $sessdata = $commonHelper->getUserSessionData();

        if (empty($sessdata["UT_ID"]) && empty($ORG_ID) && empty($inrollData)) {
            //return $this->redirect()->toRoute('error-page', array('action' => 'error404'));
            return $this->redirect()->toRoute('content', array('action' => 'content', 'id' => $content_id));
        }
        $courseId = $this->db->getCourseId($content_id);
        $GetLaunchUrl = $reportpage = "";
        if (!empty($courseId) && !empty($this->container->authDetail['USER_OID'])) {
            $baseDirPath = getcwd() . '/library/'; 
            require_once($baseDirPath . "scorm/ScormEngineUtilities.php");
            require_once($baseDirPath . 'scorm/ScormEngineService.php');
            require_once($baseDirPath . 'scorm/Configuration.php');
            require_once($baseDirPath . 'scorm/ServiceRequest.php');
            require_once($baseDirPath . 'scorm/ReportingService.php');
            $config = $this->serviceLocator->get('config');
            $ServiceUrl = $config['scorm_serviceurl'];
            $SecretKey = $config['scorm_secretkey'];
            $AppId = $config['scorm_appid'];
            $Origin = ScormEngineUtilities::getCanonicalOriginString('Piron', 'Test', 'Version 2.0');
            $ScormService = new ScormEngineService($ServiceUrl, $AppId, $SecretKey, $Origin);
            $regService = $ScormService->getRegistrationService();
            $status = "Uncomplete";
            $REG_ID = $this->db->checkScormUserRegistration($courseId, $this->container->authDetail['USER_OID']);
            if (empty($REG_ID)) {
                $regId = uniqid(rand(), true);
                $learnerId = $this->container->authDetail['EMAIL_ID'];
                $learnerFirstName = $this->container->authDetail['FIRST_NAME'];
                $learnerLastName = $this->container->authDetail['LAST_NAME'];
                // Save on scorm
                $response = $regService->CreateRegistration($regId, $courseId, $learnerId, $learnerFirstName, $learnerLastName);
                // Saving data into tables
                $regArr['SCORM_COURSE_ID'] = $courseId;
                $regArr['USER_OID'] = $this->container->authDetail['USER_OID'];
                $regArr['REG_ID'] = $regId;
                $this->db->saveUserScormRegistration($regArr);
                $REG_ID = $regId;
            }

            $conf = new Configuration($config['scorm_serviceurl'], $AppId, $SecretKey);
            $srvc = new ReportingService($conf);
            $learnerId = $this->container->authDetail['EMAIL_ID'];
            $homePage = "/Reportage/reportage.php?appId=$AppId";
            $learnerPage = $homePage . "&courseId=$courseId&learnerId=$learnerId";
            $reportageAuth = $srvc->GetReportageAuth('NONAV', false);
            $reportpage = $srvc->GetReportUrl($reportageAuth, $learnerPage);
            $GetLaunchUrl = $regService->GetLaunchUrl($REG_ID, $reportpage);
        }

        $getContentdetails = $this->db->getContentDetailBycId($content_id, null);

//            if($UT_ID == 6 && $getContentdetails['CONTTYPE_ID'] == 13){
//                return $this->redirect()->toRoute('error-page', array('action' => 'error404'));                
//            }

        $authToken = "";
        if ($getContentdetails['CONTTYPE_ID'] == '13') {
            $client = new HttpClient(null, ['timeout' => 1200]);
            //$client 	= new HttpClient();
            $config = $this->getServiceLocator()->get('config');
            $atb = new AtbController();
            if ($this->container->authDetail['UT_ID'] == 6) {
                $data = $atb->apiAtbBookLogin($config, $client);
            } else {


                $data = $atb->apiAtbUserBookLogin($config, $client, $this->container->authDetail['EMAIL_ID']);
            }
            $authToken = $data['auth_token'];
        }

        $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
        $translator = $this->getServiceLocator()->get('translator');
        $this->CommonClass()->setCustomLayout($this, 'subjectLayout');
        $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
        $result = ['result' => true, 'current_path_redirect' => 'Y'];
        $ut_id = (!empty($this->container->authDetail['UT_ID'])) ? $this->container->authDetail['UT_ID'] : "";
        $user_oid = (!empty($this->container->authDetail['USER_OID'])) ? $this->container->authDetail['USER_OID'] : "";
        $viewModel->setVariables(['data' => $result, 'user_oid' => $user_oid, 'getContentdetails' => $getContentdetails, 'ut_id' => $ut_id, 'GetLaunchUrl' => $GetLaunchUrl, 'auth_token' => $authToken]);
        return $viewModel;
    }

    ////// End here ///////
    //////content page/////
    function contentAction() {
        $content_id = $this->params('id');
        $this->db = new AdmgradeTable($this->getAdapter());
        $getContentdetails = $this->db->getContentDetailBycId($content_id, null);
        //print_r($getContentdetails);
        if (empty($getContentdetails)) {
            return $this->notFoundAction();
            //return $this->redirect()->toRoute('error-page', array('action' => 'error404'));
        } else {
            if (!count($getContentdetails)) {
                return $this->redirect()->toUrl($this->returnBasePath());
            }
            $this->CommonClass()->setCustomLayout($this, 'subjectLayout');
            $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
            $request = $this->getRequest();



            $extraCheck = true;
            if (!empty($_POST["TXNID"])) {
                $extraCheck = false;
            }
            // print_r($_POST);
            /* start here paytm */
            if ($request->isPost() || !$extraCheck) {
                $config = $this->getServiceLocator()->get('config');
                $postData = $request->getPost()->toArray();
                  //print_r($postData);die;
                if ($request->isPost() || !$extraCheck) {
                    if (!empty($_POST["STATUS"]) && $_POST["STATUS"] != 'TXN_SUCCESS') {

                        $this->container->failtrans = 1;
                        return $this->redirect()->toRoute('content', array('action' => 'content', 'id' => $content_id));
                    }

                    // if amount is greater then 0 then send user to paypal site
                    if ($postData['amount'] > 0.01 && $postData['subscription_type'] != 'R') {
                        if (!isset($_POST["TXNID"])) {
                            //Paytm payment code block
                            $baseDirPath = getcwd() . '/library/';
                            // following files need to be included
                            require_once($baseDirPath . "paytm/lib/config_paytm.php");
                            require_once($baseDirPath . "paytm/lib/encdec_paytm.php");
                            header("Pragma: no-cache");
                            header("Cache-Control: no-cache");
                            header("Expires: 0");
                            $couponId=$postData['couponId'];
                            $orderID = $content_id . "ORDS" . rand(10000, 99999999)."ORDS".$couponId; 
                            $postData['orderID'] = $orderID;

                            $checkSum = "";
                            $paramList = array();
                            $ORDER_ID = $postData['orderID'];
                            $CUST_ID = 'USR' . $this->container->authDetail['USER_OID'];
                            $INDUSTRY_TYPE_ID = 'Retail'; // THIS WILL BE PROVIDED BY PAYTM
                            $CHANNEL_ID = 'WEB';
                            $TXN_AMOUNT = $_POST["amount"];


                            //ORDER_DETAILS/CUST_ID
                            // Create an array having all required parameters for creating checksum.
                            $paramList["MID"] = PAYTM_MERCHANT_MID;
                            $paramList["ORDER_ID"] = $ORDER_ID;
                            $paramList["CUST_ID"] = $CUST_ID;
                            $paramList["INDUSTRY_TYPE_ID"] = $INDUSTRY_TYPE_ID;
                            $paramList["CHANNEL_ID"] = $CHANNEL_ID;
                            $paramList["TXN_AMOUNT"] = $TXN_AMOUNT;
                            $paramList["WEBSITE"] = PAYTM_MERCHANT_WEBSITE;
                            //$paramList["CALLBACK_URL"] = "http://192.168.1.210/mbd-development/bhoopendra/public/payment-success";
                            $paramList["CALLBACK_URL"] = $this->returnBasePath()."/payment-success";

                            //Here checksum string will return by getChecksumFromArray() function.
                            $checkSum = getChecksumFromArray($paramList, PAYTM_MERCHANT_KEY);

                            echo '<html>
                            <head>
                                <title>Merchant Check Out Page</title>
                            </head>
                            <body>
                            <center><h1>Please do not refresh this page...</h1></center>
                            <form method="post" action="' . PAYTM_TXN_URL . '" name="octopusPaytm">
                                <table border="1">
                                    <tbody>';

                            foreach ($paramList as $name => $value) {
                                echo '<input type="hidden" name="' . $name . '" value="' . $value . '">';
                            }

                            echo '<input type="hidden" name="SubscriptionType" value="' . $postData['subscription_type'] . '">
                                 <input type="hidden" name="CHECKSUMHASH" value="' . $checkSum . '">
                                    </tbody>
                                </table>

                            </form>
                            </body>
                            </html>
                            <script type="text/javascript">
                             
                            document.octopusPaytm.submit();
                            </script>';
                            die;
                        }
                    }

                    $arr = array();
                    $arr['CONTENT_ID'] = $content_id;
                    $arr['couponId'] = $couponId;
                    if (!empty($_POST["TXNID"])) {
                        $arr['TRANSACTION_ID'] = $_POST["TXNID"];
                    }
                    $arr['subscription_type'] = $postData['subscription_type'];
                    $arr['days'] = $postData['days'];
                    $arr['amount'] = $postData['amount'];
                    
                    $this->subscribeContent($arr);


                    return $this->redirect()->toRoute('content', array('action' => 'content', 'id' => $content_id));

                    // $result = ['result' => true, 'current_path_redirect' => 'Y'];
                } else {
                    return $this->redirect()->toRoute('content', array('action' => 'content', 'id' => $content_id));
                    // $result = ['result' => false, 'message' => 'error'];
                }
//                $viewModel->setVariables(['data' => $result]);
//                return $viewModel;
            }
            /* End here paytm */
            $liveClassUrl = '';
            if ($getContentdetails['CONTTYPE_ID'] == 15) {
                $liveClassUrl = $this->db->getLiveClassUrlByContId($this->container->authDetail["UT_ID"], $getContentdetails["CONT_ID"]);
                //$liveClassUrl = "https://live.wiziq.com/aliveext/LoginToSession.aspx?SessionCode=9sbzXtdmlusyyNLYRsnIhA%3d%3d";
            }

            $authToken = "";
            if ($getContentdetails['CONTTYPE_ID'] == '13') {
                $client = new HttpClient(null, ['timeout' => 1200]);
                //$client 	= new HttpClient();
                $config = $this->getServiceLocator()->get('config');
                $atb = new AtbController();
                $data = $atb->apiAtbBookLogin($config, $client);
                $authToken = $data['auth_token'];
            }
            $courseId = $this->db->getCourseId($content_id);
            $GetLaunchUrl = $reportpage = "";
            if (!empty($courseId) && !empty($this->container->authDetail['USER_OID'])) {
                $baseDirPath = getcwd() . '/library/'; 
                require_once($baseDirPath . "scorm/ScormEngineUtilities.php");
                require_once($baseDirPath . 'scorm/ScormEngineService.php');
                require_once($baseDirPath . 'scorm/Configuration.php');
                require_once($baseDirPath . 'scorm/ServiceRequest.php');
                require_once($baseDirPath . 'scorm/ReportingService.php');
                $config = $this->serviceLocator->get('config');
                $ServiceUrl = $config['scorm_serviceurl'];
                $SecretKey = $config['scorm_secretkey'];
                $AppId = $config['scorm_appid'];
                $Origin = ScormEngineUtilities::getCanonicalOriginString('Piron', 'Test', 'Version 2.0');
                $ScormService = new ScormEngineService($ServiceUrl, $AppId, $SecretKey, $Origin);
                $regService = $ScormService->getRegistrationService();
                $status = "Uncomplete";
                $REG_ID = $this->db->checkScormUserRegistration($courseId, $this->container->authDetail['USER_OID']);
                if (empty($REG_ID)) {
                    $regId = uniqid(rand(), true);
                    $learnerId = $this->container->authDetail['EMAIL_ID'];
                    $learnerFirstName = $this->container->authDetail['FIRST_NAME'];
                    $learnerLastName = $this->container->authDetail['LAST_NAME'];
                    // Save on scorm
                    $response = $regService->CreateRegistration($regId, $courseId, $learnerId, $learnerFirstName, $learnerLastName);
                    // Saving data into tables
                    $regArr['SCORM_COURSE_ID'] = $courseId;
                    $regArr['USER_OID'] = $this->container->authDetail['USER_OID'];
                    $regArr['REG_ID'] = $regId;
                    $this->db->saveUserScormRegistration($regArr);
                    $REG_ID = $regId;
                }
                //echo "$REG_ID, $courseId <br/>" ;
                $conf = new Configuration($config['scorm_serviceurl'], $AppId, $SecretKey);
                $srvc = new ReportingService($conf);
                $learnerId = $this->container->authDetail['EMAIL_ID'];
                $homePage = "/Reportage/reportage.php?appId=$AppId";
                $learnerPage = $homePage . "&courseId=$courseId&learnerId=$learnerId";
                $reportageAuth = $srvc->GetReportageAuth('NONAV', false);
                $reportpage = $srvc->GetReportUrl($reportageAuth, $learnerPage);
                $GetLaunchUrl = $regService->GetLaunchUrl($REG_ID, $reportpage);
            }


            $params['ORG_ID'] = !empty($this->container->authDetail['ORG_ID']) ? $this->container->authDetail['ORG_ID'] : null;

            $arrEnv["user_id"] = (!empty($this->container->authDetail['USER_OID'])) ? $this->container->authDetail['USER_OID'] : null;
            $arrEnv["content_id"] = $content_id;
            
            $inrollData = $this->db->getContentUserEnrollData($arrEnv);
             
          

            /* if(empty($inrollData)){
              return $this->redirect()->toRoute('error-page', array('action' => 'error404'));
              } */
            //  echo '<pre />'; print_r($inrollData); die('macro');
            // if (empty($inrollData)) {
            //   return $this->redirect()->toRoute('secure', array('action' => 'login'));
            // }
            $similarSubject = $this->getSimilarSubject($getContentdetails["GRADE_NAME"], 1);

            $viewModel->setVariables(array(
                'content_id' => $content_id,
                'inrollData' => $inrollData,
//                'stPositionData' => $stPositionData,
//                'subject_id' => $subject_id,
                'org_id' => $params['ORG_ID'],
                'user_oid' => (!empty($this->container->authDetail['USER_OID'])) ? $this->container->authDetail['USER_OID'] : "",
                'ut_id' => (!empty($this->container->authDetail['UT_ID'])) ? $this->container->authDetail['UT_ID'] : "",
                'GetLaunchUrl' => $GetLaunchUrl,
                'getContentdetails' => $getContentdetails,
                'liveClassUrl' => $liveClassUrl,
                'auth_token' => $authToken,
                'similar_subjects' => $similarSubject
            ));
            return $viewModel;
        }
    }

    //////end content page////

    function paymentSuccessAction() {
        header("Pragma: no-cache");
        header("Cache-Control: no-cache");
        header("Expires: 0");
        $baseDirPath = getcwd() . '/library/';
        // following files need to be included
        require_once($baseDirPath . "paytm/lib/config_paytm.php");
        require_once($baseDirPath . "paytm/lib/encdec_paytm.php");
        $paytmChecksum = "";
        $paramList = array();
        $isValidChecksum = "FALSE";
        $paramList = $_POST;
        $paytmChecksum = isset($_POST["CHECKSUMHASH"]) ? $_POST["CHECKSUMHASH"] : ""; //Sent by Paytm pg
        //Verify all parameters received from Paytm pg to your application. Like MID received from paytm pg is same as your application�s MID, TXN_AMOUNT and ORDER_ID are same as what was sent by you to Paytm PG for initiating transaction etc.
        $isValidChecksum = verifychecksum_e($paramList, PAYTM_MERCHANT_KEY, $paytmChecksum); //will return TRUE or FALSE string.
        if ($isValidChecksum == "TRUE") {
            $arr = array();
//            echo "<pre>";
//            print_r($_POST);die;
            //  echo "<b>Checksum matched and following are the transaction details:</b>" . "<br/>";
            $getContentID = explode('ORDS', $_POST['ORDERID']);
           //  print_r($getContentID);die;
            $arr['CONTENT_ID'] = $getContentID['0'];
            
            
            if ($_POST["STATUS"] == "TXN_SUCCESS") {
                //echo "<b>Transaction status is success</b>" . "<br/>";
                //Process your transaction here as success transaction.
                //Verify amount & order id received from Payment gateway with your application's order id and amount.

                if (!empty($_POST["TXNID"])) {
                    $arr['TRANSACTION_ID'] = $_POST["TXNID"];
                }
                $arr['subscription_type'] = 'B';
                $arr['amount'] = $_POST['TXNAMOUNT'];
                
                $couponId =!empty($getContentID['2'])?$getContentID['2']:0;
                if($couponId>0){
                    //get coupon Table data
                    $CouponTable = $this->initTable('CouponCode\Model\CouponTable');
                    $couponData = $CouponTable->fetchData('t_coupon_cnf_master', ['COUPON_ID' => $couponId], null, null);
                    if(count($couponData['0'])>0){
                        //is use check update here 
                        $IS_USED=$couponData['0']['IS_USED']+1;
                        //update coupon table
                        $updateCouponData=$CouponTable->updateData('t_coupon_cnf_master',array('IS_USED'=>$IS_USED),array('COUPON_ID' => $couponId));
                    } 
                 }
                 $this->notify($_POST);
                $this->subscribeContent($arr);
                $this->container->subscribe = 1;
                return $this->redirect()->toRoute('content', array('action' => 'content', 'id' => $arr['CONTENT_ID']));
            } else {
                // echo "<b>Transaction status is failure</b>" . "<br/>";

                $this->notify($_POST);
                $this->container->failtrans = 1;
                return $this->redirect()->toRoute('content', array('action' => 'content', 'id' => $arr['CONTENT_ID'], 'second_id' => $this->container->failtrans));
            }

//            if (isset($_POST) && count($_POST) > 0) {
//                foreach ($_POST as $paramName => $paramValue) {
//                    echo "<br/>" . $paramName . " = " . $paramValue;
//                }
//            }
        } else {
            // echo "<b>Checksum mismatched.</b>";
            //Process transaction as suspicious.
            $this->container->failtrans = 1;
            return $this->redirect()->toRoute('content', array('action' => 'content', 'id' => $arr['CONTENT_ID']));
        }
        die;
    }

    function notify($data) {
        $payment = array();
        $payment['DETAILS'] = serialize($data);
        $payment['TRANSACTION_ID'] = $data['TXNID'];
        $payment['AMOUNT'] = $data['TXNAMOUNT'];
        $getContentID = explode('ORDS', $data['ORDERID']);
        //$payment['CONTENT_ID'] =$getContentID['0'];
        $payment['STATUS'] = $data['STATUS'];
        $payment['CREATED_ON'] = date("Y-m-d H:i:s");
        $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
        $admGrade = new AdmgradeTable($this->getAdapter());
        $admGrade->savePaymentsDetail($payment);
        return true;
    }

    function subjectAction() { 
        $subject_id = $this->params('id');
        $this->db = new AdmgradeTable($this->getAdapter());
        
        $this->CommonClass()->setCustomLayout($this, 'subjectLayout');
        $getallsubjectdetails = $this->db->getSubjectFullDetailById($subject_id, null);
        $this->layout()->setVariable('subjectName', $getallsubjectdetails['DISPLAY_NAME']);
        
        if (empty($getallsubjectdetails)) {
            return $this->notFoundAction();
            //return $this->redirect()->toRoute('error-page', array('action' => 'error404'));
        } else {
            if (!count($getallsubjectdetails)) {
                return $this->redirect()->toUrl($this->returnBasePath());
            }
            $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
            $request = $this->getRequest();
            $extraCheck = true;
            if (!empty($_POST["txn_id"])) {
                $extraCheck = false;
            }
            if ($request->isPost() || !$extraCheck) {
                $config = $this->getServiceLocator()->get('config');
                $postData = $request->getPost()->toArray();
                if ($postData['enroll'] || !$extraCheck) {
                    if (!empty($_POST["payment_status"]) && $_POST["payment_status"] != 'Completed') {
                        $this->container->failtrans = 1;
                        return $this->redirect()->toRoute('subject', array('action' => 'subject', 'id' => $subject_id));
                    }
                    // if amount is greater then 0 then send user to paypal site
                    if ($postData['amount'] > 0.01) {
                        //paytm integration for subject
                        if (!isset($_POST["TXNID"])) {
                            //Paytm payment code block
                            $baseDirPath = getcwd() . '/library/';
                            // following files need to be included
                            require_once($baseDirPath . "paytm/lib/config_paytm.php");
                            require_once($baseDirPath . "paytm/lib/encdec_paytm.php");
                            header("Pragma: no-cache");
                            header("Cache-Control: no-cache");
                            header("Expires: 0");
                            $couponId=$postData['couponId'];
                            $orderID = $subject_id . "ORDS" . rand(10000, 99999999)."ORDS".$couponId;  
                            $postData['orderID'] = $orderID;

                            $checkSum = "";
                            $paramList = array();
                            $ORDER_ID = $postData['orderID'];
                            $CUST_ID = 'USR' . $this->container->authDetail['USER_OID'];
                            $INDUSTRY_TYPE_ID = 'Retail'; // THIS WILL BE PROVIDED BY PAYTM
                            $CHANNEL_ID = 'WEB';
                            $TXN_AMOUNT = $_POST["amount"];


                            //ORDER_DETAILS/CUST_ID
                            // Create an array having all required parameters for creating checksum.
                            $paramList["MID"] = PAYTM_MERCHANT_MID;
                            $paramList["ORDER_ID"] = $ORDER_ID;
                            $paramList["CUST_ID"] = $CUST_ID;
                            $paramList["INDUSTRY_TYPE_ID"] = $INDUSTRY_TYPE_ID;
                            $paramList["CHANNEL_ID"] = $CHANNEL_ID;
                            $paramList["TXN_AMOUNT"] = $TXN_AMOUNT;
                            $paramList["WEBSITE"] = PAYTM_MERCHANT_WEBSITE;
                            //$paramList["CALLBACK_URL"] = "http://192.168.1.210/mbd-development/bhoopendra/public/subject-payment-success";
                           
                            $paramList["CALLBACK_URL"] = $this->returnBasePath()."/subject-payment-success";
                            //Here checksum string will return by getChecksumFromArray() function.
                            $checkSum = getChecksumFromArray($paramList, PAYTM_MERCHANT_KEY);

                            echo '<html>
                            <head>
                                <title>Merchant Check Out Page</title>
                            </head>
                            <body>
                            <center><h1>Please do not refresh this page...</h1></center>
                            <form method="post" action="' . PAYTM_TXN_URL . '" name="octopusPaytm">
                                <table border="1">
                                    <tbody>';

                            foreach ($paramList as $name => $value) {
                                echo '<input type="hidden" name="' . $name . '" value="' . $value . '">';
                            }

                            echo '<input type="hidden" name="CHECKSUMHASH" value="' . $checkSum . '">
                                    </tbody>
                                </table>

                            </form>
                            </body>
                            </html>
                            <script type="text/javascript">
                             
                            document.octopusPaytm.submit();
                            </script>';
                            die;
                        }
                    }


                    $arr = array();
                    $arr['SUBJECT_ID'] = $subject_id;
                    $arr['couponId'] = $couponId;
                    if (!empty($_POST["txn_id"])) {
                        $arr['TRANSACTION_ID'] = $_POST["txn_id"];
                    }

                    $this->subscribeSubject($arr);


                    return $this->redirect()->toRoute('subject', array('action' => 'subject', 'id' => $subject_id));

                    // $result = ['result' => true, 'current_path_redirect' => 'Y'];
                } else {
                    return $this->redirect()->toRoute('subject', array('action' => 'subject', 'id' => $subject_id));
                    //  $result = ['result' => false, 'message' => 'error'];
                }


//                $viewModel->setVariables(['data' => $result]);
//                return $viewModel;
            }

            //$similar_subjects = $this->db->getSimilarSubjectsByGradeId($getallsubjectdetails["GRADE_ID"], $subject_id, 0, 3);

            /* Fetch public similar subject by grade Id */
            //$similar_subjects = $this->db->getSimilarSubjectsPublicDetail($getallsubjectdetails["GRADE_ID"], $subject_id);
            $similarSubject = $this->getSimilarSubject($getallsubjectdetails["GRADE_ID"]);
            /* End Here */



            $arrEnv["user_id"] = (!empty($this->container->authDetail['USER_OID'])) ? $this->container->authDetail['USER_OID'] : null;
            $arrEnv["subject_id"] = $subject_id;
            $inrollData = $this->db->getSubjectUserEnrollData($arrEnv);
            
            $inrollgrade = $this->db->getSubjectGradeUserEnrollData($arrEnv);

            if (empty($subject_id))
                $subject_id = null;
            $params['SUBJECT_ID'] = $subject_id;
            $params['ORG_ID'] = !empty($this->container->authDetail['ORG_ID']) ? $this->container->authDetail['ORG_ID'] : null;
            $lessonplan = $this->db->getLessonplanAvailableForB2c($params);
            $stData = $this->db->fetchData('t_b2c_master_test', ['SUBJECT_ID' => $subject_id, 'QUIZ_TYPE' => 'ST', 'PUBLISH' => 'Y'], [], 'ST_POSITION');
            $stPositionData = [];
            if (count($stData)) {
                foreach ($stData as $data) {
                    $stPositionData[] = $data['ST_POSITION'];
                }
            }
            $ftTestDetail = $this->db->fetchData('t_b2c_master_test', ['SUBJECT_ID' => $subject_id, 'QUIZ_TYPE' => 'FT', 'PUBLISH' => 'Y'], [], null, false);            
            
            /** Code to calculte global rank of logged in student (By Rizban Ahmad) */
            $globalRank = '';
            $getGTQuizIdsInSubject = $this->db->getGTQuizIdsInSubject($subject_id);            
            $getSTQuizIdsInSubject = !empty($stData) ? array_values(array_column($stData, 'QUIZ_ID')) : array();
            $getMergedGTSTQuizIds = array_merge($getGTQuizIdsInSubject, $getSTQuizIdsInSubject);            
            !empty($ftTestDetail['QUIZ_ID']) ? array_push($getMergedGTSTQuizIds, $ftTestDetail['QUIZ_ID']) : $getMergedGTSTQuizIds;
            sort($getMergedGTSTQuizIds);
            //echo '<pre>';print_r($getMergedGTSTQuizIds);die;
            if(!empty($getMergedGTSTQuizIds)) {
                foreach($getMergedGTSTQuizIds as $quizId) {
                    $getAllUsersRankQuizWise[] = $this->db->getRankOfUsersByQuizId($quizId);
                }
                if(!empty($getAllUsersRankQuizWise)) {
                    /** check that if logged in user attempted any test inside subject */
                    $userNotAttemptedAnyTestInSubject = false;
                    foreach($getAllUsersRankQuizWise as $userRank) {
                        if(!array_key_exists($this->container->authDetail['USER_OID'], $userRank)) {
                            $userNotAttemptedAnyTestInSubject = true;
                        }
                    }
                    //echo $userNotAttemptedAnyTestInSubject.' rizban';die;
                    /** if attempted */
                    if(!$userNotAttemptedAnyTestInSubject) {
                        //echo '<pre>';print_r($getAllUsersRankQuizWise);die;
                        $allUsersRankSubjectWise = array();
                        array_walk_recursive($getAllUsersRankQuizWise, function($item, $key) use (&$allUsersRankSubjectWise){
                            $allUsersRankSubjectWise[$key] = isset($allUsersRankSubjectWise[$key]) ?  $item + $allUsersRankSubjectWise[$key] : $item;
                        });
                        if(empty(array_filter($allUsersRankSubjectWise))) {
                            $globalRank = 'N/A';
                        } else {
                            arsort($allUsersRankSubjectWise, SORT_NUMERIC);
                            $globalRank = array_search($this->container->authDetail['USER_OID'], array_keys($allUsersRankSubjectWise))+1;
                            //echo '<pre>';print_r($allUsersRankSubjectWise);die;                    
                        }
                    } else{ /** if not attempted */                        
                        $globalRank = 'N/A';
                    }
                } else {
                    $globalRank = 'N/A';
                }
                                
            } else {
                $globalRank = 'N/A';
            }
            /** End code */
            
            /** Get data to displayed at main page for selected LPs. */
            $joins[] = ['t_b2c_mgr_test_lessonplan', 't_b2c_mgr_test_lessonplan.QUIZ_ID = t_b2c_master_test.QUIZ_ID', ['LESSONPLAN_ID']];
            $joins[] = ['t_b2c_cm_lessonplan_master', 't_b2c_cm_lessonplan_master.LESSONPLAN_ID = t_b2c_mgr_test_lessonplan.LESSONPLAN_ID', ['LP_NAME']];
            $lpTestDetail = $this->db->fetchData('t_b2c_master_test', ['t_b2c_master_test.SUBJECT_ID' => $subject_id, 't_b2c_master_test.QUIZ_TYPE' => 'ST'], ['QUIZ_ID'], 'LP_POSITION', true, null, null, null, null, null, null, $joins);
            $viewModel->setVariables(array(
                'lessonplan' => $lessonplan,
                'inrollData' => $inrollData,
                'inrollgrade' => $inrollgrade,
                'stData' => $stData,
                'stPositionData' => $stPositionData,
                'subject_id' => $subject_id,
                'org_id' => $params['ORG_ID'],
                'user_oid' => (!empty($this->container->authDetail['USER_OID'])) ? $this->container->authDetail['USER_OID'] : "",
                'ut_id' => (!empty($this->container->authDetail['UT_ID'])) ? $this->container->authDetail['UT_ID'] : "",
                'countlp' => count($lessonplan),
                'getallsubjectdetails' => $getallsubjectdetails,
                'similar_subjects' => $similarSubject,
                'finalTestId' => !empty($ftTestDetail['QUIZ_ID']) ? $ftTestDetail : null,
                'lpTestDetail' => $lpTestDetail,
                'globalRank' => $globalRank,
            ));
            return $viewModel;
        }
    }

    function courseAction() {
        $grade_id = $this->params('id');
        $id = (!empty($this->params()->fromQuery('student_id'))) ? $this->params()->fromQuery('student_id') : "";
        $studentId = (!empty($id)) ? $id : $this->container->authDetail['USER_OID'];
        $this->db = new AdmgradeTable($this->getAdapter());
        $this->CommonClass()->setCustomLayout($this, 'subjectLayout');
        $getallgradedetails = $this->db->getGradeFullDetailById($grade_id, null);
        $getallsubjectdetails = $this->db->getAllSubjectList($user_oid = '', $grade_id);
        $this->layout()->setVariable('courseName', $getallgradedetails['DISPLAY_NAME']);

        if (empty($getallgradedetails)) {
            return $this->notFoundAction();
            //return $this->redirect()->toRoute('error-page', array('action' => 'error404'));
        } else {
            if (!count($getallgradedetails)) {
                return $this->redirect()->toUrl($this->returnBasePath());
            }
            $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
            $request = $this->getRequest();
            $extraCheck = true;
            if (!empty($_POST["txn_id"])) {
                $extraCheck = false;
            }
            if ($request->isPost() || !$extraCheck) {
                $config = $this->getServiceLocator()->get('config');
                $postData = $request->getPost()->toArray();
                if ($postData['enroll'] || !$extraCheck) {
                    if (!empty($_POST["payment_status"]) && $_POST["payment_status"] != 'Completed') {
                        $this->container->failtrans = 1;
                        return $this->redirect()->toRoute('course', array('action' => 'course', 'id' => $grade_id));
                    }
                    // if amount is greater then 0 then send user to paypal site
                    if ($postData['amount'] > 0.01) {
                        //paytm integration for subject
                        if (!isset($_POST["TXNID"])) {
                            //Paytm payment code block
                            $baseDirPath = getcwd() . '/library/';
                            // following files need to be included
                            require_once($baseDirPath . "paytm/lib/config_paytm.php");
                            require_once($baseDirPath . "paytm/lib/encdec_paytm.php");
                            header("Pragma: no-cache");
                            header("Cache-Control: no-cache");
                            header("Expires: 0");
                            $couponId=$postData['couponId'];
                            $orderID = $grade_id . "ORDS" . rand(10000, 99999999)."ORDS".$couponId; 
                            $postData['orderID'] = $orderID;

                            $checkSum = "";
                            $paramList = array();
                            $ORDER_ID = $postData['orderID'];
                            $CUST_ID = 'USR' . $this->container->authDetail['USER_OID'];
                            $INDUSTRY_TYPE_ID = 'Retail'; // THIS WILL BE PROVIDED BY PAYTM
                            $CHANNEL_ID = 'WEB';
                            $TXN_AMOUNT = $_POST["amount"];

                            //ORDER_DETAILS/CUST_ID
                            // Create an array having all required parameters for creating checksum.
                            $paramList["MID"] = PAYTM_MERCHANT_MID;
                            $paramList["ORDER_ID"] = $ORDER_ID;
                            $paramList["CUST_ID"] = $CUST_ID;
                            $paramList["INDUSTRY_TYPE_ID"] = $INDUSTRY_TYPE_ID;
                            $paramList["CHANNEL_ID"] = $CHANNEL_ID;
                            $paramList["TXN_AMOUNT"] = $TXN_AMOUNT;
                            $paramList["WEBSITE"] = PAYTM_MERCHANT_WEBSITE;
                            // $paramList["CALLBACK_URL"] = "http://192.168.1.210/mbd-development/bhoopendra/public/course-payment-success";
                            $paramList["CALLBACK_URL"] = $this->returnBasePath()."/course-payment-success";
                            //Here checksum string will return by getChecksumFromArray() function.
                            $checkSum = getChecksumFromArray($paramList, PAYTM_MERCHANT_KEY);

                            echo '<html>
                            <head>
                                <title>Merchant Check Out Page</title>
                            </head>
                            <body>
                            <center><h1>Please do not refresh this page...</h1></center>
                            <form method="post" action="' . PAYTM_TXN_URL . '" name="octopusPaytm">
                                <table border="1">
                                    <tbody>';

                            foreach ($paramList as $name => $value) {
                                echo '<input type="hidden" name="' . $name . '" value="' . $value . '">';
                            }

                            echo '<input type="hidden" name="CHECKSUMHASH" value="' . $checkSum . '">
                                    </tbody>
                                </table>

                            </form>
                            </body>
                            </html>
                            <script type="text/javascript">
                             
                            document.octopusPaytm.submit();
                            </script>';
                            die;
                        }
                    }


                    $arr = array();
                    $arr['GRADE_ID'] = $grade_id;
                    $arr['couponId'] = $couponId;
                    if (!empty($_POST["txn_id"])) {
                        $arr['TRANSACTION_ID'] = $_POST["txn_id"];
                    }

                    // $this->subscribeSubject($arr);

                    $this->subscribeGrade($arr);

                    return $this->redirect()->toRoute('course', array('action' => 'course', 'id' => $grade_id));

                    // $result = ['result' => true, 'current_path_redirect' => 'Y'];
                } else {
                    return $this->redirect()->toRoute('course', array('action' => 'course', 'id' => $grade_id));
                    //  $result = ['result' => false, 'message' => 'error'];
                }


//                $viewModel->setVariables(['data' => $result]);
//                return $viewModel;
            }
            $similarSubject = $this->getSimilarSubject($getallgradedetails["GRADE_ID"]);
            /* End Here */
            $arrEnv["user_id"] = (!empty($this->container->authDetail['USER_OID'])) ? $this->container->authDetail['USER_OID'] : null;
            $arrEnv["grade_id"] = $grade_id;
            $inrollData = $this->db->getGradeUserEnrollData($arrEnv);



            $viewModel->setVariables(array(
                'lessonplan' => "",
                'allSubject' => $getallsubjectdetails,
                'inrollData' => $inrollData,
                'stData' => "",
                'stPositionData' => "",
                'subject_id' => $grade_id,
                'grade_id' => $grade_id,
                'org_id' => !empty($params['ORG_ID']) ? $params['ORG_ID'] : '',
                'user_oid' => (!empty($this->container->authDetail['USER_OID'])) ? $this->container->authDetail['USER_OID'] : "",
                'ut_id' => (!empty($this->container->authDetail['UT_ID'])) ? $this->container->authDetail['UT_ID'] : "",
                'countlp' => "",
                'getallgradedetails' => $getallgradedetails,
                'similar_subjects' => $similarSubject,
                'finalTestId' => !empty($ftTestDetail['QUIZ_ID']) ? $ftTestDetail : null,
                'lpTestDetail' => "",
                'student_id' => $studentId
            ));
            return $viewModel;
        }
    }

    public function subjectPaymentSuccessAction() {

        header("Pragma: no-cache");
        header("Cache-Control: no-cache");
        header("Expires: 0");
        $baseDirPath = getcwd() . '/library/';
        // following files need to be included
        require_once($baseDirPath . "paytm/lib/config_paytm.php");
        require_once($baseDirPath . "paytm/lib/encdec_paytm.php");

        $paytmChecksum = "";
        $paramList = array();
        $isValidChecksum = "FALSE";
        $paramList = $_POST;
        $paytmChecksum = isset($_POST["CHECKSUMHASH"]) ? $_POST["CHECKSUMHASH"] : ""; //Sent by Paytm pg
        //Verify all parameters received from Paytm pg to your application. Like MID received from paytm pg is same as your application�s MID, TXN_AMOUNT and ORDER_ID are same as what was sent by you to Paytm PG for initiating transaction etc.
        $isValidChecksum = verifychecksum_e($paramList, PAYTM_MERCHANT_KEY, $paytmChecksum); //will return TRUE or FALSE string.
        if ($isValidChecksum == "TRUE") {
            $arr = array();
            //  echo "<b>Checksum matched and following are the transaction details:</b>" . "<br/>";
            $getContentID = explode('ORDS', $_POST['ORDERID']);
            $arr['SUBJECT_ID'] = $getContentID['0'];
            

            if ($_POST["STATUS"] == "TXN_SUCCESS") {
                //echo "<b>Transaction status is success</b>" . "<br/>";
                //Process your transaction here as success transaction.
                //Verify amount & order id received from Payment gateway with your application's order id and amount.

                if (!empty($_POST["TXNID"])) {
                    $arr['TRANSACTION_ID'] = $_POST["TXNID"];
                }
                $arr['subscription_type'] = 'B';
                $arr['amount'] = $_POST['TXNAMOUNT'];
                $couponId =!empty($getContentID['2'])?$getContentID['2']:0;
                if($couponId>0){
                    //get coupon Table data
                    $CouponTable = $this->initTable('CouponCode\Model\CouponTable');
                    $couponData = $CouponTable->fetchData('t_coupon_cnf_master', ['COUPON_ID' => $couponId], null, null);
                    if(count($couponData['0'])>0){
                        //is use check update here 
                        $IS_USED=$couponData['0']['IS_USED']+1;
                        //update coupon table
                        $updateCouponData=$CouponTable->updateData('t_coupon_cnf_master',array('IS_USED'=>$IS_USED),array('COUPON_ID' => $couponId));
                    } 
                 }
                
                $this->subjectNotify($_POST);
                
                $this->subscribeSubject($arr);
                $this->container->subscribe = 1;
                return $this->redirect()->toRoute('subject', array('action' => 'subject', 'id' => $arr['SUBJECT_ID']));
            } else {
                // echo "<b>Transaction status is failure</b>" . "<br/>";

                $this->subjectNotify($_POST);
                $this->container->failtrans = 1;
                return $this->redirect()->toRoute('subject', array('action' => 'subject', 'id' => $arr['SUBJECT_ID']));
            }

//            if (isset($_POST) && count($_POST) > 0) {
//                foreach ($_POST as $paramName => $paramValue) {
//                    echo "<br/>" . $paramName . " = " . $paramValue;
//                }
//            }
        } else {
            // echo "<b>Checksum mismatched.</b>";
            //Process transaction as suspicious.
            $this->container->failtrans = 1;
            return $this->redirect()->toRoute('subject', array('action' => 'subject', 'id' => $arr['SUBJECT_ID']));
        }
        die;
    }

    public function coursePaymentSuccessAction() {

        header("Pragma: no-cache");
        header("Cache-Control: no-cache");
        header("Expires: 0");
        $baseDirPath = getcwd() . '/library/';
        // following files need to be included
        require_once($baseDirPath . "paytm/lib/config_paytm.php");
        require_once($baseDirPath . "paytm/lib/encdec_paytm.php");

        $paytmChecksum = "";
        $paramList = array();
        $isValidChecksum = "FALSE";
        $paramList = $_POST;
        $paytmChecksum = isset($_POST["CHECKSUMHASH"]) ? $_POST["CHECKSUMHASH"] : ""; //Sent by Paytm pg
        //Verify all parameters received from Paytm pg to your application. Like MID received from paytm pg is same as your application�s MID, TXN_AMOUNT and ORDER_ID are same as what was sent by you to Paytm PG for initiating transaction etc.
        $isValidChecksum = verifychecksum_e($paramList, PAYTM_MERCHANT_KEY, $paytmChecksum); //will return TRUE or FALSE string.
        if ($isValidChecksum == "TRUE") {
            $arr = array();
            //  echo "<b>Checksum matched and following are the transaction details:</b>" . "<br/>";
            $getContentID = explode('ORDS', $_POST['ORDERID']);
            $arr['GRADE_ID'] = $getContentID['0'];

            if ($_POST["STATUS"] == "TXN_SUCCESS") {
                //echo "<b>Transaction status is success</b>" . "<br/>";
                //Process your transaction here as success transaction.
                //Verify amount & order id received from Payment gateway with your application's order id and amount.

                if (!empty($_POST["TXNID"])) {
                    $arr['TRANSACTION_ID'] = $_POST["TXNID"];
                }
                $arr['subscription_type'] = 'B';
                $arr['amount'] = $_POST['TXNAMOUNT'];
               $couponId =!empty($getContentID['2'])?$getContentID['2']:0;
                if($couponId>0){
                    //get coupon Table data
                    $CouponTable = $this->initTable('CouponCode\Model\CouponTable');
                    $couponData = $CouponTable->fetchData('t_coupon_cnf_master', ['COUPON_ID' => $couponId], null, null);
                    if(count($couponData['0'])>0){
                        //is use check update here 
                        $IS_USED=$couponData['0']['IS_USED']+1;
                        //update coupon table
                        $updateCouponData=$CouponTable->updateData('t_coupon_cnf_master',array('IS_USED'=>$IS_USED),array('COUPON_ID' => $couponId));
                    } 
                 }
                
                $this->subjectNotify($_POST);
                $this->subscribeGrade($arr);
                $this->container->subscribe = 1;
                return $this->redirect()->toRoute('course', array('action' => 'course', 'id' => $arr['GRADE_ID']));
            } else {
                // echo "<b>Transaction status is failure</b>" . "<br/>";

                $this->subjectNotify($_POST);
                $this->container->failtrans = 1;
                return $this->redirect()->toRoute('course', array('action' => 'course', 'id' => $arr['GRADE_ID']));
            }

//            if (isset($_POST) && count($_POST) > 0) {
//                foreach ($_POST as $paramName => $paramValue) {
//                    echo "<br/>" . $paramName . " = " . $paramValue;
//                }
//            }
        } else {
            // echo "<b>Checksum mismatched.</b>";
            //Process transaction as suspicious.
            $this->container->failtrans = 1;
            return $this->redirect()->toRoute('course', array('action' => 'course', 'id' => $arr['GRADE_ID']));
        }
        die;
    }

    function subjectNotify($data) {
        $payment = array();
        $payment['DETAILS'] = serialize($data);
        $payment['TRANSACTION_ID'] = $data['TXNID'];
        $payment['AMOUNT'] = $data['TXNAMOUNT'];
        $getContentID = explode('ORDS', $data['ORDERID']);
        //$payment['CONTENT_ID'] =$getContentID['0'];
        $payment['STATUS'] = $data['STATUS'];
        $payment['CREATED_ON'] = date("Y-m-d H:i:s");
        $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
        $admGrade = new AdmgradeTable($this->getAdapter());
        $admGrade->savePaymentsDetail($payment);
        return true;
    }

    //get similar books from cloud search
    function getSimilarSubject($gradeId, $contentFlag = 0) {
        $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
        $admTable = $this->initTable('Secure\Model\Administrator\AdministratorTable');
        $cloudSearch = ['KEY' => 'title', 'VALUE' => 'subject'];
        $gradeCond = $standardCond = '';
        if (!empty($gradeId) && empty($contentFlag)) {

            // grade name
            if ($contentFlag) {
                $grades = $gradeId;
            } else {
                $gradeSeries = $admTable->getGradenameById($gradeId);
                $grades = $gradeSeries['GRADE_NAME'];
            }

            $cloudSearch = ['KEY' => 'grade', 'VALUE' => $grades];
            $gradeCond = "(or grade:'" . $grades . "')";

            // standard name
            $standardSeries = $admTable->getStandardnameById($gradeId);
            $standards = $standardSeries['STANDARD_NAME'];
            $cloudSearch = ['KEY' => 'standard', 'VALUE' => $standards];
            $standardCond = "(or standard:'" . $standards . "')";
        }

        $config = $this->serviceLocator->get('config');
        $cloudSearchUrl = $config['cloud_search_endpoint'];
        $returnField = "&return=_all_fields,_score&sort=_score desc&size=4";
        $countryCode = $this->container->countryCode;
        $serachString = '';
        $cs_string_cond = '';
        if ($cloudSearch['VALUE'] != 'subject') {
            $serachString = "$gradeCond $standardCond";
        }
        if (!empty($serachString)) {
            $cs_string_cond = "&fq=(and " . $serachString . " )";
        }

        $searchData = $this->getCloudSearchData($cloudSearchUrl, $cs_string_cond, $returnField, $contentFlag);
        $csdata = [];
        $csids = [];

        if (isset($searchData['hits']['found'])) {
            $i = 0;
            foreach ($searchData['hits']['hit'] as $data) {
                $csdata[$i]['id'] = $data['id'];
                $csdata[$i]['action_url'] = $data['fields']['action_url'];
                $csdata[$i]['title'] = $data['fields']['title'];
                $csdata[$i]['image_url'] = $data['fields']['thumb_url'];
                $csdata[$i]['fp'] = $data['fields']['course_price'];
                $csids[] = $data['id'];
                $i++;
            }
        }
        if (count($csdata) < 3) {
            $cs_string_cond = null;
            $searchData2 = $this->getCloudSearchData($cloudSearchUrl, $cs_string_cond, $returnField, $contentFlag);
            if (isset($searchData2['hits']['hit'])) {
                foreach ($searchData2['hits']['hit'] as $data2) {
                    if (!in_array($data2['id'], $csids)) {
                        $csdata[$i]['id'] = $data2['id'];
                        $csdata[$i]['action_url'] = $data2['fields']['action_url'];
                        $csdata[$i]['title'] = $data2['fields']['title'];
                        $csdata[$i]['image_url'] = $data2['fields']['thumb_url'];
                        $csdata[$i]['fp'] = $data2['fields']['course_price'];
                        $i++;
                    }
                }
            }
        }
        return $csdata;
    }

    // Subscribe book function
    function subscribeSubject($arr = array()) {

        if (empty($arr["SUBJECT_ID"])) {
            return false;
        } else {

            $config = $this->getServiceLocator()->get('config');
            $subject_id = $arr["SUBJECT_ID"];


            $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
            $admgradeObj = new AdmgradeTable($dbadapter);
            $subjDetail = $admgradeObj->getSubjectFullDetailById($subject_id);
            $subScrData['USER_OID'] = $this->container->authDetail['USER_OID'];
            $subScrData['SUBSCRIPTION_NUM'] = time();
            $subScrData['SUBJECT_ID'] = $arr["SUBJECT_ID"];
            $subScrData['SUBSCRIBED_ON'] = date("Y-m-d H:i:s");
            if (!empty($arr["TRANSACTION_ID"])) {
                $subScrData['TRANSACTION_ID'] = $arr["TRANSACTION_ID"];
                $subScrData['SUBSCRIPTION_TYPE'] = 'B';
            }

            $result = $admgradeObj->saveSubscriptionData($subScrData);


            if ($result) {
                $emailPluginObj = new EmailPlugin();
                $userManagement = new UserManagementTable($dbadapter);
                $username = $userManagement->getUserName($subScrData['USER_OID']);
                #$userdetail = $userManagement->getUserDetail($this->container->authDetail['USER_OID']);
                $email = $userManagement->getUserEmail($subScrData['USER_OID']);
                $url = $this->returnBasePath() . "/subject/" . $subject_id;

                $bookimage = $this->returnBasePath() . "/images/default-subject.jpg";
                if (!empty($subjDetail['SUBJECT_IMAGE'])) {
                    $viewHelperManager = $this->getServiceLocator()->get('ViewHelperManager');
                    $s3Link = $viewHelperManager->get('s3Link');
                    $bookimage = str_replace('https', 'http', $s3Link("SUBJECT/" . $subjDetail['SUBJECT_IMAGE'], $config['s3bucket']));
                }

                $userimage = $this->returnBasePath() . "/images/default-user.png";

                $profileImg = $userManagement->getUserProfileImage($subScrData['USER_OID']);
                if (!empty($profileImg) && $profileImg != '') {

                    $viewHelperManager = $this->getServiceLocator()->get('ViewHelperManager');
                    $s3Link = $viewHelperManager->get('s3Link');
                    $userimage = str_replace('https', 'http', $s3Link("USER/" . $profileImg, $config['s3bucket']));
                }


                $params = [
                    'baseUrl' => $this->returnBasePath(),
                    'userimage' => $userimage,
                    'useremail' => $email,
                    'url' => $url,
                    'username' => $username,
                    'subjectname' => $subjDetail['SUBJECT_NAME'],
                    'subjectimage' => $bookimage,
                    'subscription_num' => $subScrData['SUBSCRIPTION_NUM']
                ];

                // first mail goes to user  
                $body = $emailPluginObj->setEmailTemplate('subscription_confirmation.phtml', $params);
             
                 $emailPluginObj->sendMail($email, $body);

                // second mail goes to administartor  
                $adminemail = $userManagement->getAdminEmail();
                $body = $emailPluginObj->setEmailTemplate('subscription_alert.phtml', $params);
                 $emailPluginObj->sendMail($adminemail, $body);
                $this->container->subscribe = 1;
            }
        }
    }

    function subscribeGrade($arr = array()) {

        if (empty($arr["GRADE_ID"])) {
            return false;
        } else {

            $config = $this->getServiceLocator()->get('config');
            $grade_id = $arr["GRADE_ID"];


            $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
            $admgradeObj = new AdmgradeTable($dbadapter);
            $gradeDetail = $admgradeObj->getGradeFullDetailById($grade_id);
            $subScrData['USER_OID'] = $this->container->authDetail['USER_OID'];
            $subScrData['SUBSCRIPTION_NUM'] = time();
            $subScrData['GRADE_ID'] = $arr["GRADE_ID"];
            $subScrData['SUBSCRIBED_ON'] = date("Y-m-d H:i:s");
            if (!empty($arr["TRANSACTION_ID"])) {
                $subScrData['TRANSACTION_ID'] = $arr["TRANSACTION_ID"];
                $subScrData['SUBSCRIPTION_TYPE'] = 'B';
            }

            $result = $admgradeObj->saveSubscriptionData($subScrData);


            if ($result) {
                $emailPluginObj = new EmailPlugin();
                $userManagement = new UserManagementTable($dbadapter);
                $username = $userManagement->getUserName($subScrData['USER_OID']);
                #$userdetail = $userManagement->getUserDetail($this->container->authDetail['USER_OID']);
                $email = $userManagement->getUserEmail($subScrData['USER_OID']);
                $url = $this->returnBasePath() . "/grade/" . $grade_id;

                $bookimage = $this->returnBasePath() . "/images/default-subject.jpg";
                if (!empty($gradeDetail['GRADE_IMAGE'])) {
                    $viewHelperManager = $this->getServiceLocator()->get('ViewHelperManager');
                    $s3Link = $viewHelperManager->get('s3Link');
                    $bookimage = str_replace('https', 'http', $s3Link("GRADE/" . $gradeDetail['GRADE_IMAGE'], $config['s3bucket']));
                }

                $userimage = $this->returnBasePath() . "/images/default-user.png";

                $profileImg = $userManagement->getUserProfileImage($subScrData['USER_OID']);
                if (!empty($profileImg) && $profileImg != '') {

                    $viewHelperManager = $this->getServiceLocator()->get('ViewHelperManager');
                    $s3Link = $viewHelperManager->get('s3Link');
                    $userimage = str_replace('https', 'http', $s3Link("USER/" . $profileImg, $config['s3bucket']));
                }


                $params = [
                    'baseUrl' => $this->returnBasePath(),
                    'userimage' => $userimage,
                    'useremail' => $email,
                    'url' => $url,
                    'username' => $username,
                    'subjectname' => $gradeDetail['GRADE_NAME'],
                    'subjectimage' => $bookimage,
                    'subscription_num' => $subScrData['SUBSCRIPTION_NUM']
                ];

                // first mail goes to user  
                $body = $emailPluginObj->setEmailTemplate('subscription_confirmation.phtml', $params);
                $emailPluginObj->sendMail($email, $body);

                // second mail goes to administartor  
                 $adminemail = $userManagement->getAdminEmail();
                $body = $emailPluginObj->setEmailTemplate('subscription_alert.phtml', $params);
                $emailPluginObj->sendMail($adminemail, $body);
                $this->container->subscribe = 1;
            }
        }
    }

    /*
     * @desc   Set language selected from the drop down list	
     */

    public function languageAction() {
        //$language = $this->params('lang');		
        $language = strtoupper($this->params('lang'));
        if ($language) {
            $session = new Container('language');
            $config = $this->serviceLocator->get('config');
            $clang = array_search($language, $config['locale']['available']);
            if (isset($config['locale']['available'][$clang])) {
                $session->language = str_replace($language . "_", '', $clang);
                $this->container->language = $session->language;
                $this->container->countryCode = strtoupper($session->language);
                // set language
                $this->serviceLocator->get('translator')->setLocale($session->language);
            }
        }
        if (!$this->getRequest()->isXmlHttpRequest()) {
            $server_url = $this->getRequest()->getUri();
            $url = explode('/', $server_url);
            $arr = array_pop($url);
            $arr = array_pop($url);
            $newurl = implode('/', $url);
            return $this->redirect()->toUrl($newurl);
        }
         echo "1";
        die;
    }

    //simialr books
    /* public function similarbookAction() {        
      $book_id = $this->params('bookid');
      $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
      $this->db = new AtbTable($dbadapter);


      $bookDetails = $this->db->getBookPublicDetails($book_id);
      echo "<pre>";
      print_r($bookDetails);
      exit;
      $similarBooks = $this->getSimilarBooks($bookDetails);
      //echo '<pre>';print_r($csdata);die;
      if ($this->getRequest()->isXmlHttpRequest()) {
      $htmlViewPart = new ViewModel();
      $htmlViewPart->setTerminal(true)
      ->setTemplate('application/index/similar_books.phtml')
      ->setVariables(array(
      'similarBooks' => $similarBooks,
      'book_id' => $book_id
      ));
      $htmlOutput = $this->getServiceLocator()->get('viewrenderer')->render($htmlViewPart);
      $jsonModel = new JsonModel();
      $jsonModel->setVariables(array(
      //'html' => str_replace('          ','',$htmlOutput)
      //'html' => str_replace('&#65279;','',$htmlOutput)
      'html' => $htmlOutput
      ));
      return $jsonModel;
      }
      } */

    // Get similar subject details Data
    public function similarbookAction() {
        $subject_id = $this->params('bookid');

        $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
        $admTable = $this->initTable('Secure\Model\Administrator\AdministratorTable');
        //$this->db = new AtbTable($dbadapter);
        // Feth the subject details         
        $subjectDetails = $admTable->getSubjectPublicDetails($subject_id);
        //echo '<pre>'; print_r($subjectDetails);	die;
        //$similarBooks = $this->getSimilarBooks($bookDetails);
        $similarBooks = $this->getSimilarBooks($subjectDetails);
        //echo '<pre>';print_r($similarBooks);die;
        //echo '<pre>';print_r($csdata);die;
        if ($this->getRequest()->isXmlHttpRequest()) {
            $htmlViewPart = new ViewModel();
            $htmlViewPart->setTerminal(true)
                    ->setTemplate('application/index/similar_books.phtml')
                    ->setVariables(array(
                        'similarBooks' => $similarBooks,
                        'book_id' => $book_id
            ));
            $htmlOutput = $this->getServiceLocator()->get('viewrenderer')->render($htmlViewPart);
            $jsonModel = new JsonModel();
            $jsonModel->setVariables(array(
                //'html' => str_replace('          ','',$htmlOutput)
                //'html' => str_replace('&#65279;','',$htmlOutput)
                'html' => $htmlOutput
            ));
            return $jsonModel;
        }
    }

    //get similar books from cloud search
    function getSimilarBooks($subjectDetails) {

        $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
        $admTable = $this->initTable('Secure\Model\Administrator\AdministratorTable');
        $cloudSearch = ['KEY' => 'title', 'VALUE' => 'grade'];
        $series = $author = $publisher = $seriesCond = $authorCond = $publisherCond = '';
        if (!empty($subjectDetails['GRADE_ID'])) {
            // grade series
            $gradeSeries = $admTable->getGradenameById($subjectDetails['GRADE_ID']);
            $grades = $gradeSeries['GRADE_NAME'];
            //echo '<pre>';print_r($gradeSeries);			
            //$bookSeries = $admTable->getSeriesNameById($bookDetails['ADM_SERIES_ID']);
            $cloudSearch = ['KEY' => 'grade', 'VALUE' => $grades];
            $gradeCond = "(or grade:'" . $grades . "')";
        }
        //echo '<pre>';print_r($cloudSearch);die;
        $config = $this->serviceLocator->get('config');
        $cloudSearchUrl = $config['cloud_search_endpoint'];
        $returnField = "&return=_all_fields,_score&sort=_score desc&size=6";
        $countryCode = $this->container->countryCode;
        $serachString = '';
        if ($cloudSearch['VALUE'] != 'grade') {
            //$serachString = "(or ".$cloudSearch['KEY'].":'".$cloudSearch['VALUE']."')";
            $serachString = "$gradeCond";
        }

        $cs_string_cond = "&fq=(and " . $serachString . " )";
        //echo $cs_string_cond;die;
        /* $inputString = 'book';
          $q = "q=".urlencode($inputString);
          $CSUrl = $cloudSearchUrl.'?'.$q.$cs_string_cond.$returnField;
          if($CSUrl!=""){
          $CSUrl=str_replace("'",'%27',$CSUrl);
          $CSUrl=str_replace(" ",'%20',$CSUrl);
          $searchData=json_decode(file_get_contents($CSUrl),true);
          } */
        $searchData = $this->getCloudSearchData($cloudSearchUrl, $cs_string_cond, $returnField);
        //echo '<pre>';print_r($searchData);die;
        $csdata = [];
        if (isset($searchData['hits']['found'])) {
            $i = 0;
            foreach ($searchData['hits']['hit'] as $data) {
                $csdata[$i]['id'] = $data['id'];
                $csdata[$i]['action_url'] = $data['fields']['action_url'];
                $csdata[$i]['title'] = $data['fields']['title'];
                $csdata[$i]['image_url'] = $data['fields']['thumb_url'];
                //$csdata[$i]['content_type'] = $data['fields']['content_type'];
                $csdata[$i]['fp'] = $data['fields']['course_price'];
                $i++;
            }
        }
        if (count($csdata) < 5) {
            $cs_string_cond = null;
            $searchData2 = $this->getCloudSearchData($cloudSearchUrl, $cs_string_cond, $returnField);
            if (isset($searchData2['hits']['hit'])) {
                foreach ($searchData2['hits']['hit'] as $data2) {
                    $csdata[$i]['action_url'] = $data2['fields']['action_url'];
                    $csdata[$i]['title'] = $data2['fields']['title'];
                    $csdata[$i]['image_url'] = $data2['fields']['thumb_url'];
                    //$csdata[$i]['content_type'] = $data['fields']['content_type'];
                    $csdata[$i]['fp'] = $data2['fields']['course_price'];
                    $i++;
                }
            }
        }
        return $csdata;
    }

    function getCloudSearchData($cloudSearchUrl, $cs_string_cond = null, $returnField, $contentFlag = 0) {
        if ($contentFlag == 1) {
            $inputString = 'content';
        } else {
            $inputString = 'subject';
        }
        $q = "q=" . urlencode($inputString);
        $CSUrl = $cloudSearchUrl . '?' . $q . $cs_string_cond . $returnField;
        $CSUrl = str_replace("'", '%27', $CSUrl);
        $CSUrl = str_replace(" ", '%20', $CSUrl);
        $searchData = @json_decode(file_get_contents($CSUrl), true);
        return $searchData;
    }

    //home page cloud search data
    function getHomePageCsData() {
        $config = $this->serviceLocator->get('config');
        $cloudSearchUrl = $config['cloud_search_endpoint'];
        $returnField = "&return=_all_fields,_score&sort=_score desc&size=15";
        $countryCode = $this->container->countryCode;
        if ($countryCode == '' || $countryCode == '-') {
            $cs_string_cond = "&fq=(and (or mode:'ATB') (or homepage:'Y'))";
        } else {
            $cs_string_cond = "&fq=(and (or mode:'ATB') (or homepage:'Y') (or dist:'" . $countryCode . "'))";
        }
        $searchData = $this->getCloudSearchData($cloudSearchUrl, $cs_string_cond, $returnField);
        return $searchData;
    }

    function enableButtonOnbookDetailPage($book_id) {
        $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
        $this->db = new AtbTable($dbadapter);
        $isLogged = false;
        $subcriptionDetail = array();
        $options = array();
        if (!empty($this->container->authDetail['USER_OID'])) {
            $isLogged = 1;
            if (empty($this->container->authDetail['ORG_ID'])) {
                if ($this->container->authDetail['UT_ID'] == 1 || $this->container->authDetail['UT_ID'] == 3) {
                    if (!empty($this->container->authDetail['EMAIL_ID'])) {
                        $options['showBox'] = true;
                    }
                }
            } else {
                $options['showBox'] = false;
            }
        } else {
            $options['showBox'] = true;
        }
        if ($isLogged) {
            $subcriptionDetail = $this->db->getBookSubscriptionDetail($this->container->authDetail['USER_OID'], $book_id);
            if (!count($subcriptionDetail)) {
                $options['buyOption'] = true;
            } else {
                if ($subcriptionDetail['SUBSCRIPTION_TYPE'] == 'B') {
                    $options['readOption'] = true;
                } else if ($subcriptionDetail['SUBSCRIPTION_TYPE'] == 'R') {
                    $expireDate = $subcriptionDetail['EXPIRE_ON'];
                    $today = date("Y-m-d");
                    if ($today > $expireDate) {
                        $options['buyOption'] = true;
                    } else {
                        $options['readOption'] = true;
                    }
                }
            }
        } else {
            $options['subscribeOption'] = true;
        }
        return $options;
    }

    //user/customer registration 
    public function userAction() {
        $lang = (!empty($this->container->language)) ? $this->container->language : 'en';
        $useralias = $this->params('useralias');
        $this->CommonClass()->setCustomLayout($this, 'homeLayout');
        $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
        $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
        $this->db = new UserManagementTable($dbadapter);
        $userId = $this->db->getUserIdByAlias($useralias);
        $connectionUser=array();
        /* for referal url*/
        $referer = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
        $refererURL = '';
        if ($referer) {			
            $refererURL = (strpos($referer, 'user') != false) ? $referer : '';
        }
        
        if (empty($userId)) {
            $userId = $useralias;
        }
       
        $userdetail = $this->db->getUserDetail($userId);
         
        if(count($userdetail)>0){
           $connectionUser= $this->db->getUserConnection($userdetail[0]["USER_OID"]);
        }
        
        $fname = (!empty($userdetail[0]["FIRST_NAME"])) ? $userdetail[0]["FIRST_NAME"] : '';
        $lname = (!empty($userdetail[0]["LAST_NAME"])) ? $userdetail[0]["LAST_NAME"] : '';
        $orgId = (!empty($userdetail[0]["ORG_ID"])) ? $userdetail[0]["ORG_ID"] : '';

        $title = $fname . " " . $lname;
        $translator = $this->getServiceLocator()->get('translator');
        $param = [
            'title' => $title . " - " . $translator->translate("Kalemon"),
            'keywords' => $title,
            'description' => $title
        ];
        $this->CommonClass()->setMetaData($this, $param);
        if (!count($userdetail)) {
            return $this->notFoundAction();
        }
        $org = $this->db->getUserOrg($userId);
        $utype = $this->db->getUserTypeByUtid($userdetail[0]['UT_ID']);
    
        if (empty($orgId) && $userdetail[0]['UT_ID'] == 1) {
            $userEnrollData = $this->db->getUserEnrollDataB2c($userId);
        } if (empty($orgId) && $userdetail[0]['UT_ID'] == 2) {
            $userEnrollData = $this->db->getTeacherUserEnrollDataB2c($userId);
        } else {
            $userEnrollData = $this->db->getUserEnrollData($userId);
        }

        $canEdit = 0;
        $USER_OID = $this->container->authDetail['USER_OID'];
        if (!empty($USER_OID) && $USER_OID == $userId) {
            $canEdit = 1;
        }

        $resultCountries = ['' => $translator->translate('Country')];
        $countryList = $this->db->getAllActiveCountries();
        if (count($countryList)) {
            foreach ($countryList as $countryK => $countryV) {
                $resultCountries[$countryV['COUNTRY_ID']] = $countryV['SHORT_NAME'];
            }
        }
        $userdetail[0]['COUNTRY_NAME'] = !empty($resultCountries[$userdetail[0]['COUNTRY_ID']]) ? $resultCountries[$userdetail[0]['COUNTRY_ID']] : '';
        $this->UserProfileForm = new UserProfileForm($this->getServiceLocator()->get('Zend\Db\Adapter\Adapter'), $resultCountries);
        $this->LoginForm = new \Secure\Form\LoginForm();

        $viewModel->setVariables(['userdetail' => $userdetail[0],'connectionUser'=>$connectionUser, 'utype' => $utype, "enrollment" => $userEnrollData, 'lang' => $lang, 'canEdit' => $canEdit, 'profileForm' => $this->UserProfileForm, 'form' => $this->LoginForm, 'org' => $org, 'refererURL' => $refererURL]);
        return $viewModel;
    }
    
    //user/customer registration 
    public function connectionsAction() {
        $lang = (!empty($this->container->language)) ? $this->container->language : 'en';
        $useralias = $this->params('useralias');
        $this->CommonClass()->setCustomLayout($this, 'homeLayout');
        $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
        $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
        $this->db = new UserManagementTable($dbadapter);
        $userId = $this->db->getUserIdByAlias($useralias);
        $connectionUser=array();
        /* for referal url*/
        $referer = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
        $refererURL = '';
        if ($referer) {			
            $refererURL = (strpos($referer, 'user') != false) ? $referer : '';
        }
        
        if (empty($userId)) {
            $userId = $useralias;
        }
       
        $userdetail = $this->db->getUserDetail($userId);
         
        if(count($userdetail)>0){
           $connectionUser= $this->db->getUserConnection($userdetail[0]["USER_OID"]);
        }
        
        $fname = (!empty($userdetail[0]["FIRST_NAME"])) ? $userdetail[0]["FIRST_NAME"] : '';
        $lname = (!empty($userdetail[0]["LAST_NAME"])) ? $userdetail[0]["LAST_NAME"] : '';
        $orgId = (!empty($userdetail[0]["ORG_ID"])) ? $userdetail[0]["ORG_ID"] : '';

        $title = $fname . " " . $lname;
        $translator = $this->getServiceLocator()->get('translator');
        $param = [
            'title' => $title . " - " . $translator->translate("Kalemon"),
            'keywords' => $title,
            'description' => $title
        ];
        $this->CommonClass()->setMetaData($this, $param);
        if (!count($userdetail)) {
            return $this->notFoundAction();
        }
        $org = $this->db->getUserOrg($userId);
        $utype = $this->db->getUserTypeByUtid($userdetail[0]['UT_ID']);
    
        if (empty($orgId) && $userdetail[0]['UT_ID'] == 1) {
            $userEnrollData = $this->db->getUserEnrollDataB2c($userId);
        } if (empty($orgId) && $userdetail[0]['UT_ID'] == 2) {
            $userEnrollData = $this->db->getTeacherUserEnrollDataB2c($userId);
        } else {
            $userEnrollData = $this->db->getUserEnrollData($userId);
        }

        $canEdit = 0;
        $USER_OID = $this->container->authDetail['USER_OID'];
        if (!empty($USER_OID) && $USER_OID == $userId) {
            $canEdit = 1;
        }

        $resultCountries = ['' => $translator->translate('Country')];
        $countryList = $this->db->getAllActiveCountries();
        if (count($countryList)) {
            foreach ($countryList as $countryK => $countryV) {
                $resultCountries[$countryV['COUNTRY_ID']] = $countryV['SHORT_NAME'];
            }
        }
        $userdetail[0]['COUNTRY_NAME'] = !empty($resultCountries[$userdetail[0]['COUNTRY_ID']]) ? $resultCountries[$userdetail[0]['COUNTRY_ID']] : '';
        $this->UserProfileForm = new UserProfileForm($this->getServiceLocator()->get('Zend\Db\Adapter\Adapter'), $resultCountries);
        $this->LoginForm = new \Secure\Form\LoginForm();

        $viewModel->setVariables(['userdetail' => $userdetail[0],'connectionUser'=>$connectionUser, 'utype' => $utype, "enrollment" => $userEnrollData, 'lang' => $lang, 'canEdit' => $canEdit, 'profileForm' => $this->UserProfileForm, 'form' => $this->LoginForm, 'org' => $org, 'refererURL' => $refererURL]);
        return $viewModel;
    }

    function addCommentAction() {
        $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
        $this->Form = new AddCommentForm();
        $request = $this->getRequest();
        if ($request->isPost()) {
            $postData = $request->getPost()->toArray();
            $postData['USER_OID'] = $this->container->authDetail['USER_OID'];
            $postData['BOOK_ID'] = $this->params('bookid');
            $postData['IP_SRC'] = $_SERVER['REMOTE_ADDR'];
            $postData['CREATED_ON'] = date("Y-m-d h:i:s");
            $addCommnet = new AddCommentInputFilter($this->getServiceLocator()->get('Zend\Db\Adapter\Adapter'));
            $this->Form->setInputFilter($addCommnet->getInputFilter());
            $this->Form->setData($request->getPost());
            $translator = $this->getServiceLocator()->get('translator');
            if ($this->Form->isValid()) {
                $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
                $this->db = new AtbTable($dbadapter);
                if (empty($postData['ATB_REVIEW_ID'])) {
                    $result = $this->db->saveCommentsData($postData);
                } else {
                    $result = $this->db->updateCommentsData($postData);
                }
                if ($result) {
                    $url = $this->returnBasePath() . "/book/" . $postData['BOOK_ID'];
                    $result = ['result' => true, 'redirectUrl' => $url];
                } else {
                    $result = ['result' => false, 'message' => 'Could not process'];
                }
            } else {
                $result = ['result' => false, 'message' => $this->Form->getMessages()];
            }
            $viewModel->setVariables(['data' => $result]);
            return $viewModel;
        }
    }

    function downloadFilesAction() {
        $config = $this->getServiceLocator()->get('config');
        $id = $this->params('id');
        $user_id = $this->params('user_id');
        $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
        $assignment = new AssignmentTable($dbadapter);
        if (!$user_id) {
            $files = $assignment->getFilesBYAssignmentId($id);
        } else {
            $files = $assignment->getAllSubmissionByAssignmentAttemptId($id);
        }
        $filearray = array();
        $viewHelperManager = $this->getServiceLocator()->get('ViewHelperManager');
        $s3Link = $viewHelperManager->get('s3Link');
        foreach ($files as $file) {
            $filearray[] = str_replace('https', 'http', $s3Link('CONTENT/' . $file['FILE_NAME'], $config['s3bucket']));
        }
        # create new zip opbject
        $zip = new ZipArchive();
        # create a temp file & open it
        $tmp_file = tempnam('.', '');
        $zip->open($tmp_file, ZipArchive::CREATE);
        # loop through each file
        foreach ($filearray as $file) {
            # download file
            $download_file = file_get_contents($file);
            #add it to the zip
            $zip->addFromString(basename($file), $download_file);
        }
        # close zip
        $zip->close();
        # send the file to the browser as a download
        header('Content-disposition: attachment; filename=assignment_' . (date("d_m_Y_h_i_s")) . '.zip');
        header('Content-type: application/zip');
        readfile($tmp_file);
        exit();
    }

    public function schooldetailsAction() {
        $gradelist = [];
        $i = 0;
        $id = (int) $this->params('id');
        $this->CommonClass()->setCustomLayout($this, 'homeLayout');
        $viewModel = $this->acceptableViewModelSelector($this->acceptCriteria);
        $request = $this->getRequest();
        $adm = new UserManagementTable($this->getAdapter());
        $curriculumTable = new \Curriculum\Model\CurriculumTable($this->getAdapter());
        $schooldata = $adm->getSchoolDetail($id);
        $gradeObj = new \Secure\Model\Grade\GradeTable($this->getAdapter());
        $impordetedGrades = $gradeObj->getAllImportedGrade($schooldata['ORG_ID']);
        //$dataArray = $this->apiCall()->getCcoGradeList($schooldata['PROJECT_UUID']);
        $dataArray = array();
        if (empty($schooldata['PROJECT_UUID'])) {
            $dataArray = array();
        }
        $countrylist = $curriculumTable->getCountryDetails();             //fetch countries from local
        foreach ($countrylist as $data) {
            if ($data['COUNTRY_ID'] == $schooldata['COUNTRY_ID']) {
                $country = $data['SHORT_NAME'];
            }
        }
        foreach ($dataArray as $data) {
            foreach ($impordetedGrades as $import) {
                if ($data['GRADE_ID'] == $import) {
                    $gradelist[$i] = $data;
                    $i++;
                }
            }
        }
        return $viewModel->setVariables(['schooldata' => $schooldata, 'country' => empty($country) ? '' : $country, 'gradelist' => $gradelist]);
    }

    public function contentdetailAction() {

        $translator = $this->getServiceLocator()->get('translator');
        $contentId = $this->params('id');
        $subjectId = $this->params('second_id');
        $test_type = ''; // !empty($this->params()->fromQuery('test_type')) ? $this->params()->fromQuery('test_type') : '';
        $this->db = new AdmgradeTable($this->getAdapter());
        $ordId = null;
        $uId = $this->container->authDetail['USER_OID'];
        $isValidContId = $this->db->validContId($uId, $contentId);
        $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
        $grade = new AdmgradeTable($dbadapter);
        if (empty($this->container->authDetail["UT_ID"])) {
            return $this->redirect()->toRoute('secure', array('action' => 'login'));
        }
        $arrEnv["user_id"] = (!empty($this->container->authDetail['USER_OID'])) ? $this->container->authDetail['USER_OID'] : null;
        $arrEnv["subject_id"] = $subjectId;
                
        //get grade by subject 
        $subjectDetail=$this->db->getSubjectDetailContentDetail($arrEnv);
        
        $inrollData = $this->db->getSubjectUserEnrollData($arrEnv);
        
        if(empty($inrollData)){
              //again check for grade exist
              $arrEnv['grade_id']=$subjectDetail['GRADE_ID'];
             $inrollData  = $this->db->getGradeUserEnrollData($arrEnv);
           
        }
        
//        echo '<pre />'; print_r($inrollData); 
//        
//        die('macro');
        
        
        if (empty($inrollData)) {
            return $this->redirect()->toRoute('secure', array('action' => 'login'));
        }
        if (!$isValidContId && empty($test_type)) {
            return $this->redirect()->toRoute('admgrade', array('action' => 'lesson-plan'));
        }
        //print_r($this->container->authDetail['ATB_AUTH_TOKEN']);die;


        $displaybook = 0;
        if ($contentId && empty($test_type)) {
            $quizDetail = array();
            $getLessionId = $this->db->getLessonplanIdByContentId($contentId);
            $condArr['LP_ID'] = $getLessionId;
            $userIds = null;
            $this->db = new AdmgradeTable($this->getAdapter());
            $lpData = $this->db->getContentsByLpid($getLessionId);

            $contentData = $this->db->getContentByContentId($contentId);
            //$lpData = $this->db->getContentBySubjectId($subjectId);

            $courseId = $grade->getCourseId($contentId);
            $GetLaunchUrl = $reportpage = "";
            if (!empty($courseId)) {

                $baseDirPath = getcwd() . '/library/';
                require_once($baseDirPath . "scorm/ScormEngineUtilities.php");
                require_once($baseDirPath . 'scorm/ScormEngineService.php');
                require_once($baseDirPath . 'scorm/Configuration.php');
                require_once($baseDirPath . 'scorm/ServiceRequest.php');
                require_once($baseDirPath . 'scorm/ReportingService.php');
                $config = $this->serviceLocator->get('config');
                $ServiceUrl = $config['scorm_serviceurl'];
                $SecretKey = $config['scorm_secretkey'];
                $AppId = $config['scorm_appid'];
                $Origin = ScormEngineUtilities::getCanonicalOriginString('Piron', 'Test', 'Version 2.0');
                $ScormService = new ScormEngineService($ServiceUrl, $AppId, $SecretKey, $Origin);
                $regService = $ScormService->getRegistrationService();
                $status = "Uncomplete";
                $REG_ID = $grade->checkScormUserRegistration($courseId, $this->container->authDetail['USER_OID']);
                if (empty($REG_ID)) {
                    $regId = uniqid(rand(), true);
                    $learnerId = $this->container->authDetail['EMAIL_ID'];
                    $learnerFirstName = $this->container->authDetail['FIRST_NAME'];
                    $learnerLastName = $this->container->authDetail['LAST_NAME'];
                    // Save on scorm
                    $response = $regService->CreateRegistration($regId, $courseId, $learnerId, $learnerFirstName, $learnerLastName);
                    // Saving data into tables
                    $regArr['SCORM_COURSE_ID'] = $courseId;
                    $regArr['USER_OID'] = $this->container->authDetail['USER_OID'];
                    $regArr['REG_ID'] = $regId;
                    $grade->saveUserScormRegistration($regArr);
                    $REG_ID = $regId;
                }
                //echo "$REG_ID, $courseId <br/>" ;
                $conf = new Configuration($config['scorm_serviceurl'], $AppId, $SecretKey);
                $srvc = new ReportingService($conf);
                $learnerId = $this->container->authDetail['EMAIL_ID'];
                $homePage = "/Reportage/reportage.php?appId=$AppId";
                $learnerPage = $homePage . "&courseId=$courseId&learnerId=$learnerId";
                $reportageAuth = $srvc->GetReportageAuth('NONAV', false);
                $reportpage = $srvc->GetReportUrl($reportageAuth, $learnerPage);
                $GetLaunchUrl = $regService->GetLaunchUrl($REG_ID, $reportpage);
                /*
                  $allResults = $regService->GetLaunchHistory($REG_ID);
                  if(count($allResults)){
                  foreach($allResults as $result){
                  if($result->getCompletion()=='complete' && $result->getSatisfaction()=='passed'){
                  $status = "Completed";
                  break;
                  }
                  }
                  } */
            }
//            if (!empty($contentData['EXTERNAL_ID'])) {
//                if ($contentData['CONTTYPE_ID'] == '13') {
//                    $grade = new AdmgradeTable($dbadapter);
//                    $contDataTemp = $contentData;
//                    $bookData = $grade->getBookDetailByBookId($contentData['EXTERNAL_ID']);
//                    //echo '<pre>';print_r($contentData);die;
//                    //$contentData['LESSONPLAN_ID'] = $contDataTemp['LESSONPLAN_ID'];
//                    //$contentData['CONT_ID'] = $contDataTemp['CONT_ID'];
//                    //$contentData['CONT_TYPE'] = $this->db->getContentTypeById($contentData['CONTTYPE_ID']);//ENRICHMENT : [VIDEO/AUDIO/WIDGET/DOCUMENT]
//                    //$contentData['CONT_ID'] = $contentData['ENRICHCONT_ID'];
//                    $contentData['CONT_TITLE'] = $bookData['BOOK_NAME'];
//                    $contentData['BOOK_HASH'] = $bookData['BOOK_HASH'];
//                    $contentData['CONT_DESC'] = $bookData['BOOK_DESCRIPTION'];
//                    $contentData['BACKING_FILE'] = $bookData['BOOK_BACKING_FILE'];
//                    //print_r($contentData);die;
//                } else {
//                    $adm = new AdministratorTable($dbadapter);
//                    $contDataTemp = $contentData;
//                    $contentData = $adm->getEnrichmentContentById($contentData['EXTERNAL_ID']);
//                    $contentData['BACKING_FILE'] = 'LOL/' . $contentData['BACKING_FILE'];
//                    //echo '<pre>';print_r($contentData);die;
//                    $contentData['LESSONPLAN_ID'] = $contDataTemp['LESSONPLAN_ID'];
//                    $contentData['CONT_ID'] = $contDataTemp['CONT_ID'];
//                    $contentData['CONT_TYPE'] = $this->db->getContentTypeById($contentData['CONTTYPE_ID']); //ENRICHMENT : [VIDEO/AUDIO/WIDGET/DOCUMENT]
//                    //$contentData['CONT_ID'] = $contentData['ENRICHCONT_ID'];
//                    $contentData['CONT_TITLE'] = $contentData['ENRICHCONT_TITLE'];
//                    $contentData['CONT_DESC'] = $contentData['ENRICHCONT_DESC'];
//                }
//            }
            /*             * ******************************** Acl Checking Start *********************************** */

            $aclCheck = 0;
            if (!empty($contentData['EXTERNAL_ID'])) {
                if ($contentData['CONTTYPE_ID'] == '13') {
                    $aclCheck = 1;
                }
            }
            $register = 0;


            $liveClassUrl = "";
            if ($contentData['CONTTYPE_ID'] == 15) {
                $liveClassUrl = $this->db->getLiveClassUrlByContId($this->container->authDetail["UT_ID"], $contentData["CONT_ID"]);
                //$liveClassUrl = "https://live.wiziq.com/aliveext/LoginToSession.aspx?SessionCode=9sbzXtdmlusyyNLYRsnIhA%3d%3d";
            }
        } else if (!empty($test_type) && ($test_type == 'ST' || $test_type == 'FT')) {
            $lpData = [];
            $quizDetail = [];
            $contentData = [];
            $displaybook = 0;
            $GetLaunchUrl = '';
            $liveClassUrl = '';
        } else {
            return $this->redirect()->toRoute('admgrade', array('action' => 'lesson-plan'));
        }
        if (!empty($contentData)) {
            $param = [
                'title' => $contentData['CONT_TITLE'] . " - " . $translator->translate("Octopus"),
                'keywords' => $contentData['CONT_TITLE'],
                'description' => $contentData['CONT_TITLE']
            ];
        } else {
            $param = ['title' => '', 'keywords' => '', 'description' => ''];
        }
        $authToken = "";
        if ($contentData['CONTTYPE_ID'] == '13') {
            $client = new HttpClient(null, ['timeout' => 1200]);
            //$client 	= new HttpClient();
            $config = $this->getServiceLocator()->get('config');
            $atb = new AtbController();
            $data = $atb->apiAtbBookLogin($config, $client);
            $authToken = $data['auth_token'];
        }
        $this->CommonClass()->setMetaData($this, $param);
        $this->CommonClass()->setCustomLayout($this, 'lpLayout');
        $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
        $viewModel->setVariables([
            'lpData' => $lpData,
            "contentId" => $contentId,
            "subjectId" => $subjectId,
            "contentData" => $contentData,
            'authDetail' => $this->container->authDetail,
            'quizDetail' => $quizDetail,
            'displaybook' => $displaybook,
            'title' => "SK",
            'keywords' => "SK",
            'description' => "SK",
            'GetLaunchUrl' => $GetLaunchUrl,
            'liveClassUrl' => $liveClassUrl,
            'test_type' => $test_type,
            'auth_token' => $authToken,
            'student_id' => $uId
        ]);
        return $viewModel;
    }

    public function userListAction() {
//        $prms = $this->params('id');
//        if (!empty($prms)) {
//            return $this->browse($prms, 'instructor', $this);
//        }
//        $request = $this->getRequest();
//        $admtable = $this->initTable('Secure\Model\Administrator\AdministratorTable');
//        $pageLen = 8;
//        $pagingData['START'] = 0;
//        $pagingData['LENGTH'] = $pageLen;
//        
//        if ($request->isPost() && $request->isXmlHttpRequest()) {
//            $postData = $request->getPost()->toArray();
//            $pagingData['LENGTH'] = (!empty($postData['LENGTH'])) ? $postData['LENGTH'] : $pageLen;
//            $pagingData['START'] = $postData['START'] + $pageLen;
//           //$trainers = $admtable->getTrainerList($pagingData);
//            $userlist = $admtable->getUsersList($pagingData);
//            //echo '<pre />'; print_r($trainers); die('macro');
//            $trainerHtml = $this->getTrainerHtml($userlist);            
//            $view = new JsonModel();
//            $view->setVariables(['html' => $trainerHtml, 'start' => $pagingData['START']]);
//            return $view;
//        }
//       // $trainers = $admtable->getTrainerList($pagingData);
//        $userlist = $admtable->getUsersList($pagingData);
//        $this->CommonClass()->setCustomLayout($this, 'homeLayout');
//        $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
//        $curLocale = $this->serviceLocator->get('translator')->getLocale();
//        $viewModel->setVariables(['curLocale' => $curLocale, 'trainers' => $userlist]);
//        return $viewModel;



        $this->CommonClass()->setCustomLayout($this, 'homeLayout');
        $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
        $request = $this->getRequest();
        $admtable = $this->initTable('Secure\Model\Administrator\AdministratorTable');
        if ($request->isXmlHttpRequest()) {
            $requestQuery = $request->getQuery()->toArray();
            $postData = $request->getPost()->toArray();

            //$data['search'] = (!empty($postData['search'])) ? trim($postData['search']) : null;
            $userlist = $admtable->getUsersList(true);

            $userlist = $this->CommonClass()->setPagination($userlist, 96);

            $courseViewPart = new ViewModel();
            $courseViewPart->setTemplate('application/index/paging-user-listing');
            $courseViewPart->setTerminal(true);

            $courseViewPart->setVariables(array('userlist' => $userlist));

            $htmlOutput = $this->getServiceLocator()->get('viewrenderer')->render($courseViewPart);
            $jsonModel = new JsonModel();
            $jsonModel->setVariables(array(
                'html' => $htmlOutput,
            ));
            return $jsonModel;
        }
        return $viewModel;
    }

    function getTrainerHtml($trainerList) {
        $str = '';
        $base = $this->getRequest()->getBaseUrl();
        $config = $this->getServiceLocator()->get('config');
        $translator = $this->getServiceLocator()->get('translator');
        $viewHelperManager = $this->getServiceLocator()->get('ViewHelperManager');

        if (count($trainerList)) {
            foreach ($trainerList as $detail) {
                $userDefaultImg = $base . '/images/default-instructor.jpg';
                $userDefinedImg = $detail['PROFILE_PHOTO'];
//                if (!empty($userDefinedImg)) {
//                    $s3Link = $viewHelperManager->get('s3Link');
//                    $userImg = str_replace('https', 'http', $s3Link($detail['AUTHOR_IMG'], $config['s3bucket']));
//                } else {
                $userImg = $userDefaultImg;
                // }
                $instructor_fname = !empty($detail['FIRST_NAME']) ? $detail['FIRST_NAME'] : null;
                $instructor_lname = !empty($detail['LAST_NAME']) ? $detail['LAST_NAME'] : null;
                $instructor_full_name = (!empty($instructor_fname) && !empty($instructor_lname)) ? $instructor_fname . ' ' . $instructor_lname : $instructor_fname;
                $instructor_full_name_encoded = !empty($instructor_full_name) ? urlencode($instructor_full_name) : null;

                $str .= '<div class="col-lg-3 col-md-4 col-xs-2 product-container with-subscribed">';
                $str .= '<div class="thumbnail-box">';
                $str .= '<div class="text-box">';
                $str .= '<div class="big-head">';
                $str .= '<a target="_blank" href="' . $viewHelperManager->get('url')->__invoke('browse', ['action' => 'user', 'id' => $detail['USER_OID']]) . '">';
                $str .= !empty($instructor_full_name) ? $instructor_full_name : '';
                $str .= '</div>';
                $str .= '</div>';
                $str .= '</div>';
                $str .= '</div>';
            }
        } else {
            $str .= '<div class="col-lg-12 text-center">' . $translator->translate('There are no data available here.') . '</div>';
        }
        return stripslashes($str);
    }

    /**
     * @desc used to calculate product price after discount.
     * @updated by SAIF <shakeel.saif@pironcorp.com>
     * @return JsonModel | Array
     */
    function discountCouponAction() {
        $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
        $request = $this->getRequest();
        $postData = $request->getPost()->toArray();
        $couponTable = $this->initTable('CouponCode\Model\CouponTable');
         //print_r($this->container->authDetail);die;
        /** Set user specific time-zone as default. */
        $helperManager = $this->getServiceLocator()->get('ViewHelperManager');
        $get_timezone = $helperManager->get('WiziqHelper')->getUserTimeZone();
        $timezone = ($get_timezone == 'UTC') ? 'Asia/Kolkata' : $get_timezone;
        date_default_timezone_set($timezone);

        /** Proceed only if COUPON CODE typed for existed subject with id. */
        if (!empty($postData['COUPON_CODE'])) {
            //get coupon data 
            $getCouponData = $couponTable->getCouponCodeData('', $postData['COUPON_CODE']);

            /** proceed if coupon code matched with existed coupon */
            if (isset($getCouponData['COUPON_CODE']) && $getCouponData['COUPON_CODE'] == $postData['COUPON_CODE']) {
                //for subject coupon
                if (isset($postData['SUBJECT_ID']) && !empty($postData['SUBJECT_ID'])) {
                    $result = $this->subjectCoupon($postData['SUBJECT_ID'], $getCouponData);
                //for all content check     
                } else if(isset($postData['CONTENT_ID']) ) {
                     $result = $this->contentCoupon($postData['CONTENT_ID'], $getCouponData);
                   //  echo $postData['CONTENT_ID'];die;
                }else{
                    //for grade coupon
                    $result = $this->gradeCoupon($postData['GRADE_ID'], $getCouponData);
                }
            } else {
                $result = array("status" => '407', 'msg' => 'Coupon code does not exist', 'data' => '');
            }
        } else {
            $result = array("status" => '408', 'msg' => 'Coupon code required', 'data' => '');
        }

        $viewModel->setVariables(['result' => $result]);
        return $viewModel;
    }
        //content coupon validation check here
    private function contentCoupon($contentId, $getCouponData) {
        $couponTable = $this->initTable('CouponCode\Model\CouponTable');
        $curDate = date('Y-m-d H:i:s');
        $coupon_id = $getCouponData['COUPON_ID'];
        $start_date = $getCouponData['START_DATE'];
        $expiry_date = $getCouponData['EXPIRY_DATE'];
        $is_active = $getCouponData['COUPON_STATUS'];
        $isCouponNotCreated = strtotime($curDate) < strtotime($start_date);
        $discount_type = $getCouponData['DISCOUNT_TYPE'];
        $discount_amount = $getCouponData['DISCOUNT_AMOUNT'];
        $distribution = $getCouponData['DISTRIBUTION'];
        $useFor = $getCouponData['USE_FOR'];
        $is_used = $getCouponData['IS_USED'];
        $postData['CONTENT_ID'] = $contentId;
        /** Get subject, grade details by subject */
        $contentData = $couponTable->getContent($postData['CONTENT_ID']);
 
        if ($isCouponNotCreated || $is_active == 'I') {
            $result = array("status" => '400', 'msg' => 'Coupon code has expired', 'data' => '');
        } else if (strtotime($expiry_date) < strtotime($curDate)) {
            $result = array("status" => '401', 'msg' => 'Coupon code has expired', 'data' => '');
        } else if ($useFor == 'S' && $is_used > 0) {
            $result = array("status" => '402', 'msg' => 'This coupon is already used', 'data' => '');
        } else if (count($contentData) > 0) {
            $price = $contentData['CONT_PRICE'];
            if ($discount_type == 'percentage') {
                $discountValue = $price * ($discount_amount / 100);
            } else if ($discount_type == 'fixed') {
                $discountValue = $discount_amount;
            }
            if ($price >= $discountValue) {
                $getCouponData['DISCOUNT_AMT_VALUE'] = $discountValue;
                $getCouponData['DISCOUNTED_PRICE'] = $price - $discountValue;
                /** C = all content */
                if ($distribution == 'C') {
                    $result = array("status" => '200', 'msg' => 'This coupon has been applied successfully', 'data' => $getCouponData);
                }else if ($distribution == 'SC') {
                    /** Get All standards array for checking which have coupon available for */
                    $distCouponContent = $couponTable->fetchData('t_coupon_cnf_content', ['COUPON_ID' => $coupon_id], ['CONT_ID']);
                    $distCouponContentArray = [];
                    if (count($distCouponContent)) {
                        foreach ($distCouponContent as $distContent) {
                            $distCouponContentArray[] = $distContent['CONT_ID'];
                        }
                    }
                    /******* Proceed if standard exists in distributed content-array. *******/
                    if (in_array($contentData['CONT_ID'], $distCouponContentArray)) {
                        $result = array("status" => '200', 'msg' => 'This coupon has been applied successfully', 'data' => $getCouponData);
                    } else {
                        $result = array("status" => '403', 'msg' => 'This coupon is not available for this content', 'data' => '');
                    }
                }else{
                      $result = array("status" => '400', 'msg' => 'Coupon code is not valid for this product', 'data' => '');
                }
            } else {
                $result = array("status" => '405', 'msg' => 'Coupon code does not applied for this product', 'data' => '');
            }
        } else {
            $result = array("status" => '406', 'msg' => 'Content does not exist', 'data' => '');
        }
        return $result;
    }
    
    
    
      //grade coupon validation check here
    private function gradeCoupon($grade_Id, $getCouponData) {
        $couponTable = $this->initTable('CouponCode\Model\CouponTable');
        $curDate = date('Y-m-d H:i:s');
        $coupon_id = $getCouponData['COUPON_ID'];
        $start_date = $getCouponData['START_DATE'];
        $expiry_date = $getCouponData['EXPIRY_DATE'];
        $is_active = $getCouponData['COUPON_STATUS'];
        $isCouponNotCreated = strtotime($curDate) < strtotime($start_date);
        $discount_type = $getCouponData['DISCOUNT_TYPE'];
        $discount_amount = $getCouponData['DISCOUNT_AMOUNT'];
        $distribution = $getCouponData['DISTRIBUTION'];
        $useFor = $getCouponData['USE_FOR'];
        $is_used = $getCouponData['IS_USED'];
        $postData['GRADE_ID'] = $grade_Id;
        /** Get subject, grade details by subject */
        $gradeData = $couponTable->getGradeDetail($postData['GRADE_ID']);
          //print_r($getCouponData);die;
        if ($isCouponNotCreated || $is_active == 'I') {
            $result = array("status" => '400', 'msg' => 'Coupon code has expired', 'data' => '');
        } else if (strtotime($expiry_date) < strtotime($curDate)) {
            $result = array("status" => '401', 'msg' => 'Coupon code has expired', 'data' => '');
        } else if ($useFor == 'S' && $is_used > 0) {
            $result = array("status" => '402', 'msg' => 'This coupon is already used', 'data' => '');
        } else if (count($gradeData) > 0) {
            $price = $gradeData['GRADE_PRICE'];
            if ($discount_type == 'percentage') {
                $discountValue = $price * ($discount_amount / 100);
            } else if ($discount_type == 'fixed') {
                $discountValue = $discount_amount;
            }

            if ($price >= $discountValue) {
                $getCouponData['DISCOUNT_AMT_VALUE'] = $discountValue;
                $getCouponData['DISCOUNTED_PRICE'] = $price - $discountValue;

                /** A = all product, S=standard, P=subject,G=garde */
                if ($distribution == 'A') {
                    $result = array("status" => '200', 'msg' => 'This coupon has been applied successfully', 'data' => $getCouponData);
                } else if ($distribution == 'S') {
                    /** Get All standards array for checking which have coupon available for */
                    $distCouponStandards = $couponTable->fetchData('t_coupon_cnf_stdn', ['COUPON_ID' => $coupon_id], ['STANDARD_ID']);
                    $distCouponStandardsArray = [];
                    if (count($distCouponStandards)) {
                        foreach ($distCouponStandards as $distStandard) {
                            $distCouponStandardsArray[] = $distStandard['STANDARD_ID'];
                        }
                    }

                    /** Proceed if standard exists in distributed standard-array. **/
                    if (in_array($gradeData['STANDARD_ID'], $distCouponStandardsArray)) {
                        $result = array("status" => '200', 'msg' => 'This coupon has been applied successfully', 'data' => $getCouponData);
                    } else {
                        $result = array("status" => '403', 'msg' => 'This coupon is not available for this Subject', 'data' => '');
                    }
                }
//                else if ($distribution == 'P') {
//                    /** Get All Subjects array for checking which have coupon available for */
//                    $distCouponSubjects = $couponTable->fetchData('t_coupon_cnf_product', ['COUPON_ID' => $coupon_id], ['SUBJECT_ID']);
//                    $distCouponSubjectsArray = [];
//                    if (count($distCouponSubjects)) {
//                        foreach ($distCouponSubjects as $distSubject) {
//                            $distCouponSubjectsArray[] = $distSubject['SUBJECT_ID'];
//                        }
//                    }
//                    /** Proceed if subject exists in distributed subject-array. */
//                    if (in_array($gradeData['SUBJECT_ID'], $distCouponSubjectsArray)) {
//                        $result = array("status" => '200', 'msg' => 'This coupon has been applied successfully', 'data' => $getCouponData);
//                    } else {
//                        $result = array("status" => '404', 'msg' => 'This coupon is not available for this Subject', 'data' => '');
//                    }
//                } 
                else if ($distribution == 'G') {
                    /** Get All grade array for checking which have coupon available for */
                    $distCouponGrades = $couponTable->fetchData('t_coupon_cnf_grade', ['COUPON_ID' => $coupon_id], ['GRADE_ID']);
                    $distCouponGradesArray = [];
                    if (count($distCouponGrades)) {
                        foreach ($distCouponGrades as $distGrade) {
                            $distCouponGradesArray[] = $distGrade['GRADE_ID'];
                        }
                    }
                    /** Proceed if subject exists in distributed subject-array. */
                    if (in_array($gradeData['GRADE_ID'], $distCouponGradesArray)) {
                        $result = array("status" => '200', 'msg' => 'This coupon has been applied successfully', 'data' => $getCouponData);
                    } else {
                        $result = array("status" => '404', 'msg' => 'This coupon is not available for this Course', 'data' => '');
                    }
                }else{
                      $result = array("status" => '400', 'msg' => 'Coupon code is not valid for this product', 'data' => '');
                }
            } else {
                $result = array("status" => '405', 'msg' => 'Coupon code does not applied for this product', 'data' => '');
            }
        } else {
            $result = array("status" => '406', 'msg' => 'Course does not exist', 'data' => '');
        }
        return $result;
    }
    
    
    
    
    //subject coupon validation check here
    private function subjectCoupon($subectId, $getCouponData) {
        $couponTable = $this->initTable('CouponCode\Model\CouponTable');
        $curDate = date('Y-m-d H:i:s');
        $coupon_id = $getCouponData['COUPON_ID'];
        $start_date = $getCouponData['START_DATE'];
        $expiry_date = $getCouponData['EXPIRY_DATE'];
        $is_active = $getCouponData['COUPON_STATUS'];
        $isCouponNotCreated = strtotime($curDate) < strtotime($start_date);
        $discount_type = $getCouponData['DISCOUNT_TYPE'];
        $discount_amount = $getCouponData['DISCOUNT_AMOUNT'];
        $distribution = $getCouponData['DISTRIBUTION'];
        $useFor = $getCouponData['USE_FOR'];
        $is_used = $getCouponData['IS_USED'];
        $postData['SUBJECT_ID'] = $subectId;
        /** Get subject, grade details by subject */
        $subjectData = $couponTable->getSubejctGrade($postData['SUBJECT_ID']);
 
        if ($isCouponNotCreated || $is_active == 'I') {
            $result = array("status" => '400', 'msg' => 'Coupon code has expired', 'data' => '');
        } else if (strtotime($expiry_date) < strtotime($curDate)) {
            $result = array("status" => '401', 'msg' => 'Coupon code has expired', 'data' => '');
        } else if ($useFor == 'S' && $is_used > 0) {
            $result = array("status" => '402', 'msg' => 'This coupon is already used', 'data' => '');
        } else if (count($subjectData) > 0) {
            $price = $subjectData['SUBJECT_PRICE'];
            if ($discount_type == 'percentage') {
                $discountValue = $price * ($discount_amount / 100);
            } else if ($discount_type == 'fixed') {
                $discountValue = $discount_amount;
            }

            if ($price >= $discountValue) {
                $getCouponData['DISCOUNT_AMT_VALUE'] = $discountValue;
                $getCouponData['DISCOUNTED_PRICE'] = $price - $discountValue;

                /** A = all product, S=standard, P=subject,G=garde */
                if ($distribution == 'A') {
                    $result = array("status" => '200', 'msg' => 'This coupon has been applied successfully', 'data' => $getCouponData);
                } else if ($distribution == 'S') {

                    /** Get All standards array for checking which have coupon available for */
                    $distCouponStandards = $couponTable->fetchData('t_coupon_cnf_stdn', ['COUPON_ID' => $coupon_id], ['STANDARD_ID']);
                    $distCouponStandardsArray = [];
                    if (count($distCouponStandards)) {
                        foreach ($distCouponStandards as $distStandard) {
                            $distCouponStandardsArray[] = $distStandard['STANDARD_ID'];
                        }
                    }

                    /** Proceed if standard exists in distributed standard-array. */
                    if (in_array($subjectData['STANDARD_ID'], $distCouponStandardsArray)) {
                        $result = array("status" => '200', 'msg' => 'This coupon has been applied successfully', 'data' => $getCouponData);
                    } else {
                        $result = array("status" => '403', 'msg' => 'This coupon is not available for this Subject', 'data' => '');
                    }
                } else if ($distribution == 'P') {
                    /** Get All Subjects array for checking which have coupon available for */
                    $distCouponSubjects = $couponTable->fetchData('t_coupon_cnf_product', ['COUPON_ID' => $coupon_id], ['SUBJECT_ID']);
                    $distCouponSubjectsArray = [];
                    if (count($distCouponSubjects)) {
                        foreach ($distCouponSubjects as $distSubject) {
                            $distCouponSubjectsArray[] = $distSubject['SUBJECT_ID'];
                        }
                    }
                    /** Proceed if subject exists in distributed subject-array. */
                    if (in_array($subjectData['SUBJECT_ID'], $distCouponSubjectsArray)) {
                        $result = array("status" => '200', 'msg' => 'This coupon has been applied successfully', 'data' => $getCouponData);
                    } else {
                        $result = array("status" => '404', 'msg' => 'This coupon is not available for this Subject', 'data' => '');
                    }
                } else if ($distribution == 'G') {
                    /** Get All grade array for checking which have coupon available for */
                    $distCouponGrades = $couponTable->fetchData('t_coupon_cnf_grade', ['COUPON_ID' => $coupon_id], ['GRADE_ID']);
                    $distCouponGradesArray = [];
                    if (count($distCouponGrades)) {
                        foreach ($distCouponGrades as $distGrade) {
                            $distCouponGradesArray[] = $distGrade['GRADE_ID'];
                        }
                    }
                    /** Proceed if subject exists in distributed subject-array. */
                    if (in_array($subjectData['GRADE_ID'], $distCouponGradesArray)) {
                        $result = array("status" => '200', 'msg' => 'This coupon has been applied successfully', 'data' => $getCouponData);
                    } else {
                        $result = array("status" => '404', 'msg' => 'This coupon is not available for this Course', 'data' => '');
                    }
                }else{
                      $result = array("status" => '400', 'msg' => 'Coupon code is not valid for this product', 'data' => '');
                }
            } else {
                $result = array("status" => '405', 'msg' => 'Coupon code does not applied for this product', 'data' => '');
            }
        } else {
            $result = array("status" => '406', 'msg' => 'Subject does not exist', 'data' => '');
        }
        return $result;
    }

   
    
    // Subscribe Content function
    function subscribeContent($arr = array()) {

        if (empty($arr["CONTENT_ID"])) {
            return false;
        } else {
            $config = $this->getServiceLocator()->get('config');
            $CONTENT_ID = $arr["CONTENT_ID"];
            $dbadapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
            $admgradeObj = new AdmgradeTable($dbadapter);
            $contentDetail = $admgradeObj->getContentDetailBycId($CONTENT_ID);
            $subScrData['USER_OID'] = $this->container->authDetail['USER_OID'];
            $subScrData['SUBSCRIPTION_NUM'] = time();
            $subScrData['CONT_ID'] = $arr["CONTENT_ID"];
            $subScrData['SUBSCRIBED_ON'] = date("Y-m-d H:i:s");
            $subScrData['subscription_type'] = $arr['subscription_type'];
            $subScrData['TRANSACTION_ID'] = !empty($arr['TRANSACTION_ID']) ? $arr['TRANSACTION_ID'] : null;
            $expireDate = null;
            if(isset($arr['days'])){
             $days = base64_decode($arr['days']);
             if (!empty($days) && $days > 0 && $arr['amount'] > 0) {
                $newDate = strtotime('+' . $days . ' days', time());
                $expireDate = date("Y-m-d H:i:s", $newDate);
             }
            }
             
            $result = $admgradeObj->saveSubscriptionData($subScrData);

            if ($result) {
                $emailPluginObj = new EmailPlugin();
                $userManagement = new UserManagementTable($dbadapter);
                $username = $userManagement->getUserName($subScrData['USER_OID']);
                #$userdetail = $userManagement->getUserDetail($this->container->authDetail['USER_OID']);
                $email = $userManagement->getUserEmail($subScrData['USER_OID']);
                $url = $this->returnBasePath() . "/content/" . $CONTENT_ID;
                $bookimage = $this->returnBasePath() . "/images/default-subject.jpg";
              
                if (!empty($contentDetail['CONT_IMAGE'])) {
                    $viewHelperManager = $this->getServiceLocator()->get('ViewHelperManager');
                    $s3Link = $viewHelperManager->get('s3Link');
                     $bookimage = str_replace('https', 'http', $s3Link("CONTENT/" . $contentDetail['CONT_IMAGE'], $config['s3bucket']));
               
                  }
                $userimage = $this->returnBasePath() . "/images/default-user.png";
                $profileImg = $userManagement->getUserProfileImage($subScrData['USER_OID']);
                if (!empty($profileImg) && $profileImg != '') {

                    $viewHelperManager = $this->getServiceLocator()->get('ViewHelperManager');
                    $s3Link = $viewHelperManager->get('s3Link');
                    $userimage = str_replace('https', 'http', $s3Link("USER/" . $profileImg, $config['s3bucket']));
                }

                /*                 * *******************************  Acl Entry Point Start   ************************************* */
//                echo "<pre>";
//                echo "=contentdetail=";
//                print_r($contentDetail);
//                 echo "=subScrData=";
//                print_r($subScrData);
//                 echo "=arr=";
//                print_r($arr);
//                die;
                if ($contentDetail['CONTTYPE_ID'] == 13) {
                    $client = new HttpClient();
                    $atb = new AtbController();
                    $resp = $atb->apiAtbBookLogin($config, $client);
                    $openBookUrl = $config['atbBaseUrl'] . '/active_textbooks/' . $contentDetail['BOOK_HASH'] . '?locale=en&auth_token=' . $resp['auth_token'];

                    $atb_user_id = $userManagement->getAtbUserId($subScrData['USER_OID']);
                    if ($arr['subscription_type'] == 'B') {
                        $expire_on = null;
                    } else {
                        $expire_on = $expireDate;
                    }
                    
                        if (!empty($contentDetail['BOOK_COVERIMG'])) {
                            $bookimage = $config['atbBaseUrl'] . $contentDetail['BOOK_COVERIMG'];
                        } else {
                            $bookimage =  $this->returnBasePath() .'/images/default_content.png';
                        }

                    $postData = [
                        'annotation_set_id' => $contentDetail['ANNOTATION_SET_ID'],
                        'book_id' => $contentDetail['BOOK_HASH'],
                        'user_id' => $atb_user_id,
                        'type' => 'readonly',
                        'expiration' => $expire_on,
                        'openBookUrl' => $openBookUrl
                    ];
                    //print_r($postData);

                    $atb->createAclContactAction($postData, $this->getServiceLocator());
                }
                /**                 * ********************************************  Acl End    ****************************** */
                $params = [
                    'baseUrl' => $this->returnBasePath(),
                    'userimage' => $userimage,
                    'useremail' => $email,
                    'url' => $url,
                    'username' => $username,
                    'contentname' => $contentDetail['CONT_TITLE'],
                    'contentimage' => $bookimage,
                    'subscription_num' => $subScrData['SUBSCRIPTION_NUM']
                ];
                // first mail goes to user  
                $body = $emailPluginObj->setEmailTemplate('content_subscription_confirmation.phtml', $params);
               // print_r($body);die;
                 $emailPluginObj->sendMail($email, $body);
                
                // second mail goes to administartor  
                $adminemail = $userManagement->getAdminEmail();
                $body = $emailPluginObj->setEmailTemplate('content_alert.phtml', $params);
               // print_r($body);
                //die;
                $emailPluginObj->sendMail($adminemail, $body);
                $this->container->subscribe = 1;
            }
        }
    }

    /** @Comment : For open popup  */
    public function openPopupAction() {
        $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
        $requestData = $this->getRequest()->getQuery()->toArray();
        $translator = $this->getServiceLocator()->get('translator');
        $viewModel = $this->ExamPlugin()->openPopUp($viewModel, $requestData);
        //$viewModel = $this->CommonClass()->openPopUp($viewModel,$requestData);
        $fileName = $requestData['file'];

        if ($fileName == 'videopreview') {
            $viewModel->setVariables(['result' => $requestData]);
            return $viewModel;
        }
    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit