[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [8850] Merge 8842:8848 from trunk
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [8850] Merge 8842:8848 from trunk |
Date: |
Mon, 13 Feb 2012 13:45:40 +0000 |
Revision: 8850
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8850
Author: sigurdne
Date: 2012-02-13 13:45:39 +0000 (Mon, 13 Feb 2012)
Log Message:
-----------
Merge 8842:8848 from trunk
Modified Paths:
--------------
branches/Version-1_0-branch/controller/inc/class.uicase.inc.php
branches/Version-1_0-branch/controller/inc/class.uicontrol_location.inc.php
branches/Version-1_0-branch/controller/inc/helper/class.status_checker.inc.php
branches/Version-1_0-branch/controller/js/controller/ajax.js
branches/Version-1_0-branch/controller/setup/phpgw_no.lang
branches/Version-1_0-branch/controller/templates/base/check_list/view_open_cases.xsl
branches/Version-1_0-branch/controller/templates/base/control_location/register_control_to_location.xsl
branches/Version-1_0-branch/controller/templates/base/control_location/view_locations_for_control.xsl
branches/Version-1_0-branch/controller/templates/base/css/base.css
branches/Version-1_0-branch/rental/inc/class.socontract.inc.php
branches/Version-1_0-branch/rental/templates/base/contract_list.php
Property Changed:
----------------
branches/Version-1_0-branch/
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,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332,7334-7338,7340-7348,7350,7352-7353,7355-7361,7363-7366,7368-7370,7372,7374,7376,7378,7380-7386,7388-7400,7402,7404-7433,7435-7439,7441-7446,7448-7458,7460-7469,7471-7483,7485-7487,7489-7490,7492,7494,7496-7497,7499,7501-7502,7504,7506-7507,7509-7511,7513-7517,7519-7521,7523,7525,7527-7529,7531,7533,7535-7538,7540-7542,7544-7549,7551-7552,7554-7561,7563,7565,7567-7573,7575-7578,7580-7584,7586-7591,7593-7624,7627-7636,7638-7656,7658-7718,7720-7732,7734,7736,7738-7750,7754-7759,7761-7767,7769-7780,7782,7784-7809,7811-7812,7814-7835,7837-7847,7849-7887,7889-7895,7897,7899,7901,7903-7905,7907-7921,7923-7925,7927-7933,7935,7937-7952,7954-7968,7970-7974,7976,7978-7979,7981-7982,7984-7988,7990-7992,7994-8041,8043-8066,8068-8087,8089,8091-8108,8110-8124,8126-8129,8131,8133-8150,8152-8154,8156-8162,8164-8167,8169-8170,8172-8179,8181,8183-8196,8198-8207,8209-8211,8213-8214,8216-8217,8219-8220,8222,8224-8225,8227-8247,8249,8251,8253-8282,8284-8352,8354-8368,8370-8396,8398-8430,8432,8434-8440,8442-8445,8447-8453,8455-8456,8458,8460,8462-8464,8466-8473,8475-8479,8481,8483-8501,8503-8523,8525,8527-8531,8533,8535-8536,8538-8550,8552-8554,8556-8557,8559-8579,8581-8587,8589,8591-8592,8594-8595,8597-8601,8603-8610,8612-8613,8615,8617,8619-8645,8647-8650,8652-8661,8663-8666,8668-8669,8671-8683,8685-8691,8693-8730,8732-8737,8739,8741-8767,8769,8771-8772,8774,8776-8797,8799-8812,8814-8819,8821,8823-8833,8835-8837,8839,8841
+
/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,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332,7334-7338,7340-7348,7350,7352-7353,7355-7361,7363-7366,7368-7370,7372,7374,7376,7378,7380-7386,7388-7400,7402,7404-7433,7435-7439,7441-7446,7448-7458,7460-7469,7471-7483,7485-7487,7489-7490,7492,7494,7496-7497,7499,7501-7502,7504,7506-7507,7509-7511,7513-7517,7519-7521,7523,7525,7527-7529,7531,7533,7535-7538,7540-7542,7544-7549,7551-7552,7554-7561,7563,7565,7567-7573,7575-7578,7580-7584,7586-7591,7593-7624,7627-7636,7638-7656,7658-7718,7720-7732,7734,7736,7738-7750,7754-7759,7761-7767,7769-7780,7782,7784-7809,7811-7812,7814-7835,7837-7847,7849-7887,7889-7895,7897,7899,7901,7903-7905,7907-7921,7923-7925,7927-7933,7935,7937-7952,7954-7968,7970-7974,7976,7978-7979,7981-7982,7984-7988,7990-7992,7994-8041,8043-8066,8068-8087,8089,8091-8108,8110-8124,8126-8129,8131,8133-8150,8152-8154,8156-8162,8164-8167,8169-8170,8172-8179,8181,8183-8196,8198-8207,8209-8211,8213-8214,8216-8217,8219-8220,8222,8224-8225,8227-8247,8249,8251,8253-8282,8284-8352,8354-8368,8370-8396,8398-8430,8432,8434-8440,8442-8445,8447-8453,8455-8456,8458,8460,8462-8464,8466-8473,8475-8479,8481,8483-8501,8503-8523,8525,8527-8531,8533,8535-8536,8538-8550,8552-8554,8556-8557,8559-8579,8581-8587,8589,8591-8592,8594-8595,8597-8601,8603-8610,8612-8613,8615,8617,8619-8645,8647-8650,8652-8661,8663-8666,8668-8669,8671-8683,8685-8691,8693-8730,8732-8737,8739,8741-8767,8769,8771-8772,8774,8776-8797,8799-8812,8814-8819,8821,8823-8833,8835-8837,8839,8841,8843-8848
Modified: branches/Version-1_0-branch/controller/inc/class.uicase.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicase.inc.php
2012-02-13 13:34:42 UTC (rev 8849)
+++ branches/Version-1_0-branch/controller/inc/class.uicase.inc.php
2012-02-13 13:45:39 UTC (rev 8850)
@@ -52,7 +52,8 @@
'register_case_message' => true,
'register_measurement_case' => true,
'updateStatusForCases' => true,
-
'delete_case' => true
+
'delete_case' => true,
+
'close_case' => true
);
function __construct()
@@ -399,5 +400,25 @@
return json_encode( array( "status" =>
"not_deleted" ) );
}
+ public function close_case()
+ {
+ $case_id = phpgw::get_var('case_id');
+ $check_list_id = phpgw::get_var('check_list_id');
+
+ $case = $this->so->get_single($case_id);
+ $case->set_status(1);
+
+ $case_id = $this->so->store($case);
+
+ if($case_id > 0){
+ $status_checker = new status_checker();
+ $status_checker->update_check_list_status(
$check_list_id );
+
+ return json_encode( array( "status" => "closed"
) );
+ }
+ else
+ return json_encode( array( "status" =>
"not_closed" ) );
+ }
+
public function query(){}
}
Modified:
branches/Version-1_0-branch/controller/inc/class.uicontrol_location.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicontrol_location.inc.php
2012-02-13 13:34:42 UTC (rev 8849)
+++ branches/Version-1_0-branch/controller/inc/class.uicontrol_location.inc.php
2012-02-13 13:45:39 UTC (rev 8850)
@@ -61,7 +61,9 @@
'view_locations_for_control' => true,
'register_control_to_location' => true,
'register_control_to_location_2' => true,
-
'get_locations_for_control' => true
+
'get_locations_for_control' => true,
+
'get_location_category' => true,
+
'get_district_part_of_town' => true
);
function __construct()
@@ -224,7 +226,8 @@
return $this->query();
}
$building_types =
execMethod('property.soadmin_location.read',array());
-
+ //$type_id=phpgw::get_var('type_id');
+ //if(!isset($type_id))
$type_id = 1;
$category_types =
$this->bocommon->select_category_list(array(
@@ -234,7 +237,9 @@
'type_id' =>$type_id,
'order'=>'descr'
));
-
+ $default_value = array
('id'=>'','name'=>lang('no category selected'));
+ array_unshift($category_types,$default_value);
+
$district_list =
$this->bocommon->select_district_list('filter',$this->district_id);
$default_value = array
('id'=>'','name'=>lang('no district'));
array_unshift($district_list,$default_value);
@@ -381,6 +386,7 @@
public function query(){
$type_id = phpgw::get_var('type_id');
+ //var_dump($type_id);
$view_type = phpgw::get_var('view_type');
$return_results = phpgw::get_var('results', 'int',
'REQUEST', 0);
@@ -393,7 +399,7 @@
$location_list = $this->bo->read(array('user_id' =>
$user_id, 'role_id' =>$role_id,
'type_id'=>$type_id,'lookup_tenant'=>$lookup_tenant,
'lookup'=>$lookup,'allrows'=>$this->allrows,'dry_run'
=>$dry_run));
-
+//_debug_array($location_list);
$rows_total = $this->bo->read(array('type_id' =>
$type_id, 'allrows' => true));
foreach($location_list as $location)
@@ -447,4 +453,35 @@
$value['parameters'][] = "control_id";
*/
}
- }
+
+ /*
+ * Return categories based on chosen location
+ */
+ public function get_location_category()
+ {
+ $type_id = phpgw::get_var('type_id');
+ $category_types =
$this->bocommon->select_category_list(array(
+
'format'=>'filter',
+
'selected' => 0,
+
'type'
=>'location',
+
'type_id'
=>$type_id,
+
'order'=>'descr'
+
));
+ $default_value = array ('id'=>'','name'=>lang('no
category selected'));
+ array_unshift($category_types,$default_value);
+ return json_encode( $category_types );
+ }
+
+ /*
+ * Return parts of town based on chosen district
+ */
+ public function get_district_part_of_town()
+ {
+ $district_id = phpgw::get_var('district_id');
+ $part_of_town_list =
$this->bocommon->select_part_of_town('filter',null,$district_id);
+ $default_value = array ('id'=>'','name'=>lang('no part
of town'));
+ array_unshift($part_of_town_list,$default_value);
+
+ return json_encode( $part_of_town_list );
+ }
+ }
\ No newline at end of file
Modified:
branches/Version-1_0-branch/controller/inc/helper/class.status_checker.inc.php
===================================================================
---
branches/Version-1_0-branch/controller/inc/helper/class.status_checker.inc.php
2012-02-13 13:34:42 UTC (rev 8849)
+++
branches/Version-1_0-branch/controller/inc/helper/class.status_checker.inc.php
2012-02-13 13:45:39 UTC (rev 8850)
@@ -24,15 +24,16 @@
$num_open_cases = 0;
$num_pending_cases = 0;
-
+
foreach($check_items as $check_item){
foreach($check_item->get_cases_array() as $case){
- if($case->get_status() == 0 |
$case->get_status() == 2){
+ if($case->get_status() == 0){
$num_open_cases++;
}
- else if($case->get_status() == 2){
+
+ if($case->get_status() == 2){
$num_pending_cases++;
}
}
Modified: branches/Version-1_0-branch/controller/js/controller/ajax.js
===================================================================
--- branches/Version-1_0-branch/controller/js/controller/ajax.js
2012-02-13 13:34:42 UTC (rev 8849)
+++ branches/Version-1_0-branch/controller/js/controller/ajax.js
2012-02-13 13:45:39 UTC (rev 8850)
@@ -1,7 +1,7 @@
$(document).ready(function(){
// file: uicalendar.xsl
- $("#choose_my_location option").click(function () {
+ $("#choose_my_location").change(function () {
var location_code = $(this).val();
var thisForm = $(this).parents("form");
@@ -27,10 +27,74 @@
window.location.href = requestUrl;
});
+ //update location category based on location type
+ //file:
+ $("#type_id").change(function () {
+ var location_type_id = $(this).val();
+ var oArgs =
{menuaction:'controller.uicontrol_location.get_location_category'};
+ var requestUrl = phpGWLink('index.php', oArgs, true);
+ //var requestUrl =
"index.php?menuaction=controller.uicontrol.get_controls_by_control_area&phpgw_return_as=json"
+
+ var htmlString = "";
+
+ $.ajax({
+ type: 'POST',
+ dataType: 'json',
+ url: requestUrl + "&type_id=" + location_type_id,
+ success: function(data) {
+ if( data != null){
+ var obj = jQuery.parseJSON(data);
+
+ $.each(obj, function(i) {
+ htmlString += "<option
value='" + obj[i].id + "'>" + obj[i].name + "</option>";
+ });
+
+ $("#cat_id").html( htmlString );
+ }else {
+ htmlString += "<option>Ingen
kontroller</option>"
+ $("#cat_id").html( htmlString );
+ }
+ }
+ });
+
+ });
+
+ //update part of town category based on district
+ //file:
+ $("#district_id").change(function () {
+ var district_id = $(this).val();
+ var oArgs =
{menuaction:'controller.uicontrol_location.get_district_part_of_town'};
+ var requestUrl = phpGWLink('index.php', oArgs, true);
+ //var requestUrl =
"index.php?menuaction=controller.uicontrol.get_controls_by_control_area&phpgw_return_as=json"
+
+ var htmlString = "";
+
+ $.ajax({
+ type: 'POST',
+ dataType: 'json',
+ url: requestUrl + "&district_id=" + district_id,
+ success: function(data) {
+ if( data != null){
+ var obj = jQuery.parseJSON(data);
+
+ $.each(obj, function(i) {
+ htmlString += "<option
value='" + obj[i].id + "'>" + obj[i].name + "</option>";
+ });
+
+ $("#part_of_town_id").html(
htmlString );
+ }else {
+ htmlString += "<option>Ingen
kontroller</option>"
+ $("#part_of_town_id").html( htmlString
);
+ }
+ }
+ });
+
+ });
+
// file: uicheck_list.xsl
// When control area is selected, controls are fetched from db and
control select list is populated
- $("#control_area_list option").click(function () {
- var control_area_id = $(this).val();
+ $("#control_area_list").change(function () {
+ var control_area_id = $(this).val();
var oArgs =
{menuaction:'controller.uicontrol.get_controls_by_control_area',
phpgw_return_as:'json'};
var requestUrl = phpGWLink('index.php', oArgs, true);
//var requestUrl =
"index.php?menuaction=controller.uicontrol.get_controls_by_control_area&phpgw_return_as=json"
@@ -43,6 +107,7 @@
url: requestUrl + "&control_area_id=" +
control_area_id,
success: function(data) {
if( data != null){
+ htmlString = "<option>Velg
kontroll</option>"
var obj = jQuery.parseJSON(data);
$.each(obj, function(i) {
@@ -61,7 +126,7 @@
// file: uicheck_list.xsl
// When control area is selected, controls are fetched from db and
control select list is populated
- $("#control_group_area_list option").click(function () {
+ $("#control_group_area_list").change(function () {
var control_area_id = $(this).val();
var oArgs =
{menuaction:'controller.uicontrol_group.get_control_groups_by_control_area',
phpgw_return_as:'json'};
var requestUrl = phpGWLink('index.php', oArgs, true);
@@ -76,6 +141,7 @@
url: requestUrl + "&control_area_id=" +
control_area_id,
success: function(data) {
if( data != null){
+ htmlString = "<option>Velg
kontroll</option>"
var obj = jQuery.parseJSON(data);
$.each(obj, function(i) {
@@ -95,7 +161,7 @@
// file: add_component_to_control.xsl
// When component category is selected, corresponding component types
are fetched from db and component type select list is populated
- $("#ifc option").click(function () {
+ $("#ifc").change(function () {
var ifc_id = $(this).val();
var oArgs =
{menuaction:'controller.uicheck_list_for_component.get_component_types_by_category',
phpgw_return_as:'json'};
@@ -110,6 +176,7 @@
url: requestUrl + "&ifc=" + ifc_id,
success: function(data) {
if( data != null){
+ htmlString = "<option>Velg
type</option>"
var obj = jQuery.parseJSON(data);
$.each(obj, function(i) {
@@ -128,7 +195,7 @@
// file: control.xsl
// When control area is selected, procedures are fetched from db and
procedure select list is populated
- $("#control_area_id option").click(function () {
+ $("#control_area_id").change(function () {
var control_area_id = $(this).val();
var oArgs =
{menuaction:'controller.uiprocedure.get_procedures'};
@@ -143,6 +210,7 @@
url: requestUrl + "&control_area_id=" +
control_area_id,
success: function(data) {
if( data != null){
+ htmlString = "<option>Velg
prosedyre</option>"
var obj = jQuery.parseJSON(data);
$.each(obj, function(i) {
@@ -453,18 +521,19 @@
success: function(data) {
if(data){
var jsonObj = jQuery.parseJSON(data);
-
+
if(jsonObj.status == "saved"){
- var case_id = "#case_" +
jsonObj.case.id;
- var case_descr = jsonObj.case.descr;
+ // var case_id = "#case_" +
jsonObj.case.id;
+ // var case_descr = jsonObj.case.descr;
$(case_id).show();
$(case_id).find(".case_descr").text(case_descr);
- $(thisForm).parents("li").remove();
+
$(thisForm).parents("li.quick_edit").remove();
}
}
- }
+ }
});
+
});
$("a.quick_edit").live("click", function(e){
@@ -546,6 +615,47 @@
return false;
});
+ // Closes a case
+ $(".close_case").live("click", function(){
+ var clickElem = $(this);
+ var clickRow = $(this).closest("li");
+ var clickItem = $(this).closest("ul");
+ var checkItemRow = $(this).parents("li.check_item_case");
+
+ var url = $(clickElem).attr("href");
+
+ // Sending request for deleting a control item list
+ $.ajax({
+ type: 'POST',
+ url: url,
+ success: function(data) {
+ var obj = jQuery.parseJSON(data);
+
+ if(obj.status == "closed"){
+ if( $(clickItem).children("li").length
> 1){
+ $(clickRow).fadeOut(300,
function(){
+ $(clickRow).remove();
+ });
+
+ var next_row =
$(clickRow).next();
+
+ // Updating order numbers for
rows below deleted row
+ while( $(next_row).length > 0){
+
update_order_nr_for_row(next_row, "-");
+ next_row =
$(next_row).next();
+ }
+ }else{
+ $(checkItemRow).fadeOut(300,
function(){
+
$(checkItemRow).remove();
+ });
+ }
+ }
+ }
+ });
+
+ return false;
+ });
+
$("#frm_update_check_list").live("click", function(e){
var thisForm = $(this);
var submitBnt = $(thisForm).find("input[type='submit']");
@@ -568,8 +678,7 @@
var thisForm = $(this);
var submitBnt = $(thisForm).find("input[type='submit']");
$(submitBnt).removeClass("not_active");
- });
-
+ });
});
function clear_form( form ){
Modified: branches/Version-1_0-branch/controller/setup/phpgw_no.lang
===================================================================
--- branches/Version-1_0-branch/controller/setup/phpgw_no.lang 2012-02-13
13:34:42 UTC (rev 8849)
+++ branches/Version-1_0-branch/controller/setup/phpgw_no.lang 2012-02-13
13:45:39 UTC (rev 8850)
@@ -317,4 +317,5 @@
show_controls_for_location controller no Vis lokasjoner
Property name controller no Lokasjonsnavn
Address controller no Adresse
-Zip code controller no Postnummer
\ No newline at end of file
+Zip code controller no Postnummer
+no category selected controller no Kategori ikke valgt
\ No newline at end of file
Modified:
branches/Version-1_0-branch/controller/templates/base/check_list/view_open_cases.xsl
===================================================================
---
branches/Version-1_0-branch/controller/templates/base/check_list/view_open_cases.xsl
2012-02-13 13:34:42 UTC (rev 8849)
+++
branches/Version-1_0-branch/controller/templates/base/check_list/view_open_cases.xsl
2012-02-13 13:45:39 UTC (rev 8850)
@@ -59,6 +59,17 @@
</xsl:attribute>
endre
</a>
+
<a class="close_case">
+
<xsl:attribute name="href">
+
<xsl:text>index.php?menuaction=controller.uicase.close_case</xsl:text>
+
<xsl:text>&case_id=</xsl:text>
+
<xsl:value-of select="id"/>
+
<xsl:text>&check_list_id=</xsl:text>
+
<xsl:value-of select="//check_list/id"/>
+
<xsl:text>&phpgw_return_as=json</xsl:text>
+
</xsl:attribute>
+
lukk
+
</a>
<xsl:choose>
<xsl:when test="location_item_id = 0">
<a class="delete_case">
@@ -139,6 +150,17 @@
</xsl:attribute>
endre
</a>
+
<a class="close_case">
+
<xsl:attribute name="href">
+
<xsl:text>index.php?menuaction=controller.uicase.close_case</xsl:text>
+
<xsl:text>&case_id=</xsl:text>
+
<xsl:value-of select="id"/>
+
<xsl:text>&check_list_id=</xsl:text>
+
<xsl:value-of select="//check_list/id"/>
+
<xsl:text>&phpgw_return_as=json</xsl:text>
+
</xsl:attribute>
+
lukk
+
</a>
<xsl:choose>
<xsl:when test="location_item_id = 0">
<a class="delete_case">
Modified:
branches/Version-1_0-branch/controller/templates/base/control_location/register_control_to_location.xsl
===================================================================
---
branches/Version-1_0-branch/controller/templates/base/control_location/register_control_to_location.xsl
2012-02-13 13:34:42 UTC (rev 8849)
+++
branches/Version-1_0-branch/controller/templates/base/control_location/register_control_to_location.xsl
2012-02-13 13:45:39 UTC (rev 8850)
@@ -90,9 +90,6 @@
<ul id="filters">
<li>
<select id="type_id" name="type_id">
- <option value="">
- <xsl:value-of select="php:function('lang',
'Choose_building_type')"/>
- </option>
<xsl:for-each select="building_types">
<xsl:variable
name="building_type_id"><xsl:value-of select="id"/></xsl:variable>
<option value="{$building_type_id}">
@@ -103,9 +100,6 @@
</li>
<li>
<select id="cat_id" name="cat_id">
- <option value="">
- <xsl:value-of select="php:function('lang',
'Choose_building_category')"/>
- </option>
<xsl:for-each select="category_types">
<xsl:variable
name="category_type_id"><xsl:value-of select="id"/></xsl:variable>
<option value="{$category_type_id}">
@@ -116,9 +110,6 @@
</li>
<li>
<select id="district_id" name="district_id">
- <option value="">
- <xsl:value-of
select="php:function('lang', 'Choose_district')"/>
- </option>
<xsl:for-each select="district_list">
<xsl:variable name="district_id"><xsl:value-of
select="id"/></xsl:variable>
<option value="{$district_id}">
@@ -129,9 +120,6 @@
</li>
<li>
<select id="part_of_town_id" name="part_of_town_id">
- <option value="">
- <xsl:value-of
select="php:function('lang', 'Choose_part_of_town')"/>
- </option>
<xsl:for-each select="part_of_town_list">
<xsl:variable
name="part_of_town_id"><xsl:value-of select="id"/></xsl:variable>
<option value="{$part_of_town_id}">
@@ -205,7 +193,6 @@
}
}
- //alert(document.getElementById('control_id').value);
var control_id_value =
document.getElementById('control_id').value;
var returnfield = document.createElement('input');
@@ -218,8 +205,7 @@
control_id_field.setAttribute('name', 'control_id');
control_id_field.setAttribute('type', 'text');
control_id_field.setAttribute('value', control_id_value);
- mydiv.appendChild(control_id_field);
-
+ mydiv.appendChild(control_id_field);
}
]]>
</script>
@@ -261,7 +247,7 @@
var main_source = '<xsl:value-of select="source"/>';
var main_columnDefs = YAHOO.controller.columnDefs;
var main_form = 'queryForm';
- var main_filters = ['type_id', 'cat_id', 'district_id',
'part-of_town_list', 'responsibility_roles_list'];
+ var main_filters = ['type_id', 'cat_id', 'district_id',
'part_of_town_id', 'responsibility_roles_list'];
var main_container = 'datatable-container';
var main_table_id = 'datatable';
var main_pag = 'data_paginator';
Modified:
branches/Version-1_0-branch/controller/templates/base/control_location/view_locations_for_control.xsl
===================================================================
---
branches/Version-1_0-branch/controller/templates/base/control_location/view_locations_for_control.xsl
2012-02-13 13:34:42 UTC (rev 8849)
+++
branches/Version-1_0-branch/controller/templates/base/control_location/view_locations_for_control.xsl
2012-02-13 13:45:39 UTC (rev 8850)
@@ -39,24 +39,22 @@
</select>
<form id="loc_form" action="" method="GET">
-
<select id="control_id"
name="control_id">
- <xsl:choose>
- <xsl:when
test="control_array/child::node()">
- <xsl:for-each
select="control_array">
- <xsl:variable
name="control_id"><xsl:value-of select="id"/></xsl:variable>
- <option
value="{$control_id}">
-
<xsl:value-of select="title"/>
- </option>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <option>
- Ingen kontroller
- </option>
- </xsl:otherwise>
- </xsl:choose>
-
+ <xsl:choose>
+ <xsl:when
test="control_array/child::node()">
+ <xsl:for-each
select="control_array">
+
<xsl:variable name="control_id"><xsl:value-of select="id"/></xsl:variable>
+ <option
value="{$control_id}">
+
<xsl:value-of select="title"/>
+
</option>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <option>
+ Ingen
kontroller
+ </option>
+ </xsl:otherwise>
+ </xsl:choose>
</select>
</form>
</div>
@@ -78,6 +76,7 @@
<xsl:apply-templates select="locations_table"/>
<xsl:call-template name="yui_booking_i18n"/>
+
</div>
</div>
</xsl:template>
@@ -123,4 +122,4 @@
</script>
-</xsl:template>
+</xsl:template>
\ No newline at end of file
Modified: branches/Version-1_0-branch/controller/templates/base/css/base.css
===================================================================
--- branches/Version-1_0-branch/controller/templates/base/css/base.css
2012-02-13 13:34:42 UTC (rev 8849)
+++ branches/Version-1_0-branch/controller/templates/base/css/base.css
2012-02-13 13:45:39 UTC (rev 8850)
@@ -829,7 +829,7 @@
font-size:16px;
}
ul.calendar {
- clear: right;
+ clear: both;
float: left;
margin-top: 30px;
width: 100%;
Modified: branches/Version-1_0-branch/rental/inc/class.socontract.inc.php
===================================================================
--- branches/Version-1_0-branch/rental/inc/class.socontract.inc.php
2012-02-13 13:34:42 UTC (rev 8849)
+++ branches/Version-1_0-branch/rental/inc/class.socontract.inc.php
2012-02-13 13:45:39 UTC (rev 8850)
@@ -12,9 +12,7 @@
{
protected static $so;
protected $fields_of_responsibility; // Used for caching the values
- protected $ordermethod;
- protected $order_field;
-
+
/**
* Get a static reference to the storage object associated with this
model object
*
@@ -22,13 +20,12 @@
*/
public static function get_instance()
{
- if (self::$so == null)
- {
+ if (self::$so == null) {
self::$so = CreateObject('rental.socontract');
}
return self::$so;
}
-
+
/**
* Filters:
* Contracts with party as contract party
@@ -43,62 +40,41 @@
* @see rental/inc/rental_socommon#get_query($sort_field, $ascending,
$search_for, $search_type, $filters, $return_count)
*/
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';
if($sort_field == null || $sort_field == '')
{
$sort_field = 'contract.id';
}
- else if ($sort_field == 'party')
- {
+ else if ($sort_field == 'party'){
$sort_field = "party.company_name {$dir},
party.last_name {$dir}, party.first_name";
- $this->order_field = 'party.company_name,
party.last_name, party.first_name';
}
- else if ($sort_field == 'composite')
- {
+ else if ($sort_field == 'composite'){
$sort_field = "composite.name";
- $this->order_field = $sort_field;
}
- else if ($sort_field == 'type')
- {
+ else if ($sort_field == 'type'){
$sort_field = 'contract.location_id';
- $this->order_field = $sort_field;
}
- else if($sort_field == 'term_label')
- {
+ else if($sort_field == 'term_label'){
$sort_field = 'contract.term_id';
- $this->order_field = $sort_field;
}
- else
- {
- $this->order_field = $sort_field;
- }
-
-
+
+
//Contracts for billing should always be sorted on biling start
if(isset($filters['contracts_for_billing']))
{
- $order = "ORDER BY contract.billing_start ASC";
- $this->order_field = 'billing_start';
+ $order = "ORDER BY contract.billing_start ASC";
}
else
{
- switch ($sort_field)
- {
- case 'contract_id':
- $order = "ORDER BY contract.id {$dir}";
- $this->order_field = '';
- break;
- default:
- $order = "ORDER BY {$sort_field}
{$dir}";
- }
+ $order = "ORDER BY {$sort_field} {$dir}";
}
-
+
// Search for based on search type
if($search_for)
{
@@ -106,8 +82,7 @@
$like_pattern = "'%".$search_for."%'";
$int_value_of_search = (int) $search_for;
$like_clauses = array();
- switch($search_type)
- {
+ switch($search_type){
case "id":
$like_clauses[] =
"contract.old_contract_id $this->like $like_pattern";
break;
@@ -126,7 +101,7 @@
$like_clauses[] = "r_u.location_code
like '{$search_for}%'";
break;
case "all":
-
+
$like_clauses[] =
"contract.old_contract_id $this->like $like_pattern";
$like_clauses[] = "contract.comment
$this->like $like_pattern";
$like_clauses[] = "party.first_name
$this->like $like_pattern";
@@ -136,7 +111,7 @@
$like_clauses[] = "r_u.location_code
$this->like $like_pattern";
break;
}
-
+
if($composite_address)
{
$sql_composite_address = "select
rental_composite.id as rc_id from rental_composite,rental_unit,fm_gab_location
where rental_unit.composite_id=rental_composite.id and
fm_gab_location.location_code=rental_unit.location_code and
fm_gab_location.address like upper({$like_pattern})";
@@ -156,77 +131,73 @@
$like_clauses[] = "composite.id in
(-1)";
}
}
-
-
+
+
if(count($like_clauses))
{
$clauses[] = '(' . join(' OR ', $like_clauses)
. ')';
}
+
+
}
-
+
$filter_clauses = array();
-
+
// Contracts with party as contract party
- if(isset($filters['party_id']))
- {
+ if(isset($filters['party_id'])){
$party_id =
$this->marshal($filters['party_id'],'int');
$filter_clauses[] = "party.id = $party_id";
}
-
+
// Contracts for this executive officer
- if(isset($filters['executive_officer']))
- {
+ if(isset($filters['executive_officer'])){
$account_id =
$this->marshal($filters['executive_officer'],'int');
$filter_clauses[] = "contract.executive_officer =
$account_id";
}
// Contracts of type
- if(isset($filters['contract_type']) &&
$filters['contract_type'] != 'all')
- {
+ if(isset($filters['contract_type']) &&
$filters['contract_type'] != 'all'){
$type =
$this->marshal($filters['contract_type'],'field');
$filter_clauses[] = "contract.location_id IN ($type)";
}
-
+
// Contracts with this id (filter for retrieveing a single
contract)
- if(isset($filters[$this->get_id_field_name()]))
- {
+ if(isset($filters[$this->get_id_field_name()])){
$id =
$this->marshal($filters[$this->get_id_field_name()],'int');
$filter_clauses[] = "contract.id = {$id}";
}
-
+
// All contracts with composite as contract composite
if(isset($filters['composite_id']))
- {
+ {
$composite_id =
$this->marshal($filters['composite_id'],'int');
$filter_clauses[] = "composite.id = {$composite_id}";
}
-
+
// Affected contracts by regulation
if(isset($filters['adjustment_interval']) &&
isset($filters['adjustment_year']))
{
$adjustment_interval =
$this->marshal($filters['adjustment_interval'],'int');
$adjustment_year =
$this->marshal($filters['adjustment_year'],'int');
-
- if($filters['adjustment_is_executed'])
- {
+
+ if($filters['adjustment_is_executed']){
$filter_clauses[] = "contract.adjustment_year =
{$adjustment_year}";
}
- else
- {
+ else{
$filter_clauses[] = "contract.adjustment_year +
{$adjustment_interval} <= {$adjustment_year}";
}
-
+
$firstJanAdjYear = mktime(0,0,0,1,1,$adjustment_year);
-
+
//make sure the contracts are active
$filter_clauses[] = "(contract.date_end is null OR
contract.date_end >= {$firstJanAdjYear})";
$filter_clauses[] = "contract.date_start is not null
AND contract.date_start <= {$firstJanAdjYear}";
-
+
$filter_clauses[] = "contract.adjustable IS true";
$filter_clauses[] = "contract.adjustment_interval =
{$adjustment_interval}";
-
+
}
-
+
/*
* Contract status is defined by the dates in each contract
compared to the target date (default today):
* - contracts under planning:
@@ -241,9 +212,8 @@
* - ended:
* the end date is smaller than the target date
*/
- if(isset($filters['contract_status']) &&
$filters['contract_status'] != 'all')
- {
-
+ if(isset($filters['contract_status']) &&
$filters['contract_status'] != 'all'){
+
if(isset($filters['status_date_hidden']) &&
$filters['status_date_hidden'] != "")
{
$ts_query =
strtotime($filters['status_date_hidden']); // target timestamp specified by user
@@ -252,8 +222,7 @@
{
$ts_query = strtotime(date('Y-m-d')); //
timestamp for query (today)
}
- switch($filters['contract_status'])
- {
+ switch($filters['contract_status']){
case 'under_planning':
$filter_clauses[] =
"contract.date_start > {$ts_query} OR contract.date_start IS NULL";
break;
@@ -276,7 +245,7 @@
break;
}
}
-
+
/*
* Contracts for billing
*/
@@ -305,41 +274,27 @@
}
$timestamp_end = strtotime('+1 month', $timestamp_end);
// The first day in the month after the one to bill for
//$timestamp_start = strtotime("{$year}-{$month}-01");
-
+
$filter_clauses[] = "contract.term_id =
{$billing_term_id}";
$filter_clauses[] = "contract.date_start <
$timestamp_end";
$filter_clauses[] = "(contract.date_end IS NULL OR
contract.date_end >= {$timestamp_start})";
$filter_clauses[] = "(contract.billing_start IS NULL OR
contract.billing_start < {$timestamp_end})";
-
+
$specific_ordering = 'invoice.timestamp_end DESC,
contract.billing_start DESC, contract.date_start DESC, contract.date_end DESC';
- $this->order_field = 'invoice.timestamp_end,
contract.billing_start, contract.date_start, contract.date_end';
-
$order = $order ? $order.', '.$specific_ordering :
"ORDER BY {$specific_ordering}";
}
-
+
if(count($filter_clauses))
{
$clauses[] = join(' AND ', $filter_clauses);
}
-
+
$condition = join(' AND ', $clauses);
-
- $tables = "rental_contract contract";
- $join_contract_type = $this->left_join.'
rental_contract_responsibility type ON (type.location_id =
contract.location_id)';
- $join_parties = $this->left_join.' rental_contract_party c_t ON
(contract.id = c_t.contract_id) LEFT JOIN rental_party party ON (c_t.party_id =
party.id)';
- $join_composites = $this->left_join."
rental_contract_composite c_c ON (contract.id = c_c.contract_id)
{$this->left_join} rental_composite composite ON c_c.composite_id =
composite.id";
- $join_units = $this->left_join." rental_unit r_u ON
(r_u.composite_id=composite.id)";
- $join_last_edited = $this->left_join.'
rental_contract_last_edited last_edited ON (contract.id =
last_edited.contract_id)';
- $join_last_billed = "{$this->left_join} rental_invoice invoice
ON (contract.id = invoice.contract_id) {$this->left_join} rental_billing
billing ON (invoice.billing_id = billing.id)";
- $join_term_title = "{$this->left_join} rental_billing_term
r_b_t ON (contract.term_id = r_b_t.id)";
- $joins = $join_contract_type.' '.$join_parties.'
'.$join_composites.' '.$join_units.' '.$join_last_edited.'
'.$join_last_billed.' '.$join_term_title;
-
+
if($return_count) // We should only return a count
{
- // Sigurd 4. feb 2012: The improved query is 50 %
faster - might have the use the old one for non-postgresql-db
- // $cols = 'COUNT(DISTINCT(contract.id)) AS count';
- // return "SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition}";
- return "SELECT COUNT(id) AS count FROM (SELECT
DISTINCT(contract.id) as id FROM {$tables} {$joins} WHERE {$condition}) as t";
+ $cols = 'COUNT(DISTINCT(contract.id)) AS count';
+ $order = ''; // No ordering
}
else
{
@@ -348,108 +303,31 @@
$columns[] = 'contract.date_start, contract.date_end,
contract.old_contract_id, contract.executive_officer, contract.last_updated,
contract.location_id, contract.billing_start, contract.service_id,
contract.responsibility_id, contract.reference, contract.invoice_header,
contract.project_id, billing.deleted, contract.account_in,
contract.account_out, contract.term_id, contract.security_type,
contract.security_amount, contract.comment, contract.due_date,
contract.contract_type_id,contract.rented_area,contract.adjustable,contract.adjustment_interval,contract.adjustment_share,contract.adjustment_year,contract.publish_comment';
$columns[] = 'party.id AS party_id';
$columns[] = 'party.first_name, party.last_name,
party.company_name';
- $columns[] = 'c_t.is_payer';
+ $columns[] = 'c_t.is_payer';
$columns[] = 'composite.id AS composite_id';
$columns[] = 'composite.name AS composite_name';
$columns[] = 'type.title, type.notify_before,
type.notify_before_due_date, type.notify_after_termination_date';
$columns[] = 'last_edited.edited_on';
- $columns[] = 'invoice.timestamp_end';
+ $columns[] = 'invoice.timestamp_end';
$columns[] = 'r_b_t.title AS term_title';
$cols = implode(',',$columns);
-
- $this->ordermethod = $order;
-
- return "SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition}";
}
- }
+
+ $tables = "rental_contract contract";
+ $join_contract_type = $this->left_join.'
rental_contract_responsibility type ON (type.location_id =
contract.location_id)';
+ $join_parties = $this->left_join.' rental_contract_party c_t ON
(contract.id = c_t.contract_id) LEFT JOIN rental_party party ON (c_t.party_id =
party.id)';
+ $join_composites = $this->left_join."
rental_contract_composite c_c ON (contract.id = c_c.contract_id)
{$this->left_join} rental_composite composite ON c_c.composite_id =
composite.id";
+ $join_units = $this->left_join." rental_unit r_u ON
(r_u.composite_id=composite.id)";
+ $join_last_edited = $this->left_join.'
rental_contract_last_edited last_edited ON (contract.id =
last_edited.contract_id)';
+ $join_last_billed = "{$this->left_join} rental_invoice invoice
ON (contract.id = invoice.contract_id) {$this->left_join} rental_billing
billing ON (invoice.billing_id = billing.id)";
+ $join_term_title = "{$this->left_join} rental_billing_term
r_b_t ON (contract.term_id = r_b_t.id)";
+ $joins = $join_contract_type.' '.$join_parties.'
'.$join_composites.' '.$join_units.' '.$join_last_edited.'
'.$join_last_billed.' '.$join_term_title;
- /**
- * Method for retreiving objects.
- *
- * @param $start_index int with index of first object.
- * @param $num_of_objects int with max number of objects to return.
- * @param $sort_field string representing the object field to sort on.
- * @param $ascending boolean true for ascending sort on sort field,
false
- * for descending.
- * @param $search_for string with free text search query.
- * @param $search_type string with the query type.
- * @param $filters array with key => value of filters.
- * @return array of objects. May return an empty
- * array, never null. The array keys are the respective index numbers.
- */
- public function get(int $start_index, int $num_of_objects, string
$sort_field, boolean $ascending, string $search_for, string $search_type, array
$filters)
- {
- $results = array(); // Array to store
result objects
-
- // Retrieve information about the table name and the name and
alias of id column
- // for all the
result objects are traversed
- $id_field_name_info = $this->get_id_field_name(true);
- if(is_array($id_field_name_info))
- {
- $id_field_name = $id_field_name_info['translated'];
- }
- else
- {
- $id_field_name = $id_field_name_info;
- }
-
- // Special case: Sort on id field. Always changed to the id
field name.
- // results are reached and we are sure that the
records are ordered by the id
- if($sort_field == null || $sort_field == 'id' || $sort_field ==
'')
- {
- $sort_field = $id_field_name;
- }
-
- // Only allow positive start index
- if($start_index < 0)
- {
- $start_index = 0;
- }
-
- $sql = $this->get_query($sort_field, $ascending, $search_for,
$search_type, $filters, false);
- $sql_parts = explode('1=1',$sql); // Split the query to insert
extra condition on test for break
-
- $sql_minimized = 'SELECT DISTINCT contract.id ' .
substr($sql,strripos($sql,'FROM'));
- $order_field = $this->order_field ? ", {$this->order_field}" :
'';
- $sql_end = str_replace('SELECT DISTINCT contract.id',"SELECT
DISTINCT contract.id {$order_field}", $sql_minimized) . " GROUP BY contract.id
{$order_field} {$this->ordermethod}";
- //_debug_array($sql_end);
-
- $records = array();
- if( isset($filters['contract_id']) && $filters['contract_id'])
- {
- $records[] = (int)$filters['contract_id'];
- }
- else
- {
- if($num_of_objects == null)
- {
- $this->db->query($sql_end,__LINE__,__FILE__,
false, true);
- }
- else
- {
-
$this->db->limit_query($sql_end,$start_index,__LINE__,__FILE__,
$num_of_objects);
- }
-
- while ($this->db->next_record())
- {
- $records[] = (int)$this->db->f('id');
- }
- }
-
- foreach ($records as $id)
- {
- $this->db->query("{$sql_parts[0]} contract.id =
{$id}",__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- $result = &$results[$id];
- $results[$id] = $this->populate($id,$result);
- }
- }
-
- return $results;
+ //var_dump("SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition} {$order}");
+
+ return "SELECT {$cols} FROM {$tables} {$joins} WHERE
{$condition} {$order}";
}
-
-
+
public function get_id_field_name($extended_info = false)
{
if(!$extended_info)
@@ -468,10 +346,10 @@
return $ret;
}
-
+
function populate(int $contract_id, &$contract)
{
-
+
if($contract == null ) // new contract
{
$contract_id = (int) $contract_id;
@@ -512,23 +390,23 @@
$contract->set_notify_before($this->unmarshal($this->db->f('notify_before'),'int'));
$contract->set_notify_before_due_date($this->unmarshal($this->db->f('notify_before_due_date'),'int'));
$contract->set_notify_after_termination_date($this->unmarshal($this->db->f('notify_after_termination_date'),'int'));
-
-
+
+
}
-
+
$timestamp_end =
$this->unmarshal($this->db->f('timestamp_end'),'int');
$billing_deleted =
$this->unmarshal($this->db->f('deleted'),'bool');
if($timestamp_end && !$billing_deleted)
{
$contract->add_bill_timestamp($timestamp_end);
}
-
+
$total_price =
$this->unmarshal($this->db->f('total_price'),'int');
if($total_price)
{
$contract->set_total_price($total_price);
}
-
+
$party_id = $this->unmarshal($this->db->f('party_id', true),
'int');
if($party_id)
{
@@ -543,7 +421,7 @@
}
$contract->add_party($party);
}
-
+
$composite_id = $this->unmarshal($this->db->f('composite_id',
true), 'int');
if($composite_id)
{
@@ -553,21 +431,19 @@
}
return $contract;
}
-
+
/**
* Get a key/value array of contract type titles keyed by their id
*
* @return array
*/
- function get_fields_of_responsibility()
- {
+ function get_fields_of_responsibility(){
if($this->fields_of_responsibility == null)
{
$sql = "SELECT location_id,title FROM
rental_contract_responsibility";
$this->db->query($sql, __LINE__, __FILE__);
$results = array();
- while($this->db->next_record())
- {
+ while($this->db->next_record()){
$location_id = $this->db->f('location_id',
true);
$results[$location_id] = $this->db->f('title',
true);
}
@@ -575,9 +451,8 @@
}
return $this->fields_of_responsibility;
}
-
- function get_default_account(int $location_id, bool $in)
- {
+
+ function get_default_account(int $location_id, bool $in){
if(isset($location_id) && $location_id > 0)
{
if($in)
@@ -588,7 +463,7 @@
{
$col = 'account_out';
}
-
+
$sql = "SELECT {$col} FROM
rental_contract_responsibility WHERE location_id = {$location_id}";
$this->db->query($sql, __LINE__, __FILE__);
$this->db->next_record();
@@ -596,7 +471,7 @@
}
return '';
}
-
+
function get_default_project_number(int $location_id)
{
if(isset($location_id) && $location_id > 0)
@@ -605,9 +480,9 @@
$this->db->query($sql, __LINE__, __FILE__);
$this->db->next_record();
return $this->db->f('project_number',true);
- }
+ }
}
-
+
function get_responsibility_title(int $location_id)
{
if(isset($location_id) && $location_id > 0)
@@ -616,9 +491,9 @@
$this->db->query($sql, __LINE__, __FILE__);
$this->db->next_record();
return $this->db->f('title',true);
- }
+ }
}
-
+
/**
* Returns the range of year there are contracts. That is, the array
* returned contains reversed chronologically all the years from the
earliest start
@@ -648,10 +523,10 @@
{
$year_range[] = $year;
}
-
+
return $year_range;
}
-
+
/**
* Update the database values for an existing contract object.
*
@@ -661,7 +536,7 @@
function update($contract)
{
$id = intval($contract->get_id());
-
+
$values = array();
// Set all fields in form
@@ -669,19 +544,18 @@
// FORM COLUMN 1
$values[] = "contract_type_id = ".
$this->marshal($contract->get_contract_type_id(), 'int');
$values[] = "executive_officer = ".
$this->marshal($contract->get_executive_officer_id(), 'int');
-
- if ($contract->get_contract_date())
- {
+
+ if ($contract->get_contract_date()) {
$values[] = "date_start = " .
$this->marshal($contract->get_contract_date()->get_start_date(), 'int');
$values[] = "date_end = " .
$this->marshal($contract->get_contract_date()->get_end_date(), 'int');
}
-
+
$values[] = "due_date = " .
$this->marshal($contract->get_due_date(), 'int');
$values[] = "invoice_header = ".
$this->marshal($contract->get_invoice_header(),'string');
$values[] = "term_id = " .
$this->marshal($contract->get_term_id(), 'int');
$values[] = "billing_start = " .
$this->marshal($contract->get_billing_start_date(), 'int');
$values[] = "reference = ".
$this->marshal($contract->get_reference(),'string');
-
+
// FORM COLUMN 2
$values[] = "service_id = ".
$this->marshal($contract->get_service_id(),'string');
$values[] = "responsibility_id = ".
$this->marshal($contract->get_responsibility_id(),'string');
@@ -695,25 +569,25 @@
$values[] = "adjustment_interval = ".
$this->marshal($contract->get_adjustment_interval(),'int');
$values[] = "adjustment_share = ".
$this->marshal($contract->get_adjustment_share(),'int');
$values[] = "publish_comment = ".
($contract->get_publish_comment() ? "true" : "false");
-
+
// FORM COLUMN 3
$values[] = "comment = ".
$this->marshal($contract->get_comment(), 'string');
-
-
+
+
// Set date last updated
$values[] = "last_updated = ". strtotime('now');
-
+
$result = $this->db->query('UPDATE rental_contract SET ' .
join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);
-
+
if(isset($result))
{
$this->last_edited_by($id);
return true;
}
-
+
return false;
}
-
+
/**
* This method marks the combination contract/user account with the
current timestamp. It updates the record if the user has updated
* this contract before; inserts a new record if the user has never
updated this contract.
@@ -721,14 +595,13 @@
* @param $contract_id
* @return true if the contract was marker, false otherwise
*/
- public function last_edited_by($contract_id)
- {
+ public function last_edited_by($contract_id){
$account_id = $GLOBALS['phpgw_info']['user']['account_id']; //
current user
$ts_now = strtotime('now');
-
+
$sql_has_edited_before = "SELECT account_id FROM
rental_contract_last_edited WHERE contract_id = $contract_id AND account_id =
$account_id";
$result = $this->db->query($sql_has_edited_before);
-
+
if(isset($result))
{
if($this->db->next_record())
@@ -747,13 +620,13 @@
}
return false;
}
-
+
public function remove_Last_edited_by_information()
{
$sql = "DELETE * FROM rental_contract_last_edited";
$this->db->query($sql);
}
-
+
public function get_last_edited_by($contract_id)
{
$sql = "SELECT account_id FROM rental_contract_last_edited
where contract_id={$contract_id} ORDER by edited_on DESC";
@@ -768,15 +641,14 @@
}
return "";
}
-
+
/**
* This method markw the given contract with the current timestamp
*
* @param $contract_id
* @return true if the contract was marked, false otherwise
*/
- public function last_updated($contract_id)
- {
+ public function last_updated($contract_id){
$ts_now = strtotime('now');
$sql = "UPDATE rental_contract SET last_updated=$ts_now";
$result = $this->db->query($sql);
@@ -789,7 +661,7 @@
return false;
}
}
-
+
/**
* Add a new contract to the database. Adds the new insert id to the
object reference.
*
@@ -798,128 +670,121 @@
*/
function add(&$contract)
{
+
+ $contract->set_id(self::get_new_id($contract->get_old_contract_id()));
-
$contract->set_id(self::get_new_id($contract->get_old_contract_id()));
+ // Contract has no old or new ID, get next ID available from DB
+ if($this->marshal($contract->get_id(), 'int') == 0) {
+ $new_id = $this->db->next_id('rental_contract');
+ $contract->set_id($new_id);
+ }
- // Contract has no old or new ID, get next ID available from DB
- if($this->marshal($contract->get_id(), 'int') == 0)
- {
- $new_id = $this->db->next_id('rental_contract');
- $contract->set_id($new_id);
- }
-
// These are the columns we know we have or that are nullable
$cols = array('location_id', 'term_id');//
-
+
// Start making a db-formatted list of values of the columns we
have to have
$values = array(
$this->marshal($contract->get_location_id(), 'int'),
$this->marshal($contract->get_term_id(), 'int')
);
- // Set ID according to old contract id or generate a new one
- $cols[] = 'id';
- $values[] = $new_id ? $new_id :
$this->marshal($contract->get_id(), 'int');
+ // Set ID according to old contract id or generate a new one
+ $cols[] = 'id';
+ $values[] = $new_id ? $new_id : $this->marshal($contract->get_id(),
'int');
-
+
// Check values that can be null before trying to add them to
the db-pretty list
- if ($contract->get_billing_start_date())
- {
+ if ($contract->get_billing_start_date()) {
$cols[] = 'billing_start';
$values[] =
$this->marshal($contract->get_billing_start_date(), 'int');
}
-
- if ($contract->get_contract_date())
- {
+
+ if ($contract->get_contract_date()) {
$cols[] = 'date_start';
$cols[] = 'date_end';
$values[] =
$this->marshal($contract->get_contract_date()->get_start_date(), 'int');
$values[] =
$this->marshal($contract->get_contract_date()->get_end_date(), 'int');
}
-
- if($contract->get_executive_officer_id())
- {
+
+ if($contract->get_executive_officer_id()) {
$cols[] = 'executive_officer';
$values[] =
$this->marshal($contract->get_executive_officer_id(), 'int');
}
-
+
$cols[] = 'created';
$cols[] = 'created_by';
$values[] = strtotime('now');
$values[] = $GLOBALS['phpgw_info']['user']['account_id'];
-
-
+
+
$cols[] = 'service_id';
$cols[] = 'responsibility_id';
$values[] =
$this->marshal($contract->get_service_id(),'string');
$values[] =
$this->marshal($contract->get_responsibility_id(),'string');
-
+
$cols[] = 'reference';
$cols[] = 'invoice_header';
$values[] = $this->marshal($contract->get_reference(),'string');
$values[] =
$this->marshal($contract->get_invoice_header(),'string');
-
+
$cols[] = 'account_in';
$cols[] = 'account_out';
$values[] =
$this->marshal($contract->get_account_in(),'string');
$values[] =
$this->marshal($contract->get_account_out(),'string');
-
+
$cols[] = 'project_id';
$values[] =
$this->marshal($contract->get_project_id(),'string');
-
+
$cols[] = 'old_contract_id';
- $values[] = $new_id ?
$this->marshal(self::get_old_id($new_id),'string') :
$this->marshal($contract->get_old_contract_id(),'string');
-
- $cols[] = 'rented_area';
- $values[] =
$this->marshal($contract->get_rented_area(),'float');
-
+ $values[] = $new_id ?
$this->marshal(self::get_old_id($new_id),'string') :
$this->marshal($contract->get_old_contract_id(),'string');
+
+ $cols[] = 'rented_area';
+ $values[] = $this->marshal($contract->get_rented_area(),'float');
+
$cols[] = 'comment';
$values[] = $this->marshal($contract->get_comment(),'string');
-
+
$cols[] = 'adjustment_interval';
$values[] =
$this->marshal($contract->get_adjustment_interval(),'int');
-
+
$cols[] = 'adjustment_share';
$values[] =
$this->marshal($contract->get_adjustment_share(),'int');
-
+
$cols[] = 'adjustable';
$values[] = ($contract->get_adjustable() ? "true" : "false");
-
+
$cols[] = 'adjustment_year';
$values[] =
$this->marshal($contract->get_adjustment_year(),'int');
-
+
$cols[] = 'publish_comment';
$values[] = ($contract->get_publish_comment() ? "true" :
"false");
-
-
- if ($contract->get_security_type())
- {
+
+
+ if ($contract->get_security_type()) {
$cols[] = 'security_type';
$values[] =
$this->marshal($contract->get_security_type(),'int');
$cols[] = 'security_amount';
$values[] =
$this->marshal($contract->get_security_amount(),'string');
}
-
- if ($contract->get_due_date())
- {
+
+ if ($contract->get_due_date()) {
$cols[] = 'due_date';
$values[] = $this->marshal($contract->get_due_date(),
'int');
}
-
- if($contract->get_contract_type_id())
- {
+
+ if($contract->get_contract_type_id()) {
$cols[] = 'contract_type_id';
$values[] =
$this->marshal($contract->get_contract_type_id(), 'int');
}
-
+
// Insert the new contract
$q ="INSERT INTO rental_contract (" . join(',', $cols) . ")
VALUES (" . join(',', $values) . ")";
$result = $this->db->query($q);
-
+
return $contract;
}
-
+
/**
* This method adds a party to a contract. Updates last edited history.
*
@@ -939,7 +804,7 @@
}
return false;
}
-
+
/**
* This method removes a party from a contract. Updates last edited
history.
*
@@ -959,7 +824,7 @@
}
return false;
}
-
+
/**
* This method adds a composite to a contract. Updates last edited
history.
*
@@ -979,7 +844,7 @@
}
return false;
}
-
+
/**
* This method removes a composite from a contract. Updates last edited
history.
*
@@ -999,9 +864,9 @@
}
return false;
}
-
-
-
+
+
+
/**
* This method sets a payer on a contract
*
@@ -1032,194 +897,171 @@
return false;
}
- /**
- * Convert old contract ID to new format
- *
- * @param $cid Old contract ID
- * @return int New contract ID
- */
- public static function get_new_id($old)
- {
- return (int) preg_replace('/[a-z]/i', '', $old);
- }
+ /**
+ * Convert old contract ID to new format
+ *
+ * @param $cid Old contract ID
+ * @return int New contract ID
+ */
+ public static function get_new_id($old) {
+ return (int) preg_replace('/[a-z]/i', '', $old);
+ }
- /**
- * Get new contract ID in "old" format
- *
- * @param $cid New contract ID
- * @return string "Old" contract ID
- */
- public static function get_old_id($cid, $prefix = 'K', $digits = 8)
- {
- $length = strlen(''.$cid);
+ /**
+ * Get new contract ID in "old" format
+ *
+ * @param $cid New contract ID
+ * @return string "Old" contract ID
+ */
+ public static function get_old_id($cid, $prefix = 'K', $digits = 8) {
+ $length = strlen(''.$cid);
- while($length != $digits)
- {
- if($digits < $length)
- {
- // If number of digits is lower that current
length, this will loop forever, return null to stop it.
- return null;
- }
- $cid = '0'.$cid;
- $length = strlen(''.$cid);
- }
+ while($length != $digits) {
+ if($digits < $length) {
+ // If number of digits is lower that current length, this will
loop forever, return null to stop it.
+ return null;
+ }
+ $cid = '0'.$cid;
+ $length = strlen(''.$cid);
+ }
- return $prefix.$cid;
- }
-
- public function get_contract_types($location_id)
- {
- $q1="SELECT rct.id, rct.label FROM rental_contract_types rct,
rental_contract_responsibility rcr WHERE rcr.location_id={$location_id} AND
rct.responsibility_id=rcr.id";
+ return $prefix.$cid;
+ }
+
+ public function get_contract_types($location_id){
+ $q1="SELECT rct.id, rct.label FROM rental_contract_types rct,
rental_contract_responsibility rcr WHERE rcr.location_id={$location_id} AND
rct.responsibility_id=rcr.id";
$this->db->query($q1, __LINE__, __FILE__);
$results = array();
- while($this->db->next_record())
- {
+ while($this->db->next_record()){
$results[$this->db->f('id')] = $this->db->f('label');
}
-
+
return $results;
- }
-
- public function get_contract_type_label($contract_type_id)
- {
- $result = "Ingen";
- if(isset($contract_type_id))
- {
- $q1="SELECT rct.label FROM rental_contract_types rct
WHERE rct.id={$contract_type_id}";
+ }
+
+ public function get_contract_type_label($contract_type_id){
+ $result = "Ingen";
+ if(isset($contract_type_id)){
+ $q1="SELECT rct.label FROM rental_contract_types rct WHERE
rct.id={$contract_type_id}";
$this->db->query($q1, __LINE__, __FILE__);
- while($this->db->next_record())
- {
+ while($this->db->next_record()){
$result = $this->db->f('label');
}
- }
-
+ }
+
return $result;
- }
-
- public function get_contract_type_account($contract_type_id)
- {
- $q1="SELECT rct.account FROM rental_contract_types rct WHERE
rct.id={$contract_type_id}";
+ }
+
+ public function get_contract_type_account($contract_type_id)
+ {
+ $q1="SELECT rct.account FROM rental_contract_types rct WHERE
rct.id={$contract_type_id}";
$this->db->query($q1, __LINE__, __FILE__);
$results = "";
- while($this->db->next_record())
- {
+ while($this->db->next_record()){
$result = $this->db->f('account');
}
-
+
return $result;
- }
-
-
- public function get_term_label($billing_term_id)
- {
- $q1="SELECT rbt.title FROM rental_billing_term rbt WHERE
rbt.id={$billing_term_id}";
+ }
+
+
+ public function get_term_label($billing_term_id){
+ $q1="SELECT rbt.title FROM rental_billing_term rbt WHERE
rbt.id={$billing_term_id}";
$this->db->query($q1, __LINE__, __FILE__);
$results = "";
- while($this->db->next_record())
- {
+ while($this->db->next_record()){
$result = $this->db->f('title');
}
-
+
return $result;
- }
+ }
- public function clear_last_edited_table()
- {
- $q = "DELETE FROM rental_contract_last_edited";
- $this->db->query($q, '', '', true);
- }
- public function copy_contract($contract_id, $old_contract_id)
- {
- //queries for selecting composites, parties and price items for
the contract to be copied
- $q_composites = "SELECT composite_id FROM
rental_contract_composite WHERE contract_id={$old_contract_id}";
- $q_parties = "SELECT party_id, is_payer FROM
rental_contract_party WHERE contract_id={$old_contract_id}";
- $q_price_items = "SELECT price_item_id, title, area, count,
agresso_id, is_area, price, total_price, is_one_time FROM
rental_contract_price_item WHERE contract_id={$old_contract_id}";
- $success_composites = true;
- $success_parties = true;
- $success_price_items = true;
-
- //composites
- $this->db->query($q_composites);
- while($this->db->next_record())
- {
- $composite_id =
$this->unmarshal($this->db->f('composite_id'),'int');
- $composite_id = $this->marshal($composite_id, 'int');
- $sql = "INSERT INTO rental_contract_composite
(contract_id, composite_id) VALUES ({$contract_id}, {$composite_id})";
- $result_composites = $this->db->query($sql);
- if($result_composites)
- {
- //noop
- }
- else
- {
- $success_composites = false;
- }
- }
-
- //parties
- $this->db->query($q_parties);
- while($this->db->next_record())
- {
- $party_id =
$this->unmarshal($this->db->f('party_id'),'int');
- $party_id = $this->marshal($party_id, 'int');
- $is_payer =
$this->unmarshal($this->db->f('is_payer'),'bool');
- $is_payer = $this->marshal($is_payer ? 'true' :
'false','bool');
- $sql = "INSERT INTO rental_contract_party (contract_id,
party_id, is_payer) VALUES ({$contract_id}, {$party_id}, {$is_payer})";
- $result_parties = $this->db->query($sql);
- if($result_parties)
- {
- //noop
- }
- else
- {
- $success_parties = false;
- }
- }
-
- //price items
- $this->db->query($q_price_items);
- while($this->db->next_record())
- {
- $price_item_id =
$this->unmarshal($this->db->f('price_item_id'),'int');
- $price_item_id = $this->marshal($price_item_id, 'int');
- $title =
$this->unmarshal($this->db->f('title'),'string');
- $title = $this->marshal($title, 'string');
- $area = $this->unmarshal($this->db->f('area'),'float');
- $area = $this->marshal($area, 'float');
- $count = $this->unmarshal($this->db->f('count'),'int');
- $count = $this->marshal($count, 'int');
- $agresso_id =
$this->unmarshal($this->db->f('agresso_id'),'string');
- $agresso_id = $this->marshal($agresso_id, 'string');
- $is_area =
$this->unmarshal($this->db->f('is_area'),'bool');
- $is_area = $this->marshal($is_area ? 'true' :
'false','bool');
- $price =
$this->unmarshal($this->db->f('price'),'float');
- $price = $this->marshal($price, 'float');
- $total_price =
$this->unmarshal($this->db->f('total_price'),'float');
- $total_price = $this->marshal($total_price, 'float');
- $is_one_time =
$this->unmarshal($this->db->f('is_one_time'),'bool');
- $is_one_time = $this->marshal($is_one_time ? 'true' :
'false','bool');
- $sql = "INSERT INTO rental_contract_price_item
(price_item_id, contract_id, title, area, count, agresso_id, is_area, price,
total_price, is_one_time, date_start, date_end) VALUES ({$price_item_id},
{$contract_id}, {$title}, {$area}, {$count}, {$agresso_id}, {$is_area},
{$price}, {$total_price}, {$is_one_time}, null, null)";
- $result_price_items = $this->db->query($sql);
- if($result_price_items)
- {
- //noop
- }
- else
- {
- $success_price_items = false;
- }
- }
-// var_dump($success_composites.' '.$success_parties.'
'.$success_price_items);
- if($success_composites && $success_parties &&
$success_price_items){
- return true;
- }
- else{
- return false;
- }
- }
-
- public function get_months_in_term($term_id)
- {
+ public function clear_last_edited_table() {
+ $q = "DELETE FROM rental_contract_last_edited";
+ $this->db->query($q, '', '', true);
+ }
+ public function copy_contract($contract_id, $old_contract_id){
+ //queries for selecting composites, parties and price items for the
contract to be copied
+ $q_composites = "SELECT composite_id FROM rental_contract_composite
WHERE contract_id={$old_contract_id}";
+ $q_parties = "SELECT party_id, is_payer FROM rental_contract_party
WHERE contract_id={$old_contract_id}";
+ $q_price_items = "SELECT price_item_id, title, area, count, agresso_id,
is_area, price, total_price, is_one_time FROM rental_contract_price_item WHERE
contract_id={$old_contract_id}";
+ $success_composites = true;
+ $success_parties = true;
+ $success_price_items = true;
+
+ //composites
+ $this->db->query($q_composites);
+ while($this->db->next_record()){
+ $composite_id =
$this->unmarshal($this->db->f('composite_id'),'int');
+ $composite_id = $this->marshal($composite_id, 'int');
+ $sql = "INSERT INTO rental_contract_composite (contract_id,
composite_id) VALUES ({$contract_id}, {$composite_id})";
+ $result_composites = $this->db->query($sql);
+ if($result_composites){
+ //noop
+ }
+ else{
+ $success_composites = false;
+ }
+ }
+
+ //parties
+ $this->db->query($q_parties);
+ while($this->db->next_record()){
+ $party_id = $this->unmarshal($this->db->f('party_id'),'int');
+ $party_id = $this->marshal($party_id, 'int');
+ $is_payer = $this->unmarshal($this->db->f('is_payer'),'bool');
+ $is_payer = $this->marshal($is_payer ? 'true' : 'false','bool');
+ $sql = "INSERT INTO rental_contract_party (contract_id,
party_id, is_payer) VALUES ({$contract_id}, {$party_id}, {$is_payer})";
+ $result_parties = $this->db->query($sql);
+ if($result_parties){
+ //noop
+ }
+ else{
+ $success_parties = false;
+ }
+ }
+
+ //price items
+ $this->db->query($q_price_items);
+ while($this->db->next_record()){
+ $price_item_id =
$this->unmarshal($this->db->f('price_item_id'),'int');
+ $price_item_id = $this->marshal($price_item_id, 'int');
+ $title = $this->unmarshal($this->db->f('title'),'string');
+ $title = $this->marshal($title, 'string');
+ $area = $this->unmarshal($this->db->f('area'),'float');
+ $area = $this->marshal($area, 'float');
+ $count = $this->unmarshal($this->db->f('count'),'int');
+ $count = $this->marshal($count, 'int');
+ $agresso_id =
$this->unmarshal($this->db->f('agresso_id'),'string');
+ $agresso_id = $this->marshal($agresso_id, 'string');
+ $is_area = $this->unmarshal($this->db->f('is_area'),'bool');
+ $is_area = $this->marshal($is_area ? 'true' : 'false','bool');
+ $price = $this->unmarshal($this->db->f('price'),'float');
+ $price = $this->marshal($price, 'float');
+ $total_price =
$this->unmarshal($this->db->f('total_price'),'float');
+ $total_price = $this->marshal($total_price, 'float');
+ $is_one_time =
$this->unmarshal($this->db->f('is_one_time'),'bool');
+ $is_one_time = $this->marshal($is_one_time ? 'true' :
'false','bool');
+ $sql = "INSERT INTO rental_contract_price_item (price_item_id,
contract_id, title, area, count, agresso_id, is_area, price, total_price,
is_one_time, date_start, date_end) VALUES ({$price_item_id}, {$contract_id},
{$title}, {$area}, {$count}, {$agresso_id}, {$is_area}, {$price},
{$total_price}, {$is_one_time}, null, null)";
+ $result_price_items = $this->db->query($sql);
+ if($result_price_items){
+ //noop
+ }
+ else{
+ $success_price_items = false;
+ }
+ }
+// var_dump($success_composites.' '.$success_parties.'
'.$success_price_items);
+ if($success_composites && $success_parties && $success_price_items){
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+
+ public function get_months_in_term($term_id)
+ {
$sql = "SELECT months FROM rental_billing_term WHERE id =
{$term_id}";
$result = $this->db->query($sql);
if(!$result)
@@ -1232,91 +1074,88 @@
}
$months = $this->unmarshal($this->db->f('months', true), 'int');
return $months;
- }
-
- public function update_price_items($contract_id, $rented_area){
- $success_price_item = true;
- $new_area = $rented_area;
- $q_price_items = "SELECT id AS rpi_id, price as rpi_price FROM
rental_contract_price_item WHERE contract_id={$contract_id} AND is_area";
- $res1 = $this->db->query($q_price_items, __LINE__,
__FILE__,false,true);
- while($this->db->next_record())
- {
- $id = $this->db->f('rpi_id');
- $price = $this->db->f('rpi_price');
- $curr_total_price = ($new_area * $price);
- $sql_pi = "UPDATE rental_contract_price_item SET
area={$new_area}, total_price={$curr_total_price} WHERE id={$id}";
- $result = $this->db->query($sql_pi, __LINE__,
__FILE__,false,true);
- if($result)
- {
- //noop
- }
- else
- {
- $success_price_item = false;
- }
- }
- if($success_price_item)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- public function import_contract_reference($contract_id, $reference)
- {
- $reference = $this->marshal($reference,'string');
- $sql = "UPDATE rental_contract SET reference={$reference} WHERE
id = {$contract_id}";
- $this->db->query($sql);
- }
-
- public function update_adjustment_year_interval($contract_id,
$adjusted_year, $adjustment_interval)
- {
- $new_adjusted_year = $this->marshal($adjusted_year, 'int');
- $new_adjustment_interval = $this->marshal($adjustment_interval,
'int');
- $sql = "UPDATE rental_contract SET adjustable=true,
adjustment_interval={$new_adjustment_interval},
adjustment_year={$new_adjusted_year} WHERE id = {$contract_id} AND
(adjustment_year IS NULL OR adjustment_year<{$new_adjusted_year})";
- $this->db->query($sql);
- return $this->db->affected_rows() > 0 ? true : false;
- }
-
- public function update_contract_end_date($contract_id, $date)
- {
- $cid = $this->marshal($contract_id, 'int');
- $end_date = $this->marshal($date, 'int');
- $sql = "UPDATE rental_contract SET date_end={$end_date} WHERE
id = {$cid}";
- $this->db->query($sql);
- }
-
+ }
+
+ public function update_price_items($contract_id, $rented_area){
+ $success_price_item = true;
+ $new_area = $rented_area;
+ $q_price_items = "SELECT id AS rpi_id, price as rpi_price FROM
rental_contract_price_item WHERE contract_id={$contract_id} AND is_area";
+ $res1 = $this->db->query($q_price_items, __LINE__, __FILE__,false,true);
+ while($this->db->next_record()){
+ $id = $this->db->f('rpi_id');
+ $price = $this->db->f('rpi_price');
+ $curr_total_price = ($new_area * $price);
+ $sql_pi = "UPDATE rental_contract_price_item SET
area={$new_area}, total_price={$curr_total_price} WHERE id={$id}";
+ $result = $this->db->query($sql_pi, __LINE__,
__FILE__,false,true);
+ if($result){
+ //noop
+ }
+ else{
+ $success_price_item = false;
+ }
+ }
+ if($success_price_item){
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+
+ public function import_contract_reference($contract_id, $reference)
+ {
+ $reference = $this->marshal($reference,'string');
+ $sql = "UPDATE rental_contract SET reference={$reference} WHERE id =
{$contract_id}";
+ $this->db->query($sql);
+ }
+
+ public function update_adjustment_year_interval($contract_id,
$adjusted_year, $adjustment_interval)
+ {
+ $new_adjusted_year = $this->marshal($adjusted_year, 'int');
+ $new_adjustment_interval = $this->marshal($adjustment_interval, 'int');
+ $sql = "UPDATE rental_contract SET adjustable=true,
adjustment_interval={$new_adjustment_interval},
adjustment_year={$new_adjusted_year} WHERE id = {$contract_id} AND
(adjustment_year IS NULL OR adjustment_year<{$new_adjusted_year})";
+ $this->db->query($sql);
+ return $this->db->affected_rows() > 0 ? true : false;
+ }
+
+ public function update_contract_end_date($contract_id, $date)
+ {
+ $cid = $this->marshal($contract_id, 'int');
+ $end_date = $this->marshal($date, 'int');
+ $sql = "UPDATE rental_contract SET date_end={$end_date} WHERE id =
{$cid}";
+ $this->db->query($sql);
+ }
+
public function update_adjustment_year($contract_id, $adjusted_year)
- {
- $new_adjusted_year = $this->marshal($adjusted_year, 'int');
- $sql = "UPDATE rental_contract SET
adjustment_year={$new_adjusted_year} WHERE id={$contract_id}
AND(adjustment_year IS NULL OR adjustment_year<{$new_adjusted_year})";
- $this->db->query($sql);
- return $this->db->affected_rows() > 0 ? true : false;
- }
+ {
+ $new_adjusted_year = $this->marshal($adjusted_year, 'int');
+ $sql = "UPDATE rental_contract SET adjustment_year={$new_adjusted_year}
WHERE id={$contract_id} AND(adjustment_year IS NULL OR
adjustment_year<{$new_adjusted_year})";
+ $this->db->query($sql);
+ return $this->db->affected_rows() > 0 ? true : false;
+ }
+
+ public function update_adjustment_share($contract_id, $adjustment_share)
+ {
+ $new_adjustment_share = $this->marshal($adjustment_share, 'int');
+ $sql = "UPDATE rental_contract SET
adjustment_share={$new_adjustment_share} WHERE id = {$contract_id}";
+ $this->db->query($sql);
+ }
+
+ public function get_default_price_items($location_id)
+ {
+ $price_items = array();
+ $loc_id = $this->marshal($location_id, 'int');
+
+ //select all standard price_items for given location_id
+ $sql = "SELECT id FROM rental_price_item WHERE
responsibility_id={$loc_id} AND NOT is_inactive AND standard";
+ $this->db->query($sql);
+ while($this->db->next_record())
+ {
+ $price_item_id = $this->unmarshal($this->db->f('id'),'int');
+ $price_items[] = $price_item_id;
+ }
+ return $price_items;
+ }
- public function update_adjustment_share($contract_id, $adjustment_share)
- {
- $new_adjustment_share = $this->marshal($adjustment_share,
'int');
- $sql = "UPDATE rental_contract SET
adjustment_share={$new_adjustment_share} WHERE id = {$contract_id}";
- $this->db->query($sql);
- }
-
- public function get_default_price_items($location_id)
- {
- $price_items = array();
- $loc_id = $this->marshal($location_id, 'int');
-
- //select all standard price_items for given location_id
- $sql = "SELECT id FROM rental_price_item WHERE
responsibility_id={$loc_id} AND NOT is_inactive AND standard";
- $this->db->query($sql);
- while($this->db->next_record())
- {
- $price_item_id =
$this->unmarshal($this->db->f('id'),'int');
- $price_items[] = $price_item_id;
- }
- return $price_items;
- }
}
+?>
Modified: branches/Version-1_0-branch/rental/templates/base/contract_list.php
===================================================================
--- branches/Version-1_0-branch/rental/templates/base/contract_list.php
2012-02-13 13:34:42 UTC (rev 8849)
+++ branches/Version-1_0-branch/rental/templates/base/contract_list.php
2012-02-13 13:45:39 UTC (rev 8850)
@@ -58,9 +58,9 @@
$editable = false;
$extra_cols = array(
array("key" => "type", "label" => lang('responsibility'), "index" => 3),
- array("key" => "composite", "label" => lang('composite'), "sortable"=>
false , "index" => 4),
+ array("key" => "composite", "label" => lang('composite'),
"sortable"=>'true', "index" => 4),
array("key" => "party", "label" => lang('party'), "sortable"=>'true',
"index" => 5),
array("key" => "contract_notification_status", "label" =>
lang('notification_status'), "sortable"=>false)
);
include('contract_list_partial.php');
-?>
+?>
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [8850] Merge 8842:8848 from trunk,
Sigurd Nes <=