36 $stmt = $mysqli->prepare(
'SELECT
40 WHERE '.$whereColumn.
' = ?');
41 $stmt->bind_param(
"i", $whereValue);
43 $stmt->bind_result($lockTime, $lockUserId);
47 while ($stmt->fetch()) {
49 if (($lockTime == 0) || $lockTime < $curTime) {
53 if (($lockUserId == $loggedInUser->userId) && $lockTime > $curTime) {
55 $result = $lockUserId;
58 if ($lockTime > $curTime) {
81 if ($lockState === FALSE) {
85 if ($lockState === $loggedInUser->userId) {
87 $stmt = $mysqli->prepare(
'UPDATE '.$tableName.
'
88 SET lock_time = -1 , lock_user_id = 0
89 WHERE '.$whereColumn.
' = ?');
90 $stmt->bind_param(
"i", $whereValue);
91 $result = $stmt->execute();
107 function lockTableRow($tableName, $whereColumn, $whereValue, $lockUntil) {
109 $stmt = $mysqli->prepare(
'UPDATE '.$tableName.
'
110 SET lock_time = ? , lock_user_id = ?
111 WHERE '.$whereColumn.
' = ?');
112 $stmt->bind_param(
"iii", $lockUntil, $loggedInUser->userId, $whereValue);
113 $result = $stmt->execute();
131 return $db[
'sponsor'];
134 return $db[
'contact_person'];
137 return $db[
'sp_production_facility'];
140 return $db[
'sponsor_car'];
154 global $loggedInUser;
157 if ($tableName !== FALSE) {
160 if ($result === FALSE || $result === $loggedInUser->userId) {
184 if ($tableName !== FALSE) {
186 return lockTableRow($tableName,
'sponsor_id', $sponsorId, $lockUntil);
201 if ($tableName !== FALSE) {
216 global $loggedInUser;
219 if ($tableName !== FALSE) {
221 if ($result === $loggedInUser->userId) {
225 return lockTableRow($tableName,
'sponsor_id', $sponsorId, $lockUntil);
238 global
$db, $loggedInUser;
240 $result =
getTableRowLock($db[
'production_facility'],
'production_facility_id', $id);
241 if ($result === FALSE || $result === $loggedInUser->userId) {
257 return lockTableRow($db[
'production_facility'],
'production_facility_id', $id, $lockUntil);
268 return unlockTableRow($db[
'production_facility'],
'production_facility_id', $id);
278 global
$db, $loggedInUser;
279 $result =
getTableRowLock($db[
'production_facility'],
'production_facility_id', $id);
280 if ($result === $loggedInUser->userId) {
292 global
$db, $loggedInUser;
295 if ($result === FALSE || $result === $loggedInUser->userId) {
311 return lockTableRow($db[
'status'],
'status_id', $id, $lockUntil);
332 global
$db, $loggedInUser;
334 if ($result === $loggedInUser->userId) {
346 global
$db, $loggedInUser;
349 if ($result === FALSE || $result === $loggedInUser->userId) {
365 return lockTableRow($db[
'category'],
'category_id', $id, $lockUntil);
386 global
$db, $loggedInUser;
388 if ($result === $loggedInUser->userId) {
400 global
$db, $loggedInUser;
403 if ($result === FALSE || $result === $loggedInUser->userId) {
419 return lockTableRow($db[
'car'],
'car_id', $id, $lockUntil);
440 global
$db, $loggedInUser;
442 if ($result === $loggedInUser->userId) {