mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
When changing a resource with accessories to an accessory, change existing accessories to resources, and give a message to the user
This commit is contained in:
parent
8e97c326e0
commit
442c3d605e
@ -359,6 +359,18 @@ class resources_bo
|
|||||||
if($resource['accessory_of'] != $old['accessory_of'])
|
if($resource['accessory_of'] != $old['accessory_of'])
|
||||||
{
|
{
|
||||||
egw_link::unlink(0,'resources',$resource['res_id'],'','resources',$old['accessory_of']);
|
egw_link::unlink(0,'resources',$resource['res_id'],'','resources',$old['accessory_of']);
|
||||||
|
|
||||||
|
// Check for resource changing to accessory - move its accessories to resource
|
||||||
|
if($old['accessory_of'] == -1 && $accessories = $this->get_acc_list($resource['res_id']))
|
||||||
|
{
|
||||||
|
foreach($accessories as $accessory => $name)
|
||||||
|
{
|
||||||
|
egw_link::unlink(0,'resources',$accessory,'','resources',$resource['res_id']);
|
||||||
|
$acc = $this->read($accessory);
|
||||||
|
$acc['accessory_of'] = -1;
|
||||||
|
$this->so->save($acc);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if($resource['accessory_of'] != -1)
|
if($resource['accessory_of'] != -1)
|
||||||
{
|
{
|
||||||
|
@ -104,7 +104,7 @@ class resources_ui
|
|||||||
$msg = $content;
|
$msg = $content;
|
||||||
}
|
}
|
||||||
$content = array();
|
$content = array();
|
||||||
$content['msg'] = $msg;
|
$content['msg'] = $msg ? $msg : $_GET['msg'];
|
||||||
|
|
||||||
$content['nm']['header_left'] = 'resources.resource_select.header';
|
$content['nm']['header_left'] = 'resources.resource_select.header';
|
||||||
$content['nm']['header_right'] = 'resources.show.nm_right';
|
$content['nm']['header_right'] = 'resources.show.nm_right';
|
||||||
@ -451,23 +451,32 @@ class resources_ui
|
|||||||
// // links are already saved by eTemplate
|
// // links are already saved by eTemplate
|
||||||
// unset($resource['link_to']['to_id']);
|
// unset($resource['link_to']['to_id']);
|
||||||
// }
|
// }
|
||||||
|
if($content['res_id'])
|
||||||
|
{
|
||||||
|
$acc_count = count($this->bo->get_acc_list($content['res_id']));
|
||||||
|
}
|
||||||
$result = $this->bo->save($content);
|
$result = $this->bo->save($content);
|
||||||
if(is_numeric($result))
|
if(is_numeric($result))
|
||||||
{
|
{
|
||||||
$content['res_id'] = $result;
|
$content['res_id'] = $result;
|
||||||
|
if($acc_count && $content['accessory_of'] != -1)
|
||||||
|
{
|
||||||
|
// Resource with accessories changed into accessory
|
||||||
|
if($acc_count) $msg = lang('%1 accessories now resources',$acc_count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$content['msg'] = $result;
|
$msg = $result;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'delete':
|
case 'delete':
|
||||||
unset($content['delete']);
|
unset($content['delete']);
|
||||||
$content['msg'] = $this->bo->delete($content['res_id']);
|
$msg = $this->bo->delete($content['res_id']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$js = "opener.egw_refresh('".str_replace("'","\\'",$content['msg'])."','addressbook',{$content['res_id']});";
|
$js = "opener.egw_refresh('".str_replace("'","\\'",$msg)."','resources',{$content['res_id']});";
|
||||||
if($button != 'apply' && !$content['msg'])
|
if($button != 'apply' && !$msg)
|
||||||
{
|
{
|
||||||
$js .= 'window.close();';
|
$js .= 'window.close();';
|
||||||
echo "<html><body><script>$js</script></body></html>\n";
|
echo "<html><body><script>$js</script></body></html>\n";
|
||||||
@ -485,7 +494,6 @@ class resources_ui
|
|||||||
if (isset($nm_session_data['filter2']) && $nm_session_data['filter2'] > 0) $accessory_of = $nm_session_data['filter2'];
|
if (isset($nm_session_data['filter2']) && $nm_session_data['filter2'] > 0) $accessory_of = $nm_session_data['filter2'];
|
||||||
if (isset($_GET['accessory_of'])) $accessory_of = $_GET['accessory_of'];
|
if (isset($_GET['accessory_of'])) $accessory_of = $_GET['accessory_of'];
|
||||||
$content = array('res_id' => $res_id);
|
$content = array('res_id' => $res_id);
|
||||||
|
|
||||||
if ($res_id > 0)
|
if ($res_id > 0)
|
||||||
{
|
{
|
||||||
$content = $this->bo->read($res_id);
|
$content = $this->bo->read($res_id);
|
||||||
@ -511,6 +519,10 @@ class resources_ui
|
|||||||
$content['cat_id'] = $nm_session_data['filter'];
|
$content['cat_id'] = $nm_session_data['filter'];
|
||||||
$content['bookable'] = true;
|
$content['bookable'] = true;
|
||||||
}
|
}
|
||||||
|
if($msg) {
|
||||||
|
$content['msg'] = $msg;
|
||||||
|
}
|
||||||
|
|
||||||
if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']);
|
if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']);
|
||||||
|
|
||||||
// some presetes
|
// some presetes
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* EGroupware - eTemplates for Application resources
|
* EGroupware - eTemplates for Application resources
|
||||||
* http://www.egroupware.org
|
* http://www.egroupware.org
|
||||||
* generated by soetemplate::dump4setup() 2013-01-02 09:11
|
* generated by soetemplate::dump4setup() 2013-01-07 09:19
|
||||||
*
|
*
|
||||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||||
* @package resources
|
* @package resources
|
||||||
@ -18,7 +18,7 @@ $templ_data[] = array('name' => 'resources.add_buttons','template' => '','lang'
|
|||||||
|
|
||||||
$templ_data[] = array('name' => 'resources.admin','template' => '','lang' => '','group' => '0','version' => '','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:3:{s:4:"type";s:8:"checkbox";s:5:"label";s:55:"Don\'t use vfs (this will need a symlink --> see README)";s:4:"name";s:12:"dont_use_vfs";}}i:2;a:1:{s:1:"A";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:4:"Save";s:4:"name";s:4:"save";}i:2;a:3:{s:4:"type";s:6:"button";s:5:"label";s:6:"Cancel";s:4:"name";s:6:"cancel";}}}}s:4:"rows";i:2;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1109673054',);
|
$templ_data[] = array('name' => 'resources.admin','template' => '','lang' => '','group' => '0','version' => '','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:3:{s:4:"type";s:8:"checkbox";s:5:"label";s:55:"Don\'t use vfs (this will need a symlink --> see README)";s:4:"name";s:12:"dont_use_vfs";}}i:2;a:1:{s:1:"A";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:4:"Save";s:4:"name";s:4:"save";}i:2;a:3:{s:4:"type";s:6:"button";s:5:"label";s:6:"Cancel";s:4:"name";s:6:"cancel";}}}}s:4:"rows";i:2;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1109673054',);
|
||||||
|
|
||||||
$templ_data[] = array('name' => 'resources.edit','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:5:{i:0;a:1:{s:1:"A";s:3:"700";}i:1;a:1:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";}}i:2;a:1:{s:1:"A";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";i:1;a:5:{s:4:"type";s:4:"text";s:5:"label";s:4:"Name";s:4:"name";s:4:"name";s:4:"help";s:16:"Name of resource";s:6:"needed";s:1:"1";}i:2;a:3:{s:4:"type";s:4:"text";s:5:"label";s:16:"Inventory number";s:4:"name";s:16:"inventory_number";}i:3;a:7:{s:4:"type";s:6:"select";s:5:"label";s:8:"Category";s:7:"no_lang";s:1:"1";s:4:"name";s:6:"cat_id";s:6:"needed";s:1:"1";s:4:"help";s:44:"Which category does this resource belong to?";s:5:"align";s:5:"right";}}}i:3;a:1:{s:1:"A";a:2:{s:4:"type";s:8:"template";s:4:"name";s:19:"resources.edit_tabs";}}i:4;a:1:{s:1:"A";a:2:{s:4:"type";s:8:"template";s:4:"name";s:22:"resources.edit_buttons";}}}s:4:"rows";i:4;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1353446670',);
|
$templ_data[] = array('name' => 'resources.edit','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:5:{i:0;a:1:{s:1:"A";s:3:"700";}i:1;a:1:{s:1:"A";a:4:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";s:4:"span";s:11:"all,message";}}i:2;a:1:{s:1:"A";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";i:1;a:5:{s:4:"type";s:4:"text";s:5:"label";s:4:"Name";s:4:"name";s:4:"name";s:4:"help";s:16:"Name of resource";s:6:"needed";s:1:"1";}i:2;a:3:{s:4:"type";s:4:"text";s:5:"label";s:16:"Inventory number";s:4:"name";s:16:"inventory_number";}i:3;a:7:{s:4:"type";s:6:"select";s:5:"label";s:8:"Category";s:7:"no_lang";s:1:"1";s:4:"name";s:6:"cat_id";s:6:"needed";s:1:"1";s:4:"help";s:44:"Which category does this resource belong to?";s:5:"align";s:5:"right";}}}i:3;a:1:{s:1:"A";a:2:{s:4:"type";s:8:"template";s:4:"name";s:19:"resources.edit_tabs";}}i:4;a:1:{s:1:"A";a:2:{s:4:"type";s:8:"template";s:4:"name";s:22:"resources.edit_buttons";}}}s:4:"rows";i:4;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1353446670',);
|
||||||
|
|
||||||
$templ_data[] = array('name' => 'resources.edit.accessories','template' => '','lang' => '','group' => '0','version' => '','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:3:{s:4:"type";s:9:"nextmatch";s:4:"name";s:2:"nm";s:4:"size";s:19:"resources.show.rows";}}}s:4:"rows";i:1;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1352913344',);
|
$templ_data[] = array('name' => 'resources.edit.accessories','template' => '','lang' => '','group' => '0','version' => '','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:3:{s:4:"type";s:9:"nextmatch";s:4:"name";s:2:"nm";s:4:"size";s:19:"resources.show.rows";}}}s:4:"rows";i:1;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1352913344',);
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@
|
|||||||
</columns>
|
</columns>
|
||||||
<rows>
|
<rows>
|
||||||
<row>
|
<row>
|
||||||
<description id="msg" no_lang="1"/>
|
<description id="msg" no_lang="1" span="all" class="message"/>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<hbox>
|
<hbox>
|
||||||
|
Loading…
Reference in New Issue
Block a user