Revision 274

Date:
2013/02/07 18:18:11
Author:
ahitrov
Revision Log:
Coupon workaround
Files:

Legend:

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

     
    5 5 <tr class="<% $status == 1 ? 'inverted' : '' %>">
    6 6 <td><a href="/contenido/webshop/coupons.html">Активные:</a></td>
    7 7 <td><b><% $stats{1} || 0 %></b></td></tr>
    8 <tr class="<% $status == 0 ? 'inverted' : '' %>">
    9 <td><a href="/contenido/webshop/coupons.html?cst=0" style="<% $status == 0 ? '' : 'color:gray' %>">Неактивные:</a></td>
    8 <tr class="<% defined $status && $status == 0 ? 'inverted' : '' %>">
    9 <td><a href="/contenido/webshop/coupons.html?cst=0" style="<% defined $status && $status == 0 ? '' : 'color:gray' %>">Неактивные:</a></td>
    10 10 <td><b><% $stats{0} || 0 %></b></td></tr>
    11 11 <tr class="<% $status == 3 ? 'inverted' : '' %>">
    12 12 <td><a href="/contenido/webshop/coupons.html?cst=3" style="<% $status == 3 ? '' : 'color:black' %>">Использованные:</a></td>
  • utf8/plugins/webshop/comps/contenido/webshop/components/pbase_links.msn

     
    1 <style>
    2 <!--
    3 .tab { font:9pt Verdana; padding:1px 5px 2px 5px;
    4 border-top:1px solid silver; border-left:1px solid silver; border-right:2px solid silver; }
    5 .tab a { text-decoration:none; }
    6 .tabi { font:9pt Verdana; padding:1px 5px 1px 5px; background: #d0d0d0;
    7 border-top:1px solid #f0f0f0; border-left:1px solid #f0f0f0; border-right:2px solid silver; }
    8 .tabi a { text-decoration:none; }
    9 -->
    10 </style>
    11 <script language="javascript">
    12 <!--
    13 var Controls = [\
    14 % if ( ref $links eq 'ARRAY' && scalar @$links ) {
    15 % for ( 0 .. (scalar(@$links)-1) ) {
    16 % if ( $_ ) { $m->out(',') }
    17 'tab_<% $_ %>'\
    18 % }
    19 % }
    20 ];
    21 function SetActive ( sControl ) {
    22 var oControl;
    23 for (sC in Controls) {
    24 oControl = document.getElementById(Controls[sC]);
    25 oControl.style.backgroundColor = '#d0d0d0';
    26 oControl.style.borderTop = '1px solid #f0f0f0';
    27 oControl.style.borderLeft = '1px solid #f0f0f0';
    28 }
    29 oControl = document.getElementById(sControl);
    30 oControl.style.backgroundColor = 'white';
    31 oControl.style.borderTop = '1px solid silver';
    32 oControl.style.borderLeft = '1px solid silver';
    33 }
    34 //-->
    35 </script>
    36 % if ( ref $links eq 'ARRAY' && scalar @$links ) {
    37 % my $deflink = $links->[0];
    38 % my $id = exists $deflink->{source_field} ? $deflink->{source_field} : 'id';
    39 % my $auto = '';
    40 % if ( exists $deflink->{auto} && ref $deflink->{auto} eq 'HASH' ) {
    41 % while ( my ($from, $to) = each %{ $deflink->{auto} } ) {
    42 % $auto .= '&from='.$from.'&to='.$document->$to;
    43 % }
    44 % }
    45 <fieldset style="width:97%;">
    46 <legend>Зависимости этого документа</legend>
    47 <div style="border-bottom:2px solid gray; padding:1px 0 2px;">
    48 % my $i = 0;
    49 % foreach my $link ( @$links ) {
    50 % my $id = exists $link->{source_field} ? $link->{source_field} : 'id';
    51 % my $auto = '';
    52 % if ( exists $link->{auto} && ref $link->{auto} eq 'HASH' ) {
    53 % while ( my ($from, $to) = each %{ $link->{auto} } ) {
    54 % $auto .= '&from='.$from.'&to='.$document->$to;
    55 % }
    56 % }
    57 <span id="tab_<% $i %>" class="tab<% $i ? 'i' : '' %>"><a onclick="SetActive('tab_<% $i %>')"
    58 href="/contenido/document_filter_list.html?class=<% $link->{class} %>&filter=<% $link->{filter} %>&field=<% $link->{field} %><% $auto %>&id=<% $document->$id %><% exists $link->{order_by} ? '&order_by='.$link->{order_by} : '' %>"
    59 target="filtered"><% $link->{name} %></a></span>\
    60 % $i++;
    61 % }
    62 </div>
    63 <iframe id="filtered" name="filtered" src="/contenido/document_filter_list.html?class=<% $deflink->{class} %>&filter=<% $deflink->{filter} %>&field=<% $deflink->{field} %><% $auto %>&id=<% $document->$id %><% exists $deflink->{order_by} ? '&order_by='.$deflink->{order_by} : '' %>"
    64 width="100%" height="470" frameborder="0"></iframe>
    65 </fieldset>
    66 % }
    67 <%args>
    68
    69 $document => undef
    70
    71 </%args>
    72 <%init>
    73
    74 return unless ref $document;
    75 my $links = $document->table_links;
    76
    77 </%init>
  • utf8/plugins/webshop/comps/contenido/webshop/coupon.html

     
    181 181
    182 182 </form>
    183 183
    184
    185
    186 % if (ref($object) && ($object->id)) {
    187
    188 <!-- Связи и привязки к рубрикам -->
    189
    190 <br>
    191
    192 <table width="100%" cellspacing="5" cellpadding="0" border="0">
    193 <tr>
    194 <td width=50% valign=top>\
    195 <iframe id="links" src="/contenido/document_links.html?id=<% $object->id() %>&class=<% $object->class() %>" width="100%" height="700" frameborder="0"></iframe>
    196 % if ( $m->comp_exists ("/contenido/components/pbase_rubrics.msn") ) {
    197 <& "/contenido/components/pbase_rubrics.msn", document => $object &>\
    198 % }
    199 </td>
    200 <td width=50% valign=top>
    201 % if ( $object->pid == 0 && $m->comp_exists ("/contenido/webshop/components/pbase_links.msn") ) {
    202 <& "/contenido/webshop/components/pbase_links.msn", document => $object &>\
    203 % }
    204
    205 </td>
    206 </tr>
    207 </table>
    208
    209 <!-- / Связи и привязки к рубрикам -->
    210
    211 % }
    212
    213
    214
    184 215 %#<pre><% Dumper($object) %></pre>
    185 216
    186 217 </body>
  • utf8/plugins/webshop/lib/webshop/Coupon.pm

     
    73 73 }
    74 74 }
    75 75
    76 sub table_links
    77 {
    78 return [
    79 { name => 'Купоны', class => 'webshop::Coupon', filter => 'pid', field => 'pid' },
    80 ];
    81 }
    76 82
    77 83
    78 84 sub get_discount
     
    175 181 return 1;
    176 182 }
    177 183
    184
    185 sub post_delete
    186 {
    187 my $self = shift;
    188
    189 my $sql = $self->keeper->SQL->prepare('DELETE FROM webshop_coupons where pid = ?');
    190 $sql->execute( $self->id );
    191 my $sql = $self->keeper->SQL->prepare('DELETE FROM webshop_coupon_links where source_id = ?');
    192 $sql->execute( $self->id );
    193 my $sql = $self->keeper->SQL->prepare('DELETE FROM webshop_order_coupons where dest_id = ?');
    194 $sql->execute( $self->id );
    195
    196 1;
    197 }
    198
    178 199 1;
  • utf8/plugins/webshop/lib/webshop/CouponItemLink.pm

     
    18 18 return ();
    19 19 }
    20 20
    21 sub class_table
    22 {
    23 return 'webshop::SQL::CouponLinkTable';
    24 }
    25
    26
    21 27 sub available_sources
    22 28 {
    23 29 return [ qw(webshop::Coupon) ];
  • utf8/plugins/webshop/lib/webshop/SQL/CouponsTable.pm

     
    25 25 _link_filter
    26 26
    27 27 _uid_filter
    28 _pid_filter
    28 29 _code_filter
    29 30 )];
    30 31
     
    134 135 return &SQL::Common::_generic_int_filter('d.uid', $opts{uid});
    135 136 }
    136 137
    138 sub _pid_filter {
    139 my ($self,%opts)=@_;
    140 return undef unless ( exists $opts{pid} );
    141 return &SQL::Common::_generic_int_filter('d.pid', $opts{pid});
    142 }
    143
    137 144 sub _code_filter {
    138 145 my ($self,%opts)=@_;
    139 146 return undef unless ( exists $opts{code} );