{"id":648,"date":"2013-10-13T12:26:18","date_gmt":"2013-10-13T03:26:18","guid":{"rendered":"http:\/\/www.sambuichi.jp\/?p=648"},"modified":"2014-07-25T10:25:05","modified_gmt":"2014-07-25T01:25:05","slug":"xbrl-gl%e9%96%b2%e8%a6%a7%e3%82%b5%e3%83%bc%e3%83%93%e3%82%b9%e8%a9%a6%e4%bd%9c33","status":"publish","type":"post","link":"https:\/\/www.sambuichi.jp\/?p=648&lang=en","title":{"rendered":"XBRL GL instance viewing service[Prototype](3\/3)"},"content":{"rendered":"<p>Views: 119<\/p><h1>Viewing XBRL GL instance by period and\/or account number<\/h1>\n<p>Three steps<br \/>\n\uff08\uff11\uff09A browser side javascript program calls PHP program at server side to process request based on period and\/or account number passed with an arguments of jQuery&#8217;s ajax.<br \/>\n\uff08\uff12\uff09A PHP program generate a query based on arguments and generate &lt;table&gt; then returns generated page to the browser.<br \/>\n\uff08\uff13\uff09A web browser displays a result from the server.<br \/>\n<!--more--><\/p>\n<h2>jQuery&#8217;s ajax call to start PHP program<\/h2>\n<p>&lt;select&gt; element for specify period and\/or account number and\u00a0&lt;button&gt; element with\u00a0id=&#8221;jQbutton&#8221; are defined here.<\/p>\n<p>Returned result will be\u00a0\u00a0populated inside of this &lt;div&gt;.<\/p>\n<p><span class=\"small\">[html]<\/span><\/p>\n<div class=\"codex\">\n<pre><code>&lt;div id=\"jQ\"&gt;\r\n        &lt;select name=\"period\" id=\"period\"&gt;\r\n                &lt;option value=\"\" style=\"font-size: x-large\"&gt;Select period ...&lt;\/option&gt;\r\n                &lt;option value=\"2009-04\" style=\"font-size: x-large\"&gt;2009-04&lt;\/option&gt;\r\n                  \u2026 \u2026\r\n        &lt;\/select&gt;\r\n        &lt;select name=\"account\" id=\"account\"\u3000style=\"font-size: x-large\"&gt;\r\n                &lt;option value=\"\"&gt;Select account ...&lt;\/option&gt;\r\n                &lt;option value=\"111\"&gt;Cash&lt;\/option&gt;\r\n                  \u2026 \u2026\r\n        &lt;\/select&gt;\r\n    &lt;button id=\"jQbutton\"\u3000style=\"font-size: x-large\"&gt;Find&lt;\/button&gt;\r\n    &lt;p&gt;\r\n        &lt;span id=\"jQtextStatus\"&gt;&lt;\/span&gt;\r\n    &lt;\/p&gt;\r\n    &lt;div id=\"jQajax\"&gt;&lt;\/div&gt;\r\n&lt;\/div&gt;<\/code><\/pre>\n<\/div>\n<p>We define procedure for clicking a button with $(&#8216;#jQbutton&#8217;).on(&#8220;click&#8221;, function() {\u3000})<br \/>\n$period, $account variables are defined based on &lt;select&gt; and calls glList.php with ajax.<br \/>\nresulting &lt;table&gt; are populated with $(&#8216;#jQajax&#8217;).html(data).<\/p>\n<p><span class=\"small\">[javascript]<\/span><\/p>\n<div class=\"codex\">\n<pre><code>&lt;script&gt;\r\n    $(function() {\r\n        $('#jQbutton').on(\"click\",\r\n                function() {\r\n                    $periodList = $(\"select#period\");\r\n                    $period = $(\"option:selected\", $periodList).val();\r\n                    $accountList = $(\"select#account\");\r\n                    $account = $(\"option:selected\", $accountList).val();\r\n                    $.ajax({\r\n                        url : 'glList.php',\r\n                        data : {\r\n                            period : $period,\r\n                            account : $account\r\n                        },\r\n                        success : function(data) {\r\n                            $('#jQajax').html(data);\r\n                        },\r\n                        error : function(data) {\r\n                            $('#jQtextStatus').text('\u30a8\u30e9\u30fc\uff01');\r\n                        }\r\n                    });\r\n                }\r\n        );\r\n    });\r\n&lt;\/script&gt;<\/code><\/pre>\n<\/div>\n<h2>Query by condition and display this result<\/h2>\n<p><span class=\"small\">[php]Define SQL and execute query<\/span><\/p>\n<div class=\"codex\">\n<pre><code>$sql = \"SELECT postingdate,entrynumber,detailcomment,\";\r\n    $sql .= \"CASE debitcreditcode WHEN 'debit' \";\r\n    $sql .= \"THEN accountmaindescription ELSE '' END AS account_d, \";\r\n    $sql .= \"CASE debitcreditcode WHEN 'credit' \";\r\n    $sql .= \"THEN accountmaindescription ELSE '' END AS account_c,\";\r\n    $sql .= \"CASE debitcreditcode WHEN 'debit' \";\r\n    $sql .= \"THEN amount ELSE '' END AS debit,\";\r\n    $sql .= \"CASE debitcreditcode WHEN 'credit' \";\r\n    $sql .= \"THEN amount ELSE '' END AS credit \";\r\n    $sql .= \"FROM entryheaders h, entrydetails d \";\r\n    $sql .= \"WHERE \";\r\n    $sql .= \"entryHeadersID = h.id \";\r\n    if ($period)\r\n        $sql .= \"AND postingdate~'\".$period.\"' \";\r\n    if($account) {\r\n        $sql .= \"AND entryHeadersID IN (\";\r\n        $sql .= \"SELECT entryHeadersID FROM entrydetails WHERE accountmainid='\".$account.\"')\";\r\n    }\r\n    $sql .= \"ORDER BY postingdate,h.id,d.id;\";\r\n    $stmt = $pdo -&gt; query($sql);<\/code><\/pre>\n<\/div>\n<p><span class=\"small\">[php]Picking up resulting value and construct &lt;table&gt; element<\/span><\/p>\n<div class=\"codex\">\n<pre><code>print '&lt;table border=\"1\" cellpadding=\"4\"&gt;';\r\nprint '&lt;tr&gt;\u65e5\u4ed8&lt;\/td&gt;&lt;td&gt;\uff03&lt;\/td&gt;&lt;td&gt;\u6458\u8981&lt;\/td&gt;';\r\nprint '&lt;td&gt;\u501f\u65b9\u79d1\u76ee&lt;\/td&gt;&lt;td&gt;\u8cb8\u65b9\u79d1\u76ee&lt;\/td&gt;&lt;td&gt;\u501f\u65b9&lt;\/td&gt;&lt;td&gt;\u8cb8\u65b9&lt;\/td&gt;&lt;\/tr&gt;';\r\nwhile ($row = $stmt -&gt; fetch(PDO::FETCH_ASSOC)) {\r\n    print \"&lt;tr&gt;\";\r\n    $postingdate = $row['postingdate'];\r\n    print \"&lt;td&gt;\".$postingdate.\"&lt;\/td&gt;\";\r\n    $entrynumber = $row['entrynumber'];\r\n    print \"&lt;td align='right'&gt;\".$entrynumber.\"&lt;\/td&gt;\";\r\n    $detailcomment = $row['detailcomment'];\r\n    print \"&lt;td&gt;\".$detailcomment.\"&lt;\/td&gt;\";\r\n    $account_d = $row['account_d'];\r\n    print \"&lt;td&gt;\".$account_d.\"&lt;\/td&gt;\";\r\n    $account_c = $row['account_c'];\r\n    print \"&lt;td&gt;\".$account_c.\"&lt;\/td&gt;\";\r\n    $debit = $row['debit'];\r\n    if (is_numeric($debit))\r\n        print \"&lt;td align='right'&gt;\".number_format($debit).\"&lt;\/td&gt;\";\r\n    else\r\n        print \"&lt;td&gt;&lt;\/td&gt;\";\r\n    $credit = $row['credit'];\r\n    if (is_numeric($credit))\r\n        print \"&lt;td align='right'&gt;\".number_format($credit).\"&lt;\/td&gt;\";\r\n    else\r\n        print \"&lt;td&gt;&lt;\/td&gt;\";\r\n    print \"&lt;\/tr&gt;\";\r\n}\r\nprint \"&lt;\/table&gt;\";<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Views: 119Viewing XBRL GL instance by period and\/or account number Three steps \uff08\uff11\uff09A browser side javascript pr [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":427,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[17],"tags":[],"_links":{"self":[{"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/posts\/648"}],"collection":[{"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=648"}],"version-history":[{"count":2,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/posts\/648\/revisions"}],"predecessor-version":[{"id":655,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/posts\/648\/revisions\/655"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=\/wp\/v2\/media\/427"}],"wp:attachment":[{"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sambuichi.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}