Esempio n. 1
0
 public function createCheckoutLog($checkout_at = null, $admin, $user, $expected_checkin = null, $note = null)
 {
     $logaction = new Actionlog();
     $logaction->asset_id = $this->id;
     $logaction->checkedout_to = $this->assigned_to;
     $logaction->asset_type = 'hardware';
     $logaction->location_id = $user->location_id;
     $logaction->adminlog()->associate($admin);
     $logaction->note = $note;
     if ($checkout_at) {
         $logaction->created_at = $checkout_at;
     }
     $log = $logaction->logaction('checkout');
     return $logaction->id;
 }
Esempio n. 2
0
 public function run()
 {
     // Initialize empty array
     $assetlog = array();
     $date = new DateTime();
     $assetlog[] = array('user_id' => '1', 'action_type' => 'checkout', 'asset_id' => '1', 'checkedout_to' => '1', 'location_id' => '3', 'created_at' => $date->modify('-10 day'), 'asset_type' => 'hardware', 'note' => NULL, 'filename' => NULL);
     $assetlog[] = array('user_id' => '1', 'action_type' => 'checkin from', 'asset_id' => '1', 'checkedout_to' => '1', 'location_id' => NULL, 'created_at' => $date->modify('-10 day'), 'asset_type' => 'hardware', 'note' => NULL, 'filename' => NULL);
     $assetlog[] = array('user_id' => '1', 'action_type' => 'checkout', 'asset_id' => '1', 'checkedout_to' => '1', 'location_id' => '3', 'created_at' => $date->modify('-10 day'), 'asset_type' => 'software', 'note' => NULL, 'filename' => NULL);
     $assetlog[] = array('user_id' => '1', 'action_type' => 'checkin from', 'asset_id' => '1', 'checkedout_to' => '1', 'location_id' => NULL, 'created_at' => $date->modify('-10 day'), 'asset_type' => 'software', 'note' => NULL, 'filename' => NULL);
     // Delete all the old data
     DB::table('asset_logs')->truncate();
     // Insert the new posts
     Actionlog::insert($assetlog);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     if (!Schema::hasColumn('asset_logs', 'thread_id')) {
         Schema::table('asset_logs', function (Blueprint $table) {
             $table->integer('thread_id')->nullable()->default(null);
             $table->index('thread_id');
         });
     }
     $this->actionlog = new App\Models\Actionlog();
     $this->assetLogs = $this->actionlog->getListingOfActionLogsChronologicalOrder();
     foreach ($this->assetLogs as $assetLog) {
         if ($this->hasAssetChanged($assetLog)) {
             $this->resetCurrentAssetInformation($assetLog);
         }
         if ($this->hasBegunNewChain($assetLog)) {
             $this->startOfCurrentThread = false;
             continue;
         }
         $this->updateAssetLogWithThreadInformation($assetLog);
         if ($this->hasReachedEndOfChain($assetLog)) {
             $this->clearCurrentAssetInformation();
         }
     }
 }
 /**
  * updateAssetLogWithThreadInformation
  *
  * @param $assetLog
  *
  * @author  Vincent Sposato <*****@*****.**>
  * @version v1.0
  */
 protected function updateAssetLogWithThreadInformation($assetLog)
 {
     $loadedAssetLog = Actionlog::find($assetLog->id);
     $loadedAssetLog->thread_id = $this->currentAssetLogId;
     $loadedAssetLog->update();
     unset($loadedAssetLog);
 }