SlideShare a Scribd company logo
Rahadyan Dharmaparayana Gusti (30210172)
         Suslianto Hadi Saputra (30210213)
         Ayu Ekarani Swanditha (30210178)
Ext JS adalah librari Javascript yang membuat
tampilan aplikasi web menjadi desktop aplikasi.
   Sebelum itu download Codeigniter dan EXTJs
   Buat struktur seperti ini
   Kita buat databasenya di phpmyadmin
    CREATE TABLE IF NOT EXISTS `phonebook`
    (`ID` int(11) NOT NULL
    AUTO_INCREMENT,`NAME` varchar(255) NOT
    NULL,`ADDRESS` varchar(255) NOT
    NULL,`PHONE` varchar(20) NOT NULL,`TYPE`
    tinyint(1) NOT NULL DEFAULT '0',`STATUS`
    tinyint(1) NOT NULL DEFAULT '0',PRIMARY
    KEY (`ID`))
   kemudian ubah konfigurasi pada
    application/config/database.php
   Kemudian masuk ke “model”, buat file phonebook_model.php
    <?php
    if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    class Phonebook_model extends CI_Model {
              function __construct(){
                          parent::__construct();
              }           // mengambil data phonebook
    function get($start, $limit){
                          $rows = $this->db->get('phonebook', $limit, $start);
                          if ($this->count() > 0){
                                       foreach ($rows->result() as $row){
                                                    $item = array('ID' => $row->ID,
                                                      'NAME' => $row->NAME,
                                                      'ADDRESS' => $row->ADDRESS,
                                                      'PHONE' => $row->PHONE,
                                                      'TYPE' => $row->TYPE,
                                                                    'STATUS' => $row->STATUS);
                                                                  $items[] = $item;
                                       }
                                       $data = json_encode($items);
                                       return $data;
                          }
                          return NULL;
              }
              function insert($data){
              }
              function update($id, $data){
              }
              function delete($id){
              }           // menghitung jumlah data di table phonebook
              function count()
              {
                          return $this->db->count_all('phonebook');
              }
    }/* End of file phonebook_model.php *//* Location: ./application/models/phonebook_model.php */
   Kemudian kita masuk ke View, ganti isi welcome_message.php menjadi seperti
    ini:
    <!DOCTYPE html><html lang="en">
    <head><title>Welcome to CodeIgniter</title>
    <link rel="stylesheet" type="text/css“ href="extjs/resources/css/ext-all.css" />
    <style type="text/css" media="screen">
    .menu {
    background-image: url(images/preview.png) !important;
    }
    #about-title {
       font-size:16px;
     padding-bottom: 20px;
     display:block;
    }
    #about-content {
       border-top: 1px solid #ccc;
    }
    </style>
    <script type="text/javascript">
          var base_url = <?php echo '"'.base_url().'"„;?>;
    </script>
    </head>
    <body>
    <script type="text/javascript" src="extjs/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="extjs/ext-all.js"></script>
    <script type="text/javascript" src="js/home.js"></script>
    </body>
    </html>
   Kemudian kita masuk ke Controller buat welcome.php
    <?php
    if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    class Welcome extends CI_Controller {
                function __construct(){
                                  parent::__construct();
                                                   $this->load->model('phonebook_model', 'phonebook');                }
                function index(){
                                  $this->load->view('welcome_message');
                }
                function task(){
                                  switch ($this->input->post('task')) {
                                                   case 'get':
                                                                       $this->pb_get();
                                                   break;
                                                   case 'create':
                                                                       $this->pb_create();
                                                   break;
                                                   case 'update':
                                                                       $this->pb_update();
                                                   break;
                                                   case 'delete':
                                                                       $this->pb_delete();
                                                   break;
                                                   default:
                                                   break;
                                  }
                }
                private function pb_get(){
                                  $start = 0;
                                  $limit = 10;
                                                   if ($this->input->post('start') && $this->input->post('limit')){
                                                   $start = $this->input->post('start');
                                                   $limit = $this->input->post('limit');
                                  }
                                  $cnt = $this->phonebook->count();
                                  if ($cnt > 0){
                                                   $data = $this->phonebook->get($start, $limit);
                                                   echo '({"total":"'.$cnt.'", "results":'.$data.'})';
                                  }
                                  else{
                                                   echo '({"total":"0", "results":""})';
                                  }
                }
                                  private function pb_create(){
                                  ;}
                                  private function pb_update(){
                                  ;}
                                  private function pb_delete(){
                                  ;}
                }/* End of file welcome.php *//* Location: ./application/controllers/welcome.php */
   Kemudian kita buat home.js dimasukan ke folder js,
    isinya:
    Ext.ns('Phonebook','Phonebook.fn', 'Phonebook.data');
    Phonebook.data.dataStore = new Ext.data.Store({
    proxy : new Ext.data.HttpProxy({
          url : base_url + 'index.php/welcome/task/',
            method: 'POST„
        }),
        baseParams:{task: "get"},
        reader : new Ext.data.JsonReader({
                root: 'results',
                totalProperty: 'total„
            }, [
                {name: 'ID', mapping: 'ID'},
                {name: 'NAME', mapping: 'NAME'},
                {name: 'ADDRESS', mapping: 'ADDRESS'},
                {name: 'PHONE', mapping: 'PHONE'},
                {name: 'TYPE', mapping: 'TYPE'},
                {name: 'STATUS', mapping: 'STATUS'}
            ]
        )
    });
var fm = Ext.form;
    Ext.util.Format.comboRenderer = function(combo){
    return function(value){
        var record = combo.findRecord(combo.valueField, value);
        return record ? record.get(combo.displayField) :
    combo.valueNotFoundText;
    };
};
Phonebook.data.txtName = new fm.TextField({
    allowBlank: false
});
Phonebook.data.txtAddress = new fm.TextField({
    allowBlank: false
});
Phonebook.data.txtPhone = new fm.TextField({
    allowBlank: false
});
Phonebook.data.comboStatus = new fm.ComboBox({
    typeAhead: true,
    triggerAction: 'all',
    store:new Ext.data.SimpleStore({
       fields:['id', 'status'],
       data: [['0','Inactive'],['1','Active']]
    }),
mode: 'local',
  forceSelection: true,
  displayField: 'status',
  valueField: 'id',
  lazyRender:true,
  listClass: 'x-combo-list-small„
});
Phonebook.data.comboType = new fm.ComboBox({
    typeAhead: true,
    triggerAction: 'all',
    store:new Ext.data.SimpleStore({
       fields:['id', 'type'],
       data: [['0','Phone'],['1','Mobile']]
    }),
    mode: 'local',
    forceSelection: true,
    displayField: 'type',
    valueField: 'id',
    lazyRender:true,
    listClass: 'x-combo-list-small„
});
Phonebook.data.columnModel = new Ext.grid.ColumnModel({
defaults : {
      sortable: true
  }, columns : [
      { header: 'ID',
           dataIndex: 'ID',
           width: 30,
       },{
           header: 'NAME',
           dataIndex: 'NAME',
           width: 200,
           editor: Phonebook.data.txtName
       },{
           header: 'ADDRESS',
           dataIndex: 'ADDRESS',
           width: 290,
           editor: Phonebook.data.txtAddress
},{
              header: 'PHONE',
              dataIndex: 'PHONE',
              width: 100,
              editor: Phonebook.data.txtPhone
        },{
             header: 'TYPE',
             dataIndex: 'TYPE',
             width: 75,
             editor: Phonebook.data.comboType,
             renderer:
      Ext.util.Format.comboRenderer(Phonebook.data.comboType)
         },{
             header: 'STATUS',
             dataIndex: 'STATUS',
             width: 75,
             editor: Phonebook.data.comboStatus,
             renderer:
      Ext.util.Format.comboRenderer(Phonebook.data.comboStatus)
         }
      ]
});
// grid untuk menampilkan data
Phonebook.data.dataGrid = new Ext.grid.EditorGridPanel({
    store: Phonebook.data.dataStore,
    cm: Phonebook.data.columnModel,
    autoScroll: true,
    style: {padding: 5},
    id: 'merkGrid',
    selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
    bbar: new Ext.PagingToolbar({
       pageSize: 20,
       store: Phonebook.data.dataStore,
       displayInfo: true
    })
});

// window untuk menampung grid
Phonebook.fn.showData = function() {
   // window data
   var windowData = new Ext.Window({
      title: 'Phonebook',
      closable:true,
      closeAction: 'hide',
      width:800,
      height:350,
      border: false,
      plain:true,
modal: true,
       layout: 'fit',
       items: [Phonebook.data.dataGrid]
     });
     // load data ke dalam datastore
     Phonebook.data.dataStore.reload();
     windowData.show(this);
};

//untuk memunculkan window About Application
Phonebook.fn.showAbout = function() {
  var htmlAbout = '<div id="about-title">Application v0.1</div>';
  htmlAbout += '<div id="about-content">brief description about the application</div>„

     var windowAbout = new Ext.Window({
         title: 'About Application',
         closable:true,
         resizable: false,
         width:250,
         height:150,
         border: false,
         plain:true,
         layout: 'fit',
         padding: '3',
         html: htmlAbout,
         items: []
     });

     windowAbout.show(this);
};
Phonebook.app = function(){

  return {
     init: function(){
        // menu
        var toolbar = new Ext.Toolbar({
            height: 30,
            items: [{
                iconCls: 'menu',
                text: 'Applications',
                menu: new Ext.menu.Menu({
                    items:[{
                       text: 'Phonebook',
                       handler: Phonebook.fn.showData
                    }]
                })
            },'-',{
                iconCls: 'menu',
                text: 'Help',
                menu: new Ext.menu.Menu({
                    items:[{
                       text: 'About Aplication',
handler: Phonebook.fn.showAbout
                             }]
                        })
                   }]
             });

             // frame paling luar
             var viewport = new Ext.Viewport({
                 layout:'border',
                 items:[
                    new Ext.BoxComponent({
                        region: 'north',
                        height: 25,
                        autoEl: {
                           tag: 'div',
                           style: 'padding: 5px 10px; color: #ff0000;',
                           html:'<p><b>PHONEBOOK</b></p>„
                        }
                    }),{
                        region:'center',
                        margins:'2 2 2 2',
                        items: toolbar
                    }
                 ]
             });
         }
    };
}();

Ext.onReady(Phonebook.app.init, Phonebook.app);
   Kembali ke phonebook_model.php pada folder module
    ganti insert,update dan delete
    function insert($data)
    {
     $this->db->insert("phonebook", $data);
}

function update($id, $data)
{
  $this->db->where('ID', $id);
  $this->db->update('phonebook', $data);
}

function delete($id)
{
  $this->db->where('ID', $id);
  $this->db->delete('phonebook');
}
   Berikut method pb_create, pb_update,
    dan pb_delete pada welcome.php pada folder view
    private function pb_create()
{
    $data = array ("NAME" => $this->input->post('NAME'),
               "ADDRESS" => $this->input->post('ADDRESS'),
               "PHONE" => $this->input->post('PHONE'),
               "TYPE" => $this->input->post('TYPE'),
               "STATUS" => $this->input->post('STATUS')
          );
    if (!empty($data))
    {
        $this->phonebook->insert($data);
        echo '({"status":1})';
    }
    else
    {
        echo '({"status":0})';
    }
}
private function pb_update()
{
   $id = $this->input->post('ID');
   $data = array ("NAME" => $this->input->post('NAME'),
              "ADDRESS" => $this->input->post('ADDRESS'),
              "PHONE" => $this->input->post('PHONE'),
              "TYPE" => $this->input->post('TYPE'),
              "STATUS" => $this->input->post('STATUS')
          );
   if (!is_null($id) && !empty($data))
   {
       $this->phonebook->update($id, $data);
       echo '({"status":1})';
   }
   else
   {
       echo '({"status":0})';
   }
}

private function pb_delete()
{
   $id = $this->input->post('id');
   if (!is_null($id))
   {
       $this->phonebook->delete($id);
       echo '({"status":1})';
   }
   else
   {
       echo '({"status":0})';
   }
}

More Related Content

What's hot

Dependency Injection IPC 201
Dependency Injection IPC 201Dependency Injection IPC 201
Dependency Injection IPC 201Fabien Potencier
 
Silex meets SOAP & REST
Silex meets SOAP & RESTSilex meets SOAP & REST
Silex meets SOAP & REST
Hugo Hamon
 
PHP Data Objects
PHP Data ObjectsPHP Data Objects
PHP Data Objects
Wez Furlong
 
You code sucks, let's fix it
You code sucks, let's fix itYou code sucks, let's fix it
You code sucks, let's fix it
Rafael Dohms
 
Object Calisthenics Applied to PHP
Object Calisthenics Applied to PHPObject Calisthenics Applied to PHP
Object Calisthenics Applied to PHP
Guilherme Blanco
 
PHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くためにPHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くために
Yuya Takeyama
 
Command Bus To Awesome Town
Command Bus To Awesome TownCommand Bus To Awesome Town
Command Bus To Awesome Town
Ross Tuck
 
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)Fabien Potencier
 
Doctrine fixtures
Doctrine fixturesDoctrine fixtures
Doctrine fixturesBill Chang
 
Internationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsInternationalizing CakePHP Applications
Internationalizing CakePHP Applications
Pierre MARTIN
 
Models and Service Layers, Hemoglobin and Hobgoblins
Models and Service Layers, Hemoglobin and HobgoblinsModels and Service Layers, Hemoglobin and Hobgoblins
Models and Service Layers, Hemoglobin and Hobgoblins
Ross Tuck
 
Dependency injection in PHP 5.3/5.4
Dependency injection in PHP 5.3/5.4Dependency injection in PHP 5.3/5.4
Dependency injection in PHP 5.3/5.4Fabien Potencier
 
Object Calisthenics Adapted for PHP
Object Calisthenics Adapted for PHPObject Calisthenics Adapted for PHP
Object Calisthenics Adapted for PHP
Chad Gray
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium Apps
Nate Abele
 
Mocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnitMocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnit
mfrost503
 
PHP 5.4
PHP 5.4PHP 5.4
Dependency injection-zendcon-2010
Dependency injection-zendcon-2010Dependency injection-zendcon-2010
Dependency injection-zendcon-2010Fabien Potencier
 

What's hot (20)

Agile database access with CakePHP 3
Agile database access with CakePHP 3Agile database access with CakePHP 3
Agile database access with CakePHP 3
 
Dependency Injection IPC 201
Dependency Injection IPC 201Dependency Injection IPC 201
Dependency Injection IPC 201
 
Silex meets SOAP & REST
Silex meets SOAP & RESTSilex meets SOAP & REST
Silex meets SOAP & REST
 
PHP Data Objects
PHP Data ObjectsPHP Data Objects
PHP Data Objects
 
You code sucks, let's fix it
You code sucks, let's fix itYou code sucks, let's fix it
You code sucks, let's fix it
 
Object Calisthenics Applied to PHP
Object Calisthenics Applied to PHPObject Calisthenics Applied to PHP
Object Calisthenics Applied to PHP
 
PHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くためにPHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くために
 
Command Bus To Awesome Town
Command Bus To Awesome TownCommand Bus To Awesome Town
Command Bus To Awesome Town
 
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
 
Doctrine fixtures
Doctrine fixturesDoctrine fixtures
Doctrine fixtures
 
Internationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsInternationalizing CakePHP Applications
Internationalizing CakePHP Applications
 
Models and Service Layers, Hemoglobin and Hobgoblins
Models and Service Layers, Hemoglobin and HobgoblinsModels and Service Layers, Hemoglobin and Hobgoblins
Models and Service Layers, Hemoglobin and Hobgoblins
 
Dependency injection in PHP 5.3/5.4
Dependency injection in PHP 5.3/5.4Dependency injection in PHP 5.3/5.4
Dependency injection in PHP 5.3/5.4
 
Object Calisthenics Adapted for PHP
Object Calisthenics Adapted for PHPObject Calisthenics Adapted for PHP
Object Calisthenics Adapted for PHP
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium Apps
 
Mocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnitMocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnit
 
PHP 5.4
PHP 5.4PHP 5.4
PHP 5.4
 
Dependency injection-zendcon-2010
Dependency injection-zendcon-2010Dependency injection-zendcon-2010
Dependency injection-zendcon-2010
 
Separation of concerns - DPC12
Separation of concerns - DPC12Separation of concerns - DPC12
Separation of concerns - DPC12
 
Php 101: PDO
Php 101: PDOPhp 101: PDO
Php 101: PDO
 

Similar to Presentation1

Advanced php testing in action
Advanced php testing in actionAdvanced php testing in action
Advanced php testing in action
Jace Ju
 
Crazy things done on PHP
Crazy things done on PHPCrazy things done on PHP
Crazy things done on PHPTaras Kalapun
 
Your code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnConYour code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnCon
Rafael Dohms
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
Rifat Nabi
 
Adding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsAdding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy Applications
Sam Hennessy
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Masahiro Nagano
 
Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB jhchabran
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6
garux
 
Oops in php
Oops in phpOops in php
Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
 Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011 Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
Alessandro Nadalin
 
究極のコントローラを目指す
究極のコントローラを目指す究極のコントローラを目指す
究極のコントローラを目指す
Yasuo Harada
 
R57shell
R57shellR57shell
R57shell
ady36
 
[PHPCon 2023] “Kto to pisał?!... a, to ja.”, czyli sposoby żeby znienawidzić ...
[PHPCon 2023] “Kto to pisał?!... a, to ja.”, czyli sposoby żeby znienawidzić ...[PHPCon 2023] “Kto to pisał?!... a, to ja.”, czyli sposoby żeby znienawidzić ...
[PHPCon 2023] “Kto to pisał?!... a, to ja.”, czyli sposoby żeby znienawidzić ...
Mateusz Zalewski
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolve
XSolve
 
Tidy Up Your Code
Tidy Up Your CodeTidy Up Your Code
Tidy Up Your Code
Abbas Ali
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Kang-min Liu
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11
Michelangelo van Dam
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
Stoyan Stefanov
 

Similar to Presentation1 (20)

Advanced php testing in action
Advanced php testing in actionAdvanced php testing in action
Advanced php testing in action
 
Crazy things done on PHP
Crazy things done on PHPCrazy things done on PHP
Crazy things done on PHP
 
Your code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnConYour code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnCon
 
Bacbkone js
Bacbkone jsBacbkone js
Bacbkone js
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Adding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsAdding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy Applications
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
 
Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6
 
Oops in php
Oops in phpOops in php
Oops in php
 
Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
 Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011 Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
 
究極のコントローラを目指す
究極のコントローラを目指す究極のコントローラを目指す
究極のコントローラを目指す
 
R57shell
R57shellR57shell
R57shell
 
[PHPCon 2023] “Kto to pisał?!... a, to ja.”, czyli sposoby żeby znienawidzić ...
[PHPCon 2023] “Kto to pisał?!... a, to ja.”, czyli sposoby żeby znienawidzić ...[PHPCon 2023] “Kto to pisał?!... a, to ja.”, czyli sposoby żeby znienawidzić ...
[PHPCon 2023] “Kto to pisał?!... a, to ja.”, czyli sposoby żeby znienawidzić ...
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolve
 
Tidy Up Your Code
Tidy Up Your CodeTidy Up Your Code
Tidy Up Your Code
 
Database api
Database apiDatabase api
Database api
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
 

Recently uploaded

JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 

Recently uploaded (20)

JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 

Presentation1

  • 1. Rahadyan Dharmaparayana Gusti (30210172) Suslianto Hadi Saputra (30210213) Ayu Ekarani Swanditha (30210178)
  • 2. Ext JS adalah librari Javascript yang membuat tampilan aplikasi web menjadi desktop aplikasi.
  • 3.
  • 4.
  • 5. Sebelum itu download Codeigniter dan EXTJs  Buat struktur seperti ini
  • 6. Kita buat databasenya di phpmyadmin CREATE TABLE IF NOT EXISTS `phonebook` (`ID` int(11) NOT NULL AUTO_INCREMENT,`NAME` varchar(255) NOT NULL,`ADDRESS` varchar(255) NOT NULL,`PHONE` varchar(20) NOT NULL,`TYPE` tinyint(1) NOT NULL DEFAULT '0',`STATUS` tinyint(1) NOT NULL DEFAULT '0',PRIMARY KEY (`ID`))  kemudian ubah konfigurasi pada application/config/database.php
  • 7. Kemudian masuk ke “model”, buat file phonebook_model.php <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Phonebook_model extends CI_Model { function __construct(){ parent::__construct(); } // mengambil data phonebook function get($start, $limit){ $rows = $this->db->get('phonebook', $limit, $start); if ($this->count() > 0){ foreach ($rows->result() as $row){ $item = array('ID' => $row->ID, 'NAME' => $row->NAME, 'ADDRESS' => $row->ADDRESS, 'PHONE' => $row->PHONE, 'TYPE' => $row->TYPE, 'STATUS' => $row->STATUS); $items[] = $item; } $data = json_encode($items); return $data; } return NULL; } function insert($data){ } function update($id, $data){ } function delete($id){ } // menghitung jumlah data di table phonebook function count() { return $this->db->count_all('phonebook'); } }/* End of file phonebook_model.php *//* Location: ./application/models/phonebook_model.php */
  • 8. Kemudian kita masuk ke View, ganti isi welcome_message.php menjadi seperti ini: <!DOCTYPE html><html lang="en"> <head><title>Welcome to CodeIgniter</title> <link rel="stylesheet" type="text/css“ href="extjs/resources/css/ext-all.css" /> <style type="text/css" media="screen"> .menu { background-image: url(images/preview.png) !important; } #about-title { font-size:16px; padding-bottom: 20px; display:block; } #about-content { border-top: 1px solid #ccc; } </style> <script type="text/javascript"> var base_url = <?php echo '"'.base_url().'"„;?>; </script> </head> <body> <script type="text/javascript" src="extjs/adapter/ext/ext-base.js"></script> <script type="text/javascript" src="extjs/ext-all.js"></script> <script type="text/javascript" src="js/home.js"></script> </body> </html>
  • 9. Kemudian kita masuk ke Controller buat welcome.php <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Welcome extends CI_Controller { function __construct(){ parent::__construct(); $this->load->model('phonebook_model', 'phonebook'); } function index(){ $this->load->view('welcome_message'); } function task(){ switch ($this->input->post('task')) { case 'get': $this->pb_get(); break; case 'create': $this->pb_create(); break; case 'update': $this->pb_update(); break; case 'delete': $this->pb_delete(); break; default: break; } } private function pb_get(){ $start = 0; $limit = 10; if ($this->input->post('start') && $this->input->post('limit')){ $start = $this->input->post('start'); $limit = $this->input->post('limit'); } $cnt = $this->phonebook->count(); if ($cnt > 0){ $data = $this->phonebook->get($start, $limit); echo '({"total":"'.$cnt.'", "results":'.$data.'})'; } else{ echo '({"total":"0", "results":""})'; } } private function pb_create(){ ;} private function pb_update(){ ;} private function pb_delete(){ ;} }/* End of file welcome.php *//* Location: ./application/controllers/welcome.php */
  • 10. Kemudian kita buat home.js dimasukan ke folder js, isinya: Ext.ns('Phonebook','Phonebook.fn', 'Phonebook.data'); Phonebook.data.dataStore = new Ext.data.Store({ proxy : new Ext.data.HttpProxy({ url : base_url + 'index.php/welcome/task/', method: 'POST„ }), baseParams:{task: "get"}, reader : new Ext.data.JsonReader({ root: 'results', totalProperty: 'total„ }, [ {name: 'ID', mapping: 'ID'}, {name: 'NAME', mapping: 'NAME'}, {name: 'ADDRESS', mapping: 'ADDRESS'}, {name: 'PHONE', mapping: 'PHONE'}, {name: 'TYPE', mapping: 'TYPE'}, {name: 'STATUS', mapping: 'STATUS'} ] ) });
  • 11. var fm = Ext.form; Ext.util.Format.comboRenderer = function(combo){ return function(value){ var record = combo.findRecord(combo.valueField, value); return record ? record.get(combo.displayField) : combo.valueNotFoundText; }; }; Phonebook.data.txtName = new fm.TextField({ allowBlank: false }); Phonebook.data.txtAddress = new fm.TextField({ allowBlank: false }); Phonebook.data.txtPhone = new fm.TextField({ allowBlank: false }); Phonebook.data.comboStatus = new fm.ComboBox({ typeAhead: true, triggerAction: 'all', store:new Ext.data.SimpleStore({ fields:['id', 'status'], data: [['0','Inactive'],['1','Active']] }),
  • 12. mode: 'local', forceSelection: true, displayField: 'status', valueField: 'id', lazyRender:true, listClass: 'x-combo-list-small„ }); Phonebook.data.comboType = new fm.ComboBox({ typeAhead: true, triggerAction: 'all', store:new Ext.data.SimpleStore({ fields:['id', 'type'], data: [['0','Phone'],['1','Mobile']] }), mode: 'local', forceSelection: true, displayField: 'type', valueField: 'id', lazyRender:true, listClass: 'x-combo-list-small„ });
  • 13. Phonebook.data.columnModel = new Ext.grid.ColumnModel({ defaults : { sortable: true }, columns : [ { header: 'ID', dataIndex: 'ID', width: 30, },{ header: 'NAME', dataIndex: 'NAME', width: 200, editor: Phonebook.data.txtName },{ header: 'ADDRESS', dataIndex: 'ADDRESS', width: 290, editor: Phonebook.data.txtAddress
  • 14. },{ header: 'PHONE', dataIndex: 'PHONE', width: 100, editor: Phonebook.data.txtPhone },{ header: 'TYPE', dataIndex: 'TYPE', width: 75, editor: Phonebook.data.comboType, renderer: Ext.util.Format.comboRenderer(Phonebook.data.comboType) },{ header: 'STATUS', dataIndex: 'STATUS', width: 75, editor: Phonebook.data.comboStatus, renderer: Ext.util.Format.comboRenderer(Phonebook.data.comboStatus) } ] });
  • 15. // grid untuk menampilkan data Phonebook.data.dataGrid = new Ext.grid.EditorGridPanel({ store: Phonebook.data.dataStore, cm: Phonebook.data.columnModel, autoScroll: true, style: {padding: 5}, id: 'merkGrid', selModel: new Ext.grid.RowSelectionModel({singleSelect:true}), bbar: new Ext.PagingToolbar({ pageSize: 20, store: Phonebook.data.dataStore, displayInfo: true }) }); // window untuk menampung grid Phonebook.fn.showData = function() { // window data var windowData = new Ext.Window({ title: 'Phonebook', closable:true, closeAction: 'hide', width:800, height:350, border: false, plain:true,
  • 16. modal: true, layout: 'fit', items: [Phonebook.data.dataGrid] }); // load data ke dalam datastore Phonebook.data.dataStore.reload(); windowData.show(this); }; //untuk memunculkan window About Application Phonebook.fn.showAbout = function() { var htmlAbout = '<div id="about-title">Application v0.1</div>'; htmlAbout += '<div id="about-content">brief description about the application</div>„ var windowAbout = new Ext.Window({ title: 'About Application', closable:true, resizable: false, width:250, height:150, border: false, plain:true, layout: 'fit', padding: '3', html: htmlAbout, items: [] }); windowAbout.show(this); };
  • 17. Phonebook.app = function(){ return { init: function(){ // menu var toolbar = new Ext.Toolbar({ height: 30, items: [{ iconCls: 'menu', text: 'Applications', menu: new Ext.menu.Menu({ items:[{ text: 'Phonebook', handler: Phonebook.fn.showData }] }) },'-',{ iconCls: 'menu', text: 'Help', menu: new Ext.menu.Menu({ items:[{ text: 'About Aplication',
  • 18. handler: Phonebook.fn.showAbout }] }) }] }); // frame paling luar var viewport = new Ext.Viewport({ layout:'border', items:[ new Ext.BoxComponent({ region: 'north', height: 25, autoEl: { tag: 'div', style: 'padding: 5px 10px; color: #ff0000;', html:'<p><b>PHONEBOOK</b></p>„ } }),{ region:'center', margins:'2 2 2 2', items: toolbar } ] }); } }; }(); Ext.onReady(Phonebook.app.init, Phonebook.app);
  • 19.
  • 20. Kembali ke phonebook_model.php pada folder module ganti insert,update dan delete function insert($data) { $this->db->insert("phonebook", $data); } function update($id, $data) { $this->db->where('ID', $id); $this->db->update('phonebook', $data); } function delete($id) { $this->db->where('ID', $id); $this->db->delete('phonebook'); }
  • 21. Berikut method pb_create, pb_update, dan pb_delete pada welcome.php pada folder view private function pb_create() { $data = array ("NAME" => $this->input->post('NAME'), "ADDRESS" => $this->input->post('ADDRESS'), "PHONE" => $this->input->post('PHONE'), "TYPE" => $this->input->post('TYPE'), "STATUS" => $this->input->post('STATUS') ); if (!empty($data)) { $this->phonebook->insert($data); echo '({"status":1})'; } else { echo '({"status":0})'; } }
  • 22. private function pb_update() { $id = $this->input->post('ID'); $data = array ("NAME" => $this->input->post('NAME'), "ADDRESS" => $this->input->post('ADDRESS'), "PHONE" => $this->input->post('PHONE'), "TYPE" => $this->input->post('TYPE'), "STATUS" => $this->input->post('STATUS') ); if (!is_null($id) && !empty($data)) { $this->phonebook->update($id, $data); echo '({"status":1})'; } else { echo '({"status":0})'; } } private function pb_delete() { $id = $this->input->post('id'); if (!is_null($id)) { $this->phonebook->delete($id); echo '({"status":1})'; } else { echo '({"status":0})'; } }