Skip to content

Commit

Permalink
Task #163911: Added cols client issued to and client issued to name (#28
Browse files Browse the repository at this point in the history
)

* Bug #162401 Fix: Warning on com_tjcertificate edit template view (#18)

* Task #163911: Added cols client issued to and client issued to name

* Task #163911: Added cols client issued to and client issued to name

* Task #163911: Added cols client issued to and client issued to name

Co-authored-by: MeghaBiranje <[email protected]>
  • Loading branch information
punambaravkar and MeghaBiranje authored Sep 10, 2020
1 parent 2737130 commit 2b59f81
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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;
}
Expand All @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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`;
2 changes: 1 addition & 1 deletion src/components/com_tjcertificate/tjcertificate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<authorEmail>[email protected]</authorEmail>
<authorUrl>http://techjoomla.com</authorUrl>
<description />
<version>1.0.0</version>
<version>1.0.1</version>
<install>
<!-- Runs on install -->
<sql>
Expand Down

0 comments on commit 2b59f81

Please sign in to comment.