2
0
forked from Wavyzz/dolibarr

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

Conflicts:
	htdocs/filefunc.inc.php
	htdocs/opensurvey/class/opensurveysondage.class.php
	htdocs/product/class/product.class.php
	htdocs/supplier_proposal/card.php
This commit is contained in:
Laurent Destailleur
2020-12-04 19:24:29 +01:00
9 changed files with 45 additions and 30 deletions

View File

@@ -4804,7 +4804,7 @@ function price2num($amount, $rounding = '', $option = 0)
if ($option != 1) { // If not a PHP number or unknown, we change or clean format if ($option != 1) { // If not a PHP number or unknown, we change or clean format
//print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'<br>'; //print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'<br>';
if (!is_numeric($amount)) { if (!is_numeric($amount)) {
$amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\-]/', '', $amount); $amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>]/', '', $amount);
} }
if ($option == 2 && $thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator and string come frominput data, so 1.123 is 1123 if ($option == 2 && $thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator and string come frominput data, so 1.123 is 1123

View File

@@ -130,7 +130,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
// List of fields to search into when doing a "search in all" // List of fields to search into when doing a "search in all"
$fieldstosearchall = array( $fieldstosearchall = array(
'cf.ref'=>'Ref', 'cf.ref'=>'Ref',
'cf.ref_supplier'=>'RefSupplierOrder', 'cf.ref_supplier'=>'RefOrderSupplier',
'pd.description'=>'Description', 'pd.description'=>'Description',
's.nom'=>"ThirdParty", 's.nom'=>"ThirdParty",
's.name_alias'=>"AliasNameShort", 's.name_alias'=>"AliasNameShort",

View File

@@ -37,9 +37,9 @@ INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active)
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (6,'KIALA','KIALA','Relais Kiala','http://www.kiala.fr/tnt/delivery/{TRACKID}', 0); INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (6,'KIALA','KIALA','Relais Kiala','http://www.kiala.fr/tnt/delivery/{TRACKID}', 0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (7,'GLS','GLS','General Logistics Systems','https://gls-group.eu/FR/fr/suivi-colis?match={TRACKID}', 0); INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (7,'GLS','GLS','General Logistics Systems','https://gls-group.eu/FR/fr/suivi-colis?match={TRACKID}', 0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (8,'CHRONO','Chronopost','Chronopost','http://www.chronopost.fr/expedier/inputLTNumbersNoJahia.do?listeNumeros={TRACKID}', 0); INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (8,'CHRONO','Chronopost','Chronopost','http://www.chronopost.fr/expedier/inputLTNumbersNoJahia.do?listeNumeros={TRACKID}', 0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (9,'INPERSON', 'In person at your site', NULL, NULL, 0, NULL), INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (9,'INPERSON', 'In person at your site', NULL, NULL, 0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (10,'FEDEX', 'Fedex', NULL, 'https://www.fedex.com/apps/fedextrack/index.html?tracknumbers={TRACKID}', 0, NULL), INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (10,'FEDEX', 'Fedex', NULL, 'https://www.fedex.com/apps/fedextrack/index.html?tracknumbers={TRACKID}', 0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (11,'TNT', 'TNT', NULL, 'https://www.tnt.com/express/fr_fr/site/outils-expedition/suivi.html?searchType=con&cons=={TRACKID}', 0, NULL), INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (11,'TNT', 'TNT', NULL, 'https://www.tnt.com/express/fr_fr/site/outils-expedition/suivi.html?searchType=con&cons=={TRACKID}', 0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (12,'DHL', 'DHL', NULL, 'https://www.dhl.com/fr-fr/home/tracking/tracking-global-forwarding.html?submit=1&tracking-id={TRACKID}', 0, NULL), INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (12,'DHL', 'DHL', NULL, 'https://www.dhl.com/fr-fr/home/tracking/tracking-global-forwarding.html?submit=1&tracking-id={TRACKID}', 0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (13,'DPD', 'DPD', NULL, 'https://www.dpd.fr/trace/{TRACKID}', 0, NULL), INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (13,'DPD', 'DPD', NULL, 'https://www.dpd.fr/trace/{TRACKID}', 0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (14,'MAINFREIGHT', 'Mainfreight', NULL, 'https://www.mainfreight.com/track?{TRACKID}', 0, NULL); INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (14,'MAINFREIGHT', 'Mainfreight', NULL, 'https://www.mainfreight.com/track?{TRACKID}', 0);

View File

@@ -338,3 +338,14 @@ ALTER TABLE llx_expedition ADD COLUMN billed smallint DEFAULT 0;
-- VMYSQL4.3 ALTER TABLE llx_mrp_mo MODIFY COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; -- VMYSQL4.3 ALTER TABLE llx_mrp_mo MODIFY COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
ALTER TABLE llx_commande_fournisseurdet ADD INDEX idx_commande_fournisseurdet_fk_commande (fk_commande);
ALTER TABLE llx_commande_fournisseurdet ADD INDEX idx_commande_fournisseurdet_fk_product (fk_product);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (9,'INPERSON', 'In person at your site', NULL, NULL, 0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (10,'FEDEX', 'Fedex', NULL, 'https://www.fedex.com/apps/fedextrack/index.html?tracknumbers={TRACKID}', 0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (11,'TNT', 'TNT', NULL, 'https://www.tnt.com/express/fr_fr/site/outils-expedition/suivi.html?searchType=con&cons=={TRACKID}', 0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (12,'DHL', 'DHL', NULL, 'https://www.dhl.com/fr-fr/home/tracking/tracking-global-forwarding.html?submit=1&tracking-id={TRACKID}', 0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (13,'DPD', 'DPD', NULL, 'https://www.dpd.fr/trace/{TRACKID}', 0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (14,'MAINFREIGHT', 'Mainfreight', NULL, 'https://www.mainfreight.com/track?{TRACKID}', 0);

View File

@@ -131,7 +131,7 @@ if (!$sortfield)
} }
// Products // Products
$TRes = $form->select_produits_list('', '', '', 20, 0, '', 1, 2, 1, 0, '', 1); $TRes = $form->select_produits_list('', '', '', '', 0, '', 1, 2, 1, 0, '', 1);
$TProducts = array(); $TProducts = array();
foreach ($TRes as $prod) { foreach ($TRes as $prod) {

View File

@@ -128,7 +128,6 @@ class Opensurveysondage extends CommonObject
const STATUS_CLOSED = 2; const STATUS_CLOSED = 2;
/** /**
* Constructor * Constructor
* *
@@ -149,6 +148,8 @@ class Opensurveysondage extends CommonObject
*/ */
public function create(User $user, $notrigger = 0) public function create(User $user, $notrigger = 0)
{ {
global $conf;
$error = 0; $error = 0;
// Clean parameters // Clean parameters
@@ -173,7 +174,8 @@ class Opensurveysondage extends CommonObject
$sql .= "mailsonde,"; $sql .= "mailsonde,";
$sql .= "allow_comments,"; $sql .= "allow_comments,";
$sql .= "allow_spy,"; $sql .= "allow_spy,";
$sql .= "sujet"; $sql .= "sujet,";
$sql .= "entity";
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= "'".$this->db->escape($this->id_sondage)."',"; $sql .= "'".$this->db->escape($this->id_sondage)."',";
$sql .= " ".(empty($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").","; $sql .= " ".(empty($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").",";
@@ -182,10 +184,11 @@ class Opensurveysondage extends CommonObject
$sql .= " '".$this->db->idate($this->date_fin)."',"; $sql .= " '".$this->db->idate($this->date_fin)."',";
$sql .= " ".(int) $this->status.","; $sql .= " ".(int) $this->status.",";
$sql .= " '".$this->db->escape($this->format)."',"; $sql .= " '".$this->db->escape($this->format)."',";
$sql .= " ".$this->db->escape($this->mailsonde).","; $sql .= " ".((int) $this->mailsonde).",";
$sql .= " ".$this->db->escape($this->allow_comments).","; $sql .= " ".((int) $this->allow_comments).",";
$sql .= " ".$this->db->escape($this->allow_spy).","; $sql .= " ".((int) $this->allow_spy).",";
$sql .= " '".$this->db->escape($this->sujet)."'"; $sql .= " '".$this->db->escape($this->sujet)."',";
$sql .= " ".((int) $conf->entity);
$sql .= ")"; $sql .= ")";
$this->db->begin(); $this->db->begin();

View File

@@ -846,6 +846,11 @@ class Product extends CommonObject
$this->width_units = trim($this->width_units); $this->width_units = trim($this->width_units);
$this->height = price2num($this->height); $this->height = price2num($this->height);
$this->height_units = trim($this->height_units); $this->height_units = trim($this->height_units);
$this->surface = price2num($this->surface);
$this->surface_units = trim($this->surface_units);
$this->volume = price2num($this->volume);
$this->volume_units = trim($this->volume_units);
// set unit not defined // set unit not defined
if (is_numeric($this->length_units)) { if (is_numeric($this->length_units)) {
$this->width_units = $this->length_units; // Not used yet $this->width_units = $this->length_units; // Not used yet
@@ -853,20 +858,17 @@ class Product extends CommonObject
if (is_numeric($this->length_units)) { if (is_numeric($this->length_units)) {
$this->height_units = $this->length_units; // Not used yet $this->height_units = $this->length_units; // Not used yet
} }
// Automated compute surface and volume if not filled // Automated compute surface and volume if not filled
if (empty($this->surface) && !empty($this->length) && !empty($this->width) && $this->length_units == $this->width_units) { if (empty($this->surface) && !empty($this->length) && !empty($this->width) && $this->length_units == $this->width_units) {
$this->surface = $this->length * $this->width; $this->surface = $this->length * $this->width;
$this->surface_units = measuring_units_squared($this->length_units); $this->surface_units = measuring_units_squared($this->length_units);
} }
if (empty($this->volume) && !empty($this->surface_units) && !empty($this->height) && $this->length_units == $this->height_units) { if (empty($this->volume) && !empty($this->surface) && !empty($this->height) && $this->length_units == $this->height_units) {
$this->volume = $this->surface * $this->height; $this->volume = $this->surface * $this->height;
$this->volume_units = measuring_units_cubed($this->height_units); $this->volume_units = measuring_units_cubed($this->height_units);
} }
$this->surface = price2num($this->surface);
$this->surface_units = trim($this->surface_units);
$this->volume = price2num($this->volume);
$this->volume_units = trim($this->volume_units);
if (empty($this->tva_tx)) { if (empty($this->tva_tx)) {
$this->tva_tx = 0; $this->tva_tx = 0;
} }

View File

@@ -545,14 +545,13 @@ if (empty($reshook))
$date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
$ref_supplier = GETPOST('fourn_ref', 'alpha'); $ref_supplier = GETPOST('fourn_ref', 'alpha');
$prod_entry_mode = GETPOST('prod_entry_mode'); $prod_entry_mode = GETPOST('prod_entry_mode');
if ($prod_entry_mode == 'free') if ($prod_entry_mode == 'free') {
{
$idprod = 0; $idprod = 0;
$price_ht = GETPOST('price_ht'); $price_ht = GETPOST('price_ht');
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
} else { } else {
$idprod = GETPOST('idprod', 'int'); $idprod = GETPOST('idprod', 'int');
$price_ht = ''; $price_ht = GETPOST('price_ht');
$tva_tx = ''; $tva_tx = '';
} }
@@ -586,8 +585,8 @@ if (empty($reshook))
$error++; $error++;
} }
if (!$error && ($qty >= 0)) { if (!$error && ($qty >= 0)) {
$pu_ht = 0; $pu_ht = price2num($price_ht, 'MU');
$pu_ttc = 0; $pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
$price_min = 0; $price_min = 0;
$price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT');
@@ -652,12 +651,12 @@ if (empty($reshook))
$localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
$localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
$pu_ht = $productsupplier->fourn_pu;
if (empty($pu_ht)) $pu_ht = 0; // If pu is '' or null, we force to have a numeric value if (empty($pu_ht)) $pu_ht = 0; // If pu is '' or null, we force to have a numeric value
// If GETPOST('idprodfournprice') is a numeric, we can use it. If it is empty or if it is 'idprod_123', we should use -1 (not used) // If GETPOST('idprodfournprice') is a numeric, we can use it. If it is empty or if it is 'idprod_123', we should use -1 (not used)
$fournprice = (is_numeric(GETPOST('idprodfournprice', 'alpha')) ? GETPOST('idprodfournprice', 'alpha') : -1); $fournprice = (is_numeric(GETPOST('idprodfournprice', 'alpha')) ? GETPOST('idprodfournprice', 'alpha') : -1);
$buyingprice = 0; $buyingprice = 0;
$pu_ht_devise = price2num($price_ht_devise, 'MU');
$result = $object->addline( $result = $object->addline(
$desc, $desc,
@@ -683,7 +682,7 @@ if (empty($reshook))
$productsupplier->fk_unit, $productsupplier->fk_unit,
'', '',
0, 0,
$productsupplier->fourn_multicurrency_unitprice, $pu_ht_devise,
$date_start, $date_start,
$date_end $date_end
); );

View File

@@ -1267,9 +1267,9 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
$this->assertEquals(1234, price2num('1.234', '', 2), 'Test 1.234 give 1234 with spanish language if user input'); $this->assertEquals(1234, price2num('1.234', '', 2), 'Test 1.234 give 1234 with spanish language if user input');
$this->assertEquals(1.234, price2num('1,234', '', 2), 'Test 1,234 give 1234 with spanish language if user input'); $this->assertEquals(1.234, price2num('1,234', '', 2), 'Test 1,234 give 1234 with spanish language if user input');
$this->assertEquals(1234, price2num('1 234', '', 2), 'Test 1 234 give 1234 with spanish language if user input'); $this->assertEquals(1234, price2num('1 234', '', 2), 'Test 1 234 give 1234 with spanish language if user input');
$this->assertEquals(1.234, price2num('1.234'), 'Test 1.234 give 1.234 with spanish language'); $this->assertEquals(-1.234, price2num('-1.234'), 'Test 1.234 give 1.234 with spanish language');
$this->assertEquals(1.234, price2num('1,234'), 'Test 1,234 give 1234 with spanish language'); $this->assertEquals(-1.234, price2num('-1,234'), 'Test 1,234 give 1234 with spanish language');
$this->assertEquals(1234, price2num('1 234'), 'Test 1 234 give 1234 with spanish language'); $this->assertEquals(-1234, price2num('-1 234'), 'Test 1 234 give 1234 with spanish language');
$this->assertEquals(21500123, price2num('21.500.123'), 'Test 21.500.123 give 21500123 with spanish language'); $this->assertEquals(21500123, price2num('21.500.123'), 'Test 21.500.123 give 21500123 with spanish language');
$this->assertEquals(21500123, price2num('21500.123', 0, 2), 'Test 21500.123 give 21500123 with spanish language if user input'); $this->assertEquals(21500123, price2num('21500.123', 0, 2), 'Test 21500.123 give 21500123 with spanish language if user input');
$this->assertEquals(21500.123, price2num('21500.123'), 'Test 21500.123 give 21500123 with spanish language'); $this->assertEquals(21500.123, price2num('21500.123'), 'Test 21500.123 give 21500123 with spanish language');