init
This commit is contained in:
123
modules/EcmReports/RewizorGT/Dokument.php
Normal file
123
modules/EcmReports/RewizorGT/Dokument.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Dokument{
|
||||
public $typ_dokumentu;
|
||||
public $status_dokumentu;
|
||||
public $status_rejestracji_fiskalnej;
|
||||
public $numer_dokumentu;
|
||||
public $numer_dokumentu_dostawcy;
|
||||
public $rozszerzenie_numeru;
|
||||
public $pelny_numer_dokumentu;
|
||||
public $numer_dokumentu_korygowanego;
|
||||
public $data_wystawienia_korekty;
|
||||
public $numer_zamowienia;
|
||||
public $magazyn_docelowy;
|
||||
/*
|
||||
* Kontrahent
|
||||
*/
|
||||
public $kod_identyfikacyjny_kontrahenta;
|
||||
public $nazwa_skrocona;
|
||||
public $nazwa_pelna;
|
||||
public $miasto;
|
||||
public $kod_pocztowy;
|
||||
public $ulica_i_numer;
|
||||
public $nip;
|
||||
/*
|
||||
* Kategoria dokumentu
|
||||
*/
|
||||
public $kategoria;
|
||||
public $podtytul;
|
||||
/*
|
||||
* Miejsce i data
|
||||
*/
|
||||
public $miejsce_wystawienia='Obrowo';
|
||||
public $data_wystawienia;
|
||||
public $data_sprzedazy;
|
||||
public $data_otrzymania;
|
||||
/*
|
||||
* Pozycje
|
||||
*/
|
||||
public $pozycje;
|
||||
public $pozycjeObiekt;
|
||||
/*
|
||||
* Cena na dokumencie
|
||||
*/
|
||||
public $czy_dokumenty_wystawian_wg_ceny_netto;
|
||||
public $aktywna_cena;
|
||||
/*
|
||||
* Wartość i koszt dokumentu
|
||||
*/
|
||||
public $wartosc_netto;
|
||||
public $wartosc_vat;
|
||||
public $wartosc_brutto;
|
||||
public $koszt;
|
||||
/*
|
||||
* Rabat i forma płatności
|
||||
*/
|
||||
public $rabat_nazwa;
|
||||
public $rabat_procent;
|
||||
public $rabat_format_platnosci;
|
||||
public $rabat_termin_platnosci;
|
||||
/*
|
||||
* Kwoty na dokumencie;
|
||||
*/
|
||||
public $kwota_zaplacona_przy_odbiorze;
|
||||
public $wartosc_do_zaplaty;
|
||||
/*
|
||||
* Zaokrąglenie i przeliczenia
|
||||
*/
|
||||
public $zaokraglenie_wartosci_do_zaplaty;
|
||||
public $zaokraglenie_wartosci_vat;
|
||||
public $automatyczne_zaokgraglanie;
|
||||
public $statusy_rozszerzone_i_specjalne;
|
||||
/*
|
||||
* Osoby
|
||||
*/
|
||||
public $nazwisko_i_imie_wystawcy;
|
||||
public $nazwisko_i_imie_odbiorcy;
|
||||
public $podstawa_wydania_dokumentu;
|
||||
/*
|
||||
* Opakowanie
|
||||
*/
|
||||
public $wartosc_wydanych_opakowan;
|
||||
public $wartosc_zwroconych_opakowan;
|
||||
/*
|
||||
* Waluta dokumentu
|
||||
*/
|
||||
public $waluta;
|
||||
public $kurs_waluty;
|
||||
/*
|
||||
* Inne parametry
|
||||
*/
|
||||
public $uwagi;
|
||||
public $komentarze;
|
||||
public $podtytul_dokumentu;
|
||||
public $nie_uzywane;
|
||||
public $import_dokumentu;
|
||||
public $dokument_eksportowy;
|
||||
public $rodzaj_transakcji;
|
||||
/*
|
||||
* Płatnosc karta
|
||||
*/
|
||||
public $platnosc_karta_nazwa;
|
||||
public $platnosc_karta_kwota;
|
||||
public $platnosc_kredytowa_nazwa;
|
||||
public $platnosc_kredytowa_kwota;
|
||||
/*
|
||||
* Inne dane
|
||||
*/
|
||||
public $panstwo_kontrahenta;
|
||||
public $prefix_panstwa_ue;
|
||||
public $czy_kontrahent_unijny;
|
||||
|
||||
|
||||
public function getPozycjeObiekt(){
|
||||
return $this->pozycjeObiekt;
|
||||
}
|
||||
|
||||
public function setPozycjeObiekt($pozycje){
|
||||
$this->pozycjeObiekt=$pozycje;
|
||||
}
|
||||
}
|
||||
?>
|
||||
195
modules/EcmReports/RewizorGT/InvoiceCreator.php
Normal file
195
modules/EcmReports/RewizorGT/InvoiceCreator.php
Normal file
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
class InvoiceCreator{
|
||||
|
||||
private $db;
|
||||
public $kontrahenci;
|
||||
|
||||
public function __construct($date){
|
||||
$this->db=$GLOBALS['db'];
|
||||
$date = new DateTime($date);
|
||||
$this->date_from = $date->format("Y-m-01");
|
||||
$this->date_to=$date->format("Y-m-t");
|
||||
$this->kontrahenci=[];
|
||||
}
|
||||
|
||||
public function getInvoices(){
|
||||
$query="select * from ecminvoiceouts where deleted=0 and canceled=0 and register_date >='".$this->date_from."' and register_date <='".$this->date_to."' order by document_no ASC";
|
||||
|
||||
$rs = $this->db->query($query);
|
||||
global $app_list_strings;
|
||||
$documents=array();
|
||||
while($dane = $this->db->fetchByAssoc($rs)){
|
||||
$dokument = new Dokument();
|
||||
$kontrahent = new Kontrahent();
|
||||
if($dane['type']=='correct'){
|
||||
$dokument->typ_dokumentu=(string)'KFS';
|
||||
} else {
|
||||
$dokument->typ_dokumentu=(string)'FS';
|
||||
}
|
||||
$dokument->status_dokumentu=($dane['canceled']==true? 2 :1);
|
||||
$dokument->status_rejestracji_fiskalnej=0;
|
||||
$dokument->numer_dokumentu=0;
|
||||
$dokument->numer_dokumentu_dostawcy=$dane['document_no'];
|
||||
$dokument->rozszerzenie_numeru=(string)"FS";
|
||||
$dokument->pelny_numer_dokumentu=$dane['document_no'];
|
||||
|
||||
if($dane['type']=='correct'){
|
||||
$ii = new EcmInvoiceOut();
|
||||
$ii->retrieve($dane['ecminvoiceout_id']);
|
||||
$dokument->numer_dokumentu_korygowanego=$ii->document_no;
|
||||
$dokument->data_wystawienia_korekty=date("Ymd000000",strtotime($dane['register_date']));
|
||||
$dokument->wartosc_wydanych_opakowan=0;
|
||||
$dokument->wartosc_zwroconych_opakowan=0;
|
||||
if($dokument->numer_dokumentu_korygowanego==""){
|
||||
$dokument->numer_dokumentu_korygowanego='Korekta zbiorcza';
|
||||
}
|
||||
} else {
|
||||
$dokument->numer_dokumentu_korygowanego=null;
|
||||
$dokument->data_wystawienia_korekty=null;
|
||||
}
|
||||
|
||||
$letters = substr($dane['parent_nip'],0,2);
|
||||
if(ctype_alpha ($letters)){
|
||||
$rest = substr($dane['parent_nip'],2);
|
||||
$dane['parent_nip']=$letters.' '.$rest;
|
||||
}
|
||||
$dokument->numer_zamowienia=$dane['order_no'];
|
||||
$dokument->magazyn_docelowy=null;
|
||||
$a = new Account();
|
||||
$a->retrieve($dane['parent_id']);
|
||||
$a->name=str_replace("\r\n","",$a->name);
|
||||
$kontrahent->typ_kontrahenta=(float)0;
|
||||
$kontrahent->kod_identyfikacyjny=$a->number;
|
||||
$kontrahent->nazwa_skrocona=mb_substr($dane['parent_name'],0,40,'UTF-8');
|
||||
$kontrahent->nazwa_pelna=str_replace("\r\n","",$dane['parent_name']);
|
||||
$kontrahent->miasto=$dane['parent_address_city'];
|
||||
$kontrahent->kod_pocztowy=$a->billing_address_postalcode;
|
||||
$kontrahent->ulica_i_adres=$dane['parent_address_street'];
|
||||
$kontrahent->nip=$dane['parent_nip'];
|
||||
if($a->invoice_type=='U'){
|
||||
$kontrahent->prefix=mb_substr($a->to_vatid,0,2,'UTF-8');
|
||||
$kontrahent->czy_unijny=1;
|
||||
} else {
|
||||
$kontrahent->czy_unijny=0;
|
||||
}
|
||||
$this->kontrahenci[$a->id]=$kontrahent;
|
||||
$dokument->kod_identyfikacyjny_kontrahenta=$a->number;
|
||||
$dokument->nazwa_skrocona=mb_substr($dane['parent_name'],0,40,'UTF-8');
|
||||
$dokument->nazwa_pelna=str_replace("\r\n","",$dane['parent_name']);
|
||||
$dokument->miasto=$dane['parent_address_city'];
|
||||
$dokument->kod_pocztowy=$a->billing_address_postalcode;
|
||||
$dokument->ulica_i_numer=$dane['parent_address_street'];
|
||||
$dokument->nip=$dane['parent_nip'];
|
||||
|
||||
$dokument->kategoria="Sprzedaż";
|
||||
$dokument->podtytul=null;
|
||||
|
||||
$dokument->data_wystawienia=date("Ymd000000",strtotime($dane['register_date']));
|
||||
$dokument->data_sprzedazy=date("Ymd000000",strtotime($dane['sell_date']));
|
||||
$dokument->data_otrzymania=date("Ymd000000",strtotime($dane['register_date']));
|
||||
|
||||
$dokument->czy_dokumenty_wystawian_wg_ceny_netto=0;
|
||||
$dokument->wartosc_netto=(float)$dane['total_netto'];
|
||||
$dokument->wartosc_vat=(float)$dane['total_vat'];
|
||||
$dokument->wartosc_brutto=(float)$dane['total_brutto'];
|
||||
$dokument->koszt=(float)$dane['purchase_price'];
|
||||
$dokument->rabat_format_platnosci=$app_list_strings['payment_method'][$dane['payment_method']];
|
||||
$dokument->rabat_termin_platnosci=date("Ymd000000",strtotime($dane['payment_date']));
|
||||
|
||||
$dokument->kwota_zaplacona_przy_odbiorze=(float)$dane['paid_val'];
|
||||
$dokument->wartosc_do_zaplaty=(float)round($dane['total_brutto'],2);
|
||||
|
||||
$dokument->zaokraglenie_wartosci_do_zaplaty=0;
|
||||
$dokument->zaokraglenie_wartosci_vat=0;
|
||||
|
||||
$dokument->automatyczne_zaokgraglanie=0;
|
||||
$dokument->statusy_rozszerzone_i_specjalne=0;
|
||||
$u = new User();
|
||||
$u->retrieve($dane['assigned_user_id']);
|
||||
$dokument->nazwisko_i_imie_wystawcy=$u->full_name;
|
||||
|
||||
if($dane['currency_id']=="PLN"){
|
||||
$dokument->waluta='PLN';
|
||||
|
||||
} else {
|
||||
$cur = new Currency();
|
||||
$cur->retrieve($dane['currency_id']);
|
||||
|
||||
$dokument->waluta=$cur->name;
|
||||
$dokument->kurs_waluty=(float)$dane['currency_value_nbp'];
|
||||
}
|
||||
|
||||
$dokument->uwagi=str_replace("\r\n","",$dane['pdf_text']);
|
||||
$dokument->import_dokumentu=0;
|
||||
if($dane['pdf_type']=='K'){
|
||||
$dokument->rodzaj_transakcji=0;
|
||||
} else {
|
||||
if($dane['pdf_type']=='U'){
|
||||
$dokument->rodzaj_transakcji=2;
|
||||
} else {
|
||||
$dokument->rodzaj_transakcji=1;
|
||||
}
|
||||
}
|
||||
|
||||
//$dokument->panstwo_kontrahenta=$a->billing_address_country;
|
||||
|
||||
if($a->invoice_type=='U'){
|
||||
$dokument->prefix_panstwa_ue=mb_substr($a->to_vatid,0,2,'UTF-8');
|
||||
$dokument->czy_kontrahent_unijny=1;
|
||||
}
|
||||
|
||||
$dokument->setPozycjeObiekt($this->getDocumentPositions($dane['id'],$dokument));
|
||||
|
||||
$documents[]=$dokument;
|
||||
|
||||
}
|
||||
return $documents;
|
||||
}
|
||||
|
||||
public function getDocumentPositions($id,&$doc){
|
||||
$query="select * from ecminvoiceoutitems where ecminvoiceout_id='".$id."' and deleted=0";
|
||||
|
||||
$rr=$this->db->query($query);
|
||||
|
||||
$pozycje=[];
|
||||
while($dane=$this->db->fetchByAssoc($rr)){
|
||||
if($pozycje[$dane ['ecmvat_value']]!=""){
|
||||
$obiekt = $pozycje[$dane ['ecmvat_value']];
|
||||
if ($doc->typ_dokumentu!= 'FS') {
|
||||
$obiekt->wartosc_netto+= $dane ['total_netto_corrected'];
|
||||
$obiekt->wartosc_vat+= $dane ['total_vat_corrected'];
|
||||
$obiekt->wartosc_brutto+= $dane ['total_brutto_corrected'];
|
||||
} else {
|
||||
$obiekt->wartosc_netto+= $dane ['total_netto'];
|
||||
$obiekt->wartosc_vat+= $dane ['total_vat'];
|
||||
$obiekt->wartosc_brutto+= $dane ['total_brutto'];
|
||||
}
|
||||
$obiekt->wartosc_nabycia+= round ( $dane ['price_purchase'] * $dane ['quantity'], 2 );
|
||||
$pozycje[$dane ['ecmvat_value']]=$obiekt;
|
||||
} else {
|
||||
$pozycja = new Pozycja;
|
||||
$pozycja->symbol_stawki_vat = $dane ['ecmvat_value'];
|
||||
$pozycja->wysokosc_stawki_vat_w_procentach = floatval ($dane ['ecmvat_value'] . '.00');
|
||||
if ($doc->typ_dokumentu!= 'FS') {
|
||||
$pozycja->wartosc_netto =floatval($dane ['total_netto_corrected']);
|
||||
$pozycja->wartosc_vat = floatval($dane ['total_vat_corrected']);
|
||||
$pozycja->wartosc_brutto =floatval($dane ['total_brutto_corrected']);
|
||||
} else {
|
||||
$pozycja->wartosc_netto = floatval($dane ['total_netto']);
|
||||
$pozycja->wartosc_vat = floatval($dane ['total_vat']);
|
||||
$pozycja->wartosc_brutto = floatval($dane ['total_brutto']);
|
||||
}
|
||||
$pozycja->wartosc_nabycia = round ( $dane ['price_purchase'] * $dane ['quantity'], 2 );
|
||||
$pozycje[$dane ['ecmvat_value']]=$pozycja;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$doc->pozycje=count($pozycja);
|
||||
|
||||
return $pozycje;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
34
modules/EcmReports/RewizorGT/Kontrahent.php
Normal file
34
modules/EcmReports/RewizorGT/Kontrahent.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
class Kontrahent{
|
||||
public $typ_kontrahenta;
|
||||
public $kod_identyfikacyjny;
|
||||
public $nazwa_skrocona;
|
||||
public $nazwa_pelna;
|
||||
public $miasto;
|
||||
public $kod_pocztowy;
|
||||
public $ulica_i_adres;
|
||||
public $nip;
|
||||
public $regon;
|
||||
public $telefon;
|
||||
public $faks;
|
||||
public $email;
|
||||
public $www;
|
||||
public $nazwisko_imie;
|
||||
public $analityka_dostawcy;
|
||||
public $analityka_odbiorcy;
|
||||
public $pole_uzytkownika_1;
|
||||
public $pole_uzytkownika_2;
|
||||
public $pole_uzytkownika_3;
|
||||
public $pole_uzytkownika_4;
|
||||
public $pole_uzytkownika_5;
|
||||
public $pole_uzytkownika_6;
|
||||
public $pole_uzytkownika_7;
|
||||
public $pole_uzytkownika_8;
|
||||
public $nazwa_banku;
|
||||
public $numer_banku;
|
||||
public $panstwo_kontrahenta;
|
||||
public $prefix;
|
||||
public $czy_unijny;
|
||||
}
|
||||
?>
|
||||
169
modules/EcmReports/RewizorGT/MmCreator.php
Normal file
169
modules/EcmReports/RewizorGT/MmCreator.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
class MmCreator{
|
||||
|
||||
private $db;
|
||||
public $kontrahenci;
|
||||
|
||||
public function __construct($date){
|
||||
$this->db=$GLOBALS['db'];
|
||||
$date = new DateTime($date);
|
||||
$this->date_from = $date->format("Y-m-01");
|
||||
$this->date_to=$date->format("Y-m-t");
|
||||
$this->kontrahenci=[];
|
||||
}
|
||||
|
||||
public function getDocuments(){
|
||||
$query="select * from ecmstockdocmoves where deleted=0 and register_date >='".$this->date_from."' and register_date <='".$this->date_to."' order by document_no ASC";
|
||||
|
||||
$rs = $this->db->query($query);
|
||||
global $app_list_strings;
|
||||
$documents=array();
|
||||
while($dane = $this->db->fetchByAssoc($rs)){
|
||||
$dokument = new Dokument();
|
||||
$kontrahent = new Kontrahent();
|
||||
|
||||
$dokument->typ_dokumentu=(string)'MM';
|
||||
|
||||
$dokument->status_dokumentu=1;
|
||||
$dokument->status_rejestracji_fiskalnej=0;
|
||||
$dokument->numer_dokumentu=0;
|
||||
$dokument->numer_dokumentu_dostawcy=$dane['document_no'];
|
||||
$dokument->rozszerzenie_numeru=(string)"MM";
|
||||
$dokument->pelny_numer_dokumentu=$dane['document_no'];
|
||||
|
||||
$dokument->numer_dokumentu_korygowanego=null;
|
||||
$dokument->data_wystawienia_korekty=null;
|
||||
$dane['parent_nip']=$kontrahent->to_vatid;
|
||||
$letters = substr($dane['parent_nip'],0,2);
|
||||
if(ctype_alpha ($letters)){
|
||||
$rest = substr($dane['parent_nip'],2);
|
||||
$dane['parent_nip']=$letters.' '.$rest;
|
||||
}
|
||||
$dokument->numer_zamowienia="";
|
||||
$dokument->magazyn_docelowy=null;
|
||||
$a = new Account();
|
||||
$a->retrieve($dane['parent_id']);
|
||||
$a->name=str_replace("\r\n","",$a->name);
|
||||
$kontrahent->typ_kontrahenta=(float)0;
|
||||
$kontrahent->kod_identyfikacyjny=$a->number;
|
||||
$kontrahent->nazwa_skrocona=mb_substr($dane['parent_name'],0,40,'UTF-8');
|
||||
$kontrahent->nazwa_pelna=str_replace("\r\n","",$dane['parent_name']);
|
||||
$kontrahent->miasto=$dane['parent_address_city'];
|
||||
$kontrahent->kod_pocztowy=$a->billing_address_postalcode;
|
||||
$kontrahent->ulica_i_adres=$dane['parent_address_street'];
|
||||
$kontrahent->nip=$dane['parent_nip'];
|
||||
if($a->invoice_type=='U'){
|
||||
$kontrahent->prefix=mb_substr($a->to_vatid,0,2,'UTF-8');
|
||||
$kontrahent->czy_unijny=1;
|
||||
} else {
|
||||
$kontrahent->czy_unijny=0;
|
||||
}
|
||||
$this->kontrahenci[$a->id]=$kontrahent;
|
||||
$dokument->kod_identyfikacyjny_kontrahenta=$a->number;
|
||||
$dokument->nazwa_skrocona=mb_substr($dane['parent_name'],0,40,'UTF-8');
|
||||
$dokument->nazwa_pelna=str_replace("\r\n","",$dane['parent_name']);
|
||||
$dokument->miasto=$dane['parent_address_city'];
|
||||
$dokument->kod_pocztowy=$a->billing_address_postalcode;
|
||||
$dokument->ulica_i_numer=$dane['parent_address_street'];
|
||||
$dokument->nip=$dane['parent_nip'];
|
||||
|
||||
$s = new EcmStock();
|
||||
$s->retrieve($dane['stock_in_id']);
|
||||
|
||||
$s2 = new EcmStock();
|
||||
$s2->retrieve($dane['stock_out_id']);
|
||||
$dokument->kategoria=$s->name.' - '.$s2->name;
|
||||
$dokument->podtytul='';
|
||||
|
||||
$dokument->data_wystawienia=date("Ymd000000",strtotime($dane['register_date']));
|
||||
$dokument->data_sprzedazy=date("Ymd000000",strtotime($dane['register_date']));
|
||||
$dokument->data_otrzymania=date("Ymd000000",strtotime($dane['register_date']));
|
||||
|
||||
$dokument->czy_dokumenty_wystawian_wg_ceny_netto=0;
|
||||
$dokument->wartosc_netto=(float)$dane['total'];
|
||||
$dokument->wartosc_vat=(float)$dane['total_vat'];
|
||||
$dokument->wartosc_brutto=(float)$dane['total'];
|
||||
$dokument->koszt=(float)$dane['total'];
|
||||
$dokument->rabat_format_platnosci=$app_list_strings['payment_method'][$dane['payment_method']];
|
||||
$dokument->rabat_termin_platnosci=date("Ymd000000",strtotime($dane['payment_date']));
|
||||
|
||||
$dokument->kwota_zaplacona_przy_odbiorze=(float)0;
|
||||
$dokument->wartosc_do_zaplaty=(float)0;
|
||||
|
||||
$dokument->zaokraglenie_wartosci_do_zaplaty=0;
|
||||
$dokument->zaokraglenie_wartosci_vat=0;
|
||||
|
||||
$dokument->automatyczne_zaokgraglanie=0;
|
||||
$dokument->statusy_rozszerzone_i_specjalne=0;
|
||||
$u = new User();
|
||||
$u->retrieve($dane['assigned_user_id']);
|
||||
$dokument->nazwisko_i_imie_wystawcy=$u->full_name;
|
||||
|
||||
$dokument->waluta='PLN';
|
||||
|
||||
|
||||
$dokument->uwagi=str_replace("\r\n","",$dane['pdf_text']);
|
||||
$dokument->import_dokumentu=0;
|
||||
|
||||
$dokument->rodzaj_transakcji=0;
|
||||
|
||||
|
||||
//$dokument->panstwo_kontrahenta=$a->billing_address_country;
|
||||
|
||||
|
||||
|
||||
//$dokument->setPozycjeObiekt($this->getDocumentPositions($dane['id'],$dokument));
|
||||
|
||||
$documents[]=$dokument;
|
||||
|
||||
}
|
||||
return $documents;
|
||||
}
|
||||
|
||||
public function getDocumentPositions($id,&$doc){
|
||||
$query="select * from ecminvoiceoutitems where ecminvoiceout_id='".$id."' and deleted=0";
|
||||
|
||||
$rr=$this->db->query($query);
|
||||
|
||||
$pozycje=[];
|
||||
while($dane=$this->db->fetchByAssoc($rr)){
|
||||
if($pozycje[$dane ['ecmvat_value']]!=""){
|
||||
$obiekt = $pozycje[$dane ['ecmvat_value']];
|
||||
if ($doc->typ_dokumentu!= 'FS') {
|
||||
$obiekt->wartosc_netto+= $dane ['total_netto_corrected'];
|
||||
$obiekt->wartosc_vat+= $dane ['total_vat_corrected'];
|
||||
$obiekt->wartosc_brutto+= $dane ['total_brutto_corrected'];
|
||||
} else {
|
||||
$obiekt->wartosc_netto+= $dane ['total_netto'];
|
||||
$obiekt->wartosc_vat+= $dane ['total_vat'];
|
||||
$obiekt->wartosc_brutto+= $dane ['total_brutto'];
|
||||
}
|
||||
$obiekt->wartosc_nabycia+= round ( $dane ['price_purchase'] * $dane ['quantity'], 2 );
|
||||
$pozycje[$dane ['ecmvat_value']]=$obiekt;
|
||||
} else {
|
||||
$pozycja = new Pozycja;
|
||||
$pozycja->symbol_stawki_vat = $dane ['ecmvat_value'];
|
||||
$pozycja->wysokosc_stawki_vat_w_procentach = floatval ($dane ['ecmvat_value'] . '.00');
|
||||
if ($doc->typ_dokumentu!= 'FS') {
|
||||
$pozycja->wartosc_netto =floatval($dane ['total_netto_corrected']);
|
||||
$pozycja->wartosc_vat = floatval($dane ['total_vat_corrected']);
|
||||
$pozycja->wartosc_brutto =floatval($dane ['total_brutto_corrected']);
|
||||
} else {
|
||||
$pozycja->wartosc_netto = floatval($dane ['total_netto']);
|
||||
$pozycja->wartosc_vat = floatval($dane ['total_vat']);
|
||||
$pozycja->wartosc_brutto = floatval($dane ['total_brutto']);
|
||||
}
|
||||
$pozycja->wartosc_nabycia = round ( $dane ['price_purchase'] * $dane ['quantity'], 2 );
|
||||
$pozycje[$dane ['ecmvat_value']]=$pozycja;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$doc->pozycje=count($pozycja);
|
||||
|
||||
return $pozycje;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
179
modules/EcmReports/RewizorGT/ObjectLoader.php
Normal file
179
modules/EcmReports/RewizorGT/ObjectLoader.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
if ($_REQUEST ['date']) {
|
||||
$date = $_REQUEST ['date'];
|
||||
} else {
|
||||
$date = new DateTime ();
|
||||
$date->modify ( "-1 month" );
|
||||
$date = $date->format ( "01.m.Y" );
|
||||
}
|
||||
|
||||
$dokumenty = $_REQUEST['documents'];
|
||||
if ($_REQUEST ['date'] != "") {
|
||||
|
||||
$array=[];
|
||||
foreach ($dokumenty as $dokument){
|
||||
echo $dokument;
|
||||
if($dokument=='fs'){
|
||||
$invoiceCreator = new InvoiceCreator ( $_REQUEST ['date'] );
|
||||
|
||||
$array2 = $invoiceCreator->getInvoices ();
|
||||
|
||||
$array = array_merge ( $array, $array2 );
|
||||
}
|
||||
if($dokument=='fz-all'){
|
||||
$purchaseCreator = new PurchaseCreator ( $_REQUEST ['date'] );
|
||||
|
||||
$array2 = $purchaseCreator->getPurchases ("all");
|
||||
|
||||
$array = array_merge ( $array, $array2 );
|
||||
}
|
||||
if($dokument=='fz-new'){
|
||||
$purchaseCreator = new PurchaseCreator ( $_REQUEST ['date'] );
|
||||
|
||||
$array2 = $purchaseCreator->getPurchases ("new");
|
||||
|
||||
$array = array_merge ( $array, $array2 );
|
||||
}
|
||||
if($dokument=='pz'){
|
||||
$purchaseCreator = new PzCreator ( $_REQUEST ['date'] );
|
||||
|
||||
$array2 = $purchaseCreator->getDocuments();
|
||||
|
||||
$array = array_merge ( $array, $array2 );
|
||||
}
|
||||
if($dokument=='wz'){
|
||||
$purchaseCreator = new WzCreator ( $_REQUEST ['date'] );
|
||||
|
||||
$array2 = $purchaseCreator->getDocuments();
|
||||
|
||||
$array = array_merge ( $array, $array2 );
|
||||
}
|
||||
if($dokument=='rw'){
|
||||
$purchaseCreator = new RwCreator ( $_REQUEST ['date'] );
|
||||
|
||||
$array2 = $purchaseCreator->getDocuments();
|
||||
|
||||
$array = array_merge ( $array, $array2 );
|
||||
}
|
||||
|
||||
if($dokument=='pw'){
|
||||
$purchaseCreator = new PwCreator ( $_REQUEST ['date'] );
|
||||
|
||||
$array2 = $purchaseCreator->getDocuments();
|
||||
|
||||
$array = array_merge ( $array, $array2 );
|
||||
}
|
||||
|
||||
if($dokument=='mm'){
|
||||
$purchaseCreator = new MmCreator ( $_REQUEST ['date'] );
|
||||
|
||||
$array2 = $purchaseCreator->getDocuments();
|
||||
|
||||
$array = array_merge ( $array, $array2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$delimiter = ',';
|
||||
unlink( 'eksport.epp');
|
||||
if (count ( $array ) > 0) {
|
||||
|
||||
$fp = fopen ( 'eksport.epp', 'w' );
|
||||
fwriteEncoding ( $fp, "[INFO]\r\n" );
|
||||
fwriteEncoding ( $fp, '"1.05.4",0,1250,"Subiekt GT","GT","SubTest","Firma przykładowa systemu InsERT GT","Wrocław","54-445","Bławatkowa 25/3","111-111-11-11","MAG","Główny","Magazyn główny",,1,20170101000000,20170331000000,"Kowalski Jan",20170804155934,"Polska","PL",,0' . "\r\n\r\n" );
|
||||
foreach ( $array as $element ) {
|
||||
fwriteEncoding ( $fp, "[NAGLOWEK]\r\n" );
|
||||
|
||||
$arrayElement = ( array ) $element;
|
||||
|
||||
unset ( $arrayElement ['pozycjeObiekt'] );
|
||||
|
||||
fwriteArray ( $fp, $arrayElement, $delimiter );
|
||||
fwriteEncoding ( $fp, "\r\n" );
|
||||
|
||||
$pozycje = $element->getPozycjeObiekt ();
|
||||
|
||||
if (count ( $pozycje ) > 0) {
|
||||
fwriteEncoding ( $fp, "[ZAWARTOSC]\r\n" );
|
||||
foreach ( $pozycje as $pozycja ) {
|
||||
|
||||
fwriteArray ( $fp, ( array ) $pozycja, $delimiter );
|
||||
}
|
||||
fwriteEncoding ( $fp, "\r\n" );
|
||||
} else {
|
||||
fwriteEncoding ( $fp, "[ZAWARTOSC]\r\n" );
|
||||
fwriteEncoding ( $fp, "\r\n" );
|
||||
}
|
||||
}
|
||||
|
||||
fwriteEncoding ( $fp, "[NAGLOWEK]\r\n" );
|
||||
fwriteEncoding ( $fp, "\"KONTRAHENCI\"\r\n\r\n" );
|
||||
|
||||
fwriteEncoding ( $fp, "[ZAWARTOSC]\r\n" );
|
||||
foreach ( $invoiceCreator->kontrahenci as $pozycja ) {
|
||||
|
||||
fwriteArray ( $fp, ( array ) $pozycja, $delimiter );
|
||||
}
|
||||
/*
|
||||
foreach ( $purchaseCreator->kontrahenci as $pozycja ) {
|
||||
|
||||
fwriteArray ( $fp, ( array ) $pozycja, $delimiter );
|
||||
}*/
|
||||
fwriteEncoding ( $fp, "\r\n" );
|
||||
}
|
||||
|
||||
|
||||
$quoted = sprintf('"%s"', addcslashes(basename('eksport.epp'), '"\\'));
|
||||
$size = filesize('eksport.epp');
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename=' . $quoted);
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Connection: Keep-Alive');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . $size);
|
||||
ob_clean();
|
||||
flush();
|
||||
readfile('eksport.epp'); //Absolute URL
|
||||
exit();
|
||||
|
||||
|
||||
} else {
|
||||
$smarty = new Sugar_Smarty ();
|
||||
$smarty->assign ( 'dateFormat', $Calendar_daFormat = str_replace ( "d", "%d", str_replace ( "m", "%m", str_replace ( "Y", "%Y", $GLOBALS ['timedate']->get_date_format () ) ) ) );
|
||||
$smarty->assign ( "date", $date );
|
||||
echo $smarty->fetch ( "modules/EcmReports/RewizorGT/form.tpl.html" );
|
||||
}
|
||||
|
||||
function fwriteEncoding($fp,$text){
|
||||
//cp1250
|
||||
return fwrite($fp, iconv('UTF-8//TRANSLIT',"Windows-1250//TRANSLIT",$text));
|
||||
|
||||
}
|
||||
|
||||
function fwriteArray($fp, $array, $delimiter) {
|
||||
$string = "";
|
||||
|
||||
$i = 0;
|
||||
$len = count ( $array );
|
||||
foreach ( $array as $key => $value ) {
|
||||
if ($i == $len - 1) {
|
||||
$string .= addEnclosure ( $value ) . "\r\n";
|
||||
} else {
|
||||
$string .= addEnclosure ( $value ) . $delimiter;
|
||||
}
|
||||
// …
|
||||
$i ++;
|
||||
}
|
||||
fwriteEncoding ( $fp, $string );
|
||||
}
|
||||
function addEnclosure($value) {
|
||||
if (is_string ( $value )) {
|
||||
return '"' . $value . '"';
|
||||
} else {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
?>
|
||||
38
modules/EcmReports/RewizorGT/Pozycja.php
Normal file
38
modules/EcmReports/RewizorGT/Pozycja.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
class Pozycja{
|
||||
public $symbol_stawki_vat;
|
||||
public $wysokosc_stawki_vat_w_procentach;
|
||||
public $wartosc_netto;
|
||||
public $wartosc_vat;
|
||||
public $wartosc_brutto;
|
||||
public $wartosc_netto_ogolna_koncowa=0;
|
||||
public $wartosc_vat_ogolna_koncowa=0;
|
||||
public $wartosc_brutto_ogolna_koncowa=0;
|
||||
public $wartosc_netto_poprzednich_zaliczek=0;
|
||||
public $wartosc_vat_poprzednich_zaliczek=0;
|
||||
public $wartosc_brutto_poprzednich_zaliczek=0;
|
||||
public $wartosc_netto_w_pln_poprzednich_zaliczek=0;
|
||||
public $wartosc_vat_w_pln_poprzednich_zaliczek=0;
|
||||
public $wartosc_brutto_w_pln_poprzednich_zaliczek=0;
|
||||
public $wartosc_netto_marzy=0;
|
||||
public $wartosc_vat_marzy=0;
|
||||
public $wartosc_brutto_marzy=0;
|
||||
public $wartosc_nabycia;
|
||||
|
||||
public function dupa(){
|
||||
$pozycja->symbol_stawki_vat = $dane ['ecmvat_value'];
|
||||
$pozycja->wysokosc_stawki_vat_w_procentach = $dane ['ecmvat_value'] . '.00';
|
||||
if ($dokument->numer_dokumentu_korygowanego != '') {
|
||||
$pozycja->wartosc_netto = $dane ['total_netto_corrected'];
|
||||
$pozycja->wartosc_vat = $dane ['total_vat_corrected'];
|
||||
$pozycja->wartosc_brutto = $dane ['total_brutto_corrected'];
|
||||
} else {
|
||||
$pozycja->wartosc_netto = $dane ['total_netto'];
|
||||
$pozycja->wartosc_vat = $dane ['total_vat'];
|
||||
$pozycja->wartosc_brutto = $dane ['total_brutto'];
|
||||
}
|
||||
$pozycja->wartosc_nabycia = round ( $dane ['price_purchase'] * $dane ['quantity'], 2 );
|
||||
}
|
||||
}
|
||||
?>
|
||||
191
modules/EcmReports/RewizorGT/PurchaseCreator.php
Normal file
191
modules/EcmReports/RewizorGT/PurchaseCreator.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
class PurchaseCreator{
|
||||
|
||||
private $db;
|
||||
public $kontrahenci;
|
||||
|
||||
public function __construct($date){
|
||||
$this->db=$GLOBALS['db'];
|
||||
$date = new DateTime($date);
|
||||
$this->date_from = $date->format("Y-m-01");
|
||||
$this->date_to=$date->format("Y-m-t");
|
||||
$this->kontrahenci=[];
|
||||
}
|
||||
|
||||
public function getPurchases($type){
|
||||
$query="select * from documents where document_date>='" . $this->date_from . "' and document_date<='" . $this->date_to . "' and category_id in ('invoice','compain_note','return_note') and deleted=0";
|
||||
|
||||
if ($type == "new") {
|
||||
$query .= " and exported = 0";
|
||||
}
|
||||
|
||||
echo $query;
|
||||
$rs = $this->db->query($query);
|
||||
global $app_list_strings;
|
||||
$documents=array();
|
||||
while($dane = $this->db->fetchByAssoc($rs)){
|
||||
$dokument = new Dokument();
|
||||
$kontrahent = new Kontrahent();
|
||||
if($dane['corrected_document_name']!=""){
|
||||
$dokument->typ_dokumentu=(string)'KFZ';
|
||||
} else {
|
||||
$dokument->typ_dokumentu=(string)'FZ';
|
||||
}
|
||||
$dokument->status_dokumentu=1;
|
||||
$dokument->status_rejestracji_fiskalnej=0;
|
||||
$dokument->numer_dokumentu=0;
|
||||
$dokument->numer_dokumentu_dostawcy=$dane['document_name'];
|
||||
$dokument->rozszerzenie_numeru=(string)"FZ";
|
||||
$dokument->pelny_numer_dokumentu=$dane['document_name'];
|
||||
|
||||
if($dane['corrected_document_name']!=""){
|
||||
$dokument->numer_dokumentu_korygowanego=$dane['corrected_document_name'];
|
||||
$dokument->data_wystawienia_korekty=date("Ymd000000",strtotime($dane['document_date']));
|
||||
} else {
|
||||
$dokument->numer_dokumentu_korygowanego=null;
|
||||
$dokument->data_wystawienia_korekty=null;
|
||||
}
|
||||
$dokument->numer_zamowienia=null;
|
||||
$dokument->magazyn_docelowy=null;
|
||||
$value = new Document();
|
||||
$value->retrieve($dane['id']);
|
||||
$relations=$value->getParentList(true);
|
||||
$a = new Account ();
|
||||
$a->retrieve ( $relations[0]['parent_id']);
|
||||
$dokument->kod_identyfikacyjny_kontrahenta=$a->number;
|
||||
$dokument->nazwa_skrocona=mb_substr($a->name,0,40,'UTF-8');
|
||||
$dokument->nazwa_pelna=str_replace("\r\n","",$a->name);
|
||||
$dokument->miasto=$a->billing_address_city;
|
||||
$dokument->kod_pocztowy=$a->billing_address_postalcode;
|
||||
$dokument->ulica_i_numer=$a->billing_address_street;
|
||||
$dokument->nip=$a->to_vatid;
|
||||
|
||||
$dokument->kategoria=null;
|
||||
$dokument->podtytul=null;
|
||||
$kontrahent->typ_kontrahenta=(float)0;
|
||||
$kontrahent->kod_identyfikacyjny=$a->number;
|
||||
$kontrahent->nazwa_skrocona=mb_substr($a->name,0,40,'UTF-8');
|
||||
$kontrahent->nazwa_pelna=str_replace("\r\n","",$a->name);
|
||||
$kontrahent->miasto=$a->billing_address_city;
|
||||
$kontrahent->kod_pocztowy=$a-billing_address_postalcode;
|
||||
$kontrahent->ulica_i_adres=$a->billing_address_street;
|
||||
$kontrahent->nip=$a->to_vatid;
|
||||
if($a->invoice_type=='U'){
|
||||
$kontrahent->prefix=mb_substr($a->to_vatid,0,2,'UTF-8');
|
||||
$kontrahent->czy_unijny=1;
|
||||
} else {
|
||||
$kontrahent->czy_unijny=0;
|
||||
}
|
||||
$this->kontrahenci[$a->id]=$kontrahent;
|
||||
$dokument->data_wystawienia=date("Ymd000000",strtotime($dane['document_date']));
|
||||
$dokument->data_sprzedazy=date("Ymd000000",strtotime($dane['document_date']));
|
||||
$dokument->data_otrzymania=date("Ymd000000",strtotime($dane['document_date']));
|
||||
|
||||
$sumQuery=$this->db->query("select ROUND(sum(netto),2) AS total_netto,ROUND(sum(vat),2) AS total_vat,ROUND(sum(vat+netto),2) AS total_brutto from documents_vat WHERE document_id='".$dane['id']."' and netto!='NaN' and vat!='NaN' and netto!=0 and deleted=0");
|
||||
|
||||
$sumRes=$this->db->fetchByAssoc($sumQuery);
|
||||
|
||||
$dokument->czy_dokumenty_wystawian_wg_ceny_netto=0;
|
||||
$dokument->wartosc_netto=(float)$sumRes['total_netto'];
|
||||
$dokument->wartosc_vat=(float)$sumRes['total_vat'];
|
||||
$dokument->wartosc_brutto=(float)$sumRes['total_brutto'];
|
||||
$dokument->koszt=(float)$dane['value'];
|
||||
if($dane['payment_date']!=""){
|
||||
$dokument->rabat_format_platnosci='przelew';
|
||||
$dokument->rabat_termin_platnosci=date("Ymd000000",strtotime($dane['payment_date']));
|
||||
} else {
|
||||
$dokument->rabat_format_platnosci='gotówka';
|
||||
$dokument->rabat_termin_platnosci=date("Ymd000000",strtotime($dane['document_date']));
|
||||
}
|
||||
|
||||
if($dane['left_paid']!=0){
|
||||
$dokument->kwota_zaplacona_przy_odbiorze=(float)$dane['left_paid'];;
|
||||
$dokument->wartosc_do_zaplaty=(float)round($dane['value'],2);
|
||||
} else {
|
||||
$dokument->kwota_zaplacona_przy_odbiorze=(float)$dane['value'];
|
||||
$dokument->wartosc_do_zaplaty=(float)$dane['value'];
|
||||
}
|
||||
|
||||
|
||||
$dokument->zaokraglenie_wartosci_do_zaplaty=0;
|
||||
$dokument->zaokraglenie_wartosci_vat=0;
|
||||
|
||||
$dokument->automatyczne_zaokgraglanie=0;
|
||||
$dokument->statusy_rozszerzone_i_specjalne=0;
|
||||
$u = new User();
|
||||
$u->retrieve($dane['assigned_user_id']);
|
||||
$dokument->nazwisko_i_imie_wystawcy=$u->full_name;
|
||||
|
||||
if($dane['currency_id']=="PLN"){
|
||||
$dokument->waluta='PLN';
|
||||
|
||||
} else {
|
||||
$cur = new Currency();
|
||||
$cur->retrieve($dane['currency_id']);
|
||||
|
||||
$dokument->waluta=$cur->name;
|
||||
$dokument->kurs_waluty=(float)$dane['currency_value'];
|
||||
}
|
||||
|
||||
$dokument->uwagi=null;
|
||||
$dokument->import_dokumentu=0;
|
||||
if($dane['document_type']=='k'){
|
||||
$dokument->rodzaj_transakcji=1;
|
||||
} else {
|
||||
if($dane['document_type']=='u'){
|
||||
$dokument->rodzaj_transakcji=2;
|
||||
} else {
|
||||
$dokument->rodzaj_transakcji=1;
|
||||
}
|
||||
}
|
||||
|
||||
$dokument->panstwo_kontrahenta=$a->billing_address_country;
|
||||
|
||||
if($a->invoice_type=='U'){
|
||||
$dokument->prefix_panstwa_ue=mb_substr($a->to_vatid,0,2,'UTF-8');
|
||||
$dokument->czy_kontrahent_unijny=1;
|
||||
}
|
||||
|
||||
$dokument->setPozycjeObiekt($this->getDocumentPositions($dane['id'],$dokument));
|
||||
|
||||
$query="update documents set exported = 1 where id='".$dane['id']."'";
|
||||
|
||||
$this->db->query($query);
|
||||
|
||||
$documents[]=$dokument;
|
||||
|
||||
}
|
||||
return $documents;
|
||||
}
|
||||
|
||||
public function getDocumentPositions($id,&$doc){
|
||||
$query="select * from documents_vat WHERE document_id='".$id."' and netto!='NaN' and vat!='NaN' and netto!=0 and deleted=0";
|
||||
|
||||
$rr=$this->db->query($query);
|
||||
|
||||
$pozycje=[];
|
||||
while($dane=$this->db->fetchByAssoc($rr)){
|
||||
$pozycja = new Pozycja;
|
||||
$pozycja->symbol_stawki_vat = $dane ['vat_id'];
|
||||
$pozycja->wysokosc_stawki_vat_w_procentach = $dane ['vat_id'] . '.00';
|
||||
if ($doc->numer_dokumentu_korygowanego != '') {
|
||||
$pozycja->wartosc_netto =(float)$dane ['netto'];
|
||||
$pozycja->wartosc_vat =(float)$dane ['vat'];
|
||||
$pozycja->wartosc_brutto = (float)round( $dane ['netto']+ $dane ['vat'],2);
|
||||
} else {
|
||||
$pozycja->wartosc_netto =(float)$dane ['netto'];
|
||||
$pozycja->wartosc_vat =(float)$dane ['vat'];
|
||||
$pozycja->wartosc_brutto = (float)round( $dane ['netto']+ $dane ['vat'],2);
|
||||
}
|
||||
$pozycja->wartosc_nabycia =(float)round( $dane ['netto']+ $dane ['vat'],2);
|
||||
$pozycje[]=$pozycja;
|
||||
}
|
||||
|
||||
$doc->pozycje=count($pozycja);
|
||||
|
||||
return $pozycje;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
166
modules/EcmReports/RewizorGT/PwCreator.php
Normal file
166
modules/EcmReports/RewizorGT/PwCreator.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
class PwCreator{
|
||||
|
||||
private $db;
|
||||
public $kontrahenci;
|
||||
|
||||
public function __construct($date){
|
||||
$this->db=$GLOBALS['db'];
|
||||
$date = new DateTime($date);
|
||||
$this->date_from = $date->format("Y-m-01");
|
||||
$this->date_to=$date->format("Y-m-t");
|
||||
$this->kontrahenci=[];
|
||||
}
|
||||
|
||||
public function getDocuments(){
|
||||
$query="select * from ecmstockdocinsideins where deleted=0 and register_date >='".$this->date_from."' and register_date <='".$this->date_to."' order by document_no ASC";
|
||||
|
||||
$rs = $this->db->query($query);
|
||||
global $app_list_strings;
|
||||
$documents=array();
|
||||
while($dane = $this->db->fetchByAssoc($rs)){
|
||||
$dokument = new Dokument();
|
||||
$kontrahent = new Kontrahent();
|
||||
|
||||
$dokument->typ_dokumentu=(string)'PW';
|
||||
|
||||
$dokument->status_dokumentu=1;
|
||||
$dokument->status_rejestracji_fiskalnej=0;
|
||||
$dokument->numer_dokumentu=0;
|
||||
$dokument->numer_dokumentu_dostawcy=$dane['document_no'];
|
||||
$dokument->rozszerzenie_numeru=(string)"PW";
|
||||
$dokument->pelny_numer_dokumentu=$dane['document_no'];
|
||||
|
||||
$dokument->numer_dokumentu_korygowanego=null;
|
||||
$dokument->data_wystawienia_korekty=null;
|
||||
$dane['parent_nip']=$kontrahent->to_vatid;
|
||||
$letters = substr($dane['parent_nip'],0,2);
|
||||
if(ctype_alpha ($letters)){
|
||||
$rest = substr($dane['parent_nip'],2);
|
||||
$dane['parent_nip']=$letters.' '.$rest;
|
||||
}
|
||||
$dokument->numer_zamowienia="";
|
||||
$dokument->magazyn_docelowy=null;
|
||||
$a = new Account();
|
||||
$a->retrieve($dane['parent_id']);
|
||||
$a->name=str_replace("\r\n","",$a->name);
|
||||
$kontrahent->typ_kontrahenta=(float)0;
|
||||
$kontrahent->kod_identyfikacyjny=$a->number;
|
||||
$kontrahent->nazwa_skrocona=mb_substr($dane['parent_name'],0,40,'UTF-8');
|
||||
$kontrahent->nazwa_pelna=str_replace("\r\n","",$dane['parent_name']);
|
||||
$kontrahent->miasto=$dane['parent_address_city'];
|
||||
$kontrahent->kod_pocztowy=$a->billing_address_postalcode;
|
||||
$kontrahent->ulica_i_adres=$dane['parent_address_street'];
|
||||
$kontrahent->nip=$dane['parent_nip'];
|
||||
if($a->invoice_type=='U'){
|
||||
$kontrahent->prefix=mb_substr($a->to_vatid,0,2,'UTF-8');
|
||||
$kontrahent->czy_unijny=1;
|
||||
} else {
|
||||
$kontrahent->czy_unijny=0;
|
||||
}
|
||||
$this->kontrahenci[$a->id]=$kontrahent;
|
||||
$dokument->kod_identyfikacyjny_kontrahenta=$a->number;
|
||||
$dokument->nazwa_skrocona=mb_substr($dane['parent_name'],0,40,'UTF-8');
|
||||
$dokument->nazwa_pelna=str_replace("\r\n","",$dane['parent_name']);
|
||||
$dokument->miasto=$dane['parent_address_city'];
|
||||
$dokument->kod_pocztowy=$a->billing_address_postalcode;
|
||||
$dokument->ulica_i_numer=$dane['parent_address_street'];
|
||||
$dokument->nip=$dane['parent_nip'];
|
||||
|
||||
$s = new EcmStock();
|
||||
$s->retrieve($dane['stock_id']);
|
||||
$dokument->kategoria=$s->name;
|
||||
$dokument->podtytul='';
|
||||
|
||||
$dokument->data_wystawienia=date("Ymd000000",strtotime($dane['register_date']));
|
||||
$dokument->data_sprzedazy=date("Ymd000000",strtotime($dane['register_date']));
|
||||
$dokument->data_otrzymania=date("Ymd000000",strtotime($dane['register_date']));
|
||||
|
||||
$dokument->czy_dokumenty_wystawian_wg_ceny_netto=0;
|
||||
$dokument->wartosc_netto=(float)$dane['total'];
|
||||
$dokument->wartosc_vat=(float)$dane['total_vat'];
|
||||
$dokument->wartosc_brutto=(float)$dane['total'];
|
||||
$dokument->koszt=(float)$dane['total'];
|
||||
$dokument->rabat_format_platnosci=$app_list_strings['payment_method'][$dane['payment_method']];
|
||||
$dokument->rabat_termin_platnosci=date("Ymd000000",strtotime($dane['payment_date']));
|
||||
|
||||
$dokument->kwota_zaplacona_przy_odbiorze=(float)0;
|
||||
$dokument->wartosc_do_zaplaty=(float)0;
|
||||
|
||||
$dokument->zaokraglenie_wartosci_do_zaplaty=0;
|
||||
$dokument->zaokraglenie_wartosci_vat=0;
|
||||
|
||||
$dokument->automatyczne_zaokgraglanie=0;
|
||||
$dokument->statusy_rozszerzone_i_specjalne=0;
|
||||
$u = new User();
|
||||
$u->retrieve($dane['assigned_user_id']);
|
||||
$dokument->nazwisko_i_imie_wystawcy=$u->full_name;
|
||||
|
||||
$dokument->waluta='PLN';
|
||||
|
||||
|
||||
$dokument->uwagi=str_replace("\r\n","",$dane['pdf_text']);
|
||||
$dokument->import_dokumentu=0;
|
||||
|
||||
$dokument->rodzaj_transakcji=0;
|
||||
|
||||
|
||||
//$dokument->panstwo_kontrahenta=$a->billing_address_country;
|
||||
|
||||
|
||||
|
||||
//$dokument->setPozycjeObiekt($this->getDocumentPositions($dane['id'],$dokument));
|
||||
|
||||
$documents[]=$dokument;
|
||||
|
||||
}
|
||||
return $documents;
|
||||
}
|
||||
|
||||
public function getDocumentPositions($id,&$doc){
|
||||
$query="select * from ecminvoiceoutitems where ecminvoiceout_id='".$id."' and deleted=0";
|
||||
|
||||
$rr=$this->db->query($query);
|
||||
|
||||
$pozycje=[];
|
||||
while($dane=$this->db->fetchByAssoc($rr)){
|
||||
if($pozycje[$dane ['ecmvat_value']]!=""){
|
||||
$obiekt = $pozycje[$dane ['ecmvat_value']];
|
||||
if ($doc->typ_dokumentu!= 'FS') {
|
||||
$obiekt->wartosc_netto+= $dane ['total_netto_corrected'];
|
||||
$obiekt->wartosc_vat+= $dane ['total_vat_corrected'];
|
||||
$obiekt->wartosc_brutto+= $dane ['total_brutto_corrected'];
|
||||
} else {
|
||||
$obiekt->wartosc_netto+= $dane ['total_netto'];
|
||||
$obiekt->wartosc_vat+= $dane ['total_vat'];
|
||||
$obiekt->wartosc_brutto+= $dane ['total_brutto'];
|
||||
}
|
||||
$obiekt->wartosc_nabycia+= round ( $dane ['price_purchase'] * $dane ['quantity'], 2 );
|
||||
$pozycje[$dane ['ecmvat_value']]=$obiekt;
|
||||
} else {
|
||||
$pozycja = new Pozycja;
|
||||
$pozycja->symbol_stawki_vat = $dane ['ecmvat_value'];
|
||||
$pozycja->wysokosc_stawki_vat_w_procentach = floatval ($dane ['ecmvat_value'] . '.00');
|
||||
if ($doc->typ_dokumentu!= 'FS') {
|
||||
$pozycja->wartosc_netto =floatval($dane ['total_netto_corrected']);
|
||||
$pozycja->wartosc_vat = floatval($dane ['total_vat_corrected']);
|
||||
$pozycja->wartosc_brutto =floatval($dane ['total_brutto_corrected']);
|
||||
} else {
|
||||
$pozycja->wartosc_netto = floatval($dane ['total_netto']);
|
||||
$pozycja->wartosc_vat = floatval($dane ['total_vat']);
|
||||
$pozycja->wartosc_brutto = floatval($dane ['total_brutto']);
|
||||
}
|
||||
$pozycja->wartosc_nabycia = round ( $dane ['price_purchase'] * $dane ['quantity'], 2 );
|
||||
$pozycje[$dane ['ecmvat_value']]=$pozycja;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$doc->pozycje=count($pozycja);
|
||||
|
||||
return $pozycje;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
167
modules/EcmReports/RewizorGT/PzCreator.php
Normal file
167
modules/EcmReports/RewizorGT/PzCreator.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
class PzCreator{
|
||||
|
||||
private $db;
|
||||
public $kontrahenci;
|
||||
|
||||
public function __construct($date){
|
||||
$this->db=$GLOBALS['db'];
|
||||
$date = new DateTime($date);
|
||||
$this->date_from = $date->format("Y-m-01");
|
||||
$this->date_to=$date->format("Y-m-t");
|
||||
$this->kontrahenci=[];
|
||||
}
|
||||
|
||||
public function getDocuments(){
|
||||
$query="select * from ecmstockdocins where deleted=0 and register_date >='".$this->date_from."' and register_date <='".$this->date_to."' order by document_no ASC";
|
||||
|
||||
$rs = $this->db->query($query);
|
||||
global $app_list_strings;
|
||||
$documents=array();
|
||||
while($dane = $this->db->fetchByAssoc($rs)){
|
||||
$dokument = new Dokument();
|
||||
$kontrahent = new Kontrahent();
|
||||
|
||||
$dokument->typ_dokumentu=(string)'PZ';
|
||||
|
||||
$dokument->status_dokumentu=1;
|
||||
$dokument->status_rejestracji_fiskalnej=0;
|
||||
$dokument->numer_dokumentu=0;
|
||||
$dokument->numer_dokumentu_dostawcy=$dane['document_no'];
|
||||
$dokument->rozszerzenie_numeru=(string)"PZ";
|
||||
$dokument->pelny_numer_dokumentu=$dane['document_no'];
|
||||
|
||||
$dokument->numer_dokumentu_korygowanego=null;
|
||||
$dokument->data_wystawienia_korekty=null;
|
||||
$dane['parent_nip']=$kontrahent->to_vatid;
|
||||
$letters = substr($dane['parent_nip'],0,2);
|
||||
if(ctype_alpha ($letters)){
|
||||
$rest = substr($dane['parent_nip'],2);
|
||||
$dane['parent_nip']=$letters.' '.$rest;
|
||||
}
|
||||
$dokument->numer_zamowienia="";
|
||||
$dokument->magazyn_docelowy=null;
|
||||
$a = new Account();
|
||||
$a->retrieve($dane['parent_id']);
|
||||
$a->name=str_replace("\r\n","",$a->name);
|
||||
$dane['parent_name']=str_replace("\r\n","",$dane['parent_name']);
|
||||
$kontrahent->typ_kontrahenta=(float)0;
|
||||
$kontrahent->kod_identyfikacyjny=$a->number;
|
||||
$kontrahent->nazwa_skrocona=mb_substr($dane['parent_name'],0,40,'UTF-8');
|
||||
$kontrahent->nazwa_pelna=str_replace("\r\n","",$dane['parent_name']);
|
||||
$kontrahent->miasto=$dane['parent_address_city'];
|
||||
$kontrahent->kod_pocztowy=$a->billing_address_postalcode;
|
||||
$kontrahent->ulica_i_adres=str_replace("\n","",str_replace("\r\n","",$dane['parent_address_street']));
|
||||
$kontrahent->nip=$dane['parent_nip'];
|
||||
if($a->invoice_type=='U'){
|
||||
$kontrahent->prefix=mb_substr($a->to_vatid,0,2,'UTF-8');
|
||||
$kontrahent->czy_unijny=1;
|
||||
} else {
|
||||
$kontrahent->czy_unijny=0;
|
||||
}
|
||||
$this->kontrahenci[$a->id]=$kontrahent;
|
||||
$dokument->kod_identyfikacyjny_kontrahenta=$a->number;
|
||||
$dokument->nazwa_skrocona=mb_substr($dane['parent_name'],0,40,'UTF-8');
|
||||
$dokument->nazwa_pelna=str_replace("\r\n","",$dane['parent_name']);
|
||||
$dokument->miasto=$dane['parent_address_city'];
|
||||
$dokument->kod_pocztowy=$a->billing_address_postalcode;
|
||||
$dokument->ulica_i_numer=$a->billing_address_street;
|
||||
$dokument->nip=$dane['parent_nip'];
|
||||
|
||||
$s = new EcmStock();
|
||||
$s->retrieve($dane['stock_id']);
|
||||
$dokument->kategoria=$s->name;
|
||||
$dokument->podtytul='';
|
||||
|
||||
$dokument->data_wystawienia=date("Ymd000000",strtotime($dane['register_date']));
|
||||
$dokument->data_sprzedazy=date("Ymd000000",strtotime($dane['data_fk']));
|
||||
$dokument->data_otrzymania=date("Ymd000000",strtotime($dane['register_date']));
|
||||
|
||||
$dokument->czy_dokumenty_wystawian_wg_ceny_netto=0;
|
||||
$dokument->wartosc_netto=(float)$dane['subtotal'];
|
||||
$dokument->wartosc_vat=(float)$dane['total_vat'];
|
||||
$dokument->wartosc_brutto=(float)$dane['subtotal'];
|
||||
$dokument->koszt=(float)$dane['subtotal'];
|
||||
$dokument->rabat_format_platnosci=$app_list_strings['payment_method'][$dane['payment_method']];
|
||||
$dokument->rabat_termin_platnosci=date("Ymd000000",strtotime($dane['payment_date']));
|
||||
|
||||
$dokument->kwota_zaplacona_przy_odbiorze=(float)0;
|
||||
$dokument->wartosc_do_zaplaty=(float)0;
|
||||
|
||||
$dokument->zaokraglenie_wartosci_do_zaplaty=0;
|
||||
$dokument->zaokraglenie_wartosci_vat=0;
|
||||
|
||||
$dokument->automatyczne_zaokgraglanie=0;
|
||||
$dokument->statusy_rozszerzone_i_specjalne=0;
|
||||
$u = new User();
|
||||
$u->retrieve($dane['assigned_user_id']);
|
||||
$dokument->nazwisko_i_imie_wystawcy=$u->full_name;
|
||||
|
||||
$dokument->waluta='PLN';
|
||||
|
||||
|
||||
$dokument->uwagi=str_replace("\r\n","",$dane['pdf_text']);
|
||||
$dokument->import_dokumentu=0;
|
||||
|
||||
$dokument->rodzaj_transakcji=0;
|
||||
|
||||
|
||||
//$dokument->panstwo_kontrahenta=$a->billing_address_country;
|
||||
|
||||
|
||||
|
||||
//$dokument->setPozycjeObiekt($this->getDocumentPositions($dane['id'],$dokument));
|
||||
|
||||
$documents[]=$dokument;
|
||||
|
||||
}
|
||||
return $documents;
|
||||
}
|
||||
|
||||
public function getDocumentPositions($id,&$doc){
|
||||
$query="select * from ecminvoiceoutitems where ecminvoiceout_id='".$id."' and deleted=0";
|
||||
|
||||
$rr=$this->db->query($query);
|
||||
|
||||
$pozycje=[];
|
||||
while($dane=$this->db->fetchByAssoc($rr)){
|
||||
if($pozycje[$dane ['ecmvat_value']]!=""){
|
||||
$obiekt = $pozycje[$dane ['ecmvat_value']];
|
||||
if ($doc->typ_dokumentu!= 'FS') {
|
||||
$obiekt->wartosc_netto+= $dane ['total_netto_corrected'];
|
||||
$obiekt->wartosc_vat+= $dane ['total_vat_corrected'];
|
||||
$obiekt->wartosc_brutto+= $dane ['total_brutto_corrected'];
|
||||
} else {
|
||||
$obiekt->wartosc_netto+= $dane ['total_netto'];
|
||||
$obiekt->wartosc_vat+= $dane ['total_vat'];
|
||||
$obiekt->wartosc_brutto+= $dane ['total_brutto'];
|
||||
}
|
||||
$obiekt->wartosc_nabycia+= round ( $dane ['price_purchase'] * $dane ['quantity'], 2 );
|
||||
$pozycje[$dane ['ecmvat_value']]=$obiekt;
|
||||
} else {
|
||||
$pozycja = new Pozycja;
|
||||
$pozycja->symbol_stawki_vat = $dane ['ecmvat_value'];
|
||||
$pozycja->wysokosc_stawki_vat_w_procentach = floatval ($dane ['ecmvat_value'] . '.00');
|
||||
if ($doc->typ_dokumentu!= 'FS') {
|
||||
$pozycja->wartosc_netto =floatval($dane ['total_netto_corrected']);
|
||||
$pozycja->wartosc_vat = floatval($dane ['total_vat_corrected']);
|
||||
$pozycja->wartosc_brutto =floatval($dane ['total_brutto_corrected']);
|
||||
} else {
|
||||
$pozycja->wartosc_netto = floatval($dane ['total_netto']);
|
||||
$pozycja->wartosc_vat = floatval($dane ['total_vat']);
|
||||
$pozycja->wartosc_brutto = floatval($dane ['total_brutto']);
|
||||
}
|
||||
$pozycja->wartosc_nabycia = round ( $dane ['price_purchase'] * $dane ['quantity'], 2 );
|
||||
$pozycje[$dane ['ecmvat_value']]=$pozycja;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$doc->pozycje=count($pozycja);
|
||||
|
||||
return $pozycje;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
166
modules/EcmReports/RewizorGT/RwCreator.php
Normal file
166
modules/EcmReports/RewizorGT/RwCreator.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
class RwCreator{
|
||||
|
||||
private $db;
|
||||
public $kontrahenci;
|
||||
|
||||
public function __construct($date){
|
||||
$this->db=$GLOBALS['db'];
|
||||
$date = new DateTime($date);
|
||||
$this->date_from = $date->format("Y-m-01");
|
||||
$this->date_to=$date->format("Y-m-t");
|
||||
$this->kontrahenci=[];
|
||||
}
|
||||
|
||||
public function getDocuments(){
|
||||
$query="select * from ecmstockdocinsideouts where deleted=0 and register_date >='".$this->date_from."' and register_date <='".$this->date_to."' order by document_no ASC";
|
||||
|
||||
$rs = $this->db->query($query);
|
||||
global $app_list_strings;
|
||||
$documents=array();
|
||||
while($dane = $this->db->fetchByAssoc($rs)){
|
||||
$dokument = new Dokument();
|
||||
$kontrahent = new Kontrahent();
|
||||
|
||||
$dokument->typ_dokumentu=(string)'RW';
|
||||
|
||||
$dokument->status_dokumentu=1;
|
||||
$dokument->status_rejestracji_fiskalnej=0;
|
||||
$dokument->numer_dokumentu=0;
|
||||
$dokument->numer_dokumentu_dostawcy=$dane['document_no'];
|
||||
$dokument->rozszerzenie_numeru=(string)"RW";
|
||||
$dokument->pelny_numer_dokumentu=$dane['document_no'];
|
||||
|
||||
$dokument->numer_dokumentu_korygowanego=null;
|
||||
$dokument->data_wystawienia_korekty=null;
|
||||
$dane['parent_nip']=$kontrahent->to_vatid;
|
||||
$letters = substr($dane['parent_nip'],0,2);
|
||||
if(ctype_alpha ($letters)){
|
||||
$rest = substr($dane['parent_nip'],2);
|
||||
$dane['parent_nip']=$letters.' '.$rest;
|
||||
}
|
||||
$dokument->numer_zamowienia="";
|
||||
$dokument->magazyn_docelowy=null;
|
||||
$a = new Account();
|
||||
$a->retrieve($dane['parent_id']);
|
||||
$a->name=str_replace("\r\n","",$a->name);
|
||||
$kontrahent->typ_kontrahenta=(float)0;
|
||||
$kontrahent->kod_identyfikacyjny=$a->number;
|
||||
$kontrahent->nazwa_skrocona=mb_substr($dane['parent_name'],0,40,'UTF-8');
|
||||
$kontrahent->nazwa_pelna=str_replace("\r\n","",$dane['parent_name']);
|
||||
$kontrahent->miasto=$dane['parent_address_city'];
|
||||
$kontrahent->kod_pocztowy=$a->billing_address_postalcode;
|
||||
$kontrahent->ulica_i_adres=$dane['parent_address_street'];
|
||||
$kontrahent->nip=$dane['parent_nip'];
|
||||
if($a->invoice_type=='U'){
|
||||
$kontrahent->prefix=mb_substr($a->to_vatid,0,2,'UTF-8');
|
||||
$kontrahent->czy_unijny=1;
|
||||
} else {
|
||||
$kontrahent->czy_unijny=0;
|
||||
}
|
||||
$this->kontrahenci[$a->id]=$kontrahent;
|
||||
$dokument->kod_identyfikacyjny_kontrahenta=$a->number;
|
||||
$dokument->nazwa_skrocona=mb_substr($dane['parent_name'],0,40,'UTF-8');
|
||||
$dokument->nazwa_pelna=str_replace("\r\n","",$dane['parent_name']);
|
||||
$dokument->miasto=$dane['parent_address_city'];
|
||||
$dokument->kod_pocztowy=$a->billing_address_postalcode;
|
||||
$dokument->ulica_i_numer=$dane['parent_address_street'];
|
||||
$dokument->nip=$dane['parent_nip'];
|
||||
|
||||
$s = new EcmStock();
|
||||
$s->retrieve($dane['stock_id']);
|
||||
$dokument->kategoria=$s->name;
|
||||
$dokument->podtytul='';
|
||||
|
||||
$dokument->data_wystawienia=date("Ymd000000",strtotime($dane['register_date']));
|
||||
$dokument->data_sprzedazy=date("Ymd000000",strtotime($dane['register_date']));
|
||||
$dokument->data_otrzymania=date("Ymd000000",strtotime($dane['register_date']));
|
||||
|
||||
$dokument->czy_dokumenty_wystawian_wg_ceny_netto=0;
|
||||
$dokument->wartosc_netto=(float)$dane['total'];
|
||||
$dokument->wartosc_vat=(float)$dane['total_vat'];
|
||||
$dokument->wartosc_brutto=(float)$dane['total'];
|
||||
$dokument->koszt=(float)$dane['total'];
|
||||
$dokument->rabat_format_platnosci=$app_list_strings['payment_method'][$dane['payment_method']];
|
||||
$dokument->rabat_termin_platnosci=date("Ymd000000",strtotime($dane['payment_date']));
|
||||
|
||||
$dokument->kwota_zaplacona_przy_odbiorze=(float)0;
|
||||
$dokument->wartosc_do_zaplaty=(float)0;
|
||||
|
||||
$dokument->zaokraglenie_wartosci_do_zaplaty=0;
|
||||
$dokument->zaokraglenie_wartosci_vat=0;
|
||||
|
||||
$dokument->automatyczne_zaokgraglanie=0;
|
||||
$dokument->statusy_rozszerzone_i_specjalne=0;
|
||||
$u = new User();
|
||||
$u->retrieve($dane['assigned_user_id']);
|
||||
$dokument->nazwisko_i_imie_wystawcy=$u->full_name;
|
||||
|
||||
$dokument->waluta='PLN';
|
||||
|
||||
|
||||
$dokument->uwagi=str_replace("\r\n","",$dane['pdf_text']);
|
||||
$dokument->import_dokumentu=0;
|
||||
|
||||
$dokument->rodzaj_transakcji=0;
|
||||
|
||||
|
||||
//$dokument->panstwo_kontrahenta=$a->billing_address_country;
|
||||
|
||||
|
||||
|
||||
//$dokument->setPozycjeObiekt($this->getDocumentPositions($dane['id'],$dokument));
|
||||
|
||||
$documents[]=$dokument;
|
||||
|
||||
}
|
||||
return $documents;
|
||||
}
|
||||
|
||||
public function getDocumentPositions($id,&$doc){
|
||||
$query="select * from ecminvoiceoutitems where ecminvoiceout_id='".$id."' and deleted=0";
|
||||
|
||||
$rr=$this->db->query($query);
|
||||
|
||||
$pozycje=[];
|
||||
while($dane=$this->db->fetchByAssoc($rr)){
|
||||
if($pozycje[$dane ['ecmvat_value']]!=""){
|
||||
$obiekt = $pozycje[$dane ['ecmvat_value']];
|
||||
if ($doc->typ_dokumentu!= 'FS') {
|
||||
$obiekt->wartosc_netto+= $dane ['total_netto_corrected'];
|
||||
$obiekt->wartosc_vat+= $dane ['total_vat_corrected'];
|
||||
$obiekt->wartosc_brutto+= $dane ['total_brutto_corrected'];
|
||||
} else {
|
||||
$obiekt->wartosc_netto+= $dane ['total_netto'];
|
||||
$obiekt->wartosc_vat+= $dane ['total_vat'];
|
||||
$obiekt->wartosc_brutto+= $dane ['total_brutto'];
|
||||
}
|
||||
$obiekt->wartosc_nabycia+= round ( $dane ['price_purchase'] * $dane ['quantity'], 2 );
|
||||
$pozycje[$dane ['ecmvat_value']]=$obiekt;
|
||||
} else {
|
||||
$pozycja = new Pozycja;
|
||||
$pozycja->symbol_stawki_vat = $dane ['ecmvat_value'];
|
||||
$pozycja->wysokosc_stawki_vat_w_procentach = floatval ($dane ['ecmvat_value'] . '.00');
|
||||
if ($doc->typ_dokumentu!= 'FS') {
|
||||
$pozycja->wartosc_netto =floatval($dane ['total_netto_corrected']);
|
||||
$pozycja->wartosc_vat = floatval($dane ['total_vat_corrected']);
|
||||
$pozycja->wartosc_brutto =floatval($dane ['total_brutto_corrected']);
|
||||
} else {
|
||||
$pozycja->wartosc_netto = floatval($dane ['total_netto']);
|
||||
$pozycja->wartosc_vat = floatval($dane ['total_vat']);
|
||||
$pozycja->wartosc_brutto = floatval($dane ['total_brutto']);
|
||||
}
|
||||
$pozycja->wartosc_nabycia = round ( $dane ['price_purchase'] * $dane ['quantity'], 2 );
|
||||
$pozycje[$dane ['ecmvat_value']]=$pozycja;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$doc->pozycje=count($pozycja);
|
||||
|
||||
return $pozycje;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
167
modules/EcmReports/RewizorGT/WzCreator.php
Normal file
167
modules/EcmReports/RewizorGT/WzCreator.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
class WzCreator{
|
||||
|
||||
private $db;
|
||||
public $kontrahenci;
|
||||
|
||||
public function __construct($date){
|
||||
$this->db=$GLOBALS['db'];
|
||||
$date = new DateTime($date);
|
||||
$this->date_from = $date->format("Y-m-01");
|
||||
$this->date_to=$date->format("Y-m-t");
|
||||
$this->kontrahenci=[];
|
||||
}
|
||||
|
||||
public function getDocuments(){
|
||||
$query="select * from ecmstockdocouts where deleted=0 and register_date >='".$this->date_from."' and register_date <='".$this->date_to."' order by document_no ASC";
|
||||
|
||||
$rs = $this->db->query($query);
|
||||
global $app_list_strings;
|
||||
$documents=array();
|
||||
while($dane = $this->db->fetchByAssoc($rs)){
|
||||
$dokument = new Dokument();
|
||||
$kontrahent = new Kontrahent();
|
||||
|
||||
$dokument->typ_dokumentu=(string)'WZ';
|
||||
|
||||
$dokument->status_dokumentu=1;
|
||||
$dokument->status_rejestracji_fiskalnej=0;
|
||||
$dokument->numer_dokumentu=0;
|
||||
$dokument->numer_dokumentu_dostawcy=$dane['document_no'];
|
||||
$dokument->rozszerzenie_numeru=(string)"WZ";
|
||||
$dokument->pelny_numer_dokumentu=$dane['document_no'];
|
||||
|
||||
$dokument->numer_dokumentu_korygowanego=null;
|
||||
$dokument->data_wystawienia_korekty=null;
|
||||
$dane['parent_nip']=$kontrahent->to_vatid;
|
||||
$letters = substr($dane['parent_nip'],0,2);
|
||||
if(ctype_alpha ($letters)){
|
||||
$rest = substr($dane['parent_nip'],2);
|
||||
$dane['parent_nip']=$letters.' '.$rest;
|
||||
}
|
||||
$dokument->numer_zamowienia="";
|
||||
$dokument->magazyn_docelowy=null;
|
||||
$a = new Account();
|
||||
$a->retrieve($dane['parent_id']);
|
||||
$a->name=str_replace("\r\n","",$a->name);
|
||||
$dane['parent_name']=str_replace("\r\n","",$dane['parent_name']);
|
||||
$kontrahent->typ_kontrahenta=(float)0;
|
||||
$kontrahent->kod_identyfikacyjny=$a->number;
|
||||
$kontrahent->nazwa_skrocona=mb_substr($dane['parent_name'],0,40,'UTF-8');
|
||||
$kontrahent->nazwa_pelna=str_replace("\r\n","",$dane['parent_name']);
|
||||
$kontrahent->miasto=$dane['parent_address_city'];
|
||||
$kontrahent->kod_pocztowy=$a->billing_address_postalcode;
|
||||
$kontrahent->ulica_i_adres=str_replace("\n"," ",str_replace("\r\n"," ",$dane['parent_address_street']));
|
||||
$kontrahent->nip=$dane['parent_nip'];
|
||||
if($a->invoice_type=='U'){
|
||||
$kontrahent->prefix=mb_substr($a->to_vatid,0,2,'UTF-8');
|
||||
$kontrahent->czy_unijny=1;
|
||||
} else {
|
||||
$kontrahent->czy_unijny=0;
|
||||
}
|
||||
$this->kontrahenci[$a->id]=$kontrahent;
|
||||
$dokument->kod_identyfikacyjny_kontrahenta=$a->number;
|
||||
$dokument->nazwa_skrocona=mb_substr($dane['parent_name'],0,40,'UTF-8');
|
||||
$dokument->nazwa_pelna=str_replace("\r\n","",$dane['parent_name']);
|
||||
$dokument->miasto=$dane['parent_address_city'];
|
||||
$dokument->kod_pocztowy=$a->billing_address_postalcode;
|
||||
$dokument->ulica_i_numer=$a->billing_address_street;
|
||||
$dokument->nip=$dane['parent_nip'];
|
||||
|
||||
$s = new EcmStock();
|
||||
$s->retrieve($dane['stock_id']);
|
||||
$dokument->kategoria=$s->name;
|
||||
$dokument->podtytul='';
|
||||
|
||||
$dokument->data_wystawienia=date("Ymd000000",strtotime($dane['register_date']));
|
||||
$dokument->data_sprzedazy=date("Ymd000000",strtotime($dane['register_date']));
|
||||
$dokument->data_otrzymania=date("Ymd000000",strtotime($dane['register_date']));
|
||||
|
||||
$dokument->czy_dokumenty_wystawian_wg_ceny_netto=0;
|
||||
$dokument->wartosc_netto=(float)$dane['total'];
|
||||
$dokument->wartosc_vat=(float)$dane['total_vat'];
|
||||
$dokument->wartosc_brutto=(float)$dane['total'];
|
||||
$dokument->koszt=(float)$dane['total'];
|
||||
$dokument->rabat_format_platnosci=$app_list_strings['payment_method'][$dane['payment_method']];
|
||||
$dokument->rabat_termin_platnosci=date("Ymd000000",strtotime($dane['payment_date']));
|
||||
|
||||
$dokument->kwota_zaplacona_przy_odbiorze=(float)0;
|
||||
$dokument->wartosc_do_zaplaty=(float)0;
|
||||
|
||||
$dokument->zaokraglenie_wartosci_do_zaplaty=0;
|
||||
$dokument->zaokraglenie_wartosci_vat=0;
|
||||
|
||||
$dokument->automatyczne_zaokgraglanie=0;
|
||||
$dokument->statusy_rozszerzone_i_specjalne=0;
|
||||
$u = new User();
|
||||
$u->retrieve($dane['assigned_user_id']);
|
||||
$dokument->nazwisko_i_imie_wystawcy=$u->full_name;
|
||||
|
||||
$dokument->waluta='PLN';
|
||||
|
||||
|
||||
$dokument->uwagi=str_replace("\r\n","",$dane['pdf_text']);
|
||||
$dokument->import_dokumentu=0;
|
||||
|
||||
$dokument->rodzaj_transakcji=0;
|
||||
|
||||
|
||||
//$dokument->panstwo_kontrahenta=$a->billing_address_country;
|
||||
|
||||
|
||||
|
||||
//$dokument->setPozycjeObiekt($this->getDocumentPositions($dane['id'],$dokument));
|
||||
|
||||
$documents[]=$dokument;
|
||||
|
||||
}
|
||||
return $documents;
|
||||
}
|
||||
|
||||
public function getDocumentPositions($id,&$doc){
|
||||
$query="select * from ecminvoiceoutitems where ecminvoiceout_id='".$id."' and deleted=0";
|
||||
|
||||
$rr=$this->db->query($query);
|
||||
|
||||
$pozycje=[];
|
||||
while($dane=$this->db->fetchByAssoc($rr)){
|
||||
if($pozycje[$dane ['ecmvat_value']]!=""){
|
||||
$obiekt = $pozycje[$dane ['ecmvat_value']];
|
||||
if ($doc->typ_dokumentu!= 'FS') {
|
||||
$obiekt->wartosc_netto+= $dane ['total_netto_corrected'];
|
||||
$obiekt->wartosc_vat+= $dane ['total_vat_corrected'];
|
||||
$obiekt->wartosc_brutto+= $dane ['total_brutto_corrected'];
|
||||
} else {
|
||||
$obiekt->wartosc_netto+= $dane ['total_netto'];
|
||||
$obiekt->wartosc_vat+= $dane ['total_vat'];
|
||||
$obiekt->wartosc_brutto+= $dane ['total_brutto'];
|
||||
}
|
||||
$obiekt->wartosc_nabycia+= round ( $dane ['price_purchase'] * $dane ['quantity'], 2 );
|
||||
$pozycje[$dane ['ecmvat_value']]=$obiekt;
|
||||
} else {
|
||||
$pozycja = new Pozycja;
|
||||
$pozycja->symbol_stawki_vat = $dane ['ecmvat_value'];
|
||||
$pozycja->wysokosc_stawki_vat_w_procentach = floatval ($dane ['ecmvat_value'] . '.00');
|
||||
if ($doc->typ_dokumentu!= 'FS') {
|
||||
$pozycja->wartosc_netto =floatval($dane ['total_netto_corrected']);
|
||||
$pozycja->wartosc_vat = floatval($dane ['total_vat_corrected']);
|
||||
$pozycja->wartosc_brutto =floatval($dane ['total_brutto_corrected']);
|
||||
} else {
|
||||
$pozycja->wartosc_netto = floatval($dane ['total_netto']);
|
||||
$pozycja->wartosc_vat = floatval($dane ['total_vat']);
|
||||
$pozycja->wartosc_brutto = floatval($dane ['total_brutto']);
|
||||
}
|
||||
$pozycja->wartosc_nabycia = round ( $dane ['price_purchase'] * $dane ['quantity'], 2 );
|
||||
$pozycje[$dane ['ecmvat_value']]=$pozycja;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$doc->pozycje=count($pozycja);
|
||||
|
||||
return $pozycje;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
53
modules/EcmReports/RewizorGT/form.tpl.html
Normal file
53
modules/EcmReports/RewizorGT/form.tpl.html
Normal file
@@ -0,0 +1,53 @@
|
||||
|
||||
<ul class="tablist" style="width:100%;">
|
||||
<li>
|
||||
<a class="current" href="#">Eksport dokumentów REWIZOR</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<form action="index.php">
|
||||
<table style="border-top: 0px none; margin-bottom: 4px;width:100%" class="tabForm" border="0" cellpadding="0" cellspacing="0">
|
||||
|
||||
<tr>
|
||||
<td class="dataLabel" width="5%" nowrap="nowrap"> Wybierz miesiąc: </td>
|
||||
<td class="dataField" width="10%" nowrap="nowrap">
|
||||
<input type="hidden" name="action" value="RewizorGT">
|
||||
<input type="hidden" name="module" value="EcmReports">
|
||||
<input type="hidden" name="to_pdf" value="1">
|
||||
<input id="date" name="date" type="text" maxlength="10" size="11" tabindex="" title="Data " value="{$date}" autocomplete="off">
|
||||
<img id="date_trigger" border="0" align="absmiddle" alt="Enter Date" src="themes/default/images/jscalendar.gif">
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
Calendar.setup({ldelim}
|
||||
inputField: "date",
|
||||
daFormat: "{$dateFormat}",
|
||||
button: "date_trigger",
|
||||
singleClick: true,
|
||||
dateStr: "",
|
||||
step: 1
|
||||
{rdelim}
|
||||
);
|
||||
</script>
|
||||
</td>
|
||||
<td class="dataLabel" width="5%" nowrap="nowrap">Wybierz typ dokumentów: </td>
|
||||
<td class="dataField" width="10%" nowrap="nowrap">
|
||||
|
||||
<select name="documents[]" multiple required="required">
|
||||
<option value="fs">Faktury sprzedaży</option>
|
||||
<option value="fz-all">Faktury zakupu - wszystkie</option>
|
||||
<option value="fz-new">Faktury zakupu - nowe</option>
|
||||
<option value="pz">Dokument PZ</option>
|
||||
<option value="wz">Dokument WZ</option>
|
||||
<option value="rw">Dokument RW</option>
|
||||
<option value="pw">Dokument PW</option>
|
||||
<option value="mm">Dokument MM</option>
|
||||
<option value="ks">Dokument KS</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<br><input type="submit" value="Generuj" name="submit">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
Reference in New Issue
Block a user