[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [15999] more on integration
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [15999] more on integration |
Date: |
Mon, 14 Nov 2016 15:30:53 +0000 (UTC) |
Revision: 15999
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15999
Author: sigurdne
Date: 2016-11-14 15:30:52 +0000 (Mon, 14 Nov 2016)
Log Message:
-----------
more on integration
Modified Paths:
--------------
trunk/property/inc/class.botts.inc.php
trunk/property/inc/class.socommon.inc.php
trunk/property/inc/class.sotts.inc.php
trunk/property/inc/class.uitts.inc.php
trunk/property/inc/class.uiworkorder.inc.php
trunk/property/js/portico/tts.view.js
trunk/property/js/portico/workorder.edit.js
trunk/property/templates/base/tts.xsl
trunk/property/templates/base/workorder.xsl
Modified: trunk/property/inc/class.botts.inc.php
===================================================================
--- trunk/property/inc/class.botts.inc.php 2016-11-14 09:27:26 UTC (rev
15998)
+++ trunk/property/inc/class.botts.inc.php 2016-11-14 15:30:52 UTC (rev
15999)
@@ -1778,7 +1778,7 @@
return $this->so->add_relation($add_relation, $id);
}
- public function check_purchase_right($ecodimb = 0, $amount = 0,
$ticket_id = 0)
+ public function check_purchase_right($ecodimb = 0, $amount = 0,
$order_id = 0)
{
$need_approval =
isset($this->config->config_data['workorder_approval']) ?
$this->config->config_data['workorder_approval'] : '';
if(!$need_approval)
@@ -1850,7 +1850,7 @@
$supervisor_id =
$GLOBALS['phpgw_info']['user']['preferences']['property']['approval_from'];
}
- return $this->get_supervisor_email($supervisor_id,
$ticket_id);
+ return $this->get_supervisor_email($supervisor_id,
$order_id);
}
public function check_external_register($param)
@@ -1895,9 +1895,26 @@
return json_decode($result, true);
}
- protected function get_supervisor_email($supervisor_id,
$ticket_id)
+ protected function get_supervisor_email($supervisor_id,
$order_id)
{
$need_approval =
isset($this->config->config_data['workorder_approval']) ?
$this->config->config_data['workorder_approval'] : '';
+
+ $order_type =
$this->bocommon->socommon->get_order_type($order_id);
+
+ switch ($order_type)
+ {
+ case 'workorder':
+ $location = '.project.workorder';
+ $location_item_id = $order_id;
+ break;
+ case 'ticket':
+ $location = '.ticket';
+ $location_item_id =
$this->so->get_ticket_from_order($order_id);
+ break;
+ default:
+ throw new Exception('Not supported');
+ }
+
$supervisor_email = array();
if ($supervisor_id && $need_approval)
{
@@ -1907,8 +1924,8 @@
$action_params = array(
'appname' => 'property',
- 'location' => '.ticket',
- 'id' => $ticket_id,
+ 'location' => $location,
+ 'id' => $location_item_id,
'responsible' => $supervisor_id,
'responsible_type' => 'user',
'action' => 'approval',
@@ -1953,8 +1970,8 @@
{
$action_params = array(
'appname' => 'property',
- 'location' => '.ticket',
- 'id' => $ticket_id,
+ 'location' => $location,
+ 'id' =>
$location_item_id,
'responsible' =>
$prefs['approval_from'],
'responsible_type' => 'user',
'action' => 'approval',
@@ -1993,9 +2010,6 @@
unset($prefs);
}
-
-
-
return $supervisor_email;
}
Modified: trunk/property/inc/class.socommon.inc.php
===================================================================
--- trunk/property/inc/class.socommon.inc.php 2016-11-14 09:27:26 UTC (rev
15998)
+++ trunk/property/inc/class.socommon.inc.php 2016-11-14 15:30:52 UTC (rev
15999)
@@ -475,4 +475,17 @@
}
return $access_location;
}
+
+ /**
+ *
+ * @param int $id
+ * @return string
+ */
+ public function get_order_type($id)
+ {
+ $id = (int) $id;
+ $this->db->query("SELECT type FROM fm_orders WHERE
id={$id}", __LINE__, __FILE__);
+ $this->db->next_record();
+ return $this->db->f('type');
+ }
}
\ No newline at end of file
Modified: trunk/property/inc/class.sotts.inc.php
===================================================================
--- trunk/property/inc/class.sotts.inc.php 2016-11-14 09:27:26 UTC (rev
15998)
+++ trunk/property/inc/class.sotts.inc.php 2016-11-14 15:30:52 UTC (rev
15999)
@@ -2062,4 +2062,12 @@
$this->db->transaction_commit();
return $receipt;
}
+ function get_ticket_from_order($order_id)
+ {
+ $order_id = (int) $order_id;
+ $this->db->query("SELECT id FROM fm_tts_tickets WHERE
order_id = {$order_id}", __LINE__, __FILE__);
+ $this->db->next_record();
+ return $this->db->f('id');
+
+ }
}
\ No newline at end of file
Modified: trunk/property/inc/class.uitts.inc.php
===================================================================
--- trunk/property/inc/class.uitts.inc.php 2016-11-14 09:27:26 UTC (rev
15998)
+++ trunk/property/inc/class.uitts.inc.php 2016-11-14 15:30:52 UTC (rev
15999)
@@ -2979,9 +2979,9 @@
{
$ecodimb = phpgw::get_var('ecodimb');
$amount = phpgw::get_var('amount', 'int');
- $ticket_id = phpgw::get_var('ticket_id', 'int');
+ $order_id = phpgw::get_var('order_id', 'int');
- return $this->bo->check_purchase_right($ecodimb,
$amount, $ticket_id);
+ return $this->bo->check_purchase_right($ecodimb,
$amount, $order_id);
}
/**
Modified: trunk/property/inc/class.uiworkorder.inc.php
===================================================================
--- trunk/property/inc/class.uiworkorder.inc.php 2016-11-14 09:27:26 UTC
(rev 15998)
+++ trunk/property/inc/class.uiworkorder.inc.php 2016-11-14 15:30:52 UTC
(rev 15999)
@@ -2329,7 +2329,7 @@
'lang_budget' => lang('Budget'),
'value_budget' =>
isset($this->receipt['error']) && $this->receipt['error'] ?
$_POST['values']['budget'] : '',
'check_for_budget' => abs($budget),
-
+ 'value_budget' => $budget,
'lang_budget_statustext' => lang('Enter the
budget'),
'lang_incl_tax' => lang('incl tax'),
'lang_calculation' => lang('Calculation'),
Modified: trunk/property/js/portico/tts.view.js
===================================================================
--- trunk/property/js/portico/tts.view.js 2016-11-14 09:27:26 UTC (rev
15998)
+++ trunk/property/js/portico/tts.view.js 2016-11-14 15:30:52 UTC (rev
15999)
@@ -397,7 +397,7 @@
var total_amount = Number(amount) + Number($('#budget').val());
$("#order_received_amount").val(total_amount);
- var oArgs = {menuaction: 'property.uitts.check_purchase_right',
ecodimb: ecodimb, amount: total_amount, ticket_id: location_item_id};
+ var oArgs = {menuaction: 'property.uitts.check_purchase_right',
ecodimb: ecodimb, amount: total_amount, order_id: order_id};
var requestUrl = phpGWLink('index.php', oArgs, true);
var htmlString = "";
Modified: trunk/property/js/portico/workorder.edit.js
===================================================================
--- trunk/property/js/portico/workorder.edit.js 2016-11-14 09:27:26 UTC (rev
15998)
+++ trunk/property/js/portico/workorder.edit.js 2016-11-14 15:30:52 UTC (rev
15999)
@@ -1,6 +1,37 @@
var vendor_id;
+function calculate_order()
+{
+ if (!validate_form())
+ {
+ return;
+ }
+ document.getElementsByName("calculate_workorder")[0].value = 1;
+ check_and_submit_valid_session();
+}
+;
+
+function submit_workorder()
+{
+ if (!validate_form())
+ {
+ return;
+ }
+ check_and_submit_valid_session();
+}
+
+
+function send_order()
+{
+ if (!validate_form())
+ {
+ return;
+ }
+ document.getElementsByName("send_workorder")[0].value = 1;
+ check_and_submit_valid_session();
+}
+
$(document).ready(function ()
{
$('form[name=form]').submit(function (e)
@@ -55,6 +86,7 @@
{
msg = 'OK';
$("#order_received_time").html(data['time']);
+
$("#current_received_amount").html($("#order_received_amount").val());
}
else
{
@@ -116,33 +148,6 @@
return $('form').isValid(validateLanguage, conf);
}
-function submit_workorder()
-{
- if (!validate_form())
- {
- return;
- }
- check_and_submit_valid_session();
-}
-
-function calculate_workorder()
-{
- if (!validate_form())
- {
- return;
- }
- document.getElementsByName("calculate_workorder")[0].value = 1;
- check_and_submit_valid_session();
-}
-function send_workorder()
-{
- if (!validate_form())
- {
- return;
- }
- document.getElementsByName("send_workorder")[0].value = 1;
- check_and_submit_valid_session();
-}
function set_tab(tab)
{
$("#order_tab").val(tab);
@@ -391,4 +396,189 @@
// parent.hide_popupBox();
});
+
+ var test = document.getElementById('save_button');
+ var width = 200;
+ if (test !== null)
+ {
+ width = 160;
+ }
+ else
+ {
+ return;
+ }
+
+ test = document.getElementById('calculate_button');
+ if (test !== null)
+ {
+ width = 380;
+ }
+
+ $("#submitbox").css({
+ position: 'absolute',
+ right: '10px',
+ border: '1px solid #B5076D',
+ padding: '0 10px 10px 10px',
+ width: width + 'px',
+ "background - color": '#FFF',
+ display: "block",
+ });
+
+ var offset = $("#submitbox").offset();
+ var topPadding = 180;
+
+ if ($("#center_content").length === 1)
+ {
+ $("#center_content").scroll(function ()
+ {
+ if ($("#center_content").scrollTop() > offset.top)
+ {
+ $("#submitbox").stop().animate({
+ marginTop:
$("#center_content").scrollTop() - offset.top + topPadding
+ }, 100);
+ }
+ else
+ {
+ $("#submitbox").stop().animate({
+ marginTop: 0
+ }, 100);
+ }
+ ;
+ });
+ }
+ else
+ {
+ $(window).scroll(function ()
+ {
+ if ($(window).scrollTop() > offset.top)
+ {
+ $("#submitbox").stop().animate({
+ marginTop: $(window).scrollTop() -
offset.top + topPadding
+ }, 100);
+ }
+ else
+ {
+ $("#submitbox").stop().animate({
+ marginTop: 0
+ }, 100);
+ }
+ ;
+ });
+ }
});
+
+
+var ecodimb_selection = "";
+
+$(window).on('load', function ()
+{
+ ecodimb = $('#ecodimb').val();
+ if (ecodimb)
+ {
+ populateTableChkApproval();
+ ecodimb_selection = ecodimb;
+ }
+ $("#ecodimb_name").on("autocompleteselect", function (event, ui)
+ {
+ var ecodimb = ui.item.value;
+ if (ecodimb != ecodimb_selection)
+ {
+ populateTableChkApproval(ecodimb);
+ }
+ });
+
+ $("#budget").change(function ()
+ {
+ populateTableChkApproval();
+ });
+
+});
+
+function populateTableChkApproval(ecodimb)
+{
+ ecodimb = ecodimb || $('#ecodimb').val();
+
+ if (!ecodimb)
+ {
+ return;
+ }
+
+ var total_amount = Number(value_budget) +
Number($('#field_budget').val());
+ $("#order_received_amount").val(total_amount);
+
+ var oArgs = {menuaction: 'property.uitts.check_purchase_right',
ecodimb: ecodimb, amount: total_amount, order_id: order_id};
+ var requestUrl = phpGWLink('index.php', oArgs, true);
+ var htmlString = "";
+
+ $.ajax({
+ type: 'POST',
+ dataType: 'json',
+ url: requestUrl,
+ success: function (data)
+ {
+ if (data != null)
+ {
+ htmlString = "<table><thead><th>Be om
godkjenning</th><th>Adresse</th><th>Godkjent</th></thead><tbody>";
+ var obj = data;
+ var required = '';
+
+ $.each(obj, function (i)
+ {
+ required = '';
+
+ htmlString += "<tr><td>";
+
+ var left_cell = "Ikke relevant";
+
+ if (obj[i].requested === true)
+ {
+ left_cell =
obj[i].requested_time;
+ }
+ else if (obj[i].is_user !== true)
+ {
+ if (obj[i].approved !== true)
+ {
+ if (obj[i].required ===
true)
+ {
+ required =
'checked="checked" disabled="disabled"';
+ left_cell =
"<input type=\"hidden\" name=\"values[approval][" + obj[i].id + "]\" value=\""
+ obj[i].address + "\"></input>";
+ }
+ else
+ {
+ left_cell = '';
+ }
+ left_cell += "<input
type=\"checkbox\" name=\"values[approval][" + obj[i].id + "]\" value=\"" +
obj[i].address + "\"" + required + "></input>";
+ }
+ }
+ else if (obj[i].is_user === true)
+ {
+ left_cell = '(Meg selv...)';
+ }
+ htmlString += left_cell;
+ htmlString += "</td><td
valign=\"top\">";
+ htmlString += obj[i].address;
+ htmlString += "</td>";
+ htmlString += "<td>";
+
+ if (obj[i].approved === true)
+ {
+ htmlString +=
obj[i].approved_time;
+ }
+ else
+ {
+ if (obj[i].is_user === true)
+ {
+ htmlString += "<input
type=\"checkbox\" name=\"values[do_approve][" + obj[i].id + "]\" value=\"" +
obj[i].id + "\"></input>";
+ }
+ }
+ htmlString += "</td>";
+
+ htmlString += "</tr>";
+ });
+ htmlString += "</tbody></table>";
+//console.log(htmlString);
+ $("#approval_container").html(htmlString);
+ }
+ }
+ });
+}
Modified: trunk/property/templates/base/tts.xsl
===================================================================
--- trunk/property/templates/base/tts.xsl 2016-11-14 09:27:26 UTC (rev
15998)
+++ trunk/property/templates/base/tts.xsl 2016-11-14 15:30:52 UTC (rev
15999)
@@ -289,6 +289,7 @@
var base_java_url = <xsl:value-of select="base_java_url"/>;
var location_item_id = '<xsl:value-of
select="location_item_id"/>';
+ var order_id = '<xsl:value-of select="value_order_id"/>';
var location_code = '<xsl:value-of
select="value_location_code"/>';
// var initialSelection = <xsl:value-of
select="resources_json"/>;
Modified: trunk/property/templates/base/workorder.xsl
===================================================================
--- trunk/property/templates/base/workorder.xsl 2016-11-14 09:27:26 UTC (rev
15998)
+++ trunk/property/templates/base/workorder.xsl 2016-11-14 15:30:52 UTC (rev
15999)
@@ -73,6 +73,15 @@
<!-- add / edit -->
<xsl:template xmlns:php="http://php.net/xsl" match="edit">
+ <style type="text/css">
+ #floating-box {
+ position: relative;
+ z-index: 10;
+ }
+ #submitbox {
+ display: none;
+ }
+ </style>
<xsl:variable name="lang_done">
<xsl:value-of select="lang_done"/>
@@ -92,6 +101,7 @@
<table cellpadding="2" cellspacing="2" align="center">
<div id="receipt"></div>
<input type="hidden" id = "lean" name="lean" value="{lean}"/>
+ <!--
<xsl:choose>
<xsl:when test="mode='edit' and lean = 0">
<td>
@@ -125,7 +135,7 @@
<xsl:variable
name="lang_calculate">
<xsl:value-of select="lang_calculate"/>
</xsl:variable>
- <input
type="button" class="pure-button pure-button-primary" name="calculate"
value="{$lang_calculate}" onClick="calculate_workorder()">
+ <input
type="button" class="pure-button pure-button-primary" name="calculate"
value="{$lang_calculate}" onClick="calculate_order();">
<xsl:attribute name="title">
<xsl:value-of select="lang_calculate_statustext"/>
</xsl:attribute>
@@ -135,7 +145,7 @@
<xsl:variable
name="lang_send">
<xsl:value-of select="lang_send"/>
</xsl:variable>
- <input
type="button" class="pure-button pure-button-primary" name="send"
value="{$lang_send}" onClick="send_workorder()">
+ <input
type="button" class="pure-button pure-button-primary" name="send"
value="{$lang_send}" onClick="send_order()">
<xsl:attribute name="title">
<xsl:value-of select="lang_send_statustext"/>
</xsl:attribute>
@@ -146,6 +156,7 @@
</td>
</xsl:when>
</xsl:choose>
+ -->
</table>
<xsl:variable name="form_action">
<xsl:value-of select="form_action"/>
@@ -160,6 +171,58 @@
<input id="order_tab" type="hidden" name="tab" value=""/>
<div id="tab-content">
<xsl:value-of disable-output-escaping="yes"
select="tabs"/>
+ <div id="floating-box">
+ <div id="submitbox">
+ <table width="200px">
+ <tbody>
+ <tr>
+ <xsl:choose>
+
<xsl:when test="mode='edit' and lean = 0">
+
<td>
+
<input type="button" class="pure-button pure-button-primary"
id="save_button" name="save" value="{$lang_save}" onClick="submit_workorder();">
+
<xsl:attribute name="title">
+
<xsl:value-of select="lang_save_statustext"/>
+
</xsl:attribute>
+
</input>
+
</td>
+
<td>
+
<input type="button" class="pure-button pure-button-primary"
name="done" value="{$lang_done}" onClick="document.done_form.submit();">
+
<xsl:attribute name="title">
+
<xsl:value-of select="lang_done_statustext"/>
+
</xsl:attribute>
+
</input>
+
</td>
+
</xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+
<xsl:when test="value_workorder_id!='' and mode='edit' and lean = 0">
+
<td valign="top">
+
<xsl:variable name="lang_calculate">
+
<xsl:value-of select="lang_calculate"/>
+
</xsl:variable>
+
<input type="button" class="pure-button pure-button-primary"
id="calculate_button" name="calculate" value="{$lang_calculate}"
onClick="calculate_order();">
+
<xsl:attribute name="title">
+
<xsl:value-of select="lang_calculate_statustext"/>
+
</xsl:attribute>
+
</input>
+
</td>
+
<td>
+
<xsl:variable name="lang_send">
+
<xsl:value-of select="lang_send"/>
+
</xsl:variable>
+
<input type="button" class="pure-button pure-button-primary"
name="send" value="{$lang_send}" onClick="send_order();">
+
<xsl:attribute name="title">
+
<xsl:value-of select="lang_send_statustext"/>
+
</xsl:attribute>
+
</input>
+
</td>
+
</xsl:when>
+ </xsl:choose>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
<div id="general">
<fieldset>
<xsl:choose>
@@ -922,6 +985,17 @@
</xsl:for-each>
</div>
</div>
+ <xsl:choose>
+ <xsl:when
test="need_approval='1'">
+ <div
class="pure-control-group">
+ <label>
+
<xsl:value-of select="php:function('lang', 'approval')"/>
+ </label>
+ <div
id="approval_container" class="pure-table pure-u-md-1-2">
+ </div>
+ </div>
+ </xsl:when>
+ </xsl:choose>
<div class="pure-control-group">
<label for="name">
<xsl:choose>
@@ -993,16 +1067,15 @@
</xsl:attribute>
</xsl:if>
</input>
- <div
id="order_received_time" class="pure-custom">
+ <div
class="pure-custom">
<table>
<tr>
-
<td>
-
+
<td id="order_received_time">
<xsl:value-of select="value_order_received"/>
</td>
</tr>
<tr>
-
<td align="right">
+
<td align="right" id ="current_received_amount">
<xsl:value-of select="value_order_received_amount"/>
</td>
</tr>
@@ -1197,8 +1270,10 @@
<script type="text/javascript">
var lang = <xsl:value-of
select="php:function('js_lang', 'please enter either a budget or contrakt
sum')"/>;
var check_for_budget = <xsl:value-of
select="check_for_budget"/>;
+ var value_budget = <xsl:value-of
select="value_budget"/>;
var base_java_url = <xsl:value-of
select="base_java_url"/>;
var location_item_id = '<xsl:value-of
select="location_item_id"/>';
+ var order_id = '<xsl:value-of
select="value_workorder_id"/>';
</script>
</div>
<div class="proplist-col">
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [15999] more on integration,
sigurdne <=