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

This commit is contained in:
florian HENRY 2020-03-26 08:24:39 +01:00
commit aded72a6fa
44 changed files with 394 additions and 234 deletions

View File

@ -282,7 +282,7 @@ script:
# Ensure we catch errors # Ensure we catch errors
set -e set -e
#parallel-lint --exclude htdocs/includes --blame . #parallel-lint --exclude htdocs/includes --blame .
parallel-lint --exclude dev/namespacemig --exclude dev/initdata/dbf/includes --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/composer/autoload_static.php --blame . parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/myclabs --exclude htdocs/includes/webmozart --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/composer/autoload_static.php --blame .
set +e set +e
echo echo

View File

@ -622,7 +622,7 @@ if ($action == 'delbookkeepingyear') {
'default' => $deljournal 'default' => $deljournal
); );
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1, 300); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, '', 1, 300);
print $formconfirm; print $formconfirm;
} }

View File

@ -332,7 +332,7 @@ if ($result) {
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "fd.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "fd.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
$clickpicto = $form->showCheckAddButtons(); $clickpicto = $form->showCheckAddButtons();
print_liste_field_titre($clickpicto, '', '', '', '', '', '', '', 'center '); print_liste_field_titre($clickpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n"; print "</tr>\n";
@ -341,7 +341,7 @@ if ($result) {
$product_static = new Product($db); $product_static = new Product($db);
while ($objp = $db->fetch_object($result)) { while ($objp = $db->fetch_object($result)) {
$codecompta = length_accountg($objp->account_number).' - '.$objp->label_compte; $codecompta = length_accountg($objp->account_number).' - <span class="opacitymedium">'.$objp->label_compte.'</span>';
$facture_static->ref = $objp->ref; $facture_static->ref = $objp->ref;
$facture_static->id = $objp->facid; $facture_static->id = $objp->facid;
@ -390,7 +390,7 @@ if ($result) {
print '<td>'.$objp->tva_intra.'</td>'; print '<td>'.$objp->tva_intra.'</td>';
print '<td class="center">'; print '<td>';
print $codecompta.' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">'; print $codecompta.' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
print img_edit(); print img_edit();
print '</a>'; print '</a>';

View File

@ -287,7 +287,7 @@ if ($result) {
while ($i < min($num_lines, $limit)) { while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$codeCompta = length_accountg($objp->account_number).' - '.$objp->label; $codeCompta = length_accountg($objp->account_number).' - <span class="opacitymedium">'.$objp->label.'</span>';
$expensereport_static->ref = $objp->ref; $expensereport_static->ref = $objp->ref;
$expensereport_static->id = $objp->erid; $expensereport_static->id = $objp->erid;
@ -315,7 +315,7 @@ if ($result) {
print '<td>'.$codeCompta.'</td>'; print '<td>'.$codeCompta.'</td>';
print '<td class="left"><a href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">'; print '<td class="left"><a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
print img_edit(); print img_edit();
print '</a></td>'; print '</a></td>';

View File

@ -336,7 +336,7 @@ if ($result) {
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
$checkpicto = $form->showCheckAddButtons(); $checkpicto = $form->showCheckAddButtons();
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n"; print "</tr>\n";
@ -347,7 +347,7 @@ if ($result) {
while ($i < min($num_lines, $limit)) { while ($i < min($num_lines, $limit)) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$codecompta = length_accountg($objp->account_number).' - '.$objp->label; $codecompta = length_accountg($objp->account_number).' - <span class="opacitymedium">'.$objp->label.'</span>';
$facturefournisseur_static->ref = $objp->ref; $facturefournisseur_static->ref = $objp->ref;
$facturefournisseur_static->id = $objp->facid; $facturefournisseur_static->id = $objp->facid;
@ -399,7 +399,7 @@ if ($result) {
print '<td>'.$objp->tva_intra.'</td>'; print '<td>'.$objp->tva_intra.'</td>';
print '<td class="center">'; print '<td>';
print $codecompta.' <a href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">'; print $codecompta.' <a href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
print img_edit(); print img_edit();
print '</a></td>'; print '</a></td>';

View File

@ -148,7 +148,10 @@ elseif ($action == 'setapilayer')
} }
else else
{ {
MultiCurrency::syncRates($conf->global->MULTICURRENCY_APP_ID); $result = MultiCurrency::syncRates($conf->global->MULTICURRENCY_APP_ID);
if ($result > 0) {
setEventMessages($langs->trans("CurrencyRateSyncSucceed"), null, "mesgs");
}
} }
} }

View File

@ -167,7 +167,7 @@ if ($savehandler == 'files')
if (count($listofsessions) == 0) if (count($listofsessions) == 0)
{ {
print '<tr '.$bc[false].'><td colspan="6">'.$langs->trans("NoSessionFound", $savepath, $openbasedir).'</td></tr>'; print '<tr class="oddeven"><td colspan="7">'.$langs->trans("NoSessionFound", $savepath, $openbasedir).'</td></tr>';
} }
print "</table>"; print "</table>";
} }

View File

@ -56,6 +56,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$url = $_SERVER['PHP_SELF']; $url = $_SERVER['PHP_SELF'];
if (preg_match('/api\/index\.php$/', $url)) { // sometimes $_SERVER['PHP_SELF'] is 'api\/index\.php' instead of 'api\/index\.php/explorer.php' or 'api\/index\.php/method'
$url = $_SERVER['PHP_SELF'].$_SERVER['PATH_INFO'];
}
// Fix for some NGINX setups (this should not be required even with NGINX, however setup of NGINX are often mysterious and this may help is such cases) // Fix for some NGINX setups (this should not be required even with NGINX, however setup of NGINX are often mysterious and this may help is such cases)
if (! empty($conf->global->MAIN_NGINX_FIX)) if (! empty($conf->global->MAIN_NGINX_FIX))
{ {

View File

@ -60,10 +60,9 @@ function printDropdownBookmarksList()
} }
$searchForm = '<!-- form with POST method by default, will be replaced with GET for external link by js -->'."\n"; $searchForm = '<!-- form with POST method by default, will be replaced with GET for external link by js -->'."\n";
$searchForm .= '<form id="top-menu-action-bookmark" name="actionbookmark" method="POST" action="" onsubmit="return false" >'; $searchForm .= '<form id="top-menu-action-bookmark" name="actionbookmark" method="POST" action=""'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?'onsubmit="return false"':'').'>';
$searchForm .= '<input type="hidden" name="token" value="'.newToken().'">'; $searchForm .= '<input type="hidden" name="token" value="'.newToken().'">';
$searchForm .= '<input name="bookmark" id="top-bookmark-search-input" class="dropdown-search-input" placeholder="'.$langs->trans('Bookmarks').'" autocomplete="off" >';
$searchForm .= '</form>';
// Url to list bookmark // Url to list bookmark
$listbtn = '<a class="top-menu-dropdown-link" title="'.$langs->trans('AddThisPageToBookmarks').'" href="'.DOL_URL_ROOT.'/bookmarks/list.php" >'; $listbtn = '<a class="top-menu-dropdown-link" title="'.$langs->trans('AddThisPageToBookmarks').'" href="'.DOL_URL_ROOT.'/bookmarks/list.php" >';
@ -79,7 +78,6 @@ function printDropdownBookmarksList()
$newbtn .= img_picto('', 'bookmark', '', false, 0, 0, '', 'paddingright').dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).'</a>'; $newbtn .= img_picto('', 'bookmark', '', false, 0, 0, '', 'paddingright').dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).'</a>';
} }
$bookmarkList = '<div id="dropdown-bookmarks-list" >';
// Menu with list of bookmarks // Menu with list of bookmarks
$sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark"; $sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark";
$sql .= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)"; $sql .= " WHERE (fk_user = ".$user->id." OR fk_user is NULL OR fk_user = 0)";
@ -87,21 +85,86 @@ function printDropdownBookmarksList()
$sql .= " ORDER BY position"; $sql .= " ORDER BY position";
if ($resql = $db->query($sql)) if ($resql = $db->query($sql))
{ {
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$bookmarkList = '<div id="dropdown-bookmarks-list" >';
$i = 0; $i = 0;
while (($conf->global->BOOKMARKS_SHOW_IN_MENU == 0 || $i < $conf->global->BOOKMARKS_SHOW_IN_MENU) && $obj = $db->fetch_object($resql)) while ((empty($conf->global->BOOKMARKS_SHOW_IN_MENU) || $i < $conf->global->BOOKMARKS_SHOW_IN_MENU) && $obj = $db->fetch_object($resql))
{ {
$bookmarkList .= '<a class="dropdown-item bookmark-item" id="bookmark-item-'.$obj->rowid.'" data-id="'.$obj->rowid.'" '.($obj->target == 1 ? ' target="_blank"' : '').' href="'.dol_escape_htmltag($obj->url).'" >'; $bookmarkList .= '<a class="dropdown-item bookmark-item" id="bookmark-item-'.$obj->rowid.'" data-id="'.$obj->rowid.'" '.($obj->target == 1 ? ' target="_blank"' : '').' href="'.dol_escape_htmltag($obj->url).'" >';
$bookmarkList .= dol_escape_htmltag($obj->title); $bookmarkList .= dol_escape_htmltag($obj->title);
$bookmarkList .= '</a>'; $bookmarkList .= '</a>';
$i++; $i++;
} }
$bookmarkList .= '</div>';
$searchForm .= '<input name="bookmark" id="top-bookmark-search-input" class="dropdown-search-input" placeholder="'.$langs->trans('Bookmarks').'" autocomplete="off" >';
} else {
$searchForm .= '<select name"=bookmark" id="boxbookmark" class="topmenu-bookmark-dropdown .dropdown-toggle">';
//$searchForm .= '<option>--'.$langs->trans("Bookmarks").'--</option>';
$searchForm .= '<option hidden value="listbookmarks" class="optiongrey" selected rel="'.DOL_URL_ROOT.'/bookmarks/list.php">'.$langs->trans('Bookmarks').'</option>';
$searchForm .= '<option value="listbookmark" class="optionblue" rel="'.dol_escape_htmltag(DOL_URL_ROOT.'/bookmarks/list.php').'" ';
$searchForm .= ' data-html="'.dol_escape_htmltag(img_picto('', 'bookmark').' '.($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...').'">';
$searchForm .= dol_escape_htmltag($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...</option>';
// Url to go on create new bookmark page
if (! empty($user->rights->bookmark->creer))
{
$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;url='.urlencode($url);
$searchForm .= '<option value="newbookmark" class="optionblue" rel="'.dol_escape_htmltag($urltoadd).'"';
$searchForm .= ' data-html="'.dol_escape_htmltag(img_picto('', 'bookmark').' '.$langs->trans('AddThisPageToBookmarks').'...').'">'.dol_escape_htmltag($langs->trans('AddThisPageToBookmarks').'...').'</option>';
}
$i = 0;
while ((empty($conf->global->BOOKMARKS_SHOW_IN_MENU) || $i < $conf->global->BOOKMARKS_SHOW_IN_MENU) && $obj = $db->fetch_object($resql))
{
$searchForm .= '<option name="bookmark'.$obj->rowid.'" value="'.$obj->rowid.'" '.($obj->target == 1 ? ' target="_blank"' : '').' rel="'.dol_escape_htmltag($obj->url).'" >';
$searchForm .= dol_escape_htmltag($obj->title);
$searchForm .= '</option>';
$i++;
}
$searchForm .= '</select>';
}
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
} }
$bookmarkList .= '</div>';
$searchForm .= '</form>';
// Generate the return string
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$html = $searchForm;
$html.='<!-- script to open selected choice -->
<script>
$(document).ready(function () {
jQuery("#boxbookmark").change(function() {
var urlselected = jQuery("#boxbookmark option:selected").attr("rel");
if (! urlselected) console.log("Error, failed to get the URL to jump to from the rel attribute");
var urltarget = jQuery("#boxbookmark option:selected").attr("target");
if (! urltarget) { urltarget=""; }
jQuery("form#top-menu-action-bookmark").attr("target",urltarget);
jQuery("form#top-menu-action-bookmark").attr("action",urlselected);
console.log("We change select bookmark. We choose urlselected="+urlselected+" with target="+urltarget);
// Method is POST for internal link, GET for external
if (urlselected.startsWith(\'http\'))
{
var newmethod=\'GET\';
jQuery("form#top-menu-action-bookmark").attr("method", newmethod);
console.log("We change method to newmethod="+newmethod);
jQuery("form#top-menu-action-bookmark").submit();
console.log("We restore method to POST");
jQuery("form#top-menu-action-bookmark").attr("method", \'POST\');
}
else
{
jQuery("form#top-menu-action-bookmark").submit();
}
});
})
</script>';
} else {
$html = ' $html = '
<!-- search input --> <!-- search input -->
<div class="dropdown-header bookmark-header"> <div class="dropdown-header bookmark-header">
@ -124,7 +187,8 @@ function printDropdownBookmarksList()
</div> </div>
'; ';
$html .= '<script> $html .= '<!-- script to open/close the popup -->
<script>
$( document ).on("keyup", "#top-bookmark-search-input", function () { $( document ).on("keyup", "#top-bookmark-search-input", function () {
var filter = $(this).val(), count = 0; var filter = $(this).val(), count = 0;
@ -140,6 +204,7 @@ function printDropdownBookmarksList()
$("#top-bookmark-search-filter-count").text(count); $("#top-bookmark-search-filter-count").text(count);
}); });
</script>'; </script>';
}
return $html; return $html;
} }

View File

@ -4,6 +4,7 @@
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com> * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -290,8 +291,18 @@ if ($user->rights->categorie->supprimer)
print "</div>"; print "</div>";
if (! empty($user->rights->categorie->creer))
{
$link = DOL_URL_ROOT.'/categories/card.php';
$link .= '?action=create';
$link .= '&type='.$type;
$link .= '&catorigin='.$object->id;
$link .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.'&id='.$id);
print '<div class="right">';
print dolGetButtonTitle($langs->trans('NewCategory'), '', 'fa fa-plus-circle', $link);
print "</div>";
}
$cats = $object->get_filles(); $cats = $object->get_filles();
if ($cats < 0) if ($cats < 0)

View File

@ -56,7 +56,7 @@ if (GETPOST('cancel', 'alpha') && !empty($backtopage))
exit; exit;
} }
if ($action == 'confirm_split' && GETPOST("confirm") == 'yes') if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes')
{ {
//if ($user->rights->societe->creer) //if ($user->rights->societe->creer)
//if ($user->rights->facture->creer) //if ($user->rights->facture->creer)
@ -122,6 +122,8 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes')
$newdiscount2->datec = $discount->datec; $newdiscount2->datec = $discount->datec;
$newdiscount1->tva_tx = $discount->tva_tx; $newdiscount1->tva_tx = $discount->tva_tx;
$newdiscount2->tva_tx = $discount->tva_tx; $newdiscount2->tva_tx = $discount->tva_tx;
$newdiscount1->vat_src_code = $discount->vat_src_code;
$newdiscount2->vat_src_code = $discount->vat_src_code;
$newdiscount1->amount_ttc = $amount_ttc_1; $newdiscount1->amount_ttc = $amount_ttc_1;
$newdiscount2->amount_ttc = price2num($discount->amount_ttc - $newdiscount1->amount_ttc); $newdiscount2->amount_ttc = price2num($discount->amount_ttc - $newdiscount1->amount_ttc);
$newdiscount1->amount_ht = price2num($newdiscount1->amount_ttc / (1 + $newdiscount1->tva_tx / 100), 'MT'); $newdiscount1->amount_ht = price2num($newdiscount1->amount_ttc / (1 + $newdiscount1->tva_tx / 100), 'MT');
@ -129,6 +131,13 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes')
$newdiscount1->amount_tva = price2num($newdiscount1->amount_ttc - $newdiscount1->amount_ht); $newdiscount1->amount_tva = price2num($newdiscount1->amount_ttc - $newdiscount1->amount_ht);
$newdiscount2->amount_tva = price2num($newdiscount2->amount_ttc - $newdiscount2->amount_ht); $newdiscount2->amount_tva = price2num($newdiscount2->amount_ttc - $newdiscount2->amount_ht);
$newdiscount1->multicurrency_amount_ttc = $amount_ttc_1 * ($discount->multicurrency_amount_ttc / $discount->amount_ttc);
$newdiscount2->multicurrency_amount_ttc = price2num($discount->multicurrency_amount_ttc - $newdiscount1->multicurrency_amount_ttc);
$newdiscount1->multicurrency_amount_ht = price2num($newdiscount1->multicurrency_amount_ttc / (1 + $newdiscount1->tva_tx / 100), 'MT');
$newdiscount2->multicurrency_amount_ht = price2num($newdiscount2->multicurrency_amount_ttc / (1 + $newdiscount2->tva_tx / 100), 'MT');
$newdiscount1->multicurrency_amount_tva = price2num($newdiscount1->multicurrency_amount_ttc - $newdiscount1->multicurrency_amount_ht);
$newdiscount2->multicurrency_amount_tva = price2num($newdiscount2->multicurrency_amount_ttc - $newdiscount2->multicurrency_amount_ht);
$db->begin(); $db->begin();
$discount->fk_facture_source = 0; // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_facture_source $discount->fk_facture_source = 0; // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_facture_source
// This is to delete only the require record (that we will recreate with two records) and not all family with same fk_invoice_supplier_source // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_invoice_supplier_source
@ -154,12 +163,12 @@ if ($action == 'setremise' && $user->rights->societe->creer)
//if ($user->rights->societe->creer) //if ($user->rights->societe->creer)
//if ($user->rights->facture->creer) //if ($user->rights->facture->creer)
$amount_ht = GETPOST('amount_ht'); $amount_ht = price2num(GETPOST('amount_ht', 'alpha'));
$desc = GETPOST('desc', 'alpha'); $desc = GETPOST('desc', 'alpha');
$tva_tx = GETPOST('tva_tx', 'alpha'); $tva_tx = GETPOST('tva_tx', 'alpha');
$discount_type = !empty($_POST['discount_type']) ?GETPOST('discount_type', 'alpha') : 0; $discount_type = !empty($_POST['discount_type']) ?GETPOST('discount_type', 'alpha') : 0;
if (price2num($amount_ht) > 0) if ($amount_ht > 0)
{ {
$error = 0; $error = 0;
if (empty($desc)) if (empty($desc))
@ -196,7 +205,7 @@ if ($action == 'setremise' && $user->rights->societe->creer)
} }
else else
{ {
setEventMessages($langs->trans("ErrorFieldFormat", $langs->transnoentitiesnoconv("NewGlobalDiscount")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldFormat", $langs->transnoentitiesnoconv("AmountHT")), null, 'errors');
} }
} }
@ -375,10 +384,10 @@ if ($socid > 0)
print '<span class="hideonsmartphone">&nbsp;'.$langs->trans("Currency".$conf->currency).'</span></td></tr>'; print '<span class="hideonsmartphone">&nbsp;'.$langs->trans("Currency".$conf->currency).'</span></td></tr>';
print '<tr><td>'.$langs->trans("VAT").'</td>'; print '<tr><td>'.$langs->trans("VAT").'</td>';
print '<td>'; print '<td>';
print $form->load_tva('tva_tx', GETPOST('tva_tx'), $mysoc, $object); print $form->load_tva('tva_tx', GETPOSTISSET('tva_tx') ? GETPOST('tva_tx', 'alpha') : 0, $mysoc, $object, 0, 0, '', 0, 1);
print '</td></tr>'; print '</td></tr>';
print '<tr><td class="fieldrequired" >'.$langs->trans("NoteReason").'</td>'; print '<tr><td class="fieldrequired" >'.$langs->trans("NoteReason").'</td>';
print '<td><input type="text" class="quatrevingtpercent" name="desc" value="'.GETPOST('desc', 'none').'"></td></tr>'; print '<td><input type="text" class="quatrevingtpercent" name="desc" value="'.GETPOST('desc', 'alphanohtml').'"></td></tr>';
print "</table>"; print "</table>";
@ -409,7 +418,7 @@ if ($socid > 0)
/* /*
* List remises fixes client restant en cours (= liees a aucune facture ni ligne de facture) * List not consumed available credits (= linked to no invoice and no invoice line)
*/ */
print load_fiche_titre($langs->trans("DiscountStillRemaining")); print load_fiche_titre($langs->trans("DiscountStillRemaining"));
@ -421,7 +430,8 @@ if ($socid > 0)
print load_fiche_titre($langs->trans("CustomerDiscounts"), '', ''); print load_fiche_titre($langs->trans("CustomerDiscounts"), '', '');
} }
$sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
$sql .= " rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
$sql .= " rc.datec as dc, rc.description,"; $sql .= " rc.datec as dc, rc.description,";
$sql .= " rc.fk_facture_source,"; $sql .= " rc.fk_facture_source,";
$sql .= " u.login, u.rowid as user_id,"; $sql .= " u.login, u.rowid as user_id,";
@ -510,7 +520,7 @@ if ($socid > 0)
{ {
print '<td class="right">'.price($obj->multicurrency_amount_ht).'</td>'; print '<td class="right">'.price($obj->multicurrency_amount_ht).'</td>';
} }
print '<td class="right">'.vatrate($obj->tva_tx, true).'</td>'; print '<td class="right">'.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).'</td>';
print '<td class="right">'.price($obj->amount_ttc).'</td>'; print '<td class="right">'.price($obj->amount_ttc).'</td>';
if (!empty($conf->multicurrency->enabled)) if (!empty($conf->multicurrency->enabled))
{ {
@ -577,7 +587,8 @@ if ($socid > 0)
/* /*
* Liste remises fixes fournisseur restant en cours (= liees a aucune facture ni ligne de facture) * Liste remises fixes fournisseur restant en cours (= liees a aucune facture ni ligne de facture)
*/ */
$sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
$sql .= " rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
$sql .= " rc.datec as dc, rc.description,"; $sql .= " rc.datec as dc, rc.description,";
$sql .= " rc.fk_invoice_supplier_source,"; $sql .= " rc.fk_invoice_supplier_source,";
$sql .= " u.login, u.rowid as user_id,"; $sql .= " u.login, u.rowid as user_id,";
@ -666,7 +677,7 @@ if ($socid > 0)
{ {
print '<td class="right">'.price($obj->multicurrency_amount_ht).'</td>'; print '<td class="right">'.price($obj->multicurrency_amount_ht).'</td>';
} }
print '<td class="right">'.vatrate($obj->tva_tx, true).'</td>'; print '<td class="right">'.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).'</td>';
print '<td class="right">'.price($obj->amount_ttc).'</td>'; print '<td class="right">'.price($obj->amount_ttc).'</td>';
if (!empty($conf->multicurrency->enabled)) if (!empty($conf->multicurrency->enabled))
{ {
@ -744,7 +755,8 @@ if ($socid > 0)
} }
// Discount linked to invoice lines // Discount linked to invoice lines
$sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
$sql .= " rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
$sql .= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture_source,"; $sql .= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture_source,";
$sql .= " u.login, u.rowid as user_id,"; $sql .= " u.login, u.rowid as user_id,";
$sql .= " f.rowid as invoiceid, f.ref,"; $sql .= " f.rowid as invoiceid, f.ref,";
@ -762,7 +774,7 @@ if ($socid > 0)
$sql .= " ORDER BY dc DESC"; $sql .= " ORDER BY dc DESC";
//$sql.= " UNION "; //$sql.= " UNION ";
// Discount linked to invoices // Discount linked to invoices
$sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,"; $sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
$sql2 .= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,"; $sql2 .= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,";
$sql2 .= " rc.fk_facture_source,"; $sql2 .= " rc.fk_facture_source,";
$sql2 .= " u.login, u.rowid as user_id,"; $sql2 .= " u.login, u.rowid as user_id,";
@ -881,7 +893,7 @@ if ($socid > 0)
{ {
print '<td class="right">'.price($obj->multicurrency_amount_ht).'</td>'; print '<td class="right">'.price($obj->multicurrency_amount_ht).'</td>';
} }
print '<td class="right">'.vatrate($obj->tva_tx, true).'</td>'; print '<td class="right">'.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).'</td>';
print '<td class="right">'.price($obj->amount_ttc).'</td>'; print '<td class="right">'.price($obj->amount_ttc).'</td>';
if (!empty($conf->multicurrency->enabled)) if (!empty($conf->multicurrency->enabled))
{ {
@ -920,7 +932,8 @@ if ($socid > 0)
} }
// Discount linked to invoice lines // Discount linked to invoice lines
$sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
$sql .= " rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,";
$sql .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; $sql .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,";
$sql .= " rc.fk_invoice_supplier_source,"; $sql .= " rc.fk_invoice_supplier_source,";
$sql .= " u.login, u.rowid as user_id,"; $sql .= " u.login, u.rowid as user_id,";
@ -939,7 +952,7 @@ if ($socid > 0)
$sql .= " ORDER BY dc DESC"; $sql .= " ORDER BY dc DESC";
//$sql.= " UNION "; //$sql.= " UNION ";
// Discount linked to invoices // Discount linked to invoices
$sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,"; $sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,";
$sql2 .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; $sql2 .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,";
$sql2 .= " rc.fk_invoice_supplier_source,"; $sql2 .= " rc.fk_invoice_supplier_source,";
$sql2 .= " u.login, u.rowid as user_id,"; $sql2 .= " u.login, u.rowid as user_id,";
@ -1057,7 +1070,7 @@ if ($socid > 0)
{ {
print '<td class="right">'.price($obj->multicurrency_amount_ht).'</td>'; print '<td class="right">'.price($obj->multicurrency_amount_ht).'</td>';
} }
print '<td class="right">'.vatrate($obj->tva_tx, true).'</td>'; print '<td class="right">'.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).'</td>';
print '<td class="right">'.price($obj->amount_ttc).'</td>'; print '<td class="right">'.price($obj->amount_ttc).'</td>';
if (!empty($conf->multicurrency->enabled)) if (!empty($conf->multicurrency->enabled))
{ {

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2015 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
@ -302,10 +302,12 @@ if (empty($reshook))
$array_of_total_ht_per_vat_rate = array(); $array_of_total_ht_per_vat_rate = array();
$array_of_total_ht_devise_per_vat_rate = array(); $array_of_total_ht_devise_per_vat_rate = array();
foreach ($object->lines as $line) { foreach ($object->lines as $line) {
if (empty($array_of_total_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code])) $array_of_total_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] = 0; //$vat_src_code_for_line = $line->vat_src_code; // TODO We chek sign of total per vat without taking into account the vat code because for the moment the vat code is lost/unknown when we add a down payment.
if (empty($array_of_total_ht_devise_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code])) $array_of_total_ht_devise_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] = 0; $vat_src_code_for_line = '';
$array_of_total_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] += $line->total_ht; if (empty($array_of_total_ht_per_vat_rate[$line->tva_tx.'_'.$vat_src_code_for_line])) $array_of_total_ht_per_vat_rate[$line->tva_tx.'_'.$vat_src_code_for_line] = 0;
$array_of_total_ht_devise_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] += $line->multicurrency_total_ht; if (empty($array_of_total_ht_devise_per_vat_rate[$line->tva_tx.'_'.$vat_src_code_for_line])) $array_of_total_ht_devise_per_vat_rate[$line->tva_tx.'_'.$vat_src_code_for_line] = 0;
$array_of_total_ht_per_vat_rate[$line->tva_tx.'_'.$vat_src_code_for_line] += $line->total_ht;
$array_of_total_ht_devise_per_vat_rate[$line->tva_tx.'_'.$vat_src_code_for_line] += $line->multicurrency_total_ht;
} }
//var_dump($array_of_total_ht_per_vat_rate);exit; //var_dump($array_of_total_ht_per_vat_rate);exit;
@ -485,10 +487,10 @@ if (empty($reshook))
// POST[remise_id] or POST[remise_id_for_payment] // POST[remise_id] or POST[remise_id_for_payment]
// We use the credit to reduce amount of invoice // We use the credit to reduce amount of invoice
if (!empty($_POST["remise_id"])) { if (GETPOST("remise_id", 'int') > 0) {
$ret = $object->fetch($id); $ret = $object->fetch($id);
if ($ret > 0) { if ($ret > 0) {
$result = $object->insert_discount($_POST["remise_id"]); $result = $object->insert_discount(GETPOST("remise_id", 'int'));
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
@ -497,11 +499,11 @@ if (empty($reshook))
} }
} }
// We use the credit to reduce remain to pay // We use the credit to reduce remain to pay
if (!empty($_POST["remise_id_for_payment"])) if (GETPOST("remise_id_for_payment", 'int') > 0)
{ {
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
$discount = new DiscountAbsolute($db); $discount = new DiscountAbsolute($db);
$discount->fetch($_POST["remise_id_for_payment"]); $discount->fetch(GETPOST("remise_id_for_payment", 'int'));
//var_dump($object->getRemainToPay(0)); //var_dump($object->getRemainToPay(0));
//var_dump($discount->amount_ttc);exit; //var_dump($discount->amount_ttc);exit;
@ -809,14 +811,16 @@ if (empty($reshook))
$i = 0; $i = 0;
foreach ($object->lines as $line) foreach ($object->lines as $line)
{ {
if ($line->product_type < 9 && $line->total_ht != 0) // Remove lines with product_type greater than or equal to 9 if ($line->product_type < 9 && $line->total_ht != 0) // Remove lines with product_type greater than or equal to 9 and no need to create discount if amount is null
{ // no need to create discount if amount is null {
$amount_ht[$line->tva_tx] += $line->total_ht; $keyforvatrate = $line->tva_tx.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : '');
$amount_tva[$line->tva_tx] += $line->total_tva;
$amount_ttc[$line->tva_tx] += $line->total_ttc; $amount_ht[$keyforvatrate] += $line->total_ht;
$multicurrency_amount_ht[$line->tva_tx] += $line->multicurrency_total_ht; $amount_tva[$keyforvatrate] += $line->total_tva;
$multicurrency_amount_tva[$line->tva_tx] += $line->multicurrency_total_tva; $amount_ttc[$keyforvatrate] += $line->total_ttc;
$multicurrency_amount_ttc[$line->tva_tx] += $line->multicurrency_total_ttc; $multicurrency_amount_ht[$keyforvatrate] += $line->multicurrency_total_ht;
$multicurrency_amount_tva[$keyforvatrate] += $line->multicurrency_total_tva;
$multicurrency_amount_ttc[$keyforvatrate] += $line->multicurrency_total_ttc;
$i++; $i++;
} }
} }
@ -830,9 +834,9 @@ if (empty($reshook))
$amount_ht[$vatrate] = price2num($amount_ht[$vatrate] * $ratio, 'MU'); $amount_ht[$vatrate] = price2num($amount_ht[$vatrate] * $ratio, 'MU');
$amount_tva[$vatrate] = price2num($amount_tva[$vatrate] * $ratio, 'MU'); $amount_tva[$vatrate] = price2num($amount_tva[$vatrate] * $ratio, 'MU');
$amount_ttc[$vatrate] = price2num($amount_ttc[$vatrate] * $ratio, 'MU'); $amount_ttc[$vatrate] = price2num($amount_ttc[$vatrate] * $ratio, 'MU');
$multicurrency_amount_ht[$line->tva_tx] = price2num($multicurrency_amount_ht[$vatrate] * $ratio, 'MU'); $multicurrency_amount_ht[$vatrate] = price2num($multicurrency_amount_ht[$vatrate] * $ratio, 'MU');
$multicurrency_amount_tva[$line->tva_tx] = price2num($multicurrency_amount_tva[$vatrate] * $ratio, 'MU'); $multicurrency_amount_tva[$vatrate] = price2num($multicurrency_amount_tva[$vatrate] * $ratio, 'MU');
$multicurrency_amount_ttc[$line->tva_tx] = price2num($multicurrency_amount_ttc[$vatrate] * $ratio, 'MU'); $multicurrency_amount_ttc[$vatrate] = price2num($multicurrency_amount_ttc[$vatrate] * $ratio, 'MU');
} }
} }
} }
@ -887,6 +891,7 @@ if (empty($reshook))
$discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc; $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc;
$discount->amount_tva = 0; $discount->amount_tva = 0;
$discount->tva_tx = 0; $discount->tva_tx = 0;
$discount->vat_src_code = '';
$result = $discount->create($user); $result = $discount->create($user);
if ($result < 0) if ($result < 0)
@ -904,7 +909,18 @@ if (empty($reshook))
$discount->multicurrency_amount_ht = abs($multicurrency_amount_ht[$tva_tx]); $discount->multicurrency_amount_ht = abs($multicurrency_amount_ht[$tva_tx]);
$discount->multicurrency_amount_tva = abs($multicurrency_amount_tva[$tva_tx]); $discount->multicurrency_amount_tva = abs($multicurrency_amount_tva[$tva_tx]);
$discount->multicurrency_amount_ttc = abs($multicurrency_amount_ttc[$tva_tx]); $discount->multicurrency_amount_ttc = abs($multicurrency_amount_ttc[$tva_tx]);
// Clean vat code
$reg = array();
$vat_src_code = '';
if (preg_match('/\((.*)\)/', $tva_tx, $reg))
{
$vat_src_code = $reg[1];
$tva_tx = preg_replace('/\s*\(.*\)/', '', $tva_tx); // Remove code into vatrate.
}
$discount->tva_tx = abs($tva_tx); $discount->tva_tx = abs($tva_tx);
$discount->vat_src_code =$vat_src_code;
$result = $discount->create($user); $result = $discount->create($user);
if ($result < 0) if ($result < 0)
@ -3397,7 +3413,7 @@ if ($action == 'create')
{ {
$langs->load('projects'); $langs->load('projects');
print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">';
$numprojet = $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1); $numprojet = $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500');
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id.($fac_rec ? '&fac_rec='.$fac_rec : '')).'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans("AddProject").'"></span></a>'; print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id.($fac_rec ? '&fac_rec='.$fac_rec : '')).'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans("AddProject").'"></span></a>';
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -3076,6 +3076,7 @@ class Facture extends CommonInvoice
$localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
// Clean vat code // Clean vat code
$reg = array();
$vat_src_code = ''; $vat_src_code = '';
if (preg_match('/\((.*)\)/', $txtva, $reg)) if (preg_match('/\((.*)\)/', $txtva, $reg))
{ {

View File

@ -104,7 +104,7 @@ abstract class CommonInvoice extends CommonObject
$alreadypaid+=$this->getSumDepositsUsed($multicurrency); $alreadypaid+=$this->getSumDepositsUsed($multicurrency);
$alreadypaid+=$this->getSumCreditNotesUsed($multicurrency); $alreadypaid+=$this->getSumCreditNotesUsed($multicurrency);
$remaintopay = ($this->total_ttc - $alreadypaid); $remaintopay = price2num($this->total_ttc - $alreadypaid, 'MT');
if ($this->statut == self::STATUS_CLOSED && $this->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment if ($this->statut == self::STATUS_CLOSED && $this->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment
$remaintopay = 0; $remaintopay = 0;
} }

View File

@ -62,6 +62,7 @@ class DiscountAbsolute
public $multicurrency_amount_ttc; public $multicurrency_amount_ttc;
// Vat rate // Vat rate
public $tva_tx; public $tva_tx;
public $vat_src_code;
/** /**
* @var int User ID Id utilisateur qui accorde la remise * @var int User ID Id utilisateur qui accorde la remise
@ -133,7 +134,7 @@ class DiscountAbsolute
$sql = "SELECT sr.rowid, sr.fk_soc, sr.discount_type,"; $sql = "SELECT sr.rowid, sr.fk_soc, sr.discount_type,";
$sql.= " sr.fk_user,"; $sql.= " sr.fk_user,";
$sql.= " sr.amount_ht, sr.amount_tva, sr.amount_ttc, sr.tva_tx,"; $sql.= " sr.amount_ht, sr.amount_tva, sr.amount_ttc, sr.tva_tx, sr.vat_src_code,";
$sql.= " sr.multicurrency_amount_ht, sr.multicurrency_amount_tva, sr.multicurrency_amount_ttc,"; $sql.= " sr.multicurrency_amount_ht, sr.multicurrency_amount_tva, sr.multicurrency_amount_ttc,";
$sql.= " sr.fk_facture_line, sr.fk_facture, sr.fk_facture_source, sr.fk_invoice_supplier_line, sr.fk_invoice_supplier, sr.fk_invoice_supplier_source, sr.description,"; $sql.= " sr.fk_facture_line, sr.fk_facture, sr.fk_facture_source, sr.fk_invoice_supplier_line, sr.fk_invoice_supplier, sr.fk_invoice_supplier_source, sr.description,";
$sql.= " sr.datec,"; $sql.= " sr.datec,";
@ -168,6 +169,8 @@ class DiscountAbsolute
$this->multicurrency_amount_ttc = $obj->multicurrency_amount_ttc; $this->multicurrency_amount_ttc = $obj->multicurrency_amount_ttc;
$this->tva_tx = $obj->tva_tx; $this->tva_tx = $obj->tva_tx;
$this->vat_src_code = $obj->vat_src_code;
$this->fk_user = $obj->fk_user; $this->fk_user = $obj->fk_user;
$this->fk_facture_line = $obj->fk_facture_line; $this->fk_facture_line = $obj->fk_facture_line;
$this->fk_facture = $obj->fk_facture; $this->fk_facture = $obj->fk_facture;
@ -244,12 +247,12 @@ class DiscountAbsolute
// Insert request // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except";
$sql .= " (entity, datec, fk_soc, discount_type, fk_user, description,"; $sql .= " (entity, datec, fk_soc, discount_type, fk_user, description,";
$sql .= " amount_ht, amount_tva, amount_ttc, tva_tx,"; $sql .= " amount_ht, amount_tva, amount_ttc, tva_tx, vat_src_code,";
$sql .= " multicurrency_amount_ht, multicurrency_amount_tva, multicurrency_amount_ttc,"; $sql .= " multicurrency_amount_ht, multicurrency_amount_tva, multicurrency_amount_ttc,";
$sql .= " fk_facture_source, fk_invoice_supplier_source"; $sql .= " fk_facture_source, fk_invoice_supplier_source";
$sql .= ")"; $sql .= ")";
$sql .= " VALUES (".$conf->entity.", '".$this->db->idate($this->datec != '' ? $this->datec : dol_now())."', ".$this->fk_soc.", ".(empty($this->discount_type) ? 0 : intval($this->discount_type)).", ".$userid.", '".$this->db->escape($this->description)."',"; $sql .= " VALUES (".$conf->entity.", '".$this->db->idate($this->datec != '' ? $this->datec : dol_now())."', ".$this->fk_soc.", ".(empty($this->discount_type) ? 0 : intval($this->discount_type)).", ".$userid.", '".$this->db->escape($this->description)."',";
$sql .= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.","; $sql .= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.", '".$this->db->escape($this->vat_src_code)."',";
$sql .= " ".$this->multicurrency_amount_ht.", ".$this->multicurrency_amount_tva.", ".$this->multicurrency_amount_ttc.", "; $sql .= " ".$this->multicurrency_amount_ht.", ".$this->multicurrency_amount_tva.", ".$this->multicurrency_amount_ttc.", ";
$sql .= " ".($this->fk_facture_source ? "'".$this->db->escape($this->fk_facture_source)."'" : "null").","; $sql .= " ".($this->fk_facture_source ? "'".$this->db->escape($this->fk_facture_source)."'" : "null").",";
$sql .= " ".($this->fk_invoice_supplier_source ? "'".$this->db->escape($this->fk_invoice_supplier_source)."'" : "null"); $sql .= " ".($this->fk_invoice_supplier_source ? "'".$this->db->escape($this->fk_invoice_supplier_source)."'" : "null");

View File

@ -669,12 +669,14 @@ class Form
/* console.log( index + ": " + $( this ).text() ); */ /* console.log( index + ": " + $( this ).text() ); */
if ($(this).is(\':checked\')) atleastoneselected++; if ($(this).is(\':checked\')) atleastoneselected++;
}); });
console.log("initCheckForSelect mode="+mode+" atleastoneselected="+atleastoneselected); console.log("initCheckForSelect mode="+mode+" atleastoneselected="+atleastoneselected);
if (atleastoneselected || '.$alwaysvisible.') if (atleastoneselected || '.$alwaysvisible.')
{ {
jQuery(".massaction").show(); jQuery(".massaction").show();
'.($selected ? 'if (atleastoneselected) { jQuery(".massactionselect").val("'.$selected.'"); jQuery(".massactionconfirmed").prop(\'disabled\', false); }' : '').' '.($selected ? 'if (atleastoneselected) { jQuery(".massactionselect").val("'.$selected.'").trigger(\'change\'); jQuery(".massactionconfirmed").prop(\'disabled\', false); }' : '').'
'.($selected ? 'if (! atleastoneselected) { jQuery(".massactionselect").val("0"); jQuery(".massactionconfirmed").prop(\'disabled\', true); } ' : '').' '.($selected ? 'if (! atleastoneselected) { jQuery(".massactionselect").val("0").trigger(\'change\'); jQuery(".massactionconfirmed").prop(\'disabled\', true); } ' : '').'
} }
else else
{ {
@ -2141,7 +2143,7 @@ class Form
} }
} }
$selectFields = " p.rowid, p.ref, p.label, p.description, p.barcode, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.duration, p.fk_price_expression"; $selectFields = " p.rowid, p.ref, p.label, p.description, p.barcode, p.fk_country, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.duration, p.fk_price_expression";
if (count($warehouseStatusArray)) if (count($warehouseStatusArray))
{ {
$selectFieldsGrouped = ", sum(".$db->ifsql("e.statut IS NULL", "0", "ps.reel").") as stock"; // e.statut is null if there is no record in stock $selectFieldsGrouped = ", sum(".$db->ifsql("e.statut IS NULL", "0", "ps.reel").") as stock"; // e.statut is null if there is no record in stock
@ -2445,6 +2447,7 @@ class Form
$outlabel = ''; $outlabel = '';
$outdesc = ''; $outdesc = '';
$outbarcode = ''; $outbarcode = '';
$outorigin = '';
$outtype = ''; $outtype = '';
$outprice_ht = ''; $outprice_ht = '';
$outprice_ttc = ''; $outprice_ttc = '';
@ -2464,6 +2467,7 @@ class Form
$outlabel = $objp->label; $outlabel = $objp->label;
$outdesc = $objp->description; $outdesc = $objp->description;
$outbarcode = $objp->barcode; $outbarcode = $objp->barcode;
$outorigin = $objp->fk_country;
$outpbq = empty($objp->price_by_qty_rowid) ? '' : $objp->price_by_qty_rowid; $outpbq = empty($objp->price_by_qty_rowid) ? '' : $objp->price_by_qty_rowid;
$outtype = $objp->fk_product_type; $outtype = $objp->fk_product_type;
@ -2525,12 +2529,15 @@ class Form
$opt .= $objp->ref; $opt .= $objp->ref;
if ($outbarcode) $opt .= ' ('.$outbarcode.')'; if ($outbarcode) $opt .= ' ('.$outbarcode.')';
$opt .= ' - '.dol_trunc($label, $maxlengtharticle); $opt .= ' - '.dol_trunc($label, $maxlengtharticle);
if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) $opt .= ' ('.getCountry($outorigin, 1).')';
$objRef = $objp->ref; $objRef = $objp->ref;
if (!empty($filterkey) && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey).')/i', '<strong>$1</strong>', $objRef, 1); if (!empty($filterkey) && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey).')/i', '<strong>$1</strong>', $objRef, 1);
$outval .= $objRef; $outval .= $objRef;
if ($outbarcode) $outval .= ' ('.$outbarcode.')'; if ($outbarcode) $outval .= ' ('.$outbarcode.')';
$outval .= ' - '.dol_trunc($label, $maxlengtharticle); $outval .= ' - '.dol_trunc($label, $maxlengtharticle);
if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) $outval .= ' ('.getCountry($outorigin, 1).')';
// Units // Units
$opt .= $outvalUnits; $opt .= $outvalUnits;
$outval .= $outvalUnits; $outval .= $outvalUnits;
@ -4770,7 +4777,7 @@ class Form
print '<form method="POST" action="'.$page.'">'; print '<form method="POST" action="'.$page.'">';
print '<input type="hidden" name="action" value="setmulticurrencyrate">'; print '<input type="hidden" name="action" value="setmulticurrencyrate">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="text" name="'.$htmlname.'" value="'.(!empty($rate) ? price($rate) : 1).'" size="10" /> '; print '<input type="text" class="maxwidth100" name="'.$htmlname.'" value="'.(!empty($rate) ? price(price2num($rate, 'CR')) : 1).'" /> ';
print '<select name="calculation_mode">'; print '<select name="calculation_mode">';
print '<option value="1">'.$currency.' > '.$conf->currency.'</option>'; print '<option value="1">'.$currency.' > '.$conf->currency.'</option>';
print '<option value="2">'.$conf->currency.' > '.$currency.'</option>'; print '<option value="2">'.$conf->currency.' > '.$currency.'</option>';

View File

@ -524,8 +524,9 @@ function hideMessage(fieldId,message) {
* @param int entity Entity * @param int entity Entity
* @param int strict Strict * @param int strict Strict
* @param int forcereload Force reload * @param int forcereload Force reload
* @param int userid User id
*/ */
function setConstant(url, code, input, entity, strict, forcereload) { function setConstant(url, code, input, entity, strict, forcereload, userid) {
$.get( url, { $.get( url, {
action: "set", action: "set",
name: code, name: code,
@ -593,8 +594,9 @@ function setConstant(url, code, input, entity, strict, forcereload) {
* @param int entity Entity * @param int entity Entity
* @param int strict Strict * @param int strict Strict
* @param int forcereload Force reload * @param int forcereload Force reload
* @param int userid User id
*/ */
function delConstant(url, code, input, entity, strict, forcereload) { function delConstant(url, code, input, entity, strict, forcereload, userid) {
$.get( url, { $.get( url, {
action: "del", action: "del",
name: code, name: code,
@ -661,8 +663,9 @@ function delConstant(url, code, input, entity, strict, forcereload) {
* @param int yesButton yesButton * @param int yesButton yesButton
* @param int noButton noButton * @param int noButton noButton
* @param int strict Strict * @param int strict Strict
* @param int userid User id
*/ */
function confirmConstantAction(action, url, code, input, box, entity, yesButton, noButton, strict) { function confirmConstantAction(action, url, code, input, box, entity, yesButton, noButton, strict, userid) {
var boxConfirm = box; var boxConfirm = box;
$("#confirm_" + code) $("#confirm_" + code)
.attr("title", boxConfirm.title) .attr("title", boxConfirm.title)
@ -678,9 +681,9 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
text : yesButton, text : yesButton,
click : function() { click : function() {
if (action == "set") { if (action == "set") {
setConstant(url, code, input, entity, strict); setConstant(url, code, input, entity, strict, 0, userid);
} else if (action == "del") { } else if (action == "del") {
delConstant(url, code, input, entity, strict); delConstant(url, code, input, entity, strict, 0, userid);
} }
// Close dialog // Close dialog
$(this).dialog("close"); $(this).dialog("close");

View File

@ -485,7 +485,7 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete =
*/ */
function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0, $forcereload = 0, $marginleftonlyshort = 2) function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0, $forcereload = 0, $marginleftonlyshort = 2)
{ {
global $conf, $langs; global $conf, $langs, $user;
$entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity); $entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity);
@ -504,6 +504,7 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof
var code = \''.$code.'\'; var code = \''.$code.'\';
var entity = \''.$entity.'\'; var entity = \''.$entity.'\';
var strict = \''.$strict.'\'; var strict = \''.$strict.'\';
var userid = \''.$user->id.'\';
var yesButton = "'.dol_escape_js($langs->transnoentities("Yes")).'"; var yesButton = "'.dol_escape_js($langs->transnoentities("Yes")).'";
var noButton = "'.dol_escape_js($langs->transnoentities("No")).'"; var noButton = "'.dol_escape_js($langs->transnoentities("No")).'";
@ -512,9 +513,9 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof
if (input.alert && input.alert.set) { if (input.alert && input.alert.set) {
if (input.alert.set.yesButton) yesButton = input.alert.set.yesButton; if (input.alert.set.yesButton) yesButton = input.alert.set.yesButton;
if (input.alert.set.noButton) noButton = input.alert.set.noButton; if (input.alert.set.noButton) noButton = input.alert.set.noButton;
confirmConstantAction("set", url, code, input, input.alert.set, entity, yesButton, noButton, strict); confirmConstantAction("set", url, code, input, input.alert.set, entity, yesButton, noButton, strict, userid);
} else { } else {
setConstant(url, code, input, entity, 0, '.$forcereload.'); setConstant(url, code, input, entity, 0, '.$forcereload.', userid);
} }
}); });
@ -523,9 +524,9 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof
if (input.alert && input.alert.del) { if (input.alert && input.alert.del) {
if (input.alert.del.yesButton) yesButton = input.alert.del.yesButton; if (input.alert.del.yesButton) yesButton = input.alert.del.yesButton;
if (input.alert.del.noButton) noButton = input.alert.del.noButton; if (input.alert.del.noButton) noButton = input.alert.del.noButton;
confirmConstantAction("del", url, code, input, input.alert.del, entity, yesButton, noButton, strict); confirmConstantAction("del", url, code, input, input.alert.del, entity, yesButton, noButton, strict, userid);
} else { } else {
delConstant(url, code, input, entity, 0, '.$forcereload.'); delConstant(url, code, input, entity, 0, '.$forcereload.', userid);
} }
}); });
}); });

View File

@ -1100,7 +1100,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
if (!empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($val['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; if (!empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($val['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n";
if ($key == 'role') $align .= ($align ? ' ' : '').'left'; if ($key == 'role') $align .= ($align ? ' ' : '').'left';
if (!empty($arrayfields['sc.'.$key]['checked'])) { if (!empty($arrayfields['sc.'.$key]['checked'])) {
print getTitleFieldOfList($arrayfields['sc.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 'sc.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; print getTitleFieldOfList($arrayfields['sc.'.$key]['label'], 0, $_SERVER['PHP_SELF'], '', '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n";
} }
} }
// Extra fields // Extra fields

View File

@ -4660,6 +4660,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $
* 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT) * 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT)
* 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT) * 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT)
* 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK) * 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK)
* 'CR'=Currency rate
* Numeric = Nb of digits for rounding * Numeric = Nb of digits for rounding
* @param int $alreadysqlnb Put 1 if you know that content is already universal format number * @param int $alreadysqlnb Put 1 if you know that content is already universal format number
* @return string Amount with universal numeric format (Example: '99.99999'). * @return string Amount with universal numeric format (Example: '99.99999').
@ -4713,6 +4714,7 @@ function price2num($amount, $rounding = '', $alreadysqlnb = 0)
if ($rounding == 'MU') $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT; if ($rounding == 'MU') $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT;
elseif ($rounding == 'MT') $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT; elseif ($rounding == 'MT') $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT;
elseif ($rounding == 'MS') $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK; elseif ($rounding == 'MS') $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK;
elseif ($rounding == 'CR') $nbofdectoround = 8;
elseif (is_numeric($rounding)) $nbofdectoround = $rounding; elseif (is_numeric($rounding)) $nbofdectoround = $rounding;
//print "RR".$amount.' - '.$nbofdectoround.'<br>'; //print "RR".$amount.' - '.$nbofdectoround.'<br>';
if (dol_strlen($nbofdectoround)) $amount = round($amount, $nbofdectoround); // $nbofdectoround can be 0. if (dol_strlen($nbofdectoround)) $amount = round($amount, $nbofdectoround); // $nbofdectoround can be 0.

View File

@ -942,6 +942,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("MAIN_OPTIMIZEFORTEXTBROWSER").'</td>'; print '<td>'.$langs->trans("MAIN_OPTIMIZEFORTEXTBROWSER").'</td>';
print '<td colspan="'.($colspan - 1).'">'; print '<td colspan="'.($colspan - 1).'">';
//print ajax_constantonoff("MAIN_OPTIMIZEFORTEXTBROWSER", array(), null, 0, 0, 1, 0);
if ($edit) if ($edit)
{ {
print $form->selectyesno('MAIN_OPTIMIZEFORTEXTBROWSER', $fuser->conf->MAIN_OPTIMIZEFORTEXTBROWSER, 1); print $form->selectyesno('MAIN_OPTIMIZEFORTEXTBROWSER', $fuser->conf->MAIN_OPTIMIZEFORTEXTBROWSER, 1);

View File

@ -7,6 +7,7 @@
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com> * Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -605,7 +606,7 @@ class ProductFournisseur extends Product
global $conf; global $conf;
$sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
$sql .= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; $sql .= " pfp.rowid as product_fourn_pri_id, pfp.entity, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,";
$sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,";
$sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,";
$sql .= " pfp.barcode, pfp.fk_barcode_type"; $sql .= " pfp.barcode, pfp.fk_barcode_type";
@ -632,6 +633,7 @@ class ProductFournisseur extends Product
$prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"]; $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"];
$prodfourn->product_fourn_id = $record["product_fourn_id"]; $prodfourn->product_fourn_id = $record["product_fourn_id"];
$prodfourn->product_fourn_entity = $record["entity"];
$prodfourn->fourn_ref = $record["ref_fourn"]; $prodfourn->fourn_ref = $record["ref_fourn"];
$prodfourn->ref_supplier = $record["ref_fourn"]; $prodfourn->ref_supplier = $record["ref_fourn"];
$prodfourn->desc_supplier = $record["desc_fourn"]; $prodfourn->desc_supplier = $record["desc_fourn"];

View File

@ -200,3 +200,6 @@ ALTER TABLE llx_entrepot ADD COLUMN phone varchar(20) DEFAULT NULL;
ALTER TABLE llx_accounting_account ADD COLUMN reconcilable tinyint DEFAULT 0 NOT NULL after active; ALTER TABLE llx_accounting_account ADD COLUMN reconcilable tinyint DEFAULT 0 NOT NULL after active;
ALTER TABLE llx_categorie MODIFY type integer NOT NULL DEFAULT 1; ALTER TABLE llx_categorie MODIFY type integer NOT NULL DEFAULT 1;
ALTER TABLE llx_societe_remise_except ADD COLUMN vat_src_code varchar(10) DEFAULT '';

View File

@ -31,7 +31,7 @@ create table llx_commande_fournisseur_dispatch
fk_entrepot integer, fk_entrepot integer,
fk_user integer, fk_user integer,
comment varchar(255), -- comment on movement comment varchar(255), -- comment on movement
batch varchar(30) DEFAULT NULL, batch varchar(128) DEFAULT NULL,
eatby date DEFAULT NULL, eatby date DEFAULT NULL,
sellby date DEFAULT NULL, sellby date DEFAULT NULL,
status integer, status integer,

View File

@ -20,7 +20,7 @@ CREATE TABLE llx_expeditiondet_batch (
fk_expeditiondet int NOT NULL, fk_expeditiondet int NOT NULL,
eatby date DEFAULT NULL, eatby date DEFAULT NULL,
sellby date DEFAULT NULL, sellby date DEFAULT NULL,
batch varchar(30) DEFAULT NULL, batch varchar(128) DEFAULT NULL,
qty double NOT NULL DEFAULT '0', qty double NOT NULL DEFAULT '0',
fk_origin_stock integer NOT NULL fk_origin_stock integer NOT NULL
) ENGINE=InnoDB; ) ENGINE=InnoDB;

View File

@ -25,7 +25,7 @@ tms timestamp,
fk_inventory integer DEFAULT 0, fk_inventory integer DEFAULT 0,
fk_warehouse integer DEFAULT 0, fk_warehouse integer DEFAULT 0,
fk_product integer DEFAULT 0, fk_product integer DEFAULT 0,
batch varchar(30) DEFAULT NULL, -- Lot or serial number batch varchar(128) DEFAULT NULL, -- Lot or serial number
qty_stock double DEFAULT NULL, -- The targeted value. can be filled during draft edition qty_stock double DEFAULT NULL, -- The targeted value. can be filled during draft edition
qty_view double DEFAULT NULL, -- must be filled once regulation is done qty_view double DEFAULT NULL, -- must be filled once regulation is done
qty_regulated double DEFAULT NULL -- must be filled once regulation is done qty_regulated double DEFAULT NULL -- must be filled once regulation is done

View File

@ -23,7 +23,7 @@ CREATE TABLE llx_mrp_production(
qty real NOT NULL DEFAULT 1, qty real NOT NULL DEFAULT 1,
qty_frozen smallint DEFAULT 0, qty_frozen smallint DEFAULT 0,
disable_stock_change smallint DEFAULT 0, disable_stock_change smallint DEFAULT 0,
batch varchar(30), batch varchar(128),
role varchar(10), -- 'toconsume' or 'toproduce' (initialized at MO creation), 'consumed' or 'produced' (added after MO validation) role varchar(10), -- 'toconsume' or 'toproduce' (initialized at MO creation), 'consumed' or 'produced' (added after MO validation)
fk_mrp_production integer, -- if role = 'consumed', id of line with role 'toconsume', if role = 'produced' id of line with role 'toproduce' fk_mrp_production integer, -- if role = 'consumed', id of line with role 'toconsume', if role = 'produced' id of line with role 'toproduce'
fk_stock_movement integer, -- id of stock movement when movements are validated fk_stock_movement integer, -- id of stock movement when movements are validated

View File

@ -24,7 +24,7 @@ CREATE TABLE llx_product_batch (
fk_product_stock integer NOT NULL, fk_product_stock integer NOT NULL,
eatby datetime DEFAULT NULL, -- deprecated. should not be used here but should be stored into a table llx_product_lot eatby datetime DEFAULT NULL, -- deprecated. should not be used here but should be stored into a table llx_product_lot
sellby datetime DEFAULT NULL, -- deprecated. should not be used here but should be stored into a table llx_product_lot sellby datetime DEFAULT NULL, -- deprecated. should not be used here but should be stored into a table llx_product_lot
batch varchar(30) NOT NULL, batch varchar(128) NOT NULL,
qty double NOT NULL DEFAULT 0, qty double NOT NULL DEFAULT 0,
import_key varchar(14) DEFAULT NULL import_key varchar(14) DEFAULT NULL
) ENGINE=InnoDB; ) ENGINE=InnoDB;

View File

@ -21,7 +21,7 @@ CREATE TABLE llx_product_lot (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
entity integer DEFAULT 1, entity integer DEFAULT 1,
fk_product integer NOT NULL, -- Id of product fk_product integer NOT NULL, -- Id of product
batch varchar(30) DEFAULT NULL, -- Lot or serial number batch varchar(128) DEFAULT NULL, -- Lot or serial number
eatby date DEFAULT NULL, -- Eatby date eatby date DEFAULT NULL, -- Eatby date
sellby date DEFAULT NULL, -- Sellby date sellby date DEFAULT NULL, -- Sellby date
datec datetime, datec datetime,

View File

@ -30,6 +30,7 @@ create table llx_societe_remise_except
amount_tva double(24,8) DEFAULT 0 NOT NULL, amount_tva double(24,8) DEFAULT 0 NOT NULL,
amount_ttc double(24,8) DEFAULT 0 NOT NULL, amount_ttc double(24,8) DEFAULT 0 NOT NULL,
tva_tx double(6,3) DEFAULT 0 NOT NULL, tva_tx double(6,3) DEFAULT 0 NOT NULL,
vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here.
fk_user integer NOT NULL, fk_user integer NOT NULL,
fk_facture_line integer, fk_facture_line integer,
fk_facture integer, fk_facture integer,

View File

@ -23,7 +23,7 @@ create table llx_stock_mouvement
tms timestamp, tms timestamp,
datem datetime, -- Date and hour of movement datem datetime, -- Date and hour of movement
fk_product integer NOT NULL, -- Id of product fk_product integer NOT NULL, -- Id of product
batch varchar(30) DEFAULT NULL, -- Lot or serial number batch varchar(128) DEFAULT NULL, -- Lot or serial number
eatby date DEFAULT NULL, -- Eatby date (deprecated, we should get value from batch number in table llx_product_lot) eatby date DEFAULT NULL, -- Eatby date (deprecated, we should get value from batch number in table llx_product_lot)
sellby date DEFAULT NULL, -- Sellby date (deprecated, we should get value from batch number in table llx_product_lot) sellby date DEFAULT NULL, -- Sellby date (deprecated, we should get value from batch number in table llx_product_lot)
fk_entrepot integer NOT NULL, -- Id warehouse fk_entrepot integer NOT NULL, -- Id warehouse

View File

@ -18,3 +18,5 @@ MulticurrencyReceived=Received, original currency
MulticurrencyRemainderToTake=Remaining amount, original currency MulticurrencyRemainderToTake=Remaining amount, original currency
MulticurrencyPaymentAmount=Payment amount, original currency MulticurrencyPaymentAmount=Payment amount, original currency
AmountToOthercurrency=Amount To (in currency of receiving account) AmountToOthercurrency=Amount To (in currency of receiving account)
CurrencyRateSyncSucceed=Currency rate synchronization done successfuly
MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT=Use the currency of the document for online payments

View File

@ -1969,6 +1969,11 @@ function top_menu_bookmark()
include_once DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php'; include_once DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php';
$langs->load("bookmarks"); $langs->load("bookmarks");
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$html .= '<div id="topmenu-bookmark-dropdown" class="dropdown inline-block">';
$html .= printDropdownBookmarksList();
$html .= '</div>';
} else {
$html .= '<!-- div for bookmark link --> $html .= '<!-- div for bookmark link -->
<div id="topmenu-bookmark-dropdown" class="dropdown inline-block"> <div id="topmenu-bookmark-dropdown" class="dropdown inline-block">
<a class="dropdown-toggle login-dropdown-a" data-toggle="dropdown" href="#" title="'.$langs->trans('Bookmarks').' ('.$langs->trans('BookmarksMenuShortCut').')"> <a class="dropdown-toggle login-dropdown-a" data-toggle="dropdown" href="#" title="'.$langs->trans('Bookmarks').' ('.$langs->trans('BookmarksMenuShortCut').')">
@ -1980,7 +1985,7 @@ function top_menu_bookmark()
</div>'; </div>';
$html .= ' $html .= '
<!-- Code to show/hide the user drop-down --> <!-- Code to show/hide the bookmark drop-down -->
<script> <script>
$( document ).ready(function() { $( document ).ready(function() {
$(document).on("click", function(event) { $(document).on("click", function(event) {
@ -2015,6 +2020,7 @@ function top_menu_bookmark()
</script> </script>
'; ';
} }
}
return $html; return $html;
} }

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
@ -29,6 +29,7 @@
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php'; require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php';
/** /**
* Class Currency * Class Currency
* *
@ -92,6 +93,7 @@ class MultiCurrency extends CommonObject
*/ */
public $rate; public $rate;
/** /**
* Constructor * Constructor
* *
@ -99,7 +101,7 @@ class MultiCurrency extends CommonObject
*/ */
public function __construct(DoliDB $db) public function __construct(DoliDB $db)
{ {
$this->db = &$db; $this->db = $db;
return 1; return 1;
} }
@ -109,14 +111,13 @@ class MultiCurrency extends CommonObject
* *
* @param User $user User that creates * @param User $user User that creates
* @param bool $trigger true=launch triggers after, false=disable triggers * @param bool $trigger true=launch triggers after, false=disable triggers
*
* @return int <0 if KO, Id of created object if OK * @return int <0 if KO, Id of created object if OK
*/ */
public function create(User $user, $trigger = true) public function create(User $user, $trigger = true)
{ {
global $conf,$langs; global $conf,$langs;
dol_syslog('Currency::create', LOG_DEBUG); dol_syslog('MultiCurrency::create', LOG_DEBUG);
$error = 0; $error = 0;
@ -152,7 +153,7 @@ class MultiCurrency extends CommonObject
if (!$resql) { if (!$resql) {
$error ++; $error ++;
$this->errors[] = 'Error ' . $this->db->lasterror(); $this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog('Currency::create ' . join(',', $this->errors), LOG_ERR); dol_syslog('MultiCurrency::create ' . join(',', $this->errors), LOG_ERR);
} }
if (!$error) { if (!$error) {
@ -182,12 +183,11 @@ class MultiCurrency extends CommonObject
* *
* @param int $id Id object * @param int $id Id object
* @param string $code code * @param string $code code
*
* @return int <0 if KO, 0 if not found, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
public function fetch($id, $code = null) public function fetch($id, $code = null)
{ {
dol_syslog('Currency::fetch', LOG_DEBUG); dol_syslog('MultiCurrency::fetch', LOG_DEBUG);
global $conf; global $conf;
@ -224,7 +224,7 @@ class MultiCurrency extends CommonObject
} }
} else { } else {
$this->errors[] = 'Error ' . $this->db->lasterror(); $this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog('Currency::fetch ' . join(',', $this->errors), LOG_ERR); dol_syslog('MultiCurrency::fetch ' . join(',', $this->errors), LOG_ERR);
return -1; return -1;
} }
@ -260,7 +260,7 @@ class MultiCurrency extends CommonObject
return $num; return $num;
} else { } else {
$this->errors[] = 'Error ' . $this->db->lasterror(); $this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog('Currency::fetchAllCurrencyRate ' . join(',', $this->errors), LOG_ERR); dol_syslog('MultiCurrency::fetchAllCurrencyRate ' . join(',', $this->errors), LOG_ERR);
return - 1; return - 1;
} }
@ -271,14 +271,13 @@ class MultiCurrency extends CommonObject
* *
* @param User $user User that modifies * @param User $user User that modifies
* @param bool $trigger true=launch triggers after, false=disable triggers * @param bool $trigger true=launch triggers after, false=disable triggers
*
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function update(User $user, $trigger = true) public function update(User $user, $trigger = true)
{ {
$error = 0; $error = 0;
dol_syslog('Currency::update', LOG_DEBUG); dol_syslog('MultiCurrency::update', LOG_DEBUG);
// Clean parameters // Clean parameters
$this->name = trim($this->name); $this->name = trim($this->name);
@ -287,7 +286,7 @@ class MultiCurrency extends CommonObject
// Check parameters // Check parameters
if (empty($this->code)) { if (empty($this->code)) {
$error++; $error++;
dol_syslog('Currency::update $this->code can not be empty', LOG_ERR); dol_syslog('MultiCurrency::update $this->code can not be empty', LOG_ERR);
return -1; return -1;
} }
@ -298,14 +297,13 @@ class MultiCurrency extends CommonObject
$sql .= ' code=\''.$this->db->escape($this->code).'\''; $sql .= ' code=\''.$this->db->escape($this->code).'\'';
$sql .= ' WHERE rowid=' . $this->id; $sql .= ' WHERE rowid=' . $this->id;
dol_syslog(__METHOD__, LOG_DEBUG);
$this->db->begin(); $this->db->begin();
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {
$error ++; $error ++;
$this->errors[] = 'Error ' . $this->db->lasterror(); $this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog('Currency::update ' . join(',', $this->errors), LOG_ERR); dol_syslog('MultiCurrency::update ' . join(',', $this->errors), LOG_ERR);
} }
if (!$error && $trigger) { if (!$error && $trigger) {
@ -329,14 +327,13 @@ class MultiCurrency extends CommonObject
* Delete object in database * Delete object in database
* *
* @param bool $trigger true=launch triggers after, false=disable triggers * @param bool $trigger true=launch triggers after, false=disable triggers
*
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function delete($trigger = true) public function delete($trigger = true)
{ {
global $user; global $user;
dol_syslog('Currency::delete', LOG_DEBUG); dol_syslog('MultiCurrency::delete', LOG_DEBUG);
$error = 0; $error = 0;
@ -363,7 +360,7 @@ class MultiCurrency extends CommonObject
if (!$resql) { if (!$resql) {
$error ++; $error ++;
$this->errors[] = 'Error ' . $this->db->lasterror(); $this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog('Currency::delete ' . join(',', $this->errors), LOG_ERR); dol_syslog('MultiCurrency::delete ' . join(',', $this->errors), LOG_ERR);
} }
} }
@ -398,16 +395,15 @@ class MultiCurrency extends CommonObject
} }
/** /**
* Delete rate in database * Add a Rate into database
* *
* @param double $rate rate value * @param double $rate rate value
*
* @return int -1 if KO, 1 if OK * @return int -1 if KO, 1 if OK
*/ */
public function addRate($rate) public function addRate($rate)
{ {
$currencyRate = new CurrencyRate($this->db); $currencyRate = new CurrencyRate($this->db);
$currencyRate->rate = $rate; $currencyRate->rate = price2num($rate);
if ($currencyRate->create($this->id) > 0) if ($currencyRate->create($this->id) > 0)
{ {
@ -427,7 +423,6 @@ class MultiCurrency extends CommonObject
* *
* @param string $code currency code * @param string $code currency code
* @param double $rate new rate * @param double $rate new rate
*
* @return int -1 if KO, 1 if OK, 2 if label found and OK * @return int -1 if KO, 1 if OK, 2 if label found and OK
*/ */
public function addRateFromDolibarr($code, $rate) public function addRateFromDolibarr($code, $rate)
@ -459,10 +454,9 @@ class MultiCurrency extends CommonObject
} }
/** /**
* Add new entry into llx_multicurrency_rate to historise * Add new entry into llx_multicurrency_rate
* *
* @param double $rate rate value * @param double $rate rate value
*
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function updateRate($rate) public function updateRate($rate)
@ -628,11 +622,11 @@ class MultiCurrency extends CommonObject
} }
/** /**
* Sync rates from api * Sync rates from API
* *
* @param string $key Key to use. Come from $conf->global->MULTICURRENCY_APP_ID. * @param string $key Key to use. Come from $conf->global->MULTICURRENCY_APP_ID.
* @param int $addifnotfound Add if not found * @param int $addifnotfound Add if not found
* @return void * @return int <0 if KO, >0 if OK
*/ */
public static function syncRates($key, $addifnotfound = 0) public static function syncRates($key, $addifnotfound = 0)
{ {
@ -672,11 +666,15 @@ class MultiCurrency extends CommonObject
} }
} }
} }
return 1;
} }
else else
{ {
dol_syslog("Failed to call endpoint ".$response->error->info, LOG_WARNING); dol_syslog("Failed to call endpoint ".$response->error->info, LOG_WARNING);
setEventMessages($langs->trans('multicurrency_syncronize_error', $response->error->info), null, 'errors'); setEventMessages($langs->trans('multicurrency_syncronize_error', $response->error->info), null, 'errors');
return -1;
} }
} }

View File

@ -89,15 +89,11 @@ function llxHeaderSurvey($title, $head = "", $disablejs = 0, $disablehead = 0, $
print '<input type="hidden" name="token" value="'.newToken().'">'."\n"; print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
print "\n"; print "\n";
// Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo) // Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo)
$width = 0; $width = 0;
// Define logo and logosmall // Define logo and logosmall
$logosmall = $mysoc->logo_small; $logosmall = $mysoc->logo_small;
$logo = $mysoc->logo; $logo = $mysoc->logo;
$paramlogo = 'ONLINE_PAYMENT_LOGO_'.$suffix;
if (!empty($conf->global->$paramlogo)) $logosmall = $conf->global->$paramlogo;
elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) $logosmall = $conf->global->ONLINE_PAYMENT_LOGO;
//print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n"; //print '<!-- Show logo (logosmall='.$logosmall.' logo='.$logo.') -->'."\n";
// Define urllogo // Define urllogo
$urllogo = ''; $urllogo = '';

View File

@ -10,6 +10,7 @@
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019 Tim Otte <otte@meuser.it> * Copyright (C) 2019 Tim Otte <otte@meuser.it>
* Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -1070,6 +1071,7 @@ SCRIPT;
// Modify-Remove // Modify-Remove
print '<td class="center nowraponall">'; print '<td class="center nowraponall">';
if ($usercancreate) if ($usercancreate)
{ {
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$productfourn->fourn_id.'&amp;action=update_price&amp;rowid='.$productfourn->product_fourn_price_id.'">'.img_edit()."</a>"; print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$productfourn->fourn_id.'&amp;action=update_price&amp;rowid='.$productfourn->product_fourn_price_id.'">'.img_edit()."</a>";

View File

@ -3,6 +3,7 @@
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2020 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -154,7 +155,8 @@ class Task extends CommonObject
// Insert request // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task ("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task (";
$sql .= "fk_projet"; $sql .= "entity";
$sql .= ", fk_projet";
$sql .= ", ref"; $sql .= ", ref";
$sql .= ", entity"; $sql .= ", entity";
$sql .= ", fk_task_parent"; $sql .= ", fk_task_parent";
@ -167,7 +169,8 @@ class Task extends CommonObject
$sql .= ", planned_workload"; $sql .= ", planned_workload";
$sql .= ", progress"; $sql .= ", progress";
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= $this->fk_project; $sql .= $conf->entity;
$sql .= ", ".$this->fk_project;
$sql .= ", ".(!empty($this->ref) ? "'".$this->db->escape($this->ref)."'" : 'null'); $sql .= ", ".(!empty($this->ref) ? "'".$this->db->escape($this->ref)."'" : 'null');
$sql .= ", ".$conf->entity; $sql .= ", ".$conf->entity;
$sql .= ", ".$this->fk_task_parent; $sql .= ", ".$this->fk_task_parent;

View File

@ -1987,11 +1987,11 @@ class Societe extends CommonObject
* @param float $remise Amount of discount * @param float $remise Amount of discount
* @param User $user User adding discount * @param User $user User adding discount
* @param string $desc Reason of discount * @param string $desc Reason of discount
* @param float $tva_tx VAT rate * @param string $vatrate VAT rate (may contain the vat code too). Exemple: '1.23', '1.23 (ABC)', ...
* @param int $discount_type 0 => customer discount, 1 => supplier discount * @param int $discount_type 0 => customer discount, 1 => supplier discount
* @return int <0 if KO, id of discount record if OK * @return int <0 if KO, id of discount record if OK
*/ */
public function set_remise_except($remise, User $user, $desc, $tva_tx = 0, $discount_type = 0) public function set_remise_except($remise, User $user, $desc, $vatrate = '', $discount_type = 0)
{ {
// phpcs:enable // phpcs:enable
global $langs; global $langs;
@ -2012,8 +2012,17 @@ class Societe extends CommonObject
return -2; return -2;
} }
if ($this->id) if ($this->id > 0)
{ {
// Clean vat code
$reg = array();
$vat_src_code = '';
if (preg_match('/\((.*)\)/', $vatrate, $reg))
{
$vat_src_code = $reg[1];
$vatrate = preg_replace('/\s*\(.*\)/', '', $vatrate); // Remove code into vatrate.
}
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
$discount = new DiscountAbsolute($this->db); $discount = new DiscountAbsolute($this->db);
@ -2022,10 +2031,12 @@ class Societe extends CommonObject
$discount->discount_type = $discount_type; $discount->discount_type = $discount_type;
$discount->amount_ht = $discount->multicurrency_amount_ht = price2num($remise, 'MT'); $discount->amount_ht = $discount->multicurrency_amount_ht = price2num($remise, 'MT');
$discount->amount_tva = $discount->multicurrency_amount_tva = price2num($remise * $tva_tx / 100, 'MT'); $discount->amount_tva = $discount->multicurrency_amount_tva = price2num($remise * $vatrate / 100, 'MT');
$discount->amount_ttc = $discount->multicurrency_amount_ttc = price2num($discount->amount_ht + $discount->amount_tva, 'MT'); $discount->amount_ttc = $discount->multicurrency_amount_ttc = price2num($discount->amount_ht + $discount->amount_tva, 'MT');
$discount->tva_tx = price2num($tva_tx, 'MT'); $discount->tva_tx = price2num($vatrate, 'MT');
$discount->vat_src_code = $vat_src_code;
$discount->description = $desc; $discount->description = $desc;
$result = $discount->create($user); $result = $discount->create($user);

View File

@ -733,7 +733,6 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
?> ?>
</a></div> </a></div>
<div class="inline-block valignmiddle" id="customerandsales"> <div class="inline-block valignmiddle" id="customerandsales">
<a class="valignmiddle" id="customer" onclick="Customer();"></a>
</div> </div>
<div class="inline-block valignmiddle" id="moreinfo"></div> <div class="inline-block valignmiddle" id="moreinfo"></div>
<div class="inline-block valignmiddle" id="infowarehouse"></div> <div class="inline-block valignmiddle" id="infowarehouse"></div>

View File

@ -717,7 +717,7 @@ $( document ).ready(function() {
<?php <?php
$s = $langs->trans("Customer"); $s = $langs->trans("Customer");
if ($invoice->socid != $conf->global->$constforcompanyid) { if ($invoice->id > 0 && ($invoice->socid != $conf->global->$constforcompanyid)) {
$s = $soc->name; $s = $soc->name;
} }
?> ?>
@ -733,17 +733,17 @@ $( document ).ready(function() {
while ($obj = $db->fetch_object($resql)) { while ($obj = $db->fetch_object($resql)) {
echo '$("#customerandsales").append(\''; echo '$("#customerandsales").append(\'';
if ($placeid==$obj->rowid) echo "<b>"; if ($placeid==$obj->rowid) echo "<b>";
echo '<a class="valignmiddle" onclick="location.href=\\\'index.php?place='; echo '<a class="valignmiddle" onclick="place=\\\'';
$num_sale=str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref)); $num_sale=str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref));
echo $num_sale; echo $num_sale;
if (str_replace("-", "", $num_sale)>$max_sale) $max_sale=str_replace("-", "", $num_sale); if (str_replace("-", "", $num_sale)>$max_sale) $max_sale=str_replace("-", "", $num_sale);
echo '\\\'">'.date('H:i', strtotime($obj->datec)); echo '\\\';Refresh();">'.date('H:i', strtotime($obj->datec));
if ($placeid==$obj->rowid) echo "</b>"; if ($placeid==$obj->rowid) echo "</b>";
echo '</a>\');'; echo '</a>\');';
} }
echo '$("#customerandsales").append(\'<a onclick="location.href=\\\'index.php?place=0-'; echo '$("#customerandsales").append(\'<a onclick="place=\\\'0-';
echo $max_sale+1; echo $max_sale+1;
echo '\\\'"><span class="fa fa-plus-square" title="'.dol_escape_htmltag($langs->trans("StartAParallelSale")).'"></a>\');'; echo '\\\';Refresh();"><span class="fa fa-plus-square" title="'.dol_escape_htmltag($langs->trans("StartAParallelSale")).'"></a>\');';
} else { } else {
dol_print_error($db); dol_print_error($db);
} }

View File

@ -118,13 +118,13 @@ a.badge-warning:focus, a.badge-warning:hover {
} }
/* WARNING colorblind */ /* WARNING colorblind */
body[class^="colorblind-"] .badge-warning { body[class*="colorblind-"] .badge-warning {
background-color: <?php print $colorblind_deuteranopes_badgeWarning; ?>; background-color: <?php print $colorblind_deuteranopes_badgeWarning; ?>;
} }
body[class^="colorblind-"] a.badge-warning.focus,body[class^="colorblind-"] a.badge-warning:focus { body[class*="colorblind-"] a.badge-warning.focus,body[class^="colorblind-"] a.badge-warning:focus {
box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($colorblind_deuteranopes_badgeWarning, 0.5); ?>; box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($colorblind_deuteranopes_badgeWarning, 0.5); ?>;
} }
body[class^="colorblind-"] a.badge-warning:focus, a.badge-warning:hover { body[class*="colorblind-"] a.badge-warning:focus, a.badge-warning:hover {
background-color: <?php print colorDarker($colorblind_deuteranopes_badgeWarning, 10); ?>; background-color: <?php print colorDarker($colorblind_deuteranopes_badgeWarning, 10); ?>;
} }

View File

@ -164,7 +164,9 @@ button.dropdown-item.global-search-item {
} }
div#topmenu-global-search-dropdown, div#topmenu-bookmark-dropdown { div#topmenu-global-search-dropdown, div#topmenu-bookmark-dropdown {
<?php if (empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) { ?>
line-height: 46px; line-height: 46px;
<?php } ?>
} }
a.top-menu-dropdown-link { a.top-menu-dropdown-link {
padding: 8px; padding: 8px;

View File

@ -145,16 +145,21 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?>
background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
} }
.progress-bar-green, .progress-bar-green, .progress-bar-success {
.progress-bar-success {
background-color: <?php echo $badgeSuccess ?>; background-color: <?php echo $badgeSuccess ?>;
} }
.progress-striped .progress-bar-green, .progress-striped .progress-bar-green, .progress-striped .progress-bar-success {
.progress-striped .progress-bar-success {
background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
} }
body[class*="colorblind-"] .progress-bar-green, body[class*="colorblind-"] .progress-bar-success {
background-color: <?php echo $colorblind_deuteranopes_badgeSuccess ?>;
}
body[class*="colorblind-"] .progress-bar-red, body[class*="colorblind-"] .progress-bar-danger {
background-color: <?php echo $colorblind_deuteranopes_badgeDanger ?>;
}
.progress-bar-aqua, .progress-bar-aqua,
.progress-bar-info { .progress-bar-info {
background-color: #00c0ef; background-color: #00c0ef;

View File

@ -99,6 +99,7 @@ $badgeLight = '#f8f9fa';
$colorblind_deuteranopes_badgeSuccess = '#37de5d'; //! text color black $colorblind_deuteranopes_badgeSuccess = '#37de5d'; //! text color black
$colorblind_deuteranopes_badgeSuccess_textColor7 = '#000'; $colorblind_deuteranopes_badgeSuccess_textColor7 = '#000';
$colorblind_deuteranopes_badgeWarning = '#e4e411'; $colorblind_deuteranopes_badgeWarning = '#e4e411';
$colorblind_deuteranopes_badgeDanger = $badgeDanger; // currently not tested with a color blind people so use default color
/* default color for status : After a quick check, somme status can have oposite function according to objects /* default color for status : After a quick check, somme status can have oposite function according to objects
* So this badges status uses default value according to theme eldy status img * So this badges status uses default value according to theme eldy status img