<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — attachments file view]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=4547</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=4547&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in attachments file view.]]></description>
		<lastBuildDate>Sat, 21 Dec 2013 03:04:02 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: attachments file view]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=18778#p18778</link>
			<description><![CDATA[<p>Thanks Joe - fixed in this <a href="http://devel.frontaccounting.com/git/?p=fa-stable.git;a=blobdiff;f=admin/db/fiscalyears_db.inc;h=29e826dc2cfde0cd65ca1ee835176a3551ae2d7f;hp=c605c064d2b0aae5bd7abdf9d541ea1f304f99ee;hb=1f0c0dd5711510de8fb1d405d15a380def6e818e;hpb=bb6b2a6f6e61aa7e1da0ce31de36b34e6fbdf64e">commit</a>.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Sat, 21 Dec 2013 03:04:02 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=18778#p18778</guid>
		</item>
		<item>
			<title><![CDATA[Re: attachments file view]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=18717#p18717</link>
			<description><![CDATA[<p>Ok, sorry apmuthu, I will fix this. Thanks.</p><p>/Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Tue, 10 Dec 2013 07:11:31 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=18717#p18717</guid>
		</item>
		<item>
			<title><![CDATA[Re: attachments file view]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=18710#p18710</link>
			<description><![CDATA[<p>My last post is not a new function but a rehash of the existing function to avoid redundant passes.</p><p>The diff patch for the latest Hg is:<br /></p><div class="codebox"><pre><code>--- old/admin/db/fiscalyears_db.inc    Wed Nov 06 16:43:56 2013
+++ new/admin/db/fiscalyears_db.inc    Tue Dec 10 08:53:50 2013
@@ -190,11 +190,15 @@
     
     $sql = &quot;SELECT * FROM &quot;.TB_PREF.&quot;attachments WHERE type_no = $type_no AND trans_no = $trans_no&quot;;
     $result = db_query($sql, &quot;Could not retrieve attachments&quot;);
+    $delflag = false;
     while ($row = db_fetch($result))
     {
+        $delflag = true;
         $dir =  company_path(). &quot;/attachments&quot;;
         if (file_exists($dir.&quot;/&quot;.$row[&#039;unique_name&#039;]))
             unlink($dir.&quot;/&quot;.$row[&#039;unique_name&#039;]);
+    }
+    if ($delflag) {
         $sql = &quot;DELETE FROM &quot;.TB_PREF.&quot;attachments WHERE  type_no = $type_no AND trans_no = $trans_no&quot;;
         db_query($sql, &quot;Could not delete attachment&quot;);
     }    </code></pre></div>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Tue, 10 Dec 2013 03:28:59 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=18710#p18710</guid>
		</item>
		<item>
			<title><![CDATA[Re: attachments file view]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=18701#p18701</link>
			<description><![CDATA[<p>I don&#039;t Think this is necessaey, apmuthu.</p><p>We have a 2 liners to fix the deletetion in fiscal year, and really, it is not necessary to make another function to replace this.</p><p>/Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Sun, 08 Dec 2013 22:54:32 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=18701#p18701</guid>
		</item>
		<item>
			<title><![CDATA[Re: attachments file view]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=18695#p18695</link>
			<description><![CDATA[<p>Line 193 in <strong>admin/db/fiscalyears_db.inc</strong> :<br /></p><div class="codebox"><pre><code>while ($row = db_fetch($result))</code></pre></div><p>will make sure that all pertinent ids will be deleted one at a time, but in the existing code, all pertinent ids will get deleted in the first pass and then be redundantly executed thereafter.</p><p>To truly benefit from a single pass deletion, the function would have to be structured thus:<br /></p><div class="codebox"><pre><code>function delete_attachments_and_comments($type_no, $trans_no)
{
    
    $sql = &quot;SELECT * FROM &quot;.TB_PREF.&quot;attachments WHERE type_no = $type_no AND trans_no = $trans_no&quot;;
    $result = db_query($sql, &quot;Could not retrieve attachments&quot;);
    $delflag = false;
    while ($row = db_fetch($result))
    {
        $delflag = true;
        $dir =  company_path(). &quot;/attachments&quot;;
        if (file_exists($dir.&quot;/&quot;.$row[&#039;unique_name&#039;]))
            unlink($dir.&quot;/&quot;.$row[&#039;unique_name&#039;]);
    }
    if ($delflag) {
        $sql = &quot;DELETE FROM &quot;.TB_PREF.&quot;attachments WHERE  type_no = $type_no AND trans_no = $trans_no&quot;;
        db_query($sql, &quot;Could not delete attachment&quot;);
    }
    $sql = &quot;DELETE FROM &quot;.TB_PREF.&quot;comments WHERE  type = $type_no AND id = $trans_no&quot;;
    db_query($sql, &quot;Could not delete comments&quot;);
    $sql = &quot;DELETE FROM &quot;.TB_PREF.&quot;refs WHERE  type = $type_no AND id = $trans_no&quot;;
    db_query($sql, &quot;Could not delete refs&quot;);
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Sun, 08 Dec 2013 09:51:14 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=18695#p18695</guid>
		</item>
		<item>
			<title><![CDATA[Re: attachments file view]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=18667#p18667</link>
			<description><![CDATA[<p>This has been fixed and is available at the stable repository. You can also download the files here and replace them.</p><p><a href="http://https:/sourceforge.net/p/frontaccounting/mercurial/ci/default/tree/includes/ui/ui_controls.inc">ui_controls.inc</a><br /><a href="http://https:/sourceforge.net/p/frontaccounting/mercurial/ci/default/tree/admin/db/attachments_db.inc">attachments_db.inc</a></p><p>Regarding the deletion in fiscal years, then it could not be used. The function only deletes one id, we need to delete all attachment to a specific document type.</p><p>/Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Wed, 04 Dec 2013 10:46:54 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=18667#p18667</guid>
		</item>
		<item>
			<title><![CDATA[Re: attachments file view]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=18547#p18547</link>
			<description><![CDATA[<p>This is a useful addition to the FA core. Hope Joe/Janusz add it.</p><p>Also since the <strong>function delete_attachment($id) </strong> is available in the said file <strong>admin/db/attachments_db.inc</strong>, it can be used in <strong>admin/db/fiscalyears_db.inc</strong> to replace lines 198-199 in <strong>function delete_attachments_and_comments()</strong>:<br /></p><div class="codebox"><pre><code>        $sql = &quot;DELETE FROM &quot;.TB_PREF.&quot;attachments WHERE  type_no = $type_no AND trans_no = $trans_no&quot;;
        db_query($sql, &quot;Could not delete attachment&quot;);</code></pre></div><p>with<br /></p><div class="codebox"><pre><code>        delete_attachment($row[&#039;id&#039;]);</code></pre></div><p>provided the file <strong>admin/db/attachments_db.inc</strong> has been included beforehand.</p><p>Furthermore, the error strings in <strong>admin/db/attachments_db.inc</strong> need to get into the translation files (*.po/*.mo) as well.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Sun, 24 Nov 2013 12:19:18 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=18547#p18547</guid>
		</item>
		<item>
			<title><![CDATA[attachments file view]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=18538#p18538</link>
			<description><![CDATA[<p>the attach file view options it&#039;s not complete. If you attach 2 or more files the function will only output the last one from the array, and will only display that you have one file attached to your order/invoice/dispatch.... etc</p><p>so here my add </p><p>in attachment_db.inc i added this function:<br /> </p><div class="codebox"><pre><code> 

function get_attachment_string($type, $id)
{
global $path_to_root;
    $str_return = &quot;&quot;;    
    $sql = &quot;SELECT * FROM &quot;.TB_PREF.&quot;attachments WHERE type_no=&quot;.db_escape($type).&quot; AND trans_no=&quot;.db_escape($id).&quot; ORDER BY trans_no&quot;;
    $return = db_query($sql, &quot;Could not retrieve attachments&quot;);
    while ($attachment = db_fetch($return))
    {
        if (strlen($str_return))
            $str_return = $str_return . &quot; \n&quot;;    
            $str_return .= &quot;&lt;br/&gt;&quot;;
        $str_return = $str_return . &quot; - Attached File: &lt;a href=&#039;$path_to_root/admin/attachments.php?vw=&quot;.$attachment[&quot;id&quot;].&quot; &#039; target=&#039;blanc_&#039;&gt;ID: &quot;. $attachment[&quot;id&quot;] . &quot; Description &quot;. $attachment[&quot;description&quot;]. &quot; - &quot;. $attachment[&quot;filename&quot;].&quot;&lt;/a&gt;&quot;;
    }
    return $str_return;
}</code></pre></div><p>in ui_controls.inc line 179 just after $id = has_attachment($type_no, $trans_no); add</p><div class="codebox"><pre><code> 

    $attach = get_attachment_string($type_no, $trans_no);
    echo $attach;</code></pre></div><p>FA team: the above function needs a bit styling but for now this will do the job.</p>]]></description>
			<author><![CDATA[null@example.com (cristiart)]]></author>
			<pubDate>Sat, 23 Nov 2013 16:56:03 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=18538#p18538</guid>
		</item>
	</channel>
</rss>
