Skip to content

Commit

Permalink
Merge branch 'develop' into enhance-stars-extrafields-and-alwayseditable
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy authored Nov 18, 2024
2 parents 987b720 + 1a9722c commit d864eab
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 25 deletions.
2 changes: 1 addition & 1 deletion htdocs/core/class/commonobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4292,7 +4292,7 @@ public function getElementType()
*/
public function fetchObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $clause = 'OR', $alsosametype = 1, $orderby = 'sourcetype', $loadalsoobjects = 1)
{
global $conf, $hookmanager, $action;
global $hookmanager, $action;

// Important for pdf generation time reduction
// This boolean is true if $this->linkedObjects has already been loaded with all objects linked without filter
Expand Down
64 changes: 44 additions & 20 deletions htdocs/core/class/html.form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9698,10 +9698,12 @@ public function showLinkedObjectBlock($object, $morehtmlright = '', $compatibleI
*/
public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excludelinksto = array(), $nooutput = 0)
{
global $conf, $langs, $hookmanager;
global $conf, $langs, $hookmanager, $form;
global $action;

$form = new Form($this->db);
if (empty($form)) {
$form = new Form($this->db);
}

$linktoelem = '';
$linktoelemlist = '';
Expand All @@ -9711,21 +9713,22 @@ public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excl
$object->fetch_thirdparty();
}

$object->fetchObjectLinked();
$possiblelinks = array();

$dontIncludeCompletedItems = getDolGlobalString('DONT_INCLUDE_COMPLETED_ELEMENTS_LINKS');

if (is_object($object->thirdparty) && !empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
$listofidcompanytoscan = $object->thirdparty->id;
$listofidcompanytoscan = (int) $object->thirdparty->id;
if (($object->thirdparty->parent > 0) && getDolGlobalString('THIRDPARTY_INCLUDE_PARENT_IN_LINKTO')) {
$listofidcompanytoscan .= ',' . $object->thirdparty->parent;
$listofidcompanytoscan .= ',' . (int) $object->thirdparty->parent;
}
if (($object->fk_project > 0) && getDolGlobalString('THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO')) {
include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
$tmpproject = new Project($this->db);
$tmpproject->fetch($object->fk_project);
if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) {
$listofidcompanytoscan .= ',' . $tmpproject->socid;
$listofidcompanytoscan .= ',' . (int) $tmpproject->socid;
}
unset($tmpproject);
}
Expand All @@ -9735,63 +9738,76 @@ public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excl
'enabled' => isModEnabled('propal'),
'perms' => 1,
'label' => 'LinkToProposal',
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('propal') . ')'.($dontIncludeCompletedItems ? ' AND t.fk_statut < 4' : '')),
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('propal') . ')'.($dontIncludeCompletedItems ? ' AND t.fk_statut < 4' : ''),
),
'shipping' => array(
'enabled' => isModEnabled('shipping'),
'perms' => 1,
'label' => 'LinkToExpedition',
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "expedition as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('shipping') . ')'.($dontIncludeCompletedItems ? ' AND t.fk_statut < 2' : '')),
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "expedition as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('shipping') . ')'.($dontIncludeCompletedItems ? ' AND t.fk_statut < 2' : ''),
),
'order' => array(
'enabled' => isModEnabled('order'),
'perms' => 1,
'label' => 'LinkToOrder',
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('commande') . ')'.($dontIncludeCompletedItems ? ' AND t.facture < 1' : '')),
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('commande') . ')'.($dontIncludeCompletedItems ? ' AND t.facture < 1' : ''),
'linkname' => 'commande',
),
'invoice' => array(
'enabled' => isModEnabled('invoice'),
'perms' => 1,
'label' => 'LinkToInvoice',
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('invoice') . ')'.($dontIncludeCompletedItems ? ' AND t.paye < 1' : '')),
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('invoice') . ')'.($dontIncludeCompletedItems ? ' AND t.paye < 1' : ''),
'linkname' => 'facture',
),
'invoice_template' => array(
'enabled' => isModEnabled('invoice'),
'perms' => 1,
'label' => 'LinkToTemplateInvoice',
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('invoice') . ')'.($dontIncludeCompletedItems ? ' AND t.paye < 1' : '')),
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('invoice') . ')'.($dontIncludeCompletedItems ? ' AND t.paye < 1' : ''),
),
'contrat' => array(
'enabled' => isModEnabled('contract'),
'perms' => 1,
'label' => 'LinkToContract',
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht
FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "contrat as t, " . $this->db->prefix() . "contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('contract') . ') GROUP BY s.rowid, s.nom, s.client, t.rowid, t.ref, t.ref_customer, t.ref_supplier'
FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "contrat as t, " . $this->db->prefix() . "contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('contract') . ') GROUP BY s.rowid, s.nom, s.client, t.rowid, t.ref, t.ref_customer, t.ref_supplier',
),
'fichinter' => array(
'enabled' => isModEnabled('intervention'),
'perms' => 1,
'label' => 'LinkToIntervention',
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('intervention') . ')'),
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('intervention') . ')',
),
'supplier_proposal' => array(
'enabled' => isModEnabled('supplier_proposal'),
'perms' => 1,
'label' => 'LinkToSupplierProposal',
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('supplier_proposal') . ')'.($dontIncludeCompletedItems ? ' AND t.fk_statut < 4' : '')),
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('supplier_proposal') . ')'.($dontIncludeCompletedItems ? ' AND t.fk_statut < 4' : ''),
),
'order_supplier' => array(
'enabled' => isModEnabled("supplier_order"),
'perms' => 1,
'label' => 'LinkToSupplierOrder',
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('commande_fournisseur') . ')'.($dontIncludeCompletedItems ? ' AND t.billed < 1' : '')),
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('commande_fournisseur') . ')'.($dontIncludeCompletedItems ? ' AND t.billed < 1' : ''),
),
'invoice_supplier' => array(
'enabled' => isModEnabled("supplier_invoice"),
'perms' => 1, 'label' => 'LinkToSupplierInvoice',
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('facture_fourn') . ')'.($dontIncludeCompletedItems ? ' AND t.paye < 1' : '')),
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('facture_fourn') . ')'.($dontIncludeCompletedItems ? ' AND t.paye < 1' : ''),
),
'ticket' => array(
'enabled' => isModEnabled('ticket'),
'perms' => 1,
'label' => 'LinkToTicket',
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.track_id, '0' as total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "ticket as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('ticket') . ')'.($dontIncludeCompletedItems ? ' AND t.fk_statut < 8' : '')),
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.track_id, '0' as total_ht FROM " . $this->db->prefix() . "societe as s, " . $this->db->prefix() . "ticket as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('ticket') . ')'.($dontIncludeCompletedItems ? ' AND t.fk_statut < 8' : ''),
),
'mo' => array(
'enabled' => isModEnabled('mrp'),
'perms' => 1,
'label' => 'LinkToMo',
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.rowid, '0' as total_ht FROM " . $this->db->prefix() . "societe as s INNER JOIN " . $this->db->prefix() . "mrp_mo as t ON t.fk_soc = s.rowid WHERE t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('mo') . ')'.($dontIncludeCompletedItems ? ' AND t.status < 3' : ''))
'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.rowid, '0' as total_ht FROM " . $this->db->prefix() . "societe as s INNER JOIN " . $this->db->prefix() . "mrp_mo as t ON t.fk_soc = s.rowid WHERE t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) . ') AND t.entity IN (' . getEntity('mo') . ')'.($dontIncludeCompletedItems ? ' AND t.status < 3' : ''),
),
);
}

Expand Down Expand Up @@ -9823,7 +9839,6 @@ public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excl
$htmltoenteralink = '';
foreach ($possiblelinks as $key => $possiblelink) {
$num = 0;

if (empty($possiblelink['enabled'])) {
continue;
}
Expand Down Expand Up @@ -9879,10 +9894,19 @@ public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excl
$htmltoenteralink .= '</tr>';
while ($i < $num) {
$objp = $this->db->fetch_object($resqllist);

$alreadylinked = false;
if (!empty($object->linkedObjectsIds[$possiblelink['linkname'] ?? $key])) {
if (in_array($objp->rowid, array_values($object->linkedObjectsIds[$possiblelink['linkname'] ?? $key]))) {
$alreadylinked = true;
}
}
$htmltoenteralink .= '<tr class="oddeven">';
$htmltoenteralink .= '<td>';
$htmltoenteralink .= '<input type="checkbox" name="idtolinkto[' . $key . '_' . $objp->rowid . ']" id="' . $key . '_' . $objp->rowid . '" value="' . $objp->rowid . '">';
if ($alreadylinked) {
$htmltoenteralink .= img_picto('', 'link');
} else {
$htmltoenteralink .= '<input type="checkbox" name="idtolinkto[' . $key . '_' . $objp->rowid . ']" id="' . $key . '_' . $objp->rowid . '" value="' . $objp->rowid . '">';
}
$htmltoenteralink .= '</td>';
$htmltoenteralink .= '<td><label for="' . $key . '_' . $objp->rowid . '">' . $objp->ref . '</label></td>';
$htmltoenteralink .= '<td>' . (!empty($objp->ref_client) ? $objp->ref_client : (!empty($objp->ref_supplier) ? $objp->ref_supplier : '')) . '</td>';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/DolibarrModules.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,7 @@ public function insert_cronjobs()
$cronjob->command = $command;
$cronjob->params = $params;
$cronjob->md5params = $md5params;
$cronjob->comment = $comment;
$cronjob->note_private = $comment;
$cronjob->frequency = $frequency;
$cronjob->unitfrequency = $unitfrequency;
$cronjob->priority = $priority;
Expand Down
6 changes: 3 additions & 3 deletions htdocs/product/class/product.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2616,7 +2616,7 @@ public function get_buyprice($prodfournprice, $qty, $product_id = 0, $fourn_ref
/**
* Modify customer price of a product/Service for a given level
*
* @param double|string $newprice New price
* @param double $newprice New price
* @param string $newpricebase HT or TTC
* @param User $user Object user that make change
* @param ?float $newvat New VAT Rate (For example 8.5. Should not be a string)
Expand Down Expand Up @@ -2675,7 +2675,7 @@ public function updatePrice($newprice, $newpricebase, $user, $newvat = null, $ne
$price = (float) price2num($newprice) / (1 + ((float) $newvat / 100));
$price = (float) price2num($price, 'MU');

if ($newminprice != '' || $newminprice == 0) {
if ((string) $newminprice != '0') {
$price_min_ttc = (float) price2num($newminprice, 'MU');
$price_min = (float) price2num($newminprice) / (1 + ($newvat / 100));
$price_min = (float) price2num($price_min, 'MU');
Expand All @@ -2688,7 +2688,7 @@ public function updatePrice($newprice, $newpricebase, $user, $newvat = null, $ne
$price_ttc = ($newnpr != 1) ? (float) price2num($newprice) * (1 + ($newvat / 100)) : $price;
$price_ttc = (float) price2num($price_ttc, 'MU');

if ($newminprice !== '' || $newminprice == 0) {
if ((string) $newminprice != '0') {
$price_min = (float) price2num($newminprice, 'MU');
$price_min_ttc = (float) price2num($newminprice) * (1 + ($newvat / 100));
$price_min_ttc = (float) price2num($price_min_ttc, 'MU');
Expand Down

0 comments on commit d864eab

Please sign in to comment.