|
|
@@ -100,6 +100,32 @@ class Windykacja_BillingListDocs {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function set_paid_status_for_all() {
|
|
|
+ // get all BillingDoc with type FVAT | KORV in reverse order
|
|
|
+ $fvIdxList = [];
|
|
|
+ foreach ($this->_docs as $idx_day => $listDayDocs) {
|
|
|
+ foreach ($listDayDocs as $idx_doc => $doc) {
|
|
|
+ if ($doc instanceof Windykacja_BillingDoc && in_array($doc->_type, [ 'FVAT', 'KORV' ])) {
|
|
|
+ array_unshift($fvIdxList, [
|
|
|
+ 'idx_day' => $idx_day,
|
|
|
+ 'idx_doc' => $idx_doc,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $fvUnpaidList = $this->get_unpaid_fvat(); // [ billDoc._data + 'WINIEN_POZOSTALO' ]
|
|
|
+ $mapFvUnpaid = []; // doc.ID => WINIEN_POZOSTALO
|
|
|
+ foreach ($fvUnpaidList as $billDocData) {
|
|
|
+ $mapFvUnpaid[ $billDocData['ID'] ] = $billDocData['WINIEN_POZOSTALO'];
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($fvIdxList as $idxFv) {
|
|
|
+ $billDoc = $this->_docs[ $idxFv['idx_day'] ][ $idxFv['idx_doc'] ];
|
|
|
+ $billDoc->_paid_status = (!array_key_exists($billDoc->get('ID'), $mapFvUnpaid));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function get_unpaid_fvat() {
|
|
|
$today_date = date("Y-m-d");
|
|
|
$fvat_arr = array();
|
|
|
@@ -242,6 +268,7 @@ class Windykacja_BillingDoc extends Windykacja_TimelineDoc {
|
|
|
$this->_class = 'BILLING';
|
|
|
$this->_convert_type($type);
|
|
|
$this->_count_saldo();
|
|
|
+ $this->_paid_status = 0; // 1: Opłacona | 0: Nieopłacona; Set in Windykacja_BillingListDocs.set_paid_status_for_all
|
|
|
}
|
|
|
|
|
|
public function get($key) {
|