/**
  * Attempts to upload a file, adds it to the database and removes other database entries for that file type if they are asked to be removed
  * @param  string  $field             The name of the $_FILES field you want to upload
  * @param  boolean $upload_type       The type of upload ('news', 'gallery', 'section') etc
  * @param  boolean $type_id           The ID of the item (above) that the upload is linked to
  * @param  boolean $remove_existing   Setting this to true will remove all existing uploads of the passed in type (useful for replacing news article images when a new one is uploaded for example)
  * @return object                     Returns the upload object so we can work with the uploaded file and details
  */
 public static function upload($field = 'image', $upload_type = false, $type_id = false, $remove_existing = false)
 {
     if (!$field || !$upload_type || !$type_id) {
         return false;
     }
     $input = Input::file($field);
     if ($input && $input['error'] == UPLOAD_ERR_OK) {
         if ($remove_existing) {
             static::remove($upload_type, $type_id);
         }
         $ext = File::extension($input['name']);
         $filename = Str::slug(Input::get('title'), '-');
         Input::upload('image', './uploads/' . $filename . '.' . $ext);
         $upload = new Upload();
         $upload->link_type = $upload_type;
         $upload->link_id = $type_id;
         $upload->filename = $filename . '.' . $ext;
         if (Koki::is_image('./uploads/' . $filename . '.' . $ext)) {
             $upload->small_filename = $filename . '_small' . '.' . $ext;
             $upload->thumb_filename = $filename . '_thumb' . '.' . $ext;
             $upload->image = 1;
         }
         $upload->extension = $ext;
         $upload->user_id = Auth::user()->id;
         $upload->save();
         return $upload;
     }
 }
Exemplo n.º 2
0
 public function get_add()
 {
     $this->data['pools'] = Koki::to_dropdown(Pool::all(), 'id', 'pool_name', array(0 => 'All'));
     $this->data['users'] = Koki::to_dropdown(User::all(), 'id', 'first_name');
     $this->data['create'] = true;
     return View::make('themes.modul.' . $this->views . '.form', $this->data);
 }
Exemplo n.º 3
0
 /**
  * Attempts to upload a file, adds it to the database and removes other database entries for that file type if they are asked to be removed
  * @param  string  $field             The name of the $_FILES field you want to upload
  * @param  boolean $upload_type       The type of upload ('news', 'gallery', 'section') etc
  * @param  boolean $type_id           The ID of the item (above) that the upload is linked to
  * @param  boolean $remove_existing   Setting this to true will remove all existing uploads of the passed in type (useful for replacing news article images when a new on
  * @param  boolean $title             Sets the title of the upload
  * @param  boolean $path_to_store     Sets the path to the upload (where it should go)
  * @return object                     Returns the upload object so we can work with the uploaded file and details
  */
 public static function upload($details = array())
 {
     $upload_details = array('remove_existing_for_link' => true, 'path_to_store' => path('public') . 'uploads/', 'resizing' => array('small' => array('w' => 200, 'h' => 200), 'thumb' => array('w' => 200, 'h' => 200)));
     if (!empty($details)) {
         $required_keys = array('upload_field_name', 'upload_type', 'upload_link_id', 'title');
         $continue = true;
         foreach ($required_keys as $key) {
             if (!isset($details[$key]) || empty($details[$key])) {
                 Messages::add('error', 'Your upload array details are not complete... please fill this in properly.');
                 $continue = false;
             }
         }
         if ($continue) {
             $configuration = $details + $upload_details;
             $input = Input::file($configuration['upload_field_name']);
             if ($input && $input['error'] == UPLOAD_ERR_OK) {
                 if ($configuration['remove_existing_for_link']) {
                     static::remove($configuration['upload_type'], $configuration['upload_link_id']);
                 }
                 $ext = File::extension($input['name']);
                 $filename = Str::slug($configuration['upload_type'] . '-' . $configuration['upload_link_id'] . '-' . Str::limit(md5($input['name']), 10, false) . '-' . $configuration['title'], '-');
                 Input::upload($configuration['upload_field_name'], $configuration['path_to_store'], $filename . '.' . $ext);
                 $upload = new Upload();
                 $upload->link_type = $configuration['upload_type'];
                 $upload->link_id = $configuration['upload_link_id'];
                 $upload->filename = $filename . '.' . $ext;
                 if (Koki::is_image($configuration['path_to_store'] . $filename . '.' . $ext)) {
                     $upload->small_filename = $filename . '_small' . '.' . $ext;
                     $upload->thumb_filename = $filename . '_thumb' . '.' . $ext;
                     $upload->image = 1;
                 }
                 $upload->extension = $ext;
                 $upload->user_id = Auth::user()->id;
                 $upload->save();
                 if (Koki::is_image($configuration['path_to_store'] . $filename . '.' . $ext)) {
                     WideImage::load($configuration['path_to_store'] . $upload->filename)->resize($configuration['resizing']['small']['w'], $configuration['resizing']['small']['h'])->saveToFile($configuration['path_to_store'] . $upload->small_filename);
                     WideImage::load($configuration['path_to_store'] . $upload->small_filename)->crop('center', 'center', $configuration['resizing']['thumb']['w'], $configuration['resizing']['thumb']['h'])->saveToFile($configuration['path_to_store'] . $upload->thumb_filename);
                 }
                 return true;
             }
         }
     } else {
         Messages::add('error', 'Your upload array details are empty... please fill this in properly.');
     }
     return false;
 }
 public function upload($field = 'image', $upload_type = false, $type_id = false)
 {
     if (!$field || !$upload_type || !$type_id) {
         return false;
     }
     if (Input::file($field)) {
         $input = Input::file('image');
         $ext = File::extension($input['name']);
         $filename = Str::slug(Input::get('title'), '-');
         Input::upload('image', './uploads/' . $filename . '.' . $ext);
         $upload = new Upload();
         $upload->link_type = $upload_type;
         $upload->link_id = $type_id;
         $upload->filename = $filename . '.' . $ext;
         if (Koki::is_image('./uploads/' . $filename . '.' . $ext)) {
             $upload->small_filename = $filename . '_small' . '.' . $ext;
             $upload->thumb_filename = $filename . '_thumb' . '.' . $ext;
             $upload->image = 1;
         }
         $upload->extension = $ext;
         $upload->save();
         return $upload;
     }
 }
Exemplo n.º 5
0
          </fieldset>
          
           <div class="form-actions">
            <a class="btn" href="{{url('roles')}}">Go Back</a>
            <input type="submit" class="btn btn-primary" value="{{ ($create ? 'Create Role' : 'Save Role') }}" />
          </div>
          <?php 
if ($users) {
    echo '<fieldset><legend>Users Assigned To This Role</legend><div class="control-group">';
    echo Form::label('user_list', 'Role\'s Users', array('class' => 'control-label'));
    foreach ($users as $user) {
        ?>
              <div class="controls">
                <label class="checkbox">
                  <?php 
        echo Form::checkbox('users[' . $user->id . ']', '1', Input::old('users[' . $user->id . ']') || $create ? Input::old('users[' . $user->id . ']') : Koki::has_role($user, $role->id));
        ?>
                  <?php 
        echo $user->fullname;
        ?>
                </label>
              </div>
            </div>
          <?php 
    }
    echo '</fieldset>';
}
?>

{{Form::close()}}
Exemplo n.º 6
0
 public function get_rekapsetoran()
 {
     $shifts = Shift::all();
     $pool_id = Auth::user()->pool_id;
     $shiftoption = Koki::to_dropdown($shifts, 'id', 'shift');
     $this->data['shifts'] = $shiftoption + array('all' => 'Gabungan');
     $this->data['fleets'] = Kso::join('fleets', 'fleets.id', '=', 'ksos.fleet_id')->where('ksos.pool_id', '=', $pool_id)->where('ksos.actived', '=', 1)->get(array('ksos.id', 'ksos.fleet_id', 'fleets.taxi_number'));
     return View::make('themes.modul.' . $this->views . '.rekapsetoranarmada', $this->data);
 }
Exemplo n.º 7
0
 public function get_reportdaily($date = false)
 {
     Log::write('info', Request::ip() . ' User : '******' Event: Read report', true);
     if (!$date) {
         $date = date('Y-m-d');
     }
     $timestamp = strtotime($date);
     $shifts = Shift::all();
     $this->data['shifts'] = Koki::to_dropdown($shifts, 'id', 'shift');
     $this->data['report_daily'] = DB::table('financial_report_daily')->where_pool_id(Auth::user()->pool_id)->get();
     //return json_encode($report_daily);
     return View::make('themes.modul.' . $this->report . '.dailyreport', $this->data);
 }
Exemplo n.º 8
0
 public function get_reportmonthly($date = false)
 {
     Log::write('info', Request::ip() . ' User : '******' Event: Read report Kas', true);
     if (!$date) {
         $date = date('Y-m-d');
     }
     $timestamp = strtotime($date);
     $shifts = Shift::all();
     $shiftoption = Koki::to_dropdown($shifts, 'id', 'shift');
     $this->data['shifts'] = $shiftoption + array('all' => 'Gabungan');
     return View::make('themes.modul.' . $this->report . '.monthreport', $this->data);
 }
Exemplo n.º 9
0
 public function get_ps()
 {
     $this->data['create'] = true;
     $this->data['suppliers'] = Koki::to_dropdown(Supplier::all(), 'id', 'company_name');
     //var_dump($this->data['suppliers'] );
     return View::make('themes.modul.' . $this->views . '.penerimaansp-jquery', $this->data);
 }
Exemplo n.º 10
0
 public function get_detail($id = false, $id_group = false)
 {
     if (!$id || !$id_group) {
         return false;
     }
     $group = Schedulegroup::find($id_group);
     $interval = Schedulemaster::find($group->schedule_master_id);
     $dayofmonth = array();
     $optionsmonth = array();
     $optionsyears = array();
     for ($i = 1; $i <= $interval->bravo_interval + 1; $i++) {
         $dayofmonth[$i] = $i;
     }
     for ($month = 1; $month <= 12; $month++) {
         $optionsmonth[$month] = Myfungsi::bulan($month);
     }
     for ($year = date('Y'); $year < date('Y') + 3; $year++) {
         $optionsyears[$year] = $year;
     }
     $this->data['fleets'] = Schedulefleetgroup::where('schedule_group_id', '=', $id_group)->get();
     $this->data['group'] = Schedulegroup::find($id_group);
     $this->data['dayofmonth'] = $dayofmonth;
     $this->data['months'] = $optionsmonth;
     $this->data['years'] = $optionsyears;
     $this->data['shifts'] = Koki::to_dropdown(Shift::all(), 'id', 'shift');
     $this->data['fleetinfo'] = Fleet::join('ksos', 'fleets.id', '=', 'ksos.fleet_id')->where('ksos.fleet_id', '=', $id)->where('ksos.actived', '=', 1)->where('fleets.pool_id', '=', Auth::user()->pool_id)->first();
     //->get(array('fleets.*','ksos.bravo_driver_id', 'ksos.charlie_driver_id'));
     return View::make('themes.modul.' . $this->views . '.setholiday', $this->data);
 }
Exemplo n.º 11
0
 public function get_qzspj()
 {
     $shifts = Shift::all();
     $this->data['shifts'] = Koki::to_dropdown($shifts, 'id', 'shift');
     return View::make('themes.modul.' . $this->views . '.qzcheckouts', $this->data);
 }