public function getWeeklyHours($employee_id, $weeks_back = 5) { $weekly_hours = []; $current_week_number = date('W'); $current_year_number = date('Y'); //get array of [week_start, week_end, hours], account for breaks for ($i = $weeks_back - 1; $i >= 0; $i--) { $week_number = $current_week_number - $i; $week_dates = getStartAndEndDate($week_number, $current_year_number); $query = <<<SQL SELECT ROUND(SUM(TIMESTAMPDIFF(SECOND,start_time,end_time)/3600), 2) AS hours FROM shift WHERE employee_id = 1 AND start_time >= '{$week_dates['week_start']}' AND start_time <= '{$week_dates['week_end']}'; SQL; $result = $this->query($query)->first(); $week_hours['week_start'] = date(\DateTime::RFC2822, strtotime($week_dates['week_start'])); $week_hours['week_end'] = date(\DateTime::RFC2822, strtotime($week_dates['week_end'])); $week_hours['hours'] = empty($result->hours) ? 0 : $result->hours; $weekly_hours[] = $week_hours; } return $weekly_hours; }
public function shu() { if ($this->session->userdata('logged_in')) { $total_branch = $this->branch_model->count_branch(); //Cek User Branch $user_branch = $this->session->userdata('user_branch'); if ($user_branch == "0") { $user_branch = NULL; } function getStartAndEndDate($week, $year) { $time = strtotime("1 January {$year}", time()); $day = date('w', $time); $time += (7 * $week + 1 - $day) * 24 * 3600; $return[0] = date('Y-n-j', $time); $time += 6 * 24 * 3600; $return[1] = date('Y-n-j', $time); return $return; } $date_today = date("Y-m-d"); $date_year_today = date("Y"); $date_week_today = date("W", strtotime($date_today)) - 1; $date_week_before = $date_week_today - 1; $week_today = getStartAndEndDate($date_week_today, $date_year_today); $date_start = $this->input->post('date_start'); $date_end = $this->input->post('date_end'); if ($date_start and $date_end and $date_start <= $date_end) { $date_start = $this->input->post('date_start'); $date_end = $this->input->post('date_end'); } else { //$date_start =$week_today[0]; $date_start = "2015-01-01"; $date_end = date("Y-m-d"); } $date_end_before = strtotime($date_start); //$date_end_before = $date_start; $date_end_before = strtotime("-1 day", $date_end_before); $date_end_before = date('Y-m-d', $date_end_before); $date_start_before = "2014-01-01"; //echo $date_start_before." ----- ".$date_end_before; $account_debet = 0; $account_credit = 0; $account_saldo = 0; $saldo_awal = 0; //PENDAPATAN $print .= ' <tr><td align="left" ><b>Pendapatan</b></td> <td colspan="' . $colspan . '" ></td></tr>'; //4010000 Pendapatan Pembiayaan $code = "4010000"; $code_level1 = substr($code, 0, 3); for ($branch = 0; $branch <= $total_branch; $branch++) { $account_4010000_debet[$branch] = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $branch); $account_4010000_credit[$branch] = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $branch); $account_4010000[$branch] = $account_4010000_credit[$branch] - $account_4010000_debet[$branch]; $account_4010000_total += $account_4010000[$branch]; $account_pendapatan_total[$branch] += $account_4010000[$branch]; } $print .= ' <tr><td align="left" > Pendapatan Pembiayaan</td>'; $print .= ' <td align="right" class="">' . ($account_4010000_total < 0 ? "(" . number_format(abs($account_4010000_total)) . ")" : number_format($account_4010000_total)) . '</td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">' . ($account_4010000[$branch] < 0 ? "(" . number_format(abs($account_4010000[$branch])) . ")" : number_format($account_4010000[$branch])) . '</td>'; } $print .= '</tr>'; //4020000 Pendapatan Jasa Administrasi $code = "4020000"; $code_level1 = substr($code, 0, 3); for ($branch = 0; $branch <= $total_branch; $branch++) { $account_4020000_debet[$branch] = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $branch); $account_4020000_credit[$branch] = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $branch); $account_4020000[$branch] = $account_4020000_credit[$branch] - $account_4020000_debet[$branch]; $account_4020000_total += $account_4020000[$branch]; $account_pendapatan_total[$branch] += $account_4020000[$branch]; } $print .= ' <tr><td align="left" > Pendapatan Administrasi</td>'; $print .= ' <td align="right" class="border_btm">' . ($account_4020000_total < 0 ? "(" . number_format(abs($account_4020000_total)) . ")" : number_format($account_4020000_total)) . '</td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="border_btm">' . ($account_4020000[$branch] < 0 ? "(" . number_format(abs($account_4020000[$branch])) . ")" : number_format($account_4020000[$branch])) . '</td>'; } $print .= '</tr>'; //Jumlah Pendapatan $account_pendapatan_konsolidasi = $account_4010000_total + $account_4020000_total; $print .= ' <tr><td align="left" >Total Pendapatan</td>'; $print .= ' <td align="right" class="border_btm">' . ($account_pendapatan_konsolidasi < 0 ? "(" . number_format(abs($account_pendapatan_konsolidasi)) . ")" : number_format($account_pendapatan_konsolidasi)) . '</td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="border_btm">' . ($account_pendapatan_total[$branch] < 0 ? "(" . number_format(abs($account_pendapatan_total[$branch])) . ")" : number_format($account_pendapatan_total[$branch])) . '</td>'; } $print .= ' </tr>'; //--------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------- $print .= ' <tr><td align="left" colspan="' . $colspan2 . '"> </td></tr>'; $print .= ' <tr><td align="left" ><b>Beban Pembiayaan</b></td> <td colspan="' . $colspan . '" ></td></tr>'; //--------------------------------------------------------------------------------------------- //BEBAN OPERASI //--------------------------------------------------------------------------------------------- $print .= ' <tr><td align="left" colspan="' . $colspan2 . '"> </td></tr>'; $print .= ' <tr><td align="left" ><b>Biaya Operasi</b></td> <td colspan="' . $colspan . '" ></td></tr>'; //Beban Lainnya: 5030101, 5030102, 5030103, 5030104, 5030105, 5030106, 5030108, 5030109, 5030110, 5030111, 5030112, 5030113, 5030114 $code = "5030101"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5030101_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5030101_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5030101[$branch] = $account_5030101_debet[$branch] - $account_5030101_credit[$branch]; $account_5030101_total += $account_5030101[$branch]; $account_beban_gaji_total[$branch] += $account_5030101[$branch]; $account_beban_operasi_total[$branch] += $account_5030101[$branch]; } $code = "5030102"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5030102_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5030102_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5030102[$branch] = $account_5030102_debet[$branch] - $account_5030102_credit[$branch]; $account_5030102_total += $account_5030102[$branch]; $account_beban_gaji_total[$branch] += $account_5030102[$branch]; $account_beban_operasi_total[$branch] += $account_5030102[$branch]; } $code = "5030103"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5030103_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5030103_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5030103[$branch] = $account_5030103_debet[$branch] - $account_5030103_credit[$branch]; $account_5030103_total += $account_5030103[$branch]; $account_beban_gaji_total[$branch] += $account_5030103[$branch]; $account_beban_operasi_total[$branch] += $account_5030103[$branch]; } $code = "5030104"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5030104_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5030104_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5030104[$branch] = $account_5030104_debet[$branch] - $account_5030104_credit[$branch]; $account_5030104_total += $account_5030104[$branch]; $account_beban_gaji_total[$branch] += $account_5030104[$branch]; $account_beban_operasi_total[$branch] += $account_5030104[$branch]; } $code = "5030105"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5030105_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5030105_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5030105[$branch] = $account_5030105_debet[$branch] - $account_5030105_credit[$branch]; $account_5030105_total += $account_5030105[$branch]; $account_beban_gaji_total[$branch] += $account_5030105[$branch]; $account_beban_operasi_total[$branch] += $account_5030105[$branch]; } $code = "5030106"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5030106_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5030106_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5030106[$branch] = $account_5030106_debet[$branch] - $account_5030106_credit[$branch]; $account_5030106_total += $account_5030106[$branch]; $account_beban_gaji_total[$branch] += $account_5030106[$branch]; $account_beban_operasi_total[$branch] += $account_5030106[$branch]; } $code = "5030108"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5030108_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5030108_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5030108[$branch] = $account_5030108_debet[$branch] - $account_5030108_credit[$branch]; $account_5030108_total += $account_5030108[$branch]; $account_beban_gaji_total[$branch] += $account_5030108[$branch]; $account_beban_operasi_total[$branch] += $account_5030108[$branch]; } $code = "5030109"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5030109_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5030109_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5030109[$branch] = $account_5030109_debet[$branch] - $account_5030109_credit[$branch]; $account_5030109_total += $account_5030109[$branch]; $account_beban_gaji_total[$branch] += $account_5030109[$branch]; $account_beban_operasi_total[$branch] += $account_5030109[$branch]; } $code = "5030110"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5030110_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5030110_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5030110[$branch] = $account_5030110_debet[$branch] - $account_5030110_credit[$branch]; $account_5030110_total += $account_5030110[$branch]; $account_beban_gaji_total[$branch] += $account_5030110[$branch]; $account_beban_operasi_total[$branch] += $account_5030110[$branch]; } $code = "5030111"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5030111_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5030111_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5030111[$branch] = $account_5030111_debet[$branch] - $account_5030111_credit[$branch]; $account_5030111_total += $account_5030111[$branch]; $account_beban_gaji_total[$branch] += $account_5030111[$branch]; $account_beban_operasi_total[$branch] += $account_5030111[$branch]; } $code = "5030112"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5030112_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5030112_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5030112[$branch] = $account_5030112_debet[$branch] - $account_5030112_credit[$branch]; $account_5030112_total += $account_5030112[$branch]; $account_beban_gaji_total[$branch] += $account_5030112[$branch]; $account_beban_operasi_total[$branch] += $account_5030112[$branch]; } $code = "5030113"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5030113_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5030113_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5030113[$branch] = $account_5030113_debet[$branch] - $account_5030113_credit[$branch]; $account_5030113_total += $account_5030113[$branch]; $account_beban_gaji_total[$branch] += $account_5030113[$branch]; $account_beban_operasi_total[$branch] += $account_5030113[$branch]; } $code = "5030114"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5030114_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5030114_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5030114[$branch] = $account_5030114_debet[$branch] - $account_5030114_credit[$branch]; $account_5030114_total += $account_5030114[$branch]; $account_beban_gaji_total[$branch] += $account_5030114[$branch]; $account_beban_operasi_total[$branch] += $account_5030114[$branch]; } $account_beban_gaji_konsolidasi = $account_5030101_total + $account_5030102_total + $account_5030103_total + $account_5030104_total + $account_5030105_total + $account_5030106_total + $account_5030108_total + $account_5030109_total + $account_5030110_total + $account_5030111_total + $account_5030112_total + $account_5030113_total + $account_5030114_total; $print .= ' <tr><td align="left" > Beban Gaji & Honor</td>'; $print .= ' <td align="right" class="">' . ($account_beban_gaji_konsolidasi < 0 ? "(" . number_format(abs($account_beban_gaji_konsolidasi)) . ")" : number_format($account_beban_gaji_konsolidasi)) . '</td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">' . ($account_beban_gaji_total[$branch] < 0 ? "(" . number_format(abs($account_beban_gaji_total[$branch])) . ")" : number_format($account_beban_gaji_total[$branch])) . '</td>'; } $print .= '</tr>'; //5080404 Beban Asuransi Jiwa $code = "5080404"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080404_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080404_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080404[$branch] = $account_5080404_debet[$branch] - $account_5080404_credit[$branch]; $account_5080404_total += $account_5080404[$branch]; $account_beban_operasi_total[$branch] += $account_5080404[$branch]; } $print .= ' <tr><td align="left" > Beban Asuransi Jiwa</td>'; $print .= ' <td align="right" class="">' . ($account_5080404_total < 0 ? "(" . number_format(abs($account_5080404_total)) . ")" : number_format($account_5080404_total)) . '</td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">' . ($account_5080404[$branch] < 0 ? "(" . number_format(abs($account_5080404[$branch])) . ")" : number_format($account_5080404[$branch])) . '</td>'; } $print .= '</tr>'; //5040003 Beban Rekrutmen $code = "5040003"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5040003_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5040003_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5040003[$branch] = $account_5040003_debet[$branch] - $account_5040003_credit[$branch]; $account_5040003_total += $account_5040003[$branch]; $account_beban_operasi_total[$branch] += $account_5040003[$branch]; } $print .= ' <tr><td align="left" > Beban Rekrutmen</td>'; $print .= ' <td align="right" class="">' . ($account_5040003_total < 0 ? "(" . number_format(abs($account_5040003_total)) . ")" : number_format($account_5040003_total)) . '</td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">' . ($account_5040003[$branch] < 0 ? "(" . number_format(abs($account_5040003[$branch])) . ")" : number_format($account_5040003[$branch])) . '</td>'; } $print .= '</tr>'; //Beban Training $print .= ' <tr><td align="left" > Beban Training</td>'; $print .= ' <td align="right" class="">' . ($account_9999999_total < 0 ? "(" . number_format(abs($account_9999999_total)) . ")" : number_format($account_9999999_total)) . '</td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">' . ($account_9999999[$branch] < 0 ? "(" . number_format(abs($account_9999999[$branch])) . ")" : number_format($account_9999999[$branch])) . '</td>'; } $print .= '</tr>'; //5030107 Insentif Operations $code = "5030107"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5030107_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5030107_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5030107[$branch] = $account_5030107_debet[$branch] - $account_5030107_credit[$branch]; $account_5030107_total += $account_5030107[$branch]; $account_beban_operasi_total[$branch] += $account_5030107[$branch]; } $print .= ' <tr><td align="left" > Insentif Operations</td>'; $print .= ' <td align="right" class="">' . ($account_5030107_total < 0 ? "(" . number_format(abs($account_5030107_total)) . ")" : number_format($account_5030107_total)) . '</td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">' . ($account_5030107[$branch] < 0 ? "(" . number_format(abs($account_5030107[$branch])) . ")" : number_format($account_5030107[$branch])) . '</td>'; } $print .= '</tr>'; //5080501 Beban Rumah Tangga Pusat $code = "5080501"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080501_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080501_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080501[$branch] = $account_5080501_debet[$branch] - $account_5080501_credit[$branch]; $account_5080501_total += $account_5080501[$branch]; $account_beban_RT_pusat_total[$branch] += $account_5080501[$branch]; $account_beban_operasi_total[$branch] += $account_5080501[$branch]; } $code = "5080301"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080301_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080301_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080301[$branch] = $account_5080301_debet[$branch] - $account_5080301_credit[$branch]; $account_5080301_total += $account_5080301[$branch]; $account_beban_RT_pusat_total[$branch] += $account_5080301[$branch]; $account_beban_operasi_total[$branch] += $account_5080301[$branch]; } $account_beban_RT_pusat_konsolidasi = $account_5080501_total + $account_5080301_total; $account_beban_RT_cabang_konsolidasi = $account_beban_RT_pusat_konsolidasi - $account_beban_RT_pusat_total[0]; $print .= ' <tr><td align="left" > Beban Rumah Tangga Pusat</td>'; $print .= ' <td align="right" class="">' . ($account_beban_RT_pusat_total[0] < 0 ? "(" . number_format(abs($account_beban_RT_pusat_total[0])) . ")" : number_format($account_beban_RT_pusat_total[0])) . '</td>'; $print .= ' <td align="right" class="">' . ($account_beban_RT_pusat_total[0] < 0 ? "(" . number_format(abs($account_beban_RT_pusat_total[0])) . ")" : number_format($account_beban_RT_pusat_total[0])) . '</td>'; for ($branch = 1; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">0</td>'; } $print .= '</tr>'; //Beban ATK Pusat : 5080201, 5080202, 5080203, 5080401 $code = "5080201"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080201_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080201_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080201[$branch] = $account_5080201_debet[$branch] - $account_5080201_credit[$branch]; $account_5080201_total += $account_5080201[$branch]; $account_beban_ATK_pusat_total[$branch] += $account_5080201[$branch]; $account_beban_operasi_total[$branch] += $account_5080201[$branch]; } $code = "5080202"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080202_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080202_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080202[$branch] = $account_5080202_debet[$branch] - $account_5080202_credit[$branch]; $account_5080202_total += $account_5080202[$branch]; $account_beban_ATK_pusat_total[$branch] += $account_5080202[$branch]; $account_beban_operasi_total[$branch] += $account_5080202[$branch]; } $code = "5080203"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080203_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080203_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080203[$branch] = $account_5080203_debet[$branch] - $account_5080203_credit[$branch]; $account_5080203_total += $account_5080203[$branch]; $account_beban_ATK_pusat_total[$branch] += $account_5080203[$branch]; $account_beban_operasi_total[$branch] += $account_5080203[$branch]; } $code = "5080401"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080401_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080401_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080401[$branch] = $account_5080401_debet[$branch] - $account_5080401_credit[$branch]; $account_5080401_total += $account_5080401[$branch]; $account_beban_ATK_pusat_total[$branch] += $account_5080401[$branch]; $account_beban_operasi_total[$branch] += $account_5080401[$branch]; } $account_beban_ATK_pusat_konsolidasi = $account_5080201_total + $account_5080202_total + $account_5080203_total + $account_5080401_total; $account_beban_ATK_cabang_konsolidasi = $account_beban_ATK_pusat_konsolidasi - $account_beban_ATK_pusat_total[0]; $print .= ' <tr><td align="left" > Beban ATK Pusat</td>'; $print .= ' <td align="right" class="">' . ($account_beban_ATK_pusat_total[0] < 0 ? "(" . number_format(abs($account_beban_ATK_pusat_total[0])) . ")" : number_format($account_beban_ATK_pusat_total[0])) . '</td>'; $print .= ' <td align="right" class="">' . ($account_beban_ATK_pusat_total[0] < 0 ? "(" . number_format(abs($account_beban_ATK_pusat_total[0])) . ")" : number_format($account_beban_ATK_pusat_total[0])) . '</td>'; for ($branch = 1; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">0</td>'; } $print .= '</tr>'; //Beban Transportasi Pusat : 5080302, 5080303, 5080304 $code = "5080302"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080302_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080302_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080302[$branch] = $account_5080302_debet[$branch] - $account_5080302_credit[$branch]; $account_5080302_total += $account_5080302[$branch]; $account_beban_transportasi_pusat_total[$branch] += $account_5080302[$branch]; $account_beban_operasi_total[$branch] += $account_5080302[$branch]; } $code = "5080303"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080303_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080303_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080303[$branch] = $account_5080303_debet[$branch] - $account_5080303_credit[$branch]; $account_5080303_total += $account_5080303[$branch]; $account_beban_transportasi_pusat_total[$branch] += $account_5080303[$branch]; $account_beban_operasi_total[$branch] += $account_5080303[$branch]; } $code = "5080304"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080304_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080304_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080304[$branch] = $account_5080304_debet[$branch] - $account_5080304_credit[$branch]; $account_5080304_total += $account_5080304[$branch]; $account_beban_transportasi_pusat_total[$branch] += $account_5080304[$branch]; $account_beban_operasi_total[$branch] += $account_5080304[$branch]; } $account_beban_transportasi_pusat_konsolidasi = $account_5080302_total + $account_5080303_total + $account_5080304_total; $account_beban_transportasi_cabang_konsolidasi = $account_beban_transportasi_pusat_konsolidasi - $account_beban_transportasi_pusat_total[0]; $print .= ' <tr><td align="left" > Beban Transportasi Pusat</td>'; $print .= ' <td align="right" class="">' . ($account_beban_transportasi_pusat_total[0] < 0 ? "(" . number_format(abs($account_beban_transportasi_pusat_total[0])) . ")" : number_format($account_beban_transportasi_pusat_total[0])) . '</td>'; $print .= ' <td align="right" class="">' . ($account_beban_transportasi_pusat_total[0] < 0 ? "(" . number_format(abs($account_beban_transportasi_pusat_total[0])) . ")" : number_format($account_beban_transportasi_pusat_total[0])) . '</td>'; for ($branch = 1; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">0</td>'; } $print .= '</tr>'; //Beban Perawatan Pusat $code = "5060000"; $code_level1 = substr($code, 0, 3); for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5060000_debet[$branch] = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $branch); $account_5060000_credit[$branch] = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $branch); $account_5060000[$branch] = $account_5060000_debet[$branch] - $account_5060000_credit[$branch]; $account_5060000_total += $account_5060000[$branch]; $account_beban_operasi_total[$branch] += $account_5060000[$branch]; } $account_5060000_cabang = $account_5060000_total - $account_5060000[0]; $print .= ' <tr><td align="left" > Beban Perawatan Pusat</td>'; $print .= ' <td align="right" class="">' . ($account_5060000[0] < 0 ? "(" . number_format(abs($account_5060000[0])) . ")" : number_format($account_5060000[0])) . '</td>'; $print .= ' <td align="right" class="">' . ($account_5060000[0] < 0 ? "(" . number_format(abs($account_5060000[0])) . ")" : number_format($account_5060000[0])) . '</td>'; for ($branch = 1; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">0</td>'; } $print .= '</tr>'; //Beban Lain-lain : 5080101, 5080102, 5080103 $code = "5080101"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080101_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080101_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080101[$branch] = $account_5080101_debet[$branch] - $account_5080101_credit[$branch]; $account_5080101_total += $account_5080101[$branch]; $account_beban_listrik_air_telp_pusat_total[$branch] += $account_5080101[$branch]; $account_beban_operasi_total[$branch] += $account_5080101[$branch]; } $code = "5080102"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080102_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080102_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080102[$branch] = $account_5080102_debet[$branch] - $account_5080102_credit[$branch]; $account_5080102_total += $account_5080102[$branch]; $account_beban_listrik_air_telp_pusat_total[$branch] += $account_5080102[$branch]; $account_beban_operasi_total[$branch] += $account_5080102[$branch]; } $code = "5080103"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080103_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080103_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080103[$branch] = $account_5080103_debet[$branch] - $account_5080103_credit[$branch]; $account_5080103_total += $account_5080103[$branch]; $account_beban_listrik_air_telp_pusat_total[$branch] += $account_5080103[$branch]; $account_beban_operasi_total[$branch] += $account_5080103[$branch]; } $account_beban_listrik_air_telp_pusat_konsolidasi = $account_5080101_total + $account_5080102_total + $account_5080103_total; $account_beban_listrik_air_telp_cabang_konsolidasi = $account_beban_listrik_air_telp_pusat_konsolidasi - $account_beban_listrik_air_telp_pusat_total[0]; $print .= ' <tr><td align="left" > Beban Listrik, Air, Telepon dan Internet Pusat</td>'; $print .= ' <td align="right" class="">' . ($account_beban_listrik_air_telp_pusat_total[0] < 0 ? "(" . number_format(abs($account_beban_listrik_air_telp_pusat_total[0])) . ")" : number_format($account_beban_listrik_air_telp_pusat_total[0])) . '</td>'; $print .= ' <td align="right" class="">' . ($account_beban_listrik_air_telp_pusat_total[0] < 0 ? "(" . number_format(abs($account_beban_listrik_air_telp_pusat_total[0])) . ")" : number_format($account_beban_listrik_air_telp_pusat_total[0])) . '</td>'; for ($branch = 1; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">0</td>'; } $print .= '</tr>'; //Beban Lain-lain Pusat : 5080104, 5080402, 5080403, 5080406, 5080502, 5080503, 5080504 $code = "5080104"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080104_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080104_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080104[$branch] = $account_5080104_debet[$branch] - $account_5080104_credit[$branch]; $account_5080104_total += $account_5080104[$branch]; $account_beban_lainlain_pusat_total[$branch] += $account_5080104[$branch]; $account_beban_operasi_total[$branch] += $account_5080104[$branch]; } $code = "5080402"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080402_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080402_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080402[$branch] = $account_5080402_debet[$branch] - $account_5080402_credit[$branch]; $account_5080402_total += $account_5080402[$branch]; $account_beban_lainlain_pusat_total[$branch] += $account_5080402[$branch]; $account_beban_operasi_total[$branch] += $account_5080402[$branch]; } $code = "5080403"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080403_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080403_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080403[$branch] = $account_5080403_debet[$branch] - $account_5080403_credit[$branch]; $account_5080403_total += $account_5080403[$branch]; $account_beban_lainlain_pusat_total[$branch] += $account_5080403[$branch]; $account_beban_operasi_total[$branch] += $account_5080403[$branch]; } $code = "5080406"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080406_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080406_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080406[$branch] = $account_5080406_debet[$branch] - $account_5080406_credit[$branch]; $account_5080406_total += $account_5080406[$branch]; $account_beban_lainlain_pusat_total[$branch] += $account_5080406[$branch]; $account_beban_operasi_total[$branch] += $account_5080406[$branch]; } $code = "5080502"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080502_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080502_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080502[$branch] = $account_5080502_debet[$branch] - $account_5080502_credit[$branch]; $account_5080502_total += $account_5080502[$branch]; $account_beban_lainlain_pusat_total[$branch] += $account_5080502[$branch]; $account_beban_operasi_total[$branch] += $account_5080502[$branch]; } $code = "5080503"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080503_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080503_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080503[$branch] = $account_5080503_debet[$branch] - $account_5080503_credit[$branch]; $account_5080503_total += $account_5080503[$branch]; $account_beban_lainlain_pusat_total[$branch] += $account_5080503[$branch]; $account_beban_operasi_total[$branch] += $account_5080503[$branch]; } $code = "5080504"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080504_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080504_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080504[$branch] = $account_5080504_debet[$branch] - $account_5080504_credit[$branch]; $account_5080504_total += $account_5080504[$branch]; $account_beban_lainlain_pusat_total[$branch] += $account_5080504[$branch]; $account_beban_operasi_total[$branch] += $account_5080504[$branch]; } $account_beban_lainlain_pusat_konsolidasi = $account_5080104_total + $account_5080402_total + $account_5080403_total + $account_5080406_total + $account_5080502_total + $account_5080503_total + $account_5080504_total; $account_beban_lainlain_cabang_konsolidasi = $account_beban_lainlain_pusat_konsolidasi - $account_beban_lainlain_pusat_total[0]; $print .= ' <tr><td align="left" > Beban Lain-lain Pusat</td>'; $print .= ' <td align="right" class="">' . ($account_beban_lainlain_pusat_total[0] < 0 ? "(" . number_format(abs($account_beban_lainlain_pusat_total[0])) . ")" : number_format($account_beban_lainlain_pusat_total[0])) . '</td>'; $print .= ' <td align="right" class="">' . ($account_beban_lainlain_pusat_total[0] < 0 ? "(" . number_format(abs($account_beban_lainlain_pusat_total[0])) . ")" : number_format($account_beban_lainlain_pusat_total[0])) . '</td>'; for ($branch = 1; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">0</td>'; } $print .= '</tr>'; //Beban Rumah Tangga Seluruh Cabang $account_beban_RT_cabang_konsolidasi = $account_beban_RT_pusat_konsolidasi - $account_beban_RT_pusat_total[0]; $print .= ' <tr><td align="left" > Beban Rumah Seluruh Cabang</td>'; $print .= ' <td align="right" class="">' . ($account_beban_RT_cabang_konsolidasi < 0 ? "(" . number_format(abs($account_beban_RT_cabang_konsolidasi)) . ")" : number_format($account_beban_RT_cabang_konsolidasi)) . '</td>'; $print .= ' <td align="right" class="">0</td>'; for ($branch = 1; $total_branch <= 0; $branch++) { $print .= ' <td align="right" class="">' . ($account_beban_RT_pusat_total[$branch] < 0 ? "(" . number_format(abs($account_beban_RT_pusat_total[$branch])) . ")" : number_format($account_beban_RT_pusat_total[$branch])) . '</td>'; } $print .= '</tr>'; //Beban ATK Seluruh Cabang $account_beban_ATK_cabang_konsolidasi = $account_beban_ATK_pusat_konsolidasi - $account_beban_ATK_pusat_total[0]; $print .= ' <tr><td align="left" > Beban ATK Seluruh Cabang</td>'; $print .= ' <td align="right" class="">' . ($account_beban_ATK_cabang_konsolidasi < 0 ? "(" . number_format(abs($account_beban_ATK_cabang_konsolidasi)) . ")" : number_format($account_beban_ATK_cabang_konsolidasi)) . '</td>'; $print .= ' <td align="right" class="">0</td>'; for ($branch = 1; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">' . ($account_beban_ATK_pusat_total[$branch] < 0 ? "(" . number_format(abs($account_beban_ATK_pusat_total[$branch])) . ")" : number_format($account_beban_ATK_pusat_total[$branch])) . '</td>'; } //Beban Transportasi Seluruh Cabang $account_beban_transportasi_cabang_konsolidasi = $account_beban_transportasi_pusat_konsolidasi - $account_beban_transportasi_pusat_total[0]; $print .= ' <tr><td align="left" > Beban Transportasi Seluruh Cabang</td>'; $print .= ' <td align="right" class="">' . ($account_beban_transportasi_cabang_konsolidasi < 0 ? "(" . number_format(abs($account_beban_transportasi_cabang_konsolidasi)) . ")" : number_format($account_beban_transportasi_cabang_konsolidasi)) . '</td>'; $print .= ' <td align="right" class="">0</td>'; for ($branch = 1; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">' . ($account_beban_transportasi_pusat_total[$branch] < 0 ? "(" . number_format(abs($account_beban_transportasi_pusat_total[$branch])) . ")" : number_format($account_beban_transportasi_pusat_total[$branch])) . '</td>'; } $print .= '</tr>'; //Beban Perawatan Seluruh Cabang $print .= ' <tr><td align="left" > Beban Perawatan Seluruh Cabang</td>'; $print .= ' <td align="right" class="">' . ($account_5060000_cabang < 0 ? "(" . number_format(abs($account_5060000_cabang)) . ")" : number_format($account_5060000_cabang)) . '</td>'; $print .= ' <td align="right" class="">0</td>'; for ($branch = 1; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">' . ($account_5060000[$branch] < 0 ? "(" . number_format(abs($account_5060000[$branch])) . ")" : number_format($account_5060000[$branch])) . '</td>'; } $print .= '</tr>'; //Beban Listrik, Air, Telepon dan Internet Seluruh Cabang $account_beban_listrik_air_telp_cabang_konsolidasi = $account_beban_listrik_air_telp_pusat_konsolidasi - $account_beban_listrik_air_telp_pusat_total[0]; $print .= ' <tr><td align="left" > Beban Listrik, Air, Telepon dan Internet Seluruh Cabang</td>'; $print .= ' <td align="right" class="">' . ($account_beban_listrik_air_telp_cabang_konsolidasi < 0 ? "(" . number_format(abs($account_beban_listrik_air_telp_cabang_konsolidasi)) . ")" : number_format($account_beban_listrik_air_telp_cabang_konsolidasi)) . '</td>'; $print .= ' <td align="right" class="">0</td>'; for ($branch = 1; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">' . ($account_beban_listrik_air_telp_pusat_total[$branch] < 0 ? "(" . number_format(abs($account_beban_listrik_air_telp_pusat_total[$branch])) . ")" : number_format($account_beban_listrik_air_telp_pusat_total[$branch])) . '</td>'; } $print .= '</tr>'; //Beban Lain-lain Seluruh Cabang $account_beban_lainlain_cabang_konsolidasi = $account_beban_lainlain_pusat_konsolidasi - $account_beban_lainlain_pusat_total[0]; $print .= ' <tr><td align="left" > Beban Lain-lain Seluruh Cabang</td>'; $print .= ' <td align="right" class="">' . ($account_beban_lainlain_cabang_konsolidasi < 0 ? "(" . number_format(abs($account_beban_lainlain_cabang_konsolidasi)) . ")" : number_format($account_beban_lainlain_cabang_konsolidasi)) . '</td>'; $print .= ' <td align="right" class="">0</td>'; for ($branch = 1; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">' . ($account_beban_lainlain_pusat_total[$branch] < 0 ? "(" . number_format(abs($account_beban_lainlain_pusat_total[$branch])) . ")" : number_format($account_beban_lainlain_pusat_total[$branch])) . '</td>'; } //Beban Cleaning Service $print .= ' <tr><td align="left" > Beban Cleaning Service</td>'; $print .= ' <td align="right" class="">' . ($account_9999999_total < 0 ? "(" . number_format(abs($account_9999999_total)) . ")" : number_format($account_9999999_total)) . '</td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">' . ($account_9999999[$branch] < 0 ? "(" . number_format(abs($account_9999999[$branch])) . ")" : number_format($account_9999999[$branch])) . '</td>'; } $print .= '</tr>'; //Beban Keamanan dan Kebersihan $code = "5080405"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5080405_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5080405_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5080405[$branch] = $account_5080405_debet[$branch] - $account_5080405_credit[$branch]; $account_5080405_total += $account_5080405[$branch]; $account_biaya_langsung_total[$branch] += $account_5080405[$branch]; } $print .= ' <tr><td align="left" > Beban Keamanan dan Kebersihan</td>'; $print .= ' <td align="right" class="">' . ($account_5080405_total < 0 ? "(" . number_format(abs($account_5080405_total)) . ")" : number_format($account_5080405_total)) . '</td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">' . ($account_5080405[$branch] < 0 ? "(" . number_format(abs($account_5080405[$branch])) . ")" : number_format($account_5080405[$branch])) . '</td>'; } $print .= '</tr>'; //Beban Penyusutan $code = "5070000"; $code_level1 = substr($code, 0, 3); for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5070000_debet[$branch] = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $branch); $account_5070000_credit[$branch] = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $branch); $account_5070000[$branch] = $account_5070000_debet[$branch] - $account_5070000_credit[$branch]; $account_5070000_total += $account_5070000[$branch]; $account_biaya_operasi_total[$branch] += $account_5070000[$branch]; } $print .= ' <tr><td align="left" > Beban Penyusutan</td>'; $print .= ' <td align="right" class="">' . ($account_5070000_total < 0 ? "(" . number_format(abs($account_5070000_total)) . ")" : number_format($account_5070000_total)) . '</td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">' . ($account_5070000[$branch] < 0 ? "(" . number_format(abs($account_5070000[$branch])) . ")" : number_format($account_5070000[$branch])) . '</td>'; } $print .= '</tr>'; //Beban Sewa Kantor Cabang : 5040001, 5040002 $code = "5040001"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5040001_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5040001_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5040001[$branch] = $account_5040001_debet[$branch] - $account_5040001_credit[$branch]; $account_5040001_total += $account_5040001[$branch]; $account_beban_sewa_kantor_cabang_total[$branch] += $account_5040001[$branch]; $account_beban_operasi_total[$branch] += $account_5040001[$branch]; } $code = "5040002"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5040002_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5040002_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5040002[$branch] = $account_5040002_debet[$branch] - $account_5040002_credit[$branch]; $account_5040002_total += $account_5040002[$branch]; $account_beban_sewa_kantor_cabang_total[$branch] += $account_5040002[$branch]; $account_beban_operasi_total[$branch] += $account_5040002[$branch]; } $account_beban_sewa_kantor_cabang_konsolidasi = $account_5040001_total + $account_5040002_total; $print .= ' <tr><td align="left" > Beban Sewa Kantor Cabang</td>'; $print .= ' <td align="right" class="">' . ($account_beban_sewa_kantor_cabang_konsolidasi < 0 ? "(" . number_format(abs($account_beban_sewa_kantor_cabang_konsolidasi)) . ")" : number_format($account_beban_sewa_kantor_cabang_konsolidasi)) . '</td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="">' . ($account_beban_sewa_kantor_cabang_total[$branch] < 0 ? "(" . number_format(abs($account_beban_sewa_kantor_cabang_total[$branch])) . ")" : number_format($account_beban_sewa_kantor_cabang_total[$branch])) . '</td>'; } $print .= '</tr>'; //Beban MIS $print .= ' <tr><td align="left" > Beban MIS</td>'; $print .= ' <td align="right" class="border_btm">' . ($account_9999999_total < 0 ? "(" . number_format(abs($account_9999999_total)) . ")" : number_format($account_9999999_total)) . '</td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="border_btm">' . ($account_9999999[$branch] < 0 ? "(" . number_format(abs($account_9999999[$branch])) . ")" : number_format($account_9999999[$branch])) . '</td>'; } $print .= '</tr>'; //Total Biaya Operasi for ($branch = 0; $branch <= $total_branch; $branch++) { $account_beban_operasi_konsolidasi += $account_beban_operasi_total[$branch]; } $print .= ' <tr><td align="left" >Jumlah Biaya Operasi</td>'; $print .= ' <td align="right" class="border_btm">' . ($account_beban_operasi_konsolidasi < 0 ? "(" . number_format(abs($account_beban_operasi_konsolidasi)) . ")" : number_format($account_beban_operasi_konsolidasi)) . '</td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="border_btm">' . ($account_beban_operasi_total[$branch] < 0 ? "(" . number_format(abs($account_beban_operasi_total[$branch])) . ")" : number_format($account_beban_operasi_total[$branch])) . '</td>'; } $print .= ' </tr>'; $print .= ' <tr><td></td><td align="left" class="border_btm" colspan="' . $colspan . '"> </td></tr>'; //Laba (Rugi) Operasi $account_LR_operasi_konsolidasi = $account_labarugi_kotor_konsolidasi - $account_beban_operasi_konsolidasi; $print .= ' <tr><td align="left" ><b>Sisa Hasil Usaha Operasional</b></td>'; $print .= ' <td align="right" class="border_btm"><b>' . ($account_LR_operasi_konsolidasi < 0 ? "(" . number_format(abs($account_LR_operasi_konsolidasi)) . ")" : number_format($account_LR_operasi_konsolidasi)) . '</b></td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_LR_operasi[$branch] = $account_labarugi_kotor_total[$branch] - $account_beban_operasi_total[$branch]; $print .= ' <td align="right" class="border_btm"><b>' . ($account_LR_operasi[$branch] < 0 ? "(" . number_format(abs($account_LR_operasi[$branch])) . ")" : number_format($account_LR_operasi[$branch])) . '</b></td>'; } $print .= ' </tr>'; //--------------------------------------------------------------------------------------------- //Pendapatan Diluar Usaha //--------------------------------------------------------------------------------------------- $print .= ' <tr><td align="left" colspan="' . $colspan2 . '"> </td></tr>'; $print .= ' <tr><td align="left" ><b>Pendapatan (beban) lainnya</b></td> <td colspan="' . $colspan . '" ></td></tr>'; //Pendapatan Lainnya : 4030001, 4030002, 4030003, 4030004, 4030005, 4030006 $code = "4030001"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_4030001_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_4030001_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_4030001[$branch] = $account_4030001_credit[$branch] - $account_4030001_debet[$branch]; $account_4030001_total += $account_4030001[$branch]; $account_pendapatan_lain_pusat_total[$branch] += $account_4030001[$branch]; $account_pendapatan_diluar_usaha_total[$branch] += $account_4030001[$branch]; } $code = "4030002"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_4030002_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_4030002_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_4030002[$branch] = $account_4030002_credit[$branch] - $account_4030002_debet[$branch]; $account_4030002_total += $account_4030002[$branch]; $account_pendapatan_lain_pusat_total[$branch] += $account_4030002[$branch]; $account_pendapatan_diluar_usaha_total[$branch] += $account_4030002[$branch]; } $code = "4030003"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_4030003_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_4030003_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_4030003[$branch] = $account_4030003_credit[$branch] - $account_4030003_debet[$branch]; $account_4030003_total += $account_4030003[$branch]; $account_pendapatan_lain_pusat_total[$branch] += $account_4030003[$branch]; $account_pendapatan_diluar_usaha_total[$branch] += $account_4030003[$branch]; } $code = "4030004"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_4030004_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_4030004_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_4030004[$branch] = $account_4030004_credit[$branch] - $account_4030004_debet[$branch]; $account_4030004_total += $account_4030004[$branch]; $account_pendapatan_lain_pusat_total[$branch] += $account_4030004[$branch]; $account_pendapatan_diluar_usaha_total[$branch] += $account_4030004[$branch]; } //Pendapatan Bunga Bank $code = "4030005"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_4030005_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_4030005_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_4030005[$branch] = $account_4030005_credit[$branch] - $account_4030005_debet[$branch]; $account_4030005_total += $account_4030005[$branch]; $account_pendapatan_lain_pusat_total[$branch] += $account_4030005[$branch]; $account_pendapatan_diluar_usaha_total[$branch] += $account_4030005[$branch]; } $code = "4030006"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_4030006_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_4030006_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_4030006[$branch] = $account_4030006_credit[$branch] - $account_4030006_debet[$branch]; $account_4030006_total += $account_4030006[$branch]; $account_pendapatan_lain_pusat_total[$branch] += $account_4030006[$branch]; $account_pendapatan_diluar_usaha_total[$branch] += $account_4030006[$branch]; } $account_pendapatan_lain_konsolidasi = $account_4030001_total + $account_4030002_total + $account_4030003_total + $account_4030004_total + $account_4030005_total + $account_4030006_total; $print .= ' <tr><td align="left" > Pendapatan Lain-lain</td>'; $print .= ' <td align="right" class="border_btm">' . ($account_pendapatan_lain_konsolidasi < 0 ? "(" . number_format(abs($account_pendapatan_lain_konsolidasi)) . ")" : number_format($account_pendapatan_lain_konsolidasi)) . '</td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="border_btm">' . ($account_pendapatan_lain_pusat_total[$branch] < 0 ? "(" . number_format(abs($account_pendapatan_lain_pusat_total[$branch])) . ")" : number_format($account_pendapatan_lain_pusat_total[$branch])) . '</td>'; } $print .= '</tr>'; //--------------------------------------------------------------------------------------------- //(beban) lainnya //--------------------------------------------------------------------------------------------- //5090001 $code = "5090001"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5090001_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5090001_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5090001[$branch] = $account_5090001_debet[$branch] - $account_5090001_credit[$branch]; $account_5090001_total += $account_5090001[$branch]; $account_beban_diluar_usaha_total[$branch] += $account_5090001[$branch]; } //5090002 $code = "5090002"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5090002_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5090002_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5090002[$branch] = $account_5090002_debet[$branch] - $account_5090002_credit[$branch]; $account_5090002_total += $account_5090002[$branch]; $account_beban_diluar_usaha_total[$branch] += $account_5090002[$branch]; } //5090003 $code = "5090003"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5090003_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5090003_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5090003[$branch] = $account_5090003_debet[$branch] - $account_5090003_credit[$branch]; $account_5090003_total += $account_5090003[$branch]; $account_beban_diluar_usaha_total[$branch] += $account_5090003[$branch]; } //5090004 $code = "5090004"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5090004_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5090004_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5090004[$branch] = $account_5090004_debet[$branch] - $account_5090004_credit[$branch]; $account_5090004_total += $account_5090004[$branch]; $account_beban_diluar_usaha_total[$branch] += $account_5090004[$branch]; } //5090005 $code = "5090005"; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_5090005_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_5090005_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_5090005[$branch] = $account_5090005_debet[$branch] - $account_5090005_credit[$branch]; $account_5090005_total += $account_5090005[$branch]; $account_beban_diluar_usaha_total[$branch] += $account_5090005[$branch]; } //Total Beban Diluar Usaha for ($branch = 0; $branch <= $total_branch; $branch++) { $account_beban_diluar_usaha_konsolidasi += $account_beban_diluar_usaha_total[$branch]; } $print .= ' <tr><td align="left" > Beban Lain-Lain</td>'; $print .= ' <td align="right" class="border_btm">' . ($account_beban_diluar_usaha_konsolidasi < 0 ? "(" . number_format(abs($account_beban_diluar_usaha_konsolidasi)) . ")" : number_format($account_beban_diluar_usaha_konsolidasi)) . '</td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="border_btm">' . ($account_beban_diluar_usaha_total[$branch] < 0 ? "(" . number_format(abs($account_beban_diluar_usaha_total[$branch])) . ")" : number_format($account_beban_diluar_usaha_total[$branch])) . '</td>'; } $print .= '</tr>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_jumlah_lainlain[$branch] = $account_pendapatan_lain_pusat_total[$branch] - $account_beban_diluar_usaha_total[$branch]; } $account_jumlah_lainlain_konsolidasi = $account_pendapatan_lain_konsolidasi - $account_beban_diluar_usaha_konsolidasi; $print .= ' <tr><td align="left" > Jumlah</td>'; $print .= ' <td align="right" class="border_btm">' . ($account_jumlah_lainlain_konsolidasi < 0 ? "(" . number_format(abs($account_jumlah_lainlain_konsolidasi)) . ")" : number_format($account_jumlah_lainlain_konsolidasi)) . '</td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $print .= ' <td align="right" class="border_btm">' . ($account_jumlah_lainlain[$branch] < 0 ? "(" . number_format(abs($account_jumlah_lainlain[$branch])) . ")" : number_format($account_jumlah_lainlain[$branch])) . '</td>'; } $print .= '</tr>'; $print .= ' <tr><td></td><td align="left" colspan="' . $colspan . '" class="border_btm"> </td></tr>'; //--------------------------------------------------------------------------------------------- //Laba (Rugi) TOTAL //--------------------------------------------------------------------------------------------- //Laba (Rugi) Bersih $account_LR_bersih_konsolidasi = $account_labarugi_kotor_konsolidasi - $account_jumlah_lainlain_konsolidasi; $print .= ' <tr><td align="left" ><b>Sisa hasil usaha bersih</b></td>'; $print .= ' <td align="right" class="border_btm"><b>' . ($account_LR_bersih_konsolidasi < 0 ? "(" . number_format(abs($account_LR_bersih_konsolidasi)) . ")" : number_format($account_LR_bersih_konsolidasi)) . '</b></td>'; for ($branch = 0; $branch <= $total_branch; $branch++) { $account_LR_bersih_total[$branch] = $account_LR_operasi[$branch] - $account_jumlah_lainlain[$branch]; $print .= ' <td align="right" class="border_btm"><b>' . ($account_LR_bersih_total[$branch] < 0 ? "(" . number_format(abs($account_LR_bersih_total[$branch])) . ")" : number_format($account_LR_bersih_total[$branch])) . '</b></td>'; } $print .= '</tr>'; $this->template->set('menu_title', 'Laporan Keuangan - Sisa Hasil Usaha')->set('menu_report', 'active')->set('print', $print)->build('accounting/labarugi_konsolidasi'); } else { //If no session, redirect to login page redirect('login', 'refresh'); } }
public function laporan_keuangan() { if ($this->session->userdata('logged_in')) { function getStartAndEndDate($week, $year) { $time = strtotime("1 January {$year}", time()); $day = date('w', $time); $time += (7 * $week + 1 - $day) * 24 * 3600; $return[0] = date('Y-n-j', $time); $time += 6 * 24 * 3600; $return[1] = date('Y-n-j', $time); return $return; } $date_today = date("Y-m-d"); $date_year_today = date("Y"); $date_week_today = date("W", strtotime($date_today)) - 1; $date_week_before = $date_week_today - 1; $week_today = getStartAndEndDate($date_week_today, $date_year_today); $date_start = $this->input->post('date_start'); $date_end = $this->input->post('date_end'); if ($date_start and $date_end and $date_start <= $date_end) { $date_start = $this->input->post('date_start'); $date_end = $this->input->post('date_end'); } else { $date_start = $week_today[0]; $date_end = $week_today[1]; } $date_end_before = strtotime($date_end); $date_end_before = strtotime("-7 day", $date_end_before); $date_end_before = date('Y-m-d', $date_end_before); $date_start_before = "2013-01-01"; $accounting = $this->accounting_model->get_all_accounting()->result(); foreach ($accounting as $c) { $code = $c->accounting_code; $code_level0 = substr($code, 0, 1); $code_level1 = substr($code, 0, 3); $code_level2 = substr($code, 0, 5); $haschild = $c->accounting_haschild; $parent = $c->accounting_parent; $account_debet = 0; $account_credit = 0; $account_saldo = 0; $saldo_awal = 0; if ($code_level0_old != $code_level0) { $neraca .= '<tr><td colspan="5"> </td></tr><tr>'; } if ($haschild == "1" and $parent == "0") { //LEVEL 1 $account_debet = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end); $account_credit = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end); $account_debet_before = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start_before, $date_end_before); $account_credit_before = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start_before, $date_end_before); $account_saldo_before = $account_debet_before - $account_credit_before; $account_saldo = $account_saldo_before + $account_debet - $account_credit; $neraca .= '<tr> <td align="left" ><b>' . $c->accounting_code . " " . $c->accounting_name . '</b></td> <td class="text-right"><b>' . ($account_saldo_before < 0 ? "(" . number_format(abs($account_saldo_before)) . ")" : number_format($account_saldo_before)) . '</b></td> <td class="text-right"><b>' . number_format($account_debet) . '</b></td> <td class="text-right"><b>' . number_format($account_credit) . '</b></td> <td class="text-right"><b>' . ($account_saldo < 0 ? "(" . number_format(abs($account_saldo)) . ")" : number_format($account_saldo)) . '</b></td> </tr>'; } elseif ($haschild == "1" and $parent != "0") { //LEVEL 2 $account_debet = $this->jurnal_model->sum_account_parent_debet_by_date($code_level2, $date_start, $date_end); $account_credit = $this->jurnal_model->sum_account_parent_credit_by_date($code_level2, $date_start, $date_end); $account_debet_before = $this->jurnal_model->sum_account_parent_debet_by_date($code_level2, $date_start_before, $date_end_before); $account_credit_before = $this->jurnal_model->sum_account_parent_credit_by_date($code_level2, $date_start_before, $date_end_before); $account_saldo_before = $account_debet_before - $account_credit_before; $account_saldo = $account_saldo_before + $account_debet - $account_credit; $neraca .= '<tr> <td align="left" ><b> ' . $c->accounting_code . " " . $c->accounting_name . '</b></td> <td class="text-right"><b>' . ($account_saldo_before < 0 ? "(" . number_format(abs($account_saldo_before)) . ")" : number_format($account_saldo_before)) . '</b></td> <td class="text-right"><b>' . number_format($account_debet) . '</b></td> <td class="text-right"><b>' . number_format($account_credit) . '</b></td> <td class="text-right"><b>' . ($account_saldo < 0 ? "(" . number_format(abs($account_saldo)) . ")" : number_format($account_saldo)) . '</b></td> </tr>'; } else { //LEVEL 3 $account_debet = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end); $account_credit = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end); $account_debet_before = $this->jurnal_model->sum_account_debet_by_date($code, $date_start_before, $date_end_before); $account_credit_before = $this->jurnal_model->sum_account_credit_by_date($code, $date_start_before, $date_end_before); $account_saldo_before = $account_debet_before - $account_credit_before; $account_saldo = $account_saldo_before + $account_debet - $account_credit; //grand total dihitung dari total account level 3 $grand_total_debet += $account_debet; $grand_total_credit += $account_credit; $grand_total_before += $account_saldo_before; $neraca .= '<tr> <td align="left" > ' . $c->accounting_code . " " . $c->accounting_name . '</td> <td class="text-right">' . ($account_saldo_before < 0 ? "(" . number_format(abs($account_saldo_before)) . ")" : number_format($account_saldo_before)) . '</td> <td class="text-right">' . number_format($account_debet) . '</td> <td class="text-right">' . number_format($account_credit) . '</td> <td class="text-right">' . ($account_saldo < 0 ? "(" . number_format(abs($account_saldo)) . ")" : number_format($account_saldo)) . '</td> </tr>'; } $code_level0_old = $code_level0; } //GRAND TOTAL $grand_total_saldo = $saldo_awal + $grand_total_debet - $grand_total_credit; $neraca .= '<tfoot bgcolor="#ddd"><tr"> <td align="left" ><b>GRAND TOTAL</b></td> <td class="text-right"><b>' . ($grand_total_before < 0 ? "(" . number_format(abs($grand_total_before)) . ")" : number_format($grand_total_before)) . '</b></td> <td class="text-right"><b>' . number_format($grand_total_debet) . '</b></td> <td class="text-right"><b>' . number_format($grand_total_credit) . '</b></td> <td class="text-right"><b>' . ($grand_total_saldo < 0 ? "(" . number_format(abs($grand_total_saldo)) . ")" : number_format($grand_total_saldo)) . '</b></td> </tr></tfoot>'; $this->template->set('menu_title', 'Laporan Keuangan')->set('menu_jurnal', 'active')->set('accounting', $accounting)->set('neraca', $neraca)->build('neraca'); } else { //If no session, redirect to login page redirect('login', 'refresh'); } }
/** * Renders a specific part out of the complete display of hours * This result is based on the assignment * @param Integer $id Id of the student * @param Integer $weeknr Week number to zoom in on * @param Integer $jaar Year to zoom in on * @param Integer $cursusid Id of the course * @return Template that shows a specific part of the complete display of hours based on an assignment */ public function studentOverzichtDetailOnderdeel($id, $weeknr, $jaar, $onderdeelid) { $result = getUserDetails($id); if (isLogged($id) && $result['Rol_rol_Id'] == 1) { $startandenddate = getStartAndEndDate($weeknr, $jaar); $statement = $this->db->prepare("SELECT\n\t\t\t\t(SELECT onderdeel_Name FROM Onderdeel WHERE onderdeel_Id = Onderdeel_onderdeel_Id) AS onderdeel,\t\t\t\t\t\t\t\t\t\t\n\t\t\t\turen_Studielast as studielast,\n\t\t\t\turen_Date AS datum\n\t\t\t\tFROM\n\t\t\t\tUren\n\t\t\t\tWHERE\n\t\t\t\turen_Date between '" . $startandenddate[0] . "' and '" . $startandenddate[1] . "' \n\t\t\t\tAND \n\t\t\t\tUser_user_Id = " . $id . "\n\t\t\t\tAND\n\t\t\t\tOnderdeel_onderdeel_Id = '" . $onderdeelid . "'\n\t\t\t\tGROUP BY uren_Date"); $statement->execute(); $urenoverzichtData = $statement->fetchAll(\PDO::FETCH_ASSOC); $array = array(); $onderdeel = ''; foreach ($urenoverzichtData as $uren) { $studielast_in_uren = min_naar_uren($uren['studielast']); $dag_vd_week = date('w', strtotime($uren['datum'])); $dagen = array('Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'); $onderdeel = $uren['onderdeel']; $array[] = array('dag' => $dagen[$dag_vd_week], 'datum' => date('d-M-Y', strtotime($uren['datum'])), 'onderdeel' => $uren['onderdeel'], 'studielast' => $studielast_in_uren); } echo $this->twigRenderer->renderTemplate('urenoverzichtdetailOnderdeel_student.twig', array('id' => $id, 'onderdeeloverzichtarray' => $array, 'onderdeel' => $onderdeel, 'weeknr' => $weeknr)); } else { echo $this->twigRenderer->renderTemplate('noaccess.twig'); } }
public function neraca_test() { //Cek User Branch $user_branch = $this->session->userdata('user_branch'); ////if($user_branch == "0"){ $user_branch=NULL;} function getStartAndEndDate($week, $year) { $time = strtotime("1 January {$year}", time()); $day = date('w', $time); $time += (7 * $week + 1 - $day) * 24 * 3600; $return[0] = date('Y-n-j', $time); $time += 6 * 24 * 3600; $return[1] = date('Y-n-j', $time); return $return; } $date_today = date("Y-m-d"); $date_year_today = date("Y"); $date_week_today = date("W", strtotime($date_today)) - 1; $date_week_before = $date_week_today - 1; $week_today = getStartAndEndDate($date_week_today, $date_year_today); $date_start = $this->input->post('date_start'); $date_end = $this->input->post('date_end'); if ($date_start and $date_end and $date_start <= $date_end) { $date_start = $this->input->post('date_start'); $date_end = $this->input->post('date_end'); } else { $date_start = $week_today[0]; $date_end = $week_today[1]; } $date_end_before = strtotime($date_start); $date_end_before = strtotime("-1 day", $date_end_before); $date_end_before = date('Y-m-d', $date_end_before); $date_start_before = "2013-01-01"; //Hitung Laba Rugi $accounting = $this->accounting_model->get_all_accounting_labarugi()->result(); foreach ($accounting as $c) { $code = $c->accounting_code; $code_level0 = substr($code, 0, 1); $code_level1 = substr($code, 0, 3); $code_level2 = substr($code, 0, 5); $haschild = $c->accounting_haschild; $parent = $c->accounting_parent; $account_debet = 0; $account_credit = 0; $account_saldo = 0; $saldo_awal = 0; if ($haschild == "1" and $parent == "0") { } elseif ($haschild == "1" and $parent != "0") { } else { //LEVEL 3 $account_debet = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $user_branch); $account_credit = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $user_branch); $account_debet_before = $this->jurnal_model->sum_account_debet_by_date($code, $date_start_before, $date_end_before, $user_branch); $account_credit_before = $this->jurnal_model->sum_account_credit_by_date($code, $date_start_before, $date_end_before, $user_branch); //$account_saldo_before = $account_debet_before - $account_credit_before; //$account_saldo = $account_saldo_before + $account_debet - $account_credit; if ($code_level0 == "4") { $account_saldo_before = $account_credit_before - $account_debet_before; $account_saldo = $account_saldo_before + $account_credit - $account_debet; } elseif ($code_level0 == "5") { $account_saldo_before = $account_debet_before - $account_credit_before; $account_saldo = $account_saldo_before + $account_debet - $account_credit; } //grand total dihitung dari total account level 3 $grand_total_debet += $account_debet; $grand_total_credit += $account_credit; $grand_total_before += $account_saldo_before; if ($code_level0 == "4") { $grand_total_pendapatan_debet += $account_debet; $grand_total_pendapatan_credit += $account_credit; $grand_total_pendapatan_before += $account_saldo_before; } elseif ($code_level0 == "5") { $grand_total_beban_debet += $account_debet; $grand_total_beban_credit += $account_credit; $grand_total_beban_before += $account_saldo_before; } } $code_level0_old = $code_level0; } //GRAND TOTAL LABA RUGI BERJALAN //GRAND TOTAL $grand_total_saldo = $saldo_awal + $grand_total_debet - $grand_total_credit; $grand_total_pendapatan_saldo = $grand_total_pendapatan_before - $grand_total_pendapatan_debet + $grand_total_pendapatan_credit; $grand_total_beban_saldo = $grand_total_beban_before + $grand_total_beban_debet - $grand_total_beban_credit; //$laba_rugi = ($grand_total_pendapatan_before+$grand_total_pendapatan_credit) - ($grand_total_beban_before+$grand_total_beban_debet); $laba_rugi = $grand_total_pendapatan_saldo - $grand_total_beban_saldo; $laba_rugi_before = $grand_total_pendapatan_before - $grand_total_beban_before; //End of Hitung Laba Rugi $grand_total_debet = 0; $grand_total_credit = 0; $grand_total_before = 0; //ASET $accounting = $this->accounting_model->get_all_accounting_aset()->result(); $get_neraca = $this->print_neraca("ASET", $accounting, $date_start, $date_end, $date_start_before, $date_end_before, $user_branch); list($neraca_list, $aset_before, $aset_debet, $aset_credit, $aset_saldo) = $get_neraca; $neraca .= $neraca_list; $grand_total_aktiva_saldo_before = $aset_before; $grand_total_aktiva_saldo = $aset_saldo; //KEWAJIBAN $accounting = $this->accounting_model->get_all_accounting_kewajiban()->result(); $get_neraca = $this->print_neraca("KEWAJIBAN", $accounting, $date_start, $date_end, $date_start_before, $date_end_before, $user_branch); list($neraca_list, $aset_before, $aset_debet, $aset_credit, $aset_saldo) = $get_neraca; $neraca .= $neraca_list; //$neraca .= $this->print_neraca("KEWAJIBAN",$accounting,$date_start,$date_end,$date_start_before,$date_end_before); $grand_total_kewajiban_saldo_before = $aset_before; $grand_total_kewajiban_saldo = $aset_saldo; //MODAL $accounting = $this->accounting_model->get_all_accounting_modal()->result(); foreach ($accounting as $c) { $code = $c->accounting_code; $code_level0 = substr($code, 0, 1); $code_level1 = substr($code, 0, 3); $code_level2 = substr($code, 0, 5); $haschild = $c->accounting_haschild; $parent = $c->accounting_parent; $account_debet = 0; $account_credit = 0; $account_saldo = 0; $saldo_awal = 0; if ($code_level0_old != $code_level0) { $neraca .= '<tr><td colspan="5"> </td></tr><tr>'; } if ($haschild == "1" and $parent == "0") { //LEVEL 1 $account_debet = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $user_branch); $account_credit = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $user_branch); $account_debet_before = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start_before, $date_end_before, $user_branch); $account_credit_before = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start_before, $date_end_before, $user_branch); $account_saldo_before = $account_credit_before - $account_debet_before; $account_saldo = $account_saldo_before - $account_debet + $account_credit + $laba_rugi; /*$neraca .= '<tr> <td align="left" ><b>'.$c->accounting_code." ".$c->accounting_name.'</b></td> <td class="text-right"><b>'.($account_saldo_before < 0 ? "(".number_format(abs($account_saldo_before)).")" : number_format($account_saldo_before)).'</b></td> <td class="text-right"><b>'.number_format($account_debet).'</b></td> <td class="text-right"><b>'.number_format($account_credit).'</b></td> <td class="text-right"><b>'.($account_saldo < 0 ? "(".number_format(abs($account_saldo)).")" : number_format($account_saldo)).'</b></td> </tr>';*/ $neraca .= '<tr> <td align="left" ><b>' . $c->accounting_code . " " . $c->accounting_name . '</b></td> <td class="text-right"><b></b></td> <td class="text-right"><b></b></td> <td class="text-right"><b></b></td> <td class="text-right"><b></b></td> </tr>'; } elseif ($haschild == "1" and $parent != "0") { //LEVEL 2 $account_debet = $this->jurnal_model->sum_account_parent_debet_by_date($code_level2, $date_start, $date_end, $user_branch); $account_credit = $this->jurnal_model->sum_account_parent_credit_by_date($code_level2, $date_start, $date_end, $user_branch); $account_debet_before = $this->jurnal_model->sum_account_parent_debet_by_date($code_level2, $date_start_before, $date_end_before, $user_branch); $account_credit_before = $this->jurnal_model->sum_account_parent_credit_by_date($code_level2, $date_start_before, $date_end_before, $user_branch); $account_saldo_before = $account_credit_before - $account_debet_before; $account_saldo = $account_saldo_before - $account_debet + $account_credit; $neraca .= '<tr> <td align="left" ><b> ' . $c->accounting_code . " " . $c->accounting_name . '</b></td> <td class="text-right"><b>' . ($account_saldo_before < 0 ? "(" . number_format(abs($account_saldo_before)) . ")" : number_format($account_saldo_before)) . '</b></td> <td class="text-right"><b>' . number_format($account_debet) . '</b></td> <td class="text-right"><b>' . number_format($account_credit) . '</b></td> <td class="text-right"><b>' . ($account_saldo < 0 ? "(" . number_format(abs($account_saldo)) . ")" : number_format($account_saldo)) . '</b></td> </tr>'; } else { //LEVEL 3 $account_debet = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $user_branch); $account_credit = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $user_branch); $account_debet_before = $this->jurnal_model->sum_account_debet_by_date($code, $date_start_before, $date_end_before, $user_branch); $account_credit_before = $this->jurnal_model->sum_account_credit_by_date($code, $date_start_before, $date_end_before, $user_branch); $account_saldo_before = $account_credit_before - $account_debet_before; if ($c->accounting_code == "3020002") { $account_saldo_before = $laba_rugi_before; $account_saldo_before = 0; $account_credit = $laba_rugi; } elseif ($c->accounting_code == "3020001") { $account_saldo_before = $account_debet_before - $account_credit_before; } $account_saldo = $account_saldo_before + $account_credit - $account_debet; //grand total dihitung dari total account level 3 $grand_total_debet += $account_debet; $grand_total_credit += $account_credit; $grand_total_before += $account_saldo_before; $grand_total_modal_debet += $account_debet; $grand_total_modal_credit += $account_credit; $grand_total_modal_before += $account_saldo_before; //if($c->accounting_code == "3020001"){ echo "<b>$account_debet --- $account_credit</b>";} $neraca .= '<tr> <td align="left" > ' . $c->accounting_code . " " . $c->accounting_name . '</td> <td class="text-right">' . ($account_saldo_before < 0 ? "(" . number_format(abs($account_saldo_before)) . ")" : number_format($account_saldo_before)) . '</td> <td class="text-right">' . ($account_debet < 0 ? "(" . number_format(abs($account_debet)) . ")" : number_format($account_debet)) . '</td> <td class="text-right">' . ($account_credit < 0 ? "(" . number_format(abs($account_credit)) . ")" : number_format($account_credit)) . '</td> <td class="text-right">' . ($account_saldo < 0 ? "(" . number_format(abs($account_saldo)) . ")" : number_format($account_saldo)) . '</td> </tr>'; } $code_level0_old = $code_level0; } $grand_total_modal_saldo = $grand_total_modal_before - $grand_total_modal_debet + $grand_total_modal_credit; $neraca .= '<tr bgcolor="#eee"> <td align="left" ><b>TOTAL MODAL</b></td> <td class="text-right"><b>' . ($grand_total_modal_before < 0 ? "(" . number_format(abs($grand_total_modal_before)) . ")" : number_format($grand_total_modal_before)) . '</b></td> <td class="text-right"><b>' . ($grand_total_modal_debet < 0 ? "(" . number_format(abs($grand_total_modal_debet)) . ")" : number_format($grand_total_modal_debet)) . '</b></td> <td class="text-right"><b>' . ($grand_total_modal_credit < 0 ? "(" . number_format(abs($grand_total_modal_credit)) . ")" : number_format($grand_total_modal_credit)) . '</b></td> <td class="text-right"><b>' . ($grand_total_modal_saldo < 0 ? "(" . number_format(abs($grand_total_modal_saldo)) . ")" : number_format($grand_total_modal_saldo)) . '</b></td> </tr>'; //----------- //GRAND TOTAL //----------- $grand_total_saldo = $grand_total_aktiva_saldo - $grand_total_kewajiban_saldo - $grand_total_modal_saldo; $grand_total_before = $grand_total_aktiva_before - $grand_total_kewajiban_before - $grand_total_modal_before; $grand_total_before = 0; $grand_total_debet = 0; $grand_total_credit = 0; $neraca .= '<tfoot bgcolor="#ddd"><tr"> <td align="left" ><b>GRAND TOTAL</b></td> <td class="text-right"><b>' . ($grand_total_before < 0 ? "(" . number_format(abs($grand_total_before)) . ")" : number_format($grand_total_before)) . '</b></td> <td class="text-right"><b>' . number_format($grand_total_debet) . '</b></td> <td class="text-right"><b>' . number_format($grand_total_credit) . '</b></td> <td class="text-right"><b>' . ($grand_total_saldo < 0 ? "(" . number_format(abs($grand_total_saldo)) . ")" : number_format($grand_total_saldo)) . '</b></td> </tr></tfoot>'; $this->template->set('menu_title', 'Neraca')->set('menu_jurnal', 'active')->set('accounting', $accounting)->set('neraca', $neraca)->build('neraca'); }
$return_from = date($time); $time += 6 * 24 * 3600; $return_to = date($time); if ($fromOrTo == 1) { return $return_from; } else { return $return_to; } } $currentYear = date("Y"); if (date('n') < 7) { // if before July $currentYear = $currentYear - 1; } for ($i = 1; $i <= 52; $i++) { echo '<option from="' . getStartAndEndDate($i, $currentYear, 1) . '" to="' . getStartAndEndDate($i, $currentYear, 2) . '">' . $i . '</option>'; } ?> </select> </div> </div> </br> <div class="row"> <div class="col-md-4"> <div class="input-group input-large"> <input type="text" class="form-control" placeholder="Date from" id="filterDateFrom" > <span class="input-group-addon">To</span> <input type="text" class="form-control" placeholder="Date to" id="filterDateTo"> </div>
public function neraca_excel() { if ($this->session->userdata('logged_in')) { //Cek User Branch $user_branch = $this->session->userdata('user_branch'); $branch_name = str_replace(' ', '', $this->session->userdata('user_branch_name')); if ($user_branch == "0") { $user_branch = NULL; } //load our new PHPExcel library $this->load->library('excel'); $objPHPExcel = new PHPExcel(); $objPHPExcel->getProperties()->setCreator("Amartha MIS"); $objPHPExcel->getProperties()->setLastModifiedBy("Amartha MIS"); $objPHPExcel->getProperties()->setTitle("Neraca"); $objPHPExcel->getProperties()->setSubject("Neraca"); $objPHPExcel->getProperties()->setDescription("Neraca"); $objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->getActiveSheet()->setTitle('Neraca'); //TITLE $objPHPExcel->getActiveSheet()->setCellValue("A1", "Amartha Microfinance"); $objPHPExcel->getActiveSheet()->setCellValue("A2", "Cabang {$branch_name}"); $objPHPExcel->getActiveSheet()->mergeCells("A1:D1"); $objPHPExcel->getActiveSheet()->getStyle("A1")->applyFromArray(array("font" => array("bold" => true, 'size' => 16))); $objPHPExcel->getActiveSheet()->getStyle("A2")->applyFromArray(array("font" => array("bold" => true))); //TOP ROW $objPHPExcel->getActiveSheet()->getStyle("A4:E4")->applyFromArray(array("font" => array("bold" => true))); $objPHPExcel->getActiveSheet()->getStyle("B4:E4")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->setCellValue("A4", "ACCOUNT"); $objPHPExcel->getActiveSheet()->getColumnDimension("A")->setWidth(60); $objPHPExcel->getActiveSheet()->setCellValue("B4", "SALDO AWAL"); $objPHPExcel->getActiveSheet()->getColumnDimension("B")->setWidth(15); $objPHPExcel->getActiveSheet()->setCellValue("C4", "DEBET"); $objPHPExcel->getActiveSheet()->getColumnDimension("C")->setWidth(15); $objPHPExcel->getActiveSheet()->setCellValue("D4", "CREDIT"); $objPHPExcel->getActiveSheet()->getColumnDimension("D")->setWidth(15); $objPHPExcel->getActiveSheet()->setCellValue("E4", "SALDO AKHIR"); $objPHPExcel->getActiveSheet()->getColumnDimension("E")->setWidth(15); $timestamp = date("Ymdhis"); function getStartAndEndDate($week, $year) { $time = strtotime("1 January {$year}", time()); $day = date('w', $time); $time += (7 * $week + 1 - $day) * 24 * 3600; $return[0] = date('Y-n-j', $time); $time += 6 * 24 * 3600; $return[1] = date('Y-n-j', $time); return $return; } $date_today = date("Y-m-d"); $date_year_today = date("Y"); $date_week_today = date("W", strtotime($date_today)) - 1; $date_week_before = $date_week_today - 1; $week_today = getStartAndEndDate($date_week_today, $date_year_today); $date_start = $this->input->post('date_start'); $date_end = $this->input->post('date_end'); if ($date_start and $date_end and $date_start <= $date_end) { $date_start = $this->input->post('date_start'); $date_end = $this->input->post('date_end'); } else { $date_start = $week_today[0]; $date_end = $week_today[1]; } $date_end_before = strtotime($date_end); $date_end_before = strtotime("-7 day", $date_end_before); $date_end_before = date('Y-m-d', $date_end_before); $date_start_before = "2013-01-01"; //Hitung Laba Rugi $accounting = $this->accounting_model->get_all_accounting_labarugi()->result(); foreach ($accounting as $c) { $code = $c->accounting_code; $code_level0 = substr($code, 0, 1); $code_level1 = substr($code, 0, 3); $code_level2 = substr($code, 0, 5); $haschild = $c->accounting_haschild; $parent = $c->accounting_parent; $account_debet = 0; $account_credit = 0; $account_saldo = 0; $saldo_awal = 0; if ($haschild == "1" and $parent == "0") { } elseif ($haschild == "1" and $parent != "0") { } else { //LEVEL 3 $account_debet = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $user_branch); $account_credit = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $user_branch); $account_debet_before = $this->jurnal_model->sum_account_debet_by_date($code, $date_start_before, $date_end_before, $user_branch); $account_credit_before = $this->jurnal_model->sum_account_credit_by_date($code, $date_start_before, $date_end_before, $user_branch); $account_saldo_before = $account_debet_before - $account_credit_before; $account_saldo = $account_saldo_before + $account_debet - $account_credit; //grand total dihitung dari total account level 3 $grand_total_debet += $account_debet; $grand_total_credit += $account_credit; $grand_total_before += $account_saldo_before; if ($code_level0 == "4") { $grand_total_pendapatan_debet += $account_debet; $grand_total_pendapatan_credit += $account_credit; $grand_total_pendapatan_before += $account_saldo_before; } elseif ($code_level0 == "5") { $grand_total_beban_debet += $account_debet; $grand_total_beban_credit += $account_credit; $grand_total_beban_before += $account_saldo_before; } } $code_level0_old = $code_level0; } //GRAND TOTAL LABA RUGI BERJALAN $grand_total_saldo = $saldo_awal + $grand_total_debet - $grand_total_credit; $grand_total_pendapatan_saldo = $grand_total_pendapatan_before + $grand_total_pendapatan_debet - $grand_total_pendapatan_credit; $grand_total_beban_saldo = $grand_total_beban_before + $grand_total_beban_debet - $grand_total_beban_credit; $laba_rugi = $grand_total_pendapatan_credit - $grand_total_beban_debet; //End of Hitung Laba Rugi $grand_total_debet = 0; $grand_total_credit = 0; $grand_total_before = 0; //ASET $objPHPExcel->getActiveSheet()->setCellValue("A5", "ASET"); $objPHPExcel->getActiveSheet()->getStyle("A5")->applyFromArray(array("font" => array("bold" => true, 'size' => 16))); $accounting = $this->accounting_model->get_all_accounting_aset()->result(); $no = 6; foreach ($accounting as $c) { $code = $c->accounting_code; $code_level0 = substr($code, 0, 1); $code_level1 = substr($code, 0, 3); $code_level2 = substr($code, 0, 5); $haschild = $c->accounting_haschild; $parent = $c->accounting_parent; $account_debet = 0; $account_credit = 0; $account_saldo = 0; $saldo_awal = 0; if ($code_level0_old != $code_level0) { $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", ""); } if ($haschild == "1" and $parent == "0") { //LEVEL 1 $account_debet = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $branch); $account_credit = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $branch); $account_debet_before = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start_before, $date_end_before, $branch); $account_credit_before = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start_before, $date_end_before, $branch); $account_saldo_before = $account_debet_before - $account_credit_before; $account_saldo = $account_saldo_before + $account_debet - $account_credit; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", $c->accounting_code . " " . $c->accounting_name); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_saldo_before < 0 ? "(" . number_format(abs($account_saldo_before)) . ")" : number_format($account_saldo_before)); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", number_format($account_debet)); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", number_format($account_credit)); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_saldo < 0 ? "(" . number_format(abs($account_saldo)) . ")" : number_format($account_saldo)); $objPHPExcel->getActiveSheet()->getStyle("A{$no}:E{$no}")->applyFromArray(array("font" => array("bold" => true))); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:E{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); } elseif ($haschild == "1" and $parent != "0") { //LEVEL 2 $account_debet = $this->jurnal_model->sum_account_parent_debet_by_date($code_level2, $date_start, $date_end, $branch); $account_credit = $this->jurnal_model->sum_account_parent_credit_by_date($code_level2, $date_start, $date_end, $branch); $account_debet_before = $this->jurnal_model->sum_account_parent_debet_by_date($code_level2, $date_start_before, $date_end_before, $branch); $account_credit_before = $this->jurnal_model->sum_account_parent_credit_by_date($code_level2, $date_start_before, $date_end_before, $branch); $account_saldo_before = $account_debet_before - $account_credit_before; $account_saldo = $account_saldo_before + $account_debet - $account_credit; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", " " . $c->accounting_code . " " . $c->accounting_name); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_saldo_before < 0 ? "(" . number_format(abs($account_saldo_before)) . ")" : number_format($account_saldo_before)); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", number_format($account_debet)); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", number_format($account_credit)); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_saldo < 0 ? "(" . number_format(abs($account_saldo)) . ")" : number_format($account_saldo)); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:E{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); } else { //LEVEL 3 $account_debet = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_credit = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_debet_before = $this->jurnal_model->sum_account_debet_by_date($code, $date_start_before, $date_end_before, $branch); $account_credit_before = $this->jurnal_model->sum_account_credit_by_date($code, $date_start_before, $date_end_before, $branch); $account_saldo_before = $account_debet_before - $account_credit_before; $account_saldo = $account_saldo_before + $account_debet - $account_credit; //grand total dihitung dari total account level 3 $grand_total_debet += $account_debet; $grand_total_credit += $account_credit; $grand_total_before += $account_saldo_before; $grand_total_aktiva_debet += $account_debet; $grand_total_aktiva_credit += $account_credit; $grand_total_aktiva_before += $account_saldo_before; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", " " . $c->accounting_code . " " . $c->accounting_name); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_saldo_before < 0 ? "(" . number_format(abs($account_saldo_before)) . ")" : number_format($account_saldo_before)); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", number_format($account_debet)); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", number_format($account_credit)); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_saldo < 0 ? "(" . number_format(abs($account_saldo)) . ")" : number_format($account_saldo)); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:E{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); } $code_level0_old = $code_level0; $no++; } $grand_total_aktiva_saldo = $grand_total_aktiva_before + $grand_total_aktiva_debet - $grand_total_aktiva_credit; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", "TOTAL ASET"); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $grand_total_aktiva_before < 0 ? "(" . number_format(abs($grand_total_aktiva_before)) . ")" : number_format($grand_total_aktiva_before)); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", number_format($grand_total_aktiva_debet)); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", number_format($grand_total_aktiva_credit)); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $grand_total_aktiva_saldo < 0 ? "(" . number_format(abs($grand_total_aktiva_saldo)) . ")" : number_format($grand_total_aktiva_saldo)); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:E{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle("A{$no}:E{$no}")->applyFromArray(array("font" => array("bold" => true))); $no++; //reset $grand_total_debet = 0; $grand_total_credit = 0; $grand_total_before = 0; $grand_total_aktiva_before = 0; $grand_total_aktiva_debet = 0; $grand_total_aktiva_credit = 0; $grand_total_aktiva_saldo = 0; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", ""); $no++; //KEWAJIBAN $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", "KEWAJIBAN"); $objPHPExcel->getActiveSheet()->getStyle("A{$no}")->applyFromArray(array("font" => array("bold" => true, 'size' => 16))); $no++; $accounting = $this->accounting_model->get_all_accounting_kewajiban()->result(); foreach ($accounting as $c) { $code = $c->accounting_code; $code_level0 = substr($code, 0, 1); $code_level1 = substr($code, 0, 3); $code_level2 = substr($code, 0, 5); $haschild = $c->accounting_haschild; $parent = $c->accounting_parent; $account_debet = 0; $account_credit = 0; $account_saldo = 0; $saldo_awal = 0; if ($code_level0_old != $code_level0) { $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", ""); } if ($haschild == "1" and $parent == "0") { //LEVEL 1 $account_debet = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $branch); $account_credit = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $branch); $account_debet_before = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start_before, $date_end_before, $branch); $account_credit_before = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start_before, $date_end_before, $branch); $account_saldo_before = $account_debet_before - $account_credit_before; $account_saldo = $account_saldo_before + $account_debet - $account_credit; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", $c->accounting_code . " " . $c->accounting_name); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_saldo_before < 0 ? "(" . number_format(abs($account_saldo_before)) . ")" : number_format($account_saldo_before)); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", number_format($account_debet)); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", number_format($account_credit)); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_saldo < 0 ? "(" . number_format(abs($account_saldo)) . ")" : number_format($account_saldo)); $objPHPExcel->getActiveSheet()->getStyle("A{$no}:E{$no}")->applyFromArray(array("font" => array("bold" => true))); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:E{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); } elseif ($haschild == "1" and $parent != "0") { //LEVEL 2 $account_debet = $this->jurnal_model->sum_account_parent_debet_by_date($code_level2, $date_start, $date_end, $branch); $account_credit = $this->jurnal_model->sum_account_parent_credit_by_date($code_level2, $date_start, $date_end, $branch); $account_debet_before = $this->jurnal_model->sum_account_parent_debet_by_date($code_level2, $date_start_before, $date_end_before, $branch); $account_credit_before = $this->jurnal_model->sum_account_parent_credit_by_date($code_level2, $date_start_before, $date_end_before, $branch); $account_saldo_before = $account_debet_before - $account_credit_before; $account_saldo = $account_saldo_before + $account_debet - $account_credit; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", " " . $c->accounting_code . " " . $c->accounting_name); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_saldo_before < 0 ? "(" . number_format(abs($account_saldo_before)) . ")" : number_format($account_saldo_before)); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", number_format($account_debet)); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", number_format($account_credit)); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_saldo < 0 ? "(" . number_format(abs($account_saldo)) . ")" : number_format($account_saldo)); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:E{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); } else { //LEVEL 3 $account_debet = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_credit = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_debet_before = $this->jurnal_model->sum_account_debet_by_date($code, $date_start_before, $date_end_before, $branch); $account_credit_before = $this->jurnal_model->sum_account_credit_by_date($code, $date_start_before, $date_end_before, $branch); $account_saldo_before = $account_debet_before - $account_credit_before; $account_saldo = $account_saldo_before + $account_debet - $account_credit; //grand total dihitung dari total account level 3 $grand_total_debet += $account_debet; $grand_total_credit += $account_credit; $grand_total_before += $account_saldo_before; $grand_total_aktiva_debet += $account_debet; $grand_total_aktiva_credit += $account_credit; $grand_total_aktiva_before += $account_saldo_before; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", " " . $c->accounting_code . " " . $c->accounting_name); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_saldo_before < 0 ? "(" . number_format(abs($account_saldo_before)) . ")" : number_format($account_saldo_before)); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", number_format($account_debet)); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", number_format($account_credit)); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_saldo < 0 ? "(" . number_format(abs($account_saldo)) . ")" : number_format($account_saldo)); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:E{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); } $code_level0_old = $code_level0; $no++; } $grand_total_aktiva_saldo = $grand_total_aktiva_before + $grand_total_aktiva_debet - $grand_total_aktiva_credit; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", "TOTAL KEWAJIBAN"); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $grand_total_aktiva_before < 0 ? "(" . number_format(abs($grand_total_aktiva_before)) . ")" : number_format($grand_total_aktiva_before)); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", number_format($grand_total_aktiva_debet)); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", number_format($grand_total_aktiva_credit)); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $grand_total_aktiva_saldo < 0 ? "(" . number_format(abs($grand_total_aktiva_saldo)) . ")" : number_format($grand_total_aktiva_saldo)); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:E{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle("A{$no}:E{$no}")->applyFromArray(array("font" => array("bold" => true))); $no++; //reset $grand_total_debet = 0; $grand_total_credit = 0; $grand_total_before = 0; $grand_total_aktiva_before = 0; $grand_total_aktiva_debet = 0; $grand_total_aktiva_credit = 0; $grand_total_aktiva_saldo = 0; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", ""); $no++; //MODAL $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", "MODAL"); $objPHPExcel->getActiveSheet()->getStyle("A{$no}")->applyFromArray(array("font" => array("bold" => true, 'size' => 16))); $no++; $accounting = $this->accounting_model->get_all_accounting_modal()->result(); foreach ($accounting as $c) { $code = $c->accounting_code; $code_level0 = substr($code, 0, 1); $code_level1 = substr($code, 0, 3); $code_level2 = substr($code, 0, 5); $haschild = $c->accounting_haschild; $parent = $c->accounting_parent; $account_debet = 0; $account_credit = 0; $account_saldo = 0; $saldo_awal = 0; if ($code_level0_old != $code_level0) { $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", ""); } if ($haschild == "1" and $parent == "0") { //LEVEL 1 $account_debet = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $branch); $account_credit = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $branch); $account_debet_before = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start_before, $date_end_before, $branch); $account_credit_before = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start_before, $date_end_before, $branch); $account_saldo_before = $account_debet_before - $account_credit_before; $account_saldo = $account_saldo_before + $account_debet - $account_credit; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", $c->accounting_code . " " . $c->accounting_name); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_saldo_before < 0 ? "(" . number_format(abs($account_saldo_before)) . ")" : number_format($account_saldo_before)); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", number_format($account_debet)); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", number_format($account_credit)); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_saldo < 0 ? "(" . number_format(abs($account_saldo)) . ")" : number_format($account_saldo)); $objPHPExcel->getActiveSheet()->getStyle("A{$no}:E{$no}")->applyFromArray(array("font" => array("bold" => true))); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:E{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); } elseif ($haschild == "1" and $parent != "0") { //LEVEL 2 $account_debet = $this->jurnal_model->sum_account_parent_debet_by_date($code_level2, $date_start, $date_end, $branch); $account_credit = $this->jurnal_model->sum_account_parent_credit_by_date($code_level2, $date_start, $date_end, $branch); $account_debet_before = $this->jurnal_model->sum_account_parent_debet_by_date($code_level2, $date_start_before, $date_end_before, $branch); $account_credit_before = $this->jurnal_model->sum_account_parent_credit_by_date($code_level2, $date_start_before, $date_end_before, $branch); $account_saldo_before = $account_debet_before - $account_credit_before; $account_saldo = $account_saldo_before + $account_debet - $account_credit; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", " " . $c->accounting_code . " " . $c->accounting_name); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_saldo_before < 0 ? "(" . number_format(abs($account_saldo_before)) . ")" : number_format($account_saldo_before)); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", number_format($account_debet)); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", number_format($account_credit)); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_saldo < 0 ? "(" . number_format(abs($account_saldo)) . ")" : number_format($account_saldo)); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:E{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); } else { //LEVEL 3 $account_debet = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_credit = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_debet_before = $this->jurnal_model->sum_account_debet_by_date($code, $date_start_before, $date_end_before, $branch); $account_credit_before = $this->jurnal_model->sum_account_credit_by_date($code, $date_start_before, $date_end_before, $branch); $account_saldo_before = $account_debet_before - $account_credit_before; if ($c->accounting_code == "3020002") { $account_saldo_before = $laba_rugi; } $account_saldo = $account_saldo_before + $account_debet - $account_credit; //grand total dihitung dari total account level 3 $grand_total_debet += $account_debet; $grand_total_credit += $account_credit; $grand_total_before += $account_saldo_before; $grand_total_aktiva_debet += $account_debet; $grand_total_aktiva_credit += $account_credit; $grand_total_aktiva_before += $account_saldo_before; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", " " . $c->accounting_code . " " . $c->accounting_name); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_saldo_before < 0 ? "(" . number_format(abs($account_saldo_before)) . ")" : number_format($account_saldo_before)); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", number_format($account_debet)); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", number_format($account_credit)); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_saldo < 0 ? "(" . number_format(abs($account_saldo)) . ")" : number_format($account_saldo)); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:E{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); } $code_level0_old = $code_level0; $no++; } $grand_total_aktiva_saldo = $grand_total_aktiva_before + $grand_total_aktiva_debet - $grand_total_aktiva_credit; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", "TOTAL MODAL"); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $grand_total_aktiva_before < 0 ? "(" . number_format(abs($grand_total_aktiva_before)) . ")" : number_format($grand_total_aktiva_before)); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", number_format($grand_total_aktiva_debet)); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", number_format($grand_total_aktiva_credit)); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $grand_total_aktiva_saldo < 0 ? "(" . number_format(abs($grand_total_aktiva_saldo)) . ")" : number_format($grand_total_aktiva_saldo)); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:E{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle("A{$no}:E{$no}")->applyFromArray(array("font" => array("bold" => true))); $no++; //EXPORT $filename = "Neraca_" . $branch_name . "_" . time() . '.xls'; //save our workbook as this file name header('Content-Type: application/vnd.ms-excel'); //mime type header('Content-Disposition: attachment;filename="' . $filename . '"'); //tell browser what's the file name header('Cache-Control: max-age=0'); //no cache $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output'); redirect('accounting/neraca', 'refresh'); } else { //If no session, redirect to login page redirect('login', 'refresh'); } }
public function labarugi_excel() { if ($this->session->userdata('logged_in')) { //Cek User Branch $user_branch = $this->session->userdata('user_branch'); function getStartAndEndDate($week, $year) { $time = strtotime("1 January {$year}", time()); $day = date('w', $time); $time += (7 * $week + 1 - $day) * 24 * 3600; $return[0] = date('Y-n-j', $time); $time += 6 * 24 * 3600; $return[1] = date('Y-n-j', $time); return $return; } $date_today = date("Y-m-d"); $date_year_today = date("Y"); $date_week_today = date("W", strtotime($date_today)) - 1; $date_week_before = $date_week_today - 1; $week_today = getStartAndEndDate($date_week_today, $date_year_today); $date_start = $this->uri->segment(3); $date_end = $this->uri->segment(4); if ($date_start and $date_end and $date_start <= $date_end) { $date_start = $this->uri->segment(3); $date_end = $this->uri->segment(4); } else { //$date_start =$week_today[0]; $date_start = "2013-01-01"; $date_end = date("Y-m-d"); } $date_end_before = strtotime($date_start); //$date_end_before = $date_start; $date_end_before = strtotime("-1 day", $date_end_before); $date_end_before = date('Y-m-d', $date_end_before); $date_start_before = "2013-01-01"; //echo $date_start_before." ----- ".$date_end_before; $account_debet = 0; $account_credit = 0; $account_saldo = 0; $saldo_awal = 0; //load our new PHPExcel library $this->load->library('excel'); $objPHPExcel = new PHPExcel(); $style_border_top_btm = array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'top' => array('style' => PHPExcel_Style_Border::BORDER_THIN))); $style_border_top_btm_double = array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_DOUBLE), 'top' => array('style' => PHPExcel_Style_Border::BORDER_THIN))); $objPHPExcel->getProperties()->setCreator("Amartha MIS"); $objPHPExcel->getProperties()->setLastModifiedBy("Amartha MIS"); $objPHPExcel->getProperties()->setTitle("Laba Rugi Konsolidasi"); $objPHPExcel->getProperties()->setSubject("Laba Rugi Konsolidasi"); $objPHPExcel->getProperties()->setDescription("Laba Rugi Konsolidasi"); $objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->getActiveSheet()->setTitle('Laba Rugi Konsolidasi'); //TITLE $objPHPExcel->getActiveSheet()->setCellValue("A1", "Laba Rugi Konsolidasi"); $objPHPExcel->getActiveSheet()->setCellValue("A2", "Amartha Microfinance"); $objPHPExcel->getActiveSheet()->setCellValue("A3", $date_start . " s/d " . $date_end); $objPHPExcel->getActiveSheet()->mergeCells("A1:D1"); $objPHPExcel->getActiveSheet()->getStyle("A1")->applyFromArray(array("font" => array("bold" => true, 'size' => 16))); $objPHPExcel->getActiveSheet()->getStyle("A2")->applyFromArray(array("font" => array("bold" => true))); $objPHPExcel->getActiveSheet()->getStyle("A3")->applyFromArray(array("font" => array("bold" => true))); //TOP ROW $objPHPExcel->getActiveSheet()->getStyle("A4:I4")->applyFromArray(array("font" => array("bold" => true))); $objPHPExcel->getActiveSheet()->getStyle("B4:I4")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->setCellValue("A4", ""); $objPHPExcel->getActiveSheet()->getColumnDimension("A")->setWidth(50); $objPHPExcel->getActiveSheet()->setCellValue("B4", "KONSOLIDASI"); $objPHPExcel->getActiveSheet()->getColumnDimension("B4")->setWidth(25); $objPHPExcel->getActiveSheet()->setCellValue("C4", "PUSAT"); $objPHPExcel->getActiveSheet()->getColumnDimension("C4")->setWidth(25); $objPHPExcel->getActiveSheet()->setCellValue("D4", "CS"); $objPHPExcel->getActiveSheet()->getColumnDimension("D4")->setWidth(25); $objPHPExcel->getActiveSheet()->setCellValue("E4", "JS"); $objPHPExcel->getActiveSheet()->getColumnDimension("E4")->setWidth(25); $objPHPExcel->getActiveSheet()->setCellValue("F4", "BG"); $objPHPExcel->getActiveSheet()->getColumnDimension("F4")->setWidth(25); $objPHPExcel->getActiveSheet()->setCellValue("G4", "KM"); $objPHPExcel->getActiveSheet()->getColumnDimension("G4")->setWidth(25); $objPHPExcel->getActiveSheet()->setCellValue("H4", "TN"); $objPHPExcel->getActiveSheet()->getColumnDimension("H4")->setWidth(25); $objPHPExcel->getActiveSheet()->setCellValue("I4", "CK"); $objPHPExcel->getActiveSheet()->getColumnDimension("I4")->setWidth(25); //PENDAPATAN $print .= ' <tr><td align="left" ><b>Pendapatan</b></td> <td colspan="9" ></td></tr>'; $cell_no = 5; $objPHPExcel->getActiveSheet()->setCellValue("A{$cell_no}", "Pendapatan"); //Kas //1010000 $code = "1010000"; $code_level1 = substr($code, 0, 3); for ($branch = 0; $branch <= 7; $branch++) { $account_1010000_debet[$branch] = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $branch); $account_1010000_credit[$branch] = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $branch); $account_1010000[$branch] = $account_1010000_debet[$branch] - $account_1010000_credit[$branch]; $account_1010000_konsolidasi += $account_1010000[$branch]; $account_kas[$branch] += $account_1010000[$branch]; $account_aset_lancar[$branch] += $account_1010000[$branch]; } //1020000 $code = "1020000"; $code_level1 = substr($code, 0, 3); for ($branch = 0; $branch <= 7; $branch++) { $account_1020000_debet[$branch] = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $branch); $account_1020000_credit[$branch] = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $branch); $account_1020000[$branch] = $account_1020000_debet[$branch] - $account_1020000_credit[$branch]; $account_1020000_konsolidasi += $account_1020000[$branch]; $account_kas[$branch] += $account_1020000[$branch]; $account_aset_lancar[$branch] += $account_1020000[$branch]; } //Total Kas $account_kas_konsolidasi = $account_1010000_konsolidasi + $account_1020000_konsolidasi; $objPHPExcel->getActiveSheet()->getStyle("A4:A6")->applyFromArray(array("font" => array("bold" => true))); $objPHPExcel->getActiveSheet()->setCellValue("A7", " Kas dan setara Kas"); $objPHPExcel->getActiveSheet()->setCellValue("B7", $account_kas_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C7", $account_kas[0]); $objPHPExcel->getActiveSheet()->setCellValue("D7", $account_kas[1]); $objPHPExcel->getActiveSheet()->setCellValue("E7", $account_kas[4]); $objPHPExcel->getActiveSheet()->setCellValue("F7", $account_kas[3]); $objPHPExcel->getActiveSheet()->setCellValue("G7", $account_kas[2]); $objPHPExcel->getActiveSheet()->setCellValue("H7", $account_kas[5]); $objPHPExcel->getActiveSheet()->setCellValue("I7", $account_kas[6]); $objPHPExcel->getActiveSheet()->getStyle("B7:I7")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); //Piutang MBA 1030102 $code = "1030102"; for ($branch = 0; $branch <= 7; $branch++) { $account_1030102_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_1030102_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_1030102[$branch] = $account_1030102_debet[$branch] - $account_1030102_credit[$branch]; $account_1030102_konsolidasi += $account_1030102[$branch]; $account_piutang_pembiayaan[$branch] += $account_1030102[$branch]; $account_aset_lancar[$branch] += $account_1030102[$branch]; } //Piutang IJA 1030103 $code = "1030103"; for ($branch = 0; $branch <= 7; $branch++) { $account_1030103_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_1030103_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_1030103[$branch] = $account_1030103_debet[$branch] - $account_1030103_credit[$branch]; $account_1030103_konsolidasi += $account_1030103[$branch]; $account_piutang_pembiayaan[$branch] += $account_1030103[$branch]; $account_aset_lancar[$branch] += $account_1030103[$branch]; } //Piutang QH 1030104 $code = "1030104"; for ($branch = 0; $branch <= 7; $branch++) { $account_1030104_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_1030104_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_1030104[$branch] = $account_1030104_debet[$branch] - $account_1030104_credit[$branch]; $account_1030104_konsolidasi += $account_1030104[$branch]; $account_piutang_pembiayaan[$branch] += $account_1030104[$branch]; $account_aset_lancar[$branch] += $account_1030104[$branch]; } //Piutang Pembiayaan Lembaga 1030200 //Piutang QH 1030504 $code = "1030504"; for ($branch = 0; $branch <= 7; $branch++) { $account_1030504_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_1030504_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_1030104[$branch] = $account_1030504_debet[$branch] - $account_1030504_credit[$branch]; $account_1030104_konsolidasi += $account_1030104[$branch]; $account_piutang_pembiayaan[$branch] += $account_1030104[$branch]; $account_aset_lancar[$branch] += $account_1030104[$branch]; } $code = "1030200"; $code_level2 = substr($code, 0, 5); for ($branch = 0; $branch <= 7; $branch++) { $account_1030200_debet[$branch] = $this->jurnal_model->sum_account_parent_debet_by_date($code_level2, $date_start, $date_end, $branch); $account_1030200_credit[$branch] = $this->jurnal_model->sum_account_parent_credit_by_date($code_level2, $date_start, $date_end, $branch); $account_1030200[$branch] = $account_1030200_debet[$branch] - $account_1030200_credit[$branch]; $account_1030104[$branch] += $account_1030200[$branch]; $account_1030104_konsolidasi += $account_1030200[$branch]; $account_piutang_pembiayaan[$branch] += $account_1030200[$branch]; $account_aset_lancar[$branch] += $account_1030200[$branch]; } /* //Piutang Cabang 1030400 $code = "1030400"; $code_level2 = substr($code,0,5); for($branch=0; $branch <=7; $branch++){ $account_1030400_debet[$branch] = $this->jurnal_model->sum_account_parent_debet_by_date($code_level2,$date_start,$date_end,$branch); $account_1030400_credit[$branch] = $this->jurnal_model->sum_account_parent_credit_by_date($code_level2,$date_start,$date_end,$branch); $account_1030400[$branch] = $account_1030400_debet[$branch] - $account_1030400_credit[$branch]; //$account_1030400_konsolidasi += $account_1030400[$branch]; $account_1030400_konsolidasi = 0; $account_piutang_pembiayaan[$branch] += $account_1030400[$branch]; $account_aset_lancar[$branch] += $account_1030400[$branch]; } */ $account_piutang_pembiayaan_konsolidasi = $account_1030102_konsolidasi + $account_1030103_konsolidasi + +$account_1030104_konsolidasi + $account_1030400_konsolidasi; $objPHPExcel->getActiveSheet()->setCellValue("A8", " Piutang Pembiayaan"); $objPHPExcel->getActiveSheet()->setCellValue("B8", $account_piutang_pembiayaan_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C8", $account_piutang_pembiayaan[0]); $objPHPExcel->getActiveSheet()->setCellValue("D8", $account_piutang_pembiayaan[1]); $objPHPExcel->getActiveSheet()->setCellValue("E8", $account_piutang_pembiayaan[4]); $objPHPExcel->getActiveSheet()->setCellValue("F8", $account_piutang_pembiayaan[3]); $objPHPExcel->getActiveSheet()->setCellValue("G8", $account_piutang_pembiayaan[2]); $objPHPExcel->getActiveSheet()->setCellValue("H8", $account_piutang_pembiayaan[5]); $objPHPExcel->getActiveSheet()->setCellValue("I8", $account_piutang_pembiayaan[6]); $objPHPExcel->getActiveSheet()->getStyle("B8:I8")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->setCellValue("A9", " Murabahah"); $objPHPExcel->getActiveSheet()->setCellValue("B9", $account_1030102_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C9", $account_1030102[0]); $objPHPExcel->getActiveSheet()->setCellValue("D9", $account_1030102[1]); $objPHPExcel->getActiveSheet()->setCellValue("E9", $account_1030102[4]); $objPHPExcel->getActiveSheet()->setCellValue("F9", $account_1030102[3]); $objPHPExcel->getActiveSheet()->setCellValue("G9", $account_1030102[2]); $objPHPExcel->getActiveSheet()->setCellValue("H9", $account_1030102[5]); $objPHPExcel->getActiveSheet()->setCellValue("I9", $account_1030102[6]); $objPHPExcel->getActiveSheet()->getStyle("B9:I9")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->setCellValue("A10", " Ijarah"); $objPHPExcel->getActiveSheet()->setCellValue("B10", $account_1030103_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C10", $account_1030103[0]); $objPHPExcel->getActiveSheet()->setCellValue("D10", $account_1030103[1]); $objPHPExcel->getActiveSheet()->setCellValue("E10", $account_1030103[4]); $objPHPExcel->getActiveSheet()->setCellValue("F10", $account_1030103[3]); $objPHPExcel->getActiveSheet()->setCellValue("G10", $account_1030103[2]); $objPHPExcel->getActiveSheet()->setCellValue("H10", $account_1030103[5]); $objPHPExcel->getActiveSheet()->setCellValue("I10", $account_1030103[6]); $objPHPExcel->getActiveSheet()->getStyle("B10:I10")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->setCellValue("A11", " Qadrul Hasan"); $objPHPExcel->getActiveSheet()->setCellValue("B11", $account_1030104_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C11", $account_1030104[0]); $objPHPExcel->getActiveSheet()->setCellValue("D11", $account_1030104[1]); $objPHPExcel->getActiveSheet()->setCellValue("E11", $account_1030104[4]); $objPHPExcel->getActiveSheet()->setCellValue("F11", $account_1030104[3]); $objPHPExcel->getActiveSheet()->setCellValue("G11", $account_1030104[2]); $objPHPExcel->getActiveSheet()->setCellValue("H11", $account_1030104[5]); $objPHPExcel->getActiveSheet()->setCellValue("I11", $account_1030104[6]); $objPHPExcel->getActiveSheet()->getStyle("B11:I11")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); //Beban dibayar dimuka 1050000 $code = "1050000"; $code_level1 = substr($code, 0, 3); for ($branch = 0; $branch <= 7; $branch++) { $account_1050000_debet[$branch] = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $branch); $account_1050000_credit[$branch] = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $branch); $account_1050000[$branch] = $account_1050000_debet[$branch] - $account_1050000_credit[$branch]; $account_1050000_konsolidasi += $account_1050000[$branch]; $account_aset_lancar[$branch] += $account_1050000[$branch]; } //Persediaan Barang Cetakan 1060000 $code = "1060000"; $code_level1 = substr($code, 0, 3); for ($branch = 0; $branch <= 7; $branch++) { $account_1060000_debet[$branch] = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $branch); $account_1060000_credit[$branch] = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $branch); $account_1060000[$branch] = $account_1060000_debet[$branch] - $account_1060000_credit[$branch]; $account_1060000_konsolidasi += $account_1060000[$branch]; $account_aset_lancar[$branch] += $account_1060000[$branch]; } $account_aset_lancar_konsolidasi = $account_kas_konsolidasi + $account_piutang_pembiayaan_konsolidasi + $account_1060000_konsolidasi + $account_1050000_konsolidasi; $objPHPExcel->getActiveSheet()->setCellValue("A13", " Beban dibayar dimuka"); $objPHPExcel->getActiveSheet()->setCellValue("B13", $account_1050000_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C13", $account_1050000[0]); $objPHPExcel->getActiveSheet()->setCellValue("D13", $account_1050000[1]); $objPHPExcel->getActiveSheet()->setCellValue("E13", $account_1050000[4]); $objPHPExcel->getActiveSheet()->setCellValue("F13", $account_1050000[3]); $objPHPExcel->getActiveSheet()->setCellValue("G13", $account_1050000[2]); $objPHPExcel->getActiveSheet()->setCellValue("H13", $account_1050000[5]); $objPHPExcel->getActiveSheet()->setCellValue("I13", $account_1050000[6]); $objPHPExcel->getActiveSheet()->getStyle("B13:I13")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->setCellValue("A14", " Persediaan Barang Cetakan"); $objPHPExcel->getActiveSheet()->setCellValue("B14", $account_1060000_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C14", $account_1060000[0]); $objPHPExcel->getActiveSheet()->setCellValue("D14", $account_1060000[1]); $objPHPExcel->getActiveSheet()->setCellValue("E14", $account_1060000[4]); $objPHPExcel->getActiveSheet()->setCellValue("F14", $account_1060000[3]); $objPHPExcel->getActiveSheet()->setCellValue("G14", $account_1060000[2]); $objPHPExcel->getActiveSheet()->setCellValue("H14", $account_1060000[5]); $objPHPExcel->getActiveSheet()->setCellValue("I14", $account_1060000[6]); $objPHPExcel->getActiveSheet()->getStyle("B14:I14")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->setCellValue("A14", "Jumlah Aset Lancar"); $objPHPExcel->getActiveSheet()->setCellValue("B14", $account_aset_lancar_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C14", $account_aset_lancar[0]); $objPHPExcel->getActiveSheet()->setCellValue("D14", $account_aset_lancar[1]); $objPHPExcel->getActiveSheet()->setCellValue("E14", $account_aset_lancar[4]); $objPHPExcel->getActiveSheet()->setCellValue("F14", $account_aset_lancar[3]); $objPHPExcel->getActiveSheet()->setCellValue("G14", $account_aset_lancar[2]); $objPHPExcel->getActiveSheet()->setCellValue("H14", $account_aset_lancar[5]); $objPHPExcel->getActiveSheet()->setCellValue("I14", $account_aset_lancar[6]); $objPHPExcel->getActiveSheet()->getStyle("B14:I14")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle('B14:I14')->applyFromArray($style_border_top_btm); //ASET TIDAK LANCAR $objPHPExcel->getActiveSheet()->setCellValue("A16", "ASET TIDAK LANCAR"); $objPHPExcel->getActiveSheet()->getStyle("A16")->applyFromArray(array("font" => array("bold" => true))); //Aset Tetap setelah dikurangi = 1080301 + 1080302 $code = "1080301"; for ($branch = 0; $branch <= 7; $branch++) { $account_1080301_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_1080301_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_1080301[$branch] = $account_1080301_debet[$branch] - $account_1080301_credit[$branch]; $account_1080301_konsolidasi += $account_1080301[$branch]; $account_aset_tetap[$branch] += $account_1080301[$branch]; $account_aset_tidak_lancar[$branch] += $account_1080301[$branch]; } $code = "1080302"; for ($branch = 0; $branch <= 7; $branch++) { $account_1080302_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_1080302_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_1080302[$branch] = $account_1080302_debet[$branch] - $account_1080302_credit[$branch]; $account_1080302_konsolidasi += $account_1080302[$branch]; $account_aset_tetap[$branch] += $account_1080302[$branch]; $account_aset_tidak_lancar[$branch] += $account_1080302[$branch]; } $account_aset_tetap_konsolidasi = $account_1080301_konsolidasi + $account_1080302_konsolidasi; //Aset Lain 1090000 $code = "1090000"; $code_level1 = substr($code, 0, 3); for ($branch = 0; $branch <= 7; $branch++) { $account_1090000_debet[$branch] = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $branch); $account_1090000_credit[$branch] = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $branch); $account_1090000[$branch] = $account_1090000_debet[$branch] - $account_1090000_credit[$branch]; $account_aset_lain_konsolidasi += $account_1090000[$branch]; $account_aset_tidak_lancar[$branch] += $account_1090000[$branch]; } $account_aset_tidak_lancar_konsolidasi = $account_aset_tetap_konsolidasi + $account_aset_lain_konsolidasi; $objPHPExcel->getActiveSheet()->setCellValue("A17", " Aset Tetap - setelah dikurangi"); $objPHPExcel->getActiveSheet()->setCellValue("B17", $account_aset_tetap_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C17", $account_aset_tetap[0]); $objPHPExcel->getActiveSheet()->setCellValue("D17", $account_aset_tetap[1]); $objPHPExcel->getActiveSheet()->setCellValue("E17", $account_aset_tetap[4]); $objPHPExcel->getActiveSheet()->setCellValue("F17", $account_aset_tetap[3]); $objPHPExcel->getActiveSheet()->setCellValue("G17", $account_aset_tetap[2]); $objPHPExcel->getActiveSheet()->setCellValue("H17", $account_aset_tetap[5]); $objPHPExcel->getActiveSheet()->setCellValue("I17", $account_aset_tetap[6]); $objPHPExcel->getActiveSheet()->setCellValue("A18", " Aset Lain"); $objPHPExcel->getActiveSheet()->setCellValue("B18", $account_aset_lain_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C18", $account_1090000[0]); $objPHPExcel->getActiveSheet()->setCellValue("D18", $account_1090000[1]); $objPHPExcel->getActiveSheet()->setCellValue("E18", $account_1090000[4]); $objPHPExcel->getActiveSheet()->setCellValue("F18", $account_1090000[3]); $objPHPExcel->getActiveSheet()->setCellValue("G18", $account_1090000[2]); $objPHPExcel->getActiveSheet()->setCellValue("H18", $account_1090000[5]); $objPHPExcel->getActiveSheet()->setCellValue("I18", $account_1090000[6]); $objPHPExcel->getActiveSheet()->setCellValue("A19", "Jumlah Aset Tidak Lancar"); $objPHPExcel->getActiveSheet()->setCellValue("B19", $account_aset_tidak_lancar_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C19", $account_aset_tidak_lancar[0]); $objPHPExcel->getActiveSheet()->setCellValue("D19", $account_aset_tidak_lancar[1]); $objPHPExcel->getActiveSheet()->setCellValue("E19", $account_aset_tidak_lancar[4]); $objPHPExcel->getActiveSheet()->setCellValue("F19", $account_aset_tidak_lancar[3]); $objPHPExcel->getActiveSheet()->setCellValue("G19", $account_aset_tidak_lancar[2]); $objPHPExcel->getActiveSheet()->setCellValue("H19", $account_aset_tidak_lancar[5]); $objPHPExcel->getActiveSheet()->setCellValue("I19", $account_aset_tidak_lancar[6]); $objPHPExcel->getActiveSheet()->getStyle("B17:I19")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle('B19:I19')->applyFromArray($style_border_top_btm); //JUMLAH ASET for ($branch = 0; $branch <= 7; $branch++) { $account_aset[$branch] += $account_aset_lancar[$branch] + $account_aset_tidak_lancar[$branch]; $account_aset_konsolidasi += $account_aset_lancar[$branch] + $account_aset_tidak_lancar[$branch]; } $account_aset_tidak_lancar_konsolidasi = $account_aset_tetap_konsolidasi + $account_aset_lain_konsolidasi; $objPHPExcel->getActiveSheet()->setCellValue("A21", "JUMLAH ASET"); $objPHPExcel->getActiveSheet()->setCellValue("B21", $account_aset_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C21", $account_aset[0]); $objPHPExcel->getActiveSheet()->setCellValue("D21", $account_aset[1]); $objPHPExcel->getActiveSheet()->setCellValue("E21", $account_aset[4]); $objPHPExcel->getActiveSheet()->setCellValue("F21", $account_aset[3]); $objPHPExcel->getActiveSheet()->setCellValue("G21", $account_aset[2]); $objPHPExcel->getActiveSheet()->setCellValue("H21", $account_aset[5]); $objPHPExcel->getActiveSheet()->setCellValue("I21", $account_aset[6]); $objPHPExcel->getActiveSheet()->getStyle("H21:I21")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle('B21:I21')->applyFromArray($style_border_top_btm_double); $objPHPExcel->getActiveSheet()->getStyle("A21:I21")->applyFromArray(array("font" => array("bold" => true))); //LIABILITAS $objPHPExcel->getActiveSheet()->setCellValue("A23", "LIABILITAS DAN EKUITAS"); $objPHPExcel->getActiveSheet()->setCellValue("A24", "LIABILITAS JANGKA PENDEK"); $objPHPExcel->getActiveSheet()->getStyle("A23:A24")->applyFromArray(array("font" => array("bold" => true))); //Simpanan Anggota 2010000 $code = "2010000"; $code_level1 = substr($code, 0, 3); for ($branch = 0; $branch <= 7; $branch++) { $account_2010000_debet[$branch] = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $branch); $account_2010000_credit[$branch] = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $branch); $account_2010000[$branch] = $account_2010000_credit[$branch] - $account_2010000_debet[$branch]; $account_2010000_konsolidasi += $account_2010000[$branch]; $account_liabilitas[$branch] += $account_2010000[$branch]; } //Simpanan Berjangka 2020000 $code = "2020000"; $code_level1 = substr($code, 0, 3); for ($branch = 0; $branch <= 7; $branch++) { $account_2020000_debet[$branch] = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $branch); $account_2020000_credit[$branch] = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $branch); $account_2020000[$branch] = $account_2020000_credit[$branch] - $account_2020000_debet[$branch]; $account_2020000_konsolidasi += $account_2020000[$branch]; $account_liabilitas[$branch] += $account_2020000[$branch]; } //Hutang Pembiayaan 2030000 $code = "2030000"; $code_level1 = substr($code, 0, 3); for ($branch = 0; $branch <= 7; $branch++) { $account_2030000_debet[$branch] = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $branch); $account_2030000_credit[$branch] = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $branch); $account_2030000[$branch] = $account_2030000_credit[$branch] - $account_2030000_debet[$branch]; if ($branch != 0) { $account_2030000[$branch] = 0; } $account_2030000_konsolidasi += $account_2030000[$branch]; $account_liabilitas[$branch] += $account_2030000[$branch]; } /*//Hutang Pembiayaan Kantor Pusat 2030200*/ $code = "2030200"; $code_level2 = substr($code, 0, 5); for ($branch = 0; $branch <= 7; $branch++) { //$account_2030200_debet[$branch] = $this->jurnal_model->sum_account_parent_debet_by_date($code_level2,$date_start,$date_end,$branch); //$account_2030200_credit[$branch] = $this->jurnal_model->sum_account_parent_credit_by_date($code_level2,$date_start,$date_end,$branch); //$account_2030200[$branch] = $account_2030200_credit[$branch] - $account_2030200_debet[$branch]; $account_2030200[$branch] = 0; //if($branch==0) { $account_2030000[0] = 0; } $account_2030200_konsolidasi += $account_2030200[$branch]; $account_liabilitas[$branch] += $account_2030200[$branch]; } //Hutang Leasing 2040000 $code = "2040000"; $code_level1 = substr($code, 0, 3); for ($branch = 0; $branch <= 7; $branch++) { $account_2040000_debet[$branch] = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $branch); $account_2040000_credit[$branch] = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $branch); $account_2040000[$branch] = $account_2040000_credit[$branch] - $account_2040000_debet[$branch]; $account_2040000_konsolidasi += $account_2040000[$branch]; $account_liabilitas[$branch] += $account_2040000[$branch]; } //Hutang Lain-lain 2050000 $code = "2050000"; $code_level1 = substr($code, 0, 3); for ($branch = 0; $branch <= 7; $branch++) { $account_2050000_debet[$branch] = $this->jurnal_model->sum_account_parent_debet_by_date($code_level1, $date_start, $date_end, $branch); $account_2050000_credit[$branch] = $this->jurnal_model->sum_account_parent_credit_by_date($code_level1, $date_start, $date_end, $branch); $account_2050000[$branch] = $account_2050000_credit[$branch] - $account_2050000_debet[$branch]; $account_2050000_konsolidasi += $account_2050000[$branch]; $account_liabilitas[$branch] += $account_2050000[$branch]; } for ($branch = 0; $branch <= 7; $branch++) { $account_liabilitas_konsolidasi += $account_liabilitas[$branch]; } $objPHPExcel->getActiveSheet()->setCellValue("A25", " Simpanan Anggota"); $objPHPExcel->getActiveSheet()->setCellValue("B25", $account_2010000_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C25", $account_2010000[0]); $objPHPExcel->getActiveSheet()->setCellValue("D25", $account_2010000[1]); $objPHPExcel->getActiveSheet()->setCellValue("E25", $account_2010000[4]); $objPHPExcel->getActiveSheet()->setCellValue("F25", $account_2010000[3]); $objPHPExcel->getActiveSheet()->setCellValue("G25", $account_2010000[2]); $objPHPExcel->getActiveSheet()->setCellValue("H25", $account_2010000[5]); $objPHPExcel->getActiveSheet()->setCellValue("I25", $account_2010000[6]); $objPHPExcel->getActiveSheet()->getStyle("H25:I25")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->setCellValue("A26", " Simpanan Berjangka"); $objPHPExcel->getActiveSheet()->setCellValue("B26", $account_2020000_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C26", $account_2020000[0]); $objPHPExcel->getActiveSheet()->setCellValue("D26", $account_2020000[1]); $objPHPExcel->getActiveSheet()->setCellValue("E26", $account_2020000[4]); $objPHPExcel->getActiveSheet()->setCellValue("F26", $account_2020000[3]); $objPHPExcel->getActiveSheet()->setCellValue("G26", $account_2020000[2]); $objPHPExcel->getActiveSheet()->setCellValue("H26", $account_2020000[5]); $objPHPExcel->getActiveSheet()->setCellValue("I26", $account_2020000[6]); $objPHPExcel->getActiveSheet()->getStyle("H26:I26")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->setCellValue("A27", " Hutang Pembiayaan"); $objPHPExcel->getActiveSheet()->setCellValue("B27", $account_2030000_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C27", $account_2030000[0]); $objPHPExcel->getActiveSheet()->setCellValue("D27", $account_2030000[1]); $objPHPExcel->getActiveSheet()->setCellValue("E27", $account_2030000[4]); $objPHPExcel->getActiveSheet()->setCellValue("F27", $account_2030000[3]); $objPHPExcel->getActiveSheet()->setCellValue("G27", $account_2030000[2]); $objPHPExcel->getActiveSheet()->setCellValue("H27", $account_2030000[5]); $objPHPExcel->getActiveSheet()->setCellValue("I27", $account_2030000[6]); $objPHPExcel->getActiveSheet()->getStyle("H27:I27")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->setCellValue("A28", " Hutang Pembiayaan K. Pusat"); $objPHPExcel->getActiveSheet()->setCellValue("B28", $account_2030200_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C28", $account_2030200[0]); $objPHPExcel->getActiveSheet()->setCellValue("D28", $account_2030200[1]); $objPHPExcel->getActiveSheet()->setCellValue("E28", $account_2030200[4]); $objPHPExcel->getActiveSheet()->setCellValue("F28", $account_2030200[3]); $objPHPExcel->getActiveSheet()->setCellValue("G28", $account_2030200[2]); $objPHPExcel->getActiveSheet()->setCellValue("H28", $account_2030200[5]); $objPHPExcel->getActiveSheet()->setCellValue("I28", $account_2030200[6]); $objPHPExcel->getActiveSheet()->getStyle("H28:I28")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->setCellValue("A29", " Hutang Leasing"); $objPHPExcel->getActiveSheet()->setCellValue("B29", $account_2040000_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C29", $account_2040000[0]); $objPHPExcel->getActiveSheet()->setCellValue("D29", $account_2040000[1]); $objPHPExcel->getActiveSheet()->setCellValue("E29", $account_2040000[4]); $objPHPExcel->getActiveSheet()->setCellValue("F29", $account_2040000[3]); $objPHPExcel->getActiveSheet()->setCellValue("G29", $account_2040000[2]); $objPHPExcel->getActiveSheet()->setCellValue("H29", $account_2040000[5]); $objPHPExcel->getActiveSheet()->setCellValue("I29", $account_2040000[6]); $objPHPExcel->getActiveSheet()->getStyle("H29:I29")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->setCellValue("A30", " Hutang Lain-lain"); $objPHPExcel->getActiveSheet()->setCellValue("B30", $account_2050000_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C30", $account_2050000[0]); $objPHPExcel->getActiveSheet()->setCellValue("D30", $account_2050000[1]); $objPHPExcel->getActiveSheet()->setCellValue("E30", $account_2050000[4]); $objPHPExcel->getActiveSheet()->setCellValue("F30", $account_2050000[3]); $objPHPExcel->getActiveSheet()->setCellValue("G30", $account_2050000[2]); $objPHPExcel->getActiveSheet()->setCellValue("H30", $account_2050000[5]); $objPHPExcel->getActiveSheet()->setCellValue("I30", $account_2050000[6]); $objPHPExcel->getActiveSheet()->getStyle("H30:I30")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $no = 31; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", "Jumlah Liabilitas Jangka Pendek"); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_liabilitas_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", $account_liabilitas[0]); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", $account_liabilitas[1]); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_liabilitas[4]); $objPHPExcel->getActiveSheet()->setCellValue("F{$no}", $account_liabilitas[3]); $objPHPExcel->getActiveSheet()->setCellValue("G{$no}", $account_liabilitas[2]); $objPHPExcel->getActiveSheet()->setCellValue("H{$no}", $account_liabilitas[5]); $objPHPExcel->getActiveSheet()->setCellValue("I{$no}", $account_liabilitas[6]); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:I{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:I{$no}")->applyFromArray($style_border_top_btm); //EKUITAS $no = 33; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", "EKUITAS"); $objPHPExcel->getActiveSheet()->getStyle("A{$no}")->applyFromArray(array("font" => array("bold" => true))); //Simpanan Pokok 3010102 $code = "3010102"; for ($branch = 0; $branch <= 7; $branch++) { $account_3010102_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_3010102_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_3010102[$branch] = $account_3010102_credit[$branch] - $account_3010102_debet[$branch]; $account_3010102_konsolidasi += $account_3010102[$branch]; $account_ekuitas[$branch] += $account_3010102[$branch]; $account_ekuitas_konsolidasi += $account_3010102[$branch]; } //Simpanan Wajib 3010101 $code = "3010101"; for ($branch = 0; $branch <= 7; $branch++) { $account_3010101_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_3010101_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_3010101[$branch] = $account_3010101_credit[$branch] - $account_3010101_debet[$branch]; $account_3010101_konsolidasi += $account_3010101[$branch]; $account_ekuitas[$branch] += $account_3010101[$branch]; $account_ekuitas_konsolidasi += $account_3010101[$branch]; } //Hibah 3010103 $code = "3010103"; for ($branch = 0; $branch <= 7; $branch++) { $account_3010103_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_3010103_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_3010103[$branch] = $account_3010103_credit[$branch] - $account_3010103_debet[$branch]; $account_3010103_konsolidasi += $account_3010103[$branch]; $account_ekuitas[$branch] += $account_3010103[$branch]; $account_ekuitas_konsolidasi += $account_3010103[$branch]; } //Modal Penyertaan 3010201 $code = "3010201"; for ($branch = 0; $branch <= 7; $branch++) { $account_3010201_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_3010201_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_3010201[$branch] = $account_3010201_credit[$branch] - $account_3010201_debet[$branch]; $account_3010201_konsolidasi += $account_3010201[$branch]; $account_ekuitas[$branch] += $account_3010201[$branch]; $account_ekuitas_konsolidasi += $account_3010201[$branch]; } //SHU Tahun Lalu $code = "3020001"; for ($branch = 0; $branch <= 7; $branch++) { $account_3020001_debet[$branch] = $this->jurnal_model->sum_account_debet_by_date($code, $date_start, $date_end, $branch); $account_3020001_credit[$branch] = $this->jurnal_model->sum_account_credit_by_date($code, $date_start, $date_end, $branch); $account_3020001[$branch] = $account_3020001_credit[$branch] - $account_3020001_debet[$branch]; $account_3020001_konsolidasi += $account_3020001[$branch]; $account_ekuitas[$branch] += $account_3020001[$branch]; $account_ekuitas_konsolidasi += $account_3020001[$branch]; } for ($branch = 0; $branch <= 7; $branch++) { $account_3020002[$branch] = $this->hitung_laba_rugi($date_start, $date_end, $branch); $account_3020002_konsolidasi += $account_3020002[$branch]; $account_ekuitas[$branch] += $account_3020002[$branch]; $account_ekuitas_konsolidasi += $account_3020002[$branch]; } $lr_ciseeng = $this->hitung_laba_rugi($date_start, $date_end, $user_branch); $no = 34; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", " Simpanan Pokok"); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_3010102_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", $account_3010102[0]); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", $account_3010102[1]); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_3010102[4]); $objPHPExcel->getActiveSheet()->setCellValue("F{$no}", $account_3010102[3]); $objPHPExcel->getActiveSheet()->setCellValue("G{$no}", $account_3010102[2]); $objPHPExcel->getActiveSheet()->setCellValue("H{$no}", $account_3010102[5]); $objPHPExcel->getActiveSheet()->setCellValue("I{$no}", $account_3010102[6]); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:I{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $no = 35; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", " Simpanan Wajib"); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_3010101_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", $account_3010101[0]); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", $account_3010101[1]); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_3010101[4]); $objPHPExcel->getActiveSheet()->setCellValue("F{$no}", $account_3010101[3]); $objPHPExcel->getActiveSheet()->setCellValue("G{$no}", $account_3010101[2]); $objPHPExcel->getActiveSheet()->setCellValue("H{$no}", $account_3010101[5]); $objPHPExcel->getActiveSheet()->setCellValue("I{$no}", $account_3010101[6]); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:I{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $no = 36; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", " Hibah"); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_3010103_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", $account_3010103[0]); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", $account_3010103[1]); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_3010103[4]); $objPHPExcel->getActiveSheet()->setCellValue("F{$no}", $account_3010103[3]); $objPHPExcel->getActiveSheet()->setCellValue("G{$no}", $account_3010103[2]); $objPHPExcel->getActiveSheet()->setCellValue("H{$no}", $account_3010103[5]); $objPHPExcel->getActiveSheet()->setCellValue("I{$no}", $account_3010103[6]); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:I{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $no = 37; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", " Modal Penyertaan"); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_3010201_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", $account_3010201[0]); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", $account_3010201[1]); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_3010201[4]); $objPHPExcel->getActiveSheet()->setCellValue("F{$no}", $account_3010201[3]); $objPHPExcel->getActiveSheet()->setCellValue("G{$no}", $account_3010201[2]); $objPHPExcel->getActiveSheet()->setCellValue("H{$no}", $account_3010201[5]); $objPHPExcel->getActiveSheet()->setCellValue("I{$no}", $account_3010201[6]); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:I{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $no = 38; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", " SHU Tahun Lalu"); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_3020001_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", $account_3020001[0]); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", $account_3020001[1]); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_3020001[4]); $objPHPExcel->getActiveSheet()->setCellValue("F{$no}", $account_3020001[3]); $objPHPExcel->getActiveSheet()->setCellValue("G{$no}", $account_3020001[2]); $objPHPExcel->getActiveSheet()->setCellValue("H{$no}", $account_3020001[5]); $objPHPExcel->getActiveSheet()->setCellValue("I{$no}", $account_3020001[6]); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:I{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $no = 39; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", " SHU Tahun Berjalan"); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_3020002_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", $account_3020002[0]); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", $account_3020002[1]); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_3020002[4]); $objPHPExcel->getActiveSheet()->setCellValue("F{$no}", $account_3020002[3]); $objPHPExcel->getActiveSheet()->setCellValue("G{$no}", $account_3020002[2]); $objPHPExcel->getActiveSheet()->setCellValue("H{$no}", $account_3020002[5]); $objPHPExcel->getActiveSheet()->setCellValue("I{$no}", $account_3020002[6]); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:I{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $no = 40; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", "Jumlah Ekuitas"); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_ekuitas_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", $account_ekuitas[0]); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", $account_ekuitas[1]); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_ekuitas[4]); $objPHPExcel->getActiveSheet()->setCellValue("F{$no}", $account_ekuitas[3]); $objPHPExcel->getActiveSheet()->setCellValue("G{$no}", $account_ekuitas[2]); $objPHPExcel->getActiveSheet()->setCellValue("H{$no}", $account_ekuitas[5]); $objPHPExcel->getActiveSheet()->setCellValue("I{$no}", $account_ekuitas[6]); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:I{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:I{$no}")->applyFromArray($style_border_top_btm); //JUMLAH lIABILITAS EKUITAS for ($branch = 0; $branch <= 7; $branch++) { $account_liabilitas_ekuitas[$branch] += $account_liabilitas[$branch] + $account_ekuitas[$branch]; $account_liabilitas_ekuitas_konsolidasi += $account_liabilitas[$branch] + $account_ekuitas[$branch]; } $account_aset_tidak_lancar_konsolidasi = $account_aset_tetap_konsolidasi + $account_aset_lain_konsolidasi; $no = 42; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", "JUMLAH LIABILITAS DAN EKUITAS"); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", $account_liabilitas_ekuitas_konsolidasi); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", $account_liabilitas_ekuitas[0]); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", $account_liabilitas_ekuitas[1]); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_liabilitas_ekuitas[4]); $objPHPExcel->getActiveSheet()->setCellValue("F{$no}", $account_liabilitas_ekuitas[3]); $objPHPExcel->getActiveSheet()->setCellValue("G{$no}", $account_liabilitas_ekuitas[2]); $objPHPExcel->getActiveSheet()->setCellValue("H{$no}", $account_liabilitas_ekuitas[5]); $objPHPExcel->getActiveSheet()->setCellValue("I{$no}", $account_liabilitas_ekuitas[6]); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:I{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:I{$no}")->applyFromArray($style_border_top_btm_double); $objPHPExcel->getActiveSheet()->getStyle("A{$no}:I{$no}")->applyFromArray(array("font" => array("bold" => true))); //SELISIH $selisih = $account_aset_konsolidasi - $account_liabilitas_ekuitas_konsolidasi; for ($branch = 0; $branch <= 7; $branch++) { $account_selisih[$branch] += $account_aset[$branch] - $account_liabilitas_ekuitas[$branch]; } $no = 44; $objPHPExcel->getActiveSheet()->setCellValue("A{$no}", "SELISIH"); $objPHPExcel->getActiveSheet()->setCellValue("B{$no}", ROUND($selisih)); $objPHPExcel->getActiveSheet()->setCellValue("C{$no}", ROUND($account_selisih[0])); $objPHPExcel->getActiveSheet()->setCellValue("D{$no}", $account_selisih[1]); $objPHPExcel->getActiveSheet()->setCellValue("E{$no}", $account_selisih[4]); $objPHPExcel->getActiveSheet()->setCellValue("F{$no}", $account_selisih[3]); $objPHPExcel->getActiveSheet()->setCellValue("G{$no}", $account_selisih[2]); $objPHPExcel->getActiveSheet()->setCellValue("H{$no}", $account_selisih[5]); $objPHPExcel->getActiveSheet()->setCellValue("I{$no}", $account_selisih[6]); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:I{$no}")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle("B{$no}:I{$no}")->applyFromArray($style_border_top_btm_double); $objPHPExcel->getActiveSheet()->getStyle("A{$no}:I{$no}")->applyFromArray(array("font" => array("bold" => true))); //Set Column Format Accounting $objPHPExcel->getActiveSheet()->getStyle("A7:I42")->getNumberFormat()->setFormatCode("#0"); //Set Column Auto Width foreach (range('B', 'I') as $columnID) { $objPHPExcel->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true); } //EXPORT $filename = "Neraca_Konsolidasi_" . time() . '.xls'; //save our workbook as this file name header('Content-Type: application/vnd.ms-excel'); //mime type header('Content-Disposition: attachment;filename="' . $filename . '"'); //tell browser what's the file name header('Cache-Control: max-age=0'); //no cache $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output'); redirect('accounting/neraca', 'refresh'); } else { //If no session, redirect to login page redirect('login', 'refresh'); } }
/** * Renders the template that shows a specific entry out of the hours page of the teacher * @param Integer $id Id of the teacher * @param Integer $userid Id of the user * @param Integer $weeknr Week number * @param Integer $jaar The year * @param Integer $cursusid Id of the course * @return Template of the specific entry based on the data provided */ public function docentOverzichtDetail($id, $userid, $weeknr, $jaar, $cursusid) { $result = getUserDetails($id); if (isLogged($id)) { $startandenddate = getStartAndEndDate($weeknr, $jaar); $statement = $this->db->prepare("SELECT\n\t\t\t\t(SELECT onderdeel_Name FROM Onderdeel WHERE onderdeel_Id = Onderdeel_onderdeel_Id) AS onderdeel,\n\t\t\t\t(SELECT onderdeel_Norm FROM Onderdeel WHERE onderdeel_Id = Onderdeel_onderdeel_Id) AS onderdeel_Norm,\n\t\t\t\t(SELECT user_Name FROM User WHERE user_Id = '" . $userid . "') AS student,\n\t\t\t\t(SELECT cursus_Name FROM Cursus WHERE cursus_Id = '" . $cursusid . "') as cursus,\n\t\t\t\tSUM(uren_Studielast) as studielast\n\t\t\t\tFROM\n\t\t\t\tUren\n\t\t\t\tWHERE\n\t\t\t\tOnderdeel_onderdeel_Id in (SELECT onderdeel_Id FROM Onderdeel WHERE Onderdeel_onderdeel_Id = onderdeel_Id AND Cursus_cursus_Id IN (SELECT cursus_Id FROM Cursus WHERE cursus_Id = Cursus_cursus_Id AND cursus_Id = '" . $cursusid . "'))\n\t\t\t\tAND\n\t\t\t\tUser_user_Id = '" . $userid . "'\n\t\t\t\tAND\n\t\t\t\turen_Date between '" . $startandenddate[0] . "' and '" . $startandenddate[1] . "'\n\t\t\t\tGROUP BY Onderdeel_onderdeel_Id"); $statement->execute(); $urenoverzichtData = $statement->fetchAll(\PDO::FETCH_ASSOC); $totaalPerOnderdeel = $this->totaalTotDatum($userid, $startandenddate[1], $cursusid); $count = 0; $student = ''; $cursus = ''; foreach ($urenoverzichtData as $uren) { $onderdeel_norm = $uren['onderdeel_Norm']; $berekening = $totaalPerOnderdeel[$count]['totaalOnderdeel'] / $onderdeel_norm * 100; if ($berekening > 100) { $berekening = $berekening - 100; $berekening = "<font color=\"red\">" . $berekening . "%</font> boven"; } else { $berekening = 100 - $berekening; $berekening = "<font color=\"green\">" . $berekening . "%</font> onder"; } $studielast_in_uren = min_naar_uren($uren['studielast']); $student = $uren['student']; $cursus = $uren['cursus']; $array[] = array('onderdeel' => $uren['onderdeel'], 'studielast' => $studielast_in_uren, 'onderdeel_Norm' => min_naar_uren($uren['onderdeel_Norm']), 'totaalPerOnderdeel' => min_naar_uren($totaalPerOnderdeel[$count]['totaalOnderdeel']), 'berekening' => $berekening); $count++; } echo $this->twigRenderer->renderTemplate('urenoverzichtdetail_docent.twig', array('id' => $id, 'onderdeeloverzichtarray' => $array, 'student' => $student, 'weeknr' => $weeknr, 'cursus_Name' => $cursus)); } else { echo $this->twigRenderer->renderTemplate('noaccess.twig'); } }
$net_price = $price_selling; } else { $net_price = Product::calculateNetPrice($price_selling, VAT); } $profit = Product::calculateProfit($net_price, $cogs); $margin = Product::calculateMargin($profit, $net_price); $result .= ' <br/><br/>Price: ' . displayCurrency('EUR', $price_selling); $result .= ' <br/>Margin: ' . Product::displayMargin($price_selling, $margin); $result .= ' <br/>Total Sold' . ($spid == 0 ? '' : ' (excl. JG)') . ': ' . $total_sold . '<br/><br/>'; //Get start date list($year, $week) = explode('-', $week_start); $temp_date = getStartAndEndDate($week, $year); $report_date_start = $temp_date['start_date']; //Get end date list($year, $week) = explode('-', $week_end); $temp_date = getStartAndEndDate($week, $year); $report_date_end = $temp_date['end_date']; //Validate week filter input if (strtotime($report_date_end) < strtotime($report_date_start)) { echo utf8_encode('Invalid week range input'); exit; } $week_date_start = $report_date_start; $week_date_end = date('Y-m-d', strtotime($report_date_start . " + 6 days")); $row = 0; while (strtotime($week_date_end) <= strtotime($report_date_end)) { //echo("$week_date_start | $week_date_end<br/>"); $row++; $week_number = date('W', strtotime($week_date_start)); $prod_summary = ReportCOGS::retrieveSummaryByProducts($products_id, $spid, $week_date_start, $week_date_end); $week_sold = isset($prod_summary[$products_id]['total_quantity_sold']) ? $prod_summary[$products_id]['total_quantity_sold'] : 0;
if ($seconds > 0) { $ret .= "{$seconds} s"; } return $ret; } // Calculate datum range. function getStartAndEndDate($week, $year) { $dto = new DateTime(); $dto->setISODate($year, $week); $ret['week_start'] = $dto->format('d-m-Y'); $dto->modify('+6 days'); $ret['week_end'] = $dto->format('d-m-Y'); return $ret; } $weekDaterange = getStartAndEndDate($_GET["w"], '2015'); // End calculate datum range // END SETTINGS // Queries reports // Alles - Fietsers - Lopers - Zwemmers // TO DO: /* Berggeit - Turbo - Langste rit/loop/zwem */ /*$sqlAlles = "SELECT activities.Weeknummer, leden.lFname, leden.lName, activities.aType, SUM(aDistance) as Oever, SUM(aMovingtime) as Oelang, SUM(aElevation) as OeOog,