Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
jqGrid Time Management/Calendar Processor Development
12/07/2011
21:35
Avatar
Exact
New Member
Members
Forum Posts: 1
Member Since:
12/07/2011
sp_UserOfflineSmall Offline

Hi,

I'm working with jqGrid to develop a time management module for a customer. We have already deployed jqGrid extensively over the rest of the site so we're working to make it fit this role too.

We need to be able to display a column for each day of a calendar month, each day then being split into two columns for overtime worked (HV - text input box) and the reason (R - select dropdown). I've got the grid designed to an extent (overtime/reason columns, list of branch staff etc) but am having trouble writing the processor. The code below shows what I currently have. This populates the grid (via another file) with a list of employees. The column list (day numbers 1-31) is generated from a PHP function which determines the current month and year. Grid.php then posts to gridsave.php when the row is clicked-off.

I would like to be able to determine which field has been edited as easily as possible. I do not want 62 columns (HV and R for each day of a 31 day month) in my database just in case, I'd like to programmatically determine the field id (date) and store that in a date column using my processor. If at all possible, I'd like to only pass modified fields to my processor to save on processing time.

Then, in reverse, I need to be able to extract this information (based on the date determined above) and input it into the correct column in jqGrid.

Needless to say I've now come up against a brick wall and not sure how to proceed on any of the above so will have to bow to superior knowledge. I'm not worried about validation of user input at this exact moment in time, I'm just trying to determine if this will work in theory! Any assistance in this will be much appreciated..

grid.php

    var lastsel2;
    jQuery(document).ready(function(){
      jQuery("#timeLog").jqGrid({
        url:'datagrid.php?module=timemanagement&branchid=<?php echo($branchid); ?>',
        editurl: "gridsave.php?branchid=<?php echo($branchid); ?>",
        datatype: 'json',
        mtype: 'GET',
        colNames:['First Name','Surname','Job Title',       
        <?php
        $x = 1;
        while($x <= $numdays) {
            echo("'HV',");
            echo("'R',");
            $x++;
        }           
        ?>
        ],
        colModel :[
            {name:'firstname', index:'firstname', align: 'center', width: 100, searchoptions: { sopt: ['eq', 'ne', 'lt', 'gt', 'cn', 'nc']}},
            {name:'lastname', index:'lastname', align: 'center', width: 100, searchoptions: { sopt: ['eq', 'ne', 'lt', 'gt', 'cn', 'nc']}},
            {name:'jobtitle', index:'jobtitle', align: 'center', width: 100, searchoptions: { sopt: ['eq', 'ne', 'lt', 'gt', 'cn', 'nc']}},
            <?php
            $x = 1;
            while($x <= $numdays) {
                echo("{name:'hv-$x-$month-$year', index:'hv', align: 'center', width: 25, sortable: false, editable: true},");
                echo("{name:'r-$x-$month-$year', index:'r', align: 'center', width: 25, sortable: false, editable:true, edittype:'select', editoptions:{value:':;OT:OT;S:S;H:H;OA:OA'}},");
                $x++;
            }
            ?>
        ],
        onSelectRow: function(id){
            if(id && id!==lastsel2){
                $('#timeLog').jqGrid('saveRow',lastsel2);
                $('#timeLog').jqGrid('editRow',id,true);
                lastsel2=id;
            }
        },
        pager: '#pager',
        height: 500,
        rowNum:25,
        rowList:[25,50,100],
        sortname: 'firstname',
        sortorder: 'ASC',
        viewrecords: true,
      }).navGrid('#pager', {search:true, edit: false, add:false, del:false});
    });  

   

gridsave.php

// Check for exec permission
define('_CHECKEXEC', TRUE);

// Connect to database
include("./includes/init.inc.php");

if($_GET['oper'] == "edit") {
    // Generate query and insert data
    $sql = "INSERT INTO tbltimemanagement(userid, hv, r) VALUES ('$_POST[id]', '$_POST[hv]', '$_POST[r]');";
    mysql_query($sql);
}

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
68 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information