SlideShare une entreprise Scribd logo
1  sur  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})';
   }
}

Contenu connexe

Tendances

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
 

Tendances (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 

Dernier (20)

My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 

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