|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace backend\controllers; |
|
|
namespace backend\controllers; |
|
|
|
|
|
|
|
|
|
|
|
use common\models\Order ; |
|
|
|
|
|
|
|
|
class SubscriptionController extends BackendController |
|
|
class SubscriptionController extends BackendController |
|
|
{ |
|
|
{ |
|
|
var $enableCsrfValidation = false; |
|
|
var $enableCsrfValidation = false; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Crée une commande récurrente. |
|
|
|
|
|
|
|
|
* Crée un abonnement. |
|
|
* |
|
|
* |
|
|
* @return string |
|
|
* @return string |
|
|
*/ |
|
|
*/ |
|
|
public function actionCreate() |
|
|
|
|
|
|
|
|
public function actionCreate($idOrder = 0) |
|
|
{ |
|
|
{ |
|
|
// form |
|
|
// form |
|
|
$model = new SubscriptionForm; |
|
|
$model = new SubscriptionForm; |
|
|
$model->id_producer = Producer::getId(); |
|
|
$model->id_producer = Producer::getId(); |
|
|
|
|
|
|
|
|
|
|
|
if($idOrder) { |
|
|
|
|
|
$order = Order::searchOne(['id' => $idOrder]); |
|
|
|
|
|
if ($order) { |
|
|
|
|
|
$model->id_user = $order->id_user; |
|
|
|
|
|
$model->username = $order->username; |
|
|
|
|
|
$model->id_point_sale = $order->id_point_sale; |
|
|
|
|
|
$model->date_begin = date('d/m/Y') ; |
|
|
|
|
|
$dateDay = strtolower(date('l',strtotime($order->distribution->date))) ; |
|
|
|
|
|
$model->$dateDay = 1 ; |
|
|
|
|
|
$model->week_frequency = 1 ; |
|
|
|
|
|
if($model->id_user && Producer::getConfig('credit')) { |
|
|
|
|
|
$model->auto_payment = 1 ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// produits |
|
|
|
|
|
foreach ($order->productOrder as $productOrder) { |
|
|
|
|
|
$model->products['product_' . $productOrder->id_product] = $productOrder->quantity; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
throw new NotFoundHttpException('La commande est introuvable.', 404); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// produits |
|
|
// produits |
|
|
$productsArray = Product::searchAll() ; |
|
|
$productsArray = Product::searchAll() ; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Modifie une commande récurrente. |
|
|
|
|
|
|
|
|
* Modifie un abonnement. |
|
|
* |
|
|
* |
|
|
* @param integer $id |
|
|
* @param integer $id |
|
|
* @return string |
|
|
* @return string |