Shop Url in Produkt Karte hinzugefügt
This commit is contained in:
parent
834a5204bc
commit
393a2a4be6
3 changed files with 66 additions and 0 deletions
2
.idea/.gitignore
vendored
2
.idea/.gitignore
vendored
|
|
@ -6,3 +6,5 @@
|
|||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
/data_source_mapping.xml
|
||||
/dataSources.xml
|
||||
|
|
|
|||
|
|
@ -511,4 +511,67 @@ class ActionsSupplierLink3 extends CommonHookActions
|
|||
return 0;
|
||||
}
|
||||
|
||||
public function formObjectOptions($parameters, &$object, &$action)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (strpos($parameters['context'], 'productcard') === false) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($action != 'create' && $action != 'edit') {
|
||||
|
||||
$sql = "SELECT DISTINCT pfp.ref_fourn, pfp.quantity, pfp.price, s.nom, se.shop_url
|
||||
FROM ".MAIN_DB_PREFIX."product_fournisseur_price pfp
|
||||
INNER JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = pfp.fk_soc
|
||||
INNER JOIN ".MAIN_DB_PREFIX."societe_extrafields se ON se.fk_object = pfp.fk_soc
|
||||
WHERE pfp.fk_product = ".(int)$object->id."
|
||||
AND se.shop_url IS NOT NULL
|
||||
AND se.shop_url != ''
|
||||
ORDER BY pfp.price ASC";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
$links = array();
|
||||
$minPrice = null;
|
||||
|
||||
// Ersten Durchlauf: günstigsten Preis finden
|
||||
if ($resql) {
|
||||
$results = array();
|
||||
while ($obj = $db->fetch_object($resql)) {
|
||||
$results[] = $obj;
|
||||
if ($minPrice === null || $obj->price < $minPrice) {
|
||||
$minPrice = $obj->price;
|
||||
}
|
||||
}
|
||||
|
||||
// Zweiter Durchlauf: Links bauen
|
||||
foreach ($results as $obj) {
|
||||
$shortName = explode(' ', $obj->nom)[0];
|
||||
$tooltip = '<b><u>'.$obj->nom.'</u></b><br><b>Artikel-Nr:</b> '.$obj->ref_fourn.'<br><b>Preis:</b> '.round($obj->price,2).' EUR<br><b>Mindestmenge: </b>'.$obj->quantity;
|
||||
|
||||
// Günstigster Lieferant wird fett
|
||||
$displayText = $shortName.' ('.$obj->ref_fourn.')';
|
||||
if ($obj->price == $minPrice) {
|
||||
$displayText = '<b>'.$displayText.'</b>';
|
||||
}
|
||||
|
||||
$links[] = '<a href="'.dol_escape_htmltag($obj->shop_url).$obj->ref_fourn.'" target="_blank" class="classfortooltip" title="'.$tooltip.'">'.$displayText.'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($links)) {
|
||||
$linksHtml = implode(' | ', $links);
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
var linksDiv = '<div class="refidno opacitymedium" style="font-size: 12px;"><?php echo addslashes($linksHtml); ?></div>';
|
||||
$('.refidno').last().after(linksDiv);
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ class modSupplierLink3 extends DolibarrModules
|
|||
'data' => array(
|
||||
'ordersuppliercard',
|
||||
'ordercard',
|
||||
'productcard',
|
||||
),
|
||||
'entity' => '0',
|
||||
),
|
||||
|
|
|
|||
Loading…
Reference in a new issue