ordersprinter/webapp/php/utilities/roles.php

147 lines
3.7 KiB
PHP
Raw Normal View History

2020-11-19 23:03:48 +01:00
<?php
class Roles {
2020-11-19 23:11:33 +01:00
private static function createNewRoleEntry($pdo,$rolename) {
2020-11-19 23:11:36 +01:00
$cols = Basedb::getAllColsOfATable($pdo, '%roles%',array('id','name'));
2020-11-19 23:11:33 +01:00
$quests = array('?');
$vals = array($rolename);
$colnames = array('name');
foreach($cols as $aCol) {
$quests[] = '?';
$vals[] = 0;
$colnames[] = $aCol;
}
$colnamesStr = join(',',$colnames);
$questsStr = join(',', $quests);
$sql = "INSERT INTO %roles% ($colnamesStr) values($questsStr)";
CommonUtils::execSql($pdo, $sql, $vals);
return $pdo->lastInsertId();
}
private static function setPermission($pdo,$roleid,$permissionsArr) {
foreach ($permissionsArr as $perm) {
$sql = "UPDATE %roles% SET $perm=? WHERE id=?";
CommonUtils::execSql($pdo, $sql, array(1,$roleid));
}
}
2020-11-19 23:03:48 +01:00
public static function insertAdminRole($pdo) {
2020-11-19 23:11:33 +01:00
$roleid = self::createNewRoleEntry($pdo, "Admin");
$permissionsYes = array(
'is_admin',
'right_statistics',
'right_products',
'right_manager',
'right_closing',
'right_dash',
'right_timetracking',
'right_timemanager',
'right_tasks',
'right_tasksmanagement');
self::setPermission($pdo, $roleid, $permissionsYes);
return $roleid;
2020-11-19 23:03:48 +01:00
}
public static function insertDigiManagerRole($pdo) {
2020-11-19 23:11:33 +01:00
$roleid = self::createNewRoleEntry($pdo, "Manager");
$permissionsYes = array(
'right_waiter',
'right_kitchen',
'right_bar',
'right_supply',
'right_paydesk',
'right_statistics',
'right_bill',
'right_products',
'right_manager',
'right_closing',
'right_dash',
'right_reservation',
'right_rating',
'right_changeprice',
'right_customers',
'right_timetracking',
'right_timemanager',
'right_tasks',
'right_tasksmanagement');
self::setPermission($pdo, $roleid, $permissionsYes);
return $roleid;
2020-11-19 23:03:48 +01:00
}
public static function insertWorkManagerRole($pdo) {
2020-11-19 23:11:33 +01:00
$roleid = self::createNewRoleEntry($pdo, "Manager");
$permissionsYes = array(
'right_waiter',
'right_paydesk',
'right_statistics',
'right_bill',
'right_products',
'right_manager',
'right_closing',
'right_dash',
'right_reservation',
'right_rating',
'right_changeprice',
'right_customers',
'right_timetracking',
'right_timemanager',
'right_tasks',
'right_tasksmanagement');
self::setPermission($pdo, $roleid, $permissionsYes);
return $roleid;
2020-11-19 23:03:48 +01:00
}
public static function insertDigiWaiterRole($pdo) {
2020-11-19 23:11:33 +01:00
$roleid = self::createNewRoleEntry($pdo, "Kellner");
$permissionsYes = array(
'right_waiter',
'right_kitchen',
'right_bar',
'right_supply',
'right_paydesk',
'right_bill',
'right_closing',
'right_reservation',
'right_changeprice',
'right_timetracking',
'right_tasks'
);
self::setPermission($pdo, $roleid, $permissionsYes);
return $roleid;
2020-11-19 23:03:48 +01:00
}
public static function insertWorkWaiterRole($pdo) {
2020-11-19 23:11:33 +01:00
$roleid = self::createNewRoleEntry($pdo, "Kellner");
$permissionsYes = array(
'right_waiter',
'right_kitchen',
'right_bar',
'right_supply',
'right_paydesk',
'right_bill',
'right_closing',
'right_reservation',
'right_changeprice',
'right_timetracking',
'right_tasks'
);
self::setPermission($pdo, $roleid, $permissionsYes);
return $roleid;
2020-11-19 23:03:48 +01:00
}
public static function insertCookRole($pdo) {
2020-11-19 23:11:33 +01:00
$roleid = self::createNewRoleEntry($pdo, "Koch");
$permissionsYes = array(
'right_kitchen',
'right_bar',
'right_supply',
'right_timetracking',
'right_tasks'
);
self::setPermission($pdo, $roleid, $permissionsYes);
return $roleid;
2020-11-19 23:03:48 +01:00
}
}