-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelation_setup.php
55 lines (43 loc) · 1.41 KB
/
relation_setup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
include_once "db/db.php";
error_reporting(E_ALL ^ E_NOTICE);
$from_month = explode( '/', $_POST["from_month"] );
$to_month = explode( '/', $_POST["to_month"] );
$fromMonth = $from_month[1].'-'.$from_month[0];
$toMonth = $to_month[1].'-'.$to_month[0];
$sql = "SELECT sum((sts.`selling_price`*sts.`quantity`) - (std.`company_price` * sts.`quantity`)) as profit, MONTHNAME(STR_TO_DATE(MONTH(sts.`date`), '%m'))
as month FROM `stock_sales` as sts INNER join `stock_details` as std on sts.stock_name = std.stock_name WHERE DATE_FORMAT(sts.`date`, \"%Y-%m\")
<= '$toMonth' AND DATE_FORMAT(sts.`date`, \" % Y -%m\") <= '$fromMonth' GROUP BY MONTH(sts.`date`)";
$query = mysql_query($sql);
?>
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Sl No</th>
<th>Months</th>
<th>Profit</th>
</tr>
</thead>
<tbody>
<?php
$sl = 1;
$gandProfit = 0;
$payment = 10;
while($row = mysql_fetch_array($query)){
?>
<tr>
<td><?php echo $sl;?></td>
<td><?php echo $row['month'];?></td>
<td><?php echo number_format($row['profit'],2);?></td>
</tr>
<?php
$gandProfit +=$row['profit'];
$sl++;
}//while
?>
<tr>
<td colspan="2" style="text-align: right;">Total</td>
<td><?php echo number_format($gandProfit,2);?></td>
</tr>
</tbody>
</table>