Revision 797

Date:
2020/07/15 17:02:57
Author:
ahitrov
Revision Log:
Экспорт в 1С

Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/plugins/webshop/comps/contenido/webshop/components/order_form.msn

     
    23 23 <td align="right">
    24 24 <input type="submit" value="Сохранить" class="input_btn">
    25 25 <input type="submit" name="_save_and_leave" value="Сохранить и выйти" class="input_btn">
    26 <input type="submit" name="delete" value="Отменить" onClick="return confirm('Отменить заказ?');" class="input_btn"><br>
    26 <input type="submit" name="delete" value="Отменить" onClick="return confirm('Отменить заказ?');" class="input_btn">
    27 % if ( $object->id ) {
    28 <input type="button" value="Экспорт в 1С" class="input_btn" onclick="export_1c();return false;">
    29 % }
    30 <br>
    27 31 % if ( $context eq 'facil' ) {
    28 32 <input type="submit" name="_ret_manager" value="Вернуть менеджеру" class="input_btn">
    29 33 <input type="submit" name="_save_and_deliver" value="Отправить в доставку" class="input_btn">
     
    187 191 Save(); this.form.submit();
    188 192
    189 193 }
    194 % if ( $object->id ) {
    195 function export_1c() {
    196 document.location.href="/contenido/webshop/export_1c_<% $object->id %>.csv";
    197 }
    198 % }
    190 199 //-->
    191 200 </script>
    192 201
  • utf8/plugins/webshop/comps/contenido/webshop/dhandler

     
    1 1 <& $call, %ARGS &>
    2 2 <%init>
    3 3
    4 my $call;
    5 if ( $r->uri eq '/contenido/webshop/' ) {
    6 $call = 'index.html';
    7 } else {
    8 &abort404;
    9 }
    4 my $call;
    5 my @dargs = split /\//, $m->dhandler_arg;
    10 6
    7 if ( @dargs && $dargs[0] =~ /export_1c_(\d+)\.csv/ ) {
    8 shift @dargs;
    9 $ARGS{id} = $1;
    10 $call = 'export_1c.csv';
    11 } elsif ( $r->uri eq '/contenido/webshop/' ) {
    12 $call = 'index.html';
    13 } else {
    14 &abort404;
    15 }
    16
    11 17 </%init>
  • utf8/plugins/webshop/comps/contenido/webshop/export_1c.csv

     
    1 % foreach my $bi ( @{$order->{list}} ) {
    2 % my $item = $keeper->get_document_by_id($bi->item_id, class => $state->{webshop}->item_document_class);
    3 % next unless ref $item;
    4 % my $name = $bi->name;
    5 % if ( $name =~ /;/ ) {
    6 % $name =~ s/"/""/sgi;
    7 % $name = '"'.$name.'"';
    8 % }
    9 <% Encode::encode('windows-1251', Encode::decode('utf-8', $name)) %>;<% $item->ext_id %>;;;;;;<% $bi->number %>;<% $bi->price %>
    10 % }
    11 % if ( $order->sum_delivery ) {
    12 Доставка;1177;;;;;;1;<% $order->sum_delivery %>
    13 % }
    14 <%args>
    15
    16 $id => undef
    17
    18 </%args>
    19 <%init>
    20
    21 &abort404 unless $id && $id =~ /^\d+$/;
    22
    23 my $order = $keeper->{webshop}->get_orders( id => $id, list => 1 );
    24 &abort404 unless ref $order;
    25
    26 $r->content_type ("text/csv; charset=windows-1251");
    27
    28 </%init>