[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [16168] More on rental
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [16168] More on rental |
Date: |
Wed, 18 Jan 2017 15:11:15 -0500 (EST) |
Revision: 16168
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16168
Author: sigurdne
Date: 2017-01-18 15:11:15 -0500 (Wed, 18 Jan 2017)
Log Message:
-----------
More on rental
Modified Paths:
--------------
trunk/rental/inc/class.boemail_out.inc.php
trunk/rental/inc/class.soemail_out.inc.php
trunk/rental/inc/class.soparty.inc.php
trunk/rental/inc/class.uiemail_out.inc.php
trunk/rental/inc/model/class.email_out.inc.php
trunk/rental/js/rental/email_out.edit.js
trunk/rental/setup/phpgw_no.lang
trunk/rental/templates/base/email_out.xsl
Added Paths:
-----------
trunk/rental/inc/class.uilookup.inc.php
Modified: trunk/rental/inc/class.boemail_out.inc.php
===================================================================
--- trunk/rental/inc/class.boemail_out.inc.php 2017-01-16 22:11:10 UTC (rev
16167)
+++ trunk/rental/inc/class.boemail_out.inc.php 2017-01-18 20:11:15 UTC (rev
16168)
@@ -112,9 +112,51 @@
return
rental_soemail_out::get_instance()->set_candidates($id, $ids);
}
+ function delete_recipients($id, $ids)
+ {
+ return
rental_soemail_out::get_instance()->delete_recipients($id, $ids);
+ }
+
public function get_recipients( $email_out_id )
{
return
rental_soemail_out::get_instance()->get_recipients($email_out_id);
}
+ public function send_email( $id, $ids = array() )
+ {
+ $email_out = $this->read_single($id);
+ $subject = $email_out->subject;
+ $content = $email_out->content;
+ phpgw::import_class('rental.soparty');
+ $email_validator =
CreateObject('phpgwapi.EmailAddressValidator');
+ if (!is_object($GLOBALS['phpgw']->send))
+ {
+ $GLOBALS['phpgw']->send =
CreateObject('phpgwapi.send');
+ }
+
+ $cc ='';
+ $bcc = '';
+ $from_email = '';
+ $from_name = '';
+ foreach ($ids as $party_id)
+ {
+ $party =
rental_soparty::get_instance()->get_single($party_id);
+ $to_email = $party->get_email();
+ if
(!$email_validator->check_email_address($to_email) )
+ {
+
rental_soemail_out::get_instance()->set_status($id, $party_id,
rental_email_out::STATUS_ERROR);
+ continue;
+ }
+
+ try
+ {
+ $rcpt =
$GLOBALS['phpgw']->send->msg('email', $to_email, $subject,
stripslashes($content), '', $cc, $bcc, $from_email, $from_name, 'html');
+
rental_soemail_out::get_instance()->set_status($id, $party_id,
rental_email_out::STATUS_SENT);
+ }
+ catch (Exception $exc)
+ {
+
rental_soemail_out::get_instance()->set_status($id, $party_id,
rental_email_out::STATUS_ERROR);
+ }
+ }
+ }
}
\ No newline at end of file
Modified: trunk/rental/inc/class.soemail_out.inc.php
===================================================================
--- trunk/rental/inc/class.soemail_out.inc.php 2017-01-16 22:11:10 UTC (rev
16167)
+++ trunk/rental/inc/class.soemail_out.inc.php 2017-01-18 20:11:15 UTC (rev
16168)
@@ -67,7 +67,6 @@
protected function update( $object )
{
$this->db->transaction_begin();
- // $status_text = rental_email_out::get_status_list();
$dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
$lang_active = lang('active');
$lang_inactive = lang('inactive');
@@ -80,19 +79,6 @@
if (!empty($params['history']) && ($new_value
!= $old_value))
{
$label = !empty($params['label']) ?
lang($params['label']) : $field;
- switch ($field)
- {
- case 'status':
- $old_value =
$status_text[$old_value];
- $new_value =
$status_text[$new_value];
- break;
- case 'active':
- $old_value = $old_value
? $lang_active : $lang_inactive;
- $new_value = $new_value
? $lang_active : $lang_inactive;
- break;
- default:
- break;
- }
$value_set = array
(
'email_out_id' =>
$object->get_id(),
@@ -159,6 +145,9 @@
public function get_recipients( $email_out_id )
{
+
+ $status_list = rental_email_out::get_status_list();
+
$email_out_id = (int) $email_out_id;
$values = array();
@@ -192,7 +181,7 @@
'id' => $this->db->f('id'),
'name' => $name,
'email' => $this->db->f('email',true),
- 'status' =>
$this->db->f('status')
+ 'status' =>
$status_list[$this->db->f('status')]
);
}
return $values;
@@ -201,7 +190,7 @@
function set_candidates($id, $ids)
{
$recipients = $this->get_recipients($id);
-
+
$check_duplicates = array();
foreach ($recipients as $entry)
{
@@ -237,4 +226,24 @@
return $GLOBALS['phpgw']->db->insert($sql,
$valueset, __LINE__, __FILE__);
}
}
+
+ function delete_recipients($id, $ids = array())
+ {
+ $id = (int) $id;
+ if($ids)
+ {
+ $parties = implode(',', $ids);
+ $sql = "DELETE FROM rental_email_out_party
WHERE email_out_id = {$id} AND party_id IN ({$parties})";
+ return $this->db->query($sql,__LINE__,__FILE__);
+ }
+ }
+
+ function set_status($id, $party_id, $status)
+ {
+ $id = (int) $id;
+ $party_id = (int) $party_id;
+ $status = (int) $status;
+ $sql = "UPDATE rental_email_out_party SET status =
{$status} WHERE email_out_id = {$id} AND party_id = {$party_id}";
+ return $this->db->query($sql,__LINE__,__FILE__);
+ }
}
\ No newline at end of file
Modified: trunk/rental/inc/class.soparty.inc.php
===================================================================
--- trunk/rental/inc/class.soparty.inc.php 2017-01-16 22:11:10 UTC (rev
16167)
+++ trunk/rental/inc/class.soparty.inc.php 2017-01-18 20:11:15 UTC (rev
16168)
@@ -343,7 +343,7 @@
$id = intval($party->get_id());
- $location_id =
$this->marshal($party->get_location_id(), 'int');
+ $location_id = $party->get_location_id();
if ($location_id)
{
@@ -376,7 +376,7 @@
'comment = ' .
$this->marshal($party->get_comment(), 'string'),
'org_enhet_id = ' .
$this->marshal($party->get_org_enhet_id(), 'int'),
'unit_leader = ' .
$this->marshal($party->get_unit_leader(), 'string'),
- 'location_id = ' . $location_id,
+ 'location_id = ' .
$this->marshal($party->get_location_id(), 'int'),
'result_unit_number = ' . $result_unit_number
);
Modified: trunk/rental/inc/class.uiemail_out.inc.php
===================================================================
--- trunk/rental/inc/class.uiemail_out.inc.php 2017-01-16 22:11:10 UTC (rev
16167)
+++ trunk/rental/inc/class.uiemail_out.inc.php 2017-01-18 20:11:15 UTC (rev
16168)
@@ -44,7 +44,10 @@
'get' => true,
'get_candidates' => true,
'set_candidates' => true,
- 'get_recipients'=> true
+ 'delete_recipients' => true,
+ 'get_recipients'=> true,
+ 'set_email' => true,
+ 'send_email' => true
);
protected
@@ -197,7 +200,7 @@
$parties_def = array(
array('key' => 'id', 'label' => 'ID',
'sortable' => true, 'resizeable' => true,'formatter' =>
'JqueryPortico.formatLink'),
array('key' => 'name', 'label' => lang('name'),
'sortable' => true, 'resizeable' => true),
- array('key' => 'email', 'label' =>
lang('email'), 'sortable' => true, 'resizeable' => true),
+ array('key' => 'email', 'label' =>
lang('email'), 'sortable' => true, 'resizeable' => true, 'editor' =>true),
);
$tabletools = array
@@ -244,7 +247,8 @@
'tabletools' =>
array_merge($tabletools,$tabletools_candidate),
'config' => array(
array('disableFilter' => true),
- array('disablePagination' => true)
+ array('disablePagination' => true),
+ array('editor_action' =>
self::link(array('menuaction' => 'rental.uiemail_out.set_email')))
)
);
@@ -271,11 +275,35 @@
var aData = selected[n];
ids.push(aData['id']);
}
-
onActionsClick_recipient('delete', ids);
+
onActionsClick_recipient('delete_recipients', ids);
"
);
+ $tabletools_recipient[] = array
+ (
+ 'my_name' => 'send_email',
+ 'text' => lang('send email'),
+ 'type' => 'custom',
+ 'custom_code' => "
+ var api = oTable2.api();
+ var selected = api.rows( {
selected: true } ).data();
+ var numSelected =
selected.length;
+ if (numSelected ==0){
+ alert('None selected');
+ return false;
+ }
+ var ids = [];
+ for ( var n = 0; n <
selected.length; ++n )
+ {
+ var aData = selected[n];
+ ids.push(aData['id']);
+ }
+
onActionsClick_recipient('send_email', ids);
+ "
+ );
+
+
$parties_def[] = array('key' => 'status', 'label' =>
lang('status'), 'sortable' => true, 'resizeable' => true);
@@ -289,7 +317,8 @@
'tabletools' =>
array_merge($tabletools,$tabletools_recipient),
'config' => array(
array('disableFilter' => true),
- array('disablePagination' => true)
+ array('disablePagination' => true),
+ array('editor_action' =>
self::link(array('menuaction' => 'rental.uiemail_out.set_email')))
)
);
@@ -360,13 +389,32 @@
public function set_candidates()
{
+ if (empty($this->permissions[PHPGW_ACL_EDIT]))
+ {
+ phpgw::no_access();
+ }
$id = phpgw::get_var('id', 'int');
$ids = (array) phpgw::get_var('ids', 'int');
$ret = $this->bo->set_candidates($id, $ids);
}
+ public function delete_recipients()
+ {
+ if (empty($this->permissions[PHPGW_ACL_EDIT]))
+ {
+ phpgw::no_access();
+ }
+ $id = phpgw::get_var('id', 'int');
+ $ids = (array) phpgw::get_var('ids', 'int');
+ $ret = $this->bo->delete_recipients($id, $ids);
+ }
+
public function get_recipients()
{
+ if (empty($this->permissions[PHPGW_ACL_EDIT]))
+ {
+ phpgw::no_access();
+ }
$id = phpgw::get_var('id', 'int');
$values = $this->bo->get_recipients($id);
array_walk($values, array($this, "_add_links"),
"rental.uiparty.edit");
@@ -373,4 +421,53 @@
return $this->jquery_results(array('results' =>
$values));
}
+
+ public function send_email( )
+ {
+ if (empty($this->permissions[PHPGW_ACL_EDIT]))
+ {
+ phpgw::no_access();
+ }
+ $id = phpgw::get_var('id', 'int');
+ $ids = (array) phpgw::get_var('ids', 'int');
+ $ret = $this->bo->send_email($id, $ids);
+ }
+
+ public function set_email( )
+ {
+ if (empty($this->permissions[PHPGW_ACL_EDIT]))
+ {
+ phpgw::no_access();
+ }
+
+ phpgw::import_class('rental.soparty');
+
+ $field_name = phpgw::get_var('field_name');
+ $email = phpgw::get_var('value');
+ $id = phpgw::get_var('id');
+ $email_validator =
CreateObject('phpgwapi.EmailAddressValidator');
+ $message = array();
+ if (!$email_validator->check_email_address($email) )
+ {
+ $message['error'][] = array('msg' => lang('data
has not validated'));
+ return $message;
+ }
+
+ $party =
rental_soparty::get_instance()->get_single($id);
+ $party->set_field('email', $email);
+ $result = rental_soparty::get_instance()->store($party);
+
+ $message = array();
+ if ($result)
+ {
+ $message['message'][] = array('msg' =>
lang('data has been saved'));
+ }
+ else
+ {
+ $message['error'][] = array('msg' => lang('data
has not been saved'));
+ }
+
+ return $message;
+
+ }
}
\ No newline at end of file
Added: trunk/rental/inc/class.uilookup.inc.php
===================================================================
--- trunk/rental/inc/class.uilookup.inc.php (rev 0)
+++ trunk/rental/inc/class.uilookup.inc.php 2017-01-18 20:11:15 UTC (rev
16168)
@@ -0,0 +1,165 @@
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software
Foundation, Inc. http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package property
+ * @subpackage core
+ * @version $Id: class.uilookup.inc.php 15854 2016-10-19 11:39:12Z
sigurdne $
+ */
+ /**
+ * Description
+ * @package rental
+ */
+ phpgw::import_class('phpgwapi.uicommon_jquery');
+ phpgw::import_class('phpgwapi.jquery');
+
+ class rental_uilookup extends phpgwapi_uicommon_jquery
+ {
+
+ var $grants;
+ var $cat_id;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $filter;
+ var $part_of_town_id;
+ var $district_id;
+ var $sub;
+ var $currentapp;
+ var $public_functions = array
+ (
+ 'phpgw_user' => true,
+ 'external_project' => true,
+ 'ecodimb' => true,
+ 'order_template' => true,
+ 'email_template' => true,
+ 'custom' => true
+ );
+
+ function __construct()
+ {
+ parent::__construct();
+
+ $GLOBALS['phpgw_info']['flags']['noframework'] = true;
+ $GLOBALS['phpgw_info']['flags']['headonly'] = true;
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
+ }
+
+ public function query()
+ {
+
+ }
+
+
+ function email_template()
+ {
+ if (phpgw::get_var('phpgw_return_as') == 'json')
+ {
+ $search = phpgw::get_var('search');
+ $order = phpgw::get_var('order');
+ $draw = phpgw::get_var('draw', 'int');
+ $columns = phpgw::get_var('columns');
+
+ $params = array(
+ 'start' => phpgw::get_var('start',
'int', 'REQUEST', 0),
+ 'results' => phpgw::get_var('length',
'int', 'REQUEST', 0),
+ 'query' => $search['value'],
+ 'order' =>
$columns[$order[0]['column']]['data'],
+ 'sort' => $order[0]['dir'],
+ 'dir' => $order[0]['dir'],
+ 'allrows' => phpgw::get_var('length',
'int') == -1,
+ 'filter' => ''
+ );
+
+ $values = array();
+ $bo = CreateObject('rental.bogeneric');
+ $bo->get_location_info('email_template');
+ $values = $bo->read($params);
+
+ $result_data = array
+ (
+ 'results' => $values,
+ 'total_records' => $bo->total_records,
+ 'draw' => $draw
+ );
+ return $this->jquery_results($result_data);
+ }
+
+ $action = 'var temp =
parent.document.getElementById("content").value;' . "\r\n";
+ $action .= 'if(temp){temp = temp + "\n";}' . "\r\n";
+ $action .=
'parent.document.getElementById("content").value = temp + aData["content"];' .
"\r\n";
+ $action .=
'parent.JqueryPortico.onPopupClose("close");' . "\r";
+
+ $data = array(
+ 'left_click_action' => $action,
+ 'datatable_name' => '',
+ 'form' => array(
+ 'toolbar' => array(
+ 'item' => array()
+ )
+ ),
+ 'datatable' => array(
+ 'source' => self::link(array(
+ 'menuaction' =>
'rental.uilookup.email_template',
+ 'query' => $this->query,
+ 'filter' => $this->filter,
+ 'cat_id' => $this->cat_id,
+ 'type' => 'email_template',
+ 'phpgw_return_as' => 'json'
+ )),
+ 'allrows' => true,
+ 'editor_action' => '',
+ 'field' => array()
+ )
+ );
+
+ $uicols = array(
+ 'input_type' => array('text', 'text', 'text'),
+ 'name' => array('id', 'name', 'content'),
+ 'formatter' => array('', '', ''),
+ 'descr' => array(lang('ID'), lang('name'),
lang('content'))
+ );
+
+ $count_uicols_name = count($uicols['name']);
+
+ for ($k = 0; $k < $count_uicols_name; $k++)
+ {
+ $params = array(
+ 'key' => $uicols['name'][$k],
+ 'label' => $uicols['descr'][$k],
+ 'sortable' => $uicols['sortable'][$k],
+ 'hidden' => false
+ );
+
+ array_push($data['datatable']['field'],
$params);
+ }
+
+ $appname = lang('template');
+ $function_msg = lang('list email template');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('property') . ' - ' . $appname . ': ' . $function_msg;
+
+ self::render_template_xsl('datatable_jquery', $data);
+ }
+ }
\ No newline at end of file
Modified: trunk/rental/inc/model/class.email_out.inc.php
===================================================================
--- trunk/rental/inc/model/class.email_out.inc.php 2017-01-16 22:11:10 UTC
(rev 16167)
+++ trunk/rental/inc/model/class.email_out.inc.php 2017-01-18 20:11:15 UTC
(rev 16168)
@@ -34,9 +34,9 @@
class rental_email_out extends phpgwapi_model
{
- const STATUS_PENDING = 1;
- const STATUS_SENT = 2;
- const STATUS_ERROR = 3;
+ const STATUS_PENDING = 0;
+ const STATUS_SENT = 1;
+ const STATUS_ERROR = 2;
const acl_location = '.email_out';
protected
@@ -71,7 +71,7 @@
public static function get_status_list()
{
return array(
- self::STATUS_PENDING => lang('pending'),
+ self::STATUS_PENDING => lang('planned'),
self::STATUS_SENT => lang('sent'),
self::STATUS_ERROR => lang('error')
);
@@ -111,6 +111,7 @@
'type' => 'string',
'label' => 'description',
'sortable' => false,
+// 'history' => true
),
'modified' => array('action'=> PHPGW_ACL_READ |
PHPGW_ACL_EDIT,
'type' => 'date',
Modified: trunk/rental/js/rental/email_out.edit.js
===================================================================
--- trunk/rental/js/rental/email_out.edit.js 2017-01-16 22:11:10 UTC (rev
16167)
+++ trunk/rental/js/rental/email_out.edit.js 2017-01-18 20:11:15 UTC (rev
16168)
@@ -85,3 +85,41 @@
});
}
+this.onActionsClick_recipient = function (type, ids)
+{
+ oArgs = {
+ menuaction: 'rental.uiemail_out.' + type,
+ id: $('#id').val()
+ };
+
+ var requestUrl = phpGWLink('index.php', oArgs, true);
+
+ $.ajax({
+ type: 'POST',
+ dataType: 'json',
+ url: requestUrl,
+ data: {ids: ids, type: type},
+ success: function (data)
+ {
+ if (data != null)
+ {
+
+ }
+ oArgs = {
+ menuaction: 'rental.uiemail_out.get_recipients',
+ id: $('#id').val()
+ };
+
+ var requestUrl = phpGWLink('index.php', oArgs, true);
+ JqueryPortico.updateinlineTableHelper(oTable2,
requestUrl);
+ }
+ });
+
+}
+
+function template_lookup()
+{
+ var oArgs = {menuaction: 'rental.uilookup.email_template'};
+ var strURL = phpGWLink('index.php', oArgs);
+ TINY.box.show({iframe: strURL, boxid: "frameless", width: 750, height:
450, fixed: false, maskid: "darkmask", maskopacity: 40, mask: true, animate:
true, close: true});
+}
Modified: trunk/rental/setup/phpgw_no.lang
===================================================================
--- trunk/rental/setup/phpgw_no.lang 2017-01-16 22:11:10 UTC (rev 16167)
+++ trunk/rental/setup/phpgw_no.lang 2017-01-18 20:11:15 UTC (rev 16168)
@@ -655,4 +655,13 @@
note rental no Merknad
report is already recorded for %1 rental no Rapport finnes allerede
for %1
email out rental no Epost ut
-recipient rental no Adressat
\ No newline at end of file
+recipient rental no Mottaker
+recipients rental no Mottakere
+candidates rental no Kandidater
+send email rental no Send epost
+remark rental no Merknad
+subject rental no Overskrift
+content rental no Innhold
+select all rental no Velg alle
+planned rental no Planlagt
+email template rental no Standardtekster
\ No newline at end of file
Modified: trunk/rental/templates/base/email_out.xsl
===================================================================
--- trunk/rental/templates/base/email_out.xsl 2017-01-16 22:11:10 UTC (rev
16167)
+++ trunk/rental/templates/base/email_out.xsl 2017-01-18 20:11:15 UTC (rev
16168)
@@ -78,9 +78,14 @@
</div>
<div class="pure-control-group">
<label>
- <xsl:value-of
select="php:function('lang', 'content')"/>
+ <a
href="javascript:template_lookup();">
+
<xsl:attribute name="title">
+
<xsl:value-of select="php:function('lang', 'content')"/>
+
</xsl:attribute>
+
<xsl:value-of select="php:function('lang', 'content')"/>
+ </a>
</label>
- <textarea cols="47"
rows="7" name="content">
+ <textarea cols="47"
rows="7" id="content" name="content">
<xsl:attribute
name="data-validation">
<xsl:text>required</xsl:text>
</xsl:attribute>
@@ -87,7 +92,7 @@
<xsl:value-of
select="email_out/content"/>
</textarea>
</div>
- <div class="pure-control-group">
+ <!--div
class="pure-control-group">
<label>
<xsl:value-of
select="php:function('lang', 'details')"/>
</label>
@@ -104,7 +109,7 @@
</xsl:if>
</xsl:for-each>
</div>
- </div>
+ </div-->
</fieldset>
</div>
<div id="recipient">
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [16168] More on rental,
sigurdne <=