SlideShare uma empresa Scribd logo
1 de 22
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})';
   }
}

Mais conteúdo relacionado

Mais procurados

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 & RESTHugo Hamon
 
PHP Data Objects
PHP Data ObjectsPHP Data Objects
PHP Data ObjectsWez 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 itRafael Dohms
 
Object Calisthenics Applied to PHP
Object Calisthenics Applied to PHPObject Calisthenics Applied to PHP
Object Calisthenics Applied to PHPGuilherme 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 TownRoss 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 ApplicationsPierre 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 HobgoblinsRoss 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 PHPChad Gray
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium AppsNate Abele
 
Mocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnitMocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnitmfrost503
 
Dependency injection-zendcon-2010
Dependency injection-zendcon-2010Dependency injection-zendcon-2010
Dependency injection-zendcon-2010Fabien Potencier
 

Mais procurados (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
 

Semelhante a Presentation1

Advanced php testing in action
Advanced php testing in actionAdvanced php testing in action
Advanced php testing in actionJace 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 UnConRafael Dohms
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency InjectionRifat Nabi
 
Adding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsAdding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsSam 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 6garux
 
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-2011Alessandro Nadalin
 
究極のコントローラを目指す
究極のコントローラを目指す究極のコントローラを目指す
究極のコントローラを目指すYasuo Harada
 
R57shell
R57shellR57shell
R57shellady36
 
[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 / XSolveXSolve
 
Tidy Up Your Code
Tidy Up Your CodeTidy Up Your Code
Tidy Up Your CodeAbbas 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 tek11Michelangelo van Dam
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developersStoyan Stefanov
 

Semelhante a 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
 

Último

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

Último (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

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})'; } }