PageRenderTime 49ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/application/controllers/neraca.php

https://gitlab.com/zetrosoft/pos-accounting
PHP | 295 lines | 284 code | 7 blank | 4 comment | 2 complexity | 499277bf41de9652bcda0cd375268a7a MD5 | raw file
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. class Neraca extends CI_Controller{
  3. function __construct()
  4. {
  5. parent::__construct();
  6. $this->load->model("inv_model");
  7. $this->load->model("report_model");
  8. $this->load->helper("print_report");
  9. $this->load->model("akun_model");
  10. $this->load->model("neraca_model");
  11. $this->load->library("zetro_auth");
  12. $this->userid=$this->session->userdata('idlevel');
  13. }
  14. function Header(){
  15. $this->load->view('admin/header');
  16. }
  17. function Footer(){
  18. $this->load->view('admin/footer');
  19. }
  20. function list_data($data){
  21. $this->data=$data;
  22. }
  23. function View($view){
  24. $this->Header();
  25. //$this->zetro_auth->view($view);
  26. $this->load->view($view,$this->data);
  27. $this->Footer();
  28. }
  29. function faktur(){
  30. $this->zetro_auth->menu_id(array('rekaplaporan'));
  31. $this->list_data($this->zetro_auth->auth());
  32. $this->View('laporan/lap_faktur');
  33. }
  34. function neraca_index(){
  35. $this->zetro_auth->menu_id(array('neraca'));
  36. $this->list_data($this->zetro_auth->auth());
  37. $this->View('laporan/neracane');
  38. }
  39. function neraca_lajur(){
  40. $this->zetro_auth->menu_id(array('neracalajur'));
  41. $this->list_data($this->zetro_auth->auth());
  42. $this->View('laporan/neraca_lajur_bener');
  43. }
  44. function rekap_simpanan(){
  45. $this->zetro_auth->menu_id(array('neraca__rekap_simpanan'));
  46. $this->list_data($this->zetro_auth->auth());
  47. $this->View('laporan/neraca_lajur');
  48. }
  49. function neraca_lajur_data(){
  50. //bukan neraca lajur tetapi laporan rekap simpanan anggota per departemen
  51. $data=array();$n=0;
  52. $periode=tglToSql($_POST['periode']);
  53. $this->neraca_model->neraca_unit();
  54. $data=$this->neraca_model->get_rekap_data($periode);
  55. //return $data;
  56. foreach($data as $row){
  57. $saldo=0;$n++;
  58. echo tr().td($n,'center').td($row->ID_Dept);
  59. for ($i=1;$i<=3;$i++){
  60. $field=str_replace('. ','_',rdb("jenis_simpanan",'Jenis','Jenis',"where ID='".$i."'"));
  61. echo td(number_format($row->$field,2),'right');
  62. $saldo=($saldo+$row->$field);
  63. }
  64. echo td(number_format($saldo,2),'right')._tr();
  65. }
  66. }
  67. function get_data_nc_lajur(){
  68. //neraca lajur simpanan anggota per departemen
  69. $datax =array();$n=0;$saldo=0;
  70. $periode=empty($_POST['tgl_start'])?'':tglToSql($_POST['tgl_start']);
  71. $tgl_stop=empty($_POST['tgl_stop'])?$periode:tglToSql($_POST['tgl_stop']);
  72. $id_dept=$_POST['id_dept'];
  73. $ID_Stat=empty($_POST['stat_agt'])?'':$_POST['stat_agt'];
  74. $akun =empty($_POST['akun'])?'':$_POST['akun'];
  75. $tahun =empty($_POST['tahun'])?'':$_POST['tahun'];
  76. $filter =$_POST['filterby'];
  77. $where =" and ID_Dept='".$id_dept."'";
  78. $where.=($akun=='')?'':" and ID_Simpanan='".$akun."'";
  79. $where.=($filter=='thn')?" and Tahun='".$tahun."'":" and (Tanggal between '".$periode."' and '".$tgl_stop."')";
  80. $prdd=($filter=='thn')? $tahun.'1231':$tgl_stop;
  81. $this->neraca_model->neraca_unit();
  82. $datax=$this->neraca_model->get_nc_lajure($prdd,$where);
  83. foreach($datax as $r){
  84. $n++;
  85. $saldoawal=rdb("perkiraan",'SaldoAwal','sum(SaldoAwal) as SaldoAwal',"where ID_Agt='".$r->ID_Agt."' and ID_Dept='".$r->ID_Dept."' and ID_Simpanan='".$r->ID_Simpanan."'");
  86. $kode=rdb('klasifikasi','Kode','Kode',"where ID='".$r->ID_Klas."'");
  87. $kode.=rdb('sub_klasifikasi','Kode','Kode',"where ID='".$r->ID_SubKlas."'");
  88. $kode.=rdb('unit_jurnal','Kode','Kode',"where ID='".$r->ID_Dept."'");
  89. $kode.=rdb('mst_departemen','Kode','Kode',"where ID='".$r->ID_Unit."'");
  90. $kode.=rdb('mst_anggota','No_Perkiraan','No_Perkiraan',"where ID='".$r->ID_Agt."'");
  91. $simp=rdb('jenis_simpanan','Jenis','Jenis',"where ID='".$r->ID_Simpanan."'");
  92. $saldo=($r->ID_Calc=='2')?($r->Kredit-$r->Debet):($r->Debet-$r->Kredit);
  93. echo tr().td($n,'center').
  94. td($kode,'center').
  95. td(rdb('mst_anggota','Nama','Nama',"where ID='".$r->ID_Agt."'")." - ".$simp,"left' nowrap").
  96. td(number_format($saldoawal),'right').
  97. td(number_format($r->Debet,2),'right').
  98. td(number_format($r->Kredit,2),'right').
  99. td(number_format($saldoawal+$saldo,2),'right');
  100. echo _tr();
  101. }/**/
  102. }
  103. function print_neraca_lajur(){
  104. $data=array();
  105. $tgl_start =($this->input->post('tgl_start')=='')?'' :$this->input->post('tgl_start');
  106. $periode =($this->input->post('tgl_stop')=='')?$tgl_start:$this->input->post('tgl_stop');
  107. $id_dept =$this->input->post('ID_Dept');
  108. $ID_Stat =($this->input->post('ID_Stat')=='')?'' :$this->input->post('ID_Stat');
  109. $akun =($this->input->post('ID_Perkiraan')=='')?'0' :$this->input->post('ID_Perkiraan');
  110. $tahun =($this->input->post('tahun')=='')?'' :$this->input->post('tahun');
  111. $filter =$this->input->post('filper');
  112. $where =" and t.ID_Dept='".$id_dept."'";
  113. $where .=($akun=='')?'':" and t.ID_Simpanan='".$akun."'";
  114. $where .=($filter=='thn')?" and Tahun='".$tahun."'":" and (Tanggal between '".tglToSql($tgl_start)."' and '".tglToSql($periode)."')";
  115. $prdd=($filter=='thn')? $tahun.'1231':tglToSql($periode);
  116. $data['dept']=rdb('mst_departemen','Departemen','Departemen',"where ID='".$id_dept."'");
  117. $data['tanggal']=($filter=='thn')?$tahun: $tgl_start.' s/d '.$periode;
  118. $data['akun']=rdb('jenis_simpanan','jenis','jenis',"where ID='".$akun."'");
  119. $data['thn']=($filter=='thn')?$tahun:substr($tgl_start,6,4);
  120. $this->neraca_model->neraca_unit();
  121. $data['temp_rec']=($filter=='thn')?$this->neraca_model->get_nc_lajure($tahun,$id_dept,$akun):
  122. $this->neraca_model->get_nc_lajure_tg($tgl_start,$periode,$id_dept,$akun);
  123. $this->zetro_auth->menu_id(array('trans_beli'));
  124. $this->list_data($data);
  125. $this->View("laporan/neraca_lajur_print_new");
  126. }
  127. function print_lap_pdf(){
  128. $data['tanggal']=$this->input->post('tgl_start');
  129. $periode=tglToSql($this->input->post('tgl_start'));
  130. $this->neraca_model->neraca_unit();
  131. $data['temp_rec']=$this->neraca_model->get_rekap_data($periode);
  132. $this->zetro_auth->menu_id(array('trans_beli'));
  133. $this->list_data($data);
  134. $this->View("laporan/rekap_simpanan_print");
  135. }
  136. function print_neraca(){
  137. $data['unit'] =$this->input->post('unite');
  138. $data['periode'] =$this->input->post('tgl_start');
  139. $data['pembanding'] =$this->input->post('tgl_banding');
  140. $data['users'] =$this->session->userdata('userid');
  141. $unite =$this->input->post('unite');
  142. ($unite!=3)?$unite =rdb("unit_jurnal",'Unit','Unit',"where ID='".$unite."'"):$unite='';
  143. $unte =$this->input->post('unite');
  144. $periode =tglToSql($this->input->post('tgl_start'));
  145. $data['awal'] =getPrevDays($periode,365);
  146. $awal =getPrevDays($periode,365);
  147. $this->neraca_model->neraca_unit($unte);
  148. $this->neraca_model->build_data($periode);
  149. $this->neraca_model->tmp_balance();
  150. $this->neraca_model->generate_shu($awal,$periode,$unte);
  151. //$data['temp_rec'] =$this->neraca_model->neraca_kalkulasi($periode,$unite);
  152. $this->zetro_auth->menu_id(array('trans_beli'));
  153. $this->list_data($data);
  154. ($this->input->post('tgl_banding')=='')?
  155. $this->View("laporan/neraca_print"):
  156. $this->View("laporan/neraca_print_banding");
  157. }
  158. function print_neraca_gabungan(){
  159. $data['periode'] =$this->input->post('tgl_start');
  160. $data['pembanding'] =$this->input->post('tgl_banding');
  161. $data['users'] =$this->session->userdata('userid');
  162. $unte =$this->input->post('unite');
  163. $periode =tglToSql($this->input->post('tgl_start'));
  164. $data['awal'] =getPrevDays($periode,365);
  165. $awal =getPrevDays($periode,365);
  166. $this->neraca_model->neraca_unit();
  167. $this->neraca_model->build_data($periode);
  168. $this->neraca_model->tmp_balance();
  169. $this->neraca_model->generate_shu($awal,$periode,$unte);
  170. $this->neraca_model->periode($periode);
  171. $this->neraca_model->generate_data('1');
  172. $this->neraca_model->generate_data('2');
  173. //$data['temp_rec'] =$this->neraca_model->neraca_kalkulasi($periode,$unite);
  174. $this->zetro_auth->menu_id(array('trans_beli'));
  175. $this->list_data($data);
  176. $this->View("laporan/neraca_print_gabung");
  177. }
  178. function shu(){
  179. $this->zetro_auth->menu_id(array('sisahasilusaha'));
  180. $this->list_data($this->zetro_auth->auth());
  181. $this->View('laporan/shu');
  182. }
  183. function print_shu(){
  184. $data['unit'] =$this->input->post('unite');
  185. $data['periode'] =$this->input->post('tgl_start');
  186. $data['akhir'] =$this->input->post('tgl_stop');
  187. $data['users'] =$this->session->userdata('userid');
  188. $periode =tglToSql($this->input->post('tgl_stop'));
  189. $this->neraca_model->neraca_unit();
  190. $this->neraca_model->build_data($periode);
  191. $this->zetro_auth->menu_id(array('trans_beli'));
  192. $this->list_data($data);
  193. ($this->input->post('unite')==3)?
  194. $this->View("laporan/shu_print_gabungan"):
  195. $this->View("laporan/shu_print");
  196. //$this->output->enable_profiler();
  197. }
  198. function graph_shu(){
  199. //$this->neraca_model->data_grap_shu();
  200. $this->zetro_auth->menu_id(array('grafikshu'));
  201. $this->list_data($this->zetro_auth->auth());
  202. $this->View('laporan/shu_graph');
  203. }
  204. function graph_shu_data(){
  205. $thn=(date('Y')-6);
  206. $this->neraca_model->neraca_unit();
  207. $this->neraca_model->data_grap_shu($thn);
  208. }
  209. //generate data for grafik
  210. function data_XML(){
  211. $n=0;$x=0;
  212. $user=$this->session->userdata('userid');
  213. $xml=fopen(base_url()."application/log/".$user.'_graph.xml','wb');
  214. fwrite($xml,"<graph caption='".$this->judul."' xAxisName='".$this->xAxis."' yAxisName='".$this->yAxis."' numberPrefix='' showvalues='1' numDivLines='4' formatNumberScale='0' decimalPrecision='0' anchorSides='10' anchorRadius='3' anchorBorderColor='00990'>\r\n");
  215. foreach($this->datasec as $sec=>$par_tip){
  216. fwrite($xml,"<set name='".$sec.'\' value=\''.$par_tip."'/>\r\n");
  217. $n++;
  218. }
  219. fwrite($xml,"</graph>\r\n");
  220. }
  221. function _judul_grafik($judul=''){
  222. $this->judul=$judul;
  223. }
  224. function _judul_axis($xAxis='',$yAxis=''){
  225. $this->xAxis=$xAxis;
  226. $this->yAxis=$yAxis;
  227. }
  228. function _data_cat($datacat){
  229. if(is_array($datacat)){
  230. $this->datacat=$datacat;
  231. }else{
  232. return false;
  233. }
  234. }
  235. function _data_sec($datasec){
  236. if(is_array($datasec)){
  237. $this->datasec=$datasec;
  238. }else{
  239. return false;
  240. }
  241. }
  242. function rekap_simpanan_dept(){
  243. $this->zetro_auth->menu_id(array('rekappiutangbarang'));
  244. $this->list_data($this->zetro_auth->auth());
  245. $this->View('laporan/rekap_simpanan_dept');
  246. }
  247. function get_rkp_simpan_dept(){
  248. $data=array();$n=0;
  249. $bulan=$this->input->post('bln');
  250. $tahun=$this->input->post('thn');
  251. $jumHari = cal_days_in_month(CAL_GREGORIAN,$bulan,$tahun);
  252. $bulan=(strlen($bulan)==1)?'0'.$bulan:$bulan;
  253. $periode=$tahun.'-'.$bulan.'-'.$jumHari;
  254. $where2="where year(p.Tanggal) <'".$tahun."'";
  255. //$where="where month(p.Tanggal)='".$bulan."'";
  256. $where ="where year(p.Tanggal)='".$tahun."'";
  257. $where.=($this->input->post('ID_Dept')=='')?"and p.ID_Dept<>'0'":" and p.ID_Dept='".$this->input->post('ID_Dept')."'";
  258. $where.=($this->input->post('ID_Simpanan')=='')?"and p.ID_Simpanan<>'0'":" and p.ID_Simpanan='".$this->input->post('ID_Simpanan')."'";
  259. $where2.=($this->input->post('ID_Dept')=='')?"and p.ID_Dept<>'0'":" and p.ID_Dept='".$this->input->post('ID_Dept')."'";
  260. $where2.=($this->input->post('ID_Simpanan')=='')?"and p.ID_Simpanan<>'0'":" and p.ID_Simpanan='".$this->input->post('ID_Simpanan')."'";
  261. $groupby="group by month(p.Tanggal),p.ID_Simpanan";
  262. $groupby2="group by p.ID_Simpanan";
  263. //kirim dalam bentuk pdf
  264. $this->neraca_model->neraca_unit();
  265. $data['temp_rec'] =$this->neraca_model->get_rekap_dept($periode,$where,$groupby);
  266. $data['saldoawal'] =$this->neraca_model->get_saldo_awal($where2,$groupby2);
  267. $data['bulan'] =rdb('mst_bulan','Bulan','Bulan',"where ID='".(int)$bulan."'");
  268. $data['tahun'] =$tahun;
  269. $data['Dept'] =rdb('mst_departemen','Departemen','Departemen',"where ID='".$this->input->post('ID_Dept')."'");
  270. $data['simp'] =rdb('jenis_simpanan','Jenis','Jenis',"where ID='".$this->input->post('ID_Simpanan')."'");
  271. $this->zetro_auth->menu_id(array('trans_beli'));
  272. $this->list_data($data);
  273. $this->View("laporan/rekap_simpanan_dept_print");
  274. }
  275. function rekap_departemen(){
  276. }
  277. }