Location: PHPKode > projects > Toutateam Groupware > toutateam-v1.56/notes/notes_forms.php
<?php
/*
 * Toutateam Groupware
 * Created on 23 févr. 07
 * Copyright  ©  2007 Yannick Bétemps hide@address.com
 * www.toutateam.com
 * Author : Yannick Bétemps
 * 
 * Toutateam is a fork project of PHProjekt v4.0
 * 
 * File : notes_forms.php
 * Description : 
 * 
 */
$debugnotesform=false;
if(!defined("TTLIB_INCLUDED")) die('Direct Access not allowed');
if($debugnotesform) echo __LINE__."<br>\n";
  // fetch data from record
  if ($ID) {
    // fetch values from db
    $result = db_query("select * from notes where ID = '$ID'") or db_die();
    $row = db_fetch_row($result);
    // only check whether the user is the owner if 
    // 1. notes is private or 
    // 2. in group system user is not in this group or
    // in groupless system the value ext is not set to 1
    if (!$row[5] or ($groups and $row[5] <> $user_group) or (!$groups and $row[5] <> 1)) {
      // check permission and if a record exist
      check_permission("notes","von",$ID);
    }
  }
if($debugnotesform) echo __LINE__."<br>\n";
  
  // check permission to modify this record
  if (check_role("notes") < 2) {
    $read_o = "disabled style='background-color:$bgcolor3;'";
  }
if($debugnotesform) echo __LINE__."<br>\n";

  // display input form
  $hidden = array_merge(array('ID'=>$ID,'mode'=>'data'), $view_param);
  if(SID) { $hidden['PHPSESSID'] = $PHPSESSID; }
  echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width:750px;\" style=\"padding:0px;\"  align=\"center\">";
  echo "<tr><td style=\"padding:0px;\">";
  TT_Template::BlockBegin("notes","notesform","","mod_header");
  echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"4\">\n";
  echo "<form action='notes.php' method='post' name=frm onSubmit=\"return chkForm('frm','title','$opt_bm4!')\">\n";
  // title and link to help file
  //echo "<tr><td colspan=2  align=\"left\"><a href='$doc/notes.html' target=m><b>$o_notes</b></a></td></tr>\n";
  hidden_fields($hidden);
  // title ...
  echo "<tr><td colspan=\"2\" align=\"left\" class=\"lightbordercolor\" nowrap=\"nowrap\"><div align=\"left\"><b>".$forum_text5."</b>&nbsp;:&nbsp;<input type='text' name='title' size='90' value='".html_out($row[2])."' $read_o></div></td></tr>\n";
  // ... and remark
  echo "<tr><td style=\"width:550px;\" ><textarea style=\"width:550px;\"  rows=20 cols=70 name=\"remark\" id=\"remark\" wrap=physical $read_o>".html_out($row[3])."</textarea></td>\n";
  echo "<td>\n";
  // little table just to align the input fields contacts, projects and 'open to all'
  echo "<table border=0 cellspacing=\"0\" class=\"framestyleH\" style=\"margin-left:5px;\">\n";
  // contact link
  if ($adressen and !$contacts_nolink) {
    if (!$contact_ID) { $contact_ID = $row[4]; }
    echo "<tr><td>$proj_text12:</td><td> <select name=contact style=\"width:100px;\" $read_o>\n";
    echo "<option value=0>\n";
    $result2 = db_query("select ID, nachname, vorname from contacts where (von = '$user_ID' or acc like 'a' or (acc like 'g' and gruppe=".$user_group.")) order by nachname") or db_die();
    while ($row2 = db_fetch_row($result2)) {
      echo "<option value='$row2[0]'";
      if ($contact_ID == $row2[0]) { echo " selected"; }
      echo ">$row2[1], $row2[2]\n";
    }
    echo "</select></td></tr>\n";
  }
if($debugnotesform) echo __LINE__."<br>\n";


  // project link
  if ($projekte) {
    if (!$projekt_ID) { $projekt_ID = $row[8]; }
    echo "<tr><td>$l_text11:</td><td> <select name=projekt style=\"width:100px;\" $read_o><option value=0>\n";
    // prepare query for function
    $query = "where $sql_user_group";
    // call function to show all required elemts in a tree structure in the select box
    show_elements_of_tree("projekte","name",$query,"personen"," order by name",$projekt_ID,"parent",0);

    echo "</select></td></tr>\n";
  }
  // checkbox for general note
  // show only if you are the author
  if ($row[1] == $user_ID or !$ID) {
 
    // in the group system the value for this field is be the group ID
    if ($groups == "1") { $ext_value = $user_group; }    
    // but the groupless system the group doesn't have any number, so define the value of this field simply as '1'
    else { $ext_value = "1"; } 
    // if the 'external filed' in the db has a value, mark this box as checked.    
    if ($row[5] > 0) { $checked = "checked"; }
    echo "<tr><td>$con_text11:</td><td> <input type='checkbox' name='ext' value='$ext_value' $read_o$checked>&nbsp;</td></tr>\n";
  }
  // otherwise as hidden field so the other user shouldn't change this flag
  else { echo "<input type='hidden' name='ext' value='$row[5]'>\n"; }

// Modif YB du 22/02/2006 - Adding more fields
	if(file_exists("notes_morefields.php"))
	{
		include_once("notes_morefields.php");
		$myCls=new morefields_notes();
		$myCls->print_fields($row[0]);
	}

if($debugnotesform) echo __LINE__."<br>\n";

  // actions submit form, copy, print etc. only possible if this user has write access for notes in his role
  if (check_role("notes") > 1) {
    echo"<tr><td colspan=2><input type=image src='".$img_los."' border='0' id='tr'><br></td></tr>";
    // several actions: copy, mail or print
    if ($ID) {
      // copy or mail - only if the note is to privae, otherwise it wouldn't make sense
      if (!$row[5]) {
        echo "<tr><td colspan=2>\n";
        if(SID) echo "<input type='hidden' name='PHPSESSID' value='$PHPSESSID'>\n";
        echo "<input type='hidden' name='ID' value='$ID'>\n";
        echo "<br><select name='pers_ID'>\n";
        if ($user_group) {$result3 = db_query("select grup_user.user_ID,users.vorname,users.nachname from grup_user,users where grup_user.grup_ID = $user_group and grup_user.user_ID <> $user_ID AND grup_user.User_ID=users.ID;") or db_die();}
        else {$result3 = db_query("select ID from users where ID <> '$user_ID'") or db_die();}
        while ($row3 = db_fetch_row($result3)) {
          //$result2 = db_query("select ID, nachname, vorname from users where ID = '$row3[0]' order by nachname") or db_die();
          //$row2 = db_fetch_row($result2);
          //echo "<option value=$row2[0]>$row2[1], $row2[2]\n";
		  echo "<option value=\"$row3[0]\">".trim($row3[1]." ".$row3[2])."</option>\n";
        }
        echo "</select>";
        // copy button
        echo "&nbsp;&nbsp;<input type='submit' name='copy' value='$copy_it' border='0' onClick=\"return confirm('$confirm')\"> &nbsp; ";
        // mail button
        echo "<input type=submit name=mail value=$mail_text9 border=0 onClick=\"return confirm('$confirm')\"></td></tr></form>\n";
      } // end check owner of record
    } // end  check for role 
    // print
    echo "<tr><td colspan=2><div style=\"padding:2px;\"><a href='../misc/print.php?ID=$ID&module=notes$sid' target=_blank class=\"stylebutton\">$print</a></div></td></tr>\n";
  }
if($debugnotesform) echo __LINE__."<br>\n";
  echo "<tr><td colspan=2><div style=\"padding:2px;\"><a href='notes.php?mode=view&sort=$sort&up=$up&page=$page&perpage=$perpage&keyword=$keyword&filter=$filter$sid' class=\"stylebutton\">$back</a></div></td></tr>\n";
  echo "</form>\n";
  if(!$new_note)
  {
	  echo "<tr><td colspan=2><hr>\n";
	  $km_ID=$row[0]; $km_subject=$row[2]; $km_author=$row[1]; $km_doctype="note"; $km_body=$row[3]; $km_table="notes";
	  $km_file="../notes/notes.php";
	  include "../km/km_data.php";
	  echo "</td></tr>\n";  
  }
  echo "</table></td></tr></table>\n";
  TT_Template::BlockEnd();
  echo "</td></tr></table>\n";
  
	if($new_note==1 || $action=="modify" || $action=="add" || ( isset($ID) && $ID>0 ) || $notes_view_both)
	{
		TT_Template::EDITOR_Activate("remark","Simple",$path_pre);
	}
if($debugnotesform) echo __LINE__."<br>\n";

?>
Return current item: Toutateam Groupware