From 0aa90e82ea25505addb8ed876eccc8ed2d9a31ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Oct 2021 15:47:29 +0200 Subject: [PATCH] Clean code --- htdocs/core/class/html.form.class.php | 11 +- htdocs/expensereport/card.php | 317 +++++++++--------- .../tpl/expensereport_addfile.tpl.php | 9 +- .../tpl/expensereport_linktofile.tpl.php | 13 +- htdocs/langs/fr_FR/projects.lang | 2 + htdocs/langs/fr_FR/propal.lang | 2 +- htdocs/theme/eldy/global.inc.php | 7 + 7 files changed, 193 insertions(+), 168 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c69b794a011..c479b59cbde 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -9307,11 +9307,12 @@ class Form * * @param string $save_label Alternative label for save button * @param string $cancel_label Alternative label for cancel button - * @param array $morefields Add additional buttons between save and cancel + * @param array $morebuttons Add additional buttons between save and cancel * @param bool $withoutdiv Option to remove enclosing centered div + * @param string $morecss More CSS * @return string Html code with the buttons */ - public function buttonsSaveCancel($save_label = 'Save', $cancel_label = 'Cancel', $morefields = array(), $withoutdiv = 0) + public function buttonsSaveCancel($save_label = 'Save', $cancel_label = 'Cancel', $morebuttons = array(), $withoutdiv = 0, $morecss = '') { global $langs; @@ -9335,8 +9336,8 @@ class Form !empty($save_label) ? $buttons[] = $save : ''; - if (!empty($morefields)) { - $buttons[] = $morefields; + if (!empty($morebuttons)) { + $buttons[] = $morebuttons; } !empty($cancel_label) ? $buttons[] = $cancel : ''; @@ -9345,7 +9346,7 @@ class Form foreach ($buttons as $button) { $addclass = empty($button['addclass']) ? '' : $button['addclass']; - $retstring .= ''; + $retstring .= ''; } $retstring .= $withoutdiv ? '': ''; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 983a355b867..911b9cb08c3 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1696,20 +1696,20 @@ if ($action == 'create') { } } }*/ - $morehtmlref .= ''; + $morehtmlref .= ''; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print '
'; - print '
'; - print '
'; + print '
'; + print '
'; + print '
'; - print ''; + print '
'; - // Author - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - // Period - print ''; - print ''; - print ''; - print ''; + // Period + print ''; + print ''; + print ''; + print ''; if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) { print ''; print ''; @@ -1735,20 +1735,20 @@ if ($action == 'create') { print ''; } - // Validation date - print ''; - print ''; - print ''; + print ''; + print ''; - print ''; + print ''; + print ''; - // User to inform for approval + // User to inform for approval if ($object->status <= ExpenseReport::STATUS_VALIDATED) { // informed print ''; print ''; // approver @@ -1842,24 +1842,24 @@ if ($action == 'create') { */ } - // Other attributes - $cols = 2; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - print '
'.$langs->trans("User").''; + // Author + print '
'.$langs->trans("User").''; if ($object->fk_user_author > 0) { $userauthor = new User($db); $result = $userauthor->fetch($object->fk_user_author); @@ -1719,15 +1719,15 @@ if ($action == 'create') { print $userauthor->getNomUrl(-1); } } - print '
'.$langs->trans("Period").''; - print get_date_range($object->date_debut, $object->date_fin, 'day', $langs, 0); - print '
'.$langs->trans("Period").''; + print get_date_range($object->date_debut, $object->date_fin, 'day', $langs, 0); + print '
'.$langs->trans("ModePaiement").'
'.$langs->trans("DATE_SAVE").''.dol_print_date($object->date_valid, 'dayhour', 'tzuser'); + // Validation date + print '
'.$langs->trans("DATE_SAVE").''.dol_print_date($object->date_valid, 'dayhour', 'tzuser'); if ($object->status == 2 && $object->hasDelay('toapprove')) { print ' '.img_warning($langs->trans("Late").' - '.$langs->trans("ToApprove")); } if ($object->status == 5 && $object->hasDelay('topay')) { print ' '.img_warning($langs->trans("Late").' - '.$langs->trans("ToPay")); } - print '
'.$langs->trans("VALIDATOR").'
'; + print ''; - print '
'; - print '
'; - print '
'; - print '
'; + print '
'; + print '
'; + print '
'; + print '
'; - print ''; + print '
'; - // Amount - print ''; - print ''; - print ''; - $rowspan = 5; + // Amount + print ''; + print ''; + print ''; + $rowspan = 5; if ($object->status <= ExpenseReport::STATUS_VALIDATED) { $rowspan++; } elseif ($object->status == ExpenseReport::STATUS_CANCELED) { @@ -1873,15 +1873,15 @@ if ($action == 'create') { if ($object->status == ExpenseReport::STATUS_CLOSED) { $rowspan += 2; } - print ""; - print ''; + print ""; + print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - // Amount Local Taxes + // Amount Local Taxes if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { // Localtax1 print ''; print ''; @@ -1891,45 +1891,45 @@ if ($action == 'create') { print ''; } - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - // List of payments already done - $nbcols = 3; + // List of payments already done + $nbcols = 3; if (!empty($conf->banque->enabled)) { $nbrows++; $nbcols++; } - print '
'.$langs->trans("AmountHT").''.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->trans("AmountHT").''.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->trans("AmountVAT").''.price($object->total_tva, 1, '', 1, -1, -1, $conf->currency).'
'.$langs->trans("AmountVAT").''.price($object->total_tva, 1, '', 1, -1, -1, $conf->currency).'
'.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($object->total_localtax1, 1, '', 1, -1, -1, $conf->currency).'
'.price($object->total_localtax2, 1, '', 1, -1, -1, $conf->currency).'
'.$langs->trans("AmountTTC").''.price($object->total_ttc, 1, '', 1, -1, -1, $conf->currency).'
'.$langs->trans("AmountTTC").''.price($object->total_ttc, 1, '', 1, -1, -1, $conf->currency).'
'; + print '
'; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; if (!empty($conf->banque->enabled)) { print ''; } - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - // Payments already done (from payment on this expensereport) - $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,"; - $sql .= "c.code as p_code, c.libelle as payment_type,"; - $sql .= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; - $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; - $sql .= " WHERE e.rowid = '".$id."'"; - $sql .= " AND p.fk_expensereport = e.rowid"; - $sql .= ' AND e.entity IN ('.getEntity('expensereport').')'; - $sql .= " ORDER BY dp"; + // Payments already done (from payment on this expensereport) + $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,"; + $sql .= "c.code as p_code, c.libelle as payment_type,"; + $sql .= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; + $sql .= " WHERE e.rowid = '".$id."'"; + $sql .= " AND p.fk_expensereport = e.rowid"; + $sql .= ' AND e.entity IN ('.getEntity('expensereport').')'; + $sql .= " ORDER BY dp"; - $resql = $db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; $totalpaid = 0; @@ -2000,29 +2000,29 @@ if ($action == 'create') { } else { dol_print_error($db); } - print "
'.$langs->trans('Payments').''.$langs->trans('Date').''.$langs->trans('Type').'
'.$langs->trans('Payments').''.$langs->trans('Date').''.$langs->trans('Type').''.$langs->trans('BankAccount').''.$langs->trans('Amount').' 
'.$langs->trans('Amount').' 
"; + print ""; - print '
'; - print '
'; - print '
'; + print '
'; + print '
'; + print '
'; - print '

'; + print '

'; - print '
'; + print '
'; - $actiontouse = 'updateline'; + $actiontouse = 'updateline'; if (($object->status == 0 || $object->status == 99) && $action != 'editline') { $actiontouse = 'addline'; } - print '
'; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print '
'; - print ''; + print '
'; + print '
'; if (!empty($object->lines)) { $i = 0; $total = 0; @@ -2214,6 +2214,7 @@ if ($action == 'create') { $colspan++; } + print ''."\n"; print ''; print ''; + print ''; print ''; } @@ -2344,10 +2347,8 @@ if ($action == 'create') { } // Add a new line - if (($object->status == ExpenseReport::STATUS_DRAFT || $object->status == ExpenseReport::STATUS_REFUSED) - && $action != 'editline' - && $user->rights->expensereport->creer) { - $colspan = 11; + if (($object->status == ExpenseReport::STATUS_DRAFT || $object->status == ExpenseReport::STATUS_REFUSED) && $action != 'editline' && $user->rights->expensereport->creer) { + $colspan = 11; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { $colspan++; } @@ -2358,8 +2359,8 @@ if ($action == 'create') { $colspan++; } - $nbFiles = $nbLinks = 0; - $arrayoffiles = array(); + $nbFiles = $nbLinks = 0; + $arrayoffiles = array(); if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; @@ -2370,21 +2371,21 @@ if ($action == 'create') { $nbLinks = Link::count($db, $object->element, $object->id); } - // Add line with link to add new file or attach to an existing file - print ''; - print ''; + print ''; + print ''."\n"; + print ''; - include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_linktofile.tpl.php'; - include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_addfile.tpl.php'; + include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_linktofile.tpl.php'; + include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_addfile.tpl.php'; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if (!empty($conf->projet->enabled)) { print ''; } - print ''; + print ''; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { print ''; } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print ''; + print ''; - // Line number - print ''; + // Line number + print ''; - // Select date - print ''; + // Select date + print ''; - // Select project + // Select project if (!empty($conf->projet->enabled)) { print ''; } - // Add comments - print ''; + // Add comments + print ''; - // Select VAT - print ''; + print $form->load_tva('vatrate', ($vatrate != '' ? $vatrate : $defaultvat), $mysoc, '', 0, 0, '', false, 1); + print ''; - // Unit price net - print ''; + // Unit price net + print ''; - // Unit price with tax - print ''; + // Unit price with tax + print ''; - // Quantity - print ''; + // Quantity + print ''; - // Picture - print ''; + // Picture + print ''; if ($action != 'editline') { print ''; print ''; } - print ''; + print ''; - print ''; + print ''; } // Fin si c'est payé/validé print '
'; @@ -2333,8 +2334,10 @@ if ($action == 'create') { //print $line->fk_ecm_files; print ''; print ''; - print $form->buttonsSaveCancel(); + print $form->buttonsSaveCancel('Save', 'Cancel', array(), 0, 'small'); + print '
'; - print ''.$langs->trans("UploadANewFileNow"); - print img_picto($langs->trans("UploadANewFileNow"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); - print ''; + // Add line with link to add new file or attach to an existing file + print '
'; + print ''.$langs->trans("UploadANewFileNow"); + print img_picto($langs->trans("UploadANewFileNow"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); + print ''; if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { print '   -   '.$langs->trans("AttachTheNewLineToTheDocument"); print img_picto($langs->trans("AttachTheNewLineToTheDocument"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); print ''; } - print ''."\n"; - print ''."\n"; - print '
'.$langs->trans('Date').'
'.$langs->trans('Date').''.$form->textwithpicto($langs->trans('Project'), $langs->trans("ClosedProjectsAreHidden")).''.$langs->trans('Type').''.$langs->trans('Type').''.$langs->trans('CarCategory').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUTTC').''.$langs->trans('Qty').'
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUTTC').''.$langs->trans('Qty').'
'; - print $form->selectDate($date ? $date : -1, 'date', 0, 0, 0, '', 1, 1); - print ''; + print $form->selectDate($date ? $date : -1, 'date', 0, 0, 0, '', 1, 1); + print ''; $formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, $projectRequired ? 0 : 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300'); @@ -2475,48 +2476,48 @@ if ($action == 'create') { print ''; - print ''; - print ''; + print ''; + print ''; - $defaultvat = -1; + // Select VAT + print ''; + $defaultvat = -1; if (!empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) { $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none'; } - print $form->load_tva('vatrate', ($vatrate != '' ? $vatrate : $defaultvat), $mysoc, '', 0, 0, '', false, 1); - print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; // We must be able to enter decimal qty - print ''; + print ''; // We must be able to enter decimal qty + print ''; - print $form->buttonsSaveCancel("Add", '', '', 1); - print ''; + print $form->buttonsSaveCancel("Add", '', '', 1); + print '
'; diff --git a/htdocs/expensereport/tpl/expensereport_addfile.tpl.php b/htdocs/expensereport/tpl/expensereport_addfile.tpl.php index c27136ebd38..d74b68e6738 100644 --- a/htdocs/expensereport/tpl/expensereport_addfile.tpl.php +++ b/htdocs/expensereport/tpl/expensereport_addfile.tpl.php @@ -2,7 +2,14 @@ // Add line to upload new file print ''."\n"; print 'global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ' style="display: none"' : '').'>'; -print ''; + +// Num line +if ($action == 'editline') { + print ''; +} + +// Upload section +print ''; $modulepart = 'expensereport'; $permission = $user->rights->expensereport->creer; diff --git a/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php b/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php index 9264400a71f..33cfc0976fe 100644 --- a/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php +++ b/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php @@ -13,7 +13,14 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { if ($nbFiles > 0) { print 'global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ' style="display: none"' : '').'>'; - print ''; + + // Num line + if ($action == 'editline') { + print ''; + } + + // Select image section + print ''; //print ''.$langs->trans("AttachTheNewLineToTheDocument").'
'; $modulepart = 'expensereport'; $maxheightmini = 48; $relativepath = (!empty($object->ref) ?dol_sanitizeFileName($object->ref) : '').'/'; @@ -112,8 +119,8 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { if (!empty($filenamelinked) && $filenamelinked == $file['relativename']) { $checked = ' checked'; } - print '
'; - print ''; + print '
'; + print ''; print '
'; print '
'; diff --git a/htdocs/langs/fr_FR/projects.lang b/htdocs/langs/fr_FR/projects.lang index 9a7f3c189bc..53e1e80a0e8 100644 --- a/htdocs/langs/fr_FR/projects.lang +++ b/htdocs/langs/fr_FR/projects.lang @@ -274,6 +274,7 @@ NewInter=Nouvelle intervention OneLinePerTask=Une ligne par tâche OneLinePerPeriod=Une ligne par période OneLinePerTimeSpentLine=Une ligne pour chaque déclaration de temps passé +AddDetailDateAndDuration=Avec date et durée dans la description de la ligne RefTaskParent=Réf. Tâche parent ProfitIsCalculatedWith=Le bénéfice est calculé sur la base de AddPersonToTask=Ajouter également aux tâches @@ -281,3 +282,4 @@ UsageOrganizeEvent=Utilisation: Organisation d'événements PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE=Classer le projet comme étant clos lorsque toutes ses tâches sont terminées (progression 100%%) PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE_help=Remarque : les projets existants avec toutes les tâches terminées à 100 %% ne seront pas affectés : vous devrez les fermer manuellement. Cette option n’affecte que les projets ouverts. SelectLinesOfTimeSpentToInvoice=Sélectionnez les lignes de temps consacré non facturées, puis l'action groupée "Générer la facture" pour les facturer +ProjectTasksWithoutTimeSpent=Project tasks without time spent diff --git a/htdocs/langs/fr_FR/propal.lang b/htdocs/langs/fr_FR/propal.lang index b019b275e6e..f822d4f1d02 100644 --- a/htdocs/langs/fr_FR/propal.lang +++ b/htdocs/langs/fr_FR/propal.lang @@ -33,7 +33,7 @@ PropalStatusSigned=Signée (à facturer) PropalStatusNotSigned=Non signée (fermée) PropalStatusBilled=Facturée PropalStatusDraftShort=Brouillon -PropalStatusValidatedShort=Validé (ouvert) +PropalStatusValidatedShort=Ouvert PropalStatusClosedShort=Fermée PropalStatusSignedShort=Signée PropalStatusNotSignedShort=Non signée diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index c14392540ee..0eb55107a0c 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -886,6 +886,13 @@ span.fa.fa-plus-circle.paddingleft { font-size: 1.5em; vertical-align: text-bottom; } +.divoverflow { + overflow: hidden; + white-space: nowrap; + vertical-align: middle; + text-overflow: ellipsis; +} + /* Themes for badges */