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');
43 $object =
new Task($db);
44 $projectstatic =
new Project($db);
46 if ($id > 0 || $ref) {
47 $object->fetch($id, $ref);
53 restrictedArea($user,
'projet', $object->fk_project,
'projet&project');
61 if ($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');
106 if ($action ==
'swapstatut' && $user->rights->projet->creer) {
107 if ($object->fetch($id, $ref)) {
108 $result = $object->swapContactStatus(
GETPOST(
'ligne',
'int'));
115 if ($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' :
''));
128 if (!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));
148 $contactstatic =
new Contact($db);
149 $userstatic =
new User($db);
158 if ($id > 0 || !empty($ref)) {
159 if ($object->fetch($id, $ref) > 0) {
160 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object,
'fetchComments') && empty($object->comments)) {
161 $object->fetchComments();
165 $result = $projectstatic->fetch($object->fk_project);
166 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
167 $projectstatic->fetchComments();
169 if (!empty($projectstatic->socid)) {
170 $projectstatic->fetch_thirdparty();
173 $object->project = clone $projectstatic;
175 $userWrite = $projectstatic->restrictedProjectArea($user,
'write');
181 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
183 $param = ($mode ==
'mine' ?
'&mode=mine' :
'');
187 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
189 $morehtmlref =
'<div class="refidno">';
191 $morehtmlref .= $projectstatic->title;
193 if ($projectstatic->thirdparty->id > 0) {
194 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$projectstatic->thirdparty->getNomUrl(1,
'project');
196 $morehtmlref .=
'</div>';
199 if (empty($user->rights->projet->all->lire)) {
200 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
201 $projectstatic->next_prev_filter =
" rowid IN (".$db->sanitize(count($objectsListId) ?join(
',', array_keys($objectsListId)) :
'0').
")";
204 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
206 print
'<div class="fichecenter">';
207 print
'<div class="fichehalfleft">';
208 print
'<div class="underbanner clearboth"></div>';
210 print
'<table class="border tableforfield centpercent">';
213 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) {
214 print
'<tr><td class="tdtop">';
215 print $langs->trans(
"Usage");
218 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
219 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
220 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
221 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
224 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
225 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')).
'"> ';
226 $htmltext = $langs->trans(
"ProjectFollowTasks");
227 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
230 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
231 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"' :
'')).
'"> ';
232 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
233 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
236 if (!empty($conf->eventorganization->enabled)) {
237 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"' :
'')).
'"> ';
238 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
239 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
245 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
246 if ($projectstatic->public) {
247 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
248 print $langs->trans(
'SharedProject');
250 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
251 print $langs->trans(
'PrivateProject');
256 print
'<tr><td>'.$langs->trans(
"DateStart").
' - '.$langs->trans(
"DateEnd").
'</td><td>';
258 print ($start ? $start :
'?');
261 print ($end ? $end :
'?');
262 if ($projectstatic->hasDelay()) {
268 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
269 if (strcmp($projectstatic->budget_amount,
'')) {
270 print
price($projectstatic->budget_amount,
'', $langs, 1, 0, 0, $conf->currency);
281 print
'<div class="fichehalfright">';
282 print
'<div class="underbanner clearboth"></div>';
284 print
'<table class="border tableforfield centpercent">';
287 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
288 print nl2br($projectstatic->description);
293 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
294 print $form->showCategories($projectstatic->id,
'project', 1);
303 print
'<div class="clearboth"></div>';
316 print
dol_get_fiche_head($head,
'task_contact', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
319 $param = (
GETPOST(
'withproject') ?
'&withproject=1' :
'');
320 $linkback =
GETPOST(
'withproject') ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' :
'';
322 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
323 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
324 $object->next_prev_filter =
" fk_projet IN (".$db->sanitize($projectsListId).
")";
326 $object->next_prev_filter =
" fk_projet = ".$projectstatic->id;
332 if (empty($withproject)) {
333 $result = $projectstatic->fetch($object->fk_project);
334 $morehtmlref .=
'<div class="refidno">';
335 $morehtmlref .= $langs->trans(
"Project").
': ';
336 $morehtmlref .= $projectstatic->getNomUrl(1);
337 $morehtmlref .=
'<br>';
340 $morehtmlref .= $langs->trans(
"ThirdParty").
': ';
341 if ($projectstatic->socid > 0) {
342 $projectstatic->fetch_thirdparty();
343 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
346 $morehtmlref .=
'</div>';
349 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param, 0,
'',
'', 1);
369 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'" method="POST">';
370 print
'<input type="hidden" name="token" value="'.newToken().
'">';
371 print
'<input type="hidden" name="action" value="addcontact">';
372 print
'<input type="hidden" name="id" value="'.$id.
'">';
374 print
'<input type="hidden" name="withproject" value="'.$withproject.
'">';
377 print
'<table class="noborder centpercent">';
379 if ($action !=
'editline' && $user->rights->projet->creer) {
380 print
'<tr class="liste_titre">';
381 print
'<td>'.$langs->trans(
"NatureOfContact").
'</td>';
382 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
383 print
'<td>'.$langs->trans(
"Users").
'</td>';
384 print
'<td>'.$langs->trans(
"ContactType").
'</td>';
385 print
'<td colspan="3"> </td>';
389 print
'<tr class="oddeven nohover">';
391 print
'<td class="nowrap">';
392 print
img_object(
'',
'user').
' '.$langs->trans(
"Users");
396 print $conf->global->MAIN_INFO_SOCIETE_NOM;
401 if ($object->project->public) {
402 $contactsofproject =
'';
404 $contactsofproject = $projectstatic->getListContactId(
'internal');
406 print $form->select_dolusers((
GETPOSTISSET(
'userid') ?
GETPOST(
'userid',
'int') : $user->id),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 1, $langs->trans(
"ResourceNotAssignedToProject"));
409 $formcompany->selectTypeContact($object,
'',
'type',
'internal',
'rowid');
411 print
'<td class="right" colspan="3" ><input type="submit" class="button button-add" value="'.$langs->trans(
"Add").
'" name="addsourceinternal"></td>';
415 if ($projectstatic->socid) {
416 print
'<tr class="oddeven">';
418 print
'<td class="nowrap">';
419 print
img_object(
'',
'contact').
' '.$langs->trans(
"ThirdPartyContacts");
423 $thirdpartyofproject = $projectstatic->getListContactId(
'thirdparty');
424 $selectedCompany = isset($_GET[
"newcompany"]) ? $_GET[
"newcompany"] : $projectstatic->socid;
425 $selectedCompany = $formcompany->selectCompaniesForNewContact($object,
'id', $selectedCompany,
'newcompany', $thirdpartyofproject, 0,
'&withproject='.$withproject);
429 $contactofproject = $projectstatic->getListContactId(
'external');
430 print $form->selectcontacts($selectedCompany,
'',
'contactid', 0,
'', $contactofproject, 0,
'',
false, 0, 0);
431 $nbofcontacts = $form->num;
434 $formcompany->selectTypeContact($object,
'',
'typecontact',
'external',
'rowid');
436 print
'<td class="right" colspan="3" ><input type="submit" class="button" id="add-customer-contact" name="addsourceexternal" value="'.$langs->trans(
"Add").
'"';
437 if (!$nbofcontacts) {
446 print
'<tr class="liste_titre">';
447 print
'<td>'.$langs->trans(
"Source").
'</td>';
448 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
449 print
'<td>'.$langs->trans(
"TaskContact").
'</td>';
450 print
'<td>'.$langs->trans(
"ContactType").
'</td>';
451 print
'<td class="center">'.$langs->trans(
"Status").
'</td>';
452 print
'<td colspan="2"> </td>';
455 $companystatic =
new Societe($db);
457 foreach (array(
'internal',
'external') as $source) {
458 $tab = $object->liste_contact(-1, $source);
464 print
'<tr class="oddeven" valign="top">';
467 print
'<td class="left">';
468 if ($tab[$i][
'source'] ==
'internal') {
469 print $langs->trans(
"User");
471 if ($tab[$i][
'source'] ==
'external') {
472 print $langs->trans(
"ThirdPartyContact");
477 print
'<td class="left">';
478 if ($tab[$i][
'socid'] > 0) {
479 $companystatic->fetch($tab[$i][
'socid']);
480 print $companystatic->getNomUrl(1);
482 if ($tab[$i][
'socid'] < 0) {
483 print $conf->global->MAIN_INFO_SOCIETE_NOM;
485 if (!$tab[$i][
'socid']) {
492 if ($tab[$i][
'source'] ==
'internal') {
493 $userstatic->id = $tab[$i][
'id'];
494 $userstatic->lastname = $tab[$i][
'lastname'];
495 $userstatic->firstname = $tab[$i][
'firstname'];
496 $userstatic->photo = $tab[$i][
'photo'];
497 $userstatic->login = $tab[$i][
'login'];
498 $userstatic->email = $tab[$i][
'email'];
499 $userstatic->statut = $tab[$i][
'statuscontact'];
501 print $userstatic->getNomUrl(-1);
503 if ($tab[$i][
'source'] ==
'external') {
504 $contactstatic->id = $tab[$i][
'id'];
505 $contactstatic->lastname = $tab[$i][
'lastname'];
506 $contactstatic->firstname = $tab[$i][
'firstname'];
507 $contactstatic->email = $tab[$i][
'email'];
508 $contactstatic->statut = $tab[$i][
'statuscontact'];
509 print $contactstatic->getNomUrl(1);
514 print
'<td>'.$tab[$i][
'libelle'].
'</td>';
517 print
'<td class="center">';
519 if ($object->statut >= 0) {
520 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=swapstatut&ligne='.$tab[$i][
'rowid'].($withproject ?
'&withproject=1' :
'').
'">';
522 print $contactstatic->LibStatut($tab[$i][
'status'], 3);
523 if ($object->statut >= 0) {
529 print
'<td class="center nowrap">';
530 if ($user->rights->projet->creer) {
532 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=deleteline&token='.
newToken().
'&lineid='.$tab[$i][
'rowid'].($withproject ?
'&withproject=1' :
'').
'">';
533 print
img_picto($langs->trans(
'Unlink'),
'unlink');
547 print
"ErrorRecordNotFound";
551 if (is_object($hookmanager)) {
552 $hookmanager->initHooks(array(
'contacttpl'));
553 $parameters = array();
554 $reshook = $hookmanager->executeHooks(
'formContactTpl', $parameters, $object, $action);
project_prepare_head(Project $project, $moreparam= '')
Prepare array with list of tabs.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Class to manage Dolibarr users.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
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 from a POST of a form...
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)
restrictedArea($user, $features, $objectid=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.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
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.
isModEnabled($module)
Is Dolibarr module enabled.
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.