[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11257] logisitc: fix edit / delete requirement
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11257] logisitc: fix edit / delete requirement |
Date: |
Sat, 10 Aug 2013 11:40:57 +0000 |
Revision: 11257
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11257
Author: sigurdne
Date: 2013-08-10 11:40:56 +0000 (Sat, 10 Aug 2013)
Log Message:
-----------
logisitc: fix edit / delete requirement
Modified Paths:
--------------
trunk/logistic/inc/class.socommon.inc.php
trunk/logistic/inc/class.sorequirement.inc.php
trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php
trunk/logistic/inc/class.sorequirement_value.inc.php
trunk/logistic/inc/class.uiactivity.inc.php
trunk/logistic/inc/class.uirequirement.inc.php
trunk/logistic/templates/base/requirement/requirement_overview.xsl
trunk/phpgwapi/templates/portico/navbar.inc.php
Modified: trunk/logistic/inc/class.socommon.inc.php
===================================================================
--- trunk/logistic/inc/class.socommon.inc.php 2013-08-09 07:56:16 UTC (rev
11256)
+++ trunk/logistic/inc/class.socommon.inc.php 2013-08-10 11:40:56 UTC (rev
11257)
@@ -33,6 +33,7 @@
protected $like;
protected $join;
protected $left_join;
+ protected $global_lock = false;
public function __construct()
{
Modified: trunk/logistic/inc/class.sorequirement.inc.php
===================================================================
--- trunk/logistic/inc/class.sorequirement.inc.php 2013-08-09 07:56:16 UTC
(rev 11256)
+++ trunk/logistic/inc/class.sorequirement.inc.php 2013-08-10 11:40:56 UTC
(rev 11257)
@@ -94,6 +94,25 @@
}
}
+
+ /**
+ * Called from uirequirement - where transactions are initiated
+ */
+ public function delete($id)
+ {
+ $id = (int) $id;
+
+ if ( !$this->db->get_transaction() )
+ {
+ throw new Exception('sorequirement::delete()
really need to be part of a transaction');
+ return false;
+ }
+
+ $result = $this->db->query("DELETE FROM lg_requirement
WHERE id={$id}", __LINE__,__FILE__);
+ return $result;
+ }
+
+
protected function get_id_field_name()
{
if(!$extended_info)
Modified: trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php
===================================================================
--- trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php
2013-08-09 07:56:16 UTC (rev 11256)
+++ trunk/logistic/inc/class.sorequirement_resource_allocation.inc.php
2013-08-10 11:40:56 UTC (rev 11257)
@@ -364,10 +364,17 @@
public function delete_resources($requirement_id)
{
- echo "i delete_resources: " . $requirement_id;
-
- $this->db->transaction_begin();
+// echo "i delete_resources: " . $requirement_id;
+ if ( $this->db->get_transaction() )
+ {
+ $this->global_lock = true;
+ }
+ else
+ {
+ $this->db->transaction_begin();
+ }
+
$requirement_id = (int) $requirement_id;
$this->db->query("SELECT id FROM
lg_requirement_resource_allocation WHERE requirement_id =
$requirement_id",__LINE__,__FILE__);
$ids = array();
@@ -380,9 +387,16 @@
{
$this->db->query("DELETE FROM lg_calendar WHERE
allocation_id = IN ( " . explode(',', $id) . ')',__LINE__,__FILE__);
}
- $this->db->query("DELETE FROM
lg_requirement_resource_allocation WHERE requirement_id =
$requirement_id",__LINE__,__FILE__);
- return !!$this->db->transaction_commit();
+ $ret = $this->db->query("DELETE FROM
lg_requirement_resource_allocation WHERE requirement_id =
$requirement_id",__LINE__,__FILE__);
+
+
+ if ( !$this->global_lock )
+ {
+ $ret = $this->db->transaction_commit();
+ }
+
+ return $ret;
}
public static function get_instance()
Modified: trunk/logistic/inc/class.sorequirement_value.inc.php
===================================================================
--- trunk/logistic/inc/class.sorequirement_value.inc.php 2013-08-09
07:56:16 UTC (rev 11256)
+++ trunk/logistic/inc/class.sorequirement_value.inc.php 2013-08-10
11:40:56 UTC (rev 11257)
@@ -203,4 +203,4 @@
}
return self::$so;
}
- }
\ No newline at end of file
+ }
Modified: trunk/logistic/inc/class.uiactivity.inc.php
===================================================================
--- trunk/logistic/inc/class.uiactivity.inc.php 2013-08-09 07:56:16 UTC (rev
11256)
+++ trunk/logistic/inc/class.uiactivity.inc.php 2013-08-10 11:40:56 UTC (rev
11257)
@@ -45,6 +45,12 @@
private $so_requirement;
private $so_resource_allocation;
+ private $read;
+ private $add;
+ private $edit;
+ private $delete;
+ private $manage;
+
public $public_functions = array(
'query' => true,
'add' => true,
@@ -66,6 +72,13 @@
$this->so_resource_allocation =
CreateObject('logistic.sorequirement_resource_allocation');
$GLOBALS['phpgw_info']['flags']['menu_selection'] =
"logistic::project::activity";
+
+ $this->read =
$GLOBALS['phpgw']->acl->check('.activity', PHPGW_ACL_READ, 'logistic');//1
+ $this->add =
$GLOBALS['phpgw']->acl->check('.activity', PHPGW_ACL_ADD, 'logistic');//2
+ $this->edit =
$GLOBALS['phpgw']->acl->check('.activity', PHPGW_ACL_EDIT, 'logistic');//4
+ $this->delete =
$GLOBALS['phpgw']->acl->check('.activity', PHPGW_ACL_DELETE, 'logistic');//8
+ $this->manage =
$GLOBALS['phpgw']->acl->check('.activity', 16, 'logistic');//16
+
}
public function index()
@@ -679,20 +692,40 @@
'label' => lang('Status
requirement'),
'sortable' => false,
),
- array(
- 'key' => 'alloc_link',
- 'label' =>
lang('Allocate resources'),
- 'sortable' => false,
- ),
- array(
- 'key' =>
'edit_requirement_link',
- 'label' => lang('Edit
requirement'),
- 'sortable' => false,
- )
)
),
);
+
+ if($this->add)
+ {
+ $data['datatable']['field'][] = array
+ (
+ 'key' => 'alloc_link',
+ 'label' => lang('Allocate
resources'),
+ 'sortable' => false,
+ );
+ }
+ if($this->add)
+ {
+ $data['datatable']['field'][] = array
+ (
+ 'key' =>
'edit_requirement_link',
+ 'label' => lang('Edit
requirement'),
+ 'sortable' => false,
+ );
+ }
+
+ if($this->delete)
+ {
+ $data['datatable']['field'][] = array
+ (
+ 'key' =>
'delete_requirement_link',
+ 'label' => lang('Delete
requirement'),
+ 'sortable' => false,
+ );
+ }
+
phpgwapi_yui::load_widget('datatable');
phpgwapi_yui::load_widget('paginator');
phpgwapi_jquery::load_widget('core');
Modified: trunk/logistic/inc/class.uirequirement.inc.php
===================================================================
--- trunk/logistic/inc/class.uirequirement.inc.php 2013-08-09 07:56:16 UTC
(rev 11256)
+++ trunk/logistic/inc/class.uirequirement.inc.php 2013-08-10 11:40:56 UTC
(rev 11257)
@@ -51,11 +51,18 @@
private $so_resource_allocation;
private $nonavbar;
+ private $read;
+ private $add;
+ private $edit;
+ private $delete;
+ private $manage;
+
public $public_functions = array(
'query'
=> true,
'index'
=> true,
'add'
=> true,
'edit'
=> true,
+ 'delete'
=> true,
'view'
=> true,
'save'
=> true,
'add_requirement_values' => true,
@@ -89,6 +96,14 @@
$GLOBALS['phpgw_info']['flags']['nonavbar'] = true;
$GLOBALS['phpgw_info']['flags']['noheader_xsl'] = true;
$GLOBALS['phpgw_info']['flags']['nofooter']
= true;
+
+
+ $this->read =
$GLOBALS['phpgw']->acl->check('.activity', PHPGW_ACL_READ, 'logistic');//1
+ $this->add =
$GLOBALS['phpgw']->acl->check('.activity', PHPGW_ACL_ADD, 'logistic');//2
+ $this->edit =
$GLOBALS['phpgw']->acl->check('.activity', PHPGW_ACL_EDIT, 'logistic');//4
+ $this->delete =
$GLOBALS['phpgw']->acl->check('.activity', PHPGW_ACL_DELETE, 'logistic');//8
+ $this->manage =
$GLOBALS['phpgw']->acl->check('.activity', 16, 'logistic');//16
+
}
@@ -240,6 +255,9 @@
//$href = self::link(array('menuaction' =>
'logistic.uirequirement.edit', 'id' => $entry['id']));
$href =
"javascript:load_requirement_edit_id({$entry['id']});";
$entry['edit_requirement_link'] = "<a
class=\"btn-sm alloc\" href=\"{$href}\">Endre behov</a>";
+
+ $href =
"javascript:load_requirement_delete_id({$entry['id']});";
+ $entry['delete_requirement_link'] = "<a
class=\"btn-sm alloc\" href=\"{$href}\">Slett behov</a>";
}
// ... add result data
@@ -525,6 +543,12 @@
$GLOBALS['phpgw_info']['flags']['nofooter']
= true;
}
+ if(!$this->read)
+ {
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'logistic.uirequirement.view', 'id' => $requirement_id,
'nonavbar' => $nonavbar));
+ return false; // in case redirect fail;
+ }
+
if ($requirement_id)
{
$requirement =
$this->so->get_single($requirement_id);
@@ -569,6 +593,42 @@
$this->edit($requirement);
}
}
+
+ public function delete()
+ {
+ if(!$this->delete)
+ {
+ return false;
+ }
+
+ $requirement_id = phpgw::get_var('id', 'int');
+ $GLOBALS['phpgw']->db->transaction_begin();
+ try
+ {
+ $this->so_requirement_value->delete_values(
$requirement_id );
+
$this->so_resource_allocation->delete_resources( $requirement_id );
+ $this->so->delete( $requirement_id );
+ }
+ catch (Exception $e)
+ {
+ if($e)
+ {
+
$GLOBALS['phpgw']->db->transaction_abort();
+
+ $GLOBALS['phpgw']->log->error(array(
+ 'text' =>
'uirequirement::delete() : error when trying to delete requirement: %1',
+ 'p1' => $e->getMessage(),
+ 'p2' => '',
+ 'line' => __LINE__,
+ 'file' => __FILE__
+ ));
+
+ }
+
+ return $e->getMessage();
+ }
+ $GLOBALS['phpgw']->db->transaction_commit();
+ }
public function add_requirement_values()
{
Modified: trunk/logistic/templates/base/requirement/requirement_overview.xsl
===================================================================
--- trunk/logistic/templates/base/requirement/requirement_overview.xsl
2013-08-09 07:56:16 UTC (rev 11256)
+++ trunk/logistic/templates/base/requirement/requirement_overview.xsl
2013-08-10 11:40:56 UTC (rev 11257)
@@ -58,6 +58,25 @@
TINY.box.show({iframe:requestUrl,
boxid:'frameless',width:750,height:450,fixed:false,maskid:'darkmask',maskopacity:40,
mask:true, animate:true, close: true,closejs:function(){closeJS_local()}});
}
+ function load_requirement_delete_id( id ){
+ confirm_msg = 'Slette behov?';
+ if(confirm(confirm_msg))
+ {
+ var oArgs = {menuaction:
'logistic.uirequirement.delete', id:id};
+ var requestUrl = phpGWLink('index.php', oArgs, true);
+
+ var callback = { success: function(o){
+ // var
message_delete = o.responseText.toString().replace("\"","").replace("\"","");
+ var
reqUrl = '<xsl:value-of select="//datatable/source"/>';
+
YAHOO.portico.inlineTableHelper('requirement-container', reqUrl,
YAHOO.portico.columnDefs);
+ },
+ failure:
function(o){window.alert('failed')},
+ timeout: 10000
+ };
+ var request = YAHOO.util.Connect.asyncRequest('POST',
requestUrl, callback);
+ }
+ }
+
function closeJS_local()
{
var reqUrl = '<xsl:value-of select="//datatable/source"/>';
Modified: trunk/phpgwapi/templates/portico/navbar.inc.php
===================================================================
--- trunk/phpgwapi/templates/portico/navbar.inc.php 2013-08-09 07:56:16 UTC
(rev 11256)
+++ trunk/phpgwapi/templates/portico/navbar.inc.php 2013-08-10 11:40:56 UTC
(rev 11257)
@@ -100,8 +100,7 @@
$navigation = array();
if(
!isset($GLOBALS['phpgw_info']['user']['preferences']['property']['nonavbar'])
|| $GLOBALS['phpgw_info']['user']['preferences']['property']['nonavbar'] !=
'yes' )
{
-//moved..
-// prepare_navbar($navbar);
+ prepare_navbar($navbar);
}
else
{
@@ -161,7 +160,7 @@
}
else
{
- prepare_navbar($navbar);
+// prepare_navbar($navbar);
$navigation = execMethod('phpgwapi.menu.get',
'navigation');
$treemenu = '';
foreach($navbar as $app => $app_data)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11257] logisitc: fix edit / delete requirement,
Sigurd Nes <=