Search This Blog

Thursday, November 28, 2019

onclick , delete codeigniter



<td><a href="<?php echo base_url();?>site/ceditpelangganpage/<?php echo $value['idpelanggan']; ?>" class="btn btn-success">Edit </a>
<a onClick="javascript:return confirm('yakin hapus <?php echo $value['namapelanggan']; ?> coy ? ');"href="<?php echo base_url();?>site/cdeletepelanggan/<?php echo $value['idpelanggan']; ?>" class="btn btn-warning"> Del </a>
<a href="<?php echo base_url();?>site/cdetailpelanggan/<?php echo $value['idpelanggan']; ?>" class="btn btn-danger"> More</a>
</td>


Regards,


HERY PURNAMA

Certified IT Trainer
http://www.inhousetrainer.net

 Call/ SMS/WA :  081.223344.506 , BBM : 7DC633AA
 
 
 Social Net :

Hometown : Bandung - Jawa Barat

Please consider your environmental responsibility. Before printing this e-mail message, ask yourself whether you really need a hard copy.





Codeigniter proses tambah pelanggan

    public function ctambahpelangganprocess() {
        $varnama    = $this->input->post('nama');
        $varkota    = $this->input->post('kota');
        $vardetail  = $this->input->post('detail');

        //semua variable diatas harus ditampung menjadi 1 object sebelum dikirim
        $varobject = array(
            'namapelanggan' => $varnama, //array item namapelanggan harus sama dgn nama kolom di tabel db
            'kotapelanggan' => $varkota,
            'detailpelanggan' => $vardetail
        );

        $processquery = $this->db->insert('tbpelanggan',$varobject) ;

        if($processquery) {
            $data['pesan'] = 'data sukses ditambahkan';
            //halaman redirect after sukses tambah
            $data['content'] = 'vdisduk/vpelanggan/vlistpelanggan';
            $this->load->view('vtemplate/template',$data);

        }
        else //jika gagal insert
        {
            $data['pesan'] = "Gagal tambah pelanggan";
            $data['content'] = 'vdisduk/vpelanggan/vform';
            $this->load->view('vtemplate/template',$data);

        }






Regards,


HERY PURNAMA

Certified IT Trainer
http://www.inhousetrainer.net

 Call/ SMS/WA :  081.223344.506 , BBM : 7DC633AA
 
 
 Social Net :

Hometown : Bandung - Jawa Barat

Please consider your environmental responsibility. Before printing this e-mail message, ask yourself whether you really need a hard copy.





Codeigniter Tambah Pelanggan


controlller site.php

public function ctambahpelangganpage() {

$data['content'] = 'vdisduk/vpelanggan/vform';
$this->load->view('vtemplate/template',$data);

}

--------------------------
vform.php

<form  action="/action_page.php">
  <div class="form-group">
    <label for="nama">Nama Pelanggan:</label>
    <input type="text" class="form-control" id="nama" name="detail" placeholder="Isikan nama">
  </div>
 
  <div class="form-group">
    <label for="kota">Kota Pelanggan:</label>
    <input type="text" class="form-control" id="kota" name="kota" placeholder="Isikan kota">
  </div>

 <div class="form-group">
    <label for="detail">Detail Pelanggan:</label>
    <textarea class="form-control" rows="5" id="detail" name="detail">></textarea>
  </div>


  <button type="submit" class="btn btn-primary">Tambah</button>
  <button type="reset" class="btn btn-primary">Reset</button>
</form>

--------------------------------------------
vlistpelanggan.php

<div class="container">
<a  href="<?php echo base_url()?>site/ctambahpelangganpage" class="btn btn-primary">Tambah </a>
<p>
            <table  class="table table-striped">
                <tr>
                <th>ID Pelanggan </th>
                    <th>NAMA </th>
                    <th>KOTA</th>
                    <th>Admin</th>
                </tr>
                <?php foreach($varpelanggan as $key => $value) { ?>
                    <tr>
                        <td><?php echo $value['idpelanggan']; ?> </td>
                        <td><?php echo $value['namapelanggan']; ?> </td>
                        <td><?php echo $value['kotapelanggan']; ?> </td>
                        <td><a  href="#" class="btn btn-success">Edit </a>
                            <a href="#" class="btn btn-warning"> Del </a>
                            <a href="<?php base_url();?>index.php/site/cdetailpelanggan/<?php echo $value['idpelanggan']; ?>" class="btn btn-danger"> More</a>
                        </td>
                    </tr>
                <?php } ?>
            </table>

</div>

}




Regards,


HERY PURNAMA

Certified IT Trainer
http://www.inhousetrainer.net

 Call/ SMS/WA :  081.223344.506 , BBM : 7DC633AA
 
 
 Social Net :

Hometown : Bandung - Jawa Barat

Please consider your environmental responsibility. Before printing this e-mail message, ask yourself whether you really need a hard copy.





CONFIGURATION CODEIGNITER 2.2 FOR ORACLE 11 G database.php

Cara Konfigurasi PHP Codeigniter 2.2 , php 5.3 oci8 ke oracle 11g

$db['default']['hostname'] = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID=ORCL)))';
$db['default']['username'] = 'hery';
$db['default']['password'] = 'hery';
$db['default']['database'] = '';
$db['default']['dbdriver'] = 'oci8';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;




Regards,


HERY PURNAMA

Certified IT Trainer
http://www.inhousetrainer.net

 Call/ SMS/WA :  081.223344.506 , BBM : 7DC633AA
 
 
 Social Net :

Hometown : Bandung - Jawa Barat

Please consider your environmental responsibility. Before printing this e-mail message, ask yourself whether you really need a hard copy.





Wednesday, November 27, 2019

vlistpelanggan.php

<div class="container">
<table class="table" width="400" border="1">
<tr>
<th>ID Pelanggan </th>
<th>NAMA </th>
<th>KOTA</th>
<th>Admin</th>
</tr>
<?php foreach($varpelanggan as $key => $value) { ?>
<tr>
<td><?php echo $value['idpelanggan']; ?> </td>
<td><?php echo $value['namapelanggan']; ?> </td>
<td><?php echo $value['kotapelanggan']; ?> </td>
<td><a href="#" class="btn btn-success">Edit </a>
<a href="#" class="btn btn-warning"> Del </a>
<a href="#" class="btn btn-danger"> More</a>
</td>
</tr>
<?php } ?>
</table>

</div>




Regards,


HERY PURNAMA

Certified IT Trainer
http://www.inhousetrainer.net

 Call/ SMS/WA :  081.223344.506 , BBM : 7DC633AA
 
 
 Social Net :

Hometown : Bandung - Jawa Barat

Please consider your environmental responsibility. Before printing this e-mail message, ask yourself whether you really need a hard copy.





site.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Site extends CI_Controller {

        
        public function __construct(){
                parent::__construct();
                //kosongkan sementara
                //$this->load->model('sitemodel');
                
         }
        
        public function index()
        {
$this->load->view('vdisduk/home');
        }

        public function about()
        {
$this->load->view('vdisduk/home');
        }

        public function admin()
        {
$this->load->view('vdisduk/home');
        }

        public function login()
        {
$this->load->view('vdisduk/home');
        }

        public function logout()
        {
$this->load->view('vdisduk/home');
        }

        #---------best practive with db-----------------
        public function clistpelanggan()
        {
        
                //load model dahulu
                $this->load->model('sitemodel'); //sudah di wakilkan di construct
                $this->load->helper('url');
                // agar tidak perlu dipanggil berkali kali

                //load function berisi logic/ proses yang dibuat dalam model
                $data['varpelanggan'] = $this->sitemodel->mlistpelanggan()
                                                        ->result_array();
                $this->load->view('vdisduk/vpelanggan/vlistpelanggan.php',$data);
        }

        public function clistproduk()
        {
                //load model dahulu
                $this->load->model('sitemodel'); //sudah di wakilkan di construct
                // agar tidak perlu dipanggil berkali kali
                //load function berisi logic/ proses yang dibuat dalam model
                $data['varproduk'] = $this->sitemodel->mlistproduk();
                $this->load->view('vdisduk/vproduk/vlistproduk.php',$data);

        }

        public function clistorders()
        {
                                //load model dahulu
                $this->load->model('sitemodel'); //sudah di wakilkan di construct
                // agar tidak perlu dipanggil berkali kali
                //load function berisi logic/ proses yang dibuat dalam model
                $data['varorders'] = $this->sitemodel->mlistorders();
                $this->load->view('vdisduk/vorders/vlistorders.php',$data);

        }

}






Regards,


HERY PURNAMA

Certified IT Trainer
http://www.inhousetrainer.net

 Call/ SMS/WA :  081.223344.506 , BBM : 7DC633AA
 
 
 Social Net :

Hometown : Bandung - Jawa Barat

Please consider your environmental responsibility. Before printing this e-mail message, ask yourself whether you really need a hard copy.





SITEMODEL.PHP

<?php
defined('BASEPATH') OR exit ('no direct script');

class Sitemodel extends CI_Model {


public function mlistpelanggan() {
$data = $this->db->order_by('idpelanggan','DESC')
->get('tbpelanggan');
return $data;

}
public function mlistproduk() {

$data = $this->db->get('tbproduk');
return $data ;
//return $this->db->get('tbproduk');

}

public function mlistorders() {
$data = $this->db->query("select    b.idorders,
        a.namapelanggan,
a.kotapelanggan,
c.namaproduk,
c.harga,
b.jumlahorder,
(c.harga * b.jumlahorder) as total,
b.tglorder
from tbpelanggan a join tborders b
        on a.idpelanggan = b.idpelanggan
join tbproduk as c
on b.idproduk = c.idproduk
order by b.idorders desc");
return $data;
}



}





Regards,


HERY PURNAMA

Certified IT Trainer
http://www.inhousetrainer.net

 Call/ SMS/WA :  081.223344.506 , BBM : 7DC633AA
 
 
 Social Net :

Hometown : Bandung - Jawa Barat

Please consider your environmental responsibility. Before printing this e-mail message, ask yourself whether you really need a hard copy.





Db Order sample

select b.idorders,
        a.namapelanggan,
        a.kotapelanggan,
        c.namaproduk,
        c.harga,
        b.jumlahorder,
        (c.harga * b.jumlahorder) as total,
        b.tglorder
       
from tbpelanggan a join tborders b  
            on a.idpelanggan = b.idpelanggan
        join tbproduk as c
                    on b.idproduk = c.idproduk
       
 order by b.idorders desc




Regards,


HERY PURNAMA

Certified IT Trainer
http://www.inhousetrainer.net

 Call/ SMS/WA :  081.223344.506 , BBM : 7DC633AA
 
 
 Social Net :

Hometown : Bandung - Jawa Barat

Please consider your environmental responsibility. Before printing this e-mail message, ask yourself whether you really need a hard copy.