Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers;
- use App\Services\EnergyAccountingTableService;
- use Illuminate\Http\Request;
- use Illuminate\Routing\Controller;
- use App\Counter;
- use App\InfoCounter;
- use App\EnergyAccountingTable;
- use App\ReportingDate;
- use App\Accruals;
- use App\DopAkti;
- use \App\DopPu;
- use \App\DopSredn;
- use \App\DopNormativ;
- use \App\DopProchee;
- class EnergyAccounting extends Controller
- {
- protected $energyAccountingTableService;
- /**
- * EnergyAccounting constructor.
- * @param EnergyAccountingTableService $energyAccountingTableService
- */
- public function __construct(
- EnergyAccountingTableService $energyAccountingTableService)
- {
- $this->energyAccountingTableService = $energyAccountingTableService;
- }
- public function getEnergyAccounting()
- {
- $adress = Counter::getAdress($_GET['idcounter']);
- $consumer = Counter::getConsumer($_GET['idcounter']);
- $infocounter = InfoCounter::getInfoCounter($_GET['idcounter']);
- $counter = Counter::where('idcounter', '=', $_GET['idcounter'])->get();
- $arrfoto = \App\Http\Controllers\UploadFiles::getArrayFiles($_GET['idcounter']);
- return view('energyAccounting',
- [
- 'adress' => $adress,
- 'counter' => $counter[0],
- 'infocounter' => $infocounter,
- 'consumer' => $consumer,
- 'arrfoto' => $arrfoto
- ]);
- }
- /**
- * @param Request $request
- * @return \Illuminate\Http\JsonResponse
- */
- public function getEnergyAccountingTable(Request $request)
- {
- $dataTables = $this->energyAccountingTableService->getTable($request->idcounter);
- return response()->json($dataTables);
- }
- /**
- * @param Request $request
- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
- */
- public function getEnergyAccountingInfo(Request $request)
- {
- $infocounter = InfoCounter::getInfoCounter($request->idcounter);
- return view('modalCounterInfo',
- [
- 'infocounter' => $infocounter
- ]);
- }
- // @TODO сделать обновление информации в модель
- public function postEnergyAccountingInfoUpdate(Request $request)
- {
- if (!$_POST['idinfocounter'] == '') {
- $infocounter = InfoCounter::find($_POST['idinfocounter']);
- } else {
- $infocounter = new InfoCounter();
- }
- $infocounter->counterid = $_POST['idcounter'];
- $infocounter->tip = $_POST['tip'];
- $infocounter->znak = $_POST['znak'];
- $infocounter->klasstochnosti = $_POST['klasstochnosti'];
- $infocounter->godvipuska = $_POST['godvipuska'];
- $infocounter->gos_poverka = new \DateTime($_POST['gos_poverka']);
- $infocounter->amperi = $_POST['amperi'];
- $infocounter->plomba = $_POST['plomba'];
- $infocounter->primechanie = $_POST['primechanie'];
- $infocounter->telefon = $_POST['telefon'];
- $infocounter->primechaniecounter = $_POST['primechaniecounter'];
- $infocounter->soglasie = $_POST['soglasie'];
- $infocounter->komnati = $_POST['komnati'];
- $infocounter->datampi = $_POST['datampi'];
- echo $infocounter->save();
- }
- public function getEnergyAccountingPeriod()
- {
- $counter = Counter::find($_GET['idcounter']);
- $arrSelectDateStart = ReportingDate::SelectDateDesc();
- $arrSelectDateFinish = ReportingDate::SelectDateDesc();
- return view('modalCounterPeriod',
- [
- 'idcounter' => $counter->idcounter,
- 'start' => $counter->start,
- 'finish' => $counter->finish,
- 'arrSelectDateStart' => $arrSelectDateStart,
- 'arrSelectDateFinish' => $arrSelectDateFinish,
- ]);
- }
- public function postEnergyAccountingPeriodUpdate()
- {
- if (isset($_POST['idcounter'])){
- $counter = Counter::find($_POST['idcounter']);
- $counter->start = $_POST['DateStart'];
- if ($_POST['DateFinish'] != 0){
- $counter->finish = $_POST['DateFinish'];
- }
- else{
- $counter->finish = '2099-01-01';
- }
- echo $counter->save();
- }
- }
- public function postEnergyAccountingOff()
- {
- $info = Counter::find($_POST['idcounter']);
- $info->onCounter = $_POST['onCounter'];
- $info->save();
- }
- public function getEnergyAccountingAccruals()
- {
- $iddate = ReportingDate::idDate($_GET['daterealiz']);
- $summ = Accruals::getSummAccruals($iddate,$_GET['idcounter']);
- $DopAkti = DopAkti::findByAccDateCounter($iddate, $_GET['idcounter']);
- return view('modalCounterAccruals',
- [
- 'summ' => $summ,
- 'dopAkti' => $DopAkti,
- 'iddate' => $iddate,
- 'idcounter' => $_GET['idcounter']
- ]);
- }
- public function postEnergyAccountingAccrualsUpdate(Request $request)
- {
- if ($request->has('doppu')) {
- if ($request->input('doppu') != ''){
- DopPu::accrualsUpdate($request->iddate, $request->idcounter,$request->input('doppu'));
- }
- else{
- DopPu::accrualsDel($request->iddate, $request->idcounter);
- }
- }
- if ($request->has('dopsredn')) {
- if ($request->input('dopsredn') != '') {
- DopSredn::accrualsUpdate($request->iddate, $request->idcounter, $request->input('dopsredn'));
- }
- else{
- DopSredn::accrualsDel($request->iddate, $request->idcounter);
- }
- }
- if ($request->has('dopnormativ')) {
- if ($request->input('dopnormativ') != '') {
- DopNormativ::accrualsUpdate($request->iddate, $request->idcounter, $request->input('dopnormativ'));
- }
- else{
- DopNormativ::accrualsDel($request->iddate, $request->idcounter);
- }
- }
- if ($request->has('dopprochee')) {
- if ($request->input('dopprochee') != '') {
- DopProchee::accrualsUpdate($request->iddate, $request->idcounter, $request->input('dopprochee'));
- }
- else{
- DopProchee::accrualsDel($request->iddate, $request->idcounter);
- }
- }
- if ($request->has('dopakti')) {
- if ($request->input('dopakti') != '') {
- DopAkti::accrualsUpdate($request->iddate, $request->idcounter, $request->input('dopakti'));
- }
- else{
- DopAkti::accrualsDel($request->iddate, $request->idcounter);
- }
- }
- echo true;
- }
- public function getCounterShift()
- {
- $counter = Counter::find($_GET['idcounter']);
- $consumers = \App\Consumer::getConsumerInCity($_GET['idgorod']);
- $idconsumer = $counter->consumer;
- return view('modalCounterShift',
- [
- 'consumers' => $consumers,
- 'idconsumer' => $idconsumer[0]->idvladelec,
- 'counter' => $counter
- ]);
- }
- public function postToStartShift (Request $request){
- \App\Counter::shiftCounter($request->idcounter,$request->idconsumer);
- echo 'true';
- }
- public function postDelCounter(Request $request){
- \App\Counter::destroy($request->id);
- return redirect()->route('cityStreetList',['idgorod' => $request->idgorod, 'arrStreet' => $request->arrStreet]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement