function add_activities($offset, $limit)
{
    global $dt_db, $si_db, $company_rates, $user_rates, $invoices, $checks;
    debug("add_activities({$limit}, offset)");
    $task_activity_sql = "\n\tSELECT ta.id, ta.task_id, ta.user_id, ta.text, ta.start_ts, ta.end_ts, ta.invoice, ta.check, p.company_id \n\tFROM `task_activities` AS ta\n\tLEFT JOIN tasks AS t ON t.id = ta.task_id\n\tLEFT JOIN projects AS p ON p.id = t.project_id\n\tLIMIT {$offset}, {$limit}\n\t";
    $task_activity_result = $dt_db->query($task_activity_sql, TRUE);
    assert_die($task_activity_result, "Could not get task activities!\n" . $dt_db->getLastError());
    debug('Got ' . $task_activity_result->numRows() . ' task activity rows from phpdt.');
    while ($row = $task_activity_result->fetchArray(MYSQL_ASSOC)) {
        $ta = new SI_TaskActivity();
        $ta->task_id = $row['task_id'];
        $ta->user_id = $row['user_id'];
        $ta->text = $row['text'];
        $ta->start_ts = $row['start_ts'];
        $ta->end_ts = $row['end_ts'];
        $ta->hourly_rate = $company_rates[$row['company_id']];
        $ta->hourly_cost = $user_rates[$row['user_id']];
        // Special exception for david
        if ($row['user_id'] == 10 && $row['end_ts'] < mktime(0, 0, 0, 1, 1, 2005)) {
            $ta->getUser();
            $ta->_user->rate_type = 'HOURLY';
        }
        $GLOBALS['phpdt_cost_ts'] = $row['end_ts'];
        assert_die($ta->add(), "Error adding task activity!\n" . $ta->getLastError());
        $invoices[$row['invoice']]['company_id'] = $row['company_id'];
        if ($ta->end_ts > $invoices[$row['invoice']]['timestamp']) {
            $invoices[$row['invoice']]['timestamp'] = $ta->end_ts;
        }
        $invoices[$row['invoice']]['ids'][] = $ta->id;
        $checks[$row['check']]['user_id'] = $row['user_id'];
        $checks[$row['check']]['ids'][] = $ta->cost_trans_id;
        if ($ta->end_ts > $checks[$row['check']]['timestamp']) {
            $checks[$row['check']]['timestamp'] = $ta->end_ts;
        }
        $checks[$row['check']]['amount'] += $ta->cost;
    }
    $task_activity_result->free();
    debug('Added task activities to sureinvoice!');
}
Пример #2
0
         }
     } else {
         $tasks = $task->findTasks($params[0]);
     }
     if ($tasks === false) {
         $output['error'] = $task->getLastError();
     } else {
         $output['tasks'] = $tasks;
     }
     break;
 case 'addTaskActivity':
     $project = new SI_Project();
     $company = new SI_Company();
     $task = new SI_Task();
     $item_code = new SI_ItemCode();
     $task_activity = new SI_TaskActivity();
     $task_activity->start_ts = getTSFromInput($_POST['ta_popup_start_ts']['date'], $_POST['ta_popup_start_ts']['time']);
     $task_activity->end_ts = getTSFromInput($_POST['ta_popup_end_ts']['date'], $_POST['ta_popup_end_ts']['time']);
     $task_activity->task_id = intval($_POST['ta_popup_task_id']);
     $task_activity->user_id = $loggedin_user->id;
     $task_activity->text = $_POST['ta_popup_text'];
     $task_activity->item_code_id = $_POST['ta_popup_item_code_id'];
     $debug_info = "\n\t\t\tPOST = " . print_r($_POST, true) . "\n\n\t\t\tstart_ts = {$task_activity->start_ts}\n\n\t\t\tend_ts = {$task_activity->end_ts}\n\n\t\t\ttask_id = {$task_activity->task_id}\n\n\t\t\tuser_id = {$task_activity->user_id}\n\n\t\t\titem_code_id = {$task_activity->item_code_id}\n\n\t\t\ttext = {$task_activity->text}\n\n\t\t";
     $output['debug'] = $debug_info;
     if ($task_activity->task_id > 0 || $task_activity->start_ts > 0 || $task_activity->end_ts > 0) {
         if ($task_activity->task_id <= 0 || $task_activity->start_ts <= 0 || $task_activity->end_ts <= 0) {
             $output['error'] = "Skipping incomplete entry\n";
             break;
         }
     } else {
         $output['error'] = "Skipping incomplete entry\n";
Пример #3
0
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 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_Project.php');
require_once('includes/SI_Task.php');
require_once('includes/SI_TaskActivity.php');
require_once('includes/SI_PaymentSchedule.php');

checkLogin();

$project = new SI_Project();
$task = new SI_Task();
$ta = new SI_TaskActivity();
$activities = array();

if(!empty($_REQUEST['task_id'])){
	$task->get($_REQUEST['task_id']);
	$project->get($task->project_id);
	if(!$project->hasRights(PROJECT_RIGHT_VIEW)){
		fatal_error('Insufficent access rights for this project!');
	}
	$activities = $ta->retrieveSet("task_id = ".$task->id);
	if($activities === FALSE){
		$error_msg .= "Error getting list of task time!\n";
		debug_message($ta->getLastError());
	}
}else{
	fatal_error("Task ID must be supplied!\n");
Пример #4
0
}
echo "\n\n\$\$\$\$ START MAKIN MONEY \$\$\$\$\n\n";
$comp_ids = array_unique($comp_ids);
if (count($comp_ids) > 0) {
    foreach ($comp_ids as $compid) {
        echo "\$\$\$ Generating Invoice for Company_id - {$compid}\n";
        $invoice = new SI_Invoice();
        $company = new SI_Company();
        if ($company->get($compid)) {
            $company_array = get_object_vars($company);
            $company_array['company_id'] = $company->id;
            unset($company_array['id']);
        }
        $invoice->updateFromAssocArray($company_array);
        if ($invoice->add() !== FALSE) {
            $activity = new SI_TaskActivity();
            $temp_array = $activity->getActivitiesForCompany($compid);
            if ($temp_array != NULL) {
                $ta_ids = '';
                foreach ($temp_array as $temptask) {
                    $ta_ids[] = $temptask->id;
                }
                $ta_ids = array_unique($ta_ids);
            }
            if (count($ta_ids) > 0) {
                if ($invoice->addTaskActivities($ta_ids, SI_ACTIVITY_AGGREGATION_TASK) === FALSE) {
                    $error_msg .= "Error adding activities to invoice!\n";
                    debug_message($invoice->getLastError());
                }
            }
            $ps = new SI_PaymentSchedule();
Пример #5
0
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 * http://www.gnu.org/copyleft/gpl.html
 *
 */
require_once('includes/common.php');
checkLogin();

require_once('includes/SI_Project.php');
require_once('includes/SI_Task.php');
require_once('includes/SI_TaskActivity.php');
require_once('includes/SI_Expense.php');
require_once('includes/SI_ItemCode.php');

$title = '';
$task_activity = new SI_TaskActivity();
$task = new SI_Task();
$project = new SI_Project();
$user = new SI_User();
$item_code = new SI_ItemCode();
$disabled = false;

if($_REQUEST['mode'] == 'add'){
	$title = "Add Time Entry";
	if(empty($_REQUEST['task_id'])){
		fatal_error("No Task ID specified!\n");
	}else{
		$task_activity->task_id = $_REQUEST['task_id'];
		$task_activity->completed_ts = time();
		$task_activity->user_id = $loggedin_user->id;
		if($task->get($task_activity->task_id) === FALSE){
Пример #6
0
echo $invoice->_lines[$i]->id;
?>
"><img src="images/edit.png" width="16" height="16" title="Edit Line" border="0" /></a>
		</td>
		<td class="gridActions">
			<a class="link1" href="invoice_line.php?mode=delete&id=<?php 
echo $invoice->_lines[$i]->id;
?>
"><img src="images/delete.png" width="16" height="16" title="Delete Line" border="0" /></a>
		</td>		
	</tr>
<? if($_REQUEST['detail']){
	$links =& $invoice->_lines[$i]->_links; 
	for($x=0; $x<count($links); $x++){ 
		if($links[$x]->task_activity_id > 0){ 
			$ta = new SI_TaskActivity();
			$ta->get($links[$x]->task_activity_id); ?>
	<tr>
		<td colspan="11" class="dg_data_cell_1">
			<table cellpadding="2" cellspacing="0">
    		<tr>
      			<td valign="top" nowrap><b><?php 
echo date("n/j/y H:i", $ta->start_ts) . "-" . date("H:i", $ta->end_ts);
?>
</b></td>
      			<td valign="top"><?php 
echo $ta->text;
?>
</td>
			</tr>
			</table>
Пример #7
0
function soap_add_task_activity($username, $password, $task_activity)
{
    global $loggedin_user;
    $user = auth_user($username, $password);
    if ($user === FALSE) {
        return new soap_fault('Client', '', 'Access Denied');
    }
    $loggedin_user = $user;
    $task = new SI_Task();
    $project = new SI_Project();
    $item_code = new SI_ItemCode();
    $ta = new SI_TaskActivity();
    $ta->start_ts = $task_activity['start_ts'];
    $ta->end_ts = $task_activity['end_ts'];
    $ta->task_id = $task_activity['task_id'];
    $ta->user_id = $loggedin_user->id;
    $ta->text = $task_activity['text'];
    $ta->item_code_id = $task_activity['item_code_id'];
    if ($ta->task_id > 0 || $ta->start_ts > 0 || $ta->end_ts > 0) {
        if ($ta->task_id <= 0 || $ta->start_ts <= 0 || $ta->end_ts <= 0) {
            return new soap_fault('Client', '', 'Invalid data fields in task_activity');
        }
    }
    if ($task->get($ta->task_id) === FALSE) {
        return new soap_fault('Client', '', 'Could not retreive task ID ' . $ta->task_id, $task->getLastError());
    }
    if ($project->get($task->project_id) === FALSE) {
        return new soap_fault('Client', '', 'Could not retreive project!', $project->getLastError());
    }
    if (!$project->hasRights(PROJECT_RIGHT_EDIT)) {
        return new soap_fault('Client', '', 'Insufficent access rights for this project!');
    }
    $ta->hourly_cost = $loggedin_user->hourly_rate;
    $company = $project->getCompany();
    if ($company === FALSE) {
        return new soap_fault('Client', '', 'Could not get company information!', $project->getLastError());
    }
    $ta->hourly_rate = $item_code->getCompanyPrice($company->id, $ta->item_code_id);
    if ($ta->hourly_rate === FALSE) {
        return new soap_fault('Client', '', 'Error getting price for this item code!', $item_code->getLastError());
    }
    $sct = $task->getSalesCommissionType();
    $ta->sales_com_type_id = $sct->id;
    if ($ta->add()) {
        $project->sendUpdateNotification(array("Added new task activity " . $GLOBALS['CONFIG']['url'] . '/task_activity.php?mode=edit&id=' . $task_activity->id));
    } else {
        return new soap_fault('Client', '', 'Error adding Task Activity!', $ta->getLastError());
    }
    return $ta->id;
}
Пример #8
0
	function _getLinked(){
		$id = intval($this->id);
		if($id <= 0)
			return TRUE;
			
		if($this->_ta == FALSE){
			$ta = new SI_TaskActivity();
			$tas = $ta->retrieveSet("WHERE a.cost_trans_id = $id OR a.com_trans_id = $id");
			if($tas === FALSE){
				$this->error = "Error getting linked task: ".$ta->getLastError();
				return FALSE;	
			}
			if(count($tas) == 1){
				$this->_ta = &$tas[0];
			}
		}
		
		if($this->_check == FALSE){
			$check = new SI_Check();
			$checks = $check->retrieveSet("WHERE trans_id = $id");
			if($checks === FALSE){
				$this->error = "Error getting linked task: ".$check->getLastError();
				return FALSE;	
			}
			if(count($checks) == 1){
				$this->_check = &$checks[0];
			}
		}

		return TRUE;
	}
Пример #9
0
	function getActivityDetailHTML($id){
		global $loggedin_user;
		
		$ta = new SI_TaskActivity();
		if($ta->get($id) === false){
			return "Error getting detail for $id: ".$this->getLastError();
		}
		$html = '';
		//$html .= print_r($ta, true);
		$html .= '<div class="ad_div">';
		$html .= '<span class="ad_label">Company:</span>&nbsp;'.$ta->company_name.'<br/>';
		$html .= '<span class="ad_label">User:</span>&nbsp;'.$ta->getUserName().'<br/>';
		if($loggedin_user->hasRight('accounting')){
			$html .= '<span class="ad_label">Hourly Cost:</span>&nbsp;'.$ta->hourly_cost.'<br/>';
			$html .= '<span class="ad_label">Hourly Rate:</span>&nbsp;'.$ta->hourly_rate.'<br/>';
		}
		$html .= '<span class="ad_label">Note:</span><br/>'.nl2br($ta->text).'<br/>';
		$html .= '</div>';
		return $html;
	}
Пример #10
0
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 * http://www.gnu.org/copyleft/gpl.html
 *
 */
require_once('includes/common.php');
checkLogin();

require_once('includes/SI_Project.php');
require_once('includes/SI_Company.php');
require_once('includes/SI_TaskActivity.php');
require_once('includes/SI_Task.php');

$title = 'Reports';
$activity = new SI_TaskActivity();

if(!isset($_REQUEST['billable'])){
	$_REQUEST['billable'] = 'N';
}

	if(!$loggedin_user->hasRight('admin') && !$loggedin_user->isDeveloper()){
		$_REQUEST['billable'] = 'Y';
		$_REQUEST['company_id'] = $loggedin_user->company_id;
	}

	if(!$loggedin_user->hasRight('admin') && $loggedin_user->isDeveloper()){
		$_REQUEST['resource_id'] = $loggedin_user->id;
	}

	$activities = $activity->find($_REQUEST['start_ts'], $_REQUEST['end_ts']+86400, $_REQUEST['resource_id'], $_REQUEST['company_id'], $_REQUEST['billable']);
Пример #11
0
	function addDiscountLine(){
		if($this->company_id == 0){
			$this->error = "SI_Invoice::addDiscountLine(): Company ID is not set\n";
			return FALSE;
		}
		
		$discount_amount = 0.00;
		$company =& $this->getCompany();
		$rs =& $company->getRateStructure();
		
		//Get all months with time on this invoice
		$time = array();
		foreach($this->_lines as $line){
			if(in_array($line->item_code_id, $rs->item_code_ids) && $line->getType() == 'Task Activity'){
				$links =& $line->getLinks();
				foreach($links as $link){
					$ta = new SI_TaskActivity();
					if($ta->get($link->task_activity_id) === FALSE){
						$this->error = "SI_Invoice::addDiscountLine(): Error getting task activity!\n";
						return FALSE;	
					}
					$time[date('n-Y', $ta->start_ts)]['new_hours'] += ($ta->end_ts - $ta->start_ts) / 60 / 60;
				}
			}
		}
		
		//Get billed hours for the months on this invoice
		foreach($time as $month => $hours){
			$time[$month]['billed_hours'] = $company->getBilledQuantity($rs->item_code_ids, $month) - $time[$month]['new_hours'];
		}
//		var_dump($time);
		
		//Calculate Discount
		$discount = 0.00;
		foreach($time as $month => $hours){
//			debug_message("Looking at month $month with billed hours of ".$hours['billed_hours']." and new hours of ".$hours['new_hours']);
			$ranges = $rs->getLines();
			$current_hours = $hours['billed_hours'];
			$total_hours = $hours['billed_hours'] + $hours['new_hours'];
			foreach($ranges as $range){
//				debug_message("Looking at range {$range->low} - {$range->high} with current hours of $current_hours");
				if($range->high > 0 && $current_hours <= $range->high){
//					debug_message("$current_hours is below range high");
					if($current_hours < $range->low){
//						debug_message("$current_hours is below range low adding ".($range->low - $current_hours)." to current hours");
						$current_hours += $range->low - $current_hours;
					}
					
					if($current_hours < $range->high && $total_hours > $range->high){
//						debug_message("$total_hours is above range high adding ".($range->high - $current_hours)." hours");
						$discount += ($range->high - $current_hours) * $range->discount;
						$current_hours += ($range->high - $current_hours);
					}elseif($current_hours <= $range->high){
//						debug_message("Adjusting discount and current hours for range with ".($total_hours - $current_hours)." hours");
						$discount += ($total_hours - $current_hours) * $range->discount;
						$current_hours +=  ($total_hours - $current_hours);
					}
				}else{
					if($range->high == 0){
//						debug_message("range high is 0 adding ".($total_hours - $current_hours)." hours to discount.");
						$discount += ($total_hours - $current_hours) * $range->discount;
					}
				}
			}
		}
		var_dump($discount);
		
		//TODO Add discount line item
		$new_line = array();
		$new_line[0]['item_code_id'] =  $rs->discount_item_code_id;
		$new_line[0]['quantity'] = 1;
		$new_line[0]['description'] = 'Volume Discount';
		$new_line[0]['price'] = $discount;
		return $this->addCustomLines($new_line);
	}
Пример #12
0
	function getUnitPrice(){
		if($this->task_activity_id > 0){
			$ta = new SI_TaskActivity();
			if($ta->get($this->task_activity_id) === FALSE){
				$this->error = 'SI_InvoiceLineLink::getUnitPrice(): Error getting task activity: '.$ta->getLastError();
				return FALSE;	
			}
			
			return $ta->hourly_rate;
		}elseif($this->expense_id > 0){
			$ex = new SI_Expense();
			if($ex->get($this->expense_id) === FALSE){
				$this->error = 'SI_InvoiceLineLink::getPrice(): Error getting expense: '.$ex->getLastError();
				return FALSE;	
			}
			return $ex->price;
		}elseif($this->payment_schedule_id > 0){
			$ps = new SI_PaymentSchedule();
			if($ps->get($this->payment_schedule_id) === FALSE){
				$this->error = 'SI_InvoiceLineLink::getPrice(): Error getting scheduled payment: '.$ps->getLastError();
				return FALSE;	
			}
			return $ps->amount;
		}
		
		return 'Unknown';
	}
Пример #13
0
 function run($preview = true)
 {
     $results = array();
     if (is_readable($this->file)) {
         $handle = fopen($this->file, "r");
         $first_row = true;
         while (($data = fgetcsv($handle, 4096, ",")) !== FALSE) {
             if ($first_row) {
                 $first_row = false;
                 continue;
             }
             // Process a row
             $result = array();
             $result['action'] = 'Import';
             $result['start_ts'] = strtotime($data[$this->column_mappings[SI_IMPORT_COLUMN_START]]);
             if (isset($this->column_mappings[SI_IMPORT_COLUMN_DURATION])) {
                 // Duration based import
                 $result['end_ts'] = $result['start_ts'] + floatval($data[$this->column_mappings[SI_IMPORT_COLUMN_DURATION]]) * 60 * 60;
             } else {
                 // Start and end time provided
                 $result['start_ts'] = strtotime($data[$this->column_mappings[SI_IMPORT_COLUMN_END]]);
             }
             if (isset($this->column_mappings[SI_IMPORT_COLUMN_COMMENTS])) {
                 $result['comments'] = $data[$this->column_mappings[SI_IMPORT_COLUMN_COMMENTS]];
             } else {
                 $results['comments'] = '';
             }
             $user = $data[$this->column_mappings[SI_IMPORT_COLUMN_USER]];
             $normalized_user = $this->normalize($user);
             if (empty($normalized_user)) {
                 $normalized_user = '******';
             }
             if ($this->users[$normalized_user]['action'] == SI_IMPORT_ACTION_SKIP) {
                 $result['user_id'] = 0;
                 $result['message'] = "Skipped because no user map for '{$user}' was configured";
                 $result['action'] = "Skip";
                 $results[] = $result;
                 continue;
             } else {
                 $result['user_id'] = $this->users[$normalized_user]['param'];
             }
             $task = $data[$this->column_mappings[SI_IMPORT_COLUMN_TASK]];
             $normalized_task = $this->normalize($task);
             if (empty($normalized_task)) {
                 $normalized_task = '_blank_';
             }
             if ($this->tasks[$normalized_task]['action'] == SI_IMPORT_ACTION_SKIP) {
                 $result['task_id'] = 0;
                 $result['message'] = "Skipped because no task map for '{$task}' was configured";
                 $result['action'] = "Skip";
                 $results[] = $result;
                 continue;
             } else {
                 $result['task_id'] = $this->tasks[$normalized_task]['param'];
             }
             $task = new SI_Task();
             $task->get($result['task_id']);
             $ic = $data[$this->column_mappings[SI_IMPORT_COLUMN_ITEMCODE]];
             $normalized_ic = $this->normalize($ic);
             if (empty($normalized_ic)) {
                 $normalized_ic = '_blank_';
             }
             if ($this->item_codes[$normalized_ic]['action'] == SI_IMPORT_ACTION_SKIP) {
                 $result['item_code_id'] = $task->getDefaultItemCode();
                 if ($result['item_code_id'] == 0) {
                     $result['message'] = "Skipped because no item code map for '{$ic}' was configured and no default item code exists for project";
                     $result['action'] = "Skip";
                     $results[] = $result;
                     continue;
                 } else {
                     $result['message'] = "Item Code retreived from project";
                 }
             } else {
                 $result['item_code_id'] = $this->item_codes[$normalized_ic]['param'];
             }
             if ($result['start_ts'] <= 0 || $result['end_ts'] <= 0) {
                 $result['message'] = "Invalid start or end time";
                 $result['action'] = "Skip";
                 $results[] = $result;
                 continue;
             }
             if ($result['start_ts'] > $result['end_ts']) {
                 $result['message'] = "Start Time is before end time";
                 $result['action'] = "Skip";
                 $results[] = $result;
                 continue;
             }
             if ($result['end_ts'] - $result['start_ts'] > 12 * 60 * 60) {
                 $result['message'] = "Length of time is too long, >12 hours";
                 $result['action'] = "Skip";
                 $results[] = $result;
                 continue;
             }
             $project = new SI_Project();
             $company = new SI_Company();
             $task = new SI_Task();
             $item_code = new SI_ItemCode();
             $task_activity = new SI_TaskActivity();
             $task_activity->start_ts = $result['start_ts'];
             $task_activity->end_ts = $result['end_ts'];
             $task_activity->task_id = $result['task_id'];
             $task_activity->user_id = $result['user_id'];
             $task_activity->text = $result['comments'];
             $task_activity->item_code_id = $result['item_code_id'];
             if ($task_activity->task_id > 0 || $task_activity->start_ts > 0 || $task_activity->end_ts > 0) {
                 if ($task_activity->task_id <= 0 || $task_activity->start_ts <= 0 || $task_activity->end_ts <= 0) {
                     $result['action'] = "Skip";
                     $result['message'] = "Skipping incomplete entry\n";
                     $results[] = $result;
                     continue;
                 }
             } else {
                 $result['action'] = "Skip";
                 $result['message'] = "Skipping incomplete entry\n";
                 $results[] = $result;
                 continue;
             }
             if ($task->get($task_activity->task_id) === FALSE) {
                 $result['action'] = "Skip";
                 $result['message'] = "Could not retreive task:\n" . $task->getLastError();
                 $results[] = $result;
                 continue;
             }
             if ($project->get($task->project_id) === FALSE) {
                 $result['action'] = "Skip";
                 $result['message'] = "Could not retreive project:\n" . $project->getLastError();
                 $results[] = $result;
                 continue;
             }
             $user = new SI_User();
             if ($user->get($task_activity->user_id) === FALSE) {
                 $result['action'] = "Skip";
                 $result['message'] = "Could not retreive user:\n" . $user->getLastError();
                 $results[] = $result;
                 continue;
             }
             $task_activity->hourly_cost = $user->hourly_rate;
             $company = $project->getCompany();
             if ($company === FALSE) {
                 $result['action'] = "Skip";
                 $result['message'] = "Could not get company information:\n" . $project->getLastError();
                 $results[] = $result;
                 continue;
             }
             $task_activity->hourly_rate = $item_code->getCompanyPrice($company->id, $task_activity->item_code_id);
             if ($task_activity->hourly_rate === FALSE) {
                 $result['action'] = "Skip";
                 $result['message'] = "Error getting price for this item code:\n" . $item_code->getLastError();
                 $results[] = $result;
                 continue;
             }
             $sct = $task->getSalesCommissionType();
             $task_activity->sales_com_type_id = $sct->id;
             if (!$preview) {
                 if (!$task_activity->add()) {
                     $result['action'] = "Skip";
                     $result['message'] = "Error adding Task Activity:\n" . $task_activity->getLastError();
                 }
             }
             $results[] = $result;
         }
     }
     return $results;
 }
Пример #14
0
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 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_Project.php');
require_once('includes/SI_Task.php');
require_once('includes/SI_TaskActivity.php');

checkLogin();

$activity = new SI_TaskActivity();
$_REQUEST['detail'] = strtolower(substr($_REQUEST['detail'],0,1)) == "y" ? TRUE : FALSE;

if($_REQUEST['company_id']){
	if(!$loggedin_user->hasRight('admin') && !$loggedin_user->hasRight('accounting')){
		if($loggedin_user->company_id != $_REQUEST['company_id']){
			fatal_error('You do not have access to view this company!');
		}
	}
	$title = "for Company";
	$field_header = 'Billed';
	$field = 'invoice_id';
	$url = $_SERVER['PHP_SELF']."?company_id=".$_REQUEST['company_id']."&unbilled=".$_REQUEST['unbilled']."&";
	$_REQUEST['unbilled'] = strtolower(substr($_REQUEST['unbilled'],0,1)) == "y" ? TRUE : FALSE;
	$activities = $activity->getActivitiesForCompany($_REQUEST['company_id'], $_REQUEST['unbilled']);
	if($activities === FALSE){
Пример #15
0
				$ct->amount -= $old_line->getTotal();
				$ct->amount += $line->getTotal();
				if($ct->update() === FALSE){
					$error_msg .= "Error updating company transaction with new price";
					debug_message($ct->getLastError());	
				}else{
					header('Location: '.getCurrentURL('invoice_edit.php').'?id='.$invoice->id."\r\n");
					die();
				}	
			}
			
		}
	}	
}

$activity = new SI_TaskActivity();
$ps = new SI_PaymentSchedule();
$activities = $activity->getActivitiesForCompany($invoice->company_id, true, 0, true);
if($activities === FALSE){
	$error_msg .= "Could not retrieve Activity List for Company!\n";
	debug_message($activity->getLastError());
}

$items = $ps->getForCompany($invoice->company_id);
if($items === FALSE){
	$error_msg .= "Could not retrieve scheduled payments for Company!\n";
	debug_message($ps->getLastError());
}

$expenses = $company->getExpenses(TRUE);
if($expenses === FALSE){
Пример #16
0
if ($loggedin_user->hasRight('admin') && isset($_REQUEST['user_id'])) {
    $user_id = $_REQUEST['user_id'];
} else {
    $user_id = $loggedin_user->id;
}
// Create a new day
$day = new Day($_GET['y'], $_GET['m'], $_GET['d']);
// Get the task data
$task = new SI_Task();
$tasks = $task->getCalendarTasks($user_id, $day->getTimestamp(), $day->getTimestamp() + 24 * 60 * 60, 'hour');
if ($tasks === FALSE) {
    $error_msg .= "Could not retrieve Tasks!\n";
    debug_message($task->getLastError());
}
// Get the activity data
$ta = new SI_TaskActivity();
$activities = $ta->getCalendarActivities($user_id, $day->getTimestamp(), $day->getTimestamp() + 24 * 60 * 60, 'hour');
if ($activities === FALSE) {
    $error_msg .= "Could not retrieve activities!\n";
    debug_message($ta->getLastError());
}
// Make sure the current date is selected
$sHours = array(new Hour(date('Y'), date('m'), date('d'), date('H')));
// Build the hour list for that day
$day->build($sHours);
$title = "Calendar - Month View";
require 'header.php';
?>
<table class="dg_table" width="450">
	<TR>
		<TD COLSPAN="2" CLASS="dg_header_cell"><?php 
Пример #17
0
}
// Instantiate the Month class
$month = new Month($_GET['y'], $_GET['m'], "Sunday");
// Get the details of the months as timestamps
$last = $month->lastMonth(true);
$next = $month->nextMonth(true);
$thisMonth = $month->thisMonth(true);
// Get the task data
$task = new SI_Task();
$tasks = $task->getCalendarTasks($user_id, $thisMonth, $next, 'day');
if ($tasks === FALSE) {
    $error_msg .= "Could not retrieve Tasks!\n";
    debug_message($task->getLastError());
}
// Get the activity data
$ta = new SI_TaskActivity();
$activities = $ta->getCalendarActivities($user_id, $thisMonth, $next, 'day');
if ($activities === FALSE) {
    $error_msg .= "Could not retrieve activities!\n";
    debug_message($ta->getLastError());
}
// Make sure the current date is selected
$sDays = array(new Day(date('Y'), date('m'), date('d')));
// Build the days of the month
$month->buildWeekDays($sDays);
// Define the days of the week for column headings
$daysOfWeek = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
$title = "Calendar - Month View";
require 'header.php';
?>
<?
Пример #18
0
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 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_Invoice.php');
require_once('includes/SI_Company.php');
require_once('includes/SI_TaskActivity.php');
require_once('includes/SI_PaymentSchedule.php');
require_once('includes/SI_ItemCode.php');

checkLogin('accounting');

$num_custom_lines = 5;
$activity = new SI_TaskActivity();
$ps = new SI_PaymentSchedule();
$invoice = new SI_Invoice();
$item_code = new SI_ItemCode();

if ($_POST['save']){
	$ta_ids = $_POST['task_activity_ids'];
	$ps_ids = $_POST['payment_schedule_ids'];
	$ex_ids = $_POST['expense_ids'];
	
	$at_least_one = false;
	if(count($ta_ids) == 0 && count($ps_ids) == 0 && count($ex_ids) == 0){
		if(isset($_REQUEST['custom']) && is_array($_REQUEST['custom'])){
			foreach($_REQUEST['custom'] as $custom_line){
				if($custom_line['quantity'] > 0 || $custom_line['description'] != ''){
					$at_least_one = true;