Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b24afac7

Von Bernd Bleßmann vor fast 3 Jahren hinzugefügt

  • ID b24afac71c944667fdf55ad734e92b9d9c4ca905
  • Vorgänger c4a13349
  • Nachfolger ab010352

Auftrags-Controller: wenn kein Recht zur Bearbeitung, dann Aktionen ausblenden …

… und nicht weglassen

Unterschiede anzeigen:

SL/Controller/Order.pm
2032 2032
    $has_final_invoice               = any {'SL::DB::Invoice' eq ref $_ && "final_invoice" eq $_->type} @$lr;
2033 2033
  }
2034 2034

  
2035
  my $right_for = { map { $_ => $_.'_edit' } @{$self->valid_types} };
2036
  my $right     = $right_for->{ $self->type };
2037
  $right      ||= 'DOES_NOT_EXIST';
2035
  my $right_for         = { map { $_ => $_.'_edit' } @{$self->valid_types} };
2036
  my $right             = $right_for->{ $self->type };
2037
  $right              ||= 'DOES_NOT_EXIST';
2038
  my $may_edit_create   = $::auth->assert($right, 'may fail');
2038 2039

  
2039
  if ($::auth->assert($right, 1)) {
2040 2040
  for my $bar ($::request->layout->get('actionbar')) {
2041 2041
    $bar->add(
2042 2042
      combobox => [
......
2048 2048
          checks    => [ 'kivi.Order.check_save_active_periodic_invoices', ['kivi.validate_form','#order_form'],
2049 2049
                         @req_trans_cost_art, @req_cusordnumber,
2050 2050
          ],
2051
          disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
2051 2052
        ],
2052 2053
        action => [
2053 2054
          t8('Save as new'),
......
2055 2056
          checks    => [ 'kivi.Order.check_save_active_periodic_invoices',
2056 2057
                         @req_trans_cost_art, @req_cusordnumber,
2057 2058
          ],
2058
          disabled  => !$self->order->id ? t8('This object has not been saved yet.') : undef,
2059
          disabled  => !$may_edit_create ? t8('You do not have the permissions to access this function.')
2060
                     : !$self->order->id ? t8('This object has not been saved yet.')
2061
                     :                     undef,
2059 2062
        ],
2060 2063
      ], # end of combobox "Save"
2061 2064

  
......
2068 2071
          submit   => [ '#order_form', { action => "Order/sales_quotation" } ],
2069 2072
          checks   => [ @req_trans_cost_art, @req_cusordnumber ],
2070 2073
          only_if  => (any { $self->type eq $_ } (sales_order_type())),
2074
          disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
2071 2075
        ],
2072 2076
        action => [
2073 2077
          t8('Save and RFQ'),
2074 2078
          submit   => [ '#order_form', { action => "Order/request_for_quotation" } ],
2075 2079
          only_if  => (any { $self->type eq $_ } (purchase_order_type())),
2080
          disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
2076 2081
        ],
2077 2082
        action => [
2078 2083
          t8('Save and Sales Order'),
2079 2084
          submit   => [ '#order_form', { action => "Order/sales_order" } ],
2080 2085
          checks   => [ @req_trans_cost_art ],
2081 2086
          only_if  => (any { $self->type eq $_ } (sales_quotation_type(), purchase_order_type())),
2087
          disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
2082 2088
        ],
2083 2089
        action => [
2084 2090
          t8('Save and Purchase Order'),
2085 2091
          call      => [ 'kivi.Order.purchase_order_check_for_direct_delivery' ],
2086 2092
          checks    => [ @req_trans_cost_art, @req_cusordnumber ],
2087 2093
          only_if   => (any { $self->type eq $_ } (sales_order_type(), request_quotation_type())),
2094
          disabled  => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
2088 2095
        ],
2089 2096
        action => [
2090 2097
          t8('Save and Delivery Order'),
......
2094 2101
          checks    => [ 'kivi.Order.check_save_active_periodic_invoices',
2095 2102
                         @req_trans_cost_art, @req_cusordnumber,
2096 2103
          ],
2097
          only_if   => (any { $self->type eq $_ } (sales_order_type(), purchase_order_type()))
2104
          only_if   => (any { $self->type eq $_ } (sales_order_type(), purchase_order_type())),
2105
          disabled  => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
2098 2106
        ],
2099 2107
        action => [
2100 2108
          t8('Save and Supplier Delivery Order'),
......
2104 2112
          checks    => [ 'kivi.Order.check_save_active_periodic_invoices',
2105 2113
                         @req_trans_cost_art, @req_cusordnumber,
2106 2114
          ],
2107
          only_if   => (any { $self->type eq $_ } (purchase_order_type()))
2115
          only_if   => (any { $self->type eq $_ } (purchase_order_type())),
2116
          disabled  => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
2108 2117
        ],
2109 2118
        action => [
2110 2119
          t8('Save and Invoice'),
......
2112 2121
          checks    => [ 'kivi.Order.check_save_active_periodic_invoices',
2113 2122
                         @req_trans_cost_art, @req_cusordnumber,
2114 2123
          ],
2124
          disabled  => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
2115 2125
        ],
2116 2126
        action => [
2117 2127
          ($has_invoice_for_advance_payment ? t8('Save and Further Invoice for Advance Payment') : t8('Save and Invoice for Advance Payment')),
......
2119 2129
          checks    => [ 'kivi.Order.check_save_active_periodic_invoices',
2120 2130
                         @req_trans_cost_art, @req_cusordnumber,
2121 2131
          ],
2122
          disabled  => $has_final_invoice ? t8('This order has already a final invoice.')
2123
                                          : undef,
2132
          disabled  => !$may_edit_create  ? t8('You do not have the permissions to access this function.')
2133
                     : $has_final_invoice ? t8('This order has already a final invoice.')
2134
                     :                      undef,
2124 2135
          only_if   => (any { $self->type eq $_ } (sales_order_type())),
2125 2136
        ],
2126 2137
        action => [
......
2129 2140
          checks    => [ 'kivi.Order.check_save_active_periodic_invoices',
2130 2141
                         @req_trans_cost_art, @req_cusordnumber,
2131 2142
          ],
2132
          disabled  => $has_final_invoice ? t8('This order has already a final invoice.')
2133
                                          : undef,
2143
          disabled  => !$may_edit_create  ? t8('You do not have the permissions to access this function.')
2144
                     : $has_final_invoice ? t8('This order has already a final invoice.')
2145
                     :                      undef,
2134 2146
          only_if   => (any { $self->type eq $_ } (sales_order_type())) && $has_invoice_for_advance_payment,
2135 2147
        ],
2136 2148
        action => [
2137 2149
          t8('Save and AP Transaction'),
2138 2150
          call      => [ 'kivi.Order.save', 'save_and_ap_transaction', $::instance_conf->get_order_warn_duplicate_parts ],
2139
          only_if   => (any { $self->type eq $_ } (purchase_order_type()))
2151
          only_if   => (any { $self->type eq $_ } (purchase_order_type())),
2152
          disabled  => !$may_edit_create  ? t8('You do not have the permissions to access this function.') : undef,
2140 2153
        ],
2141 2154

  
2142 2155
      ], # end of combobox "Workflow"
......
2147 2160
        ],
2148 2161
        action => [
2149 2162
          t8('Save and preview PDF'),
2150
          call   => [ 'kivi.Order.save', 'preview_pdf', $::instance_conf->get_order_warn_duplicate_parts,
2151
                                                        $::instance_conf->get_order_warn_no_deliverydate,
2152
                    ],
2153
          checks => [ @req_trans_cost_art, @req_cusordnumber ],
2163
          call     => [ 'kivi.Order.save', 'preview_pdf', $::instance_conf->get_order_warn_duplicate_parts,
2164
                                                          $::instance_conf->get_order_warn_no_deliverydate,
2165
                      ],
2166
          checks   => [ @req_trans_cost_art, @req_cusordnumber ],
2167
          disabled => !$may_edit_create  ? t8('You do not have the permissions to access this function.') : undef,
2154 2168
        ],
2155 2169
        action => [
2156 2170
          t8('Save and print'),
2157
          call   => [ 'kivi.Order.show_print_options', $::instance_conf->get_order_warn_duplicate_parts,
2158
                                                       $::instance_conf->get_order_warn_no_deliverydate,
2159
                    ],
2160
          checks => [ @req_trans_cost_art, @req_cusordnumber ],
2171
          call     => [ 'kivi.Order.show_print_options', $::instance_conf->get_order_warn_duplicate_parts,
2172
                                                         $::instance_conf->get_order_warn_no_deliverydate,
2173
                      ],
2174
          checks   => [ @req_trans_cost_art, @req_cusordnumber ],
2175
          disabled => !$may_edit_create  ? t8('You do not have the permissions to access this function.') : undef,
2161 2176
        ],
2162 2177
        action => [
2163 2178
          t8('Save and E-mail'),
2164
          id   => 'save_and_email_action',
2165
          call => [ 'kivi.Order.save', 'save_and_show_email_dialog', $::instance_conf->get_order_warn_duplicate_parts,
2166
                                                                     $::instance_conf->get_order_warn_no_deliverydate,
2167
                  ],
2168
          disabled => !$self->order->id ? t8('This object has not been saved yet.') : undef,
2179
          id       => 'save_and_email_action',
2180
          call     => [ 'kivi.Order.save', 'save_and_show_email_dialog', $::instance_conf->get_order_warn_duplicate_parts,
2181
                                                                         $::instance_conf->get_order_warn_no_deliverydate,
2182
                      ],
2183
          disabled => !$may_edit_create  ? t8('You do not have the permissions to access this function.')
2184
                    : !$self->order->id  ? t8('This object has not been saved yet.')
2185
                    :                      undef,
2169 2186
        ],
2170 2187
        action => [
2171 2188
          t8('Download attachments of all parts'),
......
2179 2196
        t8('Delete'),
2180 2197
        call     => [ 'kivi.Order.delete_order' ],
2181 2198
        confirm  => $::locale->text('Do you really want to delete this object?'),
2182
        disabled => !$self->order->id ? t8('This object has not been saved yet.') : undef,
2199
        disabled => !$may_edit_create  ? t8('You do not have the permissions to access this function.')
2200
                  : !$self->order->id  ? t8('This object has not been saved yet.')
2201
                  :                      undef,
2183 2202
        only_if  => $deletion_allowed,
2184 2203
      ],
2185 2204

  
2186 2205
    );
2187 2206
  }
2188
  }
2189

  
2190
  for my $bar ($::request->layout->get('actionbar')) {
2191
    $bar->add(
2192
      combobox => [
2193
        action => [
2194
          t8('more')
2195
        ],
2196
        action => [
2197
          t8('History'),
2198
          call     => [ 'set_history_window', $self->order->id, 'id' ],
2199
          disabled => !$self->order->id ? t8('This record has not been saved yet.') : undef,
2200
        ],
2201
        action => [
2202
          t8('Follow-Up'),
2203
          call     => [ 'kivi.Order.follow_up_window' ],
2204
          disabled => !$self->order->id ? t8('This object has not been saved yet.') : undef,
2205
          only_if  => $::auth->assert('productivity', 1),
2206
        ],
2207
      ], # end of combobox "more"
2208
    );
2209
  }
2210

  
2211 2207
}
2212 2208

  
2213 2209
sub generate_doc {

Auch abrufbar als: Unified diff