Add multi-entry action to change timesheet category

This commit is contained in:
Nathan Gray 2010-12-10 18:03:46 +00:00
parent 0cd5658ca1
commit 86402b7973
2 changed files with 80 additions and 5 deletions

View File

@ -783,6 +783,16 @@ class timesheet_ui extends timesheet_bo
}
else
{
// Action has a parameter - cat_id, percent, etc
$multi_action = $content['action'];
if (in_array($multi_action, array('cat')))
{
if(is_array($content[$multi_action]))
{
$content[$multi_action] = implode(',',$content[$multi_action]);
}
$content['action'] .= '_' . $content[$multi_action];
}
if ($this->action($content['action'],$content['nm']['rows']['checked'],$content['use_all'],
$success,$failed,$action_msg,'index',$msg))
{
@ -837,6 +847,7 @@ class timesheet_ui extends timesheet_bo
$status =array();
$sel_options['action'] ['delete']= lang('Delete Timesheet');
$sel_options['action']['cat'] = lang('Change category');
foreach ($this->status_labels as $status_id => $label_status)
{
$status['to_status_'.$status_id] = $label_status;
@ -889,6 +900,11 @@ class timesheet_ui extends timesheet_bo
$to_status = (int)substr($action,10);
$action = 'to_status';
}
else
{
// Dialogs to get options
list($action, $settings) = explode('_', $action, 2);
}
switch($action)
{
@ -920,6 +936,23 @@ class timesheet_ui extends timesheet_bo
}
}
break;
case 'cat':
$cat_name = categories::id2name($settings);
$action_msg = lang('changed category to %1', $cat_name);
foreach((array)$checked as $n => $id) {
$entry = $this->read($id);
$entry['cat_id'] = $settings;
if($this->save($entry) == 0)
{
$success++;
}
else
{
$failed++;
}
}
break;
}
return !$failed;
@ -1022,14 +1055,32 @@ class timesheet_ui extends timesheet_bo
return false;
}
/**
* Javascript handling for multiple entry actions
*/
function do_action(selbox)
{
if (selbox.value != "") {
if(selbox.value == "") return;
var prefix = selbox.id.substring(0,selbox.id.indexOf("["));
var popup = document.getElementById(prefix + "[" + selbox.value + "_popup]");
if(popup) {
popup.style.display = "block";
return;
}
selbox.form.submit();
selbox.value = "";
}
}
/**
* Hide popup and clear values
*/
function hide_popup(element, div_id) {
var prefix = element.id.substring(0,element.id.indexOf("["));
var popup = document.getElementById(prefix+"["+div_id+"]");
if(popup) {
popup.style.display = "none";
}
}
</script>';
}
}

View File

@ -2,7 +2,7 @@
/**
* eGroupWare - eTemplates for Application timesheet
* http://www.egroupware.org
* generated by soetemplate::dump4setup() 2010-03-23 13:51
* generated by soetemplate::dump4setup() 2010-12-10 10:59
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package timesheet
@ -37,7 +37,31 @@ $templ_data[] = array('name' => 'timesheet.edit.notes','template' => '','lang' =
$templ_data[] = array('name' => 'timesheet.editstatus','template' => '','lang' => '','group' => '0','version' => '1.7.004','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:4:{i:0;a:3:{s:1:"D";s:3:"30%";s:1:"A";s:3:"100";s:2:"h1";s:6:",!@msg";}i:1;a:4:{s:1:"A";a:4:{s:4:"type";s:5:"label";s:4:"name";s:3:"msg";s:4:"span";s:13:"all,redItalic";s:5:"align";s:6:"center";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}}i:2;a:4:{s:1:"A";a:6:{s:4:"type";s:8:"groupbox";s:4:"data";a:2:{i:0;a:1:{s:2:"h1";s:6:",!@msg";}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";}}}s:4:"rows";i:1;s:4:"cols";i:1;s:4:"size";s:1:"1";i:1;a:5:{s:4:"type";s:4:"grid";s:4:"data";a:2:{i:0;a:3:{s:1:"D";s:3:"30%";s:2:"c1";s:7:"row,top";s:1:"A";s:3:"100";}i:1;a:4:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:6:"Status";}s:1:"B";a:8:{s:4:"type";s:4:"grid";s:4:"size";s:17:"100%,280,,,,,auto";s:4:"span";s:3:"all";s:4:"name";s:6:"statis";s:4:"data";a:3:{i:0;a:3:{s:2:"c1";s:2:"th";s:2:"c2";s:3:"row";s:1:"E";s:2:"5%";}i:1;a:5:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:2:"ID";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:5:"label";s:4:"Name";}s:1:"C";a:2:{s:4:"type";s:5:"label";s:5:"label";s:6:"Parent";}s:1:"D";a:2:{s:4:"type";s:5:"label";s:5:"label";s:10:"Only Admin";}s:1:"E";a:2:{s:4:"type";s:5:"label";s:5:"label";s:7:"Actions";}}i:2;a:5:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:4:"name";s:10:"${row}[id]";}s:1:"B";a:4:{s:4:"type";s:4:"text";s:4:"size";s:6:"80,150";s:4:"blur";s:18:"--> enter new name";s:4:"name";s:12:"${row}[name]";}s:1:"C";a:3:{s:4:"type";s:6:"select";s:4:"name";s:14:"${row}[parent]";s:4:"size";s:13:"please select";}s:1:"D";a:3:{s:4:"type";s:8:"checkbox";s:4:"name";s:13:"${row}[admin]";s:4:"help";s:33:"Only Admin can change this Status";}s:1:"E";a:7:{s:4:"type";s:6:"button";s:4:"size";s:6:"delete";s:5:"label";s:6:"Delete";s:5:"align";s:6:"center";s:4:"name";s:21:"delete[$row_cont[id]]";s:4:"help";s:18:"Delete this status";s:7:"onclick";s:37:"return confirm(\'Delete this status\');";}}}s:4:"rows";i:2;s:4:"cols";i:5;s:7:"options";a:3:{i:0;s:4:"100%";i:1;s:3:"280";i:6;s:4:"auto";}}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:1;s:4:"cols";i:4;s:4:"size";s:17:"100%,300,,,,,auto";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}}i:3;a:4:{s:1:"A";a:6:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";s:4:"span";s:1:"2";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:4:"Save";s:4:"name";s:12:"button[save]";}i:2;a:3:{s:4:"type";s:6:"button";s:4:"name";s:13:"button[apply]";s:5:"label";s:5:"Apply";}i:3;a:3:{s:4:"type";s:6:"button";s:5:"label";s:6:"Cancel";s:4:"name";s:14:"button[cancel]";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:3;s:4:"cols";i:4;s:4:"size";s:17:"100%,450,,,,,auto";s:7:"options";a:3:{i:0;s:4:"100%";i:1;s:3:"450";i:6;s:4:"auto";}}}','size' => '100%,450,,,,,auto','style' => '','modified' => '1252352154',);
$templ_data[] = array('name' => 'timesheet.index','template' => '','lang' => '','group' => '0','version' => '1.7.003','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:6:{i:0;a:4:{s:2:"h1";s:6:",!@msg";s:2:"h2";s:2:",1";s:2:"c4";s:7:"noPrint";s:2:"h5";s:2:",1";}i:1;a:2:{s:1:"A";a:5:{s:4:"type";s:5:"label";s:4:"span";s:13:"all,redItalic";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";s:5:"align";s:6:"center";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:2:{s:4:"type";s:8:"template";s:4:"name";s:5:"dates";}i:2;a:3:{s:4:"type";s:8:"template";s:4:"name";s:3:"add";s:5:"align";s:5:"right";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:3;a:2:{s:1:"A";a:4:{s:4:"type";s:9:"nextmatch";s:4:"name";s:2:"nm";s:4:"size";s:20:"timesheet.index.rows";s:4:"span";s:3:"all";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:4;a:2:{s:1:"A";a:4:{s:4:"type";s:6:"button";s:5:"label";s:3:"Add";s:4:"name";s:3:"add";s:7:"onclick";s:164:"window.open(egw::link(\'/index.php\',\'menuaction=timesheet.timesheet_ui.edit\'),\'_blank\',\'dependent=yes,width=600,height=400,scrollbars=yes,status=yes\'); return false;";}s:1:"B";a:6:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";s:5:"align";s:5:"right";i:1;a:5:{s:4:"type";s:8:"checkbox";s:4:"name";s:7:"use_all";s:5:"label";s:11:"whole query";s:8:"onchange";s:128:"if (this.checked==true && !confirm(\'Apply the action on the whole query, NOT only the shown timesheets!!!\')) this.checked=false;";s:4:"help";s:69:"Apply the action on the whole query, NOT only the shown timesheets!!!";}i:2;a:5:{s:4:"type";s:6:"select";s:8:"onchange";s:16:"do_action(this);";s:4:"size";s:13:"Select action";s:4:"name";s:6:"action";s:4:"help";s:13:"Select action";}i:3;a:8:{s:4:"type";s:6:"button";s:4:"size";s:9:"arrow_ltr";s:5:"label";s:9:"Check all";s:4:"name";s:9:"check_all";s:4:"help";s:9:"Check all";s:7:"onclick";s:70:"toggle_all(this.form,form::name(\'nm[rows][checked][]\')); return false;";s:6:"needed";s:1:"1";s:4:"span";s:14:",checkAllArrow";}}}i:5;a:2:{s:1:"A";a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Export";s:7:"onclick";s:33:"timesheet_export(); return false;";s:4:"name";s:6:"export";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:5;s:4:"cols";i:2;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '','modified' => '1251217617',);
$templ_data[] = array('name' => 'timesheet.index','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:6:{i:0;a:4:{s:2:"h1";s:6:",!@msg";s:2:"h2";s:2:",1";s:2:"c4";s:7:"noPrint";s:2:"h5";s:2:",1";}i:1;a:2:{s:1:"A";a:5:{s:4:"type";s:5:"label";s:4:"span";s:13:"all,redItalic";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";s:5:"align";s:6:"center";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:2:{s:4:"type";s:8:"template";s:4:"name";s:5:"dates";}i:2;a:3:{s:4:"type";s:8:"template";s:4:"name";s:3:"add";s:5:"align";s:5:"right";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:3;a:2:{s:1:"A";a:4:{s:4:"type";s:9:"nextmatch";s:4:"name";s:2:"nm";s:4:"size";s:20:"timesheet.index.rows";s:4:"span";s:3:"all";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:4;a:2:{s:1:"A";a:4:{s:4:"type";s:6:"button";s:5:"label";s:3:"Add";s:4:"name";s:3:"add";s:7:"onclick";s:164:"window.open(egw::link(\'/index.php\',\'menuaction=timesheet.timesheet_ui.edit\'),\'_blank\',\'dependent=yes,width=600,height=400,scrollbars=yes,status=yes\'); return false;";}s:1:"B";a:7:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"4";s:5:"align";s:5:"right";i:1;a:5:{s:4:"type";s:8:"checkbox";s:4:"name";s:7:"use_all";s:5:"label";s:11:"whole query";s:8:"onchange";s:128:"if (this.checked==true && !confirm(\'Apply the action on the whole query, NOT only the shown timesheets!!!\')) this.checked=false;";s:4:"help";s:69:"Apply the action on the whole query, NOT only the shown timesheets!!!";}i:2;a:5:{s:4:"type";s:3:"box";s:4:"name";s:9:"cat_popup";s:4:"size";s:1:"1";s:4:"span";s:20:",action_popup prompt";i:1;a:5:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"3";i:1;a:3:{s:4:"type";s:5:"label";s:4:"span";s:13:",promptheader";s:5:"label";s:15:"Change category";}i:2;a:5:{s:4:"type";s:10:"select-cat";s:4:"span";s:21:",action_popup-content";s:4:"name";s:3:"cat";s:4:"size";s:16:"None,,,timesheet";s:5:"label";s:19:"Select new category";}i:3;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:5:"Apply";s:4:"name";s:10:"change_cat";}i:2;a:3:{s:4:"type";s:10:"buttononly";s:5:"label";s:6:"Cancel";s:7:"onclick";s:29:"hide_popup(this,\'cat_popup\');";}}}}i:3;a:5:{s:4:"type";s:6:"select";s:8:"onchange";s:16:"do_action(this);";s:4:"size";s:13:"Select action";s:4:"name";s:6:"action";s:4:"help";s:13:"Select action";}i:4;a:8:{s:4:"type";s:6:"button";s:4:"size";s:9:"arrow_ltr";s:5:"label";s:9:"Check all";s:4:"name";s:9:"check_all";s:4:"help";s:9:"Check all";s:7:"onclick";s:70:"toggle_all(this.form,form::name(\'nm[rows][checked][]\')); return false;";s:6:"needed";s:1:"1";s:4:"span";s:14:",checkAllArrow";}}}i:5;a:2:{s:1:"A";a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Export";s:7:"onclick";s:33:"timesheet_export(); return false;";s:4:"name";s:6:"export";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:5;s:4:"cols";i:2;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '/**
* Add / remove link or category popup used for actions on multiple entries
*/
.action_popup {
position: fixed;
top: 200px;
left: 450px;
width: 76ex;
z-index: 20000;
display: none;
border-collapse:collapse;
border-spacing:0px
}
.action_popup-content {
display:block;
padding:2ex;
color:#666666;
margin: -2px -1px 0px -2px;
}
.action_popup > table {
width: 100%
}
','modified' => '1291996935',);
$templ_data[] = array('name' => 'timesheet.index.add','template' => '','lang' => '','group' => '0','version' => '1.7.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:10:"buttononly";s:5:"label";s:3:"Add";s:4:"name";s:3:"add";s:7:"onclick";s:164:"window.open(egw::link(\'/index.php\',\'menuaction=timesheet.timesheet_ui.edit\'),\'_blank\',\'dependent=yes,width=600,height=400,scrollbars=yes,status=yes\'); return false;";}}','size' => '','style' => '','modified' => '1158042543',);