Friday, September 23, 2011

Salary Slip Generation for Payroll System

Today I am Done with generation of salary slip for Workers in Payroll Management System. for the time I am done with only the phase of downloading complete slips for every employee.

Here Below is snapshot:-

[caption id="attachment_45" align="aligncenter" width="1024" caption="Salary Slip Generation"]Salary Slip Generation[/caption]

And below is the Complete Coding for Generating the Odt file
<?php
require_once('../library/odf.php');
include_once '../dbfiles/config.php';
class salaryslip {
private $query= array();
private $result= array();
private $calsal;
private $acc;
private $ded;
private $totwages;
private $netpay;
private $month;
public function slip() {
$odf = new odf("slip.odt");
$article = $odf->setSegment('articles');
$this->month= date('n')-1;
if($_GET['op']=='comp') {
$this->query[0]= mysql_query("Select workers.id as id, worker_fname, worker_lname, gross, hra, rate, workdays, pf, esi, advance, accno from workers, worker_fixeds, worker_varys, worker_acc where workers.id=worker_fixeds.worker_id and workers.id=worker_varys.id and workers.id=worker_acc.id and month='$this->month'");
if(!$this->query[0]) {
header('location:qerror.php?op=uperror');
}
while($this->result[0]=mysql_fetch_array($this->query[0])) {
$comp_name= $this->result[0]['worker_fname'].' '.$this->result[0]['worker_lname'];
$this->ded=($this->result[0]['pf']+$this->result[0]['esi']+$this->result[0]['advance']);
$article->name($comp_name);
$article->accno($this->result[0]['accno']);
$article->ecode($this->result[0]['id']);
$article->basic($this->result[0]['gross']);
$article->days($this->result[0]['workdays']);
$this->calsal= sprintf('%.2f',($this->result[0]['rate'])*($this->result[0]['workdays']));
$article->calsal($this->calsal);
if($this->result[0]['workdays']<20) {
$article->hra('0');
$this->totwages=sprintf('%.2f',($this->calsal)+0);
$article->total($this->totwages);
}
else {
$article->hra($this->result[0]['hra']);
$this->totwages=sprintf('%.2f',($this->calsal)+$this->result[0]['hra']);
$article->total($this->totwages);
}
$article->pf($this->result[0]['pf']);
$article->esi($this->result[0]['esi']);
$article->advance($this->result[0]['advance']);
$article->totalded($this->ded);
$this->netpay= sprintf('%.2f',($this->totwages)-($this->ded));
$article->netpay($this->netpay);
$article->merge();
}
}
$odf->mergeSegment($article);
$odf->exportAsAttachedFile('CompleteSlip.odt');
}
}
$sh= new salaryslip();
$sh->slip();
?>

No comments:

Post a Comment