コード例 #1
0
    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();
         $condition = 'invno='.'"'.$invno.'"';
         $criteria = new CDbCriteria;
         $criteria->condition = $condition; 
         $record = Productprice::model()->findAll( $criteria ); 
         $json = new CArJSON;			   

            $relations = array('supplier');
            // array('product') or array(array('product'=>array('taxrate')))            
            $attributes = array(
                'root' => array(),//null,//array of attribute names
                'supplier' => array('id','lookupDisplay'),//null,//array of attribute names
            );
            $isarray = true;			
              $product = $json->toJSON($record, $relations, $attributes, $isarray);
			 // return true;
            if(empty($product))
            {
			return false;
            }
			else{
			$RetCode ='success';
			return $this->returnJsonResponse($RetCode , $product , 'Success');			
			}

    }
コード例 #2
0
  public function actionGetPricesForAProduct()
 {
     $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('subproductprices'=>array('supplier')));        
         $attributes = array(
             'root' => array('id','name'),//null,//array of attribute names
             'subproductprices'=> 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;
     }
     $this->returnJsonResponse($rtnCode, $data, $message);
 }
コード例 #3
0
 public function actionGetOrderProductsForABill()
 {
     $postedData = $this->getPostedData();
     $qoi_id = $postedData['billnumber'];
     $criteria=new CDbCriteria;
     $criteria->with = array('statusmaster');
     $criteria->compare('LCASE(qoi_id)',strtolower($qoi_id));
     $stsary = array(
         strtolower(Helper::CONST_REFUNDOLD),
         strtolower(Helper::CONST_REFUNDNEW),
         strtolower(Helper::CONST_CANCELOLD),
         strtolower(Helper::CONST_CANCELNEW)
                 );
     $criteria->addNotInCondition('LCASE(statusmaster.name)', $stsary);
     $data = Order::model()->findAll($criteria);
     if(!empty($data))
     {
         $json = new CArJSON;
         // Define which relations do you want to load
         //$relations = array('product');            
         $relations = array(array('orderproducts'=>array('productprice')));
         // array('product') or array(array('product'=>array('taxrate')))
         // Define which attributes, foreach relations do you want to load
         // root denote attributes for the main model  
         $attributes = array(
             'root' => array('id','disc','roundoff'),//null,//array of attribute names
             'orderproducts'=> array(),
             'productprice' => $this->prdcolumns,
             //'taxrate' => array(),
         );
         $isarray = true;
         $data = $json->toJSON($data, $relations, $attributes, $isarray);
         $rtnCode = Helper::CONST_Error_None;
         $message = Helper::CONST_ORDERPRD_LIST;
     }
     else
     {
         $rtnCode = Helper::CONST_Error_None; 
         $message = Helper::CONST_NotFound_Message;
     }
     //$edata = $this->getJsonOfData($rtnCode, $data, $message);
     //$this->writeToCookie(Helper::CONST_orderproducts, $edata);
     $this->returnJsonResponse($rtnCode, $data, $message);
 }
コード例 #4
0
    public function actionJobs()
    {
        $result = null;
        try
        {
            $orderstatus = Helper::CONST_ExceptOpenRejected;
            $forthedate = (!empty($postedData['slotdate'])?$postedData['slotdate']:null);
            $result = $this->getMyOrders($orderstatus, $forthedate);
            if(!empty($result))
            {
                $json = new CArJSON;
                // Define which relations do you want to load
                $relations = array('ordrcustomers', 'blngaddresses', 'shpngaddresses', 'ordrreceivers' , 'statusmaster');
                // Define which attributes, foreach relations do you want to load
                // root denote attributes for the main model
                $attributes = array(
                    'root' => array('id', 'type', 'qoi_id', 'name', 'desc'
                        , 'addnlinfo', 'addnlinfo1', 'addnlinfo3', 'addnlinfo4', 'remarks','status'),
                    'ordrcustomers' => array('id', 'name', 'firstname', 'lastname', 'mobile'),
                    'blngaddresses' => array( 'id', 'street', 'pincode' ),
                    'shpngaddresses' => array( 'id', 'street', 'pincode' ),                    
                    'ordrreceivers' => array( 'name', 'mobile' ),
                    'statusmaster' => array( 'display'),
                );
//blngaddresses shpngaddresses ordrcustomers ordrreceivers
                $isarray = true;
                $data = $json->toJSON($result, $relations, $attributes, $isarray);
                $rtnCode = Helper::CONST_Error_None;
                $message = Helper::CONST_ORDER_LIST;
                $this->returnJsonResponse($rtnCode, $data, $message);                
            }
        }
        catch(Exception $e)
        {
            $result = null;
        }
        $rtnCode = Helper::CONST_InternalServerError;
        $message = Helper::CONST_ORDER_FETCH_FAIL;
        $data = array();
        $this->returnJsonResponse($rtnCode, $data, $message);
    }