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

This commit is contained in:
Laurent Destailleur 2020-08-14 11:09:06 +02:00
commit a916f6af59
10 changed files with 67 additions and 11 deletions

View File

@ -113,7 +113,7 @@ if ($conf->global->PRODUCT_USE_UNITS)
{
$coldisplay++;
print '<td class="nobottom linecoluseunit left">';
print $form->selectUnits($line->fk_unit, "units");
print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit, "units");
print '</td>';
}

View File

@ -3850,7 +3850,7 @@ function dol_print_error($db = '', $error = '', $errors = null)
{
$out .= "<b>".$langs->trans("OS").":</b> ".php_uname()."<br>\n";
}
$out .= "<b>".$langs->trans("UserAgent").":</b> ".$_SERVER["HTTP_USER_AGENT"]."<br>\n";
$out .= "<b>".$langs->trans("UserAgent").":</b> ".dol_htmlentities($_SERVER["HTTP_USER_AGENT"], ENT_COMPAT, 'UTF-8')."<br>\n";
$out .= "<br>\n";
$out .= "<b>".$langs->trans("RequestedUrl").":</b> ".dol_htmlentities($_SERVER["REQUEST_URI"], ENT_COMPAT, 'UTF-8')."<br>\n";
$out .= "<b>".$langs->trans("Referer").":</b> ".(isset($_SERVER["HTTP_REFERER"]) ?dol_htmlentities($_SERVER["HTTP_REFERER"], ENT_COMPAT, 'UTF-8') : '')."<br>\n";

View File

@ -362,7 +362,7 @@ if ($nolinesbefore) {
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$coldisplay++;
print '<td class="nobottom linecoluseunit left">';
print $form->selectUnits($line->fk_unit, "units");
print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit, "units");
print '</td>';
}
$remise_percent = $buyer->remise_percent;
@ -423,6 +423,27 @@ if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dat
print '<td colspan="'.($coldisplay - (empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? 0 : 1)).'">';
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
$prefillDates = false;
if(! empty($conf->global->MAIN_FILL_SERVICE_DATES_FROM_LAST_SERVICE_LINE) && ! empty($object->lines))
{
for($i = count($object->lines) - 1; $i >= 0; $i--)
{
$lastline = $object->lines[$i];
if($lastline->product_type == Product::TYPE_SERVICE && (! empty($lastline->date_start) || ! empty($lastline->date_end)))
{
$date_start_prefill = $lastline->date_start;
$date_end_prefill = $lastline->date_end;
$prefillDates = true;
break;
}
}
}
if (!empty($object->element) && $object->element == 'contrat')
{
print $langs->trans("DateStartPlanned").' ';
@ -435,7 +456,33 @@ if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dat
print ' '.$langs->trans('to').' ';
print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0);
};
if($prefillDates)
{
echo ' <span class="small"><a href="#" id="prefill_service_dates">' . $langs->trans('FillWithLastServiceDates') . '</a></span>';
}
print '<script>';
if($prefillDates)
{
?>
function prefill_service_dates()
{
$('#date_start').val("<?php echo dol_escape_js(dol_print_date($date_start_prefill, '%d/%m/%Y')); ?>").trigger('change');
$('#date_end').val("<?php echo dol_escape_js(dol_print_date($date_end_prefill, '%d/%m/%Y')); ?>").trigger('change');
return false; // Prevent default link behaviour (which is go to href URL)
}
$(document).ready(function()
{
$('#prefill_service_dates').click(prefill_service_dates);
});
<?php
}
if (!$date_start) {
if (isset($conf->global->MAIN_DEFAULT_DATE_START_HOUR)) {
print 'jQuery("#date_starthour").val("'.$conf->global->MAIN_DEFAULT_DATE_START_HOUR.'");';

View File

@ -219,3 +219,10 @@ create table llx_c_recruitment_origin
label varchar(64) NOT NULL,
active tinyint DEFAULT 1 NOT NULL
)ENGINE=innodb;
ALTER TABLE llx_product MODIFY COLUMN seuil_stock_alerte float;
ALTER TABLE llx_product MODIFY COLUMN desiredstock float;
ALTER TABLE llx_product_warehouse_properties MODIFY COLUMN seuil_stock_alerte float;
ALTER TABLE llx_product_warehouse_properties MODIFY COLUMN desiredstock float;

View File

@ -60,7 +60,7 @@ create table llx_product
tobatch tinyint DEFAULT 0 NOT NULL, -- Is it a product that need a batch management (eat-by or lot management)
fk_product_type integer DEFAULT 0, -- Type of product: 0 for regular product, 1 for service, 9 for other (used by external module)
duration varchar(6),
seuil_stock_alerte integer DEFAULT NULL,
seuil_stock_alerte float DEFAULT NULL,
url varchar(255),
barcode varchar(180) DEFAULT NULL, -- barcode
fk_barcode_type integer DEFAULT NULL, -- barcode type
@ -96,7 +96,7 @@ create table llx_product
import_key varchar(14), -- Import key
model_pdf varchar(255), -- model save dodument used
fk_price_expression integer, -- Link to the rule for dynamic price calculation
desiredstock integer DEFAULT 0,
desiredstock float DEFAULT 0,
fk_unit integer DEFAULT NULL,
price_autogen tinyint DEFAULT 0,
fk_project integer DEFAULT NULL -- Used when product was generated by a project or is specifif to a project

View File

@ -24,8 +24,8 @@ create table llx_product_warehouse_properties
tms timestamp,
fk_product integer NOT NULL,
fk_entrepot integer NOT NULL,
seuil_stock_alerte integer DEFAULT '0',
desiredstock integer DEFAULT '0',
seuil_stock_alerte float DEFAULT '0',
desiredstock float DEFAULT '0',
import_key varchar(14) -- Import key
)ENGINE=innodb;

View File

@ -104,6 +104,7 @@ SetDefaultBarcodeType=Set barcode type
BarcodeValue=Barcode value
NoteNotVisibleOnBill=Note (not visible on invoices, proposals...)
ServiceLimitedDuration=If product is a service with limited duration:
FillWithLastServiceDates=Fill with last service line dates
MultiPricesAbility=Multiple price segments per product/service (each customer is in one price segment)
MultiPricesNumPrices=Number of prices
DefaultPriceType=Base of prices per default (with versus without tax) when adding new sale prices

View File

@ -1107,7 +1107,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
{
print '<tr><td>'.$langs->trans('DefaultUnitToShow').'</td>';
print '<td colspan="3">';
print $form->selectUnits('', 'units');
print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit, 'units');
print '</td></tr>';
}

View File

@ -205,7 +205,7 @@ class Product extends CommonObject
/**
* Stock alert
*
* @var int
* @var float
*/
public $seuil_stock_alerte = 0;
@ -995,7 +995,7 @@ class Product extends CommonObject
$sql .= ", volume = ".($this->volume != '' ? "'".$this->db->escape($this->volume)."'" : 'null');
$sql .= ", volume_units = ".($this->volume_units != '' ? "'".$this->db->escape($this->volume_units)."'" : 'null');
$sql .= ", fk_default_warehouse = ".($this->fk_default_warehouse > 0 ? $this->db->escape($this->fk_default_warehouse) : 'null');
$sql .= ", seuil_stock_alerte = ".((isset($this->seuil_stock_alerte) && is_numeric($this->seuil_stock_alerte)) ? (int) $this->seuil_stock_alerte : 'null');
$sql .= ", seuil_stock_alerte = ".((isset($this->seuil_stock_alerte) && is_numeric($this->seuil_stock_alerte)) ? (float) $this->seuil_stock_alerte : 'null');
$sql .= ", description = '".$this->db->escape($this->description)."'";
$sql .= ", url = ".($this->url ? "'".$this->db->escape($this->url)."'" : 'null');
$sql .= ", customcode = '".$this->db->escape($this->customcode)."'";
@ -1008,7 +1008,7 @@ class Product extends CommonObject
$sql .= ", accountancy_code_sell= '".$this->db->escape($this->accountancy_code_sell)."'";
$sql .= ", accountancy_code_sell_intra= '".$this->db->escape($this->accountancy_code_sell_intra)."'";
$sql .= ", accountancy_code_sell_export= '".$this->db->escape($this->accountancy_code_sell_export)."'";
$sql .= ", desiredstock = ".((isset($this->desiredstock) && is_numeric($this->desiredstock)) ? (int) $this->desiredstock : "null");
$sql .= ", desiredstock = ".((isset($this->desiredstock) && is_numeric($this->desiredstock)) ? (float) $this->desiredstock : "null");
$sql .= ", cost_price = ".($this->cost_price != '' ? $this->db->escape($this->cost_price) : 'null');
$sql .= ", fk_unit= ".(!$this->fk_unit ? 'NULL' : (int) $this->fk_unit);
$sql .= ", price_autogen = ".(!$this->price_autogen ? 0 : 1);

View File

@ -398,6 +398,7 @@ if ($action == "deleteline") {
$invoice->deleteline($deletelineid);
$invoice->fetch($placeid);
}
if (count($invoice->lines)==0) $invoice->delete($user);
}
if ($action == "delete") {