public static function New_Assign($assign_id) { $root_url = dirname($_SERVER['PHP_SELF']); $root_url = "http://ojconsultinggroup.com" . $root_url; $assingment = Assignment::where("id", "=", $assign_id)->first(); $user = Member::where("id", "=", $assingment->user_id)->first(); $event = event::where("id", "=", $assingment->event_id)->first(); $customer_id = $event->customer_id; $venue_id = $event->venue_id; $venue_room = venue::where("id", "=", $venue_id)->first(); $customer = customer::where("id", "=", $customer_id)->first(); $userid = $user->id; $idcard = $user->id_card; $name = $user->name . " " . $user->surname; $email = $user->email; $event_name = $event->event_name; $event_type = $event->event_type; $split_event_date = explode("-", $event->event_date); $event_date = $split_event_date[2] . " " . AssignCalendar::get_month_thai($split_event_date[1]) . " " . AssignCalendar::get_BE_year($split_event_date[0]); $staff_appointment_time = $event->staff_appointment_time; $customer_name = $customer->symbol . " - " . $customer->name; $venue_name = $venue_room->venue->name . " : " . $venue_room->room_name; $venue_address = $venue_room->venue->address; $subject = "OJ - คุณได้รับมอบหมายงานในวันที่ " . $event_date; $data = array('root_url' => $root_url, 'userid' => $userid, 'idcard' => $idcard, 'id' => $assign_id, 'name' => $name, 'event_name' => $event_name, 'event_type' => $event_type, 'event_date' => $event_date, 'staff_appointment_time' => $staff_appointment_time, 'customer_name' => $customer_name, 'venue_name' => $venue_name, 'venue_address' => $venue_address, 'subject' => $subject, 'email' => $email); Mail::queue('Assign.New_assign_mail', $data, function ($message) use($data) { $message->to($data['email'])->subject($data['subject']); }); }
public static function getcalendar($fulldate) { if (empty($fulldate)) { //กำหนดตัวแปรที่ใช้คำนวณวัน $now = strtotime("now"); } else { $now = strtotime("{$fulldate}"); } $user_id = Auth::user()->id; $Year = date('Y', $now); $month = date('n', $now); $first_of_month = strtotime("{$Year}-{$month}-1"); $first_day_of_week = date('w', $first_of_month); $last_day_of_month = date('t', $now); $lastday_previousmonth = date("j", strtotime("{$Year}-{$month}-1" . "last day of previous month")); $weekrow_of_month = AssignCalendar::getweekofmonth($now); $today = date("Y-n-j"); //แปลงเป็นภาษาไทย $thai_month = AssignCalendar::get_month_thai($month); $BE_year = AssignCalendar::get_BE_year($Year); //กำหนดวันแรกของหน้าปฏฺทิน $startday = 1 - $first_day_of_week; //กำหนดลำดับวันประจำสัปดาห์ $day_of_week = 1; $row_of_month = 1; // $all_event_of_week = ""; echo "\n\t\t\t <div class='panel-body'>\n\n\t\t\t <div id='gridcontainer' style='height: 631px;position:relative;' >\n\t\t\t <div class='mv-container'>\n\n <div class='row' style='padding-bottom:8px;'>\n <div class='col-xs-7'>\n <span style='font-size: 18px;'><b>" . $thai_month . "</b> " . $BE_year . "</span>\n </div>\n <div class='col-xs-5 text-right'>\n <button class='btn btn-outline btn-info btn-xs' type='submit' name = 'btn-previous' onclick='assign_previous(" . date('d', $now) . "," . date('m', $now) . "," . $Year . ")' > < </button>\n <button class='btn btn-outline btn-info btn-xs' type='submit' name = 'btn-previous' onclick='assign_today()' > today </button>\n <button class='btn btn-outline btn-info btn-xs' type='submit' name = 'btn-next' onclick='assign_next(" . date('d', $now) . "," . date('m', $now) . "," . $Year . ")'> > </button>\n </div>\n </div>\n\n\t\t\t <table cellspacing='0' cellpadding='0' class='mv-daynames-table' >\n\t\t\t <tbody>\n\t\t\t <tr>\n\t\t\t <th title='Sun' class='mv-dayname'>Sun</th>\n\t\t\t <th title='Mon' class='mv-dayname'>Mon</th>\n\t\t\t <th title='Tue' class='mv-dayname'>Tue</th>\n\t\t\t <th title='Wed' class='mv-dayname'>Wed</th>\n\t\t\t <th title='Thu' class='mv-dayname'>Thu</th>\n\t\t\t <th title='Fri' class='mv-dayname'>Fri</th>\n\t\t\t <th title='Sat' class='mv-dayname'>Sat</th>\n\t\t\t </tr>\n\t\t\t </tbody>\n\t\t\t </table>\n\n\t\t\t <div class='mv-event-container' >"; //Set variable echo //กำหนดตัวแปริาร์เรย์ทมีหลายค่าไม่เหมือนกันี่ $weekrow = array(); $table1_row = array(); $table2_row = array(); $table2_row_event = array(); $week_event_row = array(); //จำนวนกิจกรรมในวันนั้น $weekrowfoot = "</div>"; $table1_head = "<table cellspacing='0' cellpadding='0' class='st-bg-table'><tbody><tr>"; $table1_foot = "</tr></tbody></table>"; $table2_head = "<table cellspacing='0' cellpadding='0' class='st-grid' ><tbody>"; $table2_foot = "</tbody></table>"; $table2_row_foot = "</tr>"; //End set variable echo //ใช้คำสั่ง for เพื่อสร้างปฏิทิน =================================================================================== for ($run_day = $startday;; $run_day++) { //กำหนดวันที่ปัจจุบัน $current_day = "{$Year}-{$month}-{$run_day}"; $text_current_day = "{$Year},{$month},{$run_day}"; //กำหนดค่าเริ่มต้น array ถ้า array ว่างอยู่ if (empty($table1_row[$row_of_month - 1]) && empty($table2_row[$row_of_month - 1])) { $table1_row[$row_of_month - 1] = ""; $table2_row[$row_of_month - 1] = "<tr>"; $table2_row_event[$row_of_month - 1] = "<tr>"; } if ($row_of_month == 1) { $class = "st-dtitle-fr"; } else { $class = ""; } //ถ้าวันปัจจุบันน้อยกว่าวันแรกของเดือน if ($run_day < 1) { $table1_row[$row_of_month - 1] .= "<td class='st-bg'> </td>"; $table2_row[$row_of_month - 1] .= "<td class='st-dtitle " . $class . " st-dtitle-nonmonth' >\n\t\t\t <span>" . ($lastday_previousmonth + $run_day) . "</span>\n\t\t\t </td>"; //ถ้าวันปัจจุบันมากกว่าวันสุดท้ายของเดือน } else { if ($run_day > $last_day_of_month) { $table1_row[$row_of_month - 1] .= "<td class='st-bg'> </td>"; $table2_row[$row_of_month - 1] .= "<td class='st-dtitle " . $class . " st-dtitle-nonmonth' >\n\t\t\t <span>" . ($run_day - $last_day_of_month) . "</span>\n\t\t\t </td>"; if ($day_of_week == 7) { $weekrow[$row_of_month - 1] = "<div class='month-row weekrow" . $row_of_month . "_" . $weekrow_of_month . "' >"; //หลายค่า break; } //ถ้าวันปัจจุบันเท่ากับวันสุดท้ายของเดือน และเป็นวันสุดท้ายของสัปดาห์ } else { if ($run_day == $last_day_of_month && $day_of_week == 7) { if ($today == $current_day) { $class_today = "st-bg-today"; } else { $class_today = ""; } $table1_row[$row_of_month - 1] .= "<td class='st-bg " . $class_today . "' id='" . $current_day . "' > </td>"; $table2_row[$row_of_month - 1] .= "<td class='st-dtitle " . $class . "' id='" . $current_day . "'>\n\t\t\t <span>" . $run_day . "</span>\n\t\t\t </td>"; $weekrow[$row_of_month - 1] = "<div class='month-row weekrow" . $row_of_month . "_" . $weekrow_of_month . "' >"; //หลายค่า $table2_row_event[$row_of_month - 1] .= AssignCalendar::get_assign_event($current_day, Auth::user()->id); break; } else { if ($today == $current_day) { $class_today = "st-bg-today"; } else { $class_today = ""; } if ($run_day == 1) { $month_in_calendar = date('M', $now); } else { $month_in_calendar = ""; } $table1_row[$row_of_month - 1] .= "<td class='st-bg " . $class_today . "' id='" . $current_day . "' > </td>"; $table2_row[$row_of_month - 1] .= "<td class='st-dtitle " . $class . "' id='" . $current_day . "'>\n\t\t\t <span>" . $month_in_calendar . $run_day . "</span>\n\t\t\t </td>"; $table2_row_event[$row_of_month - 1] .= AssignCalendar::get_assign_event($current_day, Auth::user()->id); } } } //ถ้าปัจจุบันเป็นวันสุดท้ายของสัปดาห์ if ($day_of_week == 7) { $weekrow[$row_of_month - 1] = "<div class='month-row weekrow" . $row_of_month . "_" . $weekrow_of_month . "' >"; //หลายค่า $table2_row_event[$row_of_month - 1] .= "</tr>"; $day_of_week = 1; $row_of_month++; //ถ้าปัจจุบันไม่ใช่วันสุดท้ายของสัปดาห์ } else { $day_of_week++; } } //จบคำสั่ง for เพื่อสร้างปฏิทิน =================================================================================== //run เพื่อแสดงผล for ($round = 0; $round < $weekrow_of_month; $round++) { echo $weekrow[$round] . $table1_head . $table1_row[$round] . $table1_foot . $table2_head . $table2_row[$round] . $table2_row_foot . $table2_row_event[$round] . $table2_row_foot . $table2_foot . $weekrowfoot; } echo "</div>\n\t\t\t </div>\n\t\t\t </div>\n\n\t\t\t </div>\n\t\t\t"; }