Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

punambaravkar marked this conversation as resolved.
Show resolved Hide resolved
$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 @@ -184,14 +184,15 @@ protected function populateState()
/**
* Method to validate the form data.
*
* @param \JForm $form The form to validate against.
* @param JForm $form The form to validate against.
* @param Array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @return array|boolean Array of filtered data if valid, false otherwise.
*
* @since 12.2
*/
public function validate($form, $data)
public function validate($form, $data, $group = null)
{
$return = true;
$return = parent::validate($form, $data);
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