dolibarr  7.0.0-beta
bloc_comment.tpl.php
1 <?php
2 
3 // Protection to avoid direct call of template
4 if (empty($conf) || ! is_object($conf))
5 {
6  print "Error, template page can't be called as URL";
7  exit;
8 }
9 
10 // Require
11 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
12 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
13 
14 
15 // Vars
16 $userstatic = new User($db);
17 $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
18 
19 
20 // Add comment
21 print '<br>';
22 print '<div id="comment">';
23 print '<form method="POST" action="'.$varpage.'?id='.$object->id.'">';
24 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
25 print '<input type="hidden" name="action" value="addcomment">';
26 print '<input type="hidden" name="id" value="'.$object->id.'">';
27 print '<input type="hidden" name="comment_element_type" value="'.$object->element.'">';
28 print '<input type="hidden" name="withproject" value="'.$withproject.'">';
29 
30 print '<table class="noborder nohover" width="100%">';
31 
32 print '<tr class="liste_titre">';
33 print '<td width="25%">'.$langs->trans("Comments").'</td>';
34 print '<td width="25%"></td>';
35 print '<td width="25%"></td>';
36 print '<td width="25%"></td>';
37 print "</tr>\n";
38 
39 print '<tr class="oddeven">';
40 
41 // Description
42 print '<td colspan="3">';
43 
44 $desc = GETPOST('comment_description');
45 
46 $doleditor = new DolEditor('comment_description', $desc, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '100%');
47 print $doleditor->Create(1);
48 
49 print '</td>';
50 
51 print '<td align="center">';
52 print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
53 print '</td></tr>';
54 print '</table></form>';
55 
56 // List of comments
57 if (!empty($object->comments))
58 {
59  // Default color for current user
60  $TColors = array($user->id => array('bgcolor'=>'efefef','color'=>'555'));
61  $first = true;
62  foreach($object->comments as $comment)
63  {
64  $fk_user = $comment->fk_user_author;
65  $userstatic->fetch($fk_user);
66 
67  if(empty($TColors[$fk_user])) {
68  $bgcolor = random_color(180,240);
69  if(!empty($userstatic->color)) {
70  $bgcolor = $userstatic->color;
71  }
72  $color = (colorIsLight($bgcolor))?'555':'fff';
73  $TColors[$fk_user] = array('bgcolor'=>$bgcolor,'color'=>$color);
74  }
75  print '<div class="width100p" style="color:#'.$TColors[$fk_user]['color'].'">';
76  if ($fk_user != $user->id) {
77  print '<div class="width25p float">&nbsp;</div>';
78  }
79 
80  print '<div class="width75p float comment comment-table" style="background-color:#'.$TColors[$fk_user]['bgcolor'].'">';
81  print '<div class="comment-info comment-cell">';
82  if (! empty($user->photo))
83  {
84  print Form::showphoto('userphoto', $userstatic, 80, 0, 0, '', 'small', 0, 1).'<br/>';
85  }
86  print $langs->trans('User').' : '.$userstatic->getNomUrl().'<br/>';
87  print $langs->trans('Date').' : '.dol_print_date($comment->datec,'dayhoursec');
88  print '</div>'; // End comment-info
89 
90  print '<div class="comment-cell comment-right">';
91  print '<div class="comment-table width100p">';
92  print '<div class="comment-description comment-cell">';
93  print $comment->description;
94  print '</div>'; // End comment-description
95  if(($first && $fk_user == $user->id) || $user->admin == 1) {
96  print '<a class="comment-delete comment-cell" href="'.$varpage.'?action=deletecomment&id='.$id.'&withproject=1&idcomment='.$comment->id.'" title="'.$langs->trans('Delete').'">';
97  print img_picto('', 'delete.png');
98  print '</a>';
99  }
100  print '</div>'; // End comment-table
101  print '</div>'; // End comment-right
102  print '</div>'; // End comment
103 
104  if($fk_user == $user->id) {
105  print '<div class="width25p float">&nbsp;</div>';
106  }
107  print '<div class="clearboth"></div>';
108  print '</div>'; // end 100p
109 
110  $first = false;
111  }
112 }
113 
114 print '<br>';
115 print '</div>';
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
Class to manage Dolibarr users.
Definition: user.class.php:39
static showphoto($modulepart, $object, $width=100, $height=0, $caneditfield=0, $cssclass='photowithmargin', $imagesize='', $addlinktofullsize=1, $cache=0)
Return HTML code to output a photo.
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print
Draft customers invoices.
Definition: index.php:91
Class to manage a WYSIWYG editor.
colorIsLight($stringcolor)
Return true if the color is light.