Hi, I am a newbie here and I want to ask a question about how to call another value from another table and set it as set?
As far I know, the ENUM only allow us to select the one option from the drop down list and I need to multiselect the value namadesain
(where status = approved) from the desain table into namadesain in the pembelian table .
Here is my database
CREATE TABLE IF NOT EXISTS `desain` ( `id` int(11) NOT NULL AUTO_INCREMENT, `namadesain` varchar(25) NOT NULL, `desain` varchar(255) NOT NULL, `tanggalsubmit` date NOT NULL, `tanggalapproval` date NOT NULL, `status` enum('PENDING','REJECTED','APPROVED') NOT NULL DEFAULT 'PENDING', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `pembelian` ( `id` int(11) NOT NULL AUTO_INCREMENT, `namapembelian` varchar(25) NOT NULL, `namadesain` varchar(255) NOT NULL, `idvendor` varchar(3) NOT NULL, `jumlahbeli` int(11) NOT NULL, `jumlahtiba` int(11) NOT NULL, `sisapembelian` int(11) NOT NULL, `hargabeli` float NOT NULL, `keterangan` text NOT NULL, `status` enum('PENDING','LUNAS','SELESAI') NOT NULL DEFAULT 'PENDING', `tanggalbeli` date NOT NULL, `tanggalbayar` date NOT NULL, `tanggaltiba` date NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
and my current controller
function pembelian($status='PENDING', $jumlahtiba=NULL, $sisapembelian=NULL) //$sisapembelian=0 { if (!$this->ion_auth->logged_in()) { redirect('auth/login','refresh'); } else { $crud = new grocery_CRUD(); //$neko = $this->db->get_where('desain',array('status' => 'APPROVED'))->row(); $crud->set_table('pembelian') ->add_subject('Pembelian') ->columns('namadesain','namapembelian','idvendor','sisapembelian','jumlahbeli','hargabeli','tanggalbeli','keterangan','status') //->where('status =','APPROVED') //->where('namadesain',$neko->status) ->display_as('namadesain','Nama Desain') ->display_as('namapembelian','Nama Pembelian') ->display_as('idvendor','ID Vendor') ->display_as('jumlahbeli','Jumlah Pembelian',integer) ->display_as('sisapembelian','Sisa Pembelian',integer) ->display_as('hargabeli','Harga Pembelian',integer) ->display_as('tanggalbeli','Tanggal Pembelian') ->display_as('keterangan','Keterangan') ->display_as('status','Status') // default PENDING ->unset_texteditor('keterangan') ->callback_column('hargabeli',array($this,'valuetoidr')) ->callback_column('sisapembelian',array($this,'hitungsisapembelian')) ->field_type('status','hidden',$status) ->field_type('sisapembelian','hidden',$sisapembelian) ->field_type('jumlahtiba','hidden',$jumlahtiba) //->field_type('namadesain','set',$neko->status) ->field_type('status','enum',array('PENDING')); //->set_relation('namadesain','desain','namadesain') ->set_relation('namadesain','desain','namadesain',array('status' => 'APPROVED'),'priority ASC') ->set_relation('idvendor','vendor','idvendor'); $output = $crud->render(); $this->kekgwpeduliaja($output); } }
Thanks before.