fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [7987] Added functionality for synchronizing data wit


From: Torstein
Subject: [Fmsystem-commits] [7987] Added functionality for synchronizing data with Fellesdata from table view .
Date: Wed, 02 Nov 2011 11:28:12 +0000

Revision: 7987
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7987
Author:   vator
Date:     2011-11-02 11:27:52 +0000 (Wed, 02 Nov 2011)
Log Message:
-----------
Added functionality for synchronizing data with Fellesdata from table view . 
When right click on row it's possible to choose synchronize.

Modified Paths:
--------------
    trunk/rental/inc/class.uiparty.inc.php
    trunk/rental/templates/base/common.php
    trunk/rental/templates/base/css/base.css
    trunk/rental/templates/base/party.php
    trunk/rental/templates/base/party_list_partial.php
    trunk/rental/templates/base/sync_party_list_org_id.php

Modified: trunk/rental/inc/class.uiparty.inc.php
===================================================================
--- trunk/rental/inc/class.uiparty.inc.php      2011-11-02 11:07:18 UTC (rev 
7986)
+++ trunk/rental/inc/class.uiparty.inc.php      2011-11-02 11:27:52 UTC (rev 
7987)
@@ -82,7 +82,7 @@
 
                $config = CreateObject('phpgwapi.config','rental');
                $config->read();
-               $use_fellesdata = $config->config_data['use_fellesdata'];       
+               $use_fellesdata = $config->config_data['use_fellesdata'];
                switch($type)
                {
                        case 'included_parties': // ... get all parties 
incolved in the contract
@@ -113,7 +113,6 @@
                $result_objects = 
rental_soparty::get_instance()->get($start_index, $num_of_objects, $sort_field, 
$sort_ascending, $search_for, $search_type, $filters);
                $result_count = 
rental_soparty::get_instance()->get_count($search_for, $search_type, $filters);
                
-               
                // Create an empty row set
                $rows = array();
                foreach ($result_objects as $party) {
@@ -143,16 +142,33 @@
                                        {
                                                $unit_id = 
$unit_name_and_id['UNIT_ID'];
                                                $unit_name = 
$unit_name_and_id['UNIT_NAME'];
+                                               
                                                if(isset($unit_id) && 
is_numeric($unit_id))
                                                {
                                                        
$serialized['org_unit_name'] =  isset($unit_name) ? $unit_name : 
lang('no_name');
                                                        
$serialized['org_unit_id'] = $unit_id;
                                                }
+
+                                               // Fetches data from Fellesdata
+                                               $org_unit_id = 
$sync_data['org_enhet_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);
+                               
+                                               $org_name = 
$org_unit_with_leader['ORG_UNIT_NAME'];
+                                               $org_email = 
$org_unit_with_leader['ORG_EMAIL'];
+                                               $unit_leader_fullname = 
$org_unit_with_leader['LEADER_FULLNAME'];
+                                               $dep_org_name = 
$org_department['DEP_ORG_NAME'];
+
+                                               // Fields are displayed in 
syncronization table
+                                               $serialized['org_unit_name'] = 
$org_name;
+                                               $serialized['unit_leader'] = 
$unit_leader_fullname;
+                                               $serialized['org_email'] = 
$org_email;
+                                               $serialized['dep_org_name'] = 
$dep_org_name;            
                                        }
                                }
                                
                                //check if party is a part of a contract
-                               
                                $party_in_contract = 
rental_soparty::get_instance()->has_contract($party->get_id());
                                $serialized['party_in_contract'] = 
$party_in_contract ? true : false;
                                
@@ -178,7 +194,6 @@
                        );
                }
                
-               
                return $this->yui_results($party_data, 'total_records', 
'results');
        }
        
@@ -346,7 +361,8 @@
                $value['ajax'] = array();
                $value['actions'] = array();
                $value['labels'] = array();
-
+               $value['alert'] = array();
+       
                // Get parameters
                $contract_id = $params[0];
                $type = $params[1];
@@ -397,7 +413,7 @@
                                        $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 'rental.uiparty.edit', 'id' 
=> $value['id'])));
                                        $value['labels'][] = lang('edit');
                                        
-                                       if(isset($value['party_in_contract']) 
&& $value['party_in_contract'] == false)
+                                       if(isset($value['is_inactive']) && 
$value['is_inactive'] == true)
                                        {
                                                $value['ajax'][] = true;
                                                $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 
'rental.uiparty.delete_party', 'id' => $value['id'])));
@@ -411,18 +427,24 @@
                                                $value['labels'][] = 
lang('frontend_access');
                                        }
                                        
-                                       if(isset($value['org_unit_id']))
+                                       if(isset($value['org_enhet_id']) && 
$value['org_enhet_id'] != '')
                                        {
                                                $value['ajax'][] = true;
-                                               $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 
'rental.uiparty.syncronize_party', 'org_unit_id' => $value['org_unit_id'], 
'party_id' => $value['id'])));
+                                               $value['alert'][] = true;
+                                               
+                                               $alertMessage = "Du er i ferd 
med å overskrive data med informasjon hentet fra Fellesdata.\n\n";
+                                               $alertMessage .= "Følgende felt 
vil bli overskrevet: Foretak, Avdeling, Enhetsleder, Epost. \n\n";
+                                               $alertMessage .= "Vil du gjøre 
dette?";
+                                               
+                                               $value['alert'][] = 
$alertMessage; 
+                                               $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 
'rental.uiparty.syncronize_party', 'org_enhet_id' => $value['org_enhet_id'], 
'party_id' => $value['id'])));
                                                $value['labels'][] = 
lang('syncronize_party');
-                                       }                       
+                                       }
                                }
                                break;
                }
        }
-
-
+       
        /**
         * Public method. View all contracts.
         */
@@ -592,15 +614,48 @@
                if(($this->isExecutiveOfficer() || $this->isAdministrator()))
                {
                        $party_id = phpgw::get_var('party_id');
-                       $org_unit_id = phpgw::get_var('org_unit_id');
-                       $org_unit_name = phpgw::get_var('org_unit_id');
+                       $org_unit_id = phpgw::get_var('org_enhet_id');
+
                        if(isset($party_id) && $party_id > 0 && 
isset($org_unit_id) && $org_unit_id > 0)
                        {       
+                               $config = 
CreateObject('phpgwapi.config','rental');
+                               $config->read();
+                               
+                               $use_fellesdata = 
$config->config_data['use_fellesdata'];
+                               if(!$use_fellesdata){ 
+                                       return;
+                               }
+                               
+                               $bofelles = rental_bofellesdata::get_instance();
+                               
+                               $org_unit_with_leader = 
$bofelles->get_result_unit_with_leader($org_unit_id);
+                               $org_department = 
$bofelles->get_department_for_org_unit($org_unit_id);
+                               
+                               $org_name = 
$org_unit_with_leader['ORG_UNIT_NAME'];
+                               $org_email = $org_unit_with_leader['ORG_EMAIL'];
+                               $unit_leader_fullname = 
$org_unit_with_leader['LEADER_FULLNAME'];
+                               $dep_org_name = $org_department['DEP_ORG_NAME'];
+                                       
                                $party = 
rental_soparty::get_instance()->get_single($party_id);
-                               $party->set_org_enhet_id($org_unit_id);
-                               $patry->set_company_name($org_unit_name);
-                               // add log-statement for synchronization
+                                                               
+                               if(!empty($dep_org_name) & $dep_org_name != '')
+                                       $party->set_department($dep_org_name);
+                               
+                               if(!empty($unit_leader_fullname) & 
$unit_leader_fullname != '')
+                                       
$party->set_unit_leader($unit_leader_fullname);
+                                       
+                               if(!empty($org_name) & $org_name != '')
+                                       $party->set_company_name($org_name);
+
+                               if(!empty($org_email) & $org_email != '')
+                                       $party->set_email($org_email);
+                                       
+                               if(!empty($org_unit_id) & $org_unit_id != '')
+                                       $party->set_org_enhet_id($org_unit_id);
+       
                                rental_soparty::get_instance()->store($party);
+                               
+                               $party = 
rental_soparty::get_instance()->get_single($party_id);
                        }
                }
        }
@@ -639,8 +694,7 @@
                                $jsonArr = array("email" => trim($org_email), 
"org_name" => trim($org_name), 
                                                                 
"unit_leader_fullname" => trim($unit_leader_fullname), "department" => 
trim($dep_org_name));
                                
-                               return json_decode( json_encode($jsonArr) );
-                               
+                               return json_decode( json_encode($jsonArr) );    
        
                        }       
                }
        }       

Modified: trunk/rental/templates/base/common.php
===================================================================
--- trunk/rental/templates/base/common.php      2011-11-02 11:07:18 UTC (rev 
7986)
+++ trunk/rental/templates/base/common.php      2011-11-02 11:27:52 UTC (rev 
7987)
@@ -259,6 +259,24 @@
 
                                //... check whether this action should be an 
AJAX call
                                if(record.getData().ajax[task.index]) {
+
+                                       var alertStatus = false;
+
+                                       // Check if confirm box should be 
displayed before request is executed
+                                       if( record.getData().alert != null )
+                                           alertStatus = 
record.getData().alert[0];
+
+                                       if( alertStatus ){
+                                               // Display confirm box with 
message
+                                               var alertMessage = 
record.getData().alert[1];
+                                               var answer = confirm( 
alertMessage );
+                                               
+                                               // Abort request if user clicks 
the abort button
+                                               if (!answer){
+                                                       return false;
+                                               }
+                                       }
+                                       
                                        var request = 
YAHOO.util.Connect.asyncRequest(
                                                'GET',
                                                record.getData().actions[ 
task.index ],

Modified: trunk/rental/templates/base/css/base.css
===================================================================
--- trunk/rental/templates/base/css/base.css    2011-11-02 11:07:18 UTC (rev 
7986)
+++ trunk/rental/templates/base/css/base.css    2011-11-02 11:27:52 UTC (rev 
7987)
@@ -184,7 +184,7 @@
 }
 
 dl.proplist-col input.address_2{
-       margin-top:4px; 
+       margin-top:2px; 
 }
 
 div.identifier-header {

Modified: trunk/rental/templates/base/party.php
===================================================================
--- trunk/rental/templates/base/party.php       2011-11-02 11:07:18 UTC (rev 
7986)
+++ trunk/rental/templates/base/party.php       2011-11-02 11:27:52 UTC (rev 
7987)
@@ -330,6 +330,47 @@
                                                <dt><label><?php 
if($party->is_inactive()){?><font style="color: red;"><?php echo 
lang('inactive_party');?></font><?php }else{ ?><font style="color: 
green;"><?php echo lang('active_party');?></font><?php } ?></label></dt>
                                                <dd>&nbsp;</dd>
                                        <?php }?>
+                                       
+                                       <dt>
+                                               <?php 
if($party->get_unit_leader() || $editable) { ?>
+                                               <label for="unit_leader"><?php 
echo lang('unit_leader') ?></label>
+                                               <?php  } ?>
+                                       </dt>
+                                       <dd>
+                                               <?php
+                                               if ($editable)
+                                               {
+                                               ?>
+                                                       <input type="text" 
name="unit_leader" id="unit_leader" value="<?php echo $party->get_unit_leader() 
?>" />
+                                               <?php
+                                               }
+                                               else
+                                               {
+                                                       echo 
$party->get_unit_leader();
+                                               }
+                                               ?>
+                                       </dd>
+                               </dl>
+                       <dl class="proplist-col">
+                                       <dt>
+                                               <?php if($party->get_comment() 
|| $editable) { ?>
+                                               <label for="comment"><?php echo 
lang('comment') ?></label>
+                                               <?php } ?>
+                                       </dt>
+                                       <dd>
+                                               <?php
+                                               if ($editable)
+                                               {
+                                   ?>
+                                   <textarea cols="47" rows="7" name="comment" 
id="comment"><?php echo $party->get_comment(); ?></textarea>
+                                   <?php
+                                               }
+                                               else
+                                               {
+                                                       echo 
$party->get_comment();
+                                               }
+                                               ?>
+                                       </dd>
                                        <!--<dt>
                                                <?php 
if($party->get_location_id() || $editable) {?>
                                                <label for="location_id"><?php 
echo lang('party_location') ?></label>
@@ -394,48 +435,7 @@
                                                        include 
PHPGW_SERVER_ROOT . "/rental/inc/plugins/fellesdata/party.edit.php";
                                                }
                                        ?>
-                                       
                                </dl>
-                       <dl class="proplist-col">
-                                       <dt>
-                                               <?php 
if($party->get_unit_leader() || $editable) { ?>
-                                               <label for="unit_leader"><?php 
echo lang('unit_leader') ?></label>
-                                               <?php  } ?>
-                                       </dt>
-                                       <dd>
-                                               <?php
-                                               if ($editable)
-                                               {
-                                               ?>
-                                                       <input type="text" 
name="unit_leader" id="unit_leader" value="<?php echo $party->get_unit_leader() 
?>" />
-                                               <?php
-                                               }
-                                               else
-                                               {
-                                                       echo 
$party->get_unit_leader();
-                                               }
-                                               ?>
-                                       </dd>
-                                       <dt>
-                                               <?php if($party->get_comment() 
|| $editable) { ?>
-                                               <label for="comment"><?php echo 
lang('comment') ?></label>
-                                               <?php } ?>
-                                       </dt>
-                                       <dd>
-                                               <?php
-                                               if ($editable)
-                                               {
-                                   ?>
-                                   <textarea cols="40" rows="7" name="comment" 
id="comment"><?php echo $party->get_comment(); ?></textarea>
-                                   <?php
-                                               }
-                                               else
-                                               {
-                                                       echo 
$party->get_comment();
-                                               }
-                                               ?>
-                                       </dd>
-                               </dl>
                                <div class="form-buttons">
                                        <span id="unit_errorMsg">Du må velge 
organisasjonsenhet før du kan synkronisere</span>
                                        <?php

Modified: trunk/rental/templates/base/party_list_partial.php
===================================================================
--- trunk/rental/templates/base/party_list_partial.php  2011-11-02 11:07:18 UTC 
(rev 7986)
+++ trunk/rental/templates/base/party_list_partial.php  2011-11-02 11:27:52 UTC 
(rev 7987)
@@ -37,6 +37,10 @@
        {
                key: "ajax",
                hidden: true
+       },
+       {
+               key: "alert",
+               hidden: true
        }
        ];
 

Modified: trunk/rental/templates/base/sync_party_list_org_id.php
===================================================================
--- trunk/rental/templates/base/sync_party_list_org_id.php      2011-11-02 
11:07:18 UTC (rev 7986)
+++ trunk/rental/templates/base/sync_party_list_org_id.php      2011-11-02 
11:27:52 UTC (rev 7987)
@@ -12,8 +12,11 @@
        $list_id = 'sync_parties_org_unit';
        $url_add_on = '&amp;type=sync_parties_org_unit';
        $extra_cols = array(
-               array("key" => "sync_message", "label" => lang('sync_message'), 
"index" => 3),
-               array("key" => "org_unit_name", "label" => 
lang('org_unit_name'), "index" => 4)
+               //array("key" => "sync_message", "label" => 
lang('sync_message'), "index" => 3),
+               array("key" => "org_unit_name", "label" => 
lang('sync_org_name_fellesdata'), "index" => 4),
+               array("key" => "dep_org_name", "label" => 
lang('sync_org_department_fellesdata'), "index" => 5),
+               array("key" => "unit_leader", "label" => 
lang('sync_org_unit_leader_fellesdata'), "index" => 6),
+               array("key" => "org_email", "label" => 
lang('sync_org_email_fellesdata'), "index" => 7)
        );
        include('party_list_partial.php');
 ?>
\ No newline at end of file




reply via email to

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