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';
48$langsLoad = array(
'projects',
'companies');
50 $langsLoad[] =
'eventorganization';
53$langs->loadLangs($langsLoad);
59$action =
GETPOST(
'action',
'aZ09');
61$mine =
GETPOST(
'mode') ==
'mine' ? 1 : 0;
65include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
70$extrafields->fetch_name_optionals_label(
$object->table_element);
76$hookmanager->initHooks(array(
'projectcontactcard',
'globalcard'));
81$permissiontoadd = $user->hasRight(
'projet',
'creer');
82$permissiontoeditextra = $permissiontoadd;
83if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
84 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
92$parameters = array(
'id' => $id);
93$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
98$formconfirmtoaddtasks =
'';
100 if ($action ==
'update_extras' && $permissiontoeditextra) {
102 $attribute_name =
GETPOST(
'attribute',
'aZ09');
103 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
108 $result =
$object->updateExtraField($attribute_name,
'PROJECT_MODIFY');
115 $action =
'edit_extras';
120 if ($action ==
'addcontact' && $permissiontoadd) {
123 $source =
GETPOST(
"source",
'aZ09');
126 $task_array = $taskstatic->getTasksArray(
null,
null,
$object->id, 0, 0);
127 $nbTasks = count($task_array);
130 $type_to = (
GETPOST(
'typecontact') ?
'typecontact='.GETPOST(
'typecontact') :
'type='.GETPOST(
'type'));
132 $affect_to = (
GETPOST(
'userid') ?
'userid='.$personToAffect :
'contactid='.$personToAffect);
133 $url_redirect =
'?id='.$object->id.
'&'.$affect_to.
'&'.$type_to.
'&source='.$source;
135 if ($personToAffect > 0 && (!
getDolGlobalString(
'PROJECT_HIDE_TASKS') || $nbTasks > 0)) {
136 $text = $langs->trans(
'AddPersonToTask');
137 $textbody = $text.
' (<a href="#" class="selectall">'.$langs->trans(
"SelectAll").
'</a>)';
138 $formquestion = array(
'text' => $textbody);
140 $task_to_affect = array();
141 foreach ($task_array as $task) {
142 $task_already_affected =
false;
143 $personsLinked = $task->liste_contact(-1, $source);
144 if (!is_array($personsLinked)) {
148 foreach ($personsLinked as $person) {
149 if ($person[
'id'] == $personToAffect) {
150 $task_already_affected =
true;
154 if (!$task_already_affected) {
155 $task_to_affect[$task->id] = $task->id;
160 if (empty($task_to_affect)) {
161 $action =
'addcontact_confirm';
164 foreach ($task_array as $task) {
166 $val = $task->ref .
' '.dol_trunc($task->label);
167 $formquestion[] = array(
169 'name' =>
'person_'.$key.
',person_role_'.$key,
170 '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>',
171 'value' => $formcompany->selectTypeContact($taskstatic,
'',
'person_role_'.$key, $source,
'position', 0,
'minwidth100imp', 0, 1)
174 $formquestion[] = array(
'type' =>
'other',
'name' =>
'tasksavailable',
'label' =>
'',
'value' =>
'<input type="hidden" id="tasksavailable" name="tasksavailable" value="'.implode(
',', array_keys($task_to_affect)).
'">');
177 $formconfirmtoaddtasks = $form->formconfirm($_SERVER[
'PHP_SELF'] . $url_redirect, $text,
'',
'addcontact_confirm', $formquestion,
'', 1, 300, 590);
178 $formconfirmtoaddtasks .=
'
180 $(document).ready(function() {
181 var saveprop = false;
182 $(".selectall").click(function(){
183 console.log("We click on select all with "+saveprop);
185 $(".taskcheckboxes").prop("checked", true);
188 $(".taskcheckboxes").prop("checked", false);
195 $action =
'addcontact_confirm';
200 if ($action ==
'addcontact_confirm' && $permissiontoadd) {
201 if (
GETPOST(
'confirm',
'alpha') ==
'no') {
202 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
209 $contactarray = array();
211 $errorgrouparray = array();
214 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
216 $result = $usergroup->fetch($groupid);
218 $excludefilter =
'statut = 1';
219 $tmpcontactarray = $usergroup->listUsersForGroup($excludefilter, 0);
220 if (!is_array($tmpcontactarray)) {
223 foreach ($tmpcontactarray as $tmpuser) {
224 $contactarray[] = $tmpuser->id;
230 } elseif (! ($contactid > 0)) {
232 $langs->load(
"errors");
233 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Contact")),
null,
'errors');
235 $contactarray[] = $contactid;
240 if (!$error && $result > 0 && $id > 0) {
241 foreach ($contactarray as $key => $contactid) {
242 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
247 $errorgrouparray[] = $contactid;
249 $langs->load(
"errors");
250 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
252 } elseif ($result < 0) {
253 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
256 $errorgrouparray[] = $contactid;
258 $langs->load(
"errors");
259 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
266 $affecttotask =
GETPOST(
'tasksavailable',
'intcomma');
267 if (!empty($affecttotask)) {
268 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
269 $task_to_affect = explode(
',', $affecttotask);
270 if (!empty($task_to_affect)) {
271 foreach ($task_to_affect as $task_id) {
272 if (GETPOSTISSET(
'person_'.$task_id) &&
GETPOST(
'person_'.$task_id,
'aZ09comma')) {
273 $tasksToAffect =
new Task(
$db);
274 $result = $tasksToAffect->fetch((
int) $task_id);
278 $result = $tasksToAffect->add_contact($contactid,
GETPOST(
'person_role_'.$task_id),
GETPOST(
"source",
'aZ09'));
280 if ($tasksToAffect->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
281 $langs->load(
"errors");
282 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
294 if ($errorgroup > 0) {
295 $langs->load(
"errors");
296 if ($errorgroup == count($contactarray)) {
297 setEventMessages($langs->trans(
"ErrorThisGroupIsAlreadyDefinedAsThisType"),
null,
'errors');
300 foreach ($errorgrouparray as $key => $value) {
301 $tmpuser->fetch($value);
308 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
314 if ($action ==
'swapstatut' && $permissiontoadd) {
323 if (($action ==
'deleteline' || $action ==
'deletecontact') && $permissiontoadd) {
328 header(
"Location: contact.php?id=".
$object->id);
345$title = $langs->trans(
'ProjectContact').
' - '.
$object->ref.
' '.
$object->name;
347 $title =
$object->ref.
' '.
$object->name.
' - '.$langs->trans(
'ProjectContact');
350$help_url =
'EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte';
352llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project page-card_contact');
356if ($id > 0 || !empty($ref)) {
365 $userWrite =
$object->restrictedProjectArea($user,
'write');
372 $formconfirm = $formconfirmtoaddtasks;
375 $parameters = array(
'formConfirm' => $formconfirm);
376 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
377 if (empty($reshook)) {
378 $formconfirm .= $hookmanager->resPrint;
379 } elseif ($reshook > 0) {
380 $formconfirm = $hookmanager->resPrint;
388 if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
389 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
390 $tmpurl = preg_replace(
'/__SOCID__/', (
string)
$object->socid, $tmpurl);
391 $linkback =
'<a href="'.$tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
393 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
396 $morehtmlref =
'<div class="refidno">';
399 $morehtmlref .=
'<br>';
401 if (!empty(
$object->thirdparty->id) &&
$object->thirdparty->id > 0) {
402 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'project');
404 $morehtmlref .=
'</div>';
407 if (!$user->hasRight(
'projet',
'all',
'lire')) {
408 $objectsListId =
$object->getProjectsAuthorizedForUser($user, 0, 0);
409 $object->next_prev_filter =
"rowid:IN:".$db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0');
412 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
415 print
'<div class="fichecenter">';
416 print
'<div class="fichehalfleft">';
417 print
'<div class="underbanner clearboth"></div>';
419 print
'<table class="border tableforfield centpercent">';
423 print
'<tr><td class="tdtop">';
424 print $langs->trans(
"Usage");
428 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
429 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
430 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
434 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_task ?
' checked="checked"' :
'')).
'"> ';
435 $htmltext = $langs->trans(
"ProjectFollowTasks");
436 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
440 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"' :
'')).
'"> ';
441 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
442 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
446 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"' :
'')).
'"> ';
447 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
448 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
455 print
'<tr><td>'.$langs->trans(
"OpportunityStatus").
'</td><td>';
458 print $langs->trans(
"OppStatus".$code);
462 print
' <span title="'.$langs->trans(
"OpportunityProbability").
'"> / ';
463 if (strcmp(
$object->opp_percent,
'')) {
464 print
price(
$object->opp_percent, 0, $langs, 1, 0).
' %';
466 print
'</span></td></tr>';
469 print
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
470 if (strcmp(
$object->opp_amount,
'')) {
471 print
'<span class="amount">'.price(
$object->opp_amount, 0, $langs, 1, 0, -1,
$conf->currency).
'</span>';
472 if (strcmp(
$object->opp_percent,
'')) {
473 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>';
480 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
481 if (!is_null(
$object->budget_amount) && strcmp(
$object->budget_amount,
'')) {
482 print
'<span class="amount">'.price(
$object->budget_amount, 0, $langs, 1, 0, 0,
$conf->currency).
'</span>';
487 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
489 print($start ? $start :
'?');
491 print
' <span class="opacitymedium">-</span> ';
492 print($end ? $end :
'?');
499 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
501 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
502 print $langs->trans(
'SharedProject');
504 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
505 print $langs->trans(
'PrivateProject');
511 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
516 print
'<div class="fichehalfright">';
517 print
'<div class="underbanner clearboth"></div>';
519 print
'<table class="border tableforfield centpercent">';
523 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
524 print $form->showCategories(
$object->id, Categorie::TYPE_PROJECT, 1);
529 print
'<tr><td class="titlefield'.($object->description ?
' noborderbottom' :
'').
'" colspan="2">'.$langs->trans(
"Description").
'</td></tr>';
531 print
'<tr><td class="nottitleforfield" colspan="2">';
532 print
'<div class="longmessagecut">';
543 print
'<div class="clearboth"></div>';
550 $dirtpls = array_merge(
$conf->modules_parts[
'tpl'], array(
'/core/tpl'));
551 foreach ($dirtpls as $reldir) {
553 if (file_exists($file)) {
554 $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.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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.