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)) {
67$hookmanager->initHooks(array(
'projectcontactcard',
'globalcard'));
74$parameters = array(
'id' => $id);
75$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
82 $formconfirmtoaddtasks =
'';
83 if ($action ==
'addcontact') {
84 $form =
new Form($db);
86 $source =
GETPOST(
"source",
'aZ09');
88 $taskstatic =
new Task($db);
89 $task_array = $taskstatic->getTasksArray(0, 0,
$object->id, 0, 0);
90 $nbTasks = count($task_array);
93 $type_to = (
GETPOST(
'typecontact') ?
'typecontact='.GETPOST(
'typecontact') :
'type='.GETPOST(
'type'));
95 $affect_to = (
GETPOST(
'userid') ?
'userid='.$personToAffect :
'contactid='.$personToAffect);
96 $url_redirect =
'?id='.$object->id.
'&'.$affect_to.
'&'.$type_to.
'&source='.$source;
98 if ($personToAffect > 0 && (!
getDolGlobalString(
'PROJECT_HIDE_TASKS') || $nbTasks > 0)) {
99 $text = $langs->trans(
'AddPersonToTask');
100 $textbody = $text.
' (<a href="#" class="selectall">'.$langs->trans(
"SelectAll").
'</a>)';
101 $formquestion = array(
'text' => $textbody);
103 $task_to_affect = array();
104 foreach ($task_array as $task) {
105 $task_already_affected =
false;
106 $personsLinked = $task->liste_contact(-1, $source);
107 if (!is_array($personsLinked) && count($personsLinked) < 0) {
110 foreach ($personsLinked as $person) {
111 if ($person[
'id'] == $personToAffect) {
112 $task_already_affected =
true;
116 if (!$task_already_affected) {
117 $task_to_affect[$task->id] = $task->id;
122 if (empty($task_to_affect)) {
123 $action =
'addcontact_confirm';
126 foreach ($task_array as $task) {
128 $val = $task->ref .
' '.dol_trunc($task->label);
129 $formquestion[] = array(
131 'name' =>
'person_'.$key.
',person_role_'.$key,
132 '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>',
133 'value' => $formcompany->selectTypeContact($taskstatic,
'',
'person_role_'.$key, $source,
'position', 0,
'minwidth100imp', 0, 1)
136 $formquestion[] = array(
'type' =>
'other',
'name' =>
'tasksavailable',
'label' =>
'',
'value' =>
'<input type="hidden" id="tasksavailable" name="tasksavailable" value="'.implode(
',', array_keys($task_to_affect)).
'">');
139 $formconfirmtoaddtasks = $form->formconfirm($_SERVER[
'PHP_SELF'] . $url_redirect, $text,
'',
'addcontact_confirm', $formquestion,
'', 1, 300, 590);
140 $formconfirmtoaddtasks .=
'
142 $(document).ready(function() {
143 var saveprop = false;
144 $(".selectall").click(function(){
145 console.log("We click on select all with "+saveprop);
147 $(".taskcheckboxes").prop("checked", true);
150 $(".taskcheckboxes").prop("checked", false);
157 $action =
'addcontact_confirm';
162 if ($action ==
'addcontact_confirm' && $user->hasRight(
'projet',
'creer')) {
163 if (
GETPOST(
'confirm',
'alpha') ==
'no') {
164 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
171 $contactarray = array();
173 $errorgrouparray = array();
176 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
178 $result = $usergroup->fetch($groupid);
180 $excludefilter =
'statut = 1';
181 $tmpcontactarray = $usergroup->listUsersForGroup($excludefilter, 0);
182 if ($contactarray <= 0) {
185 foreach ($tmpcontactarray as $tmpuser) {
186 $contactarray[] = $tmpuser->id;
192 } elseif (! ($contactid > 0)) {
194 $langs->load(
"errors");
195 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Contact")),
null,
'errors');
197 $contactarray[] = $contactid;
202 if (!$error && $result > 0 && $id > 0) {
203 foreach ($contactarray as $key => $contactid) {
204 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
209 $errorgrouparray[] = $contactid;
211 $langs->load(
"errors");
212 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
214 } elseif ($result < 0) {
215 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
218 $errorgrouparray[] = $contactid;
220 $langs->load(
"errors");
221 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
228 $affecttotask =
GETPOST(
'tasksavailable',
'intcomma');
229 if (!empty($affecttotask)) {
230 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
231 $task_to_affect = explode(
',', $affecttotask);
232 if (!empty($task_to_affect)) {
233 foreach ($task_to_affect as $task_id) {
234 if (GETPOSTISSET(
'person_'.$task_id) &&
GETPOST(
'person_'.$task_id,
'san_alpha')) {
235 $tasksToAffect =
new Task($db);
236 $result = $tasksToAffect->fetch($task_id);
240 $result = $tasksToAffect->add_contact($contactid,
GETPOST(
'person_role_'.$task_id),
GETPOST(
"source",
'aZ09'));
242 if ($tasksToAffect->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
243 $langs->load(
"errors");
244 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
256 if ($errorgroup > 0) {
257 $langs->load(
"errors");
258 if ($errorgroup == count($contactarray)) {
259 setEventMessages($langs->trans(
"ErrorThisGroupIsAlreadyDefinedAsThisType"),
null,
'errors');
261 $tmpuser =
new User($db);
262 foreach ($errorgrouparray as $key => $value) {
263 $tmpuser->fetch($value);
270 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
276 if ($action ==
'swapstatut' && $user->hasRight(
'projet',
'creer')) {
285 if (($action ==
'deleteline' || $action ==
'deletecontact') && $user->hasRight(
'projet',
'creer')) {
290 header(
"Location: contact.php?id=".
$object->id);
303$form =
new Form($db);
304$contactstatic =
new Contact($db);
305$userstatic =
new User($db);
307$title = $langs->trans(
'ProjectContact').
' - '.
$object->ref.
' '.
$object->name;
309 $title =
$object->ref.
' '.
$object->name.
' - '.$langs->trans(
'ProjectContact');
312$help_url =
'EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte';
318if ($id > 0 || !empty($ref)) {
322 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object,
'fetchComments') && empty(
$object->comments)) {
327 $userWrite =
$object->restrictedProjectArea($user,
'write');
334 $formconfirm = $formconfirmtoaddtasks;
337 $parameters = array(
'formConfirm' => $formconfirm);
338 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
339 if (empty($reshook)) {
340 $formconfirm .= $hookmanager->resPrint;
341 } elseif ($reshook > 0) {
342 $formconfirm = $hookmanager->resPrint;
350 if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
351 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
352 $tmpurl = preg_replace(
'/__SOCID__/', (
string)
$object->socid, $tmpurl);
353 $linkback =
'<a href="'.$tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
355 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
358 $morehtmlref =
'<div class="refidno">';
361 $morehtmlref .=
'<br>';
363 if (!empty(
$object->thirdparty->id) &&
$object->thirdparty->id > 0) {
364 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'project');
366 $morehtmlref .=
'</div>';
369 if (!$user->hasRight(
'projet',
'all',
'lire')) {
370 $objectsListId =
$object->getProjectsAuthorizedForUser($user, 0, 0);
371 $object->next_prev_filter =
"rowid IN (".$db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) :
'0').
")";
374 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
377 print
'<div class="fichecenter">';
378 print
'<div class="fichehalfleft">';
379 print
'<div class="underbanner clearboth"></div>';
381 print
'<table class="border tableforfield centpercent">';
385 print
'<tr><td class="tdtop">';
386 print $langs->trans(
"Usage");
390 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
391 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
392 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
396 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : (
$object->usage_task ?
' checked="checked"' :
'')).
'"> ';
397 $htmltext = $langs->trans(
"ProjectFollowTasks");
398 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
402 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"' :
'')).
'"> ';
403 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
404 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
407 if (isModEnabled(
'eventorganization')) {
408 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"' :
'')).
'"> ';
409 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
410 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
416 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
418 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
419 print $langs->trans(
'SharedProject');
421 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
422 print $langs->trans(
'PrivateProject');
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 :
'?');
473 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
478 print
'<div class="fichehalfright">';
479 print
'<div class="underbanner clearboth"></div>';
481 print
'<table class="border tableforfield centpercent">';
484 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
489 if (isModEnabled(
'category')) {
490 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
491 print $form->showCategories(
$object->id, Categorie::TYPE_PROJECT, 1);
500 print
'<div class="clearboth"></div>';
507 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array(
'/core/tpl'));
508 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()
Empty header.
Class to manage projects.
Class to manage user groups.
Class to manage Dolibarr users.
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)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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.