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';
35 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
47$langsLoad = array(
'projects',
'companies');
49 $langsLoad[] =
'eventorganization';
52$langs->loadLangs($langsLoad);
58$action =
GETPOST(
'action',
'aZ09');
60$mine =
GETPOST(
'mode') ==
'mine' ? 1 : 0;
64include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
72$hookmanager->initHooks(array(
'projectcontactcard',
'globalcard'));
77$permissiontoadd = $user->hasRight(
'projet',
'creer');
84$parameters = array(
'id' => $id);
85$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
90$formconfirmtoaddtasks =
'';
93 if ($action ==
'addcontact' && $permissiontoadd) {
96 $source =
GETPOST(
"source",
'aZ09');
99 $task_array = $taskstatic->getTasksArray(
null,
null,
$object->id, 0, 0);
100 $nbTasks = count($task_array);
103 $type_to = (
GETPOST(
'typecontact') ?
'typecontact='.GETPOST(
'typecontact') :
'type='.GETPOST(
'type'));
105 $affect_to = (
GETPOST(
'userid') ?
'userid='.$personToAffect :
'contactid='.$personToAffect);
106 $url_redirect =
'?id='.$object->id.
'&'.$affect_to.
'&'.$type_to.
'&source='.$source;
108 if ($personToAffect > 0 && (!
getDolGlobalString(
'PROJECT_HIDE_TASKS') || $nbTasks > 0)) {
109 $text = $langs->trans(
'AddPersonToTask');
110 $textbody = $text.
' (<a href="#" class="selectall">'.$langs->trans(
"SelectAll").
'</a>)';
111 $formquestion = array(
'text' => $textbody);
113 $task_to_affect = array();
114 foreach ($task_array as $task) {
115 $task_already_affected =
false;
116 $personsLinked = $task->liste_contact(-1, $source);
117 if (!is_array($personsLinked)) {
121 foreach ($personsLinked as $person) {
122 if ($person[
'id'] == $personToAffect) {
123 $task_already_affected =
true;
127 if (!$task_already_affected) {
128 $task_to_affect[$task->id] = $task->id;
133 if (empty($task_to_affect)) {
134 $action =
'addcontact_confirm';
137 foreach ($task_array as $task) {
139 $val = $task->ref .
' '.dol_trunc($task->label);
140 $formquestion[] = array(
142 'name' =>
'person_'.$key.
',person_role_'.$key,
143 '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>',
144 'value' => $formcompany->selectTypeContact($taskstatic,
'',
'person_role_'.$key, $source,
'position', 0,
'minwidth100imp', 0, 1)
147 $formquestion[] = array(
'type' =>
'other',
'name' =>
'tasksavailable',
'label' =>
'',
'value' =>
'<input type="hidden" id="tasksavailable" name="tasksavailable" value="'.implode(
',', array_keys($task_to_affect)).
'">');
150 $formconfirmtoaddtasks = $form->formconfirm($_SERVER[
'PHP_SELF'] . $url_redirect, $text,
'',
'addcontact_confirm', $formquestion,
'', 1, 300, 590);
151 $formconfirmtoaddtasks .=
'
153 $(document).ready(function() {
154 var saveprop = false;
155 $(".selectall").click(function(){
156 console.log("We click on select all with "+saveprop);
158 $(".taskcheckboxes").prop("checked", true);
161 $(".taskcheckboxes").prop("checked", false);
168 $action =
'addcontact_confirm';
173 if ($action ==
'addcontact_confirm' && $permissiontoadd) {
174 if (
GETPOST(
'confirm',
'alpha') ==
'no') {
175 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
182 $contactarray = array();
184 $errorgrouparray = array();
187 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
189 $result = $usergroup->fetch($groupid);
191 $excludefilter =
'statut = 1';
192 $tmpcontactarray = $usergroup->listUsersForGroup($excludefilter, 0);
193 if (!is_array($tmpcontactarray)) {
196 foreach ($tmpcontactarray as $tmpuser) {
197 $contactarray[] = $tmpuser->id;
203 } elseif (! ($contactid > 0)) {
205 $langs->load(
"errors");
206 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Contact")),
null,
'errors');
208 $contactarray[] = $contactid;
213 if (!$error && $result > 0 && $id > 0) {
214 foreach ($contactarray as $key => $contactid) {
215 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
220 $errorgrouparray[] = $contactid;
222 $langs->load(
"errors");
223 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
225 } elseif ($result < 0) {
226 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
229 $errorgrouparray[] = $contactid;
231 $langs->load(
"errors");
232 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
239 $affecttotask =
GETPOST(
'tasksavailable',
'intcomma');
240 if (!empty($affecttotask)) {
241 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
242 $task_to_affect = explode(
',', $affecttotask);
243 if (!empty($task_to_affect)) {
244 foreach ($task_to_affect as $task_id) {
245 if (GETPOSTISSET(
'person_'.$task_id) &&
GETPOST(
'person_'.$task_id,
'aZ09comma')) {
246 $tasksToAffect =
new Task(
$db);
247 $result = $tasksToAffect->fetch((
int) $task_id);
251 $result = $tasksToAffect->add_contact($contactid,
GETPOST(
'person_role_'.$task_id),
GETPOST(
"source",
'aZ09'));
253 if ($tasksToAffect->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
254 $langs->load(
"errors");
255 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
267 if ($errorgroup > 0) {
268 $langs->load(
"errors");
269 if ($errorgroup == count($contactarray)) {
270 setEventMessages($langs->trans(
"ErrorThisGroupIsAlreadyDefinedAsThisType"),
null,
'errors');
273 foreach ($errorgrouparray as $key => $value) {
274 $tmpuser->fetch($value);
281 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
287 if ($action ==
'swapstatut' && $permissiontoadd) {
296 if (($action ==
'deleteline' || $action ==
'deletecontact') && $permissiontoadd) {
301 header(
"Location: contact.php?id=".
$object->id);
318$title = $langs->trans(
'ProjectContact').
' - '.
$object->ref.
' '.
$object->name;
320 $title =
$object->ref.
' '.
$object->name.
' - '.$langs->trans(
'ProjectContact');
323$help_url =
'EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte';
325llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project page-card_contact');
329if ($id > 0 || !empty($ref)) {
338 $userWrite =
$object->restrictedProjectArea($user,
'write');
345 $formconfirm = $formconfirmtoaddtasks;
348 $parameters = array(
'formConfirm' => $formconfirm);
349 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
350 if (empty($reshook)) {
351 $formconfirm .= $hookmanager->resPrint;
352 } elseif ($reshook > 0) {
353 $formconfirm = $hookmanager->resPrint;
361 if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
362 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
363 $tmpurl = preg_replace(
'/__SOCID__/', (
string)
$object->socid, $tmpurl);
364 $linkback =
'<a href="'.$tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
366 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
369 $morehtmlref =
'<div class="refidno">';
372 $morehtmlref .=
'<br>';
374 if (!empty(
$object->thirdparty->id) &&
$object->thirdparty->id > 0) {
375 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'project');
377 $morehtmlref .=
'</div>';
380 if (!$user->hasRight(
'projet',
'all',
'lire')) {
381 $objectsListId =
$object->getProjectsAuthorizedForUser($user, 0, 0);
382 $object->next_prev_filter =
"rowid:IN:".$db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0');
385 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
388 print
'<div class="fichecenter">';
389 print
'<div class="fichehalfleft">';
390 print
'<div class="underbanner clearboth"></div>';
392 print
'<table class="border tableforfield centpercent">';
396 print
'<tr><td class="tdtop">';
397 print $langs->trans(
"Usage");
401 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
402 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
403 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
407 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_task ?
' checked="checked"' :
'')).
'"> ';
408 $htmltext = $langs->trans(
"ProjectFollowTasks");
409 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
413 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"' :
'')).
'"> ';
414 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
415 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
419 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"' :
'')).
'"> ';
420 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
421 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
428 print
'<tr><td>'.$langs->trans(
"OpportunityStatus").
'</td><td>';
431 print $langs->trans(
"OppStatus".$code);
435 print
' <span title="'.$langs->trans(
"OpportunityProbability").
'"> / ';
436 if (strcmp(
$object->opp_percent,
'')) {
437 print
price(
$object->opp_percent, 0, $langs, 1, 0).
' %';
439 print
'</span></td></tr>';
442 print
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
443 if (strcmp(
$object->opp_amount,
'')) {
444 print
'<span class="amount">'.price(
$object->opp_amount, 0, $langs, 1, 0, -1,
$conf->currency).
'</span>';
445 if (strcmp(
$object->opp_percent,
'')) {
446 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>';
453 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
454 if (!is_null(
$object->budget_amount) && strcmp(
$object->budget_amount,
'')) {
455 print
'<span class="amount">'.price(
$object->budget_amount, 0, $langs, 1, 0, 0,
$conf->currency).
'</span>';
460 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
462 print($start ? $start :
'?');
464 print
' <span class="opacitymedium">-</span> ';
465 print($end ? $end :
'?');
472 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
474 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
475 print $langs->trans(
'SharedProject');
477 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
478 print $langs->trans(
'PrivateProject');
484 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
489 print
'<div class="fichehalfright">';
490 print
'<div class="underbanner clearboth"></div>';
492 print
'<table class="border tableforfield centpercent">';
496 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
497 print $form->showCategories(
$object->id, Categorie::TYPE_PROJECT, 1);
502 print
'<tr><td class="titlefield'.($object->description ?
' noborderbottom' :
'').
'" colspan="2">'.$langs->trans(
"Description").
'</td></tr>';
504 print
'<tr><td class="nottitleforfield" colspan="2">';
505 print
'<div class="longmessagecut">';
516 print
'<div class="clearboth"></div>';
523 $dirtpls = array_merge(
$conf->modules_parts[
'tpl'], array(
'/core/tpl'));
524 foreach ($dirtpls as $reldir) {
526 if (file_exists($file)) {
527 $res = @include $file;
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
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.
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_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.
isModEnabled($module)
Is Dolibarr module enabled.
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.