28require
"../../main.inc.php";
29require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
44$langs->loadLangs(array(
'projects',
'companies'));
48$action =
GETPOST(
'action',
'aZ09');
49$confirm =
GETPOST(
'confirm',
'alpha');
51$project_ref =
GETPOST(
'project_ref',
'alpha');
54$projectstatic =
new Project($db);
71if ($action ==
'addcontact' && $user->hasRight(
'projet',
'creer')) {
73 if (
GETPOST(
"addsourceexternal")) {
77 $result =
$object->fetch($id, $ref);
79 if ($result > 0 && $id > 0) {
80 if ($source ==
'internal') {
85 $typeid =
GETPOST(
'typecontact');
87 if ($idfortaskuser == -2) {
88 $result = $projectstatic->fetch(
$object->fk_project);
92 $contactsofproject = $projectstatic->getListContactId(
'internal');
93 foreach ($contactsofproject as $key => $val) {
94 $result =
$object->add_contact($val, $typeid, $source);
98 $result =
$object->add_contact($idfortaskuser, $typeid, $source);
103 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
$object->id.($withproject ?
'&withproject=1' :
''));
106 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
107 $langs->load(
"errors");
108 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
116if ($action ==
'swapstatut' && $user->hasRight(
'projet',
'creer')) {
117 if (
$object->fetch($id, $ref)) {
125if ($action ==
'deleteline' && $user->hasRight(
'projet',
'creer')) {
130 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
$object->id.($withproject ?
'&withproject=1' :
''));
138if (!empty($project_ref) && !empty($withproject)) {
139 if ($projectstatic->fetch(0, $project_ref) > 0) {
140 $tasksarray =
$object->getTasksArray(
null,
null, $projectstatic->id, $socid, 0);
141 if (count($tasksarray) > 0) {
142 $id = $tasksarray[0]->id;
144 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.($withproject ?
'&withproject=1' :
'').(empty($mode) ?
'' :
'&mode='.$mode));
153$form =
new Form($db);
155$contactstatic =
new Contact($db);
156$userstatic =
new User($db);
157$result = $projectstatic->fetch(
$object->fk_project);
159$title =
$object->ref .
' - ' . $langs->trans(
"Contacts");
160if (!empty($withproject)) {
161 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': '.$projectstatic->ref :
'') ;
165llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project project-tasks page-task_contact');
174if ($id > 0 || !empty($ref)) {
175 if (
$object->fetch($id, $ref) > 0) {
176 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
181 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
182 $projectstatic->fetchComments();
184 if (!empty($projectstatic->socid)) {
185 $projectstatic->fetch_thirdparty();
188 $object->project = clone $projectstatic;
190 $userWrite = $projectstatic->restrictedProjectArea($user,
'write');
196 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
198 $param = (!empty($mode) && $mode ==
'mine' ?
'&mode=mine' :
'');
202 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
204 $morehtmlref =
'<div class="refidno">';
206 $morehtmlref .= $projectstatic->title;
208 if (isset($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
209 $morehtmlref .=
'<br>'.$projectstatic->thirdparty->getNomUrl(1,
'project');
211 $morehtmlref .=
'</div>';
214 if (!$user->hasRight(
'projet',
'all',
'lire')) {
215 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
216 $projectstatic->next_prev_filter =
"rowid:IN:".$db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0');
219 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
221 print
'<div class="fichecenter">';
222 print
'<div class="fichehalfleft">';
223 print
'<div class="underbanner clearboth"></div>';
225 print
'<table class="border tableforfield centpercent">';
229 print
'<tr><td class="tdtop">';
230 print $langs->trans(
"Usage");
234 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
235 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
236 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
240 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')).
'"> ';
241 $htmltext = $langs->trans(
"ProjectFollowTasks");
242 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
246 print
'<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET(
'usage_bill_time') ? (
GETPOST(
'usage_bill_time',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_bill_time ?
' checked="checked"' :
'')).
'"> ';
247 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
248 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
251 if (isModEnabled(
'eventorganization')) {
252 print
'<input type="checkbox" disabled name="usage_organize_event"'.(GETPOSTISSET(
'usage_organize_event') ? (
GETPOST(
'usage_organize_event',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_organize_event ?
' checked="checked"' :
'')).
'"> ';
253 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
254 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
260 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
261 if (isset($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
262 print
price($projectstatic->budget_amount, 0, $langs, 1, 0, 0,
$conf->currency);
267 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
269 print($start ? $start :
'?');
272 print($end ? $end :
'?');
273 if ($projectstatic->hasDelay()) {
279 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
280 if ($projectstatic->public) {
281 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
282 print $langs->trans(
'SharedProject');
284 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
285 print $langs->trans(
'PrivateProject');
293 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
299 print
'<div class="fichehalfright">';
300 print
'<div class="underbanner clearboth"></div>';
302 print
'<table class="border tableforfield centpercent">';
305 if (isModEnabled(
'category')) {
306 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
307 print $form->showCategories($projectstatic->id,
'project', 1);
312 print
'<tr><td class="titlefield'.($projectstatic->description ?
' noborderbottom' :
'').
'" colspan="2">'.$langs->trans(
"Description").
'</td></tr>';
313 if ($projectstatic->description) {
314 print
'<tr><td class="nottitleforfield" colspan="2">';
315 print
'<div class="longmessagecut">';
326 print
'<div class="clearboth"></div>';
339 print
dol_get_fiche_head($head,
'task_contact', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
342 $param = (
GETPOST(
'withproject') ?
'&withproject=1' :
'');
343 $linkback =
GETPOST(
'withproject') ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' :
'';
345 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
346 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
347 $object->next_prev_filter =
"fk_projet:IN:".$db->sanitize($projectsListId);
349 $object->next_prev_filter =
"fk_projet:=:".((int) $projectstatic->id);
355 if (empty($withproject)) {
356 $result = $projectstatic->fetch(
$object->fk_project);
357 $morehtmlref .=
'<div class="refidno">';
358 $morehtmlref .= $langs->trans(
"Project").
': ';
359 $morehtmlref .= $projectstatic->getNomUrl(1);
360 $morehtmlref .=
'<br>';
363 $morehtmlref .= $langs->trans(
"ThirdParty").
': ';
364 if ($projectstatic->socid > 0) {
365 $projectstatic->fetch_thirdparty();
366 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
369 $morehtmlref .=
'</div>';
372 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param, 0,
'',
'', 1);
392 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$id.
'" method="POST">';
393 print
'<input type="hidden" name="token" value="'.newToken().
'">';
394 print
'<input type="hidden" name="action" value="addcontact">';
395 print
'<input type="hidden" name="id" value="'.$id.
'">';
397 print
'<input type="hidden" name="withproject" value="'.$withproject.
'">';
400 print
'<div class="div-table-responsive">';
401 print
'<table class="noborder centpercent">';
403 if ($action !=
'editline' && $user->hasRight(
'projet',
'creer')) {
404 print
'<tr class="liste_titre">';
405 print
'<td>'.$langs->trans(
"NatureOfContact").
'</td>';
406 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
407 print
'<td>'.$langs->trans(
"Users").
'</td>';
408 print
'<td>'.$langs->trans(
"ContactType").
'</td>';
409 print
'<td colspan="3"> </td>';
413 print
'<tr class="oddeven nohover">';
415 print
'<td class="nowraponall">';
416 print
img_object(
'',
'user').
' '.$langs->trans(
"Users");
425 if (
$object->project->public) {
426 $contactsofproject =
'';
428 $contactsofproject = $projectstatic->getListContactId(
'internal');
430 print $form->select_dolusers((GETPOSTISSET(
'userid') ?
GETPOSTINT(
'userid') : $user->id),
'userid', 0, null, 0,
'', $contactsofproject,
'0', 0, 0,
'', 1, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth200imp maxwidth300');
433 print $formcompany->selectTypeContact($object,
'',
'type',
'internal',
'position', 0,
'minwidth200imp maxwidth300', 0);
435 print
'<td class="right" colspan="3"><input type="submit" class="button button-add small" value="'.$langs->trans(
"Add").
'" name="addsourceinternal"></td>';
439 if ($projectstatic->socid) {
440 print
'<tr class="oddeven">';
442 print
'<td class="nowraponall">';
443 print
img_object(
'',
'contact').
' '.$langs->trans(
"ThirdPartyContacts");
447 $thirdpartyofproject = $projectstatic->getListContactId(
'thirdparty');
448 $selectedCompany = GETPOSTISSET(
"newcompany") ?
GETPOST(
"newcompany") : $projectstatic->socid;
449 $selectedCompany = $formcompany->selectCompaniesForNewContact($object,
'id', $selectedCompany,
'newcompany', $thirdpartyofproject, 0,
'&withproject='.$withproject,
'minwidth200imp maxwidth300');
453 $contactofproject = $projectstatic->getListContactId(
'external');
455 print $form->select_contact($selectedCompany,
'',
'contactid', 0,
'',
'', 0,
'minwidth200imp maxwidth300',
true);
456 $nbofcontacts = $form->num;
459 print $formcompany->selectTypeContact($object,
'',
'typecontact',
'external',
'position', 0,
'minwidth200imp maxwidth300', 0);
461 print
'<td class="right" colspan="3" ><input type="submit" class="button button-add small" id="add-customer-contact" name="addsourceexternal" value="'.$langs->trans(
"Add").
'"';
462 if (!$nbofcontacts) {
471 print
'<tr class="liste_titre">';
472 print
'<td>'.$langs->trans(
"Source").
'</td>';
473 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
474 print
'<td>'.$langs->trans(
"TaskContact").
'</td>';
475 print
'<td>'.$langs->trans(
"ContactType").
'</td>';
476 print
'<td class="center">'.$langs->trans(
"Status").
'</td>';
477 print
'<td colspan="2"> </td>';
480 $companystatic =
new Societe($db);
482 foreach (array(
'internal',
'external') as $source) {
483 $tab =
$object->liste_contact(-1, $source);
489 print
'<tr class="oddeven" valign="top">';
492 print
'<td class="left">';
493 if ($tab[$i][
'source'] ==
'internal') {
494 print $langs->trans(
"User");
496 if ($tab[$i][
'source'] ==
'external') {
497 print $langs->trans(
"ThirdPartyContact");
502 print
'<td class="left">';
503 if ($tab[$i][
'socid'] > 0) {
504 $companystatic->fetch($tab[$i][
'socid']);
505 print $companystatic->getNomUrl(1);
507 if ($tab[$i][
'socid'] < 0) {
510 if (!$tab[$i][
'socid']) {
516 print
'<td class="tdoverflowmax150">';
517 if ($tab[$i][
'source'] ==
'internal') {
518 $userstatic->id = $tab[$i][
'id'];
519 $userstatic->lastname = $tab[$i][
'lastname'];
520 $userstatic->firstname = $tab[$i][
'firstname'];
521 $userstatic->photo = $tab[$i][
'photo'];
522 $userstatic->login = $tab[$i][
'login'];
523 $userstatic->email = $tab[$i][
'email'];
524 $userstatic->gender = $tab[$i][
'gender'];
525 $userstatic->status = $tab[$i][
'statuscontact'];
527 print $userstatic->getNomUrl(-1);
529 if ($tab[$i][
'source'] ==
'external') {
530 $contactstatic->id = $tab[$i][
'id'];
531 $contactstatic->lastname = $tab[$i][
'lastname'];
532 $contactstatic->firstname = $tab[$i][
'firstname'];
533 $contactstatic->email = $tab[$i][
'email'];
534 $contactstatic->statut = $tab[$i][
'statuscontact'];
535 print $contactstatic->getNomUrl(1);
540 print
'<td>'.$tab[$i][
'libelle'].
'</td>';
543 print
'<td class="center">';
546 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=swapstatut&ligne='.$tab[$i][
'rowid'].($withproject ?
'&withproject=1' :
'').
'">';
548 print $contactstatic->LibStatut($tab[$i][
'status'], 3);
555 print
'<td class="center nowrap">';
556 if ($user->hasRight(
'projet',
'creer')) {
558 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deleteline&token='.
newToken().
'&lineid='.$tab[$i][
'rowid'].($withproject ?
'&withproject=1' :
'').
'">';
559 print
img_picto($langs->trans(
'Unlink'),
'unlink');
574 print
"ErrorRecordNotFound";
578if (is_object($hookmanager)) {
579 $hookmanager->initHooks(array(
'contacttpl'));
580 $parameters = array();
581 $reshook = $hookmanager->executeHooks(
'formContactTpl', $parameters, $object, $action);
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
task_prepare_head($object)
Prepare array with list of tabs.
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.