Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 31378f48

Von Werner Hahn vor mehr als 7 Jahren hinzugefügt

  • ID 31378f48eb1742809789dd2e9670f8564850cce1
  • Vorgänger 1228b36f
  • Nachfolger 255d89a0

WebshopApi: Bilder hochladen

Unterschiede anzeigen:

SL/File.pm
8 8
use SL::File::Backend;
9 9
use SL::File::Object;
10 10
use SL::DB::History;
11
use SL::DB::ShopImage;
11 12
use SL::DB::File;
12 13
use SL::Helper::UserPreferences;
14
use SL::Controller::Helper::ThumbnailCreator qw(file_probe_type);
13 15
use SL::JSON;
14 16

  
15 17
use constant RENAME_OK          => 0;
......
240 242

  
241 243
  $file->mtime(DateTime->now_local);
242 244
  $file->save;
245
  #ShopImage
246
  if($file->object_type eq "shop_image"){
247
    my $image_content = $params{file_contents};
248
    my $thumbnail = file_probe_type($image_content);
249
    my $shopimage = SL::DB::ShopImage->new();
250
    $shopimage->assign_attributes(
251
                                  file_id                => $file->id,
252
                                  thumbnail_content      => $thumbnail->{thumbnail_img_content},
253
                                  org_file_height        => $thumbnail->{file_image_height},
254
                                  org_file_width         => $thumbnail->{file_image_width},
255
                                  thumbnail_content_type => $thumbnail->{thumbnail_img_content_type},
256
                                  object_id              => $file->object_id,
257
                                 );
258
    $shopimage->save;
259
  }
243 260
  if ($params{file_type} eq 'document' && $params{source} ne 'created') {
244 261
    SL::DB::History->new(
245 262
      addition    => 'IMPORT',
SL/File/Backend/Webdav.pm
128 128
  assembly                => 'erzeugnisse',
129 129
  letter                  => 'briefe',
130 130
  general_ledger          => 'dialogbuchungen',
131
  gl_transaction          => 'dialogbuchungen',
131 132
  accounts_payable        => 'kreditorenbuchungen',
133
  shop_image              => 'shopbilder',
132 134
);
133 135

  
134 136
my %type_to_model = (
......
146 148
  assembly                => 'Part',
147 149
  letter                  => 'Letter',
148 150
  general_ledger          => 'GLTransaction',
151
  gl_transaction          => 'GLTransaction',
149 152
  accounts_payable        => 'GLTransaction',
153
  shop_image              => 'Part',
150 154
);
151 155

  
152 156
my %model_to_number = (
......
156 160
  PurchaseInvoice => 'invnumber',
157 161
  Part            => 'partnumber',
158 162
  Letter          => 'letternumber',
159
  GLTransaction   => 'reference'
163
  GLTransaction   => 'reference',
164
  ShopImage       => 'partnumber',
160 165
);
161 166

  
162 167
sub webdav_path {
js/kivi.File.js
170 170
    return false;
171 171
  }
172 172

  
173
  ns.delete_file = function(id,controller_action) {
174
    $.post('controller.pl', { action: controller_action, id: id }, function(data) {
175
      kivi.eval_json_result(data);
176
    });
177
  };
178

  
173 179
  ns.unimport = function(id,type,file_type,checkbox_class) {
174 180
    var checkboxes = $('.'+checkbox_class).filter(function () { return  $(this).prop('checked'); });
175 181

  
templates/webpages/file/upload_dialog.html
1 1
[%- USE L -%][%- USE LxERP -%][%- USE JavaScript -%]
2 2

  
3 3
<form method="post" id="upload_form" enctype="multipart/form-data" action="controller.pl">
4
  [% SET multiple = 'true' %]
5
  [% IF SELF.object_type == 'shop_image' %][% multiple = 'false' %][% END %]
4 6
 <table>
5 7
  <tr>
6 8
   <td>[%- LxERP.t8("Filename") %]:</td><td>
7
   <input type="file" name="uploadfiles[]" multiple="true" id="upload_files" size="45" accept="[% SELF.accept_types %]" onchange="kivi.File.allow_upload_submit();"></td>
9
   <input type="file" name="uploadfiles[]" multiple="[% multiple %]" id="upload_files" size="45" accept="[% SELF.accept_types %]" onchange="kivi.File.allow_upload_submit();"></td>
8 10
  </tr>
11
  [% IF SELF.object_type == 'shop_image' %]
12
    <tr>
13
      <td>[% LxERP.t8("Title") %]</td>
14
      <td>[% L.input_tag("title",'') %]</td>
15
    </tr>
16
    <tr>
17
      <td>[% LxERP.t8("Description") %]</td>
18
      <td>[% L.input_tag("description",'') %]</td>
19
    </tr>
20
  [% END %]
9 21
 </table>
10 22

  
11 23
 <p>

Auch abrufbar als: Unified diff