public function actionCreateEvent()
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         $dU = new DateTimeHelper();
         $e = new Event();
         $e->title = $_POST['title'];
         $e->body = $_POST['body'];
         $dt = $dU->getDateTimeFromUI($_POST['end']);
         $e->end = $dt->getTimestamp();
         $dt = $dU->getDateTimeFromUI($_POST['start']);
         $e->start = $dt->getTimestamp();
         $e->user_id = Yii::app()->user->id;
         if (!$e->save()) {
             $transaction->commit();
             Response::ok(CJSON::encode(array("result" => "error", "message" => CJSON::encode($e->getErrors()))));
         } else {
             Response::ok(CJSON::encode(array("result" => "success", "message" => $e->id)));
         }
     } catch (Exception $exc) {
         $transaction->rollback();
         Yii::log($exc->getMessage(), DBLog::LOG_LEVEL_ERROR);
         Response::error(CJSON::encode(array("result" => "error", "message" => Yii::app()->params["httpErrorCode500Message"])));
     }
 }
Example #2
0
 protected function createOrUpdate(Event $model)
 {
     if (isset($_POST['Event'])) {
         $model->scenario = 'backend';
         $model->attributes = $_POST['Event'];
         $categories = EventCategory::model()->findAllByPk($_POST['Event']['categories']);
         $links = array();
         if (!$model->isNewRecord) {
             EventLink::model()->deleteAllByAttributes(array('eventId' => $model->id));
         }
         if (isset($_POST['EventLink'])) {
             foreach ($_POST['EventLink'] as $i => $info) {
                 $link = new EventLink();
                 $link->attributes = $info;
                 if (strlen($link->url) > 0) {
                     $links[] = $link;
                 }
             }
         }
         $model->categories = $categories;
         $model->links = $links;
         $model->validate();
         if ($model->save()) {
             if ($pictureSmall = CUploadedFile::getInstance($model, 'pictureSmall')) {
                 $model->pictureSmall = $pictureSmall;
             }
             if ($pictureBig = CUploadedFile::getInstance($model, 'pictureBig')) {
                 $model->pictureBig = $pictureBig;
             }
             $model->setTags($_POST['Event']['tagsString'])->save();
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
 }
Example #3
0
 public function afterDelete()
 {
     $event = new Event(['cart_id' => $this->cart_id, 'user_id' => \Users\User::$cur->id, 'cart_event_type_id' => 2, 'info' => $this->item_offer_price_id]);
     $event->save();
     \Ecommerce\Warehouse\Block::deleteList([['cart_id', $this->cart->id], ['item_offer_id', $this->price->item_offer_id]]);
     $this->cart->checkStage();
 }
Example #4
0
 public function actionAddEvent()
 {
     $data = $_POST;
     $model = new Event();
     $model->u_id = $data['uid'];
     $model->lat = $data['lat'];
     $model->lng = $data['lng'];
     $model->address = $data['address'];
     $model->message = $data['message'];
     $model->status = 0;
     if ($model->save()) {
         $e_id = $model->primaryKey;
         $model = new EventMedia();
         foreach (explode(",", $data['files'], -1) as $id) {
             $model->updateByPk($id, array("e_id" => $e_id));
         }
         $tids = explode(",", $data['tid']);
         foreach ($tids as $tid) {
             $model = new EventType();
             $model->event = $e_id;
             $model->node = $tid;
             $model->save();
         }
         echo 1;
     } else {
         echo 0;
     }
 }
Example #5
0
 private function _add()
 {
     use_helper('Validate');
     $data = $_POST['event'];
     Flash::set('event_postdata', $data);
     // Add pre-save checks here
     $errors = false;
     // CSRF checks
     if (isset($_POST['csrf_token'])) {
         $csrf_token = $_POST['csrf_token'];
         if (!SecureToken::validateToken($csrf_token, BASE_URL . 'event/add')) {
             Flash::set('error', __('Invalid CSRF token found!'));
             redirect(get_url('event/add'));
         }
     } else {
         Flash::set('error', __('No CSRF token found!'));
         redirect(get_url('event/add'));
     }
     if (empty($data['name'])) {
         Flash::set('error', __('You have to specify a event name!'));
         redirect(get_url('event/add'));
     }
     if ($errors !== false) {
         // Set the errors to be displayed.
         Flash::set('error', implode('<br/>', $errors));
         redirect(get_url('event/add'));
     }
     $oEvent = new Event();
     $last_seq = $oEvent->getLastEventSeq();
     $new_event = new Event($data);
     $new_event->created_by_id = AuthUser::getId();
     $new_event->created_on = date('Y-m-d H:i:s');
     $new_event->sequence = $last_seq + 1;
     if ($new_event->save()) {
         if (isset($_FILES)) {
             if (strlen($_FILES['upload_file']['name']) > 0) {
                 $event_id = $new_event->lastInsertId();
                 //okstmtcc 20150827 Replace image filename spaces
                 $_FILES['upload_file']['name'] = str_replace(array(" ", "(", ")"), array("_", "", ""), $_FILES['upload_file']['name']);
                 $overwrite = false;
                 $file = $this->upload_event_main_image($event_id, $_FILES['upload_file']['name'], FILES_DIR . '/event/images/', $_FILES['upload_file']['tmp_name'], $overwrite);
                 if ($file === false) {
                     Flash::set('error', __('Image has not been uploaded!'));
                     redirect(get_url('event/edit/' . $new_event->id));
                 }
             }
         }
         Flash::set('success', __('Event has been added!'));
         Observer::notify('event_after_add', $new_event->name);
         // save and quit or save and continue editing?
         if (isset($_POST['commit'])) {
             redirect(get_url('event'));
         } else {
             redirect(get_url('event/edit/' . $new_event->id));
         }
     } else {
         Flash::set('error', __('Event has not been added!'));
         redirect(get_url('event/add'));
     }
 }
Example #6
0
 /**
  * Create an event
  * @return void
  */
 private function createEvent()
 {
     // if post data is set, we are creating an event
     if (isset($_POST) && count($_POST) > 0) {
         require_once FRAMEWORK_PATH . 'models/event.php';
         $event = new Event($this->registry, 0);
         $event->setName($this->registry->getObject('db')->sanitizeData($_POST['name']));
         $event->setDescription($this->registry->getObject('db')->sanitizeData($_POST['description']));
         $event->setDate($this->registry->getObject('db')->sanitizeData($_POST['date']), false);
         $event->setStartTime($this->registry->getObject('db')->sanitizeData($_POST['start_time']));
         $event->setEndTime($this->registry->getObject('db')->sanitizeData($_POST['end_time']));
         $event->setCreator($this->registry->getObject('authenticate')->getUser()->getID());
         $event->setType($this->registry->getObject('db')->sanitizeData($_POST['type']));
         if (isset($_POST['invitees']) && is_array($_POST['invitees']) && count($_POST['invitees']) > 0) {
             // assumes invitees are added to a table using javascript, with a hidden field with name invitees[] for the ID of invitee
             $is = array();
             foreach ($_POST['invitees'] as $i) {
                 $is[] = intval($i);
             }
             $event->setInvitees($is);
         }
         $event->save();
         $this->registry->redirectUser($this->registry->buildURL(array('event', 'view', $event->getID()), '', false), 'Event created', 'Thanks, the event has been created', false);
     } else {
         $this->registry->getObject('template')->buildFromTemplates('header.tpl.php', 'events/create.tpl.php', 'footer.tpl.php');
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $postdata = file_get_contents("php://input");
     //var_dump($postdata);
     $request = json_decode($postdata);
     $model = new Event();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (array_key_exists('host_phone', $request) and array_key_exists('subject', $request) and array_key_exists('planned_time', $request) and array_key_exists('current_time', $request) and array_key_exists('invites', $request)) {
         //POST
         //host_phone
         //subject
         //planned_time
         //current_time
         //invites => "2384238034823,23423423424,42342342343,23432423"
         $user = User::model()->findByAttributes(array('phone_number' => $request->host_phone));
         $model->host_id = $user->id;
         $model->create_time = time();
         $model->planned_time = time() + (intval($request->planned_time) - intval($request->current_time));
         $model->subject = $request->subject;
         $invites = split(',', $request->invites);
         array_push($invites, $request->host_phone);
         //parse the $_POST['invites'] csv
         if ($model->save()) {
             echo $model->id;
             foreach ($invites as $invite) {
                 if (strlen($invite) < 5) {
                     continue;
                 }
                 $user = User::model()->findByAttributes(array('phone_number' => intval($invite)));
                 if (!$user or $user->status == 0) {
                     //twilio
                     if (!$user) {
                         $new_user = new User();
                         $new_user->create_time = time();
                         $new_user->phone_number = $invite;
                         $new_user->status = 0;
                         $new_user->save(false);
                     }
                     //$response = http_get("http://jakemor.com/services/sendSMS", array("number"=>$invite, 'message'=>1, 'key'=>"123"), $info);
                 } else {
                     //send user the message, etc
                     $viter = new Invite();
                     $viter->event_id = $model->id;
                     $viter->create_time = time();
                     $viter->receiver_id = $user->id;
                     $viter->sender_id = $model->host_id;
                     $viter->status = 0;
                     $viter->save(false);
                 }
             }
         } else {
             var_dump($model->errors);
         }
     } else {
         echo "did not receive parameters";
     }
 }
Example #8
0
 /**
  * @before _secure, _school
  */
 public function schedule()
 {
     if (RequestMethods::post("action") == "addEvent") {
         $date = RequestMethods::post("date");
         $date = explode("T", $date);
         $event = new Event(array("user_id" => $this->user->id, "organization_id" => $this->organization->id, "description" => RequestMethods::post("description"), "title" => RequestMethods::post("title"), "start" => $date[0] . " 00:00:00", "end" => $date[0] . " 23:59:59", "allDay" => true, "live" => true));
         $event->save();
     }
     self::redirect("/events");
 }
Example #9
0
 static function Set($Subject, $action, $Object = false, $object_is_string = false, $offset = 0)
 {
     if (!$Subject || !$action) {
         return false;
     }
     $Event = new Event();
     $Event->populate_alt(array_merge(array('subject_class' => get_class($Subject), 'subject_id' => $Subject->id, 'action' => $action), $Object != false ? array('object_class' => $object_is_string ? $Object : get_class($Object), 'object_id' => !$object_is_string ? $Object->id : null) : array()));
     $Event->set_datetime('timestamp', $offset != 0 ? time() + (int) $offset : null);
     return $Event->save();
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Event();
     if (isset($_POST['Event'])) {
         $model->attributes = $_POST['Event'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #11
0
 public function actionAdd()
 {
     $event = new Event();
     $event->scenario = 'frontend';
     $event->attributes = $_POST;
     if ($event->save()) {
         $this->send(array('id' => $event->id, 'message' => 'Создано новое событие с именем ' . $event->title));
     } else {
         $this->sendError(500, 'Error while saving event');
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Event();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Event'])) {
         $model->attributes = $_POST['Event'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #13
0
 public function test_for_table_inheritance()
 {
     $Event = new Event(array('description' => 'Uncategorized Event'));
     $this->assertTrue($Event->save());
     $Concert = new Concert(array('description' => 'Madonna at Barcelona'));
     $this->assertTrue($Concert->save());
     $OpenHouseMeeting = new OpenHouseMeeting(array('description' => 'Networking event at Akelos'));
     $this->assertTrue($OpenHouseMeeting->save());
     $this->assertEqual($OpenHouseMeeting->get('type'), 'Open house meeting');
     $this->assertTrue($OpenHouseMeeting = $Event->findFirstBy('description', 'Networking event at Akelos'));
     $this->assertEqual($OpenHouseMeeting->get('description'), 'Networking event at Akelos');
     $this->assertEqual($OpenHouseMeeting->getType(), 'OpenHouseMeeting');
 }
Example #14
0
 public function executeSave(sfWebRequest $request)
 {
     $items = $request->getParameter('events');
     $config = $request->getParameter('config');
     $place = PlaceTable::getInstance()->findOneById((int) $config['place_id']);
     $user = $this->getUser()->getGuardUser();
     $this->events = array();
     foreach ($items as $item) {
         $event = new Event();
         $event->fromArray(array('icon' => $config['icon'], 'title' => $item['title'], 'description' => $item['description'], 'fire_at' => date('Y-m-d H:i:s', strtotime($item['fire_at'])), 'place_id' => (int) $config['place_id'], 'user_id' => $user->id, 'geo_lat' => $place->geo_lat, 'geo_lng' => $place->geo_lng));
         $event->save();
         $this->events[] = $event;
     }
 }
 public static function store()
 {
     $params = $_POST;
     $team = $params['team'];
     $Event = new Event(array('description' => $params['description'], 'time' => $params['time'], 'place' => $params['place'], 'team_id' => $team));
     $errors = $Event->errors();
     if (count($errors) != 0) {
         $p = self::get_user_logged_in();
         $teams = Teammember::findByPlayer($p->id);
         View::make('/Event/new.html', array('errors' => $errors, 'event' => $Event, 'teams' => $teams));
     } else {
         $Event->save();
         Redirect::to('/event/' . $Event->id, array('message' => 'Tapahtuma luotu!'));
     }
 }
Example #16
0
 /**
  * @param Event                         $unlinkedEvent
  * @param OphInBiometry_Imported_Events $importedEvent
  */
 private function updateImportedEvent(Event $unlinkedEvent, OphInBiometry_Imported_Events $importedEvent)
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         $unlinkedEvent->episode_id = $this->episode->id;
         if ($unlinkedEvent->save()) {
             $importedEvent->is_linked = 1;
             $importedEvent->save();
         }
         $transaction->commit();
     } catch (Exception $e) {
         $transaction->rollBack();
         Yii::app()->user->setFlash('warning.event_error', "{$e->getMessage()}");
         Yii::log($e->getMessage(), CLogger::LEVEL_ERROR);
     }
 }
Example #17
0
 public function add_event()
 {
     $this->_checkPermission();
     $data = $_POST['event'];
     Flash::set('postdata', $data);
     $image = $_POST['upload'];
     $path = str_replace('..', '', $image['path']);
     $overwrite = false;
     // verification
     if (empty($data['title'])) {
         Flash::set('error', __('You have to specify a event title!'));
         redirect(get_url('event/create'));
     }
     if (empty($data['url'])) {
         Flash::set('error', __('You have to specify the "Read More" URL!'));
         redirect(get_url('event/create'));
     }
     if (isset($_FILES)) {
         // no image file selected
         if (empty($_FILES['upload_file']['name'])) {
             Flash::set('error', __('You have to select a image to be uploaded!'));
             redirect(get_url('event/create'));
         }
     } else {
         Flash::set('error', __('You have to select a image to be uploaded!'));
         redirect(get_url('event/create'));
     }
     $event = new Event($data);
     $event->created_by_id = AuthUser::getId();
     $event->created_on = date('Y-m-d H:i:s');
     if (!$event->save()) {
         Flash::set('error', __('Event is not added!'));
         redirect(get_url('event/create'));
     } else {
         if (isset($_FILES)) {
             $event_id = $event->lastInsertId();
             $file = $this->upload_file($_FILES['upload_file']['name'], FILES_DIR . '/event/images/', $_FILES['upload_file']['tmp_name'], $overwrite, $event_id);
             if ($file === false) {
                 Flash::set('error', __('File has not been uploaded!'));
             }
         }
         Flash::set('success', __('Event has been added!'));
     }
     redirect(get_url('event'));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Event();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Event'])) {
         $model->attributes = $_POST['Event'];
         $group = User::model()->findByPk(Yii::app()->user->id)->group;
         if (null === $group) {
             throw new CHttpException(404, 'The current group is not specified.');
         }
         $model->group_id = $group->id;
         if ($model->save()) {
             $this->redirect(array('admin'));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #19
0
 /**
  * Store a newly created event in storage.
  *
  * @return Response
  */
 public function store()
 {
     $faker = Faker::create();
     $directory = '/img/uploads/';
     //         $image = Input::file('img');
     $event = new Event();
     $event->event_title = Input::get('event_title');
     $event->description = Input::get('description');
     $event->date = Input::get('date');
     $event->start_time = Input::get('start_time');
     $event->venue = Input::get('venue');
     if (Input::has('venue_site')) {
         $event->venue_site = Input::get('venue_site');
     }
     if (Input::has('price')) {
         $event->price = Input::get('price');
     } else {
         $event->price = 0;
     }
     $event->zip_code = Input::get('zip_code');
     $event->city = Input::get('city');
     $event->address = Input::get('address');
     $event->state = Input::get('state');
     if (Input::hasFile('img')) {
         $file = Input::file('img');
         $filename = Auth::id() . $file->getClientOriginalName();
         $file = $file->move(public_path() . $directory, $filename);
         $event->img = $directory . $filename;
     }
     $event->img = $faker->imageUrl($width = 640, $height = 480, $category = 'nightlife');
     if (Input::hasFile('cover_img')) {
         $file = Input::file('cover_img');
         $filename = Auth::id() . $file->getClientOriginalName();
         $file = $file->move(public_path() . $directory, $filename);
         $event->cover_img = $directory . $filename;
     }
     $event->cover_img = $faker->imageUrl($width = 1103, $height = 363);
     $event->user_id = Auth::id();
     $event->save();
     Log::info("Event successfully saved.", Input::all());
     Session::flash('successMessage', 'You created ' . $event->title . ' successfully');
     return Redirect::action('events.show', $event->id);
 }
Example #20
0
 static function get_events()
 {
     $events = array();
     require dirname(__FILE__) . '/settings.php';
     $db = mysql_connect($db_host, $db_user, $db_password);
     //connect to database
     mysql_select_db($db_name, $db);
     $result = mysql_query("SELECT * FROM events WHERE dtstart > " . time() . " OR rrule > 0 ORDER BY dtstart ASC, event_id DESC", $db) or die(mysql_error());
     while ($event = mysql_fetch_assoc($result)) {
         $obj = new Event($event);
         if ($obj->repeats()) {
             $obj->save();
         }
         $events[] = $obj;
     }
     //end while event
     mysql_close($db);
     return $events;
 }
Example #21
0
 /**
  * Create a new event, or saves an edited event
  *
  * Route: /events/save
  */
 public function save($id = NULL)
 {
     // Get the POST parameters
     $e = new Event();
     if ($id != NULL) {
         $e = new Event($id);
     }
     $e->name = $this->input->post('event-name');
     $e->location = $this->input->post('event-location');
     $e->start = date("Y-m-d H:i:s", strtotime($this->input->post('event-start')));
     $e->end = date("Y-m-d H:i:s", strtotime($this->input->post('event-end')));
     $e->user_id = $this->session->userdata('id');
     $e->description = $this->input->post('event-description');
     $e->capacity = $this->input->post('event-capacity');
     $e->open = 1;
     $e->save();
     // Redirect to page for that event
     header('Location: /events/view/' . $e->id);
 }
Example #22
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aEvent !== null) {
             if ($this->aEvent->isModified() || $this->aEvent->isNew()) {
                 $affectedRows += $this->aEvent->save($con);
             }
             $this->setEvent($this->aEvent);
         }
         if ($this->aWing !== null) {
             if ($this->aWing->isModified() || $this->aWing->isNew()) {
                 $affectedRows += $this->aWing->save($con);
             }
             $this->setWing($this->aWing);
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = EventWingsPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setNew(false);
             } else {
                 $affectedRows += EventWingsPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Example #23
0
 /**
  * The file contents is looked at and events are created here.
  * @param string $fileContents
  * @return integer The number of events saved.
  */
 public function setEventsFromICal($fullDir, $fullFileName, $personId)
 {
     //start parse of local file
     $v = new vcalendar();
     // set directory
     $v->setConfig('directory', $fullDir);
     // set file name
     $v->setConfig('filename', $fullFileName);
     $v->parse();
     $count = 0;
     foreach ($v->components as $component => $info) {
         # get first vevent
         $comp = $v->getComponent("VEVENT");
         $summary_array = $comp->getProperty("summary", 1, TRUE);
         //echo "Event: ", $summary_array["value"], "\n";
         $dtstart_array = $comp->getProperty("dtstart", 1, TRUE);
         $dtstart = $dtstart_array["value"];
         $startDate = "{$dtstart["year"]}-{$dtstart["month"]}-{$dtstart["day"]}";
         $startTime = "{$dtstart["hour"]}:{$dtstart["min"]}:{$dtstart["sec"]}";
         $dtend_array = $comp->getProperty("dtend", 1, TRUE);
         $dtend = $dtend_array["value"];
         $endDate = "{$dtend["year"]}-{$dtend["month"]}-{$dtend["day"]}";
         $endTime = "{$dtend["hour"]}:{$dtend["min"]}:{$dtend["sec"]}";
         //echo "start: ",  $startDate,"T",$startTime, "\n";
         //echo "end: ",  $endDate,"T",$endTime, "\n";
         $location_array = $comp->getProperty("location", 1, TRUE);
         //echo "Location: ", $location_array["value"], "\n <br>";
         //TODO: Check that this event does not already exist.
         $event = new Event();
         $event->setPersonId($personId);
         $event->setName($summary_array["value"]);
         $event->setStartTime($startDate . "T" . $startTime);
         $event->setEndTime($endDate . "T" . $endTime);
         $event->setLocation($location_array["value"]);
         $event->save();
         $count++;
     }
     return $count;
 }
Example #24
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Event();
     $fileModel = new FileUploadFormModel();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $this->layout = '//layouts/admin';
     if (isset($_POST['Event'])) {
         //db transaction start
         $transaction = Yii::app()->db->beginTransaction();
         try {
             $model->attributes = $_POST['Event'];
             if ($model->save()) {
                 $fileModel->LoadUploadedeImage();
                 $fileModel->setScenario(FileUploadFormModel::FILE_UPLOAD_MODE_SINGLE);
                 if ($fileModel->isUploadedFile()) {
                     if ($fileModel->validate()) {
                         $ips = new ImageProcessService($fileModel, get_class($model), $model->id, "icon");
                         $ips->saveImage(300, 300);
                         $SavedFileRelativePaths = $ips->getOriginalImageVirtualPath();
                         $SavedThumbnailFileRelativePaths = $ips->getThumbnailImageVirtualPath();
                         $model->save_img_src($SavedFileRelativePaths, $SavedThumbnailFileRelativePaths);
                         $transaction->commit();
                         $this->redirect(array('view', 'id' => $model->id));
                     }
                 } else {
                     $model->save_img_src(array('img/Event/default.jpg'), array('img/Event/default.jpg'));
                     $transaction->commit();
                     $this->redirect(array('view', 'id' => $model->id));
                 }
             }
         } catch (Exception $ex) {
             $transaction->rollback();
             Yii::app()->user->setFlash(FlashMsg::ERROR, $e->getMessage());
         }
     }
     $this->render('create', array('model' => $model, 'fileModel' => $fileModel));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     if ($this->menu_use[3]) {
         $model = new Event();
         // Uncomment the following line if AJAX validation is needed
         // $this->performAjaxValidation($model);
         if (isset($_POST['Event'])) {
             list($day, $month, $year) = explode('/', $_POST['Event']['event_start']);
             $start_date = $year . '-' . $month . '-' . $day;
             $_POST['Event']['event_start'] = $start_date;
             list($day2, $month2, $year2) = explode('/', $_POST['Event']['event_end']);
             $end_date = $year2 . '-' . $month2 . '-' . $day2;
             $_POST['Event']['event_end'] = $end_date;
             $model->attributes = $_POST['Event'];
             if ($model->save()) {
                 $this->redirect(array('index'));
             }
         }
         $this->render('create', array('model' => $model));
     } else {
         $this->redirect(array('site/index'));
     }
 }
 public function run()
 {
     $faker = Faker::create();
     for ($i = 1; $i <= 200; $i++) {
         $event = new Event();
         $event->event_title = $faker->word;
         $event->date = $faker->dateTimeBetween($startDate = 'now', $endDate = '3 months');
         $event->description = $faker->realText;
         $event->price = $faker->numberBetween($min = 1, $max = 100);
         $event->start_time = $faker->time($format = 'H:i:s', $min = 'now');
         $event->venue = "Tycoon Flats";
         $event->venue_site = "flatsisback.com";
         $event->address = "2926 N. St. Marys Street";
         $event->city = "San Antonio";
         $event->state = "TX";
         $event->zip_code = "78212";
         $event->img = $faker->imageUrl($width = 640, $height = 480, $category = 'nightlife');
         // 'http://lorempixel.com/640/480/'
         $event->cover_img = $faker->imageUrl($width = 1103, $height = 363);
         $event->user_id = User::all()->random(1)->id;
         $event->save();
     }
 }
Example #27
0
 public function actionCreate()
 {
     $model = new Event();
     if (isset($_POST['Event'])) {
         $model->setAttributes($_POST['Event']);
         if (isset($_POST['Event']['page'])) {
             $model->page = $_POST['Event']['page'];
         }
         try {
             if ($model->save()) {
                 if (isset($_GET['returnUrl'])) {
                     $this->redirect($_GET['returnUrl']);
                 } else {
                     $this->redirect(array('view', 'id' => $model->id));
                 }
             }
         } catch (Exception $e) {
             $model->addError('page->title', $e->getMessage());
         }
     } elseif (isset($_GET['Event'])) {
         $model->attributes = $_GET['Event'];
     }
     $this->render('create', array('model' => $model));
 }
 public static function generate($array)
 {
     $event = new Event();
     $event->setType($array["type"]);
     $event->setParentClass(get_class($array["parent"]));
     $event->setParentId($array["parent"]->getId());
     //$event->setParentName($array["parent_name"]);
     switch ($array["type"]) {
         case "Inventory":
             $parent = $event->getParent();
             //create stockentry
             if (get_class($parent) == "Invoicedetail") {
                 $stockentry = StockTable::createStockOut(SettingsTable::fetch("default_warehouse_id"), $parent->getProductId(), $parent->getQty(), $parent->getInvoice()->getDate(), $parent);
             } else {
                 if (get_class($parent) == "Purchasedetail") {
                     $stockentry = StockTable::createStockIn(SettingsTable::fetch("default_warehouse_id"), $parent->getProductId(), $parent->getQty(), $parent->getPurchase()->getDate(), $parent);
                 }
             }
             $event->setChildClass("Stockentry");
             $event->setChildrenId($stockentry->getId());
             break;
     }
     $event->save();
 }
Example #29
0
 if ($update == null) {
     header('Location: ' . Url::error());
     exit;
 }
 $commentID = Filter::numeric($_POST['commentID']);
 $message = Filter::formattedText($_POST['message']);
 if ($message == '') {
     $json = array('error' => 'Your reply cannot be empty.');
     exit(json_encode($json));
 } else {
     // post the comment
     $reply = new Comment(array('creator_id' => Session::getUserID(), 'project_id' => $project->getID(), 'update_id' => $updateID, 'parent_id' => $commentID, 'message' => $message));
     $reply->save();
     // log it
     $logEvent = new Event(array('event_type_id' => 'create_update_comment_reply', 'project_id' => $project->getID(), 'user_1_id' => Session::getUserID(), 'item_1_id' => $commentID, 'item_2_id' => $reply->getID(), 'item_3_id' => $updateID, 'data_1' => $message));
     $logEvent->save();
     // send email notification, if desired
     $creator = User::load($update->getCreatorID());
     if ($creator->getID() != Session::getUserID()) {
         // don't email yourself
         if ($creator->getNotifyCommentTaskUpdate()) {
             // compose email
             $msg = "<p>" . formatUserLink(Session::getUserID()) . ' replied to a comment on your task update <a href="' . Url::update($updateID) . '">' . $update->getTitle() . '</a> in the project ' . formatProjectLink($project->getID()) . '. The reply was:</p>';
             $msg .= "<blockquote>" . formatUpdate($message) . "</blockquote>";
             $email = array('to' => $creator->getEmail(), 'subject' => '[' . PIPELINE_NAME . '] New comment reply on your task update in ' . $project->getTitle(), 'message' => $msg);
             // send email
             Email::send($email);
         }
     }
     // send us back
     Session::setMessage('You replied to a comment on this update.');
 private function createEvent($event_date = null)
 {
     $event = new Event();
     $event->episode_id = $this->episode['episode2']['id'];
     $event->event_type_id = Yii::app()->db->createCommand('select id from event_type where class_name = "OphCiExamination"')->queryScalar();
     if ($event_date) {
         $event->event_date = $event_date;
     }
     $event->save(false);
     return $event;
 }