fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15688]


From: saul . huanay
Subject: [Fmsystem-commits] [15688]
Date: Fri, 16 Sep 2016 23:58:10 +0000 (UTC)

Revision: 15688
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15688
Author:   psaul
Date:     2016-09-16 23:58:10 +0000 (Fri, 16 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/application.xsl
    branches/dev-syncromind-2/rental/templates/base/rental_schedule.xsl
    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-16 
09:01:05 UTC (rev 15687)
+++ branches/dev-syncromind-2/phpgwapi/js/jquery/common.js      2016-09-16 
23:58:10 UTC (rev 15688)
@@ -1829,6 +1829,70 @@
        return data_return;
 }
 
+function rentalScheduleApplication (data, col, date)
+{
+       var text = "";
+       var classes = "";
+       var trAttributes = [];
+       var trFunction = [];
+       
+       var validate = false;
+       
+       if ( (schedule.rental.availability_from) && 
(schedule.rental.availability_to) ){
+               if (col.date >= schedule.rental.availability_from && col.date 
<= schedule.rental.availability_to){
+                       validate = true;
+               }
+       }
+       
+       if (validate)
+       {
+               var k = col.key;
+
+               var needFree = true;
+               if (data[k])
+               {
+                       text = data[k]['status'];
+                       if (text == "Ikke ledig")
+                       {
+                               needFree = false;
+                       }
+               }
+               else
+               {
+                       text = "free";
+                       classes = "free";
+               }
+
+               trAttributes.push( {attribute: 'data-id', value: data['id']} );
+               trFunction.push(
+                       {
+                               event: 'click',
+                               callFunction: function () {
+                                       
$(this).parent().parent().find('tr').removeClass("trselected")
+                                       $(this).parent().addClass("trselected");
+                                       $('#schedule_toolbar 
button').attr('disabled', false);
+                                       var b_needFree = eval(needFree);
+                                       if (!b_needFree)
+                                       {
+                                               $('#schedule_toolbar 
button.need-free').attr('disabled', true);
+                                       }
+                                       schedule.rental.data = data;
+                                       schedule.rental.col = col;
+                               }
+                       }
+               );
+       }
+
+       var data_return = {
+               text: text,
+               classes: classes,
+               trAttributes: trAttributes,
+               trFunction: trFunction
+       }
+
+       return data_return;
+}
+
 function restartColors()
 {
        colors = [

Modified: branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php      
2016-09-16 09:01:05 UTC (rev 15687)
+++ branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php      
2016-09-16 23:58:10 UTC (rev 15688)
@@ -80,14 +80,14 @@
 
                        if (isset($filters['availability_date_from']) && 
$filters['availability_date_from'] != '')
                        {
-                               //$availability_date_from = 
strtotime($filters['availability_date_from']);
-                               $availability_date_from =  
phpgwapi_datetime::date_to_timestamp($filters['availability_date_from']);
+                               $availability_date_from = 
strtotime($filters['availability_date_from']);
+//                             $availability_date_from =  
phpgwapi_datetime::date_to_timestamp($filters['availability_date_from']);
                        }
 
                        if (isset($filters['availability_date_to']) && 
$filters['availability_date_to'] != '')
                        {
-                               //$availability_date_to = 
strtotime($filters['availability_date_to']);
-                               $availability_date_to =  
phpgwapi_datetime::date_to_timestamp($filters['availability_date_to']);
+                               $availability_date_to = 
strtotime($filters['availability_date_to']);
+//                             $availability_date_to =  
phpgwapi_datetime::date_to_timestamp($filters['availability_date_to']);
                        }
 
                        switch ($filters['has_contract'])
@@ -163,8 +163,8 @@
                        {
                                $filter_clauses[] = "rental_composite.id = 
{$this->marshal($filters[$this->get_id_field_name()], 'int')}";
                        }
+                       
 
-
                        $tables = "rental_composite";
                        $joins = "      {$this->left_join} rental_unit ON 
(rental_composite.id = rental_unit.composite_id)";
                        $joins .= "     {$this->left_join} 
rental_contract_composite ON (rental_contract_composite.composite_id = 
rental_composite.id)";

Modified: branches/dev-syncromind-2/rental/inc/class.uicomposite.inc.php
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.uicomposite.inc.php      
2016-09-16 09:01:05 UTC (rev 15687)
+++ branches/dev-syncromind-2/rental/inc/class.uicomposite.inc.php      
2016-09-16 23:58:10 UTC (rev 15688)
@@ -1235,7 +1235,7 @@
                                                'responsibility_id' => 
$create_type[0]
                                        )),
                                        'attributes' => array(
-                                               'class' => 'create_type'
+                                               'class' => 'need-free'
                                        ),
                                        'parameters' => $parameters
                                );
@@ -1279,65 +1279,15 @@
 
                        foreach ($composites_data as $composite)
                        {
-                               $composite_obj = 
rental_socomposite::get_instance()->get_single($composite['id']);
-                               $contracts = $composite_obj->get_contracts();
-                               $c = 0;
-                               if (count($contracts) > 0)
-                               {
-                                       foreach ($contracts as $contract)
-                                       {
-                                               $contract = 
$contract->serialize();
+                               $composites[$n]['id'] = $composite['id'];
+                               $composites[$n]['name'] = $composite['name'];
+                               $composites[$n]['object_number'] = 
$composite['location_code'];
 
-                                               if ($composites[$n-1]['id'] != 
$composite['id'])
-                                               {
-                                                       $composites[$n]['id'] = 
$composite['id'];
-                                               }
-                                               
-                                               $composites[$n]['name'] = 
$composite['name'];
-                                               
$composites[$n]['object_number'] = $composite['location_code'];
-
-                                               $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'])));
-                                               
-                                               foreach ($days as $day)
-                                               {
-                                                       if 
($composites[$n][date_format($day, 'D')]['status'] == 'Ikke ledig') {
-                                                               break 2;
-                                                       }
-                                                       if ($day >= 
$contract_date_start && ($day <= $contract_date_end || $contract['date_end'] != 
''))
-                                                       {
-                                                               
$composites[$n][date_format($day, 'D')]['status'] = 'Ikke ledig';
-                                                               $c++;
-                                                       }
-                                                       else
-                                                       {
-                                                               
$composites[$n][date_format($day, 'D')]['status'] = 'Ledig';
-                                                       }
-                                               }
-//                                             $n++;
-                                       }
-                               }
-                               else
+                               foreach ($days as $day)
                                {
-                                       $composites[$n]['id'] = 
$composite['id'];
-                                       $composites[$n]['name'] = 
$composite['name'];
-                                       $composites[$n]['object_number'] = 
$composite['location_code'];
-
-                                       foreach ($days as $day)
-                                       {
-                                               
$composites[$n][date_format($day, 'D')]['status'] = 'Ledig';
-                                       }
-//                                     $n++;
+                                       $composites[$n][date_format($day, 
'D')]['status'] = $composite['status'];
                                }
-                               if ($c >= 7)
-                               {
-                                       unset($composites[$n]);
-                               }
-                               else
-                               {
-                                       $n++;
-                               }
-                               //$n++;
+                               $n++;
                        }
 
                        $data = array(

Modified: branches/dev-syncromind-2/rental/js/rental/schedule.js
===================================================================
--- branches/dev-syncromind-2/rental/js/rental/schedule.js      2016-09-16 
09:01:05 UTC (rev 15687)
+++ branches/dev-syncromind-2/rental/js/rental/schedule.js      2016-09-16 
23:58:10 UTC (rev 15688)
@@ -137,12 +137,40 @@
 
 schedule.prevWeek = function ()
 {
-       schedule.moveWeek(-7)
+       var move = true;
+       var date = schedule.date;
+       
+       if ( (schedule.rental.availability_from) && 
(schedule.rental.availability_to) )
+       {
+               if (date <= schedule.rental.availability_from){
+                       move = false;
+               }
+       }
+       
+       if (move)
+       {
+               schedule.moveWeek(-7);
+       }
 };
 
 schedule.nextWeek = function ()
 {
-       schedule.moveWeek(7)
+       var move = true;
+       var date = schedule.date;
+       date.setDate(date.getDate() + 7); // Revisar, aumenta dos semanas
+       
+       if ( (schedule.rental.availability_from) && 
(schedule.rental.availability_to) )
+       {
+               if (date >= schedule.rental.availability_to)
+               {
+                       move = false;
+               }
+       }
+
+       if (move)
+       {
+               schedule.moveWeek(7);
+       }
 }
 
 $(window).load(function()

Modified: branches/dev-syncromind-2/rental/templates/base/application.xsl
===================================================================
--- branches/dev-syncromind-2/rental/templates/base/application.xsl     
2016-09-16 09:01:05 UTC (rev 15687)
+++ branches/dev-syncromind-2/rental/templates/base/application.xsl     
2016-09-16 23:58:10 UTC (rev 15688)
@@ -433,31 +433,81 @@
                                                                <xsl:with-param 
name="schedule" select ='./schedule'/>
                                                        </xsl:call-template>
                                                        <script 
type="text/javascript">
-                                                               
$(window).load(function ()
-                                                               {
 
+                                                               var 
composite_id = '<xsl:value-of select="schedule/composite_id"/>';
+                                                               
schedule.params.application_id = $('#application_id').val();
+
+                                                               schedule.rental 
= {};
+                                                               
$(window).load(function() {
+
+                                                                       
schedule.params.length = $('#cboNObjects').val();
+                                                                       
schedule.params.search = $('#txtSearchSchedule').val();
+                                                                       
schedule.params.start = 0;
+                                                                       
schedule.params.availability_date_from = "";
+                                                                       
schedule.params.availability_date_to = "";
+                                                               
+                                                                       
schedule.rental.availability_from = "";
+                                                                       
schedule.rental.availability_to = "";
+                                                               
                                                                        <xsl:if 
test="application/assign_date_start != 0 and application/assign_date_start != 
''">
-                                                                               
var adend = '<xsl:value-of select="php:function('date', $date_format, 
number(application/assign_date_start))"/>';
-                                                                               
var adend_date = new Date(adend.substr(6,4), adend.substr(3,2) - 1, 
adend.substr(0,2));
-                                                                               
schedule.updateSchedule(adend_date);
+                                                                               
var adstart = '<xsl:value-of select="php:function('date', $date_format, 
number(application/assign_date_start))"/>';
+                                                                               
var adstart_date = adstart.substr(6,4) + "-" + adstart.substr(3,2) + "-" + 
adstart.substr(0,2);
+                                                                               
schedule.params.availability_date_from = adstart_date;
+                                                                               
schedule.rental.availability_from = new Date(adstart_date);
+                                                                               
<xsl:if test="application/assign_date_end != 0 and application/assign_date_end 
!= ''">
+                                                                               
        var adend = '<xsl:value-of select="php:function('date', $date_format, 
number(application/assign_date_end))"/>';
+                                                                               
        var adend_date = adend.substr(6,4) + "-" + adend.substr(3,2) + "-" + 
adend.substr(0,2);
+                                                                               
        schedule.params.availability_date_to = adend_date;
+                                                                               
        schedule.rental.availability_to = new Date(adend_date);
+                                                                               
</xsl:if>
                                                                        
</xsl:if>
 
+                                                                       
schedule.setupWeekPicker('cal_container');
+                                                                       
$("#cal_container #datepicker").datepicker( "option", "minDate", 
schedule.params.availability_date_from );
+                                                                       
$("#cal_container #datepicker").datepicker( "option", "maxDate", 
schedule.params.availability_date_to );
+
+                                                                       var 
img_src = '<xsl:value-of select="schedule/picker_img"/>';
+
+                                                                       
schedule.datasourceUrl = '<xsl:value-of select="schedule/datasource_url"/>';
+                                                                       var 
initialRequest = ((schedule.params.availability_date_from) ? 
schedule.params.availability_date_from : '<xsl:value-of 
select="schedule/date"/>') || getUrlData("date");
+
+                                                                       
schedule.includeResource = false;
+                                                                       
schedule.colFormatter = 'rentalScheduleApplication';
+                                                                       var 
handleHistoryNavigation = function (state) {
+                                                                               
schedule.date = parseISO8601(state);
+                                                                               
schedule.renderSchedule('schedule_container', schedule.datasourceUrl, 
schedule.date, schedule.colFormatter, schedule.includeResource);
+                                                                       };
+
+                                                                       var 
state = getUrlData("date") || initialRequest;
+                                                                       if 
(state){
+                                                                               
handleHistoryNavigation(state);
+                                                                               
schedule.week = $.datepicker.iso8601Week(schedule.date);
+                                                                               
$('#cal_container #numberWeek').text(schedule.week);
+                                                                               
$("#cal_container #datepicker").datepicker("setDate", parseISO8601(state));
+                                                                       }
+                                                                       
schedule.toolbar = <xsl:value-of select="schedule/toolbar" />;
+                                                                       
                                                                        
$('#assign_date_start').datepicker("option", "onSelect", function (a, e) {
                                                                                
console.log(a);
-                                                                               
//console.log(e);
-                                                                               
schedule.params.availability_date_from = a;
-                                                                               
var date = new Date(a);
-                                                                               
schedule.updateSchedule(date);
-                                                                               
//schedule.renderSchedule('schedule_container', schedule.datasourceUrl, 
schedule.date, schedule.colFormatter, schedule.includeResource);
+                                                                               
var adstart_date = a.substr(6,4) + "-" + a.substr(3,2) + "-" + a.substr(0,2);
+                                                                               
schedule.params.availability_date_from = adstart_date;
+                                                                               
schedule.rental.availability_from = new Date(adstart_date);
+                                                                               
schedule.date = parseISO8601(adstart_date);
+                                                                               
$("#cal_container #datepicker").datepicker( "option", "minDate", adstart_date );
+                                                                               
schedule.updateSchedule(schedule.date);
                                                                        });
 
                                                                        
$('#assign_date_end').datepicker("option", "onSelect", function (a, e) {
                                                                                
console.log(a);
-                                                                               
//console.log(e);
-                                                                               
schedule.params.availability_date_to = a;
-                                                                               
schedule.renderSchedule('schedule_container', schedule.datasourceUrl, 
schedule.date, schedule.colFormatter, schedule.includeResource);
+                                                                               
var adstart_end = a.substr(6,4) + "-" + a.substr(3,2) + "-" + a.substr(0,2);
+                                                                               
schedule.params.availability_date_to = adstart_end;
+                                                                               
schedule.rental.availability_to = new Date(adend_date);
+                                                                               
$("#cal_container #datepicker").datepicker( "option", "maxDate", adstart_end );
+                                                                               
schedule.updateSchedule(schedule.date);
                                                                        });
+                                                                       
                                                                });
+
                                                        </script>
                                                </fieldset>
                                        </div>

Modified: branches/dev-syncromind-2/rental/templates/base/rental_schedule.xsl
===================================================================
--- branches/dev-syncromind-2/rental/templates/base/rental_schedule.xsl 
2016-09-16 09:01:05 UTC (rev 15687)
+++ branches/dev-syncromind-2/rental/templates/base/rental_schedule.xsl 
2016-09-16 23:58:10 UTC (rev 15688)
@@ -158,40 +158,4 @@
                        </script>
                </p>
        </div>
-       <script type="text/javascript">
-               var composite_id = '<xsl:value-of 
select="schedule/composite_id"/>';
-               schedule.rental = {};
-               $(window).load(function() {
-
-                       schedule.params.length = $('#cboNObjects').val();
-                       schedule.params.search = $('#txtSearchSchedule').val();
-                       schedule.params.start = 0;
-                       schedule.params.availability_date_from = "";
-                       schedule.params.availability_date_to = "";
-
-                       schedule.setupWeekPicker('cal_container');
-
-                       var img_src = '<xsl:value-of 
select="schedule/picker_img"/>';
-                       //var composite_id = '<xsl:value-of 
select="schedule/composite_id"/>';
-
-                       schedule.datasourceUrl = '<xsl:value-of 
select="schedule/datasource_url"/>';
-                       var initialRequest = getUrlData("date") || 
'<xsl:value-of select="schedule/date"/>';
-
-                       schedule.includeResource = false;
-                       schedule.colFormatter = 'rentalSchedule';
-                       var handleHistoryNavigation = function (state) {
-                               schedule.date = parseISO8601(state);
-                               schedule.renderSchedule('schedule_container', 
schedule.datasourceUrl, schedule.date, schedule.colFormatter, 
schedule.includeResource);
-                       };
-
-                       var state = getUrlData("date") || initialRequest;
-                       if (state){
-                               handleHistoryNavigation(state);
-                               schedule.week = 
$.datepicker.iso8601Week(schedule.date);
-                               $('#cal_container 
#numberWeek').text(schedule.week);
-                               $("#cal_container 
#datepicker").datepicker("setDate", parseISO8601(state));
-                       }
-                       schedule.toolbar = <xsl:value-of 
select="schedule/toolbar" />;
-               });
-       </script>
 </xsl:template>
\ No newline at end of file

Modified: branches/dev-syncromind-2/rental/templates/base/schedule.xsl
===================================================================
--- branches/dev-syncromind-2/rental/templates/base/schedule.xsl        
2016-09-16 09:01:05 UTC (rev 15687)
+++ branches/dev-syncromind-2/rental/templates/base/schedule.xsl        
2016-09-16 23:58:10 UTC (rev 15688)
@@ -10,4 +10,39 @@
        <xsl:call-template name="rental_schedule">
                <xsl:with-param name="schedule" select ='schedule'/>
        </xsl:call-template>
+       <script type="text/javascript">
+               var composite_id = '<xsl:value-of 
select="schedule/composite_id"/>';
+               schedule.rental = {};
+               $(window).load(function() {
+
+                       schedule.params.length = $('#cboNObjects').val();
+                       schedule.params.search = $('#txtSearchSchedule').val();
+                       schedule.params.start = 0;
+                       schedule.params.availability_date_from = "";
+                       schedule.params.availability_date_to = "";
+
+                       schedule.setupWeekPicker('cal_container');
+
+                       var img_src = '<xsl:value-of 
select="schedule/picker_img"/>';
+
+                       schedule.datasourceUrl = '<xsl:value-of 
select="schedule/datasource_url"/>';
+                       var initialRequest = getUrlData("date") || 
'<xsl:value-of select="schedule/date"/>';
+
+                       schedule.includeResource = false;
+                       schedule.colFormatter = 'rentalSchedule';
+                       var handleHistoryNavigation = function (state) {
+                               schedule.date = parseISO8601(state);
+                               schedule.renderSchedule('schedule_container', 
schedule.datasourceUrl, schedule.date, schedule.colFormatter, 
schedule.includeResource);
+                       };
+
+                       var state = getUrlData("date") || initialRequest;
+                       if (state){
+                               handleHistoryNavigation(state);
+                               schedule.week = 
$.datepicker.iso8601Week(schedule.date);
+                               $('#cal_container 
#numberWeek').text(schedule.week);
+                               $("#cal_container 
#datepicker").datepicker("setDate", parseISO8601(state));
+                       }
+                       schedule.toolbar = <xsl:value-of 
select="schedule/toolbar" />;
+               });
+       </script>
 </xsl:template>
\ No newline at end of file




reply via email to

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