TimeTrex Community Edition v16.2.0
This commit is contained in:
79
classes/modules/plugins/PermissionFactory.plugin.example
Normal file
79
classes/modules/plugins/PermissionFactory.plugin.example
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/*$License$*/
|
||||
|
||||
|
||||
//
|
||||
// Example plugin to modify available permissions
|
||||
//
|
||||
class PermissionFactoryPlugin extends PermissionListFactoryPlugin {
|
||||
private $exclude_section_group = array( 'payroll' ); //Disable entire payroll section group
|
||||
private $exclude_section = array( 'request' ); //Disable entire request section
|
||||
private $exclude_name = array(
|
||||
'absence' => array('view', 'edit'), //Disable specific permissions in absence section
|
||||
'user' => array('edit_own_bank', 'edit_child_bank'), //Disable specific permission in user section
|
||||
);
|
||||
|
||||
function _getFactoryOptions( $name, $parent = NULL ) {
|
||||
$retarr = parent::_getFactoryOptions( $name );
|
||||
|
||||
switch( $name ) {
|
||||
case 'section_group':
|
||||
case 'section_group_map':
|
||||
if ( is_array( $this->exclude_section_group) ) {
|
||||
foreach( $this->exclude_section_group as $exclude_section_group ) {
|
||||
unset($retarr[$exclude_section_group]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'section':
|
||||
//Exclude entire groups first.
|
||||
$section_group_map = parent::_getFactoryOptions( 'section_group_map' );
|
||||
if ( is_array( $this->exclude_section_group) ) {
|
||||
foreach( $this->exclude_section_group as $exclude_section_group ) {
|
||||
foreach( $section_group_map[$exclude_section_group] as $exclude_section_from_group ) {
|
||||
$this->exclude_section[] = $exclude_section_from_group;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Exclude individual sections next.
|
||||
if ( is_array($this->exclude_section) ) {
|
||||
foreach( $this->exclude_section as $exclude_section ) {
|
||||
unset($retarr[$exclude_section]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'name':
|
||||
//Exclude entire groups first.
|
||||
$section_group_map = parent::_getFactoryOptions( 'section_group_map' );
|
||||
if ( is_array( $this->exclude_section_group) ) {
|
||||
foreach( $this->exclude_section_group as $exclude_section_group ) {
|
||||
foreach( $section_group_map[$exclude_section_group] as $exclude_section_from_group ) {
|
||||
$this->exclude_section[] = $exclude_section_from_group;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Exclude individual sections next.
|
||||
if ( is_array($this->exclude_section) ) {
|
||||
foreach( $this->exclude_section as $exclude_section ) {
|
||||
unset($retarr[$exclude_section]); //Remove all sections in the payroll group.
|
||||
}
|
||||
}
|
||||
|
||||
//Exclude individual permissions last.
|
||||
if ( is_array($this->exclude_name) ) {
|
||||
foreach( $this->exclude_name as $exclude_section => $exclude_name_arr ) {
|
||||
foreach( $exclude_name_arr as $exclude_name ) {
|
||||
unset($retarr[$exclude_section][$exclude_name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $retarr;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/*$License$*/
|
||||
|
||||
|
||||
/*
|
||||
* Example plugin.
|
||||
*/
|
||||
class PermissionListFactoryPlugin extends PermissionListFactory {
|
||||
}
|
9
classes/modules/plugins/PunchFactory.plugin.example
Normal file
9
classes/modules/plugins/PunchFactory.plugin.example
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/*$License$*/
|
||||
|
||||
|
||||
/*
|
||||
* Example plugin.
|
||||
*/
|
||||
class PunchFactoryPlugin extends PunchListFactory {
|
||||
}
|
19
classes/modules/plugins/PunchListFactory.plugin.example
Normal file
19
classes/modules/plugins/PunchListFactory.plugin.example
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/*$License$*/
|
||||
|
||||
|
||||
/*
|
||||
* Example plugin.
|
||||
*/
|
||||
class PunchListFactoryPlugin extends PunchListFactory {
|
||||
function postSave() {
|
||||
parent::postSave(); //Make sure you always call the parents function to maintain proper code operation.
|
||||
|
||||
//Punch record was saved. We can do all sorts of things here like trigger real-time data exporting.
|
||||
Debug::Arr( $this->getObjectAsArray(), 'Plugin postSave(): Punch Data: ', __FILE__, __LINE__, __METHOD__,10);
|
||||
Debug::Arr( $this->getPunchControlObject()->getObjectAsArray(), 'Plugin postSave(): Punch Control Data: ', __FILE__, __LINE__, __METHOD__,10);
|
||||
Debug::Arr( $this->getPunchControlObject()->getUserDateObject()->getUserObject()->getObjectAsArray(), 'Plugin postSave(): User Data: ', __FILE__, __LINE__, __METHOD__,10);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
53
classes/modules/plugins/TimesheetDetailReport.plugin.example
Normal file
53
classes/modules/plugins/TimesheetDetailReport.plugin.example
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/*$License$*/
|
||||
|
||||
|
||||
|
||||
//Extend the "ListFactory" if you want your plugin to affect it AND the base Factory class.
|
||||
//Extend just the "Factory" if you just want it to affect just it, and not account for objects read/modified through iterators.
|
||||
class TimesheetDetailReportPlugin extends TimesheetDetailReport {
|
||||
|
||||
function timesheetSignature( $user_data ) {
|
||||
//Custom signature lines for specific companies based on the "id" column from the company table.
|
||||
if ( $this->getUserObject()->getCompany() == 1001 ) {
|
||||
$border = 0;
|
||||
|
||||
$this->pdf->SetFont($this->config['other']['default_font'], '', $this->_pdf_fontSize(10) );
|
||||
$this->pdf->setFillColor(255,255,255);
|
||||
$this->pdf->Ln(1);
|
||||
|
||||
$margins = $this->pdf->getMargins();
|
||||
$total_width = $this->pdf->getPageWidth()-$margins['left']-$margins['right'];
|
||||
|
||||
$buffer = ($total_width-200)/4;
|
||||
|
||||
$line_h = $this->_pdf_scaleSize(6);
|
||||
|
||||
//Signature lines
|
||||
$this->pdf->MultiCell($total_width,5, TTi18n::gettext('CUSTOM SIGNATURE LINE - By signing this timesheet I hereby certify that the above time accurately and fully reflects the time that').' '. $user_data['first_name'] .' '. $user_data['last_name'] .' '.TTi18n::gettext('worked during the designated period.'), $border, 'L');
|
||||
$this->pdf->Ln( $line_h );
|
||||
|
||||
$this->pdf->Cell(40+$buffer, $line_h, TTi18n::gettext('Employee Signature').':', $border, 0, 'L');
|
||||
$this->pdf->Cell(60+$buffer, $line_h, '_____________________________' , $border, 0, 'C');
|
||||
$this->pdf->Cell(40+$buffer, $line_h, TTi18n::gettext('Supervisor Signature').':', $border, 0, 'R');
|
||||
$this->pdf->Cell(60+$buffer, $line_h, '_____________________________' , $border, 0, 'C');
|
||||
|
||||
$this->pdf->Ln( $line_h );
|
||||
$this->pdf->Cell(40+$buffer, $line_h, '', $border, 0, 'R');
|
||||
$this->pdf->Cell(60+$buffer, $line_h, $user_data['first_name'] .' '. $user_data['last_name'] , $border, 0, 'C');
|
||||
|
||||
$this->pdf->Ln( $line_h );
|
||||
$this->pdf->Cell(140+($buffer*3), $line_h, '', $border, 0, 'R');
|
||||
$this->pdf->Cell(60+$buffer, $line_h, '_____________________________' , $border, 0, 'C');
|
||||
|
||||
$this->pdf->Ln( $line_h );
|
||||
$this->pdf->Cell(140+($buffer*3), $line_h, '', $border, 0, 'R');
|
||||
$this->pdf->Cell(60+$buffer, $line_h, TTi18n::gettext('(print name)'), $border, 0, 'C');
|
||||
|
||||
return TRUE;
|
||||
} else {
|
||||
//Fall back to default signature line.
|
||||
return parent::timesheetSignature( $user_data );
|
||||
}
|
||||
}
|
||||
}
|
28
classes/modules/plugins/UserFactory.plugin.example
Normal file
28
classes/modules/plugins/UserFactory.plugin.example
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/*$License$*/
|
||||
|
||||
|
||||
/*
|
||||
* Example plugin.
|
||||
*/
|
||||
|
||||
|
||||
//Extend the "ListFactory" if you want your plugin to affect it AND the base Factory class.
|
||||
//Extend just the "Factory" if you just want it to affect just it, and not account for objects read/modified through iterators.
|
||||
class UserFactoryPlugin extends UserListFactory {
|
||||
function setLastName( $value ) {
|
||||
//Modify last name, so it always has "-Smith" on the end.
|
||||
$value .= '-Smith';
|
||||
|
||||
return parent::setLastName( $value );
|
||||
}
|
||||
|
||||
function postSave() {
|
||||
parent::postSave(); //Make sure you always call the parents function to maintain proper code operation.
|
||||
|
||||
//User record was saved. We can do all sorts of things here like trigger real-time data exporting.
|
||||
Debug::Arr( $this->getObjectAsArray(), 'Plugin postSave(): ', __FILE__, __LINE__, __METHOD__,10);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user