:

$contact){ $query = "INSERT INTO infoboard (category_id, date, main_contact_id) VALUES ( '" . $category_id . "', '" . $date . "', '" . $contact . "' )"; @mysqli_query($GLOBALS['mysql_con'], $query); } } } function save_infoboard_card(){ $start_date = new DateTime($_POST['input_start_date']); $end_date = new DateTime($_POST['input_end_date']); $category_id = $_POST['input_category']; $input_contact = $_POST['input_contact']; $contacts = explode(',', $input_contact); if(!empty($contacts) && gettype($contacts) == 'array') { foreach($contacts as $key => $contact){ for($i = $start_date; $i <= $end_date; $i->modify('+1 day')){ $query = "SELECT * FROM infoboard WHERE date = '".$i->format('Y-m-d')."' AND category_id = ".$category_id. " AND main_contact_id = ".$contact; $result = @mysqli_query($GLOBALS['mysql_con'], $query); if (@mysqli_num_rows($result) == 0) { $query = "INSERT INTO infoboard (category_id, date, main_contact_id) VALUES ( '" . $category_id . "', '" . $i->format('Y-m-d') . "', '" . $contact . "' )"; // var_dump($query); @mysqli_query($GLOBALS['mysql_con'], $query); } } } } // require_once("infoboard_cardform.inc.php"); } function load_contact($date, $category_id){ global $filter_mandant; $join_mandant = ""; $where_mandant = ""; if($filter_mandant != 0){ $join_mandant = "LEFT JOIN main_contact_department ON main_contact.id = main_contact_department.main_contact_id"; $where_mandant = " AND main_mandant_id = ".$filter_mandant; } $query = "SELECT main_contact.* FROM infoboard LEFT JOIN main_contact ON infoboard.main_contact_id = main_contact.id ".$join_mandant." WHERE date = '".$date."' AND category_id = ".$category_id. " AND main_contact.id != 0" . $where_mandant; $result = @mysqli_query($GLOBALS['mysql_con'], $query); if (@mysqli_num_rows($result) == 0) { $person = "Keine Auswahl"; } $i = 1; while($contact = @mysqli_fetch_array($result)) { if($i > 1){ $person .= ", "; } $person .= $contact['shortcut']; $i++; } return $person; } function load_contact_ids($date, $category_id){ $preselect = array(); global $filter_mandant; $join_mandant = ""; $where_mandant = ""; if($filter_mandant != 0){ $join_mandant = "LEFT JOIN main_contact_department ON main_contact.id = main_contact_department.main_contact_id"; $where_mandant = " AND main_mandant_id = ".$filter_mandant; } $query = "SELECT main_contact.* FROM infoboard LEFT JOIN main_contact ON infoboard.main_contact_id = main_contact.id ".$join_mandant." WHERE date = '".$date."' AND category_id = ".$category_id . $where_mandant; $result = @mysqli_query($GLOBALS['mysql_con'], $query); while($row = @mysqli_fetch_array($result)){ array_push($preselect,$row['id']); } return $preselect; } function load_infoboard(){ global $filter_mandant; $current_date = new DateTime(); $this_day = new DateTime('Monday this week'); $next_week = $current_date->format('W')+1; $prev_week = $current_date->format('W')-1; if(isset($_GET['week'])){ $this_day->setISODate($current_date->format('Y'), $_GET['week']); $next_week = $_GET['week']+1; $prev_week = $_GET['week']-1; } $categories = array("Abwesend", "Home Office", "Urlaub", "Berufsschule", "Anwesend"); $days = array("Mo", "Di", "Mi", "Do", "Fr"); echo "
"; echo "KW ".$this_day->format('W'); foreach($categories as $key_categories => $value_categories){ echo "
".$value_categories."
"; } echo "
"; foreach ($days as $key_days => $value_days) { $current = ""; if($this_day->format('d.m.Y') == $current_date->format('d.m.Y')){ $current = "current"; } echo "
"; echo "
".$value_days.". ".$this_day->format('d.m.Y')."
"; echo "
"; foreach($categories as $key_categories => $value_categories){ $person = load_contact($this_day->format('Y-m-d'), $key_categories); $person_ids = load_contact_ids($this_day->format('Y-m-d'), $key_categories); echo "
"; echo "
".$person."
"; echo "
"; } echo "
"; $this_day->modify("+1 day"); echo "
"; } echo "
"; echo "vorherige Woche"; echo "nächste Woche"; echo "
"; } function select_contact(){ global $filter_mandant; $join_mandant = ""; $where_mandant = ""; if($filter_mandant != 0){ $join_mandant = "LEFT JOIN main_contact_department ON main_contact.id = main_contact_department.main_contact_id"; $where_mandant = "WHERE main_mandant_id = ".$filter_mandant; } $query = "SELECT main_contact.* FROM main_contact ". $join_mandant . " " . $where_mandant; $result_contact = @mysqli_query($GLOBALS['mysql_con'], $query); if (@mysqli_num_rows($result_contact) == 0) { return; } ?>