|
@@ -134,7 +134,7 @@ discard block |
|
|
block discarded – undo |
134
|
134
|
*/ |
135
|
135
|
public $price; |
136
|
136
|
|
137
|
|
- public $price_formated; // used by takepos/ajax/ajax.php |
|
137
|
+ public $price_formated; // used by takepos/ajax/ajax.php |
138
|
138
|
|
139
|
139
|
/** |
140
|
140
|
* Selling price with tax |
|
@@ -143,7 +143,7 @@ discard block |
|
|
block discarded – undo |
143
|
143
|
*/ |
144
|
144
|
public $price_ttc; |
145
|
145
|
|
146
|
|
- public $price_ttc_formated; // used by takepos/ajax/ajax.php |
|
146
|
+ public $price_ttc_formated; // used by takepos/ajax/ajax.php |
147
|
147
|
|
148
|
148
|
/** |
149
|
149
|
* Minimum price net |
|
@@ -396,20 +396,20 @@ discard block |
|
|
block discarded – undo |
396
|
396
|
|
397
|
397
|
//! Metric of products |
398
|
398
|
public $weight; |
399
|
|
- public $weight_units; // scale -3, 0, 3, 6 |
|
399
|
+ public $weight_units; // scale -3, 0, 3, 6 |
400
|
400
|
public $length; |
401
|
|
- public $length_units; // scale -3, 0, 3, 6 |
|
401
|
+ public $length_units; // scale -3, 0, 3, 6 |
402
|
402
|
public $width; |
403
|
|
- public $width_units; // scale -3, 0, 3, 6 |
|
403
|
+ public $width_units; // scale -3, 0, 3, 6 |
404
|
404
|
public $height; |
405
|
|
- public $height_units; // scale -3, 0, 3, 6 |
|
405
|
+ public $height_units; // scale -3, 0, 3, 6 |
406
|
406
|
public $surface; |
407
|
|
- public $surface_units; // scale -3, 0, 3, 6 |
|
407
|
+ public $surface_units; // scale -3, 0, 3, 6 |
408
|
408
|
public $volume; |
409
|
|
- public $volume_units; // scale -3, 0, 3, 6 |
|
409
|
+ public $volume_units; // scale -3, 0, 3, 6 |
410
|
410
|
|
411
|
411
|
public $net_measure; |
412
|
|
- public $net_measure_units; // scale -3, 0, 3, 6 |
|
412
|
+ public $net_measure_units; // scale -3, 0, 3, 6 |
413
|
413
|
|
414
|
414
|
public $accountancy_code_sell; |
415
|
415
|
public $accountancy_code_sell_intra; |
|
@@ -723,10 +723,10 @@ discard block |
|
|
block discarded – undo |
723
|
723
|
$this->ref = dol_sanitizeFileName(dol_string_nospecial(trim($this->ref))); |
724
|
724
|
} |
725
|
725
|
$this->label = trim($this->label); |
726
|
|
- $this->price_ttc = (float)price2num($this->price_ttc); |
727
|
|
- $this->price = (float)price2num($this->price); |
728
|
|
- $this->price_min_ttc = (float)price2num($this->price_min_ttc); |
729
|
|
- $this->price_min = (float)price2num($this->price_min); |
|
726
|
+ $this->price_ttc = (float) price2num($this->price_ttc); |
|
727
|
+ $this->price = (float) price2num($this->price); |
|
728
|
+ $this->price_min_ttc = (float) price2num($this->price_min_ttc); |
|
729
|
+ $this->price_min = (float) price2num($this->price_min); |
730
|
730
|
$this->price_label = trim($this->price_label); |
731
|
731
|
if (empty($this->tva_tx)) { |
732
|
732
|
$this->tva_tx = 0; |
|
@@ -895,20 +895,20 @@ discard block |
|
|
block discarded – undo |
895
|
895
|
$sql .= ", mandatory_period"; |
896
|
896
|
$sql .= ") VALUES ("; |
897
|
897
|
$sql .= "'" . $this->db->idate($this->date_creation) . "'"; |
898
|
|
- $sql .= ", " . (!empty($this->entity) ? (int)$this->entity : (int)$conf->entity); |
|
898
|
+ $sql .= ", " . (!empty($this->entity) ? (int) $this->entity : (int) $conf->entity); |
899
|
899
|
$sql .= ", '" . $this->db->escape($this->ref) . "'"; |
900
|
900
|
$sql .= ", " . (!empty($this->ref_ext) ? "'" . $this->db->escape($this->ref_ext) . "'" : "null"); |
901
|
901
|
$sql .= ", " . price2num($price_min_ht); |
902
|
902
|
$sql .= ", " . price2num($price_min_ttc); |
903
|
903
|
$sql .= ", " . (!empty($this->label) ? "'" . $this->db->escape($this->label) . "'" : "null"); |
904
|
|
- $sql .= ", " . ((int)$user->id); |
905
|
|
- $sql .= ", " . ((int)$this->type); |
|
904
|
+ $sql .= ", " . ((int) $user->id); |
|
905
|
+ $sql .= ", " . ((int) $this->type); |
906
|
906
|
$sql .= ", " . price2num($price_ht, 'MT'); |
907
|
907
|
$sql .= ", " . price2num($price_ttc, 'MT'); |
908
|
908
|
$sql .= ", '" . $this->db->escape($this->price_base_type) . "'"; |
909
|
909
|
$sql .= ", " . (!empty($this->price_label) ? "'" . $this->db->escape($this->price_label) . "'" : "null"); |
910
|
|
- $sql .= ", " . ((int)$this->status); |
911
|
|
- $sql .= ", " . ((int)$this->status_buy); |
|
910
|
+ $sql .= ", " . ((int) $this->status); |
|
911
|
+ $sql .= ", " . ((int) $this->status_buy); |
912
|
912
|
if (!getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { |
913
|
913
|
$sql .= ", '" . $this->db->escape($this->accountancy_code_buy) . "'"; |
914
|
914
|
$sql .= ", '" . $this->db->escape($this->accountancy_code_buy_intra) . "'"; |
|
@@ -918,11 +918,11 @@ discard block |
|
|
block discarded – undo |
918
|
918
|
$sql .= ", '" . $this->db->escape($this->accountancy_code_sell_export) . "'"; |
919
|
919
|
} |
920
|
920
|
$sql .= ", '" . $this->db->escape($this->canvas) . "'"; |
921
|
|
- $sql .= ", " . ((!isset($this->finished) || $this->finished < 0 || $this->finished == '') ? 'NULL' : (int)$this->finished); |
922
|
|
- $sql .= ", " . ((empty($this->status_batch) || $this->status_batch < 0) ? '0' : ((int)$this->status_batch)); |
923
|
|
- $sql .= ", " . ((empty($this->sell_or_eat_by_mandatory) || $this->sell_or_eat_by_mandatory < 0) ? 0 : ((int)$this->sell_or_eat_by_mandatory)); |
|
921
|
+ $sql .= ", " . ((!isset($this->finished) || $this->finished < 0 || $this->finished == '') ? 'NULL' : (int) $this->finished); |
|
922
|
+ $sql .= ", " . ((empty($this->status_batch) || $this->status_batch < 0) ? '0' : ((int) $this->status_batch)); |
|
923
|
+ $sql .= ", " . ((empty($this->sell_or_eat_by_mandatory) || $this->sell_or_eat_by_mandatory < 0) ? 0 : ((int) $this->sell_or_eat_by_mandatory)); |
924
|
924
|
$sql .= ", '" . $this->db->escape($this->batch_mask) . "'"; |
925
|
|
- $sql .= ", " . ($this->fk_unit > 0 ? ((int)$this->fk_unit) : 'NULL'); |
|
925
|
+ $sql .= ", " . ($this->fk_unit > 0 ? ((int) $this->fk_unit) : 'NULL'); |
926
|
926
|
$sql .= ", '" . $this->db->escape($this->mandatory_period) . "'"; |
927
|
927
|
$sql .= ")"; |
928
|
928
|
|
|
@@ -951,7 +951,7 @@ discard block |
|
|
block discarded – undo |
951
|
951
|
|
952
|
952
|
// update accountancy for this entity |
953
|
953
|
if (!$error && getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { |
954
|
|
- $this->db->query("DELETE FROM " . $this->db->prefix() . "product_perentity WHERE fk_product = " . ((int)$this->id) . " AND entity = " . ((int)$conf->entity)); |
|
954
|
+ $this->db->query("DELETE FROM " . $this->db->prefix() . "product_perentity WHERE fk_product = " . ((int) $this->id) . " AND entity = " . ((int) $conf->entity)); |
955
|
955
|
|
956
|
956
|
$sql = "INSERT INTO " . $this->db->prefix() . "product_perentity ("; |
957
|
957
|
$sql .= " fk_product"; |
|
@@ -1161,8 +1161,8 @@ discard block |
|
|
block discarded – undo |
1161
|
1161
|
// Add new price |
1162
|
1162
|
$sql = "INSERT INTO " . $this->db->prefix() . "product_price(price_level,date_price, fk_product, fk_user_author, price_label, price, price_ttc, price_base_type,tosell, tva_tx, default_vat_code, recuperableonly,"; |
1163
|
1163
|
$sql .= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, price_min,price_min_ttc,price_by_qty,entity,fk_price_expression) "; |
1164
|
|
- $sql .= " VALUES(" . ($level ? ((int)$level) : 1) . ", '" . $this->db->idate($now) . "', " . ((int)$this->id) . ", " . ((int)$user->id) . ", " . (empty($this->price_label) ? "null" : "'" . $this->db->escape($this->price_label) . "'") . ", " . ((float)price2num($this->price)) . ", " . ((float)price2num($this->price_ttc)) . ",'" . $this->db->escape($this->price_base_type) . "'," . ((int)$this->status) . ", " . ((float)price2num($this->tva_tx)) . ", " . ($this->default_vat_code ? ("'" . $this->db->escape($this->default_vat_code) . "'") : "null") . ", " . ((int)$this->tva_npr) . ","; |
1165
|
|
- $sql .= " " . price2num($this->localtax1_tx) . ", " . price2num($this->localtax2_tx) . ", '" . $this->db->escape($this->localtax1_type) . "', '" . $this->db->escape($this->localtax2_type) . "', " . price2num($this->price_min) . ", " . price2num($this->price_min_ttc) . ", " . price2num($this->price_by_qty) . ", " . ((int)$conf->entity) . "," . ($this->fk_price_expression > 0 ? ((int)$this->fk_price_expression) : 'null'); |
|
1164
|
+ $sql .= " VALUES(" . ($level ? ((int) $level) : 1) . ", '" . $this->db->idate($now) . "', " . ((int) $this->id) . ", " . ((int) $user->id) . ", " . (empty($this->price_label) ? "null" : "'" . $this->db->escape($this->price_label) . "'") . ", " . ((float) price2num($this->price)) . ", " . ((float) price2num($this->price_ttc)) . ",'" . $this->db->escape($this->price_base_type) . "'," . ((int) $this->status) . ", " . ((float) price2num($this->tva_tx)) . ", " . ($this->default_vat_code ? ("'" . $this->db->escape($this->default_vat_code) . "'") : "null") . ", " . ((int) $this->tva_npr) . ","; |
|
1165
|
+ $sql .= " " . price2num($this->localtax1_tx) . ", " . price2num($this->localtax2_tx) . ", '" . $this->db->escape($this->localtax1_type) . "', '" . $this->db->escape($this->localtax2_type) . "', " . price2num($this->price_min) . ", " . price2num($this->price_min_ttc) . ", " . price2num($this->price_by_qty) . ", " . ((int) $conf->entity) . "," . ($this->fk_price_expression > 0 ? ((int) $this->fk_price_expression) : 'null'); |
1166
|
1166
|
$sql .= ")"; |
1167
|
1167
|
|
1168
|
1168
|
dol_syslog(get_only_class($this) . "::_log_price", LOG_DEBUG); |
|
@@ -1233,11 +1233,11 @@ discard block |
|
|
block discarded – undo |
1233
|
1233
|
|
1234
|
1234
|
// Automated compute surface and volume if not filled |
1235
|
1235
|
if (empty($this->surface) && !empty($this->length) && !empty($this->width) && $this->length_units == $this->width_units) { |
1236
|
|
- $this->surface = (float)$this->length * (float)$this->width; |
|
1236
|
+ $this->surface = (float) $this->length * (float) $this->width; |
1237
|
1237
|
$this->surface_units = measuring_units_squared($this->length_units); |
1238
|
1238
|
} |
1239
|
1239
|
if (empty($this->volume) && !empty($this->surface) && !empty($this->height) && $this->length_units == $this->height_units) { |
1240
|
|
- $this->volume = $this->surface * (float)$this->height; |
|
1240
|
+ $this->volume = $this->surface * (float) $this->height; |
1241
|
1241
|
$this->volume_units = measuring_units_cubed($this->height_units); |
1242
|
1242
|
} |
1243
|
1243
|
|
|
@@ -1318,7 +1318,7 @@ discard block |
|
|
block discarded – undo |
1318
|
1318
|
foreach ($ObjW->detail_batch as $detail) { // Each lines of detail in product_batch of the current $ObjW = product_stock |
1319
|
1319
|
if ($detail->batch == $valueforundefinedlot || $detail->batch == 'Undefined') { |
1320
|
1320
|
// We discard this line, we will create it later |
1321
|
|
- $sqlclean = "DELETE FROM " . $this->db->prefix() . "product_batch WHERE batch in('Undefined', '" . $this->db->escape($valueforundefinedlot) . "') AND fk_product_stock = " . ((int)$ObjW->id); |
|
1321
|
+ $sqlclean = "DELETE FROM " . $this->db->prefix() . "product_batch WHERE batch in('Undefined', '" . $this->db->escape($valueforundefinedlot) . "') AND fk_product_stock = " . ((int) $ObjW->id); |
1322
|
1322
|
$result = $this->db->query($sqlclean); |
1323
|
1323
|
if (!$result) { |
1324
|
1324
|
dol_print_error($this->db); |
|
@@ -1368,30 +1368,30 @@ discard block |
|
|
block discarded – undo |
1368
|
1368
|
$sql .= " SET label = '" . $this->db->escape($this->label) . "'"; |
1369
|
1369
|
|
1370
|
1370
|
if ($updatetype && ($this->isProduct() || $this->isService())) { |
1371
|
|
- $sql .= ", fk_product_type = " . ((int)$this->type); |
|
1371
|
+ $sql .= ", fk_product_type = " . ((int) $this->type); |
1372
|
1372
|
} |
1373
|
1373
|
|
1374
|
1374
|
$sql .= ", ref = '" . $this->db->escape($this->ref) . "'"; |
1375
|
1375
|
$sql .= ", ref_ext = " . (!empty($this->ref_ext) ? "'" . $this->db->escape($this->ref_ext) . "'" : "null"); |
1376
|
1376
|
$sql .= ", default_vat_code = " . ($this->default_vat_code ? "'" . $this->db->escape($this->default_vat_code) . "'" : "null"); |
1377
|
|
- $sql .= ", tva_tx = " . ((float)$this->tva_tx); |
1378
|
|
- $sql .= ", recuperableonly = " . ((int)$this->tva_npr); |
1379
|
|
- $sql .= ", localtax1_tx = " . ((float)$this->localtax1_tx); |
1380
|
|
- $sql .= ", localtax2_tx = " . ((float)$this->localtax2_tx); |
|
1377
|
+ $sql .= ", tva_tx = " . ((float) $this->tva_tx); |
|
1378
|
+ $sql .= ", recuperableonly = " . ((int) $this->tva_npr); |
|
1379
|
+ $sql .= ", localtax1_tx = " . ((float) $this->localtax1_tx); |
|
1380
|
+ $sql .= ", localtax2_tx = " . ((float) $this->localtax2_tx); |
1381
|
1381
|
$sql .= ", localtax1_type = " . ($this->localtax1_type != '' ? "'" . $this->db->escape($this->localtax1_type) . "'" : "'0'"); |
1382
|
1382
|
$sql .= ", localtax2_type = " . ($this->localtax2_type != '' ? "'" . $this->db->escape($this->localtax2_type) . "'" : "'0'"); |
1383
|
1383
|
|
1384
|
1384
|
$sql .= ", barcode = " . (empty($this->barcode) ? "null" : "'" . $this->db->escape($this->barcode) . "'"); |
1385
|
1385
|
$sql .= ", fk_barcode_type = " . (empty($this->barcode_type) ? "null" : $this->db->escape($this->barcode_type)); |
1386
|
1386
|
|
1387
|
|
- $sql .= ", tosell = " . (int)$this->status; |
1388
|
|
- $sql .= ", tobuy = " . (int)$this->status_buy; |
1389
|
|
- $sql .= ", tobatch = " . ((empty($this->status_batch) || $this->status_batch < 0) ? '0' : (int)$this->status_batch); |
1390
|
|
- $sql .= ", sell_or_eat_by_mandatory = " . ((empty($this->sell_or_eat_by_mandatory) || $this->sell_or_eat_by_mandatory < 0) ? 0 : (int)$this->sell_or_eat_by_mandatory); |
|
1387
|
+ $sql .= ", tosell = " . (int) $this->status; |
|
1388
|
+ $sql .= ", tobuy = " . (int) $this->status_buy; |
|
1389
|
+ $sql .= ", tobatch = " . ((empty($this->status_batch) || $this->status_batch < 0) ? '0' : (int) $this->status_batch); |
|
1390
|
+ $sql .= ", sell_or_eat_by_mandatory = " . ((empty($this->sell_or_eat_by_mandatory) || $this->sell_or_eat_by_mandatory < 0) ? 0 : (int) $this->sell_or_eat_by_mandatory); |
1391
|
1391
|
$sql .= ", batch_mask = '" . $this->db->escape($this->batch_mask) . "'"; |
1392
|
1392
|
|
1393
|
|
- $sql .= ", finished = " . ((!isset($this->finished) || $this->finished < 0 || $this->finished == '') ? "null" : (int)$this->finished); |
1394
|
|
- $sql .= ", fk_default_bom = " . ((!isset($this->fk_default_bom) || $this->fk_default_bom < 0 || $this->fk_default_bom == '') ? "null" : (int)$this->fk_default_bom); |
|
1393
|
+ $sql .= ", finished = " . ((!isset($this->finished) || $this->finished < 0 || $this->finished == '') ? "null" : (int) $this->finished); |
|
1394
|
+ $sql .= ", fk_default_bom = " . ((!isset($this->fk_default_bom) || $this->fk_default_bom < 0 || $this->fk_default_bom == '') ? "null" : (int) $this->fk_default_bom); |
1395
|
1395
|
$sql .= ", net_measure = " . ($this->net_measure != '' ? "'" . $this->db->escape($this->net_measure) . "'" : 'null'); |
1396
|
1396
|
$sql .= ", net_measure_units = " . ($this->net_measure_units != '' ? "'" . $this->db->escape($this->net_measure_units) . "'" : 'null'); |
1397
|
1397
|
$sql .= ", weight = " . ($this->weight != '' ? "'" . $this->db->escape($this->weight) . "'" : 'null'); |
|
@@ -1406,16 +1406,16 @@ discard block |
|
|
block discarded – undo |
1406
|
1406
|
$sql .= ", surface_units = " . ($this->surface_units != '' ? "'" . $this->db->escape($this->surface_units) . "'" : 'null'); |
1407
|
1407
|
$sql .= ", volume = " . ($this->volume != '' ? "'" . $this->db->escape($this->volume) . "'" : 'null'); |
1408
|
1408
|
$sql .= ", volume_units = " . ($this->volume_units != '' ? "'" . $this->db->escape($this->volume_units) . "'" : 'null'); |
1409
|
|
- $sql .= ", fk_default_warehouse = " . ($this->fk_default_warehouse > 0 ? ((int)$this->fk_default_warehouse) : 'null'); |
1410
|
|
- $sql .= ", fk_default_workstation = " . ($this->fk_default_workstation > 0 ? ((int)$this->fk_default_workstation) : 'null'); |
1411
|
|
- $sql .= ", seuil_stock_alerte = " . ((isset($this->seuil_stock_alerte) && is_numeric($this->seuil_stock_alerte)) ? (float)$this->seuil_stock_alerte : 'null'); |
|
1409
|
+ $sql .= ", fk_default_warehouse = " . ($this->fk_default_warehouse > 0 ? ((int) $this->fk_default_warehouse) : 'null'); |
|
1410
|
+ $sql .= ", fk_default_workstation = " . ($this->fk_default_workstation > 0 ? ((int) $this->fk_default_workstation) : 'null'); |
|
1411
|
+ $sql .= ", seuil_stock_alerte = " . ((isset($this->seuil_stock_alerte) && is_numeric($this->seuil_stock_alerte)) ? (float) $this->seuil_stock_alerte : 'null'); |
1412
|
1412
|
$sql .= ", description = '" . $this->db->escape($this->description) . "'"; |
1413
|
1413
|
$sql .= ", url = " . ($this->url ? "'" . $this->db->escape($this->url) . "'" : 'null'); |
1414
|
1414
|
$sql .= ", customcode = '" . $this->db->escape($this->customcode) . "'"; |
1415
|
|
- $sql .= ", fk_country = " . ($this->country_id > 0 ? (int)$this->country_id : 'null'); |
1416
|
|
- $sql .= ", fk_state = " . ($this->state_id > 0 ? (int)$this->state_id : 'null'); |
1417
|
|
- $sql .= ", lifetime = " . ($this->lifetime > 0 ? (int)$this->lifetime : 'null'); |
1418
|
|
- $sql .= ", qc_frequency = " . ($this->qc_frequency > 0 ? (int)$this->qc_frequency : 'null'); |
|
1415
|
+ $sql .= ", fk_country = " . ($this->country_id > 0 ? (int) $this->country_id : 'null'); |
|
1416
|
+ $sql .= ", fk_state = " . ($this->state_id > 0 ? (int) $this->state_id : 'null'); |
|
1417
|
+ $sql .= ", lifetime = " . ($this->lifetime > 0 ? (int) $this->lifetime : 'null'); |
|
1418
|
+ $sql .= ", qc_frequency = " . ($this->qc_frequency > 0 ? (int) $this->qc_frequency : 'null'); |
1419
|
1419
|
$sql .= ", note = " . (isset($this->note_private) ? "'" . $this->db->escape($this->note_private) . "'" : 'null'); |
1420
|
1420
|
$sql .= ", note_public = " . (isset($this->note_public) ? "'" . $this->db->escape($this->note_public) . "'" : 'null'); |
1421
|
1421
|
$sql .= ", duration = '" . $this->db->escape($this->duration_value . $this->duration_unit) . "'"; |
|
@@ -1427,15 +1427,15 @@ discard block |
|
|
block discarded – undo |
1427
|
1427
|
$sql .= ", accountancy_code_sell_intra= '" . $this->db->escape($this->accountancy_code_sell_intra) . "'"; |
1428
|
1428
|
$sql .= ", accountancy_code_sell_export= '" . $this->db->escape($this->accountancy_code_sell_export) . "'"; |
1429
|
1429
|
} |
1430
|
|
- $sql .= ", desiredstock = " . ((isset($this->desiredstock) && is_numeric($this->desiredstock)) ? (float)$this->desiredstock : "null"); |
|
1430
|
+ $sql .= ", desiredstock = " . ((isset($this->desiredstock) && is_numeric($this->desiredstock)) ? (float) $this->desiredstock : "null"); |
1431
|
1431
|
$sql .= ", cost_price = " . ($this->cost_price != '' ? $this->db->escape($this->cost_price) : 'null'); |
1432
|
|
- $sql .= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : (int)$this->fk_unit); |
|
1432
|
+ $sql .= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : (int) $this->fk_unit); |
1433
|
1433
|
$sql .= ", price_autogen = " . (!$this->price_autogen ? 0 : 1); |
1434
|
|
- $sql .= ", fk_price_expression = " . ($this->fk_price_expression != 0 ? (int)$this->fk_price_expression : 'NULL'); |
|
1434
|
+ $sql .= ", fk_price_expression = " . ($this->fk_price_expression != 0 ? (int) $this->fk_price_expression : 'NULL'); |
1435
|
1435
|
$sql .= ", fk_user_modif = " . ($user->id > 0 ? $user->id : 'NULL'); |
1436
|
1436
|
$sql .= ", mandatory_period = " . ($this->mandatory_period); |
1437
|
1437
|
// stock field is not here because it is a denormalized value from product_stock. |
1438
|
|
- $sql .= " WHERE rowid = " . ((int)$id); |
|
1438
|
+ $sql .= " WHERE rowid = " . ((int) $id); |
1439
|
1439
|
|
1440
|
1440
|
dol_syslog(get_only_class($this) . "::update", LOG_DEBUG); |
1441
|
1441
|
|
|
@@ -1456,7 +1456,7 @@ discard block |
|
|
block discarded – undo |
1456
|
1456
|
|
1457
|
1457
|
// update accountancy for this entity |
1458
|
1458
|
if (!$error && getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { |
1459
|
|
- $this->db->query("DELETE FROM " . $this->db->prefix() . "product_perentity WHERE fk_product = " . ((int)$this->id) . " AND entity = " . ((int)$conf->entity)); |
|
1459
|
+ $this->db->query("DELETE FROM " . $this->db->prefix() . "product_perentity WHERE fk_product = " . ((int) $this->id) . " AND entity = " . ((int) $conf->entity)); |
1460
|
1460
|
|
1461
|
1461
|
$sql = "INSERT INTO " . $this->db->prefix() . "product_perentity ("; |
1462
|
1462
|
$sql .= " fk_product"; |
|
@@ -1488,7 +1488,7 @@ discard block |
|
|
block discarded – undo |
1488
|
1488
|
// Selection of all product stock movements that contains batchs |
1489
|
1489
|
$sql = 'SELECT pb.qty, ps.fk_entrepot, pb.batch FROM ' . MAIN_DB_PREFIX . 'product_batch as pb'; |
1490
|
1490
|
$sql .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'product_stock as ps ON (ps.rowid = pb.fk_product_stock)'; |
1491
|
|
- $sql .= ' WHERE ps.fk_product = ' . (int)$this->id; |
|
1491
|
+ $sql .= ' WHERE ps.fk_product = ' . (int) $this->id; |
1492
|
1492
|
|
1493
|
1493
|
$resql = $this->db->query($sql); |
1494
|
1494
|
if ($resql) { |
|
@@ -1509,7 +1509,7 @@ discard block |
|
|
block discarded – undo |
1509
|
1509
|
|
1510
|
1510
|
if ($res > 0) { |
1511
|
1511
|
$label = $langs->trans('BatchStockMouvementAddInGlobal'); |
1512
|
|
- $res = $this->correct_stock($user, $fk_entrepot, abs($value), (int)empty($addOremove), $label, $price, $inventorycode, '', null, 0); |
|
1512
|
+ $res = $this->correct_stock($user, $fk_entrepot, abs($value), (int) empty($addOremove), $label, $price, $inventorycode, '', null, 0); |
1513
|
1513
|
if ($res < 0) { |
1514
|
1514
|
$error++; |
1515
|
1515
|
} |
|
@@ -1648,7 +1648,7 @@ discard block |
|
|
block discarded – undo |
1648
|
1648
|
$sql .= ", " . $this->db->prefix() . "entrepot as w"; |
1649
|
1649
|
$sql .= " WHERE w.entity IN (" . getEntity('stock') . ")"; |
1650
|
1650
|
$sql .= " AND w.rowid = ps.fk_entrepot"; |
1651
|
|
- $sql .= " AND ps.fk_product = " . ((int)$this->id); |
|
1651
|
+ $sql .= " AND ps.fk_product = " . ((int) $this->id); |
1652
|
1652
|
if (count($warehouseStatus)) { |
1653
|
1653
|
$sql .= " AND w.statut IN (" . $this->db->sanitize(implode(',', $warehouseStatus)) . ")"; |
1654
|
1654
|
} |
|
@@ -1846,12 +1846,12 @@ discard block |
|
|
block discarded – undo |
1846
|
1846
|
$sql .= " WHERE c.rowid = cd.fk_commande"; |
1847
|
1847
|
$sql .= " AND c.fk_soc = s.rowid"; |
1848
|
1848
|
$sql .= " AND c.entity IN (" . getEntity($forVirtualStock && getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE') ? 'stock' : 'commande') . ")"; |
1849
|
|
- $sql .= " AND cd.fk_product = " . ((int)$this->id); |
|
1849
|
+ $sql .= " AND cd.fk_product = " . ((int) $this->id); |
1850
|
1850
|
if (!$user->hasRight('societe', 'client', 'voir') && !$forVirtualStock) { |
1851
|
|
- $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
1851
|
+ $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
1852
|
1852
|
} |
1853
|
1853
|
if ($socid > 0) { |
1854
|
|
- $sql .= " AND c.fk_soc = " . ((int)$socid); |
|
1854
|
+ $sql .= " AND c.fk_soc = " . ((int) $socid); |
1855
|
1855
|
} |
1856
|
1856
|
if ($filtrestatut != '') { |
1857
|
1857
|
$sql .= " AND c.fk_statut in (" . $this->db->sanitize($filtrestatut) . ")"; |
|
@@ -1896,7 +1896,7 @@ discard block |
|
|
block discarded – undo |
1896
|
1896
|
$sql .= " JOIN " . $this->db->prefix() . "facture as f ON fd.fk_facture = f.rowid"; |
1897
|
1897
|
$sql .= " JOIN " . $this->db->prefix() . "element_element as el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))"; |
1898
|
1898
|
$sql .= " JOIN " . $this->db->prefix() . "commande as c ON el.fk_source = c.rowid"; |
1899
|
|
- $sql .= " WHERE c.fk_statut IN (" . $this->db->sanitize($filtrestatut) . ") AND c.facture = 0 AND fd.fk_product = " . ((int)$this->id); |
|
1899
|
+ $sql .= " WHERE c.fk_statut IN (" . $this->db->sanitize($filtrestatut) . ") AND c.facture = 0 AND fd.fk_product = " . ((int) $this->id); |
1900
|
1900
|
|
1901
|
1901
|
dol_syslog(__METHOD__ . ":: sql $sql", LOG_NOTICE); |
1902
|
1902
|
$resql = $this->db->query($sql); |
|
@@ -1917,7 +1917,7 @@ discard block |
|
|
block discarded – undo |
1917
|
1917
|
$sql .= " JOIN " . MAIN_DB_PREFIX . "facture as f ON fd.fk_facture = f.rowid"; |
1918
|
1918
|
$sql .= " JOIN " . MAIN_DB_PREFIX . "element_element as el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))"; |
1919
|
1919
|
$sql .= " JOIN " . MAIN_DB_PREFIX . "commande as c ON el.fk_source = c.rowid"; |
1920
|
|
- $sql .= " WHERE c.fk_statut IN (" . $this->db->sanitize($filtrestatut) . ") AND f.fk_statut > " . Facture::STATUS_DRAFT . " AND fd.fk_product = " . ((int)$this->id); |
|
1920
|
+ $sql .= " WHERE c.fk_statut IN (" . $this->db->sanitize($filtrestatut) . ") AND f.fk_statut > " . Facture::STATUS_DRAFT . " AND fd.fk_product = " . ((int) $this->id); |
1921
|
1921
|
|
1922
|
1922
|
dol_syslog(__METHOD__ . ":: sql $sql", LOG_NOTICE); |
1923
|
1923
|
$resql = $this->db->query($sql); |
|
@@ -1960,7 +1960,7 @@ discard block |
|
|
block discarded – undo |
1960
|
1960
|
$sql .= " FROM " . $this->db->prefix() . "product_association as pa,"; |
1961
|
1961
|
$sql .= " " . $this->db->prefix() . "product as p"; |
1962
|
1962
|
$sql .= " WHERE p.rowid = pa.fk_product_pere"; |
1963
|
|
- $sql .= " AND pa.fk_product_fils = " . ((int)$this->id); |
|
1963
|
+ $sql .= " AND pa.fk_product_fils = " . ((int) $this->id); |
1964
|
1964
|
|
1965
|
1965
|
$res = $this->db->query($sql); |
1966
|
1966
|
if ($res) { |
|
@@ -2016,12 +2016,12 @@ discard block |
|
|
block discarded – undo |
2016
|
2016
|
$sql .= " AND e.fk_soc = s.rowid"; |
2017
|
2017
|
$sql .= " AND e.entity IN (" . getEntity($forVirtualStock && getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE') ? 'stock' : 'expedition') . ")"; |
2018
|
2018
|
$sql .= " AND ed.fk_elementdet = cd.rowid"; |
2019
|
|
- $sql .= " AND cd.fk_product = " . ((int)$this->id); |
|
2019
|
+ $sql .= " AND cd.fk_product = " . ((int) $this->id); |
2020
|
2020
|
if (!$user->hasRight('societe', 'client', 'voir') && !$forVirtualStock) { |
2021
|
|
- $sql .= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
2021
|
+ $sql .= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
2022
|
2022
|
} |
2023
|
2023
|
if ($socid > 0) { |
2024
|
|
- $sql .= " AND e.fk_soc = " . ((int)$socid); |
|
2024
|
+ $sql .= " AND e.fk_soc = " . ((int) $socid); |
2025
|
2025
|
} |
2026
|
2026
|
if ($filtrestatut != '') { |
2027
|
2027
|
$sql .= " AND c.fk_statut IN (" . $this->db->sanitize($filtrestatut) . ")"; |
|
@@ -2100,12 +2100,12 @@ discard block |
|
|
block discarded – undo |
2100
|
2100
|
$sql .= " WHERE c.rowid = cd.fk_commande"; |
2101
|
2101
|
$sql .= " AND c.fk_soc = s.rowid"; |
2102
|
2102
|
$sql .= " AND c.entity IN (" . getEntity($forVirtualStock && getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE') ? 'stock' : 'supplier_order') . ")"; |
2103
|
|
- $sql .= " AND cd.fk_product = " . ((int)$this->id); |
|
2103
|
+ $sql .= " AND cd.fk_product = " . ((int) $this->id); |
2104
|
2104
|
if (!$user->hasRight('societe', 'client', 'voir') && !$forVirtualStock) { |
2105
|
|
- $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
2105
|
+ $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
2106
|
2106
|
} |
2107
|
2107
|
if ($socid > 0) { |
2108
|
|
- $sql .= " AND c.fk_soc = " . ((int)$socid); |
|
2108
|
+ $sql .= " AND c.fk_soc = " . ((int) $socid); |
2109
|
2109
|
} |
2110
|
2110
|
if ($filtrestatut != '') { |
2111
|
2111
|
$sql .= " AND c.fk_statut in (" . $this->db->sanitize($filtrestatut) . ")"; // Peut valoir 0 |
|
@@ -2160,12 +2160,12 @@ discard block |
|
|
block discarded – undo |
2160
|
2160
|
$sql .= " WHERE cf.rowid = fd.fk_element"; |
2161
|
2161
|
$sql .= " AND cf.fk_soc = s.rowid"; |
2162
|
2162
|
$sql .= " AND cf.entity IN (" . getEntity($forVirtualStock && getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE') ? 'stock' : 'supplier_order') . ")"; |
2163
|
|
- $sql .= " AND fd.fk_product = " . ((int)$this->id); |
|
2163
|
+ $sql .= " AND fd.fk_product = " . ((int) $this->id); |
2164
|
2164
|
if (!$user->hasRight('societe', 'client', 'voir') && !$forVirtualStock) { |
2165
|
|
- $sql .= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
2165
|
+ $sql .= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
2166
|
2166
|
} |
2167
|
2167
|
if ($socid > 0) { |
2168
|
|
- $sql .= " AND cf.fk_soc = " . ((int)$socid); |
|
2168
|
+ $sql .= " AND cf.fk_soc = " . ((int) $socid); |
2169
|
2169
|
} |
2170
|
2170
|
if ($filtrestatut != '') { |
2171
|
2171
|
$sql .= " AND cf.fk_statut IN (" . $this->db->sanitize($filtrestatut) . ")"; |
|
@@ -2224,13 +2224,13 @@ discard block |
|
|
block discarded – undo |
2224
|
2224
|
} |
2225
|
2225
|
$sql .= " WHERE m.rowid = mp.fk_mo"; |
2226
|
2226
|
$sql .= " AND m.entity IN (" . getEntity(($forVirtualStock && getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE')) ? 'stock' : 'mrp') . ")"; |
2227
|
|
- $sql .= " AND mp.fk_product = " . ((int)$this->id); |
|
2227
|
+ $sql .= " AND mp.fk_product = " . ((int) $this->id); |
2228
|
2228
|
$sql .= " AND (mp.disable_stock_change IN (0) OR mp.disable_stock_change IS NULL)"; |
2229
|
2229
|
if (!$user->hasRight('societe', 'client', 'voir') && !$forVirtualStock) { |
2230
|
|
- $sql .= " AND m.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
2230
|
+ $sql .= " AND m.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
2231
|
2231
|
} |
2232
|
2232
|
if ($socid > 0) { |
2233
|
|
- $sql .= " AND m.fk_soc = " . ((int)$socid); |
|
2233
|
+ $sql .= " AND m.fk_soc = " . ((int) $socid); |
2234
|
2234
|
} |
2235
|
2235
|
if ($filtrestatut != '') { |
2236
|
2236
|
$sql .= " AND m.status IN (" . $this->db->sanitize($filtrestatut) . ")"; |
|
@@ -2239,10 +2239,10 @@ discard block |
|
|
block discarded – undo |
2239
|
2239
|
$sql .= " AND m.date_valid <= '" . $this->db->idate($dateofvirtualstock) . "'"; // better date to code ? end of production ? |
2240
|
2240
|
} |
2241
|
2241
|
if (!$serviceStockIsEnabled) { |
2242
|
|
- $sql .= "AND EXISTS (SELECT p.rowid FROM " . $this->db->prefix() . "product AS p WHERE p.rowid = " . ((int)$this->id) . " AND p.fk_product_type IN (0))"; |
|
2242
|
+ $sql .= "AND EXISTS (SELECT p.rowid FROM " . $this->db->prefix() . "product AS p WHERE p.rowid = " . ((int) $this->id) . " AND p.fk_product_type IN (0))"; |
2243
|
2243
|
} |
2244
|
2244
|
if (!empty($warehouseid)) { |
2245
|
|
- $sql .= " AND m.fk_warehouse = " . ((int)$warehouseid); |
|
2245
|
+ $sql .= " AND m.fk_warehouse = " . ((int) $warehouseid); |
2246
|
2246
|
} |
2247
|
2247
|
$sql .= " GROUP BY role"; |
2248
|
2248
|
|
|
@@ -2363,12 +2363,12 @@ discard block |
|
|
block discarded – undo |
2363
|
2363
|
|
2364
|
2364
|
//For MultiCompany |
2365
|
2365
|
//PMP per entity & Stocks Sharings stock_reel includes only stocks shared with this entity |
2366
|
|
- $separatedEntityPMP = false; // Set to true to get the AWP from table llx_product_perentity instead of field 'pmp' into llx_product. |
2367
|
|
- $separatedStock = false; // Set to true will count stock from subtable llx_product_stock. It is slower than using denormalized field 'stock', but it is required when using multientity and shared warehouses. |
|
2366
|
+ $separatedEntityPMP = false; // Set to true to get the AWP from table llx_product_perentity instead of field 'pmp' into llx_product. |
|
2367
|
+ $separatedStock = false; // Set to true will count stock from subtable llx_product_stock. It is slower than using denormalized field 'stock', but it is required when using multientity and shared warehouses. |
2368
|
2368
|
$visibleWarehousesEntities = $conf->entity; |
2369
|
2369
|
if (getDolGlobalString('MULTICOMPANY_PRODUCT_SHARING_ENABLED')) { |
2370
|
2370
|
if (getDolGlobalString('MULTICOMPANY_PMP_PER_ENTITY_ENABLED')) { |
2371
|
|
- $checkPMPPerEntity = $this->db->query("SELECT pmp FROM " . $this->db->prefix() . "product_perentity WHERE fk_product = " . ((int)$id) . " AND entity = " . (int)$conf->entity); |
|
2371
|
+ $checkPMPPerEntity = $this->db->query("SELECT pmp FROM " . $this->db->prefix() . "product_perentity WHERE fk_product = " . ((int) $id) . " AND entity = " . (int) $conf->entity); |
2372
|
2372
|
if ($this->db->num_rows($checkPMPPerEntity) > 0) { |
2373
|
2373
|
$separatedEntityPMP = true; |
2374
|
2374
|
} |
|
@@ -2394,14 +2394,14 @@ discard block |
|
|
block discarded – undo |
2394
|
2394
|
} |
2395
|
2395
|
$sql .= " FROM " . $this->db->prefix() . "product as p"; |
2396
|
2396
|
if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED') || $separatedEntityPMP) { |
2397
|
|
- $sql .= " LEFT JOIN " . $this->db->prefix() . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int)$conf->entity); |
|
2397
|
+ $sql .= " LEFT JOIN " . $this->db->prefix() . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); |
2398
|
2398
|
} |
2399
|
2399
|
if ($separatedStock) { |
2400
|
2400
|
$sql .= " LEFT JOIN " . $this->db->prefix() . "product_stock as sp ON sp.fk_product = p.rowid AND sp.fk_entrepot IN (SELECT rowid FROM " . $this->db->prefix() . "entrepot WHERE entity IN (" . $this->db->sanitize($visibleWarehousesEntities) . "))"; |
2401
|
2401
|
} |
2402
|
2402
|
|
2403
|
2403
|
if ($id) { |
2404
|
|
- $sql .= " WHERE p.rowid = " . ((int)$id); |
|
2404
|
+ $sql .= " WHERE p.rowid = " . ((int) $id); |
2405
|
2405
|
} else { |
2406
|
2406
|
$sql .= " WHERE p.entity IN (" . getEntity($this->element) . ")"; |
2407
|
2407
|
if ($ref) { |
|
@@ -2555,10 +2555,10 @@ discard block |
|
|
block discarded – undo |
2555
|
2555
|
$sql .= " ,price_label"; |
2556
|
2556
|
$sql .= " FROM " . $this->db->prefix() . "product_price"; |
2557
|
2557
|
$sql .= " WHERE entity IN (" . getEntity('productprice') . ")"; |
2558
|
|
- $sql .= " AND price_level=" . ((int)$i); |
2559
|
|
- $sql .= " AND fk_product = " . ((int)$this->id); |
2560
|
|
- $sql .= " ORDER BY date_price DESC, rowid DESC"; // Get the most recent line |
2561
|
|
- $sql .= " LIMIT 1"; // Only the first one |
|
2558
|
+ $sql .= " AND price_level=" . ((int) $i); |
|
2559
|
+ $sql .= " AND fk_product = " . ((int) $this->id); |
|
2560
|
+ $sql .= " ORDER BY date_price DESC, rowid DESC"; // Get the most recent line |
|
2561
|
+ $sql .= " LIMIT 1"; // Only the first one |
2562
|
2562
|
$resql = $this->db->query($sql); |
2563
|
2563
|
if ($resql) { |
2564
|
2564
|
$result = $this->db->fetch_array($resql); |
|
@@ -2619,7 +2619,7 @@ discard block |
|
|
block discarded – undo |
2619
|
2619
|
$sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; |
2620
|
2620
|
$sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid"; |
2621
|
2621
|
$sql .= " FROM " . $this->db->prefix() . "product_price"; |
2622
|
|
- $sql .= " WHERE fk_product = " . ((int)$this->id); |
|
2622
|
+ $sql .= " WHERE fk_product = " . ((int) $this->id); |
2623
|
2623
|
$sql .= " ORDER BY date_price DESC, rowid DESC"; |
2624
|
2624
|
$sql .= " LIMIT 1"; |
2625
|
2625
|
|
|
@@ -2635,7 +2635,7 @@ discard block |
|
|
block discarded – undo |
2635
|
2635
|
if ($this->prices_by_qty[0] == 1) { |
2636
|
2636
|
$sql = "SELECT rowid,price, unitprice, quantity, remise_percent, remise, remise, price_base_type"; |
2637
|
2637
|
$sql .= " FROM " . $this->db->prefix() . "product_price_by_qty"; |
2638
|
|
- $sql .= " WHERE fk_product_price = " . ((int)$this->prices_by_qty_id[0]); |
|
2638
|
+ $sql .= " WHERE fk_product_price = " . ((int) $this->prices_by_qty_id[0]); |
2639
|
2639
|
$sql .= " ORDER BY quantity ASC"; |
2640
|
2640
|
|
2641
|
2641
|
$resql = $this->db->query($sql); |
|
@@ -2671,8 +2671,8 @@ discard block |
|
|
block discarded – undo |
2671
|
2671
|
$sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly"; |
2672
|
2672
|
$sql .= " FROM " . $this->db->prefix() . "product_price"; |
2673
|
2673
|
$sql .= " WHERE entity IN (" . getEntity('productprice') . ")"; |
2674
|
|
- $sql .= " AND price_level=" . ((int)$i); |
2675
|
|
- $sql .= " AND fk_product = " . ((int)$this->id); |
|
2674
|
+ $sql .= " AND price_level=" . ((int) $i); |
|
2675
|
+ $sql .= " AND fk_product = " . ((int) $this->id); |
2676
|
2676
|
$sql .= " ORDER BY date_price DESC, rowid DESC"; |
2677
|
2677
|
$sql .= " LIMIT 1"; |
2678
|
2678
|
$resql = $this->db->query($sql); |
|
@@ -2696,7 +2696,7 @@ discard block |
|
|
block discarded – undo |
2696
|
2696
|
if ($this->prices_by_qty[$i] == 1) { |
2697
|
2697
|
$sql = "SELECT rowid, price, unitprice, quantity, remise_percent, remise, price_base_type"; |
2698
|
2698
|
$sql .= " FROM " . $this->db->prefix() . "product_price_by_qty"; |
2699
|
|
- $sql .= " WHERE fk_product_price = " . ((int)$this->prices_by_qty_id[$i]); |
|
2699
|
+ $sql .= " WHERE fk_product_price = " . ((int) $this->prices_by_qty_id[$i]); |
2700
|
2700
|
$sql .= " ORDER BY quantity ASC"; |
2701
|
2701
|
|
2702
|
2702
|
$resql = $this->db->query($sql); |
|
@@ -2731,8 +2731,8 @@ discard block |
|
|
block discarded – undo |
2731
|
2731
|
if ($price_result >= 0) { |
2732
|
2732
|
$this->price = $price_result; |
2733
|
2733
|
// Calculate the VAT |
2734
|
|
- $this->price_ttc = (float)price2num($this->price) * (1 + ($this->tva_tx / 100)); |
2735
|
|
- $this->price_ttc = (float)price2num($this->price_ttc, 'MU'); |
|
2734
|
+ $this->price_ttc = (float) price2num($this->price) * (1 + ($this->tva_tx / 100)); |
|
2735
|
+ $this->price_ttc = (float) price2num($this->price_ttc, 'MU'); |
2736
|
2736
|
} |
2737
|
2737
|
} |
2738
|
2738
|
|
|
@@ -2763,7 +2763,7 @@ discard block |
|
|
block discarded – undo |
2763
|
2763
|
|
2764
|
2764
|
$sql = "SELECT lang, label, description, note as other"; |
2765
|
2765
|
$sql .= " FROM " . $this->db->prefix() . "product_lang"; |
2766
|
|
- $sql .= " WHERE fk_product = " . ((int)$this->id); |
|
2766
|
+ $sql .= " WHERE fk_product = " . ((int) $this->id); |
2767
|
2767
|
|
2768
|
2768
|
$result = $this->db->query($sql); |
2769
|
2769
|
if ($result) { |
|
@@ -2774,9 +2774,9 @@ discard block |
|
|
block discarded – undo |
2774
|
2774
|
$this->description = $obj->description; |
2775
|
2775
|
$this->other = $obj->other; |
2776
|
2776
|
} |
2777
|
|
- $this->multilangs[(string)$obj->lang]["label"] = $obj->label; |
2778
|
|
- $this->multilangs[(string)$obj->lang]["description"] = $obj->description; |
2779
|
|
- $this->multilangs[(string)$obj->lang]["other"] = $obj->other; |
|
2777
|
+ $this->multilangs[(string) $obj->lang]["label"] = $obj->label; |
|
2778
|
+ $this->multilangs[(string) $obj->lang]["description"] = $obj->description; |
|
2779
|
+ $this->multilangs[(string) $obj->lang]["other"] = $obj->other; |
2780
|
2780
|
} |
2781
|
2781
|
return 1; |
2782
|
2782
|
} else { |
|
@@ -2802,7 +2802,7 @@ discard block |
|
|
block discarded – undo |
2802
|
2802
|
if ($key == $current_lang) { |
2803
|
2803
|
$sql = "SELECT rowid"; |
2804
|
2804
|
$sql .= " FROM " . $this->db->prefix() . "product_lang"; |
2805
|
|
- $sql .= " WHERE fk_product = " . ((int)$this->id); |
|
2805
|
+ $sql .= " WHERE fk_product = " . ((int) $this->id); |
2806
|
2806
|
$sql .= " AND lang = '" . $this->db->escape($key) . "'"; |
2807
|
2807
|
|
2808
|
2808
|
$result = $this->db->query($sql); |
|
@@ -2815,14 +2815,14 @@ discard block |
|
|
block discarded – undo |
2815
|
2815
|
if (getDolGlobalString('PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION')) { |
2816
|
2816
|
$sql2 .= ", note='" . $this->db->escape($this->other) . "'"; |
2817
|
2817
|
} |
2818
|
|
- $sql2 .= " WHERE fk_product = " . ((int)$this->id) . " AND lang = '" . $this->db->escape($key) . "'"; |
|
2818
|
+ $sql2 .= " WHERE fk_product = " . ((int) $this->id) . " AND lang = '" . $this->db->escape($key) . "'"; |
2819
|
2819
|
} else { |
2820
|
2820
|
$sql2 = "INSERT INTO " . $this->db->prefix() . "product_lang (fk_product, lang, label, description"; |
2821
|
2821
|
if (getDolGlobalString('PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION')) { |
2822
|
2822
|
$sql2 .= ", note"; |
2823
|
2823
|
} |
2824
|
2824
|
$sql2 .= ")"; |
2825
|
|
- $sql2 .= " VALUES(" . ((int)$this->id) . ",'" . $this->db->escape($key) . "','" . $this->db->escape($this->label) . "',"; |
|
2825
|
+ $sql2 .= " VALUES(" . ((int) $this->id) . ",'" . $this->db->escape($key) . "','" . $this->db->escape($this->label) . "',"; |
2826
|
2826
|
$sql2 .= " '" . $this->db->escape($this->description) . "'"; |
2827
|
2827
|
if (getDolGlobalString('PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION')) { |
2828
|
2828
|
$sql2 .= ", '" . $this->db->escape($this->other) . "'"; |
|
@@ -2842,7 +2842,7 @@ discard block |
|
|
block discarded – undo |
2842
|
2842
|
|
2843
|
2843
|
$sql = "SELECT rowid"; |
2844
|
2844
|
$sql .= " FROM " . $this->db->prefix() . "product_lang"; |
2845
|
|
- $sql .= " WHERE fk_product = " . ((int)$this->id); |
|
2845
|
+ $sql .= " WHERE fk_product = " . ((int) $this->id); |
2846
|
2846
|
$sql .= " AND lang = '" . $this->db->escape($key) . "'"; |
2847
|
2847
|
|
2848
|
2848
|
$result = $this->db->query($sql); |
|
@@ -2855,14 +2855,14 @@ discard block |
|
|
block discarded – undo |
2855
|
2855
|
if (getDolGlobalString('PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION')) { |
2856
|
2856
|
$sql2 .= ", note = '" . $this->db->escape($this->multilangs["$key"]["other"]) . "'"; |
2857
|
2857
|
} |
2858
|
|
- $sql2 .= " WHERE fk_product = " . ((int)$this->id) . " AND lang = '" . $this->db->escape($key) . "'"; |
|
2858
|
+ $sql2 .= " WHERE fk_product = " . ((int) $this->id) . " AND lang = '" . $this->db->escape($key) . "'"; |
2859
|
2859
|
} else { |
2860
|
2860
|
$sql2 = "INSERT INTO " . $this->db->prefix() . "product_lang (fk_product, lang, label, description"; |
2861
|
2861
|
if (getDolGlobalString('PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION')) { |
2862
|
2862
|
$sql2 .= ", note"; |
2863
|
2863
|
} |
2864
|
2864
|
$sql2 .= ")"; |
2865
|
|
- $sql2 .= " VALUES(" . ((int)$this->id) . ",'" . $this->db->escape($key) . "','" . $this->db->escape($this->multilangs["$key"]["label"]) . "',"; |
|
2865
|
+ $sql2 .= " VALUES(" . ((int) $this->id) . ",'" . $this->db->escape($key) . "','" . $this->db->escape($this->multilangs["$key"]["label"]) . "',"; |
2866
|
2866
|
$sql2 .= " '" . $this->db->escape($this->multilangs["$key"]["description"]) . "'"; |
2867
|
2867
|
if (getDolGlobalString('PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION')) { |
2868
|
2868
|
$sql2 .= ", '" . $this->db->escape($this->multilangs["$key"]["other"]) . "'"; |
|
@@ -2955,8 +2955,8 @@ discard block |
|
|
block discarded – undo |
2955
|
2955
|
} |
2956
|
2956
|
|
2957
|
2957
|
$op = array(); |
2958
|
|
- $op[0] = "+" . trim((string)$nbpiece); |
2959
|
|
- $op[1] = "-" . trim((string)$nbpiece); |
|
2958
|
+ $op[0] = "+" . trim((string) $nbpiece); |
|
2959
|
+ $op[1] = "-" . trim((string) $nbpiece); |
2960
|
2960
|
|
2961
|
2961
|
$movementstock = new MouvementStock($this->db); |
2962
|
2962
|
$movementstock->setOrigin($origin_element, $origin_id); // Set ->origin_type and ->fk_origin |
|
@@ -3015,8 +3015,8 @@ discard block |
|
|
block discarded – undo |
3015
|
3015
|
$nbpiece = abs($nbpiece); |
3016
|
3016
|
} |
3017
|
3017
|
$op = array(); |
3018
|
|
- $op[0] = "+" . trim((string)$nbpiece); |
3019
|
|
- $op[1] = "-" . trim((string)$nbpiece); |
|
3018
|
+ $op[0] = "+" . trim((string) $nbpiece); |
|
3019
|
+ $op[1] = "-" . trim((string) $nbpiece); |
3020
|
3020
|
|
3021
|
3021
|
$movementstock = new MouvementStock($this->db); |
3022
|
3022
|
$movementstock->setOrigin($origin_element, $origin_id); // Set ->origin_type and ->origin_id |
|
@@ -3087,7 +3087,7 @@ discard block |
|
|
block discarded – undo |
3087
|
3087
|
$sql = "DELETE FROM " . $this->db->prefix() . 'product_batch'; |
3088
|
3088
|
$sql .= " WHERE fk_product_stock IN ("; |
3089
|
3089
|
$sql .= "SELECT rowid FROM " . $this->db->prefix() . 'product_stock'; |
3090
|
|
- $sql .= " WHERE fk_product = " . ((int)$this->id) . ")"; |
|
3090
|
+ $sql .= " WHERE fk_product = " . ((int) $this->id) . ")"; |
3091
|
3091
|
|
3092
|
3092
|
$result = $this->db->query($sql); |
3093
|
3093
|
if (!$result) { |
|
@@ -3102,7 +3102,7 @@ discard block |
|
|
block discarded – undo |
3102
|
3102
|
foreach ($elements as $table) { |
3103
|
3103
|
if (!$error) { |
3104
|
3104
|
$sql = "DELETE FROM " . $this->db->prefix() . $table; |
3105
|
|
- $sql .= " WHERE fk_product = " . (int)$this->id; |
|
3105
|
+ $sql .= " WHERE fk_product = " . (int) $this->id; |
3106
|
3106
|
|
3107
|
3107
|
$result = $this->db->query($sql); |
3108
|
3108
|
if (!$result) { |
|
@@ -3132,7 +3132,7 @@ discard block |
|
|
block discarded – undo |
3132
|
3132
|
// Delete from product_association |
3133
|
3133
|
if (!$error) { |
3134
|
3134
|
$sql = "DELETE FROM " . $this->db->prefix() . "product_association"; |
3135
|
|
- $sql .= " WHERE fk_product_pere = " . (int)$this->id . " OR fk_product_fils = " . (int)$this->id; |
|
3135
|
+ $sql .= " WHERE fk_product_pere = " . (int) $this->id . " OR fk_product_fils = " . (int) $this->id; |
3136
|
3136
|
|
3137
|
3137
|
$result = $this->db->query($sql); |
3138
|
3138
|
if (!$result) { |
|
@@ -3153,7 +3153,7 @@ discard block |
|
|
block discarded – undo |
3153
|
3153
|
// Delete product |
3154
|
3154
|
if (!$error) { |
3155
|
3155
|
$sqlz = "DELETE FROM " . $this->db->prefix() . "product"; |
3156
|
|
- $sqlz .= " WHERE rowid = " . (int)$this->id; |
|
3156
|
+ $sqlz .= " WHERE rowid = " . (int) $this->id; |
3157
|
3157
|
|
3158
|
3158
|
$resultz = $this->db->query($sqlz); |
3159
|
3159
|
if (!$resultz) { |
|
@@ -3256,7 +3256,7 @@ discard block |
|
|
block discarded – undo |
3256
|
3256
|
public function delMultiLangs($langtodelete, $user) |
3257
|
3257
|
{ |
3258
|
3258
|
$sql = "DELETE FROM " . $this->db->prefix() . "product_lang"; |
3259
|
|
- $sql .= " WHERE fk_product = " . ((int)$this->id) . " AND lang = '" . $this->db->escape($langtodelete) . "'"; |
|
3259
|
+ $sql .= " WHERE fk_product = " . ((int) $this->id) . " AND lang = '" . $this->db->escape($langtodelete) . "'"; |
3260
|
3260
|
|
3261
|
3261
|
dol_syslog(get_only_class($this) . '::delMultiLangs', LOG_DEBUG); |
3262
|
3262
|
$result = $this->db->query($sql); |
|
@@ -3313,7 +3313,7 @@ discard block |
|
|
block discarded – undo |
3313
|
3313
|
|
3314
|
3314
|
$sql = "UPDATE " . $this->db->prefix() . $this->table_element . " SET "; |
3315
|
3315
|
$sql .= "$field = '" . $this->db->escape($value) . "'"; |
3316
|
|
- $sql .= " WHERE rowid = " . ((int)$this->id); |
|
3316
|
+ $sql .= " WHERE rowid = " . ((int) $this->id); |
3317
|
3317
|
|
3318
|
3318
|
dol_syslog(__METHOD__, LOG_DEBUG); |
3319
|
3319
|
$resql = $this->db->query($sql); |
|
@@ -3355,11 +3355,11 @@ discard block |
|
|
block discarded – undo |
3355
|
3355
|
{ |
3356
|
3356
|
// phpcs:enable |
3357
|
3357
|
$sql = "DELETE FROM " . $this->db->prefix() . "product_price_by_qty"; |
3358
|
|
- $sql .= " WHERE fk_product_price = " . ((int)$rowid); |
|
3358
|
+ $sql .= " WHERE fk_product_price = " . ((int) $rowid); |
3359
|
3359
|
$resql = $this->db->query($sql); |
3360
|
3360
|
|
3361
|
3361
|
$sql = "DELETE FROM " . $this->db->prefix() . "product_price"; |
3362
|
|
- $sql .= " WHERE rowid=" . ((int)$rowid); |
|
3362
|
+ $sql .= " WHERE rowid=" . ((int) $rowid); |
3363
|
3363
|
$resql = $this->db->query($sql); |
3364
|
3364
|
if ($resql) { |
3365
|
3365
|
return 1; |
|
@@ -3534,9 +3534,9 @@ discard block |
|
|
block discarded – undo |
3534
|
3534
|
$sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; |
3535
|
3535
|
$sql .= " pfp.packaging"; |
3536
|
3536
|
$sql .= " FROM " . $this->db->prefix() . "product_fournisseur_price as pfp"; |
3537
|
|
- $sql .= " WHERE pfp.rowid = " . ((int)$prodfournprice); |
|
3537
|
+ $sql .= " WHERE pfp.rowid = " . ((int) $prodfournprice); |
3538
|
3538
|
if ($qty > 0) { |
3539
|
|
- $sql .= " AND pfp.quantity <= " . ((float)$qty); |
|
3539
|
+ $sql .= " AND pfp.quantity <= " . ((float) $qty); |
3540
|
3540
|
} |
3541
|
3541
|
$sql .= " ORDER BY pfp.quantity DESC"; |
3542
|
3542
|
|
|
@@ -3590,16 +3590,16 @@ discard block |
|
|
block discarded – undo |
3590
|
3590
|
$sql .= " FROM " . $this->db->prefix() . "product_fournisseur_price as pfp"; |
3591
|
3591
|
$sql .= " WHERE 1 = 1"; |
3592
|
3592
|
if ($product_id > 0) { |
3593
|
|
- $sql .= " AND pfp.fk_product = " . ((int)$product_id); |
|
3593
|
+ $sql .= " AND pfp.fk_product = " . ((int) $product_id); |
3594
|
3594
|
} |
3595
|
3595
|
if ($fourn_ref != 'none') { |
3596
|
3596
|
$sql .= " AND pfp.ref_fourn = '" . $this->db->escape($fourn_ref) . "'"; |
3597
|
3597
|
} |
3598
|
3598
|
if ($fk_soc > 0) { |
3599
|
|
- $sql .= " AND pfp.fk_soc = " . ((int)$fk_soc); |
|
3599
|
+ $sql .= " AND pfp.fk_soc = " . ((int) $fk_soc); |
3600
|
3600
|
} |
3601
|
3601
|
if ($qty > 0) { |
3602
|
|
- $sql .= " AND pfp.quantity <= " . ((float)$qty); |
|
3602
|
+ $sql .= " AND pfp.quantity <= " . ((float) $qty); |
3603
|
3603
|
} |
3604
|
3604
|
$sql .= " ORDER BY pfp.quantity DESC"; |
3605
|
3605
|
$sql .= " LIMIT 1"; |
|
@@ -3720,25 +3720,25 @@ discard block |
|
|
block discarded – undo |
3720
|
3720
|
if ($newprice !== '' || $newprice === 0) { |
3721
|
3721
|
if ($newpricebase == 'TTC') { |
3722
|
3722
|
$price_ttc = price2num($newprice, 'MU'); |
3723
|
|
- $price = (float)price2num($newprice) / (1 + ((float)$newvat / 100)); |
|
3723
|
+ $price = (float) price2num($newprice) / (1 + ((float) $newvat / 100)); |
3724
|
3724
|
$price = price2num($price, 'MU'); |
3725
|
3725
|
|
3726
|
3726
|
if ($newminprice != '' || $newminprice == 0) { |
3727
|
3727
|
$price_min_ttc = price2num($newminprice, 'MU'); |
3728
|
|
- $price_min = (float)price2num($newminprice) / (1 + ($newvat / 100)); |
|
3728
|
+ $price_min = (float) price2num($newminprice) / (1 + ($newvat / 100)); |
3729
|
3729
|
$price_min = price2num($price_min, 'MU'); |
3730
|
3730
|
} else { |
3731
|
3731
|
$price_min = 0; |
3732
|
3732
|
$price_min_ttc = 0; |
3733
|
3733
|
} |
3734
|
3734
|
} else { |
3735
|
|
- $price = (float)price2num($newprice, 'MU'); |
|
3735
|
+ $price = (float) price2num($newprice, 'MU'); |
3736
|
3736
|
$price_ttc = ($newnpr != 1) ? price2num($newprice) * (1 + ($newvat / 100)) : $price; |
3737
|
|
- $price_ttc = (float)price2num($price_ttc, 'MU'); |
|
3737
|
+ $price_ttc = (float) price2num($price_ttc, 'MU'); |
3738
|
3738
|
|
3739
|
3739
|
if ($newminprice !== '' || $newminprice === 0) { |
3740
|
3740
|
$price_min = price2num($newminprice, 'MU'); |
3741
|
|
- $price_min_ttc = (float)price2num($newminprice) * (1 + ($newvat / 100)); |
|
3741
|
+ $price_min_ttc = (float) price2num($newminprice) * (1 + ($newvat / 100)); |
3742
|
3742
|
$price_min_ttc = price2num($price_min_ttc, 'MU'); |
3743
|
3743
|
//print 'X'.$newminprice.'-'.$price_min; |
3744
|
3744
|
} else { |
|
@@ -3761,7 +3761,7 @@ discard block |
|
|
block discarded – undo |
3761
|
3761
|
$sql = "SELECT t.rowid, t.code, t.recuperableonly as tva_npr, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; |
3762
|
3762
|
$sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c"; |
3763
|
3763
|
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $this->db->escape($mysoc->country_code) . "'"; |
3764
|
|
- $sql .= " AND t.taux = " . ((float)$newdefaultvatcode) . " AND t.active = 1"; |
|
3764
|
+ $sql .= " AND t.taux = " . ((float) $newdefaultvatcode) . " AND t.active = 1"; |
3765
|
3765
|
$sql .= " AND t.code = '" . $this->db->escape($newdefaultvatcode) . "'"; |
3766
|
3766
|
$resql = $this->db->query($sql); |
3767
|
3767
|
if ($resql) { |
|
@@ -3795,19 +3795,19 @@ discard block |
|
|
block discarded – undo |
3795
|
3795
|
// Ceci provoque des stockages avec arrondis en base au lieu des valeurs exactes. |
3796
|
3796
|
$sql = "UPDATE " . $this->db->prefix() . "product SET"; |
3797
|
3797
|
$sql .= " price_base_type = '" . $this->db->escape($newpricebase) . "',"; |
3798
|
|
- $sql .= " price = " . (float)$price . ","; |
3799
|
|
- $sql .= " price_ttc = " . (float)$price_ttc . ","; |
3800
|
|
- $sql .= " price_min = " . (float)$price_min . ","; |
3801
|
|
- $sql .= " price_min_ttc = " . (float)$price_min_ttc . ","; |
3802
|
|
- $sql .= " localtax1_tx = " . ($localtax1 >= 0 ? (float)$localtax1 : 'NULL') . ","; |
3803
|
|
- $sql .= " localtax2_tx = " . ($localtax2 >= 0 ? (float)$localtax2 : 'NULL') . ","; |
|
3798
|
+ $sql .= " price = " . (float) $price . ","; |
|
3799
|
+ $sql .= " price_ttc = " . (float) $price_ttc . ","; |
|
3800
|
+ $sql .= " price_min = " . (float) $price_min . ","; |
|
3801
|
+ $sql .= " price_min_ttc = " . (float) $price_min_ttc . ","; |
|
3802
|
+ $sql .= " localtax1_tx = " . ($localtax1 >= 0 ? (float) $localtax1 : 'NULL') . ","; |
|
3803
|
+ $sql .= " localtax2_tx = " . ($localtax2 >= 0 ? (float) $localtax2 : 'NULL') . ","; |
3804
|
3804
|
$sql .= " localtax1_type = " . ($localtaxtype1 != '' ? "'" . $this->db->escape($localtaxtype1) . "'" : "'0'") . ","; |
3805
|
3805
|
$sql .= " localtax2_type = " . ($localtaxtype2 != '' ? "'" . $this->db->escape($localtaxtype2) . "'" : "'0'") . ","; |
3806
|
3806
|
$sql .= " default_vat_code = " . ($newdefaultvatcode ? "'" . $this->db->escape($newdefaultvatcode) . "'" : "null") . ","; |
3807
|
3807
|
$sql .= " price_label = " . (!empty($price_label) ? "'" . $this->db->escape($price_label) . "'" : "null") . ","; |
3808
|
|
- $sql .= " tva_tx = " . (float)price2num($newvat) . ","; |
|
3808
|
+ $sql .= " tva_tx = " . (float) price2num($newvat) . ","; |
3809
|
3809
|
$sql .= " recuperableonly = '" . $this->db->escape($newnpr) . "'"; |
3810
|
|
- $sql .= " WHERE rowid = " . ((int)$id); |
|
3810
|
+ $sql .= " WHERE rowid = " . ((int) $id); |
3811
|
3811
|
|
3812
|
3812
|
dol_syslog(get_only_class($this) . "::update_price", LOG_DEBUG); |
3813
|
3813
|
$resql = $this->db->query($sql); |
|
@@ -3893,13 +3893,13 @@ discard block |
|
|
block discarded – undo |
3893
|
3893
|
|
3894
|
3894
|
$lastPrice = array( |
3895
|
3895
|
'level' => $level ? $level : 1, |
3896
|
|
- 'multiprices' => (float)$this->multiprices[$level], |
3897
|
|
- 'multiprices_ttc' => (float)$this->multiprices_ttc[$level], |
|
3896
|
+ 'multiprices' => (float) $this->multiprices[$level], |
|
3897
|
+ 'multiprices_ttc' => (float) $this->multiprices_ttc[$level], |
3898
|
3898
|
'multiprices_base_type' => $this->multiprices_base_type[$level], |
3899
|
|
- 'multiprices_min' => (float)$this->multiprices_min[$level], |
3900
|
|
- 'multiprices_min_ttc' => (float)$this->multiprices_min_ttc[$level], |
3901
|
|
- 'multiprices_tva_tx' => (float)$this->multiprices_tva_tx[$level], |
3902
|
|
- 'multiprices_recuperableonly' => (float)$this->multiprices_recuperableonly[$level], |
|
3899
|
+ 'multiprices_min' => (float) $this->multiprices_min[$level], |
|
3900
|
+ 'multiprices_min_ttc' => (float) $this->multiprices_min_ttc[$level], |
|
3901
|
+ 'multiprices_tva_tx' => (float) $this->multiprices_tva_tx[$level], |
|
3902
|
+ 'multiprices_recuperableonly' => (float) $this->multiprices_recuperableonly[$level], |
3903
|
3903
|
); |
3904
|
3904
|
|
3905
|
3905
|
return $lastPrice; |
|
@@ -4015,15 +4015,15 @@ discard block |
|
|
block discarded – undo |
4015
|
4015
|
$sql .= " FROM " . $this->db->prefix() . "mrp_mo as c"; |
4016
|
4016
|
$sql .= " INNER JOIN " . $this->db->prefix() . "mrp_production as mp ON mp.fk_mo=c.rowid"; |
4017
|
4017
|
if (!$user->hasRight('societe', 'client', 'voir')) { |
4018
|
|
- $sql .= " INNER JOIN " . $this->db->prefix() . "societe_commerciaux as sc ON sc.fk_soc=c.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
4018
|
+ $sql .= " INNER JOIN " . $this->db->prefix() . "societe_commerciaux as sc ON sc.fk_soc=c.fk_soc AND sc.fk_user = " . ((int) $user->id); |
4019
|
4019
|
} |
4020
|
4020
|
$sql .= " WHERE "; |
4021
|
4021
|
$sql .= " c.entity IN (" . getEntity('mo') . ")"; |
4022
|
4022
|
|
4023
|
|
- $sql .= " AND mp.fk_product = " . ((int)$this->id); |
|
4023
|
+ $sql .= " AND mp.fk_product = " . ((int) $this->id); |
4024
|
4024
|
$sql .= " AND mp.role ='" . $this->db->escape($role) . "'"; |
4025
|
4025
|
if ($socid > 0) { |
4026
|
|
- $sql .= " AND c.fk_soc = " . ((int)$socid); |
|
4026
|
+ $sql .= " AND c.fk_soc = " . ((int) $socid); |
4027
|
4027
|
} |
4028
|
4028
|
|
4029
|
4029
|
$result = $this->db->query($sql); |
|
@@ -4031,7 +4031,7 @@ discard block |
|
|
block discarded – undo |
4031
|
4031
|
$obj = $this->db->fetch_object($result); |
4032
|
4032
|
$this->stats_mo['customers_' . $role] = $obj->nb_customers ? $obj->nb_customers : 0; |
4033
|
4033
|
$this->stats_mo['nb_' . $role] = $obj->nb ? $obj->nb : 0; |
4034
|
|
- $this->stats_mo['qty_' . $role] = $obj->qty ? price2num($obj->qty, 'MS') : 0; // qty may be a float due to the SUM() |
|
4034
|
+ $this->stats_mo['qty_' . $role] = $obj->qty ? price2num($obj->qty, 'MS') : 0; // qty may be a float due to the SUM() |
4035
|
4035
|
} else { |
4036
|
4036
|
$this->error = $this->db->error(); |
4037
|
4037
|
$error++; |
|
@@ -4077,7 +4077,7 @@ discard block |
|
|
block discarded – undo |
4077
|
4077
|
$sql .= " INNER JOIN " . $this->db->prefix() . "bom_bomline as bl ON bl.fk_bom=b.rowid"; |
4078
|
4078
|
$sql .= " WHERE "; |
4079
|
4079
|
$sql .= " b.entity IN (" . getEntity('bom') . ")"; |
4080
|
|
- $sql .= " AND b.fk_product =" . ((int)$this->id); |
|
4080
|
+ $sql .= " AND b.fk_product =" . ((int) $this->id); |
4081
|
4081
|
$sql .= " GROUP BY b.rowid"; |
4082
|
4082
|
|
4083
|
4083
|
$result = $this->db->query($sql); |
|
@@ -4096,7 +4096,7 @@ discard block |
|
|
block discarded – undo |
4096
|
4096
|
$sql .= " INNER JOIN " . $this->db->prefix() . "bom_bomline as bl ON bl.fk_bom=b.rowid"; |
4097
|
4097
|
$sql .= " WHERE "; |
4098
|
4098
|
$sql .= " b.entity IN (" . getEntity('bom') . ")"; |
4099
|
|
- $sql .= " AND bl.fk_product =" . ((int)$this->id); |
|
4099
|
+ $sql .= " AND bl.fk_product =" . ((int) $this->id); |
4100
|
4100
|
|
4101
|
4101
|
$result = $this->db->query($sql); |
4102
|
4102
|
if ($result) { |
|
@@ -4145,13 +4145,13 @@ discard block |
|
|
block discarded – undo |
4145
|
4145
|
$sql .= " WHERE p.rowid = pd.fk_propal"; |
4146
|
4146
|
$sql .= " AND p.fk_soc = s.rowid"; |
4147
|
4147
|
$sql .= " AND p.entity IN (" . getEntity('propal') . ")"; |
4148
|
|
- $sql .= " AND pd.fk_product = " . ((int)$this->id); |
|
4148
|
+ $sql .= " AND pd.fk_product = " . ((int) $this->id); |
4149
|
4149
|
if (!$user->hasRight('societe', 'client', 'voir')) { |
4150
|
|
- $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
4150
|
+ $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
4151
|
4151
|
} |
4152
|
4152
|
//$sql.= " AND pr.fk_statut != 0"; |
4153
|
4153
|
if ($socid > 0) { |
4154
|
|
- $sql .= " AND p.fk_soc = " . ((int)$socid); |
|
4154
|
+ $sql .= " AND p.fk_soc = " . ((int) $socid); |
4155
|
4155
|
} |
4156
|
4156
|
|
4157
|
4157
|
$result = $this->db->query($sql); |
|
@@ -4220,13 +4220,13 @@ discard block |
|
|
block discarded – undo |
4220
|
4220
|
$sql .= " WHERE p.rowid = pd.fk_supplier_proposal"; |
4221
|
4221
|
$sql .= " AND p.fk_soc = s.rowid"; |
4222
|
4222
|
$sql .= " AND p.entity IN (" . getEntity('supplier_proposal') . ")"; |
4223
|
|
- $sql .= " AND pd.fk_product = " . ((int)$this->id); |
|
4223
|
+ $sql .= " AND pd.fk_product = " . ((int) $this->id); |
4224
|
4224
|
if (!$user->hasRight('societe', 'client', 'voir')) { |
4225
|
|
- $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
4225
|
+ $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
4226
|
4226
|
} |
4227
|
4227
|
//$sql.= " AND pr.fk_statut != 0"; |
4228
|
4228
|
if ($socid > 0) { |
4229
|
|
- $sql .= " AND p.fk_soc = " . ((int)$socid); |
|
4229
|
+ $sql .= " AND p.fk_soc = " . ((int) $socid); |
4230
|
4230
|
} |
4231
|
4231
|
|
4232
|
4232
|
$result = $this->db->query($sql); |
|
@@ -4274,13 +4274,13 @@ discard block |
|
|
block discarded – undo |
4274
|
4274
|
$sql .= " WHERE c.rowid = cd.fk_contrat"; |
4275
|
4275
|
$sql .= " AND c.fk_soc = s.rowid"; |
4276
|
4276
|
$sql .= " AND c.entity IN (" . getEntity('contract') . ")"; |
4277
|
|
- $sql .= " AND cd.fk_product = " . ((int)$this->id); |
|
4277
|
+ $sql .= " AND cd.fk_product = " . ((int) $this->id); |
4278
|
4278
|
if (!$user->hasRight('societe', 'client', 'voir')) { |
4279
|
|
- $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
4279
|
+ $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
4280
|
4280
|
} |
4281
|
4281
|
//$sql.= " AND c.statut != 0"; |
4282
|
4282
|
if ($socid > 0) { |
4283
|
|
- $sql .= " AND c.fk_soc = " . ((int)$socid); |
|
4283
|
+ $sql .= " AND c.fk_soc = " . ((int) $socid); |
4284
|
4284
|
} |
4285
|
4285
|
|
4286
|
4286
|
$result = $this->db->query($sql); |
|
@@ -4349,13 +4349,13 @@ discard block |
|
|
block discarded – undo |
4349
|
4349
|
$sql .= " WHERE f.rowid = fd.fk_facture"; |
4350
|
4350
|
$sql .= " AND f.fk_soc = s.rowid"; |
4351
|
4351
|
$sql .= " AND f.entity IN (" . getEntity('invoice') . ")"; |
4352
|
|
- $sql .= " AND fd.fk_product = " . ((int)$this->id); |
|
4352
|
+ $sql .= " AND fd.fk_product = " . ((int) $this->id); |
4353
|
4353
|
if (!$user->hasRight('societe', 'client', 'voir')) { |
4354
|
|
- $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
4354
|
+ $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
4355
|
4355
|
} |
4356
|
4356
|
//$sql.= " AND f.fk_statut != 0"; |
4357
|
4357
|
if ($socid > 0) { |
4358
|
|
- $sql .= " AND f.fk_soc = " . ((int)$socid); |
|
4358
|
+ $sql .= " AND f.fk_soc = " . ((int) $socid); |
4359
|
4359
|
} |
4360
|
4360
|
|
4361
|
4361
|
$result = $this->db->query($sql); |
|
@@ -4424,13 +4424,13 @@ discard block |
|
|
block discarded – undo |
4424
|
4424
|
$sql .= " WHERE f.rowid = fd.fk_facture"; |
4425
|
4425
|
$sql .= " AND f.fk_soc = s.rowid"; |
4426
|
4426
|
$sql .= " AND f.entity IN (" . getEntity('invoice') . ")"; |
4427
|
|
- $sql .= " AND fd.fk_product = " . ((int)$this->id); |
|
4427
|
+ $sql .= " AND fd.fk_product = " . ((int) $this->id); |
4428
|
4428
|
if (!$user->hasRight('societe', 'client', 'voir')) { |
4429
|
|
- $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
4429
|
+ $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
4430
|
4430
|
} |
4431
|
4431
|
//$sql.= " AND f.fk_statut != 0"; |
4432
|
4432
|
if ($socid > 0) { |
4433
|
|
- $sql .= " AND f.fk_soc = " . ((int)$socid); |
|
4433
|
+ $sql .= " AND f.fk_soc = " . ((int) $socid); |
4434
|
4434
|
} |
4435
|
4435
|
|
4436
|
4436
|
$result = $this->db->query($sql); |
|
@@ -4499,13 +4499,13 @@ discard block |
|
|
block discarded – undo |
4499
|
4499
|
$sql .= " WHERE f.rowid = fd.fk_facture_fourn"; |
4500
|
4500
|
$sql .= " AND f.fk_soc = s.rowid"; |
4501
|
4501
|
$sql .= " AND f.entity IN (" . getEntity('facture_fourn') . ")"; |
4502
|
|
- $sql .= " AND fd.fk_product = " . ((int)$this->id); |
|
4502
|
+ $sql .= " AND fd.fk_product = " . ((int) $this->id); |
4503
|
4503
|
if (!$user->hasRight('societe', 'client', 'voir')) { |
4504
|
|
- $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
4504
|
+ $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
4505
|
4505
|
} |
4506
|
4506
|
//$sql.= " AND f.fk_statut != 0"; |
4507
|
4507
|
if ($socid > 0) { |
4508
|
|
- $sql .= " AND f.fk_soc = " . ((int)$socid); |
|
4508
|
+ $sql .= " AND f.fk_soc = " . ((int) $socid); |
4509
|
4509
|
} |
4510
|
4510
|
|
4511
|
4511
|
$result = $this->db->query($sql); |
|
@@ -4561,17 +4561,17 @@ discard block |
|
|
block discarded – undo |
4561
|
4561
|
} |
4562
|
4562
|
$sql .= " WHERE f.rowid = d.fk_facture"; |
4563
|
4563
|
if ($this->id > 0) { |
4564
|
|
- $sql .= " AND d.fk_product = " . ((int)$this->id); |
|
4564
|
+ $sql .= " AND d.fk_product = " . ((int) $this->id); |
4565
|
4565
|
} else { |
4566
|
4566
|
$sql .= " AND d.fk_product > 0"; |
4567
|
4567
|
} |
4568
|
4568
|
if ($filteronproducttype >= 0) { |
4569
|
|
- $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = " . ((int)$filteronproducttype); |
|
4569
|
+ $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = " . ((int) $filteronproducttype); |
4570
|
4570
|
} |
4571
|
4571
|
$sql .= " AND f.fk_soc = s.rowid"; |
4572
|
4572
|
$sql .= " AND f.entity IN (" . getEntity('invoice') . ")"; |
4573
|
4573
|
if (!$user->hasRight('societe', 'client', 'voir')) { |
4574
|
|
- $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
4574
|
+ $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
4575
|
4575
|
} |
4576
|
4576
|
if ($socid > 0) { |
4577
|
4577
|
$sql .= " AND f.fk_soc = $socid"; |
|
@@ -4605,7 +4605,7 @@ discard block |
|
|
block discarded – undo |
4605
|
4605
|
while ($i < $num) { |
4606
|
4606
|
$arr = $this->db->fetch_array($resql); |
4607
|
4607
|
if (is_array($arr)) { |
4608
|
|
- $keyfortab = (string)$arr[1]; |
|
4608
|
+ $keyfortab = (string) $arr[1]; |
4609
|
4609
|
if ($year == -1) { |
4610
|
4610
|
$keyfortab = substr($keyfortab, -2); |
4611
|
4611
|
} |
|
@@ -4694,17 +4694,17 @@ discard block |
|
|
block discarded – undo |
4694
|
4694
|
} |
4695
|
4695
|
$sql .= " WHERE f.rowid = d.fk_facture_fourn"; |
4696
|
4696
|
if ($this->id > 0) { |
4697
|
|
- $sql .= " AND d.fk_product = " . ((int)$this->id); |
|
4697
|
+ $sql .= " AND d.fk_product = " . ((int) $this->id); |
4698
|
4698
|
} else { |
4699
|
4699
|
$sql .= " AND d.fk_product > 0"; |
4700
|
4700
|
} |
4701
|
4701
|
if ($filteronproducttype >= 0) { |
4702
|
|
- $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = " . ((int)$filteronproducttype); |
|
4702
|
+ $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = " . ((int) $filteronproducttype); |
4703
|
4703
|
} |
4704
|
4704
|
$sql .= " AND f.fk_soc = s.rowid"; |
4705
|
4705
|
$sql .= " AND f.entity IN (" . getEntity('facture_fourn') . ")"; |
4706
|
4706
|
if (!$user->hasRight('societe', 'client', 'voir')) { |
4707
|
|
- $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
4707
|
+ $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
4708
|
4708
|
} |
4709
|
4709
|
if ($socid > 0) { |
4710
|
4710
|
$sql .= " AND f.fk_soc = $socid"; |
|
@@ -4748,20 +4748,20 @@ discard block |
|
|
block discarded – undo |
4748
|
4748
|
} |
4749
|
4749
|
$sql .= " WHERE p.rowid = d.fk_propal"; |
4750
|
4750
|
if ($this->id > 0) { |
4751
|
|
- $sql .= " AND d.fk_product = " . ((int)$this->id); |
|
4751
|
+ $sql .= " AND d.fk_product = " . ((int) $this->id); |
4752
|
4752
|
} else { |
4753
|
4753
|
$sql .= " AND d.fk_product > 0"; |
4754
|
4754
|
} |
4755
|
4755
|
if ($filteronproducttype >= 0) { |
4756
|
|
- $sql .= " AND prod.rowid = d.fk_product AND prod.fk_product_type = " . ((int)$filteronproducttype); |
|
4756
|
+ $sql .= " AND prod.rowid = d.fk_product AND prod.fk_product_type = " . ((int) $filteronproducttype); |
4757
|
4757
|
} |
4758
|
4758
|
$sql .= " AND p.fk_soc = s.rowid"; |
4759
|
4759
|
$sql .= " AND p.entity IN (" . getEntity('propal') . ")"; |
4760
|
4760
|
if (!$user->hasRight('societe', 'client', 'voir')) { |
4761
|
|
- $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
4761
|
+ $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
4762
|
4762
|
} |
4763
|
4763
|
if ($socid > 0) { |
4764
|
|
- $sql .= " AND p.fk_soc = " . ((int)$socid); |
|
4764
|
+ $sql .= " AND p.fk_soc = " . ((int) $socid); |
4765
|
4765
|
} |
4766
|
4766
|
$sql .= $morefilter; |
4767
|
4767
|
$sql .= " GROUP BY date_format(p.datep,'%Y%m')"; |
|
@@ -4802,20 +4802,20 @@ discard block |
|
|
block discarded – undo |
4802
|
4802
|
} |
4803
|
4803
|
$sql .= " WHERE p.rowid = d.fk_supplier_proposal"; |
4804
|
4804
|
if ($this->id > 0) { |
4805
|
|
- $sql .= " AND d.fk_product = " . ((int)$this->id); |
|
4805
|
+ $sql .= " AND d.fk_product = " . ((int) $this->id); |
4806
|
4806
|
} else { |
4807
|
4807
|
$sql .= " AND d.fk_product > 0"; |
4808
|
4808
|
} |
4809
|
4809
|
if ($filteronproducttype >= 0) { |
4810
|
|
- $sql .= " AND prod.rowid = d.fk_product AND prod.fk_product_type = " . ((int)$filteronproducttype); |
|
4810
|
+ $sql .= " AND prod.rowid = d.fk_product AND prod.fk_product_type = " . ((int) $filteronproducttype); |
4811
|
4811
|
} |
4812
|
4812
|
$sql .= " AND p.fk_soc = s.rowid"; |
4813
|
4813
|
$sql .= " AND p.entity IN (" . getEntity('supplier_proposal') . ")"; |
4814
|
4814
|
if (!$user->hasRight('societe', 'client', 'voir')) { |
4815
|
|
- $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
4815
|
+ $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
4816
|
4816
|
} |
4817
|
4817
|
if ($socid > 0) { |
4818
|
|
- $sql .= " AND p.fk_soc = " . ((int)$socid); |
|
4818
|
+ $sql .= " AND p.fk_soc = " . ((int) $socid); |
4819
|
4819
|
} |
4820
|
4820
|
$sql .= $morefilter; |
4821
|
4821
|
$sql .= " GROUP BY date_format(p.date_valid,'%Y%m')"; |
|
@@ -4855,20 +4855,20 @@ discard block |
|
|
block discarded – undo |
4855
|
4855
|
} |
4856
|
4856
|
$sql .= " WHERE c.rowid = d.fk_commande"; |
4857
|
4857
|
if ($this->id > 0) { |
4858
|
|
- $sql .= " AND d.fk_product = " . ((int)$this->id); |
|
4858
|
+ $sql .= " AND d.fk_product = " . ((int) $this->id); |
4859
|
4859
|
} else { |
4860
|
4860
|
$sql .= " AND d.fk_product > 0"; |
4861
|
4861
|
} |
4862
|
4862
|
if ($filteronproducttype >= 0) { |
4863
|
|
- $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = " . ((int)$filteronproducttype); |
|
4863
|
+ $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = " . ((int) $filteronproducttype); |
4864
|
4864
|
} |
4865
|
4865
|
$sql .= " AND c.fk_soc = s.rowid"; |
4866
|
4866
|
$sql .= " AND c.entity IN (" . getEntity('commande') . ")"; |
4867
|
4867
|
if (!$user->hasRight('societe', 'client', 'voir')) { |
4868
|
|
- $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
4868
|
+ $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
4869
|
4869
|
} |
4870
|
4870
|
if ($socid > 0) { |
4871
|
|
- $sql .= " AND c.fk_soc = " . ((int)$socid); |
|
4871
|
+ $sql .= " AND c.fk_soc = " . ((int) $socid); |
4872
|
4872
|
} |
4873
|
4873
|
$sql .= $morefilter; |
4874
|
4874
|
$sql .= " GROUP BY date_format(c.date_commande,'%Y%m')"; |
|
@@ -4908,20 +4908,20 @@ discard block |
|
|
block discarded – undo |
4908
|
4908
|
} |
4909
|
4909
|
$sql .= " WHERE c.rowid = d.fk_commande"; |
4910
|
4910
|
if ($this->id > 0) { |
4911
|
|
- $sql .= " AND d.fk_product = " . ((int)$this->id); |
|
4911
|
+ $sql .= " AND d.fk_product = " . ((int) $this->id); |
4912
|
4912
|
} else { |
4913
|
4913
|
$sql .= " AND d.fk_product > 0"; |
4914
|
4914
|
} |
4915
|
4915
|
if ($filteronproducttype >= 0) { |
4916
|
|
- $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = " . ((int)$filteronproducttype); |
|
4916
|
+ $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = " . ((int) $filteronproducttype); |
4917
|
4917
|
} |
4918
|
4918
|
$sql .= " AND c.fk_soc = s.rowid"; |
4919
|
4919
|
$sql .= " AND c.entity IN (" . getEntity('supplier_order') . ")"; |
4920
|
4920
|
if (!$user->hasRight('societe', 'client', 'voir')) { |
4921
|
|
- $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
4921
|
+ $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
4922
|
4922
|
} |
4923
|
4923
|
if ($socid > 0) { |
4924
|
|
- $sql .= " AND c.fk_soc = " . ((int)$socid); |
|
4924
|
+ $sql .= " AND c.fk_soc = " . ((int) $socid); |
4925
|
4925
|
} |
4926
|
4926
|
$sql .= $morefilter; |
4927
|
4927
|
$sql .= " GROUP BY date_format(c.date_commande,'%Y%m')"; |
|
@@ -4963,20 +4963,20 @@ discard block |
|
|
block discarded – undo |
4963
|
4963
|
$sql .= " AND c.rowid = d.fk_contrat"; |
4964
|
4964
|
|
4965
|
4965
|
if ($this->id > 0) { |
4966
|
|
- $sql .= " AND d.fk_product = " . ((int)$this->id); |
|
4966
|
+ $sql .= " AND d.fk_product = " . ((int) $this->id); |
4967
|
4967
|
} else { |
4968
|
4968
|
$sql .= " AND d.fk_product > 0"; |
4969
|
4969
|
} |
4970
|
4970
|
if ($filteronproducttype >= 0) { |
4971
|
|
- $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = " . ((int)$filteronproducttype); |
|
4971
|
+ $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = " . ((int) $filteronproducttype); |
4972
|
4972
|
} |
4973
|
4973
|
$sql .= " AND c.fk_soc = s.rowid"; |
4974
|
4974
|
|
4975
|
4975
|
if (!$user->hasRight('societe', 'client', 'voir')) { |
4976
|
|
- $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
4976
|
+ $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
4977
|
4977
|
} |
4978
|
4978
|
if ($socid > 0) { |
4979
|
|
- $sql .= " AND c.fk_soc = " . ((int)$socid); |
|
4979
|
+ $sql .= " AND c.fk_soc = " . ((int) $socid); |
4980
|
4980
|
} |
4981
|
4981
|
$sql .= $morefilter; |
4982
|
4982
|
$sql .= " GROUP BY date_format(c.date_contrat,'%Y%m')"; |
|
@@ -5018,19 +5018,19 @@ discard block |
|
|
block discarded – undo |
5018
|
5018
|
$sql .= " AND d.status > 0"; |
5019
|
5019
|
|
5020
|
5020
|
if ($this->id > 0) { |
5021
|
|
- $sql .= " AND d.fk_product = " . ((int)$this->id); |
|
5021
|
+ $sql .= " AND d.fk_product = " . ((int) $this->id); |
5022
|
5022
|
} else { |
5023
|
5023
|
$sql .= " AND d.fk_product > 0"; |
5024
|
5024
|
} |
5025
|
5025
|
if ($filteronproducttype >= 0) { |
5026
|
|
- $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = " . ((int)$filteronproducttype); |
|
5026
|
+ $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type = " . ((int) $filteronproducttype); |
5027
|
5027
|
} |
5028
|
5028
|
|
5029
|
5029
|
if (!$user->hasRight('societe', 'client', 'voir')) { |
5030
|
|
- $sql .= " AND d.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
5030
|
+ $sql .= " AND d.fk_soc = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
5031
|
5031
|
} |
5032
|
5032
|
if ($socid > 0) { |
5033
|
|
- $sql .= " AND d.fk_soc = " . ((int)$socid); |
|
5033
|
+ $sql .= " AND d.fk_soc = " . ((int) $socid); |
5034
|
5034
|
} |
5035
|
5035
|
$sql .= $morefilter; |
5036
|
5036
|
$sql .= " GROUP BY date_format(d.date_valid,'%Y%m')"; |
|
@@ -5072,21 +5072,21 @@ discard block |
|
|
block discarded – undo |
5072
|
5072
|
|
5073
|
5073
|
// Check not already father of id_pere (to avoid father -> child -> father links) |
5074
|
5074
|
$sql = "SELECT fk_product_pere from " . $this->db->prefix() . "product_association"; |
5075
|
|
- $sql .= " WHERE fk_product_pere = " . ((int)$id_fils) . " AND fk_product_fils = " . ((int)$id_pere); |
|
5075
|
+ $sql .= " WHERE fk_product_pere = " . ((int) $id_fils) . " AND fk_product_fils = " . ((int) $id_pere); |
5076
|
5076
|
if (!$this->db->query($sql)) { |
5077
|
5077
|
dol_print_error($this->db); |
5078
|
5078
|
return -1; |
5079
|
5079
|
} else { |
5080
|
5080
|
//Selection of the highest row |
5081
|
5081
|
$sql = "SELECT MAX(rang) as max_rank FROM " . $this->db->prefix() . "product_association"; |
5082
|
|
- $sql .= " WHERE fk_product_pere = " . ((int)$id_pere); |
|
5082
|
+ $sql .= " WHERE fk_product_pere = " . ((int) $id_pere); |
5083
|
5083
|
$resql = $this->db->query($sql); |
5084
|
5084
|
if ($resql) { |
5085
|
5085
|
$obj = $this->db->fetch_object($resql); |
5086
|
5086
|
$rank = $obj->max_rank + 1; |
5087
|
5087
|
//Addition of a product with the highest rank +1 |
5088
|
5088
|
$sql = "INSERT INTO " . $this->db->prefix() . "product_association(fk_product_pere,fk_product_fils,qty,incdec,rang)"; |
5089
|
|
- $sql .= " VALUES (" . ((int)$id_pere) . ", " . ((int)$id_fils) . ", " . price2num($qty, 'MS') . ", " . ((int)$incdec) . ", " . ((int)$rank) . ")"; |
|
5089
|
+ $sql .= " VALUES (" . ((int) $id_pere) . ", " . ((int) $id_fils) . ", " . price2num($qty, 'MS') . ", " . ((int) $incdec) . ", " . ((int) $rank) . ")"; |
5090
|
5090
|
if (!$this->db->query($sql)) { |
5091
|
5091
|
dol_print_error($this->db); |
5092
|
5092
|
return -1; |
|
@@ -5132,8 +5132,8 @@ discard block |
|
|
block discarded – undo |
5132
|
5132
|
} |
5133
|
5133
|
|
5134
|
5134
|
$sql = "DELETE FROM " . $this->db->prefix() . "product_association"; |
5135
|
|
- $sql .= " WHERE fk_product_pere = " . ((int)$fk_parent); |
5136
|
|
- $sql .= " AND fk_product_fils = " . ((int)$fk_child); |
|
5135
|
+ $sql .= " WHERE fk_product_pere = " . ((int) $fk_parent); |
|
5136
|
+ $sql .= " AND fk_product_fils = " . ((int) $fk_child); |
5137
|
5137
|
|
5138
|
5138
|
dol_syslog(get_only_class($this) . '::del_sousproduit', LOG_DEBUG); |
5139
|
5139
|
if (!$this->db->query($sql)) { |
|
@@ -5143,7 +5143,7 @@ discard block |
|
|
block discarded – undo |
5143
|
5143
|
|
5144
|
5144
|
// Updated ranks so that none are missing |
5145
|
5145
|
$sqlrank = "SELECT rowid, rang FROM " . $this->db->prefix() . "product_association"; |
5146
|
|
- $sqlrank .= " WHERE fk_product_pere = " . ((int)$fk_parent); |
|
5146
|
+ $sqlrank .= " WHERE fk_product_pere = " . ((int) $fk_parent); |
5147
|
5147
|
$sqlrank .= " ORDER BY rang"; |
5148
|
5148
|
$resqlrank = $this->db->query($sqlrank); |
5149
|
5149
|
if ($resqlrank) { |
|
@@ -5151,8 +5151,8 @@ discard block |
|
|
block discarded – undo |
5151
|
5151
|
while ($objrank = $this->db->fetch_object($resqlrank)) { |
5152
|
5152
|
$cpt++; |
5153
|
5153
|
$sql = "UPDATE " . $this->db->prefix() . "product_association"; |
5154
|
|
- $sql .= " SET rang = " . ((int)$cpt); |
5155
|
|
- $sql .= " WHERE rowid = " . ((int)$objrank->rowid); |
|
5154
|
+ $sql .= " SET rang = " . ((int) $cpt); |
|
5155
|
+ $sql .= " WHERE rowid = " . ((int) $objrank->rowid); |
5156
|
5156
|
if (!$this->db->query($sql)) { |
5157
|
5157
|
dol_print_error($this->db); |
5158
|
5158
|
return -1; |
|
@@ -5205,8 +5205,8 @@ discard block |
|
|
block discarded – undo |
5205
|
5205
|
|
5206
|
5206
|
$sql = 'UPDATE ' . $this->db->prefix() . 'product_association SET '; |
5207
|
5207
|
$sql .= 'qty = ' . price2num($qty, 'MS'); |
5208
|
|
- $sql .= ',incdec = ' . ((int)$incdec); |
5209
|
|
- $sql .= ' WHERE fk_product_pere = ' . ((int)$id_pere) . ' AND fk_product_fils = ' . ((int)$id_fils); |
|
5208
|
+ $sql .= ',incdec = ' . ((int) $incdec); |
|
5209
|
+ $sql .= ' WHERE fk_product_pere = ' . ((int) $id_pere) . ' AND fk_product_fils = ' . ((int) $id_fils); |
5210
|
5210
|
|
5211
|
5211
|
if (!$this->db->query($sql)) { |
5212
|
5212
|
dol_print_error($this->db); |
|
@@ -5239,8 +5239,8 @@ discard block |
|
|
block discarded – undo |
5239
|
5239
|
// phpcs:enable |
5240
|
5240
|
$sql = "SELECT fk_product_pere, qty, incdec"; |
5241
|
5241
|
$sql .= " FROM " . $this->db->prefix() . "product_association"; |
5242
|
|
- $sql .= " WHERE fk_product_pere = " . ((int)$fk_parent); |
5243
|
|
- $sql .= " AND fk_product_fils = " . ((int)$fk_child); |
|
5242
|
+ $sql .= " WHERE fk_product_pere = " . ((int) $fk_parent); |
|
5243
|
+ $sql .= " AND fk_product_fils = " . ((int) $fk_child); |
5244
|
5244
|
|
5245
|
5245
|
$result = $this->db->query($sql); |
5246
|
5246
|
if ($result) { |
|
@@ -5288,9 +5288,9 @@ discard block |
|
|
block discarded – undo |
5288
|
5288
|
// Check if ref is not already used |
5289
|
5289
|
$sql = "SELECT rowid, fk_product"; |
5290
|
5290
|
$sql .= " FROM " . $this->db->prefix() . "product_fournisseur_price"; |
5291
|
|
- $sql .= " WHERE fk_soc = " . ((int)$id_fourn); |
|
5291
|
+ $sql .= " WHERE fk_soc = " . ((int) $id_fourn); |
5292
|
5292
|
$sql .= " AND ref_fourn = '" . $this->db->escape($ref_fourn) . "'"; |
5293
|
|
- $sql .= " AND fk_product <> " . ((int)$this->id); |
|
5293
|
+ $sql .= " AND fk_product <> " . ((int) $this->id); |
5294
|
5294
|
$sql .= " AND entity IN (" . getEntity('productsupplierprice') . ")"; |
5295
|
5295
|
|
5296
|
5296
|
$resql = $this->db->query($sql); |
|
@@ -5307,14 +5307,14 @@ discard block |
|
|
block discarded – undo |
5307
|
5307
|
|
5308
|
5308
|
$sql = "SELECT rowid"; |
5309
|
5309
|
$sql .= " FROM " . $this->db->prefix() . "product_fournisseur_price"; |
5310
|
|
- $sql .= " WHERE fk_soc = " . ((int)$id_fourn); |
|
5310
|
+ $sql .= " WHERE fk_soc = " . ((int) $id_fourn); |
5311
|
5311
|
if ($ref_fourn) { |
5312
|
5312
|
$sql .= " AND ref_fourn = '" . $this->db->escape($ref_fourn) . "'"; |
5313
|
5313
|
} else { |
5314
|
5314
|
$sql .= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; |
5315
|
5315
|
} |
5316
|
|
- $sql .= " AND quantity = " . ((float)$quantity); |
5317
|
|
- $sql .= " AND fk_product = " . ((int)$this->id); |
|
5316
|
+ $sql .= " AND quantity = " . ((float) $quantity); |
|
5317
|
+ $sql .= " AND fk_product = " . ((int) $this->id); |
5318
|
5318
|
$sql .= " AND entity IN (" . getEntity('productsupplierprice') . ")"; |
5319
|
5319
|
|
5320
|
5320
|
$resql = $this->db->query($sql); |
|
@@ -5334,12 +5334,12 @@ discard block |
|
|
block discarded – undo |
5334
|
5334
|
$sql .= ", tva_tx"; |
5335
|
5335
|
$sql .= ") VALUES ("; |
5336
|
5336
|
$sql .= "'" . $this->db->idate($now) . "'"; |
5337
|
|
- $sql .= ", " . ((int)$conf->entity); |
5338
|
|
- $sql .= ", " . ((int)$this->id); |
5339
|
|
- $sql .= ", " . ((int)$id_fourn); |
|
5337
|
+ $sql .= ", " . ((int) $conf->entity); |
|
5338
|
+ $sql .= ", " . ((int) $this->id); |
|
5339
|
+ $sql .= ", " . ((int) $id_fourn); |
5340
|
5340
|
$sql .= ", '" . $this->db->escape($ref_fourn) . "'"; |
5341
|
|
- $sql .= ", " . ((float)$quantity); |
5342
|
|
- $sql .= ", " . ((int)$user->id); |
|
5341
|
+ $sql .= ", " . ((float) $quantity); |
|
5342
|
+ $sql .= ", " . ((int) $user->id); |
5343
|
5343
|
$sql .= ", 0"; |
5344
|
5344
|
$sql .= ")"; |
5345
|
5345
|
|
|
@@ -5377,8 +5377,8 @@ discard block |
|
|
block discarded – undo |
5377
|
5377
|
|
5378
|
5378
|
$sql = "SELECT DISTINCT p.fk_soc"; |
5379
|
5379
|
$sql .= " FROM " . $this->db->prefix() . "product_fournisseur_price as p"; |
5380
|
|
- $sql .= " WHERE p.fk_product = " . ((int)$this->id); |
5381
|
|
- $sql .= " AND p.entity = " . ((int)$conf->entity); |
|
5380
|
+ $sql .= " WHERE p.fk_product = " . ((int) $this->id); |
|
5381
|
+ $sql .= " AND p.entity = " . ((int) $conf->entity); |
5382
|
5382
|
|
5383
|
5383
|
$result = $this->db->query($sql); |
5384
|
5384
|
if ($result) { |
|
@@ -5466,8 +5466,8 @@ discard block |
|
|
block discarded – undo |
5466
|
5466
|
$sql .= ", multicurrency_price"; |
5467
|
5467
|
$sql .= ", multicurrency_price_ttc"; |
5468
|
5468
|
$sql .= " FROM " . $this->db->prefix() . "product_price ps"; |
5469
|
|
- $sql .= " WHERE fk_product = " . ((int)$fromId); |
5470
|
|
- $sql .= " AND date_price IN (SELECT MAX(pd.date_price) FROM " . $this->db->prefix() . "product_price pd WHERE pd.fk_product = " . ((int)$fromId) . " AND pd.price_level = ps.price_level)"; |
|
5469
|
+ $sql .= " WHERE fk_product = " . ((int) $fromId); |
|
5470
|
+ $sql .= " AND date_price IN (SELECT MAX(pd.date_price) FROM " . $this->db->prefix() . "product_price pd WHERE pd.fk_product = " . ((int) $fromId) . " AND pd.price_level = ps.price_level)"; |
5471
|
5471
|
$sql .= " ORDER BY date_price DESC"; |
5472
|
5472
|
|
5473
|
5473
|
dol_syslog(__METHOD__, LOG_DEBUG); |
|
@@ -5495,7 +5495,7 @@ discard block |
|
|
block discarded – undo |
5495
|
5495
|
|
5496
|
5496
|
$sql = 'INSERT INTO ' . $this->db->prefix() . 'product_association (fk_product_pere, fk_product_fils, qty, incdec)'; |
5497
|
5497
|
$sql .= " SELECT " . $toId . ", fk_product_fils, qty, incdec FROM " . $this->db->prefix() . "product_association"; |
5498
|
|
- $sql .= " WHERE fk_product_pere = " . ((int)$fromId); |
|
5498
|
+ $sql .= " WHERE fk_product_pere = " . ((int) $fromId); |
5499
|
5499
|
|
5500
|
5500
|
dol_syslog(get_only_class($this) . '::clone_association', LOG_DEBUG); |
5501
|
5501
|
if (!$this->db->query($sql)) { |
|
@@ -5537,9 +5537,9 @@ discard block |
|
|
block discarded – undo |
5537
|
5537
|
// les prix de fournisseurs. |
5538
|
5538
|
$sql = "INSERT " . $this->db->prefix() . "product_fournisseur_price ("; |
5539
|
5539
|
$sql .= " datec, fk_product, fk_soc, price, quantity, fk_user, tva_tx)"; |
5540
|
|
- $sql .= " SELECT '" . $this->db->idate($now) . "', " . ((int)$toId) . ", fk_soc, price, quantity, fk_user, tva_tx"; |
|
5540
|
+ $sql .= " SELECT '" . $this->db->idate($now) . "', " . ((int) $toId) . ", fk_soc, price, quantity, fk_user, tva_tx"; |
5541
|
5541
|
$sql .= " FROM " . $this->db->prefix() . "product_fournisseur_price"; |
5542
|
|
- $sql .= " WHERE fk_product = " . ((int)$fromId); |
|
5542
|
+ $sql .= " WHERE fk_product = " . ((int) $fromId); |
5543
|
5543
|
|
5544
|
5544
|
dol_syslog(get_only_class($this) . '::clone_fournisseurs', LOG_DEBUG); |
5545
|
5545
|
$resql = $this->db->query($sql); |
|
@@ -5658,11 +5658,11 @@ discard block |
|
|
block discarded – undo |
5658
|
5658
|
$sql = "SELECT COUNT(pa.rowid) as nb"; |
5659
|
5659
|
$sql .= " FROM " . $this->db->prefix() . "product_association as pa"; |
5660
|
5660
|
if ($mode == 0) { |
5661
|
|
- $sql .= " WHERE pa.fk_product_fils = " . ((int)$this->id) . " OR pa.fk_product_pere = " . ((int)$this->id); |
|
5661
|
+ $sql .= " WHERE pa.fk_product_fils = " . ((int) $this->id) . " OR pa.fk_product_pere = " . ((int) $this->id); |
5662
|
5662
|
} elseif ($mode == -1) { |
5663
|
|
- $sql .= " WHERE pa.fk_product_fils = " . ((int)$this->id); // We are a child, so we found lines that link to parents (can have several parents) |
|
5663
|
+ $sql .= " WHERE pa.fk_product_fils = " . ((int) $this->id); // We are a child, so we found lines that link to parents (can have several parents) |
5664
|
5664
|
} elseif ($mode == 1) { |
5665
|
|
- $sql .= " WHERE pa.fk_product_pere = " . ((int)$this->id); // We are a parent, so we found lines that link to children (can have several children) |
|
5665
|
+ $sql .= " WHERE pa.fk_product_pere = " . ((int) $this->id); // We are a parent, so we found lines that link to children (can have several children) |
5666
|
5666
|
} |
5667
|
5667
|
|
5668
|
5668
|
$resql = $this->db->query($sql); |
|
@@ -5689,7 +5689,7 @@ discard block |
|
|
block discarded – undo |
5689
|
5689
|
public function hasVariants() |
5690
|
5690
|
{ |
5691
|
5691
|
$nb = 0; |
5692
|
|
- $sql = "SELECT count(rowid) as nb FROM " . $this->db->prefix() . "product_attribute_combination WHERE fk_product_parent = " . ((int)$this->id); |
|
5692
|
+ $sql = "SELECT count(rowid) as nb FROM " . $this->db->prefix() . "product_attribute_combination WHERE fk_product_parent = " . ((int) $this->id); |
5693
|
5693
|
$sql .= " AND entity IN (" . getEntity('product') . ")"; |
5694
|
5694
|
|
5695
|
5695
|
$resql = $this->db->query($sql); |
|
@@ -5714,7 +5714,7 @@ discard block |
|
|
block discarded – undo |
5714
|
5714
|
{ |
5715
|
5715
|
global $conf; |
5716
|
5716
|
if (isModEnabled('variants')) { |
5717
|
|
- $sql = "SELECT rowid FROM " . $this->db->prefix() . "product_attribute_combination WHERE fk_product_child = " . ((int)$this->id) . " AND entity IN (" . getEntity('product') . ")"; |
|
5717
|
+ $sql = "SELECT rowid FROM " . $this->db->prefix() . "product_attribute_combination WHERE fk_product_child = " . ((int) $this->id) . " AND entity IN (" . getEntity('product') . ")"; |
5718
|
5718
|
|
5719
|
5719
|
$query = $this->db->query($sql); |
5720
|
5720
|
|
|
@@ -5779,8 +5779,8 @@ discard block |
|
|
block discarded – undo |
5779
|
5779
|
$sql .= " FROM " . $this->db->prefix() . "product as p,"; |
5780
|
5780
|
$sql .= " " . $this->db->prefix() . "product_association as pa"; |
5781
|
5781
|
$sql .= " WHERE p.rowid = pa.fk_product_fils"; |
5782
|
|
- $sql .= " AND pa.fk_product_pere = " . ((int)$id); |
5783
|
|
- $sql .= " AND pa.fk_product_fils <> " . ((int)$id); // This should not happens, it is to avoid infinite loop if it happens |
|
5782
|
+ $sql .= " AND pa.fk_product_pere = " . ((int) $id); |
|
5783
|
+ $sql .= " AND pa.fk_product_fils <> " . ((int) $id); // This should not happens, it is to avoid infinite loop if it happens |
5784
|
5784
|
$sql .= " ORDER BY pa.rang"; |
5785
|
5785
|
|
5786
|
5786
|
dol_syslog(get_only_class($this) . '::getChildsArbo id=' . $id . ' level=' . $level . ' parents=' . (is_array($parents) ? implode(',', $parents) : $parents), LOG_DEBUG); |
|
@@ -5873,7 +5873,7 @@ discard block |
|
|
block discarded – undo |
5873
|
5873
|
$label = ''; |
5874
|
5874
|
|
5875
|
5875
|
if (isset($this->finished) && $this->finished >= 0) { |
5876
|
|
- $sql = "SELECT label, code FROM " . $this->db->prefix() . "c_product_nature where code = " . ((int)$this->finished) . " AND active=1"; |
|
5876
|
+ $sql = "SELECT label, code FROM " . $this->db->prefix() . "c_product_nature where code = " . ((int) $this->finished) . " AND active=1"; |
5877
|
5877
|
$resql = $this->db->query($sql); |
5878
|
5878
|
if (!$resql) { |
5879
|
5879
|
$this->error = $this->db->error() . ' sql=' . $sql; |
|
@@ -5902,7 +5902,7 @@ discard block |
|
|
block discarded – undo |
5902
|
5902
|
$result = array(); |
5903
|
5903
|
|
5904
|
5904
|
$sql = "SELECT pb.batch, pb.eatby, pb.sellby, SUM(pb.qty) AS qty FROM " . $this->db->prefix() . "product_batch as pb, " . $this->db->prefix() . "product_stock as ps"; |
5905
|
|
- $sql .= " WHERE pb.fk_product_stock = ps.rowid AND ps.fk_product = " . ((int)$this->id) . " AND pb.batch = '" . $this->db->escape($batch) . "'"; |
|
5905
|
+ $sql .= " WHERE pb.fk_product_stock = ps.rowid AND ps.fk_product = " . ((int) $this->id) . " AND pb.batch = '" . $this->db->escape($batch) . "'"; |
5906
|
5906
|
$sql .= " GROUP BY pb.batch, pb.eatby, pb.sellby"; |
5907
|
5907
|
dol_syslog(get_only_class($this) . "::loadBatchInfo load first entry found for lot/serial = " . $batch, LOG_DEBUG); |
5908
|
5908
|
$resql = $this->db->query($sql); |
|
@@ -6211,7 +6211,7 @@ discard block |
|
|
block discarded – undo |
6211
|
6211
|
$label_type = 'short_label'; |
6212
|
6212
|
} |
6213
|
6213
|
|
6214
|
|
- $sql = "SELECT " . $label_type . ", code from " . $this->db->prefix() . "c_units where rowid = " . ((int)$this->fk_unit); |
|
6214
|
+ $sql = "SELECT " . $label_type . ", code from " . $this->db->prefix() . "c_units where rowid = " . ((int) $this->fk_unit); |
6215
|
6215
|
|
6216
|
6216
|
$resql = $this->db->query($sql); |
6217
|
6217
|
if (!$resql) { |
|
@@ -6286,7 +6286,7 @@ discard block |
|
|
block discarded – undo |
6286
|
6286
|
$sql = "SELECT p.rowid, p.ref, p.datec as date_creation, p.tms as date_modification,"; |
6287
|
6287
|
$sql .= " p.fk_user_author, p.fk_user_modif"; |
6288
|
6288
|
$sql .= " FROM " . $this->db->prefix() . $this->table_element . " as p"; |
6289
|
|
- $sql .= " WHERE p.rowid = " . ((int)$id); |
|
6289
|
+ $sql .= " WHERE p.rowid = " . ((int) $id); |
6290
|
6290
|
|
6291
|
6291
|
$result = $this->db->query($sql); |
6292
|
6292
|
if ($result) { |