Files
crm.twinpol.com/modules/EcmReportsBackUp20151106/class/class.Account.php

73 lines
1.7 KiB
PHP
Raw Normal View History

2025-05-12 15:44:39 +00:00
<?php
/**
* Klasa pobiera informacje o właścicielu faktury
* @author Krzysztof Raciniewski
*
*/
class Account {
/**
* Pobera wszystkie pozycje faktury o unikalnym ID
*
* @param $id -
* unikalny ID faktury
*/
public static function getByAccountId($id) {
$db = $GLOBALS ['db'];
$query = "SELECT * FROM accounts WHERE id='$id'";
$result = $db->query ( $query );
return $result->fetch_assoc();
}
/**
* Metoda stworzy strukturę tablicy:
* .
* .
* |
* |
* +----- Kontrahent1 --------------------------+ Dokument1 ------------------> Wpisy na fakturze
* | |
* | |
* | |
* | +-------------------+ Dokument2 ------------------> Wpisy na fakturze
* |
* |
* |
* +----- Kontrahent2 --------------------------+ Kategoria ------------------> Wpisy na fakturze
* . |
* . |
* . |
* +-------------------+ Kategoria2 ------------------> Wpisy na fakturze
*
*
*
*
* Na podstawie tablicy z dokumentami( taką tablicę zwraca metoda getBetweenDate w klasie Invoice i Receipt )
* */
public static function getAccountsFromInvoicesArray($invoices) {
$accounts = array();
foreach( $invoices as $invoice ){
$accounts[$invoice["parent_name"]]["invoices"][] = $invoice;
}
return $accounts;
}
/**
* Zwraca w formie tablicy wszystkie wiersze odpowiedzi na zapytanie
* @param $result
* @return multitype:
*/
public static function getAllFromResult( $result ) {
$itemsArray = array();
while($row = $result->fetch_assoc()){
array_push($itemsArray, $row);
}
return $itemsArray;
}
}
?>