fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [17130] bookingfrontend: dateformat


From: sigurdne
Subject: [Fmsystem-commits] [17130] bookingfrontend: dateformat
Date: Mon, 2 Oct 2017 10:00:15 -0400 (EDT)

Revision: 17130
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=17130
Author:   sigurdne
Date:     2017-10-02 10:00:14 -0400 (Mon, 02 Oct 2017)
Log Message:
-----------
bookingfrontend: dateformat

Modified Paths:
--------------
    trunk/booking/inc/class.uibooking.inc.php
    trunk/bookingfrontend/inc/class.uibooking.inc.php
    trunk/bookingfrontend/inc/custom/default/Altinn2_Bergen_kommune.php

Modified: trunk/booking/inc/class.uibooking.inc.php
===================================================================
--- trunk/booking/inc/class.uibooking.inc.php   2017-10-01 12:46:54 UTC (rev 
17129)
+++ trunk/booking/inc/class.uibooking.inc.php   2017-10-02 14:00:14 UTC (rev 
17130)
@@ -397,12 +397,6 @@
                        }
                        if ($_SERVER['REQUEST_METHOD'] == 'POST')
                        {
-//                             $_POST['from_'] = date("Y-m-d H:i:s", 
phpgwapi_datetime::date_to_timestamp($_POST['from_']));
-//                             $_POST['to_'] = date("Y-m-d H:i:s", 
phpgwapi_datetime::date_to_timestamp($_POST['to_']));
-//                             $_POST['repeat_until'] = date("Y-m-d", 
phpgwapi_datetime::date_to_timestamp($_POST['repeat_until']));
-//                             $_POST['from_'] = 
phpgw::get_var('from_','string', 'POST');
-//                             $_POST['to_'] = phpgw::get_var('to_','string', 
'POST');
-//                             $_POST['repeat_until'] = 
phpgw::get_var('repeat_until','string', 'POST');
 
                                $today = getdate();
                                $booking = extract_values($_POST, 
$this->fields);
@@ -411,10 +405,8 @@
                                        $this->add_cost_history($booking, 
phpgw::get_var('cost_comment'), phpgw::get_var('cost', 'float'));
                                }
 
-//                             $timestamp = strtotime($booking['from_']);
                                $timestamp = 
phpgwapi_datetime::date_to_timestamp($booking['from_']);
                                $booking['from_'] = date("Y-m-d H:i:s", 
$timestamp);
-//                             $timestamp = strtotime($booking['to_']);
                                $timestamp = 
phpgwapi_datetime::date_to_timestamp($booking['to_']);
                                $booking['to_'] = date("Y-m-d H:i:s", 
$timestamp);
 
@@ -438,18 +430,6 @@
 
                                $errors = $this->bo->validate($booking);
 
-#                              if (strtotime($_POST['from_']) < $today[0])
-#                              {
-#                                      if($_POST['recurring'] == 'on' || 
$_POST['outseason'] == 'on')
-#                                      {                                       
-#                                              $errors['booking'] = lang('Can 
not repeat from a date in the past');
-#                                      }
-#                                      else
-#                                      {
-#                                              $errors['booking'] = lang('Can 
not create a booking in the past');
-#                                      }
-#                              } 
-
                                if (!$booking['season_id'] && 
$_POST['outseason'] == 'on')
                                {
                                        $errors['booking'] = lang('This booking 
is not connected to a season');

Modified: trunk/bookingfrontend/inc/class.uibooking.inc.php
===================================================================
--- trunk/bookingfrontend/inc/class.uibooking.inc.php   2017-10-01 12:46:54 UTC 
(rev 17129)
+++ trunk/bookingfrontend/inc/class.uibooking.inc.php   2017-10-02 14:00:14 UTC 
(rev 17130)
@@ -106,6 +106,12 @@
                        #The string replace is a workaround for a problem at 
Bergen Kommune
                        $booking['from_'] = str_replace('%3A', ':', 
phpgw::get_var('from_', 'string', 'GET'));
                        $booking['to_'] = str_replace('%3A', ':', 
phpgw::get_var('to_', 'string', 'GET'));
+                       foreach ($booking['from_'] as $k => $v)
+                       {
+                               $booking['from_'][$k] = 
pretty_timestamp($booking['from_'][$k]);
+                               $booking['to_'][$k] = 
pretty_timestamp($booking['to_'][$k]);
+                       }
+
                        $time_from = explode(" ", phpgw::get_var('from_', 
'string', 'GET'));
                        $time_to = explode(" ", phpgw::get_var('to_', 'string', 
'GET'));
 
@@ -116,6 +122,9 @@
                        if ($allocation_id)
                        {
                                $allocation = 
$this->allocation_bo->read_single($allocation_id);
+                               $boapplication = 
CreateObject('booking.boapplication');
+                               $application = 
$boapplication->read_single($allocation['application_id']);
+                               $activity_id = $application['activity_id'];
                                $season = 
$this->season_bo->read_single($allocation['season_id']);
                                $building = 
$this->building_bo->read_single($season['building_id']);
                                $booking['season_id'] = $season['id'];
@@ -130,16 +139,21 @@
                        }
                        if ($_SERVER['REQUEST_METHOD'] == 'POST')
                        {
-                               $_POST['repeat_until'] = 
($_POST['repeat_until']) ? date("Y-m-d", 
phpgwapi_datetime::date_to_timestamp($_POST['repeat_until'])) : "";
 
                                $today = getdate();
                                $booking = extract_values($_POST, 
$this->fields);
+
+                               $timestamp = 
phpgwapi_datetime::date_to_timestamp($booking['from_']);
+                               $booking['from_'] = date("Y-m-d H:i:s", 
$timestamp);
+                               $timestamp = 
phpgwapi_datetime::date_to_timestamp($booking['to_']);
+                               $booking['to_'] = date("Y-m-d H:i:s", 
$timestamp);
+
                                if (strlen($_POST['from_']) < 6)
                                {
-                                       $date_from = array($time_from[0], 
phpgw::get_var('from_'));
+                                       $date_from = array($time_from[0], 
$_POST['from_']);
                                        $booking['from_'] = join(" ", 
$date_from);
                                        $_POST['from_'] = join(" ", $date_from);
-                                       $date_to = array($time_to[0], 
phpgw::get_var('to_'));
+                                       $date_to = array($time_to[0], 
$_POST['to_']);
                                        $booking['to_'] = join(" ", $date_to);
                                        $_POST['to_'] = join(" ", $date_to);
                                }
@@ -158,17 +172,6 @@
                                $errors = $this->bo->validate($booking);
 
 
-#                              if (strtotime($_POST['from_']) < $today[0])
-#                              {
-#                                      if($_POST['recurring'] == 'on' || 
$_POST['outseason'] == 'on')
-#                                      {                                       
-#                                              $errors['booking'] = lang('Can 
not repeat from a date in the past');
-#                                      }
-#                                      else
-#                                      {
-#                                              $errors['booking'] = lang('Can 
not create a booking in the past');
-#                                      }
-#                              } 
                                if (!$season['id'] && $_POST['outseason'] == 
'on')
                                {
                                        $errors['booking'] = lang('This booking 
is not connected to a season');
@@ -189,15 +192,15 @@
                                {
                                        if ($_POST['recurring'] == 'on')
                                        {
-                                               $repeat_until = 
strtotime($_POST['repeat_until']) + 60 * 60 * 24;
+                                               $repeat_until = 
phpgwapi_datetime::date_to_timestamp($_POST['repeat_until']) + 60 * 60 * 24;
                                        }
                                        else
                                        {
                                                $repeat_until = 
strtotime($season['to_']) + 60 * 60 * 24;
-                                               $_POST['repeat_until'] = 
$season['to_'];
+                                               $_POST['repeat_until'] = 
pretty_timestamp($season['to_']);
                                        }
 
-                                       $max_dato = strtotime($_POST['to_']); 
// highest date from input
+                                       $max_dato = 
phpgwapi_datetime::date_to_timestamp($_POST['to_']); // highest date from input
                                        $interval = $_POST['field_interval'] * 
60 * 60 * 24 * 7; // weeks in seconds
                                        $i = 0;
                                        // calculating valid and invalid dates 
from the first booking's to-date to the repeat_until date is reached
@@ -204,8 +207,8 @@
                                        // the form from step 1 should validate 
and if we encounter any errors they are caused by double bookings.
                                        while (($max_dato + ($interval * $i)) 
<= $repeat_until)
                                        {
-                                               $fromdate = date('Y-m-d H:i', 
strtotime($_POST['from_']) + ($interval * $i));
-                                               $todate = date('Y-m-d H:i', 
strtotime($_POST['to_']) + ($interval * $i));
+                                               $fromdate = date('Y-m-d H:i', 
phpgwapi_datetime::date_to_timestamp($_POST['from_']) + ($interval * $i));
+                                               $todate = date('Y-m-d H:i', 
phpgwapi_datetime::date_to_timestamp($_POST['to_']) + ($interval * $i));
                                                $booking['from_'] = $fromdate;
                                                $booking['to_'] = $todate;
                                                $fromdate = 
pretty_timestamp($fromdate);
@@ -212,6 +215,7 @@
                                                $todate = 
pretty_timestamp($todate);
 
                                                $err = 
$this->bo->validate($booking);
+
                                                if ($err)
                                                {
                                                        
$invalid_dates[$i]['from_'] = $fromdate;
@@ -245,6 +249,8 @@
                        {
                                $activity_id = phpgw::get_var('activity_id', 
'int', 'REQUEST', -1);
                        }
+                       $booking['activity_id'] = $activity_id;
+
                        $activity_path = 
$this->activity_bo->get_path($activity_id);
                        $top_level_activity = $activity_path ? 
$activity_path[0]['id'] : -1;
 
@@ -270,13 +276,13 @@
                                $res_names[] = array('id' => $res['id'], 'name' 
=> $res['name']);
                        }
 
-                       $GLOBALS['phpgw']->jqcal2->add_listener('field_from', 
'time');
-                       $GLOBALS['phpgw']->jqcal2->add_listener('field_to', 
'time');
-                       
$GLOBALS['phpgw']->jqcal2->add_listener('field_repeat_until', 'date');
-
                        $booking['from_'] = pretty_timestamp($booking['from_']);
                        $booking['to_'] = pretty_timestamp($booking['to_']);
 
+                       $GLOBALS['phpgw']->jqcal2->add_listener('field_from', 
'datetime', phpgwapi_datetime::date_to_timestamp($booking['from_']));
+                       $GLOBALS['phpgw']->jqcal2->add_listener('field_to', 
'datetime', phpgwapi_datetime::date_to_timestamp($booking['to_']));
+                       
$GLOBALS['phpgw']->jqcal2->add_listener('field_repeat_until', 'date');
+
                        
phpgwapi_jquery::formvalidator_generate(array('location', 'date', 'security',
                                'file'), 'booking_form');
 
@@ -517,13 +523,14 @@
                                        'active' => 1)));
                        $groups = $groups['results'];
 
-                       $GLOBALS['phpgw']->jqcal2->add_listener('field_from', 
'datetime');
-                       $GLOBALS['phpgw']->jqcal2->add_listener('field_to', 
'datetime');
+                       $booking['from_'] = pretty_timestamp($booking['from_']);
+                       $booking['to_'] = pretty_timestamp($booking['to_']);
 
+                       $GLOBALS['phpgw']->jqcal2->add_listener('field_from', 
'datetime', phpgwapi_datetime::date_to_timestamp($booking['from_']));
+                       $GLOBALS['phpgw']->jqcal2->add_listener('field_to', 
'datetime', phpgwapi_datetime::date_to_timestamp($booking['to_']));
+
                        
$GLOBALS['phpgw']->jqcal2->add_listener('field_repeat_until', 'date');
 
-                       $booking['from_'] = pretty_timestamp($booking['from_']);
-                       $booking['to_'] = pretty_timestamp($booking['to_']);
 
                        foreach ($bookings['results'] as &$b)
                        {
@@ -857,8 +864,8 @@
                                $booking['resources_json'] = 
json_encode(array_map('intval', $booking['resources']));
 
                                $this->flash_form_errors($errors);
-                               $allocation['cancel_link'] = 
self::link(array('menuaction' => 'bookingfrontend.uibuilding.schedule',
-                                               'id' => 
$allocation['building_id']));
+                               $booking['cancel_link'] = 
self::link(array('menuaction' => 'bookingfrontend.uibuilding.schedule',
+                                               'id' => 
$booking['building_id']));
 
                                self::rich_text_editor('field-message');
                                self::render_template_xsl('booking_cancel', 
array('booking' => $booking));

Modified: trunk/bookingfrontend/inc/custom/default/Altinn2_Bergen_kommune.php
===================================================================
--- trunk/bookingfrontend/inc/custom/default/Altinn2_Bergen_kommune.php 
2017-10-01 12:46:54 UTC (rev 17129)
+++ trunk/bookingfrontend/inc/custom/default/Altinn2_Bergen_kommune.php 
2017-10-02 14:00:14 UTC (rev 17130)
@@ -121,6 +121,17 @@
                        $stage = phpgw::get_var('stage');
                        $org_id = phpgw::get_var('org_id');
 
+                       if ($this->debug)
+                       {
+                               $orgs[] = array
+                                       (
+                                       'id' => 994239929,
+                                       'name' => 'Bølleball',
+                               );
+                               $orgs_validate[] = 994239929;
+                               $fodsels_nr = 1;
+                       }
+
                        if ($stage == 2 && $fodsels_nr && in_array($org_id, 
$orgs_validate))
                        {
                                try




reply via email to

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