Example #1
0
			$error_msg .= "Error adding transaction to company account!\n";
			debug_message($ct->getLastError());
		}

		// Update the payment with the company transaction id and auth code
		$payment->trans_id = $ct->id;
		$payment->auth_code = $cc_processor->getAuthCode();
		if($payment->update() === FALSE){
			$error_msg .= "Error updating payment with company transaction id!\n";
			debug_message($payment->getLastError());
		}

		if(empty($error_msg)){
			if(isset($_POST['email_invoice']) && $_POST['email_invoice'] == 'Y'){
				$invoice = new SI_Invoice();
				if($invoice->get(intval($_POST['invoice_id'])) === FALSE){
					$error_msg .= "Error retreiving invoice!\n";
					debug_message($invoice->getLastError());
				}
				
				if($invoice->sendEmail('InvoiceEmail') === FALSE){
					$error_msg .= "Error sending invoice notification!\n";
					debug_message($invoice->getLastError());
				}
			}
			if(empty($error_msg)){
				goBack();
			}
		}
	}else{
		$error_msg .= "Error adding Payment!\n";
Example #2
0
 *
 */
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_Payment.php');

checkLogin('accounting');

if(intval($_REQUEST['id']) == 0){
  fatal_error("You must provide an invoice id to edit!");
}

$invoice = new SI_Invoice();
if($invoice->get(intval($_REQUEST['id'])) === FALSE){
  $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;
for ($i = 0; $i < $ta_count; $i += 50) {
    add_activities($i, 50);
}
// Create invoices
$invoice = new SI_Invoice();
foreach ($invoices as $number => $data) {
    if ($number == 0) {
        continue;
    }
    //	debug("Going to create invoice $number for company id ".$data['company_id']." with ids ".join(', ', $data['ids']));
    $company =& $companies[$data['company_id']];
    $invoice_insert_sql = "\nINSERT INTO invoices (id, company_id, address1, address2, city, \nstate, zip, timestamp, terms, trans_id)\nVALUES(" . $number . ", " . $data['company_id'] . ", '" . $company['address1'] . "', '" . $company['address2'] . "', '" . $company['city'] . "', \n'" . $company['state'] . "', '" . $company['zip'] . "', " . $data['timestamp'] . ", 'NET15', 0)\n\t";
    $invoice_result = $si_db->query($invoice_insert_sql, TRUE);
    assert_die($invoice_result, "Could not add invoice!\n" . $si_db->getLastError());
    // Add activities
    $invoice->get($number);
    //	debug("Adding line items to invoice ".$invoice->id);
    assert_die($invoice->addTaskActivities($data['ids']), "Error adding task activities to invoice: " . $invoice->getLastError());
    // Add the company transaction
    $ct = new SI_CompanyTransaction();
    $ct->amount = $invoice->getTotal();
    $ct->company_id = $invoice->company_id;
    $ct->description = "Invoice #" . $invoice->id;
    $ct->timestamp = $invoice->timestamp;
    assert_die($ct->add(), "Error adding company transaction: " . $ct->getLastError());
}
// Create checks
$check = new SI_Check();
foreach ($checks as $number => $data) {
    if ($number == 0) {
        continue;
Example #4
0
	$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){
		$error_msg .= "Could not retrieve Activity List for Company ID ".$_REQUEST['company_id']."!\n";
		debug_message($activity->getLastError());
	}
}else if($_REQUEST['invoice']){
	$title = "for Invoice Number ".$_REQUEST['invoice'];
	$field_header = 'Billed';
	$field = 'invoice';
	$url = $_SERVER['PHP_SELF']."?invoice=".$_REQUEST['invoice']."&";
	$invoice = new SI_Invoice();
	if($invoice->get($_REQUEST['invoice']) === FALSE){
		$error_msg .= "Could not find invoice!\n";
		debug_message($invoice->getLastError());
	}
	
	if(!$loggedin_user->hasRight('admin') && !$loggedin_user->hasRight('accounting')){
		if($loggedin_user->company_id != $invoice->company_id){
			fatal_error('You do not have access to view this invoice!');
		}
	}
	
	$activities = $activity->getActivitiesForCompany(0, TRUE, $_REQUEST['invoice']);
	if($activities === FALSE){
		$error_msg .= "Could not retrieve Activity List for Invoice ".$_REQUEST['invoice']."!\n";
		debug_message($activity->getLastError());
	}