Use Os3grid to make a web-based and Ajax payroll entry interface

Source: Internet
Author: User
Tags add array object count insert interface return strlen
Ajax|web

1 First make some minor modifications to Os3grid: Add the following code

function strlen (str)
{
var Len;
var i;
len = 0;
for (i=0;i{
if (Str.charcodeat (i) >255) len+=2; else len++;
}
return Len;
}

Then modify the following line within the function Grid_cell_txt_edit (cell), mainly to cope with Chinese

s + + ' size= ' + strlen (val) + ' ";

In addition, modify some colors

This.cols = {"Hover": "#d5f1ff",

2 wage gauge structure

Consider that each unit has a different set of books, so set up a set of accounts by the number of pairs

CREATE TABLE PQ_UNITGZXM (
unit_id Char (8) Not NULL DEFAULT ',
Xmbh int not NULL DEFAULT 0,
XMBM varchar (3) Not NULL PRIMARY KEY,
XMMC varchar not NULL DEFAULT ',
LX varchar (MB) Not NULL DEFAULT ',
JSGS varchar not NULL DEFAULT '
)

INSERT into PQ_UNITGZXM values (' 00000001 ', 1, ' F01 ', ' Employee number ', ' System value ', ');
INSERT into PQ_UNITGZXM values (' 00000001 ', 2, ' F02 ', ' name ', ' System value ', ');
INSERT into PQ_UNITGZXM values (' 00000001 ', 3, ' F03 ', ' unit ', ' system value ', ');
INSERT into PQ_UNITGZXM values (' 00000001 ', 4, ' F04 ', ' base salary ', ' input value ', ');
INSERT into PQ_UNITGZXM values (' 00000001 ', 5, ' F05 ', ' bonus ', ' input value ', ');
INSERT into PQ_UNITGZXM values (' 00000001 ', 6, ' F06 ', ' salary payable ', ' calculated value ', ');
INSERT into PQ_UNITGZXM values (' 00000001 ', 7, ' F07 ', ' personal income tax ', ' calculated value ', ');
INSERT into PQ_UNITGZXM values (' 00000001 ', 8, ' F08 ', ' should be deducted wages ', ' calculated value ', ');
INSERT into PQ_UNITGZXM values (' 00000001 ', 9, ' F09 ', ' real wages ', ' calculated value ', ');

Method of using space redundancy in real wage entry

CREATE TABLE PQ_GZXM (
gzb_id Char (8) Not NULL DEFAULT ',
employee_id char (8) Not NULL DEFAULT ',
XM varchar not NULL DEFAULT ',
employeecontract_id Char (8) Not NULL DEFAULT ',
Gzdata1 decimal not NULL DEFAULT ' 0 ',
Gzdata2 decimal not NULL DEFAULT ' 0 ',
Gzdata3 decimal not NULL DEFAULT ' 0 ',
GZDATA4 decimal not NULL DEFAULT ' 0 ',
Gzdata5 decimal not NULL DEFAULT ' 0 ',
GZDATA6 decimal not NULL DEFAULT ' 0 ',
Gzdata7 decimal not NULL DEFAULT ' 0 ',
Gzdata8 decimal not NULL DEFAULT ' 0 ',
gzdata9 decimal not NULL DEFAULT ' 0 ',
GZDATA10 decimal not NULL DEFAULT ' 0 ',
GZDATA11 decimal not NULL DEFAULT ' 0 ',
Gzdata12 decimal not NULL DEFAULT ' 0 ',
Gzdata13 decimal not NULL DEFAULT ' 0 ',
GZDATA14 decimal not NULL DEFAULT ' 0 ',
GZDATA15 decimal not NULL DEFAULT ' 0 ',
Gzdata16 decimal not NULL DEFAULT ' 0 ',
Gzdata17 decimal not NULL DEFAULT ' 0 ',
Gzdata18 decimal not NULL DEFAULT ' 0 ',
Gzdata19 decimal not NULL DEFAULT ' 0 ',
GZDATA20 decimal not NULL DEFAULT ' 0 '
)


INSERT into PQ_GZXM (gzb_id,employee_id,xm,employeecontract_id,gzdata1) VALUES (' 00000001 ', ' 00000001 ', ' John ', ' 00000001 ', 0);
INSERT into PQ_GZXM (gzb_id,employee_id,xm,employeecontract_id,gzdata1) VALUES (' 00000001 ', ' 00000002 ', ' Dick ', ' 00000002 ', 0);

3 Generating Forms

function Show_form ($unit _id = ', $gzyear = ', $gzmonth = ', $error = ') {
Global $db, $me, $t, $_post;

Extract ($_post);
if ($unit _id &&! $error) {
$rs = $db->execute ("SELECT * from".) Tbl_unitgzxm. "Where unit_id = ' $unit _id '");
$items = $rs->getarray ();
$t->assign (' Items ', $items);

$rs = $db->execute ("Select E.employee_id,e.xm,ec.dwmc from". Tbl_employee. "E,". Tbl_employeecontract. "EC,". Tbl_unitcontract. "UC where e.employee_id=

ec.employee_id and ec.unitcontract_id = uc.unitcontract_id and uc.unit_id = ' $unit _id ');
$t->assign (' Employees ', $rs->getarray ());
$gzb _id = ';
$DWMC = ';

$GZB = $db->getrow ("Select Gzb_id,dwmc from". Tbl_gzb. "Where unit_id = ' $unit _id '

and Gzyear= ' 2006 ' and gzmonth= ' 04 ');

$GZB _id = $gzb [' gzb_id '];
$DWMC = $gzb [' DWMC '];

$gz _array = Array ();
$rs = $db->execute ("SELECT * from".) Tbl_gzxm. "Where gzb_id = ' $gzb _id '");
while (! $rs->eof) {

$gzdata _array = Array ();

Gzdata1 starting from 1
for ($i = 1, $count = count ($items)-3; $i <= $count; $i + +) {
Array_push ($gzdata _array, $rs->fields[' Gzdata '. $i]);
}


$gzline = Array ($rs->fields[' employee_id '), $rs->fields[' XM '], $DWMC, $gzdata _array);
Array_push ($gz _array, $gzline);

$rs->movenext ();
}

} else {
$t->assign ($_post);
}

Print_r ($gz _array);
$t->assign (' Error ', $error);
$t->assign (' Gz_array ', $gz _array);
$t->render (' salary.html ', page_title, ' wrap.html ', False);
}

form template

The 4 Http_fetch_sync function is as follows

var global_xmlhttp = getxmlhttpinstance ();

function Http_fetch_sync (url,post_data)
{

Global_xmlhttp = Getxmlhttpinstance ();

var method = ' Get ';
if (typeof (Post_data)!= ' undefined ')
{
method = ' POST ';
}

Try
{
Global_xmlhttp.open (method, url,true);
Global_xmlhttp.open (method, Url,false);
}
catch (E)
{
Alert (' Message: ' +e.message+ ': url: "+url);
}
if (method = = ' POST ')
{
Global_xmlhttp.setrequestheader (' Content-type ', ' application/x-www-form-urlencoded ');
}

Global_xmlhttp.send (Post_data);
var args = {"ResponseText": Global_xmlhttp.responsetext, "Responsexml": Global_xmlhttp.responsexml,

"request_id": request_id};
return args;

}



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.