[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [12089] property: refine actual cost at tickets
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [12089] property: refine actual cost at tickets |
Date: |
Fri, 12 Sep 2014 13:57:34 +0000 |
Revision: 12089
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=12089
Author: sigurdne
Date: 2014-09-12 13:57:32 +0000 (Fri, 12 Sep 2014)
Log Message:
-----------
property: refine actual cost at tickets
Modified Paths:
--------------
trunk/property/inc/class.botts.inc.php
trunk/property/inc/class.sotts.inc.php
trunk/property/inc/class.uitts.inc.php
trunk/property/js/yahoo/tts.view.js
trunk/property/setup/setup.inc.php
trunk/property/setup/tables_current.inc.php
trunk/property/setup/tables_update.inc.php
trunk/property/templates/base/tts.xsl
Modified: trunk/property/inc/class.botts.inc.php
===================================================================
--- trunk/property/inc/class.botts.inc.php 2014-09-10 09:40:20 UTC (rev
12088)
+++ trunk/property/inc/class.botts.inc.php 2014-09-12 13:57:32 UTC (rev
12089)
@@ -1652,4 +1652,14 @@
$values = $this->custom->prepare($values, 'property',
'.ticket', false);
return $values;
}
+
+ public function get_payments($id)
+ {
+ $payments = $this->so->get_payments($id);
+ foreach($payments as &$payment)
+ {
+ $payment['created_on_date'] =
$GLOBALS['phpgw']->common->show_date($payment['created_on'],$this->dateformat);
+ }
+ return $payments;
+ }
}
Modified: trunk/property/inc/class.sotts.inc.php
===================================================================
--- trunk/property/inc/class.sotts.inc.php 2014-09-10 09:40:20 UTC (rev
12088)
+++ trunk/property/inc/class.sotts.inc.php 2014-09-12 13:57:32 UTC (rev
12089)
@@ -1083,7 +1083,6 @@
// $old_billable_rate = $this->db->f('billable_rate');
$old_subject =
$this->db->f('subject');
$old_contact_id =
$this->db->f('contact_id');
- $old_actual_cost =
$this->db->f('actual_cost');
$old_order_cat_id =
$this->db->f('order_cat_id');
$old_building_part =
$this->db->f('building_part',true);
$old_order_dim1 =
(int)$this->db->f('order_dim1');
@@ -1432,11 +1431,31 @@
if($order_add || $order_edit)
{
- if ((int)$old_actual_cost !=
(int)$ticket['actual_cost'])
+ if ((int)$ticket['actual_cost'])
{
- $this->db->query("UPDATE fm_tts_tickets
SET actual_cost='" . (float)$ticket['actual_cost']
+
+ $this->db->query("SELECT sum(amount) AS
actual_cost FROM fm_tts_payments WHERE ticket_id = {$id}", __LINE__,__FILE__);
+ $this->db->next_record();
+ $old_actual_cost =
$this->db->f('actual_cost');
+ $new_actual_cost = $old_actual_cost +
$ticket['actual_cost'];
+
+ $this->db->query("UPDATE fm_tts_tickets
SET actual_cost='" . (float) $new_actual_cost
. "' WHERE
id='$id'",__LINE__,__FILE__);
-
$this->historylog->add('AC',$id,(float)$ticket['actual_cost'] ,
$old_actual_cost);
+
+ $value_set_cost = array
+ (
+ 'ticket_id' => $id,
+ 'amount' =>
$ticket['actual_cost'],
+ 'period' =>
$ticket['actual_cost_period'],
+ 'created_on'=> time(),
+ 'created_by'=> $this->account
+ );
+
+ $cols_cost = implode(',',
array_keys($value_set_cost));
+ $values_cost =
$this->db->validate_insert(array_values($value_set_cost));
+ $this->db->query("INSERT INTO
fm_tts_payments ({$cols_cost}) VALUES ({$values_cost})");
+
+
$this->historylog->add('AC',$id,(float)$new_actual_cost , $old_actual_cost);
$receipt['message'][]= array('msg' =>
lang('actual cost has been updated'));
}
@@ -1693,4 +1712,29 @@
return $values;
}
+
+ public function get_payments($id)
+ {
+ $id = (int) $id;
+ $values = array();
+ $sql = "SELECT * FROM fm_tts_payments WHERE ticket_id =
{$id} ORDER BY period ASC";
+
+ $this->db->query($sql, __LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $values[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'ticket_id' =>
$this->db->f('ticket_id'),
+ 'amount' =>
$this->db->f('amount'),
+ 'period' =>
$this->db->f('period'),
+ 'created_on'=>
$this->db->f('created_on'),
+ 'created_by'=>
$this->db->f('created_by'),
+ 'remark' =>
$this->db->f('remark', true)
+ );
+ }
+ return $values;
+ }
+
}
Modified: trunk/property/inc/class.uitts.inc.php
===================================================================
--- trunk/property/inc/class.uitts.inc.php 2014-09-10 09:40:20 UTC (rev
12088)
+++ trunk/property/inc/class.uitts.inc.php 2014-09-12 13:57:32 UTC (rev
12089)
@@ -3218,7 +3218,27 @@
'footer'
=> 0
);
+ $myColumnDefs[4] = array
+ (
+ 'name' => "4",
+ 'values' =>
json_encode(array( array('key' =>
'period','label'=>lang('period'),'sortable'=>true,'resizeable'=>true),
+
array('key' =>
'amount','label'=>lang('amount'),'sortable'=>true,'resizeable'=>true,
'formatter'=> 'FormatterAmount2')))
+ );
+ $payments = $this->bo->get_payments($id);
+
+ $datavalues[4] = array
+ (
+ 'name'
=> "4",
+ 'values'
=> json_encode($payments),
+ 'total_records' =>
count($payments),
+ 'permission' => "''",
+ 'is_paginator' => 1,
+ 'edit_action' => "''",
+ 'footer'
=> 0
+ );
+
+
$location_id =
$GLOBALS['phpgw']->locations->get_id('property', $this->acl_location);
$notify_info =
execMethod('property.notify.get_yui_table_def',array
(
@@ -3318,6 +3338,8 @@
'value_budget'
=> $ticket['budget'],
'value_actual_cost'
=> $ticket['actual_cost'],
'year_list'
=> array('options' => $this->bocommon->select_list(
$ticket['actual_cost_year'] ? $ticket['actual_cost_year'] : date('Y'),
$year_list )),
+ 'period_list'
=> array('options' => execMethod('property.boinvoice.period_list',
date('Ym'))),
+
'need_approval'
=> $need_approval,
'value_approval_mail_address' =>
$supervisor_email,
// 'vendor_email'
=> $vendor_email,
Modified: trunk/property/js/yahoo/tts.view.js
===================================================================
--- trunk/property/js/yahoo/tts.view.js 2014-09-10 09:40:20 UTC (rev 12088)
+++ trunk/property/js/yahoo/tts.view.js 2014-09-12 13:57:32 UTC (rev 12089)
@@ -2,20 +2,55 @@
var myPaginator_1, myDataTable_1;
var myPaginator_2, myDataTable_2;
var myPaginator_3, myDataTable_3;
+var myPaginator_4, myDataTable_4;
+var myPaginator_5, myDataTable_5;
var d;
var vendor_id = 0;
/********************************************************************************/
this.myParticularRenderEvent = function()
{
+ this.addFooterDatatable(myPaginator_4,myDataTable_4);
}
+this.addFooterDatatable = function(paginator,datatable)
+{
+ //call getSumPerPage(name of column) in property.js
+ tmp_sum1 = getTotalSum('amount',2,paginator,datatable);
+
+ if(typeof(tableYUI)=='undefined')
+ {
+ tableYUI =
YAHOO.util.Dom.getElementsByClassName("yui-dt-data","tbody")[2].parentNode;
+ tableYUI.setAttribute("id","tableYUI");
+ }
+ else
+ {
+ tableYUI.deleteTFoot();
+ }
+
+ //Create ROW
+ newTR = document.createElement('tr');
+
+ td_sum('Sum');
+ td_sum(tmp_sum1);
+
+ myfoot = tableYUI.createTFoot();
+ myfoot.setAttribute("id","myfoot");
+ myfoot.appendChild(newTR);
+}
+
/********************************************************************************/
var FormatterCenter = function(elCell, oRecord, oColumn, oData)
{
elCell.innerHTML = "<center>"+oData+"</center>";
}
+var FormatterAmount2 = function(elCell, oRecord, oColumn, oData)
+{
+ var amount = YAHOO.util.Number.format(oData, {decimalPlaces:2,
decimalSeparator:",", thousandsSeparator:" "});
+ elCell.innerHTML = "<div align=\"right\">"+amount+"</div>";
+}
+
/********************************************************************************/
this.confirm_session = function(action)
Modified: trunk/property/setup/setup.inc.php
===================================================================
--- trunk/property/setup/setup.inc.php 2014-09-10 09:40:20 UTC (rev 12088)
+++ trunk/property/setup/setup.inc.php 2014-09-12 13:57:32 UTC (rev 12089)
@@ -12,7 +12,7 @@
*/
$setup_info['property']['name'] = 'property';
- $setup_info['property']['version'] = '0.9.17.684';
+ $setup_info['property']['version'] = '0.9.17.685';
$setup_info['property']['app_order'] = 8;
$setup_info['property']['enable'] = 1;
$setup_info['property']['app_group'] = 'office';
@@ -140,6 +140,7 @@
'fm_tts_tickets',
'fm_tts_history',
'fm_tts_views',
+ 'fm_tts_payments',
'fm_org_unit',
'fm_ecoart',
'fm_ecoavvik',
Modified: trunk/property/setup/tables_current.inc.php
===================================================================
--- trunk/property/setup/tables_current.inc.php 2014-09-10 09:40:20 UTC (rev
12088)
+++ trunk/property/setup/tables_current.inc.php 2014-09-12 13:57:32 UTC (rev
12089)
@@ -1086,6 +1086,21 @@
'fk' => array(),
'uc' => array()
),
+ 'fm_tts_payments' => array(
+ 'fd' => array(
+ 'id' => array('type' => 'auto','nullable' =>
False),
+ 'ticket_id' => array('type' =>
'int','precision' => '4','nullable' => False),
+ 'amount' => array('type' =>
'decimal','precision' => '20','scale' => '2','default' => '0','nullable' =>
false),
+ 'period' => array('type' => 'int','precision'
=> '4','nullable' => false),
+ 'remark' => array('type' => 'text','nullable'
=> true),
+ 'created_on' => array('type' => 'int',
'precision' => 4,'nullable' => true),
+ 'created_by' => array('type' => 'int',
'precision' => 4,'nullable' => true),
+ ),
+ 'pk' => array('id'),
+ 'ix' => array(),
+ 'fk' => array('fm_tts_tickets' => array('ticket_id' =>
'id')),
+ 'uc' => array()
+ ),
'fm_org_unit' => array(
'fd' => array(
'id' => array('type' => 'int','precision' =>
'4','nullable' => False),
Modified: trunk/property/setup/tables_update.inc.php
===================================================================
--- trunk/property/setup/tables_update.inc.php 2014-09-10 09:40:20 UTC (rev
12088)
+++ trunk/property/setup/tables_update.inc.php 2014-09-12 13:57:32 UTC (rev
12089)
@@ -8083,7 +8083,7 @@
}
/**
- * Update property version from 0.9.17.681 to 0.9.17.682
+ * Update property version from 0.9.17.683 to 0.9.17.684
* Add tender related dates to workorder
*/
$test[] = '0.9.17.683';
@@ -8103,3 +8103,66 @@
return $GLOBALS['setup_info']['property']['currentver'];
}
}
+
+ /**
+ * Update property version from 0.9.17.684 to 0.9.17.685
+ * Add tender related dates to workorder
+ */
+ $test[] = '0.9.17.684';
+ function property_upgrade0_9_17_684()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+ $GLOBALS['phpgw_setup']->oProc->CreateTable(
+ 'fm_tts_payments', array(
+ 'fd' => array(
+ 'id' => array('type' =>
'auto','nullable' => False),
+ 'ticket_id' => array('type' =>
'int','precision' => '4','nullable' => False),
+ 'amount' => array('type' =>
'decimal','precision' => '20','scale' => '2','default' => '0','nullable' =>
false),
+ 'period' => array('type' =>
'int','precision' => '4','nullable' => false),
+ 'remark' => array('type' =>
'text','nullable' => true),
+ 'created_on' => array('type' => 'int',
'precision' => 4,'nullable' => true),
+ 'created_by' => array('type' => 'int',
'precision' => 4,'nullable' => true),
+ ),
+ 'pk' => array('id'),
+ 'ix' => array(),
+ 'fk' => array('fm_tts_tickets' =>
array('ticket_id' => 'id')),
+ 'uc' => array()
+ )
+ );
+
+ $GLOBALS['phpgw_setup']->oProc->query("SELECT id, actual_cost,
modified_date FROM fm_tts_tickets WHERE actual_cost != '0.00' ORDER BY
modified_date");
+
+ $tickets = array();
+ while ($GLOBALS['phpgw_setup']->oProc->next_record())
+ {
+ $tickets[] = array
+ (
+ 'id' =>
$GLOBALS['phpgw_setup']->oProc->f('id'),
+ 'actual_cost' =>
$GLOBALS['phpgw_setup']->oProc->f('actual_cost'),
+ 'modified_date' =>
$GLOBALS['phpgw_setup']->oProc->f('modified_date')
+ );
+ }
+
+ foreach($tickets as $ticket)
+ {
+ $period = date('Ym', $ticket['modified_date']);
+ $value_set = array
+ (
+ 'ticket_id' => $ticket['id'],
+ 'amount' => $ticket['actual_cost'],
+ 'period' => $period,
+ 'created_on'=> $ticket['modified_date']
+ );
+ $cols = implode(',', array_keys($value_set));
+ $values =
$GLOBALS['phpgw_setup']->oProc->validate_insert(array_values($value_set));
+ $sql = "INSERT INTO fm_tts_payments ({$cols}) VALUES
({$values})";
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ }
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['property']['currentver'] =
'0.9.17.685';
+ return $GLOBALS['setup_info']['property']['currentver'];
+ }
+ }
Modified: trunk/property/templates/base/tts.xsl
===================================================================
--- trunk/property/templates/base/tts.xsl 2014-09-10 09:40:20 UTC (rev
12088)
+++ trunk/property/templates/base/tts.xsl 2014-09-12 13:57:32 UTC (rev
12089)
@@ -940,29 +940,40 @@
<tr>
<td valign="top">
<label>
-
<xsl:value-of select="php:function('lang',
'actual cost')"/>
+
<xsl:value-of select="php:function('lang',
'payment')"/>
</label>
</td>
<td>
-
<input type="text" name="values[actual_cost]"
value="{value_actual_cost}">
+
<input type="text" name="values[actual_cost]">
<xsl:attribute name="title">
<xsl:value-of
select="php:function('lang', 'Enter actual cost')"/>
</xsl:attribute>
</input>
<xsl:text> </xsl:text> [ <xsl:value-of
select="currency"/> ]
-
<xsl:variable name="lang_year"><xsl:value-of
select="php:function('lang', 'year')"/></xsl:variable>
+
<xsl:variable name="lang_period"><xsl:value-of
select="php:function('lang', 'period')"/></xsl:variable>
-
<select name="values[actual_cost_year]">
+
<select name="values[actual_cost_period]">
<xsl:attribute name="title">
-
<xsl:value-of select='$lang_year'/>
+
<xsl:value-of select='$lang_period'/>
</xsl:attribute>
-
<xsl:apply-templates
select="year_list/options"/>
+
<xsl:apply-templates
select="period_list/options"/>
</select>
-
<xsl:text> </xsl:text> [ <xsl:value-of
select='$lang_year'/> ]
+
<xsl:text> </xsl:text> [ <xsl:value-of
select='$lang_period'/> ]
</td>
</tr>
<tr>
+
<td valign="top" class="th_text">
+
<label>
+
<xsl:value-of select="php:function('lang',
'actual cost')"/>
+
</label>
+
</td>
+
<td>
+
<div id="paging_4"> </div>
+
<div id="datatable-container_4"/>
+
</td>
+
</tr>
+
<tr>
<td valign="top">
<label>
<a href="javascript:template_lookup()">
@@ -1133,9 +1144,9 @@
</label>
</td>
<td>
- <div
id="paging_4"> </div>
- <div
id="datatable-container_4"/>
- <div
id="datatable-buttons_4"/>
+ <div
id="paging_5"> </div>
+ <div
id="datatable-container_5"/>
+ <div
id="datatable-buttons_5"/>
</td>
</tr>
</table>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [12089] property: refine actual cost at tickets,
Sigurd Nes <=