Fixed CLI update_group

This commit is contained in:
Luis Calvo 2020-11-05 14:31:26 +01:00
parent 6662b4f286
commit 6337fd3667
1 changed files with 9 additions and 3 deletions

View File

@ -5754,16 +5754,22 @@ sub cli_delete_group() {
sub cli_update_group() {
my ($group_id,$group_name,$parent_group_name,$icon,$description) = @ARGV[2..6];
my $result;
$result = db_do ($dbh, 'SELECT * FROM tgrupo WHERE id_grupo=?', $group_id);
$result = get_db_value ($dbh, 'SELECT * FROM tgrupo WHERE id_grupo=?', $group_id);
if($result == "0E0"){
print_log "[ERROR] Group '$group_id' doesn`t exist \n\n";
}else{
if(defined($group_name)){
if(defined($parent_group_name)){
my $parent_group_id = get_group_id($dbh,$parent_group_name);
exist_check($parent_group_id, 'group name', $parent_group_name);
my $parent_group_id = 0;
if($parent_group_name ne 'All') {
$parent_group_id = get_group_id($dbh,$parent_group_name);
exist_check($parent_group_id, 'group name', $parent_group_name);
}
if(defined($icon)){
if(defined($description)){
db_do ($dbh,'UPDATE tgrupo SET nombre=? , parent=? , icon=? , description=? WHERE id_grupo=?',$group_name,$parent_group_id,$icon,$description,$group_id);