[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [10034] Started functionality for activities
From: |
Erik Holm-Larsen |
Subject: |
[Fmsystem-commits] [10034] Started functionality for activities |
Date: |
Thu, 27 Sep 2012 07:33:34 +0000 |
Revision: 10034
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10034
Author: erikhl
Date: 2012-09-27 07:33:32 +0000 (Thu, 27 Sep 2012)
Log Message:
-----------
Started functionality for activities
bugfixing on project
Modified Paths:
--------------
trunk/logistic/inc/class.soproject.inc.php
trunk/logistic/inc/class.uiproject.inc.php
trunk/logistic/inc/model/class.activity.inc.php
trunk/logistic/setup/phpgw_no.lang
Added Paths:
-----------
trunk/logistic/inc/class.soactivity.inc.php
trunk/logistic/inc/class.uiactivity.inc.php
trunk/logistic/templates/base/activity_datatable.xsl
Added: trunk/logistic/inc/class.soactivity.inc.php
===================================================================
--- trunk/logistic/inc/class.soactivity.inc.php (rev 0)
+++ trunk/logistic/inc/class.soactivity.inc.php 2012-09-27 07:33:32 UTC (rev
10034)
@@ -0,0 +1,209 @@
+<?php
+ /**
+ * phpGroupWare - logistic: a part of a Facilities Management System.
+ *
+ * @author Erik Holm-Larsen <address@hidden>
+ * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare 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.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/
+ * @package property
+ * @subpackage logistic
+ * @version $Id:$
+ */
+ phpgw::import_class('logistic.socommon');
+
+ include_class('logistic', 'activity', 'inc/model/');
+
+ class logistic_soactivity extends logistic_socommon
+ {
+ protected static $so;
+
+ /**
+ * Get a static reference to the storage object associated with
this model object
+ *
+ * @return logistic_soactivity the storage object
+ */
+ public static function get_instance()
+ {
+ if (self::$so == null)
+ {
+ self::$so = CreateObject('logistic.soactivity');
+ }
+ return self::$so;
+ }
+
+ protected function add(logistic_activity &$activity)
+ {
+ $cols = array(
+ 'name',
+ 'parent_id',
+ 'project_id',
+ 'start_date',
+ 'end_date',
+ 'responsible_user_id',
+ 'update_user',
+ 'update_date'
+ );
+
+ $values = array(
+ $this->marshal($activity->get_name(), 'string'),
+ $this->marshal($activity->get_parent_id(),
'int'),
+ $this->marshal($activity->get_project_id(),
'int'),
+ $this->marshal($activity->get_start_date(),
'int'),
+ $this->marshal($activity->get_end_date(),
'int'),
+
$this->marshal($activity->get_responsible_user_id(), 'int'),
+ $this->marshal($activity->get_update_user(),
'int'),
+ $this->marshal(strtotime('now'), 'int')
+ );
+
+ $sql = 'INSERT INTO lg_activity (' . join(',', $cols) .
') VALUES (' . join(',', $values) . ')';
+ $result = $this->db->query($sql, __LINE__,__FILE__);
+
+ if($result)
+ {
+ // Return the new activity ID
+ return
$this->db->get_last_insert_id('lg_activity', 'id');
+ }
+ else
+ {
+ return 0;
+ }
+
+ }
+
+ protected function update(logistic_activity $activity)
+ {
+ $id = intval($activity->get_id());
+
+ $values = array(
+ 'name=' . $this->marshal($activity->get_name(),
'string'),
+ 'parent_id=' .
$this->marshal($activity->get_parent_id(), 'int'),
+ 'project_id=' .
$this->marshal($activity->get_project_id(), 'int'),
+ 'start_date=' .
$this->marshal($activity->get_start_date(), 'int'),
+ 'end_date=' .
$this->marshal($activity->get_end_date(), 'int'),
+ 'responsible_user_id=' .
$this->marshal($activity->get_responsible_user_id(), 'int'),
+ 'update_user=' .
$this->marshal($activity->get_update_user(), 'int'),
+ 'update_date=' .
$this->marshal(strtotime('now'), 'int')
+ );
+
+ $result = $this->db->query('UPDATE lg_activity SET ' .
join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);
+
+ return $result;
+ }
+
+ protected function get_id_field_name()
+ {
+ if(!$extended_info)
+ {
+ $ret = 'id';
+ }
+ else
+ {
+ $ret = array
+ (
+ 'table' => 'activity',
// alias
+ 'field' => 'id',
+ 'translated' => 'id'
+ );
+ }
+
+ return $ret;
+ }
+
+ protected function get_query(string $sort_field, boolean
$ascending, string $search_for, string $search_type, array $filters, boolean
$return_count)
+ {
+ $clauses = array('1=1');
+
+ if($search_for)
+ {
+ $like_pattern = "'%" .
$this->db->db_addslashes($search_for) . "%'";
+ $like_clauses = array();
+ switch($search_type)
+ {
+ default:
+ $like_clauses[] =
"activity.name $this->like $like_pattern";
+ break;
+ }
+ if(count($like_clauses))
+ {
+ $clauses[] = '(' . join(' OR ',
$like_clauses) . ')';
+ }
+ }
+
+ $filter_clauses = array();
+ if(isset($filters[$this->get_id_field_name()]))
+ {
+ $filter_clauses[] = "activity.id =
{$this->marshal($filters[$this->get_id_field_name()],'int')}";
+ }/*
+ if(isset($filters['project']) && !$filters['project']
== '')
+ {
+ $filter_clauses[] = "activity.project_id =
{$this->marshal($filters['project'], 'int')}";
+ }
+ if(isset($filters['user']) && !$filters['user'] == '')
+ {
+ $filter_clauses[] =
"activity.responsible_user_id = {$this->marshal($filters['user'], 'int')}";
+ }
+*/
+ if(count($filter_clauses))
+ {
+ $clauses[] = join(' AND ', $filter_clauses);
+ }
+
+ $condition = join(' AND ', $clauses);
+
+ //$joins = " {$this->left_join} controller_control_area
ON (controller_procedure.control_area_id = controller_control_area.id)";
+ $tables = "lg_activity activity";
+
+ if($return_count) // We should only return a count
+ {
+ $cols = 'COUNT(DISTINCT(activity.id)) AS count';
+ }
+ else
+ {
+ $cols .= "* ";
+ }
+
+ $dir = $ascending ? 'ASC' : 'DESC';
+ $order = $sort_field ? "ORDER BY
{$this->marshal($sort_field, 'field')} $dir ": '';
+
+ //var_dump("SELECT {$cols} FROM {$tables} {$joins}
WHERE {$condition} {$order}");
+
+ return "SELECT {$cols} FROM {$tables} WHERE
{$condition} {$order}";
+ }
+
+ protected function populate(int $activity_id, &$activity)
+ {
+ if($activity == null)
+ {
+ $activity = new logistic_activity((int)
$activity_id);
+
+
$activity->set_name($this->unmarshal($this->db->f('name'), 'string'));
+
$activity->set_parent_id($this->unmarshal($this->db->f('parent_id'), 'int'));
+
$activity->set_project_id($this->unmarshal($this->db->f('project_id'), 'int'));
+
$activity->set_start_date($this->unmarshal($this->db->f('start_date'), 'int'));
+
$activity->set_end_date($this->unmarshal($this->db->f('end_date'), 'int'));
+
$activity->set_responsible_user_id($this->unmarshal($this->db->f('responsible_user_id'),
'int'));
+
$activity->set_update_date($this->unmarshal($this->db->f('update_date'),
'int'));
+
$activity->set_update_user($this->unmarshal($this->db->f('update_user'),
'int'));
+ }
+
+ return $activity;
+ }
+ }
+?>
Modified: trunk/logistic/inc/class.soproject.inc.php
===================================================================
--- trunk/logistic/inc/class.soproject.inc.php 2012-09-25 12:48:20 UTC (rev
10033)
+++ trunk/logistic/inc/class.soproject.inc.php 2012-09-27 07:33:32 UTC (rev
10034)
@@ -144,6 +144,10 @@
{
$filter_clauses[] = "{$table_alias}.id =
{$this->marshal($filters[$this->get_id_field_name()],'int')}";
}
+ if(isset($filters['project_type']) &&
!$filters['project_type'] == '')
+ {
+ $filter_clauses[] =
"{$table_alias}.project_type_id = {$this->marshal($filters['project_type'],
'int')}";
+ }
if(count($filter_clauses))
{
@@ -171,7 +175,7 @@
{
$cols .= "* ";
}
- //var_dump($sort_field);
+
$dir = $ascending ? 'ASC' : 'DESC';
$order = $sort_field ? "ORDER BY
{$this->marshal($sort_field, 'field')} $dir ": '';
@@ -198,6 +202,28 @@
return $project;
}
+ public function get_projects()
+ {
+ $project_array = array();
+ $project_array[] = array(
+ 'id' => '',
+ 'name' => lang('all_types'),
+ 'selected' => 1
+ );
+ $sql = "SELECT id, name FROM lg_project";
+ $this->db->query($sql, __LINE__, __FILE__);
+
+ while ($this->db->next_record())
+ {
+ $project_array[] = array(
+ 'id' => $this->db->f('id'),
+ 'name' =>
$this->unmarshal($this->db->f('name'), 'string')
+ );
+ }
+ return $project_array;
+ }
+
+
private function get_project_type_label($id)
{
$sql = "SELECT name FROM lg_project_type where id=$id";
@@ -212,6 +238,11 @@
public function get_project_types()
{
$project_type_array = array();
+ $project_type_array[] = array(
+ 'id' => '',
+ 'name' => lang('all_types'),
+ 'selected' => 1
+ );
$sql = "SELECT * FROM lg_project_type";
$this->db->query($sql, __LINE__, __FILE__);
Added: trunk/logistic/inc/class.uiactivity.inc.php
===================================================================
--- trunk/logistic/inc/class.uiactivity.inc.php (rev 0)
+++ trunk/logistic/inc/class.uiactivity.inc.php 2012-09-27 07:33:32 UTC (rev
10034)
@@ -0,0 +1,242 @@
+<?php
+/**
+ * phpGroupWare - logistic: a part of a Facilities Management System.
+ *
+ * @author Erik Holm-Larsen <address@hidden>
+ * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare 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.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/
+ * @package property
+ * @subpackage logistic
+ * @version $Id:$
+ */
+
+ phpgw::import_class('phpgwapi.uicommon');
+ phpgw::import_class('logistic.soactivity');
+
+ include_class('logistic', 'actvity');
+
+ class logistic_uiactivity extends phpgwapi_uicommon
+ {
+ private $so;
+ private $so_project;
+
+ public $public_functions = array(
+ 'query' => true,
+ 'index' => true
+ );
+
+ public function __construct() {
+ parent::__construct();
+
+ $this->so = createObject('logistic.soactivity');
+ $this->so_project = createObject('logistic.soproject');
+ $GLOBALS['phpgw_info']['flags']['menu_selection'] =
"logistic::project::activity";
+ }
+
+ public function index()
+ {
+ if(phpgw::get_var('phpgw_return_as') == 'json') {
+ return $this->query();
+ }
+ self::add_javascript('logistic', 'yahoo',
'datatable.js');
+ phpgwapi_yui::load_widget('datatable');
+ phpgwapi_yui::load_widget('paginator');
+
+ $project_array = $this->so_project->get_projects();
+ $user_array = $this->get_user_array();
+
+ $data = array(
+ 'form' => array(
+ 'toolbar' => array(
+ 'item' => array(
+ array('type' =>
'filter',
+ 'name' =>
'project',
+ 'text' =>
lang('Project').':',
+ 'list' =>
$project_array,
+ ),
+ array('type' =>
'filter',
+ 'name' =>
'user',
+ 'text' =>
lang('Responsible user').':',
+ 'list' =>
$user_array,
+ ),
+ array('type' => 'text',
+ 'text' =>
lang('search'),
+ 'name' =>
'query'
+ ),
+ array(
+ 'type' =>
'submit',
+ 'name' =>
'search',
+ 'value' =>
lang('Search')
+ ),
+ array(
+ 'type' =>
'link',
+ 'value' =>
lang('t_new_activity'),
+ 'href' =>
self::link(array('menuaction' => 'logistic.uiactivity.add')),
+ 'class' =>
'new_item'
+ ),
+ ),
+ ),
+ ),
+ 'datatable' => array(
+ 'source' =>
self::link(array('menuaction' => 'logistic.uiactivity.index', 'phpgw_return_as'
=> 'json')),
+ 'field' => array(
+ array(
+ 'key' => 'name',
+ 'label' =>
lang('Activity name'),
+ 'sortable' => true
+ ),
+ array(
+ 'key' => 'id',
+ 'label' => lang('ID'),
+ 'sortable' => true,
+ 'formatter' =>
'YAHOO.portico.formatLink'
+ ),
+ array(
+ 'key' => 'project_name',
+ 'label' =>
lang('Project'),
+ 'sortable' => false
+ ),
+ array(
+ 'key' => 'start_date',
+ 'label' => lang('Start
date'),
+ 'sortable' => false
+ ),
+ array(
+ 'key' => 'end_date',
+ 'label' => lang('End
date'),
+ 'sortable' => false
+ ),
+ array(
+ 'key' =>
'responsible_user_id',
+ 'label' =>
lang('Responsible user'),
+ 'sortable' => false
+ ),
+ array(
+ 'key' => 'link',
+ 'hidden' => true
+ )
+ )
+ ),
+ );
+
+ self::render_template_xsl(array( 'activity_datatable',
'datatable' ), $data);
+ }
+
+ public function query()
+ {
+ $params = array(
+ 'start' => phpgw::get_var('startIndex', 'int',
'REQUEST', 0),
+ 'results' => phpgw::get_var('results', 'int',
'REQUEST', null),
+ 'query' => phpgw::get_var('query'),
+ 'sort' => phpgw::get_var('sort'),
+ 'dir' => phpgw::get_var('dir'),
+ 'filters' => $filters
+ );
+
+
if($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] > 0)
+ {
+ $user_rows_per_page =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else {
+ $user_rows_per_page = 10;
+ }
+ // YUI variables for paging and sorting
+ $start_index = phpgw::get_var('startIndex', 'int');
+ $num_of_objects = phpgw::get_var('results', 'int',
'GET', $user_rows_per_page);
+ $sort_field = phpgw::get_var('sort');
+ $sort_ascending = phpgw::get_var('dir') == 'desc' ?
false : true;
+ // Form variables
+ $search_for = phpgw::get_var('query');
+ $search_type = phpgw::get_var('search_option');
+ // Create an empty result set
+ $result_objects = array();
+ $result_count = 0;
+
+ //Retrieve a contract identifier and load corresponding
contract
+ //$activity_id = phpgw::get_var('activity_id');
+
+ $exp_param = phpgw::get_var('export');
+ $export = false;
+ if(isset($exp_param)){
+ $export=true;
+ $num_of_objects = null;
+ }
+
+ //Retrieve the type of query and perform type specific
logic
+ $query_type = phpgw::get_var('type');
+ //var_dump($query_type);
+ switch($query_type)
+ {
+ default: // ... all activities, filters (active
and vacant)
+ phpgwapi_cache::session_set('logistic',
'activity_query', $search_for);
+ $filters = array('project' =>
phpgw::get_var('project'), 'user' => phpgw::get_var('user'));
+ $result_objects =
$this->so->get($start_index, $num_of_objects, $sort_field, $sort_ascending,
$search_for, $search_type, $filters);
+ $object_count =
$this->so->get_count($search_for, $search_type, $filters);
+ break;
+ }
+
+ //Create an empty row set
+ $rows = array();
+ foreach($result_objects as $result) {
+ if(isset($result))
+ {
+ $rows[] = $result->serialize();
+ }
+ }
+
+ // ... add result data
+ $result_data = array('results' => $rows);
+
+ $result_data['total_records'] = $object_count;
+ $result_data['start'] = $params['start'];
+ $result_data['sort'] = $params['sort'];
+ $result_data['dir'] = $params['dir'];
+
+ $editable = phpgw::get_var('editable') == 'true' ? true
: false;
+
+ if(!$export)
+ {
+ //Add action column to each row in result table
+ array_walk(
+ $result_data['results'],
+ array($this, '_add_links'),
+ "logistic.uiactivity.view");
+ }
+
+ return $this->yui_results($result_data);
+ }
+
+ private function get_user_array()
+ {
+ $user_array = array();
+ $user_array[] = array(
+ 'id' => '',
+ 'name' => lang('all_types')
+ );
+ $user_array[] = array(
+ 'id' =>
$GLOBALS['phpgw_info']['user']['account_id'],
+ 'name' => lang('my_activities'),
+ 'selected' => 1
+ );
+
+ return $user_array;
+ }
+ }
+?>
Modified: trunk/logistic/inc/class.uiproject.inc.php
===================================================================
--- trunk/logistic/inc/class.uiproject.inc.php 2012-09-25 12:48:20 UTC (rev
10033)
+++ trunk/logistic/inc/class.uiproject.inc.php 2012-09-27 07:33:32 UTC (rev
10034)
@@ -109,7 +109,7 @@
break;
default: // ... all composites, filters (active
and vacant)
phpgwapi_cache::session_set('logistic',
'project_query', $search_for);
- //$filters = array();
+ $filters = array('project_type' =>
phpgw::get_var('project_type'));
$result_objects =
$this->so->get($start_index, $num_of_objects, $sort_field, $sort_ascending,
$search_for, $search_type, $filters);
$object_count =
$this->so->get_count($search_for, $search_type, $filters);
break;
@@ -171,7 +171,7 @@
'toolbar' => array(
'item' => array(
array('type' =>
'filter',
- 'name' =>
'project_types',
+ 'name' =>
'project_type',
'text' =>
lang('Project_type').':',
'list' =>
$project_type_array,
),
Modified: trunk/logistic/inc/model/class.activity.inc.php
===================================================================
--- trunk/logistic/inc/model/class.activity.inc.php 2012-09-25 12:48:20 UTC
(rev 10033)
+++ trunk/logistic/inc/model/class.activity.inc.php 2012-09-27 07:33:32 UTC
(rev 10034)
@@ -27,7 +27,7 @@
* @version $Id $
*/
- include_class('logistic', 'model' , 'inc/model');
+ include_class('logistic', 'model' , 'inc/model/');
class logistic_activity extends logistic_model
{
@@ -40,6 +40,8 @@
protected static $start_date;
protected static $end_date;
protected static $responsible_user_id;
+ protected static $update_user;
+ protected static $update_date;
/**
* Constructor. Takes an optional ID. If a
contract is created from outside
@@ -121,6 +123,26 @@
{
return $this->responsible_user_id;
}
+
+ public function set_update_user($user_id)
+ {
+ $this->update_user = $user_id;
+ }
+
+ public function get_update_user()
+ {
+ return $this->update_user;
+ }
+
+ public function set_update_date($date)
+ {
+ $this->update_date = $date;
+ }
+
+ public function get_update_date()
+ {
+ return $this->update_date;
+ }
/**
* Get a static reference to the storage object
associated with this model object
@@ -130,7 +152,7 @@
public static function get_so()
{
if (self::$so == null) {
- self::$so =
CreateObject('logistic.soproject');
+ self::$so =
CreateObject('logistic.soactivity');
}
return self::$so;
Modified: trunk/logistic/setup/phpgw_no.lang
===================================================================
--- trunk/logistic/setup/phpgw_no.lang 2012-09-25 12:48:20 UTC (rev 10033)
+++ trunk/logistic/setup/phpgw_no.lang 2012-09-27 07:33:32 UTC (rev 10034)
@@ -10,9 +10,17 @@
ID logistic no ID
t_new_project logistic no Nytt prosjekt
t_new_project_type logistic no Ny prosjekttype
+t_new_activity logistic no Ny aktivitet
Project_type logistic no Prosjekttype
settings logistic no innstillinger
Project types logistic no Prosjekttyper
Project type name logistic no Navn
Project title logistic no Prosjektnavn
-Description logistic no Beskrivelse
\ No newline at end of file
+Description logistic no Beskrivelse
+all_types logistic no Alle
+Activity name logistic no Aktivitetsnavn
+Start date logistic no Startdato
+End date logistic no Sluttdato
+Responsible user logistic no Ansvarlig
+my_activities logistic no Mine aktiviteter
+No records found logistic no Ingen data
\ No newline at end of file
Added: trunk/logistic/templates/base/activity_datatable.xsl
===================================================================
--- trunk/logistic/templates/base/activity_datatable.xsl
(rev 0)
+++ trunk/logistic/templates/base/activity_datatable.xsl 2012-09-27
07:33:32 UTC (rev 10034)
@@ -0,0 +1,13 @@
+<!-- $Id: $ -->
+
+<xsl:template match="data" xmlns:php="http://php.net/xsl">
+
+<div id="main_content">
+
+ <h1><xsl:value-of select="php:function('lang','Activity')" /></h1>
+
+ <div id="activity" class="content-wrp">
+ <xsl:call-template name="datatable" />
+ </div>
+</div>
+</xsl:template>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [10034] Started functionality for activities,
Erik Holm-Larsen <=