getDocument();
$wa = $document->getWebAssetManager();
// Build the script
$script = array();
$script[] = ' function jSelectVenue_'.$this->id.'(id, venue, object) {';
$script[] = ' document.getElementById("'.$this->id.'_id").value = id;';
$script[] = ' document.getElementById("'.$this->id.'_name").value = venue;';
// $script[] = ' SqueezeBox.close();';
$script[] = ' $("#venue-modal").modal("hide");';
$script[] = ' }';
// Add to document head
$wa->addInlineScript(implode("\n", $script));
// Setup variables for display
$html = array();
$link = Uri::base() . 'index.php?option=com_jem&view=editevent&layout=choosevenue&tmpl=component&function=jSelectVenue_'.$this->id;
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('venue');
$query->from('#__jem_venues');
$query->where(array('id='.(int)$this->value));
$db->setQuery($query);
// if ($error = $db->getErrorMsg()) {
// \Joomla\CMS\Factory::getApplication()->enqueueMessage($error, 'warning');
// }
try
{
$venue = $db->loadResult();
}
catch (RuntimeException $e)
{
\Joomla\CMS\Factory::getApplication()->enqueueMessage($e->getMessage(), 'warning');
}
if (empty($venue)) {
$venue = Text::_('COM_JEM_SELECT_VENUE');
}
$venue = htmlspecialchars($venue, ENT_QUOTES, 'UTF-8');
// The current venue input field
$html[] = ' ';
// The venue select button
// $html[] = ' '.
// Text::_('COM_JEM_SELECT').'';
$html[] = HTMLHelper::_(
'bootstrap.renderModal',
'venue-modal',
array(
'url' => $link.'&'.Session::getFormToken().'=1',
'title' => Text::_('COM_JEM_SELECT'),
'width' => '800px',
'height' => '450px',
'footer' => ''
)
);
$html[] ='';
// The active venue id field
if (0 == (int)$this->value) {
$value = '';
} else {
$value = (int)$this->value;
}
// class='required' for client side validation
$class = '';
if ($this->required) {
$class = ' class="required modal-value"';
}
$html[] = '';
return implode("\n", $html);
}
}
?>