/** * @return mixed */ function periodSchool() { if (userSchool()) { return \AccountHon\Entities\AccountingPeriod::where('school_id', userSchool()->id)->get()->last(); } return false; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!userSchool()) { return redirect('/porcentajes'); } return $next($request); }
public function estadoCuentaAuxiliary($token) { $school = $this->schoolsRepository->whereId('id', userSchool()->id, 'id'); /** @var TYPE_NAME $catalog */ $student = $this->studentRepository->token($token); $seatings = $this->auxiliarySeatRepository->whereDuo('financial_records_id', $student->financialRecords->id, 'status', 'aplicado', 'id', 'ASC'); $headers = array(array($school[0]->name), array('ESTADO DE CUENTA'), array($student->book . ' ' . $student->nameComplete()), array(''), array('Fecha', 'Descripción', 'Referencia', 'Debito', 'Credito')); $content = $headers; $countHeader = count($headers); foreach ($seatings as $seating) { if ($seating->types->name == 'DEBITO') { $content[] = array($seating->date, $seating->detail, $seating->code, $seating->amount, ''); } else { $content[] = array($seating->date, $seating->detail, $seating->code, '', $seating->amount); } } $countContent = count($content); $content[] = array('', 'Fecha de Impresión: ' . date('d-m-Y'), 'Saldo ', $this->saldoEstadoCuentaAuxiliary($student)); $countFooter = count($content); Excel::create(date('d-m-Y') . '-' . $student->nameComplete(), function ($excel) use($student, $content, $countHeader, $countContent, $countFooter) { $excel->sheet($student->book, function ($sheet) use($content, $countHeader, $countContent, $countFooter) { $sheet->mergeCells('A1:E1'); $sheet->mergeCells('A2:E2'); $sheet->mergeCells('A3:E3'); $sheet->cell('A1', function ($cell) { $cell->setFontSize(16); $cell->setFontWeight('bold'); $cell->setAlignment('center'); }); $sheet->cell('A2', function ($cell) { $cell->setFontSize(16); $cell->setFontWeight('bold'); $cell->setAlignment('center'); }); $sheet->cell('A3', function ($cell) { $cell->setFontSize(16); $cell->setFontWeight('bold'); $cell->setAlignment('center'); }); $sheet->cells('A5:E5', function ($cells) { $cells->setFontSize(12); $cells->setFontWeight('bold'); $cells->setAlignment('center'); }); $sheet->cells('A' . $countFooter . ':E' . $countFooter, function ($cells) { $cells->setFontSize(12); $cells->setFontWeight('bold'); $cells->setAlignment('center'); }); $sheet->fromArray($content, null, 'A1', true, false); }); })->export('xlsx'); }
public function report() { $school = $this->schoolsRepository->whereId('id', userSchool()->id, 'id'); $headers = array(array($school[0]->name), array($school[0]->charter), array('Tel.: ' . $school[0]->phoneOne . ' Fax: ' . $school[0]->fax), array('ESTADO DE RESULTADO'), array('MES DE '), array(''), array('INGRESOS: ')); $catalogs = $this->catalogRepository->getModel()->where('id', userSchool()->id)->get(); $content = $headers; foreach ($catalogs as $catalog) { echo json_encode($catalog); if ($catalog->type == '4') { $content[] = array($catalog->code, $catalog->name); } } echo json_encode($content); die; }
public function sumInSchool($column1, $filter1) { return $this->newQuery()->where('school_id', userSchool()->id)->whereIn($column1, $filter1)->sum('amount'); }
public function index() { set_time_limit(0); $student = $this->studentRepository->whereId('school_id', userSchool()->id, 'sex'); $content = array(array(userSchool()->name), array('LISTA DE SALDOS DE ESTUDIANTES'), array('')); $countTotal = array(); $countGrado = array(); $countHeader = count($content); $school = $this->schoolsRepository->getModel()->find(userSchool()->id); foreach ($school->degrees as $degree) { $content[] = array('GRADO: ' . $degree->name); $countGrado[] = count($content); $content[] = array('CARNET', 'NOMBRE ALUMNO', 'SALDO'); $students = $this->financialRecordsRepository->whereId('year', periodSchool()->year, 'updated_at'); $total = 0; foreach ($students as $student) { if ($degree->id == $student->degreeDatos()->id) { $content[] = array($student->students->book, $student->students->nameComplete(), $student->balance); $total += $student->balance; } } $content[] = array('', 'TOTAL', $total); $countTotal[] = count($content); $content[] = array('', '', ''); } Excel::create(date('d-m-Y') . '- Todos los Grados', function ($excel) use($content, $countTotal, $countGrado) { $excel->sheet('Saldos de todos los Alumnos', function ($sheet) use($content, $countTotal, $countGrado) { $sheet->mergeCells('A1:C1'); $sheet->mergeCells('A2:C2'); $sheet->mergeCells('A3:C3'); foreach ($countGrado as $grado) { $sheet->mergeCells('A' . $grado . ':C' . $grado); $sheet->cells('A' . $grado . ':D' . $grado, function ($cells) { $cells->setFontSize(12); $cells->setFontWeight('bold'); $cells->setAlignment('center'); }); $grado = $grado + 1; $sheet->cells('A' . $grado . ':D' . $grado, function ($cells) { $cells->setFontSize(12); $cells->setFontWeight('bold'); $cells->setAlignment('center'); }); } foreach ($countTotal as $total) { $sheet->cells('A' . $total . ':D' . $total, function ($cells) { $cells->setFontSize(12); $cells->setFontWeight('bold'); $cells->setAlignment('center'); }); } $sheet->cell('A1', function ($cell) { $cell->setFontSize(16); $cell->setFontWeight('bold'); $cell->setAlignment('center'); }); $sheet->cell('A2', function ($cell) { $cell->setFontSize(16); $cell->setFontWeight('bold'); $cell->setAlignment('center'); }); $sheet->cell('A3', function ($cell) { $cell->setFontSize(16); $cell->setFontWeight('bold'); $cell->setAlignment('center'); }); $sheet->fromArray($content, null, 'A1', true, false); }); })->export('xlsx'); }
public function index($token) { $seatings = $this->auxiliarySeatRepository->whereDuo('token', $token, 'status', 'aplicado', 'id', 'ASC'); $headers = array(array(userSchool()->name), array('DETALLE DE ASIENTO'), array('Numero de Referencia: ' . $seatings[0]->code), array('Fecha Asiento: ' . $seatings[0]->date . ' PERIODO: ' . $seatings[0]->accountingPeriods->period()), array(''), array('Código', 'Cuenta', 'Debito', 'Credito'), array('Descripción')); $content = $headers; $countHeader = count($headers); $debito = 0; $credito = 0; foreach ($seatings as $seating) { if ($seating->types->name == 'DEBITO') { $debito += $seating->amount; // $credito += $seating->amount; $content[] = array($seating->financialRecords->students->book, $seating->financialRecords->students->nameComplete(), $seating->amount, ''); $content[] = array($seating->detail); } else { // $debito += $seating->amount; $credito += $seating->amount; $content[] = array($seating->financialRecords->students->book, $seating->financialRecords->students->nameComplete(), '', $seating->amount); $content[] = array($seating->detail); } } $controlDebito = $debito; $content[] = array('00-00000', 'Control Alumno', $credito, $debito); $content[] = array($seating->detail); $controlCredito = $credito; $controlCredito = $controlCredito + $debito; $controlDebito = $controlDebito + $credito; $countContent = count($content); $content[] = array('Fecha de Impresión: ' . date('d-m-Y'), 'Total de Asiento ', $controlDebito, $controlCredito); $countFooter = count($content); Excel::create(date('d-m-Y') . '-' . $seatings[0]->code, function ($excel) use($seatings, $content, $countHeader, $countContent, $countFooter) { $excel->sheet($seatings[0]->code, function ($sheet) use($content, $countHeader, $countContent, $countFooter) { $sheet->mergeCells('A1:D1'); $sheet->mergeCells('A2:D2'); $sheet->mergeCells('A3:D3'); $sheet->mergeCells('A4:D4'); $sheet->mergeCells('A7:B7'); $sheet->cell('A1', function ($cell) { $cell->setFontSize(16); $cell->setFontWeight('bold'); $cell->setAlignment('center'); }); $sheet->cell('A2', function ($cell) { $cell->setFontSize(16); $cell->setFontWeight('bold'); $cell->setAlignment('center'); }); $sheet->cell('A3', function ($cell) { $cell->setFontSize(16); $cell->setFontWeight('bold'); $cell->setAlignment('center'); }); $sheet->cell('A4', function ($cell) { $cell->setFontSize(16); $cell->setFontWeight('bold'); $cell->setAlignment('center'); }); $sheet->cells('A6:D6', function ($cells) { $cells->setFontSize(12); $cells->setFontWeight('bold'); $cells->setAlignment('center'); }); $sheet->cells('A7:D7', function ($cells) { $cells->setFontSize(12); $cells->setFontWeight('bold'); $cells->setAlignment('center'); }); $sheet->cells('A' . $countFooter . ':D' . $countFooter, function ($cells) { $cells->setFontSize(12); $cells->setFontWeight('bold'); $cells->setAlignment('center'); }); $sheet->fromArray($content, null, 'A1', true, false); }); })->export('xlsx'); }
public function report() { $content = array(array(userSchool()->name), array('BALANCE DE COMPROBACIÓN'), array(''), array('CODIGO', 'NOMBRE DE CUENTA', 'SALDO INICIAL', 'DEBITO PERIODO', 'CREDITO PERIODO', 'BALANCE FINAL')); $countHeader = count($content); }
public function report($rangePeriods) { set_time_limit(0); //$rangePeriods = $this->convertionObjeto(); $range = explode('-', $rangePeriods); $periodInitial = $range[0]; $periodFinal = $range[1]; $periods = $this->accountingPeriodRepository->listsRange(array($periodInitial, $periodFinal), 'period', 'id'); $catalogs = $this->catalogRepository->getModel()->where('style', 'Detalle')->where('school_id', userSchool()->id)->orderBy('code', 'ASC')->get(); $content = array(array(userSchool()->name), array('BALANCE DE COMPROBACIÓN'), array(''), array('CODIGO', 'NOMBRE DE CUENTA', 'SALDO INICIAL', 'DEBITO PERIODO', 'CREDITO PERIODO', 'BALANCE FINAL')); $countHeader = count($content); $inicial = 0; $Tinicial = 0; $debito = 0; $Tdebito = 0; $credito = 0; $Tcredito = 0; $balance = 0; $Tbalance = 0; foreach ($catalogs as $catalog) { $inicial = $this->saldoInicialCatalog($catalog->id, $periodInitial); $debito = $this->saldoPeriod($catalog->id, $periods, 'DEBITO'); $credito = $this->saldoPeriod($catalog->id, $periods, 'CREDITO'); $balance = $inicial + $debito - $credito; $Tinicial += $inicial; $Tdebito += $debito; $Tcredito += $credito; $Tbalance += $balance; /* if($balance>0): $balance =$balance; else: $balance= -0-$balance; $balance= $balance.' cr'; endif;*/ $content[] = array($catalog->code, $catalog->name, $this->saldoInicialCatalog($catalog->id, $periodInitial), $debito, $credito, $balance); } $countContent = count($content); $content[] = array('', 'TOTAL', $Tinicial, $Tdebito, $Tcredito, $Tbalance); $countFooter = count($content); Excel::create(date('d-m-Y') . '- Balance Comprobación', function ($excel) use($catalog, $content, $countHeader, $countContent, $countFooter) { $excel->sheet('Balance Comprobación', function ($sheet) use($content, $countHeader, $countContent, $countFooter) { $sheet->mergeCells('A1:F1'); $sheet->mergeCells('A2:F2'); $sheet->mergeCells('A3:F3'); $sheet->cell('A1', function ($cell) { $cell->setFontSize(16); $cell->setFontWeight('bold'); $cell->setAlignment('center'); }); $sheet->cell('A2', function ($cell) { $cell->setFontSize(16); $cell->setFontWeight('bold'); $cell->setAlignment('center'); }); $sheet->cell('A3', function ($cell) { $cell->setFontSize(16); $cell->setFontWeight('bold'); $cell->setAlignment('center'); }); $sheet->cells('A' . $countHeader . ':F' . $countHeader, function ($cells) { $cells->setFontSize(12); $cells->setFontWeight('bold'); $cells->setAlignment('center'); }); $sheet->cells('A' . $countFooter . ':F' . $countFooter, function ($cells) { $cells->setFontSize(12); $cells->setFontWeight('bold'); $cells->setAlignment('center'); }); $sheet->fromArray($content, null, 'A1', true, false); }); })->export('xlsx'); }
/** * @param $token */ public function estadoCuenta($token) { echo json_encode($token); die; $school = $this->schoolsRepository->whereId('id', userSchool()->id, 'id'); /** @var TYPE_NAME $catalog */ $catalog = $this->catalogRepository->token($token); $seatings = $this->seatingRepository->whereDuo('catalog_id', $catalog->id, 'status', 'aplicado', 'id', 'ASC'); $headers = array(array($school[0]->name), array('ESTADO DE CUENTA'), array($catalog->code . ' ' . $catalog->name), array(''), array('Fecha', 'Descripción', 'Referencia', 'Debito', 'Credito')); $content = $headers; $countHeader = count($headers); foreach ($seatings as $seating) { $seatingParts = $this->seatingPartRepository->getModel()->where('seating_id', $seating->id)->get(); echo json_encode($seatingParts); die; if ($seating->types->name == 'DEBITO') { $content[] = array($seating->date, $seating->detail, $seating->code, $seating->amount, ''); } else { $content[] = array($seating->date, $seating->detail, $seating->code, '', $seating->amount); } foreach ($seatingParts as $seatingPart) { if ($seating->types->name == 'DEBITO') { $content[] = array($seatingPart[]->date, $seatingPart->detail, $seatingPart->code, '', $seatingPart->amount); } else { $content[] = array($seatingPart->date, $seatingPart->detail, $seatingPart->code, $seatingPart->amount, ''); } } } $countContent = count($content); $content[] = array('', 'Fecha de Impresión: ' . date('d-m-Y'), 'Saldo ', $this->saldoEstadoCuenta($catalog)); $countFooter = count($content); // Excel::create(date('d-m-Y') . '-' . $catalog->name, function ($excel) use($catalog, $content, $countHeader, $countContent, $countFooter) { $excel->sheet($catalog->code, function ($sheet) use($content, $countHeader, $countContent, $countFooter) { $sheet->mergeCells('A1:E1'); $sheet->mergeCells('A2:E2'); $sheet->mergeCells('A3:E3'); $sheet->mergeCells('D' . $countFooter . ':E' . $countFooter); $sheet->cell('A1', function ($cell) { $cell->setFontSize(16); $cell->setFontWeight('bold'); $cell->setAlignment('center'); }); $sheet->cell('A2', function ($cell) { $cell->setFontSize(16); $cell->setFontWeight('bold'); $cell->setAlignment('center'); }); $sheet->cell('A3', function ($cell) { $cell->setFontSize(16); $cell->setFontWeight('bold'); $cell->setAlignment('center'); }); $sheet->cells('A5:E5', function ($cells) { $cells->setFontSize(12); $cells->setFontWeight('bold'); $cells->setAlignment('center'); }); $sheet->cells('A' . $countFooter . ':E' . $countFooter, function ($cells) { $cells->setFontSize(12); $cells->setFontWeight('bold'); $cells->setAlignment('center'); }); $sheet->fromArray($content, null, 'A1', true, false); }); })->export('xlsx'); }