Committer: wisest-owl
LJSUP-11906: Userhead admin tool improvementsU trunk/cgi-bin/LJ/Pay/Payment/PayItem/UserHead.pm U trunk/cgi-bin/LJ/UserHead.pm U trunk/htdocs/admin/userheads/manage.bml
Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/UserHead.pm =================================================================== --- trunk/cgi-bin/LJ/Pay/Payment/PayItem/UserHead.pm 2012-04-27 11:16:42 UTC (rev 11845) +++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/UserHead.pm 2012-04-27 11:41:37 UTC (rev 11846) @@ -84,6 +84,19 @@ my $res = $dbh->selectall_arrayref("SELECT item, UNIX_TIMESTAMP(expdate) as expdate, size " . "FROM paidexp WHERE userid=?", { Slice => {} }, $userid); + + $u = LJ::load_userid ($userid) unless $u; + my $propval = $u->prop ('custom_usericon_individual'); + if ($propval) { + my $individual_uh_info = LJ::JSON->from_json ($propval); + if ($individual_uh_info->{'date_exp'} > time) { + push @$res => { + item => $individual_uh_info->{'uh_id'}, + expdate => $individual_uh_info->{'date_exp'}, + size => 1, + }; + } + } return [ grep { $_->{item} =~ /uh-\d+/ } @$res ]; } Modified: trunk/cgi-bin/LJ/UserHead.pm =================================================================== --- trunk/cgi-bin/LJ/UserHead.pm 2012-04-27 11:16:42 UTC (rev 11845) +++ trunk/cgi-bin/LJ/UserHead.pm 2012-04-27 11:41:37 UTC (rev 11846) @@ -4,7 +4,7 @@ use base qw(Class::Accessor); __PACKAGE__->follow_best_practice; -__PACKAGE__->mk_accessors( qw( uh_id uh_author uh_desc uh_desc_sup price visibility ) ); +__PACKAGE__->mk_accessors( qw( uh_id uh_author uh_desc uh_desc_sup price visibility individ_buyer ) ); use LJ::FileStore; Modified: trunk/htdocs/admin/userheads/manage.bml =================================================================== --- trunk/htdocs/admin/userheads/manage.bml 2012-04-27 11:16:42 UTC (rev 11845) +++ trunk/htdocs/admin/userheads/manage.bml 2012-04-27 11:41:37 UTC (rev 11846) @@ -83,7 +83,22 @@ $uh->set_uh_desc ($desc); $uh->set_uh_desc_sup ($desc_sup); $uh->set_visibility ($visibility); + my $buyer = $FORM{"$id-buyer"}; + $uh->set_individ_buyer ($buyer); $uh->save; + + ## Save individual usericon if need + my $exp_date = $FORM{"$id-expdate"}; + my $u = LJ::load_user ($buyer); + if ($u && $exp_date) { + my ($yy, $mm, $dd) = $exp_date =~ m#(\d{4})(\d{2})(\d{2})#; + my $date = DateTime->new (year => $yy, month => $mm, day => $dd); + my $propval = LJ::JSON->to_json ({ + uh_id => "uh-$id", + date_exp => $date->epoch, + }); + $u->set_prop ('custom_usericon_individual' => $propval); + } } } @@ -140,11 +155,15 @@ value => 'D', name => 'Disabled', }, + { + value => 'I', + name => 'Individual', + }, ); $ret .= "<form method='POST'>"; $ret .= "<table border=0 cellspacing=1 cellpadding=4>"; -$ret .= "<tr><td>Id</td><td>Img Enb</td><td>Img Dis</td><td>Cost</td><td> </td><td>Author</td><td>Description</td><td>Description SUP</td><td>Edit</td></tr>"; +$ret .= "<tr><td>Id</td><td>Img Enb</td><td>Img Dis</td><td>Cost</td><td> </td><td>Author</td><td>Description</td><td>Description SUP</td><td>Individual user buyer</td><td>Indv. expdate (<span style=\"font-size:10px;\">YYYYMMDD</span>)</td><td>Edit</td></tr>"; foreach my $uh (@$uhs) { $ret .= "<tr>\n"; $ret .= "<td><input type='hidden' name='".$uh->get_uh_id."-uh_id' value='".$uh->get_uh_id."'>".$uh->get_uh_id."</td>\n"; @@ -165,12 +184,26 @@ $ret .= "<td><input type='text' name='".$uh->get_uh_id."-price' size='5' value='".$uh->get_price."'></td>\n"; $ret .= "<td><select name='".$uh->get_uh_id."-visibility'>\n"; foreach my $sel (@selects) { - $ret .= "\t<option value='".$sel->{'value'}."'".($uh->get_visibility eq $sel->{'value'} ? " selected='selected' " : "").">".$sel->{'name'}."</option>\n"; + $ret .= "\t<option value='".$sel->{'value'}."'".($uh->get_visibility eq $sel->{'value'} ? "qazxsqq selected='selected' " : "").">".$sel->{'name'}."</option>\n"; } $ret .= "</select></td>\n"; + my $exp_date = ""; + if ($uh->get_visibility eq 'I') { + my $i_buyer_u = LJ::load_user ($uh->get_individ_buyer); + if ($i_buyer_u) { + my $uh_data = LJ::JSON->from_json ($i_buyer_u->prop ('custom_usericon_individual') || "{}"); + my $prop_date_exp = $uh_data->{'date_exp'}; + if ($prop_date_exp) { + $exp_date = DateTime->from_epoch (epoch => $prop_date_exp); + $exp_date = $exp_date ? $exp_date->year.sprintf ("%02d", $exp_date->month).sprintf ("%02d", $exp_date->day) : ""; + } + } + } $ret .= "<td><input type='text' name='".$uh->get_uh_id."-author' value='".$uh->get_uh_author."'></td>\n"; $ret .= "<td><input type='text' name='".$uh->get_uh_id."-desc' value='".$uh->get_uh_desc."'></td>\n"; $ret .= "<td><input type='text' name='".$uh->get_uh_id."-desc-sup' value='".$uh->get_uh_desc_sup."'></td>\n"; + $ret .= "<td><input type='text' name='".$uh->get_uh_id."-buyer' value='".$uh->get_individ_buyer."'></td>\n"; + $ret .= "<td><input type='text' name='".$uh->get_uh_id."-expdate' value='".$exp_date."'></td>\n"; $ret .= "<td><input type='submit' name='edit' value='".$uh->get_uh_id."'></td>\n"; $ret .= "</tr>\n"; }