[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [13881] Syncromind: Merge 13815:13880 from trunk
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [13881] Syncromind: Merge 13815:13880 from trunk |
Date: |
Fri, 11 Sep 2015 10:24:36 +0000 |
Revision: 13881
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=13881
Author: sigurdne
Date: 2015-09-11 10:24:35 +0000 (Fri, 11 Sep 2015)
Log Message:
-----------
Syncromind: Merge 13815:13880 from trunk
Modified Paths:
--------------
branches/dev-syncromind/booking/inc/class.boapplication.inc.php
branches/dev-syncromind/booking/inc/class.uicommon.inc.php
branches/dev-syncromind/controller/inc/class.uicomponent.inc.php
branches/dev-syncromind/phpgwapi/templates/base/datatable_jquery.xsl
branches/dev-syncromind/property/inc/class.botts.inc.php
branches/dev-syncromind/property/inc/class.soresponsible.inc.php
branches/dev-syncromind/property/inc/class.sotts.inc.php
branches/dev-syncromind/property/inc/class.uilocation.inc.php
branches/dev-syncromind/property/inc/cron/default/import_oppdatering_av_bestilling_fra_agresso_bkb.php
branches/dev-syncromind/property/inc/custom/default/EBF_update_ticket_on_project_change.php
branches/dev-syncromind/property/templates/base/entity.xsl
branches/dev-syncromind/rental/inc/class.sobilling.inc.php
branches/dev-syncromind/rental/inc/class.socommon.inc.php
branches/dev-syncromind/rental/inc/class.socontract_price_item.inc.php
branches/dev-syncromind/rental/inc/class.soparty.inc.php
branches/dev-syncromind/rental/inc/model/class.invoice.inc.php
branches/dev-syncromind/sms/bin/default/set_workorder_status.php
Property Changed:
----------------
branches/dev-syncromind/
branches/dev-syncromind/booking/
branches/dev-syncromind/controller/
Property changes on: branches/dev-syncromind
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/stavangerkommune:12743-12875,12986
/trunk:12111-12211,12213-12246,12250-12363,12366-12405,12407-12435,12437-12462,12464-12527,12530-12602,12604-12670,12672-12683,12686-12750,12753-12785,12787-12974,12987,12989-13177,13179-13344,13346-13399,13401-13432,13434-13481,13483-13506,13542-13602,13604-13653,13656-13668,13670-13689,13691-13726,13731-13773,13775,13778-13791,13793-13800,13802-13811
+ /branches/stavangerkommune:12743-12875,12986
/trunk:12111-12211,12213-12246,12250-12363,12366-12405,12407-12435,12437-12462,12464-12527,12530-12602,12604-12670,12672-12683,12686-12750,12753-12785,12787-12974,12987,12989-13177,13179-13344,13346-13399,13401-13432,13434-13481,13483-13506,13542-13602,13604-13653,13656-13668,13670-13689,13691-13726,13731-13773,13775,13778-13791,13793-13800,13802-13811,13816-13880
Property changes on: branches/dev-syncromind/booking
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/stavangerkommune/booking:9468-12740,12743-12875,12986
/trunk/booking:12111-12211,12213-12246,12250-12363,12366-12405,12407-12435,12437-12462,12464-12527,12530-12602,12604-12670,12672-12683,12686-12750,12753-12785,12787-12974,12987,13179-13344,13434-13481,13778-13791
+ /branches/stavangerkommune/booking:9468-12740,12743-12875,12986
/trunk/booking:12111-12211,12213-12246,12250-12363,12366-12405,12407-12435,12437-12462,12464-12527,12530-12602,12604-12670,12672-12683,12686-12750,12753-12785,12787-12974,12987,13179-13344,13434-13481,13778-13791,13816-13880
Modified: branches/dev-syncromind/booking/inc/class.boapplication.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.boapplication.inc.php
2015-09-11 08:24:24 UTC (rev 13880)
+++ branches/dev-syncromind/booking/inc/class.boapplication.inc.php
2015-09-11 10:24:35 UTC (rev 13881)
@@ -56,7 +56,9 @@
$adates = implode("\n",$_adates);
- $rejected =
$this->so->get_rejected($application['id']);
+ //FIXME Sigurd 2. sept 2015: Something wrong
with this one;
+// $rejected =
$this->so->get_rejected($application['id']);
+ $rejected = array();
$rdates = "";
foreach ($rejected as $key => $date)
{
Modified: branches/dev-syncromind/booking/inc/class.uicommon.inc.php
===================================================================
--- branches/dev-syncromind/booking/inc/class.uicommon.inc.php 2015-09-11
08:24:24 UTC (rev 13880)
+++ branches/dev-syncromind/booking/inc/class.uicommon.inc.php 2015-09-11
10:24:35 UTC (rev 13881)
@@ -25,8 +25,9 @@
foreach($keys as $write_key)
{
$array_key =
$options['prefix'].$write_key.$options['suffix'];
- if(isset($array[$array_key])) {
- $result[($options['preserve_prefix'] ?
$options['prefix'] : '').$write_key.($options['preserve_suffix'] ?
$options['suffix'] : '')] = $array[$array_key];
+ if(isset($array[$array_key]))
+ {
+ $result[($options['preserve_prefix'] ?
$options['prefix'] : '').$write_key.($options['preserve_suffix'] ?
$options['suffix'] : '')] = phpgw::clean_value($array[$array_key]);
}
}
return $result;
Property changes on: branches/dev-syncromind/controller
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/stavangerkommune/controller:12743-12875,12986
/trunk/controller:12111-12211,12213-12246,12250-12363,12366-12405,12407-12435,12437-12462,12464-12527,12530-12602,12604-12670,12672-12683,12686-12750,12753-12785,12787-12974,12987,12989-13177,13179-13344,13346-13399,13401-13432,13434-13481,13483-13506,13542-13602,13604-13653,13656-13668,13670-13689,13691-13726,13728-13729,13731-13773,13802-13811
+ /branches/stavangerkommune/controller:12743-12875,12986
/trunk/controller:12111-12211,12213-12246,12250-12363,12366-12405,12407-12435,12437-12462,12464-12527,12530-12602,12604-12670,12672-12683,12686-12750,12753-12785,12787-12974,12987,12989-13177,13179-13344,13346-13399,13401-13432,13434-13481,13483-13506,13542-13602,13604-13653,13656-13668,13670-13689,13691-13726,13728-13729,13731-13773,13802-13811,13816-13880
Modified: branches/dev-syncromind/controller/inc/class.uicomponent.inc.php
===================================================================
--- branches/dev-syncromind/controller/inc/class.uicomponent.inc.php
2015-09-11 08:24:24 UTC (rev 13880)
+++ branches/dev-syncromind/controller/inc/class.uicomponent.inc.php
2015-09-11 10:24:35 UTC (rev 13881)
@@ -183,7 +183,7 @@
}
phpgwapi_jquery::load_widget('core');
- $users =
$GLOBALS['phpgw']->acl->get_user_list_right(PHPGW_ACL_EDIT, '.control');
+ $users =
$GLOBALS['phpgw']->acl->get_user_list_right(PHPGW_ACL_EDIT, '.checklist');
$user_list = array();
foreach($users as $user)
{
@@ -528,7 +528,6 @@
)
);
$components = array_merge($components,
$_components);
-
}
}
else if(!$location_id)
@@ -594,7 +593,7 @@
{
$location_id = $_component['location_id'];
$component_id = $_component['id'];
- $all_components[$component_id] = $_component;
+
$all_components["{$location_id}_{$component_id}"] = $_component;
$short_description =
$_component['short_description'];
$short_description .= ' [' .
$_component['location_name']. ']';
@@ -645,7 +644,7 @@
$year_calendar_agg
= new year_calendar_agg($control, $year,
$location_code, "VIEW_LOCATIONS_FOR_CONTROL");
$calendar_array
=
$year_calendar_agg->build_calendar($agg_open_cases_pr_month_array);
-
$components_with_calendar_array[$component_id][] = array("component" =>
$component->toArray(),
+
$components_with_calendar_array["{$location_id}_{$component_id}"][] =
array("component" => $component->toArray(),
"calendar_array" =>
$calendar_array);
}
@@ -700,12 +699,12 @@
}
if(!$found_assigned_to)
{
-
unset($all_components[$component_id]);
+
unset($all_components["{$location_id}_{$component_id}"]);
continue;
}
}
-
$components_with_calendar_array[$component_id][] = array("component" =>
$component->toArray(),
+
$components_with_calendar_array["{$location_id}_{$component_id}"][] =
array("component" => $component->toArray(),
"calendar_array" =>
$calendar_array);
}
@@ -727,11 +726,13 @@
);
$values = array();
- foreach($components_with_calendar_array as
$component_id => $entry)
+ foreach($components_with_calendar_array as $dummy =>
$entry)
{
- unset($all_components[$component_id]);
+ $location_id =
$entry[0]['component']['location_id'];
+ $component_id = $entry[0]['component']['id'];
+
+
unset($all_components["{$location_id}_{$component_id}"]);
$data = array();
- $location_id =
$entry[0]['component']['location_id'];
$component_link_data = array
(
'menuaction' =>
'property.uientity.edit',
@@ -828,10 +829,11 @@
if($all_components && count($all_components))
{
$choose_master = true;
- foreach($all_components as $component_id =>
$component)
+ foreach($all_components as $dummy => $component)
{
$data = array();
$location_id =
$component['location_id'];
+ $component_id = $component['id'];
$component_link_data = array
(
Modified: branches/dev-syncromind/phpgwapi/templates/base/datatable_jquery.xsl
===================================================================
--- branches/dev-syncromind/phpgwapi/templates/base/datatable_jquery.xsl
2015-09-11 08:24:24 UTC (rev 13880)
+++ branches/dev-syncromind/phpgwapi/templates/base/datatable_jquery.xsl
2015-09-11 10:24:35 UTC (rev 13881)
@@ -495,6 +495,11 @@
oParams.columns = null;
oParams.start = null;
oParams.draw = null;
+ var addtional_filterdata =
oTable.dataTableSettings[0]['ajax']['data'];
+ for (var attrname in
addtional_filterdata)
+ {
+ oParams[attrname] =
addtional_filterdata[attrname];
+ }
var iframe =
document.createElement('iframe');
iframe.style.height = "0px";
iframe.style.width = "0px";
Modified: branches/dev-syncromind/property/inc/class.botts.inc.php
===================================================================
--- branches/dev-syncromind/property/inc/class.botts.inc.php 2015-09-11
08:24:24 UTC (rev 13880)
+++ branches/dev-syncromind/property/inc/class.botts.inc.php 2015-09-11
10:24:35 UTC (rev 13881)
@@ -270,6 +270,12 @@
'id' => 'difference',
'name'=> lang('difference')
);
+
+ $columns['order_dim1'] = array
+ (
+ 'id' => 'order_dim1',
+ 'name'=> lang('order_dim1')
+ );
}
$columns['ecodimb'] = array
@@ -552,6 +558,12 @@
$closed_status[] = "C{$custom['id']}";
}
}
+ $order_dim1_list = $this->so->get_order_dim1();
+ $order_dim1_arr = array();
+ foreach($order_dim1_list as $_order_dim1)
+ {
+ $order_dim1_arr[$_order_dim1['id']] =
$_order_dim1['name'];
+ }
foreach ($tickets as & $ticket)
{
@@ -567,6 +579,11 @@
$ticket['subject'] =
$category_name[$ticket['cat_id']];
}
+ if($ticket['order_dim1'])
+ {
+ $ticket['order_dim1'] =
$order_dim1_arr[$ticket['order_dim1']];
+ }
+
if(!isset($account[$ticket['user_id']]))
{
$ticket['user'] =
$GLOBALS['phpgw']->accounts->id2name($ticket['user_id']);
Modified: branches/dev-syncromind/property/inc/class.soresponsible.inc.php
===================================================================
--- branches/dev-syncromind/property/inc/class.soresponsible.inc.php
2015-09-11 08:24:24 UTC (rev 13880)
+++ branches/dev-syncromind/property/inc/class.soresponsible.inc.php
2015-09-11 10:24:35 UTC (rev 13881)
@@ -441,11 +441,11 @@
/**
* get the responsibility name
*
- * @param type $id
- * @return string name
+ * @param type $id responsibility id
+ * @return string responsibility name
*/
public function get_responsibility_name($id)
- {
+ {
static $names = array();
$i = (int) $id;
@@ -453,17 +453,42 @@
{
return $names[$i];
}
-
$sql = "SELECT * FROM fm_responsibility WHERE id=
{$id}";
$this->db->query($sql, __LINE__, __FILE__);
- $this->db->next_record();
+ $this->db->next_record();
$name = $this->db->f('name', true);
$names[$i] = $name;
return $name;
}
/**
+ * get the responsibility name from role
+ *
+ * @param type $id role id
+ * @return string responsibility name
+ */
+ public function get_responsibility_name_from_role($id)
+ {
+ static $names = array();
+ $i = (int) $id;
+
+ if ($names[$i])
+ {
+ return $names[$i];
+ }
+
+ $sql = "SELECT fm_responsibility.name FROM
fm_responsibility"
+ . " {$this->join} fm_responsibility_role ON
fm_responsibility.id = fm_responsibility_role.responsibility_id"
+ . " WHERE fm_responsibility_role.id= {$id}";
+ $this->db->query($sql, __LINE__, __FILE__);
+ $this->db->next_record();
+ $name = $this->db->f('name', true);
+ $names[$i] = $name;
+ return $name;
+ }
+
+ /**
* Read single responsibility type
*
* @param integer $id ID of responsibility type
Modified: branches/dev-syncromind/property/inc/class.sotts.inc.php
===================================================================
--- branches/dev-syncromind/property/inc/class.sotts.inc.php 2015-09-11
08:24:24 UTC (rev 13880)
+++ branches/dev-syncromind/property/inc/class.sotts.inc.php 2015-09-11
10:24:35 UTC (rev 13881)
@@ -482,7 +482,7 @@
$return_fields =
"fm_tts_tickets.id,fm_tts_tickets.assignedto,fm_tts_tickets.status,fm_tts_tickets.user_id,"
.
"fm_tts_tickets.subject,fm_tts_tickets.address,fm_tts_tickets.location_code,fm_tts_tickets.priority,fm_tts_tickets.cat_id,fm_tts_tickets.group_id,"
.
"fm_tts_tickets.entry_date,fm_tts_tickets.modified_date,fm_tts_tickets.finnish_date,fm_tts_tickets.finnish_date2,fm_tts_tickets.order_id,fm_tts_tickets.vendor_id,"
- .
"fm_tts_tickets.budget,fm_tts_tickets.billable_hours,fm_district.descr as
district,fm_tts_views.id as view,fm_location1.loc1_name,fm_tts_tickets.ecodimb
{$result_order_field}";
+ .
"fm_tts_tickets.budget,fm_tts_tickets.billable_hours,fm_district.descr as
district,fm_tts_views.id as
view,fm_location1.loc1_name,fm_tts_tickets.ecodimb,fm_tts_tickets.order_dim1
{$result_order_field}";
$custom_cols = $this->custom->find('property',
'.ticket', 0, '', 'ASC', 'attrib_sort', true, true);
@@ -626,7 +626,8 @@
'estimate'
=> $this->db->f('budget'),
'new_ticket'
=> $this->db->f('view') ? false : true,
'billable_hours'
=> $this->db->f('billable_hours'),
- 'ecodimb'
=> $this->db->f('ecodimb')
+ 'ecodimb'
=> $this->db->f('ecodimb'),
+ 'order_dim1'
=> $this->db->f('order_dim1'),
);
foreach ($custom_cols as $custom_col)
Modified: branches/dev-syncromind/property/inc/class.uilocation.inc.php
===================================================================
--- branches/dev-syncromind/property/inc/class.uilocation.inc.php
2015-09-11 08:24:24 UTC (rev 13880)
+++ branches/dev-syncromind/property/inc/class.uilocation.inc.php
2015-09-11 10:24:35 UTC (rev 13881)
@@ -261,18 +261,55 @@
function download()
{
- $summary = phpgw::get_var('summary',
'bool', 'GET');
-
- if(!$summary)
+ if (!$this->acl_read)
{
- $list = $this->query();
+ $this->bocommon->no_access();
+ return;
}
- else
+
+ $download_type = phpgw::get_var('download_type');
+
+ switch($download_type)
{
- $list= $this->query_summary();
+ case 'summary':
+ $list = $this->query_summary();
+ $uicols = $this->bo->uicols;
+ break;
+ case 'responsiblility_role':
+ $user_id =
phpgw::get_var('user_id', 'int');
+ $role_id =
phpgw::get_var('role_id', 'int');
+ $type_id =
phpgw::get_var('type_id', 'int', 'GET');
+ $search =
phpgw::get_var('search');
+
+ $list =
$this->bo->get_responsible(array('user_id' => $user_id, 'role_id' =>$role_id,
'type_id'=>$type_id,'query' => $search['value'], 'allrows'=>true));
+
+ foreach($list as &$entry)
+ {
+ $entry['role_id'] = $role_id;
+ }
+
+ $uicols = $this->bo->uicols;
+
+ $uicols['name'][] =
'role_id';
+ $uicols['descr'][] =
'role_id';
+ $uicols['input_type'][] = '';
+
+ $uicols['name'][] =
'responsible_contact';
+ $uicols['descr'][] =
lang('responsible');
+ $uicols['input_type'][] = '';
+
+ $uicols['name'][] =
'contact_id';
+ $uicols['descr'][] =
'contact_id';
+ $uicols['input_type'][] = '';
+
+
+ break;
+ default:
+ $list = $this->query();
+ $uicols = $this->bo->uicols;
+ break;
}
- $uicols = $this->bo->uicols;
$this->bocommon->download($list,$uicols['name'],$uicols['descr'],$uicols['input_type']);
}
@@ -480,7 +517,7 @@
$values_combo_box[4] =
execMethod('property.sogeneric.get_list',$_role_criteria);
foreach($values_combo_box[4] as &$_role)
{
- $_role['name'] .= ':: ' .
execMethod('property.soresponsible.get_responsibility_name',$_role['id']);
+ $_role['name'] .= ':: ' .
execMethod('property.soresponsible.get_responsibility_name_from_role',$_role['id']);
}
array_unshift ($values_combo_box[4], array('id'=>'',
'name'=>lang('no role')));
$combos[] = array('type' => 'filter',
@@ -1293,6 +1330,13 @@
'entity_id'
=> $this->entity_id,
'phpgw_return_as' => 'json'
)),
+ 'download' =>
self::link(array('menuaction' => 'property.uilocation.download',
+
'type_id' => $type_id,
+
'role_id' => $role_id,
+
'export' => true,
+
'allrows' => true,
+
'download_type' => 'responsiblility_role'
+ )),
'allrows' => true,
'editor_action' => '',
'field' => array()
@@ -2519,9 +2563,11 @@
'phpgw_return_as' => 'json'
)),
'download' =>
self::link(array('menuaction' => 'property.uilocation.download',
-
'summary' => true,
-
'export' => true,
-
'allrows' => true)),
+
'summary' => true,
+
'export' => true,
+
'allrows' => true,
+
'download_type' => 'summary'
+ )),
'allrows' => true,
'editor_action' => '',
'field' => array(),
Modified:
branches/dev-syncromind/property/inc/cron/default/import_oppdatering_av_bestilling_fra_agresso_bkb.php
===================================================================
---
branches/dev-syncromind/property/inc/cron/default/import_oppdatering_av_bestilling_fra_agresso_bkb.php
2015-09-11 08:24:24 UTC (rev 13880)
+++
branches/dev-syncromind/property/inc/cron/default/import_oppdatering_av_bestilling_fra_agresso_bkb.php
2015-09-11 10:24:35 UTC (rev 13881)
@@ -141,6 +141,8 @@
{
$this->receipt['error'][] = array('msg' =>
"Arkiv katalog '{$dirname}/archive/' ikke er ikke skrivbar - kontakt
systemadminstrator for å korrigere");
}
+
+ $this->send_error_messages_as_email();
}
protected function get_files()
@@ -395,4 +397,34 @@
}
}
}
+
+ private function send_error_messages_as_email()
+ {
+ if
(!isset($GLOBALS['phpgw_info']['server']['smtp_server']) ||
!$GLOBALS['phpgw_info']['server']['smtp_server'])
+ {
+ return;
+ }
+
+ $subject = 'Feil ved oppdatering av
meldinger(bestillinger) fra Agresso';
+ $from = "Ikke svar<address@hidden>";
+ $to = "address@hidden";
+ $cc = "address@hidden";
+ if($this->receipt['error'])
+ {
+ $errors = array();
+ foreach($this->receipt['error'] as $error)
+ {
+ $errors[] = $error['msg'];
+ }
+ $body = implode("<br/>", $errors);
+ try
+ {
+ $rc = $this->send->msg('email',$to,
$subject, $body, '', $cc, '',$from,'','html');
+ }
+ catch (phpmailerException $e)
+ {
+ $this->receipt['error'][] = array('msg'
=> $e->getMessage());
+ }
+ }
+ }
}
Modified:
branches/dev-syncromind/property/inc/custom/default/EBF_update_ticket_on_project_change.php
===================================================================
---
branches/dev-syncromind/property/inc/custom/default/EBF_update_ticket_on_project_change.php
2015-09-11 08:24:24 UTC (rev 13880)
+++
branches/dev-syncromind/property/inc/custom/default/EBF_update_ticket_on_project_change.php
2015-09-11 10:24:35 UTC (rev 13881)
@@ -82,9 +82,19 @@
}
}
- $this->db->query("SELECT finnish_date, finnish_date2
FROM fm_tts_tickets WHERE id='$id'",__LINE__,__FILE__);
+ $this->db->query("SELECT status, finnish_date,
finnish_date2 FROM fm_tts_tickets WHERE id='$id'",__LINE__,__FILE__);
$this->db->next_record();
+ $status = $this->db->f('status');
+
+ /**
+ * Kun oppdatere åpne meldinger
+ */
+ if($status == 'X')
+ {
+ return;
+ }
+
$oldfinnish_date = (int)$this->db->f('finnish_date');
$oldfinnish_date2 = (int)$this->db->f('finnish_date2');
Modified: branches/dev-syncromind/property/templates/base/entity.xsl
===================================================================
--- branches/dev-syncromind/property/templates/base/entity.xsl 2015-09-11
08:24:24 UTC (rev 13880)
+++ branches/dev-syncromind/property/templates/base/entity.xsl 2015-09-11
10:24:35 UTC (rev 13881)
@@ -514,7 +514,7 @@
<script
type="text/javascript">
lookup_control_responsible = function()
{
- var oArgs =
{menuaction:'property.uilookup.phpgw_user', column:'control_responsible',
acl_app:'controller', acl_location: '.control', acl_required:4};
+ var oArgs =
{menuaction:'property.uilookup.phpgw_user', column:'control_responsible',
acl_app:'controller', acl_location: '.checklist', acl_required:4};
var requestUrl
= phpGWLink('index.php', oArgs);
TINY.box.show({iframe:requestUrl,
boxid:"frameless",width:750,height:450,fixed:false,maskid:"darkmask",maskopacity:40,
mask:true, animate:true, close: true});
}
Modified: branches/dev-syncromind/rental/inc/class.sobilling.inc.php
===================================================================
--- branches/dev-syncromind/rental/inc/class.sobilling.inc.php 2015-09-11
08:24:24 UTC (rev 13880)
+++ branches/dev-syncromind/rental/inc/class.sobilling.inc.php 2015-09-11
10:24:35 UTC (rev 13881)
@@ -305,7 +305,7 @@
foreach($contracts_to_bill as $contract_id) // Runs
through all the contracts that should be billed in this run
{
- $invoice =
rental_invoice::create_invoice($decimals, $billing->get_id(), $contract_id,
in_array($contract_id, $contracts_overriding_billing_start) ? true : false,
$bill_from_timestamp, $billing_end_timestamp, in_array($contract_id,
$contracts_bill_only_one_time) ? true : false ); // Creates an invoice of the
contract
+ $invoice =
rental_invoice::create_invoice($decimals, $billing->get_id(), $contract_id,
in_array($contract_id, $contracts_overriding_billing_start) ? true : false,
$bill_from_timestamp, $billing_end_timestamp, in_array($contract_id,
$contracts_bill_only_one_time) ? true : false, false, $billing_term ); //
Creates an invoice of the contract
if($invoice != null)
{
$total_sum += $invoice->get_total_sum();
Modified: branches/dev-syncromind/rental/inc/class.socommon.inc.php
===================================================================
--- branches/dev-syncromind/rental/inc/class.socommon.inc.php 2015-09-11
08:24:24 UTC (rev 13880)
+++ branches/dev-syncromind/rental/inc/class.socommon.inc.php 2015-09-11
10:24:35 UTC (rev 13881)
@@ -226,7 +226,23 @@
$sql_parts_filter = explode('FROM',$sql, 2);
$sql_filter = "SELECT DISTINCT
{$id_field_name_info['table']}.{$id_field_name_info['field']} AS
{$id_field_name_info['translated']}";
- $_sort_field = $this->sort_field ? $this->sort_field :
$sort_field;
+
+ if($this->sort_field)
+ {
+ if(is_array($this->sort_field))
+ {
+ $_sort_field = implode(',',
$this->sort_field);
+ }
+ else
+ {
+ $_sort_field = $this->sort_field;
+ }
+ }
+ else
+ {
+ $_sort_field = $sort_field;
+ }
+
if($_sort_field && $_sort_field !=
$id_field_name_info['translated'])
{
$sql_filter .= ",{$_sort_field}";
Modified: branches/dev-syncromind/rental/inc/class.socontract_price_item.inc.php
===================================================================
--- branches/dev-syncromind/rental/inc/class.socontract_price_item.inc.php
2015-09-11 08:24:24 UTC (rev 13880)
+++ branches/dev-syncromind/rental/inc/class.socontract_price_item.inc.php
2015-09-11 10:24:35 UTC (rev 13881)
@@ -1,374 +1,397 @@
<?php
-phpgw::import_class('rental.socommon');
+ phpgw::import_class('rental.socommon');
-class rental_socontract_price_item extends rental_socommon
-{
- protected static $so;
-
- /**
- * Get a static reference to the storage object associated with this
model object
- *
- * @return rental_socontract_price_item the storage object
- */
- public static function get_instance()
+ class rental_socontract_price_item extends rental_socommon
{
- if (self::$so == null) {
- self::$so =
CreateObject('rental.socontract_price_item');
+
+ protected static $so;
+
+ /**
+ * Get a static reference to the storage object associated with
this model object
+ *
+ * @return rental_socontract_price_item the storage object
+ */
+ public static function get_instance()
+ {
+ if(self::$so == null)
+ {
+ self::$so =
CreateObject('rental.socontract_price_item');
+ }
+ return self::$so;
}
- return self::$so;
- }
-
- protected function get_id_field_name()
- {
- return 'id';
- }
-
- protected function get_query(string $sort_field, boolean $ascending,
string $search_for, string $search_type, array $filters, boolean $return_count)
- {
- $clauses = array('1=1');
-
- //Add columns to this array to include them in the query
- $columns = array();
-
- $dir = $ascending ? 'ASC' : 'DESC';
- $order = $sort_field ? "ORDER BY
rental_contract_price_item.{$sort_field} $dir": 'ORDER BY agresso_id ASC, title
ASC';
-
- $filter_clauses = array();
-
- if(isset($filters[$this->get_id_field_name()])){
- $id =
$this->marshal($filters[$this->get_id_field_name()],'int');
- $filter_clauses[] =
"rental_contract_price_item.{$this->get_id_field_name()} = {$id}";
+
+ protected function get_id_field_name()
+ {
+ return 'id';
}
- if(isset($filters['contract_id'])){
- $id = $this->marshal($filters['contract_id'],'int');
- $filter_clauses[] = "contract_id = {$id}";
- }
- if(isset($filters['contract_ids_one_time'])){
- $billing_term_id = (int)$filters['billing_term_id'];
- $sql = "SELECT months FROM rental_billing_term WHERE id
= {$billing_term_id}";
- $result = $this->db->query($sql);
- if(!$result)
+
+ protected function get_query(string $sort_field, boolean
$ascending, string $search_for, string $search_type, array $filters, boolean
$return_count)
+ {
+ $clauses = array('1=1');
+
+ //Add columns to this array to include them in the query
+ $columns = array();
+
+ $dir = $ascending ? 'ASC' : 'DESC';
+ $order = $sort_field ? "ORDER BY
rental_contract_price_item.{$sort_field} $dir" : 'ORDER BY agresso_id ASC,
title ASC';
+
+ $filter_clauses = array();
+
+ if(isset($filters[$this->get_id_field_name()]))
{
- return;
+ $id =
$this->marshal($filters[$this->get_id_field_name()], 'int');
+ $filter_clauses[] =
"rental_contract_price_item.{$this->get_id_field_name()} = {$id}";
}
- if(!$this->db->next_record())
+ if(isset($filters['contract_id']))
{
- return;
+ $id =
$this->marshal($filters['contract_id'], 'int');
+ $filter_clauses[] = "contract_id =
{$id}";
}
- $month = (int)$filters['month'];
- $year = (int)$filters['year'];
- $months = $this->unmarshal($this->db->f('months',
true), 'int');
- $timestamp_end = strtotime("{$year}-{$month}-01"); //
The first day in the month to bill for
- if($months == 1){
- $timestamp_start = $timestamp_end; // The first
day of the period to bill for
- }else{
- $months = $months-1;
- $timestamp_start = strtotime("-{$months}
months", $timestamp_end); // The first day of the period to bill for
+ if(isset($filters['contract_ids_one_time']))
+ {
+ $billing_term_id =
(int)$filters['billing_term_id'];
+ $sql = "SELECT months FROM
rental_billing_term WHERE id = {$billing_term_id}";
+ $result =
$this->db->query($sql);
+ if(!$result)
+ {
+ return;
+ }
+ if(!$this->db->next_record())
+ {
+ return;
+ }
+ $month =
(int)$filters['month'];
+ $year =
(int)$filters['year'];
+ $months =
$this->unmarshal($this->db->f('months', true), 'int');
+ $timestamp_end =
strtotime("{$year}-{$month}-01"); // The first day in the month to bill for
+ if($months == 1)
+ {
+ $timestamp_start = $timestamp_end; //
The first day of the period to bill for
+ }
+ else
+ {
+ $months = $months - 1;
+ $timestamp_start =
strtotime("-{$months} months", $timestamp_end); // The first day of the period
to bill for
+ }
+ $timestamp_end = strtotime('+1 month',
$timestamp_end); // The first day in the month after the one to bill for
+
+ $filter_clauses[] = "is_one_time";
+ $filter_clauses[] = "date_start <
{$timestamp_end}";
+ $filter_clauses[] = "date_start >=
{$timestamp_start}";
}
- $timestamp_end = strtotime('+1 month', $timestamp_end);
// The first day in the month after the one to bill for
-
- $filter_clauses[] = "is_one_time";
- $filter_clauses[] = "date_start < {$timestamp_end}";
- $filter_clauses[] = "date_start >= {$timestamp_start}";
+ if(isset($filters['one_time']) &&
$filters['include_billed'])
+ {
+ $filter_clauses[] = "is_one_time";
+ }
+ if(isset($filters['one_time']) &&
!$filters['include_billed'])
+ {
+ $filter_clauses[] = "is_one_time AND NOT
is_billed";
+ }
+ else if($filters['include_billed'])
+ {
+ // Do not add filter on showing only price
items that has not yet been billed
+ }
+ else
+ {
+ $filter_clauses[] = "NOT is_billed";
+ }
+
+ if(count($filter_clauses))
+ {
+ $clauses[] = join(' AND ', $filter_clauses);
+ }
+
+ $condition = join(' AND ', $clauses);
+
+ if($return_count) // We should only return a count
+ {
+ $cols =
'COUNT(DISTINCT(rental_contract_price_item.id)) AS count';
+ $order = "";
+ }
+ else if(isset($filters['export']))
+ {
+ $cols = "rental_contract_price_item.id,
rental_contract_price_item.price_item_id,"
+ . " rental_contract_price_item.contract_id,
rental_contract_price_item.area, rental_contract_price_item.count,"
+ . " rental_contract_price_item.agresso_id,
rental_contract_price_item.title, rental_contract_price_item.is_area,"
+ . " rental_contract_price_item.price,
rental_contract_price_item.total_price, rental_contract_price_item.is_one_time,"
+ . " rental_contract_price_item.date_start,
rental_contract_price_item.date_end";
+ }
+ else
+ {
+ $cols = 'rental_contract_price_item.*,
rental_price_item.type';
+ }
+
+ $tables = "rental_contract_price_item";
+// $joins = "";
+ $joins = "{$this->join} rental_price_item ON
(rental_price_item.id = rental_contract_price_item.price_item_id)";
+
+ //var_dump("SELECT {$cols} FROM {$tables} {$joins}
WHERE {$condition} {$order}");
+ return "SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition} {$order}";
}
- if(isset($filters['one_time']) && $filters['include_billed'])
+
+ protected function populate(int $price_item_id, &$price_item)
{
- $filter_clauses[] = "is_one_time";
+ if($price_item == null)
+ {
+ $price_item = new
rental_contract_price_item($this->unmarshal($this->db->f('id'), 'int'));
+
$price_item->set_price_item_id($this->unmarshal($this->db->f('price_item_id'),
'int'));
+
$price_item->set_contract_id($this->unmarshal($this->db->f('contract_id'),
'int'));
+
$price_item->set_title($this->unmarshal($this->db->f('title'), 'string'));
+
$price_item->set_agresso_id($this->unmarshal($this->db->f('agresso_id'),
'string'));
+
$price_item->set_is_area($this->unmarshal($this->db->f('is_area'), 'bool'));
+
$price_item->set_is_one_time($this->unmarshal($this->db->f('is_one_time'),
'bool'));
+
$price_item->set_is_billed($this->unmarshal($this->db->f('is_billed'), 'bool'));
+
$price_item->set_price($this->unmarshal($this->db->f('price'), 'float'));
+
$price_item->set_area($this->unmarshal($this->db->f('area'), 'float'));
+
$price_item->set_count($this->unmarshal($this->db->f('count'), 'int'));
+
$price_item->set_total_price($this->unmarshal($this->db->f('total_price'),
'float'));
+
$price_item->set_date_start($this->unmarshal($this->db->f('date_start'),
'int'));
+
$price_item->set_date_end($this->unmarshal($this->db->f('date_end'), 'int'));
+ $price_type_id = (int)$this->db->f('type');
+ $price_item->set_price_type_id($price_type_id);
+
$price_item->set_price_type_title($price_type_id);
+ }
+ return $price_item;
}
- if(isset($filters['one_time']) && !$filters['include_billed'])
+
+ /**
+ * Add a new contract_price_item to the database from import.
Adds the new insert id to the object reference.
+ *
+ * @param $price_item the contract_price_item to be added
+ * @return mixed receipt from the db operation
+ */
+ public function import(&$price_item)
{
- $filter_clauses[] = "is_one_time AND NOT is_billed";
+ $price = $price_item->get_price() ?
$price_item->get_price() : 0;
+ $total_price = $price_item->get_total_price() ?
$price_item->get_total_price() : 0;
+ $rented_area = $price_item->get_area();
+
+ // Build a db-friendly array of the composite object
+ $values = array(
+ $price_item->get_price_item_id(),
+ $price_item->get_contract_id(),
+ '\'' . $price_item->get_title() . '\'',
+ '\'' . $price_item->get_agresso_id() . '\'',
+ ($price_item->is_area() ? "true" : "false"),
+ str_replace(',', '.', $price),
+ str_replace(',', '.', $rented_area),
+ str_replace(',', '.', $price_item->get_count()),
+ str_replace(',', '.', $total_price),
+ ($price_item->is_billed() ? "true" : "false")
+ );
+
+ $cols = array('price_item_id', 'contract_id', 'title',
'agresso_id', 'is_area',
+ 'price', 'area', 'count', 'total_price',
'is_billed');
+
+ if($price_item->get_date_start())
+ {
+ $values[] =
$this->marshal($price_item->get_date_start(), 'int');
+ $cols[] = 'date_start';
+ }
+
+ if($price_item->get_date_end())
+ {
+ $values[] =
$this->marshal($price_item->get_date_end(), 'int');
+ $cols[] = 'date_end';
+ }
+
+ $q = "INSERT INTO rental_contract_price_item (" .
join(',', $cols) . ") VALUES (" . join(',', $values) . ")";
+
+ $result = $this->db->query($q);
+ $receipt['id'] =
$this->db->get_last_insert_id("rental_contract_price_item", 'id');
+
+ $price_item->set_id($receipt['id']);
+
+ return $receipt;
}
- else if($filters['include_billed'])
+
+ /**
+ * Add a new contract_price_item to the database. Adds the new
insert id to the object reference.
+ *
+ * @param $price_item the contract_price_item to be added
+ * @return mixed receipt from the db operation
+ */
+ protected function add(&$price_item)
{
- // Do not add filter on showing only price items that
has not yet been billed
+ $price = $price_item->get_price() ?
$price_item->get_price() : 0;
+ $total_price = $price_item->get_total_price() ?
$price_item->get_total_price() : 0;
+ $rented_area = $price_item->get_area();
+ $contract =
rental_socontract::get_instance()->get_single($price_item->get_contract_id);
+ if($price_item->is_area())
+ {
+ $rented_area = $contract->get_rented_area();
+ if($rented_area == '')
+ {
+ $rented_area = 0;
+ }
+ $total_price = ($rented_area * $price);
+ }
+
+ // Build a db-friendly array of the composite object
+ $values = array(
+ $price_item->get_price_item_id(),
+ $price_item->get_contract_id(),
+ '\'' . $price_item->get_title() . '\'',
+ '\'' . $price_item->get_agresso_id() . '\'',
+ ($price_item->is_area() ? "true" : "false"),
+ str_replace(',', '.', $price),
+ str_replace(',', '.', $rented_area),
+ str_replace(',', '.', $price_item->get_count()),
+ str_replace(',', '.', $total_price),
+ ($price_item->is_one_time() ? "true" : "false"),
+ ($price_item->is_billed() ? "true" : "false")
+ );
+
+ $cols = array('price_item_id', 'contract_id', 'title',
'agresso_id', 'is_area',
+ 'price', 'area', 'count', 'total_price',
'is_one_time', 'is_billed');
+
+ if($price_item->get_date_start())
+ {
+ $values[] =
$this->marshal($price_item->get_date_start(), 'int');
+ $cols[] = 'date_start';
+ }
+
+ if($price_item->get_date_end())
+ {
+ $values[] =
$this->marshal($price_item->get_date_end(), 'int');
+ $cols[] = 'date_end';
+ }
+
+ $q = "INSERT INTO rental_contract_price_item (" .
join(',', $cols) . ") VALUES (" . join(',', $values) . ")";
+
+ $result = $this->db->query($q);
+ $receipt['id'] =
$this->db->get_last_insert_id("rental_contract_price_item", 'id');
+
+ $price_item->set_id($receipt['id']);
+
+ return $receipt;
}
- else
- {
- $filter_clauses[] = "NOT is_billed";
- }
-
- if(count($filter_clauses))
- {
- $clauses[] = join(' AND ', $filter_clauses);
- }
-
- $condition = join(' AND ', $clauses);
-
- if($return_count) // We should only return a count
- {
- $cols = 'COUNT(DISTINCT(rental_contract_price_item.id))
AS count';
- $order = "";
- }
- else if(isset($filters['export']))
- {
- $cols = "rental_contract_price_item.id,
rental_contract_price_item.price_item_id,"
- . " rental_contract_price_item.contract_id,
rental_contract_price_item.area, rental_contract_price_item.count,"
- . " rental_contract_price_item.agresso_id,
rental_contract_price_item.title, rental_contract_price_item.is_area,"
- . " rental_contract_price_item.price,
rental_contract_price_item.total_price, rental_contract_price_item.is_one_time,"
- . " rental_contract_price_item.date_start,
rental_contract_price_item.date_end";
- }
- else
- {
- $cols = 'rental_contract_price_item.*,
rental_price_item.type';
- }
-
- $tables = "rental_contract_price_item";
-// $joins = "";
- $joins = "{$this->join} rental_price_item ON
(rental_price_item.id = rental_contract_price_item.price_item_id)";
- //var_dump("SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition} {$order}");
- return "SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition} {$order}";
- }
-
- protected function populate(int $price_item_id, &$price_item)
- {
- if($price_item == null)
+ /**
+ * Update the database values for an existing contract price
item.
+ *
+ * @param $price_item the contract price item to be updated
+ * @return result receipt from the db operation
+ */
+ protected function update($price_item)
{
- $price_item = new
rental_contract_price_item($this->unmarshal($this->db->f('id'),'int'));
-
$price_item->set_price_item_id($this->unmarshal($this->db->f('price_item_id'),'int'));
-
$price_item->set_contract_id($this->unmarshal($this->db->f('contract_id'),'int'));
-
$price_item->set_title($this->unmarshal($this->db->f('title'),'string'));
-
$price_item->set_agresso_id($this->unmarshal($this->db->f('agresso_id'),'string'));
-
$price_item->set_is_area($this->unmarshal($this->db->f('is_area'),'bool'));
-
$price_item->set_is_one_time($this->unmarshal($this->db->f('is_one_time'),'bool'));
-
$price_item->set_is_billed($this->unmarshal($this->db->f('is_billed'),'bool'));
-
$price_item->set_price($this->unmarshal($this->db->f('price'),'float'));
-
$price_item->set_area($this->unmarshal($this->db->f('area'),'float'));
-
$price_item->set_count($this->unmarshal($this->db->f('count'),'int'));
-
$price_item->set_total_price($this->unmarshal($this->db->f('total_price'),'float'));
-
$price_item->set_date_start($this->unmarshal($this->db->f('date_start'),'int'));
-
$price_item->set_date_end($this->unmarshal($this->db->f('date_end'),'int'));
- $price_type_id = (int)$this->db->f('type');
- $price_item->set_price_type_id($price_type_id);
- $price_item->set_price_type_title($price_type_id);
- }
- return $price_item;
- }
-
- /**
- * Add a new contract_price_item to the database from import. Adds the
new insert id to the object reference.
- *
- * @param $price_item the contract_price_item to be added
- * @return mixed receipt from the db operation
- */
- public function import(&$price_item)
- {
- $price = $price_item->get_price() ? $price_item->get_price() :
0;
- $total_price = $price_item->get_total_price() ?
$price_item->get_total_price() : 0;
- $rented_area = $price_item->get_area();
+ $id = intval($price_item->get_id());
- // Build a db-friendly array of the composite object
- $values = array(
- $price_item->get_price_item_id(),
- $price_item->get_contract_id(),
- '\'' . $price_item->get_title() . '\'',
- '\'' . $price_item->get_agresso_id() . '\'',
- ($price_item->is_area() ? "true" : "false"),
- str_replace(',','.',$price),
- str_replace(',','.',$rented_area),
- str_replace(',','.',$price_item->get_count()),
- str_replace(',','.',$total_price),
- ($price_item->is_billed() ? "true" : "false")
- );
-
- $cols = array('price_item_id', 'contract_id', 'title',
'agresso_id', 'is_area', 'price', 'area', 'count', 'total_price', 'is_billed');
-
- if ($price_item->get_date_start()) {
- $values[] =
$this->marshal($price_item->get_date_start(), 'int');
- $cols[] = 'date_start';
- }
-
- if ($price_item->get_date_end()) {
- $values[] = $this->marshal($price_item->get_date_end(),
'int');
- $cols[] = 'date_end';
- }
-
- $q ="INSERT INTO rental_contract_price_item (" . join(',',
$cols) . ") VALUES (" . join(',', $values) . ")";
+ $price = $price_item->get_price() ?
$price_item->get_price() : 0;
+ //$total_price = $price_item->get_total_price() ?
$price_item->get_total_price() : 0;
+ //if($total_price == 0){
+ //}
- $result = $this->db->query($q);
- $receipt['id'] =
$this->db->get_last_insert_id("rental_contract_price_item", 'id');
-
- $price_item->set_id($receipt['id']);
-
- return $receipt;
- }
-
- /**
- * Add a new contract_price_item to the database. Adds the new insert
id to the object reference.
- *
- * @param $price_item the contract_price_item to be added
- * @return mixed receipt from the db operation
- */
- protected function add(&$price_item)
- {
- $price = $price_item->get_price() ? $price_item->get_price() :
0;
- $total_price = $price_item->get_total_price() ?
$price_item->get_total_price() : 0;
- $rented_area = $price_item->get_area();
- $contract =
rental_socontract::get_instance()->get_single($price_item->get_contract_id);
- if($price_item->is_area()){
- $rented_area = $contract->get_rented_area();
- if($rented_area == ''){
- $rented_area = 0;
+ if($price_item->is_area())
+ {
+ $total_price = $price_item->get_area() *
$price_item->get_price();
}
- $total_price = ($rented_area * $price);
- }
+ else
+ {
+ $total_price = $price_item->get_count() *
$price_item->get_price();
+ }
- // Build a db-friendly array of the composite object
- $values = array(
- $price_item->get_price_item_id(),
- $price_item->get_contract_id(),
- '\'' . $price_item->get_title() . '\'',
- '\'' . $price_item->get_agresso_id() . '\'',
- ($price_item->is_area() ? "true" : "false"),
- str_replace(',','.',$price),
- str_replace(',','.',$rented_area),
- str_replace(',','.',$price_item->get_count()),
- str_replace(',','.',$total_price),
- ($price_item->is_one_time() ? "true" : "false"),
- ($price_item->is_billed() ? "true" : "false")
- );
-
- $cols = array('price_item_id', 'contract_id', 'title',
'agresso_id', 'is_area', 'price', 'area', 'count', 'total_price',
'is_one_time', 'is_billed');
-
- if ($price_item->get_date_start()) {
- $values[] =
$this->marshal($price_item->get_date_start(), 'int');
- $cols[] = 'date_start';
- }
-
- if ($price_item->get_date_end()) {
- $values[] = $this->marshal($price_item->get_date_end(),
'int');
- $cols[] = 'date_end';
- }
-
- $q ="INSERT INTO rental_contract_price_item (" . join(',',
$cols) . ") VALUES (" . join(',', $values) . ")";
+ // Build a db-friendly array of the composite object
+ $values = array(
+ "price_item_id=" .
$price_item->get_price_item_id(),
+ "contract_id=" . $price_item->get_contract_id(),
+ "title=" . '\'' . $price_item->get_title() .
'\'',
+ "area=" . str_replace(',', '.',
$price_item->get_area()),
+ "count=" . str_replace(',', '.',
$price_item->get_count()),
+ "agresso_id=" . '\'' .
$price_item->get_agresso_id() . '\'',
+ "is_area=" . ($price_item->is_area() ? "true" :
"false"),
+ "price=" . str_replace(',', '.', $price),
+ "total_price=" . str_replace(',', '.',
$total_price),
+ "date_start=" .
$this->marshal($price_item->get_date_start(), 'int'),
+ "date_end=" .
$this->marshal($price_item->get_date_end(), 'int'),
+ "is_one_time=" .
($price_item->get_is_one_time() == "true" ? "true" : "false"),
+ "is_billed=" . ($price_item->is_billed() ?
"true" : "false")
+ );
+ $this->db->query('UPDATE rental_contract_price_item SET
' . join(',', $values) . " WHERE id=$id", __LINE__, __FILE__);
- $result = $this->db->query($q);
- $receipt['id'] =
$this->db->get_last_insert_id("rental_contract_price_item", 'id');
-
- $price_item->set_id($receipt['id']);
-
- return $receipt;
- }
-
- /**
- * Update the database values for an existing contract price item.
- *
- * @param $price_item the contract price item to be updated
- * @return result receipt from the db operation
- */
- protected function update($price_item)
- {
- $id = intval($price_item->get_id());
-
- $price = $price_item->get_price() ? $price_item->get_price() :
0;
- //$total_price = $price_item->get_total_price() ?
$price_item->get_total_price() : 0;
- //if($total_price == 0){
-
- //}
-
- if($price_item->is_area()){
- $total_price = $price_item->get_area() *
$price_item->get_price();
+ $receipt['id'] = $id;
+ $receipt['message'][] = array('msg' => lang('Entity
%1 has been updated', $entry['id']));
+ return $receipt;
}
- else{
- $total_price = $price_item->get_count() *
$price_item->get_price();
- }
- // Build a db-friendly array of the composite object
- $values = array(
- "price_item_id=" . $price_item->get_price_item_id(),
- "contract_id=" . $price_item->get_contract_id(),
- "title=" . '\'' . $price_item->get_title() . '\'',
- "area=" . str_replace(',','.',$price_item->get_area()),
- "count=" .
str_replace(',','.',$price_item->get_count()),
- "agresso_id=" . '\'' . $price_item->get_agresso_id() .
'\'',
- "is_area=" . ($price_item->is_area() ? "true" :
"false"),
- "price=" . str_replace(',','.',$price),
- "total_price=" . str_replace(',','.',$total_price),
- "date_start=" .
$this->marshal($price_item->get_date_start(), 'int'),
- "date_end=" .
$this->marshal($price_item->get_date_end(), 'int'),
- "is_one_time=" . ($price_item->get_is_one_time() ==
"true" ? "true" : "false"),
- "is_billed=" . ($price_item->is_billed() ? "true" :
"false")
- );
- $this->db->query('UPDATE rental_contract_price_item SET ' .
join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);
-
- $receipt['id'] = $id;
- $receipt['message'][] = array('msg'=>lang('Entity %1 has been
updated', $entry['id']));
- return $receipt;
- }
-
- /**
- * Select total sum of all "active" price-items on a contract.
- *
- * @param $contract_id the id of the contract to generate total price
on
- * @return total_price the total price
- */
- public function get_total_price($contract_id){
- $ts_query = strtotime(date('Y-m-d')); // timestamp for query
(today)
- //$this->db->query("SELECT sum(rcpi.total_price::numeric) AS
sum_total FROM rental_contract_price_item rcpi, rental_price_item rpi WHERE
rpi.id = rcpi.price_item_id AND NOT rpi.is_one_time AND
rcpi.contract_id={$contract_id} AND ((rcpi.date_start <= {$ts_query} AND
rcpi.date_end >= {$ts_query}) OR (rcpi.date_start <= {$ts_query} AND
(rcpi.date_end is null OR rcpi.date_end = 0)) OR (rcpi.date_start is null AND
(rcpi.date_end >= {$ts_query} OR rcpi.date_end is null)))");
+ /**
+ * Select total sum of all "active" price-items on a contract.
+ *
+ * @param $contract_id the id of the contract to generate
total price on
+ * @return total_price the total price
+ */
+ public function get_total_price($contract_id)
+ {
+ $ts_query = strtotime(date('Y-m-d')); // timestamp for
query (today)
+ //$this->db->query("SELECT
sum(rcpi.total_price::numeric) AS sum_total FROM rental_contract_price_item
rcpi, rental_price_item rpi WHERE rpi.id = rcpi.price_item_id AND NOT
rpi.is_one_time AND rcpi.contract_id={$contract_id} AND ((rcpi.date_start <=
{$ts_query} AND rcpi.date_end >= {$ts_query}) OR (rcpi.date_start <=
{$ts_query} AND (rcpi.date_end is null OR rcpi.date_end = 0)) OR
(rcpi.date_start is null AND (rcpi.date_end >= {$ts_query} OR rcpi.date_end is
null)))");
// $this->db->query("SELECT sum(total_price::numeric) AS sum_total
FROM rental_contract_price_item WHERE NOT is_one_time AND
contract_id={$contract_id}");
- $this->db->query("SELECT sum(total_price::numeric) AS sum_total
FROM rental_contract_price_item WHERE contract_id={$contract_id} AND (NOT
is_one_time OR NOT is_billed)");
- if($this->db->next_record()){
- $total_price = $this->db->f('sum_total');
- return $total_price;
+ $this->db->query("SELECT sum(total_price::numeric) AS
sum_total FROM rental_contract_price_item WHERE contract_id={$contract_id} AND
(NOT is_one_time OR NOT is_billed)");
+ if($this->db->next_record())
+ {
+ $total_price = $this->db->f('sum_total');
+ return $total_price;
+ }
}
- }
-
- /**
- * Select total sum of all "active" price-items on a contract for
invoice-generation.
- *
- * @param $contract_id the id of the contract to generate total price
on
- * @return total_price the total price
- */
- public function get_total_price_invoice($contract_id, $billing_term,
$month, $year){
- $billing_term_id = (int)$billing_term;
- $sql = "SELECT months FROM rental_billing_term WHERE id =
{$billing_term_id}";
- $result = $this->db->query($sql);
- if(!$result)
+
+ /**
+ * Select total sum of all "active" price-items on a contract
for invoice-generation.
+ *
+ * @param $contract_id the id of the contract to generate
total price on
+ * @return total_price the total price
+ */
+ public function get_total_price_invoice($contract_id,
$billing_term, $month, $year)
{
- return;
+ $billing_term_id = (int)$billing_term;
+ $sql = "SELECT months FROM
rental_billing_term WHERE id = {$billing_term_id}";
+ $result = $this->db->query($sql);
+ if(!$result)
+ {
+ return;
+ }
+ if(!$this->db->next_record())
+ {
+ return;
+ }
+ $months =
$this->unmarshal($this->db->f('months', true), 'int');
+ $timestamp_end = strtotime("{$year}-{$month}-01"); //
The first day in the month to bill for
+ if($months == 1)
+ {
+ $timestamp_start = $timestamp_end; // The first
day of the period to bill for
+ }
+ else
+ {
+ $months = $months - 1;
+ $timestamp_start = strtotime("-{$months}
months", $timestamp_end); // The first day of the period to bill for
+ }
+ $timestamp_end = strtotime('+1 month', $timestamp_end);
// The first day in the month after the one to bill for
+ //$this->db->query("SELECT
sum(rcpi.total_price::numeric) AS sum_total FROM rental_contract_price_item
rcpi, rental_price_item rpi WHERE rpi.id = rcpi.price_item_id AND NOT
rpi.is_one_time AND rcpi.contract_id={$contract_id} AND ((rcpi.date_start <=
{$ts_query} AND rcpi.date_end >= {$ts_query}) OR (rcpi.date_start <=
{$ts_query} AND (rcpi.date_end is null OR rcpi.date_end = 0)) OR
(rcpi.date_start is null AND (rcpi.date_end >= {$ts_query} OR rcpi.date_end is
null)))");
+ $q_total_price = "SELECT sum(total_price::numeric) AS
sum_total ";
+ $q_total_price .= "FROM rental_contract_price_item ";
+ $q_total_price .= "WHERE contract_id={$contract_id} ";
+ $q_total_price .= "AND NOT is_billed ";
+ $q_total_price .= "AND ((NOT date_start IS NULL AND
date_start < {$timestamp_end}) OR date_start IS NULL) ";
+ $q_total_price .= "AND ((NOT date_end IS NULL AND
date_end >= {$timestamp_start}) OR date_end IS NULL)";
+ $this->db->query($q_total_price);
+ if($this->db->next_record())
+ {
+ $total_price = $this->db->f('sum_total');
+ return $total_price;
+ }
}
- if(!$this->db->next_record())
+
+ /**
+ * Select max area of all "active" price-items on a contract.
+ *
+ * @param $contract_id the id of the contract to generate
total price on
+ * @return max_area the max area
+ */
+ public function get_max_area($contract_id)
{
- return;
+ $this->db->query("SELECT max(area) AS max_area FROM
rental_contract_price_item WHERE contract_id={$contract_id} AND is_area");
+ if($this->db->next_record())
+ {
+ $max_area = $this->db->f('max_area');
+ return $max_area;
+ }
}
- $months = $this->unmarshal($this->db->f('months', true), 'int');
- $timestamp_end = strtotime("{$year}-{$month}-01"); // The first
day in the month to bill for
- if($months == 1){
- $timestamp_start = $timestamp_end; // The first day of
the period to bill for
- }else{
- $months = $months-1;
- $timestamp_start = strtotime("-{$months} months",
$timestamp_end); // The first day of the period to bill for
- }
- $timestamp_end = strtotime('+1 month', $timestamp_end); // The
first day in the month after the one to bill for
-
- //$this->db->query("SELECT sum(rcpi.total_price::numeric) AS
sum_total FROM rental_contract_price_item rcpi, rental_price_item rpi WHERE
rpi.id = rcpi.price_item_id AND NOT rpi.is_one_time AND
rcpi.contract_id={$contract_id} AND ((rcpi.date_start <= {$ts_query} AND
rcpi.date_end >= {$ts_query}) OR (rcpi.date_start <= {$ts_query} AND
(rcpi.date_end is null OR rcpi.date_end = 0)) OR (rcpi.date_start is null AND
(rcpi.date_end >= {$ts_query} OR rcpi.date_end is null)))");
- $q_total_price = "SELECT sum(total_price::numeric) AS sum_total
";
- $q_total_price .= "FROM rental_contract_price_item ";
- $q_total_price .= "WHERE contract_id={$contract_id} ";
- $q_total_price .= "AND NOT is_billed ";
- $q_total_price .= "AND ((NOT date_start IS NULL AND date_start
< {$timestamp_end}) OR date_start IS NULL) ";
- $q_total_price .= "AND ((NOT date_end IS NULL AND date_end >=
{$timestamp_start}) OR date_end IS NULL)";
- $this->db->query($q_total_price);
- if($this->db->next_record()){
- $total_price = $this->db->f('sum_total');
- return $total_price;
- }
- }
-
- /**
- * Select max area of all "active" price-items on a contract.
- *
- * @param $contract_id the id of the contract to generate total price
on
- * @return max_area the max area
- */
- public function get_max_area($contract_id){
- $this->db->query("SELECT max(area) AS max_area FROM
rental_contract_price_item WHERE contract_id={$contract_id} AND is_area");
- if($this->db->next_record()){
- $max_area = $this->db->f('max_area');
- return $max_area;
- }
- }
-
-}
-?>
\ No newline at end of file
+ }
\ No newline at end of file
Modified: branches/dev-syncromind/rental/inc/class.soparty.inc.php
===================================================================
--- branches/dev-syncromind/rental/inc/class.soparty.inc.php 2015-09-11
08:24:24 UTC (rev 13880)
+++ branches/dev-syncromind/rental/inc/class.soparty.inc.php 2015-09-11
10:24:35 UTC (rev 13881)
@@ -79,12 +79,15 @@
if($sort_field == 'name')
{
$order = "ORDER BY party.last_name {$dir},
party.first_name {$dir}";
+ $this->sort_field = array('party.last_name',
'party.first_name');
}
else
{
if($sort_field == 'address')
{
$sort_field = 'party.address_1';
+ $this->sort_field =
array('party.address_1');
+
}
$order = "ORDER BY
{$this->marshal($sort_field,'field')} $dir";
}
Modified: branches/dev-syncromind/rental/inc/model/class.invoice.inc.php
===================================================================
--- branches/dev-syncromind/rental/inc/model/class.invoice.inc.php
2015-09-11 08:24:24 UTC (rev 13880)
+++ branches/dev-syncromind/rental/inc/model/class.invoice.inc.php
2015-09-11 10:24:35 UTC (rev 13881)
@@ -261,7 +261,7 @@
* @param bool $bill_only_one_time flag to indicate if the
the invoice should only bil one time price elements
* @return rental_invoice the newly created invoice
*/
- public static function create_invoice(int $decimals, int
$billing_id, int $contract_id, bool $override,int $timestamp_invoice_start, int
$timestamp_invoice_end, $bill_only_one_time, $dry_run = false)
+ public static function create_invoice(int $decimals, int
$billing_id, int $contract_id, bool $override,int $timestamp_invoice_start, int
$timestamp_invoice_end, $bill_only_one_time, $dry_run = false, $billing_term =
0)
{
$contract =
rental_socontract::get_instance()->get_single($contract_id);
@@ -317,7 +317,15 @@
// Retrieve the contract price items: only one-time or
all
if($bill_only_one_time)
{
- $contract_price_items =
rental_socontract_price_item::get_instance()->get(null, null, null, null, null,
null, array('contract_id' => $contract->get_id(), 'one_time' => true));
+ $filters2 = array('contract_id' =>
$contract->get_id(),
+ 'contract_ids_one_time' =>
true,
+ 'billing_term_id' =>
$billing_term,
+ 'year' => date('Y',
$timestamp_invoice_start),
+ 'month' => date('m',
$timestamp_invoice_start));
+ //$contract_price_items =
$socontract_price_item->get($start_index, $num_of_objects, $sort_field,
$sort_ascending, $search_for, $search_type, $filters2);
+
+ $contract_price_items =
rental_socontract_price_item::get_instance()->get(null, null, null, null, null,
null, $filters2);
+ //$contract_price_items =
rental_socontract_price_item::get_instance()->get(null, null, null, null, null,
null, array('contract_id' => $contract->get_id(), 'one_time' => true));
}
else
{
Modified: branches/dev-syncromind/sms/bin/default/set_workorder_status.php
===================================================================
--- branches/dev-syncromind/sms/bin/default/set_workorder_status.php
2015-09-11 08:24:24 UTC (rev 13880)
+++ branches/dev-syncromind/sms/bin/default/set_workorder_status.php
2015-09-11 10:24:35 UTC (rev 13881)
@@ -55,44 +55,44 @@
$historylog_project->add('S',$project_id,'i_arbeid', $status_old);
$historylog_project->add('RM',$project_id,"Bestilling {$workorder_id} endret
av: {$sms_sender}");
}
- }
+
+ //
execMethod('property.soworkorder.check_project_status',$workorder_id);
-//
execMethod('property.soworkorder.check_project_status',$workorder_id);
+ $project_status_on_last_order_closed =
'utført';
- $project_status_on_last_order_closed = 'utført';
+ $this->db->query("SELECT count(id) AS
orders_at_project FROM fm_workorder WHERE project_id= {$project_id}", __LINE__,
__FILE__);
+ $this->db->next_record();
+ $orders_at_project = (int)
$this->db->f('orders_at_project');
- $this->db->query("SELECT count(id) AS
orders_at_project FROM fm_workorder WHERE project_id= {$project_id}", __LINE__,
__FILE__);
- $this->db->next_record();
- $orders_at_project = (int)
$this->db->f('orders_at_project');
+ $this->db->query("SELECT
count(fm_workorder.id) AS closed_orders_at_project"
+ . " FROM fm_workorder"
+ . " JOIN fm_workorder_status ON
(fm_workorder.status = fm_workorder_status.id)"
+ . " WHERE project_id= {$project_id}"
+ . " AND (fm_workorder_status.closed = 1
OR fm_workorder_status.delivered = 1)", __LINE__, __FILE__);
- $this->db->query("SELECT count(fm_workorder.id)
AS closed_orders_at_project"
- . " FROM fm_workorder"
- . " JOIN fm_workorder_status ON
(fm_workorder.status = fm_workorder_status.id)"
- . " WHERE project_id= {$project_id}"
- . " AND (fm_workorder_status.closed = 1 OR
fm_workorder_status.delivered = 1)", __LINE__, __FILE__);
+ $this->db->next_record();
+ $closed_orders_at_project = (int)
$this->db->f('closed_orders_at_project');
- $this->db->next_record();
- $closed_orders_at_project = (int)
$this->db->f('closed_orders_at_project');
+ $this->db->query("SELECT
fm_project_status.closed AS closed_project, fm_project.status as old_status"
+ . " FROM fm_project"
+ . " JOIN fm_project_status ON
(fm_project.status = fm_project_status.id)"
+ . " WHERE fm_project.id=
{$project_id}", __LINE__, __FILE__);
- $this->db->query("SELECT
fm_project_status.closed AS closed_project, fm_project.status as old_status"
- . " FROM fm_project"
- . " JOIN fm_project_status ON
(fm_project.status = fm_project_status.id)"
- . " WHERE fm_project.id= {$project_id}",
__LINE__, __FILE__);
+ $this->db->next_record();
+ $closed_project =
!!$this->db->f('closed_project');
+ $old_status =
$this->db->f('old_status');
- $this->db->next_record();
- $closed_project =
!!$this->db->f('closed_project');
- $old_status =
$this->db->f('old_status');
+ if($status == 'utført'
+ && $orders_at_project ==
$closed_orders_at_project
+ && $old_status !=
$project_status_on_last_order_closed)
+ {
+ $this->db->query("UPDATE
fm_project SET status = '{$project_status_on_last_order_closed}' WHERE id=
{$project_id}", __LINE__, __FILE__);
- if($status == 'utført'
- && $orders_at_project ==
$closed_orders_at_project
- && $old_status !=
$project_status_on_last_order_closed)
- {
- $this->db->query("UPDATE fm_project SET
status = '{$project_status_on_last_order_closed}' WHERE id= {$project_id}",
__LINE__, __FILE__);
+ $historylog_project =
CreateObject('property.historylog', 'project');
- $historylog_project =
CreateObject('property.historylog', 'project');
-
- $historylog_project->add('S',
$project_id, $project_status_on_last_order_closed, $old_status);
- $historylog_project->add('RM',
$project_id, 'Status endret ved at siste bestilling er satt til utført');
+ $historylog_project->add('S',
$project_id, $project_status_on_last_order_closed, $old_status);
+ $historylog_project->add('RM',
$project_id, 'Status endret ved at siste bestilling er satt til utført');
+ }
}
$command_output = 'success';
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [13881] Syncromind: Merge 13815:13880 from trunk,
Sigurd Nes <=