fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15606] property: handle relations


From: sigurdne
Subject: [Fmsystem-commits] [15606] property: handle relations
Date: Wed, 7 Sep 2016 15:10:35 +0000 (UTC)

Revision: 15606
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15606
Author:   sigurdne
Date:     2016-09-07 15:10:34 +0000 (Wed, 07 Sep 2016)
Log Message:
-----------
property: handle relations

Modified Paths:
--------------
    trunk/property/inc/class.borequest.inc.php
    trunk/property/inc/class.botts.inc.php
    trunk/property/inc/class.sorequest.inc.php
    trunk/property/inc/class.sotts.inc.php
    trunk/property/inc/class.uiproject.inc.php
    trunk/property/inc/class.uirequest.inc.php
    trunk/property/inc/class.uitts.inc.php
    trunk/property/js/portico/tts.view.js
    trunk/property/setup/phpgw_no.lang
    trunk/property/templates/base/tts.xsl

Modified: trunk/property/inc/class.borequest.inc.php
===================================================================
--- trunk/property/inc/class.borequest.inc.php  2016-09-07 13:14:31 UTC (rev 
15605)
+++ trunk/property/inc/class.borequest.inc.php  2016-09-07 15:10:34 UTC (rev 
15606)
@@ -484,13 +484,6 @@
                                }
                        }
 
-                       /* $request = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
-                         'filter' => $this->filter,'district_id' => 
$this->district_id,'cat_id' => $this->cat_id,'status_id' => $this->status_id,
-                         'project_id' => 
$data['project_id'],'allrows'=>$data['allrows'],'list_descr' => 
$data['list_descr'],
-                         'dry_run'=>$data['dry_run'], 'p_num' => 
$this->p_num,'start_date'=>$this->start_date,'end_date'=>$this->end_date,
-                         'property_cat_id' => $this->property_cat_id, 
'building_part' => $this->building_part,
-                         'degree_id' => $this->degree_id, 'attrib_filter' => 
$attrib_filter, 'condition_survey_id' => $this->condition_survey_id,
-                         'responsible_unit' => $this->responsible_unit, 
'recommended_year' => $this->recommended_year)); */
                        $values = $this->so->read(array
                                (
                                'start' => $data['start'],
@@ -500,7 +493,7 @@
                                'sort' => $data['sort'],
                                'allrows' => $data['allrows'],
                                'list_descr' => $data['list_descr'],
-                               'project_id' => $data['project_id'],
+                               'make_relation' => $data['make_relation'],
                                'dry_run' => $data['dry_run'],
                                'filter' => $this->filter,
                                'district_id' => $this->district_id,

Modified: trunk/property/inc/class.botts.inc.php
===================================================================
--- trunk/property/inc/class.botts.inc.php      2016-09-07 13:14:31 UTC (rev 
15605)
+++ trunk/property/inc/class.botts.inc.php      2016-09-07 15:10:34 UTC (rev 
15606)
@@ -1784,4 +1784,11 @@
                                );
                }
 
+
+               function add_relation( $add_relation, $id )
+               {
+                       return $this->so->add_relation($add_relation, $id);
+               }
+
+
        }
\ No newline at end of file

Modified: trunk/property/inc/class.sorequest.inc.php
===================================================================
--- trunk/property/inc/class.sorequest.inc.php  2016-09-07 13:14:31 UTC (rev 
15605)
+++ trunk/property/inc/class.sorequest.inc.php  2016-09-07 15:10:34 UTC (rev 
15606)
@@ -307,7 +307,7 @@
                        $property_cat_id = isset($data['property_cat_id']) ? 
$data['property_cat_id'] : 0;
                        $status_id = isset($data['status_id']) && 
$data['status_id'] ? $data['status_id'] : 'open';
                        $district_id = isset($data['district_id']) && 
$data['district_id'] ? $data['district_id'] : 0;
-                       $project_id = isset($data['project_id']) ? 
$data['project_id'] : '';
+                       $make_relation = isset($data['make_relation']) ? 
$data['make_relation'] : '';
                        $allrows = isset($data['allrows']) ? $data['allrows'] : 
'';
                        $results = isset($data['results']) ? 
(int)$data['results'] : 0;
                        $list_descr = isset($data['list_descr']) ? 
$data['list_descr'] : '';
@@ -716,9 +716,8 @@
                                $where = 'AND';
                        }
 
-                       if ($project_id && !$status_id)// lookup requests not 
already allocated to projects
+                       if ($make_relation && !$status_id)// lookup requests 
not already allocated to projects
                        {
-//                             $filtermethod .= " $where project_id is NULL ";
                                $filtermethod .= " $where 
fm_request_status.closed is NULL ";
                                $where = 'AND';
                        }

Modified: trunk/property/inc/class.sotts.inc.php
===================================================================
--- trunk/property/inc/class.sotts.inc.php      2016-09-07 13:14:31 UTC (rev 
15605)
+++ trunk/property/inc/class.sotts.inc.php      2016-09-07 15:10:34 UTC (rev 
15606)
@@ -1979,4 +1979,49 @@
 
                        return $values;
                }
+
+               function add_relation( $add_relation, $id )
+               {
+                       $config = $GLOBALS['phpgw']->config->read();
+                       $interlink = CreateObject('property.interlink');
+                       $this->db->transaction_begin();
+
+                       foreach ($add_relation['request_id'] as $relation_id)
+                       {
+                               $target_id = false;
+                               $target = 
$interlink->get_specific_relation('property', '.project.request', '.ticket', 
$relation_id, 'target');
+                               if ($target)
+                               {
+                                       $target_id =  $target[0];
+                               }
+
+                               if (!$target_id)
+                               {
+                                       $interlink_data = array(
+                                               'location1_id' => 
$GLOBALS['phpgw']->locations->get_id('property', '.project.request'),
+                                               'location1_item_id' => 
$relation_id,
+                                               'location2_id' => 
$GLOBALS['phpgw']->locations->get_id('property', '.ticket'),
+                                               'location2_item_id' => $id,
+                                               'account_id' => $this->account
+                                       );
+
+                                       $interlink->add($interlink_data);
+
+                                       $request_ticket_hookup_status = 
isset($config['request_ticket_hookup_status']) && 
$config['request_ticket_hookup_status'] ? 
$config['request_ticket_hookup_status'] : false;
+
+                                       if ($request_ticket_hookup_status)
+                                       {
+                                               $this->db->query("UPDATE 
fm_request SET status='{$request_ticket_hookup_status}' WHERE id='" . 
$relation_id . "'", __LINE__, __FILE__);
+                                       }
+
+                                       
phpgwapi_cache::message_set(lang('request %1 has been added', $relation_id), 
'message');
+                               }
+                               else
+                               {
+                                       
phpgwapi_cache::message_set(lang('request %1 has already been added to ticket 
%2', $relation_id, $target_id), 'error');
+                               }
+                       }
+                       $this->db->transaction_commit();
+                       return $receipt;
+               }
        }
\ No newline at end of file

Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php  2016-09-07 13:14:31 UTC (rev 
15605)
+++ trunk/property/inc/class.uiproject.inc.php  2016-09-07 15:10:34 UTC (rev 
15606)
@@ -1458,7 +1458,9 @@
                                (
                                'menuaction' => 'property.uirequest.index',
                                'query' => 
(isset($values['location_data']['loc1']) ? $values['location_data']['loc1'] : 
''),
-                               'project_id' => (isset($id) ? $id : '')
+                               'make_relation' => !!$id,
+                               'relation_id' => isset($id) ? $id : 0,
+                               'relation_type' => 'project'
                        );
 
                        $supervisor_email = array();

Modified: trunk/property/inc/class.uirequest.inc.php
===================================================================
--- trunk/property/inc/class.uirequest.inc.php  2016-09-07 13:14:31 UTC (rev 
15605)
+++ trunk/property/inc/class.uirequest.inc.php  2016-09-07 15:10:34 UTC (rev 
15606)
@@ -120,7 +120,7 @@
                 */
                public function query()
                {
-                       $project_id = phpgw::get_var('project_id', 'int');
+                       $make_relation =  phpgw::get_var('make_relation', 
'bool');
                        $search = phpgw::get_var('search');
                        $order = phpgw::get_var('order');
                        $draw = phpgw::get_var('draw', 'int');
@@ -150,7 +150,7 @@
                                'sort' => $order[0]['dir'],
                                'dir' => $order[0]['dir'],
                                'allrows' => phpgw::get_var('length', 'int') == 
-1 || $export,
-                               'project_id' => $project_id,
+                               'make_relation' => $make_relation,
                                'start_date' => $start_date,
                                'end_date' => $end_date,
                                'list_descr' => $list_descr
@@ -615,10 +615,27 @@
                                return $this->query();
                        }
 
-                       $project_id = phpgw::get_var('project_id', 'int'); // 
lookup for maintenance planning
+                       $make_relation =  phpgw::get_var('make_relation', 
'bool'); // lookup for maintenance planning
+                       $relation_id = phpgw::get_var('relation_id', 'int');
+                       $relation_type = phpgw::get_var('relation_type');
+
+                       switch ($relation_type)
+                       {
+                               case 'ticket':
+                                       $update_menuaction = 
'property.uitts.view';
+                                       $lang_update_relation = lang('update 
ticket');
+                                       break;
+                               case 'project':
+                                       $update_menuaction = 
'property.uiproject.edit';
+                                       $lang_update_relation = lang('update 
project');
+                                       break;
+                               default:
+                                       break;
+                       }
+
                        $query = phpgw::get_var('query');
 
-                       if ($project_id)
+                       if ($make_relation)
                        {
                                $lookup = true;
                        }
@@ -678,7 +695,9 @@
                                        'source' => self::link(array(
                                                'menuaction' => 
'property.uirequest.index',
                                                'lookup' => $lookup,
-                                               'project_id' => $project_id,
+                                               'make_relation' => 
$make_relation,
+                                               'relation_id' => $relation_id,
+                                               'relation_type' => 
$relation_type,
                                                'nonavbar' => $this->nonavbar,
                                                'phpgw_return_as' => 'json'
                                        )),
@@ -690,7 +709,7 @@
                                                'menuaction' => 
'property.uirequest.add'
                                        )),
                                        'allrows' => true,
-                                       'select_all' => !!$project_id,
+                                       'select_all' => $make_relation,
                                        'editor_action' => array(),
                                        'field' => array(),
                                        'query' => phpgw::get_var('query')
@@ -738,7 +757,7 @@
                                array_unshift($data['form']['toolbar']['item'], 
$filter);
                        }
 
-                       $this->bo->read(array('project_id' => $project_id, 
'allrows' => $this->allrows,
+                       $this->bo->read(array('make_relation' => 
$make_relation, 'allrows' => $this->allrows,
                                'dry_run' => true));
                        $uicols = $this->bo->uicols;
                        //_debug_array($uicols);die();
@@ -884,8 +903,8 @@
                                $data['datatable']['actions'][] = array
                                        (
                                        'my_name' => 'update_project',
-                                       'statustext' => lang('Update project'),
-                                       'text' => lang('Update project'),
+                                       'statustext' => $lang_update_relation,
+                                       'text' => $lang_update_relation,
                                        'type' => 'custom',
                                        'custom_code' => "
                                                                                
        
@@ -906,8 +925,8 @@
                        }
 
                                                                                
        var path_update = new Array();
-                                                                               
        path_update['menuaction'] = 'property.uiproject.edit';
-                                                                               
        path_update['id'] = '" . $project_id . "';
+                                                                               
        path_update['menuaction'] = '{$update_menuaction}';
+                                                                               
        path_update['id'] = '{$relation_id}';
 
                                                                                
        var sUrl = phpGWLink('index.php', path_update);
 

Modified: trunk/property/inc/class.uitts.inc.php
===================================================================
--- trunk/property/inc/class.uitts.inc.php      2016-09-07 13:14:31 UTC (rev 
15605)
+++ trunk/property/inc/class.uitts.inc.php      2016-09-07 15:10:34 UTC (rev 
15606)
@@ -1585,7 +1585,7 @@
                                        'perm' => 1, 'acl_location' => 
$this->acl_location));
                        }
 
-                       $id = phpgw::get_var('id', 'int', 'GET');
+                       $id = phpgw::get_var('id', 'int');
 
                        if ($this->tenant_id)
                        {
@@ -1593,6 +1593,12 @@
                                        'id' => $id));
                        }
 
+                       $add_relation = phpgw::get_var('add_request');
+                       if($add_relation)
+                       {
+                               $receipt = 
$this->bo->add_relation($add_relation, $id);
+                       }
+
                        $bolocation = CreateObject('property.bolocation');
 
                        $values = phpgw::get_var('values');
@@ -2768,17 +2774,17 @@
 
                        $relation_type_list = array(
                                array(
-                                       'id'    => 'property.uiproject.index',
-                                       'name'  => lang('project')
-                               ),
-                               array(
                                        'id'    => 'property.uirequest.index',
                                        'name'  => lang('request')
                                ),
-                               array(
-                                       'id'    => 'property.uilookup.entity',
-                                       'name'  => 'Everything else'
-                               ),
+//                             array(
+//                                     'id'    => 'property.uiproject.index',
+//                                     'name'  => lang('project')
+//                             ),
+//                             array(
+//                                     'id'    => 'property.uilookup.entity',
+//                                     'name'  => 'Everything else'
+//                             ),
                        );
 
                        $data = array(

Modified: trunk/property/js/portico/tts.view.js
===================================================================
--- trunk/property/js/portico/tts.view.js       2016-09-07 13:14:31 UTC (rev 
15605)
+++ trunk/property/js/portico/tts.view.js       2016-09-07 15:10:34 UTC (rev 
15606)
@@ -254,17 +254,24 @@
        relation_type = $('#make_relation').val();
        if (relation_type)
        {
-               oArgs = {
-                       menuaction: relation_type,
-                       make_relation: true,
-                       relation_id: id,
-                       relation_type: 'ticket',
-                       query: location_code, //defined in xsl
-                       clear_state:1,
-               };
-               var strURL = phpGWLink('index.php', oArgs);
-               window.open(strURL, '_self');
+               if (confirm("Du vil miste informasjon som ikke er lagret"))
+               {
+                       oArgs = {
+                               menuaction: relation_type,
+                               make_relation: true,
+                               relation_id: id,
+                               relation_type: 'ticket',
+                               query: location_code, //defined in xsl
+                               clear_state: 1,
+                       };
+                       var strURL = phpGWLink('index.php', oArgs);
+                       window.open(strURL, '_self');
+               }
        }
+       else
+       {
+               alert('Velg type');
+       }
 };
 
 window.addEventListener("load", function ()

Modified: trunk/property/setup/phpgw_no.lang
===================================================================
--- trunk/property/setup/phpgw_no.lang  2016-09-07 13:14:31 UTC (rev 15605)
+++ trunk/property/setup/phpgw_no.lang  2016-09-07 15:10:34 UTC (rev 15606)
@@ -2064,4 +2064,6 @@
 no date        property        no      Ingen dato
 Please select an external project!     property        no      Velg et 
tilnyttet eksternt prosjekt
 mine roles     property        no      Mine roller
-account type   property        no      Rolletype
\ No newline at end of file
+account type   property        no      Rolletype
+update ticket  property        no      Oppdater melding
+make relation  property        no      Opprett kopling
\ No newline at end of file

Modified: trunk/property/templates/base/tts.xsl
===================================================================
--- trunk/property/templates/base/tts.xsl       2016-09-07 13:14:31 UTC (rev 
15605)
+++ trunk/property/templates/base/tts.xsl       2016-09-07 15:10:34 UTC (rev 
15606)
@@ -371,7 +371,7 @@
                                                        </xsl:for-each>
                                                </div>
                                        </xsl:for-each>
-                                       <!--div class="pure-control-group">
+                                       <div class="pure-control-group">
                                                <xsl:variable 
name="lang_make_relation">
                                                        <xsl:value-of 
select="php:function('lang', 'make relation')"/>
                                                </xsl:variable>
@@ -393,7 +393,7 @@
                                                        </option>
                                                        <xsl:apply-templates 
select="relation_type_list/options"/>
                                                </select>
-                                       </div-->
+                                       </div>
 
                                        <div class="pure-control-group">
                                                <label>




reply via email to

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