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'));
73 $formconfirmtoaddtasks =
'';
74 if ($action ==
'addcontact') {
77 $source=
GETPOST(
"source",
'aZ09');
79 $taskstatic =
new Task($db);
80 $task_array = $taskstatic->getTasksArray(0, 0, $object->id, 0, 0);
81 $nbTasks = count($task_array);
84 $type_to = (
GETPOST(
'typecontact') ?
'typecontact='.GETPOST(
'typecontact') :
'type='.GETPOST(
'type'));
86 $affect_to = (
GETPOST(
'userid') ?
'userid='.$personToAffect :
'contactid='.$personToAffect);
87 $url_redirect=
'?id='.$object->id.
'&'.$affect_to.
'&'.$type_to.
'&source='.$source;
89 if ($personToAffect > 0 && (empty($conf->global->PROJECT_HIDE_TASKS) || $nbTasks > 0)) {
90 $text = $langs->trans(
'AddPersonToTask');
91 $textbody = $text.
' (<a href="#" class="selectall">'.$langs->trans(
"SelectAll").
'</a>)';
92 $formquestion = array(
'text' => $textbody);
94 $task_to_affect = array();
95 foreach ($task_array as $task) {
96 $task_already_affected=
false;
97 $personsLinked = $task->liste_contact(-1, $source);
98 if (!is_array($personsLinked) && count($personsLinked) < 0) {
101 foreach ($personsLinked as $person) {
102 if ($person[
'id']==$personToAffect) {
103 $task_already_affected =
true;
107 if (!$task_already_affected) {
108 $task_to_affect[$task->id] = $task->id;
113 if (empty($task_to_affect)) {
114 $action =
'addcontact_confirm';
117 foreach ($task_array as $task) {
119 $val = $task->ref .
' '.dol_trunc($task->label);
120 $formquestion[] = array(
122 'name' =>
'person_'.$key.
',person_role_'.$key,
123 '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>',
124 'value' => $formcompany->selectTypeContact($taskstatic,
'',
'person_role_'.$key, $source,
'position', 0,
'minwidth100imp', 0, 1)
127 $formquestion[] = array(
'type'=>
'other',
'name'=>
'tasksavailable',
'label'=>
'',
'value' =>
'<input type="hidden" id="tasksavailable" name="tasksavailable" value="'.implode(
',', array_keys($task_to_affect)).
'">');
130 $formconfirmtoaddtasks =
$form->formconfirm($_SERVER[
'PHP_SELF'] . $url_redirect, $text,
'',
'addcontact_confirm', $formquestion,
'', 1, 300, 590);
131 $formconfirmtoaddtasks .=
'
133 $(document).ready(function() {
134 var saveprop = false;
135 $(".selectall").click(function(){
136 console.log("We click on select all with "+saveprop);
138 $(".taskcheckboxes").prop("checked", true);
141 $(".taskcheckboxes").prop("checked", false);
148 $action =
'addcontact_confirm';
153 if ($action ==
'addcontact_confirm' && $user->rights->projet->creer) {
157 if (! ($contactid > 0)) {
159 $langs->load(
"errors");
160 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Contact")),
null,
'errors');
164 $result = $object->fetch($id);
166 if (!$error && $result > 0 && $id > 0) {
167 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
170 $langs->load(
"errors");
171 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
172 } elseif ($result < 0) {
173 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
174 $langs->load(
"errors");
175 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
181 $affecttotask=
GETPOST(
'tasksavailable',
'intcomma');
182 if (!empty($affecttotask)) {
183 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
184 $task_to_affect = explode(
',', $affecttotask);
185 if (!empty($task_to_affect)) {
186 foreach ($task_to_affect as $task_id) {
188 $tasksToAffect =
new Task($db);
189 $result=$tasksToAffect->fetch($task_id);
193 $result = $tasksToAffect->add_contact($contactid,
GETPOST(
'person_role_'.$task_id),
GETPOST(
"source",
'aZ09'));
195 if ($tasksToAffect->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
196 $langs->load(
"errors");
197 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
210 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
216 if ($action ==
'swapstatut' && $user->rights->projet->creer) {
217 if ($object->fetch($id)) {
218 $result = $object->swapContactStatus(
GETPOST(
'ligne',
'int'));
225 if (($action ==
'deleteline' || $action ==
'deletecontact') && $user->rights->projet->creer) {
227 $result = $object->delete_contact(
GETPOST(
"lineid",
'int'));
230 header(
"Location: contact.php?id=".$object->id);
243 $title = $langs->trans(
'ProjectContact').
' - '.$object->ref.
' '.$object->name;
244 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
245 $title = $object->ref.
' '.$object->name.
' - '.$langs->trans(
'ProjectContact');
248 $help_url =
'EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte';
253 $contactstatic =
new Contact($db);
254 $userstatic =
new User($db);
263 if ($id > 0 || !empty($ref)) {
264 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object,
'fetchComments') && empty($object->comments)) {
265 $object->fetchComments();
269 $userWrite = $object->restrictedProjectArea($user,
'write');
274 print
dol_get_fiche_head($head,
'contact', $langs->trans(
"Project"), -1, ($object->public ?
'projectpub' :
'project'));
280 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
281 if (empty($reshook)) {
283 } elseif ($reshook > 0) {
292 $linkback =
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
294 $morehtmlref =
'<div class="refidno">';
296 $morehtmlref .= $object->title;
298 if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
299 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1,
'project');
301 $morehtmlref .=
'</div>';
304 if (empty($user->rights->projet->all->lire)) {
305 $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
306 $object->next_prev_filter =
" rowid IN (".$db->sanitize(count($objectsListId) ?join(
',', array_keys($objectsListId)) :
'0').
")";
309 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
312 print
'<div class="fichecenter">';
313 print
'<div class="fichehalfleft">';
314 print
'<div class="underbanner clearboth"></div>';
316 print
'<table class="border tableforfield centpercent">';
319 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) ||
isModEnabled(
'eventorganization')) {
320 print
'<tr><td class="tdtop">';
321 print $langs->trans(
"Usage");
324 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
325 print
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_opportunity ?
' checked="checked"' :
'')).
'"> ';
326 $htmltext = $langs->trans(
"ProjectFollowOpportunity");
327 print
$form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
330 if (empty($conf->global->PROJECT_HIDE_TASKS)) {
331 print
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task',
'alpha') !=
'' ?
' checked="checked"' :
'') : ($object->usage_task ?
' checked="checked"' :
'')).
'"> ';
332 $htmltext = $langs->trans(
"ProjectFollowTasks");
333 print
$form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
336 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
337 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"' :
'')).
'"> ';
338 $htmltext = $langs->trans(
"ProjectBillTimeDescription");
339 print
$form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
343 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"' :
'')).
'"> ';
344 $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
345 print
$form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
351 print
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
352 if ($object->public) {
353 print
img_picto($langs->trans(
'SharedProject'),
'world',
'class="paddingrightonly"');
354 print $langs->trans(
'SharedProject');
356 print
img_picto($langs->trans(
'PrivateProject'),
'private',
'class="paddingrightonly"');
357 print $langs->trans(
'PrivateProject');
361 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && $object->opp_status) {
363 print
'<tr><td>'.$langs->trans(
"OpportunityStatus").
'</td><td>';
364 $code =
dol_getIdFromCode($db, $object->opp_status,
'c_lead_status',
'rowid',
'code');
366 print $langs->trans(
"OppStatus".$code);
371 print
'<tr><td>'.$langs->trans(
"OpportunityProbability").
'</td><td>';
372 if (strcmp($object->opp_percent,
'')) {
373 print
price($object->opp_percent,
'', $langs, 1, 0).
' %';
378 print
'<tr><td>'.$langs->trans(
"OpportunityAmount").
'</td><td>';
379 if (strcmp($object->opp_amount,
'')) {
380 print
'<span class="amount">'.price($object->opp_amount,
'', $langs, 0, 0, 0, $conf->currency).
'</span>';
381 if (strcmp($object->opp_percent,
'')) {
382 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>';
389 print
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
390 if (strcmp($object->budget_amount,
'')) {
391 print
'<span class="amount">'.price($object->budget_amount,
'', $langs, 0, 0, 0, $conf->currency).
'</span>';
396 print
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
398 print ($start ? $start :
'?');
401 print ($end ? $end :
'?');
402 if ($object->hasDelay()) {
409 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
414 print
'<div class="fichehalfright">';
415 print
'<div class="underbanner clearboth"></div>';
417 print
'<table class="border tableforfield centpercent">';
420 print
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
421 print nl2br($object->description);
426 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
427 print
$form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
436 print
'<div class="clearboth"></div>';
443 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array(
'/core/tpl'));
444 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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages 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.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
$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.