public static function uploadHelper($file) { $imgurKey = AppSetting::findOne('imgur_key')->string_value; $imgurSecret = AppSetting::findOne('imgur_secret')->string_value; $imgurToken = AppSetting::findOne('imgur_token')->string_value; $cacher = new FilesystemCache('/tmp'); $uploader = RemoteImageUploader\Factory::create('Imgur', array('cacher' => $cacher, 'api_key' => $imgurKey, 'api_secret' => $imgurSecret, 'refresh_token' => $imgurToken, 'auto_authorize' => false, 'username' => '', 'password' => '')); $uploader->authorize(); $url = $uploader->upload($file); return $url; }
/** * get how many listings to be sync.so that I can get how many pages */ public function getPreListingInfo() { $request = $this->activeListReqInit(); $appSetting = \common\models\setting\AppSetting::findOne('listing_sync_entries_per_page'); $request->ActiveList->Pagination = new Types\PaginationType(); $request->ActiveList->Pagination->EntriesPerPage = $appSetting->number_value; $service = $this->tradingServiceInit(); $response = $service->getMyeBaySelling($request); $result = $this->getResponseError($response); if ($response->Ack !== 'Failure' && isset($response->ActiveList)) { $result['data'] = $response->ActiveList->PaginationResult->TotalNumberOfEntries; $result['totalPages'] = $response->ActiveList->PaginationResult->TotalNumberOfPages; } else { $result['Error'][] = \Yii::t('app/listing', 'connect Failure', []); } return $result; }
}], ['attribute' => 'create_to', 'value' => function ($model, $key, $index, $column) { if ($model['create_to']) { $date = new DateTime($model['create_to'], new DateTimeZone('GMT')); $date->setTimezone(new DateTimeZone('Australia/Sydney')); return $date->format('Y-m-d H:i:s'); } else { return null; } }], 'complete_at', ['attribute' => 'status', 'value' => function ($model, $key, $index, $column) { if ($model['status']) { return $model['status'] == 1 ? 'Init' : 'Completed'; } else { return null; } }], ['class' => 'yii\\grid\\ActionColumn', 'header' => Yii::t('app/order', 'Not Paid', []), 'template' => '{update-not-paid}', 'buttons' => ['update-not-paid' => function ($url, $model, $key) { $appSetting = \common\models\setting\AppSetting::findOne('fetch_order_entries_per_page'); if ($model['Not Paid'] == 0) { return $model['Not Paid']; } else { return Html::button('<span class="ace-icon fa fa-refresh"></span>' . $model['Not Paid'], ['type' => 'button', 'class' => 'btn btn-xs btn-warning btn-update-not-paid', 'data-ebay-id' => $model['ebay_id'], 'data-toggle' => 'modal', 'data-target' => '#update-not-paid-orders-modal']); } }]], ['attribute' => 'Not Shipped'], ['class' => 'yii\\grid\\ActionColumn', 'header' => Yii::t('app/order', 'Get Orders', []), 'template' => '{pre-fetch}', 'buttons' => ['pre-fetch' => function ($url, $model, $key) { return Html::button('<span class="ace-icon fa fa-cart-arrow-down"></span>', ['type' => 'button', 'class' => 'btn btn-xs btn-danger btn-pre-fetch', 'data-ebay-id' => $model['ebay_id'], 'data-toggle' => 'modal', 'data-target' => '#download-orders-modal']); }]]]]); ?> </div> <?php echo Html::endForm(); Modal::begin(['header' => 'Download Orders', 'options' => ['id' => 'download-orders-modal'], 'size' => 'modal-lg', 'clientOptions' => ['backdrop' => 'static', 'keyboard' => false], 'clientEvents' => ['shown.bs.modal' => "function(e){downloadOrdersInit(e);}", 'hidden.bs.modal' => "function(e){location.reload();}"]]); ?> <div class="download-orders-container" style="max-height:500px;min-height:500px;">
/** * Finds the AppSetting model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return AppSetting the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = AppSetting::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
private function commonFetchRequest($createFrom, $createTo) { $appSetting = \common\models\setting\AppSetting::findOne('fetch_order_entries_per_page'); $request = $this->fetchPaidOrderReqInit(); $request->Pagination = new Types\PaginationType(); $request->Pagination->EntriesPerPage = $appSetting->number_value; $request->CreateTimeFrom = $createFrom; $request->CreateTimeTo = $createTo; $request->OrderStatus = 'Completed'; $request->OrderRole = 'Seller'; $request->IncludeFinalValueFee = true; return $request; }