wrapper()->title(_t('@bills', 'Payments / Transactions')); $statusText = array( Bills::STATUS_WAITING => ''._t('@bills', 'not completed').'', Bills::STATUS_COMPLETED => ''._t('@bills', 'completed').'', Bills::STATUS_PROCESSING => ''._t('@bills', 'processing').'', Bills::STATUS_CANCELED => ''._t('@bills', 'canceled').'', 'activated' => ''._t('@bills', 'completed').'', ); $list->filters() ->text('id', _t('@bills', 'Transaction #'), ['width'=> 70]) ->text('item', _t('@bills', 'Object ID'), ['width'=> 90]) ->date('p_from', _t('@bills', 'Date From'), ['width'=> 90]) ->date('p_to', _t('@bills', 'Date To'), ['width'=> 90]) ->autocomplete('uid', _te('@bills', 'User Email'), false, [], [ 'autocomplete' => function($q) { return Bills::model()->userAutocomplete($q); }, 'values' => function($id) { $fields = ['email']; $phone = method_exists(Users::model(), 'userPhoneCrypted'); if ($phone) { $fields[] = 'phone_number'; } $data = Users::model()->userDataByFilter($id, $fields); if (method_exists('Users', 'autocompleteTitleEmail')) { return Users::autocompleteTitleEmail($data); } return $data['email']; }, 'width'=> 180 ]) ->select('type', _t('@bills', 'Transaction Type'), function(){ return Bills::getTypeOptions(); }, 0, ['width'=> 120]) ->select('svc', _t('@bills', 'Service'), function(){ return Bills::serviceOptions(); }, 0, ['idKey' => 'id', 'titleKey' => 'title', 'width'=> 110]) ; $statusChangeAllowed = Bills::getStatusChangeAllowed(); $statuses = Bills::getStatusData(); $list ->column('id', 'ID', 60, ['order'=> $list::COLUMN_ORDER_DESC]) ->column('created', _t('@bills', 'Date'), 180, [], function($t, $r, $o){return tpl::date_format2($r['created'], true);}) ->column('user', _t('@bills', 'User'), 180, [], function($t, $r, $o) { $user = empty($r['email']) && ! empty($r['phone_number']) ? $r['phone_number'] : $r['email']; return $r['user_id'] > 0 ? ''.$user.'' : ''.$r['ip'].''; }) ->column('user_balance', _t('@bills', 'Balance'), 80, ['align'=>$list::COLUMN_ALIGN_CENTER]) ->column('amount_text', _t('@bills', 'Amount'), 80, ['align'=>$list::COLUMN_ALIGN_CENTER], function($t, $r, $o){ return (in_array($r['type'], [Bills::TYPE_OUT_SERVICE, Bills::TYPE_OUT_ADMIN]) ? ( !$r['amount'] ? '0' : '– '.$r['amount'].'' ) : '+ '.$r['amount'].''); }) ->column('description', _t('@bills', 'Description'), 150, ['align'=>$list::COLUMN_ALIGN_LEFT], function ($t, $r, $o){ $title = ''; if (! empty($r['psystem'])) { $way = ! empty($r['psystem_way']) ? $r['psystem_way'] : ''; $title = $r['psystem'] . ($way ? ' / ' . $way : ''); $system = Bills::paymentProvider($r['psystem']); if ($system) { $title = $system->providerTitle(); if ($way) { $ways = $system->payWays(); if (isset($ways[$way]['title'])) { $title .= ' / ' . $ways[$way]['title']; } } } } ?> '.$title.'' : '' ?> column('status', _t('@bills', 'Status'), 200, [], function($t, $r, $o) use(&$statusText, &$list, &$statusChangeAllowed, &$statuses) { if(in_array($r['status'], $statusChangeAllowed)) { $status = isset($statusText[ $r['status'] ]) ? $statusText[ $r['status'] ] : ''; if (! $status && isset($statuses[ $r['status'] ])) { $status = mb_strtolower($statuses[ $r['status'] ]); } return '' . $status . ''; } else if($r['status'] == Bills::STATUS_COMPLETED) { if( $r['type'] == Bills::TYPE_OUT_SERVICE) { return $statusText['activated']; } else { return $statusText[ $r['status'] ].'
'.tpl::date_format2($r['payed'], true); } } else if($r['status'] == Bills::STATUS_CANCELED) { return $statusText[ $r['status'] ]; } return ''; }) ->afterFilterRender(function($html) use ($list, & $summary){ ob_start();ob_implicit_flush(false); ?> '._t('@bills', 'Amount').' '.round($cnt, 0).' '._t('@bills', 'Amount').' '.round($sum, 2).''; }; $list->onAjaxResponse(function($data) use(& $summary) { $data['summary'] = $summary(); return $data; }); $list->jsStart('jBillListing'); ?> jsStop();