From b9ec45fd49150c01951282b479e2a3b245ed947d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Oct 2019 14:02:13 +0200 Subject: [PATCH] Clean code --- htdocs/commande/card.php | 20 ++++---- htdocs/compta/facture/card.php | 84 +++++++++++++++++----------------- test/phpunit/FilesLibTest.php | 4 +- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 0d13537037c..ea423a0a99c 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2543,19 +2543,19 @@ if ($action == 'create' && $usercancreate) // Send if ($object->statut > Commande::STATUS_DRAFT || !empty($conf->global->COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS)) { if ($usercansend) { - print '
' . $langs->trans('SendMail') . '
'; + print '' . $langs->trans('SendMail') . ''; } else - print '
' . $langs->trans('SendMail') . '
'; + print '' . $langs->trans('SendMail') . ''; } // Valid if ($object->statut == Commande::STATUS_DRAFT && $object->total_ttc >= 0 && $numlines > 0 && $usercanvalidate) { - print '
' . $langs->trans('Validate') . '
'; + print '' . $langs->trans('Validate') . ''; } // Edit if ($object->statut == Commande::STATUS_VALIDATED && $usercancreate) { - print '
' . $langs->trans('Modify') . '
'; + print '' . $langs->trans('Modify') . ''; } // Create event /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) @@ -2572,9 +2572,9 @@ if ($action == 'create' && $usercancreate) if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { if ($user->rights->ficheinter->creer) { - print '
' . $langs->trans('AddIntervention') . '
'; + print '' . $langs->trans('AddIntervention') . ''; } else { - print '
' . $langs->trans('AddIntervention') . '
'; + print '' . $langs->trans('AddIntervention') . ''; } } } @@ -2584,7 +2584,7 @@ if ($action == 'create' && $usercancreate) $langs->load("contracts"); if ($user->rights->contrat->creer) { - print '
' . $langs->trans('AddContract') . '
'; + print '' . $langs->trans('AddContract') . ''; } } @@ -2596,13 +2596,13 @@ if ($action == 'create' && $usercancreate) if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer)) { if ($user->rights->expedition->creer) { - print '
' . $langs->trans('CreateShipment') . '
'; + print '' . $langs->trans('CreateShipment') . ''; } else { - print '
' . $langs->trans('CreateShipment') . '
'; + print '' . $langs->trans('CreateShipment') . ''; } } else { $langs->load("errors"); - print '
transnoentitiesnoconv("Shipment"))) . '">' . $langs->trans('CreateShipment') . '
'; + print 'transnoentitiesnoconv("Shipment"))) . '">' . $langs->trans('CreateShipment') . ''; } } } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 9467cebde59..2a08c55eeba 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4845,20 +4845,20 @@ elseif ($id > 0 || ! empty($ref)) { if ($usercanunvalidate) { - print '
' . $langs->trans('Modify') . '
'; + print '' . $langs->trans('Modify') . ''; } else { - print '
' . $langs->trans('Modify') . '
'; + print '' . $langs->trans('Modify') . ''; } } elseif (!$object->is_last_in_cycle()) { - print '
' . $langs->trans('Modify') . '
'; + print '' . $langs->trans('Modify') . ''; } else { - print '
' . $langs->trans('Modify') . '
'; + print '' . $langs->trans('Modify') . ''; } } } else { - print '
' . $langs->trans('Modify') . '
'; + print '' . $langs->trans('Modify') . ''; } } @@ -4874,9 +4874,9 @@ elseif ($id > 0 || ! empty($ref)) { if ($object->close_code != 'replaced' || (! $objectidnext)) // Not replaced by another invoice or replaced but the replacement invoice has been deleted { - print '
' . $langs->trans('ReOpen') . '
'; + print '' . $langs->trans('ReOpen') . ''; } else { - print '
' . $langs->trans('ReOpen') . '
'; + print '' . $langs->trans('ReOpen') . ''; } } @@ -4884,19 +4884,19 @@ elseif ($id > 0 || ! empty($ref)) if ($object->statut == Facture::STATUS_DRAFT && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) { if ($usercanvalidate) { - print '
' . $langs->trans('Validate') . '
'; + print '' . $langs->trans('Validate') . ''; } } // Send by mail if (($object->statut == Facture::STATUS_VALIDATED || $object->statut == Facture::STATUS_CLOSED) || ! empty($conf->global->FACTURE_SENDBYEMAIL_FOR_ALL_STATUS)) { if ($objectidnext) { - print '
' . $langs->trans('SendMail') . '
'; + print '' . $langs->trans('SendMail') . ''; } else { if ($usercansend) { - print '
' . $langs->trans('SendMail') . '
'; + print '' . $langs->trans('SendMail') . ''; } else - print '
' . $langs->trans('SendMail') . '
'; + print '' . $langs->trans('SendMail') . ''; } } @@ -4911,7 +4911,7 @@ elseif ($id > 0 || ! empty($ref)) { print ''.$langs->trans("MakeWithdrawRequest").''; } else { - print '
' . $langs->trans('MakeWithdrawRequest') . '
'; + print '' . $langs->trans('MakeWithdrawRequest') . ''; } } else @@ -4930,18 +4930,18 @@ elseif ($id > 0 || ! empty($ref)) { $langs->load("cashdesk"); $receipt_url=DOL_URL_ROOT."/takepos/receipt.php"; - print '
' . $langs->trans('POSTicket') .'
'; + print '' . $langs->trans('POSTicket') .''; } // Create payment if ($object->type != Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercanissuepayment) { if ($objectidnext) { - print '
' . $langs->trans('DoPayment') . '
'; + print '' . $langs->trans('DoPayment') . ''; } else { //if ($resteapayer == 0) { // Sometimes we can receive more, so we accept to enter more and will offer a button to convert into discount (but it is not a credit note, just a prepayment done) // print '
' . $langs->trans('DoPayment') . '
'; //} else { - print '
' . $langs->trans('DoPayment') . '
'; + print '' . $langs->trans('DoPayment') . ''; //} } } @@ -4953,27 +4953,27 @@ elseif ($id > 0 || ! empty($ref)) { if ($resteapayer == 0) { - print '
'.$langs->trans('DoPaymentBack').'
'; + print ''.$langs->trans('DoPaymentBack').''; } else { - print '
'.$langs->trans('DoPaymentBack').'
'; + print ''.$langs->trans('DoPaymentBack').''; } } // For standard invoice with excess received if ($object->type == Facture::TYPE_STANDARD && empty($object->paye) && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) < 0 && $usercancreate && empty($discount->id)) { - print '
'.$langs->trans('ConvertExcessReceivedToReduc').'
'; + print ''.$langs->trans('ConvertExcessReceivedToReduc').''; } // For credit note if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate && $object->getSommePaiement() == 0) { - print '
' . $langs->trans('ConvertToReduc') . '
'; + print '' . $langs->trans('ConvertToReduc') . ''; } // For deposit invoice if ($object->type == Facture::TYPE_DEPOSIT && $usercancreate && $object->statut > 0 && empty($discount->id)) { - print '
'.$langs->trans('ConvertToReduc').'
'; + print ''.$langs->trans('ConvertToReduc').''; } } @@ -4982,7 +4982,7 @@ elseif ($id > 0 || ! empty($ref)) || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $usercanissuepayment && empty($discount->id)) ) { - print '
'.$langs->trans('ClassifyPaid').'
'; + print ''.$langs->trans('ClassifyPaid').''; } // Classify 'closed not completely paid' (possible si validee et pas encore classee payee) @@ -4992,7 +4992,7 @@ elseif ($id > 0 || ! empty($ref)) if ($totalpaye > 0 || $totalcreditnotes > 0) { // If one payment or one credit note was linked to this invoice - print '
' . $langs->trans('ClassifyPaidPartially') . '
'; + print '' . $langs->trans('ClassifyPaidPartially') . ''; } else { @@ -5000,11 +5000,11 @@ elseif ($id > 0 || ! empty($ref)) { if ($objectidnext) { - print '
' . $langs->trans('ClassifyCanceled') . '
'; + print '' . $langs->trans('ClassifyCanceled') . ''; } else { - print '
' . $langs->trans('ClassifyCanceled') . '
'; + print '' . $langs->trans('ClassifyCanceled') . ''; } } } @@ -5013,7 +5013,7 @@ elseif ($id > 0 || ! empty($ref)) // Clone if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $usercancreate) { - print '
' . $langs->trans("ToClone") . '
'; + print '' . $langs->trans("ToClone") . ''; } // Clone as predefined / Create template @@ -5021,7 +5021,7 @@ elseif ($id > 0 || ! empty($ref)) { if (! $objectidnext && count($object->lines) > 0) { - print '
' . $langs->trans("ChangeIntoRepeatableInvoice") . '
'; + print '' . $langs->trans("ChangeIntoRepeatableInvoice") . ''; } } @@ -5030,7 +5030,7 @@ elseif ($id > 0 || ! empty($ref)) { if (! $objectidnext) { - print '
' . $langs->trans("CreateCreditNote") . '
'; + print '' . $langs->trans("CreateCreditNote") . ''; } } @@ -5045,9 +5045,9 @@ elseif ($id > 0 || ! empty($ref)) { if ($usercanunvalidate) { - print '
' . $langs->trans("CreateCreditNote") . '
'; + print '' . $langs->trans("CreateCreditNote") . ''; } else { - print '
' . $langs->trans("CreateCreditNote") . '
'; + print '' . $langs->trans("CreateCreditNote") . ''; } } @@ -5063,22 +5063,22 @@ elseif ($id > 0 || ! empty($ref)) { if(($object->total_ttc - $totalcreditnotes ) == 0 ) { - print '
' . $langs->trans("RemoveSituationFromCycle") . '
'; + print '' . $langs->trans("RemoveSituationFromCycle") . ''; } else { - print '
' . $langs->trans("RemoveSituationFromCycle") . '
'; + print '' . $langs->trans("RemoveSituationFromCycle") . ''; } } // Create next situation invoice if ($usercancreate && ($object->type == 5) && ($object->statut == 1 || $object->statut == 2)) { if ($object->is_last_in_cycle() && $object->situation_final != 1) { - print '
' . $langs->trans('CreateNextSituationInvoice') . '
'; + print '' . $langs->trans('CreateNextSituationInvoice') . ''; } elseif (!$object->is_last_in_cycle()) { - print '
' . $langs->trans('CreateNextSituationInvoice') . '
'; + print '' . $langs->trans('CreateNextSituationInvoice') . ''; } else { - print '
' . $langs->trans('CreateNextSituationInvoice') . '
'; + print '' . $langs->trans('CreateNextSituationInvoice') . ''; } } @@ -5088,31 +5088,31 @@ elseif ($id > 0 || ! empty($ref)) { //var_dump($isErasable); if ($isErasable == -4) { - print '
' . $langs->trans('Delete') . '
'; + print '' . $langs->trans('Delete') . ''; } elseif ($isErasable == -3) { - print '
' . $langs->trans('Delete') . '
'; + print '' . $langs->trans('Delete') . ''; } elseif ($isErasable == -2) { - print '
' . $langs->trans('Delete') . '
'; + print '' . $langs->trans('Delete') . ''; } elseif ($isErasable == -1) { - print '
' . $langs->trans('Delete') . '
'; + print '' . $langs->trans('Delete') . ''; } elseif ($isErasable <= 0) // Any other cases { - print '
' . $langs->trans('Delete') . '
'; + print '' . $langs->trans('Delete') . ''; } elseif ($objectidnext) { - print '
' . $langs->trans('Delete') . '
'; + print '' . $langs->trans('Delete') . ''; } else { - print '
' . $langs->trans('Delete') . '
'; + print '' . $langs->trans('Delete') . ''; } } else { - print '
' . $langs->trans('Delete') . '
'; + print '' . $langs->trans('Delete') . ''; } } print ''; diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 9b990d78922..d73d99f7078 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -413,11 +413,11 @@ class FilesLibTest extends PHPUnit\Framework\TestCase $result=dol_compress_file($filein, $fileout, $format, $errorstring); print __METHOD__." result=".$result."\n"; - $this->assertGreaterThanOrEqual(1, $result, "Pb with dol_compress_file on ".$filein." : ".$errorstring); + $this->assertGreaterThanOrEqual(1, $result, "Pb with dol_compress_file on ".$filein." into ".$fileout." : ".$errorstring); $result=dol_uncompress($fileout, $dirout); print __METHOD__." result=".join(',', $result)."\n"; - $this->assertEquals(0, count($result), "Pb with dol_uncompress_file"); + $this->assertEquals(0, count($result), "Pb with dol_uncompress_file of file ".$fileout); } /**