[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [8337] property: notifier
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [8337] property: notifier |
Date: |
Fri, 16 Dec 2011 11:10:47 +0000 |
Revision: 8337
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8337
Author: sigurdne
Date: 2011-12-16 11:10:47 +0000 (Fri, 16 Dec 2011)
Log Message:
-----------
property: notifier
Modified Paths:
--------------
trunk/property/inc/class.notify.inc.php
trunk/property/inc/class.uiproject.inc.php
trunk/property/inc/class.uiworkorder.inc.php
trunk/property/js/yahoo/notify.js
trunk/property/templates/base/project.xsl
trunk/property/templates/base/workorder.xsl
Modified: trunk/property/inc/class.notify.inc.php
===================================================================
--- trunk/property/inc/class.notify.inc.php 2011-12-16 08:56:34 UTC (rev
8336)
+++ trunk/property/inc/class.notify.inc.php 2011-12-16 11:10:47 UTC (rev
8337)
@@ -70,20 +70,20 @@
public function read($data = array())
{
- if(!isset($data['location_id']) ||
!isset($data['location_item_id']))
+ if(!isset($data['location_id']) ||
!isset($data['location_item_id']) || !$data['location_item_id'])
{
throw new Exception("property_notify::read() -
Missing location info in input");
}
$location_id = (int) $data['location_id'];
- $location_item_id = (int) $data['location_item_id'];
+ $location_item_id = $data['location_item_id']; // in
case of bigint
$sql = "SELECT phpgw_notification.id,
phpgw_notification.contact_id,phpgw_notification.user_id,"
. "
phpgw_notification.is_active,phpgw_notification.entry_date,phpgw_notification.notification_method,"
. " first_name, last_name"
. " FROM phpgw_notification"
. " {$this->_join} phpgw_contact_person ON
phpgw_notification.contact_id = phpgw_contact_person.person_id"
- . " WHERE location_id = {$location_id} AND
location_item_id = {$location_item_id}";
+ . " WHERE location_id = {$location_id} AND
location_item_id = '{$location_item_id}'";
$this->_db->query($sql,__LINE__,__FILE__);
$values = array();
@@ -115,7 +115,7 @@
$entry['sms'] =
$comms[$entry['contact_id']]['mobile (cell) phone'];
$entry['is_active_text'] = $entry['is_active']
? $lang_yes : $lang_no;
}
-//_debug_array($values);
+
return $values;
}
@@ -128,19 +128,18 @@
public function get_yui_table_def($data = array())
{
-//_debug_array($data);die();
- if(!isset($data['location_id']) ||
!isset($data['location_item_id']))
- {
- throw new
Exception("property_notify::get_yui_table_def() - Missing location info in
input");
- }
-
if(!isset($data['count']))
{
throw new
Exception("property_notify::get_yui_table_def() - Missing count in input");
}
- $content = $this->read($data);
+ $content = array();
+ if(isset($data['location_id']) &&
isset($data['location_item_id']))
+ {
+ $content = $this->read($data);
+ }
+
$count = (int)$data['count'];
$datavalues = array
(
@@ -183,15 +182,13 @@
))
);
-
$GLOBALS['phpgw']->js->validate_file( 'yahoo',
'notify', 'property' );
$lang_view = lang('view');
$code = <<<JS
- YAHOO.widget.DataTable.formatLink_notify = function(elCell, oRecord,
oColumn, oData)
- {
- elCell.innerHTML = "<a
href="+datatable[{$count}][0]["edit_action"]+"&ab_id="+oData+"
title='"+oData+"'>{$lang_view}</a>";
- };
+ var notify_table_count = {$count};
+ var notify_lang_view = "{$lang_view}";
+ var notify_lang_alert = "Posten må lagres før kontakter kan tilordnes";
this.refresh_notify_contact=function()
{
@@ -236,15 +233,12 @@
execute_async(myDataTable_{$count});
}
}
-
-
JS;
$GLOBALS['phpgw']->js->add_code($namespace, $code);
return array('datavalues' => $datavalues, 'column_defs'
=> $column_defs, 'buttons' => $buttons);
}
-
public function update_data()
{
$action = phpgw::get_var('action', 'string', 'GET');
Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php 2011-12-16 08:56:34 UTC (rev
8336)
+++ trunk/property/inc/class.uiproject.inc.php 2011-12-16 11:10:47 UTC (rev
8337)
@@ -1241,7 +1241,7 @@
)
{
$prefs_coordinator =
$this->bocommon->create_preferences('property',$values['coordinator']);
- $to[] =
$prefs_coordinator['email'];
+ $toarray[] =
$prefs_coordinator['email'];
}
}
@@ -1691,12 +1691,7 @@
);
-
- $content_notify = array();
-
- $notify =
CreateObject('property.notify');
-
- $notify_info = $notify->get_yui_table_def(array
+ $notify_info =
execMethod('property.notify.get_yui_table_def',array
(
'location_id' => $location_id,
'location_item_id' => $id,
Modified: trunk/property/inc/class.uiworkorder.inc.php
===================================================================
--- trunk/property/inc/class.uiworkorder.inc.php 2011-12-16 08:56:34 UTC
(rev 8336)
+++ trunk/property/inc/class.uiworkorder.inc.php 2011-12-16 11:10:47 UTC
(rev 8337)
@@ -845,9 +845,10 @@
$values['b_account_name'] =
phpgw::get_var('b_account_name', 'string', 'POST');
$values['event_id'] =
phpgw::get_var('event_id', 'int', 'POST');
+ $location_id =
$GLOBALS['phpgw']->locations->get_id('property', $this->acl_location);
+
$config->read();
-
$origin =
phpgw::get_var('origin');
$origin_id =
phpgw::get_var('origin_id', 'int');
@@ -1056,6 +1057,84 @@
$receipt['error'][]=array('msg'=>lang('SMTP server is not set! (admin
section)'));
}
}
+ $toarray = array();
+ $toarray_sms = array();
+
+ if (isset($receipt['notice_owner']) &&
is_array($receipt['notice_owner'])
+// &&
$config->config_data['mailnotification'])
+ &&
isset($GLOBALS['phpgw_info']['user']['preferences']['property']['notify_project_owner'])
&&
$GLOBALS['phpgw_info']['user']['preferences']['property']['notify_project_owner']
+ )
+ {
+
if($this->account!=$project['coordinator'] &&
$config->config_data['workorder_approval'])
+ {
+ $prefs_coordinator =
$this->bocommon->create_preferences('property',$project['coordinator']);
+ $toarray[] =
$prefs_coordinator['email'];
+ }
+ }
+
+ $notify_list =
execMethod('property.notify.read', array
+ (
+ 'location_id'
=> $location_id,
+
'location_item_id' => $id
+ )
+ );
+
+ $subject=lang('workorder %1 has been
edited',$id);
+ $sms_text = "{$subject}.
\r\n{$GLOBALS['phpgw_info']['user']['fullname']}
\r\n{$GLOBALS['phpgw_info']['user']['preferences']['property']['email']}";
+ $sms = CreateObject('sms.sms');
+
+ foreach($notify_list as $entry)
+ {
+ if($entry['is_active'] &&
$entry['notification_method'] == 'email' && $entry['email'])
+ {
+ $toarray[] =
"{$entry['first_name']} {$entry['last_name']}<{$entry['email']}>";
+ }
+ else if($entry['is_active'] &&
$entry['notification_method'] == 'sms' && $entry['sms'])
+ {
+
$sms->websend2pv($this->account,$entry['sms'],$sms_text);
+ $toarray_sms[] =
"{$entry['first_name']} {$entry['last_name']}({$entry['sms']})";
+
$receipt['message'][]=array('msg'=>lang('%1 is
notified',"{$entry['first_name']} {$entry['last_name']}"));
+ }
+ }
+ unset($entry);
+
+ if($toarray_sms)
+ {
+
$historylog->add('MS',$id,implode(',',$toarray_sms));
+ }
+
+ if ($toarray)
+ {
+ $to = implode(';',$toarray);
+
$from_name=$GLOBALS['phpgw_info']['user']['fullname'];
+
$from_email=$GLOBALS['phpgw_info']['user']['preferences']['property']['email'];
+ $body = '<a href ="http://' .
$GLOBALS['phpgw_info']['server']['hostname'] .
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
'property.uiworkorder.edit','id'=> $id)).'">' . lang('workorder %1 has been
edited',$id) .'</a>' . "\n";
+
foreach($receipt['notice_owner'] as $notice)
+ {
+ $body .= $notice . "\n";
+ }
+ $body .= lang('Altered by') .
': ' . $from_name . "\n";
+ $body .= lang('remark') . ': '
. $values['remark'] . "\n";
+ $body = nl2br($body);
+
+ if
(!is_object($GLOBALS['phpgw']->send))
+ {
+ $GLOBALS['phpgw']->send
= CreateObject('phpgwapi.send');
+ }
+
+ $returncode =
$GLOBALS['phpgw']->send->msg('email',$to,$subject,$body, false,false,false,
$from_email, $from_name, 'html');
+
+ if (!$returncode) // not
nice, but better than failing silently
+ {
+
$receipt['error'][]=array('msg'=>"uiworkorder::edit: sending message to '$to'
subject='$subject' failed !!!");
+
$receipt['error'][]=array('msg'=> $GLOBALS['phpgw']->send->err['desc']);
+ }
+ else
+ {
+ $historylog->add('ON',
$id, lang('%1 is notified',$to));
+
$receipt['message'][]=array('msg'=>lang('%1 is notified',$to));
+ }
+ }
}
}
@@ -1093,46 +1172,8 @@
$GLOBALS['phpgw']->session->appsession('receipt','property',$receipt);
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=>
'property.uiworkorder.view', 'id'=>$id));
}
- if (isset($receipt['notice_owner']) &&
is_array($receipt['notice_owner'])
- //
&& $config->config_data['mailnotification'])
- &&
isset($GLOBALS['phpgw_info']['user']['preferences']['property']['notify_project_owner'])
&&
$GLOBALS['phpgw_info']['user']['preferences']['property']['notify_project_owner']
- )
- {
-
if($this->account!=$project['coordinator'] &&
$config->config_data['workorder_approval'])
- {
- $prefs_coordinator =
$this->bocommon->create_preferences('property',$project['coordinator']);
- $to =
$prefs_coordinator['email'];
-
$from_name=$GLOBALS['phpgw_info']['user']['fullname'];
-
$from_email=$GLOBALS['phpgw_info']['user']['preferences']['property']['email'];
- $body = '<a href ="http://' .
$GLOBALS['phpgw_info']['server']['hostname'] .
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
'property.uiworkorder.edit','id'=> $id)).'">' . lang('workorder %1 has been
edited',$id) .'</a>' . "\n";
-
foreach($receipt['notice_owner'] as $notice)
- {
- $body .= $notice . "\n";
- }
- $body .= lang('Altered by') .
': ' . $from_name . "\n";
- $body .= lang('remark') . ': '
. $values['remark'] . "\n";
- $body = nl2br($body);
- if
(!is_object($GLOBALS['phpgw']->send))
- {
- $GLOBALS['phpgw']->send
= CreateObject('phpgwapi.send');
- }
- $returncode =
$GLOBALS['phpgw']->send->msg('email',$to,$subject=lang('workorder %1 has been
edited',$id),$body, false,false,false, $from_email, $from_name, 'html');
-
- if (!$returncode) // not
nice, but better than failing silently
- {
-
$receipt['error'][]=array('msg'=>"uiworkorder::edit: sending message to '$to'
subject='$subject' failed !!!");
-
$receipt['error'][]=array('msg'=> $GLOBALS['phpgw']->send->err['desc']);
- }
- else
- {
- $historylog->add('ON',
$id, lang('%1 is notified',$to));
-
$receipt['message'][]=array('msg'=>lang('%1 is notified',$to));
- }
- }
- }
-
if( $project['key_fetch'] &&
!$values['key_fetch'])
{
$values['key_fetch']=$project['key_fetch'];
@@ -1507,9 +1548,19 @@
))
);
+ $notify_info =
execMethod('property.notify.get_yui_table_def',array
+ (
+
'location_id' => $location_id,
+
'location_item_id' => $id,
+ 'count'
=> count($myColumnDefs)
+ )
+ );
+
+ $datavalues[] = $notify_info['datavalues'];
+ $myColumnDefs[] = $notify_info['column_defs'];
+ $myButtons = array();
+ $myButtons[] = $notify_info['buttons'];
-
-
$link_claim = '';
if(isset($values['charge_tenant'])?$values['charge_tenant']:'')
{
@@ -1541,8 +1592,9 @@
'suppresscoordination'
=> $suppresscoordination,
'property_js'
=>
json_encode($GLOBALS['phpgw_info']['server']['webserver_url']."/property/js/yahoo/property2.js"),
'datatable'
=> $datavalues,
- 'myColumnDefs'
=> $myColumnDefs,
- 'tabs'
=>
self::_generate_tabs(array(),array('coordination' => $suppresscoordination)),
+ 'myColumnDefs'
=> $myColumnDefs,
+ 'myButtons'
=> $myButtons,
+ 'tabs'
=>
self::_generate_tabs(array(),array('documents' => $id?false:true, 'history' =>
$id?false:true)),
'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
'value_origin'
=> isset($values['origin']) ? $values['origin'] : '',
'value_origin_type'
=> isset($origin)?$origin:'',
@@ -1709,6 +1761,7 @@
'lang_upload_file'
=> lang('Upload file'),
'lang_file_statustext'
=> lang('Select file to upload'),
'value_billable_hours'
=> $values['billable_hours'],
+ 'base_java_url'
=>
"{menuaction:'property.notify.update_data',location_id:{$location_id},location_item_id:'{$id}'}",
);
$appname
= lang('Workorder');
Modified: trunk/property/js/yahoo/notify.js
===================================================================
--- trunk/property/js/yahoo/notify.js 2011-12-16 08:56:34 UTC (rev 8336)
+++ trunk/property/js/yahoo/notify.js 2011-12-16 11:10:47 UTC (rev 8337)
@@ -21,6 +21,14 @@
};
*/
+// var notify_table_count defined in property_notify::get_yui_table_def()
+// var notify_lang_view defined in property_notify::get_yui_table_def()
+
+ YAHOO.widget.DataTable.formatLink_notify = function(elCell, oRecord,
oColumn, oData)
+ {
+ elCell.innerHTML = "<a
href="+datatable[notify_table_count][0]["edit_action"]+"&ab_id="+oData+"
title='"+oData+"'>"+notify_lang_view+"</a>";
+ };
+
var FormatterRight_notify = function(elCell, oRecord, oColumn, oData)
{
elCell.innerHTML = "<div align=\"right\">"+oData+"</div>";
@@ -69,7 +77,7 @@
{
if(!base_java_url['location_item_id'])
{
- alert('Posten må lagres før kontakter kan tilordnes');
+ alert(notify_lang_alert); // notify_lang_alert is
defined in php-class property_notify::get_yui_table_def()
return;
}
var oArgs =
{menuaction:'property.uilookup.addressbook',column:'notify_contact'};
Modified: trunk/property/templates/base/project.xsl
===================================================================
--- trunk/property/templates/base/project.xsl 2011-12-16 08:56:34 UTC (rev
8336)
+++ trunk/property/templates/base/project.xsl 2011-12-16 11:10:47 UTC (rev
8337)
@@ -561,8 +561,8 @@
</script>
</div>
<div id="coordination">
- <xsl:variable name="lang_contact_statustext"><xsl:value-of
select="php:function('lang', 'click this link to select')" /></xsl:variable>
<table cellpadding="2" cellspacing="2" width="80%"
align="center">
+ <xsl:variable
name="lang_contact_statustext"><xsl:value-of select="php:function('lang',
'click this link to select')" /></xsl:variable>
<tr>
<td valign="top">
<a
href="javascript:notify_contact_lookup()" title="{$lang_contact_statustext}">
@@ -570,7 +570,7 @@
</a>
</td>
<td><table><tr><td>
- <input size="5" type="hidden"
id = "notify_contact" name="notify_contact" value=""
title="{$lang_contact_statustext}">
+ <input type="hidden" id =
"notify_contact" name="notify_contact" value=""
title="{$lang_contact_statustext}">
</input>
<input size="30" type="text"
name="notify_contact_name" value="" onClick="notify_contact_lookup();" readonly
= 'readonly' title="{$lang_contact_statustext}"/>
</td></tr></table></td>
Modified: trunk/property/templates/base/workorder.xsl
===================================================================
--- trunk/property/templates/base/workorder.xsl 2011-12-16 08:56:34 UTC (rev
8336)
+++ trunk/property/templates/base/workorder.xsl 2011-12-16 11:10:47 UTC (rev
8337)
@@ -825,11 +825,33 @@
</div>
- <xsl:choose>
- <xsl:when test="suppresscoordination =''">
-
- <div id="coordination">
- <table cellpadding="2" cellspacing="2"
width="80%" align="center">
+ <div id="coordination">
+ <table cellpadding="2" cellspacing="2" width="80%"
align="center">
+ <xsl:variable
name="lang_contact_statustext"><xsl:value-of select="php:function('lang',
'click this link to select')" /></xsl:variable>
+ <tr>
+ <td valign="top">
+ <a
href="javascript:notify_contact_lookup()" title="{$lang_contact_statustext}">
+ <xsl:value-of
select="php:function('lang', 'contact')" />
+ </a>
+ </td>
+ <td><table><tr><td>
+ <input type="hidden" id =
"notify_contact" name="notify_contact" value=""
title="{$lang_contact_statustext}">
+ </input>
+ <input size="30" type="text"
name="notify_contact_name" value="" onClick="notify_contact_lookup();" readonly
= 'readonly' title="{$lang_contact_statustext}"/>
+ </td></tr></table></td>
+ </tr>
+ <tr>
+ <td valign = "top" class="th_text">
+ <xsl:value-of
select="php:function('lang', 'notify')" />
+ </td>
+ <td >
+ <div id="paging_3"> </div>
+ <div id="datatable-container_3"></div>
+ <div id="datatable-buttons_3"></div>
+ </td>
+ </tr>
+ <xsl:choose>
+ <xsl:when test="suppresscoordination =''">
<tr>
<td>
<xsl:value-of
select="lang_key_fetch"/>
@@ -868,41 +890,37 @@
</xsl:for-each>
</td>
</tr>
- </table>
- </div>
- </xsl:when>
- </xsl:choose>
-
- <div id="documents">
- <table cellpadding="2" cellspacing="2" width="80%"
align="center">
-
- <xsl:choose>
- <xsl:when test="files!=''">
- <!-- <xsl:call-template
name="file_list"/> -->
+ </xsl:when>
+ </xsl:choose>
+ </table>
+ </div>
+ <xsl:choose>
+ <xsl:when test="value_workorder_id!=''">
+ <div id="documents">
+ <table cellpadding="2" cellspacing="2"
width="80%" align="center">
<tr>
<td align="left" valign="top">
<xsl:value-of
select="//lang_files"/>
</td>
<td>
- <div
id="datatable-container_1"></div>
+ <div
id="datatable-container_1"></div>
</td>
</tr>
- </xsl:when>
- </xsl:choose>
-
- <xsl:call-template name="file_upload"/>
- </table>
-
- </div>
- <div id="history">
-
- <div id="paging_0"> </div>
- <div id="datatable-container_0"></div>
-
+ <xsl:call-template name="file_upload"/>
+ </table>
+ </div>
+ <div id="history">
+ <div id="paging_0"> </div>
+ <div id="datatable-container_0"></div>
+ </div>
+ </xsl:when>
+ </xsl:choose>
<script type="text/javascript">
var property_js = <xsl:value-of select="property_js" />;
+ var base_java_url = <xsl:value-of
select="base_java_url" />;
var datatable = new Array();
var myColumnDefs = new Array();
+ var myButtons = new Array();
<xsl:for-each select="datatable">
datatable[<xsl:value-of select="name"/>] = [
@@ -919,9 +937,11 @@
<xsl:for-each select="myColumnDefs">
myColumnDefs[<xsl:value-of select="name"/>] =
<xsl:value-of select="values"/>
</xsl:for-each>
+ <xsl:for-each select="myButtons">
+ myButtons[<xsl:value-of select="name"/>] =
<xsl:value-of select="values"/>
+ </xsl:for-each>
</script>
- </div>
</div>
</div>
<table>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [8337] property: notifier,
Sigurd Nes <=