I'm working on a plugin, I have a dropdown menu in the admin ui for the plugin to select a user - I went and added a custom query:
SELECT u.user_id, u.user_name FROM `#user` AS u
LEFT JOIN `#service_records_sys` AS sr ON sr.user_id = u.user_id
WHERE sr.user_id IS NULL
That filters out the users who already have a service record in the dropdown. Issue is, when going to Managed (list) user names are no longer displayed....
The code used:
public function init()
{
$filterQuery = "SELECT u.user_id, u.user_name FROM `#user` AS u
LEFT JOIN `#service_records_sys` AS sr ON sr.user_id = u.user_id
WHERE sr.user_id IS NULL";
$sql = e107::getDB();
if($sql->retrieve($filterQuery))
{
while ($row = $sql->fetch())
{
$this->user_id[$row['user_id']] = $row['user_name'];
}
}
$this->fields['user_id']['writeParms'] = $this->user_id;
}
I used to have it without the LEFT JOIN which had no filter
public function init()
{
$sql = e107::getDB();
if($sql->select("user", "*", true))
{
while ($row = $sql->fetch())
{
$this->user_id[$row['user_id']] = $row['user_name'];
}
}
$this->fields['user_id']['writeParms'] = $this->user_id;
}
I could use Custom function which would be 'method' - but how would I display it as a dropdown in edit, and when listed (read) show the user names? and inline edit allow for admin to change user display name?
I'm working on a plugin, I have a dropdown menu in the admin ui for the plugin to select a user - I went and added a custom query:
That filters out the users who already have a service record in the dropdown. Issue is, when going to Managed (list) user names are no longer displayed....
The code used:
I used to have it without the LEFT JOIN which had no filter