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

Conflicts:
	htdocs/compta/facture/card.php
	htdocs/filefunc.inc.php
This commit is contained in:
Laurent Destailleur 2020-06-07 19:55:48 +02:00
commit 6f12488e30
15 changed files with 78 additions and 33 deletions

View File

@ -118,6 +118,7 @@ if ($action == 'install')
// $original_file should match format module_modulename-x.y[.z].zip
$original_file = basename($_FILES["fileinstall"]["name"]);
$original_file = preg_replace('/\(\d+\)\.zip$/i', '.zip', $original_file);
$newfile = $conf->admin->dir_temp.'/'.$original_file.'/'.$original_file;
if (!$original_file)

View File

@ -1068,6 +1068,11 @@ if (empty($reshook))
}
$id = $object->create($user);
// NOTE: Pb with situation invoice
// NOTE: fields total on situation invoice are stored as cumulative values on total of lines (bad) but delta on invoice total
// NOTE: fields total on credit note are stored as delta both on total of lines and on invoice total (good)
// NOTE: fields situation_percent on situation invoice are stored as cumulative values on lines (bad)
// NOTE: fields situation_percent on credit note are stored as delta on lines (good)
if (GETPOST('invoiceAvoirWithLines', 'int') == 1 && $id > 0)
{
if (!empty($facture_source->lines))
@ -1088,17 +1093,17 @@ if (empty($reshook))
}
if ($facture_source->type == Facture::TYPE_SITUATION)
{
$source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id
$line->fk_prev_id = $line->id; // Credit note line need to be linked to the situation invoice it is create from
$line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from
if (!empty($facture_source->tab_previous_situation_invoice))
{
// search the last invoice in cycle
$lineIndex = count($facture_source->tab_previous_situation_invoice) - 1;
// search the last standard invoice in cycle and the possible credit note between this last and facture_source
// TODO Move this out of loop of $facture_source->lines
$tab_jumped_credit_notes = array();
$lineIndex = count($facture_source->tab_previous_situation_invoice) - 1;
$searchPreviousInvoice = true;
while ($searchPreviousInvoice)
{
@ -1107,11 +1112,13 @@ if (empty($reshook))
$searchPreviousInvoice = false; // find, exit;
break;
} else {
if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) {
$tab_jumped_credit_notes[$lineIndex] = $facture_source->tab_previous_situation_invoice[$lineIndex]->id;
}
$lineIndex--; // go to previous invoice in cycle
}
}
$maxPrevSituationPercent = 0;
foreach ($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine)
{
@ -1135,6 +1142,36 @@ if (empty($reshook))
// prorata
$line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
//print 'New line based on invoice id '.$facture_source->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'<br>';
// If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta)
$maxPrevSituationPercent = 0;
foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
foreach ($facture_source->tab_previous_situation_invoice[$index]->lines as $prevLine)
{
if ($prevLine->fk_prev_id == $source_fk_prev_id)
{
$maxPrevSituationPercent = $prevLine->situation_percent;
$line->total_ht -= $prevLine->total_ht;
$line->total_tva -= $prevLine->total_tva;
$line->total_ttc -= $prevLine->total_ttc;
$line->total_localtax1 -= $prevLine->total_localtax1;
$line->total_localtax2 -= $prevLine->total_localtax2;
$line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
$line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
$line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
$line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
}
}
}
// prorata
$line->situation_percent += $maxPrevSituationPercent;
//print 'New line based on invoice id '.$facture_source->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'<br>';
}
}

View File

@ -1762,7 +1762,8 @@ class Facture extends CommonInvoice
}
/**
* Fetch previous and next situations invoices
* Fetch previous and next situations invoices.
* Return all previous and next invoices (both standard and credit notes).
*
* @return void
*/
@ -1773,7 +1774,7 @@ class Facture extends CommonInvoice
$this->tab_previous_situation_invoice = array();
$this->tab_next_situation_invoice = array();
$sql = 'SELECT rowid, situation_counter FROM '.MAIN_DB_PREFIX.'facture';
$sql = 'SELECT rowid, type, situation_cycle_ref, situation_counter FROM '.MAIN_DB_PREFIX.'facture';
$sql .= ' WHERE rowid <> '.$this->id;
$sql .= ' AND entity = '.$this->entity;
$sql .= ' AND situation_cycle_ref = '.(int) $this->situation_cycle_ref;

View File

@ -270,7 +270,9 @@ if ($modecompta == 'CREANCES-DETTES') {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
$sql .= " AND f.entity IN (".getEntity('invoice', 0).")";
$sql .= " GROUP BY fd.tva_tx,fd.product_type, cc.label ";
$sql .= " GROUP BY fd.tva_tx,fd.product_type, cc.label, cc.code ";
$sql .= " ORDER BY country, product_type, vatrate";
dol_syslog("htdocs/compta/tva/index.php sql=".$sql, LOG_DEBUG);
$resql = $db->query($sql);
@ -351,7 +353,8 @@ if ($modecompta == 'CREANCES-DETTES') {
$sql .= " AND ff.type IN (0,1,2,3,5)";
}
$sql2 .= " AND ff.entity IN (".getEntity("facture_fourn", 0).")";
$sql2 .= " GROUP BY ffd.tva_tx, ffd.product_type, cc.label";
$sql2 .= " GROUP BY ffd.tva_tx, ffd.product_type, cc.label, cc.code ";
$sql2 .= " ORDER BY country, product_type, vatrate";
//print $sql2;
dol_syslog("htdocs/compta/tva/index.php sql=".$sql, LOG_DEBUG);

View File

@ -443,13 +443,19 @@ abstract class CommonObject
public $next_prev_filter;
/**
* @var array List of child tables. To test if we can delete object.
*/
protected $childtables = array();
/**
* @var array List of child tables. To know object to delete on cascade.
* if name like with @ClassNAme:FilePathClass;ParentFkFieldName' it will
* call method deleteByParentField(parentId,ParentFkFieldName) to fetch and delete child object
* If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
* call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
*/
protected $childtablesoncascade = array();
// No constructor as it is an abstract class
/**
* Check an object id/ref exists

View File

@ -52,7 +52,7 @@ class Menu
* Add a menu entry into this->liste (at end)
*
* @param string $url Url to follow on click (does not include DOL_URL_ROOT)
* @param string $titre Label of menu to add
* @param string $titre Label of menu to add. The value must already be translated.
* @param integer $level Level of menu to add
* @param int $enabled Menu active or not (0=Not active, 1=Active, 2=Active but grey)
* @param string $target Target link
@ -75,7 +75,7 @@ class Menu
*
* @param int $idafter Array key after which inserting new entry
* @param string $url Url to follow on click
* @param string $titre Label of menu to add
* @param string $titre Label of menu to add. The value must already be translated.
* @param integer $level Level of menu to add
* @param int $enabled Menu active or not
* @param string $target Target link

View File

@ -711,9 +711,9 @@ class Menubase
$tabMenu[$b]['mainmenu'] = $menu['mainmenu'];
$tabMenu[$b]['leftmenu'] = $menu['leftmenu'];
$tabMenu[$b]['perms'] = $perms;
$tabMenu[$b]['langs'] = $menu['langs']; // Note that this should not be used, lang file should be already loaded.
$tabMenu[$b]['enabled'] = $enabled;
$tabMenu[$b]['type'] = $menu['type'];
//$tabMenu[$b]['langs'] = $menu['langs'];
$tabMenu[$b]['fk_mainmenu'] = $menu['fk_mainmenu'];
$tabMenu[$b]['fk_leftmenu'] = $menu['fk_leftmenu'];
$tabMenu[$b]['position'] = (int) $menu['position'];

View File

@ -2799,20 +2799,11 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
exit;
}
/*$perm = GETPOST('perm', 'aZ09');
$subperm = GETPOST('subperm', 'aZ09');
if ($perm || $subperm)
{
if (($perm && !$subperm && $fuser->rights->$modulepart->$perm) || ($perm && $subperm && $fuser->rights->$modulepart->$perm->$subperm)) $accessallowed = 1;
}
else
{*/
// Check fuser->rights->modulepart->myobject->read and fuser->rights->modulepart->read
$partsofdirinoriginalfile = explode('/', $original_file);
$partofdirinoriginalfile = $partsofdirinoriginalfile[0];
if ($partofdirinoriginalfile && ($fuser->rights->$modulepart->$partofdirinoriginalfile->{$lire} || $fuser->rights->$modulepart->$partofdirinoriginalfile->{$read})) $accessallowed = 1;
if ($fuser->rights->$modulepart->{$lire} || $fuser->rights->$modulepart->{$read}) $accessallowed = 1;
//}
$original_file = $conf->$modulepart->dir_output.'/'.$original_file;
}

View File

@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
* @param DoliDB $db Database handler
* @param string $atarget Target (Example: '' or '_top')
* @param int $type_user 0=Menu for backoffice, 1=Menu for front office
* @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty)
* @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty). For eldy menu, it contains menu entries loaded from database.
* @param Menu $menu Object Menu to return back list of menu entries
* @param int $noout 1=Disable output (Initialise &$menu only).
* @param string $mode 'top', 'topnb', 'left', 'jmobile'
@ -49,6 +49,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
$mainmenu = (empty($_SESSION["mainmenu"]) ? '' : $_SESSION["mainmenu"]);
$leftmenu = (empty($_SESSION["leftmenu"]) ? '' : $_SESSION["leftmenu"]);
$id = 'mainmenu';
$listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);

View File

@ -896,10 +896,10 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS))
$boxstat .= '<!-- Database statistics -->'."\n";
$boxstat .= '<div class="box">';
$boxstat .= '<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="noborder boxtable boxtablenobottom nohover" width="100%">';
$boxstat .= '<tr class="liste_titre">';
$boxstat .= '<th class="liste_titre">';
$boxstat .= '<tr class="liste_titre box_titre">';
$boxstat .= '<td class="liste_titre">';
$boxstat .= '<div class="inline-block valignmiddle">'.$langs->trans("DolibarrStateBoard").'</div>';
$boxstat .= '</th>';
$boxstat .= '</td>';
$boxstat .= '</tr>';
$boxstat .= '<tr class="nobottom nohover"><td class="tdboxstats nohover flexcontainer">';

View File

@ -495,8 +495,8 @@ UPDATE llx_accounting_bookkeeping set date_creation = tms where date_creation IS
UPDATE llx_facturedet SET situation_percent = 100 WHERE situation_percent IS NULL AND fk_prev_id IS NULL;
-- Test inconsistency of data into situation invoices: If it differs, it may be the total_ht that is wrong and situation_percent that is good.
-- select f.rowid, f.type, qty, subprice, situation_percent, fd.total_ht, fd.total_ttc, fd.total_tva, fd.multicurrency_total_ht, fd.multicurrency_total_tva, fd.multicurrency_total_ttc, (situation_percent / 100 * subprice * qty * (1 - (fd.remise_percent / 100)))
-- from llx_facturedet as fd, llx_facture as f where fd.fk_facture = f.rowid AND (fd.total_ht - situation_percent / 100 * subprice * qty * (1 - (fd.remise_percent / 100))) > 0.01 and f.type = 5;
-- select f.rowid, f.type, fd.qty, fd.subprice, fd.situation_percent, fd.total_ht, fd.total_ttc, fd.total_tva, fd.multicurrency_total_ht, fd.multicurrency_total_tva, fd.multicurrency_total_ttc, (situation_percent / 100 * subprice * qty * (1 - (fd.remise_percent / 100)))
-- from llx_facturedet as fd, llx_facture as f where fd.fk_facture = f.rowid AND (total_ht - situation_percent / 100 * subprice * qty * (1 - (fd.remise_percent / 100))) > 0.01 and f.type = 5;
-- Note to make all deposit as payed when there is already a discount generated from it.

View File

@ -196,7 +196,9 @@ class MyObject extends CommonObject
//protected $childtables = array();
/**
* @var array List of child tables. To know object to delete on cascade.
* @var array List of child tables. To know object to delete on cascade.
* If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
* call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
*/
//protected $childtablesoncascade = array('mymodule_myobjectdet');

View File

@ -269,7 +269,7 @@ class modMyModule extends DolibarrModules
$this->menu[$r++] = array(
'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'top', // This is a Top menu entry
'titre'=>'MyModule',
'titre'=>'ModuleMyModuleName',
'mainmenu'=>'mymodule',
'leftmenu'=>'',
'url'=>'/mymodule/mymoduleindex.php',

View File

@ -372,8 +372,11 @@ if ($usevirtualstock)
$sqlExpeditionsCli = "(SELECT ".$db->ifsql("SUM(ed2.qty) IS NULL", "0", "SUM(ed2.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL
$sqlExpeditionsCli .= " FROM ".MAIN_DB_PREFIX."expedition as e2,";
$sqlExpeditionsCli .= " ".MAIN_DB_PREFIX."expeditiondet as ed2,";
$sqlExpeditionsCli .= " ".MAIN_DB_PREFIX."commande as c2,";
$sqlExpeditionsCli .= " ".MAIN_DB_PREFIX."commandedet as cd2";
$sqlExpeditionsCli .= " WHERE ed2.fk_expedition = e2.rowid AND cd2.rowid = ed2.fk_origin_line AND e2.entity IN (".getEntity('expedition').")";
$sqlExpeditionsCli .= " AND cd2.fk_commande = c2.rowid";
$sqlExpeditionsCli .= " AND c2.fk_statut IN (1,2)";
$sqlExpeditionsCli .= " AND cd2.fk_product = p.rowid";
$sqlExpeditionsCli .= " AND e2.fk_statut IN (1,2))";
} else {

View File

@ -1376,7 +1376,7 @@ td.showDragHandle {
.side-nav {
display: table-cell;
border-<?php echo $right; ?>: 1px solid #d0d0d0;
border-<?php echo $right; ?>: 1px solid #E0E0E0;
box-shadow: 3px 0 6px -2px #eee;
background: var(--colorbackvmenu1);
transition: left 0.5s ease;