Skip to content

Commit

Permalink
Set import_key in import when update record (#28644)
Browse files Browse the repository at this point in the history
* fix can't delete pdf if ref is not encoded (#28630)

* fix typo in ChangeLog (#28613)

* fix typo in ChangeLog

* Update ChangeLog

* FIX: Count of virtual stock at Services and MoLine with disabled stock change (#28580)

* fix the count of virtual stock

* - fix "Found non sanitized string" ?

---------

Co-authored-by: christian.humpel <[email protected]>

* Set import_key in import when update record

* Set import_key in import when update record

---------

Co-authored-by: Frédéric FRANCE <[email protected]>
Co-authored-by: Christian Humpel <[email protected]>
Co-authored-by: christian.humpel <[email protected]>
Co-authored-by: Laurent Destailleur <[email protected]>
  • Loading branch information
5 people authored Mar 5, 2024
1 parent 13f3dcf commit cb77ff0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion htdocs/compta/facture/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -4511,7 +4511,7 @@ function setRadioForTypeOfInvoice() {
$file = GETPOST('file', 'alpha');

$formconfirm = $form->formconfirm(
$_SERVER["PHP_SELF"].'?facid='.$object->id.'&file='.$file,
$_SERVER["PHP_SELF"].'?facid='.$object->id.'&file='.urlencode($file),
$langs->trans('DeleteFileHeader'),
$langs->trans('DeleteFileText')."<br><br>".$file,
'remove_file',
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/import/import_csv.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ public function import_insert($arrayrecord, $array_match_file_to_database, $obji
foreach ($data as $key => $val) {
$set[] = $key." = ".$val;
}
$sqlstart .= " SET ".implode(', ', $set);
$sqlstart .= " SET ".implode(', ', $set).", import_key = '".$this->db->escape($importid)."'";

if (empty($keyfield)) {
$keyfield = 'rowid';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/import/import_xlsx.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ public function import_insert($arrayrecord, $array_match_file_to_database, $obji
foreach ($data as $key => $val) {
$set[] = $key." = ".$val;
}
$sqlstart .= " SET " . implode(', ', $set);
$sqlstart .= " SET " . implode(', ', $set) . ", import_key = '" . $this->db->escape($importid) . "'";

if (empty($keyfield)) {
$keyfield = 'rowid';
Expand Down
6 changes: 6 additions & 0 deletions htdocs/product/class/product.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3535,6 +3535,8 @@ public function load_stats_inproduction($socid = 0, $filtrestatut = '', $forVirt
// phpcs:enable
global $conf, $user, $hookmanager, $action;

$serviceStockIsEnabled = isModEnabled("service") && getDolGlobalString('STOCK_SUPPORTS_SERVICES');

$sql = "SELECT COUNT(DISTINCT m.fk_soc) as nb_customers, COUNT(DISTINCT m.rowid) as nb,";
$sql .= " COUNT(mp.rowid) as nb_rows, SUM(mp.qty) as qty, role";
$sql .= " FROM ".$this->db->prefix()."mrp_production as mp";
Expand All @@ -3546,6 +3548,7 @@ public function load_stats_inproduction($socid = 0, $filtrestatut = '', $forVirt
$sql .= " WHERE m.rowid = mp.fk_mo";
$sql .= " AND m.entity IN (".getEntity($forVirtualStock && getDolGlobalString('STOCK_CALCULATE_VIRTUAL_STOCK_TRANSVERSE_MODE') ? 'stock' : 'mrp').")";
$sql .= " AND mp.fk_product = ".((int) $this->id);
$sql .= " AND mp.disable_stock_change IN (0)";
if (!$user->hasRight('societe', 'client', 'voir') && !$forVirtualStock) {
$sql .= " AND m.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
Expand All @@ -3558,6 +3561,9 @@ public function load_stats_inproduction($socid = 0, $filtrestatut = '', $forVirt
if (!empty($dateofvirtualstock)) {
$sql .= " AND m.date_valid <= '".$this->db->idate($dateofvirtualstock)."'"; // better date to code ? end of production ?
}
if (!$serviceStockIsEnabled) {
$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))";
}

Check failure on line 3566 in htdocs/product/class/product.class.php

View workflow job for this annotation

GitHub Actions / pre-commit

Tabs must be used to indent lines; spaces are not allowed

Check failure on line 3566 in htdocs/product/class/product.class.php

View workflow job for this annotation

GitHub Actions / pre-commit

Line indented incorrectly; expected 2 tabs, found 1

Check failure on line 3566 in htdocs/product/class/product.class.php

View workflow job for this annotation

GitHub Actions / pre-commit

Closing brace indented incorrectly; expected 8 spaces, found 4
if (!empty($warehouseid)) {
$sql.= " AND m.fk_warehouse = ".((int) $warehouseid);
}
Expand Down

0 comments on commit cb77ff0

Please sign in to comment.