// Create checks
$check = new SI_Check();
foreach ($checks as $number => $data) {
    if ($number == 0) {
        continue;
    }
    //	debug("Going to create check $number for amount ".$data['amount']." with ids ".join(', ', $data['ids']));
    $check->user_id = $data['user_id'];
    $check->number = $number;
    $check->timestamp = $data['timestamp'];
    $check->amount = $data['amount'];
    $check->type = 'CHECK';
    $check->name = $users[$data['user_id']]['first_name'] . ' ' . $users[$data['user_id']]['last_name'];
    $check->address1 = $users[$data['user_id']]['address1'];
    $check->address2 = $users[$data['user_id']]['address2'];
    $check->city = $users[$data['user_id']]['city'];
    $check->state = $users[$data['user_id']]['state'];
    $check->zip = $users[$data['user_id']]['zip'];
    assert_die($check->add(), "Error adding check: " . $check->getLastError());
    assert_die($check->attachCostTransactions($data['ids']), "Error adding cost transactions to check: " . $check->getLastError());
    // Add user transaction
    $ut = new SI_UserTransaction();
    $ut->amount = -$check->amount;
    $ut->description = "Check #" . $check->number;
    $ut->timestamp = $check->timestamp;
    $ut->user_id = $check->user_id;
    assert_die($ut->add(), "Error adding user transaction: " . $ut->getLastError());
    // Update check trans id
    $check->trans_id = $ut->id;
    assert_die($check->update(), "Error updating transaction id for check: " . $check->getLastError());
}
Exemple #2
0
		if(in_array($ta->cost_trans_id, $cost_trans_ids)){
			$total_amount += $ta->cost;
		}
	}

	foreach($commissions as $com){
		if(in_array($com->com_trans_id, $comm_trans_ids)){
			$total_amount += $com->com_amount;
		}
	}

	if(empty($error_msg)){
		$check->updateFromAssocArray($_POST);
		$check->timestamp = time();
		$check->amount = $total_amount;
		if($check->add() !== FALSE){
			if($check->attachCostTransactions($cost_trans_ids) === FALSE){
				$error_msg .= "Error adding cost transactions to check!";
				debug_message($check->getLastError());
			}

			if($check->attachCommTransactions($comm_trans_ids) === FALSE){
				$error_msg .= "Error adding commission transactions to check!";
				debug_message($check->getLastError());
			}

			// Add user transaction
			if($check->type == 'CHECK'){
				$desc = "Check #".$check->number;
			}elseif($check->type == "EFT"){
				$desc = "Electronic Funds Transfer";