1: <?php
2:
3: 4: 5: 6: 7: 8:
9: class ActivityController extends BaseController {
10:
11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27:
28: public function postDatesactivities() {
29: try {
30: $serial_usr = JWTAuth::getPayload(JWTAuth::getToken())->get('sub');
31: $user = User::find($serial_usr);
32: $serial_std = Input::get('serial_std');
33: $month = Input::get('month');
34: $year = Input::get('year');
35: $validator = Validator::make(Input::all(), Activity::rulesactivityDate());
36: if ($validator->fails()) {
37: return ws_response(true, Input::get('serial_std') . '-' . Input::get('month') . '-' . Input::get('year'), $validator->errors()->getMessages(), 200);
38: }
39: $start_date = $year . '-' . $month . '-01';
40: $end_day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
41: $end_date = $year . '-' . $month . '-' . $end_day;
42: $activity = new Activity();
43: $message = $activity->activityDates($serial_std, $start_date, $end_date);
44: $activity_dates = array();
45: foreach ($message as $value) {
46: $day_of_activity = explode('-', $value->date_date);
47: $activity_dates[] = $day_of_activity[0];
48: }
49: return ws_response(false, $activity_dates, 'Dates for Activities', 200);
50: } catch (Exception $ex) {
51: return ws_response(true, null, 'ERROR ' . $ex->getCode() . '! ' . $ex->getMessage(), 500);
52: }
53: }
54:
55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70:
71: public function postActivitiesbyday() {
72: try {
73: $serial_usr = JWTAuth::getPayload(JWTAuth::getToken())->get('sub');
74: $user = User::find($serial_usr);
75: $serial_std = Input::get('serial_std');
76: $day = Input::get('day');
77: $validator = Validator::make(Input::all(), Activity::rulesActivitiesByDay());
78: if ($validator->fails()) {
79: return ws_response(true, Input::get('serial_std') . '-' . Input::get('day'), $validator->errors()->getMessages(), 200);
80: }
81: $activity = new Activity();
82: $message = $activity->ActivitiesByDay($day, $serial_std);
83:
84: return ws_response(false, $message, 'Activities By Day', 200);
85: } catch (Exception $ex) {
86: return ws_response(true, null, 'ERROR ' . $ex->getCode() . '! ' . $ex->getMessage(), 500);
87: }
88: }
89:
90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105:
106: public function postActivitydetails() {
107: try {
108: $serial_usr = JWTAuth::getPayload(JWTAuth::getToken())->get('sub');
109: $serial_act = Input::get('serial_act');
110: $optative = strtoupper(Input::get('optative'));
111: $validator = Validator::make(Input::all(), Activity::rulesActivityDetails());
112: if ($validator->fails()) {
113: return ws_response(true, Input::get('serial_act') . '-' . Input::get('optative'), $validator->errors()->getMessages(), 200);
114: }
115: $activity = new Activity();
116: $message = $activity->ActivityDetails($serial_act, $optative);
117: $old_format_date_send = explode('-', $message['send_date']);
118: $old_format_date_due = explode('-', $message['due_date']);
119: $array_days = array('Monday' => 'Lunes', 'Tuesday' => 'Martes', 'Wednesday' => 'MiƩrcoles', 'Thursday' => 'Jueves', 'Friday' => 'Viernes', 'Saturday' => 'Sabado', 'Sunday' => 'Domingo');
120: $array_month = array('January' => 'Enero', 'February' => 'Febrero', 'March' => 'Marzo', 'April' => 'Abril', 'May' => 'Mayo', 'June' => 'Junio', 'July' => 'Julio', 'August' => 'Agostro', 'September' => 'Septiembre', 'October' => 'Octubre', 'November' => 'Noviembre', 'December' => 'Diciembre');
121: $number_month = array('January' => '01', 'February' => '02', 'March' => '03', 'April' => '04', 'May' => '05', 'June' => '06', 'July' => '07', 'August' => '08', 'September' => '09', 'October' => '10', 'November' => '11', 'December' => '12');
122: $new_format_date_send = $array_days[$old_format_date_send[0]] . ', ' . $old_format_date_send[1] . ' de ' . $array_month[$old_format_date_send[2]] . ', ' . $old_format_date_due[3];
123: $new_format_date_due = $array_days[$old_format_date_due[0]] . ', ' . $old_format_date_due[1] . ' de ' . $array_month[$old_format_date_due[2]] . ', ' . $old_format_date_due[3];
124: $message['send_date'] = $new_format_date_send;
125: $message['due_date'] = $new_format_date_due;
126: $message['due_day'] = $old_format_date_due[1];
127: $message['due_month'] = $number_month[$old_format_date_due[2]];
128: $message['due_year'] = $old_format_date_due[3];
129: return ws_response(false, $message, 'Activities Details', 200);
130: } catch (Exception $ex) {
131: return ws_response(true, null, 'ERROR ' . $ex->getCode() . '! ' . $ex->getMessage(), 500);
132: }
133: }
134:
135: }
136: