[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [10054] Registration and editing activity
From: |
Torstein |
Subject: |
[Fmsystem-commits] [10054] Registration and editing activity |
Date: |
Fri, 28 Sep 2012 11:06:59 +0000 |
Revision: 10054
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10054
Author: vator
Date: 2012-09-28 11:06:59 +0000 (Fri, 28 Sep 2012)
Log Message:
-----------
Registration and editing activity
Modified Paths:
--------------
trunk/logistic/inc/class.soactivity.inc.php
trunk/logistic/inc/class.uiactivity.inc.php
trunk/logistic/inc/class.uiproject.inc.php
trunk/logistic/inc/model/class.activity.inc.php
trunk/logistic/templates/base/css/base.css
Added Paths:
-----------
trunk/logistic/templates/base/activity_item.xsl
Modified: trunk/logistic/inc/class.soactivity.inc.php
===================================================================
--- trunk/logistic/inc/class.soactivity.inc.php 2012-09-28 09:22:47 UTC (rev
10053)
+++ trunk/logistic/inc/class.soactivity.inc.php 2012-09-28 11:06:59 UTC (rev
10054)
@@ -51,8 +51,8 @@
protected function add(&$activity)
{
$cols = array(
+ 'parent_activity_id',
'name',
- 'parent_id',
'project_id',
'start_date',
'end_date',
@@ -61,9 +61,19 @@
'update_date'
);
+ if( $activity->get_project_id() == '')
+ {
+ $activity->set_project_id(1);
+ }
+
+ if( $activity->get_responsible_user_id() == '')
+ {
+ $activity->set_responsible_user_id(1);
+ }
+
$values = array(
+ $this->marshal($activity->get_parent_id(),
'int'),
$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'),
@@ -74,7 +84,7 @@
$sql = 'INSERT INTO lg_activity (' . join(',', $cols) .
') VALUES (' . join(',', $values) . ')';
$result = $this->db->query($sql, __LINE__,__FILE__);
-
+
if($result)
{
// Return the new activity ID
@@ -84,7 +94,6 @@
{
return 0;
}
-
}
protected function update($activity)
@@ -93,7 +102,7 @@
$values = array(
'name=' . $this->marshal($activity->get_name(),
'string'),
- 'parent_id=' .
$this->marshal($activity->get_parent_id(), 'int'),
+ 'parent_activity_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'),
@@ -104,7 +113,15 @@
$result = $this->db->query('UPDATE lg_activity SET ' .
join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);
- return $result;
+ if($result)
+ {
+ // Return the new activity ID
+ return
$this->db->get_last_insert_id('lg_activity', 'id');
+ }
+ else
+ {
+ return 0;
+ }
}
protected function get_id_field_name()
Modified: trunk/logistic/inc/class.uiactivity.inc.php
===================================================================
--- trunk/logistic/inc/class.uiactivity.inc.php 2012-09-28 09:22:47 UTC (rev
10053)
+++ trunk/logistic/inc/class.uiactivity.inc.php 2012-09-28 11:06:59 UTC (rev
10054)
@@ -29,7 +29,7 @@
*/
phpgw::import_class('phpgwapi.uicommon');
phpgw::import_class('logistic.soactivity');
-
+
include_class('logistic', 'actvity');
class logistic_uiactivity extends phpgwapi_uicommon
@@ -39,6 +39,9 @@
private $so_project;
public $public_functions = array(
'query' => true,
+ 'add' => true,
+ 'edit' => true,
+ 'view' => true,
'index' => true
);
@@ -229,7 +232,123 @@
return $this->yui_results($result_data);
}
+
+ public function add()
+ {
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'logistic.uiactivity.edit'));
+ }
+ public function edit()
+ {
+ $activity_id = phpgw::get_var('id');
+ if ($activity_id && is_numeric($activity_id))
+ {
+ $activity = $this->so->get_single($activity_id);
+ }
+ else
+ {
+ $activity = new logistic_activity();
+ }
+
+ $activity->set_project_id(phpgw::get_var('project_id'));
+
+ if (isset($_POST['save_activity']))
+ {
+ $user_id = $GLOBALS['phpgw_info']['user']['id'];
+ $activity->set_id(phpgw::get_var('id'));
+ $activity->set_name(phpgw::get_var('name'));
+ $activity->set_update_user($user_id);
+
+ if(phpgw::get_var('start_date','string') != '')
+ {
+ $start_date_ts =
phpgwapi_datetime::date_to_timestamp( phpgw::get_var('start_date','string') );
+
$activity->set_start_date($start_date_ts);
+ }
+ else
+ {
+ $activity->set_start_date(0);
+ }
+
+ if( phpgw::get_var('end_date','string') != '')
+ {
+ $end_date_ts =
phpgwapi_datetime::date_to_timestamp( phpgw::get_var('end_date','string') );
+ $activity->set_end_date($end_date_ts);
+ }
+ else
+ {
+ $activity->set_end_date(0);
+ }
+
+ $activity_id = $this->so->store($activity);
+
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'logistic.uiactivity.view', 'id' => $activity_id,
'project_id' => $activity->get_project_id()));
+ }
+ else if (isset($_POST['cancel_activity']))
+ {
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'logistic.uiactivity.view', 'id' => $activity_id));
+ }
+ else
+ {
+ $data = array
+ (
+ 'activity' => $activity->toArray(),
+ 'img_go_home' =>
'rental/templates/base/images/32x32/actions/go-home.png',
+ 'editable' => true,
+ 'dateformat'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']
+ );
+
+ $this->use_yui_editor('description');
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('logistic') . '::' . lang('Add activity');
+
+
$GLOBALS['phpgw']->jqcal->add_listener('start_date');
+
$GLOBALS['phpgw']->jqcal->add_listener('end_date');
+
+
self::render_template_xsl(array('activity_item'), $data);
+ }
+ }
+
+
+ public function view()
+ {
+ $activity_id = phpgw::get_var('id');
+ $project_id = phpgw::get_var('project_id');
+ if (isset($_POST['edit_activity']))
+ {
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'logistic.uiactivity.edit', 'id' => $activity_id,
'project_id' => $project_id));
+ }
+ else if (isset($_POST['new_activity']))
+ {
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'logistic.uiactivity.edit', 'project_id' => $project_id));
+ }
+ else
+ {
+ if ($activity_id && is_numeric($activity_id))
+ {
+ $activity =
$this->so->get_single($activity_id);
+ }
+
+ $activity_array = $activity->toArray();
+
+ if ($this->flash_msgs)
+ {
+ $msgbox_data =
$GLOBALS['phpgw']->common->msgbox_data($this->flash_msgs);
+ $msgbox_data =
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
+ }
+
+ $activity->set_project_id($project_id);
+
+ $data = array
+ (
+ 'activity' =>
$activity->toArray(),
+ 'img_go_home' =>
'rental/templates/base/images/32x32/actions/go-home.png',
+ 'dateformat'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']
+ );
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('logistic') . '::' . lang('Project');
+
self::render_template_xsl(array('activity_item'), $data);
+ }
+ }
+
private function get_user_array()
{
$user_array = array();
@@ -245,5 +364,4 @@
return $user_array;
}
-
}
Modified: trunk/logistic/inc/class.uiproject.inc.php
===================================================================
--- trunk/logistic/inc/class.uiproject.inc.php 2012-09-28 09:22:47 UTC (rev
10053)
+++ trunk/logistic/inc/class.uiproject.inc.php 2012-09-28 11:06:59 UTC (rev
10054)
@@ -45,7 +45,8 @@
'edit_project_type' => true,
'edit_project_type_name' => true,
'add' => true,
- 'edit' => true
+ 'edit' => true,
+ 'edit_something' => true
);
public function __construct()
@@ -150,44 +151,18 @@
{
array_walk(
$result_data['results'], array($this, '_add_links'), "logistic.uiproject.view");
-
//$result_data['results'], array($this, 'add_actions'), array('project'));
}
}
return $this->yui_results($result_data);
}
- public function add_actions(&$value, $key, $params)
- {
- $value['ajax'] = array();
- $value['actions'] = array();
- $value['labels'] = array();
-
- $type = $params[0];
-
- switch($type)
- {
- default:
- $value['ajax'][] = false;
- $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'logistic.uiactivity.view',
'id' => $value['id'])));
- $value['labels'][] = lang('Show
activity');
-
- $value['ajax'][] = false;
- $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'logistic.uiactivity.edit',
'id' => $value['id'])));
- $value['labels'][] = lang('Edit
activity');
-
- $value['ajax'][] = false;
- $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'logistic.uiactivity.add')));
- $value['labels'][] = lang('New
activity');
- }
- }
-
public function index()
{
if (phpgw::get_var('phpgw_return_as') == 'json')
{
return $this->query();
}
-
+// self::add_javascript('logistic', 'yahoo',
'datatable.js');
self::add_javascript('phpgwapi', 'yahoo',
'datatable.js');
phpgwapi_yui::load_widget('datatable');
phpgwapi_yui::load_widget('paginator');
@@ -224,6 +199,7 @@
),
'datatable' => array(
'source' =>
self::link(array('menuaction' => 'logistic.uiproject.index', 'phpgw_return_as'
=> 'json')),
+ 'editor_action' =>
'logistic.uiproject.edit_something',
'field' => array(
array(
'key' => 'name',
@@ -239,7 +215,8 @@
array(
'key' => 'description',
'label' =>
lang('Project description'),
- 'sortable' => false
+ 'sortable' => false,
+ 'editor' => 'new
YAHOO.widget.TextboxCellEditor({disableBtns:true})'
),
array(
'key' =>
'project_type_label',
@@ -254,9 +231,14 @@
),
);
- self::render_template_xsl(array('datatable_common'),
$data);
+ self::render_template_xsl('datatable_common', $data);
}
+ public function edit_something()
+ {
+ return 'kvittering';
+ }
+
public function project_types()
{
$GLOBALS['phpgw_info']['flags']['menu_selection'] =
"admin::logistic::project_types";
@@ -281,7 +263,6 @@
{
//list project types
$data = array(
- 'datatable_name' => lang('project
types'),
'form' => array(
'toolbar' => array(
'item' => array(
@@ -327,7 +308,7 @@
),
);
-
self::render_template_xsl(array('datatable_common'), $data);
+
self::render_template_xsl(array('project_types_datatable', 'datatable'), $data);
}
}
@@ -340,7 +321,7 @@
}
else if (isset($_POST['new_activity']))
{
- $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'logistic.uiactivity.add', 'project_id' => $project_id));
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'logistic.uiactivity.edit', 'project_id' => $project_id));
}
else
{
Modified: trunk/logistic/inc/model/class.activity.inc.php
===================================================================
--- trunk/logistic/inc/model/class.activity.inc.php 2012-09-28 09:22:47 UTC
(rev 10053)
+++ trunk/logistic/inc/model/class.activity.inc.php 2012-09-28 11:06:59 UTC
(rev 10054)
@@ -72,7 +72,7 @@
public function get_name()
{
- return $this->title;
+ return $this->name;
}
public function set_parent_id($parent_id)
@@ -163,8 +163,8 @@
{
return array(
'id' => $this->get_id(),
+ 'parent_id' =>
$this->get_parent_id(),
'name' => $this->get_name(),
- 'parent_id' =>
$this->get_parent_id(),
'project_id' =>
$this->get_project_id(),
'start_date' =>
$this->get_start_date(),
'end_date' =>
$this->get_end_date(),
Added: trunk/logistic/templates/base/activity_item.xsl
===================================================================
--- trunk/logistic/templates/base/activity_item.xsl
(rev 0)
+++ trunk/logistic/templates/base/activity_item.xsl 2012-09-28 11:06:59 UTC
(rev 10054)
@@ -0,0 +1,110 @@
+<!-- $Id:$ -->
+<!-- item -->
+
+<xsl:template match="data" xmlns:php="http://php.net/xsl">
+<xsl:variable name="date_format"><xsl:value-of
select="dateformat"/></xsl:variable>
+
+<xsl:call-template name="yui_phpgw_i18n"/>
+<div class="yui-navset yui-navset-top">
+ <div class="identifier-header">
+ <h1><img src="{img_go_home}" />
+ <xsl:value-of select="php:function('lang', 'Add
activity')" />
+ </h1>
+ </div>
+ <div class="yui-content">
+ <div id="details">
+ <form action="#" method="post">
+ <input type="hidden" name="id" value =
"{activity/id}" />
+ <input type="hidden" name="project_id"
value="{activity/project_id}" />
+
+ <dl class="proplist-col">
+ <dt>
+ <label for="name"><xsl:value-of
select="php:function('lang','Activity name')" /></label>
+ </dt>
+ <dd>
+ <xsl:choose>
+ <xsl:when test="editable">
+ <input type="text"
name="name" id="name" value="{activity/name}" size="100"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of
select="activity/name" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </dd>
+ <dt>
+ <label
for="description"><xsl:value-of select="php:function('lang', 'Description')"
/></label>
+ </dt>
+ <dd>
+ <xsl:choose>
+ <xsl:when test="editable">
+ <textarea
id="description" name="description" rows="5" cols="60"><xsl:value-of
select="activity/description" disable-output-escaping="yes"/></textarea>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of
select="activity/description" disable-output-escaping="yes"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </dd>
+ <dt>
+ <label
for="start_date">Startdato</label>
+ </dt>
+ <dd>
+ <xsl:choose>
+ <xsl:when
test="editable">
+ <input
class="date" id="start_date" name="start_date" type="text">
+ <xsl:if
test="activity/start_date != 0">
+ <xsl:attribute
name="value"><xsl:value-of select="php:function('date', $date_format,
number(activity/start_date))"/></xsl:attribute>
+ </xsl:if>
+ </input>
+ </xsl:when>
+ <xsl:otherwise>
+ <span><xsl:value-of
select="php:function('date', $date_format,
number(activity/start_date))"/></span>
+ </xsl:otherwise>
+ </xsl:choose>
+ </dd>
+ <dt>
+ <label
for="end_date">Sluttdato</label>
+ </dt>
+ <dd>
+ <xsl:choose>
+ <xsl:when
test="editable">
+ <input
class="date" id="end_date" name="end_date" type="text">
+ <xsl:if
test="activity/end_date != 0">
+ <xsl:attribute
name="value"><xsl:value-of select="php:function('date', $date_format,
number(activity/end_date))"/></xsl:attribute>
+ </xsl:if>
+ </input>
+ </xsl:when>
+ <xsl:otherwise>
+ <span><xsl:value-of
select="php:function('date', $date_format, number(activity/end_date))"/></span>
+ </xsl:otherwise>
+ </xsl:choose>
+ </dd>
+ </dl>
+
+ <div class="form-buttons">
+ <xsl:choose>
+ <xsl:when test="editable">
+ <xsl:variable
name="lang_save"><xsl:value-of select="php:function('lang', 'save')"
/></xsl:variable>
+ <xsl:variable
name="lang_cancel"><xsl:value-of select="php:function('lang', 'cancel')"
/></xsl:variable>
+ <input type="submit"
name="save_activity" value="{$lang_save}" title = "{$lang_save}" />
+ <input type="submit"
name="cancel_activity" value="{$lang_cancel}" title = "{$lang_cancel}" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable
name="lang_edit"><xsl:value-of select="php:function('lang', 'edit')"
/></xsl:variable>
+ <input type="submit"
name="edit_activity" value="{$lang_edit}" title = "{$lang_edit}" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </div>
+ </form>
+ </div>
+ </div>
+</div>
+</xsl:template>
+
+<xsl:template match="options">
+ <option value="{id}">
+ <xsl:if test="selected">
+ <xsl:attribute name="selected" value="selected" />
+ </xsl:if>
+ <xsl:value-of disable-output-escaping="yes" select="name"/>
+ </option>
+</xsl:template>
Property changes on: trunk/logistic/templates/base/activity_item.xsl
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/logistic/templates/base/css/base.css
===================================================================
--- trunk/logistic/templates/base/css/base.css 2012-09-28 09:22:47 UTC (rev
10053)
+++ trunk/logistic/templates/base/css/base.css 2012-09-28 11:06:59 UTC (rev
10054)
@@ -384,13 +384,12 @@
}
#innertoolbar-button, input[type="submit"] {
- background: none repeat scroll 0 0 #4F9AEA;
- border: 1px solid #4685C8;
- border-radius: 4px;
- color: #FFFFFF;
- cursor: pointer;
- filter:chroma(color=#000000);
- padding: 5px 20px;
+ background: none repeat scroll 0 0 #4F9AEA;
+ border: 1px solid #4685C8;
+ border-radius: 4px 4px 4px 4px;
+ color: #FFFFFF;
+ cursor: pointer;
+ padding: 3px 15px;
}
#innertoolbar-button {
@@ -913,7 +912,7 @@
input.date {
text-align: right;
- width: 65px;
+ width: 80px;
}
/* ======================================= CHECK LIST
========================================= */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [10054] Registration and editing activity,
Torstein <=