27require
"../../main.inc.php";
28require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
43$langs->loadLangs(array(
'projects',
'companies'));
47$action =
GETPOST(
'action',
'aZ09');
48$confirm =
GETPOST(
'confirm',
'alpha');
50$project_ref =
GETPOST(
'project_ref',
'alpha');
53$projectstatic =
new Project($db);
70if ($action ==
'addcontact' && $user->hasRight(
'projet',
'creer')) {
72 if (
GETPOST(
"addsourceexternal")) {
76 $result =
$object->fetch($id, $ref);
78 if ($result > 0 && $id > 0) {
79 if ($source ==
'internal') {
84 $typeid =
GETPOST(
'typecontact');
86 if ($idfortaskuser == -2) {
87 $result = $projectstatic->fetch(
$object->fk_project);
91 $contactsofproject = $projectstatic->getListContactId(
'internal');
92 foreach ($contactsofproject as $key => $val) {
93 $result =
$object->add_contact($val, $typeid, $source);
97 $result =
$object->add_contact($idfortaskuser, $typeid, $source);
102 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
$object->id.($withproject ?
'&withproject=1' :
''));
105 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
106 $langs->load(
"errors");
107 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
115if ($action ==
'swapstatut' && $user->hasRight(
'projet',
'creer')) {
116 if (
$object->fetch($id, $ref)) {
124if ($action ==
'deleteline' && $user->hasRight(
'projet',
'creer')) {
129 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
$object->id.($withproject ?
'&withproject=1' :
''));
137if (!empty($project_ref) && !empty($withproject)) {
138 if ($projectstatic->fetch(0, $project_ref) > 0) {
139 $tasksarray =
$object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
140 if (count($tasksarray) > 0) {
141 $id = $tasksarray[0]->id;
143 header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.($withproject ?
'&withproject=1' :
'').(empty($mode) ?
'' :
'&mode='.$mode));
152$form =
new Form($db);
154$contactstatic =
new Contact($db);
155$userstatic =
new User($db);
156$result = $projectstatic->fetch(
$object->fk_project);
158$title =
$object->ref .
' - ' . $langs->trans(
"Contacts");
159if (!empty($withproject)) {
160 $title .=
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ?
': '.$projectstatic->ref :
'') ;
164llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project project-tasks page-task_contact');
173if ($id > 0 || !empty($ref)) {
174 if (
$object->fetch($id, $ref) > 0) {
175 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
180 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic,
'fetchComments') && empty($projectstatic->comments)) {
181 $projectstatic->fetchComments();
183 if (!empty($projectstatic->socid)) {
184 $projectstatic->fetch_thirdparty();
187 $object->project = clone $projectstatic;
189 $userWrite = $projectstatic->restrictedProjectArea($user,
'write');
195 print
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ?
'projectpub' :
'project'));
197 $param = (!empty($mode) && $mode ==
'mine' ?
'&mode=mine' :
'');
201 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
203 $morehtmlref =
'<div class="refidno">';
205 $morehtmlref .= $projectstatic->title;
207 if (isset($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
208 $morehtmlref .=
'<br>'.$projectstatic->thirdparty->getNomUrl(1,
'project');
210 $morehtmlref .=
'</div>';
213 if (!$user->hasRight(
'projet',
'all',
'lire')) {
214 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
215 $projectstatic->next_prev_filter =
"rowid:IN:(".$db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0').
")";
218 dol_banner_tab($projectstatic,
'project_ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
220 print
'<div class="fichecenter">';
221 print
'<div class="fichehalfleft">';
222 print
'<div class="underbanner clearboth"></div>';
224 print
'<table class="border tableforfield centpercent">';
228 print
'<tr><td class="tdtop">';
229 print $langs->trans(
"Usage");
233 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
234 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
235 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
239 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($projectstatic->usage_task ?
' checked="checked"' :
'')).
'"> ';
240 $htmltext = $langs->trans(
"ProjectFollowTasks");
241 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
245 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"' :
'')).
'"> ';
246 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
247 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
250 if (isModEnabled(
'eventorganization')) {
251 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"' :
'')).
'"> ';
252 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
253 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
259 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
260 if ($projectstatic->public) {
261 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
262 print $langs->trans(
'SharedProject');
264 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
265 print $langs->trans(
'PrivateProject');
270 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
271 if (isset($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount,
'')) {
272 print
price($projectstatic->budget_amount, 0, $langs, 1, 0, 0,
$conf->currency);
277 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
279 print($start ? $start :
'?');
282 print($end ? $end :
'?');
283 if ($projectstatic->hasDelay()) {
295 print
'<div class="fichehalfright">';
296 print
'<div class="underbanner clearboth"></div>';
298 print
'<table class="border tableforfield centpercent">';
301 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
302 print nl2br($projectstatic->description);
306 if (isModEnabled(
'category')) {
307 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
308 print $form->showCategories($projectstatic->id,
'project', 1);
317 print
'<div class="clearboth"></div>';
330 print
dol_get_fiche_head($head,
'task_contact', $langs->trans(
"Task"), -1,
'projecttask', 0,
'',
'reposition');
333 $param = (
GETPOST(
'withproject') ?
'&withproject=1' :
'');
334 $linkback =
GETPOST(
'withproject') ?
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' :
'';
336 if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
337 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
338 $object->next_prev_filter =
"fk_projet:IN:(".$db->sanitize($projectsListId).
")";
340 $object->next_prev_filter =
"fk_projet:=:".((int) $projectstatic->id);
346 if (empty($withproject)) {
347 $result = $projectstatic->fetch(
$object->fk_project);
348 $morehtmlref .=
'<div class="refidno">';
349 $morehtmlref .= $langs->trans(
"Project").
': ';
350 $morehtmlref .= $projectstatic->getNomUrl(1);
351 $morehtmlref .=
'<br>';
354 $morehtmlref .= $langs->trans(
"ThirdParty").
': ';
355 if ($projectstatic->socid > 0) {
356 $projectstatic->fetch_thirdparty();
357 $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
360 $morehtmlref .=
'</div>';
363 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $param, 0,
'',
'', 1);
383 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$id.
'" method="POST">';
384 print
'<input type="hidden" name="token" value="'.newToken().
'">';
385 print
'<input type="hidden" name="action" value="addcontact">';
386 print
'<input type="hidden" name="id" value="'.$id.
'">';
388 print
'<input type="hidden" name="withproject" value="'.$withproject.
'">';
391 print
'<div class="div-table-responsive">';
392 print
'<table class="noborder centpercent">';
394 if ($action !=
'editline' && $user->hasRight(
'projet',
'creer')) {
395 print
'<tr class="liste_titre">';
396 print
'<td>'.$langs->trans(
"NatureOfContact").
'</td>';
397 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
398 print
'<td>'.$langs->trans(
"Users").
'</td>';
399 print
'<td>'.$langs->trans(
"ContactType").
'</td>';
400 print
'<td colspan="3"> </td>';
404 print
'<tr class="oddeven nohover">';
406 print
'<td class="nowrap">';
407 print
img_object(
'',
'user').
' '.$langs->trans(
"Users");
411 print
$conf->global->MAIN_INFO_SOCIETE_NOM;
416 if (
$object->project->public) {
417 $contactsofproject =
'';
419 $contactsofproject = $projectstatic->getListContactId(
'internal');
421 print $form->select_dolusers((GETPOSTISSET(
'userid') ?
GETPOSTINT(
'userid') : $user->id),
'userid', 0,
'', 0,
'', $contactsofproject, 0, 0, 0,
'', 1, $langs->trans(
"ResourceNotAssignedToProject"));
424 $formcompany->selectTypeContact($object,
'',
'type',
'internal',
'position');
426 print
'<td class="right" colspan="3" ><input type="submit" class="button button-add small" value="'.$langs->trans(
"Add").
'" name="addsourceinternal"></td>';
430 if ($projectstatic->socid) {
431 print
'<tr class="oddeven">';
433 print
'<td class="nowrap">';
434 print
img_object(
'',
'contact').
' '.$langs->trans(
"ThirdPartyContacts");
438 $thirdpartyofproject = $projectstatic->getListContactId(
'thirdparty');
439 $selectedCompany = GETPOSTISSET(
"newcompany") ?
GETPOST(
"newcompany") : $projectstatic->socid;
440 $selectedCompany = $formcompany->selectCompaniesForNewContact($object,
'id', $selectedCompany,
'newcompany', $thirdpartyofproject, 0,
'&withproject='.$withproject);
444 $contactofproject = $projectstatic->getListContactId(
'external');
446 print $form->select_contact($selectedCompany,
'',
'contactid', 0,
'', $contactofproject, 0,
'maxwidth300 widthcentpercentminusx',
true);
447 $nbofcontacts = $form->num;
450 $formcompany->selectTypeContact($object,
'',
'typecontact',
'external',
'position');
452 print
'<td class="right" colspan="3" ><input type="submit" class="button button-add small" id="add-customer-contact" name="addsourceexternal" value="'.$langs->trans(
"Add").
'"';
453 if (!$nbofcontacts) {
462 print
'<tr class="liste_titre">';
463 print
'<td>'.$langs->trans(
"Source").
'</td>';
464 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
465 print
'<td>'.$langs->trans(
"TaskContact").
'</td>';
466 print
'<td>'.$langs->trans(
"ContactType").
'</td>';
467 print
'<td class="center">'.$langs->trans(
"Status").
'</td>';
468 print
'<td colspan="2"> </td>';
471 $companystatic =
new Societe($db);
473 foreach (array(
'internal',
'external') as $source) {
474 $tab =
$object->liste_contact(-1, $source);
480 print
'<tr class="oddeven" valign="top">';
483 print
'<td class="left">';
484 if ($tab[$i][
'source'] ==
'internal') {
485 print $langs->trans(
"User");
487 if ($tab[$i][
'source'] ==
'external') {
488 print $langs->trans(
"ThirdPartyContact");
493 print
'<td class="left">';
494 if ($tab[$i][
'socid'] > 0) {
495 $companystatic->fetch($tab[$i][
'socid']);
496 print $companystatic->getNomUrl(1);
498 if ($tab[$i][
'socid'] < 0) {
499 print
$conf->global->MAIN_INFO_SOCIETE_NOM;
501 if (!$tab[$i][
'socid']) {
508 if ($tab[$i][
'source'] ==
'internal') {
509 $userstatic->id = $tab[$i][
'id'];
510 $userstatic->lastname = $tab[$i][
'lastname'];
511 $userstatic->firstname = $tab[$i][
'firstname'];
512 $userstatic->photo = $tab[$i][
'photo'];
513 $userstatic->login = $tab[$i][
'login'];
514 $userstatic->email = $tab[$i][
'email'];
515 $userstatic->gender = $tab[$i][
'gender'];
516 $userstatic->status = $tab[$i][
'statuscontact'];
518 print $userstatic->getNomUrl(-1);
520 if ($tab[$i][
'source'] ==
'external') {
521 $contactstatic->id = $tab[$i][
'id'];
522 $contactstatic->lastname = $tab[$i][
'lastname'];
523 $contactstatic->firstname = $tab[$i][
'firstname'];
524 $contactstatic->email = $tab[$i][
'email'];
525 $contactstatic->statut = $tab[$i][
'statuscontact'];
526 print $contactstatic->getNomUrl(1);
531 print
'<td>'.$tab[$i][
'libelle'].
'</td>';
534 print
'<td class="center">';
537 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=swapstatut&ligne='.$tab[$i][
'rowid'].($withproject ?
'&withproject=1' :
'').
'">';
539 print $contactstatic->LibStatut($tab[$i][
'status'], 3);
546 print
'<td class="center nowrap">';
547 if ($user->hasRight(
'projet',
'creer')) {
549 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deleteline&token='.
newToken().
'&lineid='.$tab[$i][
'rowid'].($withproject ?
'&withproject=1' :
'').
'">';
550 print
img_picto($langs->trans(
'Unlink'),
'unlink');
565 print
"ErrorRecordNotFound";
569if (is_object($hookmanager)) {
570 $hookmanager->initHooks(array(
'contacttpl'));
571 $parameters = array();
572 $reshook = $hookmanager->executeHooks(
'formContactTpl', $parameters, $object, $action);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
Show tabs of a record.
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=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.