fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [16913] rental mass syncronization of party


From: sigurdne
Subject: [Fmsystem-commits] [16913] rental mass syncronization of party
Date: Thu, 6 Jul 2017 07:02:56 -0400 (EDT)

Revision: 16913
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16913
Author:   sigurdne
Date:     2017-07-06 07:02:55 -0400 (Thu, 06 Jul 2017)
Log Message:
-----------
rental mass syncronization of party

Modified Paths:
--------------
    trunk/phpgwapi/templates/base/datatable_jquery.xsl
    trunk/rental/inc/class.uiparty.inc.php
    trunk/rental/js/rental/party.sync.js
    trunk/rental/setup/phpgw_no.lang

Modified: trunk/phpgwapi/templates/base/datatable_jquery.xsl
===================================================================
--- trunk/phpgwapi/templates/base/datatable_jquery.xsl  2017-07-05 14:22:43 UTC 
(rev 16912)
+++ trunk/phpgwapi/templates/base/datatable_jquery.xsl  2017-07-06 11:02:55 UTC 
(rev 16913)
@@ -747,8 +747,16 @@
                                <xsl:choose>
                                        <xsl:when test="columns">
                                                button_def.push({
-                                               text: "<xsl:value-of 
select="php:function('lang', 'columns')"/>",
-                                               titleAttr: "<xsl:value-of 
select="php:function('lang', 'columns')"/>",
+                                               <xsl:choose>
+                                                       <xsl:when 
test="columns/name">
+                                                               text: 
"<xsl:value-of select="columns/name"/>",
+                                                               titleAttr: 
"<xsl:value-of select="columns/name"/>",
+                                                       </xsl:when>
+                                                       <xsl:otherwise>
+                                                               text: 
"<xsl:value-of select="php:function('lang', 'columns')"/>",
+                                                               titleAttr: 
"<xsl:value-of select="php:function('lang', 'columns')"/>",
+                                                       </xsl:otherwise>
+                                               </xsl:choose>
                                                className: 'download',
                                                action: function (e, dt, node, 
config) {
                                                        <xsl:value-of 
select="columns/onclick"/>;

Modified: trunk/rental/inc/class.uiparty.inc.php
===================================================================
--- trunk/rental/inc/class.uiparty.inc.php      2017-07-05 14:22:43 UTC (rev 
16912)
+++ trunk/rental/inc/class.uiparty.inc.php      2017-07-06 11:02:55 UTC (rev 
16913)
@@ -98,15 +98,11 @@
                 */
                public function query()
                {
-                       if 
($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] > 0)
-                       {
-                               $user_rows_per_page = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
-                       }
-                       else
-                       {
-                               $user_rows_per_page = 10;
-                       }
+                       $length = phpgw::get_var('length', 'int');
 
+                       $user_rows_per_page = $length > 0 ? $length : 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+                       $num_of_objects = $length == -1 ? 0 : 
$user_rows_per_page;
+
                        $search = phpgw::get_var('search');
                        $order = phpgw::get_var('order');
                        $draw = phpgw::get_var('draw', 'int', 'REQUEST', 1);
@@ -113,7 +109,6 @@
                        $columns = phpgw::get_var('columns');
 
                        $start_index = phpgw::get_var('start', 'int', 
'REQUEST', 0);
-                       $num_of_objects = (phpgw::get_var('length', 'int') <= 
0) ? $user_rows_per_page : phpgw::get_var('length', 'int');
                        $sort_field = ($columns[$order[0]['column']]['data']) ? 
$columns[$order[0]['column']]['data'] : 'identifier';
                        $sort_ascending = ($order[0]['dir'] == 'desc') ? false 
: true;
                        // Form variables
@@ -264,6 +259,45 @@
 
                        return $this->jquery_results($result_data);
                }
+
+               private function get_sync_candidates()
+               {
+                       $config_data = CreateObject('phpgwapi.config', 
'rental')->read();
+                       $filters = array('sync' => 'sync_parties_org_unit', 
'party_type' => 'all', 'active' => 'all');
+                       if( !$config_data['use_fellesdata'])
+                       {
+                               return array();
+                       }
+
+                       $bofelles = rental_bofellesdata::get_instance();
+                       $result_objects = 
rental_soparty::get_instance()->get(0, 0, '', true, '', 'all', $filters);
+                       $candidates = array();
+                       foreach ($result_objects as $party)
+                       {
+                               if (isset($party))
+                               {
+                                       $sync_data = $party->get_sync_data();
+                                       $unit_name_and_id = 
$bofelles->org_unit_exist($sync_data['org_enhet_id']);
+
+                                       if (isset($unit_name_and_id) && 
$unit_name_and_id)
+                                       {
+                                               $unit_id = 
$unit_name_and_id['UNIT_ID'];
+                                               $unit_name = 
$unit_name_and_id['UNIT_NAME'];
+
+                                               if (isset($unit_id) && 
is_numeric($unit_id))
+                                               {
+                                                       $candidates[] = array(
+                                                               'party_id' => 
$party->get_id(),
+                                                               'org_unit_id' 
=> $unit_id
+                                                       );
+                                               }
+                                       }
+                               }
+                       }
+
+                       return $candidates;
+               }
+
                /*
                 * One time job for updating the parties with no org_enhet_id.
                 * The org_enhet_id will be set according to the suggestions 
given in
@@ -400,7 +434,7 @@
                                                        $actions[] = '<a 
href="' . $url2 . '">' . lang('frontend_access') . '</a>';
 
                                                        $url3 = 
html_entity_decode(self::link(array('menuaction' => 
'rental.uiparty.syncronize_party',
-                                                                       
'org_enhet_id' => $value['org_enhet_id'], 'party_id' => $value['id'])));
+                                                                       
'org_enhet_id' => $value['org_enhet_id'], 'party_id' => $value['id'], 
'phpgw_return_as' => 'json')));
                                                        $actions[] = '<a 
onclick="onSyncronize_party(\'' . $url3 . '\')">' . lang('syncronize_party') . 
'</a>';
                                                }
                                        }
@@ -1214,7 +1248,7 @@
                                if($sync_job == 'org_unit')
                                {
                                        //not really columns - but a 
placeholder for mass-sync.
-                                       $data['datatable']['columns'] = 
array('name' => 'Sync', 'onclick' => "PartyMassSync({type:'{$type}'})");
+                                       $data['datatable']['columns'] = 
array('name' => lang('syncronize all'), 'onclick' => 
"PartyMassSync({type:'{$type}'})");
                                }
                        }
 
@@ -1239,21 +1273,38 @@
                {
                        if (($this->isExecutiveOfficer() || 
$this->isAdministrator()))
                        {
-                               $party_id = phpgw::get_var('party_id');
-                               $org_unit_id = phpgw::get_var('org_enhet_id');
+                               $config_data = CreateObject('phpgwapi.config', 
'rental')->read();
+                               if (empty($config_data['use_fellesdata']))
+                               {
+                                       return;
+                               }
+                               $bofelles = rental_bofellesdata::get_instance();
 
-                               if (isset($party_id) && $party_id > 0 && 
isset($org_unit_id) && $org_unit_id > 0)
+
+                               $multisync = phpgw::get_var('multisync', 
'bool');
+
+                               if($multisync)
                                {
-                                       $config = 
CreateObject('phpgwapi.config', 'rental');
-                                       $config->read();
-
-                                       $use_fellesdata = 
$config->config_data['use_fellesdata'];
-                                       if (!$use_fellesdata)
+                                       $candidates = 
$this->get_sync_candidates();
+                               }
+                               else
+                               {
+                                       $candidates = array();
+                                       $candidates[] = array(
+                                               'party_id' => 
phpgw::get_var('party_id', 'int'),
+                                               'org_unit_id' => 
phpgw::get_var('org_enhet_id', 'int')
+                                       );
+                               }
+                               $i = 0;
+                               foreach ($candidates as $candidate)
+                               {
+                                       if(!$candidate['party_id'] > 0 && 
!$candidate['org_unit_id'] > 0)
                                        {
-                                               return;
+                                               continue;
                                        }
 
-                                       $bofelles = 
rental_bofellesdata::get_instance();
+                                       $party_id = $candidate['party_id'];
+                                       $org_unit_id = 
$candidate['org_unit_id'];
 
                                        $org_unit_with_leader = 
$bofelles->get_result_unit_with_leader($org_unit_id);
                                        $org_department = 
$bofelles->get_department_for_org_unit($org_unit_id);
@@ -1282,9 +1333,16 @@
 
                                        
rental_soparty::get_instance()->store($party);
 
-                                       $party = 
rental_soparty::get_instance()->get_single($party_id);
+                       //              echo  json_encode( array('message'=> 
lang('party %1 is updated', $party_id)));
+                                       $i++;
                                }
+
+                               return array('message'=> lang('synchronized: 
%1',  $i));
                        }
+                       else
+                       {
+                               return array('message'=> lang('no access'));
+                       }
                }
 
                /**

Modified: trunk/rental/js/rental/party.sync.js
===================================================================
--- trunk/rental/js/rental/party.sync.js        2017-07-05 14:22:43 UTC (rev 
16912)
+++ trunk/rental/js/rental/party.sync.js        2017-07-06 11:02:55 UTC (rev 
16913)
@@ -9,9 +9,9 @@
 
        JqueryPortico.execute_ajax(action, function (result)
        {
-               document.getElementById("message").innerHTML = result;
+               document.getElementById("message").innerHTML = result.message;
                oTable.fnDraw();
-       });
+       }, '', "POST", "JSON");
 }
 
 function onDelete_party(requestUrl)
@@ -66,4 +66,15 @@
                return false;
        }
 
+       document.getElementById("message").innerHTML = 'Processing...';
+
+       var oArgs = {menuaction: 'rental.uiparty.syncronize_party', multisync: 
1};
+       var requestUrl = phpGWLink('index.php', oArgs, true);
+
+       JqueryPortico.execute_ajax(requestUrl, function (result)
+       {
+               document.getElementById("message").innerHTML = result.message;
+               oTable.fnDraw();
+       }, '', "POST", "JSON");
+
 }
\ No newline at end of file

Modified: trunk/rental/setup/phpgw_no.lang
===================================================================
--- trunk/rental/setup/phpgw_no.lang    2017-07-05 14:22:43 UTC (rev 16912)
+++ trunk/rental/setup/phpgw_no.lang    2017-07-06 11:02:55 UTC (rev 16913)
@@ -676,7 +676,9 @@
 entity %1 has been updated     rental  no      Post %1 er oppdatert
 event  rental  no      Hendelse
 export contacts        rental  no      Eksporter kontakter
-has been added rental  no      rr lagt til
+has been added rental  no      er lagt til
 has been removed       rental  no      er fjernet
 select date    rental  no      Velg dato
 select file to upload  rental  no      Velg fil for opplasting
+synchronized: %1       rental  no      Synkronisert: %1
+syncronize all rental  no      Synkroniser alle
\ No newline at end of file




reply via email to

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