fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [15582] Stable: Merge 15572:15581 from trunk


From: sigurdne
Subject: [Fmsystem-commits] [15582] Stable: Merge 15572:15581 from trunk
Date: Mon, 5 Sep 2016 08:24:31 +0000 (UTC)

Revision: 15582
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15582
Author:   sigurdne
Date:     2016-09-05 08:24:31 +0000 (Mon, 05 Sep 2016)
Log Message:
-----------
Stable: Merge 15572:15581 from trunk

Modified Paths:
--------------
    branches/Version-2_0-branch/controller/inc/class.uidocument.inc.php
    branches/Version-2_0-branch/property/inc/class.soentity.inc.php
    
branches/Version-2_0-branch/rental/inc/model/class.invoice_price_item.inc.php
    branches/Version-2_0-branch/rental/inc/model/class.price_item.inc.php

Property Changed:
----------------
    branches/Version-2_0-branch/


Property changes on: branches/Version-2_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/dev-syncromind:13653
/branches/dev-syncromind-2:14937-15027,15165-15215,15223-15228,15230-15243,15245-15250,15254-15257
/branches/stavangerkommune:12743-12875,12986
/trunk:14721-14732,14734-14735,14737,14739,14741,14743-14744,14746-14749,14751,14753,14755-14757,14759,14761-14764,14766-14768,14770-14783,14785-14792,14794-14813,14815-14816,14818,14820-14822,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845,14847,14849-14866,14868-14869,14871,14873-14875,14877-14878,14880-14884,14886-14896,14898,14900-14902,14904,14906-14909,14911-14915,14917-14919,14921-14922,14924-14978,14980-15258,15260-15261,15263-15264,15266-15285,15287-15288,15290-15291,15293,15295,15297,15299-15305,15307-15310,15312-15335,15337-15352,15354,15356,15358,15360-15541,15543-15566,15568-15569,15571
   + /branches/dev-syncromind:13653
/branches/dev-syncromind-2:14937-15027,15165-15215,15223-15228,15230-15243,15245-15250,15254-15257
/branches/stavangerkommune:12743-12875,12986
/trunk:14721-14732,14734-14735,14737,14739,14741,14743-14744,14746-14749,14751,14753,14755-14757,14759,14761-14764,14766-14768,14770-14783,14785-14792,14794-14813,14815-14816,14818,14820-14822,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845,14847,14849-14866,14868-14869,14871,14873-14875,14877-14878,14880-14884,14886-14896,14898,14900-14902,14904,14906-14909,14911-14915,14917-14919,14921-14922,14924-14978,14980-15258,15260-15261,15263-15264,15266-15285,15287-15288,15290-15291,15293,15295,15297,15299-15305,15307-15310,15312-15335,15337-15352,15354,15356,15358,15360-15541,15543-15566,15568-15569,15571,15573-15581

Modified: branches/Version-2_0-branch/controller/inc/class.uidocument.inc.php
===================================================================
--- branches/Version-2_0-branch/controller/inc/class.uidocument.inc.php 
2016-09-05 08:07:08 UTC (rev 15581)
+++ branches/Version-2_0-branch/controller/inc/class.uidocument.inc.php 
2016-09-05 08:24:31 UTC (rev 15582)
@@ -56,10 +56,10 @@
                        parent::__construct();
                        $this->so = controller_sodocument::get_instance();
                        $this->so_procedure = 
controller_soprocedure::get_instance();
-                       $this->read = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_READ, 'controller');//1
-                       $this->add = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_ADD, 'controller');//2
-                       $this->edit = $GLOBALS['phpgw']->acl->check('.control', 
PHPGW_ACL_EDIT, 'controller');//4
-                       $this->delete = 
$GLOBALS['phpgw']->acl->check('.control', PHPGW_ACL_DELETE, 'controller');//8
+                       $this->read = 
$GLOBALS['phpgw']->acl->check('.procedure', PHPGW_ACL_READ, 'controller');//1
+                       $this->add = 
$GLOBALS['phpgw']->acl->check('.procedure', PHPGW_ACL_ADD, 'controller');//2
+                       $this->edit = 
$GLOBALS['phpgw']->acl->check('.procedure', PHPGW_ACL_EDIT, 'controller');//4
+                       $this->delete = 
$GLOBALS['phpgw']->acl->check('.procedure', PHPGW_ACL_DELETE, 'controller');//8
                        
$GLOBALS['phpgw']->css->add_external_file('controller/templates/base/css/base.css');
                }
 
@@ -349,20 +349,21 @@
                          return;
                          } */
 
-                       $result = $this->so->delete_document_from_vfs
-                               (
+                       $result = $this->so->delete_document_from_vfs(
                                $document_properties['document_type'], 
$document_properties['id'], $document->get_name()
                        );
 
                        if ($result)
                        {
                                $this->so->delete_document($document_id);
-                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uidocument.show',
+                       }
+                       else
+                       {
+                               phpgwapi_cache::message_set('Not deleted', 
'error');
+                       }
+                       $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uidocument.show',
                                        'procedure_id' => $procedure->get_id(),
                                        'tab' => 'documents'));
-                       }
-                       // TODO: communicate error/message to user
-                       return false;
                }
 
                /**

Modified: branches/Version-2_0-branch/property/inc/class.soentity.inc.php
===================================================================
--- branches/Version-2_0-branch/property/inc/class.soentity.inc.php     
2016-09-05 08:07:08 UTC (rev 15581)
+++ branches/Version-2_0-branch/property/inc/class.soentity.inc.php     
2016-09-05 08:24:31 UTC (rev 15582)
@@ -820,6 +820,37 @@
 
                        if ($check_for_control && !$control_registered)
                        {
+                               /*
+                                * Filter inactive
+                                */
+                               static $cache_attribute_status = array();
+
+                               
if(!isset($cache_attribute_status[$location_id]))
+                               {
+                                       $filters = array("column_name" => 
"status");
+                                       $cache_attribute_status[$location_id] = 
$GLOBALS['phpgw']->custom_fields->find2($location_id, 0, '', 'ASC', '', true, 
true,$filters);
+                               }
+
+                               
if(!empty($cache_attribute_status[$location_id]))
+                               {
+                                       foreach 
($cache_attribute_status[$location_id] as $attibute_id => $attibute)
+                                       {
+                                               if(!empty($attibute['choice']))
+                                               {
+                                                       $_querymethod[] = 
"CAST( json_representation->>'status' AS integer) < 90";
+                                                       $__querymethod = 
array(); // remove block
+//                                                     foreach 
($attibute['choice'] as $choice)
+//                                                     {
+//                                                             
if($choice['id'] < 90)
+//                                                             {
+//                                                                     
$_querymethod[] = "CAST( json_representation->>'status' AS integer) = " 
.(int)$choice['id'];
+//                                                                     
$__querymethod = array(); // remove block
+//                                                             }
+//                                                     }
+                                               }
+                                       }
+                               }
+
                                $sql .= "{$this->left_join} {$join_control}";
 
                                $sql_custom_field .= ',count(control_id) AS 
has_control';

Modified: 
branches/Version-2_0-branch/rental/inc/model/class.invoice_price_item.inc.php
===================================================================
--- 
branches/Version-2_0-branch/rental/inc/model/class.invoice_price_item.inc.php   
    2016-09-05 08:07:08 UTC (rev 15581)
+++ 
branches/Version-2_0-branch/rental/inc/model/class.invoice_price_item.inc.php   
    2016-09-05 08:24:31 UTC (rev 15582)
@@ -136,68 +136,71 @@
                                $date_end['day'] = (int)date('j', 
$this->get_timestamp_end());
 
                                // Runs through all the years this price item 
goes for
-                               for ($current_year = $date_end['year']; 
$current_year >= $date_start['year']; $current_year--)
+                               if($this->price_type_id != 
rental_price_item::PRICE_TYPE_DAY)
                                {
-                                       // Within each year: which months do 
the price item run for
-                                       // First we set the defaults (whole 
year)
-                                       $current_start_month = 1; // January
-                                       $current_end_month = 12; // December
-                                       // If we are at the start year, use the 
start month of this year as start month
-                                       if ($current_year == 
$date_start['year'])
+                                       for ($current_year = $date_end['year']; 
$current_year >= $date_start['year']; $current_year--)
                                        {
-                                               $current_start_month = 
$date_start['month'];
-                                       }
-
-                                       // If we are at the start year, use the 
end month of this year as end month
-                                       if ($current_year == $date_end['year'])
-                                       {
-                                               $current_end_month = 
$date_end['month'];
-                                       }
-
-                                       // Runs through all of the months of 
the current year (we go backwards since we go backwards with the years)
-                                       for ($current_month = 
$current_end_month; $current_month >= $current_start_month; $current_month--)
-                                       {
-                                               // Retrive the number of days 
in the current month
-                                               $num_of_days_in_current_month = 
date('t', strtotime($current_year . '-' . $current_month . '-01'));
-
-                                               // Set the defaults (whole 
month)
-                                               $first_day = 1;
-                                               $last_day = 
$num_of_days_in_current_month;
-
-                                               // If we are at the start month 
in the start year, use day in this month as first day
-                                               if ($current_year == 
$date_start['year'] && $current_month == $date_start['month'])
+                                               // Within each year: which 
months do the price item run for
+                                               // First we set the defaults 
(whole year)
+                                               $current_start_month = 1; // 
January
+                                               $current_end_month = 12; // 
December
+                                               // If we are at the start year, 
use the start month of this year as start month
+                                               if ($current_year == 
$date_start['year'])
                                                {
-                                                       $first_day = 
$date_start['day'];
+                                                       $current_start_month = 
$date_start['month'];
                                                }
 
-                                               // If we are at the end month 
in the end year, use the day in this month as end day
-                                               if ($current_year == 
$date_end['year'] && $current_month == $date_end['month'])
+                                               // If we are at the start year, 
use the end month of this year as end month
+                                               if ($current_year == 
$date_end['year'])
                                                {
-                                                       $last_day = 
$date_end['day']; // The end date's day is the item's end day
+                                                       $current_end_month = 
$date_end['month'];
                                                }
 
-                                               // Increase counter: complete 
months or incomplete months (number of days in this year and number of days )
-                                               if ($first_day === 1 && 
$last_day == $num_of_days_in_current_month)
-                                               { // This is a whole month
-                                                       
$num_of_complete_months++;
-                                               }
-                                               else // Incomplete month
+                                               // Runs through all of the 
months of the current year (we go backwards since we go backwards with the 
years)
+                                               for ($current_month = 
$current_end_month; $current_month >= $current_start_month; $current_month--)
                                                {
-                                                       // YYY: There must be a 
better day to do this!?
-                                                       if($this->price_type_id 
== 1) // year
+                                                       // Retrive the number 
of days in the current month
+                                                       
$num_of_days_in_current_month = date('t', strtotime($current_year . '-' . 
$current_month . '-01'));
+
+                                                       // Set the defaults 
(whole month)
+                                                       $first_day = 1;
+                                                       $last_day = 
$num_of_days_in_current_month;
+
+                                                       // If we are at the 
start month in the start year, use day in this month as first day
+                                                       if ($current_year == 
$date_start['year'] && $current_month == $date_start['month'])
                                                        {
-                                                               
$num_of_days_in_current_year = (date('L', strtotime($current_year . '01-01')) 
== 0) ? 365 : 366;
-                                                               $num_of_days = 
$last_day - $first_day + 1;
-                                                               
$incomplete_months[] = array($num_of_days_in_current_year, $num_of_days);
+                                                               $first_day = 
$date_start['day'];
                                                        }
-                                                       else 
if($this->price_type_id == 2) //month
+
+                                                       // If we are at the end 
month in the end year, use the day in this month as end day
+                                                       if ($current_year == 
$date_end['year'] && $current_month == $date_end['month'])
                                                        {
-                                                               $num_of_days = 
$last_day - $first_day + 1;
-                                                               
$incomplete_months[] = array($num_of_days_in_current_month, $num_of_days);
+                                                               $last_day = 
$date_end['day']; // The end date's day is the item's end day
                                                        }
-                                                       else
+
+                                                       // Increase counter: 
complete months or incomplete months (number of days in this year and number of 
days )
+                                                       if ($first_day === 1 && 
$last_day == $num_of_days_in_current_month)
+                                                       { // This is a whole 
month
+                                                               
$num_of_complete_months++;
+                                                       }
+                                                       else // Incomplete month
                                                        {
-                                                               throw new 
Exception('Price type not supported');
+                                                               // YYY: There 
must be a better day to do this!?
+                                                               
if($this->price_type_id == rental_price_item::PRICE_TYPE_YEAR)
+                                                               {
+                                                                       
$num_of_days_in_current_year = (date('L', strtotime($current_year . '01-01')) 
== 0) ? 365 : 366;
+                                                                       
$num_of_days = $last_day - $first_day + 1;
+                                                                       
$incomplete_months[] = array($num_of_days_in_current_year, $num_of_days);
+                                                               }
+                                                               else 
if($this->price_type_id == rental_price_item::PRICE_TYPE_MONTH)
+                                                               {
+                                                                       
$num_of_days = $last_day - $first_day + 1;
+                                                                       
$incomplete_months[] = array($num_of_days_in_current_month, $num_of_days);
+                                                               }
+                                                               else
+                                                               {
+                                                                       throw 
new Exception('Price type not supported');
+                                                               }
                                                        }
                                                }
                                        }
@@ -208,14 +211,23 @@
 
                                // The total price of this price element for 
complete months
                                
-                               if($this->price_type_id == 1) // year
+                               if($this->price_type_id == 
rental_price_item::PRICE_TYPE_YEAR)
                                {
                                        $this->total_price = 
(($this->get_price() * $num_of_complete_months) / 12.0) * $amount;
                                }
-                               else if($this->price_type_id == 2) //month
+                               else if($this->price_type_id == 
rental_price_item::PRICE_TYPE_MONTH)
                                {
                                        $this->total_price = 
($this->get_price() * $num_of_complete_months) * $amount;
                                }
+                               else if($this->price_type_id == 
rental_price_item::PRICE_TYPE_DAY)
+                               {
+                                       $date1 = new DateTime(date('Y-m-d', 
$this->get_timestamp_start()));
+                                       $date2 = new DateTime(date('Y-m-d', 
$this->get_timestamp_end()));
+                                       $total_num_of_days = 
$date2->diff($date1)->format("%a");
+                                       $this->total_price = 
($this->get_price() * $total_num_of_days) * $amount;
+                                       //block the year and month correction
+                                       $incomplete_months = array();
+                               }
                                else
                                {
                                        throw new Exception('Price type not 
supported');
@@ -225,7 +237,7 @@
 
                                $price_per_type = $this->get_price() * $amount;
 
-                               // Run through all the incomplete months ...
+                               // Run through all the incomplete months 
...blocked if rental_price_item::PRICE_TYPE_DAY
                                foreach ($incomplete_months as $day_factors)
                                {
                                        // ... and add the sum of each 
incomplete month to the total price of the price item

Modified: branches/Version-2_0-branch/rental/inc/model/class.price_item.inc.php
===================================================================
--- branches/Version-2_0-branch/rental/inc/model/class.price_item.inc.php       
2016-09-05 08:07:08 UTC (rev 15581)
+++ branches/Version-2_0-branch/rental/inc/model/class.price_item.inc.php       
2016-09-05 08:24:31 UTC (rev 15582)
@@ -8,6 +8,11 @@
        class rental_price_item extends rental_model
        {
 
+               const PRICE_TYPE_YEAR = 1;
+               const PRICE_TYPE_MONTH = 2;
+               const PRICE_TYPE_DAY = 3;
+               const PRICE_TYPE_HOUR = 4;
+
                public static $so;
                protected $id;
                protected $title;
@@ -24,7 +29,7 @@
                protected $price_types = array(
                        1 => 'year',
                        2 => 'month',
-//                     3 => 'day',
+                       3 => 'day',
 //                     4 => 'hour',
                );
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]