Ask what to do with accessories when deleting a resource

This commit is contained in:
Nathan Gray 2012-11-06 23:17:26 +00:00
parent b48bee9406
commit 78011ed719
4 changed files with 59 additions and 6 deletions

View File

@ -291,6 +291,16 @@ class resources_bo
if ($this->so->delete(array('res_id'=>$res_id))) if ($this->so->delete(array('res_id'=>$res_id)))
{ {
$accessories = $this->get_acc_list($res_id);
foreach($accessories as $acc_id => $name)
{
if($this->delete($acc_id))
{
$acc = $this->read($acc_id);
$acc['accessory_of'] = -1;
$this->save($acc);
}
};
$this->remove_picture($res_id); $this->remove_picture($res_id);
egw_link::unlink(0,'resources',$res_id); egw_link::unlink(0,'resources',$res_id);
// delete the resource from the calendar // delete the resource from the calendar

View File

@ -264,10 +264,9 @@ class resources_ui
*/ */
'delete' => array( 'delete' => array(
'caption' => 'Delete', 'caption' => 'Delete',
'confirm' => 'Delete this entry',
'confirm_multiple' => 'Delete these entries',
'group' => ++$group, 'group' => ++$group,
'disableClass' => 'no_delete', 'disableClass' => 'no_delete',
'nm_action' => 'open_popup'
), ),
); );
return $actions; return $actions;
@ -342,6 +341,17 @@ class resources_ui
$action_msg = lang('deleted'); $action_msg = lang('deleted');
foreach((array)$checked as $n => $id) foreach((array)$checked as $n => $id)
{ {
if($settings == 'promote')
{
// Make accessories into resources
$accessories = $this->bo->get_acc_list($id);
foreach($accessories as $acc_id => $name)
{
$acc = $this->bo->read($acc_id);
$acc['accessory_of'] = -1;
$this->bo->save($acc);
}
}
$error = $this->bo->delete($id); $error = $this->bo->delete($id);
if (!$error) if (!$error)
{ {

View File

@ -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() 2012-05-02 20:06 * generated by soetemplate::dump4setup() 2012-11-06 16:10
* *
* @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
@ -48,10 +48,20 @@ $templ_data[] = array('name' => 'resources.resource_select.row','template' => ''
$templ_data[] = array('name' => 'resources.resource_selectbox','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:1:{s:2:"c1";s:7:",bottom";}i:1;a:2:{s:1:"A";a:4:{s:4:"type";s:6:"select";s:4:"size";s:3:"14+";s:4:"name";s:9:"resources";s:7:"no_lang";s:1:"1";}s:1:"B";a:6:{s:4:"type";s:6:"button";s:7:"onclick";s:160:"window.open(egw::link(\'/index.php\',\'menuaction=resources.resources_ui.select\'),\'\',\'dependent=yes,width=600,height=450,scrollbars=yes,status=yes\'); return false;";s:5:"label";s:13:"Add resources";s:4:"size";s:6:"navbar";s:6:"needed";s:1:"1";s:4:"name";s:5:"popup";}}}s:4:"rows";i:1;s:4:"cols";i:2;}}','size' => '','style' => '','modified' => '1118520536',); $templ_data[] = array('name' => 'resources.resource_selectbox','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:1:{s:2:"c1";s:7:",bottom";}i:1;a:2:{s:1:"A";a:4:{s:4:"type";s:6:"select";s:4:"size";s:3:"14+";s:4:"name";s:9:"resources";s:7:"no_lang";s:1:"1";}s:1:"B";a:6:{s:4:"type";s:6:"button";s:7:"onclick";s:160:"window.open(egw::link(\'/index.php\',\'menuaction=resources.resources_ui.select\'),\'\',\'dependent=yes,width=600,height=450,scrollbars=yes,status=yes\'); return false;";s:5:"label";s:13:"Add resources";s:4:"size";s:6:"navbar";s:6:"needed";s:1:"1";s:4:"name";s:5:"popup";}}}s:4:"rows";i:1;s:4:"cols";i:2;}}','size' => '','style' => '','modified' => '1118520536',);
$templ_data[] = array('name' => 'resources.show','template' => '','lang' => '','group' => '0','version' => '1.9.002','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:6:{i:0;a:4:{s:1:"A";s:4:"100%";s:2:"h1";s:6:",!@msg";s:2:"h4";s:34:",!@nm[selectcols]=/legacy_actions/";s:2:"h2";s:2:",1";}i:1;a:1:{s:1:"A";a:4:{s:4:"type";s:5:"label";s:4:"span";s:11:"all,message";s:4:"name";s:3:"msg";s:5:"align";s:6:"center";}}i:2;a:1:{s:1:"A";a:3:{s:4:"type";s:8:"template";s:5:"align";s:5:"right";s:4:"name";s:8:"nm_right";}}i:3;a:1:{s:1:"A";a:4:{s:4:"type";s:9:"nextmatch";s:4:"size";s:19:"resources.show.rows";s:7:"no_lang";s:1:"1";s:4:"name";s:2:"nm";}}i:4;a:1:{s:1:"A";a:6:{s:5:"align";s:5:"right";s:4:"span";s:3:"all";s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:5:{s:5:"label";s:13:"Select action";s:7:"onclick";s:184:"if (!egw_globalObjectManager.getObjectById(\'resources.show.rows\').executeActionImplementation(this, \'popup\')) alert(egw::lang(\'You need to select some entries first!\')); return false;;";s:4:"name";s:14:"legacy_actions";s:4:"type";s:10:"buttononly";s:4:"help";s:13:"Select action";}i:2;a:8:{s:5:"label";s:9:"Check all";s:6:"needed";s:1:"1";s:7:"onclick";s:95:"egw_globalObjectManager.getObjectById(\'resources.show.rows\').toggleAllSelected(); return false;";s:4:"name";s:9:"check_all";s:4:"type";s:6:"button";s:4:"size";s:9:"arrow_ltr";s:4:"help";s:9:"Check all";s:4:"span";s:14:",checkAllArrow";}}}i:5;a:1:{s:1:"A";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";i:1;a:4:{s:4:"type";s:6:"button";s:5:"label";s:3:"Add";s:7:"onclick";s:206:"window.open(egw::link(\'/index.php\',\'menuaction=resources.resources_ui.edit\'),\'\',\'dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false; return false;";s:4:"name";s:3:"add";}i:2;a:4:{s:4:"type";s:6:"button";s:5:"label";s:13:"Add accessory";s:4:"name";s:7:"add_sub";s:7:"onclick";s:235:"window.open(egw::link(\'/index.php\',\'menuaction=resources.resources_ui.edit&content=0&accessory_of=$cont[view_accs_of]\'),\'\',\'dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false;";}i:3;a:3:{s:4:"type";s:6:"button";s:5:"label";s:4:"Back";s:4:"name";s:4:"back";}}}}s:4:"rows";i:5;s:4:"cols";i:1;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '.image16 img { $templ_data[] = array('name' => 'resources.show','template' => '','lang' => '','group' => '0','version' => '1.9.003','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:7:{i:0;a:4:{s:1:"A";s:4:"100%";s:2:"h1";s:6:",!@msg";s:2:"h4";s:34:",!@nm[selectcols]=/legacy_actions/";s:2:"h2";s:2:",1";}i:1;a:1:{s:1:"A";a:4:{s:4:"type";s:5:"label";s:4:"span";s:11:"all,message";s:4:"name";s:3:"msg";s:5:"align";s:6:"center";}}i:2;a:1:{s:1:"A";a:3:{s:4:"type";s:8:"template";s:5:"align";s:5:"right";s:4:"name";s:8:"nm_right";}}i:3;a:1:{s:1:"A";a:4:{s:4:"type";s:9:"nextmatch";s:4:"size";s:19:"resources.show.rows";s:7:"no_lang";s:1:"1";s:4:"name";s:2:"nm";}}i:4;a:1:{s:1:"A";a:6:{s:5:"align";s:5:"right";s:4:"span";s:3:"all";s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:5:{s:5:"label";s:13:"Select action";s:7:"onclick";s:184:"if (!egw_globalObjectManager.getObjectById(\'resources.show.rows\').executeActionImplementation(this, \'popup\')) alert(egw::lang(\'You need to select some entries first!\')); return false;;";s:4:"name";s:14:"legacy_actions";s:4:"type";s:10:"buttononly";s:4:"help";s:13:"Select action";}i:2;a:8:{s:5:"label";s:9:"Check all";s:6:"needed";s:1:"1";s:7:"onclick";s:95:"egw_globalObjectManager.getObjectById(\'resources.show.rows\').toggleAllSelected(); return false;";s:4:"name";s:9:"check_all";s:4:"type";s:6:"button";s:4:"size";s:9:"arrow_ltr";s:4:"help";s:9:"Check all";s:4:"span";s:14:",checkAllArrow";}}}i:5;a:1:{s:1:"A";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";i:1;a:4:{s:4:"type";s:6:"button";s:5:"label";s:3:"Add";s:7:"onclick";s:206:"window.open(egw::link(\'/index.php\',\'menuaction=resources.resources_ui.edit\'),\'\',\'dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false; return false;";s:4:"name";s:3:"add";}i:2;a:4:{s:4:"type";s:6:"button";s:5:"label";s:13:"Add accessory";s:4:"name";s:7:"add_sub";s:7:"onclick";s:235:"window.open(egw::link(\'/index.php\',\'menuaction=resources.resources_ui.edit&content=0&accessory_of=$cont[view_accs_of]\'),\'\',\'dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false;";}i:3;a:3:{s:4:"type";s:6:"button";s:5:"label";s:4:"Back";s:4:"name";s:4:"back";}}}i:6;a:1:{s:1:"A";a:6:{s:5:"class";s:12:"action_popup";s:4:"name";s:12:"delete_popup";s:4:"type";s:3:"box";s:4:"size";s:1:"1";i:1;a:6:{s:5:"class";s:6:"prompt";s:4:"type";s:4:"vbox";s:4:"size";s:1:"3";i:1;a:3:{s:4:"type";s:5:"label";s:5:"label";s:6:"Delete";s:4:"span";s:13:",promptheader";}i:2;a:2:{s:4:"type";s:5:"label";s:5:"label";s:19:"Delete accessories?";}i:3;a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";i:1;a:4:{s:5:"label";s:12:"Yes - Delete";s:7:"onclick";s:36:"nm_submit_popup(this); return false;";s:4:"name";s:6:"delete";s:4:"type";s:6:"button";}i:2;a:4:{s:5:"label";s:24:"No - Make them resources";s:7:"onclick";s:75:"nm_popup_action.id = \'delete_promote\'; nm_submit_popup(this); return false;";s:4:"name";s:14:"delete_promote";s:4:"type";s:6:"button";}i:3;a:3:{s:5:"label";s:11:"No - Cancel";s:7:"onclick";s:35:"nm_hide_popup(this,\'delete_popup\');";s:4:"type";s:10:"buttononly";}}}s:4:"span";s:20:",action_popup prompt";}}}s:4:"rows";i:6;s:4:"cols";i:1;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '.image16 img {
max-width: 16px; max-width: 16px;
max-height: 16px; max-height: 16px;
}','modified' => '1331039067',); }
div.action_popup[id] {
position: fixed;
top: 200px;
left: 450px;
width: 76ex;
z-index: 20000;
display: none;
border-collapse:collapse;
border-spacing:0px
}','modified' => '1352242021',);
$templ_data[] = array('name' => 'resources.show.actions','template' => '','lang' => '','group' => '0','version' => '','data' => 'a:1:{i:0;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:3:{s:1:"F";s:2:"3%";s:2:"c1";s:3:"nmh";s:2:"c2";s:3:"nmr";}i:1;a:6:{s:1:"A";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:4:"Name";s:4:"name";s:4:"name";}s:1:"B";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:17:"Short description";s:4:"name";s:17:"short_description";}s:1:"C";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:7:"Useable";s:4:"name";s:7:"useable";}s:1:"D";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:8:"Category";s:4:"name";s:6:"cat_id";}s:1:"E";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:8:"Location";s:4:"name";s:8:"location";}s:1:"F";a:3:{s:4:"type";s:8:"template";s:5:"align";s:5:"right";s:4:"name";s:29:"resources.show.actions_header";}}i:2;a:6:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:12:"${row}[name]";}s:1:"B";a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:25:"${row}[short_description]";}s:1:"C";a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:14:"${row}[usable]";}s:1:"D";a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:16:"${row}[category]";}s:1:"E";a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:16:"${row}[location]";}s:1:"F";a:3:{s:4:"type";s:6:"button";s:5:"align";s:5:"right";s:4:"name";s:20:"lukas[$row_cont[id]]";}}}s:4:"rows";i:2;s:4:"cols";i:6;s:4:"size";s:4:"100%";}}','size' => '100%','style' => '','modified' => '1098891355',); $templ_data[] = array('name' => 'resources.show.actions','template' => '','lang' => '','group' => '0','version' => '','data' => 'a:1:{i:0;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:3:{s:1:"F";s:2:"3%";s:2:"c1";s:3:"nmh";s:2:"c2";s:3:"nmr";}i:1;a:6:{s:1:"A";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:4:"Name";s:4:"name";s:4:"name";}s:1:"B";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:17:"Short description";s:4:"name";s:17:"short_description";}s:1:"C";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:7:"Useable";s:4:"name";s:7:"useable";}s:1:"D";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:8:"Category";s:4:"name";s:6:"cat_id";}s:1:"E";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:8:"Location";s:4:"name";s:8:"location";}s:1:"F";a:3:{s:4:"type";s:8:"template";s:5:"align";s:5:"right";s:4:"name";s:29:"resources.show.actions_header";}}i:2;a:6:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:12:"${row}[name]";}s:1:"B";a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:25:"${row}[short_description]";}s:1:"C";a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:14:"${row}[usable]";}s:1:"D";a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:16:"${row}[category]";}s:1:"E";a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:16:"${row}[location]";}s:1:"F";a:3:{s:4:"type";s:6:"button";s:5:"align";s:5:"right";s:4:"name";s:20:"lukas[$row_cont[id]]";}}}s:4:"rows";i:2;s:4:"cols";i:6;s:4:"size";s:4:"100%";}}','size' => '100%','style' => '','modified' => '1098891355',);

View File

@ -100,7 +100,7 @@
</rows> </rows>
</grid> </grid>
</template> </template>
<template id="resources.show" template="" lang="" group="0" version="1.9.002"> <template id="resources.show" template="" lang="" group="0" version="1.9.003">
<grid width="100%"> <grid width="100%">
<columns> <columns>
<column width="100%"/> <column width="100%"/>
@ -128,12 +128,35 @@
<button label="Back" id="back"/> <button label="Back" id="back"/>
</hbox> </hbox>
</row> </row>
<row>
<box class="action_popup prompt" id="delete_popup">
<vbox class="prompt">
<description value="Delete" class="promptheader"/>
<description value="Delete accessories?"/>
<hbox>
<button label="Yes - Delete" id="delete" onclick="nm_submit_popup(this); return false;"/>
<button label="No - Make them resources" id="delete_promote" onclick="nm_popup_action.id = 'delete_promote'; nm_submit_popup(this); return false;"/>
<buttononly label="No - Cancel" onclick="nm_hide_popup(this,'delete_popup');"/>
</hbox>
</vbox>
</box>
</row>
</rows> </rows>
</grid> </grid>
<styles> <styles>
.image16 img { .image16 img {
max-width: 16px; max-width: 16px;
max-height: 16px; max-height: 16px;
}
div.action_popup[id] {
position: fixed;
top: 200px;
left: 450px;
width: 76ex;
z-index: 20000;
display: none;
border-collapse:collapse;
border-spacing:0px
} }
</styles> </styles>
</template> </template>