diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 434b8ace7e5..7a2966a20e1 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -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) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index bf9080c9860..7ae80f72842 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -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.'
'; + + // 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.'
'; } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 28f0883bb90..791273a4fda 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -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; diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index dc5ebd1731d..ee859965552 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -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); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 6cc6cbfc725..83e3c5d1f4f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -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 diff --git a/htdocs/core/class/menu.class.php b/htdocs/core/class/menu.class.php index 040cb4a3552..60bf6474031 100644 --- a/htdocs/core/class/menu.class.php +++ b/htdocs/core/class/menu.class.php @@ -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 diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 40edb80b3f3..3fd2a9b2bb3 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -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']; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 23744be4027..180dcda0e0c 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -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; } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 097325f267c..77ba49e3101 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -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); diff --git a/htdocs/index.php b/htdocs/index.php index 588dca00506..54d76de6190 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -896,10 +896,10 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) $boxstat .= ''."\n"; $boxstat .= '
'; $boxstat .= ''; - $boxstat .= ''; - $boxstat .= ''; + $boxstat .= ''; $boxstat .= ''; $boxstat .= '
'; + $boxstat .= '
'; $boxstat .= '
'.$langs->trans("DolibarrStateBoard").'
'; - $boxstat .= ''; + $boxstat .= '
'; diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 9a77781df8c..aa5ab65d3ff 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -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. diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index d68cc5a66da..cd33147a066 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -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'); diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 1331ef38fb2..98fdafaae8c 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -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', diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index c9011c47d64..bd8045d0b5d 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -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 { diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 0c210f1c946..ca2bf5f2b1b 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1376,7 +1376,7 @@ td.showDragHandle { .side-nav { display: table-cell; - border-: 1px solid #d0d0d0; + border-: 1px solid #E0E0E0; box-shadow: 3px 0 6px -2px #eee; background: var(--colorbackvmenu1); transition: left 0.5s ease;