protected function getBarcodeId() { $result = Productprice::model()->findAll(); if ( count( $result ) > 0 ) { $listdata = CHtml::listData( $result, 'id', 'sku' ); } else { $listdata = CHtml::listData( array ( ), 'id', 'sku' ); } return $listdata; }
public function actionGetAllProducts() { $json = new CArJSON; $criteria=new CDbCriteria; $criteria->order='id asc'; $criteria->addCondition('parent_id = 0 and status=1'); $catwithproducts = Category::model()->findAll($criteria); $prdcondition = array('condition'=>'t.status = 1 AND product.status = 1'); $products = Subproductprice::model()->with('product') ->findAll($prdcondition); $prdcondition_non_mngd = array('condition'=>'t.status = 1 AND product.status = 1 AND t.dontsyncwithstock = 1'); $non_mngd_products = Productprice::model()->with('product') ->findAll($prdcondition_non_mngd); if(!empty($catwithproducts) && !empty($products) ) { //$relations = array(array('categories'=>array(array('products'=>array('taxrate'))))); $relations = array(array('categories'=>array('subproductprices'))); $attributes = array( 'root' => array(),//null,//array of attribute names 'categories' => array(), 'subproductprices' => $this->prdcolumns, ); $isarray = true; $iskeybasedarray = true; $sec_cat_products = $json->toJSON($catwithproducts, $relations, $attributes, $isarray, $iskeybasedarray); $relations = array(); $attributes = array( 'root' => $this->prdcolumns, ); $isarray = true; $iskeybasedarray = true; $non_mngd_products = $json->toJSON($non_mngd_products, $relations, $attributes, $isarray, $iskeybasedarray); $relations = array(); $attributes = array( 'root' => array('value','label'), ); $isarray = true; $iskeybasedarray = false; $allproducts_short = $json->toJSON($products, $relations, $attributes, $isarray, $iskeybasedarray); $customercondition = array(); $customers = $this->getAllPeopleNoRestriction(Helper::CONST_Customer); $allcustomers = CHtml::listData($customers, 'id', 'name'); $dfltcustomerid = $this->getPersonByName(Helper::CONST_Walk_in_Customer); $data = array( //Helper::CONST_prdskuToIdMap => $prdskuToIdMap, Helper::CONST_allproducts_short => $allproducts_short, Helper::CONST_non_mngd_products => $non_mngd_products, Helper::CONST_sec_cat_products => $sec_cat_products, Helper::CONST_allcustomers => $allcustomers, Helper::CONST_default_customer_id => $dfltcustomerid ); $rtnCode = Helper::CONST_Error_None; $message = Helper::CONST_POS_Masters; } else { $data = array( Helper::CONST_allproducts_short => array(), Helper::CONST_non_mngd_products => array(), Helper::CONST_sec_cat_products => array(), Helper::CONST_allcustomers => array(), Helper::CONST_default_customer_id => -1 ); $rtnCode = Helper::CONST_Error_None; $message = Helper::CONST_NotFound_Message; } // $edata = $this->getJsonOfData($rtnCode, $data, $message); // $this->writeToCookie(Helper::CONST_sec_cat_products, $edata); $this->returnJsonResponse($rtnCode, $data, $message); }
public function actionStockReport() { $model = new Productprice('stockreport'); $model->unsetAttributes(); if ( isset( $_GET['Productprice'] ) ) $model->attributes = $_GET['Productprice']; $this->render('stockreport', array( 'model' => $model, )); }
public function actionGetPricesForAProduct() { $postedData = $this->getPostedData(); $id = $postedData['Productprice_id']; $rowsql = "select invno from productprices where id=$id"; $invno = Yii::app()->db->createCommand( $rowsql )->queryScalar(); $rowsql ='select pp.code,pp.sku,pp.invno,pp.invdate from products p JOIN productprices pp on pp.product_id=p.id where pp.invno="inv001"'; $result = Yii::app()->db->createCommand( $rowsql )->queryAll(); $data=$result; $record = Product::model() ->with(array( 'productprices' => array('condition'=>'productprices.invno='.'"'.$invno.'"'), ) )->together()->findAll(); // return $record; $condition = 'invno='.'"'.$invno.'"'.' AND product_id= '.$postedData['Product_id']; $criteria = new CDbCriteria; $criteria->condition = $condition; $record = Productprice::model()->findAll( $criteria ); $json = new CArJSON; $relations = array(); $attributes = array( ); $isarray = true; $product = $json->toJSON($record, $relations, $attributes, $isarray); // return true; if(empty($product)) { return false; } else{ $RetCode ='success'; return $this->returnJsonResponse($RetCode , $record , 'Success'); } //*********************************** // $criteria->with =array(); $postedData = $this->getPostedData(); $product_id = $postedData['product_id']; $criteria=new CDbCriteria; $criteria->addCondition('status = 1'); $data = Product::model()->findByPk($product_id, $criteria); if(!empty($data)) { $json = new CArJSON; $relations = array(array('productprices'=>array('supplier'))); // array('product') or array(array('product'=>array('taxrate'))) $attributes = array( 'root' => array('id','name'),//null,//array of attribute names 'productprices'=> array(), 'supplier' => array('id','lookupDisplay'),//null,//array of attribute names ); $isarray = true; $data = $json->toJSON($data, $relations, $attributes, $isarray); $rtnCode = Helper::CONST_Error_None; $message = Helper::CONST_PRDPRICES_LIST; } else { $rtnCode = Helper::CONST_Error_None; $message = Helper::CONST_NotFound_Message; } $rtnCode = Helper::CONST_Error_None; $message = Helper::CONST_NotFound_Message; $this->returnJsonResponse($rtnCode, $data, $message); }