X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fbrowse%2Felements%2Fbrowse-simple.html;fp=httemplate%2Fbrowse%2Felements%2Fbrowse-simple.html;h=cfa27e88257c0fb8f4a6107f73983e174db2d02b;hb=1af8ff7f48f7259fc99f090c301c84b9680fdb4d;hp=0000000000000000000000000000000000000000;hpb=0f0bc1ef7aafc6b3869c0f71ee2528c1c9897ce6;p=freeside.git diff --git a/httemplate/browse/elements/browse-simple.html b/httemplate/browse/elements/browse-simple.html new file mode 100644 index 000000000..cfa27e882 --- /dev/null +++ b/httemplate/browse/elements/browse-simple.html @@ -0,0 +1,57 @@ +<& browse.html, + 'query' => { 'table' => $table }, + 'count_query' => "SELECT COUNT(*) FROM $table", + 'header' => [ '#', $opt{name_header} ], + 'fields' => [ $table_key, $opt{name_col} ], + 'links' => [ '', '' ], + 'link_onclicks' => [ '', $sub_edit_popup ], + 'disableable' => 1, + 'disabled_statuspos' => 2, + 'html_init' => $html_init, + %opt, +&> +<%doc> +A simple wrapper around search/elements/search.html for browsing/editing +tables that only have a primary key, a 'disabled' field, and one other column +which is the object's name or description. Usage: + +<& browse-simple.html, + # required + 'table' => 'mytable', + 'title' => 'My Things', + 'name_singular' => 'thing', + 'name_col' => 'thingname', + 'name_header' => 'Thing name' + 'acl' => 'Configure things', +&> + + +<%init> +my %opt = @_; + +my $table = delete $opt{table}; +my $name_singular = $opt{name_singular}; + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right($opt{acl}); + +my $table_key = dbdef->table($table)->primary_key; +my $sub_edit_popup = sub { + my $pkey = $_[0]->get($table_key); + include('/elements/popup_link_onclick.html', + 'action' => $p."edit/$table.html?$pkey", + 'actionlabel' => "Edit $name_singular", + 'width' => 350, + 'height' => 220, + ); +}; + +my $html_init = include('/elements/popup_link.html', + 'action' => $p."edit/$table.html?", + 'actionlabel' => "Add $name_singular", + 'width' => 350, + 'height' => 220, + 'label' => "Add a new $name_singular", +) . '
'; + +