Merge branch 'NEW_contact_project_tab' of github.com:atm-quentin/dolibarr into NEW_contact_project_tab

This commit is contained in:
Quentin VIAL-GOUTEYRON 2022-01-07 10:18:57 +01:00
commit 137371cae5
2 changed files with 65 additions and 68 deletions

View File

@ -40,8 +40,8 @@ $hookmanager->initHooks(array('projectcontact'));
$parameters = array('id' => $id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
/*
@ -50,67 +50,66 @@ if($reshook < 0) {
$form = new Form($db);
if($id) {
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php';
if ($id) {
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php';
$object = new Contact($db);
$object = new Contact($db);
$result = $object->fetch($id);
if(empty($object->thirdparty)) {
$object->fetch_thirdparty();
}
$socid = $object->thirdparty->id;
$title = $langs->trans("Projects");
if(! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $object->name." - ".$title;
}
llxHeader('', $title);
$result = $object->fetch($id);
if (empty($object->thirdparty)) {
$object->fetch_thirdparty();
}
$socid = $object->thirdparty->id;
$title = $langs->trans("Projects");
if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $object->name." - ".$title;
}
llxHeader('', $title);
if(! empty($conf->notification->enabled)) {
$langs->load("mails");
}
$head = contact_prepare_head($object);
if (! empty($conf->notification->enabled)) {
$langs->load("mails");
}
$head = contact_prepare_head($object);
print dol_get_fiche_head($head, 'project', $langs->trans("Contact"), -1, 'contact');
print dol_get_fiche_head($head, 'project', $langs->trans("Contact"), -1, 'contact');
$linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refidno">';
if(empty($conf->global->SOCIETE_DISABLE_CONTACTS) && !empty($socid)) {
$object->thirdparty->fetch($socid);
// Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : ';
if($object->thirdparty->id > 0) {
$morehtmlref .= $object->thirdparty->getNomUrl(1, 'contact');
}
else {
$morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
}
}
$morehtmlref .= '</div>';
$morehtmlref = '<div class="refidno">';
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS) && !empty($socid)) {
$object->thirdparty->fetch($socid);
// Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : ';
if ($object->thirdparty->id > 0) {
$morehtmlref .= $object->thirdparty->getNomUrl(1, 'contact');
} else {
$morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
}
}
$morehtmlref .= '</div>';
dol_banner_tab($object, 'id', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', $morehtmlref);
dol_banner_tab($object, 'id', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">';
// Civility
print '<tr><td class="titlefield">'.$langs->trans("UserTitle").'</td><td>';
print $object->getCivilityLabel();
print '</td></tr>';
// Civility
print '<tr><td class="titlefield">'.$langs->trans("UserTitle").'</td><td>';
print $object->getCivilityLabel();
print '</td></tr>';
print '</table>';
print '</table>';
print '</div>';
print '</div>';
print dol_get_fiche_end();
print '<br>';
print dol_get_fiche_end();
print '<br>';
// Projects list
$result = show_contacts_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?id='.$object->id, 1);
// Projects list
$result = show_contacts_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?id='.$object->id, 1);
}
// End of page

View File

@ -57,7 +57,7 @@ function contact_prepare_head(Contact $object)
$head[$tab][2] = 'perso';
$tab++;
if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) {
if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) {
$nbProject = 0;
// Enable caching of thirdrparty count projects
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
@ -67,12 +67,12 @@ function contact_prepare_head(Contact $object)
if (!is_null($dataretrieved)) {
$nbProject = $dataretrieved;
} else {
$sql = 'SELECT COUNT(n.rowid) as nb';
$sql .= ' FROM '.MAIN_DB_PREFIX.'projet as n';
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact as cc ON (n.rowid = cc.element_id)';
$sql .= ' WHERE cc.fk_socpeople = '.((int) $object->id);
$sql .= ' AND cc.fk_c_type_contact IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE element="project" AND source="external")';
$sql .= ' AND n.entity IN ('.getEntity('project').')';
$sql = 'SELECT COUNT(n.rowid) as nb';
$sql .= ' FROM '.MAIN_DB_PREFIX.'projet as n';
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact as cc ON (n.rowid = cc.element_id)';
$sql .= ' WHERE cc.fk_socpeople = '.((int) $object->id);
$sql .= ' AND cc.fk_c_type_contact IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE element="project" AND source="external")';
$sql .= ' AND n.entity IN ('.getEntity('project').')';
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
@ -184,15 +184,15 @@ function show_contacts_projects($conf, $langs, $db, $object, $backtopage = '', $
print "\n".'<table class="noborder" width=100%>';
$sql = 'SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount';
$sql .= ', cls.code as opp_status_code, ctc.libelle';
$sql .= ' FROM '.MAIN_DB_PREFIX.'projet as p';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls on p.fk_opp_status = cls.rowid';
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact as cc ON (p.rowid = cc.element_id)';
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_contact as ctc ON (ctc.rowid = cc.fk_c_type_contact)';
$sql .= ' WHERE cc.fk_socpeople = '.((int) $object->id);
$sql .= ' AND ctc.element="project" AND ctc.source="external"';
$sql .= ' AND p.entity IN ('.getEntity('project').')';
$sql .= ' ORDER BY p.dateo DESC';
$sql .= ', cls.code as opp_status_code, ctc.libelle';
$sql .= ' FROM '.MAIN_DB_PREFIX.'projet as p';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls on p.fk_opp_status = cls.rowid';
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact as cc ON (p.rowid = cc.element_id)';
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_contact as ctc ON (ctc.rowid = cc.fk_c_type_contact)';
$sql .= ' WHERE cc.fk_socpeople = '.((int) $object->id);
$sql .= ' AND ctc.element="project" AND ctc.source="external"';
$sql .= ' AND p.entity IN ('.getEntity('project').')';
$sql .= ' ORDER BY p.dateo DESC';
$result = $db->query($sql);
if ($result) {
@ -201,7 +201,6 @@ function show_contacts_projects($conf, $langs, $db, $object, $backtopage = '', $
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Ref").'</td>';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("ContactType").'</td>';
print '<td class="center">'.$langs->trans("DateStart").'</td>';
print '<td class="center">'.$langs->trans("DateEnd").'</td>';
print '<td class="right">'.$langs->trans("OpportunityAmountShort").'</td>';
@ -234,7 +233,6 @@ function show_contacts_projects($conf, $langs, $db, $object, $backtopage = '', $
// Label
print '<td>'.$obj->title.'</td>';
print '<td>'.$obj->libelle.'</td>';
// Date start
print '<td class="center">'.dol_print_date($db->jdate($obj->do), "day").'</td>';
// Date end
@ -278,4 +276,4 @@ function show_contacts_projects($conf, $langs, $db, $object, $backtopage = '', $
}
return $i;
}
}