Skip to content

Commit

Permalink
#1449 [Hook] fix: remove globalcard
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Aug 14, 2023
1 parent 86aa0a8 commit 166b6fe
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 30 deletions.
55 changes: 26 additions & 29 deletions class/actions_digiquali.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,26 +267,21 @@ public function printCommonFooter($parameters)
jQuery('.fichecenter').last().after(<?php echo json_encode($out) ; ?>)
</script>
<?php
} elseif ($parameters['currentcontext'] == 'globalcard') {
if (preg_match('/productlotcard/', $parameters['context'])) {

$productLot = new ProductLot($this->db);
$productLot->fetch(GETPOST('id'));
$objectB64 = $productLot->array_options['options_control_history_link'];
$publicControlInterfaceUrl = dol_buildpath('custom/digiquali/public/control/public_control_history.php?track_id=' . $objectB64, 3);

$out = showValueWithClipboardCPButton($publicControlInterfaceUrl, 0, '&nbsp;');
$out .= '<a target="_blank" href="'. $publicControlInterfaceUrl .'"><div class="butAction">';
$out .= '<i class="fa fa-external-link"></i>';
$out .= '</div></a>';

?>
<script>
$('[class*=extras_control_history_link]').html(<?php echo json_encode($out) ?>);
</script>
<?php
}

} elseif ($parameters['currentcontext'] == 'productlotcard') {
$productLot = new ProductLot($this->db);
$productLot->fetch(GETPOST('id'));
$objectB64 = $productLot->array_options['options_control_history_link'];
$publicControlInterfaceUrl = dol_buildpath('custom/digiquali/public/control/public_control_history.php?track_id=' . $objectB64, 3);

$out = showValueWithClipboardCPButton($publicControlInterfaceUrl, 0, '&nbsp;');
$out .= '<a target="_blank" href="'. $publicControlInterfaceUrl .'"><div class="butAction">';
$out .= '<i class="fa fa-external-link"></i>';
$out .= '</div></a>'; ?>

<script>
$('[class*=extras_control_history_link]').html(<?php echo json_encode($out) ?>);
</script>
<?php
}

if (!$error) {
Expand All @@ -298,19 +293,21 @@ public function printCommonFooter($parameters)
}
}

public function formObjectOptions($parameters, $object, $options) {
global $langs, $user;

if ($parameters['currentcontext'] == 'globalcard' && preg_match('/productlotcard/', $parameters['context'])) {
$objectData = [
'type' => $object->element,
'id' => $object->id
];
/**
* Overloading the formObjectOptions function : replacing the parent's function with the one below
*
* @param array $parameters Hook metadata (context, etc...)
* @param object $object Object
* @return void
*/
public function formObjectOptions(array $parameters, object $object) {
if ($parameters['currentcontext'] == 'productlotcard') {
$objectData = ['type' => $object->element, 'id' => $object->id];

$objectDataJson = json_encode($objectData);
$objectDataB64 = base64_encode($objectDataJson);

if (dol_strlen($object)->array_options['options_control_history_link'] == 0 ) {
if (dol_strlen($object->array_options['options_control_history_link'] == 0 )) {
$object->array_options['options_control_history_link'] = $objectDataB64;
$object->update($user, 1);
}
Expand Down
1 change: 0 additions & 1 deletion core/modules/modDigiQuali.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ public function __construct($db)
'publiccontrol',
'publicsurvey',
'digiqualiadmindocuments',
'globalcard',
'productlotcard'
],
// Set this to 1 if features of module are opened to external users
Expand Down

0 comments on commit 166b6fe

Please sign in to comment.