/**
* 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=Accountpurchase::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
Ejemplo n.º 2
0
 private function saveAccountPurchases($purchases, $accountId){
     if(!isset($purchases)) return;
     foreach($purchases as $puchase){
         $ordertaskId = -1;
         $dummyorderid = 1;
         $purchaseId = (!is_null($puchase->id))?$puchase->id:0;
         if($purchaseId === 0) continue;
         $attributes = array(
                     "account_id" => $accountId,
                     "purchase_id" => $purchaseId,
                     );
         \Accountpurchase::create($attributes);
         $tmp = \Purchase::find($purchaseId);
         if(!is_null($tmp)){
             $attributes = array(
                         "status" => Menu::sts_closed,
                         "invstatus" => Menu::sts_invoiced
                         );
             $tmp->update_attributes($attributes);
         }
     }
 }