Exemple #1
0
 private function deleteOrderPersonByPpltype($orderid, $ppltype){
     $conditions = array('order_id=? AND type=?', $orderid, $ppltype);
     $result = \Orderperson::find('all', array('conditions' => $conditions));
     foreach($result as $data){
         $data->delete();
     }
 }
 public function updateOrderPeopleFor($model, $person_id, $type)
 {
     $rtn = false;
     $order_id = $model->id;
     $condition = 'order_id=' . $order_id;
     $condition .= ' AND LCASE(type) = "' . strtolower($type) . '"';
     $criteria = new CDbCriteria;
     $criteria->condition = $condition;
     $result = Orderperson::model()->findAll( $criteria );
     if(count($result)>0)
     {
         if(strtolower($type) === strtolower(Helper::CONST_Created)) return true;
         $record = $result[0];
     }
     else
     {
         $record = new Orderperson;
     }
     if(empty($person_id) && !empty($record->id))
     {
         $rtn = $record->delete();
     }
     else
     {
         $record->order_id = $order_id;
         $record->person_id = $person_id;
         $record->type = $type;
         $rtn = $record->save();            
     }
     return $rtn;
 }
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model=Orderperson::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}