[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [15495]
From: |
saul . huanay |
Subject: |
[Fmsystem-commits] [15495] |
Date: |
Sat, 20 Aug 2016 01:00:20 +0000 (UTC) |
Revision: 15495
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15495
Author: psaul
Date: 2016-08-20 01:00:20 +0000 (Sat, 20 Aug 2016)
Log Message:
-----------
Modified Paths:
--------------
branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php
branches/dev-syncromind-2/rental/inc/class.uicomposite.inc.php
Added Paths:
-----------
branches/dev-syncromind-2/rental/js/rental/schedule.js
Modified: branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php
2016-08-19 13:04:03 UTC (rev 15494)
+++ branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php
2016-08-20 01:00:20 UTC (rev 15495)
@@ -518,9 +518,10 @@
return $uicols;
}
- public function get_schedule () {
- $date = new DateTime(phpgw::get_var('date'));
- $composite_id = (int)phpgw::get_var('id');
+ public function get_schedule ($composite_id, $date) {
+ //$date = new DateTime('2016-8-24');
+ //$date = new DateTime(phpgw::get_var('date'));
+ //$composite_id = (int)phpgw::get_var('id');
if ($date->format('w') != 1) {
$date->modify('last monday');
@@ -539,7 +540,8 @@
$date_to_array = clone $date;
for ($i = 0; $i < 7; $i++)
{
- $days[] = clone $date_to_array->modify("+1 day");
+ $days[] = clone $date_to_array;
+ $date_to_array->modify("+1 day");
}
/*----------------------------------------------------------------*/
@@ -563,15 +565,47 @@
$data_contracts = array();
- foreach ($contracts as $contract) {
+ //foreach ($contracts as $contract) {
+ //$contract = $contract->serialize();
+ //$contract_date = new DateTime($contract['date_start']);
+ //$contract_date = date("d-m-Y",
strtotime($contract['date_start']));
+ //$contract_date =
date_format(date_create_from_format('d/m/Y', $contract['date_start']), 'Y-m-d');
+ //$data_contracts[date_format($date, 'D')] = $contract_date;
+ //}
+ //var_dump($contracts);exit();
+ foreach ($contracts as $contract)
+ {
$contract = $contract->serialize();
- $contract_date = date_format(date_create_from_format('d/m/Y',
$contract['date_start']), 'Y-m-d');
- $data_contracts[date_format($date, 'D')] = $contract_date;
+
+ //$contract_date_start = new
DateTime(date_format(date_create_from_format('d/m/Y', $contract['date_start']),
'Y-m-d'));
+ //$contract_date_end = new
DateTime(date_format(date_create_from_format('d/m/Y', $contract['date_end']),
'Y-m-d'));
+
+ $contract_date_start = new DateTime(date('Y-m-d',
phpgwapi_datetime::date_to_timestamp($contract['date_start'])));
+ $contract_date_end = new DateTime(date('Y-m-d',
phpgwapi_datetime::date_to_timestamp($contract['date_end'])));
+
+ $data_contract = array();
+
+ foreach ($days as $day)
+ {
+ if ($day >= $contract_date_start && $day <=
$contract_date_end)
+ {
+ $data_contract[date_format($day, 'D')] = $contract;
+ }
+ }
+ if ($data_contract) {
+ $data_contracts[] = $data_contract;
+ }
+
}
- var_dump($data_contracts);
- exit();
+ if (!(count($data_contracts) > 0))
+ {
+ $data_contracts[] = '';
+ }
- return $composite1;
+ return array(
+ 'total_records' => count($data_contracts),
+ 'results' => $data_contracts
+ );
}
}
\ No newline at end of file
Modified: branches/dev-syncromind-2/rental/inc/class.uicomposite.inc.php
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.uicomposite.inc.php
2016-08-19 13:04:03 UTC (rev 15494)
+++ branches/dev-syncromind-2/rental/inc/class.uicomposite.inc.php
2016-08-20 01:00:20 UTC (rev 15495)
@@ -1115,14 +1115,14 @@
$schedule['datasource_url'] = self::link(array(
'menuaction' => 'rental.uicomposite.get_schedule',
- 'composite_id' => $composite_id,
+ 'id' => $composite_id,
'phpgw_return_as' => 'json'
));
$schedule['date'] = $date;
$schedule['picker_img'] =
$GLOBALS['phpgw']->common->image('phpgwapi', 'cal');
// self::add_javascript('booking','booking','common.js');
- self::add_javascript('booking','booking','schedule.js');
+ self::add_javascript('rental','rental','schedule.js');
phpgwapi_jquery::load_widget("datepicker");
@@ -1131,9 +1131,17 @@
public function get_schedule () {
$composite_id = (int)phpgw::get_var('id');
- $date = phpgw::get_var('date');
- $schedule = rental_socomposite::get_instance()->get_schedule();
+ $date = new DateTime(phpgw::get_var('date'));
+
+ $schedule =
rental_socomposite::get_instance()->get_schedule($composite_id, $date);
- return $date;
+ $data = array(
+ 'ResultSet' => array(
+ "totalResultsAvailable" => $schedule['total_records'],
+ "Result" => $schedule['results']
+ )
+ );
+
+ return $data;
}
}
\ No newline at end of file
Added: branches/dev-syncromind-2/rental/js/rental/schedule.js
===================================================================
--- branches/dev-syncromind-2/rental/js/rental/schedule.js
(rev 0)
+++ branches/dev-syncromind-2/rental/js/rental/schedule.js 2016-08-20
01:00:20 UTC (rev 15495)
@@ -0,0 +1,137 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+var schedule = new Array();
+
+schedule.renderSchedule = function (container, url, date, colFormatter,
includeResource, classTable)
+{
+ classTable = (classTable) ? classTable : "pure-table";
+ while (date.getDay() != 1)
+ {
+ date.setDate(date.getDate() - 1);
+ }
+
+ var datestr = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' +
date.getDate();
+ url += '&date=' + datestr;
+
+ var detected_lang = navigator.language || navigator.userLanguage;
+ var lang = {};
+
+ if(detected_lang == 'no' || detected_lang == 'nn' || detected_lang ==
'nb')
+ {
+ lang = {
+ WEEKDAYS_FULL: [
+ 'Søndag', 'Mandag', 'Tirsdag', 'Onsdag',
'Torsdag', 'Fredag', 'Lørdag'
+ ],
+ MONTHS_LONG: [
+ 'Januar', 'Februar', 'Mars', 'April', 'May',
'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Desember'
+ ],
+ LBL_TIME: 'Tidsrom',
+ LBL_RESOURCE: 'Ressurs',
+ LBL_WEEK: 'Uke'
+ };
+ }
+ else
+ {
+ lang = {
+ WEEKDAYS_FULL: [
+ 'Sunday', 'Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday'
+ ],
+ MONTHS_LONG: [
+ 'January', 'February', 'March', 'April', 'May',
'June', 'July', 'August', 'September', 'October', 'November', 'December'
+ ],
+ LBL_TIME: 'Time',
+ LBL_RESOURCE: 'Resource',
+ LBL_WEEK: 'Week'
+ };
+ }
+
+ var colDefs = [
+ {key: '', label: ''}
+ ]
+
+ var keys = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
+ schedule.dates = {};
+
+ for (var i = 0; i < 7; i++)
+ {
+ var d = new Date(date.getFullYear(), date.getMonth(), date.getDate());
+ d.setDate(d.getDate() + i);
+ var x = (i < 6) ? i + 1 : 0;
+ schedule.dates[keys[x]] = d;
+ colDefs.push({
+ key: keys[x],
+ value: 'old_contract_id',
+ label: lang['WEEKDAYS_FULL'][x] + '<br>' +
lang['MONTHS_LONG'][d.getMonth()] + ' ' + d.getDate(), formatter: colFormatter,
date: d, day: d.getDate()
+ });
+ }
+
+ var r = [{n: 'ResultSet'}, {n: 'Result'}];
+
+ createTableSchedule(container, url, colDefs, r, classTable, datestr)
+
+}
+
+schedule.setupWeekPicker = function ()
+{
+}
+$(function ()
+{
+ $("#cal_container #datepicker").datepicker({
+ showWeek: true,
+ changeMonth: true,
+ changeYear: true,
+ firstDay: 1,
+ dateFormat: 'yy-mm-dd',
+ onSelect: function (a, e)
+ {
+ if (a != schedule.dateSelected)
+ {
+ var date = new Date(a);
+ schedule.dateSelected = a;
+ schedule.updateSchedule(date);
+ }
+ }
+ });
+ $("#cal_container #pickerImg").on('click', function ()
+ {
+ $("#cal_container #datepicker").datepicker("show");
+ });
+});
+
+schedule.updateSchedule = function (date)
+{
+ schedule.week = $.datepicker.iso8601Week(date);
+ $('#cal_container #numberWeek').text(schedule.week);
+ $("#cal_container #datepicker").datepicker("setDate", date);
+ classTable = (schedule.classTable) ? schedule.classTable : 'pure-table';
+
+ var url = self.location.href;
+ url = url.substr(0, (url.indexOf("#date")));
+ url += '#date=' + date.getFullYear() + '-' + (date.getMonth() + 1) +
'-' + date.getDate();
+ location.replace(url);
+ schedule.renderSchedule('schedule_container', schedule.datasourceUrl,
date, schedule.colFormatter, schedule.includeResource, classTable);
+ schedule.date = date;
+}
+
+schedule.moveWeek = function (n)
+{
+ var date = schedule.date;
+ while (date.getDay() != 1)
+ {
+ date.setDate(date.getDate() - 1);
+ }
+ date.setDate(date.getDate() + n);
+ schedule.updateSchedule(date);
+}
+schedule.prevWeek = function ()
+{
+ schedule.moveWeek(-7)
+};
+schedule.nextWeek = function ()
+{
+ schedule.moveWeek(7)
+}
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [15495],
saul . huanay <=