public static function fetchByName($title, $fund, $period, $type, $author, $accountno, $preparedby1, $preparedby2, $certifiedby1, $certifiedby2)
 {
     if (!$title) {
         return;
     }
     //remove "page 1" from title
     $start = strpos($title, " page ");
     if ($start === false) {
         $journaltitle = $title;
     } else {
         $journaltitle = substr($title, 0, $start);
     }
     //search journal with title in database
     //if not found, create
     $journal = Doctrine::getTable('Journal')->findOneByName($journaltitle);
     if (!$journal) {
         //create one
         $journal = new Journal();
         $journal->setName($journaltitle);
         $journal->setFundId($fund->getId());
         $journal->setPeriodId($period->getId());
         $journal->setType($type);
         $journal->setAuthor($author);
         $journal->setAccountno($accountno);
         $journal->setPreparedby1($preparedby1);
         $journal->setPreparedby2($preparedby2);
         $journal->setCertifiedby1($certifiedby1);
         $journal->setCertifiedby2($certifiedby2);
         $journal->save();
     }
     return $journal;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('publish_date' => 'required|date|unique_with:journals,user_id,publish_date', 'contents' => 'required');
     $request = Request::all();
     $errors = $this->validateAndReturnErrors($request, $rules);
     if ($errors) {
         return Response::json(array('message' => 'The following errors were encountered ', 'errors' => $errors), 400);
     }
     $journal = new Journal();
     $journal->user_id = Authorizer::getResourceOwnerId();
     $journal->publish_date = Carbon::parse($request['publish_date']);
     $journal->volume = $journal->publish_date->diffInMonths(Config::get('constants.ANNIVERSARY')) + 2;
     $journal->day = $journal->publish_date->diffInDays(Config::get('constants.ANNIVERSARY')) + 1;
     $journal->contents = $request['contents'];
     $journal->special_events = array_key_exists('special_events', $request) ? $request['special_events'] : '';
     try {
         $journal->save();
     } catch (Illuminate\Database\QueryException $e) {
         $error = $e->errorInfo;
         if ($error[1] = 1062) {
             //Duplicate Entry
             return Response::json(['error' => '1062', 'error_description' => 'Your journal entry for this date already exists'], 409);
         }
     }
     return Response::json(['message' => 'The resource has been successfuly created', 'journals' => $journal], 201);
 }
Exemplo n.º 3
0
 public function actionUpgrade()
 {
     $player = Player::model()->findByAttributes(array('email' => Yii::app()->user->id));
     $ship = Ship::model()->findByAttributes(array('id' => $player->id));
     if ($ship == null) {
         $this->redirect($this->createUrl('player/Needship'));
         return;
     }
     // Получить ссылку на все предметы игрока
     $person_prototype_items_shop = $ship->getBuyNextMagazinesForType();
     if (!isset($_GET['type'])) {
         $this->redirect($this->createUrl('player/myship'));
         return;
     }
     $type_item = $_GET['type'];
     // Получить текущий список по типу покупаемой вещи
     $type_buy = $person_prototype_items_shop[$type_item];
     // Получить текущую ИД текущей установленной вещи
     $id_ship_item = $ship->getParamForKeyPrototype($type_item);
     // Получить покупаемую вещь (следующюю по счету)
     $buy_item = $type_buy[$id_ship_item + 1];
     if ($player->setSummBuyPlus(-$buy_item['summ'])) {
         $ship->setNewItemToshipAndUpdateSummship($type_item, $buy_item['summ'], $buy_item['gfx_ship']);
         $journal = new Journal();
         $journal->item_id = $buy_item['id'];
         $journal->type = $type_item;
         $journal->summ = $buy_item['summ'];
         $journal->id_player = $player->id;
         $journal->save();
         $this->redirect($this->createUrl('/player/myship'));
     } else {
         $this->render('noMoney');
     }
 }
Exemplo n.º 4
0
 public function debitAccount($data, $trans_no)
 {
     $journal = new Journal();
     $account = Account::findOrFail($data['debit_account']);
     $journal->account()->associate($account);
     $journal->date = $data['date'];
     $journal->trans_no = $trans_no;
     $journal->initiated_by = $data['initiated_by'];
     $journal->amount = $data['amount'];
     $journal->type = 'debit';
     $journal->description = $data['description'];
     $journal->save();
 }
Exemplo n.º 5
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Journal();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Journal'])) {
         $model->attributes = $_POST['Journal'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function run()
 {
     DB::table('journals')->truncate();
     $faker = Faker\Factory::create();
     foreach (range(1, 50) as $index) {
         $journal = new Journal();
         $journal->user_id = $faker->randomDigit();
         $journal->publish_date = Carbon::instance($faker->dateTimeBetween($startDate = Config::get('constants.ANNIVERSARY')));
         $journal->volume = $journal->publish_date->diffInMonths(Config::get('constants.ANNIVERSARY')) + 2;
         $journal->day = $journal->publish_date->diffInDays(Config::get('constants.ANNIVERSARY')) + 1;
         $journal->contents = implode("\n\n", $faker->paragraphs(5));
         $journal->special_events = implode("\n", $faker->sentences(2));
         $journal->save();
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $input = $request->all();
     $journal = new Journal();
     $journal->Title = $input['title'];
     $journal->Description = $input['description'];
     $journal->Frequency = $input['frequency'];
     /*$journal->Logo=$input['logo'];*/
     if (isset($input['img'])) {
         $Image = $input['img'];
         //dd($Image);
         $Image = $this->imageUpload($Image);
         //dd($Image);
         $input['img'] = $Image;
     } else {
         $input['img'] = "reg_img/default.gif";
     }
     $journal = new Journal(array('title' => $request->get('title'), 'img' => $Image));
     $journal->Language = $input['language'];
     $journal->save();
     return redirect('/journal');
 }
Exemplo n.º 8
0
 public function storeData($walletID)
 {
     $attributes = $this->apiAttributes();
     $character = Characters::Model()->findByPk($walletID);
     //Retrieve the XML dataset
     $journal = $this->getEVEData($walletID);
     if (!isset($journal->error)) {
         foreach ($journal->result->rowset->row as $row) {
             if ($character->limitUpdate) {
                 $orderTime = strtotime($row->attributes()->date);
                 $timeLimit = strtotime($character->limitDate);
             } else {
                 $orderTime = 1;
                 $timeLimit = 0;
             }
             $exist = Journal::Model()->exists('refID=:refID', array(':refID' => $row->attributes()->refID));
             if (!$exist && $orderTime > $timeLimit) {
                 $orderRow = new Journal();
                 $orderRow->date = $row->attributes()->date;
                 $orderRow->refID = $row->attributes()->refID;
                 $orderRow->refTypeID = $row->attributes()->refTypeID;
                 $orderRow->ownerName1 = $row->attributes()->ownerName1;
                 $orderRow->ownerID1 = $row->attributes()->ownerID1;
                 $orderRow->ownerName2 = $row->attributes()->ownerName2;
                 $orderRow->ownerID2 = $row->attributes()->ownerID2;
                 $orderRow->argName1 = $row->attributes()->argName1;
                 $orderRow->argID1 = $row->attributes()->argID1;
                 $orderRow->amount = $row->attributes()->amount;
                 $orderRow->balance = $row->attributes()->balance;
                 $orderRow->reason = $row->attributes()->reason;
                 $orderRow->characterID = $walletID;
                 $orderRow->save();
             }
         }
     }
 }
Exemplo n.º 9
0
 function testLastEntry()
 {
     $content = "What is the meaning of life?";
     $date = date("Y-m-d");
     $test_journal = new Journal($content, $date);
     $test_journal->save();
     $content2 = "I hate my dad";
     $date2 = "2012-09-13";
     $test_journal2 = new Journal($content2, $date2);
     $test_journal2->save();
     $result = Journal::lastEntry();
     $this->assertEquals($date, $result);
 }
Exemplo n.º 10
0
                    $object->setUserId($data['userId']);
                }
                if (isset($data['journalDate'])) {
                    $object->setJournalDate($data['journalDate']);
                }
                if (isset($data['journalTitle'])) {
                    $object->setJournalTitle($data['journalTitle']);
                }
                if (isset($data['journalText'])) {
                    $object->setJournalText($data['journalText']);
                }
                if (isset($data['deleted'])) {
                    $object->setDeleted($data['deleted']);
                }
                if (isset($data['hash'])) {
                    $object->setHash($data['hash']);
                }
                if ($object->save()) {
                    $response = successResponse();
                } else {
                    $response = errorResponse(RESPONSE_INTERNAL_ERROR);
                }
            } else {
                $response = errorResponse(RESPONSE_BAD_REQUEST, 'tripId or journalId not set');
            }
        } else {
            $response = errorResponse(RESPONSE_BAD_REQUEST, 'not GET or PUT response');
        }
    }
}
echo json_encode($response);
Exemplo n.º 11
0
 /**
  * Test #11. SYNCH get an existent object.
  * @depends testDataWipedBeforeTest
  * @depends testGetExistent
  */
 public function testSynchGet()
 {
     global $testTripId1;
     global $testJournalId1;
     global $synchAuthToken;
     // Create the object and set attributes
     $object = new Journal($testTripId1, $testJournalId1);
     $object->setUserId('user');
     $object->setJournalDate('2015-09-30');
     $object->setJournalTitle('Journal Title');
     $object->setJournalText('Journal Text');
     $object->setDeleted('Y');
     // Save the object and confirm a row is added to the database
     $this->assertTrue($object->save());
     $this->assertEquals(1, $this->countTestRows());
     $data = array('hash' => $object->getHash());
     $result = getApi('synchJournal.php', $data, $synchAuthToken);
     $this->assertEquals(RESPONSE_SUCCESS, $result['resultCode']);
     $this->assertTrue(isset($result['tripId']));
     $this->assertTrue(isset($result['journalId']));
     $this->assertTrue(isset($result['created']));
     $this->assertTrue(isset($result['updated']));
     $this->assertTrue(isset($result['userId']));
     $this->assertTrue(isset($result['journalDate']));
     $this->assertTrue(isset($result['journalTitle']));
     $this->assertTrue(isset($result['journalText']));
     $this->assertTrue(isset($result['deleted']));
     $this->assertTrue(isset($result['hash']));
     $this->assertEquals($testTripId1, $result['tripId']);
     $this->assertEquals($testJournalId1, $result['journalId']);
     $this->assertEquals($object->getCreated(), $result['created']);
     $this->assertEquals($object->getUpdated(), $result['updated']);
     $this->assertEquals('user', $result['userId']);
     $this->assertEquals('2015-09-30', $result['journalDate']);
     $this->assertEquals('Journal Title', $result['journalTitle']);
     $this->assertEquals('Journal Text', $result['journalText']);
     $this->assertEquals('Y', $result['deleted']);
     $this->assertEquals($object->getHash(), $result['hash']);
 }
Exemplo n.º 12
0
 /**
  * Test #19. 
  * Iteration functions, when the journal entries have the same date
  * @depends testIterationDifferentDates
  */
 public function testIterationSameDate()
 {
     global $testTripId1;
     global $testJournalId1, $testJournalId2;
     global $testJournalId3, $testJournalId4;
     // Creat journal entries. For testing purposes, the entries will
     // be ordered in sequence (Id1, Id2, Id3, Id4). They are created
     // in this order, since we're testing on creation timestamp
     $journal1 = new Journal($testTripId1, $testJournalId1);
     $journal1->setJournalDate('2015-10-01');
     $this->assertTrue($journal1->save());
     $journal2 = new Journal($testTripId1, $testJournalId2);
     $journal2->setJournalDate('2015-10-01');
     $this->assertTrue($journal2->save());
     $journal3 = new Journal($testTripId1, $testJournalId3);
     $journal3->setJournalDate('2015-10-01');
     $this->assertTrue($journal3->save());
     $journal4 = new Journal($testTripId1, $testJournalId4);
     $journal4->setJournalDate('2015-10-01');
     $this->assertTrue($journal4->save());
     $test = Journal::getFirstJournal($testTripId1);
     $this->assertEquals($testTripId1, $test->getTripId());
     $this->assertEquals($testJournalId1, $test->getJournalId());
     $test = Journal::getLastJournal($testTripId1);
     $this->assertEquals($testTripId1, $test->getTripId());
     $this->assertEquals($testJournalId4, $test->getJournalId());
     $test = $journal1->getPreviousJournal();
     $this->assertNull($test);
     $test = $journal1->getNextJournal();
     $this->assertEquals($testJournalId2, $test->getJournalId());
     $test = $journal2->getPreviousJournal();
     $this->assertEquals($testJournalId1, $test->getJournalId());
     $test = $journal2->getNextJournal();
     $this->assertEquals($testJournalId3, $test->getJournalId());
     $test = $journal3->getPreviousJournal();
     $this->assertEquals($testJournalId2, $test->getJournalId());
     $test = $journal3->getNextJournal();
     $this->assertEquals($testJournalId4, $test->getJournalId());
     $test = $journal4->getPreviousJournal();
     $this->assertEquals($testJournalId3, $test->getJournalId());
     $test = $journal4->getNextJournal();
     $this->assertNull($test);
 }
Exemplo n.º 13
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 corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aJournal !== null) {
             if ($this->aJournal->isModified() || $this->aJournal->isNew()) {
                 $affectedRows += $this->aJournal->save($con);
             }
             $this->setJournal($this->aJournal);
         }
         if ($this->aUserRelatedByCreatedBy !== null) {
             if ($this->aUserRelatedByCreatedBy->isModified() || $this->aUserRelatedByCreatedBy->isNew()) {
                 $affectedRows += $this->aUserRelatedByCreatedBy->save($con);
             }
             $this->setUserRelatedByCreatedBy($this->aUserRelatedByCreatedBy);
         }
         if ($this->aUserRelatedByUpdatedBy !== null) {
             if ($this->aUserRelatedByUpdatedBy->isModified() || $this->aUserRelatedByUpdatedBy->isNew()) {
                 $affectedRows += $this->aUserRelatedByUpdatedBy->save($con);
             }
             $this->setUserRelatedByUpdatedBy($this->aUserRelatedByUpdatedBy);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->journalCommentsScheduledForDeletion !== null) {
             if (!$this->journalCommentsScheduledForDeletion->isEmpty()) {
                 JournalCommentQuery::create()->filterByPrimaryKeys($this->journalCommentsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->journalCommentsScheduledForDeletion = null;
             }
         }
         if ($this->collJournalComments !== null) {
             foreach ($this->collJournalComments as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->journalEntryImagesScheduledForDeletion !== null) {
             if (!$this->journalEntryImagesScheduledForDeletion->isEmpty()) {
                 JournalEntryImageQuery::create()->filterByPrimaryKeys($this->journalEntryImagesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->journalEntryImagesScheduledForDeletion = null;
             }
         }
         if ($this->collJournalEntryImages !== null) {
             foreach ($this->collJournalEntryImages as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Exemplo n.º 14
0
 public function createEmptyJournal()
 {
     $journal = new Journal();
     $this->assertFalse($journal->save());
 }
Exemplo n.º 15
0
    $todays_date = date("M-d-Y");
    $entries = Journal::getAll();
    $existing_entry = "";
    foreach ($entries as $entry) {
        if ($entry->getDate() == date("Y-m-d")) {
            $existing_entry .= $entry->getContent();
        }
    }
    return $app['twig']->render('journal/new_journal_entry.html.twig', array('date' => $todays_date, 'existing_entry' => $existing_entry));
});
$journal->post('/save_journal_entry', function () use($app) {
    $entry = $_POST['entry'];
    $time_zone = date_default_timezone_set('America/Los_Angeles');
    $entry_date = date("Y-m-d");
    $todays_entry = new Journal($entry, $entry_date);
    $todays_entry->save();
    return $app['twig']->render('journal/edit_journal_entry.html.twig', array('journal' => $todays_entry));
});
$journal->get('/entries/{id}', function ($id) use($app) {
    $entry = Journal::find($id);
    return $app['twig']->render('journal/entry.html.twig', array('entry' => $entry));
});
$journal->patch('/entries/{id}', function ($id) use($app) {
    $entry = Journal::find($id);
    $entry_content = $entry->getContent();
    $latest_entry = $entry_content . " " . $_POST['content'];
    $entry->updateContent($latest_entry);
    return $app['twig']->render('journal/entry.html.twig', array('entry' => $entry));
});
$journal->patch('/entries_edit/{id}', function ($id) use($app) {
    $entry = Journal::find($id);