Commit 40ecc67e authored by Heddi Heryadi's avatar Heddi Heryadi 💪

whmcs report

parent 25001dc2
<?php
mysql_connect("localhost", "root", "") or die("Could not connect: " . mysql_error());
mysql_select_db("devmanage_whmcs");
?>
<?php
$date = isset($_GET["date"]) ? $_GET["date"] : "2019-09-06"; // date("Y-m-d");
$result = mysql_query("SELECT i.*, it.*,
SUBSTRING_INDEX(SUBSTRING_INDEX(it.description, '-', 2), '-', 1) kategori,
IF(LENGTH(SUBSTRING_INDEX(SUBSTRING_INDEX(it.description, '.', -1), ' ', 1)) < 4,
CONCAT(REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX(it.description, '.', 1), ' ', -1), '(', ''), '.',
IF(LENGTH(SUBSTRING_INDEX(SUBSTRING_INDEX(it.description, '.', -1), ' ', 1)) >= 3 || LENGTH(SUBSTRING_INDEX(SUBSTRING_INDEX(it.description, '.', -2), '.', 1)) > 3,
SUBSTRING_INDEX(SUBSTRING_INDEX(it.description, '.', -1), ' ', 1), SUBSTRING_INDEX(SUBSTRING_INDEX(it.description, '.', -2), ' ', 1))), '') domain
FROM devmanage_whmcs.tblinvoices i
LEFT JOIN tblinvoiceitems it ON it.invoiceid = i.id
WHERE i.status = 'PAID' AND DATE(i.datepaid) = '".$date."'
ORDER BY i.datepaid DESC");
$datas = array();
$categories = array();
while ($d = mysql_fetch_array($result)) {
$datas[] = $d;
if(!isset($categories[$d['kategori']][$d['paymentmethod']])) $categories[$d['kategori']][$d['paymentmethod']] = 0;
$categories[$d['kategori']][$d['paymentmethod']] = $categories[$d['kategori']][$d['paymentmethod']] + $d['total'];
}
$qMethod = mysql_query("SELECT paymentmethod FROM tblinvoiceitems group by paymentmethod");
$method = array();
while ($d2 = mysql_fetch_array($qMethod)) {
if($d2['paymentmethod'])
$method[] = $d2['paymentmethod'];
}
// print_r($method);
$no = 1;
?>
<form method="get">
<input name="date" value="<?=$date?>" />
<input type="submit" value="show">
</form>
<table border="1">
<tr>
<th>No</th>
<th>Method</th>
<th>Amount</th>
<th>Category</th>
<th>Sub Category 1</th>
<th>Sub Category 2</th>
<th>IN</th>
<th>OUT</th>
<th>PPN</th>
<th>Harga Modal</th>
</tr>
<?php foreach($datas as $d) { // print_r($row); ?>
<tr>
<td><?=$no?></td>
<td><?=$d["paymentmethod"]?></td>
<td><?=$d["total"]?></td>
<td><?=$d["kategori"]?></td>
<td><?=$d["domain"]?></td>
<td></td>
<td><?=$d["amount"]?></td>
<td></td>
<td></td>
<td></td>
</tr>
<?php $no++; } ?>
</table>
<hr/>
<?php $no=1; ?>
<table border="1">
<tr>
<th>No</th>
<th>Category</th>
<?php foreach($method as $m) { ?>
<th><?=$m?></th>
<?php } ?>
</tr>
<?php foreach($categories as $k => $d) { ?>
<tr>
<td><?=$no?></td>
<td><?=$k?></td>
<?php foreach($method as $m) { ?>
<td><?=isset($d[$m])?$d[$m]:0?></td>
<?php } ?>
</tr>
<?php $no++; } ?>
</table>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment