Hybrid View

  1. #1
    Sencha User
    Join Date
    Feb 2013
    Posts
    5
    Vote Rating
    0
    coxy is on a distinguished road

      0  

    Default Please help creating a web app using EXT Js 3.4 + PHP + MySQL. Description inside...

    Please help creating a web app using EXT Js 3.4 + PHP + MySQL. Description inside...


    Okay, I am taking a web app development class and we are using EXT Js as our presentation layer, PHP as our conduit between MySQL and EXT Js.

    The project I decided on was to create a web app for a guitar teacher so that they could add students, edit students, make notes about students and generally just keep track of everyday activities associated with the business.

    I've had no problem creating the EXT Js, or the MySQL database. Those things really haven't been that bad.When I started working on the examples I was given for PHP I realized that it really doesn't apply to my project at all. It just shows some different things. Here is the example.

    PHP Code:
    session_start();
    require_once(
    'database_connection.php');

    if(isset(
    $_REQUEST['action'])){
        switch(
    $_REQUEST['action']){
            case 
    'logon':
            
    $userID=$_REQUEST['userid'];
            
    $password=$_REQUEST['password'];
            
            
    $stmtLogin $dbh->prepare("select * from user where userid=? and pass=sha1(?);");
            
    $stmtLogin->bindParam(1$userID);
            
    $stmtLogin->bindParam(2$password);
            
    $stmtLogin->execute();
            
            if(
    $result $stmtLogin->fetch()){
                
    $id=$result['id'];
                
    $admin=$result['admin'];
                
    $lastname $result['lastname'];
                
    $firstname $result['firstname'];
                
    $deleted $result['deleted'];
                
    $_SESSION['id']=$id;
                
    $_SESSION['admin']=$admin;
                
                if(
    $deleted == 1){
                    echo 
    '{success: false, data{"error_title": "Account Deleted", "errormsg": "User no longer active."}}';
                }
                else{
                echo 
    '({success: true,data:{"admin":"'.$admin.'", "id":"'.$id.'"}})';
                }
            }
            
                else{
                    echo 
    '{success: false, data{"error_title": "Invalid Credentials", "errormsg":"Logon Failed"}}';
                    }
            break;
            
            case 
    'logoff':
                
    session_unset();
                
    session_destroy();
                echo 
    '{success: true,data:{}}';
                break;
            
    /*---Send Message---*/
            
            
    case 'sendmessage':
                if(isset(
    $_SESSION['id'])){
                    
    $toid=$_REQUEST['toid'];
                    
    $fromid=$_REQUEST['fromid'];
                    
    $subject=$_request['subject'];
                    
    $body=$_REQUEST['body'];
                    
                    if (
    $toid='alluser'){
                    
                    if (
    $_SESSION['admin'] == 1){
                        
    $stmtAllUsers $dbh->prepare("select id from user where deleted=0;");
                        
    $stmtAllUsers -> execute(); 
                        
                            while(
    $tmp $stmtAllUsers -> fetch()){
                                    
    $stmtSendMsg $dbh->prepare("insert into message (toid, fromid, subject, body) values (?,?,?,?);");
                                    
    $stmtSendMsg -> bindParam(1,$tmp['id']);
                                    
    $stmtSendMsg -> bindParam(2,$_SESSION['id']);
                                    
    $stmtSendMsg -> bindParam(3,$subject);
                                    
    $stmtSendMsg -> bindParam(4,$body);
                                    
    $stmtSendMsg -> execute();
                                    }
                    }        
                    else{
                        echo 
    '{success: false, data{"error_title": "Error", "errormsg": "Permission Denied"}}';
                        }
                    }
                    
                elseif (
    $toid='alladmin'){
                    if (
    $_SESSION['admin'] == 1){
                        
    $stmtAdmin $dbh->prepare("select id from user where deleted=0 and admin=1");
                        
    $stmtAdmin -> execute();
                        
                        while(
    $tmp $stmtAdmin -> fetch()){
                                    
    $stmtSendMsg $dbh->prepare("insert into message (toid, fromid, subject, body) values (?,?,?,?);");
                                    
    $stmtSendMsg -> bindParam(1,$tmp['id']);
                                    
    $stmtSendMsg -> bindParam(2,$_SESSION['id']);
                                    
    $stmtSendMsg -> bindParam(3,$subject);
                                    
    $stmtSendMsg -> bindParam(4,$body);
                                    
    $stmtSendMsg -> execute();
                        }
                    }                                
                    else{
                        echo 
    '{success: false, data{"error_title": "Error", "errormsg": "Permission Denied"}}';
                        }
                }
                            
                elseif (
    $toid'allnonadmin'){
                    if (
    $_SESSION['admin'] == 1){
                        
    $stmtNonAdmin $dbh->prepare("select id from user where deleted=0 and admin=0");
                        
    $stmtNonAdmin -> execute();
                        
                        while(
    $tmp $stmtNonAdmin -> fetch()){
                                    
    $stmtSendMsg $dbh->prepare("insert into message (toid, fromid, subject, body) values (?,?,?,?);");
                                    
    $stmtSendMsg -> bindParam(1,$tmp['id']);
                                    
    $stmtSendMsg -> bindParam(2,$_SESSION['id']);
                                    
    $stmtSendMsg -> bindParam(3,$subject);
                                    
    $stmtSendMsg -> bindParam(4,$body);
                                    
    $stmtSendMsg -> execute();
                        }
                    }
                
                    else{
                        echo 
    '{success: false, data{"error_title": "Error", "errormsg": "Permission Denied"}}';
                    }
                }
                        
                else{
                            
    $stmtCon $dbh->prepare("select id from user where id=?;");
                            
    $stmtCon -> bindParam(1,$toid);
                            
    $stmtCon -> execute();
                            
                            while(
    $tmp $stmtCon -> fetch()){
                                
    $stmtSendMsg $dbh->prepare("insert into message (toid, fromid, subject, body) values (?,?,?,?);");
                                
    $stmtSendMsg -> bindParam(1,$tmp['id']);
                                
    $stmtSendMsg -> bindParam(2,$_SESSION['id']);
                                
    $stmtSendMsg -> bindParam(3,$subject);
                                
    $stmtSendMsg -> bindParam(4,$body);
                                
    $stmtSendMsg -> execute();
                            }    
                }
        }
    else{
        echo 
    '{success: false, data{"error_title": "Error", "errormsg": "Permission Denied"}}';
        }


                break;
                
                
    /*---Delete Message---*/
                
                
    case 'deletemessage':
                    if(isset(
    $_SESSION['id'])){
                        
    $messageid $_REQUEST['msgid'];
                        
    $stmtToID $dbh->prepare("select toid from message where id=?;");
                        
    $stmtToID -> bindParam(1,$messageid);
                        
    $stmtToID -> execute();
                        
                        if(
    $result $stmtToID -> fetch()){
                            if(
    $result['toid'] == $_SESSION['id']){
                                
    $stmtDelete $dbh->prepare("update message set deleted=1 where id=?;");
                                
    $stmtDelete -> bindParam(1,$messageid);
                                
    $stmtDelete -> execute();
                                echo 
    '{success: true,data:{}}';
                            }
                            else {
                                echo 
    '{success: false, data{"error_title": "Error", "errormsg": "Permission Denied"}}';
                            }
                        }
                        else{
                            echo 
    '{success: false, data{"error_title": "Error", "errormsg": "Permission Denied"}}';
                        }
                    }
                    else{
                        echo 
    '{success: false, data{"error_title": "Error", "errormsg": "Permission Denied"}}';
                    }
                break;

        }
    }

    if(isset(
    $_REQUEST['list'])){
        switch(
    $_REQUEST['list']){
            case 
    'messages':
            
    $userID=mysql_escape_string($_REQUEST['userid']);
            
                
    $stmtListMessage $dbh->prepare("select m.id, m.fromid, m.subject, m.opened, m.datetime, concat(u.lastname, ', ', u.firstname) as name from message m, user u where m.toid=? and m.deleted=0 and m.fromid=u.id order by datetime desc");
                
    $stmListMessage->execute();
                while(
    $tmp $stmt->fetch()){
                    
    $y .='{"fromid":"'.$tmp['fromid'].'","subject":"'.$tmp['subject'].'","opened":"'.$tmp['opened'].'","datetime":"'.$tmp['datetime'].'","name":"'.$tmp['name'].'"},';
                    
                }
                
    $y trim($y',');
                echo 
    '{"users":['.$y.']}';
            
            }
    }
                else{
                    echo 
    '{success: false, data{"error_title": "Error", "errormsg": "Permission Denied"}}';
                    }
                break;
        

    if(isset(
    $_REQUEST['action'])){
        switch(
    $_REQUEST['action']){
            case 
    'add_user'
            if(isset(
    $_SESSION['id']) && $_SESSION['admin']==1){
                
    $userID=mysql_escape_string($_REQUEST['userid']);
                
    $password=mysql_escape_string($_REQUEST['password']);
                
    $admin=mysql_escape_string($_REQUEST['admin']);
                
                
    $stmt $dbh->prepare("insert into user (userid, password, admin) values (?,sha1(?),?)");
                
    $stmt->bindParam(1$userID);
                
    $stmt->bindParam(2$password);
                
    $stmt->bindParam(3$admin);
                
    $stmt->execute();
                if(
    $stmt->rowCount()>0){
                    
                echo 
    '({success: true,data:{"id":"'.$dbh->lastinsertid().'"}});';}
                    
                    else {
                        echo 
    '{success: false, data{"error_title": "Error", "errormsg": "Invalid Input"}}';
                    }
            }
            else {
                        echo 
    '{success: false, data{"error_title": "Error", "errormsg": "Permission Denied"}}';
                    }
            }
    }
    ?> 
    this is database_connection.php
    [REDACTED] I figured out my DB connection problem.
    PHP Code:
    <?php
        $dbh
    =new PDO('mysql:host=phpproject4363.db.4839770.hostedresource.com;dbname=phpproject4363''phpproject4363''Msis4363');
    ?>
    I just can't really make sense of it, because I can't see how it interacts with the database.

    So if you guys could give me an idea of a starting point I would appreciate it.

    Here is my EXT Js
    Code:
    Ext.onReady(function(){
                         Ext.QuickTips.init();
    
    function addStudent(){
        var recordType = Ext.data.Record.create(['fname', 'lname', 'phoneNumber', 'email', 'dateOfBirth', 'street', 'city', 'state', 'zip', 'schedule', 'dateStarted', 'musicalInterest']); 
            var newStudent = new recordType({
                                         "fname":firstNameTextField.getValue(),
                                         "lname":lastNameTextField.getValue(),
                                         "phoneNumber":phoneNumberTextField.getValue(),
                                         "email": emailTextField.getValue(),
                                         "dateOfBirth":Ext.util.Format.date(dateOfBirth.getValue(), 'Y-m-d'),
                                         "street":streetTextField.getValue(),
                                         "city":cityTextField.getValue(),
                                         "state":stateTextField.getValue(),
                                         "zip":zipTextField.getValue(),
                                         "schedule":dayTypeCombo.getValue(),
                                         "dateStarted":dateStarted.getValue(),
                                         "musicalInterest":musicInterest.getValue()
                                         });
            studentStore.add(newStudent);
            tabPanel.activate(studentGrid);
            clearStudentForm();
    }
    
    function clearStudentForm(){
            firstNameTextField.setValue("");
            lastNameTextField.setValue("");
            phoneNumberTextField.setValue(),
            emailTextField.setValue(),
            dateOfBirth.setValue(),
            streetTextField.setValue(),
            cityTextField.setValue(),
            stateTextField.setValue(),
            zipTextField.setValue(),
            dayTypeCombo.setValue(),
            dateStarted.setValue(),
            musicInterest.setValue()
        }
        
    
    function deleteStudent(){
        var selectedUser = studentGrid.getSelectionModel().getSelected();
        studentStore.remove(selectedUser);
    }
        /*if(!selectedUser){
            Ext.Msg.alert("Warning!", "No student selected!");
            return false;
        }
        else
        currentRecord=selectedUser;
    
    
    function makePayment
    function viewNotes
    function viewPaymentHistory
    function viewStudentRecords
    function emailStudent
    
    function editStudentSchedule
    function createNote
    */
    function showAddStudentForm(){    
                addStudentWindow.show();
            }
            
    function showStudentSkillWindow(){    
                studentSkillWindow.show();
            }
    
    var currentRecord;
    function showEditStudentWindow(){
        var selectedUser = studentGrid.getSelectionModel().getSelected();
        if(!selectedUser){
            Ext.Msg.alert("Warning!", "No student selected!");
            return false;
        }    
        else{
            currentRecord=selectedUser;
            editFirstNameTextField.setValue(selectedUser.get('fname'));
            editLastNameTextField.setValue(selectedUser.get('lname'));
            editPhoneNumberTextField.setValue(selectedUser.get('phoneNumber')),
            editEmailTextField.setValue(selectedUser.get('email')),
            editStreetTextField.setValue(selectedUser.get('street')),
            editCityTextField.setValue(selectedUser.get('city')),
            editStateTextField.setValue(selectedUser.get('state')),
            editZipTextField.setValue(selectedUser.get('zip')),
            editDayTypeCombo.setValue(selectedUser.get('schedule')),
            editMusicInterest.setValue(selectedUser.get('musicalInterest'))
            editStudentWindow.show();
            }
    }
    
    function updateStudent(){
            currentRecord.set('fname',editFirstNameTextField.getValue());
            currentRecord.set('lname',editLastNameTextField.getValue());
            currentRecord.set('phoneNumber',editPhoneNumberTextField.getValue());
            currentRecord.set('email',editEmailTextField.getValue());
            currentRecord.set('street',editStreetTextField.getValue());
            currentRecord.set('city',editCityTextField.getValue());
            currentRecord.set('state',editStateTextField.getValue());
            currentRecord.set('zip',editZipTextField.getValue());
            currentRecord.set('schedule',editDayTypeCombo.getValue());
            currentRecord.set('musicalInterest',editMusicInterest.getValue());
            currentRecord.commit();
            editStudentWindow.show();
    }
    
    /*----Buttons---
    -*/
    var newStudentButton = new Ext.Button({
        text: 'Add New Student',
        listeners:{click: function(){
                                    showAddStudentForm();
                                    }
        }
    });
    
    
    var deleteStudentButton = new Ext.Button({
        text: 'Delete Student',
        listeners:{click: function(){
                                    deleteStudent();
                                     }
        }
    });
    
    var viewPaymentHistoryButton = new Ext.Button({
        text: 'View Payment History',
        listeners:{}
    });
    
    var processPaymentButton = new Ext.Button({
        text: 'Process Payment',
        listeners:{}
    });
    
    var viewStudentRecords = new Ext.Button({
        text: 'View Student Records',
        listeners:{}
    });
    
    var emailStudent = new Ext.Button({
        text: 'E-mail Student',
        listeners:{}
    });
    
    var createNote = new Ext.Button({
        text: 'Create Note',
        listeners:{click: function(){
                                    showStudentSkillWindow();
                                    }
        }
    });
    
    var editStudentRecords = new Ext.Button({
        text: 'Edit Student Records',
            listeners:{click: function(){
                                    showEditStudentWindow();
                                    }
        }
    });
    
    var noteStore = new Ext.data.SimpleStore({
            fields: ['id', 'Note'],
            data: [
                   ['1', 'note 1'],
                   ['2', 'note 2']
                ]
                                                 });
        
    var noteTypeCombo = new Ext.form.ComboBox({
                                                  fieldLabel: 'Select Note',
                                                  triggerAction: 'all',
                                                  store: noteStore,
                                                  mode: 'local',
                                                  valueField: 'id',
                                                  displayField: 'Note',
                                                  editable: false,
                                                  width: 143
                                                  });
    
    /*---endbutttons---*/
    
    
    /*---Grids---*/    
    var studentStore = new Ext.data.SimpleStore({
        fields:['fname', 'lname', 'phoneNumber', 'email', 'dateOfBirth', 'street', 'city', 'state', 'zip', 'schedule', 'dateStarted', 'musicalInterest']
    });
    
    var studentGridToolbar = new Ext.Toolbar({
                                              items:['-',viewStudentRecords, '-',emailStudent,'-',createNote,'-',editStudentRecords,'-']                              
                                              });
    
    var studentGrid = new Ext.grid.GridPanel({
        region: 'center',
        tbar: studentGridToolbar,
        store: studentStore,
        layout: 'form',     
        region: 'center',
        height: 400,
        colModel: new Ext.grid.ColumnModel({
                defaults:{
                                                autoScroll: true,
                                                hideBorders: true,
                                                anchor: '100% 50%',
                                                width: 'auto',
                                                sortable: true
                                                 },
            columns:[
                    {id: 'FirstName', header: 'First Name', dataIndex: 'fname'},
                    {id: 'LastName', header: 'Last Name', dataIndex: 'lname'},
                    {id: 'Email', header: 'E-mail', dataIndex: 'email'},
                    {id: 'phoneNumber', header: 'Phone Number', dataIndex: 'phoneNumber'},
                    {id: 'dateOfBirth', header: 'Date of Birth', dataIndex: 'dateOfBirth'},
                    {id: 'Street', header: 'Street Address', dataIndex: 'street'},
                    {id: 'City', header: 'City', dataIndex: 'city'},
                    {id: 'State', header: 'State', dataIndex: 'state'},
                    {id: 'Zip', header: 'Zip Code', dataIndex: 'zip'},
                    {id: 'Schedule', header: 'Schedule', dataIndex: 'schedule'},        
                    ]
        })
    });
    
    var scheduleStore = new Ext.data.SimpleStore({
        fields:['fname', 'lname', 'day', 'time']
    });
    
    var scheduleGrid = new Ext.grid.GridPanel({
        region: 'center',
        title: 'Daily Schedule',
        store: scheduleStore,
        colModel: new Ext.grid.ColumnModel({
            defaults:{
                width: 'auto',
                sortable: true
            },
            columns:[
                    {id: 'FirstName', header: 'First Name', dataIndex: 'fname'},
                    {id: 'LastName', header: 'Last Name', dataIndex: 'lname'},
                    {id: 'day', header: 'Day', dataIndex: 'day'},
                    {id: 'time', header: 'Time', dataIndex: 'time'}
                    ]
        })
    });
    
    /*---Panels---*/
    var RightPanel = new Ext.Panel(
        {
            renderTo: tabPanel,
            region: 'east',
            width: 450,
            height: 'auto',
            collapsible: true,
            items: [
            {
                style: 'background-color:#d0def0;padding-left:2px;',
                width: 'auto',
                tbar: new Ext.Toolbar(
                {
                    cls: 'x-inline-toolbar',
                    width: 200,
                    items:[newStudentButton, deleteStudentButton, viewPaymentHistoryButton, processPaymentButton, scheduleGrid],
                    layout: 'auto',
                    flat: true
                }),
                bodyStyle: 'background-color:#d0def0;padding-left:2px;',
                border: false
            }],
            layout: 'column',
            title: 'Teacher Toolbar'
        });
        
        
    
    var TopCenterPanel = new Ext.Panel({
        anchor: '100% 50%',
        items: [studentGrid]
        });        
        
    var BottomCenterPanel = new Ext.Panel({
        anchor: '100% 50%',
        layout: 'form',
        html: 'Bottom C Panel',
        items: [noteTypeCombo]
        });        
    
    var CenterPanel = new Ext.Panel({
        layout: 'anchor',
        title: 'Student Information',
        items: [TopCenterPanel, BottomCenterPanel]
        });        
    
    var tabPanel = new Ext.TabPanel({
        region: 'center',
        activeTab: 0,
        items: [CenterPanel]
    });
    /*---End Panels---*/
    
    
    
    /*-----------------Forms-------------------------------*/
    //Add User Form--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------        
    var firstNameTextField = new Ext.form.TextField({
                                                            fieldLabel: '<span class="spacer">&nbsp;</span> First Name',
                                                            allowBlank: false
                                                            });
    
    var lastNameTextField = new Ext.form.TextField({
                                                            fieldLabel: '<span class="spacer">&nbsp;</span> Last Name',
                                                            allowBlank: false
                                                            });    
    var phoneNumberTextField = new Ext.form.TextField({
                                                            fieldLabel: '<span class="spacer">&nbsp;</span> Phone Number',
                                                            allowBlank: false
                                                            });    
    var emailTextField = new Ext.form.TextField({
                                                            fieldLabel: '<span class="spacer">&nbsp;</span> E-Mail Address',
                                                            allowBlank: false
                                                            });    
    var streetTextField = new Ext.form.TextField({
                                                            fieldLabel: '<span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> Street',
                                                            allowBlank: false
                                                            });                                                        
    var cityTextField = new Ext.form.TextField({
                                                            fieldLabel: '<span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> City',
                                                            allowBlank: false,
                                                            });
    var stateTextField = new Ext.form.TextField({
                                                            fieldLabel: '<span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> State',
                                                            allowBlank: false
                                                            });
    var zipTextField = new Ext.form.TextField({
                                                            fieldLabel: '<span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> Zip Code',
                                                            allowBlank: false
                                                            });
    var dayStore = new Ext.data.SimpleStore({
            fields: ['id', 'Day'],
            data: [
                   ['1', 'Monday'],
                   ['2', 'Tuesday']
                ]
                                                 });
        
    var dayTypeCombo = new Ext.form.ComboBox({
                                                  fieldLabel: '<span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> Schedule',
                                                  triggerAction: 'all',
                                                  store: dayStore,
                                                  mode: 'local',
                                                  valueField: 'Day',
                                                  displayField: 'Day',
                                                  editable: false,
                                                  width: 143
                                                  });
    var dateStarted = new Ext.form.DateField({
            fieldLabel: '<span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> Date Started',
            width: 143,
            editable: false
                         });
    
    var dateOfBirth = new Ext.form.DateField({
            fieldLabel: '<span class="spacer">&nbsp;</span> Date of Birth',
            dateFormat: 'm-d-Y g:i A',
            width: 143,
            editable: false
                         });
                         
    var musicInterest= new Ext.form.HtmlEditor({
            anchor: '100% 100%'
                                                });
    var addStudentPanelOne = new Ext.form.FormPanel({
                                               anchor: '50% 100%',
                                               border: false,
                                               items: [firstNameTextField,lastNameTextField, phoneNumberTextField, emailTextField, dateOfBirth]
                                               });
                                               
    var addStudentPanelTwo = new Ext.form.FormPanel({
                                               anchor: '100% 50%',
                                               border: false,
                                               items: [streetTextField, cityTextField, stateTextField, zipTextField, dayTypeCombo, dateStarted]
                                               });
    
    var addStudentPanelThree = new Ext.form.FormPanel({
                                               layout: 'anchor',
                                               border: false,
                                               title: 'Musical Interests',
                                               items: [musicInterest]
                                               });            
                                               
                                               
    var addStudentCenterPanel = new Ext.Panel({
        layout: 'column',
        title: 'Add Student',
        items: [addStudentPanelOne, addStudentPanelTwo, addStudentPanelThree]
        });
    
    var submitStudentButton = new Ext.Button({
                                               text: 'Add Student',
                                               listeners:{
                                                   click: function(){
                                                       addStudent();
                                                       addStudentWindow.hide();
                                                   }
                                               }
                                               });
        
    var cancelStudentButton = new Ext.Button({
                                              text: 'Cancel',
                                              listeners:{
                                                  click: function(){
                                                      addStudentWindow.hide();
                                                  }
                                              }
                                              });                            
        
        
                   
                                               
    var addStudentWindow = new Ext.Window({
                                        width: 520,
                                        height: 600,
                                        layout: 'form',
                                        autoscroll: true,
                                        closable: true,
                                        draggable: true,
                                        resizable: false,
                                        header: false,
                                        items:[addStudentCenterPanel],
                                        buttons: [submitStudentButton, cancelStudentButton]
                                        });     
    //End Add Student Form-------------------------------------------------------------------------------------------------------------------------------------------------------------------------                                                                                   
    
    //Create Student Notes Form--------------------------------------------------------------------------------------------------------------------------------------------------------------------    
    var skillStore = new Ext.data.SimpleStore({
            fields: ['id', 'Skill'],
            data: [
                   ['1', 'Sweeping'],
                   ['2', 'Strumming']
                ]
                                                 });
        
    var skillTypeCombo = new Ext.form.ComboBox({
                                                  fieldLabel: 'Skill',
                                                  triggerAction: 'all',
                                                  store: skillStore,
                                                  mode: 'local',
                                                  valueField: 'id',
                                                  displayField: 'Skill',
                                                  editable: false,
                                                  width: 143
                                                  });
    
    var skillDateStarted = new Ext.form.DateField({
            fieldLabel: 'Date Started',
            width: 143,
            editable: false
                         });
                 
    var lessonNotes= new Ext.form.HtmlEditor({
            fieldLabel: 'Lesson Notes',
            width: 525,
            height: 300
                                                });
    
    
    
    var studentSkillPanel = new Ext.form.FormPanel({
                                               layout: 'form',
                                               border: false,
                                               title: 'Create Student Note',
                                               items: [skillTypeCombo, skillDateStarted, lessonNotes]
                                               });    
                                               
    var submitNoteButton = new Ext.Button({
                                               text: 'Add Student',
                                               listeners:{
                                                   //click: function(){
                                                     //  updateUser();
                                                   //}
                                               }
                                               });
        
    var cancelNoteButton = new Ext.Button({
                                              text: 'Cancel',
                                              listeners:{
                                                  click: function(){
                                                      studentSkillWindow.hide();
                                                  }
                                              }
                                              });        
    
    var studentSkillWindow = new Ext.Window({
                                        width: 655,
                                        height: 450,
                                        layout: 'form',
                                        autoscroll: true,
                                        closable: true,
                                        draggable: false,
                                        resizable: false,
                                        header: false,
                                        items:[studentSkillPanel],
                                        buttons: [submitNoteButton, cancelNoteButton]
                                        });     
    //End Create Note Form-------------------------------------------------------------------------------------------------------------------------------------------------------------------------                
    
    
    //Edit Student Records Form--------------------------------------------------------------------------------------------------------------------------------------------------------------------        
    var editFirstNameTextField = new Ext.form.TextField({
                                                            fieldLabel: '<span class="spacer">&nbsp;</span> First Name',
                                                            allowBlank: false
                                                            });
    
    var editLastNameTextField = new Ext.form.TextField({
                                                            fieldLabel: '<span class="spacer">&nbsp;</span> Last Name',
                                                            allowBlank: false
                                                            });    
    var editPhoneNumberTextField = new Ext.form.TextField({
                                                            fieldLabel: '<span class="spacer">&nbsp;</span> Phone Number',
                                                            allowBlank: false
                                                            });    
    var editEmailTextField = new Ext.form.TextField({
                                                            fieldLabel: '<span class="spacer">&nbsp;</span> E-Mail Address',
                                                            allowBlank: false
                                                            });    
    var editStreetTextField = new Ext.form.TextField({
                                                            fieldLabel: '<span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> Street',
                                                            allowBlank: false
                                                            });                                                        
    var editCityTextField = new Ext.form.TextField({
                                                            fieldLabel: '<span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> City',
                                                            allowBlank: false,
                                                            });
    var editStateTextField = new Ext.form.TextField({
                                                            fieldLabel: '<span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> State',
                                                            allowBlank: false
                                                            });
    var editZipTextField = new Ext.form.TextField({
                                                            fieldLabel: '<span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> Zip Code',
                                                            allowBlank: false
                                                            });
    
    var editDayTypeCombo = new Ext.form.ComboBox({
                                                  fieldLabel: '<span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> Schedule',
                                                  triggerAction: 'all',
                                                  store: dayStore,
                                                  mode: 'local',
                                                  valueField: 'Day',
                                                  displayField: 'Day',
                                                  editable: false,
                                                  width: 143
                                                  });
    var editMusicInterest= new Ext.form.HtmlEditor({
            anchor: '100% 100%'
                                                });
    var editStudentPanelOne = new Ext.form.FormPanel({
                                               anchor: '50% 100%',
                                               border: false,
                                               items: [editFirstNameTextField,editLastNameTextField, editPhoneNumberTextField, editEmailTextField]
                                               });
                                               
    var editStudentPanelTwo = new Ext.form.FormPanel({
                                               anchor: '100% 50%',
                                               border: false,
                                               items: [editStreetTextField, editCityTextField, editStateTextField, editZipTextField, editDayTypeCombo]
                                               });
    
    var editStudentPanelThree = new Ext.form.FormPanel({
                                               layout: 'anchor',
                                               border: false,
                                               title: 'Musical Interests',
                                               items: [editMusicInterest]
                                               });            
                                               
                                               
    var editStudentCenterPanel = new Ext.Panel({
        layout: 'column',
        title: 'Edit Student',
        items: [editStudentPanelOne, editStudentPanelTwo, editStudentPanelThree]
        });                    
        
    
    var submitEditButton = new Ext.Button({
                                               text: 'Edit Student',
                                               listeners:{
                                                   click: function(){
                                                       updateStudent();
                                                       editStudentWindow.hide();
                                                   }
                                               }
                                               });
        
    var cancelEditButton = new Ext.Button({
                                              text: 'Cancel',
                                              listeners:{
                                                  click: function(){
                                                      editStudentWindow.hide();
                                                  }
                                              }
                                              });            
        
        
                   
                                               
    var editStudentWindow = new Ext.Window({
                                        width: 520,
                                        height: 600,
                                        layout: 'form',
                                        autoscroll: true,
                                        closable: true,
                                        draggable: false,
                                        resizable: false,
                                        header: false,
                                        items:[editStudentCenterPanel],
                                        buttons: [submitEditButton, cancelEditButton]
                                        });     
    
    var editStudentWindow = new Ext.Window({
                                        width: 520,
                                        height: 600,
                                        layout: 'form',
                                        autoscroll: true,
                                        closable: true,
                                        draggable: false,
                                        resizable: false,
                                        header: false,
                                        items:[editStudentCenterPanel],
                                        buttons: [submitEditButton, cancelEditButton]
                                        });
    //End Edit Student Records Form----------------------------------------------------------------------------------------------------------------------------------------------------------------                                                                                                                                                                        
    
    var mainViewport = new Ext.Viewport({
        layout: 'border',
        items:[tabPanel, RightPanel]
        });
    
    });
    and this is my database

    Code:
    use cox4363;
    
    drop table teacher;
    drop table lesson;
    drop table student; 
    drop table payment;
    drop table skills;
    drop table TeacherTrainingLog; 
    drop table StudentTrainingLog;
    
    
    CREATE TABLE teacher
        (TeacherID int,
        TeacherLast varchar(30), 
        TeacherFirst varchar(30),
        TeacherEmail varchar(254),
        TeacherDOB date, 
        TeacherAddress varchar(50), 
        TeacherCity varchar(30), 
        TeacherState char(2), 
        TeacherZip varchar(10), 
        TeacherPhone varchar(12), 
        TeacherUserId varchar(50), 
        TeacherPassword varchar(15));
    alter table teacher add constraint TeacherPK primary key (TeacherID); 
    
    CREATE TABLE lesson
        (LessonID int,
        WeekDay varchar(10),
        LessonTime varchar(12));
    alter table lesson add constraint LessonPK primary key (LessonID);  
    
    CREATE TABLE student
        (StudentID int,
        StudentLast varchar(30), 
        StudentFirst varchar(30),
        StudentEmail varchar(254),
        DateStarted date, 
        LessonID int,
        StudentDOB date,
        MusicInterest text, 
        StudentAddress varchar(50), 
        StudentCity varchar(30), 
        StudentState char(2), 
        StudentZip varchar(10), 
        StudentPhone varchar(12), 
        StudentUserId varchar(50), 
        StudentPassword varchar(15),
        TeacherID int);
    alter table student add constraint StudentPK primary key (StudentID); 
    alter table student add constraint TeacherFK foreign key (TeacherID) references teacher(TeacherID);
    alter table student add constraint LessonFK foreign key (LessonID) references lesson(LessonID);
    
    CREATE TABLE payment
        (PaymentID int,
        PaymentDueDate date,
        PaymentAmount int,
        TeacherID int,
        StudentID int);
    alter table payment add constraint PaymentPK primary key (PaymentID); 
    alter table payment add constraint TeacherFK foreign key (TeacherID) references teacher(TeacherID);
    alter table payment add constraint StudentFK foreign key (StudentID) references student(StudentID);
    
    
    CREATE TABLE skills
        (SkillID int,
        SkillName varchar(30));
    alter table skills add constraint SkillPK primary key (SkillID);
    
    
    CREATE TABLE TeacherTrainingLog
        (TeacherID int,
        SkillID int,
        TeacherDateStarted date,
        Teacherlevel int,
        TeacherTrainingNotes text);
    alter table TeacherTrainingLog add constraint TeachIDfk foreign key (TeacherID) references teacher (TeacherID); 
    alter table TeacherTrainingLog add constraint SkillIDfk foreign key (SkillID) references skills (SkillID); 
    alter table TeacherTrainingLog add constraint TeacherTraingingLogPK primary key (TeacherID, SkillID); 
    
    CREATE TABLE StudentTrainingLog
        (StudentID int,
        SkillID int,
        StudentDateStarted date,
        Studentlevel int,
        StudentTrainingNotes text);
    alter table StudentTrainingLog add constraint StudentIDfk foreign key (StudentID) references student (StudentID); 
    alter table StudentTrainingLog add constraint SkillIDfk foreign key (SkillID) references skills (SkillID); 
    alter table StudentTrainingLog add constraint StudentTraingingLogPK primary key (StudentID, SkillID); 
    
    
                        
    insert into teacher values (1, 'Bob', 'Joe','teacher.troxy@gmail.com','1988/5/4', '1120 Sweet St.', 'Boulder', 'CO', '55555', '555-555-5555','capn', 'crunch');
    
    insert into student values (1, 'Joey', 'Bobby','student.troxy@gmail.com','2013/4/8','5', '1988/9/12', 'Led Zepplin, Taylor Swift', '2120 Garbage Can Ln', 'Boulder', 'CO', '55555', '333-333-333','student1', 'first', 1);
    
    insert into skills values (1, 'Chord');
    insert into skills values (2, 'Strumming');
    insert into skills values (3, 'Alternate Picking');
    insert into skills values (4, 'Bend');
    insert into skills values (5, 'Bend/Release');
    insert into skills values (6, 'Hammer-on');
    insert into skills values (7, 'Pull-off');
    insert into skills values (8, 'Slide');
    insert into skills values (9, 'Vibrato');
    insert into skills values (10, 'Tapping');
    insert into skills values (11, 'Natural Harmonic');
    insert into skills values (12, 'Pinch Harmonic');
    insert into skills values (13, 'Sweep Picking');
    insert into skills values (14, 'Finger Picking');
    
    
    insert into lesson values ('1', 'Monday', '11:15am-12:45PM');
    insert into lesson values ('2', 'Monday', '1:00PM-1:30PM');
    insert into lesson values ('3', 'Monday', '1:45PM-2:15PM');
    insert into lesson values ('4', 'Monday', '2:30PM-3:00PM');
    insert into lesson values ('5', 'Monday', '3:15PM-4:00PM');
    insert into lesson values ('6', 'Monday', '4:15PM-4:45PM');
    insert into lesson values ('7', 'Monday', '5:00PM-5:30PM');
    insert into lesson values ('8', 'Monday', '5:45PM-6:15PM');
    insert into lesson values ('9', 'Monday', '6:30PM-7:00PM');
    insert into lesson values ('10', 'Monday', '7:15PM-7:30PM');
    
    insert into lesson values ('11', 'Tuesday', '11:15am-12:45PM');
    insert into lesson values ('12', 'Tuesday', '1:00PM-1:30PM');
    insert into lesson values ('13', 'Tuesday', '1:45PM-2:15PM');
    insert into lesson values ('14', 'Tuesday', '2:30PM-3:00PM');
    insert into lesson values ('15', 'Tuesday', '3:15PM-4:00PM');
    insert into lesson values ('16', 'Tuesday', '4:15PM-4:45PM');
    insert into lesson values ('17', 'Tuesday', '5:00PM-5:30PM');
    insert into lesson values ('18', 'Tuesday', '5:45PM-6:15PM');
    insert into lesson values ('19', 'Tuesday', '6:30PM-7:00PM');
    insert into lesson values ('20', 'Tuesday', '7:15PM-7:30PM');
    
    insert into lesson values ('21', 'Wednesday', '11:15am-12:45PM');
    insert into lesson values ('22', 'Wednesday', '1:00PM-1:30PM');
    insert into lesson values ('23', 'Wednesday', '1:45PM-2:15PM');
    insert into lesson values ('24', 'Wednesday', '2:30PM-3:00PM');
    insert into lesson values ('25', 'Wednesday', '3:15PM-4:00PM');
    insert into lesson values ('26', 'Wednesday', '4:15PM-4:45PM');
    insert into lesson values ('27', 'Wednesday', '5:00PM-5:30PM');
    insert into lesson values ('28', 'Wednesday', '5:45PM-6:15PM');
    insert into lesson values ('29', 'Wednesday', '6:30PM-7:00PM');
    insert into lesson values ('30', 'Wednesday', '7:15PM-7:30PM');
    
    insert into lesson values ('31', 'Thursday', '11:15am-12:45PM');
    insert into lesson values ('32', 'Thursday', '1:00PM-1:30PM');
    insert into lesson values ('33', 'Thursday', '1:45PM-2:15PM');
    insert into lesson values ('34', 'Thursday', '2:30PM-3:00PM');
    insert into lesson values ('35', 'Thursday', '3:15PM-4:00PM');
    insert into lesson values ('36', 'Thursday', '4:15PM-4:45PM');
    insert into lesson values ('37', 'Thursday', '5:00PM-5:30PM');
    insert into lesson values ('38', 'Thursday', '5:45PM-6:15PM');
    insert into lesson values ('39', 'Thursday', '6:30PM-7:00PM');
    insert into lesson values ('40', 'Thursday', '7:15PM-7:30PM');
    
    insert into lesson values ('41', 'Friday', '11:15am-12:45PM');
    insert into lesson values ('42', 'Friday', '1:00PM-1:30PM');
    insert into lesson values ('43', 'Friday', '1:45PM-2:15PM');
    insert into lesson values ('44', 'Friday', '2:30PM-3:00PM');
    insert into lesson values ('45', 'Friday', '3:15PM-4:00PM');
    insert into lesson values ('46', 'Friday', '4:15PM-4:45PM');
    insert into lesson values ('47', 'Friday', '5:00PM-5:30PM');
    insert into lesson values ('48', 'Friday', '5:45PM-6:15PM');
    insert into lesson values ('49', 'Friday', '6:30PM-7:00PM');
    insert into lesson values ('50', 'Friday', '7:15PM-7:30PM');
    I appreciate any help guys.

    THANKS!

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Posts
    5
    Vote Rating
    0
    coxy is on a distinguished road

      0  

    Default


    Not trying to spam guys. Sorry

    But I have made some progress.

    At the moment I am trying to populate a combobox from my MySQL database using PHP to parse the information into JSON that will then be read by my combobox in EXT Js. I can get the values from my database.
    They are displayed below.

    Code:
    {"Lessons":[{"id":"1","time":"11:15am-12:45PM","day":"Monday"},{"id":"2","time":"1:00PM-1:30PM","day":"Monday"},{"id":"3","time":"1:45PM-2:15PM","day":"Monday"},{"id":"4","time":"2:30PM-3:00PM","day":"Monday"},{"id":"5","time":"3:15PM-4:00PM","day":"Monday"},{"id":"6","time":"4:15PM-4:45PM","day":"Monday"},{"id":"7","time":"5:00PM-5:30PM","day":"Monday"},{"id":"8","time":"5:45PM-6:15PM","day":"Monday"},{"id":"9","time":"6:30PM-7:00PM","day":"Monday"},{"id":"10","time":"7:15PM-7:30PM","day":"Monday"},{"id":"11","time":"11:15am-12:45PM","day":"Tuesday"},{"id":"12","time":"1:00PM-1:30PM","day":"Tuesday"},{"id":"13","time":"1:45PM-2:15PM","day":"Tuesday"},{"id":"14","time":"2:30PM-3:00PM","day":"Tuesday"},{"id":"15","time":"3:15PM-4:00PM","day":"Tuesday"},{"id":"16","time":"4:15PM-4:45PM","day":"Tuesday"},{"id":"17","time":"5:00PM-5:30PM","day":"Tuesday"},{"id":"18","time":"5:45PM-6:15PM","day":"Tuesday"},{"id":"19","time":"6:30PM-7:00PM","day":"Tuesday"},{"id":"20","time":"7:15PM-7:30PM","day":"Tuesday"},{"id":"21","time":"11:15am-12:45PM","day":"Wednesday"},{"id":"22","time":"1:00PM-1:30PM","day":"Wednesday"},{"id":"23","time":"1:45PM-2:15PM","day":"Wednesday"},{"id":"24","time":"2:30PM-3:00PM","day":"Wednesday"},{"id":"25","time":"3:15PM-4:00PM","day":"Wednesday"},{"id":"26","time":"4:15PM-4:45PM","day":"Wednesday"},{"id":"27","time":"5:00PM-5:30PM","day":"Wednesday"},{"id":"28","time":"5:45PM-6:15PM","day":"Wednesday"},{"id":"29","time":"6:30PM-7:00PM","day":"Wednesday"},{"id":"30","time":"7:15PM-7:30PM","day":"Wednesday"},{"id":"31","time":"11:15am-12:45PM","day":"Thursday"},{"id":"32","time":"1:00PM-1:30PM","day":"Thursday"},{"id":"33","time":"1:45PM-2:15PM","day":"Thursday"},{"id":"34","time":"2:30PM-3:00PM","day":"Thursday"},{"id":"35","time":"3:15PM-4:00PM","day":"Thursday"},{"id":"36","time":"4:15PM-4:45PM","day":"Thursday"},{"id":"37","time":"5:00PM-5:30PM","day":"Thursday"},{"id":"38","time":"5:45PM-6:15PM","day":"Thursday"},{"id":"39","time":"6:30PM-7:00PM","day":"Thursday"},{"id":"40","time":"7:15PM-7:30PM","day":"Thursday"},{"id":"41","time":"11:15am-12:45PM","day":"Friday"},{"id":"42","time":"1:00PM-1:30PM","day":"Friday"},{"id":"43","time":"1:45PM-2:15PM","day":"Friday"},{"id":"44","time":"2:30PM-3:00PM","day":"Friday"},{"id":"45","time":"3:15PM-4:00PM","day":"Friday"},{"id":"46","time":"4:15PM-4:45PM","day":"Friday"},{"id":"47","time":"5:00PM-5:30PM","day":"Friday"},{"id":"48","time":"5:45PM-6:15PM","day":"Friday"},{"id":"49","time":"6:30PM-7:00PM","day":"Friday"},{"id":"50","time":"7:15PM-7:30PM","day":"Friday"}]}
    This is my PHP

    PHP Code:
    if(isset($_REQUEST['list'])){
        switch(
    $_REQUEST['list']){
                    case 
    'lessons':
                    
    $stmt $dbh -> prepare("select * from lesson");
                    
    $stmt -> execute();
                    while(
    $tmp $stmt -> fetch()){
                        
    $l .= '{"id":"'.$tmp['LessonID'].'","time":"'.$tmp['LessonTime'].'","day":"'.$tmp['WeekDay'].'"},';
                              
                    }
                    
    $l trim($l',');

                        echo 
    '{"Lessons":['.$l.']}';
                break;

        } 
    And here is my EXT Js combobox and data store.

    Code:
    var scheduleStore = new Ext.data.Store({
        autoload: false,
        url: 'inc/template.php',
        baseParams: {
                    list: 'lessons'
                    },
        reader: new Ext.data.JsonReader({
            root: 'lessons',
            id: 'id',
            fields: ['id', 'time', 'day']
        })
    });
    
    var dayTypeCombo = new Ext.form.ComboBox({
                                                  fieldLabel: '<span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> <span class="spacer">&nbsp;</span> Schedule',
                                                  triggerAction: 'all',
                                                  store: scheduleStore,
                                                  valueField: 'time',
                                                  displayField: 'time',
                                                  editable: false,
                                                  width: 143,
                                                  tpl: new Ext.XTemplate(
                                                  '<tpl for=".">',
                                                  '<tpl if="this.day != values.day">',
                                                  '<tpl exec="this.day = values.day"></tpl>',
                                                  '<hr><h1><span style="color:gray;">{day}</span></h1><hr>',
                                                  '</tpl>',
                                                  '<div class="x-combo-list-item">{day}</div>',
                                                  '</tpl>'
                                                  )
                                                  });

    I am trying to make groups in the combobox that will display Monday(time,time,time,time) Tuesday(time,time,time,time) if that makes sense.
    Again, any help would be very much appreciated. I'm pulling my hair out!

    Thank You!

  3. #3
    Sencha User
    Join Date
    Feb 2013
    Posts
    5
    Vote Rating
    0
    coxy is on a distinguished road

      0  

    Default


    Everything is passing through to EXT Js just fine, it just won't populate the combobox

    Attached Images

  4. #4
    Sencha User
    Join Date
    Feb 2013
    Posts
    5
    Vote Rating
    0
    coxy is on a distinguished road

      0  

    Default


    Never mind. I capatalized something that shouldn't have been. I feel stupid.

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar