26 include(
"inc/common.php");
40 if(!empty($_GET[
'result'])) {
42 $resultIdentifier = $_GET[
'result'];
43 if($loggedInUser->isResultAvailable($resultIdentifier)) {
44 $smarty->assign(
'resultIdentifier',$resultIdentifier);
49 if (isset($_GET[
'id']) && ($_GET[
'id'] ==
'new')) {
50 if (isset($_GET[
'editsec']) && ctype_digit($_GET[
'editsec'])) {
55 $sponsor[
'name'] = htmlSpecialChars(trim($_POST[
'name']), ENT_QUOTES);
56 if (empty($sponsor[
'name'])) {
57 $errors[] =
"Geben Sie einen gültigen 'Namen' an!";
60 $sponsor[
'street'] = htmlSpecialChars(trim($_POST[
'street']), ENT_QUOTES);
61 if (empty($sponsor[
'street'])) {
62 $errors[] =
"Geben Sie eine gültige 'Straße' an!";
65 $sponsor[
'houseNumber'] = htmlSpecialChars(trim($_POST[
'houseNumber']), ENT_QUOTES);
66 if (empty($sponsor[
'houseNumber'])) {
67 $errors[] =
"Geben Sie eine gültige 'Haunummer' an!";
70 $sponsor[
'zipCode'] = htmlSpecialChars(trim($_POST[
'zipCode']), ENT_QUOTES);
71 if (empty($sponsor[
'zipCode'])) {
72 $errors[] =
"Geben Sie eine gültige 'PLZ' an!";
75 $sponsor[
'town'] = htmlSpecialChars(trim($_POST[
'town']), ENT_QUOTES);
76 if (empty($sponsor[
'town'])) {
77 $errors[] =
"Geben Sie eine gültige 'Stadt' an!";
80 $sponsor[
'country'] = htmlSpecialChars(trim($_POST[
'country']), ENT_QUOTES);
81 if (empty($sponsor[
'country'])) {
82 $errors[] =
"Geben Sie eine gültiges 'Land' an!";
85 $sponsor[
'statusId'] = $_POST[
'statusId'];
86 if ($sponsor[
'statusId'] == -1) {
87 $errors[] =
"Geben Sie einen gültigen 'Status' an!";
94 if (!empty($newSponsorId)) {
96 $_GET[
'id'] = (string)$newSponsorId;
97 $successes[] =
"Der Sponsor wurde erfolgreich hinzugefügt";
100 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
107 $smarty->assign(
'edit', array(
'section' => 1,
108 'lockDuration' => -1));
110 $smarty->assign(
'isNewSponsor', TRUE);
111 $smarty->assign(
'sponsor', $sponsor);
121 $smarty->assign(
'edit', array(
'section' => 1,
122 'lockDuration' => -1));
126 $smarty->assign(
'isNewSponsor', TRUE);
127 $smarty->assign(
'sponsor',FALSE);
134 if(isset($_GET[
'id']) && ctype_digit($_GET[
'id'])) {
136 if (isset($_GET[
'ajax']) && ctype_digit($_GET[
'ajax'])) {
137 if ($_GET[
'ajax'] == 1) {
139 if (isset($_GET[
'editsec']) && ctype_digit($_GET[
'editsec'])) {
144 if(isset($_GET[
'unlocksec']) && ctype_digit($_GET[
'unlocksec'])) {
153 if(isset($_REQUEST[
'ref'])&&(strcmp(trim($_REQUEST[
'ref']),
'search')==0)) {
154 $backToSearch = TRUE;
155 $smarty->assign(
'backToSearch',TRUE);
157 $backToSearch = FALSE;
158 $smarty->assign(
'backToSearch',FALSE);
162 if(!empty($_POST[
'deleteSponsor'][$_GET[
'id']]) && ctype_digit($_POST[
'deleteSponsor'][$_GET[
'id']])) {
163 $sponsorIdToDelete = $_POST[
'deleteSponsor'][$_GET[
'id']];
164 if ($sponsorIdToDelete == $_GET[
'id']) {
167 if($result === FALSE) {
168 $errors[] =
"Es ist ein Datenbankfehler aufgetreten!";
169 }
else if($result===-1){
170 $errors[] =
"Löschen fehlgeschlagen, da mindestens ein Bereich momentan von einem anderen Benutzer bearbeitet wird.";
171 }
else if($result===-2){
172 $errors[] =
"Es ist ein Datenbankfehler aufgetreten!";
174 $url =
"sponsors".($backToSearch ?
'_search':
'').
".php?sort=1&dir=0".(isset($resultIdentifier)?
'&result='.$resultIdentifier:
'');
191 if ($sponsor[
'cars']) {
192 foreach ($sponsor[
'cars'] as &$car) {
205 if(isset($_GET[
'editsec']) && ctype_digit($_GET[
'editsec'])) {
210 $smarty->assign(
'edit', array(
'section' => $_GET[
'editsec'],
213 switch ($_GET[
'editsec']) {
219 if (!empty($_POST)) {
221 $newSponsorName = htmlSpecialChars(trim($_POST[
'name']), ENT_QUOTES);
222 if (!empty($newSponsorName)) {
223 if(strcmp($sponsor[
'name'], $newSponsorName) != 0) {
224 $sponsor[
'name'] = $newSponsorName;
225 $changed[] =
"Der 'Name' wurde erfolgreich aktualisiert.";
229 $sponsor[
'name'] = $newSponsorName;
230 $errors[] =
"Geben Sie einen gültigen 'Namen' an!";
233 $newSponsorStreet = htmlSpecialChars(trim($_POST[
'street']), ENT_QUOTES);
234 if (!empty($newSponsorStreet)) {
235 if (strcmp($sponsor[
'street'], $newSponsorStreet) != 0) {
236 $sponsor[
'street'] = $newSponsorStreet;
237 $changed[] =
"Die 'Straße' wurde erfolgreich aktualisiert.";
240 $sponsor[
'street'] = $newSponsorStreet;
241 $errors[] =
"Geben Sie eine gültige 'Straße' an!";
244 $newSponsorHouseNumber = htmlSpecialChars(trim($_POST[
'houseNumber']), ENT_QUOTES);
245 if (!empty($newSponsorHouseNumber)) {
246 if (strcmp($sponsor[
'houseNumber'], $newSponsorHouseNumber) != 0) {
247 $sponsor[
'houseNumber'] = $newSponsorHouseNumber;
248 $changed[] =
"Die 'Hausnummer' wurde erfolgreich aktualisiert.";
252 $sponsor[
'houseNumber'] = $newSponsorHouseNumber;
253 $errors[] =
"Geben Sie eine gültige 'Hausnummer' an!";
256 $newSponsorZipCode = htmlSpecialChars(trim($_POST[
'zipCode']), ENT_QUOTES);
257 if (!empty($newSponsorZipCode)) {
258 if (strcmp($sponsor[
'zipCode'], $newSponsorZipCode) != 0) {
259 $sponsor[
'zipCode'] = $newSponsorZipCode;
260 $changed[] =
"Die 'PLZ' wurde erfolgreich aktualisiert.";
264 $sponsor[
'zipCode'] = $newSponsorZipCode;
265 $errors[] =
"Geben Sie eine gültige 'PLZ' an!";
268 $newSponsorTown = htmlSpecialChars(trim($_POST[
'town']), ENT_QUOTES);
269 if (!empty($newSponsorTown)) {
270 if (strcmp($sponsor[
'town'], $newSponsorTown) != 0) {
271 $sponsor[
'town'] = $newSponsorTown;
272 $changed[] =
"Die 'Stadt' wurde erfolgreich aktualisiert.";
276 $sponsor[
'town'] = $newSponsorTown;
277 $errors[] =
"Geben Sie eine gültige 'Stadt' an!";
280 $newSponsorCountry = htmlSpecialChars(trim($_POST[
'country']), ENT_QUOTES);
281 if (!empty($newSponsorCountry)) {
282 if (strcmp($sponsor[
'country'], $newSponsorCountry) != 0) {
283 $sponsor[
'country'] = $newSponsorCountry;
284 $changed[] =
"Das 'Land' wurde erfolgreich aktualisiert.";
288 $sponsor[
'country'] = $newSponsorCountry;
289 $errors[] =
"Geben Sie ein gültiges 'Land' an!";
293 if (strcmp($sponsor[
'website'], $newSponsorWebsite) != 0) {
294 $sponsor[
'website'] = $newSponsorWebsite;
295 $changed[] =
"Die 'Webseite' wurde erfolgreich aktualisiert.";
298 $newSponsorStatusId = $_POST[
'statusId'];
299 if ($newSponsorStatusId != -1) {
300 if (strcmp($sponsor[
'statusId'], $newSponsorStatusId) != 0) {
301 $sponsor[
'statusId'] = $newSponsorStatusId;
302 $changed[] =
"Der 'Status' wurde erfolgreich aktualisiert.";
304 if (!empty($statusDetails)) {
305 $sponsor[
'statusName'] = $statusDetails[
'name'];
310 $sponsor[
'statusId'] = $newSponsorStatusId;
311 $errors[] =
"Wählen Sie einen gültigen 'Status' aus!";
314 if (!empty($_FILES[
'sponsorLogo'][
'name'])) {
316 if ($_FILES[
'sponsorLogo'][
'error'] == 0) {
317 if (($_FILES[
"sponsorLogo"][
"type"] ==
"image/gif")
318 || ($_FILES[
"sponsorLogo"][
"type"] ==
"image/jpeg")
319 || ($_FILES[
"sponsorLogo"][
"type"] ==
"image/jpg")
320 || ($_FILES[
"sponsorLogo"][
"type"] ==
"image/pjpeg")
321 || ($_FILES[
"sponsorLogo"][
"type"] ==
"image/x-png")
322 || ($_FILES[
"sponsorLogo"][
"type"] ==
"image/png")) {
328 if (file_exists(
ABS_PATH.$sponsor[
'sponsorLogo']) && !empty($sponsor[
'sponsorLogo'])) {
330 unlink(
ABS_PATH.$sponsor[
'sponsorLogo']);
332 $pathParts = pathinfo($sponsor[
'sponsorLogo']);
333 $files = glob(
ABS_PATH.$pathParts[
'dirname'].
'/_scaled/'.$pathParts[
'filename'].
'*.'.$pathParts[
'extension']);
334 foreach($files as $file){
335 if (file_exists($file)) {
340 $pathParts = pathinfo($_FILES[
'sponsorLogo'][
'name']);
342 $newFilename =
prepareFilename($pathParts[
'filename']).
'_'.uniqid().
'.'.$pathParts[
'extension'];
344 if (move_uploaded_file($_FILES[
'sponsorLogo'][
'tmp_name'],
ABS_PATH.
'data/logos/'.$newFilename)) {
345 $sponsor[
'sponsorLogo'] =
'data/logos/'.$newFilename;
346 $changed[] =
"Der 'Logo' wurde erfolgreich aktualisiert.";
349 $errors[] =
"Fehler beim internen Verarbeiten des 'Logos'.";
355 $errors[] =
"Das aktuelle Bildformat wird nicht unterstützt! (Folgende Formate werden unterstützt: *.jpg, *.gif, *.png)";
359 $errors[] =
"Unbekannter Fehler beim Upload des 'Logos'.";
363 if (isset($_POST[
'sponsorLogoDelete']) && ctype_digit($_POST[
'sponsorLogoDelete'])) {
364 if ($_POST[
'sponsorLogoDelete'] == 1) {
366 if (file_exists(
ABS_PATH.$sponsor[
'sponsorLogo']) && !empty($sponsor[
'sponsorLogo'])) {
368 unlink(
ABS_PATH.$sponsor[
'sponsorLogo']);
370 $pathParts = pathinfo($sponsor[
'sponsorLogo']);
371 $files = glob(
ABS_PATH.$pathParts[
'dirname'].
'/_scaled/'.$pathParts[
'filename'].
'*.'.$pathParts[
'extension']);
372 foreach($files as $file){
373 if (file_exists($file)) {
378 $sponsor[
'sponsorLogo'] =
'';
379 $changed[] =
"Das 'Logo' wurde erfolgreich gelöscht.";
385 $newSponsorLastContactDateTimestamp = strToTime(trim($_POST[
'lastContactDateTimestamp']));
386 if ($newSponsorLastContactDateTimestamp != FALSE) {
387 if (strcmp($sponsor[
'lastContactDateTimestamp'], $newSponsorLastContactDateTimestamp) != 0) {
388 $sponsor[
'lastContactDateTimestamp'] = $newSponsorLastContactDateTimestamp;
389 $changed[] =
"Das 'Datum' des letzten Kontaktes wurde erfolgreich aktualisiert.";
393 if (!empty($_POST[
'lastContactDateTimestamp'])) {
394 $errors[] =
"Geben Sie ein gültiges 'Datum' des letzten Kontaktes im Format: 'dd.mm.yyyy hh:mm' an!";
399 $newSponsorLastContactPerson = htmlSpecialChars(trim($_POST[
'lastContactPerson']), ENT_QUOTES);
400 if (strcmp($sponsor[
'lastContactPerson'], $newSponsorLastContactPerson) != 0) {
401 $sponsor[
'lastContactPerson'] = $newSponsorLastContactPerson;
402 $changed[] =
"Die 'Person' des letzten Kontaktes wurde erfolgreich aktualisiert.";
405 $newSponsorHints = htmlSpecialChars(trim($_POST[
'hints']), ENT_QUOTES);
406 if (strcmp($sponsor[
'hints'], $newSponsorHints) != 0) {
407 $sponsor[
'hints'] = $newSponsorHints;
408 $changed[] =
"Die 'Hinweise' wurden erfolgreich aktualisiert.";
415 if (!empty($changed)) {
422 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
440 if (!empty($_POST)) {
441 if(isset($_POST[
'cnt']) && ctype_digit($_POST[
'cnt'])) {
444 $curCnt = ($sponsor[
'contactPersons'] === FALSE) ? 0 : count($sponsor[
'contactPersons']);
445 if ($_POST[
'cnt'] == $curCnt) {
446 for ($i = 1; $i <= $curCnt; $i++) {
447 if (!empty($_POST[
'id_'.$i])) {
448 $id = $_POST[
'id_'.$i];
451 if(isset($_POST[
'delete_'.$i]) && ctype_digit($_POST[
'delete_'.$i])) {
452 if($_POST[
'delete_'.$i] == $id) {
453 $sponsorContactPersonsIdsToDelete[] = $id;
460 $newContactPersonName = htmlSpecialChars(trim($_POST[
'name_'.$i]), ENT_QUOTES);
461 if (!empty($newContactPersonName)) {
462 if (strcmp($sponsor[
'contactPersons'][$i-1][
'name'], $newContactPersonName) != 0) {
463 $sponsor[
'contactPersons'][$i-1][
'name'] = $newContactPersonName;
464 $changed[] =
"Ansprechpartner #".$i.
": Der 'Name' wurde erfolgreich aktualisiert.";
468 $sponsor[
'contactPersons'][$i-1][
'name'] = $newContactPersonName;
469 $errors[] =
"Ansprechpartner #".$i.
": Geben Sie einen gültigen 'Namen' an!";
472 $newContactPersonEmail = trim($_POST[
'email_'.$i]);
474 if (strcmp($sponsor[
'contactPersons'][$i-1][
'email'], $newContactPersonEmail) != 0) {
475 $sponsor[
'contactPersons'][$i-1][
'email'] = $newContactPersonEmail;
476 $changed[] =
"Ansprechpartner #".$i.
": Die 'E-Mail-Adresse' wurde erfolgreich aktualisiert.";
480 $sponsor[
'contactPersons'][$i-1][
'email'] = $newContactPersonEmail;
481 $errors[] =
"Ansprechpartner #".$i.
": Geben Sie eine gültige 'E-Mail-Adresse' an!";
484 $newContactPersonPhone = trim($_POST[
'phone_'.$i]);
486 if (strcmp($sponsor[
'contactPersons'][$i-1][
'phone'], $newContactPersonPhone) != 0) {
487 $sponsor[
'contactPersons'][$i-1][
'phone'] = $newContactPersonPhone;
488 $changed[] =
"Ansprechpartner #".$i.
": Die 'Telefonnummer' wurde erfolgreich aktualisiert.";
492 $sponsor[
'contactPersons'][$i-1][
'phone'] = $newContactPersonPhone;
493 $errors[] =
"Ansprechpartner #".$i.
": Geben Sie eine gültige 'Telefonnummer' an!";
496 $newContactPersonMobile = trim($_POST[
'mobile_'.$i]);
497 if (!empty($newContactPersonMobile)) {
499 if (strcmp($sponsor[
'contactPersons'][$i-1][
'mobile'], $newContactPersonMobile) != 0) {
500 $sponsor[
'contactPersons'][$i-1][
'mobile'] = $newContactPersonMobile;
501 $changed[] =
"Ansprechpartner #".$i.
": Die 'Handynummer' wurde erfolgreich aktualisiert.";
505 $sponsor[
'contactPersons'][$i-1][
'mobile'] = $newContactPersonMobile;
506 $errors[] =
"Ansprechpartner #".$i.
": Geben Sie eine gültige 'Handynummer' an!";
510 $newContactPersonPosition = htmlSpecialChars(trim($_POST[
'position_'.$i]), ENT_QUOTES);
511 if (!empty($newContactPersonPosition)) {
512 if (strcmp($sponsor[
'contactPersons'][$i-1][
'position'], $newContactPersonPosition) != 0) {
513 $sponsor[
'contactPersons'][$i-1][
'position'] = $newContactPersonPosition;
514 $changed[] =
"Ansprechpartner #".$i.
": Die 'Position' wurde erfolgreich aktualisiert.";
519 $newContactPersonNewsletter = $_POST[
'newsletter_'.$i];
520 if ($sponsor[
'contactPersons'][$i-1][
'newsletter'] != $newContactPersonNewsletter) {
521 $sponsor[
'contactPersons'][$i-1][
'newsletter'] = $newContactPersonNewsletter;
522 $changed[] =
"Ansprechpartner #".$i.
": Die 'Newsletter'-Option wurde erfolgreich aktualisiert.";
528 $errors[] =
"Ein unbekannter Fehler ist aufgetreten!";
534 $errors[] =
"Ein unbekannter Fehler ist aufgetreten!__";
538 $errors[] =
"Ein unbekannter Fehler ist aufgetreten!";
542 if(isset($_POST[
'newContactPerson']) && ctype_digit($_POST[
'newContactPerson'])) {
543 if ($_POST[
'newContactPerson'] == 1) {
545 $newContactPerson[
'sponsor_id'] = $sponsor[
'id'];
547 $newContactPerson[
'name'] = htmlSpecialChars(trim($_POST[
'name_new']), ENT_QUOTES);
548 if (empty($newContactPerson[
'name'])) {
549 $errors [] =
"neuer Ansprechpartner: Geben Sie einen gültigen 'Namen' an!";
552 $newContactPerson[
'email'] = trim($_POST[
'email_new']);
554 $errors[] =
"neuer Ansprechpartner: Geben Sie eine gültige 'E-Mail-Adresse' an!";
557 $newContactPerson[
'phone'] = trim($_POST[
'phone_new']);
559 $errors[] =
"neuer Ansprechpartner: Geben Sie eine gültige 'Telefonnummer' an!";
562 $newContactPerson[
'mobile'] = trim($_POST[
'mobile_new']);
563 if (!empty($newContactPerson[
'mobile'])) {
565 $errors[] =
"neuer Ansprechpartner: Geben Sie eine gültige 'Handynummer' an!";
569 $newContactPerson[
'position'] = htmlSpecialChars(trim($_POST[
'position_new']), ENT_QUOTES);
572 $newContactPerson[
'newsletter'] = $_POST[
'newsletter_new'];
575 $smarty->assign(
'newContactPerson', $newContactPerson);
584 if (!empty($sponsorContactPersonsIdsToDelete)) {
585 $newContactPersonsArray = array();
586 for ($i = 0; $i < count($sponsor[
'contactPersons']); $i++) {
587 if (in_array($sponsor[
'contactPersons'][$i][
'id'], $sponsorContactPersonsIdsToDelete)) {
589 $successes [] =
"Ansprechpartner #".($i+1).
" wurde erfolgreich gelöscht.";
592 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
596 $newContactPersonsArray[] = $sponsor[
'contactPersons'][$i];
599 $sponsor[
'contactPersons'] = $newContactPersonsArray;
604 if (isset($newContactPerson)) {
606 if (is_array($sponsor[
'contactPersons'])) {
608 array_push($sponsor[
'contactPersons'], $newContactPerson);
612 $sponsor[
'contactPersons'] = array($newContactPerson);
614 $successes[] =
"Ansprechpartner erfolgreich hinzugefügt";
617 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
623 if (!empty($changed)) {
629 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
651 if (!empty($_POST)) {
652 if(isset($_POST[
'cnt']) && ctype_digit($_POST[
'cnt'])) {
654 $curCnt = ($sponsor[
'productionFacilities'] === FALSE) ? 0 : count($sponsor[
'productionFacilities']);
656 if ($_POST[
'cnt'] == $curCnt) {
658 for ($i = 1; $i <= $curCnt; $i++) {
659 if (!empty($_POST[
'id_'.$i])) {
660 $id = $_POST[
'id_'.$i];
663 if(isset($_POST[
'delete_'.$i]) && ctype_digit($_POST[
'delete_'.$i])) {
664 if($_POST[
'delete_'.$i] == $id) {
665 $sponsorProductionFacilityIdsToDelete[] = $id;
671 $newProductionFacilityId = $_POST[
'productionFacilityId_'.$i];
672 if ($newProductionFacilityId != -1) {
673 if (strcmp($sponsor[
'productionFacilities'][$i-1][
'productionFacilityId'], $newProductionFacilityId) != 0) {
674 $sponsor[
'productionFacilities'][$i-1][
'productionFacilityId'] = $newProductionFacilityId;
676 $sponsor[
'productionFacilities'][$i-1][
'name'] = $productionFacilityDetails[
'output'];
677 $changed[] =
"Fertigungsmöglichkeit #".$i.
": Der 'Name' wurde erfolgreich aktualisiert.";
681 $errors[] =
"Fertigungsmöglichkeit #".$i.
": Wählen Sie einen gültigen 'Namen' aus!";
682 $sponsor[
'productionFacilities'][$i-1][
'productionFacilityId'] = $newProductionFacilityId;
685 $newProductionFacilityComments = htmlSpecialChars(trim($_POST[
'comments_'.$i]), ENT_QUOTES);
686 if (strcmp($sponsor[
'productionFacilities'][$i-1][
'comments'], $newProductionFacilityComments) != 0) {
687 $sponsor[
'productionFacilities'][$i-1][
'comments'] = $newProductionFacilityComments;
688 $changed[] =
"Fertigungsmöglichkeit #".$i.
": Die 'Bemerkung' wurde erfolgreich aktualisiert.";
692 $errors[] =
"Ein unbekannter Fehler ist aufgetreten!";
698 $errors[] =
"Ein unbekannter Fehler ist aufgetreten!";
702 $errors[] =
"Ein unbekannter Fehler ist aufgetreten!";
707 if(isset($_POST[
'newProductionFacility']) && ctype_digit($_POST[
'newProductionFacility'])) {
708 if ($_POST[
'newProductionFacility'] == 1) {
710 $newSponsorProductionFacility[
'comments'] = htmlSpecialChars(trim($_POST[
'comments_new']), ENT_QUOTES);
712 $newSponsorProductionFacility[
'sponsor_id'] = $sponsor[
'id'];
714 $newSponsorProductionFacility[
'productionFacilityId'] = $_POST[
'productionFacilityId_new'];
715 if ($newSponsorProductionFacility[
'productionFacilityId'] == -1) {
716 $smarty->assign(
'newSponsorProductionFacility', $newSponsorProductionFacility);
717 $errors[] =
"neue Fertigungsmöglichkeit: Wählen Sie einen gültigen 'Namen' aus!";
726 $newProductionFacilitiesArray = array();
727 if (!empty($sponsorProductionFacilityIdsToDelete)) {
728 for ($i = 0; $i < count($sponsor[
'productionFacilities']); $i++) {
729 if (in_array($sponsor[
'productionFacilities'][$i][
'id'], $sponsorProductionFacilityIdsToDelete)) {
731 $successes [] =
"Fertigungsmöglichkeit #".($i+1).
" wurde erfolgreich gelöscht.";
733 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
737 $newProductionFacilitiesArray[] = $sponsor[
'productionFacilities'][$i];
741 $sponsor[
'productionFacilities'] = $newProductionFacilitiesArray;
745 if (isset($newSponsorProductionFacility)) {
748 $newSponsorProductionFacility[
'name'] = $productionFacilityDetails[
'name'];
750 if (is_array($sponsor[
'productionFacilities'])) {
752 array_push($sponsor[
'productionFacilities'], $newSponsorProductionFacility);
756 $sponsor[
'productionFacilities'] = array($newSponsorProductionFacility);
758 $successes[] =
"Fertigungsmöglichkeit erfolgreich hinzugefügt";
761 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
767 if (!empty($changed)) {
773 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
798 if (!empty($_POST)) {
800 if(!empty($_POST[
'deleteCar']) && !empty($_POST[
'deleteCar'][$_GET[
'carId']]) && ctype_digit($_POST[
'deleteCar'][$_GET[
'carId']])) {
801 $sponsorCarIdToDelete = $_POST[
'deleteCar'][$_GET[
'carId']];
802 if ($sponsorCarIdToDelete == $_GET[
'carId']) {
805 $successes[] =
'Das Sponsorenfahrzeug wurde erfolgreich gelöscht!';
807 foreach ($sponsor[
'cars'] as $key => $theCar){
808 if ($theCar[
'id'] == $sponsorCarIdToDelete) {
809 unset($sponsor[
'cars'][$key]);
813 unset($_GET[
'carId']);
819 $errors[] =
"Es ist ein Datenbankfehler aufgetreten!";
826 if(!empty($_POST[
'cars'])) {
827 if (is_array($_POST[
'cars'])) {
829 foreach ($_POST[
'cars'] as $carKey => $curPostedCar) {
830 if (is_numeric($carKey)) {
834 $carIdx = $carKey - 1;
835 $curCar = &$sponsor[
'cars'][$carIdx];
838 $newCategorieId = $curPostedCar[
'categoryId'];
839 if ($newCategorieId != -1) {
840 if (strcmp($curCar[
'categoryId'], $newCategorieId) != 0) {
841 $curCar[
'categoryId'] = $newCategorieId;
842 $changedCarDetails[$carIdx][] =
"Fahrzeug '".$curCar[
'name'].
"': Die 'Kategorie' wurde erfolgreich aktualisiert.";
844 if (!empty($categoryDetails)) {
845 $curCar[
'categoryName'] = $categoryDetails[
'name'];
850 $curCar[
'categoryId'] = $newCategorieId;
851 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': Wählen Sie eine gültige 'Kategorie' aus!";
855 $newCodetermination = $curPostedCar[
'codetermination'];
856 if ($newCodetermination != -1) {
857 if (strcmp($curCar[
'codetermination'], $newCodetermination) != 0) {
858 $curCar[
'codetermination'] = $newCodetermination;
859 $changedCarDetails[$carIdx][] =
"Fahrzeug '".$curCar[
'name'].
"': Das 'Mitbestimmungsrecht' wurde erfolgreich aktualisiert.";
863 $curCar[
'codetermination'] = $newCodetermination;
864 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': Wählen Sie ein gültiges 'Mitbestimmungsrecht' aus!";
868 $newHints = htmlSpecialChars(trim($curPostedCar[
'hints']), ENT_QUOTES);
869 if (strcmp($curCar[
'hints'], $newHints) != 0) {
870 $curCar[
'hints'] = $newHints;
871 $changedCarDetails[$carIdx][] =
"Fahrzeug '".$curCar[
'name'].
"': Die 'Hinweise' wurden erfolgreich aktualisiert.";
876 foreach ($curPostedCar[
'events'] as $eventKey => $curPostedEvent) {
877 if (is_numeric($eventKey)) {
881 $eventIdx = $eventKey - 1;
882 $curEvent = &$curCar[
'events'][$eventIdx];
885 if(isset($curPostedEvent[
'delete']) && ctype_digit($curPostedEvent[
'delete'])) {
886 if ($curPostedEvent[
'delete'] == $curEvent[
'id']) {
887 $eventsToDelete[$carIdx][] = $curEvent[
'id'];
893 $newTimestamp = strToTime(trim($curPostedEvent[
'timestamp']));
894 if ($newTimestamp != FALSE) {
895 if (strcmp($curEvent[
'timestamp'], $newTimestamp) != 0) {
896 $curEvent[
'timestamp'] = $newTimestamp;
897 $changedEvents[$carIdx][] =
"Fahrzeug '".$curCar[
'name'].
"': Event: #".$eventKey.
" Das 'Datum' wurde erfolgreich aktualisiert.";
902 $curEvent[
'timestamp'] =
'';
903 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': Event: #".$eventKey.
" Geben Sie ein gültiges 'Datum' im Format: 'dd.mm.yyyy' an!";
907 $newEventName = htmlSpecialChars(trim($curPostedEvent[
'event']), ENT_QUOTES);
908 if (!empty($newEventName)) {
909 if (strcmp($curEvent[
'event'], $newEventName) != 0) {
910 $curEvent[
'event'] = $newEventName;
911 $changedEvents[$carIdx][] =
"Fahrzeug '".$curCar[
'name'].
"': Event: #".$eventKey.
" Die 'Veranstaltung' wurde erfolgreich aktualisiert.";
915 $curEvent[
'event'] = $newEventName;
916 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': Event: #".$eventKey.
" Geben Sie eine gültige 'Veranstaltung' an!";
920 if ((!empty($curPostedEvent[
'isNew'])) && ($curPostedEvent[
'isNew'] == 1)) {
924 $curCar[
'newEvent'][
'timestamp'] = strToTime(trim($curPostedEvent[
'timestamp']));
925 if (empty($curCar[
'newEvent'][
'timestamp'])) {
927 $curCar[
'newEvent'][
'timestamp'] =
'';
928 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': neues Event: Geben Sie ein gültiges 'Datum' im Format: 'dd.mm.yyyy' an!";
932 $curCar[
'newEvent'][
'event'] = htmlSpecialChars(trim($curPostedEvent[
'event']), ENT_QUOTES);
933 if (empty($curCar[
'newEvent'][
'event'])) {
934 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': neues Event: Geben Sie eine gültige 'Veranstaltung' an!";
936 $curCar[
'newEvent'][
'sponsorCarId'] = $curCar[
'id'];
942 foreach ($curPostedCar[
'financialDonations'] as $financialDonationKey => $curPostedFinancialDonation) {
943 if (is_numeric($financialDonationKey)) {
947 $financialDonationIdx = $financialDonationKey - 1;
948 $curFinancialDonation = &$curCar[
'financialDonations'][$financialDonationIdx];
951 if(isset($curPostedFinancialDonation[
'delete']) && ctype_digit($curPostedFinancialDonation[
'delete'])) {
952 if ($curPostedFinancialDonation[
'delete'] == $curFinancialDonation[
'id']) {
953 $financialDonationsToDelete[$carIdx][] = $curFinancialDonation[
'id'];
959 $newTimestamp = strToTime(trim($curPostedFinancialDonation[
'timestamp']));
960 if ($newTimestamp != FALSE) {
961 if (strcmp($curFinancialDonation[
'timestamp'], $newTimestamp) != 0) {
962 $curFinancialDonation[
'timestamp'] = $newTimestamp;
963 $changedFinancialDonations[$carIdx][] =
"Fahrzeug '".$curCar[
'name'].
"': Finanzspende: #".$financialDonationKey.
" Das 'Datum' wurde erfolgreich aktualisiert.";
968 $curFinancialDonation[
'timestamp'] =
'';
969 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': Finanzspende: #".$financialDonationKey.
" Geben Sie ein gültiges 'Datum' im Format: 'dd.mm.yyyy' an!";
973 $newAmount = str_replace(array(
' ',
'EUR',
'€',
','), array(
'',
'',
'',
'.'), trim($curPostedFinancialDonation[
'amount']));
974 if (is_numeric($newAmount)) {
975 if (floatval($curFinancialDonation[
'amount']) != floatval($newAmount)) {
976 $curFinancialDonation[
'amount'] = floatval($newAmount);
977 $changedFinancialDonations[$carIdx][] =
"Fahrzeug '".$curCar[
'name'].
"': Finanzspende: #".$financialDonationKey.
" Der 'Betrag' wurde erfolgreich aktualisiert.";
981 $curFinancialDonation[
'amount'] = $newAmount;
982 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': Finanzspende: #".$financialDonationKey.
" Geben Sie einen gültigen 'Betrag' an!";
986 if ((!empty($curPostedFinancialDonation[
'isNew'])) && ($curPostedFinancialDonation[
'isNew'] == 1)) {
990 $curCar[
'newFinancialDonation'][
'timestamp'] = strToTime(trim($curPostedFinancialDonation[
'timestamp']));
991 if (empty($curCar[
'newFinancialDonation'][
'timestamp'])) {
993 $curCar[
'newFinancialDonation'][
'timestamp'] =
'';
994 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': neue Finanzspende: Geben Sie ein gültiges 'Datum' im Format: 'dd.mm.yyyy' an!";
998 $amount = str_replace(array(
' ',
'EUR',
'€',
','), array(
'',
'',
'',
'.'), trim($curPostedFinancialDonation[
'amount']));
999 if (!is_numeric($amount)) {
1000 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': neue Finanzspende: Geben Sie einen gültigen 'Betrag' an!";
1001 $curCar[
'newFinancialDonation'][
'amount'] = $amount;
1004 $curCar[
'newFinancialDonation'][
'amount'] = floatval($amount);
1006 $curCar[
'newFinancialDonation'][
'sponsorCarId'] = $curCar[
'id'];
1012 foreach ($curPostedCar[
'materialDonations'] as $materialDonationKey => $curPostedMaterialDonation) {
1013 if (is_numeric($materialDonationKey)) {
1017 $materialDonationIdx = $materialDonationKey - 1;
1018 $curMaterialDonation = &$curCar[
'materialDonations'][$materialDonationIdx];
1021 if(isset($curPostedMaterialDonation[
'delete']) && ctype_digit($curPostedMaterialDonation[
'delete'])) {
1022 if ($curPostedMaterialDonation[
'delete'] == $curMaterialDonation[
'id']) {
1023 $materialDonationsToDelete[$carIdx][] = $curMaterialDonation[
'id'];
1029 $newTimestamp = strToTime(trim($curPostedMaterialDonation[
'timestamp']));
1030 if ($newTimestamp != FALSE) {
1031 if (strcmp($curMaterialDonation[
'timestamp'], $newTimestamp) != 0) {
1032 $curMaterialDonation[
'timestamp'] = $newTimestamp;
1033 $changedMaterialDonations[$carIdx][] =
"Fahrzeug '".$curCar[
'name'].
"': Sachspende: #".$materialDonationKey.
" Das 'Datum' wurde erfolgreich aktualisiert.";
1038 $curMaterialDonation[
'timestamp'] =
'';
1039 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': Sachspende: #".$materialDonationKey.
" Geben Sie ein gültiges 'Datum' im Format: 'dd.mm.yyyy' an!";
1043 $newObject = htmlSpecialChars(trim($curPostedMaterialDonation[
'object']), ENT_QUOTES);
1044 if (!empty($newObject)) {
1045 if (strcmp($curMaterialDonation[
'object'], $newObject) != 0) {
1046 $curMaterialDonation[
'object'] = $newObject;
1047 $changedMaterialDonations[$carIdx][] =
"Fahrzeug '".$curCar[
'name'].
"': Sachspende: #".$materialDonationKey.
" Der 'Gegenstand' wurde erfolgreich aktualisiert.";
1051 $curMaterialDonation[
'object'] = $newObject;
1052 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': Sachspende: #".$materialDonationKey.
" Geben Sie einen gültigen 'Gegenstand' an!";
1056 $newAmount = str_replace(array(
' ',
'EUR',
'€',
','), array(
'',
'',
'',
'.'), trim($curPostedMaterialDonation[
'amount']));
1057 if (is_numeric($newAmount)) {
1058 if (floatval($curMaterialDonation[
'amount']) != floatval($newAmount)) {
1059 $curMaterialDonation[
'amount'] = floatval($newAmount);
1060 $changedMaterialDonations[$carIdx][] =
"Fahrzeug '".$curCar[
'name'].
"': Sachspende: #".$materialDonationKey.
" Der 'Wert' wurde erfolgreich aktualisiert.";
1064 $curMaterialDonation[
'amount'] = $newAmount;
1065 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': Sachspende: #".$materialDonationKey.
" Geben Sie einen gültigen 'Wert' an!";
1069 if ((!empty($curPostedMaterialDonation[
'isNew'])) && ($curPostedMaterialDonation[
'isNew'] == 1)) {
1073 $curCar[
'newMaterialDonation'][
'timestamp'] = strToTime(trim($curPostedMaterialDonation[
'timestamp']));
1074 if (empty($curCar[
'newMaterialDonation'][
'timestamp'])) {
1076 $curCar[
'newMaterialDonation'][
'timestamp'] =
'';
1077 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': neue Sachspende: Geben Sie ein gültiges 'Datum' im Format: 'dd.mm.yyyy' an!";
1080 $curCar[
'newMaterialDonation'][
'object'] = htmlSpecialChars(trim($curPostedMaterialDonation[
'object']), ENT_QUOTES);
1081 if (empty($curCar[
'newMaterialDonation'][
'object'])) {
1082 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': neues Sachspende: Geben Sie einen gültigen 'Gegenstand' an!";
1085 $amount = str_replace(array(
' ',
'EUR',
'€',
','), array(
'',
'',
'',
'.'), trim($curPostedMaterialDonation[
'amount']));
1086 if (!is_numeric($amount)) {
1087 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': neue Sachspende: Geben Sie einen gültigen 'Wert' an!";
1088 $curCar[
'newMaterialDonation'][
'amount'] = $amount;
1091 $curCar[
'newMaterialDonation'][
'amount'] = floatval($amount);
1093 $curCar[
'newMaterialDonation'][
'sponsorCarId'] = $curCar[
'id'];
1100 foreach ($curPostedCar[
'producedParts'] as $producedPartKey => $curPostedProducedPart) {
1101 if (is_numeric($producedPartKey)) {
1105 $producedPartIdx = $producedPartKey - 1;
1106 $curProducedPart = &$curCar[
'producedParts'][$producedPartIdx];
1109 if(isset($curPostedProducedPart[
'delete']) && ctype_digit($curPostedProducedPart[
'delete'])) {
1110 if ($curPostedProducedPart[
'delete'] == $curProducedPart[
'id']) {
1111 $producedPartsToDelete[$carIdx][] = $curProducedPart[
'id'];
1117 $newTimestamp = strToTime(trim($curPostedProducedPart[
'timestamp']));
1118 if ($newTimestamp != FALSE) {
1119 if (strcmp($curProducedPart[
'timestamp'], $newTimestamp) != 0) {
1120 $curProducedPart[
'timestamp'] = $newTimestamp;
1121 $changedProducedParts[$carIdx][] =
"Fahrzeug '".$curCar[
'name'].
"': gefertigtes Teil #".$producedPartKey.
": Das 'Datum' wurde erfolgreich aktualisiert.";
1126 $curProducedPart[
'timestamp'] =
'';
1127 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': gefertigtes Teil #".$producedPartKey.
": Geben Sie ein gültiges 'Datum' im Format: 'dd.mm.yyyy' an!";
1131 $newName = htmlSpecialChars(trim($curPostedProducedPart[
'name']), ENT_QUOTES);
1132 if (!empty($newName)) {
1133 if (strcmp($curProducedPart[
'name'], $newName) != 0) {
1134 $curProducedPart[
'name'] = $newName;
1135 $changedProducedParts[$carIdx][] =
"Fahrzeug '".$curCar[
'name'].
"': gefertigtes Teil #".$producedPartKey.
": Der 'Gegenstand' wurde erfolgreich aktualisiert.";
1139 $curProducedPart[
'name'] = $newName;
1140 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': gefertigtes Teil #".$producedPartKey.
": Geben Sie einen gültigen 'Gegenstand' an!";
1144 $newValue = str_replace(array(
' ',
'EUR',
'€',
','), array(
'',
'',
'',
'.'), trim($curPostedProducedPart[
'value']));
1145 if (is_numeric($newValue)) {
1146 if (floatval($curProducedPart[
'value']) != floatval($newValue)) {
1147 $curProducedPart[
'value'] = floatval($newValue);
1148 $changedProducedParts[$carIdx][] =
"Fahrzeug '".$curCar[
'name'].
"': gefertigtes Teil #".$producedPartKey.
": Der 'Wert' wurde erfolgreich aktualisiert.";
1152 $curProducedPart[
'value'] = $newValue;
1153 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': gefertigtes Teil #".$producedPartKey.
": Geben Sie einen gültigen 'Wert' an!";
1157 if ((!empty($curPostedProducedPart[
'isNew'])) && ($curPostedProducedPart[
'isNew'] == 1)) {
1161 $curCar[
'newProducedPart'][
'timestamp'] = strToTime(trim($curPostedProducedPart[
'timestamp']));
1162 if (empty($curCar[
'newProducedPart'][
'timestamp'])) {
1164 $curCar[
'newProducedPart'][
'timestamp'] =
'';
1165 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': neues gefertigtes Teil: Geben Sie ein gültiges 'Datum' im Format: 'dd.mm.yyyy' an!";
1168 $curCar[
'newProducedPart'][
'name'] = htmlSpecialChars(trim($curPostedProducedPart[
'name']), ENT_QUOTES);
1169 if (empty($curCar[
'newProducedPart'][
'name'])) {
1170 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': neues gefertigtes Teil: Geben Sie einen gültigen 'Gegenstand' an!";
1173 $value = str_replace(array(
' ',
'EUR',
'€',
','), array(
'',
'',
'',
'.'), trim($curPostedProducedPart[
'value']));
1174 if (!is_numeric($value)) {
1175 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': neue gefertigtes Teil: Geben Sie einen gültigen 'Wert' an!";
1176 $curCar[
'newProducedPart'][
'value'] = $value;
1179 $curCar[
'newProducedPart'][
'value'] = floatval($value);
1181 $curCar[
'newProducedPart'][
'sponsorCarId'] = $curCar[
'id'];
1188 foreach ($curPostedCar[
'attachments'] as $attachmentKey => $curPostedAttachment) {
1189 if (is_numeric($attachmentKey)) {
1193 $attachmentIdx = $attachmentKey - 1;
1194 $curAttachment = &$curCar[
'attachments'][$attachmentIdx];
1197 if(isset($curPostedAttachment[
'delete']) && ctype_digit($curPostedAttachment[
'delete'])) {
1198 if ($curPostedAttachment[
'delete'] == $curAttachment[
'id']) {
1199 $attachmentsToDelete[$carIdx][] = $curAttachment[
'id'];
1205 $newFileName = htmlSpecialChars(trim($curPostedAttachment[
'filename']), ENT_QUOTES);
1206 if (!empty($newFileName)) {
1207 if (strcmp($curAttachment[
'filename'], $newFileName) != 0) {
1208 $curAttachment[
'filename'] = $newFileName;
1209 $changedAttachments[$carIdx][] =
"Fahrzeug '".$curCar[
'name'].
"': Anlage #".$attachmentKey.
": Der 'Dateiname' wurde erfolgreich aktualisiert.";
1213 $curAttachment[
'filename'] = $newFileName;
1214 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': Anlage #".$producedPartKey.
": Geben Sie einen gültigen 'Dateinamen' an!";
1219 if ((!empty($curPostedAttachment[
'isNew'])) && ($curPostedAttachment[
'isNew'] == 1)) {
1223 $curCar[
'newAttachment'][
'filename'] = htmlSpecialChars(trim($curPostedAttachment[
'filename']), ENT_QUOTES);
1224 if (empty($curCar[
'newAttachment'][
'filename'])) {
1225 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': neue Anlage: Geben Sie einen gültigen 'Dateinamen' an!";
1229 $postedAttachmentFileName = $_FILES[
'cars'][
'name'][$carKey][
'attachments'][
'new'][
'file'];
1230 $postedAttachmentError = $_FILES[
'cars'][
'error'][$carKey][
'attachments'][
'new'][
'file'];
1231 $postedAttachmentTmpName = $_FILES[
'cars'][
'tmp_name'][$carKey][
'attachments'][
'new'][
'file'];
1233 if (!empty($postedAttachmentFileName)) {
1234 if ($postedAttachmentError == 0) {
1237 $pathParts = pathinfo($postedAttachmentFileName);
1238 $newFilename =
prepareFilename($pathParts[
'filename']).
'_'.uniqid().
'.'.$pathParts[
'extension'];
1239 if (move_uploaded_file($postedAttachmentTmpName,
ABS_PATH.
'data/attachments/'.$newFilename)) {
1240 $curCar[
'newAttachment'][
'path'] =
'data/attachments/'.$newFilename;
1243 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': neue Anlage: Es ist ein Fehler beim internen Verarbeiten der 'Anlage' aufgetreten!";
1248 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': neue Anlage: Es ist ein unbekannter Fehler beim Upload aufgetreten!";
1253 $errors[] =
"Fahrzeug '".$curCar[
'name'].
"': neue Anlage: Geben Sie eine gültige 'Datei' an!";
1256 $curCar[
'newAttachment'][
'sponsorCarId'] = $curCar[
'id'];
1264 if(isset($curPostedCar[
'id']) && ctype_digit($curPostedCar[
'id'])) {
1265 if($curPostedCar[
'id'] != -1) {
1266 $sponsor[
'newCar'][
'id'] = $curPostedCar[
'id'];
1274 $errors[] =
"Ein unbekannter Fehler ist aufgetreten!";
1278 $errors[] =
"Ein unbekannter Fehler ist aufgetreten!";
1284 foreach ($_POST[
'cars'] as $carKey => $curPostedCar) {
1286 if (!is_numeric($carKey)) {
1291 $carIdx = $carKey - 1;
1292 $curCar = &$sponsor[
'cars'][$carIdx];
1295 if (!empty($changedCarDetails[$carIdx])) {
1301 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
1306 $newEventsArray = array();
1307 if (!empty($eventsToDelete[$carIdx])) {
1308 for ($i = 0; $i < count($curCar[
'events']); $i++) {
1309 if (in_array($curCar[
'events'][$i][
'id'], $eventsToDelete[$carIdx])) {
1311 $successes[] =
"Fahrzeug '".$curCar[
'name'].
"': Die 'Veranstaltung ".$curCar[
'events'][$i][
'event'].
"' wurde erfolgreich gelöscht.";
1313 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
1317 $newEventsArray[] = $curCar[
'events'][$i];
1321 $curCar[
'events'] = $newEventsArray;
1324 if (!empty($changedEvents[$carIdx])) {
1330 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
1334 if (isset($curCar[
'newEvent'])) {
1336 if (is_array($curCar[
'events'])) {
1338 array_push($curCar[
'events'], $curCar[
'newEvent']);
1342 $curCar[
'events'] = array($curCar[
'newEvent']);
1344 $successes[] =
"Fahrzeug '".$curCar[
'name'].
"': Die 'Veranstaltung' wurde erfolgreich hinzugefügt.";
1347 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
1352 $newFinancialDonationsArray = array();
1353 if (!empty($financialDonationsToDelete[$carIdx])) {
1354 for ($i = 0; $i < count($curCar[
'financialDonations']); $i++) {
1355 if (in_array($curCar[
'financialDonations'][$i][
'id'], $financialDonationsToDelete[$carIdx])) {
1357 $successes[] =
"Fahrzeug '".$curCar[
'name'].
"': Die 'Finanzspende #".($i+1).
"' wurde erfolgreich gelöscht.";
1359 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
1363 $newFinancialDonationsArray[] = $curCar[
'financialDonations'][$i];
1367 $curCar[
'financialDonations'] = $newFinancialDonationsArray;
1370 if (!empty($changedFinancialDonations[$carIdx])) {
1376 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
1380 if (isset($curCar[
'newFinancialDonation'])) {
1382 if (is_array($curCar[
'financialDonations'])) {
1384 array_push($curCar[
'financialDonations'], $curCar[
'newFinancialDonation']);
1388 $curCar[
'financialDonations'] = array($curCar[
'newFinancialDonation']);
1390 $successes[] =
"Fahrzeug '".$curCar[
'name'].
"': Die 'Finanzspende' wurde erfolgreich hinzugefügt.";
1393 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
1399 $newMaterialDonationsArray = array();
1400 if (!empty($materialDonationsToDelete[$carIdx])) {
1401 for ($i = 0; $i < count($curCar[
'materialDonations']); $i++) {
1402 if (in_array($curCar[
'materialDonations'][$i][
'id'], $materialDonationsToDelete[$carIdx])) {
1404 $successes[] =
"Fahrzeug '".$curCar[
'name'].
"': Die 'Sachspende #".($i+1).
"' wurde erfolgreich gelöscht.";
1406 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
1410 $newMaterialDonationsArray[] = $curCar[
'materialDonations'][$i];
1414 $curCar[
'materialDonations'] = $newMaterialDonationsArray;
1417 if (!empty($changedMaterialDonations[$carIdx])) {
1423 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
1427 if (isset($curCar[
'newMaterialDonation'])) {
1429 if (is_array($curCar[
'materialDonations'])) {
1431 array_push($curCar[
'materialDonations'], $curCar[
'newMaterialDonation']);
1435 $curCar[
'materialDonations'] = array($curCar[
'newMaterialDonation']);
1437 $successes[] =
"Fahrzeug '".$curCar[
'name'].
"': Die 'Sachspende' wurde erfolgreich hinzugefügt.";
1440 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
1446 $newProducedPartsArray = array();
1447 if (!empty($producedPartsToDelete[$carIdx])) {
1448 for ($i = 0; $i < count($curCar[
'producedParts']); $i++) {
1449 if (in_array($curCar[
'producedParts'][$i][
'id'], $producedPartsToDelete[$carIdx])) {
1451 $successes[] =
"Fahrzeug '".$curCar[
'name'].
"': Das 'gefertigte Teil #".($i+1).
"' wurde erfolgreich gelöscht.";
1453 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
1457 $newProducedPartsArray[] = $curCar[
'producedParts'][$i];
1461 $curCar[
'producedParts'] = $newProducedPartsArray;
1464 if (!empty($changedProducedParts[$carIdx])) {
1470 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
1474 if (isset($curCar[
'newProducedPart'])) {
1476 if (is_array($curCar[
'producedParts'])) {
1478 array_push($curCar[
'producedParts'], $curCar[
'newProducedPart']);
1482 $curCar[
'producedParts'] = array($curCar[
'newProducedPart']);
1484 $successes[] =
"Fahrzeug '".$curCar[
'name'].
"': Das 'gefertigte Teil' wurde erfolgreich hinzugefügt.";
1487 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
1493 $newAttachmentsArray = array();
1494 if (!empty($attachmentsToDelete[$carIdx])) {
1495 for ($i = 0; $i < count($curCar[
'attachments']); $i++) {
1496 if (in_array($curCar[
'attachments'][$i][
'id'], $attachmentsToDelete[$carIdx])) {
1499 if (file_exists(
ABS_PATH.$curCar[
'attachments'][$i][
'path'])) {
1500 unlink(
ABS_PATH.$curCar[
'attachments'][$i][
'path']);
1502 $successes[] =
"Fahrzeug '".$curCar[
'name'].
"': Die 'Anlage ".$curCar[
'attachments'][$i][
'filename'].
"' wurde erfolgreich gelöscht.";
1504 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
1508 $newAttachmentsArray[] = $curCar[
'attachments'][$i];
1512 $curCar[
'attachments'] = $newAttachmentsArray;
1516 if (!empty($changedAttachments[$carIdx])) {
1522 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
1527 if (isset($curCar[
'newAttachment'])) {
1529 if (is_array($curCar[
'attachments'])) {
1531 array_push($curCar[
'attachments'], $curCar[
'newAttachment']);
1535 $curCar[
'attachments'] = array($curCar[
'newAttachment']);
1537 $successes[] =
"Fahrzeug '".$curCar[
'name'].
"': Das 'Anlage' wurde erfolgreich hinzugefügt.";
1540 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
1546 if (isset($sponsor[
'newCar'])) {
1547 $newSponsorCarId =
addSponsorCar($sponsor[
'newCar'][
'id'], $sponsor[
'id']);
1548 if ($newSponsorCarId) {
1550 if (is_array($sponsor[
'cars'])) {
1558 $successes[] =
"Das Fahrzeug wurde erfolgreich hinzugefügt.";
1560 kdsort($sponsor[
'cars'], array_search(
'carId', array_keys($sponsor[
'cars'][0])), SORT_DESC);
1562 $smarty->assign(
'clickedCarId', $newSponsorCarId);
1565 foreach($possibleNewCars as $key => $possibleNewCar) {
1566 if (empty($sponsor[
'cars'])) {
1569 foreach ($sponsor[
'cars'] as $_car) {
1570 if ($_car[
'carId'] == $possibleNewCar[
'id']) {
1571 unset($possibleNewCars[$key]);
1575 $smarty->assign(
'possibleNewCars', $possibleNewCars);
1578 $errors[] =
'Es ist ein Datenbankfehler aufgetreten!';
1585 if (isset($sponsor[
'newCar'])) {
1593 $smarty->assign(
'edit', NULL);
1599 if(isset($_GET[
'carId']) && ctype_digit($_GET[
'carId'])) {
1600 $smarty->assign(
'clickedCarId', $_GET[
'carId']);
1612 $errors [] =
'Dieser Bereich wird gerade von einem anderen Benutzer bearbeitet und ist gesperrt!';
1620 if (!empty($lastChange)) {
1621 $sponsor[
'lastChangeDateTimestamp'] = $lastChange[
'timestamp'];
1622 $sponsor[
'lastChangeUserId'] = $lastChange[
'userId'];
1623 $sponsor[
'lastChangeUserName'] = $lastChange[
'userName'];
1628 $smarty->assign(
'lastChangesForEditSections',$lastChangesForEditSections);
1631 $smarty->assign(
'sponsor',$sponsor);
1639 if(isset($resultIdentifier)&&$loggedInUser->isResultAvailable($resultIdentifier)) {
1641 $sponsorIds = $loggedInUser->loadResult($resultIdentifier);
1642 if(!$sponsorIds==FALSE) {
1643 $sponsors = array();
1644 foreach($sponsorIds as $sponsorId) {
1649 if(!empty($sponsors)) {
1650 foreach ($sponsors as &$sponsor) {
1657 $smarty->assign(
'resultIdentifier',$resultIdentifier);
1666 foreach ($sponsors as &$sponsor) {
1674 $filterActive = FALSE;
1677 if(isset($_POST[
'selectStatus']) && $_POST[
'selectStatus']!=-1) {
1678 if(ctype_digit($_POST[
'selectStatus'])) {
1680 $statusId = $_POST[
'selectStatus'];
1682 $smarty->assign(
'selectedStatus',$statusId);
1683 if(is_array($sponsors)) {
1685 foreach($sponsors as $id => $sponsor) {
1686 if(!empty($sponsor[
'statusId'])) {
1688 if(!($statusId == $sponsor[
'statusId'])) {
1690 unset($sponsors[$id]);
1693 unset($sponsors[$id]);
1696 $filterActive = $filterActive || TRUE;
1699 $smarty->assign(
'selectedStatus',-1);
1702 $smarty->assign(
'selectedStatus',-1);
1706 if(isset($_POST[
'selectCategory']) && $_POST[
'selectCategory']!=-1) {
1707 if(ctype_digit($_POST[
'selectCategory'])) {
1710 $categoryId = $_POST[
'selectCategory'];
1711 $smarty->assign(
'selectedCategory',$categoryId);
1712 $filterActive = $filterActive || TRUE;
1714 $smarty->assign(
'selectedCategory',-1);
1717 $smarty->assign(
'selectedCategory',-1);
1722 if(isset($_POST[
'selectProductionFacility'])&&$_POST[
'selectProductionFacility']!=-1) {
1724 if(ctype_digit($_POST[
'selectProductionFacility'])) {
1726 $productionFacilityId = $_POST[
'selectProductionFacility'];
1728 $smarty->assign(
'selectedFacility',$productionFacilityId);
1729 if(is_array($sponsors)) {
1731 foreach($sponsors as $id => $sponsor) {
1733 if(!empty($sponsor[
'productionFacilities'])) {
1734 $cFacilities = $sponsor[
'productionFacilities'];
1737 foreach($cFacilities as $facility) {
1738 if($productionFacilityId == $facility[
'productionFacilityId']) {
1746 unset($sponsors[$id]);
1750 unset($sponsors[$id]);
1753 $filterActive = $filterActive || TRUE;
1757 $smarty->assign(
'selectedFacility',-1);
1761 if(isset($_POST[
'selectCar'])&&$_POST[
'selectCar']!=-1) {
1763 if(ctype_digit($_POST[
'selectCar'])) {
1765 $carId = $_POST[
'selectCar'];
1767 $smarty->assign(
'selectedCar',$carId);
1768 if(is_array($sponsors)) {
1770 foreach($sponsors as $id => $sponsor) {
1772 if(!empty($sponsor[
'cars'])) {
1773 $cCars = $sponsor[
'cars'];
1776 foreach($cCars as $car) {
1777 if($carId == $car[
'id']) {
1781 if(isset($_POST[
'selectCategory']) && $_POST[
'selectCategory']!=-1) {
1782 if(ctype_digit($_POST[
'selectCategory'])) {
1784 $categoryId = $_POST[
'selectCategory'];
1786 foreach ($sponsorCarsDetails as $details) {
1787 if(strcmp($details[
'name'],$car[
'name'])==0) {
1788 $contains = $contains && ($details[
'categoryId']==$categoryId);
1799 unset($sponsors[$id]);
1802 unset($sponsors[$id]);
1806 $filterActive = $filterActive || TRUE;
1809 $smarty->assign(
'selectedCar',-1);
1815 header(
"Cache-Control: max-age=600");
1816 foreach($sponsors as $sponsor) {
1817 $tmp[] = $sponsor[
'id'];
1820 $resultIdentifier = $loggedInUser->storeFilterResult($tmp);
1821 $smarty->assign(
'resultIdentifier',$resultIdentifier);
1825 if(isset($_GET[
'sort']) && ctype_digit($_GET[
'sort']) && !empty($sponsors)) {
1826 $columnIdx = $_GET[
'sort'];
1827 if(isset($_GET[
'dir']) && ctype_digit($_GET[
'dir'])) {
1828 $direction = ($_GET[
'dir'] == 0) ? SORT_ASC : SORT_DESC;
1830 kdsort($sponsors, $columnIdx, $direction);
1832 $smarty->assign(
'sort', array(
'colIdx' => $columnIdx,
1833 'direction' => $_GET[
'dir']));
1844 $smarty->assign(
'dropdownCategories',$categories);
1845 $smarty->assign(
'dropdownCars',$cars);
1846 $smarty->assign(
'dropdownStatus',$sponsorStatus);
1847 $smarty->assign(
'dropdownFacilities',$productionFacilities);
1848 $smarty->assign(
'sponsors',$sponsors);