fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15695]


From: saul . huanay
Subject: [Fmsystem-commits] [15695]
Date: Tue, 20 Sep 2016 00:24:27 +0000 (UTC)

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


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

Modified: branches/dev-syncromind-2/booking/js/booking/schedule.js
===================================================================
--- branches/dev-syncromind-2/booking/js/booking/schedule.js    2016-09-19 
09:32:34 UTC (rev 15694)
+++ branches/dev-syncromind-2/booking/js/booking/schedule.js    2016-09-20 
00:24:27 UTC (rev 15695)
@@ -1,4 +1,5 @@
 var schedule = new Array();
+schedule.params = {};
 
 schedule.renderSchedule = function (container, url, date, colFormatter, 
includeResource, classTable)
 {
@@ -11,6 +12,7 @@
 //    container.innerHTML = '';
        var datestr = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + 
date.getDate();
        url += '&date=' + datestr;
+       schedule.params.date = datestr;
 
        var detected_lang = navigator.language || navigator.userLanguage;
        var lang = {};
@@ -62,8 +64,10 @@
                colDefs.push({key: keys[x], 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'}];
+       var params = (schedule.params) ? schedule.params : new Array();
+
 //    createta d u c r cl
-       createTableSchedule(container, url, colDefs, r, classTable, datestr);
+       createTableSchedule(container, url, colDefs, r, classTable, params);
 
 };
 

Modified: 
branches/dev-syncromind-2/bookingfrontend/js/bookingfrontend/schedule.js
===================================================================
--- branches/dev-syncromind-2/bookingfrontend/js/bookingfrontend/schedule.js    
2016-09-19 09:32:34 UTC (rev 15694)
+++ branches/dev-syncromind-2/bookingfrontend/js/bookingfrontend/schedule.js    
2016-09-20 00:24:27 UTC (rev 15695)
@@ -1,4 +1,5 @@
 var schedule = new Array();
+schedule.params = {};
 
 schedule.renderSchedule = function (container, url, date, colFormatter, 
includeResource, classTable)
 {
@@ -9,6 +10,7 @@
        }
        var datestr = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + 
date.getDate();
        url += '&date=' + datestr;
+       schedule.params.date = datestr;
 
        var detected_lang = navigator.language || navigator.userLanguage;
        var lang = {};
@@ -61,8 +63,10 @@
                colDefs.push({key: keys[x], 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'}];
+       var params = (schedule.params) ? schedule.params : new Array();
+
 //    createta d u c r cl
-       createTableSchedule(container, url, colDefs, r, classTable, datestr);
+       createTableSchedule(container, url, colDefs, r, classTable, params);
 
 };
 

Modified: branches/dev-syncromind-2/phpgwapi/js/jquery/common.js
===================================================================
--- branches/dev-syncromind-2/phpgwapi/js/jquery/common.js      2016-09-19 
09:32:34 UTC (rev 15694)
+++ branches/dev-syncromind-2/phpgwapi/js/jquery/common.js      2016-09-20 
00:24:27 UTC (rev 15695)
@@ -1273,14 +1273,14 @@
 }
 
 
-function createTableSchedule (d, u, c, r, cl, dt, a, p, t)
+function createTableSchedule (d, u, c, r, cl, a, p, t)
 {
        var container = document.getElementById(d);
        var container_toolbar = document.createElement('div');
        var xtable = document.createElement('table');
        var tableHead = document.createElement('thead');
        var tableHeadTr = document.createElement('tr');
-       var date = (dt) ? dt : "";
+       var date = (a) ? (a.date) ? a.date : "" : "";
 
        restartColors();
        r = (r) ? r : 'data';

Modified: branches/dev-syncromind-2/rental/inc/class.soapplication.inc.php
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.soapplication.inc.php    
2016-09-19 09:32:34 UTC (rev 15694)
+++ branches/dev-syncromind-2/rental/inc/class.soapplication.inc.php    
2016-09-20 00:24:27 UTC (rev 15695)
@@ -129,5 +129,16 @@
                        }
                        return false;
                }
+               
+               public function remove_composite($application_id, $composite_id)
+               {
+                       $q = "DELETE FROM rental_application_composite WHERE 
application_id = {$application_id} AND composite_id = {$composite_id}";
+                       $result = $this->db->query($q);
+                       if ($result)
+                       {
+                               return true;
+                       }
+                       return false;
+               }
 
        }
\ No newline at end of file

Modified: branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php      
2016-09-19 09:32:34 UTC (rev 15694)
+++ branches/dev-syncromind-2/rental/inc/class.socomposite.inc.php      
2016-09-20 00:24:27 UTC (rev 15695)
@@ -98,27 +98,52 @@
 
                                        /* The contract's start date not after 
the end of the period if there is no end date */
                                        $filter_clauses[] = "
-                                       ((NOT rental_contract.date_start > 
$availability_date_to AND rental_contract.date_end IS NULL)
-                                        OR
-                                       (NOT rental_contract.date_start > 
$availability_date_to AND NOT rental_contract.date_end IS NULL AND NOT 
rental_contract.date_end < $availability_date_from))";
+                                       (
+                                               (
+                                                       ((NOT 
rental_contract.date_start > $availability_date_to AND rental_contract.date_end 
IS NULL)
+                                                       OR
+                                                       (NOT 
rental_contract.date_start > $availability_date_to AND NOT 
rental_contract.date_end IS NULL AND NOT rental_contract.date_end < 
$availability_date_from))
+                                               )
+                                               OR
+                                               (
+                                                       ((NOT 
rental_application.date_start > $availability_date_to AND 
rental_application.date_end IS NULL)
+                                                       OR
+                                                       (NOT 
rental_application.date_start > $availability_date_to AND NOT 
rental_application.date_end IS NULL AND NOT rental_application.date_end < 
$availability_date_from))
+                                               )
+                                       )";
                                        $special_query = true;
                                        break;
                                case "has_no_contract":
                                        $filter_clauses[] = "
                                (
-                                       rental_contract_composite.contract_id 
IS NULL OR 
-                                       NOT rental_composite.id IN 
+                                       rental_contract_composite.contract_id 
IS NULL OR
+                                       
rental_application_composite.application_id IS NULL OR
+                                       NOT rental_composite.id IN
                                        (
                                                SELECT rental_composite.id FROM 
rental_composite 
-                                               LEFT JOIN  
rental_contract_composite ON (rental_contract_composite.composite_id = 
rental_composite.id) 
-                                               LEFT JOIN  rental_contract ON 
(rental_contract.id = rental_contract_composite.contract_id) 
+                                               LEFT JOIN 
rental_contract_composite ON (rental_contract_composite.composite_id = 
rental_composite.id) 
+                                               LEFT JOIN rental_contract ON 
(rental_contract.id = rental_contract_composite.contract_id) 
+                                               LEFT JOIN 
rental_application_composite ON (rental_application_composite.composite_id = 
rental_composite.id)
+                                               LEFT JOIN rental_application ON 
(rental_application.id = rental_application_composite.application_id)
                                                WHERE  
                                                (
-                                                       NOT 
rental_contract_composite.contract_id IS NULL AND
-                                                       NOT 
rental_contract.date_start IS NULL AND
-                                                       ((NOT 
rental_contract.date_start > $availability_date_to AND rental_contract.date_end 
IS NULL)
-                                                       OR
-                                                       (NOT 
rental_contract.date_start > $availability_date_to AND NOT 
rental_contract.date_end IS NULL AND NOT rental_contract.date_end < 
$availability_date_from))
+                                                       (
+                                                               NOT 
rental_contract_composite.contract_id IS NULL AND
+                                                               NOT 
rental_contract.date_start IS NULL AND
+                                                               ((NOT 
rental_contract.date_start > $availability_date_to AND rental_contract.date_end 
IS NULL)
+                                                               OR
+                                                               (NOT 
rental_contract.date_start > $availability_date_to AND NOT 
rental_contract.date_end IS NULL AND NOT rental_contract.date_end < 
$availability_date_from))
+                                                       )
+                                                       OR
+                                                       (
+                                                               NOT 
rental_application_composite.application_id IS NULL AND
+                                                               NOT 
rental_application.date_start IS NULL AND
+                                                               ((NOT 
rental_application.date_start > $availability_date_to AND 
rental_application.date_end IS NULL)
+                                                               OR
+                                                               (NOT 
rental_application.date_start > $availability_date_to AND NOT 
rental_application.date_end IS NULL AND NOT rental_application.date_end < 
$availability_date_from))
+                                                       )
+
+
                                                )
                                        )
                                )
@@ -319,7 +344,7 @@
                                        $composite->add_contract($contract);
                                }
                        }
-
+                       
                        if (!$composite->contains_unit($location_code))
                        {
                                //composite inneholder ikke unit -> legg den til

Modified: branches/dev-syncromind-2/rental/inc/class.uiapplication.inc.php
===================================================================
--- branches/dev-syncromind-2/rental/inc/class.uiapplication.inc.php    
2016-09-19 09:32:34 UTC (rev 15694)
+++ branches/dev-syncromind-2/rental/inc/class.uiapplication.inc.php    
2016-09-20 00:24:27 UTC (rev 15695)
@@ -42,7 +42,8 @@
                        'view' => true,
                        'edit' => true,
                        'save' => true,
-                       'add_composite' => true
+                       'add_composite' => true,
+                       'remove_composite' => true
                );
 
                protected
@@ -360,6 +361,20 @@
 //                     $filters = rental_uicomposite::get_filters();
                        $filters = ExecMethod('rental.uicomposite.get_filters');
 
+                       foreach ($filters as $k1 => $filter)
+                       {
+                               if ($filter['name'] == 'has_contract')
+                               {
+                                       foreach ($filter['list'] as $k2 => 
$option)
+                                       {
+                                               if ($option['id'] == 
'has_no_contract')
+                                               {
+                                                       
$filters[$k1]['list'][$k2]['selected'] = 'selected';
+                                               }
+                                       }
+                               }
+                       }
+
                        $schedule['filters'] = $filters;
 
                        $schedule['datasource_url'] = self::link(array(
@@ -494,8 +509,51 @@
                        $schedule['date'] = $date;
                        $schedule['picker_img'] = 
$GLOBALS['phpgw']->common->image('phpgwapi', 'cal');
                        $schedule['toolbar'] = json_encode($toolbar);
+                       
+                       $composites['datasource_url'] = self::link(array(
+                               'menuaction' => 'rental.uicomposite.query',
+                               'editable' => ($editable) ? 1 : 0,
+                               'application_id' => $application->get_id(),
+                               'type' => $type,
+                               'phpgw_return_as' => 'json'
+                       ));
+                       $uicols_composite = 
rental_socomposite::get_instance()->get_uicols();
+                       $columns_def = array();
+                       $uicols_count = count($uicols_composite['descr']);
+                       for ($i = 0; $i < $uicols_count; $i++)
+                       {
+                               if ($uicols_composite['input_type'][$i] != 
'hidden')
+                               {
+                                       $columns_def[$i]['key'] = 
$uicols_composite['name'][$i];
+                                       $columns_def[$i]['label'] = 
$uicols_composite['descr'][$i];
+                                       $columns_def[$i]['sortable'] = 
$uicols_composite['sortable'][$i];
+                               }
+                       }
+                       $composites['columns'] = json_encode($columns_def);
+                       $composites['application_id'] = $application->get_id();
+                       
+                       $toolbar_composites = array();
+                       $toolbar_composites[] = array (
+                               'name' => 'remove',
+                               'text' => 'Remove',
+                               'callFunction' => array(
+                                       'name' => 'removeComposite',
+                                       'args' => json_encode(array(
+                                               'url' => self::link(array(
+                                                       'menuaction' => 
'rental.uiapplication.remove_composite',
+                                                       'phpgw_return_as' => 
'json'
+                                               ))
+                                       ))
+                               ),
+                               'attributes' => array(
+                                       'class' => 'need-free'
+                               ),
+                               'parameters' => $parameters
+                       );
+                       $composites['toolbar'] = 
json_encode($toolbar_composites);
 
                        $data['schedule'] = $schedule;
+                       $data['composites'] = $composites;
 
                        phpgwapi_jquery::load_widget("datepicker");
                        phpgwapi_jquery::formvalidator_generate(array('date', 
'security', 'file'));
@@ -602,4 +660,22 @@
                        }
                        return $message;
                }
+               
+               public function remove_composite()
+               {
+                       $application_id = (int)phpgw::get_var('application_id');
+                       $composite_id = (int)phpgw::get_var('composite_id');
+                       
+                       $so_application = rental_soapplication::get_instance();
+                       $result = 
$so_application->remove_composite($application_id, $composite_id);
+                       if ($result)
+                       {
+                               $message = 'Composite ' . $composite_id . ' ' . 
lang('has been removed');
+                       }
+                       else
+                       {
+                               $message = 'Composite ' . $composite_id . ' ' . 
lang('not removed');
+                       }
+                       return $message;
+               }
        }
\ 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-09-19 09:32:34 UTC (rev 15694)
+++ branches/dev-syncromind-2/rental/inc/class.uicomposite.inc.php      
2016-09-20 00:24:27 UTC (rev 15695)
@@ -158,6 +158,8 @@
 
                        //Retrieve a contract identifier and load corresponding 
contract
                        $contract_id = phpgw::get_var('contract_id');
+                       
+                       $application_id = (phpgw::get_var('application_id')) ? 
phpgw::get_var('application_id') : 0;
 
                        if ($export)
                        {
@@ -195,6 +197,10 @@
                                                'is_active' => 
phpgw::get_var('is_active'), 'is_vacant' => phpgw::get_var('occupancy'),
                                                'has_contract' => 
phpgw::get_var('has_contract'), 'availability_date_from' => 
phpgw::get_var('availability_date_from'),
                                                'availability_date_to' => 
phpgw::get_var('availability_date_to'), 'district_id' => $district_id);
+                                       if ($application_id > 0)
+                                       {
+                                               $filters['application_id'] = 
$application_id;
+                                       }
                                        $result_objects = 
rental_socomposite::get_instance()->get($start_index, $num_of_objects, 
$sort_field, $sort_ascending, $search_for, $search_type, $filters);
                                        $object_count = 
rental_socomposite::get_instance()->get_count($search_for, $search_type, 
$filters);
                                        break;

Modified: branches/dev-syncromind-2/rental/js/rental/application.edit.js
===================================================================
--- branches/dev-syncromind-2/rental/js/rental/application.edit.js      
2016-09-19 09:32:34 UTC (rev 15694)
+++ branches/dev-syncromind-2/rental/js/rental/application.edit.js      
2016-09-20 00:24:27 UTC (rev 15695)
@@ -45,5 +45,20 @@
        {
                button.disabled = false;
                $('#tempMessage').append("<li>" + m + "</li>");
+               schedule.updateSchedule(schedule.date);
+               renderComposites('schedule_composites_container');
        });
+}
+
+renderComposites = function (container)
+{
+       var classTable = "pure-table rentalScheduleTable";
+
+       var columns = [];
+       $.each(composites.columns, function(i, v)
+       {
+               columns.push({key: v['key'], label: v['label'], type: 'td'});
+       });
+       var r = [{n: 'ResultSet'}, {n: 'Result'}];
+       createTableSchedule(container, composites.datasourceUrl, columns);
 }
\ No newline at end of file

Modified: branches/dev-syncromind-2/rental/js/rental/schedule.js
===================================================================
--- branches/dev-syncromind-2/rental/js/rental/schedule.js      2016-09-19 
09:32:34 UTC (rev 15694)
+++ branches/dev-syncromind-2/rental/js/rental/schedule.js      2016-09-20 
00:24:27 UTC (rev 15695)
@@ -16,6 +16,7 @@
 
        var datestr = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + 
date.getDate();
        url += '&date=' + datestr;
+       schedule.params.date = datestr;
 
        var detected_lang = navigator.language || navigator.userLanguage;
        var lang = {};
@@ -77,7 +78,7 @@
        var pagination = true;
        var toolbar = true;
 
-       createTableSchedule(container, url, colDefs, r, classTable, datestr, 
params, pagination, toolbar);
+       createTableSchedule(container, url, colDefs, r, classTable, params, 
pagination, toolbar);
 }
 
 schedule.setupWeekPicker = function ()
@@ -156,9 +157,9 @@
 schedule.nextWeek = function ()
 {
        var move = true;
-       var date = schedule.date;
+       var date = new 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)
@@ -275,8 +276,9 @@
                {
                        if (name == 'download')
                        {
-                               button.addEventListener('click', function()
+                               button.addEventListener('click', function(event)
                                {
+                                       event.preventDefault();
                                        var new_action = action;
                                        $.each(schedule.params, function(i, v)
                                        {
@@ -302,8 +304,9 @@
                        }
                        else
                        {
-                               button.addEventListener('click', function()
+                               button.addEventListener('click', function(event)
                                {
+                                       event.preventDefault();
                                        var new_action = action;
                                        if (parameters)
                                        {

Modified: branches/dev-syncromind-2/rental/templates/base/application.xsl
===================================================================
--- branches/dev-syncromind-2/rental/templates/base/application.xsl     
2016-09-19 09:32:34 UTC (rev 15694)
+++ branches/dev-syncromind-2/rental/templates/base/application.xsl     
2016-09-20 00:24:27 UTC (rev 15695)
@@ -429,13 +429,14 @@
                                                                        
                                                                </ul>
                                                        </div>
+                                                       <div 
id="schedule_composites_container"></div>
                                                        <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.params.application_id = $('#application_id').val();
+                                                               var 
application_id = $('#application_id').val();
 
                                                                schedule.rental 
= {};
                                                                
$(window).load(function() {
@@ -449,13 +450,13 @@
                                                                        
schedule.rental.availability_from = "";
                                                                        
schedule.rental.availability_to = "";
                                                                
-                                                                       <xsl:if 
test="application/assign_date_start != 0 and application/assign_date_start != 
''">
-                                                                               
var adstart = '<xsl:value-of select="php:function('date', $date_format, 
number(application/assign_date_start))"/>';
+                                                                       <xsl:if 
test="application/date_start != 0 and application/date_start != ''">
+                                                                               
var adstart = '<xsl:value-of select="php:function('date', $date_format, 
number(application/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))"/>';
+                                                                               
<xsl:if test="application/date_end != 0 and application/date_end != ''">
+                                                                               
        var adend = '<xsl:value-of select="php:function('date', $date_format, 
number(application/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);
@@ -478,7 +479,7 @@
                                                                                
schedule.renderSchedule('schedule_container', schedule.datasourceUrl, 
schedule.date, schedule.colFormatter, schedule.includeResource);
                                                                        };
 
-                                                                       var 
state = getUrlData("date") || initialRequest;
+                                                                       var 
state = initialRequest || getUrlData("date");
                                                                        if 
(state){
                                                                                
handleHistoryNavigation(state);
                                                                                
schedule.week = $.datepicker.iso8601Week(schedule.date);
@@ -487,7 +488,7 @@
                                                                        }
                                                                        
schedule.toolbar = <xsl:value-of select="schedule/toolbar" />;
                                                                        
-                                                                       
$('#assign_date_start').datepicker("option", "onSelect", function (a, e) {
+                                                                       
$('#date_start').datepicker("option", "onSelect", function (a, e) {
                                                                                
console.log(a);
                                                                                
var adstart_date = a.substr(6,4) + "-" + a.substr(3,2) + "-" + a.substr(0,2);
                                                                                
schedule.params.availability_date_from = adstart_date;
@@ -497,7 +498,7 @@
                                                                                
schedule.updateSchedule(schedule.date);
                                                                        });
 
-                                                                       
$('#assign_date_end').datepicker("option", "onSelect", function (a, e) {
+                                                                       
$('#date_end').datepicker("option", "onSelect", function (a, e) {
                                                                                
console.log(a);
                                                                                
var adstart_end = a.substr(6,4) + "-" + a.substr(3,2) + "-" + a.substr(0,2);
                                                                                
schedule.params.availability_date_to = adstart_end;
@@ -506,6 +507,13 @@
                                                                                
schedule.updateSchedule(schedule.date);
                                                                        });
                                                                        
+                                                                       
composites = new Array();
+
+                                                                       
composites.datasourceUrl = '<xsl:value-of select="composites/datasource_url"/>';
+                                                                       
composites.columns = <xsl:value-of select="composites/columns"/>;
+                                                                       
composites.toolbar = <xsl:value-of select="composites/toolbar" />;
+
+                                                                       
renderComposites('schedule_composites_container');
                                                                });
 
                                                        </script>




reply via email to

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