Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2019-03-14 14:20:42 +01:00
commit 58fa1292f2
8 changed files with 230 additions and 239 deletions

View File

@ -288,7 +288,9 @@ elseif ($modecompta=="BOOKKEEPING")
$j=1; $j=1;
$sommes = array(); $sommes = array();
$totPerAccount = array(); $totPerAccount = array();
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 foreach ($cats as $cat) // Loop on each group
{ {
if (!empty($cat['category_type'])) // category calculed if (!empty($cat['category_type'])) // category calculed
@ -309,7 +311,7 @@ elseif ($modecompta=="BOOKKEEPING")
$vars = array(); $vars = array();
// Previous Fiscal year (N-1) // Previous Fiscal year (N-1)
foreach($sommes as $code => $det){ foreach ($sommes as $code => $det) {
$vars[$code] = $det['NP']; $vars[$code] = $det['NP'];
} }
@ -328,8 +330,8 @@ elseif ($modecompta=="BOOKKEEPING")
$sommes[$code]['NP'] += $r; $sommes[$code]['NP'] += $r;
// Current fiscal year (N) // Current fiscal year (N)
if (is_array($sommes) && ! empty($sommes)){ if (is_array($sommes) && !empty($sommes)) {
foreach($sommes as $code => $det){ foreach ($sommes as $code => $det) {
$vars[$code] = $det['N']; $vars[$code] = $det['N'];
} }
} }
@ -343,11 +345,9 @@ elseif ($modecompta=="BOOKKEEPING")
$sommes[$code]['N'] += $r; $sommes[$code]['N'] += $r;
// Detail by month // Detail by month
foreach($months as $k => $v) foreach ($months as $k => $v) {
{ if (($k + 1) >= $date_startmonth) {
if (($k+1) >= $date_startmonth) foreach ($sommes as $code => $det) {
{
foreach($sommes as $code => $det){
$vars[$code] = $det['M'][$k]; $vars[$code] = $det['M'][$k];
} }
$result = strtr($formula, $vars); $result = strtr($formula, $vars);
@ -359,11 +359,9 @@ elseif ($modecompta=="BOOKKEEPING")
$sommes[$code]['M'][$k] += $r; $sommes[$code]['M'][$k] += $r;
} }
} }
foreach($months as $k => $v) foreach ($months as $k => $v) {
{ if (($k + 1) < $date_startmonth) {
if (($k+1) < $date_startmonth) foreach ($sommes as $code => $det) {
{
foreach($sommes as $code => $det){
$vars[$code] = $det['M'][$k]; $vars[$code] = $det['M'][$k];
} }
$result = strtr($formula, $vars); $result = strtr($formula, $vars);
@ -379,8 +377,7 @@ elseif ($modecompta=="BOOKKEEPING")
print "</tr>\n"; print "</tr>\n";
//var_dump($sommes); //var_dump($sommes);
} } else // normal category
else // normal category
{ {
$code = $cat['code']; // Category code we process $code = $cat['code']; // Category code we process
@ -388,32 +385,30 @@ elseif ($modecompta=="BOOKKEEPING")
$totCat['NP'] = 0; $totCat['NP'] = 0;
$totCat['N'] = 0; $totCat['N'] = 0;
$totCat['M'] = array(); $totCat['M'] = array();
foreach($months as $k => $v) foreach ($months as $k => $v) {
{
$totCat['M'][$k] = 0; $totCat['M'][$k] = 0;
} }
// Set $cpts with array of accounts in the category/group // Set $cpts with array of accounts in the category/group
$cpts = $AccCat->getCptsCat($cat['rowid']); $cpts = $AccCat->getCptsCat($cat['rowid']);
$arrayofaccountforfilter=array(); $arrayofaccountforfilter = array();
foreach($cpts as $i => $cpt) // Loop on each account. foreach ($cpts as $i => $cpt) // Loop on each account.
{ {
$arrayofaccountforfilter[]=$cpt['account_number']; $arrayofaccountforfilter[] = $cpt['account_number'];
} }
// N-1 // N-1
if (! empty($arrayofaccountforfilter)) if (!empty($arrayofaccountforfilter)) {
{ $return = $AccCat->getSumDebitCredit($arrayofaccountforfilter, $date_start_previous, $date_end_previous, $cat['dc'] ? $cat['dc'] : 0);
$return = $AccCat->getSumDebitCredit($arrayofaccountforfilter, $date_start_previous, $date_end_previous, $cat['dc']?$cat['dc']:0);
if ($return < 0) { if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors'); setEventMessages(null, $AccCat->errors, 'errors');
$resultNP=0; $resultNP = 0;
} else { } else {
foreach($cpts as $i => $cpt) // Loop on each account. foreach ($cpts as $i => $cpt) // Loop on each account.
{ {
$resultNP = empty($AccCat->sdcperaccount[$cpt['account_number']])?0:$AccCat->sdcperaccount[$cpt['account_number']]; $resultNP = empty($AccCat->sdcperaccount[$cpt['account_number']]) ? 0 : $AccCat->sdcperaccount[$cpt['account_number']];
$totCat['NP'] += $resultNP; $totCat['NP'] += $resultNP;
$sommes[$code]['NP'] += $resultNP; $sommes[$code]['NP'] += $resultNP;
@ -424,26 +419,26 @@ elseif ($modecompta=="BOOKKEEPING")
// Set value into column N and month M ($totCat) // Set value into column N and month M ($totCat)
// This make 12 calls for each accountancy account (12 monthes M) // This make 12 calls for each accountancy account (12 monthes M)
foreach($cpts as $i => $cpt) // Loop on each account. foreach ($cpts as $i => $cpt) // Loop on each account.
{ {
// We make 1 loop for each account because we may want detail per account. // 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 // @TODO Optimize to ask a 'group by' account and a filter with account in (..., ...) in request
// Each month // Each month
$resultN = 0; $resultN = 0;
foreach($months as $k => $v) foreach ($months as $k => $v) {
{ $monthtoprocess = $k + 1; // ($k+1) is month 1, 2, ..., 12
$monthtoprocess = $k+1; // ($k+1) is month 1, 2, ..., 12
$yeartoprocess = $start_year; $yeartoprocess = $start_year;
if (($k+1) < $start_month) $yeartoprocess++; if (($k + 1) < $start_month)
$yeartoprocess++;
//var_dump($monthtoprocess.'_'.$yeartoprocess); //var_dump($monthtoprocess.'_'.$yeartoprocess);
$return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, $cat['dc']?$cat['dc']:0, 'nofilter', $monthtoprocess, $yeartoprocess); $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, $cat['dc'] ? $cat['dc'] : 0, 'nofilter', $monthtoprocess, $yeartoprocess);
if ($return < 0) { if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors'); setEventMessages(null, $AccCat->errors, 'errors');
$resultM=0; $resultM = 0;
} else { } else {
$resultM=$AccCat->sdc; $resultM = $AccCat->sdc;
} }
$totCat['M'][$k] += $resultM; $totCat['M'][$k] += $resultM;
$sommes[$code]['M'][$k] += $resultM; $sommes[$code]['M'][$k] += $resultM;
@ -472,24 +467,22 @@ elseif ($modecompta=="BOOKKEEPING")
print $cat['label']; print $cat['label'];
if (count($cpts) > 0) // Show example of 5 first accounting accounts if (count($cpts) > 0) // Show example of 5 first accounting accounts
{ {
$i=0; $i = 0;
foreach($cpts as $cpt) foreach ($cpts as $cpt) {
{ if ($i > 5) {
if ($i > 5)
{
print '...)'; print '...)';
break; break;
} }
if ($i > 0) print ', '; if ($i > 0)
print ', ';
else print ' ('; else print ' (';
print $cpt['account_number']; print $cpt['account_number'];
$i++; $i++;
} }
if ($i <= 5) print ')'; if ($i <= 5)
} print ')';
else } else {
{ print ' - <span class="warning">' . $langs->trans("GroupIsEmptyCheckSetup") . '</span>';
print ' - <span class="warning">'.$langs->trans("GroupIsEmptyCheckSetup").'</span>';
} }
print '</td>'; print '</td>';
@ -497,25 +490,24 @@ elseif ($modecompta=="BOOKKEEPING")
print '<td class="right">' . price($totCat['N']) . '</td>'; print '<td class="right">' . price($totCat['N']) . '</td>';
// Each month // Each month
foreach($totCat['M'] as $k => $v){ foreach ($totCat['M'] as $k => $v) {
if (($k+1) >= $date_startmonth) print '<td class="right">' . price($v) . '</td>'; if (($k + 1) >= $date_startmonth)
print '<td class="right">' . price($v) . '</td>';
} }
foreach($totCat['M'] as $k => $v){ foreach ($totCat['M'] as $k => $v) {
if (($k+1) < $date_startmonth) print '<td class="right">' . price($v) . '</td>'; if (($k + 1) < $date_startmonth)
print '<td class="right">' . price($v) . '</td>';
} }
print "</tr>\n"; print "</tr>\n";
// Loop on detail of all accounts to output the detail // Loop on detail of all accounts to output the detail
if ($showaccountdetail != 'no') if ($showaccountdetail != 'no') {
{ foreach ($cpts as $i => $cpt) {
foreach($cpts as $i => $cpt) $resultNP = $totPerAccount[$cpt['account_number']]['NP'];
{ $resultN = $totPerAccount[$cpt['account_number']]['N'];
$resultNP=$totPerAccount[$cpt['account_number']]['NP'];
$resultN=$totPerAccount[$cpt['account_number']]['N'];
if ($showaccountdetail == 'all' || $resultN > 0) if ($showaccountdetail == 'all' || $resultN > 0) {
{
print '<tr>'; print '<tr>';
print '<td></td>'; print '<td></td>';
print '<td class="tdoverflowmax200">'; print '<td class="tdoverflowmax200">';
@ -527,19 +519,15 @@ elseif ($modecompta=="BOOKKEEPING")
print '<td class="right">' . price($resultN) . '</td>'; print '<td class="right">' . price($resultN) . '</td>';
// Make one call for each month // Make one call for each month
foreach($months as $k => $v) foreach ($months as $k => $v) {
{ if (($k + 1) >= $date_startmonth) {
if (($k+1) >= $date_startmonth) $resultM = $totPerAccount[$cpt['account_number']]['M'][$k];
{
$resultM=$totPerAccount[$cpt['account_number']]['M'][$k];
print '<td class="right">' . price($resultM) . '</td>'; print '<td class="right">' . price($resultM) . '</td>';
} }
} }
foreach($months as $k => $v) foreach ($months as $k => $v) {
{ if (($k + 1) < $date_startmonth) {
if (($k+1) < $date_startmonth) $resultM = $totPerAccount[$cpt['account_number']]['M'][$k];
{
$resultM=$totPerAccount[$cpt['account_number']]['M'][$k];
print '<td class="right">' . price($resultM) . '</td>'; print '<td class="right">' . price($resultM) . '</td>';
} }
} }
@ -549,6 +537,7 @@ elseif ($modecompta=="BOOKKEEPING")
} }
} }
} }
}
} }
print "</table>"; print "</table>";

View File

@ -517,7 +517,6 @@ abstract class CommonInvoice extends CommonObject
return dolGetStatus($labelstatut, $labelstatutShort, '', $statusType, $mode); return dolGetStatus($labelstatut, $labelstatutShort, '', $statusType, $mode);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

View File

@ -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 = new ExpenseReport($db);
$object->fetch($id); $object->fetch($id);
@ -1640,9 +1640,9 @@ else
$formconfirm=$form->formconfirm($_SEVER["PHP_SELF"]."?id=".$id, $langs->trans("Cancel"), "", "confirm_cancel", $array_input, "", 1); $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 if ($action == 'refuse') // Deny
@ -2431,7 +2431,7 @@ if ($action != 'create' && $action != 'edit')
// Modify // Modify
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$object->id.'">'.$langs->trans('Modify').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$object->id.'">'.$langs->trans('Modify').'</a></div>';
// Brouillonner (le statut refusée est identique à brouillon) // setdraft (le statut refusée est identique à brouillon)
//print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('BROUILLONNER').'</a>'; //print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('BROUILLONNER').'</a>';
// Enregistrer depuis le statut "Refusée" // Enregistrer depuis le statut "Refusée"
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=save_from_refuse&id='.$object->id.'">'.$langs->trans('ValidateAndSubmit').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=save_from_refuse&id='.$object->id.'">'.$langs->trans('ValidateAndSubmit').'</a></div>';
@ -2442,8 +2442,8 @@ if ($action != 'create' && $action != 'edit')
{ {
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{ {
// Brouillonner // setdraft
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$object->id.'">'.$langs->trans('SetToDraft').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=setdraft&id='.$object->id.'">'.$langs->trans('SetToDraft').'</a></div>';
} }
} }
@ -2456,8 +2456,8 @@ if ($action != 'create' && $action != 'edit')
{ {
if (in_array($object->fk_user_author, $user->getAllChildIds(1))) if (in_array($object->fk_user_author, $user->getAllChildIds(1)))
{ {
// Brouillonner // set draft
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$object->id.'">'.$langs->trans('SetToDraft').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=setdraft&id='.$object->id.'">'.$langs->trans('SetToDraft').'</a></div>';
} }
} }

View File

@ -337,8 +337,8 @@ class FormProduct
$return .= '<option value="0">' . $langs->trans("Default") . '</option>'; $return .= '<option value="0">' . $langs->trans("Default") . '</option>';
foreach ($measuringUnits->records as $lines) { foreach ($measuringUnits->records as $lines) {
$return .= '<option value="' . $lines->code . '"'; $return .= '<option value="' . $lines->id . '"';
if ($lines->code == $default) { if ($lines->id == $default) {
$return .= ' selected'; $return .= ' selected';
} }
// $return.= '>'.$value.'</option>'; // $return.= '>'.$value.'</option>';

View File

@ -4168,7 +4168,7 @@ class Product extends CommonObject
case 2: case 2:
return $this->LibStatut($status, 3, 2).' '.$this->LibStatut($status, 1, 2); return $this->LibStatut($status, 3, 2).' '.$this->LibStatut($status, 1, 2);
case 3: 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: case 4:
return $this->LibStatut($status, 3, 2).' '.$this->LibStatut($status, 0, 2); return $this->LibStatut($status, 3, 2).' '.$this->LibStatut($status, 0, 2);
case 5: case 5:
@ -4213,7 +4213,7 @@ class Product extends CommonObject
if($mode>6){ if($mode>6){
return dolGetStatus($langs->trans('Unknown'),'', '', 'status0', 0); return dolGetStatus($langs->trans('Unknown'), '', '', 'status0', 0);
} }
else{ else{
return dolGetStatus($labelstatut, $labelstatutShort, '', $statuttrans, $mode); return dolGetStatus($labelstatut, $labelstatutShort, '', $statuttrans, $mode);

View File

@ -157,10 +157,13 @@ class PriceParser
$extrafields = new ExtraFields($this->db); $extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label('product', true); $extralabels = $extrafields->fetch_name_optionals_label('product', true);
$product->fetch_optionals(); $product->fetch_optionals();
if (is_array($extrafields->attributes[$product->table_element]['label']))
{
foreach ($extrafields->attributes[$product->table_element]['label'] as $key=>$label) foreach ($extrafields->attributes[$product->table_element]['label'] as $key=>$label)
{ {
$values["extrafield_".$key] = $product->array_options['options_'.$key]; $values["extrafield_".$key] = $product->array_options['options_'.$key];
} }
}
//Process any pending updaters //Process any pending updaters
$price_updaters = new PriceGlobalVariableUpdater($this->db); $price_updaters = new PriceGlobalVariableUpdater($this->db);

View File

@ -1630,7 +1630,7 @@ a.tmenuimage:hover{
else 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"; 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 "div.mainmenu.".$val." {\n";
print " background-image: url(".$url.");\n"; print " background-image: url(".$url.");\n";
print "}\n"; print "}\n";

View File

@ -1824,7 +1824,7 @@ foreach($mainmenuusedarray as $val)
else 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"; 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 "div.mainmenu.".$val." {\n";
print " background-image: url(".$url.");\n"; print " background-image: url(".$url.");\n";
print "}\n"; print "}\n";