From 665e401564b30079c1f2ba64b016c374e11da60e Mon Sep 17 00:00:00 2001 From: steve Date: Fri, 4 Mar 2022 17:03:40 +0100 Subject: [PATCH 1/3] wip: replace butAction --- htdocs/compta/facture/card.php | 89 +++++++++++++++++++++++++--------- 1 file changed, 67 insertions(+), 22 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index a4d85c257f8..5b4acb040d6 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -5359,6 +5359,12 @@ if ($action == 'create') { $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { + $params = array( + 'attr' => array( + 'title' => '', + 'class' => 'classfortooltip' + ) + ); // Editer une facture deja validee, sans paiement effectue et pas exporte en compta if ($object->statut == Facture::STATUS_VALIDATED) { // We check if lines of invoice are not already transfered into accountancy @@ -5368,18 +5374,27 @@ if ($action == 'create') { if (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == price2num($object->total_ttc, 'MT', 1) && empty($object->paye))) { if (!$objectidnext && $object->is_last_in_cycle()) { if ($usercanunvalidate) { - print ''.$langs->trans('Modify').''; + //print ''.$langs->trans('Modify').''; + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif', '', true, $params); } else { - print ''.$langs->trans('Modify').''; + //print ''.$langs->trans('Modify').''; + $params['attr']['title'] = $langs->trans('NotEnoughPermissions'); + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif', '', false, $params); } } elseif (!$object->is_last_in_cycle()) { - print ''.$langs->trans('Modify').''; + //print ''.$langs->trans('Modify').''; + $params['attr']['title'] = $langs->trans('NotLastInCycle'); + print dolGetButtonAction($langs->trans('Modify'), '', 'default', '#', '', false, $params); } else { - print ''.$langs->trans('Modify').''; + //print ''.$langs->trans('Modify').''; + $params['attr']['title'] = $langs->trans('DisabledBecauseReplacedInvoice'); + print dolGetButtonAction($langs->trans('Modify'), '', 'default', '#', '', false, $params); } } } else { - print ''.$langs->trans('Modify').''; + //print ''.$langs->trans('Modify').''; + $params['attr']['title'] = $langs->trans('DisabledBecauseDispatchedInBookkeeping'); + print dolGetButtonAction($langs->trans('Modify'), '', 'default', '#', '', false, $params); } } @@ -5414,7 +5429,8 @@ if ($action == 'create') { // Validate 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 dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=valid&token='.newToken(), '', true, $params); + //print ''.$langs->trans('Validate').''; } } @@ -5425,9 +5441,11 @@ if ($action == 'create') { print ''.$langs->trans('SendMail').''; } else { if ($usercansend) { - print ''.$langs->trans('SendMail').''; + //print ''.$langs->trans('SendMail').''; + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '', true, $params); } else { - print ''.$langs->trans('SendMail').''; + //print ''.$langs->trans('SendMail').''; + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', '#', '', false, $params); } } } @@ -5464,10 +5482,13 @@ if ($action == 'create') { } else { if ($object->type == Facture::TYPE_DEPOSIT && $resteapayer == 0) { // For down payment, we refuse to receive more than amount to pay. - print ''.$langs->trans('DoPayment').''; + //print ''.$langs->trans('DoPayment').''; + $params['attr']['title'] = $langs->trans('DisabledBecauseRemainderToPayIsZero'); + print dolGetButtonAction($langs->trans('DoPayment'), '', 'default', '#', '', false, $params); } else { // 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').''; + //print ''.$langs->trans('DoPayment').''; + print dolGetButtonAction($langs->trans('DoPayment'), '', 'default', DOL_URL_ROOT.'/compta/paiement.php?facid='.$object->id.'&action=create&accountid='.$object->fk_account, '', true, $params); } } } @@ -5516,9 +5537,12 @@ if ($action == 'create') { ) { if ($object->type == Facture::TYPE_DEPOSIT && price2num($object->total_ttc, 'MT') != price2num($sumofpaymentall, 'MT')) { // We can close a down payment only if paid amount is same than amount of down payment (by definition) - print ''.$langs->trans('ClassifyPaid').''; + //print ''.$langs->trans('ClassifyPaid').''; + $params['attr']['title'] = $langs->trans('AmountPaidMustMatchAmountOfDownPayment'); + print dolGetButtonAction($langs->trans('ClassifyPaid'), '', 'default', '#', '', false, $params); } else { - print ''.$langs->trans('ClassifyPaid').''; + //print ''.$langs->trans('ClassifyPaid').''; + print dolGetButtonAction($langs->trans('ClassifyPaid'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=paid', '', true, $params); } } @@ -5563,13 +5587,15 @@ if ($action == 'create') { // 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").''; + print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=clone&object=invoice', '', true, $params); } // Clone as predefined / Create template if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut == 0 && $usercancreate) { if (!$objectidnext && count($object->lines) > 0) { - print ''.$langs->trans("ChangeIntoRepeatableInvoice").''; + //print ''.$langs->trans("ChangeIntoRepeatableInvoice").''; + print dolGetButtonAction($langs->trans('ChangeIntoRepeatableInvoice'), '', 'default', DOL_URL_ROOT.'/compta/facture/card-rec.php?facid='.$object->id.'&action=create', '', true, $params); } } @@ -5602,25 +5628,44 @@ if ($action == 'create') { // Delete $isErasable = $object->is_erasable(); + $params = array( + 'attr' => array( + 'title' => '', + 'class' => 'classfortooltip' + ) + ); if ($usercandelete || ($usercancreate && $isErasable == 1)) { // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions) //var_dump($isErasable); + $enableDelete = false; + $deleteHref = '#'; if ($isErasable == -4) { - print ''.$langs->trans('Delete').''; + $params['attr']['title'] = $langs->trans('DisabledBecausePayments'); + //print ''.$langs->trans('Delete').''; } elseif ($isErasable == -3) { - print ''.$langs->trans('Delete').''; + $params['attr']['title'] = $langs->trans('DisabledBecauseNotLastSituationInvoice'); + //print ''.$langs->trans('Delete').''; } elseif ($isErasable == -2) { - print ''.$langs->trans('Delete').''; + $params['attr']['title'] = $langs->trans('DisabledBecauseNotLastInvoice'); + //print ''.$langs->trans('Delete').''; } elseif ($isErasable == -1) { - print ''.$langs->trans('Delete').''; + $params['attr']['title'] = $langs->trans('DisabledBecauseDispatchedInBookkeeping'); + //print ''.$langs->trans('Delete').''; } elseif ($isErasable <= 0) { // Any other cases - print ''.$langs->trans('Delete').''; + $params['attr']['title'] = $langs->trans('DisabledBecauseNotErasable'); + //print ''.$langs->trans('Delete').''; } elseif ($objectidnext) { - print ''.$langs->trans('Delete').''; + $params['attr']['title'] = $langs->trans('DisabledBecauseReplacedInvoice'); + //print ''.$langs->trans('Delete').''; } else { - print ''.$langs->trans('Delete').''; + //print ''.$langs->trans('Delete').''; + $deleteHref = $_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=delete&token='.newToken(); + $enableDelete = true; } + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $deleteHref, '', $enableDelete, $params); } else { - print ''.$langs->trans('Delete').''; + //print ''.$langs->trans('Delete').''; + $params['attr']['title'] = $langs->trans('NotAllowed'); + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', '#', '', false, $params); } } print ''; From 25fcb83b7490c6abbedbcb953fcc6c30ebbd7c06 Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 9 Mar 2022 16:41:26 +0100 Subject: [PATCH 2/3] wip: reopen button --- htdocs/compta/facture/card.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 5b4acb040d6..c974a1b053c 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -5409,9 +5409,12 @@ if ($action == 'create') { && ($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || $usercanreopen)) { // A paid invoice (partially or completely) 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').''; + print dolGetButtonAction($langs->trans('ReOpen'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=reopen&token='.newToken(), '', true, $params); } else { - print ''.$langs->trans('ReOpen').''; + //print ''.$langs->trans('ReOpen').''; + $params['attr']['title'] = $langs->trans("DisabledBecauseReplacedInvoice"); + print dolGetButtonAction($langs->trans('ReOpen'), '', 'default', '#', '', false, $params); } } From c3b22ed26ec1773556140ec2e54e6d62d0e3430a Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 9 Mar 2022 17:10:53 +0100 Subject: [PATCH 3/3] wip: clean comments --- htdocs/compta/facture/card.php | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c974a1b053c..710ae01d1a6 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -5374,25 +5374,20 @@ if ($action == 'create') { if (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == price2num($object->total_ttc, 'MT', 1) && empty($object->paye))) { if (!$objectidnext && $object->is_last_in_cycle()) { if ($usercanunvalidate) { - //print ''.$langs->trans('Modify').''; print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif', '', true, $params); } else { - //print ''.$langs->trans('Modify').''; $params['attr']['title'] = $langs->trans('NotEnoughPermissions'); print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif', '', false, $params); } } elseif (!$object->is_last_in_cycle()) { - //print ''.$langs->trans('Modify').''; $params['attr']['title'] = $langs->trans('NotLastInCycle'); print dolGetButtonAction($langs->trans('Modify'), '', 'default', '#', '', false, $params); } else { - //print ''.$langs->trans('Modify').''; $params['attr']['title'] = $langs->trans('DisabledBecauseReplacedInvoice'); print dolGetButtonAction($langs->trans('Modify'), '', 'default', '#', '', false, $params); } } } else { - //print ''.$langs->trans('Modify').''; $params['attr']['title'] = $langs->trans('DisabledBecauseDispatchedInBookkeeping'); print dolGetButtonAction($langs->trans('Modify'), '', 'default', '#', '', false, $params); } @@ -5409,10 +5404,8 @@ if ($action == 'create') { && ($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || $usercanreopen)) { // A paid invoice (partially or completely) 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 dolGetButtonAction($langs->trans('ReOpen'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=reopen&token='.newToken(), '', true, $params); } else { - //print ''.$langs->trans('ReOpen').''; $params['attr']['title'] = $langs->trans("DisabledBecauseReplacedInvoice"); print dolGetButtonAction($langs->trans('ReOpen'), '', 'default', '#', '', false, $params); } @@ -5433,7 +5426,6 @@ if ($action == 'create') { 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 dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=valid&token='.newToken(), '', true, $params); - //print ''.$langs->trans('Validate').''; } } @@ -5444,10 +5436,8 @@ if ($action == 'create') { print ''.$langs->trans('SendMail').''; } else { if ($usercansend) { - //print ''.$langs->trans('SendMail').''; print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '', true, $params); } else { - //print ''.$langs->trans('SendMail').''; print dolGetButtonAction($langs->trans('SendMail'), '', 'default', '#', '', false, $params); } } @@ -5485,7 +5475,6 @@ if ($action == 'create') { } else { if ($object->type == Facture::TYPE_DEPOSIT && $resteapayer == 0) { // For down payment, we refuse to receive more than amount to pay. - //print ''.$langs->trans('DoPayment').''; $params['attr']['title'] = $langs->trans('DisabledBecauseRemainderToPayIsZero'); print dolGetButtonAction($langs->trans('DoPayment'), '', 'default', '#', '', false, $params); } else { @@ -5540,11 +5529,9 @@ if ($action == 'create') { ) { if ($object->type == Facture::TYPE_DEPOSIT && price2num($object->total_ttc, 'MT') != price2num($sumofpaymentall, 'MT')) { // We can close a down payment only if paid amount is same than amount of down payment (by definition) - //print ''.$langs->trans('ClassifyPaid').''; $params['attr']['title'] = $langs->trans('AmountPaidMustMatchAmountOfDownPayment'); print dolGetButtonAction($langs->trans('ClassifyPaid'), '', 'default', '#', '', false, $params); } else { - //print ''.$langs->trans('ClassifyPaid').''; print dolGetButtonAction($langs->trans('ClassifyPaid'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=paid', '', true, $params); } } @@ -5590,14 +5577,12 @@ if ($action == 'create') { // Clone if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $usercancreate) { - //print ''.$langs->trans("ToClone").''; print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=clone&object=invoice', '', true, $params); } // Clone as predefined / Create template if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut == 0 && $usercancreate) { if (!$objectidnext && count($object->lines) > 0) { - //print ''.$langs->trans("ChangeIntoRepeatableInvoice").''; print dolGetButtonAction($langs->trans('ChangeIntoRepeatableInvoice'), '', 'default', DOL_URL_ROOT.'/compta/facture/card-rec.php?facid='.$object->id.'&action=create', '', true, $params); } } @@ -5638,35 +5623,26 @@ if ($action == 'create') { ) ); if ($usercandelete || ($usercancreate && $isErasable == 1)) { // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions) - //var_dump($isErasable); $enableDelete = false; $deleteHref = '#'; if ($isErasable == -4) { $params['attr']['title'] = $langs->trans('DisabledBecausePayments'); - //print ''.$langs->trans('Delete').''; } elseif ($isErasable == -3) { $params['attr']['title'] = $langs->trans('DisabledBecauseNotLastSituationInvoice'); - //print ''.$langs->trans('Delete').''; } elseif ($isErasable == -2) { $params['attr']['title'] = $langs->trans('DisabledBecauseNotLastInvoice'); - //print ''.$langs->trans('Delete').''; } elseif ($isErasable == -1) { $params['attr']['title'] = $langs->trans('DisabledBecauseDispatchedInBookkeeping'); - //print ''.$langs->trans('Delete').''; } elseif ($isErasable <= 0) { // Any other cases $params['attr']['title'] = $langs->trans('DisabledBecauseNotErasable'); - //print ''.$langs->trans('Delete').''; } elseif ($objectidnext) { $params['attr']['title'] = $langs->trans('DisabledBecauseReplacedInvoice'); - //print ''.$langs->trans('Delete').''; } else { - //print ''.$langs->trans('Delete').''; $deleteHref = $_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=delete&token='.newToken(); $enableDelete = true; } print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $deleteHref, '', $enableDelete, $params); } else { - //print ''.$langs->trans('Delete').''; $params['attr']['title'] = $langs->trans('NotAllowed'); print dolGetButtonAction($langs->trans('Delete'), '', 'delete', '#', '', false, $params); }