public function actionsaveNotes()
 {
     $noteModel = Notes::model()->findByAttributes(array('form' => $_POST['model'], 'cus_id' => getCurCusId()));
     if (!$noteModel) {
         $noteModel = new Notes();
     }
     if (isset($_POST['notes']) && isset($_POST['model'])) {
         $noteModel->text = $_POST['notes'];
         $noteModel->form = $_POST['model'];
         $noteModel->cus_id = getCurCusId();
         $noteModel->save();
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Notes();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Notes'])) {
         $model->attributes = $_POST['Notes'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('notes' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         return Redirect::to('notes/create')->withErrors($validator)->withInput(Input::except('password'));
     } else {
         // store
         $notes = new Notes();
         $notes->notes = Input::get('notes');
         $notes->save();
         // redirect
         Session::flash('message', 'Successfully created note!');
         return Redirect::to('notes');
     }
 }
Example #4
0
 public function actionCreate()
 {
     $data = $_POST;
     //will be empty if CSRF authentication fails
     if (!empty($data)) {
         $note = new Notes();
         $note->project_id = isset($data['project_id']) ? $data['project_id'] : Applications::model()->findByPk($data['application_id'])->project_id;
         $note->application_id = isset($data['application_id']) ? $data['application_id'] : NULL;
         $note->notes = trim($data['notes']);
         $note->date_created = date("Y-m-d H:i:s");
         $note->date_updated = '0000-00-00 00:00:00';
         $note->created_by = Yii::app()->user->name;
         $note->save();
         echo CJSON::encode(array('type' => 'success', 'data' => $note));
     } else {
         echo CJSON::encode(array('type' => 'error', 'data' => 'CSRF_ERROR: CSRF Token did not match'));
     }
 }
 public function executeAutogenchildren(sfWebRequest $request)
 {
     $notes = NotesTable::fetch($request->getParameter("id"));
     $notes->getName();
     $childrennames = explode("\n", $request->getParameter("text"));
     $priority = 2;
     foreach ($childrennames as $childname) {
         if (trim($childname) == "") {
             continue;
         }
         $child = new Notes();
         $child["name"] = $childname;
         $child["content"] = $childname;
         $child["parent_id"] = $notes->getId();
         $child["priority"] = $priority;
         $child->save();
         $priority += 2;
     }
     $this->redirect($request->getReferer());
 }
Example #6
0
 /**
  * Save all the data in the database
  * @param array $data
  * @param integer $id
  */
 public static function saveAll(array $data, $id, $userId)
 {
     if (!empty($data) && is_array($data)) {
         if (is_numeric($id)) {
             $note = Doctrine::getTable('Notes')->find($id);
             if ($note->user_id != $userId) {
                 return false;
             }
         } else {
             $note = new Notes();
             $note->created = date('Y-m-d H:i:s');
         }
         $note->name = $data['name'];
         $note->note = $data['note'];
         $note->user_id = $userId;
         $note->changed = date('Y-m-d H:i:s');
         $note->expire = !empty($data['expire']) ? Shineisp_Commons_Utilities::formatDateIn($data['expire']) : null;
         $note->save();
         return $note['note_id'];
     }
     return false;
 }