CVSROOT: /sources/phpgroupware Module name: property Changes by: Sigurd Nes <sigurdne> 07/08/10 13:41:09
Modified files: inc : class.historylog.inc.php class.sos_agreement.inc.php class.uis_agreement.inc.php setup : setup.inc.php tables_current.inc.php tables_update.inc.php templates/base : s_agreement.xsl Log message: Start making receipts on service agreements items via mobile phones (sms) CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/property/inc/class.historylog.inc.php?cvsroot=phpgroupware&r1=1.15&r2=1.16 http://cvs.savannah.gnu.org/viewcvs/property/inc/class.sos_agreement.inc.php?cvsroot=phpgroupware&r1=1.27&r2=1.28 http://cvs.savannah.gnu.org/viewcvs/property/inc/class.uis_agreement.inc.php?cvsroot=phpgroupware&r1=1.41&r2=1.42 http://cvs.savannah.gnu.org/viewcvs/property/setup/setup.inc.php?cvsroot=phpgroupware&r1=1.58&r2=1.59 http://cvs.savannah.gnu.org/viewcvs/property/setup/tables_current.inc.php?cvsroot=phpgroupware&r1=1.73&r2=1.74 http://cvs.savannah.gnu.org/viewcvs/property/setup/tables_update.inc.php?cvsroot=phpgroupware&r1=1.66&r2=1.67 http://cvs.savannah.gnu.org/viewcvs/property/templates/base/s_agreement.xsl?cvsroot=phpgroupware&r1=1.8&r2=1.9 Patches: Index: inc/class.historylog.inc.php =================================================================== RCS file: /sources/phpgroupware/property/inc/class.historylog.inc.php,v retrieving revision 1.15 retrieving revision 1.16 diff -u -b -r1.15 -r1.16 --- inc/class.historylog.inc.php 16 Mar 2007 08:57:05 -0000 1.15 +++ inc/class.historylog.inc.php 10 Aug 2007 13:41:08 -0000 1.16 @@ -24,7 +24,7 @@ * @internal Development of this application was funded by http://www.bergen.kommune.no/bbb_/ekstern/ * @package property * @subpackage core - * @version $Id: class.historylog.inc.php,v 1.15 2007/03/16 08:57:05 sigurdne Exp $ + * @version $Id: class.historylog.inc.php,v 1.16 2007/08/10 13:41:08 sigurdne Exp $ */ /** @@ -37,6 +37,8 @@ var $db; var $appname; var $table; + var $attrib_id_field = ''; + var $detail_id_field = ''; var $types = array( 'C' => 'Created', 'D' => 'Deleted', @@ -85,6 +87,12 @@ break; case 'entity': $this->table='fm_entity_history'; + $this->attrib_id_field = ',history_entity_attrib_id'; + break; + case 's_agreement': + $this->table='fm_s_agreement_history'; + $this->attrib_id_field = ',history_attrib_id'; + $this->detail_id_field = ',history_detail_id'; break; } @@ -110,19 +118,13 @@ } - function add($status,$record_id,$new_value,$old_value ='',$attrib_id='', $date='') - { - - if($attrib_id) + function add($status,$record_id,$new_value,$old_value ='',$attrib_id='', $date='',$detail_id='') { - $attrib_id_field = ',history_entity_attrib_id'; - $attrib_id_value = ",$attrib_id"; - } - else - { - $attrib_id_field = ''; - $attrib_id_value = ''; - } +_debug_array($detail_id); + $attrib_id_field = $this->attrib_id_field; + $attrib_id_value = (isset($attrib_id) && $attrib_id ? ",$attrib_id" : ''); + $detail_id_field = $this->detail_id_field; + $detail_id_value = (isset($detail_id) && $detail_id ? ",$detail_id" : ''); if($date) { @@ -134,11 +136,11 @@ } $this->db->query("insert into $this->table (history_record_id," - . "history_appname,history_owner,history_status,history_new_value,history_timestamp $attrib_id_field) " + . "history_appname,history_owner,history_status,history_new_value,history_timestamp $attrib_id_field $detail_id_field) " . "values ('$record_id','" . $this->appname . "','" . $this->account . "','$status','" . $this->db->db_addslashes($new_value) . "','" . $timestamp - . "' $attrib_id_value )",__LINE__,__FILE__); + . "' $attrib_id_value $detail_id_value)",__LINE__,__FILE__); } // array $filter_out Index: inc/class.sos_agreement.inc.php =================================================================== RCS file: /sources/phpgroupware/property/inc/class.sos_agreement.inc.php,v retrieving revision 1.27 retrieving revision 1.28 diff -u -b -r1.27 -r1.28 --- inc/class.sos_agreement.inc.php 26 Jan 2007 14:53:47 -0000 1.27 +++ inc/class.sos_agreement.inc.php 10 Aug 2007 13:41:08 -0000 1.28 @@ -24,7 +24,7 @@ * @internal Development of this application was funded by http://www.bergen.kommune.no/bbb_/ekstern/ * @package property * @subpackage agreement - * @version $Id: class.sos_agreement.inc.php,v 1.27 2007/01/26 14:53:47 sigurdne Exp $ + * @version $Id: class.sos_agreement.inc.php,v 1.28 2007/08/10 13:41:08 sigurdne Exp $ */ /** @@ -615,7 +615,8 @@ 'name' => $this->db->f('column_name'), 'input_text' => stripslashes($this->db->f('input_text')), 'statustext' => stripslashes($this->db->f('statustext')), - 'datatype' => $this->db->f('datatype') + 'datatype' => $this->db->f('datatype'), + 'history' => $this->db->f('history') ); } @@ -747,8 +748,18 @@ { if($entry['value']) { + if($entry['datatype'] == 'C' || $entry['datatype'] == 'T' || $entry['datatype'] == 'V') + { + $entry['value'] = $this->db->db_addslashes($entry['value']); + } + $cols[] = $entry['name']; $vals[] = $entry['value']; + + if($entry['history'] == 1) + { + $history_set[$entry['attrib_id']] = $entry['value']; + } } } } @@ -798,6 +809,19 @@ $receipt['message'][] = array('msg'=>lang('s_agreement %1 has been saved',$receipt['s_agreement_id'])); +//---------- History + + if (isset($history_set) AND is_array($history_set)) + { + $historylog = CreateObject($this->currentapp.'.historylog','s_agreement'); + while (list($attrib_id,$new_value) = each($history_set)) + { + $historylog->add('SO',$values['s_agreement_id'],$new_value,False, $attrib_id,false,$id); + } + } + +//---------- + $this->db->transaction_commit(); return $receipt; } @@ -850,7 +874,7 @@ function edit_item($values,$values_attribute='') { -//_debug_array($values); +_debug_array($values); //_debug_array($values_attribute); $table = 'fm_s_agreement_detail'; @@ -865,9 +889,27 @@ { if($entry['datatype']!='AB' && $entry['datatype']!='VENDOR') { + if($entry['datatype'] == 'C' || $entry['datatype'] == 'T' || $entry['datatype'] == 'V') + { + $entry['value'] = $this->db->db_addslashes($entry['value']); + } + else + { $value_set[$entry['name']] = $entry['value']; } } + if($entry['history'] == 1) + { + $this->db->query("SELECT " . $entry['name'] . " from $table WHERE agreement_id= " . $values['s_agreement_id'] . " AND id=" . $values['id'],__LINE__,__FILE__); + $this->db->next_record(); + $old_value = $this->db->f($entry['name']); + if($entry['value'] != $old_value) + { + $history_set[$entry['attrib_id']] = array('value' => $entry['value'], + 'date' => $this->bocommon->date_to_timestamp($entry['date'])); + } + } + } } if($values['street_name']) @@ -895,9 +937,19 @@ $this->db->query("UPDATE fm_s_agreement_pricing set cost = this_index *" . $this->floatval($values['cost']) . " WHERE agreement_id=" . intval($values['s_agreement_id']) . ' AND item_id=' . intval($values['id'])); + if (isset($history_set) AND is_array($history_set)) + { + $historylog = CreateObject($this->currentapp.'.historylog','s_agreement'); + while (list($attrib_id,$history) = each($history_set)) + { + $historylog->add('SO',$values['s_agreement_id'],$history['value'],False, $attrib_id,$history['date'],$values['id']); + } + } + $receipt['s_agreement_id']= $values['s_agreement_id']; $receipt['id']= $values['id']; $receipt['message'][] = array('msg'=>lang('s_agreement %1 has been edited',$values['s_agreement_id'])); + return $receipt; } @@ -1096,6 +1148,7 @@ $attrib['lookup_form'] = $this->db->f('lookup_form'); $attrib['list'] = $this->db->f('list'); $attrib['search'] = $this->db->f('search'); + $attrib['history'] = $this->db->f('history'); if($this->db->f('datatype')=='R' || $this->db->f('datatype')=='CH' || $this->db->f('datatype')=='LB') { $attrib['choice'] = $this->read_attrib_choice($id); @@ -1178,6 +1231,7 @@ $attrib['lookup_form'], $attrib['search'], $attrib['list'], + $attrib['history'], $attrib_sort, $attrib['column_info']['type'], $attrib['column_info']['precision'], @@ -1190,7 +1244,7 @@ $this->db->transaction_begin(); - $this->db->query("INSERT INTO $attribute_table (attrib_detail,id,column_name, input_text, statustext,lookup_form,search,list,attrib_sort,datatype,precision_,scale,default_value,nullable) " + $this->db->query("INSERT INTO $attribute_table (attrib_detail,id,column_name, input_text, statustext,lookup_form,search,list,history,attrib_sort,datatype,precision_,scale,default_value,nullable) " . "VALUES ($values)"); $receipt['id']= $attrib['id']; @@ -1399,6 +1453,7 @@ 'statustext' => $attrib['statustext'], 'search' => $attrib['search'], 'list' => $attrib['list'], + 'history' => $attrib['history'], ); $value_set = $this->bocommon->validate_db_update($value_set); Index: inc/class.uis_agreement.inc.php =================================================================== RCS file: /sources/phpgroupware/property/inc/class.uis_agreement.inc.php,v retrieving revision 1.41 retrieving revision 1.42 diff -u -b -r1.41 -r1.42 --- inc/class.uis_agreement.inc.php 8 Jun 2007 09:07:30 -0000 1.41 +++ inc/class.uis_agreement.inc.php 10 Aug 2007 13:41:08 -0000 1.42 @@ -24,7 +24,7 @@ * @internal Development of this application was funded by http://www.bergen.kommune.no/bbb_/ekstern/ * @package property * @subpackage agreement - * @version $Id: class.uis_agreement.inc.php,v 1.41 2007/06/08 09:07:30 sigurdne Exp $ + * @version $Id: class.uis_agreement.inc.php,v 1.42 2007/08/10 13:41:08 sigurdne Exp $ */ /** @@ -1025,7 +1025,6 @@ $s_agreement = $this->bo->read_single(array('s_agreement_id'=>$s_agreement_id)); $values = $this->bo->read_single_item(array('s_agreement_id'=>$s_agreement_id,'id'=>$id)); - $link_data = array ( 'menuaction' => $this->currentapp.'.uis_agreement.edit_item', @@ -1119,6 +1118,24 @@ 'entity_data' => $values['p'] )); + for ($i=0;$i<count($values['attributes']);$i++) + { + if($values['attributes'][$i]['history']==1) + { + $link_history_data = array + ( + 'menuaction' => $this->currentapp.'.uis_agreement.attrib_history', + 's_agreement_id' => $s_agreement_id, + 'attrib_id' => $values['attributes'][$i]['attrib_id'], + 'item_id' => $id, + 'edit' => True + ); + + $values['attributes'][$i]['link_history']=$GLOBALS['phpgw']->link('/index.php',$link_history_data); + } + } + + $GLOBALS['phpgw']->js->validate_file('overlib','overlib',$this->currentapp); $GLOBALS['phpgw']->js->validate_file('core','check',$this->currentapp); $GLOBALS['phpgw']->js->validate_file('dateformat','dateformat',$this->currentapp); @@ -1762,6 +1779,10 @@ 'value_search' => $values['search'], 'lang_include_search' => lang('Include in search'), 'lang_include_search_statustext' => lang('check to show this attribute in location list'), + + 'value_history' => $values['history'], + 'lang_history' => lang('history'), + 'lang_history_statustext' => lang('Enable history for this attribute'), ); //html_print_r($data); Index: setup/setup.inc.php =================================================================== RCS file: /sources/phpgroupware/property/setup/setup.inc.php,v retrieving revision 1.58 retrieving revision 1.59 diff -u -b -r1.58 -r1.59 --- setup/setup.inc.php 16 Mar 2007 14:14:56 -0000 1.58 +++ setup/setup.inc.php 10 Aug 2007 13:41:08 -0000 1.59 @@ -8,12 +8,12 @@ * @internal Development of this application was funded by http://www.bergen.kommune.no/bbb_/ekstern/ * @package property * @subpackage setup - * @version $Id: setup.inc.php,v 1.58 2007/03/16 14:14:56 sigurdne Exp $ + * @version $Id: setup.inc.php,v 1.59 2007/08/10 13:41:08 sigurdne Exp $ */ $setup_info['property']['name'] = 'property'; $setup_info['property']['title'] = 'Property'; - $setup_info['property']['version'] = '0.9.17.537'; + $setup_info['property']['version'] = '0.9.17.538'; $setup_info['property']['app_order'] = 8; $setup_info['property']['enable'] = 1; $setup_info['property']['app_group'] = 'office'; @@ -182,6 +182,7 @@ 'fm_s_agreement_choice', 'fm_s_agreement_detail', 'fm_s_agreement_pricing', + 'fm_s_agreement_history', 'fm_async_method', 'fm_cron_log', 'fm_origin', Index: setup/tables_current.inc.php =================================================================== RCS file: /sources/phpgroupware/property/setup/tables_current.inc.php,v retrieving revision 1.73 retrieving revision 1.74 diff -u -b -r1.73 -r1.74 --- setup/tables_current.inc.php 2 Jan 2007 14:43:03 -0000 1.73 +++ setup/tables_current.inc.php 10 Aug 2007 13:41:08 -0000 1.74 @@ -8,7 +8,7 @@ * @internal Development of this application was funded by http://www.bergen.kommune.no/bbb_/ekstern/ * @package property * @subpackage setup - * @version $Id: tables_current.inc.php,v 1.73 2007/01/02 14:43:03 sigurdne Exp $ + * @version $Id: tables_current.inc.php,v 1.74 2007/08/10 13:41:08 sigurdne Exp $ */ $phpgw_baseline = array( @@ -1843,7 +1843,8 @@ 'scale' => array('type' => 'int', 'precision' => 4,'nullable' => True), 'default_value' => array('type' => 'varchar', 'precision' => 18,'nullable' => True), 'nullable' => array('type' => 'varchar', 'precision' => 5,'nullable' => False,'default' => 'True'), - 'search' => array('type' => 'int', 'precision' => 2,'nullable' => True) + 'search' => array('type' => 'int', 'precision' => 2,'nullable' => True), + 'history' => array('type' => 'int','precision' => '2','nullable' => True) ), 'pk' => array('id','attrib_detail'), 'fk' => array(), @@ -1916,6 +1917,25 @@ 'ix' => array(), 'uc' => array() ), + + 'fm_s_agreement_history' => array( + 'fd' => array( + 'history_id' => array('type' => 'auto','precision' => '4','nullable' => False), + 'history_record_id' => array('type' => 'int','precision' => '4','nullable' => False), + 'history_appname' => array('type' => 'varchar','precision' => '64','nullable' => False), + 'history_detail_id' => array('type' => 'int','precision' => '4','nullable' => False), + 'history_attrib_id' => array('type' => 'int','precision' => '4','nullable' => False), + 'history_owner' => array('type' => 'int','precision' => '4','nullable' => False), + 'history_status' => array('type' => 'char','precision' => '2','nullable' => False), + 'history_new_value' => array('type' => 'text','nullable' => False), + 'history_timestamp' => array('type' => 'timestamp','nullable' => False,'default' => 'current_timestamp') + ), + 'pk' => array('history_id'), + 'fk' => array(), + 'ix' => array(), + 'uc' => array() + ), + 'fm_async_method' => array( 'fd' => array( 'id' => array('type' => 'int','precision' => '4','nullable' => False), Index: setup/tables_update.inc.php =================================================================== RCS file: /sources/phpgroupware/property/setup/tables_update.inc.php,v retrieving revision 1.66 retrieving revision 1.67 diff -u -b -r1.66 -r1.67 --- setup/tables_update.inc.php 16 Mar 2007 14:14:56 -0000 1.66 +++ setup/tables_update.inc.php 10 Aug 2007 13:41:08 -0000 1.67 @@ -8,7 +8,7 @@ * @internal Development of this application was funded by http://www.bergen.kommune.no/bbb_/ekstern/ * @package property * @subpackage setup - * @version $Id: tables_update.inc.php,v 1.66 2007/03/16 14:14:56 sigurdne Exp $ + * @version $Id: tables_update.inc.php,v 1.67 2007/08/10 13:41:08 sigurdne Exp $ */ /** @@ -1777,3 +1777,42 @@ return $GLOBALS['setup_info']['property']['currentver']; } } \ No newline at end of file + + /** + * Update property version from 0.9.17.537 to 0.9.17.538 + */ + + $test[] = '0.9.17.537'; + function property_upgrade0_9_17_537() + { + $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin(); + + + $GLOBALS['phpgw_setup']->oProc->AddColumn('fm_s_agreement_attribute','history',array('type' => 'int','precision' => 2,'nullable' => True)); + + $GLOBALS['phpgw_setup']->oProc->CreateTable( + 'fm_s_agreement_history', array( + 'fd' => array( + 'history_id' => array('type' => 'auto','precision' => '4','nullable' => False), + 'history_record_id' => array('type' => 'int','precision' => '4','nullable' => False), + 'history_appname' => array('type' => 'varchar','precision' => '64','nullable' => False), + 'history_detail_id' => array('type' => 'int','precision' => '4','nullable' => False), + 'history_attrib_id' => array('type' => 'int','precision' => '4','nullable' => False), + 'history_owner' => array('type' => 'int','precision' => '4','nullable' => False), + 'history_status' => array('type' => 'char','precision' => '2','nullable' => False), + 'history_new_value' => array('type' => 'text','nullable' => False), + 'history_timestamp' => array('type' => 'timestamp','nullable' => False,'default' => 'current_timestamp') + ), + 'pk' => array('history_id'), + 'fk' => array(), + 'ix' => array(), + 'uc' => array() + ) + ); + + if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit()) + { + $GLOBALS['setup_info']['property']['currentver'] = '0.9.17.538'; + return $GLOBALS['setup_info']['property']['currentver']; + } + } Index: templates/base/s_agreement.xsl =================================================================== RCS file: /sources/phpgroupware/property/templates/base/s_agreement.xsl,v retrieving revision 1.8 retrieving revision 1.9 diff -u -b -r1.8 -r1.9 --- templates/base/s_agreement.xsl 5 Jan 2007 12:54:40 -0000 1.8 +++ templates/base/s_agreement.xsl 10 Aug 2007 13:41:09 -0000 1.9 @@ -1365,6 +1365,34 @@ </xsl:choose> </td> </tr> + <tr> + <td> + <xsl:value-of select="lang_history"/> + </td> + <td> + <xsl:choose> + <xsl:when test="value_history = 1"> + <input type="checkbox" name="values[history]" value="1" checked="checked" onMouseout="window.status='';return true;"> + <xsl:attribute name="onMouseover"> + <xsl:text>window.status='</xsl:text> + <xsl:value-of select="lang_history_statustext"/> + <xsl:text>'; return true;</xsl:text> + </xsl:attribute> + </input> + </xsl:when> + <xsl:otherwise> + <input type="checkbox" name="values[history]" value="1" onMouseout="window.status='';return true;"> + <xsl:attribute name="onMouseover"> + <xsl:text>window.status='</xsl:text> + <xsl:value-of select="lang_history_statustext"/> + <xsl:text>'; return true;</xsl:text> + </xsl:attribute> + </input> + </xsl:otherwise> + </xsl:choose> + </td> + </tr> + <xsl:choose> <xsl:when test="multiple_choice != ''"> <tr> _______________________________________________ phpGroupWare-cvs mailing list phpGroupWare-cvs@gnu.org http://lists.gnu.org/mailman/listinfo/phpgroupware-cvs