public function actionStockReport()
   {           
       $model = new Productprice('stockreport'); 
       $model->unsetAttributes();
       if ( isset( $_GET['Productprice'] ) )
        $model->attributes = $_GET['Productprice'];
                      $this->render('stockreport', array(
            'model' => $model,
          ));
              
   }
Ejemplo n.º 2
0
    public function actionBulkAddProductsAjax()
    {
        if(empty($_POST['Product']))
        {
            $model = new Productprice( 'search' );
            $model->unsetAttributes();  // clear any default values
            if ( isset( $_GET['Product'] ) )
                $model->attributes = $_GET['Product'];

            $this->render( Helper::CONST_bulkAddProductsAjax, array(
                'model' => $model,
            ) );
            return;
        }
        $rtn = false;
        $failcount = 0;
        try 
        {
            $postedObjs = isset($_POST['Product'])?$_POST['Product']:array();
            foreach($postedObjs as $prdprcId => $obj)
            {
                $extcatid = -1;
                $extimgpath = null;                
                $model = $this->getObject(null);
                $model->category_id = $obj['category_id'];
                $model->name = $obj['product_id'];
                $removedprices = array();
                $existingprices = array();
                $newprices = array($obj['Productprice']);
                $rtn = $this->saveMultipriceProduct($model, $extcatid, $extimgpath, $newprices, $removedprices, $existingprices);
                if(!$rtn) $failcount++;
            }
        }catch (Exception $e) {
            $rtn = false;
            $failcount++;
            Yii::log("Error in updating stock. Rolling back... . Failure reason as reported in exception: " . $e->getMessage(), CLogger::LEVEL_ERROR, __METHOD__);
        }
        if($failcount == 0)
        {
            $data = Yii::app()->createUrl('productprice/admin');
            $rtnCode = Helper::CONST_Error_None;
            $message = Helper::CONST_Record_Updated;
        }
        else
        {
            $data = array();
            $rtnCode = Helper::CONST_SaveError;
            $message = Helper::CONST_Error_SomeOfRecordsFailed . "[$failcount]";
        }
        $this->returnJsonResponse($rtnCode, $data, $message);
    }