Skip to content

Commit

Permalink
Add childproduct photo to childproduct list
Browse files Browse the repository at this point in the history
  • Loading branch information
fappels committed Sep 27, 2019
1 parent e264f12 commit c2e9adb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
11 changes: 6 additions & 5 deletions extdirect/class/ExtDirectCommande.class.php
Expand Up @@ -874,7 +874,7 @@ public function readOrderLine(stdClass $params)
} else {
$row->warehouse_id = $warehouse_id;
array_push($results, $row);
$myprod->fetchSubProducts($results, clone $row);
$myprod->fetchSubProducts($results, clone $row, $photoSize);
}
} else {
// get orderline with stock of warehouse
Expand Down Expand Up @@ -938,9 +938,9 @@ public function readOrderLine(stdClass $params)
$row->is_sub_product = false;
if (empty($conf->productbatch->enabled) || empty($line_warehouse_id)) {
array_push($results, $row);
$myprod->fetchSubProducts($results, clone $row);
$myprod->fetchSubProducts($results, clone $row, $photoSize);
} else {
if (($res = $myprod->fetchBatches($results, $row, $line->rowid, $line_warehouse_id, $myprod->stock_warehouse[$line_warehouse_id]->id)) < 0) return $res;
if (($res = $myprod->fetchBatches($results, $row, $line->rowid, $line_warehouse_id, $myprod->stock_warehouse[$line_warehouse_id]->id, false, null, '', $photoSize)) < 0) return $res;
}
}
} else {
Expand Down Expand Up @@ -1001,9 +1001,10 @@ public function readOrderLine(stdClass $params)
$row->is_sub_product = false;
if (empty($conf->productbatch->enabled)) {
array_push($results, $row);
$myprod->fetchSubProducts($results, clone $row);
$myprod->fetchSubProducts($results, clone $row, $photoSize);
$myprod->fetch($line->fk_product);
} else {
if (($res = $myprod->fetchBatches($results, $row, $line->rowid, $warehouse, $stock_warehouse->id)) < 0) return $res;
if (($res = $myprod->fetchBatches($results, $row, $line->rowid, $warehouse, $stock_warehouse->id, false, null, '', $photoSize)) < 0) return $res;
}
}
}
Expand Down
11 changes: 8 additions & 3 deletions extdirect/class/ExtDirectProduct.class.php
Expand Up @@ -1480,7 +1480,7 @@ private function fetchIdFromBarcode($barcode)
*
* @return int < 0 if error > 0 if OK
*/
public function fetchBatches(&$results,$row,$id,$warehouseId,$productStockId,$includeNoBatch = false, $batchId = null, $batchValue = '') {
public function fetchBatches(&$results,$row,$id,$warehouseId,$productStockId,$includeNoBatch = false, $batchId = null, $batchValue = '', $photoFormat = '') {
require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
$batches = array();
$batchesQty = 0;
Expand Down Expand Up @@ -1526,7 +1526,8 @@ public function fetchBatches(&$results,$row,$id,$warehouseId,$productStockId,$in
$num++;
$row->is_sub_product = false;
array_push($results, clone $row);
$this->fetchSubProducts($results, $row);
$this->fetchSubProducts($results, $row, $photoFormat);
$this->fetch($product_id);
}

if ($includeNoBatch && (!empty($stockQty) || !empty($productStockId)) && isset($row->id) && isset($row->batch_id)) {
Expand Down Expand Up @@ -1736,7 +1737,7 @@ public function fetchBarcodeWithChecksum()
*
* @return void
*/
public function fetchSubProducts(&$results, $row) {
public function fetchSubProducts(&$results, $row, $photoFormat = '') {
global $conf;

if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) {
Expand All @@ -1755,6 +1756,10 @@ public function fetchSubProducts(&$results, $row) {
$row->label = $rowLabel.' -> '.$value['fullpath'];
$row->qty_asked = $value['nb_total'];
$row->stock = $value['stock'];
$row->has_photo = 0;
$subProduct = new Product($this->db);
$subProduct->fetch($value['id']);
$this->fetchPhoto($row, $photoFormat, 0, $subProduct);
array_push($results, clone $row);
}
}
Expand Down
2 changes: 1 addition & 1 deletion extdirect/core/modules/modExtDirect.class.php
Expand Up @@ -61,7 +61,7 @@ function __construct($db)
// not found (where XXX is value of numeric property 'numero' of module)
$this->description = "Connect to external applications which use Sencha Ext.direct";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = '1.0.51';
$this->version = '1.0.52.beta';
// Key used in llx_const table to save module status enabled/disabled
// (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
Expand Down

0 comments on commit c2e9adb

Please sign in to comment.