39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace frontend\controllers;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
use common\models\Electric;
|
||
|
|
use Yii;
|
||
|
|
use yii\base\Exception;
|
||
|
|
|
||
|
|
class ElectricController extends \yii\web\Controller
|
||
|
|
{
|
||
|
|
public function actionIndex()
|
||
|
|
{
|
||
|
|
$model = new Electric();
|
||
|
|
|
||
|
|
if($model->load(Yii::$app->request->post()) && $model->save()) {
|
||
|
|
try {
|
||
|
|
$model->map = $model->uploadElectric($model, 'map');
|
||
|
|
Yii::$app->session->setFlash('success', 'บันทึกข้อมูลเรียบร้อยแล้ว กรุณารอการติดต่อกลับจากเจ้าหน้าที่');
|
||
|
|
Yii::$app->hanuman->sendNotify('มีการแจ้งแบบคำร้องขอซ่อมไฟฟ้า/ไฟสาธารณะ');
|
||
|
|
} catch (Exception $exception) {
|
||
|
|
Yii::$app->session->setFlash('error', $exception->getMessage());
|
||
|
|
}
|
||
|
|
|
||
|
|
return $this->redirect(['index']);
|
||
|
|
}else{
|
||
|
|
|
||
|
|
//var_dump($model->getFirstErrors());
|
||
|
|
}
|
||
|
|
|
||
|
|
return $this->render('index', [
|
||
|
|
'model' => $model
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|