MMCT TEAM
Server IP : 2a02:4780:3:1493:0:3736:a38e:7  /  Your IP : 216.73.216.139
Web Server : LiteSpeed
System : Linux sg-nme-web1393.main-hosting.eu 4.18.0-553.40.1.lve.el8.x86_64 #1 SMP Wed Feb 12 18:54:57 UTC 2025 x86_64
User : u926327694 ( 926327694)
PHP Version : 7.4.33
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/u926327694/domains/smsoft.in/public_html/demo/accounts/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u926327694/domains/smsoft.in/public_html/demo/accounts/income_exp.php
<?php 

    // First we execute our common code to connection to the database and start the session 
    //  require("../common.php"); 
     session_start();
    // At the top of the page we check to see whether the user is logged in or not 
    if(!isset($_SESSION['user']) && !isset($_SESSION['Mng_User'])) 
    { 
        // If they are not, we redirect them to the login page. 
        header("Location: ../index.php"); 
         
        // Remember that this die statement is absolutely critical.  Without it, 
        // people can view your members-only content without logging in. 
        die("Redirecting to ../index.php"); 
    } 
     
    // Everything below this point in the file is secured by the login system 
     
    // We can display the user's username to them by reading it from the session array.  Remember that because 
    // a username is user submitted content we must use htmlentities on it before displaying it to the user. 

?>

<?php


        
 include "config/config.php";
 
$income_sql_res = "SELECT DISTINCT `Cr_Ledger` FROM `vochers` WHERE `Type` = 'Recipt'";
$expenditure_sql_res = "SELECT DISTINCT `Dr_Ledger` FROM `vochers` WHERE `Type` = 'Payment' ";

//ho "$income_sql_res";

$income_name=array();
$income_amount=array();
$expe_name=array();
$expe_amount=array();
?>


<!DOCTYPE html>
<html lang="en">
<?php 
$title="Income and Expenditure";
?>
<?php  include "html-head.php" ?>


<body>

    




        <!-- Navigation -->
        <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                
                    <h3 style="margin-left: 20px;margin-bottom: 20px;color: Red" href="#"><b><?php include "Name.txt"; ?></b></h3>

            </div>
            <!-- /.navbar-header -->

            
            <!-- /.navbar-top-links -->

            <?php
            include "header.php";
            ?>
            <!-- /.navbar-static-side -->
        </nav>


          <div id="wrapper">
            <div id="page-wrapper">
                <div class="tab-content">
                    <div  class="tab-pane fade in active">
                        <div class="row">
                                <div class="col-lg-12">
                                    <div class="panel panel-default">
                                        <div class="panel-heading">
                                           <center> Income and Expenditure</center>
                                        </div>
                                                 <div class="panel-body">
                                                    <?php 
                            $FromDate=date('Y-m-01', strtotime("now"));
                            $ToDate=date('Y-m-t', strtotime("now"));
                            if(isset($_POST['btnSubmit']))
                            {
                                $FromDate=$_POST['FromDate'];
                                $ToDate=$_POST['ToDate'];
                            }
                            ?>
                            <form action="" method="POST">
                                <div class="row">
                                    <div class="col-lg-3 col-md-3 col-xs-12 col-sm-12">
                                        <div class="form-group">
                                            <label>From Date</label>
                                            <input type="date" name="FromDate" class="form-control" required value="<?php echo $FromDate; ?>" />
                                        </div>
                                    </div>
                                    <div class="col-lg-3 col-md-3 col-xs-12 col-sm-12">
                                        <div class="form-group">
                                            <label>To Date</label>
                                            <input type="date" name="ToDate" class="form-control" required value="<?php echo $ToDate; ?>" />
                                        </div>
                                    </div>
                                    <div class="col-lg-3 col-md-3 col-xs-12 col-sm-12">
                                        <div class="form-group">
                                            <label style="width:100%">&nbsp;</label>
                                            <button type="submit" class="btn btn-primary" name="btnSubmit">Submit</button>
                                        </div>
                                    </div>
                                </div>
                            </form>
 
                                                      
                                                <?php 
                                                $i=0;
                                                    $expenditure_Total="";
                                                    $expenditure_res=mysqli_query($con,$expenditure_sql_res);
                                                    while($expenditure_1=mysqli_fetch_array($expenditure_res))
                                                    {
                                                   //cho "SELECT SUM(Cr_Amount) FROM `vochers` WHERE `Cr_Ledger` = '$expenditure_1[Cr_Ledger]'";
                                                    $expenditure_1_res=mysqli_query($con,
                                                        "SELECT SUM(Dr_Amount) FROM `vochers` 
                                                        WHERE `Dr_Ledger` = '$expenditure_1[Dr_Ledger]' AND (Date between '$FromDate' And '$ToDate')");
                                                            while($expenditure=mysqli_fetch_array($expenditure_1_res))
                                                            {
                                                              $expe_name[$i]=$expenditure_1['Dr_Ledger'];
                                                              $expe_amount[$i]=$expenditure['0'];
                                                                $expenditure_Total+=$expenditure['0'];
                                                            $i++;
                                                            }
                                                    }
                                             
                                                     $i=0;
                                                    $income_Total="";
                                                    $income_res=mysqli_query($con,$income_sql_res);
                                                    while($income_1=mysqli_fetch_array($income_res))
                                                    {
                                                   //cho "SELECT SUM(Cr_Amount) FROM `vochers` WHERE `Cr_Ledger` = '$expenditure_1[Cr_Ledger]'";
                                                    $income_1_res=mysqli_query($con,
                                                        "SELECT SUM(Cr_Amount) FROM `vochers` 
                                                        WHERE `Cr_Ledger` = '$income_1[Cr_Ledger]' AND (Date between '$FromDate' And '$ToDate')");
                                                    while($income=mysqli_fetch_array($income_1_res))
                                                    {
 
                                                        $income_name[$i]=$income_1['Cr_Ledger'];
                                                        $income_amount[$i]=$income['0'];
                                                             $income_Total+=$income['0'];
                                                     $i++;

                                                    }
                                                }
                                                    if(sizeof($income_name) > sizeof($expe_name))
                                                    {
                                                        $size=sizeof($income_name);
                                                    }
                                                    else
                                                     $size=sizeof($expe_name);   
 
                                                    ?>
                             <table width="100%" class="table table-striped table-bordered table-hover" id="example">
                                <thead>
                                 <tr>
                                    <th>Expenditure</th>
                                    <th></th>
                                    <th>Income</th>
                                    <th></th>
                                 </tr>
                             </thead>                
                             <tbody>
                                <?php
                                    for($i=0;$i<$size;$i++)
                                    {
                                        if($expe_amount[$i]!="" || $income_amount[$i]!="")
                                        {
                                    ?>
                                 <tr>
                                    <td>
                                        <?php 
                                        if(array_key_exists($i, $expe_name))
                                        {
                                           echo $expe_name[$i]; 
                                        } 
                                        ?> 
                                     </td>


                                        <td>
                                        <?php 
                                        if(array_key_exists($i, $expe_amount))
                                        {
                                           echo $expe_amount[$i]; 
                                        } 
                                        ?> 
                                     </td>



                                     <td>
                                        <?php 
                                        if(array_key_exists($i, $income_name))
                                        {
                                           echo $income_name[$i]; 
                                        } 
                                        ?> 
                                     </td>



                                     <td>
                                        <?php 
                                        if(array_key_exists($i, $income_amount))
                                        {
                                           echo $income_amount[$i]; 
                                        } 
                                        ?> 
                                     </td>

                                  </tr>
                                 <?php
                                        }
                                    }
                                    ?>
                                    <tr>
                                        <td></td>
                                    <td><b>Total : <?php echo $expenditure_Total; ?></b></td>
                                    <td></td>
                                    <td><b>Total : <?php echo $income_Total; ?></b></td>
                                    </tr>
                                     <?php
                                          $CashInHand=$income_Total-$expenditure_Total;
                                          $Thing2="";
                                          $Thing="";
                              
                                                        


                          
                                                        if($CashInHand > 0)
                                                        {
                                                              $lbl1="(Payments + Closing Balance):";
                                                            $label="Asset : $CashInHand";
                                                        $lbl2= $expenditure_Total. "+". $CashInHand."=";
                                                        $lbl3=$expenditure_Total+$CashInHand;
                                                        $Thing=$lbl1.$lbl2.$lbl3;
                                                        }
                                                        else
                                                        {
                                                              $lbl1="(Recipts + Closing Balance):";
                                                            $label="Liabilirties: $CashInHand";
                                                            $lbl3=$income_Total."+".abs($CashInHand);
                                                            $lbl2=$income_Total+abs($CashInHand);
                                                        
                                                        $Thing2=$lbl1.$lbl3."=".$lbl2;
                                                    }
                        ?>
                                
                              <tr>
                                <td> </td>
                                <td><?php echo "$Thing"; ?> </td>
                                <td> </td>
                                <td><?php echo $Thing2; ?> </td>
                              </tr>
                             </tbody>
                         </table>

</div>
                                    <div class="col-lg-6">
                                        <table width="100%" border="0">
                                            <tr>
            <td align="right"> </td>
                                                           
                                            </tr>
                                        </table>
                                    </div>
                                    <div class="col-lg-6">
                                        <table width="100%" border="0">
                                            <tr>
                                                    <td align="right"></td>        
                                            </tr>
                                  
                                        </table>
                                    </div>
                                </div>
                            </div>
                             </div> 
                         </div>

                                
                            <!-- Form Content Start -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
               <!-- /.ROW -->
     

 
    <!-- /#wrapper -->



<?php  include "html-footer.php" ?>

 </body>

</html>

MMCT - 2023