Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers;
- use App\ChildrenPresent;
- use App\DatiLeave;
- use App\Razpiska;
- use App\WorkingDays;
- use Illuminate\Support\Facades\Auth;
- use Session;
- class TaxesController extends Controller
- {
- protected static $doc_no = 9;
- //static protected $secret='4IUCF';
- protected static $secret = 'LLUE';
- // static protected $MIN='07';
- protected static $MIN = '8773';
- protected static $iban = 'BG85BGUS913900';
- protected static $bic = 'BGUSBGSF';
- protected static $merchant = 'Община Плевен';
- protected static $pstatement = 4002;
- public function taxes()
- {
- $records = '';
- $searchdate = date('Ym');
- $m = 1;
- $num = 0;
- $str = '';
- $ccc = ChildrenPresent::
- where('CHILDREN_ID', Auth::user()->CHILDREN_ID)
- ->where(function ($query) {
- $query->WhereNull('PAYMENT_STATUS')
- ->orWhere('PAYMENT_STATUS', 0);
- })
- ->whereNotNull('IZCHISLENA_TAX')
- ->where('IZCHISLENA_TAX', '!=', '0.00')
- ->where('YYYYMM', '<', $searchdate)
- ->get();
- $count = count($ccc);
- $query = ChildrenPresent::
- select('CHILDREN_PRESENT.*', 'NOM_GARDEN.*', 'DATI_LEAVE.*')
- ->join("NOM_GARDEN", "NOM_GARDEN.GARDEN_ID", "=", "CHILDREN_PRESENT.GARDEN_ID")
- ->join('DATI_LEAVE', 'DATI_LEAVE.CHILDREN_ID', '=', 'CHILDREN_PRESENT.CHILDREN_ID')
- ->where('CHILDREN_PRESENT.YYYYMM', '<', $searchdate)
- ->where('CHILDREN_PRESENT.CHILDREN_ID', Auth::user()->CHILDREN_ID)
- ->orderBy('CHILDREN_PRESENT.YYYYMM', 'desc')
- ->orderBy('DATI_LEAVE.DATE_BEG', 'desc')
- ->get();
- $d = array('1' => 'Яну', '2' => 'Фев', '3' => 'Март', '4' => 'Апр', '5' => 'Май', '6' => 'Юни', '7' => 'Юли', '8' => 'Авг', '9' => 'Сеп', '10' => 'Окт', '11' => 'Ное', '12' => 'Дек');
- $taxes = $query;
- if (count($taxes) == 0) {
- $records = '';
- } else {
- foreach ($query as $q) {
- $num++;
- //print_r($q);
- $get_work_days = WorkingDays::
- where('YYYY', date("Y", strtotime($q->YYYYMM . "01")))
- ->where('MM', date("m", strtotime($q->YYYYMM . "01")))
- ->where('GARDEN_ID', $q->GARDEN_ID)
- ->first();
- $work_days = str_split($get_work_days->DAY_STATUS);
- $presence_days = str_split($q->DAY_STATUS);
- $c = array_count_values($presence_days);
- $leaving = DatiLeave::
- where('CHILDREN_ID', Auth::user()->CHILDREN_ID)
- ->where('GARDEN_ID', $q->GARDEN_ID)
- ->get();
- foreach ($leaving as $leave) {
- $l = $leave;
- //$str=$str.count($leave);
- }
- $end = 1;
- foreach ($work_days as $k => $v) {
- if ($v == 1 && $presence_days[$k] == 0 && strtotime($q->YYYYMM . $k) >= strtotime($l->DATE_BEG) && ((strtotime($q->YYYYMM . $k) < strtotime($l->DATE_END)) || $l->DATE_END == '' || $l->DATE_END == 'NULL')) {
- $end = 0;
- }
- }
- if ((count(array_filter($presence_days)) != 1 && count(array_filter($presence_days)) != 0) && ($q->IZCHISLENA_TAX != '0.00' || $q->IZCHISLENA_TAX != 'NULL' || $q->IZCHISLENA_TAX != '')) {
- $records[$num]['garden'] = $q->NAME;
- $records[$num]['month'] = date("m.Y", strtotime($q->YYYYMM . "01"));
- //$str=$str. "<tr><td>".$q->NAME."</td><td>".date("m.Y", strtotime($q->YYYYMM."01"))."</td>";
- $leave = $q->BR_DNI_BOL + $q->BR_DNI_KAR + $q->BR_DNI_DOM + $q->BR_SL_OTS + $q->BR_OTPUSK + $q->BR_DNI_NEIZ;
- $records[$num]['presence'] = $q->BR_DNI_PRI;
- //$str=$str. "<td>".$q->BR_DNI_PRI."</td>";
- $payment = '';
- if (is_null($q->PAYMENT_DATE)) {
- // && ($q->PAYMENT_DATE=="" || $q->PAYMENT_DATE=="NULL")){
- $payment = '';
- } else //if($q->PAYMENT_DATE!='NULL' && $q->PAYMENT_DATE!='')
- {
- //print_r($q);
- $payment_way = Razpiska::where('RAZPISKA_ID', $q->RAZPISKA_ID)->first();
- /* foreach($get_payment_way as $payment_way){
- if($payment_way->PAYMENT_WAY==3)
- $payment=date("d.m.Yг. H:i:s", strtotime($q->PAYMENT_DATE));
- else
- $payment=date("d.m.Yг.", strtotime($q->PAYMENT_DATE));
- }
- * */
- if (isset($payment_way->PAYMENT_WAY) && $payment_way->PAYMENT_WAY == 3) {
- $payment = date("d.m.Yг. H:i:s", strtotime($q->PAYMENT_DATE));
- } else {
- $payment = date("d.m.Yг.", strtotime($q->PAYMENT_DATE));
- }
- // $payment='off';
- }
- $records[$num]['leaving'] = $leave . $str;
- $records[$num]['izchislena_tax'] = number_format($q->IZCHISLENA_TAX, 2);
- $records[$num]['nachislena_tax'] = $q->NACH_TAX;
- $records[$num]['payment_date'] = $payment;
- if ($q->IZCHISLENA_TAX != 'NULL' && $q->IZCHISLENA_TAX != '') {
- if ($end == 0) {
- if (count(array_filter($presence_days)) == 1) {
- $records[$num]['payment'] = "<span class=text-danger>Приключило посещение</span>";
- } else if ($q->NACH_TAX == 'NULL' || $q->NACH_TAX == '') {
- $records[$num]['payment'] = "<span class=text-danger>Несвършил месец</span>";
- $count--;
- } else //$str=$str. "<td><span class=text-succes>Платена</span></td></tr>";
- {
- $records[$num]['payment'] = "<span class=text-info><i class=\"material-icons\">done</i> Платена</span>";
- }
- } else {
- $c = array_count_values($presence_days);
- if (count(array_filter($presence_days)) == 1) {
- $records[$num]['payment'] = "<span class=text-info>Приключило посещение</span>";
- } else if ((($q->PAYMENT_STATUS == 0 || $q->PAYMENT_STATUS == 'NULL') && $q->NACH_TAX == '0.00') || ($q->NACH_TAX == '0.00' && $q->IZCHISLENA_TAX == '0.00')) {
- $records[$num]['payment'] = "<span class=text-info>Платена</span>";
- } else if ($q->PAYMENT_STATUS == 0 || $q->PAYMENT_STATUS == 'NULL') {
- if ($q->IZCHISLENA_TAX != '0.00') {
- if ($m == $count) {
- $records[$num]['payment'] = "<span class=text-succes></span>";
- $content = file_get_contents(Session::get('link') . "EPAY_ZAYVKA?CHILDREN_PRESENT_ID=" . $q->CHILDREN_PRESENT_ID);
- preg_match('#<p id="names">(.*)</p>#', $content, $match);
- $string = str_replace(";", "&", $match[1]);
- parse_str($string);
- if ($ERROR == '') {
- $records[$num]['payment'] = '<form action="checkout" method=post id=epay >
- <input type="hidden" name="_token" value="' . csrf_token() . '" id="_token"/>
- <input type=hidden name=TAX value="' . $IZCHISLENA_TAX . '">
- <input type=hidden name=MIN value="' . $q->MIN . '">
- <input type=hidden name=INVOICE value="' . $INVOICE . '">
- <input type=hidden name=LIHVA value="' . $LIHVA . '">
- <input type=hidden name=month value="' . date("m.Y", strtotime($q->YYYYMM . "01")) . '">
- <input class=" btn btn-primary epay-button " type=submit name=BUTTON:EPAYNOW value="ePay.bg">
- </form>';
- } else {
- $records[$num]['payment'] = "<span class=text-danger>" . iconv('windows-1251', 'utf-8', $ERROR) . "</span>";
- }
- } else {
- $records[$num]['payment'] = "<span class=text-succes></span>";
- $m++;
- }
- } else {
- $records[$num]['payment'] = "<span class=text-warning>Таксата е нула.</span>";
- }
- } else {
- $records[$num]['payment'] = "<i class=\"material-icons\">done</i> <span class=text-success>Платена</span>";
- }
- }
- } else if (($q->PAYMENT_STATUS == 0 || $q->PAYMENT_STATUS == 'NULL') && $q->IZCHISLENA_TAX == 'NULL') {
- $records[$num]['payment'] = "<span class=text-danger>Неизчислена такса</span>";
- }
- } else {
- $count--;
- }
- }
- }
- return view('views.taxes')->with('records', $records);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement