Merge pull request #2146 from cuneytsenturk/master

Added Revenue/Payment show page [#mdbaet]
This commit is contained in:
Cüneyt Şentürk
2021-06-27 13:06:52 +03:00
committed by GitHub
53 changed files with 3732 additions and 152 deletions

View File

@ -7,9 +7,13 @@ use App\Models\Banking\Transaction;
use App\Models\Setting\Currency;
use App\Http\Requests\Portal\PaymentShow as Request;
use App\Utilities\Modules;
use App\Traits\Transactions;
use Illuminate\Support\Facades\URL;
class Payments extends Controller
{
use Transactions;
/**
* Display a listing of the resource.
*
@ -51,4 +55,62 @@ class Payments extends Controller
return $this->response('portal.currencies.index', compact('currencies'));
}
/**
* Show the form for viewing the specified resource.
*
* @param Transaction $payment
*
* @return Response
*/
public function printPayment(Transaction $payment, Request $request)
{
event(new \App\Events\Transaction\TransactionPrinting($payment));
$revenue = $payment;
$view = view($payment->template_path, compact('revenue'));
return mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
}
/**
* Show the form for viewing the specified resource.
*
* @param Transaction $payment
*
* @return Response
*/
public function pdfPayment(Transaction $payment, Request $request)
{
event(new \App\Events\Transaction\TransactionPrinting($payment));
$currency_style = true;
$revenue = $payment;
$view = view($payment->template_path, compact('revenue', 'currency_style'))->render();
$html = mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
$pdf = app('dompdf.wrapper');
$pdf->loadHTML($html);
//$pdf->setPaper('A4', 'portrait');
$file_name = $this->getTransactionFileName($payment);
return $pdf->download($file_name);
}
public function signed(Transaction $payment)
{
if (empty($payment)) {
return redirect()->route('login');
}
$payment_methods = Modules::getPaymentMethods();
$print_action = URL::signedRoute('signed.payments.print', [$payment->id]);
$pdf_action = URL::signedRoute('signed.payments.pdf', [$payment->id]);
return view('portal.payments.signed', compact('payment', 'payment_methods', 'print_action', 'pdf_action'));
}
}

View File

@ -17,11 +17,12 @@ use App\Models\Setting\Category;
use App\Models\Setting\Currency;
use App\Traits\Currencies;
use App\Traits\DateTime;
use App\Traits\Transactions;
use App\Utilities\Modules;
class Payments extends Controller
{
use Currencies, DateTime;
use Currencies, DateTime, Transactions;
/**
* Display a listing of the resource.
@ -40,9 +41,9 @@ class Payments extends Controller
*
* @return Response
*/
public function show()
public function show(Transaction $payment)
{
return redirect()->route('payments.index');
return view('purchases.payments.show', compact('payment'));
}
/**
@ -91,7 +92,7 @@ class Payments extends Controller
$response = $this->ajaxDispatch(new CreateTransaction($request));
if ($response['success']) {
$response['redirect'] = route('payments.index');
$response['redirect'] = route('payments.show', $response['data']->id);
$message = trans('messages.success.added', ['type' => trans_choice('general.payments', 1)]);
@ -206,7 +207,7 @@ class Payments extends Controller
$response = $this->ajaxDispatch(new UpdateTransaction($payment, $request));
if ($response['success']) {
$response['redirect'] = route('payments.index');
$response['redirect'] = route('payments.show', $payment->id);
$message = trans('messages.success.updated', ['type' => trans_choice('general.payments', 1)]);
@ -257,4 +258,69 @@ class Payments extends Controller
{
return $this->exportExcel(new Export, trans_choice('general.payments', 2));
}
/**
* Download the PDF file of payment.
*
* @param Transaction $payment
*
* @return Response
*/
public function emailPayment(Transaction $payment)
{
if (empty($payment->contact->email)) {
return redirect()->back();
}
// Notify the customer
$payment->contact->notify(new Notification($payment, 'payment_new_customer', true));
event(new \App\Events\Transaction\TransactionSent($payment));
flash(trans('documents.messages.email_sent', ['type' => trans_choice('general.payments', 1)]))->success();
return redirect()->back();
}
/**
* Print the payment.
*
* @param Transaction $payment
*
* @return Response
*/
public function printPayment(Transaction $payment)
{
event(new \App\Events\Transaction\TransactionPrinting($payment));
$view = view($payment->template_path, compact('payment'));
return mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
}
/**
* Download the PDF file of payment.
*
* @param Transaction $payment
*
* @return Response
*/
public function pdfPayment(Transaction $payment)
{
event(new \App\Events\Transaction\TransactionPrinting($payment));
$currency_style = true;
$view = view($payment->template_path, compact('payment', 'currency_style'))->render();
$html = mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
$pdf = app('dompdf.wrapper');
$pdf->loadHTML($html);
//$pdf->setPaper('A4', 'portrait');
$file_name = $this->getTransactionFileName($payment);
return $pdf->download($file_name);
}
}

View File

@ -15,13 +15,15 @@ use App\Models\Banking\Transaction;
use App\Models\Common\Contact;
use App\Models\Setting\Category;
use App\Models\Setting\Currency;
use App\Notifications\Sale\Revenue as Notification;
use App\Traits\Currencies;
use App\Traits\DateTime;
use App\Traits\Transactions;
use App\Utilities\Modules;
class Revenues extends Controller
{
use Currencies, DateTime;
use Currencies, DateTime, Transactions;
/**
* Display a listing of the resource.
@ -40,9 +42,9 @@ class Revenues extends Controller
*
* @return Response
*/
public function show()
public function show(Transaction $revenue)
{
return redirect()->route('revenues.index');
return view('sales.revenues.show', compact('revenue'));
}
/**
@ -91,7 +93,7 @@ class Revenues extends Controller
$response = $this->ajaxDispatch(new CreateTransaction($request));
if ($response['success']) {
$response['redirect'] = route('revenues.index');
$response['redirect'] = route('revenues.show', $response['data']->id);
$message = trans('messages.success.added', ['type' => trans_choice('general.revenues', 1)]);
@ -206,7 +208,7 @@ class Revenues extends Controller
$response = $this->ajaxDispatch(new UpdateTransaction($revenue, $request));
if ($response['success']) {
$response['redirect'] = route('revenues.index');
$response['redirect'] = route('revenues.show', $revenue->id);
$message = trans('messages.success.updated', ['type' => trans_choice('general.revenues', 1)]);
@ -257,4 +259,69 @@ class Revenues extends Controller
{
return $this->exportExcel(new Export, trans_choice('general.revenues', 2));
}
/**
* Download the PDF file of revenue.
*
* @param Transaction $revenue
*
* @return Response
*/
public function emailRevenue(Transaction $revenue)
{
if (empty($revenue->contact->email)) {
return redirect()->back();
}
// Notify the customer
$revenue->contact->notify(new Notification($revenue, 'revenue_new_customer', true));
event(new \App\Events\Transaction\TransactionSent($revenue));
flash(trans('documents.messages.email_sent', ['type' => trans_choice('general.revenues', 1)]))->success();
return redirect()->back();
}
/**
* Print the revenue.
*
* @param Transaction $revenue
*
* @return Response
*/
public function printRevenue(Transaction $revenue)
{
event(new \App\Events\Transaction\TransactionPrinting($revenue));
$view = view($revenue->template_path, compact('revenue'));
return mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
}
/**
* Download the PDF file of revenue.
*
* @param Transaction $revenue
*
* @return Response
*/
public function pdfRevenue(Transaction $revenue)
{
event(new \App\Events\Transaction\TransactionPrinting($revenue));
$currency_style = true;
$view = view($revenue->template_path, compact('revenue', 'currency_style'))->render();
$html = mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
$pdf = app('dompdf.wrapper');
$pdf->loadHTML($html);
//$pdf->setPaper('A4', 'portrait');
$file_name = $this->getTransactionFileName($revenue);
return $pdf->download($file_name);
}
}