webERP Forum

Full Version: How to Show report in 3 months in profit and lost statement
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hallo, how to make report in 3 months so the script can compare between month in profit & lost statement.

i am planning to create a script based on p&l script and modified it looks like this picture below but i dont have any clue..

first, select first month
[Image: 5525_10203336554844172_1867022982_n.jpg]

second, display 3 month start from selected month..
[Image: 1959888_10203336497482738_1911236014_n.jpg]

i have tried to change the sql code to =

Code:
    $fromperiod1 = $_POST['FromPeriod'];
    $fromperiod1 = $fromperiod+1;
    $fromperiod2 = $fromperiod1+1;
    $SQL = "SELECT accountgroups.sectioninaccounts,
                    accountgroups.parentgroupname,
                    accountgroups.groupname,
                    chartdetails.accountcode,
                    chartmaster.accountname,
                    SUM(CASE WHEN chartdetails.period='" . $_POST['FromPeriod']   . "' THEN chartdetails.bfwd                       ELSE 0 END) AS firstprdbfwd,
                    SUM(CASE WHEN chartdetails.period='" . $_POST['FromPeriod']   . "' THEN chartdetails.bfwd + chartdetails.actual ELSE 0 END) AS lastprdcfwd,
                    SUM(CASE WHEN chartdetails.period='" . $fromperiod1           . "' THEN chartdetails.bfwd                       ELSE 0 END) AS firstprdbfwd1,
                    SUM(CASE WHEN chartdetails.period='" . $fromperiod1           . "' THEN chartdetails.bfwd + chartdetails.actual ELSE 0 END) AS lastprdcfwd1,
                    SUM(CASE WHEN chartdetails.period='" . $fromperiod2           . "' THEN chartdetails.bfwd                       ELSE 0 END) AS firstprdbfwd2,
                    SUM(CASE WHEN chartdetails.period='" . $fromperiod2           . "' THEN chartdetails.bfwd + chartdetails.actual ELSE 0 END) AS lastprdcfwd2

            FROM chartmaster
            INNER JOIN accountgroups ON chartmaster.group_ = accountgroups.groupname
            INNER JOIN chartdetails  ON chartmaster.accountcode= chartdetails.accountcode
            WHERE accountgroups.pandl=1
            GROUP BY accountgroups.sectioninaccounts,
                    accountgroups.parentgroupname,
                    accountgroups.groupname,
                    chartdetails.accountcode,
                    chartmaster.accountname
            ORDER BY accountgroups.sectioninaccounts,
                    accountgroups.sequenceintb,
                    accountgroups.groupname,
                    chartdetails.accountcode
the report can work on first month.. but not on second and third..
any one have any idea for this??
Reference URL's