<?php namespace myresto\controllers;use Yii;use yii\web\Controller;use myresto\models\UpdateProduct;use myresto\models\SyncConfig;class UpdateProductController extends Controller{public function actionIndex(){$model=new UpdateProduct();$tipe_tabel=$model->tipe_tabel;$conn=SyncConfig::getConnection('MyConnection');$connMyResto=SyncConfig::getConnection('MyResto');$config=SyncConfig::find()->where(['type_con'=>'resto'])->one();$access_token=$config->api_key;$idHeaderLog=$_POST['idHeaderLog'];$result=$model->ambilData($tipe_tabel);if($result!=NULL){$id_lokal=$result['product']['custom_id'];$last_update=$result['product']['last_update'];unset($result['product']['last_update']);$stmt=mysqli_query($conn,"SELECT last_update, id_jurnal FROM sync_to_jurnal WHERE id_record = '$id_lokal' AND tipe_tabel = '$tipe_tabel' AND tipe_proses = 'new' ORDER BY last_update DESC LIMIT 1");$row=mysqli_fetch_assoc($stmt);$last=$row['last_update'];$idj=$row['id_jurnal'];$stmt=mysqli_query($connMyResto,"SELECT * FROM rst_menu WHERE fpkey = $id_lokal AND fmodifieddt > '$last'");$row=mysqli_fetch_assoc($stmt);if($row>0){$response=$model->kirimData($result,$access_token);$simpan=$model->simpanStatus($response,$tipe_tabel,$id_lokal,$last_update,$idHeaderLog);$echo=$simpan;}else{$arr['product']['id']=$idj;$response=json_encode($arr);$simpan=$model->simpanStatus($response,$tipe_tabel,$id_lokal,$last_update,$idHeaderLog);$echo=$simpan;}}else{$echo="upprod";}return $echo;}}