Exemplo n.º 1
0
 function save($data)
 {
     $belanjaayam = $this->prepare($data);
     $fkey = parent::save($belanjaayam);
     $this->sirkulasiAyam($data['waktu'], $belanjaayam['ayam'], 'MASUK', 'BELANJA AYAM', $fkey, $data['ekor'], $data['kg']);
     $this->sirkulasiKeuangan('KELUAR', 'BELANJA AYAM', $data['total'], $fkey, $data['waktu']);
 }
Exemplo n.º 2
0
 function save($data, $waktu, $reason, $source, $destination)
 {
     $data['id'] = parent::save($data);
     $this->sirkulasiProdukOutlet($waktu, $data['produk'], 'KELUAR', $reason, $data['id'], $data['qty'], $source);
     $this->sirkulasiprodukOutlet($waktu, $data['produk'], 'MASUK', $reason, $data['id'], $data['qty'], $destination);
     return $data['id'];
 }
Exemplo n.º 3
0
 function save($data, $waktu, $reason, $outlet)
 {
     $data['id'] = parent::save($data);
     $this->sirkulasiAyam($waktu, $data['ayam'], 'KELUAR', $reason, $data['id'], $data['pcs'], $data['kg']);
     $this->sirkulasiAyamOutlet($waktu, $data['ayam'], 'MASUK', $reason, $data['id'], $data['pcs'], $data['kg'], $outlet);
     return $data['id'];
 }
Exemplo n.º 4
0
 function save($data)
 {
     $data['type'] = 'PEMINJAMAN';
     $data['id'] = parent::save($data);
     $this->sirkulasiKeuangan('MASUK', 'PEMINJAMAN', $data['nominal'], $data['id'], $data['waktu']);
     $this->debitur($data['debitur'], $data['nominal'], '+');
 }
Exemplo n.º 5
0
 function save($data, $waktu, $reason)
 {
     $data['id'] = parent::save($data);
     $this->sirkulasiProduk($waktu, $data['produk'], 'MASUK', $reason, $data['id'], $data['qty']);
     $this->sirkulasiProduk($waktu, $data['produk'], 'KELUAR', $reason, $data['id'], $data['qty']);
     return $data['id'];
 }
Exemplo n.º 6
0
 function update($data)
 {
     $reason = 'EDIT BELANJA';
     $databelanja = $this->prepare($data);
     $oldbelanja = $this->findOne($data['id']);
     $CI =& get_instance();
     $CI->load->model('belanjadetail');
     $excepted = array();
     foreach ($data['belanjadetail']['barang'] as $key => $value) {
         $record = array('belanja' => $data['id'], 'distributor' => $data['belanjadetail']['distributor'][$key], 'barang' => $data['belanjadetail']['barang'][$key], 'qty' => $data['belanjadetail']['qty'][$key], 'hargasatuan' => $data['belanjadetail']['total'][$key] / $data['belanjadetail']['qty'][$key], 'total' => $data['belanjadetail']['total'][$key]);
         if (!empty($data['belanjadetail']['id'][$key])) {
             $record['id'] = $data['belanjadetail']['id'][$key];
         }
         $excepted[] = $this->belanjadetail->save($record, $data['waktu'], $reason);
     }
     if (!empty($excepted)) {
         foreach ($this->belanjadetail->find(array('belanja' => $data['id']), array('id' => $excepted)) as $delete) {
             $this->belanjadetail->delete($delete->id, $data['waktu'], $reason);
         }
     }
     if ($oldbelanja['total'] > $databelanja['total']) {
         $this->sirkulasiKeuangan('MASUK', $reason, $oldbelanja['total'] - $databelanja['total'], $data['id'], $data['waktu']);
     } else {
         if ($oldbelanja['total'] < $databelanja['total']) {
             $this->sirkulasiKeuangan('KELUAR', $reason, $databelanja['total'] - $oldbelanja['total'], $data['id'], $data['waktu']);
         }
     }
     return parent::save($databelanja['record']);
 }
Exemplo n.º 7
0
 function save($data, $waktu, $reason, $outlet)
 {
     $data['id'] = parent::save($data);
     $this->sirkulasiBarang($waktu, $data['barang'], 'KELUAR', $reason, $data['id'], $data['qty']);
     $this->sirkulasiBarangOutlet($waktu, $data['barang'], 'MASUK', $reason, $data['id'], $data['qty'], $outlet);
     return $data['id'];
 }
Exemplo n.º 8
0
 function save($data)
 {
     $data['type'] = 'PENGEMBALIAN';
     $data['id'] = parent::save($data);
     $this->sirkulasiKeuangan('KELUAR', 'PENGEMBALIAN PINJAMAN', $data['nominal'], $data['id'], $data['waktu']);
     $CI =& get_instance();
     $CI->load->model('debitur');
     return $this->debitur->saldo($data['debitur'], $data['nominal'], '-');
 }
Exemplo n.º 9
0
 function save($data, $waktu, $reason, $outlet)
 {
     $data['id'] = parent::save($data);
     if ($outlet == 0) {
         $this->sirkulasiProduk($waktu, $data['produk'], 'MASUK', $reason, $data['id'], $data['qty']);
     } else {
         $this->sirkulasiProdukOutlet($waktu, $data['produk'], 'MASUK', $reason, $data['id'], $data['qty'], $outlet);
     }
     return $data['id'];
 }
Exemplo n.º 10
0
 function save($data)
 {
     $record = $this->prepare($data);
     $pengeluaran_id = parent::save($record);
     $CI =& get_instance();
     $CI->load->model('pengeluarandetail');
     foreach ($data['pengeluarandetail']['item'] as $index => $pd) {
         $this->pengeluarandetail->save(array('pengeluaran' => $pengeluaran_id, 'item' => $data['pengeluarandetail']['item'][$index], 'nominal' => $data['pengeluarandetail']['nominal'][$index]));
     }
     $this->sirkulasiKeuangan('KELUAR', 'PENGELUARAN', $record['total'], $pengeluaran_id, $data['waktu']);
 }
Exemplo n.º 11
0
 function save($data)
 {
     $record = array('waktu' => $data['waktu'], 'type' => 'PINJAMAN', 'debitur' => $data['debitur'], 'nominal' => $data['nominal']);
     if (isset($data['id'])) {
         $record['id'] = $data['id'];
         $this->delete($data['id']);
     }
     $fkey = parent::save($record);
     $this->sirkulasiKeuangan('MASUK', 'PEMINJAMAN', $data['nominal'], $fkey, $data['waktu']);
     $this->db->where('id', $data['debitur'])->set('saldo', 'saldo+' . $data['nominal'], false)->update('debitur');
     return $fkey;
 }
Exemplo n.º 12
0
 function save($data, $waktu, $reason)
 {
     $old = isset($data['id']) ? $this->findOne($data['id']) : array();
     $data['id'] = parent::save($data);
     if (empty($old)) {
         $this->sirkulasiBarang($waktu, $data['barang'], 'MASUK', $reason, $data['id'], $data['qty']);
     } else {
         if ($old['qty'] > $data['qty']) {
             $this->sirkulasiBarang($waktu, $data['barang'], 'KELUAR', $reason, $data['id'], $old['qty'] - $data['qty']);
         } else {
             if ($old['qty'] < $data['qty']) {
                 $this->sirkulasiBarang($waktu, $data['barang'], 'MASUK', $reason, $data['id'], $data['qty'] - $old['qty']);
             }
         }
     }
     return $data['id'];
 }
Exemplo n.º 13
0
 function save($data)
 {
     $prepared = $this->prepare($data);
     $data['reason'] = 'PRODUKSI';
     $data['id'] = parent::save($prepared['record']);
     $this->submodel($data);
     return $data['id'];
 }
Exemplo n.º 14
0
 function save($data)
 {
     parent::save($data);
     $this->sirkulasiKeuangan('MASUK', 'PEMASUKAN', $data['nominal'], $this->db->insert_id(), $data['waktu']);
 }
Exemplo n.º 15
0
 function save($data)
 {
     $data['reason'] = 'PESANAN';
     $record = $this->prepare($data);
     $data['id'] = parent::save($record);
     $this->submodel($data);
 }
Exemplo n.º 16
0
 function save($data)
 {
     if (isset($data['id'])) {
         die('x');
     }
     $message = '';
     $waktu = $data['waktu'];
     $outlet = $data['outlet'];
     $transaksi = 'SETORAN';
     $prices = array();
     $pemasukan = 0;
     $pengeluaran = 0;
     $produkDihasilkan = array();
     $bahanTerpakai = array();
     // COLLECT STOCK BARANG DI OUTLET UTK HITUNG PRODUKSI
     $stockBahanOutlet = array();
     foreach ($this->db->get_where('barangoutlet', array('outlet' => $outlet))->result() as $barang) {
         $stockBahanOutlet[$barang->barang] = $barang->stock;
     }
     // VALIDASI SISA BAHAN
     foreach ($data['setoransisabarang']['barang'] as $index => $barang) {
         if (!isset($stockBahanOutlet[$barang])) {
             $message = 'PROSES SUKSES, NAMUN SETORAN SISA BARANG DIBATALKAN KARENA TIDAK DITEMUKAN DI OUTLET';
             unset($data['setoransisabarang']['barang'][$index]);
         }
     }
     // HITUNG TOTAL UANG YANG DISETOR
     foreach ($this->db->get('produk')->result() as $product) {
         $prices[$product->id] = $product->harga;
     }
     foreach ($data['setoranpenjualan']['produk'] as $index => $produk) {
         if (isset($prices[$produk])) {
             $pemasukan += $prices[$produk] * $data['setoranpenjualan']['qty'][$index];
             $data['setoranpenjualan']['currentprice'][$index] = $prices[$produk];
         }
     }
     foreach ($data['setoranpengeluaran']['nominal'] as $index => $nominal) {
         $pengeluaran += $nominal;
     }
     foreach ($data['pesananbayar']['nominal'] as $pesanan) {
         $pemasukan += $pesanan;
     }
     $setoranId = parent::save(array('outlet' => $outlet, 'waktu' => $waktu, 'nominal' => $pemasukan - $pengeluaran));
     $this->sirkulasiKeuanganOutlet('MASUK', 'PEMASUKAN', $pemasukan, $setoranId, $waktu, $outlet);
     $this->sirkulasiKeuanganOutlet('KELUAR', 'PENGELUARAN', $pengeluaran, $setoranId, $waktu, $outlet);
     $this->sirkulasiKeuanganOutlet('KELUAR', 'SETORAN', $pemasukan - $pengeluaran, $setoranId, $waktu, $outlet);
     $this->sirkulasiKeuangan('MASUK', 'SETORAN', $pemasukan - $pengeluaran, $setoranId, $waktu);
     // penjualan
     foreach ($data['setoranpenjualan']['produk'] as $index => $produk) {
         if ($produk == 0) {
             continue;
         }
         $qty = $data['setoranpenjualan']['qty'][$index];
         $this->db->insert('setoranpenjualan', array('setoran' => $setoranId, 'produk' => $produk, 'qty' => $qty, 'currentprice' => $data['setoranpenjualan']['currentprice'][$index]));
         $fkey = $this->db->insert_id();
         $this->sirkulasiProdukOutlet($waktu, $produk, 'KELUAR', 'PENJUALAN OUTLET', $fkey, $qty, $outlet);
         $produkDihasilkan[$produk] = $qty;
     }
     // pengeluaran
     foreach ($data['setoranpengeluaran']['item'] as $index => $item) {
         if ($data['setoranpengeluaran']['nominal'][$index] < 1) {
             continue;
         }
         $this->db->insert('setoranpengeluaran', array('setoran' => $setoranId, 'item' => $item, 'nominal' => $data['setoranpengeluaran']['nominal'][$index]));
     }
     // sisa produk
     foreach ($data['setoransisaproduk']['produk'] as $index => $produk) {
         if ($produk == 0) {
             continue;
         }
         $qty = $data['setoransisaproduk']['qty'][$index];
         $this->db->insert('setoransisaproduk', array('setoran' => $setoranId, 'produk' => $produk, 'qty' => $qty));
         $fkey = $this->db->insert_id();
         $this->sirkulasiProdukOutlet($waktu, $produk, 'KELUAR', 'SETORAN SISA', $fkey, $qty, $outlet);
         $this->sirkulasiProduk($waktu, $produk, 'MASUK', 'SETORAN SISA', $fkey, $qty);
         if (isset($produkDihasilkan[$produk])) {
             $produkDihasilkan[$produk] += $qty;
         } else {
             $produkDihasilkan[$produk] = $qty;
         }
     }
     // sisa bahan
     foreach ($data['setoransisabarang']['barang'] as $index => $barang) {
         if ($barang == 0) {
             continue;
         }
         $qty = $data['setoransisabarang']['qty'][$index];
         $this->db->insert('setoransisabarang', array('setoran' => $setoranId, 'barang' => $barang, 'qty' => $qty));
         $fkey = $this->db->insert_id();
         $this->sirkulasiBarangOutlet($waktu, $barang, 'KELUAR', 'SETORAN SISA', $fkey, $qty, $outlet);
         $this->sirkulasiBarang($waktu, $barang, 'MASUK', 'SETORAN SISA', $fkey, $qty);
         $bahanTerpakai[$barang] = $stockBahanOutlet[$barang] - $qty;
     }
     foreach ($data['setoranbarangoutlet']['barang'] as $index => $barang) {
         if ($barang == 0) {
             continue;
         }
         $qty = $data['setoranbarangoutlet']['qty'][$index];
         $this->db->insert('setoranbarangoutlet', array('setoran' => $setoranId, 'barang' => $barang, 'qty' => $qty));
         $this->db->where('outlet', $outlet)->where('barang', $barang)->set('stock', $qty)->update('barangoutlet');
         if (isset($bahanTerpakai[$barang])) {
             $bahanTerpakai[$barang] -= $qty;
         } else {
             $bahanTerpakai[$barang] = $qty;
         }
     }
     // HITUNG PRODUKSI OUTLET
     $this->db->insert('produksi', array('waktu' => $waktu, 'karyawan' => $data['karyawan'], 'outlet' => $outlet, 'setoran' => $setoranId));
     $produksiId = $this->db->insert_id();
     // SELURUH AYAM DI OUTLET PASTI HABIS DI PRODUKSI
     $seluruhAyam = $this->db->get_where('ayamoutlet', array('outlet' => $outlet))->result();
     foreach ($seluruhAyam as $ayam) {
         $this->db->insert('produksiayam', array('produksi' => $produksiId, 'ayam' => $ayam->ayam, 'pcs' => $ayam->pcs, 'kg' => $ayam->kg));
         $fkey = $this->db->insert_id();
         $this->sirkulasiAyamOutlet($waktu, $ayam->ayam, 'KELUAR', 'PRODUKSI', $fkey, $ayam->pcs, $ayam->kg, $outlet);
     }
     foreach ($bahanTerpakai as $barang => $qty) {
         $this->db->insert('produksibarang', array('produksi' => $produksiId, 'barang' => $barang, 'qty' => $qty));
         $fkey = $this->db->insert_id();
         $this->sirkulasiBarangOutlet($waktu, $barang, 'KELUAR', 'PRODUKSI', $fkey, $qty, $outlet);
     }
     foreach ($produkDihasilkan as $produk => $qty) {
         $this->db->insert('produksiproduk', array('produksi' => $produksiId, 'produk' => $produk, 'qty' => $qty));
         $fkey = $this->db->insert_id();
         $this->sirkulasiProdukOutlet($waktu, $produk, 'MASUK', 'PRODUKSI', $fkey, $qty, $outlet);
     }
     if ($data['pesananbayar']['id'][0] > 0) {
         foreach ($data['pesananbayar']['id'] as $index => $pesanan) {
             $nominal = $data['pesananbayar']['nominal'][$index];
             $this->db->insert('pesananbayar', array('setoran' => $setoranId, 'pesanan' => $pesanan, 'nominal' => $nominal));
             $fkey = $this->db->insert_id();
             $master = $this->db->get_where('pesanan', array('id' => $pesanan))->row_array();
             $total = $master['total'];
             foreach ($this->db->get_where('pesananbayar', array('pesanan' => $pesanan))->result() as $bayar) {
                 $total -= $bayar->nominal;
             }
             if ($total <= 0) {
                 $this->db->where('id', $pesanan)->set('lunas', 1)->update('pesanan');
             }
             $this->sirkulasiKeuangan('MASUK', 'BAYAR PESANAN', $nominal, $fkey, $waktu);
         }
     }
     return $message;
 }
Exemplo n.º 17
0
 function save($data)
 {
     $record = $this->prepare($data);
     $data['reason'] = 'BAWAAN';
     $data['id'] = parent::save($record);
     $this->submodel($data);
     $this->bawaanmodal($data);
 }
Exemplo n.º 18
0
 function save($data)
 {
     $data['reason'] = 'TRANSAKSI ANTAR OUTLET';
     $record = $this->prepare($data);
     $data['id'] = parent::save($record);
     $this->internalreceh($data);
     $this->submodel($data);
 }
Exemplo n.º 19
0
 function save($data)
 {
     $reason = 'PEMOTONGAN';
     $prepared = $this->prepare($data);
     $pemotongan_id = parent::save($prepared['record']);
     $this->sirkulasiAyam($data['waktu'], $prepared['ayamhidup']['id'], 'KELUAR', $reason, $pemotongan_id, $data['bahanpcs'], $data['bahankg']);
     $CI =& get_instance();
     $CI->load->model('pemotongandetail');
     foreach ($data['pemotongandetail']['ayam'] as $index => $ayam) {
         if ($ayam == 0) {
             continue;
         }
         $pcs = $data['pemotongandetail']['pcs'][$index];
         $kg = $data['pemotongandetail']['kg'][$index];
         $this->pemotongandetail->save(array('pemotongan' => $pemotongan_id, 'ayam' => $ayam, 'pcs' => $pcs, 'kg' => $kg), $data['waktu'], $reason);
     }
 }
Exemplo n.º 20
0
 function save($data)
 {
     $data['saldo'] = parent::cashFlowGetSaldo($data['nominal'], $data['type']);
     return parent::save($data);
 }