Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.78 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers;
  4.  
  5. use App\Services\EnergyAccountingTableService;
  6. use Illuminate\Http\Request;
  7. use Illuminate\Routing\Controller;
  8. use App\Counter;
  9. use App\InfoCounter;
  10. use App\EnergyAccountingTable;
  11. use App\ReportingDate;
  12. use App\Accruals;
  13. use App\DopAkti;
  14. use \App\DopPu;
  15. use \App\DopSredn;
  16. use \App\DopNormativ;
  17. use \App\DopProchee;
  18.  
  19. class EnergyAccounting extends Controller
  20. {
  21.  
  22. protected $energyAccountingTableService;
  23.  
  24. /**
  25. * EnergyAccounting constructor.
  26. * @param EnergyAccountingTableService $energyAccountingTableService
  27. */
  28. public function __construct(
  29. EnergyAccountingTableService $energyAccountingTableService)
  30. {
  31. $this->energyAccountingTableService = $energyAccountingTableService;
  32. }
  33.  
  34. public function getEnergyAccounting()
  35. {
  36.  
  37. $adress = Counter::getAdress($_GET['idcounter']);
  38. $consumer = Counter::getConsumer($_GET['idcounter']);
  39. $infocounter = InfoCounter::getInfoCounter($_GET['idcounter']);
  40. $counter = Counter::where('idcounter', '=', $_GET['idcounter'])->get();
  41.  
  42.  
  43. $arrfoto = \App\Http\Controllers\UploadFiles::getArrayFiles($_GET['idcounter']);
  44.  
  45. return view('energyAccounting',
  46. [
  47. 'adress' => $adress,
  48. 'counter' => $counter[0],
  49. 'infocounter' => $infocounter,
  50. 'consumer' => $consumer,
  51. 'arrfoto' => $arrfoto
  52. ]);
  53.  
  54.  
  55. }
  56.  
  57.  
  58. /**
  59. * @param Request $request
  60. * @return \Illuminate\Http\JsonResponse
  61. */
  62. public function getEnergyAccountingTable(Request $request)
  63. {
  64. $dataTables = $this->energyAccountingTableService->getTable($request->idcounter);
  65. return response()->json($dataTables);
  66. }
  67.  
  68. /**
  69. * @param Request $request
  70. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  71. */
  72. public function getEnergyAccountingInfo(Request $request)
  73. {
  74. $infocounter = InfoCounter::getInfoCounter($request->idcounter);
  75.  
  76. return view('modalCounterInfo',
  77. [
  78. 'infocounter' => $infocounter
  79. ]);
  80. }
  81.  
  82. // @TODO сделать обновление информации в модель
  83. public function postEnergyAccountingInfoUpdate(Request $request)
  84. {
  85. if (!$_POST['idinfocounter'] == '') {
  86.  
  87. $infocounter = InfoCounter::find($_POST['idinfocounter']);
  88.  
  89. } else {
  90. $infocounter = new InfoCounter();
  91. }
  92. $infocounter->counterid = $_POST['idcounter'];
  93. $infocounter->tip = $_POST['tip'];
  94. $infocounter->znak = $_POST['znak'];
  95. $infocounter->klasstochnosti = $_POST['klasstochnosti'];
  96. $infocounter->godvipuska = $_POST['godvipuska'];
  97. $infocounter->gos_poverka = new \DateTime($_POST['gos_poverka']);
  98. $infocounter->amperi = $_POST['amperi'];
  99. $infocounter->plomba = $_POST['plomba'];
  100. $infocounter->primechanie = $_POST['primechanie'];
  101. $infocounter->telefon = $_POST['telefon'];
  102. $infocounter->primechaniecounter = $_POST['primechaniecounter'];
  103. $infocounter->soglasie = $_POST['soglasie'];
  104. $infocounter->komnati = $_POST['komnati'];
  105. $infocounter->datampi = $_POST['datampi'];
  106. echo $infocounter->save();
  107.  
  108.  
  109. }
  110.  
  111. public function getEnergyAccountingPeriod()
  112. {
  113. $counter = Counter::find($_GET['idcounter']);
  114. $arrSelectDateStart = ReportingDate::SelectDateDesc();
  115. $arrSelectDateFinish = ReportingDate::SelectDateDesc();
  116.  
  117. return view('modalCounterPeriod',
  118. [
  119. 'idcounter' => $counter->idcounter,
  120. 'start' => $counter->start,
  121. 'finish' => $counter->finish,
  122. 'arrSelectDateStart' => $arrSelectDateStart,
  123. 'arrSelectDateFinish' => $arrSelectDateFinish,
  124. ]);
  125. }
  126.  
  127. public function postEnergyAccountingPeriodUpdate()
  128. {
  129. if (isset($_POST['idcounter'])){
  130.  
  131. $counter = Counter::find($_POST['idcounter']);
  132. $counter->start = $_POST['DateStart'];
  133. if ($_POST['DateFinish'] != 0){
  134. $counter->finish = $_POST['DateFinish'];
  135. }
  136. else{
  137. $counter->finish = '2099-01-01';
  138. }
  139. echo $counter->save();
  140. }
  141. }
  142.  
  143.  
  144. public function postEnergyAccountingOff()
  145. {
  146.  
  147. $info = Counter::find($_POST['idcounter']);
  148. $info->onCounter = $_POST['onCounter'];
  149. $info->save();
  150.  
  151. }
  152.  
  153.  
  154. public function getEnergyAccountingAccruals()
  155. {
  156.  
  157. $iddate = ReportingDate::idDate($_GET['daterealiz']);
  158. $summ = Accruals::getSummAccruals($iddate,$_GET['idcounter']);
  159. $DopAkti = DopAkti::findByAccDateCounter($iddate, $_GET['idcounter']);
  160.  
  161. return view('modalCounterAccruals',
  162. [
  163. 'summ' => $summ,
  164. 'dopAkti' => $DopAkti,
  165. 'iddate' => $iddate,
  166. 'idcounter' => $_GET['idcounter']
  167. ]);
  168.  
  169.  
  170. }
  171.  
  172. public function postEnergyAccountingAccrualsUpdate(Request $request)
  173. {
  174.  
  175. if ($request->has('doppu')) {
  176. if ($request->input('doppu') != ''){
  177. DopPu::accrualsUpdate($request->iddate, $request->idcounter,$request->input('doppu'));
  178. }
  179. else{
  180. DopPu::accrualsDel($request->iddate, $request->idcounter);
  181. }
  182. }
  183. if ($request->has('dopsredn')) {
  184. if ($request->input('dopsredn') != '') {
  185. DopSredn::accrualsUpdate($request->iddate, $request->idcounter, $request->input('dopsredn'));
  186. }
  187. else{
  188. DopSredn::accrualsDel($request->iddate, $request->idcounter);
  189. }
  190. }
  191. if ($request->has('dopnormativ')) {
  192. if ($request->input('dopnormativ') != '') {
  193. DopNormativ::accrualsUpdate($request->iddate, $request->idcounter, $request->input('dopnormativ'));
  194. }
  195. else{
  196. DopNormativ::accrualsDel($request->iddate, $request->idcounter);
  197. }
  198. }
  199. if ($request->has('dopprochee')) {
  200. if ($request->input('dopprochee') != '') {
  201. DopProchee::accrualsUpdate($request->iddate, $request->idcounter, $request->input('dopprochee'));
  202. }
  203. else{
  204. DopProchee::accrualsDel($request->iddate, $request->idcounter);
  205. }
  206. }
  207. if ($request->has('dopakti')) {
  208. if ($request->input('dopakti') != '') {
  209. DopAkti::accrualsUpdate($request->iddate, $request->idcounter, $request->input('dopakti'));
  210. }
  211. else{
  212. DopAkti::accrualsDel($request->iddate, $request->idcounter);
  213. }
  214. }
  215.  
  216. echo true;
  217. }
  218.  
  219.  
  220. public function getCounterShift()
  221. {
  222. $counter = Counter::find($_GET['idcounter']);
  223. $consumers = \App\Consumer::getConsumerInCity($_GET['idgorod']);
  224. $idconsumer = $counter->consumer;
  225. return view('modalCounterShift',
  226. [
  227. 'consumers' => $consumers,
  228. 'idconsumer' => $idconsumer[0]->idvladelec,
  229. 'counter' => $counter
  230.  
  231. ]);
  232. }
  233.  
  234. public function postToStartShift (Request $request){
  235. \App\Counter::shiftCounter($request->idcounter,$request->idconsumer);
  236. echo 'true';
  237. }
  238.  
  239. public function postDelCounter(Request $request){
  240.  
  241. \App\Counter::destroy($request->id);
  242.  
  243. return redirect()->route('cityStreetList',['idgorod' => $request->idgorod, 'arrStreet' => $request->arrStreet]);
  244.  
  245. }
  246.  
  247. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement