28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
34if (isModEnabled(
'category')) {
35 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
39$langsLoad = array(
'projects',
'companies');
40if (isModEnabled(
'eventorganization')) {
41 $langsLoad[] =
'eventorganization';
44$langs->loadLangs($langsLoad);
50$action =
GETPOST(
'action',
'aZ09');
52$mine =
GETPOST(
'mode') ==
'mine' ? 1 : 0;
57include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
58if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
65$hookmanager->initHooks(array(
'projectcontactcard',
'globalcard'));
70$permissiontoadd = $user->hasRight(
'projet',
'creer');
77$parameters = array(
'id' => $id);
78$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
85 $formconfirmtoaddtasks =
'';
86 if ($action ==
'addcontact' && $permissiontoadd) {
87 $form =
new Form($db);
89 $source =
GETPOST(
"source",
'aZ09');
91 $taskstatic =
new Task($db);
92 $task_array = $taskstatic->getTasksArray(0, 0,
$object->id, 0, 0);
93 $nbTasks = count($task_array);
96 $type_to = (
GETPOST(
'typecontact') ?
'typecontact='.GETPOST(
'typecontact') :
'type='.GETPOST(
'type'));
98 $affect_to = (
GETPOST(
'userid') ?
'userid='.$personToAffect :
'contactid='.$personToAffect);
99 $url_redirect =
'?id='.$object->id.
'&'.$affect_to.
'&'.$type_to.
'&source='.$source;
101 if ($personToAffect > 0 && (!
getDolGlobalString(
'PROJECT_HIDE_TASKS') || $nbTasks > 0)) {
102 $text = $langs->trans(
'AddPersonToTask');
103 $textbody = $text.
' (<a href="#" class="selectall">'.$langs->trans(
"SelectAll").
'</a>)';
104 $formquestion = array(
'text' => $textbody);
106 $task_to_affect = array();
107 foreach ($task_array as $task) {
108 $task_already_affected =
false;
109 $personsLinked = $task->liste_contact(-1, $source);
110 if (!is_array($personsLinked)) {
114 foreach ($personsLinked as $person) {
115 if ($person[
'id'] == $personToAffect) {
116 $task_already_affected =
true;
120 if (!$task_already_affected) {
121 $task_to_affect[$task->id] = $task->id;
126 if (empty($task_to_affect)) {
127 $action =
'addcontact_confirm';
130 foreach ($task_array as $task) {
132 $val = $task->ref .
' '.dol_trunc($task->label);
133 $formquestion[] = array(
135 'name' =>
'person_'.$key.
',person_role_'.$key,
136 'label' =>
'<input type="checkbox" class="flat'.(in_array($key, $task_to_affect) ?
' taskcheckboxes"' :
'" checked disabled').
' id="person_'.$key.
'" name="person_'.$key.
'" value="1"> <label for="person_'.$key.
'">'.$val.
'<label>',
137 'value' => $formcompany->selectTypeContact($taskstatic,
'',
'person_role_'.$key, $source,
'position', 0,
'minwidth100imp', 0, 1)
140 $formquestion[] = array(
'type' =>
'other',
'name' =>
'tasksavailable',
'label' =>
'',
'value' =>
'<input type="hidden" id="tasksavailable" name="tasksavailable" value="'.implode(
',', array_keys($task_to_affect)).
'">');
143 $formconfirmtoaddtasks = $form->formconfirm($_SERVER[
'PHP_SELF'] . $url_redirect, $text,
'',
'addcontact_confirm', $formquestion,
'', 1, 300, 590);
144 $formconfirmtoaddtasks .=
'
146 $(document).ready(function() {
147 var saveprop = false;
148 $(".selectall").click(function(){
149 console.log("We click on select all with "+saveprop);
151 $(".taskcheckboxes").prop("checked", true);
154 $(".taskcheckboxes").prop("checked", false);
161 $action =
'addcontact_confirm';
166 if ($action ==
'addcontact_confirm' && $permissiontoadd) {
167 if (
GETPOST(
'confirm',
'alpha') ==
'no') {
168 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
175 $contactarray = array();
177 $errorgrouparray = array();
180 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
182 $result = $usergroup->fetch($groupid);
184 $excludefilter =
'statut = 1';
185 $tmpcontactarray = $usergroup->listUsersForGroup($excludefilter, 0);
186 if ($contactarray <= 0) {
189 foreach ($tmpcontactarray as $tmpuser) {
190 $contactarray[] = $tmpuser->id;
196 } elseif (! ($contactid > 0)) {
198 $langs->load(
"errors");
199 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Contact")),
null,
'errors');
201 $contactarray[] = $contactid;
206 if (!$error && $result > 0 && $id > 0) {
207 foreach ($contactarray as $key => $contactid) {
208 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
213 $errorgrouparray[] = $contactid;
215 $langs->load(
"errors");
216 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
218 } elseif ($result < 0) {
219 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
222 $errorgrouparray[] = $contactid;
224 $langs->load(
"errors");
225 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
232 $affecttotask =
GETPOST(
'tasksavailable',
'intcomma');
233 if (!empty($affecttotask)) {
234 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
235 $task_to_affect = explode(
',', $affecttotask);
236 if (!empty($task_to_affect)) {
237 foreach ($task_to_affect as $task_id) {
238 if (GETPOSTISSET(
'person_'.$task_id) &&
GETPOST(
'person_'.$task_id,
'san_alpha')) {
239 $tasksToAffect =
new Task($db);
240 $result = $tasksToAffect->fetch($task_id);
244 $result = $tasksToAffect->add_contact($contactid,
GETPOST(
'person_role_'.$task_id),
GETPOST(
"source",
'aZ09'));
246 if ($tasksToAffect->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
247 $langs->load(
"errors");
248 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
260 if ($errorgroup > 0) {
261 $langs->load(
"errors");
262 if ($errorgroup == count($contactarray)) {
263 setEventMessages($langs->trans(
"ErrorThisGroupIsAlreadyDefinedAsThisType"),
null,
'errors');
265 $tmpuser =
new User($db);
266 foreach ($errorgrouparray as $key => $value) {
267 $tmpuser->fetch($value);
274 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
280 if ($action ==
'swapstatut' && $permissiontoadd) {
289 if (($action ==
'deleteline' || $action ==
'deletecontact') && $permissiontoadd) {
294 header(
"Location: contact.php?id=".
$object->id);
307$form =
new Form($db);
308$contactstatic =
new Contact($db);
309$userstatic =
new User($db);
311$title = $langs->trans(
'ProjectContact').
' - '.
$object->ref.
' '.
$object->name;
313 $title =
$object->ref.
' '.
$object->name.
' - '.$langs->trans(
'ProjectContact');
316$help_url =
'EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte';
318llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project page-card_contact');
322if ($id > 0 || !empty($ref)) {
326 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
331 $userWrite =
$object->restrictedProjectArea($user,
'write');
338 $formconfirm = $formconfirmtoaddtasks;
341 $parameters = array(
'formConfirm' => $formconfirm);
342 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
343 if (empty($reshook)) {
344 $formconfirm .= $hookmanager->resPrint;
345 } elseif ($reshook > 0) {
346 $formconfirm = $hookmanager->resPrint;
354 if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
355 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
356 $tmpurl = preg_replace(
'/__SOCID__/', (
string)
$object->socid, $tmpurl);
357 $linkback =
'<a href="'.$tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
359 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
362 $morehtmlref =
'<div class="refidno">';
365 $morehtmlref .=
'<br>';
367 if (!empty(
$object->thirdparty->id) &&
$object->thirdparty->id > 0) {
368 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'project');
370 $morehtmlref .=
'</div>';
373 if (!$user->hasRight(
'projet',
'all',
'lire')) {
374 $objectsListId =
$object->getProjectsAuthorizedForUser($user, 0, 0);
375 $object->next_prev_filter =
"rowid IN (".$db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0').
")";
378 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
381 print
'<div class="fichecenter">';
382 print
'<div class="fichehalfleft">';
383 print
'<div class="underbanner clearboth"></div>';
385 print
'<table class="border tableforfield centpercent">';
389 print
'<tr><td class="tdtop">';
390 print $langs->trans(
"Usage");
394 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
395 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
396 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
400 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_task ?
' checked="checked"' :
'')).
'"> ';
401 $htmltext = $langs->trans(
"ProjectFollowTasks");
402 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
406 print
'<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET(
'usage_bill_time') ? (
GETPOST(
'usage_bill_time',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_bill_time ?
' checked="checked"' :
'')).
'"> ';
407 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
408 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
411 if (isModEnabled(
'eventorganization')) {
412 print
'<input type="checkbox" disabled name="usage_organize_event"'.(GETPOSTISSET(
'usage_organize_event') ? (
GETPOST(
'usage_organize_event',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_organize_event ?
' checked="checked"' :
'')).
'"> ';
413 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
414 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
420 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
422 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
423 print $langs->trans(
'SharedProject');
425 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
426 print $langs->trans(
'PrivateProject');
432 print
'<tr><td>'.$langs->trans(
"OpportunityStatus").
'</td><td>';
435 print $langs->trans(
"OppStatus".$code);
439 print
' <span title="'.$langs->trans(
"OpportunityProbability").
'"> / ';
440 if (strcmp(
$object->opp_percent,
'')) {
441 print
price(
$object->opp_percent, 0, $langs, 1, 0).
' %';
443 print
'</span></td></tr>';
446 print
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
447 if (strcmp(
$object->opp_amount,
'')) {
448 print
'<span class="amount">'.price(
$object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency).
'</span>';
449 if (strcmp(
$object->opp_percent,
'')) {
450 print
' <span title="'.dol_escape_htmltag($langs->trans(
'OpportunityWeightedAmount')).
'"><span class="opacitymedium">'.$langs->trans(
"OpportunityWeightedAmountShort").
'</span>: <span class="amount">'.
price(
$object->opp_amount *
$object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).
'</span></span>';
457 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
458 if (!is_null(
$object->budget_amount) && strcmp(
$object->budget_amount,
'')) {
459 print
'<span class="amount">'.price(
$object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).
'</span>';
464 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
466 print($start ? $start :
'?');
468 print
' <span class="opacitymedium">-</span> ';
469 print($end ? $end :
'?');
477 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
482 print
'<div class="fichehalfright">';
483 print
'<div class="underbanner clearboth"></div>';
485 print
'<table class="border tableforfield centpercent">';
488 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
493 if (isModEnabled(
'category')) {
494 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
495 print $form->showCategories(
$object->id, Categorie::TYPE_PROJECT, 1);
504 print
'<div class="clearboth"></div>';
511 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array(
'/core/tpl'));
512 foreach ($dirtpls as $reldir) {
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 user groups.
Class to manage Dolibarr users.
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.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
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_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
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).
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.