public function save() { $order = Zakaz::model()->findByPk($this->orderId); if ($order && $this->file instanceof CUploadedFile && ($order->status == 2 || $order->status == 3 || $order->status == 4)) { $dir = Yii::getPathOfAlias('webroot') . self::$folder; if (!is_dir($dir)) { mkdir($dir, 0775, true); } $paymentImage = new PaymentImage(); $paymentImage->project_id = $order->id; $paymentImage->image = md5(uniqid('')) . '.' . $this->file->extensionName; $paymentImage->save(false); //$order->status = 3; //$order->save(false); $this->file->saveAs($dir . $paymentImage->image); } }
public function actionUploadPayment($id) { $folder = Yii::getPathOfAlias('webroot') . PaymentImage::getFolder(); $result = Tools::uploadMaterials($folder, false); echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); if ($result['success'] && User::model()->isCustomer()) { $paymentImage = new PaymentImage(); $paymentImage->project_id = $id; $paymentImage->image = $result['fileName']; $paymentImage->save(false); EventHelper::chekUploaded($id); } }