| Server IP : 208.122.213.31 / Your IP : 216.73.216.185 Web Server : Apache System : Linux msd6191.mjhst.com 4.18.0-553.137.1.el8_10.x86_64 #1 SMP Wed Jun 24 11:40:24 UTC 2026 x86_64 User : WHMCS_MIA_382 ( 1001) PHP Version : 7.4.33 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/httpd/html/store.tiacyrusxxx.com/public_html/xfcadmin/ |
Upload File : |
<?php
include ('adm.config.php');
$payout = 0;
//Set date to fetch
$getDay = date('j');
$getMonth = date('m');
$getYear = date('Y');
if($getDay < 15) {
$invoiceDate = $getMonth . '-01-' . $getYear;
$invoiceDateSQL = "'" . $getYear . "-" . ($getMonth-1) . "-" . cal_days_in_month(CAL_GREGORIAN, ($getMonth-1) ,2005) . "'";
$invoiceStartDateSQL = "'" . $getYear . "-" . ($getMonth-1) . "-16'";
} else {
$invoiceDate = $getMonth . '-16-' . $getYear;
$invoiceDateSQL = "'" . $getYear . "-" . $getMonth . "-15'";
$invoiceStartDateSQL = "'" . $getYear . "-" . ($getMonth) . "-01'";
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if(isset($_POST['confirmInvoices']) && $_POST['confirmInvoices'] == 1) {
$getModels = @mysql_query("SELECT * FROM cms_models ORDER BY name ASC");
if(@mysql_num_rows($getModels) > 0) {
while ($model = mysql_fetch_object($getModels)) {
$getResults = purchasedItems(1,$model->model_id, -1, $invoiceDateSQL, "payable", 0, 1, 999, 0);
if($getResults != 0) {
$modelAmount = 0;
$invoiceAmount = 0;
$createInvoice = @mysql_query("INSERT INTO cms_billing_purchases_invoices SET invoiceDate = " . $invoiceDateSQL . ", modelID = '" . $model->model_id . "'");
$invoiceID = @mysql_insert_id();
foreach($getResults AS $row) {
$modelPay = round($row->itemPrice*$model->payPercentage/100,2);
if($row->itemType < 3) {
if($row->pay_type == 1) {
$modelPay = round($row->itemPrice * $model->revsharePercentage/100,2);
}
}
$modelAmount += $modelPay;
$invoiceAmount += $row->itemPrice;
$updateInvoice = @mysql_query("UPDATE cms_billing_purchases SET status = '2', invoiceID = '".$invoiceID."', modelAmount = '".$modelPay."' WHERE purchaseID = '".$row->purchaseID."'");
}
$updateInvoice = @mysql_query("UPDATE cms_billing_purchases_invoices SET invoiceAmount = '" . $invoiceAmount . "', modelAmount = '" . $modelAmount . "' WHERE invoiceID = '".$invoiceID."'");
}
}
}
}
header('Location: adm.accounting.php');
die();
}
include ('adm.header.php');
echo '<h1>INVOICES TO GENERATE (UP TO '.$invoiceDate.')</h1>';
$getModels = @mysql_query("SELECT * FROM cms_models ORDER BY name ASC");
if(@mysql_num_rows($getModels) > 0) {
while ($model = mysql_fetch_object($getModels)) {
$getResults = purchasedItems(1,$model->model_id, -1, $invoiceDateSQL, "payable", 0, 1, 999, 0, $invoiceStartDateSQL);
if($getResults != 0) {
$invoiceAmount = 0;
$modelAmount = 0;
?>
<h3><?php echo $model->name; ?></h3>
<table class="table table-bordered table-hover table-condensed">
<thead>
<tr>
<th class="col-md-1">ID#</th>
<th class="col-md-1">Date</th>
<th class="col-md-1">Status</th>
<th class="col-md-1">Price</th>
<th class="col-md-1">Pay Type</th>
<th class="col-md-1">Model Pay</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<?php
foreach($getResults AS $row) {
$payout = 1;
$payType = "MODEL %" . $model->payPercentage;
$modelPay = round($row->itemPrice*$model->payPercentage/100,2);
if($row->itemType < 3) {
if($row->pay_type == 1) {
$payType = "SHARE %" . $model->revsharePercentage;
$modelPay = round($row->itemPrice * $model->revsharePercentage/100,2);
}
}
$modelAmount += $modelPay;
$invoiceAmount += $row->itemPrice;
?>
<tr>
<td><?php echo $row->purchaseID;//$row->transactionID; ?></td>
<td><?php echo $row->purchaseDate; ?></td>
<td><?php echo $row->status; ?></td>
<td>$<?php echo $row->itemPrice; ?></td>
<td><?php echo $payType; ?></td>
<td>$<?php echo $modelPay; ?></td>
<td><?php echo $row->title; ?></td>
</tr>
<?php } ?>
<tr><td></td></tr>
<tr class="info">
<td></td>
<td></td>
<td>TOTAL:</td>
<td><h5>$<?php echo $invoiceAmount; ?></h5></td>
<td>MODEL:</td>
<td><h5>$<?php echo $modelAmount; ?></h5></td>
<td></td>
</tr>
</tbody>
</table>
<?php
}
} // END MODEL LOOP
$getInvoices = @mysql_query("SELECT invoiceID FROM cms_billing_purchases_invoices WHERE invoiceDate = ".$invoiceDateSQL."");
if(@mysql_num_rows($getInvoices) == 0 && $payout == 1) {
?>
<h1>CONFIRM GENERATION:</h1>
<form action="adm.accounting.generate.php" method="POST" class="form-horizontal">
<div class="form-group">
<label class="col-lg-2 control-label">CONFIRM:</label>
<div class="col-lg-3">
<select class="form-control" name="confirmInvoices">
<option value="0"> --- </option>
<option value="1">CONFIRMED</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default"> GENERATE </button>
</div>
</div>
<?php
} else {
echo '<h1>THERE ARE NO INVOICES TO GENERATE!</h1>';
}
}
include ('adm.footer.php');
?>