fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15573]


From: saul . huanay
Subject: [Fmsystem-commits] [15573]
Date: Sat, 3 Sep 2016 00:21:27 +0000 (UTC)

Revision: 15573
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15573
Author:   psaul
Date:     2016-09-03 00:21:27 +0000 (Sat, 03 Sep 2016)
Log Message:
-----------


Modified Paths:
--------------
    branches/dev-syncromind-2/phpgwapi/js/jquery/common.js
    branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php
    branches/dev-syncromind-2/rental/inc/class.uicomposite.inc.php
    branches/dev-syncromind-2/rental/js/rental/schedule.js
    branches/dev-syncromind-2/rental/templates/base/schedule.xsl

Modified: branches/dev-syncromind-2/phpgwapi/js/jquery/common.js
===================================================================
--- branches/dev-syncromind-2/phpgwapi/js/jquery/common.js      2016-09-02 
14:18:51 UTC (rev 15572)
+++ branches/dev-syncromind-2/phpgwapi/js/jquery/common.js      2016-09-03 
00:21:27 UTC (rev 15573)
@@ -1425,11 +1425,20 @@
 
             var pages = Math.floor(total / n_objects);
             var res = total % n_objects;
-
-            if (res > 0)
-            {
-                pages++;
-            }
+            var page = (start == 0) ? 1 : (start / n_objects) + 1;
+            
+            pages = (res > 0) ? pages++ : pages;
+            
+            var paginator = schedule.create_paginator(pages, page);
+            container.appendChild(paginator);
+            
+            var input_start = document.createElement('input');
+            input_start.setAttribute('type', 'hidden');
+            input_start.setAttribute('name', 'start_index');
+            input_start.setAttribute('id', 'start_index');
+            input_start.value = start;
+            container.appendChild(input_start);
+            
         }
        });
 }

Modified: branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php      
2016-09-02 14:18:51 UTC (rev 15572)
+++ branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php      
2016-09-03 00:21:27 UTC (rev 15573)
@@ -602,7 +602,7 @@
                     foreach ($contracts as $contract)
                     {
                         $contract = $contract->serialize();
-                        
+
                         if ($composites[$n-1]['id'] != $composite['id'])
                         {
                             $composites[$n]['id'] = $composite['id'];
@@ -626,7 +626,7 @@
                                 $composites[$n][date_format($day, 
'D')]['status'] = 'Ledig';
                             }
                         }
-                        $n++;
+//                        $n++;
                     }
                 }
                 else
@@ -637,10 +637,11 @@
                     {
                         $composites[$n][date_format($day, 'D')]['status'] = 
'Ledig';
                     }
-                    $n++;
+//                    $n++;
                 }
+                $n++;
             }
-            
+
 //                     if (!(count($composites) > 0))
 //                     {
 //                             $composites[] = '';

Modified: branches/dev-syncromind-2/rental/inc/class.uicomposite.inc.php
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.uicomposite.inc.php      
2016-09-02 14:18:51 UTC (rev 15572)
+++ branches/dev-syncromind-2/rental/inc/class.uicomposite.inc.php      
2016-09-03 00:21:27 UTC (rev 15573)
@@ -1152,8 +1152,8 @@
             if (phpgw::get_var('has_contract'))
                                $filters['has_contract'] = 
phpgw::get_var('has_contract');
 
-                       $options['start_index'] = 0;
-                       $options['num_of_objects'] = 
(phpgw::get_var('n_objects')) ? phpgw::get_var('n_objects') : 15;
+                       $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') : '' ;

Modified: branches/dev-syncromind-2/rental/js/rental/schedule.js
===================================================================
--- branches/dev-syncromind-2/rental/js/rental/schedule.js      2016-09-02 
14:18:51 UTC (rev 15572)
+++ branches/dev-syncromind-2/rental/js/rental/schedule.js      2016-09-03 
00:21:27 UTC (rev 15573)
@@ -7,7 +7,7 @@
 var schedule = new Array();
 
 schedule.renderSchedule = function (container, url, date, colFormatter, 
includeResource, classTable)
-{   
+{
     classTable = (classTable) ? classTable : "pure-table";
     while (date.getDay() != 1)
        {
@@ -50,8 +50,7 @@
        }
     
     var colDefs = [
-        {key: 'id', label: 'Composite ID', type: 'th'},
-        {key: 'old_contract_id', label: 'Contract'}
+        {key: 'id', label: 'Composite ID', type: 'th'}
     ]
 
     var keys = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
@@ -140,6 +139,208 @@
        schedule.moveWeek(7)
 }
 
+// p -> pages
+// a -> page actual
+
+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();
+    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;
+}
+    
+
+
+
+
+
+//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();
@@ -177,7 +378,19 @@
                 schedule.renderSchedule('schedule_container', 
schedule.datasourceUrl, schedule.date, schedule.colFormatter, 
schedule.includeResource);
             }, 500);
         }
-    });    
+    });
+
+    $('#schedule_container').on('click', '.paginate_button', function()
+    {
+        if ($(this).data('page'))
+        {
+            var page = $(this).data('page');
+            var l = $('#cboNObjects').val();
+            var start = l * (page - 1);
+            schedule.params.start = start;
+            schedule.renderSchedule('schedule_container', 
schedule.datasourceUrl, schedule.date, schedule.colFormatter, 
schedule.includeResource);
+        }
+    })
 })
 
 

Modified: branches/dev-syncromind-2/rental/templates/base/schedule.xsl
===================================================================
--- branches/dev-syncromind-2/rental/templates/base/schedule.xsl        
2016-09-02 14:18:51 UTC (rev 15572)
+++ branches/dev-syncromind-2/rental/templates/base/schedule.xsl        
2016-09-03 00:21:27 UTC (rev 15573)
@@ -16,9 +16,23 @@
                #cal_container {margin: 0 20px;}
                #cal_container #datepicker {width: 2px;opacity: 0;position: 
absolute;display:none;}
                #cal_container #numberWeek {width: 20px;display: inline-block;}
+        #schedule_container {display: inline-block;position: relative;}
         #scheduleSearchBox {display: inline-block; vertical-align: middle;}
             #scheduleSearchBox label {margin-right: 5px; margin-left: 20px;}
             #scheduleSearchBox #txtSearchSchedule {}
+        .schedule_paginate#schedule-container_paginate {bottom: 
-50px;position: absolute;right: 0;}
+        .schedule_paginate#schedule-container_paginate .ellipsis {padding: 0 
1em;}
+        .paginate_button {border: 1px solid transparent;border-radius: 
2px;box-sizing: border-box;color: #333 !important;cursor: pointer;display: 
inline-block;margin-left: 2px;min-width: 1.5em;padding: 0.5em 1em;text-align: 
center;text-decoration: none !important;}
+        .paginate_button:hover {background: rgba(0, 0, 0, 0) 
linear-gradient(to bottom, #585858 0%, #111 100%) repeat scroll 0 0;border: 1px 
solid #111;color: white !important;}
+        .paginate_button:active {background: rgba(0, 0, 0, 0) 
linear-gradient(to bottom, #2b2b2b 0%, #0c0c0c 100%) repeat scroll 0 
0;box-shadow: 0 0 3px #111 inset;outline: medium none;}
+        .paginate_button.disabled,
+        .paginate_button.disabled:hover,
+        .paginate_button.disabled:active {background: transparent none repeat 
scroll 0 0;border: 1px solid transparent;box-shadow: none;color: #666 
!important;cursor: default;}
+        .paginate_button.previous {}
+        .paginate_button.next {}
+        .paginate_button.current,
+        .paginate_button.current:hover {background: rgba(0, 0, 0, 0) 
linear-gradient(to bottom, white 0%, #dcdcdc 100%) repeat scroll 0 0;border: 
1px solid #979797;color: #333 !important;}
+        
        </style>
     <div id="contract_schedule">
         <div id="shceduleFilters">
@@ -145,6 +159,23 @@
                 });
             </script>
         </p>
+
+
+        <!--div class="schedule_paginate" id="schedule-container_paginate">
+            <a class="paginate_button previous disabled" data-dt-idx="0" 
tabindex="1" id="schedule-container_previous">!prev</a>
+            <span>
+                <a class="paginate_button current" data-dt-idx="1" 
tabindex="1">1</a>
+                <a class="paginate_button " data-dt-idx="2" tabindex="1">2</a>
+                <a class="paginate_button " data-dt-idx="3" tabindex="1">3</a>
+                <a class="paginate_button " data-dt-idx="4" tabindex="1">4</a>
+                <a class="paginate_button " data-dt-idx="5" tabindex="1">5</a>
+                <span class="ellipsis">…</span>
+                <a class="paginate_button " data-dt-idx="6" tabindex="1">25</a>
+            </span>
+            <a class="paginate_button next" data-dt-idx="7" tabindex="1" 
id="schedule-container_next">Next</a>
+        </div-->
+
+
     </div>
     <script type="text/javascript">
         var composite_id = '<xsl:value-of select="composite_id"/>';
@@ -152,6 +183,7 @@
             
             schedule.params.n_objects = $('#cboNObjects').val();
             schedule.params.search = $('#txtSearchSchedule').val();
+            schedule.params.start = 0;
         
             schedule.setupWeekPicker('cal_container');
 




reply via email to

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