芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/qrafiqxcreativeagency.com/accounts/office/app/DataTables/ProposalDataTable.php
editProposalPermission = user()->permission('edit_lead_proposals'); $this->addInvoicePermission = user()->permission('add_invoices'); $this->deleteProposalPermission = user()->permission('delete_lead_proposals'); $this->viewProposalPermission = user()->permission('view_lead_proposals'); } /** * Build DataTable class. * * @param mixed $query Results from query() method. * @return \Yajra\DataTables\DataTableAbstract */ public function dataTable($query) { return datatables() ->eloquent($query) ->addIndexColumn() ->addColumn('action', function ($row) { $action = '
'; $action .= '
' . __('app.view') . '
'; if ($row->send_status) { $action .= '
' . __('modules.proposal.publicLink') . '
'; } $action .= '
' . trans('app.download') . '
'; if (!$row->signature && $this->editProposalPermission == 'all' || ($this->editProposalPermission == 'added' && user()->id == $row->added_by)) { $action .= '
' . trans('app.edit') . '
'; } if ($row->status != 'declined') { $action .= '
' . trans('app.send') . '
'; } if ($row->status != 'declined' && $row->send_status == 0) { $action .= '
' . trans('app.markSent') . '
'; } if (($this->addInvoicePermission == 'all' || ($this->addInvoicePermission == 'added' && user()->id == $row->added_by))) { $action .= '
' . __('app.create') . ' ' . __('app.invoice') . '
'; } if (!$row->signature && $this->deleteProposalPermission == 'all' || ($this->deleteProposalPermission == 'added' && user()->id == $row->added_by)) { $action .= '
' . trans('app.delete') . '
'; } $action .= '
'; return $action; }) ->editColumn('client_name', function ($row) { return '
' . $row->client_name . '
'; }) ->addColumn('proposal_number', function ($row) { return '
' .__('modules.lead.proposal').'#'. $row->id . '
'; }) ->editColumn('status', function ($row) { $status = ''; if ($row->status == 'waiting') { $status = '
' . __('modules.proposal.' . $row->status); } if ($row->status == 'declined') { $status = '
' . __('modules.proposal.' . $row->status); } if ($row->status == 'accepted') { $status = '
' . __('modules.proposal.' . $row->status); } if (!$row->send_status) { $status .= '
' . __('modules.invoices.notSent') . '
'; } return $status; }) ->editColumn('total', function ($row) { return currency_format($row->total, $row->currencyId); }) ->editColumn( 'valid_till', function ($row) { return Carbon::parse($row->valid_till)->translatedFormat($this->company->date_format); } ) ->editColumn( 'created_at', function ($row) { return Carbon::parse($row->created_at)->translatedFormat($this->company->date_format); } ) ->rawColumns(['name', 'action', 'status', 'client_name', 'proposal_number']) ->removeColumn('currency_symbol'); } /** * @return \Illuminate\Database\Query\Builder */ public function query() { $request = $this->request(); $model = Proposal::select('proposals.id', 'proposals.hash', 'leads.client_name', 'proposals.send_status', 'leads.client_id', 'leads.id as lead_id', 'total', 'valid_till', 'proposals.status', 'currencies.currency_symbol', 'currencies.id as currencyId', 'leads.company_name', 'proposals.added_by', 'proposals.created_at') ->with('signature') ->join('currencies', 'currencies.id', '=', 'proposals.currency_id') ->join('leads', 'leads.id', 'proposals.lead_id'); if ($request->startDate !== null && $request->startDate != 'null' && $request->startDate != '') { $startDate = Carbon::createFromFormat($this->company->date_format, $request->startDate)->toDateString(); $model = $model->where(DB::raw('DATE(proposals.`created_at`)'), '>=', $startDate); } if ($request->endDate !== null && $request->endDate != 'null' && $request->endDate != '') { $endDate = Carbon::createFromFormat($this->company->date_format, $request->endDate)->toDateString(); $model = $model->where(DB::raw('DATE(proposals.`created_at`)'), '<=', $endDate); } if ($request->leadId !== null && $request->leadId != 'null' && $request->leadId != '' && $request->leadId != 'all') { $model = $model->where('proposals.lead_id', $request->leadId); } if ($request->status != 'all' && !is_null($request->status)) { $model = $model->where('proposals.status', '=', $request->status); } if ($this->viewProposalPermission == 'added') { $model = $model->where('proposals.added_by', user()->id); } return $model; } /** * Optional method if you want to use html builder. * * @return \Yajra\DataTables\Html\Builder */ public function html() { $dataTable = $this->setBuilder('invoices-table') ->parameters([ 'initComplete' => 'function () { window.LaravelDataTables["invoices-table"].buttons().container() .appendTo( "#table-actions") }', 'fnDrawCallback' => 'function( oSettings ) { $("body").tooltip({ selector: \'[data-toggle="tooltip"]\' }) }', ]); if (canDataTableExport()) { $dataTable->buttons(Button::make(['extend' => 'excel', 'text' => '
' . trans('app.exportExcel')])); } return $dataTable; } /** * Get columns. * * @return array */ protected function getColumns() { return [ '#' => ['data' => 'DT_RowIndex', 'orderable' => false, 'searchable' => false, 'visible' => false, 'title' => '#'], __('app.id') => ['data' => 'id', 'name' => 'id', 'title' => __('app.id'), 'visible' => false], __('modules.lead.proposal') => ['data' => 'proposal_number', 'name' => 'proposal_number', 'title' => __('modules.lead.proposal')], __('app.name') => ['data' => 'client_name', 'name' => 'client_name', 'title' => __('app.name')], __('modules.invoices.total') => ['data' => 'total', 'name' => 'total', 'title' => __('modules.invoices.total')], __('app.date') => ['data' => 'created_at', 'name' => 'created_at', 'title' => __('app.date')], __('modules.estimates.validTill') => ['data' => 'valid_till', 'name' => 'valid_till', 'title' => __('modules.estimates.validTill')], __('app.status') => ['data' => 'status', 'name' => 'status', 'title' => __('app.status')], Column::computed('action', __('app.action')) ->exportable(false) ->printable(false) ->orderable(false) ->searchable(false) ->addClass('text-right pr-20') ]; } }