Skip to content

Commit

Permalink
add missing hook in propal contact and document
Browse files Browse the repository at this point in the history
  • Loading branch information
FHenry committed Aug 1, 2024
1 parent dc58a90 commit 4fcf67b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
37 changes: 19 additions & 18 deletions htdocs/comm/propal/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@

// Load Dolibarr environment
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/propal.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';

// Load translation files required by the page
$langs->loadLangs(array('facture', 'propal', 'orders', 'sendings', 'companies'));
Expand All @@ -58,7 +58,7 @@
if (!$error) {
$object->fetch_thirdparty();
} else {
header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php');
header('Location: ' . DOL_URL_ROOT . '/comm/propal/list.php');
exit;
}

Expand All @@ -67,7 +67,8 @@
if (!empty($user->socid)) {
$socid = $user->socid;
}
restrictedArea($user, 'propal', $object->id);
$result = restrictedArea($user, 'propal', $object->id);
$hookmanager->initHooks(array('proposalcontactcard', 'globalcard'));

$usercancreate = $user->hasRight("propal", "creer");

Expand All @@ -76,6 +77,7 @@
* Add a new contact
*/

// Add new contact
if ($action == 'addcontact' && $user->hasRight('propal', 'creer')) {
if ($object->id > 0) {
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
Expand All @@ -84,7 +86,7 @@
}

if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id);
exit;
} else {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
Expand All @@ -104,18 +106,17 @@
$result = $object->delete_contact($lineid);

if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id);
exit;
} else {
dol_print_error($db);
}
}


/*
* View
*/
$title = $object->ref." - ".$langs->trans('ContactsAddresses');
$title = $object->ref . " - " . $langs->trans('ContactsAddresses');
$help_url = "EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos";

llxHeader('', $title, $help_url);
Expand All @@ -131,32 +132,32 @@

// Proposal card

$linkback = '<a href="'.DOL_URL_ROOT.'/comm/propal/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';


$morehtmlref = '<div class="refidno">';
// Ref customer
$morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
$morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer');
$morehtmlref .= '<br>' . $object->thirdparty->getNomUrl(1, 'customer');
// Project
if (isModEnabled('project')) {
$langs->load("projects");
$morehtmlref .= '<br>';
if (0) {
$morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
$morehtmlref .= '<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token=' . newToken() . '&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> ';
}
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
} else {
if (!empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref .= $proj->getNomUrl(1);
if ($proj->title) {
$morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
$morehtmlref .= '<span class="opacitymedium"> - ' . dol_escape_htmltag($proj->title) . '</span>';
}
}
}
Expand All @@ -171,7 +172,7 @@
// Contacts lines (modules that overwrite templates must declare this into descriptor)
$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
foreach ($dirtpls as $reldir) {
$res = @include dol_buildpath($reldir.'/contacts.tpl.php');
$res = @include dol_buildpath($reldir . '/contacts.tpl.php');
if ($res) {
break;
}
Expand Down
3 changes: 3 additions & 0 deletions htdocs/comm/propal/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
if (!empty($user->socid)) {
$socid = $user->socid;
}

$hookmanager->initHooks(array('propaldocument', 'globalcard'));

restrictedArea($user, 'propal', $object->id);

$usercancreate = $user->hasRight("propal", "creer");
Expand Down

0 comments on commit 4fcf67b

Please sign in to comment.