Skip to content
Snippets Groups Projects
Commit 3015a038 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

NEW List of projects of a thirdparty are visible on a project tab

parent 016dbd39
No related branches found
No related tags found
No related merge requests found
......@@ -91,6 +91,13 @@ function societe_prepare_head(Societe $object)
$head[$h][2] = 'agenda';
$h++;
}
if (! empty($conf->projet->enabled) && (!empty($user->rights->projet->lire) ))
{
$head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Projects");
$head[$h][2] = 'project';
$h++;
}
//show categorie tab
/*if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
{
......@@ -456,9 +463,10 @@ function getFormeJuridiqueLabel($code)
* @param DoliDB $db Database handler
* @param Object $object Third party object
* @param string $backtopage Url to go once contact is created
* @param int $nocreatelink 1=Hide create project link
* @return void
*/
function show_projects($conf,$langs,$db,$object,$backtopage='')
function show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelink=0)
{
global $user;
global $bc;
......@@ -470,7 +478,7 @@ function show_projects($conf,$langs,$db,$object,$backtopage='')
$langs->load("projects");
$buttoncreate='';
if (! empty($conf->projet->enabled) && $user->rights->projet->creer)
if (! empty($conf->projet->enabled) && $user->rights->projet->creer && empty($nocreatelink))
{
//$buttoncreate='<a class="butAction" href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$object->id.'&action=create&amp;backtopage='.urlencode($backtopage).'">'.$langs->trans("AddProject").'</a>';
$buttoncreate='<a class="addnewrecord" href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$object->id.'&amp;action=create&amp;backtopage='.urlencode($backtopage).'">'.$langs->trans("AddProject");
......@@ -864,13 +872,13 @@ function show_addresses($conf,$langs,$db,$object,$backtopage='')
/**
* Show html area with actions to do
*
* @param Conf $conf Object conf
* @param Translate $langs Object langs
* @param DoliDB $db Object db
* @param Adherent|Societe $object Object third party or member
* @param Contact $objcon Object contact
* @param int $noprint Return string but does not output it
* @return mixed Return html part or void if noprint is 1
* @param Conf $conf Object conf
* @param Translate $langs Object langs
* @param DoliDB $db Object db
* @param Adherent|Societe $object Object third party or member
* @param Contact $objcon Object contact
* @param int $noprint Return string but does not output it
* @return mixed Return html part or void if noprint is 1
*/
function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0)
{
......
......@@ -624,7 +624,7 @@ else
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
print '<td><input size="40" name="title" value="'.$object->title.'"></td></tr>';
// Customer
// Thirdparty
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
$filteronlist='';
if (! empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist=$conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST;
......@@ -713,7 +713,7 @@ else
// Third party
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
if ($object->thirdparty->id > 0) print $object->thirdparty->getNomUrl(1);
if ($object->thirdparty->id > 0) print $object->thirdparty->getNomUrl(1, 'project');
else print'&nbsp;';
print '</td></tr>';
......
......@@ -121,17 +121,34 @@ if ($socid)
dol_fiche_end();
/*
/*
* Barre d'action
*/
print '<div class="tabsAction">';
$objthirdparty=$object;
$objcon=new stdClass();
$out='';
$permok=$user->rights->agenda->myactions->create;
if ((! empty($objthirdparty->id) || ! empty($objcon->id)) && $permok)
{
//$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
if (get_class($objthirdparty) == 'Societe') $out.='&amp;socid='.$objthirdparty->id;
$out.=(! empty($objcon->id)?'&amp;contactid='.$objcon->id:'').'&amp;backtopage=1&amp;percentage=-1';
//$out.=$langs->trans("AddAnAction").' ';
//$out.=img_picto($langs->trans("AddAnAction"),'filenew');
//$out.="</a>";
}
print '<div class="tabsAction">';
if (! empty($conf->agenda->enabled))
{
if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create))
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&socid='.$socid.'">'.$langs->trans("AddAction").'</a>';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>';
}
else
{
......@@ -143,25 +160,11 @@ if ($socid)
print '<br>';
$objthirdparty=$object;
$objcon=new stdClass();
$out='';
$permok=$user->rights->agenda->myactions->create;
if ((! empty($objthirdparty->id) || ! empty($objcon->id)) && $permok)
{
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
if (get_class($objthirdparty) == 'Societe') $out.='&amp;socid='.$objthirdparty->id;
$out.=(! empty($objcon->id)?'&amp;contactid='.$objcon->id:'').'&amp;backtopage=1&amp;percentage=-1">';
$out.=$langs->trans("AddAnAction").' ';
$out.=img_picto($langs->trans("AddAnAction"),'filenew');
$out.="</a>";
}
print load_fiche_titre($langs->trans("ActionsOnCompany"),$out,'');
print load_fiche_titre($langs->trans("ActionsOnCompany"),'','');
// List of todo actions
show_actions_todo($conf,$langs,$db,$object);
show_actions_todo($conf,$langs,$db,$object,null,0,1);
// List of done actions
show_actions_done($conf,$langs,$db,$object);
......
......@@ -1747,12 +1747,12 @@ class Societe extends CommonObject
* Return a link on thirdparty (with picto)
*
* @param int $withpicto Add picto into link (0=No picto, 1=Include picto with link, 2=Picto only)
* @param string $option Target of link ('', 'customer', 'prospect', 'supplier')
* @param string $option Target of link ('', 'customer', 'prospect', 'supplier', 'project')
* @param int $maxlen Max length of name
* @param integer $notooltip 1=Disable tooltip
* @return string String with URL
*/
function getNomUrl($withpicto=0,$option='',$maxlen=0,$notooltip=0)
function getNomUrl($withpicto=0, $option='', $maxlen=0, $notooltip=0)
{
global $conf,$langs;
......@@ -1795,6 +1795,16 @@ class Societe extends CommonObject
$label.= '<u>' . $langs->trans("ShowSupplier") . '</u>';
$link = '<a href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$this->id;
}
else if ($option == 'agenda')
{
$label.= '<u>' . $langs->trans("ShowAgenda") . '</u>';
$link = '<a href="'.DOL_URL_ROOT.'/societe/agenda.php?socid='.$this->id;
}
else if ($option == 'project')
{
$label.= '<u>' . $langs->trans("ShowProject") . '</u>';
$link = '<a href="'.DOL_URL_ROOT.'/societe/project.php?socid='.$this->id;
}
else if ($option == 'category')
{
$label.= '<u>' . $langs->trans("ShowCategory") . '</u>';
......
......@@ -195,6 +195,8 @@ if ($result > 0)
print "\n";
print '<br>';
// Add notification form
print load_fiche_titre($langs->trans("AddNewNotification"),'','');
......
......@@ -429,107 +429,8 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
}
else
{
// View mode
// View mode
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter);
}
$result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
}
$option = '&search_soc=' . $search_soc . '&id=' . $object->id;
print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords);
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("Product") . '</td>';
print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
print '<td align="center">' . $langs->trans("PriceBase") . '</td>';
print '<td align="right">' . $langs->trans("VAT") . '</td>';
print '<td align="right">' . $langs->trans("HT") . '</td>';
print '<td align="right">' . $langs->trans("TTC") . '</td>';
print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>';
print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>';
print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
print '<td>&nbsp;</td>';
print '</tr>';
if (count($prodcustprice->lines) > 0) {
print '<tr class="liste_titre">';
print '<td><input type="text" class="flat" name="search_soc" value="' . $search_soc . '" size="20"></td>';
print '<td colspan="8">&nbsp;</td>';
// Print the search button
print '<td class="liste_titre" align="right">';
print '<input class="liste_titre" name="button_search" type="image" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
print '</td>';
print '</tr>';
$var = False;
foreach($prodcustprice->lines as $line)
{
print "<tr ".$bc[$var].">";
$staticprod = new Product($db);
$staticprod->fetch($line->fk_product);
print "<td>" . $staticprod->getNomUrl(1) . "</td>";
print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>";
print '<td align="right">' . price($line->price) . "</td>";
print '<td align="right">' . price($line->price_ttc) . "</td>";
print '<td align="right">' . price($line->price_min) . '</td>';
print '<td align="right">' . price($line->price_min_ttc) . '</td>';
// User
$userstatic = new User($db);
$userstatic->fetch($line->fk_user);
print '<td align="right">';
print $userstatic->getLoginUrl(1);
print '</td>';
// Todo Edit or delete button
// Action
if ($user->rights->produit->creer || $user->rights->service->creer) {
print '<td align="right">';
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=showlog_customer_price&amp;socid=' . $object->id . '&amp;prodid=' . $line->fk_product . '">';
print img_info();
print '</a>';
print ' ';
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=edit_customer_price&amp;socid=' . $object->id . '&amp;lineid=' . $line->id . '">';
print img_edit('default', 0, 'style="vertical-align: middle;"');
print '</a>';
print ' ';
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=delete_customer_price&amp;socid=' . $object->id . '&amp;lineid=' . $line->id . '">';
print img_delete('default', 'style="vertical-align: middle;"');
print '</a>';
print '</td>';
}
print "</tr>\n";
}
} else {
print '<tr '.$bc[false].'><td colspan="10">'.$langs->trans('NoPriceSpecificToCustomer').'</td></tr>';
}
print "</table>";
print "</form>";
/* ************************************************************************** */
/* */
/* Barre d'action */
......@@ -541,7 +442,112 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
if ($user->rights->produit->creer || $user->rights->service->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=add_customer_price&amp;socid=' . $object->id . '">' . $langs->trans("AddCustomerPrice") . '</a></div>';
}
print "\n</div><br>\n";
print "\n</div>\n";
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter);
}
$result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0)
{
setEventMessage($prodcustprice->error, 'errors');
}
$option = '&search_soc=' . $search_soc . '&id=' . $object->id;
print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVEUR['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, '');
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("Product") . '</td>';
print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
print '<td align="center">' . $langs->trans("PriceBase") . '</td>';
print '<td align="right">' . $langs->trans("VAT") . '</td>';
print '<td align="right">' . $langs->trans("HT") . '</td>';
print '<td align="right">' . $langs->trans("TTC") . '</td>';
print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>';
print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>';
print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
print '<td>&nbsp;</td>';
print '</tr>';
if (count($prodcustprice->lines) > 0)
{
print '<tr class="liste_titre">';
print '<td><input type="text" class="flat" name="search_soc" value="' . $search_soc . '" size="20"></td>';
print '<td colspan="8">&nbsp;</td>';
// Print the search button
print '<td class="liste_titre" align="right">';
print '<input class="liste_titre" name="button_search" type="image" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
print '</td>';
print '</tr>';
$var = False;
foreach ($prodcustprice->lines as $line)
{
print "<tr " . $bc[$var] . ">";
$staticprod = new Product($db);
$staticprod->fetch($line->fk_product);
print "<td>" . $staticprod->getNomUrl(1) . "</td>";
print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>";
print '<td align="right">' . price($line->price) . "</td>";
print '<td align="right">' . price($line->price_ttc) . "</td>";
print '<td align="right">' . price($line->price_min) . '</td>';
print '<td align="right">' . price($line->price_min_ttc) . '</td>';
// User
$userstatic = new User($db);
$userstatic->fetch($line->fk_user);
print '<td align="right">';
print $userstatic->getLoginUrl(1);
print '</td>';
// Todo Edit or delete button
// Action
if ($user->rights->produit->creer || $user->rights->service->creer)
{
print '<td align="right">';
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=showlog_customer_price&amp;socid=' . $object->id . '&amp;prodid=' . $line->fk_product . '">';
print img_info();
print '</a>';
print ' ';
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=edit_customer_price&amp;socid=' . $object->id . '&amp;lineid=' . $line->id . '">';
print img_edit('default', 0, 'style="vertical-align: middle;"');
print '</a>';
print ' ';
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=delete_customer_price&amp;socid=' . $object->id . '&amp;lineid=' . $line->id . '">';
print img_delete('default', 'style="vertical-align: middle;"');
print '</a>';
print '</td>';
}
print "</tr>\n";
}
} else
{
print '<tr ' . $bc[false] . '><td colspan="10">' . $langs->trans('NoPriceSpecificToCustomer') . '</td></tr>';
}
print "</table>";
print "</form>";
}
}
......
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Brice Davoleau <brice.davoleau@gmail.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/societe/project.php
* \ingroup societe
* \brief Page of third party projects
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$langs->load("companies");
// Security check
$socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe', $socid, '&societe');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('projectthirdparty'));
/*
* Actions
*/
$parameters=array('id'=>$socid);
$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');
/*
* View
*/
$contactstatic = new Contact($db);
$form = new Form($db);
if ($socid)
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$langs->load("companies");
$object = new Societe($db);
$result = $object->fetch($socid);
$title=$langs->trans("Agenda");
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 = societe_prepare_head($object);
dol_fiche_head($head, 'project', $langs->trans("ThirdParty"),0,'company');
dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
// Alias names (commercial, trademark or alias names)
print '<tr><td class="titlefield">'.$langs->trans('AliasNames').'</td><td colspan="3">';
print $object->name_alias;
print "</td></tr>";
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
}
if ($object->client)
{
print '<tr><td>';
print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $object->code_client;
if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
print '</td></tr>';
}
if ($object->fournisseur)
{
print '<tr><td>';
print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $object->code_fournisseur;
if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
print '</td></tr>';
}
print '</table>';
print '</div>';
dol_fiche_end();
/*
* Barre d'action
*/
print '<div class="tabsAction">';
if (! empty($conf->projet->enabled))
{
if (! empty($conf->projet->enabled) && ! empty($user->rights->projet->creer))
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$object->id.'&amp;backtopage='.urlencode($backtopage).'">'.$langs->trans("AddProject").'</a>';
}
else
{
print '<a class="butActionRefused" href="#">'.$langs->trans("AddProject").'</a>';
}
}
print '</div>';
print '<br>';
// Projects list
$result=show_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1);
}
llxFooter();
$db->close();
......@@ -2481,9 +2481,6 @@ else
{
$result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
}
// Projects list
$result=show_projects($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment