예제 #1
0
 private function updatestatushistory($ofwhich, $ofwhichid, $statusname, $statusdt){//1 -order 2- ordertask etc.,
     $higherflds = array();
     $stsfldtoupdate = $this->getStatusFieldFromName($ofwhich, $statusname, $higherflds);
     if(is_null($stsfldtoupdate))
     {
         return;
     }
     $condition = array('ofwhich_id=?', $ofwhichid);
     $result = \Statushistory::find('all', array('conditions' => $condition));
     $attributes = array(
             "$stsfldtoupdate" => $statusdt                    
             );
     foreach($higherflds as $higerfld){
         $attributes["$higerfld"] = null;
     }
     if(isset($result) && count($result) > 0){
         $recid = isset($result[0]->id)?$result[0]->id:-1;
         try{
             $data = \Statushistory::find($recid);
         }catch (\ActiveRecord\RecordNotFound $ex) {
             $data = null;
         }
         if(!is_null($data)){
             $data->update_attributes($attributes);
         }
     }else{
         $attributes["ofwhich_id"] = $ofwhichid;
         $data = \Statushistory::create($attributes);
     }
 }