Exemplo n.º 1
0
 public function proses($idpengadaan = null)
 {
     Account::_valLogin();
     $setting_model = new Setting_model();
     $transaksi_model = new Transaksi_model();
     $this->orm->debug = true;
     $data = array();
     $data['idpengadaan'] = $idpengadaan == null ? $setting_model->_getMaxId('idpengadaan', 'pengadaan') : $idpengadaan;
     $data['nomorpengadaan'] = $this->input->post('nomorpengadaan', true);
     $data['tanggalpengadaan'] = Tanggal::sqlDate($this->input->post('tanggalpengadaan', true));
     $data['nomorreff'] = $this->input->post('nomorreff', true);
     $data['idsupplier'] = $this->input->post('idsupplier', true);
     $data['insertby'] = $_SESSION['user']['email'];
     $data['idrefstore'] = $_SESSION['user']['idrefstore'];
     $data['flag_app'] = "WEB";
     if ($idpengadaan == null) {
         $idpengadaan = $data['idpengadaan'];
         $pengadaan = $this->orm->pengadaan();
         $ress = $pengadaan->insert($data);
         Message::_set(isset($ress['idpengadaan']) ? TRUE : FALSE, 'Tambah Data Barang Berhasil', 'Tambah Data Barang Gagal');
         $redirect = 'transaksi/pengadaan';
     } else {
         $pengadaan = $this->orm->pengadaan->where('idpengadaan', $idpengadaan);
         $ress = $pengadaan->update($data);
         Message::_set($idpengadaan != null ? TRUE : FALSE, 'Edit Data Barang Berhasil', 'Edit Data Barang Gagal');
         $redirect = 'transaksi/pengadaan/edit/' . $idpengadaan;
     }
     $this->orm->pengadaandetail->where('idpengadaan', $idpengadaan)->delete();
     $this->orm->transaksibarang->where('idpengadaan', $idpengadaan)->delete();
     $idRefBarang = $this->input->post('idrefbarang');
     $idRefGudang = $this->input->post('idrefgudang');
     $jumlahBarang = $this->input->post('jumlahbarang');
     $keterangan = $this->input->post('keterangan');
     foreach ($idRefBarang as $key => $value) {
         $dataDetilBarang = array();
         $dataDetilBarang['idpengadaandetail'] = $setting_model->_getMaxId('idpengadaandetail', 'pengadaandetail');
         $dataDetilBarang['idpengadaan'] = $idpengadaan;
         $dataDetilBarang['idrefbarang'] = $idRefBarang[$key];
         $dataDetilBarang['idrefgudang'] = $idRefGudang[$key];
         $dataDetilBarang['jumlahbarang'] = $jumlahBarang[$key];
         $dataDetilBarang['keterangan'] = $keterangan[$key];
         if ($dataDetilBarang['idrefbarang'] != 0) {
             $result = $this->orm->pengadaandetail->insert($dataDetilBarang);
             $idPengadaanDetail = $result['idpengadaandetail'];
             $dataTransaksiBarang = array();
             $dataTransaksiBarang['idtransaksibarang'] = $setting_model->_getMaxId('idtransaksibarang', 'transaksibarang');
             $dataTransaksiBarang['transaksi'] = 'TERIMA';
             $dataTransaksiBarang['tanggaltransaksi'] = Tanggal::sqlDate($this->input->post('tanggalpengadaan'));
             $dataTransaksiBarang['idpengadaandetail'] = $idPengadaanDetail;
             $dataTransaksiBarang['iddeliveryorderdetail'] = 0;
             $dataTransaksiBarang['idpengadaan'] = $idpengadaan;
             $this->orm->transaksibarang->insert($dataTransaksiBarang);
         }
     }
     $transaksi_model->proccessBarangMasuk($idpengadaan);
     redirect($redirect);
 }
Exemplo n.º 2
0
 public function pengadaan($sharingproduct)
 {
     $this->load->model('transaksi/transaksi_model');
     $transaksi_model = new Transaksi_model();
     $setting_model = new Setting_model();
     $data = array();
     $data['idpengadaan'] = $setting_model->_getMaxId('idpengadaan', 'pengadaan');
     $data['nomorpengadaan'] = 'SP' . $sharingproduct['idrefstore_pengirim'] . '-' . $sharingproduct['idsharingproduct'];
     $data['tanggalpengadaan'] = date('Y-m-d');
     $data['idsupplier'] = $this->checkSupplier($sharingproduct['idrefstore_pengirim']);
     // function check data store pengirim di supplier
     $data['insertby'] = $_SESSION['user']['email'];
     $data['idrefstore'] = $sharingproduct['idrefstore_pengirim'];
     $data['flag_app'] = "WEB";
     $idpengadaan = $data['idpengadaan'];
     $pengadaan = $this->orm->pengadaan();
     $ress = $pengadaan->insert($data);
     $this->orm->pengadaandetail->where('idpengadaan', $idpengadaan)->delete();
     $this->orm->transaksibarang->where('idpengadaan', $idpengadaan)->delete();
     $dataDetilBarang = array();
     $dataDetilBarang['idpengadaandetail'] = $setting_model->_getMaxId('idpengadaandetail', 'pengadaandetail');
     $dataDetilBarang['idpengadaan'] = $idpengadaan;
     $dataDetilBarang['idrefbarang'] = $sharingproduct['idrefbarang'];
     $dataDetilBarang['jumlahbarang'] = $sharingproduct['jumlah_barang'];
     if ($dataDetilBarang['idrefbarang'] != 0) {
         $result = $this->orm->pengadaandetail->insert($dataDetilBarang);
         $idPengadaanDetail = $result['idpengadaandetail'];
         $dataTransaksiBarang = array();
         $dataTransaksiBarang['idtransaksibarang'] = $setting_model->_getMaxId('idtransaksibarang', 'transaksibarang');
         $dataTransaksiBarang['transaksi'] = 'TERIMA';
         $dataTransaksiBarang['tanggaltransaksi'] = date('Y-m-d');
         $dataTransaksiBarang['idpengadaandetail'] = $idPengadaanDetail;
         $dataTransaksiBarang['iddeliveryorderdetail'] = 0;
         $dataTransaksiBarang['idpengadaan'] = $idpengadaan;
         $this->orm->transaksibarang->insert($dataTransaksiBarang);
     }
     $transaksi_model->proccessBarangMasuk($idpengadaan);
 }