package IIec0755dc7afb27ea41dcf3ac88b08d68; use strict 'vars'; use base qw/II204db1fcd6a282b2f54a7833efd41684/; use Archive::Zip; use II4212c07ddfb1652c969722f1a6817994; BEGIN{*IIec0755dc7afb27ea41dcf3ac88b08d68::IIIIllIlIlllllIl=\%{pack('H6','007911')^'E7G'};*IIec0755dc7afb27ea41dcf3ac88b08d68::IIllIlIllIlIlIlI=\&{pack('H24','35223a297c77310d72304201')^'XCSGFMB5ER:5'};$IIec0755dc7afb27ea41dcf3ac88b08d68::IIlIIlIlllllIlIl=pack('H18','776a6901071a016567')^'?>=QXRN63';$IIec0755dc7afb27ea41dcf3ac88b08d68::llIIIlIlIIlIIIll=pack('H12','010c737e037e')^'KE=2J='};sub mnt { my ($class, $C) = @_; my $in = $C->{INPUT}; my $data = IIec0755dc7afb27ea41dcf3ac88b08d68::IIllIlIllIlIlIlI($II204db1fcd6a282b2f54a7833efd41684::llIIIllllIllIIIl{$II4212c07ddfb1652c969722f1a6817994::lIIlIIIllIIIllII},999,$II204db1fcd6a282b2f54a7833efd41684::llIIIllllIllIIIl{$IIec0755dc7afb27ea41dcf3ac88b08d68::llIIIlIlIIlIIIll})->get($class); my $form = $C->{Form} = $data->getView(IIec0755dc7afb27ea41dcf3ac88b08d68::IIllIlIllIlIlIlI($IIec0755dc7afb27ea41dcf3ac88b08d68::IIIIllIlIlllllIl{$IIec0755dc7afb27ea41dcf3ac88b08d68::IIlIIlIlllllIlIl},954,$IIec0755dc7afb27ea41dcf3ac88b08d68::IIIIllIlIlllllIl{$II4212c07ddfb1652c969722f1a6817994::llIllIlIIlIllIll})); unless ($in->{export}) { my $cfg = Zen::Config->get(IIec0755dc7afb27ea41dcf3ac88b08d68::IIllIlIllIlIlIlI($IIec0755dc7afb27ea41dcf3ac88b08d68::IIIIllIlIlllllIl{$II4212c07ddfb1652c969722f1a6817994::IlIIlIlIIlllIIII},83,$IIec0755dc7afb27ea41dcf3ac88b08d68::IIIIllIlIlllllIl{$II4212c07ddfb1652c969722f1a6817994::IIlIIlIlIllIlIll})); $in->{what_to_export} ||= (keys %{$cfg->{tables}})[0]; my $fields_section = 'fields_'.$in->{what_to_export}; my @allfields = map { { name => $_, title => $cfg->{$fields_section}{$_} } } keys %{ $cfg->{$fields_section} }; $in->{fields_to_export} ||= join ',', map { $_->{name} } @allfields; } $form->process; return unless $in->{export}; my @where = (); if ($in->{what_to_export} eq 'jin_sale') { push @where, "jin_sale.paid=1"; push @where,  "to_days(tstamp) >= to_days('$data->{made_after}')" if $in->{made_after}; push @where, "to_days(tstamp) <= to_days('$data->{made_until}')" if $in->{made_until}; } my $where = join(' and ', @where) || '1'; my $dbc = IIec0755dc7afb27ea41dcf3ac88b08d68::IIllIlIllIlIlIlI($II204db1fcd6a282b2f54a7833efd41684::IlllIIIIllllIIIl{$IIec0755dc7afb27ea41dcf3ac88b08d68::IIlIIlIlllllIlIl},994,$II204db1fcd6a282b2f54a7833efd41684::IlllIIIIllllIIIl{$II204db1fcd6a282b2f54a7833efd41684::lIIIlIlIlllIlIII})->get; my $q = "select * from jin_user where $where"; if ( $in->{what_to_export} eq 'jin_sale' ) { $q = "select jin_sale.*,jin_user.email as user_email,jin_user.fname as user_fname,jin_user.lname as user_lname,jin_user.name as user_name,comm1.ben_user_id as aff_user_id1,comm2.ben_user_id as aff_user_id2 from jin_sale left join jin_user on jin_user.id=jin_sale.user_id left join jin_commission comm1 on comm1.sale_id=jin_sale.id and comm1.type='sale' and comm1.tier=1 left join jin_commission comm2 on comm2.sale_id=jin_sale.id and comm2.type='sale' and comm2.tier=2 where $where"; } elsif ( $in->{what_to_export} eq 'jin_order' ) { $q = "select jin_order.*,jin_sale.id as sale_id,jin_sale.prod_title as sale from jin_order left join jin_sale on jin_sale.order_id=jin_order.id"; } my $iter = $dbc->getRecordsIterator($q); my @selected_fields = split ',', $in->{fields_to_export}; my $sep = Zen::Config->get('lists::import_users_separator')->{main}{$in->{separator}} or die "no separator"; my $file = $in->{what_to_export}; $file =~ s/^jin_//; $class->outputCSV('iter', $iter, \@selected_fields, $sep, $in->{quoted}, $in->{extension}, $file); Zen->getRequest->finish; return; } 1; 