WIP Contract 2024-06-06
This commit is contained in:
56
scripts/contract/test.php
Normal file
56
scripts/contract/test.php
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
require("../../config/config.php");
|
||||
|
||||
define('FRONKDB_SQLDEBUG',false);
|
||||
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||
|
||||
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
|
||||
|
||||
$me = new User(1);
|
||||
define("INTERNAL_USER_ID", $me->id);
|
||||
|
||||
$cms = 0;
|
||||
$cys = 0;
|
||||
foreach(ContractModel::search(["billing_period" => 1]) as $contract) {
|
||||
$cms += $contract->price;
|
||||
}
|
||||
|
||||
$First = new DateTime("2024-04-10 00:00:00");
|
||||
$Last = new DateTime("2024-05-10 23:59:59");
|
||||
|
||||
foreach(ContractModel::search(["billing_period" => 12]) as $contract) {
|
||||
if($contract->finish_date >= $First->getTimestamp() && $contract->finish_date <= $Last->getTimestamp()) {
|
||||
$cys += $contract->price;
|
||||
}
|
||||
}
|
||||
|
||||
$cts = $cms + $cys;
|
||||
|
||||
echo "Contract Monthly Sum: $cms\n";
|
||||
echo "Contract Yearly Sum: $cys\n";
|
||||
echo "Contract Total Sum: $cts\n";
|
||||
|
||||
|
||||
|
||||
|
||||
$ims = 0;
|
||||
$iys = 0;
|
||||
|
||||
foreach(IvtCustomerProductModel::getAll() as $ivt_contract) {
|
||||
$product = $ivt_contract->product;
|
||||
if($product->interval < 1) {
|
||||
$ims += $product->price;
|
||||
} elseif($product->interval == 1 && $ivt_contract->lastdate == "2023-06-06") {
|
||||
$iys += $product->price;
|
||||
}
|
||||
}
|
||||
|
||||
$its = $ims + $iys;
|
||||
|
||||
echo "IvtContract Monthly Sum: $ims\n";
|
||||
echo "IvtContract Yearly Sum: $iys\n";
|
||||
echo "IvtContract Total Sum: $its\n";
|
||||
Reference in New Issue
Block a user