25 require
'../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
36 $langsLoad=array(
'projects',
'companies');
37 if (!empty($conf->eventorganization->enabled)) {
38 $langsLoad[]=
'eventorganization';
41 $langs->loadLangs($langsLoad);
45 $lineid =
GETPOST(
'lineid',
'int');
46 $socid =
GETPOST(
'socid',
'int');
47 $action =
GETPOST(
'action',
'aZ09');
49 $mine =
GETPOST(
'mode') ==
'mine' ? 1 : 0;
54 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
55 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object,
'fetchComments') && empty($object->comments)) {
56 $object->fetchComments();
64 $hookmanager->initHooks(array(
'projectcontactcard',
'globalcard'));
72 $formconfirmtoaddtasks =
'';
73 if ($action ==
'addcontact') {
76 $source=
GETPOST(
"source",
'aZ09');
78 $taskstatic =
new Task($db);
79 $task_array = $taskstatic->getTasksArray(0, 0, $object->id, 0, 0);
80 $nbTasks = count($task_array);
83 $type_to = (
GETPOST(
'typecontact') ?
'typecontact='.GETPOST(
'typecontact') :
'type='.GETPOST(
'type'));
85 $affect_to = (
GETPOST(
'userid') ?
'userid='.$personToAffect :
'contactid='.$personToAffect);
86 $url_redirect=
'?id='.$object->id.
'&'.$affect_to.
'&'.$type_to.
'&source='.$source;
88 if ($personToAffect > 0 && (empty($conf->global->PROJECT_HIDE_TASKS) || $nbTasks > 0)) {
89 $text = $langs->trans(
'AddPersonToTask');
90 $textbody = $text.
' (<a href="#" class="selectall">'.$langs->trans(
"SelectAll").
'</a>)';
91 $formquestion = array(
'text' => $textbody);
93 $task_to_affect = array();
94 foreach ($task_array as $task) {
95 $task_already_affected=
false;
96 $personsLinked = $task->liste_contact(-1, $source);
97 if (!is_array($personsLinked) && count($personsLinked) < 0) {
100 foreach ($personsLinked as $person) {
101 if ($person[
'id']==$personToAffect) {
102 $task_already_affected =
true;
106 if (!$task_already_affected) {
107 $task_to_affect[$task->id] = $task->id;
112 if (empty($task_to_affect)) {
113 $action =
'addcontact_confirm';
116 foreach ($task_array as $task) {
118 $val = $task->ref .
' '.dol_trunc($task->label);
119 $formquestion[] = array(
121 'name' =>
'person_'.$key.
',person_role_'.$key,
122 '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>',
123 'value' => $formcompany->selectTypeContact($taskstatic,
'',
'person_role_'.$key, $source,
'position', 0,
'minwidth100imp', 0, 1)
126 $formquestion[] = array(
'type'=>
'other',
'name'=>
'tasksavailable',
'label'=>
'',
'value' =>
'<input type="hidden" id="tasksavailable" name="tasksavailable" value="'.implode(
',', array_keys($task_to_affect)).
'">');
129 $formconfirmtoaddtasks =
$form->formconfirm($_SERVER[
'PHP_SELF'] . $url_redirect, $text,
'',
'addcontact_confirm', $formquestion,
'', 1, 300, 590);
130 $formconfirmtoaddtasks .=
'
132 $(document).ready(function() {
133 var saveprop = false;
134 $(".selectall").click(function(){
135 console.log("We click on select all with "+saveprop);
137 $(".taskcheckboxes").prop("checked", true);
140 $(".taskcheckboxes").prop("checked", false);
147 $action =
'addcontact_confirm';
152 if ($action ==
'addcontact_confirm' && $user->rights->projet->creer) {
156 if (! ($contactid > 0)) {
158 $langs->load(
"errors");
159 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Contact")), null,
'errors');
163 $result = $object->fetch($id);
165 if (!$error && $result > 0 && $id > 0) {
166 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
169 $langs->load(
"errors");
170 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"), null,
'errors');
171 } elseif ($result < 0) {
172 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
173 $langs->load(
"errors");
174 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"), null,
'errors');
180 $affecttotask=
GETPOST(
'tasksavailable',
'intcomma');
181 if (!empty($affecttotask)) {
182 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
183 $task_to_affect = explode(
',', $affecttotask);
184 if (!empty($task_to_affect)) {
185 foreach ($task_to_affect as $task_id) {
187 $tasksToAffect =
new Task($db);
188 $result=$tasksToAffect->fetch($task_id);
192 $result = $tasksToAffect->add_contact($contactid,
GETPOST(
'person_role_'.$task_id),
GETPOST(
"source",
'aZ09'));
194 if ($tasksToAffect->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
195 $langs->load(
"errors");
196 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"), null,
'errors');
209 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
215 if ($action ==
'swapstatut' && $user->rights->projet->creer) {
216 if ($object->fetch($id)) {
217 $result = $object->swapContactStatus(
GETPOST(
'ligne',
'int'));
224 if (($action ==
'deleteline' || $action ==
'deletecontact') && $user->rights->projet->creer) {
226 $result = $object->delete_contact(
GETPOST(
"lineid",
'int'));
229 header(
"Location: contact.php?id=".$object->id);
242 $title = $langs->trans(
'ProjectContact').
' - '.$object->ref.
' '.$object->name;
243 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
244 $title = $object->ref.
' '.$object->name.
' - '.$langs->trans(
'ProjectContact');
247 $help_url =
'EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte';
252 $contactstatic =
new Contact($db);
253 $userstatic =
new User($db);
262 if ($id > 0 || !empty($ref)) {
263 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object,
'fetchComments') && empty($object->comments)) {
264 $object->fetchComments();
268 $userWrite = $object->restrictedProjectArea($user,
'write');
273 print
dol_get_fiche_head($head,
'contact', $langs->trans(
"Project"), -1, ($object->public ?
'projectpub' :
'project'));
279 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
280 if (empty($reshook)) {
282 } elseif ($reshook > 0) {
291 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
293 $morehtmlref =
'<div class="refidno">';
295 $morehtmlref .= $object->title;
297 if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
298 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1,
'project');
300 $morehtmlref .=
'</div>';
303 if (empty($user->rights->projet->all->lire)) {
304 $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
305 $object->next_prev_filter =
" rowid IN (".$db->sanitize(count($objectsListId) ?join(
',', array_keys($objectsListId)) :
'0').
")";
308 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
311 print
'<div class="fichecenter">';
312 print
'<div class="fichehalfleft">';
313 print
'<div class="underbanner clearboth"></div>';
315 print
'<table class="border tableforfield centpercent">';
318 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) {
319 print
'<tr><td class="tdtop">';
320 print $langs->trans(
"Usage");
323 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
324 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
325 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
326 print
$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
329 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
330 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_task ?
' checked="checked"' :
'')).
'"> ';
331 $htmltext = $langs->trans(
"ProjectFollowTasks");
332 print
$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
335 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
336 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"' :
'')).
'"> ';
337 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
338 print
$form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
341 if (!empty($conf->eventorganization->enabled)) {
342 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"' :
'')).
'"> ';
343 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
344 print
$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
350 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
351 if ($object->public) {
352 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
353 print $langs->trans(
'SharedProject');
355 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
356 print $langs->trans(
'PrivateProject');
360 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && $object->opp_status) {
362 print
'<tr><td>'.$langs->trans(
"OpportunityStatus").
'</td><td>';
363 $code =
dol_getIdFromCode($db, $object->opp_status,
'c_lead_status',
'rowid',
'code');
365 print $langs->trans(
"OppStatus".$code);
370 print
'<tr><td>'.$langs->trans(
"OpportunityProbability").
'</td><td>';
371 if (strcmp($object->opp_percent,
'')) {
372 print
price($object->opp_percent,
'', $langs, 1, 0).
' %';
377 print
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
378 if (strcmp($object->opp_amount,
'')) {
379 print
'<span class="amount">'.price($object->opp_amount,
'', $langs, 0, 0, 0, $conf->currency).
'</span>';
380 if (strcmp($object->opp_percent,
'')) {
381 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>';
388 print
'<tr><td>'.$langs->trans(
"DateStart").
' - '.$langs->trans(
"DateEnd").
'</td><td>';
390 print ($start ? $start :
'?');
393 print ($end ? $end :
'?');
394 if ($object->hasDelay()) {
400 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
401 if (strcmp($object->budget_amount,
'')) {
402 print
'<span class="amount">'.price($object->budget_amount,
'', $langs, 0, 0, 0, $conf->currency).
'</span>';
408 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
413 print
'<div class="fichehalfright">';
414 print
'<div class="underbanner clearboth"></div>';
416 print
'<table class="border tableforfield centpercent">';
419 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
420 print nl2br($object->description);
425 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
426 print
$form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
435 print
'<div class="clearboth"></div>';
442 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array(
'/core/tpl'));
443 foreach ($dirtpls as $reldir) {
project_prepare_head(Project $project, $moreparam= '')
Prepare array with list of tabs.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Class to manage Dolibarr users.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
setEventMessage($mesgs, $style= 'mesgs')
Set event message in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0, $filters= '')
Return an id or code from a code or id.
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.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
Class to manage projects.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
restrictedArea($user, $features, $objectid=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.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
isModEnabled($module)
Is Dolibarr module enabled.
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.
$formconfirm
if ($action == 'delbookkeepingyear') {