コード例 #1
0
ファイル: UserSetting.php プロジェクト: Jagus/study_project
 public static function initialize($user_id)
 {
     $us = UserSetting::find()->where(['user_id' => $user_id])->one();
     if (is_null($us)) {
         $us = new UserSetting();
         $us->user_id = $user_id;
         $us->filename = '';
         $us->avatar = '';
         $us->reminder_eve = self::SETTING_YES;
         $us->no_email = self::SETTING_NO;
         $us->contact_share = self::SETTING_YES;
         $us->reminder_hours = 48;
         $us->save();
     }
     return $us->id;
 }
コード例 #2
0
ファイル: SignupForm.php プロジェクト: sea129/kbay
 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->save()) {
             $userSetting = new UserSetting();
             $userSetting->user_id = $user->id;
             if ($userSetting->save()) {
                 return $user;
             }
         }
     }
     return null;
 }
コード例 #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = UserSetting::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     return $dataProvider;
 }
コード例 #4
0
ファイル: UserSettingSearch.php プロジェクト: sea129/kbay
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = UserSetting::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['user_id' => $this->user_id, 'min_cost_tracking' => $this->min_cost_tracking, 'fastway_indicator' => $this->fastway_indicator]);
     return $dataProvider;
 }
コード例 #5
0
ファイル: OrderController.php プロジェクト: sea129/kbay
 /**
  * Loop orders and get shipping label
  */
 private function getShippingLabel($orders)
 {
     $label = '';
     //return count($orders);
     $userSetting = UserSetting::findOne(Yii::$app->user->id);
     $orderIndex = 0;
     $eParcelHelper = new EparcelHelper();
     foreach ($orders as $key => $order) {
         $packSign = ['eParcel' => false, 'fastway' => false, 'express' => false, 'buyerCount' => 1, 'checkoutMessage' => false, 'weight' => 0, 'totalCost' => 0];
         $transLabel = '';
         foreach ($order['ebayTransactions'] as $transaction) {
             if ($product = $transaction->getProduct()->one()) {
                 $packSign['weight'] += $product['weight'] * $transaction['qty_purchased'];
                 $packSign['totalCost'] += $product['cost'] * $transaction['qty_purchased'];
             } else {
                 $transLabel .= "Error! Can't find the product " . $transaction['item_sku'];
             }
             $transLabel .= $this->renderPartial('_translabel', ['transaction' => $transaction]);
         }
         $packSign['weight'] = round($packSign['weight'] / 1000, 2);
         $packSign['fastway'] = $userSetting->fastway_indicator && JHelper::isFastwayAvailable($order['recipient_postcode']);
         if ($packSign['totalCost'] >= $userSetting->min_cost_tracking) {
             $packSign['eParcel'] = true;
         }
         if ($order['shipping_service'] == 'AU_ExpressDelivery' || $order['shipping_service'] == 'AU_Express' || $order['shipping_service'] == 'AU_ExpressWithInsurance') {
             $packSign['express'] = true;
         }
         if ($order->buyerCount > 1) {
             $packSign['buyerCount'] = $order->buyerCount;
         }
         if ($order['checkout_message'] != NULL) {
             $packSign['checkoutMessage'] = true;
         }
         $label .= $this->renderPartial('label', ['order' => $order, 'transLabel' => $transLabel, 'packSign' => $packSign, 'orderIndex' => $orderIndex]);
         $orderIndex++;
         $eParcelHelper->addExcelRow($order, $packSign['weight']);
     }
     return ['label' => $label, 'excelObj' => $eParcelHelper];
 }
コード例 #6
0
 /**
  * Finds the UserSetting model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return UserSetting the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = UserSetting::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }