[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11159] property: condition survey delete
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11159] property: condition survey delete |
Date: |
Fri, 07 Jun 2013 11:53:29 +0000 |
Revision: 11159
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11159
Author: sigurdne
Date: 2013-06-07 11:53:29 +0000 (Fri, 07 Jun 2013)
Log Message:
-----------
property: condition survey delete
Modified Paths:
--------------
trunk/property/inc/class.socondition_survey.inc.php
trunk/property/inc/class.uicondition_survey.inc.php
Modified: trunk/property/inc/class.socondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.socondition_survey.inc.php 2013-06-07 11:52:22 UTC
(rev 11158)
+++ trunk/property/inc/class.socondition_survey.inc.php 2013-06-07 11:53:29 UTC
(rev 11159)
@@ -553,13 +553,34 @@
public function delete($id)
{
$id = (int) $id;
+ $interlink = CreateObject('property.interlink');
$this->_db->transaction_begin();
+
+ $requests = array();
+ $this->_db->query("SELECT id AS request_id FROM
fm_request WHERE condition_survey_id={$id}",__LINE__,__FILE__);
+ while ($this->_db->next_record())
+ {
+ $requests[] = $this->_db->f('request_id');
+ }
try
{
$this->_db->Exception_On_Error = true;
- $this->_db->query("DELETE FROM
fm_condition_survey WHERE id={$id}",__LINE__,__FILE__);
- $this->_db->query("DELETE FROM fm_request WHERE
condition_survey_id={$id}",__LINE__,__FILE__);
+ if($requests)
+ {
+ $this->_db->query('DELETE FROM
fm_request_planning WHERE request_id IN (' . implode(',', $requests) .
')',__LINE__,__FILE__);
+ $this->_db->query('DELETE FROM
fm_request_consume WHERE request_id IN (' . implode(',', $requests) .
')',__LINE__,__FILE__);
+ $this->_db->query('DELETE FROM
fm_request_condition WHERE request_id IN (' . implode(',', $requests) .
')',__LINE__,__FILE__);
+ $this->_db->query('DELETE FROM
fm_request_history WHERE history_record_id IN (' . implode(',', $requests) .
')',__LINE__,__FILE__);
+ }
+ $this->_db->query("DELETE FROM fm_request WHERE
condition_survey_id = {$id}",__LINE__,__FILE__);
+ $this->_db->query("DELETE FROM
fm_condition_survey WHERE id = {$id}",__LINE__,__FILE__);
+
+ foreach ($requests as $request_id)
+ {
+
$interlink->delete_at_target('property', '.project.request', $request_id,
$this->_db);
+ }
+
$this->_db->Exception_On_Error = false;
}
@@ -567,6 +588,7 @@
{
if ( $e )
{
+ $this->_db->transaction_abort();
throw $e;
}
}
Modified: trunk/property/inc/class.uicondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.uicondition_survey.inc.php 2013-06-07 11:52:22 UTC
(rev 11158)
+++ trunk/property/inc/class.uicondition_survey.inc.php 2013-06-07 11:53:29 UTC
(rev 11159)
@@ -43,6 +43,7 @@
'add' => true,
'edit' => true,
'save' => true,
+ 'delete' => true,
'get_vendors' => true,
'get_users' => true,
'edit_survey_title' => true,
@@ -219,6 +220,17 @@
$data['datatable']['actions'][] = array
(
+ 'my_name' =>
'view_survey',
+ 'text' =>
lang('view'),
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array
+ (
+ 'menuaction' =>
'property.uicondition_survey.view'
+ )),
+ 'parameters' =>
json_encode($parameters)
+ );
+
+ $data['datatable']['actions'][] = array
+ (
'my_name' =>
'edit_survey',
'text' =>
lang('edit'),
'action' =>
$GLOBALS['phpgw']->link('/index.php',array
@@ -239,6 +251,22 @@
'parameters' =>
json_encode($parameters)
);
+
+ if($GLOBALS['phpgw']->acl->check('.admin',
PHPGW_ACL_DELETE, 'property'))
+ {
+ $data['datatable']['actions'][] = array
+ (
+ 'my_name' =>
'delete_survey',
+ 'text' =>
lang('delete'),
+ 'confirm_msg' => lang('do you
really want to delete this entry') . '?',
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array
+ (
+ 'menuaction' =>
'property.uicondition_survey.delete'
+ )),
+ 'parameters' =>
json_encode($parameters)
+ );
+ }
+
self::render_template_xsl('datatable_common', $data);
}
@@ -1197,6 +1225,36 @@
}
}
+ /**
+ * Delete survey and all related info
+ *
+ * @param int $id id of entity
+ *
+ * @return string text to appear in ui as receipt on action
+ */
+
+ public function delete()
+ {
+ if(!$GLOBALS['phpgw']->acl->check('.admin',
PHPGW_ACL_DELETE, 'property'))
+ {
+ return 'No access';
+ }
+ $id = phpgw::get_var('id', 'int', 'GET');
+
+ try
+ {
+ $this->bo->delete($id);
+ }
+ catch(Exception $e)
+ {
+ if ( $e )
+ {
+ return $e->getMessage();
+ }
+ }
+ return 'Deleted';
+ }
+
/*
* Overrides with incoming data from POST
*/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11159] property: condition survey delete,
Sigurd Nes <=