[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [15588]
From: |
saul . huanay |
Subject: |
[Fmsystem-commits] [15588] |
Date: |
Mon, 5 Sep 2016 19:30:50 +0000 (UTC) |
Revision: 15588
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15588
Author: psaul
Date: 2016-09-05 19:30:49 +0000 (Mon, 05 Sep 2016)
Log Message:
-----------
Modified Paths:
--------------
branches/dev-syncromind-2/phpgwapi/js/jquery/common.js
branches/dev-syncromind-2/rental/inc/class.uicomposite.inc.php
branches/dev-syncromind-2/rental/js/rental/schedule.js
Modified: branches/dev-syncromind-2/phpgwapi/js/jquery/common.js
===================================================================
--- branches/dev-syncromind-2/phpgwapi/js/jquery/common.js 2016-09-05
18:14:11 UTC (rev 15587)
+++ branches/dev-syncromind-2/phpgwapi/js/jquery/common.js 2016-09-05
19:30:49 UTC (rev 15588)
@@ -1426,10 +1426,11 @@
var pages = Math.floor(total / n_objects);
var res = total % n_objects;
var page = (start == 0) ? 1 : (start / n_objects) + 1;
-
- pages = (res > 0) ? pages++ : pages;
-
- var paginator = schedule.create_paginator(pages, page);
+
+ pages = (res > 0) ? pages+1 : pages;
+ pages = (pages == 0) ? pages+1 : pages;
+
+ var paginator = createPaginatorSchedule(pages, page);
container.appendChild(paginator);
var input_start = document.createElement('input');
@@ -1438,11 +1439,111 @@
input_start.setAttribute('id', 'start_index');
input_start.value = start;
container.appendChild(input_start);
-
}
});
}
+// p -> n pages
+// a -> current page
+function createPaginatorSchedule (p, a)
+{
+ var max = 7;
+ var m = 4;
+
+ var ini = 1;
+ var end = p;
+
+ var buttons = new Array();
+ var n_button = "";
+ var old_button = "";
+
+ for (i = ini; i <= end; i++)
+ {
+ if (i == ini)
+ {
+ n_button = i;
+ }
+ else if ( (a - ini < m ) && (i <= ini + m) )
+ {
+ n_button = i;
+ }
+ else if ( (i >= a - 1) && (i <= a + 1) )
+ {
+ n_button = i;
+ }
+ else if ( (end - a < m ) && (i >= end - m) )
+ {
+ n_button = i;
+ }
+ else if (i == end)
+ {
+ n_button = i;
+ }
+ else
+ {
+ n_button = "...";
+ }
+ if (n_button != old_button)
+ {
+ buttons.push(n_button);
+ old_button = n_button;
+ }
+ }
+
+ var container = document.createElement('div');
+ container.classList.add('schedule_paginate');
+ container.id = "schedule-container_paginate";
+
+ var paginatorPrevButton = document.createElement('a');
+ var paginatorNextButton = document.createElement('a');
+
+ paginatorPrevButton.classList.add('paginate_button', 'previous');
+ paginatorNextButton.classList.add('paginate_button', 'next');
+
+ paginatorPrevButton.innerHTML = "Prev";
+ paginatorNextButton.innerHTML = "Next";
+
+ if (a > 1)
+ {
+ paginatorPrevButton.dataset.page = (a - 1);
+ }
+ else
+ {
+ paginatorPrevButton.classList.add('disabled');
+ }
+ if (a < p)
+ {
+ paginatorNextButton.dataset.page = (a + 1);
+ }
+ else
+ {
+ paginatorNextButton.classList.add('disabled');
+ }
+
+ container.appendChild(paginatorPrevButton);
+ var button_class = "paginate_button";
+ $.each(buttons, function (i, v)
+ {
+ button_class = "paginate_button"
+ var button = document.createElement('span');
+ if (v == "...")
+ {
+ button_class = 'ellipsis';
+ }
+ button.classList.add(button_class);
+ button.dataset.page = v;
+ if (v == a)
+ {
+ button.classList.add('current');
+ }
+ button.innerHTML = v;
+ container.appendChild(button);
+ });
+ container.appendChild(paginatorNextButton);
+
+ return container;
+}
+
function setFormatter (callFunc, data, col, date)
{
return eval(callFunc+'(data,col,date)');
Modified: branches/dev-syncromind-2/rental/inc/class.uicomposite.inc.php
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.uicomposite.inc.php
2016-09-05 18:14:11 UTC (rev 15587)
+++ branches/dev-syncromind-2/rental/inc/class.uicomposite.inc.php
2016-09-05 19:30:49 UTC (rev 15588)
@@ -1106,7 +1106,8 @@
}
}
- public function schedule () {
+ public function schedule ()
+ {
$composite_id = (int)phpgw::get_var('id');
$date = new DateTime(phpgw::get_var('date'));
if ($date->format('w') != 1) {
@@ -1119,8 +1120,8 @@
$schedule['datasource_url'] = self::link(array(
'menuaction' =>
'rental.uicomposite.get_schedule',
- 'composite_id' => $composite_id,
- 'phpgw_return_as' => 'json'
+ 'phpgw_return_as' => 'json',
+ 'type' => 'all_composites'
));
$schedule['composite_id'] = $composite_id;
$schedule['date'] = $date;
@@ -1133,38 +1134,82 @@
self::render_template_xsl(array('schedule'),
array('schedule' => $schedule));
}
- public function get_schedule () {
+ public function get_schedule ()
+ {
$composite_id = (int)phpgw::get_var('id');
$date = new DateTime(phpgw::get_var('date'));
- $filters = array();
- $options = array();
+ if ($date->format('w') != 1)
+ {
+ $date->modify('last monday');
+ }
- if (phpgw::get_var('furnished_status'))
- $filters['furnished_status'] =
phpgw::get_var('furnished_status');
+ $days = array();
+ $date_to_array = clone $date;
+ for ($i = 0; $i < 7; $i++)
+ {
+ $days[] = clone $date_to_array;
+ $date_to_array->modify("+1 day");
+ }
- if (phpgw::get_var('district_id'))
- $filters['district_id'] =
phpgw::get_var('district_id');
+ $composites_obj = $this->query();
+ $composites_data = $composites_obj['data'];
+
+ $composites = array();
+ $n = 0;
+
+ foreach ($composites_data as $composite)
+ {
+ $composite_obj =
rental_socomposite::get_instance()->get_single($composite['id']);
+ $contracts = $composite_obj->get_contracts();
- if (phpgw::get_var('is_active'))
- $filters['is_active'] =
phpgw::get_var('is_active');
+ if (count($contracts) > 0)
+ {
+ foreach ($contracts as $contract)
+ {
+ $contract = $contract->serialize();
- if (phpgw::get_var('has_contract'))
- $filters['has_contract'] =
phpgw::get_var('has_contract');
+ if ($composites[$n-1]['id'] != $composite['id'])
+ {
+ $composites[$n]['id'] = $composite['id'];
+ }
+
+ $composites[$n]['name'] = $composite['name'];
- $options['start'] = (phpgw::get_var('start')) ?
phpgw::get_var('start') : 0;
- $options['num_of_objects'] =
(phpgw::get_var('n_objects')) ? phpgw::get_var('n_objects') : 0;
- $options['sort_field'] = '';
- $options['ascending'] = false;
- $options['search_for'] = (phpgw::get_var('search')) ?
phpgw::get_var('search') : '' ;
- $options['search_type'] =
(phpgw::get_var('search_option')) ? phpgw::get_var('search_option') : 'all';
+ $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'])));
- $schedule =
rental_socomposite::get_instance()->get_schedule($date, $filters, $options);
+ foreach ($days as $day)
+ {
+ if ($day >= $contract_date_start && ($day <=
$contract_date_end || $contract['date_end'] == ''))
+ {
+ $composites[$n]['contract_id'] =
$contract['id'];
+ $composites[$n]['old_contract_id'] =
$contract['old_contract_id'];
+ $composites[$n][date_format($day,
'D')]['status'] = 'Ikke ledig';
+ }
+ else
+ {
+ $composites[$n][date_format($day,
'D')]['status'] = 'Ledig';
+ }
+ }
+ }
+ }
+ else
+ {
+ $composites[$n]['id'] = $composite['id'];
+ $composites[$n]['name'] = $composite['name'];
+ foreach ($days as $day)
+ {
+ $composites[$n][date_format($day, 'D')]['status'] =
'Ledig';
+ }
+ }
+ $n++;
+ }
$data = array(
'ResultSet' => array(
- "totalResultsAvailable" =>
$schedule['total_records'],
- "Result" => $schedule['results']
+ "totalResultsAvailable" =>
$composites_obj['recordsTotal'],
+ "Result" => $composites
)
);
Modified: branches/dev-syncromind-2/rental/js/rental/schedule.js
===================================================================
--- branches/dev-syncromind-2/rental/js/rental/schedule.js 2016-09-05
18:14:11 UTC (rev 15587)
+++ branches/dev-syncromind-2/rental/js/rental/schedule.js 2016-09-05
19:30:49 UTC (rev 15588)
@@ -106,7 +106,7 @@
});
schedule.updateSchedule = function (date)
-{
+{
schedule.week = $.datepicker.iso8601Week(date);
$('#cal_container #numberWeek').text(schedule.week);
$("#cal_container #datepicker").datepicker("setDate", date);
@@ -139,210 +139,10 @@
schedule.moveWeek(7)
}
-// p -> pages
-// a -> page actual
-
-schedule.create_paginator = function (p, a)
+$(window).load(function()
{
- var max = 7;
- var m = 4;
-// var n_buttons = (p > max) ? max : p;
- var ini = 1;
- var end = p;
-
- var buttons = new Array();
- var n_button = "";
- var old_button = "";
-
- for (i = ini; i <= end; i++)
+ function searchSchedule ()
{
- if (i == ini)
- {
- n_button = i;
- }
- else if ( (a - ini < m ) && (i <= ini + m) )
- {
- n_button = i;
- }
- else if ( (i >= a - 1) && (i <= a + 1) )
- {
- n_button = i;
- }
- else if ( (end - a < m ) && (i >= end - m) )
- {
- n_button = i;
- }
- else if (i == end)
- {
- n_button = i;
- }
- else
- {
- n_button = "...";
- }
- if (n_button != old_button)
- {
- buttons.push(n_button);
- old_button = n_button;
- }
- }
-
- var container = document.createElement('div');
- container.classList.add('schedule_paginate');
- container.id = "schedule-container_paginate";
-
- var paginatorPrevButton = document.createElement('a');
- var paginatorNextButton = document.createElement('a');
-
- paginatorPrevButton.classList.add('paginate_button', 'previous');
- paginatorNextButton.classList.add('paginate_button', 'next');
-
- paginatorPrevButton.innerHTML = "Prev";
- paginatorNextButton.innerHTML = "Next";
-
- if (a > 1)
- {
- paginatorPrevButton.dataset.page = (a - 1);
- }
- else
- {
- paginatorPrevButton.classList.add('disabled');
- }
- if (a < p)
- {
- paginatorNextButton.dataset.page = (a + 1);
- }
- else
- {
- paginatorNextButton.classList.add('disabled');
- }
-
- container.appendChild(paginatorPrevButton);
- var button_class = "paginate_button";
- $.each(buttons, function (i, v)
- {
- button_class = "paginate_button"
- var button = document.createElement('span');
- if (v == "...")
- {
- button_class = 'ellipsis';
- }
- button.classList.add(button_class);
- button.dataset.page = v;
- if (v == a)
- {
- button.classList.add('current');
- }
- button.innerHTML = v;
- container.appendChild(button);
- });
- container.appendChild(paginatorNextButton);
-
- return container;
-}
-
-
-
-
-
-
-//schedule.create_paginator = function (p, a)
-//{
-// var max = 7;
-// var m = 4;
-//
-// var n_buttons = (p > max) ? max : p;
-//
-// var ini = 1;
-// var end = p;
-//
-// var buttons = new Array();
-
-// for (i = ini; i <= n_buttons; i++)
-// {
-// if (i == ini)
-// {
-// buttons.push(ini);
-// }
-//
-// else if ( (a - ini < m) && (i > ini) && (i < a + 1) && ( (i != a +
1) && (i != a) && (i != a - 1) ) )
-// {
-// buttons.push(i);
-// }
-//
-// else if ()
-// {
-//
-// }
-//
-// else if (i == n_buttons)
-// {
-// buttons.push(end);
-// }
-// else
-// {
-// buttons.push('...');
-// }
-// }
-
-
-
-// for (i = ini; i <= end; i++)
-// {
-// if (i == ini)
-// {
-// console.log(1);
-// button = i;
-// }
-//
-//
-// else if ( (a - ini < m ) && (i <= ini + m) )
-// {
-// console.log(2);
-// button = i;
-// }
-//
-//
-// else if ( (i >= a - 1) && (i <= a + 1) )
-// {
-// console.log(3);
-// button = i;
-// }
-//
-// else if ( (end - a < m ) && (i >= end - m) )
-// {
-// console.log(4);
-// button = i;
-// }
-//
-//
-//
-//
-//
-//
-//
-//
-// else if (i == end)
-// {
-// console.log(5);
-// button = i;
-// }
-// else
-// {
-// button = "...";
-// }
-//
-// buttons.push(button);
-// }
-//
-// console.log(buttons);
-
- // Si entre el inicio y la pagina activa hay una diferencia de tres o
menos, se muestran todos esos
- // Si entre la pagina activa y el fin hay una diferencia de tres o menos,
se muestran todos esos
-//}
-
-$(window).load(function() {
- function searchSchedule () {
var location_id = $('#location_id').val();
var search_option = $('#search_option').val();
var contract_status = $('#contract_status').val();
@@ -366,13 +166,17 @@
schedule.renderSchedule('schedule_container', schedule.datasourceUrl,
schedule.date, schedule.colFormatter, schedule.includeResource);
}
- $('select.searchSchedule').on('change', function() {
+ $('select.searchSchedule').on('change', function()
+ {
schedule.renderSchedule('schedule_container', schedule.datasourceUrl,
schedule.date, schedule.colFormatter, schedule.includeResource);
});
- $('input.searchSchedule').on('keyup', function() {
+ $('input.searchSchedule').on('keyup', function()
+ {
var $this = $(this);
- if ($this.data('text') != $this.val()) {
- setTimeout(function(){
+ if ($this.data('text') != $this.val())
+ {
+ setTimeout(function()
+ {
$this.data('text', $this.val());
schedule.params.search = $this.val();
schedule.renderSchedule('schedule_container',
schedule.datasourceUrl, schedule.date, schedule.colFormatter,
schedule.includeResource);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [15588],
saul . huanay <=