diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index bd9f25bb0b8..59984ee444c 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -288,262 +288,251 @@ elseif ($modecompta=="BOOKKEEPING") $j=1; $sommes = array(); $totPerAccount = array(); - - foreach ($cats as $cat) // Loop on each group - { - if (!empty($cat['category_type'])) // category calculed + if (!is_array($cats) && $cats<0) { + setEventMessages(null,$AccCat->errors,'errors'); + } elseif (is_array($cats) && count($cats)>0) { + foreach ($cats as $cat) // Loop on each group { - // When we enter here, $sommes was filled by group of accounts + if (!empty($cat['category_type'])) // category calculed + { + // When we enter here, $sommes was filled by group of accounts - $formula = $cat['formula']; + $formula = $cat['formula']; - print ''; + print ''; - // Year NP - print ''; - print $cat['code']; - print ''; - print $cat['label']; - print ''; + // Year NP + print ''; + print $cat['code']; + print ''; + print $cat['label']; + print ''; - $vars = array(); + $vars = array(); - // Previous Fiscal year (N-1) - foreach($sommes as $code => $det){ - $vars[$code] = $det['NP']; - } - - - $result = strtr($formula, $vars); - - //var_dump($result); - //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1); - //var_dump($r); - - print '' . price($r) . ''; - - // Year N - $code = $cat['code']; // code of categorie ('VTE', 'MAR', ...) - $sommes[$code]['NP'] += $r; - - // Current fiscal year (N) - if (is_array($sommes) && ! empty($sommes)){ - foreach($sommes as $code => $det){ - $vars[$code] = $det['N']; + // Previous Fiscal year (N-1) + foreach ($sommes as $code => $det) { + $vars[$code] = $det['NP']; } - } - $result = strtr($formula, $vars); - //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1); + $result = strtr($formula, $vars); - print '' . price($r) . ''; - $sommes[$code]['N'] += $r; + //var_dump($result); + //$r = $AccCat->calculate($result); + $r = dol_eval($result, 1); + //var_dump($r); - // Detail by month - foreach($months as $k => $v) - { - if (($k+1) >= $date_startmonth) - { - foreach($sommes as $code => $det){ - $vars[$code] = $det['M'][$k]; - } - $result = strtr($formula, $vars); + print '' . price($r) . ''; - //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1); + // Year N + $code = $cat['code']; // code of categorie ('VTE', 'MAR', ...) + $sommes[$code]['NP'] += $r; - print '' . price($r) . ''; - $sommes[$code]['M'][$k] += $r; - } - } - foreach($months as $k => $v) - { - if (($k+1) < $date_startmonth) - { - foreach($sommes as $code => $det){ - $vars[$code] = $det['M'][$k]; - } - $result = strtr($formula, $vars); - - //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1); - - print '' . price($r) . ''; - $sommes[$code]['M'][$k] += $r; - } - } - - print "\n"; - - //var_dump($sommes); - } - else // normal category - { - $code = $cat['code']; // Category code we process - - $totCat = array(); - $totCat['NP'] = 0; - $totCat['N'] = 0; - $totCat['M'] = array(); - foreach($months as $k => $v) - { - $totCat['M'][$k] = 0; - } - - // Set $cpts with array of accounts in the category/group - $cpts = $AccCat->getCptsCat($cat['rowid']); - - $arrayofaccountforfilter=array(); - foreach($cpts as $i => $cpt) // Loop on each account. - { - $arrayofaccountforfilter[]=$cpt['account_number']; - } - - // N-1 - if (! empty($arrayofaccountforfilter)) - { - $return = $AccCat->getSumDebitCredit($arrayofaccountforfilter, $date_start_previous, $date_end_previous, $cat['dc']?$cat['dc']:0); - - if ($return < 0) { - setEventMessages(null, $AccCat->errors, 'errors'); - $resultNP=0; - } else { - foreach($cpts as $i => $cpt) // Loop on each account. - { - $resultNP = empty($AccCat->sdcperaccount[$cpt['account_number']])?0:$AccCat->sdcperaccount[$cpt['account_number']]; - - $totCat['NP'] += $resultNP; - $sommes[$code]['NP'] += $resultNP; - $totPerAccount[$cpt['account_number']]['NP'] = $resultNP; + // Current fiscal year (N) + if (is_array($sommes) && !empty($sommes)) { + foreach ($sommes as $code => $det) { + $vars[$code] = $det['N']; } } - } - // Set value into column N and month M ($totCat) - // This make 12 calls for each accountancy account (12 monthes M) - foreach($cpts as $i => $cpt) // Loop on each account. + $result = strtr($formula, $vars); + + //$r = $AccCat->calculate($result); + $r = dol_eval($result, 1); + + print '' . price($r) . ''; + $sommes[$code]['N'] += $r; + + // Detail by month + foreach ($months as $k => $v) { + if (($k + 1) >= $date_startmonth) { + foreach ($sommes as $code => $det) { + $vars[$code] = $det['M'][$k]; + } + $result = strtr($formula, $vars); + + //$r = $AccCat->calculate($result); + $r = dol_eval($result, 1); + + print '' . price($r) . ''; + $sommes[$code]['M'][$k] += $r; + } + } + foreach ($months as $k => $v) { + if (($k + 1) < $date_startmonth) { + foreach ($sommes as $code => $det) { + $vars[$code] = $det['M'][$k]; + } + $result = strtr($formula, $vars); + + //$r = $AccCat->calculate($result); + $r = dol_eval($result, 1); + + print '' . price($r) . ''; + $sommes[$code]['M'][$k] += $r; + } + } + + print "\n"; + + //var_dump($sommes); + } else // normal category { - // We make 1 loop for each account because we may want detail per account. - // @TODO Optimize to ask a 'group by' account and a filter with account in (..., ...) in request + $code = $cat['code']; // Category code we process - // Each month - $resultN = 0; - foreach($months as $k => $v) + $totCat = array(); + $totCat['NP'] = 0; + $totCat['N'] = 0; + $totCat['M'] = array(); + foreach ($months as $k => $v) { + $totCat['M'][$k] = 0; + } + + // Set $cpts with array of accounts in the category/group + $cpts = $AccCat->getCptsCat($cat['rowid']); + + $arrayofaccountforfilter = array(); + foreach ($cpts as $i => $cpt) // Loop on each account. { - $monthtoprocess = $k+1; // ($k+1) is month 1, 2, ..., 12 - $yeartoprocess = $start_year; - if (($k+1) < $start_month) $yeartoprocess++; + $arrayofaccountforfilter[] = $cpt['account_number']; + } + + // N-1 + if (!empty($arrayofaccountforfilter)) { + $return = $AccCat->getSumDebitCredit($arrayofaccountforfilter, $date_start_previous, $date_end_previous, $cat['dc'] ? $cat['dc'] : 0); - //var_dump($monthtoprocess.'_'.$yeartoprocess); - $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, $cat['dc']?$cat['dc']:0, 'nofilter', $monthtoprocess, $yeartoprocess); if ($return < 0) { setEventMessages(null, $AccCat->errors, 'errors'); - $resultM=0; + $resultNP = 0; } else { - $resultM=$AccCat->sdc; - } - $totCat['M'][$k] += $resultM; - $sommes[$code]['M'][$k] += $resultM; - $totPerAccount[$cpt['account_number']]['M'][$k] = $resultM; + foreach ($cpts as $i => $cpt) // Loop on each account. + { + $resultNP = empty($AccCat->sdcperaccount[$cpt['account_number']]) ? 0 : $AccCat->sdcperaccount[$cpt['account_number']]; - $resultN += $resultM; + $totCat['NP'] += $resultNP; + $sommes[$code]['NP'] += $resultNP; + $totPerAccount[$cpt['account_number']]['NP'] = $resultNP; + } + } } - $totCat['N'] += $resultN; - $sommes[$code]['N'] += $resultN; - $totPerAccount[$cpt['account_number']]['N'] = $resultN; - } - - - // Now output columns for row $code ('VTE', 'MAR', ...) - - print ""; - - // Column group - print ''; - print $cat['code']; - print ''; - - // Label of group - print ''; - print $cat['label']; - if (count($cpts) > 0) // Show example of 5 first accounting accounts - { - $i=0; - foreach($cpts as $cpt) + // Set value into column N and month M ($totCat) + // This make 12 calls for each accountancy account (12 monthes M) + foreach ($cpts as $i => $cpt) // Loop on each account. { - if ($i > 5) - { - print '...)'; - break; + // We make 1 loop for each account because we may want detail per account. + // @TODO Optimize to ask a 'group by' account and a filter with account in (..., ...) in request + + // Each month + $resultN = 0; + foreach ($months as $k => $v) { + $monthtoprocess = $k + 1; // ($k+1) is month 1, 2, ..., 12 + $yeartoprocess = $start_year; + if (($k + 1) < $start_month) + $yeartoprocess++; + + //var_dump($monthtoprocess.'_'.$yeartoprocess); + $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, $cat['dc'] ? $cat['dc'] : 0, 'nofilter', $monthtoprocess, $yeartoprocess); + if ($return < 0) { + setEventMessages(null, $AccCat->errors, 'errors'); + $resultM = 0; + } else { + $resultM = $AccCat->sdc; + } + $totCat['M'][$k] += $resultM; + $sommes[$code]['M'][$k] += $resultM; + $totPerAccount[$cpt['account_number']]['M'][$k] = $resultM; + + $resultN += $resultM; } - if ($i > 0) print ', '; - else print ' ('; - print $cpt['account_number']; - $i++; + + $totCat['N'] += $resultN; + $sommes[$code]['N'] += $resultN; + $totPerAccount[$cpt['account_number']]['N'] = $resultN; } - if ($i <= 5) print ')'; - } - else - { - print ' - '.$langs->trans("GroupIsEmptyCheckSetup").''; - } - print ''; - print '' . price($totCat['NP']) . ''; - print '' . price($totCat['N']) . ''; - // Each month - foreach($totCat['M'] as $k => $v){ - if (($k+1) >= $date_startmonth) print '' . price($v) . ''; - } - foreach($totCat['M'] as $k => $v){ - if (($k+1) < $date_startmonth) print '' . price($v) . ''; - } + // Now output columns for row $code ('VTE', 'MAR', ...) - print "\n"; + print ""; - // Loop on detail of all accounts to output the detail - if ($showaccountdetail != 'no') - { - foreach($cpts as $i => $cpt) + // Column group + print ''; + print $cat['code']; + print ''; + + // Label of group + print ''; + print $cat['label']; + if (count($cpts) > 0) // Show example of 5 first accounting accounts { - $resultNP=$totPerAccount[$cpt['account_number']]['NP']; - $resultN=$totPerAccount[$cpt['account_number']]['N']; - - if ($showaccountdetail == 'all' || $resultN > 0) - { - print ''; - print ''; - print ''; - print '     ' . length_accountg($cpt['account_number']); - print ' - '; - print $cpt['account_label']; - print ''; - print '' . price($resultNP) . ''; - print '' . price($resultN) . ''; - - // Make one call for each month - foreach($months as $k => $v) - { - if (($k+1) >= $date_startmonth) - { - $resultM=$totPerAccount[$cpt['account_number']]['M'][$k]; - print '' . price($resultM) . ''; - } + $i = 0; + foreach ($cpts as $cpt) { + if ($i > 5) { + print '...)'; + break; } - foreach($months as $k => $v) - { - if (($k+1) < $date_startmonth) - { - $resultM=$totPerAccount[$cpt['account_number']]['M'][$k]; - print '' . price($resultM) . ''; + if ($i > 0) + print ', '; + else print ' ('; + print $cpt['account_number']; + $i++; + } + if ($i <= 5) + print ')'; + } else { + print ' - ' . $langs->trans("GroupIsEmptyCheckSetup") . ''; + } + print ''; + + print '' . price($totCat['NP']) . ''; + print '' . price($totCat['N']) . ''; + + // Each month + foreach ($totCat['M'] as $k => $v) { + if (($k + 1) >= $date_startmonth) + print '' . price($v) . ''; + } + foreach ($totCat['M'] as $k => $v) { + if (($k + 1) < $date_startmonth) + print '' . price($v) . ''; + } + + print "\n"; + + // Loop on detail of all accounts to output the detail + if ($showaccountdetail != 'no') { + foreach ($cpts as $i => $cpt) { + $resultNP = $totPerAccount[$cpt['account_number']]['NP']; + $resultN = $totPerAccount[$cpt['account_number']]['N']; + + if ($showaccountdetail == 'all' || $resultN > 0) { + print ''; + print ''; + print ''; + print '     ' . length_accountg($cpt['account_number']); + print ' - '; + print $cpt['account_label']; + print ''; + print '' . price($resultNP) . ''; + print '' . price($resultN) . ''; + + // Make one call for each month + foreach ($months as $k => $v) { + if (($k + 1) >= $date_startmonth) { + $resultM = $totPerAccount[$cpt['account_number']]['M'][$k]; + print '' . price($resultM) . ''; + } } + foreach ($months as $k => $v) { + if (($k + 1) < $date_startmonth) { + $resultM = $totPerAccount[$cpt['account_number']]['M'][$k]; + print '' . price($resultM) . ''; + } + } + print "\n"; } - print "\n"; } } } diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index ec2f539369f..8ea15b31938 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -517,7 +517,6 @@ abstract class CommonInvoice extends CommonObject return dolGetStatus($labelstatut, $labelstatutShort, '', $statusType, $mode); - } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 15494a51758..c6d87acef4d 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -933,7 +933,7 @@ if (empty($reshook)) } } - if ($action == "confirm_brouillonner" && GETPOST('confirm', 'alpha')=="yes" && $id > 0 && $user->rights->expensereport->creer) + if ($action == "confirm_setdraft" && GETPOST('confirm', 'alpha')=="yes" && $id > 0 && $user->rights->expensereport->creer) { $object = new ExpenseReport($db); $object->fetch($id); @@ -1640,9 +1640,9 @@ else $formconfirm=$form->formconfirm($_SEVER["PHP_SELF"]."?id=".$id, $langs->trans("Cancel"), "", "confirm_cancel", $array_input, "", 1); } - if ($action == 'brouillonner') + if ($action == 'setdraft') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("BrouillonnerTrip"), $langs->trans("ConfirmBrouillonnerTrip"), "confirm_brouillonner", "", "", 1); + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("BrouillonnerTrip"), $langs->trans("ConfirmBrouillonnerTrip"), "confirm_setdraft", "", "", 1); } if ($action == 'refuse') // Deny @@ -2431,7 +2431,7 @@ if ($action != 'create' && $action != 'edit') // Modify print '
id.'">'.$langs->trans('Modify').'
'; - // Brouillonner (le statut refusée est identique à brouillon) + // setdraft (le statut refusée est identique à brouillon) //print ''.$langs->trans('BROUILLONNER').''; // Enregistrer depuis le statut "Refusée" print '
id.'">'.$langs->trans('ValidateAndSubmit').'
'; @@ -2442,8 +2442,8 @@ if ($action != 'create' && $action != 'edit') { if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) { - // Brouillonner - print '
id.'">'.$langs->trans('SetToDraft').'
'; + // setdraft + print '
id.'">'.$langs->trans('SetToDraft').'
'; } } @@ -2456,8 +2456,8 @@ if ($action != 'create' && $action != 'edit') { if (in_array($object->fk_user_author, $user->getAllChildIds(1))) { - // Brouillonner - print '
id.'">'.$langs->trans('SetToDraft').'
'; + // set draft + print '
id.'">'.$langs->trans('SetToDraft').'
'; } } diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 3070515b020..efe6b261e83 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -337,8 +337,8 @@ class FormProduct $return .= ''; foreach ($measuringUnits->records as $lines) { - $return .= ''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 8d446682dfd..f186c1d21da 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4168,7 +4168,7 @@ class Product extends CommonObject case 2: return $this->LibStatut($status, 3, 2).' '.$this->LibStatut($status, 1, 2); case 3: - return dolGetStatus($langs->trans('ProductStatusNotOnBatch'), '','',empty($status)?'status5':'status4',3,'dot'); + return dolGetStatus($langs->trans('ProductStatusNotOnBatch'), '', '', empty($status)?'status5':'status4', 3, 'dot'); case 4: return $this->LibStatut($status, 3, 2).' '.$this->LibStatut($status, 0, 2); case 5: @@ -4213,11 +4213,11 @@ class Product extends CommonObject if($mode>6){ - return dolGetStatus($langs->trans('Unknown'),'', '', 'status0', 0); + return dolGetStatus($langs->trans('Unknown'), '', '', 'status0', 0); } else{ return dolGetStatus($labelstatut, $labelstatutShort, '', $statuttrans, $mode); - } + } } diff --git a/htdocs/product/dynamic_price/class/price_parser.class.php b/htdocs/product/dynamic_price/class/price_parser.class.php index 8e8b8e4fcc9..d7c066d01c9 100644 --- a/htdocs/product/dynamic_price/class/price_parser.class.php +++ b/htdocs/product/dynamic_price/class/price_parser.class.php @@ -157,10 +157,13 @@ class PriceParser $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label('product', true); $product->fetch_optionals(); - foreach ($extrafields->attributes[$product->table_element]['label'] as $key=>$label) - { - $values["extrafield_".$key] = $product->array_options['options_'.$key]; - } + if (is_array($extrafields->attributes[$product->table_element]['label'])) + { + foreach ($extrafields->attributes[$product->table_element]['label'] as $key=>$label) + { + $values["extrafield_".$key] = $product->array_options['options_'.$key]; + } + } //Process any pending updaters $price_updaters = new PriceGlobalVariableUpdater($this->db); diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 1cbda302574..ae557aeb885 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1630,7 +1630,7 @@ a.tmenuimage:hover{ else { print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; - $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.(min($generic,4))."_over.png", 1); + $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.(min($generic, 4))."_over.png", 1); print "div.mainmenu.".$val." {\n"; print " background-image: url(".$url.");\n"; print "}\n"; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index a294ddf4b86..cebdaad8164 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1824,7 +1824,7 @@ foreach($mainmenuusedarray as $val) else { print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; - $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.(min($generic,4))."_over.png", 1); + $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.(min($generic, 4))."_over.png", 1); print "div.mainmenu.".$val." {\n"; print " background-image: url(".$url.");\n"; print "}\n";