26 require
"../../main.inc.php";
27 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
34 $langs->loadLangs(array(
'projects',
'companies'));
38 $action =
GETPOST(
'action',
'aZ09');
39 $confirm =
GETPOST(
'confirm',
'alpha');
40 $withproject =
GETPOST(
'withproject',
'int');
41 $project_ref =
GETPOST(
'project_ref',
'alpha');
49 $object =
new Task($db);
50 $projectstatic =
new Project($db);
58 if ($action ==
'addcontact' && $user->rights->projet->creer)
61 if (
GETPOST(
"addsourceexternal")) {
65 $result = $object->fetch($id, $ref);
67 if ($result > 0 && $id > 0)
69 if ($source ==
'internal') {
73 $idfortaskuser = ((
GETPOST(
"contactid") > 0) ?
GETPOST(
"contactid",
'int') : 0);
74 $typeid =
GETPOST(
'typecontact');
76 if ($idfortaskuser == -2)
78 $result = $projectstatic->fetch($object->fk_project);
83 $contactsofproject = $projectstatic->getListContactId(
'internal');
84 foreach ($contactsofproject as $key => $val)
86 $result = $object->add_contact($val, $typeid, $source);
90 $result = $object->add_contact($idfortaskuser, $typeid, $source);
95 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?id=".$object->id.($withproject ?
'&withproject=1' :
''));
98 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
99 $langs->load(
"errors");
100 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"), null,
'errors');
108 if ($action ==
'swapstatut' && $user->rights->projet->creer)
110 if ($object->fetch($id, $ref)) {
111 $result = $object->swapContactStatus(
GETPOST(
'ligne'));
118 if ($action ==
'deleteline' && $user->rights->projet->creer)
120 $object->fetch($id, $ref);
121 $result = $object->delete_contact($_GET[
"lineid"]);
125 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?id=".$object->id.($withproject ?
'&withproject=1' :
''));
133 if (!empty($project_ref) && !empty($withproject))
135 if ($projectstatic->fetch(0, $project_ref) > 0)
137 $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
138 if (count($tasksarray) > 0)
140 $id = $tasksarray[0]->id;
142 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.($withproject ?
'&withproject=1' :
'').(empty($mode) ?
'' :
'&mode='.$mode));
154 $form =
new Form($db);
156 $contactstatic =
new Contact($db);
157 $userstatic =
new User($db);
166 if ($id > 0 || !empty($ref))
168 if ($object->fetch($id, $ref) > 0)
170 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object,
'fetchComments') && empty($object->comments)) $object->fetchComments();
173 $result = $projectstatic->fetch($object->fk_project);
174 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments();
175 if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
177 $object->project = clone $projectstatic;
179 $userWrite = $projectstatic->restrictedProjectArea($user,
'write');
186 print dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
188 $param = ($mode ==
'mine' ?
'&mode=mine' :
'');
192 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
194 $morehtmlref =
'<div class="refidno">';
196 $morehtmlref .= $projectstatic->title;
198 if ($projectstatic->thirdparty->id > 0)
200 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$projectstatic->thirdparty->getNomUrl(1,
'project');
202 $morehtmlref .=
'</div>';
205 if (!$user->rights->projet->all->lire)
207 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
208 $projectstatic->next_prev_filter =
" rowid in (".(count($objectsListId) ?join(
',', array_keys($objectsListId)) :
'0').
")";
211 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
213 print '<div class="fichecenter">';
214 print '<div class="fichehalfleft">';
215 print '<div class="underbanner clearboth"></div>';
217 print '<table class="border tableforfield centpercent">';
220 print '<tr><td class="tdtop">';
221 print $langs->trans(
"Usage");
224 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
226 print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
227 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
228 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
231 if (empty($conf->global->PROJECT_HIDE_TASKS))
233 print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')).
'"> ';
234 $htmltext = $langs->trans(
"ProjectFollowTasks");
235 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
238 if (!empty($conf->global->PROJECT_BILL_TIME_SPENT))
240 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"' :
'')).
'"> ';
241 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
242 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
248 print '<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
249 if ($projectstatic->public)
print $langs->trans(
'SharedProject');
250 else print $langs->trans(
'PrivateProject');
254 print '<tr><td>'.$langs->trans(
"DateStart").
' - '.$langs->trans(
"DateEnd").
'</td><td>';
256 print ($start ? $start :
'?');
259 print ($end ? $end :
'?');
264 print '<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
265 if (strcmp($projectstatic->budget_amount,
''))
print price($projectstatic->budget_amount,
'', $langs, 1, 0, 0, $conf->currency);
275 print '<div class="fichehalfright">';
276 print '<div class="ficheaddleft">';
277 print '<div class="underbanner clearboth"></div>';
279 print '<table class="border tableforfield" width="100%">';
282 print '<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
283 print nl2br($projectstatic->description);
287 if ($conf->categorie->enabled) {
288 print '<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
289 print $form->showCategories($projectstatic->id,
'project', 1);
299 print '<div class="clearboth"></div>';
312 print dol_get_fiche_head($head,
'task_contact', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
315 $param = (
GETPOST(
'withproject') ?
'&withproject=1' :
'');
316 $linkback =
GETPOST(
'withproject') ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' :
'';
318 if (!
GETPOST(
'withproject') || empty($projectstatic->id))
320 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
321 $object->next_prev_filter =
" fk_projet in (".$projectsListId.
")";
322 }
else $object->next_prev_filter =
" fk_projet = ".$projectstatic->id;
327 if (empty($withproject))
329 $result = $projectstatic->fetch($object->fk_project);
330 $morehtmlref .=
'<div class="refidno">';
331 $morehtmlref .= $langs->trans(
"Project").
': ';
332 $morehtmlref .= $projectstatic->getNomUrl(1);
333 $morehtmlref .=
'<br>';
336 $morehtmlref .= $langs->trans(
"ThirdParty").
': ';
337 if ($projectstatic->socid > 0) {
338 $projectstatic->fetch_thirdparty();
339 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
342 $morehtmlref .=
'</div>';
345 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param, 0,
'',
'', 1);
365 print '<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'" method="POST">';
366 print '<input type="hidden" name="token" value="'.newToken().
'">';
367 print '<input type="hidden" name="action" value="addcontact">';
368 print '<input type="hidden" name="id" value="'.$id.
'">';
369 if ($withproject)
print '<input type="hidden" name="withproject" value="'.$withproject.
'">';
371 print '<table class="noborder centpercent">';
373 if ($action !=
'editline' && $user->rights->projet->creer)
375 print '<tr class="liste_titre">';
376 print '<td>'.$langs->trans(
"NatureOfContact").
'</td>';
377 print '<td>'.$langs->trans(
"ThirdParty").
'</td>';
378 print '<td>'.$langs->trans(
"Users").
'</td>';
379 print '<td>'.$langs->trans(
"ContactType").
'</td>';
380 print '<td colspan="3"> </td>';
384 print '<tr class="oddeven nohover">';
386 print '<td class="nowrap">';
391 print $conf->global->MAIN_INFO_SOCIETE_NOM;
396 if ($object->project->public) $contactsofproject =
'';
397 else $contactsofproject = $projectstatic->getListContactId(
'internal');
398 print $form->select_dolusers((
GETPOSTISSET(
'userid') ?
GETPOST(
'userid',
'int') : $user->id),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 1, $langs->trans(
"ResourceNotAssignedToProject"));
401 $formcompany->selectTypeContact($object,
'',
'type',
'internal',
'rowid');
403 print '<td class="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans(
"Add").
'" name="addsourceinternal"></td>';
407 if ($projectstatic->socid)
409 print '<tr class="oddeven">';
411 print '<td class="nowrap">';
412 print img_object(
'',
'contact').
' '.$langs->trans(
"ThirdPartyContacts");
416 $thirdpartyofproject = $projectstatic->getListContactId(
'thirdparty');
417 $selectedCompany = isset($_GET[
"newcompany"]) ? $_GET[
"newcompany"] : $projectstatic->socid;
418 $selectedCompany = $formcompany->selectCompaniesForNewContact($object,
'id', $selectedCompany,
'newcompany', $thirdpartyofproject, 0,
'&withproject='.$withproject);
422 $contactofproject = $projectstatic->getListContactId(
'external');
423 print $form->selectcontacts($selectedCompany,
'',
'contactid', 0,
'', $contactofproject, 0,
'',
false, 0, 0);
424 $nbofcontacts = $form->num;
427 $formcompany->selectTypeContact($object,
'',
'typecontact',
'external',
'rowid');
429 print '<td class="right" colspan="3" ><input type="submit" class="button" id="add-customer-contact" name="addsourceexternal" value="'.$langs->trans(
"Add").
'"';
430 if (!$nbofcontacts)
print ' disabled';
437 print '<tr class="liste_titre">';
438 print '<td>'.$langs->trans(
"Source").
'</td>';
439 print '<td>'.$langs->trans(
"ThirdParty").
'</td>';
440 print '<td>'.$langs->trans(
"TaskContact").
'</td>';
441 print '<td>'.$langs->trans(
"ContactType").
'</td>';
442 print '<td class="center">'.$langs->trans(
"Status").
'</td>';
443 print '<td colspan="2"> </td>';
446 $companystatic =
new Societe($db);
448 foreach (array(
'internal',
'external') as $source)
450 $tab = $object->liste_contact(-1, $source);
457 print '<tr class="oddeven" valign="top">';
460 print '<td class="left">';
461 if ($tab[$i][
'source'] ==
'internal')
print $langs->trans(
"User");
462 if ($tab[$i][
'source'] ==
'external')
print $langs->trans(
"ThirdPartyContact");
466 print '<td class="left">';
467 if ($tab[$i][
'socid'] > 0)
469 $companystatic->fetch($tab[$i][
'socid']);
470 print $companystatic->getNomUrl(1);
472 if ($tab[$i][
'socid'] < 0)
474 print $conf->global->MAIN_INFO_SOCIETE_NOM;
476 if (!$tab[$i][
'socid'])
484 if ($tab[$i][
'source'] ==
'internal')
486 $userstatic->id = $tab[$i][
'id'];
487 $userstatic->lastname = $tab[$i][
'lastname'];
488 $userstatic->firstname = $tab[$i][
'firstname'];
489 $userstatic->photo = $tab[$i][
'photo'];
490 $userstatic->login = $tab[$i][
'login'];
491 $userstatic->email = $tab[$i][
'email'];
492 $userstatic->statut = $tab[$i][
'statuscontact'];
494 print $userstatic->getNomUrl(-1);
496 if ($tab[$i][
'source'] ==
'external')
498 $contactstatic->id = $tab[$i][
'id'];
499 $contactstatic->lastname = $tab[$i][
'lastname'];
500 $contactstatic->firstname = $tab[$i][
'firstname'];
501 $contactstatic->email = $tab[$i][
'email'];
502 $contactstatic->statut = $tab[$i][
'statuscontact'];
503 print $contactstatic->getNomUrl(1);
508 print '<td>'.$tab[$i][
'libelle'].
'</td>';
511 print '<td class="center">';
513 if ($object->statut >= 0)
print '<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=swapstatut&ligne='.$tab[$i][
'rowid'].($withproject ?
'&withproject=1' :
'').
'">';
514 print $contactstatic->LibStatut($tab[$i][
'status'], 3);
515 if ($object->statut >= 0)
print '</a>';
519 print '<td class="center nowrap">';
520 if ($user->rights->projet->creer)
523 print '<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=deleteline&token='.
newToken().
'&lineid='.$tab[$i][
'rowid'].($withproject ?
'&withproject=1' :
'').
'">';
538 print "ErrorRecordNotFound";
542 if (is_object($hookmanager))
544 $hookmanager->initHooks(array(
'contacttpl'));
545 $parameters = array();
546 $reshook = $hookmanager->executeHooks(
'formContactTpl', $parameters, $object, $action);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage Dolibarr users.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage projects.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
project_prepare_head(Project $project)
Prepare array with list of tabs.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
task_prepare_head($object)
Prepare array with list of tabs.