change cart to plain post from ajax

This commit is contained in:
2016-01-04 22:02:59 +01:00
parent 2d9b527909
commit 1e206011d0
27 changed files with 622 additions and 349 deletions

View File

@@ -63,19 +63,26 @@ class ShoppingCart extends \yii\db\ActiveRecord
return $transfers;
}
public static function payout( $customer) {
public static function payout( $customer, $idTransfers) {
//apply transfer object
//delete cart
$sql = "UPDATE transfer AS t
INNER JOIN shopping_cart AS s ON t.id_transfer = s.id_transfer
SET t.status = " . Transfer::STATUS_PAID . ", t.paid_at = '" . date('Y-m-d H:i:s' ) ."'"
SET t.paid_by = ".\Yii::$app->user->id.", t.status = " . Transfer::STATUS_PAID . ", t.paid_at = '" . date('Y-m-d H:i:s' ) ."'"
. " WHERE t.status = " . Transfer::STATUS_NOT_PAID
. " and s.id_customer = " . $customer->id_customer ;
. " and s.id_customer = " . $customer->id_customer
. " and t.id_transfer in ( '" . implode("','", $idTransfers )."' )";
$q1 = Yii::$app->db->createCommand($sql);
$q1->execute();
ShoppingCart::deleteAll(['id_customer' => $customer->id_customer]);
// ShoppingCart::deleteAll(['id_customer' => $customer->id_customer]);
if ( isset($idTransfers) ){
ShoppingCart::deleteAll(['and' ,['id_customer' => $customer->id_customer] ,['in','id_transfer',$idTransfers] ]);
}else{
ShoppingCart::deleteAll(['id_customer' => $customer->id_customer]);
}
}