56 lines
1.7 KiB
PHP
56 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace HermannTelser\Gutachten\DB\Select;
|
|
|
|
use HermannTelser\Gutachten\DB\DbFunction;
|
|
|
|
class StandardsEinzeln
|
|
{
|
|
/**
|
|
* @param mixed $id
|
|
* @param mixed $projektid
|
|
*
|
|
* @return bool
|
|
*/
|
|
public static function load($projektid)
|
|
{
|
|
DbFunction::$debug = 0;
|
|
|
|
$arr = DbFunction::select('tx_gutachten_projektestandards', '*', ['pid' => $projektid, 'ORDER' => 'pos']);
|
|
|
|
if (0 == \count($arr)) {
|
|
$arr = Standards::standards();
|
|
|
|
foreach ($arr as $key => $value) {
|
|
unset($value['id']);
|
|
unset($value['textart']);
|
|
$value['pid'] = $projektid;
|
|
$value_array = [];
|
|
$value_array = $value;
|
|
|
|
DbFunction::secureInsert('tx_gutachten_projektestandards', $value_array);
|
|
}
|
|
|
|
$arr = DbFunction::select('tx_gutachten_projektestandards', '*', ['pid' => $projektid, 'ORDER' => 'pos']);
|
|
}
|
|
|
|
$sum = \count($arr);
|
|
$value_array = [];
|
|
foreach ($arr as $key => $value) {
|
|
$arr[$key]['all'] = $sum;
|
|
$arr[$key]['id'] = (int) $value['id'];
|
|
if ($value['pos'] == 0) {
|
|
$value_array['pos'] = $key+1;
|
|
DbFunction::secureUpdate('tx_gutachten_projektestandards', $value_array, ['id' => $value['id']]);
|
|
$arr[$key]['pos'] = (int) $key+1;;
|
|
} else {
|
|
$arr[$key]['pos'] = (int) $value['pos'];
|
|
}
|
|
$arr[$key]['hat_platzhalter'] = false !== strpos($value['txt'], '###') ? 1 : 0;
|
|
$arr[$key]['neueseite'] = (int) $value['neueseite'];
|
|
$arr[$key]['textart'] = ucwords($value['textart']);
|
|
}
|
|
return $arr;
|
|
}
|
|
}
|