diff --git a/src/components/com_tjcertificate/administrator/libraries/certificate.php b/src/components/com_tjcertificate/administrator/libraries/certificate.php index 4b4bd579..5a162233 100644 --- a/src/components/com_tjcertificate/administrator/libraries/certificate.php +++ b/src/components/com_tjcertificate/administrator/libraries/certificate.php @@ -41,6 +41,10 @@ class TjCertificateCertificate extends CMSObject private $client_id = 0; + private $client_issued_to = 0; + + private $client_issued_to_name = ""; + private $user_id = 0; public $state = 1; @@ -148,6 +152,58 @@ public function getClientId() return $this->client_id; } + /** + * Set client issued to + * + * @param integer $value Value to set client issued to. + * + * @return void. + * + * @since __DEPLOY_VERSION__ + */ + public function setClientIssuedTo($value = 0) + { + $this->client_issued_to = $value; + } + + /** + * Get client issued to + * + * @return string Client issued to. + * + * @since __DEPLOY_VERSION__ + */ + public function getClientIssuedTo() + { + return $this->client_issued_to; + } + + /** + * Set client issued to name + * + * @param string $value Value to set client issued to name. + * + * @return void. + * + * @since __DEPLOY_VERSION__ + */ + public function setClientIssuedToName($value = "") + { + $this->client_issued_to_name = $value; + } + + /** + * Get client issued to name + * + * @return string Client issued to name. + * + * @since __DEPLOY_VERSION__ + */ + public function getClientIssuedToName() + { + return $this->client_issued_to_name; + } + /** * Set User Id * @@ -432,21 +488,28 @@ public function bind(&$array) /** * Method to get issued certificate list * - * @param string $client Client e.g. com_tjlms.course + * @param string $client Client e.g. com_tjlms.course * - * @param integer $clientId Specific client id + * @param integer $clientId Specific client id * - * @param integer $userId User Id + * @param integer $userId User Id * - * @param boolean $expired Get expired certificates + * @param boolean $expired Get expired certificates + * + * @param boolean $clientIssuedTo Client issued to * * @return boolean|array Issued certificate array * * @since 1.0 */ - public static function getIssued($client, $clientId, $userId, $expired = false) + public static function getIssued($client, $clientId, $userId = 0, $expired = false, $clientIssuedTo = 0) { - if (empty($client) || empty($clientId) || empty($userId)) + if (empty($client) || empty($clientId)) + { + return false; + } + + if (empty($userId) && empty($clientIssuedTo)) { return false; } @@ -455,7 +518,16 @@ public static function getIssued($client, $clientId, $userId, $expired = false) $model->setState('filter.client', $client); $model->setState('filter.client_id', $clientId); - $model->setState('filter.user_id', $userId); + + if (!empty($userId)) + { + $model->setState('filter.user_id', $userId); + } + + if ($clientIssuedTo) + { + $model->setState('filter.client_issued_to', $clientIssuedTo); + } if ($expired) { diff --git a/src/components/com_tjcertificate/administrator/models/certificates.php b/src/components/com_tjcertificate/administrator/models/certificates.php index 96a099d1..6039421a 100644 --- a/src/components/com_tjcertificate/administrator/models/certificates.php +++ b/src/components/com_tjcertificate/administrator/models/certificates.php @@ -137,6 +137,14 @@ protected function getListQuery() $query->where($db->quoteName('ci.user_id') . ' = ' . (int) $userId); } + // Filter by client issued to + $clientIssuedTo = $this->getState('filter.client_issued_to'); + + if (!empty($clientIssuedTo)) + { + $query->where($db->quoteName('ci.client_issued_to') . ' = ' . (int) $clientIssuedTo); + } + // Filter by search in title. $search = $this->getState('filter.search'); diff --git a/src/components/com_tjcertificate/administrator/sql/install.mysql.utf8.sql b/src/components/com_tjcertificate/administrator/sql/install.mysql.utf8.sql index 28345089..d5b51fee 100644 --- a/src/components/com_tjcertificate/administrator/sql/install.mysql.utf8.sql +++ b/src/components/com_tjcertificate/administrator/sql/install.mysql.utf8.sql @@ -26,6 +26,8 @@ CREATE TABLE IF NOT EXISTS `#__tj_certificate_issue` ( `generated_body` text NOT NULL, `client` varchar(100) NOT NULL, `client_id` int(11) NOT NULL, + `client_issued_to` int(11) NOT NULL, + `client_issued_to_name` varchar(400) COLLATE utf8mb4_unicode_ci NOT NULL, `user_id` int(11) NOT NULL, `comment` text NULL, `state` tinyint(3) NOT NULL, diff --git a/src/components/com_tjcertificate/administrator/sql/updates/mysql/1.0.1.sql b/src/components/com_tjcertificate/administrator/sql/updates/mysql/1.0.1.sql new file mode 100644 index 00000000..6e41e6d6 --- /dev/null +++ b/src/components/com_tjcertificate/administrator/sql/updates/mysql/1.0.1.sql @@ -0,0 +1,2 @@ +ALTER TABLE `#__tj_certificate_issue` ADD `client_issued_to` int(11) NOT NULL AFTER `user_id`; +ALTER TABLE `#__tj_certificate_issue` ADD `client_issued_to_name` varchar(400) COLLATE 'utf8mb4_unicode_ci' NOT NULL AFTER `client_issued_to`; diff --git a/src/components/com_tjcertificate/media/css/tjCertificate.css b/src/components/com_tjcertificate/media/css/tjCertificate.css index 066ff7ad..64608b41 100644 --- a/src/components/com_tjcertificate/media/css/tjCertificate.css +++ b/src/components/com_tjcertificate/media/css/tjCertificate.css @@ -135,10 +135,6 @@ float: left; } #certificateContent{ -/* - min-height: 800px; - width: 1150px; -*/ margin: 0 auto; } .tj-certificate-content{ @@ -152,6 +148,7 @@ border-radius: 5px; margin-left: 4px; border: 1px solid #ddd; + display: inline-block; } .tjlmspin__caption_desc{ line-height: 18px; @@ -186,4 +183,9 @@ .tjlmslist .thumbnail{ border:0; } + + #certificateContent{ + min-height: 800px; + width: 1150px; + } } diff --git a/src/components/com_tjcertificate/media/js/certificateImage.js b/src/components/com_tjcertificate/media/js/certificateImage.js index 78d39538..22de5924 100644 --- a/src/components/com_tjcertificate/media/js/certificateImage.js +++ b/src/components/com_tjcertificate/media/js/certificateImage.js @@ -37,7 +37,16 @@ var certificateImage = { }, success: function(data) { result = data; - Joomla.loadingLayer('hide'); + + var certificateId = jQuery("#certificateId").val(); + var imagePath = certRootUrl + 'media/com_tjcertificate/certificates/'; + var img = document.createElement('img'); + jQuery('#certificateContent').hide(); + img.src = imagePath + certificateId + ".png"; + jQuery("#previewImage").append(img); + setTimeout(function(){ + Joomla.loadingLayer('hide'); }, + 1000); } }); @@ -45,8 +54,6 @@ var certificateImage = { }, generateImage: function(element) { - var certificateId = jQuery("#certificateId").val(); - var imagePath = certRootUrl + 'media/com_tjcertificate/certificates/'; jQuery('#certificateContent').width(element.offsetWidth).height(element.offsetHeight); Joomla.loadingLayer('show'); @@ -56,7 +63,6 @@ var certificateImage = { scrollY: -window.scrollY, allowTaint: true }).then(function(canvas) { - jQuery("#downloadImage").attr("href", canvas.toDataURL('image/png')); certificateImage.enableDownloadShareBtns(); certificateImage.uploadImage(canvas.toDataURL('image/png')); }); diff --git a/src/components/com_tjcertificate/media/js/certificateImage.min.js b/src/components/com_tjcertificate/media/js/certificateImage.min.js index 9d996655..a0781531 100644 --- a/src/components/com_tjcertificate/media/js/certificateImage.min.js +++ b/src/components/com_tjcertificate/media/js/certificateImage.min.js @@ -1 +1 @@ -var certificateImage={printCertificate:function(e){var t=document.getElementById(e).innerHTML,o=document.body.innerHTML;document.body.innerHTML=t,window.print(),document.body.innerHTML=o,certificateImage.enableDownloadShareBtns()},enableDownloadShareBtns:function(){jQuery("#download-popover").popover({trigger:"focus",html:!0,content:jQuery("#download-popover-content").html()}),jQuery("#sharing-popover").popover({trigger:"focus",html:!0,content:jQuery("#sharing-popover-content").html()})},uploadImage:function(e){var t=!1,o=jQuery("#certificateId").val();return jQuery.ajax({url:certRootUrl+"index.php?option=com_tjcertificate&task=certificate.uploadCertificate",type:"POST",data:{image:e,certificateId:o},success:function(e){t=e,Joomla.loadingLayer("hide")}}),t},generateImage:function(e){jQuery("#certificateId").val(),certRootUrl;jQuery("#certificateContent").width(e.offsetWidth).height(e.offsetHeight),Joomla.loadingLayer("show"),html2canvas(e,{scale:2,scrollX:0,scrollY:-window.scrollY,allowTaint:!0}).then(function(e){jQuery("#downloadImage").attr("href",e.toDataURL("image/png")),certificateImage.enableDownloadShareBtns(),certificateImage.uploadImage(e.toDataURL("image/png"))})}}; +var certificateImage={printCertificate:function(e){var t=document.getElementById(e).innerHTML,o=document.body.innerHTML;document.body.innerHTML=t,window.print(),document.body.innerHTML=o,certificateImage.enableDownloadShareBtns()},enableDownloadShareBtns:function(){jQuery("#download-popover").popover({trigger:"focus",html:!0,content:jQuery("#download-popover-content").html()}),jQuery("#sharing-popover").popover({trigger:"focus",html:!0,content:jQuery("#sharing-popover-content").html()})},uploadImage:function(e){var t=!1,o=jQuery("#certificateId").val();return jQuery.ajax({url:certRootUrl+"index.php?option=com_tjcertificate&task=certificate.uploadCertificate",type:"POST",data:{image:e,certificateId:o},success:function(e){t=e;var o=jQuery("#certificateId").val(),n=certRootUrl+"media/com_tjcertificate/certificates/",a=document.createElement("img");jQuery("#certificateContent").hide(),a.src=n+o+".png",jQuery("#previewImage").append(a),setTimeout(function(){Joomla.loadingLayer("hide")},1e3)}}),t},generateImage:function(e){jQuery("#certificateContent").width(e.offsetWidth).height(e.offsetHeight),Joomla.loadingLayer("show"),html2canvas(e,{scale:2,scrollX:0,scrollY:-window.scrollY,allowTaint:!0}).then(function(e){certificateImage.enableDownloadShareBtns(),certificateImage.uploadImage(e.toDataURL("image/png"))})}}; diff --git a/src/components/com_tjcertificate/site/views/certificate/tmpl/default.php b/src/components/com_tjcertificate/site/views/certificate/tmpl/default.php index 208de697..93dc8dda 100644 --- a/src/components/com_tjcertificate/site/views/certificate/tmpl/default.php +++ b/src/components/com_tjcertificate/site/views/certificate/tmpl/default.php @@ -19,6 +19,7 @@ $options['relative'] = true; HTMLHelper::_('jquery.framework'); +HTMLHelper::_('behavior.framework'); HTMLHelper::StyleSheet('media/com_tjcertificate/vendors/font-awesome-4.1.0/css/font-awesome.min.css'); HTMLHelper::StyleSheet('media/com_tjcertificate/css/tjCertificate.css'); HTMLHelper::StyleSheet('media/com_tjlms/vendors/artificiers/artficier.css'); @@ -60,7 +61,8 @@ // For facebook and linkedin $config = Factory::getConfig(); $siteName = $config->get('sitename'); - $document->addCustomTag(''); + $ogTitle = $this->item->title ? $this->escape($this->item->title) : $this->escape($siteName) . ' ' .Text::_('COM_TJCERTIFICATE_CERTIFICATE_DETAIL_VIEW_HEAD'); + $document->addCustomTag(''); $document->addCustomTag(''); $document->addCustomTag(''); $document->addCustomTag(''); @@ -97,7 +99,7 @@ } ?> -
+
certificate->getUserId() == Factory::getUser()->id) { @@ -108,21 +110,19 @@
- + certificate->getDownloadUrl()) { ?> - - - - - - + + + + @@ -138,18 +138,17 @@ -
item)) - { - echo $this->loadTemplate('social_sharing'); - } + echo $this->loadTemplate('social_sharing'); ?>
+ +
extensions@techjoomla.com http://techjoomla.com - 1.0.0 + 1.0.1