29require
"../../main.inc.php";
37require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
44$langs->loadLangs(array(
'projects',
'companies'));
46$action =
GETPOST(
'action',
'aZ09');
47$confirm =
GETPOST(
'confirm',
'alpha');
52$project_ref =
GETPOST(
'project_ref',
'alpha');
55$projectstatic =
new Project($db);
57$hookmanager->initHooks(array(
'projecttaskcontact',
'globalcard'));
74$parameters = array(
'projectid' =>
$object->fk_project);
75$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
82 if ($action ==
'addcontact' && $user->hasRight(
'projet',
'creer')) {
84 if (
GETPOST(
"addsourceexternal")) {
88 $result =
$object->fetch($id, $ref);
90 if ($result > 0 && $id > 0) {
91 if ($source ==
'internal') {
96 $typeid =
GETPOST(
'typecontact');
98 if ($idfortaskuser == -2) {
99 $result = $projectstatic->fetch(
$object->fk_project);
103 $contactsofproject = $projectstatic->getListContactId(
'internal');
104 foreach ($contactsofproject as $key => $val) {
105 $result =
$object->add_contact($val, $typeid, $source);
109 $result =
$object->add_contact($idfortaskuser, $typeid, $source);
114 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
$object->id.($withproject ?
'&withproject=1' :
''));
117 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
118 $langs->load(
"errors");
119 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
127 if ($action ==
'swapstatut' && $user->hasRight(
'projet',
'creer')) {
128 if (
$object->fetch($id, $ref)) {
136 if ($action ==
'deleteline' && $user->hasRight(
'projet',
'creer')) {
141 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
$object->id.($withproject ?
'&withproject=1' :
''));
149 if (!empty($project_ref) && !empty($withproject)) {
150 if ($projectstatic->fetch(0, $project_ref) > 0) {
151 $tasksarray =
$object->getTasksArray(
null,
null, $projectstatic->id, $socid, 0);
152 if (count($tasksarray) > 0) {
153 $id = $tasksarray[0]->id;
155 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.($withproject ?
'&withproject=1' :
'').(empty($mode) ?
'' :
'&mode='.$mode));
165$form =
new Form($db);
167$contactstatic =
new Contact($db);
168$userstatic =
new User($db);
169$result = $projectstatic->fetch(
$object->fk_project);
171$title =
$object->ref .
' - ' . $langs->trans(
"Contacts");
172if (!empty($withproject)) {
173 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': '.$projectstatic->ref :
'') ;
177llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project project-tasks page-task_contact');
186if ($id > 0 || !empty($ref)) {
187 if (
$object->fetch($id, $ref) > 0) {
193 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
194 $projectstatic->fetchComments();
196 if (!empty($projectstatic->socid)) {
197 $projectstatic->fetch_thirdparty();
200 $object->project = clone $projectstatic;
202 $userWrite = $projectstatic->restrictedProjectArea($user,
'write');
208 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
210 $param = (!empty($mode) && $mode ==
'mine' ?
'&mode=mine' :
'');
214 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
216 $morehtmlref =
'<div class="refidno">';
218 $morehtmlref .= $projectstatic->title;
220 if (isset($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
221 $morehtmlref .=
'<br>'.$projectstatic->thirdparty->getNomUrl(1,
'project');
223 $morehtmlref .=
'</div>';
226 if (!$user->hasRight(
'projet',
'all',
'lire')) {
227 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
228 $projectstatic->next_prev_filter =
"rowid:IN:".$db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0');
231 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param);
233 print
'<div class="fichecenter">';
234 print
'<div class="fichehalfleft">';
235 print
'<div class="underbanner clearboth"></div>';
237 print
'<table class="border tableforfield centpercent">';
241 print
'<tr><td class="tdtop">';
242 print $langs->trans(
"Usage");
246 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
247 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
248 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
252 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')).
'"> ';
253 $htmltext = $langs->trans(
"ProjectFollowTasks");
254 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
258 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"' :
'')).
'"> ';
259 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
260 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
264 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"' :
'')).
'"> ';
265 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
266 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
272 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
273 if (isset($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
274 print
'<span class="amount">'.price($projectstatic->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).
'</span>';
279 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
281 print($start ? $start :
'?');
284 print($end ? $end :
'?');
285 if ($projectstatic->hasDelay()) {
291 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
292 if ($projectstatic->public) {
293 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
294 print $langs->trans(
'SharedProject');
296 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
297 print $langs->trans(
'PrivateProject');
305 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
311 print
'<div class="fichehalfright">';
312 print
'<div class="underbanner clearboth"></div>';
314 print
'<table class="border tableforfield centpercent">';
318 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
319 print $form->showCategories($projectstatic->id,
'project', 1);
324 print
'<tr><td class="titlefield'.($projectstatic->description ?
' noborderbottom' :
'').
'" colspan="2">'.$langs->trans(
"Description").
'</td></tr>';
325 if ($projectstatic->description) {
326 print
'<tr><td class="nottitleforfield" colspan="2">';
327 print
'<div class="longmessagecut">';
338 print
'<div class="clearboth"></div>';
351 print
dol_get_fiche_head($head,
'task_contact', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
354 $param = (
GETPOST(
'withproject') ?
'&withproject=1' :
'');
355 $linkback =
GETPOST(
'withproject') ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' :
'';
357 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
358 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
359 $object->next_prev_filter =
"fk_projet:IN:".$db->sanitize($projectsListId);
361 $object->next_prev_filter =
"fk_projet:=:".((int) $projectstatic->id);
367 if (empty($withproject)) {
368 $result = $projectstatic->fetch(
$object->fk_project);
369 $morehtmlref .=
'<div class="refidno">';
370 $morehtmlref .= $langs->trans(
"Project").
': ';
371 $morehtmlref .= $projectstatic->getNomUrl(1);
372 $morehtmlref .=
'<br>';
375 $morehtmlref .= $langs->trans(
"ThirdParty").
': ';
376 if ($projectstatic->socid > 0) {
377 $projectstatic->fetch_thirdparty();
378 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
381 $morehtmlref .=
'</div>';
384 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param, 0,
'',
'', 1);
404 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$id.
'" method="POST">';
405 print
'<input type="hidden" name="token" value="'.newToken().
'">';
406 print
'<input type="hidden" name="action" value="addcontact">';
407 print
'<input type="hidden" name="id" value="'.$id.
'">';
409 print
'<input type="hidden" name="withproject" value="'.$withproject.
'">';
412 print
'<div class="div-table-responsive">';
413 print
'<table class="noborder centpercent">';
415 if ($action !=
'editline' && $user->hasRight(
'projet',
'creer')) {
416 print
'<tr class="liste_titre">';
417 print
'<td>'.$langs->trans(
"NatureOfContact").
'</td>';
418 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
419 print
'<td>'.$langs->trans(
"Users").
'</td>';
420 print
'<td>'.$langs->trans(
"ContactType").
'</td>';
421 print
'<td colspan="3"> </td>';
425 print
'<tr class="oddeven nohover">';
427 print
'<td class="nowraponall">';
428 print
img_object(
'',
'user').
' '.$langs->trans(
"Users");
437 if (
$object->project->public) {
438 $contactsofproject =
'';
440 $contactsofproject = $projectstatic->getListContactId(
'internal');
442 print $form->select_dolusers((GETPOSTISSET(
'userid') ?
GETPOSTINT(
'userid') : $user->id),
'userid', 0, null, 0,
'', $contactsofproject,
'0', 0, 0,
'', 1, $langs->trans(
"ResourceNotAssignedToProject"),
'minwidth200imp maxwidth300');
445 print $formcompany->selectTypeContact($object,
'',
'type',
'internal',
'position', 0,
'minwidth200imp maxwidth300', 0);
447 print
'<td class="right" colspan="3"><input type="submit" class="button button-add small" value="'.$langs->trans(
"Add").
'" name="addsourceinternal"></td>';
451 if ($projectstatic->socid) {
452 print
'<tr class="oddeven">';
454 print
'<td class="nowraponall">';
455 print
img_object(
'',
'contact').
' '.$langs->trans(
"ThirdPartyContacts");
459 $thirdpartyofproject = $projectstatic->getListContactId(
'thirdparty');
460 $selectedCompany = GETPOSTISSET(
"newcompany") ?
GETPOST(
"newcompany") : $projectstatic->socid;
461 $selectedCompany = $formcompany->selectCompaniesForNewContact($object,
'id', $selectedCompany,
'newcompany', $thirdpartyofproject, 0,
'&withproject='.$withproject,
'minwidth200imp maxwidth300');
465 $contactofproject = $projectstatic->getListContactId(
'external');
467 print $form->select_contact($selectedCompany,
'',
'contactid', 0,
'',
'', 0,
'minwidth200imp maxwidth300',
true);
468 $nbofcontacts = $form->num;
471 print $formcompany->selectTypeContact($object,
'',
'typecontact',
'external',
'position', 0,
'minwidth200imp maxwidth300', 0);
473 print
'<td class="right" colspan="3" ><input type="submit" class="button button-add small" id="add-customer-contact" name="addsourceexternal" value="'.$langs->trans(
"Add").
'"';
474 if (!$nbofcontacts) {
483 print
'<tr class="liste_titre">';
484 print
'<td>'.$langs->trans(
"Source").
'</td>';
485 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
486 print
'<td>'.$langs->trans(
"TaskContact").
'</td>';
487 print
'<td>'.$langs->trans(
"ContactType").
'</td>';
488 print
'<td class="center">'.$langs->trans(
"Status").
'</td>';
489 print
'<td colspan="2"> </td>';
492 $companystatic =
new Societe($db);
494 foreach (array(
'internal',
'external') as $source) {
495 $tab =
$object->liste_contact(-1, $source);
501 print
'<tr class="oddeven" valign="top">';
504 print
'<td class="left">';
505 if ($tab[$i][
'source'] ==
'internal') {
506 print $langs->trans(
"User");
508 if ($tab[$i][
'source'] ==
'external') {
509 print $langs->trans(
"ThirdPartyContact");
514 print
'<td class="left">';
515 if ($tab[$i][
'socid'] > 0) {
516 $companystatic->fetch($tab[$i][
'socid']);
517 print $companystatic->getNomUrl(1);
519 if ($tab[$i][
'socid'] < 0) {
522 if (!$tab[$i][
'socid']) {
528 print
'<td class="tdoverflowmax150">';
529 if ($tab[$i][
'source'] ==
'internal') {
530 $userstatic->id = $tab[$i][
'id'];
531 $userstatic->lastname = $tab[$i][
'lastname'];
532 $userstatic->firstname = $tab[$i][
'firstname'];
533 $userstatic->photo = $tab[$i][
'photo'];
534 $userstatic->login = $tab[$i][
'login'];
535 $userstatic->email = $tab[$i][
'email'];
536 $userstatic->gender = $tab[$i][
'gender'];
537 $userstatic->status = $tab[$i][
'statuscontact'];
539 print $userstatic->getNomUrl(-1);
541 if ($tab[$i][
'source'] ==
'external') {
542 $contactstatic->id = $tab[$i][
'id'];
543 $contactstatic->lastname = $tab[$i][
'lastname'];
544 $contactstatic->firstname = $tab[$i][
'firstname'];
545 $contactstatic->email = $tab[$i][
'email'];
546 $contactstatic->status = $tab[$i][
'statuscontact'];
547 $contactstatic->statut = $tab[$i][
'statuscontact'];
548 print $contactstatic->getNomUrl(1);
553 print
'<td>'.$tab[$i][
'libelle'].
'</td>';
556 print
'<td class="center">';
559 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=swapstatut&ligne='.$tab[$i][
'rowid'].($withproject ?
'&withproject=1' :
'').
'">';
561 print $contactstatic->LibStatut($tab[$i][
'status'], 3);
568 print
'<td class="center nowrap">';
569 if ($user->hasRight(
'projet',
'creer')) {
571 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deleteline&token='.
newToken().
'&lineid='.$tab[$i][
'rowid'].($withproject ?
'&withproject=1' :
'').
'">';
572 print
img_picto($langs->trans(
'Unlink'),
'unlink');
587 print
"ErrorRecordNotFound";
591if (is_object($hookmanager)) {
592 $hookmanager->initHooks(array(
'contacttpl'));
593 $parameters = array();
594 $reshook = $hookmanager->executeHooks(
'formContactTpl', $parameters, $object, $action);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $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)
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_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.
isModEnabled($module)
Is Dolibarr module enabled.
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.