2
0
forked from Wavyzz/dolibarr

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

Conflicts:
	htdocs/product/stock/class/mouvementstock.class.php
This commit is contained in:
Laurent Destailleur
2020-01-23 17:41:31 +01:00
13 changed files with 100 additions and 42 deletions

View File

@@ -32,6 +32,8 @@
*/
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
/**
* Manage the different format accountancy export
@@ -742,10 +744,10 @@ class AccountancyExport
print $line->label_operation.$separator;
// FEC:Debit
print price2num($line->debit).$separator;
print price2fec($line->debit).$separator;
// FEC:Credit
print price2num($line->credit).$separator;
print price2fec($line->credit).$separator;
// FEC:EcritureLet
print $line->lettering_code.$separator;

View File

@@ -1298,7 +1298,6 @@ if ($id)
// Determines the name of the field in relation to the possible names
// in data dictionaries
$showfield = 1; // By defaut
$align = "left";
$cssprefix = '';
$sortable = 1;
$valuetoshow = ucfirst($fieldlist[$field]); // By defaut
@@ -1310,23 +1309,23 @@ if ($id)
if ($fieldlist[$field] == 'taux') {
if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow = $langs->trans("Rate");
else $valuetoshow = $langs->trans("Amount");
$align = 'center';
$cssprefix = 'center ';
}
if ($fieldlist[$field] == 'localtax1_type') { $valuetoshow = $langs->trans("UseLocalTax")." 2"; $align = "center"; $sortable = 0; }
if ($fieldlist[$field] == 'localtax1') { $valuetoshow = $langs->trans("Rate")." 2"; $align = "center"; $sortable = 0; }
if ($fieldlist[$field] == 'localtax2_type') { $valuetoshow = $langs->trans("UseLocalTax")." 3"; $align = "center"; $sortable = 0; }
if ($fieldlist[$field] == 'localtax2') { $valuetoshow = $langs->trans("Rate")." 3"; $align = "center"; $sortable = 0; }
if ($fieldlist[$field] == 'localtax1_type') { $valuetoshow = $langs->trans("UseLocalTax")." 2"; $cssprefix = "center "; $sortable = 0; }
if ($fieldlist[$field] == 'localtax1') { $valuetoshow = $langs->trans("Rate")." 2"; $cssprefix = "center "; $sortable = 0; }
if ($fieldlist[$field] == 'localtax2_type') { $valuetoshow = $langs->trans("UseLocalTax")." 3"; $cssprefix = "center "; $sortable = 0; }
if ($fieldlist[$field] == 'localtax2') { $valuetoshow = $langs->trans("Rate")." 3"; $cssprefix = "center "; $sortable = 0; }
if ($fieldlist[$field] == 'organization') { $valuetoshow = $langs->trans("Organization"); }
if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); }
if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); }
if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); }
if ($fieldlist[$field] == 'position') { $align = 'right'; }
if ($fieldlist[$field] == 'position') { $cssprefix = 'right '; }
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Label"); }
if ($fieldlist[$field] == 'libelle_facture') { $valuetoshow = $langs->trans("LabelOnDocuments"); }
if ($fieldlist[$field] == 'country') { $valuetoshow = $langs->trans("Country"); }
if ($fieldlist[$field] == 'recuperableonly') { $valuetoshow = $langs->trans("NPR"); $align = "center"; }
if ($fieldlist[$field] == 'recuperableonly') { $valuetoshow = $langs->trans("NPR"); $cssprefix = "center "; }
if ($fieldlist[$field] == 'nbjour') { $valuetoshow = $langs->trans("NbOfDays"); }
if ($fieldlist[$field] == 'type_cdr') { $valuetoshow = $langs->trans("AtEndOfMonth"); $align = "center"; }
if ($fieldlist[$field] == 'type_cdr') { $valuetoshow = $langs->trans("AtEndOfMonth"); $cssprefix = "center "; }
if ($fieldlist[$field] == 'decalage') { $valuetoshow = $langs->trans("Offset"); }
if ($fieldlist[$field] == 'width' || $fieldlist[$field] == 'nx') { $valuetoshow = $langs->trans("Width"); }
if ($fieldlist[$field] == 'height' || $fieldlist[$field] == 'ny') { $valuetoshow = $langs->trans("Height"); }
@@ -1368,7 +1367,7 @@ if ($id)
// Show field title
if ($showfield)
{
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "align=".$align, $sortfield, $sortorder, $cssprefix);
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, $cssprefix);
}
}
// Favorite - Only activated on country dictionary
@@ -1424,8 +1423,8 @@ if ($id)
foreach ($fieldlist as $field => $value)
{
//var_dump($fieldlist);
$class = '';
$showfield = 1;
$align = "left";
$valuetoshow = $obj->{$fieldlist[$field]};
if ($fieldlist[$field] == 'entity') {
@@ -1457,13 +1456,13 @@ if ($id)
}
elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') {
$valuetoshow = yn($valuetoshow);
$align = "center";
$class = "center";
}
elseif ($fieldlist[$field] == 'type_cdr') {
if (empty($valuetoshow)) $valuetoshow = $langs->trans('None');
elseif ($valuetoshow == 1) $valuetoshow = $langs->trans('AtEndOfMonth');
elseif ($valuetoshow == 2) $valuetoshow = $langs->trans('CurrentNext');
$align = "center";
$class = "center";
} elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i', $fieldlist[$field])) {
$valuetoshow = price($valuetoshow);
}
@@ -1577,20 +1576,20 @@ if ($id)
$valuetoshow = $localtax_typeList[$valuetoshow];
else
$valuetoshow = '';
$align = "center";
$class = "center";
}
elseif ($fieldlist[$field] == 'localtax2_type') {
if ($obj->localtax2 != 0)
$valuetoshow = $localtax_typeList[$valuetoshow];
else
$valuetoshow = '';
$align = "center";
$class = "center";
}
elseif ($fieldlist[$field] == 'taux') {
$valuetoshow = price($valuetoshow, 0, $langs, 0, 0);
$align = "center";
$class = "center";
} elseif (in_array($fieldlist[$field], array('recuperableonly'))) {
$align = "center";
$class = "center";
}
elseif ($fieldlist[$field] == 'accountancy_code' || $fieldlist[$field] == 'accountancy_code_sell' || $fieldlist[$field] == 'accountancy_code_buy') {
$valuetoshow = length_accountg($valuetoshow);
@@ -1622,14 +1621,14 @@ if ($id)
$valuetoshow = ($obj->label && $key != strtoupper($obj->label) ? $key : $obj->{$fieldlist[$field]});
}
$class = 'tddict';
$class .= ($class ? ' ' : '').'tddict';
if ($fieldlist[$field] == 'note' && $id == 10) $class .= ' tdoverflowmax200';
if ($fieldlist[$field] == 'tracking') $class .= ' tdoverflowauto';
if ($fieldlist[$field] == 'position') $class .= ' right';
if ($fieldlist[$field] == 'localtax1_type') $class .= ' nowrap';
if ($fieldlist[$field] == 'localtax2_type') $class .= ' nowrap';
// Show value for field
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td align="'.$align.'" class="'.$class.'">'.$valuetoshow.'</td>';
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
}
}
@@ -1908,9 +1907,9 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
print '</td>';
}
elseif (in_array($fieldlist[$field], array('nbjour', 'decalage', 'taux', 'localtax1', 'localtax2'))) {
$align = "left";
if (in_array($fieldlist[$field], array('taux', 'localtax1', 'localtax2'))) $align = "center"; // Fields aligned on right
print '<td class="'.$align.'">';
$class = "left";
if (in_array($fieldlist[$field], array('taux', 'localtax1', 'localtax2'))) $class = "center"; // Fields aligned on right
print '<td class="'.$class.'">';
print '<input type="text" class="flat" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : '').'" size="3" name="'.$fieldlist[$field].'">';
print '</td>';
}

View File

@@ -791,16 +791,16 @@ class ActionComm extends CommonObject
*/
public function fetchResources()
{
$sql = 'SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency';
$this->userassigned = array();
$this->socpeopleassigned = array();
$sql = 'SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency';
$sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm_resources';
$sql .= ' WHERE fk_actioncomm = '.$this->id;
$sql .= " AND element_type IN ('user', 'socpeople')";
$resql = $this->db->query($sql);
if ($resql)
{
$this->userassigned = array();
$this->socpeopleassigned = array();
// If owner is known, we must but id first into list
if ($this->userownerid > 0) $this->userassigned[$this->userownerid] = array('id'=>$this->userownerid); // Set first so will be first into list.

View File

@@ -554,7 +554,10 @@ if ($resql)
$actionstatic->type_picto = $obj->type_picto;
$actionstatic->label = $obj->label;
$actionstatic->location = $obj->location;
$actionstatic->note = dol_htmlentitiesbr($obj->note);
$actionstatic->note = dol_htmlentitiesbr($obj->note); // deprecated
$actionstatic->note_public = dol_htmlentitiesbr($obj->note);
$actionstatic->fetchResources();
print '<tr class="oddeven">';
@@ -656,7 +659,6 @@ if ($resql)
if (!empty($arrayfields['a.fk_contact']['checked'])) {
print '<td>';
$actionstatic->fetchResources();
if (!empty($actionstatic->socpeopleassigned))
{
$contactList = array();

View File

@@ -109,7 +109,7 @@ class box_factures_imp extends ModeleBoxes
$sql.= " AND fk_statut = 1";
if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->socid) $sql.= " AND s.rowid = ".$user->socid;
$sql.= " GROUP BY s.nom, s.rowid, s.code_client, s.logo, f.ref, f.date_lim_reglement,";
$sql.= " GROUP BY s.nom, s.rowid, s.email, s.code_client, s.logo, f.ref, f.date_lim_reglement,";
$sql.= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid";
//$sql.= " ORDER BY f.datef DESC, f.ref DESC ";
$sql.= " ORDER BY datelimite ASC, f.ref ASC ";

View File

@@ -94,6 +94,7 @@ class box_services_expired extends ModeleBoxes
if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid;
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
$sql .= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid";
$sql.= ", s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
$sql .= " ORDER BY date_line ASC";
$sql .= $this->db->plimit($max, 0);

View File

@@ -508,7 +508,7 @@ class SMTPs
// The error here just means the ID/password combo doesn't work.
$_retVal = $this->socket_send_str(base64_encode("\0" . $this->_smtpsID . "\0" . $this->_smtpsPW), '235');
break;
case 'LOGIN':
case 'LOGIN': // most common case
default:
$this->socket_send_str('AUTH LOGIN', '334');
// User name will not return any error, server will take anything we give it.
@@ -588,7 +588,11 @@ class SMTPs
// From this point onward most server response codes should be 250
// Specify who the mail is from....
// This has to be the raw email address, strip the "name" off
$this->socket_send_str('MAIL FROM: ' . $this->getFrom('addr'), '250');
$resultmailfrom = $this->socket_send_str('MAIL FROM: ' . $this->getFrom('addr'), '250');
if (! $resultmailfrom) {
fclose($this->socket);
return false;
}
// 'RCPT TO:' must be given a single address, so this has to loop
// through the list of addresses, regardless of TO, CC or BCC
@@ -1792,6 +1796,7 @@ class SMTPs
$_retVal = false;
break;
}
$this->log .= $server_response;
$limit++;
}

View File

@@ -4605,7 +4605,6 @@ function price2num($amount, $rounding = '', $alreadysqlnb = 0)
return $amount;
}
/**
* Output a dimension with best unit
*

View File

@@ -2613,3 +2613,32 @@ function convertBackOfficeMediasLinksToPublicLinks($notetoshow)
$notetoshow = preg_replace('/src="[a-zA-Z0-9_\/\-\.]*(viewimage\.php\?modulepart=medias[^"]*)"/', 'src="'.$urlwithroot.'/\1"', $notetoshow);
return $notetoshow;
}
/**
* Function to format a value into a defined format for French administration (no thousand separator & decimal separator force to ',' with two decimals)
* Function used into accountancy FEC export
*
* @param float $amount Amount to format
* @return string Chain with formatted upright
* @see price2num() Format a numeric into a price for FEC files
*/
function price2fec($amount)
{
global $conf;
// Clean parameters
if (empty($amount)) $amount=0; // To have a numeric value if amount not defined or = ''
$amount = (is_numeric($amount) ? $amount : 0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number)
// Output decimal number by default
$nbdecimal = (empty($conf->global->ACCOUNTING_FEC_DECIMAL_LENGTH) ? 2 : $conf->global->ACCOUNTING_FEC_DECIMAL_LENGTH);
// Output separators by default
$dec = (empty($conf->global->ACCOUNTING_FEC_DECIMAL_SEPARATOR) ? ',' : $conf->global->ACCOUNTING_FEC_DECIMAL_SEPARATOR);
$thousand = (empty($conf->global->ACCOUNTING_FEC_THOUSAND_SEPARATOR) ? '' : $conf->global->ACCOUNTING_FEC_THOUSAND_SEPARATOR);
// Format number
$output = number_format($amount, $nbdecimal, $dec, $thousand);
return $output;
}

View File

@@ -10,6 +10,7 @@
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2019 Lenin Rivas <lenin.rivas@servcom-it.com>
*
* 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
@@ -2153,6 +2154,17 @@ function pdf_getLinkedObjects($object, $outputlangs)
$linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date_contrat, 'day', '', $outputlangs);
}
}
else if ($objecttype == 'fichinter')
{
$outputlangs->load('interventions');
foreach($objects as $elementobject)
{
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("InterRef");
$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref);
$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("InterDate");
$linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->datec, 'day', '', $outputlangs);
}
}
elseif ($objecttype == 'shipping')
{
$outputlangs->loadLangs(array("orders", "sendings"));

View File

@@ -186,11 +186,19 @@ class StockMovements extends DolibarrApi
}
// Type increase or decrease
if ($qty >= 0) $type = 3;
else $type = 2;
$type = 2;
if ($qty >= 0){
$type = 3;
}
if($this->stockmovement->_create(DolibarrApiAccess::$user, $product_id, $warehouse_id, $qty, $type, $price, $movementlabel, $movementcode, '', $dlc, $dluo, $lot) <= 0) {
throw new RestException(503, 'Error when create stock movement : '.$this->stockmovement->error);
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$eatBy = empty($dluo) ? '' : dol_stringtotime($dluo);
$sellBy = empty($dlc) ? '' : dol_stringtotime($dlc);
if($this->stockmovement->_create(DolibarrApiAccess::$user, $product_id, $warehouse_id, $qty, $type, $price, $movementlabel, $movementcode, '', $eatBy, $sellBy, $lot) <= 0) {
$errormessage = $this->stockmovement->error;
if (empty($errormessage)) $errormessage = join(',', $this->stockmovement->errors);
throw new RestException(503, 'Error when create stock movement : '.$errormessage);
}
return $this->stockmovement->id;

View File

@@ -173,7 +173,7 @@ class MouvementStock extends CommonObject
{
if (empty($batch))
{
$this->errors[] = $langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $product->ref);
$this->errors[] = $langs->transnoentitiesnoconv("ErrorTryToMakeMoveOnProductRequiringBatchData", $product->ref);
dol_syslog("Try to make a movement of a product with status_batch on without any batch data");
$this->db->rollback();
@@ -208,7 +208,8 @@ class MouvementStock extends CommonObject
if ($this->db->jdate($obj->eatby) != $eatby && $this->db->jdate($obj->eatby) != $eatbywithouthour) // We test date without hours and with hours for backward compatibility
{
// If found and eatby/sellby defined into table and provided and differs, return error
$this->errors[] = $langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby), 'dayhour'), dol_print_date($eatby, 'dayhour'));
$langs->load("stocks");
$this->errors[] = $langs->transnoentitiesnoconv("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby), 'dayhour'), dol_print_date($eatbywithouthour, 'dayhour'));
dol_syslog("ThisSerialAlreadyExistWithDifferentDate batch=".$batch.", eatby found into product_lot = ".$obj->eatby." = ".dol_print_date($this->db->jdate($obj->eatby), 'dayhourrfc')." so eatbywithouthour = ".$eatbywithouthour." = ".dol_print_date($eatbywithouthour)." - eatby provided = ".$eatby." = ".dol_print_date($eatby, 'dayhourrfc'), LOG_ERR);
$this->db->rollback();
return -3;
@@ -245,7 +246,7 @@ class MouvementStock extends CommonObject
if ($this->db->jdate($obj->sellby) != $sellby && $this->db->jdate($obj->sellby) != $sellbywithouthour) // We test date without hours and with hours for backward compatibility
{
// If found and eatby/sellby defined into table and provided and differs, return error
$this->errors[] = $langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby));
$this->errors[] = $langs->transnoentitiesnoconv("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby));
dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby)), LOG_ERR);
$this->db->rollback();
return -3;

View File

@@ -920,7 +920,7 @@ class Societe extends CommonObject
}
}
// Check for unicity
// Check for unicity on profid
if (!$error && $vallabel && $this->id_prof_verifiable($i))
{
if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0)))