/** * 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 = Purchinforec::model()->findByPk((int) $id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionGeneratedetail() { if (isset($_POST['productid']) & isset($_POST['supplierid']) & isset($_POST['prmaterialid'])) { $sodetail = Prmaterial::model()->findbysql('select * from prmaterial a inner join prheader b on b.prheaderid = a.prheaderid where prmaterialid = ' . $_POST['prmaterialid'] . ' and productid = ' . $_POST['productid'] . ' and qty > giqty ' . ' and b.prno is not null'); $pirdetail = Purchinforec::model()->findbyattributes(array('addressbookid' => $_POST['supplierid'], 'productid' => $_POST['productid'])); echo CJSON::encode(array('status' => 'success', 'gidetailid' => $sodetail->prmaterialid, 'prno' => $sodetail->prheader !== null ? $sodetail->prheader->prno : "", 'productid' => $sodetail->productid, 'productname' => $sodetail->product !== null ? $sodetail->product->productname : "", 'giqty' => $sodetail->qty - $sodetail->giqty, 'unitofmeasureid' => $sodetail->unitofmeasureid, 'uomcode' => $sodetail->unitofmeasure !== null ? $sodetail->unitofmeasure->uomcode : "", 'slocid' => $sodetail->prheader->slocid, 'itemtext' => $sodetail->itemtext)); Yii::app()->end(); } }