<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — modify function set_sql]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=2089&amp;type=atom" />
	<updated>2011-05-20T19:40:43Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=2089</id>
		<entry>
			<title type="html"><![CDATA[Re: modify function set_sql]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=9203#p9203" />
			<content type="html"><![CDATA[<p>hello Janusz!! This gave solution to my problem, single step as a parameter, the query for the count to include/db_pager.inc</p><br /><p>include/db_pager.inc line 59<br /> &nbsp; &nbsp; var $sql_count;&nbsp; &nbsp;// sql count for complex sql query.&nbsp; Add AuraE</p><p>include/db_pager.inc line&nbsp; 305<br />&nbsp; &nbsp; function _init() <br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; global $go_debug;<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;if ($this-&gt;ready == false ) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($this-&gt;sql_count == null)&nbsp; &nbsp;//add AuraE<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $sql = $this-&gt;_sql_gen(true);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $sql = $this-&gt;sql_count;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result = db_query($sql, &#039;Error reading record set&#039;);</p><p>include/db_pager.inc line 454<br />function &amp;new_db_pager($name, $sql, $coldef, $table = null, $key = null, $page_len = 0, $sql_count= null) //add AuraE<br />{</p><p>&nbsp; &nbsp; if (isset($_SESSION[$name]) &amp;&amp;<br />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; ($_SERVER[&#039;REQUEST_METHOD&#039;] == &#039;GET&#039; || $_SESSION[$name]-&gt;sql != $sql)) {<br />&nbsp; &nbsp; &nbsp; &nbsp; unset($_SESSION[$name]); // kill pager if sql has changed<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; if (!isset($_SESSION[$name])) {<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;$_SESSION[$name] = new db_pager($sql, $name, $table, $page_len);<br />&nbsp; &nbsp; &nbsp; &nbsp; $_SESSION[$name]-&gt;main_tbl = $table;<br />&nbsp; &nbsp; &nbsp; &nbsp; $_SESSION[$name]-&gt;key = $key;<br />&nbsp; &nbsp; &nbsp; &nbsp; $_SESSION[$name]-&gt;set_sql($sql);<br />&nbsp; &nbsp; &nbsp; &nbsp; $_SESSION[$name]-&gt;set_columns($coldef);<br />&nbsp; &nbsp; &nbsp; &nbsp; $_SESSION[$name]-&gt;sql_count = $sql_count;&nbsp; &nbsp;//add AuraE<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; return&nbsp; $_SESSION[$name];</p><p>}</p><p>//////////////////////<br />My functions are follows:</p><p>+&nbsp; inventory/includes/db/movement_type_db.inc&nbsp; &nbsp;line 87</p><p>function get_stock_movements_type($type, $StockLocation, $BeforeDate, $AfterDate)<br />{<br />&nbsp; &nbsp; $before_date = date2sql($BeforeDate);<br />&nbsp; &nbsp; $after_date = date2sql($AfterDate);&nbsp; <br />&nbsp; &nbsp; $sql = &quot;SELECT sm.type , sm.trans_no, sm.reference, sm.tran_date, sm.person_id,&nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (if (sm.qty &lt;0 || sm.type = &quot;.ST_LOCTRANSFER.&quot;, (<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SELECT ls.location_name<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FROM &quot;.TB_PREF.&quot;stock_moves sms, &quot;.TB_PREF.&quot;locations ls<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHERE sms.loc_code = ls.loc_code<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AND sms.trans_no = sm.trans_no<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AND sms.tran_date = sm.tran_date<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AND sms.qty &lt;0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GROUP BY sms.trans_no), null)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ) as loc_from,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (if (sm.qty &gt;0 || sm.type = &quot;.ST_LOCTRANSFER.&quot;, (<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SELECT ls.location_name<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FROM &quot;.TB_PREF.&quot;stock_moves sms, &quot;.TB_PREF.&quot;locations ls<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHERE sms.loc_code = ls.loc_code<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AND sms.trans_no = sm.trans_no<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AND sms.tran_date = sm.tran_date<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AND sms.qty &gt;0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GROUP BY sms.trans_no), null)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ) as loc_to<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FROM &quot;.TB_PREF.&quot;stock_moves sm<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHERE &quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; if (isset($_POST[&#039;trans_no&#039;]) &amp;&amp; $_POST[&#039;trans_no&#039;] != &quot;&quot;)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; // search orders with number like <br />&nbsp; &nbsp; &nbsp; &nbsp; $number_like = &quot;%&quot;.$_POST[&#039;trans_no&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; sm.trans_no LIKE &quot;.db_escape($number_like);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; } else {<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; sm.tran_date &gt;= &#039;&quot;. $after_date . &quot;&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; AND sm.tran_date &lt;= &#039;&quot; . $before_date . &quot;&#039;&quot;;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; if ($StockLocation != ALL_TEXT)<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; AND sm.loc_code=&quot;.db_escape($StockLocation);<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; if ($type != ALL_TEXT)<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; AND sm.type = &quot;.db_escape($type);<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; $sql.= &quot; GROUP BY sm.trans_no<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ORDER BY sm.tran_date, sm.trans_id&quot;;<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; return $sql;&nbsp; &nbsp; &nbsp; &nbsp; <br />}</p><p>function get_stock_movements_type_count($type, $StockLocation, $BeforeDate, $AfterDate)<br />{<br />&nbsp; &nbsp; $before_date = date2sql($BeforeDate);<br />&nbsp; &nbsp; $after_date = date2sql($AfterDate); <br />&nbsp; &nbsp; $sql = &quot;SELECT COUNT(DISTINCT sm.trans_no)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FROM &quot;.TB_PREF.&quot;stock_moves sm<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHERE &quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; if (isset($_POST[&#039;trans_no&#039;]) &amp;&amp; $_POST[&#039;trans_no&#039;] != &quot;&quot;)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; // search orders with number like <br />&nbsp; &nbsp; &nbsp; &nbsp; $number_like = &quot;%&quot;.$_POST[&#039;trans_no&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; sm.trans_no LIKE &quot;.db_escape($number_like);<br />&nbsp; &nbsp; } else {<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; sm.tran_date &gt;= &#039;&quot;. $after_date . &quot;&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; AND sm.tran_date &lt;= &#039;&quot; . $before_date . &quot;&#039;&quot;;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; if ($StockLocation != ALL_TEXT)<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; AND sm.loc_code=&quot;.db_escape($StockLocation);<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; if ($type != ALL_TEXT)<br />&nbsp; &nbsp; &nbsp; &nbsp; $sql .= &quot; AND sm.type = &quot;.db_escape($type);<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; return $sql;&nbsp; &nbsp; &nbsp; &nbsp; <br />}</p><p>//////////////////////////////////////////<br />My file:<br />+&nbsp; inventory/inquiry/stock_movements_type.php</p><p>&lt;?php<br />/**********************************************************************<br />&nbsp; &nbsp; Copyright (C) FrontAccounting, LLC.<br />&nbsp; &nbsp; Released under the terms of the GNU General Public License, GPL, <br />&nbsp; &nbsp; as published by the Free Software Foundation, either version 3 <br />&nbsp; &nbsp; of the License, or (at your option) any later version.<br />&nbsp; &nbsp; This program is distributed in the hope that it will be useful,<br />&nbsp; &nbsp; but WITHOUT ANY WARRANTY; without even the implied warranty of<br />&nbsp; &nbsp; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&nbsp; <br />&nbsp; &nbsp; See the License here &lt;http://www.gnu.org/licenses/gpl-3.0.html&gt;.<br />***********************************************************************/<br />$page_security = &#039;SA_ITEMSTRANSVIEW&#039;;<br />$path_to_root=&quot;../..&quot;;<br />include($path_to_root . &quot;/includes/db_pager.inc&quot;);<br />include($path_to_root . &quot;/includes/session.inc&quot;);</p><p>include($path_to_root . &quot;/inventory/includes/stock_transfers_ui.inc&quot;);<br />include_once($path_to_root . &quot;/reporting/includes/reporting.inc&quot;);<br />$js = &quot;&quot;;<br />if ($use_popup_windows)<br />&nbsp; &nbsp; $js .= get_js_open_window(900, 500);<br />if ($use_date_picker)<br />&nbsp; &nbsp; $js .= get_js_date_picker();<br />page(_($help_context = &quot;Inventory Movement Type&quot;), false, false, &quot;&quot;, $js);</p><p>if (isset($_GET[&#039;trans_no&#039;]))<br />{<br />&nbsp; &nbsp; $trans_no = $_GET[&#039;trans_no&#039;];<br />}</p><p>//-----------------------------------------------------------------------------------<br />// Ajax updates<br />//<br />if (get_post(&#039;SearchStockMovesTrans&#039;)) <br />{<br />&nbsp; &nbsp; $Ajax-&gt;activate(&#039;trans_tbl&#039;);<br />} </p><p>if (get_post(&#039;_trans_no_changed&#039;)) // enable/disable selection controls<br />{<br />&nbsp; &nbsp; $disable = get_post(&#039;trans_no&#039;) !== &#039;&#039;;</p><p>&nbsp; &nbsp; $Ajax-&gt;addDisable(true, &#039;OrdersAfterDate&#039;, $disable);<br />&nbsp; &nbsp; $Ajax-&gt;addDisable(true, &#039;OrdersToDate&#039;, $disable);</p><p>&nbsp; &nbsp; $Ajax-&gt;addDisable(true, &#039;StockLocation&#039;, $disable);<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; if ($disable) <br />&nbsp; &nbsp; &nbsp; &nbsp; $Ajax-&gt;addFocus(true, &#039;trans_no&#039;);</p><p>&nbsp; &nbsp; $Ajax-&gt;activate(&#039;trans_tbl&#039;);<br />}<br />//---------------------------------------------------------------------------------------------</p><p>start_form();</p><p>start_table(TABLESTYLE_NOBORDER);<br />start_row();<br />ref_cells(_(&quot;#:&quot;), &#039;trans_no&#039;, &#039;&#039;,null, &#039;&#039;, true);</p><p>date_cells(_(&quot;from:&quot;), &#039;OrdersAfterDate&#039;, &#039;&#039;, null, -30);<br />date_cells(_(&quot;to:&quot;), &#039;OrdersToDate&#039;);</p><p>locations_list_cells(_(&quot;into location:&quot;), &#039;StockLocation&#039;, null, true);<br />end_row();<br />end_table();</p><p>start_table(TABLESTYLE_NOBORDER);<br />start_row();</p><p>if (!isset($_POST[&#039;filterType&#039;]))<br />&nbsp; &nbsp; $_POST[&#039;filterType&#039;] = 0;</p><p>stock_moves_list_cells(null, &#039;filterType&#039;, $_POST[&#039;filterType&#039;], true);&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; <br />submit_cells(&#039;SearchStockMovesTrans&#039;, _(&quot;Search&quot;),&#039;&#039;,_(&#039;Select documents&#039;), &#039;default&#039;);<br />end_row();<br />end_table(1);<br />//---------------------------------------------------------------------------------------------</p><p>function trans_view($trans)<br />{<br />&nbsp; &nbsp; return get_trans_view_str($trans[&quot;type&quot;], $trans[&quot;trans_no&quot;]);<br />}</p><p>function systype_name($dummy, $type)<br />{<br />&nbsp; &nbsp; global $systypes_array;</p><p>&nbsp; &nbsp; return $systypes_array[$type];<br />}</p><p>function person_id($row)<br />{<br />&nbsp; &nbsp; if (($row[&quot;type&quot;] == ST_CUSTDELIVERY) || ($row[&quot;type&quot;] == ST_CUSTCREDIT))<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; $cust_row = get_customer_details_from_trans($row[&quot;type&quot;], $row[&quot;trans_no&quot;]);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; if (strlen($cust_row[&#039;name&#039;]) &gt; 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $person = $cust_row[&#039;name&#039;] . &quot; (&quot; . $cust_row[&#039;br_name&#039;] . &quot;)&quot;;</p><p>&nbsp; &nbsp; }<br />&nbsp; &nbsp; elseif ($row[&quot;type&quot;] == ST_LOCTRANSFER || $row[&quot;type&quot;] == ST_INVADJUST)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; // get the adjustment type<br />&nbsp; &nbsp; &nbsp; &nbsp; $movement_type = get_movement_type($row[&quot;person_id&quot;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; $person = $movement_type[&quot;name&quot;];<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; return $person;<br />}</p><p>//---------------------------------------------------------------------------------------------</p><p>&nbsp; &nbsp; $sql = get_stock_movements_type_first($_POST[&#039;filterType&#039;], $_POST[&#039;StockLocation&#039;], $_POST[&#039;OrdersToDate&#039;],$_POST[&#039;OrdersAfterDate&#039;]);<br />&nbsp; &nbsp; $sql_count = get_stock_movements_type_first_count($_POST[&#039;filterType&#039;], $_POST[&#039;StockLocation&#039;], $_POST[&#039;OrdersToDate&#039;],$_POST[&#039;OrdersAfterDate&#039;]);</p><p>$cols = array(<br />&nbsp; &nbsp; &nbsp; &nbsp; _(&quot;Type&quot;) =&gt; array(&#039;fun&#039;=&gt;&#039;systype_name&#039;, &#039;ord&#039;=&gt;&#039;&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; _(&quot;#&quot;) =&gt; array(&#039;fun&#039;=&gt;&#039;trans_view&#039;, &#039;ord&#039;=&gt;&#039;&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; _(&quot;Reference&quot;), <br />&nbsp; &nbsp; &nbsp; &nbsp; _(&quot;Date&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; _(&quot;Detail&quot;)=&gt; array(&#039;fun&#039;=&gt;&#039;person_id&#039;, &#039;ord&#039;=&gt;&#039;&#039;),<br />&nbsp; &nbsp; &nbsp; &nbsp; _(&quot;Location From&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; _(&quot;Location to&quot;)<br />);</p><p>//---------------------------------------------------------------------------------------------------</p><p>$table =&amp; new_db_pager(&#039;trans_tbl&#039;, $sql, $cols, null, null, 0, $sql_count);</p><p>$table-&gt;width = &quot;80%&quot;;</p><p>display_db_pager($table);</p><p>end_form();<br />end_page();<br />?&gt;</p><p>//////////////////////////////<br />the function stock_moves_list_cells</p><p>+ includes/ui/ui_list.inc&nbsp; line 2456<br />function stock_moves_list_cells($label, $name, $selected=null)<br />{<br />&nbsp; &nbsp; global $all_items;</p><p>&nbsp; &nbsp; if ($label != null)<br />&nbsp; &nbsp; &nbsp; &nbsp; label_cell($label);<br />&nbsp; &nbsp; echo &quot;&lt;td&gt;\n&quot;;<br />&nbsp; &nbsp; $allocs = array( <br />&nbsp; &nbsp; &nbsp; &nbsp; $all_items=&gt;_(&quot;All Types&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; ST_CUSTCREDIT =&gt; _(&quot;Credit Notes&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; ST_CUSTDELIVERY =&gt; _(&quot;Delivery Notes&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; ST_LOCTRANSFER =&gt; _(&quot;Location Transfer&quot;),<br />&nbsp; &nbsp; &nbsp; &nbsp; ST_INVADJUST =&gt; _(&quot;Inventory Adjustment&quot;)<br />&nbsp; &nbsp; );<br />&nbsp; &nbsp; echo array_selector($name, $selected, $allocs);<br />&nbsp; &nbsp; echo &quot;&lt;/td&gt;\n&quot;;<br />}</p><p>///////////////////////////////////////////////<br />I hope to help<br />Regards, AuraE</p>]]></content>
			<author>
				<name><![CDATA[mosha3D]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=1910</uri>
			</author>
			<updated>2011-05-20T19:40:43Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=9203#p9203</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: modify function set_sql]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=9127#p9127" />
			<content type="html"><![CDATA[<p>Unfortunatelly the sql processing in paging class is not bulletproof, and fails in this case. You will have to experiment with the class code to find solution. If you will find something better, please send the code to be integrated in FA.<br />Janusz</p>]]></content>
			<author>
				<name><![CDATA[itronics]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=89</uri>
			</author>
			<updated>2011-05-16T08:58:52Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=9127#p9127</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[modify function set_sql]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=9093#p9093" />
			<content type="html"><![CDATA[<p>I need a query like this:</p><p>SELECT sm.type , sm.trans_no, sm.reference, sm.tran_date, sm.person_id,&nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (if (sm.qty &lt;0 || sm.type = 16, (<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; select ls.location_name<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; FROM 0_stock_moves sms, 0_locations ls<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;WHERE (sms.loc_code = ls.loc_code<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AND sms.trans_no = sm.trans_no<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AND sms.tran_date = sm.tran_date<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AND sms.qty &lt;0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ) GROUP BY sms.trans_no), null)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ) as loc_from,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (if (sm.qty &gt;0 || sm.type = 16, (<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; select ls.location_name<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; from 0_stock_moves sms, 0_locations ls<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; where sms.loc_code = ls.loc_code<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AND sms.trans_no = sm.trans_no<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AND sms.tran_date = sm.tran_date<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AND sms.qty &gt;0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; group by sms.trans_no), null)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ) as loc_to<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FROM 0_stock_moves sm, 0_locations l<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHERE sm.loc_code = l.loc_code AND sm.tran_date &gt;= &#039;2010-01-01&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AND sm.tran_date &lt;= &#039;2011-05-10&#039;&nbsp; GROUP BY sm.trans_no<br />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; ORDER BY sm.tran_date, sm.trans_id </p><p>but is divided&nbsp; incorrectly by function set_sql of db_pager.inc, as there are more than one GROUP. </p><p>Any suggestions?</p><p>is to&nbsp; create a report of all transactions affecting stock_moves by trans_no, and show&nbsp; locations affected (location from and location to)</p><p>Thanks and sorry for my English!!</p>]]></content>
			<author>
				<name><![CDATA[mosha3D]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=1910</uri>
			</author>
			<updated>2011-05-12T19:02:05Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=9093#p9093</id>
		</entry>
</feed>
