diff --git a/include/XMLDocument/xml_reader.class.php b/include/XMLDocument/xml_reader.class.php index 49c039863..2995a374f 100644 --- a/include/XMLDocument/xml_reader.class.php +++ b/include/XMLDocument/xml_reader.class.php @@ -258,7 +258,20 @@ abstract class XML_Reader $result['postcode'] = $this->get_node_value("//cac:AccountingSupplierParty[1]/cac:Party[1]/cac:PostalAddress[1]/cbc:PostalZone[1]"); $result['country_code'] = $this->get_node_value("//cac:AccountingSupplierParty[1]/cac:Party[1]/cac:PostalAddress[1]/cac:Country[1]/cbc:IdentificationCode[1]"); $result['company_id'] = $this->get_node_value("//cac:AccountingSupplierParty[1]/cac:Party[1]/cac:PartyTaxScheme[1]/cbc:CompanyID[1]"); + if ($result['company_id'] == "" ) { + $result['company_id'] = $this->get_node_value("//cac:AccountingSupplierParty[1]/cac:Party[1]/cac:PartyLegalEntity[1]/cbc:CompanyID[1]"); + } $result['scheme'] = $this->get_node("//cac:AccountingSupplierParty[1]/cac:Party[1]/cbc:EndpointID[1]")[0]->getAttribute("schemeID"); + /** + * get contact + + Facturation NOALYSS + invoice@noalyss + + */ + $result['contact_name'] = $this->get_node_value("//cac:AccountingSupplierParty[1]/cac:Party[1]/cac:Contact[1]/cbc:Name[1]"); + $result['contact_mail'] = $this->get_node_value("//cac:AccountingSupplierParty[1]/cac:Party[1]/cac:Contact[1]/cbc:ElectronicMail"); + return $result; } @@ -416,6 +429,7 @@ abstract class XML_Reader public function to_pdf(): PDF { //$pdf = new PDF($cn); + $pdf = new PDF(); $result = $this->get_info(); $info=$result; @@ -426,7 +440,7 @@ abstract class XML_Reader // 180 mm large $pdf->setFont("DejaVu", "B", 16); $pdf->write_cell(20, 10, ""); - $pdf->write_cell(170, 10, _("Résumé facture"),1,0,'C'); + $pdf->write_cell(170, 10, _("Résumé document"),1,0,'C'); $pdf->line_new(10); $pdf->setFont("DejaVu", "", 7); $pdf->write(4, sprintf(_("Document ID %s"), $result['id'])); @@ -445,77 +459,98 @@ abstract class XML_Reader $pdf->ln(10); $pdf->setFont("DejaVu", "B", 12); + $pdf->SetTextColor(0,0,127); $pdf->write_cell(60, 4, _("Fournisseur")); - $pdf->line_new(12); + $pdf->line_new(6); + $pdf->SetTextColor(0,0,0); $supplier = $this->get_supplier(); $pdf->setFont("DejaVu", "", 7); - $pdf->write_cell(60, 4, $supplier['name']); - $pdf->write_cell(60, 4, $supplier['company_id']); - $pdf->write_cell(60, 4,$supplier['scheme'].":". $supplier['ID']); - $pdf->line_new(); - $pdf->write_cell(60, 4, $supplier['street']); - $pdf->write_cell(30, 4, $supplier['postcode']); - $pdf->write_cell(60, 4, $supplier['city']); + $pdf->write_multi(50, 4, $supplier['name']); + $pdf->write_multi(50, 4, $supplier['street']); + $pdf->write_multi(30, 4, $supplier['postcode']); + $pdf->write_multi(50, 4, $supplier['city']); $pdf->write_cell(20, 4, $supplier['country_code']); - $pdf->line_new(10); + $pdf->line_new(); + if ( $supplier['contact_name'] != '') { + $pdf->write_multi(60, 4, "contact name:".$supplier['contact_name']); + $pdf->write_multi(50, 4, $supplier['contact_mail']); + $pdf->line_new(); + } + $pdf->write_cell(50, 4, $supplier['company_id']); + $pdf->write_cell(50, 4,'PEPPOL ID:'.$supplier['scheme'].":". $supplier['ID']); + $pdf->line_new(6); $customer = $this->get_customer(); $pdf->setFont("DejaVu", "B", 12); + $pdf->SetTextColor(0,0,127); $pdf->write_cell(60, 4, _("Client")); - $pdf->line_new(10); + $pdf->line_new(6); + $pdf->SetTextColor(0,0,0); $pdf->setFont("DejaVu", "", 7); - $pdf->write_cell(60, 4, $customer['name']); - $pdf->write_cell(60, 4, $customer['company_id']); - $pdf->write_cell(60, 4, $customer['scheme'].":".$customer['ID']); + $pdf->write_multi(50, 4, $customer['name']); + $pdf->write_multi(50, 4, $customer['street']); + $pdf->write_multi(30, 4, $customer['postcode']); + $pdf->write_multi(50, 4, $customer['city']); + $pdf->write_multi(20, 4, $customer['country_code']); $pdf->line_new(); - $pdf->write_cell(60, 4, $customer['street']); - $pdf->write_cell(40, 4, $customer['postcode']); - $pdf->write_cell(60, 4, $customer['city']); - $pdf->write_cell(20, 4, $customer['country_code']); - $pdf->line_new(10); + $pdf->write_cell(50, 4, $customer['company_id']); + $pdf->write_cell(50, 4, 'PEPPOL ID:'.$customer['scheme'].":".$customer['ID']); + $pdf->line_new(6); /** * note invoice */ if ( $info['info']['note'] != "") { + $pdf->SetTextColor(0,0,127); $pdf->setFont("DejaVu", "B", 12); $pdf->write_cell(60, 4, _("Notes")); - $pdf->line_new(10); + $pdf->line_new(6); + $pdf->SetTextColor(0,0,0); $pdf->setFont("DejaVu", "", 7); - $pdf->write_multi(50, 4,$info['info']['note']); + $pdf->write_multi(130, 8,$info['info']['note']); $pdf->line_new(10); } /** * ITEM */ $pdf->setFont("DejaVu", "B", 12); + $pdf->SetTextColor(0,0,127); $pdf->write_cell(60, 4, _("Articles")); - $pdf->line_new(10); + $pdf->line_new(6); + $pdf->SetTextColor(0,0,0); $pdf->setFont("DejaVu", "", 7); $result = $this->get_invoiceLine(); $pdf->write_cell(50, 4, _("Code"), border: 'B'); - $pdf->write_cell(50, 4, _("Description"), border: 'B'); - $pdf->write_cell(30, 4, _("TVA"), border: 'B', align: 'R'); - $pdf->write_cell(25, 4, _("Quantité"), border: 'B', align: 'R'); - $pdf->write_cell(25, 4, _("Montant HT"), border: 'B', align: 'R'); + $pdf->write_cell(60, 4, _("Description"), border: 'B'); + $pdf->write_cell(20, 4, _("TVA"), border: 'B', align: 'R'); + $pdf->write_cell(20, 4, _("Prix unitaire"), border: 'B', align: 'R'); + $pdf->write_cell(20, 4, _("Quantité"), border: 'B', align: 'R'); + $pdf->write_cell(20, 4, _("Montant HT"), border: 'B', align: 'R'); $pdf->line_new(); $nb_inline = count($result); for ($i = 0; $i < $nb_inline; $i++) { - $pdf->write_multi(50, 4, $result[$i]['name']); - $pdf->write_multi(50, 4, $result[$i]['description']); - $pdf->write_cell(25, 4, $result[$i]['tva_percent'], align: 'R'); - $pdf->write_cell(5, 4, $result[$i]['tva_id']); - $pdf->write_cell(25, 4, $result[$i]['quantity'], align: 'R'); - $pdf->write_cell(25, 4, nbm($result[$i]['amount']), align: 'R'); + if ( $result[$i]['description'] == '') { + $pdf->write_multi(110, 4, $result[$i]['name']); + }else { + $pdf->write_multi(50, 4, $result[$i]['name']); + $pdf->write_multi(60, 4, $result[$i]['description']); + } + $pdf->write_cell(20, 4, $result[$i]['tva_percent'], align: 'R'); + //$pdf->write_cell(5, 4, $result[$i]['tva_id']); + $pdf->write_cell(20, 4, $result[$i]['unit_price'], align: 'R'); + $pdf->write_cell(20, 4, $result[$i]['quantity'], align: 'R'); + $pdf->write_cell(20, 4, nbm($result[$i]['amount']), align: 'R'); $pdf->line_new(); } $pdf->line_new(10); - + + $pdf->SetTextColor(0,0,127); $pdf->setFont("DejaVu", "B", 12); $pdf->write_cell(60, 4, _("Totaux")); - $pdf->line_new(10); + $pdf->line_new(6); + $pdf->SetTextColor(0,0,0); $pdf->setFont("DejaVu", "", 7); $result = $this->get_amount_summary(); // @TODO DNY : Qu'est-ce que LineExtension Amount ?? @@ -541,9 +576,11 @@ abstract class XML_Reader $nb_inline = count($result); if ( !empty ($result )) { + $pdf->SetTextColor(0,0,127); $pdf->setFont("DejaVu", "B", 12); $pdf->write_cell(60, 4, _("Charge et déduction")); - $pdf->line_new(10); + $pdf->line_new(6); + $pdf->SetTextColor(0,0,0); $pdf->setFont("DejaVu", "", 7); $pdf->write_cell(20, 4, _("code"), align: 'L', border: '1'); $pdf->write_cell(20, 4, _("Type"), border: '1'); @@ -570,13 +607,15 @@ abstract class XML_Reader $pdf->line_new(); } } + $pdf->SetTextColor(0,0,127); $pdf->setFont("DejaVu", "B", 12); $pdf->write_cell(60, 4, _("TVA")); - $pdf->line_new(10); + $pdf->line_new(6); + $pdf->SetTextColor(0,0,0); $pdf->setFont("DejaVu", "", 7); $result = $this->get_taxes(); $pdf->write_cell(25, 4, _("% Taxe"), align: 'R', border: 'B'); - $pdf->write_cell(5, 4, _("Code taxe"), border: 'B'); + $pdf->write_cell(30, 4, _("Code taxe"), border: 'B'); $pdf->write_cell(50, 4, _("Base"), align: 'R', border: 'B'); $pdf->write_cell(50, 4, _("Taxe"), align: 'R', border: 'B'); $pdf->line_new(); @@ -585,7 +624,7 @@ abstract class XML_Reader { $pdf->write_cell(25, 4, $result[$i]['tax_percent'], align: 'R'); $pdf->write_cell(5, 4, $result[$i]['tax_id']); - $pdf->write_cell(25, 4, $result[$i]['vatex']); + $pdf->write_multi(25, 4, $result[$i]['vatex']); $pdf->write_cell(50, 4, nbm($result[$i]['taxable_amount']), align: 'R'); $pdf->write_cell(50, 4, nbm($result[$i]['tax']), align: 'R'); @@ -595,8 +634,11 @@ abstract class XML_Reader $pdf->setFont("DejaVu", "B", 12); + $pdf->SetTextColor(0,0,127); $pdf->write_cell(60, 4, _("Paiement")); - $pdf->line_new(10); + $pdf->line_new(6); + $pdf->SetTextColor(0,0,0); + $pdf->setFont("DejaVu", "", 7); $result = $this->get_payment_mean(); $pdf->write_cell(50, 4, _("Code")); @@ -618,6 +660,7 @@ abstract class XML_Reader $pdf->write_multi(140, 4, str_replace(["\n", "\r", "\t"], " ", $result['note'][$i])); $pdf->line_new(); } + $pdf->line_new(6); /** * display name of embedded from files * @var $result(array of Document_Reference) @@ -625,9 +668,11 @@ abstract class XML_Reader $result=$this->get_embedded_document(); if ( count($result) > 0) { + $pdf->SetTextColor(0,0,127); $pdf->setFont("DejaVu", "B", 12); $pdf->write_cell(60,4,_('Documents inclus')); $pdf->line_new(); + $pdf->SetTextColor(0,0,0); $pdf->setFont("DejaVu", "", 7); $nb_result=count($result); for ($i=0;$i< $nb_result;$i++) diff --git a/include/XMLDocument/xmlcreditnote_reader.class.php b/include/XMLDocument/xmlcreditnote_reader.class.php index d2f845bab..7e20b0801 100644 --- a/include/XMLDocument/xmlcreditnote_reader.class.php +++ b/include/XMLDocument/xmlcreditnote_reader.class.php @@ -143,15 +143,14 @@ class XMLCreditNote_Reader extends XML_Reader for ($e = 0; $e < $node->length; $e++) { $row = []; - $xml = simplexml_import_dom($node->item($e)); - $row ['quantity'] = $this->get_node_value("//cbc:CreditedQuantity", $e); - $row ['amount'] = $this->get_node_value("//cbc:LineExtensionAmount", $e); - $row ['description'] = $this->get_node_value("//cac:Item/cbc:Description", $e); - $row ['name'] = $this->get_node_value("//cac:CreditNoteLine/cac:Item/cbc:Name", $e); - $row ['unit_price'] = $this->get_node_value("//cac:CreditNoteLine/cac:Price/cbc:PriceAmount", $e); - $row ['tva_id'] = $this->get_node_value("//cac:CreditNoteLine/cac:Item/cac:ClassifiedTaxCategory/cbc:ID", $e); - $row ['tva_percent'] = $this->get_node_value("//cac:CreditNoteLine/cac:Item/cac:ClassifiedTaxCategory/cbc:Percent", $e); - + $row ['quantity'] = $node->item($e)->getElementsByTagName("CreditedQuantity")->item(0)->textContent; + $row ['code_quantity'] = $node->item($e)->getElementsByTagName("CreditedQuantity")->item(0)->getAttribute('unitCode'); + $row ['amount'] = $node->item($e)->getElementsByTagName("LineExtensionAmount")->item(0)->textContent; + $row ['description'] = $node->item($e)->getElementsByTagName("Description")->item(0)?->textContent; + $row ['name'] = $node->item($e)->getElementsByTagName("Name")->item(0)->textContent; + $row ['unit_price'] = $node->item($e)->getElementsByTagName("PriceAmount")->item(0)->textContent; + $row ['tva_id'] = $node->item($e)->getElementsByTagName("ID")->item(0)->textContent; + $row ['tva_percent'] = $node->item($e)->getElementsByTagName("Percent")->item(0)->textContent; $result[] = $row; } return $result; diff --git a/include/XMLDocument/xmlinvoice_reader.class.php b/include/XMLDocument/xmlinvoice_reader.class.php index 523ef6d68..b8c3518b7 100644 --- a/include/XMLDocument/xmlinvoice_reader.class.php +++ b/include/XMLDocument/xmlinvoice_reader.class.php @@ -111,12 +111,12 @@ class XMLInvoice_Reader extends XML_Reader $row = []; $row ['quantity'] = $node->item($e)->getElementsByTagName("InvoicedQuantity")->item(0)->textContent; $row ['code_quantity'] = $node->item($e)->getElementsByTagName("InvoicedQuantity")->item(0)->getAttribute('unitCode'); - $row ['amount'] = $node->item($e)->getElementsByTagName("LineExtensionAmount")->item(0)->textContent; // $this->get_node_value("//cbc:LineExtensionAmount", $e); - $row ['description'] = $node->item($e)->getElementsByTagName("Description")->item(0)?->textContent; //$this->get_node_value("//cac:Item/cbc:Description", $e); - $row ['name'] = $node->item($e)->getElementsByTagName("Name")->item(0)->textContent; //$this->get_node_value("//cac:InvoiceLine/cac:Item/cbc:Name", $e); - $row ['unit_price'] = $node->item($e)->getElementsByTagName("PriceAmount")->item(0)->textContent; //$this->get_node_value("//cac:InvoiceLine/cac:Price/cbc:PriceAmount", $e); - $row ['tva_id'] = $node->item($e)->getElementsByTagName("ID")->item(0)->textContent; //$this->get_node_value("//cac:InvoiceLine/cac:Item/cac:ClassifiedTaxCategory/cbc:ID", $e); - $row ['tva_percent'] = $node->item($e)->getElementsByTagName("Percent")->item(0)->textContent; //$this->get_node_value("//cac:InvoiceLine/cac:Item/cac:ClassifiedTaxCategory/cbc:Percent", $e); + $row ['amount'] = $node->item($e)->getElementsByTagName("LineExtensionAmount")->item(0)->textContent; + $row ['description'] = $node->item($e)->getElementsByTagName("Description")->item(0)?->textContent; + $row ['name'] = $node->item($e)->getElementsByTagName("Name")->item(0)->textContent; + $row ['unit_price'] = $node->item($e)->getElementsByTagName("PriceAmount")->item(0)->textContent; + $row ['tva_id'] = $node->item($e)->getElementsByTagName("ID")->item(0)->textContent; + $row ['tva_percent'] = $node->item($e)->getElementsByTagName("Percent")->item(0)->textContent; $result[] = $row; } return $result;