2001-05-23 21:07:45 +02:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare - Info Log *
|
|
|
|
* http://www.phpgroupware.org *
|
|
|
|
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
|
2001-05-24 15:40:40 +02:00
|
|
|
* originaly based on todo written by Joseph Engo <jengo@phpgroupware.org> *
|
2001-05-23 21:07:45 +02:00
|
|
|
* -------------------------------------------- *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU General Public License as published by the *
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
$phpgw_info['flags'] = array(
|
2001-05-24 15:40:40 +02:00
|
|
|
'currentapp' => 'infolog',
|
2001-05-23 21:07:45 +02:00
|
|
|
'noheader' => True,
|
|
|
|
'nofooter' => True,
|
|
|
|
'nonavbar' => True,
|
|
|
|
'enable_categories_class' => True
|
|
|
|
);
|
|
|
|
include('../header.inc.php');
|
|
|
|
|
|
|
|
if ((!isset($info_id) || !$info_id) && !$action) {
|
2001-05-24 15:40:40 +02:00
|
|
|
Header('Location: ' . $phpgw->link('/infolog/index.php',"sort=$sort&order=$order&query=$query&start=$start&".
|
|
|
|
"filter=$filter&cat_id=$cat_id"));
|
2001-05-23 21:07:45 +02:00
|
|
|
}
|
|
|
|
|
2001-05-24 15:40:40 +02:00
|
|
|
$phpgw->infolog = createobject('infolog.infolog');
|
2001-05-23 21:07:45 +02:00
|
|
|
|
2001-05-29 22:37:57 +02:00
|
|
|
if ($save || $add) {
|
2001-05-23 21:07:45 +02:00
|
|
|
if (strlen($des) >= 8000) {
|
|
|
|
$error[] = lang('Description can not exceed 8000 characters in length');
|
|
|
|
}
|
|
|
|
if (!$subject && !$des) {
|
|
|
|
$error[] = lang('You must enter a subject or a description');
|
|
|
|
}
|
|
|
|
|
|
|
|
// check wether to write dates or not
|
|
|
|
if ($selfortoday) {
|
|
|
|
$startdate = time(); // startdate is today (checkbox is clicked)
|
|
|
|
} else {
|
|
|
|
if ($smonth || $sday || $syear) {
|
|
|
|
if ($sday && !$smonth) $smonth = date('m',time());
|
|
|
|
if ($sday && !$syear) $syear = date('Y',time());
|
|
|
|
if (! checkdate($smonth,$sday,$syear)) {
|
|
|
|
$error[] = lang('You have entered an invalid starting date');
|
|
|
|
} else {
|
|
|
|
$startdate = mktime(12,0,0,$smonth, $sday, $syear);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$startdate = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check ending date
|
|
|
|
if ($dur_days > 0) {
|
|
|
|
$enddate = mktime(12,0,0,date('m',$startdate), date('d',$startdate)+$dur_days, date('Y',$startdate));
|
|
|
|
} else
|
|
|
|
if ($emonth || $eday || $eyear) {
|
|
|
|
if ($eday && !$emonth) $emonth = date('m',time());
|
|
|
|
if ($eday && !$eyear) $eyear = date('Y',time());
|
|
|
|
if (!checkdate($emonth,$eday,$eyear)) {
|
|
|
|
$error[] = lang('You have entered an invalid ending date');
|
|
|
|
} else {
|
|
|
|
$enddate = mktime(12,0,0,$emonth,$eday,$eyear);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$enddate = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($enddate < $startdate && $enddate && $startdate) {
|
|
|
|
$error[] = lang('Ending date can not be before start date');
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($access) {
|
|
|
|
$access = 'private';
|
|
|
|
} else {
|
|
|
|
$access = 'public';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! is_array($error)) {
|
2001-05-24 15:40:40 +02:00
|
|
|
$phpgw->infolog->write(array(
|
2001-05-23 21:07:45 +02:00
|
|
|
'type' => $type,
|
|
|
|
'from' => $from,
|
|
|
|
'addr' => $addr,
|
2001-05-28 22:20:38 +02:00
|
|
|
'addr_id' => $id_addr,
|
|
|
|
'proj_id' => $id_project,
|
2001-05-23 21:07:45 +02:00
|
|
|
'subject' => $subject,
|
|
|
|
'des' => $des,
|
|
|
|
'pri' => $pri,
|
|
|
|
'status' => $status,
|
|
|
|
'confirm' => $confirm,
|
|
|
|
'access' => $access,
|
|
|
|
'cat' => $info_cat,
|
|
|
|
'startdate' => $startdate,
|
|
|
|
'enddate' => $enddate,
|
|
|
|
'info_id' => $info_id,
|
|
|
|
'id_parent' => $id_parent,
|
|
|
|
'responsible' => $responsible
|
|
|
|
));
|
|
|
|
|
2001-05-28 22:20:38 +02:00
|
|
|
if (!$query_addr && !$query_project) {
|
2001-05-24 15:40:40 +02:00
|
|
|
Header('Location: ' . $phpgw->link('/infolog/index.php', "cd=15&sort=$sort&order=$order&query=$query&".
|
2001-05-23 21:07:45 +02:00
|
|
|
"start=$start&filter=$filter&cat_id=$cat_id"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-05-24 15:40:40 +02:00
|
|
|
$phpgw->infolog->read( $info_id );
|
2001-05-23 21:07:45 +02:00
|
|
|
if ($info_id && $action == 'sp') { // new SubProject
|
2001-05-24 15:40:40 +02:00
|
|
|
if (!$phpgw->infolog->check_access($info_id,PHPGW_ACL_ADD)) {
|
|
|
|
Header('Location: ' . $phpgw->link('/infolog/index.php',"sort=$sort&order=$order&query=$query&start=$start&filter=$filter"));
|
2001-05-23 21:07:45 +02:00
|
|
|
$phpgw->common->phpgw_exit();
|
|
|
|
}
|
2001-05-24 15:40:40 +02:00
|
|
|
$parent = $phpgw->infolog->data;
|
|
|
|
$phpgw->infolog->data['info_id'] = $info_id = 0;
|
|
|
|
$phpgw->infolog->owner = $phpgw_info['user']['account_id'];
|
|
|
|
$phpgw->infolog->data['info_id_parent'] = $parent['info_id'];
|
2001-05-23 21:07:45 +02:00
|
|
|
if ($parent['info_type'] == 'task' && $parent['info_status'] == 'offer') {
|
2001-05-24 15:40:40 +02:00
|
|
|
$phpgw->infolog->data['info_type'] = 'confirm';
|
|
|
|
$phpgw->infolog->data['info_responsible'] = $parent['info_owner']; // confirmation to parent
|
2001-05-23 21:07:45 +02:00
|
|
|
}
|
2001-05-24 15:40:40 +02:00
|
|
|
$phpgw->infolog->data['info_status'] = 'ongoing';
|
|
|
|
$phpgw->infolog->data['info_confirm'] = 'not';
|
|
|
|
$phpgw->infolog->data['info_subject'] = lang('Re:').' '.$parent['info_subject'];
|
|
|
|
$phpgw->infolog->data['info_des'] = '';
|
2001-05-23 21:07:45 +02:00
|
|
|
} else {
|
2001-05-24 15:40:40 +02:00
|
|
|
if ($info_id && !$phpgw->infolog->check_access($info_id,PHPGW_ACL_EDIT)) {
|
|
|
|
Header('Location: ' . $phpgw->link('/infolog/index.php',"sort=$sort&order=$order&query=$query&start=$start&filter=$filter"));
|
2001-05-23 21:07:45 +02:00
|
|
|
$phpgw->common->phpgw_exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$common_hidden_vars =
|
|
|
|
'<input type="hidden" name="sort" value="' . $sort . '">'
|
|
|
|
. '<input type="hidden" name="order" value="' . $order. '">'
|
|
|
|
. '<input type="hidden" name="query" value="' . $query . '">'
|
|
|
|
. '<input type="hidden" name="start" value="' . $start . '">'
|
|
|
|
. '<input type="hidden" name="filter" value="' . $filter . '">'
|
|
|
|
. '<input type="hidden" name="info_id" value="' . $info_id. '">'
|
2001-05-24 15:40:40 +02:00
|
|
|
. '<input type="hidden" name="id_parent" value="' . ($id_parent = $phpgw->infolog->data['info_id_parent']). '">'
|
2001-05-23 21:07:45 +02:00
|
|
|
. '<input type="hidden" name="action" value="' . $action. '">';
|
|
|
|
|
|
|
|
$phpgw->common->phpgw_header();
|
|
|
|
echo parse_navbar();
|
|
|
|
|
2001-05-31 00:00:51 +02:00
|
|
|
$phpgw->db->query("select * FROM phpgw_infolog where info_id='$info_id'");
|
2001-05-23 21:07:45 +02:00
|
|
|
$phpgw->db->next_record();
|
|
|
|
|
2001-05-24 15:40:40 +02:00
|
|
|
$pri_selected[$phpgw->infolog->data['info_pri']] = ' selected';
|
|
|
|
$status_selected[$phpgw->infolog->data['info_status']] = ' selected';
|
2001-05-23 21:07:45 +02:00
|
|
|
|
2001-05-24 20:17:54 +02:00
|
|
|
$t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
|
|
|
|
$t->set_file(array('info_edit' => 'form.tpl'));
|
2001-05-23 21:07:45 +02:00
|
|
|
|
|
|
|
// ====================================================================
|
|
|
|
// create two seperate blocks, addblock will be cut off from template
|
|
|
|
// editblock contains the buttons and forms for edit
|
|
|
|
// ====================================================================
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_block('info_edit', 'add', 'addhandle');
|
|
|
|
$t->set_block('info_edit', 'edit', 'edithandle');
|
|
|
|
$t->set_block('info_edit', 'subpro', 'subprohandle');
|
2001-05-23 21:07:45 +02:00
|
|
|
|
|
|
|
if (is_array($error)) {
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var('error_list',$phpgw->common->error_list($error));
|
2001-05-23 21:07:45 +02:00
|
|
|
}
|
|
|
|
switch ($action) {
|
|
|
|
case 'sp':
|
|
|
|
$info_action = 'Info Log - New Subproject'; break;
|
|
|
|
case 'new':
|
|
|
|
$info_action = 'Info Log - New'; break;
|
|
|
|
default:
|
|
|
|
$info_action = 'Info Log - Edit'; break;
|
|
|
|
}
|
2001-05-28 22:20:38 +02:00
|
|
|
$t->set_var('lang_info_action',lang($info_action) . ($query_addr ? ' - '.lang('Search for:')." '$query_addr'" : ''));
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var($phpgw->infolog->setStyleSheet( ));
|
|
|
|
$t->set_var('lang_category',lang('Category'));
|
|
|
|
$t->set_var('lang_none',lang('None'));
|
|
|
|
$t->set_var('cat_list',$phpgw->categories->formated_list('select','all',$phpgw->infolog->data['info_cat'],'True'));
|
2001-05-23 21:07:45 +02:00
|
|
|
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var('actionurl',$phpgw->link('/infolog/edit.php'));
|
|
|
|
$t->set_var('common_hidden_vars',$common_hidden_vars);
|
2001-05-23 21:07:45 +02:00
|
|
|
|
2001-05-28 22:20:38 +02:00
|
|
|
$sb2 = CreateObject('phpgwapi.sbox2');
|
|
|
|
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var('lang_owner',lang('Owner'));
|
2001-05-28 22:20:38 +02:00
|
|
|
$t->set_var('owner_info',$sb2->accountInfo($phpgw->infolog->data['info_owner']));
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var('lang_type',lang('Type'));
|
2001-05-28 22:20:38 +02:00
|
|
|
$t->set_var('type_list',$sb2->getArrayItem('type',$phpgw->infolog->data['info_type'],$phpgw->infolog->enums['type']));
|
2001-05-23 21:07:45 +02:00
|
|
|
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var('lang_prfrom', lang('From'));
|
|
|
|
$t->set_var('fromval', $phpgw->strip_html($phpgw->infolog->data['info_from']));
|
|
|
|
$t->set_var('lang_praddr', lang('Phone/Email'));
|
|
|
|
$t->set_var('addrval', $phpgw->strip_html($phpgw->infolog->data['info_addr']));
|
2001-05-23 21:07:45 +02:00
|
|
|
|
2001-05-28 22:20:38 +02:00
|
|
|
$t->set_var($sb2->getProject('project',$phpgw->infolog->data['info_proj_id'],$query_project));
|
|
|
|
$t->set_var($sb2->getAddress('addr',$phpgw->infolog->data['info_addr_id'],$query_addr));
|
2001-05-23 21:07:45 +02:00
|
|
|
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var('lang_prsubject', lang('Subject'));
|
|
|
|
$t->set_var('subjectval', $phpgw->strip_html($phpgw->infolog->data['info_subject']));
|
|
|
|
$t->set_var('lang_prdesc', lang('Description'));
|
|
|
|
$t->set_var('descval', $phpgw->strip_html($phpgw->infolog->data['info_des']));
|
2001-05-23 21:07:45 +02:00
|
|
|
|
|
|
|
// get month/day/year fields for startdate and enddate
|
2001-05-24 15:40:40 +02:00
|
|
|
if ($phpgw->infolog->data['info_startdate'] == 0) {
|
2001-05-23 21:07:45 +02:00
|
|
|
$sday = $smonth = $syear = 0;
|
|
|
|
} else {
|
2001-05-24 15:40:40 +02:00
|
|
|
$sday = date('d',$phpgw->infolog->data['info_startdate']);
|
|
|
|
$smonth = date('m',$phpgw->infolog->data['info_startdate']);
|
|
|
|
$syear = date('Y',$phpgw->infolog->data['info_startdate']);
|
2001-05-23 21:07:45 +02:00
|
|
|
}
|
|
|
|
|
2001-05-24 15:40:40 +02:00
|
|
|
if ($phpgw->infolog->data['info_enddate'] == 0) {
|
2001-05-23 21:07:45 +02:00
|
|
|
$eday = $emonth = $eyear = 0;
|
|
|
|
} else {
|
2001-05-24 15:40:40 +02:00
|
|
|
$eday = date('d',$phpgw->infolog->data['info_enddate']);
|
|
|
|
$emonth = date('m',$phpgw->infolog->data['info_enddate']);
|
|
|
|
$eyear = date('Y',$phpgw->infolog->data['info_enddate']);
|
2001-05-23 21:07:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// get an instance of select box class
|
|
|
|
$sm = CreateObject('phpgwapi.sbox');
|
|
|
|
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var('lang_start_date',lang('Start Date'));
|
|
|
|
$t->set_var('start_select_date',$phpgw->common->dateformatorder($sm->getYears('syear',$syear,$syear<date('Y')?$syear:date('Y')-2),
|
2001-05-23 21:07:45 +02:00
|
|
|
$sm->getMonthText('smonth', $smonth),$sm->getDays('sday', $sday)));
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var('lang_end_date',lang('End Date'));
|
|
|
|
$t->set_var('end_select_date',$phpgw->common->dateformatorder($sm->getYears('eyear', $eyear,$eyear<date('Y')?$eyear:date('Y')-2),
|
2001-05-23 21:07:45 +02:00
|
|
|
$sm->getMonthText('emonth', $emonth),$sm->getDays('eday', $eday)));
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var('lang_selfortoday',lang('Today'));
|
|
|
|
$t->set_var('selfortoday','<input type="checkbox" name="selfortoday" value="True"> ');
|
|
|
|
$t->set_var('lang_dur_days',lang('Duration'));
|
|
|
|
$t->set_var('days',lang('days'));
|
2001-05-23 21:07:45 +02:00
|
|
|
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var('lang_status',lang('Status'));
|
2001-05-28 22:20:38 +02:00
|
|
|
$t->set_var('status_list',$sb2->getArrayItem('status',$phpgw->infolog->data['info_status'],$phpgw->infolog->enums['status']));
|
2001-05-23 21:07:45 +02:00
|
|
|
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var('lang_priority',lang('Priority'));
|
2001-05-28 22:20:38 +02:00
|
|
|
$t->set_var('priority_list',$sb2->getArrayItem('pri',$phpgw->infolog->data['info_pri'],$phpgw->infolog->enums['priority']));
|
2001-05-23 21:07:45 +02:00
|
|
|
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var('lang_confirm',lang('Confirm'));
|
2001-05-28 22:20:38 +02:00
|
|
|
$t->set_var('confirm_list',$sb2->getArrayItem('confirm',$phpgw->infolog->data['info_confirm'],$phpgw->infolog->enums['confirm']));
|
2001-05-23 21:07:45 +02:00
|
|
|
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var('lang_responsible',lang('Responsible'));
|
2001-05-28 22:20:38 +02:00
|
|
|
$t->set_var('responsible_list',$sb2->getAccount('responsible',$phpgw->infolog->data['info_responsible']));
|
2001-05-23 21:07:45 +02:00
|
|
|
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var('lang_access_type',lang('Private'));
|
|
|
|
$t->set_var('access_list', '<input type="checkbox" name="access" value="True"' . ($phpgw->infolog->data['info_access'] == 'private'?' checked':'') . '>');
|
2001-05-23 21:07:45 +02:00
|
|
|
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var('delete_action',$phpgw->link('/infolog/delete.php'));
|
2001-05-23 21:07:45 +02:00
|
|
|
|
2001-05-29 22:37:57 +02:00
|
|
|
$t->set_var('edit_button','<input type="submit" name="save" value="' . lang('Save') . '">');
|
2001-05-23 21:07:45 +02:00
|
|
|
|
2001-05-24 15:40:40 +02:00
|
|
|
if (!$action && $phpgw->infolog->check_access($info_id,PHPGW_ACL_DELETE)) {
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var('delete_button','<input type="submit" name="delete" value="' . lang('Delete') . '">');
|
2001-05-23 21:07:45 +02:00
|
|
|
}
|
2001-05-24 20:17:54 +02:00
|
|
|
$t->set_var('edithandle','');
|
|
|
|
$t->set_var('addhandle','');
|
|
|
|
$t->set_var('subprohandle','');
|
|
|
|
$t->pfp('out','info_edit');
|
|
|
|
$t->pfp('edithandle','edit');
|
2001-05-23 21:07:45 +02:00
|
|
|
|
|
|
|
// I would like to have it calculate the amount of days and drop it in days from now.
|
|
|
|
|
|
|
|
$phpgw->common->phpgw_footer();
|
|
|
|
echo parse_navbar_end();
|