* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * */ require_once('includes/common.php'); require_once('includes/SI_User.php'); checkLogin("admin"); require_once('includes/SI_SalesCommissionType.php'); $com_type = new SI_SalesCommissionType(); $com_types = $com_type->retrieveSet("ORDER BY name"); if($com_types === FALSE){ $error_msg .= "Error getting commission types!\n"; debug_message($com_type->getLastError()); } $title = "Sales Commission Type Administration"; require('header.php') ?> <div class="tableContainer"> <a href="javascript:;" class="tCollapse" onclick="toggleGrid(this)"><img src="images/arrow_down.jpg" alt="Hide table" />Sales Commission Types</a><div> <div class="gridToolbar"> <a href="sales_comission_type.php?mode=add" style="background-image:url(images/new_invoice.png);">New Sales Commission Type</a> </div> <table border="0" cellspacing="0" cellpadding="0"> <tr> <th><a href="" onclick="return sortTable('bodyId', 0, 1, false)">ID</a></th> <th><a href="" onclick="return sortTable('bodyId', 1, 1, false)">Name</a></th> <th>Edit</th>
function getSalesCommissionType(){ if($this->_sct == FALSE){ $sct = new SI_SalesCommissionType(); if($this->sales_com == 'Y' && $this->sales_com_type_id > 0){ if($sct->get($this->sales_com_type_id) === FALSE){ $this->error = "SI_Project::getSalesCommissionType(): Error getting sales commission: ".$sct->getLastError(); return FALSE; } $this->_sct = $sct; }elseif($this->sales_com == 'N'){ $this->_sct = $sct; }else{ $this->error = "SI_Project::getSalesCommissionType(): Invalid sales commission setting: {$this->sales_com}"; return FALSE; } } return $this->_sct; }
function _calcCommission(){ $task = $this->getTask(); if($task === FALSE) return FALSE; $amount = 0.00; if($this->sales_com_type_id > 0){ $task = $this->getTask(); if(!$task->isSpec() || ($task->isSpec() && $task->isCompleted())){ $sct = new SI_SalesCommissionType(); if($sct->get($this->sales_com_type_id) === FALSE){ $this->error = "SI_TaskActivity::_calcCommission(): Error getting sales commission type: ".$sct->getLastError(); return FALSE; } //debug_message("Found price of ".$this->price." and cost of ".$this->cost."\n"); $amount = round($sct->calculateCommission($this->price, $this->cost), 2); if($amount === FALSE){ $this->error = "SI_TaskActivity::_calcCommission(): Error calculating commission: ".$sct->getLastError(); return FALSE; } } } $this->com_amount = $amount; return TRUE; }