PageRenderTime 41ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/public_html/acc/application/controllers/pphbadan.php

https://bitbucket.org/stadrianto/dora
PHP | 236 lines | 210 code | 5 blank | 21 comment | 27 complexity | 8c1ffb037ad92b0e7ae848a180cbc777 MD5 | raw file
  1. <?php
  2. if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  3. class pphbadan extends CI_Controller {
  4. public function __construct(){
  5. parent::__construct();
  6. $this->load->helper('url');
  7. $this->load->library(array('uri','session'));
  8. $this->load->model('all_model');
  9. date_default_timezone_set('Asia/Jakarta');
  10. }
  11. public function getDataPrinter($id)
  12. {
  13. $result = $this->all_model->query_data("SELECT Nama as Nama from msuser where iduser=".$id, false);
  14. if(!$result){
  15. $result= "0";
  16. }
  17. return $result;
  18. }
  19. public function getDataJurnal($noakun,$tanggal1,$tanggal2)
  20. {
  21. $result = $this->all_model->query_data("SELECT Debit as Debit,Kredit as Kredit FROM jurnal a join detailjurnal b on a.nojurnal = b.nojurnal where status='Approved' and noakun='".$noakun."' and tanggaltransaksi between '".$tanggal1."' and '".$tanggal2."'", false);
  22. if(!$result){
  23. $result= "0";
  24. }
  25. return $result;
  26. }
  27. public function getDataTrial()
  28. {
  29. $result = $this->all_model->query_data("SELECT a.NoAkun as NoAkun,NamaAkun as NamaAkun,SaldoAwal as SaldoAwal,IdNeraca as IdNeraca FROM tabelakun a join kelompokakun b on a.idkelompokakun=b.idkelompokakun where left(a.noakun,1)>3 order by a.noakun asc", false);
  30. //$result = $this->all_model->query_data("SELECT a.NoAkun as NoAkun,NoOrder as NoOrder,TanggalProject as TanggalProject,NamaProject as NamaProject,BiayaProject as BiayaProject,PIC FROM project a where NoProject='".$noproject."' ", true);
  31. if(!$result){
  32. $result= "0";
  33. }
  34. return $result;
  35. }
  36. public function printPphbadan()
  37. {
  38. $tanggal1=$this->input->post('dob');
  39. $tanggal2=$this->input->post('dob1');
  40. $qtanggal1=substr($tanggal1,6,4).'-'.substr($tanggal1,0,2).'-'.substr($tanggal1,3,2);
  41. $qtanggal2=substr($tanggal2,6,4).'-'.substr($tanggal2,0,2).'-'.substr($tanggal2,3,2);
  42. $result = $this->getDataTrial();
  43. $this->load->library('fpdf17/fpdf');
  44. //(potrait, satuan , ukuran kertas(lebar x tinggi)) 'P','mm',array(120,200)
  45. $this->fpdf->FPDF('P','mm','A4');
  46. $this->fpdf->Open();
  47. $this->fpdf->SetAutoPageBreak(false);
  48. $this->fpdf->AddPage();
  49. $this->fpdf->Image('images/logo.png',35,10,30,0,'','http://www.cips.or.id/');
  50. $this->fpdf->Ln(10);
  51. $this->fpdf->SetFont('Arial','B',15);
  52. $this->fpdf->Cell(190,6,'Citra Inti Prima Sejati',0,0,'C');
  53. $this->fpdf->Ln(5);
  54. $this->fpdf->Cell(190,6,'PPH Badan',0,0,'C');
  55. $this->fpdf->SetFont('Arial','BU',12);
  56. $this->fpdf->Ln(5);
  57. $this->fpdf->Cell(190,6,$tanggal1.' - '.$tanggal2,0,0,'C');
  58. $this->fpdf->Ln(15);
  59. $y_axis_initial = 50;
  60. $this->fpdf->SetFont('Arial','',10);
  61. $this->fpdf->setFillColor(222,222,222);
  62. $this->fpdf->SetY($y_axis_initial);
  63. $this->fpdf->SetX(50);
  64. $this->fpdf->Ln();
  65. $max=25;//max baris perhalaman
  66. $i=0;
  67. $no4=0;
  68. $no5=0;
  69. $no6=0;
  70. $no7=0;
  71. $no8=0;
  72. $hpp=0;
  73. $totala=0;
  74. $totalb=0;
  75. $totalc=0;
  76. $totald=0;
  77. $totale=0;
  78. $totalf=0;
  79. $row_height = 6;//tinggi tiap2 cell/baris
  80. $y_axis = $y_axis_initial + $row_height;
  81. $date = date("Y-m-d");
  82. //$grandtotal = 0;
  83. if($result != "0")
  84. {
  85. foreach($result as $key => $value)
  86. {
  87. $i++;
  88. $saldo=floatval($result[$key]["SaldoAwal"]);
  89. $result2 = $this->getDataJurnal($result[$key]["NoAkun"]."",$qtanggal1."",$qtanggal2."");
  90. if($result[$key]["IdNeraca"]=="1")
  91. {
  92. $saldo=0;
  93. if($result2!="0")
  94. {
  95. for($z=0;$z<count($result2);$z++){
  96. $saldo+=$result2[$z]["Debit"];
  97. $saldo-=$result2[$z]["Kredit"];
  98. }
  99. }
  100. }
  101. else if($result[$key]["IdNeraca"]=="2")
  102. {
  103. $saldo=0;
  104. if($result2!="0")
  105. {
  106. for($z=0;$z<count($result2);$z++){
  107. $saldo-=$result2[$z]["Debit"];
  108. $saldo+=$result2[$z]["Kredit"];
  109. }
  110. }
  111. }
  112. $i++;
  113. if(substr($result[$key]["NoAkun"],0,1)=="4")
  114. {
  115. $no4++;
  116. $totala+=$saldo;
  117. }
  118. else if(substr($result[$key]["NoAkun"],0,1)=="5")
  119. {
  120. $no5++;
  121. $hpp+=$saldo;
  122. }
  123. else if(substr($result[$key]["NoAkun"],0,1)=="6")
  124. {
  125. $no6++;
  126. $totalb+=$saldo;
  127. }
  128. else if(substr($result[$key]["NoAkun"],0,1)=="7")
  129. {
  130. $no7++;
  131. $totald+=$saldo;
  132. }
  133. else if(substr($result[$key]["NoAkun"],0,1)=="8")
  134. {
  135. $no8++;
  136. $totale+=$saldo;
  137. }
  138. }
  139. //LabaKotor totala
  140. $this->fpdf->SetFont('Arial','B',10);
  141. $this->fpdf->SetY(50+($no4*5)+($no5*5));
  142. $this->fpdf->SetX(20);
  143. $this->fpdf->Cell(60,6,'Penghasilan Kotor',0,0,'L',0);
  144. $this->fpdf->SetX(120);
  145. //$this->fpdf->Cell(60,6,$this->all_model->rp($totala),0,0,'R',0);
  146. $this->fpdf->Cell(60,6,$this->all_model->rp(floatval($this->input->post('bruto'))),0,0,'R',0);
  147. $this->fpdf->Ln();
  148. //laba usaha totalc
  149. $totalc=$totala-$hpp-$totalb;
  150. /*
  151. if($totala>$totalb)
  152. $this->fpdf->Cell(60,6,'Laba Usaha',0,0,'L',0);
  153. else
  154. $this->fpdf->Cell(60,6,'Rugi Usaha',0,0,'L',0);
  155. */
  156. //total penghasilan diluar usaha totald
  157. //total beban diluar usaha totale
  158. //Laba Bersih Sbelum Pajak totalf
  159. $totalf=($totalc+$totald)-$totale;
  160. $this->fpdf->SetY(55+($no4*5)+($no5*5));
  161. $this->fpdf->SetX(20);
  162. $this->fpdf->Cell(60,6,'Laba Bersih Sebelum Pajak',0,0,'L',0);
  163. $this->fpdf->SetX(120);
  164. //$this->fpdf->Cell(60,6,$this->all_model->rp($totalf),0,0,'R',0);
  165. $this->fpdf->Cell(60,6,$this->all_model->rp(floatval($this->input->post('laba'))),0,0,'R',0);
  166. //Pajak
  167. $pajak=0;
  168. $rumus="";
  169. if($totala<=4800000000)
  170. {
  171. $pajak=($totalf*0.25)*0.5;
  172. $rumus="Pajak yang harus dibayar dalam setahun=(".$totalf." x 25%) x 50%";
  173. }
  174. else if($totala>4800000000 && $totala<=50000000000)
  175. {
  176. $pajak=((((4800000000/$totala)* $totalf)*0.25) *0.5) + (($totalf-((4800000000/$totala)* $totalf))*0.25);
  177. $rumus="Pajak yang harus dibayar dalam setahun=(".(4800000000/$totala)* $totalf." x 25%) x 50% + (".($totalf-((4800000000/$totala)* $totalf)). " x 25%)";
  178. }
  179. else
  180. {
  181. $pajak=($totalf*0.25);
  182. $rumus="Pajak yang harus dibayar dalam setahun=(".$totalf." x 25%)";
  183. }
  184. $this->fpdf->SetY(60+($no4*5)+($no5*5));
  185. $this->fpdf->SetX(20);
  186. $this->fpdf->Cell(60,6,$rumus,0,0,'L',0);
  187. $this->fpdf->Ln();
  188. $this->fpdf->SetX(120);
  189. //$this->fpdf->Cell(60,6,$this->all_model->rp($pajak),0,0,'R',0);
  190. $this->fpdf->Cell(60,6,$this->all_model->rp(floatval($this->input->post('pajak'))),0,0,'R',0);
  191. $this->fpdf->SetY(75+($no4*5)+($no5*5));
  192. $this->fpdf->SetX(20);
  193. $this->fpdf->Cell(60,6,"Angsuran Pajak setiap bulan",0,0,'L',0);
  194. $this->fpdf->SetX(120);
  195. //$this->fpdf->Cell(60,6,$this->all_model->rp($pajak/12),0,0,'R',0);
  196. $this->fpdf->Cell(60,6,$this->all_model->rp(floatval($this->input->post('angsuran'))),0,0,'R',0);
  197. }
  198. //buat footer
  199. $now = date("d F Y H:i:s");
  200. $this->fpdf->Ln();
  201. $this->fpdf->Ln();
  202. $this->fpdf->SetFont('Arial','B',10);
  203. $printer=$this->getDataPrinter($this->session->userdata("UserId"));
  204. $this->fpdf->SetX(0);
  205. $this->fpdf->Cell(100,6,"Processor: ".$printer[0]["Nama"],0,0,'C');
  206. $this->fpdf->SetX(40);
  207. $this->fpdf->SetFont('Arial','B',10);
  208. $this->fpdf->Cell(250,6,"Print Date: ".$now,0,0,'C');
  209. $this->fpdf->Ln();
  210. $this->fpdf->Output('Laporan PPh Badan'.date("F Y").'.pdf', 'I');
  211. }
  212. public function index(){
  213. if($this->session->userdata("UserId")=="")
  214. redirect(base_url(). "home","refresh");
  215. $config['per_page'] = 5;
  216. $config['segmen'] = 0;
  217. $data['title']="CIPS";
  218. $data['page_title']="CIPS - Pajak";
  219. //$data2['data'] = json_encode($this->getData($config['per_page'], $config['segmen'],false ));
  220. $data['include']=$this->load->view('script','',true);
  221. $this->load->view('home_header',$data);
  222. $this->load->view('pphbadan_view');
  223. $this->load->view('home_footer');
  224. }
  225. private function no_cache(){
  226. header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
  227. header('Cache-Control: no-store, no-cache, must-revalidate');
  228. header('Cache-Control: post-check=0, pre-check=0',false);
  229. header('Pragma: no-cache');
  230. }
  231. }