Overview

Packages

  • controladores
  • modelos
  • None
  • PHP

Classes

  • Activity
  • ActivityController
  • AuthController
  • BaseController
  • Course
  • DatabaseSeeder
  • ExampleTest
  • Guardian
  • HomeController
  • Message
  • MessageController
  • OptStudentCriteriaGrade
  • Period
  • Profile
  • SchoolSetup
  • Student
  • StudentCriteriaGrade
  • StudentSubjectSubperiodAverage
  • StudentSubjectSubperiodAverageController
  • SubPeriod
  • TestCase
  • User
  • UserController

Exceptions

  • Exception
  • InvalidArgumentException
  • LogicException

Functions

  • ws_response
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * Controlador de las actividades
  5:  * @package controladores
  6:  * @author David Castro
  7:  * @since  2016-02-23
  8:  */
  9: class ActivityController extends BaseController {
 10: 
 11:     /**
 12:      * Metodo para los mensajes de los usuarios
 13:      *
 14:      * @param   integer $serial_std 
 15:      * @param   date $month
 16:      * @param   date $year
 17:      * 
 18:      * @return  date  $activity_dates
 19:      * @throws  InvalidArgumentException
 20:      * @since   2016-02-24
 21:      * @author  David Castro
 22:      *
 23:      * @edit    2016-02-24<br />
 24:      *          David Castro<br />
 25:      *          documentacion del metodo<br/>
 26:      *          #edit1
 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:      * Metodo para devolver las actividades por dia
 57:      *
 58:      * @param   integer $serial_std
 59:      * @param   date $day
 60:      *
 61:      * @return  array $message
 62:      * @throws  InvalidArgumentException
 63:      * @since   2016-02-24
 64:      * @author  David Castro
 65:      *
 66:      * @edit    2016-02-24<br />
 67:      *          David Castro<br />
 68:      *          documentacion del metodo<br/>
 69:      *          #edit1
 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:             //dd($message);
 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:      * Metodo para obtener el detalle de las actividades
 92:      *
 93:      * @param   integer $serial_act
 94:      * @param   String $optative
 95:      *
 96:      * @return  array $message
 97:      * @throws  InvalidArgumentException
 98:      * @since   2016-02-24
 99:      * @author  David Castro
100:      *
101:      * @edit    2016-02-24<br />
102:      *          David Castro<br />
103:      *          documentacion del metodo<br/>
104:      *          #edit1
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: 
learnbox_ws API documentation generated by ApiGen