public function postCommit($sessid)
 {
     $in = Input::get();
     $importkey = $in['edit_key'];
     $selector = $in['selector'];
     $edit_selector = isset($in['edit_selector']) ? $in['edit_selector'] : array();
     foreach ($selector as $selected) {
         $rowitem = Importsession::find($selected)->toArray();
         $do_edit = in_array($selected, $edit_selector);
         if ($importkey != '' && !is_null($importkey) && isset($rowitem[$importkey]) && $do_edit) {
             $obj = $this->model->where($importkey, 'exists', true)->where($importkey, '=', $rowitem[$importkey])->first();
             if ($obj) {
                 foreach ($rowitem as $k => $v) {
                     if ($v != '') {
                         $obj->{$k} = $v;
                     }
                 }
                 $obj->save();
             } else {
                 unset($rowitem['_id']);
                 $rowitem['createdDate'] = new MongoDate();
                 $rowitem['lastUpdate'] = new MongoDate();
                 $rowitem = $this->beforeImportCommit($rowitem);
                 $this->model->insert($rowitem);
             }
         } else {
             unset($rowitem['_id']);
             $rowitem['createdDate'] = new MongoDate();
             $rowitem['lastUpdate'] = new MongoDate();
             $rowitem = $this->beforeImportCommit($rowitem);
             $this->model->insert($rowitem);
         }
     }
     $this->backlink = strtolower($this->controller_name);
     return Redirect::to($this->backlink);
 }
 public function postCommit($sessid)
 {
     $in = Input::get();
     $force_all = $in['force_all'];
     $importkey = $in['edit_key'];
     $edit_selector = isset($in['edit_selector']) ? $in['edit_selector'] : array();
     if ($force_all == 1) {
         $selectall = Importsession::where('sessId', '=', $sessid)->where('isHead', '=', 0)->get()->toArray();
         $selector = array();
         foreach ($selectall as $sel) {
             $selector[] = $sel['_id'];
         }
     } else {
         $selector = $in['selector'];
     }
     $exclude = $this->import_update_exclusion;
     foreach ($selector as $selected) {
         $rowitem = Importsession::find($selected)->toArray();
         $do_edit = in_array($selected, $edit_selector);
         if ($importkey != '' && !is_null($importkey) && isset($rowitem[$importkey]) && $do_edit) {
             $obj = $this->model->where($importkey, 'exists', true)->where($importkey, '=', $rowitem[$importkey])->first();
             $updated_field = array();
             if ($obj) {
                 foreach ($rowitem as $k => $v) {
                     if ($v != '' && $k != '_id') {
                         if (in_array($k, $exclude)) {
                         } else {
                             $obj->{$k} = $v;
                             $updated_field[$k] = $v;
                         }
                     }
                 }
                 //print_r($updated_field);
                 unset($obj->isHead);
                 $obj->lastUpdate = new MongoDate();
                 //print_r($obj);
                 //$obj->save();
             } else {
                 unset($rowitem['_id']);
                 unset($rowitem['isHead']);
                 $rowitem['createdDate'] = new MongoDate();
                 $rowitem['lastUpdate'] = new MongoDate();
                 $rowitem = $this->beforeImportCommit($rowitem);
                 if ($rowitem) {
                     $this->model->insert($rowitem);
                 }
             }
         } else {
             unset($rowitem['_id']);
             $rowitem['createdDate'] = new MongoDate();
             $rowitem['lastUpdate'] = new MongoDate();
             //print_r($rowitem);
             $rowitem = $this->beforeImportCommit($rowitem);
             if ($rowitem) {
                 $this->model->insert($rowitem);
             }
         }
     }
     if (is_null($this->import_commit_url)) {
         $backlink = strtolower($this->controller_name);
     } else {
         $backlink = $this->import_commit_url;
     }
     //print $backlink;
     return Redirect::to($backlink);
 }