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

This commit is contained in:
Laurent Destailleur 2020-01-19 19:49:04 +01:00
commit e679e05f57
11 changed files with 113 additions and 51 deletions

View File

@ -205,9 +205,9 @@ if ($result)
$i = 0;
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($optioncss != '') $param.='&optioncss='.$optioncss;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
if ($search_code) $param.='&search_code='.urlencode($search_code);
if ($search_ip) $param.='&search_ip='.urlencode($search_ip);
if ($search_user) $param.='&search_user='.urlencode($search_user);
@ -332,13 +332,14 @@ if ($result)
// Description
print '<td>';
$text=$langs->trans($obj->description);
$reg = array();
if (preg_match('/\((.*)\)(.*)/i', $obj->description, $reg))
{
$val=explode(',', $reg[1]);
$text=$langs->trans($val[0], isset($val[1])?$val[1]:'', isset($val[2])?$val[2]:'', isset($val[3])?$val[3]:'', isset($val[4])?$val[4]:'');
if (! empty($reg[2])) $text.=$reg[2];
}
print $text;
print dol_escape_htmltag($text);
print '</td>';
if (! empty($arrayfields['e.user_agent']['checked']))
@ -359,8 +360,8 @@ if ($result)
// More informations
print '<td class="right">';
$htmltext='<b>'.$langs->trans("UserAgent").'</b>: '.($obj->user_agent?$obj->user_agent:$langs->trans("Unknown"));
$htmltext.='<br><b>'.$langs->trans("PrefixSession").'</b>: '.($obj->prefix_session?$obj->prefix_session:$langs->trans("Unknown"));
$htmltext='<b>'.$langs->trans("UserAgent").'</b>: '.($obj->user_agent ? dol_string_nohtmltag($obj->user_agent) : $langs->trans("Unknown"));
$htmltext.='<br><b>'.$langs->trans("PrefixSession").'</b>: '.($obj->prefix_session ? dol_string_nohtmltag($obj->prefix_session) : $langs->trans("Unknown"));
print $form->textwithpicto('', $htmltext);
print '</td>';

View File

@ -959,6 +959,7 @@ class Commande extends CommonOrder
if ($result != self::STOCK_NOT_ENOUGH_FOR_ORDER)
{
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
dol_print_error($this->db);
}
$this->db->rollback();
@ -1434,6 +1435,7 @@ class Commande extends CommonOrder
{
$langs->load("errors");
$this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref);
$this->errors[] = $this->error;
dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR);
$this->db->rollback();
return self::STOCK_NOT_ENOUGH_FOR_ORDER;
@ -3083,6 +3085,7 @@ class Commande extends CommonOrder
{
$langs->load("errors");
$this->error = $langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref);
$this->errors[] = $this->error;
dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR);
$this->db->rollback();
return self::STOCK_NOT_ENOUGH_FOR_ORDER;

View File

@ -573,11 +573,13 @@ if ($page >= $nbtotalofpages)
if (empty($search_account)) $mode_balance_ok = false;
// If a search is done $mode_balance_ok=false
if (!empty($search_ref)) $mode_balance_ok = false;
if (!empty($req_nb)) $mode_balance_ok = false;
if (!empty($search_description)) $mode_balance_ok = false;
if (!empty($search_type)) $mode_balance_ok = false;
if (!empty($debit)) $mode_balance_ok = false;
if (!empty($credit)) $mode_balance_ok = false;
if (!empty($thirdparty)) $mode_balance_ok = false;
if (!empty($search_debit)) $mode_balance_ok = false;
if (!empty($search_credit)) $mode_balance_ok = false;
if (!empty($search_thirdparty)) $mode_balance_ok = false;
if (!empty($search_conciliated)) $mode_balance_ok = false;
if (!empty($search_num_releve)) $mode_balance_ok = false;
$sql .= $db->plimit($limit + 1, $offset);
//print $sql;

View File

@ -444,12 +444,11 @@ else
// Date de valeur
print '<td valign="center" class="center nowrap">';
print dol_print_date($db->jdate($objp->dv), "day").' ';
print '<a href="releve.php?action=dvprev&amp;num='.$numref.'&amp;account='.$object->id.'&amp;dvid='.$objp->rowid.'">';
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=dvprev&amp;num='.$numref.'&amp;account='.$object->id.'&amp;dvid='.$objp->rowid.'">';
print img_edit_remove()."</a> ";
print '<a href="releve.php?action=dvnext&amp;num='.$numref.'&amp;account='.$object->id.'&amp;dvid='.$objp->rowid.'">';
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;num='.$numref.'&amp;account='.$object->id.'&amp;dvid='.$objp->rowid.'">';
print img_edit_add()."</a>";
print "</td>\n";
print '<a class="ajax" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
// Type and num
if ($objp->fk_type == 'SOLD') {
@ -466,7 +465,8 @@ else
print '<td class="nowrap">'.$type_label.' '.($objp->num_chq ? $objp->num_chq : '').$link.'</td>';
// Description
print '<td valign="center"><a href="'.DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$objp->rowid.'&amp;account='.$object->id.'">';
print '<td valign="center">';
print '<a href="'.DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$objp->rowid.'&amp;account='.$object->id.'">';
$reg = array();
preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parenthese on tente recherche de traduction
if ($reg[1] && $langs->trans($reg[1]) != $reg[1]) print $langs->trans($reg[1]);

View File

@ -137,6 +137,7 @@ $isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0);
$result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid, $isdraft);
/*
* Actions
*/
@ -289,6 +290,39 @@ if (empty($reshook))
setEventMessages($langs->trans("ErrorInvoiceOfThisTypeMustBePositive"), null, 'errors');
$action = '';
}
// Also negative lines should not be allowed on 'non Credit notes' invoices. A test is done when adding or updating lines but we must
// do it again in validation to avoid cases where invoice is created from another object that allow negative lines.
// Note that we can accept the negative line if sum with other lines with same vat is positivie: Because all the lines will be merged together
// when converted into 'available credit' and we will get a positive available credit line.
// Note: Other solution if you want to add a negative line on invoice, is to create a discount for customer and consumme it (but this is possible on standard invoice only).
$array_of_pu_ht_per_vat_rate = array();
$array_of_pu_ht_devise_per_vat_rate = array();
foreach($object->lines as $line) {
if (empty($array_of_pu_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code])) $array_of_pu_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] = 0;
if (empty($array_of_pu_ht_devise_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code])) $array_of_pu_ht_devise_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] = 0;
$array_of_pu_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] += $line->subprice;
$array_of_pu_ht_devise_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] += $line->multicurrency_subprice;
}
//var_dump($array_of_pu_ht_per_vat_rate);exit;
foreach($array_of_pu_ht_per_vat_rate as $vatrate => $tmpvalue)
{
$pu_ht = $array_of_pu_ht_per_vat_rate[$vatrate];
$pu_ht_devise = $array_of_pu_ht_devise_per_vat_rate[$vatrate];
if (($pu_ht < 0 || $pu_ht_devise < 0) && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES))
{
$langs->load("errors");
if ($object->type == $object::TYPE_DEPOSIT) {
// Using negative lines on deposit lead to headach and blocking problems when you want to consume them.
setEventMessages($langs->trans("ErrorLinesCantBeNegativeOnDeposits"), null, 'errors');
} else {
setEventMessages($langs->trans("ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv("UnitPriceHT"), $langs->transnoentitiesnoconv("CustomerAbsoluteDiscountShort")), null, 'errors');
}
$error++;
$action = '';
}
}
}
}
@ -1822,7 +1856,12 @@ if (empty($reshook))
if ($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES))
{
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
if ($object->type == $object::TYPE_DEPOSIT) {
// Using negative lines on deposit lead to headach and blocking problems when you want to consume them.
setEventMessages($langs->trans("ErrorLinesCantBeNegativeOnDeposits"), null, 'errors');
} else {
setEventMessages($langs->trans("ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv("UnitPriceHT"), $langs->transnoentitiesnoconv("CustomerAbsoluteDiscountShort")), null, 'errors');
}
$error++;
}
else
@ -2203,7 +2242,12 @@ if (empty($reshook))
if ($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES))
{
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
if ($object->type == $object::TYPE_DEPOSIT) {
// Using negative lines on deposit lead to headach and blocking problems when you want to consume them.
setEventMessages($langs->trans("ErrorLinesCantBeNegativeOnDeposits"), null, 'errors');
} else {
setEventMessages($langs->trans("ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv("UnitPriceHT"), $langs->transnoentitiesnoconv("CustomerAbsoluteDiscountShort")), null, 'errors');
}
$error++;
}
else

View File

@ -389,6 +389,7 @@ if (empty($reshook))
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
$link = '<a href="' . $link . '">' . $link . '</a>';
$message = $langs->transnoentities("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut, $object->date_fin, '', $langs), $link);
// Rebuild pdf
@ -508,6 +509,7 @@ if (empty($reshook))
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
$link = '<a href="' . $link . '">' . $link . '</a>';
$dateRefusEx = explode(" ", $object->date_refuse);
$message = $langs->transnoentities("ExpenseReportWaitingForReApprovalMessage", $dateRefusEx[0], $object->detail_refuse, $expediteur->getFullName($langs), $link);
@ -633,6 +635,7 @@ if (empty($reshook))
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
$link = '<a href="' . $link . '">' . $link . '</a>';
$message = $langs->transnoentities("ExpenseReportApprovedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
// Rebuilt pdf
@ -703,7 +706,8 @@ if (empty($reshook))
$object = new ExpenseReport($db);
$object->fetch($id);
$result = $object->setDeny($user, GETPOST('detail_refuse', 'alpha'));
$detailRefuse = GETPOST('detail_refuse', 'alpha');
$result = $object->setDeny($user, $detailRefuse);
if ($result > 0)
{
@ -751,7 +755,8 @@ if (empty($reshook))
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
$message = $langs->transnoentities("ExpenseReportRefusedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $_POST['detail_refuse'], $link);
$link = '<a href="' . $link . '">' . $link . '</a>';
$message = $langs->transnoentities("ExpenseReportRefusedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailRefuse, $link);
// Rebuilt pdf
/*
@ -831,7 +836,8 @@ if (empty($reshook))
if ($user->id == $object->fk_user_valid || $user->id == $object->fk_user_author)
{
$result = $object->set_cancel($user, GETPOST('detail_cancel', 'alpha'));
$detailCancel = GETPOST('detail_cancel', 'alpha');
$result = $object->set_cancel($user, $detailCancel);
if ($result > 0)
{
@ -879,7 +885,8 @@ if (empty($reshook))
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
$message = $langs->transnoentities("ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), GETPOST('detail_cancel', 'alpha'), $link);
$link = '<a href="' . $link . '">' . $link . '</a>';
$message = $langs->transnoentities("ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailCancel, $link);
// Rebuilt pdf
/*
@ -1104,6 +1111,7 @@ if (empty($reshook))
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
$link = '<a href="' . $link . '">' . $link . '</a>';
$message = $langs->transnoentities("ExpenseReportPaidMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
// Generate pdf before attachment
@ -1735,7 +1743,7 @@ else
if ($action == 'cancel')
{
$array_input = array('text'=>$langs->trans("ConfirmCancelTrip"), array('type'=>"text", 'label'=>'<strong>'.$langs->trans("Comment").'</strong>', 'name'=>"detail_cancel", 'value'=>""));
$formconfirm = $form->formconfirm($_SEVER["PHP_SELF"]."?id=".$id, $langs->trans("Cancel"), "", "confirm_cancel", $array_input, "", 1);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("Cancel"), "", "confirm_cancel", $array_input, "", 1);
}
if ($action == 'setdraft')

View File

@ -377,9 +377,9 @@ if ($step == 2 && $action == 'select_model')
$result = $objexport->fetch($exportmodelid);
if ($result > 0)
{
$fieldsarray = explode(',', $objexport->hexa);
$fieldsarray = preg_split("/,(?! [^(]*\))/", $objexport->hexa);
$i = 1;
foreach ($fieldsarray as $val)
foreach($fieldsarray as $val)
{
$array_selected[$val] = $i;
$i++;

View File

@ -179,6 +179,8 @@ delete from llx_categorie_member where fk_categorie not in (select rowid from ll
delete from llx_categorie_contact where fk_categorie not in (select rowid from llx_categorie where type = 4);
delete from llx_categorie_project where fk_categorie not in (select rowid from llx_categorie where type = 6);
-- Fix: delete orphelins in ecm_files
delete from llx_ecm_files where src_object_type = 'expensereport' and src_object_id NOT IN (select rowid from llx_expensereport);
-- Fix: delete orphelin deliveries. Note: deliveries are linked to shipment by llx_element_element only. No other links.
delete from llx_livraisondet where fk_livraison not in (select fk_target from llx_element_element where targettype = 'delivery') AND fk_livraison not in (select fk_source from llx_element_element where sourcetype = 'delivery');

View File

@ -117,7 +117,8 @@ ErrorLoginDoesNotExists=User with login <b>%s</b> could not be found.
ErrorLoginHasNoEmail=This user has no email address. Process aborted.
ErrorBadValueForCode=Bad value for security code. Try again with new value...
ErrorBothFieldCantBeNegative=Fields %s and %s can't be both negative
ErrorFieldCantBeNegativeOnInvoice=Field <strong>%s</strong> cannot be negative on this type of invoice. If you want to add a discount line, just create the discount first with link %s on screen and apply it to the invoice. You can also ask your admin to set option FACTURE_ENABLE_NEGATIVE_LINES to 1 to allow the old behaviour.
ErrorFieldCantBeNegativeOnInvoice=Field <strong>%s</strong> cannot be negative on this type of invoice. If you need to add a discount line, just create the discount first (from field '%s' in thirdparty card) and apply it to the invoice. You can also ask your admin to set option FACTURE_ENABLE_NEGATIVE_LINES to 1 to allow the old behaviour.
ErrorLinesCantBeNegativeOnDeposits=Lines can't be negative in a deposit. You will face problems when you will need to consume the deposit in final invoice if you do so.
ErrorQtyForCustomerInvoiceCantBeNegative=Quantity for line into customer invoices can't be negative
ErrorWebServerUserHasNotPermission=User account <b>%s</b> used to execute web server has no permission for that
ErrorNoActivatedBarcode=No barcode type activated

View File

@ -29,7 +29,7 @@ ExpenseReportApprovedMessage=La note de frais %s a été approuvée.<br>- Utilis
ExpenseReportRefused=Une note de frais a été refusée
ExpenseReportRefusedMessage=La note de frais %s a été refusée.<br>- Utilisateur : %s<br>- Refusée par : %s<br>- Motif du refus : %s<br>Cliquez ici pour afficher la note de frais: %s
ExpenseReportCanceled=Une note de frais a été annulée
ExpenseReportCanceledMessage=La note de frais %s a été annulée.<br>- Utilisateur : %s<br>- Annulée par : %s<br>- Motif de l'annulation :%s<br>Cliquez ici pour afficher la note de frais %s
ExpenseReportCanceledMessage=La note de frais %s a été annulée.<br>- Utilisateur : %s<br>- Annulée par : %s<br>- Motif de l'annulation : %s<br>Cliquez ici pour afficher la note de frais %s
ExpenseReportPaid=Une note de frais a été réglée
ExpenseReportPaidMessage=La note de frais %s a été réglée.<br>- Utilisateur : %s<br>- Réglée par : %s<br>Cliquez ici pour afficher la note de frais %s
TripId=Id note de frais

View File

@ -207,33 +207,34 @@ if (!empty($conf->stock->enabled))
print '<span class="opacitymedium">'.$langs->trans("StockDecreaseForPointOfSaleDisabled").'</span>';
}
print '</td></tr>';
if ($conf->receiptprinter->enabled) {
// Select printer to use with terminal
require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
$printer = new dolReceiptPrinter($db);
$printer->listprinters();
$printers = array();
foreach ($printer->listprinters as $key => $value) {
$printers[$value['rowid']] = $value['name'];
}
print '<tr class="oddeven"><td>'.$langs->trans("TakeposTerminalPrinterToUse").'</td>';
print '<td>';
print $form->selectarray('TAKEPOS_PRINTER_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_PRINTER_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_PRINTER_TO_USE'.$terminal}), 1);
print '</td></tr>';
$printer->listPrintersTemplates();
$templates = array();
foreach ($printer->listprinterstemplates as $key => $value) {
$templates[$value['rowid']] = $value['name'];
}
print '<tr class="oddeven"><td>'.$langs->trans("TakeposTerminalTemplateToUseForInvoicesTicket").'</td>';
print '<td>';
print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal, $templates, (empty($conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal}), 1);
print '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("TakeposTerminalTemplateToUseForOrdersTicket").'</td>';
print '<td>';
print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal, $templates, (empty($conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal}), 1);
print '</td></tr>';
}
if ($conf->receiptprinter->enabled) {
// Select printer to use with terminal
require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
$printer = new dolReceiptPrinter($db);
$printer->listprinters();
$printers = array();
foreach ($printer->listprinters as $key => $value) {
$printers[$value['rowid']] = $value['name'];
}
print '<tr class="oddeven"><td>'.$langs->trans("TakeposTerminalPrinterToUse").'</td>';
print '<td>';
print $form->selectarray('TAKEPOS_PRINTER_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_PRINTER_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_PRINTER_TO_USE'.$terminal}), 1);
print '</td></tr>';
$printer->listPrintersTemplates();
$templates = array();
foreach ($printer->listprinterstemplates as $key => $value) {
$templates[$value['rowid']] = $value['name'];
}
print '<tr class="oddeven"><td>'.$langs->trans("TakeposTerminalTemplateToUseForInvoicesTicket").'</td>';
print '<td>';
print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal, $templates, (empty($conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal}), 1);
print '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("TakeposTerminalTemplateToUseForOrdersTicket").'</td>';
print '<td>';
print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal, $templates, (empty($conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal}), 1);
print '</td></tr>';
}
print '</table>';