add product sale changes

This commit is contained in:
2015-10-01 09:37:34 +02:00
parent 7128cd438d
commit e3d6c0b902
34 changed files with 1801 additions and 1 deletions

View File

@@ -8,12 +8,19 @@ use frontend\models\ProductSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use frontend\models\ProductSaleForm;
use common\models\Card;
use common\models\Customer;
/**
* ProductController implements the CRUD actions for Product model.
*/
class ProductController extends Controller
{
protected $card;
protected $customer;
public function behaviors()
{
return [
@@ -26,6 +33,21 @@ class ProductController extends Controller
];
}
public function actionSale( $number = null){
$this->findByNumber($number);
$model = new ProductSaleForm();
return $this->render("sale",[
'customer' => $this->customer,
'card' => $this->card
]);
}
/**
* Lists all Product models.
* @return mixed
@@ -118,4 +140,18 @@ class ProductController extends Controller
throw new NotFoundHttpException('The requested page does not exist.');
}
}
protected function findByNumber($number){
$this->card = null;
$this->customer = null;
if ( $number != null ){
$this->card = Card::readCard($number);
if ( $this->card != null ){
$this->customer = Customer::find()->innerJoin(Card::tableName(), "customer.id_customer_card = card.id_card")->andWhere( [ 'customer.id_customer_card' => $this->card->id_card ])->one();
}
}
}
}