[20932] improvement: New field for credits

Sigurd Nes <[email protected]>
Newsgroups gmane.comp.web.phpgroupware.cvs
Message-ID <[email protected]>
Revision: 20932
          http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=20932
Author:   sigurdne
Date:     2010-01-05 21:28:41 +0000 (Tue, 05 Jan 2010)
Log Message:
-----------
improvement: New field for credits

Modified Paths:
--------------
    people/sigurdne/modules/hrm/trunk/inc/class.souser.inc.php
    people/sigurdne/modules/hrm/trunk/inc/class.uiuser.inc.php
    people/sigurdne/modules/hrm/trunk/setup/phpgw_no.lang
    people/sigurdne/modules/hrm/trunk/setup/setup.inc.php
    people/sigurdne/modules/hrm/trunk/setup/tables_current.inc.php
    people/sigurdne/modules/hrm/trunk/setup/tables_update.inc.php
    people/sigurdne/modules/hrm/trunk/templates/base/user.xsl

Modified: people/sigurdne/modules/hrm/trunk/inc/class.souser.inc.php
===================================================================
--- people/sigurdne/modules/hrm/trunk/inc/class.souser.inc.php	2010-01-05 21:27:07 UTC (rev 20931)
+++ people/sigurdne/modules/hrm/trunk/inc/class.souser.inc.php	2010-01-05 21:28:41 UTC (rev 20932)
@@ -84,6 +84,7 @@
 					'reference'		=> $this->db->f('reference', true),
 					'skill'			=> $this->db->f('skill'),
 					'place_id'		=> $this->db->f('place_id'),
+					'credits'		=> (int)$this->db->f('credits'),
 					'entry_date'	=> $this->db->f('entry_date'),
 					'owner'			=> $this->db->f('owner')
 				);
@@ -95,14 +96,7 @@
 		{
 			if(is_array($data))
 			{
-				if ($data['start'])
-				{
-					$start=$data['start'];
-				}
-				else
-				{
-					$start=0;
-				}
+				$start		= isset($data['start']) && $data['start'] ? $data['start'] : 0;
 				$query		= isset($data['query']) ? $data['query'] : '';
 				$sort		= isset($data['sort']) && $data['sort'] ? $data['sort'] : 'ASC';
 				$order		= isset($data['order']) && $data['order'] ? $data['order'] : 'category DESC, start_date';
@@ -122,7 +116,7 @@
 			}
 
 			$sql = "SELECT phpgw_hrm_training.id as training_id,phpgw_hrm_training.title as title, phpgw_hrm_training.start_date,"
-				. " phpgw_hrm_training.end_date,phpgw_hrm_training_place.name as place, phpgw_hrm_training_category.descr as category"
+				. " phpgw_hrm_training.end_date,phpgw_hrm_training_place.name as place, phpgw_hrm_training_category.descr as category, credits"
 				. " FROM phpgw_hrm_training $this->left_join phpgw_hrm_training_place on phpgw_hrm_training.place_id=phpgw_hrm_training_place.id"
 				. " $this->join phpgw_hrm_training_category ON phpgw_hrm_training.category = phpgw_hrm_training_category.id"
 				. " WHERE phpgw_hrm_training.user_id=" . intval($user_id);
@@ -140,6 +134,7 @@
 					'end_date'		=> $this->db->f('end_date'),
 					'title'			=> $this->db->f('title', true),
 					'place'			=> $this->db->f('place', true),
+					'credits'		=> (int)$this->db->f('credits'),
 					'category'		=> $this->db->f('category', true)
 				);
 
@@ -195,6 +190,7 @@
 				$values['reference'],
 				$values['skill'],
 				$values['place_id'],
+				(int)$values['credits'],
 				$values['descr'],
 				time(),
 				$this->account
@@ -202,7 +198,7 @@
 
 			$insert_values	= $this->db->validate_insert($insert_values);
 
-			$this->db->query("INSERT INTO phpgw_hrm_training (id,user_id,category,title,start_date,end_date,reference,skill,place_id,descr,entry_date,owner) "
+			$this->db->query("INSERT INTO phpgw_hrm_training (id,user_id,category,title,start_date,end_date,reference,skill,place_id,credits,descr,entry_date,owner) "
 				. "VALUES ($insert_values)",__LINE__,__FILE__);
 
 			$receipt['message'][]=array('msg'=>lang('training item has been saved'));
@@ -230,6 +226,7 @@
 			$value_set['reference']		= $this->db->db_addslashes($values['reference']);
 			$value_set['skill']			= $values['skill'];
 			$value_set['place_id']		= $values['place_id'];
+			$value_set['credits']		= (int)$values['credits'];
 
 			$value_set	= $this->db->validate_update($value_set);
 

Modified: people/sigurdne/modules/hrm/trunk/inc/class.uiuser.inc.php
===================================================================
--- people/sigurdne/modules/hrm/trunk/inc/class.uiuser.inc.php	2010-01-05 21:27:07 UTC (rev 20931)
+++ people/sigurdne/modules/hrm/trunk/inc/class.uiuser.inc.php	2010-01-05 21:28:41 UTC (rev 20932)
@@ -233,6 +233,7 @@
 				(
 					'title'			=> $entry['title'],
 					'place'			=> $entry['place'],
+					'credits'		=> $entry['credits'],
 					'start_date'		=> $entry['start_date'],
 					'end_date'		=> $entry['end_date'],
 					'category'		=> $entry['category'],
@@ -268,6 +269,17 @@
 												//		'cat_id'	=> $this->cat_id,
 														'allrows' 	=> $this->allrows)
 										)),
+				'sort_credits'		=> $this->nextmatchs->show_sort_order(array
+										(
+											'sort'	=> $this->sort,
+											'var'	=> 'phpgw_hrm_training.credits',
+											'order'	=> $this->order,
+											'extra'	=> array('menuaction'	=> 'hrm.uiuser.training',
+														'user_id'	=> $user_id,
+														'query'		=> $this->query,
+												//		'cat_id'	=> $this->cat_id,
+														'allrows' 	=> $this->allrows)
+										)),
 				'sort_start_date'	=> $this->nextmatchs->show_sort_order(array
 										(
 											'sort'	=> $this->sort,
@@ -292,6 +304,7 @@
 														'allrows' 	=> $this->allrows)
 										)),
 				'lang_category'		=> lang('category'),
+				'lang_credits'		=> lang('credits'),
 				'lang_title'		=> lang('training'),
 				'lang_start_date'	=> lang('start date'),
 				'lang_end_date'		=> lang('end date'),
@@ -517,6 +530,7 @@
 				'value_title'					=> isset($values['title']) ? $values['title'] : '',
 				'value_start_date'				=> isset($values['start_date']) ? $values['start_date'] : '',
 				'value_end_date'				=> isset($values['end_date']) ? $values['end_date'] : '',
+				'value_credits'					=> isset($values['credits']) ? $values['credits'] : 0,
 				'value_entry_date'				=> isset($values['entry_date']) ? $values['entry_date'] : '',
 				'value_reference'				=> isset($values['reference']) ? $values['reference'] : '',
 				'value_new_place_name'			=> isset($values['new_place_name']) ? $values['new_place_name'] : '',
@@ -615,6 +629,7 @@
 				'value_title'				=> $values['title'],
 				'value_start_date'			=> $values['start_date'],
 				'value_end_date'			=> $values['end_date'],
+				'value_credits'				=> isset($values['credits']) ? $values['credits'] : 0,
 				'value_entry_date'			=> $values['entry_date'],
 				'value_reference'			=> $values['reference'],
 

Modified: people/sigurdne/modules/hrm/trunk/setup/phpgw_no.lang
===================================================================
--- people/sigurdne/modules/hrm/trunk/setup/phpgw_no.lang	2010-01-05 21:27:07 UTC (rev 20931)
+++ people/sigurdne/modules/hrm/trunk/setup/phpgw_no.lang	2010-01-05 21:28:41 UTC (rev 20932)
@@ -4,6 +4,7 @@
 apply	hrm	no	bruk
 category	hrm	no	kategori
 cellular phone	hrm	no	mobiltelefon
+credits	hrm	no	Studiepoeng
 descr	hrm	no	beskrivelse
 Descr	hrm	no	Beskrivelse
 edit place	hrm	no	Rette sted

Modified: people/sigurdne/modules/hrm/trunk/setup/setup.inc.php
===================================================================
--- people/sigurdne/modules/hrm/trunk/setup/setup.inc.php	2010-01-05 21:27:07 UTC (rev 20931)
+++ people/sigurdne/modules/hrm/trunk/setup/setup.inc.php	2010-01-05 21:28:41 UTC (rev 20932)
@@ -12,7 +12,7 @@
 	*/
 
 	$setup_info['hrm']['name']      = 'hrm';
-	$setup_info['hrm']['version']   = '0.9.17.005';
+	$setup_info['hrm']['version']   = '0.9.17.006';
 	$setup_info['hrm']['app_order'] = 20;
 	$setup_info['hrm']['enable']    = 1;
 	$setup_info['hrm']['globals_checked']    = True;

Modified: people/sigurdne/modules/hrm/trunk/setup/tables_current.inc.php
===================================================================
--- people/sigurdne/modules/hrm/trunk/setup/tables_current.inc.php	2010-01-05 21:27:07 UTC (rev 20931)
+++ people/sigurdne/modules/hrm/trunk/setup/tables_current.inc.php	2010-01-05 21:28:41 UTC (rev 20932)
@@ -131,6 +131,7 @@
 				'entry_date' => array('type' => 'int','precision' => '4','nullable' => True),
 				'owner' => array('type' => 'int','precision' => '4','nullable' => True),
 				'access' => array('type' => 'varchar','precision' => '7','nullable' => True),
+				'credits' => array('type' => 'int','precision' => '4','nullable' => True),
 			),
 			'pk' => array('id','user_id'),
 			'fk' => array(),

Modified: people/sigurdne/modules/hrm/trunk/setup/tables_update.inc.php
===================================================================
--- people/sigurdne/modules/hrm/trunk/setup/tables_update.inc.php	2010-01-05 21:27:07 UTC (rev 20931)
+++ people/sigurdne/modules/hrm/trunk/setup/tables_update.inc.php	2010-01-05 21:28:41 UTC (rev 20932)
@@ -150,3 +150,19 @@
 		$GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit();
 		return $GLOBALS['setup_info']['hrm']['currentver'];
 	}
+
+	/**
+	* Update hrm version from 0.9.17.005 to 0.9.17.006
+	*/
+
+	$test[] = '0.9.17.005';
+	function hrm_upgrade0_9_17_005()
+	{
+		$GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+		$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_hrm_training','credits',array('type' => 'int','precision' => '4', 'nullable' => True));
+		if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+		{
+			$GLOBALS['setup_info']['hrm']['currentver'] = '0.9.17.006';
+			return $GLOBALS['setup_info']['hrm']['currentver'];
+		}
+	}

Modified: people/sigurdne/modules/hrm/trunk/templates/base/user.xsl
===================================================================
--- people/sigurdne/modules/hrm/trunk/templates/base/user.xsl	2010-01-05 21:27:07 UTC (rev 20931)
+++ people/sigurdne/modules/hrm/trunk/templates/base/user.xsl	2010-01-05 21:28:41 UTC (rev 20932)
@@ -172,7 +172,10 @@
 			<td class="th_text" width="10%" align="left">
 				<a href="{$sort_place}"><xsl:value-of select="lang_place"/></a>
 			</td>
-			<td class="th_text" width="10%" align="left">
+			<td class="th_text" width="10%" align="right">
+				<a href="{$sort_place}"><xsl:value-of select="lang_credits"/></a>
+			</td>
+			<td class="th_text" width="10%" align="center">
 				<a href="{$sort_start_date}"><xsl:value-of select="lang_start_date"/></a>
 			</td>
 			<td class="th_text" width="5%" align="center">
@@ -218,6 +221,9 @@
 				<td align="left">
 					<xsl:value-of select="place"/>
 				</td>
+				<td align="right">
+					<xsl:value-of select="credits"/>
+				</td>
 				<td align="center">
 					<xsl:value-of select="start_date"/>
 				</td>
@@ -278,7 +284,7 @@
 
 
 <!-- add / edit  -->
-	<xsl:template match="edit">
+	<xsl:template match="edit" xmlns:php="http://php.net/xsl">
 		<div align="left">
 		<xsl:variable name="form_action"><xsl:value-of select="form_action"/></xsl:variable>
 		<form method="post" action="{$form_action}">
@@ -370,6 +376,19 @@
 			</tr>
 			<tr>
 				<td valign="top">
+					<xsl:value-of select="php:function('lang', 'credits')" />
+				</td>
+				<td>
+					<input type="text" size="60" name="values[credits]" value="{value_credits}">
+						<xsl:attribute name="title">
+							<xsl:value-of select="php:function('lang', 'credits')" />
+						</xsl:attribute>
+					</input>
+				</td>
+			</tr>
+
+			<tr>
+				<td valign="top">
 					<xsl:value-of select="lang_reference"/>
 				</td>
 				<td>
@@ -534,7 +553,7 @@
 
 
 <!-- view  -->
-	<xsl:template match="view">
+	<xsl:template match="view" xmlns:php="http://php.net/xsl">
 		<div align="left">
 		<xsl:variable name="form_action"><xsl:value-of select="form_action"/></xsl:variable>
 		<form method="post" action="{$form_action}">
@@ -610,6 +629,18 @@
 			</tr>
 			<tr>
 				<td valign="top">
+					<xsl:value-of select="php:function('lang', 'credits')" />
+				</td>
+				<td>
+					<input type="text" size="4" value="{value_credits}" readonly="readonly">
+						<xsl:attribute name="title">
+							<xsl:value-of select="php:function('lang', 'credits')" />
+						</xsl:attribute>
+					</input>
+				</td>
+			</tr>
+			<tr>
+				<td valign="top">
 					<xsl:value-of select="lang_reference"/>
 				</td>
 				<td>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.