| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace App\Http\Controllers;
- use App\Interfaces\SettlementBillControllerInterface;
- use App\Owner;
- use App\OwnerBillReport;
- use App\OwnerBillReportArchive;
- use App\Services\OwnerBillReportArchiveService;
- use App\Services\OwnerProcurementSettlementBillService;
- use App\Traits\SettlementBillTrait;
- use Illuminate\Http\RedirectResponse;
- use Illuminate\Http\Request;
- use Oursdreams\Export\Export;
- class SettlementBillPackingMaterialFeeController extends Controller implements SettlementBillControllerInterface
- {
- use SettlementBillTrait;
- /**php
- * @var $archiveService OwnerBillReportArchiveService
- */
- private $archiveService;
- /**
- * @var $service OwnerProcurementSettlementBillService
- */
- private $service;
- public function __construct()
- {
- $this->archiveService = app('OwnerBillReportArchiveService');
- $this->service = app('OwnerProcurementSettlementBillService');
- }
- public function index(Request $request)
- {
- $paginateParams = $request->input();
- list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
- list($details, $total_fee) = $this->service->get([
- 'counting_month' => $counting_month,
- 'owner_id' => $owner_id,
- 'type' => $this->service::TYPE,
- ]);
- $owners = Owner::query()->selectRaw("id,name")->whereIn('id', $permittingOwnerIds)->get();
- $owner = Owner::query()->selectRaw("name,id")->find($owner_id);
- $isArchived = $this->archiveService->isArchived($counting_month, $owner_id, $this->service::TYPE);
- $request = $this->buildRequest($request, $counting_month,$owner_id);
- return view('finance.settlementBills.packingMaterialFee.index', compact('details', 'paginateParams', 'owners', 'owner', 'request', 'isArchived', 'total_fee'));
- }
- public function export(Request $request)
- {
- list($permittingOwnerIds, $counting_month, $owner_id) = $this->getRequestParams($request->year, $request->month, $request->owner_id);
- $query = $this->service->getSql($owner_id, $counting_month);
- if (!$request->exists('checkAllSign')) {
- $query->whereIn('id', explode(',', $request['data']));
- }
- $details = $query->get();
- $json = $this->service->buildExport($details);
- $row = ['采购日期', '材料名称', '材料类型', '规格', '购买数量', '单价', '总计'];
- return Export::make($row, $json, "包材费");
- }
- }
|