Merge branch 'master' into fronkdev
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -70,10 +70,27 @@ class CalendarController extends mfBaseController
|
||||
$email->send();
|
||||
} else if ($r->customer_info_type == 2) {
|
||||
$sms = new SmsNotification();
|
||||
$body = "Xinon Terminbestätigung:" . PHP_EOL . $r->customer_info_text;
|
||||
$customerText = trim($r->customer_info_text);
|
||||
$body = "Xinon Terminbestätigung:" . PHP_EOL . $customerText;
|
||||
$sms->setBody($body);
|
||||
$sms->setRecipient($r->customer_info_type_text);
|
||||
$sms->send();
|
||||
$customerNumber = trim($r->customer_info_type_text);
|
||||
$customerNumber = str_replace(" ", "", $customerNumber);
|
||||
$customerNumber = str_replace("(", "", $customerNumber);
|
||||
$customerNumber = str_replace(")", "", $customerNumber);
|
||||
$customerNumber = str_replace("-", "", $customerNumber);
|
||||
$customerNumber = str_replace("/", "", $customerNumber);
|
||||
$customerNumber = str_replace(".", "", $customerNumber);
|
||||
$customerNumber = str_replace(",", "", $customerNumber);
|
||||
$customerNumber = str_replace(";", "", $customerNumber);
|
||||
$customerNumber = str_replace(":", "", $customerNumber);
|
||||
|
||||
if (preg_match('/^0/', $customerNumber)) {
|
||||
$customerNumber = "+43" . substr($customerNumber, 1);
|
||||
}
|
||||
$sms->setRecipient($customerNumber);
|
||||
if (!empty($customerNumber) && !empty($customerText)) {
|
||||
$sms->send();
|
||||
}
|
||||
}
|
||||
}
|
||||
die();
|
||||
@@ -104,10 +121,26 @@ class CalendarController extends mfBaseController
|
||||
$email->send();
|
||||
} else if ($r->customer_info_type == 2) {
|
||||
$sms = new SmsNotification();
|
||||
$body = "Xinon Terminbestätigung:" . PHP_EOL . $r->customer_info_text;
|
||||
$customerText = trim($r->customer_info_text);
|
||||
$body = "Xinon Terminbestätigung:" . PHP_EOL . $customerText;
|
||||
$sms->setBody($body);
|
||||
$sms->setRecipient($r->customer_info_type_text);
|
||||
$sms->send();
|
||||
$customerNumber = trim($r->customer_info_type_text);
|
||||
$customerNumber = str_replace(" ", "", $customerNumber);
|
||||
$customerNumber = str_replace("(", "", $customerNumber);
|
||||
$customerNumber = str_replace(")", "", $customerNumber);
|
||||
$customerNumber = str_replace("-", "", $customerNumber);
|
||||
$customerNumber = str_replace("/", "", $customerNumber);
|
||||
$customerNumber = str_replace(".", "", $customerNumber);
|
||||
$customerNumber = str_replace(",", "", $customerNumber);
|
||||
$customerNumber = str_replace(";", "", $customerNumber);
|
||||
$customerNumber = str_replace(":", "", $customerNumber);
|
||||
if (preg_match('/^0/', $customerNumber)) {
|
||||
$customerNumber = "+43" . substr($customerNumber, 1);
|
||||
}
|
||||
$sms->setRecipient($customerNumber);
|
||||
if (!empty($customerNumber) && !empty($customerText)) {
|
||||
$sms->send();
|
||||
}
|
||||
}
|
||||
}
|
||||
die();
|
||||
@@ -327,17 +360,18 @@ class CalendarController extends mfBaseController
|
||||
echo trim($json);
|
||||
die();
|
||||
}
|
||||
|
||||
private function getTicket($r)
|
||||
{
|
||||
|
||||
$project = new XinonProject();
|
||||
|
||||
$data=$project->searchSupportTickets($r->term);
|
||||
$data = $project->searchSupportTickets($r->term);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$rows[] = array(
|
||||
'id' => $value['id'],
|
||||
'text' => 'Ticket: '.$value['id']." ".$value['subject'],
|
||||
'text' => 'Ticket: ' . $value['id'] . " " . $value['subject'],
|
||||
'subject' => $value['subject'],
|
||||
'mail' => $value['customField5'],
|
||||
'mobilenumber' => $value['customField4'],
|
||||
|
||||
@@ -47,6 +47,8 @@ class CalendarModel
|
||||
3 => 'Grüne Kategorie', //ESTMK IBN
|
||||
4 => 'Lila Kategorie', //Snopp IBN
|
||||
5 => 'Rote Kategorie', //Störung
|
||||
98 => 'Gru00fcne Kategorie', //ESTMK IBN
|
||||
99 => 'Gr\u00fcne Kategorie', //ESTMK IBN
|
||||
);
|
||||
public static $specialCalendarColors = array(997 => '#bd0000', 998 => '#8000A3', 999 => '#08769b');
|
||||
|
||||
@@ -694,7 +696,7 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda
|
||||
if (($r->customer_info_type_text)) {
|
||||
$customer_info_type_text = $r->customer_info_type_text;
|
||||
}
|
||||
if ($r->customer_info_reminder_check) {
|
||||
if ($r->customer_info_reminder_check || $r->customer_info_reminder_check == 0) {
|
||||
$updateArray['customer_info_reminder'] = $r->customer_info_reminder_check;
|
||||
}
|
||||
$customerJson = array('customer_info_type' => $customer_info_type, 'customer_info_text' => $customer_info_text, 'customer_info_type_text' => $customer_info_type_text);
|
||||
|
||||
@@ -353,6 +353,7 @@ class ConstructionConsent extends mfBaseModel {
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM ConstructionConsent
|
||||
LEFT JOIN ".ADDRESSDB_DBNAME.".view_hausnummer ON (ConstructionConsent.adb_hausnummer_id = view_hausnummer.hausnummer_id)
|
||||
WHERE $where";
|
||||
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
@@ -377,6 +378,7 @@ class ConstructionConsent extends mfBaseModel {
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM ConstructionConsent
|
||||
LEFT JOIN ".ADDRESSDB_DBNAME.".view_hausnummer ON (ConstructionConsent.adb_hausnummer_id = view_hausnummer.hausnummer_id)
|
||||
WHERE $where
|
||||
ORDER BY $order";
|
||||
|
||||
@@ -494,6 +496,13 @@ class ConstructionConsent extends mfBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("network", $filter)) {
|
||||
$network = FronkDB::singleton()->escape($filter["network"]);
|
||||
if($network) {
|
||||
$where .= " AND view_hausnummer.netzgebiet_id=$network";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(array_key_exists("add-where", $filter)) {
|
||||
|
||||
@@ -10,9 +10,7 @@ class ConstructionConsentController extends mfBaseController {
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
if (!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908]))) $this->redirect("Dashboard");
|
||||
}
|
||||
|
||||
protected function indexAction() : void {
|
||||
|
||||
@@ -11,9 +11,7 @@ class ConstructionConsentContactController extends mfBaseController
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
if (!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908]))) $this->redirect("Dashboard");
|
||||
}
|
||||
|
||||
protected function saveAction()
|
||||
|
||||
@@ -9,9 +9,7 @@ class ConstructionConsentJournalController extends mfBaseController {
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if(!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908]))) $this->redirect("Dashboard");
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
|
||||
@@ -11,9 +11,7 @@ class ConstructionConsentOwnerController extends mfBaseController
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
if (!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908]))) $this->redirect("Dashboard");
|
||||
}
|
||||
|
||||
protected function uploadDocumentAction() {
|
||||
|
||||
@@ -10,9 +10,7 @@ class ConstructionConsentProjectController extends mfBaseController {
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
if (!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908]))) $this->redirect("Dashboard");
|
||||
}
|
||||
|
||||
protected function indexAction() : void {
|
||||
|
||||
@@ -10,6 +10,7 @@ class DashboardNewController extends mfBaseController {
|
||||
$me->loadMe();
|
||||
$this->layout()->set("me", $me);
|
||||
$this->me = $me;
|
||||
if ($this->me->address_id === '5908') $this->me->address_id = '209';
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
@@ -73,7 +74,6 @@ class DashboardNewController extends mfBaseController {
|
||||
$netowner_ids = isset($post['netOwners']) ? [$post['netOwners']] : [];
|
||||
$campaign_ids = isset($post['campaigns']) ? [$post['campaigns']] : [];
|
||||
$campaigns = [];
|
||||
|
||||
$all_campaigns = $this->me->is("Admin") ? PreordercampaignModel::getAll() : PreordercampaignModel::search(["owner_id" => $this->me->address_id]);
|
||||
|
||||
if (!empty($netowner_ids)) {
|
||||
@@ -140,10 +140,16 @@ class DashboardNewController extends mfBaseController {
|
||||
if (!empty($netowner_ids)) {
|
||||
$all_campaigns = $this->me->is("Admin") ? PreordercampaignModel::getAll() : PreordercampaignModel::search(["owner_id" => $this->me->address_id]);
|
||||
|
||||
if ($all_campaigns[0] === NULL) {
|
||||
http_response_code(500);
|
||||
self::returnJson(["status" => 500, "message" => "Keine Kampagnen gefunden"]);
|
||||
}
|
||||
|
||||
$campaign_ids = empty($campaign_ids) ?
|
||||
array_map(fn($campaign) => $campaign->id, $all_campaigns) :
|
||||
$campaign_ids;
|
||||
|
||||
|
||||
$campaign_ids = array_filter($campaign_ids, function ($campaign_id) use ($netowner_ids) {
|
||||
$campaign = new Preordercampaign($campaign_id);
|
||||
return in_array($campaign->network->owner_id, $netowner_ids);
|
||||
@@ -152,6 +158,12 @@ class DashboardNewController extends mfBaseController {
|
||||
|
||||
if (empty($campaign_ids) && !$this->me->is("Admin")) {
|
||||
$owner_campaigns = PreordercampaignModel::search(["owner_id" => $this->me->address_id]);
|
||||
|
||||
if (empty($owner_campaigns)) {
|
||||
http_response_code(500);
|
||||
self::returnJson(["status" => 500, "message" => "Keine Kampagnen gefunden"]);
|
||||
}
|
||||
|
||||
$campaign_ids = array_map(fn($campaign) => $campaign->id, $owner_campaigns);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,20 @@ class DeviceController extends mfBaseController
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
if (!$me->is(["Admin"])) {
|
||||
if (!$me->is(["Admin", "netowner", "lineplanner", "pipeplanner", "pipeworker", "lineworker"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
|
||||
if ($this->me->is(["Admin"])) {
|
||||
$this->allowedPops = null;
|
||||
} else {
|
||||
$networkIds = array_column($this->me->getProperty('my_networks'), 'id');
|
||||
$pops=PopNetworkModel::search(['Networks' => $networkIds]);
|
||||
foreach ($pops as $pop) {
|
||||
$popIds[] = $pop->pop_id;
|
||||
}
|
||||
$this->allowedPops = $popIds;
|
||||
}
|
||||
}
|
||||
|
||||
protected function indexAction()
|
||||
@@ -75,6 +86,13 @@ class DeviceController extends mfBaseController
|
||||
$this->redirect("Device");
|
||||
}
|
||||
|
||||
if (!$this->me->is(["Admin"])) {
|
||||
if (!in_array($device->pop_id, $this->allowedPops)) {
|
||||
$this->layout()->setFlash("Gerät nicht gefunden", "error");
|
||||
$this->redirect("Device");
|
||||
}
|
||||
}
|
||||
|
||||
$this->layout()->setTemplate("Device/Detail");
|
||||
$devicesconfig = DeviceModel::getconifg($id);
|
||||
$devices = DeviceModel::getOne($id);
|
||||
@@ -99,7 +117,6 @@ class DeviceController extends mfBaseController
|
||||
$this->layout()->set("devicetypes", DevicetypeModel::getAll());
|
||||
$this->layout()->set("pops", PopModel::getAll());
|
||||
$this->layout()->set("devices", DeviceModel::getAll());
|
||||
|
||||
}
|
||||
|
||||
protected function editAction()
|
||||
@@ -123,6 +140,11 @@ class DeviceController extends mfBaseController
|
||||
|
||||
protected function saveAction()
|
||||
{
|
||||
if (!$this->me->is(["Admin"])) {
|
||||
$this->layout()->setFlash("Keine Berechtigung", "error");
|
||||
$this->redirect("Device");
|
||||
}
|
||||
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
//var_dump($r->get());exit;
|
||||
@@ -395,7 +417,8 @@ class DeviceController extends mfBaseController
|
||||
|
||||
private function getDevices()
|
||||
{
|
||||
$devices = DeviceModel::getAll();
|
||||
if ($this->allowedPops === null) return [];
|
||||
$devices = DeviceModel::search(['popIds' => $this->allowedPops]);
|
||||
|
||||
foreach ($devices as $device) {
|
||||
$locationText = "";
|
||||
@@ -415,7 +438,7 @@ class DeviceController extends mfBaseController
|
||||
if ($device->last_config_backup) {
|
||||
if (time() - $device->last_config_backup <= 172800) {
|
||||
$backup = 'ok';
|
||||
if ($device->autobackup==1) {
|
||||
if ($device->autobackup == 1) {
|
||||
$backup = 'auto';
|
||||
}
|
||||
} else {
|
||||
@@ -443,5 +466,4 @@ class DeviceController extends mfBaseController
|
||||
|
||||
return $data ?? [];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,6 +136,13 @@ class DeviceModel
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists("popIds", $filter)) {
|
||||
$popids = $filter['popIds'];
|
||||
if (is_array($popids)) {
|
||||
$where .= " AND pop_id IN (" . implode(",", $popids) . ")";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
@@ -146,6 +146,11 @@ class PopNetworkModel
|
||||
$where .= " AND network_id=$networkid";
|
||||
}
|
||||
}
|
||||
if (array_key_exists("Networks", $filter)) {
|
||||
$Networks = $filter['Networks'];
|
||||
$where .= " AND network_id IN (" . implode(",", $Networks) . ")";
|
||||
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
|
||||
@@ -528,8 +528,36 @@ class TimerecordingController extends mfBaseController
|
||||
$workingHours[$workinghour->day] = $workingHours[$workinghour->day] + $whend - $whstart;
|
||||
}
|
||||
}
|
||||
$workinghourshistory = TimerecordingEmployeeWorkingHourHistoryModel::search(['user_id' => $userid]);
|
||||
if ($workinghourshistory) {
|
||||
$workingHoursHistory[2147483500]=$workingHours;
|
||||
foreach ($workinghourshistory as $workinghourhistory) {
|
||||
$whenddate = $workinghourhistory->enddate;
|
||||
$workinghourhistoryhours = json_decode($workinghourhistory->workinghours, true);
|
||||
foreach ($workinghourhistoryhours as $workinghourhistoryhour) {
|
||||
$whstart = strtotime(date('Y-m-d', time()) . " " . $workinghourhistoryhour['start'] . ":00");
|
||||
$whend = strtotime(date('Y-m-d', time()) . " " . $workinghourhistoryhour['end'] . ":00");
|
||||
if (!$workingHoursHistory[$whenddate][$workinghourhistoryhour['day']]) {
|
||||
$workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] = $whend - $whstart;
|
||||
} else {
|
||||
$workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] = $workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] + $whend - $whstart;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//check if holiday is already in the list
|
||||
foreach ($holidayDays as $key => $holidayDay) {
|
||||
if ($workingHoursHistory)
|
||||
{
|
||||
foreach ($workingHoursHistory as $whkey => $whdata) {
|
||||
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
|
||||
$timestamp = strtotime($key);
|
||||
if ($whtimestamp >= $timestamp)
|
||||
{
|
||||
$workingHours = $whdata;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (($realholiDay[$key])) {
|
||||
|
||||
} else if ($workingHours[date('w', strtotime($key))]) {
|
||||
@@ -605,6 +633,7 @@ class TimerecordingController extends mfBaseController
|
||||
|
||||
if ($plushours_timestamp > 0) {
|
||||
$return = $this->getTimerecordingsApi(5, null, null, null, $plushours_timestamp, $endtime, $userid);
|
||||
// echo $return['is'] ." ". $return['must'].PHP_EOL;
|
||||
$diffTime = $return['is'] - $return['must'];
|
||||
$plushours_now = $plushours_now + $diffTime;
|
||||
} else {
|
||||
@@ -681,6 +710,25 @@ class TimerecordingController extends mfBaseController
|
||||
$workingHours[$workinghour->day] = $workingHours[$workinghour->day] + $whend - $whstart;
|
||||
}
|
||||
}
|
||||
|
||||
$workinghourshistory = TimerecordingEmployeeWorkingHourHistoryModel::search(['user_id' => $userid]);
|
||||
if ($workinghourshistory) {
|
||||
$workingHoursHistory[2147483500]=$workingHours;
|
||||
foreach ($workinghourshistory as $workinghourhistory) {
|
||||
$whenddate = $workinghourhistory->enddate;
|
||||
$workinghourhistoryhours = json_decode($workinghourhistory->workinghours, true);
|
||||
foreach ($workinghourhistoryhours as $workinghourhistoryhour) {
|
||||
$whstart = strtotime(date('Y-m-d', time()) . " " . $workinghourhistoryhour['start'] . ":00");
|
||||
$whend = strtotime(date('Y-m-d', time()) . " " . $workinghourhistoryhour['end'] . ":00");
|
||||
if (!$workingHoursHistory[$whenddate][$workinghourhistoryhour['day']]) {
|
||||
$workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] = $whend - $whstart;
|
||||
} else {
|
||||
$workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] = $workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] + $whend - $whstart;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($holidays as $holiday) {
|
||||
$holiDay[date('Y-m-d', $holiday->timestamp)] = $holiday->description;
|
||||
}
|
||||
@@ -704,6 +752,18 @@ class TimerecordingController extends mfBaseController
|
||||
}
|
||||
$dDate = date('Y-m-d', $timestamp + $WintertimeCompensation);
|
||||
$dDay = date('w', $timestamp + $WintertimeCompensation);
|
||||
if ($workingHoursHistory)
|
||||
{
|
||||
foreach ($workingHoursHistory as $whkey => $whdata) {
|
||||
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
|
||||
if ($whtimestamp >= $timestamp)
|
||||
{
|
||||
unset($workingHours);
|
||||
$workingHours = $whdata;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) {
|
||||
$mustSeconds = $mustSeconds + $workingHours[$dDay];
|
||||
} elseif ($holiDay[$dDate]) {
|
||||
@@ -727,6 +787,18 @@ class TimerecordingController extends mfBaseController
|
||||
}
|
||||
$dDate = date('Y-m-d', $timestamp + $WintertimeCompensation);
|
||||
$dDay = date('w', $timestamp + $WintertimeCompensation);
|
||||
if ($workingHoursHistory)
|
||||
{
|
||||
foreach ($workingHoursHistory as $whkey => $whdata) {
|
||||
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
|
||||
if ($whtimestamp >= $timestamp)
|
||||
{
|
||||
unset($workingHours);
|
||||
$workingHours = $whdata;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) {
|
||||
$mustSeconds = $mustSeconds + $workingHours[$dDay];
|
||||
} elseif ($holiDay[$dDate]) {
|
||||
@@ -749,6 +821,18 @@ class TimerecordingController extends mfBaseController
|
||||
}
|
||||
$dDate = date('Y-m-d', $timestamp + $WintertimeCompensation);
|
||||
$dDay = date('w', $timestamp + $WintertimeCompensation);
|
||||
if ($workingHoursHistory)
|
||||
{
|
||||
foreach ($workingHoursHistory as $whkey => $whdata) {
|
||||
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
|
||||
if ($whtimestamp >= $timestamp)
|
||||
{
|
||||
unset($workingHours);
|
||||
$workingHours = $whdata;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) {
|
||||
$mustSeconds = $mustSeconds + $workingHours[$dDay];
|
||||
} elseif ($holiDay[$dDate]) {
|
||||
@@ -770,9 +854,23 @@ class TimerecordingController extends mfBaseController
|
||||
if (date('I', $timestamp) == 0) {
|
||||
$WintertimeCompensation = 3600;
|
||||
}
|
||||
if ($workingHoursHistory)
|
||||
{
|
||||
foreach ($workingHoursHistory as $whkey => $whdata) {
|
||||
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
|
||||
if ($whtimestamp >= $timestamp)
|
||||
{
|
||||
unset($workingHours);
|
||||
$workingHours = $whdata;
|
||||
// echo date('Y-m-d 23:59:59', $whkey).PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$dDate = date('Y-m-d', $timestamp + $WintertimeCompensation);
|
||||
$dDay = date('w', $timestamp + $WintertimeCompensation);
|
||||
if (!$holiDay[$dDate]) {
|
||||
|
||||
$mustSeconds = $mustSeconds + $workingHours[$dDay];
|
||||
}
|
||||
|
||||
@@ -828,6 +926,17 @@ class TimerecordingController extends mfBaseController
|
||||
$savecounter = 0;
|
||||
$sumdays = 0;
|
||||
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
|
||||
if ($workingHoursHistory)
|
||||
{
|
||||
foreach ($workingHoursHistory as $whkey => $whdata) {
|
||||
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
|
||||
if ($whtimestamp >= $i)
|
||||
{
|
||||
unset($workingHours);
|
||||
$workingHours = $whdata;
|
||||
}
|
||||
}
|
||||
}
|
||||
$holidaycounter = $workingHours[date("w", $i)];
|
||||
$daycheck = date("Y-m-d", $i);
|
||||
if (!$holiDay[$daycheck]) {
|
||||
@@ -877,6 +986,17 @@ class TimerecordingController extends mfBaseController
|
||||
$savecounter = 0;
|
||||
// echo $starttimecalc."<br>";
|
||||
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
|
||||
if ($workingHoursHistory)
|
||||
{
|
||||
foreach ($workingHoursHistory as $whkey => $whdata) {
|
||||
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
|
||||
if ($whtimestamp >= $i)
|
||||
{
|
||||
unset($workingHours);
|
||||
$workingHours = $whdata;
|
||||
}
|
||||
}
|
||||
}
|
||||
$holidaycounter = $workingHours[$timerecording->user_id][date("w", $i)];
|
||||
$daycheck = date("Y-m-d", $i);
|
||||
if (!$holiDay[$daycheck]) {
|
||||
|
||||
@@ -16,6 +16,47 @@ class TimerecordingEmployeeController extends mfBaseController
|
||||
}
|
||||
}
|
||||
|
||||
protected function apiAction()
|
||||
{
|
||||
$do = $this->request->do;
|
||||
$r = $this->request;
|
||||
|
||||
$data = [];
|
||||
|
||||
switch ($do) {
|
||||
case "saveWorkingHours":
|
||||
$userid = $r->userid;
|
||||
$enddate = $r->enddate;
|
||||
$workinghours = $r->workingHours;
|
||||
$data = [];
|
||||
$data['user_id'] = $userid;
|
||||
$data['enddate'] = strtotime($enddate) + 10800;
|
||||
$data['workinghours'] = json_encode($workinghours);
|
||||
$timerecordingemployeesworkinghoursHistory = TimerecordingEmployeeWorkingHourHistoryModel::create($data);
|
||||
$timerecordingemployeesworkinghoursHistory->save();
|
||||
break;
|
||||
case "deleteWorkingHours":
|
||||
$id = $r->id;
|
||||
$timerecordingemployeesworkinghoursHistory = new TimerecordingEmployeeWorkingHourHistory($id);
|
||||
if (!$timerecordingemployeesworkinghoursHistory->id || $timerecordingemployeesworkinghoursHistory->id != $id) {
|
||||
$data = ["status" => "error"];
|
||||
$this->returnJson($data);
|
||||
}
|
||||
$timerecordingemployeesworkinghoursHistory->delete();
|
||||
break;
|
||||
default:
|
||||
$data = ["status" => "error"];
|
||||
$this->returnJson($data);
|
||||
}
|
||||
if (!is_array($return) || !count($return)) {
|
||||
$data = ["status" => "error"];
|
||||
$this->returnJson($data);
|
||||
}
|
||||
$data['status'] = "OK";
|
||||
$data['result'] = $return;
|
||||
$this->returnJson($data);
|
||||
}
|
||||
|
||||
protected function indexAction()
|
||||
{
|
||||
|
||||
@@ -56,6 +97,8 @@ class TimerecordingEmployeeController extends mfBaseController
|
||||
|
||||
$this->layout()->set("timerecordingemployees", $timerecordingemployees);
|
||||
}
|
||||
$timerecordingworkinghourshistory = $this->generateWorkingHoursHistory($userid);
|
||||
$this->layout()->set("timerecordingworkinghourshistory", $timerecordingworkinghourshistory);
|
||||
$timerecordinguser = UserModel::search(['worker_id' => $userid]);
|
||||
$this->layout()->set("timerecordinguser", $timerecordinguser);
|
||||
return $this->addAction();
|
||||
@@ -202,6 +245,8 @@ class TimerecordingEmployeeController extends mfBaseController
|
||||
} else if ($mode = "add") {
|
||||
$this->layout()->setFlash("Personaladministration erfolgreich angelegt", "success");
|
||||
}
|
||||
$employee = new TimerecordingController();
|
||||
$employee->updatePlushours($r->user_id);
|
||||
$this->redirect("TimerecordingEmployee");
|
||||
}
|
||||
|
||||
@@ -219,4 +264,28 @@ class TimerecordingEmployeeController extends mfBaseController
|
||||
$this->redirect("TimerecordingEmployee");
|
||||
}
|
||||
|
||||
protected function generateWorkingHoursHistory($userid)
|
||||
{
|
||||
$days_short = TimerecordingEmployeeWorkingHourModel::$days_short;
|
||||
$TimerecordingEmployeeWorkingHourHistory = TimerecordingEmployeeWorkingHourHistoryModel::search(['user_id' => $userid]);
|
||||
foreach ($TimerecordingEmployeeWorkingHourHistory as $key => $value) {
|
||||
$workinghours = json_decode($value->workinghours, true);
|
||||
$datetimetext = "";
|
||||
$secondcounter = "";
|
||||
foreach ($workinghours as $key2 => $data) {
|
||||
$secondcounter = $secondcounter + strtotime(date("Y-m-d " . $data['end'] . ":00")) - strtotime(date("Y-m-d " . $data['start'] . ":00"));
|
||||
$datetimetext .= $days_short[$data['day']] . " " . $data['start'] . " - " . $data['end'] . "<br>";
|
||||
$datetimetext = TimerecordingEmployeeWorkingHourModel::cleardays($datetimetext);
|
||||
}
|
||||
|
||||
|
||||
$result[$value->enddate]['workinghours'] = $datetimetext;
|
||||
$result[$value->enddate]['workingtime'] = $secondcounter;
|
||||
$result[$value->enddate]['id'] = $value->id;
|
||||
}
|
||||
$employee = new TimerecordingController();
|
||||
$employee->updatePlushours($userid);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
class TimerecordingEmployeeWorkingHourHistory extends mfBaseModel
|
||||
{
|
||||
private $editor;
|
||||
private $creator;
|
||||
private $user;
|
||||
|
||||
|
||||
|
||||
public function getProperty($name)
|
||||
{
|
||||
if ($this->$name == null) {
|
||||
|
||||
if (!$this->id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($name == "creator") {
|
||||
$this->creator = mfValuecache::singleton()->get("Worker-id-" . $this->create_by);
|
||||
if ($this->creator === null) {
|
||||
$this->creator = new User($this->create_by);
|
||||
if ($this->creator->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-" . $this->create_by, $this->creator);
|
||||
}
|
||||
}
|
||||
return $this->creator;
|
||||
}
|
||||
|
||||
if ($name == "editor") {
|
||||
$this->editor = mfValuecache::singleton()->get("Worker-id-" . $this->edit_by);
|
||||
if ($this->editor === null) {
|
||||
$this->editor = new User($this->edit_by);
|
||||
if ($this->editor->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-" . $this->edit_by, $this->editor);
|
||||
}
|
||||
}
|
||||
return $this->editor;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name . "_id";
|
||||
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-" . $this->$idfield);
|
||||
if (!$this->$name) {
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
}
|
||||
|
||||
if ($this->$name->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-$name-" . $this->$name->id, $this->$name);
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
class TimerecordingEmployeeWorkingHourHistoryController extends mfBaseController
|
||||
{
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->needlogin = true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
if (!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function indexAction()
|
||||
{
|
||||
|
||||
$this->layout()->setTemplate("TimerecordingEmployeeWorkingHourHistory/Index");
|
||||
$timerecordingemployeeworkinghourhistorys = TimerecordingEmployeeWorkingHourHistoryModel::getAll();
|
||||
$this->layout()->set("timerecordingemployeeworkinghourhistorys", $timerecordingemployeeworkinghourhistorys);
|
||||
|
||||
}
|
||||
|
||||
protected function addAction()
|
||||
{
|
||||
$users=UserModel::getAll();
|
||||
$this->layout()->set("users", $users);
|
||||
|
||||
$this->layout()->setTemplate("TimerecordingEmployeeWorkingHourHistory/Form");
|
||||
|
||||
}
|
||||
|
||||
protected function editAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
|
||||
if (!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("tt History nicht gefunden", "error");
|
||||
$this->redirect("TimerecordingEmployeeWorkingHourHistory");
|
||||
}
|
||||
|
||||
$timerecordingemployeeworkinghourhistorys = new TimerecordingEmployeeWorkingHourHistory($id);
|
||||
if ($timerecordingemployeeworkinghourhistorys->id != $id) {
|
||||
$this->layout()->setFlash("tt History nicht gefunden", "error");
|
||||
$this->redirect("TimerecordingEmployeeWorkingHourHistory");
|
||||
}
|
||||
|
||||
$this->layout()->set("timerecordingemployeeworkinghourhistorys", $timerecordingemployeeworkinghourhistorys);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
protected function saveAction()
|
||||
{
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
//var_dump($r->get());exit;
|
||||
if (is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$timerecordingemployeeworkinghourhistorys = new TimerecordingEmployeeWorkingHourHistory($id);
|
||||
if (!$timerecordingemployeeworkinghourhistorys->id) {
|
||||
$this->layout()->setFlash("tt History nicht gefunden", "error");
|
||||
$this->redirect("TimerecordingEmployeeWorkingHourHistory");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['user_id'] = trim($r->user_id);
|
||||
$data['end'] = trim($r->end);
|
||||
$data['times'] = trim($r->times);
|
||||
|
||||
|
||||
if (!$data['user_id']) {
|
||||
$data['user_id']=NULL;
|
||||
}
|
||||
if (!$data['end']) {
|
||||
$data['end']=NULL;
|
||||
}
|
||||
if (!$data['times']) {
|
||||
$data['times']=NULL;
|
||||
}
|
||||
|
||||
|
||||
// var_dump($_FILES);
|
||||
// var_dump($upload);
|
||||
// exit;
|
||||
|
||||
|
||||
if ($mode == "edit") {
|
||||
$timerecordingemployeeworkinghourhistorys->update($data);
|
||||
|
||||
} else {
|
||||
$timerecordingemployeeworkinghourhistorys = TimerecordingEmployeeWorkingHourHistoryModel::create($data);
|
||||
}
|
||||
// var_dump($filestore);
|
||||
// exit;
|
||||
$id = $timerecordingemployeeworkinghourhistorys->save();
|
||||
|
||||
if (!$id) {
|
||||
$this->layout()->setFlash("tt History konnte nicht angelegt werden", "error");
|
||||
$this->redirect("TimerecordingEmployeeWorkingHourHistory");
|
||||
}
|
||||
|
||||
if ($mode == "edit") {
|
||||
$this->layout()->setFlash("tt History erfolgreich geändert", "success");
|
||||
} else if ($mode = "add") {
|
||||
$this->layout()->setFlash("tt History erfolgreich angelegt", "success");
|
||||
}
|
||||
$this->redirect("TimerecordingEmployeeWorkingHourHistory");
|
||||
}
|
||||
|
||||
|
||||
protected function deleteAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
$timerecordingemployeeworkinghourhistorys = new TimerecordingEmployeeWorkingHourHistory($id);
|
||||
if (!$timerecordingemployeeworkinghourhistorys->id || $timerecordingemployeeworkinghourhistorys->id != $id) {
|
||||
$this->layout()->setFlash("tt History nicht gefunden.", "error");
|
||||
$this->redirect("TimerecordingEmployeeWorkingHourHistory");
|
||||
}
|
||||
|
||||
$timerecordingemployeeworkinghourhistorys->delete();
|
||||
$this->redirect("TimerecordingEmployeeWorkingHourHistory");
|
||||
}
|
||||
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
class TimerecordingEmployeeWorkingHourHistoryModel
|
||||
{
|
||||
private $user_id;
|
||||
private $enddate;
|
||||
private $workinghours;
|
||||
|
||||
|
||||
public static function find($data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static function create(array $data)
|
||||
{
|
||||
$model = new TimerecordingEmployeeWorkingHourHistory();
|
||||
|
||||
foreach ($data as $field => $value) {
|
||||
if (property_exists(get_called_class(), $field)) {
|
||||
if (substr($field, 0, 5) == "vlan_" && !$value) {
|
||||
$model->$field = null;
|
||||
continue;
|
||||
}
|
||||
$model->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = mfValuecache::singleton()->get("me");
|
||||
if (!$me) {
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
mfValuecache::singleton()->set("me", $me);
|
||||
}
|
||||
|
||||
if ($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if ($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getOne($id)
|
||||
{
|
||||
if (!is_numeric($id) || !$id) {
|
||||
throw new Exception("Invalid number", 400);
|
||||
}
|
||||
$item = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("TimerecordingEmployeeWorkingHourHistory", "*", "id=$id LIMIT 1");
|
||||
if ($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new TimerecordingEmployeeWorkingHourHistory($data);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("TimerecordingEmployeeWorkingHourHistory", "*", "1=1");
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
$items[] = new TimerecordingEmployeeWorkingHourHistory($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst()
|
||||
{
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("TimerecordingEmployeeWorkingHourHistory", "*", "$where ");
|
||||
if ($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new TimerecordingEmployeeWorkingHourHistory($data);
|
||||
if ($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function search($filter)
|
||||
{
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("TimerecordingEmployeeWorkingHourHistory", "*", "$where ORDER by enddate DESC");
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
$items[] = new TimerecordingEmployeeWorkingHourHistory($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter)
|
||||
{
|
||||
$where = "1=1 ";
|
||||
|
||||
//var_dump($filter);exit;
|
||||
if (array_key_exists("user_id", $filter)) {
|
||||
$userid = $filter['user_id'];
|
||||
if (is_numeric($userid)) {
|
||||
$where .= " AND user_id=$userid";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -95,6 +95,8 @@ class TimerecordingReportController extends mfBaseController
|
||||
$workingHours[$workinghour->user_id][$workinghour->day] = $workingHours[$workinghour->user_id][$workinghour->day] + $whend - $whstart;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach ($this->holidays as $holiday) {
|
||||
$holiDay[date('Y-m-d', $holiday->timestamp)] = $holiday->timestamp;
|
||||
}
|
||||
@@ -556,13 +558,32 @@ class TimerecordingReportController extends mfBaseController
|
||||
$workingHours[$workinghour->day] = $workingHours[$workinghour->day] + $whend - $whstart;
|
||||
}
|
||||
}
|
||||
|
||||
$workinghourshistory = TimerecordingEmployeeWorkingHourHistoryModel::search(['user_id' => $user_id]);
|
||||
if ($workinghourshistory) {
|
||||
$workingHoursHistory[9732489200]=$workingHours;
|
||||
foreach ($workinghourshistory as $workinghourhistory) {
|
||||
$whenddate = $workinghourhistory->enddate;
|
||||
$workinghourhistoryhours = json_decode($workinghourhistory->workinghours, true);
|
||||
foreach ($workinghourhistoryhours as $workinghourhistoryhour) {
|
||||
$whstart = strtotime(date('Y-m-d', time()) . " " . $workinghourhistoryhour['start'] . ":00");
|
||||
$whend = strtotime(date('Y-m-d', time()) . " " . $workinghourhistoryhour['end'] . ":00");
|
||||
if (!$workingHoursHistory[$whenddate][$workinghourhistoryhour['day']]) {
|
||||
$workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] = $whend - $whstart;
|
||||
} else {
|
||||
$workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] = $workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] + $whend - $whstart;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->holidays as $holiday) {
|
||||
$holiDay[date('Y-m-d', $holiday->timestamp)] = $holiday->timestamp;
|
||||
}
|
||||
|
||||
if ($datatype == 1) {
|
||||
$kw = date('W', $dataweek);
|
||||
$year = date(o, $dataweek);
|
||||
$year = date('o', $dataweek);
|
||||
$timestamp_montag = strtotime("{$year}-W{$kw}");
|
||||
$timestamp_sonntag = strtotime("{$year}-W{$kw}-7");
|
||||
$firstdate = strtotime(date("Y-m-d", $timestamp_montag) . " 00:00:00");
|
||||
@@ -579,6 +600,16 @@ class TimerecordingReportController extends mfBaseController
|
||||
}
|
||||
$dDate = date('Y-m-d', $timestamp + $WintertimeCompensation);
|
||||
$dDay = date('w', $timestamp + $WintertimeCompensation);
|
||||
if ($workingHoursHistory)
|
||||
{
|
||||
foreach ($workingHoursHistory as $whkey => $whdata) {
|
||||
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
|
||||
if ($whtimestamp >= $timestamp)
|
||||
{
|
||||
$workingHours = $whdata;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) {
|
||||
$mustSeconds = $mustSeconds + $workingHours[$dDay];
|
||||
@@ -605,6 +636,17 @@ class TimerecordingReportController extends mfBaseController
|
||||
}
|
||||
$dDate = date('Y-m-d', $timestamp + $WintertimeCompensation);
|
||||
$dDay = date('w', $timestamp + $WintertimeCompensation);
|
||||
if ($workingHoursHistory)
|
||||
{
|
||||
foreach ($workingHoursHistory as $whkey => $whdata) {
|
||||
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
|
||||
if ($whtimestamp >= $timestamp)
|
||||
{
|
||||
$workingHours = $whdata;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) {
|
||||
$mustSeconds = $mustSeconds + $workingHours[$dDay];
|
||||
}
|
||||
@@ -628,6 +670,16 @@ class TimerecordingReportController extends mfBaseController
|
||||
}
|
||||
$dDate = date('Y-m-d', $timestamp + $WintertimeCompensation);
|
||||
$dDay = date('w', $timestamp + $WintertimeCompensation);
|
||||
if ($workingHoursHistory)
|
||||
{
|
||||
foreach ($workingHoursHistory as $whkey => $whdata) {
|
||||
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
|
||||
if ($whtimestamp >= $timestamp)
|
||||
{
|
||||
$workingHours = $whdata;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$holiDay[$dDate]) {
|
||||
$mustSeconds = $mustSeconds + $workingHours[$dDay];
|
||||
}
|
||||
@@ -756,6 +808,16 @@ class TimerecordingReportController extends mfBaseController
|
||||
$sumdays = 0;
|
||||
|
||||
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
|
||||
if ($workingHoursHistory)
|
||||
{
|
||||
foreach ($workingHoursHistory as $whkey => $whdata) {
|
||||
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
|
||||
if ($whtimestamp >= $i)
|
||||
{
|
||||
$workingHours = $whdata;
|
||||
}
|
||||
}
|
||||
}
|
||||
$holidaycounter = $workingHours[date("w", $i)];
|
||||
$daycheck = date("Y-m-d", $i);
|
||||
if (!$holiDay[$daycheck]) {
|
||||
@@ -812,6 +874,16 @@ class TimerecordingReportController extends mfBaseController
|
||||
$summcounter = 0;
|
||||
$savecounter = 0;
|
||||
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
|
||||
if ($workingHoursHistory)
|
||||
{
|
||||
foreach ($workingHoursHistory as $whkey => $whdata) {
|
||||
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
|
||||
if ($whtimestamp >= $i)
|
||||
{
|
||||
$workingHours = $whdata;
|
||||
}
|
||||
}
|
||||
}
|
||||
$holidaycounter = $workingHours[date("w", $i)];
|
||||
$isSeconds = $isSeconds + $holidaycounter;
|
||||
$summcounter = $summcounter + $holidaycounter;
|
||||
|
||||
@@ -24,6 +24,8 @@ class WarehouseArticleController extends TTCrud {
|
||||
['key' => 'actions', 'text' => 'Aktionen', 'required' => false, 'modal' => false, 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center', 'priority' => 8]]
|
||||
];
|
||||
|
||||
protected array $autocompleteColumns = ['articleNumber', 'title', 'description', 'category'];
|
||||
|
||||
protected array $additionalActions = [
|
||||
['key' => 'openHistory','title' => 'Historie','class' => 'fas fa-history text-secondary'],
|
||||
['key' => 'editDistributorEntries','title' => 'Lieferanten','class' => 'fas fa-truck text-cyan'],
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
// Hide Articles
|
||||
|
||||
|
||||
|
||||
class WarehouseEShopController extends TTCrud {
|
||||
protected string $headerTitle = 'Energie Steiermark Shop';
|
||||
protected bool $createText = false;
|
||||
@@ -12,11 +11,13 @@ class WarehouseEShopController extends TTCrud {
|
||||
protected array $columns = [
|
||||
['key' => 'title', 'text' => 'Artikel', 'priority' => 11],
|
||||
['key' => 'category', 'text' => 'Kategorie', 'table' => false],
|
||||
['key' => 'price', 'text' => 'Preis', 'table' => ['filter' => false,'sortable' => false,'class' => 'text-right']],
|
||||
['key' => 'amount', 'text' => 'Menge', 'table' => ['filter' => false,'sortable' => false,'class' => 'p-0 width-80'], 'priority' => 9],
|
||||
['key' => 'add', 'text' => 'Hinzufügen', 'table' => ['filter' => false,'sortable' => false, 'class' => 'width-120 text-center'], 'priority' => 5000]
|
||||
['key' => 'price', 'text' => 'Preis', 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-right']],
|
||||
['key' => 'amount', 'text' => 'Menge', 'table' => ['filter' => false, 'sortable' => false, 'class' => 'p-0 width-80'], 'priority' => 9],
|
||||
['key' => 'add', 'text' => 'Hinzufügen', 'table' => ['filter' => false, 'sortable' => false, 'class' => 'width-120 text-center'], 'priority' => 5000]
|
||||
];
|
||||
|
||||
protected array $permissionCheck = ['WarehouseEShop'];
|
||||
|
||||
protected array $infoMessages = [
|
||||
'create' => 'Not possible',
|
||||
'update' => 'Not possible',
|
||||
@@ -24,10 +25,6 @@ class WarehouseEShopController extends TTCrud {
|
||||
'noChanges' => 'Keine Änderungen',
|
||||
];
|
||||
|
||||
public function permissionCheck(): bool {
|
||||
return $this->user->can(["WarehouseEShop"]);
|
||||
}
|
||||
|
||||
protected function prepareCrudConfig() {
|
||||
if (!$this->user->can('WarehouseAdmin')) {
|
||||
$this->columns[2]['table'] = false;
|
||||
@@ -62,5 +59,6 @@ class WarehouseEShopController extends TTCrud {
|
||||
"total_pages" => ceil($filteredAvailable / $perPage),
|
||||
"per_page" => $perPage,
|
||||
"filtered_available" => $filteredAvailable,
|
||||
"total_rows" => $totalRows]]); }
|
||||
"total_rows" => $totalRows]]);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,8 @@ class WarehouseEShopOrderController extends TTCrud {
|
||||
['key' => 'actions', 'text' => 'Aktionen', 'required' => false, 'modal' => false, 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center']]
|
||||
];
|
||||
|
||||
protected array $permissionCheck = ['WarehouseEShop'];
|
||||
|
||||
protected array $additionalActions = [
|
||||
['key' => 'openHistory', 'title' => 'Historie', 'class' => 'fas fa-history text-primary'],
|
||||
['key' => 'showTrackingHistory', 'title' => 'Tracking Historie', 'class' => 'fas fa-truck text-primary'],
|
||||
@@ -38,10 +40,6 @@ class WarehouseEShopOrderController extends TTCrud {
|
||||
];
|
||||
//@formatter:on
|
||||
|
||||
public function permissionCheck(): bool {
|
||||
return $this->user->can(["WarehouseEShop"]);
|
||||
}
|
||||
|
||||
protected function customRowsHandler($rows): array {
|
||||
$statusToText = [
|
||||
'new' => 'Neu',
|
||||
@@ -338,6 +336,7 @@ class WarehouseEShopOrderController extends TTCrud {
|
||||
$id = WarehouseEShopOrderModel::create(['status' => 'new',
|
||||
'extRef' => $json['extRef'],
|
||||
'deliveryMode' => $json['deliveryMode'],
|
||||
'deliveryAddressAdditional' => $json['deliveryAddressAdditional'],
|
||||
'deliveryAddressName' => $json['deliveryAddressName'],
|
||||
'deliveryAddressLine' => $json['deliveryAddressLine'],
|
||||
'deliveryAddressPLZ' => $json['deliveryAddressPLZ'],
|
||||
|
||||
@@ -19,7 +19,7 @@ class WarehouseHistoryController {
|
||||
WarehouseHistoryModel::create(['table' => $mod,
|
||||
'row_id' => $postData['id'],
|
||||
'key' => $key,
|
||||
'old_value' => $currentData->$key,
|
||||
'old_value' => $currentData->$key ?? '',
|
||||
'new_value' => $value,
|
||||
'note' => '',
|
||||
'user_id' => $me->id,
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
/**
|
||||
* @property mixed|null $name
|
||||
*/
|
||||
class WarehouseOrderItem extends mfBaseModel
|
||||
class WarehouseOffer extends mfBaseModel
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
class WarehouseOfferController extends TTCrud {
|
||||
protected string $headerTitle = 'Angebote';
|
||||
protected bool $createText = false;
|
||||
|
||||
protected array $columns = [
|
||||
['key' => 'id', 'text' => 'ID', 'modal' => false],
|
||||
['key' => 'offerNumber', 'text' => 'Angebotsnummer', 'required' => true, 'modal' => false],
|
||||
['key' => 'customerNumber', 'text' => 'Kundennummer', 'required' => true, 'modal' => false],
|
||||
['key' => 'customerName', 'text' => 'Kundenname', 'required' => true, 'modal' => false],
|
||||
['key' => 'customerCity', 'text' => 'Stadt', 'required' => true, 'modal' => false],
|
||||
['key' => 'customerVAT', 'text' => 'UID', 'required' => true, 'modal' => false],
|
||||
['key' => 'editor', 'text' => 'Sachbearbeiter', 'required' => true, 'modal' => false],
|
||||
['key' => 'totalAmount', 'text' => 'Gesamtbetrag', 'required' => true, 'modal' => false],
|
||||
['key' => 'status', 'text' => 'Status', 'required' => true, 'modal' => ['type' => 'select']],
|
||||
['key' => 'create', 'text' => 'Erstellt', 'required' => true, 'modal' => false],
|
||||
['key' => 'createBy', 'text' => 'Erstellt von', 'required' => true, 'modal' => ['type' => 'select']],
|
||||
['key' => 'actions',
|
||||
'text' => 'Aktionen',
|
||||
'required' => false,
|
||||
'modal' => false,
|
||||
'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center']],
|
||||
];
|
||||
|
||||
protected array $permissionCheck = ['WarehouseAdmin'];
|
||||
|
||||
protected array $additionalActions = [
|
||||
['key' => 'openHistory', 'title' => 'Historie', 'class' => 'fas fa-history text-primary'],
|
||||
['key' => 'sendOffer', 'title' => 'Angebot senden', 'class' => 'fas fa-paper-plane text-success']
|
||||
];
|
||||
|
||||
protected array $infoMessages = [
|
||||
'create' => 'Angebot wurde erfolgreich erstellt.',
|
||||
'update' => 'Angebot wurde aktualisiert.',
|
||||
'delete' => 'Angebot wurde gelöscht',
|
||||
'noChanges' => 'Keine Änderungen',
|
||||
'sent' => 'Angebot wurde erfolgreich gesendet',
|
||||
];
|
||||
|
||||
protected function beforeCreate(): bool {
|
||||
$currentCount = WarehouseOfferModel::count(['create' => ['from' => strtotime(date('Y-01-01'))]]);
|
||||
$this->postData['offerNumber'] = 'AN' . date('Y') . '-' . str_pad($currentCount + 1, 4, '0', STR_PAD_LEFT);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function beforeUpdate($postData): bool {
|
||||
(new WarehouseHistoryController)->create($postData, $this->mod);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getHistoryAction() {
|
||||
self::returnJson((new WarehouseHistoryController)->getHistory($this->request->id, $this->mod, $this->columns));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class WarehouseOfferModel
|
||||
*
|
||||
* Represents a warehouse offer with customer details and related metadata.
|
||||
*
|
||||
* @property int $id Unique identifier for the warehouse offer
|
||||
* @property string $offerNumber Unique offer number
|
||||
* @property string $customerNumber Customer number
|
||||
* @property string $customerName Name of the customer
|
||||
* @property string $customerStreet Street address of the customer
|
||||
* @property string $customerCity City of the customer
|
||||
* @property string $customerZip Postal code of the customer
|
||||
* @property string $customerVAT VAT number of the customer
|
||||
* @property int $editor ID of the editor who last modified the offer
|
||||
* @property string $purpose Purpose of the offer
|
||||
* @property string $positions Details about positions in the offer
|
||||
* @property string $alternativePositions Details about alternative positions in the offer
|
||||
* @property float $totalDiscount Total discount applied to the offer
|
||||
* @property string $paymentTerms Payment terms for the offer
|
||||
* @property string $deliveryTerms Delivery terms for the offer
|
||||
* @property string $closingText Closing text for the offer
|
||||
* @property string $notes Additional notes for the offer
|
||||
* @property string $status Current status of the offer
|
||||
* @property float $totalAmount Total amount of the offer
|
||||
* @property int $create Timestamp of the offer creation
|
||||
* @property int $createBy ID of the user who created the offer
|
||||
*/
|
||||
class WarehouseOfferModel extends TTCrudBaseModel {
|
||||
public int $id;
|
||||
public string $offerNumber;
|
||||
public string $customerNumber;
|
||||
public string $customerName;
|
||||
public string $customerStreet;
|
||||
public string $customerCity;
|
||||
public string $customerZip;
|
||||
public string $customerVAT;
|
||||
public int $editor;
|
||||
public string $purpose;
|
||||
public string $positions;
|
||||
public string $alternativePositions;
|
||||
public float $totalDiscount;
|
||||
public string $paymentTerms;
|
||||
public string $deliveryTerms;
|
||||
public string $closingText;
|
||||
public string $notes;
|
||||
public string $status;
|
||||
public float $totalAmount;
|
||||
public int $create;
|
||||
public int $createBy;
|
||||
}
|
||||
@@ -1,110 +1,159 @@
|
||||
<?php
|
||||
//TODO: enable switching distributors in the order preview
|
||||
|
||||
class WarehouseOrderController extends TTCrud {
|
||||
protected string $headerTitle = 'Lieferantenbestellungen';
|
||||
protected bool $createText = false;
|
||||
protected array $permissionCheck = ['WarehouseAdmin'];
|
||||
|
||||
//@formatter:off
|
||||
protected array $columns = [
|
||||
['key' => 'id', 'text' => 'ID', 'modal' => false],
|
||||
['key' => 'distributorId', 'text' => 'Lieferant', 'required' => true, 'type' => 'autocomplete','table' => ['class' => 'text-nowrap', 'filter' => 'autocomplete'],'modal' => [
|
||||
'apiUrl' => 'WarehouseDistributor/autocomplete','items' => 'WarehouseDistributor/autocomplete', 'type' => 'autocomplete']],
|
||||
['key' => 'extRef', 'text' => 'Externe Referenz', 'required' => false],
|
||||
['key' => 'intRef', 'text' => 'Interne Referenz', 'required' => false],
|
||||
['key' => 'status', 'text' => 'Status', 'required' => true, 'modal' => ['type' => 'select', 'items' => [
|
||||
['value' => 'new', 'text' => 'Neu'],
|
||||
['value' => 'accepted', 'text' => 'An Lieferant übergeben'],
|
||||
['value' => 'sent', 'text' => 'Gesendet'],
|
||||
['value' => 'done', 'text' => 'Erledigt'],
|
||||
]]],
|
||||
['key' => 'trackingNumber', 'text' => 'Trackingnummer', 'required' => false],
|
||||
['key' => 'sum', 'text' => 'Summe', 'required' => true, 'modal' => false, 'table' => ['filter' => 'numberRange']],
|
||||
['key' => 'create', 'text' => 'Erstellt', 'required' => true, 'modal' => false, 'filter' => 'datetime'],
|
||||
['key' => 'createBy', 'text' => 'Erstellt von', 'required' => true, 'table' => ['filter' => 'select'], 'modal' => ['type' => 'select', 'items' => []]],
|
||||
['key' => 'id', 'text' => 'ID', 'modal' => false, 'table' => false],
|
||||
['key' => 'orderNumber', 'text' => 'Bestellnummer', 'required' => true, 'modal' => false],
|
||||
['key' => 'distributor', 'text' => 'Lieferant', 'required' => false, 'modal' => false, 'table' => ['filter' => false]],
|
||||
['key' => 'delAddrCity', 'text' => 'Stadt', 'required' => true, 'modal' => false, 'table' => false],
|
||||
['key' => 'delAddrEMail', 'text' => 'E-Mail', 'required' => true, 'modal' => false, 'table' => false],
|
||||
['key' => 'delAddrLine', 'text' => 'Adresse', 'required' => true, 'modal' => false, 'table' => false],
|
||||
['key' => 'delAddrName', 'text' => 'Name', 'required' => true, 'modal' => false, 'table' => false],
|
||||
['key' => 'delAddrPLZ', 'text' => 'PLZ', 'required' => true, 'modal' => false, 'table' => false],
|
||||
['key' => 'editor', 'text' => 'Bearbeiter', 'required' => true, 'modal' => ['type' => 'select'], 'table' => ['filter' => 'select']],
|
||||
['key' => 'note', 'text' => 'Notiz', 'required' => true, 'modal' => false, 'table' => false],
|
||||
['key' => 'sum', 'text' => 'Summe', 'required' => false, 'modal' => false, 'table' => ['class' => 'text-right']],
|
||||
['key' => 'status', 'text' => 'Status', 'required' => false, 'modal' => ['type' => 'select', 'items' => []], 'table' => ['filter' => 'select']],
|
||||
['key' => 'positions', 'text' => 'Positionen', 'required' => true, 'modal' => false, 'table' => false],
|
||||
['key' => 'extReference', 'text' => 'Externe Referenz', 'required' => true, 'modal' => false],
|
||||
['key' => 'createBy', 'text' => 'Erstellt von', 'required' => true, 'modal' => ['type' => 'select'], 'table' => ['filter' => 'select']],
|
||||
['key' => 'create', 'text' => 'Erstellt', 'required' => true, 'modal' => false],
|
||||
['key' => 'actions', 'text' => 'Aktionen', 'required' => false, 'modal' => false, 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center']],
|
||||
];
|
||||
|
||||
protected array $additionalActions = [['key' => 'openHistory', 'title' => 'Historie', 'class' => 'fas fa-history text-primary']];
|
||||
//@formatter:on
|
||||
|
||||
protected array $infoMessages = ['create' => 'Bestellung wurde erfolgreich erstellt.',
|
||||
'update' => 'Bestellung wurde aktualisiert.',
|
||||
'delete' => 'Bestellung wurde gelöscht',
|
||||
'noChanges' => 'Keine Änderungen',];
|
||||
|
||||
public function permissionCheck(): bool {
|
||||
return $this->user->can(["WarehouseEShop"]);
|
||||
}
|
||||
|
||||
protected function prepareCrudConfig() {
|
||||
// Fill Users in createBy column
|
||||
$column = array_search('createBy', array_column($this->columns, 'key'));
|
||||
$this->columns[$column]['modal']['items'] = array_map(function ($user) {
|
||||
protected function prepareCrudConfig(): void {
|
||||
$editorColumnIndex = array_search('editor', array_column($this->columns, 'key'));
|
||||
$this->columns[$editorColumnIndex]['modal']['items'] = array_map(function ($user) {
|
||||
return ['value' => intval($user->id), 'text' => $user->name];
|
||||
}, UserModel::search());
|
||||
}, UserModel::search(['employee' => true]));
|
||||
|
||||
$statusIndex = array_search('status', array_column($this->columns, 'key'));
|
||||
$this->columns[$statusIndex]['modal']['items'] = [
|
||||
['value' => 'new', 'text' => 'Neu'],
|
||||
['value' => 'accepted', 'text' => 'Akzeptiert'],
|
||||
['value' => 'ordered', 'text' => 'Bestellt'],
|
||||
['value' => 'sent', 'text' => 'Versendet'],
|
||||
['value' => 'partiallyDelivered', 'text' => 'Teilweise geliefert'],
|
||||
['value' => 'fullyDelivered', 'text' => 'Geliefert'],
|
||||
['value' => 'cancelled', 'text' => 'Storniert'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function createOrderAction() {
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
protected function beforeCreate(): bool {
|
||||
$this->postData['orderNumber'] = 'PO' . date('Y') . '-' . str_pad(WarehouseOrderModel::count(['create' => ['from' => strtotime(date('Y-01-01'))]]) + 1, 4, '0', STR_PAD_LEFT);
|
||||
|
||||
$json = json_decode(file_get_contents('php://input'), true);
|
||||
$orders = $json;
|
||||
$orderIds = [];
|
||||
|
||||
foreach ($orders as $order) {
|
||||
$distributor = $order['distributor'][0];
|
||||
$orderAmount = $order['orderAmount'];
|
||||
$orders = $order['orders'];
|
||||
|
||||
$order = [
|
||||
'distributorId' => $distributor['id'],
|
||||
'extRef' => null,
|
||||
'status' => 'new',
|
||||
'trackingNumber' => null,
|
||||
'sum' => $orderAmount,
|
||||
'create' => time(),
|
||||
'createBy' => $this->user->id,
|
||||
];
|
||||
|
||||
$orderId = WarehouseOrderModel::create($order);
|
||||
$orderIds[] = $orderId;
|
||||
|
||||
foreach ($orders as $orderItem) {
|
||||
$article = WarehouseArticleModel::get($orderItem['articleId']);
|
||||
|
||||
WarehouseEShopOrderItemModel::create([
|
||||
'orderId' => $orderId,
|
||||
'articleId' => $orderItem['articleId'],
|
||||
'quantity' => $orderItem['amount'],
|
||||
'price' => $article->cheapestPurchasePrice,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
self::returnJson(['success' => true, 'message' => $this->infoMessages['create'], 'ids' => $orderIds]);
|
||||
}
|
||||
|
||||
protected function getOrderItemsAction() {
|
||||
$orderItems = WarehouseEShopOrderItemModel::getAll(['orderId' => $this->request->id]);
|
||||
|
||||
// also get the article name of the order items
|
||||
|
||||
foreach ($orderItems as $key => $orderItem) {
|
||||
$article = WarehouseArticleModel::get($orderItem->articleId);
|
||||
$orderItem->articleName = $article->title;
|
||||
}
|
||||
|
||||
self::returnJson($orderItems);
|
||||
}
|
||||
|
||||
protected function beforeUpdate($postData): bool {
|
||||
(new WarehouseHistoryController)->create($postData, $this->mod);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getHistoryAction() {
|
||||
self::returnJson((new WarehouseHistoryController)->getHistory($this->request->id, $this->mod, $this->columns));
|
||||
protected function getArticleDistributorDataAction() {
|
||||
$articleId = $this->request->articleId;
|
||||
if ($this->request->allDistributor === 'true') self::returnJson(array_map(fn($d) => ['id' => $d->id,
|
||||
'name' => $d->name], WarehouseDistributorModel::getAll()));
|
||||
else if (!empty($articleId)) self::returnJson(array_map(fn($d) => ['id' => $d->distributorId,
|
||||
'name' => WarehouseDistributorModel::get($d->distributorId)->name,
|
||||
'purchasePrice' => $d->purchasePrice,
|
||||
'externalArticleNumber' => $d->externalArticleNumber], WarehouseArticleDistributorModel::getAll(['articleId' => $articleId])));
|
||||
else self::returnJson([]);
|
||||
}
|
||||
|
||||
protected function getByIdParse(array $order): array {
|
||||
$order['positions'] = json_decode($order['positions'], true);
|
||||
|
||||
foreach ($order['positions'] as &$position) {
|
||||
$position['distributorName'] = WarehouseDistributorModel::get($position['distributorId'])->name;
|
||||
$position['articleName'] = WarehouseArticleModel::get($position['article'])->title;
|
||||
}
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
protected function createPDFAction() {
|
||||
$order = (array) WarehouseOrderModel::get($this->request->id);
|
||||
$order['positions'] = json_decode($order['positions'], true);
|
||||
// check if all positions have the same distributor
|
||||
$distributorId = $order['positions'][0]['distributorId'];
|
||||
foreach ($order['positions'] as $key => $position) {
|
||||
if ($position['distributorId'] !== $distributorId) {
|
||||
self::returnJson(['error' => 'Die Bestellung enthält Positionen von verschiedenen Lieferanten.']);
|
||||
}
|
||||
|
||||
// we need to get the article name and distributor name for the pdf
|
||||
$position['distributorName'] = WarehouseDistributorModel::get($position['distributorId'])->name;
|
||||
$position['articleName'] = WarehouseArticleModel::get($position['article'])->title;
|
||||
|
||||
$order['positions'][$key] = $position;
|
||||
}
|
||||
|
||||
$pdf_vars = ['order' => $order,
|
||||
'distributor' => WarehouseDistributorModel::get($distributorId),
|
||||
"bank_iban" => TT_INVOICE_BANK_IBAN,
|
||||
"bank_bic" => TT_INVOICE_BANK_BIC,
|
||||
"bank_bank" => TT_INVOICE_BANK_BANK,
|
||||
"bank_owner" => TT_INVOICE_BANK_OWNER];
|
||||
|
||||
|
||||
$countryText = CountryModel::search(['id' => WarehouseDistributorModel::get($distributorId)->countryId])[0]->name;
|
||||
|
||||
$headerHtml = file_get_contents(BASEDIR . "/Layout/default/WarehouseOrder/PDF_HEADER.html");
|
||||
$headerHtml = str_replace("{{ basedir }}", BASEDIR, $headerHtml);
|
||||
$headerHtml = str_replace("{{ externalReference }}","<strong>Ihre Referenz:</strong> ". $order['extReference'], $headerHtml);
|
||||
|
||||
$headerHtml = str_replace("{{ addressLine_1 }}", WarehouseDistributorModel::get($distributorId)->name, $headerHtml);
|
||||
$headerHtml = str_replace("{{ addressLine_2 }}", WarehouseDistributorModel::get($distributorId)->address, $headerHtml);
|
||||
$headerHtml = str_replace("{{ addressLine_3 }}", WarehouseDistributorModel::get($distributorId)->plz . " " . WarehouseDistributorModel::get($distributorId)->city, $headerHtml);
|
||||
$headerHtml = str_replace("{{ addressLine_4 }}", $countryText, $headerHtml);
|
||||
|
||||
$headerHtml = str_replace("{{ billingAddressLine_1 }}", "Xinon GmbH", $headerHtml);
|
||||
$headerHtml = str_replace("{{ billingAddressLine_2 }}", "Fladnitz im Raabtal 150", $headerHtml);
|
||||
$headerHtml = str_replace("{{ billingAddressLine_3 }}", "8322 Studenzen", $headerHtml);
|
||||
$headerHtml = str_replace("{{ billingAddressLine_4 }}", "Österreich", $headerHtml);
|
||||
$headerHtml = str_replace("{{ billingAddressLine_5 }}", "einkauf@xinon.at", $headerHtml);
|
||||
$headerHtml = str_replace("{{ billingAddressLine_6 }}", "<strong>Referenz: ". $order["orderNumber"] . "</strong>", $headerHtml);
|
||||
|
||||
// if order dellAddrLine is Fladnitz im Raabtal 150 we need to set all template strings to empty
|
||||
|
||||
$chk = $order['delAddrLine'] == "Fladnitz im Raabtal 150";
|
||||
|
||||
$headerHtml = str_replace("{{ shippingAddressLine_1 }}", $chk ? "" : $order['delAddrName'], $headerHtml);
|
||||
$headerHtml = str_replace("{{ shippingAddressLine_2 }}", $chk ? "" : $order['delAddrLine'], $headerHtml);
|
||||
$headerHtml = str_replace("{{ shippingAddressLine_3 }}", $chk ? "" : $order['delAddrPLZ'] . " " . $order['delAddrCity'], $headerHtml);
|
||||
$headerHtml = str_replace("{{ shippingAddressLine_4 }}", $chk ? "" : $order['delAddrEMail'], $headerHtml);
|
||||
|
||||
|
||||
$headerFile = BASEDIR . "/var/temp/order_header-" . date("U") . "-" . rand(1000, 9999) . ".html";
|
||||
file_put_contents($headerFile, $headerHtml);
|
||||
|
||||
$footerHtml = file_get_contents(BASEDIR . "/Layout/default/WarehouseOrder/PDF_FOOTER.html");
|
||||
$footerHtml = str_replace("{{ bank_iban }}", TT_INVOICE_BANK_IBAN_FORMATTED, $footerHtml);
|
||||
$footerHtml = str_replace("{{ bank_bic }}", TT_INVOICE_BANK_BIC, $footerHtml);
|
||||
$footerHtml = str_replace("{{ bank_bank }}", TT_INVOICE_BANK_BANK, $footerHtml);
|
||||
$footerHtml = str_replace("{{ bank_owner }}", TT_INVOICE_BANK_OWNER, $footerHtml);
|
||||
|
||||
$footerFile = BASEDIR . "/var/temp/order_footer-" . date("U") . "-" . rand(1000, 9999) . ".html";
|
||||
file_put_contents($footerFile, $footerHtml);
|
||||
|
||||
|
||||
$pdf = new PdfForm("WarehouseOrder/PDF_MAIN", $pdf_vars);
|
||||
$wkhtmltopdfArgs = "--header-html $headerFile --footer-html $footerFile";
|
||||
$filename = $pdf->render($wkhtmltopdfArgs);
|
||||
|
||||
// return the pdf and die so the client sees the pdf not the filename
|
||||
header('Content-Type: application/pdf');
|
||||
header('Content-Disposition: inline; filename="' . $filename . '"');
|
||||
readfile($filename);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,28 +1,40 @@
|
||||
<?php
|
||||
//TODO: fix phpdoc
|
||||
//TODO: migration for extReference
|
||||
/**
|
||||
* @property int $id
|
||||
* @property 'new'|'accepted'|'sent'|'done' $status
|
||||
* @property 'singleAddress'|'multipleAddresses' $deliveryMode
|
||||
* @property string $deliveryAddressName
|
||||
* @property string $deliveryAddressLine
|
||||
* @property string $deliveryAddressPLZ
|
||||
* @property string $deliveryAddressCity
|
||||
* @property int $create
|
||||
* @property int $createBy
|
||||
* Class WarehouseOrderModel
|
||||
*
|
||||
* Represents a warehouse order with delivery details and related metadata.
|
||||
*
|
||||
* @property int $id Unique identifier for the warehouse order
|
||||
* @property string $orderNumber Unique order number
|
||||
* @property string $extReference External reference number
|
||||
* @property int $distributorId ID of the distributor associated with the order
|
||||
* @property string $delAddrCity City of the delivery address
|
||||
* @property string $delAddrEMail Email associated with the delivery address
|
||||
* @property string $delAddrLine Line of the delivery address
|
||||
* @property string $delAddrName Name associated with the delivery address
|
||||
* @property string $delAddrPLZ Postal code of the delivery address
|
||||
* @property int $editor ID of the editor who last modified the order
|
||||
* @property string $note Additional notes for the order
|
||||
* @property string $positions Details about positions in the order
|
||||
* @property int $create Timestamp of the order creation
|
||||
* @property int $createBy ID of the user who created the order
|
||||
*/
|
||||
|
||||
// id, distributorId, intRef, extRef, status, trackingNumber, create, createBy
|
||||
class WarehouseOrderModel extends TTCrudBaseModel {
|
||||
public int $id;
|
||||
public string $orderNumber;
|
||||
public string $extReference;
|
||||
public int $distributorId;
|
||||
public ?string $intRef;
|
||||
public ?string $extRef;
|
||||
public float $sum;
|
||||
public string $status;
|
||||
public ?string $trackingNumber;
|
||||
public string $delAddrCity;
|
||||
public string $delAddrEMail;
|
||||
public string $delAddrLine;
|
||||
public string $delAddrName;
|
||||
public string $delAddrPLZ;
|
||||
public int $editor;
|
||||
public string $note;
|
||||
public string $positions;
|
||||
public int $create;
|
||||
public int $createBy;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $orderId
|
||||
* @property int $articleId
|
||||
* @property int $quantity
|
||||
* @property int $price
|
||||
*/
|
||||
|
||||
class WarehouseOrderItemModel extends TTCrudBaseModel {
|
||||
public int $id;
|
||||
public int $orderId;
|
||||
public int $articleId;
|
||||
public int $quantity;
|
||||
public float $price;
|
||||
}
|
||||
@@ -41,7 +41,11 @@ class WarehouseOrderRequestController extends TTCrud {
|
||||
'table' => ['filter' => 'select'],
|
||||
'modal' => ['type' => 'select', 'items' => []]],
|
||||
['key' => 'warehouseLocation', 'text' => 'Lagerort', 'required' => false, 'type' => 'varchar'],
|
||||
['key' => 'canceled', 'text' => 'Storniert', 'required' => false, 'modal' => ['visible' => false, 'type' => 'select', 'items' => [['value' => 0, 'text' => 'Nein'], ['value' => 1, 'text' => 'Ja']]], 'table' => ['filter' => 'select']],
|
||||
['key' => 'canceled',
|
||||
'text' => 'Storniert',
|
||||
'required' => false,
|
||||
'modal' => ['visible' => false, 'type' => 'select', 'items' => [['value' => 0, 'text' => 'Nein'], ['value' => 1, 'text' => 'Ja']]],
|
||||
'table' => ['filter' => 'select']],
|
||||
['key' => 'note', 'text' => 'Notiz', 'required' => false, 'type' => 'textarea'],
|
||||
['key' => 'actions',
|
||||
'text' => 'Aktionen',
|
||||
@@ -50,6 +54,8 @@ class WarehouseOrderRequestController extends TTCrud {
|
||||
'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center']],
|
||||
];
|
||||
|
||||
protected array $permissionCheck = ['WarehouseUser'];
|
||||
|
||||
protected array $additionalActions = [['key' => 'openHistory', 'title' => 'Historie', 'class' => 'fas fa-history text-primary']];
|
||||
|
||||
protected array $infoMessages = ['create' => 'Bestellwunsch wurde erstellt.',
|
||||
@@ -59,10 +65,6 @@ class WarehouseOrderRequestController extends TTCrud {
|
||||
|
||||
protected array $additionalJSVariables = ['BASE_URL' => '/WarehouseOrderRequest', 'WAREHOUSE_ADMIN' => true];
|
||||
|
||||
public function permissionCheck(): bool {
|
||||
return $this->user->can(["WarehouseUser"]);
|
||||
}
|
||||
|
||||
protected function prepareCrudConfig() {
|
||||
// Fill Users in createBy column
|
||||
$userArray = array_map(function ($user) {
|
||||
@@ -96,10 +98,10 @@ class WarehouseOrderRequestController extends TTCrud {
|
||||
}
|
||||
|
||||
protected function customAutoCompleteWare($value) {
|
||||
if (!is_numeric($value)) return [ 'id' => $value, 'title' => $value];
|
||||
if (!is_numeric($value)) return ['id' => $value, 'title' => $value];
|
||||
|
||||
$article = WarehouseArticleModel::get(intval($value));
|
||||
return [ 'id' => $article->id, 'title' => $article->title ];
|
||||
return ['id' => $article->id, 'title' => $article->title];
|
||||
}
|
||||
|
||||
protected function beforeUpdate($postData): bool {
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
class WarehouseProject extends mfBaseModel {
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class WarehouseProjectController extends TTCrud {
|
||||
protected string $headerTitle = 'Projekte';
|
||||
protected string $createText = 'Neues Projekt erstellen';
|
||||
|
||||
//@formatter:off
|
||||
protected array $columns = [
|
||||
['key' => 'title', 'text' => 'Titel', 'required' => true, 'table' => ['class' => 'text-nowrap', 'priority' => 9]],
|
||||
['key' => 'description', 'text' => 'Beschreibung', 'required' => true, 'table' => ['class' => 'text-nowrap']],
|
||||
['key' => 'createBy', 'text' => 'Erstellt von', 'required' => true, 'type' => 'select', 'table' => ['class' => 'text-nowrap', 'filter' => 'select'], 'modal' => ['items' => [], 'type' => 'select']],
|
||||
['key' => 'create', 'text' => 'Erstellt am', 'required' => true, 'table' => ['filter' => 'date', 'class' => 'text-center']],
|
||||
['key' => 'address', 'text' => 'Adresse', 'required' => true, 'type' => 'autocomplete', 'table' => ['class' => 'text-nowrap', 'filter' => false], 'modal' => ['apiUrl' => '/Address/api?do=findAddress', 'items' => '/Address/api?do=findAddress', 'type' => 'autocomplete']],
|
||||
['key' => 'status', 'text' => 'Status', 'required' => true, 'table' => ['filter' => 'select'], 'modal' => [ 'type' => 'select', 'items' => [ ['value' => 'erstellt', 'text' => 'Erstellt'], ['value' => 'in_bearbeitung', 'text' => 'In Bearbeitung'], ['value' => 'erledigt', 'text' => 'Erledigt'], ['value' => 'verrechnet', 'text' => 'Verrechnet']]]]
|
||||
];
|
||||
|
||||
|
||||
protected array $additionalActions = [
|
||||
];
|
||||
|
||||
protected array $infoMessages = [
|
||||
'create' => 'Projekt wurde erstellt',
|
||||
'update' => 'Projekt wurde aktualisiert',
|
||||
'delete' => 'Projekt wurde gelöscht',
|
||||
'noChanges' => 'Keine Änderungen',
|
||||
];
|
||||
//@formatter:on
|
||||
|
||||
public function prepareCrudConfig() {
|
||||
$users = array_map(function($user) {
|
||||
return ['value' => $user->id, 'text' => $user->name];
|
||||
}, UserModel::search(['employee' => true]));
|
||||
|
||||
$this->columns[1]['modal']['items'] = $users;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
class WarehouseProjectModel extends TTCrudBaseModel {
|
||||
public int $id;
|
||||
public string $title;
|
||||
public string $description;
|
||||
public string $startDate;
|
||||
public string $endDate;
|
||||
public string $status;
|
||||
public string $priority;
|
||||
|
||||
public int $assignedTo;
|
||||
public int $createBy;
|
||||
public int $create;
|
||||
}
|
||||
Reference in New Issue
Block a user