Ejemplo n.º 1
0
 private function addOrUpdateOrderMilestones($id, $ordermilestone, $isFromOrder = true){
     if(!isset($ordermilestone->order))
     {
         return;
     }
     if(isset($ordermilestone->order->id))
     {
         $orderid = $ordermilestone->order->id;
     }else
     {
         $orderid = -1;
     }
     try{
         $order = \Order::find($orderid);
     }catch (\ActiveRecord\RecordNotFound $ex) 
     {
         $order = null;
     }
     if(is_null($order))
     {
         return;
     }
     try{
         try{
             $data = \Milestone::find($id);
         }catch (\ActiveRecord\RecordNotFound $ex) {
             $data = null;
         }
         $attributes = $this->getAttrFormilestonesFromPost($ordermilestone);
         $attributes["order_id"] = $order->id;
         if(is_null($data)){
             $data = \Milestone::create($attributes);
         }else{
             $data->update_attributes($attributes);
         }
         $rtnmsg = "OK";
     }
     catch (\Slim\Exception $ex) {
         $rtnmsg = "Error";
     }
     catch (\Exception $ex) {
         $rtnmsg = "Error";
     }
     return $rtnmsg;
 }