./
This commit is contained in:
@@ -20,20 +20,61 @@ class Crypto extends Main
|
|||||||
|
|
||||||
/** @var MainObject $item */
|
/** @var MainObject $item */
|
||||||
foreach ($all as $item) {
|
foreach ($all as $item) {
|
||||||
if (!in_array($item->getCurrency(), Currency::$currencies)) {
|
|
||||||
if ($item->getValue() == 0) {
|
if ($item->getValue() == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!isset($sum[$item->getCurrency()])) {
|
// if (!isset($sum[$item->getCurrency()])) {
|
||||||
$sum[$item->getCurrency()] = [];
|
// $sum[$item->getCurrency()] = [];
|
||||||
if (!isset($sum[$item->getCurrency()][$item->getDateTime()->format("Y-m-d")])){
|
// if (!isset($sum[$item->getCurrency()][$item->getDateTime()->format("Y-m-d")])){
|
||||||
$sum[$item->getCurrency()][$item->getDateTime()->format("Y-m-d")] = [];
|
// $sum[$item->getCurrency()][$item->getDateTime()->format("Y-m-d")] = [];
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
$sum[$item->getCurrency()][$item->getDateTime()->format("Y-m-d")][] = $item;
|
// $sum[$item->getCurrency()][$item->getDateTime()->format("Y-m-d")][] = $item;
|
||||||
|
$date = $item->getDateTime()->format("Y-m-d");
|
||||||
|
if (!isset($sum[$date])) {
|
||||||
|
$sum[$date] = [];
|
||||||
}
|
}
|
||||||
|
if (!isset($sum[$date][$item->getCurrency()])){
|
||||||
|
$sum[$date][$item->getCurrency()] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sum;
|
$sum[$date][$item->getCurrency()][] = $item;
|
||||||
|
}
|
||||||
|
$test=[];
|
||||||
|
foreach ($sum as $date => $items) {
|
||||||
|
$keys = array_keys($items);
|
||||||
|
$crypto="";
|
||||||
|
$succ=false;
|
||||||
|
foreach ($keys as $key) {
|
||||||
|
if ($key === "PLN") {
|
||||||
|
$succ = true;
|
||||||
|
} else {
|
||||||
|
$crypto = $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$succ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!isset($test[$crypto])) {
|
||||||
|
$test[$crypto] = [];
|
||||||
|
}
|
||||||
|
$arr = [
|
||||||
|
"crypto" => 0,
|
||||||
|
"pln" => 0
|
||||||
|
];
|
||||||
|
/** @var MainObject $obj */
|
||||||
|
foreach ($items as $currency => $obj1) {
|
||||||
|
foreach ($obj1 as $obj) {
|
||||||
|
if ($currency === $crypto) {
|
||||||
|
$arr['crypto'] += $obj->getValue();
|
||||||
|
} else {
|
||||||
|
$arr['pln'] += $obj->getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$test[$crypto] = $arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $test;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user