widgetName = JText::translate('VBO_W_AITRAININGDRAFTS_TITLE'); $this->widgetDescr = JText::translate('VBO_W_AITRAININGDRAFTS_DESCR'); $this->widgetId = basename(__FILE__, '.php'); $this->widgetIcon = ''; $this->widgetStyleName = 'pink'; } /** * @inheritDoc */ public function getPriority() { // give this widget a higher priority return 14; } /** * @inheritDoc */ public function preflight() { // can be used only if VCM is installed and the AI channel is supported (not necessarily active) return class_exists('VikChannelManager') && defined('VikChannelManagerConfig::AI') && parent::preflight(); } /** * @inheritDoc */ public function preload() { // load assets $this->vbo_app->loadSelect2(); } /** * @inheritDoc */ public function render(?VBOMultitaskData $data = null) { // increase widget's instance counter static::$instance_counter++; // check whether the widget is being rendered via AJAX when adding it through the customizer $is_ajax = $this->isAjaxRendering(); // generate a unique ID for the sticky notes wrapper instance $wrapper_instance = !$is_ajax ? static::$instance_counter : rand(); $wrapper_id = 'vbo-widget-bookdets-' . $wrapper_instance; // get permissions if (!JFactory::getUser()->authorise('core.vbo.bookings', 'com_vikbooking')) { // display nothing return; } // check for multitask data values $js_intvals_id = ''; if ($data) { // access Multitask data if ($data->isModalRendering()) { // get modal JS identifier $js_intvals_id = $data->getModalJsIdentifier(); } } try { if (!class_exists('VCMAiModelTraining')) { throw new Exception('E4jConnect Channel Manager unavailable or unsupported.', 500); } // load the draft training sets $response = (new VCMAiModelTraining)->getItems([ // needs review 'status' => 2, ], [ 'ordering' => 'created', 'direction' => 'asc', 'offset' => 0, 'limit' => 20, ]); } catch (Exception $e) { // store the exception $response = $e; } ?>

getIcon(); ?> getName(); ?>

loadDrafts(true)['html']; } catch (Exception $e) { ?>

getMessage(); ?>

close(500, 'E4jConnect Channel Manager unavailable or unsupported.'); } try { // load the draft training sets $response = (new VCMAiModelTraining)->getItems([ // needs review 'status' => 2, ], [ 'ordering' => 'created', 'direction' => 'asc', 'offset' => 0, 'limit' => 20, ]); } catch (Exception $e) { // raise an error if ($return) { throw $e; } VBOHttpDocument::getInstance($app)->close($e->getCode() ?: 500, $e->getMessage()); } // build HTML response $html = << HTML; // render drafts list $pendingLabel = JText::translate('VBO_TASK_STATUS_TYPE_PENDING'); foreach (($response->items ?? []) as $item) { // template variables $draftContent = JHtml::fetch('vikbooking.shorten', $item->content, 200); $draftDate = JHtml::fetch('date.relative', $item->created, null, null, 'Y-m-d H:i:s'); // append HTML record $html .= <<
HTML; } if (!($response->items ?? [])) { $html .= '

' . JText::translate('VBO_NO_RECORDS_FOUND') . '

'; } $html .= << HTML; // build response data $responseData = [ 'html' => $html, 'response' => $response, ]; if ($return) { // return just the HTML string return $responseData; } // send response to output VBOHttpDocument::getInstance($app)->json($responseData); } }