Display suggested values

@param integer $bas_id  The collection base_id
@return string
1209
public function getSuggestedValues($bas_id)
    {
        /** @var \databox $databox */
        $databox = $this->app->findDataboxById(\phrasea::sbasFromBas($this->app, $bas_id));
        $collection = \collection::getByBaseId($this->app, $bas_id);
        $structFields = $suggestedValues = $basePrefs = [];

        /** @var \databox_field $meta */
        foreach ($databox->get_meta_structure() as $meta) {
            if ($meta->is_readonly()) {
                continue;
            }

            $structFields[$meta->get_name()] = $meta;
        }

        if ($sxe = simplexml_load_string($collection->get_prefs())) {
            $z = $sxe->xpath('/baseprefs/sugestedValues');
            if ($z && is_array($z)) {
                $f = 0;
                foreach ($z[0] as $ki => $vi) {
                    if ($vi && isset($structFields[$ki])) {
                        foreach ($vi->value as $oneValue) {
                            $suggestedValues[] = [
                                'key'   => $ki,
                                'value' => $f,
                                'name'  => (string) $oneValue
                            ];
                            $f++;
                        }
                    }
                }
            }

            $z = $sxe->xpath('/baseprefs');
            if ($z && is_array($z)) {
                /**
                 * @var string $ki
                 * @var \SimpleXMLElement $vi
                 */
                foreach ($z[0] as $ki => $vi) {
                    $pref = ['status' => null, 'xml'    => null];

                    if ($ki == 'status') {
                        $pref['status'] = $vi;
                    } elseif ($ki != 'sugestedValues') {
                        $pref['xml'] = $vi->asXML();
                    }

                    $basePrefs[] = $pref;
                }
            }
        }

        return $this->render('admin/collection/suggested_value.html.twig', [
            'collection'      => $collection,
            'databox'         => $databox,
            'suggestedValues' => $suggestedValues,
            'structFields'    => $structFields,
            'basePrefs'       => $basePrefs,
        ]);
    }
1038841
public function render($parent_id = false)
    {
        // Available options for this menu.
        $container_tag = array_get($this->option, 'tag', 'ul');
        $item_tag = array_get($this->option, 'item_tag', 'li');
        $item_callback = array_get($this->option, 'item_callback', null);
        $text_only = array_get($this->option, 'text_only', false);
        $html = '';

        $items = $this->item_collection;

        // Render from a specific menu item.
        if ($parent_id !== false) {
            $items = $this->whereParentId($parent_id)->all();
        }

        // Generate each of the items.
        foreach ($items as $item) {
            $item->setItemTagOption($item_tag)
                ->setContainerTagOption($container_tag);

            if (!is_null($item_callback) && is_callable($item_callback)) {
                $item_callback($item);
                $item->setItemCallbackOption($item_callback);
            }
            $html .= $item->render(2, $text_only);
        }

        // Create the container and allocate the link.
        return $html;
    }
252550
public function display()
    {
        if (!$this->visible) {
            return;
        }

        parent::display();

        $ordered_options = $this->getOrderedOptions();

        $div_tag = new SwatHtmlTag('div');
        $div_tag->id = $this->id;
        $div_tag->class = $this->getCSSClassString();
        $div_tag->open();

        $list_div = new SwatHtmlTag('div');
        $list_div->style = "width: {$this->width}; height: {$this->height};";
        $list_div->id = "{$this->id}_list";
        $list_div->class = 'swat-change-order-list';
        $list_div->open();

        $option_div = new SwatHtmltag('div');
        $option_div->class = 'swat-change-order-item';

        foreach ($ordered_options as $option) {
            $title = $option->title === null ? '' : $option->title;
            $option_div->setContent($title, $option->content_type);
            $option_div->display();
        }

        $list_div->close();

        $this->displayButtons();

        echo '<div class="swat-clear"></div>';

        $values = array();
        foreach ($ordered_options as $option) {
            $values[] = SwatString::signedSerialize(
                $option->value,
                $this->getForm()->getSalt()
            );
        }

        $hidden_tag = new SwatHtmlTag('input');
        $hidden_tag->type = 'hidden';
        $hidden_tag->id = $this->id . '_value';
        $hidden_tag->name = $this->id;
        $hidden_tag->value = implode(',', $values);
        $hidden_tag->display();

        $hidden_items_tag = new SwatHtmlTag('input');
        $hidden_items_tag->type = 'hidden';
        $hidden_items_tag->id = $this->id . '_dynamic_items';
        $hidden_items_tag->value = '';
        $hidden_items_tag->display();

        $div_tag->close();

        Swat::displayInlineJavaScript($this->getInlineJavaScript());
    }
1246674
public function show($id)
    {
        $ticket = $this->tickets->findOrFail($id);

        list($priority_lists, $category_lists, $status_lists) = $this->PCS();

        $close_perm = $this->permToClose($id);
        $reopen_perm = $this->permToReopen($id);

        $cat_agents = Models\Category::find($ticket->category_id)->agents()->agentsLists();
        if (is_array($cat_agents)) {
            $agent_lists = ['auto' => 'Auto Select'] + $cat_agents;
        } else {
            $agent_lists = ['auto' => 'Auto Select'];
        }

        $comments = $ticket->comments()->paginate(Setting::grab('paginate_items'));

        return view('ticketit::tickets.show',
            compact('ticket', 'status_lists', 'priority_lists', 'category_lists', 'agent_lists', 'comments',
                'close_perm', 'reopen_perm'));
    }
1338227
public function showRefund($transaction_id)
    {
        $response = $this->client->get('transactions/refunds/' . $transaction_id);
        return json_decode($response->getBody())->refund;
    }
386953
public function show($id)
    {
        if(Request::isAjax()){
            $user = null;
            $message = '';

            try{
                $user = Sentry::findUserById($id);
            }catch(Exception $e){
                $message = $e->getMessage();
            }


            Response::headers()->set('Content-Type', 'application/json');
            Response::setBody(json_encode(
                array(
                    'success'   => !is_null($user),
                    'data'      => !is_null($user) ? $user->toArray() : $user,
                    'message'   => $message,
                    'code'      => is_null($user) ? 404 : 200
                )
            ));
        }else{

        }
    }
127102
public function show($id)
    {
        $lists      = $this->mailjet->getAllLists();
        $newsletter = $this->newsletter->find($id);

        return view('newsletter::Backend.template.show')->with(['newsletter' => $newsletter, 'lists' => $lists]);
    }
307662
public function index()
    {
        /** @var \Colibri\Database\ModelCollection $items */
        $items = new $this->listClass();
        $this->applyListFilters($items);
        $items->load();

        $this->template->vars[$this->listTplVar] = $items;
        if ($this->pagedList) {
            $this->template->vars['pagination'] = [
                'page'           => (int)(isset($_GET['page']) ? $_GET['page'] : 0),
                'recordsPerPage' => $items->recordsPerPage,
                'recordsCount'   => $items->recordsCount,
                'pagesCount'     => $items->pagesCount,
                'base_url'       => '/' . $this->division . '/' . $this->module,
            ];
        }
    }
714269
public function display()
    {
        $bc = $this->get();
        $cnt = count($bc);
        if ($cnt > 0) {
            foreach ($bc as $item) {
                echo --$cnt ? "<a href=\"{$item['uri']}\" title=\"{$item['descr']}\">" : '';
                echo $item['title'];
                echo $cnt ? '</a>&nbsp;&raquo;&nbsp;' : '';
            }
            echo "\n";
        }
    }
438475
public function show($id)
    {
        $record = $this->modelRepository->findOrFail($id);

        $this->checkListParents(false);

        return view($this->getShowView(), [
            'moduleKey'           => $this->moduleKey,
            'routePrefix'         => $this->routePrefix,
            'permissionPrefix'    => $this->permissionPrefix,
            'model'               => $this->modelInformation,
            'record'              => $record,
            'recordReference'     => $this->getReferenceRepository()->getReferenceForModel($record),
            'fieldStrategies'     => $this->renderedShowFieldStrategies($record),
            'hasActiveListParent' => (bool) $this->listParentRelation,
            'topListParentOnly'   => $this->showsTopParentsOnly(),
            'listParents'         => $this->listParents,
        ]);
    }
615506
public function getCollection(Request $request, $bas_id)
    {
        $collection = \collection::getByBaseId($this->app, $bas_id);

        $admins = [];

        if ($this->getAclForUser()->has_right_on_base($bas_id, \ACL::COLL_MANAGE)) {
            $query = $this->createUserQuery();
            $admins = $query->on_base_ids([$bas_id])
                ->who_have_right([\ACL::ORDER_MASTER])
                ->include_templates(true)
                ->execute()
                ->get_results();
        }

        switch ($errorMsg = $request->query->get('error')) {
            case 'file-error':
                $errorMsg = $this->app->trans('Error while sending the file');
                break;
            case 'file-invalid':
                $errorMsg = $this->app->trans('Invalid file format');
                break;
            case 'file-file-too-big':
                $errorMsg = $this->app->trans('The file is too big');
                break;
            case 'collection-not-empty':
                $errorMsg = $this->app->trans('Empty the collection before removing');
                break;
        }

        return $this->render('admin/collection/collection.html.twig', [
            'collection' => $collection,
            'admins'     => $admins,
            'errorMsg'   => $errorMsg,
            'reloadTree' => $request->query->get('reload-tree') === '1'
        ]);
    }
33035
public function display()
    {
        $options = $this->getOptions();

        if (!$this->visible || $options === null) {
            return;
        }

        SwatWidget::display();

        // add a hidden field so we can check if this list was submitted on
        // the process step
        $this->getForm()->addHiddenField($this->id . '_submitted', 1);

        if (count($options) === 1) {
            // get first and only element
            $this->displaySingle(current($options));
            return;
        }

        $ul_tag = new SwatHtmlTag('ul');
        $ul_tag->id = $this->id;
        $ul_tag->class = $this->getCSSClassString();
        $ul_tag->open();

        $li_tag = new SwatHtmlTag('li');
        $index = 0;

        foreach ($options as $option) {
            // add option-specific CSS classes from option metadata
            $classes = $this->getOptionMetadata($option, 'classes');
            if (is_array($classes)) {
                $li_tag->class = implode(' ', $classes);
            } elseif ($classes) {
                $li_tag->class = strval($classes);
            } else {
                $li_tag->removeAttribute('class');
            }

            $sensitive = $this->getOptionMetadata($option, 'sensitive');
            if ($sensitive === false || !$this->isSensitive()) {
                if ($li_tag->class === null) {
                    $li_tag->class = 'swat-insensitive';
                } else {
                    $li_tag->class .= ' swat-insensitive';
                }
            }

            if ($option instanceof SwatFlydownDivider) {
                if ($li_tag->class === null) {
                    $li_tag->class = 'swat-radio-list-divider-li';
                } else {
                    $li_tag->class .= ' swat-radio-list-divider-li';
                }
            }

            $li_tag->id = $this->id . '_li_' . (string) $index;
            $li_tag->open();

            if ($option instanceof SwatFlydownDivider) {
                $this->displayDivider($option, $index);
            } else {
                $this->displayOption($option, $index);
                $this->displayOptionLabel($option, $index);
            }

            $li_tag->close();
            $index++;
        }

        $ul_tag->close();
    }
12500
public function display()
    {
        $options = $this->getOptions();

        if (!$this->visible || $options === null) {
            return;
        }

        SwatWidget::display();

        // add a hidden field so we can check if this list was submitted on
        // the process step
        $this->getForm()->addHiddenField($this->id . '_submitted', 1);

        if ($this->show_blank) {
            $options = array_merge(
                array(new SwatOption(null, $this->blank_title)),
                $options
            );
        }

        $table_tag = new SwatHtmlTag('table');
        $table_tag->id = $this->id;
        $table_tag->class = $this->getCSSClassString();
        $table_tag->open();

        foreach ($options as $index => $option) {
            $this->displayRadioTableOption($option, $index);
        }

        $table_tag->close();
    }
459534
public function display()
    {
        $options = $this->getOptions();

        if (!$this->visible || count($options) === 0) {
            return;
        }

        SwatWidget::display();

        $this->getForm()->addHiddenField($this->id . '_submitted', 1);

        $div_tag = new SwatHtmlTag('div');
        $div_tag->id = $this->id;
        $div_tag->class = $this->getCSSClassString();
        $div_tag->open();

        $input_tag = new SwatHtmlTag('input');
        $input_tag->type = 'checkbox';

        $label_tag = new SwatHtmlTag('label');
        $label_tag->class = 'swat-control';

        echo '<table>';

        if ($this->entry_column_title !== null) {
            echo '<thead><tr><th>&nbsp;</th><th>';
            echo $this->entry_column_title;
            echo '</th></tr></thead>';
        }

        // Only show the check all control if more than one checkable item is
        // displayed.
        if ($this->show_check_all && count($options) > 1) {
            echo '<tfoot><tr><td colspan="2">';
            $this->getCompositeWidget('check_all')->display();
            echo '</td></tr></tfoot>';
        }

        echo '<tbody>';
        foreach ($options as $key => $option) {
            echo '<tr><td>';

            $checkbox_id = $key . '_' . $option->value;

            $input_tag->value = (string) $option->value;
            $input_tag->removeAttribute('checked');
            $input_tag->name = $this->id . '[' . $key . ']';

            if (in_array($option->value, $this->values)) {
                $input_tag->checked = 'checked';
            }

            $input_tag->id = $this->id . '_' . $checkbox_id;
            echo '<span class="swat-checkbox-wrapper">';
            $input_tag->display();
            echo '<span class="swat-checkbox-shim"></span>';
            echo '</span>';

            $label_tag->for = $this->id . '_' . $checkbox_id;
            $label_tag->setContent($option->title, $option->content_type);
            $label_tag->display();

            echo '</td><td>';

            $this->getEntryWidget($option->value)->display();

            echo '</td></tr>';
        }
        echo '</tbody>';

        echo '</table>';

        $div_tag->close();

        Swat::displayInlineJavaScript($this->getInlineJavaScript());
    }
432182
public function actionQuestion($id)
    {
        $user = $this->findModel($id);
        $query = Question::find()->where(['user_id' => $id])->orderBy(['created_at' => SORT_DESC]);
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);
        return $this->render('question', [
            'user' => $user,
            'dataProvider' => $dataProvider
        ]);
    }
1293957
public function delete(Request $request, $bas_id)
    {
        $success = false;
        $msg = $this->app->trans('An error occured');

        $collection = \collection::getByBaseId($this->app, $bas_id);

        try {
            if ($collection->get_record_amount() > 0) {
                $msg = $this->app->trans('Empty the collection before removing');
            } else {
                $collection->unmount();
                $collection->delete();
                $success = true;
                $msg = $this->app->trans('Successful removal');
            }
        } catch (\Exception $e) {
        }

        if ('json' === $request->getRequestFormat()) {
            return $this->app->json([
                'success' => $success,
                'msg'     => $msg
            ]);
        }

        if ($collection->get_record_amount() > 0) {
            return $this->app->redirectPath('admin_display_collection', [
                'bas_id'  => $collection->get_sbas_id(),
                'success' => 0,
                'error'   => 'collection-not-empty',
            ]);
        }

        if ($success) {
            return $this->app->redirectPath('admin_display_collection', [
                'bas_id'      => $collection->get_sbas_id(),
                'success'     => 1,
                'reload-tree' => 1,
            ]);
        }

        return $this->app->redirectPath('admin_display_collection', [
            'bas_id'  => $collection->get_sbas_id(),
            'success' => 0,
        ]);
    }
1074804
public static function read($id)
    {
        return (string)Symphony::Database()->fetchVar(
            'session_data',
            0,
            sprintf(
                "SELECT `session_data`
                FROM `tbl_sessions`
                WHERE `session` = '%s'
                LIMIT 1",
                Symphony::Database()->cleanValue($id)
            )
        );
    }