26require
"../../main.inc.php";
27require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
31require_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');
43$object =
new Task($db);
44$projectstatic =
new Project($db);
47 $object->fetch($id, $ref);
53restrictedArea($user,
'projet', $object->fk_project,
'projet&project');
61if ($action ==
'addcontact' && $user->rights->projet->creer) {
63 if (
GETPOST(
"addsourceexternal")) {
67 $result = $object->fetch($id, $ref);
69 if ($result > 0 && $id > 0) {
70 if ($source ==
'internal') {
74 $idfortaskuser = ((
GETPOST(
"contactid") > 0) ?
GETPOST(
"contactid",
'int') : 0);
75 $typeid =
GETPOST(
'typecontact');
77 if ($idfortaskuser == -2) {
78 $result = $projectstatic->fetch($object->fk_project);
82 $contactsofproject = $projectstatic->getListContactId(
'internal');
83 foreach ($contactsofproject as $key => $val) {
84 $result = $object->add_contact($val, $typeid, $source);
88 $result = $object->add_contact($idfortaskuser, $typeid, $source);
93 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$object->id.($withproject ?
'&withproject=1' :
''));
96 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
97 $langs->load(
"errors");
98 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
106if ($action ==
'swapstatut' && $user->rights->projet->creer) {
107 if ($object->fetch($id, $ref)) {
108 $result = $object->swapContactStatus(
GETPOST(
'ligne',
'int'));
115if ($action ==
'deleteline' && $user->rights->projet->creer) {
116 $object->fetch($id, $ref);
117 $result = $object->delete_contact(
GETPOST(
"lineid",
'int'));
120 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$object->id.($withproject ?
'&withproject=1' :
''));
128if (!empty($project_ref) && !empty($withproject)) {
129 if ($projectstatic->fetch(0, $project_ref) > 0) {
130 $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
131 if (count($tasksarray) > 0) {
132 $id = $tasksarray[0]->id;
134 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.($withproject ?
'&withproject=1' :
'').(empty($mode) ?
'' :
'&mode='.$mode));
143$form =
new Form($db);
145$contactstatic =
new Contact($db);
146$userstatic =
new User($db);
147$result = $projectstatic->fetch($object->fk_project);
149$title = $object->ref .
' - ' . $langs->trans(
"Contacts");
150if (!empty($withproject)) {
151 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': '.$projectstatic->ref :
'') ;
164if ($id > 0 || !empty($ref)) {
165 if ($object->fetch($id, $ref) > 0) {
166 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object,
'fetchComments') && empty($object->comments)) {
167 $object->fetchComments();
171 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
172 $projectstatic->fetchComments();
174 if (!empty($projectstatic->socid)) {
175 $projectstatic->fetch_thirdparty();
178 $object->project = clone $projectstatic;
180 $userWrite = $projectstatic->restrictedProjectArea($user,
'write');
186 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
188 $param = (!empty($mode) && $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 (isset($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
199 $morehtmlref .=
'<br>'.$projectstatic->thirdparty->getNomUrl(1,
'project');
201 $morehtmlref .=
'</div>';
204 if (empty($user->rights->projet->all->lire)) {
205 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
206 $projectstatic->next_prev_filter =
"rowid IN (".$db->sanitize(count($objectsListId) ?join(
',', array_keys($objectsListId)) :
'0').
")";
209 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
211 print
'<div class="fichecenter">';
212 print
'<div class="fichehalfleft">';
213 print
'<div class="underbanner clearboth"></div>';
215 print
'<table class="border tableforfield centpercent">';
218 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || isModEnabled(
'eventorganization')) {
219 print
'<tr><td class="tdtop">';
220 print $langs->trans(
"Usage");
223 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
224 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
225 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
226 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
229 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
230 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')).
'"> ';
231 $htmltext = $langs->trans(
"ProjectFollowTasks");
232 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
235 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
236 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"' :
'')).
'"> ';
237 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
238 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
241 if (isModEnabled(
'eventorganization')) {
242 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"' :
'')).
'"> ';
243 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
244 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
250 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
251 if ($projectstatic->public) {
252 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
253 print $langs->trans(
'SharedProject');
255 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
256 print $langs->trans(
'PrivateProject');
261 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
262 if (strcmp($projectstatic->budget_amount,
'')) {
263 print
price($projectstatic->budget_amount,
'', $langs, 1, 0, 0, $conf->currency);
268 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
270 print ($start ? $start :
'?');
273 print ($end ? $end :
'?');
274 if ($projectstatic->hasDelay()) {
286 print
'<div class="fichehalfright">';
287 print
'<div class="underbanner clearboth"></div>';
289 print
'<table class="border tableforfield centpercent">';
292 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
293 print nl2br($projectstatic->description);
297 if (isModEnabled(
'categorie')) {
298 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
299 print $form->showCategories($projectstatic->id,
'project', 1);
308 print
'<div class="clearboth"></div>';
321 print
dol_get_fiche_head($head,
'task_contact', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
324 $param = (
GETPOST(
'withproject') ?
'&withproject=1' :
'');
325 $linkback =
GETPOST(
'withproject') ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' :
'';
327 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
328 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
329 $object->next_prev_filter =
"fk_projet IN (".$db->sanitize($projectsListId).
")";
331 $object->next_prev_filter =
"fk_projet = ".((int) $projectstatic->id);
337 if (empty($withproject)) {
338 $result = $projectstatic->fetch($object->fk_project);
339 $morehtmlref .=
'<div class="refidno">';
340 $morehtmlref .= $langs->trans(
"Project").
': ';
341 $morehtmlref .= $projectstatic->getNomUrl(1);
342 $morehtmlref .=
'<br>';
345 $morehtmlref .= $langs->trans(
"ThirdParty").
': ';
346 if ($projectstatic->socid > 0) {
347 $projectstatic->fetch_thirdparty();
348 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
351 $morehtmlref .=
'</div>';
354 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param, 0,
'',
'', 1);
374 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'" method="POST">';
375 print
'<input type="hidden" name="token" value="'.newToken().
'">';
376 print
'<input type="hidden" name="action" value="addcontact">';
377 print
'<input type="hidden" name="id" value="'.$id.
'">';
379 print
'<input type="hidden" name="withproject" value="'.$withproject.
'">';
382 print
'<table class="noborder centpercent">';
384 if ($action !=
'editline' && $user->hasRight(
'projet',
'creer')) {
385 print
'<tr class="liste_titre">';
386 print
'<td>'.$langs->trans(
"NatureOfContact").
'</td>';
387 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
388 print
'<td>'.$langs->trans(
"Users").
'</td>';
389 print
'<td>'.$langs->trans(
"ContactType").
'</td>';
390 print
'<td colspan="3"> </td>';
394 print
'<tr class="oddeven nohover">';
396 print
'<td class="nowrap">';
397 print
img_object(
'',
'user').
' '.$langs->trans(
"Users");
401 print $conf->global->MAIN_INFO_SOCIETE_NOM;
406 if ($object->project->public) {
407 $contactsofproject =
'';
409 $contactsofproject = $projectstatic->getListContactId(
'internal');
411 print $form->select_dolusers((GETPOSTISSET(
'userid') ?
GETPOST(
'userid',
'int') : $user->id),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 1, $langs->trans(
"ResourceNotAssignedToProject"));
414 $formcompany->selectTypeContact($object,
'',
'type',
'internal',
'position');
416 print
'<td class="right" colspan="3" ><input type="submit" class="button button-add" value="'.$langs->trans(
"Add").
'" name="addsourceinternal"></td>';
420 if ($projectstatic->socid) {
421 print
'<tr class="oddeven">';
423 print
'<td class="nowrap">';
424 print
img_object(
'',
'contact').
' '.$langs->trans(
"ThirdPartyContacts");
428 $thirdpartyofproject = $projectstatic->getListContactId(
'thirdparty');
429 $selectedCompany = isset($_GET[
"newcompany"]) ? $_GET[
"newcompany"] : $projectstatic->socid;
430 $selectedCompany = $formcompany->selectCompaniesForNewContact($object,
'id', $selectedCompany,
'newcompany', $thirdpartyofproject, 0,
'&withproject='.$withproject);
434 $contactofproject = $projectstatic->getListContactId(
'external');
435 print $form->selectcontacts($selectedCompany,
'',
'contactid', 0,
'', $contactofproject, 0,
'',
false, 0, 0);
436 $nbofcontacts = $form->num;
439 $formcompany->selectTypeContact($object,
'',
'typecontact',
'external',
'position');
441 print
'<td class="right" colspan="3" ><input type="submit" class="button" id="add-customer-contact" name="addsourceexternal" value="'.$langs->trans(
"Add").
'"';
442 if (!$nbofcontacts) {
451 print
'<tr class="liste_titre">';
452 print
'<td>'.$langs->trans(
"Source").
'</td>';
453 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
454 print
'<td>'.$langs->trans(
"TaskContact").
'</td>';
455 print
'<td>'.$langs->trans(
"ContactType").
'</td>';
456 print
'<td class="center">'.$langs->trans(
"Status").
'</td>';
457 print
'<td colspan="2"> </td>';
460 $companystatic =
new Societe($db);
462 foreach (array(
'internal',
'external') as $source) {
463 $tab = $object->liste_contact(-1, $source);
469 print
'<tr class="oddeven" valign="top">';
472 print
'<td class="left">';
473 if ($tab[$i][
'source'] ==
'internal') {
474 print $langs->trans(
"User");
476 if ($tab[$i][
'source'] ==
'external') {
477 print $langs->trans(
"ThirdPartyContact");
482 print
'<td class="left">';
483 if ($tab[$i][
'socid'] > 0) {
484 $companystatic->fetch($tab[$i][
'socid']);
485 print $companystatic->getNomUrl(1);
487 if ($tab[$i][
'socid'] < 0) {
488 print $conf->global->MAIN_INFO_SOCIETE_NOM;
490 if (!$tab[$i][
'socid']) {
497 if ($tab[$i][
'source'] ==
'internal') {
498 $userstatic->id = $tab[$i][
'id'];
499 $userstatic->lastname = $tab[$i][
'lastname'];
500 $userstatic->firstname = $tab[$i][
'firstname'];
501 $userstatic->photo = $tab[$i][
'photo'];
502 $userstatic->login = $tab[$i][
'login'];
503 $userstatic->email = $tab[$i][
'email'];
504 $userstatic->statut = $tab[$i][
'statuscontact'];
506 print $userstatic->getNomUrl(-1);
508 if ($tab[$i][
'source'] ==
'external') {
509 $contactstatic->id = $tab[$i][
'id'];
510 $contactstatic->lastname = $tab[$i][
'lastname'];
511 $contactstatic->firstname = $tab[$i][
'firstname'];
512 $contactstatic->email = $tab[$i][
'email'];
513 $contactstatic->statut = $tab[$i][
'statuscontact'];
514 print $contactstatic->getNomUrl(1);
519 print
'<td>'.$tab[$i][
'libelle'].
'</td>';
522 print
'<td class="center">';
524 if ($object->statut >= 0) {
525 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=swapstatut&ligne='.$tab[$i][
'rowid'].($withproject ?
'&withproject=1' :
'').
'">';
527 print $contactstatic->LibStatut($tab[$i][
'status'], 3);
528 if ($object->statut >= 0) {
534 print
'<td class="center nowrap">';
535 if ($user->hasRight(
'projet',
'creer')) {
537 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=deleteline&token='.newToken().
'&lineid='.$tab[$i][
'rowid'].($withproject ?
'&withproject=1' :
'').
'">';
538 print
img_picto($langs->trans(
'Unlink'),
'unlink');
552 print
"ErrorRecordNotFound";
556if (is_object($hookmanager)) {
557 $hookmanager->initHooks(array(
'contacttpl'));
558 $parameters = array();
559 $reshook = $hookmanager->executeHooks(
'formContactTpl', $parameters, $object, $action);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
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.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.