fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15506] more on helpdesk


From: sigurdne
Subject: [Fmsystem-commits] [15506] more on helpdesk
Date: Thu, 25 Aug 2016 14:52:16 +0000 (UTC)

Revision: 15506
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15506
Author:   sigurdne
Date:     2016-08-25 14:52:16 +0000 (Thu, 25 Aug 2016)
Log Message:
-----------
more on helpdesk

Added Paths:
-----------
    trunk/helpdesk/inc/custom/
    trunk/helpdesk/inc/custom/default/
    trunk/helpdesk/inc/custom/default/ticket_LRS_pre_commit_validate.php

Added: trunk/helpdesk/inc/custom/default/ticket_LRS_pre_commit_validate.php
===================================================================
--- trunk/helpdesk/inc/custom/default/ticket_LRS_pre_commit_validate.php        
                        (rev 0)
+++ trunk/helpdesk/inc/custom/default/ticket_LRS_pre_commit_validate.php        
2016-08-25 14:52:16 UTC (rev 15506)
@@ -0,0 +1,64 @@
+<?php
+       /*
+        * This file will only work for the implementation of LRS
+        */
+
+       /**
+        * Intended for custom validation of tickets prior to commit.
+        *
+        * @author Sigurd Nes <address@hidden>
+        */
+       class ticket_LRS_pre_commit_validate extends helpdesk_botts
+       {
+
+               protected
+                       $db,
+                       $join,
+                       $left_join,
+                       $like;
+               function __construct()
+               {
+                       parent::__construct();
+                       $this->db = & $GLOBALS['phpgw']->db;
+                       $this->join = & $this->db->join;
+                       $this->left_join = & $this->db->left_join;
+                       $this->like = & $this->db->like;
+               }
+
+               /**
+                * Do your magic
+                * @param integer $id
+                * @param array $data
+                * @param array $values_attribute
+                */
+               function validate( $id = 0, &$data, $values_attribute = array() 
)
+               {
+                       if($id) // only on add
+                       {
+                               return;
+                       }
+                       $org_unit = (int)$values_attribute['1']['value'];
+                       $sql = "SELECT arbeidssted FROM fm_org_unit WHERE id = 
{$org_unit}";
+                       $this->db->query($sql);
+                       $this->db->next_record();
+                       $arbeidssted = (int)$this->db->f('arbeidssted');
+
+                       $location_id = 
$GLOBALS['phpgw']->locations->get_id('property', ".entity.6.1");
+
+                       $sql = "SELECT json_representation->>'alias' as alias 
FROM fm_bim_item WHERE location_id = {$location_id}"
+                       . " AND CAST(json_representation->>'arbeidssted_start' 
AS INTEGER) <= {$arbeidssted}"
+                       . " AND CAST(json_representation->>'arbeidssted_slutt' 
AS INTEGER) >= {$arbeidssted}";
+
+                       $this->db->query($sql);
+                       $this->db->next_record();
+                       $alias = strtolower($this->db->f('alias'));
+                       
+                       if(!$data['assignedto'] = 
$GLOBALS['phpgw']->accounts->name2id($alias))
+                       {
+                               $data['assignedto'] = 
isset($GLOBALS['phpgw_info']['user']['preferences']['helpdesk']['assigntodefault'])
 ? $GLOBALS['phpgw_info']['user']['preferences']['helpdesk']['assigntodefault'] 
: '';
+                       }
+                       return true;
+               }
+       }
+       $ticket_LRS_pre_commit_validate = new ticket_LRS_pre_commit_validate();
+       $ticket_LRS_pre_commit_validate->validate($id, $data, 
$values_attribute);




reply via email to

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