[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [7036] Merge 7026:7035 from trunk
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [7036] Merge 7026:7035 from trunk |
Date: |
Wed, 23 Feb 2011 09:27:06 +0000 |
Revision: 7036
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7036
Author: sigurdne
Date: 2011-02-23 09:27:06 +0000 (Wed, 23 Feb 2011)
Log Message:
-----------
Merge 7026:7035 from trunk
Modified Paths:
--------------
branches/Version-1_0-branch/property/inc/class.sogeneric.inc.php
branches/Version-1_0-branch/property/inc/class.sorequest.inc.php
branches/Version-1_0-branch/property/inc/class.uibudget.inc.php
branches/Version-1_0-branch/property/inc/class.uirequest.inc.php
branches/Version-1_0-branch/property/setup/setup.inc.php
branches/Version-1_0-branch/property/setup/tables_current.inc.php
branches/Version-1_0-branch/property/setup/tables_update.inc.php
branches/Version-1_0-branch/property/templates/base/config.tpl
branches/Version-1_0-branch/property/templates/base/request.xsl
branches/Version-1_0-branch/rental/inc/class.uicontract.inc.php
branches/Version-1_0-branch/rental/setup/phpgw_no.lang
branches/Version-1_0-branch/rental/templates/base/composite_list_partial.php
Added Paths:
-----------
branches/Version-1_0-branch/rental/inc/SnappyMedia.php
branches/Version-1_0-branch/rental/inc/SnappyPdf.php
branches/Version-1_0-branch/rental/inc/class.uimakepdf.inc.php
branches/Version-1_0-branch/rental/templates/base/pdf/
Property Changed:
----------------
branches/Version-1_0-branch/
branches/Version-1_0-branch/rental/
Property changes on: branches/Version-1_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
-
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025
+
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035
Modified: branches/Version-1_0-branch/property/inc/class.sogeneric.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.sogeneric.inc.php
2011-02-23 09:22:30 UTC (rev 7035)
+++ branches/Version-1_0-branch/property/inc/class.sogeneric.inc.php
2011-02-23 09:27:06 UTC (rev 7036)
@@ -1078,6 +1078,31 @@
'name' =>
'descr',
'descr' =>
lang('descr'),
'type' =>
'varchar'
+ ),
+ array
+ (
+ 'name' =>
'sorting',
+ 'descr' =>
lang('sorting'),
+ 'type' =>
'integer',
+ 'sortable'=>
true
+ ),
+ array
+ (
+ 'name' =>
'in_progress',
+ 'descr' =>
lang('In progress'),
+ 'type' =>
'checkbox'
+ ),
+ array
+ (
+ 'name' =>
'delivered',
+ 'descr' =>
lang('delivered'),
+ 'type' =>
'checkbox'
+ ),
+ array
+ (
+ 'name' =>
'closed',
+ 'descr' =>
lang('closed'),
+ 'type' =>
'checkbox'
)
),
'edit_msg'
=> lang('edit status'),
Modified: branches/Version-1_0-branch/property/inc/class.sorequest.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.sorequest.inc.php
2011-02-23 09:22:30 UTC (rev 7035)
+++ branches/Version-1_0-branch/property/inc/class.sorequest.inc.php
2011-02-23 09:27:06 UTC (rev 7036)
@@ -43,6 +43,7 @@
$this->custom =
createObject('property.custom_fields');
$this->db = & $GLOBALS['phpgw']->db;
$this->join = & $this->db->join;
+ $this->left_join = & $this->db->left_join;
$this->like = & $this->db->like;
$this->interlink =
CreateObject('property.interlink');
}
@@ -122,16 +123,18 @@
function select_status_list()
{
- $this->db->query("SELECT id, descr FROM
fm_request_status ORDER BY id ");
+ $this->db->query("SELECT id, descr FROM
fm_request_status ORDER BY sorting ");
- $i = 0;
+ $status = array();
while ($this->db->next_record())
{
- $status_entries[$i]['id']
= $this->db->f('id');
- $status_entries[$i]['name']
= stripslashes($this->db->f('descr'));
- $i++;
+ $status[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' => $this->db->f('descr',true)
+ );
}
- return $status_entries;
+ return $status;
}
function select_condition_type_list()
@@ -192,21 +195,55 @@
$uicols['name'][] = 'request_id';
$uicols['descr'][] =
lang('Request');
$uicols['statustext'][] = lang('Request ID');
+ $uicols['exchange'][] = '';
+ $uicols['align'][] = '';
+ $uicols['datatype'][] = '';
+ $uicols['formatter'][] = '';
+ $uicols['classname'][] = '';
+ $uicols['sortable'][] = true;
+
+ $cols.= ",fm_request_status.descr as status";
+ $cols_return[] = 'status';
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'status';
+ $uicols['descr'][] =
lang('status');
+ $uicols['statustext'][] = lang('status');
+ $uicols['exchange'][] = '';
+ $uicols['align'][] = '';
+ $uicols['datatype'][] = '';
+ $uicols['formatter'][] = '';
+ $uicols['classname'][] = '';
+ $uicols['sortable'][] = false;
+
$cols.= ",$entity_table.start_date";
$cols_return[] = 'start_date';
$uicols['input_type'][] = 'text';
$uicols['name'][] = 'start_date';
$uicols['descr'][] = lang('start
date');
$uicols['statustext'][] = lang('Request start
date');
+ $uicols['exchange'][] = '';
+ $uicols['align'][] = '';
+ $uicols['datatype'][] = '';
+ $uicols['formatter'][] = '';
+ $uicols['classname'][] = '';
+ $uicols['sortable'][] = true;
+
$cols.= ",$entity_table.title as title";
$cols_return[] = 'title';
$uicols['input_type'][] = 'text';
$uicols['name'][] = 'title';
$uicols['descr'][] = lang('title');
$uicols['statustext'][] = lang('Request title');
+ $uicols['exchange'][] = '';
+ $uicols['align'][] = '';
+ $uicols['datatype'][] = '';
+ $uicols['formatter'][] = '';
+ $uicols['classname'][] = '';
+ $uicols['sortable'][] = true;
+
if($list_descr)
{
$cols.= ",$entity_table.descr as descr";
@@ -215,6 +252,12 @@
$uicols['name'][] =
'descr';
$uicols['descr'][] =
lang('descr');
$uicols['statustext'][] = lang('Request
descr');
+ $uicols['exchange'][] = '';
+ $uicols['align'][] = '';
+ $uicols['datatype'][] = '';
+ $uicols['formatter'][] = '';
+ $uicols['classname'][] = '';
+ $uicols['sortable'][] = false;
}
@@ -224,6 +267,12 @@
$uicols['name'][] = 'budget';
$uicols['descr'][] =
lang('budget');
$uicols['statustext'][] = lang('Request
budget');
+ $uicols['exchange'][] = '';
+ $uicols['align'][] = '';
+ $uicols['datatype'][] = '';
+ $uicols['formatter'][] = '';
+ $uicols['classname'][] = '';
+ $uicols['sortable'][] = true;
$cols.= ",$entity_table.coordinator";
$cols_return[] = 'coordinator';
@@ -231,14 +280,31 @@
$uicols['name'][] = 'coordinator';
$uicols['descr'][] =
lang('Coordinator');
$uicols['statustext'][] = lang('Project
coordinator');
+ $uicols['exchange'][] = '';
+ $uicols['align'][] = '';
+ $uicols['datatype'][] = '';
+ $uicols['formatter'][] = '';
+ $uicols['classname'][] = '';
+ $uicols['sortable'][] = false;
+
$cols.= ",$entity_table.score";
$cols_return[] = 'score';
$uicols['input_type'][] = 'text';
$uicols['name'][] = 'score';
$uicols['descr'][] = lang('score');
$uicols['statustext'][] = lang('score');
+ $uicols['exchange'][] = '';
+ $uicols['align'][] = '';
+ $uicols['datatype'][] = '';
+ $uicols['formatter'][] = '';
+ $uicols['classname'][] = '';
+ $uicols['sortable'][] = true;
+
+ $paranthesis = '(';
+ $joinmethod = "{$this->left_join} fm_request_status ON
{$entity_table}.status = fm_request_status.id)";
+
$sql =
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols'=>$cols,'cols_return'=>$cols_return,
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,
'query'=>$query,'force_location'=>true));
@@ -265,13 +331,13 @@
if ($cat_id > 0)
{
- $filtermethod .= " $where
fm_request.category='$cat_id' ";
+ $filtermethod .= " $where
fm_request.category='{$cat_id}' ";
$where = 'AND';
}
if ($status_id)
{
- $filtermethod .= " $where
fm_request.status='$status_id' ";
+ $filtermethod .= " $where
fm_request.status='{$status_id}' ";
$where = 'AND';
}
@@ -281,9 +347,10 @@
$where = 'AND';
}
- if ($project_id)// lookup requests not already
allocated to projects
+ if ($project_id && !$status_id)// lookup requests not
already allocated to projects
{
- $filtermethod .= " $where project_id is NULL ";
+// $filtermethod .= " $where project_id is NULL ";
+ $filtermethod .= " $where
fm_request_status.closed is NULL ";
$where = 'AND';
}
@@ -308,7 +375,7 @@
}
$sql .= " $filtermethod $querymethod";
-
+//_debug_array($sql);
$this->uicols = $this->bocommon->uicols;
$cols_return = $this->bocommon->cols_return;
$type_id =
$this->bocommon->type_id;
Modified: branches/Version-1_0-branch/property/inc/class.uibudget.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uibudget.inc.php
2011-02-23 09:22:30 UTC (rev 7035)
+++ branches/Version-1_0-branch/property/inc/class.uibudget.inc.php
2011-02-23 09:27:06 UTC (rev 7036)
@@ -1864,9 +1864,9 @@
{
switch (phpgw::get_var('download'))
{
- case 'basis':
- $list= $this->bo->read_basis();
- $names = array
+ case 'basis':
+ $list= $this->bo->read_basis();
+ $names = array
(
'year',
'revision',
@@ -1876,7 +1876,7 @@
'category',
'budget_cost'
);
- $descr = array
+ $descr = array
(
lang('year'),
lang('revision'),
@@ -1886,10 +1886,10 @@
lang('category'),
lang('budget')
);
- break;
- case 'budget':
- $list= $this->bo->read();
- $names = array
+ break;
+ case 'budget':
+ $list= $this->bo->read();
+ $names = array
(
'year',
'revision',
@@ -1899,9 +1899,9 @@
'district_id',
'ecodimb',
'category',
- 'budget'
- );
- $descr = array
+ 'budget_cost'
+ );
+ $descr = array
(
lang('year'),
lang('revision'),
@@ -1913,15 +1913,14 @@
lang('category'),
lang('budget')
);
-
- break;
- case 'obligations':
- $gross_list= $this->bo->read_obligations();
- $sum_obligation = $sum_hits = $sum_budget_cost
= $sum_actual_cost = 0;
- $list = array();
- foreach($gross_list as $entry)
- {
- $list[] = array
+ break;
+ case 'obligations':
+ $gross_list=
$this->bo->read_obligations();
+ $sum_obligation = $sum_hits =
$sum_budget_cost = $sum_actual_cost = 0;
+ $list = array();
+ foreach($gross_list as $entry)
+ {
+ $list[] = array
(
'grouping'
=> $entry['grouping'],
'b_account'
=> $entry['b_account'],
@@ -1933,8 +1932,8 @@
'actual_cost'
=> $entry['actual_cost'],
'diff'
=> ($entry['budget_cost'] - $entry['actual_cost'] -
$entry['obligation']),
);
- }
- $names = array
+ }
+ $names = array
(
'grouping',
'b_account',
@@ -1946,7 +1945,7 @@
'actual_cost',
'diff'
);
- $descr = array
+ $descr = array
(
lang('grouping'),
lang('budget account'),
@@ -1958,10 +1957,11 @@
lang('paid'),
lang('difference')
);
- break;
- default:
- return;
+ break;
+ default:
+ return;
}
+
if($list)
{
$this->bocommon->download($list,$names,$descr);
Modified: branches/Version-1_0-branch/property/inc/class.uirequest.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uirequest.inc.php
2011-02-23 09:22:30 UTC (rev 7035)
+++ branches/Version-1_0-branch/property/inc/class.uirequest.inc.php
2011-02-23 09:27:06 UTC (rev 7036)
@@ -69,7 +69,7 @@
$this->cats = &
$this->bo->cats;
$this->bolocation =
CreateObject('property.bolocation');
$this->config =
CreateObject('phpgwapi.config','property');
-
+ $this->config->read();
$this->acl = &
$GLOBALS['phpgw']->acl;
$this->acl_location =
'.project.request';
$this->acl_read =
$this->acl->check($this->acl_location, PHPGW_ACL_READ, 'property');
@@ -540,25 +540,27 @@
$uicols_count = count($uicols['descr']);
+ $show_dates =
isset($this->config->config_data['request_show_dates']) &&
$this->config->config_data['request_show_dates'] ? 1 : '';
+
for ($i=0;$i<$uicols_count;$i++)
{
+ if(!$show_dates && $uicols['name'][$i] ==
'start_date')
+ {
+ $uicols['input_type'][$i] = 'hidden';
+ }
//all colums should be have formatter
$datatable['headers']['header'][$i]['formatter'] =
($uicols['formatter'][$i]==''? '""' : $uicols['formatter'][$i]);
-
+
if($uicols['input_type'][$i]!='hidden')
{
$datatable['headers']['header'][$i]['name'] =
$uicols['name'][$i];
$datatable['headers']['header'][$i]['text'] =
$uicols['descr'][$i];
$datatable['headers']['header'][$i]['visible'] = true;
$datatable['headers']['header'][$i]['format'] =
$this->bocommon->translate_datatype_format($uicols['datatype'][$i]);
-
$datatable['headers']['header'][$i]['sortable'] = false;
+
$datatable['headers']['header'][$i]['sortable'] =
$uicols['sortable'][$i];
+
$datatable['headers']['header'][$i]['sort_field'] =
$uicols['name'][$i];
- if($uicols['name'][$i]=='request_id' ||
$uicols['name'][$i]=='budget' || $uicols['name'][$i]=='score' ||
$uicols['name'][$i]=='start_date')
- {
-
$datatable['headers']['header'][$i]['sortable'] = true;
-
$datatable['headers']['header'][$i]['sort_field'] = $uicols['name'][$i];
- }
if($uicols['name'][$i]=='loc1')
{
$datatable['headers']['header'][$i]['sortable'] = true;
@@ -571,7 +573,7 @@
$datatable['headers']['header'][$i]['name'] =
$uicols['name'][$i];
$datatable['headers']['header'][$i]['text'] =
$uicols['descr'][$i];
$datatable['headers']['header'][$i]['visible'] = false;
-
$datatable['headers']['header'][$i]['sortable'] = false;
+
$datatable['headers']['header'][$i]['sortable'] = false;
$datatable['headers']['header'][$i]['format'] = 'hidden';
}
}
@@ -877,7 +879,6 @@
//_debug_array($values);
- $this->config->read();
if ($values['save'] && $mode == 'edit')
{
@@ -1122,9 +1123,13 @@
);
}
- $jscal = CreateObject('phpgwapi.jscalendar');
- $jscal->add_listener('values_start_date');
- $jscal->add_listener('values_end_date');
+ $show_dates =
isset($this->config->config_data['request_show_dates']) &&
$this->config->config_data['request_show_dates'] ? 1 : '';
+ if($show_dates)
+ {
+ $jscal = CreateObject('phpgwapi.jscalendar');
+ $jscal->add_listener('values_start_date');
+ $jscal->add_listener('values_end_date');
+ }
$msgbox_data = $this->bocommon->msgbox_data($receipt);
@@ -1214,10 +1219,12 @@
}
}
+
$data = array
(
'mode'
=> $mode,
'suppressmeter'
=> isset($this->config->config_data['project_suppressmeter'])
&& $this->config->config_data['project_suppressmeter'] ? 1 : '',
+ 'show_dates'
=> $show_dates,
'attributes'
=> $values['attributes'],
'property_js'
=>
json_encode($GLOBALS['phpgw_info']['server']['webserver_url']."/property/js/yahoo/property2.js"),
'datatable'
=> $datavalues,
@@ -1383,6 +1390,7 @@
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=>
'property.uilocation.stop', 'perm'=>8, 'acl_location'=> $this->acl_location));
}
+
//$id = phpgw::get_var('id', 'int');
$confirm = phpgw::get_var('confirm', 'bool',
'POST');
Modified: branches/Version-1_0-branch/property/setup/setup.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/setup.inc.php 2011-02-23
09:22:30 UTC (rev 7035)
+++ branches/Version-1_0-branch/property/setup/setup.inc.php 2011-02-23
09:27:06 UTC (rev 7036)
@@ -12,7 +12,7 @@
*/
$setup_info['property']['name'] = 'property';
- $setup_info['property']['version'] = '0.9.17.608';
+ $setup_info['property']['version'] = '0.9.17.609';
$setup_info['property']['app_order'] = 8;
$setup_info['property']['enable'] = 1;
$setup_info['property']['app_group'] = 'office';
Modified: branches/Version-1_0-branch/property/setup/tables_current.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/tables_current.inc.php
2011-02-23 09:22:30 UTC (rev 7035)
+++ branches/Version-1_0-branch/property/setup/tables_current.inc.php
2011-02-23 09:27:06 UTC (rev 7036)
@@ -818,7 +818,11 @@
'fm_request_status' => array(
'fd' => array(
'id' => array('type' => 'varchar','precision'
=> '20','nullable' => False),
- 'descr' => array('type' =>
'varchar','precision' => '255','nullable' => False)
+ 'descr' => array('type' =>
'varchar','precision' => '255','nullable' => False),
+ 'closed' => array('type' => 'int','precision'
=> '2','nullable' => True),
+ 'in_progress' => array('type' =>
'int','precision' => '2','nullable' => True),
+ 'delivered' => array('type' =>
'int','precision' => '2','nullable' => True),
+ 'sorting' => array('type' => 'int','precision'
=> '4','nullable' => True)
),
'pk' => array('id'),
'fk' => array(),
Modified: branches/Version-1_0-branch/property/setup/tables_update.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/tables_update.inc.php
2011-02-23 09:22:30 UTC (rev 7035)
+++ branches/Version-1_0-branch/property/setup/tables_update.inc.php
2011-02-23 09:27:06 UTC (rev 7036)
@@ -5019,7 +5019,34 @@
}
}
+
+
+
/**
+ * Update property version from 0.9.17.608 to 0.9.17.609
+ * Add location_link_level
+ *
+ */
+
+ $test[] = '0.9.17.608';
+ function property_upgrade0_9_17_608()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_request_status','closed',array('type'
=> 'int','precision' => 2,'nullable' => True));
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_request_status','in_progress',array('type'
=> 'int','precision' => 2,'nullable' => True));
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_request_status','delivered',array('type'
=> 'int','precision' => 2,'nullable' => True));
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_request_status','sorting',array('type'
=> 'int','precision' => 4,'nullable' => True));
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['property']['currentver'] =
'0.9.17.609';
+ return $GLOBALS['setup_info']['property']['currentver'];
+ }
+ }
+
+
+ /**
* Update property version from 0.9.17.607 to 0.9.17.608
* Add more room for address at tickets
*
Modified: branches/Version-1_0-branch/property/templates/base/config.tpl
===================================================================
--- branches/Version-1_0-branch/property/templates/base/config.tpl
2011-02-23 09:22:30 UTC (rev 7035)
+++ branches/Version-1_0-branch/property/templates/base/config.tpl
2011-02-23 09:27:06 UTC (rev 7036)
@@ -390,6 +390,16 @@
</td>
</tr>
+ <tr class="row_off">
+ <td>{lang_request_show_dates}.</td>
+ <td>
+ <select name="newsettings[request_show_dates]">
+ <option value=""
{selected_request_show_dates_}>NO</option>
+ <option value="1"
{selected_request_show_dates_1}>YES</option>
+ </select>
+ </td>
+ </tr>
+
<tr class="row_on">
<td>{lang_meter_table}:</td>
<td><input name="newsettings[meter_table]"
value="{value_meter_table}"></td>
Modified: branches/Version-1_0-branch/property/templates/base/request.xsl
===================================================================
--- branches/Version-1_0-branch/property/templates/base/request.xsl
2011-02-23 09:22:30 UTC (rev 7035)
+++ branches/Version-1_0-branch/property/templates/base/request.xsl
2011-02-23 09:27:06 UTC (rev 7036)
@@ -339,32 +339,37 @@
</select>
</td>
</tr>
- <tr>
- <td
valign="top">
-
<xsl:value-of select="lang_start_date"/>
- </td>
- <td>
- <input
type="text" id="values_start_date" name="values[start_date]" size="10"
value="{value_start_date}" readonly="readonly" >
-
<xsl:attribute name="title">
-
<xsl:value-of select="lang_start_date_statustext"/>
-
</xsl:attribute>
- </input>
- <img
id="values_start_date-trigger" src="{img_cal}" alt="{lang_datetitle}"
title="{lang_datetitle}" style="cursor:pointer; cursor:hand;" />
- </td>
- </tr>
- <tr>
- <td
valign="top">
-
<xsl:value-of select="lang_end_date"/>
- </td>
- <td>
- <input
type="text" id="values_end_date" name="values[end_date]" size="10"
value="{value_end_date}" readonly="readonly" >
-
<xsl:attribute name="title">
-
<xsl:value-of select="lang_end_date_statustext"/>
-
</xsl:attribute>
- </input>
- <img
id="values_end_date-trigger" src="{img_cal}" alt="{lang_datetitle}"
title="{lang_datetitle}" style="cursor:pointer; cursor:hand;" />
- </td>
- </tr>
+
+ <xsl:choose>
+ <xsl:when
test="show_dates !=''">
+ <tr>
+
<td valign="top">
+
<xsl:value-of select="lang_start_date"/>
+
</td>
+
<td>
+
<input type="text" id="values_start_date" name="values[start_date]"
size="10" value="{value_start_date}" readonly="readonly" >
+
<xsl:attribute name="title">
+
<xsl:value-of select="lang_start_date_statustext"/>
+
</xsl:attribute>
+
</input>
+
<img id="values_start_date-trigger" src="{img_cal}"
alt="{lang_datetitle}" title="{lang_datetitle}" style="cursor:pointer;
cursor:hand;" />
+
</td>
+ </tr>
+ <tr>
+
<td valign="top">
+
<xsl:value-of select="lang_end_date"/>
+
</td>
+
<td>
+
<input type="text" id="values_end_date" name="values[end_date]"
size="10" value="{value_end_date}" readonly="readonly" >
+
<xsl:attribute name="title">
+
<xsl:value-of select="lang_end_date_statustext"/>
+
</xsl:attribute>
+
</input>
+
<img id="values_end_date-trigger" src="{img_cal}"
alt="{lang_datetitle}" title="{lang_datetitle}" style="cursor:pointer;
cursor:hand;" />
+
</td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
<!--
<tr>
<td
valign="top">
Property changes on: branches/Version-1_0-branch/rental
___________________________________________________________________
Added: svn:ignore
+ wkhtmltopdt_test.php
testphp.php
SnappyPdf.php
SnappyMedia.php
google.pdf
Copied: branches/Version-1_0-branch/rental/inc/SnappyMedia.php (from rev 7035,
trunk/rental/inc/SnappyMedia.php)
===================================================================
--- branches/Version-1_0-branch/rental/inc/SnappyMedia.php
(rev 0)
+++ branches/Version-1_0-branch/rental/inc/SnappyMedia.php 2011-02-23
09:27:06 UTC (rev 7036)
@@ -0,0 +1,117 @@
+<?php
+
+/**
+*
+*/
+abstract class SnappyMedia
+{
+ protected $executable;
+ protected $options = array();
+ protected $defaultExtension;
+
+ /**
+ * Write the media to the standard output.
+ *
+ * @param string Url of the page
+ * @return void
+ */
+ public function output($url)
+ {
+ $file = tempnam(sys_get_temp_dir(), 'snappy') . '.' .
$this->defaultExtension;
+ $ok = $this->save($url, $file);
+ readfile($file);
+ unlink($file);
+ }
+
+ /**
+ * Save a url or file location to an image.
+ * Will create directories if needed.
+ *
+ * @param string Url of the page
+ * @param string Path of the future image
+ * @return boolean True if success
+ */
+ public function save($url, $path)
+ {
+ $command = $this->buildCommand($url, $path);
+ $basePath = dirname($path);
+ if(!is_dir($basePath)) {
+ mkdir($basePath, 0777, true);
+ }
+ if(file_exists($path)) {
+ unlink($path);
+ }
+ $ok = $this->exec($command);
+ return file_exists($path) && filesize($path);
+ }
+
+ public function setExecutable($executable)
+ {
+ $this->executable = $executable;
+ }
+
+ /**
+ * Set a wkhtmltoimage option. Be aware that option values are NOT
validated
+ * and that it is your responsibility to validate user inputs.
+ *
+ * @param string Option
+ * @param string|array Value. Null to unset the option.
+ * @return void
+ */
+ public function setOption($option, $value = null)
+ {
+ if(!array_key_exists($option, $this->options)) {
+ throw new Exception("Invalid option '$option'");
+ }
+ $this->options[$option] = $value;
+ }
+
+ /**
+ * Merge wkhtmltoimage options (passed as an array) with current options
+ *
+ * @param array Array of options
+ * @return void
+ */
+ public function mergeOptions(array $options)
+ {
+ foreach($options as $key => $value) {
+ $this->setOption($key, $value);
+ }
+ }
+
+ /**
+ * Return the command to wkhtmltoimage using the options attributes
+ *
+ * @param string Url or file location of the page to process
+ * @param string File location to the image-to-be
+ * @return string The command
+ */
+ protected function buildCommand($url, $path)
+ {
+ $command = $this->executable;
+
+ foreach($this->options as $key => $value) {
+ if(null !== $value && false !== $value) {
+ if(true === $value) {
+ $command .= " --$key";
+ } elseif(is_array($value)) {
+ foreach($value as $v) {
+ $command .= " --$key $v";
+ }
+ } else {
+ $command .= " --$key $value";
+ }
+ }
+ }
+
+ $command .= " \"$url\" \"$path\"";
+
+ return $command;
+ }
+
+ protected function exec($command)
+ {
+ return shell_exec($command);
+ }
+}
+?>
\ No newline at end of file
Copied: branches/Version-1_0-branch/rental/inc/SnappyPdf.php (from rev 7035,
trunk/rental/inc/SnappyPdf.php)
===================================================================
--- branches/Version-1_0-branch/rental/inc/SnappyPdf.php
(rev 0)
+++ branches/Version-1_0-branch/rental/inc/SnappyPdf.php 2011-02-23
09:27:06 UTC (rev 7036)
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Use this class to transform a html/a url to a pdf
+ *
+ * @package Snappy
+ * @author Matthieu Bontemps<address@hidden>
+ */
+class SnappyPdf extends SnappyMedia
+{
+ protected $defaultExtension = 'pdf';
+ protected $options = array(
+ 'ignore-load-errors' => null, // old v0.9
+ 'lowquality' => true,
+ 'username' => null,
+ 'password' => null,
+ );
+
+}
+?>
\ No newline at end of file
Modified: branches/Version-1_0-branch/rental/inc/class.uicontract.inc.php
===================================================================
--- branches/Version-1_0-branch/rental/inc/class.uicontract.inc.php
2011-02-23 09:22:30 UTC (rev 7035)
+++ branches/Version-1_0-branch/rental/inc/class.uicontract.inc.php
2011-02-23 09:27:06 UTC (rev 7036)
@@ -234,23 +234,24 @@
if(!isset($ids) || count($ids) > 0)
{
$value['ajax'][] = false;
- $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uicontract.edit',
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uicontract.edit',
'id' => $value['id'],
'initial_load' => 'no',
'adjustment_id' => $adjustment_id)));
$value['labels'][] =
lang('edit');
$value['ajax'][] = false;
- $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'rental.uicontract.copy_contract',
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'rental.uicontract.copy_contract',
'id' => $value['id'],
'adjustment_id' => $adjustment_id)));
$value['labels'][] =
lang('copy');
}
$value['ajax'][] = false;
- $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uicontract.view',
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uicontract.view',
'id' => $value['id'],
'initial_load' => 'no',
'adjustment_id' => $adjustment_id)));
$value['labels'][] = lang('show');
+
break;
default:
if(!isset($ids) || count($ids) > 0)
@@ -265,6 +266,9 @@
$value['ajax'][] = false;
$value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uicontract.view',
'id' => $value['id'], 'initial_load' => 'no')));
$value['labels'][] = lang('show');
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uimakepdf.view',
'id' => $value['id'])));
+ $value['labels'][] = lang('make_pdf');
}
}
Copied: branches/Version-1_0-branch/rental/inc/class.uimakepdf.inc.php (from
rev 7035, trunk/rental/inc/class.uimakepdf.inc.php)
===================================================================
--- branches/Version-1_0-branch/rental/inc/class.uimakepdf.inc.php
(rev 0)
+++ branches/Version-1_0-branch/rental/inc/class.uimakepdf.inc.php
2011-02-23 09:27:06 UTC (rev 7036)
@@ -0,0 +1,887 @@
+<?php
+ phpgw::import_class('rental.uicommon');
+ phpgw::import_class('rental.sobilling');
+ phpgw::import_class('rental.socontract');
+ phpgw::import_class('rental.socomposite');
+ phpgw::import_class('rental.sodocument');
+ phpgw::import_class('rental.soinvoice');
+ phpgw::import_class('rental.sonotification');
+ phpgw::import_class('rental.soprice_item');
+ phpgw::import_class('rental.socontract_price_item');
+ phpgw::import_class('rental.soadjustment');
+ phpgw::import_class('rental.soparty');
+ include_class('rental', 'contract', 'inc/model/');
+ include_class('rental', 'party', 'inc/model/');
+ include_class('rental', 'composite', 'inc/model/');
+ include_class('rental', 'price_item', 'inc/model/');
+ include_class('rental', 'contract_price_item', 'inc/model/');
+ include_class('rental', 'notification', 'inc/model/');
+ include 'SnappyMedia.php';
+ include 'SnappyPdf.php';
+
+ class rental_uimakepdf extends rental_uicommon
+ {
+ public $public_functions = array
+ (
+ 'add' => true,
+ 'add_from_composite' => true,
+ 'copy_contract' => true,
+ 'edit' => true,
+ 'index' => true,
+ 'query' => true,
+ 'view' => true,
+ 'add_party' => true,
+ 'remove_party' => true,
+ 'add_composite' => true,
+ 'remove_composite' => true,
+ 'set_payer' => true,
+ 'add_price_item' => true,
+ 'remove_price_item' => true,
+ 'reset_price_item' => true,
+ 'download' => true,
+ 'get_total_price' => true,
+ 'makePDF' => true
+ );
+
+ public function __construct()
+ {
+ parent::__construct();
+ self::set_active_menu('rental::contracts');
+ $GLOBALS['phpgw_info']['flags']['app_header'] .=
'::'.lang('contracts');
+ }
+
+ public function query()
+ {
+
if($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] > 0)
+ {
+ $user_rows_per_page =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else {
+ $user_rows_per_page = 10;
+ }
+ // YUI variables for paging and sorting
+ $start_index = phpgw::get_var('startIndex', 'int');
+ $num_of_objects = phpgw::get_var('results', 'int',
'GET', $user_rows_per_page);
+ $sort_field = phpgw::get_var('sort');
+ $sort_ascending = phpgw::get_var('dir') == 'desc' ?
false : true;
+ // Form variables
+ $search_for = phpgw::get_var('query');
+ $search_type = phpgw::get_var('search_option');
+ // Create an empty result set
+ $result_objects = array();
+ $result_count = 0;
+
+ $exp_param = phpgw::get_var('export');
+ $export = false;
+ if(isset($exp_param)){
+ $export=true;
+ $num_of_objects = null;
+ }
+
+ $type = phpgw::get_var('type');
+ switch($type)
+ {
+ case 'contracts_for_adjustment':
+ $adjustment_id =
(int)phpgw::get_var('id');
+ $adjustment =
rental_soadjustment::get_instance()->get_single($adjustment_id);
+ $filters = array('contract_type' =>
$adjustment->get_responsibility_id(), 'adjustment_interval' =>
$adjustment->get_interval(), 'adjustment_year' => $adjustment->get_year(),
'adjustment_is_executed' => $adjustment->is_executed());
+ break;
+ case 'contracts_part':
// Contracts for this party
+ $filters = array('party_id' =>
phpgw::get_var('party_id'),'contract_status' =>
phpgw::get_var('contract_status'), 'contract_type' =>
phpgw::get_var('contract_type'), 'status_date_hidden' =>
phpgw::get_var('status_date_hidden'));
+ break;
+ case 'contracts_for_executive_officer':
// Contracts for this executive officer
+ $filters = array('executive_officer' =>
$GLOBALS['phpgw_info']['user']['account_id']);
+ break;
+ case 'ending_contracts':
+ case 'ended_contracts':
+ case 'last_edited':
+ case 'closing_due_date':
+ case 'terminated_contracts':
+ // Queries that depend on areas of
responsibility
+ $types =
rental_socontract::get_instance()->get_fields_of_responsibility();
+ $ids = array();
+ $read_access = array();
+ foreach($types as $id => $label)
+ {
+ $names =
$this->locations->get_name($id);
+ if($names['appname'] ==
$GLOBALS['phpgw_info']['flags']['currentapp'])
+ {
+
if($this->hasPermissionOn($names['location'],PHPGW_ACL_ADD))
+ {
+ $ids[] = $id;
+ }
+ else
+ {
+ $read_access[]
= $id;
+ }
+ }
+ }
+
+
+ if(count($ids) > 0)
+ {
+ $comma_seperated_ids =
implode(',',$ids);
+ }
+ else
+ {
+ $comma_seperated_ids =
implode(',',$read_access);
+ }
+
+ switch($type)
+ {
+ case 'ending_contracts':
// Contracts that are about to end in areas of responsibility
+ $filters =
array('contract_status' => 'under_dismissal', 'contract_type' =>
$comma_seperated_ids);
+ break;
+ case 'ended_contracts':
// Contracts that are ended in areas of responsibility
+ $filters =
array('contract_status' => 'ended', 'contract_type' => $comma_seperated_ids);
+ break;
+ case 'last_edited':
// Contracts that are last edited in areas of resposibility
+ $filters =
array('contract_type' => $comma_seperated_ids);
+ $sort_field =
'contract.last_updated';
+ $sort_ascending = false;
+ break;
+ case 'closing_due_date':
//Contracts closing due date in areas of responsibility
+ $filters =
array('contract_status' => 'closing_due_date', 'contract_type' =>
$comma_seperated_ids);
+ break;
+ case 'terminated_contracts':
+ $filters =
array('contract_status' => 'terminated_contracts', 'contract_type' =>
$comma_seperated_ids);
+ break;
+ }
+
+ break;
+ case 'contracts_for_composite': // ... all
contracts this composite is involved in, filters (status and date)
+ $filters = array('composite_id' =>
phpgw::get_var('composite_id'),'contract_status' =>
phpgw::get_var('contract_status'), 'contract_type' =>
phpgw::get_var('contract_type'), 'status_date_hidden' =>
phpgw::get_var('date_status_hidden'));
+ break;
+ case 'get_contract_warnings': //get the
contract warnings
+ $contract =
rental_socontract::get_instance()->get_single(phpgw::get_var('contract_id'));
+ $contract->check_consistency();
+ $rows =
$contract->get_consistency_warnings();
+ $result_count = count($rows);
+ $export=true;
+ break;
+ case 'all_contracts':
+ default:
+ phpgwapi_cache::session_set('rental',
'contract_query', $search_for);
+ phpgwapi_cache::session_set('rental',
'contract_search_type', $search_type);
+ phpgwapi_cache::session_set('rental',
'contract_status', phpgw::get_var('contract_status'));
+ phpgwapi_cache::session_set('rental',
'contract_status_date', phpgw::get_var('date_status'));
+ phpgwapi_cache::session_set('rental',
'contract_type', phpgw::get_var('contract_type'));
+ $filters = array('contract_status' =>
phpgw::get_var('contract_status'), 'contract_type' =>
phpgw::get_var('contract_type'), 'status_date_hidden' =>
phpgw::get_var('date_status_hidden'));
+ }
+ if($type != 'get_contract_warnings'){
+ $result_objects =
rental_socontract::get_instance()->get($start_index, $num_of_objects,
$sort_field, $sort_ascending, $search_for, $search_type, $filters);
+ $result_count =
rental_socontract::get_instance()->get_count($search_for, $search_type,
$filters);
+
+
+ //Serialize the contracts found
+ $rows = array();
+ foreach ($result_objects as $result) {
+ if(isset($result))
+ {
+ $rows[] = $result->serialize();
+ }
+ }
+ //var_dump("Usage " .memory_get_usage() . "
bytes after serializing");
+ }
+
+ if(!$export){
+ //Add context menu columns (actions and labels)
+ array_walk($rows, array($this, 'add_actions'),
array($type,$ids,$adjustment_id));
+ }
+ //var_dump("Usage " .memory_get_usage() . " bytes after
menu");
+
+
+ //Build a YUI result from the data
+ $result_data = array('results' => $rows,
'total_records' => $result_count);
+ return $this->yui_results($result_data,
'total_records', 'results');
+ }
+
+ /**
+ * Add data for context menu
+ *
+ * @param $value pointer to
+ * @param $key ?
+ * @param $params [type of query, editable]
+ */
+ public function add_actions(&$value, $key, $params)
+ {
+ $value['ajax'] = array();
+ $value['actions'] = array();
+ $value['labels'] = array();
+
+ $type = $params[0];
+ $ids = $params[1];
+ $adjustment_id = $params[2];
+
+ switch($type)
+ {
+ case 'last_edited_by':
+ case 'contracts_for_executive_officer':
+ case 'ending_contracts':
+ case 'ended_contracts':
+ case 'closing_due_date':
+ case 'terminated_contracts':
+ if(count($ids) > 0)
+ {
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uicontract.edit',
'id' => $value['id'], 'initial_load' => 'no')));
+ $value['labels'][] =
lang('edit_contract');
+ }
+ else
+ {
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uicontract.view',
'id' => $value['id'], 'initial_load' => 'no')));
+ $value['labels'][] =
lang('show');
+ }
+ break;
+ case 'contracts_for_adjustment':
+ if(!isset($ids) || count($ids) > 0)
+ {
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uicontract.edit',
+
'id' => $value['id'],
+
'initial_load' => 'no',
+
'adjustment_id' => $adjustment_id)));
+ $value['labels'][] =
lang('edit');
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'rental.uicontract.copy_contract',
+
'id' => $value['id'],
+
'adjustment_id' => $adjustment_id)));
+ $value['labels'][] =
lang('copy');
+ }
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uicontract.view',
+
'id' => $value['id'],
+
'initial_load' => 'no',
+
'adjustment_id' => $adjustment_id)));
+ $value['labels'][] = lang('show');
+
+
+
+ break;
+ default:
+ if(!isset($ids) || count($ids) > 0)
+ {
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uicontract.edit',
'id' => $value['id'], 'initial_load' => 'no')));
+ $value['labels'][] =
lang('edit');
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' =>
'rental.uicontract.copy_contract', 'id' => $value['id'])));
+ $value['labels'][] =
lang('copy');
+ }
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uicontract.view',
'id' => $value['id'], 'initial_load' => 'no')));
+ $value['labels'][] = lang('show');
+ $value['ajax'][] = false;
+ $value['actions'][] =
html_entity_decode(self::link(array('menuaction' => 'rental.uicontract.view',
'id' => $value['id'], 'initial_load' => 'no')));
+ $value['labels'][] = lang('make_pdf');
+ }
+ }
+
+ /**
+ * View a list of all contracts
+ */
+ public function index()
+ {
+ $search_for = phpgw::get_var('search_for');
+ if($search_for)
+ {
+ phpgwapi_cache::session_set('rental',
'contract_query', $search_for);
+ phpgwapi_cache::session_set('rental',
'contract_search_type', phpgw::get_var('search_type'));
+ phpgwapi_cache::session_set('rental',
'contract_status', phpgw::get_var('contract_status'));
+ phpgwapi_cache::session_set('rental',
'contract_status_date', phpgw::get_var('date_status'));
+ phpgwapi_cache::session_set('rental',
'contract_type', phpgw::get_var('contract_type'));
+ }
+ $this->render('contract_list.php');
+ }
+
+ /**
+ * Common function for viewing or editing a contract
+ *
+ * @param $editable whether or not the contract should be
editable in the view
+ * @param $contract_id the id of the contract to show
+ */
+ public function viewedit($editable, $contract_id, $contract =
null, $location_id = null, $notification = null, string $message = null, string
$error = null)
+ {
+
+ $cancel_link = self::link(array('menuaction' =>
'rental.uicontract.index', 'populate_form' => 'yes'));
+ $adjustment_id = (int)phpgw::get_var('adjustment_id');
+ if($adjustment_id){
+ $cancel_link = self::link(array('menuaction' =>
'rental.uiadjustment.show_affected_contracts','id' => $adjustment_id));
+ $cancel_text = 'contract_regulation_back';
+ }
+
+
+ if (isset($contract_id) && $contract_id > 0) {
+ if($contract == null){
+ $contract =
rental_socontract::get_instance()->get_single($contract_id);
+ }
+ if ($contract) {
+
+ if($editable &&
!$contract->has_permission(PHPGW_ACL_EDIT))
+ {
+ $editable = false;
+ $error .=
'<br/>'.lang('permission_denied_edit_contract');
+ }
+
+ if(!$editable &&
!$contract->has_permission(PHPGW_ACL_READ))
+ {
+
$this->render('permission_denied.php',array('error' =>
lang('permission_denied_view_contract')));
+ return;
+ }
+
+ $parties =
rental_soparty::get_instance()->get(null, null, null, null, null, null,
array('contract_id' => $contract->get_id()));
+ $party = reset($parties); //
+
+ $contract_dates =
$contract->get_contract_date();
+
+ $composites =
rental_socomposite::get_instance()->get(null, null, null, null, null, null,
array('contract_id' => $contract->get_id()));
+ $composite = reset($composites);
+
+ $units = $composite->get_units();
+ $unit = reset($units);
+
+
+ $price_items =
rental_socontract_price_item::get_instance()->get(null, null, null, null, null,
null, array('contract_id' => $contract->get_id()));
+
+ $data = array
+ (
+ 'contract' => $contract,
+ 'contract_party' => $party,
+ 'contract_dates' =>
$contract_dates,
+ 'composite' => $composite,
+ 'unit' => $unit,
+ 'price_items' =>$price_items,
+ 'notification' => $notification,
+ 'editable' => $editable,
+ 'message' => isset($message) ?
$message : phpgw::get_var('message'),
+ 'error' => isset($error) ?
$error : phpgw::get_var('error'),
+ 'cancel_link' => $cancel_link,
+ 'cancel_text' => $cancel_text
+
+ );
+ $contract->check_consistency();
+
+
+ //
$this->render('pdf/rental_contract_form_hybler.php', $data);
+
$this->render('pdf/rental_contract_form_personalbolig.php', $data);
+ }
+ }
+ else
+ {
+ if($this->isAdministrator() ||
$this->isExecutiveOfficer()){
+ if(!isset($contract)){
+ $contract = new
rental_contract();
+ $fields =
rental_socontract::get_instance()->get_fields_of_responsibility();
+
$contract->set_location_id($location_id);
+
$contract->set_contract_type_title($fields[$location_id]);
+ }
+ if ($contract) {
+ $data = array
+ (
+ 'contract' =>
$contract,
+ 'notification' =>
$notification,
+ 'editable' => true,
+ 'message' =>
isset($message) ? $message : phpgw::get_var('message'),
+ 'error' =>
isset($error) ? $error : phpgw::get_var('error'),
+ 'cancel_link' =>
$cancel_link,
+ 'cancel_text' =>
$cancel_text
+ );
+ $this->render('contract.php',
$data);
+ }
+ }
+ else
+ {
+
$this->render('permission_denied.php',array('error' =>
lang('permission_denied_new_contract')));
+ return;
+ }
+ }
+ }
+
+ /**
+ * View a contract
+ */
+ public function view()
+ {
+ $GLOBALS['phpgw_info']['flags']['app_header'] .=
'::'.lang('view');
+ $contract_id = (int)phpgw::get_var('id');
+ return $this->viewedit(false, $contract_id);
+ }
+
+ /**
+ * Save a contract as PDF
+ */
+ public function makePDF()
+ {
+
+ $myFile = "/opt/portico/pe/rental/tmp/testFile.html";
+ $fh = fopen($myFile, 'w') or die("can't open file");
+ $stringData = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML
4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
+ fwrite($fh, $stringData);
+ $stringData = '<html><head><meta
http-equiv="Content-Type" content="text/html;
charset=UTF-8"><title></title></head><body>';
+ fwrite($fh, $stringData);
+ $stringData = $_SESSION['contract_html'];
+ fwrite($fh, $stringData);
+ $stringData = '</div></body></html>';
+ fwrite($fh, $stringData);
+ fclose($fh);
+ echo $_SESSION['contract_html'];
+ $_SESSION['contract_html'] = "";
+
+ $snappy = new SnappyPdf;
+
$snappy->setExecutable('/opt/portico/pe/rental/wkhtmltopdf-i386'); // or
whatever else
+
$snappy->save('/opt/portico/pe/rental/tmp/testFile.html',
'/opt/portico/pe/rental/tmp/testFile.pdf');
+ }
+
+ /**
+ * Edit a contract
+ */
+ public function edit()
+ {
+ $GLOBALS['phpgw_info']['flags']['app_header'] .=
'::'.lang('edit');
+ $contract_id = (int)phpgw::get_var('id');
+ $location_id = (int)phpgw::get_var('location_id');
+ $update_price_items = false;
+
+ $message = null;
+ $error = null;
+ $add_default_price_items = false;
+
+ if(isset($_POST['save_contract']))
+ {
+ if(isset($contract_id) && $contract_id > 0)
+ {
+ $contract =
rental_socontract::get_instance()->get_single($contract_id);
+
if(!$contract->has_permission(PHPGW_ACL_EDIT))
+ {
+ unset($contract);
+
$this->render('permission_denied.php',array('error' =>
lang('permission_denied_edit_contract')));
+ }
+ }
+ else
+ {
+ if(isset($location_id) &&
($this->isExecutiveOfficer() || $this->isAdministrator())){
+ $contract = new
rental_contract();
+ $fields =
rental_socontract::get_instance()->get_fields_of_responsibility();
+
$contract->set_location_id($location_id);
+
$contract->set_contract_type_title($fields[$location_id]);
+ $add_default_price_items = true;
+ }
+ }
+
+ $date_start =
strtotime(phpgw::get_var('date_start_hidden'));
+ $date_end =
strtotime(phpgw::get_var('date_end_hidden'));
+
+ if(isset($contract)){
+ $contract->set_contract_date(new
rental_contract_date($date_start, $date_end));
+
$contract->set_security_type(phpgw::get_var('security_type'));
+
$contract->set_security_amount(phpgw::get_var('security_amount'));
+
$contract->set_executive_officer_id(phpgw::get_var('executive_officer'));
+
$contract->set_comment(phpgw::get_var('comment'));
+
+ if(isset($location_id) && $location_id
> 0)
+ {
+
$contract->set_location_id($location_id); // only present when new contract
+ }
+
$contract->set_term_id(phpgw::get_var('billing_term'));
+
$contract->set_billing_start_date(strtotime(phpgw::get_var('billing_start_date_hidden')));
+
$contract->set_service_id(phpgw::get_var('service_id'));
+
$contract->set_responsibility_id(phpgw::get_var('responsibility_id'));
+
$contract->set_reference(phpgw::get_var('reference'));
+
$contract->set_invoice_header(phpgw::get_var('invoice_header'));
+
$contract->set_account_in(phpgw::get_var('account_in'));
+
+ /*
+ if($contract->get_contract_type_id() !=
phpgw::get_var('contract_type'))
+ {
+ // New contract type id set,
retrieve correct account out
+ $type_id =
phpgw::get_var('contract_type');
+ if(isset($type_id) && $type_is
!= ''){
+ $account =
rental_socontract::get_instance()->get_contract_type_account($type_id);
+
$contract->set_account_out($account);
+ }
+ else
+ {
+
$contract->set_account_out(phpgw::get_var('account_out'));
+ }
+ }
+ else
+ {*/
+
$contract->set_account_out(phpgw::get_var('account_out'));
+ //}
+
+
$contract->set_project_id(phpgw::get_var('project_id'));
+
$contract->set_due_date(strtotime(phpgw::get_var('due_date_hidden')));
+
$contract->set_contract_type_id(phpgw::get_var('contract_type'));
+ $old_rented_area =
$contract->get_rented_area();
+ $new_rented_area =
phpgw::get_var('rented_area');
+ $new_rented_area =
str_replace(',','.',$new_rented_area);
+ $validated_numeric=false;
+ if(!isset($new_rented_area) ||
$new_rented_area == ''){
+ $new_rented_area = 0;
+ }
+ if($old_rented_area !=
$new_rented_area){
+ $update_price_items = true;
+ }
+
$contract->set_rented_area($new_rented_area);
+
$contract->set_adjustment_interval(phpgw::get_var('adjustment_interval'));
+
$contract->set_adjustment_share(phpgw::get_var('adjustment_share'));
+
$contract->set_adjustable(phpgw::get_var('adjustable') == 'on' ? true : false);
+
$contract->set_publish_comment(phpgw::get_var('publish_comment') == 'on' ? true
: false);
+ $validated_numeric =
$contract->validate_numeric();
+
+ if($validated_numeric){
+ $so_contract =
rental_socontract::get_instance();
+ $db_contract =
$so_contract->get_db();
+
$db_contract->transaction_begin();
+
if($so_contract->store($contract))
+ {
+ if($update_price_items){
+ $success =
$so_contract->update_price_items($contract->get_id(), $new_rented_area);
+ if($success){
+
$db_contract->transaction_commit();
+
$message = lang('messages_saved_form');
+
$contract_id = $contract->get_id();
+ }
+ else{
+
$db_contract->transaction_abort();
+ $error
= lang('messages_form_error');
+ }
+ }
+ else
if($add_default_price_items)
+ {
+ $so_price_item
= rental_soprice_item::get_instance();
+ //get default
price items for location_id
+
$default_price_items =
$so_contract->get_default_price_items($contract->get_location_id());
+
+ //add
price_items to contract
+
foreach($default_price_items as $price_item_id)
+ {
+
$so_price_item->add_price_item($contract->get_id(), $price_item_id);
+ }
+
$db_contract->transaction_commit();
+ $message =
lang('messages_saved_form');
+ $contract_id =
$contract->get_id();
+ }
+ else{
+
$db_contract->transaction_commit();
+ $message =
lang('messages_saved_form');
+ $contract_id =
$contract->get_id();
+ }
+ }
+ else
+ {
+
$db_contract->transaction_abort();
+ $error =
lang('messages_form_error');
+ }
+ }
+ else{
+ $error =
$contract->get_validation_errors();
+ return $this->viewedit(true,
$contract_id, $contract, $location_id,$notification, $message, $error);
+ }
+ }
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'rental.uicontract.edit', 'id' => $contract->get_id(),
'message' => $message, 'error' => $error));
+ }
+ else if(isset($_POST['add_notification']))
+ {
+ $contract =
rental_socontract::get_instance()->get_single($contract_id);
+ if($contract->has_permission(PHPGW_ACL_EDIT))
+ {
+ $account_id =
phpgw::get_var('notification_target');
+ $location_id =
phpgw::get_var('notification_location');
+ $date =
phpgw::get_var('date_notification_hidden');
+ if($date)
+ {
+ $date = strtotime($date);
+ }
+ $notification = new
rental_notification(-1, $account_id, $location_id, $contract_id, $date,
phpgw::get_var('notification_message'),
phpgw::get_var('notification_recurrence'));
+ if
(rental_sonotification::get_instance()->store($notification))
+ {
+ $message =
lang('messages_saved_form');
+ $notification = null; // We
don't want to display the date/message when it was sucessfully stored.
+ }
+ else
+ {
+
+ $error =
lang('messages_form_error');
+ }
+ }
+ else
+ {
+ $error =
lang('permission_denied_edit_contract');
+ }
+ }
+ return $this->viewedit(true, $contract_id, null,
$location_id,$notification, $message, $error);
+ }
+
+ /**
+ * Create a new empty contract
+ */
+ public function add()
+ {
+ $location_id = phpgw::get_var('location_id');
+ if(isset($location_id) && $location_id > 0)
+ {
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'rental.uicontract.edit', 'location_id' => $location_id));
+ }
+ }
+
+ /**
+ * Create a new contract tied to the composite provided in the
composite_id parameter
+ */
+ public function add_from_composite()
+ {
+ $contract = new rental_contract();
+
$contract->set_location_id(phpgw::get_var('responsibility_id'));
+ if($contract->has_permission(PHPGW_ACL_EDIT))
+ {
+ $so_contract =
rental_socontract::get_instance();
+ $db_contract = $so_contract->get_db();
+ $db_contract->transaction_begin();
+ if($so_contract->store($contract))
+ {
+ // Add that composite to the new
contract
+ $success =
$so_contract->add_composite($contract->get_id(), phpgw::get_var('id'));
+ if($success){
+
$db_contract->transaction_commit();
+ $comp_name =
rental_socomposite::get_instance()->get_single(phpgw::get_var('id'))->get_name();
+ $message =
lang('messages_new_contract_from_composite').' '.$comp_name;
+
+
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'rental.uicontract.edit', 'id' => $contract->get_id(), 'message' => $message));
+ }
+ else{
+
$db_contract->transaction_abort();
+
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'rental.uicontract.edit', 'id' => $contract->get_id(), 'message' =>
lang('messages_form_error')));
+ }
+ }
+ else
+ {
+ $db_contract->transaction_abort();
+
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'rental.uicontract.edit', 'id' => $contract->get_id(), 'message' =>
lang('messages_form_error')));
+ }
+ }
+
+ // If no executive officer
+ $this->render('permission_denied.php',array('error' =>
lang('permission_denied_new_contract')));
+ }
+
+ /**
+ * Create a new contract based on an existing contract
+ */
+ public function copy_contract()
+ {
+ $adjustment_id = (int)phpgw::get_var('adjustment_id');
+
+ $so_contract = rental_socontract::get_instance();
+ $contract =
$so_contract->get_single(phpgw::get_var('id'));
+ $old_contract_old_id = $contract->get_old_contract_id();
+ $db_contract = $so_contract->get_db();
+ if($contract->has_permission(PHPGW_ACL_EDIT))
+ {
+ $db_contract->transaction_begin();
+ //reset id's and contract dates
+ $contract->set_id(null);
+ $contract->set_old_contract_id(null);
+ $contract->set_contract_date(null);
+ $contract->set_due_date(null);
+ $contract->set_billing_start_date(null);
+ if($so_contract->store($contract))
+ {
+ // copy the contract
+ $success =
$so_contract->copy_contract($contract->get_id(), phpgw::get_var('id'));
+ if($success){
+
$db_contract->transaction_commit();
+ $message =
lang(messages_new_contract_copied).' '.$old_contract_old_id;
+
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'rental.uicontract.edit', 'id' => $contract->get_id(), 'message' => $message,
'adjustment_id' => $adjustment_id));
+ }
+ else{
+
$db_contract->transaction_abort();
+
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'rental.uicontract.edit', 'id' => $contract->get_id(), 'message' =>
lang('messages_form_error'),'adjustment_id' => $adjustment_id));
+ }
+ }
+ else
+ {
+ $db_contract->transaction_abort();
+
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'rental.uicontract.edit', 'id' => $contract->get_id(), 'message' =>
lang('messages_form_error'),'adjustment_id' => $adjustment_id));
+ }
+ }
+
+ // If no executive officer
+ $this->render('permission_denied.php',array('error' =>
lang('permission_denied_new_contract')));
+ }
+
+ /**
+ * Public function. Add a party to a contract
+ * @param HTTP::contract_id the contract id
+ * @param HTTP::party_id the party id
+ * @return true if successful, false otherwise
+ */
+ public function add_party(){
+ $contract_id = (int)phpgw::get_var('contract_id');
+ $party_id = (int)phpgw::get_var('party_id');
+ $so_contract = rental_socontract::get_instance();
+ $contract = $so_contract->get_single($contract_id);
+ if($contract->has_permission(PHPGW_ACL_EDIT))
+ {
+ return
$so_contract->add_party($contract_id,$party_id);
+ }
+ return false;
+ }
+
+ /**
+ * Public function. Remove a party from a contract
+ * @param HTTP::contract_id the contract id
+ * @param HTTP::party_id the party id
+ * @return true if successful, false otherwise
+ */
+ public function remove_party(){
+ $contract_id = (int)phpgw::get_var('contract_id');
+ $party_id = (int)phpgw::get_var('party_id');
+ $so_contract = rental_socontract::get_instance();
+ $contract = $so_contract->get_single($contract_id);
+ if($contract->has_permission(PHPGW_ACL_EDIT))
+ {
+ return $so_contract->remove_party($contract_id,
$party_id);
+ }
+ return false;
+ }
+
+ /**
+ * Public function. Set the payer on a contract
+ * @param HTTP::contract_id the contract id
+ * @param HTTP::party_id the party id
+ * @return true if successful, false otherwise
+ */
+ public function set_payer(){
+ $contract_id = (int)phpgw::get_var('contract_id');
+ $party_id = (int)phpgw::get_var('party_id');
+ $so_contract = rental_socontract::get_instance();
+ $contract = $so_contract->get_single($contract_id);
+ if($contract->has_permission(PHPGW_ACL_EDIT))
+ {
+ return
$so_contract->set_payer($contract_id,$party_id);
+ }
+ return false;
+ }
+
+ /**
+ * Public function. Add a composite to a contract.
+ * @param HTTP::contract_id the contract id
+ * @param HTTP::composite_id the composite id
+ * @return boolean true if successful, false otherwise
+ */
+ public function add_composite(){
+ $contract_id = (int)phpgw::get_var('contract_id');
+ $composite_id = (int)phpgw::get_var('composite_id');
+ $so_contract = rental_socontract::get_instance();
+ $contract = $so_contract->get_single($contract_id);
+ if($contract->has_permission(PHPGW_ACL_EDIT))
+ {
+ return
$so_contract->add_composite($contract_id, $composite_id);
+ }
+ return false;
+ }
+
+ /**
+ * Public function. Remove a composite from a contract.
+ * @param HTTP::contract_id the contract id
+ * @param HTTP::composite_id the composite id
+ * @return boolean true if successful, false otherwise
+ */
+ public function remove_composite(){
+ $contract_id = (int)phpgw::get_var('contract_id');
+ $composite_id = (int)phpgw::get_var('composite_id');
+ $so_contract = rental_socontract::get_instance();
+ $contract = $so_contract->get_single($contract_id);
+ if(isset($contract) &&
$contract->has_permission(PHPGW_ACL_EDIT))
+ {
+ return
$so_contract->remove_composite($contract_id, $composite_id);
+ }
+ return false;
+ }
+
+ /**
+ * Public function. Add a price item to a contract
+ * @param HTTP::contract_id the contract id
+ * @param HTTP::price_item_id the price item id
+ * @return boolean true if successful, false otherwise
+ */
+ public function add_price_item()
+ {
+ $contract_id = (int)phpgw::get_var('contract_id');
+ $price_item_id = (int)phpgw::get_var('price_item_id');
+ $so_contract = rental_socontract::get_instance();
+ $contract = $so_contract->get_single($contract_id);
+ if($contract->has_permission(PHPGW_ACL_EDIT))
+ {
+ return
rental_soprice_item::get_instance()->add_price_item($contract_id,
$price_item_id);
+ }
+ return false;
+ }
+
+ /**
+ * Public function. Remove a price item from a contract
+ * @param HTTP::contract_id the contract id
+ * @param HTTP::price_item_id the price item id
+ * @return boolean true if successful, false otherwise
+ */
+ public function remove_price_item()
+ {
+ $contract_id = (int)phpgw::get_var('contract_id');
+ $price_item_id = (int)phpgw::get_var('price_item_id');
+ $so_contract = rental_socontract::get_instance();
+ $contract = $so_contract->get_single($contract_id);
+ if($contract->has_permission(PHPGW_ACL_EDIT))
+ {
+ return
rental_soprice_item::get_instance()->remove_price_item($contract_id,
$price_item_id);
+ }
+ return false;
+ }
+
+ /**
+ * Public function. Reset a price item on a contract
+ * @param HTTP::contract_id the contract id
+ * @param HTTP::price_item_id the price item id
+ * @return boolean true if successful, false otherwise
+ */
+ public function reset_price_item()
+ {
+ $contract_id = (int)phpgw::get_var('contract_id');
+ $price_item_id = (int)phpgw::get_var('price_item_id');
+ $so_contract = rental_socontract::get_instance();
+ $contract = $so_contract->get_single($contract_id);
+ if($contract->has_permission(PHPGW_ACL_EDIT))
+ {
+ return
rental_soprice_item::get_instance()->reset_contract_price_item($price_item_id);
+ }
+ return false;
+ }
+
+ public function get_total_price(){
+ $so_contract = rental_socontract::get_instance();
+ $so_contract_price_item =
rental_socontract_price_item::get_instance();
+
+ $contract_id = (int)phpgw::get_var('contract_id');
+ $total_price =
$so_contract_price_item->get_total_price($contract_id);
+ $contract = $so_contract->get_single($contract_id);
+ $area = $contract->get_rented_area();
+
+ if(isset($area) && $area > 0)
+ {
+ $price_per_unit = $total_price / $area;
+ }
+
+ $result_array = array('total_price' => $total_price,
'area' => $area, 'price_per_unit' => $price_per_unit);
+ $result_data = array('results' => $result_array,
'total_records' => 1);
+ return $this->yui_results($result_data,
'total_records', 'results');
+ }
+
+ public function get_max_area(){
+ $contract_id = (int)phpgw::get_var('contract_id');
+ $total_price =
rental_socontract_price_item::get_instance()->get_max_area($contract_id);
+ $result_array = array('max_area' => $max_area);
+ $result_data = array('results' => $result_array,
'total_records' => 1);
+ return $this->yui_results($result_data,
'total_records', 'results');
+ }
+ }
+?>
Modified: branches/Version-1_0-branch/rental/setup/phpgw_no.lang
===================================================================
--- branches/Version-1_0-branch/rental/setup/phpgw_no.lang 2011-02-23
09:22:30 UTC (rev 7035)
+++ branches/Version-1_0-branch/rental/setup/phpgw_no.lang 2011-02-23
09:27:06 UTC (rev 7036)
@@ -279,6 +279,7 @@
location_code rental no Enhetsnummer
location_id rental no Intern organisasjonstilknytning
log_in_to_add_notfications rental no Det er bare mulig å legge til
varlser i redigeringsmodus.
+make_pdf rental no Lag PDF for utskrift
manual_adjust_price_item rental no Manuell regulering av
priselement
manual_adjust_price_item_select rental no Velg priselement
manual_adjustment rental no Manuell regulering
Modified:
branches/Version-1_0-branch/rental/templates/base/composite_list_partial.php
===================================================================
---
branches/Version-1_0-branch/rental/templates/base/composite_list_partial.php
2011-02-23 09:22:30 UTC (rev 7035)
+++
branches/Version-1_0-branch/rental/templates/base/composite_list_partial.php
2011-02-23 09:27:06 UTC (rev 7036)
@@ -1,5 +1,16 @@
<script type="text/javascript">
- //Add listener resetting form: redirects browser to call index again
+
+function checkAvailabitily()
+{
+ if(document.forms[0].availability_date_to.value == '')
+ {
+ document.forms[0].availability_date_to.value =
document.forms[0].availability_date_from.value;
+ document.forms[0].availability_date_to.value_hidden =
document.forms[0].availability_date_from_hidden.value
+ }
+ return true;
+}
+
+//Add listener resetting form: redirects browser to call index again
YAHOO.util.Event.addListener(
'ctrl_reset_button',
'click',
@@ -38,6 +49,11 @@
sortable: false
},
{
+ key: "status",
+ label: "<?php echo lang('status') ?>",
+ sortable: true
+ },
+ {
key: "actions",
hidden: true
},
@@ -126,7 +142,7 @@
<option value="address" <?php echo ($s_type ==
'address') ? 'selected' : ''?>><?php echo lang('address') ?></option>
<option value="property_id" <?php echo ($s_type ==
'property_id') ? 'selected' : ''?>><?php echo lang('object_number') ?></option>
</select>
- <input type="submit" id="ctrl_search_button" value="<?php echo
lang('search') ?>" />
+ <input type="submit" id="ctrl_search_button" value="<?php echo
lang('search') ?>" onclick="javascript: checkAvailabitily();" />
<input type="button" id="ctrl_reset_button" value="<?php echo
lang('reset') ?>" />
</fieldset>
@@ -135,9 +151,9 @@
<h3><?php echo lang('filters') ?></h3>
<label for="ctrl_toggle_active_rental_composites"><?php echo
lang('availability') ?></label>
<select name="is_active" id="<?php echo $list_id
?>_ctrl_toggle_active_rental_composites">
+ <option value="both" <?php echo ($status == 'both') ?
'selected' : ''?>><?php echo lang('all') ?></option>
<option value="active" <?php echo ($status == 'active')
? 'selected' : ''?>><?php echo lang('in_operation') ?></option>
<option value="non_active" <?php echo ($status ==
'non_active') ? 'selected' : ''?>><?php echo lang('out_of_operation')
?></option>
- <option value="both" <?php echo ($status == 'both') ?
'selected' : ''?>><?php echo lang('all') ?></option>
</select>
<select name="has_contract" id="<?php echo $list_id
?>_ctrl_toggle_has_contract_rental_composites">
<option value="both" <?php echo ($status_contract ==
'both') ? 'selected' : ''?>><?php echo lang('all') ?></option>
@@ -145,7 +161,7 @@
<option value="has_no_contract" <?php echo
($status_contract == 'has_no_contract') ? 'selected' : ''?>><?php echo
lang('composite_has_no_contract') ?></option>
</select>
<label for="availability_period"><?php echo
lang('availability_date')?></label>
- <?php echo
$GLOBALS['phpgw']->yuical->add_listener('availability_date',
$availability_date); ?>
+ <?php echo
$GLOBALS['phpgw']->yuical->add_listener('availability_date_from',
$availability_date_from); ?> – <?php echo
$GLOBALS['phpgw']->yuical->add_listener('availability_date_to',
$availability_date_to); ?>
</fieldset>
</form>
<?php
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [7036] Merge 7026:7035 from trunk,
Sigurd Nes <=