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';
47$langsLoad = array(
'projects',
'companies');
48if (isModEnabled(
'eventorganization')) {
49 $langsLoad[] =
'eventorganization';
52$langs->loadLangs($langsLoad);
58$action =
GETPOST(
'action',
'aZ09');
60$mine =
GETPOST(
'mode') ==
'mine' ? 1 : 0;
65include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
66if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
73$hookmanager->initHooks(array(
'projectcontactcard',
'globalcard'));
78$permissiontoadd = $user->hasRight(
'projet',
'creer');
85$parameters = array(
'id' => $id);
86$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
93 $formconfirmtoaddtasks =
'';
94 if ($action ==
'addcontact' && $permissiontoadd) {
95 $form =
new Form($db);
97 $source =
GETPOST(
"source",
'aZ09');
99 $taskstatic =
new Task($db);
100 $task_array = $taskstatic->getTasksArray(0, 0,
$object->id, 0, 0);
101 $nbTasks = count($task_array);
104 $type_to = (
GETPOST(
'typecontact') ?
'typecontact='.GETPOST(
'typecontact') :
'type='.GETPOST(
'type'));
106 $affect_to = (
GETPOST(
'userid') ?
'userid='.$personToAffect :
'contactid='.$personToAffect);
107 $url_redirect =
'?id='.$object->id.
'&'.$affect_to.
'&'.$type_to.
'&source='.$source;
109 if ($personToAffect > 0 && (!
getDolGlobalString(
'PROJECT_HIDE_TASKS') || $nbTasks > 0)) {
110 $text = $langs->trans(
'AddPersonToTask');
111 $textbody = $text.
' (<a href="#" class="selectall">'.$langs->trans(
"SelectAll").
'</a>)';
112 $formquestion = array(
'text' => $textbody);
114 $task_to_affect = array();
115 foreach ($task_array as $task) {
116 $task_already_affected =
false;
117 $personsLinked = $task->liste_contact(-1, $source);
118 if (!is_array($personsLinked)) {
122 foreach ($personsLinked as $person) {
123 if ($person[
'id'] == $personToAffect) {
124 $task_already_affected =
true;
128 if (!$task_already_affected) {
129 $task_to_affect[$task->id] = $task->id;
134 if (empty($task_to_affect)) {
135 $action =
'addcontact_confirm';
138 foreach ($task_array as $task) {
140 $val = $task->ref .
' '.dol_trunc($task->label);
141 $formquestion[] = array(
143 'name' =>
'person_'.$key.
',person_role_'.$key,
144 '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>',
145 'value' => $formcompany->selectTypeContact($taskstatic,
'',
'person_role_'.$key, $source,
'position', 0,
'minwidth100imp', 0, 1)
148 $formquestion[] = array(
'type' =>
'other',
'name' =>
'tasksavailable',
'label' =>
'',
'value' =>
'<input type="hidden" id="tasksavailable" name="tasksavailable" value="'.implode(
',', array_keys($task_to_affect)).
'">');
151 $formconfirmtoaddtasks = $form->formconfirm($_SERVER[
'PHP_SELF'] . $url_redirect, $text,
'',
'addcontact_confirm', $formquestion,
'', 1, 300, 590);
152 $formconfirmtoaddtasks .=
'
154 $(document).ready(function() {
155 var saveprop = false;
156 $(".selectall").click(function(){
157 console.log("We click on select all with "+saveprop);
159 $(".taskcheckboxes").prop("checked", true);
162 $(".taskcheckboxes").prop("checked", false);
169 $action =
'addcontact_confirm';
174 if ($action ==
'addcontact_confirm' && $permissiontoadd) {
175 if (
GETPOST(
'confirm',
'alpha') ==
'no') {
176 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
183 $contactarray = array();
185 $errorgrouparray = array();
188 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
190 $result = $usergroup->fetch($groupid);
192 $excludefilter =
'statut = 1';
193 $tmpcontactarray = $usergroup->listUsersForGroup($excludefilter, 0);
194 if ($contactarray <= 0) {
197 foreach ($tmpcontactarray as $tmpuser) {
198 $contactarray[] = $tmpuser->id;
204 } elseif (! ($contactid > 0)) {
206 $langs->load(
"errors");
207 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Contact")),
null,
'errors');
209 $contactarray[] = $contactid;
214 if (!$error && $result > 0 && $id > 0) {
215 foreach ($contactarray as $key => $contactid) {
216 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
221 $errorgrouparray[] = $contactid;
223 $langs->load(
"errors");
224 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
226 } elseif ($result < 0) {
227 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
230 $errorgrouparray[] = $contactid;
232 $langs->load(
"errors");
233 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
240 $affecttotask =
GETPOST(
'tasksavailable',
'intcomma');
241 if (!empty($affecttotask)) {
242 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
243 $task_to_affect = explode(
',', $affecttotask);
244 if (!empty($task_to_affect)) {
245 foreach ($task_to_affect as $task_id) {
246 if (GETPOSTISSET(
'person_'.$task_id) &&
GETPOST(
'person_'.$task_id,
'san_alpha')) {
247 $tasksToAffect =
new Task($db);
248 $result = $tasksToAffect->fetch($task_id);
252 $result = $tasksToAffect->add_contact($contactid,
GETPOST(
'person_role_'.$task_id),
GETPOST(
"source",
'aZ09'));
254 if ($tasksToAffect->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
255 $langs->load(
"errors");
256 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
268 if ($errorgroup > 0) {
269 $langs->load(
"errors");
270 if ($errorgroup == count($contactarray)) {
271 setEventMessages($langs->trans(
"ErrorThisGroupIsAlreadyDefinedAsThisType"),
null,
'errors');
273 $tmpuser =
new User($db);
274 foreach ($errorgrouparray as $key => $value) {
275 $tmpuser->fetch($value);
282 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
288 if ($action ==
'swapstatut' && $permissiontoadd) {
297 if (($action ==
'deleteline' || $action ==
'deletecontact') && $permissiontoadd) {
302 header(
"Location: contact.php?id=".
$object->id);
315$form =
new Form($db);
316$contactstatic =
new Contact($db);
317$userstatic =
new User($db);
319$title = $langs->trans(
'ProjectContact').
' - '.
$object->ref.
' '.
$object->name;
321 $title =
$object->ref.
' '.
$object->name.
' - '.$langs->trans(
'ProjectContact');
324$help_url =
'EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte';
326llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project page-card_contact');
330if ($id > 0 || !empty($ref)) {
334 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
339 $userWrite =
$object->restrictedProjectArea($user,
'write');
346 $formconfirm = $formconfirmtoaddtasks;
349 $parameters = array(
'formConfirm' => $formconfirm);
350 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
351 if (empty($reshook)) {
352 $formconfirm .= $hookmanager->resPrint;
353 } elseif ($reshook > 0) {
354 $formconfirm = $hookmanager->resPrint;
362 if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
363 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
364 $tmpurl = preg_replace(
'/__SOCID__/', (
string)
$object->socid, $tmpurl);
365 $linkback =
'<a href="'.$tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
367 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
370 $morehtmlref =
'<div class="refidno">';
373 $morehtmlref .=
'<br>';
375 if (!empty(
$object->thirdparty->id) &&
$object->thirdparty->id > 0) {
376 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'project');
378 $morehtmlref .=
'</div>';
381 if (!$user->hasRight(
'projet',
'all',
'lire')) {
382 $objectsListId =
$object->getProjectsAuthorizedForUser($user, 0, 0);
383 $object->next_prev_filter =
"rowid:IN:(".$db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0').
")";
386 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
389 print
'<div class="fichecenter">';
390 print
'<div class="fichehalfleft">';
391 print
'<div class="underbanner clearboth"></div>';
393 print
'<table class="border tableforfield centpercent">';
397 print
'<tr><td class="tdtop">';
398 print $langs->trans(
"Usage");
402 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
403 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
404 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
408 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_task ?
' checked="checked"' :
'')).
'"> ';
409 $htmltext = $langs->trans(
"ProjectFollowTasks");
410 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
414 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"' :
'')).
'"> ';
415 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
416 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
419 if (isModEnabled(
'eventorganization')) {
420 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"' :
'')).
'"> ';
421 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
422 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
428 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
430 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
431 print $langs->trans(
'SharedProject');
433 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
434 print $langs->trans(
'PrivateProject');
440 print
'<tr><td>'.$langs->trans(
"OpportunityStatus").
'</td><td>';
443 print $langs->trans(
"OppStatus".$code);
447 print
' <span title="'.$langs->trans(
"OpportunityProbability").
'"> / ';
448 if (strcmp(
$object->opp_percent,
'')) {
449 print
price(
$object->opp_percent, 0, $langs, 1, 0).
' %';
451 print
'</span></td></tr>';
454 print
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
455 if (strcmp(
$object->opp_amount,
'')) {
456 print
'<span class="amount">'.price(
$object->opp_amount, 0, $langs, 1, 0, -1,
$conf->currency).
'</span>';
457 if (strcmp(
$object->opp_percent,
'')) {
458 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>';
465 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
466 if (!is_null(
$object->budget_amount) && strcmp(
$object->budget_amount,
'')) {
467 print
'<span class="amount">'.price(
$object->budget_amount, 0, $langs, 1, 0, 0,
$conf->currency).
'</span>';
472 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
474 print($start ? $start :
'?');
476 print
' <span class="opacitymedium">-</span> ';
477 print($end ? $end :
'?');
485 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
490 print
'<div class="fichehalfright">';
491 print
'<div class="underbanner clearboth"></div>';
493 print
'<table class="border tableforfield centpercent">';
496 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
501 if (isModEnabled(
'category')) {
502 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
503 print $form->showCategories(
$object->id, Categorie::TYPE_PROJECT, 1);
512 print
'<div class="clearboth"></div>';
519 $dirtpls = array_merge(
$conf->modules_parts[
'tpl'], array(
'/core/tpl'));
520 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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.