/**
  * 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 = Orderproduct::model()->findByPk( $id );
     if ( $model === null )
         throw new CHttpException( 404, 'The requested page does not exist.' );
     return $model;
 }
Exemplo n.º 2
0
    public function getExistingSubModelId($id, $product_id)
    {
        $condition = 'order_id=' . $id;
        $condition .= ' AND product_id = ' . $product_id;

        $criteria = new CDbCriteria;
        $criteria->select = array( 'id' );
        $criteria->condition = $condition;
        $result = Orderproduct::model()->findAll( $criteria );
        return ((count($result) === 0)? -1:$result[0]['id']);
    }
Exemplo n.º 3
0
 private function deleteOrderlitemsByOrder($orderid, $ordertype){
     $conditions = array('order_id=? AND order_type=?', $orderid, $ordertype);
     $result = \Orderproduct::find('all', array('conditions' => $conditions));
     foreach($result as $data){
         $stck = $data->quantity;
         $prdid = $data->product_id;
         $data->delete();
         if($this->enablestock && !$this->enableordrdn){
             $prd = \Product::find($prdid);
             if($prd){
                 $newstock= $prd->stock + $stck;
                 $attributes = array(
                     "stock" => $newstock,
                     "stockvalue" => $newstock * $prd->unit_cp);
                 $prd->update_attributes($attributes);
             }
         }
     }
 }
Exemplo n.º 4
0
 public function renderPOSTypeDashboard()
 {       
     if($this->isSales())
     {
         $this->redirect( Yii::app()->createUrl('order/' . Helper::CONST_posclient) );
     }else
     {
         $customerduemodel = new Person;
         $customerduemodel->unsetAttributes();
         $productpricemodel = new Subproductprice;
         $productpricemodel->unsetAttributes();
         $orderproductmodel = new Orderproduct;
         $orderproductmodel->unsetAttributes();
         $this->render( $this->getView('index','index'),
                     array(
                         'customerduemodel' => $customerduemodel, 
                         'productpricemodel' => $productpricemodel,
                         'orderproductmodel' => $orderproductmodel,
                         )
                 );
     }        
 }
Exemplo n.º 5
0
 public function actionDailyItemSales()
 {
     $model = new Orderproduct( 'dailyitemsales' );
     $model->unsetAttributes();  // clear any default values
     //$model->groupby = Helper::CONST_Product;
     if ( isset( $_GET['Orderproduct'] ) )
         $model->attributes = $_GET['Orderproduct'];
     
     if(!empty( $_GET['actionid'] ) && $_GET['actionid'] == Helper::CONST_PDF)
     {
         $html = $this->renderPartial( Helper::CONST_dailyItemSales, array(
                     'model' => $model,
                 ),true );
         $this->writeToPdf( $html );
     }
     else
     {
         $this->render( Helper::CONST_dailyItemSales, array(
             'model' => $model,
         ) );
     }
 }