26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
32if (isModEnabled(
'categorie')) {
33 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
37$langsLoad=array(
'projects',
'companies');
38if (isModEnabled(
'eventorganization')) {
39 $langsLoad[]=
'eventorganization';
42$langs->loadLangs($langsLoad);
46$lineid =
GETPOST(
'lineid',
'int');
47$socid =
GETPOST(
'socid',
'int');
48$action =
GETPOST(
'action',
'aZ09');
50$mine =
GETPOST(
'mode') ==
'mine' ? 1 : 0;
55include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
56if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object,
'fetchComments') && empty($object->comments)) {
57 $object->fetchComments();
65$hookmanager->initHooks(array(
'projectcontactcard',
'globalcard'));
72$parameters = array(
'id'=>$id);
73$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
80 $formconfirmtoaddtasks =
'';
81 if ($action ==
'addcontact') {
82 $form =
new Form($db);
84 $source=
GETPOST(
"source",
'aZ09');
86 $taskstatic =
new Task($db);
87 $task_array = $taskstatic->getTasksArray(0, 0, $object->id, 0, 0);
88 $nbTasks = count($task_array);
91 $type_to = (
GETPOST(
'typecontact') ?
'typecontact='.GETPOST(
'typecontact') :
'type='.GETPOST(
'type'));
93 $affect_to = (
GETPOST(
'userid') ?
'userid='.$personToAffect :
'contactid='.$personToAffect);
94 $url_redirect=
'?id='.$object->id.
'&'.$affect_to.
'&'.$type_to.
'&source='.$source;
96 if ($personToAffect > 0 && (!
getDolGlobalString(
'PROJECT_HIDE_TASKS') || $nbTasks > 0)) {
97 $text = $langs->trans(
'AddPersonToTask');
98 $textbody = $text.
' (<a href="#" class="selectall">'.$langs->trans(
"SelectAll").
'</a>)';
99 $formquestion = array(
'text' => $textbody);
101 $task_to_affect = array();
102 foreach ($task_array as $task) {
103 $task_already_affected=
false;
104 $personsLinked = $task->liste_contact(-1, $source);
105 if (!is_array($personsLinked) && count($personsLinked) < 0) {
108 foreach ($personsLinked as $person) {
109 if ($person[
'id']==$personToAffect) {
110 $task_already_affected =
true;
114 if (!$task_already_affected) {
115 $task_to_affect[$task->id] = $task->id;
120 if (empty($task_to_affect)) {
121 $action =
'addcontact_confirm';
124 foreach ($task_array as $task) {
126 $val = $task->ref .
' '.dol_trunc($task->label);
127 $formquestion[] = array(
129 'name' =>
'person_'.$key.
',person_role_'.$key,
130 '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>',
131 'value' => $formcompany->selectTypeContact($taskstatic,
'',
'person_role_'.$key, $source,
'position', 0,
'minwidth100imp', 0, 1)
134 $formquestion[] = array(
'type'=>
'other',
'name'=>
'tasksavailable',
'label'=>
'',
'value' =>
'<input type="hidden" id="tasksavailable" name="tasksavailable" value="'.implode(
',', array_keys($task_to_affect)).
'">');
137 $formconfirmtoaddtasks = $form->formconfirm($_SERVER[
'PHP_SELF'] . $url_redirect, $text,
'',
'addcontact_confirm', $formquestion,
'', 1, 300, 590);
138 $formconfirmtoaddtasks .=
'
140 $(document).ready(function() {
141 var saveprop = false;
142 $(".selectall").click(function(){
143 console.log("We click on select all with "+saveprop);
145 $(".taskcheckboxes").prop("checked", true);
148 $(".taskcheckboxes").prop("checked", false);
155 $action =
'addcontact_confirm';
160 if ($action ==
'addcontact_confirm' && $user->hasRight(
'projet',
'creer')) {
161 if (
GETPOST(
'confirm',
'alpha') ==
'no') {
162 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
169 if (! ($contactid > 0)) {
171 $langs->load(
"errors");
172 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Contact")),
null,
'errors');
176 $result = $object->fetch($id);
178 if (!$error && $result > 0 && $id > 0) {
179 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
182 $langs->load(
"errors");
183 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
184 } elseif ($result < 0) {
185 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
186 $langs->load(
"errors");
187 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
193 $affecttotask=
GETPOST(
'tasksavailable',
'intcomma');
194 if (!empty($affecttotask)) {
195 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
196 $task_to_affect = explode(
',', $affecttotask);
197 if (!empty($task_to_affect)) {
198 foreach ($task_to_affect as $task_id) {
199 if (GETPOSTISSET(
'person_'.$task_id) &&
GETPOST(
'person_'.$task_id,
'san_alpha')) {
200 $tasksToAffect =
new Task($db);
201 $result=$tasksToAffect->fetch($task_id);
205 $result = $tasksToAffect->add_contact($contactid,
GETPOST(
'person_role_'.$task_id),
GETPOST(
"source",
'aZ09'));
207 if ($tasksToAffect->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
208 $langs->load(
"errors");
209 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
222 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
228 if ($action ==
'swapstatut' && $user->hasRight(
'projet',
'creer')) {
229 if ($object->fetch($id)) {
230 $result = $object->swapContactStatus(
GETPOST(
'ligne',
'int'));
237 if (($action ==
'deleteline' || $action ==
'deletecontact') && $user->hasRight(
'projet',
'creer')) {
239 $result = $object->delete_contact(
GETPOST(
"lineid",
'int'));
242 header(
"Location: contact.php?id=".$object->id);
255$form =
new Form($db);
256$contactstatic =
new Contact($db);
257$userstatic =
new User($db);
259$title = $langs->trans(
'ProjectContact').
' - '.$object->ref.
' '.$object->name;
260if (
getDolGlobalString(
'MAIN_HTML_TITLE') && preg_match(
'/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
261 $title = $object->ref.
' '.$object->name.
' - '.$langs->trans(
'ProjectContact');
264$help_url =
'EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte';
270if ($id > 0 || !empty($ref)) {
274 if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object,
'fetchComments') && empty($object->comments)) {
275 $object->fetchComments();
279 $userWrite = $object->restrictedProjectArea($user,
'write');
284 print
dol_get_fiche_head($head,
'contact', $langs->trans(
"Project"), -1, ($object->public ?
'projectpub' :
'project'));
286 $formconfirm = $formconfirmtoaddtasks;
289 $parameters = array(
'formConfirm' => $formconfirm);
290 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
291 if (empty($reshook)) {
292 $formconfirm .= $hookmanager->resPrint;
293 } elseif ($reshook > 0) {
294 $formconfirm = $hookmanager->resPrint;
302 if (!empty($_SESSION[
'pageforbacktolist']) && !empty($_SESSION[
'pageforbacktolist'][
'project'])) {
303 $tmpurl = $_SESSION[
'pageforbacktolist'][
'project'];
304 $tmpurl = preg_replace(
'/__SOCID__/', $object->socid, $tmpurl);
305 $linkback =
'<a href="'.$tmpurl.(preg_match(
'/\?/', $tmpurl) ?
'&' :
'?').
'restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
307 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
310 $morehtmlref =
'<div class="refidno">';
313 $morehtmlref .=
'<br>';
315 if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
316 $morehtmlref .= $object->thirdparty->getNomUrl(1,
'project');
318 $morehtmlref .=
'</div>';
321 if (!$user->hasRight(
'projet',
'all',
'lire')) {
322 $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
323 $object->next_prev_filter =
"rowid IN (".$db->sanitize(count($objectsListId) ? join(
',', array_keys($objectsListId)) :
'0').
")";
326 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
329 print
'<div class="fichecenter">';
330 print
'<div class="fichehalfleft">';
331 print
'<div class="underbanner clearboth"></div>';
333 print
'<table class="border tableforfield centpercent">';
337 print
'<tr><td class="tdtop">';
338 print $langs->trans(
"Usage");
342 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
343 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
344 print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
348 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_task ?
' checked="checked"' :
'')).
'"> ';
349 $htmltext = $langs->trans(
"ProjectFollowTasks");
350 print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
354 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"' :
'')).
'"> ';
355 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
356 print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
359 if (isModEnabled(
'eventorganization')) {
360 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"' :
'')).
'"> ';
361 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
362 print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
368 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
369 if ($object->public) {
370 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
371 print $langs->trans(
'SharedProject');
373 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
374 print $langs->trans(
'PrivateProject');
378 if (
getDolGlobalString(
'PROJECT_USE_OPPORTUNITIES') && !empty($object->usage_opportunity)) {
380 print
'<tr><td>'.$langs->trans(
"OpportunityStatus").
'</td><td>';
381 $code =
dol_getIdFromCode($db, $object->opp_status,
'c_lead_status',
'rowid',
'code');
383 print $langs->trans(
"OppStatus".$code);
387 print
' <span title="'.$langs->trans(
"OpportunityProbability").
'"> / ';
388 if (strcmp($object->opp_percent,
'')) {
389 print
price($object->opp_percent, 0, $langs, 1, 0).
' %';
391 print
'</span></td></tr>';
394 print
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
395 if (strcmp($object->opp_amount,
'')) {
396 print
'<span class="amount">'.price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency).
'</span>';
397 if (strcmp($object->opp_percent,
'')) {
398 print
' <span title="'.dol_escape_htmltag($langs->trans(
'OpportunityWeightedAmount')).
'"><span class="opacitymedium">'.$langs->trans(
"Weighted").
'</span>: <span class="amount">'.
price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).
'</span></span>';
405 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
406 if (!is_null($object->budget_amount) && strcmp($object->budget_amount,
'')) {
407 print
'<span class="amount">'.price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).
'</span>';
412 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
414 print($start ? $start :
'?');
416 print
' <span class="opacitymedium">-</span> ';
417 print($end ? $end :
'?');
418 if ($object->hasDelay()) {
425 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
430 print
'<div class="fichehalfright">';
431 print
'<div class="underbanner clearboth"></div>';
433 print
'<table class="border tableforfield centpercent">';
436 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
441 if (isModEnabled(
'categorie')) {
442 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
443 print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
452 print
'<div class="clearboth"></div>';
459 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array(
'/core/tpl'));
460 foreach ($dirtpls as $reldir) {
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 Dolibarr users.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
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_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.