26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
37 $langsLoad=array(
'projects',
'companies');
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;
55 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
56 if (!empty($conf->global->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);
78 if (empty($reshook)) {
80 $formconfirmtoaddtasks =
'';
81 if ($action ==
'addcontact') {
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 && (empty($conf->global->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->rights->projet->creer) {
164 if (! ($contactid > 0)) {
166 $langs->load(
"errors");
167 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Contact")),
null,
'errors');
171 $result = $object->fetch($id);
173 if (!$error && $result > 0 && $id > 0) {
174 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
177 $langs->load(
"errors");
178 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
179 } elseif ($result < 0) {
180 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
181 $langs->load(
"errors");
182 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
188 $affecttotask=
GETPOST(
'tasksavailable',
'intcomma');
189 if (!empty($affecttotask)) {
190 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
191 $task_to_affect = explode(
',', $affecttotask);
192 if (!empty($task_to_affect)) {
193 foreach ($task_to_affect as $task_id) {
195 $tasksToAffect =
new Task($db);
196 $result=$tasksToAffect->fetch($task_id);
200 $result = $tasksToAffect->add_contact($contactid,
GETPOST(
'person_role_'.$task_id),
GETPOST(
"source",
'aZ09'));
202 if ($tasksToAffect->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
203 $langs->load(
"errors");
204 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
217 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
223 if ($action ==
'swapstatut' && $user->rights->projet->creer) {
224 if ($object->fetch($id)) {
225 $result = $object->swapContactStatus(
GETPOST(
'ligne',
'int'));
232 if (($action ==
'deleteline' || $action ==
'deletecontact') && $user->rights->projet->creer) {
234 $result = $object->delete_contact(
GETPOST(
"lineid",
'int'));
237 header(
"Location: contact.php?id=".$object->id);
251 $contactstatic =
new Contact($db);
252 $userstatic =
new User($db);
254 $title = $langs->trans(
'ProjectContact').
' - '.$object->ref.
' '.$object->name;
255 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
256 $title = $object->ref.
' '.$object->name.
' - '.$langs->trans(
'ProjectContact');
259 $help_url =
'EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte';
265 if ($id > 0 || !empty($ref)) {
269 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object,
'fetchComments') && empty($object->comments)) {
270 $object->fetchComments();
274 $userWrite = $object->restrictedProjectArea($user,
'write');
279 print
dol_get_fiche_head($head,
'contact', $langs->trans(
"Project"), -1, ($object->public ?
'projectpub' :
'project'));
285 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
286 if (empty($reshook)) {
288 } elseif ($reshook > 0) {
297 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
299 $morehtmlref =
'<div class="refidno">';
302 $morehtmlref .=
'<br>';
304 if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
305 $morehtmlref .= $object->thirdparty->getNomUrl(1,
'project');
307 $morehtmlref .=
'</div>';
310 if (empty($user->rights->projet->all->lire)) {
311 $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
312 $object->next_prev_filter =
" rowid IN (".$db->sanitize(count($objectsListId) ?join(
',', array_keys($objectsListId)) :
'0').
")";
315 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
318 print
'<div class="fichecenter">';
319 print
'<div class="fichehalfleft">';
320 print
'<div class="underbanner clearboth"></div>';
322 print
'<table class="border tableforfield centpercent">';
325 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) ||
isModEnabled(
'eventorganization')) {
326 print
'<tr><td class="tdtop">';
327 print $langs->trans(
"Usage");
330 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
331 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
332 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
333 print
$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
336 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
337 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_task ?
' checked="checked"' :
'')).
'"> ';
338 $htmltext = $langs->trans(
"ProjectFollowTasks");
339 print
$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
342 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
343 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"' :
'')).
'"> ';
344 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
345 print
$form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
349 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"' :
'')).
'"> ';
350 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
351 print
$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
357 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
358 if ($object->public) {
359 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
360 print $langs->trans(
'SharedProject');
362 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
363 print $langs->trans(
'PrivateProject');
367 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) {
369 print
'<tr><td>'.$langs->trans(
"OpportunityStatus").
'</td><td>';
370 $code =
dol_getIdFromCode($db, $object->opp_status,
'c_lead_status',
'rowid',
'code');
372 print $langs->trans(
"OppStatus".$code);
376 print
' <span title="'.$langs->trans(
"OpportunityProbability").
'"> / ';
377 if (strcmp($object->opp_percent,
'')) {
378 print
price($object->opp_percent, 0, $langs, 1, 0).
' %';
380 print
'</span></td></tr>';
383 print
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
384 if (strcmp($object->opp_amount,
'')) {
385 print
'<span class="amount">'.price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency).
'</span>';
386 if (strcmp($object->opp_percent,
'')) {
387 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>';
394 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
395 if (!is_null($object->budget_amount) && strcmp($object->budget_amount,
'')) {
396 print
'<span class="amount">'.price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).
'</span>';
401 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
403 print ($start ? $start :
'?');
405 print
' <span class="opacitymedium">-</span> ';
406 print ($end ? $end :
'?');
407 if ($object->hasDelay()) {
414 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
419 print
'<div class="fichehalfright">';
420 print
'<div class="underbanner clearboth"></div>';
422 print
'<table class="border tableforfield centpercent">';
425 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
431 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
432 print
$form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
441 print
'<div class="clearboth"></div>';
448 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array(
'/core/tpl'));
449 foreach ($dirtpls as $reldir) {
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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...
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...
$formconfirm
if ($action == 'delbookkeepingyear') {
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.