27 define(
'EDIT_SECTION_LOCK_DURATION', 300);
29 define(
'NUMBER_OF_CHANGES_SHOWN_PER_EDIT_SECTION', 5);
42 $stmt = $mysqli->prepare(
'SELECT
57 FROM '.$db[
'sponsor'].
' AS sponsor LEFT JOIN '.$db[
'status'].
' AS status ON sponsor.status_id = status.status_id
58 ORDER BY sponsor_name');
61 $stmt->bind_result($id, $name, $street, $houseNumber, $zipCode, $town, $country, $website, $hints, $sponsorLogo, $lastContactDate, $lastContactPerson, $statusId, $statusName);
62 $stmt->store_result();
64 while ($stmt->fetch()) {
66 $rows [] = array(
'id' => $id,
69 'houseNumber' => $houseNumber,
70 'zipCode' => $zipCode,
72 'country' => $country,
73 'website' => $website,
75 'sponsorLogo' => $sponsorLogo,
76 'lastContactDateTimestamp' => $lastContactDate,
77 'lastContactPerson' => $lastContactPerson,
78 'statusId' => $statusId,
79 'statusName' => $statusName,
80 'lastChangeDateTimestamp' => $lastChange[
'timestamp'],
81 'lastChangeUserId' => $lastChange[
'userId'],
82 'lastChangeUserName' => $lastChange[
'userName']);
85 return isset($rows) ? $rows : FALSE;
101 $stmt = $mysqli->prepare(
'SELECT
116 FROM '.$db[
'sponsor'].
' AS sponsor LEFT JOIN '.$db[
'status'].
' AS status ON sponsor.status_id = status.status_id
117 WHERE sponsor_id = ?');
118 $stmt->bind_param(
'i', $sponsorId);
121 $stmt->bind_result($sponsorId, $name, $street, $houseNumber, $zipCode, $town, $country, $website, $hints, $sponsorLogo, $lastContactDate, $lastContactPerson, $statusId, $statusName);
122 $stmt->store_result();
124 if ($stmt->fetch()) {
125 $row = array(
'id' => $sponsorId,
128 'houseNumber' => $houseNumber,
129 'zipCode' => $zipCode,
131 'country' => $country,
132 'website' => $website,
134 'sponsorLogo' => $sponsorLogo,
135 'lastContactDateTimestamp' => $lastContactDate,
136 'lastContactPerson' => $lastContactPerson,
137 'statusId' => $statusId,
138 'statusName' => $statusName);
139 if ($includingLastEdit === TRUE) {
141 $row [
'lastChangeDateTimestamp'] = $lastChange[
'timestamp'];
142 $row [
'lastChangeUserId'] = $lastChange[
'userId'];
143 $row [
'lastChangeUserName'] = $lastChange[
'userName'];
147 return isset($row) ? $row : FALSE;
161 $stmt = $mysqli->prepare(
'SELECT *
163 (SELECT bup_last_change_at, bup_last_change_by
164 FROM '.$dbBackup[
'sponsor'].
' AS t1
165 WHERE bup_sponsor_id = ?
166 ORDER BY t1.bup_last_change_at DESC LIMIT 1)
169 (SELECT bup_last_change_at, bup_last_change_by
170 FROM '.$dbBackup[
'contact_person'].
' AS t2
171 WHERE bup_sponsor_id = ?
172 ORDER BY t2.bup_last_change_at DESC LIMIT 1)
175 (SELECT bup_last_change_at, bup_last_change_by
176 FROM '.$dbBackup[
'sp_production_facility'].
' AS t3
177 WHERE bup_sponsor_id = ?
178 ORDER BY t3.bup_last_change_at DESC LIMIT 1)
181 (SELECT bup_last_change_at, bup_last_change_by
183 (SELECT bup_last_change_at, bup_last_change_by, bup_sponsor_car_id
184 FROM '.$dbBackup[
'sponsor_car'].
' AS t4
185 ORDER BY t4.bup_last_change_at DESC LIMIT 1)
188 (SELECT bup_last_change_at, bup_last_change_by, bup_sponsor_car_id
189 FROM '.$dbBackup[
'sc_event'].
' AS t5
190 ORDER BY t5.bup_last_change_at DESC LIMIT 1)
193 (SELECT bup_last_change_at, bup_last_change_by, bup_sponsor_car_id
194 FROM '.$dbBackup[
'sc_attachment'].
' AS t6
195 ORDER BY t6.bup_last_change_at DESC LIMIT 1)
198 (SELECT bup_last_change_at, bup_last_change_by, bup_sponsor_car_id
199 FROM '.$dbBackup[
'sc_financial_donation'].
' AS t7
200 ORDER BY t7.bup_last_change_at DESC LIMIT 1)
203 (SELECT bup_last_change_at, bup_last_change_by, bup_sponsor_car_id
204 FROM '.$dbBackup[
'sc_material_donation'].
' AS t8
205 ORDER BY t8.bup_last_change_at DESC LIMIT 1)
208 (SELECT bup_last_change_at, bup_last_change_by, bup_sponsor_car_id
209 FROM '.$dbBackup[
'sc_produced_part'].
' As t9
210 ORDER BY t9.bup_last_change_at DESC LIMIT 1)
212 WHERE bup_sponsor_car_id IN(
213 SELECT sponsor_car_id
214 FROM '.$db[
'sponsor_car'].
' AS t11
215 WHERE t11.sponsor_id = ?)
216 ORDER BY t10.bup_last_change_at DESC LIMIT 1)
218 )AS t12 ORDER BY t12.bup_last_change_at DESC LIMIT 1');
219 $stmt->bind_param(
'iiii', $sponsorId, $sponsorId, $sponsorId, $sponsorId);
222 $stmt->bind_result($timestamp, $userId);
223 $stmt->store_result();
225 if ($stmt->fetch()) {
226 $row = array(
'timestamp' => $timestamp,
228 'userName' => (!empty($userId)) ?
fetchUsername($userId) :
'-');
231 return isset($row) ? $row : FALSE;
247 $stmt = $mysqli->prepare(
'SELECT bup_last_change_at, bup_last_change_by
248 FROM '.$dbBackup[
'sponsor'].
'
249 WHERE bup_sponsor_id = ?
250 ORDER BY bup_last_change_at DESC LIMIT ?');
251 $stmt->bind_param(
'ii', $sponsorId, $cnt);
254 $stmt->bind_result($timestamp, $userId);
255 $stmt->store_result();
257 while ($stmt->fetch()) {
258 $result[1][] = array(
'timestamp' => $timestamp,
260 'userName' => (!empty($userId)) ?
fetchUsername($userId) :
'-');
265 $stmt = $mysqli->prepare(
'SELECT bup_last_change_at, bup_last_change_by
266 FROM '.$dbBackup[
'contact_person'].
'
267 WHERE bup_sponsor_id = ?
268 ORDER BY bup_last_change_at DESC LIMIT ?');
269 $stmt->bind_param(
'ii', $sponsorId, $cnt);
272 $stmt->bind_result($timestamp, $userId);
273 $stmt->store_result();
275 while ($stmt->fetch()) {
276 $result[2][] = array(
'timestamp' => $timestamp,
278 'userName' => (!empty($userId)) ?
fetchUsername($userId) :
'-');
283 $stmt = $mysqli->prepare(
'SELECT bup_last_change_at, bup_last_change_by
284 FROM '.$dbBackup[
'sp_production_facility'].
'
285 WHERE bup_sponsor_id = ?
286 ORDER BY bup_last_change_at DESC LIMIT ?');
287 $stmt->bind_param(
'ii', $sponsorId, $cnt);
290 $stmt->bind_result($timestamp, $userId);
291 $stmt->store_result();
293 while ($stmt->fetch()) {
294 $result[3][] = array(
'timestamp' => $timestamp,
296 'userName' => (!empty($userId)) ?
fetchUsername($userId) :
'-');
302 $stmt = $mysqli->prepare(
'SELECT bup_last_change_at, bup_last_change_by
304 (SELECT bup_last_change_at, bup_last_change_by, bup_sponsor_car_id
305 FROM '.$dbBackup[
'sponsor_car'].
' AS t1
306 ORDER BY t1.bup_last_change_at DESC LIMIT ?)
309 (SELECT bup_last_change_at, bup_last_change_by, bup_sponsor_car_id
310 FROM '.$dbBackup[
'sc_event'].
' AS t2
311 ORDER BY t2.bup_last_change_at DESC LIMIT ?)
314 (SELECT bup_last_change_at, bup_last_change_by, bup_sponsor_car_id
315 FROM '.$dbBackup[
'sc_attachment'].
' AS t3
316 ORDER BY t3.bup_last_change_at DESC LIMIT ?)
319 (SELECT bup_last_change_at, bup_last_change_by, bup_sponsor_car_id
320 FROM '.$dbBackup[
'sc_financial_donation'].
' AS t4
321 ORDER BY t4.bup_last_change_at DESC LIMIT ?)
324 (SELECT bup_last_change_at, bup_last_change_by, bup_sponsor_car_id
325 FROM '.$dbBackup[
'sc_material_donation'].
' AS t5
326 ORDER BY t5.bup_last_change_at DESC LIMIT ?)
329 (SELECT bup_last_change_at, bup_last_change_by, bup_sponsor_car_id
330 FROM '.$dbBackup[
'sc_produced_part'].
' As t6
331 ORDER BY t6.bup_last_change_at DESC LIMIT ?)
333 WHERE bup_sponsor_car_id IN(
334 SELECT sponsor_car_id
335 FROM '.$db[
'sponsor_car'].
' AS t8
336 WHERE t8.sponsor_id = ?)
337 ORDER BY t7.bup_last_change_at DESC LIMIT ?');
338 $stmt->bind_param(
'iiiiiiii', $cnt, $cnt, $cnt, $cnt, $cnt, $cnt, $sponsorId, $cnt);
341 $stmt->bind_result($timestamp, $userId);
342 $stmt->store_result();
344 while ($stmt->fetch()) {
345 $result[4][] = array(
'timestamp' => $timestamp,
347 'userName' => (!empty($userId)) ?
fetchUsername($userId) :
'-');
351 return !empty($result) ? $result : FALSE;;
364 $stmt = $mysqli->prepare(
'SELECT
365 sp_production_facility_id,
366 t1.production_facility_id,
367 production_facility_name,
369 FROM '.$db[
'sp_production_facility'].
' AS t1 LEFT JOIN '.$db[
'production_facility'].
' AS t2 ON t1.production_facility_id = t2.production_facility_id
370 WHERE sponsor_id = ?');
371 $stmt->bind_param(
'i', $sponsorId);
374 $stmt->bind_result($id, $productionFacilityId, $name, $comments);
376 while ($stmt->fetch()) {
377 $rows [] = array(
'id' => $id,
378 'productionFacilityId' => $productionFacilityId,
380 'comments' => $comments);
383 return isset($rows) ? $rows : FALSE;
396 $stmt = $mysqli->prepare(
'SELECT
405 FROM '.$db[
'contact_person'].
406 ' WHERE sponsor_id = ?');
407 $stmt->bind_param(
'i', $sponsorId);
410 $stmt->bind_result($id, $name, $position, $telephone, $mobile, $email, $newsletter, $sponsorId);
412 while ($stmt->fetch()) {
413 $row[] = array(
'id' => $id,
415 'position' => $position,
416 'phone' => $telephone,
419 'newsletter' => $newsletter,
420 'sponsorId' => $sponsorId);
423 return isset($row) ? $row : FALSE;
437 "SELECT cp.name, cp.email, cp.mobile_phone_number, cp.telephone_number, cp.position, cp.newsletter,
438 sp.sponsor_name, sp.street, sp.house_number, sp.zip_code, sp.town, sp.country
439 FROM ".$db[
'contact_person'].
" AS cp LEFT JOIN ".$db[
'sponsor'].
" AS sp ON cp.sponsor_id = sp.sponsor_id
440 WHERE contact_person_id = ?";
441 $stmt = $mysqli->prepare($qry);
442 $stmt->bind_param(
'i', $contactPersonId);
445 $stmt->bind_result($name, $email, $mobile, $telephone, $position, $newsletter,
446 $sponsor, $street, $house_number, $zip_code, $town, $country);
448 while ($stmt->fetch()) {
452 'mobileNumber' => $mobile,
453 'phoneNumber' => $telephone,
454 'position' => $position,
455 'sponsor' => $sponsor,
457 'house_number'=> $house_number,
458 'zip_code' => $zip_code,
460 'country' => $country,
461 'newsletter' => ($newsletter == 1) ?
'Newsletter: Ja' :
'Newsletter: Nein'
465 return isset($data) ? $data : FALSE;
476 $qry =
"SELECT COUNT(contact_person_id) FROM ".$db[
'contact_person'].
" WHERE contact_person_id = ?";
477 $stmt = $mysqli->prepare($qry);
478 $stmt->bind_param(
'i', $contactPersonId);
481 $stmt->bind_result($num);
483 while ($stmt->fetch()) {
487 return ($res == 1) ? TRUE : FALSE;
500 $stmt = $mysqli->prepare(
'SELECT
503 FROM '.$db[
'sponsor_car'].
' AS t1 LEFT JOIN '.$db[
'car'].
' AS t2 ON t1.car_id = t2.car_id
505 ORDER BY t1.car_id DESC');
506 $stmt->bind_param(
'i', $sponsorId);
509 $stmt->bind_result($id, $name);
511 while ($stmt->fetch()) {
512 $rows [] = array(
'id' => $id,
516 return isset($rows) ? $rows : FALSE;
529 $stmt = $mysqli->prepare(
'SELECT
532 FROM '.$db[
'car'].
' AS t1
533 WHERE t1.car_id NOT IN (SELECT car_id FROM '.$db[
'sponsor_car'].
' WHERE sponsor_id = ?)');
534 $stmt->bind_param(
'i', $sponsorId);
537 $stmt->bind_result($id, $name);
539 while ($stmt->fetch()) {
540 $rows [] = array(
'id' => $id,
544 return isset($rows) ? $rows : FALSE;
557 $stmt = $mysqli->prepare(
'UPDATE '.$db[
'sponsor'].
' SET
567 last_contact_date = ?,
568 last_contact_person = ?,
572 WHERE sponsor_id = ?');
573 $stmt->bind_param(
"sssssssssssiii",
574 $sponsorArray[
'name'],
575 $sponsorArray[
'street'],
576 $sponsorArray[
'houseNumber'],
577 $sponsorArray[
'zipCode'],
578 $sponsorArray[
'town'],
579 $sponsorArray[
'country'],
580 $sponsorArray[
'website'],
581 $sponsorArray[
'hints'],
582 $sponsorArray[
'sponsorLogo'],
583 $sponsorArray[
'lastContactDateTimestamp'],
584 $sponsorArray[
'lastContactPerson'],
585 $sponsorArray[
'statusId'],
586 $loggedInUser->userId,
587 $sponsorArray[
'id']);
588 $result = $stmt->execute();
604 if ($updateLockUserIdBefore === TRUE) {
606 $stmt = $mysqli->prepare(
'UPDATE '.$db[
'sp_production_facility'].
' SET
609 WHERE sp_production_facility_id = ?');
610 $stmt->bind_param(
"ii",
611 $loggedInUser->userId,
612 $sponsorProductionFacilityId);
617 $stmt = $mysqli->prepare(
"DELETE FROM " . $db[
'sp_production_facility'] .
"
618 WHERE sp_production_facility_id = ?");
619 $stmt->bind_param(
"i",$sponsorProductionFacilityId);
620 $result = $stmt->execute();
633 foreach ($sponsorProductionFacilities as $sponsorProductionFacility) {
634 $stmt = $mysqli->prepare(
'UPDATE '.$db[
'sp_production_facility'].
' SET
635 production_facility_id = ?,
639 WHERE sp_production_facility_id = ?');
640 $stmt->bind_param(
"isii",
641 $sponsorProductionFacility[
'productionFacilityId'],
642 $sponsorProductionFacility[
'comments'],
643 $loggedInUser->userId,
644 $sponsorProductionFacility[
'id']);
646 $result = $stmt->execute();
647 if ($result == FALSE) {
663 $stmt = $mysqli->prepare(
"INSERT INTO " . $db[
'sp_production_facility'] .
"
664 (production_facility_id, sponsor_id, comments, lock_time, lock_user_id)
667 $stmt->bind_param(
"iisi", $sponsorProductionFacility[
'productionFacilityId'],
668 $sponsorProductionFacility[
'sponsor_id'],
669 $sponsorProductionFacility[
'comments'],
670 $loggedInUser->userId);
671 $result = $stmt->execute();
687 if ($updateLockUserIdBefore === TRUE) {
689 $stmt = $mysqli->prepare(
'UPDATE '.$db[
'contact_person'].
' SET
692 WHERE contact_person_id = ?');
693 $stmt->bind_param(
"ii",
694 $loggedInUser->userId,
700 $stmt = $mysqli->prepare(
"DELETE FROM " . $db[
'contact_person'] .
"
701 WHERE contact_person_id = ?");
702 $stmt->bind_param(
"i", $contactPersonId);
703 $result = $stmt->execute();
716 foreach ($sponsorContactPersons as $sponsorContactPerson) {
717 $stmt = $mysqli->prepare(
'UPDATE '.$db[
'contact_person'].
' SET
720 telephone_number = ?,
721 mobile_phone_number = ?,
727 WHERE contact_person_id = ?');
728 $stmt->bind_param(
"sssssiiii",
729 $sponsorContactPerson[
'name'],
730 $sponsorContactPerson[
'position'],
731 $sponsorContactPerson[
'phone'],
732 $sponsorContactPerson[
'mobile'],
733 $sponsorContactPerson[
'email'],
734 $sponsorContactPerson[
'newsletter'],
735 $sponsorContactPerson[
'sponsorId'],
736 $loggedInUser->userId,
737 $sponsorContactPerson[
'id']);
739 $result = $stmt->execute();
740 if ($result == FALSE) {
756 $stmt = $mysqli->prepare(
"INSERT INTO " . $db[
'contact_person'] .
"
757 (name, position, telephone_number, mobile_phone_number, email, newsletter, sponsor_id, lock_time, lock_user_id)
759 (?, ?, ?, ?, ?, ?, ?, 0, ?)");
760 $stmt->bind_param(
"sssssiii", $sponsorContactPerson[
'name'],
761 $sponsorContactPerson[
'position'],
762 $sponsorContactPerson[
'phone'],
763 $sponsorContactPerson[
'mobile'],
764 $sponsorContactPerson[
'email'],
765 $sponsorContactPerson[
'newsletter'],
766 $sponsorContactPerson[
'sponsor_id'],
767 $loggedInUser->userId);
768 $result = $stmt->execute();
783 $stmt = $mysqli->prepare(
"INSERT INTO " . $db[
'sponsor'] .
"
784 (sponsor_name, street, house_number, zip_code, town, country, status_id, lock_user_id)
786 (?, ?, ?, ?, ?, ?, ?, ?)");
787 $stmt->bind_param(
"ssssssii", $sponsor[
'name'],
789 $sponsor[
'houseNumber'],
793 $sponsor[
'statusId'],
794 $loggedInUser->userId);
795 $result = $stmt->execute();
797 return ($result === TRUE) ? $mysqli->insert_id : FALSE;
819 if (isset($sponsorId)) {
820 $stmt = $mysqli->prepare(
'SELECT
828 FROM '.$db[
'sponsor_car'].
' AS t1
829 LEFT JOIN '.$db[
'car'].
' AS t2 ON t1.car_id = t2.car_id
830 LEFT JOIN '.$db[
'category'].
' AS t3 ON t1.category_id = t3.category_id
832 ORDER BY t1.car_id DESC');
833 $stmt->bind_param(
'i', $sponsorId);
836 $stmt->bind_result($id, $carId, $name, $codetermination, $hints, $categoryId, $categoryName);
838 while ($stmt->fetch()) {
839 $rows [] = array(
'id' => $id,
842 'codetermination' => $codetermination,
844 'categoryId' => $categoryId,
845 'categoryName' => $categoryName);
848 return isset($rows) ? $rows : FALSE;
850 elseif (isset($sponsorCarId)) {
851 $stmt = $mysqli->prepare(
'SELECT
859 FROM '.$db[
'sponsor_car'].
' AS t1
860 LEFT JOIN '.$db[
'car'].
' AS t2 ON t1.car_id = t2.car_id
861 LEFT JOIN '.$db[
'category'].
' AS t3 ON t1.category_id = t3.category_id
862 WHERE sponsor_car_id = ?
863 ORDER BY t1.car_id DESC');
864 $stmt->bind_param(
'i', $sponsorCarId);
867 $stmt->bind_result($id, $carId, $name, $codetermination, $hints, $categoryId, $categoryName);
869 if ($stmt->fetch()) {
870 $row = array(
'id' => $id,
873 'codetermination' => $codetermination,
875 'categoryId' => $categoryId,
876 'categoryName' => $categoryName);
879 return isset($row) ? $row : FALSE;
896 $stmt = $mysqli->prepare(
'SELECT
900 FROM '.$db[
'sc_event'].
'
901 WHERE sponsor_car_id = ?
902 ORDER BY date DESC');
903 $stmt->bind_param(
'i', $sponsorCarId);
906 $stmt->bind_result($id, $event, $date);
907 while ($stmt->fetch()) {
908 $rows [] = array(
'id' => $id,
910 'timestamp' => $date);
913 return isset($rows) ? $rows : FALSE;
926 $stmt = $mysqli->prepare(
'SELECT
927 sc_financial_donation_id,
930 FROM '.$db[
'sc_financial_donation'].
'
931 WHERE sponsor_car_id = ?
932 ORDER BY date DESC');
933 $stmt->bind_param(
'i', $sponsorCarId);
936 $stmt->bind_result($id, $amount, $date);
937 while ($stmt->fetch()) {
938 $rows [] = array(
'id' => $id,
940 'timestamp' => $date);
943 return isset($rows) ? $rows : FALSE;
956 $stmt = $mysqli->prepare(
'SELECT
957 sc_material_donation_id,
961 FROM '.$db[
'sc_material_donation'].
'
962 WHERE sponsor_car_id = ?
963 ORDER BY date DESC');
964 $stmt->bind_param(
'i', $sponsorCarId);
967 $stmt->bind_result($id, $object, $amount, $date);
968 while ($stmt->fetch()) {
969 $rows [] = array(
'id' => $id,
972 'timestamp' => $date);
975 return isset($rows) ? $rows : FALSE;
988 $stmt = $mysqli->prepare(
'SELECT
993 FROM '.$db[
'sc_produced_part'].
'
994 WHERE sponsor_car_id = ?
995 ORDER BY date DESC');
996 $stmt->bind_param(
'i', $sponsorCarId);
999 $stmt->bind_result($id, $name, $value, $date);
1000 while ($stmt->fetch()) {
1001 $rows [] = array(
'id' => $id,
1004 'timestamp' => $date);
1007 return isset($rows) ? $rows : FALSE;
1020 $stmt = $mysqli->prepare(
'SELECT
1025 FROM '.$db[
'sc_attachment'].
'
1026 WHERE sponsor_car_id = ?
1027 ORDER BY file_name ASC');
1028 $stmt->bind_param(
'i', $sponsorCarId);
1031 $stmt->bind_result($id,
$filename, $path, $date);
1032 while ($stmt->fetch()) {
1033 $rows [] = array(
'id' => $id,
1036 'timestamp' => $date);
1039 return isset($rows) ? $rows : FALSE;
1051 $stmt = $mysqli->prepare(
'UPDATE '.$db[
'sponsor_car'].
' SET
1052 co_determination = ?,
1057 WHERE sponsor_car_id = ?');
1058 $stmt->bind_param(
"isiii",
1059 $sponsorCar[
'codetermination'],
1060 $sponsorCar[
'hints'],
1061 $sponsorCar[
'categoryId'],
1062 $loggedInUser->userId,
1065 $result = $stmt->execute();
1081 $stmt = $mysqli->prepare(
"INSERT INTO " . $db[
'sponsor_car'] .
"
1082 (co_determination, hints, car_id, sponsor_id, category_id, lock_time, lock_user_id)
1084 (-1, '', ?, ?, -1, 0, ?)");
1085 $stmt->bind_param(
"iii", $carId, $sponsorId, $loggedInUser->userId);
1086 $result = $stmt->execute();
1088 return ($result === TRUE) ? $mysqli->insert_id : FALSE;
1099 foreach ($events as $event) {
1100 $stmt = $mysqli->prepare(
'UPDATE '.$db[
'sc_event'].
' SET
1105 WHERE sc_event_id = ?');
1106 $stmt->bind_param(
"siii",
1108 $event[
'timestamp'],
1109 $loggedInUser->userId,
1112 $result = $stmt->execute();
1113 if ($result == FALSE) {
1131 $stmt = $mysqli->prepare(
"INSERT INTO " . $db[
'sc_event'] .
"
1132 (sponsor_car_id, event, date, lock_time, lock_user_id)
1135 $stmt->bind_param(
"isii", $event[
'sponsorCarId'],
1137 $event[
'timestamp'],
1138 $loggedInUser->userId);
1139 $result = $stmt->execute();
1141 return ($result === TRUE) ? $mysqli->insert_id : FALSE;
1153 $stmt = $mysqli->prepare(
'UPDATE '.$db[
'sc_event'].
' SET
1156 WHERE sc_event_id = ?');
1157 $stmt->bind_param(
"ii",
1158 $loggedInUser->userId,
1164 $stmt = $mysqli->prepare(
"DELETE FROM " . $db[
'sc_event'] .
"
1165 WHERE sc_event_id = ?");
1166 $stmt->bind_param(
"i",$eventId);
1167 $result = $stmt->execute();
1180 foreach ($financialDonations as $financialDonation) {
1181 $stmt = $mysqli->prepare(
'UPDATE '.$db[
'sc_financial_donation'].
' SET
1186 WHERE sc_financial_donation_id = ?');
1187 $stmt->bind_param(
"diii",
1188 $financialDonation[
'amount'],
1189 $financialDonation[
'timestamp'],
1190 $loggedInUser->userId,
1191 $financialDonation[
'id']);
1193 $result = $stmt->execute();
1194 if ($result == FALSE) {
1212 $stmt = $mysqli->prepare(
"INSERT INTO " . $db[
'sc_financial_donation'] .
"
1213 (sponsor_car_id, amount, date, lock_time, lock_user_id)
1216 $stmt->bind_param(
"idii", $financialDonation[
'sponsorCarId'],
1217 $financialDonation[
'amount'],
1218 $financialDonation[
'timestamp'],
1219 $loggedInUser->userId);
1220 $result = $stmt->execute();
1222 return ($result === TRUE) ? $mysqli->insert_id : FALSE;
1234 $stmt = $mysqli->prepare(
'UPDATE '.$db[
'sc_financial_donation'].
' SET
1237 WHERE sc_financial_donation_id = ?');
1238 $stmt->bind_param(
"ii",
1239 $loggedInUser->userId,
1240 $financialDonationId);
1245 $stmt = $mysqli->prepare(
"DELETE FROM " . $db[
'sc_financial_donation'] .
"
1246 WHERE sc_financial_donation_id = ?");
1247 $stmt->bind_param(
"i",$financialDonationId);
1248 $result = $stmt->execute();
1261 foreach ($materialDonations as $materialDonation) {
1262 $stmt = $mysqli->prepare(
'UPDATE '.$db[
'sc_material_donation'].
' SET
1268 WHERE sc_material_donation_id = ?');
1269 $stmt->bind_param(
"sdiii",
1270 $materialDonation[
'object'],
1271 $materialDonation[
'amount'],
1272 $materialDonation[
'timestamp'],
1273 $loggedInUser->userId,
1274 $materialDonation[
'id']);
1276 $result = $stmt->execute();
1277 if ($result == FALSE) {
1295 $stmt = $mysqli->prepare(
"INSERT INTO " . $db[
'sc_material_donation'] .
"
1296 (sponsor_car_id, object, value, date, lock_time, lock_user_id)
1298 (?, ?, ?, ?, 0, ?)");
1299 $stmt->bind_param(
"isdii", $materialDonation[
'sponsorCarId'],
1300 $materialDonation[
'object'],
1301 $materialDonation[
'amount'],
1302 $materialDonation[
'timestamp'],
1303 $loggedInUser->userId);
1304 $result = $stmt->execute();
1306 return ($result === TRUE) ? $mysqli->insert_id : FALSE;
1318 $stmt = $mysqli->prepare(
'UPDATE '.$db[
'sc_material_donation'].
' SET
1321 WHERE sc_material_donation_id = ?');
1322 $stmt->bind_param(
"ii",
1323 $loggedInUser->userId,
1324 $materialDonationId);
1329 $stmt = $mysqli->prepare(
"DELETE FROM " . $db[
'sc_material_donation'] .
"
1330 WHERE sc_material_donation_id = ?");
1331 $stmt->bind_param(
"i", $materialDonationId);
1332 $result = $stmt->execute();
1345 foreach ($producedParts as $producedPart) {
1346 $stmt = $mysqli->prepare(
'UPDATE '.$db[
'sc_produced_part'].
' SET
1347 produced_part_name = ?,
1348 produced_part_value = ?,
1352 WHERE sc_produced_part_id = ?');
1353 $stmt->bind_param(
"sdiii",
1354 $producedPart[
'name'],
1355 $producedPart[
'value'],
1356 $producedPart[
'timestamp'],
1357 $loggedInUser->userId,
1358 $producedPart[
'id']);
1359 $result = $stmt->execute();
1360 if ($result == FALSE) {
1378 $stmt = $mysqli->prepare(
"INSERT INTO " . $db[
'sc_produced_part'] .
"
1379 (sponsor_car_id, produced_part_name, produced_part_value, date, lock_time, lock_user_id)
1381 (?, ?, ?, ?, 0, ?)");
1382 $stmt->bind_param(
"isdii", $producedPart[
'sponsorCarId'],
1383 $producedPart[
'name'],
1384 $producedPart[
'value'],
1385 $producedPart[
'timestamp'],
1386 $loggedInUser->userId);
1387 $result = $stmt->execute();
1389 return ($result === TRUE) ? $mysqli->insert_id : FALSE;
1401 $stmt = $mysqli->prepare(
'UPDATE '.$db[
'sc_produced_part'].
' SET
1404 WHERE sc_produced_part_id = ?');
1405 $stmt->bind_param(
"ii",
1406 $loggedInUser->userId,
1412 $stmt = $mysqli->prepare(
"DELETE FROM " . $db[
'sc_produced_part'] .
"
1413 WHERE sc_produced_part_id = ?");
1414 $stmt->bind_param(
"i", $producedPartId);
1415 $result = $stmt->execute();
1429 foreach ($attachments as $attachment) {
1430 $stmt = $mysqli->prepare(
'UPDATE '.$db[
'sc_attachment'].
' SET
1435 WHERE sc_attachment_id = ?');
1436 $stmt->bind_param(
"ssii",
1437 $attachment[
'filename'],
1438 $attachment[
'path'],
1439 $loggedInUser->userId,
1441 $result = $stmt->execute();
1442 if ($result == FALSE) {
1460 $stmt = $mysqli->prepare(
"INSERT INTO " . $db[
'sc_attachment'] .
"
1461 (sponsor_car_id, file_name, path, date, lock_time, lock_user_id)
1463 (?, ?, ?, UNIX_TIMESTAMP(), 0, ?)");
1464 $stmt->bind_param(
"issi", $attachment[
'sponsorCarId'],
1465 $attachment[
'filename'],
1466 $attachment[
'path'],
1467 $loggedInUser->userId);
1468 $result = $stmt->execute();
1470 return ($result === TRUE) ? $mysqli->insert_id : FALSE;
1482 $stmt = $mysqli->prepare(
'UPDATE '.$db[
'sc_attachment'].
' SET
1485 WHERE sc_attachment_id = ?');
1486 $stmt->bind_param(
"ii",
1487 $loggedInUser->userId,
1493 $stmt = $mysqli->prepare(
"DELETE FROM " . $db[
'sc_attachment'] .
"
1494 WHERE sc_attachment_id = ?");
1495 $stmt->bind_param(
"i", $attachmentId);
1496 $result = $stmt->execute();
1515 $stmt = $mysqli->prepare(
"SELECT
1518 FROM " . $db[
'car'].
'
1519 ORDER BY car_id DESC');
1521 $stmt->bind_result($carId, $carName);
1522 while ($stmt->fetch()) {
1523 $rows[] = array(
'id' => $carId,
'name' => $carName);
1526 return isset($rows) ? $rows : FALSE;
1539 $stmt = $mysqli->prepare(
"SELECT
1540 production_facility_id,
1541 production_facility_name
1542 FROM " . $db[
'production_facility'].
'
1543 ORDER BY production_facility_name ASC');
1545 $stmt->bind_result($productionFacilityId, $name);
1547 while ($stmt->fetch()) {
1548 $rows[] = array(
'id' => $productionFacilityId,
'name' => $name);
1551 return isset($rows) ? $rows : FALSE;
1564 $stmt = $mysqli->prepare(
"SELECT
1567 FROM " . $db[
'status'].
'
1568 ORDER BY status_name ASC');
1570 $stmt->bind_result($statusId, $statusName);
1572 while ($stmt->fetch()) {
1573 $rows[] = array(
'id' => $statusId,
'name' => $statusName);
1576 return isset($rows) ? $rows : FALSE;
1589 $stmt = $mysqli->prepare(
"SELECT
1592 FROM " . $db[
'category'].
'
1593 ORDER BY category_name ASC');
1595 $stmt->bind_result($categoryId, $categoryName);
1597 while ($stmt->fetch()) {
1598 $rows[] = array(
'id' => $categoryId,
'name' => $categoryName);
1601 return isset($rows) ? $rows : FALSE;
1615 if (empty($productionFacilityId)) {
1619 $stmt = $mysqli->prepare(
"SELECT
1620 production_facility_id,
1621 production_facility_name
1622 FROM " . $db[
'production_facility'].
"
1624 production_facility_id = ?");
1625 $stmt->bind_param(
"i", $productionFacilityId);
1627 $stmt->bind_result($productionFacilityId, $name);
1628 while ($stmt->fetch()) {
1629 $row = array(
'id' => $productionFacilityId,
'name' => $name);
1632 return isset($row) ? $row : FALSE;
1645 if (empty($statusId)) {
1649 $stmt = $mysqli->prepare(
"SELECT
1652 FROM " . $db[
'status'].
"
1655 $stmt->bind_param(
"i", $statusId);
1657 $stmt->bind_result($statusId, $statusName);
1658 while ($stmt->fetch()) {
1659 $row = array(
'id' => $statusId,
'name' => $statusName);
1662 return isset($row) ? $row : FALSE;
1675 if (empty($categoryId)) {
1679 $stmt = $mysqli->prepare(
"SELECT
1682 FROM " . $db[
'category'].
"
1685 $stmt->bind_param(
"i", $categoryId);
1687 $stmt->bind_result($categoryId, $categoryName);
1688 while ($stmt->fetch()) {
1689 $row = array(
'id' => $categoryId,
'name' => $categoryName);
1692 return isset($row) ? $row : FALSE;
1705 if (empty($carId)) {
1709 $stmt = $mysqli->prepare(
"SELECT
1712 FROM " . $db[
'car'].
"
1715 $stmt->bind_param(
"i", $carId);
1717 $stmt->bind_result($carId, $carName);
1718 while ($stmt->fetch()) {
1719 $row = array(
'id' => $carId,
'name' => $carName);
1722 return isset($row) ? $row : FALSE;
1733 $stmt = $mysqli->prepare(
"INSERT INTO " . $db[
'production_facility'] .
"(
1734 production_facility_name, lock_time, lock_user_id)
1738 $stmt->bind_param(
"si", $name, $loggedInUser->userId);
1739 $result = $stmt->execute();
1752 $stmt = $mysqli->prepare(
"INSERT INTO " . $db[
'status'] .
"(
1753 status_name, lock_time, lock_user_id)
1757 $stmt->bind_param(
"si", $name, $loggedInUser->userId);
1758 $result = $stmt->execute();
1771 $stmt = $mysqli->prepare(
"INSERT INTO " . $db[
'category'] .
"(
1772 category_name, lock_time, lock_user_id)
1776 $stmt->bind_param(
"si", $name, $loggedInUser->userId);
1777 $result = $stmt->execute();
1790 $stmt = $mysqli->prepare(
"INSERT INTO " . $db[
'car'] .
"(
1791 car_name, lock_time, lock_user_id)
1795 $stmt->bind_param(
"si", $name, $loggedInUser->userId);
1796 $result = $stmt->execute();
1810 $stmt = $mysqli->prepare(
"UPDATE " . $db[
'production_facility'] .
"
1811 SET production_facility_name = ?,
1815 production_facility_id = ?");
1816 $stmt->bind_param(
"sii", $name, $loggedInUser->userId, $id);
1817 $result = $stmt->execute();
1831 $stmt = $mysqli->prepare(
"UPDATE " . $db[
'status'] .
"
1832 SET status_name = ?,
1837 $stmt->bind_param(
"sii", $name, $loggedInUser->userId, $id);
1838 $result = $stmt->execute();
1852 $stmt = $mysqli->prepare(
"UPDATE " . $db[
'category'] .
"
1853 SET category_name = ?,
1858 $stmt->bind_param(
"sii", $name, $loggedInUser->userId, $id);
1859 $result = $stmt->execute();
1873 $stmt = $mysqli->prepare(
"UPDATE " . $db[
'car'] .
"
1879 $stmt->bind_param(
"sii", $name, $loggedInUser->userId, $id);
1880 $result = $stmt->execute();
1894 $stmt = $mysqli->prepare(
"SELECT
1895 COUNT(sp_production_facility_id)
1896 FROM ".$db[
'sp_production_facility'].
"
1897 WHERE production_facility_id = ?
1899 $stmt->bind_param(
"i",$id);
1901 $stmt->bind_result($cnt);
1902 if ($stmt->fetch()) {
1906 $stmt = $mysqli->prepare(
"DELETE FROM " . $db[
'production_facility'] .
"
1907 WHERE production_facility_id = ?");
1908 $stmt->bind_param(
"i",$id);
1909 $result = $stmt->execute();
1927 $stmt = $mysqli->prepare(
"SELECT
1929 FROM ".$db[
'sponsor'].
"
1932 $stmt->bind_param(
"i",$id);
1934 $stmt->bind_result($cnt);
1935 if ($stmt->fetch()) {
1939 $stmt = $mysqli->prepare(
"DELETE FROM " . $db[
'status'] .
"
1940 WHERE status_id = ?");
1941 $stmt->bind_param(
"i",$id);
1942 $result = $stmt->execute();
1960 $stmt = $mysqli->prepare(
"SELECT
1961 COUNT(sponsor_car_id)
1962 FROM ".$db[
'sponsor_car'].
"
1963 WHERE category_id = ?
1965 $stmt->bind_param(
"i",$id);
1967 $stmt->bind_result($cnt);
1968 if ($stmt->fetch()) {
1972 $stmt = $mysqli->prepare(
"DELETE FROM " . $db[
'category'] .
"
1973 WHERE category_id = ?");
1974 $stmt->bind_param(
"i",$id);
1975 $result = $stmt->execute();
1993 $stmt = $mysqli->prepare(
"SELECT
1994 COUNT(sponsor_car_id)
1995 FROM ".$db[
'sponsor_car'].
"
1998 $stmt->bind_param(
"i",$id);
2000 $stmt->bind_result($cnt);
2001 if ($stmt->fetch()) {
2005 $stmt = $mysqli->prepare(
"DELETE FROM " . $db[
'car'] .
"
2007 $stmt->bind_param(
"i",$id);
2008 $result = $stmt->execute();