Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1034,7 +1034,6 @@ public function import_insert($arrayrecord, $array_match_file_to_database, $obji
}
}
}

// Update not done, we do insert
if (!$error && !$updatedone) {
// We db escape social network field because he isn't in field creation
Expand All @@ -1051,6 +1050,7 @@ public function import_insert($arrayrecord, $array_match_file_to_database, $obji
$sqlstart .= ", entity";
$sqlend .= ", ".$conf->entity;
}

if (!empty($objimport->array_import_tables_creator[0][$alias])) {
$sqlstart .= ", ".$objimport->array_import_tables_creator[0][$alias];
$sqlend .= ", ".$user->id;
Expand Down
40 changes: 40 additions & 0 deletions htdocs/core/modules/modStock.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,46 @@ public function __construct($db)
$this->import_run_sql_after_array[$r] = array( // Because we may change data that are denormalized, we must update dernormalized data after.
'UPDATE '.MAIN_DB_PREFIX.'product as p SET stock = (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);'
);

// Import des stocks avec numéro de lot/série
$r++;
$this->import_code[$r] = $this->rights_class.'_'.$r;
$this->import_label[$r] = "Stocks Sérialisés"; // Translation key
$this->import_icon[$r] = "stock";
$this->import_entities_array[$r] = array();
$this->import_tables_array[$r] = array('pb' => MAIN_DB_PREFIX.'product_batch', 'pl' => MAIN_DB_PREFIX.'product_lot', 'ps' => MAIN_DB_PREFIX.'product_stock');
$this->import_fields_array[$r] = array(
'ps.fk_product' => "Product*",
'ps.fk_entrepot' => "Warehouse*",
'ps.reel' => "Stock*",
'pl.batch' => "Batch Number"
);

$this->import_convertvalue_array[$r] = array(
'ps.fk_product' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'product'),
'ps.fk_entrepot' => array('rule' => 'fetchidfromref', 'classfile' => '/product/stock/class/entrepot.class.php', 'class' => 'Entrepot', 'method' => 'fetch', 'element' => 'ref'),
'pl.batch' => array('rule' => 'noimport')
);

$this->import_examplevalues_array[$r] = array(
'ps.fk_product' => "id or ref of product",
'ps.fk_entrepot' => "id or ref of warehouse",
'ps.reel' => "10",
'pl.batch' => "LOT12345"
);

$this->import_updatekeys_array[$r] = array(
'ps.fk_product' => 'Product',
'ps.fk_entrepot' => "Warehouse",
'pl.batch' => "Batch Number"
);

$this->import_run_sql_after_array[$r] = array(
// Mettre à jour le stock total du produit
'UPDATE '.MAIN_DB_PREFIX.'product as p SET stock = (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);',
);


}


Expand Down
4 changes: 2 additions & 2 deletions htdocs/imports/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,6 @@
'lib' => implode("<br>", array_merge([$hookmanager->error], $hookmanager->errors))
];
}

if (empty($reshook)) {
// Run import
$result = $obj->import_insert($arrayrecord, $array_match_file_to_database, $objimport, count($fieldssource), $importid, $updatekeys);
Expand Down Expand Up @@ -1951,7 +1950,9 @@
$i = 0;
foreach ($objimport->array_import_run_sql_after[0] as $sqlafterimport) {
$i++;
print $sqlafterimport . '<br>';
$resqlafterimport = $db->query($sqlafterimport);
var_dump($resqlafterimport);
if (!$resqlafterimport) {
$arrayoferrors['none'][] = array('lib' => $langs->trans("Error running final request: ".$sqlafterimport));
$error++;
Expand Down Expand Up @@ -1979,7 +1980,6 @@
}

// Show Errors
//var_dump($arrayoferrors);
if (count($arrayoferrors)) {
print img_error().' <b>'.$langs->trans("ErrorsOnXLines", count($arrayoferrors)).'</b><br>';
print '<table width="100%" class="border"><tr><td>';
Expand Down
1 change: 0 additions & 1 deletion htdocs/product/class/product.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3012,7 +3012,6 @@ public function fetch($id = 0, $ref = '', $ref_ext = '', $barcode = '', $ignore_
$sql .= ", p.stock";
}
}

$resql = $this->db->query($sql);
if ($resql) {
unset($this->oldcopy);
Expand Down