<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Importing journal entries from remote table]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=3697&amp;type=atom" />
	<updated>2012-12-31T15:05:39Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=3697</id>
		<entry>
			<title type="html"><![CDATA[Importing journal entries from remote table]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=14815#p14815" />
			<content type="html"><![CDATA[<p>Please help, have studied the module for importing journal entries from CSV, but I want to do the same but get them from a remote table, been trying but don&#039;t seem to get it right, here is my code</p><p>include_once($path_to_root . &quot;/includes/ui/items_cart.inc&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />function get_dimension_id_from_reference($ref)<br />{<br />&nbsp; &nbsp; if ($ref == null || $ref == &#039;&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; $sql = &quot;SELECT id FROM &quot;.TB_PREF.&quot;dimensions WHERE reference LIKE &#039;$ref&#039;&quot;;</p><p>&nbsp; &nbsp; $result = db_query($sql, null);<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; $row = db_fetch_row($result);<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; return $row[0];<br />}&nbsp; &nbsp; &nbsp; &nbsp; <br />add_access_extensions();<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; global $Refs;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; $cart = new items_cart(0);<br />&nbsp; &nbsp; &nbsp; &nbsp; $cart-&gt;order_id = 0;<br />&nbsp; &nbsp; &nbsp; &nbsp; $cart-&gt;reference = $Refs-&gt;get_next(0);<br />&nbsp; &nbsp; &nbsp; &nbsp; $cart-&gt;tran_date = new_doc_date();</p><p>&nbsp; &nbsp; &nbsp; &nbsp; if (!is_date_in_fiscalyear($cart-&gt;tran_date))<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $cart-&gt;tran_date = end_fiscalyear();</p><p>&nbsp; &nbsp; &nbsp; &nbsp; $_POST[&#039;memo_&#039;] = $cart-&gt;memo_;<br />&nbsp; &nbsp; &nbsp; &nbsp; $_POST[&#039;ref&#039;] = $cart-&gt;reference;&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; $_POST[&#039;date_&#039;] = $cart-&gt;tran_date;<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; $_SESSION[&#039;journal_items&#039;] = &amp;$cart;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; //print_r($_SESSION[&#039;journal_items&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; $dim1 = get_dimension_id_from_reference(&#039;1&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; $dim2 = get_dimension_id_from_reference(&#039;2&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data = array(0=&gt;array(0 =&gt; &#039;1060&#039;,1=&gt;$dim1,2=&gt;&#039;90000&#039;,3=&gt;&quot;Savings Account&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;1=&gt;array(0 =&gt; &#039;204&#039;,1=&gt;$dim1,2=&gt;&#039;-90000&#039;,3=&gt;&quot;Construction Donations&quot;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach($data as $r){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Check that the account code exists<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (get_gl_account($r[0]) == null) die(&quot;Error: Could not find account code $r[0]&quot;);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //$test .= $r[0].&quot; &quot;.$r[1].&quot; &quot;.$r[2].&quot; &quot;.$r[3].&quot;&lt;/br&gt;&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $_SESSION[&#039;journal_items&#039;]-&gt;add_gl_item($r[0], $r[1], &#039;&#039;, $r[2], $r[3]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p>]]></content>
			<author>
				<name><![CDATA[lawmaina78]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=14031</uri>
			</author>
			<updated>2012-12-31T15:05:39Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=14815#p14815</id>
		</entry>
</feed>
