Exemplo n.º 1
0
        echo "  * " . $exp->getCompany()->id . " \n";
    }
}
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());
                }
Exemplo n.º 2
0
  $error_msg .= "Error retreiving invoice information!\n";
  debug_message($invoice->getLastError());
}

$company = new SI_Company();
if($company->get($invoice->company_id) === FALSE){
  $error_msg .= "Error retreiving company information!\n";
  debug_message($company->getLastError());
}


if(isset($_POST['save_top'])){
	$old_invoice = $invoice;
	$timestamp = getTSFromInput($_POST['timestamp']);
	$_POST['timestamp'] = $timestamp;
	$invoice->updateFromAssocArray($_POST);
	if($invoice->update() === FALSE){
		$error_msg .= "Error updating invoice information!";
		debug_message($invoice->getLastError());
	}else{
		//Add discount line
		if($_POST['discount_line'] == 'Y'){
			if($invoice->addDiscountLine() === FALSE){
				$error_msg = "Error calculating discount line\n";
				debug_message($invoice->getLastError());	
			}
		}
	

		if($old_invoice->company_id != $invoice->company_id){
			$ct = new SI_CompanyTransaction();