On Tuesday 18 March 2008 12:17:44 pm d3am0n wrote:
> bro can you give me website to referre to . tnx
Here is some code i use to do SSS.dbf files
This is not a perfect method but works perfectly for them..
Hope that is a start will give you more details later.
<?php
# Constants for dbf field types
define ('BOOLEAN_FIELD', 'L');
define ('CHARACTER_FIELD', 'C');
define ('DATE_FIELD', 'D');
define ('NUMBER_FIELD', 'N');
# Constants for dbf file open modes
define ('READ_ONLY', '0');
define ('WRITE_ONLY', '1');
define ('READ_WRITE', '2');
# Path to dbf file
$db_file1 = "/var/www/html/SSS_R3/EMPLOYEE.DBF";
$db_file2 = "/var/www/html/SSS_R3/HEADER.DBF";
$db_file3 = "/var/www/html/SSS_R3/TRAILER.DBF";
$db_filea = "/var/www/html/SSS_R3/MONTH/EMPLOYEE.DBF";
$db_fileb = "/var/www/html/SSS_R3/MONTH/HEADER.DBF";
$db_filec = "/var/www/html/SSS_R3/MONTH/TRAILER.DBF";
$chmod=0666;
if (!copy($db_file1, $db_filea)) {
echo "failed to copy $db_file1...\n";
};
chmod($db_filea,$chmod);
if (!copy($db_file2, $db_fileb)) {
echo "failed to copy $db_file2...\n";
};
chmod($db_fileb,$chmod);
if (!copy($db_file3, $db_filec)) {
echo "failed to copy $db_file3...\n";
};
chmod($db_filec,$chmod);
# dbf database definition
# Each element in the first level of the array represents a row
# Each array stored in the various elements represent the properties for the
row
#$dbase_definition = array (
# array ('name', CHARACTER_FIELD, 20), # string
# array ('date', DATE_FIELD), # date yyymmdd
# array ('desc', CHARACTER_FIELD, 45), # string
# array ('cost', NUMBER_FIELD, 5, 2), # number (length, precision)
# array ('good?', BOOLEAN_FIELD) # boolean#);
# Records to insert into the dbf file
#$inari = array ('Inari', 19991231, 'Deep-fried tofu pouches filled with
rice.', 1.00, TRUE);
#$unagi = array ('Unagi', 19991231, 'Freshwater Eel', 2.50, FALSE);
# create dbf file using the
#$create = @ dbase_create($db_file, $dbase_definition)
# or die ("Could not create dbf file <i>$db_file</i>.");
# open dbf file for reading and writing
$km=file_exists($db_filea);
$id = @ dbase_open ($db_filea, READ_WRITE)
or die ("Could not open dbf file $db_filea.");
#dbase_add_record ($id, $inari)
# or die ("Could not add record 'inari' to dbf file <i>$db_file</i>.");
#dbase_add_record ($id, $unagi)
# or die ("Could not add record 'unagi' to dbf file <i>$db_file</i>.");
# find the number of fields (columns) and rows in the dbf file
$num_fields = dbase_numfields ($id);
$num_rows = dbase_numrecords($id);
#echo "fields ".$num_fields."\n";
#echo "rows ".$num_rows."\n";
$dbase_definition = array (
array ('RECCD', NUMBER_FIELD, 2), # [RECCD] => 20
array ('ESURN', CHARACTER_FIELD, 15), # [ESURN] => BALAN
array ('ENAME', CHARACTER_FIELD, 15), # [ENAME] => MICHELLE
array ('EENMI', CHARACTER_FIELD, 1), # [EENMI] =>
array ('SSNUM', NUMBER_FIELD, 10), # [SSNUM] => 0922226836
array ('SIGN1', CHARACTER_FIELD, 1), # [SIGN1] =>
array ('SSS01', NUMBER_FIELD, 4, 2), # [SSS01] => 517
array ('SIGN2', CHARACTER_FIELD, 1), # [SIGN2] =>
array ('SSS02', NUMBER_FIELD, 4, 2), # [SSS02] => 0
array ('SIGN3', CHARACTER_FIELD, 1), # [SIGN3] =>
array ('SSS03', NUMBER_FIELD, 2, 2), # [SSS03] => 0
array ('SMED1', CHARACTER_FIELD, 1), # [SMED1] =>
array ('MED01', NUMBER_FIELD, 2, 2), # [MED01] => 0
array ('SMED2', CHARACTER_FIELD, 1), # [SMED2] =>
array ('MED02', NUMBER_FIELD, 2, 2), # [MED02] => 0
array ('SMED3', CHARACTER_FIELD, 1), # [SMED3] =>
array ('MED03', NUMBER_FIELD, 2, 2), # [MED03] => 0
array ('SEC01', CHARACTER_FIELD, 1), # [SEC01] =>
array ('EC001', NUMBER_FIELD, 2, 2), # [EC001] => 10
array ('SEC02', CHARACTER_FIELD, 1), # [SEC02] =>
array ('EC002', NUMBER_FIELD, 2, 2), # [EC002] => 0
array ('SEC03', CHARACTER_FIELD, 1), # [SEC03] =>
array ('EC003', NUMBER_FIELD, 2, 2), # [EC003] => 0
array ('APQTR', NUMBER_FIELD, 2, 2), # [APQTR] =>
array ('REMKS', CHARACTER_FIELD, 1), # [REMKS] => N
array ('HRDTE', NUMBER_FIELD, 2, 2), # [HRDTE] =>
array ('deleted', BOOLEAN_FIELD) # [deleted] => 0
);
#echo "dbf file $db_filea contains $num_rows row(s) with $num_fields field(s)
in each row.\n";
# Loop through the entries in the dbf file
for ($i=1; $i <= $num_rows; $i++) {
dbase_delete_record ($id,1);
dbase_pack($id);
}
$sql = "select kk.companyid,ff.lname,ff.fname,replace((case when ff.sss is
null then '' else ff.sss end),'-','') sss, round((sssecv+ sssecv*2.1201 )-
(sssecv*2.1201 ),1) sssecv,(case when sssecv>0 then
round(sssecv*3.12)-round((sssecv+ sssecv*2.1201 )- (sssecv*2.1201 ),1) else
0 end) sssccv " .
"from ((SELECT oldpayrolls.companyid," .
"sum(case when oldpayrolls.hmdf is null then 0 else oldpayrolls.hmdf end )
hdmfecv, " .
"sum(case when oldpayrolls.sss is null then 0 else oldpayrolls.sss end)
sssecv, " .
"sum(case when oldpayrolls.philhealth is null then 0 else
oldpayrolls.philhealth end) philhealthecv " .
"FROM `oldpayrolls` where month(dateto)='" . $months . "' and
year(dateto)='" . $years . "' group by companyid)kk) left join ((select
employee.companyid,birthdate,lname,fname,sss from employee left join personal
on employee.companyid=personal.companyid) ff) on ff.companyid=kk.companyid
where sssecv>0" ;
// $rst is of type "ADODB.Recordset"
$mysql_id = mysql_connect($host,$user,$pass);
mysql_select_db('attendance',$mysql_id);
$rrst = mysql_query($sql,$mysql_id);
for ($i = 0; $rst = mysql_fetch_array($rrst); $i ++){
$inserter = array (
'20',
$rst["lname"], # [ESURN] => BALAN
$rst["fname"], # [ENAME] => MICHELLE
'', # [EENMI] =>
$rst["sss"], # [SSNUM] => 0922226836
'', # [SIGN1] =>
$rst["sssecv"]+$rst["sssccv"], # [SSS01] => 517
'', # [SIGN2] =>
0, # [SSS02] => 0
'', # [SIGN3] =>
0, # [SSS03] => 0
'', # [SMED1] =>
0, # [MED01] => 0
'', # [SMED2] =>
0, # [MED02] => 0
'', # [SMED3] =>
0, # [MED03] => 0
'', # [SEC01] =>
10, # [EC001] => 10
'', # [SEC02] =>
0, # [EC002] => 0
'', # [SEC03] =>
0, # [EC003] => 0
'', # [APQTR] =>
'N', # [REMKS] => N
'', # [HRDTE] =>
);
dbase_add_record ($id, $inserter)
or die ("Could not add record 'inserter' to dbf file <i>$db_filea</i>.");
};
$num_fields = dbase_numfields ($id);
$num_rows = dbase_numrecords($id);
echo "dbf file $db_filea contains $num_rows row(s) with $num_fields field(s)
in each row.\n";
# Loop through the entries in the dbf file
#for ($i=1; $i <= $num_rows; $i++) {
# echo "\nRow $i of the database contains this information: ";
# print_r (dbase_get_record_with_names ($id,$i));
#
#}
# close the dbf file
dbase_close($id);
$km=file_exists($db_fileb);
$id = @ dbase_open ($db_fileb, READ_WRITE)
or die ("Could not open dbf file $db_fileb.");
$num_fields = dbase_numfields ($id);
$num_rows = dbase_numrecords($id);
$string1=$months.$years;
if (strlen($string1)==5){
$string1="0".$string1;
};
#echo "<br><br> ".$string1." <br><br>" ;
$inserter=array( "00","TIMES ASIA PUBLICATIONS INC.", $string1,"0391668012" );
dbase_delete_record ($id,1);
dbase_pack($id);
dbase_add_record ($id, $inserter)
or die ("Could not add record 'inserter' to dbf file <i>$db_fileb</i>.");
#for ($i=1; $i <= $num_rows; $i++) {
# echo "\nRow $i of the database contains this information: ";
# print_r (dbase_get_record_with_names ($id,$i));
#
#}
dbase_close($id);
$km=file_exists($db_filec);
$id = @ dbase_open ($db_filec, READ_WRITE)
or die ("Could not open dbf file $db_filec.");
$num_fields = dbase_numfields ($id);
$num_rows = dbase_numrecords($id);
#for ($i=1; $i <= $num_rows; $i++) {
# echo "\nRow $i of the database contains this information: ";
# print_r (dbase_get_record_with_names ($id,$i));
#
#}
dbase_close($id);
if($errorsss==1){
echo "<br><br><font color='red'><b>Warning SSS number errors check above....
DO NOT USE DISKETTE..<b></font>";
};
?>
<br>
<a href='SSS_R3/MONTH/EMPLOYEE.DBF'>SSS R3 Diskette Employee.dbf </a><br>
<a href='SSS_R3/MONTH/HEADER.DBF'>SSS R3 Diskette Header.dbf </a><br>
<a href='SSS_R3/MONTH/TRAILER.DBF'>SSS R3 Diskette Trailer.dbf </a><br>
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
[email protected] (#PLUG @ irc.free.net.ph)
Read the Guidelines: http://linux.org.ph/lists
Searchable Archives: http://archives.free.net.ph