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
|
|
|
'enable_nextmatchs_class' => True,
|
|
|
|
'enable_categories_class' => True
|
|
|
|
);
|
|
|
|
include('../header.inc.php');
|
|
|
|
|
2001-05-24 15:40:40 +02:00
|
|
|
$phpgw->infolog = createobject('infolog.infolog');
|
2001-05-23 21:07:45 +02:00
|
|
|
$db = $phpgw->db;
|
|
|
|
$db2 = $phpgw->db;
|
|
|
|
|
2001-05-24 15:40:40 +02:00
|
|
|
$phpgw->template = new Template($phpgw->common->get_tpl_dir('infolog'));
|
2001-05-23 21:07:45 +02:00
|
|
|
$phpgw->template->set_file(array( 'info_list_t' => 'list.tpl' ));
|
|
|
|
$phpgw->template->set_block('info_list_t','info_list','list');
|
|
|
|
|
2001-05-24 15:40:40 +02:00
|
|
|
$grants = $phpgw->acl->get_grants('infolog');
|
2001-05-23 21:07:45 +02:00
|
|
|
|
|
|
|
$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="cat_id" value="' . $cat_id . '">';
|
|
|
|
|
|
|
|
if ($action)
|
|
|
|
$common_hidden_vars .= '<input type="hidden" name="action" value="'.$action.'">';
|
|
|
|
|
|
|
|
switch ($action) {
|
|
|
|
case 'sp': // Sub-List
|
|
|
|
$common_hidden_vars .= '<input type="hidden" name="info_id" value="' . $info_id . '">';
|
|
|
|
$phpgw->template->set_var(lang_info_action,lang('Info Log - Subprojects from'));
|
|
|
|
break;
|
|
|
|
case 'proj':
|
|
|
|
$common_hidden_vars .= '<input type="hidden" name="proj_id" value="' . $proj_id . '">';
|
2001-05-24 15:40:40 +02:00
|
|
|
$proj = $phpgw->infolog->readProj($proj_id);
|
2001-05-23 21:07:45 +02:00
|
|
|
$phpgw->template->set_var(lang_info_action,lang('Info Log').' - '.$proj['title']);
|
|
|
|
break;
|
|
|
|
case 'addr':
|
|
|
|
$common_hidden_vars .= '<input type="hidden" name="addr_id" value="' . $addr_id . '">';
|
2001-05-24 15:40:40 +02:00
|
|
|
$addr = $phpgw->infolog->readAddr($addr_id);
|
|
|
|
$phpgw->template->set_var(lang_info_action,lang('Info Log').' - '.$phpgw->infolog->addr2name($addr));
|
2001-05-23 21:07:45 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$phpgw->template->set_var(lang_info_action,lang('Info Log'));
|
|
|
|
break;
|
|
|
|
}
|
2001-05-24 15:40:40 +02:00
|
|
|
$phpgw->template->set_var($phpgw->infolog->setStyleSheet( ));
|
|
|
|
$phpgw->template->set_var(actionurl,$phpgw->link('/infolog/edit.php?action=new'));
|
|
|
|
$phpgw->template->set_var('cat_form',$phpgw->link('/infolog/index.php'));
|
2001-05-23 21:07:45 +02:00
|
|
|
$phpgw->template->set_var('lang_category',lang('Category'));
|
|
|
|
$phpgw->template->set_var('lang_all',lang('All'));
|
|
|
|
$phpgw->template->set_var('lang_select',lang('Select'));
|
|
|
|
$phpgw->template->set_var('categories',$phpgw->categories->formated_list('select','all',$cat_id,'True'));
|
|
|
|
$phpgw->template->set_var(common_hidden_vars,$common_hidden_vars);
|
|
|
|
|
|
|
|
// ===========================================
|
|
|
|
// list header variable template-declarations
|
|
|
|
// ===========================================
|
2001-05-24 15:40:40 +02:00
|
|
|
$phpgw->template->set_var( $phpgw->infolog->infoHeaders( 1,$sort,$order ));
|
2001-05-23 21:07:45 +02:00
|
|
|
$phpgw->template->set_var(h_lang_sub,lang('Sub'));
|
|
|
|
$phpgw->template->set_var(h_lang_action,lang('Action'));
|
|
|
|
// -------------- end header declaration -----------------
|
|
|
|
|
|
|
|
if (! $start) {
|
|
|
|
$start = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($order) {
|
|
|
|
$ordermethod = 'order by ' . $order . ' ' . $sort;
|
|
|
|
} else {
|
|
|
|
$ordermethod = 'order by info_datecreated desc'; // newest first
|
|
|
|
}
|
|
|
|
if (!$filter) {
|
|
|
|
$filter = 'none';
|
|
|
|
}
|
2001-05-24 15:40:40 +02:00
|
|
|
$filtermethod = $phpgw->infolog->aclFilter($filter);
|
2001-05-23 21:07:45 +02:00
|
|
|
|
|
|
|
if ($cat_id) {
|
|
|
|
$filtermethod .= " AND info_cat='$cat_id' ";
|
|
|
|
}
|
|
|
|
if ($action == 'addr') $filtermethod .= " AND info_addr_id=$addr_id ";
|
|
|
|
if ($action == 'proj') $filtermethod .= " AND info_proj_id=$proj_id ";
|
|
|
|
// we search in _from, _subject and _des for $query
|
|
|
|
if ($query) $sql_query = "AND (info_from like '%$query%' OR info_subject like '%$query%' OR info_des like '%$query%') ";
|
|
|
|
|
|
|
|
$pid = 'AND info_id_parent='.($action == 'sp' ? $info_id : 0);
|
2001-05-24 15:40:40 +02:00
|
|
|
if ($phpgw->infolog->listChilds && $action != 'sp')
|
2001-05-23 21:07:45 +02:00
|
|
|
$pid = '';
|
|
|
|
|
2001-05-24 15:40:40 +02:00
|
|
|
$db->query("SELECT COUNT(*) FROM infolog WHERE $filtermethod $pid $sql_query",__LINE__,__FILE__);
|
2001-05-23 21:07:45 +02:00
|
|
|
$db->next_record();
|
|
|
|
$total = $db->f(0);
|
|
|
|
|
|
|
|
if ($total <= $start) $start = 0;
|
|
|
|
|
|
|
|
if ($total > $phpgw_info['user']['preferences']['common']['maxmatchs']) {
|
|
|
|
$to = $start + $phpgw_info['user']['preferences']['common']['maxmatchs']; if ($to > $total) $to = $total;
|
|
|
|
$total_matchs = lang('showing x - x of x',($start + 1),$to,$total);
|
|
|
|
} else {
|
|
|
|
$total_matchs = lang('showing x',$total);
|
|
|
|
}
|
|
|
|
$phpgw->template->set_var('total_matchs',$total_matchs);
|
|
|
|
|
|
|
|
// ==========================================
|
|
|
|
// project description if subprojectlist
|
|
|
|
// ==========================================
|
|
|
|
|
|
|
|
|
|
|
|
$phpgw->template->set_block('info_list_t','projdetails','projdetailshandle');
|
|
|
|
|
|
|
|
switch ($action) {
|
|
|
|
case 'sp': // details of parent
|
2001-05-24 15:40:40 +02:00
|
|
|
$phpgw->template->set_var( $phpgw->infolog->infoHeaders( ));
|
|
|
|
$phpgw->template->set_var( $phpgw->infolog->formatInfo( $info_id ));
|
2001-05-23 21:07:45 +02:00
|
|
|
$phpgw->template->parse('projdetailshandle','projdetails',True);
|
|
|
|
break;
|
|
|
|
case 'addr':
|
|
|
|
break;
|
|
|
|
case 'proj':
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ===========================================
|
|
|
|
// nextmatch variable template-declarations
|
|
|
|
// ===========================================
|
2001-05-24 15:40:40 +02:00
|
|
|
$next_matchs = $phpgw->nextmatchs->show_tpl('/infolog/index.php',$start,$total,
|
2001-05-23 21:07:45 +02:00
|
|
|
"&order=$order&filter=$filter&sort=$sort&query=$query&action=$action&info_id=$info_id&cat_id=$cat_id",
|
|
|
|
'95%',$phpgw_info['theme']['th_bg']);
|
|
|
|
$phpgw->template->set_var(next_matchs,$next_matchs);
|
|
|
|
// ---------- end nextmatch template --------------------
|
|
|
|
|
|
|
|
$limit = $db->limit($start);
|
|
|
|
|
2001-05-24 15:40:40 +02:00
|
|
|
$db->query($q="SELECT * FROM infolog WHERE $filtermethod $pid $sql_query $ordermethod $limit",__LINE__,__FILE__);
|
2001-05-23 21:07:45 +02:00
|
|
|
|
|
|
|
while ($db->next_record()) {
|
|
|
|
// ========================================
|
|
|
|
// check if actual project has subprojects
|
|
|
|
// ========================================
|
2001-05-24 15:40:40 +02:00
|
|
|
$db2->query("select count(*) as cnt FROM infolog where info_id_parent=" .$db->f('info_id'),__LINE__,__FILE__);
|
2001-05-23 21:07:45 +02:00
|
|
|
$db2->next_record();
|
|
|
|
if ($db2->f('cnt') > 0) {
|
|
|
|
$subproact = 1;
|
|
|
|
} else {
|
|
|
|
$subproact = 0;
|
|
|
|
}
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
$phpgw->nextmatchs->template_alternate_row_color(&$phpgw->template);
|
|
|
|
|
2001-05-24 15:40:40 +02:00
|
|
|
$phpgw->template->set_var( $phpgw->infolog->formatInfo( $db->Record,$proj_id,$addr_id ));
|
2001-05-23 21:07:45 +02:00
|
|
|
|
2001-05-24 15:40:40 +02:00
|
|
|
if ($phpgw->infolog->check_access($db->f('info_id'),PHPGW_ACL_EDIT)) {
|
|
|
|
$phpgw->template->set_var('edit','<a href="' . $phpgw->link('/infolog/edit.php','info_id=' . $db->f('info_id')
|
2001-05-23 21:07:45 +02:00
|
|
|
. '&sort=' . $sort . '&order=' . $order . '&query=' . $query . '&start=' . $start . '&filter=' . $filter)
|
2001-05-24 15:40:40 +02:00
|
|
|
. '">' . $phpgw->infolog->icon('action','edit') . '</a>');
|
2001-05-23 21:07:45 +02:00
|
|
|
} else {
|
|
|
|
$phpgw->template->set_var('edit','');
|
|
|
|
}
|
|
|
|
|
2001-05-24 15:40:40 +02:00
|
|
|
if ($phpgw->infolog->check_access($db->f('info_id'),PHPGW_ACL_DELETE)) {
|
|
|
|
$phpgw->template->set_var('delete','<a href="' . $phpgw->link('/infolog/delete.php','info_id=' . $db->f('info_id')
|
2001-05-23 21:07:45 +02:00
|
|
|
. '&sort=' . $sort . '&order=' . $order . '&query=' . $query . '&start=' . $start . '&filter=' . $filter)
|
2001-05-24 15:40:40 +02:00
|
|
|
. '">' . $phpgw->infolog->icon('action','delete') . '</a>');
|
2001-05-23 21:07:45 +02:00
|
|
|
} else {
|
|
|
|
$phpgw->template->set_var('delete','');
|
|
|
|
}
|
|
|
|
$phpgw->template->set_var('subadd', ''); // defaults no icons
|
|
|
|
$phpgw->template->set_var('viewsub', '');
|
|
|
|
$phpgw->template->set_var('viewparent', '');
|
|
|
|
|
|
|
|
if ($subproact > 0) { // if subprojects exist, display VIEW SUB icon
|
2001-05-24 15:40:40 +02:00
|
|
|
$phpgw->template->set_var('viewsub', '<a href="' . $phpgw->link('/infolog/index.php','info_id=' . $db->f('info_id')
|
|
|
|
. "&filter=$filter&action=sp") . '">' . $phpgw->infolog->icon('action','view') . '</a>');
|
2001-05-23 21:07:45 +02:00
|
|
|
} else { // else display ADD SUB-Icon
|
2001-05-24 15:40:40 +02:00
|
|
|
if ($phpgw->infolog->check_access($db->f('info_id'),PHPGW_ACL_ADD)) {
|
|
|
|
$phpgw->template->set_var('subadd', '<a href="' . $phpgw->link('/infolog/edit.php','info_id=' . $db->f('info_id') .
|
|
|
|
'&filter=' . $filter . '&action=sp') . '">' . $phpgw->infolog->icon('action','new') . '</a>');
|
2001-05-23 21:07:45 +02:00
|
|
|
}
|
|
|
|
} // if parent --> display VIEW SUBS of Parent
|
|
|
|
if ($db->f('info_id_parent') && $action != 'sp') {
|
2001-05-24 15:40:40 +02:00
|
|
|
$phpgw->template->set_var('viewparent', '<a href="' . $phpgw->link('/infolog/index.php','info_id=' . $db->f('info_id_parent') .
|
|
|
|
"&filter=$filter&action=sp") . '">' . $phpgw->infolog->icon('action','parent') . '</a>');
|
2001-05-23 21:07:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$phpgw->template->parse('list','info_list',True);
|
|
|
|
// -------------- end record declaration ------------------------
|
|
|
|
}
|
|
|
|
|
|
|
|
// =========================================================
|
|
|
|
// back2project list href declaration for subproject list
|
|
|
|
// =========================================================
|
|
|
|
|
|
|
|
if ($action) {
|
|
|
|
$phpgw->template->set_var('lang_back2projects', '<br><a href="' .
|
2001-05-24 15:40:40 +02:00
|
|
|
$phpgw->link('/infolog/index.php',"filter=$filter").
|
2001-05-23 21:07:45 +02:00
|
|
|
'">'.lang('Back to Projectlist').'</a>');
|
|
|
|
}
|
|
|
|
|
|
|
|
// get actual date and year for matrixview arguments
|
|
|
|
/* $year = date('Y');
|
|
|
|
$month = date('m');
|
2001-05-24 15:40:40 +02:00
|
|
|
$phpgw->template->set_var('lang_matrixviewhref', '<br><a href="' . $phpgw->link('/infolog/graphview.php',"month=$month&year=$year&filter=$filter").
|
2001-05-23 21:07:45 +02:00
|
|
|
'">'.lang('View Matrix of actual Month').'</a>'); */
|
|
|
|
// ============================================
|
|
|
|
// template declaration for Add Form
|
|
|
|
// ============================================
|
|
|
|
|
|
|
|
$phpgw->template->set_var(lang_add,lang('Add'));
|
|
|
|
$phpgw->template->pfp('out','info_list_t',true);
|
|
|
|
|
|
|
|
// -------------- end Add form declaration ------------------------
|
|
|
|
|
|
|
|
$phpgw->common->phpgw_footer();
|
|
|
|
?>
|