<?php namespace myresto\controllers;use Yii;use yii\web\Controller;use myresto\models\ImportTransaction;use myresto\models\SyncConfig;class ImportTransactionController extends Controller{public function actionIndex(){$model=new ImportTransaction();$tipe_tabel=$model->tipe_tabel;$conn=SyncConfig::getConnection();$config=SyncConfig::find()->where(['type_con'=>'resto'])->one();$access_token=$config->api_key;if(isset($_POST['date_start'])){$start=$_POST['date_start'];}else{$start='0000-00-00';}if(isset($_POST['jenis_sinkron'])){$jenis_sinkron=$_POST['jenis_sinkron'];}else{$jenis_sinkron='';}if(isset($_POST['date_end'])){$end=$_POST['date_end'];}else{$end='0000-00-00';}$idHeaderLog=$_POST['idHeaderLog'];$result=$model->ambilData("import",$tipe_tabel,$start,$end,$idHeaderLog);if($result!=NULL){$response=$model->kirimData($result,$access_token);$simpan=$model->simpanStatus($response,$tipe_tabel,$idHeaderLog,$jenis_sinkron,$result);$echo=$simpan;}else{$result=$model->ambilData("reimport",$tipe_tabel,$start,$end,$idHeaderLog);if($result!=NULL){$response=$model->kirimData($result,$access_token);$simpan=$model->simpanStatus($response,$tipe_tabel,$idHeaderLog,$jenis_sinkron,$result);$echo=$simpan;}else{mysqli_query($conn,"UPDATE sync_data SET is_sync = '0' WHERE id_jurnal = '0' AND tipe_tabel = '$tipe_tabel'");$echo="tran";}}return $echo;}}