Clean code

This commit is contained in:
Laurent Destailleur 2022-09-08 15:05:51 +02:00
parent c3f673c3ad
commit aa9036a0f5
13 changed files with 94 additions and 91 deletions

View File

@ -1791,7 +1791,7 @@ if ($action == 'create') {
// Terms of payment // Terms of payment
print '<tr class="field_cond_reglement_id"><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>'; print '<tr class="field_cond_reglement_id"><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
print img_picto('', 'paiment'); print img_picto('', 'paiment');
$form->select_conditions_paiements((GETPOSTISSET('cond_reglement_id') && GETPOST('cond_reglement_id') != 0) ? GETPOST('cond_reglement_id', 'int') : $soc->cond_reglement_id, 'cond_reglement_id', 1, 1, 0, '', (GETPOSTISSET('cond_reglement_id_deposit_percent') ? GETPOST('cond_reglement_id_deposit_percent', 'alpha') : $soc->deposit_percent)); print $form->getSelectConditionsPaiements((GETPOSTISSET('cond_reglement_id') && GETPOST('cond_reglement_id') != 0) ? GETPOST('cond_reglement_id', 'int') : $soc->cond_reglement_id, 'cond_reglement_id', 1, 1, 0, '', (GETPOSTISSET('cond_reglement_id_deposit_percent') ? GETPOST('cond_reglement_id_deposit_percent', 'alpha') : $soc->deposit_percent));
print '</td></tr>'; print '</td></tr>';
// Mode of payment // Mode of payment

View File

@ -1232,7 +1232,7 @@ if ($resql) {
// Payment term // Payment term
if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) { if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
$form->select_conditions_paiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1); print $form->getSelectConditionsPaiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1);
print '</td>'; print '</td>';
} }
// Payment mode // Payment mode

View File

@ -1813,7 +1813,7 @@ if ($action == 'create' && $usercancreate) {
// Terms of payment // Terms of payment
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>'; print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
print img_picto('', 'payment', 'class="pictofixedwidth"'); print img_picto('', 'payment', 'class="pictofixedwidth"');
$form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', 1, 1, 0, 'maxwidth200 widthcentpercentminusx', $deposit_percent); print $form->getSelectConditionsPaiements($cond_reglement_id, 'cond_reglement_id', 1, 1, 0, 'maxwidth200 widthcentpercentminusx', $deposit_percent);
print '</td></tr>'; print '</td></tr>';
// Payment mode // Payment mode
@ -2105,7 +2105,11 @@ if ($action == 'create' && $usercancreate) {
} }
if ($nbMandated > 0 ) $text .= '<div><span class="clearboth nowraponall warning">'.$langs->trans("mandatoryPeriodNeedTobeSetMsgValidate").'</span></div>'; if ($nbMandated > 0 ) $text .= '<div><span class="clearboth nowraponall warning">'.$langs->trans("mandatoryPeriodNeedTobeSetMsgValidate").'</span></div>';
if (getDolGlobalInt('SALE_ORDER_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
// This is a hidden option:
// Suggestion to create invoice during order validation is not enabled by default.
// Such choice should be managed by the workflow module and trigger. This option generates conflicts with some setup.
// It may also break step of creating an order when invoicing must be done from proposals and not from orders
$deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); $deposit_percent_from_payment_terms = getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id);
if (!empty($deposit_percent_from_payment_terms) && !empty($conf->facture->enabled) && !empty($user->rights->facture->creer)) { if (!empty($deposit_percent_from_payment_terms) && !empty($conf->facture->enabled) && !empty($user->rights->facture->creer)) {
@ -2139,7 +2143,6 @@ if ($action == 'create' && $usercancreate) {
} }
} }
if ($eligibleForDepositGeneration) { if ($eligibleForDepositGeneration) {
$formquestion[] = array( $formquestion[] = array(
'type' => 'checkbox', 'type' => 'checkbox',
@ -2168,9 +2171,8 @@ if ($action == 'create' && $usercancreate) {
); );
} }
ob_start();
$form->select_conditions_paiements(0, 'cond_reglement_id', -1, 0, 0, 'minwidth200'); $paymentTermsSelect = $form->getSelectConditionsPaiements(0, 'cond_reglement_id', -1, 0, 0, 'minwidth200');
$paymentTermsSelect = ob_get_clean();
$formquestion[] = array( $formquestion[] = array(
'type' => 'other', 'type' => 'other',
@ -2210,6 +2212,7 @@ if ($action == 'create' && $usercancreate) {
); );
} }
} }
}
if (!$error) { if (!$error) {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220);

View File

@ -1507,7 +1507,7 @@ if ($resql) {
// Payment term // Payment term
if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
$form->select_conditions_paiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1); print $form->getSelectConditionsPaiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1);
print '</td>'; print '</td>';
} }
// Payment mode // Payment mode

View File

@ -3670,7 +3670,7 @@ if ($action == 'create') {
// Payment term // Payment term
print '<tr><td class="nowrap fieldrequired">'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">'; print '<tr><td class="nowrap fieldrequired">'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">';
$form->select_conditions_paiements(GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id', 'int') : $cond_reglement_id, 'cond_reglement_id'); print $form->getSelectConditionsPaiements(GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id', 'int') : $cond_reglement_id, 'cond_reglement_id');
print '</td></tr>'; print '</td></tr>';
@ -3702,7 +3702,7 @@ if ($action == 'create') {
$retained_warranty_fk_cond_reglement = $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; $retained_warranty_fk_cond_reglement = $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID;
} }
} }
$form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1); print $form->getSelectConditionsPaiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1);
print '</td></tr>'; print '</td></tr>';
print '<script type="text/javascript"> print '<script type="text/javascript">
@ -4728,7 +4728,7 @@ if ($action == 'create') {
$retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int');
$retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $object->retained_warranty_fk_cond_reglement; $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $object->retained_warranty_fk_cond_reglement;
$retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID;
$form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1); print $form->getSelectConditionsPaiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1);
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
print '</form>'; print '</form>';
} else { } else {

View File

@ -530,7 +530,7 @@ if ($resql) {
if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
// Payment term // Payment term
print '<td class="liste_titre right">'; print '<td class="liste_titre right">';
$form->select_conditions_paiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100'); print $form->getSelectConditionsPaiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100');
print "</td>"; print "</td>";
} }
if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {

View File

@ -1371,7 +1371,7 @@ if ($resql) {
// Payment terms // Payment terms
if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
$form->select_conditions_paiements($search_paymentterms, 'search_paymentterms', -1, 1, 1); print $form->getSelectConditionsPaiements($search_paymentterms, 'search_paymentterms', -1, 1, 1);
print '</td>'; print '</td>';
} }
// Module source // Module source

View File

@ -5372,7 +5372,7 @@ class Form
if ($type) { if ($type) {
print '<input type="hidden" name="type" value="'.dol_escape_htmltag($type).'">'; print '<input type="hidden" name="type" value="'.dol_escape_htmltag($type).'">';
} }
$this->select_conditions_paiements($selected, $htmlname, $filtertype, $addempty, 0, '', $deposit_percent); print $this->getSelectConditionsPaiements($selected, $htmlname, $filtertype, $addempty, 0, '', $deposit_percent);
print '<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans("Modify").'">'; print '<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans("Modify").'">';
print '</form>'; print '</form>';
} else { } else {

View File

@ -1729,7 +1729,7 @@ if ($action == 'create') {
// Payment term // Payment term
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>'; print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
$form->select_conditions_paiements(GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id') : $cond_reglement_id, 'cond_reglement_id'); print $form->getSelectConditionsPaiements(GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id') : $cond_reglement_id, 'cond_reglement_id');
print '</td></tr>'; print '</td></tr>';
// Payment mode // Payment mode

View File

@ -2400,7 +2400,7 @@ if ($action == 'create') {
// Payment term // Payment term
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>'; print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
$form->select_conditions_paiements(GETPOSTISSET('cond_reglement_id') ?GETPOST('cond_reglement_id', 'int') : $cond_reglement_id, 'cond_reglement_id'); print $form->getSelectConditionsPaiements(GETPOSTISSET('cond_reglement_id') ?GETPOST('cond_reglement_id', 'int') : $cond_reglement_id, 'cond_reglement_id');
print '</td></tr>'; print '</td></tr>';
// Payment mode // Payment mode

View File

@ -521,7 +521,7 @@ if ($resql) {
if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
// Payment term // Payment term
print '<td class="liste_titre right">'; print '<td class="liste_titre right">';
$form->select_conditions_paiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100'); print $form->getSelectConditionsPaiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100');
print "</td>"; print "</td>";
} }
if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {

View File

@ -1045,7 +1045,7 @@ if ($resql) {
// Condition of payment // Condition of payment
if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
$form->select_conditions_paiements($search_paymentcond, 'search_paymentcond', -1, 1, 1, 'maxwidth100'); print $form->getSelectConditionsPaiements($search_paymentcond, 'search_paymentcond', -1, 1, 1, 'maxwidth100');
print '</td>'; print '</td>';
} }
// Payment mode // Payment mode

View File

@ -1276,7 +1276,7 @@ if ($action == 'create') {
// Terms of payment // Terms of payment
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">'; print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">';
$form->select_conditions_paiements(GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $cond_reglement_id, 'cond_reglement_id', -1, 1); print $form->getSelectConditionsPaiements(GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $cond_reglement_id, 'cond_reglement_id', -1, 1);
print '</td></tr>'; print '</td></tr>';
// Mode of payment // Mode of payment