Пример #1
0
	function importQB($data){
		if(!isset($data['Item']) || count($data['Item']) == 0){
			return TRUE;
		}
		
		foreach($data['Item'] as $qb_code){
			$cur_codes = $this->retrieveSet("WHERE code = '".mysql_real_escape_string($qb_code['NAME'])."'");
			if($cur_codes === FALSE){
				$this->error = "SI_ItemCode::import(): Error looking for item code with code of {$qb_code['NAME']}";
				return FALSE;
			}
			$code = NULL;
			if(count($cur_codes) != 1){
				// Not found or more than one found so just add a new one
				$code = new SI_ItemCode();
			}else{
				$code =& $cur_codes[0];	
			}

			$code->code = $qb_code['NAME'];
			$code->description = $qb_code['DESC'];
			if(!empty($qb_code['COST'])) $code->cost = preg_replace('/["$,]/', '', $qb_code['COST']);
			if(!empty($qb_code['PRICE'])) $code->price = preg_replace('/["$,]/', '', $qb_code['PRICE']);
			$code->taxable = $qb_code['TAXABLE'];
			$code->income_account_id = SI_Account::getIDForName($qb_code['ACCNT']);
			$code->expense_account_id = SI_Account::getIDForName($qb_code['COGSACCNT']);
						
			$result = FALSE;
			if($code->id > 0){
				$result = $code->update();
			}else{
				$result = $code->add();
			}
			if($result === FALSE){
				$this->error = "SI_ItemCode::importQB(): Error adding code: ".$code->getLastError();
				return FALSE;
			}
		}
		
		return TRUE;
	}
Пример #2
0
>
			<option value="0">Select account...</option>
			<?php 
echo SI_Account::getSelectTags($GLOBALS['CONFIG']['account_payment']);
?>
		</select>	
		</td>
	</tr>
	<tr>
		<td class="dg_data_cell_1">Receivables Account</td>
		<td class="dg_data_cell_1">This account will be used for all receivables in the Quickbooks export</td>
		<td class="dg_data_cell_1">
		<select name="params[account_rec]" <?php 
echo !SI_Config::canEdit('account_rec') ? 'DISABLED' : '';
?>
>
			<option value="0">Select account...</option>
			<?php 
echo SI_Account::getSelectTags($GLOBALS['CONFIG']['account_rec']);
?>
		</select>	
		</td>
	</tr>
	<tr>
		<td colspan="3"><div align="right"><input type="submit" class="button" name="save" value="Save"></div></td>
	</tr>
</table>
	</div>
</div>

<? require('footer.php') ?>
Пример #3
0
	function exportQB($clause = ''){
		$payments = $this->retrieveSet($clause);
		
		if($payments === FALSE){
			return FALSE;
		}
		
		$app_config = SI_Config::getAppConfig();
		$rec_account = new SI_Account();
		$rec_account->get($app_config['account_rec']);
		$payment_account = new SI_Account();
		$payment_account->get($app_config['account_payment']);
		
		$exporter = new QBExporter();
		foreach($payments as $payment){
			$company =& $payment->getCompany();
			if($company != FALSE){
				$payment_data = array();
				$payment_data['NAME'] = $company->name;
				$payment_data['TRNSID'] = $payment->id;
				$payment_data['ACCNT'] = $payment_account->name;
				$payment_data['DOCNUM'] = $payment->id;
				$payment_data['DATE'] = date("n/j/Y", $payment->timestamp);
				$payment_data['TRNSTYPE'] = 'PAYMENT';
				$payment_data['AMOUNT'] = $payment->amount;
				$payment_data['LINES'] = array();
				$payment_data['LINES'][] = array(
					'TRNSTYPE' => 'PAYMENT',
					'DATE' => $payment_data['DATE'],
					'DOCNUM' => $payment_data['DOCNUM'],
					'NAME' => $payment_data['NAME'],
					'AMOUNT' => ($payment->amount * -1),
					'ACCNT' => $rec_account->name
				);					

				if($exporter->addItem('Payment', $payment_data) === FALSE){
					$this->error = "SI_Payment::export(): Error adding payment {$payment->id}: ".$exporter->getLastError();
					return FALSE;
				}
			}
		}
		
		return $exporter->get_string();
	}
Пример #4
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * 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');
checkLogin('admin');

require_once('includes/SI_Account.php');
$title = '';
$account = new SI_Account();

if($_REQUEST['mode'] == 'add'){
	$title = "Add Account";
	
	if($_POST['save']){
		$account->updateFromAssocArray($_POST);
		$account->id = $account->add();
		if($account->id !== false){
			goBack();
		}else{
			$error_msg .= "Error adding Account!\n";
			debug_message($account->getLastError());
		}
	}
}else if($_REQUEST['mode'] == 'edit'){
Пример #5
0
if(!isset($_REQUEST['mode']) || empty($_REQUEST['mode'])){
	fatal_error("Export mode must be specified!");
}elseif(strtolower($_REQUEST['mode']) == 'company'){
	$company = new SI_Company();
	$output = $company->exportQB();
	if($output === FALSE){
		fatal_error("Error getting company export data!\n".$company->getLastError());
	}
}elseif(strtolower($_REQUEST['mode']) == 'item_code'){
	$code = new SI_ItemCode();
	$output = $code->exportQB();
	if($output === FALSE){
		fatal_error("Error getting item code export data!\n".$code->getLastError());
	}
}elseif(strtolower($_REQUEST['mode']) == 'account'){
	$account = new SI_Account();
	$output = $account->exportQB();
	if($output === FALSE){
		fatal_error("Error getting account export data!\n".$account->getLastError());
	}
}elseif(strtolower($_REQUEST['mode']) == 'payment'){
	$payment = new SI_Payment();
	$output = $payment->exportQB();
	if($output === FALSE){
		fatal_error("Error getting payment export data!\n".$payment->getLastError());
	}
}elseif(strtolower($_REQUEST['mode']) == 'invoice'){
	$invoice = new SI_Invoice();
	$output = $invoice->exportQB();
	if($output === FALSE){
		fatal_error("Error getting invoice export data!\n".$invoice->getLastError());
Пример #6
0
	function exportQB($clause = ''){
		$invoices = $this->retrieveSet($clause);
		
		if($invoices === FALSE){
			return FALSE;
		}
		
		$app_config = SI_Config::getAppConfig();
		$rec_account = new SI_Account();
		$rec_account->get($app_config['account_rec']);
		
		$exporter = new QBExporter();
		foreach($invoices as $invoice){
			$company =& $invoice->getCompany();
			if(count($invoice->_lines) > 0 && $company != FALSE){
				$invoice_data = array();
				$invoice_data['NAME'] = $company->name;
				$invoice_data['TRNSID'] = $invoice->id;
				$invoice_data['DOCNUM'] = $invoice->id;
				$invoice_data['DATE'] = date("n/j/Y", $invoice->timestamp);
				$invoice_data['TRNSTYPE'] = 'INVOICE';
				$invoice_data['TAXABLE'] = ($invoice->getTaxAmount() > 0.00);
				$invoice_data['TAX_CHARGED'] = ($invoice->getTaxAmount() > 0.00);
				$invoice_data['ACCNT'] = $rec_account->name;
				$invoice_data['AMOUNT'] = $invoice->getTotal();
				$invoice_data['LINES'] = array();
				$invoice_data['TIMESTAMP'] = $invoice->updated_ts;
				foreach($invoice->_lines as $line){
					$item_code =& $line->getItemCode();
					$amount = $line->getTotal() * -1;
					$invoice_data['LINES'][] = array(
						'TRNSTYPE' => 'INVOICE',
						'DATE' => $invoice_data['DATE'],
						'QNTY' => (float)'-'.$line->quantity,
						'MEMO' => '"'.$line->description.'"',
						'AMOUNT' => $amount,
						'PRICE' => (float)$line->unit_price,
						'INVITEM' => $item_code->code,
						'ACCNT' => $item_code->getIncomeAccountName()
					);					
				}

				if($exporter->addItem('Invoice', $invoice_data) === FALSE){
					$this->error = "SI_Company::export(): Error adding customer {$customer->name}: ".$exporter->getLastError();
					return FALSE;
				}
			}
		}
		
		return $exporter->get_string();
	}
Пример #7
0
			debug_message($importer->getLastError());
		}
		
		$company = new SI_Company();
		if($company->importQB($data) === FALSE){
			$error_msg .= "Error importing company data!";
			debug_message($company->getLastError());	
		}

		$code = new SI_ItemCode();
		if($code->importQB($data) === FALSE){
			$error_msg .= "Error importing item code data!";
			debug_message($code->getLastError());	
		}

		$account = new SI_Account();
		if($account->importQB($data) === FALSE){
			$error_msg .= "Error importing account data!";
			debug_message($account->getLastError());	
		}
	}
}

?>
<? require('header.php'); ?>
<div class="box">
<div class="boxTitle"><h3><?php 
echo $title;
?>
</h3><span class="boxTitleRight">&nbsp;</span><span class="boxTitleCorner">&nbsp;</span></div><div class="boxContent">
<form name="qb_import" action="<?php 
Пример #8
0
	function getIDForName($name){
		global $db_conn;
		
		$accounts = SI_Account::retrieveSet("WHERE name LIKE '".$db_conn->escapeString($name)."'");
		if(is_array($accounts) && count($accounts) > 0){
			return $accounts[0]->id;
		}
		
		return 0;
	}
Пример #9
0
	<td class="form_field_cell">
		<select name="income_account_id">
			<option value="0">Select account...</option>
			<?php 
echo SI_Account::getSelectTags($item_code->income_account_id);
?>
		</select>	
	</td>
</tr>
<tr>
	<td class="form_field_header_cell">Expense Account:</td>
	<td class="form_field_cell">
		<select name="expense_account_id">
			<option value="0">Select account...</option>
			<?php 
echo SI_Account::getSelectTags($item_code->expense_account_id);
?>
		</select>	
	</td>
</tr>
<tr>
	<td class="form_field_header_cell">Cost:</td>
	<td class="form_field_cell"><input name="cost" class="input_text" size="10" type="text" value="<?php 
echo $item_code->cost;
?>
"></td>
</tr>
<tr>
	<td class="form_field_header_cell">Default Price:</td>
	<td class="form_field_cell"><input name="price" class="input_text" size="10" type="text" value="<?php 
echo $item_code->price;
Пример #10
0
	<tbody id="bodyId">
<? for($i = 0; $i < count($config_items); $i++){ ?>
	<tr onmouseover="this.style.backgroundColor ='#CCCCCC'" onmouseout="this.style.backgroundColor ='#FFFFFF'">
		<td class="dg_data_cell_1"><?php 
echo $config_items[$i]->name;
?>
</td>
		<td class="dg_data_cell_1">
<?		if($config_items[$i]->name == 'account_rec' || $config_items[$i]->name == 'account_payment'){ ?>
		<select name="params[<?php 
echo $config_items[$i]->name;
?>
]">
			<option value="0">Select account...</option>
			<?php 
echo SI_Account::getSelectTags($config_items[$i]->value);
?>
		</select>	
<?		}else{ ?>
		<input type="text" class="input_text" size="45" name="params[<?php 
echo $config_items[$i]->name;
?>
]" value="<?php 
echo $config_items[$i]->value;
?>
" />	
<?		} ?>		</td>
		<td class="dg_data_cell_1" align="center">&nbsp;
			<a class="link1" href="app_config.php?mode=delete&amp;name=<?php 
echo $config_items[$i]->name;
?>
Пример #11
0
			$output .= $company_output;
		}
	}
	
	if(isset($_POST['export_item_codes']) && is_array($_POST['export_item_codes'])){
		$item_code = new SI_ItemCode();
		$item_code_output = $item_code->exportQB("WHERE id IN (".join(',', $_POST['export_item_codes']).")");
		if($item_code_output === FALSE){
			fatal_error("Error getting item_code export data!\n".$item_code->getLastError());
		}else{
			$output .= $item_code_output;
		}
	}

	if(isset($_POST['export_accounts']) && is_array($_POST['export_accounts'])){
		$account = new SI_Account();
		$account_output = $account->exportQB("WHERE id IN (".join(',', $_POST['export_accounts']).")");
		if($account_output === FALSE){
			fatal_error("Error getting account export data!\n".$account->getLastError());
		}else{
			$output .= $account_output;
		}
	}

	if(isset($_POST['export_invoices']) && is_array($_POST['export_invoices'])){
		$invoice = new SI_Invoice();
		$invoice_output = $invoice->exportQB("WHERE id IN (".join(',', $_POST['export_invoices']).")");
		if($invoice_output === FALSE){
			fatal_error("Error getting invoice export data!\n".$invoice->getLastError());
		}else{
			$output .= $invoice_output;
Пример #12
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_User.php');

checkLogin("admin");

require_once('includes/SI_Account.php');

$account = new SI_Account();
$accounts = $account->retrieveSet("ORDER BY name");
if($accounts === FALSE){
	$error_msg .= "Error getting accounts!\n";
	debug_message($account->getLastError());
}

$title = "Account Administration";

require('header.php') ?>
<div class="tableContainer">
<a href="javascript:;" class="tCollapse" onclick="toggleGrid(this)"><img src="images/arrow_down.jpg" alt="Hide table" />Accounts</a><div>
	<div class="gridToolbar">
		  <a href="account.php?mode=add" style="background-image:url(images/new_invoice.png);">New Account</a>
	</div>
<table border="0" cellspacing="0" cellpadding="0">